Files
Termind/Frameworks/TermindRemoteInfrastructure/Agent/PlanningSSHExecRunTool.swift
T
Kaede Akino 7e78bc00c4 feat(agent): unify output truncation and scratch capture
Integrate AgentKit 2.0.1 with shared scratch storage, whole-line tool policies, generated capture paths, and external MCP projection bypass. Update ssh-exec instructions and document the complete tool policy inventory.

Keep compact expansion controls left aligned and display the AgentKit truncation marker above them on both platforms. Cover narrow and wide native layouts, both button states, and marker ordering.
2026-10-17 22:51:26 +08:00

40 lines
1.5 KiB
Swift

import AgentKit
import Foundation
import TermindDomain
/// Planning registration for the ordinary `ssh_exec_run` identity. Destructive
/// commands never reach approval or execution in this posture.
public nonisolated struct PlanningSSHExecRunTool: AgentToolDefinition {
public static let presenter = SSHExecRunTool.presenter
private let base: SSHExecRunTool
public init(
authentication: AgentSSHAuthenticationRegistry,
pool: AgentConnectionPool,
background: AgentBackgroundCommands, scope: UUID = UUID()
) {
base = SSHExecRunTool(authentication: authentication, pool: pool, background: background, scope: scope)
}
public var truncateStrategy: AgentTruncateStrategy { base.truncateStrategy }
public var descriptor: AgentToolDescriptor { base.descriptor }
public func preflight(_ invocation: AgentToolInvocation) async throws -> AgentToolPreflight {
let command = try Arguments(invocation).string("command")
guard CommandRiskClassifier.assess(command).risk == .destructive else {
return try await base.preflight(invocation)
}
return AgentToolPreflight(
invocation: invocation, approvalPolicy: .deny,
reasons: ["Planning cannot execute a destructive SSH command."]
)
}
public func execute(
_ invocation: AgentToolInvocation, context: AgentToolExecutionContext
) async throws -> AgentToolResult {
try await base.execute(invocation, context: context)
}
}