@cognipeer/agent-sdk 0.4.8 → 0.5.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.ts CHANGED
@@ -1,6 +1,60 @@
1
- import { ZodSchema, z } from 'zod';
1
+ import { ZodError, ZodSchema, z } from 'zod';
2
2
  import { JSONSchema7 } from 'json-schema';
3
3
 
4
+ /** Describes what a model/provider natively supports. */
5
+ type ModelCapabilities = {
6
+ /** How the model supports structured output:
7
+ * - "native": model accepts response_format with json_schema (OpenAI, Gemini, etc.)
8
+ * - "tool_based": structured output must be emulated via a response tool
9
+ */
10
+ structuredOutput?: "native" | "tool_based";
11
+ /** Whether tools must be bound with strict=true for native structured output auto-parsing. */
12
+ strictToolCalling?: boolean;
13
+ /** Whether the model supports streaming */
14
+ streaming?: boolean;
15
+ /** Provider identifier (e.g. "openai", "anthropic", "bedrock", "google") */
16
+ provider?: string;
17
+ };
18
+ type StructuredOutputFieldError = {
19
+ path: string;
20
+ expected: string;
21
+ received: string;
22
+ message: string;
23
+ };
24
+ type StructuredOutputError = {
25
+ type: "parse_error" | "validation_error" | "no_output" | "max_retries";
26
+ message: string;
27
+ fieldErrors?: StructuredOutputFieldError[];
28
+ rawContent?: string;
29
+ };
30
+ type StructuredOutputResult<T> = {
31
+ success: true;
32
+ data: T;
33
+ attempts: number;
34
+ } | {
35
+ success: false;
36
+ error: StructuredOutputError;
37
+ attempts: number;
38
+ rawContent?: string;
39
+ };
40
+ /**
41
+ * Encapsulates how structured output is achieved for a given model/provider.
42
+ * NativeJsonSchemaStrategy uses response_format; ToolBasedStrategy uses a response tool.
43
+ */
44
+ interface StructuredOutputStrategy {
45
+ readonly kind: "native" | "tool_based";
46
+ /**
47
+ * Build a correction prompt when validation fails.
48
+ * The prompt tells the model exactly which fields were wrong.
49
+ */
50
+ buildCorrectionPrompt(error: ZodError<any>, previousAttempt: unknown): string;
51
+ }
52
+ type StructuredOutputManagerConfig = {
53
+ maxRetries?: number;
54
+ };
55
+ declare function getNestedValue(obj: unknown, path: (string | number)[]): unknown;
56
+ declare function formatZodError(error: ZodError<any>, rawContent?: string): StructuredOutputError;
57
+
4
58
  interface BaseChatMessagePart {
5
59
  type?: string;
6
60
  text?: string;
@@ -37,13 +91,20 @@ interface BaseChatModel {
37
91
  isCancellationRequested: boolean;
38
92
  };
39
93
  }): AsyncIterable<BaseChatMessage | BaseChatMessagePart | string>;
40
- bindTools?(tools: any[]): BaseChatModel;
94
+ bindTools?(tools: any[], options?: {
95
+ strict?: boolean;
96
+ [key: string]: any;
97
+ }): BaseChatModel;
41
98
  modelName?: string;
99
+ capabilities?: ModelCapabilities;
42
100
  [key: string]: any;
43
101
  }
44
102
  type SmartModel = BaseChatModel;
45
103
  declare function isSmartModel(m: any): m is SmartModel;
46
- declare function withTools(model: SmartModel, tools: any[]): BaseChatModel;
104
+ declare function withTools(model: SmartModel, tools: any[], options?: {
105
+ strict?: boolean;
106
+ [key: string]: any;
107
+ }): BaseChatModel;
47
108
  declare function fromLangchainModel(lcModel: any): BaseChatModel;
48
109
 
