agent0-js 0.0.10 → 0.0.12

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/README.md CHANGED
@@ -88,6 +88,13 @@ interface RunOptions {
88
88
  variables?: Record<string, string>; // Variables to pass to the agent
89
89
  overrides?: ModelOverrides; // Runtime model configuration overrides
90
90
  extraMessages?: Message[]; // Extra messages to append to the prompt
91
+ extraTools?: CustomTool[]; // Additional custom tools to add at runtime
92
+ }
93
+
94
+ interface CustomTool {
95
+ title: string; // Unique title for the tool (lowercase with underscores)
96
+ description: string; // Description of what the tool does
97
+ inputSchema?: Record<string, unknown>; // JSON Schema for the tool's parameters
91
98
  }
92
99
 
93
100
  interface ModelOverrides {
@@ -592,6 +599,95 @@ const response = await client.generate({
592
599
  });
593
600
  ```
594
601
 
602
+ ### Custom Tools (extraTools)
603
+
604
+ The `extraTools` option allows you to add custom tool definitions at runtime. These tools are merged with any tools defined in the agent configuration. Custom tools enable function calling without requiring an MCP server - the LLM will generate tool calls, but **execution must be handled externally** by your application.
605
+
606
+ This is useful for:
607
+ - **Dynamic Tool Injection**: Add context-specific tools at runtime
608
+ - **Function Calling Patterns**: Define tools that your application will execute
609
+ - **Hybrid Agents**: Combine MCP server tools with custom tools
610
+
611
+ ```typescript
612
+ // Define custom tools for function calling
613
+ const response = await client.generate({
614
+ agentId: 'agent_123',
615
+ extraTools: [
616
+ {
617
+ title: 'get_weather',
618
+ description: 'Get the current weather for a location',
619
+ inputSchema: {
620
+ type: 'object',
621
+ properties: {
622
+ location: {
623
+ type: 'string',
624
+ description: 'City name or zip code'
625
+ },
626
+ units: {
627
+ type: 'string',
628
+ enum: ['celsius', 'fahrenheit'],
629
+ description: 'Temperature units'
630
+ }
631
+ },
632
+ required: ['location']
633
+ }
634
+ },
635
+ {
636
+ title: 'search_database',
637
+ description: 'Search the company database for information',
638
+ inputSchema: {
639
+ type: 'object',
640
+ properties: {
641
+ query: { type: 'string', description: 'Search query' },
642
+ limit: { type: 'number', description: 'Max results to return' }
643
+ },
644
+ required: ['query']
645
+ }
646
+ }
647
+ ]
648
+ });
649
+
650
+ // The response may contain tool calls that your app needs to handle
651
+ for (const message of response.messages) {
652
+ if (message.role === 'assistant') {
653
+ for (const part of message.content) {
654
+ if (part.type === 'tool-call') {
655
+ console.log('Tool called:', part.toolName);
656
+ console.log('Arguments:', part.args);
657
+ // Execute the tool and provide results back to the agent
658
+ }
659
+ }
660
+ }
661
+ }
662
+ ```
663
+
664
+ **Streaming with Custom Tools:**
665
+
666
+ ```typescript
667
+ const stream = client.stream({
668
+ agentId: 'agent_123',
669
+ extraTools: [
670
+ {
671
+ title: 'lookup_user',
672
+ description: 'Look up user information by ID',
673
+ inputSchema: {
674
+ type: 'object',
675
+ properties: {
676
+ userId: { type: 'string' }
677
+ },
678
+ required: ['userId']
679
+ }
680
+ }
681
+ ]
682
+ });
683
+
684
+ for await (const chunk of stream) {
685
+ if (chunk.type === 'tool-call') {
686
+ console.log(`Tool ${chunk.toolName} called with:`, chunk.args);
687
+ }
688
+ }
689
+ ```
690
+
595
691
  ### Error Handling
596
692
 
597
693
  ```typescript
package/dist/index.d.ts CHANGED
@@ -24,4 +24,4 @@ export declare class Agent0 {
24
24
  */
25
25
  embedMany(options: EmbedManyOptions): Promise<EmbedManyResponse>;
26
26
  }
27
- export type { Agent0Config, EmbedManyOptions, EmbedManyResponse, EmbedModel, EmbedOptions, EmbedResponse, GenerateResponse, ModelOverrides, ProviderOptions, RunOptions, } from "./types";
27
+ export type { Agent0Config, CustomTool, EmbedManyOptions, EmbedManyResponse, EmbedModel, EmbedOptions, EmbedResponse, GenerateResponse, ModelOverrides, ProviderOptions, RunOptions, } from "./types";
package/dist/index.js CHANGED
@@ -30,6 +30,7 @@ class Agent0 {
30
30
  variables: options.variables,
31
31
  overrides: options.overrides,
32
32
  extra_messages: options.extraMessages,
33
+ extra_tools: options.extraTools,
33
34
  stream: false,
34
35
  });
