opc-agent 4.0.0 → 4.0.2
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 +74 -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 +80 -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
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
import { Readable, Writable } from 'stream';
|
|
3
|
+
import * as fs from 'fs';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import * as os from 'os';
|
|
6
|
+
|
|
7
|
+
// Mock http to control Ollama detection
|
|
8
|
+
vi.mock('http', async () => {
|
|
9
|
+
const actual = await vi.importActual<typeof import('http')>('http');
|
|
10
|
+
return { ...actual };
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
describe('setup wizard', () => {
|
|
14
|
+
const OPC_HOME = path.join(os.tmpdir(), `.opc-test-${Date.now()}`);
|
|
15
|
+
const CONFIG_PATH = path.join(OPC_HOME, 'config.json');
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
// Override HOME so setup writes to temp
|
|
19
|
+
vi.stubEnv('HOME', os.tmpdir());
|
|
20
|
+
fs.mkdirSync(OPC_HOME, { recursive: true });
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
afterEach(() => {
|
|
24
|
+
fs.rmSync(OPC_HOME, { recursive: true, force: true });
|
|
25
|
+
vi.unstubAllEnvs();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
function createMockInput(lines: string[]): Readable {
|
|
29
|
+
const input = new Readable({ read() {} });
|
|
30
|
+
// Push lines async to simulate user typing
|
|
31
|
+
let i = 0;
|
|
32
|
+
const interval = setInterval(() => {
|
|
33
|
+
if (i < lines.length) {
|
|
34
|
+
input.push(lines[i] + '\n');
|
|
35
|
+
i++;
|
|
36
|
+
} else {
|
|
37
|
+
input.push(null);
|
|
38
|
+
clearInterval(interval);
|
|
39
|
+
}
|
|
40
|
+
}, 50);
|
|
41
|
+
return input;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function createMockOutput(): Writable {
|
|
45
|
+
const chunks: Buffer[] = [];
|
|
46
|
+
const output = new Writable({
|
|
47
|
+
write(chunk, _enc, cb) { chunks.push(Buffer.from(chunk)); cb(); },
|
|
48
|
+
});
|
|
49
|
+
(output as any).getOutput = () => Buffer.concat(chunks).toString();
|
|
50
|
+
return output;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
it('should export runSetup function', async () => {
|
|
54
|
+
const { runSetup } = await import('../src/cli/setup');
|
|
55
|
+
expect(typeof runSetup).toBe('function');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('should have TEMPLATES defined', async () => {
|
|
59
|
+
// Just test that the module loads without error
|
|
60
|
+
const mod = await import('../src/cli/setup');
|
|
61
|
+
expect(mod).toBeDefined();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('createRL should return a readline interface', async () => {
|
|
65
|
+
const { createRL } = await import('../src/cli/setup');
|
|
66
|
+
const input = new Readable({ read() {} });
|
|
67
|
+
const output = createMockOutput();
|
|
68
|
+
const rl = createRL(input, output);
|
|
69
|
+
expect(rl).toBeDefined();
|
|
70
|
+
rl.close();
|
|
71
|
+
input.destroy();
|
|
72
|
+
});
|
|
73
|
+
});
|