runagent

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	APIKey  string
	BaseURL string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient core.HTTPContext, ctx core.IntegrationContext) (*Client, error)

func (*Client) AddSessionResource added in v0.26.0

func (c *Client) AddSessionResource(sessionID string, resource FileResource) error

UploadFile uploads a file to the Anthropic Files API and returns its ID. The file can then be mounted into a session via CreateManagedSessionRequest.Resources. AddSessionResource attaches a file resource to an existing session. POST /v1/sessions/{id}/resources

func (*Client) ArchiveAgent added in v0.28.0

func (c *Client) ArchiveAgent(agentID string) error

ArchiveAgent archives an agent so it is no longer usable for new sessions.

func (*Client) CleanupFiles added in v0.26.0

func (c *Client) CleanupFiles(fileIDs []string, logWarn func(string, ...any))

CleanupFiles deletes a list of uploaded files, logging failures.

func (*Client) CreateAgent added in v0.28.0

func (c *Client) CreateAgent(req CreateAgentRequest) (string, error)

CreateAgent creates a managed agent (model + system prompt + built-in toolset) and returns its ID.

func (*Client) CreateEnvVarCredential added in v0.26.0

func (c *Client) CreateEnvVarCredential(vaultID, displayName, envName, secretValue string, allowedHosts []string) error

CreateEnvVarCredential adds an environment_variable credential to a vault. The secret is injected at the network egress layer; the agent never sees the raw value.

func (*Client) CreateEnvironment added in v0.28.0

func (c *Client) CreateEnvironment(name string, config EnvironmentConfig) (string, error)

CreateEnvironment provisions a cloud environment and returns its ID.

func (*Client) CreateManagedSession

func (c *Client) CreateManagedSession(req CreateManagedSessionRequest) (*ManagedSession, error)

CreateManagedSession creates a Managed Agents session.

func (*Client) CreateVault added in v0.26.0

func (c *Client) CreateVault(displayName string, metadata map[string]string) (string, error)

CreateVault creates a temporary vault and returns its ID.

func (*Client) DeleteEnvironment added in v0.28.0

func (c *Client) DeleteEnvironment(environmentID string) error

DeleteEnvironment removes an environment (only succeeds if no session references it).

func (*Client) DeleteFile added in v0.26.0

func (c *Client) DeleteFile(fileID string) error

DeleteFile removes an uploaded file (DELETE /v1/files/{id}).

func (*Client) DeleteManagedSession

func (c *Client) DeleteManagedSession(sessionID string) error

DeleteManagedSession removes a session (DELETE /v1/sessions/{id}). The API does not allow deleting a running session without interrupting first.

func (*Client) DeleteVault added in v0.26.0

func (c *Client) DeleteVault(vaultID string) error

DeleteVault removes a vault and its credentials.

func (*Client) DownloadFileContent added in v0.29.0

func (c *Client) DownloadFileContent(fileID string) ([]byte, error)

DownloadFileContent fetches a file's raw content (GET /v1/files/{id}/content).

func (*Client) FileContentURL added in v0.29.0

func (c *Client) FileContentURL(fileID string) string

FileContentURL returns the programmatic download link for a file. Requests to it require the API key headers, including the beta header.

func (*Client) GetLastManagedSessionAgentMessage deprecated

func (c *Client) GetLastManagedSessionAgentMessage(sessionID string) (string, []ManagedSessionEvent, error)

Deprecated: use GetSessionMessages instead.

func (*Client) GetLastManagedSessionAgentMessageWithRetry

func (c *Client) GetLastManagedSessionAgentMessageWithRetry(sessionID string, attempts int, delay time.Duration) (string, []ManagedSessionEvent, error)

func (*Client) GetManagedSession

func (c *Client) GetManagedSession(sessionID string) (*ManagedSession, error)

GetManagedSession retrieves a session by ID (GET /v1/sessions/{id}).

func (*Client) GetSessionMessages added in v0.26.0

func (c *Client) GetSessionMessages(sessionID string) (*SessionMessages, error)

func (*Client) GetSessionMessagesWithRetry added in v0.26.0

func (c *Client) GetSessionMessagesWithRetry(sessionID string, attempts int, delay time.Duration) (*SessionMessages, error)

GetSessionMessagesWithRetry polls until events are fully written (session.status_idle present) or retries are exhausted.

func (*Client) ListSessionFiles added in v0.29.0

func (c *Client) ListSessionFiles(sessionID string) ([]SessionFile, error)

ListSessionFiles lists the files scoped to a session (GET /v1/files?scope_id=...), paginating forward with after_id.

func (*Client) ListSessionFilesWithRetry added in v0.29.0

