@agentica/core 0.10.4 → 0.11.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 (263) hide show
  1. package/lib/Agentica.d.ts +14 -14
  2. package/lib/Agentica.js +54 -31
  3. package/lib/Agentica.js.map +1 -1
  4. package/lib/chatgpt/ChatGptAgent.d.ts +3 -3
  5. package/lib/chatgpt/ChatGptAgent.js +1 -1
  6. package/lib/chatgpt/ChatGptAgent.js.map +1 -1
  7. package/lib/chatgpt/ChatGptCallFunctionAgent.d.ts +3 -3
  8. package/lib/chatgpt/ChatGptCallFunctionAgent.js +61 -63
  9. package/lib/chatgpt/ChatGptCallFunctionAgent.js.map +1 -1
  10. package/lib/chatgpt/ChatGptCancelFunctionAgent.d.ts +6 -6
  11. package/lib/chatgpt/ChatGptCancelFunctionAgent.js +28 -30
  12. package/lib/chatgpt/ChatGptCancelFunctionAgent.js.map +1 -1
  13. package/lib/chatgpt/ChatGptCompletionMessageUtil.d.ts +8 -0
  14. package/lib/chatgpt/ChatGptCompletionMessageUtil.js +536 -0
  15. package/lib/chatgpt/ChatGptCompletionMessageUtil.js.map +1 -0
  16. package/lib/chatgpt/ChatGptDescribeFunctionAgent.d.ts +4 -3
  17. package/lib/chatgpt/ChatGptDescribeFunctionAgent.js +56 -6
  18. package/lib/chatgpt/ChatGptDescribeFunctionAgent.js.map +1 -1
  19. package/lib/chatgpt/ChatGptHistoryDecoder.d.ts +2 -2
  20. package/lib/chatgpt/ChatGptHistoryDecoder.js +8 -8
  21. package/lib/chatgpt/ChatGptHistoryDecoder.js.map +1 -1
  22. package/lib/chatgpt/ChatGptInitializeFunctionAgent.d.ts +3 -3
  23. package/lib/chatgpt/ChatGptInitializeFunctionAgent.js +11 -5
  24. package/lib/chatgpt/ChatGptInitializeFunctionAgent.js.map +1 -1
  25. package/lib/chatgpt/ChatGptSelectFunctionAgent.d.ts +3 -3
  26. package/lib/chatgpt/ChatGptSelectFunctionAgent.js +39 -42
  27. package/lib/chatgpt/ChatGptSelectFunctionAgent.js.map +1 -1
  28. package/lib/chatgpt/ChatGptUsageAggregator.d.ts +6 -0
  29. package/lib/chatgpt/ChatGptUsageAggregator.js +48 -0
  30. package/lib/chatgpt/ChatGptUsageAggregator.js.map +1 -0
  31. package/lib/context/AgenticaCancelPrompt.d.ts +16 -0
  32. package/lib/context/AgenticaCancelPrompt.js +20 -0
  33. package/lib/context/AgenticaCancelPrompt.js.map +1 -0
  34. package/lib/context/AgenticaClassOperation.d.ts +8 -0
  35. package/lib/context/AgenticaClassOperation.js +11 -0
  36. package/lib/context/AgenticaClassOperation.js.map +1 -0
  37. package/lib/{structures/IAgenticaContext.d.ts → context/AgenticaContext.d.ts} +15 -14
  38. package/lib/{structures/IAgenticaPrompt.js → context/AgenticaContext.js} +1 -1
  39. package/lib/context/AgenticaContext.js.map +1 -0
  40. package/lib/context/AgenticaHttpOperation.d.ts +8 -0
  41. package/lib/context/AgenticaHttpOperation.js +11 -0
  42. package/lib/context/AgenticaHttpOperation.js.map +1 -0
  43. package/lib/context/AgenticaOperation.d.ts +46 -0
  44. package/lib/{structures/IAgenticaContext.js → context/AgenticaOperation.js} +1 -1
  45. package/lib/context/AgenticaOperation.js.map +1 -0
  46. package/lib/context/AgenticaOperationBase.d.ts +29 -0
  47. package/lib/context/AgenticaOperationBase.js +21 -0
  48. package/lib/context/AgenticaOperationBase.js.map +1 -0
  49. package/lib/{structures/IAgenticaOperationCollection.d.ts → context/AgenticaOperationCollection.d.ts} +6 -6
  50. package/lib/{structures/IAgenticaOperationSelection.js → context/AgenticaOperationCollection.js} +1 -1
  51. package/lib/context/AgenticaOperationCollection.js.map +1 -0
  52. package/lib/context/AgenticaOperationSelection.d.ts +15 -0
  53. package/lib/context/AgenticaOperationSelection.js +17 -0
  54. package/lib/context/AgenticaOperationSelection.js.map +1 -0
  55. package/lib/context/AgenticaTokenUsage.d.ts +82 -0
  56. package/lib/context/AgenticaTokenUsage.js +97 -0
  57. package/lib/context/AgenticaTokenUsage.js.map +1 -0
  58. package/lib/context/internal/AgenticaTokenUsageAggregator.d.ts +10 -0
  59. package/lib/{internal → context/internal}/AgenticaTokenUsageAggregator.js +0 -46
  60. package/lib/context/internal/AgenticaTokenUsageAggregator.js.map +1 -0
  61. package/lib/context/internal/__IChatCancelFunctionsApplication.js.map +1 -0
  62. package/lib/context/internal/__IChatFunctionReference.js.map +1 -0
  63. package/lib/context/internal/__IChatInitialApplication.js.map +1 -0
  64. package/lib/context/internal/__IChatSelectFunctionsApplication.js.map +1 -0
  65. package/lib/events/AgenticaCallEvent.d.ts +18 -0
  66. package/lib/events/AgenticaCallEvent.js +22 -0
  67. package/lib/events/AgenticaCallEvent.js.map +1 -0
  68. package/lib/events/AgenticaCancelEvent.d.ts +14 -0
  69. package/lib/events/AgenticaCancelEvent.js +18 -0
  70. package/lib/events/AgenticaCancelEvent.js.map +1 -0
  71. package/lib/events/AgenticaDescribeEvent.d.ts +27 -0
  72. package/lib/events/AgenticaDescribeEvent.js +40 -0
  73. package/lib/events/AgenticaDescribeEvent.js.map +1 -0
  74. package/lib/events/AgenticaEvent.d.ts +25 -0
  75. package/lib/{structures/IAgenticaEvent.js → events/AgenticaEvent.js} +1 -1
  76. package/lib/events/AgenticaEvent.js.map +1 -0
  77. package/lib/events/AgenticaEventBase.d.ts +4 -0
  78. package/lib/events/AgenticaEventBase.js +10 -0
  79. package/lib/events/AgenticaEventBase.js.map +1 -0
  80. package/lib/events/AgenticaEventSource.d.ts +1 -0
  81. package/lib/events/AgenticaEventSource.js +3 -0
  82. package/lib/events/AgenticaEventSource.js.map +1 -0
  83. package/lib/events/AgenticaExecuteEvent.d.ts +22 -0
  84. package/lib/events/AgenticaExecuteEvent.js +33 -0
  85. package/lib/events/AgenticaExecuteEvent.js.map +1 -0
  86. package/lib/events/AgenticaInitializeEvent.d.ts +6 -0
  87. package/lib/events/AgenticaInitializeEvent.js +16 -0
  88. package/lib/events/AgenticaInitializeEvent.js.map +1 -0
  89. package/lib/events/AgenticaRequestEvent.d.ts +27 -0
  90. package/lib/events/AgenticaRequestEvent.js +22 -0
  91. package/lib/events/AgenticaRequestEvent.js.map +1 -0
  92. package/lib/events/AgenticaResponseEvent.d.ts +35 -0
  93. package/lib/events/AgenticaResponseEvent.js +16 -0
  94. package/lib/events/AgenticaResponseEvent.js.map +1 -0
  95. package/lib/events/AgenticaSelectEvent.d.ts +16 -0
  96. package/lib/events/AgenticaSelectEvent.js +26 -0
  97. package/lib/events/AgenticaSelectEvent.js.map +1 -0
  98. package/lib/events/AgenticaTextEvent.d.ts +25 -0
  99. package/lib/events/AgenticaTextEvent.js +40 -0
  100. package/lib/events/AgenticaTextEvent.js.map +1 -0
  101. package/lib/index.d.ts +26 -8
  102. package/lib/index.js +29 -9
  103. package/lib/index.js.map +1 -1
  104. package/lib/index.mjs +1391 -306
  105. package/lib/index.mjs.map +1 -1
  106. package/lib/internal/AgenticaOperationComposer.d.ts +2 -2
  107. package/lib/internal/AgenticaOperationComposer.js +12 -0
  108. package/lib/internal/AgenticaOperationComposer.js.map +1 -1
  109. package/lib/internal/ByteArrayUtil.d.ts +3 -0
  110. package/lib/internal/ByteArrayUtil.js +10 -0
  111. package/lib/internal/ByteArrayUtil.js.map +1 -0
  112. package/lib/internal/MPSCUtil.d.ts +21 -0
  113. package/lib/internal/MPSCUtil.js +84 -0
  114. package/lib/internal/MPSCUtil.js.map +1 -0
  115. package/lib/internal/StreamUtil.d.ts +6 -0
  116. package/lib/internal/StreamUtil.js +65 -0
  117. package/lib/internal/StreamUtil.js.map +1 -0
  118. package/lib/json/IAgenticaEventJson.d.ts +149 -0
  119. package/lib/{structures/IAgenticaOperation.js → json/IAgenticaEventJson.js} +1 -1
  120. package/lib/json/IAgenticaEventJson.js.map +1 -0
  121. package/lib/json/IAgenticaOperationJson.d.ts +33 -0
  122. package/lib/json/IAgenticaOperationJson.js +3 -0
  123. package/lib/json/IAgenticaOperationJson.js.map +1 -0
  124. package/lib/json/IAgenticaOperationSelectionJson.d.ts +18 -0
  125. package/lib/{structures/IAgenticaOperationCollection.js → json/IAgenticaOperationSelectionJson.js} +1 -1
  126. package/lib/json/IAgenticaOperationSelectionJson.js.map +1 -0
  127. package/lib/json/IAgenticaPromptJson.d.ts +111 -0
  128. package/lib/json/IAgenticaPromptJson.js +3 -0
  129. package/lib/json/IAgenticaPromptJson.js.map +1 -0
  130. package/lib/{structures/IAgenticaTokenUsage.d.ts → json/IAgenticaTokenUsageJson.d.ts} +10 -10
  131. package/lib/json/IAgenticaTokenUsageJson.js +3 -0
  132. package/lib/json/IAgenticaTokenUsageJson.js.map +1 -0
  133. package/lib/prompts/AgenticaCancelPrompt.d.ts +16 -0
  134. package/lib/prompts/AgenticaCancelPrompt.js +20 -0
  135. package/lib/prompts/AgenticaCancelPrompt.js.map +1 -0
  136. package/lib/prompts/AgenticaDescribePrompt.d.ts +24 -0
  137. package/lib/prompts/AgenticaDescribePrompt.js +20 -0
  138. package/lib/prompts/AgenticaDescribePrompt.js.map +1 -0
  139. package/lib/prompts/AgenticaExecutePrompt.d.ts +20 -0
  140. package/lib/prompts/AgenticaExecutePrompt.js +24 -0
  141. package/lib/prompts/AgenticaExecutePrompt.js.map +1 -0
  142. package/lib/prompts/AgenticaPrompt.d.ts +7 -0
  143. package/lib/{typings/AgenticaSource.js → prompts/AgenticaPrompt.js} +1 -1
  144. package/lib/prompts/AgenticaPrompt.js.map +1 -0
  145. package/lib/prompts/AgenticaPromptBase.d.ts +22 -0
  146. package/lib/prompts/AgenticaPromptBase.js +22 -0
  147. package/lib/prompts/AgenticaPromptBase.js.map +1 -0
  148. package/lib/prompts/AgenticaSelectPrompt.d.ts +16 -0
  149. package/lib/prompts/AgenticaSelectPrompt.js +20 -0
  150. package/lib/prompts/AgenticaSelectPrompt.js.map +1 -0
  151. package/lib/prompts/AgenticaTextPrompt.d.ts +14 -0
  152. package/lib/prompts/AgenticaTextPrompt.js +20 -0
  153. package/lib/prompts/AgenticaTextPrompt.js.map +1 -0
  154. package/lib/structures/IAgenticaConfig.d.ts +3 -3
  155. package/lib/structures/IAgenticaExecutor.d.ts +12 -11
  156. package/lib/structures/IAgenticaProps.d.ts +2 -3
  157. package/lib/structures/IAgenticaSystemPrompt.d.ts +12 -11
  158. package/lib/transformers/AgenticaEventTransformer.d.ts +45 -0
  159. package/lib/transformers/AgenticaEventTransformer.js +127 -0
  160. package/lib/transformers/AgenticaEventTransformer.js.map +1 -0
  161. package/lib/transformers/AgenticaPromptTransformer.d.ts +34 -0
  162. package/lib/transformers/AgenticaPromptTransformer.js +90 -0
  163. package/lib/transformers/AgenticaPromptTransformer.js.map +1 -0
  164. package/package.json +1 -1
  165. package/src/Agentica.ts +93 -63
  166. package/src/chatgpt/ChatGptAgent.ts +8 -7
  167. package/src/chatgpt/ChatGptCallFunctionAgent.ts +90 -88
  168. package/src/chatgpt/ChatGptCancelFunctionAgent.ts +51 -58
  169. package/src/chatgpt/ChatGptCompletionMessageUtil.ts +166 -0
  170. package/src/chatgpt/ChatGptDescribeFunctionAgent.ts +81 -12
  171. package/src/chatgpt/ChatGptHistoryDecoder.ts +14 -14
  172. package/src/chatgpt/ChatGptInitializeFunctionAgent.ts +21 -13
  173. package/src/chatgpt/ChatGptSelectFunctionAgent.ts +66 -74
  174. package/src/chatgpt/ChatGptUsageAggregator.ts +62 -0
  175. package/src/context/AgenticaCancelPrompt.ts +32 -0
  176. package/src/context/AgenticaClassOperation.ts +23 -0
  177. package/src/{structures/IAgenticaContext.ts → context/AgenticaContext.ts} +17 -16
  178. package/src/context/AgenticaHttpOperation.ts +27 -0
  179. package/src/{structures/IAgenticaOperation.ts → context/AgenticaOperation.ts} +25 -22
  180. package/src/context/AgenticaOperationBase.ts +57 -0
  181. package/src/{structures/IAgenticaOperationCollection.ts → context/AgenticaOperationCollection.ts} +6 -6
  182. package/src/context/AgenticaOperationSelection.ts +27 -0
  183. package/src/context/AgenticaTokenUsage.ts +170 -0
  184. package/src/context/internal/AgenticaTokenUsageAggregator.ts +66 -0
  185. package/src/events/AgenticaCallEvent.ts +36 -0
  186. package/src/events/AgenticaCancelEvent.ts +28 -0
  187. package/src/events/AgenticaDescribeEvent.ts +61 -0
  188. package/src/events/AgenticaEvent.ts +36 -0
  189. package/src/events/AgenticaEventBase.ts +7 -0
  190. package/src/{typings/AgenticaSource.ts → events/AgenticaEventSource.ts} +1 -1
  191. package/src/events/AgenticaExecuteEvent.ts +50 -0
  192. package/src/events/AgenticaInitializeEvent.ts +14 -0
  193. package/src/events/AgenticaRequestEvent.ts +45 -0
  194. package/src/events/AgenticaResponseEvent.ts +48 -0
  195. package/src/events/AgenticaSelectEvent.ts +37 -0
  196. package/src/events/AgenticaTextEvent.ts +57 -0
  197. package/src/index.ts +33 -9
  198. package/src/internal/AgenticaOperationComposer.ts +24 -15
  199. package/src/internal/ByteArrayUtil.ts +5 -0
  200. package/src/internal/MPSCUtil.ts +75 -0
  201. package/src/internal/StreamUtil.ts +64 -0
  202. package/src/json/IAgenticaEventJson.ts +178 -0
  203. package/src/json/IAgenticaOperationJson.ts +36 -0
  204. package/src/json/IAgenticaOperationSelectionJson.ts +19 -0
  205. package/src/json/IAgenticaPromptJson.ts +130 -0
  206. package/src/{structures/IAgenticaTokenUsage.ts → json/IAgenticaTokenUsageJson.ts} +10 -10
  207. package/src/prompts/AgenticaCancelPrompt.ts +32 -0
  208. package/src/prompts/AgenticaDescribePrompt.ts +41 -0
  209. package/src/prompts/AgenticaExecutePrompt.ts +52 -0
  210. package/src/prompts/AgenticaPrompt.ts +14 -0
  211. package/src/prompts/AgenticaPromptBase.ts +27 -0
  212. package/src/prompts/AgenticaSelectPrompt.ts +32 -0
  213. package/src/prompts/AgenticaTextPrompt.ts +31 -0
  214. package/src/structures/IAgenticaConfig.ts +3 -3
  215. package/src/structures/IAgenticaExecutor.ts +14 -13
  216. package/src/structures/IAgenticaProps.ts +2 -3
  217. package/src/structures/IAgenticaSystemPrompt.ts +12 -11
  218. package/src/transformers/AgenticaEventTransformer.ts +165 -0
  219. package/src/transformers/AgenticaPromptTransformer.ts +134 -0
  220. package/lib/internal/AgenticaPromptFactory.d.ts +0 -7
  221. package/lib/internal/AgenticaPromptFactory.js +0 -9
  222. package/lib/internal/AgenticaPromptFactory.js.map +0 -1
  223. package/lib/internal/AgenticaPromptTransformer.d.ts +0 -10
  224. package/lib/internal/AgenticaPromptTransformer.js +0 -58
  225. package/lib/internal/AgenticaPromptTransformer.js.map +0 -1
  226. package/lib/internal/AgenticaTokenUsageAggregator.d.ts +0 -11
  227. package/lib/internal/AgenticaTokenUsageAggregator.js.map +0 -1
  228. package/lib/structures/IAgenticaContext.js.map +0 -1
  229. package/lib/structures/IAgenticaEvent.d.ts +0 -192
  230. package/lib/structures/IAgenticaEvent.js.map +0 -1
  231. package/lib/structures/IAgenticaOperation.d.ts +0 -47
  232. package/lib/structures/IAgenticaOperation.js.map +0 -1
  233. package/lib/structures/IAgenticaOperationCollection.js.map +0 -1
  234. package/lib/structures/IAgenticaOperationSelection.d.ts +0 -50
  235. package/lib/structures/IAgenticaOperationSelection.js.map +0 -1
  236. package/lib/structures/IAgenticaPrompt.d.ts +0 -138
  237. package/lib/structures/IAgenticaPrompt.js.map +0 -1
  238. package/lib/structures/IAgenticaTokenUsage.js +0 -3
  239. package/lib/structures/IAgenticaTokenUsage.js.map +0 -1
  240. package/lib/structures/internal/__IChatCancelFunctionsApplication.js.map +0 -1
  241. package/lib/structures/internal/__IChatFunctionReference.js.map +0 -1
  242. package/lib/structures/internal/__IChatInitialApplication.js.map +0 -1
  243. package/lib/structures/internal/__IChatSelectFunctionsApplication.js.map +0 -1
  244. package/lib/typings/AgenticaSource.d.ts +0 -1
  245. package/lib/typings/AgenticaSource.js.map +0 -1
  246. package/src/internal/AgenticaPromptFactory.ts +0 -32
  247. package/src/internal/AgenticaPromptTransformer.ts +0 -86
  248. package/src/internal/AgenticaTokenUsageAggregator.ts +0 -121
  249. package/src/structures/IAgenticaEvent.ts +0 -229
  250. package/src/structures/IAgenticaOperationSelection.ts +0 -68
  251. package/src/structures/IAgenticaPrompt.ts +0 -182
  252. /package/lib/{structures → context}/internal/__IChatCancelFunctionsApplication.d.ts +0 -0
  253. /package/lib/{structures → context}/internal/__IChatCancelFunctionsApplication.js +0 -0
  254. /package/lib/{structures → context}/internal/__IChatFunctionReference.d.ts +0 -0
  255. /package/lib/{structures → context}/internal/__IChatFunctionReference.js +0 -0
  256. /package/lib/{structures → context}/internal/__IChatInitialApplication.d.ts +0 -0
  257. /package/lib/{structures → context}/internal/__IChatInitialApplication.js +0 -0
  258. /package/lib/{structures → context}/internal/__IChatSelectFunctionsApplication.d.ts +0 -0
  259. /package/lib/{structures → context}/internal/__IChatSelectFunctionsApplication.js +0 -0
  260. /package/src/{structures → context}/internal/__IChatCancelFunctionsApplication.ts +0 -0
  261. /package/src/{structures → context}/internal/__IChatFunctionReference.ts +0 -0
  262. /package/src/{structures → context}/internal/__IChatInitialApplication.ts +0 -0
  263. /package/src/{structures → context}/internal/__IChatSelectFunctionsApplication.ts +0 -0
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AgenticaSelectPrompt = void 0;
4
+ const AgenticaPromptBase_1 = require("./AgenticaPromptBase");
5
+ class AgenticaSelectPrompt extends AgenticaPromptBase_1.AgenticaPromptBase {
6
+ constructor(props) {
7
+ super("select");
8
+ this.id = props.id;
9
+ this.selections = props.selections;
10
+ }
11
+ toJSON() {
12
+ return {
13
+ type: this.type,
14
+ id: this.id,
15
+ selections: this.selections.map((s) => s.toJSON()),
16
+ };
17
+ }
18
+ }
19
+ exports.AgenticaSelectPrompt = AgenticaSelectPrompt;
20
+ //# sourceMappingURL=AgenticaSelectPrompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgenticaSelectPrompt.js","sourceRoot":"","sources":["../../src/prompts/AgenticaSelectPrompt.ts"],"names":[],"mappings":";;;AAIA,6DAA0D;AAE1D,MAAa,oBAEX,SAAQ,uCAAyD;IAIjE,YAAmB,KAAyC;QAC1D,KAAK,CAAC,QAAQ,CAAC,CAAC;QAChB,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;IACrC,CAAC;IAEM,MAAM;QACX,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;SACnD,CAAC;IACJ,CAAC;CACF;AAnBD,oDAmBC"}
@@ -0,0 +1,14 @@
1
+ import { IAgenticaPromptJson } from "../json/IAgenticaPromptJson";
2
+ import { AgenticaPromptBase } from "./AgenticaPromptBase";
3
+ export declare class AgenticaTextPrompt<Role extends "assistant" | "user" = "assistant" | "user"> extends AgenticaPromptBase<"text", IAgenticaPromptJson.IText> {
4
+ readonly role: Role;
5
+ readonly text: string;
6
+ constructor(props: AgenticaTextPrompt.IProps<Role>);
7
+ toJSON(): IAgenticaPromptJson.IText<Role>;
8
+ }
9
+ export declare namespace AgenticaTextPrompt {
10
+ interface IProps<Role extends "assistant" | "user" = "assistant" | "user"> {
11
+ role: Role;
12
+ text: string;
13
+ }
14
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AgenticaTextPrompt = void 0;
4
+ const AgenticaPromptBase_1 = require("./AgenticaPromptBase");
5
+ class AgenticaTextPrompt extends AgenticaPromptBase_1.AgenticaPromptBase {
6
+ constructor(props) {
7
+ super("text");
8
+ this.role = props.role;
9
+ this.text = props.text;
10
+ }
11
+ toJSON() {
12
+ return {
13
+ type: this.type,
14
+ role: this.role,
15
+ text: this.text,
16
+ };
17
+ }
18
+ }
19
+ exports.AgenticaTextPrompt = AgenticaTextPrompt;
20
+ //# sourceMappingURL=AgenticaTextPrompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgenticaTextPrompt.js","sourceRoot":"","sources":["../../src/prompts/AgenticaTextPrompt.ts"],"names":[],"mappings":";;;AACA,6DAA0D;AAE1D,MAAa,kBAEX,SAAQ,uCAAqD;IAI7D,YAAmB,KAAsC;QACvD,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;IAEM,MAAM;QACX,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC;IACJ,CAAC;CACF;AAnBD,gDAmBC"}
@@ -1,7 +1,7 @@
1
1
  import { ILlmSchema } from "@samchon/openapi";
2
- import { IAgenticaContext } from "./IAgenticaContext";
2
+ import { AgenticaContext } from "../context/AgenticaContext";
3
+ import { AgenticaPrompt } from "../prompts/AgenticaPrompt";
3
4
  import { IAgenticaExecutor } from "./IAgenticaExecutor";
4
- import { IAgenticaPrompt } from "./IAgenticaPrompt";
5
5
  import { IAgenticaSystemPrompt } from "./IAgenticaSystemPrompt";
6
6
  /**
7
7
  * Configuration for Nestia Agent.
@@ -109,5 +109,5 @@ export interface IAgenticaConfig<Model extends ILlmSchema.Model> {
109
109
  * @returns Lit of prompts generated by the executor
110
110
  * @default ChatGptAgent.execute
111
111
  */
112
- executor?: Partial<IAgenticaExecutor<Model>> | ((ctx: IAgenticaContext<Model>) => Promise<IAgenticaPrompt<Model>[]>);
112
+ executor?: Partial<IAgenticaExecutor<Model>> | ((ctx: AgenticaContext<Model>) => Promise<AgenticaPrompt<Model>[]>);
113
113
  }
