@agentica/core 0.44.0-dev.20260313 → 0.44.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/LICENSE +21 -21
- package/README.md +218 -218
- package/lib/context/internal/__IChatInitialApplication.d.ts +1 -2
- package/lib/errors/AgenticaJsonParseError.js +6 -6
- package/lib/index.mjs +47 -1
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/call.js +16 -16
- package/lib/orchestrate/initialize.js +43 -1
- package/lib/orchestrate/initialize.js.map +1 -1
- package/lib/structures/IAgenticaController.d.ts +143 -143
- package/lib/utils/ChatGptCompletionMessageUtil.js +6 -6
- package/package.json +6 -6
- package/prompts/cancel.md +5 -5
- package/prompts/common.md +3 -3
- package/prompts/describe.md +7 -7
- package/prompts/execute.md +122 -122
- package/prompts/initialize.md +3 -3
- package/prompts/json_parse_error.md +35 -35
- package/prompts/select.md +7 -7
- package/prompts/validate.md +123 -123
- package/prompts/validate_repeated.md +31 -31
- package/src/Agentica.ts +367 -367
- package/src/MicroAgentica.ts +357 -357
- package/src/constants/AgenticaConstant.ts +4 -4
- package/src/constants/AgenticaDefaultPrompt.ts +44 -44
- package/src/constants/index.ts +2 -2
- package/src/context/AgenticaContext.ts +136 -136
- package/src/context/AgenticaContextRequestResult.ts +14 -14
- package/src/context/AgenticaOperation.ts +73 -73
- package/src/context/AgenticaOperationCollection.ts +49 -49
- package/src/context/AgenticaOperationSelection.ts +9 -9
- package/src/context/AgenticaTokenUsage.ts +186 -186
- package/src/context/MicroAgenticaContext.ts +99 -99
- package/src/context/index.ts +5 -5
- package/src/context/internal/AgenticaOperationComposer.ts +177 -177
- package/src/context/internal/AgenticaTokenUsageAggregator.ts +66 -66
- package/src/context/internal/__IChatCancelFunctionsApplication.ts +23 -23
- package/src/context/internal/__IChatFunctionReference.ts +21 -21
- package/src/context/internal/__IChatInitialApplication.ts +13 -15
- package/src/context/internal/__IChatSelectFunctionsApplication.ts +24 -24
- package/src/context/internal/isAgenticaContext.ts +11 -11
- package/src/errors/AgenticaJsonParseError.ts +52 -52
- package/src/errors/AgenticaValidationError.ts +49 -49
- package/src/errors/index.ts +2 -2
- package/src/events/AgenticaAssistantMessageEvent.ts +12 -12
- package/src/events/AgenticaCallEvent.ts +27 -27
- package/src/events/AgenticaCancelEvent.ts +9 -9
- package/src/events/AgenticaDescribeEvent.ts +14 -14
- package/src/events/AgenticaEvent.ts +59 -59
- package/src/events/AgenticaEvent.type.ts +19 -19
- package/src/events/AgenticaEventBase.ts +18 -18
- package/src/events/AgenticaEventSource.ts +6 -6
- package/src/events/AgenticaExecuteEvent.ts +45 -45
- package/src/events/AgenticaInitializeEvent.ts +7 -7
- package/src/events/AgenticaJsonParseErrorEvent.ts +16 -16
- package/src/events/AgenticaRequestEvent.ts +27 -27
- package/src/events/AgenticaResponseEvent.ts +32 -32
- package/src/events/AgenticaSelectEvent.ts +11 -11
- package/src/events/AgenticaUserMessageEvent.ts +12 -12
- package/src/events/AgenticaValidateEvent.ts +32 -32
- package/src/events/MicroAgenticaEvent.ts +45 -45
- package/src/events/index.ts +15 -15
- package/src/factory/events.ts +357 -357
- package/src/factory/histories.ts +348 -348
- package/src/factory/index.ts +3 -3
- package/src/factory/operations.ts +16 -16
- package/src/functional/assertHttpController.ts +106 -106
- package/src/functional/assertHttpLlmApplication.ts +52 -52
- package/src/functional/assertMcpController.ts +47 -47
- package/src/functional/createMcpLlmApplication.ts +72 -72
- package/src/functional/index.ts +7 -7
- package/src/functional/validateHttpController.ts +113 -113
- package/src/functional/validateHttpLlmApplication.ts +65 -65
- package/src/functional/validateMcpController.ts +53 -53
- package/src/histories/AgenticaAssistantMessageHistory.ts +10 -10
- package/src/histories/AgenticaCancelHistory.ts +8 -8
- package/src/histories/AgenticaDescribeHistory.ts +18 -18
- package/src/histories/AgenticaExecuteHistory.ts +64 -64
- package/src/histories/AgenticaHistory.ts +28 -28
- package/src/histories/AgenticaHistoryBase.ts +35 -35
- package/src/histories/AgenticaSelectHistory.ts +8 -8
- package/src/histories/AgenticaSystemMessageHistory.ts +10 -10
- package/src/histories/AgenticaUserMessageHistory.ts +11 -11
- package/src/histories/MicroAgenticaHistory.ts +19 -19
- package/src/histories/contents/AgenticaUserMessageAudioContent.ts +21 -21
- package/src/histories/contents/AgenticaUserMessageContent.ts +19 -19
- package/src/histories/contents/AgenticaUserMessageContentBase.ts +6 -6
- package/src/histories/contents/AgenticaUserMessageFileContent.ts +25 -25
- package/src/histories/contents/AgenticaUserMessageImageContent.ts +33 -33
- package/src/histories/contents/AgenticaUserMessageTextContent.ts +15 -15
- package/src/histories/contents/index.ts +5 -5
- package/src/histories/index.ts +10 -10
- package/src/index.ts +15 -15
- package/src/json/IAgenticaEventJson.ts +265 -265
- package/src/json/IAgenticaEventJson.type.ts +19 -19
- package/src/json/IAgenticaHistoryJson.ts +165 -165
- package/src/json/IAgenticaHistoryJson.type.ts +19 -19
- package/src/json/IAgenticaOperationJson.ts +36 -36
- package/src/json/IAgenticaOperationSelectionJson.ts +26 -26
- package/src/json/IAgenticaTokenUsageJson.ts +107 -107
- package/src/json/IMicroAgenticaEventJson.ts +22 -22
- package/src/json/IMicroAgenticaHistoryJson.ts +25 -25
- package/src/json/index.ts +7 -7
- package/src/orchestrate/call.ts +542 -542
- package/src/orchestrate/cancel.ts +265 -265
- package/src/orchestrate/describe.ts +66 -66
- package/src/orchestrate/execute.ts +61 -61
- package/src/orchestrate/index.ts +6 -6
- package/src/orchestrate/initialize.ts +102 -102
- package/src/orchestrate/internal/cancelFunctionFromContext.ts +33 -33
- package/src/orchestrate/internal/selectFunctionFromContext.ts +34 -34
- package/src/orchestrate/select.ts +320 -320
- package/src/structures/IAgenticaConfig.ts +83 -83
- package/src/structures/IAgenticaConfigBase.ts +87 -87
- package/src/structures/IAgenticaController.ts +143 -143
- package/src/structures/IAgenticaExecutor.ts +167 -167
- package/src/structures/IAgenticaProps.ts +78 -78
- package/src/structures/IAgenticaSystemPrompt.ts +236 -236
- package/src/structures/IAgenticaVendor.ts +54 -54
- package/src/structures/IMcpTool.ts +60 -60
- package/src/structures/IMicroAgenticaConfig.ts +56 -56
- package/src/structures/IMicroAgenticaExecutor.ts +67 -67
- package/src/structures/IMicroAgenticaProps.ts +77 -77
- package/src/structures/IMicroAgenticaSystemPrompt.ts +169 -169
- package/src/structures/index.ts +10 -10
- package/src/transformers/transformHistory.ts +172 -172
- package/src/utils/AssistantMessageEmptyError.ts +20 -20
- package/src/utils/AsyncQueue.spec.ts +355 -355
- package/src/utils/AsyncQueue.ts +95 -95
- package/src/utils/ByteArrayUtil.ts +5 -5
- package/src/utils/ChatGptCompletionMessageUtil.spec.ts +314 -314
- package/src/utils/ChatGptCompletionMessageUtil.ts +210 -210
- package/src/utils/ChatGptCompletionStreamingUtil.spec.ts +909 -909
- package/src/utils/ChatGptCompletionStreamingUtil.ts +91 -91
- package/src/utils/ChatGptTokenUsageAggregator.spec.ts +226 -226
- package/src/utils/ChatGptTokenUsageAggregator.ts +57 -57
- package/src/utils/MPSC.spec.ts +276 -276
- package/src/utils/MPSC.ts +42 -42
- package/src/utils/Singleton.spec.ts +138 -138
- package/src/utils/Singleton.ts +42 -42
- package/src/utils/StreamUtil.spec.ts +512 -512
- package/src/utils/StreamUtil.ts +87 -87
- package/src/utils/__map_take.spec.ts +140 -140
- package/src/utils/__map_take.ts +13 -13
- package/src/utils/__retry.spec.ts +198 -198
- package/src/utils/__retry.ts +18 -18
- package/src/utils/assertExecuteFailure.ts +16 -16
- package/src/utils/index.ts +4 -4
- package/src/utils/request.ts +140 -140
- package/src/utils/types.ts +50 -50
package/lib/orchestrate/call.js
CHANGED
|
@@ -226,22 +226,22 @@ function correctJsonError(ctx, toolCall, parseErrorEvent, previousValidationErro
|
|
|
226
226
|
toolCall: {
|
|
227
227
|
id: parseErrorEvent.id,
|
|
228
228
|
arguments: parseErrorEvent.failure.input,
|
|
229
|
-
result: (0, utils_1.dedent) `
|
|
230
|
-
Invalid JSON format.
|
|
231
|
-
|
|
232
|
-
Here is the detailed parsing failure information,
|
|
233
|
-
including error messages and their locations within the input:
|
|
234
|
-
|
|
235
|
-
\`\`\`json
|
|
236
|
-
${JSON.stringify(parseErrorEvent.failure.errors)}
|
|
237
|
-
\`\`\`
|
|
238
|
-
|
|
239
|
-
And here is the partially parsed data that was successfully
|
|
240
|
-
extracted before the error occurred:
|
|
241
|
-
|
|
242
|
-
\`\`\`json
|
|
243
|
-
${JSON.stringify(parseErrorEvent.failure.data)}
|
|
244
|
-
\`\`\`
|
|
229
|
+
result: (0, utils_1.dedent) `
|
|
230
|
+
Invalid JSON format.
|
|
231
|
+
|
|
232
|
+
Here is the detailed parsing failure information,
|
|
233
|
+
including error messages and their locations within the input:
|
|
234
|
+
|
|
235
|
+
\`\`\`json
|
|
236
|
+
${JSON.stringify(parseErrorEvent.failure.errors)}
|
|
237
|
+
\`\`\`
|
|
238
|
+
|
|
239
|
+
And here is the partially parsed data that was successfully
|
|
240
|
+
extracted before the error occurred:
|
|
241
|
+
|
|
242
|
+
\`\`\`json
|
|
243
|
+
${JSON.stringify(parseErrorEvent.failure.data)}
|
|
244
|
+
\`\`\`
|
|
245
245
|
`,
|
|
246
246
|
},
|
|
247
247
|
systemPrompt: (_d = (_c = (_b = (_a = ctx.config) === null || _a === void 0 ? void 0 : _a.systemPrompt) === null || _b === void 0 ? void 0 : _b.jsonParseError) === null || _c === void 0 ? void 0 : _c.call(_b, parseErrorEvent)) !== null && _d !== void 0 ? _d : AgenticaSystemPrompt_1.AgenticaSystemPrompt.JSON_PARSE_ERROR.replace("${{FAILURE}}", JSON.stringify(parseErrorEvent.failure)),
|
|
@@ -46,6 +46,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
46
46
|
};
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
48
|
exports.initialize = initialize;
|
|
49
|
+
const __typia_transform__validateReport = __importStar(require("typia/lib/internal/_validateReport"));
|
|
49
50
|
const __typia_transform__llmApplicationFinalize = __importStar(require("typia/lib/internal/_llmApplicationFinalize"));
|
|
50
51
|
const typia_1 = __importDefault(require("typia"));
|
|
51
52
|
const AgenticaDefaultPrompt_1 = require("../constants/AgenticaDefaultPrompt");
|
|
@@ -55,7 +56,48 @@ const histories_1 = require("../factory/histories");
|
|
|
55
56
|
const ChatGptCompletionStreamingUtil_1 = require("../utils/ChatGptCompletionStreamingUtil");
|
|
56
57
|
const StreamUtil_1 = require("../utils/StreamUtil");
|
|
57
58
|
const FUNCTION = __typia_transform__llmApplicationFinalize._llmApplicationFinalize({
|
|
58
|
-
functions: [
|
|
59
|
+
functions: [
|
|
60
|
+
{
|
|
61
|
+
name: "getApiFunctions",
|
|
62
|
+
parameters: {
|
|
63
|
+
description: "Current Type: {@link object}",
|
|
64
|
+
type: "object",
|
|
65
|
+
properties: {},
|
|
66
|
+
required: [],
|
|
67
|
+
additionalProperties: false,
|
|
68
|
+
$defs: {}
|
|
69
|
+
},
|
|
70
|
+
description: "Get list of API functions.\n\nIf user seems like to request some function calling except this one,\ncall this `getApiFunctions()` to get the list of candidate API functions\nprovided from this application.\n\nAlso, user just wants to list up every remote API functions that can be\ncalled from the backend server, utilize this function too.",
|
|
71
|
+
validate: (() => { const _io0 = input => true; const _vo0 = (input, _path, _exceptionable = true) => true; const __is = input => "object" === typeof input && null !== input && false === Array.isArray(input) && _io0(input); let errors; let _report; return input => {
|
|
72
|
+
if (false === __is(input)) {
|
|
73
|
+
errors = [];
|
|
74
|
+
_report = __typia_transform__validateReport._validateReport(errors);
|
|
75
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input && false === Array.isArray(input) || _report(true, {
|
|
76
|
+
path: _path + "",
|
|
77
|
+
expected: "object",
|
|
78
|
+
value: input
|
|
79
|
+
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
80
|
+
path: _path + "",
|
|
81
|
+
expected: "object",
|
|
82
|
+
value: input
|
|
83
|
+
}))(input, "$input", true);
|
|
84
|
+
const success = 0 === errors.length;
|
|
85
|
+
return success ? {
|
|
86
|
+
success,
|
|
87
|
+
data: input
|
|
88
|
+
} : {
|
|
89
|
+
success,
|
|
90
|
+
errors,
|
|
91
|
+
data: input
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
success: true,
|
|
96
|
+
data: input
|
|
97
|
+
};
|
|
98
|
+
}; })()
|
|
99
|
+
}
|
|
100
|
+
]
|
|
59
101
|
}, { equals: false }).functions[0];
|
|
60
102
|
function initialize(ctx) {
|
|
61
103
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../src/orchestrate/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,gCAiFC
|
|
1
|
+
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../src/orchestrate/initialize.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,143 +1,143 @@
|
|
|
1
|
-
import type { IHttpConnection, IHttpLlmApplication, IHttpLlmFunction, IHttpResponse, ILlmApplication, ILlmFunction } from "@typia/interface";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Controller of the Agentica Agent.
|
|
5
|
-
*
|
|
6
|
-
* `IAgenticaController` is a type represents a controller of the
|
|
7
|
-
* {@link Agentica}, which serves a set of functions to be called
|
|
8
|
-
* by A.I. chatbot from LLM function calling.
|
|
9
|
-
*
|
|
10
|
-
* Also, `IAgenticaController` is an union type which can specify
|
|
11
|
-
* a subtype by checking the {@link protocol} property.
|
|
12
|
-
*
|
|
13
|
-
* - HTTP server: {@link IAgenticaController.IHttp}
|
|
14
|
-
* - TypeScript class: {@link IAgenticaController.IClass}
|
|
15
|
-
* - MCP Server: {@link IAgenticaController.IMcp}
|
|
16
|
-
*
|
|
17
|
-
* @author Samchon
|
|
18
|
-
*/
|
|
19
|
-
export type IAgenticaController
|
|
20
|
-
= | IAgenticaController.IHttp
|
|
21
|
-
| IAgenticaController.IClass
|
|
22
|
-
| IAgenticaController.IMcp;
|
|
23
|
-
|
|
24
|
-
export namespace IAgenticaController {
|
|
25
|
-
/**
|
|
26
|
-
* HTTP controller.
|
|
27
|
-
*
|
|
28
|
-
* You can make it by {@link validateHttpLlmApplication} function with
|
|
29
|
-
* the Swagger or OpenAPI document.
|
|
30
|
-
*/
|
|
31
|
-
export interface IHttp extends IBase<"http", IHttpLlmApplication> {
|
|
32
|
-
/**
|
|
33
|
-
* Connection to the server.
|
|
34
|
-
*
|
|
35
|
-
* Connection to the API server including the URL and headers.
|
|
36
|
-
*/
|
|
37
|
-
connection: IHttpConnection;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Executor of the API function.
|
|
41
|
-
*
|
|
42
|
-
* @param props Properties of the API function call
|
|
43
|
-
* @returns HTTP response of the API function call
|
|
44
|
-
*/
|
|
45
|
-
execute?: (props: {
|
|
46
|
-
/**
|
|
47
|
-
* Connection to the server.
|
|
48
|
-
*/
|
|
49
|
-
connection: IHttpConnection;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Application schema.
|
|
53
|
-
*/
|
|
54
|
-
application: IHttpLlmApplication;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Function schema.
|
|
58
|
-
*/
|
|
59
|
-
function: IHttpLlmFunction;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Arguments of the function calling.
|
|
63
|
-
*
|
|
64
|
-
* It is an object of key-value pairs of the API function's parameters.
|
|
65
|
-
* The property keys are composed by below rules:
|
|
66
|
-
*
|
|
67
|
-
* - parameter names
|
|
68
|
-
* - query parameter as an object type if exists
|
|
69
|
-
* - body parameter if exists
|
|
70
|
-
*/
|
|
71
|
-
arguments: object;
|
|
72
|
-
}) => Promise<IHttpResponse>;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* TypeScript class controller.
|
|
77
|
-
*
|
|
78
|
-
* You can make it by `typia.llm.application<App, Model>()` function.
|
|
79
|
-
*
|
|
80
|
-
* - https://typia.io/docs/llm/application
|
|
81
|
-
*/
|
|
82
|
-
export interface IClass extends IBase<"class", ILlmApplication> {
|
|
83
|
-
/**
|
|
84
|
-
* Executor of the class function.
|
|
85
|
-
*
|
|
86
|
-
* Executor of the class function, by target class instance
|
|
87
|
-
* or callback function with given schema and arguments
|
|
88
|
-
* information.
|
|
89
|
-
*/
|
|
90
|
-
execute:
|
|
91
|
-
| object
|
|
92
|
-
| ((props: {
|
|
93
|
-
/**
|
|
94
|
-
* Target application schema.
|
|
95
|
-
*/
|
|
96
|
-
application: ILlmApplication;
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Target function schema.
|
|
100
|
-
*/
|
|
101
|
-
function: ILlmFunction;
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Arguments of the function calling.
|
|
105
|
-
*/
|
|
106
|
-
arguments: object;
|
|
107
|
-
}) => Promise<unknown>);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* MCP Server controller.
|
|
112
|
-
*/
|
|
113
|
-
export interface IMcp extends IBase<"mcp", ILlmApplication> {
|
|
114
|
-
/**
|
|
115
|
-
* MCP client for connection.
|
|
116
|
-
*
|
|
117
|
-
* @warning You have to install `@modelcontextprotocol/sdk` package
|
|
118
|
-
* to use this type properly. If not, this type would work
|
|
119
|
-
* as an `any` type, so that you can't validate it.
|
|
120
|
-
*/
|
|
121
|
-
// @ts-ignore Type checking only when `@modelcontextprotocol/sdk` is installed.
|
|
122
|
-
// This strategy is useful for someone who does not need MCP,
|
|
123
|
-
// for someone who has not installed `@modelcontextprotocol/sdk`.
|
|
124
|
-
client: import("@modelcontextprotocol/sdk/client/index.d.ts").Client;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
interface IBase<Protocol, Application> {
|
|
128
|
-
/**
|
|
129
|
-
* Protocol discrminator.
|
|
130
|
-
*/
|
|
131
|
-
protocol: Protocol;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Name of the controller.
|
|
135
|
-
*/
|
|
136
|
-
name: string;
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Application schema of function calling.
|
|
140
|
-
*/
|
|
141
|
-
application: Application;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
1
|
+
import type { IHttpConnection, IHttpLlmApplication, IHttpLlmFunction, IHttpResponse, ILlmApplication, ILlmFunction } from "@typia/interface";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Controller of the Agentica Agent.
|
|
5
|
+
*
|
|
6
|
+
* `IAgenticaController` is a type represents a controller of the
|
|
7
|
+
* {@link Agentica}, which serves a set of functions to be called
|
|
8
|
+
* by A.I. chatbot from LLM function calling.
|
|
9
|
+
*
|
|
10
|
+
* Also, `IAgenticaController` is an union type which can specify
|
|
11
|
+
* a subtype by checking the {@link protocol} property.
|
|
12
|
+
*
|
|
13
|
+
* - HTTP server: {@link IAgenticaController.IHttp}
|
|
14
|
+
* - TypeScript class: {@link IAgenticaController.IClass}
|
|
15
|
+
* - MCP Server: {@link IAgenticaController.IMcp}
|
|
16
|
+
*
|
|
17
|
+
* @author Samchon
|
|
18
|
+
*/
|
|
19
|
+
export type IAgenticaController
|
|
20
|
+
= | IAgenticaController.IHttp
|
|
21
|
+
| IAgenticaController.IClass
|
|
22
|
+
| IAgenticaController.IMcp;
|
|
23
|
+
|
|
24
|
+
export namespace IAgenticaController {
|
|
25
|
+
/**
|
|
26
|
+
* HTTP controller.
|
|
27
|
+
*
|
|
28
|
+
* You can make it by {@link validateHttpLlmApplication} function with
|
|
29
|
+
* the Swagger or OpenAPI document.
|
|
30
|
+
*/
|
|
31
|
+
export interface IHttp extends IBase<"http", IHttpLlmApplication> {
|
|
32
|
+
/**
|
|
33
|
+
* Connection to the server.
|
|
34
|
+
*
|
|
35
|
+
* Connection to the API server including the URL and headers.
|
|
36
|
+
*/
|
|
37
|
+
connection: IHttpConnection;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Executor of the API function.
|
|
41
|
+
*
|
|
42
|
+
* @param props Properties of the API function call
|
|
43
|
+
* @returns HTTP response of the API function call
|
|
44
|
+
*/
|
|
45
|
+
execute?: (props: {
|
|
46
|
+
/**
|
|
47
|
+
* Connection to the server.
|
|
48
|
+
*/
|
|
49
|
+
connection: IHttpConnection;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Application schema.
|
|
53
|
+
*/
|
|
54
|
+
application: IHttpLlmApplication;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Function schema.
|
|
58
|
+
*/
|
|
59
|
+
function: IHttpLlmFunction;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Arguments of the function calling.
|
|
63
|
+
*
|
|
64
|
+
* It is an object of key-value pairs of the API function's parameters.
|
|
65
|
+
* The property keys are composed by below rules:
|
|
66
|
+
*
|
|
67
|
+
* - parameter names
|
|
68
|
+
* - query parameter as an object type if exists
|
|
69
|
+
* - body parameter if exists
|
|
70
|
+
*/
|
|
71
|
+
arguments: object;
|
|
72
|
+
}) => Promise<IHttpResponse>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* TypeScript class controller.
|
|
77
|
+
*
|
|
78
|
+
* You can make it by `typia.llm.application<App, Model>()` function.
|
|
79
|
+
*
|
|
80
|
+
* - https://typia.io/docs/llm/application
|
|
81
|
+
*/
|
|
82
|
+
export interface IClass extends IBase<"class", ILlmApplication> {
|
|
83
|
+
/**
|
|
84
|
+
* Executor of the class function.
|
|
85
|
+
*
|
|
86
|
+
* Executor of the class function, by target class instance
|
|
87
|
+
* or callback function with given schema and arguments
|
|
88
|
+
* information.
|
|
89
|
+
*/
|
|
90
|
+
execute:
|
|
91
|
+
| object
|
|
92
|
+
| ((props: {
|
|
93
|
+
/**
|
|
94
|
+
* Target application schema.
|
|
95
|
+
*/
|
|
96
|
+
application: ILlmApplication;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Target function schema.
|
|
100
|
+
*/
|
|
101
|
+
function: ILlmFunction;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Arguments of the function calling.
|
|
105
|
+
*/
|
|
106
|
+
arguments: object;
|
|
107
|
+
}) => Promise<unknown>);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* MCP Server controller.
|
|
112
|
+
*/
|
|
113
|
+
export interface IMcp extends IBase<"mcp", ILlmApplication> {
|
|
114
|
+
/**
|
|
115
|
+
* MCP client for connection.
|
|
116
|
+
*
|
|
117
|
+
* @warning You have to install `@modelcontextprotocol/sdk` package
|
|
118
|
+
* to use this type properly. If not, this type would work
|
|
119
|
+
* as an `any` type, so that you can't validate it.
|
|
120
|
+
*/
|
|
121
|
+
// @ts-ignore Type checking only when `@modelcontextprotocol/sdk` is installed.
|
|
122
|
+
// This strategy is useful for someone who does not need MCP,
|
|
123
|
+
// for someone who has not installed `@modelcontextprotocol/sdk`.
|
|
124
|
+
client: import("@modelcontextprotocol/sdk/client/index.d.ts").Client;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
interface IBase<Protocol, Application> {
|
|
128
|
+
/**
|
|
129
|
+
* Protocol discrminator.
|
|
130
|
+
*/
|
|
131
|
+
protocol: Protocol;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Name of the controller.
|
|
135
|
+
*/
|
|
136
|
+
name: string;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Application schema of function calling.
|
|
140
|
+
*/
|
|
141
|
+
application: Application;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -11,12 +11,12 @@ function transformCompletionChunk(source) {
|
|
|
11
11
|
: source;
|
|
12
12
|
const result = utils_1.LlmJson.parse(str);
|
|
13
13
|
if (result.success === false) {
|
|
14
|
-
throw new Error((0, utils_1.dedent) `
|
|
15
|
-
Failed to parse ChatCompletionChunk:
|
|
16
|
-
|
|
17
|
-
\`\`\`json
|
|
18
|
-
${JSON.stringify(result, null, 2)}
|
|
19
|
-
\`\`\`
|
|
14
|
+
throw new Error((0, utils_1.dedent) `
|
|
15
|
+
Failed to parse ChatCompletionChunk:
|
|
16
|
+
|
|
17
|
+
\`\`\`json
|
|
18
|
+
${JSON.stringify(result, null, 2)}
|
|
19
|
+
\`\`\`
|
|
20
20
|
`);
|
|
21
21
|
}
|
|
22
22
|
// const valid = typia.validate<ChatCompletionChunk>(result.data);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentica/core",
|
|
3
|
-
"version": "0.44.0
|
|
3
|
+
"version": "0.44.0",
|
|
4
4
|
"description": "Agentic AI Library specialized in LLM Function Calling",
|
|
5
5
|
"author": "Wrtn Technologies",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
40
40
|
"openai": "^6.15.0",
|
|
41
|
-
"typia": "12.0.0
|
|
41
|
+
"typia": "^12.0.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependenciesMeta": {
|
|
44
44
|
"@modelcontextprotocol/sdk": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"tstl": "^3.0.0",
|
|
50
|
-
"typia": "12.0.0
|
|
50
|
+
"typia": "^12.0.0",
|
|
51
51
|
"uuid": "^13.0.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
58
58
|
"@types/node": "^25.3.0",
|
|
59
59
|
"@types/uuid": "^10.0.0",
|
|
60
|
-
"@typia/interface": "12.0.0
|
|
61
|
-
"@typia/unplugin": "12.0.0
|
|
62
|
-
"@typia/utils": "12.0.0
|
|
60
|
+
"@typia/interface": "^12.0.0",
|
|
61
|
+
"@typia/unplugin": "^12.0.0",
|
|
62
|
+
"@typia/utils": "^12.0.0",
|
|
63
63
|
"@wrtnlabs/calculator-mcp": "^0.2.1",
|
|
64
64
|
"openai": "^6.15.0",
|
|
65
65
|
"rimraf": "^6.0.1",
|
package/prompts/cancel.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
You are a helpful assistant for cancelling functions which are prepared to call.
|
|
2
|
-
|
|
3
|
-
Use the supplied tools to select some functions to cancel of `getApiFunctions()` returned.
|
|
4
|
-
|
|
5
|
-
If you can't find any proper function to select, don't talk, don't do anything.
|
|
1
|
+
You are a helpful assistant for cancelling functions which are prepared to call.
|
|
2
|
+
|
|
3
|
+
Use the supplied tools to select some functions to cancel of `getApiFunctions()` returned.
|
|
4
|
+
|
|
5
|
+
If you can't find any proper function to select, don't talk, don't do anything.
|
package/prompts/common.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
At first, the user's language locale code is "${locale}". When you are conversating with the user or describing the function calling result, consider it and always translate to the target locale language. Never conversate with different locale language text with the user.
|
|
2
|
-
|
|
3
|
-
At second, the user's timezone is "${timezone}", and ISO datetime is ${datetime}. When you are conversating with the user, consider current time and user belonged timezone.
|
|
1
|
+
At first, the user's language locale code is "${locale}". When you are conversating with the user or describing the function calling result, consider it and always translate to the target locale language. Never conversate with different locale language text with the user.
|
|
2
|
+
|
|
3
|
+
At second, the user's timezone is "${timezone}", and ISO datetime is ${datetime}. When you are conversating with the user, consider current time and user belonged timezone.
|
package/prompts/describe.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
You are a helpful assistant describing return values of function calls.
|
|
2
|
-
|
|
3
|
-
Above messages are the list of function call histories. When describing the return values, please do not too much shortly summarize them. Instead, provide detailed descriptions as much as.
|
|
4
|
-
|
|
5
|
-
Also, its content format must be markdown. If required, utilize the mermaid syntax for drawing some diagrams. When image contents are, just put them through the markdown image syntax.
|
|
6
|
-
|
|
7
|
-
At last, if user's language locale code is different with your description, please translate it to the user's language.
|
|
1
|
+
You are a helpful assistant describing return values of function calls.
|
|
2
|
+
|
|
3
|
+
Above messages are the list of function call histories. When describing the return values, please do not too much shortly summarize them. Instead, provide detailed descriptions as much as.
|
|
4
|
+
|
|
5
|
+
Also, its content format must be markdown. If required, utilize the mermaid syntax for drawing some diagrams. When image contents are, just put them through the markdown image syntax.
|
|
6
|
+
|
|
7
|
+
At last, if user's language locale code is different with your description, please translate it to the user's language.
|