49
110
  type ImageURL = {
@@ -54,7 +115,7 @@ type ImageURL = {
54
115
  media_type?: string;
55
116
  detail?: 'auto' | 'low' | 'high';
56
117
  } | string;
57
- type ContentPart = {
118
+ type ContentPart$1 = {
58
119
  type: 'text';
59
120
  text: string;
60
121
  } | {
@@ -82,7 +143,7 @@ type RunnableConfig = {
82
143
  type BaseMessage = {
83
144
  role: string;
84
145
  name?: string;
85
- content: string | ContentPart[];
146
+ content: string | ContentPart$1[];
86
147
  tool_calls?: any;
87
148
  tool_call_id?: string;
88
149
  [key: string]: any;
@@ -377,6 +438,7 @@ type AgentRuntimeConfig = {
377
438
  limits?: AgentLimits;
378
439
  useTodoList?: boolean;
379
440
  outputSchema?: ZodSchema<any>;
441
+ responseFormat?: Record<string, any>;
380
442
  tracing?: TracingConfig;
381
443
  runtimeProfile?: RuntimeProfile;
382
444
  smart?: ResolvedSmartAgentConfig;
@@ -906,6 +968,7 @@ type RestoreSnapshotOptions = {
906
968
  type AgentInvokeResult<TOutput = unknown> = {
907
969
  content: string;
908
970
  output?: TOutput;
971
+ outputError?: StructuredOutputError;
909
972
  metadata: {
910
973
  usage?: any;
911
974
  };
@@ -1176,6 +1239,152 @@ type CodeGuardrailOptions = GuardrailPresetBase & {
1176
1239
  };
1177
1240
  declare function createCodeGuardrail(options?: CodeGuardrailOptions): ConversationGuardrail;
1178
1241
 
1242
+ /**
1243
+ * Centralized manager for structured output across both base Agent and SmartAgent.
1244
+ *
1245
+ * Responsibilities:
1246
+ * - Prepare tools or response_format depending on the resolved strategy
1247
+ * - Build system prompt hints tailored to the strategy
1248
+ * - Build nudge/correction prompts for retries
1249
+ * - Parse final output from tool result or assistant content
1250
+ * - Report structured errors (never silently swallow)
1251
+ */
1252
+ declare class StructuredOutputManager<T> {
1253
+ readonly strategy: StructuredOutputStrategy;
1254
+ readonly schema: ZodSchema<T>;
1255
+ readonly maxRetries: number;
1256
+ constructor(schema: ZodSchema<T>, strategy: StructuredOutputStrategy, config?: StructuredOutputManagerConfig);
1257
+ /**
1258
+ * Get the `response` tool for tool-based strategy.
1259
+ * Returns undefined for native strategy (no tool needed).
1260
+ */
1261
+ getResponseTool(): ToolInterface | undefined;
1262
+ /**
1263
+ * Get response_format config for native strategy.
1264
+ * Returns undefined for tool-based strategy.
1265
+ */
1266
+ getResponseFormat(): Record<string, any> | undefined;
1267
+ /**
1268
+ * Build the system prompt hint that tells the model how to produce structured output.
1269
+ */
1270
+ buildSystemPromptHint(): string;
1271
+ /**
1272
+ * Build a nudge message for when the model didn't produce structured output.
1273
+ * Used by the agent loop when it needs to retry.
1274
+ */
1275
+ buildNudgeMessage(isLastAttempt: boolean): {
1276
+ role: string;
1277
+ content: string;
1278
+ };
1279
+ /**
1280
+ * Build a correction message when schema validation failed.
1281
+ */
1282
+ buildCorrectionMessage(error: StructuredOutputError, _previousAttempt?: unknown): {
1283
+ role: string;
1284
+ content: string;
1285
+ };
1286
+ /**
1287
+ * Try to parse structured output from the tool-based finalization result.
1288
+ * Called when __structuredOutputParsed is available in ctx.
1289
+ */
1290
+ parseFromToolResult(data: unknown): StructuredOutputResult<T>;
1291
+ /**
1292
+ * Try to parse structured output from assistant message content.
1293
+ * For native strategy: content should be valid JSON.
1294
+ * For tool-based strategy: last-resort fallback extraction from text.
1295
+ */
1296
+ parseFromContent(content: string): StructuredOutputResult<T>;
1297
+ /**
1298
+ * Create a "no output" error result.
1299
+ */
1300
+ noOutputResult(attempts: number, rawContent?: string): StructuredOutputResult<T>;
1301
+ /**
1302
+ * Create a "max retries" error result.
1303
+ */
1304
+ maxRetriesResult(lastError: StructuredOutputError, attempts: number, rawContent?: string): StructuredOutputResult<T>;
1305
+ }
1306
+
1307
+ /**
1308
+ * Tool-based structured output strategy.
1309
+ *
1310
+ * Injects a hidden `response` tool that the model must call with the final JSON.
1311
+ * This is the universal fallback that works with all providers.
1312
+ */
1313
+ declare class ToolBasedStrategy implements StructuredOutputStrategy {
1314
+ readonly kind: "tool_based";
1315
+ /**
1316
+ * Create the `response` tool for a given Zod schema.
1317
+ * The tool validates input against the schema and returns a sentinel object
1318
+ * that the tools node picks up to finalize the structured output.
1319
+ */
1320
+ createResponseTool<T>(schema: ZodSchema<T>): ToolInterface;
1321
+ /**
1322
+ * Try to extract structured output from raw assistant text content.
1323
+ * Used as a last resort when the model writes JSON directly instead of calling the tool.
1324
+ */
1325
+ extractFromText<T>(content: string, schema: ZodSchema<T>): {
1326
+ data: T;
1327
+ } | {
1328
+ error: StructuredOutputError;
1329
+ };
1330
+ buildCorrectionPrompt(error: ZodError<any>, previousAttempt: unknown): string;
1331
+ }
1332
+
1333
+ /**
1334
+ * Native JSON Schema strategy for providers that support `response_format`.
1335
+ *
1336
+ * Works with OpenAI (gpt-4o+), Google Gemini, and similar providers
1337
+ * that accept `response_format: { type: "json_schema", json_schema: {...} }`.
1338
+ *
1339
+ * The model guarantees valid JSON output matching the schema — no tool needed.
1340
+ */
1341
+ declare class NativeJsonSchemaStrategy implements StructuredOutputStrategy {
1342
+ readonly kind: "native";
1343
+ private resolveJsonPointer;
1344
+ private unwrapRootObjectSchema;
1345
+ private normalizeOpenAIStrictSchema;
1346
+ /**
1347
+ * Convert a Zod schema to the JSON Schema object used in response_format.
1348
+ */
1349
+ toJsonSchema(schema: ZodSchema<any>, name?: string): Record<string, any>;
1350
+ /**
1351
+ * Build response_format configuration for the model call.
1352
+ * Returns the object that should be spread into model invocation options.
1353
+ */
1354
+ buildResponseFormat(schema: ZodSchema<any>, name?: string): Record<string, any>;
1355
+ /**
1356
+ * Parse and validate model response content.
1357
+ * With native support, content is guaranteed JSON — but we still validate with Zod
1358
+ * for type safety and field-level error reporting.
1359
+ */
1360
+ extractOutput<T>(content: string, schema: ZodSchema<T>): {
1361
+ data: T;
1362
+ } | {
1363
+ error: StructuredOutputError;
1364
+ };
1365
+ buildCorrectionPrompt(error: ZodError<any>, previousAttempt: unknown): string;
1366
+ }
1367
+
1368
+ /**
1369
+ * Resolve the most appropriate structured output strategy for a given model.
1370
+ *
1371
+ * If the model exposes capabilities (via adapter or direct provider),
1372
+ * we use native JSON Schema support when available. Otherwise we fall back
1373
+ * to the universal tool-based approach.
1374
+ *
1375
+ * When direct providers are added to the SDK, they should set
1376
+ * `model.capabilities.structuredOutput = "native"` for providers that support
1377
+ * response_format (OpenAI, Gemini, etc.).
1378
+ */
1379
+ declare function resolveStrategy(model: any): StructuredOutputStrategy;
1380
+ /**
1381
+ * Extract capabilities from a model object.
1382
+ * Supports:
1383
+ * - model.capabilities (set by adapters or direct providers)
1384
+ * - Auto-detection from model class name / metadata
1385
+ */
1386
+ declare function getModelCapabilities(model: any): ModelCapabilities;
1387
+
1179
1388
  declare function captureSnapshot(state: SmartState, options?: SnapshotOptions): AgentSnapshot;
1180
1389
  declare function restoreSnapshot(snapshot: AgentSnapshot, restoreOptions?: RestoreSnapshotOptions): SmartState;
1181
1390
 
@@ -1213,4 +1422,292 @@ declare function generateSpanId(): string;
1213
1422
  */
1214
1423
  declare function startStreamingSession(session: TraceSessionRuntime | undefined, agentRuntime?: AgentRuntimeConfig): Promise<void>;
1215
1424
 
1216
- export { type AIMessage, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, type BuiltInRuntimeProfile, type CancellationTokenLike, type CancelledEvent, type ChildContextPolicy, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type ContextPolicy, type ConversationGuardrail, type CustomRuleCallback, type CustomRuleOptions, DEFAULT_PROFILE_CONFIGS, type DelegationMode, type EvalCase, type EvalCaseResult, type EvalFamily, type EvalHarnessMetrics, type EvalHarnessParams, type EvalHarnessResult, type EvalProfileDescriptor, type EvalProfileTarget, type FinalAnswerEvent, type GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailOutcome, GuardrailPhase, type GuardrailRule, type HandoffDescriptor, type HandoffEvent, InMemoryMemoryStore, type InvokeConfig, type JsonGuardrailOptions, type JsonSchemaRuleOptions, type MemoryFact, type MemoryProviderKind, type MemoryReadPolicy, type MemoryScope, type MemoryStore, type MemoryWritePolicy, type Message, type MetadataEvent, type PendingToolApproval, type PlanEvent, type PlanStepRecord, type PlanningMode, type ProfileConfig, type ProgressEvent, type ProgressUpdate, type RegexGuardrailOptions, type RegexRuleOptions, type ReplanPolicy, type ResolvedSmartAgentConfig, type ResolvedTraceConfig, type ResolvedTraceSink, type RestoreSnapshotOptions, type RuntimeProfile, type SerializableSmartState, type SmartAgentBudgetConfig, type SmartAgentContextConfig, type SmartAgentCustomProfileConfig, type SmartAgentDelegationConfig, type SmartAgentEvent, type SmartAgentInstance, type SmartAgentLimits, type SmartAgentMemoryConfig, type SmartAgentOptions, type SmartAgentPlanningConfig, type SmartAgentSummarizationConfig, type SmartAgentToolResponseConfig, type SmartAgentTracingConfig, type SmartModel, type SmartState, type SmartToolFn, type SnapshotOptions, type SnapshotRuntimeHint, type StreamChunk, type StreamEvent, type StructuredSummary, type SummarizationEvent, type SummarizationMode, type SummaryFactItem, type SummaryIntegrityCheck, type TokenLimits, type ToolApprovalEvent, type ToolApprovalResolution, type ToolApprovalStatus, type ToolCallEvent, type ToolInterface, type ToolResponseClassification, type ToolResponseRetentionPolicy, type TraceDataSection, type TraceErrorRecord, type TraceEventRecord, type TraceMessageSection, type TraceMetadataSection, type TraceSessionConfigSnapshot, type TraceSessionFile, type TraceSessionStatus, type TraceSessionSummary, type TraceSinkCognipeerConfig, type TraceSinkConfig, type TraceSinkCustomConfig, type TraceSinkFileConfig, type TraceSinkHttpConfig, type TraceSinkOtlpConfig, type TraceSinkSnapshot, type TraceSummarySection, type TraceToolCallSection, type TraceToolResultSection, type TracingConfig, type TracingMode, agentVerdictRule, applyTokenLimits, buildSystemPrompt, captureSnapshot, codePresenceRule, cognipeerSink, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createCodeGuardrail, createContextSummarizeNode, createContextTools, createGuardrail, createJsonGuardrail, createRegexGuardrail, createResolverNode, createSmartAgent, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, evaluateGuardrails, fileSink, fromLangchainModel, fromLangchainTools, generateSpanId, generateTraceId, getResolvedSmartConfig, httpSink, isSmartModel, jsonSchemaRule, normalizeSmartAgentOptions, otlpSink, readMemoryFacts, regexRule, renderMemoryFacts, resolveMemoryStore, resolveToolApprovalState, restoreSnapshot, runSmartAgentEvalHarness, startStreamingSession, traceSessionToOtlp, withTools, writeSummaryFactsToMemory };
1425
+ type MessageRole = "system" | "user" | "assistant" | "tool";
1426
+ type TextContent = {
1427
+ type: "text";
1428
+ text: string;
1429
+ };
1430
+ type ImageContent = {
1431
+ type: "image";
1432
+ source: {
1433
+ type: "base64";
1434
+ mediaType: string;
1435
+ data: string;
1436
+ } | {
1437
+ type: "url";
1438
+ url: string;
1439
+ };
1440
+ };
1441
+ type ContentPart = TextContent | ImageContent;
1442
+ type ToolCall = {
1443
+ id: string;
1444
+ name: string;
1445
+ arguments: string;
1446
+ };
1447
+ type UnifiedMessage = {
1448
+ role: MessageRole;
1449
+ content: string | ContentPart[];
1450
+ name?: string;
1451
+ toolCalls?: ToolCall[];
1452
+ toolCallId?: string;
1453
+ };
1454
+ type ToolDefinition = {
1455
+ name: string;
1456
+ description: string;
1457
+ parameters: Record<string, any>;
1458
+ strict?: boolean;
1459
+ };
1460
+ type ChatCompletionRequest = {
1461
+ model: string;
1462
+ messages: UnifiedMessage[];
1463
+ temperature?: number;
1464
+ maxTokens?: number;
1465
+ topP?: number;
1466
+ stop?: string[];
1467
+ tools?: ToolDefinition[];
1468
+ toolChoice?: "auto" | "required" | "none" | {
1469
+ name: string;
1470
+ };
1471
+ responseFormat?: {
1472
+ type: "json_schema" | "json_object" | "text";
1473
+ schema?: Record<string, any>;
1474
+ name?: string;
1475
+ };
1476
+ stream?: boolean;
1477
+ extra?: Record<string, any>;
1478
+ };
1479
+ type TokenUsage = {
1480
+ inputTokens: number;
1481
+ outputTokens: number;
1482
+ totalTokens: number;
1483
+ cachedInputTokens: number;
1484
+ cachedWriteTokens: number;
1485
+ cachedOutputTokens: number;
1486
+ reasoningTokens: number;
1487
+ };
1488
+ declare function emptyUsage(): TokenUsage;
1489
+ type FinishReason = "stop" | "tool_calls" | "length" | "content_filter" | "error";
1490
+ type ChatCompletionResponse = {
1491
+ id: string;
1492
+ model: string;
1493
+ content: string | null;
1494
+ toolCalls: ToolCall[];
1495
+ usage: TokenUsage;
1496
+ finishReason: FinishReason;
1497
+ raw: any;
1498
+ };
1499
+ type ChatCompletionChunk = {
1500
+ id: string;
1501
+ model: string;
1502
+ delta: {
1503
+ content?: string;
1504
+ toolCalls?: Partial<ToolCall>[];
1505
+ };
1506
+ usage?: TokenUsage;
1507
+ finishReason?: FinishReason;
1508
+ };
1509
+ type OpenAIProviderConfig = {
1510
+ provider: "openai";
1511
+ apiKey: string;
1512
+ baseURL?: string;
1513
+ organization?: string;
1514
+ defaultModel?: string;
1515
+ defaultHeaders?: Record<string, string>;
1516
+ };
1517
+ type AnthropicProviderConfig = {
1518
+ provider: "anthropic";
1519
+ apiKey: string;
1520
+ baseURL?: string;
1521
+ defaultModel?: string;
1522
+ defaultHeaders?: Record<string, string>;
1523
+ anthropicVersion?: string;
1524
+ };
1525
+ type AzureProviderConfig = {
1526
+ provider: "azure";
1527
+ apiKey: string;
1528
+ endpoint: string;
1529
+ apiVersion?: string;
1530
+ deploymentName?: string;
1531
+ defaultModel?: string;
1532
+ defaultHeaders?: Record<string, string>;
1533
+ };
1534
+ type OpenAICompatibleProviderConfig = {
1535
+ provider: "openai-compatible";
1536
+ apiKey: string;
1537
+ baseURL: string;
1538
+ defaultModel?: string;
1539
+ defaultHeaders?: Record<string, string>;
1540
+ };
1541
+ type BedrockProviderConfig = {
1542
+ provider: "bedrock";
1543
+ region: string;
1544
+ accessKeyId?: string;
1545
+ secretAccessKey?: string;
1546
+ sessionToken?: string;
1547
+ defaultModel?: string;
1548
+ defaultHeaders?: Record<string, string>;
1549
+ };
1550
+ type VertexProviderConfig = {
1551
+ provider: "vertex";
1552
+ projectId: string;
1553
+ location?: string;
1554
+ accessToken?: string;
1555
+ serviceAccountJson?: string | Record<string, any>;
1556
+ defaultModel?: string;
1557
+ defaultHeaders?: Record<string, string>;
1558
+ };
1559
+ type ProviderConfig = OpenAIProviderConfig | AnthropicProviderConfig | AzureProviderConfig | OpenAICompatibleProviderConfig | BedrockProviderConfig | VertexProviderConfig;
1560
+ type ProviderType = ProviderConfig["provider"];
1561
+ declare class ProviderError extends Error {
1562
+ readonly provider: string;
1563
+ readonly statusCode?: number | undefined;
1564
+ readonly responseBody?: any | undefined;
1565
+ constructor(message: string, provider: string, statusCode?: number | undefined, responseBody?: any | undefined);
1566
+ }
1567
+
1568
+ declare abstract class BaseProvider {
1569
+ abstract readonly providerName: ProviderType;
1570
+ /** Non-streaming completion */
1571
+ abstract complete(request: ChatCompletionRequest): Promise<ChatCompletionResponse>;
1572
+ /** Streaming completion – yields incremental chunks */
1573
+ abstract completeStream(request: ChatCompletionRequest): AsyncGenerator<ChatCompletionChunk, void, unknown>;
1574
+ }
1575
+
1576
+ declare class OpenAIProvider extends BaseProvider {
1577
+ readonly providerName: ProviderType;
1578
+ protected readonly apiKey: string;
1579
+ protected readonly baseURL: string;
1580
+ protected readonly defaultModel: string;
1581
+ protected readonly defaultHeaders: Record<string, string>;
1582
+ constructor(config: OpenAIProviderConfig);
1583
+ complete(request: ChatCompletionRequest): Promise<ChatCompletionResponse>;
1584
+ completeStream(request: ChatCompletionRequest): AsyncGenerator<ChatCompletionChunk, void, unknown>;
1585
+ protected buildRequestBody(request: ChatCompletionRequest, stream: boolean): Record<string, any>;
1586
+ protected toOpenAIMessage(m: UnifiedMessage): Record<string, any>;
1587
+ protected toOpenAITool(t: ToolDefinition): Record<string, any>;
1588
+ protected doFetch(body: Record<string, any>): Promise<Response>;
1589
+ protected parseResponse(json: any): ChatCompletionResponse;
1590
+ protected extractUsage(usage: any): TokenUsage;
1591
+ }
1592
+
1593
+ declare class AnthropicProvider extends BaseProvider {
1594
+ readonly providerName: ProviderType;
1595
+ private readonly apiKey;
1596
+ private readonly baseURL;
1597
+ private readonly defaultModel;
1598
+ private readonly defaultHeaders;
1599
+ private readonly anthropicVersion;
1600
+ constructor(config: AnthropicProviderConfig);
1601
+ complete(request: ChatCompletionRequest): Promise<ChatCompletionResponse>;
1602
+ completeStream(request: ChatCompletionRequest): AsyncGenerator<ChatCompletionChunk, void, unknown>;
1603
+ private buildRequestBody;
1604
+ private splitSystemMessages;
1605
+ private toAnthropicMessage;
1606
+ private toAnthropicTool;
1607
+ private doFetch;
1608
+ private parseResponse;
1609
+ }
1610
+
1611
+ declare class AzureProvider extends OpenAIProvider {
1612
+ readonly providerName: ProviderType;
1613
+ private readonly endpoint;
1614
+ private readonly apiVersion;
1615
+ private readonly deploymentName?;
1616
+ private readonly azureApiKey;
1617
+ constructor(config: AzureProviderConfig);
1618
+ protected doFetch(body: Record<string, any>): Promise<Response>;
1619
+ }
1620
+
1621
+ declare class OpenAICompatibleProvider extends OpenAIProvider {
1622
+ readonly providerName: ProviderType;
1623
+ constructor(config: OpenAICompatibleProviderConfig);
1624
+ }
1625
+
1626
+ declare class BedrockProvider extends BaseProvider {
1627
+ readonly providerName: ProviderType;
1628
+ private readonly region;
1629
+ private readonly credentials;
1630
+ private readonly defaultModel;
1631
+ private readonly defaultHeaders;
1632
+ constructor(config: BedrockProviderConfig);
1633
+ complete(request: ChatCompletionRequest): Promise<ChatCompletionResponse>;
1634
+ completeStream(request: ChatCompletionRequest): AsyncGenerator<ChatCompletionChunk, void, unknown>;
1635
+ private buildConverseBody;
1636
+ private splitSystemMessages;
1637
+ private toBedrockMessage;
1638
+ private toBedrockTool;
1639
+ private doFetch;
1640
+ private parseResponse;
1641
+ }
1642
+
1643
+ declare class VertexProvider extends BaseProvider {
1644
+ readonly providerName: ProviderType;
1645
+ private readonly projectId;
1646
+ private readonly location;
1647
+ private readonly defaultModel;
1648
+ private readonly defaultHeaders;
1649
+ private accessToken?;
1650
+ private serviceAccountJson?;
1651
+ private tokenExpiry;
1652
+ constructor(config: VertexProviderConfig);
1653
+ complete(request: ChatCompletionRequest): Promise<ChatCompletionResponse>;
1654
+ completeStream(request: ChatCompletionRequest): AsyncGenerator<ChatCompletionChunk, void, unknown>;
1655
+ private buildUrl;
1656
+ private buildGeminiBody;
1657
+ private buildContents;
1658
+ private toGeminiContent;
1659
+ private toGeminiTool;
1660
+ private getAccessToken;
1661
+ private getTokenFromServiceAccount;
1662
+ private doFetch;
1663
+ private parseResponse;
1664
+ private parseStreamChunk;
1665
+ }
1666
+
1667
+ type NativeModelOptions = {
1668
+ /** Override the model ID per adapter instance */
1669
+ model?: string;
1670
+ /** Default temperature */
1671
+ temperature?: number;
1672
+ /** Default max tokens */
1673
+ maxTokens?: number;
1674
+ /** Provider-specific extras passed on every request */
1675
+ extra?: Record<string, any>;
1676
+ };
1677
+ /**
1678
+ * Creates a BaseChatModel from a native provider.
1679
+ *
1680
+ * Usage:
1681
+ * ```ts
1682
+ * const provider = createProvider({ provider: "openai", apiKey: "..." });
1683
+ * const model = fromNativeProvider(provider, { model: "gpt-4o" });
1684
+ * const agent = createSmartAgent({ model, tools: [...] });
1685
+ * ```
1686
+ */
1687
+ declare function fromNativeProvider(provider: BaseProvider, options?: NativeModelOptions): BaseChatModel;
1688
+
1689
+ /**
1690
+ * Factory function to create a provider from a config object.
1691
+ *
1692
+ * @example
1693
+ * ```ts
1694
+ * const provider = createProvider({
1695
+ * provider: "openai",
1696
+ * apiKey: process.env.OPENAI_API_KEY!,
1697
+ * });
1698
+ *
1699
+ * // Direct usage
1700
+ * const response = await provider.complete({
1701
+ * model: "gpt-4o",
1702
+ * messages: [{ role: "user", content: "Hello!" }],
1703
+ * });
1704
+ *
1705
+ * // Or wrap as BaseChatModel for agent-sdk
1706
+ * import { fromNativeProvider } from "./adapter";
1707
+ * const model = fromNativeProvider(provider, { model: "gpt-4o" });
1708
+ * const agent = createSmartAgent({ model, tools: [...] });
1709
+ * ```
1710
+ */
1711
+ declare function createProvider(config: ProviderConfig): BaseProvider;
1712
+
1713
+ export { type AIMessage, type AgentInstance, type AgentInvokeResult, type AgentLimits, type AgentOptions, type AgentRuleOptions, type AgentRuntimeConfig, type AgentSnapshot, type AgentSnapshotMetadata, type AgentState, AnthropicProvider, type AnthropicProviderConfig, AzureProvider, type AzureProviderConfig, type BaseChatMessage, type BaseChatMessagePart, type BaseChatModel, type BaseMessage, BaseProvider, BedrockProvider, type BedrockProviderConfig, type BuiltInRuntimeProfile, type CancellationTokenLike, type CancelledEvent, type ChatCompletionChunk, type ChatCompletionRequest, type ChatCompletionResponse, type ChildContextPolicy, type CodeDetectionRuleOptions, type CodeGuardrailOptions, type ContextPolicy, type ConversationGuardrail, type CustomRuleCallback, type CustomRuleOptions, DEFAULT_PROFILE_CONFIGS, type DelegationMode, type EvalCase, type EvalCaseResult, type EvalFamily, type EvalHarnessMetrics, type EvalHarnessParams, type EvalHarnessResult, type EvalProfileDescriptor, type EvalProfileTarget, type FinalAnswerEvent, type FinishReason, type GuardrailContext, type GuardrailDisposition, type GuardrailEvent, type GuardrailIncident, type GuardrailOutcome, GuardrailPhase, type GuardrailRule, type HandoffDescriptor, type HandoffEvent, InMemoryMemoryStore, type InvokeConfig, type JsonGuardrailOptions, type JsonSchemaRuleOptions, type MemoryFact, type MemoryProviderKind, type MemoryReadPolicy, type MemoryScope, type MemoryStore, type MemoryWritePolicy, type Message, type MetadataEvent, type ModelCapabilities, NativeJsonSchemaStrategy, type NativeModelOptions, OpenAICompatibleProvider, type OpenAICompatibleProviderConfig, OpenAIProvider, type OpenAIProviderConfig, type PendingToolApproval, type PlanEvent, type PlanStepRecord, type PlanningMode, type ProfileConfig, type ProgressEvent, type ProgressUpdate, type ProviderConfig, ProviderError, type ToolCall as ProviderToolCall, type ToolDefinition as ProviderToolDefinition, type ProviderType, type RegexGuardrailOptions, type RegexRuleOptions, type ReplanPolicy, type ResolvedSmartAgentConfig, type ResolvedTraceConfig, type ResolvedTraceSink, type RestoreSnapshotOptions, type RuntimeProfile, type SerializableSmartState, type SmartAgentBudgetConfig, type SmartAgentContextConfig, type SmartAgentCustomProfileConfig, type SmartAgentDelegationConfig, type SmartAgentEvent, type SmartAgentInstance, type SmartAgentLimits, type SmartAgentMemoryConfig, type SmartAgentOptions, type SmartAgentPlanningConfig, type SmartAgentSummarizationConfig, type SmartAgentToolResponseConfig, type SmartAgentTracingConfig, type SmartModel, type SmartState, type SmartToolFn, type SnapshotOptions, type SnapshotRuntimeHint, type StreamChunk, type StreamEvent, type StructuredOutputError, type StructuredOutputFieldError, StructuredOutputManager, type StructuredOutputManagerConfig, type StructuredOutputResult, type StructuredOutputStrategy, type StructuredSummary, type SummarizationEvent, type SummarizationMode, type SummaryFactItem, type SummaryIntegrityCheck, type TokenLimits, type TokenUsage, type ToolApprovalEvent, type ToolApprovalResolution, type ToolApprovalStatus, ToolBasedStrategy, type ToolCallEvent, type ToolInterface, type ToolResponseClassification, type ToolResponseRetentionPolicy, type TraceDataSection, type TraceErrorRecord, type TraceEventRecord, type TraceMessageSection, type TraceMetadataSection, type TraceSessionConfigSnapshot, type TraceSessionFile, type TraceSessionStatus, type TraceSessionSummary, type TraceSinkCognipeerConfig, type TraceSinkConfig, type TraceSinkCustomConfig, type TraceSinkFileConfig, type TraceSinkHttpConfig, type TraceSinkOtlpConfig, type TraceSinkSnapshot, type TraceSummarySection, type TraceToolCallSection, type TraceToolResultSection, type TracingConfig, type TracingMode, type UnifiedMessage, VertexProvider, type VertexProviderConfig, agentVerdictRule, applyTokenLimits, buildSystemPrompt, captureSnapshot, codePresenceRule, cognipeerSink, countApproxTokens, countMessagesTokens, createAgent, createAgentNode, createCodeGuardrail, createContextSummarizeNode, createContextTools, createGuardrail, createJsonGuardrail, createProvider, createRegexGuardrail, createResolverNode, createSmartAgent, createTool, createToolLimitFinalizeNode, createToolsNode, customCallbackRule, customSink, emptyUsage, evaluateGuardrails, fileSink, formatZodError, fromLangchainModel, fromLangchainTools, fromNativeProvider, generateSpanId, generateTraceId, getModelCapabilities, getNestedValue, getResolvedSmartConfig, httpSink, isSmartModel, jsonSchemaRule, normalizeSmartAgentOptions, otlpSink, readMemoryFacts, regexRule, renderMemoryFacts, resolveMemoryStore, resolveStrategy, resolveToolApprovalState, restoreSnapshot, runSmartAgentEvalHarness, startStreamingSession, traceSessionToOtlp, withTools, writeSummaryFactsToMemory };