/** * Agent-scoped endpoints of the TeamShare REST client: identity, inbox, * settings, run/link tokens, folder links, diagnostics and runtime state. * Split out of api.ts (1200-line-per-file rule). */ import { ApiCore } from './api-core'; import type { AgentMention } from './api-types'; export declare class AgentEndpoints extends ApiCore { heartbeat(agentId: string, status: 'online' | 'working' | 'offline', taskId?: string, sessionId?: string, force?: boolean): Promise; inbox(agentId: string): Promise<{ tasks: Array>; comments: Array>; mentions: Array>; chat: Array>; }>; /** * The mention records for this agent, oldest first. * * This is the durable replacement for the inbox's `@` body scan: each * row is a real, addressed question with an identity the hub and the bridge * both agree on. * * The route is `/agents/self/...`, so the agent is whatever key the client * carries and the leading parameter is only kept so an existing caller does * not have to change. It is deliberately optional: the task brief reads the * ledger and has no agent id to hand. */ listMentions(_agentId?: string, opts?: { pendingOnly?: boolean; projectId?: string; limit?: number; }): Promise<{ items: AgentMention[]; }>; /** * Claim a mention for work. `claimed: false` is the authoritative * "someone already has it, or it is answered" - it replaces the old * "is my answer in the newest 50 messages?" guess, which silently missed a * reply to an older mention and could post a duplicate. */ triggerMention(agentId: string, mentionId: string): Promise<{ claimed: boolean; mention: AgentMention | null; }>; /** Close a mention once the reply is delivered. Idempotent. */ answerMention(agentId: string, mentionId: string, answerMessageId?: string | null): Promise; /** * Agent steering (2026-09): pending human instructions for this session's * scope, marked delivered. Used by the `--self` loop; harnesses call the MCP * `get_instructions` tool directly. */ listInstructions(scope: { taskId?: string | null; projectId?: string | null; orchestratorTaskId?: string | null; channelId?: string | null; documentId?: string | null; }): Promise>; /** * Record a run hygiene note for THIS agent (2026-11-18). * * The turn watchdog warns an agent that its model turn has gone silent; the * agent cannot see the bridge console, so the warning is posted as an * instruction it reads at its next `get_instructions` checkpoint. Not a human * steer: the hub creates no mirror comment and no wake. * * Best-effort by design - a failed note must never affect the run. */ createSelfInstruction(scope: { projectId?: string | null; taskId?: string | null; body: string; }): Promise<{ id: string; deduped: boolean; }>; /** * Phase D settings snapshot for sessions spawned outside the daemon / * deep-link paths (which inject settings via flags): the CLI fetches this * so direct `run`/`chat`/`doc` sessions apply the agent's stored * model/temperature/maxTokens/systemPrompt (flag > agent > env > default). * The BYOK `providerKey` is only present under the agent's own key auth. */ getAgentSettings(agentId: string, timeoutMs?: number): Promise<{ userId?: string | null; /** Agent display name (the linked user's name). */ agentName?: string | null; /** Human user that created the agent. */ ownerId?: string | null; ownerName?: string | null; ownerEmail?: string | null; model: string | null; temperature: number | null; maxTokens: number | null; reasoningEffort: string | null; systemPrompt: string | null; harness: 'auto' | 'opencode' | 'claude' | 'codex' | 'gemini' | 'antigravity' | 'copilot' | 'goose' | 'openhands' | 'aider' | 'cline' | 'none' | null; providerKey: string | null; /** Per-provider BYOK keys (provider slug -> plaintext; own-key auth only). */ providerKeys?: Record | null; /** Default working folder (per-agent linked folder). */ folderPath?: string | null; }>; /** * Agent self-service settings patch (`PATCH /agents/:id/settings`). * Currently only `folderPath` (null clears) - used by * `teamshare-agent set-folder --agent --path ` so the agent * can move its own working folder from any machine. */ patchAgentSettings(agentId: string, body: { folderPath?: string | null; }): Promise<{ id: string; folderPath: string | null; }>; mintRunToken(agentId: string, taskId?: string): Promise<{ token: string; expiresAt: string; }>; redeemRunToken(runToken: string, taskId?: string): Promise<{ wsToken: string; agentId: string; scopes: string[]; settings?: { model?: string | null; temperature?: number | null; maxTokens?: number | null; systemPrompt?: string | null; harness?: 'auto' | 'opencode' | 'claude' | 'codex' | 'gemini' | 'antigravity' | 'copilot' | 'goose' | 'openhands' | 'aider' | 'cline' | 'none' | null; backgroundSessions?: boolean | null; }; }>; redeemLinkToken(linkToken: string): Promise<{ agentId: string; projectId: string; path: string | null; }>; setLinkedFolder(agentId: string, projectId: string, path: string, opts?: { siblingAgentIds?: string[]; machineId?: string; machineLabel?: string; }): Promise<{ id: string; folderPath: string | null; }>; /** Clears this machine's folder link for a project (owner's own machine). */ unlinkFolder(agentId: string, projectId: string, machineId: string): Promise<{ ok: true; }>; /** * Posts an automatic bridge diagnostic report (crash/error/warning) with * full context. The server upserts by `(agentId, fingerprint)` so a * recurring problem bumps `occurrences` instead of flooding the table. */ reportDiagnostic(agentId: string, body: { kind: string; severity: 'fatal' | 'error' | 'warning'; message: string; errorCode?: string; stack?: string; fingerprint?: string; context?: Record; doctorReport?: string; logTail?: string; }): Promise<{ id: string; status: string; occurrences: number; }>; /** Pushes per-agent busy/queued/kind + linked-project folders to the backend. */ pushBridgeState(agentId: string, body: { busy: boolean; kind?: 'task' | 'chat' | 'doc' | 'board' | 'build' | 'orchestrator' | 'tool' /** Blog authoring session (IMP-9xx). */ | 'blog' /** Insights harness session (2026-10). */ | 'insight' /** Custom workflow session (2026-10). */ | 'workflow' /** Workflow authoring session (2026-10). */ | 'workflow-author'; since?: string; taskId?: string; queued: number; machineId?: string; machineLabel?: string; projects: Record; }): Promise<{ ok: true; }>; /** * Reports the harness-native session id for a run (once per run, best * effort). Lets the cloud correlate a TeamShare session with its harness * conversation. Never throws from the caller's perspective (callers use * `.catch(() => {})`). */ reportHarnessSession(agentId: string, body: { taskId?: string; mode: string; harness: string; harnessSessionId: string; }): Promise<{ ok: true; sessionId?: string; }>; }