@beeos-ai/device-agent 0.10.2 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/adapters/agent-gateway-client.d.ts +143 -14
  2. package/dist/adapters/agent-gateway-client.js +112 -17
  3. package/dist/adapters/agent-gateway-client.js.map +1 -1
  4. package/dist/app/multi-device-host.d.ts +4 -0
  5. package/dist/app/multi-device-host.js +4 -0
  6. package/dist/app/multi-device-host.js.map +1 -1
  7. package/dist/bootstrap.d.ts +7 -0
  8. package/dist/bootstrap.js +12 -1
  9. package/dist/bootstrap.js.map +1 -1
  10. package/dist/device/android.js +23 -12
  11. package/dist/device/android.js.map +1 -1
  12. package/dist/fleet/adapters/process/in-process-manager.d.ts +4 -0
  13. package/dist/fleet/adapters/process/in-process-manager.js +4 -0
  14. package/dist/fleet/adapters/process/in-process-manager.js.map +1 -1
  15. package/dist/fleet/adapters/state/beeos-cli-store.d.ts +6 -3
  16. package/dist/fleet/adapters/state/beeos-cli-store.js +6 -3
  17. package/dist/fleet/adapters/state/beeos-cli-store.js.map +1 -1
  18. package/dist/fleet/domain/device.d.ts +7 -5
  19. package/dist/fleet/domain/device.js.map +1 -1
  20. package/dist/fleet/http/status-client.d.ts +1 -0
  21. package/dist/fleet/http/status-client.js +9 -0
  22. package/dist/fleet/http/status-client.js.map +1 -1
  23. package/dist/fleet/http/status-server.d.ts +8 -0
  24. package/dist/fleet/http/status-server.js +24 -0
  25. package/dist/fleet/http/status-server.js.map +1 -1
  26. package/dist/fleet/ports/state-registry.d.ts +5 -4
  27. package/dist/fleet/ports/state-registry.js +5 -4
  28. package/dist/fleet/ports/state-registry.js.map +1 -1
  29. package/dist/fleet/state/state-json.d.ts +3 -3
  30. package/dist/inbound/cli/fleet-command.js +70 -2
  31. package/dist/inbound/cli/fleet-command.js.map +1 -1
  32. package/dist/inbound/cli/main.js +0 -1
  33. package/dist/inbound/cli/main.js.map +1 -1
  34. package/dist/index.d.ts +1 -1
  35. package/dist/index.js +1 -1
  36. package/dist/index.js.map +1 -1
  37. package/dist/plugins/agent-sync/index.d.ts +38 -20
  38. package/dist/plugins/agent-sync/index.js +375 -59
  39. package/dist/plugins/agent-sync/index.js.map +1 -1
  40. package/dist/plugins/http-debug/index.js +2 -1
  41. package/dist/plugins/http-debug/index.js.map +1 -1
  42. package/dist/plugins/http-debug/server.d.ts +4 -0
  43. package/dist/plugins/http-debug/server.js +11 -0
  44. package/dist/plugins/http-debug/server.js.map +1 -1
  45. package/dist/runtime-authority/canonical.d.ts +7 -0
  46. package/dist/runtime-authority/canonical.js +36 -0
  47. package/dist/runtime-authority/canonical.js.map +1 -0
  48. package/dist/runtime-authority/contract.d.ts +30 -0
  49. package/dist/runtime-authority/contract.js +50 -0
  50. package/dist/runtime-authority/contract.js.map +1 -0
  51. package/package.json +4 -4
