@agentica/core 0.15.7 → 0.16.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 (195) hide show
  1. package/lib/Agentica.d.ts +21 -21
  2. package/lib/Agentica.js +27 -27
  3. package/lib/Agentica.js.map +1 -1
  4. package/lib/MicroAgentica.d.ts +115 -0
  5. package/lib/MicroAgentica.js +279 -0
  6. package/lib/MicroAgentica.js.map +1 -0
  7. package/lib/constants/AgenticaDefaultPrompt.d.ts +2 -1
  8. package/lib/constants/AgenticaDefaultPrompt.js +4 -4
  9. package/lib/constants/AgenticaDefaultPrompt.js.map +1 -1
  10. package/lib/context/AgenticaCancelPrompt.d.ts +3 -3
  11. package/lib/context/AgenticaContext.d.ts +12 -12
  12. package/lib/context/AgenticaOperationCollection.d.ts +1 -1
  13. package/lib/context/MicroAgenticaContext.d.ts +75 -0
  14. package/lib/{prompts/AgenticaCancelPrompt.js → context/MicroAgenticaContext.js} +1 -1
  15. package/lib/context/MicroAgenticaContext.js.map +1 -0
  16. package/lib/context/internal/AgenticaOperationComposer.d.ts +2 -1
  17. package/lib/context/internal/AgenticaOperationComposer.js +3 -2
  18. package/lib/context/internal/AgenticaOperationComposer.js.map +1 -1
  19. package/lib/context/internal/isAgenticaContext.d.ts +1 -0
  20. package/lib/context/internal/isAgenticaContext.js +10 -0
  21. package/lib/context/internal/isAgenticaContext.js.map +1 -0
  22. package/lib/events/AgenticaDescribeEvent.d.ts +4 -4
  23. package/lib/events/AgenticaEvent.d.ts +1 -0
  24. package/lib/events/AgenticaExecuteEvent.d.ts +5 -5
  25. package/lib/events/AgenticaSelectEvent.d.ts +2 -2
  26. package/lib/events/AgenticaTextEvent.d.ts +2 -2
  27. package/lib/events/MicroAgenticaEvent.d.ts +32 -0
  28. package/lib/{prompts/AgenticaTextPrompt.js → events/MicroAgenticaEvent.js} +1 -1
  29. package/lib/events/MicroAgenticaEvent.js.map +1 -0
  30. package/lib/factory/events.d.ts +2 -2
  31. package/lib/factory/events.js +5 -5
  32. package/lib/factory/events.js.map +1 -1
  33. package/lib/factory/histories.d.ts +33 -0
  34. package/lib/factory/{prompts.js → histories.js} +13 -13
  35. package/lib/factory/histories.js.map +1 -0
  36. package/lib/factory/index.d.ts +1 -1
  37. package/lib/factory/index.js +1 -1
  38. package/lib/factory/index.js.map +1 -1
  39. package/lib/functional/assertHttpLlmApplication.js +577 -387
  40. package/lib/functional/assertHttpLlmApplication.js.map +1 -1
  41. package/lib/functional/validateHttpLlmApplication.js +500 -348
  42. package/lib/functional/validateHttpLlmApplication.js.map +1 -1
  43. package/lib/histories/AgenticaCancelHistory.d.ts +8 -0
  44. package/lib/{prompts/AgenticaExecutePrompt.js → histories/AgenticaCancelHistory.js} +1 -1
  45. package/lib/histories/AgenticaCancelHistory.js.map +1 -0
  46. package/lib/histories/AgenticaDescribeHistory.d.ts +16 -0
  47. package/lib/histories/AgenticaDescribeHistory.js +3 -0
  48. package/lib/histories/AgenticaDescribeHistory.js.map +1 -0
  49. package/lib/{prompts/AgenticaExecutePrompt.d.ts → histories/AgenticaExecuteHistory.d.ts} +5 -5
  50. package/lib/{prompts/AgenticaDescribePrompt.js → histories/AgenticaExecuteHistory.js} +1 -1
  51. package/lib/histories/AgenticaExecuteHistory.js.map +1 -0
  52. package/lib/histories/AgenticaHistory.d.ts +17 -0
  53. package/lib/{prompts/AgenticaPrompt.js → histories/AgenticaHistory.js} +1 -1
  54. package/lib/histories/AgenticaHistory.js.map +1 -0
  55. package/lib/{prompts/AgenticaPromptBase.d.ts → histories/AgenticaHistoryBase.d.ts} +4 -4
  56. package/lib/{json/IAgenticaPromptJson.js → histories/AgenticaHistoryBase.js} +1 -1
  57. package/lib/histories/AgenticaHistoryBase.js.map +1 -0
  58. package/lib/histories/AgenticaSelectHistory.d.ts +8 -0
  59. package/lib/histories/AgenticaSelectHistory.js +3 -0
  60. package/lib/histories/AgenticaSelectHistory.js.map +1 -0
  61. package/lib/histories/AgenticaTextHistory.d.ts +6 -0
  62. package/lib/{prompts/AgenticaPromptBase.js → histories/AgenticaTextHistory.js} +1 -1
  63. package/lib/histories/AgenticaTextHistory.js.map +1 -0
  64. package/lib/histories/MicroAgenticaHistory.d.ts +13 -0
  65. package/lib/histories/MicroAgenticaHistory.js +3 -0
  66. package/lib/histories/MicroAgenticaHistory.js.map +1 -0
  67. package/lib/index.d.ts +12 -7
  68. package/lib/index.js +12 -7
  69. package/lib/index.js.map +1 -1
  70. package/lib/index.mjs +1392 -901
  71. package/lib/index.mjs.map +1 -1
  72. package/lib/json/IAgenticaEventJson.d.ts +6 -5
  73. package/lib/json/{IAgenticaPromptJson.d.ts → IAgenticaHistoryJson.d.ts} +8 -8
  74. package/lib/json/IAgenticaHistoryJson.js +3 -0
  75. package/lib/json/IAgenticaHistoryJson.js.map +1 -0
  76. package/lib/json/IAgenticaOperationSelectionJson.d.ts +7 -1
  77. package/lib/json/IMicroAgenticaEventJson.d.ts +13 -0
  78. package/lib/json/IMicroAgenticaEventJson.js +3 -0
  79. package/lib/json/IMicroAgenticaEventJson.js.map +1 -0
  80. package/lib/json/IMicroAgenticaHistoryJson.d.ts +19 -0
  81. package/lib/json/IMicroAgenticaHistoryJson.js +3 -0
  82. package/lib/json/IMicroAgenticaHistoryJson.js.map +1 -0
  83. package/lib/orchestrate/call.d.ts +4 -2
  84. package/lib/orchestrate/call.js +50 -41
  85. package/lib/orchestrate/call.js.map +1 -1
  86. package/lib/orchestrate/cancel.js +4 -4
  87. package/lib/orchestrate/cancel.js.map +1 -1
  88. package/lib/orchestrate/describe.d.ts +4 -3
  89. package/lib/orchestrate/describe.js +3 -3
  90. package/lib/orchestrate/describe.js.map +1 -1
  91. package/lib/orchestrate/execute.d.ts +2 -2
  92. package/lib/orchestrate/execute.js +1 -1
  93. package/lib/orchestrate/execute.js.map +1 -1
  94. package/lib/orchestrate/initialize.d.ts +2 -2
  95. package/lib/orchestrate/initialize.js +3 -3
  96. package/lib/orchestrate/initialize.js.map +1 -1
  97. package/lib/orchestrate/internal/selectFunction.d.ts +1 -5
  98. package/lib/orchestrate/internal/selectFunction.js +3 -0
  99. package/lib/orchestrate/internal/selectFunction.js.map +1 -1
  100. package/lib/orchestrate/select.d.ts +2 -2
  101. package/lib/orchestrate/select.js +5 -5
  102. package/lib/orchestrate/select.js.map +1 -1
  103. package/lib/structures/IAgenticaConfig.d.ts +6 -5
  104. package/lib/structures/IAgenticaController.d.ts +1 -1
  105. package/lib/structures/IAgenticaExecutor.d.ts +11 -9
  106. package/lib/structures/IAgenticaProps.d.ts +3 -3
  107. package/lib/structures/IAgenticaSystemPrompt.d.ts +13 -13
  108. package/lib/structures/IAgenticaVendor.d.ts +1 -1
  109. package/lib/structures/IMicroAgenticaConfig.d.ts +74 -0
  110. package/lib/structures/IMicroAgenticaConfig.js +3 -0
  111. package/lib/structures/IMicroAgenticaConfig.js.map +1 -0
  112. package/lib/structures/IMicroAgenticaExecutor.d.ts +57 -0
  113. package/lib/structures/IMicroAgenticaExecutor.js +3 -0
  114. package/lib/structures/IMicroAgenticaExecutor.js.map +1 -0
  115. package/lib/structures/IMicroAgenticaProps.d.ts +63 -0
  116. package/lib/structures/IMicroAgenticaProps.js +3 -0
  117. package/lib/structures/IMicroAgenticaProps.js.map +1 -0
  118. package/lib/structures/IMicroAgenticaSystemPrompt.d.ts +66 -0
  119. package/lib/structures/IMicroAgenticaSystemPrompt.js +3 -0
  120. package/lib/structures/IMicroAgenticaSystemPrompt.js.map +1 -0
  121. package/lib/transformers/AgenticaPromptTransformer.d.ts +19 -19
  122. package/lib/transformers/AgenticaPromptTransformer.js +27 -27
  123. package/lib/transformers/AgenticaPromptTransformer.js.map +1 -1
  124. package/package.json +7 -7
  125. package/src/Agentica.ts +34 -34
  126. package/src/MicroAgentica.ts +337 -0
  127. package/src/constants/AgenticaDefaultPrompt.ts +4 -2
  128. package/src/context/AgenticaCancelPrompt.ts +3 -3
  129. package/src/context/AgenticaContext.ts +12 -12
  130. package/src/context/AgenticaOperationCollection.ts +1 -1
  131. package/src/context/MicroAgenticaContext.ts +95 -0
  132. package/src/context/internal/AgenticaOperationComposer.ts +6 -3
  133. package/src/context/internal/isAgenticaContext.ts +13 -0
  134. package/src/events/AgenticaDescribeEvent.ts +4 -4
  135. package/src/events/AgenticaEvent.ts +6 -0
  136. package/src/events/AgenticaExecuteEvent.ts +5 -5
  137. package/src/events/AgenticaSelectEvent.ts +2 -2
  138. package/src/events/AgenticaTextEvent.ts +2 -2
  139. package/src/events/MicroAgenticaEvent.ts +41 -0
  140. package/src/factory/events.ts +8 -8
  141. package/src/factory/{prompts.ts → histories.ts} +18 -18
  142. package/src/factory/index.ts +1 -1
  143. package/src/histories/AgenticaCancelHistory.ts +13 -0
  144. package/src/histories/AgenticaDescribeHistory.ts +22 -0
  145. package/src/{prompts/AgenticaExecutePrompt.ts → histories/AgenticaExecuteHistory.ts} +7 -7
  146. package/src/histories/AgenticaHistory.ts +25 -0
  147. package/src/{prompts/AgenticaPromptBase.ts → histories/AgenticaHistoryBase.ts} +4 -4
  148. package/src/histories/AgenticaSelectHistory.ts +13 -0
  149. package/src/histories/AgenticaTextHistory.ts +10 -0
  150. package/src/histories/MicroAgenticaHistory.ts +18 -0
  151. package/src/index.ts +18 -15
  152. package/src/json/IAgenticaEventJson.ts +6 -5
  153. package/src/json/{IAgenticaPromptJson.ts → IAgenticaHistoryJson.ts} +13 -13
  154. package/src/json/IAgenticaOperationSelectionJson.ts +8 -1
  155. package/src/json/IMicroAgenticaEventJson.ts +21 -0
  156. package/src/json/IMicroAgenticaHistoryJson.ts +23 -0
  157. package/src/orchestrate/call.ts +83 -59
  158. package/src/orchestrate/cancel.ts +4 -4
  159. package/src/orchestrate/describe.ts +11 -7
  160. package/src/orchestrate/execute.ts +7 -7
  161. package/src/orchestrate/initialize.ts +6 -6
  162. package/src/orchestrate/internal/selectFunction.ts +3 -0
  163. package/src/orchestrate/select.ts +13 -13
  164. package/src/structures/IAgenticaConfig.ts +6 -5
  165. package/src/structures/IAgenticaController.ts +1 -1
  166. package/src/structures/IAgenticaExecutor.ts +12 -10
  167. package/src/structures/IAgenticaProps.ts +3 -3
  168. package/src/structures/IAgenticaSystemPrompt.ts +13 -13
  169. package/src/structures/IAgenticaVendor.ts +1 -1
  170. package/src/structures/IMicroAgenticaConfig.ts +82 -0
  171. package/src/structures/IMicroAgenticaExecutor.ts +63 -0
  172. package/src/structures/IMicroAgenticaProps.ts +70 -0
  173. package/src/structures/IMicroAgenticaSystemPrompt.ts +71 -0
  174. package/src/transformers/AgenticaPromptTransformer.ts +46 -46
  175. package/lib/factory/prompts.d.ts +0 -33
  176. package/lib/factory/prompts.js.map +0 -1
  177. package/lib/json/IAgenticaPromptJson.js.map +0 -1
  178. package/lib/prompts/AgenticaCancelPrompt.d.ts +0 -8
  179. package/lib/prompts/AgenticaCancelPrompt.js.map +0 -1
  180. package/lib/prompts/AgenticaDescribePrompt.d.ts +0 -16
  181. package/lib/prompts/AgenticaDescribePrompt.js.map +0 -1
  182. package/lib/prompts/AgenticaExecutePrompt.js.map +0 -1
  183. package/lib/prompts/AgenticaPrompt.d.ts +0 -17
  184. package/lib/prompts/AgenticaPrompt.js.map +0 -1
  185. package/lib/prompts/AgenticaPromptBase.js.map +0 -1
  186. package/lib/prompts/AgenticaSelectPrompt.d.ts +0 -8
  187. package/lib/prompts/AgenticaSelectPrompt.js +0 -3
  188. package/lib/prompts/AgenticaSelectPrompt.js.map +0 -1
  189. package/lib/prompts/AgenticaTextPrompt.d.ts +0 -6
  190. package/lib/prompts/AgenticaTextPrompt.js.map +0 -1
  191. package/src/prompts/AgenticaCancelPrompt.ts +0 -13
  192. package/src/prompts/AgenticaDescribePrompt.ts +0 -22
  193. package/src/prompts/AgenticaPrompt.ts +0 -25
  194. package/src/prompts/AgenticaSelectPrompt.ts +0 -13
  195. package/src/prompts/AgenticaTextPrompt.ts +0 -10