@@ -1,6 +1,7 @@
1
1
  import { ILlmSchema } from "@samchon/openapi";
2
- import { IAgenticaContext } from "./IAgenticaContext";
3
- import { IAgenticaPrompt } from "./IAgenticaPrompt";
2
+ import { AgenticaContext } from "../context/AgenticaContext";
3
+ import { AgenticaExecutePrompt } from "../prompts/AgenticaExecutePrompt";
4
+ import { AgenticaPrompt } from "../prompts/AgenticaPrompt";
4
5
  /**
5
6
  * Executor of the Agentic AI.
6
7
  *
@@ -34,7 +35,7 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
34
35
  *
35
36
  * And if the `initialize` agent judges the user's conversation
36
37
  * implies to call some function, the `initialize` agent will
37
- * call the {@link IAgenticaContext.initialize} function, and
38
+ * call the {@link AgenticaContext.initialize} function, and
38
39
  * inform every functions enrolled in the {@link IAgenticaController}
39
40
  * to the AI agent. And then, the `initialize` agent will not never
40
41
  * be called again, and let {@link Agentica} to go to the next
@@ -53,13 +54,13 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
53
54
  * @param ctx Context of the agent
54
55
  * @returns List of prompts generated by the initializer
55
56
  */
56
- initialize: null | ((ctx: IAgenticaContext<Model>) => Promise<IAgenticaPrompt<Model>[]>);
57
+ initialize: null | ((ctx: AgenticaContext<Model>) => Promise<AgenticaPrompt<Model>[]>);
57
58
  /**
58
59
  * Function selector agent.
59
60
  *
60
61
  * `Select` agent finds candidate functions to call from the
61
62
  * conversation context with the user. And the candidate functions
62
- * would be enrolled to the {@link IAgenticaContext.stack}, and the
63
+ * would be enrolled to the {@link AgenticaContext.stack}, and the
63
64
  * next {@link call} agent will perform the LLM (Large Language Model)
64
65
  * function calling.
65
66
  *
@@ -81,13 +82,13 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
81
82
  * @param ctx Context of the agent
82
83
  * @returns List of prompts generated by the selector
83
84
  */
