@arvo-tools/agentic 1.2.3 → 1.2.4
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/Agent/stream/schema.d.ts +331 -7
- package/dist/Agent/stream/schema.d.ts.map +1 -1
- package/dist/Agent/stream/schema.js +51 -1
- package/dist/Agent/stream/schema.js.map +1 -1
- package/dist/Integrations/anthropic/index.d.ts.map +1 -1
- package/dist/Integrations/anthropic/index.js +40 -84
- package/dist/Integrations/anthropic/index.js.map +1 -1
- package/dist/Integrations/anthropic/nonstreamable.d.ts +7 -0
- package/dist/Integrations/anthropic/nonstreamable.d.ts.map +1 -0
- package/dist/Integrations/anthropic/nonstreamable.js +112 -0
- package/dist/Integrations/anthropic/nonstreamable.js.map +1 -0
- package/dist/Integrations/anthropic/streamable.d.ts +9 -0
- package/dist/Integrations/anthropic/streamable.d.ts.map +1 -0
- package/dist/Integrations/anthropic/streamable.js +245 -0
- package/dist/Integrations/anthropic/streamable.js.map +1 -0
- package/dist/Integrations/anthropic/types.d.ts +1 -1
- package/dist/Integrations/anthropic/types.d.ts.map +1 -1
- package/dist/Integrations/defaultContextTransformer.d.ts +3 -0
- package/dist/Integrations/defaultContextTransformer.d.ts.map +1 -0
- package/dist/Integrations/defaultContextTransformer.js +62 -0
- package/dist/Integrations/defaultContextTransformer.js.map +1 -0
- package/dist/Integrations/openai/index.d.ts.map +1 -1
- package/dist/Integrations/openai/index.js +48 -92
- package/dist/Integrations/openai/index.js.map +1 -1
- package/dist/Integrations/openai/nonstreamable.d.ts +10 -0
- package/dist/Integrations/openai/nonstreamable.d.ts.map +1 -0
- package/dist/Integrations/openai/nonstreamable.js +129 -0
- package/dist/Integrations/openai/nonstreamable.js.map +1 -0
- package/dist/Integrations/openai/streamable.d.ts +12 -0
- package/dist/Integrations/openai/streamable.d.ts.map +1 -0
- package/dist/Integrations/openai/streamable.js +321 -0
- package/dist/Integrations/openai/streamable.js.map +1 -0
- package/dist/Integrations/openai/types.d.ts +1 -1
- package/dist/Integrations/openai/types.d.ts.map +1 -1
- package/dist/Integrations/types.d.ts +5 -0
- package/dist/Integrations/types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/package.json +3 -2
|
@@ -431,26 +431,350 @@ export declare const AgentStreamEventSchema: z.ZodDiscriminatedUnion<"type", [z.
|
|
|
431
431
|
}>, z.ZodObject<{
|
|
432
432
|
type: z.ZodLiteral<"agent.llm.delta">;
|
|
433
433
|
data: z.ZodObject<{
|
|
434
|
-
|
|
434
|
+
finishReason: z.ZodNullable<z.ZodString>;
|
|
435
|
+
comment: z.ZodString;
|
|
436
|
+
meta: z.ZodObject<{
|
|
437
|
+
error: z.ZodNullable<z.ZodString>;
|
|
438
|
+
token: z.ZodObject<{
|
|
439
|
+
prompt: z.ZodNumber;
|
|
440
|
+
completion: z.ZodNumber;
|
|
441
|
+
}, "strip", z.ZodTypeAny, {
|
|
442
|
+
prompt: number;
|
|
443
|
+
completion: number;
|
|
444
|
+
}, {
|
|
445
|
+
prompt: number;
|
|
446
|
+
completion: number;
|
|
447
|
+
}>;
|
|
448
|
+
otel: z.ZodObject<{
|
|
449
|
+
traceparent: z.ZodNullable<z.ZodString>;
|
|
450
|
+
tracestate: z.ZodNullable<z.ZodString>;
|
|
451
|
+
}, "strip", z.ZodTypeAny, {
|
|
452
|
+
traceparent: string | null;
|
|
453
|
+
tracestate: string | null;
|
|
454
|
+
}, {
|
|
455
|
+
traceparent: string | null;
|
|
456
|
+
tracestate: string | null;
|
|
457
|
+
}>;
|
|
458
|
+
}, "strip", z.ZodTypeAny, {
|
|
459
|
+
error: string | null;
|
|
460
|
+
token: {
|
|
461
|
+
prompt: number;
|
|
462
|
+
completion: number;
|
|
463
|
+
};
|
|
464
|
+
otel: {
|
|
465
|
+
traceparent: string | null;
|
|
466
|
+
tracestate: string | null;
|
|
467
|
+
};
|
|
468
|
+
}, {
|
|
469
|
+
error: string | null;
|
|
470
|
+
token: {
|
|
471
|
+
prompt: number;
|
|
472
|
+
completion: number;
|
|
473
|
+
};
|
|
474
|
+
otel: {
|
|
475
|
+
traceparent: string | null;
|
|
476
|
+
tracestate: string | null;
|
|
477
|
+
};
|
|
478
|
+
}>;
|
|
479
|
+
}, "strip", z.ZodTypeAny, {
|
|
480
|
+
finishReason: string | null;
|
|
481
|
+
comment: string;
|
|
482
|
+
meta: {
|
|
483
|
+
error: string | null;
|
|
484
|
+
token: {
|
|
485
|
+
prompt: number;
|
|
486
|
+
completion: number;
|
|
487
|
+
};
|
|
488
|
+
otel: {
|
|
489
|
+
traceparent: string | null;
|
|
490
|
+
tracestate: string | null;
|
|
491
|
+
};
|
|
492
|
+
};
|
|
493
|
+
}, {
|
|
494
|
+
finishReason: string | null;
|
|
495
|
+
comment: string;
|
|
496
|
+
meta: {
|
|
497
|
+
error: string | null;
|
|
498
|
+
token: {
|
|
499
|
+
prompt: number;
|
|
500
|
+
completion: number;
|
|
501
|
+
};
|
|
502
|
+
otel: {
|
|
503
|
+
traceparent: string | null;
|
|
504
|
+
tracestate: string | null;
|
|
505
|
+
};
|
|
506
|
+
};
|
|
507
|
+
}>;
|
|
508
|
+
}, "strip", z.ZodTypeAny, {
|
|
509
|
+
type: "agent.llm.delta";
|
|
510
|
+
data: {
|
|
511
|
+
finishReason: string | null;
|
|
512
|
+
comment: string;
|
|
513
|
+
meta: {
|
|
514
|
+
error: string | null;
|
|
515
|
+
token: {
|
|
516
|
+
prompt: number;
|
|
517
|
+
completion: number;
|
|
518
|
+
};
|
|
519
|
+
otel: {
|
|
520
|
+
traceparent: string | null;
|
|
521
|
+
tracestate: string | null;
|
|
522
|
+
};
|
|
523
|
+
};
|
|
524
|
+
};
|
|
525
|
+
}, {
|
|
526
|
+
type: "agent.llm.delta";
|
|
527
|
+
data: {
|
|
528
|
+
finishReason: string | null;
|
|
529
|
+
comment: string;
|
|
530
|
+
meta: {
|
|
531
|
+
error: string | null;
|
|
532
|
+
token: {
|
|
533
|
+
prompt: number;
|
|
534
|
+
completion: number;
|
|
535
|
+
};
|
|
536
|
+
otel: {
|
|
537
|
+
traceparent: string | null;
|
|
538
|
+
tracestate: string | null;
|
|
539
|
+
};
|
|
540
|
+
};
|
|
541
|
+
};
|
|
542
|
+
}>, z.ZodObject<{
|
|
543
|
+
type: z.ZodLiteral<"agent.llm.delta.text">;
|
|
544
|
+
data: z.ZodObject<{
|
|
545
|
+
delta: z.ZodNullable<z.ZodString>;
|
|
435
546
|
content: z.ZodString;
|
|
547
|
+
comment: z.ZodString;
|
|
548
|
+
meta: z.ZodObject<{
|
|
549
|
+
error: z.ZodNullable<z.ZodString>;
|
|
550
|
+
token: z.ZodObject<{
|
|
551
|
+
prompt: z.ZodNumber;
|
|
552
|
+
completion: z.ZodNumber;
|
|
553
|
+
}, "strip", z.ZodTypeAny, {
|
|
554
|
+
prompt: number;
|
|
555
|
+
completion: number;
|
|
556
|
+
}, {
|
|
557
|
+
prompt: number;
|
|
558
|
+
completion: number;
|
|
559
|
+
}>;
|
|
560
|
+
otel: z.ZodObject<{
|
|
561
|
+
traceparent: z.ZodNullable<z.ZodString>;
|
|
562
|
+
tracestate: z.ZodNullable<z.ZodString>;
|
|
563
|
+
}, "strip", z.ZodTypeAny, {
|
|
564
|
+
traceparent: string | null;
|
|
565
|
+
tracestate: string | null;
|
|
566
|
+
}, {
|
|
567
|
+
traceparent: string | null;
|
|
568
|
+
tracestate: string | null;
|
|
569
|
+
}>;
|
|
570
|
+
}, "strip", z.ZodTypeAny, {
|
|
571
|
+
error: string | null;
|
|
572
|
+
token: {
|
|
573
|
+
prompt: number;
|
|
574
|
+
completion: number;
|
|
575
|
+
};
|
|
576
|
+
otel: {
|
|
577
|
+
traceparent: string | null;
|
|
578
|
+
tracestate: string | null;
|
|
579
|
+
};
|
|
580
|
+
}, {
|
|
581
|
+
error: string | null;
|
|
582
|
+
token: {
|
|
583
|
+
prompt: number;
|
|
584
|
+
completion: number;
|
|
585
|
+
};
|
|
586
|
+
otel: {
|
|
587
|
+
traceparent: string | null;
|
|
588
|
+
tracestate: string | null;
|
|
589
|
+
};
|
|
590
|
+
}>;
|
|
436
591
|
}, "strip", z.ZodTypeAny, {
|
|
437
592
|
content: string;
|
|
438
|
-
|
|
593
|
+
comment: string;
|
|
594
|
+
meta: {
|
|
595
|
+
error: string | null;
|
|
596
|
+
token: {
|
|
597
|
+
prompt: number;
|
|
598
|
+
completion: number;
|
|
599
|
+
};
|
|
600
|
+
otel: {
|
|
601
|
+
traceparent: string | null;
|
|
602
|
+
tracestate: string | null;
|
|
603
|
+
};
|
|
604
|
+
};
|
|
605
|
+
delta: string | null;
|
|
439
606
|
}, {
|
|
440
607
|
content: string;
|
|
441
|
-
|
|
608
|
+
comment: string;
|
|
609
|
+
meta: {
|
|
610
|
+
error: string | null;
|
|
611
|
+
token: {
|
|
612
|
+
prompt: number;
|
|
613
|
+
completion: number;
|
|
614
|
+
};
|
|
615
|
+
otel: {
|
|
616
|
+
traceparent: string | null;
|
|
617
|
+
tracestate: string | null;
|
|
618
|
+
};
|
|
619
|
+
};
|
|
620
|
+
delta: string | null;
|
|
442
621
|
}>;
|
|
443
622
|
}, "strip", z.ZodTypeAny, {
|
|
444
|
-
type: "agent.llm.delta";
|
|
623
|
+
type: "agent.llm.delta.text";
|
|
445
624
|
data: {
|
|
446
625
|
content: string;
|
|
447
|
-
|
|
626
|
+
comment: string;
|
|
627
|
+
meta: {
|
|
628
|
+
error: string | null;
|
|
629
|
+
token: {
|
|
630
|
+
prompt: number;
|
|
631
|
+
completion: number;
|
|
632
|
+
};
|
|
633
|
+
otel: {
|
|
634
|
+
traceparent: string | null;
|
|
635
|
+
tracestate: string | null;
|
|
636
|
+
};
|
|
637
|
+
};
|
|
638
|
+
delta: string | null;
|
|
448
639
|
};
|
|
449
640
|
}, {
|
|
450
|
-
type: "agent.llm.delta";
|
|
641
|
+
type: "agent.llm.delta.text";
|
|
451
642
|
data: {
|
|
452
643
|
content: string;
|
|
453
|
-
|
|
644
|
+
comment: string;
|
|
645
|
+
meta: {
|
|
646
|
+
error: string | null;
|
|
647
|
+
token: {
|
|
648
|
+
prompt: number;
|
|
649
|
+
completion: number;
|
|
650
|
+
};
|
|
651
|
+
otel: {
|
|
652
|
+
traceparent: string | null;
|
|
653
|
+
tracestate: string | null;
|
|
654
|
+
};
|
|
655
|
+
};
|
|
656
|
+
delta: string | null;
|
|
657
|
+
};
|
|
658
|
+
}>, z.ZodObject<{
|
|
659
|
+
type: z.ZodLiteral<"agent.llm.delta.tool">;
|
|
660
|
+
data: z.ZodObject<{
|
|
661
|
+
comment: z.ZodString;
|
|
662
|
+
toolname: z.ZodString;
|
|
663
|
+
toolUseId: z.ZodString;
|
|
664
|
+
input: z.ZodString;
|
|
665
|
+
meta: z.ZodObject<{
|
|
666
|
+
error: z.ZodNullable<z.ZodString>;
|
|
667
|
+
token: z.ZodObject<{
|
|
668
|
+
prompt: z.ZodNumber;
|
|
669
|
+
completion: z.ZodNumber;
|
|
670
|
+
}, "strip", z.ZodTypeAny, {
|
|
671
|
+
prompt: number;
|
|
672
|
+
completion: number;
|
|
673
|
+
}, {
|
|
674
|
+
prompt: number;
|
|
675
|
+
completion: number;
|
|
676
|
+
}>;
|
|
677
|
+
otel: z.ZodObject<{
|
|
678
|
+
traceparent: z.ZodNullable<z.ZodString>;
|
|
679
|
+
tracestate: z.ZodNullable<z.ZodString>;
|
|
680
|
+
}, "strip", z.ZodTypeAny, {
|
|
681
|
+
traceparent: string | null;
|
|
682
|
+
tracestate: string | null;
|
|
683
|
+
}, {
|
|
684
|
+
traceparent: string | null;
|
|
685
|
+
tracestate: string | null;
|
|
686
|
+
}>;
|
|
687
|
+
}, "strip", z.ZodTypeAny, {
|
|
688
|
+
error: string | null;
|
|
689
|
+
token: {
|
|
690
|
+
prompt: number;
|
|
691
|
+
completion: number;
|
|
692
|
+
};
|
|
693
|
+
otel: {
|
|
694
|
+
traceparent: string | null;
|
|
695
|
+
tracestate: string | null;
|
|
696
|
+
};
|
|
697
|
+
}, {
|
|
698
|
+
error: string | null;
|
|
699
|
+
token: {
|
|
700
|
+
prompt: number;
|
|
701
|
+
completion: number;
|
|
702
|
+
};
|
|
703
|
+
otel: {
|
|
704
|
+
traceparent: string | null;
|
|
705
|
+
tracestate: string | null;
|
|
706
|
+
};
|
|
707
|
+
}>;
|
|
708
|
+
}, "strip", z.ZodTypeAny, {
|
|
709
|
+
comment: string;
|
|
710
|
+
meta: {
|
|
711
|
+
error: string | null;
|
|
712
|
+
token: {
|
|
713
|
+
prompt: number;
|
|
714
|
+
completion: number;
|
|
715
|
+
};
|
|
716
|
+
otel: {
|
|
717
|
+
traceparent: string | null;
|
|
718
|
+
tracestate: string | null;
|
|
719
|
+
};
|
|
720
|
+
};
|
|
721
|
+
toolname: string;
|
|
722
|
+
toolUseId: string;
|
|
723
|
+
input: string;
|
|
724
|
+
}, {
|
|
725
|
+
comment: string;
|
|
726
|
+
meta: {
|
|
727
|
+
error: string | null;
|
|
728
|
+
token: {
|
|
729
|
+
prompt: number;
|
|
730
|
+
completion: number;
|
|
731
|
+
};
|
|
732
|
+
otel: {
|
|
733
|
+
traceparent: string | null;
|
|
734
|
+
tracestate: string | null;
|
|
735
|
+
};
|
|
736
|
+
};
|
|
737
|
+
toolname: string;
|
|
738
|
+
toolUseId: string;
|
|
739
|
+
input: string;
|
|
740
|
+
}>;
|
|
741
|
+
}, "strip", z.ZodTypeAny, {
|
|
742
|
+
type: "agent.llm.delta.tool";
|
|
743
|
+
data: {
|
|
744
|
+
comment: string;
|
|
745
|
+
meta: {
|
|
746
|
+
error: string | null;
|
|
747
|
+
token: {
|
|
748
|
+
prompt: number;
|
|
749
|
+
completion: number;
|
|
750
|
+
};
|
|
751
|
+
otel: {
|
|
752
|
+
traceparent: string | null;
|
|
753
|
+
tracestate: string | null;
|
|
754
|
+
};
|
|
755
|
+
};
|
|
756
|
+
toolname: string;
|
|
757
|
+
toolUseId: string;
|
|
758
|
+
input: string;
|
|
759
|
+
};
|
|
760
|
+
}, {
|
|
761
|
+
type: "agent.llm.delta.tool";
|
|
762
|
+
data: {
|
|
763
|
+
comment: string;
|
|
764
|
+
meta: {
|
|
765
|
+
error: string | null;
|
|
766
|
+
token: {
|
|
767
|
+
prompt: number;
|
|
768
|
+
completion: number;
|
|
769
|
+
};
|
|
770
|
+
otel: {
|
|
771
|
+
traceparent: string | null;
|
|
772
|
+
tracestate: string | null;
|
|
773
|
+
};
|
|
774
|
+
};
|
|
775
|
+
toolname: string;
|
|
776
|
+
toolUseId: string;
|
|
777
|
+
input: string;
|
|
454
778
|
};
|
|
455
779
|
}>, z.ZodObject<{
|
|
456
780
|
type: z.ZodLiteral<"agent.tool.permission.blocked">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/Agent/stream/schema.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAcpB,eAAO,MAAM,sBAAsB
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/Agent/stream/schema.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAcpB,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAwJjC,CAAC"}
|
|
@@ -80,8 +80,58 @@ exports.AgentStreamEventSchema = zod_1.default.discriminatedUnion('type', [
|
|
|
80
80
|
zod_1.default.object({
|
|
81
81
|
type: zod_1.default.literal('agent.llm.delta'),
|
|
82
82
|
data: zod_1.default.object({
|
|
83
|
-
|
|
83
|
+
finishReason: zod_1.default.string().nullable(),
|
|
84
|
+
comment: zod_1.default.string(),
|
|
85
|
+
meta: zod_1.default.object({
|
|
86
|
+
error: zod_1.default.string().nullable(),
|
|
87
|
+
token: zod_1.default.object({
|
|
88
|
+
prompt: zod_1.default.number(),
|
|
89
|
+
completion: zod_1.default.number(),
|
|
90
|
+
}),
|
|
91
|
+
otel: zod_1.default.object({
|
|
92
|
+
traceparent: zod_1.default.string().nullable(),
|
|
93
|
+
tracestate: zod_1.default.string().nullable(),
|
|
94
|
+
}),
|
|
95
|
+
}),
|
|
96
|
+
}),
|
|
97
|
+
}),
|
|
98
|
+
zod_1.default.object({
|
|
99
|
+
type: zod_1.default.literal('agent.llm.delta.text'),
|
|
100
|
+
data: zod_1.default.object({
|
|
101
|
+
delta: zod_1.default.string().nullable(),
|
|
84
102
|
content: zod_1.default.string(),
|
|
103
|
+
comment: zod_1.default.string(),
|
|
104
|
+
meta: zod_1.default.object({
|
|
105
|
+
error: zod_1.default.string().nullable(),
|
|
106
|
+
token: zod_1.default.object({
|
|
107
|
+
prompt: zod_1.default.number(),
|
|
108
|
+
completion: zod_1.default.number(),
|
|
109
|
+
}),
|
|
110
|
+
otel: zod_1.default.object({
|
|
111
|
+
traceparent: zod_1.default.string().nullable(),
|
|
112
|
+
tracestate: zod_1.default.string().nullable(),
|
|
113
|
+
}),
|
|
114
|
+
}),
|
|
115
|
+
}),
|
|
116
|
+
}),
|
|
117
|
+
zod_1.default.object({
|
|
118
|
+
type: zod_1.default.literal('agent.llm.delta.tool'),
|
|
119
|
+
data: zod_1.default.object({
|
|
120
|
+
comment: zod_1.default.string(),
|
|
121
|
+
toolname: zod_1.default.string(),
|
|
122
|
+
toolUseId: zod_1.default.string(),
|
|
123
|
+
input: zod_1.default.string(),
|
|
124
|
+
meta: zod_1.default.object({
|
|
125
|
+
error: zod_1.default.string().nullable(),
|
|
126
|
+
token: zod_1.default.object({
|
|
127
|
+
prompt: zod_1.default.number(),
|
|
128
|
+
completion: zod_1.default.number(),
|
|
129
|
+
}),
|
|
130
|
+
otel: zod_1.default.object({
|
|
131
|
+
traceparent: zod_1.default.string().nullable(),
|
|
132
|
+
tracestate: zod_1.default.string().nullable(),
|
|
133
|
+
}),
|
|
134
|
+
}),
|
|
85
135
|
}),
|
|
86
136
|
}),
|
|
87
137
|
zod_1.default.object({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/Agent/stream/schema.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AAEpB,IAAM,gBAAgB,GAAG,aAAC,CAAC,MAAM,CAA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cAAc,EAAE,aAAC,CAAC,MAAM,EAAE;SAC3B,CAAC;KACH,CAAC;CACH,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Integrations/anthropic/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAiB/C,OAAO,KAAK,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Integrations/anthropic/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAiB/C,OAAO,KAAK,EAAE,mBAAmB,EAAiD,MAAM,UAAU,CAAC;AAGnG,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAG7D;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,uBAAuB,GACjC,QAAQ,SAAS,EAAE,SAAS,6BAA6B,KAAG,mBAkKzD,CAAC"}
|
|
@@ -64,7 +64,10 @@ var api_1 = require("@opentelemetry/api");
|
|
|
64
64
|
var arvo_core_1 = require("arvo-core");
|
|
65
65
|
var zod_to_json_schema_1 = require("zod-to-json-schema");
|
|
66
66
|
var utils_1 = require("../../Agent/utils");
|
|
67
|
+
var defaultContextTransformer_1 = require("../defaultContextTransformer");
|
|
67
68
|
var prompts_1 = require("../prompts");
|
|
69
|
+
var nonstreamable_1 = require("./nonstreamable");
|
|
70
|
+
var streamable_1 = require("./streamable");
|
|
68
71
|
var utils_2 = require("./utils");
|
|
69
72
|
/**
|
|
70
73
|
* Creates an Arvo-compatible LLM Adapter for Anthropic Claude models.
|
|
@@ -88,7 +91,7 @@ var utils_2 = require("./utils");
|
|
|
88
91
|
var anthropicLLMIntegration = function (client, config) {
|
|
89
92
|
return function (_a, _b) { return __awaiter(void 0, [_a, _b], void 0, function (_c, _d) {
|
|
90
93
|
var _e;
|
|
91
|
-
var _messages = _c.messages, _system = _c.system, tools = _c.tools, outputFormat = _c.outputFormat, lifecycle = _c.lifecycle, toolInteractions = _c.toolInteractions;
|
|
94
|
+
var _messages = _c.messages, _system = _c.system, tools = _c.tools, outputFormat = _c.outputFormat, lifecycle = _c.lifecycle, toolInteractions = _c.toolInteractions, onStream = _c.onStream;
|
|
92
95
|
var otelInfo = _d.otelInfo;
|
|
93
96
|
return __generator(this, function (_f) {
|
|
94
97
|
switch (_f.label) {
|
|
@@ -105,40 +108,21 @@ var anthropicLLMIntegration = function (client, config) {
|
|
|
105
108
|
_e),
|
|
106
109
|
},
|
|
107
110
|
fn: function (span) { return __awaiter(void 0, void 0, void 0, function () {
|
|
108
|
-
var messageCreateParams, _a, messages, system, limitMessage, jsonSchema, schemaInstruction, toolDef, tools_1, tools_1_1, tool, formattedMessages,
|
|
109
|
-
var e_2, _b
|
|
110
|
-
var _d, _e, _f, _g, _h, _j, _k;
|
|
111
|
+
var messageCreateParams, _a, messages, system, limitMessage, jsonSchema, schemaInstruction, toolDef, tools_1, tools_1_1, tool, formattedMessages, enableStreaming, result, llmUsage, executionUnits, content, e_1;
|
|
112
|
+
var e_2, _b;
|
|
113
|
+
var _c, _d, _e, _f, _g, _h, _j, _k;
|
|
111
114
|
return __generator(this, function (_l) {
|
|
112
115
|
switch (_l.label) {
|
|
113
116
|
case 0:
|
|
114
|
-
messageCreateParams = (
|
|
115
|
-
|
|
116
|
-
max_tokens: 4096,
|
|
117
|
-
temperature: 0,
|
|
118
|
-
};
|
|
119
|
-
return [4 /*yield*/, ((_e = config === null || config === void 0 ? void 0 : config.contextTransformer) === null || _e === void 0 ? void 0 : _e.call(config, {
|
|
117
|
+
messageCreateParams = __assign({ model: 'claude-sonnet-4-20250514', max_tokens: 4096, temperature: 0, stream: true }, ((_c = config === null || config === void 0 ? void 0 : config.invocationParam) !== null && _c !== void 0 ? _c : {}));
|
|
118
|
+
return [4 /*yield*/, ((_d = config === null || config === void 0 ? void 0 : config.contextTransformer) !== null && _d !== void 0 ? _d : defaultContextTransformer_1.defaultContextTransformer)({
|
|
120
119
|
messages: _messages,
|
|
121
120
|
system: _system,
|
|
122
|
-
})
|
|
121
|
+
})];
|
|
123
122
|
case 1:
|
|
124
|
-
_a =
|
|
125
|
-
messages: _messages.map(function (item) {
|
|
126
|
-
if (item.content.type === 'media' && item.seenCount > 0) {
|
|
127
|
-
return {
|
|
128
|
-
role: item.role,
|
|
129
|
-
content: {
|
|
130
|
-
type: 'text',
|
|
131
|
-
content: "Media file (type: ".concat(item.content.contentType.type, "@").concat(item.content.contentType.format, ") already parsed and looked at. No need for you to look at it again"),
|
|
132
|
-
},
|
|
133
|
-
seenCount: item.seenCount,
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
return item;
|
|
137
|
-
}),
|
|
138
|
-
system: _system,
|
|
139
|
-
}, messages = _a.messages, system = _a.system;
|
|
123
|
+
_a = _l.sent(), messages = _a.messages, system = _a.system;
|
|
140
124
|
if (toolInteractions.exhausted) {
|
|
141
|
-
limitMessage = (
|
|
125
|
+
limitMessage = (_f = (_e = config === null || config === void 0 ? void 0 : config.toolLimitPrompt) === null || _e === void 0 ? void 0 : _e.call(config, toolInteractions)) !== null && _f !== void 0 ? _f : prompts_1.DEFAULT_TOOL_LIMIT_PROMPT;
|
|
142
126
|
messages.push({
|
|
143
127
|
role: 'user',
|
|
144
128
|
content: {
|
|
@@ -149,7 +133,6 @@ var anthropicLLMIntegration = function (client, config) {
|
|
|
149
133
|
});
|
|
150
134
|
system = "".concat(system, "\n\n").concat(limitMessage);
|
|
151
135
|
}
|
|
152
|
-
// For JSON output format, append schema instructions to the system prompt
|
|
153
136
|
if (outputFormat.type === 'json') {
|
|
154
137
|
jsonSchema = (0, zod_to_json_schema_1.zodToJsonSchema)(outputFormat.format);
|
|
155
138
|
schemaInstruction = (0, prompts_1.jsonPrompt)(JSON.stringify(jsonSchema));
|
|
@@ -168,7 +151,7 @@ var anthropicLLMIntegration = function (client, config) {
|
|
|
168
151
|
}, span);
|
|
169
152
|
_l.label = 2;
|
|
170
153
|
case 2:
|
|
171
|
-
_l.trys.push([2,
|
|
154
|
+
_l.trys.push([2, 7, 8, 9]);
|
|
172
155
|
toolDef = [];
|
|
173
156
|
try {
|
|
174
157
|
for (tools_1 = __values(tools), tools_1_1 = tools_1.next(); !tools_1_1.done; tools_1_1 = tools_1.next()) {
|
|
@@ -188,65 +171,37 @@ var anthropicLLMIntegration = function (client, config) {
|
|
|
188
171
|
finally { if (e_2) throw e_2.error; }
|
|
189
172
|
}
|
|
190
173
|
formattedMessages = (0, utils_2.formatMessagesForAnthropic)(messages);
|
|
191
|
-
|
|
174
|
+
enableStreaming = (_h = (_g = config === null || config === void 0 ? void 0 : config.invocationParam) === null || _g === void 0 ? void 0 : _g.stream) !== null && _h !== void 0 ? _h : false;
|
|
175
|
+
result = void 0;
|
|
176
|
+
if (!enableStreaming) return [3 /*break*/, 4];
|
|
177
|
+
return [4 /*yield*/, (0, streamable_1.streamableAnthropic)(client, __assign(__assign({}, messageCreateParams), { stream: true, system: system !== null && system !== void 0 ? system : undefined, tools: toolDef.length ? toolDef : undefined, messages: formattedMessages }), { span: span, onStream: onStream })];
|
|
192
178
|
case 3:
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
179
|
+
result = _l.sent();
|
|
180
|
+
return [3 /*break*/, 6];
|
|
181
|
+
case 4: return [4 /*yield*/, (0, nonstreamable_1.nonStreamableAnthropic)(client, __assign(__assign({}, messageCreateParams), { stream: false, system: system !== null && system !== void 0 ? system : undefined, tools: toolDef.length ? toolDef : undefined, messages: formattedMessages }), { span: span })];
|
|
182
|
+
case 5:
|
|
183
|
+
result = _l.sent();
|
|
184
|
+
_l.label = 6;
|
|
185
|
+
case 6:
|
|
186
|
+
llmUsage = result.usage;
|
|
200
187
|
executionUnits = (_k = (_j = config === null || config === void 0 ? void 0 : config.executionunits) === null || _j === void 0 ? void 0 : _j.call(config, llmUsage.tokens.prompt, llmUsage.tokens.completion)) !== null && _k !== void 0 ? _k : llmUsage.tokens.prompt + llmUsage.tokens.completion;
|
|
201
188
|
(0, utils_1.setOpenInferenceUsageOutputAttr)(llmUsage, span);
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
toolUseId: toolCall.id,
|
|
211
|
-
name: toolCall.name,
|
|
212
|
-
input: toolCall.input,
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
catch (err) {
|
|
216
|
-
(0, arvo_core_1.exceptionToSpan)(err, span);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
221
|
-
finally {
|
|
222
|
-
try {
|
|
223
|
-
if (toolUseBlocks_1_1 && !toolUseBlocks_1_1.done && (_c = toolUseBlocks_1.return)) _c.call(toolUseBlocks_1);
|
|
224
|
-
}
|
|
225
|
-
finally { if (e_3) throw e_3.error; }
|
|
226
|
-
}
|
|
227
|
-
if (toolRequests.length) {
|
|
228
|
-
(0, utils_1.setOpenInferenceToolCallOutputAttr)({ toolCalls: toolRequests }, span);
|
|
229
|
-
return [2 /*return*/, {
|
|
230
|
-
type: 'tool_call',
|
|
231
|
-
toolRequests: toolRequests,
|
|
232
|
-
usage: llmUsage,
|
|
233
|
-
executionUnits: executionUnits,
|
|
234
|
-
}];
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
textBlocks = response.content.filter(function (block) { return block.type === 'text'; });
|
|
238
|
-
content = textBlocks.map(function (block) { return block.text; }).join('');
|
|
239
|
-
// Handle stop reasons
|
|
240
|
-
if (response.stop_reason === 'max_tokens') {
|
|
241
|
-
content = "".concat(content, " [Max response token limit (<= ").concat(messageCreateParams.max_tokens, ") reached]");
|
|
242
|
-
throw new Error("Agent reached max token limit. The partial response is \"".concat(content, "\""));
|
|
189
|
+
if (result.toolRequests && result.toolRequests.length > 0) {
|
|
190
|
+
(0, utils_1.setOpenInferenceToolCallOutputAttr)({ toolCalls: result.toolRequests }, span);
|
|
191
|
+
return [2 /*return*/, {
|
|
192
|
+
type: 'tool_call',
|
|
193
|
+
toolRequests: result.toolRequests,
|
|
194
|
+
usage: llmUsage,
|
|
195
|
+
executionUnits: executionUnits,
|
|
196
|
+
}];
|
|
243
197
|
}
|
|
198
|
+
content = result.response || '';
|
|
244
199
|
(0, utils_1.setOpenInferenceResponseOutputAttr)({ response: content }, span);
|
|
245
200
|
if (outputFormat.type === 'json') {
|
|
246
201
|
return [2 /*return*/, {
|
|
247
202
|
type: 'json',
|
|
248
|
-
content: content || '
|
|
249
|
-
parsedContent: (0, utils_1.tryParseJson)(content || '
|
|
203
|
+
content: content || '',
|
|
204
|
+
parsedContent: (0, utils_1.tryParseJson)(content || ''),
|
|
250
205
|
usage: llmUsage,
|
|
251
206
|
executionUnits: executionUnits,
|
|
252
207
|
}];
|
|
@@ -257,14 +212,15 @@ var anthropicLLMIntegration = function (client, config) {
|
|
|
257
212
|
usage: llmUsage,
|
|
258
213
|
executionUnits: executionUnits,
|
|
259
214
|
}];
|
|
260
|
-
case
|
|
215
|
+
case 7:
|
|
261
216
|
e_1 = _l.sent();
|
|
262
217
|
span.setStatus({ code: api_1.SpanStatusCode.ERROR, message: e_1 === null || e_1 === void 0 ? void 0 : e_1.message });
|
|
218
|
+
(0, arvo_core_1.exceptionToSpan)(e_1, span);
|
|
263
219
|
throw e_1;
|
|
264
|
-
case
|
|
220
|
+
case 8:
|
|
265
221
|
span.end();
|
|
266
222
|
return [7 /*endfinally*/];
|
|
267
|
-
case
|
|
223
|
+
case 9: return [2 /*return*/];
|
|
268
224
|
}
|
|
269
225
|
});
|
|
270
226
|
}); },
|