@@ -1,5 +1,5 @@
1
+ import type { AgenticaTextHistory } from "../histories/AgenticaTextHistory";
1
2
  import type { IAgenticaEventJson } from "../json/IAgenticaEventJson";
2
- import type { AgenticaTextPrompt } from "../prompts/AgenticaTextPrompt";
3
3
 
4
4
  import type { AgenticaEventBase } from "./AgenticaEventBase";
5
5
 
@@ -10,5 +10,5 @@ export interface AgenticaTextEvent<
10
10
  stream: ReadableStream<string>;
11
11
  join: () => Promise<string>;
12
12
  toJSON: () => IAgenticaEventJson.IText;
13
- toPrompt: () => AgenticaTextPrompt;
13
+ toHistory: () => AgenticaTextHistory;
14
14
  }
@@ -0,0 +1,41 @@
1
+ import type { ILlmSchema } from "@samchon/openapi";
2
+
3
+ import type { AgenticaCallEvent } from "./AgenticaCallEvent";
4
+ import type { AgenticaDescribeEvent } from "./AgenticaDescribeEvent";
5
+ import type { AgenticaExecuteEvent } from "./AgenticaExecuteEvent";
6
+ import type { AgenticaRequestEvent } from "./AgenticaRequestEvent";
7
+ import type { AgenticaResponseEvent } from "./AgenticaResponseEvent";
8
+ import type { AgenticaTextEvent } from "./AgenticaTextEvent";
9
+ import type { AgenticaValidateEvent } from "./AgenticaValidateEvent";
10
+
11
+ /**
12
+ * Micro Agentica agent event.
13
+ *
14
+ * `MicroAgenticaEvent` is an union type of all possible events that
15
+ * can be emitted by the AI chatbot of the {@link MicroAgentica} class.
16
+ *
17
+ * You can discriminate the subtype by checking the {@link type} property.
18
+ *
19
+ * @author Samchon
20
+ */
21
+ export type MicroAgenticaEvent<Model extends ILlmSchema.Model> =
22
+ | AgenticaCallEvent<Model>
23
+ | AgenticaDescribeEvent<Model>
24
+ | AgenticaExecuteEvent<Model>
25
+ | AgenticaRequestEvent
26
+ | AgenticaResponseEvent
27
+ | AgenticaTextEvent
28
+ | AgenticaValidateEvent<Model>;
29
+ export namespace MicroAgenticaEvent {
30
+ export type Type = MicroAgenticaEvent<any>["type"];
31
+ export interface Mapper<Model extends ILlmSchema.Model> {
32
+ call: AgenticaCallEvent<Model>;
33
+ describe: AgenticaDescribeEvent<Model>;
34
+ execute: AgenticaExecuteEvent<Model>;
35
+ request: AgenticaRequestEvent;
36
+ response: AgenticaResponseEvent;
37
+ text: AgenticaTextEvent;
38
+ validate: AgenticaValidateEvent<Model>;
39
+ }
40
+ export type Source = "call" | "describe";
41
+ }
@@ -16,10 +16,10 @@ import type { AgenticaResponseEvent } from "../events/AgenticaResponseEvent";
16
16
  import type { AgenticaSelectEvent } from "../events/AgenticaSelectEvent";
