@illalabs/sdk 0.1.0 → 0.3.0

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.
Files changed (66) hide show
  1. package/README.md +258 -0
  2. package/dist/src/chat/Chat.d.ts +3 -0
  3. package/dist/src/chat/Chat.d.ts.map +1 -1
  4. package/dist/src/chat/Chat.js +14 -2
  5. package/dist/src/chat/Chat.js.map +1 -1
  6. package/dist/src/chat/errors/UserContextMissing.d.ts +10 -0
  7. package/dist/src/chat/errors/UserContextMissing.d.ts.map +1 -0
  8. package/dist/src/chat/errors/UserContextMissing.js +13 -0
  9. package/dist/src/chat/errors/UserContextMissing.js.map +1 -0
  10. package/dist/src/chat/errors/index.d.ts +1 -0
  11. package/dist/src/chat/errors/index.d.ts.map +1 -1
  12. package/dist/src/chat/errors/index.js +1 -0
  13. package/dist/src/chat/errors/index.js.map +1 -1
  14. package/dist/src/external.d.ts +2 -9
  15. package/dist/src/external.d.ts.map +1 -1
  16. package/dist/src/external.js +2 -8
  17. package/dist/src/external.js.map +1 -1
  18. package/dist/src/interfaces/chat.interface.d.ts +12 -2
  19. package/dist/src/interfaces/chat.interface.d.ts.map +1 -1
  20. package/dist/src/interfaces/coreApiProvider.interface.d.ts +7 -1
  21. package/dist/src/interfaces/coreApiProvider.interface.d.ts.map +1 -1
  22. package/dist/src/internal.d.ts +2 -1
  23. package/dist/src/internal.d.ts.map +1 -1
  24. package/dist/src/internal.js +2 -1
  25. package/dist/src/internal.js.map +1 -1
  26. package/dist/src/providers/coreApiProvider/CoreApiErrorHandler.d.ts +13 -0
  27. package/dist/src/providers/coreApiProvider/CoreApiErrorHandler.d.ts.map +1 -0
  28. package/dist/src/providers/coreApiProvider/CoreApiErrorHandler.js +67 -0
  29. package/dist/src/providers/coreApiProvider/CoreApiErrorHandler.js.map +1 -0
  30. package/dist/src/providers/coreApiProvider/CoreApiProvider.d.ts +9 -2
  31. package/dist/src/providers/coreApiProvider/CoreApiProvider.d.ts.map +1 -1
  32. package/dist/src/providers/coreApiProvider/CoreApiProvider.js +40 -36
  33. package/dist/src/providers/coreApiProvider/CoreApiProvider.js.map +1 -1
  34. package/dist/src/providers/coreApiProvider/errors/CoreApiAuthenticationMissing.d.ts +2 -4
  35. package/dist/src/providers/coreApiProvider/errors/CoreApiAuthenticationMissing.d.ts.map +1 -1
  36. package/dist/src/providers/coreApiProvider/errors/CoreApiAuthenticationMissing.js +7 -6
  37. package/dist/src/providers/coreApiProvider/errors/CoreApiAuthenticationMissing.js.map +1 -1
  38. package/dist/src/providers/coreApiProvider/index.d.ts +2 -3
  39. package/dist/src/providers/coreApiProvider/index.d.ts.map +1 -1
  40. package/dist/src/providers/coreApiProvider/index.js.map +1 -1
  41. package/dist/src/providers/coreApiProvider/{CoreApiProviderConfig.d.ts → interfaces/CoreApiProviderConfig.interface.d.ts} +7 -2
  42. package/dist/src/providers/coreApiProvider/interfaces/CoreApiProviderConfig.interface.d.ts.map +1 -0
  43. package/dist/src/providers/coreApiProvider/interfaces/CoreApiProviderConfig.interface.js +2 -0
  44. package/dist/src/providers/coreApiProvider/interfaces/CoreApiProviderConfig.interface.js.map +1 -0
  45. package/dist/src/providers/coreApiProvider/interfaces/CoreApiProviderRoutes.interface.d.ts +14 -0
  46. package/dist/src/providers/coreApiProvider/interfaces/CoreApiProviderRoutes.interface.d.ts.map +1 -0
  47. package/dist/src/providers/coreApiProvider/interfaces/CoreApiProviderRoutes.interface.js +2 -0
  48. package/dist/src/providers/coreApiProvider/interfaces/CoreApiProviderRoutes.interface.js.map +1 -0
  49. package/dist/src/providers/coreApiProvider/interfaces/index.d.ts +3 -0
  50. package/dist/src/providers/coreApiProvider/interfaces/index.d.ts.map +1 -0
  51. package/dist/src/providers/coreApiProvider/interfaces/index.js +2 -0
  52. package/dist/src/providers/coreApiProvider/interfaces/index.js.map +1 -0
  53. package/dist/src/providers/coreApiProvider/types.d.ts +9 -0
  54. package/dist/src/providers/coreApiProvider/types.d.ts.map +1 -1
  55. package/dist/src/sdk.d.ts +289 -0
  56. package/dist/src/sdk.d.ts.map +1 -0
  57. package/dist/src/sdk.js +288 -0
  58. package/dist/src/sdk.js.map +1 -0
  59. package/package.json +9 -3
  60. package/dist/src/providers/coreApiProvider/CoreApiProviderConfig.d.ts.map +0 -1
  61. package/dist/src/providers/coreApiProvider/CoreApiProviderConfig.js +0 -2
  62. package/dist/src/providers/coreApiProvider/CoreApiProviderConfig.js.map +0 -1
  63. package/dist/src/providers/coreApiProvider/RequestOptions.d.ts +0 -10
  64. package/dist/src/providers/coreApiProvider/RequestOptions.d.ts.map +0 -1
  65. package/dist/src/providers/coreApiProvider/RequestOptions.js +0 -2
  66. package/dist/src/providers/coreApiProvider/RequestOptions.js.map +0 -1
