@opperai/agents 0.3.0-beta → 0.3.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
@@ -1576,7 +1576,7 @@ declare const ThoughtSchema: z.ZodObject<{
1576
1576
  */
1577
1577
  confidence: z.ZodOptional<z.ZodNumber>;
1578
1578
  /**
1579
- * Additional metadata
1579
+ * Additional metadata (key-value pairs)
1580
1580
  */
1581
1581
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1582
1582
  }, "strip", z.ZodTypeAny, {
@@ -1841,15 +1841,15 @@ declare const MCPConfigVariants: z.ZodDiscriminatedUnion<"transport", [z.ZodObje
1841
1841
  }, "strip", z.ZodTypeAny, {
1842
1842
  metadata: Record<string, unknown>;
1843
1843
  name: string;
1844
+ url: string;
1844
1845
  method: "GET" | "POST";
1845
1846
  headers: Record<string, string>;
1846
1847
  timeout: number;
1847
1848
  transport: "http-sse";
1848
- url: string;
1849
1849
  }, {
1850
1850
  name: string;
1851
- transport: "http-sse";
1852
1851
  url: string;
1852
+ transport: "http-sse";
1853
1853
  metadata?: Record<string, unknown> | undefined;
1854
1854
  method?: "GET" | "POST" | undefined;
1855
1855
  headers?: Record<string, string> | undefined;
@@ -1866,15 +1866,15 @@ declare const MCPConfigVariants: z.ZodDiscriminatedUnion<"transport", [z.ZodObje
1866
1866
  }, "strip", z.ZodTypeAny, {
1867
1867
  metadata: Record<string, unknown>;
1868
1868
  name: string;
1869
+ url: string;
1869
1870
  headers: Record<string, string>;
1870
1871
  timeout: number;
1871
1872
  transport: "streamable-http";
1872
- url: string;
1873
1873
  sessionId?: string | undefined;
1874
1874
  }, {
1875
1875
  name: string;
1876
- transport: "streamable-http";
1877
1876
  url: string;
1877
+ transport: "streamable-http";
1878
1878
  metadata?: Record<string, unknown> | undefined;
1879
1879
  headers?: Record<string, string> | undefined;
1880
1880
  timeout?: number | undefined;
@@ -1925,15 +1925,15 @@ declare const MCPServerConfigSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"trans
1925
1925
  }, "strip", z.ZodTypeAny, {
1926
1926
  metadata: Record<string, unknown>;
1927
1927
  name: string;
1928
+ url: string;
1928
1929
  method: "GET" | "POST";
1929
1930
  headers: Record<string, string>;
1930
1931
  timeout: number;
1931
1932
  transport: "http-sse";
1932
- url: string;
1933
1933
  }, {
1934
1934
  name: string;
1935
- transport: "http-sse";
1936
1935
  url: string;
1936
+ transport: "http-sse";
1937
1937
  metadata?: Record<string, unknown> | undefined;
1938
1938
  method?: "GET" | "POST" | undefined;
1939
1939
  headers?: Record<string, string> | undefined;
@@ -1950,15 +1950,15 @@ declare const MCPServerConfigSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"trans
1950
1950
  }, "strip", z.ZodTypeAny, {
1951
1951
  metadata: Record<string, unknown>;
1952
1952
  name: string;
1953
+ url: string;
1953
1954
  headers: Record<string, string>;
1954
1955
  timeout: number;
1955
1956
  transport: "streamable-http";
1956
- url: string;
1957
1957
  sessionId?: string | undefined;
1958
1958
  }, {
1959
1959
  name: string;
1960
- transport: "streamable-http";
1961
1960
  url: string;
1961
+ transport: "streamable-http";
1962
1962
  metadata?: Record<string, unknown> | undefined;
1963
1963
  headers?: Record<string, string> | undefined;
1964
1964
  timeout?: number | undefined;
@@ -1976,18 +1976,18 @@ declare const MCPServerConfigSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"trans
1976
1976
  } | {
1977
1977
  metadata: Record<string, unknown>;
1978
1978
  name: string;
1979
+ url: string;
1979
1980
  method: "GET" | "POST";
1980
1981
  headers: Record<string, string>;
1981
1982
  timeout: number;
1982
1983
  transport: "http-sse";
1983
- url: string;
1984
1984
  } | {
1985
1985
  metadata: Record<string, unknown>;
1986
1986
  name: string;
1987
+ url: string;
1987
1988
  headers: Record<string, string>;
1988
1989
  timeout: number;
1989
1990
  transport: "streamable-http";
1990
- url: string;
1991
1991
  sessionId?: string | undefined;
1992
1992
  }, {
1993
1993
  name: string;
@@ -2001,16 +2001,16 @@ declare const MCPServerConfigSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"trans
2001
2001
  stderr?: "inherit" | "pipe" | "ignore" | undefined;
2002
2002
  } | {
2003
2003
  name: string;
2004
- transport: "http-sse";
2005
2004
  url: string;
2005
+ transport: "http-sse";
2006
2006
  metadata?: Record<string, unknown> | undefined;
2007
2007
  method?: "GET" | "POST" | undefined;
2008
2008
  headers?: Record<string, string> | undefined;
2009
2009
  timeout?: number | undefined;
2010
2010
  } | {
2011
2011
  name: string;
2012
- transport: "streamable-http";
2013
2012
  url: string;
2013
+ transport: "streamable-http";
2014
2014
  metadata?: Record<string, unknown> | undefined;
2015
2015
  headers?: Record<string, string> | undefined;
2016
2016
  timeout?: number | undefined;
@@ -2070,6 +2070,12 @@ declare class MCPToolProvider implements ToolProvider {
2070
2070
  }
2071
2071
  declare const mcp: (...configs: ReadonlyArray<MCPServerConfig | MCPServerConfigInput>) => MCPToolProvider;
2072
2072
 
2073
+ /**
2074
+ * Convert a Zod schema to JSON Schema, compatible with both Zod 3 and Zod 4.
2075
+ * Uses native toJSONSchema for Zod 4, falls back to zod-to-json-schema for Zod 3.
2076
+ * Note: Zod 4's toJSONSchema has a bug with single-arg z.record(), so we fall back on error.
2077
+ */
2078
+ declare function zodSchemaToJsonSchema(schema: ZodTypeAny): Record<string, unknown>;
2073
2079
  declare class SchemaValidationError extends Error {
2074
2080
  readonly issues: ZodIssue[];
2075
2081
  constructor(message: string, issues: ZodIssue[]);
@@ -2304,4 +2310,4 @@ declare class ToolRunner {
2304
2310
  };
2305
2311
  }
2306
2312
 
2307
- export { Agent, type AgentConfig, AgentContext, type AgentContextOptions, type AgentContextSnapshot, type AgentDecision, AgentDecisionSchema, AgentEventEmitter, type AgentEventListener, type AgentEventName, type AgentEventPayload, type AgentEventPayloadMap, AgentEvents, type AgentLogger, BaseAgent, type BaseAgentConfig, ConsoleLogger, type CreateSpanOptions, DEFAULT_MODEL, DEFAULT_RETRY_CONFIG, type ExecutionCycle, ExecutionCycleSchema, type Failure, type HookEventName, HookEvents, type HookHandler, HookManager, type HookPayload, type HookPayloadMap, type HookRegistration, InMemoryStore, type IterationSummary, type JsonSchemaOptions, LogLevel, MCPClient, type MCPClientOptions, type MCPServerConfig, type MCPServerConfigInput, MCPServerConfigSchema, type MCPTool, MCPToolProvider, type MCPToolProviderOptions, MCPconfig, type MaybePromise, type Memory, type MemoryCatalogEntry, type MemoryEntry, type MemoryEntryMetadata, MemoryEntryMetadataSchema, MemoryEntrySchema, type MemoryUpdate, MemoryUpdateSchema, type OpperCallOptions, type OpperCallResponse, OpperClient, type OpperClientConfig, type OpperSpan, type OpperStreamChunk, type OpperStreamEvent, type OpperStreamResponse, Result, type RetryConfig, STREAM_ROOT_PATH, type Schema, SchemaValidationError, type SchemaValidationOptions, SilentLogger, StreamAssembler, type StreamAssemblerOptions, type StreamFeedResult, type StreamFinalizeResult, type Success, type Thought, ThoughtSchema, type Tool, type ToolCall, type ToolCallRecord, ToolCallRecordSchema, ToolCallSchema, type ToolDefinition, type ToolExecutionContext, type ToolExecutionSummary, ToolExecutionSummarySchema, type ToolFailure, type ToolFunction, ToolMetadataSchema, type ToolOptions, type ToolProvider, type ToolResult, type ToolResultData, ToolResultFactory, ToolResultFailureSchema, type ToolResultInit, ToolResultSchema, ToolResultSuccessSchema, type ToolRunOptions, ToolRunner, type ToolSuccess, type UnregisterHook, type Usage, UsageSchema, type VisualizationOptions, coerceToolDefinition, createAgentDecisionWithOutputSchema, createFunctionTool, createHookManager, createInMemoryStore, createMCPServerConfig, createOpperClient, createStreamAssembler, createToolCallRecord, err, extractTools, generateAgentFlowDiagram, getDefaultLogger, getSchemaDefault, isSchemaValid, isToolProvider, mcp, mergeSchemaDefaults, normalizeToolEntries, ok, schemaToJson, setDefaultLogger, tool, validateSchema, validateToolInput };
2313
+ export { Agent, type AgentConfig, AgentContext, type AgentContextOptions, type AgentContextSnapshot, type AgentDecision, AgentDecisionSchema, AgentEventEmitter, type AgentEventListener, type AgentEventName, type AgentEventPayload, type AgentEventPayloadMap, AgentEvents, type AgentLogger, BaseAgent, type BaseAgentConfig, ConsoleLogger, type CreateSpanOptions, DEFAULT_MODEL, DEFAULT_RETRY_CONFIG, type ExecutionCycle, ExecutionCycleSchema, type Failure, type HookEventName, HookEvents, type HookHandler, HookManager, type HookPayload, type HookPayloadMap, type HookRegistration, InMemoryStore, type IterationSummary, type JsonSchemaOptions, LogLevel, MCPClient, type MCPClientOptions, type MCPServerConfig, type MCPServerConfigInput, MCPServerConfigSchema, type MCPTool, MCPToolProvider, type MCPToolProviderOptions, MCPconfig, type MaybePromise, type Memory, type MemoryCatalogEntry, type MemoryEntry, type MemoryEntryMetadata, MemoryEntryMetadataSchema, MemoryEntrySchema, type MemoryUpdate, MemoryUpdateSchema, type OpperCallOptions, type OpperCallResponse, OpperClient, type OpperClientConfig, type OpperSpan, type OpperStreamChunk, type OpperStreamEvent, type OpperStreamResponse, Result, type RetryConfig, STREAM_ROOT_PATH, type Schema, SchemaValidationError, type SchemaValidationOptions, SilentLogger, StreamAssembler, type StreamAssemblerOptions, type StreamFeedResult, type StreamFinalizeResult, type Success, type Thought, ThoughtSchema, type Tool, type ToolCall, type ToolCallRecord, ToolCallRecordSchema, ToolCallSchema, type ToolDefinition, type ToolExecutionContext, type ToolExecutionSummary, ToolExecutionSummarySchema, type ToolFailure, type ToolFunction, ToolMetadataSchema, type ToolOptions, type ToolProvider, type ToolResult, type ToolResultData, ToolResultFactory, ToolResultFailureSchema, type ToolResultInit, ToolResultSchema, ToolResultSuccessSchema, type ToolRunOptions, ToolRunner, type ToolSuccess, type UnregisterHook, type Usage, UsageSchema, type VisualizationOptions, coerceToolDefinition, createAgentDecisionWithOutputSchema, createFunctionTool, createHookManager, createInMemoryStore, createMCPServerConfig, createOpperClient, createStreamAssembler, createToolCallRecord, err, extractTools, generateAgentFlowDiagram, getDefaultLogger, getSchemaDefault, isSchemaValid, isToolProvider, mcp, mergeSchemaDefaults, normalizeToolEntries, ok, schemaToJson, setDefaultLogger, tool, validateSchema, validateToolInput, zodSchemaToJsonSchema };
package/dist/index.d.ts CHANGED
@@ -1576,7 +1576,7 @@ declare const ThoughtSchema: z.ZodObject<{
1576
1576
  */
1577
1577
  confidence: z.ZodOptional<z.ZodNumber>;
1578
1578
  /**
1579
- * Additional metadata
1579
+ * Additional metadata (key-value pairs)
1580
1580
  */
1581
1581
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1582
1582
  }, "strip", z.ZodTypeAny, {
@@ -1841,15 +1841,15 @@ declare const MCPConfigVariants: z.ZodDiscriminatedUnion<"transport", [z.ZodObje
1841
1841
  }, "strip", z.ZodTypeAny, {
1842
1842
  metadata: Record<string, unknown>;
1843
1843
  name: string;
1844
+ url: string;
1844
1845
  method: "GET" | "POST";
1845
1846
  headers: Record<string, string>;
1846
1847
  timeout: number;
1847
1848
  transport: "http-sse";
1848
- url: string;
1849
1849
  }, {
1850
1850
  name: string;
1851
- transport: "http-sse";
1852
1851
  url: string;
1852
+ transport: "http-sse";
1853
1853
  metadata?: Record<string, unknown> | undefined;
1854
1854
  method?: "GET" | "POST" | undefined;
1855
1855
  headers?: Record<string, string> | undefined;
@@ -1866,15 +1866,15 @@ declare const MCPConfigVariants: z.ZodDiscriminatedUnion<"transport", [z.ZodObje
1866
1866
  }, "strip", z.ZodTypeAny, {
1867
1867
  metadata: Record<string, unknown>;
1868
1868
  name: string;
1869
+ url: string;
1869
1870
  headers: Record<string, string>;
1870
1871
  timeout: number;
1871
1872
  transport: "streamable-http";
1872
- url: string;
1873
1873
  sessionId?: string | undefined;
1874
1874
  }, {
1875
1875
  name: string;
1876
- transport: "streamable-http";
1877
1876
  url: string;
1877
+ transport: "streamable-http";
1878
1878
  metadata?: Record<string, unknown> | undefined;
1879
1879
  headers?: Record<string, string> | undefined;
1880
1880
  timeout?: number | undefined;
@@ -1925,15 +1925,15 @@ declare const MCPServerConfigSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"trans
1925
1925
  }, "strip", z.ZodTypeAny, {
1926
1926
  metadata: Record<string, unknown>;
1927
1927
  name: string;
1928
+ url: string;
1928
1929
  method: "GET" | "POST";
1929
1930
  headers: Record<string, string>;
1930
1931
  timeout: number;
1931
1932
  transport: "http-sse";
1932
- url: string;
1933
1933
  }, {
1934
1934
  name: string;
1935
- transport: "http-sse";
1936
1935
  url: string;
1936
+ transport: "http-sse";
1937
1937
  metadata?: Record<string, unknown> | undefined;
1938
1938
  method?: "GET" | "POST" | undefined;
1939
1939
  headers?: Record<string, string> | undefined;
@@ -1950,15 +1950,15 @@ declare const MCPServerConfigSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"trans
1950
1950
  }, "strip", z.ZodTypeAny, {
1951
1951
  metadata: Record<string, unknown>;
1952
1952
  name: string;
1953
+ url: string;
1953
1954
  headers: Record<string, string>;
1954
1955
  timeout: number;
1955
1956
  transport: "streamable-http";
1956
- url: string;
1957
1957
  sessionId?: string | undefined;
1958
1958
  }, {
1959
1959
  name: string;
1960
- transport: "streamable-http";
1961
1960
  url: string;
1961
+ transport: "streamable-http";
1962
1962
  metadata?: Record<string, unknown> | undefined;
1963
1963
  headers?: Record<string, string> | undefined;
1964
1964
  timeout?: number | undefined;
@@ -1976,18 +1976,18 @@ declare const MCPServerConfigSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"trans
1976
1976
  } | {
1977
1977
  metadata: Record<string, unknown>;
1978
1978
  name: string;
1979
+ url: string;
1979
1980
  method: "GET" | "POST";
1980
1981
  headers: Record<string, string>;
1981
1982
  timeout: number;
1982
1983
  transport: "http-sse";
1983
- url: string;
1984
1984
  } | {
1985
1985
  metadata: Record<string, unknown>;
1986
1986
  name: string;
1987
+ url: string;
1987
1988
  headers: Record<string, string>;
1988
1989
  timeout: number;
1989
1990
  transport: "streamable-http";
1990
- url: string;
1991
1991
  sessionId?: string | undefined;
1992
1992
  }, {
1993
1993
  name: string;
@@ -2001,16 +2001,16 @@ declare const MCPServerConfigSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"trans
2001
2001
  stderr?: "inherit" | "pipe" | "ignore" | undefined;
2002
2002
  } | {
2003
2003
  name: string;
2004
- transport: "http-sse";
2005
2004
  url: string;
2005
+ transport: "http-sse";
2006
2006
  metadata?: Record<string, unknown> | undefined;
2007
2007
  method?: "GET" | "POST" | undefined;
2008
2008
  headers?: Record<string, string> | undefined;
2009
2009
  timeout?: number | undefined;
2010
2010
  } | {
2011
2011
  name: string;
2012
- transport: "streamable-http";
2013
2012
  url: string;
2013
+ transport: "streamable-http";
2014
2014
  metadata?: Record<string, unknown> | undefined;
2015
2015
  headers?: Record<string, string> | undefined;
2016
2016
  timeout?: number | undefined;
@@ -2070,6 +2070,12 @@ declare class MCPToolProvider implements ToolProvider {
2070
2070
  }
2071
2071
  declare const mcp: (...configs: ReadonlyArray<MCPServerConfig | MCPServerConfigInput>) => MCPToolProvider;
2072
2072
 
2073
+ /**
2074
+ * Convert a Zod schema to JSON Schema, compatible with both Zod 3 and Zod 4.
2075
+ * Uses native toJSONSchema for Zod 4, falls back to zod-to-json-schema for Zod 3.
2076
+ * Note: Zod 4's toJSONSchema has a bug with single-arg z.record(), so we fall back on error.
2077
+ */
2078
+ declare function zodSchemaToJsonSchema(schema: ZodTypeAny): Record<string, unknown>;
2073
2079
  declare class SchemaValidationError extends Error {
2074
2080
  readonly issues: ZodIssue[];
2075
2081
  constructor(message: string, issues: ZodIssue[]);
@@ -2304,4 +2310,4 @@ declare class ToolRunner {
2304
2310
  };
2305
2311
  }
2306
2312
 
2307
- export { Agent, type AgentConfig, AgentContext, type AgentContextOptions, type AgentContextSnapshot, type AgentDecision, AgentDecisionSchema, AgentEventEmitter, type AgentEventListener, type AgentEventName, type AgentEventPayload, type AgentEventPayloadMap, AgentEvents, type AgentLogger, BaseAgent, type BaseAgentConfig, ConsoleLogger, type CreateSpanOptions, DEFAULT_MODEL, DEFAULT_RETRY_CONFIG, type ExecutionCycle, ExecutionCycleSchema, type Failure, type HookEventName, HookEvents, type HookHandler, HookManager, type HookPayload, type HookPayloadMap, type HookRegistration, InMemoryStore, type IterationSummary, type JsonSchemaOptions, LogLevel, MCPClient, type MCPClientOptions, type MCPServerConfig, type MCPServerConfigInput, MCPServerConfigSchema, type MCPTool, MCPToolProvider, type MCPToolProviderOptions, MCPconfig, type MaybePromise, type Memory, type MemoryCatalogEntry, type MemoryEntry, type MemoryEntryMetadata, MemoryEntryMetadataSchema, MemoryEntrySchema, type MemoryUpdate, MemoryUpdateSchema, type OpperCallOptions, type OpperCallResponse, OpperClient, type OpperClientConfig, type OpperSpan, type OpperStreamChunk, type OpperStreamEvent, type OpperStreamResponse, Result, type RetryConfig, STREAM_ROOT_PATH, type Schema, SchemaValidationError, type SchemaValidationOptions, SilentLogger, StreamAssembler, type StreamAssemblerOptions, type StreamFeedResult, type StreamFinalizeResult, type Success, type Thought, ThoughtSchema, type Tool, type ToolCall, type ToolCallRecord, ToolCallRecordSchema, ToolCallSchema, type ToolDefinition, type ToolExecutionContext, type ToolExecutionSummary, ToolExecutionSummarySchema, type ToolFailure, type ToolFunction, ToolMetadataSchema, type ToolOptions, type ToolProvider, type ToolResult, type ToolResultData, ToolResultFactory, ToolResultFailureSchema, type ToolResultInit, ToolResultSchema, ToolResultSuccessSchema, type ToolRunOptions, ToolRunner, type ToolSuccess, type UnregisterHook, type Usage, UsageSchema, type VisualizationOptions, coerceToolDefinition, createAgentDecisionWithOutputSchema, createFunctionTool, createHookManager, createInMemoryStore, createMCPServerConfig, createOpperClient, createStreamAssembler, createToolCallRecord, err, extractTools, generateAgentFlowDiagram, getDefaultLogger, getSchemaDefault, isSchemaValid, isToolProvider, mcp, mergeSchemaDefaults, normalizeToolEntries, ok, schemaToJson, setDefaultLogger, tool, validateSchema, validateToolInput };
2313
+ export { Agent, type AgentConfig, AgentContext, type AgentContextOptions, type AgentContextSnapshot, type AgentDecision, AgentDecisionSchema, AgentEventEmitter, type AgentEventListener, type AgentEventName, type AgentEventPayload, type AgentEventPayloadMap, AgentEvents, type AgentLogger, BaseAgent, type BaseAgentConfig, ConsoleLogger, type CreateSpanOptions, DEFAULT_MODEL, DEFAULT_RETRY_CONFIG, type ExecutionCycle, ExecutionCycleSchema, type Failure, type HookEventName, HookEvents, type HookHandler, HookManager, type HookPayload, type HookPayloadMap, type HookRegistration, InMemoryStore, type IterationSummary, type JsonSchemaOptions, LogLevel, MCPClient, type MCPClientOptions, type MCPServerConfig, type MCPServerConfigInput, MCPServerConfigSchema, type MCPTool, MCPToolProvider, type MCPToolProviderOptions, MCPconfig, type MaybePromise, type Memory, type MemoryCatalogEntry, type MemoryEntry, type MemoryEntryMetadata, MemoryEntryMetadataSchema, MemoryEntrySchema, type MemoryUpdate, MemoryUpdateSchema, type OpperCallOptions, type OpperCallResponse, OpperClient, type OpperClientConfig, type OpperSpan, type OpperStreamChunk, type OpperStreamEvent, type OpperStreamResponse, Result, type RetryConfig, STREAM_ROOT_PATH, type Schema, SchemaValidationError, type SchemaValidationOptions, SilentLogger, StreamAssembler, type StreamAssemblerOptions, type StreamFeedResult, type StreamFinalizeResult, type Success, type Thought, ThoughtSchema, type Tool, type ToolCall, type ToolCallRecord, ToolCallRecordSchema, ToolCallSchema, type ToolDefinition, type ToolExecutionContext, type ToolExecutionSummary, ToolExecutionSummarySchema, type ToolFailure, type ToolFunction, ToolMetadataSchema, type ToolOptions, type ToolProvider, type ToolResult, type ToolResultData, ToolResultFactory, ToolResultFailureSchema, type ToolResultInit, ToolResultSchema, ToolResultSuccessSchema, type ToolRunOptions, ToolRunner, type ToolSuccess, type UnregisterHook, type Usage, UsageSchema, type VisualizationOptions, coerceToolDefinition, createAgentDecisionWithOutputSchema, createFunctionTool, createHookManager, createInMemoryStore, createMCPServerConfig, createOpperClient, createStreamAssembler, createToolCallRecord, err, extractTools, generateAgentFlowDiagram, getDefaultLogger, getSchemaDefault, isSchemaValid, isToolProvider, mcp, mergeSchemaDefaults, normalizeToolEntries, ok, schemaToJson, setDefaultLogger, tool, validateSchema, validateToolInput, zodSchemaToJsonSchema };
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { randomUUID } from 'crypto';
2
+ import * as zod from 'zod';
2
3
  import { z } from 'zod';
3
4
  import { promises } from 'fs';
4
5
  import { Opper } from 'opperai';
@@ -570,8 +571,11 @@ function getSchemaName(schema) {
570
571
  return schemaAny._def.description;
571
572
  }
572
573
  const typeName = schemaAny._def?.typeName;
573
- if (typeName === "ZodObject" && schemaAny._def) {
574
- const shape = schemaAny._def.shape?.();
574
+ const type = schemaAny._def?.type;
575
+ const isObject = typeName === "ZodObject" || type === "object";
576
+ if (isObject && schemaAny._def) {
577
+ const shapeRaw = schemaAny._def.shape;
578
+ const shape = typeof shapeRaw === "function" ? shapeRaw() : shapeRaw;
575
579
  if (shape && typeof shape === "object") {
576
580
  const keys = Object.keys(shape);
577
581
  if (keys.length > 0) {
@@ -584,6 +588,9 @@ function getSchemaName(schema) {
584
588
  if (typeName) {
585
589
  return typeName.replace("Zod", "").replace("Type", "");
586
590
  }
591
+ if (type) {
592
+ return type.charAt(0).toUpperCase() + type.slice(1);
593
+ }
587
594
  return "Any";
588
595
  } catch {
589
596
  return "Any";
@@ -595,12 +602,15 @@ function extractParameters(schema) {
595
602
  }
596
603
  try {
597
604
  const schemaAny = schema;
598
- if (schemaAny._def?.typeName === "ZodObject") {
599
- const shape = schemaAny._def.shape?.();
605
+ const isObject = schemaAny._def?.typeName === "ZodObject" || schemaAny._def?.type === "object";
606
+ if (isObject) {
607
+ const shapeRaw = schemaAny._def?.shape;
608
+ const shape = typeof shapeRaw === "function" ? shapeRaw() : shapeRaw;
600
609
  if (shape && typeof shape === "object") {
601
610
  const params = [];
602
611
  for (const [key, value] of Object.entries(shape)) {
603
- const fieldType = value?._def?.typeName;
612
+ const valueAny = value;
613
+ const fieldType = valueAny._def?.typeName || valueAny.def?.type || valueAny.type;
604
614
  if (fieldType) {
605
615
  const cleanType = fieldType.replace("Zod", "").toLowerCase();
606
616
  params.push(`${key}: ${cleanType}`);
@@ -1428,7 +1438,7 @@ var ThoughtSchema = z.object({
1428
1438
  */
1429
1439
  confidence: z.number().min(0).max(1).optional(),
1430
1440
  /**
1431
- * Additional metadata
1441
+ * Additional metadata (key-value pairs)
1432
1442
  */
1433
1443
  metadata: z.record(z.string(), z.unknown()).optional()
1434
1444
  });
@@ -1481,7 +1491,7 @@ var AgentDecisionSchema = z.object({
1481
1491
  /**
1482
1492
  * Memory entries to write/update (key -> payload)
1483
1493
  */
1484
- memoryUpdates: z.record(MemoryUpdateSchema).default({}),
1494
+ memoryUpdates: z.record(z.string(), MemoryUpdateSchema).default({}),
1485
1495
  /**
1486
1496
  * Whether the task is complete and finalResult is available
1487
1497
  * (single LLM call pattern)
@@ -1503,7 +1513,7 @@ function createAgentDecisionWithOutputSchema(outputSchema) {
1503
1513
  userMessage: z.string().default("Working on it..."),
1504
1514
  toolCalls: z.array(ToolCallSchema).default([]),
1505
1515
  memoryReads: z.array(z.string()).default([]),
1506
- memoryUpdates: z.record(MemoryUpdateSchema).default({}),
1516
+ memoryUpdates: z.record(z.string(), MemoryUpdateSchema).default({}),
1507
1517
  isComplete: z.boolean().default(false),
1508
1518
  finalResult: finalResultSchema
1509
1519
  });
@@ -1527,10 +1537,60 @@ var ToolExecutionSummarySchema = z.object({
1527
1537
  */
1528
1538
  error: z.string().optional()
1529
1539
  });
1540
+ var hasNativeToJSONSchema = typeof zod.toJSONSchema === "function";
1541
+ function zodSchemaToJsonSchema(schema) {
1542
+ if (hasNativeToJSONSchema) {
1543
+ try {
1544
+ const toJSONSchema2 = zod.toJSONSchema;
1545
+ const result = toJSONSchema2(schema);
1546
+ return result;
1547
+ } catch {
1548
+ }
1549
+ }
1550
+ return zodToJsonSchema(schema);
1551
+ }
1552
+ var SchemaValidationError = class extends Error {
1553
+ issues;
1554
+ constructor(message, issues) {
1555
+ super(message);
1556
+ this.name = "SchemaValidationError";
1557
+ this.issues = issues;
1558
+ }
1559
+ };
1560
+ var validateSchema = (schema, value, options = {}) => {
1561
+ const result = schema.safeParse(value);
1562
+ if (!result.success) {
1563
+ throw new SchemaValidationError(
1564
+ options.message ?? "Schema validation failed",
1565
+ result.error.issues
1566
+ );
1567
+ }
1568
+ return result.data;
1569
+ };
1570
+ var isSchemaValid = (schema, value) => {
1571
+ return schema.safeParse(value).success;
1572
+ };
1573
+ var schemaToJson = (schema, options = {}) => {
1574
+ if (hasNativeToJSONSchema) {
1575
+ return zodSchemaToJsonSchema(schema);
1576
+ }
1577
+ return zodToJsonSchema(schema, options);
1578
+ };
1579
+ var getSchemaDefault = (schema) => {
1580
+ const result = schema.safeParse(void 0);
1581
+ return result.success ? result.data : void 0;
1582
+ };
1583
+ var mergeSchemaDefaults = (schema, value) => {
1584
+ const defaults = getSchemaDefault(schema);
1585
+ if (defaults && typeof defaults === "object") {
1586
+ return validateSchema(schema, { ...defaults, ...value });
1587
+ }
1588
+ return validateSchema(schema, value);
1589
+ };
1530
1590
 
1531
1591
  // package.json
1532
1592
  var package_default = {
1533
- version: "0.3.0-beta"};
1593
+ version: "0.3.0"};
1534
1594
 
1535
1595
  // src/utils/version.ts
1536
1596
  var SDK_NAME = "@opperai/agents";
@@ -1761,7 +1821,7 @@ var OpperClient = class {
1761
1821
  }
1762
1822
  if (isZodSchema(schema)) {
1763
1823
  try {
1764
- return zodToJsonSchema(schema);
1824
+ return zodSchemaToJsonSchema(schema);
1765
1825
  } catch (error) {
1766
1826
  this.logger.warn("Failed to convert Zod schema to JSON Schema", {
1767
1827
  error: error instanceof Error ? error.message : String(error)
@@ -1787,41 +1847,6 @@ var OpperClient = class {
1787
1847
  function createOpperClient(apiKey, options) {
1788
1848
  return new OpperClient(apiKey, options);
1789
1849
  }
1790
- var SchemaValidationError = class extends Error {
1791
- issues;
1792
- constructor(message, issues) {
1793
- super(message);
1794
- this.name = "SchemaValidationError";
1795
- this.issues = issues;
1796
- }
1797
- };
1798
- var validateSchema = (schema, value, options = {}) => {
1799
- const result = schema.safeParse(value);
1800
- if (!result.success) {
1801
- throw new SchemaValidationError(
1802
- options.message ?? "Schema validation failed",
1803
- result.error.issues
1804
- );
1805
- }
1806
- return result.data;
1807
- };
1808
- var isSchemaValid = (schema, value) => {
1809
- return schema.safeParse(value).success;
1810
- };
1811
- var schemaToJson = (schema, options = {}) => {
1812
- return zodToJsonSchema(schema, options);
1813
- };
1814
- var getSchemaDefault = (schema) => {
1815
- const result = schema.safeParse(void 0);
1816
- return result.success ? result.data : void 0;
1817
- };
1818
- var mergeSchemaDefaults = (schema, value) => {
1819
- const defaults = getSchemaDefault(schema);
1820
- if (defaults && typeof defaults === "object") {
1821
- return validateSchema(schema, { ...defaults, ...value });
1822
- }
1823
- return validateSchema(schema, value);
1824
- };
1825
1850
 
1826
1851
  // src/utils/streaming.ts
1827
1852
  var STREAM_ROOT_PATH = "_root";
@@ -2106,6 +2131,7 @@ var Agent = class extends BaseAgent {
2106
2131
  this.log("Task completed with final result in single call", {
2107
2132
  iteration: currentIteration
2108
2133
  });
2134
+ await this.handleMemoryActions(decision, context, thinkSpanId);
2109
2135
  let finalResult;
2110
2136
  if (this.outputSchema) {
2111
2137
  const parseResult = this.outputSchema.safeParse(
@@ -3744,6 +3770,6 @@ var ToolRunner = class {
3744
3770
  }
3745
3771
  };
3746
3772
 
3747
- export { Agent, AgentContext, AgentDecisionSchema, AgentEventEmitter, AgentEvents, BaseAgent, ConsoleLogger, DEFAULT_MODEL, DEFAULT_RETRY_CONFIG, ExecutionCycleSchema, HookEvents, HookManager, InMemoryStore, LogLevel, MCPClient, MCPServerConfigSchema, MCPToolProvider, MCPconfig, MemoryEntryMetadataSchema, MemoryEntrySchema, MemoryUpdateSchema, OpperClient, Result, STREAM_ROOT_PATH, SchemaValidationError, SilentLogger, StreamAssembler, ThoughtSchema, ToolCallRecordSchema, ToolCallSchema, ToolExecutionSummarySchema, ToolMetadataSchema, ToolResultFactory, ToolResultFailureSchema, ToolResultSchema, ToolResultSuccessSchema, ToolRunner, UsageSchema, coerceToolDefinition, createAgentDecisionWithOutputSchema, createFunctionTool, createHookManager, createInMemoryStore, createMCPServerConfig, createOpperClient, createStreamAssembler, createToolCallRecord, err, extractTools, generateAgentFlowDiagram, getDefaultLogger, getSchemaDefault, isSchemaValid, isToolProvider, mcp, mergeSchemaDefaults, normalizeToolEntries, ok, schemaToJson, setDefaultLogger, tool, validateSchema, validateToolInput };
3773
+ export { Agent, AgentContext, AgentDecisionSchema, AgentEventEmitter, AgentEvents, BaseAgent, ConsoleLogger, DEFAULT_MODEL, DEFAULT_RETRY_CONFIG, ExecutionCycleSchema, HookEvents, HookManager, InMemoryStore, LogLevel, MCPClient, MCPServerConfigSchema, MCPToolProvider, MCPconfig, MemoryEntryMetadataSchema, MemoryEntrySchema, MemoryUpdateSchema, OpperClient, Result, STREAM_ROOT_PATH, SchemaValidationError, SilentLogger, StreamAssembler, ThoughtSchema, ToolCallRecordSchema, ToolCallSchema, ToolExecutionSummarySchema, ToolMetadataSchema, ToolResultFactory, ToolResultFailureSchema, ToolResultSchema, ToolResultSuccessSchema, ToolRunner, UsageSchema, coerceToolDefinition, createAgentDecisionWithOutputSchema, createFunctionTool, createHookManager, createInMemoryStore, createMCPServerConfig, createOpperClient, createStreamAssembler, createToolCallRecord, err, extractTools, generateAgentFlowDiagram, getDefaultLogger, getSchemaDefault, isSchemaValid, isToolProvider, mcp, mergeSchemaDefaults, normalizeToolEntries, ok, schemaToJson, setDefaultLogger, tool, validateSchema, validateToolInput, zodSchemaToJsonSchema };
3748
3774
  //# sourceMappingURL=index.js.map
3749
3775
  //# sourceMappingURL=index.js.map