17
17
  import type { AgenticaTextEvent } from "../events/AgenticaTextEvent";
18
18
  import type { AgenticaValidateEvent } from "../events/AgenticaValidateEvent";
19
+ import type { AgenticaExecuteHistory } from "../histories/AgenticaExecuteHistory";
19
20
  import type { IAgenticaEventJson } from "../json/IAgenticaEventJson";
20
- import type { AgenticaExecutePrompt } from "../prompts/AgenticaExecutePrompt";
21
21
 
22
- import { createExecutePrompt, createSelectPrompt } from "./prompts";
22
+ import { createExecuteHistory, createSelectHistory } from "./histories";
23
23
 
24
24
  /* -----------------------------------------------------------
25
25
  FUNCTION SELECTS
@@ -44,7 +44,7 @@ export function createSelectEvent<Model extends ILlmSchema.Model>(props: {
44
44
  type: "select",
45
45
  selection: props.selection.toJSON(),
46
46
  }),
47
- toPrompt: () => createSelectPrompt({
47
+ toHistory: () => createSelectHistory({
48
48
  id: v4(),
49
49
  selections: [props.selection],
50
50
  }),
@@ -126,8 +126,8 @@ export function createExecuteEvent<Model extends ILlmSchema.Model>(props: {
126
126
  arguments: props.arguments,
127
127
  value: props.value,
128
128
  }),
129
- toPrompt: () =>
130
- createExecutePrompt(props) as AgenticaExecutePrompt.Class<Model>,
129
+ toHistory: () =>
130
+ createExecuteHistory(props) as AgenticaExecuteHistory.Class<Model>,
131
131
  };
132
132
  }
133
133
 
@@ -152,7 +152,7 @@ export function createTextEvent<Role extends "user" | "assistant">(props: {
152
152
  done: props.done(),
153
153
  text: props.get(),
154
154
  }),
155
- toPrompt: () => ({
155
+ toHistory: () => ({
156
156
  type: "text",
157
157
  role: props.role,
158
158
  text: props.get(),
@@ -166,7 +166,7 @@ export function createTextEvent<Role extends "user" | "assistant">(props: {
166
166
  }
167
167
 
168
168
  export function createDescribeEvent<Model extends ILlmSchema.Model>(props: {
169
- executes: AgenticaExecutePrompt<Model>[];
169
+ executes: AgenticaExecuteHistory<Model>[];
170
170
  stream: ReadableStream<string>;
171
171
  done: () => boolean;
172
172
  get: () => string;
@@ -183,7 +183,7 @@ export function createDescribeEvent<Model extends ILlmSchema.Model>(props: {
183
183
  done: props.done(),
184
184
  text: props.get(),
185
185
  }),
186
- toPrompt: () => ({
186
+ toHistory: () => ({
187
187
  type: "describe",
188
188
  executes: props.executes,
189
189
  text: props.get(),
@@ -4,14 +4,14 @@ import type OpenAI from "openai";
4
4
  import type { AgenticaCancelPrompt } from "../context/AgenticaCancelPrompt";
5
5
  import type { AgenticaOperation } from "../context/AgenticaOperation";
6
6
  import type { AgenticaOperationSelection } from "../context/AgenticaOperationSelection";
7
- import type { IAgenticaPromptJson } from "../json/IAgenticaPromptJson";
8
- import type { AgenticaDescribePrompt } from "../prompts/AgenticaDescribePrompt";
9
- import type { AgenticaExecutePrompt } from "../prompts/AgenticaExecutePrompt";
10
- import type { AgenticaPrompt } from "../prompts/AgenticaPrompt";
11
- import type { AgenticaSelectPrompt } from "../prompts/AgenticaSelectPrompt";
12
- import type { AgenticaTextPrompt } from "../prompts/AgenticaTextPrompt";
7
+ import type { AgenticaDescribeHistory } from "../histories/AgenticaDescribeHistory";
8
+ import type { AgenticaExecuteHistory } from "../histories/AgenticaExecuteHistory";
9
+ import type { AgenticaHistory } from "../histories/AgenticaHistory";
10
+ import type { AgenticaSelectHistory } from "../histories/AgenticaSelectHistory";
11
+ import type { AgenticaTextHistory } from "../histories/AgenticaTextHistory";
12
+ import type { IAgenticaHistoryJson } from "../json/IAgenticaHistoryJson";
13
13
 
14
- export function decodePrompt<Model extends ILlmSchema.Model>(history: AgenticaPrompt<Model>): OpenAI.ChatCompletionMessageParam[] {
14
+ export function decodeHistory<Model extends ILlmSchema.Model>(history: AgenticaHistory<Model>): OpenAI.ChatCompletionMessageParam[] {
15
15
  // NO NEED TO DECODE DESCRIBE
16
16
  if (history.type === "describe") {
17
17
  return [];
@@ -98,11 +98,11 @@ export function decodePrompt<Model extends ILlmSchema.Model>(history: AgenticaPr
98
98
  /* -----------------------------------------------------------
99
99
  TEXT PROMPTS
100
100
  ----------------------------------------------------------- */
