@atgs/tapeworm 0.0.2 → 0.1.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.
@@ -1 +1 @@
1
- (function(o,h){typeof exports=="object"&&typeof module<"u"?h(exports):typeof define=="function"&&define.amd?define(["exports"],h):(o=typeof globalThis<"u"?globalThis:o||self,h(o.Tapeworm={}))})(this,(function(o){"use strict";class h{messages;manager;constructor(){this.messages=[],this.manager=new y}append(e){this.messages.push(e),this.messages=this.manager.compact(this.messages)}}class l{role;content;toolCalls;toolName;thinking;constructor(e,s,t,n,r){this.role=e,this.content=s,this.toolCalls=t,this.toolName=n,this.thinking=r}setRole(e){this.role=e}setContent(e){this.content=e}setToolCalls(e){this.toolCalls=e}static builder(){return new _}}class _{_role;_content;_toolCalls;_toolName;_thinking;role(e){return this._role=e,this}content(e){return this._content=e,this}toolCalls(e){return this._toolCalls=e,this}toolName(e){return this._toolName=e,this}thinking(e){return this._thinking=e,this}build(){return new l(this._role,this._content,this._toolCalls,this._toolName,this._thinking)}}class f{compact(e){throw new T("No implementation for conversation manager!")}configure(e){throw new T("No implementation for conversation manager!")}}class y extends f{compact(e){return e}configure(e){}}class T extends Error{constructor(e){super(e),this.name="ConversationManagerNotImplemented"}}class v{async invoke(e){throw new M("The invoke function for this model was not correctly implemented.")}tokenLimit(){throw new M("The tokenLimit function for this model was not correctly implemented.")}}class w{messages;tools;constructor(e,s){this.messages=e,this.tools=s}static builder(){return new c}}class c{_messages;_tools;messages(e){return this._messages=e,this}tools(e){return this._tools=e,this}build(){return this._tools==null&&(this._tools=[]),new w(this._messages,this._tools)}}class b{toolCalls;role;content;thinking;constructor(e,s,t,n){this.toolCalls=e,this.role=s,this.content=t,this.thinking=n}static builder(){return new m}}class m{_toolCalls;_role;_content;_thinking;toolCalls(e){return this._toolCalls=e,this}role(e){return this._role=e,this}content(e){return this._content=e,this}thinking(e){return this._thinking=e,this}build(){return new b(this._toolCalls,this._role,this._content,this._thinking)}}class M extends Error{constructor(e){super(e),this.name="ModelNotImplementedError"}}class S{name;system_prompt;tools;model;conversation;conversationManager;toolNameToIndexMap;async invoke(e){this.conversation==null&&(this.conversation=new h,this.conversationManager!=null&&(this.conversation.manager=this.conversationManager),this.conversation.append(l.builder().role("system").content(this.system_prompt).build())),this.conversation.append(l.builder().role("user").content(e).build());let s=!1;for(;!s;){let t=await this._runQuery();if(this.conversation.append(l.builder().role(t.role??"assistant").content(t.content??"").thinking(t.thinking??"").build()),console.log("Assistant thinking: "+t.thinking),console.log("Assistant reply: "+t.content),s=!0,t.toolCalls!=null&&t.toolCalls.length!=0){s=!1,t.toolCalls.sort((n,r)=>(n.sequence??0)<(r.sequence??0)?-1:1);for(let n in t.toolCalls)this._runTool(t.toolCalls[n])}}}async _runQuery(){return await this.model.invoke(new c().messages(this.conversation?.messages).tools(this.tools).build())}async _runTool(e){if(console.log("Calling tool: "+JSON.stringify(e)),this.generateToolNameToIndexMap(),!(e.name in this.toolNameToIndexMap)){this.conversation.append(l.builder().role("tool").toolName(e.name).content(JSON.stringify({error:"tool does not exist"})).build());return}let s=this.tools[this.toolNameToIndexMap[e.name]];try{let t=s.execute(e.parameters);this.conversation.append(l.builder().role("tool").toolName(e.name).content(JSON.stringify(t)).build())}catch(t){this.conversation.append(l.builder().role("tool").toolName(e.name).content(JSON.stringify(t)).build())}}generateToolNameToIndexMap(){if(this.toolNameToIndexMap==null){this.toolNameToIndexMap={};for(let e=0;e<this.tools.length;e++)this.toolNameToIndexMap[this.tools[e].getName()]=e}}}class d extends Error{constructor(e){super(e),this.name="ToolNotDefinedError"}}class B{name;description;tool_schema;constructor(){this.name=this.getName(),this.description=this.getDescription(),this.tool_schema=this.getToolSchema()}getName(){throw new d("Tool name not defined.")}getDescription(){throw new d("Tool description not defined.")}getToolSchema(){throw new d("Tool parameter schema not defined.")}execute(e){return null}}class p{sequence;name;parameters;type;constructor(e,s,t,n){this.sequence=e,this.name=s,this.parameters=t,this.type=n}static builder(){return new N}}class N{_sequence;_name;_parameters;_type;sequence(e){return this._sequence=e,this}name(e){return this._name=e,this}parameters(e){return this._parameters=e,this}type(e){return this._type=e,this}build(){return this._sequence==null&&(this._sequence=0),new p(this._sequence,this._name,this._parameters,this._type)}}class C{parameters;output;constructor(e,s){this.parameters=e,this.output=s}static builder(){return new q}}class q{_parameters;_output;addParameter(e){return this._parameters==null&&(this._parameters=[]),this._parameters.push(e),this}output(e){return this._output=e,this}build(){return this._parameters==null&&(this._parameters=[]),new C(this._parameters,this._output)}}class k{name;description;type;required;constructor(e,s,t,n){this.name=e,this.description=s,this.type=t,this.required=n,this.assertValidType()}assertValidType(){}static builder(){return new O}}class O{_name;_description;_type;_required;name(e){return this._name=e,this}description(e){return this._description=e,this}type(e){return this._type=e,this}required(e){return this._required=e,this}build(){return this._required==null&&(this._required=!1),new k(this._name,this._description,this._type,this._required)}}class I extends v{endpoint;model;options;constructor(e,s,t){super(),this.endpoint=e,this.model=s,this.options=t}async invoke(e){let s={model:this.model,messages:this._formatMessages(e),tools:this._formatTools(e),...this.options},t=await fetch(this.endpoint+"/api/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);let n=await t.json(),r=[];if(n.message.tool_calls)for(let g in n.message.tool_calls){const a=n.message.tool_calls[g];let u="function",j=a[u]?.name,E=a[u]?.index,R=a[u]?.arguments;r.push(p.builder().name(j).type(u).parameters(R).sequence(E).build())}return new m().toolCalls(r).role(n.message.role).content(n.message.content).thinking(n.message.thinking).build()}_formatTools(e){let s=[],t=[];for(let n of e.tools){let r={};for(let a of n.getToolSchema().parameters)r[a.name]={},r[a.name].type=a.name,r[a.name].description=a.description,a.required&&t.push(a.name);let g={type:"function",function:{name:n.getName(),description:n.getDescription(),parameters:{type:"object",properties:r,required:t}}};s.push(g)}return s}_formatMessages(e){let s=[];for(let t of e.messages){if(t.role=="assistant"||t.role=="system"||t.role=="user"){s.push(t);continue}t.role=="tool"&&s.push({role:"tool",content:t.content,tool_name:t.toolName})}return s}}o.Agent=S,o.Conversation=h,o.ConversationManager=f,o.DefaultConversationManager=y,o.Message=l,o.MessageBuilder=_,o.Model=v,o.ModelRequest=w,o.ModelRequestBuilder=c,o.ModelResponse=b,o.ModelResponseBuilder=m,o.OllamaModel=I,o.Parameter=k,o.ParameterBuilder=O,o.Tool=B,o.ToolCall=p,o.ToolCallBuilder=N,o.ToolSchema=C,o.ToolSchemaBuilder=q,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(i,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(i=typeof globalThis<"u"?globalThis:i||self,u(i.Tapeworm={}))})(this,(function(i){"use strict";class u{messages;manager;constructor(){this.messages=[],this.manager=new g}append(e){this.messages.push(e),this.messages=this.manager.compact(this.messages)}}class v{compact(e){throw new y("No implementation for conversation manager!")}configure(e){throw new y("No implementation for conversation manager!")}}class g extends v{compact(e){return e}configure(e){}}class y extends Error{constructor(e){super(e),this.name="ConversationManagerNotImplemented"}}class c{role;content;constructor(e,t){this.role=e,this.content=t}static builder(){return new M}filter(e){return this.content.filter(t=>t.getMessageComponentType()==e)}}class M{_role;_content;role(e){return this._role=e,this}init(){this._content==null&&(this._content=[])}toolCall(e){return e==null?this:(this.init(),this._content.push(e),this)}toolCalls(e){if(e==null)return this;this.init();for(const t of e)this._content.push(t);return this}toolResult(e){return e==null?this:(this.init(),this._content.push(e),this)}thinking(e){return e==null?this:(this.init(),this._content.push(b.of(e)),this)}content(e){return e==null?this:(this.init(),this._content.push(w.of(e)),this)}build(){if(this._content==null||this._content.length==0)throw new Error("Role-only messages are not supported by Tapeworm.");return new c(this._role,this._content)}}const l={Content:"content",Thinking:"thinking",ToolCall:"toolcall",ToolResult:"toolresult"};class d{getMessageComponentType(){throw new Error("Message components that do not have a message component type are not allowed.")}}class w extends d{text;constructor(e){super(),this.text=e}getMessageComponentType(){return l.Content}get(){return this.text}static of(e){return new this(e)}}class b extends d{thought;constructor(e){super(),this.thought=e}getMessageComponentType(){return l.Thinking}get(){return this.thought}static of(e){return new this(e)}}class p extends d{id;toolName;toolResult;constructor(e,t,o){super(),this.id=e,this.toolName=t,this.toolResult=o}getMessageComponentType(){return l.ToolResult}static of(e,t){return new this(e.id,e.name,t)}}class C{async invoke(e){throw new k("The invoke function for this model was not correctly implemented.")}tokenLimit(){throw new k("The tokenLimit function for this model was not correctly implemented.")}}class N{messages;tools;constructor(e,t){this.messages=e,this.tools=t}static builder(){return new f}}class f{_messages;_tools;messages(e){return this._messages=e,this}tools(e){return this._tools=e,this}build(){if(this._tools==null&&(this._tools=[]),this._messages==null)throw new O("Requests to the model should include content.");return new N(this._messages,this._tools)}}class k extends Error{constructor(e){super(e),this.name="ModelNotImplementedError"}}class O extends Error{constructor(e){super(e),this.name="MessagesNotDefinedError"}}class _ extends d{sequence;name;parameters;type;id;getMessageComponentType(){return l.ToolCall}constructor(e,t,o,s,r){super(),this.sequence=e,this.name=t,this.parameters=o,this.type=s,this.id=r}static builder(){return new q}}class q{_sequence;_name;_parameters;_type;_id;sequence(e){return this._sequence=e,this}name(e){return this._name=e,this}parameters(e){return this._parameters=e,this}type(e){return this._type=e,this}id(e){return e!=null&&(this._id=e),this}build(){return this._sequence==null&&(this._sequence=0),this._id==null&&(this._id=(Math.random()+1).toString(36).slice(2,7)),new _(this._sequence,this._name,this._parameters,this._type,this._id)}}class I extends Error{constructor(e){super(e),this.name="ToolNotFoundError"}}class R{name;systemPrompt;tools;model;conversation;conversationManager;toolNameToIndexMap;callback;constructor(e,t,o,s,r){this.name=e,this.model=o,this.conversationManager=s,this.tools=t,this.callback=r,this.conversationManager.configure(o)}async invoke(e){this.conversation==null&&(this.conversation=new u,this.conversationManager!=null&&(this.conversation.manager=this.conversationManager),this.systemPrompt!=null&&this.conversation.append(c.builder().role("system").content(this.systemPrompt).build())),this.conversation.append(c.builder().role("user").content(e).build());let t=!1;for(;!t;){let o=await this._runQuery();this.callback(o),this.conversation.append(o),t=!0;const s=o.filter(l.ToolCall);if(s!=null&&s.length!=0){t=!1,s.sort((r,h)=>(r.sequence??0)<(h.sequence??0)?-1:1);for(let r of s)await this._runTool(r)}}}async _runQuery(){return await this.model.invoke(new f().messages(this.conversation?.messages).tools(this.tools).build())}async _runTool(e){if(this.generateToolNameToIndexMap(),!(e.name in this.toolNameToIndexMap)){this.conversation.append(c.builder().role("tool").toolResult(p.of(e,new I("Agent does not have a tool with this name."))).build());return}let t=this.tools[this.toolNameToIndexMap[e.name]];try{let o=await t.execute(e.parameters);this.conversation.append(c.builder().role("tool").toolResult(p.of(e,o)).build())}catch(o){this.conversation.append(c.builder().role("tool").toolResult(p.of(e,JSON.stringify(o))).build())}}generateToolNameToIndexMap(){if(this.toolNameToIndexMap==null){this.toolNameToIndexMap={};for(let e=0;e<this.tools.length;e++)this.toolNameToIndexMap[this.tools[e].getName()]=e}}static builder(){return new j}}class j{_name;_systemPrompt;_tools;_model;_conversation;_conversationManager=new g;_toolNameToIndexMap;_callback=e=>x(e);name(e){return this._name=e,this}systemPrompt(e){return this._systemPrompt=e,this}tools(e){return this._tools=e,this}addTool(e){return this._tools==null&&(this._tools=[]),this._tools.push(e),this}model(e){return this._model=e,this}conversationManager(e){return this._conversationManager=e,this}callback(e){return this._callback=e,this}build(){let e=new R(this._name,this._tools,this._model,this._conversationManager,this._callback);return this._conversation!=null&&(e.conversation=this._conversation),this._systemPrompt!=null&&(e.systemPrompt=this._systemPrompt),e}}function x(n){for(const e of n.filter(l.Thinking))console.log("\x1B[90m"+e.get()+"\x1B[0m");for(const e of n.filter(l.Content))console.log(e.get());for(const e of n.filter(l.ToolCall))console.log("\x1B[32mCalling Tool: "+e.name+"\x1B[0m")}class T extends Error{constructor(e){super(e),this.name="ToolNotDefinedError"}}class D{name;description;tool_schema;constructor(){this.name=this.getName(),this.description=this.getDescription(),this.tool_schema=this.getToolSchema()}getName(){throw new T("Tool name not defined.")}getDescription(){throw new T("Tool description not defined.")}getToolSchema(){throw new T("Tool parameter schema not defined.")}execute(e){return null}}class E{parameters;output;constructor(e,t){this.parameters=e,this.output=t}static builder(){return new P}}class P{_parameters;_output;addParameter(e){return this._parameters==null&&(this._parameters=[]),this._parameters.push(e),this}output(e){return this._output=e,this}build(){return this._parameters==null&&(this._parameters=[]),new E(this._parameters,this._output)}}class S{name;description;type;required;constructor(e,t,o,s){this.name=e,this.description=t,this.type=o,this.required=s,this.assertValidType()}assertValidType(){}static builder(){return new B}}class B{_name;_description;_type;_required;name(e){return this._name=e,this}description(e){return this._description=e,this}type(e){return this._type=e,this}required(e){return this._required=e,this}build(){return this._required==null&&(this._required=!1),new S(this._name,this._description,this._type,this._required)}}class A extends C{endpoint;model;options;constructor(e,t,o){super(),this.endpoint=e,this.model=t,this.options=o}async invoke(e){let t={model:this.model,messages:this._formatMessages(e),tools:this._formatTools(e),...this.options},o=await fetch(this.endpoint+"/api/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);let s=await o.json(),r=[];if(s.message.tool_calls)for(let h in s.message.tool_calls){const a=s.message.tool_calls[h];let m="function",J=a[m]?.name,F=a[m]?.index,L=a.id??void 0,Q=typeof a[m]?.arguments=="string"?JSON.parse(a[m]?.arguments):a[m]?.arguments;r.push(_.builder().name(J).type(m).parameters(Q).sequence(F).id(L).build())}return c.builder().toolCalls(r).role(s.message.role).content(s.message.content).thinking(s.message.thinking).build()}_formatTools(e){let t=[];for(let o of e.tools){let s={},r=[];for(let a of o.getToolSchema().parameters)s[a.name]={},s[a.name].type=a.type,s[a.name].description=a.description,a.required&&r.push(a.name);let h={type:"function",function:{name:o.getName(),description:o.getDescription(),parameters:{type:"object",properties:s,required:r}}};t.push(h)}return t}_formatMessages(e){let t=[];for(let o of e.messages){if(o.role=="assistant"||o.role=="system"||o.role=="user"){t.push(this._formatSingleMessage(o));continue}if(o.role=="tool"){for(const s of o.content)if(s.getMessageComponentType()==l.ToolResult){const r=s;t.push({role:o.role,name:r.toolName,content:JSON.stringify(r.toolResult)})}}}return t}_formatSingleMessage(e){let t={role:e.role},o,s,r;for(const h of e.content){if(h.getMessageComponentType()==l.Content){const a=h;o==null&&(o=""),o+=a.get()}if(h.getMessageComponentType()==l.Thinking){const a=h;r==null&&(r=""),r+=a.get()}if(h.getMessageComponentType()==l.ToolCall){const a=h;s==null&&(s=[]),s.push(this._formatToolCall(a))}}return o!=null&&(t.content=o),s!=null&&(t.tool_calls=s),r!=null&&(t.thinking=r),t}_formatToolCall(e){return{function:{name:e.name,arguments:e.parameters}}}}i.Agent=R,i.Content=w,i.Conversation=u,i.ConversationManager=v,i.DefaultConversationManager=g,i.Message=c,i.MessageBuilder=M,i.MessageComponent=d,i.MessageComponentType=l,i.Model=C,i.ModelRequest=N,i.ModelRequestBuilder=f,i.OllamaModel=A,i.Parameter=S,i.ParameterBuilder=B,i.Thinking=b,i.Tool=D,i.ToolCall=_,i.ToolCallBuilder=q,i.ToolResult=p,i.ToolSchema=E,i.ToolSchemaBuilder=P,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
@@ -7,9 +7,29 @@ export default class Tool {
7
7
  private name;
8
8
  private description;
9
9
  private tool_schema;
10
+ /**
11
+ * Initialize tool metadata from subclass implementations.
12
+ */
10
13
  constructor();
14
+ /**
15
+ * Name that uniquely identifies this tool.
16
+ * @returns A short, stable identifier string.
17
+ */
11
18
  getName(): string;
19
+ /**
20
+ * Human-readable description of what the tool does.
21
+ * @returns Description string shown to the model.
22
+ */
12
23
  getDescription(): string;
24
+ /**
25
+ * Structured schema describing tool parameters and output.
26
+ * @returns ToolSchema instance.
27
+ */
13
28
  getToolSchema(): ToolSchema;
14
- execute(input: any): any;
29
+ /**
30
+ * Execute the tool against provided input parameters.
31
+ * @param input Parsed arguments from the model.
32
+ * @returns Tool-specific output.
33
+ */
34
+ execute(_input: any): any;
15
35
  }
@@ -1,13 +1,34 @@
1
+ import { MessageComponent, MessageComponentType } from "../conversation/message";
1
2
  /**
2
3
  * Represents a single tool invocation returned by a model, including the target
3
4
  * tool name, argument map, type (function/spec), and optional sequence number.
5
+ *
6
+ * The ToolCall object is also a MessageComponent and thus is a component of Message.
4
7
  */
5
- export default class ToolCall {
8
+ export default class ToolCall extends MessageComponent {
6
9
  sequence: number | undefined;
7
10
  name: string;
8
11
  parameters: any;
9
12
  type: string;
10
- constructor(sequence: number | undefined, name: string, parameters: any, type: string);
13
+ id: string;
14
+ /**
15
+ * Get the type of this message component, as defined in MessageComponentType.
16
+ * This returns MessageComponentType.ToolCall.
17
+ */
18
+ getMessageComponentType(): MessageComponentType;
19
+ /**
20
+ * Create a ToolCall component to represent a model-requested tool invocation.
21
+ * @param sequence Optional ordering from the model for batched tool calls.
22
+ * @param name Name of the tool to invoke.
23
+ * @param parameters Arguments provided by the model.
24
+ * @param type Type of tool call (e.g., function).
25
+ * @param id Provider-generated identifier for correlating results.
26
+ */
27
+ constructor(sequence: number | undefined, name: string, parameters: any, type: string, id: string);
28
+ /**
29
+ * Convenience factory for a ToolCallBuilder.
30
+ * @returns A new ToolCallBuilder instance.
31
+ */
11
32
  static builder(): ToolCallBuilder;
12
33
  }
13
34
  /**
@@ -18,9 +39,46 @@ export declare class ToolCallBuilder {
18
39
  private _name;
19
40
  private _parameters;
20
41
  private _type;
42
+ private _id;
43
+ /**
44
+ * Set the sequence number for the tool call.
45
+ * @param sequence Optional position of the tool call in a batch.
46
+ * @returns This builder for chaining.
47
+ */
21
48
  sequence(sequence: number | undefined): ToolCallBuilder;
49
+ /**
50
+ * Set the name of the tool to invoke.
51
+ * @param name Tool identifier.
52
+ * @returns This builder for chaining.
53
+ */
22
54
  name(name: string): this;
55
+ /**
56
+ * Provide the argument payload for the tool call.
57
+ * @param parameters JSON-serializable arguments to pass to the tool.
58
+ * @returns This builder for chaining.
59
+ */
23
60
  parameters(parameters: any): ToolCallBuilder;
61
+ /**
62
+ * Set the type of tool call (e.g., function).
63
+ * @param type Provider-specific tool call type.
64
+ * @returns This builder for chaining.
65
+ */
24
66
  type(type: string): ToolCallBuilder;
67
+ /**
68
+ * Assign the provider tool call identifier for correlation.
69
+ * @param id Unique identifier returned by the model.
70
+ * @returns This builder for chaining.
71
+ */
72
+ id(id: string | undefined): ToolCallBuilder;
73
+ /**
74
+ * Build the ToolCall with collected data, defaulting sequence to 0.
75
+ * @returns ToolCall instance ready to attach to a message.
76
+ */
25
77
  build(): ToolCall;
26
78
  }
79
+ /**
80
+ * Error thrown when a requested tool cannot be found on the agent.
81
+ */
82
+ export declare class ToolNotFoundError extends Error {
83
+ constructor(message: string);
84
+ }
@@ -25,15 +25,18 @@ export declare class ToolSchemaBuilder {
25
25
  /**
26
26
  * Add a parameter definition to the schema.
27
27
  * @param parameter Fully constructed parameter to append.
28
+ * @returns This builder for chaining.
28
29
  */
29
30
  addParameter(parameter: Parameter): ToolSchemaBuilder;
30
31
  /**
31
32
  * Describe the output of the tool.
32
33
  * @param output Text description of what the tool returns.
34
+ * @returns This builder for chaining.
33
35
  */
34
36
  output(output: string): ToolSchemaBuilder;
35
37
  /**
36
38
  * Build the ToolSchema instance from the collected fields.
39
+ * @returns Constructed ToolSchema describing parameters and output.
37
40
  */
38
41
  build(): ToolSchema;
39
42
  }
@@ -61,8 +64,15 @@ export declare class Parameter {
61
64
  * Placeholder for validating supported parameter types.
62
65
  */
63
66
  assertValidType(): void;
67
+ /**
68
+ * Create a builder for constructing a Parameter.
69
+ * @returns A ParameterBuilder instance.
70
+ */
64
71
  static builder(): ParameterBuilder;
65
72
  }
73
+ /**
74
+ * Builder for defining tool parameters step by step.
75
+ */
66
76
  export declare class ParameterBuilder {
67
77
  private _name;
68
78
  private _description;
@@ -70,22 +80,27 @@ export declare class ParameterBuilder {
70
80
  private _required?;
71
81
  /**
72
82
  * Set the parameter name.
83
+ * @returns This builder for chaining.
73
84
  */
74
85
  name(name: string): ParameterBuilder;
75
86
  /**
76
87
  * Set the parameter description.
88
+ * @returns This builder for chaining.
77
89
  */
78
90
  description(description: string): ParameterBuilder;
79
91
  /**
80
92
  * Set the parameter type.
93
+ * @returns This builder for chaining.
81
94
  */
82
95
  type(type: string): ParameterBuilder;
83
96
  /**
84
97
  * Mark the parameter as required or optional.
98
+ * @returns This builder for chaining.
85
99
  */
86
100
  required(required: boolean): ParameterBuilder;
87
101
  /**
88
102
  * Build a Parameter instance using the accumulated fields.
103
+ * @returns Constructed Parameter definition.
89
104
  */
90
105
  build(): Parameter;
91
106
  }
package/package.json CHANGED
@@ -1,24 +1,27 @@
1
1
  {
2
2
  "name": "@atgs/tapeworm",
3
- "version": "0.0.2",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "main": "dist/tapeworm.cjs.js",
6
6
  "module": "dist/tapeworm.es.js",
7
7
  "browser": "dist/tapeworm.umd.js",
8
8
  "types": "dist/index.d.ts",
9
9
  "files": [
10
- "dist"
10
+ "dist",
11
+ "README.md"
11
12
  ],
12
13
  "scripts": {
13
- "build": "vite build && npm run build:types",
14
+ "build": "npm run format && npm run test && vite build && npm run build:types",
14
15
  "build:types": "tsc -p tsconfig.types.json",
15
- "test": "jest"
16
+ "test": "jest",
17
+ "format": "prettier --write \"**/*.{ts,tsx,js,jsx,json,css,md}\""
16
18
  },
17
19
  "devDependencies": {
18
20
  "@babel/preset-env": "^7.28.5",
19
21
  "@babel/preset-typescript": "^7.28.5",
20
22
  "@types/jest": "^30.0.0",
21
23
  "jest": "^30.2.0",
24
+ "prettier": "^3.7.4",
22
25
  "ts-node": "^10.9.2",
23
26
  "typescript": "^5.9.3",
24
27
  "vite": "^7.2.7"