run

package
v0.0.0-...-d382f1f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Copyright © 2024 ks6088ts

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCommand

func GetCommand() *cobra.Command

GetCommand returns the run command for registration on the root command.

func RunSession

func RunSession(ctx context.Context, opts RunOptions) error

RunSession creates a Copilot session with the given options and streams the assistant response to stdout. It is exported so the serve subcommand can reuse it for background task execution.

func RunSessionCollect

func RunSessionCollect(ctx context.Context, opts RunOptions) (string, error)

RunSessionCollect works like RunSession but captures the full assistant response in a string instead of writing it to stdout. It is used by the serve subcommand to collect task output.

func RunSessionCollectWithEvents

func RunSessionCollectWithEvents(ctx context.Context, opts RunOptions, onProgress func(ProgressEvent)) (string, error)

RunSessionCollectWithEvents works like RunSessionCollect and reports compact progress events to onProgress while the session runs.

Types

type ProgressEvent

type ProgressEvent struct {
	Time       time.Time `json:"time"`
	Type       string    `json:"type"`
	Message    string    `json:"message,omitempty"`
	ToolName   string    `json:"tool_name,omitempty"`
	ToolCallID string    `json:"tool_call_id,omitempty"`
}

ProgressEvent is a normalized session event emitted while a Copilot task is running. It is intentionally small so it can be returned by the serve API.

type RunOptions

type RunOptions struct {
	// Model is the Copilot model identifier (e.g. "gpt-4o"). Uses the default
	// model when empty.
	Model string
	// Prompt is the user message to send.
	Prompt string
	// AgentsFile is the optional path to an agents.md (or any markdown) file
	// whose contents are appended as session instructions.
	AgentsFile string
	// ImagePath is the optional path to an image file attached to the message.
	// The model must support vision for this to have an effect.
	ImagePath string
	// ImagePaths are optional paths to image files attached to the message.
	// The model must support vision for these to have an effect.
	ImagePaths []string
	// FilePaths are optional non-image files attached to the message.
	FilePaths []string
	// CLIURL is the optional Copilot CLI server URL (e.g. "localhost:3000").
	// When empty, the SDK spawns the bundled CLI over stdio.
	CLIURL string
	// Yolo approves every permission request. When false, only read requests are
	// approved automatically.
	Yolo bool
}

RunOptions holds the inputs for RunSession.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL