@atgs/tapeworm 0.1.2 → 0.1.4

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
@@ -1,8 +1,14 @@
1
- ![Tapeworm Logo](./tapeworm.svg)
1
+ ![Tapeworm Logo](https://raw.githubusercontent.com/andygrace227/tapeworm/main/tapeworm.svg)
2
2
 
3
3
  # Tapeworm
4
4
 
5
- Tapeworm is an in-browser and node agent framework.
5
+ <h3>In-browser and Node agent framework.</h3>
6
+
7
+ [![npm version](https://img.shields.io/npm/v/@atgs/tapeworm.svg?style=flat-square)](https://www.npmjs.org/package/@atgs/tapeworm.svg)
8
+
9
+ [![npm downloads](https://img.shields.io/npm/dm/@atgs/tapeworm?style=flat-square)](https://npm-stat.com/charts.html?package=@atgs/tapeworm)
10
+
11
+ [repo link](https://github.com/andygrace227/tapeworm)
6
12
 
7
13
  This is the root package for Tapeworm. You can consume other packages like @atgs/tapeworm_bedrock for AWS Bedrock support.
8
14
 
@@ -12,53 +18,128 @@ It provides an object-oriented API to create agents that run either on Node or w
12
18
 
13
19
  ## Current Features
14
20
 
15
- - Base API Defined
16
- - Supports `function` tools
17
- - Supports Ollama models
18
-
19
- ## Example
20
-
21
- ```
22
- import {Agent, OllamaModel, Parameter, Tool, ToolSchema} from '../../dist/tapeworm.es.js';
23
-
24
- class SomeTool extends Tool {
25
-
26
- // Get the name of the function
27
- getName() {
28
- return "AdditionTool";
29
- }
30
-
31
- // Tell models what this function does
32
- getDescription() {
33
- return "Adds two numbers together.";
34
- }
21
+ - Base API Defined.
22
+ - Supports `function` tools.
23
+ - Supports Ollama models.
24
+ - Has a Babel plugin to make tool creation really easy.
25
+
26
+ ## Examples
27
+
28
+ #### With the babel plugin (@atgs/@atgs/babel-plugin-tapeworm-decorator) (recommended, super concise)
29
+
30
+ ```js
31
+ @Tool({ description: "Adds 2 numbers together" })
32
+ class AdditionTool extends Tool {
33
+ @TParam({
34
+ name: "a",
35
+ description: "The first number to add",
36
+ required: true,
37
+ type: "number",
38
+ })
39
+ @TParam({
40
+ name: "b",
41
+ description: "The second number to add",
42
+ required: true,
43
+ type: "number",
44
+ })
45
+ @TOutput("The sum of inputs a and b")
46
+ execute(input) {
47
+ let a = +input.a;
48
+ let b = +input.b;
49
+ console.log("Adding " + a + " and " + b + ": " + (a + b));
50
+ return a + b;
51
+ }
52
+ }
35
53
 
36
- // Define the tool schema
37
- getToolSchema() {
54
+ const ollama = new OllamaModel("http://localhost:11434", "gpt-oss:20b", {
55
+ stream: false,
56
+ });
38
57
 
39
- }
58
+ const agent = Agent.builder()
59
+ .name("calculatorAgent")
60
+ .tools([new AdditionTool()])
61
+ .systemPrompt("You are an agent that runs math operations.")
62
+ .model(ollama)
63
+ .build();
40
64
 
41
- // Actually run the code!
42
- execute(input) {
43
- let a = input.a;
44
- let b = input.b;
45
- return a + b;
46
- }
65
+ await agent.invoke("What is 9 + 10?");
66
+ ```
47
67
 
68
+ #### Without the plugin (still pretty readable.)
69
+
70
+ ```js
71
+ import {
72
+ Agent,
73
+ OllamaModel,
74
+ Parameter,
75
+ Tool,
76
+ ToolSchema,
77
+ } from "../../dist/tapeworm.es.js";
78
+
79
+ class AdditionTool extends Tool {
80
+ /**
81
+ * Unique name used to reference this tool.
82
+ * @returns Tool identifier string.
83
+ */
84
+ getName() {
85
+ return "AdditionTool";
86
+ }
87
+
88
+ /**
89
+ * Short description provided to the model.
90
+ * @returns Human-readable explanation of the tool.
91
+ */
92
+ getDescription() {
93
+ return "Adds two numbers together.";
94
+ }
95
+
96
+ getToolSchema() {
97
+ return (
98
+ ToolSchema.builder()
99
+ .addParameter(
100
+ Parameter.builder()
101
+ .name("a")
102
+ .description("The first number to add.")
103
+ .required(true)
104
+ .type("number")
105
+ .build(),
106
+ )
107
+ //... more parameter additions.
108
+ .output("A number that is equal to a + b")
109
+ .build()
110
+ );
111
+ }
112
+
113
+ execute(input) {
114
+ let a = +input.a;
115
+ let b = +input.b;
116
+ console.log("Adding " + a + " and " + b + ": " + (a + b));
117
+ return a + b;
118
+ }
48
119
  }
49
120
 
50
- const ollama = new Model();
121
+ // Because this is a test file, we are going to run this locally using Ollama
51
122
 
52
- const agent = new Agent();
53
- agent.name = "agent";
54
- agent.tools = [new YourTool(), new YourOtherTool()]
55
- agent.system_prompt = "You are an agent "
56
- agent.model = ollama;
123
+ const ollama = new OllamaModel("http://localhost:11434", "gpt-oss:20b", {
124
+ stream: false,
125
+ });
57
126
 
58
- await agent.invoke("What is 9 + 10"); // Most likely doesn't print 21.
127
+ const agent = Agent.builder()
128
+ .name("calculatorAgent")
129
+ .tools([new AdditionTool()])
130
+ .systemPrompt("You are an agent that runs math operations.")
131
+ .model(ollama)
132
+ .build();
59
133
 
134
+ await agent.invoke("What is 9 + 10");
60
135
  ```
61
136
 
137
+ ## Tapeworm's Tenets
138
+
139
+ - **Be the most ergonomic agentic solution for Node and the browser.** Each commit should make it easier to develop and deploy agentic AI solutions.
140
+ - **Be as model-agnostic as possible.** Use your own machine, AWS, Google, a literal potato... we don't care.
141
+ - **Keep things light.** We already waste so much water and energy with AI. The overhead from Tapeworm should be kept to a minimum when possible.
142
+
62
143
  ## Roadmap
63
144
 
64
145
  Tapeworm seeks to be the most ergonomic agentic solution for Node and the browser.
@@ -67,12 +148,6 @@ It has a long way to go before this project is there, but I believe we're off to
67
148
 
68
149
  Here are the main areas that will be addressed:
69
150
 
70
- ### Better Agent Definitions
71
-
72
- Agents will have a dedicated builder, and I will attempt to make tool definitions a lot easier to write so that the `getName()`, `getDescription()`, and `getToolSchema()` can be generated from your JSDoc or with annotations.
73
-
74
- In the meantime, schemas are easy to define with builders. See the example calculator bot for an example.
75
-
76
151
  ### More documentation and examples
77
152
 
78
153
  We will build JS Docs and expose them, and more examples.
@@ -0,0 +1,18 @@
1
+ /**
2
+ * This file contains TypeScript decorator functions for Tapeworm.
3
+ *
4
+ * They are different from the Babel decorators in @atgs/babel-plugin-tapeworm-decorator, but they achieve the same functionality.
5
+ *
6
+ *
7
+ */
8
+ export declare function ToolName(name: String): (toolClass: Function) => void;
9
+ export declare function ToolDescription(description: String): (toolClass: Function) => void;
10
+ interface ShortHandParameter {
11
+ name: string;
12
+ description: string;
13
+ required: boolean;
14
+ type: string;
15
+ }
16
+ export declare function ToolParameter(parameter: ShortHandParameter): (toolClass: Function) => void;
17
+ export declare function ToolOutput(output: string): (toolClass: Function) => void;
18
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atgs/tapeworm",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "main": "dist/tapeworm.cjs.js",
6
6
  "module": "dist/tapeworm.es.js",