84
- select: (ctx: IAgenticaContext<Model>) => Promise<IAgenticaPrompt<Model>[]>;
85
+ select: (ctx: AgenticaContext<Model>) => Promise<AgenticaPrompt<Model>[]>;
85
86
  /**
86
87
  * Function caller agent.
87
88
  *
88
89
  * `Call` agent performs the LLM (Large Language Model) function
89
90
  * calling from the candidate functions enrolled in the
90
- * {@link IAgenticaContext.stack}. And the scope of function calling
91
+ * {@link AgenticaContext.stack}. And the scope of function calling
91
92
  * is, not only just arguments filling, but also actual executing
92
93
  * the function and returning the result.
93
94
  *
@@ -107,7 +108,7 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
107
108
  * agent is the most general topic which can be universally
108
109
  * applied to all domain fields.
109
110
  */
110
- call: (ctx: IAgenticaContext<Model>) => Promise<IAgenticaPrompt<Model>[]>;
111
+ call: (ctx: AgenticaContext<Model>) => Promise<AgenticaPrompt<Model>[]>;
111
112
  /**
112
113
  * Describer agent of the function calling result.
113
114
  *
@@ -118,12 +119,12 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
118
119
  * @param executes List of function calling results
119
120
  * @returns List of prompts generated by the describer
120
121
  */
