import type { AuthStatusResponse, VaultEntryMeta, Task, Mission, AgentConfig, ProjectLoopConfig, LoopRunFilters, LoopRunRecord, AgentProcess, Team, PolpoState, PolpoConfig, HealthResponse, TaskFilters, CreateTaskRequest, UpdateTaskRequest, CreateMissionRequest, UpdateMissionRequest, AddMissionTaskRequest, UpdateMissionTaskRequest, ReorderMissionTasksRequest, AddMissionCheckpointRequest, UpdateMissionCheckpointRequest, AddMissionDelayRequest, UpdateMissionDelayRequest, ActiveDelay, AddMissionQualityGateRequest, UpdateMissionQualityGateRequest, AddMissionTeamMemberRequest, UpdateMissionTeamMemberRequest, UpdateMissionNotificationsRequest, AddAgentRequest, UpdateAgentRequest, UpdateSettingsRequest, AddTeamRequest, UpdateTeamRequest, ExecuteMissionResult, ResumeMissionResult, LogSession, LogEntry, ChatSession, ChatMessage, ChatCompletionRequest, ContinueClientToolResultRequest, ChatCompletionResponse, ChatCompletionChunk, ChatSuggestion, AskUserPayload, MissionPreviewPayload, VaultPreviewPayload, OpenFilePayload, NavigateToPayload, OpenTabPayload, RunActivityEntry, TaskActivityPayload, SkillInfo, LoadedSkill, SkillWithAssignment, SkillIndexEntry, SkillIndex, SkillBundle, NotificationChannelConfig, NotificationRecord, NotificationStats, SendNotificationRequest, SendNotificationResult, ApprovalRequest, ApprovalStatus, ScheduleEntry, Schedule, ScheduleMutationOptions, ScheduleRun, ScheduleRunStatus, ScheduleStatus, CreateScheduleInput, UpdateScheduleInput, CreateScheduleRequest, UpdateScheduleRequest, TriggerScheduleRequest, DeleteScheduleResult, PlaybookInfo, PlaybookDefinition, PlaybookRunResult, CreatePlaybookRequest, CreateSkillRequest, InstallSkillsResult, InstallSkillsOptions, FileRoot, FileEntry, FilePreview, SandboxVolumeCatalog, SandboxVolumeResource, SandboxVolumeGrant, CreateSandboxVolumeInput, UpdateSandboxVolumeInput, SetSandboxVolumeGrantInput, CreateMemoryItemInput, MemoryItem, MemoryItemsPage, MemoryItemUsage, MemoryItemPatch, MemorySearchResult, ListMemoryItemsQuery, ListMemoryItemsPageQuery, SearchMemoryRequest, ListMemoryCandidatesQuery, MemoryCandidatesPage, MemoryExtractionAuditEvent, MemoryExtractionCandidate, DecideMemoryCandidateInput, ApplyMemoryCandidateInput, AppliedMemoryCandidate, BrainScope, BrainSource, BrainSourceFilters, BrainSourceListResult, BrainRetrievalResult, BrainSourceVersion, ReadBrainSourceRequest, ReadBrainSourceResult, CreateBrainSourceRequest, BrainUpdateSourceRequest, BrainReindexSourceRequest, SearchBrainRequest, SteerRunResult, AbortRunResult, SteeringMessageInput, SteeringJsonValue, ChannelProviderDescriptor, ChannelProvisioningResult, ConfigureConversationChannelInput, ConversationChannel, ConversationChannelQuery, ConversationChannelRoute, UpdateConversationChannelInput, UpsertConversationChannelRouteInput, RunStreamEvent, RunEventStreamOptions, CancelRunResult, ChatStreamConnectionState } from "./types.js"; export interface PolpoClientConfig { baseUrl: string; /** @deprecated No longer used. Kept for backwards compatibility. */ projectId?: string; apiKey?: string; fetch?: typeof globalThis.fetch; /** API path prefix. Default: "/v1" for polpo.sh, "/api/v1" for self-hosted. */ apiPrefix?: string; /** * Default end-user identifier (OpenAI-compat `user`). When set, every * `chatCompletions` / `chatCompletionsStream` / task / mission call that * doesn't supply its own `user` will inherit this value. The intended * pattern is: read your authenticated end-user id once (Supabase / Clerk / * NextAuth / whatever) and pass it here; every subsequent SDK call will * carry it without further wiring. */ user?: string; } /** * Async-iterable streaming response from chat completions. * Exposes `sessionId` from the server's `x-session-id` response header, * which lets callers learn which session was created/reused. */ export declare class ChatCompletionStream implements AsyncIterable { /** Session ID assigned by the server. Available after the first `next()` call. */ sessionId: string | null; /** Monotonic transcript version after this completion is persisted. */ sessionVersion: number | null; /** Active Run id used by steering APIs. Available after start() or first next(). */ runId: string | null; /** Last fully processed durable SSE cursor. */ lastEventId: string | null; /** If the stream ended with finish_reason "ask_user", this contains the questions. */ askUser: AskUserPayload | null; /** Suggested next messages emitted before the stream closes. */ suggestions: ChatSuggestion[]; /** If the stream ended with finish_reason "mission_preview", this contains the proposed mission. */ missionPreview: MissionPreviewPayload | null; /** If the stream ended with finish_reason "vault_preview", this contains the proposed vault entry. */ vaultPreview: VaultPreviewPayload | null; /** If the stream ended with finish_reason "open_file", this contains the file path to open. */ openFile: OpenFilePayload | null; /** If the stream ended with finish_reason "navigate_to", this contains navigation target info. */ navigateTo: NavigateToPayload | null; /** If the stream ended with finish_reason "open_tab", this contains the URL to open. */ openTab: OpenTabPayload | null; /** Whether abort() has been called. */ aborted: boolean; private fetchFn; private url; private runsUrl; private clientHeaders; private req; private reader; private decoder; private buffer; private started; private abortController; private resumeMode; private resumeAfter; private detached; private terminal; private readonly connectionStateListeners; constructor(fetchFn: typeof globalThis.fetch, url: string, runsUrl: string, clientHeaders: Record, req: ChatCompletionRequest); /** Backward-compatible cancel command. Use detach() to keep a durable run alive. */ abort(): void; /** Observe transport state without implementing a second SSE parser. */ subscribeConnectionState(listener: (state: ChatStreamConnectionState) => void): () => void; /** Close only this subscriber. A durable run continues server-side. */ detach(): void; /** Explicitly cancel the underlying run, then close this subscriber. */ cancel(reason?: string): Promise; /** Reattach this stream to its existing run after the last processed cursor. */ resume(options?: { after?: string; }): this; private closeLocalStream; /** Start the HTTP stream and resolve response metadata without consuming a chunk. */ start(): Promise; private ensureStarted; [Symbol.asyncIterator](): AsyncGenerator; private isDurable; private emitConnectionState; } export declare class PolpoClient { private readonly baseUrl; private readonly apiPrefix; private readonly apiKey; private readonly headers; private readonly fetchFn; /** In-flight GET deduplication */ private readonly inflight; /** * Default end-user identifier auto-applied to chat / task / mission calls * when the call doesn't explicitly set its own `user`. Settable post-construct * via {@link setUser} so a Provider can update it on auth state change. */ private defaultUser; constructor(config: PolpoClientConfig); /** * Update the default end-user identifier auto-applied to subsequent calls. * Call from a React Provider whenever auth state changes. Pass `undefined` * to clear (e.g. on logout) so further calls go un-scoped. */ setUser(user: string | undefined): void; /** Read the currently-active default user, primarily for debugging. */ getUser(): string | undefined; private apiUrl; private request; private get; private post; private put; private patch; private del; private brainScopeQuery; getTasks(filters?: TaskFilters): Promise; getTask(taskId: string): Promise; createTask(req: CreateTaskRequest): Promise; updateTask(taskId: string, req: UpdateTaskRequest): Promise; deleteTask(taskId: string): Promise<{ removed: boolean; }>; retryTask(taskId: string): Promise<{ retried: boolean; }>; killTask(taskId: string): Promise<{ killed: boolean; }>; reassessTask(taskId: string): Promise<{ reassessed: boolean; }>; queueTask(taskId: string): Promise<{ queued: boolean; }>; getMissions(): Promise; getResumableMissions(): Promise; getMission(missionId: string): Promise; createMission(req: CreateMissionRequest): Promise; updateMission(missionId: string, req: UpdateMissionRequest): Promise; deleteMission(missionId: string): Promise<{ deleted: boolean; }>; executeMission(missionId: string): Promise; resumeMission(missionId: string, opts?: { retryFailed?: boolean; }): Promise; abortMission(missionId: string): Promise<{ aborted: number; }>; addMissionTask(missionId: string, req: AddMissionTaskRequest): Promise; updateMissionTask(missionId: string, taskTitle: string, req: UpdateMissionTaskRequest): Promise; removeMissionTask(missionId: string, taskTitle: string): Promise; reorderMissionTasks(missionId: string, req: ReorderMissionTasksRequest): Promise; addMissionCheckpoint(missionId: string, req: AddMissionCheckpointRequest): Promise; updateMissionCheckpoint(missionId: string, checkpointName: string, req: UpdateMissionCheckpointRequest): Promise; removeMissionCheckpoint(missionId: string, checkpointName: string): Promise; listDelays(): Promise; addMissionDelay(missionId: string, req: AddMissionDelayRequest): Promise; updateMissionDelay(missionId: string, delayName: string, req: UpdateMissionDelayRequest): Promise; removeMissionDelay(missionId: string, delayName: string): Promise; addMissionQualityGate(missionId: string, req: AddMissionQualityGateRequest): Promise; updateMissionQualityGate(missionId: string, gateName: string, req: UpdateMissionQualityGateRequest): Promise; removeMissionQualityGate(missionId: string, gateName: string): Promise; addMissionTeamMember(missionId: string, req: AddMissionTeamMemberRequest): Promise; updateMissionTeamMember(missionId: string, memberName: string, req: UpdateMissionTeamMemberRequest): Promise; removeMissionTeamMember(missionId: string, memberName: string): Promise; updateMissionNotifications(missionId: string, req: UpdateMissionNotificationsRequest): Promise; /** * Save a vault entry directly to the encrypted store. * Bypasses the LLM entirely — credentials go straight to AES-256-GCM encrypted storage. * Returns metadata only (never credential values). */ saveVaultEntry(req: { agent: string; service: string; type: "smtp" | "imap" | "oauth" | "api_key" | "login" | "custom"; label?: string; credentials: Record; }): Promise<{ agent: string; service: string; type: string; keys: string[]; }>; /** * Partially update credential fields in an existing vault entry. * Only the provided fields are merged — existing fields are preserved. */ patchVaultEntry(agent: string, service: string, patch: { type?: string; label?: string; credentials?: Record; }): Promise<{ agent: string; service: string; type: string; keys: string[]; }>; /** * Remove a vault entry from the encrypted store. */ removeVaultEntry(agent: string, service: string): Promise<{ removed: boolean; }>; /** * List vault entries for an agent (metadata only — no secret values). * Returns service names, types, labels, and credential field names. */ listVaultEntries(agent: string): Promise; /** * Get per-provider auth status: config keys, env vars, OAuth profiles (metadata only). * Tokens are NEVER exposed. */ getAuthStatus(): Promise; getSchedules(): Promise; /** Create a schedule for a mission. */ createSchedule(req: CreateScheduleRequest): Promise; /** Update an existing schedule. */ updateSchedule(missionId: string, req: UpdateScheduleRequest): Promise; /** Delete a schedule by mission ID. */ deleteSchedule(missionId: string): Promise<{ deleted: boolean; }>; /** List first-class schedules. Legacy mission methods remain additive above. */ listSchedules(filter?: { status?: ScheduleStatus; surface?: Schedule["invocation"]["surface"]; includeDeleted?: boolean; }): Promise; getSchedule(scheduleId: string): Promise; createScheduleV2(input: CreateScheduleInput): Promise; updateScheduleV2(scheduleId: string, input: UpdateScheduleInput, options?: ScheduleMutationOptions): Promise; deleteScheduleV2(scheduleId: string, options?: ScheduleMutationOptions): Promise; pauseSchedule(scheduleId: string, options?: ScheduleMutationOptions): Promise; resumeSchedule(scheduleId: string, options?: ScheduleMutationOptions): Promise; listScheduleRuns(scheduleId: string, filter?: { status?: ScheduleRunStatus; limit?: number; order?: "asc" | "desc"; }): Promise; triggerSchedule(scheduleId: string, input: TriggerScheduleRequest): Promise; getAgents(): Promise; getAgent(name: string): Promise; addAgent(req: AddAgentRequest, teamName?: string): Promise<{ added: boolean; }>; removeAgent(name: string): Promise<{ removed: boolean; }>; updateAgent(name: string, req: UpdateAgentRequest): Promise; getLoops(): Promise; getLoop(name: string): Promise; createLoop(req: ProjectLoopConfig): Promise; updateLoop(name: string, req: ProjectLoopConfig): Promise; deleteLoop(name: string): Promise<{ removed: boolean; name: string; }>; getLoopRuns(filters?: LoopRunFilters): Promise; getLoopRun(id: string): Promise; approveLoopRun(id: string, opts?: { resolvedBy?: string; note?: string; }): Promise; rejectLoopRun(id: string, opts?: { resolvedBy?: string; note?: string; feedback?: string; }): Promise; resumeLoopRun(id: string, opts?: { resolvedBy?: string; }): Promise; getTeams(): Promise; getTeam(name?: string): Promise; addTeam(req: AddTeamRequest): Promise<{ added: boolean; }>; updateTeam(name: string, req: UpdateTeamRequest): Promise; removeTeam(name: string): Promise<{ removed: boolean; }>; renameTeam(oldName: string, newName: string): Promise; getProcesses(): Promise; getState(): Promise; getConfig(): Promise; updateSettings(req: UpdateSettingsRequest): Promise; listChannels(): Promise>; upsertChannel(name: string, config: NotificationChannelConfig): Promise; deleteChannel(name: string): Promise; testChannel(name: string): Promise<{ success: boolean; }>; listConversationChannelProviders(): Promise; listConversationChannels(query?: ConversationChannelQuery): Promise; getConversationChannel(channelId: string): Promise; configureConversationChannel(input: ConfigureConversationChannelInput): Promise; updateConversationChannel(channelId: string, input: UpdateConversationChannelInput): Promise; testConversationChannel(channelId: string): Promise<{ message?: string; success: boolean; }>; removeConversationChannel(channelId: string): Promise<{ removed: true; }>; listConversationChannelRoutes(channelId: string): Promise; upsertConversationChannelRoute(channelId: string, input: Omit): Promise; removeConversationChannelRoute(channelId: string, routeId: string): Promise<{ removed: true; }>; getConversationChannelSetup(setupId: string): Promise; listBrainSources(filters?: BrainSourceFilters): Promise; createBrainSource(request: CreateBrainSourceRequest): Promise; getBrainSource(sourceId: string, scope?: BrainScope): Promise; updateBrainSource(sourceId: string, request: BrainUpdateSourceRequest, scope?: BrainScope): Promise; deleteBrainSource(sourceId: string, scope?: BrainScope): Promise<{ deleted: boolean; }>; reindexBrainSource(sourceId: string, request: BrainReindexSourceRequest, scope?: BrainScope): Promise; listBrainSourceVersions(sourceId: string, scope?: BrainScope): Promise; readBrainSource(sourceId: string, request?: ReadBrainSourceRequest): Promise; searchBrain(request: SearchBrainRequest): Promise; getMemory(): Promise<{ exists: boolean; content: string; }>; saveMemory(content: string): Promise<{ saved: boolean; }>; getAgentMemory(agentName: string): Promise<{ exists: boolean; content: string; agent: string; }>; saveAgentMemory(agentName: string, content: string): Promise<{ saved: boolean; agent: string; }>; listMemoryItems(agentName: string, query?: ListMemoryItemsQuery): Promise; listMemoryItemsPage(agentName: string, query?: ListMemoryItemsPageQuery): Promise; createMemoryItem(agentName: string, input: CreateMemoryItemInput): Promise; searchMemory(agentName: string, query: SearchMemoryRequest): Promise; getMemoryItemUsage(agentName: string, itemId: string): Promise; updateMemoryItem(agentName: string, itemId: string, patch: MemoryItemPatch): Promise; forgetMemoryItem(agentName: string, itemId: string): Promise; listMemoryCandidates(agentName: string, query?: ListMemoryCandidatesQuery): Promise; getMemoryCandidate(agentName: string, candidateId: string): Promise; decideMemoryCandidate(agentName: string, candidateId: string, input: DecideMemoryCandidateInput): Promise; applyMemoryCandidate(agentName: string, candidateId: string, input?: ApplyMemoryCandidateInput): Promise; getMemoryCandidateAudit(agentName: string, candidateId: string): Promise; getLogs(): Promise; getLogEntries(sessionId: string): Promise; /** Discover available skills in the agent skill pool with assignment info. */ getSkills(): Promise; /** Assign a skill to an agent. */ assignSkill(skillName: string, agent: string): Promise<{ skill: string; agent: string; }>; /** Unassign a skill from an agent. */ unassignSkill(skillName: string, agent: string): Promise<{ skill: string; agent: string; }>; /** Discover orchestrator skills (.polpo/.agent/skills/). */ getOrchestratorSkills(): Promise; /** Get the full content of an agent skill by name. */ getSkillContent(name: string): Promise; /** Get every file in a skill directory as a binary-safe bundle. */ getSkillBundle(name: string): Promise; /** Atomically replace every file in a skill directory. */ putSkillBundle(bundle: SkillBundle): Promise<{ name: string; files: number; }>; /** Get the full content of an orchestrator skill by name. */ getOrchestratorSkillContent(name: string): Promise; /** Get the full skills index (tags and categories for all skills). */ getSkillsIndex(): Promise; /** Update a skill's tags and/or category in the skills index. */ updateSkillIndex(name: string, entry: SkillIndexEntry): Promise<{ skill: string; tags?: string[]; category?: string; }>; /** Create a new skill with a SKILL.md file. */ createSkill(req: CreateSkillRequest): Promise<{ name: string; path: string; }>; /** Install skills from a GitHub repo or local path. */ installSkills(source: string, opts?: InstallSkillsOptions): Promise; /** Delete a skill by name. */ deleteSkill(name: string): Promise<{ removed: boolean; name: string; }>; /** Get the full activity history for a task from its run JSONL log. */ getTaskActivity(taskId: string): Promise; /** * Composite task activity — task row + current run + resolved log * session + entries in a single call. Replaces the four-round-trip * fan-out (getTask + getRunByTaskId + listSessions + getSessionEntries) * that dashboards used to do, and centralizes the session-resolution * heuristic (explicit sessionId → time-window match against log * sessions). Backed by GET /tasks/:id/activity (server 0.7.13+). */ getTaskActivityFull(taskId: string): Promise; /** Queue a message for an active run's next safe model/tool boundary. */ steerRun(runId: string, input: SteeringMessageInput): Promise; /** Abort an active run through the same run-scoped steering controller. */ abortRun(runId: string, reason?: SteeringJsonValue): Promise; /** Follow the canonical durable event log for an existing run. */ streamRunEvents(runId: string, options?: RunEventStreamOptions): AsyncGenerator; /** Request idempotent cancellation for a durable run. */ cancelRun(runId: string, reason?: string): Promise; /** * Talk to Polpo via the OpenAI-compatible chat completions endpoint. * Non-streaming mode — returns the full response. */ chatCompletions(req: ChatCompletionRequest): Promise; /** * Talk to Polpo via the OpenAI-compatible chat completions endpoint. * Streaming mode — returns a ChatCompletionStream (async-iterable + metadata). */ chatCompletionsStream(req: ChatCompletionRequest): ChatCompletionStream; /** Resume one pending client-side tool call in direct chat or through an explicit Project Loop. */ continueWithToolResult(req: ContinueClientToolResultRequest): ChatCompletionStream; getSessions(): Promise<{ sessions: ChatSession[]; }>; getSessionMessages(sessionId: string): Promise<{ session: ChatSession; messages: ChatMessage[]; }>; renameSession(sessionId: string, title: string): Promise<{ renamed: boolean; }>; deleteSession(sessionId: string): Promise<{ deleted: boolean; }>; /** List notification history. */ getNotifications(opts?: { limit?: number; status?: string; channel?: string; rule?: string; }): Promise; /** Get notification stats (total, sent, failed). */ getNotificationStats(): Promise; /** Send a notification directly to a channel (with optional delay). */ sendNotification(req: SendNotificationRequest): Promise; /** List approval requests. */ getApprovals(status?: ApprovalStatus): Promise; /** Get pending approval requests. */ getPendingApprovals(): Promise; /** Approve a request. */ approveRequest(requestId: string, opts?: { resolvedBy?: string; note?: string; }): Promise; /** Reject a request with feedback. */ rejectRequest(requestId: string, feedback: string, resolvedBy?: string): Promise; /** List available playbooks discovered from disk. */ getPlaybooks(): Promise; /** Get full playbook definition including the mission body. */ getPlaybook(name: string): Promise; /** Run a playbook with parameters. Returns the created mission + task count. */ runPlaybook(name: string, params?: Record): Promise; /** Create or update a playbook definition. */ createPlaybook(req: CreatePlaybookRequest): Promise<{ name: string; path: string; }>; /** Delete a playbook by name. */ deletePlaybook(name: string): Promise; getFileRoots(): Promise<{ roots: FileRoot[]; }>; /** List the host-managed persistent volume catalog and supported policies. */ listSandboxVolumes(): Promise; /** Create a project-scoped persistent volume. */ createSandboxVolume(input: CreateSandboxVolumeInput): Promise; /** Update a persistent volume policy. Volume names are immutable. */ updateSandboxVolume(name: string, input: UpdateSandboxVolumeInput): Promise; /** Delete a persistent volume and its grants. */ deleteSandboxVolume(name: string): Promise<{ removed: true; name: string; }>; /** List persistent-volume grants for one agent. */ listSandboxVolumeGrants(agentName: string): Promise<{ grants: SandboxVolumeGrant[]; }>; /** Create or narrow an agent's persistent-volume grant. */ setSandboxVolumeGrant(agentName: string, volumeId: string, input?: SetSandboxVolumeGrantInput): Promise; /** Revoke an agent's persistent-volume grant. */ revokeSandboxVolumeGrant(agentName: string, volumeId: string): Promise<{ removed: true; }>; listFiles(path?: string): Promise<{ path: string; entries: FileEntry[]; }>; previewFile(path: string, maxLines?: number): Promise; /** Download/read a file. Returns raw Response for binary handling. */ readFile(path: string, download?: boolean): Promise; uploadFile(destPath: string, file: File | Blob, filename: string): Promise<{ uploaded: { name: string; size: number; }[]; count: number; }>; createDirectory(path: string): Promise<{ path: string; }>; renameFile(path: string, newName: string): Promise<{ oldPath: string; newName: string; }>; deleteFile(path: string): Promise<{ path: string; }>; searchFiles(query?: string, root?: string, limit?: number): Promise<{ files: { name: string; path: string; }[]; total: number; }>; /** @deprecated Use getPlaybooks instead. */ getTemplates(): Promise; /** @deprecated Use getPlaybook instead. */ getTemplate(name: string): Promise; /** @deprecated Use runPlaybook instead. */ runTemplate(name: string, params?: Record): Promise; /** Health check (instance method — uses configured base URL, no auth). */ getHealth(): Promise; static health(baseUrl: string): Promise; /** Build SSE URL for EventSource (with optional apiKey as query param — EventSource can't send headers) */ getEventsUrl(filter?: string[]): string; } //# sourceMappingURL=polpo-client.d.ts.map