opc-agent 3.0.1 → 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 -74
- package/README.zh-CN.md +82 -0
- package/dist/channels/dingtalk.d.ts +17 -0
- package/dist/channels/dingtalk.js +38 -0
- package/dist/channels/googlechat.d.ts +14 -0
- package/dist/channels/googlechat.js +37 -0
- package/dist/channels/imessage.d.ts +13 -0
- package/dist/channels/imessage.js +28 -0
- package/dist/channels/irc.d.ts +20 -0
- package/dist/channels/irc.js +71 -0
- package/dist/channels/line.d.ts +14 -0
- package/dist/channels/line.js +28 -0
- package/dist/channels/matrix.d.ts +15 -0
- package/dist/channels/matrix.js +28 -0
- package/dist/channels/mattermost.d.ts +18 -0
- package/dist/channels/mattermost.js +49 -0
- package/dist/channels/msteams.d.ts +14 -0
- package/dist/channels/msteams.js +28 -0
- package/dist/channels/nostr.d.ts +14 -0
- package/dist/channels/nostr.js +28 -0
- package/dist/channels/qq.d.ts +15 -0
- package/dist/channels/qq.js +28 -0
- package/dist/channels/signal.d.ts +14 -0
- package/dist/channels/signal.js +28 -0
- package/dist/channels/sms.d.ts +15 -0
- package/dist/channels/sms.js +28 -0
- package/dist/channels/twitch.d.ts +17 -0
- package/dist/channels/twitch.js +59 -0
- package/dist/channels/voice-call.d.ts +27 -0
- package/dist/channels/voice-call.js +82 -0
- package/dist/channels/whatsapp.d.ts +14 -0
- package/dist/channels/whatsapp.js +28 -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 +142 -6
- package/dist/core/api-server.d.ts +25 -0
- package/dist/core/api-server.js +286 -0
- package/dist/core/audio.d.ts +50 -0
- package/dist/core/audio.js +68 -0
- package/dist/core/context-discovery.d.ts +16 -0
- package/dist/core/context-discovery.js +107 -0
- package/dist/core/context-refs.d.ts +29 -0
- package/dist/core/context-refs.js +162 -0
- package/dist/core/gateway.d.ts +53 -0
- package/dist/core/gateway.js +80 -0
- package/dist/core/heartbeat.d.ts +19 -0
- package/dist/core/heartbeat.js +50 -0
- package/dist/core/hooks.d.ts +28 -0
- package/dist/core/hooks.js +82 -0
- package/dist/core/ide-bridge.d.ts +53 -0
- package/dist/core/ide-bridge.js +97 -0
- package/dist/core/node-network.d.ts +23 -0
- package/dist/core/node-network.js +77 -0
- package/dist/core/profiles.d.ts +27 -0
- package/dist/core/profiles.js +131 -0
- package/dist/core/sandbox.d.ts +25 -0
- package/dist/core/sandbox.js +84 -1
- package/dist/core/session-manager.d.ts +33 -0
- package/dist/core/session-manager.js +157 -0
- package/dist/core/vision.d.ts +45 -0
- package/dist/core/vision.js +177 -0
- 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 +66 -1
- package/dist/index.js +95 -3
- package/dist/memory/context-compressor.d.ts +43 -0
- package/dist/memory/context-compressor.js +167 -0
- package/dist/memory/index.d.ts +4 -0
- package/dist/memory/index.js +5 -1
- package/dist/memory/user-profiler.d.ts +50 -0
- package/dist/memory/user-profiler.js +201 -0
- 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/schema/oad.d.ts +12 -12
- package/dist/security/approvals.d.ts +53 -0
- package/dist/security/approvals.js +115 -0
- package/dist/security/elevated.d.ts +41 -0
- package/dist/security/elevated.js +89 -0
- package/dist/security/index.d.ts +6 -0
- package/dist/security/index.js +7 -1
- package/dist/security/secrets.d.ts +34 -0
- package/dist/security/secrets.js +115 -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/browser.d.ts +47 -0
- package/dist/tools/builtin/browser.js +284 -0
- package/dist/tools/builtin/home-assistant.d.ts +12 -0
- package/dist/tools/builtin/home-assistant.js +126 -0
- package/dist/tools/builtin/index.d.ts +7 -1
- package/dist/tools/builtin/index.js +23 -2
- package/dist/tools/builtin/rl-tools.d.ts +13 -0
- package/dist/tools/builtin/rl-tools.js +228 -0
- package/dist/tools/builtin/vision.d.ts +6 -0
- package/dist/tools/builtin/vision.js +61 -0
- 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/channels/dingtalk.ts +46 -0
- package/src/channels/googlechat.ts +42 -0
- package/src/channels/imessage.ts +32 -0
- package/src/channels/irc.ts +82 -0
- package/src/channels/line.ts +33 -0
- package/src/channels/matrix.ts +34 -0
- package/src/channels/mattermost.ts +57 -0
- package/src/channels/msteams.ts +33 -0
- package/src/channels/nostr.ts +33 -0
- package/src/channels/qq.ts +34 -0
- package/src/channels/signal.ts +33 -0
- package/src/channels/sms.ts +34 -0
- package/src/channels/twitch.ts +65 -0
- package/src/channels/voice-call.ts +100 -0
- package/src/channels/whatsapp.ts +33 -0
- package/src/cli/chat.ts +99 -0
- package/src/cli/setup.ts +314 -0
- package/src/cli.ts +148 -6
- package/src/core/api-server.ts +277 -0
- package/src/core/audio.ts +98 -0
- package/src/core/context-discovery.ts +85 -0
- package/src/core/context-refs.ts +140 -0
- package/src/core/gateway.ts +106 -0
- package/src/core/heartbeat.ts +51 -0
- package/src/core/hooks.ts +105 -0
- package/src/core/ide-bridge.ts +133 -0
- package/src/core/node-network.ts +86 -0
- package/src/core/profiles.ts +122 -0
- package/src/core/sandbox.ts +100 -0
- package/src/core/session-manager.ts +137 -0
- package/src/core/vision.ts +180 -0
- package/src/hub/brain-seed.ts +54 -0
- package/src/hub/client.ts +60 -0
- package/src/index.ts +86 -1
- package/src/memory/context-compressor.ts +189 -0
- package/src/memory/index.ts +4 -0
- package/src/memory/user-profiler.ts +215 -0
- package/src/providers/index.ts +64 -1
- package/src/scheduler/cron-engine.ts +191 -0
- package/src/scheduler/index.ts +2 -0
- package/src/security/approvals.ts +143 -0
- package/src/security/elevated.ts +105 -0
- package/src/security/index.ts +6 -0
- package/src/security/secrets.ts +129 -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/browser.ts +299 -0
- package/src/tools/builtin/home-assistant.ts +116 -0
- package/src/tools/builtin/index.ts +37 -28
- package/src/tools/builtin/rl-tools.ts +243 -0
- package/src/tools/builtin/vision.ts +64 -0
- 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/api-server.test.ts +148 -0
- package/tests/approvals.test.ts +89 -0
- package/tests/audio.test.ts +40 -0
- package/tests/browser.test.ts +179 -0
- package/tests/builtin-tools.test.ts +83 -83
- package/tests/channels-extra.test.ts +45 -0
- package/tests/context-compressor.test.ts +172 -0
- package/tests/context-refs.test.ts +121 -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/elevated.test.ts +69 -0
- package/tests/gateway.test.ts +63 -71
- package/tests/home-assistant.test.ts +40 -0
- package/tests/hooks.test.ts +79 -0
- package/tests/ide-bridge.test.ts +38 -0
- package/tests/image-generator.test.ts +84 -0
- package/tests/node-network.test.ts +74 -0
- package/tests/profiles.test.ts +61 -0
- package/tests/rl-tools.test.ts +93 -0
- package/tests/sandbox-manager.test.ts +46 -0
- package/tests/secrets.test.ts +107 -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/tools/builtin-extended.test.ts +138 -138
- package/tests/user-profiler.test.ts +169 -0
- package/tests/v090-features.test.ts +254 -0
- package/tests/vision.test.ts +61 -0
- package/tests/voice-call.test.ts +47 -0
- package/tests/voice-interaction.test.ts +38 -0
- package/tests/web-search.test.ts +155 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Cron Engine — persistent scheduler with file-based storage.
|
|
4
|
+
* Manages scheduled tasks with cron expressions, persists to ~/.opc/schedules.json,
|
|
5
|
+
* and auto-recovers on startup.
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.CronEngine = void 0;
|
|
42
|
+
exports.frequencyToCron = frequencyToCron;
|
|
43
|
+
const fs_1 = require("fs");
|
|
44
|
+
const path_1 = require("path");
|
|
45
|
+
const os = __importStar(require("os"));
|
|
46
|
+
const scheduler_1 = require("../core/scheduler");
|
|
47
|
+
function getSchedulesPath() {
|
|
48
|
+
const dir = (0, path_1.join)(os.homedir(), '.opc');
|
|
49
|
+
if (!(0, fs_1.existsSync)(dir))
|
|
50
|
+
(0, fs_1.mkdirSync)(dir, { recursive: true });
|
|
51
|
+
return (0, path_1.join)(dir, 'schedules.json');
|
|
52
|
+
}
|
|
53
|
+
function loadSchedules() {
|
|
54
|
+
const p = getSchedulesPath();
|
|
55
|
+
if ((0, fs_1.existsSync)(p)) {
|
|
56
|
+
try {
|
|
57
|
+
return JSON.parse((0, fs_1.readFileSync)(p, 'utf-8'));
|
|
58
|
+
}
|
|
59
|
+
catch { /* ignore */ }
|
|
60
|
+
}
|
|
61
|
+
return { tasks: [] };
|
|
62
|
+
}
|
|
63
|
+
function saveSchedules(store) {
|
|
64
|
+
(0, fs_1.writeFileSync)(getSchedulesPath(), JSON.stringify(store, null, 2));
|
|
65
|
+
}
|
|
66
|
+
/** Convert frequency + time to cron expression */
|
|
67
|
+
function frequencyToCron(frequency, time) {
|
|
68
|
+
const [hour, minute] = (time || '09:00').split(':').map(Number);
|
|
69
|
+
switch (frequency) {
|
|
70
|
+
case 'daily': return `${minute} ${hour} * * *`;
|
|
71
|
+
case 'weekly': return `${minute} ${hour} * * 1`;
|
|
72
|
+
case 'monthly': return `${minute} ${hour} 1 * *`;
|
|
73
|
+
default: return '0 9 * * *'; // fallback
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/** Compute next run from a cron expression */
|
|
77
|
+
function computeNextRun(cronExpr) {
|
|
78
|
+
try {
|
|
79
|
+
const parsed = (0, scheduler_1.parseCron)(cronExpr);
|
|
80
|
+
const d = new Date();
|
|
81
|
+
d.setSeconds(0, 0);
|
|
82
|
+
d.setMinutes(d.getMinutes() + 1);
|
|
83
|
+
for (let i = 0; i < 48 * 60; i++) {
|
|
84
|
+
if ((0, scheduler_1.cronMatches)(parsed, d))
|
|
85
|
+
return d.toISOString();
|
|
86
|
+
d.setMinutes(d.getMinutes() + 1);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch { /* ignore */ }
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
class CronEngine {
|
|
93
|
+
scheduler;
|
|
94
|
+
store;
|
|
95
|
+
handler;
|
|
96
|
+
constructor(handler) {
|
|
97
|
+
this.handler = handler || (async (job) => {
|
|
98
|
+
console.log(`[cron-engine] Executing job: ${job.name} (${job.id})`);
|
|
99
|
+
});
|
|
100
|
+
this.scheduler = new scheduler_1.Scheduler(this.handler);
|
|
101
|
+
this.store = loadSchedules();
|
|
102
|
+
}
|
|
103
|
+
/** Initialize and recover persisted tasks */
|
|
104
|
+
start() {
|
|
105
|
+
for (const task of this.store.tasks) {
|
|
106
|
+
if (task.enabled) {
|
|
107
|
+
this.scheduler.addJob({
|
|
108
|
+
id: task.id,
|
|
109
|
+
name: task.name,
|
|
110
|
+
schedule: task.schedule,
|
|
111
|
+
task: task.description,
|
|
112
|
+
enabled: true,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
this.scheduler.start();
|
|
117
|
+
console.log(`[cron-engine] Started with ${this.store.tasks.filter(t => t.enabled).length} active tasks`);
|
|
118
|
+
}
|
|
119
|
+
stop() {
|
|
120
|
+
this.scheduler.stop();
|
|
121
|
+
}
|
|
122
|
+
listTasks() {
|
|
123
|
+
// Refresh nextRun
|
|
124
|
+
return this.store.tasks.map(t => ({
|
|
125
|
+
...t,
|
|
126
|
+
nextRun: t.enabled ? computeNextRun(t.schedule) : undefined,
|
|
127
|
+
}));
|
|
128
|
+
}
|
|
129
|
+
getTask(id) {
|
|
130
|
+
return this.store.tasks.find(t => t.id === id);
|
|
131
|
+
}
|
|
132
|
+
createTask(input) {
|
|
133
|
+
const id = `sched-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
|
|
134
|
+
const now = new Date().toISOString();
|
|
135
|
+
const schedule = input.schedule || frequencyToCron(input.frequency, input.time);
|
|
136
|
+
const task = {
|
|
137
|
+
...input,
|
|
138
|
+
id,
|
|
139
|
+
schedule,
|
|
140
|
+
createdAt: now,
|
|
141
|
+
updatedAt: now,
|
|
142
|
+
nextRun: input.enabled ? computeNextRun(schedule) : undefined,
|
|
143
|
+
};
|
|
144
|
+
this.store.tasks.push(task);
|
|
145
|
+
saveSchedules(this.store);
|
|
146
|
+
if (task.enabled) {
|
|
147
|
+
this.scheduler.addJob({
|
|
148
|
+
id: task.id,
|
|
149
|
+
name: task.name,
|
|
150
|
+
schedule: task.schedule,
|
|
151
|
+
task: task.description,
|
|
152
|
+
enabled: true,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return task;
|
|
156
|
+
}
|
|
157
|
+
updateTask(id, updates) {
|
|
158
|
+
const idx = this.store.tasks.findIndex(t => t.id === id);
|
|
159
|
+
if (idx === -1)
|
|
160
|
+
return null;
|
|
161
|
+
const task = { ...this.store.tasks[idx], ...updates, id, updatedAt: new Date().toISOString() };
|
|
162
|
+
if (updates.frequency || updates.time) {
|
|
163
|
+
task.schedule = updates.schedule || frequencyToCron(task.frequency, task.time);
|
|
164
|
+
}
|
|
165
|
+
task.nextRun = task.enabled ? computeNextRun(task.schedule) : undefined;
|
|
166
|
+
this.store.tasks[idx] = task;
|
|
167
|
+
saveSchedules(this.store);
|
|
168
|
+
// Update scheduler
|
|
169
|
+
this.scheduler.removeJob(id);
|
|
170
|
+
if (task.enabled) {
|
|
171
|
+
this.scheduler.addJob({
|
|
172
|
+
id: task.id,
|
|
173
|
+
name: task.name,
|
|
174
|
+
schedule: task.schedule,
|
|
175
|
+
task: task.description,
|
|
176
|
+
enabled: true,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
return task;
|
|
180
|
+
}
|
|
181
|
+
deleteTask(id) {
|
|
182
|
+
const idx = this.store.tasks.findIndex(t => t.id === id);
|
|
183
|
+
if (idx === -1)
|
|
184
|
+
return false;
|
|
185
|
+
this.store.tasks.splice(idx, 1);
|
|
186
|
+
saveSchedules(this.store);
|
|
187
|
+
this.scheduler.removeJob(id);
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
async runTask(id) {
|
|
191
|
+
const task = this.store.tasks.find(t => t.id === id);
|
|
192
|
+
if (!task)
|
|
193
|
+
return false;
|
|
194
|
+
task.lastRun = new Date().toISOString();
|
|
195
|
+
saveSchedules(this.store);
|
|
196
|
+
return this.scheduler.runJob(id);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
exports.CronEngine = CronEngine;
|
|
200
|
+
//# sourceMappingURL=cron-engine.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.frequencyToCron = exports.CronEngine = void 0;
|
|
4
|
+
var cron_engine_1 = require("./cron-engine");
|
|
5
|
+
Object.defineProperty(exports, "CronEngine", { enumerable: true, get: function () { return cron_engine_1.CronEngine; } });
|
|
6
|
+
Object.defineProperty(exports, "frequencyToCron", { enumerable: true, get: function () { return cron_engine_1.frequencyToCron; } });
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
package/dist/schema/oad.d.ts
CHANGED
|
@@ -39,14 +39,14 @@ export declare const VoiceSchema: z.ZodObject<{
|
|
|
39
39
|
language: z.ZodOptional<z.ZodString>;
|
|
40
40
|
}, "strip", z.ZodTypeAny, {
|
|
41
41
|
enabled: boolean;
|
|
42
|
+
language?: string | undefined;
|
|
42
43
|
sttProvider?: string | undefined;
|
|
43
44
|
ttsProvider?: string | undefined;
|
|
44
|
-
language?: string | undefined;
|
|
45
45
|
}, {
|
|
46
|
+
language?: string | undefined;
|
|
46
47
|
enabled?: boolean | undefined;
|
|
47
48
|
sttProvider?: string | undefined;
|
|
48
49
|
ttsProvider?: string | undefined;
|
|
49
|
-
language?: string | undefined;
|
|
50
50
|
}>;
|
|
51
51
|
export declare const WebhookSchema: z.ZodObject<{
|
|
52
52
|
path: z.ZodOptional<z.ZodString>;
|
|
@@ -827,14 +827,14 @@ export declare const SpecSchema: z.ZodObject<{
|
|
|
827
827
|
language: z.ZodOptional<z.ZodString>;
|
|
828
828
|
}, "strip", z.ZodTypeAny, {
|
|
829
829
|
enabled: boolean;
|
|
830
|
+
language?: string | undefined;
|
|
830
831
|
sttProvider?: string | undefined;
|
|
831
832
|
ttsProvider?: string | undefined;
|
|
832
|
-
language?: string | undefined;
|
|
833
833
|
}, {
|
|
834
|
+
language?: string | undefined;
|
|
834
835
|
enabled?: boolean | undefined;
|
|
835
836
|
sttProvider?: string | undefined;
|
|
836
837
|
ttsProvider?: string | undefined;
|
|
837
|
-
language?: string | undefined;
|
|
838
838
|
}>>;
|
|
839
839
|
webhook: z.ZodOptional<z.ZodObject<{
|
|
840
840
|
path: z.ZodOptional<z.ZodString>;
|
|
@@ -1071,9 +1071,9 @@ export declare const SpecSchema: z.ZodObject<{
|
|
|
1071
1071
|
} | undefined;
|
|
1072
1072
|
voice?: {
|
|
1073
1073
|
enabled: boolean;
|
|
1074
|
+
language?: string | undefined;
|
|
1074
1075
|
sttProvider?: string | undefined;
|
|
1075
1076
|
ttsProvider?: string | undefined;
|
|
1076
|
-
language?: string | undefined;
|
|
1077
1077
|
} | undefined;
|
|
1078
1078
|
webhook?: {
|
|
1079
1079
|
path?: string | undefined;
|
|
@@ -1185,10 +1185,10 @@ export declare const SpecSchema: z.ZodObject<{
|
|
|
1185
1185
|
sessionIsolation?: boolean | undefined;
|
|
1186
1186
|
} | undefined;
|
|
1187
1187
|
voice?: {
|
|
1188
|
+
language?: string | undefined;
|
|
1188
1189
|
enabled?: boolean | undefined;
|
|
1189
1190
|
sttProvider?: string | undefined;
|
|
1190
1191
|
ttsProvider?: string | undefined;
|
|
1191
|
-
language?: string | undefined;
|
|
1192
1192
|
} | undefined;
|
|
1193
1193
|
webhook?: {
|
|
1194
1194
|
path?: string | undefined;
|
|
@@ -1573,14 +1573,14 @@ export declare const OADSchema: z.ZodObject<{
|
|
|
1573
1573
|
language: z.ZodOptional<z.ZodString>;
|
|
1574
1574
|
}, "strip", z.ZodTypeAny, {
|
|
1575
1575
|
enabled: boolean;
|
|
1576
|
+
language?: string | undefined;
|
|
1576
1577
|
sttProvider?: string | undefined;
|
|
1577
1578
|
ttsProvider?: string | undefined;
|
|
1578
|
-
language?: string | undefined;
|
|
1579
1579
|
}, {
|
|
1580
|
+
language?: string | undefined;
|
|
1580
1581
|
enabled?: boolean | undefined;
|
|
1581
1582
|
sttProvider?: string | undefined;
|
|
1582
1583
|
ttsProvider?: string | undefined;
|
|
1583
|
-
language?: string | undefined;
|
|
1584
1584
|
}>>;
|
|
1585
1585
|
webhook: z.ZodOptional<z.ZodObject<{
|
|
1586
1586
|
path: z.ZodOptional<z.ZodString>;
|
|
@@ -1817,9 +1817,9 @@ export declare const OADSchema: z.ZodObject<{
|
|
|
1817
1817
|
} | undefined;
|
|
1818
1818
|
voice?: {
|
|
1819
1819
|
enabled: boolean;
|
|
1820
|
+
language?: string | undefined;
|
|
1820
1821
|
sttProvider?: string | undefined;
|
|
1821
1822
|
ttsProvider?: string | undefined;
|
|
1822
|
-
language?: string | undefined;
|
|
1823
1823
|
} | undefined;
|
|
1824
1824
|
webhook?: {
|
|
1825
1825
|
path?: string | undefined;
|
|
@@ -1931,10 +1931,10 @@ export declare const OADSchema: z.ZodObject<{
|
|
|
1931
1931
|
sessionIsolation?: boolean | undefined;
|
|
1932
1932
|
} | undefined;
|
|
1933
1933
|
voice?: {
|
|
1934
|
+
language?: string | undefined;
|
|
1934
1935
|
enabled?: boolean | undefined;
|
|
1935
1936
|
sttProvider?: string | undefined;
|
|
1936
1937
|
ttsProvider?: string | undefined;
|
|
1937
|
-
language?: string | undefined;
|
|
1938
1938
|
} | undefined;
|
|
1939
1939
|
webhook?: {
|
|
1940
1940
|
path?: string | undefined;
|
|
@@ -2092,9 +2092,9 @@ export declare const OADSchema: z.ZodObject<{
|
|
|
2092
2092
|
} | undefined;
|
|
2093
2093
|
voice?: {
|
|
2094
2094
|
enabled: boolean;
|
|
2095
|
+
language?: string | undefined;
|
|
2095
2096
|
sttProvider?: string | undefined;
|
|
2096
2097
|
ttsProvider?: string | undefined;
|
|
2097
|
-
language?: string | undefined;
|
|
2098
2098
|
} | undefined;
|
|
2099
2099
|
webhook?: {
|
|
2100
2100
|
path?: string | undefined;
|
|
@@ -2223,10 +2223,10 @@ export declare const OADSchema: z.ZodObject<{
|
|
|
2223
2223
|
sessionIsolation?: boolean | undefined;
|
|
2224
2224
|
} | undefined;
|
|
2225
2225
|
voice?: {
|
|
2226
|
+
language?: string | undefined;
|
|
2226
2227
|
enabled?: boolean | undefined;
|
|
2227
2228
|
sttProvider?: string | undefined;
|
|
2228
2229
|
ttsProvider?: string | undefined;
|
|
2229
|
-
language?: string | undefined;
|
|
2230
2230
|
} | undefined;
|
|
2231
2231
|
webhook?: {
|
|
2232
2232
|
path?: string | undefined;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Approvals Module - v1.0.0
|
|
3
|
+
* Policy-based exec approval system with queue, expiry, history, and callbacks.
|
|
4
|
+
*/
|
|
5
|
+
export type ExecApprovalPolicy = 'always' | 'elevated-only' | 'never' | 'allowlist';
|
|
6
|
+
export interface ExecApprovalRequest {
|
|
7
|
+
id: string;
|
|
8
|
+
command: string;
|
|
9
|
+
elevated: boolean;
|
|
10
|
+
requestedAt: number;
|
|
11
|
+
expiresAt: number;
|
|
12
|
+
status: 'pending' | 'approved' | 'denied' | 'expired';
|
|
13
|
+
approvedBy?: string;
|
|
14
|
+
reason?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ExecApprovalHistory {
|
|
17
|
+
request: ExecApprovalRequest;
|
|
18
|
+
resolvedAt: number;
|
|
19
|
+
}
|
|
20
|
+
export type ApprovalRequestCallback = (request: ExecApprovalRequest) => void;
|
|
21
|
+
export declare class ExecApprovalManager {
|
|
22
|
+
private policy;
|
|
23
|
+
private pending;
|
|
24
|
+
private history;
|
|
25
|
+
private allowedCommands;
|
|
26
|
+
private expiryMs;
|
|
27
|
+
private onRequestCallback?;
|
|
28
|
+
private expiryTimer?;
|
|
29
|
+
constructor(options?: {
|
|
30
|
+
policy?: ExecApprovalPolicy;
|
|
31
|
+
expiryMs?: number;
|
|
32
|
+
allowedCommands?: string[];
|
|
33
|
+
onRequest?: ApprovalRequestCallback;
|
|
34
|
+
});
|
|
35
|
+
getPolicy(): ExecApprovalPolicy;
|
|
36
|
+
setPolicy(p: ExecApprovalPolicy): void;
|
|
37
|
+
addAllowedCommand(cmd: string): void;
|
|
38
|
+
removeAllowedCommand(cmd: string): void;
|
|
39
|
+
getAllowedCommands(): string[];
|
|
40
|
+
needsApproval(command: string, elevated: boolean): boolean;
|
|
41
|
+
private isAllowed;
|
|
42
|
+
request(command: string, elevated?: boolean): ExecApprovalRequest;
|
|
43
|
+
approve(id: string, approver: string): ExecApprovalRequest;
|
|
44
|
+
deny(id: string, approver: string, reason?: string): ExecApprovalRequest;
|
|
45
|
+
getPending(): ExecApprovalRequest[];
|
|
46
|
+
getHistory(): ExecApprovalHistory[];
|
|
47
|
+
getRequest(id: string): ExecApprovalRequest | undefined;
|
|
48
|
+
private expirePending;
|
|
49
|
+
/** Force expire check (for testing) */
|
|
50
|
+
checkExpiry(): void;
|
|
51
|
+
destroy(): void;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=approvals.d.ts.map
|
|
@@ -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
|
package/dist/security/index.d.ts
CHANGED
|
@@ -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
|
package/dist/security/index.js
CHANGED
|
@@ -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
|