@dsh-enhanced/coding-subscription-provider 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/LICENSE +21 -0
- package/README.md +204 -0
- package/cordis.patch.yml +3 -0
- package/lib/adapter.d.ts +76 -0
- package/lib/adapter.d.ts.map +1 -0
- package/lib/adapter.js +404 -0
- package/lib/adapter.js.map +1 -0
- package/lib/auth.d.ts +33 -0
- package/lib/auth.d.ts.map +1 -0
- package/lib/auth.js +101 -0
- package/lib/auth.js.map +1 -0
- package/lib/codex-catalog.d.ts +57 -0
- package/lib/codex-catalog.d.ts.map +1 -0
- package/lib/codex-catalog.js +368 -0
- package/lib/codex-catalog.js.map +1 -0
- package/lib/config.d.ts +48 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +66 -0
- package/lib/config.js.map +1 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +40 -0
- package/lib/index.js.map +1 -0
- package/lib/process.d.ts +114 -0
- package/lib/process.d.ts.map +1 -0
- package/lib/process.js +712 -0
- package/lib/process.js.map +1 -0
- package/lib/prompt.d.ts +4 -0
- package/lib/prompt.d.ts.map +1 -0
- package/lib/prompt.js +49 -0
- package/lib/prompt.js.map +1 -0
- package/lib/providers.d.ts +30 -0
- package/lib/providers.d.ts.map +1 -0
- package/lib/providers.js +61 -0
- package/lib/providers.js.map +1 -0
- package/lib/subscription-catalog.d.ts +51 -0
- package/lib/subscription-catalog.d.ts.map +1 -0
- package/lib/subscription-catalog.js +289 -0
- package/lib/subscription-catalog.js.map +1 -0
- package/package.json +69 -0
package/lib/process.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { CliInvocation } from './providers.js';
|
|
2
|
+
export interface SpawnedProcess {
|
|
3
|
+
readonly pid?: number;
|
|
4
|
+
readonly stdout?: NodeJS.ReadableStream | null;
|
|
5
|
+
readonly stderr?: NodeJS.ReadableStream | null;
|
|
6
|
+
readonly exitCode?: number | null;
|
|
7
|
+
kill(signal?: NodeJS.Signals | number): boolean;
|
|
8
|
+
once(event: 'error' | 'close' | 'spawn', listener: (...args: any[]) => void): this;
|
|
9
|
+
removeListener?(event: 'error' | 'close' | 'spawn', listener: (...args: any[]) => void): this;
|
|
10
|
+
unref?(): void;
|
|
11
|
+
}
|
|
12
|
+
/** Whether the prompt argv was handed to the OS; the only safe basis for reasoning about replay. */
|
|
13
|
+
export type PromptSubmissionState = 'not-submitted' | 'submitted' | 'unknown';
|
|
14
|
+
/** Coarse lifecycle phase a failure was observed in, transport-scoped (auth lives in the adapter). */
|
|
15
|
+
export type CliLifecyclePhase = 'spawn' | 'initialize' | 'prompt' | 'stream' | 'terminal' | 'child-close';
|
|
16
|
+
/** Progress of the bounded child teardown attempt; `timed-out` means close was not proven. */
|
|
17
|
+
export type TeardownState = 'not-started' | 'in-progress' | 'completed' | 'timed-out';
|
|
18
|
+
/** Latency metrics with named clock origins so they stay comparable across providers. */
|
|
19
|
+
export interface CliLifecycleMetrics {
|
|
20
|
+
/** Spawn to the first accepted (recognized) protocol event. */
|
|
21
|
+
readonly spawnToFirstEventMs?: number;
|
|
22
|
+
/** First recognized event to the first assistant text chunk. */
|
|
23
|
+
readonly eventToFirstTextMs?: number;
|
|
24
|
+
/** Spawn to the successful terminal event. */
|
|
25
|
+
readonly spawnToTerminalMs?: number;
|
|
26
|
+
/** Stop request to child-close teardown completion. */
|
|
27
|
+
readonly teardownDurationMs?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Credential-free lifecycle facts for one CLI invocation. Diagnostic side-channel only:
|
|
31
|
+
* it never carries prompt text, stderr, tokens or argv, and never changes settlement.
|
|
32
|
+
*/
|
|
33
|
+
export interface ProviderFailureContext {
|
|
34
|
+
readonly phase: CliLifecyclePhase;
|
|
35
|
+
readonly promptSubmissionState: PromptSubmissionState;
|
|
36
|
+
readonly assistantTextObserved: boolean;
|
|
37
|
+
readonly teardownState: TeardownState;
|
|
38
|
+
readonly terminalReason?: string;
|
|
39
|
+
readonly exitCode?: number | null;
|
|
40
|
+
readonly signal?: NodeJS.Signals | null;
|
|
41
|
+
/** Explicit-clock-origin latency metrics; only measurable ones are present. */
|
|
42
|
+
readonly metrics?: CliLifecycleMetrics;
|
|
43
|
+
}
|
|
44
|
+
export type SpawnProcess = (command: string, args: readonly string[], options: {
|
|
45
|
+
cwd: string;
|
|
46
|
+
shell: false;
|
|
47
|
+
detached: boolean;
|
|
48
|
+
stdio: readonly ['ignore', 'pipe', 'pipe'];
|
|
49
|
+
env: NodeJS.ProcessEnv;
|
|
50
|
+
}) => SpawnedProcess;
|
|
51
|
+
export interface RunCliTextOptions {
|
|
52
|
+
readonly spawn?: SpawnProcess;
|
|
53
|
+
readonly signal?: AbortSignal;
|
|
54
|
+
readonly timeoutMs?: number;
|
|
55
|
+
readonly killGraceMs?: number;
|
|
56
|
+
readonly maxLineBytes?: number;
|
|
57
|
+
readonly maxOutputBytes?: number;
|
|
58
|
+
readonly maxStderrBytes?: number;
|
|
59
|
+
/** Names only. Values are copied from process.env; callers cannot pass secret values. */
|
|
60
|
+
readonly extraEnvNames?: readonly string[];
|
|
61
|
+
readonly onDiagnostic?: (diagnostic: string) => void;
|
|
62
|
+
/** Receives credential-free lifecycle facts exactly once at settlement (success or failure); never affects the stream. */
|
|
63
|
+
readonly onSettled?: (context: ProviderFailureContext) => void;
|
|
64
|
+
}
|
|
65
|
+
export type CliProtocolFailureReason = 'MALFORMED_JSON' | 'NO_JSON_EVENTS' | 'UNRECOGNIZED_EVENTS' | 'NO_ASSISTANT_TEXT' | 'MISSING_SUCCESS_TERMINAL' | 'INVALID_TERMINAL' | 'REPORTED_FAILURE';
|
|
66
|
+
/** A stable, credential-free protocol failure that the adapter can map. */
|
|
67
|
+
export declare class CliProtocolError extends Error {
|
|
68
|
+
readonly provider: CliInvocation['provider'];
|
|
69
|
+
readonly reason: CliProtocolFailureReason;
|
|
70
|
+
readonly code = "CLI_PROTOCOL_ERROR";
|
|
71
|
+
constructor(provider: CliInvocation['provider'], reason: CliProtocolFailureReason);
|
|
72
|
+
}
|
|
73
|
+
export type CliSubscriptionAuthFailureReason = 'MISSING_AUTH_EVENT' | 'UNEXPECTED_AUTH_SOURCE';
|
|
74
|
+
/** Cursor reported, or failed to report, the subscription login required by this route. */
|
|
75
|
+
export declare class CliSubscriptionAuthError extends Error {
|
|
76
|
+
readonly provider: 'cursor';
|
|
77
|
+
readonly reason: CliSubscriptionAuthFailureReason;
|
|
78
|
+
readonly code = "CLI_SUBSCRIPTION_AUTH_ERROR";
|
|
79
|
+
constructor(provider: 'cursor', reason: CliSubscriptionAuthFailureReason);
|
|
80
|
+
}
|
|
81
|
+
/** The child really closed, but not with an unambiguous zero-code, no-signal exit. */
|
|
82
|
+
export declare class CliProcessExitError extends Error {
|
|
83
|
+
readonly provider: CliInvocation['provider'];
|
|
84
|
+
readonly exitCode: number | null;
|
|
85
|
+
readonly signal: NodeJS.Signals | null;
|
|
86
|
+
readonly code = "CLI_PROCESS_EXIT_ERROR";
|
|
87
|
+
constructor(provider: CliInvocation['provider'], exitCode: number | null, signal: NodeJS.Signals | null);
|
|
88
|
+
}
|
|
89
|
+
/** SIGKILL was requested, but ChildProcess never proved process/stdio closure. */
|
|
90
|
+
export declare class CliTeardownTimeoutError extends Error {
|
|
91
|
+
readonly provider: CliInvocation['provider'];
|
|
92
|
+
readonly timeoutMs: number;
|
|
93
|
+
readonly code = "CLI_TEARDOWN_TIMEOUT";
|
|
94
|
+
constructor(provider: CliInvocation['provider'], timeoutMs: number);
|
|
95
|
+
}
|
|
96
|
+
/** Build an inherited environment that favours the local CLI's subscription login over API-key billing. */
|
|
97
|
+
export declare function buildSubscriptionEnv(extraEnvNames?: readonly string[]): NodeJS.ProcessEnv;
|
|
98
|
+
/**
|
|
99
|
+
* Starts one local, already-authenticated coding CLI and yields only assistant text.
|
|
100
|
+
* It never reads credential files or accepts credential values in config. An explicitly
|
|
101
|
+
* allowlisted environment name may still be forwarded unchanged to the official CLI.
|
|
102
|
+
* No shell is invoked.
|
|
103
|
+
*/
|
|
104
|
+
export declare function runCliText(invocation: CliInvocation, options?: RunCliTextOptions): AsyncIterable<string>;
|
|
105
|
+
export interface ParsedEvent {
|
|
106
|
+
readonly text?: string;
|
|
107
|
+
/** True when text is a full aggregate that must not repeat prior deltas. */
|
|
108
|
+
readonly terminal: boolean;
|
|
109
|
+
readonly outcome?: 'success' | 'failure' | 'invalid';
|
|
110
|
+
readonly auth?: 'subscription' | 'other';
|
|
111
|
+
}
|
|
112
|
+
export declare function parseAssistantEvent(provider: CliInvocation['provider'], line: string): ParsedEvent | undefined;
|
|
113
|
+
export declare function parseAssistantText(provider: CliInvocation['provider'], line: string): string | undefined;
|
|
114
|
+
//# sourceMappingURL=process.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,GAAG,IAAI,CAAA;IAC9C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,GAAG,IAAI,CAAA;IAC9C,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,GAAG,MAAM,GAAG,OAAO,CAAA;IAC/C,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,IAAI,CAAA;IAClF,cAAc,CAAC,CAAC,KAAK,EAAE,OAAO,GAAG,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