dsh-openai-subscription 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/host.d.ts ADDED
@@ -0,0 +1,88 @@
1
+ import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
2
+ import type { Context } from '@deepseek-ai/cordis';
3
+ /** Host-side notice queued for the polling client. Mirrors `AuthorizationNotice`. */
4
+ interface FlowNotice {
5
+ message: string;
6
+ url?: string;
7
+ code?: string;
8
+ }
9
+ /** Mutable state of one in-flight authorization attempt. */
10
+ interface FlowState {
11
+ notices: FlowNotice[];
12
+ done: boolean;
13
+ outcome: 'authorized' | 'cancelled' | 'failed' | null;
14
+ error: string | null;
15
+ controller: AbortController;
16
+ task: Promise<void> | null;
17
+ }
18
+ /** `openaiSubscription/status` reply. */
19
+ type StatusResult = {
20
+ configured: false;
21
+ ready: boolean;
22
+ } | {
23
+ configured: true;
24
+ ready: boolean;
25
+ accountId: string | null;
26
+ expires: number | null;
27
+ loginMethod: string | null;
28
+ obtainedAt: number | null;
29
+ refreshedAt: number | null;
30
+ hasRefresh: boolean;
31
+ };
32
+ /** `openaiSubscription/authorize` reply. */
33
+ type AuthorizeResult = {
34
+ started: false;
35
+ error: string;
36
+ } | {
37
+ started: true;
38
+ };
39
+ /** `openaiSubscription/poll` reply. */
40
+ type PollResult = {
41
+ status: 'idle';
42
+ notices: FlowNotice[];
43
+ } | {
44
+ status: 'pending';
45
+ notices: FlowNotice[];
46
+ } | {
47
+ status: 'done';
48
+ notices: FlowNotice[];
49
+ outcome: FlowState['outcome'];
50
+ error: string | null;
51
+ };
52
+ declare class OpenAISubscriptionController extends TypertRemoteService {
53
+ private registeredAuthorization;
54
+ private cachedModule;
55
+ private locatingModule;
56
+ private pendingBridge;
57
+ constructor(ctx: Context);
58
+ private credentials;
59
+ private shell;
60
+ private timer;
61
+ private authorization;
62
+ private ensureAuthorizationFlow;
63
+ private locateAuthModule;
64
+ private runDevice;
65
+ private runRefresh;
66
+ /** Store the credential used by the `openai-codex` provider. */
67
+ private mirrorToPiAi;
68
+ /** Enable the default provider without replacing user configuration. */
69
+ private ensurePiRoute;
70
+ /** Mark the default provider as plugin-managed. */
71
+ private markPiRouteManaged;
72
+ /** Remove only the unchanged default provider created by this plugin. */
73
+ private removePiRouteIfBare;
74
+ private beginLogin;
75
+ private registerAuthorizationFlow;
76
+ private shq;
77
+ status(): Promise<StatusResult>;
78
+ authorize(method: unknown): Promise<AuthorizeResult>;
79
+ poll(): Promise<PollResult>;
80
+ cancel(): Promise<{
81
+ ok: true;
82
+ }>;
83
+ /** Cancel active authorization and remove plugin-managed credentials and settings. */
84
+ logout(): Promise<{
85
+ ok: true;
86
+ }>;
87
+ }
88
+ export default OpenAISubscriptionController;