feat(companion): add HTTPS pairing and scoped device authority

This commit is contained in:
Agent Workbench Dev
2026-10-31 17:38:57 +08:00
parent 06c9fac87e
commit dfe2e40387
24 changed files with 2572 additions and 5 deletions
+11 -1
View File
@@ -652,8 +652,18 @@ export class Runtime {
if (signal.aborted) terminate();
});
}
async stop(sessionId) {
async stop(sessionId, expected = null) {
const original = this.active.get(sessionId);
const assertOriginal = () => {
if (!expected) return;
const session = this.store.session(sessionId);
if (session.taskId !== expected.taskId || session.runId !== expected.runId || this.active.get(sessionId) && this.active.get(sessionId) !== original) {
throw Object.assign(new Error('原停止请求的任务或运行已变化。'), { status: 409 });
}
};
assertOriginal();
await this.workers?.stopParent(sessionId);
assertOriginal();
const run = this.active.get(sessionId);
if (!run) { await this.checks?.stop(sessionId); await this.deliveries?.stop(sessionId); await this.changeSets?.stop(sessionId); await this.workspaces?.stop(sessionId); await this.research?.stop(sessionId); await this.engines?.stop(sessionId); await this.browser?.stop(sessionId); await this.mcp?.stop(sessionId); await this.taskPlans?.settle(sessionId); return; }
const session = this.store.session(sessionId);