@opperai/agents 0.5.0 → 0.6.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.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +276 -235
- package/dist/index.d.ts +276 -235
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -514,7 +514,24 @@ declare const ExecutionCycleSchema: z.ZodObject<{
|
|
|
514
514
|
results?: unknown[] | undefined;
|
|
515
515
|
timestamp?: number | undefined;
|
|
516
516
|
}>;
|
|
517
|
-
|
|
517
|
+
/** Structured thought recorded during an execution cycle */
|
|
518
|
+
interface ExecutionThought {
|
|
519
|
+
reasoning: string;
|
|
520
|
+
memoryReads?: string[];
|
|
521
|
+
memoryUpdates?: Record<string, unknown>;
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* A single iteration of the agent's think-act loop.
|
|
525
|
+
* The Zod schema (`ExecutionCycleSchema`) handles runtime parsing;
|
|
526
|
+
* this interface provides precise TypeScript types for `thought`.
|
|
527
|
+
*/
|
|
528
|
+
interface ExecutionCycle {
|
|
529
|
+
iteration: number;
|
|
530
|
+
thought?: ExecutionThought | null;
|
|
531
|
+
toolCalls: ToolCallRecord[];
|
|
532
|
+
results: unknown[];
|
|
533
|
+
timestamp: number;
|
|
534
|
+
}
|
|
518
535
|
interface AgentContextOptions {
|
|
519
536
|
agentName: string;
|
|
520
537
|
sessionId?: string;
|
|
@@ -655,6 +672,223 @@ declare function getDefaultLogger(): AgentLogger;
|
|
|
655
672
|
*/
|
|
656
673
|
declare function setDefaultLogger(logger: AgentLogger): void;
|
|
657
674
|
|
|
675
|
+
/**
|
|
676
|
+
* Streaming chunk payload from Opper SSE responses.
|
|
677
|
+
*/
|
|
678
|
+
interface OpperStreamChunk {
|
|
679
|
+
delta?: string | number | boolean | null | undefined;
|
|
680
|
+
jsonPath?: string | null | undefined;
|
|
681
|
+
spanId?: string | null | undefined;
|
|
682
|
+
chunkType?: string | null | undefined;
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Server-sent event emitted during streaming calls.
|
|
686
|
+
*/
|
|
687
|
+
interface OpperStreamEvent {
|
|
688
|
+
id?: string;
|
|
689
|
+
event?: string;
|
|
690
|
+
retry?: number;
|
|
691
|
+
data?: OpperStreamChunk;
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* Structured response returned by Opper stream endpoints.
|
|
695
|
+
*/
|
|
696
|
+
interface OpperStreamResponse {
|
|
697
|
+
headers: Record<string, string[]>;
|
|
698
|
+
result: AsyncIterable<OpperStreamEvent>;
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Opper call response
|
|
702
|
+
*/
|
|
703
|
+
interface OpperCallResponse<TOutput = unknown> {
|
|
704
|
+
/**
|
|
705
|
+
* Parsed JSON output (if outputSchema provided)
|
|
706
|
+
*/
|
|
707
|
+
jsonPayload?: TOutput;
|
|
708
|
+
/**
|
|
709
|
+
* Text message response
|
|
710
|
+
*/
|
|
711
|
+
message?: string | null | undefined;
|
|
712
|
+
/**
|
|
713
|
+
* Span ID for this call
|
|
714
|
+
*/
|
|
715
|
+
spanId: string;
|
|
716
|
+
/**
|
|
717
|
+
* Token usage information
|
|
718
|
+
*/
|
|
719
|
+
usage: {
|
|
720
|
+
inputTokens: number;
|
|
721
|
+
outputTokens: number;
|
|
722
|
+
totalTokens: number;
|
|
723
|
+
cost: {
|
|
724
|
+
generation: number;
|
|
725
|
+
platform: number;
|
|
726
|
+
total: number;
|
|
727
|
+
};
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Options for Opper call
|
|
732
|
+
*/
|
|
733
|
+
interface OpperCallOptions<TInput = unknown, TOutput = unknown> {
|
|
734
|
+
/**
|
|
735
|
+
* Unique name for this call/task
|
|
736
|
+
*/
|
|
737
|
+
name: string;
|
|
738
|
+
/**
|
|
739
|
+
* Natural language instructions
|
|
740
|
+
*/
|
|
741
|
+
instructions: string;
|
|
742
|
+
/**
|
|
743
|
+
* Input data for the call
|
|
744
|
+
*/
|
|
745
|
+
input: TInput;
|
|
746
|
+
/**
|
|
747
|
+
* Input schema (Zod or JSON Schema)
|
|
748
|
+
*/
|
|
749
|
+
inputSchema?: z.ZodType<TInput> | Record<string, unknown>;
|
|
750
|
+
/**
|
|
751
|
+
* Output schema (Zod or JSON Schema)
|
|
752
|
+
*/
|
|
753
|
+
outputSchema?: z.ZodType<TOutput> | Record<string, unknown>;
|
|
754
|
+
/**
|
|
755
|
+
* Model to use. Accepts a single model identifier or an ordered list for fallback.
|
|
756
|
+
* Example: "anthropic/claude-3.7-sonnet" or ["openai/gpt-4o", "anthropic/claude-3.7-sonnet"].
|
|
757
|
+
*/
|
|
758
|
+
model?: string | readonly string[];
|
|
759
|
+
/**
|
|
760
|
+
* Parent span ID for tracing
|
|
761
|
+
*/
|
|
762
|
+
parentSpanId?: string;
|
|
763
|
+
/**
|
|
764
|
+
* Abort signal used to cancel the underlying HTTP request.
|
|
765
|
+
*/
|
|
766
|
+
signal?: AbortSignal;
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Span information
|
|
770
|
+
*/
|
|
771
|
+
interface OpperSpan {
|
|
772
|
+
id: string;
|
|
773
|
+
name: string;
|
|
774
|
+
input?: unknown;
|
|
775
|
+
output?: unknown;
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* Options for creating a span
|
|
779
|
+
*/
|
|
780
|
+
interface CreateSpanOptions {
|
|
781
|
+
name: string;
|
|
782
|
+
input?: unknown;
|
|
783
|
+
parentSpanId?: string;
|
|
784
|
+
type?: string;
|
|
785
|
+
}
|
|
786
|
+
/**
|
|
787
|
+
* Retry configuration
|
|
788
|
+
*/
|
|
789
|
+
interface RetryConfig {
|
|
790
|
+
/**
|
|
791
|
+
* Maximum number of retry attempts
|
|
792
|
+
*/
|
|
793
|
+
maxRetries: number;
|
|
794
|
+
/**
|
|
795
|
+
* Initial delay in milliseconds
|
|
796
|
+
*/
|
|
797
|
+
initialDelayMs: number;
|
|
798
|
+
/**
|
|
799
|
+
* Backoff multiplier
|
|
800
|
+
*/
|
|
801
|
+
backoffMultiplier: number;
|
|
802
|
+
/**
|
|
803
|
+
* Maximum delay in milliseconds
|
|
804
|
+
*/
|
|
805
|
+
maxDelayMs: number;
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
808
|
+
* Default retry configuration
|
|
809
|
+
*/
|
|
810
|
+
declare const DEFAULT_RETRY_CONFIG: RetryConfig;
|
|
811
|
+
/**
|
|
812
|
+
* Opper client wrapper with retry logic and usage tracking
|
|
813
|
+
*/
|
|
814
|
+
declare class OpperClient {
|
|
815
|
+
private readonly client;
|
|
816
|
+
private readonly logger;
|
|
817
|
+
private readonly retryConfig;
|
|
818
|
+
constructor(apiKey?: string, options?: {
|
|
819
|
+
logger?: AgentLogger;
|
|
820
|
+
retryConfig?: Partial<RetryConfig>;
|
|
821
|
+
/**
|
|
822
|
+
* Override the default Opper API server URL.
|
|
823
|
+
* Useful for local development or self-hosted deployments.
|
|
824
|
+
* Example: "http://127.0.0.1:8000/v2"
|
|
825
|
+
*/
|
|
826
|
+
baseUrl?: string;
|
|
827
|
+
});
|
|
828
|
+
/**
|
|
829
|
+
* Make a call to Opper with retry logic
|
|
830
|
+
*/
|
|
831
|
+
call<TInput = unknown, TOutput = unknown>(options: OpperCallOptions<TInput, TOutput>): Promise<OpperCallResponse<TOutput>>;
|
|
832
|
+
/**
|
|
833
|
+
* Stream a call to Opper with retry logic
|
|
834
|
+
*/
|
|
835
|
+
stream<TInput = unknown, TOutput = unknown>(options: OpperCallOptions<TInput, TOutput>): Promise<OpperStreamResponse>;
|
|
836
|
+
/**
|
|
837
|
+
* Create a span for tracing
|
|
838
|
+
*/
|
|
839
|
+
createSpan(options: CreateSpanOptions): Promise<OpperSpan>;
|
|
840
|
+
/**
|
|
841
|
+
* Update a span with output or error
|
|
842
|
+
*/
|
|
843
|
+
updateSpan(spanId: string, output: unknown, options?: {
|
|
844
|
+
error?: string;
|
|
845
|
+
startTime?: Date;
|
|
846
|
+
endTime?: Date;
|
|
847
|
+
meta?: Record<string, unknown>;
|
|
848
|
+
name?: string;
|
|
849
|
+
}): Promise<void>;
|
|
850
|
+
/**
|
|
851
|
+
* Get the underlying Opper client
|
|
852
|
+
*/
|
|
853
|
+
getClient(): Opper;
|
|
854
|
+
/**
|
|
855
|
+
* Execute a function with retry logic and exponential backoff
|
|
856
|
+
*/
|
|
857
|
+
private withRetry;
|
|
858
|
+
/**
|
|
859
|
+
* Check if an error is retryable
|
|
860
|
+
*/
|
|
861
|
+
private isRetryableError;
|
|
862
|
+
/**
|
|
863
|
+
* Convert Zod schema to JSON Schema
|
|
864
|
+
*/
|
|
865
|
+
private toJsonSchema;
|
|
866
|
+
/**
|
|
867
|
+
* Sleep for specified milliseconds
|
|
868
|
+
*/
|
|
869
|
+
private sleep;
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* Create an Opper client with optional configuration
|
|
873
|
+
*/
|
|
874
|
+
declare function createOpperClient(apiKey?: string, options?: {
|
|
875
|
+
logger?: AgentLogger;
|
|
876
|
+
retryConfig?: Partial<RetryConfig>;
|
|
877
|
+
/**
|
|
878
|
+
* Override the default Opper API server URL.
|
|
879
|
+
* Useful for local development or self-hosted deployments.
|
|
880
|
+
* Example: "http://127.0.0.1:8000/v2"
|
|
881
|
+
*/
|
|
882
|
+
baseUrl?: string;
|
|
883
|
+
}): OpperClient;
|
|
884
|
+
|
|
885
|
+
/** The two LLM call phases in the agent loop */
|
|
886
|
+
type LlmCallType = "think" | "final_result";
|
|
887
|
+
/** Thought summary emitted by the ThinkEnd hook */
|
|
888
|
+
interface AgentThought {
|
|
889
|
+
reasoning: string;
|
|
890
|
+
userMessage: string;
|
|
891
|
+
}
|
|
658
892
|
declare const HookEvents: {
|
|
659
893
|
readonly AgentStart: "agent:start";
|
|
660
894
|
readonly AgentEnd: "agent:end";
|
|
@@ -692,17 +926,17 @@ interface HookPayloadMap {
|
|
|
692
926
|
};
|
|
693
927
|
[HookEvents.LlmCall]: {
|
|
694
928
|
context: AgentContext;
|
|
695
|
-
callType:
|
|
929
|
+
callType: LlmCallType;
|
|
696
930
|
};
|
|
697
931
|
[HookEvents.LlmResponse]: {
|
|
698
932
|
context: AgentContext;
|
|
699
|
-
callType:
|
|
700
|
-
response:
|
|
933
|
+
callType: LlmCallType;
|
|
934
|
+
response: OpperCallResponse | OpperStreamResponse;
|
|
701
935
|
parsed?: unknown;
|
|
702
936
|
};
|
|
703
937
|
[HookEvents.ThinkEnd]: {
|
|
704
938
|
context: AgentContext;
|
|
705
|
-
thought:
|
|
939
|
+
thought: AgentThought;
|
|
706
940
|
};
|
|
707
941
|
[HookEvents.BeforeTool]: {
|
|
708
942
|
context: AgentContext;
|
|
@@ -740,13 +974,13 @@ interface HookPayloadMap {
|
|
|
740
974
|
};
|
|
741
975
|
[HookEvents.StreamStart]: {
|
|
742
976
|
context: AgentContext;
|
|
743
|
-
callType:
|
|
977
|
+
callType: LlmCallType;
|
|
744
978
|
};
|
|
745
979
|
[HookEvents.StreamChunk]: {
|
|
746
980
|
context: AgentContext;
|
|
747
|
-
callType:
|
|
981
|
+
callType: LlmCallType;
|
|
748
982
|
chunkData: {
|
|
749
|
-
delta:
|
|
983
|
+
delta: string | number | boolean | null | undefined;
|
|
750
984
|
jsonPath?: string | null;
|
|
751
985
|
chunkType?: string | null;
|
|
752
986
|
};
|
|
@@ -755,16 +989,33 @@ interface HookPayloadMap {
|
|
|
755
989
|
};
|
|
756
990
|
[HookEvents.StreamEnd]: {
|
|
757
991
|
context: AgentContext;
|
|
758
|
-
callType:
|
|
992
|
+
callType: LlmCallType;
|
|
759
993
|
fieldBuffers: Record<string, string>;
|
|
760
994
|
};
|
|
761
995
|
[HookEvents.StreamError]: {
|
|
762
996
|
context: AgentContext;
|
|
763
|
-
callType:
|
|
997
|
+
callType: LlmCallType;
|
|
764
998
|
error: unknown;
|
|
765
999
|
};
|
|
766
1000
|
}
|
|
767
1001
|
type HookPayload<E extends HookEventName> = HookPayloadMap[E];
|
|
1002
|
+
type AgentStartPayload = HookPayloadMap[typeof HookEvents.AgentStart];
|
|
1003
|
+
type AgentEndPayload = HookPayloadMap[typeof HookEvents.AgentEnd];
|
|
1004
|
+
type LoopStartPayload = HookPayloadMap[typeof HookEvents.LoopStart];
|
|
1005
|
+
type LoopEndPayload = HookPayloadMap[typeof HookEvents.LoopEnd];
|
|
1006
|
+
type LlmCallPayload = HookPayloadMap[typeof HookEvents.LlmCall];
|
|
1007
|
+
type LlmResponsePayload = HookPayloadMap[typeof HookEvents.LlmResponse];
|
|
1008
|
+
type ThinkEndPayload = HookPayloadMap[typeof HookEvents.ThinkEnd];
|
|
1009
|
+
type BeforeToolPayload = HookPayloadMap[typeof HookEvents.BeforeTool];
|
|
1010
|
+
type AfterToolPayload = HookPayloadMap[typeof HookEvents.AfterTool];
|
|
1011
|
+
type ToolErrorPayload = HookPayloadMap[typeof HookEvents.ToolError];
|
|
1012
|
+
type MemoryReadPayload = HookPayloadMap[typeof HookEvents.MemoryRead];
|
|
1013
|
+
type MemoryWritePayload = HookPayloadMap[typeof HookEvents.MemoryWrite];
|
|
1014
|
+
type MemoryErrorPayload = HookPayloadMap[typeof HookEvents.MemoryError];
|
|
1015
|
+
type StreamStartPayload = HookPayloadMap[typeof HookEvents.StreamStart];
|
|
1016
|
+
type StreamChunkPayload = HookPayloadMap[typeof HookEvents.StreamChunk];
|
|
1017
|
+
type StreamEndPayload = HookPayloadMap[typeof HookEvents.StreamEnd];
|
|
1018
|
+
type StreamErrorPayload = HookPayloadMap[typeof HookEvents.StreamError];
|
|
768
1019
|
type HookHandler<E extends HookEventName> = (payload: HookPayload<E>) => void | Promise<void>;
|
|
769
1020
|
interface HookRegistration<E extends HookEventName> {
|
|
770
1021
|
event: E;
|
|
@@ -1415,216 +1666,6 @@ type AgentEventPayload<E extends AgentEventName> = AgentEventPayloadMap[E];
|
|
|
1415
1666
|
*/
|
|
1416
1667
|
type AgentEventListener<E extends AgentEventName> = HookHandler<E>;
|
|
1417
1668
|
|
|
1418
|
-
/**
|
|
1419
|
-
* Streaming chunk payload from Opper SSE responses.
|
|
1420
|
-
*/
|
|
1421
|
-
interface OpperStreamChunk {
|
|
1422
|
-
delta?: string | number | boolean | null | undefined;
|
|
1423
|
-
jsonPath?: string | null | undefined;
|
|
1424
|
-
spanId?: string | null | undefined;
|
|
1425
|
-
chunkType?: string | null | undefined;
|
|
1426
|
-
}
|
|
1427
|
-
/**
|
|
1428
|
-
* Server-sent event emitted during streaming calls.
|
|
1429
|
-
*/
|
|
1430
|
-
interface OpperStreamEvent {
|
|
1431
|
-
id?: string;
|
|
1432
|
-
event?: string;
|
|
1433
|
-
retry?: number;
|
|
1434
|
-
data?: OpperStreamChunk;
|
|
1435
|
-
}
|
|
1436
|
-
/**
|
|
1437
|
-
* Structured response returned by Opper stream endpoints.
|
|
1438
|
-
*/
|
|
1439
|
-
interface OpperStreamResponse {
|
|
1440
|
-
headers: Record<string, string[]>;
|
|
1441
|
-
result: AsyncIterable<OpperStreamEvent>;
|
|
1442
|
-
}
|
|
1443
|
-
/**
|
|
1444
|
-
* Opper call response
|
|
1445
|
-
*/
|
|
1446
|
-
interface OpperCallResponse<TOutput = unknown> {
|
|
1447
|
-
/**
|
|
1448
|
-
* Parsed JSON output (if outputSchema provided)
|
|
1449
|
-
*/
|
|
1450
|
-
jsonPayload?: TOutput;
|
|
1451
|
-
/**
|
|
1452
|
-
* Text message response
|
|
1453
|
-
*/
|
|
1454
|
-
message?: string | null | undefined;
|
|
1455
|
-
/**
|
|
1456
|
-
* Span ID for this call
|
|
1457
|
-
*/
|
|
1458
|
-
spanId: string;
|
|
1459
|
-
/**
|
|
1460
|
-
* Token usage information
|
|
1461
|
-
*/
|
|
1462
|
-
usage: {
|
|
1463
|
-
inputTokens: number;
|
|
1464
|
-
outputTokens: number;
|
|
1465
|
-
totalTokens: number;
|
|
1466
|
-
cost: {
|
|
1467
|
-
generation: number;
|
|
1468
|
-
platform: number;
|
|
1469
|
-
total: number;
|
|
1470
|
-
};
|
|
1471
|
-
};
|
|
1472
|
-
}
|
|
1473
|
-
/**
|
|
1474
|
-
* Options for Opper call
|
|
1475
|
-
*/
|
|
1476
|
-
interface OpperCallOptions<TInput = unknown, TOutput = unknown> {
|
|
1477
|
-
/**
|
|
1478
|
-
* Unique name for this call/task
|
|
1479
|
-
*/
|
|
1480
|
-
name: string;
|
|
1481
|
-
/**
|
|
1482
|
-
* Natural language instructions
|
|
1483
|
-
*/
|
|
1484
|
-
instructions: string;
|
|
1485
|
-
/**
|
|
1486
|
-
* Input data for the call
|
|
1487
|
-
*/
|
|
1488
|
-
input: TInput;
|
|
1489
|
-
/**
|
|
1490
|
-
* Input schema (Zod or JSON Schema)
|
|
1491
|
-
*/
|
|
1492
|
-
inputSchema?: z.ZodType<TInput> | Record<string, unknown>;
|
|
1493
|
-
/**
|
|
1494
|
-
* Output schema (Zod or JSON Schema)
|
|
1495
|
-
*/
|
|
1496
|
-
outputSchema?: z.ZodType<TOutput> | Record<string, unknown>;
|
|
1497
|
-
/**
|
|
1498
|
-
* Model to use. Accepts a single model identifier or an ordered list for fallback.
|
|
1499
|
-
* Example: "anthropic/claude-3.7-sonnet" or ["openai/gpt-4o", "anthropic/claude-3.7-sonnet"].
|
|
1500
|
-
*/
|
|
1501
|
-
model?: string | readonly string[];
|
|
1502
|
-
/**
|
|
1503
|
-
* Parent span ID for tracing
|
|
1504
|
-
*/
|
|
1505
|
-
parentSpanId?: string;
|
|
1506
|
-
/**
|
|
1507
|
-
* Abort signal used to cancel the underlying HTTP request.
|
|
1508
|
-
*/
|
|
1509
|
-
signal?: AbortSignal;
|
|
1510
|
-
}
|
|
1511
|
-
/**
|
|
1512
|
-
* Span information
|
|
1513
|
-
*/
|
|
1514
|
-
interface OpperSpan {
|
|
1515
|
-
id: string;
|
|
1516
|
-
name: string;
|
|
1517
|
-
input?: unknown;
|
|
1518
|
-
output?: unknown;
|
|
1519
|
-
}
|
|
1520
|
-
/**
|
|
1521
|
-
* Options for creating a span
|
|
1522
|
-
*/
|
|
1523
|
-
interface CreateSpanOptions {
|
|
1524
|
-
name: string;
|
|
1525
|
-
input?: unknown;
|
|
1526
|
-
parentSpanId?: string;
|
|
1527
|
-
type?: string;
|
|
1528
|
-
}
|
|
1529
|
-
/**
|
|
1530
|
-
* Retry configuration
|
|
1531
|
-
*/
|
|
1532
|
-
interface RetryConfig {
|
|
1533
|
-
/**
|
|
1534
|
-
* Maximum number of retry attempts
|
|
1535
|
-
*/
|
|
1536
|
-
maxRetries: number;
|
|
1537
|
-
/**
|
|
1538
|
-
* Initial delay in milliseconds
|
|
1539
|
-
*/
|
|
1540
|
-
initialDelayMs: number;
|
|
1541
|
-
/**
|
|
1542
|
-
* Backoff multiplier
|
|
1543
|
-
*/
|
|
1544
|
-
backoffMultiplier: number;
|
|
1545
|
-
/**
|
|
1546
|
-
* Maximum delay in milliseconds
|
|
1547
|
-
*/
|
|
1548
|
-
maxDelayMs: number;
|
|
1549
|
-
}
|
|
1550
|
-
/**
|
|
1551
|
-
* Default retry configuration
|
|
1552
|
-
*/
|
|
1553
|
-
declare const DEFAULT_RETRY_CONFIG: RetryConfig;
|
|
1554
|
-
/**
|
|
1555
|
-
* Opper client wrapper with retry logic and usage tracking
|
|
1556
|
-
*/
|
|
1557
|
-
declare class OpperClient {
|
|
1558
|
-
private readonly client;
|
|
1559
|
-
private readonly logger;
|
|
1560
|
-
private readonly retryConfig;
|
|
1561
|
-
constructor(apiKey?: string, options?: {
|
|
1562
|
-
logger?: AgentLogger;
|
|
1563
|
-
retryConfig?: Partial<RetryConfig>;
|
|
1564
|
-
/**
|
|
1565
|
-
* Override the default Opper API server URL.
|
|
1566
|
-
* Useful for local development or self-hosted deployments.
|
|
1567
|
-
* Example: "http://127.0.0.1:8000/v2"
|
|
1568
|
-
*/
|
|
1569
|
-
baseUrl?: string;
|
|
1570
|
-
});
|
|
1571
|
-
/**
|
|
1572
|
-
* Make a call to Opper with retry logic
|
|
1573
|
-
*/
|
|
1574
|
-
call<TInput = unknown, TOutput = unknown>(options: OpperCallOptions<TInput, TOutput>): Promise<OpperCallResponse<TOutput>>;
|
|
1575
|
-
/**
|
|
1576
|
-
* Stream a call to Opper with retry logic
|
|
1577
|
-
*/
|
|
1578
|
-
stream<TInput = unknown, TOutput = unknown>(options: OpperCallOptions<TInput, TOutput>): Promise<OpperStreamResponse>;
|
|
1579
|
-
/**
|
|
1580
|
-
* Create a span for tracing
|
|
1581
|
-
*/
|
|
1582
|
-
createSpan(options: CreateSpanOptions): Promise<OpperSpan>;
|
|
1583
|
-
/**
|
|
1584
|
-
* Update a span with output or error
|
|
1585
|
-
*/
|
|
1586
|
-
updateSpan(spanId: string, output: unknown, options?: {
|
|
1587
|
-
error?: string;
|
|
1588
|
-
startTime?: Date;
|
|
1589
|
-
endTime?: Date;
|
|
1590
|
-
meta?: Record<string, unknown>;
|
|
1591
|
-
name?: string;
|
|
1592
|
-
}): Promise<void>;
|
|
1593
|
-
/**
|
|
1594
|
-
* Get the underlying Opper client
|
|
1595
|
-
*/
|
|
1596
|
-
getClient(): Opper;
|
|
1597
|
-
/**
|
|
1598
|
-
* Execute a function with retry logic and exponential backoff
|
|
1599
|
-
*/
|
|
1600
|
-
private withRetry;
|
|
1601
|
-
/**
|
|
1602
|
-
* Check if an error is retryable
|
|
1603
|
-
*/
|
|
1604
|
-
private isRetryableError;
|
|
1605
|
-
/**
|
|
1606
|
-
* Convert Zod schema to JSON Schema
|
|
1607
|
-
*/
|
|
1608
|
-
private toJsonSchema;
|
|
1609
|
-
/**
|
|
1610
|
-
* Sleep for specified milliseconds
|
|
1611
|
-
*/
|
|
1612
|
-
private sleep;
|
|
1613
|
-
}
|
|
1614
|
-
/**
|
|
1615
|
-
* Create an Opper client with optional configuration
|
|
1616
|
-
*/
|
|
1617
|
-
declare function createOpperClient(apiKey?: string, options?: {
|
|
1618
|
-
logger?: AgentLogger;
|
|
1619
|
-
retryConfig?: Partial<RetryConfig>;
|
|
1620
|
-
/**
|
|
1621
|
-
* Override the default Opper API server URL.
|
|
1622
|
-
* Useful for local development or self-hosted deployments.
|
|
1623
|
-
* Example: "http://127.0.0.1:8000/v2"
|
|
1624
|
-
*/
|
|
1625
|
-
baseUrl?: string;
|
|
1626
|
-
}): OpperClient;
|
|
1627
|
-
|
|
1628
1669
|
/**
|
|
1629
1670
|
* Configuration for the core Agent.
|
|
1630
1671
|
*
|
|
@@ -1951,13 +1992,13 @@ declare const AgentDecisionSchema: z.ZodObject<{
|
|
|
1951
1992
|
arguments?: unknown;
|
|
1952
1993
|
}[];
|
|
1953
1994
|
reasoning: string;
|
|
1954
|
-
userMessage: string;
|
|
1955
1995
|
memoryReads: string[];
|
|
1956
1996
|
memoryUpdates: Record<string, {
|
|
1957
1997
|
value?: unknown;
|
|
1958
1998
|
metadata?: Record<string, unknown> | undefined;
|
|
1959
1999
|
description?: string | undefined;
|
|
1960
2000
|
}>;
|
|
2001
|
+
userMessage: string;
|
|
1961
2002
|
isComplete: boolean;
|
|
1962
2003
|
finalResult?: unknown;
|
|
1963
2004
|
}, {
|
|
@@ -1967,13 +2008,13 @@ declare const AgentDecisionSchema: z.ZodObject<{
|
|
|
1967
2008
|
toolName: string;
|
|
1968
2009
|
arguments?: unknown;
|
|
1969
2010
|
}[] | undefined;
|
|
1970
|
-
userMessage?: string | undefined;
|
|
1971
2011
|
memoryReads?: string[] | undefined;
|
|
1972
2012
|
memoryUpdates?: Record<string, {
|
|
1973
2013
|
value?: unknown;
|
|
1974
2014
|
metadata?: Record<string, unknown> | undefined;
|
|
1975
2015
|
description?: string | undefined;
|
|
1976
2016
|
}> | undefined;
|
|
2017
|
+
userMessage?: string | undefined;
|
|
1977
2018
|
isComplete?: boolean | undefined;
|
|
1978
2019
|
finalResult?: unknown;
|
|
1979
2020
|
}>;
|
|
@@ -2064,15 +2105,15 @@ declare const MCPConfigVariants: z.ZodDiscriminatedUnion<"transport", [z.ZodObje
|
|
|
2064
2105
|
method: z.ZodDefault<z.ZodEnum<["GET", "POST"]>>;
|
|
2065
2106
|
}, "strip", z.ZodTypeAny, {
|
|
2066
2107
|
metadata: Record<string, unknown>;
|
|
2067
|
-
name: string;
|
|
2068
2108
|
url: string;
|
|
2109
|
+
name: string;
|
|
2069
2110
|
method: "GET" | "POST";
|
|
2070
2111
|
headers: Record<string, string>;
|
|
2071
2112
|
timeout: number;
|
|
2072
2113
|
transport: "http-sse";
|
|
2073
2114
|
}, {
|
|
2074
|
-
name: string;
|
|
2075
2115
|
url: string;
|
|
2116
|
+
name: string;
|
|
2076
2117
|
transport: "http-sse";
|
|
2077
2118
|
metadata?: Record<string, unknown> | undefined;
|
|
2078
2119
|
method?: "GET" | "POST" | undefined;
|
|
@@ -2089,15 +2130,15 @@ declare const MCPConfigVariants: z.ZodDiscriminatedUnion<"transport", [z.ZodObje
|
|
|
2089
2130
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
2090
2131
|
}, "strip", z.ZodTypeAny, {
|
|
2091
2132
|
metadata: Record<string, unknown>;
|
|
2092
|
-
name: string;
|
|
2093
2133
|
url: string;
|
|
2134
|
+
name: string;
|
|
2094
2135
|
headers: Record<string, string>;
|
|
2095
2136
|
timeout: number;
|
|
2096
2137
|
transport: "streamable-http";
|
|
2097
2138
|
sessionId?: string | undefined;
|
|
2098
2139
|
}, {
|
|
2099
|
-
name: string;
|
|
2100
2140
|
url: string;
|
|
2141
|
+
name: string;
|
|
2101
2142
|
transport: "streamable-http";
|
|
2102
2143
|
metadata?: Record<string, unknown> | undefined;
|
|
2103
2144
|
headers?: Record<string, string> | undefined;
|
|
@@ -2148,15 +2189,15 @@ declare const MCPServerConfigSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"trans
|
|
|
2148
2189
|
method: z.ZodDefault<z.ZodEnum<["GET", "POST"]>>;
|
|
2149
2190
|
}, "strip", z.ZodTypeAny, {
|
|
2150
2191
|
metadata: Record<string, unknown>;
|
|
2151
|
-
name: string;
|
|
2152
2192
|
url: string;
|
|
2193
|
+
name: string;
|
|
2153
2194
|
method: "GET" | "POST";
|
|
2154
2195
|
headers: Record<string, string>;
|
|
2155
2196
|
timeout: number;
|
|
2156
2197
|
transport: "http-sse";
|
|
2157
2198
|
}, {
|
|
2158
|
-
name: string;
|
|
2159
2199
|
url: string;
|
|
2200
|
+
name: string;
|
|
2160
2201
|
transport: "http-sse";
|
|
2161
2202
|
metadata?: Record<string, unknown> | undefined;
|
|
2162
2203
|
method?: "GET" | "POST" | undefined;
|
|
@@ -2173,15 +2214,15 @@ declare const MCPServerConfigSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"trans
|
|
|
2173
2214
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
2174
2215
|
}, "strip", z.ZodTypeAny, {
|
|
2175
2216
|
metadata: Record<string, unknown>;
|
|
2176
|
-
name: string;
|
|
2177
2217
|
url: string;
|
|
2218
|
+
name: string;
|
|
2178
2219
|
headers: Record<string, string>;
|
|
2179
2220
|
timeout: number;
|
|
2180
2221
|
transport: "streamable-http";
|
|
2181
2222
|
sessionId?: string | undefined;
|
|
2182
2223
|
}, {
|
|
2183
|
-
name: string;
|
|
2184
2224
|
url: string;
|
|
2225
|
+
name: string;
|
|
2185
2226
|
transport: "streamable-http";
|
|
2186
2227
|
metadata?: Record<string, unknown> | undefined;
|
|
2187
2228
|
headers?: Record<string, string> | undefined;
|
|
@@ -2199,16 +2240,16 @@ declare const MCPServerConfigSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"trans
|
|
|
2199
2240
|
stderr?: "inherit" | "pipe" | "ignore" | undefined;
|
|
2200
2241
|
} | {
|
|
2201
2242
|
metadata: Record<string, unknown>;
|
|
2202
|
-
name: string;
|
|
2203
2243
|
url: string;
|
|
2244
|
+
name: string;
|
|
2204
2245
|
method: "GET" | "POST";
|
|
2205
2246
|
headers: Record<string, string>;
|
|
2206
2247
|
timeout: number;
|
|
2207
2248
|
transport: "http-sse";
|
|
2208
2249
|
} | {
|
|
2209
2250
|
metadata: Record<string, unknown>;
|
|
2210
|
-
name: string;
|
|
2211
2251
|
url: string;
|
|
2252
|
+
name: string;
|
|
2212
2253
|
headers: Record<string, string>;
|
|
2213
2254
|
timeout: number;
|
|
2214
2255
|
transport: "streamable-http";
|
|
@@ -2224,16 +2265,16 @@ declare const MCPServerConfigSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"trans
|
|
|
2224
2265
|
cwd?: string | undefined;
|
|
2225
2266
|
stderr?: "inherit" | "pipe" | "ignore" | undefined;
|
|
2226
2267
|
} | {
|
|
2227
|
-
name: string;
|
|
2228
2268
|
url: string;
|
|
2269
|
+
name: string;
|
|
2229
2270
|
transport: "http-sse";
|
|
2230
2271
|
metadata?: Record<string, unknown> | undefined;
|
|
2231
2272
|
method?: "GET" | "POST" | undefined;
|
|
2232
2273
|
headers?: Record<string, string> | undefined;
|
|
2233
2274
|
timeout?: number | undefined;
|
|
2234
2275
|
} | {
|
|
2235
|
-
name: string;
|
|
2236
2276
|
url: string;
|
|
2277
|
+
name: string;
|
|
2237
2278
|
transport: "streamable-http";
|
|
2238
2279
|
metadata?: Record<string, unknown> | undefined;
|
|
2239
2280
|
headers?: Record<string, string> | undefined;
|
|
@@ -2546,4 +2587,4 @@ declare class ToolRunner {
|
|
|
2546
2587
|
};
|
|
2547
2588
|
}
|
|
2548
2589
|
|
|
2549
|
-
export { Agent, type AgentConfig, AgentContext, type AgentContextOptions, type AgentContextSnapshot, type AgentDecision, AgentDecisionSchema, type AgentEventListener, type AgentEventName, type AgentEventPayload, type AgentEventPayloadMap, AgentEvents, type AgentLogger, BaseAgent, type BaseAgentConfig, type BaseUsage, BaseUsageSchema, 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 ToolExample, 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, addUsage, coerceToolDefinition, createAgentDecisionWithOutputSchema, createEmptyUsage, createFunctionTool, createHookManager, createInMemoryStore, createMCPServerConfig, createOpperClient, createStreamAssembler, createToolCallRecord, err, extractTools, generateAgentFlowDiagram, getDefaultLogger, getSchemaDefault, isSchemaValid, isToolProvider, mcp, mergeSchemaDefaults, normalizeToolEntries, ok, schemaToJson, setDefaultLogger, tool, validateSchema, validateToolInput, zodSchemaToJsonSchema };
|
|
2590
|
+
export { type AfterToolPayload, Agent, type AgentConfig, AgentContext, type AgentContextOptions, type AgentContextSnapshot, type AgentDecision, AgentDecisionSchema, type AgentEndPayload, type AgentEventListener, type AgentEventName, type AgentEventPayload, type AgentEventPayloadMap, AgentEvents, type AgentLogger, type AgentStartPayload, type AgentThought, BaseAgent, type BaseAgentConfig, type BaseUsage, BaseUsageSchema, type BeforeToolPayload, ConsoleLogger, type CreateSpanOptions, DEFAULT_MODEL, DEFAULT_RETRY_CONFIG, type ExecutionCycle, ExecutionCycleSchema, type ExecutionThought, type Failure, type HookEventName, HookEvents, type HookHandler, HookManager, type HookPayload, type HookPayloadMap, type HookRegistration, InMemoryStore, type IterationSummary, type JsonSchemaOptions, type LlmCallPayload, type LlmCallType, type LlmResponsePayload, LogLevel, type LoopEndPayload, type LoopStartPayload, 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 MemoryErrorPayload, type MemoryReadPayload, type MemoryUpdate, MemoryUpdateSchema, type MemoryWritePayload, 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 StreamChunkPayload, type StreamEndPayload, type StreamErrorPayload, type StreamFeedResult, type StreamFinalizeResult, type StreamStartPayload, type Success, type ThinkEndPayload, type Thought, ThoughtSchema, type Tool, type ToolCall, type ToolCallRecord, ToolCallRecordSchema, ToolCallSchema, type ToolDefinition, type ToolErrorPayload, type ToolExample, 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, addUsage, coerceToolDefinition, createAgentDecisionWithOutputSchema, createEmptyUsage, createFunctionTool, createHookManager, createInMemoryStore, createMCPServerConfig, createOpperClient, createStreamAssembler, createToolCallRecord, err, extractTools, generateAgentFlowDiagram, getDefaultLogger, getSchemaDefault, isSchemaValid, isToolProvider, mcp, mergeSchemaDefaults, normalizeToolEntries, ok, schemaToJson, setDefaultLogger, tool, validateSchema, validateToolInput, zodSchemaToJsonSchema };
|