@illalabs/sdk 0.3.3-canary.ae6ff112 → 0.4.0-canary.1a04c18e
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 +36 -4
- package/dist/src/chat/Chat.d.ts.map +1 -1
- package/dist/src/chat/Chat.js +129 -11
- package/dist/src/chat/Chat.js.map +1 -1
- package/dist/src/chat/errors/ChatInvalidMultiplePromptsKind.d.ts +22 -0
- package/dist/src/chat/errors/ChatInvalidMultiplePromptsKind.d.ts.map +1 -0
- package/dist/src/chat/errors/ChatInvalidMultiplePromptsKind.js +31 -0
- package/dist/src/chat/errors/ChatInvalidMultiplePromptsKind.js.map +1 -0
- package/dist/src/chat/errors/ChatInvalidPromptSnapshot.d.ts +19 -0
- package/dist/src/chat/errors/ChatInvalidPromptSnapshot.d.ts.map +1 -0
- package/dist/src/chat/errors/ChatInvalidPromptSnapshot.js +28 -0
- package/dist/src/chat/errors/ChatInvalidPromptSnapshot.js.map +1 -0
- package/dist/src/chat/errors/ChatInvalidSinglePromptKind.d.ts +22 -0
- package/dist/src/chat/errors/ChatInvalidSinglePromptKind.d.ts.map +1 -0
- package/dist/src/chat/errors/ChatInvalidSinglePromptKind.js +31 -0
- package/dist/src/chat/errors/ChatInvalidSinglePromptKind.js.map +1 -0
- package/dist/src/chat/errors/index.d.ts +3 -0
- package/dist/src/chat/errors/index.d.ts.map +1 -1
- package/dist/src/chat/errors/index.js +3 -0
- package/dist/src/chat/errors/index.js.map +1 -1
- package/dist/src/chat/utils/prompt.d.ts +3 -0
- package/dist/src/chat/utils/prompt.d.ts.map +1 -0
- package/dist/src/chat/utils/prompt.js +5 -0
- package/dist/src/chat/utils/prompt.js.map +1 -0
- package/dist/src/context/ContextManager.d.ts +2 -0
- package/dist/src/context/ContextManager.d.ts.map +1 -1
- package/dist/src/context/ContextManager.js +8 -1
- package/dist/src/context/ContextManager.js.map +1 -1
- package/dist/src/errors/SdkEmptyToolsResultsError.d.ts +19 -0
- package/dist/src/errors/SdkEmptyToolsResultsError.d.ts.map +1 -0
- package/dist/src/errors/SdkEmptyToolsResultsError.js +28 -0
- package/dist/src/errors/SdkEmptyToolsResultsError.js.map +1 -0
- package/dist/src/interfaces/chat.interface.d.ts +55 -3
- package/dist/src/interfaces/chat.interface.d.ts.map +1 -1
- package/dist/src/interfaces/contextManager.interface.d.ts +7 -1
- package/dist/src/interfaces/contextManager.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 +311 -25
- package/dist/src/sdk.d.ts.map +1 -1
- package/dist/src/sdk.js +365 -26
- 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
|
@@ -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,
|
|
@@ -37,6 +37,13 @@ export class ContextManager {
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
/** @inheritdoc */
|
|
40
|
+
async clearContext(chatId) {
|
|
41
|
+
return this.writeRecord(chatId, {
|
|
42
|
+
messages: cloneMessages(this.defaultSnapshot.messages),
|
|
43
|
+
toolsConfig: cloneToolsConfig(this.defaultSnapshot.toolsConfig),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/** @inheritdoc */
|
|
40
47
|
async setMessages(chatId, messages) {
|
|
41
48
|
const record = await this.readRecord(chatId);
|
|
42
49
|
const updated = {
|
|
@@ -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,OAAO,EAAE,mBAAmB,CAAC,OAAO,CAAC,OAAO,CAAC;CAChD,CAAC,CAAuB,CAAC;AAE9B,MAAM,gBAAgB,GAAG,CAAC,MAA6B,EAAyB,EAAE,CAC9E,eAAe,CAAC,MAAM,CAAC,CAAC;AAE5B;;GAEG;AACH,MAAM,OAAO,cAAc;IAQF;IAPJ,iBAAiB,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,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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error emitted when attempting to send tool results when no tool results are provided.
|
|
3
|
+
*
|
|
4
|
+
* The error may include a `context` property with additional debugging information
|
|
5
|
+
* such as the `chatId`.
|
|
6
|
+
*/
|
|
7
|
+
export declare class SdkEmptyToolsResultsError extends Error {
|
|
8
|
+
/**
|
|
9
|
+
* Optional context describing the chat details.
|
|
10
|
+
*/
|
|
11
|
+
readonly context?: unknown;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new {@link SdkEmptyToolsResultsError} instance.
|
|
14
|
+
*
|
|
15
|
+
* @param context Additional context useful for debugging, e.g. `{ chatId: string }`.
|
|
16
|
+
*/
|
|
17
|
+
constructor(context?: unknown);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=SdkEmptyToolsResultsError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SdkEmptyToolsResultsError.d.ts","sourceRoot":"","sources":["../../../src/errors/SdkEmptyToolsResultsError.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;IAChD;;OAEG;IACH,SAAgB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElC;;;;OAIG;gBACgB,OAAO,CAAC,EAAE,OAAO;CAUvC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error emitted when attempting to send tool results when no tool results are provided.
|
|
3
|
+
*
|
|
4
|
+
* The error may include a `context` property with additional debugging information
|
|
5
|
+
* such as the `chatId`.
|
|
6
|
+
*/
|
|
7
|
+
export class SdkEmptyToolsResultsError extends Error {
|
|
8
|
+
/**
|
|
9
|
+
* Optional context describing the chat details.
|
|
10
|
+
*/
|
|
11
|
+
context;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new {@link SdkEmptyToolsResultsError} instance.
|
|
14
|
+
*
|
|
15
|
+
* @param context Additional context useful for debugging, e.g. `{ chatId: string }`.
|
|
16
|
+
*/
|
|
17
|
+
constructor(context) {
|
|
18
|
+
super("No tool results provided");
|
|
19
|
+
this.name = "SdkEmptyToolsResultsError";
|
|
20
|
+
if (context !== undefined) {
|
|
21
|
+
Object.defineProperty(this, "context", {
|
|
22
|
+
value: context,
|
|
23
|
+
enumerable: true,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=SdkEmptyToolsResultsError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SdkEmptyToolsResultsError.js","sourceRoot":"","sources":["../../../src/errors/SdkEmptyToolsResultsError.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAChD;;OAEG;IACa,OAAO,CAAW;IAElC;;;;OAIG;IACH,YAAmB,OAAiB;QAChC,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;QACxC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE;gBACnC,KAAK,EAAE,OAAO;gBACd,UAAU,EAAE,IAAI;aACnB,CAAC,CAAC;QACP,CAAC;IACL,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,14 +97,20 @@ 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
|
*/
|
|
57
108
|
readonly prompt: CoreApiChatBodyRequest["prompt"];
|
|
58
109
|
/**
|
|
59
|
-
* Snapshot of the original prompt before normalization.
|
|
110
|
+
* Snapshot of the original prompt(s) before normalization.
|
|
111
|
+
* Can be a single snapshot or an array of snapshots.
|
|
60
112
|
*/
|
|
61
|
-
readonly promptSnapshot: PromptSnapshot;
|
|
113
|
+
readonly promptSnapshot: PromptSnapshot | PromptSnapshot[];
|
|
62
114
|
/**
|
|
63
115
|
* Message history including the user's message and any response messages.
|
|
64
116
|
*/
|
|
@@ -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,gCAAgC,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,QAAQ,CAAC,eAAe,EAAE,gBAAgB,CAAC;IAE3C;;OAEG;IACH,QAAQ,CAAC,cAAc,EAAE,eAAe,CAAC;IAEzC;;OAEG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,UAAU,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c,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"}
|
|
@@ -77,10 +77,16 @@ export interface IContextManager {
|
|
|
77
77
|
*/
|
|
78
78
|
setToolsConfig(chatId: string, toolsConfig: ToolAutorouterRequest): Promise<void>;
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
80
|
+
* Deletes all persisted data associated with the chat.
|
|
81
81
|
*
|
|
82
82
|
* @param chatId Identifier of the chat session.
|
|
83
83
|
*/
|
|
84
84
|
deleteContext(chatId: string): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Clears all persisted data associated with the chat.
|
|
87
|
+
*
|
|
88
|
+
* @param chatId Identifier of the chat session.
|
|
89
|
+
*/
|
|
90
|
+
clearContext(chatId: string): Promise<void>;
|
|
85
91
|
}
|
|
86
92
|
//# sourceMappingURL=contextManager.interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextManager.interface.d.ts","sourceRoot":"","sources":["../../../src/interfaces/contextManager.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAA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iChatResponse, 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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ToolOutcomesSchema } from "@illalabs/interfaces";
|
|
2
2
|
import { stringify } from "viem";
|
|
3
3
|
import { PromptConfigurationConflict } from "./errors/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { cloneToolOutcome } from "./utils/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Represents a message payload that can be sent to the Core API.
|
|
7
7
|
*
|
|
@@ -34,31 +34,18 @@ export class Prompt {
|
|
|
34
34
|
* @param role The role to assign to the message (e.g., "user", "assistant", "tool").
|
|
35
35
|
* @returns A normalized snapshot containing both the prompt payload and message format.
|
|
36
36
|
*/
|
|
37
|
-
getNormalizedSnapshot(
|
|
37
|
+
getNormalizedSnapshot() {
|
|
38
38
|
if (this.snapshot.kind === "text") {
|
|
39
|
-
const normalized = normalizeTextPrompt(this.snapshot.text, role);
|
|
40
39
|
return {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
message: normalized.message,
|
|
40
|
+
type: "text",
|
|
41
|
+
text: this.snapshot.text,
|
|
44
42
|
};
|
|
45
43
|
}
|
|
46
|
-
const normalized = normalizeToolResult(this.snapshot.toolResult, role);
|
|
47
44
|
return {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
message: normalized.message,
|
|
45
|
+
type: "tool-result",
|
|
46
|
+
toolResults: this.snapshot.toolResult,
|
|
51
47
|
};
|
|
52
48
|
}
|
|
53
|
-
/**
|
|
54
|
-
* Converts the prompt into a message history entry with the specified role.
|
|
55
|
-
*
|
|
56
|
-
* @param role The role to assign to the message (e.g., "user", "assistant", "tool").
|
|
57
|
-
* @returns A message object compatible with the message history format.
|
|
58
|
-
*/
|
|
59
|
-
toMessage(role) {
|
|
60
|
-
return this.getNormalizedSnapshot(role).message;
|
|
61
|
-
}
|
|
62
49
|
/**
|
|
63
50
|
* Converts the prompt to a string representation.
|
|
64
51
|
*
|
|
@@ -90,7 +77,7 @@ export class Prompt {
|
|
|
90
77
|
text,
|
|
91
78
|
};
|
|
92
79
|
}
|
|
93
|
-
const validated =
|
|
80
|
+
const validated = ToolOutcomesSchema.parse(toolResult);
|
|
94
81
|
return {
|
|
95
82
|
kind: "tool-result",
|
|
96
83
|
toolResult: validated,
|
|
@@ -111,7 +98,7 @@ export class Prompt {
|
|
|
111
98
|
}
|
|
112
99
|
return {
|
|
113
100
|
kind: "tool-result",
|
|
114
|
-
toolResult:
|
|
101
|
+
toolResult: snapshot.toolResult.map((item) => cloneToolOutcome(item)),
|
|
115
102
|
};
|
|
116
103
|
}
|
|
117
104
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Prompt.js","sourceRoot":"","sources":["../../../src/prompt/Prompt.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Prompt.js","sourceRoot":"","sources":["../../../src/prompt/Prompt.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAGjC,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,OAAO,MAAM;IACE,QAAQ,CAAiB;IAE1C;;;;;OAKG;IACH,YAAmB,OAAsB;QACrC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IACnD,CAAC;IAED;;;;OAIG;IACI,WAAW;QACd,OAAO,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;OAKG;IACI,qBAAqB;QACxB,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAChC,OAAO;gBACH,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,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,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;SACxE,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { Prompt } from "./Prompt.js";
|
|
2
2
|
export { PromptConfigurationConflict } from "./errors/index.js";
|
|
3
|
-
export type { PromptKind, PromptOptions,
|
|
3
|
+
export type { NormalizedPromptSnapshot, PromptKind, PromptOptions, PromptRole, PromptSnapshot, } from "./types.js";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/prompt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAChE,YAAY,EACR,UAAU,EACV,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/prompt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAChE,YAAY,EACR,wBAAwB,EACxB,UAAU,EACV,aAAa,EACb,UAAU,EACV,cAAc,GACjB,MAAM,YAAY,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ToolOutcomesType } from "@illalabs/interfaces";
|
|
2
2
|
/**
|
|
3
3
|
* Enumerates the supported prompt payload variants.
|
|
4
4
|
*/
|
|
@@ -28,7 +28,7 @@ type XOR<TLeft, TRight> = (Without<TLeft, TRight> & TRight) | (Without<TRight, T
|
|
|
28
28
|
export type PromptOptions = XOR<{
|
|
29
29
|
readonly text: string;
|
|
30
30
|
}, {
|
|
31
|
-
readonly toolResult:
|
|
31
|
+
readonly toolResult: ToolOutcomesType;
|
|
32
32
|
}>;
|
|
33
33
|
/**
|
|
34
34
|
* Resulting payload snapshot produced by a {@link Prompt} instance.
|
|
@@ -38,20 +38,18 @@ export type PromptSnapshot = {
|
|
|
38
38
|
readonly text: string;
|
|
39
39
|
} | {
|
|
40
40
|
readonly kind: "tool-result";
|
|
41
|
-
readonly toolResult:
|
|
41
|
+
readonly toolResult: ToolOutcomesType;
|
|
42
42
|
};
|
|
43
43
|
/**
|
|
44
44
|
* Normalized prompt snapshot containing both the prompt payload and corresponding message format.
|
|
45
45
|
* This structure is suitable for transmission to the Core API.
|
|
46
46
|
*/
|
|
47
47
|
export type NormalizedPromptSnapshot = {
|
|
48
|
-
readonly
|
|
49
|
-
readonly
|
|
50
|
-
readonly message: MessageType;
|
|
48
|
+
readonly type: "text";
|
|
49
|
+
readonly text: string;
|
|
51
50
|
} | {
|
|
52
|
-
readonly
|
|
53
|
-
readonly
|
|
54
|
-
readonly message: MessageType;
|
|
51
|
+
readonly type: "tool-result";
|
|
52
|
+
readonly toolResults: ToolOutcomesType;
|
|
55
53
|
};
|
|
56
54
|
export {};
|
|
57
55
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/prompt/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/prompt/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,aAAa,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;AAEvD;;GAEG;AACH,KAAK,OAAO,CAAC,OAAO,EAAE,SAAS,IAAI;KAC9B,GAAG,IAAI,OAAO,CAAC,MAAM,OAAO,EAAE,MAAM,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK;CAC3D,CAAC;AAEF;;GAEG;AACH,KAAK,GAAG,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC;AAE/F;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,GAAG,CAC3B;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EACzB;IAAE,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAA;CAAE,CAC5C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GACpB;IACI,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACzB,GACD;IACI,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;CACzC,CAAC;AAER;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAC9B;IACI,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACzB,GACD;IACI,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAAC;CAC1C,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IllaToolOutcomeJSON } from "@illalabs/interfaces";
|
|
2
2
|
/**
|
|
3
|
-
* Creates a deep clone of a tool
|
|
3
|
+
* Creates a deep clone of a tool outcome object to prevent external mutation.
|
|
4
4
|
*
|
|
5
5
|
* This function clones all potentially complex fields (result and error) while
|
|
6
|
-
* preserving primitive identifiers (
|
|
6
|
+
* preserving primitive identifiers (id and name).
|
|
7
7
|
*
|
|
8
|
-
* @param
|
|
9
|
-
* @returns A deep copy of the tool
|
|
8
|
+
* @param toolOutcome The tool outcome to clone.
|
|
9
|
+
* @returns A deep copy of the tool outcome with all complex fields cloned.
|
|
10
10
|
*/
|
|
11
|
-
export declare function
|
|
11
|
+
export declare function cloneToolOutcome(toolOutcome: IllaToolOutcomeJSON): IllaToolOutcomeJSON;
|
|
12
12
|
//# sourceMappingURL=cloneToolResult.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloneToolResult.d.ts","sourceRoot":"","sources":["../../../../src/prompt/utils/cloneToolResult.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"cloneToolResult.d.ts","sourceRoot":"","sources":["../../../../src/prompt/utils/cloneToolResult.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAIhE;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,mBAAmB,GAAG,mBAAmB,CAYtF"}
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import { deepClone } from "./deepClone.js";
|
|
2
2
|
/**
|
|
3
|
-
* Creates a deep clone of a tool
|
|
3
|
+
* Creates a deep clone of a tool outcome object to prevent external mutation.
|
|
4
4
|
*
|
|
5
5
|
* This function clones all potentially complex fields (result and error) while
|
|
6
|
-
* preserving primitive identifiers (
|
|
6
|
+
* preserving primitive identifiers (id and name).
|
|
7
7
|
*
|
|
8
|
-
* @param
|
|
9
|
-
* @returns A deep copy of the tool
|
|
8
|
+
* @param toolOutcome The tool outcome to clone.
|
|
9
|
+
* @returns A deep copy of the tool outcome with all complex fields cloned.
|
|
10
10
|
*/
|
|
11
|
-
export function
|
|
11
|
+
export function cloneToolOutcome(toolOutcome) {
|
|
12
12
|
const cloned = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
result:
|
|
13
|
+
id: toolOutcome.id,
|
|
14
|
+
name: toolOutcome.name,
|
|
15
|
+
result: toolOutcome.result !== undefined ? deepClone(toolOutcome.result) : undefined,
|
|
16
16
|
};
|
|
17
|
-
// Deep clone error only if it's a non-
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
cloned.error = deepClone(toolResult.error);
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
cloned.error = toolResult.error;
|
|
24
|
-
}
|
|
17
|
+
// Deep clone error only if it's a non-undefined object
|
|
18
|
+
if (toolOutcome.error !== undefined) {
|
|
19
|
+
cloned.error = deepClone(toolOutcome.error);
|
|
25
20
|
}
|
|
26
21
|
return cloned;
|
|
27
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloneToolResult.js","sourceRoot":"","sources":["../../../../src/prompt/utils/cloneToolResult.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;;;;;;;GAQG;AACH,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"cloneToolResult.js","sourceRoot":"","sources":["../../../../src/prompt/utils/cloneToolResult.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,WAAgC;IAC7D,MAAM,MAAM,GAAwB;QAChC,EAAE,EAAE,WAAW,CAAC,EAAE;QAClB,IAAI,EAAE,WAAW,CAAC,IAAI;QACtB,MAAM,EAAE,WAAW,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;KACvF,CAAC;IAEF,uDAAuD;IACvD,IAAI,WAAW,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAClC,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { cloneToolOutcome } from "./cloneToolResult.js";
|
|
2
2
|
export { deepClone } from "./deepClone.js";
|
|
3
|
-
export { normalizeTextPrompt } from "./normalizeTextPrompt.js";
|
|
4
|
-
export { normalizeToolResult } from "./normalizeToolResult.js";
|
|
5
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/prompt/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/prompt/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { cloneToolOutcome } from "./cloneToolResult.js";
|
|
2
2
|
export { deepClone } from "./deepClone.js";
|
|
3
|
-
export { normalizeTextPrompt } from "./normalizeTextPrompt.js";
|
|
4
|
-
export { normalizeToolResult } from "./normalizeToolResult.js";
|
|
5
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/prompt/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/prompt/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
|