@aigne/core 1.5.0 → 1.5.1-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/cjs/agents/agent.d.ts +8 -4
- package/lib/cjs/agents/agent.js +69 -8
- package/lib/cjs/agents/ai-agent.d.ts +5 -5
- package/lib/cjs/agents/ai-agent.js +1 -3
- package/lib/cjs/agents/memory.d.ts +1 -1
- package/lib/cjs/agents/user-agent.d.ts +4 -3
- package/lib/cjs/agents/user-agent.js +5 -5
- package/lib/cjs/execution-engine/context.d.ts +58 -5
- package/lib/cjs/execution-engine/context.js +169 -0
- package/lib/cjs/execution-engine/execution-engine.d.ts +10 -13
- package/lib/cjs/execution-engine/execution-engine.js +7 -96
- package/lib/cjs/execution-engine/message-queue.d.ts +2 -0
- package/lib/cjs/execution-engine/utils.d.ts +2 -2
- package/lib/cjs/execution-engine/utils.js +11 -15
- package/lib/cjs/models/chat-model.d.ts +8 -0
- package/lib/cjs/models/chat-model.js +21 -0
- package/lib/cjs/models/claude-chat-model.js +24 -4
- package/lib/cjs/models/openai-chat-model.d.ts +2 -1
- package/lib/cjs/models/openai-chat-model.js +13 -1
- package/lib/cjs/models/xai-chat-model.d.ts +1 -2
- package/lib/cjs/models/xai-chat-model.js +0 -2
- package/lib/cjs/prompt/prompt-builder.js +3 -3
- package/lib/cjs/utils/json-schema.js +1 -2
- package/lib/cjs/utils/logger.d.ts +9 -1
- package/lib/cjs/utils/logger.js +47 -3
- package/lib/cjs/utils/model-utils.d.ts +3 -0
- package/lib/cjs/utils/model-utils.js +9 -0
- package/lib/cjs/utils/type-utils.d.ts +2 -3
- package/lib/cjs/utils/type-utils.js +16 -11
- package/lib/dts/agents/agent.d.ts +8 -4
- package/lib/dts/agents/ai-agent.d.ts +5 -5
- package/lib/dts/agents/memory.d.ts +1 -1
- package/lib/dts/agents/user-agent.d.ts +4 -3
- package/lib/dts/execution-engine/context.d.ts +58 -5
- package/lib/dts/execution-engine/execution-engine.d.ts +10 -13
- package/lib/dts/execution-engine/message-queue.d.ts +2 -0
- package/lib/dts/execution-engine/utils.d.ts +2 -2
- package/lib/dts/models/chat-model.d.ts +8 -0
- package/lib/dts/models/openai-chat-model.d.ts +2 -1
- package/lib/dts/models/xai-chat-model.d.ts +1 -2
- package/lib/dts/utils/logger.d.ts +9 -1
- package/lib/dts/utils/model-utils.d.ts +3 -0
- package/lib/dts/utils/type-utils.d.ts +2 -3
- package/lib/esm/agents/agent.d.ts +8 -4
- package/lib/esm/agents/agent.js +36 -8
- package/lib/esm/agents/ai-agent.d.ts +5 -5
- package/lib/esm/agents/ai-agent.js +1 -3
- package/lib/esm/agents/memory.d.ts +1 -1
- package/lib/esm/agents/user-agent.d.ts +4 -3
- package/lib/esm/agents/user-agent.js +5 -5
- package/lib/esm/execution-engine/context.d.ts +58 -5
- package/lib/esm/execution-engine/context.js +164 -1
- package/lib/esm/execution-engine/execution-engine.d.ts +10 -13
- package/lib/esm/execution-engine/execution-engine.js +7 -96
- package/lib/esm/execution-engine/message-queue.d.ts +2 -0
- package/lib/esm/execution-engine/utils.d.ts +2 -2
- package/lib/esm/execution-engine/utils.js +11 -15
- package/lib/esm/models/chat-model.d.ts +8 -0
- package/lib/esm/models/chat-model.js +21 -0
- package/lib/esm/models/claude-chat-model.js +24 -4
- package/lib/esm/models/openai-chat-model.d.ts +2 -1
- package/lib/esm/models/openai-chat-model.js +13 -1
- package/lib/esm/models/xai-chat-model.d.ts +1 -2
- package/lib/esm/models/xai-chat-model.js +0 -2
- package/lib/esm/prompt/prompt-builder.js +1 -1
- package/lib/esm/utils/json-schema.js +1 -2
- package/lib/esm/utils/logger.d.ts +9 -1
- package/lib/esm/utils/logger.js +15 -3
- package/lib/esm/utils/model-utils.d.ts +3 -0
- package/lib/esm/utils/model-utils.js +6 -0
- package/lib/esm/utils/type-utils.d.ts +2 -3
- package/lib/esm/utils/type-utils.js +12 -8
- package/package.json +3 -4
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import debug, { type Debugger } from "debug";
|
|
2
|
+
import type { Ora } from "ora";
|
|
2
3
|
interface DebugWithSpinner extends Debugger {
|
|
3
4
|
spinner<T>(promise: Promise<T>, message?: string, callback?: (result: T) => void, options?: {
|
|
4
5
|
disabled?: boolean;
|
|
@@ -10,7 +11,14 @@ export declare const logger: debug.Debug & {
|
|
|
10
11
|
debug: debug.Debug;
|
|
11
12
|
default: debug.Debug;
|
|
12
13
|
} & {
|
|
13
|
-
globalSpinner:
|
|
14
|
+
globalSpinner: {
|
|
15
|
+
start: (text?: string | undefined) => Promise<Ora>;
|
|
16
|
+
stop: () => Promise<Ora>;
|
|
17
|
+
fail: (text?: string | undefined) => Promise<Ora>;
|
|
18
|
+
succeed: (text?: string | undefined) => Promise<Ora>;
|
|
19
|
+
} & {
|
|
20
|
+
isSpinning: boolean;
|
|
21
|
+
};
|
|
14
22
|
base: DebugWithSpinner;
|
|
15
23
|
debug: DebugWithSpinner;
|
|
16
24
|
spinner: typeof spinner;
|
package/lib/esm/utils/logger.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import debug from "debug";
|
|
2
|
-
|
|
3
|
-
debug.log = (...args) => {
|
|
2
|
+
debug.log = async (...args) => {
|
|
4
3
|
const { isSpinning } = globalSpinner;
|
|
5
4
|
if (isSpinning)
|
|
6
5
|
globalSpinner.stop();
|
|
@@ -26,7 +25,20 @@ function createDebugger(namespace) {
|
|
|
26
25
|
overrideExtend(i);
|
|
27
26
|
return i;
|
|
28
27
|
}
|
|
29
|
-
|
|
28
|
+
let _spinner;
|
|
29
|
+
const _spinnerPromise = import("ora")
|
|
30
|
+
.then((o) => o.default())
|
|
31
|
+
.then((spinner) => {
|
|
32
|
+
_spinner = spinner;
|
|
33
|
+
return spinner;
|
|
34
|
+
});
|
|
35
|
+
const globalSpinner = {
|
|
36
|
+
isSpinning: _spinner?.isSpinning ?? false,
|
|
37
|
+
start: (...args) => _spinnerPromise.then((o) => o.start(...args)),
|
|
38
|
+
stop: (...args) => _spinnerPromise.then((o) => o.stop(...args)),
|
|
39
|
+
fail: (...args) => _spinnerPromise.then((o) => o.fail(...args)),
|
|
40
|
+
succeed: (...args) => _spinnerPromise.then((o) => o.succeed(...args)),
|
|
41
|
+
};
|
|
30
42
|
const globalSpinnerTasks = [];
|
|
31
43
|
async function spinner(promise, message, callback) {
|
|
32
44
|
const task = { promise, message, callback };
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { type ZodType } from "zod";
|
|
2
2
|
export type PromiseOrValue<T> = T | Promise<T>;
|
|
3
3
|
export type Nullish<T> = T | null | undefined;
|
|
4
|
+
export declare function isNil(value: unknown): value is null | undefined;
|
|
5
|
+
export declare function isEmpty(obj: unknown): boolean;
|
|
4
6
|
export declare function isNonNullable<T>(value: T): value is NonNullable<T>;
|
|
5
7
|
export declare function isNotEmpty<T>(arr: T[]): arr is [T, ...T[]];
|
|
6
8
|
export declare function orArrayToArray<T>(value?: T | T[]): T[];
|
|
7
|
-
export declare function get(obj: unknown, path: string | string[], type?: undefined): unknown | undefined;
|
|
8
|
-
export declare function get(obj: unknown, path: string | string[], type: "string"): string | undefined;
|
|
9
|
-
export declare function get(obj: unknown, path: string | string[], type: "number"): number | undefined;
|
|
10
9
|
export declare function createAccessorArray<T>(array: T[], accessor: (array: T[], name: string) => T | undefined): T[] & {
|
|
11
10
|
[key: string]: T;
|
|
12
11
|
};
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
import { get as _get, isNil } from "lodash-es";
|
|
2
1
|
import { z } from "zod";
|
|
2
|
+
export function isNil(value) {
|
|
3
|
+
return value === null || value === undefined;
|
|
4
|
+
}
|
|
5
|
+
export function isEmpty(obj) {
|
|
6
|
+
if (isNil(obj))
|
|
7
|
+
return true;
|
|
8
|
+
if (typeof obj === "string" || Array.isArray(obj))
|
|
9
|
+
return obj.length === 0;
|
|
10
|
+
if (typeof obj === "object")
|
|
11
|
+
Object.keys(obj).length === 0;
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
3
14
|
export function isNonNullable(value) {
|
|
4
15
|
return !isNil(value);
|
|
5
16
|
}
|
|
@@ -11,13 +22,6 @@ export function orArrayToArray(value) {
|
|
|
11
22
|
return [];
|
|
12
23
|
return Array.isArray(value) ? value : [value];
|
|
13
24
|
}
|
|
14
|
-
export function get(obj, path, type) {
|
|
15
|
-
const v = _get(obj, path);
|
|
16
|
-
if (type === "string" && typeof v === "string")
|
|
17
|
-
return v;
|
|
18
|
-
if (type === "number" && typeof v === "number")
|
|
19
|
-
return v;
|
|
20
|
-
}
|
|
21
25
|
export function createAccessorArray(array, accessor) {
|
|
22
26
|
return new Proxy(array, {
|
|
23
27
|
get: (t, p, r) => Reflect.get(t, p, r) ?? accessor(array, p),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/core",
|
|
3
|
-
"version": "1.5.0",
|
|
3
|
+
"version": "1.5.1-0",
|
|
4
4
|
"description": "AIGNE core library for building AI-powered applications",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -62,10 +62,8 @@
|
|
|
62
62
|
"@aigne/json-schema-to-zod": "^1.3.3",
|
|
63
63
|
"@modelcontextprotocol/sdk": "^1.8.0",
|
|
64
64
|
"@types/debug": "^4.1.12",
|
|
65
|
-
"@types/mustache": "^4.2.5",
|
|
66
65
|
"debug": "^4.4.0",
|
|
67
66
|
"inquirer": "^12.5.0",
|
|
68
|
-
"lodash-es": "^4.17.21",
|
|
69
67
|
"mustache": "^4.2.0",
|
|
70
68
|
"nanoid": "^5.1.5",
|
|
71
69
|
"ora": "^8.2.0",
|
|
@@ -81,7 +79,8 @@
|
|
|
81
79
|
"@anthropic-ai/sdk": "^0.39.0",
|
|
82
80
|
"@google/generative-ai": "^0.24.0",
|
|
83
81
|
"@types/bun": "^1.2.6",
|
|
84
|
-
"@types/
|
|
82
|
+
"@types/mustache": "^4.2.5",
|
|
83
|
+
"@types/node": "^22.13.14",
|
|
85
84
|
"npm-run-all": "^4.1.5",
|
|
86
85
|
"openai": "^4.89.1",
|
|
87
86
|
"rimraf": "^6.0.1",
|