@proposit/proposit-core 1.9.0 → 1.11.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.
Files changed (35) hide show
  1. package/dist/extensions/openai/errors.d.ts +23 -0
  2. package/dist/extensions/openai/errors.d.ts.map +1 -1
  3. package/dist/extensions/openai/errors.js +28 -0
  4. package/dist/extensions/openai/errors.js.map +1 -1
  5. package/dist/extensions/openai/index.d.ts +3 -3
  6. package/dist/extensions/openai/index.d.ts.map +1 -1
  7. package/dist/extensions/openai/index.js +4 -3
  8. package/dist/extensions/openai/index.js.map +1 -1
  9. package/dist/extensions/openai/provider.d.ts +167 -1
  10. package/dist/extensions/openai/provider.d.ts.map +1 -1
  11. package/dist/extensions/openai/provider.js +359 -17
  12. package/dist/extensions/openai/provider.js.map +1 -1
  13. package/dist/lib/index.d.ts +3 -3
  14. package/dist/lib/index.d.ts.map +1 -1
  15. package/dist/lib/index.js +1 -1
  16. package/dist/lib/index.js.map +1 -1
  17. package/dist/lib/llm/index.d.ts +1 -1
  18. package/dist/lib/llm/index.d.ts.map +1 -1
  19. package/dist/lib/llm/types.d.ts +55 -0
  20. package/dist/lib/llm/types.d.ts.map +1 -1
  21. package/dist/lib/pipelines/execute.d.ts +175 -3
  22. package/dist/lib/pipelines/execute.d.ts.map +1 -1
  23. package/dist/lib/pipelines/execute.js +574 -219
  24. package/dist/lib/pipelines/execute.js.map +1 -1
  25. package/dist/lib/pipelines/index.d.ts +2 -2
  26. package/dist/lib/pipelines/index.d.ts.map +1 -1
  27. package/dist/lib/pipelines/index.js +1 -1
  28. package/dist/lib/pipelines/index.js.map +1 -1
  29. package/dist/lib/pipelines/stage-helpers.d.ts +80 -1
  30. package/dist/lib/pipelines/stage-helpers.d.ts.map +1 -1
  31. package/dist/lib/pipelines/stage-helpers.js +247 -28
  32. package/dist/lib/pipelines/stage-helpers.js.map +1 -1
  33. package/dist/lib/pipelines/types.d.ts +25 -0
  34. package/dist/lib/pipelines/types.d.ts.map +1 -1
  35. package/package.json +1 -1
@@ -63,4 +63,27 @@ export declare class ToolLoopExhaustedError extends Error {
63
63
  rounds: number;
64
64
  });
65
65
  }
