@agentica/core 0.38.0 → 0.40.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/lib/Agentica.js +1 -1
- package/lib/Agentica.js.map +1 -1
- package/lib/MicroAgentica.js +1 -1
- package/lib/MicroAgentica.js.map +1 -1
- package/lib/context/AgenticaContext.d.ts +2 -1
- package/lib/context/AgenticaContextRequestResult.d.ts +12 -0
- package/lib/context/AgenticaContextRequestResult.js +3 -0
- package/lib/context/AgenticaContextRequestResult.js.map +1 -0
- package/lib/context/MicroAgenticaContext.d.ts +2 -1
- package/lib/errors/AgenticaJsonParseError.d.ts +17 -0
- package/lib/errors/AgenticaJsonParseError.js +33 -0
- package/lib/errors/AgenticaJsonParseError.js.map +1 -0
- package/lib/errors/AgenticaValidationError.d.ts +18 -0
- package/lib/errors/AgenticaValidationError.js +33 -0
- package/lib/errors/AgenticaValidationError.js.map +1 -0
- package/lib/errors/index.d.ts +2 -0
- package/lib/errors/index.js +19 -0
- package/lib/errors/index.js.map +1 -0
- package/lib/events/AgenticaRequestEvent.d.ts +1 -1
- package/lib/factory/events.d.ts +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +139 -32
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/call.js +20 -14
- package/lib/orchestrate/call.js.map +1 -1
- package/lib/orchestrate/cancel.js +7 -3
- package/lib/orchestrate/cancel.js.map +1 -1
- package/lib/orchestrate/describe.js +16 -3
- package/lib/orchestrate/describe.js.map +1 -1
- package/lib/orchestrate/initialize.js +15 -3
- package/lib/orchestrate/initialize.js.map +1 -1
- package/lib/orchestrate/select.js +17 -5
- package/lib/orchestrate/select.js.map +1 -1
- package/lib/structures/IAgenticaConfig.d.ts +2 -54
- package/lib/structures/IAgenticaConfigBase.d.ts +82 -0
- package/lib/structures/IAgenticaConfigBase.js +3 -0
- package/lib/structures/IAgenticaConfigBase.js.map +1 -0
- package/lib/structures/IMicroAgenticaConfig.d.ts +2 -54
- package/lib/utils/ChatGptCompletionMessageUtil.spec.js +3 -3
- package/lib/utils/ChatGptCompletionMessageUtil.spec.js.map +1 -1
- package/lib/utils/request.d.ts +3 -2
- package/lib/utils/request.js +18 -8
- package/lib/utils/request.js.map +1 -1
- package/package.json +1 -1
- package/src/Agentica.ts +2 -2
- package/src/MicroAgentica.ts +2 -2
- package/src/context/AgenticaContext.ts +2 -1
- package/src/context/AgenticaContextRequestResult.ts +14 -0
- package/src/context/MicroAgenticaContext.ts +2 -1
- package/src/errors/AgenticaJsonParseError.ts +47 -0
- package/src/errors/AgenticaValidationError.ts +49 -0
- package/src/errors/index.ts +2 -0
- package/src/events/AgenticaRequestEvent.ts +1 -1
- package/src/factory/events.ts +1 -1
- package/src/index.ts +1 -0
- package/src/orchestrate/call.ts +23 -14
- package/src/orchestrate/cancel.ts +7 -3
- package/src/orchestrate/describe.ts +16 -2
- package/src/orchestrate/initialize.ts +15 -2
- package/src/orchestrate/select.ts +15 -2
- package/src/structures/IAgenticaConfig.ts +2 -58
- package/src/structures/IAgenticaConfigBase.ts +87 -0
- package/src/structures/IMicroAgenticaConfig.ts +2 -58
- package/src/utils/ChatGptCompletionMessageUtil.spec.ts +3 -3
- package/src/utils/request.ts +21 -9
package/lib/Agentica.js
CHANGED
|
@@ -210,7 +210,7 @@ class Agentica {
|
|
|
210
210
|
* @internal
|
|
211
211
|
*/
|
|
212
212
|
getContext(props) {
|
|
213
|
-
const request = (0, request_1.
|
|
213
|
+
const request = (0, request_1.getChatCompletionFunction)({
|
|
214
214
|
vendor: this.props.vendor,
|
|
215
215
|
config: this.props.config,
|
|
216
216
|
dispatch: props.dispatch,
|
package/lib/Agentica.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Agentica.js","sourceRoot":"","sources":["../src/Agentica.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAAiC;AAgBjC,qEAAkE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;;YAEZ,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC5C,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;gBACtB,MAAM,OAAO,CAAC,GAAG,CACf,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAO,QAAQ,EAAE,EAAE;oBACrC,IAAI,CAAC;wBACH,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;oBACxB,CAAC;oBACD,WAAM,CAAC;wBACL,WAAW;oBACb,CAAC;gBACH,CAAC,CAAA,CAAC,CACH,CAAC;YACJ,CAAC;QACH,CAAC;KAAA;CACF;AA3TD,4BA2TC"}
|
package/lib/MicroAgentica.js
CHANGED
|
@@ -217,7 +217,7 @@ class MicroAgentica {
|
|
|
217
217
|
* @internal
|
|
218
218
|
*/
|
|
219
219
|
getContext(props) {
|
|
220
|
-
const request = (0, request_1.
|
|
220
|
+
const request = (0, request_1.getChatCompletionFunction)({
|
|
221
221
|
vendor: this.props.vendor,
|
|
222
222
|
config: this.props.config,
|
|
223
223
|
dispatch: props.dispatch,
|
package/lib/MicroAgentica.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MicroAgentica.js","sourceRoot":"","sources":["../src/MicroAgentica.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAAiC;AAejC,qEAAkE;AAClE,4FAAyF;AACzF,6CAA0D;AAC1D,+CAA+C;AAC/C,sEAAmE;AACnE,mDAAgD;AAChD,uEAAoE;AACpE,
|
|
1
|
+
{"version":3,"file":"MicroAgentica.js","sourceRoot":"","sources":["../src/MicroAgentica.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAAiC;AAejC,qEAAkE;AAClE,4FAAyF;AACzF,6CAA0D;AAC1D,+CAA+C;AAC/C,sEAAmE;AACnE,mDAAgD;AAChD,uEAAoE;AACpE,6CAA4D;AAE5D;;;;;;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AAC;oBACD,WAAM,CAAC;wBACL,WAAW;oBACb,CAAC;gBACH,CAAC,CAAA,CAAC,CACH,CAAC;YACJ,CAAC;QACH,CAAC;KAAA;CACF;AA9SD,sCA8SC"}
|
|
@@ -4,6 +4,7 @@ import type { AgenticaEventSource } from "../events/AgenticaEventSource";
|
|
|
4
4
|
import type { AgenticaHistory } from "../histories/AgenticaHistory";
|
|
5
5
|
import type { AgenticaUserMessageHistory } from "../histories/AgenticaUserMessageHistory";
|
|
6
6
|
import type { IAgenticaConfig } from "../structures/IAgenticaConfig";
|
|
7
|
+
import type { AgenticaContextRequestResult } from "./AgenticaContextRequestResult";
|
|
7
8
|
import type { AgenticaOperationCollection } from "./AgenticaOperationCollection";
|
|
8
9
|
import type { AgenticaOperationSelection } from "./AgenticaOperationSelection";
|
|
9
10
|
/**
|
|
@@ -103,7 +104,7 @@ export interface AgenticaContext {
|
|
|
103
104
|
* @param body The request body to the OpenAI server
|
|
104
105
|
* @returns Response from the OpenAI server
|
|
105
106
|
*/
|
|
106
|
-
request: (source: AgenticaEventSource, body: Omit<OpenAI.ChatCompletionCreateParamsStreaming, "model" | "stream">) => Promise<
|
|
107
|
+
request: (source: AgenticaEventSource, body: Omit<OpenAI.ChatCompletionCreateParamsStreaming, "model" | "stream">) => Promise<AgenticaContextRequestResult>;
|
|
107
108
|
/**
|
|
108
109
|
* Initialize the agent.
|
|
109
110
|
*/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type OpenAI from "openai";
|
|
2
|
+
export type AgenticaContextRequestResult = AgenticaContextRequestResult.Stream | AgenticaContextRequestResult.NoneStream;
|
|
3
|
+
export declare namespace AgenticaContextRequestResult {
|
|
4
|
+
interface Stream {
|
|
5
|
+
type: "stream";
|
|
6
|
+
value: ReadableStream<OpenAI.Chat.Completions.ChatCompletionChunk>;
|
|
7
|
+
}
|
|
8
|
+
interface NoneStream {
|
|
9
|
+
type: "none-stream";
|
|
10
|
+
value: OpenAI.ChatCompletion;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgenticaContextRequestResult.js","sourceRoot":"","sources":["../../src/context/AgenticaContextRequestResult.ts"],"names":[],"mappings":""}
|
|
@@ -3,6 +3,7 @@ import type { MicroAgenticaEvent } from "../events/MicroAgenticaEvent";
|
|
|
3
3
|
import type { AgenticaUserMessageHistory } from "../histories/AgenticaUserMessageHistory";
|
|
4
4
|
import type { MicroAgenticaHistory } from "../histories/MicroAgenticaHistory";
|
|
5
5
|
import type { IMicroAgenticaConfig } from "../structures/IMicroAgenticaConfig";
|
|
6
|
+
import type { AgenticaContextRequestResult } from "./AgenticaContextRequestResult";
|
|
6
7
|
import type { AgenticaOperationCollection } from "./AgenticaOperationCollection";
|
|
7
8
|
/**
|
|
8
9
|
* Context of the Micro Agentic AI agent.
|
|
@@ -74,5 +75,5 @@ export interface MicroAgenticaContext {
|
|
|
74
75
|
* @param body The request body to the OpenAI server
|
|
75
76
|
* @returns Response from the OpenAI server
|
|
76
77
|
*/
|
|
77
|
-
request: (source: MicroAgenticaEvent.Source, body: Omit<OpenAI.ChatCompletionCreateParamsStreaming, "model" | "stream">) => Promise<
|
|
78
|
+
request: (source: MicroAgenticaEvent.Source, body: Omit<OpenAI.ChatCompletionCreateParamsStreaming, "model" | "stream">) => Promise<AgenticaContextRequestResult>;
|
|
78
79
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare class AgenticaJsonParseError extends Error {
|
|
2
|
+
readonly arguments: string;
|
|
3
|
+
readonly reason: string;
|
|
4
|
+
constructor(props: AgenticaJsonParseError.IProps);
|
|
5
|
+
get name(): "AgenticaJsonParseError";
|
|
6
|
+
toJSON(): AgenticaJsonParseError.IJson;
|
|
7
|
+
}
|
|
8
|
+
export declare namespace AgenticaJsonParseError {
|
|
9
|
+
interface IProps {
|
|
10
|
+
arguments: string;
|
|
11
|
+
reason: string;
|
|
12
|
+
}
|
|
13
|
+
interface IJson extends IProps {
|
|
14
|
+
name: "AgenticaJsonParseError";
|
|
15
|
+
message: string;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AgenticaJsonParseError = void 0;
|
|
4
|
+
const AgenticaConstant_1 = require("../constants/AgenticaConstant");
|
|
5
|
+
class AgenticaJsonParseError extends Error {
|
|
6
|
+
constructor(props) {
|
|
7
|
+
super(`Invalid JSON format. The parsing failed after ${AgenticaConstant_1.AgenticaConstant.RETRY} retries.`);
|
|
8
|
+
const proto = new.target.prototype;
|
|
9
|
+
// eslint-disable-next-line
|
|
10
|
+
if (Object.setPrototypeOf) {
|
|
11
|
+
Object.setPrototypeOf(this, proto);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
// eslint-disable-next-line
|
|
15
|
+
this.__proto__ = proto;
|
|
16
|
+
}
|
|
17
|
+
this.arguments = props.arguments;
|
|
18
|
+
this.reason = props.reason;
|
|
19
|
+
}
|
|
20
|
+
get name() {
|
|
21
|
+
return "AgenticaJsonParseError";
|
|
22
|
+
}
|
|
23
|
+
toJSON() {
|
|
24
|
+
return {
|
|
25
|
+
name: "AgenticaJsonParseError",
|
|
26
|
+
message: this.message,
|
|
27
|
+
arguments: this.arguments,
|
|
28
|
+
reason: this.reason,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.AgenticaJsonParseError = AgenticaJsonParseError;
|
|
33
|
+
//# sourceMappingURL=AgenticaJsonParseError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgenticaJsonParseError.js","sourceRoot":"","sources":["../../src/errors/AgenticaJsonParseError.ts"],"names":[],"mappings":";;;AAAA,oEAAiE;AAEjE,MAAa,sBAAuB,SAAQ,KAAK;IAI/C,YAAmB,KAAoC;QACrD,KAAK,CAAC,iDAAiD,mCAAgB,CAAC,KAAK,WAAW,CAAC,CAAC;QAE1F,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC;QAEnC,2BAA2B;QAC3B,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;YAC1B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACrC,CAAC;aACI,CAAC;YACJ,2BAA2B;YAC1B,IAAY,CAAC,SAAS,GAAG,KAAK,CAAC;QAClC,CAAC;QAED,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,IAAW,IAAI;QACb,OAAO,wBAAwB,CAAC;IAClC,CAAC;IAEM,MAAM;QACX,OAAO;YACL,IAAI,EAAE,wBAAwB;YAC9B,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC;IACJ,CAAC;CACF;AAlCD,wDAkCC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IValidation } from "@samchon/openapi";
|
|
2
|
+
export declare class AgenticaValidationError extends Error {
|
|
3
|
+
readonly arguments: unknown;
|
|
4
|
+
readonly errors: IValidation.IError[];
|
|
5
|
+
constructor(props: AgenticaValidationError.IProps);
|
|
6
|
+
get name(): "AgenticaValidationError";
|
|
7
|
+
toJSON(): AgenticaValidationError.IJson;
|
|
8
|
+
}
|
|
9
|
+
export declare namespace AgenticaValidationError {
|
|
10
|
+
interface IProps {
|
|
11
|
+
arguments: unknown;
|
|
12
|
+
errors: IValidation.IError[];
|
|
13
|
+
}
|
|
14
|
+
interface IJson extends IProps {
|
|
15
|
+
name: "AgenticaValidationError";
|
|
16
|
+
message: string;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AgenticaValidationError = void 0;
|
|
4
|
+
const AgenticaConstant_1 = require("../constants/AgenticaConstant");
|
|
5
|
+
class AgenticaValidationError extends Error {
|
|
6
|
+
constructor(props) {
|
|
7
|
+
super(`Invalid arguments. The validation failed after ${AgenticaConstant_1.AgenticaConstant.RETRY} retries.`);
|
|
8
|
+
const proto = new.target.prototype;
|
|
9
|
+
// eslint-disable-next-line
|
|
10
|
+
if (Object.setPrototypeOf) {
|
|
11
|
+
Object.setPrototypeOf(this, proto);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
// eslint-disable-next-line
|
|
15
|
+
this.__proto__ = proto;
|
|
16
|
+
}
|
|
17
|
+
this.arguments = props.arguments;
|
|
18
|
+
this.errors = props.errors;
|
|
19
|
+
}
|
|
20
|
+
get name() {
|
|
21
|
+
return "AgenticaValidationError";
|
|
22
|
+
}
|
|
23
|
+
toJSON() {
|
|
24
|
+
return {
|
|
25
|
+
name: "AgenticaValidationError",
|
|
26
|
+
message: this.message,
|
|
27
|
+
arguments: this.arguments,
|
|
28
|
+
errors: this.errors,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.AgenticaValidationError = AgenticaValidationError;
|
|
33
|
+
//# sourceMappingURL=AgenticaValidationError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgenticaValidationError.js","sourceRoot":"","sources":["../../src/errors/AgenticaValidationError.ts"],"names":[],"mappings":";;;AAEA,oEAAiE;AAEjE,MAAa,uBAAwB,SAAQ,KAAK;IAIhD,YAAmB,KAAqC;QACtD,KAAK,CAAC,kDAAkD,mCAAgB,CAAC,KAAK,WAAW,CAAC,CAAC;QAE3F,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC;QAEnC,2BAA2B;QAC3B,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;YAC1B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACrC,CAAC;aACI,CAAC;YACJ,2BAA2B;YAC1B,IAAY,CAAC,SAAS,GAAG,KAAK,CAAC;QAClC,CAAC;QAED,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,IAAW,IAAI;QACb,OAAO,yBAAyB,CAAC;IACnC,CAAC;IAEM,MAAM;QACX,OAAO;YACL,IAAI,EAAE,yBAAyB;YAC/B,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC;IACJ,CAAC;CACF;AAlCD,0DAkCC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./AgenticaJsonParseError"), exports);
|
|
18
|
+
__exportStar(require("./AgenticaValidationError"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,4DAA0C"}
|
|
@@ -3,6 +3,6 @@ import type { AgenticaEventBase } from "./AgenticaEventBase";
|
|
|
3
3
|
import type { AgenticaEventSource } from "./AgenticaEventSource";
|
|
4
4
|
export interface AgenticaRequestEvent extends AgenticaEventBase<"request"> {
|
|
5
5
|
source: AgenticaEventSource;
|
|
6
|
-
body: OpenAI.ChatCompletionCreateParamsStreaming;
|
|
6
|
+
body: OpenAI.ChatCompletionCreateParamsStreaming | OpenAI.ChatCompletionCreateParamsNonStreaming;
|
|
7
7
|
options?: OpenAI.RequestOptions | undefined;
|
|
8
8
|
}
|
package/lib/factory/events.d.ts
CHANGED
|
@@ -67,7 +67,7 @@ export declare function createDescribeEvent(props: {
|
|
|
67
67
|
}): AgenticaDescribeEvent;
|
|
68
68
|
export declare function createRequestEvent(props: {
|
|
69
69
|
source: AgenticaEventSource;
|
|
70
|
-
body: OpenAI.ChatCompletionCreateParamsStreaming;
|
|
70
|
+
body: OpenAI.ChatCompletionCreateParamsStreaming | OpenAI.ChatCompletionCreateParamsNonStreaming;
|
|
71
71
|
options?: OpenAI.RequestOptions | undefined;
|
|
72
72
|
}): AgenticaRequestEvent;
|
|
73
73
|
export declare function createResponseEvent(props: {
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -40,6 +40,7 @@ exports.utils = exports.orchestrate = exports.factory = void 0;
|
|
|
40
40
|
__exportStar(require("./Agentica"), exports);
|
|
41
41
|
__exportStar(require("./constants"), exports);
|
|
42
42
|
__exportStar(require("./context"), exports);
|
|
43
|
+
__exportStar(require("./errors"), exports);
|
|
43
44
|
__exportStar(require("./events"), exports);
|
|
44
45
|
exports.factory = __importStar(require("./factory"));
|
|
45
46
|
__exportStar(require("./functional"), exports);
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA2B;AAE3B,8CAA4B;AAC5B,4CAA0B;AAC1B,2CAAyB;AACzB,qDAAqC;AACrC,+CAA6B;AAC7B,8CAA4B;AAC5B,yCAAuB;AACvB,kDAAgC;AAChC,6DAA6C;AAC7C,+CAA6B;AAE7B;;GAEG;AACH,iDAAiC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA2B;AAE3B,8CAA4B;AAC5B,4CAA0B;AAC1B,2CAAyB;AACzB,2CAAyB;AACzB,qDAAqC;AACrC,+CAA6B;AAC7B,8CAA4B;AAC5B,yCAAuB;AACvB,kDAAgC;AAChC,6DAA6C;AAC7C,+CAA6B;AAE7B;;GAEG;AACH,iDAAiC"}
|
package/lib/index.mjs
CHANGED
|
@@ -825,6 +825,56 @@ function isAgenticaContext(ctx) {
|
|
|
825
825
|
return typeof ctx.initialize === "function";
|
|
826
826
|
}
|
|
827
827
|
|
|
828
|
+
class AgenticaJsonParseError extends Error {
|
|
829
|
+
constructor(props) {
|
|
830
|
+
super(`Invalid JSON format. The parsing failed after ${AgenticaConstant.RETRY} retries.`);
|
|
831
|
+
const proto = new.target.prototype;
|
|
832
|
+
if (Object.setPrototypeOf) {
|
|
833
|
+
Object.setPrototypeOf(this, proto);
|
|
834
|
+
} else {
|
|
835
|
+
this.__proto__ = proto;
|
|
836
|
+
}
|
|
837
|
+
this.arguments = props.arguments;
|
|
838
|
+
this.reason = props.reason;
|
|
839
|
+
}
|
|
840
|
+
get name() {
|
|
841
|
+
return "AgenticaJsonParseError";
|
|
842
|
+
}
|
|
843
|
+
toJSON() {
|
|
844
|
+
return {
|
|
845
|
+
name: "AgenticaJsonParseError",
|
|
846
|
+
message: this.message,
|
|
847
|
+
arguments: this.arguments,
|
|
848
|
+
reason: this.reason
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
class AgenticaValidationError extends Error {
|
|
854
|
+
constructor(props) {
|
|
855
|
+
super(`Invalid arguments. The validation failed after ${AgenticaConstant.RETRY} retries.`);
|
|
856
|
+
const proto = new.target.prototype;
|
|
857
|
+
if (Object.setPrototypeOf) {
|
|
858
|
+
Object.setPrototypeOf(this, proto);
|
|
859
|
+
} else {
|
|
860
|
+
this.__proto__ = proto;
|
|
861
|
+
}
|
|
862
|
+
this.arguments = props.arguments;
|
|
863
|
+
this.errors = props.errors;
|
|
864
|
+
}
|
|
865
|
+
get name() {
|
|
866
|
+
return "AgenticaValidationError";
|
|
867
|
+
}
|
|
868
|
+
toJSON() {
|
|
869
|
+
return {
|
|
870
|
+
name: "AgenticaValidationError",
|
|
871
|
+
message: this.message,
|
|
872
|
+
arguments: this.arguments,
|
|
873
|
+
errors: this.errors
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
|
|
828
878
|
function __get_retry(limit) {
|
|
829
879
|
const retryFn = async (fn, prevError, attempt = 0) => {
|
|
830
880
|
try {
|
|
@@ -1543,7 +1593,7 @@ async function call(ctx, operations) {
|
|
|
1543
1593
|
throw e;
|
|
1544
1594
|
}));
|
|
1545
1595
|
const completion = await retryFn((async prevError => {
|
|
1546
|
-
const
|
|
1596
|
+
const result = await ctx.request("call", {
|
|
1547
1597
|
messages: [ {
|
|
1548
1598
|
role: "system",
|
|
1549
1599
|
content: AgenticaDefaultPrompt.write(ctx.config)
|
|
@@ -1573,7 +1623,10 @@ async function call(ctx, operations) {
|
|
|
1573
1623
|
}))),
|
|
1574
1624
|
tool_choice: "auto"
|
|
1575
1625
|
});
|
|
1576
|
-
|
|
1626
|
+
if (result.type === "none-stream") {
|
|
1627
|
+
return result.value;
|
|
1628
|
+
}
|
|
1629
|
+
const completion = await reduceStreamingWithDispatch(result.value, (props => {
|
|
1577
1630
|
const event = createAssistantMessageEvent(props);
|
|
1578
1631
|
void ctx.dispatch(event).catch((() => {}));
|
|
1579
1632
|
}));
|
|
@@ -1647,11 +1700,10 @@ async function correctTypeError(ctx, callEvent, validateEvent, previousValidatio
|
|
|
1647
1700
|
call_id: callEvent.id,
|
|
1648
1701
|
operation: callEvent.operation,
|
|
1649
1702
|
arguments: callEvent.arguments,
|
|
1650
|
-
value: {
|
|
1651
|
-
|
|
1652
|
-
message: `Invalid arguments. The validation failed after ${AgenticaConstant.RETRY} retries.`,
|
|
1703
|
+
value: new AgenticaValidationError({
|
|
1704
|
+
arguments: callEvent.arguments,
|
|
1653
1705
|
errors: validateEvent.result.errors
|
|
1654
|
-
},
|
|
1706
|
+
}),
|
|
1655
1707
|
success: false
|
|
1656
1708
|
}),
|
|
1657
1709
|
operation: callEvent.operation,
|
|
@@ -1672,12 +1724,10 @@ async function correctJsonError(ctx, toolCall, parseErrorEvent, previousValidati
|
|
|
1672
1724
|
call_id: toolCall.id,
|
|
1673
1725
|
operation: parseErrorEvent.operation,
|
|
1674
1726
|
arguments: {},
|
|
1675
|
-
value: {
|
|
1676
|
-
name: "JsonParseError",
|
|
1677
|
-
message: `Invalid JSON format. The parsing failed after ${AgenticaConstant.RETRY} retries.`,
|
|
1727
|
+
value: new AgenticaJsonParseError({
|
|
1678
1728
|
arguments: parseErrorEvent.arguments,
|
|
1679
|
-
|
|
1680
|
-
},
|
|
1729
|
+
reason: parseErrorEvent.errorMessage
|
|
1730
|
+
}),
|
|
1681
1731
|
success: false
|
|
1682
1732
|
}),
|
|
1683
1733
|
operation: parseErrorEvent.operation,
|
|
@@ -1715,7 +1765,7 @@ async function correctError(ctx, props) {
|
|
|
1715
1765
|
if (props.life <= 0) {
|
|
1716
1766
|
return props.giveUp();
|
|
1717
1767
|
}
|
|
1718
|
-
const
|
|
1768
|
+
const result = await ctx.request("call", {
|
|
1719
1769
|
messages: [ {
|
|
1720
1770
|
role: "system",
|
|
1721
1771
|
content: AgenticaDefaultPrompt.write(ctx.config)
|
|
@@ -1759,8 +1809,12 @@ async function correctError(ctx, props) {
|
|
|
1759
1809
|
} ],
|
|
1760
1810
|
tool_choice: "required"
|
|
1761
1811
|
});
|
|
1762
|
-
const
|
|
1763
|
-
|
|
1812
|
+
const completion = await (async () => {
|
|
1813
|
+
if (result.type === "none-stream") {
|
|
1814
|
+
return result.value;
|
|
1815
|
+
}
|
|
1816
|
+
return ChatGptCompletionMessageUtil.merge(await StreamUtil.readAll(result.value));
|
|
1817
|
+
})();
|
|
1764
1818
|
const toolCall = completion.choices[0]?.message.tool_calls?.filter((tc => tc.type === "function")).find((s => s.function.name === props.operation.name));
|
|
1765
1819
|
return toolCall === undefined ? props.giveUp() : predicate(ctx, props.operation, toolCall, props.previousValidationErrors, props.life);
|
|
1766
1820
|
}
|
|
@@ -1963,7 +2017,7 @@ async function cancel(ctx) {
|
|
|
1963
2017
|
}
|
|
1964
2018
|
|
|
1965
2019
|
async function step$1(ctx, operations, retry, failures) {
|
|
1966
|
-
const
|
|
2020
|
+
const result = await ctx.request("cancel", {
|
|
1967
2021
|
messages: [ {
|
|
1968
2022
|
role: "system",
|
|
1969
2023
|
content: AgenticaDefaultPrompt.write(ctx.config)
|
|
@@ -2006,8 +2060,12 @@ async function step$1(ctx, operations, retry, failures) {
|
|
|
2006
2060
|
} ],
|
|
2007
2061
|
tool_choice: retry === 0 ? "auto" : "required"
|
|
2008
2062
|
});
|
|
2009
|
-
const
|
|
2010
|
-
|
|
2063
|
+
const completion = await (async () => {
|
|
2064
|
+
if (result.type === "none-stream") {
|
|
2065
|
+
return result.value;
|
|
2066
|
+
}
|
|
2067
|
+
return ChatGptCompletionMessageUtil.merge(await StreamUtil.readAll(result.value));
|
|
2068
|
+
})();
|
|
2011
2069
|
if (retry++ < (ctx.config?.retry ?? AgenticaConstant.RETRY)) {
|
|
2012
2070
|
const failures = [];
|
|
2013
2071
|
for (const choice of completion.choices) {
|
|
@@ -2143,7 +2201,7 @@ async function describe(ctx, histories) {
|
|
|
2143
2201
|
if (histories.length === 0) {
|
|
2144
2202
|
return;
|
|
2145
2203
|
}
|
|
2146
|
-
const
|
|
2204
|
+
const result = await ctx.request("describe", {
|
|
2147
2205
|
messages: [ {
|
|
2148
2206
|
role: "system",
|
|
2149
2207
|
content: AgenticaDefaultPrompt.write(ctx.config)
|
|
@@ -2152,7 +2210,19 @@ async function describe(ctx, histories) {
|
|
|
2152
2210
|
content: ctx.config?.systemPrompt?.describe?.(histories) ?? AgenticaSystemPrompt.DESCRIBE
|
|
2153
2211
|
} ]
|
|
2154
2212
|
});
|
|
2155
|
-
|
|
2213
|
+
if (result.type === "none-stream") {
|
|
2214
|
+
const message = result.value.choices[0]?.message.content ?? "";
|
|
2215
|
+
const event = createDescribeEvent({
|
|
2216
|
+
executes: histories,
|
|
2217
|
+
stream: toAsyncGenerator(message),
|
|
2218
|
+
done: () => true,
|
|
2219
|
+
get: () => message,
|
|
2220
|
+
join: async () => message
|
|
2221
|
+
});
|
|
2222
|
+
void ctx.dispatch(event).catch((() => {}));
|
|
2223
|
+
return;
|
|
2224
|
+
}
|
|
2225
|
+
await reduceStreamingWithDispatch(result.value, (props => {
|
|
2156
2226
|
const event = createDescribeEvent({
|
|
2157
2227
|
executes: histories,
|
|
2158
2228
|
...props
|
|
@@ -3004,7 +3074,7 @@ const FUNCTION = {
|
|
|
3004
3074
|
}.functions[0];
|
|
3005
3075
|
|
|
3006
3076
|
async function initialize(ctx) {
|
|
3007
|
-
const
|
|
3077
|
+
const result = await ctx.request("initialize", {
|
|
3008
3078
|
messages: [ {
|
|
3009
3079
|
role: "system",
|
|
3010
3080
|
content: AgenticaDefaultPrompt.write(ctx.config)
|
|
@@ -3025,7 +3095,18 @@ async function initialize(ctx) {
|
|
|
3025
3095
|
} ],
|
|
3026
3096
|
tool_choice: "auto"
|
|
3027
3097
|
});
|
|
3028
|
-
|
|
3098
|
+
if (result.type === "none-stream") {
|
|
3099
|
+
const message = result.value.choices[0]?.message.content ?? "";
|
|
3100
|
+
const event = createAssistantMessageEvent({
|
|
3101
|
+
stream: toAsyncGenerator(message),
|
|
3102
|
+
done: () => true,
|
|
3103
|
+
get: () => message,
|
|
3104
|
+
join: async () => message
|
|
3105
|
+
});
|
|
3106
|
+
void ctx.dispatch(event).catch((() => {}));
|
|
3107
|
+
return;
|
|
3108
|
+
}
|
|
3109
|
+
const completion = await reduceStreamingWithDispatch(result.value, (props => {
|
|
3029
3110
|
const event = createAssistantMessageEvent(props);
|
|
3030
3111
|
void ctx.dispatch(event).catch((() => {}));
|
|
3031
3112
|
}), ctx.abortSignal);
|
|
@@ -3184,7 +3265,7 @@ async function step(ctx, operations, retry, failures) {
|
|
|
3184
3265
|
throw e;
|
|
3185
3266
|
}));
|
|
3186
3267
|
const completion = await retryFn((async prevError => {
|
|
3187
|
-
const
|
|
3268
|
+
const result = await ctx.request("select", {
|
|
3188
3269
|
messages: [ {
|
|
3189
3270
|
role: "system",
|
|
3190
3271
|
content: AgenticaDefaultPrompt.write(ctx.config)
|
|
@@ -3230,7 +3311,19 @@ async function step(ctx, operations, retry, failures) {
|
|
|
3230
3311
|
} ],
|
|
3231
3312
|
tool_choice: retry === 0 ? "auto" : "required"
|
|
3232
3313
|
});
|
|
3233
|
-
|
|
3314
|
+
if (result.type === "none-stream") {
|
|
3315
|
+
const completion = result.value;
|
|
3316
|
+
const allAssistantMessagesEmpty = completion.choices.every((v => v.message.tool_calls == null && v.message.content === ""));
|
|
3317
|
+
if (allAssistantMessagesEmpty) {
|
|
3318
|
+
const firstChoice = completion.choices.at(0);
|
|
3319
|
+
if (firstChoice?.message?.reasoning != null) {
|
|
3320
|
+
throw new AssistantMessageEmptyWithReasoningError(firstChoice?.message?.reasoning ?? "");
|
|
3321
|
+
}
|
|
3322
|
+
throw new AssistantMessageEmptyError;
|
|
3323
|
+
}
|
|
3324
|
+
return completion;
|
|
3325
|
+
}
|
|
3326
|
+
const completion = await reduceStreamingWithDispatch(result.value, (props => {
|
|
3234
3327
|
const event = createAssistantMessageEvent(props);
|
|
3235
3328
|
void ctx.dispatch(event).catch((() => {}));
|
|
3236
3329
|
}), ctx.abortSignal);
|
|
@@ -3551,17 +3644,22 @@ var index$1 = Object.freeze({
|
|
|
3551
3644
|
decodeUserMessageContent
|
|
3552
3645
|
});
|
|
3553
3646
|
|
|
3554
|
-
function
|
|
3647
|
+
function getChatCompletionFunction(props) {
|
|
3555
3648
|
return async (source, body) => {
|
|
3649
|
+
const streamOptions = props.config?.stream === true || props.config?.stream === undefined ? {
|
|
3650
|
+
stream: true,
|
|
3651
|
+
stream_options: {
|
|
3652
|
+
include_usage: true
|
|
3653
|
+
}
|
|
3654
|
+
} : {
|
|
3655
|
+
stream: false
|
|
3656
|
+
};
|
|
3556
3657
|
const event = createRequestEvent({
|
|
3557
3658
|
source,
|
|
3558
3659
|
body: {
|
|
3559
3660
|
...body,
|
|
3560
3661
|
model: props.vendor.model,
|
|
3561
|
-
|
|
3562
|
-
stream_options: {
|
|
3563
|
-
include_usage: true
|
|
3564
|
-
}
|
|
3662
|
+
...streamOptions
|
|
3565
3663
|
},
|
|
3566
3664
|
options: {
|
|
3567
3665
|
...props.vendor.options,
|
|
@@ -3587,6 +3685,12 @@ function getChatCompletionWithStreamingFunction(props) {
|
|
|
3587
3685
|
}
|
|
3588
3686
|
}
|
|
3589
3687
|
})();
|
|
3688
|
+
if ("toReadableStream" in completion === false) {
|
|
3689
|
+
return {
|
|
3690
|
+
type: "none-stream",
|
|
3691
|
+
value: completion
|
|
3692
|
+
};
|
|
3693
|
+
}
|
|
3590
3694
|
const [streamForEvent, temporaryStream] = StreamUtil.transform(completion.toReadableStream(), (value => ChatGptCompletionMessageUtil.transformCompletionChunk(value)), props.abortSignal).tee();
|
|
3591
3695
|
const [streamForAggregate, streamForReturn] = temporaryStream.tee();
|
|
3592
3696
|
(async () => {
|
|
@@ -3620,7 +3724,10 @@ function getChatCompletionWithStreamingFunction(props) {
|
|
|
3620
3724
|
},
|
|
3621
3725
|
created_at: (new Date).toISOString()
|
|
3622
3726
|
}).catch((() => {}));
|
|
3623
|
-
return
|
|
3727
|
+
return {
|
|
3728
|
+
type: "stream",
|
|
3729
|
+
value: streamForReturn
|
|
3730
|
+
};
|
|
3624
3731
|
};
|
|
3625
3732
|
}
|
|
3626
3733
|
|
|
@@ -3701,7 +3808,7 @@ class Agentica {
|
|
|
3701
3808
|
return this.token_usage_;
|
|
3702
3809
|
}
|
|
3703
3810
|
getContext(props) {
|
|
3704
|
-
const request =
|
|
3811
|
+
const request = getChatCompletionFunction({
|
|
3705
3812
|
vendor: this.props.vendor,
|
|
3706
3813
|
config: this.props.config,
|
|
3707
3814
|
dispatch: props.dispatch,
|
|
@@ -45435,7 +45542,7 @@ class MicroAgentica {
|
|
|
45435
45542
|
return this.token_usage_;
|
|
45436
45543
|
}
|
|
45437
45544
|
getContext(props) {
|
|
45438
|
-
const request =
|
|
45545
|
+
const request = getChatCompletionFunction({
|
|
45439
45546
|
vendor: this.props.vendor,
|
|
45440
45547
|
config: this.props.config,
|
|
45441
45548
|
dispatch: props.dispatch,
|
|
@@ -45484,5 +45591,5 @@ class MicroAgentica {
|
|
|
45484
45591
|
}
|
|
45485
45592
|
}
|
|
45486
45593
|
|
|
45487
|
-
export { Agentica, AgenticaDefaultPrompt, AgenticaSystemPrompt, AgenticaTokenUsage, MicroAgentica, assertHttpController, assertHttpLlmApplication, assertMcpController, index$1 as factory, index as orchestrate, index$2 as utils, validateHttpController, validateHttpLlmApplication, validateMcpController, write };
|
|
45594
|
+
export { Agentica, AgenticaDefaultPrompt, AgenticaJsonParseError, AgenticaSystemPrompt, AgenticaTokenUsage, AgenticaValidationError, MicroAgentica, assertHttpController, assertHttpLlmApplication, assertMcpController, index$1 as factory, index as orchestrate, index$2 as utils, validateHttpController, validateHttpLlmApplication, validateMcpController, write };
|
|
45488
45595
|
//# sourceMappingURL=index.mjs.map
|