121
- describe: (ctx: IAgenticaContext<Model>, executes: IAgenticaPrompt.IExecute<Model>[]) => Promise<IAgenticaPrompt<Model>[]>;
122
+ describe: (ctx: AgenticaContext<Model>, executes: AgenticaExecutePrompt<Model>[]) => Promise<AgenticaPrompt<Model>[]>;
122
123
  /**
123
124
  * Function canceler agent.
124
125
  *
125
126
  * `Cancel` agent erases the candidate functions from the
126
- * {@link IAgenticaContext.stack} by analyzing the conversation
127
+ * {@link AgenticaContext.stack} by analyzing the conversation
127
128
  * context with the user.
128
129
  *
129
130
  * For reference, the first reason of the cancelation is explicit
@@ -141,5 +142,5 @@ export interface IAgenticaExecutor<Model extends ILlmSchema.Model> {
141
142
  * @param ctx Context of the agent
142
143
  * @returns List of prompts generated by the canceler
143
144
  */
144
- cancel: (ctx: IAgenticaContext<Model>) => Promise<IAgenticaPrompt<Model>[]>;
145
+ cancel: (ctx: AgenticaContext<Model>) => Promise<AgenticaPrompt<Model>[]>;
145
146
  }
@@ -1,8 +1,7 @@
1
1
  import { ILlmSchema } from "@samchon/openapi";
