@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.
- package/README.md +10 -11
- package/lib/Agentica.d.ts +2 -1
- package/lib/Agentica.js +15 -13
- package/lib/Agentica.js.map +1 -1
- package/lib/MicroAgentica.d.ts +12 -1
- package/lib/MicroAgentica.js +23 -10
- package/lib/MicroAgentica.js.map +1 -1
- package/lib/context/AgenticaContext.d.ts +4 -4
- package/lib/context/MicroAgenticaContext.d.ts +2 -2
- package/lib/events/AgenticaEvent.d.ts +3 -1
- package/lib/events/AgenticaTextEvent.d.ts +2 -2
- package/lib/events/AgenticaUserInputEvent.d.ts +10 -0
- package/lib/events/AgenticaUserInputEvent.js +3 -0
- package/lib/events/AgenticaUserInputEvent.js.map +1 -0
- package/lib/events/MicroAgenticaEvent.d.ts +3 -1
- package/lib/factory/events.d.ts +7 -3
- package/lib/factory/events.js +29 -4
- package/lib/factory/events.js.map +1 -1
- package/lib/factory/histories.d.ts +6 -3
- package/lib/factory/histories.js +59 -32
- package/lib/factory/histories.js.map +1 -1
- package/lib/functional/assertHttpController.d.ts +75 -0
- package/lib/functional/assertHttpController.js +9622 -0
- package/lib/functional/assertHttpController.js.map +1 -0
- package/lib/functional/assertHttpLlmApplication.d.ts +1 -0
- package/lib/functional/assertHttpLlmApplication.js +1 -0
- package/lib/functional/assertHttpLlmApplication.js.map +1 -1
- package/lib/functional/assertMcpController.d.ts +1 -1
- package/lib/functional/assertMcpController.js +1 -1
- package/lib/functional/assertMcpController.js.map +1 -1
- package/lib/functional/validateHttpController.d.ts +75 -0
- package/lib/functional/validateHttpController.js +7952 -0
- package/lib/functional/validateHttpController.js.map +1 -0
- package/lib/functional/validateHttpLlmApplication.d.ts +1 -0
- package/lib/functional/validateHttpLlmApplication.js +1 -0
- package/lib/functional/validateHttpLlmApplication.js.map +1 -1
- package/lib/functional/validateMcpController.d.ts +24 -0
- package/lib/functional/validateMcpController.js +3034 -0
- package/lib/functional/validateMcpController.js.map +1 -0
- package/lib/histories/AgenticaHistory.d.ts +3 -1
- package/lib/histories/AgenticaTextHistory.d.ts +2 -2
- package/lib/histories/AgenticaUserInputHistory.d.ts +80 -0
- package/lib/histories/AgenticaUserInputHistory.js +3 -0
- package/lib/histories/AgenticaUserInputHistory.js.map +1 -0
- package/lib/histories/MicroAgenticaHistory.d.ts +2 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +25984 -5962
- package/lib/index.mjs.map +1 -1
- package/lib/json/IAgenticaEventJson.d.ts +8 -1
- package/lib/json/IAgenticaHistoryJson.d.ts +15 -3
- package/lib/orchestrate/call.js +3 -7
- package/lib/orchestrate/call.js.map +1 -1
- package/lib/orchestrate/cancel.js +1 -1
- package/lib/orchestrate/cancel.js.map +1 -1
- package/lib/orchestrate/initialize.js +2 -6
- package/lib/orchestrate/initialize.js.map +1 -1
- package/lib/orchestrate/select.js +2 -6
- package/lib/orchestrate/select.js.map +1 -1
- package/lib/transformers/AgenticaEventTransformer.js +0 -1
- package/lib/transformers/AgenticaEventTransformer.js.map +1 -1
- package/package.json +2 -2
- package/src/Agentica.ts +21 -18
- package/src/MicroAgentica.ts +30 -15
- package/src/context/AgenticaContext.ts +4 -4
- package/src/context/MicroAgenticaContext.ts +2 -2
- package/src/events/AgenticaEvent.ts +4 -1
- package/src/events/AgenticaTextEvent.ts +2 -4
- package/src/events/AgenticaUserInputEvent.ts +12 -0
- package/src/events/MicroAgenticaEvent.ts +4 -1
- package/src/factory/events.ts +26 -8
- package/src/factory/histories.ts +76 -43
- package/src/functional/assertHttpController.ts +112 -0
- package/src/functional/assertHttpLlmApplication.ts +1 -0
- package/src/functional/assertMcpController.ts +1 -2
- package/src/functional/validateHttpController.ts +118 -0
- package/src/functional/validateHttpLlmApplication.ts +1 -1
- package/src/functional/validateMcpController.ts +56 -0
- package/src/histories/AgenticaHistory.ts +4 -1
- package/src/histories/AgenticaTextHistory.ts +2 -4
- package/src/histories/AgenticaUserInputHistory.ts +88 -0
- package/src/histories/MicroAgenticaHistory.ts +3 -1
- package/src/index.ts +3 -0
- package/src/json/IAgenticaEventJson.ts +9 -1
- package/src/json/IAgenticaHistoryJson.ts +16 -4
- package/src/orchestrate/call.ts +5 -7
- package/src/orchestrate/cancel.ts +1 -1
- package/src/orchestrate/initialize.ts +2 -6
- package/src/orchestrate/select.ts +2 -7
- 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"
|
|
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:
|
|
128
|
+
role: "assistant";
|
|
117
129
|
|
|
118
130
|
/**
|
|
119
131
|
* The text content.
|
package/src/orchestrate/call.ts
CHANGED
|
@@ -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.
|
|
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
|
-
|
|
186
|
-
|
|
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.
|
|
474
|
+
content: ctx.prompt.contents,
|
|
477
475
|
},
|
|
478
476
|
// TYPE CORRECTION
|
|
479
477
|
...(ctx.config?.systemPrompt?.execute === null
|
|
@@ -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.
|
|
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.
|
|
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
|
|
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,
|