@agentica/core 0.21.0 → 0.23.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 (91) hide show
  1. package/README.md +10 -11
  2. package/lib/Agentica.d.ts +2 -1
  3. package/lib/Agentica.js +15 -13
  4. package/lib/Agentica.js.map +1 -1
  5. package/lib/MicroAgentica.d.ts +12 -1
  6. package/lib/MicroAgentica.js +23 -10
  7. package/lib/MicroAgentica.js.map +1 -1
  8. package/lib/context/AgenticaContext.d.ts +4 -4
  9. package/lib/context/MicroAgenticaContext.d.ts +2 -2
  10. package/lib/events/AgenticaEvent.d.ts +3 -1
  11. package/lib/events/AgenticaTextEvent.d.ts +2 -2
  12. package/lib/events/AgenticaUserInputEvent.d.ts +10 -0
  13. package/lib/events/AgenticaUserInputEvent.js +3 -0
  14. package/lib/events/AgenticaUserInputEvent.js.map +1 -0
  15. package/lib/events/MicroAgenticaEvent.d.ts +3 -1
  16. package/lib/factory/events.d.ts +7 -3
  17. package/lib/factory/events.js +29 -4
  18. package/lib/factory/events.js.map +1 -1
  19. package/lib/factory/histories.d.ts +6 -3
  20. package/lib/factory/histories.js +59 -32
  21. package/lib/factory/histories.js.map +1 -1
  22. package/lib/functional/assertHttpController.d.ts +75 -0
  23. package/lib/functional/assertHttpController.js +9622 -0
  24. package/lib/functional/assertHttpController.js.map +1 -0
  25. package/lib/functional/assertHttpLlmApplication.d.ts +1 -0
  26. package/lib/functional/assertHttpLlmApplication.js +1 -0
  27. package/lib/functional/assertHttpLlmApplication.js.map +1 -1
  28. package/lib/functional/assertMcpController.d.ts +1 -1
  29. package/lib/functional/assertMcpController.js +1 -1
  30. package/lib/functional/assertMcpController.js.map +1 -1
  31. package/lib/functional/validateHttpController.d.ts +75 -0
  32. package/lib/functional/validateHttpController.js +7952 -0
  33. package/lib/functional/validateHttpController.js.map +1 -0
  34. package/lib/functional/validateHttpLlmApplication.d.ts +1 -0
  35. package/lib/functional/validateHttpLlmApplication.js +1 -0
  36. package/lib/functional/validateHttpLlmApplication.js.map +1 -1
  37. package/lib/functional/validateMcpController.d.ts +24 -0
  38. package/lib/functional/validateMcpController.js +3034 -0
  39. package/lib/functional/validateMcpController.js.map +1 -0
  40. package/lib/histories/AgenticaHistory.d.ts +3 -1
  41. package/lib/histories/AgenticaTextHistory.d.ts +2 -2
  42. package/lib/histories/AgenticaUserInputHistory.d.ts +80 -0
  43. package/lib/histories/AgenticaUserInputHistory.js +3 -0
  44. package/lib/histories/AgenticaUserInputHistory.js.map +1 -0
  45. package/lib/histories/MicroAgenticaHistory.d.ts +2 -1
  46. package/lib/index.d.ts +3 -0
  47. package/lib/index.js +3 -0
  48. package/lib/index.js.map +1 -1
  49. package/lib/index.mjs +25984 -5962
  50. package/lib/index.mjs.map +1 -1
  51. package/lib/json/IAgenticaEventJson.d.ts +8 -1
  52. package/lib/json/IAgenticaHistoryJson.d.ts +15 -3
  53. package/lib/orchestrate/call.js +3 -7
  54. package/lib/orchestrate/call.js.map +1 -1
  55. package/lib/orchestrate/cancel.js +1 -1
  56. package/lib/orchestrate/cancel.js.map +1 -1
  57. package/lib/orchestrate/initialize.js +2 -6
  58. package/lib/orchestrate/initialize.js.map +1 -1
  59. package/lib/orchestrate/select.js +2 -6
  60. package/lib/orchestrate/select.js.map +1 -1
  61. package/lib/transformers/AgenticaEventTransformer.js +0 -1
  62. package/lib/transformers/AgenticaEventTransformer.js.map +1 -1
  63. package/package.json +2 -2
  64. package/src/Agentica.ts +21 -18
  65. package/src/MicroAgentica.ts +30 -15
  66. package/src/context/AgenticaContext.ts +4 -4
  67. package/src/context/MicroAgenticaContext.ts +2 -2
  68. package/src/events/AgenticaEvent.ts +4 -1
  69. package/src/events/AgenticaTextEvent.ts +2 -4
  70. package/src/events/AgenticaUserInputEvent.ts +12 -0
  71. package/src/events/MicroAgenticaEvent.ts +4 -1
  72. package/src/factory/events.ts +26 -8
  73. package/src/factory/histories.ts +76 -43
  74. package/src/functional/assertHttpController.ts +112 -0
  75. package/src/functional/assertHttpLlmApplication.ts +1 -0
  76. package/src/functional/assertMcpController.ts +1 -2
  77. package/src/functional/validateHttpController.ts +118 -0
  78. package/src/functional/validateHttpLlmApplication.ts +1 -1
  79. package/src/functional/validateMcpController.ts +56 -0
  80. package/src/histories/AgenticaHistory.ts +4 -1
  81. package/src/histories/AgenticaTextHistory.ts +2 -4
  82. package/src/histories/AgenticaUserInputHistory.ts +88 -0
  83. package/src/histories/MicroAgenticaHistory.ts +3 -1
  84. package/src/index.ts +3 -0
  85. package/src/json/IAgenticaEventJson.ts +9 -1
  86. package/src/json/IAgenticaHistoryJson.ts +16 -4
  87. package/src/orchestrate/call.ts +5 -7
  88. package/src/orchestrate/cancel.ts +1 -1
  89. package/src/orchestrate/initialize.ts +2 -6
  90. package/src/orchestrate/select.ts +2 -7
  91. package/src/transformers/AgenticaEventTransformer.ts +0 -1
