@agentica/core 0.24.0 → 0.26.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 (189) hide show
  1. package/README.md +56 -17
  2. package/lib/Agentica.d.ts +2 -2
  3. package/lib/Agentica.js +4 -4
  4. package/lib/Agentica.js.map +1 -1
  5. package/lib/MicroAgentica.d.ts +2 -2
  6. package/lib/MicroAgentica.js +4 -4
  7. package/lib/MicroAgentica.js.map +1 -1
  8. package/lib/context/AgenticaContext.d.ts +2 -2
  9. package/lib/context/MicroAgenticaContext.d.ts +2 -2
  10. package/lib/context/index.d.ts +5 -0
  11. package/lib/{structures/mcp → context}/index.js +5 -1
  12. package/lib/context/index.js.map +1 -0
  13. package/lib/context/internal/AgenticaOperationComposer.spec.js +13 -5
  14. package/lib/context/internal/AgenticaOperationComposer.spec.js.map +1 -1
  15. package/lib/events/AgenticaAssistantMessageEvent.d.ts +9 -0
  16. package/lib/events/AgenticaAssistantMessageEvent.js +3 -0
  17. package/lib/events/AgenticaAssistantMessageEvent.js.map +1 -0
  18. package/lib/events/AgenticaEvent.d.ts +9 -9
  19. package/lib/events/AgenticaEvent.type.d.ts +1 -0
  20. package/lib/events/AgenticaEvent.type.js +8 -0
  21. package/lib/events/AgenticaEvent.type.js.map +1 -0
  22. package/lib/events/AgenticaUserMessageEvent.d.ts +9 -0
  23. package/lib/events/{AgenticaUserInputEvent.js → AgenticaUserMessageEvent.js} +1 -1
  24. package/lib/events/AgenticaUserMessageEvent.js.map +1 -0
  25. package/lib/events/MicroAgenticaEvent.d.ts +6 -6
  26. package/lib/events/index.d.ts +14 -0
  27. package/lib/events/index.js +31 -0
  28. package/lib/events/index.js.map +1 -0
  29. package/lib/factory/events.d.ts +8 -8
  30. package/lib/factory/events.js +23 -38
  31. package/lib/factory/events.js.map +1 -1
  32. package/lib/factory/histories.d.ts +1 -36
  33. package/lib/factory/histories.js +103 -22
  34. package/lib/factory/histories.js.map +1 -1
  35. package/lib/functional/assertHttpController.js +6 -6
  36. package/lib/functional/assertHttpLlmApplication.js +6 -6
  37. package/lib/functional/assertMcpController.d.ts +1 -2
  38. package/lib/functional/assertMcpController.js +6 -6
  39. package/lib/functional/assertMcpController.js.map +1 -1
  40. package/lib/functional/index.d.ts +6 -0
  41. package/lib/functional/index.js +23 -0
  42. package/lib/functional/index.js.map +1 -0
  43. package/lib/functional/validateHttpController.js +5 -5
  44. package/lib/functional/validateHttpLlmApplication.js +5 -5
  45. package/lib/functional/validateMcpController.d.ts +1 -2
  46. package/lib/functional/validateMcpController.js +11 -11
  47. package/lib/functional/validateMcpController.js.map +1 -1
  48. package/lib/histories/AgenticaAssistantMessageHistory.d.ts +5 -0
  49. package/lib/histories/AgenticaAssistantMessageHistory.js +3 -0
  50. package/lib/histories/AgenticaAssistantMessageHistory.js.map +1 -0
  51. package/lib/histories/AgenticaHistory.d.ts +9 -7
  52. package/lib/histories/{AgenticaTextHistory.d.ts → AgenticaSystemMessageHistory.d.ts} +1 -2
  53. package/lib/histories/{AgenticaUserInputHistory.js → AgenticaSystemMessageHistory.js} +1 -1
  54. package/lib/histories/AgenticaSystemMessageHistory.js.map +1 -0
  55. package/lib/histories/AgenticaUserMessageHistory.d.ts +6 -0
  56. package/lib/{events/AgenticaTextEvent.js → histories/AgenticaUserMessageHistory.js} +1 -1
  57. package/lib/histories/AgenticaUserMessageHistory.js.map +1 -0
  58. package/lib/histories/MicroAgenticaHistory.d.ts +5 -4
  59. package/lib/histories/contents/AgenticaUserMessageAudioContent.d.ts +19 -0
  60. package/lib/histories/contents/AgenticaUserMessageAudioContent.js +3 -0
  61. package/lib/histories/contents/AgenticaUserMessageAudioContent.js.map +1 -0
  62. package/lib/histories/contents/AgenticaUserMessageContent.d.ts +14 -0
  63. package/lib/histories/{AgenticaTextHistory.js → contents/AgenticaUserMessageContent.js} +1 -1
  64. package/lib/histories/contents/AgenticaUserMessageContent.js.map +1 -0
  65. package/lib/histories/contents/AgenticaUserMessageContentBase.d.ts +6 -0
  66. package/lib/histories/contents/AgenticaUserMessageContentBase.js +3 -0
  67. package/lib/histories/contents/AgenticaUserMessageContentBase.js.map +1 -0
  68. package/lib/histories/contents/AgenticaUserMessageFileContent.d.ts +26 -0
  69. package/lib/histories/contents/AgenticaUserMessageFileContent.js +3 -0
  70. package/lib/histories/contents/AgenticaUserMessageFileContent.js.map +1 -0
  71. package/lib/histories/contents/AgenticaUserMessageImageContent.d.ts +20 -0
  72. package/lib/histories/contents/AgenticaUserMessageImageContent.js +3 -0
  73. package/lib/histories/contents/AgenticaUserMessageImageContent.js.map +1 -0
  74. package/lib/histories/contents/AgenticaUserMessageTextContent.d.ts +14 -0
  75. package/lib/histories/contents/AgenticaUserMessageTextContent.js +3 -0
  76. package/lib/histories/contents/AgenticaUserMessageTextContent.js.map +1 -0
  77. package/lib/histories/contents/index.d.ts +5 -0
  78. package/lib/histories/contents/index.js +22 -0
  79. package/lib/histories/contents/index.js.map +1 -0
  80. package/lib/histories/index.d.ts +10 -0
  81. package/lib/histories/index.js +27 -0
  82. package/lib/histories/index.js.map +1 -0
  83. package/lib/index.d.ts +6 -45
  84. package/lib/index.js +6 -46
  85. package/lib/index.js.map +1 -1
  86. package/lib/index.mjs +182 -131
  87. package/lib/index.mjs.map +1 -1
  88. package/lib/json/IAgenticaEventJson.d.ts +44 -19
  89. package/lib/json/IAgenticaEventJson.type.d.ts +1 -0
  90. package/lib/json/IAgenticaEventJson.type.js +8 -0
  91. package/lib/json/IAgenticaEventJson.type.js.map +1 -0
  92. package/lib/json/IAgenticaHistoryJson.d.ts +34 -19
  93. package/lib/json/IAgenticaHistoryJson.type.d.ts +1 -0
  94. package/lib/json/IAgenticaHistoryJson.type.js +8 -0
  95. package/lib/json/IAgenticaHistoryJson.type.js.map +1 -0
  96. package/lib/json/IMicroAgenticaEventJson.d.ts +1 -1
  97. package/lib/json/IMicroAgenticaHistoryJson.d.ts +1 -1
  98. package/lib/json/index.d.ts +7 -0
  99. package/lib/json/index.js +24 -0
  100. package/lib/json/index.js.map +1 -0
  101. package/lib/orchestrate/call.js +4 -4
  102. package/lib/orchestrate/call.js.map +1 -1
  103. package/lib/orchestrate/cancel.js +1 -1
  104. package/lib/orchestrate/cancel.js.map +1 -1
  105. package/lib/orchestrate/initialize.js +4 -4
  106. package/lib/orchestrate/initialize.js.map +1 -1
  107. package/lib/orchestrate/select.js +3 -3
  108. package/lib/orchestrate/select.js.map +1 -1
  109. package/lib/structures/IAgenticaController.d.ts +1 -2
  110. package/lib/structures/index.d.ts +10 -0
  111. package/lib/structures/index.js +27 -0
  112. package/lib/structures/index.js.map +1 -0
  113. package/lib/transformers/transformHistory.d.ts +1 -0
  114. package/lib/transformers/{AgenticaHistoryTransformer.js → transformHistory.js} +33 -23
  115. package/lib/transformers/transformHistory.js.map +1 -0
  116. package/lib/utils/ChatGptCompletionMessageUtil.js +2 -2
  117. package/lib/utils/types.d.ts +33 -0
  118. package/lib/utils/types.js +29 -0
  119. package/lib/utils/types.js.map +1 -0
  120. package/package.json +7 -7
  121. package/src/Agentica.ts +10 -9
  122. package/src/MicroAgentica.ts +12 -9
  123. package/src/context/AgenticaContext.ts +2 -2
  124. package/src/context/MicroAgenticaContext.ts +2 -2
  125. package/src/context/index.ts +5 -0
  126. package/src/context/internal/AgenticaOperationComposer.spec.ts +15 -5
  127. package/src/events/AgenticaAssistantMessageEvent.ts +12 -0
  128. package/src/events/AgenticaEvent.ts +15 -15
  129. package/src/events/AgenticaEvent.type.ts +19 -0
  130. package/src/events/AgenticaUserMessageEvent.ts +12 -0
  131. package/src/events/MicroAgenticaEvent.ts +9 -9
  132. package/src/events/index.ts +14 -0
  133. package/src/factory/events.ts +29 -34
  134. package/src/factory/histories.ts +120 -29
  135. package/src/functional/assertMcpController.ts +4 -2
  136. package/src/functional/index.ts +7 -0
  137. package/src/functional/validateMcpController.ts +4 -2
  138. package/src/histories/AgenticaAssistantMessageHistory.ts +10 -0
  139. package/src/histories/AgenticaHistory.ts +11 -8
  140. package/src/histories/{AgenticaTextHistory.ts → AgenticaSystemMessageHistory.ts} +4 -2
  141. package/src/histories/AgenticaUserMessageHistory.ts +11 -0
  142. package/src/histories/MicroAgenticaHistory.ts +6 -5
  143. package/src/histories/contents/AgenticaUserMessageAudioContent.ts +21 -0
  144. package/src/histories/contents/AgenticaUserMessageContent.ts +19 -0
  145. package/src/histories/contents/AgenticaUserMessageContentBase.ts +6 -0
  146. package/src/histories/contents/AgenticaUserMessageFileContent.ts +27 -0
  147. package/src/histories/contents/AgenticaUserMessageImageContent.ts +23 -0
  148. package/src/histories/contents/AgenticaUserMessageTextContent.ts +15 -0
  149. package/src/histories/contents/index.ts +5 -0
  150. package/src/histories/index.ts +10 -0
  151. package/src/index.ts +6 -54
  152. package/src/json/IAgenticaEventJson.ts +53 -21
  153. package/src/json/IAgenticaEventJson.type.ts +19 -0
  154. package/src/json/IAgenticaHistoryJson.ts +41 -23
  155. package/src/json/IAgenticaHistoryJson.type.ts +19 -0
  156. package/src/json/IMicroAgenticaEventJson.ts +2 -1
  157. package/src/json/IMicroAgenticaHistoryJson.ts +2 -1
  158. package/src/json/index.ts +7 -0
  159. package/src/orchestrate/call.ts +8 -8
  160. package/src/orchestrate/cancel.ts +2 -2
  161. package/src/orchestrate/initialize.ts +5 -5
  162. package/src/orchestrate/select.ts +5 -5
  163. package/src/structures/IAgenticaController.ts +4 -2
  164. package/src/structures/index.ts +10 -0
  165. package/src/transformers/{AgenticaHistoryTransformer.ts → transformHistory.ts} +43 -26
  166. package/src/utils/types.ts +50 -0
  167. package/lib/events/AgenticaTextEvent.d.ts +0 -10
  168. package/lib/events/AgenticaTextEvent.js.map +0 -1
  169. package/lib/events/AgenticaUserInputEvent.d.ts +0 -10
  170. package/lib/events/AgenticaUserInputEvent.js.map +0 -1
  171. package/lib/histories/AgenticaTextHistory.js.map +0 -1
  172. package/lib/histories/AgenticaUserInputHistory.d.ts +0 -86
  173. package/lib/histories/AgenticaUserInputHistory.js.map +0 -1
  174. package/lib/structures/mcp/IMcpLlmTransportProps.d.ts +0 -11
  175. package/lib/structures/mcp/IMcpLlmTransportProps.js +0 -3
  176. package/lib/structures/mcp/IMcpLlmTransportProps.js.map +0 -1
  177. package/lib/structures/mcp/index.d.ts +0 -1
  178. package/lib/structures/mcp/index.js.map +0 -1
  179. package/lib/transformers/AgenticaEventTransformer.d.ts +0 -63
  180. package/lib/transformers/AgenticaEventTransformer.js +0 -155
  181. package/lib/transformers/AgenticaEventTransformer.js.map +0 -1
  182. package/lib/transformers/AgenticaHistoryTransformer.d.ts +0 -41
  183. package/lib/transformers/AgenticaHistoryTransformer.js.map +0 -1
  184. package/src/events/AgenticaTextEvent.ts +0 -12
  185. package/src/events/AgenticaUserInputEvent.ts +0 -12
  186. package/src/histories/AgenticaUserInputHistory.ts +0 -94
  187. package/src/structures/mcp/IMcpLlmTransportProps.ts +0 -13
  188. package/src/structures/mcp/index.ts +0 -1
  189. package/src/transformers/AgenticaEventTransformer.ts +0 -196
