@vellumai/credential-executor 0.8.4 → 0.8.6

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/src/server.ts CHANGED
@@ -94,6 +94,11 @@ export interface CesServerOptions {
94
94
  onApiKeyUpdate?: (assistantApiKey: string, assistantId?: string) => void;
95
95
  }
96
96
 
97
+ export type ServeEndReason =
98
+ | "input_stream_ended"
99
+ | "signal_aborted"
100
+ | "signal_aborted_before_start";
101
+
97
102
  // ---------------------------------------------------------------------------
98
103
  // Server implementation
99
104
  // ---------------------------------------------------------------------------
@@ -134,17 +139,17 @@ export class CesRpcServer {
134
139
  * Start serving. Returns a promise that resolves when the input stream
135
140
  * ends or the abort signal fires.
136
141
  */
137
- async serve(): Promise<void> {
138
- return new Promise<void>((resolve, reject) => {
142
+ async serve(): Promise<ServeEndReason> {
143
+ return new Promise<ServeEndReason>((resolve, reject) => {
139
144
  if (this.signal?.aborted) {
140
145
  this.close();
141
- resolve();
146
+ resolve("signal_aborted_before_start");
142
147
  return;
143
148
  }
144
149
 
145
150
  const onAbort = () => {
146
151
  this.close();
147
- resolve();
152
+ resolve("signal_aborted");
148
153
  };
149
154
 
150
155
  if (this.signal) {
@@ -162,7 +167,7 @@ export class CesRpcServer {
162
167
  this.signal.removeEventListener("abort", onAbort);
163
168
  }
164
169
  this.close();
165
- resolve();
170
+ resolve("input_stream_ended");
166
171
  });
167
172
 
168
173
  this.input.on("error", (err) => {
@@ -190,7 +195,7 @@ export class CesRpcServer {
190
195
  if (this.closed) return;
191
196
  this.closed = true;
192
197
  this.input.destroy();
193
- if (typeof (this.output as any).destroy === "function") {
198
+ if (typeof (this.output as { destroy?: () => void }).destroy === "function") {
194
199
  this.output.destroy();
195
200
  }
196
201
  }