@@ -1,28 +1,42 @@
1
1
  /**
2
- * Plugin — agent-sync.
2
+ * Runtime authority + Agent projection lifecycle.
3
3
  *
4
- * Posts a single `POST /api/v1/agents/sync` to Agent Gateway during
5
- * `start()` so the device-agent appears in the platform's Agents
6
- * directory and is discoverable via A2A.
7
- *
8
- * Failure is non-fatal — sync errors only emit a warning, the device
9
- * still serves ACP normally. This keeps ground-truth agent metadata
10
- * close to the binary that hosts the actual capabilities, while
11
- * allowing development setups (no AGW reachability, no key file)
12
- * to keep working.
13
- *
14
- * Resync semantics:
15
- * - one shot at start (parity with the legacy `main.ts` behavior)
16
- * - if `BEEOS_AGENT_SYNC_INTERVAL_MS` (or the constructor option) is
17
- * set to a positive number, we re-post on that cadence; default off
4
+ * Each attached device owns an independent logical runtime lease even when
5
+ * multiple device runtimes share one OS process. Lease credentials remain
6
+ * memory-only and are never included in logs.
7
+ */
8
+ import { heartbeatRuntime, registerRuntime, syncAgents, } from "../../adapters/agent-gateway-client.js";
9
+ import { AGENT_PROJECTION_HASH_DOMAIN, DEVICE_RUNTIME_CAPABILITIES, DEVICE_RUNTIME_CONTRACT_REVISION, DEVICE_RUNTIME_METHODS, DEVICE_RUNTIME_RPC_PROTOCOL_VERSION, verifiedAdmittedManifestDigest, } from "../../runtime-authority/contract.js";
10
+ import { runtimeDomainHash, sha256Hex, } from "../../runtime-authority/canonical.js";
11
+ const REGISTER_RETRY_MS = 5_000;
12
+ const HANDOFF_RETRY_MS = 65_000;
13
+ const SYNC_RETRY_MS = 5_000;
14
+ /**
15
+ * The Agent Gateway rejects registrations whose method or capability list is
16
+ * empty, so an empty declaration would thrash the register loop without ever
17
+ * healing. Fail closed instead of advertising an authority we cannot obtain.
18
18
  */
