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
+73
@@ -0,0 +1,73 @@
|
||||
// Package harness implements the agent's core loop as a state machine:
|
||||
// stream a completion, recover from max-output-tokens / prompt-too-long,
|
||||
// surface text/thinking/tool events, execute tool calls through a streaming
|
||||
// executor (FIFO + exclusive scheduling), gate the Stop transition with hooks
|
||||
// and a token budget, and repeat. It is exposed as a range-over-func iterator
|
||||
// of Events and threads context cancellation throughout.
|
||||
package harness
|
||||
|
||||
import "github.com/Autumn-27/norma/llm"
|
||||
|
||||
// EventKind classifies a loop Event.
|
||||
type EventKind string
|
||||
|
||||
const (
|
||||
KindText EventKind = "text" // assistant text delta
|
||||
KindThinking EventKind = "thinking" // reasoning delta
|
||||
KindToolUse EventKind = "tool_use" // a tool is about to run
|
||||
KindToolResult EventKind = "tool_result" // a tool finished
|
||||
KindProgress EventKind = "progress" // mid-tool progress
|
||||
KindUsage EventKind = "usage" // cumulative token usage so far (per model turn)
|
||||
KindResult EventKind = "result" // terminal event (loop finished)
|
||||
)
|
||||
|
||||
// Event is one item in the loop's output stream.
|
||||
type Event struct {
|
||||
Kind EventKind
|
||||
Text string // KindText / KindThinking / KindProgress
|
||||
ToolUse *llm.ContentBlock // KindToolUse
|
||||
ToolResult *llm.ContentBlock // KindToolResult
|
||||
Terminal *Terminal // KindResult
|
||||
Usage *llm.Usage // KindUsage: cumulative usage after the latest model turn
|
||||
}
|
||||
|
||||
// TerminalReason explains why the loop stopped.
|
||||
type TerminalReason string
|
||||
|
||||
const (
|
||||
ReasonCompleted TerminalReason = "completed" // model ended its turn
|
||||
ReasonBlockingLimit TerminalReason = "blocking_limit" // hard context limit hit pre-request
|
||||
ReasonImageError TerminalReason = "image_error" // unsupported media (multimodal)
|
||||
ReasonModelError TerminalReason = "model_error" // provider/API failure
|
||||
ReasonAbortedStreaming TerminalReason = "aborted_streaming" // canceled during streaming
|
||||
ReasonAbortedTools TerminalReason = "aborted_tools" // canceled during tool execution
|
||||
ReasonPromptTooLong TerminalReason = "prompt_too_long" // overflow recovery exhausted
|
||||
ReasonStopHookPrevented TerminalReason = "stop_hook_prevented" // a Stop hook blocked continuation
|
||||
ReasonHookStopped TerminalReason = "hook_stopped" // a tool/hook stopped continuation
|
||||
ReasonMaxTurns TerminalReason = "max_turns" // hit MaxTurns
|
||||
ReasonTimeout TerminalReason = "timeout" // hit a wall-clock run budget (host-imposed)
|
||||
)
|
||||
|
||||
// ContinueReason names why the loop took another turn. These drive control
|
||||
// flow; they are recorded on the loop for telemetry.
|
||||
type ContinueReason string
|
||||
|
||||
const (
|
||||
ContinueNextTurn ContinueReason = "next_turn"
|
||||
ContinueReactiveCompactRetry ContinueReason = "reactive_compact_retry"
|
||||
ContinueMaxOutputTokensEscalate ContinueReason = "max_output_tokens_escalate"
|
||||
ContinueMaxOutputTokensRecovery ContinueReason = "max_output_tokens_recovery"
|
||||
ContinueStopHookBlocking ContinueReason = "stop_hook_blocking"
|
||||
ContinueTokenBudget ContinueReason = "token_budget_continuation"
|
||||
ContinueTaskNotification ContinueReason = "task_notification"
|
||||
)
|
||||
|
||||
// Terminal is the final state of a Query, delivered as the KindResult event.
|
||||
type Terminal struct {
|
||||
Reason TerminalReason
|
||||
Err error
|
||||
Usage llm.Usage
|
||||
Turns int
|
||||
Messages []llm.Message // full conversation snapshot (non-destructive: retains history)
|
||||
Text string // the assistant's final text, for convenience
|
||||
}
|
||||
Reference in new issue
Block a user