Documentation
¶
Overview ¶
Package agents is the agent subsystem: agents-as-users and their templates, skills and standing orders (AgentService), the run orchestrator with its approval gates, cross-instance turn coordination and coding-task layer, runner pairing tokens, shared channel context, connectors (API docs bundles plus per-user credentials, synced from the connector provider), server-side Bedrock execution (ServerEngine) and projects.
It builds on the chat core in internal/service — posting, reading and access checks go through the service layer's exported API and narrow interfaces — and never the other way round: internal/service does not import this package; it reaches agents only through interfaces it defines (AgentDispatcher, RunLogPurger, AutomationStopper, RunnerRevoker, …), wired in internal/app.
Index ¶
- Constants
- Variables
- func AgentUserID(slug string) string
- func AllowConnectorDomains(domains []string)
- func AllowPrivateConnectorTargets(v bool)
- func CondenseThemeCSS(css string) (string, int)
- func ConfigureConnectorDomains(ctx context.Context, raw string)
- func IsDesignAgent(agent *model.User) bool
- func LegacyApproval(a *model.Approval) bool
- func MRApprovalSummary(t *model.CodingTask) string
- func ProjectChannelID(projectKey, requesterID string) string
- func ProjectKey(name string) string
- func RunnerHasHarness(runners []*model.RunnerRegistration, harness string) bool
- func RunnerRecordedEvent(e *model.RunEvent) bool
- func TaskMarker(t *model.CodingTask) string
- func TwoFactorAccessCode(err error) string
- type ActionGate
- type AgentDirectoryStore
- type AgentPrefsPatch
- type AgentService
- func (s *AgentService) AgentFollows(ctx context.Context, parentID, threadRootID string) ([]*model.AgentThreadFollow, error)
- func (s *AgentService) AllSubscriptions(ctx context.Context) ([]*model.AgentSubscription, error)
- func (s *AgentService) CountAgentOverrides(ctx context.Context, slug string) (int, error)
- func (s *AgentService) CreateAgent(ctx context.Context, in CreateAgentInput) (*model.AgentTemplate, error)
- func (s *AgentService) CreateSkill(ctx context.Context, authorID string, asAdmin bool, ...) (*model.Skill, error)
- func (s *AgentService) CreateSubscription(ctx context.Context, creatorID, slug, parentID, parentType string, ...) (*model.AgentSubscription, error)
- func (s *AgentService) DeleteSkill(ctx context.Context, callerID string, asAdmin bool, id string) error
- func (s *AgentService) DeleteSubscription(ctx context.Context, creatorID, parentID, id string) error
- func (s *AgentService) GetAgentBySlug(ctx context.Context, slug string) (*model.User, error)
- func (s *AgentService) GetMemory(ctx context.Context, invokerID, agentID string) (string, error)
- func (s *AgentService) GetPrefs(ctx context.Context, userID, slug string) (*model.UserAgentPrefs, error)
- func (s *AgentService) GetSkill(ctx context.Context, id string) (*model.Skill, error)
- func (s *AgentService) GetVisibleSkill(ctx context.Context, userID, id string) (*model.Skill, error)
- func (s *AgentService) ListAgents(ctx context.Context) ([]*model.User, error)
- func (s *AgentService) ListSchedules(ctx context.Context, creatorID string) ([]ScheduleEntry, error)
- func (s *AgentService) ListSkillIndex(ctx context.Context, callerID string) ([]*model.Skill, error)
- func (s *AgentService) ListSkills(ctx context.Context, callerID string) ([]*model.Skill, error)
- func (s *AgentService) ListSubscriptionsFor(ctx context.Context, creatorID, slug string) ([]*model.AgentSubscription, error)
- func (s *AgentService) ListWatchersInParent(ctx context.Context, viewerID, parentID string) ([]*model.AgentSubscription, error)
- func (s *AgentService) LiveRunners(ctx context.Context, userID string) ([]*model.RunnerRegistration, error)
- func (s *AgentService) PutAgentFollow(ctx context.Context, f *model.AgentThreadFollow) error
- func (s *AgentService) PutRunner(ctx context.Context, reg *model.RunnerRegistration) error
- func (s *AgentService) PutSubscription(ctx context.Context, sub *model.AgentSubscription) error
- func (s *AgentService) PutTaskClaim(ctx context.Context, c *model.TaskClaim) error
- func (s *AgentService) RenameAgent(ctx context.Context, slug, newName string) (*model.AgentTemplate, error)
- func (s *AgentService) ResetAgentOverrides(ctx context.Context, slug string) (int, error)
- func (s *AgentService) Resolve(ctx context.Context, agent *model.User, invokerID string) (*model.ResolvedAgentConfig, error)
- func (s *AgentService) SeedDefaults(ctx context.Context) error
- func (s *AgentService) SetAgentEngine(ctx context.Context, slug, harness, mdl, executionMode string) (*model.AgentTemplate, error)
- func (s *AgentService) SetAgentPersona(ctx context.Context, slug, persona string) (*model.AgentTemplate, error)
- func (s *AgentService) SetAgentSkills(ctx context.Context, callerID, slug string, skillIDs []string) (*model.AgentTemplate, error)
- func (s *AgentService) SetDMResolver(r agentDMResolver)
- func (s *AgentService) SetIndexer(i service.UserIndexer)
- func (s *AgentService) SetModelCatalog(c agentModelCatalog)
- func (s *AgentService) SetUserLister(l agentUserLister)
- func (s *AgentService) SlugForAgent(ctx context.Context, agentID string) (string, error)
- func (s *AgentService) SubscriptionsByParent(ctx context.Context, parentID string) ([]*model.AgentSubscription, error)
- func (s *AgentService) TaskClaims(ctx context.Context, parentID, threadRootID string) ([]*model.TaskClaim, error)
- func (s *AgentService) Template(ctx context.Context, slug string) (*model.AgentTemplate, error)
- func (s *AgentService) UpdateMemory(ctx context.Context, invokerID, agentID, content string) error
- func (s *AgentService) UpdatePrefs(ctx context.Context, userID, slug string, patch AgentPrefsPatch) (*model.UserAgentPrefs, error)
- func (s *AgentService) UpdateSkill(ctx context.Context, callerID string, asAdmin bool, id string, ...) (*model.Skill, error)
- func (s *AgentService) UpdateSubscription(ctx context.Context, creatorID, parentID, id string, in WatchInput) (*model.AgentSubscription, error)
- func (s *AgentService) Wired() error
- type ApprovalRequest
- type Assignment
- type CodingTaskService
- func (s *CodingTaskService) Close(ctx context.Context, callerID, taskID, state string) (*model.CodingTask, error)
- func (s *CodingTaskService) Create(ctx context.Context, run *model.Run, in CreateTaskInput) (*CreateTaskResult, error)
- func (s *CodingTaskService) GetVisible(ctx context.Context, callerID, id string) (*model.CodingTask, error)
- func (s *CodingTaskService) ListByChannel(ctx context.Context, callerID, channelID string) ([]*model.CodingTask, error)
- func (s *CodingTaskService) ListProjects(ctx context.Context) ([]*model.CodingProject, error)
- func (s *CodingTaskService) PublishTestPlan(ctx context.Context, run *model.Run, plan model.TestPlan) (*model.CodingTask, error)
- func (s *CodingTaskService) Report(ctx context.Context, run *model.Run, up TaskUpdate) (*model.CodingTask, error)
- func (s *CodingTaskService) RequestMR(ctx context.Context, run *model.Run, approvalID string) (status string, t *model.CodingTask, gate *model.Approval, err error)
- func (s *CodingTaskService) SetBaseURL(u string)
- func (s *CodingTaskService) SetSteering(ctx context.Context, callerID, taskID, mode string) (*model.CodingTask, error)
- func (s *CodingTaskService) SignOff(ctx context.Context, callerID, taskID string) (*model.CodingTask, error)
- func (s *CodingTaskService) TaskURL(t *model.CodingTask) string
- func (s *CodingTaskService) Wired() error
- type ConnectorIndexEntry
- type ConnectorService
- func (s *ConnectorService) AgentUsePolicy(ctx context.Context, userID, slug string) (policy, title string, err error)
- func (s *ConnectorService) ForRunner(ctx context.Context, invokerID string, slugs []string) ([]RunnerConnector, error)
- func (s *ConnectorService) Ingest(ctx context.Context, callerID string, in IngestInput) (*model.Connector, error)
- func (s *ConnectorService) Install(ctx context.Context, userID, slug string, in InstallInput) (*model.ConnectorInstall, error)
- func (s *ConnectorService) InstalledIndex(ctx context.Context, userID string) ([]ConnectorIndexEntry, error)
- func (s *ConnectorService) KnownSlugs(ctx context.Context) (map[string]bool, error)
- func (s *ConnectorService) ListForUser(ctx context.Context, userID string) ([]ConnectorWithStatus, error)
- func (s *ConnectorService) ProviderConfigured() bool
- func (s *ConnectorService) RunProviderSync(ctx context.Context, interval time.Duration)
- func (s *ConnectorService) SetAgentUse(ctx context.Context, userID, slug, mode string) error
- func (s *ConnectorService) SetProvider(baseURL, apiKey string)
- func (s *ConnectorService) SyncFromProvider(ctx context.Context, callerID string, force bool) (*SyncResult, error)
- func (s *ConnectorService) Uninstall(ctx context.Context, userID, slug string) error
- func (s *ConnectorService) VerifyInstall(ctx context.Context, userID, slug string) (*model.ConnectorInstall, error)
- type ConnectorWithStatus
- type ContextItemStore
- type ContextService
- func (s *ContextService) Delete(ctx context.Context, accessorID, parentID, parentType, itemID string) error
- func (s *ContextService) List(ctx context.Context, accessorID, parentID, parentType string) ([]*model.ContextItem, error)
- func (s *ContextService) SetPinned(ctx context.Context, accessorID, parentID, parentType, itemID string, ...) (*model.ContextItem, error)
- func (s *ContextService) Write(ctx context.Context, in ContextWrite) (*model.ContextItem, error)
- type ContextWrite
- type CreateAgentInput
- type CreateTaskInput
- type CreateTaskResult
- type Decision
- type IngestInput
- type InstallInput
- type IssuedRunnerToken
- type Orchestrator
- func (o *Orchestrator) ApprovalGranted(ctx context.Context, runID, approvalID, purpose string) (*model.Approval, bool)
- func (o *Orchestrator) ApprovalStatus(ctx context.Context, runID, approvalID string) (*model.Approval, error)
- func (o *Orchestrator) Artifacts(ctx context.Context, runID string) ([]*model.Artifact, error)
- func (o *Orchestrator) ArtifactsForCaller(ctx context.Context, callerID, runID string) (*model.Run, []*model.Artifact, error)
- func (o *Orchestrator) AttachConnector(ctx context.Context, runID, slug, reason string) error
- func (o *Orchestrator) AuthorizeAction(ctx context.Context, run *model.Run, action, summary string, ...) (ActionGate, error)
- func (o *Orchestrator) BundleForRun(ctx context.Context, run *model.Run) string
- func (o *Orchestrator) ChainFromAgentPost(ctx context.Context, run *model.Run, msg *model.Message)
- func (o *Orchestrator) Claim(ctx context.Context, ownerID, runnerID string, harnesses []string, max int, ...) ([]Assignment, error)
- func (o *Orchestrator) ClaimTask(ctx context.Context, run *model.Run, label string) (mine bool, lines []string, err error)
- func (o *Orchestrator) ClaimWithFeatures(ctx context.Context, ownerID, runnerID string, harnesses, features []string, ...) ([]Assignment, error)
- func (o *Orchestrator) CompleteRun(ctx context.Context, ownerID, runnerID, runID, finalText string, ...) error
- func (o *Orchestrator) ConsumeDeliberateApproval(ctx context.Context, runID string) (bool, error)
- func (o *Orchestrator) DecideApproval(ctx context.Context, deciderID, runID, approvalID string, d Decision) (*model.Approval, error)
- func (o *Orchestrator) DecideCatchUp(ctx context.Context, callerID, parentID, subID string, process bool) error
- func (o *Orchestrator) FailRun(ctx context.Context, ownerID, runnerID, runID, reason string) error
- func (o *Orchestrator) GetLiveRun(ctx context.Context, runID string) (*model.Run, error)
- func (o *Orchestrator) Heartbeat(ctx context.Context, reg *model.RunnerRegistration, activeRunIDs []string) (kill []string, err error)
- func (o *Orchestrator) LinkifyMentions(ctx context.Context, run *model.Run, body string) string
- func (o *Orchestrator) OnMessage(ctx context.Context, msg *model.Message, parentType string, ...)
- func (o *Orchestrator) PendingApprovals(ctx context.Context, userID string) ([]map[string]any, error)
- func (o *Orchestrator) ProposeReply(ctx context.Context, run *model.Run, text, threadRoot, replyTo string) (*model.Approval, error)
- func (o *Orchestrator) PublishArtifact(ctx context.Context, run *model.Run, kind, title, content string) (*model.Artifact, error)
- func (o *Orchestrator) PurgeThreadLogs(ctx context.Context, parentID, msgID string)
- func (o *Orchestrator) RecordAgentPost(ctx context.Context, runID string) (remaining int, err error)
- func (o *Orchestrator) RecordAgentUpload(ctx context.Context, runID string) (remaining int, err error)
- func (o *Orchestrator) RecordContextWrite(ctx context.Context, run *model.Run, itemID string, pinned bool)
- func (o *Orchestrator) RecordMemoryUpdate(ctx context.Context, run *model.Run, bytes int)
- func (o *Orchestrator) RecordSkillInvoked(ctx context.Context, run *model.Run, skill *model.Skill)
- func (o *Orchestrator) RecordWorkspaceAction(ctx context.Context, run *model.Run, action string, payload map[string]any)
- func (o *Orchestrator) RegisterRunner(ctx context.Context, reg *model.RunnerRegistration) error
- func (o *Orchestrator) RenderMessages(ctx context.Context, msgs []*model.Message) string
- func (o *Orchestrator) ReportEvents(ctx context.Context, ownerID, runnerID, runID string, batch []RunEventInput) (abort bool, reason string, err error)
- func (o *Orchestrator) RequestApproval(ctx context.Context, run *model.Run, req ApprovalRequest) (*model.Approval, error)
- func (o *Orchestrator) Run(ctx context.Context, runID string) (*model.Run, error)
- func (o *Orchestrator) RunForCaller(ctx context.Context, callerID, runID string) (*model.Run, error)
- func (o *Orchestrator) RunForParentMember(ctx context.Context, callerID, runID string) (*model.Run, error)
- func (o *Orchestrator) RunMayReadScreen(ctx context.Context, run *model.Run, attachmentID string) bool
- func (o *Orchestrator) RunSkillBadges(ctx context.Context, runID string) []string
- func (o *Orchestrator) SetApprovalNotifier(n approvalNotifier)
- func (o *Orchestrator) SetAttachments(a runAttachments)
- func (o *Orchestrator) SetConnectorRegistry(r connectorRegistry)
- func (o *Orchestrator) SetContextService(svc *ContextService)
- func (o *Orchestrator) SetEventArchive(a eventArchive)
- func (o *Orchestrator) SetGitHost(host string)
- func (o *Orchestrator) SetOwnerDMResolver(r ownerDMResolver)
- func (o *Orchestrator) SetProjects(p projectResolver)
- func (o *Orchestrator) SetRunState(ctx context.Context, runID, state string) error
- func (o *Orchestrator) SetServerEngine(e serverDispatcher)
- func (o *Orchestrator) SetSkillPrefs(p skillPrefs)
- func (o *Orchestrator) SetTaskStore(t orchestratorTasks)
- func (o *Orchestrator) SetTurnCoordinator(ctx context.Context, c *RedisTurnCoordinator)
- func (o *Orchestrator) StartReconciler(ctx context.Context)
- func (o *Orchestrator) StartTaskRun(ctx context.Context, task *model.CodingTask, requester *model.User, ...) error
- func (o *Orchestrator) StopThread(ctx context.Context, stopperID, runID string) (int, error)
- func (o *Orchestrator) StopUserAutomations(ctx context.Context, userID string) error
- func (o *Orchestrator) ThreadMessages(ctx context.Context, userID, parentID, parentType, rootID string) ([]*model.Message, error)
- func (o *Orchestrator) ThreadSpend(ctx context.Context, run *model.Run) ThreadSpendSummary
- func (o *Orchestrator) ThreadTimeline(ctx context.Context, callerID, parentID, rootID string) ([]*model.Run, []*model.RunEvent, int, error)
- func (o *Orchestrator) ThreadWindow(ctx context.Context, run *model.Run, limit int) string
- func (o *Orchestrator) Timeline(ctx context.Context, callerID, runID string) (*model.Run, []*model.RunEvent, int, error)
- func (o *Orchestrator) Window(ctx context.Context, accessorID, parentID, parentType, threadRootID string, ...) (string, error)
- func (o *Orchestrator) Wired() error
- type ProjectCaller
- type ProjectDetail
- type ProjectInput
- type ProjectService
- func (s *ProjectService) AddScreen(ctx context.Context, caller ProjectCaller, key string, in ScreenInput) (*model.ProjectScreen, error)
- func (s *ProjectService) Create(ctx context.Context, caller ProjectCaller, in ProjectInput) (*model.CodingProject, error)
- func (s *ProjectService) Delete(ctx context.Context, caller ProjectCaller, key string) error
- func (s *ProjectService) DeleteScreen(ctx context.Context, caller ProjectCaller, key, id string) error
- func (s *ProjectService) DesignLayer(ctx context.Context, projectKey string) string
- func (s *ProjectService) Get(ctx context.Context, caller ProjectCaller, key string) (*ProjectDetail, error)
- func (s *ProjectService) List(ctx context.Context, caller ProjectCaller) ([]*ProjectSummary, error)
- func (s *ProjectService) ProjectByName(ctx context.Context, text string) string
- func (s *ProjectService) ProjectByToken(ctx context.Context, candidates []string) string
- func (s *ProjectService) ScreenImage(ctx context.Context, projectKey, attachmentID string) bool
- func (s *ProjectService) Screens(ctx context.Context, key string) ([]*model.ProjectScreen, error)
- func (s *ProjectService) SetPublisher(p service.Publisher)
- func (s *ProjectService) Update(ctx context.Context, caller ProjectCaller, key string, in ProjectInput) (*model.CodingProject, error)
- func (s *ProjectService) UpdateScreen(ctx context.Context, caller ProjectCaller, key, id string, in ScreenInput) (*model.ProjectScreen, error)
- func (s *ProjectService) Wired() error
- type ProjectSummary
- type RedisTurnCoordinator
- type RepoInput
- type RepoUpdate
- type RunAttachment
- type RunEventInput
- type RunnerConnector
- type RunnerTokenService
- func (s *RunnerTokenService) ConnectWorkbench(ctx context.Context, userID string) (*WorkbenchJob, error)
- func (s *RunnerTokenService) CreateGrant(ctx context.Context, userID, challenge, label string) (code string, expiresAt time.Time, err error)
- func (s *RunnerTokenService) Exchange(ctx context.Context, code, verifier string) (*IssuedRunnerToken, error)
- func (s *RunnerTokenService) List(ctx context.Context, userID string) ([]*model.RunnerToken, error)
- func (s *RunnerTokenService) Renew(ctx context.Context, claims *model.TokenClaims) (*IssuedRunnerToken, error)
- func (s *RunnerTokenService) Revoke(ctx context.Context, userID, id string) error
- func (s *RunnerTokenService) RevokeAllForUser(ctx context.Context, userID string) error
- func (s *RunnerTokenService) RevokeSelf(ctx context.Context, claims *model.TokenClaims) error
- func (s *RunnerTokenService) RunnerTokenActive(ctx context.Context, claims *model.TokenClaims) (bool, error)
- func (s *RunnerTokenService) SetPublisher(p service.Publisher)
- func (s *RunnerTokenService) SetWorkbench(w Workbench)
- func (s *RunnerTokenService) UseWorkbenchURL(baseURL, apiToken, server string)
- func (s *RunnerTokenService) Wired() error
- func (s *RunnerTokenService) WorkbenchEnabled() bool
- func (s *RunnerTokenService) WorkbenchStatus(ctx context.Context, userID string) (*WorkbenchJob, error)
- type RunnerTokenStore
- type ScheduleEntry
- type ScreenInput
- type ScreenView
- type ServerEngine
- type SkillPatch
- type SyncResult
- type TaskUpdate
- type ThemeView
- type ThreadSpendSummary
- type WatchInput
- type Workbench
- type WorkbenchClient
- type WorkbenchJob
Constants ¶
const ( AgentSlugGG = "gg" AgentSlugQib = "qib" // AgentSlugDesign is the mockup agent (plan-projects-design.md), shown as // "Apelles"; the slug stays "design" so templates and prefs keep their keys. AgentSlugDesign = "design" )
Default agent template slugs (plan-v2 §4, revised). gg and qib are SHARED workspace agents — plain users owned by no one. What is per-user is attribution (whose invocation a run serves, whose machine executes) and preferences (each user's prompt/harness/model for when THEY invoke). Nothing anywhere may branch on these slugs — they select config, never code paths.
const ( MRStatusApproved = "approved" MRStatusAsk = "ask" MRStatusNotReady = "not_ready" MRStatusDenied = "denied" )
MR request statuses (the request_mr tool contract).
const AgentSkillsMax = 8
AgentSkillsMax bounds how many skills one agent template can pin — every attached skill's full instructions ride each run's bundle, so this is a context-budget guard, not an arbitrary knob.
const AgentSlugDev = "dev"
AgentSlugDev is the seeded coding agent. Like gg/qib it is a shared user; unlike them it is the ONLY agent that WORKS coding tasks (any agent may open one — a hand-off).
const ( // RunnerTokenTTL is how long a runner token lives without renewal. The // runner renews itself in its last week, so only a machine left off for // a month needs `ex-runner login` again. RunnerTokenTTL = 30 * 24 * time.Hour )
const WorkbenchJobFailed = "failed"
WorkbenchJobFailed is the state of a job that never started.
const WorkbenchLabel = "Agent workbench"
WorkbenchLabel names the workbench install on the Runners page.
Variables ¶
var ( ErrTaskActive = errors.New("task: this project already has an active task") ErrNotRequester = errors.New("task: only the requester may do that") ErrTaskTransition = errors.New("task: illegal state transition") ErrTaskNotReady = errors.New("task: not ready for that step") ErrTaskAgent = errors.New("task: the coding agent is not available") ErrNotTaskRun = errors.New("task: this run is not bound to a coding task") // ErrProjectUnknown: a new project needs its repos — the agent must ask // the requester which GitLab repositories make up the product. ErrProjectUnknown = errors.New("task: unknown project — its repositories are needed") // ErrStaleTask: the task's state changed concurrently (the store's // conditional write lost), re-exported so callers needn't import store. ErrStaleTask = store.ErrStaleTask )
Task-layer errors.
var ( ErrConnectorInvalid = errors.New("connector invalid") ErrTokenRejected = errors.New("token rejected by the service") // ErrLoginFailed: the external service REJECTED the caller's credentials // (401 to the caller). ErrServiceUnreachable: we could not reach it at all // (502 — nothing is wrong with the caller). These used to be one sentinel, // which is why one handler answered 401 and another 502 for the same error. ErrLoginFailed = errors.New("login failed") ErrServiceUnreachable = errors.New("service unreachable") ErrTwoFactorRequired = errors.New("two-factor code required") // ErrNoConnectorProvider: no connector provider is configured, so there // is no catalog to sync (an unconfigured dependency, not bad input). ErrNoConnectorProvider = fmt.Errorf("%w: no connector provider configured", ErrConnectorInvalid) )
var ( ErrRunClosed = errors.New("orchestrator: run is terminal") // maps to 409 ErrWrongRunner = errors.New("orchestrator: run leased elsewhere") // maps to 409 ErrAgentOffline = errors.New("orchestrator: invoker has no live runner") ErrAgentBusy = errors.New("orchestrator: agent already active in this thread") // ErrInvokerInactive: the person a run would act for is deactivated. ErrInvokerInactive = errors.New("orchestrator: invoker account is deactivated") )
Orchestrator errors surfaced to the runner/run APIs.
var ( ErrNotInvoker = errors.New("orchestrator: only the invoker decides approvals") ErrApprovalSettled = errors.New("orchestrator: approval already settled") ErrArtifactCap = errors.New("orchestrator: per-run artifact cap reached") // the run cannot raise the card (it is too close to its deadline to wait). ErrApprovalUnavailable = errors.New("orchestrator: approval unavailable") )
Gate errors.
var ( // ErrRunnerGrantInvalid covers every failed code exchange — unknown, // used, expired, wrong verifier, account gone — deliberately alike, so a // prober learns nothing about which part was wrong. ErrRunnerGrantInvalid = errors.New("runner: this sign-in link is invalid or has expired") // ErrRunnerTokenRevoked reports a runner token whose record is gone or // expired (renewal of a dead install). ErrRunnerTokenRevoked = errors.New("runner: this runner was disconnected") )
var ( // ErrWorkbenchOff means this deployment has no agent workbench. ErrWorkbenchOff = errors.New("the agent workbench isn't set up here") // ErrWorkbenchConnected means the person already has a workbench runner. ErrWorkbenchConnected = errors.New("you're already connected to Claude") // ErrWorkbenchFailed means the workbench didn't take the onboarding. ErrWorkbenchFailed = errors.New("the agent workbench couldn't set you up") // ErrWorkbenchNotConnected means the person has no workbench runner. ErrWorkbenchNotConnected = errors.New("you aren't connected to Claude") // ErrWorkbenchUnreachable means the workbench didn't answer a status check. ErrWorkbenchUnreachable = errors.New("couldn't reach the agent workbench") )
var ErrContextFull = errors.New("shared context is full for this channel")
ErrContextFull signals the per-parent item cap (plan-v2 §8 governance).
var ErrNoRunAccess = errors.New("orchestrator: no access to this run")
ErrNoRunAccess means the caller may neither read nor act on this run.
var ErrUploadCap = errors.New("orchestrator: per-run upload cap reached")
ErrUploadCap is returned once a run has stored its share of files.
Functions ¶
func AgentUserID ¶
AgentUserID derives the shared agent user's deterministic ID from its slug, so every boot converges on the same row.
func AllowConnectorDomains ¶ added in v0.0.105
func AllowConnectorDomains(domains []string)
AllowConnectorDomains sets the domains whose hosts connectors may reach on a private 10.x address.
func AllowPrivateConnectorTargets ¶
func AllowPrivateConnectorTargets(v bool)
AllowPrivateConnectorTargets opts the workspace into private/plain-HTTP connector endpoints. Wired from config at boot; development only.
func CondenseThemeCSS ¶
CondenseThemeCSS turns a project's main stylesheet (globals.css and the like) into the few lines a design agent needs, so a 40 KB file costs a few hundred tokens: the imports and plugins (they name the stack — tailwindcss, shadcn/tailwind.css…), every CSS custom property grouped by selector (:root, .dark, @theme…), and font families. Pure aliases inside @theme (`--color-x: var(--x)`) are dropped — they only restate the variables. Ordinary rules (.status-pill { … }) are ignored. Returns the summary and how many variables it kept.
func ConfigureConnectorDomains ¶ added in v0.0.105
ConfigureConnectorDomains reads CONNECTOR_PRIVATE_DOMAINS at boot. It never fails: an entry it can't use is logged as an error and left out, so the connectors behind it stay blocked until the setting is fixed.
func IsDesignAgent ¶
IsDesignAgent reports whether agent is the seeded design agent.
func LegacyApproval ¶
LegacyApproval reports whether a is an approved decision with no purpose — a card an agent (or an older desktop runner) raised itself. It never authorizes a server gate; a gate that is handed one raises its own server-worded card instead, so a run caught mid-flight by the change asks the invoker once more rather than failing or slipping through.
func MRApprovalSummary ¶
func MRApprovalSummary(t *model.CodingTask) string
MRApprovalSummary is the approval-card text request_mr raises; RequestMR verifies the decided approval by this exact task id.
func ProjectChannelID ¶
ProjectChannelID is the derived, coordination-free ID of ONE REQUESTER's channel for a project: Alice's first task on CliffHub creates ~cliffhub-alice, every later task of hers finds it; Bob's tasks on the same product land in ~cliffhub-bob. The server never adds anyone to another person's channel — sharing is an ordinary private-channel invite.
Decision 2026-09-21, reversing the 2026-08-26 "one shared channel per project": that design auto-joined every later requester (bypassing the invite that every other private channel requires), showed them each other's task threads, approval relays and test links, and — through the one-active-task-per-channel rule — let one requester's task block or even close (supersede) another's.
func ProjectKey ¶
ProjectKey normalizes a product name into its key: "CliffHub" → "cliffhub", "Booking Portal" → "booking-portal". The key names the channel and derives its ID, so two spellings of one product land in one place.
func RunnerHasHarness ¶
func RunnerHasHarness(runners []*model.RunnerRegistration, harness string) bool
RunnerHasHarness reports whether any of the given (live) runners detected the harness.
func RunnerRecordedEvent ¶
RunnerRecordedEvent reports whether a timeline row came from a runner's event batch rather than from the server: runner sequences live in their own band (runnerSeqBase+1 … runnerSeqBase+maxRunnerSeq), server rows use the reserved lifecycle sequences or a wall-clock nanosecond stamp. Rows written before reserved types were refused can still carry a forged type, so a reader that acts on a server-recorded type checks this too.
func TaskMarker ¶
func TaskMarker(t *model.CodingTask) string
TaskMarker renders the task card message body — machine syntax the SPA renders as a live card: [task:<id>|<title>|<state>|<kind>|<project>].
func TwoFactorAccessCode ¶
TwoFactorAccessCode extracts the challenge access code from an ErrTwoFactorRequired error.
Types ¶
type ActionGate ¶
type ActionGate struct {
// Granted: go ahead — the run acts on its invoker's own words, or the
// invoker approved exactly this action.
Granted bool
// Denied: the invoker refused exactly this action; it must not be retried.
Denied bool
// Pending is the server-raised approval card waiting on the invoker.
Pending *model.Approval
}
ActionGate is the verdict on one write or exfiltration action a run asked to take.
type AgentDirectoryStore ¶
type AgentDirectoryStore interface {
PutTemplate(ctx context.Context, tpl *model.AgentTemplate) error
CreateTemplateIfAbsent(ctx context.Context, tpl *model.AgentTemplate) error
GetTemplate(ctx context.Context, slug string) (*model.AgentTemplate, error)
ListTemplates(ctx context.Context) ([]*model.AgentTemplate, error)
CreateAgentUser(ctx context.Context, user *model.User) error
PutAgentPrefs(ctx context.Context, prefs *model.UserAgentPrefs) error
GetAgentPrefs(ctx context.Context, userID, slug string) (*model.UserAgentPrefs, error)
DeleteAgentPrefs(ctx context.Context, userID, slug string) error
PutRunner(ctx context.Context, reg *model.RunnerRegistration) error
ListRunners(ctx context.Context, ownerID string) ([]*model.RunnerRegistration, error)
PutSkill(ctx context.Context, sk *model.Skill) error
GetSkill(ctx context.Context, id string) (*model.Skill, error)
ListSkills(ctx context.Context) ([]*model.Skill, error)
ListSkillIndex(ctx context.Context) ([]*model.Skill, error)
DeleteSkill(ctx context.Context, id string) error
PutAgentMemory(ctx context.Context, m *model.AgentMemory) error
GetAgentMemory(ctx context.Context, invokerID, agentID string) (*model.AgentMemory, error)
PutAgentSubscription(ctx context.Context, sub *model.AgentSubscription) error
ListSubscriptionsByParent(ctx context.Context, parentID string) ([]*model.AgentSubscription, error)
ListAllSubscriptions(ctx context.Context) ([]*model.AgentSubscription, error)
ListSubscriptionsByCreator(ctx context.Context, creatorID, agentID string) ([]*model.AgentSubscription, error)
DeleteAgentSubscription(ctx context.Context, parentID, id string) error
PutTaskClaim(ctx context.Context, c *model.TaskClaim) error
ListTaskClaims(ctx context.Context, parentID, threadRootID string) ([]*model.TaskClaim, error)
PutAgentFollow(ctx context.Context, f *model.AgentThreadFollow) error
ListAgentFollows(ctx context.Context, parentID, threadRootID string) ([]*model.AgentThreadFollow, error)
}
AgentDirectoryStore is the store surface AgentService needs.
type AgentPrefsPatch ¶
type AgentPrefsPatch struct {
Harness *string `json:"harness,omitempty"`
Model *string `json:"model,omitempty"`
ExecutionMode *string `json:"executionMode,omitempty"`
Persona *string `json:"persona,omitempty"`
Limits *model.AgentLimits `json:"limits,omitempty"`
OfflinePolicy *string `json:"offlinePolicy,omitempty"`
FollowUpMode *string `json:"followUpMode,omitempty"`
FollowUpMins *int `json:"followUpMins,omitempty"`
FollowUpAsk *bool `json:"followUpAsk,omitempty"`
// AutoAllow replaces the pre-approved harness tool classes (nil = leave
// as-is; empty list = clear).
AutoAllow *[]string `json:"autoAllow,omitempty"`
}
AgentPrefsPatch is the caller-editable slice of their own prefs for one shared agent. Nil pointer = leave as-is; pointer to "" = reset to inherit.
type AgentService ¶
type AgentService struct {
// contains filtered or unexported fields
}
AgentService owns agent templates, the shared agent users, and per-user preference resolution. Runs are the Orchestrator's business.
func NewAgentService ¶
func NewAgentService(agents AgentDirectoryStore, users agentUserGetter) *AgentService
NewAgentService constructs an AgentService.
func (*AgentService) AgentFollows ¶
func (s *AgentService) AgentFollows(ctx context.Context, parentID, threadRootID string) ([]*model.AgentThreadFollow, error)
AgentFollows lists the follow markers on one thread.
func (*AgentService) AllSubscriptions ¶
func (s *AgentService) AllSubscriptions(ctx context.Context) ([]*model.AgentSubscription, error)
AllSubscriptions lists every subscription in the workspace (the reconcile sweeps read it once per tick).
func (*AgentService) CountAgentOverrides ¶
CountAgentOverrides reports how many people have customized this agent, so an admin editing the workspace default can see how far that default actually reaches.
func (*AgentService) CreateAgent ¶
func (s *AgentService) CreateAgent(ctx context.Context, in CreateAgentInput) (*model.AgentTemplate, error)
CreateAgent defines a new shared agent (template + its singleton agent user), the same shape SeedDefaults produces for gg/qib. Admin-gated at the handler. The agent is immediately mentionable workspace-wide; per-user prefs still override harness/model/persona as usual.
func (*AgentService) CreateSkill ¶
func (s *AgentService) CreateSkill(ctx context.Context, authorID string, asAdmin bool, name, description, instructions, visibility string) (*model.Skill, error)
CreateSkill adds a skill owned by its author. Any member may define one for themselves; edits and deletion belong to the author. New skills default to private (visibility "").
Publishing is an ADMIN act: a published skill's name and description ride every run's context in the workspace, and any run may invoke it — so a member's skill stays private until an admin publishes it.
func (*AgentService) CreateSubscription ¶
func (s *AgentService) CreateSubscription(ctx context.Context, creatorID, slug, parentID, parentType string, keywords []string, heartbeatMins int, watch WatchInput) (*model.AgentSubscription, error)
func (*AgentService) DeleteSkill ¶
func (s *AgentService) DeleteSkill(ctx context.Context, callerID string, asAdmin bool, id string) error
DeleteSkill removes a skill (author-only).
func (*AgentService) DeleteSubscription ¶
func (s *AgentService) DeleteSubscription(ctx context.Context, creatorID, parentID, id string) error
DeleteSubscription removes a subscription (creator-only).
func (*AgentService) GetAgentBySlug ¶
GetAgentBySlug fetches one shared agent user. An unknown slug is a not-found that names the slug, so the caller (often a model) sees which agent does not exist.
func (*AgentService) GetMemory ¶
GetMemory returns the (agent, invoker) core memory; ("" , nil) when unset.
func (*AgentService) GetPrefs ¶
func (s *AgentService) GetPrefs(ctx context.Context, userID, slug string) (*model.UserAgentPrefs, error)
GetPrefs returns the user's prefs for a slug (zero-value prefs when never customized).
func (*AgentService) GetVisibleSkill ¶
func (s *AgentService) GetVisibleSkill(ctx context.Context, userID, id string) (*model.Skill, error)
GetVisibleSkill fetches a skill only if userID may use it — the author, or anyone once it is published. A private skill owned by someone else reads as not found, so its existence never leaks. This is the check every USE path (run-tool invoke, agent attach) goes through.
func (*AgentService) ListAgents ¶
ListAgents returns the shared agent users (from the template registry).
func (*AgentService) ListSchedules ¶
func (s *AgentService) ListSchedules(ctx context.Context, creatorID string) ([]ScheduleEntry, error)
ListSchedules returns the creator's SCHEDULED orders across every agent — what an agent answers "what have I got scheduled?" from. One indexed query per agent, and there are a handful.
func (*AgentService) ListSkillIndex ¶
ListSkillIndex returns id/name/description only — what a routing hint needs — scoped to what callerID may see and use.
func (*AgentService) ListSkills ¶
ListSkills returns the skills visible to callerID — every published skill plus the caller's own private ones — instructions included. A private skill owned by someone else never appears.
func (*AgentService) ListSubscriptionsFor ¶
func (s *AgentService) ListSubscriptionsFor(ctx context.Context, creatorID, slug string) ([]*model.AgentSubscription, error)
ListSubscriptionsFor returns the creator's subscriptions for one agent.
func (*AgentService) ListWatchersInParent ¶
func (s *AgentService) ListWatchersInParent(ctx context.Context, viewerID, parentID string) ([]*model.AgentSubscription, error)
ListWatchersInParent returns the viewer's OWN watchers in one channel/DM, across all agents — the data the message list uses to badge watched threads. Scoped to the viewer's own subscriptions (a watch is personal, like a reminder), so it never leaks who else is watching.
func (*AgentService) LiveRunners ¶
func (s *AgentService) LiveRunners(ctx context.Context, userID string) ([]*model.RunnerRegistration, error)
LiveRunners returns the user's runners whose lease is still current.
func (*AgentService) PutAgentFollow ¶
func (s *AgentService) PutAgentFollow(ctx context.Context, f *model.AgentThreadFollow) error
PutAgentFollow upserts the (agent, invoker) follow marker for a thread.
func (*AgentService) PutRunner ¶
func (s *AgentService) PutRunner(ctx context.Context, reg *model.RunnerRegistration) error
PutRunner records a runner registration (heartbeat/registration path).
func (*AgentService) PutSubscription ¶
func (s *AgentService) PutSubscription(ctx context.Context, sub *model.AgentSubscription) error
PutSubscription writes a subscription row as-is (flag updates, catch-up bookkeeping). CreateSubscription is the validating entry point for new ones.
func (*AgentService) PutTaskClaim ¶
PutTaskClaim writes a co-invocation task claim iff its label is free.
func (*AgentService) RenameAgent ¶
func (s *AgentService) RenameAgent(ctx context.Context, slug, newName string) (*model.AgentTemplate, error)
RenameAgent changes a shared agent's display name (the @name people see) on both the template and its singleton agent user. Admin-only at the handler.
func (*AgentService) ResetAgentOverrides ¶
ResetAgentOverrides deletes everyone's personal settings for one agent, so the template becomes the effective config for the whole workspace.
DESTRUCTIVE and not undoable: a prefs row is one document, so this clears a person's persona, limits, follow-up settings and pre-approved tool classes for this agent too — not just the harness and model an admin was thinking about. The route is admin-gated and the UI confirms; this returns how many rows it removed so the caller can say so.
func (*AgentService) Resolve ¶
func (s *AgentService) Resolve(ctx context.Context, agent *model.User, invokerID string) (*model.ResolvedAgentConfig, error)
Resolve computes the effective config for a run: the INVOKER's prefs ?? template ?? platform default (plan-v2 §4 — the invoker's, because the run executes on their machine, on their quota, with their prompt).
func (*AgentService) SeedDefaults ¶
func (s *AgentService) SeedDefaults(ctx context.Context) error
SeedDefaults writes the gg/qib templates AND their shared agent users when absent. Boot-time idempotent: existing rows (possibly admin-edited) are never overwritten.
func (*AgentService) SetAgentEngine ¶
func (s *AgentService) SetAgentEngine(ctx context.Context, slug, harness, mdl, executionMode string) (*model.AgentTemplate, error)
SetAgentEngine re-pins an agent template's execution backend: harness, and optionally model + execution mode (admin-gated at the route). Changing the harness with no model given CLEARS the template model — model ids live in a harness's own namespace, and carrying one across harnesses hands the new harness a foreign string (the same rule Resolve applies to prefs).
func (*AgentService) SetAgentPersona ¶
func (s *AgentService) SetAgentPersona(ctx context.Context, slug, persona string) (*model.AgentTemplate, error)
SetAgentPersona replaces the template's prompt — the instructions every member inherits unless they have written their own. Admin-gated at the route.
Blank is refused rather than treated as "clear": Resolve falls back to the template persona, so emptying it would leave everyone without an override running with no instructions at all.
func (*AgentService) SetAgentSkills ¶
func (s *AgentService) SetAgentSkills(ctx context.Context, callerID, slug string, skillIDs []string) (*model.AgentTemplate, error)
SetAgentSkills pins skills to an agent template. Attached skills are injected verbatim into every run's context bundle ("# Attached skills"), so the agent follows them without needing to discover them. Empty list clears. Every id must name an existing skill.
func (*AgentService) SetDMResolver ¶
func (s *AgentService) SetDMResolver(r agentDMResolver)
SetDMResolver wires DM resolution so a subscription can be created without naming a channel (scheduled orders default to the creator's DM).
func (*AgentService) SetIndexer ¶
func (s *AgentService) SetIndexer(i service.UserIndexer)
SetIndexer wires the search indexer. Optional: deployments without a search client resolve user search by linear scan instead, and need no index.
func (*AgentService) SetModelCatalog ¶ added in v0.0.118
func (s *AgentService) SetModelCatalog(c agentModelCatalog)
SetModelCatalog wires the admin's model list, which every model an admin or a member saves for an agent must come from.
func (*AgentService) SetUserLister ¶
func (s *AgentService) SetUserLister(l agentUserLister)
SetUserLister wires the roster walk the override count and reset need.
func (*AgentService) SlugForAgent ¶
SlugForAgent maps a shared agent user id back to its template slug — the id is derived from the slug one way (AgentUserID), so this walks the handful of templates.
func (*AgentService) SubscriptionsByParent ¶
func (s *AgentService) SubscriptionsByParent(ctx context.Context, parentID string) ([]*model.AgentSubscription, error)
SubscriptionsByParent lists every subscription watching one parent.
func (*AgentService) TaskClaims ¶
func (s *AgentService) TaskClaims(ctx context.Context, parentID, threadRootID string) ([]*model.TaskClaim, error)
TaskClaims lists the claims on one thread.
func (*AgentService) Template ¶
func (s *AgentService) Template(ctx context.Context, slug string) (*model.AgentTemplate, error)
Template returns one shared agent's workspace template — the defaults a user's prefs override (the agents page shows the default persona as real, editable text, so it needs the template separately from the resolve).
func (*AgentService) UpdateMemory ¶
func (s *AgentService) UpdateMemory(ctx context.Context, invokerID, agentID, content string) error
UpdateMemory replaces the (agent, invoker) core memory — buzz-style: the agent curates one small document, not an append log.
func (*AgentService) UpdatePrefs ¶
func (s *AgentService) UpdatePrefs(ctx context.Context, userID, slug string, patch AgentPrefsPatch) (*model.UserAgentPrefs, error)
UpdatePrefs applies a user's edits to THEIR prefs for a shared agent. No ownership check — everyone edits only their own row.
func (*AgentService) UpdateSkill ¶
func (s *AgentService) UpdateSkill(ctx context.Context, callerID string, asAdmin bool, id string, patch SkillPatch) (*model.Skill, error)
UpdateSkill applies the author's edits. Admins may edit anyone's skill: a skill is workspace-visible once published, so a bad one is everyone's problem and waiting for its author is not a fix.
func (*AgentService) UpdateSubscription ¶
func (s *AgentService) UpdateSubscription(ctx context.Context, creatorID, parentID, id string, in WatchInput) (*model.AgentSubscription, error)
UpdateSubscription edits a watcher's standing order (creator-only): its instruction and/or action mode. The agent and thread scope are fixed — those define a different watcher, so changing them means remove + re-add. An empty actionMode leaves the mode unchanged; instruction is set as given (may clear). UpdateSubscription rewrites a watcher's standing order. PATCH semantics are FULL-STATE for the order fields (instruction, schedule): the caller sends what the row should now say, so clearing a schedule is just sending none.
func (*AgentService) Wired ¶
func (s *AgentService) Wired() error
type ApprovalRequest ¶
type ApprovalRequest struct {
Summary string
Risk string
// Options non-empty turns the gate into a multiple-choice question
// (ask_user): the invoker picks one instead of approving/denying.
Options []string
// Kind is the harness tool class (read / edit / shell / web) for
// permission-gateway approvals — the card uses it to offer "always allow
// <class> for this agent". Empty = a plain gate.
Kind string
Purpose string
}
ApprovalRequest describes one human-in-the-loop gate.
Purpose is the field that makes a decision verifiable: a gate that later checks "was THIS authorized?" compares purposes for equality instead of searching the summary prose. It is settable only from server-side callers — the agent-facing endpoint always leaves it empty, so a purpose on an approval is proof the server raised that gate itself.
type Assignment ¶
type Assignment struct {
RunID string `json:"runID"`
AgentID string `json:"agentID"`
AgentName string `json:"agentName"`
InvokerID string `json:"invokerID"`
InvokerName string `json:"invokerName"`
ParentID string `json:"parentID"`
ParentType string `json:"parentType"`
ThreadRootID string `json:"threadRootID,omitempty"`
MessageID string `json:"messageID"`
Harness string `json:"harness"`
Model string `json:"model,omitempty"`
Persona string `json:"persona"`
Mode string `json:"mode"`
AskFirst bool `json:"askFirst,omitempty"`
// WatchInstruction + ActionMode drive watcher runs: the standing order and
// how much the agent may do (notify/draft/reply/autonomous).
WatchInstruction string `json:"watchInstruction,omitempty"`
ActionMode string `json:"actionMode,omitempty"`
Prompt string `json:"prompt"`
ContextBundle string `json:"contextBundle"`
ConnectorSlugs []string `json:"connectorSlugs,omitempty"`
// Attachments are the invoking message's files (see Run.AttachmentIDs).
Attachments []RunAttachment `json:"attachments,omitempty"`
// Task is set on coding-task runs (RunModeTask): the workspace manager
// prepares the project checkout from it before the harness starts.
Task *model.TaskSpec `json:"task,omitempty"`
// AutoAllow: harness tool classes the invoker pre-approved for this agent
// (read | edit | shell | web) — the runner's permission gateway skips the
// approval card for them.
AutoAllow []string `json:"autoAllow,omitempty"`
Limits model.AgentLimits `json:"limits"`
MCPToken string `json:"mcpToken"`
LeaseExpiresAt time.Time `json:"leaseExpiresAt"`
Deadline time.Time `json:"deadline"`
}
Assignment is one claimed run handed to a runner.
type CodingTaskService ¶
type CodingTaskService struct {
// contains filtered or unexported fields
}
CodingTaskService is the task layer.
func NewCodingTaskService ¶
func NewCodingTaskService(tasks taskStore, channels taskChannels, messages taskMessages, users orchestratorUsers, agents *AgentService, orch *Orchestrator) *CodingTaskService
NewCodingTaskService wires the task layer.
func (*CodingTaskService) Close ¶
func (s *CodingTaskService) Close(ctx context.Context, callerID, taskID, state string) (*model.CodingTask, error)
Close ends a task by hand from the card: done (its merge requests are open — Ex's part is finished) or abandoned (drop the work; the branch stays on the requester's machine). Requester-only. Until this existed nothing moved a task off mr_created — the merge watcher is v2 — so one shipped task blocked its project's next task indefinitely.
func (*CodingTaskService) Create ¶
func (s *CodingTaskService) Create(ctx context.Context, run *model.Run, in CreateTaskInput) (*CreateTaskResult, error)
func (*CodingTaskService) GetVisible ¶
func (s *CodingTaskService) GetVisible(ctx context.Context, callerID, id string) (*model.CodingTask, error)
GetVisible fetches a task the caller may see (member of its channel).
func (*CodingTaskService) ListByChannel ¶
func (s *CodingTaskService) ListByChannel(ctx context.Context, callerID, channelID string) ([]*model.CodingTask, error)
ListByChannel lists a project channel's tasks for a member.
func (*CodingTaskService) ListProjects ¶
func (s *CodingTaskService) ListProjects(ctx context.Context) ([]*model.CodingProject, error)
ListProjects lists the known projects (products + repos).
func (*CodingTaskService) PublishTestPlan ¶
func (s *CodingTaskService) PublishTestPlan(ctx context.Context, run *model.Run, plan model.TestPlan) (*model.CodingTask, error)
PublishTestPlan records the requester-facing test plan and moves the task to awaiting_user_test. Gates: at least one step and one counter-check; a project with a UI (a frontend repo on the task) must be tested through it, so an API-only handoff is refused there.
func (*CodingTaskService) Report ¶
func (s *CodingTaskService) Report(ctx context.Context, run *model.Run, up TaskUpdate) (*model.CodingTask, error)
Report applies a lifecycle update from a task run: validates the transition, persists, posts the deterministic thread note, refreshes the card. The MR gate is enforced here too (defense in depth): mr_created needs a sign-off on record and at least one MR URL.
func (*CodingTaskService) RequestMR ¶
func (s *CodingTaskService) RequestMR(ctx context.Context, run *model.Run, approvalID string) (status string, t *model.CodingTask, gate *model.Approval, err error)
RequestMR is the hard gate before push + MR. Approved when the requester signed off (card button, or an approval card raised by this very tool); "ask" tells the tool to raise that approval; anything before the requester has tested is not_ready. gate is the approval it raised on the "ask" path — empty when it could not be raised, so an older runner falls back to raising its own card.
func (*CodingTaskService) SetBaseURL ¶
func (s *CodingTaskService) SetBaseURL(u string)
SetBaseURL wires the public origin used for task-thread permalinks.
func (*CodingTaskService) SetSteering ¶
func (s *CodingTaskService) SetSteering(ctx context.Context, callerID, taskID, mode string) (*model.CodingTask, error)
SetSteering flips who may direct the task in chat. Requester-only.
func (*CodingTaskService) SignOff ¶
func (s *CodingTaskService) SignOff(ctx context.Context, callerID, taskID string) (*model.CodingTask, error)
SignOff records the requester's "ship it" from the task card and starts the run that pushes + opens the MRs. Requester-only; the task must be awaiting the requester's test.
func (*CodingTaskService) TaskURL ¶
func (s *CodingTaskService) TaskURL(t *model.CodingTask) string
TaskURL is the permalink to a task's thread (the card message).
func (*CodingTaskService) Wired ¶
func (s *CodingTaskService) Wired() error
type ConnectorIndexEntry ¶
type ConnectorIndexEntry struct {
Slug string
Title string
Description string
AgentUse string // ask | always | never ("" = ask)
}
ConnectorIndexEntry is one row of the ambient connector index — enough for an agent to know the service EXISTS and decide to request it, nothing more.
type ConnectorService ¶
type ConnectorService struct {
// contains filtered or unexported fields
}
ConnectorService manages the connector registry (admin) and per-user installs. Credentials are collected at install time: paste a bearer token, or — for password-kind connectors — sign in and Ex exchanges the credentials for a token server-side (the password is never stored).
func NewConnectorService ¶
func NewConnectorService(s connectorStore) *ConnectorService
func (*ConnectorService) AgentUsePolicy ¶
func (s *ConnectorService) AgentUsePolicy(ctx context.Context, userID, slug string) (policy, title string, err error)
AgentUsePolicy resolves how an agent may attach this connector for this user: ask | always | never. Not installed → never.
func (*ConnectorService) ForRunner ¶
func (s *ConnectorService) ForRunner(ctx context.Context, invokerID string, slugs []string) ([]RunnerConnector, error)
ForRunner returns the invoker's installs, ready to sync to the runner's disk and env — restricted to `slugs`, the run's explicit picks.
Filtering happens BEFORE the fetch on purpose: each bundle is up to 64 files of 350KB, so loading every install and letting the caller discard the rest cost one full bundle read per install on every run start (10 installs, 1 pick = ~10x wasted reads). Empty slugs means no picks, hence nothing to send — the user decides which services a run may touch.
func (*ConnectorService) Ingest ¶
func (s *ConnectorService) Ingest(ctx context.Context, callerID string, in IngestInput) (*model.Connector, error)
Ingest registers or replaces a connector (admin-gated at the route).
func (*ConnectorService) Install ¶
func (s *ConnectorService) Install(ctx context.Context, userID, slug string, in InstallInput) (*model.ConnectorInstall, error)
Install connects the caller to a connector. It resolves a token (pasted or via password grant), verifies it against the connector's VerifyURL, and stores the install. Verify failures with a definite 401/403 reject the credential; network failures accept it as "unverified" so an unreachable staging VPN never blocks usability.
func (*ConnectorService) InstalledIndex ¶
func (s *ConnectorService) InstalledIndex(ctx context.Context, userID string) ([]ConnectorIndexEntry, error)
InstalledIndex lists the user's installed connectors for the ambient bundle index (agent discovery). "never" entries are included — the agent may still tell the user the service exists — but use_connector will refuse them.
func (*ConnectorService) KnownSlugs ¶
KnownSlugs returns the set of registered connector slugs — the orchestrator uses it to tell a real /connector pick apart from prose slashes before recording picks on a run.
func (*ConnectorService) ListForUser ¶
func (s *ConnectorService) ListForUser(ctx context.Context, userID string) ([]ConnectorWithStatus, error)
ListForUser returns the registry with the caller's install status.
func (*ConnectorService) ProviderConfigured ¶
func (s *ConnectorService) ProviderConfigured() bool
ProviderConfigured reports whether a connector-provider is wired.
func (*ConnectorService) RunProviderSync ¶
func (s *ConnectorService) RunProviderSync(ctx context.Context, interval time.Duration)
RunProviderSync keeps the registry in step with the provider until ctx is cancelled: a forced pull at boot (registration changes such as baseURL or auth do not bump the provider revision, so a restart is when they propagate), then a revision-gated pass every interval — an unchanged catalog costs one small listing fetch. Passes run sequentially on the caller's goroutine, so they never overlap, and each one is panic-isolated: the loop lives on a detached goroutine where a single bad pass would otherwise take the whole process down.
func (*ConnectorService) SetAgentUse ¶
func (s *ConnectorService) SetAgentUse(ctx context.Context, userID, slug, mode string) error
SetAgentUse updates the caller's agent-use policy for one installed connector.
func (*ConnectorService) SetProvider ¶
func (s *ConnectorService) SetProvider(baseURL, apiKey string)
SetProvider wires the connector-provider ex pulls from. No-op values (empty URL) leave the feature off.
func (*ConnectorService) SyncFromProvider ¶
func (s *ConnectorService) SyncFromProvider(ctx context.Context, callerID string, force bool) (*SyncResult, error)
SyncFromProvider pulls every PUBLISHED connector from the provider and ingests it (docs + admin auth) into the registry. A connector with no published revision, or no registration (admin hasn't said how to connect it), is skipped with a reason rather than failing the whole sync — one bad source never blocks the rest.
Unless force is set, a connector whose stored revision already matches the provider's is left alone — the periodic sync then costs one listing fetch when nothing changed. force re-ingests everything: registration changes (baseURL, auth) live in the provider's config, not the bundle, so they don't bump the revision — the admin sync endpoint and the boot sync force so those still propagate.
func (*ConnectorService) Uninstall ¶
func (s *ConnectorService) Uninstall(ctx context.Context, userID, slug string) error
Uninstall disconnects the caller from a connector.
func (*ConnectorService) VerifyInstall ¶
func (s *ConnectorService) VerifyInstall(ctx context.Context, userID, slug string) (*model.ConnectorInstall, error)
VerifyInstall re-runs the verify check on an existing install — for installs saved as "unverified" because the service was unreachable at install time. 2xx upgrades to connected; 401/403 reports the token as rejected (the install is kept so the user can Reconnect); network errors leave it unverified.
type ConnectorWithStatus ¶
type ConnectorWithStatus struct {
*model.Connector
Installed bool `json:"installed"`
Status string `json:"installStatus,omitempty"`
ConnectedAs string `json:"connectedAs,omitempty"`
AgentUse string `json:"agentUse,omitempty"`
}
ConnectorWithStatus is a registry entry joined with the caller's install.
type ContextItemStore ¶
type ContextItemStore interface {
PutContextItem(ctx context.Context, it *model.ContextItem) error
GetContextItem(ctx context.Context, parentType, parentID, itemID string) (*model.ContextItem, error)
ListContextItems(ctx context.Context, parentType, parentID string) ([]*model.ContextItem, error)
DeleteContextItem(ctx context.Context, parentType, parentID, itemID string) error
}
ContextItemStore is the store surface ContextService needs.
type ContextService ¶
type ContextService struct {
// contains filtered or unexported fields
}
ContextService owns the shared-context items (CTX#, plan-v2 §8): the curated facts/briefs/decisions every agent run in a parent reads. Humans manage them over REST; agents append via write_shared_context.
func NewContextService ¶
func NewContextService(items ContextItemStore, access contextAccessChecker) *ContextService
NewContextService wires the service.
func (*ContextService) Delete ¶
func (s *ContextService) Delete(ctx context.Context, accessorID, parentID, parentType, itemID string) error
Delete removes an item. Allowed for its author, the invoker of the run that wrote it, or anyone with access when the author was an agent — humans curate what agents accumulate.
func (*ContextService) List ¶
func (s *ContextService) List(ctx context.Context, accessorID, parentID, parentType string) ([]*model.ContextItem, error)
List returns a parent's items, checked against the accessor.
func (*ContextService) SetPinned ¶
func (s *ContextService) SetPinned(ctx context.Context, accessorID, parentID, parentType, itemID string, pinned bool) (*model.ContextItem, error)
SetPinned toggles an item's trim priority. Same edit rights as Delete.
func (*ContextService) Write ¶
func (s *ContextService) Write(ctx context.Context, in ContextWrite) (*model.ContextItem, error)
type ContextWrite ¶
type ContextWrite struct {
AuthorID string
InvokerID string
AccessorID string
ParentID string
ParentType string
Body string
Pinned bool
}
Write appends one item. authorID is who the item is attributed to (a human, or a shared agent — then invokerID says whose run); accessorID is whose permissions gate the write. For humans the two are the same; for agent runs the accessor is the INVOKER (plan-v2 §3 — an agent can never write where the invoker can't). ContextWrite is one shared-context append.
The three IDs are genuinely different and were positional: AuthorID is who wrote it (an agent, for an agent-authored item), InvokerID attributes that agent's invocation, and AccessorID is whose membership gates the write. Six strings and a bool in a row made a swap invisible at a call site.
type CreateAgentInput ¶
type CreateAgentInput struct {
Slug string
DisplayName string
Harness string
Model string
ExecutionMode string
Persona string
}
CreateAgentInput is the admin-supplied definition of a new shared agent.
type CreateTaskInput ¶
type CreateTaskInput struct {
// Project is the PRODUCT name ("CliffHub"), not a repo path.
Project string
// Repos the task touches. Required for a project Ex hasn't seen yet;
// optional afterwards (defaults to every repo the project is known to
// have — untouched repos simply get no MR).
Repos []RepoInput
Title string
Goal string
Kind string
BaseBranch string // default base for repos that don't name one
Ticket *model.TaskTicket
}
CreateTaskInput is what intake resolved from the ask.
type CreateTaskResult ¶
type CreateTaskResult struct {
Task *model.CodingTask
Project *model.CodingProject
ProjectCreated bool
Channel *model.Channel
ChannelCreated bool
URL string
// KickoffErr is set when the task exists but its first run could not
// start (the requester's runner vanished between intake and kickoff).
KickoffErr error
}
CreateTaskResult is what the creating agent learns back.
type Decision ¶
type Decision struct {
Approve bool
// Choice names one of the gate's Options (ask_user); ignored otherwise.
Choice string
Text string
}
Decision is one invoker's verdict on a gate.
Text is mode-overloaded by design, and the naming used to hide it: on a REPLY PROPOSAL it is the edited reply that gets posted; on every other gate it is a note that rides the tool result back to the agent ("no — use the seed DB instead"). Two strings and a bool as positional arguments made that impossible to read at a call site.
type IngestInput ¶
type IngestInput struct {
Slug string `json:"slug"`
Title string `json:"title"`
Description string `json:"description"`
BaseURL string `json:"baseURL"`
AuthKind string `json:"authKind"`
TokenURL string `json:"tokenURL"`
ClientID string `json:"clientID"`
VerifyURL string `json:"verifyURL"`
Files []model.ConnectorFile `json:"files"`
// StartURL + CapturePattern drive sso_window connects (see model.Connector).
StartURL string `json:"startURL,omitempty"`
CapturePattern string `json:"capturePattern,omitempty"`
// AuthHeader: how the credential is sent (see model.Connector.AuthHeader);
// empty = Authorization: Bearer.
AuthHeader string `json:"authHeader,omitempty"`
// CredentialHint + CredentialURL: the instruction shown under the paste
// field and the token page it links to (see model.Connector).
CredentialHint string `json:"credentialHint,omitempty"`
CredentialURL string `json:"credentialURL,omitempty"`
// Revision is set by the provider sync (the bundle's content hash);
// direct admin uploads leave it empty.
Revision string `json:"revision,omitempty"`
}
IngestInput is the admin payload that registers (or replaces) a connector.
type InstallInput ¶
type InstallInput struct {
Token string `json:"token"`
Email string `json:"email"`
Password string `json:"password"`
// Two-factor continuation (second call after ErrTwoFactorRequired).
TwoFactorCode string `json:"twoFactorCode"`
AccessCode string `json:"accessCode"`
}
InstallInput carries the user's credential: a pasted token, or (password connectors) email+password with an optional 2FA continuation.
type IssuedRunnerToken ¶
type IssuedRunnerToken struct {
Token string `json:"token"`
ID string `json:"id"`
Label string `json:"label"`
ExpiresAt time.Time `json:"expiresAt"`
UserName string `json:"userName"`
}
IssuedRunnerToken is a freshly minted or renewed runner token.
type Orchestrator ¶
type Orchestrator struct {
// contains filtered or unexported fields
}
Orchestrator owns the run lifecycle: mention-gated invocation, the claim queue, limit enforcement, leases, and the audit timeline. It is the authoritative side of every bound — the runner enforces the same limits locally only as a fast-fail (plan-v2 §9).
func NewOrchestrator ¶
func NewOrchestrator(runs orchestratorRunStore, agentSvc *AgentService, users orchestratorUsers, messages orchestratorMessages, pub service.Publisher, tokens runTokenMinter) *Orchestrator
NewOrchestrator wires the orchestrator.
func (*Orchestrator) ApprovalGranted ¶
func (o *Orchestrator) ApprovalGranted(ctx context.Context, runID, approvalID, purpose string) (*model.Approval, bool)
ApprovalGranted reports whether approvalID is an APPROVED, unspent decision that authorizes exactly `purpose` (action and target, e.g. "connector:<slug>", "task-mr:<task id>") for this run — and SPENDS it: one "yes" authorizes one action, so a replayed approval id authorizes nothing. This is the check every server-side gate makes before acting on "the invoker said yes".
Purpose equality is the only test. Gates used to accept an approval with no purpose when its summary mentioned the subject — but every approval an agent raises (request_approval) is purpose-less, so an agent could word its own card to unlock a server gate. Such an approval now authorizes no gate; see LegacyApproval for how callers re-ask instead of failing a run that was mid-flight when this changed.
func (*Orchestrator) ApprovalStatus ¶
func (o *Orchestrator) ApprovalStatus(ctx context.Context, runID, approvalID string) (*model.Approval, error)
ApprovalStatus returns the approval, lazily expiring it past its deadline — expiry is discovered by the poll that crosses it, no timer needed. An expired approval reads as denied{approval_timeout} to the agent.
func (*Orchestrator) ArtifactsForCaller ¶
func (o *Orchestrator) ArtifactsForCaller(ctx context.Context, callerID, runID string) (*model.Run, []*model.Artifact, error)
ArtifactsForCaller lists a run's artifacts the caller is allowed to see. Artifacts keep the MEMBER rule the logs gave up: an agent publishes an artifact INTO a conversation (its card renders there for everyone), so anyone who can read that conversation can open it — unlike the timeline, which records the invoker's private tool activity.
func (*Orchestrator) AttachConnector ¶
func (o *Orchestrator) AttachConnector(ctx context.Context, runID, slug, reason string) error
AttachConnector adds a connector to a LIVE run (the use_connector tool): the runner re-fetches the run's connector payload afterwards, so attachment takes effect mid-run. Policy (ask/always/never) is enforced by the handler; this only records the attachment.
func (*Orchestrator) AuthorizeAction ¶
func (o *Orchestrator) AuthorizeAction(ctx context.Context, run *model.Run, action, summary string, args map[string]any) (ActionGate, error)
AuthorizeAction gates one write or exfiltration action (publish an artifact, rewrite memory, post elsewhere, DM someone, call a connector's write endpoint, …) of a run whose TRIGGER its invoker did not write — a watcher woken by another member's message, a catch-up, a periodic check-in, or a hand-off chained from one. Such a run reads someone else's words with the invoker's access; whatever those words say, the invoker decides every action it takes outside its own reply. Trusted runs pass.
The server raises the card itself, worded from the action, and binds it by purpose to the exact action and arguments: the run re-issues the same call after the invoker answers, and that one call — never a different one, and never twice — goes through. A denied action stays denied.
func (*Orchestrator) BundleForRun ¶
BundleForRun re-assembles the bundle fresh for the get_context tool — the thread moves during a run, and the claim-time bundle goes stale.
func (*Orchestrator) ChainFromAgentPost ¶
ChainFromAgentPost inspects an agent's posted message for @mentions of OTHER agents and starts their turns at round+1 — the mention-gated agent-to-agent handoff (plan.md §5). Bounded three ways: the round cap, the per-thread busy dedup, and the no-self-trigger rule.
func (*Orchestrator) Claim ¶
func (o *Orchestrator) Claim(ctx context.Context, ownerID, runnerID string, harnesses []string, max int, wait time.Duration) ([]Assignment, error)
Claim is the runner's long-poll: hand out queued runs for this owner whose harness the runner actually has, up to max. Returns immediately when work exists; otherwise parks until wakeup or the wait budget lapses.
func (*Orchestrator) ClaimTask ¶
func (o *Orchestrator) ClaimTask(ctx context.Context, run *model.Run, label string) (mine bool, lines []string, err error)
ClaimTask atomically claims one part of a co-invoked task for this run's agent — first write wins, so parallel peers can split work ("hindi" / "english") without racing to post. Returns whether WE now hold the label, plus rendered lines for every claim on the thread (so a losing agent sees what's taken and by whom). Labels are normalized: lowercase, collapsed whitespace.
func (*Orchestrator) ClaimWithFeatures ¶
func (o *Orchestrator) ClaimWithFeatures(ctx context.Context, ownerID, runnerID string, harnesses, features []string, max int, wait time.Duration) ([]Assignment, error)
ClaimWithFeatures is Claim for a runner that advertises features (model.RunnerFeature*): a run requiring a feature the runner lacks is left for another runner of the same owner.
func (*Orchestrator) CompleteRun ¶
func (o *Orchestrator) CompleteRun(ctx context.Context, ownerID, runnerID, runID, finalText string, usage map[string]any, attachmentIDs ...string) error
CompleteRun finalizes a successful run. If the agent never posted during the run, the final text is posted on its behalf so the answer always lands in the thread.
func (*Orchestrator) ConsumeDeliberateApproval ¶
ConsumeDeliberateApproval spends ONE deliberate "yes" the invoker granted on this run — the hard server-side check behind reply-mode watchers, which may post publicly only after the invoker says yes, not merely because the prompt told them to. Each public post spends its own approval: one "yes" used to unlock every post up to the run's cap.
"Deliberate" is a plain request_approval answer. It excludes the approvals that mean something else: a permission-gateway click (Kind set, or Risk "tool") is consent for one harness tool call, a reply proposal is consent for the SERVER to post that exact text, and a server-raised gate (Purpose set) authorizes only its own action. Counting any of those as permission to post is how a notify-only watcher talked its way into a channel.
func (*Orchestrator) DecideApproval ¶
func (o *Orchestrator) DecideApproval(ctx context.Context, deciderID, runID, approvalID string, d Decision) (*model.Approval, error)
DecideApproval records the INVOKER's verdict. Nobody else may decide — the run acts with the invoker's permissions, so the risk is theirs.
func (*Orchestrator) DecideCatchUp ¶
func (o *Orchestrator) DecideCatchUp(ctx context.Context, callerID, parentID, subID string, process bool) error
DecideCatchUp is the creator's answer to the catch-up ask: process starts the coalesced run now, dismiss drops the backlog. Creator-only.
func (*Orchestrator) FailRun ¶
func (o *Orchestrator) FailRun(ctx context.Context, ownerID, runnerID, runID, reason string) error
FailRun records a runner-reported failure.
func (*Orchestrator) GetLiveRun ¶
GetLiveRun returns a run only while it's claimable-or-running; terminal runs surface ErrRunClosed so tool stragglers die cleanly.
func (*Orchestrator) Heartbeat ¶
func (o *Orchestrator) Heartbeat(ctx context.Context, reg *model.RunnerRegistration, activeRunIDs []string) (kill []string, err error)
Heartbeat refreshes the runner registration and extends leases for the runs it reports as in flight. Returns runs the runner should kill (they reached a terminal state server-side, e.g. canceled or limit-failed).
func (*Orchestrator) LinkifyMentions ¶
LinkifyMentions rewrites plain-text "@gg" / "@Alice" in an agent's post into the canonical mention markup, so mentions render as real chips, notify humans, and parse for chain dispatch — models write plain @names, not the editor's @[id|name] serialization.
Resolvable names: every shared agent's slug, plus the display names (and unambiguous first names) of this run's thread participants — exactly the people whose names the agent saw in its context bundle. Longest name wins so "@Alice Smith" never half-matches an "@Alice".
func (*Orchestrator) OnMessage ¶
func (o *Orchestrator) OnMessage(ctx context.Context, msg *model.Message, parentType string, conv *model.Conversation)
OnMessage implements AgentDispatcher: every persisted message flows through here off the send path. Human-authored messages that @mention agent users start runs; everything else is inert. Mention-gated by construction — there is no other entry point to StartRun from chat. conv is the conversation the send loaded (nil for a channel post).
func (*Orchestrator) PendingApprovals ¶ added in v0.0.119
func (o *Orchestrator) PendingApprovals(ctx context.Context, userID string) ([]map[string]any, error)
PendingApprovals lists what is still waiting on userID: the approvals, questions and draft replies whose cards a page that loads or reconnects would otherwise never see, since each card arrives once, as an event. One past its deadline is expired on the way (which tells any open page to drop it), never listed.
func (*Orchestrator) ProposeReply ¶
func (o *Orchestrator) ProposeReply(ctx context.Context, run *model.Run, text, threadRoot, replyTo string) (*model.Approval, error)
ProposeReply creates an editable REPLY PROPOSAL: the agent drafted `text` as a reply and the invoker gets a card to approve/edit/cancel it. threadRoot is where it will post (defaults to the run's thread); replyTo is the message it answers, shown for context. Non-blocking — the run can end; DecideApproval posts the (possibly edited) text when the invoker approves.
func (*Orchestrator) PublishArtifact ¶
func (o *Orchestrator) PublishArtifact(ctx context.Context, run *model.Run, kind, title, content string) (*model.Artifact, error)
PublishArtifact stores one run-produced document (size- and count-capped) and audits it on the timeline.
func (*Orchestrator) PurgeThreadLogs ¶
func (o *Orchestrator) PurgeThreadLogs(ctx context.Context, parentID, msgID string)
PurgeThreadLogs deletes the run-event logs — archived S3 objects and any hot DynamoDB rows — for every run tied to a deleted message: the runs that message invoked, and (when msgID is a thread root) every reply run in that thread. Wired into message deletion so a chat's activity logs don't outlive it; deleting a parent chat sweeps all its replies' logs. Best-effort — a run whose log fails to delete is logged, never fatal.
func (*Orchestrator) RecordAgentPost ¶
func (o *Orchestrator) RecordAgentPost(ctx context.Context, runID string) (remaining int, err error)
RecordAgentPost bumps the run's post count (called by the run-tool API after a successful post_message) and reports whether the cap is now exhausted.
func (*Orchestrator) RecordAgentUpload ¶
func (o *Orchestrator) RecordAgentUpload(ctx context.Context, runID string) (remaining int, err error)
RecordAgentUpload counts one stored file against the run's upload cap and returns how many more it may store. The counter is bumped atomically BEFORE the check so two concurrent uploads cannot both squeeze under the cap.
func (*Orchestrator) RecordContextWrite ¶
func (o *Orchestrator) RecordContextWrite(ctx context.Context, run *model.Run, itemID string, pinned bool)
RecordContextWrite audits a write_shared_context tool call on the run's timeline — CTX# writes are governed AND audited (plan-v2 §8).
func (*Orchestrator) RecordMemoryUpdate ¶
RecordMemoryUpdate audits an update_memory tool call.
func (*Orchestrator) RecordSkillInvoked ¶
RecordSkillInvoked audits an invoke_skill call on the run's timeline.
func (*Orchestrator) RecordWorkspaceAction ¶
func (o *Orchestrator) RecordWorkspaceAction(ctx context.Context, run *model.Run, action string, payload map[string]any)
RecordWorkspaceAction audits one workspace tool call (create_channel, join_channel, send_dm, …) on the run's timeline — every cross-workspace action an agent takes is attributable from the drawer.
func (*Orchestrator) RegisterRunner ¶
func (o *Orchestrator) RegisterRunner(ctx context.Context, reg *model.RunnerRegistration) error
RegisterRunner records a runner coming online and nudges its owner's clients, so the Runners page shows that computer as online at once.
func (*Orchestrator) RenderMessages ¶
RenderMessages renders messages in the bundle format ([m:<id>] name hh:mm: body) — the shared renderer behind Window and the pin-listing tool, so every message a tool hands the model carries the same labels and markers.
func (*Orchestrator) ReportEvents ¶
func (o *Orchestrator) ReportEvents(ctx context.Context, ownerID, runnerID, runID string, batch []RunEventInput) (abort bool, reason string, err error)
ReportEvents ingests a runner batch: turns, usage, tool calls, progress. Returns abort=true (with a reason) when a limit tripped and the runner must kill the harness. Every bound is enforced HERE, not on the runner — runner figures only ever move spend toward the caps.
func (*Orchestrator) RequestApproval ¶
func (o *Orchestrator) RequestApproval(ctx context.Context, run *model.Run, req ApprovalRequest) (*model.Approval, error)
RequestApproval opens a pending approval and parks the run's state on ✋. The MCP server polls ApprovalStatus until a decision or the deadline.
func (*Orchestrator) Run ¶
Run returns a run by ID regardless of state. Unchecked — internal callers only (the reconciler, the purge sweep). Anything serving a request uses RunForCaller.
func (*Orchestrator) RunForCaller ¶
func (o *Orchestrator) RunForCaller(ctx context.Context, callerID, runID string) (*model.Run, error)
RunForCaller loads a run the caller is allowed to see (invoker-only).
func (*Orchestrator) RunForParentMember ¶
func (o *Orchestrator) RunForParentMember(ctx context.Context, callerID, runID string) (*model.Run, error)
RunForParentMember loads a run the caller is allowed to STOP: the invoker, or any member of the run's parent — a runaway agent floods THEIR channel, so the brake stays shared even though the logs do not.
func (*Orchestrator) RunMayReadScreen ¶
func (o *Orchestrator) RunMayReadScreen(ctx context.Context, run *model.Run, attachmentID string) bool
RunMayReadScreen reports whether run may download attachmentID as one of its project's reference screenshots.
func (*Orchestrator) RunSkillBadges ¶
func (o *Orchestrator) RunSkillBadges(ctx context.Context, runID string) []string
RunSkillBadges names the skills a run USED, for the badges on its posted messages: the invoking message's /skill picks plus every invoke_skill call so far — never the template's standing skills (they'd tag every reply). Wired into MessageService via SetRunSkillResolver.
func (*Orchestrator) SetApprovalNotifier ¶
func (o *Orchestrator) SetApprovalNotifier(n approvalNotifier)
SetApprovalNotifier wires the special approval notification. Optional — nil still shows the live approval card, just without the extra alert/push.
func (*Orchestrator) SetAttachments ¶
func (o *Orchestrator) SetAttachments(a runAttachments)
SetAttachments wires the attachment service. Optional — without it runs are text-only, exactly as before files reached agents.
func (*Orchestrator) SetConnectorRegistry ¶
func (o *Orchestrator) SetConnectorRegistry(r connectorRegistry)
SetConnectorRegistry enables /connector pick validation on new runs.
func (*Orchestrator) SetContextService ¶
func (o *Orchestrator) SetContextService(svc *ContextService)
SetContextService wires the shared-context layer into bundle assembly.
func (*Orchestrator) SetEventArchive ¶
func (o *Orchestrator) SetEventArchive(a eventArchive)
SetEventArchive enables tiering terminal runs' events to object storage.
func (*Orchestrator) SetGitHost ¶ added in v0.0.119
func (o *Orchestrator) SetGitHost(host string)
SetGitHost names the team's GitLab (AGENT_GIT_HOST, e.g. gitlab.example.com; a URL works too). Runs with a shell are then told to use it with the git and glab already signed in on their machine. Empty leaves that out.
func (*Orchestrator) SetOwnerDMResolver ¶
func (o *Orchestrator) SetOwnerDMResolver(r ownerDMResolver)
SetOwnerDMResolver wires private-DM delivery for notify/draft watcher completions. Optional — nil keeps the old behavior (the answer is suppressed rather than delivered).
func (*Orchestrator) SetProjects ¶
func (o *Orchestrator) SetProjects(p projectResolver)
SetProjects enables project picks and the design-references bundle layer. Optional: nil keeps every run project-less.
func (*Orchestrator) SetRunState ¶
func (o *Orchestrator) SetRunState(ctx context.Context, runID, state string) error
SetRunState handles the MCP set_state tool: validated against the machine emoji set, reflected as the reaction + a timeline row.
func (*Orchestrator) SetServerEngine ¶
func (o *Orchestrator) SetServerEngine(e serverDispatcher)
SetServerEngine wires the backend executor for server-mode API-harness runs.
func (*Orchestrator) SetSkillPrefs ¶
func (o *Orchestrator) SetSkillPrefs(p skillPrefs)
SetSkillPrefs wires per-user skill discovery curation into bundle assembly.
func (*Orchestrator) SetTaskStore ¶
func (o *Orchestrator) SetTaskStore(t orchestratorTasks)
SetTaskStore wires coding-task persistence (plan-coding-agent.md).
func (*Orchestrator) SetTurnCoordinator ¶
func (o *Orchestrator) SetTurnCoordinator(ctx context.Context, c *RedisTurnCoordinator)
SetTurnCoordinator shares the orchestrator's turn state with every other instance through Redis, and subscribes this instance to the claim wakeups the others publish (until ctx ends). Without it the state stays in-process — correct for exactly one instance.
func (*Orchestrator) StartReconciler ¶
func (o *Orchestrator) StartReconciler(ctx context.Context)
StartReconciler recovers active runs after a restart and sweeps deadline breaches on an interval. Lease loss is handled by per-run timers armed at claim/heartbeat; the sweep is the backstop.
func (*Orchestrator) StartTaskRun ¶
func (o *Orchestrator) StartTaskRun(ctx context.Context, task *model.CodingTask, requester *model.User, msg *model.Message, prompt string) error
StartTaskRun starts a run bound to a task: the task's agent, executed for the REQUESTER (their machine, their quota) even when a steering message came from someone else, threaded under the task card, with an explicit prompt. Used for the kickoff after create_coding_task and the sign-off run.
func (*Orchestrator) StopThread ¶
StopThread is the human brake on a runaway conversation: it cancels every live run in the given run's thread and drops queued handoffs, so nothing restarts the chain. Returns how many runs were canceled.
func (*Orchestrator) StopUserAutomations ¶
func (o *Orchestrator) StopUserAutomations(ctx context.Context, userID string) error
StopUserAutomations ends everything agents do on userID's behalf, for account deactivation (UserService's AutomationStopper):
- every standing order the user created — message watchers and clock-driven schedules alike — is deleted, so no sweep or message can start a run for them again (a reactivated account sets them up anew);
- queued handoffs they invoked are dropped;
- every live run they invoked is canceled through the same terminal path as a human stop.
Every step runs even when an earlier one fails; the failures come back joined so the caller can report the deactivation as incomplete.
func (*Orchestrator) ThreadMessages ¶
func (o *Orchestrator) ThreadMessages(ctx context.Context, userID, parentID, parentType, rootID string) ([]*model.Message, error)
ThreadMessages lists a thread's messages (root + replies) for the caller, access-checked by the message service — the whole-thread activity view shows dev's posts and the requester's steering inline with the tool work.
func (*Orchestrator) ThreadSpend ¶
func (o *Orchestrator) ThreadSpend(ctx context.Context, run *model.Run) ThreadSpendSummary
ThreadSpend sums spend over the given run's thread.
func (*Orchestrator) ThreadTimeline ¶
func (o *Orchestrator) ThreadTimeline(ctx context.Context, callerID, parentID, rootID string) ([]*model.Run, []*model.RunEvent, int, error)
ThreadTimeline is every run threaded under one root message (a coding task's card, a debate's opening post), oldest first, with all their events concatenated in time order. "Show activity" on a thread root shows the whole thread's work, not just the run that posted the root.
func (*Orchestrator) ThreadWindow ¶
ThreadWindow renders the run's thread (or recent channel window when the mention was top-level) in bundle format — one line per message, each carrying its stable [m:<id>] label. Also serves the get_thread tool so bundle and tool results share one ID space.
func (*Orchestrator) Timeline ¶
func (o *Orchestrator) Timeline(ctx context.Context, callerID, runID string) (*model.Run, []*model.RunEvent, int, error)
Timeline returns a run's event list for the drawer, access-checked and bounded to the newest maxTimelineEvents (with the number omitted).
func (*Orchestrator) Window ¶
func (o *Orchestrator) Window(ctx context.Context, accessorID, parentID, parentType, threadRootID string, limit int) (string, error)
Window renders ANY parent's recent messages in bundle format, read as the accessor — the read_channel tool's engine as well as ThreadWindow's. The accessor's membership gates it; threadRootID narrows to one thread.
func (*Orchestrator) Wired ¶
func (o *Orchestrator) Wired() error
Wired covers what boot wires. The turn coordinator is attached when the background workers start (it needs their context), so it is not listed.
type ProjectCaller ¶
type ProjectCaller struct {
ID string
Role model.SystemRole
}
ProjectCaller is who is asking: the handler fills it from signed claims.
type ProjectDetail ¶
type ProjectDetail struct {
Project *model.CodingProject `json:"project"`
Screens []*ScreenView `json:"screens"`
CanManage bool `json:"canManage"`
// Theme is the uploaded stylesheet as the agent sees it (never the raw
// file); nil when none was uploaded.
Theme *ThemeView `json:"theme,omitempty"`
}
ProjectDetail is one project with its gallery.
type ProjectInput ¶
type ProjectInput struct {
Name *string `json:"name"`
AppURL *string `json:"appURL"`
Description *string `json:"description"`
DesignNotes *string `json:"designNotes"`
Links *[]model.ProjectLink `json:"links"`
Repos *[]model.ProjectRepo `json:"repos"`
UILibrary *string `json:"uiLibrary"`
// ThemeCSS sets the project's main stylesheet ("" removes it);
// ThemeFilename names it for display.
ThemeCSS *string `json:"themeCSS"`
ThemeFilename *string `json:"themeFilename"`
}
ProjectInput is a create or patch of a project. Nil fields are untouched on a patch.
type ProjectService ¶
type ProjectService struct {
// contains filtered or unexported fields
}
ProjectService manages projects as the Projects page sees them (plan-projects-design.md): the product identity coding tasks already learn (key, name, repos) plus the design references the design agent copies from — app link, description, design notes, links and labelled screenshots of real pages.
Permissions: every member reads and maintains references (screens, notes, links, description) — freshness depends on many hands, and screenshots are low risk. Renaming, deleting and editing repos drive coding tasks and MRs, so they stay with the project's creator and admins. Guests see nothing.
func NewProjectService ¶
func NewProjectService(s projectStore, a projectAttachments) *ProjectService
NewProjectService wires the service.
func (*ProjectService) AddScreen ¶
func (s *ProjectService) AddScreen(ctx context.Context, caller ProjectCaller, key string, in ScreenInput) (*model.ProjectScreen, error)
AddScreen adds a reference screenshot. The image is an attachment the caller uploaded through the normal upload flow; the screen takes a reference on it so it outlives the upload's draft state.
func (*ProjectService) Create ¶
func (s *ProjectService) Create(ctx context.Context, caller ProjectCaller, in ProjectInput) (*model.CodingProject, error)
Create registers a new project. The key derives from the name, the same way coding tasks derive it, so a project created here and one learned by dev are the same product.
func (*ProjectService) Delete ¶
func (s *ProjectService) Delete(ctx context.Context, caller ProjectCaller, key string) error
Delete removes a project and its gallery (manage rights). Coding tasks keep their own copy of the project's name and repos, so history survives.
func (*ProjectService) DeleteScreen ¶
func (s *ProjectService) DeleteScreen(ctx context.Context, caller ProjectCaller, key, id string) error
DeleteScreen removes a screen and releases its image (any member).
func (*ProjectService) DesignLayer ¶
func (s *ProjectService) DesignLayer(ctx context.Context, projectKey string) string
DesignLayer renders the bundle section for a design run. With a project: what it is, its notes and links, and the screen catalog (one line per screen; images are fetched on demand). Without one: the projects that have references, so the agent can ask which one is meant.
func (*ProjectService) Get ¶
func (s *ProjectService) Get(ctx context.Context, caller ProjectCaller, key string) (*ProjectDetail, error)
Get returns one project and its gallery with image URLs resolved.
func (*ProjectService) List ¶
func (s *ProjectService) List(ctx context.Context, caller ProjectCaller) ([]*ProjectSummary, error)
List returns every project with gallery counts, by name.
func (*ProjectService) ProjectByName ¶
func (s *ProjectService) ProjectByName(ctx context.Context, text string) string
ProjectByName finds the project a message talks about by name or key, as whole words, case-insensitive ("the CliffHub booking page" → cliffhub). The longest matching name wins so "Booking Portal Admin" beats "Booking Portal". "" when nothing matches.
func (*ProjectService) ProjectByToken ¶
func (s *ProjectService) ProjectByToken(ctx context.Context, candidates []string) string
ProjectByToken returns the key of the first candidate /token that names a project, or "".
func (*ProjectService) ScreenImage ¶
func (s *ProjectService) ScreenImage(ctx context.Context, projectKey, attachmentID string) bool
ScreenImage reports whether attachmentID is the image of one of the project's screens — the run-scoped read rule: a run about a project may fetch that project's reference screenshots, and nothing else through this path.
func (*ProjectService) Screens ¶
func (s *ProjectService) Screens(ctx context.Context, key string) ([]*model.ProjectScreen, error)
Screens returns a project's screens in gallery order: page, then desktop before mobile, then state.
func (*ProjectService) SetPublisher ¶
func (s *ProjectService) SetPublisher(p service.Publisher)
SetPublisher wires the real-time nudge: every change publishes project.changed so open Projects pages refetch. Optional (nil = silent).
func (*ProjectService) Update ¶
func (s *ProjectService) Update(ctx context.Context, caller ProjectCaller, key string, in ProjectInput) (*model.CodingProject, error)
Update patches a project. Name and repos need manage rights; references (app link, description, notes, links) any member may maintain.
func (*ProjectService) UpdateScreen ¶
func (s *ProjectService) UpdateScreen(ctx context.Context, caller ProjectCaller, key, id string, in ScreenInput) (*model.ProjectScreen, error)
UpdateScreen edits a screen's labels or replaces its image (any member). A new image counts as a fresh screenshot: the freshness date moves.
func (*ProjectService) Wired ¶
func (s *ProjectService) Wired() error
type ProjectSummary ¶
type ProjectSummary struct {
*model.CodingProject
ScreenCount int `json:"screenCount"`
// OldestScreenAt drives the list's freshness hint; nil when no screens.
OldestScreenAt *time.Time `json:"oldestScreenAt,omitempty"`
}
ProjectSummary is one row of the Projects list.
type RedisTurnCoordinator ¶
type RedisTurnCoordinator struct {
// contains filtered or unexported fields
}
RedisTurnCoordinator shares the orchestrator's turn state across instances. Every failure degrades in the direction the notification contract prefers — an extra turn, a duplicate typing frame — never a silently dropped reply.
func NewRedisTurnCoordinator ¶
func NewRedisTurnCoordinator(rdb redis.UniversalClient) *RedisTurnCoordinator
NewRedisTurnCoordinator wraps an existing go-redis client (built through redisx.Options like every other Redis client in the app).
type RepoUpdate ¶
type RepoUpdate struct {
Path string
Branch string
BaseBranch string
WorkspaceDir string
MRURL string
Changed *bool
}
RepoUpdate is one repo's slice of a lifecycle report.
type RunAttachment ¶
type RunAttachment struct {
ID string `json:"id"`
MessageID string `json:"messageID"`
Filename string `json:"filename"`
ContentType string `json:"contentType"`
Size int64 `json:"size"`
}
RunAttachment describes one input file of a run for the runner: enough to show the model what was attached and to fetch the bytes by ID.
type RunEventInput ¶
type RunEventInput struct {
Seq int64 `json:"seq"`
Type string `json:"type"` // "turn" | "usage" | "progress" | "tool" | "state"
Payload map[string]any `json:"payload,omitempty"`
}
RunEventInput is one runner-reported event. Seq is the runner's own monotonic counter (from 1) so retried batches are idempotent.
type RunnerConnector ¶
type RunnerConnector struct {
Slug string `json:"slug"`
Title string `json:"title"`
Description string `json:"description"`
BaseURL string `json:"baseURL"`
EnvPrefix string `json:"envPrefix"`
Token string `json:"token"`
// AuthHeader: header template the runner sends the token in (empty =
// Authorization: Bearer) — see model.Connector.AuthHeader.
AuthHeader string `json:"authHeader,omitempty"`
Files []model.ConnectorFile `json:"files"`
Services []model.ConnectorServiceInfo `json:"services,omitempty"`
}
RunnerConnector is one installed connector shipped to the runner: docs bundle + the invoker's token + the env prefix agents use.
type RunnerTokenService ¶
type RunnerTokenService struct {
// contains filtered or unexported fields
}
RunnerTokenService owns pairing, renewal and revocation of ex-runner installs.
func NewRunnerTokenService ¶
func NewRunnerTokenService(st RunnerTokenStore, users runnerTokenUsers, jwt runnerTokenMinter) *RunnerTokenService
NewRunnerTokenService wires the service.
func (*RunnerTokenService) ConnectWorkbench ¶ added in v0.0.119
func (s *RunnerTokenService) ConnectWorkbench(ctx context.Context, userID string) (*WorkbenchJob, error)
ConnectWorkbench issues a runner token for the user and onboards them on the workbench. The install is stored either way: while the workbench is being tested a failed onboarding keeps its token to look into, and disconnecting "Agent workbench" from the Runners list allows another try.
func (*RunnerTokenService) CreateGrant ¶
func (s *RunnerTokenService) CreateGrant(ctx context.Context, userID, challenge, label string) (code string, expiresAt time.Time, err error)
CreateGrant records the signed-in user's approval of one pairing attempt and returns the one-time code the browser hands to the CLI.
func (*RunnerTokenService) Exchange ¶
func (s *RunnerTokenService) Exchange(ctx context.Context, code, verifier string) (*IssuedRunnerToken, error)
Exchange redeems a one-time code plus its PKCE verifier for a runner token. The grant is consumed BEFORE any check, so a wrong verifier burns the code — no retries against one code.
func (*RunnerTokenService) List ¶
func (s *RunnerTokenService) List(ctx context.Context, userID string) ([]*model.RunnerToken, error)
List returns the user's live runner installs, newest first.
func (*RunnerTokenService) Renew ¶
func (s *RunnerTokenService) Renew(ctx context.Context, claims *model.TokenClaims) (*IssuedRunnerToken, error)
Renew extends a live install's token by another RunnerTokenTTL. The jti stays the same, so revoking the install still kills old and new JWTs alike — and a renewal whose response is lost leaves the old token working.
func (*RunnerTokenService) Revoke ¶
func (s *RunnerTokenService) Revoke(ctx context.Context, userID, id string) error
Revoke removes one of the user's own installs. Someone else's install answers ErrNotFound — exactly like a missing one, so IDs can't be probed.
func (*RunnerTokenService) RevokeAllForUser ¶
func (s *RunnerTokenService) RevokeAllForUser(ctx context.Context, userID string) error
RevokeAllForUser disconnects every runner the user has paired — account deactivation and password reset.
func (*RunnerTokenService) RevokeSelf ¶
func (s *RunnerTokenService) RevokeSelf(ctx context.Context, claims *model.TokenClaims) error
RevokeSelf is `ex-runner logout`: the runner retires its own token. Already-gone is success — there is nothing left to undo.
func (*RunnerTokenService) RunnerTokenActive ¶
func (s *RunnerTokenService) RunnerTokenActive(ctx context.Context, claims *model.TokenClaims) (bool, error)
RunnerTokenActive is the runner middleware's revocation check: the install still exists AND its owner is still an active account. Deactivation also revokes every install, but that sweep can fail or lag; the runner acts with the owner's access, so a deactivated owner is refused here on every request.
func (*RunnerTokenService) SetPublisher ¶
func (s *RunnerTokenService) SetPublisher(p service.Publisher)
SetPublisher lets the service tell a user's clients that their runners changed (the Runners list refetches). Optional: nil publishes nothing.
func (*RunnerTokenService) SetWorkbench ¶ added in v0.0.119
func (s *RunnerTokenService) SetWorkbench(w Workbench)
SetWorkbench turns Connect to Claude on. Optional: nil leaves it off.
func (*RunnerTokenService) UseWorkbenchURL ¶ added in v0.0.119
func (s *RunnerTokenService) UseWorkbenchURL(baseURL, apiToken, server string)
UseWorkbenchURL turns Connect to Claude on for the workbench at baseURL, called with apiToken, whose runners connect back to server. An empty baseURL leaves it off.
func (*RunnerTokenService) Wired ¶
func (s *RunnerTokenService) Wired() error
func (*RunnerTokenService) WorkbenchEnabled ¶ added in v0.0.119
func (s *RunnerTokenService) WorkbenchEnabled() bool
WorkbenchEnabled reports whether Connect to Claude is available.
func (*RunnerTokenService) WorkbenchStatus ¶ added in v0.0.119
func (s *RunnerTokenService) WorkbenchStatus(ctx context.Context, userID string) (*WorkbenchJob, error)
WorkbenchStatus reports how the user's workbench onboarding is going. An install whose onboarding the workbench never took reads as failed.
type RunnerTokenStore ¶
type RunnerTokenStore interface {
PutRunnerGrant(ctx context.Context, g *model.RunnerGrant) error
TakeRunnerGrant(ctx context.Context, codeHash string) (*model.RunnerGrant, error)
PutRunnerToken(ctx context.Context, t *model.RunnerToken) error
GetRunnerToken(ctx context.Context, id string) (*model.RunnerToken, error)
SetRunnerTokenExpiry(ctx context.Context, id string, expiresAt time.Time) error
ListRunnerTokens(ctx context.Context, userID string) ([]*model.RunnerToken, error)
DeleteRunnerToken(ctx context.Context, id string) error
DeleteAllRunnerTokensForUser(ctx context.Context, userID string) error
}
RunnerTokenStore persists runner tokens and pairing grants.
type ScheduleEntry ¶
type ScheduleEntry struct {
Slug string
Sub *model.AgentSubscription
}
ScheduleEntry pairs a scheduled order with the agent that carries it out.
type ScreenInput ¶
type ScreenInput struct {
Page *string `json:"page"`
Description *string `json:"description"`
Viewport *string `json:"viewport"`
State *string `json:"state"`
SeenBy *string `json:"seenBy"`
Route *string `json:"route"`
AttachmentID *string `json:"attachmentID"`
}
ScreenInput is a create or patch of one screen. Nil fields are untouched on a patch; AttachmentID replaces the image.
type ScreenView ¶
type ScreenView struct {
*model.ProjectScreen
ImageURL string `json:"imageURL,omitempty"`
ThumbnailURL string `json:"thumbnailURL,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
}
ScreenView is a screen with its image resolved for the gallery.
type ServerEngine ¶
type ServerEngine struct {
// contains filtered or unexported fields
}
ServerEngine executes API-harness runs in the backend: the bedrock Converse loop with in-process tools (connector calls + connector docs), no desktop app involved. It is the ExecutionServer counterpart of the desktop runner's bedrock harness — same protocol, same run lifecycle, same audit trail.
func NewServerEngine ¶
func NewServerEngine(orch *Orchestrator, connectors *ConnectorService, client bedrock.Client) *ServerEngine
NewServerEngine wires the backend executor. The orchestrator gains the dispatcher via SetServerEngine — done by the caller so the two can be constructed in either order.
func (*ServerEngine) Dispatch ¶
func (e *ServerEngine) Dispatch(runID string)
Dispatch hands a queued run to the engine. Non-blocking: execution happens on its own goroutine, gated by the concurrency semaphore. The goroutine is panic-isolated: a bug in one run is a logged error, never a process crash that drops every WebSocket client on the instance — and the deferred release still hands the concurrency slot back.
func (*ServerEngine) InferenceProfileCount ¶ added in v0.0.122
func (e *ServerEngine) InferenceProfileCount() int
InferenceProfileCount reports how many models are called through an inference profile; 0 means model ids go to Bedrock as given.
func (*ServerEngine) SetInferenceProfiles ¶ added in v0.0.122
func (e *ServerEngine) SetInferenceProfiles(profiles map[string]string)
SetInferenceProfiles names the application inference profile to call each model through (model id → profile ARN). The profile is what attributes a call's cost to this deployment. A model with no entry is called by its own id: whether calls outside a profile are allowed is the AWS account's policy to decide, not this server's.
func (*ServerEngine) SetRunAPIBase ¶
func (e *ServerEngine) SetRunAPIBase(base string)
SetRunAPIBase wires the loopback address of the server's own run-tool API (e.g. "http://127.0.0.1:8080"); empty leaves the bridged tools off.
func (*ServerEngine) Wired ¶
func (e *ServerEngine) Wired() error
type SkillPatch ¶
type SkillPatch struct {
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
Instructions *string `json:"instructions,omitempty"`
Visibility *string `json:"visibility,omitempty"`
}
SkillPatch is the editable slice of a skill. Visibility flips private ↔ published — author-only, like every other edit.
type SyncResult ¶
type SyncResult struct {
Synced []string `json:"synced"`
Unchanged []string `json:"unchanged,omitempty"` // revision matched; not re-pulled
Skipped map[string]string `json:"skipped,omitempty"` // slug → reason
}
SyncResult reports what one provider sync did.
type TaskUpdate ¶
type TaskUpdate struct {
State model.TaskState
Note string
Repos []RepoUpdate
}
TaskUpdate is one lifecycle report from a task run (runner or agent).
type ThemeView ¶
type ThemeView struct {
Filename string `json:"filename"`
Size int `json:"size"`
Variables int `json:"variables"`
Summary string `json:"summary"`
UpdatedBy string `json:"updatedBy"`
UpdatedAt time.Time `json:"updatedAt"`
}
ThemeView describes a project's theme stylesheet and its condensed form.
type ThreadSpendSummary ¶
type ThreadSpendSummary struct {
Runs int `json:"runs"`
Active int `json:"active"`
Turns int `json:"turns"`
InputTokens int64 `json:"inputTokens"`
OutputTokens int64 `json:"outputTokens"`
Posts int `json:"posts"`
}
ThreadSpendSummary aggregates spend across every run in one conversation thread — the drawer's "whole conversation" line (a chained debate is many runs; per-run spend alone reads as zeros on a fresh round).
func SpendOf ¶
func SpendOf(runs []*model.Run) ThreadSpendSummary
SpendOf totals spend across runs the caller ALREADY has — the whole-thread drawer view was re-running the same 100-run listing purely to add this line.
type WatchInput ¶
type WatchInput struct {
ThreadRootID string
Instruction string
ActionMode string
// Schedule (five-field cron) turns the row into a clock-driven standing
// order instead of a message watcher. ScheduleTZ is optional: empty adopts
// the CREATOR's profile timezone, so "0 8 * * 1-5" means 08:00 where they
// are.
Schedule string
ScheduleTZ string
// Tools this order may reach for. Skills are validated against what the
// creator may see; connector slugs are filtered against the live registry
// when the run starts (a service can be removed after scheduling).
ConnectorSlugs []string
SkillIDs []string
}
CreateSubscription makes an agent watch a channel FOR the creator: matches run on their machine and quota. WatchInput carries the optional standing-order fields of a watcher on top of the base channel-subscription params.
type Workbench ¶ added in v0.0.119
type Workbench interface {
// Onboard queues setting up a runner for username with runnerToken
// and returns the job's id.
Onboard(ctx context.Context, username, runnerToken string) (string, error)
// Job reports how an onboarding is going.
Job(ctx context.Context, id string) (*WorkbenchJob, error)
}
Workbench is the agent workbench's onboarding API.
type WorkbenchClient ¶ added in v0.0.119
type WorkbenchClient struct {
// contains filtered or unexported fields
}
WorkbenchClient calls the workbench's onboarding API.
func NewWorkbenchClient ¶ added in v0.0.119
func NewWorkbenchClient(baseURL, apiToken, server string) *WorkbenchClient
NewWorkbenchClient returns a client for the workbench at baseURL that authenticates with apiToken and tells it to connect runners to server.
func (*WorkbenchClient) Job ¶ added in v0.0.119
func (c *WorkbenchClient) Job(ctx context.Context, id string) (*WorkbenchJob, error)
Job gets <url>/onboard/<id>.
type WorkbenchJob ¶ added in v0.0.119
type WorkbenchJob struct {
ID string `json:"id"`
State string `json:"state"`
Username string `json:"username,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
StartedAt string `json:"started_at,omitempty"`
FinishedAt string `json:"finished_at,omitempty"`
Status json.RawMessage `json:"status,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
}
WorkbenchJob is one onboarding on the workbench. State is queued, running, done or failed; Status and Result are the workbench's own, passed through.
Source Files
¶
- agent.go
- codingtask.go
- connector.go
- connectorsync.go
- context.go
- doc.go
- gitaccess.go
- must.go
- orchestrator.go
- orchestrator_coord.go
- orchestrator_deactivation.go
- orchestrator_gates.go
- orchestrator_project.go
- orchestrator_task.go
- project.go
- project_agent.go
- project_theme.go
- runnertoken.go
- serverengine.go
- serverengine_bridge.go
- wired.go
- workbench.go