session: remove Submit and agent pass-through methods
Session no longer has Submit(), IsRunning(), State(), Reply(), BackendName(), ModelName(), AgentName(), CtxSz(), Cost(), Usage(), Context(), SystemPrompt(), GenerationParams(), SetGenerationParams(), CompactionModel(), SetCompactionModel(), ListModels(), Reactions(), React(), ReactTo(), PopQueue(), ToolCallCount(). Callers access the Agent directly via Session.Agent(). Session retains only genuinely session-level operations: Agent(), Bus(), Close(), SetEnv(), Interrupt(), Queue(), InjectSystemEvent(), CWD(), SetCWD(), SetSessionID(), WaitChange(), persistence, and detach. Agent.Submit now dispatches slash commands internally (HandleCommand) before falling through to executeTurn.
This commit is contained in:
parent
0b3d04c17c
commit
24b9a0bdd3
|
|
@ -40,6 +40,10 @@ func (ag *Agent) Submit(ctx context.Context, input string) {
|
|||
}
|
||||
|
||||
if ag.IsRunning() {
|
||||
// While running, slash commands are still dispatched immediately.
|
||||
if ag.HandleCommand(ctx, input) {
|
||||
return
|
||||
}
|
||||
ag.fifo.Push(input)
|
||||
return
|
||||
}
|
||||
|
|
@ -49,6 +53,10 @@ func (ag *Agent) Submit(ctx context.Context, input string) {
|
|||
ag.submitMu.Lock()
|
||||
defer ag.submitMu.Unlock()
|
||||
|
||||
if ag.HandleCommand(ctx, input) {
|
||||
return
|
||||
}
|
||||
|
||||
if ag.IsRunning() {
|
||||
ag.fifo.Push(input)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -185,52 +185,10 @@ func (a *Session) SetEnv(key, value string) {
|
|||
a.r.SetEnv(key, value)
|
||||
}
|
||||
|
||||
// Submit forwards user input to the agent for processing.
|
||||
// Slash commands are handled by the agent; session-level operations
|
||||
// are issued via the ctl file, not via prompt.
|
||||
func (a *Session) Submit(ctx context.Context, input string) {
|
||||
if input == "" {
|
||||
return
|
||||
}
|
||||
a.r.Submit(ctx, input)
|
||||
}
|
||||
|
||||
func (a *Session) IsRunning() bool { return a.r.IsRunning() }
|
||||
func (a *Session) State() string { return a.r.State() }
|
||||
func (a *Session) Reply() string { return a.r.Reply() }
|
||||
func (a *Session) AgentName() string { return a.r.Name() }
|
||||
func (a *Session) BackendName() string { return a.r.BackendName() }
|
||||
func (a *Session) ModelName() string { return a.r.ModelName() }
|
||||
func (a *Session) Agent() *agent.Agent { return a.r }
|
||||
func (a *Session) Bus() *pubsub.Bus { return a.bus }
|
||||
func (a *Session) ToolCallCount() int64 { return a.r.ToolCallCount() }
|
||||
func (a *Session) CtxSz() string { return a.r.CtxSz() }
|
||||
func (a *Session) Cost() string { return a.r.CostStr() }
|
||||
func (a *Session) Usage() string { return a.r.UsageStr() }
|
||||
func (a *Session) Context() []backend.Message { return a.r.Context() }
|
||||
func (a *Session) SystemPrompt() string { return a.r.SystemPrompt() }
|
||||
func (a *Session) CompactionModel() string { return a.r.CompactionModel() }
|
||||
func (a *Session) SetCompactionModel(m string) { a.r.SetCompactionModel(m) }
|
||||
|
||||
func (a *Session) GenerationParams() backend.GenerationParams {
|
||||
return a.r.GenParams()
|
||||
}
|
||||
|
||||
func (a *Session) SetGenerationParams(params backend.GenerationParams) error {
|
||||
if a.IsRunning() {
|
||||
return fmt.Errorf("cannot change params while agent is running")
|
||||
}
|
||||
a.r.SetGenParams(params)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *Session) ListModels() string {
|
||||
models := a.r.ListModels()
|
||||
return strings.Join(models, "\n")
|
||||
}
|
||||
|
||||
func (a *Session) Interrupt(cause error) bool {
|
||||
a.log.Debug("Interrupt() cause=%v", cause)
|
||||
return a.r.Interrupt(cause)
|
||||
}
|
||||
|
||||
|
|
@ -239,18 +197,10 @@ func (a *Session) Queue(prompt string) {
|
|||
a.bus.Publish("queued", prompt)
|
||||
}
|
||||
|
||||
func (a *Session) PopQueue() (string, bool) { return a.r.PopQueue() }
|
||||
|
||||
func (a *Session) InjectSystemEvent(content string) {
|
||||
a.Queue("<detached-process-result>\n" + content + "\n</detached-process-result>")
|
||||
}
|
||||
|
||||
func (a *Session) Reactions() map[string]string { return a.r.Reactions() }
|
||||
func (a *Session) React(emoji string) { _ = a.r.React("", emoji) }
|
||||
func (a *Session) ReactTo(responseID, emoji string) error {
|
||||
return a.r.React(responseID, emoji)
|
||||
}
|
||||
|
||||
// CWD returns the current working directory for tool execution.
|
||||
func (a *Session) CWD() string {
|
||||
if c := a.r.Cwd(); c != "" {
|
||||
|
|
@ -304,17 +254,17 @@ func (a *Session) WaitChange(ctx context.Context, field, current string) (string
|
|||
if field == agent.WatchState {
|
||||
return a.r.WaitChange(ctx, field, current)
|
||||
}
|
||||
// Other fields — read via session methods, use agent's change signal.
|
||||
// Other fields — read via agent methods, use agent's change signal.
|
||||
read := func() string {
|
||||
switch field {
|
||||
case "usage":
|
||||
return a.Usage()
|
||||
return a.r.UsageStr()
|
||||
case "ctxsz":
|
||||
return a.CtxSz()
|
||||
return a.r.CtxSz()
|
||||
case "cwd":
|
||||
return a.CWD()
|
||||
case "agent":
|
||||
return a.AgentName()
|
||||
return a.r.Name()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
|
|
|||
Reference in New Issue