feat: agent keeps SSH file sessions and runs file operations on the host by commands

This commit is contained in:
redtea committed 2026-10-15 21:26:11 +03:00
1 parent f5d6bd30e8
commit 2859e69abe
4 files changed
+607

No files matched your search

+18
View File
@@ -26,6 +26,12 @@ func (a *Agent) runTask(ctx context.Context, taskID string) {
res = a.doFSPut(ctx, env)
case proto.TaskFSSend:
res = a.doFSSend(ctx, env)
case proto.TaskSSHFSSend:
res = a.doSSHFSSend(ctx, env)
case proto.TaskSSHFSPut:
res = a.doSSHFSPut(ctx, env)
case proto.TaskSSHFSOpen, proto.TaskSSHFSClose, proto.TaskSSHFSOp:
res = resultOf(a.sshfsTask(ctx, env))
case proto.TaskFSShipOut:
res = a.doShipOut(ctx, env)
case proto.TaskFSShipIn:
@@ -107,3 +113,15 @@ func itoa64(n int64) string {
}
return string(b[i:])
}
// resultOf makes a task's result of what it returned.
func resultOf(data any, err error) proto.TaskResult {
if err != nil {
return proto.TaskResult{Error: err.Error()}
}
raw, err := json.Marshal(data)
if err != nil {
return proto.TaskResult{Error: err.Error()}
}
return proto.TaskResult{OK: true, Data: raw}
}