homeagent-runner 0.0.0-stage → 0.4.4
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/CHANGELOG.md +124 -0
- package/CONTRIBUTING.md +65 -0
- package/LICENSE +21 -0
- package/README.en.md +300 -0
- package/README.md +217 -2
- package/SECURITY.md +59 -0
- package/THIRD_PARTY_NOTICES.md +45 -0
- package/bin/runner.mjs +2 -0
- package/dist/runner/agent.js +254 -0
- package/dist/runner/cli.js +66 -0
- package/dist/runner/config-location.js +67 -0
- package/dist/runner/config.js +43 -0
- package/dist/runner/context.js +86 -0
- package/dist/runner/credentials.js +68 -0
- package/dist/runner/editor.js +262 -0
- package/dist/runner/files.js +298 -0
- package/dist/runner/git.js +333 -0
- package/dist/runner/lock.js +28 -0
- package/dist/runner/output-log.js +59 -0
- package/dist/runner/patch.js +103 -0
- package/dist/runner/permissions.js +93 -0
- package/dist/runner/policy.js +87 -0
- package/dist/runner/process-tree.js +28 -0
- package/dist/runner/processes.js +367 -0
- package/dist/runner/service.js +53 -0
- package/dist/runner/setup.js +79 -0
- package/dist/runner/tools.js +118 -0
- package/dist/shared/permissions.js +40 -0
- package/dist/shared/protocol.js +98 -0
- package/dist/shared/tools.js +108 -0
- package/docs/ARCHITECTURE.md +92 -0
- package/docs/CLIENTS.md +130 -0
- package/docs/COMPARISON.md +36 -0
- package/docs/DEPLOYMENT.md +295 -0
- package/docs/DEVELOPMENT_WORKFLOW.md +126 -0
- package/docs/OPEN_SOURCE.md +127 -0
- package/docs/README.md +26 -0
- package/docs/TOOLS.md +105 -0
- package/docs/VALIDATION.md +172 -0
- package/docs/WEBCODEX_CODE_AUDIT.md +107 -0
- package/docs/webcodex-parity-map.json +75 -0
- package/docs/webcodex-source-inventory.json +2254 -0
- package/licenses/npm-runtime.txt +3673 -0
- package/package.json +44 -4
- package/runtime/windows-process-tree.cs +105 -0
- package/runtime/windows-process-tree.ps1 +19 -0
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
3
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
4
|
+
import { EventEmitter } from 'node:events';
|
|
5
|
+
import { open, unlink } from 'node:fs/promises';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { AppError, jobViewSchema, terminalJob } from '../shared/protocol.js';
|
|
9
|
+
import { OutputLog } from './output-log.js';
|
|
10
|
+
export function toolEnvironment() {
|
|
11
|
+
const env = {};
|
|
12
|
+
for (const [key, value] of Object.entries(process.env)) {
|
|
13
|
+
if (/^(path|pathext|systemroot|windir|comspec|temp|tmp|home|userprofile|localappdata|appdata|lang|lc_.*|term)$/i.test(key))
|
|
14
|
+
env[key] = value;
|
|
15
|
+
}
|
|
16
|
+
if (process.platform === 'win32') {
|
|
17
|
+
// WinPS needs an explicit module path in a filtered environment. Use only
|
|
18
|
+
// built-in modules; never inherit user/project module-loader hooks.
|
|
19
|
+
env.PSModulePath = path.join(process.env.SystemRoot ?? 'C:\\Windows', 'System32', 'WindowsPowerShell', 'v1.0', 'Modules');
|
|
20
|
+
}
|
|
21
|
+
env.NO_COLOR = '1';
|
|
22
|
+
return env;
|
|
23
|
+
}
|
|
24
|
+
const digest = (value) => createHash('sha256').update(JSON.stringify(value)).digest('hex');
|
|
25
|
+
export class Processes extends EventEmitter {
|
|
26
|
+
config;
|
|
27
|
+
policy;
|
|
28
|
+
db;
|
|
29
|
+
live = new Map();
|
|
30
|
+
closing;
|
|
31
|
+
constructor(config, policy) {
|
|
32
|
+
super();
|
|
33
|
+
this.config = config;
|
|
34
|
+
this.policy = policy;
|
|
35
|
+
this.setMaxListeners(64);
|
|
36
|
+
this.db = new DatabaseSync(path.join(config.stateDir, 'jobs.sqlite'));
|
|
37
|
+
this.db.exec('PRAGMA journal_mode=WAL; PRAGMA busy_timeout=5000; CREATE TABLE IF NOT EXISTS jobs (id TEXT PRIMARY KEY, data TEXT NOT NULL); CREATE TABLE IF NOT EXISTS requests (key TEXT PRIMARY KEY, signature TEXT NOT NULL, jobId TEXT NOT NULL, expires INTEGER NOT NULL)');
|
|
38
|
+
for (const job of this.all())
|
|
39
|
+
if (!job.finished) {
|
|
40
|
+
job.state = 'interrupted';
|
|
41
|
+
job.finished = Date.now();
|
|
42
|
+
// A crash can occur between the ring write and its metadata commit. Do not invent a valid tail cursor.
|
|
43
|
+
delete job.totalOutputBytes;
|
|
44
|
+
this.save(job);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
all() { return this.db.prepare('SELECT data FROM jobs').all().map(row => ({ revision: 0, ...JSON.parse(row.data) })); }
|
|
48
|
+
view(job) {
|
|
49
|
+
const { error, requestKey, executionHash, ...view } = job;
|
|
50
|
+
return jobViewSchema.parse({ ...view, executable: path.basename(job.executable) });
|
|
51
|
+
}
|
|
52
|
+
snapshot() { return this.all().map(job => this.view(job)); }
|
|
53
|
+
save(job) {
|
|
54
|
+
job.revision = (job.revision ?? 0) + 1;
|
|
55
|
+
this.db.prepare('INSERT INTO jobs VALUES(?,?) ON CONFLICT(id) DO UPDATE SET data=excluded.data').run(job.id, JSON.stringify(job));
|
|
56
|
+
this.emit('change', this.view(job));
|
|
57
|
+
}
|
|
58
|
+
receipt(job) { const { requestKey, executionHash, ...receipt } = job; return receipt; }
|
|
59
|
+
filename(id) { return path.join(this.config.stateDir, `${id}.output`); }
|
|
60
|
+
get(id) {
|
|
61
|
+
const live = this.live.get(id);
|
|
62
|
+
if (live)
|
|
63
|
+
return live.job;
|
|
64
|
+
const row = this.db.prepare('SELECT data FROM jobs WHERE id=?').get(id);
|
|
65
|
+
return row ? { revision: 0, ...JSON.parse(row.data) } : undefined;
|
|
66
|
+
}
|
|
67
|
+
owned(id, owner, projectId) {
|
|
68
|
+
const job = this.get(id);
|
|
69
|
+
if (!job || job.owner !== owner || job.projectId !== projectId)
|
|
70
|
+
throw new AppError('unknown_process', 'Process is not owned by this client and project');
|
|
71
|
+
return job;
|
|
72
|
+
}
|
|
73
|
+
replay(key, signature) {
|
|
74
|
+
if (!key)
|
|
75
|
+
return;
|
|
76
|
+
const row = this.db.prepare('SELECT * FROM requests WHERE key=?').get(key);
|
|
77
|
+
if (!row || row.expires <= Date.now())
|
|
78
|
+
return;
|
|
79
|
+
if (row.signature !== signature)
|
|
80
|
+
throw new AppError('idempotency_conflict', 'This idempotency key was used with different execution arguments');
|
|
81
|
+
const job = this.get(row.jobId);
|
|
82
|
+
if (!job)
|
|
83
|
+
throw new AppError('idempotency_receipt_expired', 'The execution was admitted, but its job history has been pruned. Inspect the project before starting a new execution.');
|
|
84
|
+
return { ...this.receipt(job), replayed: true };
|
|
85
|
+
}
|
|
86
|
+
async start(project, owner, args, signal, authorization) {
|
|
87
|
+
if (authorization?.authorizationExpiresAt && authorization.authorizationExpiresAt <= Date.now())
|
|
88
|
+
throw new AppError('permissions_expired', 'Temporary authorization expired before execution');
|
|
89
|
+
const alias = Object.hasOwn(project.commandAliases, args.executable) ? project.commandAliases[args.executable] : undefined;
|
|
90
|
+
const executable = alias?.executable ?? args.executable;
|
|
91
|
+
const argv = [...(alias?.args ?? []), ...args.args];
|
|
92
|
+
if (!alias)
|
|
93
|
+
this.policy.command(project, executable);
|
|
94
|
+
else if (process.platform === 'win32' && /\.(cmd|bat)$/i.test(executable))
|
|
95
|
+
throw new AppError('command_denied', 'Command aliases must resolve to an executable, not a .cmd/.bat wrapper');
|
|
96
|
+
if (argv.some(arg => arg.includes('\0')) || executable.includes('\0'))
|
|
97
|
+
throw new AppError('invalid_command', 'NUL is not permitted in executable arguments');
|
|
98
|
+
const env = toolEnvironment();
|
|
99
|
+
if (args.environment) {
|
|
100
|
+
const profile = Object.hasOwn(project.environmentProfiles, args.environment) ? project.environmentProfiles[args.environment] : undefined;
|
|
101
|
+
if (!profile)
|
|
102
|
+
throw new AppError('unknown_environment', 'Environment profile is not configured in the device policy');
|
|
103
|
+
for (const key of profile.inherit)
|
|
104
|
+
if (process.env[key] !== undefined)
|
|
105
|
+
env[key] = process.env[key];
|
|
106
|
+
Object.assign(env, profile.env);
|
|
107
|
+
}
|
|
108
|
+
const cwd = await this.policy.resolve(project, args.cwd);
|
|
109
|
+
const key = args.idempotencyKey ? digest([owner, project.id, ...(authorization?.authorizationId ? [authorization.authorizationId] : []), args.idempotencyKey]) : undefined;
|
|
110
|
+
const signature = digest([executable, argv, cwd, args.timeoutMs, args.environment ?? null, args.environment ? env : null]);
|
|
111
|
+
const existing = this.replay(key, signature);
|
|
112
|
+
if (existing)
|
|
113
|
+
return existing;
|
|
114
|
+
await this.prune();
|
|
115
|
+
if (signal?.aborted || this.closing)
|
|
116
|
+
throw new AppError('cancelled', 'Process start cancelled');
|
|
117
|
+
if (authorization?.authorizationExpiresAt && authorization.authorizationExpiresAt <= Date.now())
|
|
118
|
+
throw new AppError('permissions_expired', 'Temporary authorization expired before process admission');
|
|
119
|
+
const concurrentReplay = this.replay(key, signature);
|
|
120
|
+
if (concurrentReplay)
|
|
121
|
+
return concurrentReplay;
|
|
122
|
+
if (this.live.size >= this.config.maxProcesses)
|
|
123
|
+
throw new AppError('process_limit', 'Runner process limit reached');
|
|
124
|
+
if (key && this.db.prepare('SELECT count(*) AS n FROM requests').get().n >= 10000)
|
|
125
|
+
throw new AppError('idempotency_limit', 'Idempotency receipt capacity reached; retry after old receipts expire');
|
|
126
|
+
const job = { id: randomUUID(), owner, projectId: project.id, executable, started: Date.now(), state: 'starting', revision: 0, outputBytes: 0, totalOutputBytes: 0, truncated: false, requestKey: key, executionHash: signature, authorizationId: authorization?.authorizationId, authorizationExpiresAt: authorization?.authorizationExpiresAt, authorizationRevision: authorization?.authorizationRevision };
|
|
127
|
+
const log = new OutputLog(this.filename(job.id), this.config.maxOutputBytes);
|
|
128
|
+
// Persist admission before spawn. A crash is an interrupted outcome, never an automatic second execution.
|
|
129
|
+
this.db.exec('BEGIN IMMEDIATE');
|
|
130
|
+
try {
|
|
131
|
+
this.save(job);
|
|
132
|
+
if (key)
|
|
133
|
+
this.db.prepare('INSERT OR REPLACE INTO requests VALUES(?,?,?,?)').run(key, signature, job.id, Date.now() + 48 * 3600000);
|
|
134
|
+
this.db.exec('COMMIT');
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
this.db.exec('ROLLBACK');
|
|
138
|
+
log.close();
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
141
|
+
let child;
|
|
142
|
+
try {
|
|
143
|
+
const options = { cwd, shell: false, windowsHide: true, detached: process.platform !== 'win32', env, stdio: 'pipe' };
|
|
144
|
+
if (process.platform === 'win32') {
|
|
145
|
+
const helper = fileURLToPath(new URL('../../runtime/windows-process-tree.ps1', import.meta.url));
|
|
146
|
+
child = spawn('powershell.exe', ['-NoProfile', '-NonInteractive', '-WindowStyle', 'Hidden', '-File', helper, '-Executable', executable, '-ArgumentsBase64', Buffer.from(JSON.stringify(argv)).toString('base64'), '-ParentPid', String(process.pid)], options);
|
|
147
|
+
}
|
|
148
|
+
else
|
|
149
|
+
child = spawn(executable, argv, options);
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
log.close();
|
|
153
|
+
job.state = 'failed';
|
|
154
|
+
job.finished = Date.now();
|
|
155
|
+
job.error = String(error);
|
|
156
|
+
this.save(job);
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
159
|
+
let finish;
|
|
160
|
+
const done = new Promise(resolve => { finish = resolve; });
|
|
161
|
+
const timer = setTimeout(() => { void this.terminate(job.id, 'timed_out').catch(error => { job.error = String(error); this.save(job); }); }, args.timeoutMs).unref();
|
|
162
|
+
const live = { child, log, timer, job, done, finish, treeReleased: false };
|
|
163
|
+
this.live.set(job.id, live);
|
|
164
|
+
if (authorization?.authorizationExpiresAt)
|
|
165
|
+
live.authorizationTimer = setTimeout(() => {
|
|
166
|
+
job.error = 'Temporary authorization expired';
|
|
167
|
+
void this.terminate(job.id, 'stopped').catch(error => { job.error = String(error); this.save(job); });
|
|
168
|
+
}, Math.max(1, authorization.authorizationExpiresAt - Date.now())).unref();
|
|
169
|
+
const capture = (buffer) => {
|
|
170
|
+
log.append(buffer);
|
|
171
|
+
job.outputBytes = log.retained;
|
|
172
|
+
job.totalOutputBytes = log.total;
|
|
173
|
+
if (log.total > log.retained)
|
|
174
|
+
job.truncated = true;
|
|
175
|
+
this.save(job);
|
|
176
|
+
};
|
|
177
|
+
child.stdout?.on('data', capture);
|
|
178
|
+
child.stderr?.on('data', capture);
|
|
179
|
+
child.stdin?.on('error', () => { });
|
|
180
|
+
child.once('spawn', () => { if (job.state === 'starting') {
|
|
181
|
+
job.state = 'running';
|
|
182
|
+
this.save(job);
|
|
183
|
+
} });
|
|
184
|
+
child.once('error', error => { job.state = 'failed'; job.error = error.message; this.save(job); });
|
|
185
|
+
child.once('exit', () => {
|
|
186
|
+
// A leader's exit is not proof its descendants exited. Reap the remaining owned group immediately.
|
|
187
|
+
if (process.platform !== 'win32')
|
|
188
|
+
this.killGroup(live, 'SIGKILL');
|
|
189
|
+
});
|
|
190
|
+
child.once('close', (code, killedSignal) => {
|
|
191
|
+
clearTimeout(timer);
|
|
192
|
+
if (live.killTimer)
|
|
193
|
+
clearTimeout(live.killTimer);
|
|
194
|
+
if (live.authorizationTimer)
|
|
195
|
+
clearTimeout(live.authorizationTimer);
|
|
196
|
+
live.treeReleased = true;
|
|
197
|
+
log.close();
|
|
198
|
+
this.live.delete(job.id);
|
|
199
|
+
if (live.stoppedAs)
|
|
200
|
+
job.state = live.stoppedAs;
|
|
201
|
+
else if (job.state !== 'failed')
|
|
202
|
+
job.state = code === 0 ? 'exited' : 'failed';
|
|
203
|
+
job.finished = Date.now();
|
|
204
|
+
job.exitCode = code;
|
|
205
|
+
job.signal = killedSignal;
|
|
206
|
+
this.save(job);
|
|
207
|
+
finish();
|
|
208
|
+
});
|
|
209
|
+
await new Promise(resolve => { child.once('spawn', resolve); child.once('error', () => resolve()); });
|
|
210
|
+
return this.receipt(job);
|
|
211
|
+
}
|
|
212
|
+
async read(owner, projectId, args) {
|
|
213
|
+
const job = this.owned(args.processId, owner, projectId);
|
|
214
|
+
const handle = await open(this.filename(job.id), 'r');
|
|
215
|
+
try {
|
|
216
|
+
const buffer = Buffer.alloc(args.length);
|
|
217
|
+
const { bytesRead } = await handle.read(buffer, 0, args.length, args.cursor);
|
|
218
|
+
return { ...this.receipt(job), output: buffer.subarray(0, bytesRead).toString('utf8'), cursor: args.cursor, nextCursor: args.cursor + bytesRead };
|
|
219
|
+
}
|
|
220
|
+
finally {
|
|
221
|
+
await handle.close();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
list(owner, projectId) { return this.all().filter(job => job.owner === owner && job.projectId === projectId).sort((a, b) => b.started - a.started).map(job => this.receipt(job)); }
|
|
225
|
+
tail(owner, projectId, args) {
|
|
226
|
+
const job = this.owned(args.processId, owner, projectId);
|
|
227
|
+
if (job.totalOutputBytes === undefined)
|
|
228
|
+
throw new AppError('tail_unavailable', 'Rolling-tail position is unavailable for this legacy or interrupted job; use read_process_output');
|
|
229
|
+
return { ...this.receipt(job), ...OutputLog.read(this.filename(job.id), job.totalOutputBytes, args.length, args.cursor) };
|
|
230
|
+
}
|
|
231
|
+
async wait(owner, projectId, args, signal) {
|
|
232
|
+
this.owned(args.processId, owner, projectId);
|
|
233
|
+
if (signal?.aborted)
|
|
234
|
+
throw new AppError('cancelled', 'Wait cancelled; execution continues');
|
|
235
|
+
const baseline = args.cursor ?? (this.get(args.processId).totalOutputBytes ?? 0);
|
|
236
|
+
let reason = 'timeout';
|
|
237
|
+
await new Promise((resolve, reject) => {
|
|
238
|
+
let timer;
|
|
239
|
+
const cleanup = () => { clearTimeout(timer); this.off('change', changed); signal?.removeEventListener('abort', abort); };
|
|
240
|
+
const finish = (why) => { reason = why; cleanup(); resolve(); };
|
|
241
|
+
const check = () => {
|
|
242
|
+
const job = this.get(args.processId);
|
|
243
|
+
if (job.finished) {
|
|
244
|
+
finish('finished');
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
if (args.until === 'output' && (job.totalOutputBytes ?? 0) > baseline)
|
|
248
|
+
finish('output');
|
|
249
|
+
};
|
|
250
|
+
const changed = (job) => { if (job.id === args.processId)
|
|
251
|
+
check(); };
|
|
252
|
+
const abort = () => { cleanup(); reject(new AppError('cancelled', 'Wait cancelled; execution continues')); };
|
|
253
|
+
timer = setTimeout(() => finish('timeout'), args.waitMs);
|
|
254
|
+
this.on('change', changed);
|
|
255
|
+
signal?.addEventListener('abort', abort, { once: true });
|
|
256
|
+
check();
|
|
257
|
+
});
|
|
258
|
+
return { ...this.tail(owner, projectId, args), waitReason: reason };
|
|
259
|
+
}
|
|
260
|
+
async run(project, owner, args, signal, authorization) {
|
|
261
|
+
const started = await this.start(project, owner, args, signal, authorization);
|
|
262
|
+
return { ...await this.wait(owner, project.id, { processId: started.id, length: args.length, waitMs: args.waitMs, until: 'finished' }, signal), replayed: 'replayed' in started ? started.replayed : false };
|
|
263
|
+
}
|
|
264
|
+
async input(owner, projectId, args) {
|
|
265
|
+
this.owned(args.processId, owner, projectId);
|
|
266
|
+
const live = this.live.get(args.processId);
|
|
267
|
+
if (!live || live.job.state !== 'running' || !live.child.stdin?.writable)
|
|
268
|
+
throw new AppError('process_finished', 'Process stdin is not available');
|
|
269
|
+
await new Promise((resolve, reject) => live.child.stdin.write(args.input, error => error ? reject(error) : resolve()));
|
|
270
|
+
if (args.close)
|
|
271
|
+
live.child.stdin.end();
|
|
272
|
+
return { sent: Buffer.byteLength(args.input) };
|
|
273
|
+
}
|
|
274
|
+
async stop(owner, projectId, id) {
|
|
275
|
+
this.owned(id, owner, projectId);
|
|
276
|
+
await this.terminate(id, 'stopped');
|
|
277
|
+
return this.receipt(this.owned(id, owner, projectId));
|
|
278
|
+
}
|
|
279
|
+
killGroup(live, signal) {
|
|
280
|
+
if (live.treeReleased || !live.child.pid)
|
|
281
|
+
return;
|
|
282
|
+
if (live.killTimer)
|
|
283
|
+
clearTimeout(live.killTimer);
|
|
284
|
+
try {
|
|
285
|
+
process.kill(-live.child.pid, signal);
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
if (error.code !== 'ESRCH')
|
|
289
|
+
throw error;
|
|
290
|
+
}
|
|
291
|
+
if (signal === 'SIGKILL')
|
|
292
|
+
live.treeReleased = true;
|
|
293
|
+
}
|
|
294
|
+
async terminate(id, state) {
|
|
295
|
+
const live = this.live.get(id);
|
|
296
|
+
if (!live || live.stoppedAs || live.treeReleased)
|
|
297
|
+
return;
|
|
298
|
+
live.stoppedAs = state;
|
|
299
|
+
live.job.state = 'stopping';
|
|
300
|
+
this.save(live.job);
|
|
301
|
+
if (process.platform === 'win32') {
|
|
302
|
+
if (live.child.pid)
|
|
303
|
+
await new Promise((resolve, reject) => {
|
|
304
|
+
const killer = spawn('taskkill.exe', ['/PID', String(live.child.pid), '/T', '/F'], { windowsHide: true, stdio: 'ignore' });
|
|
305
|
+
killer.once('error', reject);
|
|
306
|
+
killer.once('close', code => { if (code && live.child.exitCode === null && this.live.has(id))
|
|
307
|
+
reject(new AppError('termination_failed', 'Windows rejected process-tree termination'));
|
|
308
|
+
else
|
|
309
|
+
resolve(); });
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
else if (live.child.pid) {
|
|
313
|
+
this.killGroup(live, 'SIGTERM');
|
|
314
|
+
live.killTimer = setTimeout(() => this.killGroup(live, 'SIGKILL'), 1500).unref();
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
async prune() {
|
|
318
|
+
this.db.prepare('DELETE FROM requests WHERE expires <= ?').run(Date.now());
|
|
319
|
+
const finished = this.all().filter(terminalJob).sort((a, b) => b.started - a.started);
|
|
320
|
+
for (const job of finished.slice(this.config.maxJobHistory - this.config.maxProcesses)) {
|
|
321
|
+
await unlink(this.filename(job.id)).catch(() => { });
|
|
322
|
+
await unlink(`${this.filename(job.id)}.tail`).catch(() => { });
|
|
323
|
+
this.db.prepare('DELETE FROM jobs WHERE id=?').run(job.id);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
async stopAll() { await Promise.all([...this.live.keys()].map(id => this.terminate(id, 'stopped'))); }
|
|
327
|
+
async stopAuthorization(authorizationId) {
|
|
328
|
+
await Promise.all([...this.live.values()].filter(live => live.job.authorizationId === authorizationId).map(live => this.terminate(live.job.id, 'stopped')));
|
|
329
|
+
}
|
|
330
|
+
async stopTemporaryAuthorizations() {
|
|
331
|
+
await Promise.all([...this.live.values()].filter(live => live.job.authorizationExpiresAt).map(live => this.terminate(live.job.id, 'stopped')));
|
|
332
|
+
}
|
|
333
|
+
async syncAuthorizations(authorizations) {
|
|
334
|
+
const revisions = new Map(authorizations.map(item => [item.id, item.revision]));
|
|
335
|
+
await Promise.all([...this.live.values()].filter(live => live.job.authorizationId && revisions.get(live.job.authorizationId) !== (live.job.authorizationRevision ?? 0)).map(live => this.terminate(live.job.id, 'stopped')));
|
|
336
|
+
}
|
|
337
|
+
async stopAllAndWait() {
|
|
338
|
+
await this.stopAll();
|
|
339
|
+
let timer;
|
|
340
|
+
try {
|
|
341
|
+
await Promise.race([Promise.all([...this.live.values()].map(live => live.done)), new Promise((_resolve, reject) => { timer = setTimeout(() => reject(new Error('Process trees have not stopped; permission change remains blocked')), 10000); })]);
|
|
342
|
+
}
|
|
343
|
+
finally {
|
|
344
|
+
if (timer)
|
|
345
|
+
clearTimeout(timer);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
close() {
|
|
349
|
+
if (this.closing)
|
|
350
|
+
return this.closing;
|
|
351
|
+
this.closing = (async () => {
|
|
352
|
+
await this.stopAll();
|
|
353
|
+
const pending = [...this.live.values()].map(live => live.done);
|
|
354
|
+
let timer;
|
|
355
|
+
try {
|
|
356
|
+
await Promise.race([Promise.all(pending), new Promise((_resolve, reject) => { timer = setTimeout(() => reject(new Error('Runner process trees have not exited; persistence remains open')), 7000); })]);
|
|
357
|
+
}
|
|
358
|
+
finally {
|
|
359
|
+
if (timer)
|
|
360
|
+
clearTimeout(timer);
|
|
361
|
+
}
|
|
362
|
+
this.db.close();
|
|
363
|
+
})();
|
|
364
|
+
return this.closing;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
//# sourceMappingURL=processes.js.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { promisify } from 'node:util';
|
|
3
|
+
import { mkdir, writeFile, unlink } from 'node:fs/promises';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { createHash } from 'node:crypto';
|
|
8
|
+
import { loadCredential } from './credentials.js';
|
|
9
|
+
const exec = promisify(execFile);
|
|
10
|
+
const xml = (value) => value.replace(/[&<>"']/g, char => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[char]);
|
|
11
|
+
export async function service(config, configFile, uninstall) {
|
|
12
|
+
const cli = fileURLToPath(new URL('./cli.js', import.meta.url));
|
|
13
|
+
if (!cli.endsWith('.js'))
|
|
14
|
+
throw new Error('Build before installing a service');
|
|
15
|
+
if (!uninstall)
|
|
16
|
+
await loadCredential(config);
|
|
17
|
+
const suffix = createHash('sha256').update(path.resolve(configFile)).digest('hex').slice(0, 8);
|
|
18
|
+
if (process.platform === 'linux') {
|
|
19
|
+
const name = `homeagent-${suffix}.service`, directory = path.join(os.homedir(), '.config/systemd/user'), unit = path.join(directory, name);
|
|
20
|
+
const quote = (value) => `"${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/%/g, '%%')}"`;
|
|
21
|
+
if (uninstall) {
|
|
22
|
+
await exec('systemctl', ['--user', 'disable', '--now', name]);
|
|
23
|
+
await unlink(unit);
|
|
24
|
+
await exec('systemctl', ['--user', 'daemon-reload']);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
await mkdir(directory, { recursive: true });
|
|
28
|
+
await writeFile(unit, `[Unit]\nDescription=HomeAgent outbound runner\nAfter=network-online.target\n\n[Service]\nExecStart=${quote(process.execPath)} ${quote(cli)} run --config ${quote(path.resolve(configFile))}\nRestart=on-failure\nRestartSec=5\nKillMode=control-group\nUMask=0077\nNoNewPrivileges=yes\n\n[Install]\nWantedBy=default.target\n`, { mode: 0o600 });
|
|
29
|
+
await exec('systemctl', ['--user', 'daemon-reload']);
|
|
30
|
+
await exec('systemctl', ['--user', 'enable', '--now', name]);
|
|
31
|
+
console.log(`已安装 ${name}。如需退出登录后继续运行:sudo loginctl enable-linger ${os.userInfo().username}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else if (process.platform === 'win32') {
|
|
35
|
+
const name = `HomeAgent-${suffix}`;
|
|
36
|
+
if (uninstall) {
|
|
37
|
+
await exec('schtasks.exe', ['/End', '/TN', name], { windowsHide: true }).catch(() => { });
|
|
38
|
+
await exec('schtasks.exe', ['/Delete', '/TN', name, '/F'], { windowsHide: true });
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const account = (await exec('whoami.exe', [], { windowsHide: true })).stdout.trim();
|
|
42
|
+
const quote = (value) => `"${value.replace(/"/g, '')}"`;
|
|
43
|
+
const task = `<?xml version="1.0" encoding="UTF-16"?><Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"><Triggers><LogonTrigger><Enabled>true</Enabled><UserId>${xml(account)}</UserId></LogonTrigger></Triggers><Principals><Principal id="Author"><UserId>${xml(account)}</UserId><LogonType>InteractiveToken</LogonType><RunLevel>LeastPrivilege</RunLevel></Principal></Principals><Settings><MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy><DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries><StopIfGoingOnBatteries>false</StopIfGoingOnBatteries><ExecutionTimeLimit>PT0S</ExecutionTimeLimit><RestartOnFailure><Interval>PT1M</Interval><Count>3</Count></RestartOnFailure><Hidden>true</Hidden></Settings><Actions Context="Author"><Exec><Command>${xml(process.execPath)}</Command><Arguments>${xml(`${quote(cli)} run --config ${quote(path.resolve(configFile))}`)}</Arguments><WorkingDirectory>${xml(path.dirname(configFile))}</WorkingDirectory></Exec></Actions></Task>`;
|
|
44
|
+
const filename = path.join(config.stateDir, 'service.xml');
|
|
45
|
+
await writeFile(filename, '\uFEFF' + task, 'utf16le');
|
|
46
|
+
await exec('schtasks.exe', ['/Create', '/TN', name, '/XML', filename, '/F'], { windowsHide: true });
|
|
47
|
+
await exec('schtasks.exe', ['/Run', '/TN', name], { windowsHide: true });
|
|
48
|
+
console.log(`已安装登录启动任务 ${name}(低权限运行)。`);
|
|
49
|
+
}
|
|
50
|
+
else
|
|
51
|
+
throw new Error('Service installation currently supports Linux and Windows');
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { access, mkdir, unlink, writeFile } from 'node:fs/promises';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { createInterface } from 'node:readline/promises';
|
|
5
|
+
import { stdin as input, stdout as output } from 'node:process';
|
|
6
|
+
import { runnerConfigSchema, loadRunnerConfig } from './config.js';
|
|
7
|
+
import { pair } from './credentials.js';
|
|
8
|
+
import { defaultRunnerConfigPath, rememberRunnerConfigPath, resolveRunnerConfigPath } from './config-location.js';
|
|
9
|
+
import { AppError } from '../shared/protocol.js';
|
|
10
|
+
const isMissing = (error) => error.code === 'ENOENT';
|
|
11
|
+
async function exists(filename) {
|
|
12
|
+
try {
|
|
13
|
+
await access(filename);
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
if (isMissing(error))
|
|
18
|
+
return false;
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async function question(rl, label, fallback = '') {
|
|
23
|
+
const suffix = fallback ? ` [${fallback}]` : '';
|
|
24
|
+
const answer = (await rl.question(`${label}${suffix}: `)).trim();
|
|
25
|
+
return answer || fallback;
|
|
26
|
+
}
|
|
27
|
+
async function createConfig(filename, options, rl) {
|
|
28
|
+
const server = options.server ?? await question(rl, 'HomeAgent Web URL', 'http://localhost:3210');
|
|
29
|
+
const name = options.name ?? await question(rl, '设备名称', os.hostname());
|
|
30
|
+
if (!server)
|
|
31
|
+
throw new Error('HomeAgent Web URL 不能为空');
|
|
32
|
+
if (!name)
|
|
33
|
+
throw new Error('设备名称不能为空');
|
|
34
|
+
const value = runnerConfigSchema.parse({
|
|
35
|
+
server, name, stateDir: path.join(path.dirname(filename), 'state'),
|
|
36
|
+
maxProcesses: 8, maxOutputBytes: 8388608, maxJobHistory: 500,
|
|
37
|
+
});
|
|
38
|
+
await writeFile(filename, JSON.stringify(value, null, 2) + '\n', { flag: 'wx', mode: 0o600 });
|
|
39
|
+
try {
|
|
40
|
+
return await loadRunnerConfig(filename);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
await unlink(filename).catch(cleanupError => { if (!isMissing(cleanupError))
|
|
44
|
+
throw cleanupError; });
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export async function interactiveLogin(options, log = console.log) {
|
|
49
|
+
const filename = options.config !== undefined
|
|
50
|
+
? await resolveRunnerConfigPath(options.config)
|
|
51
|
+
: await resolveRunnerConfigPath().catch(error => {
|
|
52
|
+
if (error instanceof AppError && error.code === 'config_not_found')
|
|
53
|
+
return defaultRunnerConfigPath();
|
|
54
|
+
throw error;
|
|
55
|
+
});
|
|
56
|
+
await mkdir(path.dirname(filename), { recursive: true, mode: 0o700 });
|
|
57
|
+
let config;
|
|
58
|
+
if (await exists(filename)) {
|
|
59
|
+
config = await loadRunnerConfig(filename);
|
|
60
|
+
log(`使用现有 Runner 配置:${filename}`);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
const rl = createInterface({ input, output });
|
|
64
|
+
try {
|
|
65
|
+
config = await createConfig(filename, options, rl);
|
|
66
|
+
log(`已生成 Runner 配置:${filename}`);
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
rl.close();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
await pair(config, options.force, log);
|
|
73
|
+
await rememberRunnerConfigPath(filename).catch(() => log('无法记录配置位置,下次启动请通过 --config 指定路径。'));
|
|
74
|
+
log(`登录完成。配置文件:${filename}`);
|
|
75
|
+
log('项目目录和权限由 Server 保存;请在网页中配置。');
|
|
76
|
+
log('运行 homeagent run 启动设备;安装自启动可使用 homeagent service-install。');
|
|
77
|
+
return { filename, config: await loadRunnerConfig(filename) };
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=setup.js.map
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { AppError, errorText, result } from '../shared/protocol.js';
|
|
2
|
+
import { toolSchemas, toolScope } from '../shared/tools.js';
|
|
3
|
+
import { Policy } from './policy.js';
|
|
4
|
+
import { Files } from './files.js';
|
|
5
|
+
import { Processes } from './processes.js';
|
|
6
|
+
import { Git } from './git.js';
|
|
7
|
+
import { Editor } from './editor.js';
|
|
8
|
+
import { Context } from './context.js';
|
|
9
|
+
import { parseUnifiedDiff } from './patch.js';
|
|
10
|
+
/** Serialize each project's mutations so expected hashes and moves are meaningful across concurrent clients. */
|
|
11
|
+
export class Tools {
|
|
12
|
+
deviceId;
|
|
13
|
+
policy;
|
|
14
|
+
files;
|
|
15
|
+
processes;
|
|
16
|
+
git;
|
|
17
|
+
editor;
|
|
18
|
+
context;
|
|
19
|
+
locks = new Map();
|
|
20
|
+
constructor(config, deviceId) {
|
|
21
|
+
this.deviceId = deviceId;
|
|
22
|
+
this.policy = new Policy(config);
|
|
23
|
+
this.files = new Files(this.policy);
|
|
24
|
+
this.processes = new Processes(config, this.policy);
|
|
25
|
+
this.git = new Git(this.policy);
|
|
26
|
+
this.editor = new Editor(config, this.files);
|
|
27
|
+
this.context = new Context(config, this.files, this.git, this.processes);
|
|
28
|
+
}
|
|
29
|
+
async invoke(name, input, principal, signal) {
|
|
30
|
+
try {
|
|
31
|
+
if (principal.tools && !principal.tools.includes(name))
|
|
32
|
+
throw new AppError('tool_forbidden', 'Tool is not enabled for this client authorization');
|
|
33
|
+
if (!Object.hasOwn(toolSchemas, name))
|
|
34
|
+
throw new AppError('unknown_tool', 'Unknown tool');
|
|
35
|
+
const tool = name, args = toolSchemas[tool].parse(input);
|
|
36
|
+
const project = this.policy.project(args.projectId, principal, toolScope(tool), this.deviceId);
|
|
37
|
+
const execute = async () => {
|
|
38
|
+
await this.editor.ready;
|
|
39
|
+
if (signal?.aborted)
|
|
40
|
+
throw new AppError('cancelled', 'Call cancelled');
|
|
41
|
+
const deadline = Math.min(principal.authorizationExpiresAt ?? Infinity, this.policy.expiresAt ?? Infinity);
|
|
42
|
+
const executionAuthorization = { authorizationId: principal.authorizationId, authorizationRevision: principal.authorizationRevision, authorizationExpiresAt: Number.isFinite(deadline) ? deadline : undefined };
|
|
43
|
+
if (toolScope(tool) !== 'read' && !['recover_edit_transaction', 'save_project_note'].includes(tool))
|
|
44
|
+
await this.editor.assertWritable(project);
|
|
45
|
+
switch (tool) {
|
|
46
|
+
case 'get_project_context': return { ...await this.context.get(project, principal.id, toolSchemas.get_project_context.parse(args).includeInstructions, signal), grantedScopes: principal.scopes };
|
|
47
|
+
case 'save_project_note': return this.context.note(project, principal.id, toolSchemas.save_project_note.parse(args).text);
|
|
48
|
+
case 'read_files': return this.files.readFiles(project, toolSchemas.read_files.parse(args));
|
|
49
|
+
case 'edit_files': {
|
|
50
|
+
const input = toolSchemas.edit_files.parse(args);
|
|
51
|
+
return this.editor.edit(project, principal.id, input.changes, input.dryRun, signal);
|
|
52
|
+
}
|
|
53
|
+
case 'apply_unified_diff': {
|
|
54
|
+
const input = toolSchemas.apply_unified_diff.parse(args);
|
|
55
|
+
return this.editor.edit(project, principal.id, await parseUnifiedDiff(this.files, project, input.diff, input.expectedSha256), input.dryRun, signal);
|
|
56
|
+
}
|
|
57
|
+
case 'get_edit_transactions': return this.editor.list(project, principal.id);
|
|
58
|
+
case 'recover_edit_transaction': return this.editor.recover(project, principal.id, toolSchemas.recover_edit_transaction.parse(args).transactionId);
|
|
59
|
+
case 'list_directory': return this.files.list(project, toolSchemas.list_directory.parse(args));
|
|
60
|
+
case 'read_file': return this.files.read(project, toolSchemas.read_file.parse(args));
|
|
61
|
+
case 'write_file': return this.files.write(project, toolSchemas.write_file.parse(args));
|
|
62
|
+
case 'create_directory': return this.files.mkdir(project, toolSchemas.create_directory.parse(args).path);
|
|
63
|
+
case 'move_file': {
|
|
64
|
+
const a = toolSchemas.move_file.parse(args);
|
|
65
|
+
return this.files.move(project, a.source, a.destination);
|
|
66
|
+
}
|
|
67
|
+
case 'search_files': {
|
|
68
|
+
const input = toolSchemas.search_files.parse(args);
|
|
69
|
+
let source;
|
|
70
|
+
if (input.respectGitIgnore) {
|
|
71
|
+
try {
|
|
72
|
+
source = await this.git.listFiles(project, input.path, signal);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (error instanceof AppError && error.code === 'search_source_limit')
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return this.files.search(project, input, signal, source);
|
|
80
|
+
}
|
|
81
|
+
case 'edit_block': return this.files.edit(project, toolSchemas.edit_block.parse(args));
|
|
82
|
+
case 'get_file_info': return this.files.info(project, toolSchemas.get_file_info.parse(args).path);
|
|
83
|
+
case 'start_process': return this.processes.start(project, principal.id, toolSchemas.start_process.parse(args), signal, executionAuthorization);
|
|
84
|
+
case 'run_command': return this.processes.run(project, principal.id, toolSchemas.run_command.parse(args), signal, executionAuthorization);
|
|
85
|
+
case 'wait_process': return this.processes.wait(principal.id, project.id, toolSchemas.wait_process.parse(args), signal);
|
|
86
|
+
case 'tail_process_output': return this.processes.tail(principal.id, project.id, toolSchemas.tail_process_output.parse(args));
|
|
87
|
+
case 'read_process_output': return this.processes.read(principal.id, project.id, toolSchemas.read_process_output.parse(args));
|
|
88
|
+
case 'write_process_input': return this.processes.input(principal.id, project.id, toolSchemas.write_process_input.parse(args));
|
|
89
|
+
case 'list_processes': return this.processes.list(principal.id, project.id);
|
|
90
|
+
case 'stop_process': return this.processes.stop(principal.id, project.id, toolSchemas.stop_process.parse(args).processId);
|
|
91
|
+
default: return this.git.invoke(project, tool, args, signal);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
if (toolScope(tool) === 'read' || ['start_process', 'run_command', 'stop_process', 'write_process_input'].includes(tool))
|
|
95
|
+
return result(await execute());
|
|
96
|
+
const prior = this.locks.get(project.id) ?? Promise.resolve();
|
|
97
|
+
const current = prior.catch(() => { }).then(execute);
|
|
98
|
+
this.locks.set(project.id, current);
|
|
99
|
+
try {
|
|
100
|
+
return result(await current);
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
if (this.locks.get(project.id) === current)
|
|
104
|
+
this.locks.delete(project.id);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
const code = error instanceof AppError ? error.code : 'tool_failed';
|
|
109
|
+
return result({ error: code, message: errorText(error), retryable: ['process_limit', 'git_busy'].includes(code), outcomeUnknown: ['cancelled', 'commit_reconcile_required', 'recovery_required'].includes(code) }, true);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async close() {
|
|
113
|
+
await this.editor.ready.catch(() => { });
|
|
114
|
+
await Promise.all([...this.locks.values()].map(lock => lock.catch(() => { })));
|
|
115
|
+
await this.processes.close();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const commandAliasesSchema = z.record(z.string().regex(/^[a-zA-Z0-9_-]{1,64}$/), z.object({
|
|
3
|
+
executable: z.string().min(1).max(4096), args: z.array(z.string().max(8192)).max(256).default([]),
|
|
4
|
+
}).strict()).refine(value => Object.keys(value).length <= 64, 'At most 64 command aliases per project').default({});
|
|
5
|
+
export const environmentProfilesSchema = z.record(z.string().regex(/^[a-zA-Z0-9_-]{1,64}$/), z.object({
|
|
6
|
+
env: z.record(z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/), z.string().max(32768)).default({}),
|
|
7
|
+
inherit: z.array(z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/)).max(100).default([]),
|
|
8
|
+
}).strict()).refine(value => Object.keys(value).length <= 64, 'At most 64 environment profiles per project').default({});
|
|
9
|
+
export const permissionProjectSchema = z.object({
|
|
10
|
+
id: z.string().regex(/^[a-zA-Z0-9_-]{1,64}$/),
|
|
11
|
+
name: z.string().min(1).max(128),
|
|
12
|
+
root: z.string().min(1).max(4096),
|
|
13
|
+
readOnly: z.boolean().default(false),
|
|
14
|
+
commands: z.array(z.string().min(1).max(512)).max(64).default([]),
|
|
15
|
+
commandMode: z.enum(['allowlist', 'unrestricted']).default('allowlist'),
|
|
16
|
+
filesystemScope: z.enum(['project', 'device']).default('project'),
|
|
17
|
+
allowGitWrite: z.boolean().default(false),
|
|
18
|
+
allowGitNetwork: z.boolean().default(false),
|
|
19
|
+
allowGitPush: z.boolean().default(false),
|
|
20
|
+
commandAliases: commandAliasesSchema,
|
|
21
|
+
environmentProfiles: environmentProfilesSchema,
|
|
22
|
+
gitCommonDir: z.string().min(1).max(4096).optional(),
|
|
23
|
+
deniedNames: z.array(z.string().min(1).max(128)).max(64).default(['.git', '.env', '.ssh', '.aws', '.homeagent']),
|
|
24
|
+
}).strict();
|
|
25
|
+
export const remotePermissionsSchema = z.object({
|
|
26
|
+
revision: z.number().int().min(0),
|
|
27
|
+
projects: z.array(permissionProjectSchema).max(100),
|
|
28
|
+
expiresAt: z.number().int().positive().nullable(),
|
|
29
|
+
fallbackProjects: z.array(permissionProjectSchema).max(100),
|
|
30
|
+
}).strict();
|
|
31
|
+
export const grantPermissionsSchema = z.object({
|
|
32
|
+
scopes: z.array(z.enum(['read', 'write', 'execute', 'git'])).max(4),
|
|
33
|
+
devices: z.array(z.string().uuid()).max(100),
|
|
34
|
+
projectGrants: z.record(z.string().uuid(), z.array(z.string().min(1).max(64)).max(100)),
|
|
35
|
+
tools: z.array(z.string().min(1).max(64)).max(100).nullable().default(null),
|
|
36
|
+
machineAccess: z.boolean().default(false),
|
|
37
|
+
unrestrictedExecution: z.boolean().default(false),
|
|
38
|
+
}).strict();
|
|
39
|
+
export const permissionDuration = z.number().int().min(1).max(10080).nullable();
|
|
40
|
+
//# sourceMappingURL=permissions.js.map
|