@illalabs/sdk 0.3.3-canary.b7f69a88 → 0.4.0-canary.361ed2fa

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 (68) hide show
  1. package/README.md +15 -9
  2. package/dist/src/chat/Chat.d.ts +6 -3
  3. package/dist/src/chat/Chat.d.ts.map +1 -1
  4. package/dist/src/chat/Chat.js +54 -22
  5. package/dist/src/chat/Chat.js.map +1 -1
  6. package/dist/src/chat/errors/ChatInvalidMultiplePromptsKind.d.ts +22 -0
  7. package/dist/src/chat/errors/ChatInvalidMultiplePromptsKind.d.ts.map +1 -0
  8. package/dist/src/chat/errors/ChatInvalidMultiplePromptsKind.js +31 -0
  9. package/dist/src/chat/errors/ChatInvalidMultiplePromptsKind.js.map +1 -0
  10. package/dist/src/chat/errors/ChatInvalidPromptSnapshot.d.ts +19 -0
  11. package/dist/src/chat/errors/ChatInvalidPromptSnapshot.d.ts.map +1 -0
  12. package/dist/src/chat/errors/ChatInvalidPromptSnapshot.js +28 -0
  13. package/dist/src/chat/errors/ChatInvalidPromptSnapshot.js.map +1 -0
  14. package/dist/src/chat/errors/ChatInvalidSinglePromptKind.d.ts +22 -0
  15. package/dist/src/chat/errors/ChatInvalidSinglePromptKind.d.ts.map +1 -0
  16. package/dist/src/chat/errors/ChatInvalidSinglePromptKind.js +31 -0
  17. package/dist/src/chat/errors/ChatInvalidSinglePromptKind.js.map +1 -0
  18. package/dist/src/chat/errors/index.d.ts +3 -0
  19. package/dist/src/chat/errors/index.d.ts.map +1 -1
  20. package/dist/src/chat/errors/index.js +3 -0
  21. package/dist/src/chat/errors/index.js.map +1 -1
  22. package/dist/src/chat/utils/prompt.d.ts +3 -0
  23. package/dist/src/chat/utils/prompt.d.ts.map +1 -0
  24. package/dist/src/chat/utils/prompt.js +5 -0
  25. package/dist/src/chat/utils/prompt.js.map +1 -0
  26. package/dist/src/context/ContextManager.d.ts +2 -0
  27. package/dist/src/context/ContextManager.d.ts.map +1 -1
  28. package/dist/src/context/ContextManager.js +7 -0
  29. package/dist/src/context/ContextManager.js.map +1 -1
  30. package/dist/src/errors/SdkEmptyToolsResultsError.d.ts +19 -0
  31. package/dist/src/errors/SdkEmptyToolsResultsError.d.ts.map +1 -0
  32. package/dist/src/errors/SdkEmptyToolsResultsError.js +28 -0
  33. package/dist/src/errors/SdkEmptyToolsResultsError.js.map +1 -0
  34. package/dist/src/interfaces/chat.interface.d.ts +3 -2
  35. package/dist/src/interfaces/chat.interface.d.ts.map +1 -1
  36. package/dist/src/interfaces/contextManager.interface.d.ts +7 -1
  37. package/dist/src/interfaces/contextManager.interface.d.ts.map +1 -1
  38. package/dist/src/prompt/Prompt.d.ts +2 -10
  39. package/dist/src/prompt/Prompt.d.ts.map +1 -1
  40. package/dist/src/prompt/Prompt.js +9 -22
  41. package/dist/src/prompt/Prompt.js.map +1 -1
  42. package/dist/src/prompt/types.d.ts +7 -9
  43. package/dist/src/prompt/types.d.ts.map +1 -1
  44. package/dist/src/prompt/utils/cloneToolResult.d.ts +6 -6
  45. package/dist/src/prompt/utils/cloneToolResult.d.ts.map +1 -1
  46. package/dist/src/prompt/utils/cloneToolResult.js +11 -16
  47. package/dist/src/prompt/utils/cloneToolResult.js.map +1 -1
  48. package/dist/src/prompt/utils/index.d.ts +1 -3
  49. package/dist/src/prompt/utils/index.d.ts.map +1 -1
  50. package/dist/src/prompt/utils/index.js +1 -3
  51. package/dist/src/prompt/utils/index.js.map +1 -1
  52. package/dist/src/sdk.d.ts +251 -25
  53. package/dist/src/sdk.d.ts.map +1 -1
  54. package/dist/src/sdk.js +312 -26
  55. package/dist/src/sdk.js.map +1 -1
  56. package/package.json +2 -2
  57. package/dist/src/chat/errors/ChatInvalidModelContext.d.ts +0 -15
  58. package/dist/src/chat/errors/ChatInvalidModelContext.d.ts.map +0 -1
  59. package/dist/src/chat/errors/ChatInvalidModelContext.js +0 -24
  60. package/dist/src/chat/errors/ChatInvalidModelContext.js.map +0 -1
  61. package/dist/src/prompt/utils/normalizeTextPrompt.d.ts +0 -14
  62. package/dist/src/prompt/utils/normalizeTextPrompt.d.ts.map +0 -1
  63. package/dist/src/prompt/utils/normalizeTextPrompt.js +0 -22
  64. package/dist/src/prompt/utils/normalizeTextPrompt.js.map +0 -1
  65. package/dist/src/prompt/utils/normalizeToolResult.d.ts +0 -14
  66. package/dist/src/prompt/utils/normalizeToolResult.d.ts.map +0 -1
  67. package/dist/src/prompt/utils/normalizeToolResult.js +0 -27
  68. package/dist/src/prompt/utils/normalizeToolResult.js.map +0 -1
@@ -1,5 +1,4 @@
1
- import type { MessageType } from "@illalabs/interfaces";
2
- import type { NormalizedPromptSnapshot, PromptOptions, PromptRole, PromptSnapshot } from "./types.js";
1
+ import type { NormalizedPromptSnapshot, PromptOptions, PromptSnapshot } from "./types.js";
3
2
  /**
4
3
  * Represents a message payload that can be sent to the Core API.
5
4
  *
@@ -28,14 +27,7 @@ export declare class Prompt {
28
27
  * @param role The role to assign to the message (e.g., "user", "assistant", "tool").
29
28
  * @returns A normalized snapshot containing both the prompt payload and message format.
30
29
  */
31
- getNormalizedSnapshot(role: PromptRole): NormalizedPromptSnapshot;
32
- /**
33
- * Converts the prompt into a message history entry with the specified role.
34
- *
35
- * @param role The role to assign to the message (e.g., "user", "assistant", "tool").
36
- * @returns A message object compatible with the message history format.
37
- */
38
- toMessage(role: PromptRole): MessageType;
30
+ getNormalizedSnapshot(): NormalizedPromptSnapshot;
39
31
  /**
40
32
  * Converts the prompt to a string representation.
41
33
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Prompt.d.ts","sourceRoot":"","sources":["../../../src/prompt/Prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,sBAAsB,CAAC;AAIxE,OAAO,KAAK,EACR,wBAAwB,EACxB,aAAa,EACb,UAAU,EACV,cAAc,EACjB,MAAM,YAAY,CAAC;AAIpB;;;;;;GAMG;AACH,qBAAa,MAAM;IACf,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAiB;IAE1C;;;;;OAKG;gBACgB,OAAO,EAAE,aAAa;IAIzC;;;;OAIG;IACI,WAAW,IAAI,cAAc;IAIpC;;;;;OAKG;IACI,qBAAqB,CAAC,IAAI,EAAE,UAAU,GAAG,wBAAwB;IAoBxE;;;;;OAKG;IACI,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,WAAW;IAI/C;;;;OAIG;IACI,QAAQ,IAAI,MAAM;IAQzB;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IAyB7B;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;CAa/B"}
1
+ {"version":3,"file":"Prompt.d.ts","sourceRoot":"","sources":["../../../src/prompt/Prompt.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,wBAAwB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAI1F;;;;;;GAMG;AACH,qBAAa,MAAM;IACf,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAiB;IAE1C;;;;;OAKG;gBACgB,OAAO,EAAE,aAAa;IAIzC;;;;OAIG;IACI,WAAW,IAAI,cAAc;IAIpC;;;;;OAKG;IACI,qBAAqB,IAAI,wBAAwB;IAcxD;;;;OAIG;IACI,QAAQ,IAAI,MAAM;IAQzB;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IAyB7B;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;CAa/B"}
@@ -1,7 +1,7 @@
1
- import { ToolResultSchema } from "@illalabs/interfaces";
1
+ import { ToolOutcomesSchema } from "@illalabs/interfaces";
2
2
  import { stringify } from "viem";
3
3
  import { PromptConfigurationConflict } from "./errors/index.js";
4
- import { cloneToolResult, normalizeTextPrompt, normalizeToolResult } from "./utils/index.js";
4
+ import { cloneToolOutcome } from "./utils/index.js";
5
5
  /**
6
6
  * Represents a message payload that can be sent to the Core API.
7
7
  *
@@ -34,31 +34,18 @@ export class Prompt {
34
34
  * @param role The role to assign to the message (e.g., "user", "assistant", "tool").
35
35
  * @returns A normalized snapshot containing both the prompt payload and message format.
36
36
  */
