diff --git a/src/shared/contracts/channels.ts b/src/shared/contracts/channels.ts index 874e63b9..a82896f1 100644 --- a/src/shared/contracts/channels.ts +++ b/src/shared/contracts/channels.ts @@ -133,4 +133,14 @@ export const IPC_CHANNELS = { windowMaximize: "window:maximize", windowClose: "window:close", windowIsMaximized: "window:isMaximized", + // Credentials (pi-mono) + credentialsList: "credentials:list", + credentialsSave: "credentials:save", + credentialsRemove: "credentials:remove", + credentialsTest: "credentials:test", + // OAuth (pi-mono) + oauthStart: "oauth:start", + oauthCancel: "oauth:cancel", + oauthPromptResponse: "oauth:submit-prompt", + oauthManualCodeResponse: "oauth:submit-manual-code", } as const; diff --git a/src/shared/contracts/desktop-api/credentials.ts b/src/shared/contracts/desktop-api/credentials.ts index 2ecf8eef..b79c3fba 100644 --- a/src/shared/contracts/desktop-api/credentials.ts +++ b/src/shared/contracts/desktop-api/credentials.ts @@ -1,9 +1,28 @@ import type { z } from "zod"; import type { secretInputSchema } from "../schemas-company"; import type { deleteEntitySchema } from "../schemas-badges"; +import type { + CredentialSummary, + SaveCredentialInput, +} from "../schemas-credentials"; +import type { + OAuthStartInput, + OAuthPromptResponseInput, + OAuthManualCodeResponseInput, +} from "../schemas-oauth"; import type { DesktopResult } from "./common"; export type CredentialsApi = { saveSecret: (input: z.infer) => Promise>; deleteSecret: (input: z.infer) => Promise>; + // pi-mono credentials + listCredentials: () => Promise>; + saveCredential: (input: SaveCredentialInput) => Promise>; + removeCredential: (input: { connectorId: string }) => Promise>; + testCredential: (input: { connectorId: string }) => Promise>; + // pi-mono OAuth + startOAuth: (input: OAuthStartInput) => Promise>; + cancelOAuth: (input: { connectorId: string }) => Promise>; + submitOAuthPrompt: (input: OAuthPromptResponseInput) => Promise>; + submitOAuthManualCode: (input: OAuthManualCodeResponseInput) => Promise>; }; diff --git a/src/shared/types/events.ts b/src/shared/types/events.ts index ae386997..acdb99d2 100644 --- a/src/shared/types/events.ts +++ b/src/shared/types/events.ts @@ -102,6 +102,69 @@ export interface RecoveryNeededEvent { }>; } +// ─── pi-mono credentials / OAuth events ──────────────────────────────────── + +export type OAuthStatusValue = + | "pending" + | "in_progress" + | "active" + | "error" + | "cancelled" + | "completed"; + +export interface OAuthStatusEvent { + type: "oauth:status"; + connectorId: string; + status: OAuthStatusValue; + message?: string; + errorMessage?: string; +} + +export interface OAuthAuthUrlEvent { + type: "oauth:auth-url"; + connectorId: string; + url: string; + instructions?: string; +} + +export interface OAuthProgressEvent { + type: "oauth:progress"; + connectorId: string; + message: string; +} + +export interface OAuthPromptRequestEvent { + type: "oauth:prompt-request"; + connectorId: string; + requestId: string; + message: string; + placeholder?: string; + allowEmpty?: boolean; +} + +export interface OAuthManualCodeRequestEvent { + type: "oauth:manual-code-request"; + connectorId: string; + requestId: string; + authUrl?: string; + instructions?: string; +} + +export interface CredentialsChangedEvent { + type: "credentials-changed"; + connectorId?: string; +} + +export interface AgentEvent { + type: "agent-event"; + runId: string; + agentId: string; + companyId: string; + taskId: string | null; + emittedAt: string; + event: { type: string } & Record; +} + export type DesktopEvent = | LogChunkEvent | DomainChangedEvent @@ -118,4 +181,11 @@ export type DesktopEvent = | AgentUpdatedEvent | BudgetChangedEvent | ThreadWaitStateUpdatedEvent - | RecoveryNeededEvent; + | RecoveryNeededEvent + | OAuthStatusEvent + | OAuthAuthUrlEvent + | OAuthProgressEvent + | OAuthPromptRequestEvent + | OAuthManualCodeRequestEvent + | CredentialsChangedEvent + | AgentEvent;