bs-agent 0.0.12 → 0.0.16

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,160 +0,0 @@
1
- import { ZodSchema } from 'zod';
2
-
3
- /**
4
- * Unified tool type discriminator.
5
- */
6
- type ToolType = "flow" | "node" | "mcp" | "client" | "builtin" | "agent";
7
- type StreamEventMeta = {
8
- executionId: string;
9
- sequence: number;
10
- timestamp?: number;
11
- };
12
- type TextDeltaEvent = {
13
- type: "text_delta";
14
- data: string;
15
- meta: StreamEventMeta;
16
- };
17
- type ReasoningDeltaEvent = {
18
- type: "reasoning_delta";
19
- data: {
20
- delta: string;
21
- index: number;
22
- };
23
- meta: StreamEventMeta;
24
- };
25
- type AgentHandoffEvent = {
26
- type: "agent_handoff";
27
- data: {
28
- agentName: string;
29
- };
30
- meta: StreamEventMeta;
31
- };
32
- type ToolCallStartEvent = {
33
- type: "tool_call_start";
34
- data: {
35
- callId: string;
36
- toolName: string;
37
- toolType: ToolType;
38
- inputs?: any;
39
- serverName?: string;
40
- paused?: boolean;
41
- };
42
- meta: StreamEventMeta;
43
- };
44
- type ToolCallEndEvent = {
45
- type: "tool_call_end";
46
- data: {
47
- callId: string;
48
- toolName: string;
49
- toolType: ToolType;
50
- result?: any;
51
- error?: string;
52
- executionTime?: number;
53
- };
54
- meta: StreamEventMeta;
55
- };
56
- type RunErrorEvent = {
57
- type: "run_error";
58
- data: {
59
- message: string;
60
- code?: string;
61
- };
62
- meta: StreamEventMeta;
63
- };
64
- type StreamEvent = TextDeltaEvent | ReasoningDeltaEvent | AgentHandoffEvent | ToolCallStartEvent | ToolCallEndEvent | RunErrorEvent;
65
- /** Branded session ID type. */
66
- type SessionId = string & {
67
- readonly __brand: unique symbol;
68
- };
69
- /** Configuration for the BuildShipAgent constructor. */
70
- interface AgentConfig {
71
- /** Your BuildShip agent ID. */
72
- agentId: string;
73
- /** Access key if your agent requires authentication. */
74
- accessKey?: string;
75
- /** Custom API base URL. Defaults to `https://api.buildship.run`. */
76
- baseUrl?: string;
77
- }
78
- /** Callbacks for streaming responses. */
79
- interface StreamCallbacks {
80
- /** Called for each text chunk from the agent. */
81
- onText?: (text: string) => void;
82
- /** Called for each reasoning chunk (models with chain-of-thought). */
83
- onReasoning?: (delta: string, index: number) => void;
84
- /** Called when control is handed off to a sub-agent. */
85
- onAgentHandoff?: (agentName: string) => void;
86
- /** Called when a tool execution starts. */
87
- onToolStart?: (toolName: string, toolType: ToolType) => void;
88
- /** Called when a tool execution completes. */
89
- onToolEnd?: (toolName: string, result?: any, error?: string) => void;
90
- /** Called when agent pauses for a blocking client tool. */
91
- onPaused?: (toolName: string, args: any) => void;
92
- /** Called when the stream completes successfully. */
93
- onComplete?: (fullText: string) => void;
94
- /** Called if an error occurs during streaming. */
95
- onError?: (error: Error) => void;
96
- /** Called for every stream event. Useful for advanced consumers (e.g. debug panels). */
97
- onEvent?: (event: StreamEvent) => void;
98
- }
99
- /** A client-side tool that the agent can invoke. */
100
- interface ClientTool {
101
- /** Tool name — must match the name the agent knows. */
102
- name: string;
103
- /** Description of what the tool does. */
104
- description: string;
105
- /**
106
- * Tool parameters — accepts a **Zod schema** or a raw JSON Schema object.
107
- *
108
- * @example
109
- * // Zod
110
- * parameters: z.object({ message: z.string() })
111
- *
112
- * // JSON Schema
113
- * parameters: { type: "object", properties: { message: { type: "string" } } }
114
- */
115
- parameters: ZodSchema | Record<string, any>;
116
- /** If true, agent pauses until result is provided. */
117
- await?: boolean;
118
- /** Handler function. If provided with `await: true`, auto-resumes. */
119
- handler?: (args: any) => any | Promise<any>;
120
- }
121
- /** Information about a paused tool call. */
122
- interface PausedToolInfo {
123
- callId: string;
124
- toolName: string;
125
- args: any;
126
- }
127
- /** @internal Body sent to the /executeAgent endpoint. */
128
- interface ExecuteRequestBody {
129
- input?: string;
130
- stream: true;
131
- clientTools?: Array<{
132
- name: string;
133
- description: string;
134
- parameters: Record<string, any>;
135
- await?: boolean;
136
- }>;
137
- toolCallResult?: {
138
- callId: string;
139
- result: any;
140
- };
141
- }
142
- /** @internal Options passed to the internal stream executor. */
143
- interface StreamOptions {
144
- url: string;
145
- body: ExecuteRequestBody;
146
- headers: Record<string, string>;
147
- callbacks: StreamCallbacks;
148
- clientTools: Map<string, ClientTool>;
149
- signal?: AbortSignal;
150
- /** Called when session ID is received from response headers. */
151
- onSessionId?: (sessionId: SessionId, sessionName?: string) => void;
152
- /** Called when paused tool info is detected. */
153
- onPaused?: (info: PausedToolInfo) => void;
154
- /** Called to auto-resume after a client tool handler completes. */
155
- onAutoResume?: (callId: string, result: any) => void;
156
- /** Called with the raw Response object after the HTTP request completes. */
157
- onResponse?: (response: Response) => void;
158
- }
159
-
160
- export type { AgentConfig as A, ClientTool as C, ExecuteRequestBody as E, PausedToolInfo as P, ReasoningDeltaEvent as R, SessionId as S, ToolType as T, StreamCallbacks as a, StreamOptions as b, StreamEvent as c, StreamEventMeta as d, TextDeltaEvent as e, AgentHandoffEvent as f, ToolCallStartEvent as g, ToolCallEndEvent as h, RunErrorEvent as i };
@@ -1,160 +0,0 @@
1
- import { ZodSchema } from 'zod';
2
-
3
- /**
4
- * Unified tool type discriminator.
5
- */
6
- type ToolType = "flow" | "node" | "mcp" | "client" | "builtin" | "agent";
7
- type StreamEventMeta = {
8
- executionId: string;
9
- sequence: number;
10
- timestamp?: number;
11
- };
12
- type TextDeltaEvent = {
13
- type: "text_delta";
14
- data: string;
15
- meta: StreamEventMeta;
16
- };
17
- type ReasoningDeltaEvent = {
18
- type: "reasoning_delta";
19
- data: {
20
- delta: string;
21
- index: number;
22
- };
23
- meta: StreamEventMeta;
24
- };
25
- type AgentHandoffEvent = {
26
- type: "agent_handoff";
27
- data: {
28
- agentName: string;
29
- };
30
- meta: StreamEventMeta;
31
- };
32
- type ToolCallStartEvent = {
33
- type: "tool_call_start";
34
- data: {
35
- callId: string;
36
- toolName: string;
37
- toolType: ToolType;
38
- inputs?: any;
39
- serverName?: string;
40
- paused?: boolean;
41
- };
42
- meta: StreamEventMeta;
43
- };
44
- type ToolCallEndEvent = {
45
- type: "tool_call_end";
46
- data: {
47
- callId: string;
48
- toolName: string;
49
- toolType: ToolType;
50
- result?: any;
51
- error?: string;
52
- executionTime?: number;
53
- };
54
- meta: StreamEventMeta;
55
- };
56
- type RunErrorEvent = {
57
- type: "run_error";
58
- data: {
59
- message: string;
60
- code?: string;
61
- };
62
- meta: StreamEventMeta;
63
- };
64
- type StreamEvent = TextDeltaEvent | ReasoningDeltaEvent | AgentHandoffEvent | ToolCallStartEvent | ToolCallEndEvent | RunErrorEvent;
65
- /** Branded session ID type. */
66
- type SessionId = string & {
67
- readonly __brand: unique symbol;
68
- };
69
- /** Configuration for the BuildShipAgent constructor. */
70
- interface AgentConfig {
71
- /** Your BuildShip agent ID. */
72
- agentId: string;
73
- /** Access key if your agent requires authentication. */
74
- accessKey?: string;
75
- /** Custom API base URL. Defaults to `https://api.buildship.run`. */
76
- baseUrl?: string;
77
- }
78
- /** Callbacks for streaming responses. */
79
- interface StreamCallbacks {
80
- /** Called for each text chunk from the agent. */
81
- onText?: (text: string) => void;
82
- /** Called for each reasoning chunk (models with chain-of-thought). */
83
- onReasoning?: (delta: string, index: number) => void;
84
- /** Called when control is handed off to a sub-agent. */
85
- onAgentHandoff?: (agentName: string) => void;
86
- /** Called when a tool execution starts. */
87
- onToolStart?: (toolName: string, toolType: ToolType) => void;
88
- /** Called when a tool execution completes. */
89
- onToolEnd?: (toolName: string, result?: any, error?: string) => void;
90
- /** Called when agent pauses for a blocking client tool. */
91
- onPaused?: (toolName: string, args: any) => void;
92
- /** Called when the stream completes successfully. */
93
- onComplete?: (fullText: string) => void;
94
- /** Called if an error occurs during streaming. */
95
- onError?: (error: Error) => void;
96
- /** Called for every stream event. Useful for advanced consumers (e.g. debug panels). */
97
- onEvent?: (event: StreamEvent) => void;
98
- }
99
- /** A client-side tool that the agent can invoke. */
100
- interface ClientTool {
101
- /** Tool name — must match the name the agent knows. */
102
- name: string;
103
- /** Description of what the tool does. */
104
- description: string;
105
- /**
106
- * Tool parameters — accepts a **Zod schema** or a raw JSON Schema object.
107
- *
108
- * @example
109
- * // Zod
110
- * parameters: z.object({ message: z.string() })
111
- *
112
- * // JSON Schema
113
- * parameters: { type: "object", properties: { message: { type: "string" } } }
114
- */
115
- parameters: ZodSchema | Record<string, any>;
116
- /** If true, agent pauses until result is provided. */
117
- await?: boolean;
118
- /** Handler function. If provided with `await: true`, auto-resumes. */
119
- handler?: (args: any) => any | Promise<any>;
120
- }
121
- /** Information about a paused tool call. */
122
- interface PausedToolInfo {
123
- callId: string;
124
- toolName: string;
125
- args: any;
126
- }
127
- /** @internal Body sent to the /executeAgent endpoint. */
128
- interface ExecuteRequestBody {
129
- input?: string;
130
- stream: true;
131
- clientTools?: Array<{
132
- name: string;
133
- description: string;
134
- parameters: Record<string, any>;
135
- await?: boolean;
136
- }>;
137
- toolCallResult?: {
138
- callId: string;
139
- result: any;
140
- };
141
- }
142
- /** @internal Options passed to the internal stream executor. */
143
- interface StreamOptions {
144
- url: string;
145
- body: ExecuteRequestBody;
146
- headers: Record<string, string>;
147
- callbacks: StreamCallbacks;
148
- clientTools: Map<string, ClientTool>;
149
- signal?: AbortSignal;
150
- /** Called when session ID is received from response headers. */
151
- onSessionId?: (sessionId: SessionId, sessionName?: string) => void;
152
- /** Called when paused tool info is detected. */
153
- onPaused?: (info: PausedToolInfo) => void;
154
- /** Called to auto-resume after a client tool handler completes. */
155
- onAutoResume?: (callId: string, result: any) => void;
156
- /** Called with the raw Response object after the HTTP request completes. */
157
- onResponse?: (response: Response) => void;
158
- }
159
-
160
- export type { AgentConfig as A, ClientTool as C, ExecuteRequestBody as E, PausedToolInfo as P, ReasoningDeltaEvent as R, SessionId as S, ToolType as T, StreamCallbacks as a, StreamOptions as b, StreamEvent as c, StreamEventMeta as d, TextDeltaEvent as e, AgentHandoffEvent as f, ToolCallStartEvent as g, ToolCallEndEvent as h, RunErrorEvent as i };