101
- export function createTextPrompt<Role extends "assistant" | "user" = "assistant" | "user">(props: {
101
+ export function createTextHistory<Role extends "assistant" | "user" = "assistant" | "user">(props: {
102
102
  role: Role;
103
103
  text: string;
104
- }): AgenticaTextPrompt<Role> {
105
- const prompt: IAgenticaPromptJson.IText<Role> = {
104
+ }): AgenticaTextHistory<Role> {
105
+ const prompt: IAgenticaHistoryJson.IText<Role> = {
106
106
  type: "text",
107
107
  role: props.role,
108
108
  text: props.text,
@@ -113,10 +113,10 @@ export function createTextPrompt<Role extends "assistant" | "user" = "assistant"
113
113
  };
114
114
  }
115
115
 
116
- export function createDescribePrompt<Model extends ILlmSchema.Model>(props: {
117
- executes: AgenticaExecutePrompt<Model>[];
116
+ export function createDescribeHistory<Model extends ILlmSchema.Model>(props: {
117
+ executes: AgenticaExecuteHistory<Model>[];
118
118
  text: string;
119
- }): AgenticaDescribePrompt<Model> {
119
+ }): AgenticaDescribeHistory<Model> {
120
120
  return {
121
121
  type: "describe",
122
122
  text: props.text,
@@ -132,10 +132,10 @@ export function createDescribePrompt<Model extends ILlmSchema.Model>(props: {
132
132
  /* -----------------------------------------------------------
133
133
  FUNCTION CALLING PROMPTS
134
134
  ----------------------------------------------------------- */
135
- export function createSelectPrompt<Model extends ILlmSchema.Model>(props: {
135
+ export function createSelectHistory<Model extends ILlmSchema.Model>(props: {
136
136
  id: string;
137
137
  selections: AgenticaOperationSelection<Model>[];
138
- }): AgenticaSelectPrompt<Model> {
138
+ }): AgenticaSelectHistory<Model> {
139
139
  return {
140
140
  type: "select",
141
141
  id: props.id,
@@ -148,7 +148,7 @@ export function createSelectPrompt<Model extends ILlmSchema.Model>(props: {
148
148
  };
149
149
  }
150
150
 
151
- export function createCancelPrompt<Model extends ILlmSchema.Model>(props: {
151
+ export function createCancelHistory<Model extends ILlmSchema.Model>(props: {
152
152
  id: string;
153
153
  selections: AgenticaOperationSelection<Model>[];
154
154
  }): AgenticaCancelPrompt<Model> {
@@ -164,14 +164,14 @@ export function createCancelPrompt<Model extends ILlmSchema.Model>(props: {
164
164
  };
165
165
  }
166
166
 
167
- export function createExecutePrompt<
167
+ export function createExecuteHistory<
168
168
  Model extends ILlmSchema.Model,
169
169
  >(props: {
170
170
  id: string;
171
171
  operation: AgenticaOperation<Model>;
172
172
  arguments: Record<string, any>;
173
173
  value: unknown;
174
- }): AgenticaExecutePrompt<Model> {
174
+ }): AgenticaExecuteHistory<Model> {
175
175
  return {
176
176
  type: "execute",
177
177
  protocol: props.operation.protocol as "class",
@@ -1,3 +1,3 @@
1
1
  export * from "./events";
2
+ export * from "./histories";
2
3
  export * from "./operations";
3
- export * from "./prompts";
@@ -0,0 +1,13 @@
1
+ import type { ILlmSchema } from "@samchon/openapi";
2
+
3
+ import type { AgenticaOperationSelection } from "../context/AgenticaOperationSelection";
4
+ import type { IAgenticaHistoryJson } from "../json/IAgenticaHistoryJson";
5
+
6
+ import type { AgenticaHistoryBase } from "./AgenticaHistoryBase";
7
+
8
+ export interface AgenticaCancelHistory<
9
+ Model extends ILlmSchema.Model,
10
+ > extends AgenticaHistoryBase<"cancel", IAgenticaHistoryJson.ICancel> {
11
+ id: string;
12
+ selections: AgenticaOperationSelection<Model>[];
13
+ }
@@ -0,0 +1,22 @@
1
+ import type { ILlmSchema } from "@samchon/openapi";
2
+
3
+ import type { IAgenticaHistoryJson } from "../json/IAgenticaHistoryJson";
4
+
5
+ import type { AgenticaExecuteHistory } from "./AgenticaExecuteHistory";
6
+ import type { AgenticaHistoryBase } from "./AgenticaHistoryBase";
7
+
8
+ export interface AgenticaDescribeHistory<
9
+ Model extends ILlmSchema.Model,
10
+ > extends AgenticaHistoryBase<"describe", IAgenticaHistoryJson.IDescribe> {
11
+ /**
12
+ * Executions of the LLM function calling.
13
+ *
14
+ * This prompt describes the return value of them.
15
+ */
16
+ executes: AgenticaExecuteHistory<Model>[];
17
+
18
+ /**
19
+ * Description text.
20
+ */
21
+ text: string;
22
+ }
@@ -1,19 +1,19 @@
1
1
  import type { IHttpResponse, ILlmSchema } from "@samchon/openapi";
2
2
 
3
3
  import type { AgenticaOperation } from "../context/AgenticaOperation";
4
- import type { IAgenticaPromptJson } from "../json/IAgenticaPromptJson";
4
+ import type { IAgenticaHistoryJson } from "../json/IAgenticaHistoryJson";
5
5
 
6
- import type { AgenticaPromptBase } from "./AgenticaPromptBase";
6
+ import type { AgenticaHistoryBase } from "./AgenticaHistoryBase";
7
7
 
8
8
  /**
9
9
  * Execute prompt.
10
10
  *
11
11
  * @author Samchon
12
12
  */
13
- export type AgenticaExecutePrompt<Model extends ILlmSchema.Model> =
14
- | AgenticaExecutePrompt.Class<Model>
15
- | AgenticaExecutePrompt.Http<Model>;
16
- export namespace AgenticaExecutePrompt {
13
+ export type AgenticaExecuteHistory<Model extends ILlmSchema.Model> =
14
+ | AgenticaExecuteHistory.Class<Model>
15
+ | AgenticaExecuteHistory.Http<Model>;
16
+ export namespace AgenticaExecuteHistory {
17
17
  /**
18
18
  * Class protocol case.
19
19
  */
@@ -30,7 +30,7 @@ export namespace AgenticaExecutePrompt {
30
30
  Protocol extends "http" | "class",
31
31
  Operation extends AgenticaOperation<any>,
32
32
  Value,
33
- > extends AgenticaPromptBase<"execute", IAgenticaPromptJson.IExecute> {
33
+ > extends AgenticaHistoryBase<"execute", IAgenticaHistoryJson.IExecute> {
34
34
  /**
35
35
  * ID of the LLM tool call result.
36
36
  */
@@ -0,0 +1,25 @@
1
+ import type { ILlmSchema } from "@samchon/openapi";
2
+
3
+ import type { AgenticaCancelPrompt } from "../context/AgenticaCancelPrompt";
4
+
5
+ import type { AgenticaDescribeHistory } from "./AgenticaDescribeHistory";
6
+ import type { AgenticaExecuteHistory } from "./AgenticaExecuteHistory";
7
+ import type { AgenticaSelectHistory } from "./AgenticaSelectHistory";
8
+ import type { AgenticaTextHistory } from "./AgenticaTextHistory";
9
+
10
+ export type AgenticaHistory<Model extends ILlmSchema.Model> =
11
+ | AgenticaCancelPrompt<Model>
12
+ | AgenticaDescribeHistory<Model>
13
+ | AgenticaExecuteHistory<Model>
14
+ | AgenticaSelectHistory<Model>
15
+ | AgenticaTextHistory;
16
+ export namespace AgenticaHistory {
17
+ export type Type = AgenticaHistory<any>["type"];
18
+ export interface Mapper<Model extends ILlmSchema.Model> {
19
+ cancel: AgenticaCancelPrompt<Model>;
20
+ describe: AgenticaDescribeHistory<Model>;
21
+ execute: AgenticaExecuteHistory<Model>;
22
+ select: AgenticaSelectHistory<Model>;
23
+ text: AgenticaTextHistory;
24
+ }
25
+ }
@@ -1,16 +1,16 @@
1
1
  /**
2
- * Base type for all prompts in Agentica.
2
+ * Base type for all histories in Agentica.
3
3
  *
4
- * `AgenticaPromptBase` is a base type for every prompt types
4
+ * `AgenticaHistoryBase` is a base type for every history types
5
5
  * in Agentica. It is generated by {@link Agentica.conversate} function,
6
6
  * and used for restoring the previous conversation history when
7
7
  * constructing the {@link Agentica} instance.
8
8
  *
9
9
  * @template Type Discriminator type
10
- * @template Json Primitive type of the prompt
10
+ * @template Json Primitive type of the history
11
11
  * @author Samchon
12
12
  */
13
- export interface AgenticaPromptBase<
13
+ export interface AgenticaHistoryBase<
14
14
  Type extends string,
15
15
  Json extends { type: Type },
16
16
  > {
@@ -0,0 +1,13 @@
1
+ import type { ILlmSchema } from "@samchon/openapi";
2
+
3
+ import type { AgenticaOperationSelection } from "../context/AgenticaOperationSelection";
4
+ import type { IAgenticaHistoryJson } from "../json/IAgenticaHistoryJson";
5
+
6
+ import type { AgenticaHistoryBase } from "./AgenticaHistoryBase";
7
+
8
+ export interface AgenticaSelectHistory<
9
+ Model extends ILlmSchema.Model,
10
+ > extends AgenticaHistoryBase<"select", IAgenticaHistoryJson.ISelect> {
11
+ id: string;
12
+ selections: AgenticaOperationSelection<Model>[];
13
+ }
@@ -0,0 +1,10 @@
1
+ import type { IAgenticaHistoryJson } from "../json/IAgenticaHistoryJson";
2
+
3
+ import type { AgenticaHistoryBase } from "./AgenticaHistoryBase";
4
+
5
+ export interface AgenticaTextHistory<
6
+ Role extends "assistant" | "user" = "assistant" | "user",
7
+ > extends AgenticaHistoryBase<"text", IAgenticaHistoryJson.IText> {
8
+ role: Role;
9
+ text: string;
10
+ }
@@ -0,0 +1,18 @@
1
+ import type { ILlmSchema } from "@samchon/openapi";
2
+
3
+ import type { AgenticaDescribeHistory } from "./AgenticaDescribeHistory";
4
+ import type { AgenticaExecuteHistory } from "./AgenticaExecuteHistory";
5
+ import type { AgenticaTextHistory } from "./AgenticaTextHistory";
6
+
7
+ export type MicroAgenticaHistory<Model extends ILlmSchema.Model> =
8
+ | AgenticaDescribeHistory<Model>
9
+ | AgenticaExecuteHistory<Model>
10
+ | AgenticaTextHistory;
11
+ export namespace MicroAgenticaHistory {
12
+ export type Type = MicroAgenticaHistory<any>["type"];
13
+ export interface Mapper<Model extends ILlmSchema.Model> {
14
+ describe: AgenticaDescribeHistory<Model>;
15
+ execute: AgenticaExecuteHistory<Model>;
16
+ text: AgenticaTextHistory;
17
+ }
18
+ }
package/src/index.ts CHANGED
@@ -1,13 +1,14 @@
1
1
  export * from "./Agentica";
2
-
3
2
  export * from "./context/AgenticaContext";
3
+
4
4
  export * from "./context/AgenticaOperation";
5
+
5
6
  export * from "./context/AgenticaOperationCollection";
6
7
  export * from "./context/AgenticaOperationSelection";
7
8
  export * from "./context/AgenticaTokenUsage";
8
-
9
9
  export * from "./events/AgenticaCallEvent";
10
10
  export * from "./events/AgenticaCancelEvent";
11
+
11
12
  export * from "./events/AgenticaDescribeEvent";
12
13
  export * from "./events/AgenticaEvent";
13
14
  export * from "./events/AgenticaEventSource";
@@ -17,34 +18,36 @@ export * from "./events/AgenticaResponseEvent";
17
18
  export * from "./events/AgenticaSelectEvent";
18
19
  export * from "./events/AgenticaTextEvent";
19
20
  export * from "./events/AgenticaValidateEvent";
20
-
21
+ export * from "./events/MicroAgenticaEvent";
21
22
  export * as factory from "./factory";
22
-
23
23
  export * from "./functional/assertHttpLlmApplication";
24
+
24
25
  export * from "./functional/validateHttpLlmApplication";
26
+ export * from "./histories/AgenticaCancelHistory";
27
+ export * from "./histories/AgenticaDescribeHistory";
28
+ export * from "./histories/AgenticaExecuteHistory";
29
+ export * from "./histories/AgenticaHistory";
30
+ export * from "./histories/AgenticaSelectHistory";
31
+ export * from "./histories/AgenticaTextHistory";
32
+
33
+ export * from "./histories/MicroAgenticaHistory";
34
+
25
35
  export * from "./json/IAgenticaEventJson";
36
+ export * from "./json/IAgenticaHistoryJson";
26
37
  export * from "./json/IAgenticaOperationJson";
27
38
  export * from "./json/IAgenticaOperationSelectionJson";
28
- export * from "./json/IAgenticaPromptJson";
29
-
30
39
  export * from "./json/IAgenticaTokenUsageJson";
31
-
40
+ export * from "./MicroAgentica";
32
41
  export * as orchestrate from "./orchestrate";
33
42
 
34
- export * from "./prompts/AgenticaCancelPrompt";
35
- export * from "./prompts/AgenticaDescribePrompt";
36
- export * from "./prompts/AgenticaExecutePrompt";
37
- export * from "./prompts/AgenticaPrompt";
38
- export * from "./prompts/AgenticaSelectPrompt";
39
-
40
- export * from "./prompts/AgenticaTextPrompt";
41
43
  export * from "./structures/IAgenticaConfig";
42
44
  export * from "./structures/IAgenticaController";
43
45
  export * from "./structures/IAgenticaExecutor";
44
46
  export * from "./structures/IAgenticaProps";
45
47
  export * from "./structures/IAgenticaSystemPrompt";
46
-
47
48
  export * from "./structures/IAgenticaVendor";
49
+ export * from "./structures/IMicroAgenticaConfig";
50
+ export * from "./structures/IMicroAgenticaProps";
48
51
 
49
52
  /**
50
53
  * @internal
@@ -2,16 +2,17 @@ import type OpenAI from "openai";
2
2
 
3
3
  import type { AgenticaEventSource } from "../events/AgenticaEventSource";
4
4
 
5
+ import type { IAgenticaHistoryJson } from "./IAgenticaHistoryJson";
5
6
  import type { IAgenticaOperationJson } from "./IAgenticaOperationJson";
6
7
  import type { IAgenticaOperationSelectionJson } from "./IAgenticaOperationSelectionJson";
7
- import type { IAgenticaPromptJson } from "./IAgenticaPromptJson";
8
8
 
9
9
  /**
10
- * Nestia A.I. chatbot event.
10
+ * Agentic AI agent event.
11
11
  *
12
12
  * `IAgenticaEventJson` is an union type of all possible events that can
13
- * be emitted by the A.I. chatbot of the {@link Agentica} class. You
14
- * can discriminate the subtype by checking the {@link type} property.
13
+ * be emitted by the A.I. chatbot of the {@link Agentica} class.
14
+ *
15
+ * You can discriminate the subtype by checking the {@link type} property.
15
16
  *
16
17
  * @author Samchon
17
18
  */
@@ -119,7 +120,7 @@ export namespace IAgenticaEventJson {
119
120
  *
120
121
  * This prompt describes the return value of them.
121
122
  */
122
- executes: IAgenticaPromptJson.IExecute[];
123
+ executes: IAgenticaHistoryJson.IExecute[];
123
124
 
124
125
  /**
125
126
  * Description text.
@@ -2,14 +2,14 @@ import type { IAgenticaOperationJson } from "./IAgenticaOperationJson";
2
2
  import type { IAgenticaOperationSelectionJson } from "./IAgenticaOperationSelectionJson";
3
3
 
4
4
  /**
5
- * Nestia A.I. chatbot prompt.
5
+ * Agentic AI agent prompt.
6
6
  *
7
- * `IWrtnChatPrompt` is an union type of all possible prompts that can
8
- * be generated by the A.I. chatbot of the {@link Agentica} class.
7
+ * `IAgenticaHistoryJson` is an union type of all possible prompts that
8
+ * can be generated by the AI chatbot of the {@link Agentica} class.
9
9
  *
10
- * In other words, `IWrtnChatPrompt` is a type of chat history that
11
- * is occurred during the conversation between the user and the A.I. chatbot
12
- * in the {@link Agentica} class.
10
+ * In other words, `IAgenticaHistoryJson` is a type of chat history that
11
+ * is occurred during the conversation between the user and the AI
12
+ * chatbot in the {@link Agentica} class.
13
13
  *
14
14
  * If you want to continue the previous A.I. chatbot session, you can
15
15
  * accomplish it by assigning the {@link IAgenticaProps.histories}
@@ -17,13 +17,13 @@ import type { IAgenticaOperationSelectionJson } from "./IAgenticaOperationSelect
17
17
  *
18
18
  * @author Samchon
19
19
  */
20
- export type IAgenticaPromptJson =
21
- | IAgenticaPromptJson.IText
22
- | IAgenticaPromptJson.ISelect
23
- | IAgenticaPromptJson.ICancel
24
- | IAgenticaPromptJson.IExecute
25
- | IAgenticaPromptJson.IDescribe;
26
- export namespace IAgenticaPromptJson {
20
+ export type IAgenticaHistoryJson =
21
+ | IAgenticaHistoryJson.IText
22
+ | IAgenticaHistoryJson.ISelect
23
+ | IAgenticaHistoryJson.ICancel
24
+ | IAgenticaHistoryJson.IExecute
25
+ | IAgenticaHistoryJson.IDescribe;
26
+ export namespace IAgenticaHistoryJson {
27
27
  /**
28
28
  * Select prompt.
29
29
  *
@@ -1,7 +1,7 @@
1
1
  import type { IAgenticaOperationJson } from "./IAgenticaOperationJson";
2
2
 
3
3
  /**
4
- * Nestia agent operation selection.
4
+ * Agentica agent operation selection.
5
5
  *
6
6
  * `IAgenticaOperationSelection` is a type represents an operation
7
7
  * which has been selected by the A.I. chatbot of {@link Agentica}
@@ -14,6 +14,13 @@ import type { IAgenticaOperationJson } from "./IAgenticaOperationJson";
14
14
  * @author Samchon
15
15
  */
16
16
  export interface IAgenticaOperationSelectionJson {
17
+ /**
18
+ * The reason of the selection.
19
+ */
17
20
  reason: string;
21
+
22
+ /**
23
+ * Selected operation.
24
+ */
18
25
  operation: IAgenticaOperationJson;
19
26
  }
@@ -0,0 +1,21 @@
1
+ import type { IAgenticaEventJson } from "./IAgenticaEventJson";
2
+
3
+ /**
4
+ * Micro Agentic AI agent event.
5
+ *
6
+ * `IMicroAgenticaEventJson` is an union type of all possible events
7
+ * that can be emitted by the A.I. chatbot of the {@link MicroAgentica}
8
+ * class.
9
+ *
10
+ * You can discriminate the subtype by checking the {@link type} property.
11
+ *
12
+ * @author Samchon
13
+ */
14
+ export type IMicroAgenticaEventJson =
15
+ | IAgenticaEventJson.ICall
16
+ | IAgenticaEventJson.IDescribe
17
+ | IAgenticaEventJson.IExecute
18
+ | IAgenticaEventJson.IInitialize
19
+ | IAgenticaEventJson.IRequest
20
+ | IAgenticaEventJson.IText
21
+ | IAgenticaEventJson.IValidate;
@@ -0,0 +1,23 @@
1
+ import type { IAgenticaHistoryJson } from "./IAgenticaHistoryJson";
2
+
3
+ /**
4
+ * Micro Agentic AI agent prompt.
5
+ *
6
+ * `IMicroAgenticaPromptJson` is an union type of all possible prompts
7
+ * that can be generated by the AI chatbot of the {@link MicroAgentica}
8
+ * class.
9
+ *
10
+ * In other words, `IMicroAgenticaPromptJson` is a type of chat history
11
+ * that is occurred during the conversation between the user and the
12
+ * AI chatbot in the {@link MicroAgentica} class.
13
+ *
14
+ * If you want to continue the previous A.I. chatbot session, you can
15
+ * accomplish it by assigning the {@link IMicroAgenticaProps.histories}
16
+ * property when creating a new {@link MicroAgentica} instance.
17
+ *
18
+ * @author Samchon
19
+ */
20
+ export type IMicroAgenticaHistoryJson =
21
+ | IAgenticaHistoryJson.IText
22
+ | IAgenticaHistoryJson.IExecute
23
+ | IAgenticaHistoryJson.IDescribe;