Skip to content

Commit 7bf21bc

Browse files
authored
refactor(mac): remove orphaned IPC request codec (#126267)
1 parent e71fc90 commit 7bf21bc

3 files changed

Lines changed: 0 additions & 396 deletions

File tree

‎apps/macos/Sources/OpenClawIPC/IPC.swift‎

Lines changed: 0 additions & 294 deletions
Original file line numberDiff line numberDiff line change
@@ -98,43 +98,6 @@ public struct CanvasShowResult: Codable, Sendable {
9898
}
9999
}
100100

101-
// MARK: - Canvas A2UI
102-
103-
public enum CanvasA2UICommand: String, Codable, Sendable {
104-
case pushJSONL
105-
case reset
106-
}
107-
108-
public enum Request: Sendable {
109-
case notify(
110-
title: String,
111-
body: String,
112-
sound: String?,
113-
priority: NotificationPriority?,
114-
delivery: NotificationDelivery?)
115-
case ensurePermissions([Capability], interactive: Bool)
116-
case runShell(
117-
command: [String],
118-
cwd: String?,
119-
env: [String: String]?,
120-
timeoutSec: Double?,
121-
needsScreenRecording: Bool)
122-
case status
123-
case agent(message: String, thinking: String?, session: String?, deliver: Bool, to: String?)
124-
case rpcStatus
125-
case canvasPresent(session: String, path: String?, placement: CanvasPlacement?)
126-
case canvasHide(session: String)
127-
case canvasEval(session: String, javaScript: String)
128-
case canvasSnapshot(session: String, outPath: String?)
129-
case canvasA2UI(session: String, command: CanvasA2UICommand, jsonl: String?)
130-
case nodeList
131-
case nodeDescribe(nodeId: String)
132-
case nodeInvoke(nodeId: String, command: String, paramsJSON: String?)
133-
case cameraSnap(facing: CameraFacing?, maxWidth: Int?, quality: Double?, outPath: String?)
134-
case cameraClip(facing: CameraFacing?, durationMs: Int?, includeAudio: Bool, outPath: String?)
135-
case screenRecord(screenIndex: Int?, durationMs: Int?, fps: Double?, includeAudio: Bool, outPath: String?)
136-
}
137-
138101
// MARK: - Responses
139102

