@ton-agent-kit/core 1.0.0 → 1.0.1

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.
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ton-agent-kit/core",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Core SDK for TON Agent Kit — plugin system, wallet abstraction, agent class",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -22,8 +22,19 @@
22
22
  "@ton/ton": ">=14.0.0",
23
23
  "@ton/core": ">=0.63.0"
24
24
  },
25
- "keywords": ["ton", "blockchain", "ai", "agent", "sdk"],
25
+ "keywords": [
26
+ "ton",
27
+ "blockchain",
28
+ "ai",
29
+ "agent",
30
+ "sdk"
31
+ ],
26
32
  "license": "MIT",
27
- "publishConfig": { "access": "public" },
28
- "repository": { "type": "git", "url": "https://github.com/Andy00L/ton-agent-kit.git" }
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "https://github.com/Andy00L/ton-agent-kit.git"
39
+ }
29
40
  }
package/src/agent.ts CHANGED
@@ -202,6 +202,59 @@ export class TonAgentKit {
202
202
  return this.wallet.address.toString();
203
203
  }
204
204
 
205
+ /**
206
+ * Returns OpenAI-compatible function calling tools, ready to use with any LLM provider
207
+ * (OpenAI, Anthropic, Google, Groq, Mistral, OpenRouter, Together).
208
+ */
209
+ toAITools(): Array<{ type: "function"; function: { name: string; description: string; parameters: any } }> {
210
+ return this.getAvailableActions().map((action) => {
211
+ let parameters: any = { type: "object", properties: {} };
212
+
213
+ // Try Zod v4 native toJSONSchema first
214
+ try {
215
+ const { toJSONSchema } = require("zod");
216
+ const schema = toJSONSchema(action.schema);
217
+ const { $schema, ...rest } = schema;
218
+ parameters = { type: "object", properties: {}, ...rest };
219
+ } catch {
220
+ // Fallback: extract property names from Zod schema shape
221
+ try {
222
+ const shape = (action.schema as any)?._def?.shape || (action.schema as any)?.shape;
223
+ if (shape && typeof shape === "object") {
224
+ const props: Record<string, any> = {};
225
+ for (const [key, val] of Object.entries(shape)) {
226
+ const def = (val as any)?._def || (val as any)?.def || {};
227
+ const zodType = def.type || def.typeName || "string";
228
+ let jsonType = "string";
229
+ if (zodType === "number" || zodType === "ZodNumber" || zodType === "float64") jsonType = "number";
230
+ if (zodType === "boolean" || zodType === "ZodBoolean") jsonType = "boolean";
231
+
232
+ const isOptional = zodType === "optional" || zodType === "ZodOptional" || def.type === "optional";
233
+ const innerDef = isOptional ? (def.innerType?.def || def.innerType?._def || {}) : def;
234
+ const innerType = innerDef.type || innerDef.typeName || "string";
235
+ let finalType = "string";
236
+ if (innerType === "number" || innerType === "ZodNumber" || innerType === "float64") finalType = "number";
237
+ if (innerType === "boolean" || innerType === "ZodBoolean") finalType = "boolean";
238
+
239
+ const description = (val as any)?._def?.description || (val as any)?.description || "";
240
+ props[key] = { type: finalType, ...(description ? { description } : {}) };
241
+ }
242
+ parameters = { type: "object", properties: props };
243
+ }
244
+ } catch {}
245
+ }
246
+
247
+ return {
248
+ type: "function" as const,
249
+ function: {
250
+ name: action.name,
251
+ description: action.description,
252
+ parameters,
253
+ },
254
+ };
255
+ });
256
+ }
257
+
205
258
  // ============================================================
206
259
  // Autonomous Agent Loop
207
260
  // ============================================================