mirror of
https://github.com/esengine/DeepSeek-Reasonix.git
synced 2026-11-07 10:45:59 -10:00
internal/ was 141 packages side by side, so nothing but a reader's memory
said which were foundations and which assembled the rest. Each now sits in a
layer directory, and the directory is the declaration:
base L0 foundation with no domain in it
contract L1 types and interfaces the layers above agree on
model, tools, safety, ext, state, platform
L2 subsystems, peers of one another
runtime L3 the turn engine
session L4 the controller
assembly L5 the composition root
frontend L6 cli, serve, acp and the host adapters
Only paths change: package names, code and behaviour do not. Imports,
repolint and coverage baselines, sensitive paths, CI package lists and docs
follow the new paths; release notes keep the paths they were written with,
and sample paths inside tests and fixtures keep theirs.
repolint gains layer-order: a package may import its own layer and those
below it, read from where it lives. The 47 imports that point upward today
are recorded as that rule's opening debt (-allow-widen, a new rule's first
baseline) and can only go down. Most of it is config, which still reaches
into eight subsystems and is the next thing to take apart; the rest is
event, history and a few tools reaching into runtime for types that belong
in contract.
62 lines
1.9 KiB
Go
62 lines
1.9 KiB
Go
package agent
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
|
|
"reasonix/internal/contract/event"
|
|
"reasonix/internal/contract/provider"
|
|
)
|
|
|
|
// What the provider produced on its own side, rather than through the tool loop:
|
|
// an opaque item to replay next turn, or a tool it ran itself.
|
|
|
|
func appendProviderItem(items []json.RawMessage, item json.RawMessage) []json.RawMessage {
|
|
if len(item) == 0 {
|
|
return items
|
|
}
|
|
return append(items, append(json.RawMessage(nil), item...))
|
|
}
|
|
|
|
// absorbProviderRunCall reports a call that arrives already finished and keeps
|
|
// its result in the turn's text — the only copy the next turn has, because the
|
|
// provider keeps the plain content encrypted. Result and no dispatch: there is no
|
|
// pending moment to show, and a dispatch is the one event deferredStreamSink
|
|
// holds back, so it would land after its own result and never settle the card.
|
|
func (a *Agent) absorbProviderRunCall(text *strings.Builder, sink event.Sink, chunk provider.Chunk, attemptID string) {
|
|
// The listing joins the turn text, so it passes the same gate a tool result
|
|
// does. The card still shows every result — an event is not context.
|
|
bounded, _, _ := a.boundToolOutput(chunk.Text, providerToolName(chunk), providerToolCallID(chunk), providerToolArgs(chunk), false)
|
|
text.WriteString(bounded)
|
|
tc := chunk.ToolCall
|
|
if tc == nil {
|
|
return
|
|
}
|
|
sink.Emit(event.Event{Kind: event.ToolResult, Tool: event.Tool{
|
|
ID: tc.ID, Name: tc.Name, Args: tc.Arguments,
|
|
Output: chunk.Text, ReadOnly: true, AttemptID: attemptID,
|
|
Issuer: event.IssuedByProvider,
|
|
}})
|
|
}
|
|
|
|
func providerToolName(chunk provider.Chunk) string {
|
|
if chunk.ToolCall == nil {
|
|
return ""
|
|
}
|
|
return chunk.ToolCall.Name
|
|
}
|
|
|
|
func providerToolCallID(chunk provider.Chunk) string {
|
|
if chunk.ToolCall == nil {
|
|
return ""
|
|
}
|
|
return chunk.ToolCall.ID
|
|
}
|
|
|
|
func providerToolArgs(chunk provider.Chunk) string {
|
|
if chunk.ToolCall == nil {
|
|
return ""
|
|
}
|
|
return chunk.ToolCall.Arguments
|
|
}
|