19
- import { syncAgents, } from "../../adapters/agent-gateway-client.js";
19
+ export function resolveRegistrationManifestDigest() {
20
+ if (DEVICE_RUNTIME_METHODS.length === 0 || DEVICE_RUNTIME_CAPABILITIES.length === 0) {
21
+ throw new Error(`runtime registration refused: methods=${DEVICE_RUNTIME_METHODS.length} capabilities=${DEVICE_RUNTIME_CAPABILITIES.length}`);
22
+ }
23
+ return verifiedAdmittedManifestDigest();
24
+ }
20
25
  export class AgentSyncPlugin {
21
26
  opts;
22
27
  name = "agent-sync";
23
28
  ctx;
24
- timer = null;
25
- stopped = false;
29
+ stopped = true;
30
+ generation = 0;
31
+ controlTimer = null;
32
+ expiryTimer = null;
33
+ syncTimer = null;
34
+ periodicSync = null;
35
+ lease = null;
36
+ identity = null;
37
+ acceptedRevision = 0;
38
+ acceptedHash = "";
39
+ queue = Promise.resolve();
26
40
  constructor(opts) {
27
41
  this.opts = opts;
28
42
  }
@@ -30,79 +44,381 @@ export class AgentSyncPlugin {
30
44
  this.ctx = ctx;
31
45
  }
32
46
  async start() {
33
- if (!this.ctx)
47
+ if (!this.ctx || this.ctx.config.standalone)
34
48
  return;
35
- await this.runOnce();
49
+ this.stopped = false;
50
+ const generation = ++this.generation;
51
+ await this.enqueue(() => this.registerOnce(generation));
36
52
  const interval = this.opts.intervalMs ??
37
53
  Number(process.env.BEEOS_AGENT_SYNC_INTERVAL_MS ?? "0");
38
54
  if (interval > 0) {
39
- this.timer = setInterval(() => {
40
- if (this.stopped)
41
- return;
42
- void this.runOnce();
55
+ this.periodicSync = setInterval(() => {
56
+ void this.enqueue(() => this.syncProjection(generation, false));
43
57
  }, interval);
44
- this.timer.unref?.();
58
+ this.periodicSync.unref?.();
45
59
  }
46
60
  }
47
61
  async stop() {
48
62
  this.stopped = true;
49
- if (this.timer) {
50
- clearInterval(this.timer);
51
- this.timer = null;
52
- }
63
+ this.generation++;
64
+ this.clearTimers();
65
+ this.lease = null;
66
+ this.identity = null;
67
+ await this.queue.catch(() => undefined);
53
68
  }
54
- async runOnce() {
55
- if (!this.ctx)
69
+ async registerOnce(generation) {
70
+ if (!this.isCurrent(generation) || !this.ctx)
56
71
  return;
57
72
  const { config, log } = this.ctx;
58
- if (!config.agentGatewayUrl) {
59
- log.debug("agent-sync: agentGatewayUrl unset, skipping");
73
+ if (!config.agentGatewayUrl)
60
74
  return;
61
- }
62
75
  const identity = await this.opts.loadIdentity().catch(() => null);
63
76
  if (!identity) {
64
- log.debug("agent-sync: identity unavailable, skipping");
77
+ log.warn("runtime-authority: identity unavailable; retrying registration");
78
+ this.scheduleRegister(REGISTER_RETRY_MS, generation);
65
79
  return;
66
80
  }
67
- let agents;
81
+ this.identity = identity;
82
+ let manifestDigest;
68
83
  try {
69
- agents = await this.opts.buildDeclarations();
70
- }
71
- catch (e) {
72
- log.warn({ err: e.message }, "agent-sync: declaration build failed");
73
- return;
84
+ manifestDigest = resolveRegistrationManifestDigest();
74
85
  }
75
- if (agents.length === 0) {
76
- log.debug("agent-sync: no declarations to publish");
86
+ catch (error) {
87
+ // A defective contract cannot heal by retrying, and the gateway rejects it
88
+ // with a 400 that would otherwise thrash the register loop forever.
89
+ log.error({ err: error.message }, "runtime-authority: runtime contract invalid; not registering");
77
90
  return;
78
91
  }
92
+ const fingerprint = sha256Hex(identity.publicKey);
93
+ const payload = {
94
+ registrationId: `device-agent-${fingerprint.slice(0, 32)}`,
95
+ handlerIdentity: `device-agent:${fingerprint.slice(0, 32)}`,
96
+ contractRevision: DEVICE_RUNTIME_CONTRACT_REVISION,
97
+ manifestDigest,
98
+ runtimeRpcProtocolVersion: DEVICE_RUNTIME_RPC_PROTOCOL_VERSION,
99
+ runtimeMethods: [...DEVICE_RUNTIME_METHODS],
100
+ capabilities: [...DEVICE_RUNTIME_CAPABILITIES],
101
+ journalStoreId: `device-agent:${fingerprint}`,
102
+ journalGeneration: "1",
103
+ };
79
104
  try {
80
- const result = await syncAgents({
105
+ const result = await registerRuntime({
81
106
  agentGatewayUrl: config.agentGatewayUrl,
82
107
  identity,
83
- agents,
108
+ payload,
109
+ fetchImpl: this.opts.fetchImpl,
110
+ now: this.opts.now,
111
+ randomUUID: this.opts.randomUUID,
84
112
  });
113
+ if (!this.isCurrent(generation))
114
+ return;
115
+ if (result.status !== "active" ||
116
+ !result.instanceId ||
117
+ !result.leaseId ||
118
+ !result.runtimeLeaseCredential ||
119
+ !result.leaseExpiresAt ||
120
+ !result.heartbeatIntervalMs ||
121
+ !result.runtimeEpoch) {
122
+ log.warn({ status: result.status, activeRuntimeEpoch: result.activeRuntimeEpoch }, "runtime-authority: registration fenced; waiting for handoff");
123
+ this.dropLease();
124
+ this.scheduleRegister(HANDOFF_RETRY_MS, generation);
125
+ return;
126
+ }
127
+ if (Date.parse(result.leaseExpiresAt) <= this.now()) {
128
+ throw new Error("runtime authority returned an expired lease");
129
+ }
130
+ const sameEpoch = this.lease?.runtimeEpoch === result.runtimeEpoch;
131
+ this.lease = {
132
+ instanceId: result.instanceId,
133
+ leaseId: result.leaseId,
134
+ runtimeEpoch: result.runtimeEpoch,
135
+ runtimeLeaseCredential: result.runtimeLeaseCredential,
136
+ leaseExpiresAt: result.leaseExpiresAt,
137
+ heartbeatIntervalMs: result.heartbeatIntervalMs,
138
+ };
139
+ if (!sameEpoch) {
140
+ this.acceptedRevision = 0;
141
+ this.acceptedHash = "";
142
+ }
143
+ this.scheduleExpiry(generation);
85
144
  log.info({
145
+ runtimeEpoch: this.lease.runtimeEpoch,
146
+ leaseExpiresAt: this.lease.leaseExpiresAt,
147
+ }, "runtime-authority: active lease acquired");
148
+ await this.syncProjection(generation, true);
149
+ this.scheduleHeartbeat(this.lease.heartbeatIntervalMs, generation);
150
+ }
151
+ catch (error) {
152
+ if (!this.isCurrent(generation))
153
+ return;
154
+ const gatewayError = error;
155
+ const retryMs = gatewayError.status === 409
156
+ ? HANDOFF_RETRY_MS
157
+ : REGISTER_RETRY_MS;
158
+ log.warn({
159
+ err: gatewayError.message,
160
+ status: gatewayError.status,
161
+ retryMs,
162
+ }, "runtime-authority: registration failed");
163
+ this.dropLease();
164
+ this.scheduleRegister(retryMs, generation);
165
+ }
166
+ }
167
+ async heartbeat(generation) {
168
+ if (!this.isCurrent(generation) || !this.ctx || !this.identity || !this.lease)
169
+ return;
170
+ const active = this.lease;
171
+ try {
172
+ const result = await heartbeatRuntime({
173
+ agentGatewayUrl: this.ctx.config.agentGatewayUrl,
174
+ identity: this.identity,
175
+ registrationId: this.registrationId(this.identity),
176
+ payload: {
177
+ leaseId: active.leaseId,
178
+ handlerIdentity: this.handlerIdentity(this.identity),
179
+ runtimeEpoch: active.runtimeEpoch,
180
+ },
181
+ fetchImpl: this.opts.fetchImpl,
182
+ now: this.opts.now,
183
+ randomUUID: this.opts.randomUUID,
184
+ });
185
+ if (!this.isCurrent(generation) || this.lease !== active)
186
+ return;
187
+ if (result.status !== "renewed" ||
188
+ !result.runtimeLeaseCredential ||
189
+ !result.leaseExpiresAt) {
190
+ this.ctx.log.warn({ status: result.status, activeRuntimeEpoch: result.activeRuntimeEpoch }, "runtime-authority: heartbeat fenced");
191
+ this.dropLease();
192
+ this.scheduleRegister(REGISTER_RETRY_MS, generation);
193
+ return;
194
+ }
195
+ this.lease = {
196
+ ...active,
197
+ runtimeLeaseCredential: result.runtimeLeaseCredential,
198
+ leaseExpiresAt: result.leaseExpiresAt,
199
+ };
200
+ this.scheduleExpiry(generation);
201
+ this.scheduleHeartbeat(active.heartbeatIntervalMs, generation);
202
+ }
203
+ catch (error) {
204
+ if (!this.isCurrent(generation) || this.lease !== active)
205
+ return;
206
+ this.ctx.log.warn({ err: error.message }, "runtime-authority: heartbeat transport failure");
207
+ if (Date.parse(active.leaseExpiresAt) > this.now()) {
208
+ this.scheduleHeartbeat(Math.min(active.heartbeatIntervalMs, REGISTER_RETRY_MS), generation);
209
+ }
210
+ else {
211
+ this.dropLease();
212
+ this.scheduleRegister(REGISTER_RETRY_MS, generation);
213
+ }
214
+ }
215
+ }
216
+ async syncProjection(generation, force, allowConflictRetry = true) {
217
+ if (!this.isCurrent(generation) || !this.ctx || !this.identity || !this.lease)
218
+ return;
219
+ const declarations = await this.opts.buildDeclarations().catch((error) => {
220
+ this.ctx.log.warn({ err: error.message }, "agent-sync: declaration build failed");
221
+ return null;
222
+ });
223
+ if (!declarations?.length)
224
+ return;
225
+ const agents = this.toProjection(declarations, this.identity);
226
+ const canonicalHash = runtimeDomainHash(AGENT_PROJECTION_HASH_DOMAIN, {
227
+ agentsComplete: true,
228
+ agents,
229
+ });
230
+ if (!force && canonicalHash === this.acceptedHash)
231
+ return;
232
+ const revision = this.acceptedRevision + 1;
233
+ const active = this.lease;
234
+ const snapshotId = `device-${active.runtimeEpoch}-${revision}-${canonicalHash.slice(0, 16)}`;
235
+ try {
236
+ const result = await syncAgents({
237
+ agentGatewayUrl: this.ctx.config.agentGatewayUrl,
238
+ identity: this.identity,
239
+ request: {
240
+ runtimeEpoch: active.runtimeEpoch,
241
+ revision: String(revision),
242
+ snapshotId,
243
+ canonicalHash,
244
+ agentsComplete: true,
245
+ skillsComplete: true,
246
+ agents,
247
+ runtimeLeaseCredential: active.runtimeLeaseCredential,
248
+ },
249
+ fetchImpl: this.opts.fetchImpl,
250
+ now: this.opts.now,
251
+ randomUUID: this.opts.randomUUID,
252
+ });
253
+ if (!this.isCurrent(generation) || this.lease !== active)
254
+ return;
255
+ if (!result.accepted) {
256
+ const acceptedRevision = Number(result.revision);
257
+ if (result.runtimeEpoch !== active.runtimeEpoch) {
258
+ this.ctx.log.warn({
259
+ runtimeEpoch: active.runtimeEpoch,
260
+ acceptedRuntimeEpoch: result.runtimeEpoch,
261
+ }, "agent-sync: projection fenced by a newer runtime epoch");
262
+ this.dropLease();
263
+ this.scheduleRegister(REGISTER_RETRY_MS, generation);
264
+ return;
265
+ }
266
+ if (Number.isSafeInteger(acceptedRevision) && acceptedRevision > 0) {
267
+ this.acceptedRevision = acceptedRevision;
268
+ this.acceptedHash = result.canonicalHash;
269
+ }
270
+ if (result.canonicalHash !== canonicalHash) {
271
+ if (allowConflictRetry) {
272
+ await this.syncProjection(generation, true, false);
273
+ }
274
+ else {
275
+ this.scheduleSyncRetry(generation);
276
+ }
277
+ }
278
+ return;
279
+ }
280
+ this.acceptedRevision = Number(result.revision) || revision;
281
+ this.acceptedHash = result.canonicalHash || canonicalHash;
282
+ this.ctx.log.info({
86
283
  created: result.created,
87
284
  updated: result.updated,
88
285
  deactivated: result.deactivated,
89
- agents: result.agents.map((a) => ({ id: a.id, name: a.name, status: a.status })),
90
- }, "agent-sync: agents synced to platform");
286
+ runtimeEpoch: active.runtimeEpoch,
287
+ revision: this.acceptedRevision,
288
+ }, "agent-sync: runtime projection accepted");
91
289
  }
92
- catch (e) {
93
- const ae = e;
94
- if (ae.status === 401) {
95
- // A definitive 401 is categorically different from a transient
96
- // failure: the platform no longer recognises this device's
97
- // Ed25519 key (instance deleted / unbound). Surface it loudly so
98
- // operators see it in `fleet logs` rather than burying it in a
99
- // generic warn alongside network blips.
100
- log.error({ err: ae.message, status: ae.status, body: ae.body }, "agent-sync: agents/sync rejected with 401 — the platform no longer recognises this device's Ed25519 key (instance deleted/unbound); the agent will be absent from the platform directory until re-bound (see scripts/device-rebind-guide.md)");
101
- }
102
- else {
103
- log.warn({ err: ae.message, status: ae.status, body: ae.body }, "agent-sync: sync failed (non-fatal)");
290
+ catch (error) {
291
+ if (!this.isCurrent(generation))
292
+ return;
293
+ const gatewayError = error;
294
+ this.ctx.log.warn({ err: gatewayError.message, status: gatewayError.status }, "agent-sync: projection failed");
295
+ if (gatewayError.status === 401 || gatewayError.status === 409) {
296
+ this.dropLease();
297
+ this.scheduleRegister(REGISTER_RETRY_MS, generation);
298
+ return;
104
299
  }
300
+ this.scheduleSyncRetry(generation);
105
301
  }
106
302
  }
303
+ toProjection(declarations, identity) {
304
+ const fingerprint = sha256Hex(identity.publicKey);
305
+ return declarations
306
+ .map((agent) => ({
307
+ runtimeAgentUid: `device:${fingerprint}:${agent.name}`,
308
+ localKey: agent.name,
309
+ displayName: agent.displayName ?? agent.name,
310
+ ...(agent.description ? { description: agent.description } : {}),
311
+ ...(agent.version ? { version: agent.version } : {}),
312
+ ...(agent.avatarUrl ? { avatarUrl: agent.avatarUrl } : {}),
313
+ ...(agent.homepage ? { homepage: agent.homepage } : {}),
314
+ capabilities: {
315
+ canvas: agent.capabilities?.canvas === true,
316
+ terminal: agent.capabilities?.terminal === true,
317
+ webSsh: agent.capabilities?.webSsh === true,
318
+ fileSystem: agent.capabilities?.fileSystem === true,
319
+ image: agent.capabilities?.image === true,
320
+ audio: agent.capabilities?.audio === true,
321
+ mcp: agent.capabilities?.mcp === true,
322
+ cron: agent.capabilities?.cron === true,
323
+ streaming: agent.capabilities?.streaming === true,
324
+ pushNotifications: agent.capabilities?.pushNotifications === true,
325
+ },
326
+ skills: (agent.skills ?? [])
327
+ .map((skill) => ({
328
+ skillKey: skill.id || skill.name,
329
+ name: skill.name,
330
+ ...(skill.description ? { description: skill.description } : {}),
331
+ enabled: true,
332
+ }))
333
+ .sort((left, right) => left.skillKey.localeCompare(right.skillKey)),
334
+ skillsComplete: true,
335
+ }))
336
+ .sort((left, right) => left.runtimeAgentUid.localeCompare(right.runtimeAgentUid));
337
+ }
338
+ scheduleRegister(delayMs, generation) {
339
+ if (!this.isCurrent(generation))
340
+ return;
341
+ if (this.controlTimer)
342
+ clearTimeout(this.controlTimer);
343
+ this.controlTimer = setTimeout(() => {
344
+ this.controlTimer = null;
345
+ void this.enqueue(() => this.registerOnce(generation));
346
+ }, delayMs);
347
+ }
348
+ scheduleHeartbeat(delayMs, generation) {
349
+ if (!this.isCurrent(generation))
350
+ return;
351
+ if (this.controlTimer)
352
+ clearTimeout(this.controlTimer);
353
+ this.controlTimer = setTimeout(() => {
354
+ this.controlTimer = null;
355
+ void this.enqueue(() => this.heartbeat(generation));
356
+ }, delayMs);
357
+ this.controlTimer.unref?.();
358
+ }
359
+ scheduleSyncRetry(generation) {
360
+ if (!this.isCurrent(generation) || this.syncTimer)
361
+ return;
362
+ this.syncTimer = setTimeout(() => {
363
+ this.syncTimer = null;
364
+ void this.enqueue(() => this.syncProjection(generation, true));
365
+ }, SYNC_RETRY_MS);
366
+ this.syncTimer.unref?.();
367
+ }
368
+ scheduleExpiry(generation) {
369
+ if (this.expiryTimer)
370
+ clearTimeout(this.expiryTimer);
371
+ const expected = this.lease;
372
+ if (!expected)
373
+ return;
374
+ const remaining = Math.max(0, Date.parse(expected.leaseExpiresAt) - this.now());
375
+ this.expiryTimer = setTimeout(() => {
376
+ this.expiryTimer = null;
377
+ if (!this.isCurrent(generation) || this.lease !== expected)
378
+ return;
379
+ this.ctx?.log.warn("runtime-authority: lease expired");
380
+ this.dropLease();
381
+ this.scheduleRegister(REGISTER_RETRY_MS, generation);
382
+ }, remaining);
383
+ this.expiryTimer.unref?.();
384
+ }
385
+ registrationId(identity) {
386
+ return `device-agent-${sha256Hex(identity.publicKey).slice(0, 32)}`;
387
+ }
388
+ handlerIdentity(identity) {
389
+ return `device-agent:${sha256Hex(identity.publicKey).slice(0, 32)}`;
390
+ }
391
+ dropLease() {
392
+ this.lease = null;
393
+ if (this.expiryTimer)
394
+ clearTimeout(this.expiryTimer);
395
+ this.expiryTimer = null;
396
+ }
397
+ clearTimers() {
398
+ for (const timer of [
399
+ this.controlTimer,
400
+ this.expiryTimer,
401
+ this.syncTimer,
402
+ this.periodicSync,
403
+ ]) {
404
+ if (timer)
405
+ clearTimeout(timer);
406
+ }
407
+ this.controlTimer = null;
408
+ this.expiryTimer = null;
409
+ this.syncTimer = null;
410
+ this.periodicSync = null;
411
+ }
412
+ now() {
413
+ return this.opts.now ? this.opts.now() : Date.now();
414
+ }
415
+ isCurrent(generation) {
416
+ return !this.stopped && generation === this.generation;
417
+ }
418
+ enqueue(work) {
419
+ const next = this.queue.then(work, work);
420
+ this.queue = next.catch(() => undefined);
421
+ return next;
422
+ }
107
423
  }
108
424
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/agent-sync/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAEL,UAAU,GAGX,MAAM,wCAAwC,CAAC;AAYhD,MAAM,OAAO,eAAe;IAMG;IALpB,IAAI,GAAG,YAAY,CAAC;IACrB,GAAG,CAAiB;IACpB,KAAK,GAA0B,IAAI,CAAC;IACpC,OAAO,GAAG,KAAK,CAAC;IAExB,YAA6B,IAAsB;QAAtB,SAAI,GAAJ,IAAI,CAAkB;IAAG,CAAC;IAEvD,IAAI,CAAC,GAAkB;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,IAAI,CAAC,GAAG;YAAE,OAAO;QACtB,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QAErB,MAAM,QAAQ,GACZ,IAAI,CAAC,IAAI,CAAC,UAAU;YACpB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,4BAA4B,IAAI,GAAG,CAAC,CAAC;QAC1D,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;YACjB,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;gBAC5B,IAAI,IAAI,CAAC,OAAO;oBAAE,OAAO;gBACzB,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;YACtB,CAAC,EAAE,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AI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;IAC3B,CAAC;IAEO,GAAG;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;IACtD,CAAC;IAEO,SAAS,CAAC,UAAkB;QAClC,OAAO,CAAC,IAAI,CAAC,OAAO,IAAI,UAAU,KAAK,IAAI,CAAC,UAAU,CAAC;IACzD,CAAC;IAEO,OAAO,CAAC,IAAyB;QACvC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -23,7 +23,7 @@ export class HttpDebugPlugin {
23
23
  async start() {
24
24
  if (!this.ctx)
25
25
  return;
26
- const { config, log, host } = this.ctx;
26
+ const { config, log, host, sessionManager } = this.ctx;
27
27
  if (!config.httpEnabled) {
28
28
  log.debug("http-debug: httpEnabled=false, skipping");
29
29
  return;
@@ -41,6 +41,7 @@ export class HttpDebugPlugin {
41
41
  this.server = new HttpServer({
42
42
  devices: this.opts.devices,
43
43
  host,
44
+ clearSession: () => sessionManager.clearSession(""),
44
45
  bindHost,
45
46
  port,
46
47
  corsOrigins: config.httpCorsOrigins,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/http-debug/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAWzC,MAAM,OAAO,eAAe;IAKG;IAJpB,IAAI,GA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  devices: DeviceManager;
20
20
  host: AgentHost;
21
+ /** Clears the runtime's canonical operator session when supplied. */
22
+ clearSession?: () => {
23
+ cleared: boolean;
24
+ };
21
25
  bindHost?: string;
22
26
  port?: number;
23
27
  log?: boolean;
@@ -140,6 +140,7 @@ export class HttpServer {
140
140
  this.opts = {
141
141
  devices: opts.devices,
142
142
  host: opts.host,
143
+ clearSession: opts.clearSession,
143
144
  bindHost: opts.bindHost ?? "127.0.0.1",
144
145
  port: opts.port ?? 9090,
145
146
  log: opts.log ?? false,
@@ -235,6 +236,16 @@ export class HttpServer {
235
236
  await devices.active().apply(a);
236
237
  return { ok: true };
237
238
  });
239
+ // Local fleet control uses this route in classic mode. It intentionally
240
+ // clears only the device-agent's local operator context; it does not
241
+ // cancel a task or alter cloud-side chat rendering.
242
+ app.post("/session/clear", async (_req, reply) => {
243
+ const clearSession = this.opts.clearSession;
244
+ if (!clearSession) {
245
+ return reply.status(501).send({ error: "session control is unavailable" });
246
+ }
247
+ return clearSession();
248
+ });
238
249
  app.post("/tasks", async (req, reply) => {
239
250
  const body = (req.body ?? {});
240
251
  const instruction = body.instruction ?? "";