@illalabs/sdk 0.4.0-canary.361ed2fa → 0.4.0-canary.4647332c
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/README.md +53 -0
- package/dist/src/chat/Chat.d.ts +31 -2
- package/dist/src/chat/Chat.d.ts.map +1 -1
- package/dist/src/chat/Chat.js +81 -3
- package/dist/src/chat/Chat.js.map +1 -1
- package/dist/src/context/ContextManager.js +1 -1
- package/dist/src/context/ContextManager.js.map +1 -1
- package/dist/src/interfaces/chat.interface.d.ts +52 -1
- package/dist/src/interfaces/chat.interface.d.ts.map +1 -1
- package/dist/src/interfaces/coreApiProvider.interface.d.ts +13 -1
- package/dist/src/interfaces/coreApiProvider.interface.d.ts.map +1 -1
- package/dist/src/interfaces/index.d.ts +1 -1
- package/dist/src/interfaces/index.d.ts.map +1 -1
- package/dist/src/internal.d.ts +1 -0
- package/dist/src/internal.d.ts.map +1 -1
- package/dist/src/internal.js +1 -0
- package/dist/src/internal.js.map +1 -1
- package/dist/src/prompt/index.d.ts +1 -1
- package/dist/src/prompt/index.d.ts.map +1 -1
- package/dist/src/providers/coreApiProvider/CoreApiProvider.d.ts +40 -1
- package/dist/src/providers/coreApiProvider/CoreApiProvider.d.ts.map +1 -1
- package/dist/src/providers/coreApiProvider/CoreApiProvider.js +124 -2
- package/dist/src/providers/coreApiProvider/CoreApiProvider.js.map +1 -1
- package/dist/src/providers/coreApiProvider/index.d.ts +1 -1
- package/dist/src/providers/coreApiProvider/index.d.ts.map +1 -1
- package/dist/src/providers/coreApiProvider/types.d.ts +44 -0
- package/dist/src/providers/coreApiProvider/types.d.ts.map +1 -1
- package/dist/src/sdk.d.ts +65 -4
- package/dist/src/sdk.d.ts.map +1 -1
- package/dist/src/sdk.js +58 -4
- package/dist/src/sdk.js.map +1 -1
- package/dist/src/streaming/errors/SSEParse.d.ts +15 -0
- package/dist/src/streaming/errors/SSEParse.d.ts.map +1 -0
- package/dist/src/streaming/errors/SSEParse.js +23 -0
- package/dist/src/streaming/errors/SSEParse.js.map +1 -0
- package/dist/src/streaming/errors/StreamingHttpError.d.ts +18 -0
- package/dist/src/streaming/errors/StreamingHttpError.d.ts.map +1 -0
- package/dist/src/streaming/errors/StreamingHttpError.js +27 -0
- package/dist/src/streaming/errors/StreamingHttpError.js.map +1 -0
- package/dist/src/streaming/errors/StreamingResponseBodyNull.d.ts +13 -0
- package/dist/src/streaming/errors/StreamingResponseBodyNull.d.ts.map +1 -0
- package/dist/src/streaming/errors/StreamingResponseBodyNull.js +21 -0
- package/dist/src/streaming/errors/StreamingResponseBodyNull.js.map +1 -0
- package/dist/src/streaming/errors/StreamingServerError.d.ts +23 -0
- package/dist/src/streaming/errors/StreamingServerError.d.ts.map +1 -0
- package/dist/src/streaming/errors/StreamingServerError.js +33 -0
- package/dist/src/streaming/errors/StreamingServerError.js.map +1 -0
- package/dist/src/streaming/errors/index.d.ts +5 -0
- package/dist/src/streaming/errors/index.d.ts.map +1 -0
- package/dist/src/streaming/errors/index.js +5 -0
- package/dist/src/streaming/errors/index.js.map +1 -0
- package/dist/src/streaming/index.d.ts +4 -0
- package/dist/src/streaming/index.d.ts.map +1 -0
- package/dist/src/streaming/index.js +3 -0
- package/dist/src/streaming/index.js.map +1 -0
- package/dist/src/streaming/parseSSE.d.ts +23 -0
- package/dist/src/streaming/parseSSE.d.ts.map +1 -0
- package/dist/src/streaming/parseSSE.js +152 -0
- package/dist/src/streaming/parseSSE.js.map +1 -0
- package/dist/src/streaming/types.d.ts +6 -0
- package/dist/src/streaming/types.d.ts.map +1 -0
- package/dist/src/streaming/types.js +6 -0
- package/dist/src/streaming/types.js.map +1 -0
- package/dist/src/telemetry/TelemetryClient.d.ts +140 -0
- package/dist/src/telemetry/TelemetryClient.d.ts.map +1 -0
- package/dist/src/telemetry/TelemetryClient.js +225 -0
- package/dist/src/telemetry/TelemetryClient.js.map +1 -0
- package/dist/src/telemetry/index.d.ts +2 -0
- package/dist/src/telemetry/index.d.ts.map +1 -0
- package/dist/src/telemetry/index.js +2 -0
- package/dist/src/telemetry/index.js.map +1 -0
- package/package.json +3 -5
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
|
+
import { stringify } from "viem";
|
|
3
|
+
import { generateUUID } from "../../chat/utils/index.js";
|
|
4
|
+
import { parseSSEStream, StreamingHttpError, StreamingResponseBodyNull, StreamingServerError, } from "../../streaming/index.js";
|
|
2
5
|
import { AsyncToolCheckerErrorHandler, ChatErrorHandler } from "./CoreApiErrorHandler.js";
|
|
3
6
|
import { CoreApiAuthenticationMissing } from "./errors/index.js";
|
|
4
7
|
/**
|
|
@@ -13,15 +16,25 @@ export class CoreApiProvider {
|
|
|
13
16
|
* Routes used by the provider when issuing requests.
|
|
14
17
|
*/
|
|
15
18
|
routes;
|
|
19
|
+
/**
|
|
20
|
+
* Base URL for the API (stored for streaming requests that use fetch)
|
|
21
|
+
*/
|
|
22
|
+
baseUrl;
|
|
23
|
+
/**
|
|
24
|
+
* Auth headers for streaming requests that use fetch
|
|
25
|
+
*/
|
|
26
|
+
authHeaders;
|
|
16
27
|
/**
|
|
17
28
|
* @param config Core API provider configuration
|
|
18
29
|
*/
|
|
19
30
|
constructor({ baseURL, timeout, headers, httpClientFactory, routes }) {
|
|
20
31
|
const authHeaders = this.ensureAuthHeaders(headers);
|
|
32
|
+
this.authHeaders = authHeaders;
|
|
33
|
+
this.baseUrl = this.resolveBaseUrl(baseURL);
|
|
21
34
|
const resolveClientFactory = httpClientFactory ??
|
|
22
35
|
((configuration) => axios.create(configuration));
|
|
23
36
|
this.client = resolveClientFactory({
|
|
24
|
-
baseURL: this.
|
|
37
|
+
baseURL: this.baseUrl,
|
|
25
38
|
timeout,
|
|
26
39
|
headers: this.buildDefaultHeaders(authHeaders),
|
|
27
40
|
});
|
|
@@ -32,11 +45,29 @@ export class CoreApiProvider {
|
|
|
32
45
|
}
|
|
33
46
|
/**
|
|
34
47
|
* Sends a chat message to the Core API
|
|
48
|
+
*
|
|
49
|
+
* @param body - The request body
|
|
50
|
+
* @param options - Request options including abort signal and onRequestId callback
|
|
51
|
+
* @returns The API response
|
|
35
52
|
*/
|
|
36
53
|
async sendMessage(body, options = {}) {
|
|
37
54
|
const requestConfig = this.buildRequestConfig(options);
|
|
55
|
+
// Generate a requestId for telemetry if not already provided
|
|
56
|
+
const requestId = body.requestId ?? generateUUID();
|
|
57
|
+
const bodyWithRequestId = {
|
|
58
|
+
...body,
|
|
59
|
+
requestId,
|
|
60
|
+
};
|
|
38
61
|
try {
|
|
39
|
-
const
|
|
62
|
+
const requestPromise = this.client.post(this.routes.chat, bodyWithRequestId, requestConfig);
|
|
63
|
+
// Notify caller of the requestId after request is initiated
|
|
64
|
+
// This allows connecting to telemetry stream while request is in flight
|
|
65
|
+
if (options.onRequestId) {
|
|
66
|
+
// Use queueMicrotask to ensure callback runs after request starts
|
|
67
|
+
// but before we block on await
|
|
68
|
+
queueMicrotask(() => options.onRequestId(requestId));
|
|
69
|
+
}
|
|
70
|
+
const response = await requestPromise;
|
|
40
71
|
return response.data;
|
|
41
72
|
}
|
|
42
73
|
catch (error) {
|
|
@@ -44,6 +75,97 @@ export class CoreApiProvider {
|
|
|
44
75
|
return errorResponse;
|
|
45
76
|
}
|
|
46
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Sends a chat message with streaming response via SSE.
|
|
80
|
+
*
|
|
81
|
+
* Instead of waiting for the full response, this method streams telemetry events
|
|
82
|
+
* in real-time as they occur during orchestration. The final result is delivered
|
|
83
|
+
* through the `onComplete` callback.
|
|
84
|
+
*
|
|
85
|
+
* This eliminates the need for a separate telemetry subscription - events and
|
|
86
|
+
* the result are delivered through a single HTTP connection.
|
|
87
|
+
*
|
|
88
|
+
* @param body - The request body (same as sendMessage)
|
|
89
|
+
* @param options - Streaming options with event callbacks
|
|
90
|
+
* @returns A promise that resolves when the stream ends (either successfully or with error)
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* await provider.sendMessageStreaming(
|
|
95
|
+
* { prompt, userContext },
|
|
96
|
+
* {
|
|
97
|
+
* onEvent: (event) => console.log('Event:', event.type),
|
|
98
|
+
* onComplete: (result) => console.log('Done:', result.text),
|
|
99
|
+
* onError: (error) => console.error('Error:', error),
|
|
100
|
+
* }
|
|
101
|
+
* );
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
async sendMessageStreaming(body, options = {}) {
|
|
105
|
+
const requestId = body.requestId ?? generateUUID();
|
|
106
|
+
const bodyWithRequestId = {
|
|
107
|
+
...body,
|
|
108
|
+
requestId,
|
|
109
|
+
};
|
|
110
|
+
// Notify caller of the requestId for API consistency with sendMessage
|
|
111
|
+
options.onRequestId?.(requestId);
|
|
112
|
+
const url = `${this.baseUrl}${this.routes.chat}`;
|
|
113
|
+
try {
|
|
114
|
+
const response = await fetch(url, {
|
|
115
|
+
method: "POST",
|
|
116
|
+
headers: {
|
|
117
|
+
"Content-Type": "application/json",
|
|
118
|
+
Accept: "text/event-stream",
|
|
119
|
+
...this.authHeaders,
|
|
120
|
+
},
|
|
121
|
+
body: stringify(bodyWithRequestId),
|
|
122
|
+
signal: options.signal,
|
|
123
|
+
});
|
|
124
|
+
if (!response.ok) {
|
|
125
|
+
const errorText = await response.text();
|
|
126
|
+
let errorMessage;
|
|
127
|
+
try {
|
|
128
|
+
const errorJson = JSON.parse(errorText);
|
|
129
|
+
errorMessage = errorJson.message ?? `HTTP ${response.status}`;
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
errorMessage = errorText || `HTTP ${response.status}`;
|
|
133
|
+
}
|
|
134
|
+
throw new StreamingHttpError(response.status, errorMessage);
|
|
135
|
+
}
|
|
136
|
+
if (!response.body) {
|
|
137
|
+
throw new StreamingResponseBodyNull();
|
|
138
|
+
}
|
|
139
|
+
// Parse SSE stream and dispatch events to callbacks
|
|
140
|
+
for await (const event of parseSSEStream(response.body, options.signal)) {
|
|
141
|
+
switch (event.type) {
|
|
142
|
+
case "telemetry": {
|
|
143
|
+
const telemetryEvent = event.data;
|
|
144
|
+
options.onEvent?.(telemetryEvent);
|
|
145
|
+
// Handle text_delta events for streaming text display
|
|
146
|
+
if (telemetryEvent.type === "text_delta") {
|
|
147
|
+
options.onTextDelta?.(telemetryEvent.data.delta);
|
|
148
|
+
}
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
case "result":
|
|
152
|
+
options.onComplete?.(event.data);
|
|
153
|
+
break;
|
|
154
|
+
case "error":
|
|
155
|
+
options.onError?.(new StreamingServerError(event.data.requestId, event.data.data.message, event.data.data.code));
|
|
156
|
+
break;
|
|
157
|
+
case "stream_end":
|
|
158
|
+
// Stream ended, nothing more to do
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
165
|
+
options.onError?.(err);
|
|
166
|
+
throw err;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
47
169
|
/**
|
|
48
170
|
* Polls the Core API for transaction status
|
|
49
171
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreApiProvider.js","sourceRoot":"","sources":["../../../../src/providers/coreApiProvider/CoreApiProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CoreApiProvider.js","sourceRoot":"","sources":["../../../../src/providers/coreApiProvider/CoreApiProvider.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAKjC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EACH,cAAc,EACd,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,GACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AA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AAa,CAAC;QACzB,CAAC;IACL,CAAC;IAED,kBAAkB;IACX,SAAS;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACO,kBAAkB,CAAC,OAAuB;QAChD,OAAO;YACH,MAAM,EAAE,OAAO,CAAC,MAAM;SACzB,CAAC;IACN,CAAC;IAEO,cAAc,CAAC,OAAyC;QAC5D,sDAAsD;QACtD,OAAO,OAAO,IAAI,6BAA6B,CAAC;IACpD,CAAC;IAEO,mBAAmB,CAAC,OAA2B;QACnD,OAAO;YACH,cAAc,EAAE,kBAAkB;YAClC,GAAG,OAAO;SACb,CAAC;IACN,CAAC;IAEO,iBAAiB,CAAC,OAA4B;QAClD,IAAI,OAAO,EAAE,CAAC,WAAW,CAAC,KAAK,SAAS,EAAE,CAAC;YACvC,MAAM,IAAI,4BAA4B,EAAE,CAAC;QAC7C,CAAC;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from "./CoreApiProvider.js";
|
|
2
2
|
export type { ICoreApiProvider } from "../../interfaces/index.js";
|
|
3
3
|
export type { CoreApiProviderConfig, CoreApiProviderRoutes } from "./interfaces/index.js";
|
|
4
|
-
export type { HttpClientFactory, RequestOptions } from "./types.js";
|
|
4
|
+
export type { HttpClientFactory, RequestOptions, StreamingRequestOptions } from "./types.js";
|
|
5
5
|
export * from "./errors/index.js";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/providers/coreApiProvider/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,YAAY,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC1F,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/providers/coreApiProvider/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,YAAY,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC1F,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAC7F,cAAc,mBAAmB,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TelemetryEvent, ValidatedResultEventData } from "@illalabs/interfaces";
|
|
1
2
|
import type { AxiosInstance, AxiosRequestConfig } from "axios";
|
|
2
3
|
/**
|
|
3
4
|
* Factory for constructing configured Axios clients.
|
|
@@ -12,5 +13,48 @@ export interface RequestOptions {
|
|
|
12
13
|
* Abort signal used to cancel the request
|
|
13
14
|
*/
|
|
14
15
|
readonly signal?: AbortSignal;
|
|
16
|
+
/**
|
|
17
|
+
* Callback invoked with the requestId after the request is initiated.
|
|
18
|
+
* This enables connecting to telemetry streams for real-time event updates.
|
|
19
|
+
* The callback is called asynchronously after the HTTP request starts.
|
|
20
|
+
*/
|
|
21
|
+
readonly onRequestId?: (requestId: string) => void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Options for streaming chat requests.
|
|
25
|
+
* Streaming mode sends telemetry events and the final result through a single SSE connection.
|
|
26
|
+
*/
|
|
27
|
+
export interface StreamingRequestOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Abort signal used to cancel the request
|
|
30
|
+
*/
|
|
31
|
+
readonly signal?: AbortSignal;
|
|
32
|
+
/**
|
|
33
|
+
* Callback invoked with the requestId after the request is initiated.
|
|
34
|
+
* Provides API consistency with the non-streaming sendMessage method.
|
|
35
|
+
* The callback is called synchronously before the fetch request starts.
|
|
36
|
+
*/
|
|
37
|
+
readonly onRequestId?: (requestId: string) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Called when a telemetry event is received during orchestration.
|
|
40
|
+
* Events are emitted in real-time as they occur on the server.
|
|
41
|
+
*/
|
|
42
|
+
readonly onEvent?: (event: TelemetryEvent) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Called when a text delta is received from the LLM.
|
|
45
|
+
* This enables real-time display of LLM-generated text as it streams in.
|
|
46
|
+
* @param delta - The text chunk received from the LLM
|
|
47
|
+
*/
|
|
48
|
+
readonly onTextDelta?: (delta: string) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Called when the orchestration completes successfully.
|
|
51
|
+
* The result contains the final chat response with messages, text, and pending tools.
|
|
52
|
+
* Type is inferred from resultEventDataSchema for compile-time safety.
|
|
53
|
+
*/
|
|
54
|
+
readonly onComplete?: (result: ValidatedResultEventData) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Called when an error occurs during streaming or orchestration.
|
|
57
|
+
*/
|
|
58
|
+
readonly onError?: (error: Error) => void;
|
|
15
59
|
}
|
|
16
60
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/providers/coreApiProvider/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAE/D;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,CAAC,EAAE,kBAAkB,KAAK,aAAa,CAAC;AAE/E;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/providers/coreApiProvider/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAE/D;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,CAAC,EAAE,kBAAkB,KAAK,aAAa,CAAC;AAE/E;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAE9B;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CACtD;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACpC;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAE9B;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAEnD;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAEnD;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAE/C;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,wBAAwB,KAAK,IAAI,CAAC;IAEjE;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAC7C"}
|
package/dist/src/sdk.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CoreApiChatErrorResponse, IllaToolErrorJSON, IllaToolOutcomeJSON, MessageHistoryType, ModelContext, PendingToolCallType, PersonalityContext, UserContext } from "@illalabs/interfaces";
|
|
2
|
-
import type { AsyncCheckerEvents, AsyncToolCheckerCheckParams, AwaitableActionDescriptor, AwaitActionResult, CacheEntryOptions, ChatContextSnapshot, ContextManagerOptions, CoreApiProviderConfig, CoreApiProviderRoutes, EventSubscription, HttpClientFactory, ICache, IContextManager, PollingConfig, SendMessageResult } from "./internal.js";
|
|
2
|
+
import type { AsyncCheckerEvents, AsyncToolCheckerCheckParams, AwaitableActionDescriptor, AwaitActionResult, CacheEntryOptions, ChatContextSnapshot, ContextManagerOptions, CoreApiProviderConfig, CoreApiProviderRoutes, EventSubscription, HttpClientFactory, ICache, IContextManager, PollingConfig, SendMessageResult, SendMessageStreamingOptions } from "./internal.js";
|
|
3
3
|
import { Chat, ContextManager, Prompt } from "./internal.js";
|
|
4
4
|
/**
|
|
5
5
|
* Configuration options for initializing the IllaSDK.
|
|
@@ -63,6 +63,17 @@ type SendMessageContext = {
|
|
|
63
63
|
chatId?: never;
|
|
64
64
|
userContext: UserContext;
|
|
65
65
|
};
|
|
66
|
+
/**
|
|
67
|
+
* Options for sending a message via the SDK.
|
|
68
|
+
*
|
|
69
|
+
* @property signal - Abort signal used to cancel the request
|
|
70
|
+
* @property onRequestId - Callback invoked with the requestId after the request is initiated,
|
|
71
|
+
* enabling real-time telemetry streaming
|
|
72
|
+
*/
|
|
73
|
+
type SdkSendMessageOptions = {
|
|
74
|
+
signal?: AbortSignal;
|
|
75
|
+
onRequestId?: (requestId: string) => void;
|
|
76
|
+
};
|
|
66
77
|
/**
|
|
67
78
|
* Metadata extracted from a SendMessageResult response.
|
|
68
79
|
* Provides detailed information about the response including errors, pending tools, and tool errors.
|
|
@@ -240,9 +251,57 @@ declare class IllaSDK {
|
|
|
240
251
|
* if (result2.response.pendingTools && result2.response.pendingTools.length > 0) {
|
|
241
252
|
* console.log("Tool to execute:", result2.response.pendingTools[0]);
|
|
242
253
|
* }
|
|
254
|
+
*
|
|
255
|
+
* // With telemetry callback for real-time events
|
|
256
|
+
* const result3 = await sdk.sendMessage(
|
|
257
|
+
* "Show me my balance",
|
|
258
|
+
* { chatId: result1.chatId },
|
|
259
|
+
* undefined,
|
|
260
|
+
* {
|
|
261
|
+
* onRequestId: (requestId) => {
|
|
262
|
+
* // Connect to telemetry stream
|
|
263
|
+
* telemetryClient.connect(requestId);
|
|
264
|
+
* }
|
|
265
|
+
* }
|
|
266
|
+
* );
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
sendMessage(msg: string | Prompt, context: SendMessageContext, chatOptions?: Omit<ChatOptions, "userContext">, options?: SdkSendMessageOptions): Promise<SendMessageResult>;
|
|
270
|
+
/**
|
|
271
|
+
* Sends a message with streaming response via SSE.
|
|
272
|
+
*
|
|
273
|
+
* Instead of waiting for the full response, this method streams telemetry events
|
|
274
|
+
* in real-time as they occur during orchestration. The final result is delivered
|
|
275
|
+
* through the `onComplete` callback.
|
|
276
|
+
*
|
|
277
|
+
* This eliminates the need for a separate telemetry subscription - events and
|
|
278
|
+
* the result are delivered through a single HTTP connection.
|
|
279
|
+
*
|
|
280
|
+
* @param msg - The message to send (can be a string or Prompt object)
|
|
281
|
+
* @param context - Context containing either chatId for existing chat or userContext for new chat
|
|
282
|
+
* @param options - Streaming options with event callbacks
|
|
283
|
+
* @param chatOptions - Optional chat configuration when creating a new chat
|
|
284
|
+
* @returns {Promise<void>} A promise that resolves when the stream ends
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* ```typescript
|
|
288
|
+
* const sdk = new IllaSDK({ apiKey: 'your-api-key' });
|
|
289
|
+
*
|
|
290
|
+
* await sdk.sendMessageStreaming(
|
|
291
|
+
* "What can you help me with?",
|
|
292
|
+
* { userContext: { address: "0x1234..." } },
|
|
293
|
+
* {
|
|
294
|
+
* onEvent: (event) => console.log('Event:', event.type),
|
|
295
|
+
* onComplete: (result) => {
|
|
296
|
+
* console.log('Response:', result.text);
|
|
297
|
+
* console.log('Pending tools:', result.pendingTools?.length ?? 0);
|
|
298
|
+
* },
|
|
299
|
+
* onError: (error) => console.error('Error:', error),
|
|
300
|
+
* }
|
|
301
|
+
* );
|
|
243
302
|
* ```
|
|
244
303
|
*/
|
|
245
|
-
|
|
304
|
+
sendMessageStreaming(msg: string | Prompt, context: SendMessageContext, options?: SendMessageStreamingOptions, chatOptions?: Omit<ChatOptions, "userContext">): Promise<void>;
|
|
246
305
|
/**
|
|
247
306
|
* Gets an existing chat or creates a new one if it doesn't exist.
|
|
248
307
|
*
|
|
@@ -510,6 +569,8 @@ export { ContextManager } from "./context/index.js";
|
|
|
510
569
|
export { AsyncToolChecker } from "./asyncToolChecker/index.js";
|
|
511
570
|
export { CoreApiProvider } from "./providers/index.js";
|
|
512
571
|
export { UserContextMissing } from "./chat/errors/index.js";
|
|
513
|
-
export
|
|
514
|
-
export
|
|
572
|
+
export { TelemetryClient, TelemetryStreamFailed, type TelemetryClientConfig, type TelemetryStreamState, } from "./telemetry/index.js";
|
|
573
|
+
export { parseSSEStream, SSEParse, StreamingHttpError, StreamingResponseBodyNull, StreamingServerError, type ErrorStreamEvent, type ResultStreamEvent, type SSEStreamEndEvent, type SSEStreamEvent, type StreamEventType, type TelemetryStreamEvent, } from "./streaming/index.js";
|
|
574
|
+
export type { illaSDKConfig, illaSDKOptions, ChatOptions, ChatContextSnapshot, CacheEntryOptions, ICache, IContextManager, SendMessageContext, SendMessageResult, SendMessageStreamingOptions, SdkSendMessageOptions, ResponseMetadata, AsyncCheckerEvents, AsyncToolCheckerCheckParams, AwaitableActionDescriptor, AwaitActionResult, CoreApiProviderConfig, CoreApiProviderRoutes, EventSubscription, HttpClientFactory, PollingConfig, ContextManagerOptions, };
|
|
575
|
+
export type { MessageHistoryType, IllaToolOutcomeJSON, IllaToolErrorJSON, UserContext, ModelContext, PersonalityContext, CoreApiChatErrorResponse, CoreApiChatSuccessResponse, PendingToolCallType, TelemetryEvent, TelemetryEventType, OrchestratorPhase, OrchestratorObserver, BaseTelemetryEvent, ToolResultStatus, TelemetryEnabledResponse, } from "@illalabs/interfaces";
|
|
515
576
|
//# sourceMappingURL=sdk.d.ts.map
|
package/dist/src/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,wBAAwB,EAGxB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACd,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EACR,kBAAkB,EAClB,2BAA2B,EAC3B,yBAAyB,EACzB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,MAAM,EACN,eAAe,EACf,aAAa,EACb,iBAAiB,
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,wBAAwB,EAGxB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACd,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EACR,kBAAkB,EAClB,2BAA2B,EAC3B,yBAAyB,EACzB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,MAAM,EACN,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,2BAA2B,EAC9B,MAAM,eAAe,CAAC;AAGvB,OAAO,EAEH,IAAI,EACJ,cAAc,EAGd,MAAM,EAET,MAAM,eAAe,CAAC;AAEvB;;;;;;;;;GASG;AACH,KAAK,aAAa,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,iBAA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GACxB,CAAC;AAGF,YAAY,EACR,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,wBAAwB,EACxB,0BAA0B,EAC1B,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,wBAAwB,GAC3B,MAAM,sBAAsB,CAAC"}
|
package/dist/src/sdk.js
CHANGED
|
@@ -205,12 +205,64 @@ class IllaSDK {
|
|
|
205
205
|
* if (result2.response.pendingTools && result2.response.pendingTools.length > 0) {
|
|
206
206
|
* console.log("Tool to execute:", result2.response.pendingTools[0]);
|
|
207
207
|
* }
|
|
208
|
+
*
|
|
209
|
+
* // With telemetry callback for real-time events
|
|
210
|
+
* const result3 = await sdk.sendMessage(
|
|
211
|
+
* "Show me my balance",
|
|
212
|
+
* { chatId: result1.chatId },
|
|
213
|
+
* undefined,
|
|
214
|
+
* {
|
|
215
|
+
* onRequestId: (requestId) => {
|
|
216
|
+
* // Connect to telemetry stream
|
|
217
|
+
* telemetryClient.connect(requestId);
|
|
218
|
+
* }
|
|
219
|
+
* }
|
|
220
|
+
* );
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
sendMessage(msg, context, chatOptions, options) {
|
|
224
|
+
const prompt = normalizePrompt(msg);
|
|
225
|
+
const chat = this.getOrCreateChat(context, chatOptions);
|
|
226
|
+
return chat.sendMessage(prompt, options);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Sends a message with streaming response via SSE.
|
|
230
|
+
*
|
|
231
|
+
* Instead of waiting for the full response, this method streams telemetry events
|
|
232
|
+
* in real-time as they occur during orchestration. The final result is delivered
|
|
233
|
+
* through the `onComplete` callback.
|
|
234
|
+
*
|
|
235
|
+
* This eliminates the need for a separate telemetry subscription - events and
|
|
236
|
+
* the result are delivered through a single HTTP connection.
|
|
237
|
+
*
|
|
238
|
+
* @param msg - The message to send (can be a string or Prompt object)
|
|
239
|
+
* @param context - Context containing either chatId for existing chat or userContext for new chat
|
|
240
|
+
* @param options - Streaming options with event callbacks
|
|
241
|
+
* @param chatOptions - Optional chat configuration when creating a new chat
|
|
242
|
+
* @returns {Promise<void>} A promise that resolves when the stream ends
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```typescript
|
|
246
|
+
* const sdk = new IllaSDK({ apiKey: 'your-api-key' });
|
|
247
|
+
*
|
|
248
|
+
* await sdk.sendMessageStreaming(
|
|
249
|
+
* "What can you help me with?",
|
|
250
|
+
* { userContext: { address: "0x1234..." } },
|
|
251
|
+
* {
|
|
252
|
+
* onEvent: (event) => console.log('Event:', event.type),
|
|
253
|
+
* onComplete: (result) => {
|
|
254
|
+
* console.log('Response:', result.text);
|
|
255
|
+
* console.log('Pending tools:', result.pendingTools?.length ?? 0);
|
|
256
|
+
* },
|
|
257
|
+
* onError: (error) => console.error('Error:', error),
|
|
258
|
+
* }
|
|
259
|
+
* );
|
|
208
260
|
* ```
|
|
209
261
|
*/
|
|
210
|
-
|
|
262
|
+
sendMessageStreaming(msg, context, options = {}, chatOptions) {
|
|
211
263
|
const prompt = normalizePrompt(msg);
|
|
212
264
|
const chat = this.getOrCreateChat(context, chatOptions);
|
|
213
|
-
return chat.
|
|
265
|
+
return chat.sendMessageStreaming(prompt, options);
|
|
214
266
|
}
|
|
215
267
|
/**
|
|
216
268
|
* Gets an existing chat or creates a new one if it doesn't exist.
|
|
@@ -282,7 +334,7 @@ class IllaSDK {
|
|
|
282
334
|
if (!this.chats.has(chatId)) {
|
|
283
335
|
throw new ChatNotFound(chatId);
|
|
284
336
|
}
|
|
285
|
-
return this.chats.get(chatId).sendMessage(new Prompt({ toolResult: [toolResult] }));
|
|
337
|
+
return this.chats.get(chatId).sendMessage([new Prompt({ toolResult: [toolResult] })]);
|
|
286
338
|
}
|
|
287
339
|
/**
|
|
288
340
|
* Gets the messages for a given chat ID.
|
|
@@ -405,7 +457,7 @@ class IllaSDK {
|
|
|
405
457
|
throw new SdkEmptyToolsResultsError({ chatId });
|
|
406
458
|
}
|
|
407
459
|
const chat = this.chats.get(chatId);
|
|
408
|
-
return await chat.sendMessage(new Prompt({ toolResult:
|
|
460
|
+
return await chat.sendMessage(toolResults.map((toolResult) => new Prompt({ toolResult: [toolResult] })));
|
|
409
461
|
}
|
|
410
462
|
/**
|
|
411
463
|
* Subscribes to status updates for a long-running tool execution.
|
|
@@ -571,4 +623,6 @@ export { ContextManager } from "./context/index.js";
|
|
|
571
623
|
export { AsyncToolChecker } from "./asyncToolChecker/index.js";
|
|
572
624
|
export { CoreApiProvider } from "./providers/index.js";
|
|
573
625
|
export { UserContextMissing } from "./chat/errors/index.js";
|
|
626
|
+
export { TelemetryClient, TelemetryStreamFailed, } from "./telemetry/index.js";
|
|
627
|
+
export { parseSSEStream, SSEParse, StreamingHttpError, StreamingResponseBodyNull, StreamingServerError, } from "./streaming/index.js";
|
|
574
628
|
//# sourceMappingURL=sdk.js.map
|
package/dist/src/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AA+BA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EACH,gBAAgB,EAChB,IAAI,EACJ,cAAc,EACd,eAAe,EACf,aAAa,EACb,MAAM,EACN,kBAAkB,GACrB,MAAM,eAAe,CAAC;AA2FvB;;;;;GAKG;AACH,MAAM,YAAa,SAAQ,KAAK;IAC5B;;OAEG;IACa,MAAM,CAAS;IAE/B;;;;;OAKG;IACH,YAAmB,MAAc,EAAE,OAAsB;QACrD,KAAK,CAAC,gBAAgB,MAAM,YAAY,EAAE,OAAO,C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,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EACH,eAAe,EACf,qBAAqB,GAGxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACH,cAAc,EACd,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,GAOvB,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when SSE parsing fails.
|
|
3
|
+
*
|
|
4
|
+
* This error is emitted when the SSE stream contains malformed data
|
|
5
|
+
* that cannot be parsed as valid JSON or event format.
|
|
6
|
+
*/
|
|
7
|
+
export declare class SSEParse extends Error {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new SSEParse error
|
|
10
|
+
* @param message - Description of the parse error
|
|
11
|
+
* @param cause - Optional underlying error that caused the parse failure
|
|
12
|
+
*/
|
|
13
|
+
constructor(message: string, cause?: unknown);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=SSEParse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SSEParse.d.ts","sourceRoot":"","sources":["../../../../src/streaming/errors/SSEParse.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,QAAS,SAAQ,KAAK;IAC/B;;;;OAIG;gBACS,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAW/C"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when SSE parsing fails.
|
|
3
|
+
*
|
|
4
|
+
* This error is emitted when the SSE stream contains malformed data
|
|
5
|
+
* that cannot be parsed as valid JSON or event format.
|
|
6
|
+
*/
|
|
7
|
+
export class SSEParse extends Error {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new SSEParse error
|
|
10
|
+
* @param message - Description of the parse error
|
|
11
|
+
* @param cause - Optional underlying error that caused the parse failure
|
|
12
|
+
*/
|
|
13
|
+
constructor(message, cause) {
|
|
14
|
+
super(`SSE parse error: ${message}`, { cause });
|
|
15
|
+
this.name = "SSEParse";
|
|
16
|
+
// Restore the prototype chain for proper Error subclassing in TypeScript
|
|
17
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
18
|
+
if (Error.captureStackTrace) {
|
|
19
|
+
Error.captureStackTrace(this, SSEParse);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=SSEParse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SSEParse.js","sourceRoot":"","sources":["../../../../src/streaming/errors/SSEParse.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IAC/B;;;;OAIG;IACH,YAAY,OAAe,EAAE,KAAe;QACxC,KAAK,CAAC,oBAAoB,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QAEvB,yEAAyE;QACzE,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAElD,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC1B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC5C,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when the streaming request receives an HTTP error response.
|
|
3
|
+
*
|
|
4
|
+
* This error captures the HTTP status code and error message from the server.
|
|
5
|
+
*/
|
|
6
|
+
export declare class StreamingHttpError extends Error {
|
|
7
|
+
/**
|
|
8
|
+
* The HTTP status code from the failed request.
|
|
9
|
+
*/
|
|
10
|
+
readonly statusCode: number;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new StreamingHttpError.
|
|
13
|
+
* @param statusCode - The HTTP status code from the response
|
|
14
|
+
* @param message - The error message from the server or a default message
|
|
15
|
+
*/
|
|
16
|
+
constructor(statusCode: number, message: string);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=StreamingHttpError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StreamingHttpError.d.ts","sourceRoot":"","sources":["../../../../src/streaming/errors/StreamingHttpError.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IACzC;;OAEG;IACH,SAAgB,UAAU,EAAE,MAAM,CAAC;IAEnC;;;;OAIG;gBACS,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAYlD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when the streaming request receives an HTTP error response.
|
|
3
|
+
*
|
|
4
|
+
* This error captures the HTTP status code and error message from the server.
|
|
5
|
+
*/
|
|
6
|
+
export class StreamingHttpError extends Error {
|
|
7
|
+
/**
|
|
8
|
+
* The HTTP status code from the failed request.
|
|
9
|
+
*/
|
|
10
|
+
statusCode;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new StreamingHttpError.
|
|
13
|
+
* @param statusCode - The HTTP status code from the response
|
|
14
|
+
* @param message - The error message from the server or a default message
|
|
15
|
+
*/
|
|
16
|
+
constructor(statusCode, message) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.name = "StreamingHttpError";
|
|
19
|
+
this.statusCode = statusCode;
|
|
20
|
+
// Restore the prototype chain for proper Error subclassing in TypeScript
|
|
21
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
22
|
+
if (Error.captureStackTrace) {
|
|
23
|
+
Error.captureStackTrace(this, StreamingHttpError);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=StreamingHttpError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StreamingHttpError.js","sourceRoot":"","sources":["../../../../src/streaming/errors/StreamingHttpError.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IACzC;;OAEG;IACa,UAAU,CAAS;IAEnC;;;;OAIG;IACH,YAAY,UAAkB,EAAE,OAAe;QAC3C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAE7B,yEAAyE;QACzE,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAElD,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC1B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;QACtD,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when the streaming response body is null.
|
|
3
|
+
*
|
|
4
|
+
* This typically indicates the server did not return a streaming response
|
|
5
|
+
* when one was expected.
|
|
6
|
+
*/
|
|
7
|
+
export declare class StreamingResponseBodyNull extends Error {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new StreamingResponseBodyNull error.
|
|
10
|
+
*/
|
|
11
|
+
constructor();
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=StreamingResponseBodyNull.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StreamingResponseBodyNull.d.ts","sourceRoot":"","sources":["../../../../src/streaming/errors/StreamingResponseBodyNull.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;IAChD;;OAEG;;CAYN"}
|