140103
public struct Response: Codable, Sendable {
@@ -149,260 +112,3 @@ public struct Response: Codable, Sendable {
149112
self.payload = payload
150113
}
151114
}
152-
153-
// MARK: - Codable conformance for Request
154-
155-
extension Request: Codable {
156-
private enum CodingKeys: String, CodingKey {
157-
case type
158-
case title, body, sound, priority, delivery
159-
case caps, interactive
160-
case command, cwd, env, timeoutSec, needsScreenRecording
161-
case message, thinking, session, deliver, to
162-
case rpcStatus
163-
case path
164-
case javaScript
165-
case outPath
166-
case screenIndex
167-
case fps
168-
case canvasA2UICommand
169-
case jsonl
170-
case facing
171-
case maxWidth
172-
case quality
173-
case durationMs
174-
case includeAudio
175-
case placement
176-
case nodeId
177-
case nodeCommand
178-
case paramsJSON
179-
}
180-
181-
private enum Kind: String, Codable {
182-
case notify
183-
case ensurePermissions
184-
case runShell
185-
case status
186-
case agent
187-
case rpcStatus
188-
case canvasPresent
189-
case canvasHide
190-
case canvasEval
191-
case canvasSnapshot
192-
case canvasA2UI
193-
case nodeList
194-
case nodeDescribe
195-
case nodeInvoke
196-
case cameraSnap
197-
case cameraClip
198-
case screenRecord
199-
}
200-
201-
public func encode(to encoder: Encoder) throws {
202-
var container = encoder.container(keyedBy: CodingKeys.self)
203-
switch self {
204-
case let .notify(title, body, sound, priority, delivery):
205-
try container.encode(Kind.notify, forKey: .type)
206-
try container.encode(title, forKey: .title)
207-
try container.encode(body, forKey: .body)
208-
try container.encodeIfPresent(sound, forKey: .sound)
209-
try container.encodeIfPresent(priority, forKey: .priority)
210-
try container.encodeIfPresent(delivery, forKey: .delivery)
211-
212-
case let .ensurePermissions(caps, interactive):
213-
try container.encode(Kind.ensurePermissions, forKey: .type)
214-
try container.encode(caps, forKey: .caps)
215-
try container.encode(interactive, forKey: .interactive)
216-
217-
case let .runShell(command, cwd, env, timeoutSec, needsSR):
218-
try container.encode(Kind.runShell, forKey: .type)
219-
try container.encode(command, forKey: .command)
220-
try container.encodeIfPresent(cwd, forKey: .cwd)
221-
try container.encodeIfPresent(env, forKey: .env)
222-
try container.encodeIfPresent(timeoutSec, forKey: .timeoutSec)
223-
try container.encode(needsSR, forKey: .needsScreenRecording)
224-
225-
case .status:
226-
try container.encode(Kind.status, forKey: .type)
227-
228-
case let .agent(message, thinking, session, deliver, to):
229-
try container.encode(Kind.agent, forKey: .type)
230-
try container.encode(message, forKey: .message)
231-
try container.encodeIfPresent(thinking, forKey: .thinking)
232-
try container.encodeIfPresent(session, forKey: .session)
233-
try container.encode(deliver, forKey: .deliver)
234-
try container.encodeIfPresent(to, forKey: .to)
235-
236-
case .rpcStatus:
237-
try container.encode(Kind.rpcStatus, forKey: .type)
238-
239-
case let .canvasPresent(session, path, placement):
240-
try container.encode(Kind.canvasPresent, forKey: .type)
241-
try container.encode(session, forKey: .session)
242-
try container.encodeIfPresent(path, forKey: .path)
243-
try container.encodeIfPresent(placement, forKey: .placement)
244-
245-
case let .canvasHide(session):
246-
try container.encode(Kind.canvasHide, forKey: .type)
247-
try container.encode(session, forKey: .session)
248-
249-
case let .canvasEval(session, javaScript):
250-
try container.encode(Kind.canvasEval, forKey: .type)
251-
try container.encode(session, forKey: .session)
252-
try container.encode(javaScript, forKey: .javaScript)
253-
254-
case let .canvasSnapshot(session, outPath):
255-
try container.encode(Kind.canvasSnapshot, forKey: .type)
256-
try container.encode(session, forKey: .session)
257-
try container.encodeIfPresent(outPath, forKey: .outPath)
258-
259-
case let .canvasA2UI(session, command, jsonl):
260-
try container.encode(Kind.canvasA2UI, forKey: .type)
261-
try container.encode(session, forKey: .session)
262-
try container.encode(command, forKey: .canvasA2UICommand)
263-
try container.encodeIfPresent(jsonl, forKey: .jsonl)
264-
265-
case .nodeList:
266-
try container.encode(Kind.nodeList, forKey: .type)
267-
268-
case let .nodeDescribe(nodeId):
269-
try container.encode(Kind.nodeDescribe, forKey: .type)
270-
try container.encode(nodeId, forKey: .nodeId)
271-
272-
case let .nodeInvoke(nodeId, command, paramsJSON):
273-
try container.encode(Kind.nodeInvoke, forKey: .type)
274-
try container.encode(nodeId, forKey: .nodeId)
275-
try container.encode(command, forKey: .nodeCommand)
276-
try container.encodeIfPresent(paramsJSON, forKey: .paramsJSON)
277-
278-
case let .cameraSnap(facing, maxWidth, quality, outPath):
279-
try container.encode(Kind.cameraSnap, forKey: .type)
280-
try container.encodeIfPresent(facing, forKey: .facing)
281-
try container.encodeIfPresent(maxWidth, forKey: .maxWidth)
282-
try container.encodeIfPresent(quality, forKey: .quality)
283-
try container.encodeIfPresent(outPath, forKey: .outPath)
284-
285-
case let .cameraClip(facing, durationMs, includeAudio, outPath):
286-
try container.encode(Kind.cameraClip, forKey: .type)
287-
try container.encodeIfPresent(facing, forKey: .facing)
288-
try container.encodeIfPresent(durationMs, forKey: .durationMs)
289-
try container.encode(includeAudio, forKey: .includeAudio)
290-
try container.encodeIfPresent(outPath, forKey: .outPath)
291-
292-
case let .screenRecord(screenIndex, durationMs, fps, includeAudio, outPath):
293-
try container.encode(Kind.screenRecord, forKey: .type)
294-
try container.encodeIfPresent(screenIndex, forKey: .screenIndex)
295-
try container.encodeIfPresent(durationMs, forKey: .durationMs)
296-
try container.encodeIfPresent(fps, forKey: .fps)
297-
try container.encode(includeAudio, forKey: .includeAudio)
298-
try container.encodeIfPresent(outPath, forKey: .outPath)
299-
}
300-
}
301-
302-
public init(from decoder: Decoder) throws {
303-
let container = try decoder.container(keyedBy: CodingKeys.self)
304-
let kind = try container.decode(Kind.self, forKey: .type)
305-
switch kind {
306-
case .notify:
307-
let title = try container.decode(String.self, forKey: .title)
308-
let body = try container.decode(String.self, forKey: .body)
309-
let sound = try container.decodeIfPresent(String.self, forKey: .sound)
310-
let priority = try container.decodeIfPresent(NotificationPriority.self, forKey: .priority)
311-
let delivery = try container.decodeIfPresent(NotificationDelivery.self, forKey: .delivery)
312-
self = .notify(title: title, body: body, sound: sound, priority: priority, delivery: delivery)
313-
314-
case .ensurePermissions:
315-
let caps = try container.decode([Capability].self, forKey: .caps)
316-
let interactive = try container.decode(Bool.self, forKey: .interactive)
317-
self = .ensurePermissions(caps, interactive: interactive)
318-
319-
case .runShell:
320-
let command = try container.decode([String].self, forKey: .command)
321-
let cwd = try container.decodeIfPresent(String.self, forKey: .cwd)
322-
let env = try container.decodeIfPresent([String: String].self, forKey: .env)
323-
let timeout = try container.decodeIfPresent(Double.self, forKey: .timeoutSec)
324-
let needsSR = try container.decode(Bool.self, forKey: .needsScreenRecording)
325-
self = .runShell(command: command, cwd: cwd, env: env, timeoutSec: timeout, needsScreenRecording: needsSR)
326-
327-
case .status:
328-
self = .status
329-
330-
case .agent:
331-
let message = try container.decode(String.self, forKey: .message)
332-
let thinking = try container.decodeIfPresent(String.self, forKey: .thinking)
333-
let session = try container.decodeIfPresent(String.self, forKey: .session)
334-
let deliver = try container.decode(Bool.self, forKey: .deliver)
335-
let to = try container.decodeIfPresent(String.self, forKey: .to)
336-
self = .agent(message: message, thinking: thinking, session: session, deliver: deliver, to: to)
337-
338-
case .rpcStatus:
339-
self = .rpcStatus
340-
341-
case .canvasPresent:
342-
let session = try container.decode(String.self, forKey: .session)
343-
let path = try container.decodeIfPresent(String.self, forKey: .path)
344-
let placement = try container.decodeIfPresent(CanvasPlacement.self, forKey: .placement)
345-
self = .canvasPresent(session: session, path: path, placement: placement)
346-
347-
case .canvasHide:
348-
let session = try container.decode(String.self, forKey: .session)
349-
self = .canvasHide(session: session)
350-
351-
case .canvasEval:
352-
let session = try container.decode(String.self, forKey: .session)
353-
let javaScript = try container.decode(String.self, forKey: .javaScript)
354-
self = .canvasEval(session: session, javaScript: javaScript)
355-
356-
case .canvasSnapshot:
357-
let session = try container.decode(String.self, forKey: .session)
358-
let outPath = try container.decodeIfPresent(String.self, forKey: .outPath)
359-
self = .canvasSnapshot(session: session, outPath: outPath)
360-
361-
case .canvasA2UI:
362-
let session = try container.decode(String.self, forKey: .session)
363-
let command = try container.decode(CanvasA2UICommand.self, forKey: .canvasA2UICommand)
364-
let jsonl = try container.decodeIfPresent(String.self, forKey: .jsonl)
365-
self = .canvasA2UI(session: session, command: command, jsonl: jsonl)
366-
367-
case .nodeList:
368-
self = .nodeList
369-
370-
case .nodeDescribe:
371-
let nodeId = try container.decode(String.self, forKey: .nodeId)
372-
self = .nodeDescribe(nodeId: nodeId)
373-
374-
case .nodeInvoke:
375-
let nodeId = try container.decode(String.self, forKey: .nodeId)
376-
let command = try container.decode(String.self, forKey: .nodeCommand)
377-
let paramsJSON = try container.decodeIfPresent(String.self, forKey: .paramsJSON)
378-
self = .nodeInvoke(nodeId: nodeId, command: command, paramsJSON: paramsJSON)
379-
380-
case .cameraSnap:
381-
let facing = try container.decodeIfPresent(CameraFacing.self, forKey: .facing)
382-
let maxWidth = try container.decodeIfPresent(Int.self, forKey: .maxWidth)
383-
let quality = try container.decodeIfPresent(Double.self, forKey: .quality)
384-
let outPath = try container.decodeIfPresent(String.self, forKey: .outPath)
385-
self = .cameraSnap(facing: facing, maxWidth: maxWidth, quality: quality, outPath: outPath)
386-
387-
case .cameraClip:
388-
let facing = try container.decodeIfPresent(CameraFacing.self, forKey: .facing)
389-
let durationMs = try container.decodeIfPresent(Int.self, forKey: .durationMs)
390-
let includeAudio = (try? container.decode(Bool.self, forKey: .includeAudio)) ?? true
391-
let outPath = try container.decodeIfPresent(String.self, forKey: .outPath)
392-
self = .cameraClip(facing: facing, durationMs: durationMs, includeAudio: includeAudio, outPath: outPath)
393-
394-
case .screenRecord:
395-
let screenIndex = try container.decodeIfPresent(Int.self, forKey: .screenIndex)
396-
let durationMs = try container.decodeIfPresent(Int.self, forKey: .durationMs)
397-
let fps = try container.decodeIfPresent(Double.self, forKey: .fps)
398-
let includeAudio = (try? container.decode(Bool.self, forKey: .includeAudio)) ?? true
399-
let outPath = try container.decodeIfPresent(String.self, forKey: .outPath)
400-
self = .screenRecord(
401-
screenIndex: screenIndex,
402-
durationMs: durationMs,
403-
fps: fps,
404-
includeAudio: includeAudio,
405-
outPath: outPath)
406-
}
407-
}
408-
}

‎apps/macos/Tests/OpenClawIPCTests/CameraIPCTests.swift‎

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)