* feat(memory): four-scope contract with CRUD and revisions
Seam for memory unification slice 2 (docs/prds/memory-engine-unification.md
§1, §2, §7): internal/domain/memory is now a scope-addressed CRUD contract.
- Scope{Kind,Agent,User} with the four ratified kinds, Validate rejecting a
component present where it is not required, and a length-prefixed Key so
opaque channel-native ids cannot collide.
- Subject{AgentID,UserID} with Scopes()/WritableScopes(): global is never
writable, and an absent user id removes every scope requiring one.
- Store becomes Create/Get/Query/List/Update/Forget/Revisions over
NewRecord/RecordUpdate/Record/Revision, with ErrNotFound/ErrStaleRevision.
Observation, Identity and Metadata are deleted.
- The content scanner moves into the family (internal/domain/memory) so every
engine applies it in Create and Update; internal/memory re-exports the types
until slice 5 deletes it.
- The markdown store moves to internal/infrastructure/memory/builtin, its
correct home per organisation.md.
WIP: internal/infrastructure/memory and internal/infrastructure/sessioncurator
are converted in the lanes that follow this commit.
* feat(memory): builtin engine CRUD, retained revisions and the curator's agent-user write
Slice 2 implementation (docs/prds/memory-engine-unification.md §1, §2, §6,
§7), on top of the contract seam in the previous commit.
- internal/infrastructure/memory: per-scope markdown heads with a JSON
provenance marker, per-scope HISTORY.md retaining superseded and deleted
states, Update superseding before replacing the live block, ErrStaleRevision
via RecordUpdate.Expected, idempotent Forget, and the family scanner applied
in Create and Update. Scope directories are hex(sha256(Scope.Key())).
- internal/infrastructure/sessioncurator: the participant is derived from the
session's user-role senders; exactly one writes agent-user scope, zero or
several write nothing and return ActionSkipped naming the count.
- docs/architecture: the settled decision recorded in migration-decisions §5
(superseding the 2026-09-02 marker entry) and agent-system.md pointing at it.
Draft: to be squashed and reviewed before publication.
* test(curator): conform the registry's fake memory engine to the CRUD contract
The fake still implemented the pre-CRUD Store surface (Write taking an
Observation, List/Forget keyed by a bare string), so the package's test
binary no longer compiles: fakeMemoryEngine is missing Create, Get, Update
and Revisions, and domainmemory.Observation no longer exists. That took
`go fix ./...`, `go vet ./...` and `go test ./...` down with it, which is
what `task check` runs first.
Missed by the same commit that updated internal/infrastructure/sessioncurator's
own fake to the new interface. Repaired on the fake, not by loosening the
interface: the fake is the only thing out of date.
* fix(sessioncurator): refuse to attribute a session with unidentified user messages
sessionParticipant skipped user-role messages with an empty SenderID and
counted only the identified ones, so a session holding one identified sender
plus any number of unidentified user messages yielded that sender as the
single participant. Those messages are still part of the excerpt the
extraction model reads, so facts derived from content of unknown provenance
were written into the identified sender's agent-user scope: user A's memory
can end up crediting content that may belong to someone else. It is exactly
the case the function's own doc comment claims to handle, which it only
caught when no message at all was identified.
An unidentified user message now makes the session unattributable outright,
beside any number of identified senders, and the skip action's reason names
the count instead of reporting a sender count that no longer explains the
skip. Assistant-role messages are unaffected: they carry the bot, so they
still cannot manufacture a participant.
Fixed in sessionParticipant rather than at the write, because it is the
single producer of the attribution decision: it now returns the participant
or the reason there is none, so the caller cannot print a reason that
disagrees with what it decided. The fail-closed path (nothing written, one
ActionSkipped) and the extraction flow are unchanged.
* fix(memory): carry record content through the block format intact
builtin.Store's format ends a block at a blank line and starts a section at a
"## " line, but storeContent only trimmed the content and rejected an empty
one. Content holding either delimiter was accepted, written, and answered back
to the caller in full -- then read back truncated at the delimiter by Get,
List, or a process restart, with the remainder unaddressable and no error
anywhere along the path.
Fixed at the producer, in the render/parse pair that owns the block format:
renderBlock escapes the two delimiter shapes (an empty line becomes a single
backslash, a line already starting with a backslash or "## " gains one) and
parseBlocks undoes it on the way back, so a record's content survives the
write whole. Rejecting the content instead would have made an ordinary
multi-paragraph note or a quoted heading unrepresentable; escaping every line
would have changed the on-disk shape of every record. Only the lines that need
it are escaped, so a one-paragraph record is byte-identical to what the
unfixed engine wrote and the document stays hand-editable.
Reachable from both producers: the chat tool's note and the curator's
model-extracted fact are free text, and neither is constrained to one
paragraph.
Tests: TestBuiltinEngineRenderedBlockRoundTripsContent asserts
parseBlocks(renderBlock(c)) == c for eleven content shapes, and
TestBuiltinEngineContentSurvivesTheWriteAndAReopen carries the same shapes
through Create, Get, and a second engine reading the file a restart would.
* fix(memory): compare Update's expected revision against the file, not the cache
Update read the record to compare against out of findBlock(stores.live, ...)
-- the engine's cached copy of the scope document -- and checked Expected
against that copy. This engine caches one document per scope and rewrites it
whole, so a second engine over the same scope file (archied and the gateway,
or a restart) holds a copy taken when it last read the file: its view of the
record's revision is superseded, Expected matches the revision it remembers,
ErrStaleRevision never fires, and the rewrite that follows writes that stale
copy back over the file -- discarding the other writer's update and every
record written since the copy was loaded. The field existed and could not
fire.
Reload the scope document before anything is decided from it, so the check
answers about the revision actually on disk and the rewrite starts from the
current document. That is the smaller of the two fixes the PRD leaves open
("Not determined": a reload-before-mutate or an advisory lock); no locking
scheme, no retry loop, and no change to the read paths.
Still unsolved, and deliberately: the whole-document rewrite is
last-writer-wins between the reload and the write, so two engines writing one
scope concurrently can still lose one of the two writes, and HISTORY.md is
rewritten from the cached copy the same way.
Tests: TestBuiltinEngineSecondEngineCannotReuseAStaleRevision asserts the
second engine gets ErrStaleRevision and the first writer's state survives;
TestBuiltinEngineUpdateDoesNotEraseRecordsItHasNotLoaded asserts the record
written after the second engine loaded is still there after its update.
* fix(memory): emit the scanner's warning instead of dropping it
scanContent returned nil for every result that was not ThreatBlock, so a
ThreatWarn result -- documented in the scanner as "allow the write but emit a
warning", and what every sensitive-data match produces (API keys, passwords,
tokens, private keys) -- was stored with no audit signal anywhere. The
comment justified the silence by pointing at Bind, but Bind's argument is
about Registrar.Events: internal/events declares no memory kind and the
composition binds no memory event sink, so an invented kind would look wired
and not be. A scanner warning is a diagnostic rather than an event, and there
was nothing else to carry it: the registrar had no logger.
Bind now takes Registrar.Log, optional and mirroring the curator family's
Registrar for the same reason, scanContent emits the warn-level result
through it before the write is allowed, and bootstrap passes the daemon's
logger so the line reaches archied's configured sinks instead of only the
process default. The write is still allowed: only the silence changed.
Tests: TestBuiltinEngineScanWarnsWithoutRefusingTheWrite runs Create and
Update over warn, clean and block content, asserting the write lands either
way, that a warn-level scan result logs exactly one warning carrying the
scanner's own message, that clean content logs none, and that a refused
block-level match logs none.
* test(memory): carry every content shape through Update and Revisions
Update replaces the block it read out of the document by that text, and
retains the superseded state in HISTORY.md, so an escaped block has to be
found, superseded and retained exactly like an unescaped one. Covered here
rather than left to the Create path: without the escaping, every shape in
this table came back truncated after an update, including the plain
one-paragraph record whose replacement holds a blank line.
The test asserts values only: the updated record as a second engine reads it
off disk, and the superseded content as Revisions returns it.
* style(memory): apply the linter's gofumpt form to the Update revision error
golangci-lint's bundled gofumpt wants the closing paren of that wrapped
fmt.Errorf on its own line; the standalone gofumpt binary the fmt task uses
(0.7.0, a different version) leaves it as it was. The text is unchanged from
before the engine fixes in this branch, so this is pre-existing drift inside a
function these commits already touch -- taken so the file is clean under both
formatters rather than only one.
404 lines
14 KiB
Go
404 lines
14 KiB
Go
package builtin
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"sync"
|
|
|
|
"github.com/samcharles93/archie-core/internal/memory"
|
|
"github.com/samcharles93/archie-core/internal/tools"
|
|
)
|
|
|
|
// providerName is the value returned by Provider.Name() and used to route
|
|
// tool calls to this provider.
|
|
const providerName = "builtin"
|
|
|
|
// toolName is the single tool this provider exposes to the agent.
|
|
const toolName = "memory_edit"
|
|
|
|
// Config configures a Provider.
|
|
type Config struct {
|
|
// Dir is the directory MEMORY.md and USER.md are read from and written
|
|
// to (e.g. ~/.config/archie/profiles/{profile}/memory/). It is created
|
|
// if it does not exist.
|
|
Dir string
|
|
|
|
// MaxFileBytes bounds the size of each file. Zero or negative uses
|
|
// defaultMaxFileBytes (100KB).
|
|
MaxFileBytes int
|
|
|
|
// DisableFrozenSnapshot, when true, causes SystemPromptBlock() to read
|
|
// live content from the stores on every call instead of using the
|
|
// snapshot captured at Initialize() time. Defaults to false (frozen
|
|
// snapshot enabled).
|
|
DisableFrozenSnapshot bool
|
|
}
|
|
|
|
// Provider is the built-in, file-backed MemoryProvider. It persists agent
|
|
// memory to MEMORY.md and user-provided context to USER.md under Config.Dir,
|
|
// and exposes a single "memory_edit" tool with add/replace/remove actions.
|
|
//
|
|
// By default, the provider captures a frozen snapshot of both files at
|
|
// Initialize() time and uses that snapshot for the system prompt block
|
|
// (SystemPromptProvider). Writes go to disk immediately but the snapshot is
|
|
// not updated mid-session -- only the next session (or next Initialize call)
|
|
// picks up the changes. Set Config.FrozenSnapshot to false to read live
|
|
// content on every SystemPromptBlock() call.
|
|
type Provider struct {
|
|
memory *Store
|
|
user *Store
|
|
|
|
// frozenSnapshotEnabled mirrors Config.FrozenSnapshot. When unset
|
|
// (default), Initialize() captures a snapshot that SystemPromptBlock()
|
|
// returns for the lifetime of the session.
|
|
frozenSnapshotEnabled bool
|
|
|
|
// frozenMu guards frozenMemory and frozenUser, since Initialize() can
|
|
// race with SystemPromptBlock() if a caller re-initializes a session on
|
|
// a Provider shared across goroutines.
|
|
frozenMu sync.RWMutex
|
|
|
|
// frozen memory and frozen user hold the Render() output captured at
|
|
// Initialize() time. They are only valid after Initialize() has been
|
|
// called and only used when frozenSnapshotEnabled is true.
|
|
frozenMemory string
|
|
frozenUser string
|
|
|
|
// dirErr records a Config.Dir that could not be established. The
|
|
// provider stays usable for reads -- a memory that cannot be written is
|
|
// still better than a daemon that will not start -- and reports itself
|
|
// unavailable so the failure is visible rather than looking like a
|
|
// memory that simply has nothing in it yet.
|
|
dirErr error
|
|
}
|
|
|
|
// New creates a Provider backed by the two markdown files under cfg.Dir.
|
|
// Both files are read immediately so the provider is ready for use as soon
|
|
// as New returns.
|
|
//
|
|
// An unusable cfg.Dir is reported through IsAvailable and Err, not by
|
|
// failing: memory is one capability among many, and a bad path is not worth
|
|
// refusing to start over. The caller decides whether to fall back elsewhere.
|
|
// Establishing the directory here is still what makes the problem visible at
|
|
// all -- both stores treat a missing file as an empty document, so otherwise
|
|
// a directory that does not exist is indistinguishable from a memory that
|
|
// simply has nothing in it yet, and the failure surfaces at the agent's
|
|
// first write, mid-conversation.
|
|
//
|
|
// FrozenSnapshot defaults to true (frozen snapshot enabled). Set it
|
|
// explicitly to false to have SystemPromptBlock() read live content from
|
|
// the stores.
|
|
func New(cfg Config) (*Provider, error) {
|
|
if cfg.Dir == "" {
|
|
return nil, fmt.Errorf("builtin: Config.Dir must not be empty")
|
|
}
|
|
|
|
var dirErr error
|
|
if err := os.MkdirAll(cfg.Dir, 0o755); err != nil {
|
|
dirErr = fmt.Errorf("builtin: memory directory %s unusable: %w", cfg.Dir, err)
|
|
}
|
|
|
|
// A store that cannot read its file starts empty rather than failing,
|
|
// for the same reason: reads must keep working on a degraded provider.
|
|
memStore, err := NewStore(filepath.Join(cfg.Dir, "MEMORY.md"), cfg.MaxFileBytes)
|
|
if err != nil {
|
|
if dirErr == nil {
|
|
dirErr = err
|
|
}
|
|
memStore = emptyStore(filepath.Join(cfg.Dir, "MEMORY.md"), cfg.MaxFileBytes)
|
|
}
|
|
userStore, err := NewStore(filepath.Join(cfg.Dir, "USER.md"), cfg.MaxFileBytes)
|
|
if err != nil {
|
|
if dirErr == nil {
|
|
dirErr = err
|
|
}
|
|
userStore = emptyStore(filepath.Join(cfg.Dir, "USER.md"), cfg.MaxFileBytes)
|
|
}
|
|
|
|
// Frozen snapshot is enabled by default (DisableFrozenSnapshot defaults
|
|
// to false).
|
|
frozen := !cfg.DisableFrozenSnapshot
|
|
|
|
return &Provider{
|
|
memory: memStore,
|
|
user: userStore,
|
|
frozenSnapshotEnabled: frozen,
|
|
dirErr: dirErr,
|
|
}, nil
|
|
}
|
|
|
|
// Name returns the provider's identifier.
|
|
func (p *Provider) Name() string { return providerName }
|
|
|
|
// IsAvailable reports whether the backing directory could be established.
|
|
// The built-in provider has one external dependency after all -- the
|
|
// filesystem -- and a directory it cannot write to means memory reads as
|
|
// empty and every write will fail.
|
|
func (p *Provider) IsAvailable() bool { return p.dirErr == nil }
|
|
|
|
// Err returns why the provider is unavailable, or nil. Callers log this: an
|
|
// operator told only that memory is unavailable has nothing to act on.
|
|
func (p *Provider) Err() error { return p.dirErr }
|
|
|
|
// SystemPromptBlock implements memory.SystemPromptProvider. It returns a
|
|
// markdown-formatted block containing the frozen snapshot of MEMORY.md and
|
|
// USER.md content, wrapped in <memory>…</memory> fences.
|
|
//
|
|
// When the frozen snapshot is enabled (the default), the block is built from
|
|
// the snapshot captured at Initialize() time and does not change for the
|
|
// duration of the session. When disabled (Config.DisableFrozenSnapshot =
|
|
// true), the block is built from the live store content on every call.
|
|
//
|
|
// Returns an empty string when both stores are empty.
|
|
func (p *Provider) SystemPromptBlock() string {
|
|
mem, user := p.snapshotContent()
|
|
if mem == "" && user == "" {
|
|
return ""
|
|
}
|
|
|
|
var sb strings.Builder
|
|
sb.WriteString("<memory>\n")
|
|
if mem != "" {
|
|
sb.WriteString(mem)
|
|
}
|
|
if user != "" {
|
|
if mem != "" {
|
|
sb.WriteString("\n")
|
|
}
|
|
sb.WriteString(user)
|
|
}
|
|
sb.WriteString("\n</memory>\n")
|
|
return sb.String()
|
|
}
|
|
|
|
// snapshotContent returns the memory and user content, either from the frozen
|
|
// snapshot or live from the stores, depending on the FrozenSnapshot config.
|
|
func (p *Provider) snapshotContent() (memory, user string) {
|
|
if p.frozenSnapshotEnabled {
|
|
p.frozenMu.RLock()
|
|
defer p.frozenMu.RUnlock()
|
|
return p.frozenMemory, p.frozenUser
|
|
}
|
|
return p.memory.Render(), p.user.Render()
|
|
}
|
|
|
|
// Initialize reloads MEMORY.md and USER.md from disk so that any changes
|
|
// made outside this process (or by a previous provider instance) since
|
|
// New was called are picked up before the session begins.
|
|
//
|
|
// When frozen snapshot is enabled (the default), Initialize captures the
|
|
// rendered content of both files for use by SystemPromptBlock(). The snapshot
|
|
// is not updated on subsequent writes -- only the next Initialize() call (or
|
|
// the next session) picks up the fresh content.
|
|
func (p *Provider) Initialize(sessionID string) error {
|
|
if err := p.memory.Reload(); err != nil {
|
|
return err
|
|
}
|
|
if err := p.user.Reload(); err != nil {
|
|
return err
|
|
}
|
|
|
|
if p.frozenSnapshotEnabled {
|
|
mem := p.memory.Render()
|
|
user := p.user.Render()
|
|
p.frozenMu.Lock()
|
|
p.frozenMemory = mem
|
|
p.frozenUser = user
|
|
p.frozenMu.Unlock()
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// GetToolSchemas returns the memory_edit tool definition. Handler is left
|
|
// nil so the MemoryManager injects a delegating handler via
|
|
// ToolCallProvider (see Manager.GetToolSchemas); callers that bypass the
|
|
// Manager should invoke HandleToolCall directly.
|
|
func (p *Provider) GetToolSchemas() []tools.ToolEntry {
|
|
return []tools.ToolEntry{
|
|
{
|
|
Name: toolName,
|
|
Toolset: "memory",
|
|
Description: "Persist or edit agent memory. Add, replace, or remove content in a named section of MEMORY.md (agent memory) or USER.md (user-provided context).",
|
|
Schema: toolSchema,
|
|
},
|
|
}
|
|
}
|
|
|
|
// toolSchema is the JSON Schema for the memory_edit tool's input.
|
|
var toolSchema = tools.JSONSchema{
|
|
"type": "object",
|
|
"properties": map[string]any{
|
|
"file": map[string]any{
|
|
"type": "string",
|
|
"enum": []string{"memory", "user"},
|
|
"description": "Which file to edit: \"memory\" for MEMORY.md (agent memory) or \"user\" for USER.md (user-provided context). Defaults to \"memory\".",
|
|
},
|
|
"action": map[string]any{
|
|
"type": "string",
|
|
"enum": []string{"add", "replace", "remove"},
|
|
"description": "The action to perform: add a new entry, replace a substring, or remove a matching entry.",
|
|
},
|
|
"section": map[string]any{
|
|
"type": "string",
|
|
"description": "Name of the section (markdown header) to operate on. Alphanumeric and spaces only, max 64 characters. Created automatically by \"add\" if it does not exist.",
|
|
},
|
|
"content": map[string]any{
|
|
"type": "string",
|
|
"description": "Content to append as a new entry. Required for the \"add\" action.",
|
|
},
|
|
"substring": map[string]any{
|
|
"type": "string",
|
|
"description": "Exact substring to locate within the section. Required for \"replace\" and \"remove\".",
|
|
},
|
|
"replacement": map[string]any{
|
|
"type": "string",
|
|
"description": "Text to substitute in place of substring. Required for the \"replace\" action.",
|
|
},
|
|
"case_sensitive": map[string]any{
|
|
"type": "boolean",
|
|
"description": "Whether substring matching is case-sensitive. Defaults to true.",
|
|
},
|
|
},
|
|
"required": []string{"action", "section"},
|
|
}
|
|
|
|
// HandleToolCall implements memory.ToolCallProvider. It dispatches the
|
|
// memory_edit tool's add/replace/remove actions to the selected store.
|
|
func (p *Provider) HandleToolCall(name string, args map[string]any) (any, error) {
|
|
if name != toolName {
|
|
return nil, fmt.Errorf("builtin: unknown tool %q", name)
|
|
}
|
|
|
|
store, fileLabel, err := p.selectStore(args)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
action, _ := args["action"].(string)
|
|
caseSensitive := true
|
|
if v, ok := args["case_sensitive"].(bool); ok {
|
|
caseSensitive = v
|
|
}
|
|
|
|
switch action {
|
|
case "add":
|
|
return p.handleAdd(store, fileLabel, args)
|
|
case "replace":
|
|
return p.handleReplace(store, fileLabel, args, caseSensitive)
|
|
case "remove":
|
|
return p.handleRemove(store, fileLabel, args, caseSensitive)
|
|
default:
|
|
return nil, fmt.Errorf("builtin: unknown action %q (want add, replace, or remove)", action)
|
|
}
|
|
}
|
|
|
|
func (p *Provider) handleAdd(store *Store, fileLabel string, args map[string]any) (any, error) {
|
|
content, _ := args["content"].(string)
|
|
if content == "" {
|
|
return nil, fmt.Errorf("builtin: add requires non-empty \"content\"")
|
|
}
|
|
section, _ := args["section"].(string)
|
|
res, err := store.Add(section, content)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
verb := "appended to"
|
|
if res.Created {
|
|
verb = "created"
|
|
}
|
|
return map[string]any{
|
|
"success": true,
|
|
"file": fileLabel,
|
|
"action": "add",
|
|
"section": res.Section,
|
|
"chars_added": res.CharsAdded,
|
|
"section_chars": res.SectionChars,
|
|
"file_bytes": res.FileBytes,
|
|
"message": fmt.Sprintf("%s section %q (%d chars added, %d bytes in file)", capitalize(verb), res.Section, res.CharsAdded, res.FileBytes),
|
|
}, nil
|
|
}
|
|
|
|
func (p *Provider) handleReplace(store *Store, fileLabel string, args map[string]any, caseSensitive bool) (any, error) {
|
|
substring, _ := args["substring"].(string)
|
|
replacement, _ := args["replacement"].(string)
|
|
if substring == "" {
|
|
return nil, fmt.Errorf("builtin: replace requires non-empty \"substring\"")
|
|
}
|
|
section, _ := args["section"].(string)
|
|
res, err := store.Replace(section, substring, replacement, caseSensitive)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return map[string]any{
|
|
"success": true,
|
|
"file": fileLabel,
|
|
"action": "replace",
|
|
"section": res.Section,
|
|
"chars_removed": res.CharsRemoved,
|
|
"chars_added": res.CharsAdded,
|
|
"section_chars": res.SectionChars,
|
|
"file_bytes": res.FileBytes,
|
|
"message": fmt.Sprintf("Replaced %d chars with %d chars in section %q (%d bytes in file)", res.CharsRemoved, res.CharsAdded, res.Section, res.FileBytes),
|
|
}, nil
|
|
}
|
|
|
|
func (p *Provider) handleRemove(store *Store, fileLabel string, args map[string]any, caseSensitive bool) (any, error) {
|
|
substring, _ := args["substring"].(string)
|
|
if substring == "" {
|
|
return nil, fmt.Errorf("builtin: remove requires non-empty \"substring\"")
|
|
}
|
|
section, _ := args["section"].(string)
|
|
res, err := store.Remove(section, substring, caseSensitive)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return map[string]any{
|
|
"success": true,
|
|
"file": fileLabel,
|
|
"action": "remove",
|
|
"section": res.Section,
|
|
"chars_removed": res.CharsRemoved,
|
|
"section_chars": res.SectionChars,
|
|
"file_bytes": res.FileBytes,
|
|
"message": fmt.Sprintf("Removed %d chars from section %q (%d bytes in file)", res.CharsRemoved, res.Section, res.FileBytes),
|
|
}, nil
|
|
}
|
|
|
|
// selectStore resolves the "file" argument to the corresponding store,
|
|
// defaulting to the memory (MEMORY.md) store.
|
|
func (p *Provider) selectStore(args map[string]any) (*Store, string, error) {
|
|
file, _ := args["file"].(string)
|
|
switch file {
|
|
case "", "memory":
|
|
return p.memory, "memory", nil
|
|
case "user":
|
|
return p.user, "user", nil
|
|
default:
|
|
return nil, "", fmt.Errorf("builtin: unknown file %q (want \"memory\" or \"user\")", file)
|
|
}
|
|
}
|
|
|
|
// capitalize upper-cases the first byte of s. It is only used for
|
|
// short, ASCII, English status verbs, so byte-level capitalization is
|
|
// sufficient.
|
|
func capitalize(s string) string {
|
|
if s == "" {
|
|
return s
|
|
}
|
|
b := []byte(s)
|
|
if b[0] >= 'a' && b[0] <= 'z' {
|
|
b[0] -= 'a' - 'A'
|
|
}
|
|
return string(b)
|
|
}
|
|
|
|
// Compile-time interface checks.
|
|
var (
|
|
_ memory.MemoryProvider = (*Provider)(nil)
|
|
_ memory.ToolCallProvider = (*Provider)(nil)
|
|
_ memory.SystemPromptProvider = (*Provider)(nil)
|
|
)
|