wstoken

package
v0.47.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package wstoken acquires per-workspace proxy tokens from agentserver and caches them in-process so cc-broker can stamp them onto every spawned Claude CLI's ANTHROPIC_AUTH_TOKEN env without hitting the network on every turn.

Index

Constants

View Source
const CacheTTL = 5 * time.Minute

CacheTTL bounds how long a fetched token is reused before re-validating against agentserver. Short enough that a token rotation / workspace deletion is picked up within a few minutes; long enough that steady- state turn dispatch never hits the network for token lookup.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client acquires and caches workspace proxy tokens from agentserver:/internal/workspace-token.

func New

func New(agentserverURL, internalSecret string) *Client

func (*Client) GetOrCreate

func (c *Client) GetOrCreate(ctx context.Context, workspaceID string) (string, error)

GetOrCreate returns the workspace's proxy token, fetching it from agentserver on first request (or after CacheTTL has elapsed) and caching the result. The agentserver endpoint is itself idempotent so concurrent first-time fetches converge.

func (*Client) Invalidate

func (c *Client) Invalidate(workspaceID string)

Invalidate drops the cached token for a workspace, forcing the next GetOrCreate to fetch fresh. Call this when an upstream returned 401 for the cached value (e.g., the workspace was deleted and its token row went with it). Safe to call for absent workspaces.

Jump to

Keyboard shortcuts

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