2
- import { Primitive } from "typia";
2
+ import { IAgenticaPromptJson } from "../json/IAgenticaPromptJson";
3
3
  import { IAgenticaConfig } from "./IAgenticaConfig";
4
4
  import { IAgenticaController } from "./IAgenticaController";
5
- import { IAgenticaPrompt } from "./IAgenticaPrompt";
6
5
  import { IAgenticaVendor } from "./IAgenticaVendor";
7
6
  /**
8
7
  * Properties of the Nestia Agent.
@@ -60,5 +59,5 @@ export interface IAgenticaProps<Model extends ILlmSchema.Model> {
60
59
  * If you're starting the conversation from an existing session,
61
60
  * assign the previouis prompt histories to this property.
62
61
  */
63
- histories?: Primitive<IAgenticaPrompt<Model>>[];
62
+ histories?: IAgenticaPromptJson[];
64
63
  }
@@ -1,6 +1,7 @@
1
1
  import { ILlmSchema } from "@samchon/openapi";
2
+ import { AgenticaExecutePrompt } from "../prompts/AgenticaExecutePrompt";
3
+ import { AgenticaPrompt } from "../prompts/AgenticaPrompt";
2
4
  import { IAgenticaConfig } from "./IAgenticaConfig";
3
- import { IAgenticaPrompt } from "./IAgenticaPrompt";
4
5
  /**
5
6
  * System prompt collection of the A.I. chatbot.
6
7
  *
@@ -38,13 +39,13 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
38
39
  *
39
40
  * In that case, the `initialize` system prompt would be used. You can
40
41
  * customize the `initialize` system prompt by assigning this function
41
- * with the given {@link IAgenticaPrompt histories} parameter.
42
+ * with the given {@link AgenticaPrompt histories} parameter.
42
43
  *
43
44
  * @param histories Histories of the previous prompts
44
45
  * @returns initialize system prompt
45
46
  * @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/initialize.md
46
47
  */
47
- initialize?: (histories: IAgenticaPrompt<Model>[]) => string;
48
+ initialize?: (histories: AgenticaPrompt<Model>[]) => string;
48
49
  /**
49
50
  * Select system prompt.
50
51
  *
@@ -54,7 +55,7 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
54
55
  *
55
56
  * In that case, this `select` system prompt would be used. You can
56
57
  * customize it by assigning this function with the given
57
- * {@link IAgenticaPrompt histories} parameter.
58
+ * {@link AgenticaPrompt histories} parameter.
58
59
  *
59
60
  * Note that, the `"select"` means only the function selection. It does
60
61
  * not contain the filling argument or executing the function. It
@@ -64,7 +65,7 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
64
65
  * @returns select system promopt
65
66
  * @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/select.md
66
67
  */
67
- select?: (histories: IAgenticaPrompt<Model>[]) => string;
68
+ select?: (histories: AgenticaPrompt<Model>[]) => string;
68
69
  /**
69
70
  * Cancel system prompt.
70
71
  *
@@ -74,13 +75,13 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
74
75
  *
75
76
  * In that case, this `cancel` system prompt would be used. You can
76
77
  * customize it by assigning this function with the given
77
- * {@link IAgenticaPrompt histories} parameter.
78
+ * {@link AgenticaPrompt histories} parameter.
78
79
  *
79
80
  * @param histories Histories of the previous prompts
80
81
  * @returns cancel system prompt
81
82
  * @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/cancel.md
82
83
  */