66
+ /**
67
+ * Thrown by {@link retrieveResponse} (and the background poll loop) when
68
+ * a stored response is not found (HTTP 404). This typically means the
69
+ * ~10-minute retention window has elapsed. Callers should clear the
70
+ * stored id, settle the associated stage as failed, and surface a retry
71
+ * prompt.
72
+ *
73
+ * Extends {@link NonRetryableLlmError} so it inherits the fail-fast
74
+ * disposition: a 404 is deterministic — re-fetching the same aged-out id
75
+ * will 404 again — so the framework must not burn a retry. Inheriting the
76
+ * base (which carries **no** `retryReason` tag) means `llmStage`
77
+ * classifies it as `non_retryable`, exactly as the prior generic
78
+ * `NonRetryableLlmError` did when a 404 surfaced mid-poll — so this is a
79
+ * strictly more specific, behavior-preserving subclass. Callers that
80
+ * `instanceof NonRetryableLlmError` still match; callers wanting the
81
+ * aged-out signal specifically can `instanceof ResponseNotFoundError`.
82
+ */
83
+ export declare class ResponseNotFoundError extends NonRetryableLlmError {
84
+ readonly responseId: string;
85
+ constructor(args: {
86
+ responseId: string;
87
+ });
88
+ }
66
89
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/extensions/openai/errors.ts"],"names":[],"mappings":"AAyCA,qBAAa,iBAAkB,SAAQ,KAAK;IACxC,SAAgB,WAAW,EAAG,WAAW,CAAS;IAClD,SAAgB,MAAM,CAAC,EAAE,MAAM,CAAA;gBAEnB,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;CAKzD;AAED,qBAAa,iBAAkB,SAAQ,KAAK;IACxC,SAAgB,WAAW,EAAG,YAAY,CAAS;IACnD,SAAgB,MAAM,CAAC,EAAE,MAAM,CAAA;gBAEnB,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAA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retrieveResponse} (and the background poll loop) when
114
+ * a stored response is not found (HTTP 404). This typically means the
115
+ * ~10-minute retention window has elapsed. Callers should clear the
116
+ * stored id, settle the associated stage as failed, and surface a retry
117
+ * prompt.
118
+ *
119
+ * Extends {@link NonRetryableLlmError} so it inherits the fail-fast
120
+ * disposition: a 404 is deterministic — re-fetching the same aged-out id
121
+ * will 404 again — so the framework must not burn a retry. Inheriting the
122
+ * base (which carries **no** `retryReason` tag) means `llmStage`
123
+ * classifies it as `non_retryable`, exactly as the prior generic
124
+ * `NonRetryableLlmError` did when a 404 surfaced mid-poll — so this is a
125
+ * strictly more specific, behavior-preserving subclass. Callers that
126
+ * `instanceof NonRetryableLlmError` still match; callers wanting the
127
+ * aged-out signal specifically can `instanceof ResponseNotFoundError`.
128
+ */
129
+ export class ResponseNotFoundError extends NonRetryableLlmError {
130
+ responseId;
131
+ constructor(args) {
132
+ super({
133
+ message: `OpenAI response "${args.responseId}" was not found (404). The ~10-minute retention window may have elapsed.`,
134
+ status: 404,
135
+ });
136
+ this.name = "ResponseNotFoundError";
137
+ this.responseId = args.responseId;
138
+ }
139
+ }
112
140
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/extensions/openai/errors.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,EAAE;AACF,qEAAqE;AACrE,8DAA8D;AAC9D,+DAA+D;AAC/D,sEAAsE;AACtE,0CAA0C;AAC1C,EAAE;AACF,mDAAmD;AACnD,mDAAmD;AACnD,EAAE;AACF,4DAA4D;AAC5D,8DAA8D;AAC9D,sBAAsB;AACtB,mEAAmE;AACnE,gDAAgD;AAChD,sEAAsE;AACtE,4CAA4C;AAC5C,mEAAmE;AACnE,gEAAgE;AAChE,sEAAsE;AACtE,qEAAqE;AACrE,qEAAqE;AACrE,6DAA6D;AAC7D,mEAAmE;AACnE,+CAA+C;AAC/C,6DAA6D;AAC7D,gEAAgE;AAChE,iEAAiE;AAC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,OAAO,CAAC,CAAA;QACnB,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAA;QAClC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;IAC7B,CAAC;CACJ;AAED,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC7B,MAAM,CAAQ;IAE9B,YAAY,IAAyC;QACjD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACnB,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAA;QACpC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;IAC7B,CAAC;CACJ;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,qBAAsB,SAAQ,oBAAoB;IAC3C,UAAU,CAAQ;IAElC,YAAY,IAA4B;QACpC,KAAK,CAAC;YACF,OAAO,EAAE,oBAAoB,IAAI,CAAC,UAAU,0EAA0E;YACtH,MAAM,EAAE,GAAG;SACd,CAAC,CAAA;QACF,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAA;QACnC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAA;IACrC,CAAC;CACJ"}
@@ -1,7 +1,7 @@
1
- export { createOpenAiResponsesProvider } from "./provider.js";
2
- export type { TCreateOpenAiResponsesProviderOptions } from "./provider.js";
1
+ export { createOpenAiResponsesProvider, retrieveResponse, reconnectStream, cancelResponse, submitBackgroundResponse, } from "./provider.js";
2
+ export type { TCreateOpenAiResponsesProviderOptions, TRetrievedResponse, TResponseStatus, } from "./provider.js";
3
3
  export type { TOpenAiFetch } from "./types.js";
4
- export { NonRetryableLlmError, QuotaExhaustedLlmError, RateLimitLlmError, SchemaValidationLlmError, ToolLoopExhaustedError, TransientLlmError, } from "./errors.js";
4
+ export { NonRetryableLlmError, QuotaExhaustedLlmError, RateLimitLlmError, ResponseNotFoundError, SchemaValidationLlmError, ToolLoopExhaustedError, TransientLlmError, } from "./errors.js";
5
5
  export { typeboxToOpenAiSchema } from "./structured-output.js";