@@ -1,12 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AgenticaHistoryTransformer = void 0;
3
+ exports.transformHistory = transformHistory;
4
4
  const histories_1 = require("../factory/histories");
5
5
  const operations_1 = require("../factory/operations");
6
- function transform(props) {
7
- // TEXT
8
- if (props.history.type === "text") {
9
- return transformText({
6
+ /**
7
+ * @internal
8
+ */
9
+ function transformHistory(props) {
10
+ // USER
11
+ if (props.history.type === "userMessage") {
12
+ return transformUserMessage({
13
+ history: props.history,
14
+ });
15
+ }
16
+ // ASSISTANT
17
+ else if (props.history.type === "assistantMessage") {
18
+ return transformAssistantMessage({
19
+ history: props.history,
20
+ });
21
+ }
22
+ // SYSTEM
23
+ else if (props.history.type === "systemMessage") {
24
+ return transformSystemMessage({
10
25
  history: props.history,
11
26
  });
12
27
  }
@@ -30,16 +45,19 @@ function transform(props) {
30
45
  history: props.history,
31
46
  });
32
47
  }
33
- else if (props.history.type === "describe") {
34
- return transformDescribe({
35
- operations: props.operations,
36
- history: props.history,
37
- });
38
- }
39
- throw new Error("Invalid prompt type.");
48
+ return transformDescribe({
49
+ operations: props.operations,
50
+ history: props.history,
51
+ });
52
+ }
53
+ function transformAssistantMessage(props) {
54
+ return (0, histories_1.createAssistantMessageHistory)(props.history);
55
+ }
56
+ function transformSystemMessage(props) {
57
+ return (0, histories_1.createSystemMessageHistory)(props.history);
40
58
  }
41
- function transformText(props) {
42
- return (0, histories_1.createTextHistory)(props.history);
59
+ function transformUserMessage(props) {
60
+ return (0, histories_1.createUserMessageHistory)(props.history);
43
61
  }
44
62
  function transformSelect(props) {
45
63
  return (0, histories_1.createSelectHistory)({
@@ -98,12 +116,4 @@ function findOperation(props) {
98
116
  }
99
117
  return found;
100
118
  }
101
- exports.AgenticaHistoryTransformer = {
102
- transform,
103
- transformText,
104
- transformSelect,
105
- transformCancel,
106
- transformExecute,
107
- transformDescribe,
108
- };
109
- //# sourceMappingURL=AgenticaHistoryTransformer.js.map
119
+ //# sourceMappingURL=transformHistory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformHistory.js","sourceRoot":"","sources":["../../src/transformers/transformHistory.ts"],"names":[],"mappings":";;AAmBA,4CA8CC;AApDD,oDAAkN;AAClN,sDAAiE;AAEjE;;GAEG;AACH,SAAgB,gBAAgB,CAAiC,KAGhE;IACC,OAAO;IACP,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;QACzC,OAAO,oBAAoB,CAAC;YAC1B,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;IACL,CAAC;IACD,YAAY;SACP,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QACnD,OAAO,yBAAyB,CAAC;YAC/B,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;IACL,CAAC;IACD,SAAS;SACJ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;QAChD,OAAO,sBAAsB,CAAC;YAC5B,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;IACL,CAAC;IACD,kBAAkB;SACb,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACzC,OAAO,eAAe,CAAC;YACrB,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;IACL,CAAC;SACI,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACzC,OAAO,eAAe,CAAC;YACrB,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;IACL,CAAC;IACD,UAAU;SACL,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO,gBAAgB,CAAC;YACtB,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;IACL,CAAC;IACD,OAAO,iBAAiB,CAAC;QACvB,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAC,CAAC;AACL,CAAC;AAED,SAAS,yBAAyB,CAAC,KAElC;IACC,OAAO,IAAA,yCAA6B,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,sBAAsB,CAAC,KAE/B;IACC,OAAO,IAAA,sCAA0B,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACnD,CAAC;AAED,SAAS,oBAAoB,CAAC,KAE7B;IACC,OAAO,IAAA,oCAAwB,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACjD,CAAC;AAED,SAAS,eAAe,CAAiC,KAGxD;IACC,OAAO,IAAA,+BAAmB,EAAC;QACzB,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE;QACpB,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CACtC,MAAM,CAAC,EAAE,CACP,IAAA,qCAAwB,EAAC;YACvB,SAAS,EAAE,aAAa,CAAC;gBACvB,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,KAAK,EAAE,MAAM,CAAC,SAAS;aACxB,CAAC;YACF,MAAM,EAAE,MAAM,CAAC,MAAM;SACtB,CAAC,CACL;KACF,CAAC,CAAC;AACL,CAAC;AAED,SAAS,eAAe,CAAiC,KAGxD;IACC,OAAO,IAAA,+BAAmB,EAAC;QACzB,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE;QACpB,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CACtC,MAAM,CAAC,EAAE,CACP,IAAA,qCAAwB,EAAC;YACvB,SAAS,EAAE,aAAa,CAAC;gBACvB,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,KAAK,EAAE,MAAM,CAAC,SAAS;aACxB,CAAC;YACF,MAAM,EAAE,MAAM,CAAC,MAAM;SACtB,CAAC,CACL;KACF,CAAC,CAAC;AACL,CAAC;AAED,SAAS,gBAAgB,CAAiC,KAGzD;IACC,OAAO,IAAA,gCAAoB,EAAC;QAC1B,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE;QACpB,SAAS,EAAE,aAAa,CAAC;YACvB,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,SAAS;SAC/B,CAAC;QACF,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,SAAS;QAClC;;;WAGG;QACH,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,KAAgC;KACtD,CAAC,CAAC;AACL,CAAC;AAED,SAAS,iBAAiB,CAAiC,KAG1D;IACC,OAAO,IAAA,iCAAqB,EAAC;QAC3B,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI;QACxB,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAC1C,gBAAgB,CAAC;YACf,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,OAAO,EAAE,IAAI;SACd,CAAC,CACH;KACF,CAAC,CAAC;AACL,CAAC;AAED,SAAS,aAAa,CAAiC,KAMtD;;IACC,MAAM,KAAK,GAAyC,MAAA,KAAK,CAAC,UAAU;SACjE,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,0CAC1B,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC9B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,oCAAoC,KAAK,CAAC,KAAK,CAAC,UAAU,eAAe,KAAK,CAAC,KAAK,CAAC,QAAQ,GAAG,CACjG,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -44,7 +44,7 @@ const ChatGptTokenUsageAggregator_1 = require("./ChatGptTokenUsageAggregator");
44
44
  function transformCompletionChunk(source) {
45
45
  const str = source instanceof Uint8Array ? ByteArrayUtil_1.ByteArrayUtil.toUtf8(source) : source;
46
46
  const result = JSON.parse(str);
47
- const valid = (() => { const _io0 = input => "string" === typeof input.id && (Array.isArray(input.choices) && input.choices.every(elem => "object" === typeof elem && null !== elem && _io1(elem))) && "number" === typeof input.created && "string" === typeof input.model && "chat.completion.chunk" === input.object && (null === input.service_tier || undefined === input.service_tier || "scale" === input.service_tier || "default" === input.service_tier) && (undefined === input.system_fingerprint || "string" === typeof input.system_fingerprint) && (null === input.usage || undefined === input.usage || "object" === typeof input.usage && null !== input.usage && _io9(input.usage)); const _io1 = input => "object" === typeof input.delta && null !== input.delta && false === Array.isArray(input.delta) && _io2(input.delta) && (null === input.finish_reason || "length" === input.finish_reason || "function_call" === input.finish_reason || "stop" === input.finish_reason || "tool_calls" === input.finish_reason || "content_filter" === input.finish_reason) && "number" === typeof input.index && (null === input.logprobs || undefined === input.logprobs || "object" === typeof input.logprobs && null !== input.logprobs && _io6(input.logprobs)); const _io2 = input => (null === input.content || undefined === input.content || "string" === typeof input.content) && (undefined === input.function_call || "object" === typeof input.function_call && null !== input.function_call && false === Array.isArray(input.function_call) && _io3(input.function_call)) && (null === input.refusal || undefined === input.refusal || "string" === typeof input.refusal) && (undefined === input.role || "assistant" === input.role || "user" === input.role || "developer" === input.role || "system" === input.role || "tool" === input.role) && (undefined === input.tool_calls || Array.isArray(input.tool_calls) && input.tool_calls.every(elem => "object" === typeof elem && null !== elem && _io4(elem))); const _io3 = input => (undefined === input.arguments || "string" === typeof input.arguments) && (undefined === input.name || "string" === typeof input.name); const _io4 = input => "number" === typeof input.index && (undefined === input.id || "string" === typeof input.id) && (undefined === input["function"] || "object" === typeof input["function"] && null !== input["function"] && false === Array.isArray(input["function"]) && _io5(input["function"])) && (undefined === input.type || "function" === input.type); const _io5 = input => (undefined === input.arguments || "string" === typeof input.arguments) && (undefined === input.name || "string" === typeof input.name); const _io6 = input => (null === input.content || Array.isArray(input.content) && input.content.every(elem => "object" === typeof elem && null !== elem && _io7(elem))) && (null === input.refusal || Array.isArray(input.refusal) && input.refusal.every(elem => "object" === typeof elem && null !== elem && _io7(elem))); const _io7 = input => "string" === typeof input.token && (null === input.bytes || Array.isArray(input.bytes) && input.bytes.every(elem => "number" === typeof elem)) && "number" === typeof input.logprob && (Array.isArray(input.top_logprobs) && input.top_logprobs.every(elem => "object" === typeof elem && null !== elem && _io8(elem))); const _io8 = input => "string" === typeof input.token && (null === input.bytes || Array.isArray(input.bytes) && input.bytes.every(elem => "number" === typeof elem)) && "number" === typeof input.logprob; const _io9 = input => "number" === typeof input.completion_tokens && "number" === typeof input.prompt_tokens && "number" === typeof input.total_tokens && (undefined === input.completion_tokens_details || "object" === typeof input.completion_tokens_details && null !== input.completion_tokens_details && false === Array.isArray(input.completion_tokens_details) && _io10(input.completion_tokens_details)) && (undefined === input.prompt_tokens_details || "object" === typeof input.prompt_tokens_details && null !== input.prompt_tokens_details && false === Array.isArray(input.prompt_tokens_details) && _io11(input.prompt_tokens_details)); const _io10 = input => (undefined === input.accepted_prediction_tokens || "number" === typeof input.accepted_prediction_tokens) && (undefined === input.audio_tokens || "number" === typeof input.audio_tokens) && (undefined === input.reasoning_tokens || "number" === typeof input.reasoning_tokens) && (undefined === input.rejected_prediction_tokens || "number" === typeof input.rejected_prediction_tokens); const _io11 = input => (undefined === input.audio_tokens || "number" === typeof input.audio_tokens) && (undefined === input.cached_tokens || "number" === typeof input.cached_tokens); const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.id || _report(_exceptionable, {
47
+ const valid = (() => { const _io0 = input => "string" === typeof input.id && (Array.isArray(input.choices) && input.choices.every(elem => "object" === typeof elem && null !== elem && _io1(elem))) && "number" === typeof input.created && "string" === typeof input.model && "chat.completion.chunk" === input.object && (null === input.service_tier || undefined === input.service_tier || "scale" === input.service_tier || "default" === input.service_tier) && (undefined === input.system_fingerprint || "string" === typeof input.system_fingerprint) && (null === input.usage || undefined === input.usage || "object" === typeof input.usage && null !== input.usage && _io9(input.usage)); const _io1 = input => "object" === typeof input.delta && null !== input.delta && false === Array.isArray(input.delta) && _io2(input.delta) && (null === input.finish_reason || "length" === input.finish_reason || "function_call" === input.finish_reason || "stop" === input.finish_reason || "tool_calls" === input.finish_reason || "content_filter" === input.finish_reason) && "number" === typeof input.index && (null === input.logprobs || undefined === input.logprobs || "object" === typeof input.logprobs && null !== input.logprobs && _io6(input.logprobs)); const _io2 = input => (null === input.content || undefined === input.content || "string" === typeof input.content) && (undefined === input.function_call || "object" === typeof input.function_call && null !== input.function_call && false === Array.isArray(input.function_call) && _io3(input.function_call)) && (null === input.refusal || undefined === input.refusal || "string" === typeof input.refusal) && (undefined === input.role || "user" === input.role || "developer" === input.role || "system" === input.role || "assistant" === input.role || "tool" === input.role) && (undefined === input.tool_calls || Array.isArray(input.tool_calls) && input.tool_calls.every(elem => "object" === typeof elem && null !== elem && _io4(elem))); const _io3 = input => (undefined === input.arguments || "string" === typeof input.arguments) && (undefined === input.name || "string" === typeof input.name); const _io4 = input => "number" === typeof input.index && (undefined === input.id || "string" === typeof input.id) && (undefined === input["function"] || "object" === typeof input["function"] && null !== input["function"] && false === Array.isArray(input["function"]) && _io5(input["function"])) && (undefined === input.type || "function" === input.type); const _io5 = input => (undefined === input.arguments || "string" === typeof input.arguments) && (undefined === input.name || "string" === typeof input.name); const _io6 = input => (null === input.content || Array.isArray(input.content) && input.content.every(elem => "object" === typeof elem && null !== elem && _io7(elem))) && (null === input.refusal || Array.isArray(input.refusal) && input.refusal.every(elem => "object" === typeof elem && null !== elem && _io7(elem))); const _io7 = input => "string" === typeof input.token && (null === input.bytes || Array.isArray(input.bytes) && input.bytes.every(elem => "number" === typeof elem)) && "number" === typeof input.logprob && (Array.isArray(input.top_logprobs) && input.top_logprobs.every(elem => "object" === typeof elem && null !== elem && _io8(elem))); const _io8 = input => "string" === typeof input.token && (null === input.bytes || Array.isArray(input.bytes) && input.bytes.every(elem => "number" === typeof elem)) && "number" === typeof input.logprob; const _io9 = input => "number" === typeof input.completion_tokens && "number" === typeof input.prompt_tokens && "number" === typeof input.total_tokens && (undefined === input.completion_tokens_details || "object" === typeof input.completion_tokens_details && null !== input.completion_tokens_details && false === Array.isArray(input.completion_tokens_details) && _io10(input.completion_tokens_details)) && (undefined === input.prompt_tokens_details || "object" === typeof input.prompt_tokens_details && null !== input.prompt_tokens_details && false === Array.isArray(input.prompt_tokens_details) && _io11(input.prompt_tokens_details)); const _io10 = input => (undefined === input.accepted_prediction_tokens || "number" === typeof input.accepted_prediction_tokens) && (undefined === input.audio_tokens || "number" === typeof input.audio_tokens) && (undefined === input.reasoning_tokens || "number" === typeof input.reasoning_tokens) && (undefined === input.rejected_prediction_tokens || "number" === typeof input.rejected_prediction_tokens); const _io11 = input => (undefined === input.audio_tokens || "number" === typeof input.audio_tokens) && (undefined === input.cached_tokens || "number" === typeof input.cached_tokens); const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.id || _report(_exceptionable, {
48
48
  path: _path + ".id",
49
49
  expected: "string",
50
50
  value: input.id
@@ -132,7 +132,7 @@ function transformCompletionChunk(source) {
132
132
  path: _path + ".refusal",
133
133
  expected: "(null | string | undefined)",
134
134
  value: input.refusal
135
- }), undefined === input.role || "assistant" === input.role || "user" === input.role || "developer" === input.role || "system" === input.role || "tool" === input.role || _report(_exceptionable, {
135
+ }), undefined === input.role || "user" === input.role || "developer" === input.role || "system" === input.role || "assistant" === input.role || "tool" === input.role || _report(_exceptionable, {
136
136
  path: _path + ".role",
137
137
  expected: "(\"assistant\" | \"developer\" | \"system\" | \"tool\" | \"user\" | undefined)",
138
138
  value: input.role
@@ -0,0 +1,33 @@
1
+ /**
2
+ * from ts-toolbelt repository
3
+ * https://github.com/millsp/ts-toolbelt/blob/master/sources/Test.ts
4
+ */
5
+ type Equals<A1, A2> = (<A>() => A extends A2 ? 1 : 0) extends <A>() => A extends A1 ? 1 : 0 ? 1 : 0;
6
+ type Boolean = 0 | 1;
7
+ /**
8
+ * Test should pass
9
+ */
10
+ export type Pass = 1;
11
+ /**
12
+ * Test should fail
13
+ */
14
+ export type Fail = 0;
15
+ /**
16
+ * Check or test the validity of a type
17
+ * @param debug to debug with parameter hints (`ctrl+p`, `ctrl+shift+space`)
18
+ * @example
19
+ * ```ts
20
+ * // see in `tst` folder
21
+ * ```
22
+ */
23
+ export declare function check<Type, Expect, Outcome extends Boolean>(debug?: Type): Equals<Equals<Type, Expect>, Outcome>;
24
+ /**
25
+ * Validates a batch of [[check]]
26
+ * @param _checks a batch of [[check]]
27
+ * @example
28
+ * ```ts
29
+ * // see in `tst` folder
30
+ * ```
31
+ */
32
+ export declare function checks(_checks: 1[]): void;
33
+ export {};
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.check = check;
4
+ exports.checks = checks;
5
+ /**
6
+ * Check or test the validity of a type
7
+ * @param debug to debug with parameter hints (`ctrl+p`, `ctrl+shift+space`)
8
+ * @example
9
+ * ```ts
10
+ * // see in `tst` folder
11
+ * ```
12
+ */
13
+ function check(debug) {
14
+ if (debug !== undefined) {
15
+ // eslint-disable-next-line no-console
16
+ console.log(debug);
17
+ }
18
+ return 1;
19
+ }
20
+ /**
21
+ * Validates a batch of [[check]]
22
+ * @param _checks a batch of [[check]]
23
+ * @example
24
+ * ```ts
25
+ * // see in `tst` folder
26
+ * ```
27
+ */
28
+ function checks(_checks) { }
29
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":";;AA8BA,sBASC;AAUD,wBAA8C;AA3B9C;;;;;;;GAOG;AACH,SAAgB,KAAK,CACnB,KAAY;IAEZ,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IAED,OAAO,CAA0C,CAAC;AACpD,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,MAAM,CAAC,OAAY,IAAU,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentica/core",
3
- "version": "0.24.0",
3
+ "version": "0.26.0",
4
4
  "description": "Agentic AI Library specialized in LLM Function Calling",
5
5
  "author": "Wrtn Technologies",
6
6
  "license": "MIT",
@@ -36,14 +36,13 @@
36
36
  "access": "public"
37
37
  },
38
38
  "peerDependencies": {
39
- "@modelcontextprotocol/sdk": "^1.9.0",
40
- "@samchon/openapi": "^4.2.0",
39
+ "@samchon/openapi": "^4.3.0",
41
40
  "openai": "^4.80.0",
42
- "typia": "^9.0.1"
41
+ "typia": "^9.3.0"
43
42
  },
44
43
  "dependencies": {
45
- "@samchon/openapi": "^4.2.0",
46
- "typia": "^9.0.1",
44
+ "@samchon/openapi": "^4.3.0",
45
+ "typia": "^9.3.0",
47
46
  "uuid": "^11.0.4"
48
47
  },
49
48
  "devDependencies": {
@@ -51,9 +50,10 @@
51
50
  "@nestia/e2e": "^6.0.1",
52
51
  "@rollup/plugin-terser": "^0.4.4",
53
52
  "@rollup/plugin-typescript": "^12.1.2",
54
- "@ryoppippi/unplugin-typia": "^2.2.1",
53
+ "@ryoppippi/unplugin-typia": "^2.6.2",
55
54
  "@types/node": "^22.13.4",
56
55
  "@types/uuid": "^10.0.0",
56
+ "@wrtnlabs/calculator-mcp": "^0.2.1",
57
57
  "openai": "^4.80.0",
58
58
  "rimraf": "^6.0.1",
59
59
  "rollup": "^4.34.8",
package/src/Agentica.ts CHANGED
@@ -6,8 +6,9 @@ import type { AgenticaOperationCollection } from "./context/AgenticaOperationCol
6
6
  import type { AgenticaOperationSelection } from "./context/AgenticaOperationSelection";
7
7
  import type { AgenticaEvent } from "./events/AgenticaEvent";
8
8
  import type { AgenticaRequestEvent } from "./events/AgenticaRequestEvent";
9
+ import type { AgenticaUserMessageContent } from "./histories";
9
10
  import type { AgenticaHistory } from "./histories/AgenticaHistory";
10
- import type { AgenticaUserInputHistory } from "./histories/AgenticaUserInputHistory";
11
+ import type { AgenticaUserMessageHistory } from "./histories/AgenticaUserMessageHistory";
11
12
  import type { IAgenticaConfig } from "./structures/IAgenticaConfig";
12
13
  import type { IAgenticaController } from "./structures/IAgenticaController";
13
14
  import type { IAgenticaProps } from "./structures/IAgenticaProps";
@@ -16,10 +17,10 @@ import type { IAgenticaVendor } from "./structures/IAgenticaVendor";
16
17
  import { AgenticaTokenUsage } from "./context/AgenticaTokenUsage";
17
18
  import { AgenticaOperationComposer } from "./context/internal/AgenticaOperationComposer";
18
19
  import { AgenticaTokenUsageAggregator } from "./context/internal/AgenticaTokenUsageAggregator";
19
- import { createUserInputHistory } from "./factory";
20
- import { createInitializeEvent, createRequestEvent, createUserInputEvent } from "./factory/events";
20
+ import { createUserMessageHistory } from "./factory";
21
+ import { createInitializeEvent, createRequestEvent, createUserMessageEvent } from "./factory/events";
21
22
  import { execute } from "./orchestrate/execute";
22
- import { AgenticaHistoryTransformer } from "./transformers/AgenticaHistoryTransformer";
23
+ import { transformHistory } from "./transformers/transformHistory";
23
24
  import { __map_take } from "./utils/__map_take";
24
25
  import { ChatGptCompletionMessageUtil } from "./utils/ChatGptCompletionMessageUtil";
25
26
  import { streamDefaultReaderToAsyncGenerator, StreamUtil } from "./utils/StreamUtil";
@@ -86,7 +87,7 @@ export class Agentica<Model extends ILlmSchema.Model> {
86
87
  this.stack_ = [];
87
88
  this.listeners_ = new Map();
88
89
  this.histories_ = (props.histories ?? []).map(input =>
89
- AgenticaHistoryTransformer.transform({
90
+ transformHistory({
90
91
  operations: this.operations_.group,
91
92
  history: input,
92
93
  }),
@@ -130,12 +131,12 @@ export class Agentica<Model extends ILlmSchema.Model> {
130
131
  * @returns List of newly created chat prompts
131
132
  */
132
133
  public async conversate(
133
- content: string | AgenticaUserInputHistory.Contents | Array<AgenticaUserInputHistory.Contents>,
134
+ content: string | AgenticaUserMessageContent | Array<AgenticaUserMessageContent>,
134
135
  options: {
135
136
  abortSignal?: AbortSignal;
136
137
  } = {},
137
138
  ): Promise<AgenticaHistory<Model>[]> {
138
- const prompt: AgenticaUserInputHistory = createUserInputHistory({
139
+ const prompt: AgenticaUserMessageHistory = createUserMessageHistory({
139
140
  contents: Array.isArray(content)
140
141
  ? content
141
142
  : typeof content === "string"
@@ -147,7 +148,7 @@ export class Agentica<Model extends ILlmSchema.Model> {
147
148
  });
148
149
 
149
150
  this.dispatch(
150
- createUserInputEvent({
151
+ createUserMessageEvent({
151
152
  contents: prompt.contents,
152
153
  }),
153
154
  ).catch(() => {});
@@ -226,7 +227,7 @@ export class Agentica<Model extends ILlmSchema.Model> {
226
227
  * @internal
227
228
  */
228
229
  public getContext(props: {
229
- prompt: AgenticaUserInputHistory;
230
+ prompt: AgenticaUserMessageHistory;
230
231
  usage: AgenticaTokenUsage;
231
232
  abortSignal?: AbortSignal;
232
233
  }): AgenticaContext<Model> {
@@ -5,8 +5,9 @@ import type { AgenticaOperationCollection } from "./context/AgenticaOperationCol
5
5
  import type { MicroAgenticaContext } from "./context/MicroAgenticaContext";
6
6
  import type { AgenticaRequestEvent } from "./events/AgenticaRequestEvent";
7
7
  import type { MicroAgenticaEvent } from "./events/MicroAgenticaEvent";
8
+ import type { AgenticaUserMessageContent } from "./histories";
8
9
  import type { AgenticaExecuteHistory } from "./histories/AgenticaExecuteHistory";
9
- import type { AgenticaUserInputHistory } from "./histories/AgenticaUserInputHistory";
10
+ import type { AgenticaUserMessageHistory } from "./histories/AgenticaUserMessageHistory";
10
11
  import type { MicroAgenticaHistory } from "./histories/MicroAgenticaHistory";
11
12
  import type { IAgenticaController } from "./structures/IAgenticaController";
12
13
  import type { IAgenticaVendor } from "./structures/IAgenticaVendor";
@@ -16,10 +17,10 @@ import type { IMicroAgenticaProps } from "./structures/IMicroAgenticaProps";
16
17
  import { AgenticaTokenUsage } from "./context/AgenticaTokenUsage";
17
18
  import { AgenticaOperationComposer } from "./context/internal/AgenticaOperationComposer";
18
19
  import { AgenticaTokenUsageAggregator } from "./context/internal/AgenticaTokenUsageAggregator";
19
- import { createUserInputHistory } from "./factory";
20
- import { createRequestEvent, createUserInputEvent } from "./factory/events";
20
+ import { createUserMessageHistory } from "./factory";
21
+ import { createRequestEvent, createUserMessageEvent } from "./factory/events";
21
22
  import { call, describe } from "./orchestrate";
22
- import { AgenticaHistoryTransformer } from "./transformers/AgenticaHistoryTransformer";
23
+ import { transformHistory } from "./transformers/transformHistory";
23
24
  import { __map_take } from "./utils/__map_take";
24
25
  import { ChatGptCompletionMessageUtil } from "./utils/ChatGptCompletionMessageUtil";
25
26
  import { streamDefaultReaderToAsyncGenerator, StreamUtil } from "./utils/StreamUtil";
@@ -74,7 +75,7 @@ export class MicroAgentica<Model extends ILlmSchema.Model> {
74
75
  config: props.config,
75
76
  });
76
77
  this.histories_ = (props.histories ?? []).map(input =>
77
- AgenticaHistoryTransformer.transform({
78
+ transformHistory({
78
79
  operations: this.operations_.group,
79
80
  history: input,
80
81
  }),
@@ -108,8 +109,10 @@ export class MicroAgentica<Model extends ILlmSchema.Model> {
108
109
  * @param content The content to talk
109
110
  * @returns List of newly created histories
110
111
  */
111
- public async conversate(content: string | AgenticaUserInputHistory.Contents | Array<AgenticaUserInputHistory.Contents>): Promise<MicroAgenticaHistory<Model>[]> {
112
- const talk = createUserInputHistory({
112
+ public async conversate(
113
+ content: string | AgenticaUserMessageContent | Array<AgenticaUserMessageContent>,
114
+ ): Promise<MicroAgenticaHistory<Model>[]> {
115
+ const talk = createUserMessageHistory({
113
116
  contents: Array.isArray(content)
114
117
  ? content
115
118
  : typeof content === "string"
@@ -120,7 +123,7 @@ export class MicroAgentica<Model extends ILlmSchema.Model> {
120
123
  : [content],
121
124
  });
122
125
  this.dispatch(
123
- createUserInputEvent({
126
+ createUserMessageEvent({
124
127
  contents: talk.contents,
125
128
  }),
126
129
  ).catch(() => {});
@@ -207,7 +210,7 @@ export class MicroAgentica<Model extends ILlmSchema.Model> {
207
210
  * @internal
208
211
  */
209
212
  public getContext(props: {
210
- prompt: AgenticaUserInputHistory;
213
+ prompt: AgenticaUserMessageHistory;
211
214
  usage: AgenticaTokenUsage;
212
215
  }): MicroAgenticaContext<Model> {
213
216
  const dispatch = this.dispatch.bind(this);
@@ -4,7 +4,7 @@ import type OpenAI from "openai";
4
4
  import type { AgenticaEvent } from "../events/AgenticaEvent";
5
5
  import type { AgenticaEventSource } from "../events/AgenticaEventSource";
6
6
  import type { AgenticaHistory } from "../histories/AgenticaHistory";
7
- import type { AgenticaUserInputHistory } from "../histories/AgenticaUserInputHistory";
7
+ import type { AgenticaUserMessageHistory } from "../histories/AgenticaUserMessageHistory";
8
8
  import type { IAgenticaConfig } from "../structures/IAgenticaConfig";
9
9
 
10
10
  import type { AgenticaOperationCollection } from "./AgenticaOperationCollection";
@@ -85,7 +85,7 @@ export interface AgenticaContext<Model extends ILlmSchema.Model> {
85
85
  * The user input history written by the user through the
86
86
  * {@link Agentica.conversate} function.
87
87
  */
88
- prompt: AgenticaUserInputHistory;
88
+ prompt: AgenticaUserMessageHistory;
89
89
 
90
90
  /**
91
91
  * Abort signal.
@@ -2,7 +2,7 @@ import type { ILlmSchema } from "@samchon/openapi";
2
2
  import type OpenAI from "openai";
3
3
 
4
4
  import type { MicroAgenticaEvent } from "../events/MicroAgenticaEvent";
5
- import type { AgenticaUserInputHistory } from "../histories/AgenticaUserInputHistory";
5
+ import type { AgenticaUserMessageHistory } from "../histories/AgenticaUserMessageHistory";
6
6
  import type { MicroAgenticaHistory } from "../histories/MicroAgenticaHistory";
7
7
  import type { IMicroAgenticaConfig } from "../structures/IMicroAgenticaConfig";
8
8
 
@@ -66,7 +66,7 @@ export interface MicroAgenticaContext<Model extends ILlmSchema.Model> {
66
66
  * Text conversation written the by user through the
67
67
  * {@link Agentica.conversate} function.
68
68
  */
69
- prompt: AgenticaUserInputHistory;
69
+ prompt: AgenticaUserMessageHistory;
70
70
 
71
71
  // ----
72
72
  // HANDLERS
@@ -0,0 +1,5 @@
1
+ export * from "./AgenticaContext";
2
+ export * from "./AgenticaOperation";
3
+ export * from "./AgenticaOperationCollection";
4
+ export * from "./AgenticaOperationSelection";
5
+ export * from "./AgenticaTokenUsage";
@@ -1,7 +1,8 @@
1
1
  import type { IChatGptSchema, IHttpLlmFunction, ILlmFunction, IMcpLlmFunction, IValidation } from "@samchon/openapi";
2
2
 
3
3
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
4
- import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
4
+ import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory";
5
+ import { createServer } from "@wrtnlabs/calculator-mcp";
5
6
 
6
7
  import type { IAgenticaConfig } from "../../structures/IAgenticaConfig";
7
8
  import type { IAgenticaController } from "../../structures/IAgenticaController";
@@ -86,10 +87,19 @@ async function createMockMcpController(name: string, functions: IMcpLlmFunction<
86
87
 
87
88
  describe("a AgenticaOperationComposer", () => {
88
89
  beforeAll(async () => {
89
- await client.connect(new StdioClientTransport({
90
- command: "npx",
91
- args: ["-y", "@wrtnlabs/calculator-mcp"],
92
- }));
90
+ // eslint-disable-next-line ts/no-unsafe-call
91
+ const server = await createServer({
92
+ name: "calculator",
93
+ version: "1.0.0",
94
+ });
95
+
96
+ const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
97
+
98
+ await Promise.all([
99
+ client.connect(clientTransport),
100
+ // eslint-disable-next-line ts/no-unsafe-call
101
+ server.connect(serverTransport),
102
+ ]);
93
103
  });
94
104
  describe("compose", () => {
95
105
  it("should compose operations from controllers", async () => {
@@ -0,0 +1,12 @@
1
+ import type { AgenticaAssistantMessageHistory } from "../histories/AgenticaAssistantMessageHistory";
2
+ import type { IAgenticaEventJson } from "../json/IAgenticaEventJson";
3
+
4
+ import type { AgenticaEventBase } from "./AgenticaEventBase";
5
+
6
+ export interface AgenticaAssistantMessageEvent
7
+ extends AgenticaEventBase<"assistantMessage"> {
8
+ stream: AsyncGenerator<string, undefined, undefined>;
9
+ join: () => Promise<string>;
10
+ toJSON: () => IAgenticaEventJson.IAssistantMessage;
11
+ toHistory: () => AgenticaAssistantMessageHistory;
12
+ }
@@ -1,5 +1,6 @@
1
1
  import type { ILlmSchema } from "@samchon/openapi";
2
2
 
3
+ import type { AgenticaAssistantMessageEvent } from "./AgenticaAssistantMessageEvent";
3
4
  import type { AgenticaCallEvent } from "./AgenticaCallEvent";
4
5
  import type { AgenticaCancelEvent } from "./AgenticaCancelEvent";
5
6
  import type { AgenticaDescribeEvent } from "./AgenticaDescribeEvent";
@@ -8,8 +9,7 @@ import type { AgenticaInitializeEvent } from "./AgenticaInitializeEvent";
8
9
  import type { AgenticaRequestEvent } from "./AgenticaRequestEvent";
9
10
  import type { AgenticaResponseEvent } from "./AgenticaResponseEvent";
10
11
  import type { AgenticaSelectEvent } from "./AgenticaSelectEvent";
11
- import type { AgenticaTextEvent } from "./AgenticaTextEvent";
12
- import type { AgenticaUserInputEvent } from "./AgenticaUserInputEvent";
12
+ import type { AgenticaUserMessageEvent } from "./AgenticaUserMessageEvent";
13
13
  import type { AgenticaValidateEvent } from "./AgenticaValidateEvent";
14
14
 
15
15
  /**
@@ -23,31 +23,31 @@ import type { AgenticaValidateEvent } from "./AgenticaValidateEvent";
23
23
  * @author Samchon
24
24
  */
25
25
  export type AgenticaEvent<Model extends ILlmSchema.Model> =
26
+ | AgenticaUserMessageEvent
27
+ | AgenticaAssistantMessageEvent
28
+ | AgenticaInitializeEvent
29
+ | AgenticaSelectEvent<Model>
26
30
  | AgenticaCallEvent<Model>
27
31
  | AgenticaCancelEvent<Model>
28
- | AgenticaDescribeEvent<Model>
29
32
  | AgenticaExecuteEvent<Model>
30
- | AgenticaInitializeEvent
31
- | AgenticaRequestEvent
32
- | AgenticaResponseEvent
33
- | AgenticaSelectEvent<Model>
34
- | AgenticaTextEvent
33
+ | AgenticaDescribeEvent<Model>
35
34
  | AgenticaValidateEvent<Model>
36
- | AgenticaUserInputEvent;
35
+ | AgenticaRequestEvent
36
+ | AgenticaResponseEvent;
37
37
  export namespace AgenticaEvent {
38
38
  export type Type = AgenticaEvent<any>["type"];
39
39
  export interface Mapper<Model extends ILlmSchema.Model> {
40
+ userMessage: AgenticaUserMessageEvent;
41
+ assistantMessage: AgenticaAssistantMessageEvent;
42
+ select: AgenticaSelectEvent<Model>;
43
+ initialize: AgenticaInitializeEvent;
40
44
  call: AgenticaCallEvent<Model>;
41
45
  cancel: AgenticaCancelEvent<Model>;
42
- describe: AgenticaDescribeEvent<Model>;
43
46
  execute: AgenticaExecuteEvent<Model>;
44
- initialize: AgenticaInitializeEvent;
47
+ describe: AgenticaDescribeEvent<Model>;
48
+ validate: AgenticaValidateEvent<Model>;
45
49
  request: AgenticaRequestEvent;
46
50
  response: AgenticaResponseEvent;
47
- select: AgenticaSelectEvent<Model>;
48
- text: AgenticaTextEvent;
49
- validate: AgenticaValidateEvent<Model>;
50
- user_input: AgenticaUserInputEvent;
51
51
  }
52
52
  export type Source =
53
53
  | "initialize"
@@ -0,0 +1,19 @@
1
+ import type { AgenticaHistory } from "../histories";
2
+ import type { Pass } from "../utils/types";
3
+
4
+ import { check, checks } from "../utils/types";
5
+
6
+ import type { AgenticaEvent } from "./AgenticaEvent";
7
+
8
+ checks([
9
+ check<
10
+ Exclude<AgenticaHistory.Type, "systemMessage"> extends AgenticaEvent.Type ? true : false,
11
+ true,
12
+ Pass
13
+ >(),
14
+ check<
15
+ Exclude<AgenticaHistory.Type, "systemMessage"> extends keyof AgenticaEvent.Mapper<any> ? true : false,
16
+ true,
17
+ Pass
18
+ >(),
19
+ ]);
@@ -0,0 +1,12 @@
1
+ import type { AgenticaUserMessageContent } from "../histories";
2
+ import type { AgenticaUserMessageHistory } from "../histories/AgenticaUserMessageHistory";
3
+ import type { IAgenticaEventJson } from "../json/IAgenticaEventJson";
4
+
5
+ import type { AgenticaEventBase } from "./AgenticaEventBase";
6
+
7
+ export interface AgenticaUserMessageEvent
8
+ extends AgenticaEventBase<"userMessage"> {
9
+ contents: Array<AgenticaUserMessageContent>;
10
+ toJSON: () => IAgenticaEventJson.IUserMessage;
11
+ toHistory: () => AgenticaUserMessageHistory;
12
+ }
@@ -1,12 +1,12 @@
1
1
  import type { ILlmSchema } from "@samchon/openapi";
2
2
 
3
+ import type { AgenticaAssistantMessageEvent } from "./AgenticaAssistantMessageEvent";
3
4
  import type { AgenticaCallEvent } from "./AgenticaCallEvent";
4
5
  import type { AgenticaDescribeEvent } from "./AgenticaDescribeEvent";
5
6
  import type { AgenticaExecuteEvent } from "./AgenticaExecuteEvent";
6
7
  import type { AgenticaRequestEvent } from "./AgenticaRequestEvent";
7
8
  import type { AgenticaResponseEvent } from "./AgenticaResponseEvent";
8
- import type { AgenticaTextEvent } from "./AgenticaTextEvent";
9
- import type { AgenticaUserInputEvent } from "./AgenticaUserInputEvent";
9
+ import type { AgenticaUserMessageEvent } from "./AgenticaUserMessageEvent";
10
10
  import type { AgenticaValidateEvent } from "./AgenticaValidateEvent";
11
11
 
12
12
  /**
@@ -20,25 +20,25 @@ import type { AgenticaValidateEvent } from "./AgenticaValidateEvent";
20
20
  * @author Samchon
21
21
  */
22
22
  export type MicroAgenticaEvent<Model extends ILlmSchema.Model> =
23
+ | AgenticaUserMessageEvent
24
+ | AgenticaAssistantMessageEvent
23
25
  | AgenticaCallEvent<Model>
24
- | AgenticaDescribeEvent<Model>
25
26
  | AgenticaExecuteEvent<Model>
27
+ | AgenticaDescribeEvent<Model>
26
28
  | AgenticaRequestEvent
27
29
  | AgenticaResponseEvent
28
- | AgenticaTextEvent
29
- | AgenticaValidateEvent<Model>
30
- | AgenticaUserInputEvent;
30
+ | AgenticaValidateEvent<Model>;
31
31
  export namespace MicroAgenticaEvent {
32
32
  export type Type = MicroAgenticaEvent<any>["type"];
33
33
  export interface Mapper<Model extends ILlmSchema.Model> {
34
+ userMessage: AgenticaUserMessageEvent;
35
+ assistantMessage: AgenticaAssistantMessageEvent;
34
36
  call: AgenticaCallEvent<Model>;
35
- describe: AgenticaDescribeEvent<Model>;
36
37
  execute: AgenticaExecuteEvent<Model>;
38
+ describe: AgenticaDescribeEvent<Model>;
37
39
  request: AgenticaRequestEvent;
38
40
  response: AgenticaResponseEvent;
39
- text: AgenticaTextEvent;
40
41
  validate: AgenticaValidateEvent<Model>;
41
- user_input: AgenticaUserInputEvent;
42
42
  }
43
43
  export type Source = "call" | "describe";
44
44
  }
@@ -0,0 +1,14 @@
1
+ export * from "./AgenticaAssistantMessageEvent";
2
+ export * from "./AgenticaCallEvent";
3
+ export * from "./AgenticaCancelEvent";
4
+ export * from "./AgenticaDescribeEvent";
5
+ export * from "./AgenticaEvent";
6
+ export * from "./AgenticaEventSource";
7
+ export * from "./AgenticaExecuteEvent";
8
+ export * from "./AgenticaInitializeEvent";
9
+ export * from "./AgenticaRequestEvent";
10
+ export * from "./AgenticaResponseEvent";
11
+ export * from "./AgenticaSelectEvent";
12
+ export * from "./AgenticaUserMessageEvent";
13
+ export * from "./AgenticaValidateEvent";
14
+ export * from "./MicroAgenticaEvent";