Skip to content

Commit e131433

Browse files
authored
refactor!: remove unused exports and experimental features (#221)
BREAKING CHANGE: Remove unused public exports from the SDK Removed exports: - DEFAULT_BASE_URL: Internal implementation detail, users can override via baseUrl option - DEFAULT_HYBRID_ALPHA: Internal constant for meta tools search - Experimental_SchemaOverride: Unused type for schema overrides - Experimental_PreExecuteFunction: Unused type for pre-execute hooks - Experimental_ToolCreationOptions: Unused interface for tool creation Also removed the associated implementation in BaseTool and Tools.getTool() that supported experimental_preExecute and experimental_schemaOverride options. These features were implemented but never used in examples, tests, or documentation. This simplifies the public API surface and removes dead code.
1 parent 08e7ae0 commit e131433

3 files changed

Lines changed: 4 additions & 91 deletions

File tree

src/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* StackOne AI Node.js SDK
33
*/
44

5-
export { DEFAULT_BASE_URL, DEFAULT_HYBRID_ALPHA } from './consts';
65
export { BaseTool, StackOneTool, Tools } from './tool';
76
export { createFeedbackTool } from './feedback';
87
export { StackOneAPIError, StackOneError } from './utils/errors';
@@ -22,9 +21,6 @@ export type {
2221
AISDKToolResult,
2322
ExecuteConfig,
2423
ExecuteOptions,
25-
Experimental_PreExecuteFunction,
26-
Experimental_SchemaOverride,
27-
Experimental_ToolCreationOptions,
2824
JsonDict,
2925
ParameterLocation,
3026
ToolDefinition,

src/tool.ts

Lines changed: 4 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import type {
99
AISDKToolResult,
1010
ExecuteConfig,
1111
ExecuteOptions,
12-
Experimental_PreExecuteFunction,
13-
Experimental_ToolCreationOptions,
1412
HttpExecuteConfig,
1513
JsonDict,
1614
LocalExecuteConfig,
@@ -31,7 +29,6 @@ export class BaseTool {
3129
parameters: ToolParameters;
3230
executeConfig: ExecuteConfig;
3331
protected requestBuilder?: RequestBuilder;
34-
protected experimental_preExecute?: Experimental_PreExecuteFunction;
3532
#exposeExecutionMetadata = true;
3633
#headers: Record<string, string>;
3734

@@ -77,7 +74,6 @@ export class BaseTool {
7774
parameters: ToolParameters,
7875
executeConfig: ExecuteConfig,
7976
headers?: Record<string, string>,
80-
experimental_preExecute?: Experimental_PreExecuteFunction,
8177
) {
8278
this.name = name;
8379
this.description = description;
@@ -87,7 +83,6 @@ export class BaseTool {
8783
if (executeConfig.kind === 'http') {
8884
this.requestBuilder = new RequestBuilder(executeConfig, this.#headers);
8985
}
90-
this.experimental_preExecute = experimental_preExecute;
9186
}
9287

9388
/**
@@ -146,15 +141,8 @@ export class BaseTool {
146141
// Convert string params to object
147142
const params = typeof inputParams === 'string' ? JSON.parse(inputParams) : inputParams || {};
148143

149-
// Apply experimental preExecute function (either from tool creation or execution options)
150-
let processedParams = params;
151-
152-
if (this.experimental_preExecute) {
153-
processedParams = await this.experimental_preExecute(params);
154-
}
155-
156-
// Execute the request directly with processed parameters
157-
return await this.requestBuilder.execute(processedParams, options);
144+
// Execute the request directly with parameters
145+
return await this.requestBuilder.execute(params, options);
158146
} catch (error) {
159147
if (error instanceof StackOneError) {
160148
throw error;
@@ -322,46 +310,8 @@ export class Tools implements Iterable<BaseTool> {
322310
/**
323311
* Get a tool by name
324312
*/
325-
getTool(name: string, options?: Experimental_ToolCreationOptions): BaseTool | undefined {
326-
const originalTool = this.tools.find((tool) => tool.name === name);
327-
if (!originalTool) {
328-
return undefined;
329-
}
330-
331-
// If no experimental options provided, return original tool
332-
if (!options?.experimental_schemaOverride && !options?.experimental_preExecute) {
333-
return originalTool;
334-
}
335-
336-
// Create a new tool with experimental schema override and preExecute
337-
let parameters = originalTool.parameters;
338-
339-
// Apply schema override if provided
340-
if (options.experimental_schemaOverride) {
341-
parameters = options.experimental_schemaOverride(originalTool.parameters);
342-
}
343-
344-
// Create new tool instance with modified schema and preExecute function
345-
if (originalTool instanceof StackOneTool) {
346-
const newTool = new StackOneTool(
347-
originalTool.name,
348-
originalTool.description,
349-
parameters,
350-
originalTool.executeConfig,
351-
originalTool.getHeaders(),
352-
options.experimental_preExecute,
353-
);
354-
return newTool;
355-
}
356-
const newTool = new BaseTool(
357-
originalTool.name,
358-
originalTool.description,
359-
parameters,
360-
originalTool.executeConfig,
361-
originalTool.getHeaders(),
362-
options.experimental_preExecute,
363-
);
364-
return newTool;
313+
getTool(name: string): BaseTool | undefined {
314+
return this.tools.find((tool) => tool.name === name);
365315
}
366316

367317
/**

src/types.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,6 @@ export type JsonSchemaProperties = Record<string, JSONSchema7Definition>;
2727
*/
2828
type JsonSchemaType = JSONSchema7['type'];
2929

30-
/**
31-
* EXPERIMENTAL: Function to override the tool schema at creation time
32-
* Takes the original tool parameters and returns a new schema
33-
* @param originalSchema - The original tool parameters schema from OpenAPI
34-
* @returns New schema definition for the tool
35-
*/
36-
export type Experimental_SchemaOverride = (originalSchema: ToolParameters) => ToolParameters;
37-
38-
/**
39-
* EXPERIMENTAL: Function to preprocess parameters before tool execution
40-
* Transforms parameters from override schema format back to original API format
41-
* @param params - The input parameters in override schema format
42-
* @returns Parameters in original API format
43-
*/
44-
export type Experimental_PreExecuteFunction = (params: JsonDict) => Promise<JsonDict> | JsonDict;
45-
4630
/**
4731
* Valid locations for parameters in requests
4832
*/
@@ -99,23 +83,6 @@ export interface LocalExecuteConfig {
9983
*/
10084
export type ExecuteConfig = HttpExecuteConfig | RpcExecuteConfig | LocalExecuteConfig;
10185

102-
/**
103-
* EXPERIMENTAL: Options for creating tools with schema overrides and preExecute functions
104-
*/
105-
export interface Experimental_ToolCreationOptions {
106-
/**
107-
* EXPERIMENTAL: Function to override the tool schema at creation time
108-
* Takes the original schema and returns a new schema for the tool
109-
*/
110-
experimental_schemaOverride?: Experimental_SchemaOverride;
111-
112-
/**
113-
* EXPERIMENTAL: Function to preprocess parameters before execution
114-
* Transforms parameters from override schema format back to original API format
115-
*/
116-
experimental_preExecute?: Experimental_PreExecuteFunction;
117-
}
118-
11986
/**
12087
* Options for executing a tool
12188
*/

0 commit comments

Comments
 (0)