opc-agent 3.0.1 → 4.0.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.
Files changed (151) hide show
  1. package/README.md +30 -24
  2. package/dist/channels/dingtalk.d.ts +17 -0
  3. package/dist/channels/dingtalk.js +38 -0
  4. package/dist/channels/googlechat.d.ts +14 -0
  5. package/dist/channels/googlechat.js +37 -0
  6. package/dist/channels/imessage.d.ts +13 -0
  7. package/dist/channels/imessage.js +28 -0
  8. package/dist/channels/irc.d.ts +20 -0
  9. package/dist/channels/irc.js +71 -0
  10. package/dist/channels/line.d.ts +14 -0
  11. package/dist/channels/line.js +28 -0
  12. package/dist/channels/matrix.d.ts +15 -0
  13. package/dist/channels/matrix.js +28 -0
  14. package/dist/channels/mattermost.d.ts +18 -0
  15. package/dist/channels/mattermost.js +49 -0
  16. package/dist/channels/msteams.d.ts +14 -0
  17. package/dist/channels/msteams.js +28 -0
  18. package/dist/channels/nostr.d.ts +14 -0
  19. package/dist/channels/nostr.js +28 -0
  20. package/dist/channels/qq.d.ts +15 -0
  21. package/dist/channels/qq.js +28 -0
  22. package/dist/channels/signal.d.ts +14 -0
  23. package/dist/channels/signal.js +28 -0
  24. package/dist/channels/sms.d.ts +15 -0
  25. package/dist/channels/sms.js +28 -0
  26. package/dist/channels/twitch.d.ts +17 -0
  27. package/dist/channels/twitch.js +59 -0
  28. package/dist/channels/voice-call.d.ts +27 -0
  29. package/dist/channels/voice-call.js +82 -0
  30. package/dist/channels/whatsapp.d.ts +14 -0
  31. package/dist/channels/whatsapp.js +28 -0
  32. package/dist/cli.js +36 -0
  33. package/dist/core/api-server.d.ts +25 -0
  34. package/dist/core/api-server.js +286 -0
  35. package/dist/core/audio.d.ts +50 -0
  36. package/dist/core/audio.js +68 -0
  37. package/dist/core/context-discovery.d.ts +16 -0
  38. package/dist/core/context-discovery.js +107 -0
  39. package/dist/core/context-refs.d.ts +29 -0
  40. package/dist/core/context-refs.js +162 -0
  41. package/dist/core/gateway.d.ts +53 -0
  42. package/dist/core/gateway.js +80 -0
  43. package/dist/core/heartbeat.d.ts +19 -0
  44. package/dist/core/heartbeat.js +50 -0
  45. package/dist/core/hooks.d.ts +28 -0
  46. package/dist/core/hooks.js +82 -0
  47. package/dist/core/ide-bridge.d.ts +53 -0
  48. package/dist/core/ide-bridge.js +97 -0
  49. package/dist/core/node-network.d.ts +23 -0
  50. package/dist/core/node-network.js +77 -0
  51. package/dist/core/profiles.d.ts +27 -0
  52. package/dist/core/profiles.js +131 -0
  53. package/dist/core/sandbox.d.ts +25 -0
  54. package/dist/core/sandbox.js +84 -1
  55. package/dist/core/session-manager.d.ts +33 -0
  56. package/dist/core/session-manager.js +157 -0
  57. package/dist/core/vision.d.ts +45 -0
  58. package/dist/core/vision.js +177 -0
  59. package/dist/index.d.ts +64 -1
  60. package/dist/index.js +86 -3
  61. package/dist/memory/context-compressor.d.ts +43 -0
  62. package/dist/memory/context-compressor.js +167 -0
  63. package/dist/memory/index.d.ts +4 -0
  64. package/dist/memory/index.js +5 -1
  65. package/dist/memory/user-profiler.d.ts +50 -0
  66. package/dist/memory/user-profiler.js +201 -0
  67. package/dist/schema/oad.d.ts +12 -12
  68. package/dist/security/approvals.d.ts +53 -0
  69. package/dist/security/approvals.js +115 -0
  70. package/dist/security/elevated.d.ts +41 -0
  71. package/dist/security/elevated.js +89 -0
  72. package/dist/security/index.d.ts +6 -0
  73. package/dist/security/index.js +7 -1
  74. package/dist/security/secrets.d.ts +34 -0
  75. package/dist/security/secrets.js +115 -0
  76. package/dist/tools/builtin/browser.d.ts +47 -0
  77. package/dist/tools/builtin/browser.js +284 -0
  78. package/dist/tools/builtin/home-assistant.d.ts +12 -0
  79. package/dist/tools/builtin/home-assistant.js +126 -0
  80. package/dist/tools/builtin/index.d.ts +6 -1
  81. package/dist/tools/builtin/index.js +18 -2
  82. package/dist/tools/builtin/rl-tools.d.ts +13 -0
  83. package/dist/tools/builtin/rl-tools.js +228 -0
  84. package/dist/tools/builtin/vision.d.ts +6 -0
  85. package/dist/tools/builtin/vision.js +61 -0
  86. package/package.json +2 -2
  87. package/src/channels/dingtalk.ts +46 -0
  88. package/src/channels/googlechat.ts +42 -0
  89. package/src/channels/imessage.ts +32 -0
  90. package/src/channels/irc.ts +82 -0
  91. package/src/channels/line.ts +33 -0
  92. package/src/channels/matrix.ts +34 -0
  93. package/src/channels/mattermost.ts +57 -0
  94. package/src/channels/msteams.ts +33 -0
  95. package/src/channels/nostr.ts +33 -0
  96. package/src/channels/qq.ts +34 -0
  97. package/src/channels/signal.ts +33 -0
  98. package/src/channels/sms.ts +34 -0
  99. package/src/channels/twitch.ts +65 -0
  100. package/src/channels/voice-call.ts +100 -0
  101. package/src/channels/whatsapp.ts +33 -0
  102. package/src/cli.ts +40 -0
  103. package/src/core/api-server.ts +277 -0
  104. package/src/core/audio.ts +98 -0
  105. package/src/core/context-discovery.ts +85 -0
  106. package/src/core/context-refs.ts +140 -0
  107. package/src/core/gateway.ts +106 -0
  108. package/src/core/heartbeat.ts +51 -0
  109. package/src/core/hooks.ts +105 -0
  110. package/src/core/ide-bridge.ts +133 -0
  111. package/src/core/node-network.ts +86 -0
  112. package/src/core/profiles.ts +122 -0
  113. package/src/core/sandbox.ts +100 -0
  114. package/src/core/session-manager.ts +137 -0
  115. package/src/core/vision.ts +180 -0
  116. package/src/index.ts +84 -1
  117. package/src/memory/context-compressor.ts +189 -0
  118. package/src/memory/index.ts +4 -0
  119. package/src/memory/user-profiler.ts +215 -0
  120. package/src/security/approvals.ts +143 -0
  121. package/src/security/elevated.ts +105 -0
  122. package/src/security/index.ts +6 -0
  123. package/src/security/secrets.ts +129 -0
  124. package/src/tools/builtin/browser.ts +299 -0
  125. package/src/tools/builtin/home-assistant.ts +116 -0
  126. package/src/tools/builtin/index.ts +9 -2
  127. package/src/tools/builtin/rl-tools.ts +243 -0
  128. package/src/tools/builtin/vision.ts +64 -0
  129. package/tests/api-server.test.ts +148 -0
  130. package/tests/approvals.test.ts +89 -0
  131. package/tests/audio.test.ts +40 -0
  132. package/tests/browser.test.ts +179 -0
  133. package/tests/builtin-tools.test.ts +83 -83
  134. package/tests/channels-extra.test.ts +45 -0
  135. package/tests/context-compressor.test.ts +172 -0
  136. package/tests/context-refs.test.ts +121 -0
  137. package/tests/elevated.test.ts +69 -0
  138. package/tests/gateway.test.ts +63 -71
  139. package/tests/home-assistant.test.ts +40 -0
  140. package/tests/hooks.test.ts +79 -0
  141. package/tests/ide-bridge.test.ts +38 -0
  142. package/tests/node-network.test.ts +74 -0
  143. package/tests/profiles.test.ts +61 -0
  144. package/tests/rl-tools.test.ts +93 -0
  145. package/tests/sandbox-manager.test.ts +46 -0
  146. package/tests/secrets.test.ts +107 -0
  147. package/tests/tools/builtin-extended.test.ts +138 -138
  148. package/tests/user-profiler.test.ts +169 -0
  149. package/tests/v090-features.test.ts +254 -0
  150. package/tests/vision.test.ts +61 -0
  151. package/tests/voice-call.test.ts +47 -0
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ /**
3
+ * Approvals Module - v1.0.0
4
+ * Policy-based exec approval system with queue, expiry, history, and callbacks.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.ExecApprovalManager = void 0;
8
+ const crypto_1 = require("crypto");
9
+ class ExecApprovalManager {
10
+ policy;
11
+ pending = new Map();
12
+ history = [];
13
+ allowedCommands = new Set();
14
+ expiryMs;
15
+ onRequestCallback;
16
+ expiryTimer;
17
+ constructor(options = {}) {
18
+ this.policy = options.policy ?? 'elevated-only';
19
+ this.expiryMs = options.expiryMs ?? 300_000; // 5 min default
20
+ this.onRequestCallback = options.onRequest;
21
+ if (options.allowedCommands) {
22
+ for (const cmd of options.allowedCommands)
23
+ this.allowedCommands.add(cmd);
24
+ }
25
+ this.expiryTimer = setInterval(() => this.expirePending(), 10_000);
26
+ if (this.expiryTimer.unref)
27
+ this.expiryTimer.unref();
28
+ }
29
+ getPolicy() { return this.policy; }
30
+ setPolicy(p) { this.policy = p; }
31
+ addAllowedCommand(cmd) { this.allowedCommands.add(cmd); }
32
+ removeAllowedCommand(cmd) { this.allowedCommands.delete(cmd); }
33
+ getAllowedCommands() { return [...this.allowedCommands]; }
34
+ needsApproval(command, elevated) {
35
+ switch (this.policy) {
36
+ case 'never': return false;
37
+ case 'always': return true;
38
+ case 'elevated-only': return elevated;
39
+ case 'allowlist': return !this.isAllowed(command);
40
+ }
41
+ }
42
+ isAllowed(command) {
43
+ for (const allowed of this.allowedCommands) {
44
+ if (command.startsWith(allowed) || command === allowed)
45
+ return true;
46
+ }
47
+ return false;
48
+ }
49
+ request(command, elevated = false) {
50
+ const now = Date.now();
51
+ const req = {
52
+ id: (0, crypto_1.randomUUID)(),
53
+ command,
54
+ elevated,
55
+ requestedAt: now,
56
+ expiresAt: now + this.expiryMs,
57
+ status: 'pending',
58
+ };
59
+ this.pending.set(req.id, req);
60
+ this.onRequestCallback?.(req);
61
+ return req;
62
+ }
63
+ approve(id, approver) {
64
+ const req = this.pending.get(id);
65
+ if (!req)
66
+ throw new Error(`Request ${id} not found`);
67
+ if (req.status !== 'pending')
68
+ throw new Error(`Request ${id} already ${req.status}`);
69
+ req.status = 'approved';
70
+ req.approvedBy = approver;
71
+ this.pending.delete(id);
72
+ this.history.push({ request: req, resolvedAt: Date.now() });
73
+ return req;
74
+ }
75
+ deny(id, approver, reason) {
76
+ const req = this.pending.get(id);
77
+ if (!req)
78
+ throw new Error(`Request ${id} not found`);
79
+ if (req.status !== 'pending')
80
+ throw new Error(`Request ${id} already ${req.status}`);
81
+ req.status = 'denied';
82
+ req.approvedBy = approver;
83
+ req.reason = reason;
84
+ this.pending.delete(id);
85
+ this.history.push({ request: req, resolvedAt: Date.now() });
86
+ return req;
87
+ }
88
+ getPending() {
89
+ return [...this.pending.values()];
90
+ }
91
+ getHistory() {
92
+ return [...this.history];
93
+ }
94
+ getRequest(id) {
95
+ return this.pending.get(id) ?? this.history.find(h => h.request.id === id)?.request;
96
+ }
97
+ expirePending() {
98
+ const now = Date.now();
99
+ for (const [id, req] of this.pending) {
100
+ if (now >= req.expiresAt) {
101
+ req.status = 'expired';
102
+ this.pending.delete(id);
103
+ this.history.push({ request: req, resolvedAt: now });
104
+ }
105
+ }
106
+ }
107
+ /** Force expire check (for testing) */
108
+ checkExpiry() { this.expirePending(); }
109
+ destroy() {
110
+ if (this.expiryTimer)
111
+ clearInterval(this.expiryTimer);
112
+ }
113
+ }
114
+ exports.ExecApprovalManager = ExecApprovalManager;
115
+ //# sourceMappingURL=approvals.js.map
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Elevated Permissions Module - v1.0.0
3
+ * Elevation mode management with allowed commands, auto-revoke, and audit log.
4
+ */
5
+ export type ElevationMode = 'off' | 'ask' | 'on';
6
+ export interface ElevationAuditEntry {
7
+ timestamp: number;
8
+ action: 'elevate' | 'revoke' | 'execute' | 'deny';
9
+ command?: string;
10
+ reason?: string;
11
+ }
12
+ export declare class ElevatedManager {
13
+ private mode;
14
+ private elevated;
15
+ private allowedCommands;
16
+ private auditLog;
17
+ private revokeTimer?;
18
+ private autoRevokeMs;
19
+ constructor(options?: {
20
+ mode?: ElevationMode;
21
+ allowedCommands?: (string | RegExp)[];
22
+ autoRevokeMs?: number;
23
+ });
24
+ getMode(): ElevationMode;
25
+ setMode(mode: ElevationMode): void;
26
+ isElevated(): boolean;
27
+ addAllowedCommand(pattern: string | RegExp): void;
28
+ isCommandAllowed(command: string): boolean;
29
+ elevate(reason?: string): boolean;
30
+ revoke(reason?: string): void;
31
+ canExecute(command: string): {
32
+ allowed: boolean;
33
+ needsElevation: boolean;
34
+ };
35
+ getAuditLog(): ElevationAuditEntry[];
36
+ clearAuditLog(): void;
37
+ private startAutoRevoke;
38
+ private clearAutoRevoke;
39
+ destroy(): void;
40
+ }
41
+ //# sourceMappingURL=elevated.d.ts.map
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ /**
3
+ * Elevated Permissions Module - v1.0.0
4
+ * Elevation mode management with allowed commands, auto-revoke, and audit log.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.ElevatedManager = void 0;
8
+ class ElevatedManager {
9
+ mode;
10
+ elevated = false;
11
+ allowedCommands = [];
12
+ auditLog = [];
13
+ revokeTimer;
14
+ autoRevokeMs;
15
+ constructor(options = {}) {
16
+ this.mode = options.mode ?? 'ask';
17
+ this.autoRevokeMs = options.autoRevokeMs ?? 600_000; // 10 min
18
+ if (options.allowedCommands) {
19
+ for (const cmd of options.allowedCommands) {
20
+ this.allowedCommands.push(cmd instanceof RegExp ? cmd : new RegExp(`^${cmd.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}$`));
21
+ }
22
+ }
23
+ }
24
+ getMode() { return this.mode; }
25
+ setMode(mode) { this.mode = mode; }
26
+ isElevated() { return this.elevated; }
27
+ addAllowedCommand(pattern) {
28
+ this.allowedCommands.push(pattern instanceof RegExp ? pattern : new RegExp(`^${pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}$`));
29
+ }
30
+ isCommandAllowed(command) {
31
+ return this.allowedCommands.some(r => r.test(command));
32
+ }
33
+ elevate(reason) {
34
+ if (this.mode === 'off')
35
+ return false;
36
+ this.elevated = true;
37
+ this.auditLog.push({ timestamp: Date.now(), action: 'elevate', reason });
38
+ this.startAutoRevoke();
39
+ return true;
40
+ }
41
+ revoke(reason) {
42
+ this.elevated = false;
43
+ this.clearAutoRevoke();
44
+ this.auditLog.push({ timestamp: Date.now(), action: 'revoke', reason });
45
+ }
46
+ canExecute(command) {
47
+ if (this.isCommandAllowed(command))
48
+ return { allowed: true, needsElevation: false };
49
+ if (this.mode === 'off')
50
+ return { allowed: true, needsElevation: false };
51
+ if (this.mode === 'on') {
52
+ if (!this.elevated)
53
+ this.elevate('auto-on mode');
54
+ this.auditLog.push({ timestamp: Date.now(), action: 'execute', command });
55
+ return { allowed: true, needsElevation: false };
56
+ }
57
+ // ask mode
58
+ if (this.elevated) {
59
+ this.auditLog.push({ timestamp: Date.now(), action: 'execute', command });
60
+ return { allowed: true, needsElevation: false };
61
+ }
62
+ return { allowed: false, needsElevation: true };
63
+ }
64
+ getAuditLog() {
65
+ return [...this.auditLog];
66
+ }
67
+ clearAuditLog() {
68
+ this.auditLog = [];
69
+ }
70
+ startAutoRevoke() {
71
+ this.clearAutoRevoke();
72
+ this.revokeTimer = setTimeout(() => {
73
+ this.revoke('auto-revoke timer');
74
+ }, this.autoRevokeMs);
75
+ if (this.revokeTimer.unref)
76
+ this.revokeTimer.unref();
77
+ }
78
+ clearAutoRevoke() {
79
+ if (this.revokeTimer) {
80
+ clearTimeout(this.revokeTimer);
81
+ this.revokeTimer = undefined;
82
+ }
83
+ }
84
+ destroy() {
85
+ this.clearAutoRevoke();
86
+ }
87
+ }
88
+ exports.ElevatedManager = ElevatedManager;
89
+ //# sourceMappingURL=elevated.js.map
@@ -1,4 +1,10 @@
1
1
  export { ApprovalManager } from './approval';
2
2
  export type { ApprovalPolicy, ApprovalRequest } from './approval';
3
3
  export { KeyManager } from './keys';
4
+ export { ExecApprovalManager } from './approvals';
5
+ export type { ExecApprovalPolicy, ExecApprovalRequest, ExecApprovalHistory, ApprovalRequestCallback } from './approvals';
6
+ export { ElevatedManager } from './elevated';
7
+ export type { ElevationMode, ElevationAuditEntry } from './elevated';
8
+ export { SecretsManager } from './secrets';
9
+ export type { SecretsStore } from './secrets';
4
10
  //# sourceMappingURL=index.d.ts.map
@@ -1,8 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KeyManager = exports.ApprovalManager = void 0;
3
+ exports.SecretsManager = exports.ElevatedManager = exports.ExecApprovalManager = exports.KeyManager = exports.ApprovalManager = void 0;
4
4
  var approval_1 = require("./approval");
5
5
  Object.defineProperty(exports, "ApprovalManager", { enumerable: true, get: function () { return approval_1.ApprovalManager; } });
6
6
  var keys_1 = require("./keys");
7
7
  Object.defineProperty(exports, "KeyManager", { enumerable: true, get: function () { return keys_1.KeyManager; } });
8
+ var approvals_1 = require("./approvals");
9
+ Object.defineProperty(exports, "ExecApprovalManager", { enumerable: true, get: function () { return approvals_1.ExecApprovalManager; } });
10
+ var elevated_1 = require("./elevated");
11
+ Object.defineProperty(exports, "ElevatedManager", { enumerable: true, get: function () { return elevated_1.ElevatedManager; } });
12
+ var secrets_1 = require("./secrets");
13
+ Object.defineProperty(exports, "SecretsManager", { enumerable: true, get: function () { return secrets_1.SecretsManager; } });
8
14
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Secrets Manager - v1.0.0
3
+ * AES-256-GCM encrypted secrets storage with rotation, export/import.
4
+ */
5
+ export interface SecretsStore {
6
+ version: number;
7
+ secrets: Record<string, string>;
8
+ }
9
+ export declare class SecretsManager {
10
+ private masterKey;
11
+ private filePath;
12
+ private store;
13
+ constructor(options: {
14
+ password: string;
15
+ filePath?: string;
16
+ });
17
+ private init;
18
+ private load;
19
+ private save;
20
+ set(key: string, value: string): void;
21
+ get(key: string): string | undefined;
22
+ delete(key: string): boolean;
23
+ list(): string[];
24
+ has(key: string): boolean;
25
+ /** Inject secrets into env-like object */
26
+ inject(env: Record<string, string | undefined>, keys?: string[]): Record<string, string | undefined>;
27
+ /** Rotate: re-encrypt with new password */
28
+ rotate(newPassword: string): void;
29
+ /** Export as encrypted buffer */
30
+ exportEncrypted(): Buffer;
31
+ /** Import from encrypted buffer (must know password) */
32
+ static importEncrypted(data: Buffer, password: string, filePath: string): SecretsManager;
33
+ }
34
+ //# sourceMappingURL=secrets.d.ts.map
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ /**
3
+ * Secrets Manager - v1.0.0
4
+ * AES-256-GCM encrypted secrets storage with rotation, export/import.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.SecretsManager = void 0;
8
+ const crypto_1 = require("crypto");
9
+ const fs_1 = require("fs");
10
+ const path_1 = require("path");
11
+ const os_1 = require("os");
12
+ const ALGORITHM = 'aes-256-gcm';
13
+ const KEY_LEN = 32;
14
+ const IV_LEN = 12;
15
+ const SALT_LEN = 16;
16
+ const TAG_LEN = 16;
17
+ class SecretsManager {
18
+ masterKey;
19
+ filePath;
20
+ store;
21
+ constructor(options) {
22
+ this.filePath = options.filePath ?? (0, path_1.join)((0, os_1.homedir)(), '.opc', 'secrets.enc');
23
+ // Derive a stable key from password (we store salt in the file)
24
+ this.masterKey = Buffer.alloc(KEY_LEN); // placeholder, set on load/init
25
+ this.store = { version: 1, secrets: {} };
26
+ this.init(options.password);
27
+ }
28
+ init(password) {
29
+ if ((0, fs_1.existsSync)(this.filePath)) {
30
+ this.load(password);
31
+ }
32
+ else {
33
+ const salt = (0, crypto_1.randomBytes)(SALT_LEN);
34
+ this.masterKey = (0, crypto_1.scryptSync)(password, salt, KEY_LEN);
35
+ this.store = { version: 1, secrets: {} };
36
+ this.save(salt);
37
+ }
38
+ }
39
+ load(password) {
40
+ const data = (0, fs_1.readFileSync)(this.filePath);
41
+ const salt = data.subarray(0, SALT_LEN);
42
+ const iv = data.subarray(SALT_LEN, SALT_LEN + IV_LEN);
43
+ const tag = data.subarray(SALT_LEN + IV_LEN, SALT_LEN + IV_LEN + TAG_LEN);
44
+ const encrypted = data.subarray(SALT_LEN + IV_LEN + TAG_LEN);
45
+ this.masterKey = (0, crypto_1.scryptSync)(password, salt, KEY_LEN);
46
+ const decipher = (0, crypto_1.createDecipheriv)(ALGORITHM, this.masterKey, iv);
47
+ decipher.setAuthTag(tag);
48
+ const decrypted = Buffer.concat([decipher.update(encrypted), decipher.final()]);
49
+ this.store = JSON.parse(decrypted.toString('utf8'));
50
+ }
51
+ save(salt) {
52
+ const dir = (0, path_1.dirname)(this.filePath);
53
+ if (!(0, fs_1.existsSync)(dir))
54
+ (0, fs_1.mkdirSync)(dir, { recursive: true });
55
+ if (!salt && (0, fs_1.existsSync)(this.filePath)) {
56
+ salt = (0, fs_1.readFileSync)(this.filePath).subarray(0, SALT_LEN);
57
+ }
58
+ if (!salt)
59
+ salt = (0, crypto_1.randomBytes)(SALT_LEN);
60
+ const iv = (0, crypto_1.randomBytes)(IV_LEN);
61
+ const cipher = (0, crypto_1.createCipheriv)(ALGORITHM, this.masterKey, iv);
62
+ const encrypted = Buffer.concat([cipher.update(JSON.stringify(this.store), 'utf8'), cipher.final()]);
63
+ const tag = cipher.getAuthTag();
64
+ (0, fs_1.writeFileSync)(this.filePath, Buffer.concat([salt, iv, tag, encrypted]));
65
+ }
66
+ set(key, value) {
67
+ this.store.secrets[key] = value;
68
+ this.save();
69
+ }
70
+ get(key) {
71
+ return this.store.secrets[key];
72
+ }
73
+ delete(key) {
74
+ if (!(key in this.store.secrets))
75
+ return false;
76
+ delete this.store.secrets[key];
77
+ this.save();
78
+ return true;
79
+ }
80
+ list() {
81
+ return Object.keys(this.store.secrets);
82
+ }
83
+ has(key) {
84
+ return key in this.store.secrets;
85
+ }
86
+ /** Inject secrets into env-like object */
87
+ inject(env, keys) {
88
+ const toInject = keys ?? this.list();
89
+ for (const k of toInject) {
90
+ if (this.has(k))
91
+ env[k] = this.store.secrets[k];
92
+ }
93
+ return env;
94
+ }
95
+ /** Rotate: re-encrypt with new password */
96
+ rotate(newPassword) {
97
+ const salt = (0, crypto_1.randomBytes)(SALT_LEN);
98
+ this.masterKey = (0, crypto_1.scryptSync)(newPassword, salt, KEY_LEN);
99
+ this.save(salt);
100
+ }
101
+ /** Export as encrypted buffer */
102
+ exportEncrypted() {
103
+ return (0, fs_1.readFileSync)(this.filePath);
104
+ }
105
+ /** Import from encrypted buffer (must know password) */
106
+ static importEncrypted(data, password, filePath) {
107
+ const dir = (0, path_1.dirname)(filePath);
108
+ if (!(0, fs_1.existsSync)(dir))
109
+ (0, fs_1.mkdirSync)(dir, { recursive: true });
110
+ (0, fs_1.writeFileSync)(filePath, data);
111
+ return new SecretsManager({ password, filePath });
112
+ }
113
+ }
114
+ exports.SecretsManager = SecretsManager;
115
+ //# sourceMappingURL=secrets.js.map
@@ -0,0 +1,47 @@
1
+ import type { MCPTool } from '../mcp';
2
+ export declare class BrowserManager {
3
+ private browser;
4
+ private page;
5
+ private lastActivity;
6
+ private idleTimer;
7
+ private playwrightFactory;
8
+ constructor(playwrightFactory?: () => any);
9
+ private resetIdleTimer;
10
+ ensureBrowser(): Promise<any>;
11
+ navigate(url: string): Promise<{
12
+ title: string;
13
+ text: string;
14
+ url: string;
15
+ }>;
16
+ click(selector: string): Promise<void>;
17
+ type(selector: string, text: string): Promise<void>;
18
+ screenshot(): Promise<string>;
19
+ extract(): Promise<{
20
+ text: string;
21
+ links: string[];
22
+ images: string[];
23
+ }>;
24
+ scroll(direction: 'up' | 'down', amount?: number): Promise<void>;
25
+ back(): Promise<void>;
26
+ evaluate(script: string): Promise<any>;
27
+ getImages(): Promise<Array<{
28
+ src: string;
29
+ alt: string;
30
+ }>>;
31
+ waitFor(selector: string, timeout?: number): Promise<boolean>;
32
+ close(): Promise<void>;
33
+ }
34
+ declare const browserManager: BrowserManager;
35
+ export declare const browserNavigateTool: MCPTool;
36
+ export declare const browserClickTool: MCPTool;
37
+ export declare const browserTypeTool: MCPTool;
38
+ export declare const browserScreenshotTool: MCPTool;
39
+ export declare const browserExtractTool: MCPTool;
40
+ export declare const browserScrollTool: MCPTool;
41
+ export declare const browserBackTool: MCPTool;
42
+ export declare const browserEvalTool: MCPTool;
43
+ export declare const browserGetImagesTool: MCPTool;
44
+ export declare const browserWaitTool: MCPTool;
45
+ export declare const browserTools: MCPTool[];
46
+ export { browserManager };
47
+ //# sourceMappingURL=browser.d.ts.map