@xtalpi/agentic-lab-agent-sdk 0.0.17
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.md +20 -0
- package/README.md +172 -0
- package/dist/agent/index.d.ts +21 -0
- package/dist/agent/index.js +30 -0
- package/dist/agent/tracer.d.ts +37 -0
- package/dist/agent/tracer.js +217 -0
- package/dist/context/context.d.ts +6 -0
- package/dist/context/context.js +9 -0
- package/dist/file/file.d.ts +25 -0
- package/dist/file/file.js +95 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +53 -0
- package/dist/message/message.d.ts +12 -0
- package/dist/message/message.js +35 -0
- package/dist/message/normalize.d.ts +4 -0
- package/dist/message/normalize.js +11 -0
- package/dist/middleware/createToolErrorCatchMiddleware.d.ts +7 -0
- package/dist/middleware/createToolErrorCatchMiddleware.js +45 -0
- package/dist/middleware/createToolMiddleware.d.ts +8 -0
- package/dist/middleware/createToolMiddleware.js +32 -0
- package/dist/middleware/index.d.ts +11 -0
- package/dist/middleware/index.js +11 -0
- package/dist/prompt/prompt.d.ts +11 -0
- package/dist/prompt/prompt.js +19 -0
- package/dist/protocal/protocal.d.ts +22 -0
- package/dist/protocal/protocal.js +118 -0
- package/dist/skill/skill.d.ts +14 -0
- package/dist/skill/skill.js +18 -0
- package/dist/stream/stream.d.ts +15 -0
- package/dist/stream/stream.js +38 -0
- package/dist/types/message/enum.d.ts +7 -0
- package/dist/types/message/enum.js +9 -0
- package/dist/types/message/index.d.ts +20 -0
- package/dist/types/message/index.js +1 -0
- package/dist/types/protocal/content/echarts.d.ts +7 -0
- package/dist/types/protocal/content/echarts.js +1 -0
- package/dist/types/protocal/content/fileLink.d.ts +14 -0
- package/dist/types/protocal/content/fileLink.js +9 -0
- package/dist/types/protocal/content/form.d.ts +49 -0
- package/dist/types/protocal/content/form.js +10 -0
- package/dist/types/protocal/content/progress.d.ts +16 -0
- package/dist/types/protocal/content/progress.js +9 -0
- package/dist/types/protocal/content/smiles.d.ts +21 -0
- package/dist/types/protocal/content/smiles.js +15 -0
- package/dist/types/protocal/content/toolCall.d.ts +16 -0
- package/dist/types/protocal/content/toolCall.js +11 -0
- package/dist/types/protocal/enum.d.ts +12 -0
- package/dist/types/protocal/enum.js +14 -0
- package/dist/types/protocal/index.d.ts +21 -0
- package/dist/types/protocal/index.js +1 -0
- package/dist/types/stream/index.d.ts +7 -0
- package/dist/types/stream/index.js +1 -0
- package/dist/types/tracer/index.d.ts +33 -0
- package/dist/types/tracer/index.js +14 -0
- package/dist/utils/error.d.ts +4 -0
- package/dist/utils/error.js +15 -0
- package/dist/utils/utils.d.ts +15 -0
- package/dist/utils/utils.js +42 -0
- package/package.json +72 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/types/protocal/content/progress.d.ts
|
|
2
|
+
declare enum ProgressType {
|
|
3
|
+
Linear = "Linear",
|
|
4
|
+
// 线条, 默认
|
|
5
|
+
Circular = "Circular",
|
|
6
|
+
}
|
|
7
|
+
interface ProgressContent {
|
|
8
|
+
id: string;
|
|
9
|
+
value: number;
|
|
10
|
+
type?: ProgressType;
|
|
11
|
+
text?: string;
|
|
12
|
+
position?: string;
|
|
13
|
+
[propName: string]: any;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { ProgressContent, ProgressType };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/types/protocal/content/progress.ts
|
|
2
|
+
let ProgressType = /* @__PURE__ */ function(ProgressType$1) {
|
|
3
|
+
ProgressType$1["Linear"] = "Linear";
|
|
4
|
+
ProgressType$1["Circular"] = "Circular";
|
|
5
|
+
return ProgressType$1;
|
|
6
|
+
}({});
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { ProgressType };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/types/protocal/content/smiles.d.ts
|
|
2
|
+
declare enum SmilesContentSize {
|
|
3
|
+
Normal = "Normal",
|
|
4
|
+
// 默认,常规大小
|
|
5
|
+
Medium = "Medium",
|
|
6
|
+
// 中等尺寸
|
|
7
|
+
Small = "Small",
|
|
8
|
+
}
|
|
9
|
+
declare enum SmilesContentType {
|
|
10
|
+
Image = "Image",
|
|
11
|
+
// 默认,展示为图片
|
|
12
|
+
Text = "Text",
|
|
13
|
+
}
|
|
14
|
+
interface SmilesContent {
|
|
15
|
+
value: string;
|
|
16
|
+
ui_type: SmilesContentType;
|
|
17
|
+
ui_size: SmilesContentSize;
|
|
18
|
+
[propName: string]: any;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { SmilesContent, SmilesContentSize, SmilesContentType };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/types/protocal/content/smiles.ts
|
|
2
|
+
let SmilesContentSize = /* @__PURE__ */ function(SmilesContentSize$1) {
|
|
3
|
+
SmilesContentSize$1["Normal"] = "Normal";
|
|
4
|
+
SmilesContentSize$1["Medium"] = "Medium";
|
|
5
|
+
SmilesContentSize$1["Small"] = "Small";
|
|
6
|
+
return SmilesContentSize$1;
|
|
7
|
+
}({});
|
|
8
|
+
let SmilesContentType = /* @__PURE__ */ function(SmilesContentType$1) {
|
|
9
|
+
SmilesContentType$1["Image"] = "Image";
|
|
10
|
+
SmilesContentType$1["Text"] = "Text";
|
|
11
|
+
return SmilesContentType$1;
|
|
12
|
+
}({});
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { SmilesContentSize, SmilesContentType };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/types/protocal/content/toolCall.d.ts
|
|
2
|
+
declare enum ToolCallStatus {
|
|
3
|
+
Created = "created",
|
|
4
|
+
Running = "running",
|
|
5
|
+
Finished = "finished",
|
|
6
|
+
Failed = "failed",
|
|
7
|
+
}
|
|
8
|
+
interface ToolCallContent {
|
|
9
|
+
title?: string;
|
|
10
|
+
tool_id: string;
|
|
11
|
+
status: ToolCallStatus;
|
|
12
|
+
group_id?: string;
|
|
13
|
+
[propName: string]: any;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { ToolCallContent, ToolCallStatus };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/types/protocal/content/toolCall.ts
|
|
2
|
+
let ToolCallStatus = /* @__PURE__ */ function(ToolCallStatus$1) {
|
|
3
|
+
ToolCallStatus$1["Created"] = "created";
|
|
4
|
+
ToolCallStatus$1["Running"] = "running";
|
|
5
|
+
ToolCallStatus$1["Finished"] = "finished";
|
|
6
|
+
ToolCallStatus$1["Failed"] = "failed";
|
|
7
|
+
return ToolCallStatus$1;
|
|
8
|
+
}({});
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { ToolCallStatus };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/types/protocal/enum.d.ts
|
|
2
|
+
declare enum DataType {
|
|
3
|
+
Markdown = "markdown",
|
|
4
|
+
ECharts = "echarts",
|
|
5
|
+
Smiles = "smiles",
|
|
6
|
+
Form = "form",
|
|
7
|
+
FileLink = "file_link",
|
|
8
|
+
Progress = "progress",
|
|
9
|
+
ToolCall = "tool_call",
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { DataType };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/types/protocal/enum.ts
|
|
2
|
+
let DataType = /* @__PURE__ */ function(DataType$1) {
|
|
3
|
+
DataType$1["Markdown"] = "markdown";
|
|
4
|
+
DataType$1["ECharts"] = "echarts";
|
|
5
|
+
DataType$1["Smiles"] = "smiles";
|
|
6
|
+
DataType$1["Form"] = "form";
|
|
7
|
+
DataType$1["FileLink"] = "file_link";
|
|
8
|
+
DataType$1["Progress"] = "progress";
|
|
9
|
+
DataType$1["ToolCall"] = "tool_call";
|
|
10
|
+
return DataType$1;
|
|
11
|
+
}({});
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { DataType };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DataType } from "./enum.js";
|
|
2
|
+
import { FormContent } from "./content/form.js";
|
|
3
|
+
import { EChartsContent } from "./content/echarts.js";
|
|
4
|
+
import { FileLinkContent } from "./content/fileLink.js";
|
|
5
|
+
import { SmilesContent } from "./content/smiles.js";
|
|
6
|
+
import { ToolCallContent } from "./content/toolCall.js";
|
|
7
|
+
import { ProgressContent } from "./content/progress.js";
|
|
8
|
+
|
|
9
|
+
//#region src/types/protocal/index.d.ts
|
|
10
|
+
interface CurveChunk {
|
|
11
|
+
data_type: DataType;
|
|
12
|
+
metadata: Record<string, any>;
|
|
13
|
+
content: string;
|
|
14
|
+
}
|
|
15
|
+
interface CurveInnerChunk {
|
|
16
|
+
data_type: DataType;
|
|
17
|
+
content: FormContent | EChartsContent | FileLinkContent | SmilesContent | ToolCallContent | ProgressContent;
|
|
18
|
+
metadata?: Record<string, any>;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { CurveChunk, CurveInnerChunk };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region src/types/tracer/index.d.ts
|
|
2
|
+
declare enum TraceEventType {
|
|
3
|
+
LlmStart = "llm_start",
|
|
4
|
+
LlmEnd = "llm_end",
|
|
5
|
+
LlmError = "llm_error",
|
|
6
|
+
ToolStart = "tool_start",
|
|
7
|
+
ToolEnd = "tool_end",
|
|
8
|
+
ToolError = "tool_error",
|
|
9
|
+
ChainError = "chain_error",
|
|
10
|
+
}
|
|
11
|
+
interface TraceEvent {
|
|
12
|
+
type: TraceEventType;
|
|
13
|
+
timestamp: number;
|
|
14
|
+
runId: string;
|
|
15
|
+
duration?: number;
|
|
16
|
+
data: Record<string, any>;
|
|
17
|
+
}
|
|
18
|
+
interface TraceData {
|
|
19
|
+
traceId: string;
|
|
20
|
+
query?: string;
|
|
21
|
+
startTime: number;
|
|
22
|
+
endTime?: number;
|
|
23
|
+
events: TraceEvent[];
|
|
24
|
+
totalTokens: {
|
|
25
|
+
promptTokens: number;
|
|
26
|
+
completionTokens: number;
|
|
27
|
+
totalTokens: number;
|
|
28
|
+
};
|
|
29
|
+
llmCalls: number;
|
|
30
|
+
toolCalls: number;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { TraceData, TraceEvent, TraceEventType };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/types/tracer/index.ts
|
|
2
|
+
let TraceEventType = /* @__PURE__ */ function(TraceEventType$1) {
|
|
3
|
+
TraceEventType$1["LlmStart"] = "llm_start";
|
|
4
|
+
TraceEventType$1["LlmEnd"] = "llm_end";
|
|
5
|
+
TraceEventType$1["LlmError"] = "llm_error";
|
|
6
|
+
TraceEventType$1["ToolStart"] = "tool_start";
|
|
7
|
+
TraceEventType$1["ToolEnd"] = "tool_end";
|
|
8
|
+
TraceEventType$1["ToolError"] = "tool_error";
|
|
9
|
+
TraceEventType$1["ChainError"] = "chain_error";
|
|
10
|
+
return TraceEventType$1;
|
|
11
|
+
}({});
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { TraceEventType };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/utils/error.ts
|
|
2
|
+
const getMessageFromError = (error, preset = "") => {
|
|
3
|
+
const _error = error;
|
|
4
|
+
if (_error?.response?.data?.message && typeof _error.response.data.message === "string") return _error.response.data.message;
|
|
5
|
+
else if (_error?.response?.data?.error_description && typeof _error.response.data.error_description === "string") return _error.response.data.error_description;
|
|
6
|
+
else if (_error?.response?.data?.error && typeof _error.response.data.error === "string") return _error.response.data.error;
|
|
7
|
+
else if (_error?.response?.data?.data && typeof _error.response.data.data === "string") return _error.response.data.data;
|
|
8
|
+
else if (_error?.response?.data?.msg && typeof _error.response.data.msg === "string") return _error.response.data.msg;
|
|
9
|
+
else if (_error?.message && typeof _error.message === "string") return _error.message;
|
|
10
|
+
else if (_error && typeof _error === "string") return _error;
|
|
11
|
+
return preset;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { getMessageFromError };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HttpStatus } from "@nestjs/common";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/utils.d.ts
|
|
4
|
+
declare class UtilsModule {
|
|
5
|
+
getMessageFromError(error: any, preset?: string): string;
|
|
6
|
+
uuidv4(): string;
|
|
7
|
+
delay(time: number): Promise<void>;
|
|
8
|
+
isPNum(n?: unknown): boolean;
|
|
9
|
+
isStr(str?: string, excludeEmpty?: boolean): boolean;
|
|
10
|
+
parseJsonSilent(value: string): Record<string, any>;
|
|
11
|
+
paramsException(key: string, tip?: string, status?: HttpStatus): void;
|
|
12
|
+
commonException(tip?: string, status?: HttpStatus): void;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { UtilsModule };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getMessageFromError } from "./error.js";
|
|
2
|
+
import { v4 } from "uuid";
|
|
3
|
+
import { HttpException, HttpStatus } from "@nestjs/common";
|
|
4
|
+
|
|
5
|
+
//#region src/utils/utils.ts
|
|
6
|
+
var UtilsModule = class {
|
|
7
|
+
getMessageFromError(error, preset = "") {
|
|
8
|
+
return getMessageFromError(error, preset);
|
|
9
|
+
}
|
|
10
|
+
uuidv4() {
|
|
11
|
+
return v4();
|
|
12
|
+
}
|
|
13
|
+
delay(time) {
|
|
14
|
+
return new Promise((resolve) => {
|
|
15
|
+
setTimeout(() => {
|
|
16
|
+
resolve(true);
|
|
17
|
+
}, time);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
isPNum(n) {
|
|
21
|
+
return typeof n === "number" && n > 0;
|
|
22
|
+
}
|
|
23
|
+
isStr(str, excludeEmpty = false) {
|
|
24
|
+
return excludeEmpty ? !!(typeof str === "string" && str) : typeof str === "string";
|
|
25
|
+
}
|
|
26
|
+
parseJsonSilent(value) {
|
|
27
|
+
try {
|
|
28
|
+
return JSON.parse(value);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
return {};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
paramsException(key, tip = "", status = HttpStatus.BAD_REQUEST) {
|
|
34
|
+
throw new HttpException(tip || `Invalid params ${key}`, status);
|
|
35
|
+
}
|
|
36
|
+
commonException(tip = "", status = HttpStatus.BAD_REQUEST) {
|
|
37
|
+
throw new HttpException(tip, status);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { UtilsModule };
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xtalpi/agentic-lab-agent-sdk",
|
|
3
|
+
"version": "0.0.17",
|
|
4
|
+
"description": "Agentic Lab Agent SDK",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "TheoXiong",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public",
|
|
9
|
+
"registry": "https://registry.npmjs.org/"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "dist/index.js",
|
|
13
|
+
"types": "dist/index.d.ts",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist/",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE.md",
|
|
18
|
+
"CHANGELOG.md"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsdown",
|
|
22
|
+
"release": "tsdown && npm publish",
|
|
23
|
+
"format": "prettier .",
|
|
24
|
+
"lint": "eslint . --max-warnings 0",
|
|
25
|
+
"tsc": "tsc"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@eslint/js": "9.39.1",
|
|
29
|
+
"@types/express": "^4.17.17",
|
|
30
|
+
"@types/fs-extra": "^11.0.0",
|
|
31
|
+
"@types/js-yaml": "^4.0.5",
|
|
32
|
+
"@types/node": "24.10.1",
|
|
33
|
+
"@types/uuid": "^9.0.0",
|
|
34
|
+
"@vitest/coverage-v8": "4.0.15",
|
|
35
|
+
"@vitest/eslint-plugin": "1.5.1",
|
|
36
|
+
"eslint": "9.39.1",
|
|
37
|
+
"prettier": "3.7.3",
|
|
38
|
+
"tsdown": "0.16.8",
|
|
39
|
+
"typescript": "5.9.3",
|
|
40
|
+
"typescript-eslint": "8.48.1",
|
|
41
|
+
"vitest": "4.0.15"
|
|
42
|
+
},
|
|
43
|
+
"packageManager": "pnpm@10.4.0",
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=22.22.0"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@langchain/core": "^1.1.39",
|
|
49
|
+
"langchain": ">=1.3.0"
|
|
50
|
+
},
|
|
51
|
+
"peerDependenciesMeta": {
|
|
52
|
+
"@langchain/core": {
|
|
53
|
+
"optional": true
|
|
54
|
+
},
|
|
55
|
+
"langchain": {
|
|
56
|
+
"optional": true
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@nestjs/common": "^10.0.0",
|
|
61
|
+
"axios": "^1.6.0",
|
|
62
|
+
"date-fns": "^2.30.0",
|
|
63
|
+
"date-fns-tz": "^2.0.0",
|
|
64
|
+
"express": "4.21.2",
|
|
65
|
+
"fs-extra": "^11.1.1",
|
|
66
|
+
"js-yaml": "^4.1.0",
|
|
67
|
+
"lodash": "^4.17.21",
|
|
68
|
+
"uuid": "^11.0.4",
|
|
69
|
+
"xlsx": "^0.18.5",
|
|
70
|
+
"zod": "^3.25.76"
|
|
71
|
+
}
|
|
72
|
+
}
|