@@ -1,7 +1,8 @@
1
1
  import type { CoreApiChatRequest, CoreApiChatResponse, LongPollingActionRequest, LongPollingActionResponse } from "@illalabs/interfaces";
2
2
  import type { AxiosInstance } from "axios";
3
3
  import type { ICoreApiProvider } from "../../interfaces/index.js";
4
- import type { CoreApiProviderConfig, RequestOptions } from "./index.js";
4
+ import type { CoreApiProviderConfig, CoreApiProviderRoutes } from "./interfaces/index.js";
5
+ import type { RequestOptions } from "./types.js";
5
6
  /**
6
7
  * Axios based Core API provider implementation
7
8
  */
@@ -10,10 +11,14 @@ export declare class CoreApiProvider implements ICoreApiProvider {
10
11
  * Axios instance configured for the Core API
11
12
  */
12
13
  protected readonly client: AxiosInstance;
14
+ /**
15
+ * Routes used by the provider when issuing requests.
16
+ */
17
+ protected readonly routes: Required<CoreApiProviderRoutes>;
13
18
  /**
14
19
  * @param config Core API provider configuration
15
20
  */
16
- constructor({ baseURL, timeout, headers, httpClientFactory }: CoreApiProviderConfig);
21
+ constructor({ baseURL, timeout, headers, httpClientFactory, routes }: CoreApiProviderConfig);
17
22
  /**
18
23
  * Sends a chat message to the Core API
19
24
  */
@@ -22,6 +27,8 @@ export declare class CoreApiProvider implements ICoreApiProvider {
22
27
  * Polls the Core API for transaction status
23
28
  */
24
29
  awaitTransaction(params: LongPollingActionRequest["params"], options?: RequestOptions): Promise<LongPollingActionResponse>;
30
+ /** @inheritdoc */
31
+ getRoutes(): Required<CoreApiProviderRoutes>;
25
32
  /**
26
33
  * Builds request configuration shared across endpoints
27
34
  */
@@ -1 +1 @@
1
- {"version":3,"file":"CoreApiProvider.d.ts","sourceRoot":"","sources":["../../../../src/providers/coreApiProvider/CoreApiProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAER,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,aAAa,EAAsB,MAAM,OAAO,CAAC;AAG/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAIxE;;GAEG;AACH,qBAAa,eAAgB,YAAW,gBAAgB;IACpD;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAEzC;;OAEG;gBACS,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,EAAE,qBAAqB;IAcnF;;OAEG;IACU,WAAW,CACpB,IAAI,EAAE,kBAAkB,CAAC,MAAM,CAAC,EAChC,OAAO,GAAE,cAAmB,GAC7B,OAAO,CAAC,mBAAmB,CAAC;IAsB/B;;OAEG;IACU,gBAAgB,CACzB,MAAM,EAAE,wBAAwB,CAAC,QAAQ,CAAC,EAC1C,OAAO,GAAE,cAAmB,GAC7B,OAAO,CAAC,yBAAyB,CAAC;IA0BrC;;OAEG;IACH,SAAS,CAAC,kBAAkB,CAAC,OAAO,EAAE,cAAc,GAAG;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE;IAM/E,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,iBAAiB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IAKtB,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,iBAAiB;CAO5B"}
@@ -1,4 +1,5 @@
1
1
  import axios from "axios";
2
+ import { AsyncToolCheckerErrorHandler, ChatErrorHandler } from "./CoreApiErrorHandler.js";
2
3
  import { CoreApiAuthenticationMissing } from "./errors/index.js";
3
4
  /**
4
5
  * Axios based Core API provider implementation
@@ -8,10 +9,14 @@ export class CoreApiProvider {
8
9
  * Axios instance configured for the Core API
9
10
  */
10
11
  client;
12
+ /**
13
+ * Routes used by the provider when issuing requests.
14
+ */
15
+ routes;
11
16
  /**
12
17
  * @param config Core API provider configuration
13
18
  */
14
- constructor({ baseURL, timeout, headers, httpClientFactory }) {
19
+ constructor({ baseURL, timeout, headers, httpClientFactory, routes }) {
15
20
  const authHeaders = this.ensureAuthHeaders(headers);
16
21
  const resolveClientFactory = httpClientFactory ??
17
22
  ((configuration) => axios.create(configuration));
@@ -20,51 +25,49 @@ export class CoreApiProvider {
20
25
  timeout,
21
26
  headers: this.buildDefaultHeaders(authHeaders),
22
27
  });
28
+ this.routes = {
29
+ chat: routes?.chat ?? "/api/v1/chat/",
30
+ actionStatus: routes?.actionStatus ?? "/api/v1/actions/check",
31
+ };
23
32
  }
24
33
  /**
25
34
  * Sends a chat message to the Core API
26
35
  */
27
36
  async sendMessage(body, options = {}) {
28
37
  const requestConfig = this.buildRequestConfig(options);
29
- const response = await this.client.post("/api/v1/chat", body, requestConfig);
30
- return response.data;
31
- //TODO: Handle errors
32
- // try{
33
- // this.client.post<CoreApiChatSuccessResponse>(...);
34
- // return response.data;
35
- // }
36
- // catch(error){
37
- // All errors will end up here because Axios throws for 4XX and 5XX status codes
38
- // if (error instanceof AxiosError) {
39
- // const errorResponse: CoreApiChatErrorResponse = ChatErrorHandler.handle(error);
40
- // return errorResponse;
41
- // }
38
+ try {
39
+ const response = await this.client.post(this.routes.chat, body, requestConfig);
40
+ return response.data;
41
+ }
42
+ catch (error) {
43
+ const errorResponse = ChatErrorHandler.handle(error);
44
+ return errorResponse;
45
+ }
42
46
  }
43
47
  /**
44
48
  * Polls the Core API for transaction status
45
49
  */
46
50
  async awaitTransaction(params, options = {}) {
47
51
  const requestConfig = this.buildRequestConfig(options);
48
- const response = await this.client.get("/api/v1/actions/check", {
49
- ...requestConfig,
50
- params: {
51
- toolName: params.toolName,
52
- protocol: params.protocol,
53
- args: params.args,
54
- },
55
- });
56
- return response.data;
57
- //TODO: Handle errors
58
- // try{
59
- // this.client.get<LongPollingActionSuccessResponse>(...);
60
- // return response.data;
61
- // }
62
- // catch(error){
63
- // All errors will end up here because Axios throws for 4XX and 5XX status codes
64
- // if (error instanceof AxiosError) {
65
- // const errorResponse: LongPollingActionErrorResponse = ExecutionCheckerErrorHandler.handle(error);
66
- // return errorResponse;
67
- // }
52
+ try {
53
+ const response = await this.client.get(this.routes.actionStatus, {
54
+ ...requestConfig,
55
+ params: {
56
+ toolName: params.toolName,
57
+ protocol: params.protocol,
58
+ args: params.args,
59
+ },
60
+ });
61
+ return response.data;
62
+ }
63
+ catch (error) {
64
+ const errorResponse = AsyncToolCheckerErrorHandler.handle(error);
65
+ return errorResponse;
66
+ }
67
+ }
68
+ /** @inheritdoc */
69
+ getRoutes() {
70
+ return this.routes;
68
71
  }
69
72
  /**
70
73
  * Builds request configuration shared across endpoints
@@ -75,7 +78,8 @@ export class CoreApiProvider {
75
78
  };
76
79
  }
77
80
  resolveBaseUrl(baseURL) {
78
- return baseURL ?? "https://app.illa.network";
81
+ // TODO: update base URL depending on final deployment
82
+ return baseURL ?? "https://api-dev.illalabs.io";
79
83
  }
80
84
  buildDefaultHeaders(headers) {
81
85
  return {
@@ -84,7 +88,7 @@ export class CoreApiProvider {
84
88
  };
85
89
  }
86
90
  ensureAuthHeaders(headers) {
87
- if (headers?.["x-auth-token"] === undefined) {
91
+ if (headers?.["x-api-key"] === undefined) {
88
92
  throw new CoreApiAuthenticationMissing();
89
93
  }
90
94
  return headers;
@@ -1 +1 @@
1
- {"version":3,"file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 +1,8 @@
1
1
  /**
2
- * Raised when the authentication token is not provided
2
+ * Raised when the API key is not provided
3
3
  */
4
- export declare class CoreApiAuthenticationMissing {
4
+ export declare class CoreApiAuthenticationMissing extends Error {
5
5
  readonly statusCode = 401;
6
- readonly name: string;
7
- readonly message: string;
8
6
  constructor();
9
7
  }
10
8
  //# sourceMappingURL=CoreApiAuthenticationMissing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CoreApiAuthenticationMissing.d.ts","sourceRoot":"","sources":["../../../../../src/providers/coreApiProvider/errors/CoreApiAuthenticationMissing.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,4BAA4B;IACrC,SAAgB,UAAU,OAAO;IACjC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,OAAO,EAAE,MAAM,CAAC;;CAMnC"}
1
+ {"version":3,"file":"CoreApiAuthenticationMissing.d.ts","sourceRoot":"","sources":["../../../../../src/providers/coreApiProvider/errors/CoreApiAuthenticationMissing.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,4BAA6B,SAAQ,KAAK;IACnD,SAAgB,UAAU,OAAO;;CAWpC"}
@@ -1,14 +1,15 @@
1
1
  /**
2
- * Raised when the authentication token is not provided
2
+ * Raised when the API key is not provided
3
3
  */
4
- export class CoreApiAuthenticationMissing {
4
+ export class CoreApiAuthenticationMissing extends Error {
5
5
  statusCode = 401;
6
- name;
7
- message;
8
6
  constructor() {
9
- this.statusCode = 401;
7
+ const message = "Core API key is required";
8
+ super(message);
10
9
  this.name = "CoreApiAuthenticationMissing";
11
- this.message = "Core API authentication token is required";
10
+ if (Error.captureStackTrace) {
11
+ Error.captureStackTrace(this, CoreApiAuthenticationMissing);
12
+ }
12
13
  }
13
14
  }
14
15
  //# sourceMappingURL=CoreApiAuthenticationMissing.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CoreApiAuthenticationMissing.js","sourceRoot":"","sources":["../../../../../src/providers/coreApiProvider/errors/CoreApiAuthenticationMissing.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,4BAA4B;IACrB,UAAU,GAAG,GAAG,CAAC;IACjB,IAAI,CAAS;IACb,OAAO,CAAS;IAChC;QACI,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;QAC3C,IAAI,CAAC,OAAO,GAAG,2CAA2C,CAAC;IAC/D,CAAC;CACJ"}
1
+ {"version":3,"file":"CoreApiAuthenticationMissing.js","sourceRoot":"","sources":["../../../../../src/providers/coreApiProvider/errors/CoreApiAuthenticationMissing.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,4BAA6B,SAAQ,KAAK;IACnC,UAAU,GAAG,GAAG,CAAC;IAEjC;QACI,MAAM,OAAO,GAAG,0BAA0B,CAAC;QAC3C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;QAE3C,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC1B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,4BAA4B,CAAC,CAAC;QAChE,CAAC;IACL,CAAC;CACJ"}
@@ -1,7 +1,6 @@
1
1
  export * from "./CoreApiProvider.js";
2
2
  export type { ICoreApiProvider } from "../../interfaces/index.js";
3
- export type { CoreApiProviderConfig } from "./CoreApiProviderConfig.js";
4
- export type { HttpClientFactory } from "./types.js";
5
- export type { RequestOptions } from "./RequestOptions.js";
3
+ export type { CoreApiProviderConfig, CoreApiProviderRoutes } from "./interfaces/index.js";
4
+ export type { HttpClientFactory, RequestOptions } from "./types.js";
6
5
  export * from "./errors/index.js";
7
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/providers/coreApiProvider/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,YAAY,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/providers/coreApiProvider/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,YAAY,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC1F,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACpE,cAAc,mBAAmB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/providers/coreApiProvider/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AAKrC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/providers/coreApiProvider/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AAIrC,cAAc,mBAAmB,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import type { CoreApiAuthHeaders } from "@illalabs/interfaces";
2
- import type { HttpClientFactory } from "./types.js";
2
+ import type { HttpClientFactory } from "../types.js";
3
+ import type { CoreApiProviderRoutes } from "./CoreApiProviderRoutes.interface.js";
3
4
  /**
4
5
  * Core API provider configuration
5
6
  */
@@ -20,5 +21,9 @@ export interface CoreApiProviderConfig {
20
21
  * Optional factory used to create a configured axios instance. Primarily used for testing.
21
22
  */
22
23
  readonly httpClientFactory?: HttpClientFactory;
24
+ /**
25
+ * Optional overrides for API routes used by the provider.
26
+ */
27
+ readonly routes?: CoreApiProviderRoutes;
23
28
  }
24
- //# sourceMappingURL=CoreApiProviderConfig.d.ts.map
29
+ //# sourceMappingURL=CoreApiProviderConfig.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CoreApiProviderConfig.interface.d.ts","sourceRoot":"","sources":["../../../../../src/providers/coreApiProvider/interfaces/CoreApiProviderConfig.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAElF;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAEtC;;OAEG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IAE/C;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,qBAAqB,CAAC;CAC3C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=CoreApiProviderConfig.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CoreApiProviderConfig.interface.js","sourceRoot":"","sources":["../../../../../src/providers/coreApiProvider/interfaces/CoreApiProviderConfig.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Optional route overrides used by the {@link CoreApiProvider}.
3
+ */
4
+ export interface CoreApiProviderRoutes {
5
+ /**
6
+ * Path used when sending chat requests. Defaults to `/api/v1/chat/`.
7
+ */
8
+ readonly chat?: string;
9
+ /**
10
+ * Path used when polling asynchronous tool executions. Defaults to `/api/v1/actions/check`.
11
+ */
12
+ readonly actionStatus?: string;
13
+ }
14
+ //# sourceMappingURL=CoreApiProviderRoutes.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CoreApiProviderRoutes.interface.d.ts","sourceRoot":"","sources":["../../../../../src/providers/coreApiProvider/interfaces/CoreApiProviderRoutes.interface.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC;;OAEG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAClC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=CoreApiProviderRoutes.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CoreApiProviderRoutes.interface.js","sourceRoot":"","sources":["../../../../../src/providers/coreApiProvider/interfaces/CoreApiProviderRoutes.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export type { CoreApiProviderRoutes } from "./CoreApiProviderRoutes.interface.js";
2
+ export type { CoreApiProviderConfig } from "./CoreApiProviderConfig.interface.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/providers/coreApiProvider/interfaces/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAClF,YAAY,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/providers/coreApiProvider/interfaces/index.ts"],"names":[],"mappings":""}
@@ -4,4 +4,13 @@ import type { AxiosInstance, AxiosRequestConfig } from "axios";
4
4
  * Kept separate to enable reuse in tests and other providers.
5
5
  */
6
6
  export type HttpClientFactory = (config?: AxiosRequestConfig) => AxiosInstance;
7
+ /**
8
+ * Options for Core API requests
9
+ */
10
+ export interface RequestOptions {
11
+ /**
12
+ * Abort signal used to cancel the request
13
+ */
14
+ readonly signal?: AbortSignal;
15
+ }
7
16
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/providers/coreApiProvider/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAE/D;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,CAAC,EAAE,kBAAkB,KAAK,aAAa,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/providers/coreApiProvider/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAE/D;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,CAAC,EAAE,kBAAkB,KAAK,aAAa,CAAC;AAE/E;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CACjC"}
@@ -0,0 +1,289 @@
1
+ import type { MessageHistoryType, PersonalityContext, ToolResultType, UserContext } from "@illalabs/interfaces";
2
+ import type { CacheEntryOptions, ChatContextSnapshot, ContextManagerOptions, ICache, IContextManager, SendMessageResult } from "./internal.js";
3
+ import { Chat, ContextManager } from "./internal.js";
4
+ /**
5
+ * Configuration options for initializing the IllaSDK.
6
+ *
7
+ * @property apiKey - Your ILLA API key for authentication
8
+ * @property baseURL - Optional custom base URL for the ILLA API (defaults to production API)
9
+ */
10
+ type illaSDKConfig = {
11
+ apiKey: string;
12
+ baseURL?: string;
13
+ };
14
+ /**
15
+ * Optional configuration for the IllaSDK instance.
16
+ * You can either provide a custom cache and context manager options,
17
+ * or provide a complete custom context manager implementation.
18
+ *
19
+ * @property cache - Optional custom cache implementation (used with contextManagerOptions)
20
+ * @property contextManagerOptions - Optional configuration for the default context manager
21
+ * @property contextManager - Optional custom context manager implementation (mutually exclusive with cache/contextManagerOptions)
22
+ */
23
+ type illaSDKOptions = {
24
+ cache?: ICache;
25
+ contextManagerOptions?: ContextManagerOptions;
26
+ contextManager?: never;
27
+ } | {
28
+ contextManager: IContextManager;
29
+ cache?: never;
30
+ contextManagerOptions?: never;
31
+ };
32
+ /**
33
+ * Options for creating a new chat instance.
34
+ *
35
+ * @property userContext - The user's context information { address: `0x${string}` }
36
+ * @property id - Optional custom ID for the chat. If not provided, a UUID will be generated
37
+ */
38
+ type ChatOptions = {
39
+ userContext: UserContext;
40
+ id?: string;
41
+ personalityContext?: PersonalityContext;
42
+ };
43
+ /**
44
+ * Context for sending a message. Requires either a chatId (to use an existing chat)
45
+ * or a userContext (to create a new chat).
46
+ *
47
+ * @property chatId - ID of an existing chat to send the message to
48
+ * @property userContext - User context for creating a new chat (required if chatId is not provided)
49
+ */
50
+ type SendMessageContext = {
51
+ chatId: string;
52
+ userContext?: never;
53
+ } | {
54
+ chatId?: never;
55
+ userContext: UserContext;
56
+ };
57
+ /**
58
+ * Error raised when attempting to interact with a chat that doesn't exist.
59
+ *
60
+ * This typically occurs when using an invalid or expired chat ID with methods
61
+ * like {@link IllaSDK.sendToolResult}.
62
+ */
63
+ declare class ChatNotFound extends Error {
64
+ /**
65
+ * The ID of the chat that was not found.
66
+ */
67
+ readonly chatId: string;
68
+ /**
69
+ * Creates a new {@link ChatNotFound} instance.
70
+ *
71
+ * @param chatId The ID of the chat that was not found.
72
+ * @param options Error options for error chaining.
73
+ */
74
+ constructor(chatId: string, options?: ErrorOptions);
75
+ }
76
+ /**
77
+ * The main entry point for interacting with the ILLA AI SDK.
78
+ * This class provides methods for creating and managing chat sessions,
79
+ * sending messages, handling tool results, and configuring async tool checkers.
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * import { IllaSDK } from '@illalabs/sdk';
84
+ *
85
+ * const sdk = new IllaSDK({
86
+ * apiKey: 'your-api-key'
87
+ * });
88
+ *
89
+ * // Start a conversation
90
+ * const result = await sdk.sendMessage(
91
+ * "What can you help me with?",
92
+ * { userContext: { address: "0x1234..." } }
93
+ * );
94
+ *
95
+ * console.log(result.response.text);
96
+ * ```
97
+ */
98
+ declare class IllaSDK {
99
+ private coreApiProvider;
100
+ private contextManager;
101
+ private chats;
102
+ /**
103
+ * Creates a new instance of the IllaSDK.
104
+ *
105
+ * @param config - Configuration object containing API key and optional base URL
106
+ * @param options - Optional configuration for cache and context manager
107
+ *
108
+ * @example
109
+ * ```typescript
110
+ * // Basic initialization
111
+ * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
112
+ *
113
+ * // With custom cache
114
+ * const cache = new InMemoryCache();
115
+ * const sdk = new IllaSDK(
116
+ * { apiKey: 'your-api-key' },
117
+ * { cache }
118
+ * );
119
+ *
120
+ * // With custom context manager
121
+ * const contextManager = new ContextManager(cache, { defaultToolsConfig: { autoRouter: { swapOrBridge: 'lifi' } } });
122
+ * const sdk = new IllaSDK(
123
+ * { apiKey: 'your-api-key' },
124
+ * { contextManager }
125
+ * );
126
+ * ```
127
+ */
128
+ constructor(config: illaSDKConfig, options?: illaSDKOptions);
129
+ /**
130
+ * Gets an array of all active chat IDs managed by this SDK instance.
131
+ *
132
+ * @returns {string[]} Array of chat IDs
133
+ *
134
+ * @example
135
+ * ```typescript
136
+ * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
137
+ *
138
+ * await sdk.sendMessage("Hello", { userContext: { address: "0x123" } });
139
+ * await sdk.sendMessage("Hi", { userContext: { address: "0x456" } });
140
+ *
141
+ * const chatIds = sdk.chatIds;
142
+ * console.log(chatIds); // ['chat-id-1', 'chat-id-2']
143
+ * ```
144
+ */
145
+ get chatIds(): string[];
146
+ /**
147
+ * Creates a new ContextManager instance. This is a factory method for creating
148
+ * context managers with custom configurations.
149
+ *
150
+ * @param cache - The cache implementation to use for storing context
151
+ * @param options - Configuration options for the context manager
152
+ * @returns {ContextManager} A new ContextManager instance
153
+ *
154
+ * @example
155
+ * ```typescript
156
+ * const cache = new InMemoryCache();
157
+ * const contextManager = IllaSDK.createNewContextManager(cache, {
158
+ * defaultToolsConfig: {
159
+ * autoRouter: { swapOrBridge: 'lifi' }
160
+ * }
161
+ * });
162
+ *
163
+ * const sdk = new IllaSDK(
164
+ * { apiKey: 'your-api-key' },
165
+ * { contextManager }
166
+ * );
167
+ * ```
168
+ */
169
+ static createNewContextManager(cache: ICache, options: ContextManagerOptions): ContextManager;
170
+ /**
171
+ * Creates a new Chat instance with the specified options.
172
+ * The chat is automatically registered with this SDK instance.
173
+ *
174
+ * @param options - Options for creating the chat, including user context and optional ID
175
+ * @param contextManager - Optional custom context manager for this chat. If not provided, uses the SDK's default
176
+ * @returns {Chat} A new Chat instance
177
+ *
178
+ * @example
179
+ * ```typescript
180
+ * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
181
+ *
182
+ * // Create a new chat
183
+ * const chat = sdk.createChat({
184
+ * userContext: { address: "0x1234..." }
185
+ * });
186
+ *
187
+ * // Send messages directly through the chat instance
188
+ * const result = await chat.sendMessage(new Prompt({ text: "Hello!" }));
189
+ * ```
190
+ */
191
+ createChat(options: ChatOptions, contextManager?: ContextManager): Chat;
192
+ /**
193
+ * Sends a message to a chat session. This is the primary method for interacting with the AI.
194
+ * If a chatId is provided, the message will be sent to the existing chat.
195
+ * If a chatId is not provided, a new chat will be created with the provided userContext.
196
+ *
197
+ * @param msg - The message text to send
198
+ * @param context - Context containing either chatId for existing chat or userContext for new chat
199
+ * @returns {Promise<SendMessageResult>} The AI's response including chat ID, response text, and any pending tools
200
+ *
201
+ * @example
202
+ * ```typescript
203
+ * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
204
+ *
205
+ * // Start a new conversation
206
+ * const result1 = await sdk.sendMessage(
207
+ * "What can you help me with?",
208
+ * { userContext: { address: "0x1234..." } }
209
+ * );
210
+ * console.log(result1.response.text);
211
+ * console.log("Chat ID:", result1.chatId);
212
+ *
213
+ * // Continue the conversation using the chat ID
214
+ * const result2 = await sdk.sendMessage(
215
+ * "I want to swap 1 ETH for USDC on Base",
216
+ * { chatId: result1.chatId }
217
+ * );
218
+ *
219
+ * // Check if there are tools to execute
220
+ * if (result2.response.pendingTools && result2.response.pendingTools.length > 0) {
221
+ * console.log("Tool to execute:", result2.response.pendingTools[0]);
222
+ * }
223
+ * ```
224
+ */
225
+ sendMessage(msg: string, context: SendMessageContext): Promise<SendMessageResult>;
226
+ /**
227
+ * Sends the result of a tool execution back to the AI. This method is used to complete
228
+ * the tool execution loop when the AI requests a tool to be executed.
229
+ *
230
+ * @param chatId - The ID of the chat to send the tool result to
231
+ * @param toolResult - The result of the tool execution
232
+ * @returns {Promise<SendMessageResult>} The AI's response after processing the tool result
233
+ * @throws {Error} If the chat with the specified chatId is not found
234
+ *
235
+ * @example
236
+ * ```typescript
237
+ * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
238
+ *
239
+ * // Start a conversation that will request a tool execution
240
+ * const result1 = await sdk.sendMessage(
241
+ * "Swap 1 ETH for USDC on Base",
242
+ * { userContext: { address: "0x1234..." } }
243
+ * );
244
+ *
245
+ * // Check if there are pending tools to execute
246
+ * if (result1.response.pendingTools && result1.response.pendingTools.length > 0) {
247
+ * const tool = result1.response.pendingTools[0];
248
+ *
249
+ * // Execute the tool (e.g., send a transaction)
250
+ * const executionResult = await executeTool(tool);
251
+ *
252
+ * // Send the result back to the ILLA
253
+ * const toolResult: ToolResultType = {
254
+ * toolCallId: tool.toolCallId,
255
+ * toolName: tool.toolName,
256
+ * result?: executionResult,
257
+ * error?: executionResult.error,
258
+ * };
259
+ *
260
+ * const result2 = await sdk.sendToolResult(result1.chatId, toolResult);
261
+ * console.log(result2.response.text); // ILLA's response after processing the tool result
262
+ * }
263
+ * ```
264
+ */
265
+ sendToolResult(chatId: string, toolResult: ToolResultType): Promise<SendMessageResult>;
266
+ /**
267
+ * Gets the messages for a given chat ID.
268
+ *
269
+ * @param chatId - The ID of the chat to get the messages for
270
+ * @returns {Promise<MessageHistoryType>} The messages for the chat
271
+ * @throws {ChatNotFound} If the chat with the specified chatId is not found
272
+ */
273
+ getMessages(chatId: string): Promise<MessageHistoryType>;
274
+ }
275
+ /**
276
+ * Exports the public API of the SDK.
277
+ * A user could import IllaSDK as a single entry point to the SDK.
278
+ * Or they could import the individual components of the SDK for advanced usage.
279
+ */
280
+ export { IllaSDK, ChatNotFound };
281
+ export { InMemoryCache } from "./caching/index.js";
282
+ export { Prompt } from "./prompt/index.js";
283
+ export { Chat } from "./chat/index.js";
284
+ export { ContextManager } from "./context/index.js";
285
+ export { AsyncToolChecker } from "./asyncToolChecker/index.js";
286
+ export { CoreApiProvider } from "./providers/index.js";
287
+ export { UserContextMissing } from "./chat/errors/index.js";
288
+ export type { illaSDKConfig, ChatContextSnapshot, CacheEntryOptions, ICache, IContextManager, SendMessageContext, };
289
+ //# sourceMappingURL=sdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACd,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EACR,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,MAAM,EACN,eAAe,EACf,iBAAiB,EACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAEH,IAAI,EACJ,cAAc,EAKjB,MAAM,eAAe,CAAC;AAEvB;;;;;GAKG;AACH,KAAK,aAAa,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;GAQG;AACH,KAAK,cAAc,GACb;IACI,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;IAC9C,cAAc,CAAC,EAAE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