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
+67
@@ -0,0 +1,67 @@
|
||||
package noa
|
||||
|
||||
// NodeIO is what flows between pipeline nodes: the working message view and the
|
||||
// state being threaded through it.
|
||||
type NodeIO struct {
|
||||
Messages []CoreMessage
|
||||
State CompressionState
|
||||
// Nudge is set by the nudge-inject node, nil when nothing is injected.
|
||||
Nudge *NudgeDecision
|
||||
// TruncatedCount is set by emergency-truncate: how many tool results were
|
||||
// mechanically shortened this turn. The nudge renderer uses it to tell the
|
||||
// model not to re-run those tools.
|
||||
TruncatedCount int
|
||||
}
|
||||
|
||||
// PipelineContext is the read-only environment every node sees.
|
||||
type PipelineContext struct {
|
||||
Config Config
|
||||
// TokenCount is the measured size of the context this turn.
|
||||
TokenCount int
|
||||
// CountTokens is the token estimator; nil means DefaultCountTokens.
|
||||
CountTokens TokenCountFn
|
||||
}
|
||||
|
||||
// count resolves the token estimator, defaulting when unset.
|
||||
func (c PipelineContext) count(s string) int {
|
||||
if c.CountTokens == nil {
|
||||
return DefaultCountTokens(s)
|
||||
}
|
||||
return c.CountTokens(s)
|
||||
}
|
||||
|
||||
// PipelineNode is one stage of the per-turn view projection.
|
||||
type PipelineNode interface {
|
||||
Name() string
|
||||
// Enabled reports whether the node should run at all this turn. A disabled
|
||||
// node is skipped entirely, not run as a no-op.
|
||||
Enabled(io NodeIO, ctx PipelineContext) bool
|
||||
Run(io NodeIO, ctx PipelineContext) NodeIO
|
||||
}
|
||||
|
||||
// nodeFunc adapts a plain function into a PipelineNode.
|
||||
type nodeFunc struct {
|
||||
name string
|
||||
enabled func(NodeIO, PipelineContext) bool
|
||||
run func(NodeIO, PipelineContext) NodeIO
|
||||
}
|
||||
|
||||
func (n nodeFunc) Name() string { return n.name }
|
||||
func (n nodeFunc) Enabled(io NodeIO, ctx PipelineContext) bool {
|
||||
return n.enabled == nil || n.enabled(io, ctx)
|
||||
}
|
||||
func (n nodeFunc) Run(io NodeIO, ctx PipelineContext) NodeIO { return n.run(io, ctx) }
|
||||
|
||||
// RunPipeline threads io through the nodes in order. The order is not
|
||||
// negotiable: each node assumes the invariants the previous ones established
|
||||
// (refs exist before boundaries are resolved, blocks are synced before prune
|
||||
// hides their coverage, and so on).
|
||||
func RunPipeline(nodes []PipelineNode, io NodeIO, ctx PipelineContext) NodeIO {
|
||||
for _, n := range nodes {
|
||||
if !n.Enabled(io, ctx) {
|
||||
continue
|
||||
}
|
||||
io = n.Run(io, ctx)
|
||||
}
|
||||
return io
|
||||
}
|
||||
Reference in new issue
Block a user