Documentation
¶
Index ¶
- Constants
- func ActiveEntryKey(route agentkit.RouteRef, policy RoutePolicy, userID string) agentkit.SessionID
- func ActiveEntryKeyFromContext(ctx context.Context) agentkit.SessionID
- func ActiveSessionEntryKey(platform string, delivery agentkit.SessionID, scope SessionScope, ...) agentkit.SessionID
- func AgentIDFromContext(ctx context.Context) agentkit.AgentID
- func AppendAutoRetryEnd(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendAutoRetryStart(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendCompaction(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendMessage(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendOverflowRecovery(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendRunFinish(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendSessionRecovery(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendSkillLoad(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendStepEnd(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, step int) error
- func AppendStepStart(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, step int) error
- func AppendSubagentEnd(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendSubagentStart(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendSummarizationRetryEnd(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendSummarizationRetryStart(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendTodoUpdate(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendToolCall(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendToolResult(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendTurnContinue(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func AppendTurnEnd(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, steps int) error
- func AppendTurnStart(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID) error
- func AppendUsage(ctx context.Context, s agentkit.Session, agentID agentkit.AgentID, ...) error
- func ApplyEnvelopeToContext(ctx context.Context, env agentkit.TurnEnvelope) context.Context
- func ApplyScope(delivery agentkit.SessionID, scope SessionScope, userID string) agentkit.SessionID
- func BuildDeliverySessionID(platform, channel, thread, user string) agentkit.SessionID
- func BuildSessionRoute(in SessionRouteInput) agentkit.RouteRef
- func ChannelKeyMatches(jobChannelKey, contextChannelKey string) bool
- func ChildConversationID(parentConversation, agentName string, seq int64) string
- func ContextWithDeliveryRoute(ctx context.Context, platform string, delivery agentkit.SessionID) context.Context
- func ConversationFromContext(ctx context.Context) string
- func ConversationFromEvent(event agentkit.MessageEvent) agentkit.SessionID
- func ConversationFromLoopRequest(req agentkit.LoopRequest) agentkit.SessionID
- func DecodeSessionRoute(route agentkit.RouteRef) (agentkit.SessionRouteTarget, bool)
- func DeliveryFromEnvelope(env agentkit.TurnEnvelope) agentkit.SessionID
- func DeliveryRouteFromContext(ctx context.Context) agentkit.SessionID
- func DeliveryWithUser(delivery agentkit.SessionID, userID string) agentkit.SessionID
- func EnvelopeFromContext(ctx context.Context) agentkit.TurnEnvelope
- func EstimateLogicalChars(msg agentkit.ModelMessage) int
- func HydrateLocalAttachments(ctx context.Context, msgs []agentkit.ModelMessage, ws workspace.Service, ...) ([]agentkit.ModelMessage, error)
- func InboundDeliveryID(event agentkit.MessageEvent) agentkit.SessionID
- func InterruptedToolResult(call agentkit.ToolCall) agentkit.ToolResult
- func LastAssistantText(events []agentkit.SessionEvent, seq agentkit.EventSeq) string
- func LatestEventSeq(events []agentkit.SessionEvent) agentkit.EventSeq
- func LatestSeq(ctx context.Context, s agentkit.Session) (agentkit.EventSeq, error)
- func MergeEnvelopeMetadata(env agentkit.TurnEnvelope, extra map[string]any) agentkit.TurnEnvelope
- func MetadataFromContext(ctx context.Context) map[string]any
- func MetadataString(env agentkit.TurnEnvelope, key string) string
- func NewCLISessionID() agentkit.SessionID
- func NewCommands(_ CommandsConfig, deps CommandsDeps) (agentkit.CommandProvider, error)
- func NewConversationID(current string) string
- func NewJSONL(cfg JSONLConfig) (agentkit.Session, error)
- func NewMemory(cfg MemoryConfig) (agentkit.Session, error)
- func NewSessionID(base agentkit.SessionID) agentkit.SessionID
- func NewStatic(_ StaticConfig, deps StaticDeps) (agentkit.SessionStore, error)
- func NewStore(cfg StoreConfig, deps StoreDeps) (agentkit.SessionStore, error)
- func OutboundFromEnvelope(env agentkit.TurnEnvelope, typ agentkit.EventType, data []byte) agentkit.OutboundEvent
- func OutboundRouteID(event agentkit.OutboundEvent) agentkit.SessionID
- func PlatformFromContext(ctx context.Context) string
- func PruneToolResults(messages []agentkit.ModelMessage, maxBytes int) []agentkit.ModelMessage
- func ReadAllEvents(ctx context.Context, s agentkit.Session) ([]agentkit.SessionEvent, error)
- func RegisterPlatformPolicy(platform string, policy PlatformSessionPolicy)
- func RepeatedToolCalls(events []agentkit.SessionEvent, seq agentkit.EventSeq) int
- func ResolveActiveSessionID(ctx context.Context, store agentkit.SessionStore, entryKey agentkit.SessionID) (agentkit.SessionID, error)
- func ResolveEnvelope(event agentkit.MessageEvent, policy RoutePolicy) agentkit.TurnEnvelope
- func RouteRefFromContext(ctx context.Context) agentkit.RouteRef
- func RouteReplyTo(route agentkit.RouteRef) string
- func RouteSessionID(route agentkit.RouteRef) (agentkit.SessionID, bool)
- func RunStartSeq(events []agentkit.SessionEvent) agentkit.EventSeq
- func SanitizeModelMessageForStorage(msg agentkit.ModelMessage, maxTextBytes int) agentkit.ModelMessage
- func SessionIDFromContext(ctx context.Context) agentkit.SessionID
- func SessionRoute(platform, deliveryID string) agentkit.RouteRef
- func SessionRouteFromDelivery(platform string, delivery agentkit.SessionID, replyTo string) agentkit.RouteRef
- func SlackSessionID(channelID, threadTS string) agentkit.SessionID
- func SlackSessionIDForScope(scope SessionScope, channelID, threadTS, userID string) agentkit.SessionID
- func StepCount(events []agentkit.SessionEvent, seq agentkit.EventSeq) int
- func SumLogicalCharsFromEvents(events []agentkit.SessionEvent, agentID agentkit.AgentID) int
- func SyncMessageEvent(event agentkit.MessageEvent, env agentkit.TurnEnvelope) agentkit.MessageEvent
- func TrimCompacted(s agentkit.Session, agentID agentkit.AgentID, beforeSeq agentkit.EventSeq)
- func TruncateToolResult(result agentkit.ToolResult, maxBytes int) agentkit.ToolResult
- func UserIDFromContext(ctx context.Context) string
- func WithAgentID(ctx context.Context, agentID agentkit.AgentID) context.Context
- func WithContextMetadata(ctx context.Context, extra map[string]any) context.Context
- func WithConversation(ctx context.Context, conversation string) context.Context
- func WithMetadataScope(env agentkit.TurnEnvelope, scope SessionScope) agentkit.TurnEnvelope
- func WithRoute(ctx context.Context, route agentkit.RouteRef) context.Context
- func WithWorkspace(ctx context.Context, workspace string) context.Context
- func WorkspaceDirName(key string) string
- func WorkspaceFromContext(ctx context.Context) string
- func WorkspaceKey(sessionID string) string
- func WorkspaceLocalDirName(key string, omitPlatform bool) string
- type ActiveEntryMode
- type ActiveSessionData
- type AgentBindData
- type AutoRetryEndData
- type AutoRetryStartData
- type Commands
- type CommandsConfig
- type CommandsDeps
- type DeliveryParts
- type FileBacked
- type IncompleteTurn
- type IndexedMessage
- type JSONL
- func (s *JSONL) Append(ctx context.Context, event agentkit.SessionEvent) (agentkit.EventSeq, error)
- func (s *JSONL) DeriveMessages(ctx context.Context) ([]agentkit.ModelMessage, error)
- func (s *JSONL) FilePath() string
- func (s *JSONL) ID() agentkit.SessionID
- func (s *JSONL) LatestSeq() agentkit.EventSeq
- func (s *JSONL) Read(ctx context.Context, from agentkit.EventSeq) ([]agentkit.SessionEvent, error)
- type JSONLConfig
- type Memory
- func (s *Memory) Append(_ context.Context, event agentkit.SessionEvent) (agentkit.EventSeq, error)
- func (s *Memory) DeriveMessages(ctx context.Context) ([]agentkit.ModelMessage, error)
- func (s *Memory) ID() agentkit.SessionID
- func (s *Memory) LatestSeq() agentkit.EventSeq
- func (s *Memory) Read(_ context.Context, from agentkit.EventSeq) ([]agentkit.SessionEvent, error)
- type MemoryConfig
- type OverflowRecoveryData
- type PlatformSessionPolicy
- type RecoveryData
- type RoutePolicy
- type RouteTarget
- type RunFinishData
- type RunState
- type SessionRouteInput
- type SessionScope
- type StaticConfig
- type StaticDeps
- type StaticStore
- func (s *StaticStore) ActiveSession(ctx context.Context, id agentkit.SessionID) (agentkit.SessionID, error)
- func (s *StaticStore) AgentBind(ctx context.Context, id agentkit.SessionID) (agentkit.AgentID, error)
- func (s *StaticStore) Get(_ context.Context, id agentkit.SessionID) (agentkit.Session, error)
- func (s *StaticStore) SetActiveSession(ctx context.Context, id, active agentkit.SessionID) error
- func (s *StaticStore) SetAgentBind(ctx context.Context, id agentkit.SessionID, agent agentkit.AgentID) error
- type StepEndData
- type StepStartData
- type Store
- func (s *Store) ActiveSession(ctx context.Context, id agentkit.SessionID) (agentkit.SessionID, error)
- func (s *Store) AgentBind(ctx context.Context, id agentkit.SessionID) (agentkit.AgentID, error)
- func (s *Store) Get(ctx context.Context, id agentkit.SessionID) (agentkit.Session, error)
- func (s *Store) SetActiveSession(ctx context.Context, id, active agentkit.SessionID) error
- func (s *Store) SetAgentBind(ctx context.Context, id agentkit.SessionID, agent agentkit.AgentID) error
- type StoreConfig
- type StoreDeps
- type SubagentEndData
- type SubagentStartData
- type SummarizationRetryEndData
- type SummarizationRetryStartData
- type Todo
- type TodoUpdateData
- type TurnContinueData
- type TurnEndData
- type TurnStartData
- type UsageData
Constants ¶
const ( MetadataSessionScope = "sessionScope" MetadataConversationID = "conversationId" MetadataTurnCount = "turnCount" )
const ( ScopeChannel = agentkit.SessionScopeChannel ScopeThread = agentkit.SessionScopeThread ScopeUser = agentkit.SessionScopeUser )
const ( TodoPending = "pending" TodoInProgress = "in_progress" TodoDone = "done" )
Todo statuses. Anything other than TodoDone counts as outstanding work.
const ( FinishCompleted = "completed" FinishBlocked = "blocked" )
Run finish statuses.
const DefaultCLISessionID = agentkit.SessionID("cli:default")
const DefaultMaxStoredTextBytes = 8192
DefaultMaxStoredTextBytes caps text persisted in session history.
const DefaultSessionScope = agentkit.DefaultSessionScope
DefaultSessionScope is the runner default when sessionScope is unset.
const InterruptedToolResultText = "tool execution was interrupted before it produced a result (process exited); re-run it if the result is still needed"
InterruptedToolResultText is the tool result synthesized for a call the process never got to answer. It is model-visible on purpose: the agent needs to know the call was cut off rather than silently succeeded.
const MetadataLogicalChars = "logical_chars"
MetadataLogicalChars stores pre-sanitize message size on user/assistant events.
const TenantToolWorkDir = "work"
TenantToolWorkDir is the workspace-relative directory for shell cwd and temp artifacts.
Variables ¶
This section is empty.
Functions ¶
func ActiveEntryKey ¶ added in v0.2.1
ActiveEntryKey returns the stable key for /new active-session mapping.
func ActiveEntryKeyFromContext ¶ added in v0.2.1
ActiveEntryKeyFromContext derives the stable /new active-session mapping key from the turn route. Conversation may already be resolved to a child session.
func ActiveSessionEntryKey ¶ added in v0.1.6
func ActiveSessionEntryKey(platform string, delivery agentkit.SessionID, scope SessionScope, userID string) agentkit.SessionID
ActiveSessionEntryKey returns the stable session-store key used for /new active-session mapping.
func AgentIDFromContext ¶ added in v0.2.1
AgentIDFromContext reports the agent executing the current turn.
func AppendAutoRetryEnd ¶
func AppendAutoRetryStart ¶
func AppendCompaction ¶
func AppendMessage ¶
func AppendOverflowRecovery ¶
func AppendRunFinish ¶
func AppendSessionRecovery ¶
func AppendSkillLoad ¶
func AppendStepEnd ¶
func AppendStepStart ¶
func AppendSubagentEnd ¶
func AppendSubagentStart ¶
func AppendTodoUpdate ¶
func AppendToolCall ¶
func AppendToolResult ¶
func AppendTurnContinue ¶
func AppendTurnEnd ¶
func AppendTurnStart ¶
func AppendUsage ¶
func ApplyEnvelopeToContext ¶ added in v0.2.1
ApplyEnvelopeToContext stores the turn envelope on ctx.
func ApplyScope ¶ added in v0.1.3
ApplyScope derives the effective session id used for Loop locking, history, and permission pending.
func BuildDeliverySessionID ¶ added in v0.1.3
BuildDeliverySessionID is the canonical finest-grain id platforms should emit.
func BuildSessionRoute ¶ added in v0.2.1
func BuildSessionRoute(in SessionRouteInput) agentkit.RouteRef
BuildSessionRoute builds a session-kind RouteRef from structured fields.
func ChannelKeyMatches ¶ added in v0.1.10
ChannelKeyMatches reports whether a job belongs to the given channel key.
func ChildConversationID ¶ added in v0.2.1
ChildConversationID returns a subagent conversation id under a parent.
func ContextWithDeliveryRoute ¶ added in v0.2.1
func ContextWithDeliveryRoute(ctx context.Context, platform string, delivery agentkit.SessionID) context.Context
ContextWithDeliveryRoute attaches a minimal session-kind delivery route to ctx.
func ConversationFromContext ¶ added in v0.2.1
ConversationFromContext reports the history/lock key for the current turn.
func ConversationFromEvent ¶ added in v0.2.1
func ConversationFromEvent(event agentkit.MessageEvent) agentkit.SessionID
ConversationFromEvent returns the conversation key for Loop locking and history.
func ConversationFromLoopRequest ¶ added in v0.2.1
func ConversationFromLoopRequest(req agentkit.LoopRequest) agentkit.SessionID
ConversationFromLoopRequest returns the conversation key for a queued turn.
func DecodeSessionRoute ¶ added in v0.2.1
func DecodeSessionRoute(route agentkit.RouteRef) (agentkit.SessionRouteTarget, bool)
DecodeSessionRoute decodes a session-kind RouteRef into SessionRouteTarget.
func DeliveryFromEnvelope ¶ added in v0.2.1
func DeliveryFromEnvelope(env agentkit.TurnEnvelope) agentkit.SessionID
DeliveryFromEnvelope returns the outbound delivery id from a turn envelope.
func DeliveryRouteFromContext ¶ added in v0.2.1
DeliveryRouteFromContext returns the platform delivery target from the turn envelope.
func DeliveryWithUser ¶ added in v0.1.3
DeliveryWithUser returns a delivery SessionID with the :u: segment set or replaced.
func EnvelopeFromContext ¶ added in v0.2.1
func EnvelopeFromContext(ctx context.Context) agentkit.TurnEnvelope
EnvelopeFromContext returns the current turn envelope, or zero when unset.
func EstimateLogicalChars ¶ added in v0.1.12
func EstimateLogicalChars(msg agentkit.ModelMessage) int
EstimateLogicalChars approximates model-visible size before session storage.
func HydrateLocalAttachments ¶ added in v0.1.12
func HydrateLocalAttachments(ctx context.Context, msgs []agentkit.ModelMessage, ws workspace.Service, maxImageBytes int) ([]agentkit.ModelMessage, error)
HydrateLocalAttachments reloads workspace images for LLM vision: attachment_ref on the latest user message, and read-tool image paths from the current tool batch since that user turn.
func InboundDeliveryID ¶ added in v0.2.1
func InboundDeliveryID(event agentkit.MessageEvent) agentkit.SessionID
InboundDeliveryID returns the platform delivery target from an inbound message.
func InterruptedToolResult ¶
func InterruptedToolResult(call agentkit.ToolCall) agentkit.ToolResult
InterruptedToolResult is the stand-in result for a call that never ran to completion.
func LastAssistantText ¶
func LastAssistantText(events []agentkit.SessionEvent, seq agentkit.EventSeq) string
LastAssistantText returns the text of the most recent assistant message after seq.
func LatestEventSeq ¶
func LatestEventSeq(events []agentkit.SessionEvent) agentkit.EventSeq
func LatestSeq ¶ added in v0.1.9
LatestSeq returns the highest durable event sequence for the session.
func MergeEnvelopeMetadata ¶ added in v0.2.2
func MergeEnvelopeMetadata(env agentkit.TurnEnvelope, extra map[string]any) agentkit.TurnEnvelope
MergeEnvelopeMetadata copies extra metadata onto env.
func MetadataFromContext ¶ added in v0.2.1
MetadataFromContext returns platform metadata for the current turn.
func MetadataString ¶ added in v0.2.2
func MetadataString(env agentkit.TurnEnvelope, key string) string
MetadataString returns a trimmed metadata string when present.
func NewCLISessionID ¶
NewCLISessionID returns a fresh opaque CLI session id.
func NewCommands ¶ added in v0.2.2
func NewCommands(_ CommandsConfig, deps CommandsDeps) (agentkit.CommandProvider, error)
NewCommands registers session/commands: Session lifecycle slash commands backed by SessionStore.
func NewConversationID ¶ added in v0.2.1
NewConversationID returns a fresh conversation id for /new.
func NewJSONL ¶
func NewJSONL(cfg JSONLConfig) (agentkit.Session, error)
NewJSONL registers session/jsonl: Append-only JSONL event log for one session.
Best practices:
- Reopening a file resumes event sequence numbering, so seq stays unique across restarts.
func NewMemory ¶
func NewMemory(cfg MemoryConfig) (agentkit.Session, error)
NewMemory registers session/memory: Ephemeral in-memory session. Nothing survives the process.
func NewSessionID ¶ added in v0.1.6
NewSessionID returns a fresh logical session id derived from the current stable session key. CLI keeps its historic cli:<timestamp> format.
func NewStatic ¶
func NewStatic(_ StaticConfig, deps StaticDeps) (agentkit.SessionStore, error)
NewStatic registers session/static: Wrap one pre-built Session as a store that returns it for every id.
Best practices:
- For tests and single-session hosts; every session id maps to the same log.
func NewStore ¶
func NewStore(cfg StoreConfig, deps StoreDeps) (agentkit.SessionStore, error)
NewStore registers session/store: Resolve durable JSONL sessions by id.
func OutboundFromEnvelope ¶ added in v0.2.1
func OutboundFromEnvelope(env agentkit.TurnEnvelope, typ agentkit.EventType, data []byte) agentkit.OutboundEvent
OutboundFromEnvelope builds an outbound event from envelope routing context.
func OutboundRouteID ¶ added in v0.2.1
func OutboundRouteID(event agentkit.OutboundEvent) agentkit.SessionID
OutboundRouteID returns the platform routing target for an outbound event.
func PlatformFromContext ¶ added in v0.2.1
PlatformFromContext reports the platform id for the current turn.
func PruneToolResults ¶ added in v0.2.2
func PruneToolResults(messages []agentkit.ModelMessage, maxBytes int) []agentkit.ModelMessage
PruneToolResults truncates oversized tool result text deterministically.
func ReadAllEvents ¶
func RegisterPlatformPolicy ¶ added in v0.2.1
func RegisterPlatformPolicy(platform string, policy PlatformSessionPolicy)
RegisterPlatformPolicy registers or overrides routing policy for a platform id.
func RepeatedToolCalls ¶
func RepeatedToolCalls(events []agentkit.SessionEvent, seq agentkit.EventSeq) int
RepeatedToolCalls returns how many times the most recent tool call signature repeats consecutively at the tail of the log after seq.
func ResolveActiveSessionID ¶ added in v0.1.23
func ResolveActiveSessionID(ctx context.Context, store agentkit.SessionStore, entryKey agentkit.SessionID) (agentkit.SessionID, error)
ResolveActiveSessionID maps a stable active-session entry key to the current history SessionID. When no /new mapping exists, entryKey is returned unchanged.
func ResolveEnvelope ¶ added in v0.2.1
func ResolveEnvelope(event agentkit.MessageEvent, policy RoutePolicy) agentkit.TurnEnvelope
ResolveEnvelope builds a TurnEnvelope from an inbound MessageEvent and policy.
func RouteRefFromContext ¶ added in v0.2.1
RouteRefFromContext returns the outbound route from the turn envelope.
func RouteReplyTo ¶ added in v0.2.1
RouteReplyTo returns the ephemeral reply anchor for this turn, if any.
func RouteSessionID ¶ added in v0.2.1
RouteSessionID decodes a session-kind RouteRef into a delivery SessionID.
func RunStartSeq ¶
func RunStartSeq(events []agentkit.SessionEvent) agentkit.EventSeq
RunStartSeq returns the seq of the most recent inbound user message.
func SanitizeModelMessageForStorage ¶ added in v0.1.12
func SanitizeModelMessageForStorage(msg agentkit.ModelMessage, maxTextBytes int) agentkit.ModelMessage
SanitizeModelMessageForStorage removes bulky media payloads and truncates long text before writing user/assistant messages to durable session history.
func SessionIDFromContext ¶ added in v0.2.1
SessionIDFromContext reports the history/lock key for the current turn.
func SessionRoute ¶ added in v0.3.1
SessionRoute builds a minimal session-kind route from a delivery id string.
func SessionRouteFromDelivery ¶ added in v0.2.1
func SessionRouteFromDelivery(platform string, delivery agentkit.SessionID, replyTo string) agentkit.RouteRef
SessionRouteFromDelivery builds a session route from a delivery SessionID.
func SlackSessionID ¶
SlackSessionID builds a stable session key from Slack channel and optional thread timestamp. Use threadTS from event.ThreadTimeStamp; for top-level channel messages pass "".
func SlackSessionIDForScope ¶
func SlackSessionIDForScope(scope SessionScope, channelID, threadTS, userID string) agentkit.SessionID
SlackSessionIDForScope builds the effective session id for Slack components. Prefer ApplyScope(BuildDeliverySessionID(...), scope, userID) in new code; this helper remains for tests and direct agent invocations.
func StepCount ¶
func StepCount(events []agentkit.SessionEvent, seq agentkit.EventSeq) int
StepCount counts the steps completed after seq.
func SumLogicalCharsFromEvents ¶ added in v0.1.12
func SumLogicalCharsFromEvents(events []agentkit.SessionEvent, agentID agentkit.AgentID) int
SumLogicalCharsFromEvents totals logical message size for compaction estimates.
func SyncMessageEvent ¶ added in v0.2.1
func SyncMessageEvent(event agentkit.MessageEvent, env agentkit.TurnEnvelope) agentkit.MessageEvent
SyncMessageEvent copies resolved envelope fields onto an inbound message.
func TrimCompacted ¶ added in v0.1.9
TrimCompacted drops model-visible history superseded by a compaction marker.
func TruncateToolResult ¶ added in v0.2.2
func TruncateToolResult(result agentkit.ToolResult, maxBytes int) agentkit.ToolResult
TruncateToolResult truncates oversized tool result content after execution.
func UserIDFromContext ¶ added in v0.2.1
UserIDFromContext reports the end-user id for the current turn.
func WithAgentID ¶ added in v0.2.1
WithAgentID returns ctx with an updated envelope agent id.
func WithContextMetadata ¶ added in v0.3.1
WithContextMetadata merges metadata onto the turn envelope.
func WithConversation ¶ added in v0.2.1
WithConversation returns ctx with an updated envelope conversation.
func WithMetadataScope ¶ added in v0.2.2
func WithMetadataScope(env agentkit.TurnEnvelope, scope SessionScope) agentkit.TurnEnvelope
WithMetadataScope stamps session scope onto envelope metadata for /new entry-key resolution.
func WithWorkspace ¶ added in v0.2.1
WithWorkspace returns ctx with an updated envelope workspace.
func WorkspaceDirName ¶ added in v0.2.1
WorkspaceDirName maps a workspace key to a single safe path segment.
func WorkspaceFromContext ¶ added in v0.2.1
WorkspaceFromContext reports the tenant workspace key for the current turn. Runner should set TurnEnvelope.Workspace explicitly; fallback derivation logs a warning.
func WorkspaceKey ¶ added in v0.2.1
WorkspaceKey derives the workspace isolation key from an opaque SessionID. Routable IM-style ids collapse to platform:channel; non-routable ids keep platform plus the first segment after the platform prefix.
func WorkspaceLocalDirName ¶ added in v0.2.1
WorkspaceLocalDirName maps a workspace key to a single safe path segment under localBase. When omitPlatform is true, only the first routing segment is used.
Types ¶
type ActiveEntryMode ¶ added in v0.2.1
type ActiveEntryMode string
ActiveEntryMode selects which key active-session mapping uses.
const ( ActiveEntryEffective ActiveEntryMode = "effective" ActiveEntryDelivery ActiveEntryMode = "delivery" )
type ActiveSessionData ¶ added in v0.1.6
type AgentBindData ¶ added in v0.1.6
AgentBindData is stored in each session work dir as agent.json.
type AutoRetryEndData ¶
type AutoRetryStartData ¶
type Commands ¶ added in v0.2.2
type Commands struct {
// contains filtered or unexported fields
}
Commands contributes session lifecycle slash commands (/new, /session).
type CommandsConfig ¶ added in v0.2.2
type CommandsConfig struct{}
type CommandsDeps ¶ added in v0.2.2
type CommandsDeps struct {
SessionStore agentkit.SessionStore `json:"sessionStore"`
}
type DeliveryParts ¶ added in v0.1.5
type DeliveryParts struct {
Platform string
Channel string
Thread string
User string
Routable bool
}
DeliveryParts holds parsed segments of a platform delivery SessionID.
func ParseDelivery ¶ added in v0.1.5
func ParseDelivery(id agentkit.SessionID, fallbackUser string) DeliveryParts
ParseDelivery splits a delivery SessionID into routing segments.
type FileBacked ¶
type FileBacked interface {
FilePath() string
}
FileBacked is implemented by sessions that persist to a file path.
type IncompleteTurn ¶
type IncompleteTurn struct {
TurnStartSeq agentkit.EventSeq
AgentID agentkit.AgentID
StepsStarted int
StepsEnded int
// OpenStep is the index of a step/start with no step/end, or -1 when the
// last step closed cleanly.
OpenStep int
// OrphanCalls are tool calls in the derived history that no tool result
// answers. Left alone they make the history unusable: providers reject an
// assistant message whose tool calls have no replies.
OrphanCalls []agentkit.ToolCall
}
IncompleteTurn describes a turn that never reached turn/end, which is what a crash, SIGKILL, or power loss leaves behind.
func ScanIncomplete ¶
func ScanIncomplete(events []agentkit.SessionEvent) *IncompleteTurn
ScanIncomplete reports the trailing unterminated turn, or nil when the log ends cleanly. Only the last turn can be incomplete: every earlier turn either wrote turn/end or was repaired on a previous startup.
type IndexedMessage ¶ added in v0.1.9
type IndexedMessage = compaction.IndexedMessage
IndexedMessage is a model-visible message with its primary source event seq.
func IndexMessagesForCompaction ¶ added in v0.1.9
func IndexMessagesForCompaction(ctx context.Context, events []agentkit.SessionEvent) []IndexedMessage
IndexMessagesForCompaction rebuilds the model-visible list used for compaction, including the latest compaction summary and retained tail when present.
type JSONL ¶
type JSONL struct {
// contains filtered or unexported fields
}
JSONL persists session events as append-only JSON lines.
func (*JSONL) DeriveMessages ¶
type JSONLConfig ¶
type JSONLConfig struct {
// Path is the log file itself, not a directory.
Path string `json:"path"`
// ID is fixed session id.
ID agentkit.SessionID `json:"id"`
// MaxLoadedEvents limits non-compaction events kept in memory on load. Zero loads the full file.
MaxLoadedEvents int `json:"maxLoadedEvents"`
}
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
Memory is an in-memory session backend for tests and ephemeral runs.
func (*Memory) DeriveMessages ¶
type MemoryConfig ¶
type OverflowRecoveryData ¶
type PlatformSessionPolicy ¶ added in v0.2.1
type PlatformSessionPolicy struct {
ActiveEntryMode ActiveEntryMode
}
PlatformSessionPolicy holds per-platform routing overrides applied on top of runner defaults.
func PlatformSessionPolicyFor ¶ added in v0.2.1
func PlatformSessionPolicyFor(platform string) PlatformSessionPolicy
PlatformSessionPolicyFor returns overrides for a platform, or zero when unset.
type RecoveryData ¶
type RecoveryData struct {
TurnStartSeq agentkit.EventSeq `json:"turnStartSeq"`
Steps int `json:"steps"`
OrphanResults int `json:"orphanResults"`
ClosedStep int `json:"closedStep"`
Reason string `json:"reason"`
}
RecoveryData is the audit payload of a session/recovery event.
func RepairIncomplete ¶
func RepairIncomplete(ctx context.Context, s agentkit.Session, turn *IncompleteTurn) (RecoveryData, error)
RepairIncomplete makes an interrupted turn replayable and closes it: it answers every orphan tool call, ends the open step, writes turn/end, then records a session/recovery event for audit.
type RoutePolicy ¶ added in v0.2.1
type RoutePolicy struct {
ConversationScope SessionScope
ActiveEntryMode ActiveEntryMode
}
RoutePolicy configures how inbound routes map to conversation and workspace.
func DefaultRoutePolicy ¶ added in v0.2.1
func DefaultRoutePolicy(conversationScope SessionScope) RoutePolicy
DefaultRoutePolicy is runner's default: channel conversation and workspace.
func RoutePolicyForPlatform ¶ added in v0.2.1
func RoutePolicyForPlatform(platform string, base RoutePolicy) RoutePolicy
RoutePolicyForPlatform merges runner defaults with platform-specific overrides.
type RouteTarget ¶ added in v0.2.1
type RouteTarget struct {
DeliveryID agentkit.SessionID
ChannelID string
ThreadID string
ReplyTo string
ScopeUserID string
}
RouteTarget is the decoded delivery target for a session-kind route.
func RouteTargetFromRoute ¶ added in v0.2.1
func RouteTargetFromRoute(route agentkit.RouteRef) (RouteTarget, bool)
RouteTargetFromRoute decodes structured delivery fields from a session route.
type RunFinishData ¶
type RunFinishData struct {
Status string `json:"status"`
Summary string `json:"summary,omitempty"`
}
RunFinishData is the payload of an EventRunFinish event.
func FinishAfter ¶
func FinishAfter(events []agentkit.SessionEvent, seq agentkit.EventSeq) *RunFinishData
FinishAfter returns the run/finish event recorded after seq, or nil.
type RunState ¶ added in v0.2.1
type RunState struct {
StartSeq agentkit.EventSeq
Todos []Todo
Pending []Todo
Finish *RunFinishData
Repeats int
Usage UsageData
Context int
}
RunState is a snapshot of autonomous-run signals from the session log.
func LoadRunState ¶ added in v0.2.1
func LoadRunState(ctx context.Context, store agentkit.SessionStore, sessionID agentkit.SessionID) (RunState, error)
LoadRunState reads autonomous-run signals for the given session.
type SessionRouteInput ¶ added in v0.2.1
type SessionRouteInput = agentkit.SessionRouteInput
SessionRouteInput carries structured session-kind route fields.
type SessionScope ¶
type SessionScope = agentkit.SessionScope
SessionScope selects how delivery SessionIDs collapse for Loop scheduling and session history.
func ParseScope ¶ added in v0.1.3
func ParseScope(raw string) SessionScope
ParseScope normalizes runner config. Unknown values fall back to channel scope.
func SessionScopeFromContext ¶ added in v0.2.2
func SessionScopeFromContext(ctx context.Context) SessionScope
SessionScopeFromContext reads the runner/platform session scope from envelope metadata.
type StaticConfig ¶
type StaticConfig struct{}
type StaticDeps ¶
type StaticStore ¶
type StaticStore struct {
// contains filtered or unexported fields
}
StaticStore returns one Session for matching IDs. Useful for CLI presets and tests where a single session instance is wired through pluginkit.
func NewStaticStore ¶
func NewStaticStore(sess agentkit.Session) *StaticStore
func (*StaticStore) ActiveSession ¶ added in v0.1.6
func (*StaticStore) SetActiveSession ¶ added in v0.1.6
func (*StaticStore) SetAgentBind ¶ added in v0.1.6
type StepEndData ¶
type StepEndData struct {
Step int `json:"step"`
}
type StepStartData ¶
type StepStartData struct {
Step int `json:"step"`
}
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store opens one JSONL session file per SessionID under Dir. Suitable for IM platforms where each channel/thread maps to a distinct session.
func (*Store) ActiveSession ¶ added in v0.1.6
func (*Store) SetActiveSession ¶ added in v0.1.6
type StoreConfig ¶
type StoreConfig struct {
// Dir is root directory holding one file per session, resolved through the workspace.
Dir string `json:"dir"`
// MaxCachedSessions limits in-memory hot sessions (LRU). Zero keeps every opened session cached.
MaxCachedSessions int `json:"maxCachedSessions"`
// CacheIdleTTL evicts sessions unused for this duration (for example "30m"). Empty disables idle eviction.
CacheIdleTTL string `json:"cacheIdleTTL"`
// MaxLoadedEvents limits non-compaction events kept in memory per session on load. Zero loads the full file.
MaxLoadedEvents int `json:"maxLoadedEvents"`
}
type SubagentEndData ¶
type SubagentEndData struct {
Agent string `json:"agent"`
Session string `json:"session"`
Status string `json:"status"`
Summary string `json:"summary,omitempty"`
Steps int `json:"steps"`
Error string `json:"error,omitempty"`
JobID string `json:"jobId,omitempty"`
}
SubagentEndData records the outcome of a delegation. Summary duplicates what the model sees in the tool result, on purpose: reading the parent log alone should be enough to reconstruct what came back.
type SubagentStartData ¶
type SubagentStartData struct {
Agent string `json:"agent"`
Session string `json:"session"`
Task string `json:"task"`
Async bool `json:"async,omitempty"`
JobID string `json:"jobId,omitempty"`
}
SubagentStartData records a delegation on the *parent* session. The child's own work lives in its own session; these two events are the audit trail linking the two logs together.
type Todo ¶
type Todo struct {
ID string `json:"id"`
Title string `json:"title"`
Status string `json:"status"`
}
Todo is one entry of the durable task list written by tool/todo.
func LatestTodos ¶
func LatestTodos(events []agentkit.SessionEvent) []Todo
LatestTodos returns the task list from the most recent todo/update event.
func PendingTodos ¶
PendingTodos filters LatestTodos down to entries that still need work.
type TodoUpdateData ¶
type TodoUpdateData struct {
Items []Todo `json:"items"`
}
TodoUpdateData is the payload of an EventTodoUpdate event.
type TurnContinueData ¶
type TurnContinueData struct {
Segment int `json:"segment"`
Reason string `json:"reason"`
Steps int `json:"steps"`
Messages []agentkit.ModelMessage `json:"messages,omitempty"`
}
TurnContinueData records one autonomous turn extension.
type TurnEndData ¶
type TurnStartData ¶
type TurnStartData struct{}
type UsageData ¶
type UsageData struct {
InputTokens int `json:"inputTokens"`
OutputTokens int `json:"outputTokens"`
TotalTokens int `json:"totalTokens"`
}
UsageData records token accounting for one model step.
func LatestUsage ¶
func LatestUsage(events []agentkit.SessionEvent) UsageData
LatestUsage returns the most recent usage event.
func TotalUsage ¶
func TotalUsage(events []agentkit.SessionEvent, seq agentkit.EventSeq) UsageData
TotalUsage sums usage events recorded after seq.
Source Files
¶
- active_key.go
- active_resolve.go
- agent.go
- channel.go
- commands_plugin.go
- conversation.go
- delivery.go
- derive.go
- envelope.go
- hydrate.go
- id.go
- jsonl.go
- jsonl_load.go
- layout.go
- lifecycle.go
- logical_chars.go
- memory.go
- memory_window.go
- metadata.go
- path.go
- platform_policy.go
- policy.go
- prune.go
- recovery.go
- register.go
- route.go
- router.go
- runstate.go
- sanitize.go
- scope.go
- sidecar.go
- skill_render.go
- static.go
- store.go
- store_bind.go
- store_cache.go
- subagent.go
- types.go
- workspace_key.go