func (c *Client) ListSessionFilesWithRetry(sessionID string, attempts int, delay time.Duration) ([]SessionFile, error)

ListSessionFilesWithRetry lists session files, retrying while the listing has no downloadable entries — the agent's outputs can take a few seconds to be indexed after the session goes idle, and mounted input copies (which are never downloadable) may appear before them.

func (*Client) SendManagedSessionInterrupt

func (c *Client) SendManagedSessionInterrupt(sessionID string) error

SendManagedSessionInterrupt sends a user.interrupt event (stop agent mid-execution).

func (*Client) SendManagedSessionUserMessage

func (c *Client) SendManagedSessionUserMessage(sessionID, text string) error

SendManagedSessionUserMessage appends a user.message event to the session. The events endpoint uses ?beta=true per the Managed Agents API.

func (*Client) UploadFile added in v0.26.0

func (c *Client) UploadFile(content io.Reader, filename string) (string, error)

type CreateAgentRequest added in v0.28.0

type CreateAgentRequest struct {
	Name        string
	Model       string
	System      string
	ToolsetType string // defaults to the agent toolset when empty
}

CreateAgentRequest describes a managed agent to create.

type CreateManagedSessionRequest

type CreateManagedSessionRequest struct {
	// Agent is the agent ID string, or the ID used with AgentVersion for a specific version.
	Agent         string
	AgentVersion  *int
	EnvironmentID string
	VaultIDs      []string
	Resources     []FileResource
}

CreateManagedSessionRequest is the body for POST /v1/sessions.

type EnvironmentConfig added in v0.28.0

type EnvironmentConfig struct {
	Type       string                `json:"type"` // "cloud"
	Networking EnvironmentNetworking `json:"networking"`
	Packages   map[string][]string   `json:"packages,omitempty"`
}

EnvironmentConfig is the config object for a cloud environment.

type EnvironmentNetworking added in v0.28.0

type EnvironmentNetworking struct {
	Type                 string   `json:"type"` // "unrestricted" or "limited"
	AllowedHosts         []string `json:"allowed_hosts,omitempty"`
	AllowPackageManagers *bool    `json:"allow_package_managers,omitempty"`
	AllowMCPServers      *bool    `json:"allow_mcp_servers,omitempty"`
}

EnvironmentNetworking configures a cloud environment's outbound network policy.

type ExecutionMetadata

type ExecutionMetadata struct {
	Session *SessionMetadata `json:"session,omitempty" mapstructure:"session,omitempty"`
}

ExecutionMetadata is persisted for the run.

type FileResource added in v0.26.0

type FileResource struct {
	FileID    string
	MountPath string
}

FileResource is a file uploaded via the Files API to mount into the session.

type ManagedSession

type ManagedSession struct {
	ID     string `json:"id"`
	Status string `json:"status"`
}

ManagedSession is a subset of the session resource returned by the API.

type ManagedSessionContentBlock

type ManagedSessionContentBlock struct {
	Type string `json:"type"`
	Text string `json:"text,omitempty"`
}

type ManagedSessionEvent

type ManagedSessionEvent struct {
	Type    string                       `json:"type"`
	Content []ManagedSessionContentBlock `json:"content"`
}

type OutputPayload

type OutputPayload struct {
	Status      string            `json:"status"`
	SessionID   string            `json:"sessionId"`
	LastMessage string            `json:"lastMessage"`
	Messages    []string          `json:"messages"`
	Artifacts   []SessionArtifact `json:"artifacts,omitempty"`
}

OutputPayload is emitted on the default channel when the run completes.

type RunAgent

type RunAgent struct{}

func (*RunAgent) Cancel

func (a *RunAgent) Cancel(ctx core.ExecutionContext) error

func (*RunAgent) Cleanup

func (a *RunAgent) Cleanup(ctx core.SetupContext) error

func (*RunAgent) Color

func (a *RunAgent) Color() string

func (*RunAgent) Configuration

func (a *RunAgent) Configuration() []configuration.Field

func (*RunAgent) Description

func (a *RunAgent) Description() string

func (*RunAgent) Documentation

func (a *RunAgent) Documentation() string

func (*RunAgent) ExampleOutput

func (a *RunAgent) ExampleOutput() map[string]any

func (*RunAgent) Execute

func (a *RunAgent) Execute(ctx core.ExecutionContext) error

func (*RunAgent) HandleHook

func (a *RunAgent) HandleHook(ctx core.ActionHookContext) error

func (*RunAgent) HandleWebhook

HandleWebhook — Managed Agents completion is observed via polling, not webhooks.

func (*RunAgent) Hooks

