build: 内置 norma 模块,构建不再依赖上游仓库
把 github.com/Autumn-27/norma v0.4.3(commit 320ae32)的源码复制到 third_party/norma,并用 go.mod 的 replace 指向本地副本。上游删除仓库或 改写 tag 都不再影响本仓库构建。 - 已验证 GOPROXY=off 下可完整编译并打出发行包 - go.sum 中该模块的两条校验记录随之删除(本地 replace 不需要哈希) - 升级方法与授权注意事项见 third_party/README.md
This commit is contained in:
1 parent
a819fa3230
commit
f782b612ec
213 files changed
+37401
-2
No files matched your search
Vendored
+52
@@ -0,0 +1,52 @@
|
||||
package tool
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
// NewSleep returns a tool that waits N seconds, interruptible via context. It pairs
|
||||
// with background task execution: after spawning long-running work (e.g. a Bash
|
||||
// command with run_in_background), an agent can sleep, then read partial output with
|
||||
// TaskOutput. Part of DefaultTools — every agent gets it.
|
||||
//
|
||||
// The wait is cancelled the moment ctx is done (pause/stop/timeout), returning
|
||||
// promptly rather than blocking out the deadline.
|
||||
func NewSleep() CoreTool {
|
||||
return Build(Spec{
|
||||
Name: "sleep",
|
||||
Description: "Waits for N seconds, then returns. Use to let a backgrounded command make progress before reading its partial output with TaskOutput. Interrupted immediately if the run is paused or stopped.",
|
||||
Schema: map[string]any{
|
||||
"type": "object",
|
||||
"properties": map[string]any{
|
||||
"seconds": map[string]any{"type": "integer", "description": "Seconds to wait, 1-3600."},
|
||||
},
|
||||
"required": []string{"seconds"},
|
||||
},
|
||||
ReadOnly: always,
|
||||
Concurrent: always,
|
||||
Permissions: allowReadOnly,
|
||||
Run: runSleep,
|
||||
})
|
||||
}
|
||||
|
||||
func runSleep(ctx context.Context, in json.RawMessage, _ *ToolContext) (Result, error) {
|
||||
var a struct {
|
||||
Seconds int `json:"seconds"`
|
||||
}
|
||||
_ = json.Unmarshal(in, &a)
|
||||
if a.Seconds < 1 {
|
||||
a.Seconds = 1
|
||||
}
|
||||
if a.Seconds > 3600 {
|
||||
a.Seconds = 3600
|
||||
}
|
||||
select {
|
||||
case <-time.After(time.Duration(a.Seconds) * time.Second):
|
||||
return Text(fmt.Sprintf("slept %ds", a.Seconds)), nil
|
||||
case <-ctx.Done():
|
||||
return Text("sleep interrupted"), nil
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user