@adminforth/agent 3.1.10 → 3.3.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 +71 -38
- package/dist/application/ports.d.ts +3 -1
- package/dist/application/runTurnUseCase.d.ts +3 -3
- package/dist/application/runTurnUseCase.js +8 -6
- package/dist/custom/ChatSurface.vue +25 -8
- package/dist/custom/{skills/charts/SKILL.md → charts.md} +2 -4
- package/dist/custom/composables/useAgentStore.ts +0 -20
- package/dist/custom/composables/useAgentTransitions.ts +13 -37
- package/dist/custom/utils.ts +5 -0
- package/dist/domain/systemPrompt.d.ts +3 -2
- package/dist/domain/systemPrompt.js +14 -53
- package/dist/index.d.ts +0 -3
- package/dist/index.js +24 -35
- package/dist/llm/agentRuntime.d.ts +9 -8
- package/dist/llm/agentRuntime.js +134 -106
- package/dist/llm/langGraphLlm.d.ts +3 -0
- package/dist/llm/langGraphLlm.js +10 -2
- package/dist/llm/middleware/mcpToolsMiddleware.d.ts +7 -0
- package/dist/llm/middleware/{apiToolsMiddleware.js → mcpToolsMiddleware.js} +16 -36
- package/dist/tools/agentToolProvider.d.ts +16 -5
- package/dist/tools/agentToolProvider.js +26 -10
- package/dist/tools/fetchToolSchema.d.ts +7 -3
- package/dist/tools/fetchToolSchema.js +29 -22
- package/dist/tools/mcpConnection.d.ts +38 -0
- package/dist/tools/mcpConnection.js +42 -0
- package/dist/tools/mcpTool.d.ts +3 -0
- package/dist/tools/{apiTool.js → mcpTool.js} +7 -23
- package/dist/tools/toolLabels.d.ts +5 -0
- package/dist/tools/toolLabels.js +49 -0
- package/dist/transport/http/context.d.ts +2 -2
- package/dist/transport/http/sessionEndpoints.js +1 -1
- package/package.json +6 -4
- package/dist/custom/skills/analyze_data/SKILL.md +0 -25
- package/dist/custom/skills/fetch_data/SKILL.md +0 -31
- package/dist/custom/skills/mutate_data/SKILL.md +0 -121
- package/dist/llm/middleware/apiToolsMiddleware.d.ts +0 -3
- package/dist/tools/apiBasedTools.d.ts +0 -30
- package/dist/tools/apiBasedTools.js +0 -488
- package/dist/tools/apiTool.d.ts +0 -6
- package/dist/tools/fetchSkill.d.ts +0 -8
- package/dist/tools/fetchSkill.js +0 -51
- package/dist/tools/index.d.ts +0 -4
- package/dist/tools/index.js +0 -32
- package/dist/tools/skills/registry.d.ts +0 -11
- package/dist/tools/skills/registry.js +0 -107
package/dist/tools/fetchSkill.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { tool } from "langchain";
|
|
11
|
-
import { z } from "zod";
|
|
12
|
-
import { listSkillManifests, loadSkillMarkdown, } from "./skills/registry.js";
|
|
13
|
-
const fetchSkillSchema = z.object({
|
|
14
|
-
skillName: z
|
|
15
|
-
.string()
|
|
16
|
-
.describe("Name of the custom AdminForth skill to load, for example fetch_data or mutate_data."),
|
|
17
|
-
});
|
|
18
|
-
function serializeSkillManifests(skillManifests) {
|
|
19
|
-
return skillManifests.map((skill) => ({
|
|
20
|
-
name: skill.name,
|
|
21
|
-
description: skill.description,
|
|
22
|
-
}));
|
|
23
|
-
}
|
|
24
|
-
export function createFetchSkillTool(customComponentsDir_1) {
|
|
25
|
-
return __awaiter(this, arguments, void 0, function* (customComponentsDir, pluginCustomFolderPaths = []) {
|
|
26
|
-
const availableSkills = yield listSkillManifests(customComponentsDir, pluginCustomFolderPaths);
|
|
27
|
-
const availableSkillNames = availableSkills.map((skill) => skill.name);
|
|
28
|
-
return tool((_a) => __awaiter(this, [_a], void 0, function* ({ skillName }) {
|
|
29
|
-
try {
|
|
30
|
-
const skillMarkdown = yield loadSkillMarkdown(skillName, customComponentsDir, pluginCustomFolderPaths);
|
|
31
|
-
if (!skillMarkdown) {
|
|
32
|
-
return [
|
|
33
|
-
`Skill "${skillName}" not found.`,
|
|
34
|
-
"Available skills:",
|
|
35
|
-
JSON.stringify(serializeSkillManifests(availableSkills), null, 2),
|
|
36
|
-
].join("\n");
|
|
37
|
-
}
|
|
38
|
-
return skillMarkdown;
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
return `Failed to load skill "${skillName}": ${error instanceof Error ? error.message : String(error)}`;
|
|
42
|
-
}
|
|
43
|
-
}), {
|
|
44
|
-
name: "fetch_skill",
|
|
45
|
-
description: `Fetch the raw SKILL.md content for a custom AdminForth skill by name.${availableSkillNames.length > 0
|
|
46
|
-
? ` Available skills: ${availableSkillNames.join(", ")}.`
|
|
47
|
-
: ""}`,
|
|
48
|
-
schema: fetchSkillSchema,
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
}
|
package/dist/tools/index.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { ClientTool } from "@langchain/core/tools";
|
|
2
|
-
import type { ApiBasedTool } from "./apiBasedTools.js";
|
|
3
|
-
export declare const ALWAYS_AVAILABLE_API_TOOL_NAMES: readonly ["get_resource"];
|
|
4
|
-
export declare function createAgentTools(customComponentsDir: string, apiBasedTools: Record<string, ApiBasedTool>, pluginCustomFolderPaths?: string[]): Promise<ClientTool[]>;
|
package/dist/tools/index.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { createFetchSkillTool } from "./fetchSkill.js";
|
|
11
|
-
import { createFetchToolSchemaTool } from "./fetchToolSchema.js";
|
|
12
|
-
import { createApiTool } from "./apiTool.js";
|
|
13
|
-
import { createGetUserLocationTool } from "./getUserLocation.js";
|
|
14
|
-
import { createNavigateUserTool } from "./navigateUser.js";
|
|
15
|
-
export const ALWAYS_AVAILABLE_API_TOOL_NAMES = ["get_resource"];
|
|
16
|
-
export function createAgentTools(customComponentsDir_1, apiBasedTools_1) {
|
|
17
|
-
return __awaiter(this, arguments, void 0, function* (customComponentsDir, apiBasedTools, pluginCustomFolderPaths = []) {
|
|
18
|
-
return [
|
|
19
|
-
...ALWAYS_AVAILABLE_API_TOOL_NAMES.map((toolName) => {
|
|
20
|
-
const apiBasedTool = apiBasedTools[toolName];
|
|
21
|
-
if (!apiBasedTool) {
|
|
22
|
-
throw new Error(`Required base API tool "${toolName}" is missing.`);
|
|
23
|
-
}
|
|
24
|
-
return createApiTool(toolName, apiBasedTool);
|
|
25
|
-
}),
|
|
26
|
-
createGetUserLocationTool(),
|
|
27
|
-
createNavigateUserTool(),
|
|
28
|
-
yield createFetchSkillTool(customComponentsDir, pluginCustomFolderPaths),
|
|
29
|
-
yield createFetchToolSchemaTool(apiBasedTools),
|
|
30
|
-
];
|
|
31
|
-
});
|
|
32
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export interface AgentSkillManifest {
|
|
2
|
-
directoryName: string;
|
|
3
|
-
name: string;
|
|
4
|
-
description: string;
|
|
5
|
-
instructions: string;
|
|
6
|
-
}
|
|
7
|
-
export declare function getProjectSkillsDirectoryPath(customComponentsDir: string): string;
|
|
8
|
-
export declare function listProjectSkillManifests(customComponentsDir: string, pluginCustomFolderPaths?: string[]): Promise<AgentSkillManifest[]>;
|
|
9
|
-
export declare function listSkillManifests(customComponentsDir: string, pluginCustomFolderPaths?: string[]): Promise<AgentSkillManifest[]>;
|
|
10
|
-
export declare function loadSkillManifest(skillName: string, customComponentsDir: string, pluginCustomFolderPaths?: string[]): Promise<AgentSkillManifest | null>;
|
|
11
|
-
export declare function loadSkillMarkdown(skillName: string, customComponentsDir: string, pluginCustomFolderPaths?: string[]): Promise<string | null>;
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { readdir, readFile } from "fs/promises";
|
|
11
|
-
import path from "path";
|
|
12
|
-
import { parse as parseYaml } from "yaml";
|
|
13
|
-
const SKILL_MARKDOWN_FILENAME = "SKILL.md";
|
|
14
|
-
const SKILL_FRONTMATTER_SEPARATOR = "\n---\n";
|
|
15
|
-
function normalizePluginSkillDirectoryPaths(pluginCustomFolderPaths = []) {
|
|
16
|
-
return Array.from(new Set(pluginCustomFolderPaths
|
|
17
|
-
.map((pluginCustomFolderPath) => path.resolve(pluginCustomFolderPath, "skills"))));
|
|
18
|
-
}
|
|
19
|
-
function parseSkillManifest(directoryName, markdown) {
|
|
20
|
-
var _a, _b;
|
|
21
|
-
const [frontmatterBlock, instructions = ""] = markdown.split("\r\n").join("\n").split(SKILL_FRONTMATTER_SEPARATOR, 2);
|
|
22
|
-
const metadata = parseYaml(frontmatterBlock);
|
|
23
|
-
return {
|
|
24
|
-
directoryName,
|
|
25
|
-
name: (_a = metadata.name) !== null && _a !== void 0 ? _a : directoryName,
|
|
26
|
-
description: (_b = metadata.description) !== null && _b !== void 0 ? _b : "",
|
|
27
|
-
instructions: instructions.trim(),
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function readSkillManifest(skillsDirectoryPath, directoryName) {
|
|
31
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
const markdown = yield readFile(path.join(skillsDirectoryPath, directoryName, SKILL_MARKDOWN_FILENAME), "utf8");
|
|
33
|
-
return parseSkillManifest(directoryName, markdown);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
function listDirectorySkillManifests(skillsDirectoryPath) {
|
|
37
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
try {
|
|
39
|
-
const entries = yield readdir(skillsDirectoryPath, { withFileTypes: true });
|
|
40
|
-
return yield Promise.all(entries
|
|
41
|
-
.filter((entry) => entry.isDirectory())
|
|
42
|
-
.map((entry) => entry.name)
|
|
43
|
-
.sort()
|
|
44
|
-
.map((directoryName) => readSkillManifest(skillsDirectoryPath, directoryName)));
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
if (error.code === "ENOENT") {
|
|
48
|
-
return [];
|
|
49
|
-
}
|
|
50
|
-
throw error;
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
function mergeSkillManifests(skillGroups) {
|
|
55
|
-
return Array.from(new Map(skillGroups.flat().map((skill) => [
|
|
56
|
-
`${skill.name}:${skill.directoryName}`,
|
|
57
|
-
skill,
|
|
58
|
-
])).values());
|
|
59
|
-
}
|
|
60
|
-
export function getProjectSkillsDirectoryPath(customComponentsDir) {
|
|
61
|
-
return path.resolve(customComponentsDir, "skills");
|
|
62
|
-
}
|
|
63
|
-
function getProjectSkillDirectoryPaths(customComponentsDir, pluginCustomFolderPaths = []) {
|
|
64
|
-
return Array.from(new Set([
|
|
65
|
-
getProjectSkillsDirectoryPath(customComponentsDir),
|
|
66
|
-
...normalizePluginSkillDirectoryPaths(pluginCustomFolderPaths),
|
|
67
|
-
]));
|
|
68
|
-
}
|
|
69
|
-
export function listProjectSkillManifests(customComponentsDir_1) {
|
|
70
|
-
return __awaiter(this, arguments, void 0, function* (customComponentsDir, pluginCustomFolderPaths = []) {
|
|
71
|
-
return mergeSkillManifests(yield Promise.all(getProjectSkillDirectoryPaths(customComponentsDir, pluginCustomFolderPaths).map(listDirectorySkillManifests)));
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
export function listSkillManifests(customComponentsDir_1) {
|
|
75
|
-
return __awaiter(this, arguments, void 0, function* (customComponentsDir, pluginCustomFolderPaths = []) {
|
|
76
|
-
return yield listProjectSkillManifests(customComponentsDir, pluginCustomFolderPaths);
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
export function loadSkillManifest(skillName_1, customComponentsDir_1) {
|
|
80
|
-
return __awaiter(this, arguments, void 0, function* (skillName, customComponentsDir, pluginCustomFolderPaths = []) {
|
|
81
|
-
var _a;
|
|
82
|
-
const manifests = yield listSkillManifests(customComponentsDir, pluginCustomFolderPaths);
|
|
83
|
-
return ((_a = manifests.find((manifest) => manifest.name === skillName || manifest.directoryName === skillName)) !== null && _a !== void 0 ? _a : null);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
export function loadSkillMarkdown(skillName_1, customComponentsDir_1) {
|
|
87
|
-
return __awaiter(this, arguments, void 0, function* (skillName, customComponentsDir, pluginCustomFolderPaths = []) {
|
|
88
|
-
const manifest = yield loadSkillManifest(skillName, customComponentsDir, pluginCustomFolderPaths);
|
|
89
|
-
if (!manifest) {
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
const directories = [
|
|
93
|
-
...getProjectSkillDirectoryPaths(customComponentsDir, pluginCustomFolderPaths),
|
|
94
|
-
];
|
|
95
|
-
for (const skillsDirectoryPath of directories) {
|
|
96
|
-
try {
|
|
97
|
-
return yield readFile(path.join(skillsDirectoryPath, manifest.directoryName, SKILL_MARKDOWN_FILENAME), "utf8");
|
|
98
|
-
}
|
|
99
|
-
catch (error) {
|
|
100
|
-
if (error.code !== "ENOENT") {
|
|
101
|
-
throw error;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return null;
|
|
106
|
-
});
|
|
107
|
-
}
|