Files
openclaw/apps/macos/Sources/OpenClaw/ExecHostExecutor+Response.swift
Josh Avant 1c37c8cdc7 fix(exec): scope reusable approvals to their working directory (#129636)
* fix(exec): bind durable approvals to working directory

* chore(apps): refresh native string inventory

* test(node-host): preserve prepared working directory

* fix(exec): use shared path safety facade

* fix(exec): revalidate approved directory identity
2026-08-25 18:24:14 -07:00

55 lines
1.6 KiB
Swift

import Foundation
extension ExecHostExecutor {
static func commandResponse(
execution: Task<ShellExecutor.ShellResult, Never>) async -> ExecHostResponse
{
let result = await execution.value
if let preflightError = result.preflightError {
return self.errorResponse(
code: "UNAVAILABLE",
message: preflightError,
reason: "approval-required")
}
let payload = ExecHostRunResult(
exitCode: result.exitCode,
timedOut: result.timedOut,
success: result.success,
stdout: ExecHostOutputLimiter.truncate(result.stdout),
stderr: ExecHostOutputLimiter.truncate(result.stderr),
error: result.errorMessage)
return self.successResponse(payload)
}
static func errorResponse(_ error: ExecHostError) -> ExecHostResponse {
ExecHostResponse(
type: "response",
id: UUID().uuidString,
ok: false,
payload: nil,
error: error)
}
static func errorResponse(
code: String,
message: String,
reason: String?) -> ExecHostResponse
{
ExecHostResponse(
type: "exec-res",
id: UUID().uuidString,
ok: false,
payload: nil,
error: ExecHostError(code: code, message: message, reason: reason))
}
static func successResponse(_ payload: ExecHostRunResult) -> ExecHostResponse {
ExecHostResponse(
type: "exec-res",
id: UUID().uuidString,
ok: true,
payload: payload,
error: nil)
}
}