func (a *RunAgent) Hooks() []core.Hook

func (*RunAgent) Icon

func (a *RunAgent) Icon() string

func (*RunAgent) Label

func (a *RunAgent) Label() string

func (*RunAgent) Name

func (a *RunAgent) Name() string

func (*RunAgent) OutputChannels

func (a *RunAgent) OutputChannels(config any) []core.OutputChannel

func (*RunAgent) ProcessQueueItem

func (a *RunAgent) ProcessQueueItem(ctx core.ProcessQueueContext) (*uuid.UUID, error)

func (*RunAgent) Setup

func (a *RunAgent) Setup(ctx core.SetupContext) error

type SecretBinding added in v0.26.0

type SecretBinding struct {
	EnvName      string    `json:"envName" mapstructure:"envName"`
	Value        SecretRef `json:"value" mapstructure:"value"`
	AllowedHosts []string  `json:"allowedHosts" mapstructure:"allowedHosts"`
}

SecretBinding maps a SuperPlane secret to an environment variable in the agent session.

type SecretRef added in v0.26.0

type SecretRef struct {
	Secret string `json:"secret" mapstructure:"secret"`
	Key    string `json:"key" mapstructure:"key"`
}

SecretRef references a SuperPlane secret by name and key.

type SessionArtifact added in v0.29.0

type SessionArtifact struct {
	FileID      string `json:"fileId"`
	Filename    string `json:"filename"`
	MimeType    string `json:"mimeType"`
	SizeBytes   int64  `json:"sizeBytes"`
	Encoding    string `json:"encoding,omitempty"`
	Content     string `json:"content,omitempty"`
	DownloadURL string `json:"downloadUrl"`
}

SessionArtifact is a file the agent generated during the session (written to /mnt/session/outputs/). Its content is embedded in the payload — text files as a plain string, everything else base64-encoded — so downstream steps can consume it directly. Files over the inline size cap carry metadata and the download link only.

func CollectSessionArtifacts added in v0.29.0

func CollectSessionArtifacts(client *Client, sessionID string, expectsArtifacts bool, logWarn func(string, ...any)) []SessionArtifact

CollectSessionArtifacts lists the files the agent generated during the session and resolves them into artifacts carrying the file content. Collection is best-effort: a listing or download failure is logged and degrades the artifact (or drops the list) rather than failing a run whose real output is already available. The listing is only retried (to cover the Files API indexing lag) when the session events indicate the agent wrote outputs, so artifact-less runs finish without extra delay.

type SessionFile added in v0.29.0

type SessionFile struct {
	ID           string `json:"id"`
	Filename     string `json:"filename"`
	MimeType     string `json:"mime_type"`
	SizeBytes    int64  `json:"size_bytes"`
	CreatedAt    string `json:"created_at"`
	Downloadable bool   `json:"downloadable"`
}

SessionFile is a file surfaced by the Files API for a Managed Agents session. Files the agent writes to /mnt/session/outputs/ are captured with downloadable=true; input files mounted into the session are not downloadable.

type SessionMessages added in v0.26.0

type SessionMessages struct {
	Messages    []string // all agent.message texts in chronological order
	LastMessage string   // the final agent.message text
	Complete    bool     // true if session.status_idle or session.status_terminated is in the events
	// ExpectsArtifacts is true when the session events mention the outputs
	// directory, i.e. the agent (very likely) wrote deliverables.
	ExpectsArtifacts bool
}

SessionMessages holds all agent messages and completion status from a session's events.

type SessionMetadata

type SessionMetadata struct {
	ID     string `json:"id" mapstructure:"id"`
	Status string `json:"status" mapstructure:"status"`
}

SessionMetadata tracks the Managed Agents session.

type Spec

type Spec struct {
	// Agent is the managed agent id (use latest if Version is nil, else pin to Version).
	Agent         string          `json:"agent" mapstructure:"agent"`
	Version       *int            `json:"version" mapstructure:"version"`
	EnvironmentID string          `json:"environmentId" mapstructure:"environmentId"`
	Prompt        string          `json:"prompt" mapstructure:"prompt"`
	VaultIDs      []string        `json:"vaultIds" mapstructure:"vaultIds"`
	Files         []string        `json:"files" mapstructure:"files"`
	Secrets       []SecretBinding `json:"secrets" mapstructure:"secrets"`
	// PersistSession keeps the Managed Agents session after the run finishes so
	// its transcript stays readable in the Anthropic Console.
	PersistSession bool `json:"persistSession" mapstructure:"persistSession"`
}

Spec is the workflow node configuration for claude.runAgent.

Jump to

Keyboard shortcuts

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