@illalabs/sdk 0.4.0-canary.2110efe9 → 0.4.0-canary.2c2d50f5
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 +68 -9
- 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 +87 -28
- package/dist/src/chat/Chat.js.map +1 -1
- package/dist/src/chat/utils/prompt.d.ts.map +1 -1
- package/dist/src/chat/utils/prompt.js +0 -1
- package/dist/src/chat/utils/prompt.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/Prompt.d.ts +2 -10
- package/dist/src/prompt/Prompt.d.ts.map +1 -1
- package/dist/src/prompt/Prompt.js +9 -22
- package/dist/src/prompt/Prompt.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/prompt/types.d.ts +7 -9
- package/dist/src/prompt/types.d.ts.map +1 -1
- package/dist/src/prompt/utils/cloneToolResult.d.ts +6 -6
- package/dist/src/prompt/utils/cloneToolResult.d.ts.map +1 -1
- package/dist/src/prompt/utils/cloneToolResult.js +11 -16
- package/dist/src/prompt/utils/cloneToolResult.js.map +1 -1
- package/dist/src/prompt/utils/index.d.ts +1 -3
- package/dist/src/prompt/utils/index.d.ts.map +1 -1
- package/dist/src/prompt/utils/index.js +1 -3
- package/dist/src/prompt/utils/index.js.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 +102 -28
- package/dist/src/sdk.d.ts.map +1 -1
- package/dist/src/sdk.js +90 -23
- 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
- package/dist/src/prompt/utils/normalizeTextPrompt.d.ts +0 -14
- package/dist/src/prompt/utils/normalizeTextPrompt.d.ts.map +0 -1
- package/dist/src/prompt/utils/normalizeTextPrompt.js +0 -22
- package/dist/src/prompt/utils/normalizeTextPrompt.js.map +0 -1
- package/dist/src/prompt/utils/normalizeToolResult.d.ts +0 -14
- package/dist/src/prompt/utils/normalizeToolResult.d.ts.map +0 -1
- package/dist/src/prompt/utils/normalizeToolResult.js +0 -27
- package/dist/src/prompt/utils/normalizeToolResult.js.map +0 -1
package/README.md
CHANGED
|
@@ -52,6 +52,8 @@ const result2 = await sdk.sendMessage("I want to swap 1 ETH for USDC on Base", {
|
|
|
52
52
|
When the AI needs to execute blockchain operations, it will return pending tools:
|
|
53
53
|
|
|
54
54
|
```typescript
|
|
55
|
+
import { IllaToolError, IllaToolOutcome } from "@illalabs/interfaces";
|
|
56
|
+
|
|
55
57
|
const result = await sdk.sendMessage("Swap 1 ETH for USDC on Base", {
|
|
56
58
|
userContext: { address: "0x..." },
|
|
57
59
|
});
|
|
@@ -60,17 +62,21 @@ const result = await sdk.sendMessage("Swap 1 ETH for USDC on Base", {
|
|
|
60
62
|
if (result.response.pendingTools && result.response.pendingTools.length > 0) {
|
|
61
63
|
const tool = result.response.pendingTools[0];
|
|
62
64
|
|
|
63
|
-
// Execute the tool
|
|
64
|
-
|
|
65
|
+
// Execute the tool and create the outcome
|
|
66
|
+
let toolResult: IllaToolOutcome;
|
|
67
|
+
try {
|
|
68
|
+
const executionResult = await executeTool(tool);
|
|
69
|
+
toolResult = IllaToolOutcome.success(tool.toolCallId, tool.toolName, executionResult);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
toolResult = IllaToolOutcome.error(
|
|
72
|
+
tool.toolCallId,
|
|
73
|
+
tool.toolName,
|
|
74
|
+
IllaToolError.execution(tool.toolCallId, tool.toolName, error.message),
|
|
75
|
+
);
|
|
76
|
+
}
|
|
65
77
|
|
|
66
78
|
// Send the result back to the AI
|
|
67
|
-
const
|
|
68
|
-
toolCallId: tool.toolCallId,
|
|
69
|
-
toolName: tool.toolName,
|
|
70
|
-
result: executionResult,
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const followUp = await sdk.sendToolResult(result.chatId, toolResult);
|
|
79
|
+
const followUp = await sdk.sendToolResult(result.chatId, toolResult.toJSON());
|
|
74
80
|
console.log(followUp.response.text);
|
|
75
81
|
}
|
|
76
82
|
```
|
|
@@ -225,9 +231,62 @@ E2E_API_KEY=your-api-key E2E_FORK_BASE_RPC_URL="https://mainnet.base.org" pnpm t
|
|
|
225
231
|
- **Multi-turn Conversations**: Seamless context preservation across messages
|
|
226
232
|
- **Session Persistence**: Resume conversations across different instances
|
|
227
233
|
- **Async Tool Monitoring**: Built-in support for long-running blockchain operations
|
|
234
|
+
- **Streaming Responses**: Real-time telemetry and text streaming via SSE
|
|
228
235
|
- **TypeScript-first**: Full type safety with comprehensive type definitions
|
|
229
236
|
- **Flexible Caching**: Pluggable cache implementations (in-memory, Redis, etc.)
|
|
230
237
|
|
|
238
|
+
## Streaming
|
|
239
|
+
|
|
240
|
+
The SDK supports streaming responses via Server-Sent Events (SSE). This allows you to receive telemetry events and text in real-time as the AI processes your request.
|
|
241
|
+
|
|
242
|
+
### Required Header
|
|
243
|
+
|
|
244
|
+
To enable streaming, the request must include the `Accept: text/event-stream` header. The SDK handles this automatically when using the streaming methods.
|
|
245
|
+
|
|
246
|
+
### Usage
|
|
247
|
+
|
|
248
|
+
```typescript
|
|
249
|
+
import { IllaSDK, Prompt } from "@illalabs/sdk";
|
|
250
|
+
|
|
251
|
+
const sdk = new IllaSDK({ apiKey: "your-api-key" });
|
|
252
|
+
const chat = sdk.createChat({ userContext: { address: "0x..." } });
|
|
253
|
+
|
|
254
|
+
await chat.sendMessageStreaming(new Prompt({ text: "What is my balance?" }), {
|
|
255
|
+
// Called for each telemetry event (including text_delta for streaming text)
|
|
256
|
+
onEvent: (event) => {
|
|
257
|
+
console.log("Event:", event.type);
|
|
258
|
+
},
|
|
259
|
+
// Called specifically for text chunks as they arrive
|
|
260
|
+
onTextDelta: (delta) => {
|
|
261
|
+
process.stdout.write(delta);
|
|
262
|
+
},
|
|
263
|
+
// Called when the complete response is ready
|
|
264
|
+
onComplete: (result) => {
|
|
265
|
+
console.log("\nComplete:", result.text);
|
|
266
|
+
},
|
|
267
|
+
// Called if an error occurs during streaming
|
|
268
|
+
onError: (error) => {
|
|
269
|
+
console.error("Error:", error.message);
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Direct Provider Usage
|
|
275
|
+
|
|
276
|
+
When using `CoreApiProvider` directly with fetch, include the header manually:
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
const response = await fetch(url, {
|
|
280
|
+
method: "POST",
|
|
281
|
+
headers: {
|
|
282
|
+
"Content-Type": "application/json",
|
|
283
|
+
Accept: "text/event-stream", // Required for streaming
|
|
284
|
+
"x-api-key": "your-api-key",
|
|
285
|
+
},
|
|
286
|
+
body: stringify(requestBody),
|
|
287
|
+
});
|
|
288
|
+
```
|
|
289
|
+
|
|
231
290
|
## 📦 Project Structure
|
|
232
291
|
|
|
233
292
|
```plaintext
|
package/dist/src/chat/Chat.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MessageHistoryType } from "@illalabs/interfaces";
|
|
2
2
|
import type { AwaitableActionDescriptor, AwaitActionResult } from "../asyncToolChecker/index.js";
|
|
3
|
-
import type { ChatContextSnapshot, ChatOptions, SendMessageResult } from "../interfaces/index.js";
|
|
3
|
+
import type { ChatContextSnapshot, ChatOptions, SendMessageOptions, SendMessageResult, SendMessageStreamingOptions } from "../interfaces/index.js";
|
|
4
4
|
import type { Prompt } from "../prompt/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Represents a conversational session with the Illa Core API.
|
|
@@ -33,13 +33,42 @@ export declare class Chat {
|
|
|
33
33
|
* Sends a prompt or array of prompts to the Core API and returns the processed result.
|
|
34
34
|
*
|
|
35
35
|
* @param prompt Either a single Prompt instance (must be kind "text") or an array of Prompts (all must be kind "tool-result").
|
|
36
|
+
* @param options Optional request options including abort signal and telemetry callback.
|
|
36
37
|
*
|
|
37
38
|
* @throws {ChatInvalidSinglePromptKind} When a single prompt is provided but is not of kind "text".
|
|
38
39
|
* @throws {ChatInvalidMultiplePromptsKind} When an array of prompts is provided but not all are of kind "tool-result".
|
|
39
40
|
*
|
|
40
41
|
* @returns Structured chat result containing the processed response.
|
|
41
42
|
*/
|
|
42
|
-
sendMessage(prompt: Prompt | Prompt[]): Promise<SendMessageResult>;
|
|
43
|
+
sendMessage(prompt: Prompt | Prompt[], options?: SendMessageOptions): Promise<SendMessageResult>;
|
|
44
|
+
/**
|
|
45
|
+
* Sends a message with streaming response via SSE.
|
|
46
|
+
*
|
|
47
|
+
* Instead of waiting for the full response, this method streams telemetry events
|
|
48
|
+
* in real-time as they occur during orchestration. The final result is delivered
|
|
49
|
+
* through the `onComplete` callback.
|
|
50
|
+
*
|
|
51
|
+
* This eliminates the need for a separate telemetry subscription - events and
|
|
52
|
+
* the result are delivered through a single HTTP connection.
|
|
53
|
+
*
|
|
54
|
+
* @param prompt A single Prompt instance of kind "text".
|
|
55
|
+
* @param options Streaming options with event callbacks.
|
|
56
|
+
*
|
|
57
|
+
* @throws {ChatInvalidSinglePromptKind} When the prompt is not of kind "text".
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* await chat.sendMessageStreaming(
|
|
62
|
+
* new Prompt({ text: "Show me my balance" }),
|
|
63
|
+
* {
|
|
64
|
+
* onEvent: (event) => console.log('Event:', event.type),
|
|
65
|
+
* onComplete: (result) => console.log('Done:', result.text),
|
|
66
|
+
* onError: (error) => console.error('Error:', error),
|
|
67
|
+
* }
|
|
68
|
+
* );
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
sendMessageStreaming(prompt: Prompt, options?: SendMessageStreamingOptions): Promise<void>;
|
|
43
72
|
private buildRequest;
|
|
44
73
|
private static isSuccessResponse;
|
|
45
74
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../src/chat/Chat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIR,kBAAkB,EAKrB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAER,yBAAyB,EACzB,iBAAiB,EACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EACR,mBAAmB,EACnB,WAAW,EAGX,iBAAiB,
|
|
1
|
+
{"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../src/chat/Chat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIR,kBAAkB,EAKrB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAER,yBAAyB,EACzB,iBAAiB,EACpB,MAAM,8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AIvD;;;;OAIG;IACU,UAAU,CAAC,QAAQ,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;CAIxE"}
|
package/dist/src/chat/Chat.js
CHANGED
|
@@ -50,13 +50,14 @@ export class Chat {
|
|
|
50
50
|
* Sends a prompt or array of prompts to the Core API and returns the processed result.
|
|
51
51
|
*
|
|
52
52
|
* @param prompt Either a single Prompt instance (must be kind "text") or an array of Prompts (all must be kind "tool-result").
|
|
53
|
+
* @param options Optional request options including abort signal and telemetry callback.
|
|
53
54
|
*
|
|
54
55
|
* @throws {ChatInvalidSinglePromptKind} When a single prompt is provided but is not of kind "text".
|
|
55
56
|
* @throws {ChatInvalidMultiplePromptsKind} When an array of prompts is provided but not all are of kind "tool-result".
|
|
56
57
|
*
|
|
57
58
|
* @returns Structured chat result containing the processed response.
|
|
58
59
|
*/
|
|
59
|
-
async sendMessage(prompt) {
|
|
60
|
+
async sendMessage(prompt, options) {
|
|
60
61
|
// Validate prompt kinds based on single vs array
|
|
61
62
|
const isMulti = Array.isArray(prompt);
|
|
62
63
|
const prompts = isMulti ? prompt : [prompt];
|
|
@@ -78,21 +79,32 @@ export class Chat {
|
|
|
78
79
|
});
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
|
-
const normalizedPromptsArray = prompts.map((p) => p.getNormalizedSnapshot(
|
|
82
|
+
const normalizedPromptsArray = prompts.map((p) => p.getNormalizedSnapshot());
|
|
82
83
|
const promptSnapshot = isMulti ? snapshots : snapshots[0];
|
|
83
|
-
|
|
84
|
-
if (!promptSnapshot || !normalizedPrompts) {
|
|
84
|
+
if (!promptSnapshot || normalizedPromptsArray.length === 0) {
|
|
85
85
|
throw new ChatInvalidPromptSnapshot({
|
|
86
86
|
chatId: this.id,
|
|
87
|
-
snapshot: promptSnapshot,
|
|
87
|
+
snapshot: promptSnapshot ?? [],
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
const originalContext = await this.contextManager.getContext(this.id);
|
|
91
|
-
const { body, messages: stagedMessages } = this.buildRequest(originalContext,
|
|
92
|
-
|
|
91
|
+
const { body, messages: stagedMessages } = this.buildRequest(originalContext, normalizedPromptsArray);
|
|
92
|
+
// Track requestId for the result
|
|
93
|
+
let capturedRequestId;
|
|
94
|
+
const requestOptions = options
|
|
95
|
+
? {
|
|
96
|
+
signal: options.signal,
|
|
97
|
+
onRequestId: (id) => {
|
|
98
|
+
capturedRequestId = id;
|
|
99
|
+
options.onRequestId?.(id);
|
|
100
|
+
},
|
|
101
|
+
}
|
|
102
|
+
: undefined;
|
|
103
|
+
const response = await this.coreApiProvider.sendMessage(body, requestOptions);
|
|
93
104
|
if (!Chat.isSuccessResponse(response)) {
|
|
94
105
|
return {
|
|
95
106
|
chatId: this.id,
|
|
107
|
+
requestId: capturedRequestId,
|
|
96
108
|
prompt: body.prompt,
|
|
97
109
|
promptSnapshot,
|
|
98
110
|
messages: stagedMessages,
|
|
@@ -107,6 +119,7 @@ export class Chat {
|
|
|
107
119
|
await this.contextManager.setToolsConfig(this.id, originalContext.toolsConfig);
|
|
108
120
|
return {
|
|
109
121
|
chatId: this.id,
|
|
122
|
+
requestId: response.requestId ?? capturedRequestId,
|
|
110
123
|
prompt: body.prompt,
|
|
111
124
|
promptSnapshot,
|
|
112
125
|
messages: response.messages,
|
|
@@ -117,6 +130,64 @@ export class Chat {
|
|
|
117
130
|
},
|
|
118
131
|
};
|
|
119
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Sends a message with streaming response via SSE.
|
|
135
|
+
*
|
|
136
|
+
* Instead of waiting for the full response, this method streams telemetry events
|
|
137
|
+
* in real-time as they occur during orchestration. The final result is delivered
|
|
138
|
+
* through the `onComplete` callback.
|
|
139
|
+
*
|
|
140
|
+
* This eliminates the need for a separate telemetry subscription - events and
|
|
141
|
+
* the result are delivered through a single HTTP connection.
|
|
142
|
+
*
|
|
143
|
+
* @param prompt A single Prompt instance of kind "text".
|
|
144
|
+
* @param options Streaming options with event callbacks.
|
|
145
|
+
*
|
|
146
|
+
* @throws {ChatInvalidSinglePromptKind} When the prompt is not of kind "text".
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```typescript
|
|
150
|
+
* await chat.sendMessageStreaming(
|
|
151
|
+
* new Prompt({ text: "Show me my balance" }),
|
|
152
|
+
* {
|
|
153
|
+
* onEvent: (event) => console.log('Event:', event.type),
|
|
154
|
+
* onComplete: (result) => console.log('Done:', result.text),
|
|
155
|
+
* onError: (error) => console.error('Error:', error),
|
|
156
|
+
* }
|
|
157
|
+
* );
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
async sendMessageStreaming(prompt, options = {}) {
|
|
161
|
+
const snapshot = prompt.getSnapshot();
|
|
162
|
+
if (snapshot.kind !== "text") {
|
|
163
|
+
throw new ChatInvalidSinglePromptKind({
|
|
164
|
+
chatId: this.id,
|
|
165
|
+
kind: snapshot.kind,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
const normalizedPrompt = [prompt.getNormalizedSnapshot()];
|
|
169
|
+
const context = await this.contextManager.getContext(this.id);
|
|
170
|
+
const { body } = this.buildRequest(context, normalizedPrompt);
|
|
171
|
+
await this.coreApiProvider.sendMessageStreaming(body, {
|
|
172
|
+
signal: options.signal,
|
|
173
|
+
onEvent: options.onEvent,
|
|
174
|
+
onTextDelta: options.onTextDelta,
|
|
175
|
+
onComplete: (result) => {
|
|
176
|
+
void (async () => {
|
|
177
|
+
try {
|
|
178
|
+
await this.contextManager.setMessages(this.id, result.messages);
|
|
179
|
+
await this.contextManager.setToolsConfig(this.id, context.toolsConfig);
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
options.onError?.(error instanceof Error ? error : new Error(String(error)));
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
options.onComplete?.(result);
|
|
186
|
+
})();
|
|
187
|
+
},
|
|
188
|
+
onError: options.onError,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
120
191
|
buildRequest(context, normalizedPrompt) {
|
|
121
192
|
const baseBodyRequest = {
|
|
122
193
|
body: {
|
|
@@ -129,32 +200,20 @@ export class Chat {
|
|
|
129
200
|
messages: context.messages,
|
|
130
201
|
toolsConfig: context.toolsConfig,
|
|
131
202
|
};
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
prompt: normalizedPrompt.kind === "text" ? normalizedPrompt.message : undefined,
|
|
139
|
-
},
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
// Handle array of prompts (all tool-results)
|
|
143
|
-
const toolResults = normalizedPrompt.map((p) => {
|
|
144
|
-
if (p.kind === "tool-result") {
|
|
145
|
-
return p.prompt;
|
|
203
|
+
const textPrompt = normalizedPrompt.find((p) => p.type === "text");
|
|
204
|
+
const toolResultPrompts = normalizedPrompt.filter((p) => p.type === "tool-result");
|
|
205
|
+
const promptValue = textPrompt
|
|
206
|
+
? {
|
|
207
|
+
role: "user",
|
|
208
|
+
content: [{ type: "text", text: textPrompt.text }],
|
|
146
209
|
}
|
|
147
|
-
|
|
148
|
-
throw new ChatInvalidMultiplePromptsKind({
|
|
149
|
-
chatId: this.id,
|
|
150
|
-
kind: p.kind,
|
|
151
|
-
});
|
|
152
|
-
});
|
|
210
|
+
: undefined;
|
|
153
211
|
return {
|
|
154
212
|
...baseBodyRequest,
|
|
155
213
|
body: {
|
|
156
214
|
...baseBodyRequest.body,
|
|
157
|
-
toolResults,
|
|
215
|
+
toolResults: toolResultPrompts.flatMap((p) => p.toolResults),
|
|
216
|
+
prompt: promptValue,
|
|
158
217
|
},
|
|
159
218
|
};
|
|
160
219
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.js","sourceRoot":"","sources":["../../../src/chat/Chat.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Chat.js","sourceRoot":"","sources":["../../../src/chat/Chat.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,+BA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,KAAK,CAAC,UAAU;QACnB,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACnD,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,UAAU,CAAC,QAA6B;QACjD,MAAM,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAClE,MAAM,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC5E,CAAC;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../../src/chat/utils/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,eAAO,MAAM,eAAe,QAAS,MAAM,GAAG,MAAM,KAAG,
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../../src/chat/utils/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,eAAO,MAAM,eAAe,QAAS,MAAM,GAAG,MAAM,KAAG,MAEtD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../../src/chat/utils/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAoB,EAAU,EAAE;IAC5D,OAAO,
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../../src/chat/utils/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAoB,EAAU,EAAE;IAC5D,OAAO,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AACrE,CAAC,CAAC"}
|
|
@@ -4,7 +4,7 @@ const cloneMessageContent = (content) => {
|
|
|
4
4
|
if (typeof content === "string") {
|
|
5
5
|
return content;
|
|
6
6
|
}
|
|
7
|
-
return content
|
|
7
|
+
return structuredClone(content);
|
|
8
8
|
};
|
|
9
9
|
const cloneMessages = (messages) => messages.map((message) => ({
|
|
10
10
|
...message,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextManager.js","sourceRoot":"","sources":["../../../src/context/ContextManager.ts"],"names":[],"mappings":"AAWA,MAAM,cAAc,GAAG,cAAuB,CAAC;AAC/C,MAAM,oBAAoB,GAA0B,EAAE,CAAC;AAEvD,MAAM,mBAAmB,GAAG,CAAC,OAAuB,EAAkB,EAAE;IACpE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,OAAO,
|
|
1
|
+
{"version":3,"file":"ContextManager.js","sourceRoot":"","sources":["../../../src/context/ContextManager.ts"],"names":[],"mappings":"AAWA,MAAM,cAAc,GAAG,cAAuB,CAAC;AAC/C,MAAM,oBAAoB,GAA0B,EAAE,CAAC;AAEvD,MAAM,mBAAmB,GAAG,CAAC,OAAuB,EAAkB,EAAE;IACpE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,OAAO,eAAe,CAAC,OAAO,CAAC,CAAC;AACpC,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,QAA4B,EAAsB,EAAE,CACvE,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACvB,GAAG,OAAO;IACV,OAA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AC,UAAU,CAAC,MAAc;QACnC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAgB,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;QAE/E,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO;gBACH,QAAQ,EAAE,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC;gBACtD,WAAW,EAAE,gBAAgB,CAAC,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC;aAClE,CAAC;QACN,CAAC;QAED,OAAO;YACH,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC;YACxC,WAAW,EAAE,gBAAgB,CAAC,MAAM,CAAC,WAAW,CAAC;SACpD,CAAC;IACN,CAAC;IAEO,KAAK,CAAC,WAAW,CAAC,MAAc,EAAE,MAAqB;QAC3D,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACrF,CAAC;IAEO,aAAa,CAAC,MAAc;QAChC,OAAO,GAAG,IAAI,CAAC,MAAM,IAAI,MAAM,EAAE,CAAC;IACtC,CAAC;CACJ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CoreApiChatBodyRequest, CoreApiChatErrorResponse, CoreApiChatSuccessResponse, MessageHistoryType, ModelContext, PersonalityContext, ToolAutorouterRequest, UserContext } from "@illalabs/interfaces";
|
|
1
|
+
import type { CoreApiChatBodyRequest, CoreApiChatErrorResponse, CoreApiChatSuccessResponse, MessageHistoryType, ModelContext, PersonalityContext, TelemetryEvent, ToolAutorouterRequest, UserContext, ValidatedResultEventData } from "@illalabs/interfaces";
|
|
2
2
|
import type { AsyncToolChecker } from "../asyncToolChecker/index.js";
|
|
3
3
|
import type { PromptRole, PromptSnapshot } from "../prompt/index.js";
|
|
4
4
|
import type { IContextManager } from "./contextManager.interface.js";
|
|
@@ -43,6 +43,52 @@ export interface ChatOptions {
|
|
|
43
43
|
*/
|
|
44
44
|
readonly personalityContext?: PersonalityContext;
|
|
45
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Options for sending a message through the chat instance.
|
|
48
|
+
*/
|
|
49
|
+
export interface SendMessageOptions {
|
|
50
|
+
/**
|
|
51
|
+
* Abort signal used to cancel the request.
|
|
52
|
+
*/
|
|
53
|
+
readonly signal?: AbortSignal;
|
|
54
|
+
/**
|
|
55
|
+
* Callback invoked with the requestId after the request is initiated.
|
|
56
|
+
* This enables connecting to telemetry streams for real-time event updates.
|
|
57
|
+
*/
|
|
58
|
+
readonly onRequestId?: (requestId: string) => void;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Options for streaming message responses.
|
|
62
|
+
* Streaming delivers telemetry events in real-time followed by the final result,
|
|
63
|
+
* eliminating the need for a separate telemetry subscription.
|
|
64
|
+
*/
|
|
65
|
+
export interface SendMessageStreamingOptions {
|
|
66
|
+
/**
|
|
67
|
+
* Abort signal used to cancel the request.
|
|
68
|
+
*/
|
|
69
|
+
readonly signal?: AbortSignal;
|
|
70
|
+
/**
|
|
71
|
+
* Called when a telemetry event is received during orchestration.
|
|
72
|
+
* Events are emitted in real-time as they occur on the server.
|
|
73
|
+
*/
|
|
74
|
+
readonly onEvent?: (event: TelemetryEvent) => void;
|
|
75
|
+
/**
|
|
76
|
+
* Called when a text delta is received from the LLM.
|
|
77
|
+
* This enables real-time display of LLM-generated text as it streams in.
|
|
78
|
+
* @param delta - The text chunk received from the LLM
|
|
79
|
+
*/
|
|
80
|
+
readonly onTextDelta?: (delta: string) => void;
|
|
81
|
+
/**
|
|
82
|
+
* Called when the orchestration completes successfully.
|
|
83
|
+
* The result contains the final chat response with messages, text, and pending tools.
|
|
84
|
+
* Type is inferred from resultEventDataSchema for compile-time safety.
|
|
85
|
+
*/
|
|
86
|
+
readonly onComplete?: (result: ValidatedResultEventData) => void;
|
|
87
|
+
/**
|
|
88
|
+
* Called when an error occurs during streaming or orchestration.
|
|
89
|
+
*/
|
|
90
|
+
readonly onError?: (error: Error) => void;
|
|
91
|
+
}
|
|
46
92
|
/**
|
|
47
93
|
* Result returned when sending a message through the chat instance.
|
|
48
94
|
*/
|
|
@@ -51,6 +97,11 @@ export interface SendMessageResult {
|
|
|
51
97
|
* Identifier of the chat instance that processed the message.
|
|
52
98
|
*/
|
|
53
99
|
readonly chatId: string;
|
|
100
|
+
/**
|
|
101
|
+
* Request ID used for telemetry subscription.
|
|
102
|
+
* This ID can be used to connect to the telemetry stream for real-time events.
|
|
103
|
+
*/
|
|
104
|
+
readonly requestId?: string;
|
|
54
105
|
/**
|
|
55
106
|
* The prompt that was sent to the Core API.
|
|
56
107
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.interface.d.ts","sourceRoot":"","sources":["../../../src/interfaces/chat.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,sBAAsB,EACtB,wBAAwB,EACxB,0BAA0B,EAC1B,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EACrB,WAAW,
|
|
1
|
+
{"version":3,"file":"chat.interface.d.ts","sourceRoot":"","sources":["../../../src/interfaces/chat.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,sBAAsB,EACtB,wBAAwB,EACxB,0BAA0B,EAC1B,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,WAAW,EACX,wBAAwB,EAC3B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,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C7C;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAC,QAAQ,CAAC,CAAC;IAElD;;;OAGG;IACH,QAAQ,CAAC,cAAc,EAAE,cAAc,GAAG,cAAc,EAAE,CAAC;IAE3D;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IAEtC;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,qBAAqB,CAAC;IAE5C;;OAEG;IACH,QAAQ,CAAC,QAAQ,EACX;QACI,QAAQ,CAAC,IAAI,EAAE,0BAA0B,CAAC;QAC1C,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC;KAC3B,GACD;QACI,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;QACvB,QAAQ,CAAC,KAAK,EAAE,wBAAwB,CAAC;KAC5C,CAAC;CACX;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IAEtC;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,qBAAqB,CAAC;IAE5C;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;CACrC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CoreApiChatRequest, CoreApiChatResponse, LongPollingActionRequest, LongPollingActionResponse } from "@illalabs/interfaces";
|
|
2
|
-
import type { CoreApiProviderRoutes, RequestOptions } from "../providers/coreApiProvider/index.js";
|
|
2
|
+
import type { CoreApiProviderRoutes, RequestOptions, StreamingRequestOptions } from "../providers/coreApiProvider/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Contract for the Core API provider
|
|
5
5
|
*/
|
|
@@ -13,6 +13,18 @@ export interface ICoreApiProvider {
|
|
|
13
13
|
* @returns Core API chat response
|
|
14
14
|
*/
|
|
15
15
|
sendMessage(request: CoreApiChatRequest["body"], options?: RequestOptions): Promise<CoreApiChatResponse>;
|
|
16
|
+
/**
|
|
17
|
+
* Sends a chat request with streaming response via SSE.
|
|
18
|
+
*
|
|
19
|
+
* Instead of waiting for the full response, this method streams telemetry events
|
|
20
|
+
* in real-time as they occur during orchestration. The final result is delivered
|
|
21
|
+
* through the `onComplete` callback.
|
|
22
|
+
*
|
|
23
|
+
* @param request Chat request payload
|
|
24
|
+
* @param options Streaming options with event callbacks
|
|
25
|
+
* @returns A promise that resolves when the stream ends
|
|
26
|
+
*/
|
|
27
|
+
sendMessageStreaming(request: CoreApiChatRequest["body"], options?: StreamingRequestOptions): Promise<void>;
|
|
16
28
|
/**
|
|
17
29
|
* Checks the status of a long running action
|
|
18
30
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coreApiProvider.interface.d.ts","sourceRoot":"","sources":["../../../src/interfaces/coreApiProvider.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EAC5B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"coreApiProvider.interface.d.ts","sourceRoot":"","sources":["../../../src/interfaces/coreApiProvider.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EAC5B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EACR,qBAAqB,EACrB,cAAc,EACd,uBAAuB,EAC1B,MAAM,uCAAuC,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B;;;;;;;OAOG;IACH,WAAW,CACP,OAAO,EAAE,kBAAkB,CAAC,MAAM,CAAC,EACnC,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAEhC;;;;;;;;;;OAUG;IACH,oBAAoB,CAChB,OAAO,EAAE,kBAAkB,CAAC,MAAM,CAAC,EACnC,OAAO,CAAC,EAAE,uBAAuB,GAClC,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB;;;;;;;OAOG;IACH,gBAAgB,CACZ,OAAO,EAAE,wBAAwB,CAAC,QAAQ,CAAC,EAC3C,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAEtC;;;;OAIG;IACH,SAAS,IAAI,QAAQ,CAAC,qBAAqB,CAAC,CAAC;CAChD"}
|
|
@@ -3,5 +3,5 @@ export type { CacheEntryOptions, ICache } from "./cache.interface.js";
|
|
|
3
3
|
export type { ChatContextSnapshot, ContextManagerOptions, IContextManager, } from "./contextManager.interface.js";
|
|
4
4
|
export type { AsyncCheckerEvents, AsyncToolCheckerCheckParams, AsyncToolCheckerOptions, EventSubscription, PollingConfig, StatusChangedEvent, } from "./asyncToolChecker.interface.js";
|
|
5
5
|
export type { AsyncToolChecker, AwaitActionResult, AwaitableActionDescriptor, } from "../asyncToolChecker/index.js";
|
|
6
|
-
export type { ChatOptions, ChatRequestPayload, SendMessageResult } from "./chat.interface.js";
|
|
6
|
+
export type { ChatOptions, ChatRequestPayload, SendMessageOptions, SendMessageResult, SendMessageStreamingOptions, } from "./chat.interface.js";
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,YAAY,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACtE,YAAY,EACR,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,GAClB,MAAM,+BAA+B,CAAC;AACvC,YAAY,EACR,kBAAkB,EAClB,2BAA2B,EAC3B,uBAAuB,EACvB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,GACrB,MAAM,iCAAiC,CAAC;AACzC,YAAY,EACR,gBAAgB,EAChB,iBAAiB,EACjB,yBAAyB,GAC5B,MAAM,8BAA8B,CAAC;AACtC,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,YAAY,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACtE,YAAY,EACR,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,GAClB,MAAM,+BAA+B,CAAC;AACvC,YAAY,EACR,kBAAkB,EAClB,2BAA2B,EAC3B,uBAAuB,EACvB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,GACrB,MAAM,iCAAiC,CAAC;AACzC,YAAY,EACR,gBAAgB,EAChB,iBAAiB,EACjB,yBAAyB,GAC5B,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACR,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,2BAA2B,GAC9B,MAAM,qBAAqB,CAAC"}
|
package/dist/src/internal.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC"}
|
package/dist/src/internal.js
CHANGED
package/dist/src/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { NormalizedPromptSnapshot, PromptOptions, PromptRole, PromptSnapshot } from "./types.js";
|
|
1
|
+
import type { NormalizedPromptSnapshot, PromptOptions, PromptSnapshot } from "./types.js";
|
|
3
2
|
/**
|
|
4
3
|
* Represents a message payload that can be sent to the Core API.
|
|
5
4
|
*
|
|
@@ -28,14 +27,7 @@ export declare class Prompt {
|
|
|
28
27
|
* @param role The role to assign to the message (e.g., "user", "assistant", "tool").
|
|
29
28
|
* @returns A normalized snapshot containing both the prompt payload and message format.
|
|
30
29
|
*/
|
|
31
|
-
getNormalizedSnapshot(
|
|
32
|
-
/**
|
|
33
|
-
* Converts the prompt into a message history entry with the specified role.
|
|
34
|
-
*
|
|
35
|
-
* @param role The role to assign to the message (e.g., "user", "assistant", "tool").
|
|
36
|
-
* @returns A message object compatible with the message history format.
|
|
37
|
-
*/
|
|
38
|
-
toMessage(role: PromptRole): MessageType;
|
|
30
|
+
getNormalizedSnapshot(): NormalizedPromptSnapshot;
|
|
39
31
|
/**
|
|
40
32
|
* Converts the prompt to a string representation.
|
|
41
33
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Prompt.d.ts","sourceRoot":"","sources":["../../../src/prompt/Prompt.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Prompt.d.ts","sourceRoot":"","sources":["../../../src/prompt/Prompt.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,wBAAwB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAI1F;;;;;;GAMG;AACH,qBAAa,MAAM;IACf,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAiB;IAE1C;;;;;OAKG;gBACgB,OAAO,EAAE,aAAa;IAIzC;;;;OAIG;IACI,WAAW,IAAI,cAAc;IAIpC;;;;;OAKG;IACI,qBAAqB,IAAI,wBAAwB;IAcxD;;;;OAIG;IACI,QAAQ,IAAI,MAAM;IAQzB;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IAyB7B;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;CAa/B"}
|