Documentation
¶
Index ¶
- Constants
- func CloseRuntime() error
- func Invoke(root, sessionID, name string, args []string, cwd string) (invocationResult, error)
- func InvokeContext(ctx context.Context, root, sessionID, name string, args []string, cwd string) (invocationResult, error)
- func MatchResponse(response models.CommandMockResponse, args []string, cwd, workspace string) (bool, error)
- func ResponseOutput(response models.CommandMockResponse, baseDir string) ([]byte, error)
- func RunCommand(root, name string, args []string) (int, error)
- func RunCommandContext(ctx context.Context, root, name string, args []string) (int, error)
- func RunNativeCommand(ctx context.Context, root, sessionID, name string, args []string, cwd string, ...) (exitCode int, resultErr error)
- func RuntimeEnvironment() ([]string, error)
- type NativeDispatch
- type NativeDispatchOptions
- type NativeDispatchRequest
- type NativeOutput
- type NativePrepare
- type NativePrepareRequest
- type Session
Constants ¶
const (
SessionEnvironmentVariable = "WAZA_COMMAND_MOCK_SESSION"
)
Variables ¶
This section is empty.
Functions ¶
func CloseRuntime ¶
func CloseRuntime() error
CloseRuntime removes the temporary shim registry after the Copilot runtime has stopped.
func Invoke ¶
Invoke chooses the first matching response for the task session. The cwd fallback supports callers without an explicit session ID.
func InvokeContext ¶ added in v0.39.0
func MatchResponse ¶ added in v0.39.0
func MatchResponse(response models.CommandMockResponse, args []string, cwd, workspace string) (bool, error)
MatchResponse checks invocation arguments, environment, and working directory using the native command-mock matcher semantics.
func ResponseOutput ¶ added in v0.39.0
func ResponseOutput(response models.CommandMockResponse, baseDir string) ([]byte, error)
ResponseOutput returns fixture bytes, string stdout, or JSON-encoded stdout using the native command-mock output semantics.
func RunCommand ¶
RunCommand is the entry point for the private executable shims.
func RunCommandContext ¶ added in v0.39.0
RunCommandContext returns cancellation separately from an ordinary nonzero exit so callers can avoid diagnostic writes after canceling a backpressured host.
func RunNativeCommand ¶ added in v0.39.0
func RunNativeCommand(ctx context.Context, root, sessionID, name string, args []string, cwd string, options NativeDispatchOptions) (exitCode int, resultErr error)
RunNativeCommand is an opt-in shim entry point. With no private configuration it uses RunCommand unchanged; configured mocks never fall through to the host. Nil writers use the actual process streams.
func RuntimeEnvironment ¶
RuntimeEnvironment returns an environment for the Copilot child process that puts the command-mock shims before, but does not replace, the host PATH.
Types ¶
type NativeDispatch ¶ added in v0.39.0
type NativeDispatch func(context.Context, NativeDispatchRequest, func(NativeOutput) error, func() error) (int, error)
NativeDispatch must call emit and then receipt synchronously, at most once. It owns cancellable I/O; this hook does not install process-signal handlers. Receipt failure after emission must never cause retry, re-emission or rollback.
type NativeDispatchOptions ¶ added in v0.39.0
type NativeDispatchOptions struct {
Dispatch NativeDispatch
Stdout io.Writer
Stderr io.Writer
}
type NativeDispatchRequest ¶ added in v0.39.0
type NativeDispatchRequest struct {
StateDir string
Workspace string
CWD string
Name string
Args []string
Mock json.RawMessage
Configuration json.RawMessage
}
NativeDispatchRequest carries the selected stored mock and opaque preparation result. Neither value is interpreted as a fault schema by commandmock.
type NativeOutput ¶ added in v0.39.0
type NativePrepare ¶ added in v0.39.0
type NativePrepare func(context.Context, NativePrepareRequest) (json.RawMessage, error)
type NativePrepareRequest ¶ added in v0.39.0
type NativePrepareRequest struct {
StateDir string
Workspace string
Mock json.RawMessage
}
NativePrepareRequest contains the typed, serialized baseline mock before normalization, not the retained raw source or a public schema extension. Serialization's omitempty tags lose explicit empty slices and zero values. Callers requiring source presence must retain it separately in a closure or private envelope. Preparation owns any additional private state.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session owns the temporary configuration and invocation history for a task.
func NewNativeSession ¶ added in v0.39.0
func NewNativeSession(ctx context.Context, workspace string, mocks []models.CommandMockConfig, baseDir string, prepare NativePrepare) (_ *Session, resultErr error)
NewNativeSession optionally prepares opaque task-private configuration after the task directory exists, but before baseline responses are materialized. A nil preparation preserves NewSession's legacy configuration and behavior.
func NewSession ¶
func NewSession(workspace string, mocks []models.CommandMockConfig, baseDir string) (*Session, error)
NewSession validates and materializes task-scoped mock config outside the workspace so fixtures and credentials are not captured in workspace snapshots.
func (*Session) Close ¶
func (s *Session) Close() ([]models.CommandInvocation, error)
Close removes task-private configuration and verifies exact call counts.
func (*Session) Invocations ¶
func (s *Session) Invocations() []models.CommandInvocation
Invocations returns sanitized invocation records in chronological order. Legacy records reflect selection, not stream delivery. Close checks private native capture integrity; this legacy accessor cannot report capture errors but omits corrupt or unmatched native receipts.