6
6
  export type { TOpenAiJsonSchema } from "./structured-output.js";
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/openai/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAA;AAC7D,YAAY,EAAE,qCAAqC,EAAE,MAAM,eAAe,CAAA;AAC1E,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,EACH,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,EACtB,iBAAiB,GACpB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,YAAY,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/openai/index.ts"],"names":[],"mappings":"AAQA,OAAO,EACH,6BAA6B,EAC7B,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,wBAAwB,GAC3B,MAAM,eAAe,CAAA;AACtB,YAAY,EACR,qCAAqC,EACrC,kBAAkB,EAClB,eAAe,GAClB,MAAM,eAAe,CAAA;AACtB,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,EACH,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,iBAAiB,GACpB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,YAAY,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA"}
@@ -3,8 +3,9 @@
3
3
  // Public surface consumed by `proposit-server`, the CLI, and other
4
4
  // callers: the provider constructor + caller-facing config types +
5
5
  // the error classes that callers may want to `instanceof`-match for
6
- // finer-grained observability.
7
- export { createOpenAiResponsesProvider } from "./provider.js";
8
- export { NonRetryableLlmError, QuotaExhaustedLlmError, RateLimitLlmError, SchemaValidationLlmError, ToolLoopExhaustedError, TransientLlmError, } from "./errors.js";
6
+ // finer-grained observability + the response retrieval / reconnect /
7
+ // cancel API for resync.
8
+ export { createOpenAiResponsesProvider, retrieveResponse, reconnectStream, cancelResponse, submitBackgroundResponse, } from "./provider.js";
9
+ export { NonRetryableLlmError, QuotaExhaustedLlmError, RateLimitLlmError, ResponseNotFoundError, SchemaValidationLlmError, ToolLoopExhaustedError, TransientLlmError, } from "./errors.js";
9
10
  export { typeboxToOpenAiSchema } from "./structured-output.js";
10
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/openai/index.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,EAAE;AACF,mEAAmE;AACnE,mEAAmE;AACnE,oEAAoE;AACpE,+BAA+B;AAE/B,OAAO,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAA;AAG7D,OAAO,EACH,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,EACtB,iBAAiB,GACpB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/openai/index.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,EAAE;AACF,mEAAmE;AACnE,mEAAmE;AACnE,oEAAoE;AACpE,qEAAqE;AACrE,yBAAyB;AAEzB,OAAO,EACH,6BAA6B,EAC7B,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,wBAAwB,GAC3B,MAAM,eAAe,CAAA;AAOtB,OAAO,EACH,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,iBAAiB,GACpB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA"}
@@ -1,4 +1,4 @@
1
- import type { TLlmProvider } from "../../lib/llm/types.js";
1
+ import type { TLlmProvider, TLlmRequest } from "../../lib/llm/types.js";
2
2
  import type { TOpenAiFetch } from "./types.js";
