@eserstack/ai 0.0.0-bootstrap.0 → 5.0.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 (62) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +498 -0
  3. package/dist/adapters/ajan-bridge.d.ts +69 -0
  4. package/dist/adapters/ajan-bridge.js +661 -0
  5. package/dist/adapters/anthropic.d.ts +25 -0
  6. package/dist/adapters/anthropic.js +567 -0
  7. package/dist/adapters/claude-code.d.ts +28 -0
  8. package/dist/adapters/claude-code.js +462 -0
  9. package/dist/adapters/cli-shared.d.ts +36 -0
  10. package/dist/adapters/cli-shared.js +207 -0
  11. package/dist/adapters/gemini.d.ts +19 -0
  12. package/dist/adapters/gemini.js +91 -0
  13. package/dist/adapters/google-shared.d.ts +58 -0
  14. package/dist/adapters/google-shared.js +424 -0
  15. package/dist/adapters/kiro.d.ts +19 -0
  16. package/dist/adapters/kiro.js +195 -0
  17. package/dist/adapters/mod.d.ts +61 -0
  18. package/dist/adapters/mod.js +129 -0
  19. package/dist/adapters/ollama.d.ts +20 -0
  20. package/dist/adapters/ollama.js +226 -0
  21. package/dist/adapters/openai.d.ts +25 -0
  22. package/dist/adapters/openai.js +553 -0
  23. package/dist/adapters/opencode.d.ts +19 -0
  24. package/dist/adapters/opencode.js +158 -0
  25. package/dist/adapters/vertexai.d.ts +19 -0
  26. package/dist/adapters/vertexai.js +96 -0
  27. package/dist/batch.d.ts +35 -0
  28. package/dist/batch.js +2 -0
  29. package/dist/commands/ask.d.ts +30 -0
  30. package/dist/commands/ask.js +404 -0
  31. package/dist/commands/list.d.ts +2 -0
  32. package/dist/commands/list.js +35 -0
  33. package/dist/config.d.ts +21 -0
  34. package/dist/config.js +16 -0
  35. package/dist/content.d.ts +14 -0
  36. package/dist/content.js +103 -0
  37. package/dist/detect.d.ts +9 -0
  38. package/dist/detect.js +125 -0
  39. package/dist/errors.d.ts +62 -0
  40. package/dist/errors.js +135 -0
  41. package/dist/generation.d.ts +126 -0
  42. package/dist/generation.js +96 -0
  43. package/dist/main.d.ts +22 -0
  44. package/dist/main.js +42 -0
  45. package/dist/mod.d.ts +16 -0
  46. package/dist/mod.js +11 -0
  47. package/dist/model.d.ts +27 -0
  48. package/dist/model.js +12 -0
  49. package/dist/module.d.ts +10 -0
  50. package/dist/module.js +21 -0
  51. package/dist/package.json +74 -0
  52. package/dist/registry.d.ts +22 -0
  53. package/dist/registry.js +97 -0
  54. package/dist/streams/layers.d.ts +4 -0
  55. package/dist/streams/layers.js +33 -0
  56. package/dist/streams/mod.d.ts +2 -0
  57. package/dist/streams/mod.js +5 -0
  58. package/dist/streams/sources.d.ts +6 -0
  59. package/dist/streams/sources.js +76 -0
  60. package/dist/types.d.ts +79 -0
  61. package/dist/types.js +2 -0
  62. package/package.json +63 -1
