@alienplatform/ai-gateway 3.3.0-dev.0d4f932037814a854d56a7e4e82a8a34cc2e35cb
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/binding.d.ts +29 -0
- package/dist/binding.d.ts.map +1 -0
- package/dist/client.d.ts +132 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/errors.d.ts +167 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/gateway.d.ts +18 -0
- package/dist/gateway.d.ts.map +1 -0
- package/dist/gateway.js +748 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/loader.d.ts +45 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/native.d.ts +30 -0
- package/dist/native.d.ts.map +1 -0
- package/dist/native.js +33 -0
- package/package.json +77 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parsing for the `ALIEN_<NAME>_BINDING` env var an `ai` resource projects. The client only
|
|
3
|
+
* routes on the binding: a BYO-key (`external`) binding is validated strictly here because the
|
|
4
|
+
* client itself uses its fields, while every other service tag — the ambient variants, including
|
|
5
|
+
* ones added to the platform after this SDK shipped — is passed through for the Rust gateway to
|
|
6
|
+
* validate and serve. Mirrors the Rust `AiBinding` (serde tag "service", lowercase, camelCase
|
|
7
|
+
* fields).
|
|
8
|
+
*/
|
|
9
|
+
import * as z from "zod/v4";
|
|
10
|
+
declare const externalAiBindingSchema: z.ZodObject<{
|
|
11
|
+
service: z.ZodLiteral<"external">;
|
|
12
|
+
provider: z.ZodString;
|
|
13
|
+
apiKey: z.ZodString;
|
|
14
|
+
}, z.core.$strict>;
|
|
15
|
+
export type ExternalAiBinding = z.infer<typeof externalAiBindingSchema>;
|
|
16
|
+
/** A binding served by the gateway; `service` may be a variant this SDK predates. */
|
|
17
|
+
export interface AmbientAiBinding {
|
|
18
|
+
service: string;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
}
|
|
21
|
+
export type AiBinding = ExternalAiBinding | AmbientAiBinding;
|
|
22
|
+
/** Narrow an `AiBinding` to the BYO-key variant the client handles itself. */
|
|
23
|
+
export declare function isExternalAiBinding(binding: AiBinding): binding is ExternalAiBinding;
|
|
24
|
+
/** The env var an `ai` binding is projected into: `ALIEN_<NAME>_BINDING` (uppercased, `-`→`_`). */
|
|
25
|
+
export declare function aiBindingEnvVarName(name: string): string;
|
|
26
|
+
/** Parse `ALIEN_<NAME>_BINDING`, or `undefined` if it is not set. Throws on malformed content. */
|
|
27
|
+
export declare function parseAiBinding(name: string): Promise<AiBinding | undefined>;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=binding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../src/binding.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAA;AAI3B,QAAA,MAAM,uBAAuB;;;;kBAMlB,CAAA;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAEvE,qFAAqF;AACrF,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,MAAM,MAAM,SAAS,GAAG,iBAAiB,GAAG,gBAAgB,CAAA;AAE5D,8EAA8E;AAC9E,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO,IAAI,iBAAiB,CAEpF;AAED,mGAAmG;AACnG,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,kGAAkG;AAClG,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAgCjF"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI binding — a thin OpenAI-compatible client to the workload's AI gateway.
|
|
3
|
+
*
|
|
4
|
+
* For an ambient-cloud binding the gateway process is started on the first call; for a
|
|
5
|
+
* BYO-key (External) binding the client talks to the provider directly. Either way the client
|
|
6
|
+
* only forwards OpenAI-shaped requests and streams responses back — it holds no ambient
|
|
7
|
+
* credentials and rewrites nothing (the gateway rewrites the model id and injects the
|
|
8
|
+
* credential).
|
|
9
|
+
*/
|
|
10
|
+
import type { ChatCompletion, ChatCompletionChunk } from "openai/resources/chat/completions";
|
|
11
|
+
import type { Response as OpenAIResponse, ResponseStreamEvent } from "openai/resources/responses/responses";
|
|
12
|
+
import type { Gateway } from "./gateway.js";
|
|
13
|
+
export interface ChatCompletionCreateParams {
|
|
14
|
+
model: string;
|
|
15
|
+
messages: Array<{
|
|
16
|
+
role: string;
|
|
17
|
+
content: string | object;
|
|
18
|
+
}>;
|
|
19
|
+
stream?: boolean;
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
}
|
|
22
|
+
export interface ResponseCreateParams {
|
|
23
|
+
model: string;
|
|
24
|
+
input: string | Array<{
|
|
25
|
+
role: string;
|
|
26
|
+
content: string;
|
|
27
|
+
}>;
|
|
28
|
+
stream?: boolean;
|
|
29
|
+
[key: string]: unknown;
|
|
30
|
+
}
|
|
31
|
+
/** One model the gateway exposes for this binding's cloud. */
|
|
32
|
+
export interface AiModel {
|
|
33
|
+
/** The id passed to `chat.completions.create` / `responses.create`. */
|
|
34
|
+
id: string;
|
|
35
|
+
/** The model's publisher, e.g. "openai", "anthropic", "google". */
|
|
36
|
+
provider: string;
|
|
37
|
+
/** A human label for a model picker, e.g. "Claude Opus 4.8". */
|
|
38
|
+
displayName: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* OpenAI-compatible chat-completions surface, typed so a non-streaming call
|
|
42
|
+
* resolves to a full {@link ChatCompletion} and a streaming call to an
|
|
43
|
+
* async-iterable of {@link ChatCompletionChunk}; the caller reads
|
|
44
|
+
* `.choices[0].message.content` (or iterates chunks) with no cast.
|
|
45
|
+
*/
|
|
46
|
+
export interface ChatCompletionsApi {
|
|
47
|
+
create(params: ChatCompletionCreateParams & {
|
|
48
|
+
stream?: false;
|
|
49
|
+
}): Promise<ChatCompletion>;
|
|
50
|
+
create(params: ChatCompletionCreateParams & {
|
|
51
|
+
stream: true;
|
|
52
|
+
}): Promise<AsyncIterable<ChatCompletionChunk>>;
|
|
53
|
+
}
|
|
54
|
+
/** OpenAI-compatible Responses surface (the API Codex speaks), typed like above. */
|
|
55
|
+
export interface ResponsesApi {
|
|
56
|
+
create(params: ResponseCreateParams & {
|
|
57
|
+
stream?: false;
|
|
58
|
+
}): Promise<OpenAIResponse>;
|
|
59
|
+
create(params: ResponseCreateParams & {
|
|
60
|
+
stream: true;
|
|
61
|
+
}): Promise<AsyncIterable<ResponseStreamEvent>>;
|
|
62
|
+
}
|
|
63
|
+
/** Resolution shared by `ai()` and `getAiConnection()`. `baseUrl` is the root (no `/v1`);
|
|
64
|
+
* `apiKey`/`staticModels` are set only for a BYO-key (External) provider. */
|
|
65
|
+
export interface ResolvedAiBinding {
|
|
66
|
+
baseUrl: string;
|
|
67
|
+
apiKey?: string;
|
|
68
|
+
staticModels?: AiModel[];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Resolve `ALIEN_<NAME>_BINDING` to a connection target. External -> the provider directly with
|
|
72
|
+
* the projected key. Any other service tag (the ambient variants, including ones this SDK
|
|
73
|
+
* predates) -> the in-process Rust gateway, started here on demand, which validates the binding
|
|
74
|
+
* and injects the ambient cloud credential. Backs both `ai()` and `getAiConnection()`.
|
|
75
|
+
*
|
|
76
|
+
* The returned `baseUrl` is the root without `/v1` — the gateway serves
|
|
77
|
+
* `/<segment>/v1/...`, and the client appends the versioned paths itself.
|
|
78
|
+
*/
|
|
79
|
+
export declare function resolveAiBinding(gateway: Gateway, name: string): Promise<ResolvedAiBinding>;
|
|
80
|
+
/**
|
|
81
|
+
* Constructed by the `ai(name)` factory; resolves the binding (and starts the
|
|
82
|
+
* gateway, for ambient) once on first use.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* import { ai } from "@alienplatform/sdk"
|
|
87
|
+
*
|
|
88
|
+
* const llm = ai("my-llm")
|
|
89
|
+
* const response = await llm.chat.completions.create({
|
|
90
|
+
* model: "claude-opus-4.8",
|
|
91
|
+
* messages: [{ role: "user", content: "Hello!" }],
|
|
92
|
+
* })
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export declare class Ai {
|
|
96
|
+
private readonly resolve;
|
|
97
|
+
private connectionPromise;
|
|
98
|
+
/** OpenAI-compatible chat namespace. */
|
|
99
|
+
readonly chat: {
|
|
100
|
+
completions: ChatCompletionsApi;
|
|
101
|
+
};
|
|
102
|
+
/** OpenAI-compatible Responses API namespace (the surface Codex speaks). */
|
|
103
|
+
readonly responses: ResponsesApi;
|
|
104
|
+
constructor(resolve: () => Promise<ResolvedAiBinding>);
|
|
105
|
+
private connection;
|
|
106
|
+
/** List the models the gateway exposes for this binding's cloud. */
|
|
107
|
+
getAvailableModels(): Promise<AiModel[]>;
|
|
108
|
+
private _chatCompletionsCreate;
|
|
109
|
+
private _responsesCreate;
|
|
110
|
+
private _postSurface;
|
|
111
|
+
private _fetch;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* A resolved AI connection for a plain OpenAI-compatible client: the base URL, plus an
|
|
115
|
+
* optional bearer key. `apiKey` is set for a BYO-key (External) provider and omitted for
|
|
116
|
+
* ambient-cloud bindings, where the embedded gateway injects the credential.
|
|
117
|
+
*/
|
|
118
|
+
export interface AiConnection {
|
|
119
|
+
baseURL: string;
|
|
120
|
+
apiKey?: string;
|
|
121
|
+
}
|
|
122
|
+
/** The app-facing AI client surface, shared by the lazy-loading and static-embed entries. */
|
|
123
|
+
export interface AiClient {
|
|
124
|
+
ai(name: string): Ai;
|
|
125
|
+
getAiConnection(name: string): Promise<AiConnection>;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Build the `ai()` / `getAiConnection()` pair over a gateway. Mirrors `createGateway`:
|
|
129
|
+
* each entry wires its own addon acquisition and shares this implementation.
|
|
130
|
+
*/
|
|
131
|
+
export declare function createAiClient(gateway: Gateway): AiClient;
|
|
132
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"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"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed errors for the AI client surface (`ai()` / `getAiConnection`).
|
|
3
|
+
*
|
|
4
|
+
* Defined here rather than in `@alienplatform/bindings` because the AI binding
|
|
5
|
+
* resolves through this package's gateway process, not the bindings native addon.
|
|
6
|
+
*/
|
|
7
|
+
import * as z from "zod/v4";
|
|
8
|
+
export { BindingNotFoundError, InvalidBindingConfigError } from "@alienplatform/core";
|
|
9
|
+
/**
|
|
10
|
+
* Error thrown when an upstream LLM endpoint returns a non-2xx response.
|
|
11
|
+
*
|
|
12
|
+
* Marked internal because the response body and upstream URL may contain
|
|
13
|
+
* provider-specific infra detail not intended for external clients.
|
|
14
|
+
* Retryability is derived per-call from the HTTP status code.
|
|
15
|
+
*/
|
|
16
|
+
export declare const AiUpstreamError: {
|
|
17
|
+
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
18
|
+
url: z.ZodString;
|
|
19
|
+
status: z.ZodNumber;
|
|
20
|
+
message: z.ZodString;
|
|
21
|
+
}, z.core.$strip>>;
|
|
22
|
+
contextSchema: z.ZodObject<{
|
|
23
|
+
url: z.ZodString;
|
|
24
|
+
status: z.ZodNumber;
|
|
25
|
+
message: z.ZodString;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
create: (context: {
|
|
28
|
+
url: string;
|
|
29
|
+
status: number;
|
|
30
|
+
message: string;
|
|
31
|
+
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
32
|
+
url: z.ZodString;
|
|
33
|
+
status: z.ZodNumber;
|
|
34
|
+
message: z.ZodString;
|
|
35
|
+
}, z.core.$strip>>;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Error thrown when a network-level failure occurs before or after an
|
|
39
|
+
* upstream LLM request (fetch threw, or the success body was not parseable JSON).
|
|
40
|
+
* These are always transient and safe to retry.
|
|
41
|
+
*/
|
|
42
|
+
export declare const AiTransportError: {
|
|
43
|
+
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
44
|
+
url: z.ZodString;
|
|
45
|
+
reason: z.ZodString;
|
|
46
|
+
}, z.core.$strip>>;
|
|
47
|
+
contextSchema: z.ZodObject<{
|
|
48
|
+
url: z.ZodString;
|
|
49
|
+
reason: z.ZodString;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
create: (context: {
|
|
52
|
+
url: string;
|
|
53
|
+
reason: string;
|
|
54
|
+
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
55
|
+
url: z.ZodString;
|
|
56
|
+
reason: z.ZodString;
|
|
57
|
+
}, z.core.$strip>>;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Error thrown when a BYO-key binding names a provider the client has no base URL for.
|
|
61
|
+
* External (the developer set a bad `provider` tag) and not retryable — failing closed
|
|
62
|
+
* here stops the projected BYO key from being shipped to the wrong provider's endpoint.
|
|
63
|
+
*/
|
|
64
|
+
export declare const UnsupportedProviderError: {
|
|
65
|
+
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
66
|
+
provider: z.ZodString;
|
|
67
|
+
supported: z.ZodArray<z.ZodString>;
|
|
68
|
+
}, z.core.$strip>>;
|
|
69
|
+
contextSchema: z.ZodObject<{
|
|
70
|
+
provider: z.ZodString;
|
|
71
|
+
supported: z.ZodArray<z.ZodString>;
|
|
72
|
+
}, z.core.$strip>;
|
|
73
|
+
create: (context: {
|
|
74
|
+
provider: string;
|
|
75
|
+
supported: string[];
|
|
76
|
+
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
77
|
+
provider: z.ZodString;
|
|
78
|
+
supported: z.ZodArray<z.ZodString>;
|
|
79
|
+
}, z.core.$strip>>;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Error thrown when a binding's upstream serves chat/completions but not the OpenAI Responses
|
|
83
|
+
* API. Anthropic's OpenAI-compatible host is the case in point: `/v1/chat/completions` works,
|
|
84
|
+
* `/v1/responses` 404s. External (a caller usage error), not retryable.
|
|
85
|
+
*/
|
|
86
|
+
export declare const ResponsesApiUnsupportedError: {
|
|
87
|
+
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
88
|
+
provider: z.ZodString;
|
|
89
|
+
}, z.core.$strip>>;
|
|
90
|
+
contextSchema: z.ZodObject<{
|
|
91
|
+
provider: z.ZodString;
|
|
92
|
+
}, z.core.$strip>;
|
|
93
|
+
create: (context: {
|
|
94
|
+
provider: string;
|
|
95
|
+
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
96
|
+
provider: z.ZodString;
|
|
97
|
+
}, z.core.$strip>>;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Error thrown when this platform/architecture has no prebuilt gateway binary.
|
|
101
|
+
*/
|
|
102
|
+
export declare const UnsupportedPlatformError: {
|
|
103
|
+
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
104
|
+
platform: z.ZodString;
|
|
105
|
+
arch: z.ZodString;
|
|
106
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
107
|
+
}, z.core.$strip>>;
|
|
108
|
+
contextSchema: z.ZodObject<{
|
|
109
|
+
platform: z.ZodString;
|
|
110
|
+
arch: z.ZodString;
|
|
111
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
112
|
+
}, z.core.$strip>;
|
|
113
|
+
create: (context: {
|
|
114
|
+
platform: string;
|
|
115
|
+
arch: string;
|
|
116
|
+
reason?: string | undefined;
|
|
117
|
+
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
118
|
+
platform: z.ZodString;
|
|
119
|
+
arch: z.ZodString;
|
|
120
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
121
|
+
}, z.core.$strip>>;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Error thrown when the `alien-ai-gateway` executable cannot be located (or, for a
|
|
125
|
+
* compiled Worker, extracted) for this platform. Internal because the context
|
|
126
|
+
* carries filesystem paths.
|
|
127
|
+
*/
|
|
128
|
+
export declare const GatewayBinaryUnavailableError: {
|
|
129
|
+
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
130
|
+
triple: z.ZodString;
|
|
131
|
+
reason: z.ZodString;
|
|
132
|
+
path: z.ZodOptional<z.ZodString>;
|
|
133
|
+
}, z.core.$strip>>;
|
|
134
|
+
contextSchema: z.ZodObject<{
|
|
135
|
+
triple: z.ZodString;
|
|
136
|
+
reason: z.ZodString;
|
|
137
|
+
path: z.ZodOptional<z.ZodString>;
|
|
138
|
+
}, z.core.$strip>;
|
|
139
|
+
create: (context: {
|
|
140
|
+
triple: string;
|
|
141
|
+
reason: string;
|
|
142
|
+
path?: string | undefined;
|
|
143
|
+
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
144
|
+
triple: z.ZodString;
|
|
145
|
+
reason: z.ZodString;
|
|
146
|
+
path: z.ZodOptional<z.ZodString>;
|
|
147
|
+
}, z.core.$strip>>;
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Error thrown when the spawned `alien-ai-gateway` process failed to report a
|
|
151
|
+
* ready URL: it exited early or errored on startup. Retryable because the common
|
|
152
|
+
* cause (an ambient cloud credential not yet resolvable) is transient.
|
|
153
|
+
*/
|
|
154
|
+
export declare const GatewayStartFailedError: {
|
|
155
|
+
metadata: import("@alienplatform/core").AlienErrorMetadata<z.ZodObject<{
|
|
156
|
+
reason: z.ZodString;
|
|
157
|
+
}, z.core.$strip>>;
|
|
158
|
+
contextSchema: z.ZodObject<{
|
|
159
|
+
reason: z.ZodString;
|
|
160
|
+
}, z.core.$strip>;
|
|
161
|
+
create: (context: {
|
|
162
|
+
reason: string;
|
|
163
|
+
}) => import("@alienplatform/core").AlienErrorDefinition<z.ZodObject<{
|
|
164
|
+
reason: z.ZodString;
|
|
165
|
+
}, z.core.$strip>>;
|
|
166
|
+
};
|
|
167
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAA;AAG3B,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAErF;;;;;;GAMG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;CAY1B,CAAA;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;CAU3B,CAAA;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;CAWnC,CAAA;AAEF;;;;GAIG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;CAUvC,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;CAYnC,CAAA;AAEF;;;;GAIG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;CAaxC,CAAA;AAEF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;CASlC,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The gateway surface: obtain the loopback URL of the Alien AI gateway.
|
|
3
|
+
*
|
|
4
|
+
* Two paths, unified behind {@link Gateway.startAiGateway}:
|
|
5
|
+
* - A container launcher already started the gateway out of band and exec'd the
|
|
6
|
+
* app with `ALIEN_AI_GATEWAY_URL` set, so we use that URL directly.
|
|
7
|
+
* - Otherwise (an SDK Worker) we spawn the `alien-ai-gateway` binary ourselves,
|
|
8
|
+
* read the URL it prints, and keep the child alive for the process lifetime.
|
|
9
|
+
*
|
|
10
|
+
* Parameterized over how the binary is resolved so the lazy entry (`index.ts`) and
|
|
11
|
+
* the compiled-embed entry (`native.ts`) share one implementation.
|
|
12
|
+
*/
|
|
13
|
+
import { type RawAiGatewayHandle } from "./loader.js";
|
|
14
|
+
export interface Gateway {
|
|
15
|
+
startAiGateway(): Promise<RawAiGatewayHandle>;
|
|
16
|
+
}
|
|
17
|
+
export declare function createGateway(resolveBinary: () => Promise<string>): Gateway;
|
|
18
|
+
//# sourceMappingURL=gateway.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,OAAO,EAAE,KAAK,kBAAkB,EAAkB,MAAM,aAAa,CAAA;AAOrE,MAAM,WAAW,OAAO;IACtB,cAAc,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAAA;CAC9C;AAED,wBAAgB,aAAa,CAAC,aAAa,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAqB3E"}
|