@illalabs/sdk 0.0.0 → 0.1.0-canary.48bfe253
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/LICENSE +17 -2
- package/README.md +141 -1
- package/dist/src/asyncToolChecker/AsyncToolChecker.d.ts +39 -0
- package/dist/src/asyncToolChecker/AsyncToolChecker.d.ts.map +1 -0
- package/dist/src/asyncToolChecker/AsyncToolChecker.js +209 -0
- package/dist/src/asyncToolChecker/AsyncToolChecker.js.map +1 -0
- package/dist/src/asyncToolChecker/errors/AsyncToolCheckerMaxRetriesExceeded.d.ts +23 -0
- package/dist/src/asyncToolChecker/errors/AsyncToolCheckerMaxRetriesExceeded.d.ts.map +1 -0
- package/dist/src/asyncToolChecker/errors/AsyncToolCheckerMaxRetriesExceeded.js +30 -0
- package/dist/src/asyncToolChecker/errors/AsyncToolCheckerMaxRetriesExceeded.js.map +1 -0
- package/dist/src/asyncToolChecker/errors/AsyncToolCheckerMethodNotImplemented.d.ts +17 -0
- package/dist/src/asyncToolChecker/errors/AsyncToolCheckerMethodNotImplemented.d.ts.map +1 -0
- package/dist/src/asyncToolChecker/errors/AsyncToolCheckerMethodNotImplemented.js +26 -0
- package/dist/src/asyncToolChecker/errors/AsyncToolCheckerMethodNotImplemented.js.map +1 -0
- package/dist/src/asyncToolChecker/errors/AsyncToolCheckerTimeout.d.ts +17 -0
- package/dist/src/asyncToolChecker/errors/AsyncToolCheckerTimeout.d.ts.map +1 -0
- package/dist/src/asyncToolChecker/errors/AsyncToolCheckerTimeout.js +21 -0
- package/dist/src/asyncToolChecker/errors/AsyncToolCheckerTimeout.js.map +1 -0
- package/dist/src/asyncToolChecker/errors/index.d.ts +4 -0
- package/dist/src/asyncToolChecker/errors/index.d.ts.map +1 -0
- package/dist/src/asyncToolChecker/errors/index.js +4 -0
- package/dist/src/asyncToolChecker/errors/index.js.map +1 -0
- package/dist/src/asyncToolChecker/index.d.ts +6 -0
- package/dist/src/asyncToolChecker/index.d.ts.map +1 -0
- package/dist/src/asyncToolChecker/index.js +5 -0
- package/dist/src/asyncToolChecker/index.js.map +1 -0
- package/dist/src/asyncToolChecker/types.d.ts +24 -0
- package/dist/src/asyncToolChecker/types.d.ts.map +1 -0
- package/dist/src/asyncToolChecker/types.js +2 -0
- package/dist/src/asyncToolChecker/types.js.map +1 -0
- package/dist/src/asyncToolChecker/utils/index.d.ts +3 -0
- package/dist/src/asyncToolChecker/utils/index.d.ts.map +1 -0
- package/dist/src/asyncToolChecker/utils/index.js +3 -0
- package/dist/src/asyncToolChecker/utils/index.js.map +1 -0
- package/dist/src/asyncToolChecker/utils/isErrorResponse.d.ts +11 -0
- package/dist/src/asyncToolChecker/utils/isErrorResponse.d.ts.map +1 -0
- package/dist/src/asyncToolChecker/utils/isErrorResponse.js +12 -0
- package/dist/src/asyncToolChecker/utils/isErrorResponse.js.map +1 -0
- package/dist/src/asyncToolChecker/utils/normalizeTimeout.d.ts +9 -0
- package/dist/src/asyncToolChecker/utils/normalizeTimeout.d.ts.map +1 -0
- package/dist/src/asyncToolChecker/utils/normalizeTimeout.js +14 -0
- package/dist/src/asyncToolChecker/utils/normalizeTimeout.js.map +1 -0
- package/dist/src/caching/InMemoryCache.d.ts +14 -0
- package/dist/src/caching/InMemoryCache.d.ts.map +1 -0
- package/dist/src/caching/InMemoryCache.js +31 -0
- package/dist/src/caching/InMemoryCache.js.map +1 -0
- package/dist/src/caching/index.d.ts +3 -0
- package/dist/src/caching/index.d.ts.map +1 -0
- package/dist/src/caching/index.js +2 -0
- package/dist/src/caching/index.js.map +1 -0
- package/dist/src/chat/Chat.d.ts +62 -0
- package/dist/src/chat/Chat.d.ts.map +1 -0
- package/dist/src/chat/Chat.js +126 -0
- package/dist/src/chat/Chat.js.map +1 -0
- package/dist/src/chat/errors/ChatAsyncToolCheckerUnavailable.d.ts +19 -0
- package/dist/src/chat/errors/ChatAsyncToolCheckerUnavailable.d.ts.map +1 -0
- package/dist/src/chat/errors/ChatAsyncToolCheckerUnavailable.js +28 -0
- package/dist/src/chat/errors/ChatAsyncToolCheckerUnavailable.js.map +1 -0
- package/dist/src/chat/errors/index.d.ts +2 -0
- package/dist/src/chat/errors/index.d.ts.map +1 -0
- package/dist/src/chat/errors/index.js +2 -0
- package/dist/src/chat/errors/index.js.map +1 -0
- package/dist/src/chat/index.d.ts +5 -0
- package/dist/src/chat/index.d.ts.map +1 -0
- package/dist/src/chat/index.js +3 -0
- package/dist/src/chat/index.js.map +1 -0
- package/dist/src/chat/types.d.ts +9 -0
- package/dist/src/chat/types.d.ts.map +1 -0
- package/dist/src/chat/types.js +2 -0
- package/dist/src/chat/types.js.map +1 -0
- package/dist/src/chat/utils/index.d.ts +2 -0
- package/dist/src/chat/utils/index.d.ts.map +1 -0
- package/dist/src/chat/utils/index.js +2 -0
- package/dist/src/chat/utils/index.js.map +1 -0
- package/dist/src/chat/utils/uuid.d.ts +12 -0
- package/dist/src/chat/utils/uuid.d.ts.map +1 -0
- package/dist/src/chat/utils/uuid.js +19 -0
- package/dist/src/chat/utils/uuid.js.map +1 -0
- package/dist/src/context/ContextManager.d.ts +26 -0
- package/dist/src/context/ContextManager.d.ts.map +1 -0
- package/dist/src/context/ContextManager.js +93 -0
- package/dist/src/context/ContextManager.js.map +1 -0
- package/dist/src/context/index.d.ts +2 -0
- package/dist/src/context/index.d.ts.map +1 -0
- package/dist/src/context/index.js +2 -0
- package/dist/src/context/index.js.map +1 -0
- package/dist/src/context/types.d.ts +17 -0
- package/dist/src/context/types.d.ts.map +1 -0
- package/dist/src/context/types.js +2 -0
- package/dist/src/context/types.js.map +1 -0
- package/dist/src/external.d.ts +14 -0
- package/dist/src/external.d.ts.map +1 -0
- package/dist/src/external.js +13 -0
- package/dist/src/external.js.map +1 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +8 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/interfaces/asyncToolChecker.interface.d.ts +85 -0
- package/dist/src/interfaces/asyncToolChecker.interface.d.ts.map +1 -0
- package/dist/src/interfaces/asyncToolChecker.interface.js +2 -0
- package/dist/src/interfaces/asyncToolChecker.interface.js.map +1 -0
- package/dist/src/interfaces/cache.interface.d.ts +35 -0
- package/dist/src/interfaces/cache.interface.d.ts.map +1 -0
- package/dist/src/interfaces/cache.interface.js +2 -0
- package/dist/src/interfaces/cache.interface.js.map +1 -0
- package/dist/src/interfaces/chat.interface.d.ts +84 -0
- package/dist/src/interfaces/chat.interface.d.ts.map +1 -0
- package/dist/src/interfaces/chat.interface.js +2 -0
- package/dist/src/interfaces/chat.interface.js.map +1 -0
- package/dist/src/interfaces/contextManager.interface.d.ts +86 -0
- package/dist/src/interfaces/contextManager.interface.d.ts.map +1 -0
- package/dist/src/interfaces/contextManager.interface.js +2 -0
- package/dist/src/interfaces/contextManager.interface.js.map +1 -0
- package/dist/src/interfaces/coreApiProvider.interface.d.ts +32 -0
- package/dist/src/interfaces/coreApiProvider.interface.d.ts.map +1 -0
- package/dist/src/interfaces/coreApiProvider.interface.js +2 -0
- package/dist/src/interfaces/coreApiProvider.interface.js.map +1 -0
- package/dist/src/interfaces/index.d.ts +7 -0
- package/dist/src/interfaces/index.d.ts.map +1 -0
- package/dist/src/interfaces/index.js +2 -0
- package/dist/src/interfaces/index.js.map +1 -0
- package/dist/src/internal.d.ts +14 -0
- package/dist/src/internal.d.ts.map +1 -0
- package/dist/src/internal.js +14 -0
- package/dist/src/internal.js.map +1 -0
- package/dist/src/prompt/Prompt.d.ts +61 -0
- package/dist/src/prompt/Prompt.d.ts.map +1 -0
- package/dist/src/prompt/Prompt.js +118 -0
- package/dist/src/prompt/Prompt.js.map +1 -0
- package/dist/src/prompt/errors/PromptConfigurationConflict.d.ts +10 -0
- package/dist/src/prompt/errors/PromptConfigurationConflict.d.ts.map +1 -0
- package/dist/src/prompt/errors/PromptConfigurationConflict.js +13 -0
- package/dist/src/prompt/errors/PromptConfigurationConflict.js.map +1 -0
- package/dist/src/prompt/errors/index.d.ts +2 -0
- package/dist/src/prompt/errors/index.d.ts.map +1 -0
- package/dist/src/prompt/errors/index.js +2 -0
- package/dist/src/prompt/errors/index.js.map +1 -0
- package/dist/src/prompt/index.d.ts +4 -0
- package/dist/src/prompt/index.d.ts.map +1 -0
- package/dist/src/prompt/index.js +3 -0
- package/dist/src/prompt/index.js.map +1 -0
- package/dist/src/prompt/types.d.ts +57 -0
- package/dist/src/prompt/types.d.ts.map +1 -0
- package/dist/src/prompt/types.js +2 -0
- package/dist/src/prompt/types.js.map +1 -0
- package/dist/src/prompt/utils/cloneToolResult.d.ts +12 -0
- package/dist/src/prompt/utils/cloneToolResult.d.ts.map +1 -0
- package/dist/src/prompt/utils/cloneToolResult.js +28 -0
- package/dist/src/prompt/utils/cloneToolResult.js.map +1 -0
- package/dist/src/prompt/utils/deepClone.d.ts +9 -0
- package/dist/src/prompt/utils/deepClone.d.ts.map +1 -0
- package/dist/src/prompt/utils/deepClone.js +15 -0
- package/dist/src/prompt/utils/deepClone.js.map +1 -0
- package/dist/src/prompt/utils/index.d.ts +5 -0
- package/dist/src/prompt/utils/index.d.ts.map +1 -0
- package/dist/src/prompt/utils/index.js +5 -0
- package/dist/src/prompt/utils/index.js.map +1 -0
- package/dist/src/prompt/utils/normalizeTextPrompt.d.ts +14 -0
- package/dist/src/prompt/utils/normalizeTextPrompt.d.ts.map +1 -0
- package/dist/src/prompt/utils/normalizeTextPrompt.js +22 -0
- package/dist/src/prompt/utils/normalizeTextPrompt.js.map +1 -0
- package/dist/src/prompt/utils/normalizeToolResult.d.ts +14 -0
- package/dist/src/prompt/utils/normalizeToolResult.d.ts.map +1 -0
- package/dist/src/prompt/utils/normalizeToolResult.js +27 -0
- package/dist/src/prompt/utils/normalizeToolResult.js.map +1 -0
- package/dist/src/providers/coreApiProvider/CoreApiProvider.d.ts +42 -0
- package/dist/src/providers/coreApiProvider/CoreApiProvider.d.ts.map +1 -0
- package/dist/src/providers/coreApiProvider/CoreApiProvider.js +106 -0
- package/dist/src/providers/coreApiProvider/CoreApiProvider.js.map +1 -0
- package/dist/src/providers/coreApiProvider/errors/CoreApiAuthenticationMissing.d.ts +8 -0
- package/dist/src/providers/coreApiProvider/errors/CoreApiAuthenticationMissing.d.ts.map +1 -0
- package/dist/src/providers/coreApiProvider/errors/CoreApiAuthenticationMissing.js +15 -0
- package/dist/src/providers/coreApiProvider/errors/CoreApiAuthenticationMissing.js.map +1 -0
- package/dist/src/providers/coreApiProvider/errors/CoreApiMethodNotImplemented.d.ts +9 -0
- package/dist/src/providers/coreApiProvider/errors/CoreApiMethodNotImplemented.d.ts.map +1 -0
- package/dist/src/providers/coreApiProvider/errors/CoreApiMethodNotImplemented.js +19 -0
- package/dist/src/providers/coreApiProvider/errors/CoreApiMethodNotImplemented.js.map +1 -0
- package/dist/src/providers/coreApiProvider/errors/index.d.ts +3 -0
- package/dist/src/providers/coreApiProvider/errors/index.d.ts.map +1 -0
- package/dist/src/providers/coreApiProvider/errors/index.js +3 -0
- package/dist/src/providers/coreApiProvider/errors/index.js.map +1 -0
- package/dist/src/providers/coreApiProvider/index.d.ts +6 -0
- package/dist/src/providers/coreApiProvider/index.d.ts.map +1 -0
- package/dist/src/providers/coreApiProvider/index.js +3 -0
- package/dist/src/providers/coreApiProvider/index.js.map +1 -0
- package/dist/src/providers/coreApiProvider/interfaces/CoreApiProviderConfig.interface.d.ts +29 -0
- package/dist/src/providers/coreApiProvider/interfaces/CoreApiProviderConfig.interface.d.ts.map +1 -0
- package/dist/src/providers/coreApiProvider/interfaces/CoreApiProviderConfig.interface.js +2 -0
- package/dist/src/providers/coreApiProvider/interfaces/CoreApiProviderConfig.interface.js.map +1 -0
- package/dist/src/providers/coreApiProvider/interfaces/CoreApiProviderRoutes.interface.d.ts +14 -0
- package/dist/src/providers/coreApiProvider/interfaces/CoreApiProviderRoutes.interface.d.ts.map +1 -0
- package/dist/src/providers/coreApiProvider/interfaces/CoreApiProviderRoutes.interface.js +2 -0
- package/dist/src/providers/coreApiProvider/interfaces/CoreApiProviderRoutes.interface.js.map +1 -0
- package/dist/src/providers/coreApiProvider/interfaces/index.d.ts +3 -0
- package/dist/src/providers/coreApiProvider/interfaces/index.d.ts.map +1 -0
- package/dist/src/providers/coreApiProvider/interfaces/index.js +2 -0
- package/dist/src/providers/coreApiProvider/interfaces/index.js.map +1 -0
- package/dist/src/providers/coreApiProvider/types.d.ts +16 -0
- package/dist/src/providers/coreApiProvider/types.d.ts.map +1 -0
- package/dist/src/providers/coreApiProvider/types.js +2 -0
- package/dist/src/providers/coreApiProvider/types.js.map +1 -0
- package/dist/src/providers/index.d.ts +2 -0
- package/dist/src/providers/index.d.ts.map +1 -0
- package/dist/src/providers/index.js +2 -0
- package/dist/src/providers/index.js.map +1 -0
- package/package.json +42 -5
- package/index.d.ts +0 -1
- package/index.js +0 -1
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
const DEFAULT_PREFIX = "illa:sdk:ctx";
|
|
2
|
+
const DEFAULT_TOOLS_CONFIG = {};
|
|
3
|
+
const cloneMessageContent = (content) => {
|
|
4
|
+
if (typeof content === "string") {
|
|
5
|
+
return content;
|
|
6
|
+
}
|
|
7
|
+
return content.map((part) => ({ ...part }));
|
|
8
|
+
};
|
|
9
|
+
const cloneMessages = (messages) => messages.map((message) => ({
|
|
10
|
+
...message,
|
|
11
|
+
content: cloneMessageContent(message.content),
|
|
12
|
+
}));
|
|
13
|
+
const cloneToolsConfig = (config) => structuredClone(config);
|
|
14
|
+
/**
|
|
15
|
+
* Manages chat context using an injected cache implementation.
|
|
16
|
+
*/
|
|
17
|
+
export class ContextManager {
|
|
18
|
+
cache;
|
|
19
|
+
cacheEntryOptions;
|
|
20
|
+
defaultSnapshot;
|
|
21
|
+
prefix;
|
|
22
|
+
constructor(cache, options = {}) {
|
|
23
|
+
this.cache = cache;
|
|
24
|
+
this.prefix = options.cacheKeyPrefix ?? DEFAULT_PREFIX;
|
|
25
|
+
this.cacheEntryOptions = options.cacheEntryOptions;
|
|
26
|
+
this.defaultSnapshot = {
|
|
27
|
+
messages: [],
|
|
28
|
+
toolsConfig: cloneToolsConfig(options.defaultToolsConfig ?? DEFAULT_TOOLS_CONFIG),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** @inheritdoc */
|
|
32
|
+
async getContext(chatId) {
|
|
33
|
+
const record = await this.readRecord(chatId);
|
|
34
|
+
return {
|
|
35
|
+
messages: cloneMessages(record.messages),
|
|
36
|
+
toolsConfig: cloneToolsConfig(record.toolsConfig),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** @inheritdoc */
|
|
40
|
+
async setMessages(chatId, messages) {
|
|
41
|
+
const record = await this.readRecord(chatId);
|
|
42
|
+
const updated = {
|
|
43
|
+
messages: cloneMessages(messages),
|
|
44
|
+
toolsConfig: record.toolsConfig,
|
|
45
|
+
};
|
|
46
|
+
await this.writeRecord(chatId, updated);
|
|
47
|
+
}
|
|
48
|
+
/** @inheritdoc */
|
|
49
|
+
async appendMessages(chatId, messages) {
|
|
50
|
+
if (messages.length === 0) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const record = await this.readRecord(chatId);
|
|
54
|
+
const appended = cloneMessages(record.messages).concat(cloneMessages(messages));
|
|
55
|
+
await this.writeRecord(chatId, {
|
|
56
|
+
messages: appended,
|
|
57
|
+
toolsConfig: record.toolsConfig,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/** @inheritdoc */
|
|
61
|
+
async setToolsConfig(chatId, toolsConfig) {
|
|
62
|
+
const record = await this.readRecord(chatId);
|
|
63
|
+
const updated = {
|
|
64
|
+
messages: record.messages,
|
|
65
|
+
toolsConfig: cloneToolsConfig(toolsConfig),
|
|
66
|
+
};
|
|
67
|
+
await this.writeRecord(chatId, updated);
|
|
68
|
+
}
|
|
69
|
+
/** @inheritdoc */
|
|
70
|
+
async deleteContext(chatId) {
|
|
71
|
+
await this.cache.del(this.buildCacheKey(chatId));
|
|
72
|
+
}
|
|
73
|
+
async readRecord(chatId) {
|
|
74
|
+
const stored = await this.cache.get(this.buildCacheKey(chatId));
|
|
75
|
+
if (stored === undefined) {
|
|
76
|
+
return {
|
|
77
|
+
messages: cloneMessages(this.defaultSnapshot.messages),
|
|
78
|
+
toolsConfig: cloneToolsConfig(this.defaultSnapshot.toolsConfig),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
messages: cloneMessages(stored.messages),
|
|
83
|
+
toolsConfig: cloneToolsConfig(stored.toolsConfig),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
async writeRecord(chatId, record) {
|
|
87
|
+
await this.cache.set(this.buildCacheKey(chatId), record, this.cacheEntryOptions);
|
|
88
|
+
}
|
|
89
|
+
buildCacheKey(chatId) {
|
|
90
|
+
return `${this.prefix}:${chatId}`;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=ContextManager.js.map
|
|
@@ -0,0 +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,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,CAAmB,CAAC;AAClE,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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AC,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 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { MessageHistoryType, ToolAutorouterRequest } from "@illalabs/interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* Internal record structure stored in cache.
|
|
4
|
+
*/
|
|
5
|
+
export type ContextRecord = {
|
|
6
|
+
readonly messages: MessageHistoryType;
|
|
7
|
+
readonly toolsConfig: ToolAutorouterRequest;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Single message entry from the message history.
|
|
11
|
+
*/
|
|
12
|
+
export type MessageEntry = MessageHistoryType[number];
|
|
13
|
+
/**
|
|
14
|
+
* Content of a message, which can be a string or an array of content parts.
|
|
15
|
+
*/
|
|
16
|
+
export type MessageContent = MessageEntry["content"];
|
|
17
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/context/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAEtF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IACxB,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,qBAAqB,CAAC;CAC/C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/context/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public API exports for the Illa SDK package
|
|
3
|
+
*
|
|
4
|
+
* This file explicitly defines the public interface of the SDK.
|
|
5
|
+
* Only exports listed here are considered part of the public API.
|
|
6
|
+
*/
|
|
7
|
+
export { InMemoryCache } from "./caching/index.js";
|
|
8
|
+
export { Chat } from "./chat/index.js";
|
|
9
|
+
export { ContextManager } from "./context/index.js";
|
|
10
|
+
export { AsyncToolChecker } from "./asyncToolChecker/index.js";
|
|
11
|
+
export type { CacheEntryOptions, ChatContextSnapshot, ContextManagerOptions, ICache, IContextManager, } from "./interfaces/index.js";
|
|
12
|
+
export * from "./prompt/index.js";
|
|
13
|
+
export * from "./providers/index.js";
|
|
14
|
+
//# sourceMappingURL=external.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../../src/external.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,YAAY,EACR,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,MAAM,EACN,eAAe,GAClB,MAAM,uBAAuB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public API exports for the Illa SDK package
|
|
3
|
+
*
|
|
4
|
+
* This file explicitly defines the public interface of the SDK.
|
|
5
|
+
* Only exports listed here are considered part of the public API.
|
|
6
|
+
*/
|
|
7
|
+
export { InMemoryCache } from "./caching/index.js";
|
|
8
|
+
export { Chat } from "./chat/index.js";
|
|
9
|
+
export { ContextManager } from "./context/index.js";
|
|
10
|
+
export { AsyncToolChecker } from "./asyncToolChecker/index.js";
|
|
11
|
+
export * from "./prompt/index.js";
|
|
12
|
+
export * from "./providers/index.js";
|
|
13
|
+
//# sourceMappingURL=external.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external.js","sourceRoot":"","sources":["../../src/external.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAQ/D,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main entry point for the Illa SDK package
|
|
3
|
+
*
|
|
4
|
+
* This file serves as the package entry point and re-exports the public API
|
|
5
|
+
* defined in external.ts. For internal development and testing, use internal.ts.
|
|
6
|
+
*/
|
|
7
|
+
export * from "./external.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main entry point for the Illa SDK package
|
|
3
|
+
*
|
|
4
|
+
* This file serves as the package entry point and re-exports the public API
|
|
5
|
+
* defined in external.ts. For internal development and testing, use internal.ts.
|
|
6
|
+
*/
|
|
7
|
+
export * from "./external.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { ActionStatus, BaseLongPollingArgs } from "@illalabs/interfaces";
|
|
2
|
+
import type { ICoreApiProvider } from "./coreApiProvider.interface.js";
|
|
3
|
+
/**
|
|
4
|
+
* Options required to construct an {@link AsyncToolChecker} instance.
|
|
5
|
+
*/
|
|
6
|
+
export interface AsyncToolCheckerOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Core API provider used to query the execution status of asynchronous tools.
|
|
9
|
+
*/
|
|
10
|
+
readonly coreApiProvider: ICoreApiProvider;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Parameters accepted by {@link AsyncToolChecker.check}.
|
|
14
|
+
*/
|
|
15
|
+
export interface AsyncToolCheckerCheckParams {
|
|
16
|
+
/**
|
|
17
|
+
* Identifies the tool whose execution status should be queried.
|
|
18
|
+
*/
|
|
19
|
+
readonly toolName: string;
|
|
20
|
+
/**
|
|
21
|
+
* Protocol associated with the tool execution.
|
|
22
|
+
*/
|
|
23
|
+
readonly protocol: string;
|
|
24
|
+
/**
|
|
25
|
+
* Descriptor containing the metadata required to track the asynchronous execution.
|
|
26
|
+
*/
|
|
27
|
+
readonly descriptor: BaseLongPollingArgs;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Configuration used to control polling behaviour for continuous status checks.
|
|
31
|
+
*/
|
|
32
|
+
export interface PollingConfig {
|
|
33
|
+
/**
|
|
34
|
+
* Interval, in seconds, between polling attempts.
|
|
35
|
+
*/
|
|
36
|
+
readonly interval: number;
|
|
37
|
+
/**
|
|
38
|
+
* Maximum duration, in seconds, that polling should run before timing out. A value of zero disables the timeout.
|
|
39
|
+
*/
|
|
40
|
+
readonly maxDuration: number;
|
|
41
|
+
/**
|
|
42
|
+
* Backoff threshold, in seconds, used to trigger retry logic for recoverable errors.
|
|
43
|
+
*/
|
|
44
|
+
readonly retryThreshold: number;
|
|
45
|
+
/**
|
|
46
|
+
* Maximum number of retries permitted after transient errors.
|
|
47
|
+
*/
|
|
48
|
+
readonly maxRetries: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Event emitted when the asynchronous tool status changes.
|
|
52
|
+
*/
|
|
53
|
+
export interface StatusChangedEvent<TPayload = unknown, TError = unknown> {
|
|
54
|
+
/**
|
|
55
|
+
* Previous status emitted by the checker.
|
|
56
|
+
*/
|
|
57
|
+
readonly previous: ActionStatus<TPayload, TError> | null;
|
|
58
|
+
/**
|
|
59
|
+
* Current status reported by the Core API.
|
|
60
|
+
*/
|
|
61
|
+
readonly current: ActionStatus<TPayload, TError>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Callback configuration accepted by {@link AsyncToolChecker.subscribe}.
|
|
65
|
+
*/
|
|
66
|
+
export interface AsyncCheckerEvents<TPayload = unknown, TError = unknown> {
|
|
67
|
+
/**
|
|
68
|
+
* Handler invoked whenever the asynchronous status transitions.
|
|
69
|
+
*/
|
|
70
|
+
readonly onStatusChange: (event: StatusChangedEvent<TPayload, TError>) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Optional handler invoked when an unrecoverable error occurs while polling.
|
|
73
|
+
*/
|
|
74
|
+
readonly onError?: (error: unknown) => void;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Represents a cancellable subscription created through {@link AsyncToolChecker.subscribe}.
|
|
78
|
+
*/
|
|
79
|
+
export interface EventSubscription {
|
|
80
|
+
/**
|
|
81
|
+
* Cancels the active subscription and stops further polling attempts.
|
|
82
|
+
*/
|
|
83
|
+
unsubscribe(): void;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=asyncToolChecker.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asyncToolChecker.interface.d.ts","sourceRoot":"","sources":["../../../src/interfaces/asyncToolChecker.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACpC;;OAEG;IACH,QAAQ,CAAC,eAAe,EAAE,gBAAgB,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IACxC;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,mBAAmB,CAAC;CAC5C;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAEhC;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,QAAQ,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO;IACpE;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAEzD;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;CACpD;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,QAAQ,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO;IACpE;;OAEG;IACH,QAAQ,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;IAE/E;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAC/C;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B;;OAEG;IACH,WAAW,IAAI,IAAI,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asyncToolChecker.interface.js","sourceRoot":"","sources":["../../../src/interfaces/asyncToolChecker.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options available when writing a cache entry.
|
|
3
|
+
*/
|
|
4
|
+
export interface CacheEntryOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Time to live for the entry in milliseconds. When omitted the entry lives indefinitely.
|
|
7
|
+
*/
|
|
8
|
+
readonly ttl?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Represents the contract for cache implementations used by the SDK.
|
|
12
|
+
*/
|
|
13
|
+
export interface ICache {
|
|
14
|
+
/**
|
|
15
|
+
* Retrieves a cached value for the provided key.
|
|
16
|
+
*
|
|
17
|
+
* @param key Cache key used to identify the stored value.
|
|
18
|
+
*/
|
|
19
|
+
get<TValue>(key: string): Promise<TValue | undefined>;
|
|
20
|
+
/**
|
|
21
|
+
* Stores a value in the cache.
|
|
22
|
+
*
|
|
23
|
+
* @param key Cache key used to identify the stored value.
|
|
24
|
+
* @param value Value to store in the cache.
|
|
25
|
+
* @param options Additional options such as time to live.
|
|
26
|
+
*/
|
|
27
|
+
set(key: string, value: unknown, options?: CacheEntryOptions): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Removes a cached value for the provided key.
|
|
30
|
+
*
|
|
31
|
+
* @param key Cache key used to identify the stored value.
|
|
32
|
+
*/
|
|
33
|
+
del(key: string): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=cache.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.interface.d.ts","sourceRoot":"","sources":["../../../src/interfaces/cache.interface.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B;;OAEG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,MAAM;IACnB;;;;OAIG;IACH,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAEtD;;;;;;OAMG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7E;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.interface.js","sourceRoot":"","sources":["../../../src/interfaces/cache.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { CoreApiChatBodyRequest, CoreApiChatResponse, MessageHistoryType, ToolAutorouterRequest, UserContext } from "@illalabs/interfaces";
|
|
2
|
+
import type { AsyncToolChecker } from "../asyncToolChecker/index.js";
|
|
3
|
+
import type { PromptRole, PromptSnapshot } from "../prompt/index.js";
|
|
4
|
+
import type { IContextManager } from "./contextManager.interface.js";
|
|
5
|
+
import type { ICoreApiProvider } from "./coreApiProvider.interface.js";
|
|
6
|
+
/**
|
|
7
|
+
* Options used to construct a {@link Chat} instance.
|
|
8
|
+
*/
|
|
9
|
+
export interface ChatOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Optional identifier to assign to the chat instance.
|
|
12
|
+
*
|
|
13
|
+
* When omitted, a random UUID is automatically generated using the Web Crypto API
|
|
14
|
+
* or a compatible polyfill.
|
|
15
|
+
*/
|
|
16
|
+
readonly id?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Core API provider used to communicate with Illa's Core API.
|
|
19
|
+
*/
|
|
20
|
+
readonly coreApiProvider: ICoreApiProvider;
|
|
21
|
+
/**
|
|
22
|
+
* Context manager responsible for persisting chat history and tool configuration.
|
|
23
|
+
*/
|
|
24
|
+
readonly contextManager: IContextManager;
|
|
25
|
+
/**
|
|
26
|
+
* Default role to assign to prompts when building message history entries.
|
|
27
|
+
*/
|
|
28
|
+
readonly defaultRole?: PromptRole;
|
|
29
|
+
/**
|
|
30
|
+
* User context forwarded on every Core API call.
|
|
31
|
+
*/
|
|
32
|
+
readonly userContext: UserContext;
|
|
33
|
+
/**
|
|
34
|
+
* Optional component responsible for monitoring long-running tool executions.
|
|
35
|
+
*/
|
|
36
|
+
readonly asyncToolChecker?: AsyncToolChecker;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Result returned when sending a message through the chat instance.
|
|
40
|
+
*/
|
|
41
|
+
export interface SendMessageResult {
|
|
42
|
+
/**
|
|
43
|
+
* Identifier of the chat instance that processed the message.
|
|
44
|
+
*/
|
|
45
|
+
readonly chatId: string;
|
|
46
|
+
/**
|
|
47
|
+
* The prompt that was sent to the Core API.
|
|
48
|
+
*/
|
|
49
|
+
readonly prompt: CoreApiChatBodyRequest["prompt"];
|
|
50
|
+
/**
|
|
51
|
+
* Snapshot of the original prompt before normalization.
|
|
52
|
+
*/
|
|
53
|
+
readonly promptSnapshot: PromptSnapshot;
|
|
54
|
+
/**
|
|
55
|
+
* Message history including the user's message and any response messages.
|
|
56
|
+
*/
|
|
57
|
+
readonly messages: MessageHistoryType;
|
|
58
|
+
/**
|
|
59
|
+
* Tool configuration used for the request.
|
|
60
|
+
*/
|
|
61
|
+
readonly toolsConfig: ToolAutorouterRequest;
|
|
62
|
+
/**
|
|
63
|
+
* Raw response from the Core API.
|
|
64
|
+
*/
|
|
65
|
+
readonly response: CoreApiChatResponse;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Payload structure for chat requests sent to the Core API.
|
|
69
|
+
*/
|
|
70
|
+
export interface ChatRequestPayload {
|
|
71
|
+
/**
|
|
72
|
+
* Message history to include in the request.
|
|
73
|
+
*/
|
|
74
|
+
readonly messages: MessageHistoryType;
|
|
75
|
+
/**
|
|
76
|
+
* Tool configuration for the request.
|
|
77
|
+
*/
|
|
78
|
+
readonly toolsConfig: ToolAutorouterRequest;
|
|
79
|
+
/**
|
|
80
|
+
* User context information forwarded with the request.
|
|
81
|
+
*/
|
|
82
|
+
readonly userContext: UserContext;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=chat.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.interface.d.ts","sourceRoot":"","sources":["../../../src/interfaces/chat.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,WAAW,EACd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B,CAAC;IAE5C;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;CACrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.interface.js","sourceRoot":"","sources":["../../../src/interfaces/chat.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { MessageHistoryType, ToolAutorouterRequest } from "@illalabs/interfaces";
|
|
2
|
+
import type { CacheEntryOptions } from "./index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Snapshot of the chat context maintained by the SDK.
|
|
5
|
+
*/
|
|
6
|
+
export interface ChatContextSnapshot {
|
|
7
|
+
/**
|
|
8
|
+
* Messages currently stored for the chat session.
|
|
9
|
+
*/
|
|
10
|
+
readonly messages: MessageHistoryType;
|
|
11
|
+
/**
|
|
12
|
+
* Active tools configuration associated with the chat session.
|
|
13
|
+
*/
|
|
14
|
+
readonly toolsConfig: ToolAutorouterRequest;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Options used to configure the {@link ContextManager} behavior.
|
|
18
|
+
*/
|
|
19
|
+
export interface ContextManagerOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Prefix applied to all cache keys.
|
|
22
|
+
*/
|
|
23
|
+
readonly cacheKeyPrefix?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Options forwarded to the underlying cache when persisting state.
|
|
26
|
+
*/
|
|
27
|
+
readonly cacheEntryOptions?: CacheEntryOptions;
|
|
28
|
+
/**
|
|
29
|
+
* Default tools configuration returned when no data is stored yet.
|
|
30
|
+
*/
|
|
31
|
+
readonly defaultToolsConfig?: ToolAutorouterRequest;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Contract for components capable of managing chat context.
|
|
35
|
+
*/
|
|
36
|
+
export interface IContextManager {
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves the full context for a given chat.
|
|
39
|
+
*
|
|
40
|
+
* @param chatId Identifier of the chat session.
|
|
41
|
+
*
|
|
42
|
+
* @returns Stored messages and tools configuration.
|
|
43
|
+
*/
|
|
44
|
+
getContext(chatId: string): Promise<ChatContextSnapshot>;
|
|
45
|
+
/**
|
|
46
|
+
* Replaces the entire message history with the provided messages.
|
|
47
|
+
*
|
|
48
|
+
* Use this method when:
|
|
49
|
+
* - Storing the full conversation history returned by the Core API
|
|
50
|
+
* - Replacing the context with a complete message set
|
|
51
|
+
*
|
|
52
|
+
* @param chatId Identifier of the chat session.
|
|
53
|
+
* @param messages Complete message history to store.
|
|
54
|
+
*/
|
|
55
|
+
setMessages(chatId: string, messages: MessageHistoryType): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Appends new message entries to the existing chat history.
|
|
58
|
+
*
|
|
59
|
+
* Use this method when:
|
|
60
|
+
* - Adding messages that are known to be new (not already in context)
|
|
61
|
+
* - Building up a conversation incrementally
|
|
62
|
+
*
|
|
63
|
+
* Note: This method does NOT deduplicate messages. If the messages being
|
|
64
|
+
* appended already exist in the context, they will be duplicated. When
|
|
65
|
+
* working with Core API responses that return full conversation history,
|
|
66
|
+
* use {@link setMessages} instead.
|
|
67
|
+
*
|
|
68
|
+
* @param chatId Identifier of the chat session.
|
|
69
|
+
* @param messages New messages to append to existing history.
|
|
70
|
+
*/
|
|
71
|
+
appendMessages(chatId: string, messages: MessageHistoryType): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Persists the tools configuration associated with the chat.
|
|
74
|
+
*
|
|
75
|
+
* @param chatId Identifier of the chat session.
|
|
76
|
+
* @param toolsConfig Tools configuration to store.
|
|
77
|
+
*/
|
|
78
|
+
setToolsConfig(chatId: string, toolsConfig: ToolAutorouterRequest): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Clears all persisted data associated with the chat.
|
|
81
|
+
*
|
|
82
|
+
* @param chatId Identifier of the chat session.
|
|
83
|
+
*/
|
|
84
|
+
deleteContext(chatId: string): Promise<void>;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=contextManager.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextManager.interface.d.ts","sourceRoot":"","sources":["../../../src/interfaces/contextManager.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAEtF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IAEtC;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,qBAAqB,CAAC;CAC/C;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC;;OAEG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAEjC;;OAEG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IAE/C;;OAEG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,qBAAqB,CAAC;CACvD;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B;;;;;;OAMG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAEzD;;;;;;;;;OASG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzE;;;;;;;;;;;;;;OAcG;IACH,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5E;;;;;OAKG;IACH,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAElF;;;;OAIG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextManager.interface.js","sourceRoot":"","sources":["../../../src/interfaces/contextManager.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CoreApiChatRequest, CoreApiChatResponse, LongPollingActionRequest, LongPollingActionResponse } from "@illalabs/interfaces";
|
|
2
|
+
import type { CoreApiProviderRoutes, RequestOptions } from "../providers/coreApiProvider/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Contract for the Core API provider
|
|
5
|
+
*/
|
|
6
|
+
export interface ICoreApiProvider {
|
|
7
|
+
/**
|
|
8
|
+
* Sends a chat request to the Core API
|
|
9
|
+
*
|
|
10
|
+
* @param request Chat request payload
|
|
11
|
+
* @param options Additional request options such as cancellation support
|
|
12
|
+
*
|
|
13
|
+
* @returns Core API chat response
|
|
14
|
+
*/
|
|
15
|
+
sendMessage(request: CoreApiChatRequest["body"], options?: RequestOptions): Promise<CoreApiChatResponse>;
|
|
16
|
+
/**
|
|
17
|
+
* Checks the status of a long running action
|
|
18
|
+
*
|
|
19
|
+
* @param request Long polling request parameters
|
|
20
|
+
* @param options Additional request options such as cancellation support
|
|
21
|
+
*
|
|
22
|
+
* @returns Core API execution checker response
|
|
23
|
+
*/
|
|
24
|
+
awaitTransaction(request: LongPollingActionRequest["params"], options?: RequestOptions): Promise<LongPollingActionResponse>;
|
|
25
|
+
/**
|
|
26
|
+
* Retrieves the configured routes for the Core API endpoints used by the provider.
|
|
27
|
+
*
|
|
28
|
+
* @returns Route configuration including chat and action status paths.
|
|
29
|
+
*/
|
|
30
|
+
getRoutes(): Required<CoreApiProviderRoutes>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=coreApiProvider.interface.d.ts.map
|
|
@@ -0,0 +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,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAEnG;;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;;;;;;;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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coreApiProvider.interface.js","sourceRoot":"","sources":["../../../src/interfaces/coreApiProvider.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { ICoreApiProvider } from "./coreApiProvider.interface.js";
|
|
2
|
+
export type { CacheEntryOptions, ICache } from "./cache.interface.js";
|
|
3
|
+
export type { ChatContextSnapshot, ContextManagerOptions, IContextManager, } from "./contextManager.interface.js";
|
|
4
|
+
export type { AsyncCheckerEvents, AsyncToolCheckerCheckParams, AsyncToolCheckerOptions, EventSubscription, PollingConfig, StatusChangedEvent, } from "./asyncToolChecker.interface.js";
|
|
5
|
+
export type { AsyncToolChecker, AwaitActionResult, AwaitableActionDescriptor, } from "../asyncToolChecker/index.js";
|
|
6
|
+
export type { ChatOptions, ChatRequestPayload, SendMessageResult } from "./chat.interface.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,EAAE,WAAW,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal exports for the Illa SDK package
|
|
3
|
+
*
|
|
4
|
+
* This file includes all public exports plus any internal utilities
|
|
5
|
+
* needed for testing and development. External consumers should use
|
|
6
|
+
* the main index.ts entry point instead.
|
|
7
|
+
*/
|
|
8
|
+
export * from "./caching/index.js";
|
|
9
|
+
export * from "./chat/index.js";
|
|
10
|
+
export * from "./context/index.js";
|
|
11
|
+
export * from "./external.js";
|
|
12
|
+
export * from "./prompt/index.js";
|
|
13
|
+
export * from "./asyncToolChecker/index.js";
|
|
14
|
+
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -0,0 +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,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC"}
|