@@ -0,0 +1,61 @@
1
+ import type * as model from "../model.ts";
2
+ export { anthropicFactory, AnthropicModel } from "./anthropic.ts";
3
+ export { openaiFactory, OpenAIModel } from "./openai.ts";
4
+ export { geminiFactory, GeminiModel } from "./gemini.ts";
5
+ export { vertexaiFactory, VertexAIModel } from "./vertexai.ts";
6
+ export { claudeCodeFactory, ClaudeCodeModel } from "./claude-code.ts";
7
+ export { ollamaFactory, OllamaModel } from "./ollama.ts";
8
+ export { openCodeFactory, OpenCodeModel } from "./opencode.ts";
9
+ export { kiroFactory, KiroModel } from "./kiro.ts";
10
+ export { AjanBridgeModel, AjanBridgeModelFactory, createBridgeFactories, getBridgeLoadError, tryLoadBridgeFactories, } from "./ajan-bridge.ts";
11
+ export { classifyGenAIError, mapContentBlockToGenAIPart, mapGenAIResponseToResult, mapMessagesToGenAI, mapRoleToGenAI, mapToolsToGenAI, } from "./google-shared.ts";
12
+ export { captureStderr, classifyExitCode, formatMessagesAsText, parseJsonlStream, parseTextOutput, resolveBinary, spawnCliProcess, stopCliProcess, } from "./cli-shared.ts";
13
+ /**
14
+ * Returns the default set of provider factories.
15
+ *
16
+ * The Go FFI bridge is preferred per provider, with the pure-TypeScript adapter
17
+ * used for any provider the bridge does not offer. The result is cached after
18
+ * the first call.
19
+ *
20
+ * # Per provider, not all-or-nothing
21
+ *
22
+ * This used to be a single switch: if the bridge loaded at all, its factories
23
+ * replaced the entire TS set; otherwise the TS set was used whole. The doc
24
+ * comment described the per-provider behaviour, but the code never did it.
25
+ *
26
+ * The payload losses that once made the two sets non-interchangeable are fixed:
27
+ * the bridge now carries every generation option, tool definitions, tool calls
28
+ * in both directions, image/audio payloads, AbortSignal and the typed error
29
+ * hierarchy.
30
+ *
31
+ * The TS adapters are kept anyway, and not out of inertia. They are the only
32
+ * working path when `@eserstack/ajan` cannot load a NATIVE binary — an npm
33
+ * install whose per-platform optionalDependency did not install, or a platform
34
+ * with no prebuilt artifact. The bridge deliberately refuses to load over WASM
35
+ * (see tryLoadBridgeFactories) precisely so that case falls back here instead of
36
+ * registering a provider that is present and broken.
37
+ */
38
+ export declare const defaultFactories: () => Promise<readonly model.ProviderFactory[]>;
39
+ /**
40
+ * Returns the pure-TypeScript adapter for one provider, bypassing the bridge.
41
+ *
42
+ * This is what a machine with no usable native binary gets, so it is also the
43
+ * only way to exercise that path without disabling FFI process-wide — which a
44
+ * test cannot do, because an environment variable set for the process affects
45
+ * every other test running in it, not just its own.
46
+ *
47
+ * Undefined for a provider with no TypeScript adapter.
48
+ */
49
+ export declare const tsFactoryFor: (provider: string) => Promise<model.ProviderFactory | undefined>;
50
+ /**
51
+ * Returns the factory for one provider, applying the same preference
52
+ * {@link defaultFactories} does: the Go bridge when it offers that provider,
53
+ * the pure-TypeScript adapter otherwise.
54
+ *
55
+ * Undefined for a provider neither side knows.
56
+ *
57
+ * This exists so a single-provider caller does not have to choose between the
58
+ * merge and laziness. `ai ask` previously hand-rolled its own switch over the
59
+ * TS adapters, which meant it silently never used the bridge at all.
60
+ */
61
+ export declare const factoryFor: (provider: string) => Promise<model.ProviderFactory | undefined>;
@@ -0,0 +1,129 @@
1
+ // Copyright 2023-present Eser Ozvataf and other contributors. All rights reserved. Apache-2.0 license.
2
+ // API adapter factories
3
+ export { anthropicFactory, AnthropicModel } from "./anthropic.js";
4
+ export { openaiFactory, OpenAIModel } from "./openai.js";
5
+ export { geminiFactory, GeminiModel } from "./gemini.js";
6
+ export { vertexaiFactory, VertexAIModel } from "./vertexai.js";
7
+ // CLI / local adapter factories
8
+ export { claudeCodeFactory, ClaudeCodeModel } from "./claude-code.js";
9
+ export { ollamaFactory, OllamaModel } from "./ollama.js";
10
+ export { openCodeFactory, OpenCodeModel } from "./opencode.js";
11
+ export { kiroFactory, KiroModel } from "./kiro.js";
12
+ // Go FFI bridge (requires @eserstack/ajan native library or WASM)
13
+ export { AjanBridgeModel, AjanBridgeModelFactory, createBridgeFactories, getBridgeLoadError, tryLoadBridgeFactories, } from "./ajan-bridge.js";
14
+ // Shared utilities
15
+ export { classifyGenAIError, mapContentBlockToGenAIPart, mapGenAIResponseToResult, mapMessagesToGenAI, mapRoleToGenAI, mapToolsToGenAI, } from "./google-shared.js";
16
+ export { captureStderr, classifyExitCode, formatMessagesAsText, parseJsonlStream, parseTextOutput, resolveBinary, spawnCliProcess, stopCliProcess, } from "./cli-shared.js";
17
+ // =============================================================================
18
+ // Default Factories
19
+ // =============================================================================
20
+ // The in-flight promise is cached, not the resolved value. Caching the value
21
+ // meant two concurrent first calls both ran the FFI load, and — worse — a load
22
+ // that failed was retried forever while one that succeeded was never revisited.
23
+ let cachedFactories = null;
24
+ /**
25
+ * Returns the default set of provider factories.
26
+ *
27
+ * The Go FFI bridge is preferred per provider, with the pure-TypeScript adapter
28
+ * used for any provider the bridge does not offer. The result is cached after
29
+ * the first call.
30
+ *
31
+ * # Per provider, not all-or-nothing
32
+ *
33
+ * This used to be a single switch: if the bridge loaded at all, its factories
34
+ * replaced the entire TS set; otherwise the TS set was used whole. The doc
35
+ * comment described the per-provider behaviour, but the code never did it.
36
+ *
37
+ * The payload losses that once made the two sets non-interchangeable are fixed:
38
+ * the bridge now carries every generation option, tool definitions, tool calls
39
+ * in both directions, image/audio payloads, AbortSignal and the typed error
40
+ * hierarchy.
41
+ *
42
+ * The TS adapters are kept anyway, and not out of inertia. They are the only
43
+ * working path when `@eserstack/ajan` cannot load a NATIVE binary — an npm
44
+ * install whose per-platform optionalDependency did not install, or a platform
45
+ * with no prebuilt artifact. The bridge deliberately refuses to load over WASM
46
+ * (see tryLoadBridgeFactories) precisely so that case falls back here instead of
47
+ * registering a provider that is present and broken.
48
+ */
49
+ export const defaultFactories = () => {
50
+ cachedFactories ??= loadFactories();
51
+ return cachedFactories;
52
+ };
53
+ /**
54
+ * The pure-TypeScript adapter for each provider, behind a lazy import.
55
+ *
56
+ * Importers rather than instances so a caller that wants ONE provider pays for
57
+ * one vendor SDK. `ai ask` resolves a single provider per invocation, and
58
+ * eagerly importing all eight would make it load three SDKs it will not use.
59
+ *
60
+ * A Map, so a provider name such as "constructor" finds no loader instead of
61
+ * an Object.prototype member.
62
+ */
63
+ const TS_FACTORY_LOADERS = new Map([
64
+ ["anthropic", async () => (await import("./anthropic.js")).anthropicFactory],
65
+ ["openai", async () => (await import("./openai.js")).openaiFactory],
66
+ ["gemini", async () => (await import("./gemini.js")).geminiFactory],
67
+ ["vertexai", async () => (await import("./vertexai.js")).vertexaiFactory],
68
+ [
69
+ "claude-code",
70
+ async () => (await import("./claude-code.js")).claudeCodeFactory,
71
+ ],
72
+ ["ollama", async () => (await import("./ollama.js")).ollamaFactory],
73
+ ["opencode", async () => (await import("./opencode.js")).openCodeFactory],
74
+ ["kiro", async () => (await import("./kiro.js")).kiroFactory],
75
+ ]);
76
+ // The bridge load is cached separately from defaultFactories so a single-provider
77
+ // lookup does not repeat the dlopen, and so both paths agree on what the bridge
78
+ // offers.
79
+ let cachedBridge = null;
80
+ const bridgeFactories = () => {
81
+ cachedBridge ??= (async () => {
82
+ const ajanBridge = await import("./ajan-bridge.js");
83
+ return await ajanBridge.tryLoadBridgeFactories();
84
+ })();
85
+ return cachedBridge;
86
+ };
87
+ /**
88
+ * Returns the pure-TypeScript adapter for one provider, bypassing the bridge.
89
+ *
90
+ * This is what a machine with no usable native binary gets, so it is also the
91
+ * only way to exercise that path without disabling FFI process-wide — which a
92
+ * test cannot do, because an environment variable set for the process affects
93
+ * every other test running in it, not just its own.
94
+ *
95
+ * Undefined for a provider with no TypeScript adapter.
96
+ */
97
+ export const tsFactoryFor = async (provider) => await TS_FACTORY_LOADERS.get(provider)?.();
98
+ /**
99
+ * Returns the factory for one provider, applying the same preference
100
+ * {@link defaultFactories} does: the Go bridge when it offers that provider,
101
+ * the pure-TypeScript adapter otherwise.
102
+ *
103
+ * Undefined for a provider neither side knows.
104
+ *
105
+ * This exists so a single-provider caller does not have to choose between the
106
+ * merge and laziness. `ai ask` previously hand-rolled its own switch over the
107
+ * TS adapters, which meant it silently never used the bridge at all.
108
+ */
109
+ export const factoryFor = async (provider) => {
110
+ for (const factory of await bridgeFactories()) {
111
+ if (factory.provider === provider) {
112
+ return factory;
113
+ }
114
+ }
115
+ return await tsFactoryFor(provider);
116
+ };
117
+ const loadFactories = async () => {
118
+ const tsFactories = await Promise.all([...TS_FACTORY_LOADERS.values()].map((load) => load()));
119
+ const byProvider = new Map();
120
+ // TS first, bridge second: the bridge wins where it has an entry, and the TS
121
+ // adapter remains for every provider it does not.
122
+ for (const factory of tsFactories) {
123
+ byProvider.set(factory.provider, factory);
124
+ }
125
+ for (const factory of await bridgeFactories()) {
126
+ byProvider.set(factory.provider, factory);
127
+ }
128
+ return [...byProvider.values()];
129
+ };
@@ -0,0 +1,20 @@
1
+ import * as results from "@eserstack/primitives/results";
2
+ import type * as types from "../types.ts";
3
+ import type * as config from "../config.ts";
4
+ import * as generation from "../generation.ts";
5
+ import type * as model from "../model.ts";
6
+ import * as errors from "../errors.ts";
7
+ export declare class OllamaModel implements model.LanguageModel {
8
+ readonly capabilities: readonly types.ProviderCapability[];
9
+ readonly provider = "ollama";
10
+ readonly modelId: string;
11
+ private readonly _baseUrl;
12
+ private readonly _client;
13
+ private readonly config;
14
+ constructor(baseUrl: string, cfg: config.ResolvedConfigTarget);
15
+ generateText(options: generation.GenerateTextOptions, signal?: AbortSignal): Promise<results.Result<generation.GenerateTextResult, errors.AiError>>;
16
+ streamText(options: generation.GenerateTextOptions, signal?: AbortSignal): AsyncIterable<generation.StreamEvent>;
17
+ close(): Promise<void>;
18
+ getRawClient(): unknown;
19
+ }
20
+ export declare const ollamaFactory: model.ProviderFactory;
@@ -0,0 +1,226 @@
1
+ // Copyright 2023-present Eser Ozvataf and other contributors. All rights reserved. Apache-2.0 license.
2
+ import * as results from "@eserstack/primitives/results";
3
+ import * as httpclient from "@eserstack/httpclient";
4
+ import * as generation from "../generation.js";
5
+ import * as errors from "../errors.js";
6
+ import * as cliShared from "./cli-shared.js";
7
+ // =============================================================================
8
+ // Ollama Model (HTTP API)
9
+ // =============================================================================
10
+ const DEFAULT_BASE_URL = "http://localhost:11434";
11
+ export class OllamaModel {
12
+ capabilities = [
13
+ "text_generation",
14
+ "streaming",
15
+ "vision",
16
+ ];
17
+ provider = "ollama";
18
+ modelId;
19
+ _baseUrl;
20
+ _client;
21
+ config;
22
+ constructor(baseUrl, cfg) {
23
+ this._baseUrl = baseUrl;
24
+ this._client = httpclient.createHttpClient({
25
+ baseUrl,
26
+ // AI calls are not retried automatically — consumers decide
27
+ retry: false,
28
+ });
29
+ this.config = cfg;
30
+ this.modelId = cfg.model;
31
+ }
32
+ async generateText(options, signal) {
33
+ try {
34
+ const body = buildChatBody(this.config, options, false);
35
+ const resp = await this._client.post("/api/chat", {
36
+ body,
37
+ signal,
38
+ });
39
+ return results.ok(mapChatResponse(resp.data, this.modelId));
40
+ }
41
+ catch (err) {
42
+ if (err instanceof errors.AiError)
43
+ return results.fail(err);
44
+ const statusCode = err instanceof httpclient.HttpClientError
45
+ ? (err.statusCode ?? undefined)
46
+ : undefined;
47
+ return results.fail(new errors.AiError(err instanceof Error ? err.message : String(err), {
48
+ provider: "ollama",
49
+ statusCode,
50
+ cause: err instanceof Error ? err : undefined,
51
+ }));
52
+ }
53
+ }
54
+ async *streamText(options, signal) {
55
+ try {
56
+ const body = buildChatBody(this.config, options, true);
57
+ const streamResp = await this._client.postStream("/api/chat", {
58
+ body,
59
+ signal,
60
+ });
61
+ for await (const event of cliShared.parseJsonlStream(streamResp.body)) {
62
+ const streamEvent = mapStreamEvent(event);
63
+ if (streamEvent !== null) {
64
+ yield streamEvent;
65
+ }
66
+ }
67
+ }
68
+ catch (err) {
69
+ if (err instanceof errors.AiError) {
70
+ yield { kind: "error", error: err };
71
+ }
72
+ else {
73
+ const statusCode = err instanceof httpclient.HttpClientError
74
+ ? (err.statusCode ?? undefined)
75
+ : undefined;
76
+ yield {
77
+ kind: "error",
78
+ error: new errors.AiError(err instanceof Error ? err.message : String(err), {
79
+ provider: "ollama",
80
+ statusCode,
81
+ cause: err instanceof Error ? err : undefined,
82
+ }),
83
+ };
84
+ }
85
+ }
86
+ }
87
+ close() {
88
+ return Promise.resolve();
89
+ }
90
+ getRawClient() {
91
+ return null;
92
+ }
93
+ }
94
+ // =============================================================================
95
+ // Factory
96
+ // =============================================================================
97
+ export const ollamaFactory = {
98
+ provider: "ollama",
99
+ createModel(cfg) {
100
+ const baseUrl = cfg.properties?.["baseUrl"] ?? DEFAULT_BASE_URL;
101
+ return Promise.resolve(new OllamaModel(baseUrl, cfg));
102
+ },
103
+ };
104
+ // =============================================================================
105
+ // Internal Helpers
106
+ // =============================================================================
107
+ /**
108
+ * Builds the /api/chat request body. options.effort is ignored: Ollama has no
109
+ * effort setting that every model accepts.
110
+ */
111
+ const buildChatBody = (cfg, options, stream) => {
112
+ const messages = mapMessages(options.messages, options.system);
113
+ const body = {
114
+ model: cfg.model,
115
+ messages,
116
+ stream,
117
+ };
118
+ const ollamaOptions = {};
119
+ if (options.temperature !== undefined) {
120
+ ollamaOptions["temperature"] = options.temperature;
121
+ }
122
+ if (options.maxTokens !== undefined) {
123
+ ollamaOptions["num_predict"] = options.maxTokens;
124
+ }
125
+ if (options.topP !== undefined) {
126
+ ollamaOptions["top_p"] = options.topP;
127
+ }
128
+ if (options.stopWords !== undefined) {
129
+ ollamaOptions["stop"] = options.stopWords;
130
+ }
131
+ if (Object.keys(ollamaOptions).length > 0) {
132
+ body["options"] = ollamaOptions;
133
+ }
134
+ if (options.responseFormat !== undefined) {
135
+ if (options.responseFormat.type === "json_schema") {
136
+ body["format"] = generation.requireJsonSchema(options.responseFormat, "ollama");
137
+ }
138
+ else if (options.responseFormat.type === "json_object") {
139
+ body["format"] = "json";
140
+ }
141
+ }
142
+ return body;
143
+ };
144
+ const mapMessages = (messages, system) => {
145
+ const result = [];
146
+ if (system !== undefined) {
147
+ result.push({ role: "system", content: system });
148
+ }
149
+ for (const message of messages) {
150
+ if (message.role === "system") {
151
+ const textParts = [];
152
+ for (const block of message.content) {
153
+ if (block.kind === "text") {
154
+ textParts.push(block.text);
155
+ }
156
+ }
157
+ result.push({ role: "system", content: textParts.join("\n") });
158
+ continue;
159
+ }
160
+ const textParts = [];
161
+ const images = [];
162
+ for (const block of message.content) {
163
+ if (block.kind === "text") {
164
+ textParts.push(block.text);
165
+ }
166
+ else if (block.kind === "image") {
167
+ if (block.image.url !== undefined) {
168
+ images.push(block.image.url);
169
+ }
170
+ }
171
+ }
172
+ const msg = {
173
+ role: message.role === "tool" ? "user" : message.role,
174
+ content: textParts.join("\n"),
175
+ };
176
+ if (images.length > 0) {
177
+ msg["images"] = images;
178
+ }
179
+ result.push(msg);
180
+ }
181
+ return result;
182
+ };
183
+ const mapChatResponse = (result, modelId) => {
184
+ const contentBlocks = [];
185
+ if (result.message?.content !== undefined) {
186
+ contentBlocks.push({ kind: "text", text: result.message.content });
187
+ }
188
+ return {
189
+ content: contentBlocks,
190
+ stopReason: result.done_reason === "length" ? "max_tokens" : "end_turn",
191
+ usage: {
192
+ inputTokens: result.prompt_eval_count ?? 0,
193
+ outputTokens: result.eval_count ?? 0,
194
+ totalTokens: (result.prompt_eval_count ?? 0) + (result.eval_count ?? 0),
195
+ },
196
+ modelId,
197
+ rawResponse: result,
198
+ };
199
+ };
200
+ const mapStreamEvent = (event) => {
201
+ if (event === null || typeof event !== "object") {
202
+ return null;
203
+ }
204
+ // Stream events are untyped JSON; each field is checked before use.
205
+ // oxlint-disable-next-line typescript/no-explicit-any
206
+ const obj = event;
207
+ if (obj.done === true) {
208
+ return {
209
+ kind: "message_done",
210
+ stopReason: obj.done_reason === "length" ? "max_tokens" : "end_turn",
211
+ usage: {
212
+ inputTokens: obj.prompt_eval_count ?? 0,
213
+ outputTokens: obj.eval_count ?? 0,
214
+ totalTokens: (obj.prompt_eval_count ?? 0) + (obj.eval_count ?? 0),
215
+ },
216
+ };
217
+ }
218
+ if (obj.message?.content !== undefined && obj.message.content.length > 0) {
219
+ return { kind: "content_delta", textDelta: obj.message.content };
220
+ }
221
+ // Legacy /api/generate format
222
+ if (obj.response !== undefined && obj.response.length > 0) {
223
+ return { kind: "content_delta", textDelta: obj.response };
224
+ }
225
+ return null;
226
+ };
@@ -0,0 +1,25 @@
1
+ import * as results from "@eserstack/primitives/results";
2
+ import type * as types from "../types.ts";
3
+ import type * as config from "../config.ts";
4
+ import * as generation from "../generation.ts";
5
+ import type * as batch from "../batch.ts";
6
+ import type * as model from "../model.ts";
7
+ import * as errors from "../errors.ts";
8
+ export declare class OpenAIModel implements model.LanguageModel, model.BatchCapableModel {
9
+ readonly capabilities: readonly types.ProviderCapability[];
10
+ readonly provider = "openai";
11
+ readonly modelId: string;
12
+ private readonly client;
13
+ private readonly config;
14
+ constructor(client: any, cfg: config.ResolvedConfigTarget);
15
+ generateText(options: generation.GenerateTextOptions, signal?: AbortSignal): Promise<results.Result<generation.GenerateTextResult, errors.AiError>>;
16
+ streamText(options: generation.GenerateTextOptions, signal?: AbortSignal): AsyncIterable<generation.StreamEvent>;
17
+ submitBatch(request: batch.BatchRequest, signal?: AbortSignal): Promise<batch.BatchJob>;
18
+ getBatchJob(jobId: string, signal?: AbortSignal): Promise<batch.BatchJob>;
19
+ listBatchJobs(options?: batch.ListBatchOptions, signal?: AbortSignal): Promise<readonly batch.BatchJob[]>;
20
+ downloadBatchResults(job: batch.BatchJob, signal?: AbortSignal): Promise<readonly batch.BatchResult[]>;
21
+ cancelBatchJob(jobId: string, signal?: AbortSignal): Promise<void>;
22
+ close(): Promise<void>;
23
+ getRawClient(): unknown;
24
+ }
25
+ export declare const openaiFactory: model.ProviderFactory;