opc-agent 4.0.0 → 4.0.1
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 +404 -80
- package/README.zh-CN.md +82 -0
- package/dist/cli/chat.d.ts +2 -0
- package/dist/cli/chat.js +134 -0
- package/dist/cli/setup.d.ts +4 -0
- package/dist/cli/setup.js +303 -0
- package/dist/cli.js +106 -6
- package/dist/hub/brain-seed.d.ts +14 -0
- package/dist/hub/brain-seed.js +77 -0
- package/dist/hub/client.d.ts +25 -0
- package/dist/hub/client.js +44 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +12 -3
- package/dist/providers/index.d.ts +1 -1
- package/dist/providers/index.js +54 -1
- package/dist/scheduler/cron-engine.d.ts +41 -0
- package/dist/scheduler/cron-engine.js +200 -0
- package/dist/scheduler/index.d.ts +3 -0
- package/dist/scheduler/index.js +7 -0
- package/dist/skills/builtin/index.d.ts +6 -0
- package/dist/skills/builtin/index.js +402 -0
- package/dist/skills/marketplace.d.ts +30 -0
- package/dist/skills/marketplace.js +142 -0
- package/dist/skills/types.d.ts +34 -0
- package/dist/skills/types.js +16 -0
- package/dist/studio/server.d.ts +25 -0
- package/dist/studio/server.js +780 -0
- package/dist/studio/templates-data.d.ts +21 -0
- package/dist/studio/templates-data.js +148 -0
- package/dist/studio-ui/index.html +2502 -1073
- package/dist/tools/builtin/index.d.ts +1 -0
- package/dist/tools/builtin/index.js +7 -2
- package/dist/tools/builtin/web-search.d.ts +9 -0
- package/dist/tools/builtin/web-search.js +150 -0
- package/dist/tools/document-processor.d.ts +39 -0
- package/dist/tools/document-processor.js +188 -0
- package/dist/tools/image-generator.d.ts +42 -0
- package/dist/tools/image-generator.js +136 -0
- package/dist/tools/web-scraper.d.ts +20 -0
- package/dist/tools/web-scraper.js +148 -0
- package/dist/tools/web-search.d.ts +51 -0
- package/dist/tools/web-search.js +152 -0
- package/install.ps1 +154 -0
- package/install.sh +164 -0
- package/package.json +63 -52
- package/src/cli/chat.ts +99 -0
- package/src/cli/setup.ts +314 -0
- package/src/cli.ts +108 -6
- package/src/hub/brain-seed.ts +54 -0
- package/src/hub/client.ts +60 -0
- package/src/index.ts +4 -2
- package/src/providers/index.ts +64 -1
- package/src/scheduler/cron-engine.ts +191 -0
- package/src/scheduler/index.ts +2 -0
- package/src/skills/builtin/index.ts +408 -0
- package/src/skills/marketplace.ts +113 -0
- package/src/skills/types.ts +42 -0
- package/src/studio/server.ts +1591 -791
- package/src/studio/templates-data.ts +178 -0
- package/src/studio-ui/index.html +2502 -1073
- package/src/tools/builtin/index.ts +37 -35
- package/src/tools/builtin/web-search.ts +126 -0
- package/src/tools/document-processor.ts +213 -0
- package/src/tools/image-generator.ts +150 -0
- package/src/tools/web-scraper.ts +179 -0
- package/src/tools/web-search.ts +180 -0
- package/tests/cron-engine.test.ts +101 -0
- package/tests/document-processor.test.ts +69 -0
- package/tests/e2e-nocode.test.ts +442 -0
- package/tests/image-generator.test.ts +84 -0
- package/tests/settings-api.test.ts +148 -0
- package/tests/setup.test.ts +73 -0
- package/tests/studio.test.ts +402 -229
- package/tests/voice-interaction.test.ts +38 -0
- package/tests/web-search.test.ts +155 -0
package/dist/cli.js
CHANGED
|
@@ -65,6 +65,8 @@ const knowledge_1 = require("./core/knowledge");
|
|
|
65
65
|
const doctor_1 = require("./doctor");
|
|
66
66
|
const child_process_1 = require("child_process");
|
|
67
67
|
const agent_workstation_1 = require("agent-workstation");
|
|
68
|
+
const client_1 = require("./hub/client");
|
|
69
|
+
const brain_seed_1 = require("./hub/brain-seed");
|
|
68
70
|
const program = new commander_1.Command();
|
|
69
71
|
const color = {
|
|
70
72
|
green: (s) => `\x1b[32m${s}\x1b[0m`,
|
|
@@ -330,9 +332,38 @@ export class EchoSkill extends BaseSkill {
|
|
|
330
332
|
return;
|
|
331
333
|
}
|
|
332
334
|
const name = opts.yes ? (nameArg ?? 'my-agent') : (nameArg ?? await promptUser('Project name', 'my-agent'));
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
335
|
+
// Try fetching templates from Hub API, fall back to bundled
|
|
336
|
+
let hubTemplates = [];
|
|
337
|
+
let useHub = false;
|
|
338
|
+
try {
|
|
339
|
+
const hubAvailable = await (0, client_1.isHubAvailable)();
|
|
340
|
+
if (hubAvailable) {
|
|
341
|
+
hubTemplates = await (0, client_1.fetchTemplates)();
|
|
342
|
+
if (hubTemplates.length > 0)
|
|
343
|
+
useHub = true;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
catch {
|
|
347
|
+
// Hub unreachable — fall back to bundled templates
|
|
348
|
+
}
|
|
349
|
+
let template;
|
|
350
|
+
let selectedHubTemplate;
|
|
351
|
+
if (opts.yes) {
|
|
352
|
+
template = opts.template ?? 'customer-service';
|
|
353
|
+
}
|
|
354
|
+
else if (opts.template) {
|
|
355
|
+
template = opts.template;
|
|
356
|
+
if (useHub)
|
|
357
|
+
selectedHubTemplate = hubTemplates.find(t => t.id === template);
|
|
358
|
+
}
|
|
359
|
+
else if (useHub) {
|
|
360
|
+
console.log(` ${icon.info} ${color.dim('Using templates from Workstation Hub')}`);
|
|
361
|
+
template = await select('Select a template:', hubTemplates.map(t => ({ value: t.id, label: `${t.name} - ${t.description}` })));
|
|
362
|
+
selectedHubTemplate = hubTemplates.find(t => t.id === template);
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
template = await select('Select a template:', Object.entries(TEMPLATES).map(([value, { label }]) => ({ value, label })));
|
|
366
|
+
}
|
|
336
367
|
const dir = path.resolve(name);
|
|
337
368
|
if (fs.existsSync(dir)) {
|
|
338
369
|
console.error(`\n${icon.error} Directory ${color.bold(name)} already exists.`);
|
|
@@ -612,6 +643,22 @@ on startup to understand the project context.
|
|
|
612
643
|
console.log(` ${icon.file} Dockerfile`);
|
|
613
644
|
console.log(` ${icon.file} README.md`);
|
|
614
645
|
console.log(`\n Template: ${color.cyan(template)}`);
|
|
646
|
+
// Download brain-seed files from Hub if available
|
|
647
|
+
if (selectedHubTemplate) {
|
|
648
|
+
try {
|
|
649
|
+
const seeds = await (0, client_1.fetchBrainSeeds)(selectedHubTemplate.id);
|
|
650
|
+
if (seeds.length > 0) {
|
|
651
|
+
const result = await (0, brain_seed_1.downloadAndLearnBrainSeeds)(dir, seeds);
|
|
652
|
+
console.log(`\n 📚 Imported ${color.bold(String(result.savedFiles.length))} knowledge files into brain-seed/`);
|
|
653
|
+
if (result.learnedCount > 0) {
|
|
654
|
+
console.log(` 🧠 Auto-learned ${color.bold(String(result.learnedCount))} files into local DeepBrain`);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
catch {
|
|
659
|
+
// Brain-seed download failed — non-fatal, project still usable
|
|
660
|
+
}
|
|
661
|
+
}
|
|
615
662
|
console.log(`\n${color.bold('Next steps:')}`);
|
|
616
663
|
console.log(` 1. cd ${name}`);
|
|
617
664
|
console.log(` 2. npm install`);
|
|
@@ -1990,13 +2037,66 @@ program
|
|
|
1990
2037
|
.command('studio')
|
|
1991
2038
|
.description('Start OPC Studio web UI')
|
|
1992
2039
|
.option('--port <port>', 'Port to listen on', '4000')
|
|
2040
|
+
.option('--no-open', 'Do not open browser automatically')
|
|
1993
2041
|
.action(async (opts) => {
|
|
1994
2042
|
const { StudioServer } = require('./studio/server');
|
|
1995
|
-
const
|
|
1996
|
-
|
|
1997
|
-
|
|
2043
|
+
const net = require('net');
|
|
2044
|
+
const port = parseInt(opts.port, 10);
|
|
2045
|
+
const checkPort = (p) => new Promise((resolve) => {
|
|
2046
|
+
const sock = new net.Socket();
|
|
2047
|
+
sock.setTimeout(400);
|
|
2048
|
+
sock.once('connect', () => { sock.destroy(); resolve(true); });
|
|
2049
|
+
sock.once('error', () => { sock.destroy(); resolve(false); });
|
|
2050
|
+
sock.once('timeout', () => { sock.destroy(); resolve(false); });
|
|
2051
|
+
sock.connect(p, 'localhost');
|
|
1998
2052
|
});
|
|
2053
|
+
const server = new StudioServer({ port, agentDir: process.cwd() });
|
|
1999
2054
|
await server.start();
|
|
2055
|
+
// Try to start sub-module UI servers with graceful fallback
|
|
2056
|
+
const subModules = [
|
|
2057
|
+
{ name: 'DeepBrain', icon: '🧠', pkg: 'deepbrain', port: 4001, serveMethod: 'serveUI' },
|
|
2058
|
+
{ name: 'AgentKits', icon: '📊', pkg: 'agent-kits', port: 4002, serveMethod: 'serveUI' },
|
|
2059
|
+
{ name: 'Workstation', icon: '👤', pkg: 'agent-workstation', port: 4003, serveMethod: 'serveUI' },
|
|
2060
|
+
];
|
|
2061
|
+
const moduleStatuses = [];
|
|
2062
|
+
for (const mod of subModules) {
|
|
2063
|
+
try {
|
|
2064
|
+
const already = await checkPort(mod.port);
|
|
2065
|
+
if (already) {
|
|
2066
|
+
moduleStatuses.push(` ${icon.success} ${mod.icon} ${mod.name} already running on :${mod.port}`);
|
|
2067
|
+
continue;
|
|
2068
|
+
}
|
|
2069
|
+
const modExports = require(mod.pkg);
|
|
2070
|
+
if (typeof modExports[mod.serveMethod] === 'function') {
|
|
2071
|
+
modExports[mod.serveMethod]({ port: mod.port });
|
|
2072
|
+
await new Promise(r => setTimeout(r, 600));
|
|
2073
|
+
const started = await checkPort(mod.port);
|
|
2074
|
+
moduleStatuses.push(started
|
|
2075
|
+
? ` ${icon.success} ${mod.icon} ${mod.name} started on :${mod.port}`
|
|
2076
|
+
: ` ${icon.warn} ${mod.icon} ${mod.name} failed to start`);
|
|
2077
|
+
}
|
|
2078
|
+
else {
|
|
2079
|
+
moduleStatuses.push(` ${color.dim('○')} ${mod.icon} ${mod.name} no serve method`);
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
catch {
|
|
2083
|
+
moduleStatuses.push(` ${color.dim('○')} ${mod.icon} ${mod.name} not installed`);
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
if (moduleStatuses.length > 0) {
|
|
2087
|
+
console.log('\nModules:');
|
|
2088
|
+
moduleStatuses.forEach(s => console.log(s));
|
|
2089
|
+
}
|
|
2090
|
+
const url = `http://localhost:${port}`;
|
|
2091
|
+
console.log(`\n${icon.success} OPC Studio ready → ${color.cyan(url)}`);
|
|
2092
|
+
if (opts.open !== false) {
|
|
2093
|
+
try {
|
|
2094
|
+
const { exec } = require('child_process');
|
|
2095
|
+
const openCmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start ""' : 'xdg-open';
|
|
2096
|
+
exec(`${openCmd} ${url}`);
|
|
2097
|
+
}
|
|
2098
|
+
catch { }
|
|
2099
|
+
}
|
|
2000
2100
|
console.log(color.dim('Press Ctrl+C to stop'));
|
|
2001
2101
|
});
|
|
2002
2102
|
program
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brain-seed downloader and auto-learner.
|
|
3
|
+
* Downloads brain-seed files from Hub and optionally imports into DeepBrain.
|
|
4
|
+
*/
|
|
5
|
+
import type { HubBrainSeed } from './client';
|
|
6
|
+
export interface BrainSeedResult {
|
|
7
|
+
savedFiles: string[];
|
|
8
|
+
learnedCount: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Save brain-seed files to disk and optionally auto-learn into DeepBrain.
|
|
12
|
+
*/
|
|
13
|
+
export declare function downloadAndLearnBrainSeeds(projectDir: string, seeds: HubBrainSeed[]): Promise<BrainSeedResult>;
|
|
14
|
+
//# sourceMappingURL=brain-seed.d.ts.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Brain-seed downloader and auto-learner.
|
|
4
|
+
* Downloads brain-seed files from Hub and optionally imports into DeepBrain.
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.downloadAndLearnBrainSeeds = downloadAndLearnBrainSeeds;
|
|
41
|
+
const fs = __importStar(require("fs"));
|
|
42
|
+
const path = __importStar(require("path"));
|
|
43
|
+
/**
|
|
44
|
+
* Save brain-seed files to disk and optionally auto-learn into DeepBrain.
|
|
45
|
+
*/
|
|
46
|
+
async function downloadAndLearnBrainSeeds(projectDir, seeds) {
|
|
47
|
+
if (!seeds || seeds.length === 0) {
|
|
48
|
+
return { savedFiles: [], learnedCount: 0 };
|
|
49
|
+
}
|
|
50
|
+
const seedDir = path.join(projectDir, 'brain-seed');
|
|
51
|
+
fs.mkdirSync(seedDir, { recursive: true });
|
|
52
|
+
const savedFiles = [];
|
|
53
|
+
for (const seed of seeds) {
|
|
54
|
+
const filePath = path.join(seedDir, seed.filename);
|
|
55
|
+
fs.writeFileSync(filePath, seed.content, 'utf-8');
|
|
56
|
+
savedFiles.push(seed.filename);
|
|
57
|
+
}
|
|
58
|
+
// Try auto-learn into DeepBrain (optional dependency)
|
|
59
|
+
let learnedCount = 0;
|
|
60
|
+
try {
|
|
61
|
+
const { Brain } = require('deepbrain');
|
|
62
|
+
const brain = new Brain({ database: path.join(projectDir, 'data', 'brain.db') });
|
|
63
|
+
for (const seed of seeds) {
|
|
64
|
+
await brain.learn(seed.content, {
|
|
65
|
+
slug: `brain-seed/${seed.filename.replace(/\.md$/, '')}`,
|
|
66
|
+
title: `Brain Seed: ${seed.tier}`,
|
|
67
|
+
namespace: `seed/${seed.tier}`,
|
|
68
|
+
});
|
|
69
|
+
learnedCount++;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
// deepbrain not installed — that's fine, files are saved
|
|
74
|
+
}
|
|
75
|
+
return { savedFiles, learnedCount };
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=brain-seed.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workstation Hub API client
|
|
3
|
+
* Fetches agent templates and brain-seed knowledge from the Hub.
|
|
4
|
+
*/
|
|
5
|
+
export interface HubTemplate {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
category: string;
|
|
10
|
+
tags?: string[];
|
|
11
|
+
}
|
|
12
|
+
export interface HubTemplateDetail extends HubTemplate {
|
|
13
|
+
files: Record<string, string>;
|
|
14
|
+
brainSeeds: HubBrainSeed[];
|
|
15
|
+
}
|
|
16
|
+
export interface HubBrainSeed {
|
|
17
|
+
filename: string;
|
|
18
|
+
content: string;
|
|
19
|
+
tier: 'industry' | 'job' | 'workstation';
|
|
20
|
+
}
|
|
21
|
+
export declare function fetchTemplates(query?: string): Promise<HubTemplate[]>;
|
|
22
|
+
export declare function fetchTemplate(id: string): Promise<HubTemplateDetail>;
|
|
23
|
+
export declare function fetchBrainSeeds(templateId: string): Promise<HubBrainSeed[]>;
|
|
24
|
+
export declare function isHubAvailable(): Promise<boolean>;
|
|
25
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Workstation Hub API client
|
|
4
|
+
* Fetches agent templates and brain-seed knowledge from the Hub.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.fetchTemplates = fetchTemplates;
|
|
8
|
+
exports.fetchTemplate = fetchTemplate;
|
|
9
|
+
exports.fetchBrainSeeds = fetchBrainSeeds;
|
|
10
|
+
exports.isHubAvailable = isHubAvailable;
|
|
11
|
+
const HUB_URL = process.env.OPC_HUB_URL || 'https://hub.deepleaper.com';
|
|
12
|
+
const HUB_TIMEOUT = 5000;
|
|
13
|
+
async function hubFetch(path) {
|
|
14
|
+
const controller = new AbortController();
|
|
15
|
+
const timer = setTimeout(() => controller.abort(), HUB_TIMEOUT);
|
|
16
|
+
try {
|
|
17
|
+
const res = await fetch(`${HUB_URL}${path}`, {
|
|
18
|
+
signal: controller.signal,
|
|
19
|
+
headers: { 'Accept': 'application/json', 'User-Agent': 'opc-agent/2.0' },
|
|
20
|
+
});
|
|
21
|
+
if (!res.ok)
|
|
22
|
+
throw new Error(`Hub API ${res.status} ${res.statusText}`);
|
|
23
|
+
return (await res.json());
|
|
24
|
+
}
|
|
25
|
+
finally {
|
|
26
|
+
clearTimeout(timer);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async function fetchTemplates(query) {
|
|
30
|
+
const qs = query ? `?q=${encodeURIComponent(query)}` : '';
|
|
31
|
+
return hubFetch(`/api/templates${qs}`);
|
|
32
|
+
}
|
|
33
|
+
async function fetchTemplate(id) {
|
|
34
|
+
return hubFetch(`/api/templates/${encodeURIComponent(id)}`);
|
|
35
|
+
}
|
|
36
|
+
async function fetchBrainSeeds(templateId) {
|
|
37
|
+
return hubFetch(`/api/templates/${encodeURIComponent(templateId)}/brain-seeds`);
|
|
38
|
+
}
|
|
39
|
+
function isHubAvailable() {
|
|
40
|
+
return hubFetch('/api/health')
|
|
41
|
+
.then(() => true)
|
|
42
|
+
.catch(() => false);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=client.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -137,7 +137,9 @@ export { SubAgentManager } from './core/subagent';
|
|
|
137
137
|
export type { SubAgentConfig, SubAgentResult } from './core/subagent';
|
|
138
138
|
export { Scheduler, parseCron, cronMatches } from './core/scheduler';
|
|
139
139
|
export type { CronJob, JobHandler } from './core/scheduler';
|
|
140
|
-
export { getBuiltinTools, getBuiltinToolsByName, rlTools, homeAssistantTools, configureHomeAssistant } from './tools/builtin';
|
|
140
|
+
export { getBuiltinTools, getBuiltinToolsByName, rlTools, homeAssistantTools, configureHomeAssistant, webSearchTools, webSearchTool, webReadTool } from './tools/builtin';
|
|
141
|
+
export { webSearch, parseDuckDuckGoHTML, type SearchResult as WebSearchResult, type WebSearchConfig, type SearchEngine } from './tools/web-search';
|
|
142
|
+
export { scrapeUrl, extractReadableContent, type ScrapedContent } from './tools/web-scraper';
|
|
141
143
|
export { MCPClient } from './tools/mcp-client';
|
|
142
144
|
export type { MCPServerConfig } from './tools/mcp-client';
|
|
143
145
|
export { AgentPackager, AgentPublisher, AgentInstaller } from './publish';
|
|
@@ -184,7 +186,7 @@ export type { SMSChannelConfig } from './channels/sms';
|
|
|
184
186
|
export { VoiceCallManager } from './channels/voice-call';
|
|
185
187
|
export type { VoiceCallConfig } from './channels/voice-call';
|
|
186
188
|
export { IDEBridge } from './core/ide-bridge';
|
|
187
|
-
export type { IDEConfig, Diagnostic, TextEdit, Range, SearchOptions, SearchResult } from './core/ide-bridge';
|
|
189
|
+
export type { IDEConfig, Diagnostic, TextEdit, Range, SearchOptions, SearchResult as IDESearchResult } from './core/ide-bridge';
|
|
188
190
|
export { NodeNetwork } from './core/node-network';
|
|
189
191
|
export type { RemoteNode } from './core/node-network';
|
|
190
192
|
export { Gateway } from './core/gateway';
|
package/dist/index.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.KnowledgeBase = exports.addMessages = exports.detectLocale = exports.getLocale = exports.setLocale = exports.t = exports.LazyLoader = exports.RequestBatcher = exports.ConnectionPool = exports.VersionManager = exports.WebhookChannel = exports.createVoiceProviders = exports.ElevenLabsTTSProvider = exports.OpenAITTSProvider = exports.EdgeTTSProvider = exports.DeepgramSTTProvider = exports.WhisperSTTProvider = exports.VoiceChannel = exports.HITLManager = exports.AgentCardRegistry = exports.AgentRegistry = exports.parseOADWorkflow = exports.WorkflowBuilder = exports.GraphWorkflowEngine = exports.WorkflowEngine = exports.Analytics = exports.KeyManager = exports.ApprovalManager = exports.Sandbox = exports.PluginManager = exports.createMCPTool = exports.MCPToolRegistry = exports.Room = exports.SUPPORTED_PROVIDERS = exports.createProvider = exports.DeepBrainMemoryStore = exports.InMemoryStore = exports.SkillRegistry = exports.BaseSkill = exports.WebSocketChannel = exports.TelegramChannel = exports.WebChannel = exports.BaseChannel = exports.OADSchema = exports.validateOAD = exports.loadOAD = exports.Logger = exports.truncateOutput = exports.AgentRuntime = exports.BaseAgent = void 0;
|
|
4
4
|
exports.detectInjection = exports.sanitizeInput = exports.formatErrorForUser = exports.wrapError = exports.TimeoutError = exports.SecurityError = exports.RateLimitError = exports.PluginError = exports.ChannelError = exports.ConfigError = exports.ValidationError = exports.ProviderError = exports.OPCError = exports.createTeacherConfig = exports.createDataAnalystConfig = exports.getSupportedLocales = exports.LLMCache = exports.RateLimiter = exports.AnalyticsEngine = exports.formatReport = exports.loadTestCases = exports.runTests = exports.parseSkillMarkdown = exports.skillToMarkdown = exports.SkillLearner = exports.DocumentSkill = exports.SchedulerSkill = exports.HeartbeatManager = exports.SessionManager = exports.ContextDiscovery = exports.IRCChannel = exports.TwitchChannel = exports.GoogleChatChannel = exports.MattermostChannel = exports.DingTalkChannel = exports.WebhookTriggerSkill = exports.HttpSkill = exports.TextAnalysisTool = exports.JsonTransformTool = exports.DateTimeTool = exports.CalculatorTool = exports.WeChatChannel = exports.SlackChannel = exports.EmailChannel = exports.compose = exports.AgentPipeline = exports.Orchestrator = exports.getActiveSessions = exports.createAuthMiddleware = exports.deployToHermes = void 0;
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
7
|
-
exports.getIntegrationTool = exports.getAllIntegrationTools = exports.TranslatorTool = exports.SummarizerTool = exports.CSVAnalyzerTool = exports.PDFReaderTool = exports.ImageGenerationTool = exports.NpmTool = exports.GitTool = exports.CodeExecutionTool = exports.VectorSearchTool = exports.DatabaseTool = exports.WebScraperTool = void 0;
|
|
5
|
+
exports.scrapeUrl = exports.parseDuckDuckGoHTML = exports.webSearch = exports.webReadTool = exports.webSearchTool = exports.webSearchTools = exports.configureHomeAssistant = exports.homeAssistantTools = exports.rlTools = exports.getBuiltinToolsByName = exports.getBuiltinTools = exports.cronMatches = exports.parseCron = exports.Scheduler = exports.SubAgentManager = exports.generateSpanId = exports.generateTraceId = exports.OTLPHttpExporter = exports.FileExporter = exports.ConsoleExporter = exports.Tracer = exports.DeepBrainExporter = exports.TraceConsoleExporter = exports.TraceCollector = exports.StreamableResponse = exports.StreamingManager = exports.ToolGateway = exports.ProcessWatcher = exports.DiscordChannel = exports.FeishuChannel = exports.AudioProcessor = exports.ALL_HOOK_EVENTS = exports.HookManager = exports.SecretsManager = exports.ElevatedManager = exports.ExecApprovalManager = exports.createGuardrailsFromConfig = exports.GuardrailManager = exports.createContentFilterPlugin = exports.contentFilterPlugin = exports.createEnhancedRateLimiterPlugin = exports.rateLimiterPlugin = exports.loggerPlugin = exports.createRateLimitPlugin = exports.createAnalyticsPlugin = exports.createLoggingPlugin = exports.inputValidation = exports.APIKeyManager = exports.corsMiddleware = exports.securityHeaders = void 0;
|
|
6
|
+
exports.EmailSendTool = exports.SlackTool = exports.ProfileManager = exports.SandboxManager = exports.Gateway = exports.NodeNetwork = exports.IDEBridge = exports.VoiceCallManager = exports.SMSChannel = exports.NostrChannel = exports.QQChannel = exports.MSTeamsChannel = exports.LINEChannel = exports.IMessageChannel = exports.MatrixChannel = exports.SignalChannel = exports.WhatsAppChannel = exports.visionCompareTool = exports.visionExtractTextTool = exports.visionAnalyzeTool = exports.visionTools = exports.detectMimeType = exports.VisionManager = exports.ContextRefResolver = exports.APIServer = exports.ConversationProtocol = exports.SharedContext = exports.HierarchyPattern = exports.PipelinePattern = exports.VotingPattern = exports.DebatePattern = exports.isValidEventType = exports.AGUI_EVENT_TYPES = exports.AGUIClient = exports.AGUIEventEmitter = exports.AGUIServer = exports.AgentEvaluator = exports.agentToMCPResources = exports.agentToMCPTools = exports.MCPServer = exports.JSON_RPC_ERRORS = exports.oadToAgentCard = exports.A2AClient = exports.A2AServer = exports.StudioServer = exports.AgentInstaller = exports.AgentPublisher = exports.AgentPackager = exports.MCPClient = exports.extractReadableContent = void 0;
|
|
7
|
+
exports.getIntegrationTool = exports.getAllIntegrationTools = exports.TranslatorTool = exports.SummarizerTool = exports.CSVAnalyzerTool = exports.PDFReaderTool = exports.ImageGenerationTool = exports.NpmTool = exports.GitTool = exports.CodeExecutionTool = exports.VectorSearchTool = exports.DatabaseTool = exports.WebScraperTool = exports.WebSearchTool = exports.TrelloTool = exports.CalendarTool = exports.JiraTool = exports.GitHubTool = exports.NotionTool = exports.WebhookTool = void 0;
|
|
8
8
|
// OPC Agent — Open Agent Framework
|
|
9
9
|
var agent_1 = require("./core/agent");
|
|
10
10
|
Object.defineProperty(exports, "BaseAgent", { enumerable: true, get: function () { return agent_1.BaseAgent; } });
|
|
@@ -254,6 +254,15 @@ Object.defineProperty(exports, "getBuiltinToolsByName", { enumerable: true, get:
|
|
|
254
254
|
Object.defineProperty(exports, "rlTools", { enumerable: true, get: function () { return builtin_1.rlTools; } });
|
|
255
255
|
Object.defineProperty(exports, "homeAssistantTools", { enumerable: true, get: function () { return builtin_1.homeAssistantTools; } });
|
|
256
256
|
Object.defineProperty(exports, "configureHomeAssistant", { enumerable: true, get: function () { return builtin_1.configureHomeAssistant; } });
|
|
257
|
+
Object.defineProperty(exports, "webSearchTools", { enumerable: true, get: function () { return builtin_1.webSearchTools; } });
|
|
258
|
+
Object.defineProperty(exports, "webSearchTool", { enumerable: true, get: function () { return builtin_1.webSearchTool; } });
|
|
259
|
+
Object.defineProperty(exports, "webReadTool", { enumerable: true, get: function () { return builtin_1.webReadTool; } });
|
|
260
|
+
var web_search_1 = require("./tools/web-search");
|
|
261
|
+
Object.defineProperty(exports, "webSearch", { enumerable: true, get: function () { return web_search_1.webSearch; } });
|
|
262
|
+
Object.defineProperty(exports, "parseDuckDuckGoHTML", { enumerable: true, get: function () { return web_search_1.parseDuckDuckGoHTML; } });
|
|
263
|
+
var web_scraper_1 = require("./tools/web-scraper");
|
|
264
|
+
Object.defineProperty(exports, "scrapeUrl", { enumerable: true, get: function () { return web_scraper_1.scrapeUrl; } });
|
|
265
|
+
Object.defineProperty(exports, "extractReadableContent", { enumerable: true, get: function () { return web_scraper_1.extractReadableContent; } });
|
|
257
266
|
var mcp_client_1 = require("./tools/mcp-client");
|
|
258
267
|
Object.defineProperty(exports, "MCPClient", { enumerable: true, get: function () { return mcp_client_1.MCPClient; } });
|
|
259
268
|
// v1.6.0 — publish/pack/install
|
|
@@ -9,5 +9,5 @@ export interface LLMProvider {
|
|
|
9
9
|
chatStream(messages: Message[], systemPrompt?: string): AsyncIterable<string>;
|
|
10
10
|
}
|
|
11
11
|
export declare function createProvider(name?: string, model?: string, baseUrl?: string, apiKey?: string): LLMProvider;
|
|
12
|
-
export declare const SUPPORTED_PROVIDERS: readonly ["openai", "ollama", "deepseek", "qwen", "gemini", "dashscope", "zhipu", "moonshot"];
|
|
12
|
+
export declare const SUPPORTED_PROVIDERS: readonly ["openai", "ollama", "claude-cli", "deepseek", "qwen", "gemini", "dashscope", "zhipu", "moonshot"];
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/providers/index.js
CHANGED
|
@@ -323,8 +323,61 @@ function isGeminiNative() {
|
|
|
323
323
|
const key = getApiKey();
|
|
324
324
|
return key.startsWith('AQ.') || (baseUrl.includes('googleapis.com') && !baseUrl.includes('/openai'));
|
|
325
325
|
}
|
|
326
|
+
class ClaudeCLIProvider {
|
|
327
|
+
name = 'claude-cli';
|
|
328
|
+
model;
|
|
329
|
+
constructor(model) {
|
|
330
|
+
this.model = model || 'sonnet';
|
|
331
|
+
}
|
|
332
|
+
async chat(messages, systemPrompt, options) {
|
|
333
|
+
const { execFile } = await Promise.resolve().then(() => __importStar(require('child_process')));
|
|
334
|
+
const { promisify } = await Promise.resolve().then(() => __importStar(require('util')));
|
|
335
|
+
const execFileAsync = promisify(execFile);
|
|
336
|
+
// Build the prompt from messages
|
|
337
|
+
const lastMessage = messages[messages.length - 1];
|
|
338
|
+
if (!lastMessage)
|
|
339
|
+
return '';
|
|
340
|
+
let prompt = lastMessage.content;
|
|
341
|
+
// Add tool prompt if tools provided
|
|
342
|
+
if (options?.tools && options.tools.length > 0) {
|
|
343
|
+
prompt += buildToolPrompt(options.tools);
|
|
344
|
+
}
|
|
345
|
+
const args = ['--print'];
|
|
346
|
+
if (systemPrompt) {
|
|
347
|
+
args.push('--system-prompt', systemPrompt);
|
|
348
|
+
}
|
|
349
|
+
if (this.model) {
|
|
350
|
+
args.push('--model', this.model);
|
|
351
|
+
}
|
|
352
|
+
args.push(prompt);
|
|
353
|
+
try {
|
|
354
|
+
const { stdout } = await execFileAsync('claude', args, {
|
|
355
|
+
timeout: 120_000,
|
|
356
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
357
|
+
env: { ...process.env },
|
|
358
|
+
});
|
|
359
|
+
return stdout.trim();
|
|
360
|
+
}
|
|
361
|
+
catch (err) {
|
|
362
|
+
if (err.code === 'ENOENT') {
|
|
363
|
+
throw new Error('Claude CLI not found. Install it: npm install -g @anthropic-ai/claude-code\n' +
|
|
364
|
+
'Then authenticate: claude login');
|
|
365
|
+
}
|
|
366
|
+
throw new Error(`Claude CLI error: ${err.message}`);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
async *chatStream(messages, systemPrompt) {
|
|
370
|
+
// Claude CLI --print doesn't support streaming well, so we do single-shot
|
|
371
|
+
const result = await this.chat(messages, systemPrompt);
|
|
372
|
+
yield result;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
326
375
|
function createProvider(name = 'openai', model, baseUrl, apiKey) {
|
|
327
376
|
const finalModel = model || process.env.OPC_LLM_MODEL || 'gpt-4o-mini';
|
|
377
|
+
// Claude CLI mode: use local claude command (Claude Max/Pro subscription)
|
|
378
|
+
if (name === 'claude-cli' || process.env.OPC_LLM_PROVIDER === 'claude-cli') {
|
|
379
|
+
return new ClaudeCLIProvider(finalModel !== 'gpt-4o-mini' ? finalModel : undefined);
|
|
380
|
+
}
|
|
328
381
|
if (name === 'ollama') {
|
|
329
382
|
const ollamaBase = baseUrl || process.env.OPC_LLM_BASE_URL || 'http://localhost:11434/v1';
|
|
330
383
|
const ollamaKey = apiKey || process.env.OPC_LLM_API_KEY || 'ollama';
|
|
@@ -344,5 +397,5 @@ function createProvider(name = 'openai', model, baseUrl, apiKey) {
|
|
|
344
397
|
}
|
|
345
398
|
return new OpenAICompatibleProvider(resolvedName, finalModel, baseUrl, apiKey);
|
|
346
399
|
}
|
|
347
|
-
exports.SUPPORTED_PROVIDERS = ['openai', 'ollama', 'deepseek', 'qwen', 'gemini', 'dashscope', 'zhipu', 'moonshot'];
|
|
400
|
+
exports.SUPPORTED_PROVIDERS = ['openai', 'ollama', 'claude-cli', 'deepseek', 'qwen', 'gemini', 'dashscope', 'zhipu', 'moonshot'];
|
|
348
401
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cron Engine — persistent scheduler with file-based storage.
|
|
3
|
+
* Manages scheduled tasks with cron expressions, persists to ~/.opc/schedules.json,
|
|
4
|
+
* and auto-recovers on startup.
|
|
5
|
+
*/
|
|
6
|
+
import type { JobHandler } from '../core/scheduler';
|
|
7
|
+
export interface ScheduleTask {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
schedule: string;
|
|
11
|
+
description: string;
|
|
12
|
+
frequency: 'daily' | 'weekly' | 'monthly' | 'custom';
|
|
13
|
+
time?: string;
|
|
14
|
+
outputChannel: 'telegram' | 'email' | 'web';
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
updatedAt: string;
|
|
18
|
+
lastRun?: string;
|
|
19
|
+
nextRun?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface SchedulesStore {
|
|
22
|
+
tasks: ScheduleTask[];
|
|
23
|
+
}
|
|
24
|
+
/** Convert frequency + time to cron expression */
|
|
25
|
+
export declare function frequencyToCron(frequency: string, time?: string): string;
|
|
26
|
+
export declare class CronEngine {
|
|
27
|
+
private scheduler;
|
|
28
|
+
private store;
|
|
29
|
+
private handler;
|
|
30
|
+
constructor(handler?: JobHandler);
|
|
31
|
+
/** Initialize and recover persisted tasks */
|
|
32
|
+
start(): void;
|
|
33
|
+
stop(): void;
|
|
34
|
+
listTasks(): ScheduleTask[];
|
|
35
|
+
getTask(id: string): ScheduleTask | undefined;
|
|
36
|
+
createTask(input: Omit<ScheduleTask, 'id' | 'createdAt' | 'updatedAt' | 'lastRun' | 'nextRun'>): ScheduleTask;
|
|
37
|
+
updateTask(id: string, updates: Partial<ScheduleTask>): ScheduleTask | null;
|
|
38
|
+
deleteTask(id: string): boolean;
|
|
39
|
+
runTask(id: string): Promise<boolean>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=cron-engine.d.ts.map
|