Files
yhh 394da0a313 refactor: the kernel's packages live in the layer they belong to
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.
2026-09-23 18:28:21 -07:00

51 lines
1.7 KiB
Go

package agent
import "context"
type rawUserInputKey struct{}
type subagentImageCandidatesKey struct{}
// WithRawUserInput keeps user-authored text separate from host-rendered turn
// context. Runner implementations can persist the raw text while sending their
// composed input to the provider.
func WithRawUserInput(ctx context.Context, raw string) context.Context {
if ctx == nil {
ctx = context.Background()
}
return context.WithValue(ctx, rawUserInputKey{}, raw)
}
// RawUserInput returns the host-authenticated raw user text when available.
// Direct Agent callers that do not use a Controller keep their input unchanged.
func RawUserInput(ctx context.Context, fallback string) string {
if ctx == nil {
return fallback
}
if raw, ok := ctx.Value(rawUserInputKey{}).(string); ok {
return raw
}
return fallback
}
// WithSubagentImageCandidates carries attachment data resolved by the parent
// controller for a child model to opt into when it supports vision. Keeping
// this separate from UserImages avoids changing the parent's provider-visible
// text-only turn while allowing a vision-capable child to receive the same
// authorized attachments.
func WithSubagentImageCandidates(ctx context.Context, images []string) context.Context {
if ctx == nil {
ctx = context.Background()
}
return context.WithValue(ctx, subagentImageCandidatesKey{}, append([]string(nil), images...))
}
// SubagentImageCandidates returns the parent-resolved attachment data that a
// child provider may use when its own model supports vision.
func SubagentImageCandidates(ctx context.Context) []string {
if ctx == nil {
return nil
}
images, _ := ctx.Value(subagentImageCandidatesKey{}).([]string)
return append([]string(nil), images...)
}