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.
Files changed (75) hide show
  1. package/README.md +404 -80
  2. package/README.zh-CN.md +82 -0
  3. package/dist/cli/chat.d.ts +2 -0
  4. package/dist/cli/chat.js +134 -0
  5. package/dist/cli/setup.d.ts +4 -0
  6. package/dist/cli/setup.js +303 -0
  7. package/dist/cli.js +106 -6
  8. package/dist/hub/brain-seed.d.ts +14 -0
  9. package/dist/hub/brain-seed.js +77 -0
  10. package/dist/hub/client.d.ts +25 -0
  11. package/dist/hub/client.js +44 -0
  12. package/dist/index.d.ts +4 -2
  13. package/dist/index.js +12 -3
  14. package/dist/providers/index.d.ts +1 -1
  15. package/dist/providers/index.js +74 -1
  16. package/dist/scheduler/cron-engine.d.ts +41 -0
  17. package/dist/scheduler/cron-engine.js +200 -0
  18. package/dist/scheduler/index.d.ts +3 -0
  19. package/dist/scheduler/index.js +7 -0
  20. package/dist/skills/builtin/index.d.ts +6 -0
  21. package/dist/skills/builtin/index.js +402 -0
  22. package/dist/skills/marketplace.d.ts +30 -0
  23. package/dist/skills/marketplace.js +142 -0
  24. package/dist/skills/types.d.ts +34 -0
  25. package/dist/skills/types.js +16 -0
  26. package/dist/studio/server.d.ts +25 -0
  27. package/dist/studio/server.js +780 -0
  28. package/dist/studio/templates-data.d.ts +21 -0
  29. package/dist/studio/templates-data.js +148 -0
  30. package/dist/studio-ui/index.html +2502 -1073
  31. package/dist/tools/builtin/index.d.ts +1 -0
  32. package/dist/tools/builtin/index.js +7 -2
  33. package/dist/tools/builtin/web-search.d.ts +9 -0
  34. package/dist/tools/builtin/web-search.js +150 -0
  35. package/dist/tools/document-processor.d.ts +39 -0
  36. package/dist/tools/document-processor.js +188 -0
  37. package/dist/tools/image-generator.d.ts +42 -0
  38. package/dist/tools/image-generator.js +136 -0
  39. package/dist/tools/web-scraper.d.ts +20 -0
  40. package/dist/tools/web-scraper.js +148 -0
  41. package/dist/tools/web-search.d.ts +51 -0
  42. package/dist/tools/web-search.js +152 -0
  43. package/install.ps1 +154 -0
  44. package/install.sh +164 -0
  45. package/package.json +63 -52
  46. package/src/cli/chat.ts +99 -0
  47. package/src/cli/setup.ts +314 -0
  48. package/src/cli.ts +108 -6
  49. package/src/hub/brain-seed.ts +54 -0
  50. package/src/hub/client.ts +60 -0
  51. package/src/index.ts +4 -2
  52. package/src/providers/index.ts +80 -1
  53. package/src/scheduler/cron-engine.ts +191 -0
  54. package/src/scheduler/index.ts +2 -0
  55. package/src/skills/builtin/index.ts +408 -0
  56. package/src/skills/marketplace.ts +113 -0
  57. package/src/skills/types.ts +42 -0
  58. package/src/studio/server.ts +1591 -791
  59. package/src/studio/templates-data.ts +178 -0
  60. package/src/studio-ui/index.html +2502 -1073
  61. package/src/tools/builtin/index.ts +37 -35
  62. package/src/tools/builtin/web-search.ts +126 -0
  63. package/src/tools/document-processor.ts +213 -0
  64. package/src/tools/image-generator.ts +150 -0
  65. package/src/tools/web-scraper.ts +179 -0
  66. package/src/tools/web-search.ts +180 -0
  67. package/tests/cron-engine.test.ts +101 -0
  68. package/tests/document-processor.test.ts +69 -0
  69. package/tests/e2e-nocode.test.ts +442 -0
  70. package/tests/image-generator.test.ts +84 -0
  71. package/tests/settings-api.test.ts +148 -0
  72. package/tests/setup.test.ts +73 -0
  73. package/tests/studio.test.ts +402 -229
  74. package/tests/voice-interaction.test.ts +38 -0
  75. 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
+ });