homeagent-runner 0.4.13 → 0.4.15
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 +34 -0
- package/README.en.md +7 -3
- package/README.md +7 -3
- package/SECURITY.md +3 -3
- package/dist/runner/agent.js +162 -17
- package/dist/runner/assist-consent.js +148 -0
- package/dist/runner/assist.js +255 -0
- package/dist/runner/cli.js +28 -20
- package/dist/runner/editor.js +2 -1
- package/dist/runner/files.js +8 -4
- package/dist/runner/git.js +22 -5
- package/dist/runner/interactive.js +39 -0
- package/dist/runner/permissions.js +8 -1
- package/dist/runner/policy.js +15 -3
- package/dist/runner/process-tree.js +4 -1
- package/dist/runner/processes.js +23 -9
- package/dist/runner/tools.js +19 -8
- package/dist/shared/assist.js +71 -0
- package/dist/shared/protocol.js +12 -1
- package/docs/ARCHITECTURE.md +8 -0
- package/docs/OPEN_SOURCE.md +8 -8
- package/docs/README.md +1 -0
- package/docs/REMOTE_ASSIST.md +46 -0
- package/package.json +1 -1
package/dist/runner/processes.js
CHANGED
|
@@ -116,6 +116,7 @@ export class Processes extends EventEmitter {
|
|
|
116
116
|
throw new AppError('cancelled', 'Process start cancelled');
|
|
117
117
|
if (authorization?.authorizationExpiresAt && authorization.authorizationExpiresAt <= Date.now())
|
|
118
118
|
throw new AppError('permissions_expired', 'Temporary authorization expired before process admission');
|
|
119
|
+
this.policy.check(project);
|
|
119
120
|
const concurrentReplay = this.replay(key, signature);
|
|
120
121
|
if (concurrentReplay)
|
|
121
122
|
return concurrentReplay;
|
|
@@ -123,7 +124,7 @@ export class Processes extends EventEmitter {
|
|
|
123
124
|
throw new AppError('process_limit', 'Runner process limit reached');
|
|
124
125
|
if (key && this.db.prepare('SELECT count(*) AS n FROM requests').get().n >= 10000)
|
|
125
126
|
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 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, assist: authorization?.assist };
|
|
127
128
|
const log = new OutputLog(this.filename(job.id), this.config.maxOutputBytes);
|
|
128
129
|
// Persist admission before spawn. A crash is an interrupted outcome, never an automatic second execution.
|
|
129
130
|
this.db.exec('BEGIN IMMEDIATE');
|
|
@@ -293,20 +294,33 @@ export class Processes extends EventEmitter {
|
|
|
293
294
|
}
|
|
294
295
|
async terminate(id, state) {
|
|
295
296
|
const live = this.live.get(id);
|
|
296
|
-
if (!live || live.
|
|
297
|
+
if (!live || live.treeReleased)
|
|
298
|
+
return;
|
|
299
|
+
if (!live.stoppedAs) {
|
|
300
|
+
live.stoppedAs = state;
|
|
301
|
+
live.job.state = 'stopping';
|
|
302
|
+
this.save(live.job);
|
|
303
|
+
}
|
|
304
|
+
else if (live.killTimer)
|
|
297
305
|
return;
|
|
298
|
-
live.stoppedAs = state;
|
|
299
|
-
live.job.state = 'stopping';
|
|
300
|
-
this.save(live.job);
|
|
301
306
|
if (process.platform === 'win32') {
|
|
302
307
|
if (live.child.pid)
|
|
303
308
|
await new Promise((resolve, reject) => {
|
|
304
309
|
const killer = spawn('taskkill.exe', ['/PID', String(live.child.pid), '/T', '/F'], { windowsHide: true, stdio: 'ignore' });
|
|
305
310
|
killer.once('error', reject);
|
|
306
|
-
killer.once('close', code => {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
311
|
+
killer.once('close', code => {
|
|
312
|
+
if (!code || live.child.exitCode !== null || !this.live.has(id)) {
|
|
313
|
+
resolve();
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
// Concurrent tree stops can make taskkill fail just before supervisor close.
|
|
317
|
+
let timer;
|
|
318
|
+
void Promise.race([
|
|
319
|
+
live.done,
|
|
320
|
+
new Promise((_resolve, reject) => { timer = setTimeout(() => reject(new AppError('termination_failed', 'Windows rejected process-tree termination')), 1500); }),
|
|
321
|
+
]).then(resolve, reject).finally(() => { if (timer)
|
|
322
|
+
clearTimeout(timer); });
|
|
323
|
+
});
|
|
310
324
|
});
|
|
311
325
|
}
|
|
312
326
|
else if (live.child.pid) {
|
package/dist/runner/tools.js
CHANGED
|
@@ -10,6 +10,7 @@ import { parseUnifiedDiff } from './patch.js';
|
|
|
10
10
|
/** Serialize each project's mutations so expected hashes and moves are meaningful across concurrent clients. */
|
|
11
11
|
export class Tools {
|
|
12
12
|
deviceId;
|
|
13
|
+
consent;
|
|
13
14
|
policy;
|
|
14
15
|
files;
|
|
15
16
|
processes;
|
|
@@ -17,9 +18,10 @@ export class Tools {
|
|
|
17
18
|
editor;
|
|
18
19
|
context;
|
|
19
20
|
locks = new Map();
|
|
20
|
-
constructor(config, deviceId) {
|
|
21
|
+
constructor(config, deviceId, consent) {
|
|
21
22
|
this.deviceId = deviceId;
|
|
22
|
-
this.
|
|
23
|
+
this.consent = consent;
|
|
24
|
+
this.policy = new Policy(config, consent);
|
|
23
25
|
this.files = new Files(this.policy);
|
|
24
26
|
this.processes = new Processes(config, this.policy);
|
|
25
27
|
this.git = new Git(this.policy);
|
|
@@ -35,15 +37,22 @@ export class Tools {
|
|
|
35
37
|
if (!Object.hasOwn(toolSchemas, name))
|
|
36
38
|
throw new AppError('unknown_tool', 'Unknown tool');
|
|
37
39
|
const tool = name, args = toolSchemas[tool].parse(input);
|
|
40
|
+
const guard = () => {
|
|
41
|
+
if (signal?.aborted)
|
|
42
|
+
throw new AppError('cancelled', 'Call cancelled');
|
|
43
|
+
this.consent?.assertCall(principal, tool, args.projectId);
|
|
44
|
+
};
|
|
45
|
+
guard();
|
|
38
46
|
const project = this.policy.project(args.projectId, principal, toolScope(tool), this.deviceId);
|
|
47
|
+
if (this.consent)
|
|
48
|
+
project.assertAccess = guard;
|
|
39
49
|
executionPolicy = project.executionPolicy;
|
|
40
50
|
filesystemPolicy = project.filesystemPolicy;
|
|
41
51
|
const execute = async () => {
|
|
42
52
|
await this.editor.ready;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
const executionAuthorization = { authorizationId: principal.authorizationId, authorizationRevision: principal.authorizationRevision, authorizationExpiresAt: Number.isFinite(deadline) ? deadline : undefined };
|
|
53
|
+
guard();
|
|
54
|
+
const deadline = Math.min(principal.authorizationExpiresAt ?? Infinity, this.policy.expiresAt ?? Infinity, this.consent?.deadline(principal) ?? Infinity);
|
|
55
|
+
const executionAuthorization = { authorizationId: principal.authorizationId, authorizationRevision: principal.authorizationRevision, authorizationExpiresAt: Number.isFinite(deadline) ? deadline : undefined, assist: principal.assist };
|
|
47
56
|
if (toolScope(tool) !== 'read' && !['recover_edit_transaction', 'save_project_note'].includes(tool))
|
|
48
57
|
await this.editor.assertWritable(project);
|
|
49
58
|
switch (tool) {
|
|
@@ -95,10 +104,11 @@ export class Tools {
|
|
|
95
104
|
default: return this.git.invoke(project, tool, args, signal);
|
|
96
105
|
}
|
|
97
106
|
};
|
|
107
|
+
const checkedExecute = async () => { const value = await execute(); guard(); return value; };
|
|
98
108
|
if (toolScope(tool) === 'read' || ['start_process', 'run_command', 'stop_process', 'write_process_input'].includes(tool))
|
|
99
|
-
return result(await
|
|
109
|
+
return result(await checkedExecute());
|
|
100
110
|
const prior = this.locks.get(project.id) ?? Promise.resolve();
|
|
101
|
-
const current = prior.catch(() => { }).then(
|
|
111
|
+
const current = prior.catch(() => { }).then(checkedExecute);
|
|
102
112
|
this.locks.set(project.id, current);
|
|
103
113
|
try {
|
|
104
114
|
return result(await current);
|
|
@@ -116,6 +126,7 @@ export class Tools {
|
|
|
116
126
|
async close() {
|
|
117
127
|
await this.editor.ready.catch(() => { });
|
|
118
128
|
await Promise.all([...this.locks.values()].map(lock => lock.catch(() => { })));
|
|
129
|
+
await this.git.stopAllAndWait();
|
|
119
130
|
await this.processes.close();
|
|
120
131
|
}
|
|
121
132
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { permissionProjectSchema } from './permissions.js';
|
|
3
|
+
export const ASSIST_FEATURE = 'remote-assist-v1';
|
|
4
|
+
export const ASSIST_MULTI_FEATURE = 'remote-assist-multi-v1';
|
|
5
|
+
export const ASSIST_INVITE_MS = 10 * 60000;
|
|
6
|
+
export const assistScopeSchema = z.enum(['read', 'write', 'execute']);
|
|
7
|
+
export const assistDurationSchema = z.union([z.literal(30), z.literal(120), z.literal(480)]);
|
|
8
|
+
export const assistApprovalSchema = z.object({
|
|
9
|
+
root: z.string().min(1).max(4096),
|
|
10
|
+
scopes: z.array(assistScopeSchema).min(1).max(3).refine(value => value.includes('read') && new Set(value).size === value.length, 'Read scope and unique scopes are required'),
|
|
11
|
+
commands: z.array(z.string().min(1).max(4096)).max(16).default([]),
|
|
12
|
+
durationMinutes: assistDurationSchema,
|
|
13
|
+
approvedAt: z.number().int().positive(),
|
|
14
|
+
expiresAt: z.number().int().positive(),
|
|
15
|
+
}).strict().refine(value => value.expiresAt > value.approvedAt && value.expiresAt - value.approvedAt <= value.durationMinutes * 60000, 'Invalid local authorization duration')
|
|
16
|
+
.refine(value => value.scopes.includes('execute') || value.commands.length === 0, 'Programs require explicit execute consent');
|
|
17
|
+
export const assistApprovedProjectSchema = z.object({
|
|
18
|
+
id: permissionProjectSchema.shape.id,
|
|
19
|
+
name: permissionProjectSchema.shape.name.refine(value => !/[\p{Cc}\p{Cf}]/u.test(value), 'Invalid project name'),
|
|
20
|
+
root: permissionProjectSchema.shape.root,
|
|
21
|
+
scopes: assistApprovalSchema.shape.scopes,
|
|
22
|
+
commands: z.array(z.string().min(1).max(512)).max(16).default([]),
|
|
23
|
+
}).strict().refine(value => value.scopes.includes('execute') || value.commands.length === 0, 'Programs require explicit execute consent');
|
|
24
|
+
export const assistMultiApprovalSchema = z.object({
|
|
25
|
+
projects: z.array(assistApprovedProjectSchema).min(1).max(16),
|
|
26
|
+
durationMinutes: assistDurationSchema,
|
|
27
|
+
approvedAt: z.number().int().positive(),
|
|
28
|
+
expiresAt: z.number().int().positive(),
|
|
29
|
+
}).strict()
|
|
30
|
+
.refine(value => value.expiresAt > value.approvedAt && value.expiresAt - value.approvedAt <= value.durationMinutes * 60000, 'Invalid local authorization duration')
|
|
31
|
+
.refine(value => new Set(value.projects.map(project => project.id)).size === value.projects.length, 'Project IDs must be unique')
|
|
32
|
+
.refine(value => value.projects.reduce((total, project) => total + project.commands.length, 0) <= 64, 'At most 64 programs per session');
|
|
33
|
+
export const assistAnyApprovalSchema = z.union([assistApprovalSchema, assistMultiApprovalSchema]);
|
|
34
|
+
export const assistInviteViewSchema = z.object({
|
|
35
|
+
id: z.string().uuid(), operatorId: z.string().min(1).max(200), operatorName: z.string().min(1).max(128),
|
|
36
|
+
authorizationId: z.string().min(1).max(200), authorizationRevision: z.number().int().min(0),
|
|
37
|
+
scopes: z.array(assistScopeSchema).min(1).max(3), maxDurationMinutes: assistDurationSchema,
|
|
38
|
+
expiresAt: z.number().int().positive(), state: z.enum(['pending', 'claimed', 'revoked']),
|
|
39
|
+
}).strict();
|
|
40
|
+
export const assistDescriptorSchema = z.object({
|
|
41
|
+
sessionId: z.string().uuid(), deviceId: z.string().uuid(), inviteId: z.string().uuid(),
|
|
42
|
+
operatorId: z.string().min(1).max(200), deviceOwnerId: z.string().uuid(),
|
|
43
|
+
authorizationId: z.string().min(1).max(200), authorizationRevision: z.number().int().min(0),
|
|
44
|
+
localConsentRevision: z.number().int().positive(), approval: assistApprovalSchema,
|
|
45
|
+
}).strict();
|
|
46
|
+
export const assistMultiDescriptorSchema = assistDescriptorSchema.extend({ approval: assistMultiApprovalSchema }).strict();
|
|
47
|
+
export const assistAnyDescriptorSchema = z.union([assistDescriptorSchema, assistMultiDescriptorSchema]);
|
|
48
|
+
export const assistCleanupSchema = z.enum(['pending', 'confirmed', 'failed', 'unconfirmed']);
|
|
49
|
+
export const assistContextSchema = z.object({ sessionId: z.string().uuid(), localConsentRevision: z.number().int().positive() }).strict();
|
|
50
|
+
export function assistProject(approval) {
|
|
51
|
+
return permissionProjectSchema.parse({
|
|
52
|
+
id: 'assist', name: 'Remote Assist', root: approval.root,
|
|
53
|
+
readOnly: !approval.scopes.includes('write') && !approval.scopes.includes('execute'),
|
|
54
|
+
commands: approval.commands,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
export function approvedProjects(approval) {
|
|
58
|
+
return 'projects' in approval ? structuredClone(approval.projects) : [{ id: 'assist', name: 'Remote Assist', root: approval.root, scopes: [...approval.scopes], commands: [...approval.commands] }];
|
|
59
|
+
}
|
|
60
|
+
export function assistProjects(approval) {
|
|
61
|
+
return approvedProjects(approval).map(project => permissionProjectSchema.parse({
|
|
62
|
+
id: project.id, name: project.name, root: project.root,
|
|
63
|
+
readOnly: !project.scopes.includes('write') && !project.scopes.includes('execute'),
|
|
64
|
+
commands: project.commands,
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
export function assistFeature(approval) { return 'projects' in approval ? ASSIST_MULTI_FEATURE : ASSIST_FEATURE; }
|
|
68
|
+
export function approvalEqual(left, right) {
|
|
69
|
+
return JSON.stringify(assistAnyApprovalSchema.parse(left)) === JSON.stringify(assistAnyApprovalSchema.parse(right));
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=assist.js.map
|
package/dist/shared/protocol.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { remotePermissionsSchema } from './permissions.js';
|
|
3
|
-
|
|
3
|
+
import { assistContextSchema, assistDescriptorSchema, assistMultiDescriptorSchema, assistCleanupSchema, ASSIST_FEATURE, ASSIST_MULTI_FEATURE } from './assist.js';
|
|
4
|
+
export const VERSION = '0.4.15';
|
|
4
5
|
export const RUNNER_PROTOCOL = 2;
|
|
5
6
|
export const MAX_FRAME = 2 * 1024 * 1024;
|
|
6
7
|
export const SCOPES = ['read', 'write', 'execute', 'git'];
|
|
@@ -16,6 +17,8 @@ export const principalSchema = z.object({
|
|
|
16
17
|
authorizationRevision: z.number().int().min(0).optional(),
|
|
17
18
|
machineAccess: z.boolean().optional(),
|
|
18
19
|
unrestrictedExecution: z.boolean().optional(),
|
|
20
|
+
credentialExpiresAt: z.number().int().positive().optional(),
|
|
21
|
+
assist: assistContextSchema.optional(),
|
|
19
22
|
});
|
|
20
23
|
export function projectGranted(principal, deviceId, projectId) {
|
|
21
24
|
return (!principal.devices || principal.devices.includes(deviceId))
|
|
@@ -51,6 +54,7 @@ export const jobViewSchema = z.object({
|
|
|
51
54
|
authorizationId: z.string().max(200).optional(),
|
|
52
55
|
authorizationExpiresAt: z.number().int().positive().optional(),
|
|
53
56
|
authorizationRevision: z.number().int().min(0).optional(),
|
|
57
|
+
assist: assistContextSchema.optional(),
|
|
54
58
|
});
|
|
55
59
|
export const terminalJob = (job) => !['starting', 'running', 'stopping'].includes(job.state);
|
|
56
60
|
export const agentMessageSchema = z.discriminatedUnion('type', [
|
|
@@ -60,7 +64,10 @@ export const agentMessageSchema = z.discriminatedUnion('type', [
|
|
|
60
64
|
version: z.string().max(32), projects: z.array(projectViewSchema).max(100),
|
|
61
65
|
instanceId: z.string().uuid(),
|
|
62
66
|
capabilities: z.array(z.string().max(64)).max(64),
|
|
67
|
+
assist: z.object({ feature: z.enum([ASSIST_FEATURE, ASSIST_MULTI_FEATURE]), sessionId: z.string().uuid() }).strict().optional(),
|
|
63
68
|
}).strict(),
|
|
69
|
+
z.object({ type: z.literal('assist_approved'), sessionId: z.string().uuid(), localConsentRevision: z.number().int().positive() }).strict(),
|
|
70
|
+
z.object({ type: z.literal('assist_ended'), sessionId: z.string().uuid(), localConsentRevision: z.number().int().positive(), cleanup: assistCleanupSchema, reason: z.string().max(128) }).strict(),
|
|
64
71
|
z.object({ type: z.literal('permissions_applied'), revision: z.number().int().min(0), projects: z.array(projectViewSchema).max(100), error: z.string().max(512).optional() }),
|
|
65
72
|
z.object({ type: z.literal('result'), id: z.string().uuid(), result: resultSchema }),
|
|
66
73
|
z.object({ type: z.literal('job_update'), job: jobViewSchema }),
|
|
@@ -68,6 +75,10 @@ export const agentMessageSchema = z.discriminatedUnion('type', [
|
|
|
68
75
|
]);
|
|
69
76
|
export const relayMessageSchema = z.discriminatedUnion('type', [
|
|
70
77
|
z.object({ type: z.literal('welcome'), protocol: z.literal(RUNNER_PROTOCOL), deviceId: z.string(), permissions: remotePermissionsSchema, authorizations: z.array(z.object({ id: z.string().max(200), revision: z.number().int().min(0) })).max(10000) }),
|
|
78
|
+
z.object({ type: z.literal('assist_welcome'), protocol: z.literal(RUNNER_PROTOCOL), feature: z.literal(ASSIST_FEATURE), descriptor: assistDescriptorSchema, permissions: remotePermissionsSchema }).strict(),
|
|
79
|
+
z.object({ type: z.literal('assist_multi_welcome'), protocol: z.literal(RUNNER_PROTOCOL), feature: z.literal(ASSIST_MULTI_FEATURE), descriptor: assistMultiDescriptorSchema, permissions: remotePermissionsSchema }).strict(),
|
|
80
|
+
z.object({ type: z.literal('assist_active'), sessionId: z.string().uuid(), localConsentRevision: z.number().int().positive() }).strict(),
|
|
81
|
+
z.object({ type: z.literal('assist_stop'), sessionId: z.string().uuid(), reason: z.string().max(128) }).strict(),
|
|
71
82
|
z.object({ type: z.literal('permissions'), permissions: remotePermissionsSchema }),
|
|
72
83
|
z.object({ type: z.literal('authorization_changed'), authorizationId: z.string().max(200) }),
|
|
73
84
|
z.object({
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -71,6 +71,14 @@ Server 是设备项目设置的唯一来源,保存当前项目、永久回退
|
|
|
71
71
|
|
|
72
72
|
客户端每次 MCP dispatch 都重新从 Server 解析当前 token family 的永久或临时授权,并动态过滤 `tools/list`。`authorization_changed` 会让 Runner 停止该授权创建的任务;临时授权到期由 Server 定时清理,Runner 也依据调用和任务上的到期时间独立停止。`expectedRevision` 防止 Dashboard 中的旧编辑器覆盖较新的权限修改。
|
|
73
73
|
|
|
74
|
+
## Remote Assist
|
|
75
|
+
|
|
76
|
+
Remote Assist 复用 Server/MCP 与主动 Runner 通道,但使用专用一次性邀请和临时设备,不进入普通永久授权。协议 2 的普通握手保留;旧单项目握手为 `remote-assist-v1`,多项目使用 `remote-assist-multi-v1`、版本化 inspect/claim 和 `assist_multi_welcome`。必须匹配完整项目批准集合、session/localConsentRevision、本机批准和权限应用回执后才激活。多项目 Runner 遇旧 Server 拒绝降级。
|
|
77
|
+
|
|
78
|
+
Runner 持有独立本机范围和单调时长 fence,执行范围为当前客户端、会话与具体项目本机批准的交集;1–16 个项目各自限制 scopes/程序,拒绝重叠根及共享根内的获准程序。Server 不能替换该对象或提供永久 fallback。MCP 先解析准确目标设备,再按该项目派生专属 family grant,不写回 token/refresh 的原始设备快照;Assist 不允许省略 deviceId。管理员输出 impersonation、普通权限编辑和其他 family 不能旁路。最终批准后开始计时,停止覆盖全部项目,先封锁准入再有界清理进程,清理状态与会话终态分开。
|
|
79
|
+
|
|
80
|
+
详见[远程协助指南](REMOTE_ASSIST.md)。
|
|
81
|
+
|
|
74
82
|
## 配对与认证
|
|
75
83
|
|
|
76
84
|
配对码为 40 bit 随机值(10 位十六进制),10 分钟过期。Runner 另外持有 256 bit 轮询凭据;管理员仅能批准码,不能从码直接领取设备令牌。领取操作和状态转移使用 SQLite 事务,成功后立即消费。Server 只保存设备令牌的 SHA-256。
|
package/docs/OPEN_SOURCE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 开源仓库与源码发布
|
|
2
2
|
|
|
3
|
-
本仓库以 MIT 开放原始代码,版本为 0.4.
|
|
3
|
+
本仓库以 MIT 开放原始代码,版本为 0.4.15,npm 发布拆成 `homeagent-server` 和 `homeagent-runner` 两个包。Server 包只包含编译后的 Server、Dashboard 和 Server 资源;Runner 包只包含 Runner、共享协议和 Windows 进程树辅助代码。CLI 和源码采用相同许可证;两个 npm 包都通过文件白名单只包含运行所需文件、文档和许可证。包名是否可用及账号发布权限以发布当时的 registry 为准。
|
|
4
4
|
|
|
5
5
|
## 文件划分
|
|
6
6
|
|
|
@@ -53,7 +53,7 @@ npm run release:source
|
|
|
53
53
|
|
|
54
54
|
输出位于被忽略的 release/:
|
|
55
55
|
|
|
56
|
-
- `HomeAgent-v0.4.
|
|
56
|
+
- `HomeAgent-v0.4.15-source.tar.gz`
|
|
57
57
|
- 对应 `.sha256` 校验文件
|
|
58
58
|
- 对应 `.manifest.txt`,包括版本、Git 提交和全部发布路径
|
|
59
59
|
|
|
@@ -65,8 +65,8 @@ npm run release:source
|
|
|
65
65
|
|
|
66
66
|
`npm run release:npm` 构建 JavaScript、以 `--ignore-scripts` 分别打包两个包,并检查归档文件白名单、运行资源及 SHA-512 完整性,输出:
|
|
67
67
|
|
|
68
|
-
- `release/homeagent-server-0.4.
|
|
69
|
-
- `release/homeagent-runner-0.4.
|
|
68
|
+
- `release/homeagent-server-0.4.15.tgz`
|
|
69
|
+
- `release/homeagent-runner-0.4.15.tgz`
|
|
70
70
|
- 两个归档各自的 `.sha256`
|
|
71
71
|
- `release/npm-packages.json`:两个包的名称、版本、Git commit、校验、dist-tag 和路径清单
|
|
72
72
|
|
|
@@ -76,20 +76,20 @@ npm run release:source
|
|
|
76
76
|
|
|
77
77
|
`.github/workflows/release.yml` 支持两种入口:
|
|
78
78
|
|
|
79
|
-
1. 推送版本标签,例如 `v0.4.
|
|
79
|
+
1. 推送版本标签,例如 `v0.4.15`。
|
|
80
80
|
2. 在 Actions → release → Run workflow 中填写**已经存在**的版本标签。
|
|
81
81
|
|
|
82
82
|
先按下一节配置 `NPM_TOKEN`。首次推送源码、配置真实 `origin` 并确认 Actions 可用后,可以按下面方式发布:
|
|
83
83
|
|
|
84
84
|
```sh
|
|
85
85
|
# 先提交本次版本的源码和文档,工作区保持干净
|
|
86
|
-
git tag -a v0.4.
|
|
87
|
-
git push origin v0.4.
|
|
86
|
+
git tag -a v0.4.15 -m "HomeAgent v0.4.15"
|
|
87
|
+
git push origin v0.4.15
|
|
88
88
|
```
|
|
89
89
|
|
|
90
90
|
本文只是发布说明,准备脚本不会替操作者执行这些命令。
|
|
91
91
|
|
|
92
|
-
标签必须与 package.json、package-lock.json 及 runtime VERSION 一致,CHANGELOG.md 必须有对应版本的非空条目。预发布可用 `v0.4.
|
|
92
|
+
标签必须与 package.json、package-lock.json 及 runtime VERSION 一致,CHANGELOG.md 必须有对应版本的非空条目。预发布可用 `v0.4.15-rc.1`(相关版本文件也必须为 `0.4.15-rc.1`)。禁止把普通分支或不匹配版本伪装成发布。
|
|
93
93
|
|
|
94
94
|
发布流水线按次序执行:
|
|
95
95
|
|
package/docs/README.md
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
- [部署、配对与运维](DEPLOYMENT.md):原生/Compose、HTTPS、反代、Runner、自启动、备份。
|
|
6
6
|
- [AI 客户端接入](CLIENTS.md):OAuth/PAT、协议与调用方式。
|
|
7
7
|
- [日常开发流程](DEVELOPMENT_WORKFLOW.md):命令环境、按行读取、多文件编辑、日志、安全提交与接续。
|
|
8
|
+
- [远程协助](REMOTE_ASSIST.md):邀请朋友、本机临时批准、独立到期与立即停止。
|
|
8
9
|
- [工具与权限参考](TOOLS.md):参数、限额、scope、管理 API。
|
|
9
10
|
|
|
10
11
|
## 维护与安全
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Remote Assist · 远程协助
|
|
2
|
+
|
|
3
|
+
Remote Assist 是 HomeAgent 的临时连接模式。设备持有人无需管理员账号或模型 API Key,在自己的 Runner 中批准 1–16 个项目、各自的操作权限和统一时长;Runner 独立决定请求是否能执行。Personal / Work 的普通永久配对仍保持原行为。
|
|
4
|
+
|
|
5
|
+
## 使用流程
|
|
6
|
+
|
|
7
|
+
1. 操作者先在 AI 客户端建立 OAuth/PAT 连接,并授予所需 read/write/execute scopes。
|
|
8
|
+
2. Dashboard 的「设备与项目」→「邀请朋友」中选择该客户端授权、请求方显示名称、允许请求的权限和最长时长。
|
|
9
|
+
3. 生成后点击「复制连接命令」,私下发给朋友。命令包含后端域名和 10 分钟有效的一次性邀请,例如 `homeagent assist "https://你的后端域名/assist#id=…&token=…"`,无需朋友另行配置服务地址。也可单独复制邀请链接;打开链接不会消费邀请。邀请是 bearer capability,持有者可领取,不是朋友身份验证。
|
|
10
|
+
4. 朋友安装 Runner 后,将完整命令粘贴到终端,即可进入本机审批。命令中的邀请密钥可能留在终端历史中;不希望留在历史时,运行 `homeagent assist` 后输入链接,或运行 `homeagent`,在设置中选择「加入远程协助」再粘贴链接。
|
|
11
|
+
5. 在本机项目清单中添加、修改或移除项目。当前目录使用手工绝对路径输入;每个项目单独选择只读/文件写入及指定程序,例如源码可编辑、资料只读。完成清单后选择 30 分钟 / 2 小时 / 8 小时内的统一时长,并逐项核对。
|
|
12
|
+
6. 最终批准后立即开始本机计时。权限应用成功后,绑定客户端通过原有 `/mcp` 调用 `list_devices`,使用返回的准确 deviceId 和项目 ID 开始工作,不需要更换模型或客户端凭据。新流程的项目 ID 在本机草稿创建时生成,不固定为 `assist`。
|
|
13
|
+
7. 本机「立即停止」、退出、到期、断线或绑定授权变更会结束全部项目的会话。批准后清单固定;添加项目、换目录或扩权需要结束旧会话,创建新邀请并重新本机批准。
|
|
14
|
+
|
|
15
|
+
邀请允许请求的范围不是实际执行权限。最终范围是当前客户端授权、邀请/会话范围与本机批准的交集;其他客户端不会因为设备出现而自动得到权限。
|
|
16
|
+
|
|
17
|
+
## 本机上限
|
|
18
|
+
|
|
19
|
+
- 1–16 个项目、唯一 ID、项目级路径,保留私有配置与默认排除项;不得由 Server 增加根目录、移除排除项或开放设备级路径。重复和父子重叠目录不能共享。
|
|
20
|
+
- 每项目默认只读。文件写入与程序执行分别确认;每项目最多 16 个程序,全会话最多 64 个。程序只接受所有共享根之外安装的绝对可执行文件路径,禁止另一个可写项目替换获准入口;不支持任意程序模式、远端 alias/environment profile。
|
|
21
|
+
- 只允许受控 Git 只读工具;MVP 不开放 Git 写入、push、网络或 linked worktree 的外部 common directory。
|
|
22
|
+
- 本机固定期限使用单调计时和墙钟最早截止,Server 修改时间或系统时钟回拨不能延长。
|
|
23
|
+
- 临时连接使用独立私有状态目录,不覆盖普通 Runner 配置/凭据,不保存可自动恢复的批准,不安装自启动。
|
|
24
|
+
- 新授权要求交互式本机终端;服务和非 TTY 脚本不能静默批准。`--plain` 仅改变显示方式,不取消本机审批。
|
|
25
|
+
|
|
26
|
+
## 版本兼容
|
|
27
|
+
|
|
28
|
+
普通 Runner protocol 2 不变。新多项目流程使用 `remote-assist-multi-v1`、`/assist/v2/inspect` 与 `/assist/v2/claim`;邀请链接及连接命令不变。新 Runner 遇旧 Server 明确提示升级,不降级成普通配对,也不会只共享首个项目。新 Server 保留旧 `remote-assist-v1` 单项目流程,旧持久化批准记录仍可显示,但已结束会话不能恢复。
|
|
29
|
+
|
|
30
|
+
网页盘符/目录选择器及本机目录导航尚未接入;普通设备仍可在网页手工填写多个项目路径,新增项目仍需另行选择客户端授权范围。
|
|
31
|
+
|
|
32
|
+
## 停止与观察
|
|
33
|
+
|
|
34
|
+
停止先阻止新操作和排队请求,再取消调用并清理托管进程树。界面区分访问已封锁、任务停止已确认、停止失败与离线未确认。清理失败不能恢复访问,可在本机再次请求清理。
|
|
35
|
+
|
|
36
|
+
Dashboard 展示会话及任务元数据,不能用管理员 impersonation 绕过本机授权读取协助内容;输出由绑定 MCP 客户端读取。本机状态目录保留有界参数摘要审计和现有任务输出,活动界面可查看状态。Server 审计不是抗管理员篡改账本。
|
|
37
|
+
|
|
38
|
+
## 必须理解的风险
|
|
39
|
+
|
|
40
|
+
Server 仍负责客户端认证并声明操作者身份。本机授权限制 Server 的执行范围,不提供请求方端到端身份证明。持邀请链接者可领取,请使用可信 Server、私下分享链接。
|
|
41
|
+
|
|
42
|
+
**允许解释器或构建工具仍允许它们使用 Runner 系统账户权限。** 程序列表限制入口,不限制 AI 提供的参数或项目脚本行为;它们可能访问项目外文件、网络、凭据或启动外部服务。需要强隔离时使用低权限账户、容器/VM,Linux 强杀场景应有 cgroup/systemd 约束。可写项目也可能触发已有热加载服务。
|
|
43
|
+
|
|
44
|
+
没有模型 API Key 不等于没有数据传输。读取的代码、文件和执行结果会返回操作者的 AI 客户端,并可能进入所选模型服务。公司设备和资料必须符合组织授权、数据政策和 AI 使用政策。
|
|
45
|
+
|
|
46
|
+
撤销不能回滚已完成修改、终止所有外部服务或收回已经传输的数据。本功能不是 OS 沙箱、远程桌面、离线 supervisor 或多租户系统。
|
package/package.json
CHANGED