35
36
  return await response.json();
@@ -40,6 +41,7 @@ class Agent0 {
40
41
  variables: options.variables,
41
42
  overrides: options.overrides,
42
43
  extra_messages: options.extraMessages,
44
+ extra_tools: options.extraTools,
43
45
  stream: true,
44
46
  });
45
47
  if (!response.body) {
package/dist/types.d.ts CHANGED
@@ -37,6 +37,19 @@ export interface ModelOverrides {
37
37
  /** Provider-specific options for reasoning/thinking configuration */
38
38
  providerOptions?: ProviderOptions;
39
39
  }
40
+ /**
41
+ * A custom tool defined at runtime.
42
+ * Custom tools have title, description, and inputSchema but no execute function.
43
+ * The LLM will generate tool calls for these, but execution must be handled externally.
44
+ */
45
+ export interface CustomTool {
46
+ /** Unique title for the tool (lowercase with underscores recommended) */
47
+ title: string;
48
+ /** Description of what the tool does - helps the AI understand when to use it */
49
+ description: string;
50
+ /** JSON Schema defining the parameters this tool accepts */
51
+ inputSchema?: Record<string, unknown>;
52
+ }
40
53
  export interface RunOptions {
41
54
  agentId: string;
42
55
  variables?: Record<string, string>;
@@ -44,6 +57,8 @@ export interface RunOptions {
44
57
  overrides?: ModelOverrides;
45
58
  /** Extra messages to append to the agent's prompt (used as-is, no variable substitution) */
46
59
  extraMessages?: ModelMessage[];
60
+ /** Additional custom tools to add at runtime. These are merged with any tools defined in the agent. */
61
+ extraTools?: CustomTool[];
47
62
  }
48
63
  export interface GenerateResponse {
49
64
  messages: ModelMessage[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent0-js",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "TypeScript SDK for Agent0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -17,10 +17,10 @@
17
17
  "typescript": "^5.0.0"
18
18
  },
19
19
  "dependencies": {
20
- "@ai-sdk/google": "3.0.0-beta.81",
21
- "@ai-sdk/openai": "3.0.0-beta.104",
22
- "@ai-sdk/xai": "3.0.0-beta.62",
23
- "ai": "6.0.0-beta.159"
20
+ "@ai-sdk/google": "3.0.0",
21
+ "@ai-sdk/openai": "3.0.0",
22
+ "@ai-sdk/xai": "3.0.0",
23
+ "ai": "6.0.1"
24
24
  },
25
25
  "scripts": {
26
26
  "build": "tsc",
package/src/index.ts CHANGED
@@ -49,6 +49,7 @@ export class Agent0 {
49
49
  variables: options.variables,
50
50
  overrides: options.overrides,
51
51
  extra_messages: options.extraMessages,
52
+ extra_tools: options.extraTools,
52
53
  stream: false,
53
54
  });
54
55
 
@@ -63,6 +64,7 @@ export class Agent0 {
63
64
  variables: options.variables,
64
65
  overrides: options.overrides,
65
66
  extra_messages: options.extraMessages,
67
+ extra_tools: options.extraTools,
66
68
  stream: true,
67
69
  });
68
70
 
@@ -134,6 +136,7 @@ export class Agent0 {
134
136
  // Re-export types for convenience
135
137
  export type {
136
138
  Agent0Config,
139
+ CustomTool,
137
140
  EmbedManyOptions,
138
141
  EmbedManyResponse,
139
142
  EmbedModel,
package/src/types.ts CHANGED
@@ -41,6 +41,20 @@ export interface ModelOverrides {
41
41
  providerOptions?: ProviderOptions;
42
42
  }
43
43
 
44
+ /**
45
+ * A custom tool defined at runtime.
46
+ * Custom tools have title, description, and inputSchema but no execute function.
47
+ * The LLM will generate tool calls for these, but execution must be handled externally.
48
+ */
49
+ export interface CustomTool {
50
+ /** Unique title for the tool (lowercase with underscores recommended) */
51
+ title: string;
52
+ /** Description of what the tool does - helps the AI understand when to use it */
53
+ description: string;
54
+ /** JSON Schema defining the parameters this tool accepts */
55
+ inputSchema?: Record<string, unknown>;
56
+ }
57
+
44
58
  export interface RunOptions {
45
59
  agentId: string;
46
60
  variables?: Record<string, string>;
@@ -48,6 +62,8 @@ export interface RunOptions {
48
62
  overrides?: ModelOverrides;
49
63
  /** Extra messages to append to the agent's prompt (used as-is, no variable substitution) */
50
64
  extraMessages?: ModelMessage[];
65
+ /** Additional custom tools to add at runtime. These are merged with any tools defined in the agent. */
66
+ extraTools?: CustomTool[];
51
67
  }
52
68
 
53
69
  export interface GenerateResponse {