@axlsdk/axl 0.8.0 → 0.9.0

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.
package/dist/index.d.cts CHANGED
@@ -912,8 +912,10 @@ declare class MemoryManager {
912
912
  close(): Promise<void>;
913
913
  }
914
914
 
915
- /** Convert a Zod schema to JSON Schema (subset). Exported for Studio tool introspection. */
916
- declare function zodToJsonSchema(schema: z.ZodTypeAny): unknown;
915
+ /** Convert a Zod schema to JSON Schema. Exported for Studio tool introspection.
916
+ * Wraps Zod v4's built-in `z.toJSONSchema()`, stripping the `$schema` key
917
+ * since tool parameter schemas are embedded objects, not standalone documents. */
918
+ declare function zodToJsonSchema(schema: z.ZodType): Record<string, unknown>;
917
919
  type WorkflowContextInit = {
918
920
  input: unknown;
919
921
  executionId: string;
@@ -1100,7 +1102,7 @@ type ToolHooks<TInput = unknown, TOutput = unknown> = {
1100
1102
  after?(output: TOutput, ctx: WorkflowContext): TOutput | Promise<TOutput>;
1101
1103
  };
1102
1104
  /** Tool configuration */
1103
- type ToolConfig<TInput extends z.ZodTypeAny, TOutput = unknown> = {
1105
+ type ToolConfig<TInput extends z.ZodType, TOutput = unknown> = {
1104
1106
  name: string;
1105
1107
  description: string;
1106
1108
  input: TInput;
@@ -1115,7 +1117,7 @@ type ToolConfig<TInput extends z.ZodTypeAny, TOutput = unknown> = {
1115
1117
  hooks?: ToolHooks<z.infer<TInput>, TOutput>;
1116
1118
  };
1117
1119
  /** A defined tool instance */
1118
- type Tool<TInput extends z.ZodTypeAny = z.ZodTypeAny, TOutput = unknown> = {
1120
+ type Tool<TInput extends z.ZodType = z.ZodType, TOutput = unknown> = {
1119
1121
  readonly name: string;
1120
1122
  readonly description: string;
1121
1123
  readonly inputSchema: TInput;
@@ -1133,17 +1135,17 @@ type Tool<TInput extends z.ZodTypeAny = z.ZodTypeAny, TOutput = unknown> = {
1133
1135
  * @param config - Tool configuration: name, description, input schema, handler, retry, and sensitivity options.
1134
1136
  * @returns A Tool instance that can be attached to agents and invoked via `tool.run()` or agent tool calling.
1135
1137
  */
1136
- declare function tool<TInput extends z.ZodTypeAny, TOutput = unknown>(config: ToolConfig<TInput, TOutput>): Tool<TInput, TOutput>;
1138
+ declare function tool<TInput extends z.ZodType, TOutput = unknown>(config: ToolConfig<TInput, TOutput>): Tool<TInput, TOutput>;
1137
1139
 
1138
1140
  /** Workflow configuration */
1139
- type WorkflowConfig<TInput extends z.ZodTypeAny = z.ZodTypeAny, TOutput extends z.ZodTypeAny = z.ZodTypeAny> = {
1141
+ type WorkflowConfig<TInput extends z.ZodType = z.ZodType, TOutput extends z.ZodType = z.ZodType> = {
1140
1142
  name: string;
1141
1143
  input: TInput;
1142
1144
  output?: TOutput;
1143
1145
  handler: (ctx: WorkflowContext<z.infer<TInput>>) => Promise<z.infer<TOutput>>;
1144
1146
  };
1145
1147
  /** A defined workflow instance */
1146
- type Workflow<TInput extends z.ZodTypeAny = z.ZodTypeAny, TOutput extends z.ZodTypeAny = z.ZodTypeAny> = {
1148
+ type Workflow<TInput extends z.ZodType = z.ZodType, TOutput extends z.ZodType = z.ZodType> = {
1147
1149
  readonly name: string;
1148
1150
  readonly inputSchema: TInput;
1149
1151
  readonly outputSchema: TOutput | undefined;
@@ -1155,7 +1157,7 @@ type Workflow<TInput extends z.ZodTypeAny = z.ZodTypeAny, TOutput extends z.ZodT
1155
1157
  * @param config - Workflow configuration: name, input schema, optional output schema, and async handler receiving a WorkflowContext.
1156
1158
  * @returns A Workflow instance ready to be registered with an AxlRuntime.
1157
1159
  */
1158
- declare function workflow<TInput extends z.ZodTypeAny, TOutput extends z.ZodTypeAny = z.ZodTypeAny>(config: WorkflowConfig<TInput, TOutput>): Workflow<TInput, TOutput>;
1160
+ declare function workflow<TInput extends z.ZodType, TOutput extends z.ZodType = z.ZodType>(config: WorkflowConfig<TInput, TOutput>): Workflow<TInput, TOutput>;
1159
1161
 
1160
1162
  /**
1161
1163
  * A streamable workflow execution.
package/dist/index.d.ts CHANGED
@@ -912,8 +912,10 @@ declare class MemoryManager {
912
912
  close(): Promise<void>;
913
913
  }
914
914
 
915
- /** Convert a Zod schema to JSON Schema (subset). Exported for Studio tool introspection. */
916
- declare function zodToJsonSchema(schema: z.ZodTypeAny): unknown;
915
+ /** Convert a Zod schema to JSON Schema. Exported for Studio tool introspection.
916
+ * Wraps Zod v4's built-in `z.toJSONSchema()`, stripping the `$schema` key
917
+ * since tool parameter schemas are embedded objects, not standalone documents. */
918
+ declare function zodToJsonSchema(schema: z.ZodType): Record<string, unknown>;
917
919
  type WorkflowContextInit = {
918
920
  input: unknown;
919
921
  executionId: string;
@@ -1100,7 +1102,7 @@ type ToolHooks<TInput = unknown, TOutput = unknown> = {
1100
1102
  after?(output: TOutput, ctx: WorkflowContext): TOutput | Promise<TOutput>;
1101
1103
  };
1102
1104
  /** Tool configuration */
1103
- type ToolConfig<TInput extends z.ZodTypeAny, TOutput = unknown> = {
1105
+ type ToolConfig<TInput extends z.ZodType, TOutput = unknown> = {
1104
1106
  name: string;
1105
1107
  description: string;
1106
1108
  input: TInput;
@@ -1115,7 +1117,7 @@ type ToolConfig<TInput extends z.ZodTypeAny, TOutput = unknown> = {
1115
1117
  hooks?: ToolHooks<z.infer<TInput>, TOutput>;
1116
1118
  };
1117
1119
  /** A defined tool instance */
1118
- type Tool<TInput extends z.ZodTypeAny = z.ZodTypeAny, TOutput = unknown> = {
1120
+ type Tool<TInput extends z.ZodType = z.ZodType, TOutput = unknown> = {
1119
1121
  readonly name: string;
1120
1122
  readonly description: string;
1121
1123
  readonly inputSchema: TInput;
@@ -1133,17 +1135,17 @@ type Tool<TInput extends z.ZodTypeAny = z.ZodTypeAny, TOutput = unknown> = {
1133
1135
  * @param config - Tool configuration: name, description, input schema, handler, retry, and sensitivity options.
1134
1136
  * @returns A Tool instance that can be attached to agents and invoked via `tool.run()` or agent tool calling.
1135
1137
  */
1136
- declare function tool<TInput extends z.ZodTypeAny, TOutput = unknown>(config: ToolConfig<TInput, TOutput>): Tool<TInput, TOutput>;
1138
+ declare function tool<TInput extends z.ZodType, TOutput = unknown>(config: ToolConfig<TInput, TOutput>): Tool<TInput, TOutput>;
1137
1139
 
1138
1140
  /** Workflow configuration */
1139
- type WorkflowConfig<TInput extends z.ZodTypeAny = z.ZodTypeAny, TOutput extends z.ZodTypeAny = z.ZodTypeAny> = {
1141
+ type WorkflowConfig<TInput extends z.ZodType = z.ZodType, TOutput extends z.ZodType = z.ZodType> = {
1140
1142
  name: string;
1141
1143
  input: TInput;
1142
1144
  output?: TOutput;
1143
1145
  handler: (ctx: WorkflowContext<z.infer<TInput>>) => Promise<z.infer<TOutput>>;
1144
1146
  };
1145
1147
  /** A defined workflow instance */
1146
- type Workflow<TInput extends z.ZodTypeAny = z.ZodTypeAny, TOutput extends z.ZodTypeAny = z.ZodTypeAny> = {
1148
+ type Workflow<TInput extends z.ZodType = z.ZodType, TOutput extends z.ZodType = z.ZodType> = {
1147
1149
  readonly name: string;
1148
1150
  readonly inputSchema: TInput;
1149
1151
  readonly outputSchema: TOutput | undefined;
@@ -1155,7 +1157,7 @@ type Workflow<TInput extends z.ZodTypeAny = z.ZodTypeAny, TOutput extends z.ZodT
1155
1157
  * @param config - Workflow configuration: name, input schema, optional output schema, and async handler receiving a WorkflowContext.
1156
1158
  * @returns A Workflow instance ready to be registered with an AxlRuntime.
1157
1159
  */
1158
- declare function workflow<TInput extends z.ZodTypeAny, TOutput extends z.ZodTypeAny = z.ZodTypeAny>(config: WorkflowConfig<TInput, TOutput>): Workflow<TInput, TOutput>;
1160
+ declare function workflow<TInput extends z.ZodType, TOutput extends z.ZodType = z.ZodType>(config: WorkflowConfig<TInput, TOutput>): Workflow<TInput, TOutput>;
1159
1161
 
1160
1162
  /**
1161
1163
  * A streamable workflow execution.
package/dist/index.js CHANGED
@@ -1922,7 +1922,7 @@ var defaultRegistry = new ProviderRegistry();
1922
1922
 
1923
1923
  // src/context.ts
1924
1924
  import { AsyncLocalStorage } from "async_hooks";
1925
- import { ZodError } from "zod";
1925
+ import { z, ZodError } from "zod";
1926
1926
 
1927
1927
  // src/errors.ts
1928
1928
  var AxlError = class extends Error {
@@ -2102,48 +2102,9 @@ function resolveConfig(config) {
2102
2102
  // src/context.ts
2103
2103
  var signalStorage = new AsyncLocalStorage();
2104
2104
  function zodToJsonSchema(schema) {
2105
- const def = schema._def;
2106
- if (!def || !def.typeName) return {};
2107
- switch (def.typeName) {
2108
- case "ZodString":
2109
- return { type: "string" };
2110
- case "ZodNumber":
2111
- return { type: "number" };
2112
- case "ZodBoolean":
2113
- return { type: "boolean" };
2114
- case "ZodArray":
2115
- return { type: "array", items: zodToJsonSchema(def.type) };
2116
- case "ZodObject": {
2117
- const shape = def.shape?.() ?? {};
2118
- const properties = {};
2119
- const required = [];
2120
- for (const [key, value] of Object.entries(shape)) {
2121
- properties[key] = zodToJsonSchema(value);
2122
- const innerDef = value._def;
2123
- if (innerDef?.typeName !== "ZodOptional" && innerDef?.typeName !== "ZodDefault") {
2124
- required.push(key);
2125
- }
2126
- }
2127
- return { type: "object", properties, required: required.length > 0 ? required : void 0 };
2128
- }
2129
- case "ZodOptional":
2130
- return zodToJsonSchema(def.innerType);
2131
- case "ZodDefault":
2132
- return zodToJsonSchema(def.innerType);
2133
- case "ZodEnum":
2134
- return { type: "string", enum: def.values };
2135
- case "ZodLiteral": {
2136
- const v = def.value;
2137
- const t = v === null ? "null" : typeof v;
2138
- return { type: t, const: v };
2139
- }
2140
- case "ZodUnion":
2141
- return { oneOf: def.options.map((o) => zodToJsonSchema(o)) };
2142
- case "ZodNullable":
2143
- return { ...zodToJsonSchema(def.innerType), nullable: true };
2144
- default:
2145
- return {};
2146
- }
2105
+ const result = z.toJSONSchema(schema, { unrepresentable: "any" });
2106
+ delete result.$schema;
2107
+ return result;
2147
2108
  }
2148
2109
  function estimateTokens(text) {
2149
2110
  return Math.ceil(text.length / 4);