83
- cancel?: (histories: IAgenticaPrompt<Model>[]) => string;
84
+ cancel?: (histories: AgenticaPrompt<Model>[]) => string;
84
85
  /**
85
86
  * Execute system prompt.
86
87
  *
@@ -91,13 +92,13 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
91
92
  *
92
93
  * In that case, this `execute` system prompt would be used. You can
93
94
  * customize it by assigning this function with the given
94
- * {@link IAgenticaPrompt histories} parameter.
95
+ * {@link AgenticaPrompt histories} parameter.
95
96
  *
96
97
  * @param histories Histories of the previous prompts
97
98
  * @returns execute system prompt
98
99
  * https://github.com/samchon/nestia/blob/master/packages/agent/prompts/execute.md
99
100
  */
100
- execute?: (histories: IAgenticaPrompt<Model>[]) => string;
101
+ execute?: (histories: AgenticaPrompt<Model>[]) => string;
101
102
  /**
102
103
  * Describe system prompt.
103
104
  *
@@ -107,11 +108,11 @@ export interface IAgenticaSystemPrompt<Model extends ILlmSchema.Model> {
107
108
  *
108
109
  * In that case, this `describe` system prompt would be used. You can
109
110
  * customize it by assigning this function with the given
110
- * {@link IAgenticaPrompt histories} parameter.
111
+ * {@link AgenticaPrompt histories} parameter.
111
112
  *
112
113
  * @param histories Histories of the previous prompts
113
114
  * @returns describe system prompt
114
115
  * @default https://github.com/samchon/nestia/blob/master/packages/agent/prompts/describe.md
115
116
  */
116
- describe?: (histories: IAgenticaPrompt.IExecute<Model>[]) => string;
117
+ describe?: (histories: AgenticaExecutePrompt<Model>[]) => string;
117
118
  }
