@@ -23,10 +23,13 @@ export declare class BamlRuntime {
2323 static fromFiles ( rootPath : string , files : Record < string , string > , envVars : Record < string , string | undefined | null > ) : BamlRuntime
2424 reset ( rootPath : string , files : Record < string , string > , envVars : Record < string , string > ) : void
2525 createContextManager ( ) : RuntimeContextManager
26- callFunction ( functionName : string , args : { [ name : string ] : any } , ctx : RuntimeContextManager , tb ?: TypeBuilder | undefined | null , cb ?: ClientRegistry | undefined | null ) : Promise < FunctionResult >
27- callFunctionSync ( functionName : string , args : { [ name : string ] : any } , ctx : RuntimeContextManager , tb ?: TypeBuilder | undefined | null , cb ?: ClientRegistry | undefined | null ) : FunctionResult
28- streamFunction ( functionName : string , args : { [ name : string ] : any } , cb : ( ( err : any , param : FunctionResult ) => void ) | undefined , ctx : RuntimeContextManager , tb ?: TypeBuilder | undefined | null , clientRegistry ?: ClientRegistry | undefined | null ) : FunctionResultStream
29- streamFunctionSync ( functionName : string , args : { [ name : string ] : any } , cb : ( ( err : any , param : FunctionResult ) => void ) | undefined , ctx : RuntimeContextManager , tb ?: TypeBuilder | undefined | null , clientRegistry ?: ClientRegistry | undefined | null ) : FunctionResultStream
26+ callFunction ( functionName : string , args : { [ name : string ] : any } , ctx : RuntimeContextManager , tb : TypeBuilder | undefined | null , cb : ClientRegistry | undefined | null , collectors : Array < Collector > ) : Promise < FunctionResult >
27+ callFunctionSync ( functionName : string , args : { [ name : string ] : any } , ctx : RuntimeContextManager , tb : TypeBuilder | undefined | null , cb : ClientRegistry | undefined | null , collectors : Array < Collector > ) : FunctionResult
28+ streamFunction ( functionName : string , args : { [ name : string ] : any } , cb : ( ( err : any , param : FunctionResult ) => void ) | undefined , ctx : RuntimeContextManager , tb : TypeBuilder | undefined | null , clientRegistry : ClientRegistry | undefined | null , collectors : Array < Collector > ) : FunctionResultStream
29+ streamFunctionSync ( functionName : string , args : { [ name : string ] : any } , cb : ( ( err : any , param : FunctionResult ) => void ) | undefined , ctx : RuntimeContextManager , tb : TypeBuilder | undefined | null , clientRegistry : ClientRegistry | undefined | null , collectors : Array < Collector > ) : FunctionResultStream
30+ buildRequest ( functionName : string , args : { [ name : string ] : any } , ctx : RuntimeContextManager , tb : TypeBuilder | undefined | null , cb : ClientRegistry | undefined | null , stream : boolean ) : Promise < HTTPRequest >
31+ buildRequestSync ( functionName : string , args : { [ name : string ] : any } , ctx : RuntimeContextManager , tb : TypeBuilder | undefined | null , cb : ClientRegistry | undefined | null , stream : boolean ) : HTTPRequest
32+ parseLlmResponse ( functionName : string , llmResponse : string , allowPartials : boolean , ctx : RuntimeContextManager , tb ?: TypeBuilder | undefined | null , cb ?: ClientRegistry | undefined | null ) : any
3033 setLogEventCallback ( func ?: undefined | ( ( err : any , param : BamlLogEvent ) => void ) ) : void
3134 flush ( ) : void
3235 drainStats ( ) : TraceStats
@@ -54,6 +57,17 @@ export declare class ClientRegistry {
5457 setPrimary ( primary : string ) : void
5558}
5659
60+ export declare class Collector {
61+ constructor ( name ?: string | undefined | null )
62+ get logs ( ) : Array < FunctionLog >
63+ get last ( ) : FunctionLog | null
64+ id ( functionLogId : string ) : FunctionLog | null
65+ get usage ( ) : Usage
66+ toString ( ) : string
67+ static __functionSpanCount ( ) : number
68+ static __printStorage ( ) : void
69+ }
70+
5771export declare class EnumBuilder {
5872 value ( name : string ) : EnumValueBuilder
5973 alias ( alias ?: string | undefined | null ) : EnumBuilder
@@ -71,22 +85,100 @@ export declare class FieldType {
7185 optional ( ) : FieldType
7286}
7387
88+ export declare class FunctionLog {
89+ toString ( ) : string
90+ get id ( ) : string
91+ get functionName ( ) : string
92+ get logType ( ) : string
93+ get timing ( ) : Timing
94+ get usage ( ) : Usage
95+ get calls ( ) : ( LLMCall | LLMStreamCall ) [ ]
96+ get rawLlmResponse ( ) : string | null
97+ get selectedCall ( ) : unknown
98+ }
99+
74100export declare class FunctionResult {
75101 isOk ( ) : boolean
76102 parsed ( allowPartials : boolean ) : any
77103}
78104
79105export declare class FunctionResultStream {
80- onEvent ( func : ( err : any , param : FunctionResult ) => void ) : void
106+ onEvent ( func ? : ( ( err : any , param : FunctionResult ) => void ) | undefined ) : void
81107 done ( rctx : RuntimeContextManager ) : Promise < FunctionResult >
82108}
83109
110+ export declare class HttpBody {
111+ raw ( ) : ArrayBuffer
112+ text ( ) : string
113+ json ( ) : any
114+ }
115+ export type HTTPBody = HttpBody
116+
117+ export declare class HttpRequest {
118+ get id ( ) : string
119+ get body ( ) : HttpBody
120+ toString ( ) : string
121+ get url ( ) : string
122+ get method ( ) : string
123+ get headers ( ) : object
124+ }
125+ export type HTTPRequest = HttpRequest
126+
127+ export declare class HttpResponse {
128+ toString ( ) : string
129+ get status ( ) : number
130+ get headers ( ) : object
131+ get body ( ) : any
132+ }
133+ export type HTTPResponse = HttpResponse
134+
135+ export declare class LlmCall {
136+ get selected ( ) : boolean
137+ get httpRequest ( ) : HTTPRequest | null
138+ get httpResponse ( ) : HTTPResponse | null
139+ get usage ( ) : Usage | null
140+ get timing ( ) : Timing
141+ get provider ( ) : string
142+ get clientName ( ) : string
143+ toString ( ) : string
144+ toString ( ) : string
145+ }
146+ export type LLMCall = LlmCall
147+
148+ export declare class LlmStreamCall {
149+ toString ( ) : string
150+ get httpRequest ( ) : HTTPRequest | null
151+ get httpResponse ( ) : HTTPResponse | null
152+ get provider ( ) : string
153+ get clientName ( ) : string
154+ get selected ( ) : boolean
155+ get usage ( ) : Usage | null
156+ get timing ( ) : StreamTiming
157+ toString ( ) : string
158+ }
159+ export type LLMStreamCall = LlmStreamCall
160+
84161export declare class RuntimeContextManager {
85162 upsertTags ( tags : any ) : void
86163 deepClone ( ) : RuntimeContextManager
87164 contextDepth ( ) : number
88165}
89166
167+ export declare class StreamTiming {
168+ toString ( ) : string
169+ get startTimeUtcMs ( ) : number
170+ get durationMs ( ) : number | null
171+ get timeToFirstParsedMs ( ) : number | null
172+ get timeToFirstTokenMs ( ) : number | null
173+ }
174+
175+ export declare class Timing {
176+ toString ( ) : string
177+ get startTimeUtcMs ( ) : number
178+ get durationMs ( ) : number | null
179+ get timeToFirstParsedMs ( ) : number | null
180+ }
181+
90182export declare class TraceStats {
91183 get failed ( ) : number
92184 get started ( ) : number
@@ -117,6 +209,12 @@ export declare class TypeBuilder {
117209 toString ( ) : string
118210}
119211
212+ export declare class Usage {
213+ toString ( ) : string
214+ get inputTokens ( ) : number | null
215+ get outputTokens ( ) : number | null
216+ }
217+
120218export interface BamlLogEvent {
121219 metadata : LogEventMetadata
122220 prompt ?: string
@@ -125,11 +223,21 @@ export interface BamlLogEvent {
125223 startTime : string
126224}
127225
128- export declare export declare function invoke_runtime_cli ( params : Array < string > ) : void
226+ export declare export declare function get_version ( ) : string
227+
228+ export declare export declare function getLogLevel ( ) : string
229+
230+ export declare export declare function invoke_runtime_cli ( params : Array < string > ) : number
129231
130232export interface LogEventMetadata {
131233 eventId : string
132234 parentId ?: string
133235 rootEventId : string
134236}
135237
238+ export declare export declare function setLogJsonMode ( useJson : boolean ) : void
239+
240+ export declare export declare function setLogLevel ( level : string ) : void
241+
242+ export declare export declare function setLogMaxChunkLength ( length : number ) : void
243+
0 commit comments