Documentation
¶
Overview ¶
Package rocketcode provides the reusable RocketCode runtime.
Index ¶
- Constants
- func BashPermissionSubjects(command string) []string
- func CompactedOutputToReplayInput(items []responses.ResponseOutputItemUnion) ([]json.RawMessage, error)
- func CompactionCheckpointText(compaction *responses.ResponseCompactionItemParam) string
- func DiscardChildRunLog(*ChildRunEvent)
- func LoadWorkspaceDefinitions(root *os.Root) (Agents, Skills, func(), error)
- func RecoveredReplayInput(checkpoint *ActiveTurnCheckpoint) ([]json.RawMessage, error)
- func ReplayInputFromParams(items []responses.ResponseInputItemUnionParam) ([]json.RawMessage, error)
- func ReplayInputToParams(raw []json.RawMessage) ([]responses.ResponseInputItemUnionParam, error)
- func SplitPromptAttachmentTokens(text string) (prompt string, files []string, err error)
- type ActiveTurnCheckpoint
- type Agent
- type AgentLoadResult
- type AgentMaxRecursionError
- type Agents
- type Attachment
- type BashCommand
- type BashResult
- type ChatResponse
- type CheckpointSink
- type ChildRunEvent
- type ChildRunKind
- type ChildRunLogger
- type ChildRunStage
- type Config
- type FunctionCallCheckpoint
- type FunctionOutputCheckpoint
- type InertCheckpointSink
- func (InertCheckpointSink) ClearCompletedTurn(context.Context, string) error
- func (InertCheckpointSink) RecordCompletedToolOutput(context.Context, *ActiveTurnCheckpoint) error
- func (InertCheckpointSink) RecordProviderResponse(context.Context, *ActiveTurnCheckpoint) error
- func (InertCheckpointSink) RecordRecoveredReplay(context.Context, *ActiveTurnCheckpoint) error
- func (InertCheckpointSink) StartActiveTurn(context.Context, *ActiveTurnCheckpoint) error
- type Looper
- type ObservabilityConfig
- type Operation
- type OperationError
- type PermissionAction
- type PermissionBucket
- type PermissionRule
- type PermissionSet
- func (ps *PermissionSet) Allow(permission, pattern string) error
- func (ps *PermissionSet) Deny(permission, pattern string) error
- func (ps PermissionSet) Evaluate(permission, subject string) (action PermissionAction, matched bool)
- func (ps *PermissionSet) Set(permission, pattern string, action PermissionAction) error
- type PromptInput
- type PromptInputDirectSkill
- type PromptInputRole
- type PromptShellCommandExpansion
- type ProviderDiagnostic
- type Providers
- type ReplayDecodeError
- type Runtime
- type SessionEntry
- type Skill
- type SkillLoadResult
- type Skills
- type SubagentDiagnostic
- type TokenUsage
- type Tool
- type ToolDiagnostic
- type ToolResult
Constants ¶
const ( // ChatResponseAssistantMessage identifies final assistant message output. ChatResponseAssistantMessage = "assistant_message" // ChatResponseAssistantCommentary identifies assistant progress/commentary output. ChatResponseAssistantCommentary = "assistant_commentary" // ChatResponseAssistantTool identifies structured tool and subagent diagnostics. ChatResponseAssistantTool = "assistant_tool" // ChatResponseReasoningSummary identifies reasoning summary output. ChatResponseReasoningSummary = "reasoning_summary" )
Variables ¶
This section is empty.
Functions ¶
func BashPermissionSubjects ¶ added in v0.0.7
BashPermissionSubjects returns the subjects checked by the bash tool for command.
func CompactedOutputToReplayInput ¶ added in v0.0.16
func CompactedOutputToReplayInput(items []responses.ResponseOutputItemUnion) ([]json.RawMessage, error)
CompactedOutputToReplayInput converts provider compaction output into durable replay input.
func CompactionCheckpointText ¶ added in v0.0.16
func CompactionCheckpointText(compaction *responses.ResponseCompactionItemParam) string
CompactionCheckpointText returns portable text for compaction replay that cannot be rehydrated natively.
func DiscardChildRunLog ¶ added in v0.0.20
func DiscardChildRunLog(*ChildRunEvent)
DiscardChildRunLog ignores hidden child-run output.
func LoadWorkspaceDefinitions ¶ added in v0.0.7
LoadWorkspaceDefinitions loads top-level workspace agents and recursive skills.
func RecoveredReplayInput ¶ added in v0.0.29
func RecoveredReplayInput(checkpoint *ActiveTurnCheckpoint) ([]json.RawMessage, error)
RecoveredReplayInput converts an interrupted active-turn checkpoint into replay input for a recovered model turn.
func ReplayInputFromParams ¶
func ReplayInputFromParams(items []responses.ResponseInputItemUnionParam) ([]json.RawMessage, error)
ReplayInputFromParams returns SDK-native durable replay JSON after each item round-trips through responses.ResponseInputItemUnionParam.
func ReplayInputToParams ¶
func ReplayInputToParams(raw []json.RawMessage) ([]responses.ResponseInputItemUnionParam, error)
ReplayInputToParams decodes SDK-native durable replay JSON through the OpenAI SDK input union.
Types ¶
type ActiveTurnCheckpoint ¶ added in v0.0.29
type ActiveTurnCheckpoint struct {
TurnID string `json:"turn_id"`
ConversationKey string `json:"conversation_key"`
Agent string `json:"agent"`
Model string `json:"model"`
DisplayModel string `json:"display_model"`
ReplayInput []json.RawMessage `json:"replay_input,omitempty"`
OutputTrace []json.RawMessage `json:"output_trace,omitempty"`
TokenUsage *TokenUsage `json:"token_usage,omitempty"`
ResponseID string `json:"response_id,omitempty"`
OpenFunctionCalls []FunctionCallCheckpoint `json:"open_function_calls,omitempty"`
CompletedFunctionOutputs []FunctionOutputCheckpoint `json:"completed_function_outputs,omitempty"`
}
ActiveTurnCheckpoint is RocketCode's durable, embedder-neutral checkpoint for one root turn.
type Agent ¶
type Agent struct {
Name string
Description string
Model string
ReasoningEffort string
Verbosity string
MaxRecursion *int
Guardrail string
Prompt string
Location string
Permission PermissionSet
Frontmatter map[string]any
FileMode fs.FileMode
}
Agent contains a single preloaded markdown agent definition.
type AgentLoadResult ¶
AgentLoadResult contains loaded agents and any non-fatal load errors.
func LoadAgents ¶
func LoadAgents(fsys fs.FS) AgentLoadResult
LoadAgents scans the top level of fsys for markdown agent files.
type AgentMaxRecursionError ¶ added in v0.0.7
AgentMaxRecursionError reports invalid maxRecursion frontmatter.
func (*AgentMaxRecursionError) Error ¶ added in v0.0.7
func (e *AgentMaxRecursionError) Error() string
func (*AgentMaxRecursionError) Unwrap ¶ added in v0.0.7
func (e *AgentMaxRecursionError) Unwrap() error
type Attachment ¶
type Attachment struct {
MIME string `json:"mime"`
Filename string `json:"filename,omitempty"`
URL string `json:"url"`
}
Attachment is a model-visible file attachment encoded as a URL, usually a data URL.
func PromptAttachments ¶ added in v0.0.7
PromptAttachments loads prompt attachments from workspace-local files.
type BashCommand ¶ added in v0.0.7
BashCommand is the public shape of the workspace bash tool input.
type BashResult ¶ added in v0.0.7
BashResult is the result of running a workspace bash command.
type ChatResponse ¶
type ChatResponse struct {
Kind string
Text string
Tool *ToolDiagnostic
Subagent *SubagentDiagnostic
Provider *ProviderDiagnostic
}
ChatResponse is one user-visible response item emitted by the runtime.
type CheckpointSink ¶ added in v0.0.29
type CheckpointSink interface {
StartActiveTurn(context.Context, *ActiveTurnCheckpoint) error
RecordProviderResponse(context.Context, *ActiveTurnCheckpoint) error
RecordCompletedToolOutput(context.Context, *ActiveTurnCheckpoint) error
RecordRecoveredReplay(context.Context, *ActiveTurnCheckpoint) error
ClearCompletedTurn(context.Context, string) error
}
CheckpointSink persists active root-turn lifecycle checkpoints for embedders.
type ChildRunEvent ¶ added in v0.0.20
type ChildRunEvent struct {
Kind ChildRunKind
Stage ChildRunStage
Agent string
Item ChatResponse
}
ChildRunEvent contains server/operator-only hidden child-run output.
type ChildRunKind ¶ added in v0.0.20
type ChildRunKind string
ChildRunKind identifies a hidden child-run category.
const ( // ChildRunKindGuardrail identifies an inter-agent guardrail child run. ChildRunKindGuardrail ChildRunKind = "guardrail" // ChildRunKindPermissionReview identifies an automatic permission reviewer child run. ChildRunKindPermissionReview ChildRunKind = "permission_review" )
type ChildRunLogger ¶ added in v0.0.20
type ChildRunLogger func(*ChildRunEvent)
ChildRunLogger consumes server/operator-only hidden child-run output.
type ChildRunStage ¶ added in v0.0.20
type ChildRunStage string
ChildRunStage identifies the operation being reviewed by a hidden child run.
const ( // ChildRunStageDelegation identifies guardrail review before delegation. ChildRunStageDelegation ChildRunStage = "delegation" // ChildRunStageResponse identifies guardrail review after a child response. ChildRunStageResponse ChildRunStage = "response" // ChildRunStageToolPermission identifies automatic tool permission review. ChildRunStageToolPermission ChildRunStage = "tool_permission" )
type Config ¶
type Config struct {
Model shared.ResponsesModel
AutoApproverModel shared.ResponsesModel
ReasoningEffort shared.ReasoningEffort
Diagnostics bool
ExperimentalStrongerSkills bool
ExpandPromptShellCommands PromptShellCommandExpansion
CompactThreshold int64
CompactionSteering string
ParallelToolCalls int
ShellOutputDir string
SandboxedBash bool
AutoApprovePermissions bool
Observability ObservabilityConfig
ChildRunLogger ChildRunLogger
CheckpointSink CheckpointSink
CustomTools []Tool
ShellEnv map[string]string
}
Config contains runtime settings supplied by the embedding application.
func StandaloneConfigFromEnv ¶ added in v0.0.7
StandaloneConfigFromEnv returns the shared default config for RocketCode commands.
type FunctionCallCheckpoint ¶ added in v0.0.29
type FunctionCallCheckpoint struct {
CallID string `json:"call_id"`
Name string `json:"name"`
Arguments json.RawMessage `json:"arguments,omitempty"`
}
FunctionCallCheckpoint contains replay-safe data for a model-emitted function call.
type FunctionOutputCheckpoint ¶ added in v0.0.29
type FunctionOutputCheckpoint struct {
CallID string `json:"call_id"`
Name string `json:"name,omitempty"`
ReplayInput []json.RawMessage `json:"replay_input,omitempty"`
}
FunctionOutputCheckpoint contains replay-safe data for a completed function-call output.
type InertCheckpointSink ¶ added in v0.0.29
type InertCheckpointSink struct{}
InertCheckpointSink ignores active root-turn lifecycle checkpoints.
func (InertCheckpointSink) ClearCompletedTurn ¶ added in v0.0.29
func (InertCheckpointSink) ClearCompletedTurn(context.Context, string) error
ClearCompletedTurn ignores completed-turn checkpoint cleanup.
func (InertCheckpointSink) RecordCompletedToolOutput ¶ added in v0.0.29
func (InertCheckpointSink) RecordCompletedToolOutput(context.Context, *ActiveTurnCheckpoint) error
RecordCompletedToolOutput ignores a completed tool-output checkpoint.
func (InertCheckpointSink) RecordProviderResponse ¶ added in v0.0.29
func (InertCheckpointSink) RecordProviderResponse(context.Context, *ActiveTurnCheckpoint) error
RecordProviderResponse ignores a provider response checkpoint.
func (InertCheckpointSink) RecordRecoveredReplay ¶ added in v0.0.29
func (InertCheckpointSink) RecordRecoveredReplay(context.Context, *ActiveTurnCheckpoint) error
RecordRecoveredReplay ignores a recovered replay checkpoint.
func (InertCheckpointSink) StartActiveTurn ¶ added in v0.0.29
func (InertCheckpointSink) StartActiveTurn(context.Context, *ActiveTurnCheckpoint) error
StartActiveTurn ignores an active-turn start checkpoint.
type Looper ¶
type Looper interface {
Loop(ctx context.Context, input <-chan PromptInput, sessionIn iter.Seq2[SessionEntry, error], sessionOut func(SessionEntry) error, interrupts <-chan os.Signal) error
}
Looper processes prompt input streams with a configured runtime.
type ObservabilityConfig ¶ added in v0.0.12
type ObservabilityConfig struct {
Enabled bool
Tracer trace.Tracer
TraceConfig instrumentation.TraceConfig
}
ObservabilityConfig controls OpenInference-compatible tracing for RocketCode.
type Operation ¶ added in v0.0.7
type Operation string
Operation identifies a high-level command/runtime operation.
const ( // OperationLoadConfig identifies standalone config loading. OperationLoadConfig Operation = "load config" // OperationLoadWorkspaceDefinitions identifies workspace-local agent/skill loading. OperationLoadWorkspaceDefinitions Operation = "load workspace definitions" // OperationParsePromptAttachments identifies prompt attachment token parsing. OperationParsePromptAttachments Operation = "parse prompt attachments" // OperationLoadPromptAttachments identifies workspace prompt attachment loading. OperationLoadPromptAttachments Operation = "load prompt attachments" )
type OperationError ¶ added in v0.0.7
OperationError adds typed operation context while preserving the wrapped error.
func (OperationError) Error ¶ added in v0.0.7
func (e OperationError) Error() string
func (OperationError) Unwrap ¶ added in v0.0.7
func (e OperationError) Unwrap() error
type PermissionAction ¶
type PermissionAction string
PermissionAction determines whether a matched operation is allowed or denied.
const ( // PermissionAllow allows a matching operation. PermissionAllow PermissionAction = "allow" // PermissionDeny denies a matching operation. PermissionDeny PermissionAction = "deny" // PermissionAuto requires automatic reviewer approval for a matching operation. PermissionAuto PermissionAction = "auto" )
type PermissionBucket ¶
type PermissionBucket struct {
Name string
Rules []PermissionRule
}
PermissionBucket groups permission rules under a named permission category.
type PermissionRule ¶
type PermissionRule struct {
Pattern string
Action PermissionAction
Reviewer string
}
PermissionRule matches a subject pattern to a permission action.
type PermissionSet ¶
type PermissionSet struct {
Buckets []PermissionBucket
}
PermissionSet contains all permission buckets configured for an agent.
func (*PermissionSet) Allow ¶
func (ps *PermissionSet) Allow(permission, pattern string) error
Allow appends an allow rule for permission and pattern.
func (*PermissionSet) Deny ¶
func (ps *PermissionSet) Deny(permission, pattern string) error
Deny appends a deny rule for permission and pattern.
func (PermissionSet) Evaluate ¶
func (ps PermissionSet) Evaluate(permission, subject string) (action PermissionAction, matched bool)
Evaluate returns the effective permission action for permission and subject. The matched result reports whether a configured rule explicitly matched. When matched is false, action is PermissionDeny, the default action.
func (*PermissionSet) Set ¶
func (ps *PermissionSet) Set(permission, pattern string, action PermissionAction) error
Set appends a permission rule for permission and pattern.
type PromptInput ¶
type PromptInput struct {
// Role defaults to PromptInputRoleUser when empty.
Role PromptInputRole `json:"role,omitempty"`
Text string `json:"text"`
Attachments []Attachment `json:"attachments,omitempty"`
DirectSkill *PromptInputDirectSkill `json:"directSkill,omitempty"`
// Responses receives user-visible response items for this prompt. The runtime
// closes it after the prompt's turn reaches a terminal state.
Responses chan<- ChatResponse `json:"-"`
}
PromptInput is one prompt plus optional model-visible attachments.
type PromptInputDirectSkill ¶ added in v0.0.24
type PromptInputDirectSkill struct {
Name string `json:"name"`
Arguments string `json:"arguments,omitempty"`
}
PromptInputDirectSkill requests a skill load before the model turn starts.
type PromptInputRole ¶
type PromptInputRole string
PromptInputRole identifies the instruction hierarchy role for a prompt input.
const ( // PromptInputRoleUser identifies ordinary user prompt input. PromptInputRoleUser PromptInputRole = "user" // PromptInputRoleDeveloper identifies developer instruction prompt input. PromptInputRoleDeveloper PromptInputRole = "developer" )
type PromptShellCommandExpansion ¶
type PromptShellCommandExpansion struct {
PrimaryPrompts bool
SubagentPrompts bool
SkillPrompts bool
InputPrompts bool
}
PromptShellCommandExpansion controls which prompt sources expand !`command` snippets.
type ProviderDiagnostic ¶
type ProviderDiagnostic struct {
Phase string `json:"phase"`
HTTPStatus int `json:"http_status,omitempty"`
ResponseStatus string `json:"response_status,omitempty"`
Code string `json:"code,omitempty"`
Type string `json:"type,omitempty"`
Message string `json:"message,omitempty"`
Attempt int `json:"attempt,omitempty"`
RetryAfter string `json:"retry_after,omitempty"`
ResponseID string `json:"response_id,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
}
ProviderDiagnostic describes provider request diagnostics emitted when diagnostics are enabled.
type Providers ¶ added in v0.0.7
Providers contains model provider clients supplied by embedding applications.
func StandaloneProvidersFromEnv ¶ added in v0.0.7
StandaloneProvidersFromEnv returns model provider clients for RocketCode commands.
type ReplayDecodeError ¶
ReplayDecodeError describes one durable replay item that could not be decoded through the OpenAI SDK input union.
func (*ReplayDecodeError) Error ¶
func (e *ReplayDecodeError) Error() string
func (*ReplayDecodeError) Unwrap ¶
func (e *ReplayDecodeError) Unwrap() error
type Runtime ¶ added in v0.0.7
type Runtime = looper
Runtime is the concrete RocketCode loop runtime returned by New.
func New ¶
func New( client *openai.Client, configInput *Config, root *os.Root, agents Agents, skills Skills, defaultAgent string, diagnosticsWriter io.Writer, ) (*Runtime, error)
New loads the supplied runtime dependencies and returns a configured looper.
func NewWithProviders ¶ added in v0.0.7
func NewWithProviders( providers Providers, configInput *Config, root *os.Root, agents Agents, skills Skills, defaultAgent string, diagnosticsWriter io.Writer, ) (*Runtime, error)
NewWithProviders loads the supplied runtime dependencies and returns a configured looper.
type SessionEntry ¶
type SessionEntry struct {
Version int `json:"version"`
Type string `json:"type"`
Timestamp time.Time `json:"timestamp"`
ResponseID string `json:"response_id,omitempty"`
Model string `json:"model,omitempty"`
TokenUsage *TokenUsage `json:"token_usage,omitempty"`
ReplayInput []json.RawMessage `json:"replay_input,omitempty"`
OutputTrace []json.RawMessage `json:"output_trace,omitempty"`
}
SessionEntry is one denormalized persisted session record.
type Skill ¶
type Skill struct {
Name string
Description string
License string
Compatibility string
Metadata map[string]any
Location string
Content string
}
Skill contains a single preloaded skill definition.
type SkillLoadResult ¶
SkillLoadResult contains loaded skills and any non-fatal load errors.
func LoadSkills ¶
func LoadSkills(fsys fs.FS, root string) SkillLoadResult
LoadSkills scans fsys for SKILL.md files and preloads valid skills.
type Skills ¶
type Skills struct {
Root string
Items map[string]Skill
Dirs []string
// contains filtered or unexported fields
}
Skills contains all discovered skills keyed by name.
type SubagentDiagnostic ¶
type SubagentDiagnostic struct {
Name string `json:"name"`
Label string `json:"label"`
Index int `json:"index,omitempty"`
Total int `json:"total,omitempty"`
Text string `json:"text,omitempty"`
Tool *ToolDiagnostic `json:"tool,omitempty"`
Subagent *SubagentDiagnostic `json:"subagent,omitempty"`
Provider *ProviderDiagnostic `json:"provider,omitempty"`
}
SubagentDiagnostic describes a subagent runtime diagnostic emitted when diagnostics are enabled.
type TokenUsage ¶ added in v0.0.13
type TokenUsage struct {
PromptTokens int64 `json:"prompt_tokens,omitempty"`
CompletionTokens int64 `json:"completion_tokens,omitempty"`
TotalTokens int64 `json:"total_tokens,omitempty"`
PromptCacheReadTokens int64 `json:"prompt_cache_read_tokens,omitempty"`
PromptCacheWriteTokens int64 `json:"prompt_cache_write_tokens,omitempty"`
CompletionReasoningTokens int64 `json:"completion_reasoning_tokens,omitempty"`
}
TokenUsage records replay-neutral provider token counts for a completed turn.
type Tool ¶
type Tool struct {
Name string
Description string
Parameters map[string]any
Permission string
VisibilitySubjects []string
Subjects func(json.RawMessage) ([]string, error)
Call func(context.Context, json.RawMessage, chan<- ChatResponse) (ToolResult, error)
}
Tool is a custom function tool supplied by an embedding application.
type ToolDiagnostic ¶
type ToolDiagnostic struct {
Phase string `json:"phase"`
Name string `json:"name"`
Arguments json.RawMessage `json:"arguments,omitempty"`
Result string `json:"result,omitempty"`
Status string `json:"status,omitempty"`
Action json.RawMessage `json:"action,omitempty"`
}
ToolDiagnostic describes a tool runtime diagnostic emitted when diagnostics are enabled.
type ToolResult ¶
type ToolResult struct {
Output string
Attachments []Attachment
}
ToolResult is the output of a tool call, including optional model-visible attachments.
func TextToolResult ¶
func TextToolResult(output string) ToolResult
TextToolResult returns a text-only tool result.