The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Merge remote-tracking branch 'remotes/origin/main' into feat/device-partial-updates
9ef44dfee1c8240ae69e82868025
diff --cc cli/src/backendSocket.tsindex da3f119f1,e9b0bc57f..d07b31afc--- a/cli/src/backendSocket.ts+++ b/cli/src/backendSocket.ts@@@ -1292,9 -1370,8 +1380,9 @@@ export class BackendSocket* is never returned plaintext: even legacy backend nodeRequest (`connId === ''`) gets only an error. */private emitReply(connId: string, type: string, requestId: unknown, payload: Record<string, unknown>): void {const resultType = `${type}_result`+ if (connId && deviceDump.enabled && this.e2ee.sessionRole(connId) === 'device') deviceDump.record('out', 'legacy', connId, { type: resultType, payload: { requestId, ...payload } })// Before the E2EE wrap: an RPC reply is only readable here.- if (env.LOG_FRAMES && !type.startsWith('grid_fleet_') && type !== 'agent_read_file' && type !== 'project_preview' && type !== 'git_project_info' && !SHARE_REQUEST_TYPES.has(type)) logFrame('→', connId ? `conn:${sid(connId)}` : 'backend', { type: resultType, payload: { requestId, ...payload } })+ if (env.LOG_FRAMES && !type.startsWith('grid_fleet_') && type !== 'agent_read_file' && type !== 'project_preview' && type !== 'git_project_info' && type !== 'git_pull_request' && !SHARE_REQUEST_TYPES.has(type)) logFrame('→', connId ? `conn:${sid(connId)}` : 'backend', { type: resultType, payload: { requestId, ...payload } })if (this.localClients.has(connId)) {this.sendTo(connId, { type: resultType, payload: { requestId, ...payload } })returndiff --cc cli/src/lib/autonomous-device/service.tsindex 1d60d8118,aee328e36..22fa43e51--- a/cli/src/lib/autonomous-device/service.ts+++ b/cli/src/lib/autonomous-device/service.ts@@@ -46,11 -51,13 +53,14 @@@ export interface AutonomousDeviceServic* looks at between the dial and its turn cards.*/fullText?: (agentId: string) => string | undefined- emit?: (frame: AutonomousDeviceFrame) => void+ /** `deviceId` set: this frame is for that paired device alone (an agent stream), never a broadcast. */+ emit?: (frame: AutonomousDeviceFrame, deviceId?: string) => void}- interface Entry { deviceId: string; digest: string; receipt: AutonomousDeviceReceipt }+ interface Entry { deviceId: string; digest: string; receipt: AutonomousDeviceReceipt+ promptHash?: string; reservedAt?: number; dispatchedAt?: number; sessionId?: string; evidenceManaged?: boolean; consumed?: boolean+ }+ interface ResultRecord { deviceId: string; evidenceId: string; at: number; agentId: string; payload: Record<string, unknown> }-const CAPABILITIES = ['focus.get', 'focus.ensure', 'focus.step', 'scroll', 'agents.list', 'turn.send', 'turn.stop', 'status', 'recap', 'question.answer', 'receipt.get'] as const+const CAPABILITIES = ['focus.get', 'focus.ensure', 'focus.step', 'scroll', 'agents.list', 'turn.send', 'turn.stop', 'status', 'recap', 'question.answer', 'receipt.get', 'agent.subscribe', 'agent.unsubscribe'] as constexport const AUTONOMOUS_DEVICE_CAPABILITIES: string[] = [...CAPABILITIES]const MUTATIONS = new Set(['turn.send', 'turn.stop', 'question.answer'])const STEP_RESULTS_MAX = 512@@@ -183,38 -307,28 +310,59 @@@ export class AutonomousDeviceServiceconstructor(private readonly options: AutonomousDeviceServiceOptions) {this.serverInstanceId = options.serverInstanceId ?? randomUUID()this.now = options.now ?? Date.now+ this.streams = new AgentStreams({ machineId: options.machineId, serverInstanceId: this.serverInstanceId,+ send: (deviceId, frame) => this.options.emit?.(frame, deviceId) })+ const snapshot = options.resultJournal?.load()+ if (snapshot !== undefined) {+ if (!object(snapshot) || snapshot.version !== 1 || snapshot.machineId !== options.machineId+ || !Array.isArray(snapshot.entries) || !Array.isArray(snapshot.results)) throw new Error('Invalid Device result journal; refusing to lose delivery dedupe')+ for (const entry of snapshot.entries as Entry[]) {+ if (!entry.deviceId || !entry.digest || !entry.receipt?.deliveryId || !entry.receipt.idempotencyKey) throw new Error('Invalid Device receipt journal')+ if (!['completed', 'rejected'].includes(entry.receipt.state)) {+ entry.receipt.state = 'unknown'; entry.receipt.error = { code: 'DAEMON_RESTART', message: 'Reconcile original delivery; never resend automatically' }+ }+ this.entries.set(this.key(entry.deviceId, entry.receipt.idempotencyKey), entry)+ this.deliveries.set(entry.receipt.deliveryId, entry)+ }+ for (const record of snapshot.results as ResultRecord[]) {+ if (!record.deviceId || !record.evidenceId || !record.payload?.resultId) throw new Error('Invalid Device result journal')+ this.results.set(record.evidenceId, record)+ }+ this.prune()+ this.persist()+ // New transport instance/sequence; immutable payload retains its originating instance.+ for (const record of this.results.values()) this.retainEvent('turn.summary', record.agentId, record.payload)+ }}+ private readonly streams: AgentStreams+ /** Live events of one agent, for its subscribers only. Never recorded in the replay log. */+ stream(agentId: string, events: readonly LiveEvent[]): void { this.streams.ingest(agentId, events) }+ /** The device's last link closed: its subscriptions end with it, and a reconnect subscribes again. */+ deviceOffline(deviceId: string): void { this.streams.dropDevice(deviceId) }++ private subscription(deviceId: string, type: 'agent.subscribe' | 'agent.unsubscribe', req: Record<string, unknown>): Record<string, unknown> {+ const fields = type === 'agent.subscribe' ? ['type', 'requestId', 'machineId', 'agentId', 'ttlSec', 'include'] : ['type', 'requestId', 'subscriptionId']+ if (Object.keys(req).some(k => !fields.includes(k))) fail('INVALID_REQUEST', 'Unknown request field')+ if (type === 'agent.unsubscribe') {+ if (!UUID.test(String(req.subscriptionId))) fail('INVALID_REQUEST', 'subscriptionId must be a UUIDv4')+ return { unsubscribed: this.streams.unsubscribe(deviceId, String(req.subscriptionId)) }+ }+ if (typeof req.agentId !== 'string' || !req.agentId || typeof req.machineId !== 'string') fail('MISSING_TARGET', 'machineId and agentId are required')+ if (req.machineId !== this.options.machineId) fail('MACHINE_MISMATCH', 'Only the paired machine is available')+ const ttlSec = req.ttlSec ?? STREAM_TTL_DEFAULT_SEC+ if (!Number.isInteger(ttlSec) || (ttlSec as number) < 1 || (ttlSec as number) > STREAM_TTL_MAX_SEC) fail('INVALID_REQUEST', `ttlSec must be an integer from 1 to ${STREAM_TTL_MAX_SEC}`)+ const include = req.include ?? STREAM_KINDS+ if (!Array.isArray(include) || !include.length || new Set(include).size !== include.length+ || include.some(k => !(STREAM_KINDS as readonly unknown[]).includes(k))) fail('INVALID_REQUEST', `include must be distinct values of ${STREAM_KINDS.join(', ')}`)+ const agentId = req.agentId+ if (!this.options.agents().some(a => a.agentId === agentId)) fail('AGENT_NOT_FOUND', 'Agent is not available on the paired machine')+ try {+ return { machineId: this.options.machineId, agentId, include, ...this.streams.subscribe(deviceId, agentId, ttlSec as number, new Set(include as StreamKind[])) }+ } catch (e) {+ if (e instanceof StreamRequestError) fail(e.code, e.message)+ throw e+ }+ }private key(deviceId: string, key: string): string { return `${deviceId}:${key}` }/** The newest `recap` turn's headline for an agent, or undefined when no turn has been summarised. */private latestRecap(agentId: string): string | undefined {@@@ -271,7 -416,8 +450,9 @@@this.entries.delete(key)}for (const [key, step] of this.steps) if (step.deviceId === deviceId) this.steps.delete(key)+ this.streams.dropDevice(deviceId)+ for (const [key, result] of this.results) if (result.deviceId === deviceId) this.results.delete(key)+ this.persist()// A newly paired identity cannot replay the previous device's request receipts.this.events = []}@@@ -328,9 -507,8 +542,9 @@@let reserved: Entry | undefinedtry {if (!UUID.test(String(req.requestId))) fail('INVALID_REQUEST', 'requestId must be a UUIDv4')- if (!this.capabilities.includes(type)) fail('UNSUPPORTED_CAPABILITY', 'Operation is not supported')+ if (type === 'input.status.v1' || !this.capabilities.includes(type)) fail('UNSUPPORTED_CAPABILITY', 'Operation is not supported')if ((DEVICE_STORE_CAPABILITIES as readonly string[]).includes(type)) return response(await this.options.store!.request(deviceId, req))+ if (type === 'agent.subscribe' || type === 'agent.unsubscribe') return response(this.subscription(deviceId, type, req))const allowed = ['type', 'requestId', ...(['agents.list', 'focus.get', 'focus.ensure'].includes(type) ? [] : type === 'receipt.get' ? ['idempotencyKey'] : type === 'focus.step' ? ['direction', 'idempotencyKey', 'focusRevision'] : type === 'scroll' ? ['phase', 'dy', 'velocity'] : ['machineId', 'agentId']),...(MUTATIONS.has(type) ? ['idempotencyKey'] : []), ...(type === 'turn.send' ? ['text', 'focusRevision'] : type === 'question.answer' ? ['questionRequestId', 'answers', 'focusRevision'] : type === 'recap' ? ['n'] : [])]if (Object.keys(req).some(k => !allowed.includes(k))) fail('INVALID_REQUEST', 'Unknown request field')