@@ -0,0 +1,45 @@
1
+ import { ILlmSchema } from "@samchon/openapi";
2
+ import { AgenticaOperation } from "../context/AgenticaOperation";
3
+ import { AgenticaCallEvent } from "../events/AgenticaCallEvent";
4
+ import { AgenticaCancelEvent } from "../events/AgenticaCancelEvent";
5
+ import { AgenticaDescribeEvent } from "../events/AgenticaDescribeEvent";
6
+ import { AgenticaEvent } from "../events/AgenticaEvent";
7
+ import { AgenticaExecuteEvent } from "../events/AgenticaExecuteEvent";
8
+ import { AgenticaInitializeEvent } from "../events/AgenticaInitializeEvent";
9
+ import { AgenticaRequestEvent } from "../events/AgenticaRequestEvent";
10
+ import { AgenticaSelectEvent } from "../events/AgenticaSelectEvent";
11
+ import { AgenticaTextEvent } from "../events/AgenticaTextEvent";
12
+ import { IAgenticaEventJson } from "../json/IAgenticaEventJson";
13
+ export declare namespace AgenticaEventTransformer {
14
+ const transform: <Model extends ILlmSchema.Model>(props: {
15
+ operations: Map<string, Map<string, AgenticaOperation<Model>>>;
16
+ event: IAgenticaEventJson;
17
+ }) => AgenticaEvent<Model>;
18
+ const transformCall: <Model extends ILlmSchema.Model>(props: {
19
+ operations: Map<string, Map<string, AgenticaOperation<Model>>>;
20
+ event: IAgenticaEventJson.ICall;
21
+ }) => AgenticaCallEvent<Model>;
22
+ const transformCancel: <Model extends ILlmSchema.Model>(props: {
23
+ operations: Map<string, Map<string, AgenticaOperation<Model>>>;
24
+ event: IAgenticaEventJson.ICancel;
25
+ }) => AgenticaCancelEvent<Model>;
26
+ const transformDescribe: <Model extends ILlmSchema.Model>(props: {
27
+ operations: Map<string, Map<string, AgenticaOperation<Model>>>;
28
+ event: IAgenticaEventJson.IDescribe;
29
+ }) => AgenticaDescribeEvent<Model>;
30
+ const transformExecute: <Model extends ILlmSchema.Model>(props: {
31
+ operations: Map<string, Map<string, AgenticaOperation<Model>>>;
32
+ event: IAgenticaEventJson.IExecute;
33
+ }) => AgenticaExecuteEvent<Model>;
34
+ const transformInitialize: () => AgenticaInitializeEvent;
35
+ const transformRequest: (props: {
36
+ event: IAgenticaEventJson.IRequest;
37
+ }) => AgenticaRequestEvent;
38
+ const transformSelect: <Model extends ILlmSchema.Model>(props: {
39
+ operations: Map<string, Map<string, AgenticaOperation<Model>>>;
40
+ event: IAgenticaEventJson.ISelect;
41
+ }) => AgenticaSelectEvent<Model>;
42
+ const transformText: (props: {
43
+ event: IAgenticaEventJson.IText;
44
+ }) => AgenticaTextEvent;
45
+ }
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AgenticaEventTransformer = void 0;
13
+ const AgenticaOperationSelection_1 = require("../context/AgenticaOperationSelection");
14
+ const AgenticaCallEvent_1 = require("../events/AgenticaCallEvent");
15
+ const AgenticaCancelEvent_1 = require("../events/AgenticaCancelEvent");
16
+ const AgenticaDescribeEvent_1 = require("../events/AgenticaDescribeEvent");
17
+ const AgenticaExecuteEvent_1 = require("../events/AgenticaExecuteEvent");
18
+ const AgenticaInitializeEvent_1 = require("../events/AgenticaInitializeEvent");
19
+ const AgenticaRequestEvent_1 = require("../events/AgenticaRequestEvent");
20
+ const AgenticaSelectEvent_1 = require("../events/AgenticaSelectEvent");
21
+ const AgenticaTextEvent_1 = require("../events/AgenticaTextEvent");
22
+ const StreamUtil_1 = require("../internal/StreamUtil");
23
+ var AgenticaEventTransformer;
24
+ (function (AgenticaEventTransformer) {
25
+ AgenticaEventTransformer.transform = (props) => {
26
+ if (props.event.type === "call")
27
+ return AgenticaEventTransformer.transformCall({
28
+ operations: props.operations,
29
+ event: props.event,
30
+ });
31
+ else if (props.event.type === "cancel")
32
+ return AgenticaEventTransformer.transformCancel({
33
+ operations: props.operations,
34
+ event: props.event,
35
+ });
36
+ else if (props.event.type === "describe")
37
+ return AgenticaEventTransformer.transformDescribe({
38
+ operations: props.operations,
39
+ event: props.event,
40
+ });
41
+ else if (props.event.type === "execute")
42
+ return AgenticaEventTransformer.transformExecute({
43
+ operations: props.operations,
44
+ event: props.event,
45
+ });
46
+ else if (props.event.type === "initialize")
47
+ return AgenticaEventTransformer.transformInitialize();
48
+ else if (props.event.type === "request")
49
+ return AgenticaEventTransformer.transformRequest({
50
+ event: props.event,
51
+ });
52
+ else if (props.event.type === "select")
53
+ return AgenticaEventTransformer.transformSelect({
54
+ operations: props.operations,
55
+ event: props.event,
56
+ });
57
+ else if (props.event.type === "text")
58
+ return AgenticaEventTransformer.transformText({
59
+ event: props.event,
60
+ });
61
+ else
62
+ throw new Error("Unknown event type");
63
+ };
64
+ AgenticaEventTransformer.transformCall = (props) => new AgenticaCallEvent_1.AgenticaCallEvent({
65
+ id: props.event.id,
66
+ operation: findOperation({
67
+ operations: props.operations,
68
+ input: props.event.operation,
69
+ }),
70
+ arguments: props.event.arguments,
71
+ });
72
+ AgenticaEventTransformer.transformCancel = (props) => new AgenticaCancelEvent_1.AgenticaCancelEvent({
73
+ selection: new AgenticaOperationSelection_1.AgenticaOperationSelection({
74
+ operation: findOperation({
75
+ operations: props.operations,
76
+ input: props.event.selection.operation,
77
+ }),
78
+ reason: props.event.selection.reason,
79
+ }),
80
+ });
81
+ AgenticaEventTransformer.transformDescribe = (props) => new AgenticaDescribeEvent_1.AgenticaDescribeEvent({
82
+ executes: props.event.executes.map((next) => AgenticaEventTransformer.transformExecute({
83
+ operations: props.operations,
84
+ event: next,
85
+ })),
86
+ stream: StreamUtil_1.StreamUtil.to(props.event.text),
87
+ done: () => true,
88
+ get: () => props.event.text,
89
+ join: () => __awaiter(this, void 0, void 0, function* () { return props.event.text; }),
90
+ });
91
+ AgenticaEventTransformer.transformExecute = (props) => new AgenticaExecuteEvent_1.AgenticaExecuteEvent({
92
+ id: props.event.id,
93
+ operation: findOperation({
94
+ operations: props.operations,
95
+ input: props.event.operation,
96
+ }),
97
+ arguments: props.event.arguments,
98
+ value: props.event.value,
99
+ });
100
+ AgenticaEventTransformer.transformInitialize = () => new AgenticaInitializeEvent_1.AgenticaInitializeEvent();
101
+ AgenticaEventTransformer.transformRequest = (props) => new AgenticaRequestEvent_1.AgenticaRequestEvent(props.event);
102
+ AgenticaEventTransformer.transformSelect = (props) => new AgenticaSelectEvent_1.AgenticaSelectEvent({
103
+ selection: new AgenticaOperationSelection_1.AgenticaOperationSelection({
104
+ operation: findOperation({
105
+ operations: props.operations,
106
+ input: props.event.selection.operation,
107
+ }),
108
+ reason: props.event.selection.reason,
109
+ }),
110
+ });
111
+ AgenticaEventTransformer.transformText = (props) => new AgenticaTextEvent_1.AgenticaTextEvent({
112
+ role: props.event.role,
113
+ stream: StreamUtil_1.StreamUtil.to(props.event.text),
114
+ done: () => true,
115
+ get: () => props.event.text,
116
+ join: () => __awaiter(this, void 0, void 0, function* () { return props.event.text; }),
117
+ });
118
+ })(AgenticaEventTransformer || (exports.AgenticaEventTransformer = AgenticaEventTransformer = {}));
119
+ const findOperation = (props) => {
120
+ var _a;
121
+ const found = (_a = props.operations
122
+ .get(props.input.controller)) === null || _a === void 0 ? void 0 : _a.get(props.input.function);
123
+ if (found === undefined)
124
+ throw new Error(`No operation found: (controller: ${props.input.controller}, function: ${props.input.function})`);
125
+ return found;
126
+ };
127
+ //# sourceMappingURL=AgenticaEventTransformer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgenticaEventTransformer.js","sourceRoot":"","sources":["../../src/transformers/AgenticaEventTransformer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,sFAAmF;AACnF,mEAAgE;AAChE,uEAAoE;AACpE,2EAAwE;AAExE,yEAAsE;AACtE,+EAA4E;AAC5E,yEAAsE;AACtE,uEAAoE;AACpE,mEAAgE;AAChE,uDAAoD;AAGpD,IAAiB,wBAAwB,CAmIxC;AAnID,WAAiB,wBAAwB;IAC1B,kCAAS,GAAG,CAAiC,KAGzD,EAAwB,EAAE;QACzB,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM;YAC7B,OAAO,yBAAA,aAAa,CAAC;gBACnB,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,KAAK,EAAE,KAAK,CAAC,KAAK;aACnB,CAAC,CAAC;aACA,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ;YACpC,OAAO,yBAAA,eAAe,CAAC;gBACrB,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,KAAK,EAAE,KAAK,CAAC,KAAK;aACnB,CAAC,CAAC;aACA,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,UAAU;YACtC,OAAO,yBAAA,iBAAiB,CAAC;gBACvB,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,KAAK,EAAE,KAAK,CAAC,KAAK;aACnB,CAAC,CAAC;aACA,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS;YACrC,OAAO,yBAAA,gBAAgB,CAAC;gBACtB,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,KAAK,EAAE,KAAK,CAAC,KAAK;aACnB,CAA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../context/AgenticaOperation";
3
+ import { IAgenticaPromptJson } from "../json/IAgenticaPromptJson";
4
+ import { AgenticaCancelPrompt } from "../prompts/AgenticaCancelPrompt";
5
+ import { AgenticaDescribePrompt } from "../prompts/AgenticaDescribePrompt";
6
+ import { AgenticaExecutePrompt } from "../prompts/AgenticaExecutePrompt";
7
+ import { AgenticaPrompt } from "../prompts/AgenticaPrompt";
8
+ import { AgenticaSelectPrompt } from "../prompts/AgenticaSelectPrompt";
9
+ import { AgenticaTextPrompt } from "../prompts/AgenticaTextPrompt";
10
+ export declare namespace AgenticaPromptTransformer {
11
+ const transform: <Model extends ILlmSchema.Model>(props: {
12
+ operations: Map<string, Map<string, AgenticaOperation<Model>>>;
13
+ prompt: IAgenticaPromptJson;
14
+ }) => AgenticaPrompt<Model>;
15
+ const transformText: (props: {
16
+ prompt: IAgenticaPromptJson.IText;
17
+ }) => AgenticaTextPrompt;
18
+ const transformSelect: <Model extends ILlmSchema.Model>(props: {
19
+ operations: Map<string, Map<string, AgenticaOperation<Model>>>;
20
+ prompt: IAgenticaPromptJson.ISelect;
21
+ }) => AgenticaSelectPrompt<Model>;
22
+ const transformCancel: <Model extends ILlmSchema.Model>(props: {
23
+ operations: Map<string, Map<string, AgenticaOperation<Model>>>;
24
+ prompt: IAgenticaPromptJson.ICancel;
25
+ }) => AgenticaCancelPrompt<Model>;
26
+ const transformExecute: <Model extends ILlmSchema.Model>(props: {
27
+ operations: Map<string, Map<string, AgenticaOperation<Model>>>;
28
+ prompt: IAgenticaPromptJson.IExecute;
29
+ }) => AgenticaExecutePrompt<Model>;
30
+ const transformDescribe: <Model extends ILlmSchema.Model>(props: {
31
+ operations: Map<string, Map<string, AgenticaOperation<Model>>>;
32
+ prompt: IAgenticaPromptJson.IDescribe;
33
+ }) => AgenticaDescribePrompt<Model>;
34
+ }
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AgenticaPromptTransformer = void 0;
4
+ const AgenticaOperationSelection_1 = require("../context/AgenticaOperationSelection");
5
+ const AgenticaCancelPrompt_1 = require("../prompts/AgenticaCancelPrompt");
6
+ const AgenticaDescribePrompt_1 = require("../prompts/AgenticaDescribePrompt");
7
+ const AgenticaExecutePrompt_1 = require("../prompts/AgenticaExecutePrompt");
8
+ const AgenticaSelectPrompt_1 = require("../prompts/AgenticaSelectPrompt");
9
+ const AgenticaTextPrompt_1 = require("../prompts/AgenticaTextPrompt");
10
+ var AgenticaPromptTransformer;
11
+ (function (AgenticaPromptTransformer) {
12
+ AgenticaPromptTransformer.transform = (props) => {
13
+ // TEXT
14
+ if (props.prompt.type === "text")
15
+ return AgenticaPromptTransformer.transformText({
16
+ prompt: props.prompt,
17
+ });
18
+ // SELECT & CANCEL
19
+ else if (props.prompt.type === "select")
20
+ return AgenticaPromptTransformer.transformSelect({
21
+ operations: props.operations,
22
+ prompt: props.prompt,
23
+ });
24
+ else if (props.prompt.type === "cancel")
25
+ return AgenticaPromptTransformer.transformCancel({
26
+ operations: props.operations,
27
+ prompt: props.prompt,
28
+ });
29
+ // EXECUTE
30
+ else if (props.prompt.type === "execute")
31
+ return AgenticaPromptTransformer.transformExecute({
32
+ operations: props.operations,
33
+ prompt: props.prompt,
34
+ });
35
+ else if (props.prompt.type === "describe")
36
+ return AgenticaPromptTransformer.transformDescribe({
37
+ operations: props.operations,
38
+ prompt: props.prompt,
39
+ });
40
+ throw new Error("Invalid prompt type.");
41
+ };
42
+ AgenticaPromptTransformer.transformText = (props) => {
43
+ return new AgenticaTextPrompt_1.AgenticaTextPrompt(props.prompt);
44
+ };
45
+ AgenticaPromptTransformer.transformSelect = (props) => new AgenticaSelectPrompt_1.AgenticaSelectPrompt({
46
+ id: props.prompt.id,
47
+ selections: props.prompt.selections.map((select) => new AgenticaOperationSelection_1.AgenticaOperationSelection({
48
+ operation: findOperation({
49
+ operations: props.operations,
50
+ input: select.operation,
51
+ }),
52
+ reason: select.reason,
53
+ })),
54
+ });
55
+ AgenticaPromptTransformer.transformCancel = (props) => new AgenticaCancelPrompt_1.AgenticaCancelPrompt({
56
+ id: props.prompt.id,
57
+ selections: props.prompt.selections.map((select) => new AgenticaOperationSelection_1.AgenticaOperationSelection({
58
+ operation: findOperation({
59
+ operations: props.operations,
60
+ input: select.operation,
61
+ }),
62
+ reason: select.reason,
63
+ })),
64
+ });
65
+ AgenticaPromptTransformer.transformExecute = (props) => new AgenticaExecutePrompt_1.AgenticaExecutePrompt({
66
+ id: props.prompt.id,
67
+ operation: findOperation({
68
+ operations: props.operations,
69
+ input: props.prompt.operation,
70
+ }),
71
+ arguments: props.prompt.arguments,
72
+ value: props.prompt.value,
73
+ });
74
+ AgenticaPromptTransformer.transformDescribe = (props) => new AgenticaDescribePrompt_1.AgenticaDescribePrompt({
75
+ text: props.prompt.text,
76
+ executes: props.prompt.executions.map((next) => AgenticaPromptTransformer.transformExecute({
77
+ operations: props.operations,
78
+ prompt: next,
79
+ })),
80
+ });
81
+ })(AgenticaPromptTransformer || (exports.AgenticaPromptTransformer = AgenticaPromptTransformer = {}));
82
+ const findOperation = (props) => {
83
+ var _a;
84
+ const found = (_a = props.operations
85
+ .get(props.input.controller)) === null || _a === void 0 ? void 0 : _a.get(props.input.function);
86
+ if (found === undefined)
87
+ throw new Error(`No operation found: (controller: ${props.input.controller}, function: ${props.input.function})`);
88
+ return found;
89
+ };
90
+ //# sourceMappingURL=AgenticaPromptTransformer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgenticaPromptTransformer.js","sourceRoot":"","sources":["../../src/transformers/AgenticaPromptTransformer.ts"],"names":[],"mappings":";;;AAGA,sFAAmF;AAEnF,0EAAuE;AACvE,8EAA2E;AAC3E,4EAAyE;AAEzE,0EAAuE;AACvE,sEAAmE;AAEnE,IAAiB,yBAAyB,CAwGzC;AAxGD,WAAiB,yBAAyB;IAC3B,mCAAS,GAAG,CAAiC,KAGzD,EAAyB,EAAE;QAC1B,OAAO;QACP,IAAI,KAAK,CAAC,MAAM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AC,IAAI,EAAE,EAAE,CAC7C,0BAAA,gBAAgB,CAAC;YACf,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,MAAM,EAAE,IAAI;SACb,CAAC,CACH;KACF,CAAC,CAAC;AACP,CAAC,EAxGgB,yBAAyB,yCAAzB,yBAAyB,QAwGzC;AAED,MAAM,aAAa,GAAG,CAAiC,KAMtD,EAA4B,EAAE;;IAC7B,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;QACrB,MAAM,IAAI,KAAK,CACb,oCAAoC,KAAK,CAAC,KAAK,CAAC,UAAU,eAAe,KAAK,CAAC,KAAK,CAAC,QAAQ,GAAG,CACjG,CAAC;IACJ,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentica/core",
3
- "version": "0.10.4",
3
+ "version": "0.11.0",
4
4
  "main": "lib/index.js",
5
5
  "description": "Agentic AI Library specialized in LLM Function Calling",
6
6
  "scripts": {