@illalabs/sdk 0.0.0 → 0.1.0-canary.9fc2c20f
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 +256 -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 +64 -0
- package/dist/src/chat/Chat.d.ts.map +1 -0
- package/dist/src/chat/Chat.js +129 -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/UserContextMissing.d.ts +10 -0
- package/dist/src/chat/errors/UserContextMissing.d.ts.map +1 -0
- package/dist/src/chat/errors/UserContextMissing.js +13 -0
- package/dist/src/chat/errors/UserContextMissing.js.map +1 -0
- package/dist/src/chat/errors/index.d.ts +3 -0
- package/dist/src/chat/errors/index.d.ts.map +1 -0
- package/dist/src/chat/errors/index.js +3 -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 +7 -0
- package/dist/src/external.d.ts.map +1 -0
- package/dist/src/external.js +7 -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 +15 -0
- package/dist/src/internal.d.ts.map +1 -0
- package/dist/src/internal.js +15 -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/CoreApiErrorHandler.d.ts +13 -0
- package/dist/src/providers/coreApiProvider/CoreApiErrorHandler.d.ts.map +1 -0
- package/dist/src/providers/coreApiProvider/CoreApiErrorHandler.js +67 -0
- package/dist/src/providers/coreApiProvider/CoreApiErrorHandler.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 +97 -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/dist/src/sdk.d.ts +288 -0
- package/dist/src/sdk.d.ts.map +1 -0
- package/dist/src/sdk.js +287 -0
- package/dist/src/sdk.js.map +1 -0
- package/package.json +42 -5
- package/index.d.ts +0 -1
- package/index.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AsyncToolCheckerTimeout.d.ts","sourceRoot":"","sources":["../../../../src/asyncToolChecker/errors/AsyncToolCheckerTimeout.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IAC9C;;OAEG;IACH,SAAgB,WAAW,EAAE,MAAM,CAAC;IAEpC;;;;;OAKG;gBACgB,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAKjE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error emitted when an asynchronous polling operation exceeds the configured maximum duration.
|
|
3
|
+
*/
|
|
4
|
+
export class AsyncToolCheckerTimeout extends Error {
|
|
5
|
+
/**
|
|
6
|
+
* Maximum duration, expressed in seconds, that was exceeded.
|
|
7
|
+
*/
|
|
8
|
+
maxDuration;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new {@link AsyncToolCheckerTimeout} instance.
|
|
11
|
+
*
|
|
12
|
+
* @param maxDuration Maximum duration, in seconds, permitted for the polling loop.
|
|
13
|
+
* @param options Error options.
|
|
14
|
+
*/
|
|
15
|
+
constructor(maxDuration, options) {
|
|
16
|
+
super(`Async tool checker exceeded maximum duration of ${maxDuration} seconds.`, options);
|
|
17
|
+
this.name = "AsyncToolCheckerTimeout";
|
|
18
|
+
this.maxDuration = maxDuration;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=AsyncToolCheckerTimeout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AsyncToolCheckerTimeout.js","sourceRoot":"","sources":["../../../../src/asyncToolChecker/errors/AsyncToolCheckerTimeout.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAC9C;;OAEG;IACa,WAAW,CAAS;IAEpC;;;;;OAKG;IACH,YAAmB,WAAmB,EAAE,OAAsB;QAC1D,KAAK,CAAC,mDAAmD,WAAW,WAAW,EAAE,OAAO,CAAC,CAAC;QAC1F,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACnC,CAAC;CACJ"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { AsyncToolCheckerMethodNotImplemented } from "./AsyncToolCheckerMethodNotImplemented.js";
|
|
2
|
+
export { AsyncToolCheckerTimeout } from "./AsyncToolCheckerTimeout.js";
|
|
3
|
+
export { AsyncToolCheckerMaxRetriesExceeded } from "./AsyncToolCheckerMaxRetriesExceeded.js";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/asyncToolChecker/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,MAAM,2CAA2C,CAAC;AACjG,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,kCAAkC,EAAE,MAAM,yCAAyC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { AsyncToolCheckerMethodNotImplemented } from "./AsyncToolCheckerMethodNotImplemented.js";
|
|
2
|
+
export { AsyncToolCheckerTimeout } from "./AsyncToolCheckerTimeout.js";
|
|
3
|
+
export { AsyncToolCheckerMaxRetriesExceeded } from "./AsyncToolCheckerMaxRetriesExceeded.js";
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/asyncToolChecker/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,MAAM,2CAA2C,CAAC;AACjG,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,kCAAkC,EAAE,MAAM,yCAAyC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { AsyncToolChecker } from "./AsyncToolChecker.js";
|
|
2
|
+
export type { AsyncCheckerEvents, AsyncToolCheckerCheckParams, AsyncToolCheckerOptions, EventSubscription, PollingConfig, StatusChangedEvent, } from "../interfaces/index.js";
|
|
3
|
+
export { AsyncToolCheckerMaxRetriesExceeded, AsyncToolCheckerMethodNotImplemented, AsyncToolCheckerTimeout, } from "./errors/index.js";
|
|
4
|
+
export * from "./types.js";
|
|
5
|
+
export * from "./utils/index.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/asyncToolChecker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,YAAY,EACR,kBAAkB,EAClB,2BAA2B,EAC3B,uBAAuB,EACvB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,GACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACH,kCAAkC,EAClC,oCAAoC,EACpC,uBAAuB,GAC1B,MAAM,mBAAmB,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { AsyncToolChecker } from "./AsyncToolChecker.js";
|
|
2
|
+
export { AsyncToolCheckerMaxRetriesExceeded, AsyncToolCheckerMethodNotImplemented, AsyncToolCheckerTimeout, } from "./errors/index.js";
|
|
3
|
+
export * from "./types.js";
|
|
4
|
+
export * from "./utils/index.js";
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/asyncToolChecker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AASzD,OAAO,EACH,kCAAkC,EAClC,oCAAoC,EACpC,uBAAuB,GAC1B,MAAM,mBAAmB,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ActionStatus, BaseLongPollingArgs, LongPollingActionErrorResponse, LongPollingActionParams } from "@illalabs/interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* Descriptor containing parameters for an action whose execution can be awaited.
|
|
4
|
+
*/
|
|
5
|
+
export type AwaitableActionDescriptor<T extends BaseLongPollingArgs = BaseLongPollingArgs> = LongPollingActionParams<T>;
|
|
6
|
+
/**
|
|
7
|
+
* Successful result emitted after awaiting a long running tool execution.
|
|
8
|
+
*/
|
|
9
|
+
export type AwaitActionSuccess<TPayload = unknown, TError = unknown> = {
|
|
10
|
+
readonly isError: false;
|
|
11
|
+
readonly response: ActionStatus<TPayload, TError>;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Error result emitted when awaiting a long running tool execution fails.
|
|
15
|
+
*/
|
|
16
|
+
export type AwaitActionFailure = {
|
|
17
|
+
readonly isError: true;
|
|
18
|
+
readonly error: LongPollingActionErrorResponse;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Discriminated union representing the result of awaiting a long running tool execution.
|
|
22
|
+
*/
|
|
23
|
+
export type AwaitActionResult<TPayload = unknown, TError = unknown> = AwaitActionSuccess<TPayload, TError> | AwaitActionFailure;
|
|
24
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/asyncToolChecker/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,YAAY,EACZ,mBAAmB,EACnB,8BAA8B,EAC9B,uBAAuB,EAC1B,MAAM,sBAAsB,CAAC;AAE9B;;GAEG;AACH,MAAM,MAAM,yBAAyB,CAAC,CAAC,SAAS,mBAAmB,GAAG,mBAAmB,IACrF,uBAAuB,CAAC,CAAC,CAAC,CAAC;AAE/B;;GAEG;AACH,MAAM,MAAM,kBAAkB,CAAC,QAAQ,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,IAAI;IACnE,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;CACrD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC7B,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,8BAA8B,CAAC;CAClD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,QAAQ,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,IAC5D,kBAAkB,CAAC,QAAQ,EAAE,MAAM,CAAC,GACpC,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/asyncToolChecker/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/asyncToolChecker/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/asyncToolChecker/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { LongPollingActionErrorResponse, LongPollingActionResponse } from "@illalabs/interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to determine if a long polling response represents an error state.
|
|
4
|
+
*
|
|
5
|
+
* @typeParam TPayload - Payload type associated with successful responses.
|
|
6
|
+
* @param response Response from the Core API long polling endpoint.
|
|
7
|
+
*
|
|
8
|
+
* @returns True if the response contains an error, false otherwise.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isErrorResponse<TPayload = unknown>(response: LongPollingActionResponse<TPayload>): response is LongPollingActionErrorResponse;
|
|
11
|
+
//# sourceMappingURL=isErrorResponse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isErrorResponse.d.ts","sourceRoot":"","sources":["../../../../src/asyncToolChecker/utils/isErrorResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,8BAA8B,EAC9B,yBAAyB,EAC5B,MAAM,sBAAsB,CAAC;AAE9B;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,QAAQ,GAAG,OAAO,EAC9C,QAAQ,EAAE,yBAAyB,CAAC,QAAQ,CAAC,GAC9C,QAAQ,IAAI,8BAA8B,CAE5C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard to determine if a long polling response represents an error state.
|
|
3
|
+
*
|
|
4
|
+
* @typeParam TPayload - Payload type associated with successful responses.
|
|
5
|
+
* @param response Response from the Core API long polling endpoint.
|
|
6
|
+
*
|
|
7
|
+
* @returns True if the response contains an error, false otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export function isErrorResponse(response) {
|
|
10
|
+
return response.statusCode !== undefined;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=isErrorResponse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isErrorResponse.js","sourceRoot":"","sources":["../../../../src/asyncToolChecker/utils/isErrorResponse.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC3B,QAA6C;IAE7C,OAAQ,QAA2C,CAAC,UAAU,KAAK,SAAS,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes a timeout value expressed in seconds.
|
|
3
|
+
*
|
|
4
|
+
* @param value Timeout expressed in seconds.
|
|
5
|
+
*
|
|
6
|
+
* @returns Timeout converted to milliseconds. Values less than zero are coerced to zero.
|
|
7
|
+
*/
|
|
8
|
+
export declare function normalizeTimeout(value: number): number;
|
|
9
|
+
//# sourceMappingURL=normalizeTimeout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeTimeout.d.ts","sourceRoot":"","sources":["../../../../src/asyncToolChecker/utils/normalizeTimeout.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMtD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes a timeout value expressed in seconds.
|
|
3
|
+
*
|
|
4
|
+
* @param value Timeout expressed in seconds.
|
|
5
|
+
*
|
|
6
|
+
* @returns Timeout converted to milliseconds. Values less than zero are coerced to zero.
|
|
7
|
+
*/
|
|
8
|
+
export function normalizeTimeout(value) {
|
|
9
|
+
if (!Number.isFinite(value)) {
|
|
10
|
+
return 0;
|
|
11
|
+
}
|
|
12
|
+
return Math.max(0, value) * 1000;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=normalizeTimeout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeTimeout.js","sourceRoot":"","sources":["../../../../src/asyncToolChecker/utils/normalizeTimeout.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC1C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,CAAC,CAAC;IACb,CAAC;IAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CacheEntryOptions, ICache } from "../interfaces/cache.interface.js";
|
|
2
|
+
/**
|
|
3
|
+
* Default cache implementation that keeps values in memory.
|
|
4
|
+
*/
|
|
5
|
+
export declare class InMemoryCache implements ICache {
|
|
6
|
+
private readonly store;
|
|
7
|
+
/** @inheritdoc */
|
|
8
|
+
get<TValue>(key: string): Promise<TValue | undefined>;
|
|
9
|
+
/** @inheritdoc */
|
|
10
|
+
set(key: string, value: unknown, options?: CacheEntryOptions): Promise<void>;
|
|
11
|
+
/** @inheritdoc */
|
|
12
|
+
del(key: string): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=InMemoryCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InMemoryCache.d.ts","sourceRoot":"","sources":["../../../src/caching/InMemoryCache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAMlF;;GAEG;AACH,qBAAa,aAAc,YAAW,MAAM;IACxC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA2C;IAEjE,kBAAkB;IACL,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAclE,kBAAkB;IACL,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAS7F,kBAAkB;IACL,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG/C"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default cache implementation that keeps values in memory.
|
|
3
|
+
*/
|
|
4
|
+
export class InMemoryCache {
|
|
5
|
+
store = new Map();
|
|
6
|
+
/** @inheritdoc */
|
|
7
|
+
async get(key) {
|
|
8
|
+
const entry = this.store.get(key);
|
|
9
|
+
if (entry === undefined) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
if (entry.expiresAt !== undefined && entry.expiresAt <= Date.now()) {
|
|
13
|
+
this.store.delete(key);
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
return entry.value;
|
|
17
|
+
}
|
|
18
|
+
/** @inheritdoc */
|
|
19
|
+
async set(key, value, options = {}) {
|
|
20
|
+
const expiresAt = options.ttl !== undefined ? Date.now() + options.ttl : undefined;
|
|
21
|
+
this.store.set(key, {
|
|
22
|
+
value,
|
|
23
|
+
expiresAt,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/** @inheritdoc */
|
|
27
|
+
async del(key) {
|
|
28
|
+
this.store.delete(key);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=InMemoryCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InMemoryCache.js","sourceRoot":"","sources":["../../../src/caching/InMemoryCache.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,OAAO,aAAa;IACL,KAAK,GAAG,IAAI,GAAG,EAAgC,CAAC;IAEjE,kBAAkB;IACX,KAAK,CAAC,GAAG,CAAS,GAAW;QAChC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACtB,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS,IAAI,KAAK,CAAC,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;YACjE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACvB,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,OAAO,KAAK,CAAC,KAAe,CAAC;IACjC,CAAC;IAED,kBAAkB;IACX,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAc,EAAE,UAA6B,EAAE;QACzE,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;QAEnF,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE;YAChB,KAAK;YACL,SAAS;SACZ,CAAC,CAAC;IACP,CAAC;IAED,kBAAkB;IACX,KAAK,CAAC,GAAG,CAAC,GAAW;QACxB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/caching/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/caching/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { MessageHistoryType } from "@illalabs/interfaces";
|
|
2
|
+
import type { AwaitableActionDescriptor, AwaitActionResult } from "../asyncToolChecker/index.js";
|
|
3
|
+
import type { ChatContextSnapshot, ChatOptions, SendMessageResult } from "../interfaces/index.js";
|
|
4
|
+
import type { Prompt } from "../prompt/index.js";
|
|
5
|
+
/**
|
|
6
|
+
* Represents a conversational session with the Illa Core API.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Chat {
|
|
9
|
+
private readonly id;
|
|
10
|
+
private readonly coreApiProvider;
|
|
11
|
+
private readonly contextManager;
|
|
12
|
+
private readonly asyncToolChecker?;
|
|
13
|
+
private readonly defaultRole;
|
|
14
|
+
private readonly userContext;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new {@link Chat} instance.
|
|
17
|
+
*
|
|
18
|
+
* @param options Chat construction options including dependencies.
|
|
19
|
+
*/
|
|
20
|
+
constructor(options: ChatOptions);
|
|
21
|
+
/**
|
|
22
|
+
* Retrieves the identifier associated with this chat instance.
|
|
23
|
+
*
|
|
24
|
+
* @returns Chat identifier.
|
|
25
|
+
*/
|
|
26
|
+
getId(): string;
|
|
27
|
+
get messages(): Promise<MessageHistoryType>;
|
|
28
|
+
/**
|
|
29
|
+
* Sends a prompt to the Core API and returns the processed result.
|
|
30
|
+
*
|
|
31
|
+
* @param prompt Prompt instance representing the message to be processed.
|
|
32
|
+
*
|
|
33
|
+
* @returns Structured chat result containing the processed response.
|
|
34
|
+
*/
|
|
35
|
+
sendMessage(prompt: Prompt): Promise<SendMessageResult>;
|
|
36
|
+
private buildRequest;
|
|
37
|
+
private static isSuccessResponse;
|
|
38
|
+
/**
|
|
39
|
+
* Awaits the completion of a long running action triggered by the conversation.
|
|
40
|
+
*
|
|
41
|
+
* When the chat has no async tool checker configured, the method throws a
|
|
42
|
+
* {@link ChatAsyncToolCheckerUnavailable} error; otherwise it delegates the
|
|
43
|
+
* request to the checker and returns its result.
|
|
44
|
+
*
|
|
45
|
+
* @param descriptor Descriptor identifying the action to track.
|
|
46
|
+
*
|
|
47
|
+
* @throws {ChatAsyncToolCheckerUnavailable} When no async tool checker is configured.
|
|
48
|
+
*
|
|
49
|
+
* @returns Action status result emitted by the async tool checker.
|
|
50
|
+
*/
|
|
51
|
+
awaitAction(descriptor: AwaitableActionDescriptor): Promise<AwaitActionResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Retrieves the current chat context including messages and tool configuration. *
|
|
54
|
+
* @returns Snapshot of the chat context.
|
|
55
|
+
*/
|
|
56
|
+
getContext(): Promise<ChatContextSnapshot>;
|
|
57
|
+
/**
|
|
58
|
+
* Replaces the persisted chat context with the provided snapshot.
|
|
59
|
+
*
|
|
60
|
+
* @param snapshot Context snapshot to store.
|
|
61
|
+
*/
|
|
62
|
+
setContext(snapshot: ChatContextSnapshot): Promise<void>;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=Chat.d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IxE"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { ChatAsyncToolCheckerUnavailable } from "./errors/index.js";
|
|
2
|
+
import { generateUUID } from "./utils/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Represents a conversational session with the Illa Core API.
|
|
5
|
+
*/
|
|
6
|
+
export class Chat {
|
|
7
|
+
id;
|
|
8
|
+
coreApiProvider;
|
|
9
|
+
contextManager;
|
|
10
|
+
asyncToolChecker;
|
|
11
|
+
defaultRole;
|
|
12
|
+
userContext;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new {@link Chat} instance.
|
|
15
|
+
*
|
|
16
|
+
* @param options Chat construction options including dependencies.
|
|
17
|
+
*/
|
|
18
|
+
constructor(options) {
|
|
19
|
+
this.id = options.id ?? generateUUID();
|
|
20
|
+
this.coreApiProvider = options.coreApiProvider;
|
|
21
|
+
this.contextManager = options.contextManager;
|
|
22
|
+
this.asyncToolChecker = options.asyncToolChecker;
|
|
23
|
+
this.defaultRole = options.defaultRole ?? "user";
|
|
24
|
+
this.userContext = options.userContext;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Retrieves the identifier associated with this chat instance.
|
|
28
|
+
*
|
|
29
|
+
* @returns Chat identifier.
|
|
30
|
+
*/
|
|
31
|
+
getId() {
|
|
32
|
+
return this.id;
|
|
33
|
+
}
|
|
34
|
+
get messages() {
|
|
35
|
+
return this.contextManager.getContext(this.id).then((context) => context.messages);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Sends a prompt to the Core API and returns the processed result.
|
|
39
|
+
*
|
|
40
|
+
* @param prompt Prompt instance representing the message to be processed.
|
|
41
|
+
*
|
|
42
|
+
* @returns Structured chat result containing the processed response.
|
|
43
|
+
*/
|
|
44
|
+
async sendMessage(prompt) {
|
|
45
|
+
const promptSnapshot = prompt.getSnapshot();
|
|
46
|
+
const normalizedPrompt = prompt.getNormalizedSnapshot(this.defaultRole);
|
|
47
|
+
const originalContext = await this.contextManager.getContext(this.id);
|
|
48
|
+
const { body, messages: stagedMessages } = this.buildRequest(originalContext, normalizedPrompt);
|
|
49
|
+
const response = await this.coreApiProvider.sendMessage(body);
|
|
50
|
+
if (!Chat.isSuccessResponse(response)) {
|
|
51
|
+
return {
|
|
52
|
+
chatId: this.id,
|
|
53
|
+
prompt: body.prompt,
|
|
54
|
+
promptSnapshot,
|
|
55
|
+
messages: stagedMessages,
|
|
56
|
+
toolsConfig: originalContext.toolsConfig,
|
|
57
|
+
response,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
await this.contextManager.setMessages(this.id, response.messages);
|
|
61
|
+
await this.contextManager.setToolsConfig(this.id, originalContext.toolsConfig);
|
|
62
|
+
return {
|
|
63
|
+
chatId: this.id,
|
|
64
|
+
prompt: body.prompt,
|
|
65
|
+
promptSnapshot,
|
|
66
|
+
messages: response.messages,
|
|
67
|
+
toolsConfig: originalContext.toolsConfig,
|
|
68
|
+
response,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
buildRequest(context, normalizedPrompt) {
|
|
72
|
+
return {
|
|
73
|
+
body: {
|
|
74
|
+
toolsConfig: context.toolsConfig,
|
|
75
|
+
messages: context.messages,
|
|
76
|
+
userContext: this.userContext,
|
|
77
|
+
prompt: normalizedPrompt.message,
|
|
78
|
+
},
|
|
79
|
+
messages: context.messages,
|
|
80
|
+
toolsConfig: context.toolsConfig,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
static isSuccessResponse(response) {
|
|
84
|
+
return "status" in response && response.status === 200;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Awaits the completion of a long running action triggered by the conversation.
|
|
88
|
+
*
|
|
89
|
+
* When the chat has no async tool checker configured, the method throws a
|
|
90
|
+
* {@link ChatAsyncToolCheckerUnavailable} error; otherwise it delegates the
|
|
91
|
+
* request to the checker and returns its result.
|
|
92
|
+
*
|
|
93
|
+
* @param descriptor Descriptor identifying the action to track.
|
|
94
|
+
*
|
|
95
|
+
* @throws {ChatAsyncToolCheckerUnavailable} When no async tool checker is configured.
|
|
96
|
+
*
|
|
97
|
+
* @returns Action status result emitted by the async tool checker.
|
|
98
|
+
*/
|
|
99
|
+
async awaitAction(descriptor) {
|
|
100
|
+
if (this.asyncToolChecker === undefined) {
|
|
101
|
+
throw new ChatAsyncToolCheckerUnavailable({
|
|
102
|
+
chatId: this.getId(),
|
|
103
|
+
descriptor,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return this.asyncToolChecker.check({
|
|
107
|
+
toolName: descriptor.toolName,
|
|
108
|
+
protocol: descriptor.protocol,
|
|
109
|
+
descriptor: descriptor.args,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Retrieves the current chat context including messages and tool configuration. *
|
|
114
|
+
* @returns Snapshot of the chat context.
|
|
115
|
+
*/
|
|
116
|
+
async getContext() {
|
|
117
|
+
return this.contextManager.getContext(this.id);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Replaces the persisted chat context with the provided snapshot.
|
|
121
|
+
*
|
|
122
|
+
* @param snapshot Context snapshot to store.
|
|
123
|
+
*/
|
|
124
|
+
async setContext(snapshot) {
|
|
125
|
+
await this.contextManager.setMessages(this.id, snapshot.messages);
|
|
126
|
+
await this.contextManager.setToolsConfig(this.id, snapshot.toolsConfig);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=Chat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Chat.js","sourceRoot":"","sources":["../../../src/chat/Chat.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;GAEG;AACH,MAAM,OAAO,IAAI;IACI,EAAE,CAAS;IAEX,eAAe,CAAmB;IAElC,cAAc,CAAkB;IAEhC,gBAAgB,CAA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AI,+BAA+B,CAAC;gBACtC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE;gBACpB,UAAU;aACb,CAAC,CAAC;QACP,CAAC;QAED,OAAO,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC;YAC/B,QAAQ,EAAE,UAAU,CAAC,QAAQ;YAC7B,QAAQ,EAAE,UAAU,CAAC,QAAQ;YAC7B,UAAU,EAAE,UAAU,CAAC,IAAI;SAC9B,CAAC,CAAC;IACP,CAAC;IAED;;;OAGG;IACI,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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error emitted when attempting to await an action without configuring an async tool checker.
|
|
3
|
+
*
|
|
4
|
+
* The error may include a `context` property with additional debugging information
|
|
5
|
+
* such as the `chatId` and the original `descriptor` of the awaited action.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ChatAsyncToolCheckerUnavailable extends Error {
|
|
8
|
+
/**
|
|
9
|
+
* Optional context describing the awaited action and chat details.
|
|
10
|
+
*/
|
|
11
|
+
readonly context?: unknown;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new {@link ChatAsyncToolCheckerUnavailable} instance.
|
|
14
|
+
*
|
|
15
|
+
* @param context Additional context useful for debugging, e.g. `{ chatId: string, descriptor: unknown }`.
|
|
16
|
+
*/
|
|
17
|
+
constructor(context?: unknown);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=ChatAsyncToolCheckerUnavailable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatAsyncToolCheckerUnavailable.d.ts","sourceRoot":"","sources":["../../../../src/chat/errors/ChatAsyncToolCheckerUnavailable.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,+BAAgC,SAAQ,KAAK;IACtD;;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 await an action without configuring an async tool checker.
|
|
3
|
+
*
|
|
4
|
+
* The error may include a `context` property with additional debugging information
|
|
5
|
+
* such as the `chatId` and the original `descriptor` of the awaited action.
|
|
6
|
+
*/
|
|
7
|
+
export class ChatAsyncToolCheckerUnavailable extends Error {
|
|
8
|
+
/**
|
|
9
|
+
* Optional context describing the awaited action and chat details.
|
|
10
|
+
*/
|
|
11
|
+
context;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new {@link ChatAsyncToolCheckerUnavailable} instance.
|
|
14
|
+
*
|
|
15
|
+
* @param context Additional context useful for debugging, e.g. `{ chatId: string, descriptor: unknown }`.
|
|
16
|
+
*/
|
|
17
|
+
constructor(context) {
|
|
18
|
+
super("Chat awaitAction requires an async tool checker to be configured.");
|
|
19
|
+
this.name = "ChatAsyncToolCheckerUnavailable";
|
|
20
|
+
if (context !== undefined) {
|
|
21
|
+
Object.defineProperty(this, "context", {
|
|
22
|
+
value: context,
|
|
23
|
+
enumerable: true,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=ChatAsyncToolCheckerUnavailable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatAsyncToolCheckerUnavailable.js","sourceRoot":"","sources":["../../../../src/chat/errors/ChatAsyncToolCheckerUnavailable.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,OAAO,+BAAgC,SAAQ,KAAK;IACtD;;OAEG;IACa,OAAO,CAAW;IAElC;;;;OAIG;IACH,YAAmB,OAAiB;QAChC,KAAK,CAAC,mEAAmE,CAAC,CAAC;QAC3E,IAAI,CAAC,IAAI,GAAG,iCAAiC,CAAC;QAC9C,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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error raised when a user context is not provided when creating a new chat.
|
|
3
|
+
*/
|
|
4
|
+
export declare class UserContextMissing extends Error {
|
|
5
|
+
/**
|
|
6
|
+
* Creates a new {@link UserContextMissing} instance.
|
|
7
|
+
*/
|
|
8
|
+
constructor();
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=UserContextMissing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserContextMissing.d.ts","sourceRoot":"","sources":["../../../../src/chat/errors/UserContextMissing.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IACzC;;OAEG;;CAKN"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error raised when a user context is not provided when creating a new chat.
|
|
3
|
+
*/
|
|
4
|
+
export class UserContextMissing extends Error {
|
|
5
|
+
/**
|
|
6
|
+
* Creates a new {@link UserContextMissing} instance.
|
|
7
|
+
*/
|
|
8
|
+
constructor() {
|
|
9
|
+
super("User context is required to create a new chat");
|
|
10
|
+
this.name = "UserContextMissing";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=UserContextMissing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserContextMissing.js","sourceRoot":"","sources":["../../../../src/chat/errors/UserContextMissing.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IACzC;;OAEG;IACH;QACI,KAAK,CAAC,+CAA+C,CAAC,CAAC;QACvD,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACrC,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/chat/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/chat/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/chat/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,cAAc,mBAAmB,CAAC;AAClC,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/chat/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ChatContextSnapshot } from "../interfaces/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Context replacement payload accepted by the chat facade.
|
|
4
|
+
*
|
|
5
|
+
* This type re-exports the existing {@link ChatContextSnapshot} for improved discoverability
|
|
6
|
+
* when working within the chat module.
|
|
7
|
+
*/
|
|
8
|
+
export type ChatContextInput = ChatContextSnapshot;
|
|
9
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/chat/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAElE;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,mBAAmB,CAAC"}
|