@@ -3,11 +3,13 @@ import type { ILlmSchema } from "@samchon/openapi";
3
3
  import type { AgenticaDescribeHistory } from "./AgenticaDescribeHistory";
4
4
  import type { AgenticaExecuteHistory } from "./AgenticaExecuteHistory";
5
5
  import type { AgenticaTextHistory } from "./AgenticaTextHistory";
6
+ import type { AgenticaUserInputHistory } from "./AgenticaUserInputHistory";
6
7
 
7
8
  export type MicroAgenticaHistory<Model extends ILlmSchema.Model> =
8
9
  | AgenticaDescribeHistory<Model>
9
10
  | AgenticaExecuteHistory<Model>
10
- | AgenticaTextHistory;
11
+ | AgenticaTextHistory
12
+ | AgenticaUserInputHistory;
11
13
  export namespace MicroAgenticaHistory {
12
14
  export type Type = MicroAgenticaHistory<any>["type"];
13
15
  export interface Mapper<Model extends ILlmSchema.Model> {
package/src/index.ts CHANGED
@@ -22,9 +22,12 @@ export * from "./events/MicroAgenticaEvent";
22
22
 
23
23
  export * as factory from "./factory";
24
24
 
25
+ export * from "./functional/assertHttpController";
25
26
  export * from "./functional/assertHttpLlmApplication";
26
27
  export * from "./functional/assertMcpController";
28
+ export * from "./functional/validateHttpController";
27
29
  export * from "./functional/validateHttpLlmApplication";
30
+ export * from "./functional/validateMcpController";
28
31
  // @TODO: implement validateMcpLlmApplication
29
32
 
30
33
  export * from "./histories/AgenticaCancelHistory";
@@ -1,6 +1,7 @@
1
1
  import type OpenAI from "openai";
2
2
 
3
3
  import type { AgenticaEventSource } from "../events/AgenticaEventSource";
4
+ import type { AgenticaUserInputHistory } from "../histories/AgenticaUserInputHistory";
4
5
 
5
6
  import type { IAgenticaHistoryJson } from "./IAgenticaHistoryJson";
6
7
  import type { IAgenticaOperationJson } from "./IAgenticaOperationJson";
@@ -39,6 +40,13 @@ export namespace IAgenticaEventJson {
39
40
  request: IRequest;
40
41
  }
41
42
 
43
+ /**
44
+ * Event of user input.
45
+ */
46
+ export interface IUserInput extends IBase<"user_input"> {
47
+ contents: Array<AgenticaUserInputHistory.Contents>;
48
+ }
49
+
42
50
  /**
43
51
  * Event of initializing the chatbot.
44
52
  */
@@ -140,7 +148,7 @@ export namespace IAgenticaEventJson {
140
148
  /**
141
149
  * Role of the orator.
142
150
  */
143
- role: "assistant" | "user";
151
+ role: "assistant";
144
152
 
145
153
  /**
146
154
  * Conversation text.
@@ -1,3 +1,5 @@
1
+ import type { AgenticaUserInputHistory } from "../histories/AgenticaUserInputHistory";
2
+
1
3
  import type { IAgenticaOperationJson } from "./IAgenticaOperationJson";
2
4
  import type { IAgenticaOperationSelectionJson } from "./IAgenticaOperationSelectionJson";
3
5
 
@@ -18,12 +20,24 @@ import type { IAgenticaOperationSelectionJson } from "./IAgenticaOperationSelect
18
20
  * @author Samchon
19
21
  */
20
22
  export type IAgenticaHistoryJson =
23
+ | IAgenticaHistoryJson.IUserInput
21
24
  | IAgenticaHistoryJson.IText
22
25
  | IAgenticaHistoryJson.ISelect
23
26
  | IAgenticaHistoryJson.ICancel
24
27
  | IAgenticaHistoryJson.IExecute
25
28
  | IAgenticaHistoryJson.IDescribe;
26
29
  export namespace IAgenticaHistoryJson {
30
+ /**
31
+ * User input prompt.
32
+ *
33
+ * User input prompt about the user's input.
34
+ */
35
+ export interface IUserInput extends IBase<"user_input"> {
36
+ /**
37
+ * User input.
38
+ */
39
+ contents: Array<AgenticaUserInputHistory.Contents>;
40
+ }
27
41
  /**
28
42
  * Select prompt.
29
43
  *
@@ -107,13 +121,11 @@ export namespace IAgenticaHistoryJson {
107
121
  /**
108
122
  * Text prompt.
109
123
  */
110
- export interface IText<
111
- Role extends "assistant" | "user" = "assistant" | "user",
112
- > extends IBase<"text"> {
124
+ export interface IText extends IBase<"text"> {
113
125
  /**
114
126
  * Role of the orator.
115
127
  */
116
- role: Role;
128
+ role: "assistant";
117
129
 
118
130
  /**
119
131
  * The text content.
@@ -54,7 +54,7 @@ export async function call<Model extends ILlmSchema.Model>(
54
54
  // USER INPUT
55
55
  {
56
56
  role: "user",
57
- content: ctx.prompt.text,
57
+ content: ctx.prompt.contents,
58
58
  },
59
59
  // SYSTEM PROMPT
60
60
  ...(ctx.config?.systemPrompt?.execute === null
@@ -181,13 +181,11 @@ export async function call<Model extends ILlmSchema.Model>(
181
181
  && choice.message.content.length !== 0
182
182
  ) {
183
183
  closures.push(async () => {
184
- const value: AgenticaTextHistory = createTextHistory({
185
- role: "assistant",
186
- text: choice.message.content!,
187
- });
184
+ const value: AgenticaTextHistory = createTextHistory(
185
+ { text: choice.message.content! },
186
+ );
188
187
  ctx.dispatch(
189
188
  createTextEvent({
190
- role: "assistant",
191
189
  get: () => value.text,
192
190
  done: () => true,
193
191
  stream: toAsyncGenerator(value.text),
@@ -473,7 +471,7 @@ async function correct<Model extends ILlmSchema.Model>(
473
471
  // USER INPUT
474
472
  {
475
473
  role: "user",
476
- content: ctx.prompt.text,
474
+ content: ctx.prompt.contents,
477
475
  },
478
476
  // TYPE CORRECTION
479
477
  ...(ctx.config?.systemPrompt?.execute === null
@@ -141,7 +141,7 @@ async function step<Model extends ILlmSchema.Model>(ctx: AgenticaContext<Model>,
141
141
  // USER INPUT
142
142
  {
143
143
  role: "user",
144
- content: ctx.prompt.text,
144
+ content: ctx.prompt.contents,
145
145
  },
146
146
  // SYSTEM PROMPT
147
147
  {
@@ -36,7 +36,7 @@ export async function initialize<Model extends ILlmSchema.Model>(ctx: AgenticaCo
36
36
  // USER INPUT
37
37
  {
38
38
  role: "user",
39
- content: ctx.prompt.text,
39
+ content: ctx.prompt.contents,
40
40
  },
41
41
  {
42
42
  // SYSTEM PROMPT
@@ -108,7 +108,6 @@ export async function initialize<Model extends ILlmSchema.Model>(ctx: AgenticaCo
108
108
 
109
109
  ctx.dispatch(
110
110
  createTextEvent({
111
- role: "assistant",
112
111
  stream: streamDefaultReaderToAsyncGenerator(mpsc.consumer.getReader()),
113
112
  done: () => mpsc.done(),
114
113
  get: () => textContext[choice.index]!.content,
@@ -145,10 +144,7 @@ export async function initialize<Model extends ILlmSchema.Model>(ctx: AgenticaCo
145
144
  && choice.message.content.length !== 0
146
145
  ) {
147
146
  prompts.push(
148
- createTextHistory({
149
- role: "assistant",
150
- text: choice.message.content,
151
- }),
147
+ createTextHistory({ text: choice.message.content }),
152
148
  );
153
149
  }
154
150
  }
@@ -13,7 +13,6 @@ import type { __IChatSelectFunctionsApplication } from "../context/internal/__IC
13
13
  import type { AgenticaEvent } from "../events/AgenticaEvent";
14
14
  import type { AgenticaHistory } from "../histories/AgenticaHistory";
15
15
  import type { AgenticaSelectHistory } from "../histories/AgenticaSelectHistory";
16
- import type { AgenticaTextHistory } from "../histories/AgenticaTextHistory";
17
16
 
18
17
  import { AgenticaConstant } from "../constants/AgenticaConstant";
19
18
  import { AgenticaDefaultPrompt } from "../constants/AgenticaDefaultPrompt";
@@ -145,7 +144,7 @@ async function step<Model extends ILlmSchema.Model>(ctx: AgenticaContext<Model>,
145
144
  // USER INPUT
146
145
  {
147
146
  role: "user",
148
- content: ctx.prompt.text,
147
+ content: ctx.prompt.contents,
149
148
  },
150
149
  // SYSTEM PROMPT
151
150
  {
@@ -260,15 +259,11 @@ async function step<Model extends ILlmSchema.Model>(ctx: AgenticaContext<Model>,
260
259
  && choice.message.content != null
261
260
  && choice.message.content.length !== 0
262
261
  ) {
263
- const text: AgenticaTextHistory = createTextHistory({
264
- role: "assistant",
265
- text: choice.message.content,
266
- });
262
+ const text = createTextHistory({ text: choice.message.content });
267
263
  prompts.push(text);
268
264
 
269
265
  ctx.dispatch(
270
266
  createTextEvent({
271
- role: "assistant",
272
267
  stream: toAsyncGenerator(text.text),
273
268
  join: async () => Promise.resolve(text.text),
274
269
  done: () => true,
@@ -175,7 +175,6 @@ function transformText(props: {
175
175
  event: IAgenticaEventJson.IText;
176
176
  }): AgenticaTextEvent {
177
177
  return createTextEvent({
178
- role: props.event.role,
179
178
  stream: toAsyncGenerator(props.event.text),
180
179
  done: () => true,
181
180
  get: () => props.event.text,