37
- getNormalizedSnapshot(role) {
37
+ getNormalizedSnapshot() {
38
38
  if (this.snapshot.kind === "text") {
39
- const normalized = normalizeTextPrompt(this.snapshot.text, role);
40
39
  return {
41
- kind: "text",
42
- prompt: normalized.prompt,
43
- message: normalized.message,
40
+ type: "text",
41
+ text: this.snapshot.text,
44
42
  };
45
43
  }
46
- const normalized = normalizeToolResult(this.snapshot.toolResult, role);
47
44
  return {
48
- kind: "tool-result",
49
- prompt: normalized.prompt,
50
- message: normalized.message,
45
+ type: "tool-result",
46
+ toolResults: this.snapshot.toolResult,
51
47
  };
52
48
  }
53
- /**
54
- * Converts the prompt into a message history entry with the specified role.
55
- *
56
- * @param role The role to assign to the message (e.g., "user", "assistant", "tool").
57
- * @returns A message object compatible with the message history format.
58
- */
59
- toMessage(role) {
60
- return this.getNormalizedSnapshot(role).message;
61
- }
62
49
  /**
63
50
  * Converts the prompt to a string representation.
64
51
  *
@@ -90,7 +77,7 @@ export class Prompt {
90
77
  text,
91
78
  };
92
79
  }
93
- const validated = ToolResultSchema.parse(toolResult);
80
+ const validated = ToolOutcomesSchema.parse(toolResult);
94
81
  return {
95
82
  kind: "tool-result",
96
83
  toolResult: validated,
@@ -111,7 +98,7 @@ export class Prompt {
111
98
  }
112
99
  return {
113
100
  kind: "tool-result",
114
- toolResult: cloneToolResult(snapshot.toolResult),
101
+ toolResult: snapshot.toolResult.map((item) => cloneToolOutcome(item)),
115
102
  };
116
103
  }
117
104
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Prompt.js","sourceRoot":"","sources":["../../../src/prompt/Prompt.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAQjC,OAAO,EAAE,2BAA2B,E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AE,MAAM;gBACZ,IAAI;aACP,CAAC;QACN,CAAC;QAED,MAAM,SAAS,GAAqB,kBAAkB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAEzE,OAAO;YACH,IAAI,EAAE,aAAa;YACnB,UAAU,EAAE,SAAS;SACxB,CAAC;IACN,CAAC;IAED;;;;;OAKG;IACK,MAAM,CAAC,aAAa,CAAC,QAAwB;QACjD,IAAI,QAAQ,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAC3B,OAAO;gBACH,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,QAAQ,CAAC,IAAI;aACtB,CAAC;QACN,CAAC;QAED,OAAO;YACH,IAAI,EAAE,aAAa;YACnB,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;SACxE,CAAC;IACN,CAAC;CACJ"}
@@ -1,4 +1,4 @@
1
- import type { MessageType, ToolResultType } from "@illalabs/interfaces";
1
+ import type { ToolOutcomesType } from "@illalabs/interfaces";
2
2
  /**
3
3
  * Enumerates the supported prompt payload variants.
4
4
  */
@@ -28,7 +28,7 @@ type XOR<TLeft, TRight> = (Without<TLeft, TRight> & TRight) | (Without<TRight, T
28
28
  export type PromptOptions = XOR<{
29
29
  readonly text: string;
30
30
  }, {
31
- readonly toolResult: ToolResultType;
31
+ readonly toolResult: ToolOutcomesType;
32
32
  }>;
33
33
  /**
34
34
  * Resulting payload snapshot produced by a {@link Prompt} instance.
@@ -38,20 +38,18 @@ export type PromptSnapshot = {
38
38
  readonly text: string;
39
39
  } | {
40
40
  readonly kind: "tool-result";
41
- readonly toolResult: ToolResultType;
41
+ readonly toolResult: ToolOutcomesType;
42
42
  };
43
43
  /**
44
44
  * Normalized prompt snapshot containing both the prompt payload and corresponding message format.
45
45
  * This structure is suitable for transmission to the Core API.
46
46
  */
47
47
  export type NormalizedPromptSnapshot = {
48
- readonly kind: "text";
49
- readonly prompt: string;
50
- readonly message: MessageType;
48
+ readonly type: "text";
49
+ readonly text: string;
51
50
  } | {
52
- readonly kind: "tool-result";
53
- readonly prompt: ToolResultType;
54
- readonly message: MessageType;
51
+ readonly type: "tool-result";
52
+ readonly toolResults: ToolOutcomesType;
55
53
  };
56
54
  export {};
57
55
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/prompt/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAExE;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,aAAa,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;AAEvD;;GAEG;AACH,KAAK,OAAO,CAAC,OAAO,EAAE,SAAS,IAAI;KAC9B,GAAG,IAAI,OAAO,CAAC,MAAM,OAAO,EAAE,MAAM,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK;CAC3D,CAAC;AAEF;;GAEG;AACH,KAAK,GAAG,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,KAAK,CAAC,CAAC;AAE/F;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE;IAAE,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAA;CAAE,CAAC,CAAC;AAEpG;;GAEG;AACH,MAAM,MAAM,cAAc,GACpB;IACI,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACzB,GACD;IACI,QAAQ,CAAC,IAAI,EAAE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AACH,MAAM,MAAM,cAAc,GACpB;IACI,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACzB,GACD;IACI,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;CACzC,CAAC;AAER;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAC9B;IACI,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACzB,GACD;IACI,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAAC;CAC1C,CAAC"}
@@ -1,12 +1,12 @@
1
- import type { ToolResultType } from "@illalabs/interfaces";
1
+ import type { IllaToolOutcomeJSON } from "@illalabs/interfaces";
2
2
  /**
3
- * Creates a deep clone of a tool result object to prevent external mutation.
3
+ * Creates a deep clone of a tool outcome object to prevent external mutation.
4
4
  *
5
5
  * This function clones all potentially complex fields (result and error) while
6
- * preserving primitive identifiers (toolCallId and toolName).
6
+ * preserving primitive identifiers (id and name).
7
7
  *
8
- * @param toolResult The tool result to clone.
9
- * @returns A deep copy of the tool result with all complex fields cloned.
8
+ * @param toolOutcome The tool outcome to clone.
9
+ * @returns A deep copy of the tool outcome with all complex fields cloned.
10
10
  */
11
- export declare function cloneToolResult(toolResult: ToolResultType): ToolResultType;
11
+ export declare function cloneToolOutcome(toolOutcome: IllaToolOutcomeJSON): IllaToolOutcomeJSON;
12
12
  //# sourceMappingURL=cloneToolResult.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cloneToolResult.d.ts","sourceRoot":"","sources":["../../../../src/prompt/utils/cloneToolResult.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAI3D;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,cAAc,GAAG,cAAc,CAiB1E"}
1
+ {"version":3,"file":"cloneToolResult.d.ts","sourceRoot":"","sources":["../../../../src/prompt/utils/cloneToolResult.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAIhE;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,mBAAmB,GAAG,mBAAmB,CAYtF"}
@@ -1,27 +1,22 @@
1
1
  import { deepClone } from "./deepClone.js";
2
2
  /**
3
- * Creates a deep clone of a tool result object to prevent external mutation.
3
+ * Creates a deep clone of a tool outcome object to prevent external mutation.
4
4
  *
5
5
  * This function clones all potentially complex fields (result and error) while
6
- * preserving primitive identifiers (toolCallId and toolName).
6
+ * preserving primitive identifiers (id and name).
7
7
  *
8
- * @param toolResult The tool result to clone.
9
- * @returns A deep copy of the tool result with all complex fields cloned.
8
+ * @param toolOutcome The tool outcome to clone.
9
+ * @returns A deep copy of the tool outcome with all complex fields cloned.
10
10
  */
11
- export function cloneToolResult(toolResult) {
11
+ export function cloneToolOutcome(toolOutcome) {
12
12
  const cloned = {
13
- toolCallId: toolResult.toolCallId,
14
- toolName: toolResult.toolName,
15
- result: toolResult.result !== undefined ? deepClone(toolResult.result) : undefined,
13
+ id: toolOutcome.id,
14
+ name: toolOutcome.name,
15
+ result: toolOutcome.result !== undefined ? deepClone(toolOutcome.result) : undefined,
16
16
  };
17
- // Deep clone error only if it's a non-null object
18
- if (toolResult.error !== undefined) {
19
- if (typeof toolResult.error === "object" && toolResult.error !== null) {
20
- cloned.error = deepClone(toolResult.error);
21
- }
22
- else {
23
- cloned.error = toolResult.error;
24
- }
17
+ // Deep clone error only if it's a non-undefined object
18
+ if (toolOutcome.error !== undefined) {
19
+ cloned.error = deepClone(toolOutcome.error);
25
20
  }
26
21
  return cloned;
27
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cloneToolResult.js","sourceRoot":"","sources":["../../../../src/prompt/utils/cloneToolResult.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,UAA0B;IACtD,MAAM,MAAM,GAAmB;QAC3B,UAAU,EAAE,UAAU,CAAC,UAAU;QACjC,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,MAAM,EAAE,UAAU,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;KACrF,CAAC;IAEF,kDAAkD;IAClD,IAAI,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACjC,IAAI,OAAO,UAAU,CAAC,KAAK,KAAK,QAAQ,IAAI,UAAU,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YACpE,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAC/C,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;QACpC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
1
+ {"version":3,"file":"cloneToolResult.js","sourceRoot":"","sources":["../../../../src/prompt/utils/cloneToolResult.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,WAAgC;IAC7D,MAAM,MAAM,GAAwB;QAChC,EAAE,EAAE,WAAW,CAAC,EAAE;QAClB,IAAI,EAAE,WAAW,CAAC,IAAI;QACtB,MAAM,EAAE,WAAW,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;KACvF,CAAC;IAEF,uDAAuD;IACvD,IAAI,WAAW,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAClC,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC"}
@@ -1,5 +1,3 @@
1
- export { cloneToolResult } from "./cloneToolResult.js";
1
+ export { cloneToolOutcome } from "./cloneToolResult.js";
2
2
  export { deepClone } from "./deepClone.js";
3
- export { normalizeTextPrompt } from "./normalizeTextPrompt.js";
4
- export { normalizeToolResult } from "./normalizeToolResult.js";
5
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/prompt/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/prompt/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
@@ -1,5 +1,3 @@
1
- export { cloneToolResult } from "./cloneToolResult.js";
1
+ export { cloneToolOutcome } from "./cloneToolResult.js";
2
2
  export { deepClone } from "./deepClone.js";
3
- export { normalizeTextPrompt } from "./normalizeTextPrompt.js";
4
- export { normalizeToolResult } from "./normalizeToolResult.js";
5
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/prompt/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/prompt/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/src/sdk.d.ts CHANGED
@@ -1,15 +1,23 @@
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";
1
+ import type { CoreApiChatErrorResponse, IllaToolErrorJSON, IllaToolOutcomeJSON, MessageHistoryType, ModelContext, PendingToolCallType, PersonalityContext, UserContext } from "@illalabs/interfaces";
2
+ import type { AsyncCheckerEvents, AsyncToolCheckerCheckParams, AwaitableActionDescriptor, AwaitActionResult, CacheEntryOptions, ChatContextSnapshot, ContextManagerOptions, CoreApiProviderConfig, CoreApiProviderRoutes, EventSubscription, HttpClientFactory, ICache, IContextManager, PollingConfig, SendMessageResult } from "./internal.js";
3
+ import { Chat, ContextManager, Prompt } from "./internal.js";
4
4
  /**
5
5
  * Configuration options for initializing the IllaSDK.
6
6
  *
7
7
  * @property apiKey - Your ILLA API key for authentication
8
8
  * @property baseURL - Optional custom base URL for the ILLA API (defaults to production API)
9
+ * @property timeout - Optional request timeout in milliseconds
10
+ * @property headers - Optional additional headers to send with requests
11
+ * @property httpClientFactory - Optional custom HTTP client factory
12
+ * @property routes - Optional custom routes configuration
9
13
  */
10
14
  type illaSDKConfig = {
11
15
  apiKey: string;
12
16
  baseURL?: string;
17
+ timeout?: number;
18
+ headers?: Record<string, string>;
19
+ httpClientFactory?: HttpClientFactory;
20
+ routes?: CoreApiProviderRoutes;
13
21
  };
14
22
  /**
15
23
  * Optional configuration for the IllaSDK instance.
@@ -39,6 +47,7 @@ type ChatOptions = {
39
47
  userContext: UserContext;
40
48
  id?: string;
41
49
  personalityContext?: PersonalityContext;
50
+ modelContext?: ModelContext;
42
51
  };
43
52
  /**
44
53
  * Context for sending a message. Requires either a chatId (to use an existing chat)
@@ -54,6 +63,18 @@ type SendMessageContext = {
54
63
  chatId?: never;
55
64
  userContext: UserContext;
56
65
  };
66
+ /**
67
+ * Metadata extracted from a SendMessageResult response.
68
+ * Provides detailed information about the response including errors, pending tools, and tool errors.
69
+ */
70
+ type ResponseMetadata = {
71
+ isError: boolean;
72
+ text?: string;
73
+ messages?: MessageHistoryType;
74
+ pendingTools?: ReadonlyArray<PendingToolCallType>;
75
+ toolErrors?: ReadonlyArray<IllaToolErrorJSON>;
76
+ error?: CoreApiChatErrorResponse;
77
+ };
57
78
  /**
58
79
  * Error raised when attempting to interact with a chat that doesn't exist.
59
80
  *
@@ -194,15 +215,16 @@ declare class IllaSDK {
194
215
  * If a chatId is provided, the message will be sent to the existing chat.
195
216
  * If a chatId is not provided, a new chat will be created with the provided userContext.
196
217
  *
197
- * @param msg - The message text to send
218
+ * @param msg - The message to send (can be a string or Prompt object)
198
219
  * @param context - Context containing either chatId for existing chat or userContext for new chat
220
+ * @param chatOptions - Optional chat configuration when creating a new chat
199
221
  * @returns {Promise<SendMessageResult>} The AI's response including chat ID, response text, and any pending tools
200
222
  *
201
223
  * @example
202
224
  * ```typescript
203
225
  * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
204
226
  *
205
- * // Start a new conversation
227
+ * // Start a new conversation with a string
206
228
  * const result1 = await sdk.sendMessage(
207
229
  * "What can you help me with?",
208
230
  * { userContext: { address: "0x1234..." } }
@@ -210,11 +232,9 @@ declare class IllaSDK {
210
232
  * console.log(result1.response.text);
211
233
  * console.log("Chat ID:", result1.chatId);
212
234
  *
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
- * );
235
+ * // Continue the conversation with a Prompt object
236
+ * const prompt = new Prompt({ text: "I want to swap 1 ETH for USDC on Base" });
237
+ * const result2 = await sdk.sendMessage(prompt, { chatId: result1.chatId });
218
238
  *
219
239
  * // Check if there are tools to execute
220
240
  * if (result2.response.pendingTools && result2.response.pendingTools.length > 0) {
@@ -222,7 +242,15 @@ declare class IllaSDK {
222
242
  * }
223
243
  * ```
224
244
  */
225
- sendMessage(msg: string, context: SendMessageContext): Promise<SendMessageResult>;
245
+ sendMessage(msg: string | Prompt, context: SendMessageContext, chatOptions?: Omit<ChatOptions, "userContext">): Promise<SendMessageResult>;
246
+ /**
247
+ * Gets an existing chat or creates a new one if it doesn't exist.
248
+ *
249
+ * @param context - Context containing either chatId for existing chat or userContext for new chat
250
+ * @param chatOptions - Optional chat configuration when creating a new chat
251
+ * @returns {Chat} The chat instance
252
+ */
253
+ private getOrCreateChat;
226
254
  /**
227
255
  * Sends the result of a tool execution back to the AI. This method is used to complete
228
256
  * the tool execution loop when the AI requests a tool to be executed.
@@ -230,10 +258,12 @@ declare class IllaSDK {
230
258
  * @param chatId - The ID of the chat to send the tool result to
231
259
  * @param toolResult - The result of the tool execution
232
260
  * @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
261
+ * @throws {ChatNotFound} If the chat with the specified chatId is not found
234
262
  *
235
263
  * @example
236
264
  * ```typescript
265
+ * import { IllaToolOutcome, IllaToolError } from '@illalabs/interfaces';
266
+ *
237
267
  * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
238
268
  *
239
269
  * // Start a conversation that will request a tool execution
@@ -246,23 +276,26 @@ declare class IllaSDK {
246
276
  * if (result1.response.pendingTools && result1.response.pendingTools.length > 0) {
247
277
  * const tool = result1.response.pendingTools[0];
248
278
  *
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
- * };
279
+ * // Execute the tool and create the outcome
280
+ * let toolResult: IllaToolOutcome<unknown>;
281
+ * try {
282
+ * const executionResult = await executeTool(tool);
283
+ * toolResult = IllaToolOutcome.success(tool.toolCallId, tool.toolName, executionResult);
284
+ * } catch (error) {
285
+ * toolResult = IllaToolOutcome.error(
286
+ * tool.toolCallId,
287
+ * tool.toolName,
288
+ * IllaToolError.execution(tool.toolCallId, tool.toolName, error.message)
289
+ * );
290
+ * }
259
291
  *
260
- * const result2 = await sdk.sendToolResult(result1.chatId, toolResult);
292
+ * // Send the result back to ILLA
293
+ * const result2 = await sdk.sendToolResult(result1.chatId, toolResult.toJSON());
261
294
  * console.log(result2.response.text); // ILLA's response after processing the tool result
262
295
  * }
263
296
  * ```
264
297
  */
265
- sendToolResult(chatId: string, toolResult: ToolResultType): Promise<SendMessageResult>;
298
+ sendToolResult(chatId: string, toolResult: IllaToolOutcomeJSON): Promise<SendMessageResult>;
266
299
  /**
267
300
  * Gets the messages for a given chat ID.
268
301
  *
@@ -271,6 +304,198 @@ declare class IllaSDK {
271
304
  * @throws {ChatNotFound} If the chat with the specified chatId is not found
272
305
  */
273
306
  getMessages(chatId: string): Promise<MessageHistoryType>;
307
+ /**
308
+ * Appends messages to an existing chat's message history.
309
+ *
310
+ * @param chatId - The ID of the chat to append messages to
311
+ * @param messages - The messages to append to the chat history
312
+ * @throws {ChatNotFound} If the chat with the specified chatId is not found
313
+ *
314
+ * @example
315
+ * ```typescript
316
+ * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
317
+ *
318
+ * // Append synthetic messages for testing or prompting
319
+ * await sdk.appendMessages(chatId, [
320
+ * { role: "user", content: "Previous context..." },
321
+ * { role: "assistant", content: "Understood..." }
322
+ * ]);
323
+ * ```
324
+ */
325
+ appendMessages(chatId: string, messages: MessageHistoryType): Promise<void>;
326
+ /**
327
+ * Clears the message history for a chat while keeping the chat instance.
328
+ *
329
+ * @param chatId - The ID of the chat to clear
330
+ * @throws {ChatNotFound} If the chat with the specified chatId is not found
331
+ *
332
+ * @example
333
+ * ```typescript
334
+ * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
335
+ *
336
+ * // Clear chat history to start fresh
337
+ * await sdk.clearContext(chatId);
338
+ * ```
339
+ */
340
+ clearContext(chatId: string): Promise<void>;
341
+ /**
342
+ * Deletes a chat and removes all associated data.
343
+ *
344
+ * @param chatId - The ID of the chat to delete
345
+ * @throws {ChatNotFound} If the chat with the specified chatId is not found
346
+ *
347
+ * @example
348
+ * ```typescript
349
+ * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
350
+ *
351
+ * // Clean up chat when done
352
+ * await sdk.deleteChat(chatId);
353
+ * ```
354
+ */
355
+ deleteChat(chatId: string): Promise<void>;
356
+ /**
357
+ * Sends multiple tool results back to the AI in a single request.
358
+ * This method is used when multiple tools need to be executed and their results
359
+ * sent back together.
360
+ *
361
+ * @param chatId - The ID of the chat to send the tool results to
362
+ * @param toolResults - Array of tool execution results
363
+ * @param options - Optional parameters including AbortSignal
364
+ * @returns {Promise<SendMessageResult>} The AI's response after processing all tool results
365
+ * @throws {ChatNotFound} If the chat with the specified chatId is not found
366
+ *
367
+ * @example
368
+ * ```typescript
369
+ * import { IllaToolOutcome, IllaToolError } from '@illalabs/interfaces';
370
+ *
371
+ * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
372
+ *
373
+ * // Execute multiple tools and send results together
374
+ * const toolResults = pendingTools.map(tool => {
375
+ * try {
376
+ * const result = executeToolSync(tool);
377
+ * return IllaToolOutcome.success(tool.toolCallId, tool.toolName, result);
378
+ * } catch (error) {
379
+ * return IllaToolOutcome.error(
380
+ * tool.toolCallId,
381
+ * tool.toolName,
382
+ * IllaToolError.execution(tool.toolCallId, tool.toolName, error.message)
383
+ * );
384
+ * }
385
+ * });
386
+ *
387
+ * const response = await sdk.sendToolResults(chatId, toolResults.map(r => r.toJSON()));
388
+ * ```
389
+ */
390
+ sendToolResults(chatId: string, toolResults: IllaToolOutcomeJSON[]): Promise<SendMessageResult>;
391
+ /**
392
+ * Subscribes to status updates for a long-running tool execution.
393
+ *
394
+ * @param params - Parameters identifying the tool execution to monitor
395
+ * @param callbacks - Event handlers for status changes and errors
396
+ * @param config - Optional polling configuration
397
+ * @returns {EventSubscription} Subscription handle to cancel monitoring
398
+ *
399
+ * @example
400
+ * ```typescript
401
+ * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
402
+ *
403
+ * const subscription = sdk.subscribeToToolStatus(
404
+ * { toolName: "swap", protocol: "li.fi", args: txHash },
405
+ * {
406
+ * onStatusChange: (event) => console.log("Status:", event.status),
407
+ * onError: (error) => console.error("Error:", error)
408
+ * },
409
+ * { interval: 2000, maxDuration: 300, maxRetries: 3 }
410
+ * );
411
+ *
412
+ * // Later, cancel the subscription
413
+ * subscription.unsubscribe();
414
+ * ```
415
+ */
416
+ subscribeToToolStatus<TPayload = unknown, TError = unknown>(params: AsyncToolCheckerCheckParams, callbacks: AsyncCheckerEvents<TPayload, TError>, config?: Partial<PollingConfig>): EventSubscription;
417
+ /**
418
+ * Awaits the completion of a long-running action triggered by a chat.
419
+ *
420
+ * @param chatId - The ID of the chat that triggered the action
421
+ * @param descriptor - Descriptor identifying the action to track
422
+ * @returns {Promise<AwaitActionResult>} The final status of the action
423
+ * @throws {ChatNotFound} If the chat with the specified chatId is not found
424
+ *
425
+ * @example
426
+ * ```typescript
427
+ * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
428
+ *
429
+ * const result = await sdk.awaitAction(chatId, {
430
+ * toolName: "swap",
431
+ * protocol: "li.fi",
432
+ * args: { txHash: "0x..." }
433
+ * });
434
+ *
435
+ * if (result.isError) {
436
+ * console.error("Action failed:", result.error);
437
+ * } else {
438
+ * console.log("Action completed:", result.response);
439
+ * }
440
+ * ```
441
+ */
442
+ awaitAction(chatId: string, descriptor: AwaitableActionDescriptor): Promise<AwaitActionResult>;
443
+ /**
444
+ * Gets the underlying Chat instance for advanced operations.
445
+ *
446
+ * @param chatId - The ID of the chat to retrieve
447
+ * @returns {Chat} The Chat instance
448
+ * @throws {ChatNotFound} If the chat with the specified chatId is not found
449
+ *
450
+ * @example
451
+ * ```typescript
452
+ * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
453
+ *
454
+ * const chat = sdk.getChat(chatId);
455
+ * // Now you can use advanced Chat methods directly
456
+ * const context = await chat.getContext();
457
+ * ```
458
+ */
459
+ getChat(chatId: string): Chat;
460
+ /**
461
+ * Gets all active chat IDs as an array.
462
+ * Alias for the chatIds getter property.
463
+ *
464
+ * @returns {string[]} Array of active chat IDs
465
+ *
466
+ * @example
467
+ * ```typescript
468
+ * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
469
+ *
470
+ * const ids = sdk.getChatIds();
471
+ * console.log("Active chats:", ids);
472
+ * ```
473
+ */
474
+ getChatIds(): string[];
475
+ /**
476
+ * Helper method to extract detailed response metadata from a SendMessageResult.
477
+ * Provides access to incompleteTools, toolErrors, and other response details.
478
+ *
479
+ * @param result - The SendMessageResult to extract metadata from
480
+ * @returns {ResponseMetadata} Extracted response metadata
481
+ *
482
+ * @example
483
+ * ```typescript
484
+ * const sdk = new IllaSDK({ apiKey: 'your-api-key' });
485
+ *
486
+ * const result = await sdk.sendMessage("Hello", { chatId });
487
+ * const metadata = sdk.getResponseMetadata(result);
488
+ *
489
+ * if (metadata.incompleteTools?.length > 0) {
490
+ * console.log("Incomplete tools:", metadata.incompleteTools);
491
+ * }
492
+ * if (metadata.toolErrors?.length > 0) {
493
+ * console.log("Tool errors:", metadata.toolErrors);
494
+ * }
495
+ * ```
496
+ */
497
+ getResponseMetadata(result: SendMessageResult): ResponseMetadata;
498
+ private isSuccessResponse;
274
499
  }
275
500
  /**
276
501
  * Exports the public API of the SDK.
@@ -285,5 +510,6 @@ export { ContextManager } from "./context/index.js";
285
510
  export { AsyncToolChecker } from "./asyncToolChecker/index.js";
286
511
  export { CoreApiProvider } from "./providers/index.js";
287
512
  export { UserContextMissing } from "./chat/errors/index.js";
288
- export type { illaSDKConfig, ChatContextSnapshot, CacheEntryOptions, ICache, IContextManager, SendMessageContext, };
513
+ export type { illaSDKConfig, illaSDKOptions, ChatOptions, ChatContextSnapshot, CacheEntryOptions, ICache, IContextManager, SendMessageContext, SendMessageResult, ResponseMetadata, AsyncCheckerEvents, AsyncToolCheckerCheckParams, AwaitableActionDescriptor, AwaitActionResult, CoreApiProviderConfig, CoreApiProviderRoutes, EventSubscription, HttpClientFactory, PollingConfig, ContextManagerOptions, };
514
+ export type { MessageHistoryType, IllaToolOutcomeJSON, IllaToolErrorJSON, UserContext, ModelContext, PersonalityContext, CoreApiChatErrorResponse, CoreApiChatSuccessResponse, PendingToolCallType, } from "@illalabs/interfaces";
289
515
  //# sourceMappingURL=sdk.d.ts.map
@@ -1 +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,c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