3
3
  export type TCreateOpenAiResponsesProviderOptions = {
4
4
  apiKey: string;
@@ -38,6 +38,25 @@ export type TCreateOpenAiResponsesProviderOptions = {
38
38
  * `NonRetryableLlmError`.
39
39
  */
40
40
  backgroundMode?: boolean;
41
+ /**
42
+ * Combine OpenAI **background mode** with **live SSE streaming**:
43
+ * the request is submitted with `{ background: true, stream: true,
44
+ * store: true }` so it keeps generating server-side even if the
45
+ * connection drops, and the SSE stream is consumed live while it
46
+ * runs. This is independent of the `stream` option (foreground-
47
+ * only streaming) and `backgroundMode` (poll-only).
48
+ *
49
+ * When `true`, `backgroundMode` is ignored for this provider
50
+ * instance. `stream` is also ignored (SSE is always used in this
51
+ * mode). V1 supports the **no-tools path only**: a request that
52
+ * sets `backgroundStreamMode` and carries `tools` throws
53
+ * `NonRetryableLlmError`.
54
+ *
55
+ * The response id is surfaced immediately from the submit POST
56
+ * body (before any SSE bytes), making it available for durable
57
+ * persistence by the caller. Defaults to **`false`**.
58
+ */
59
+ backgroundStreamMode?: boolean;
41
60
  /**
42
61
  * Poll interval (ms) for the background submit-then-poll loop.
43
62
  * Defaults to 2000. Ignored unless `backgroundMode` is `true`.
@@ -45,4 +64,151 @@ export type TCreateOpenAiResponsesProviderOptions = {
45
64
  backgroundPollIntervalMs?: number;
46
65
  };
47
66
  export declare function createOpenAiResponsesProvider(options: TCreateOpenAiResponsesProviderOptions): TLlmProvider;
67
+ /**
68
+ * The status values the OpenAI Responses API reports for a stored
69
+ * response. `completed` / `failed` / `incomplete` / `cancelled` are
70
+ * terminal; `queued` / `in_progress` are transient.
71
+ */
72
+ export type TResponseStatus = "queued" | "in_progress" | "completed" | "failed" | "incomplete" | "cancelled";
73
+ /**
74
+ * The structured result of a `retrieveResponse` call. All fields
75
+ * except `status` and `rawResponseId` are absent for non-terminal
76
+ * or failed responses.
77
+ */
78
+ export type TRetrievedResponse = {
79
+ /** Current status of the stored response. */
80
+ status: TResponseStatus;
81
+ /**
82
+ * Parsed text output, present when `status === "completed"` and
83
+ * the response carried a `message` output item.
84
+ */
85
+ output?: string;
86
+ /** Token usage reported by OpenAI, when available. */
87
+ tokenUsage?: import("../../lib/llm/types.js").TLlmTokenUsage;
88
+ /** The OpenAI response id that was retrieved. */
89
+ rawResponseId: string;
90
+ /**
91
+ * The envelope's `incomplete_details.reason`, present when
92
+ * `status === "incomplete"` (e.g. `max_output_tokens`,
93
+ * `content_filter`). Lets a completion-side consumer classify an
94
+ * incomplete response without re-deriving it. Additive (since
95
+ * v1.11.0).
96
+ */
97
+ incompleteReason?: string;
98
+ /**
99
+ * The envelope's `error.message`, present when `status === "failed"`.
100
+ * Additive (since v1.11.0).
101
+ */
102
+ errorMessage?: string;
103
+ };
104
+ /**
105
+ * Retrieve a stored OpenAI response by id. Surfaces the current
106
+ * status, output text (when completed), and token usage.
107
+ *
108
+ * Throws {@link ResponseNotFoundError} when the response is not found
109
+ * (HTTP 404), which typically means the ~10-minute retention window
110
+ * has elapsed. Callers should clear the stored id, settle the
111
+ * associated stage as failed, and surface a retry prompt.
112
+ *
113
+ * @param id - The OpenAI response id to retrieve.
114
+ * @param options - Provider configuration (apiKey, optional baseUrl and fetch).
115
+ */
116
+ export declare function retrieveResponse(id: string, options: {
117
+ apiKey: string;
118
+ baseUrl?: string;
119
+ fetch?: TOpenAiFetch;
120
+ signal?: AbortSignal;
121
+ }): Promise<TRetrievedResponse>;
122
+ /**
123
+ * Reconnect to a stored, still-generating background response and
124
+ * **stream it to completion**. This is what actually drives a dropped
125
+ * background response forward: a passive `retrieveResponse` GET only
126
+ * reads the current state and leaves a `queued` / `in_progress`
127
+ * response sitting where it is, whereas reconnecting with `stream=true`
128
+ * resumes consumption so the response reaches a terminal status.
129
+ *
130
+ * Issues `GET /responses/{id}?stream=true&starting_after=<cursor>` and
131
+ * consumes the SSE stream to its terminal event, returning the same
132
+ * {@link TRetrievedResponse} shape as {@link retrieveResponse}.
133
+ *
134
+ * Throws {@link ResponseNotFoundError} when the response is not found
135
+ * (HTTP 404 — typically the ~10-minute retention window elapsed).
136
+ * Honors `signal`: an abort propagates as an `AbortError` from the
137
+ * underlying stream read.
138
+ *
139
+ * @param id - The OpenAI response id to reconnect to.
140
+ * @param options - `apiKey`, optional `startingAfter` SSE cursor
141
+ * (defaults to 0 — replay from the start of the stored stream),
142
+ * optional `baseUrl`, `fetch`, and `signal`.
143
+ */
144
+ export declare function reconnectStream(id: string, options: {
145
+ apiKey: string;
146
+ startingAfter?: number;
147
+ baseUrl?: string;
148
+ fetch?: TOpenAiFetch;
149
+ signal?: AbortSignal;
150
+ }): Promise<TRetrievedResponse>;
151
+ /**
152
+ * Cancel a stored, in-flight OpenAI response. Issues
153
+ * `POST /responses/{id}/cancel` and returns the resulting
154
+ * {@link TRetrievedResponse} (typically `status: "cancelled"`).
155
+ *
156
+ * Cancel is **idempotent** per the Responses API: cancelling twice, or
157
+ * cancelling an already-terminal response, simply returns the final
158
+ * `Response` object rather than erroring — so callers do not need to
159
+ * guard against double-cancel.
160
+ *
161
+ * Throws {@link ResponseNotFoundError} when the response is not found
162
+ * (HTTP 404 — typically the ~10-minute retention window elapsed).
163
+ * Honors `signal` (an abort propagates as an `AbortError`).
164
+ *
165
+ * Use this to stop an in-flight background response when a stage is
166
+ * abandoned (resync timeout) or an import is cancelled, so generation
167
+ * does not keep running (and billing) server-side after the consumer
168
+ * has given up on it.
169
+ *
170
+ * @param id - The OpenAI response id to cancel.
171
+ * @param options - `apiKey`, optional `baseUrl`, `fetch`, and `signal`.
172
+ */
173
+ export declare function cancelResponse(id: string, options: {
174
+ apiKey: string;
175
+ baseUrl?: string;
176
+ fetch?: TOpenAiFetch;
177
+ signal?: AbortSignal;
178
+ }): Promise<TRetrievedResponse>;
179
+ /**
180
+ * Submit a background OpenAI response and return its `responseId` +
181
+ * submit-time `status` **without polling or streaming to completion**.
182
+ *
183
+ * This is the submit-only half of the existing `backgroundMode`
184
+ * (`runBackground`): it POSTs `{ background: true, store: true }`, parses
185
+ * the submit envelope, and returns immediately — the caller drives the
186
+ * response to completion later via {@link retrieveResponse} (typically
187
+ * after a durable suspend keyed on the returned `responseId`). It is the
188
+ * provider capability the pipeline's `launchStage` needs.
189
+ *
190
+ * **Terminal-on-submit fast-path:** a small/cached request can come back
191
+ * already terminal (`completed`/`failed`/`incomplete`/`cancelled`) on the
192
+ * submit POST. This function still returns `{ responseId, status }` for
193
+ * that case (no throw, no poll); the caller proceeds to
194
+ * `retrieveResponse(responseId)`, which sees the terminal state
195
+ * immediately.
196
+ *
197
+ * **No-tools precondition:** background mode does not support function
198
+ * tools in V1 — a tool-bearing request throws {@link NonRetryableLlmError},
199
+ * matching `respond`'s background guard.
200
+ *
201
+ * @param req - The structured-output request (system/user prompts +
202
+ * `outputSchema` + model knobs). Tools are rejected.
203
+ * @param options - `apiKey`, optional `baseUrl`, `fetch`, and `signal`.
204
+ */
205
+ export declare function submitBackgroundResponse<T>(req: TLlmRequest<T>, options: {
206
+ apiKey: string;
207
+ baseUrl?: string;
208
+ fetch?: TOpenAiFetch;
209
+ signal?: AbortSignal;
210
+ }): Promise<{
211
+ responseId: string;
212
+ status: TResponseStatus;
213
+ }>;
48
214
  //# sourceMappingURL=provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/extensions/openai/provider.ts"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EACR,YAAY,EAKf,MAAM,wBAAwB,CAAA;AAe/B,OAAO,KAAK,EACR,YAAY,EAMf,MAAM,YAAY,CAAA;AAOnB,MAAM,MAAM,qCAAqC,GAAG;IAChD,MAAM,EAAE,MAAM,CAAA;IACd,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,KAAK,CAAC,EAAE,YAAY,CAAA;IACpB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;OAGG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAA;CACpC,CAAA;AAED,wBAAgB,6BAA6B,CACzC,OAAO,EAAE,qCAAqC,GAC/C,YAAY,CAuSd"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/extensions/openai/provider.ts"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EACR,YAAY,EACZ,WAAW,EAId,MAAM,wBAAwB,CAAA;AAgB/B,OAAO,KAAK,EACR,YAAY,EAMf,MAAM,YAAY,CAAA;AAOnB,MAAM,MAAM,qCAAqC,GAAG;IAChD,MAAM,EAAE,MAAM,CAAA;IACd,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;OAIG;IACH,KAAK,CAAC,EAAE,YAAY,CAAA;IACpB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;;;;;;;;;;;;;;;OAiBG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B;;;OAGG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAA;CACpC,CAAA;AAED,wBAAgB,6BAA6B,CACzC,OAAO,EAAE,qCAAqC,GAC/C,YAAY,CA8Td;AAID;;;;GAIG;AACH,MAAM,MAAM,eAAe,GACrB,QAAQ,GACR,aAAa,GACb,WAAW,GACX,QAAQ,GACR,YAAY,GACZ,WAAW,CAAA;AAEjB;;;;GAIG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