client: Windows 客户端(WinUI3 壳 + agent-core;调试用 Electron 壳存档);localserver token 改为常数时间比较
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
// fake 假执行器:D8 闭环验收用,模拟平台执行(延迟后返回成功)。
|
||||
package fake
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"everypublish/agentcore/internal/exec"
|
||||
"everypublish/shared/proto"
|
||||
)
|
||||
|
||||
// Executor 假执行器(可作兜底:任何平台都返回成功)
|
||||
type Executor struct {
|
||||
SimMS int
|
||||
}
|
||||
|
||||
// Platform 空串表示通用(注册为兜底)
|
||||
func (e Executor) Platform() string { return "" }
|
||||
|
||||
// Execute 模拟执行:延迟 SimMS 后返回成功
|
||||
func (e Executor) Execute(ctx context.Context, task exec.Task) exec.Result {
|
||||
select {
|
||||
case <-time.After(time.Duration(e.SimMS) * time.Millisecond):
|
||||
case <-ctx.Done():
|
||||
return exec.Result{TaskID: task.TaskID, Status: "failed", Error: "cancelled"}
|
||||
}
|
||||
return exec.Result{
|
||||
TaskID: task.TaskID,
|
||||
Status: "success",
|
||||
PublishedURL: "https://example.com/fake/" + task.TaskID,
|
||||
Receipts: []string{},
|
||||
}
|
||||
}
|
||||
|
||||
// SolveChallenge 模拟扫码:延迟后返回已解决
|
||||
func (e Executor) SolveChallenge(ctx context.Context, ch proto.Challenge, onQR func(qrToken, qrURL string)) (bool, string) {
|
||||
if onQR != nil {
|
||||
onQR("fake-qr-token", "https://example.com/fake-qr")
|
||||
}
|
||||
select {
|
||||
case <-time.After(time.Duration(e.SimMS) * time.Millisecond):
|
||||
case <-ctx.Done():
|
||||
return false, ""
|
||||
}
|
||||
return true, "fake-qr-token"
|
||||
}
|
||||
Reference in New Issue
Block a user