types(shared): add credentials/oauth channels, events, and desktop-api
- Add IPC_CHANNELS entries for credentials list/save/remove/test and oauth start/cancel/prompt/manual-code - Extend DesktopEvent union with oauth:*, credentials-changed, and agent-event variants used by pi-mono runtime and settings UI - Extend DesktopApi CredentialsApi with listCredentials / saveCredential / removeCredential / testCredential and OAuth submit helpers
This commit is contained in:
1 parent
1f310a121e
commit
ef90a58fa2
3 files changed
+100
-1
No files matched your search
@@ -133,4 +133,14 @@ export const IPC_CHANNELS = {
|
|||||||
windowMaximize: "window:maximize",
|
windowMaximize: "window:maximize",
|
||||||
windowClose: "window:close",
|
windowClose: "window:close",
|
||||||
windowIsMaximized: "window:isMaximized",
|
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;
|
} as const;
|
||||||
@@ -1,9 +1,28 @@
|
|||||||
import type { z } from "zod";
|
import type { z } from "zod";
|
||||||
import type { secretInputSchema } from "../schemas-company";
|
import type { secretInputSchema } from "../schemas-company";
|
||||||
import type { deleteEntitySchema } from "../schemas-badges";
|
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";
|
import type { DesktopResult } from "./common";
|
||||||
|
|
||||||
export type CredentialsApi = {
|
export type CredentialsApi = {
|
||||||
saveSecret: (input: z.infer<typeof secretInputSchema>) => Promise<DesktopResult<string>>;
|
saveSecret: (input: z.infer<typeof secretInputSchema>) => Promise<DesktopResult<string>>;
|
||||||
deleteSecret: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
deleteSecret: (input: z.infer<typeof deleteEntitySchema>) => Promise<DesktopResult<boolean>>;
|
||||||
|
// pi-mono credentials
|
||||||
|
listCredentials: () => Promise<DesktopResult<CredentialSummary[]>>;
|
||||||
|
saveCredential: (input: SaveCredentialInput) => Promise<DesktopResult<CredentialSummary>>;
|
||||||
|
removeCredential: (input: { connectorId: string }) => Promise<DesktopResult<boolean>>;
|
||||||
|
testCredential: (input: { connectorId: string }) => Promise<DesktopResult<{ ok: boolean; message: string }>>;
|
||||||
|
// pi-mono OAuth
|
||||||
|
startOAuth: (input: OAuthStartInput) => Promise<DesktopResult<boolean>>;
|
||||||
|
cancelOAuth: (input: { connectorId: string }) => Promise<DesktopResult<boolean>>;
|
||||||
|
submitOAuthPrompt: (input: OAuthPromptResponseInput) => Promise<DesktopResult<boolean>>;
|
||||||
|
submitOAuthManualCode: (input: OAuthManualCodeResponseInput) => Promise<DesktopResult<boolean>>;
|
||||||
};
|
};
|
||||||
@@ -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<string, unknown>;
|
||||||
|
}
|
||||||
|
|
||||||
export type DesktopEvent =
|
export type DesktopEvent =
|
||||||
| LogChunkEvent
|
| LogChunkEvent
|
||||||
| DomainChangedEvent
|
| DomainChangedEvent
|
||||||
@@ -118,4 +181,11 @@ export type DesktopEvent =
|
|||||||
| AgentUpdatedEvent
|
| AgentUpdatedEvent
|
||||||
| BudgetChangedEvent
|
| BudgetChangedEvent
|
||||||
| ThreadWaitStateUpdatedEvent
|
| ThreadWaitStateUpdatedEvent
|
||||||
| RecoveryNeededEvent;
|
| RecoveryNeededEvent
|
||||||
|
| OAuthStatusEvent
|
||||||
|
| OAuthAuthUrlEvent
|
||||||
|
| OAuthProgressEvent
|
||||||
|
| OAuthPromptRequestEvent
|
||||||
|
| OAuthManualCodeRequestEvent
|
||||||
|
| CredentialsChangedEvent
|
||||||
|
| AgentEvent;
|
||||||
Reference in new issue
Block a user