Skip to content

Commit a02f8f4

Browse files
authored
Merge branch 'main' into fix-examples
2 parents ba64913 + e131433 commit a02f8f4

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
@@ -11,8 +11,6 @@ import type {
1111
AISDKToolResult,
1212
ExecuteConfig,
1313
ExecuteOptions,
14-
Experimental_PreExecuteFunction,
15-
Experimental_ToolCreationOptions,
1614
HttpExecuteConfig,
1715
JsonDict,
1816
JSONSchema,
@@ -42,7 +40,6 @@ export class BaseTool {
4240
parameters: ToolParameters;
4341
executeConfig: ExecuteConfig;
4442
protected requestBuilder?: RequestBuilder;
45-
protected experimental_preExecute?: Experimental_PreExecuteFunction;
4643
#exposeExecutionMetadata = true;
4744
#headers: Record<string, string>;
4845

@@ -88,7 +85,6 @@ export class BaseTool {
8885
parameters: ToolParameters,
8986
executeConfig: ExecuteConfig,
9087
headers?: Record<string, string>,
91-
experimental_preExecute?: Experimental_PreExecuteFunction,
9288
) {
9389
this.name = name;
9490
this.description = description;
@@ -98,7 +94,6 @@ export class BaseTool {
9894
if (executeConfig.kind === 'http') {
9995
this.requestBuilder = new RequestBuilder(executeConfig, this.#headers);
10096
}
101-
this.experimental_preExecute = experimental_preExecute;
10297
}
10398

10499
/**
@@ -157,15 +152,8 @@ export class BaseTool {
157152
// Convert string params to object
158153
const params = typeof inputParams === 'string' ? JSON.parse(inputParams) : inputParams || {};
159154

160-
// Apply experimental preExecute function (either from tool creation or execution options)
161-
let processedParams = params;
162-
163-
if (this.experimental_preExecute) {
164-
processedParams = await this.experimental_preExecute(params);
165-
}
166-
167-
// Execute the request directly with processed parameters
168-
return await this.requestBuilder.execute(processedParams, options);
155+
// Execute the request directly with parameters
156+
return await this.requestBuilder.execute(params, options);
169157
} catch (error) {
170158
if (error instanceof StackOneError) {
171159
throw error;
@@ -321,46 +309,8 @@ export class Tools implements Iterable<BaseTool> {
321309
/**
322310
* Get a tool by name
323311
*/
324-
getTool(name: string, options?: Experimental_ToolCreationOptions): BaseTool | undefined {
325-
const originalTool = this.tools.find((tool) => tool.name === name);
326-
if (!originalTool) {
327-
return undefined;
328-
}
329-
330-
// If no experimental options provided, return original tool
331-
if (!options?.experimental_schemaOverride && !options?.experimental_preExecute) {
332-
return originalTool;
333-
}
334-
335-
// Create a new tool with experimental schema override and preExecute
336-
let parameters = originalTool.parameters;
337-
338-
// Apply schema override if provided
339-
if (options.experimental_schemaOverride) {
340-
parameters = options.experimental_schemaOverride(originalTool.parameters);
341-
}
342-
343-
// Create new tool instance with modified schema and preExecute function
344-
if (originalTool instanceof StackOneTool) {
345-
const newTool = new StackOneTool(
346-
originalTool.name,
347-
originalTool.description,
348-
parameters,
349-
originalTool.executeConfig,
350-
originalTool.getHeaders(),
351-
options.experimental_preExecute,
352-
);
353-
return newTool;
354-
}
355-
const newTool = new BaseTool(
356-
originalTool.name,
357-
originalTool.description,
358-
parameters,
359-
originalTool.executeConfig,
360-
originalTool.getHeaders(),
361-
options.experimental_preExecute,
362-
);
363-
return newTool;
312+
getTool(name: string): BaseTool | undefined {
313+
return this.tools.find((tool) => tool.name === name);
364314
}
365315

366316
/**

src/types.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -73,22 +73,6 @@ export type JsonSchemaProperties = Record<string, JSONSchema>;
7373
*/
7474
type JsonSchemaType = JSONSchema['type'];
7575

76-
/**
77-
* EXPERIMENTAL: Function to override the tool schema at creation time
78-
* Takes the original tool parameters and returns a new schema
79-
* @param originalSchema - The original tool parameters schema from OpenAPI
80-
* @returns New schema definition for the tool
81-
*/
82-
export type Experimental_SchemaOverride = (originalSchema: ToolParameters) => ToolParameters;
83-
84-
/**
85-
* EXPERIMENTAL: Function to preprocess parameters before tool execution
86-
* Transforms parameters from override schema format back to original API format
87-
* @param params - The input parameters in override schema format
88-
* @returns Parameters in original API format
89-
*/
90-
export type Experimental_PreExecuteFunction = (params: JsonDict) => Promise<JsonDict> | JsonDict;
91-
9276
/**
9377
* Valid locations for parameters in requests
9478
*/
@@ -145,23 +129,6 @@ export interface LocalExecuteConfig {
145129
*/
146130
export type ExecuteConfig = HttpExecuteConfig | RpcExecuteConfig | LocalExecuteConfig;
147131

148-
/**
149-
* EXPERIMENTAL: Options for creating tools with schema overrides and preExecute functions
150-
*/
151-
export interface Experimental_ToolCreationOptions {
152-
/**
153-
* EXPERIMENTAL: Function to override the tool schema at creation time
154-
* Takes the original schema and returns a new schema for the tool
155-
*/
156-
experimental_schemaOverride?: Experimental_SchemaOverride;
157-
158-
/**
159-
* EXPERIMENTAL: Function to preprocess parameters before execution
160-
* Transforms parameters from override schema format back to original API format
161-
*/
162-
experimental_preExecute?: Experimental_PreExecuteFunction;
163-
}
164-
165132
/**
166133
* Options for executing a tool
167134
*/

0 commit comments

Comments
 (0)