xiaozuoassistant 0.1.83 → 0.1.85
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 +3 -3
- package/dist/client/assets/{browser-ponyfill-H0YfMNGB.js → browser-ponyfill-DrkbwkRN.js} +1 -1
- package/dist/client/assets/{index-qrxxaIgT.js → index-D8n5WPwn.js} +21 -21
- package/dist/client/index.html +1 -1
- package/dist/server/agents/office.js +3 -3
- package/dist/server/config/loader.js +1 -0
- package/dist/server/core/memories/vector.js +2 -3
- package/dist/server/core/plugin-manager.js +30 -14
- package/dist/server/index.js +26 -40
- package/dist/server/{skills → plugins/core-skills/src}/create-agent.js +13 -9
- package/dist/server/{skills → plugins/core-skills/src}/delegate.js +9 -5
- package/dist/server/{skills → plugins/core-skills/src}/file-system.js +33 -23
- package/dist/server/plugins/core-skills/src/index.js +28 -0
- package/dist/server/{skills → plugins/core-skills/src}/list-agents.js +8 -4
- package/dist/server/{skills → plugins/core-skills/src}/search.js +6 -2
- package/dist/server/{skills → plugins/core-skills/src}/system-time.js +6 -2
- package/dist/server/plugins/office-skills/src/index.js +21 -0
- package/dist/server/{skills → plugins/office-skills/src}/office-excel.js +20 -12
- package/dist/server/{skills → plugins/office-skills/src}/office-ppt.js +11 -4
- package/dist/server/{skills → plugins/office-skills/src}/office-word.js +18 -10
- package/package.json +1 -1
package/dist/client/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🍇</text></svg>" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>xiaozuoAssistant</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-D8n5WPwn.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index-Be5IGwUA.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AgentRuntime } from '../core/agents/runtime.js';
|
|
2
|
-
import { ReadWordSkill, CreateWordSkill } from '../skills/office-word.js';
|
|
3
|
-
import { ReadExcelSkill, CreateExcelSkill } from '../skills/office-excel.js';
|
|
4
|
-
import { CreatePptxSkill } from '../skills/office-ppt.js';
|
|
2
|
+
import { ReadWordSkill, CreateWordSkill } from '../plugins/office-skills/src/office-word.js';
|
|
3
|
+
import { ReadExcelSkill, CreateExcelSkill } from '../plugins/office-skills/src/office-excel.js';
|
|
4
|
+
import { CreatePptxSkill } from '../plugins/office-skills/src/office-ppt.js';
|
|
5
5
|
export const createOfficeAgent = () => {
|
|
6
6
|
return new AgentRuntime({
|
|
7
7
|
name: 'office_agent',
|
|
@@ -56,10 +56,9 @@ export class VectorMemory {
|
|
|
56
56
|
// Use OpenAI compatible embedding endpoint
|
|
57
57
|
// Note: Some compatible providers might use different models/dimensions.
|
|
58
58
|
// Default to text-embedding-ada-002 or similar standard.
|
|
59
|
-
|
|
60
|
-
// We'll try to use a more standard one or catch the error.
|
|
59
|
+
const model = config.llm.embeddingModel || 'text-embedding-ada-002';
|
|
61
60
|
const response = await this.openai.embeddings.create({
|
|
62
|
-
model:
|
|
61
|
+
model: model,
|
|
63
62
|
input: text,
|
|
64
63
|
});
|
|
65
64
|
return response.data[0].embedding;
|
|
@@ -33,26 +33,42 @@ export class PluginManager {
|
|
|
33
33
|
}
|
|
34
34
|
async loadPlugins() {
|
|
35
35
|
try {
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
await
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const entries = await fs.readdir(this.pluginDir, { withFileTypes: true });
|
|
46
|
-
for (const entry of entries) {
|
|
47
|
-
if (entry.isDirectory()) {
|
|
48
|
-
await this.loadPluginFromDir(path.join(this.pluginDir, entry.name));
|
|
49
|
-
}
|
|
36
|
+
// 1. Load built-in plugins (migrated skills) from local src/plugins
|
|
37
|
+
const internalPluginDir = path.resolve(__dirname, '../plugins');
|
|
38
|
+
await this.scanAndLoad(internalPluginDir);
|
|
39
|
+
// 2. Load user plugins from configured plugin directory
|
|
40
|
+
// Only if it's different from internal directory to avoid duplicates
|
|
41
|
+
if (path.resolve(this.pluginDir) !== internalPluginDir) {
|
|
42
|
+
await this.scanAndLoad(this.pluginDir);
|
|
50
43
|
}
|
|
51
44
|
}
|
|
52
45
|
catch (error) {
|
|
53
46
|
console.error('[PluginManager] Error loading plugins:', error);
|
|
54
47
|
}
|
|
55
48
|
}
|
|
49
|
+
async scanAndLoad(dir) {
|
|
50
|
+
try {
|
|
51
|
+
await fs.access(dir);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return; // Directory doesn't exist, skip
|
|
55
|
+
}
|
|
56
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
57
|
+
for (const entry of entries) {
|
|
58
|
+
if (entry.isDirectory()) {
|
|
59
|
+
await this.loadPluginFromDir(path.join(dir, entry.name));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
getPlugins() {
|
|
64
|
+
return Array.from(this.plugins.values()).map(p => ({
|
|
65
|
+
name: p.metadata.name,
|
|
66
|
+
version: p.metadata.version,
|
|
67
|
+
description: p.metadata.description,
|
|
68
|
+
author: p.metadata.author,
|
|
69
|
+
enabled: true // Todo: Implement enable/disable persistence
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
56
72
|
async loadPluginFromDir(dirPath) {
|
|
57
73
|
try {
|
|
58
74
|
// Check for package.json or index.js/ts
|
package/dist/server/index.js
CHANGED
|
@@ -12,15 +12,10 @@ import fsPromises from 'fs/promises'; // For async file operations if needed
|
|
|
12
12
|
import crypto from 'crypto';
|
|
13
13
|
import axios from 'axios';
|
|
14
14
|
import { memory } from './core/memory.js';
|
|
15
|
-
import { skillRegistry } from './skills/registry.js';
|
|
16
|
-
import { SystemTimeSkill } from './skills/system-time.js';
|
|
17
|
-
import { SearchSkill } from './skills/search.js';
|
|
18
|
-
import { ListDirectorySkill, ReadFileSkill, WriteFileSkill, DeleteFileSkill } from './skills/file-system.js';
|
|
19
15
|
import { PluginManager } from './core/plugin-manager.js';
|
|
20
16
|
import { initScheduler, runMaintenanceNow, getSchedulerStatus, startScheduler, stopScheduler } from './core/scheduler.js';
|
|
21
17
|
import { agentManager } from './core/agents/manager.js';
|
|
22
18
|
import { createOfficeAgent } from './agents/office.js';
|
|
23
|
-
import { DelegateSkill } from './skills/delegate.js';
|
|
24
19
|
import { createChannels } from './channels/create-channels.js';
|
|
25
20
|
import { createHttpStack } from './server/create-http.js';
|
|
26
21
|
import { taskQueue } from './core/task-queue.js';
|
|
@@ -236,6 +231,7 @@ app.get('/api/config', async (req, res) => {
|
|
|
236
231
|
apiKey: config.llm.apiKey,
|
|
237
232
|
baseURL: config.llm.baseURL,
|
|
238
233
|
model: config.llm.model,
|
|
234
|
+
embeddingModel: config.llm.embeddingModel,
|
|
239
235
|
temperature: config.llm.temperature,
|
|
240
236
|
maxHistoryMessages: config.llm.maxHistoryMessages,
|
|
241
237
|
maxToolIterations: config.llm.maxToolIterations,
|
|
@@ -248,7 +244,7 @@ app.get('/api/config', async (req, res) => {
|
|
|
248
244
|
// 更新配置并写入 config.json
|
|
249
245
|
app.post('/api/config', async (req, res) => {
|
|
250
246
|
try {
|
|
251
|
-
const { userId, apiKey, baseURL, model, temperature, systemPrompt, memoryMaintenanceCron, sessionRetentionDays, workspace, maxHistoryMessages, maxToolIterations } = req.body;
|
|
247
|
+
const { userId, apiKey, baseURL, model, embeddingModel, temperature, systemPrompt, memoryMaintenanceCron, sessionRetentionDays, workspace, maxHistoryMessages, maxToolIterations } = req.body;
|
|
252
248
|
// 更新配置对象
|
|
253
249
|
const newConfig = { ...config };
|
|
254
250
|
if (userId !== undefined)
|
|
@@ -259,6 +255,8 @@ app.post('/api/config', async (req, res) => {
|
|
|
259
255
|
newConfig.llm.baseURL = baseURL;
|
|
260
256
|
if (model !== undefined)
|
|
261
257
|
newConfig.llm.model = model;
|
|
258
|
+
if (embeddingModel !== undefined)
|
|
259
|
+
newConfig.llm.embeddingModel = embeddingModel;
|
|
262
260
|
if (temperature !== undefined)
|
|
263
261
|
newConfig.llm.temperature = parseFloat(temperature);
|
|
264
262
|
if (maxHistoryMessages !== undefined)
|
|
@@ -391,20 +389,28 @@ const thirdPartySkillsMeta = {
|
|
|
391
389
|
isBuiltIn: false
|
|
392
390
|
}
|
|
393
391
|
};
|
|
394
|
-
|
|
395
|
-
app.get('/api/skills', (req, res) => {
|
|
392
|
+
app.get('/api/plugins', (req, res) => {
|
|
396
393
|
try {
|
|
397
|
-
const
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
394
|
+
const plugins = pluginManager.getPlugins();
|
|
395
|
+
// Merge with third-party auth state (WPS/Lark)
|
|
396
|
+
// Todo: This should be handled by the plugin system itself
|
|
397
|
+
const enhancedPlugins = plugins.map(p => {
|
|
398
|
+
if (p.name === 'wps_office') {
|
|
399
|
+
return { ...p, enabled: thirdPartySkillsMeta.wps_office.enabled };
|
|
400
|
+
}
|
|
401
|
+
if (p.name === 'lark_docs') {
|
|
402
|
+
return { ...p, enabled: thirdPartySkillsMeta.lark_docs.enabled };
|
|
403
|
+
}
|
|
404
|
+
return p;
|
|
405
|
+
});
|
|
406
|
+
// Add pending third-party plugins if not loaded yet
|
|
407
|
+
if (!enhancedPlugins.find(p => p.name === 'wps_office')) {
|
|
408
|
+
enhancedPlugins.push(thirdPartySkillsMeta.wps_office);
|
|
409
|
+
}
|
|
410
|
+
if (!enhancedPlugins.find(p => p.name === 'lark_docs')) {
|
|
411
|
+
enhancedPlugins.push(thirdPartySkillsMeta.lark_docs);
|
|
412
|
+
}
|
|
413
|
+
res.json(enhancedPlugins);
|
|
408
414
|
}
|
|
409
415
|
catch (e) {
|
|
410
416
|
res.status(500).json({ error: e.message });
|
|
@@ -643,30 +649,10 @@ app.delete('/api/notes/:id', async (req, res) => {
|
|
|
643
649
|
res.status(500).json({ error: e.message });
|
|
644
650
|
}
|
|
645
651
|
});
|
|
646
|
-
import { ReadWordSkill, CreateWordSkill } from './skills/office-word.js';
|
|
647
|
-
import { ReadExcelSkill, CreateExcelSkill } from './skills/office-excel.js';
|
|
648
|
-
import { CreatePptxSkill } from './skills/office-ppt.js';
|
|
649
|
-
import { CreateAgentSkill } from './skills/create-agent.js';
|
|
650
|
-
import { ListAgentsSkill } from './skills/list-agents.js';
|
|
651
652
|
// 初始化 Agents
|
|
652
653
|
agentManager.registerAgent(createOfficeAgent());
|
|
653
|
-
// 注册技能
|
|
654
|
-
skillRegistry.register(new CreateAgentSkill()); // 允许动态创建 Agent
|
|
655
|
-
skillRegistry.register(new ListAgentsSkill()); // 允许列出所有 Agent
|
|
656
|
-
skillRegistry.register(new DelegateSkill()); // 允许主 Brain 委派任务
|
|
657
|
-
skillRegistry.register(new SystemTimeSkill());
|
|
658
|
-
skillRegistry.register(new SearchSkill());
|
|
659
|
-
skillRegistry.register(new ListDirectorySkill());
|
|
660
|
-
skillRegistry.register(new ReadFileSkill());
|
|
661
|
-
skillRegistry.register(new WriteFileSkill());
|
|
662
|
-
skillRegistry.register(new DeleteFileSkill());
|
|
663
|
-
skillRegistry.register(new ReadWordSkill());
|
|
664
|
-
skillRegistry.register(new CreateWordSkill());
|
|
665
|
-
skillRegistry.register(new ReadExcelSkill());
|
|
666
|
-
skillRegistry.register(new CreateExcelSkill());
|
|
667
|
-
skillRegistry.register(new CreatePptxSkill());
|
|
668
654
|
// 初始化插件管理器
|
|
669
|
-
const pluginManager = new PluginManager(path.
|
|
655
|
+
const pluginManager = new PluginManager(path.join(process.cwd(), 'plugins'));
|
|
670
656
|
await pluginManager.loadPlugins();
|
|
671
657
|
// 初始化通道
|
|
672
658
|
const channels = createChannels({ app, io, config, pluginManager });
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreateAgentSkill = void 0;
|
|
4
|
+
const base_skill_js_1 = require("../../../skills/base-skill.js");
|
|
5
|
+
const runtime_js_1 = require("../../../core/agents/runtime.js");
|
|
6
|
+
const manager_js_1 = require("../../../core/agents/manager.js");
|
|
7
|
+
const registry_js_1 = require("../../../skills/registry.js");
|
|
8
|
+
class CreateAgentSkill extends base_skill_js_1.BaseSkill {
|
|
6
9
|
constructor() {
|
|
7
10
|
super(...arguments);
|
|
8
11
|
this.name = 'create_agent';
|
|
@@ -34,25 +37,26 @@ export class CreateAgentSkill extends BaseSkill {
|
|
|
34
37
|
};
|
|
35
38
|
}
|
|
36
39
|
async execute(args, _ctx) {
|
|
37
|
-
if (agentManager.getAgent(args.name)) {
|
|
40
|
+
if (manager_js_1.agentManager.getAgent(args.name)) {
|
|
38
41
|
return { error: `Agent '${args.name}' already exists.` };
|
|
39
42
|
}
|
|
40
43
|
const assignedSkills = [];
|
|
41
44
|
if (args.skills) {
|
|
42
45
|
for (const skillName of args.skills) {
|
|
43
|
-
const skill = skillRegistry.getSkill(skillName);
|
|
46
|
+
const skill = registry_js_1.skillRegistry.getSkill(skillName);
|
|
44
47
|
if (skill) {
|
|
45
48
|
assignedSkills.push(skill);
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
51
|
}
|
|
49
|
-
const newAgent = new AgentRuntime({
|
|
52
|
+
const newAgent = new runtime_js_1.AgentRuntime({
|
|
50
53
|
name: args.name,
|
|
51
54
|
description: args.description,
|
|
52
55
|
systemPrompt: args.systemPrompt,
|
|
53
56
|
skills: assignedSkills
|
|
54
57
|
});
|
|
55
|
-
agentManager.registerAgent(newAgent);
|
|
58
|
+
manager_js_1.agentManager.registerAgent(newAgent);
|
|
56
59
|
return { success: true, message: `Agent '${args.name}' created successfully.` };
|
|
57
60
|
}
|
|
58
61
|
}
|
|
62
|
+
exports.CreateAgentSkill = CreateAgentSkill;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DelegateSkill = void 0;
|
|
4
|
+
const base_skill_js_1 = require("../../../skills/base-skill.js");
|
|
5
|
+
const manager_js_1 = require("../../../core/agents/manager.js");
|
|
6
|
+
class DelegateSkill extends base_skill_js_1.BaseSkill {
|
|
4
7
|
constructor() {
|
|
5
8
|
super(...arguments);
|
|
6
9
|
this.name = 'delegate_task';
|
|
@@ -22,9 +25,9 @@ export class DelegateSkill extends BaseSkill {
|
|
|
22
25
|
};
|
|
23
26
|
}
|
|
24
27
|
async execute(args, _ctx) {
|
|
25
|
-
const agent = agentManager.getAgent(args.agentName);
|
|
28
|
+
const agent = manager_js_1.agentManager.getAgent(args.agentName);
|
|
26
29
|
if (!agent) {
|
|
27
|
-
return { error: `Agent '${args.agentName}' not found. Available agents: ${agentManager.getAllAgents().map(a => a.name).join(', ')}` };
|
|
30
|
+
return { error: `Agent '${args.agentName}' not found. Available agents: ${manager_js_1.agentManager.getAllAgents().map(a => a.name).join(', ')}` };
|
|
28
31
|
}
|
|
29
32
|
console.log(`[DelegateSkill] Delegating to ${args.agentName}: ${args.task}`);
|
|
30
33
|
try {
|
|
@@ -37,3 +40,4 @@ export class DelegateSkill extends BaseSkill {
|
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
42
|
}
|
|
43
|
+
exports.DelegateSkill = DelegateSkill;
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DeleteFileSkill = exports.WriteFileSkill = exports.ReadFileSkill = exports.ListDirectorySkill = void 0;
|
|
7
|
+
const base_skill_js_1 = require("../../../skills/base-skill.js");
|
|
8
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const paths_js_1 = require("../../../config/paths.js");
|
|
11
|
+
class ListDirectorySkill extends base_skill_js_1.BaseSkill {
|
|
6
12
|
constructor() {
|
|
7
13
|
super(...arguments);
|
|
8
14
|
this.name = 'fs_list_directory';
|
|
@@ -19,10 +25,10 @@ export class ListDirectorySkill extends BaseSkill {
|
|
|
19
25
|
};
|
|
20
26
|
}
|
|
21
27
|
async execute(params, ctx) {
|
|
22
|
-
const workspace = resolveSessionWorkspace(ctx);
|
|
23
|
-
const dirPath = params.path ? resolvePathWithinWorkspace(workspace, String(params.path)) : workspace;
|
|
28
|
+
const workspace = (0, paths_js_1.resolveSessionWorkspace)(ctx);
|
|
29
|
+
const dirPath = params.path ? (0, paths_js_1.resolvePathWithinWorkspace)(workspace, String(params.path)) : workspace;
|
|
24
30
|
try {
|
|
25
|
-
const files = await
|
|
31
|
+
const files = await promises_1.default.readdir(dirPath, { withFileTypes: true });
|
|
26
32
|
return files.map(file => ({
|
|
27
33
|
name: file.name,
|
|
28
34
|
type: file.isDirectory() ? 'directory' : 'file'
|
|
@@ -33,7 +39,8 @@ export class ListDirectorySkill extends BaseSkill {
|
|
|
33
39
|
}
|
|
34
40
|
}
|
|
35
41
|
}
|
|
36
|
-
|
|
42
|
+
exports.ListDirectorySkill = ListDirectorySkill;
|
|
43
|
+
class ReadFileSkill extends base_skill_js_1.BaseSkill {
|
|
37
44
|
constructor() {
|
|
38
45
|
super(...arguments);
|
|
39
46
|
this.name = 'fs_read_file';
|
|
@@ -55,11 +62,11 @@ export class ReadFileSkill extends BaseSkill {
|
|
|
55
62
|
};
|
|
56
63
|
}
|
|
57
64
|
async execute(params, ctx) {
|
|
58
|
-
const workspace = resolveSessionWorkspace(ctx);
|
|
59
|
-
const filePath = resolvePathWithinWorkspace(workspace, String(params.path));
|
|
65
|
+
const workspace = (0, paths_js_1.resolveSessionWorkspace)(ctx);
|
|
66
|
+
const filePath = (0, paths_js_1.resolvePathWithinWorkspace)(workspace, String(params.path));
|
|
60
67
|
const encoding = params.encoding || 'utf-8';
|
|
61
68
|
try {
|
|
62
|
-
const content = await
|
|
69
|
+
const content = await promises_1.default.readFile(filePath, { encoding: encoding });
|
|
63
70
|
return content;
|
|
64
71
|
}
|
|
65
72
|
catch (error) {
|
|
@@ -67,7 +74,8 @@ export class ReadFileSkill extends BaseSkill {
|
|
|
67
74
|
}
|
|
68
75
|
}
|
|
69
76
|
}
|
|
70
|
-
|
|
77
|
+
exports.ReadFileSkill = ReadFileSkill;
|
|
78
|
+
class WriteFileSkill extends base_skill_js_1.BaseSkill {
|
|
71
79
|
constructor() {
|
|
72
80
|
super(...arguments);
|
|
73
81
|
this.name = 'fs_write_file';
|
|
@@ -88,12 +96,12 @@ export class WriteFileSkill extends BaseSkill {
|
|
|
88
96
|
};
|
|
89
97
|
}
|
|
90
98
|
async execute(params, ctx) {
|
|
91
|
-
const workspace = resolveSessionWorkspace(ctx);
|
|
92
|
-
const filePath = resolvePathWithinWorkspace(workspace, String(params.path));
|
|
99
|
+
const workspace = (0, paths_js_1.resolveSessionWorkspace)(ctx);
|
|
100
|
+
const filePath = (0, paths_js_1.resolvePathWithinWorkspace)(workspace, String(params.path));
|
|
93
101
|
try {
|
|
94
102
|
// Ensure directory exists
|
|
95
|
-
await
|
|
96
|
-
await
|
|
103
|
+
await promises_1.default.mkdir(path_1.default.dirname(filePath), { recursive: true });
|
|
104
|
+
await promises_1.default.writeFile(filePath, params.content, 'utf-8');
|
|
97
105
|
return `Successfully wrote to ${filePath}`;
|
|
98
106
|
}
|
|
99
107
|
catch (error) {
|
|
@@ -101,7 +109,8 @@ export class WriteFileSkill extends BaseSkill {
|
|
|
101
109
|
}
|
|
102
110
|
}
|
|
103
111
|
}
|
|
104
|
-
|
|
112
|
+
exports.WriteFileSkill = WriteFileSkill;
|
|
113
|
+
class DeleteFileSkill extends base_skill_js_1.BaseSkill {
|
|
105
114
|
constructor() {
|
|
106
115
|
super(...arguments);
|
|
107
116
|
this.name = 'fs_delete_file';
|
|
@@ -122,16 +131,16 @@ export class DeleteFileSkill extends BaseSkill {
|
|
|
122
131
|
};
|
|
123
132
|
}
|
|
124
133
|
async execute(params, ctx) {
|
|
125
|
-
const workspace = resolveSessionWorkspace(ctx);
|
|
126
|
-
const filePath = resolvePathWithinWorkspace(workspace, String(params.path));
|
|
134
|
+
const workspace = (0, paths_js_1.resolveSessionWorkspace)(ctx);
|
|
135
|
+
const filePath = (0, paths_js_1.resolvePathWithinWorkspace)(workspace, String(params.path));
|
|
127
136
|
const recursive = params.recursive || false;
|
|
128
137
|
try {
|
|
129
|
-
const stats = await
|
|
138
|
+
const stats = await promises_1.default.stat(filePath);
|
|
130
139
|
if (stats.isDirectory()) {
|
|
131
|
-
await
|
|
140
|
+
await promises_1.default.rm(filePath, { recursive, force: true });
|
|
132
141
|
}
|
|
133
142
|
else {
|
|
134
|
-
await
|
|
143
|
+
await promises_1.default.unlink(filePath);
|
|
135
144
|
}
|
|
136
145
|
return `Successfully deleted ${filePath}`;
|
|
137
146
|
}
|
|
@@ -140,3 +149,4 @@ export class DeleteFileSkill extends BaseSkill {
|
|
|
140
149
|
}
|
|
141
150
|
}
|
|
142
151
|
}
|
|
152
|
+
exports.DeleteFileSkill = DeleteFileSkill;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const file_system_js_1 = require("./file-system.js");
|
|
4
|
+
const search_js_1 = require("./search.js");
|
|
5
|
+
const system_time_js_1 = require("./system-time.js");
|
|
6
|
+
const create_agent_js_1 = require("./create-agent.js");
|
|
7
|
+
const delegate_js_1 = require("./delegate.js");
|
|
8
|
+
const list_agents_js_1 = require("./list-agents.js");
|
|
9
|
+
const plugin = {
|
|
10
|
+
metadata: {
|
|
11
|
+
name: 'core-skills',
|
|
12
|
+
version: '1.0.0',
|
|
13
|
+
description: 'Core system skills for XiaoZuoClaw',
|
|
14
|
+
author: 'XiaoZuoClaw Team'
|
|
15
|
+
},
|
|
16
|
+
onLoad: (context) => {
|
|
17
|
+
context.registerSkill(new file_system_js_1.ListDirectorySkill());
|
|
18
|
+
context.registerSkill(new file_system_js_1.ReadFileSkill());
|
|
19
|
+
context.registerSkill(new file_system_js_1.WriteFileSkill());
|
|
20
|
+
context.registerSkill(new file_system_js_1.DeleteFileSkill());
|
|
21
|
+
context.registerSkill(new search_js_1.SearchSkill());
|
|
22
|
+
context.registerSkill(new system_time_js_1.SystemTimeSkill());
|
|
23
|
+
context.registerSkill(new create_agent_js_1.CreateAgentSkill());
|
|
24
|
+
context.registerSkill(new delegate_js_1.DelegateSkill());
|
|
25
|
+
context.registerSkill(new list_agents_js_1.ListAgentsSkill());
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
exports.default = plugin;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ListAgentsSkill = void 0;
|
|
4
|
+
const base_skill_js_1 = require("../../../skills/base-skill.js");
|
|
5
|
+
const manager_js_1 = require("../../../core/agents/manager.js");
|
|
6
|
+
class ListAgentsSkill extends base_skill_js_1.BaseSkill {
|
|
4
7
|
constructor() {
|
|
5
8
|
super(...arguments);
|
|
6
9
|
this.name = 'list_agents';
|
|
@@ -12,7 +15,7 @@ export class ListAgentsSkill extends BaseSkill {
|
|
|
12
15
|
};
|
|
13
16
|
}
|
|
14
17
|
async execute(_params, _ctx) {
|
|
15
|
-
const agents = agentManager.getAllAgents();
|
|
18
|
+
const agents = manager_js_1.agentManager.getAllAgents();
|
|
16
19
|
return {
|
|
17
20
|
agents: agents.map(a => ({
|
|
18
21
|
name: a.name,
|
|
@@ -22,3 +25,4 @@ export class ListAgentsSkill extends BaseSkill {
|
|
|
22
25
|
};
|
|
23
26
|
}
|
|
24
27
|
}
|
|
28
|
+
exports.ListAgentsSkill = ListAgentsSkill;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SearchSkill = void 0;
|
|
4
|
+
const base_skill_js_1 = require("../../../skills/base-skill.js");
|
|
5
|
+
class SearchSkill extends base_skill_js_1.BaseSkill {
|
|
3
6
|
constructor() {
|
|
4
7
|
super(...arguments);
|
|
5
8
|
this.name = 'web_search';
|
|
@@ -29,3 +32,4 @@ export class SearchSkill extends BaseSkill {
|
|
|
29
32
|
};
|
|
30
33
|
}
|
|
31
34
|
}
|
|
35
|
+
exports.SearchSkill = SearchSkill;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SystemTimeSkill = void 0;
|
|
4
|
+
const base_skill_js_1 = require("../../../skills/base-skill.js");
|
|
5
|
+
class SystemTimeSkill extends base_skill_js_1.BaseSkill {
|
|
3
6
|
constructor() {
|
|
4
7
|
super(...arguments);
|
|
5
8
|
this.name = 'get_system_time';
|
|
@@ -25,3 +28,4 @@ export class SystemTimeSkill extends BaseSkill {
|
|
|
25
28
|
return now.toISOString();
|
|
26
29
|
}
|
|
27
30
|
}
|
|
31
|
+
exports.SystemTimeSkill = SystemTimeSkill;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const office_word_js_1 = require("./office-word.js");
|
|
4
|
+
const office_excel_js_1 = require("./office-excel.js");
|
|
5
|
+
const office_ppt_js_1 = require("./office-ppt.js");
|
|
6
|
+
const plugin = {
|
|
7
|
+
metadata: {
|
|
8
|
+
name: 'office-skills',
|
|
9
|
+
version: '1.0.0',
|
|
10
|
+
description: 'Microsoft Office integration skills (Word, Excel, PowerPoint)',
|
|
11
|
+
author: 'XiaoZuoClaw Team'
|
|
12
|
+
},
|
|
13
|
+
onLoad: (context) => {
|
|
14
|
+
context.registerSkill(new office_word_js_1.ReadWordSkill());
|
|
15
|
+
context.registerSkill(new office_word_js_1.CreateWordSkill());
|
|
16
|
+
context.registerSkill(new office_excel_js_1.ReadExcelSkill());
|
|
17
|
+
context.registerSkill(new office_excel_js_1.CreateExcelSkill());
|
|
18
|
+
context.registerSkill(new office_ppt_js_1.CreatePptxSkill());
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
exports.default = plugin;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CreateExcelSkill = exports.ReadExcelSkill = void 0;
|
|
7
|
+
const base_skill_js_1 = require("../../../skills/base-skill.js");
|
|
8
|
+
const xlsx_1 = __importDefault(require("xlsx"));
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
class ReadExcelSkill extends base_skill_js_1.BaseSkill {
|
|
5
11
|
constructor() {
|
|
6
12
|
super(...arguments);
|
|
7
13
|
this.name = 'read_excel_file';
|
|
@@ -23,16 +29,16 @@ export class ReadExcelSkill extends BaseSkill {
|
|
|
23
29
|
}
|
|
24
30
|
async execute(args, _ctx) {
|
|
25
31
|
try {
|
|
26
|
-
if (!
|
|
32
|
+
if (!fs_1.default.existsSync(args.file_path)) {
|
|
27
33
|
return { error: `File not found: ${args.file_path}` };
|
|
28
34
|
}
|
|
29
|
-
const workbook =
|
|
35
|
+
const workbook = xlsx_1.default.readFile(args.file_path);
|
|
30
36
|
const sheetName = args.sheet_name || workbook.SheetNames[0];
|
|
31
37
|
if (!workbook.Sheets[sheetName]) {
|
|
32
38
|
return { error: `Sheet "${sheetName}" not found. Available sheets: ${workbook.SheetNames.join(', ')}` };
|
|
33
39
|
}
|
|
34
40
|
const sheet = workbook.Sheets[sheetName];
|
|
35
|
-
const data =
|
|
41
|
+
const data = xlsx_1.default.utils.sheet_to_json(sheet);
|
|
36
42
|
return {
|
|
37
43
|
sheet: sheetName,
|
|
38
44
|
data: data
|
|
@@ -43,7 +49,8 @@ export class ReadExcelSkill extends BaseSkill {
|
|
|
43
49
|
}
|
|
44
50
|
}
|
|
45
51
|
}
|
|
46
|
-
|
|
52
|
+
exports.ReadExcelSkill = ReadExcelSkill;
|
|
53
|
+
class CreateExcelSkill extends base_skill_js_1.BaseSkill {
|
|
47
54
|
constructor() {
|
|
48
55
|
super(...arguments);
|
|
49
56
|
this.name = 'create_excel_file';
|
|
@@ -70,11 +77,11 @@ export class CreateExcelSkill extends BaseSkill {
|
|
|
70
77
|
}
|
|
71
78
|
async execute(args, _ctx) {
|
|
72
79
|
try {
|
|
73
|
-
const workbook =
|
|
74
|
-
const sheet =
|
|
80
|
+
const workbook = xlsx_1.default.utils.book_new();
|
|
81
|
+
const sheet = xlsx_1.default.utils.json_to_sheet(args.data);
|
|
75
82
|
const sheetName = args.sheet_name || 'Sheet1';
|
|
76
|
-
|
|
77
|
-
|
|
83
|
+
xlsx_1.default.utils.book_append_sheet(workbook, sheet, sheetName);
|
|
84
|
+
xlsx_1.default.writeFile(workbook, args.file_path);
|
|
78
85
|
return { success: true, message: `Excel file created at ${args.file_path}` };
|
|
79
86
|
}
|
|
80
87
|
catch (error) {
|
|
@@ -82,3 +89,4 @@ export class CreateExcelSkill extends BaseSkill {
|
|
|
82
89
|
}
|
|
83
90
|
}
|
|
84
91
|
}
|
|
92
|
+
exports.CreateExcelSkill = CreateExcelSkill;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CreatePptxSkill = void 0;
|
|
7
|
+
const base_skill_js_1 = require("../../../skills/base-skill.js");
|
|
8
|
+
const pptxgenjs_1 = __importDefault(require("pptxgenjs"));
|
|
9
|
+
class CreatePptxSkill extends base_skill_js_1.BaseSkill {
|
|
4
10
|
constructor() {
|
|
5
11
|
super(...arguments);
|
|
6
12
|
this.name = 'create_pptx_file';
|
|
@@ -34,7 +40,7 @@ export class CreatePptxSkill extends BaseSkill {
|
|
|
34
40
|
async execute(args, _ctx) {
|
|
35
41
|
try {
|
|
36
42
|
// Handle different import styles (ESM/CJS interop)
|
|
37
|
-
const PptxGenJS =
|
|
43
|
+
const PptxGenJS = pptxgenjs_1.default.default || pptxgenjs_1.default;
|
|
38
44
|
const pres = new PptxGenJS();
|
|
39
45
|
if (args.author) {
|
|
40
46
|
pres.author = args.author;
|
|
@@ -56,3 +62,4 @@ export class CreatePptxSkill extends BaseSkill {
|
|
|
56
62
|
}
|
|
57
63
|
}
|
|
58
64
|
}
|
|
65
|
+
exports.CreatePptxSkill = CreatePptxSkill;
|