bs-agent 0.0.9 → 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.
@@ -0,0 +1,133 @@
1
+ import { S as SessionId, a as StreamCallbacks, P as PausedToolInfo, C as ClientTool, A as AgentConfig, b as StreamOptions } from '../types-DryLPWU9.cjs';
2
+ export { f as AgentHandoffEvent, E as ExecuteRequestBody, R as ReasoningDeltaEvent, i as RunErrorEvent, c as StreamEvent, d as StreamEventMeta, e as TextDeltaEvent, h as ToolCallEndEvent, g as ToolCallStartEvent, T as ToolType } from '../types-DryLPWU9.cjs';
3
+ export { ZodSchema, toJSONSchema, z } from 'zod';
4
+
5
+ /**
6
+ * Represents a conversation session with a BuildShip agent.
7
+ *
8
+ * Sessions maintain history across multiple turns and support
9
+ * pause/resume for blocking client tools.
10
+ */
11
+ declare class AgentSession {
12
+ /** @internal */ private _agent;
13
+ /** @internal */ private _sessionId;
14
+ /** @internal */ private _paused;
15
+ /** @internal */ private _pausedToolInfo;
16
+ /** @internal */ private _abortController;
17
+ /** @internal */
18
+ constructor(agent: BuildShipAgent, sessionId?: SessionId);
19
+ /**
20
+ * Send a message in this session.
21
+ *
22
+ * @param message - The message to send
23
+ * @param callbacks - Event handlers for the stream
24
+ * @param context - Optional additional context data
25
+ * @returns This session (for chaining)
26
+ */
27
+ execute(message: string, callbacks: StreamCallbacks, context?: Record<string, any>): Promise<AgentSession>;
28
+ /**
29
+ * Resume a paused session with a tool result.
30
+ *
31
+ * @param result - The result to send back to the agent
32
+ * @param callbacks - Event handlers for the resumed stream
33
+ * @returns This session (for chaining)
34
+ */
35
+ resume(result: any, callbacks: StreamCallbacks): Promise<AgentSession>;
36
+ /**
37
+ * Check if this session is waiting for a tool result.
38
+ */
39
+ isPaused(): boolean;
40
+ /**
41
+ * Get information about the paused tool call.
42
+ * Returns `null` if the session is not paused.
43
+ */
44
+ getPausedTool(): PausedToolInfo | null;
45
+ /**
46
+ * Get the session ID.
47
+ * May be `undefined` if the session hasn't executed yet.
48
+ */
49
+ getSessionId(): SessionId;
50
+ /**
51
+ * Cancel the current streaming operation.
52
+ */
53
+ abort(): void;
54
+ /** @internal */
55
+ private _run;
56
+ /** @internal */
57
+ private _getClientToolDefs;
58
+ }
59
+
60
+ /**
61
+ * Main entry point for interacting with a BuildShip agent.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * import { BuildShipAgent } from "buildship-agent-sdk/core";
66
+ *
67
+ * const agent = new BuildShipAgent({
68
+ * agentId: "your-agent-id",
69
+ * accessKey: "your-access-key",
70
+ * });
71
+ *
72
+ * const session = await agent.execute("Hello!", {
73
+ * onText: (text) => console.log(text),
74
+ * onComplete: (fullText) => console.log("Done!", fullText),
75
+ * });
76
+ * ```
77
+ */
78
+ declare class BuildShipAgent {
79
+ /** @internal */ readonly _agentId: string;
80
+ /** @internal */ readonly _accessKey?: string;
81
+ /** @internal */ readonly _baseUrl: string;
82
+ /** @internal */ readonly _clientTools: Map<string, ClientTool>;
83
+ constructor(config: AgentConfig);
84
+ /**
85
+ * The URL for the agent's execute endpoint.
86
+ * @internal
87
+ */
88
+ get _url(): string;
89
+ /**
90
+ * Build the authorization / common headers.
91
+ * @internal
92
+ */
93
+ _buildHeaders(sessionId?: SessionId): Record<string, string>;
94
+ /**
95
+ * Start a new conversation.
96
+ *
97
+ * Creates a fresh session and sends the first message.
98
+ *
99
+ * @param message - The message to send
100
+ * @param callbacks - Event handlers for the stream
101
+ * @param context - Optional additional context data
102
+ * @returns The new session
103
+ */
104
+ execute(message: string, callbacks: StreamCallbacks, context?: Record<string, any>): Promise<AgentSession>;
105
+ /**
106
+ * Get an existing session by ID to continue a conversation.
107
+ *
108
+ * @param sessionId - The session ID from a previous conversation
109
+ * @returns The session object
110
+ */
111
+ session(sessionId: SessionId | string): AgentSession;
112
+ /**
113
+ * Register a client-side tool that the agent can call.
114
+ */
115
+ registerClientTool(tool: ClientTool): void;
116
+ /**
117
+ * Remove a registered client tool.
118
+ */
119
+ unregisterClientTool(name: string): void;
120
+ }
121
+
122
+ /**
123
+ * Opens an SSE connection to the BuildShip agent endpoint using native
124
+ * `fetch` + `ReadableStream`, parses events, and dispatches to the
125
+ * appropriate callbacks.
126
+ *
127
+ * Zero runtime dependencies — works in both browser and Node.js.
128
+ *
129
+ * @internal
130
+ */
131
+ declare function executeStream(options: StreamOptions): Promise<void>;
132
+
133
+ export { AgentConfig, AgentSession, BuildShipAgent, ClientTool, PausedToolInfo, SessionId, StreamCallbacks, StreamOptions, executeStream };
@@ -0,0 +1,133 @@
1
+ import { S as SessionId, a as StreamCallbacks, P as PausedToolInfo, C as ClientTool, A as AgentConfig, b as StreamOptions } from '../types-DryLPWU9.js';
2
+ export { f as AgentHandoffEvent, E as ExecuteRequestBody, R as ReasoningDeltaEvent, i as RunErrorEvent, c as StreamEvent, d as StreamEventMeta, e as TextDeltaEvent, h as ToolCallEndEvent, g as ToolCallStartEvent, T as ToolType } from '../types-DryLPWU9.js';
3
+ export { ZodSchema, toJSONSchema, z } from 'zod';
4
+
5
+ /**
6
+ * Represents a conversation session with a BuildShip agent.
7
+ *
8
+ * Sessions maintain history across multiple turns and support
9
+ * pause/resume for blocking client tools.
10
+ */
11
+ declare class AgentSession {
12
+ /** @internal */ private _agent;
13
+ /** @internal */ private _sessionId;
14
+ /** @internal */ private _paused;
15
+ /** @internal */ private _pausedToolInfo;
16
+ /** @internal */ private _abortController;
17
+ /** @internal */
18
+ constructor(agent: BuildShipAgent, sessionId?: SessionId);
19
+ /**
20
+ * Send a message in this session.
21
+ *
22
+ * @param message - The message to send
23
+ * @param callbacks - Event handlers for the stream
24
+ * @param context - Optional additional context data
25
+ * @returns This session (for chaining)
26
+ */
27
+ execute(message: string, callbacks: StreamCallbacks, context?: Record<string, any>): Promise<AgentSession>;
28
+ /**
29
+ * Resume a paused session with a tool result.
30
+ *
31
+ * @param result - The result to send back to the agent
32
+ * @param callbacks - Event handlers for the resumed stream
33
+ * @returns This session (for chaining)
34
+ */
35
+ resume(result: any, callbacks: StreamCallbacks): Promise<AgentSession>;
36
+ /**
37
+ * Check if this session is waiting for a tool result.
38
+ */
39
+ isPaused(): boolean;
40
+ /**
41
+ * Get information about the paused tool call.
42
+ * Returns `null` if the session is not paused.
43
+ */
44
+ getPausedTool(): PausedToolInfo | null;
45
+ /**
46
+ * Get the session ID.
47
+ * May be `undefined` if the session hasn't executed yet.
48
+ */
49
+ getSessionId(): SessionId;
50
+ /**
51
+ * Cancel the current streaming operation.
52
+ */
53
+ abort(): void;
54
+ /** @internal */
55
+ private _run;
56
+ /** @internal */
57
+ private _getClientToolDefs;
58
+ }
59
+
60
+ /**
61
+ * Main entry point for interacting with a BuildShip agent.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * import { BuildShipAgent } from "buildship-agent-sdk/core";
66
+ *
67
+ * const agent = new BuildShipAgent({
68
+ * agentId: "your-agent-id",
69
+ * accessKey: "your-access-key",
70
+ * });
71
+ *
72
+ * const session = await agent.execute("Hello!", {
73
+ * onText: (text) => console.log(text),
74
+ * onComplete: (fullText) => console.log("Done!", fullText),
75
+ * });
76
+ * ```
77
+ */
78
+ declare class BuildShipAgent {
79
+ /** @internal */ readonly _agentId: string;
80
+ /** @internal */ readonly _accessKey?: string;
81
+ /** @internal */ readonly _baseUrl: string;
82
+ /** @internal */ readonly _clientTools: Map<string, ClientTool>;
83
+ constructor(config: AgentConfig);
84
+ /**
85
+ * The URL for the agent's execute endpoint.
86
+ * @internal
87
+ */
88
+ get _url(): string;
89
+ /**
90
+ * Build the authorization / common headers.
91
+ * @internal
92
+ */
93
+ _buildHeaders(sessionId?: SessionId): Record<string, string>;
94
+ /**
95
+ * Start a new conversation.
96
+ *
97
+ * Creates a fresh session and sends the first message.
98
+ *
99
+ * @param message - The message to send
100
+ * @param callbacks - Event handlers for the stream
101
+ * @param context - Optional additional context data
102
+ * @returns The new session
103
+ */
104
+ execute(message: string, callbacks: StreamCallbacks, context?: Record<string, any>): Promise<AgentSession>;
105
+ /**
106
+ * Get an existing session by ID to continue a conversation.
107
+ *
108
+ * @param sessionId - The session ID from a previous conversation
109
+ * @returns The session object
110
+ */
111
+ session(sessionId: SessionId | string): AgentSession;
112
+ /**
113
+ * Register a client-side tool that the agent can call.
114
+ */
115
+ registerClientTool(tool: ClientTool): void;
116
+ /**
117
+ * Remove a registered client tool.
118
+ */
119
+ unregisterClientTool(name: string): void;
120
+ }
121
+
122
+ /**
123
+ * Opens an SSE connection to the BuildShip agent endpoint using native
124
+ * `fetch` + `ReadableStream`, parses events, and dispatches to the
125
+ * appropriate callbacks.
126
+ *
127
+ * Zero runtime dependencies — works in both browser and Node.js.
128
+ *
129
+ * @internal
130
+ */
131
+ declare function executeStream(options: StreamOptions): Promise<void>;
132
+
133
+ export { AgentConfig, AgentSession, BuildShipAgent, ClientTool, PausedToolInfo, SessionId, StreamCallbacks, StreamOptions, executeStream };