@a5c-ai/transport-mux 0.4.10-staging.13b6281a
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/README.md +54 -0
- package/dist/bin/amux-proxy.d.ts +2 -0
- package/dist/bin/amux-proxy.d.ts.map +1 -0
- package/dist/bin/amux-proxy.js +57 -0
- package/dist/bin/amux-proxy.js.map +1 -0
- package/dist/config.d.ts +8 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +86 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime.d.ts +19 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +55 -0
- package/dist/runtime.js.map +1 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +838 -0
- package/dist/server.js.map +1 -0
- package/dist/types.d.ts +65 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +11 -0
- package/dist/types.js.map +1 -0
- package/package.json +86 -0
package/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# transport-mux
|
|
2
|
+
|
|
3
|
+
`transport-mux` is the published transport/proxy runtime seam used by the agent-mux launcher and related runtime consumers.
|
|
4
|
+
|
|
5
|
+
<!-- docs-status:start -->
|
|
6
|
+
> Status: Public family package.
|
|
7
|
+
> Canonical docs home: [Package and Plugin Docs Map](../../docs/package-and-plugin-map.md).
|
|
8
|
+
> This README defines the package contract for the published transport/proxy runtime seam used by agent-mux.
|
|
9
|
+
<!-- docs-status:end -->
|
|
10
|
+
|
|
11
|
+
## Current status
|
|
12
|
+
|
|
13
|
+
This workspace carries the runtime, tests, and package entrypoints used by published agent-mux packages. It is expected to be installable from npm alongside the rest of the public agent-mux family.
|
|
14
|
+
|
|
15
|
+
## Intended seam
|
|
16
|
+
|
|
17
|
+
The control-plane shape is:
|
|
18
|
+
|
|
19
|
+
1. `packages/agent-mux/cli/src/commands/launch.ts` decides whether a proxy is needed.
|
|
20
|
+
2. `packages/agent-mux/core/src/provider-resolver.ts` resolves canonical provider config.
|
|
21
|
+
3. `packages/agent-mux/adapters/src/translate-for-harness.ts` chooses the harness-facing protocol contract.
|
|
22
|
+
4. `packages/transport-mux` is the package seam where that future runtime can converge once cutover work is complete.
|
|
23
|
+
|
|
24
|
+
Historical references still exist under `packages/agent-mux/amux-proxy`, but this package is now the active JS runtime seam for published launcher flows.
|
|
25
|
+
|
|
26
|
+
## What this package means right now
|
|
27
|
+
|
|
28
|
+
- it is a published npm deliverable used by the agent-mux CLI/runtime stack
|
|
29
|
+
- `src/config.ts`, `src/server.ts`, `src/runtime.ts`, and `src/types.ts` provide the transport/proxy runtime seam consumed by launcher flows
|
|
30
|
+
- package entrypoints and the `amux-proxy` bin are part of the public runtime surface
|
|
31
|
+
- the docs capture the protocol/provider split and the current runtime boundary
|
|
32
|
+
|
|
33
|
+
## Placeholder contract notes
|
|
34
|
+
|
|
35
|
+
- `POST /v1/count_tokens` now delegates to provider-aware token counting through the runtime completion engine and returns `{ "count": number }`, matching the legacy `amux-proxy` cutover target instead of a local JSON-length heuristic. Invalid JSON and provider/request failures return explicit error responses, and providers without token-count support return `501`.
|
|
36
|
+
- `GET /metrics` and `GET /cache/stats` are retained for cutover parity with the legacy proxy. `/metrics` exposes in-process request/error/token counters; `/cache/stats` returns `{ "enabled": false }` until this package owns a real cache implementation.
|
|
37
|
+
- `/passthrough/*` is expected to strip only the `/passthrough` prefix, preserve the remaining path and query string, and fail with `501` when no completion engine or resolvable upstream `apiBase` exists.
|
|
38
|
+
|
|
39
|
+
## Operator checks
|
|
40
|
+
|
|
41
|
+
Use these workspace gates when changing the runtime seam or its migration docs:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm run build --workspace=@a5c-ai/transport-mux
|
|
45
|
+
npm run test --workspace=@a5c-ai/transport-mux
|
|
46
|
+
npm run scorecard:migration --workspace=@a5c-ai/transport-mux
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Passing those commands proves the runtime seam still compiles, its runtime tests still pass, and the migration scorecard still sees metadata and docs that match the published runtime policy.
|
|
50
|
+
|
|
51
|
+
## Current document set
|
|
52
|
+
|
|
53
|
+
- [Architecture](./architecture.md): intended protocol/provider boundaries and route contract
|
|
54
|
+
- [Migration](./migration.md): release-owner policy, validation gates, and archived legacy references
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amux-proxy.d.ts","sourceRoot":"","sources":["../../src/bin/amux-proxy.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import process from 'node:process';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { createProxyConfig, readProxyConfigFromEnv, validateProxyConfig } from '../config.js';
|
|
8
|
+
import { startProxyServer } from '../server.js';
|
|
9
|
+
function readPackageVersion() {
|
|
10
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
11
|
+
const packageJsonPath = path.resolve(path.dirname(__filename), '../../package.json');
|
|
12
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
|
13
|
+
return typeof packageJson.version === 'string' ? packageJson.version : '0.0.0';
|
|
14
|
+
}
|
|
15
|
+
async function main() {
|
|
16
|
+
if (process.argv.includes('--version') || process.argv.includes('-v')) {
|
|
17
|
+
process.stdout.write(`${readPackageVersion()}\n`);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const config = createProxyConfig({
|
|
21
|
+
...readProxyConfigFromEnv(),
|
|
22
|
+
authToken: process.env.AMUX_PROXY_AUTH_TOKEN || randomUUID(),
|
|
23
|
+
});
|
|
24
|
+
const errors = validateProxyConfig(config);
|
|
25
|
+
if (errors.length > 0) {
|
|
26
|
+
for (const error of errors) {
|
|
27
|
+
process.stderr.write(`Error: ${error}\n`);
|
|
28
|
+
}
|
|
29
|
+
process.exitCode = 1;
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
process.stderr.write(`[amux-proxy] Transport: ${config.exposedTransport} -> ${config.targetProvider}\n`);
|
|
33
|
+
process.stderr.write(`[amux-proxy] Model: ${config.targetModel}\n`);
|
|
34
|
+
const server = await startProxyServer(config);
|
|
35
|
+
process.stdout.write(`${JSON.stringify({
|
|
36
|
+
event: 'ready',
|
|
37
|
+
port: server.port,
|
|
38
|
+
auth_token: config.authToken,
|
|
39
|
+
url: server.url,
|
|
40
|
+
})}\n`);
|
|
41
|
+
let stopping = false;
|
|
42
|
+
const stop = async (signal) => {
|
|
43
|
+
if (stopping) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
stopping = true;
|
|
47
|
+
if (signal) {
|
|
48
|
+
process.stderr.write(`[amux-proxy] Received ${signal}, shutting down\n`);
|
|
49
|
+
}
|
|
50
|
+
await server.stop();
|
|
51
|
+
process.exit(0);
|
|
52
|
+
};
|
|
53
|
+
process.on('SIGINT', () => void stop('SIGINT'));
|
|
54
|
+
process.on('SIGTERM', () => void stop('SIGTERM'));
|
|
55
|
+
}
|
|
56
|
+
await main();
|
|
57
|
+
//# sourceMappingURL=amux-proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amux-proxy.js","sourceRoot":"","sources":["../../src/bin/amux-proxy.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,iBAAiB,EAAE,sBAA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ProxyConfig } from './types.js';
|
|
2
|
+
export interface ProxyProcessEnvOptions extends Partial<ProxyConfig> {
|
|
3
|
+
logLevel?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function createProxyConfig(overrides?: Partial<ProxyConfig>): ProxyConfig;
|
|
6
|
+
export declare function readProxyConfigFromEnv(env?: NodeJS.ProcessEnv): ProxyConfig;
|
|
7
|
+
export declare function createProxyProcessEnv(overrides: Partial<ProxyConfig>, options?: ProxyProcessEnvOptions): Record<string, string>;
|
|
8
|
+
export declare function validateProxyConfig(config: ProxyConfig): string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAMpE,MAAM,WAAW,sBAAuB,SAAQ,OAAO,CAAC,WAAW,CAAC;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,iBAAiB,CAAC,SAAS,GAAE,OAAO,CAAC,WAAW,CAAM,GAAG,WAAW,CAmBnF;AAED,wBAAgB,sBAAsB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,WAAW,CAWxF;AAED,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,EAAE,OAAO,GAAE,sBAA2B,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkCnI;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,EAAE,CAmBjE"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { SUPPORTED_TRANSPORTS } from './types.js';
|
|
2
|
+
const DEFAULT_HOST = '127.0.0.1';
|
|
3
|
+
const DEFAULT_PORT = 0;
|
|
4
|
+
const DEFAULT_STREAM = true;
|
|
5
|
+
export function createProxyConfig(overrides = {}) {
|
|
6
|
+
const config = {
|
|
7
|
+
targetProvider: '',
|
|
8
|
+
targetModel: '',
|
|
9
|
+
exposedTransport: 'openai-chat',
|
|
10
|
+
authToken: undefined,
|
|
11
|
+
apiBase: undefined,
|
|
12
|
+
host: DEFAULT_HOST,
|
|
13
|
+
port: DEFAULT_PORT,
|
|
14
|
+
stream: DEFAULT_STREAM,
|
|
15
|
+
};
|
|
16
|
+
for (const [key, value] of Object.entries(overrides)) {
|
|
17
|
+
if (value !== undefined) {
|
|
18
|
+
config[key] = value;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return config;
|
|
22
|
+
}
|
|
23
|
+
export function readProxyConfigFromEnv(env = process.env) {
|
|
24
|
+
return createProxyConfig({
|
|
25
|
+
targetProvider: env.AMUX_PROXY_TARGET_PROVIDER,
|
|
26
|
+
targetModel: env.AMUX_PROXY_TARGET_MODEL,
|
|
27
|
+
exposedTransport: env.AMUX_PROXY_EXPOSED_TRANSPORT,
|
|
28
|
+
authToken: env.AMUX_PROXY_AUTH_TOKEN,
|
|
29
|
+
apiBase: env.AMUX_PROXY_API_BASE,
|
|
30
|
+
host: env.AMUX_PROXY_HOST || DEFAULT_HOST,
|
|
31
|
+
port: env.AMUX_PROXY_PORT ? Number(env.AMUX_PROXY_PORT) : DEFAULT_PORT,
|
|
32
|
+
stream: env.AMUX_PROXY_STREAM ? env.AMUX_PROXY_STREAM !== 'false' : DEFAULT_STREAM,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
export function createProxyProcessEnv(overrides, options = {}) {
|
|
36
|
+
const config = createProxyConfig({
|
|
37
|
+
...overrides,
|
|
38
|
+
authToken: options.authToken ?? overrides.authToken,
|
|
39
|
+
apiBase: options.apiBase ?? overrides.apiBase,
|
|
40
|
+
host: options.host ?? overrides.host,
|
|
41
|
+
port: options.port ?? overrides.port,
|
|
42
|
+
stream: options.stream ?? overrides.stream,
|
|
43
|
+
});
|
|
44
|
+
const env = {
|
|
45
|
+
AMUX_PROXY_TARGET_PROVIDER: config.targetProvider,
|
|
46
|
+
AMUX_PROXY_TARGET_MODEL: config.targetModel,
|
|
47
|
+
AMUX_PROXY_EXPOSED_TRANSPORT: config.exposedTransport,
|
|
48
|
+
AMUX_PROXY_PORT: String(config.port),
|
|
49
|
+
};
|
|
50
|
+
if (config.authToken) {
|
|
51
|
+
env.AMUX_PROXY_AUTH_TOKEN = config.authToken;
|
|
52
|
+
}
|
|
53
|
+
if (config.apiBase) {
|
|
54
|
+
env.AMUX_PROXY_API_BASE = config.apiBase;
|
|
55
|
+
}
|
|
56
|
+
if (config.host && config.host !== DEFAULT_HOST) {
|
|
57
|
+
env.AMUX_PROXY_HOST = config.host;
|
|
58
|
+
}
|
|
59
|
+
if (config.stream !== DEFAULT_STREAM) {
|
|
60
|
+
env.AMUX_PROXY_STREAM = String(config.stream);
|
|
61
|
+
}
|
|
62
|
+
if (options.logLevel) {
|
|
63
|
+
env.AMUX_PROXY_LOG_LEVEL = options.logLevel;
|
|
64
|
+
}
|
|
65
|
+
return env;
|
|
66
|
+
}
|
|
67
|
+
export function validateProxyConfig(config) {
|
|
68
|
+
const errors = [];
|
|
69
|
+
if (!config.targetProvider) {
|
|
70
|
+
errors.push('Missing targetProvider');
|
|
71
|
+
}
|
|
72
|
+
if (!config.targetModel) {
|
|
73
|
+
errors.push('Missing targetModel');
|
|
74
|
+
}
|
|
75
|
+
if (!config.exposedTransport) {
|
|
76
|
+
errors.push('Missing exposedTransport');
|
|
77
|
+
}
|
|
78
|
+
else if (!SUPPORTED_TRANSPORTS.includes(config.exposedTransport)) {
|
|
79
|
+
errors.push(`Invalid transport: ${config.exposedTransport}`);
|
|
80
|
+
}
|
|
81
|
+
if (!Number.isFinite(config.port) || config.port < 0) {
|
|
82
|
+
errors.push(`Invalid port: ${config.port}`);
|
|
83
|
+
}
|
|
84
|
+
return errors;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRo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AAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,GAAG,CAAC,oBAAoB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAC9C,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAAmB;IACrD,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;QAC3B,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACxC,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QACxB,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACrC,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;QAC7B,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;IAC1C,CAAC;SAAM,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,MAAM,CAAC,gBAAyD,CAAC,EAAE,CAAC;QAC5G,MAAM,CAAC,IAAI,CAAC,sBAAsB,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC/D,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;QACrD,MAAM,CAAC,IAAI,CAAC,iBAAiB,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './types.js';
|
|
2
|
+
export * from './config.js';
|
|
3
|
+
export * from './server.js';
|
|
4
|
+
export * from './runtime.js';
|
|
5
|
+
export declare const TRANSPORT_MUX_RUNTIME: {
|
|
6
|
+
readonly packageName: "@a5c-ai/transport-mux";
|
|
7
|
+
readonly status: "internal-placeholder";
|
|
8
|
+
readonly publishable: false;
|
|
9
|
+
readonly launcherIntegrated: true;
|
|
10
|
+
readonly cutoverComplete: false;
|
|
11
|
+
readonly ownsReleaseSurface: false;
|
|
12
|
+
readonly executable: "amux-proxy";
|
|
13
|
+
};
|
|
14
|
+
export declare const TRANSPORT_MUX_PACKAGE: "@a5c-ai/transport-mux";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAE7B,eAAO,MAAM,qBAAqB;;;;;;;;CAQxB,CAAC;AAEX,eAAO,MAAM,qBAAqB,yBAAoC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './types.js';
|
|
2
|
+
export * from './config.js';
|
|
3
|
+
export * from './server.js';
|
|
4
|
+
export * from './runtime.js';
|
|
5
|
+
export const TRANSPORT_MUX_RUNTIME = {
|
|
6
|
+
packageName: '@a5c-ai/transport-mux',
|
|
7
|
+
status: 'internal-placeholder',
|
|
8
|
+
publishable: false,
|
|
9
|
+
launcherIntegrated: true,
|
|
10
|
+
cutoverComplete: false,
|
|
11
|
+
ownsReleaseSurface: false,
|
|
12
|
+
executable: 'amux-proxy',
|
|
13
|
+
};
|
|
14
|
+
export const TRANSPORT_MUX_PACKAGE = TRANSPORT_MUX_RUNTIME.packageName;
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAE7B,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,WAAW,EAAE,uBAAuB;IACpC,MAAM,EAAE,sBAAsB;IAC9B,WAAW,EAAE,KAAK;IAClB,kBAAkB,EAAE,IAAI;IACxB,eAAe,EAAE,KAAK;IACtB,kBAAkB,EAAE,KAAK;IACzB,UAAU,EAAE,YAAY;CAChB,CAAC;AAEX,MAAM,CAAC,MAAM,qBAAqB,GAAG,qBAAqB,CAAC,WAAW,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CompletionEngine, ProxyConfig, RunningProxyServer, TransportId } from './types.js';
|
|
2
|
+
export interface StartTransportMuxRuntimeOptions {
|
|
3
|
+
targetProvider: string;
|
|
4
|
+
targetModel: string;
|
|
5
|
+
exposedTransport: TransportId;
|
|
6
|
+
authToken?: string;
|
|
7
|
+
apiBase?: string;
|
|
8
|
+
host?: string;
|
|
9
|
+
port?: number;
|
|
10
|
+
stream?: boolean;
|
|
11
|
+
completionEngine?: CompletionEngine;
|
|
12
|
+
}
|
|
13
|
+
export interface TransportMuxRuntime extends RunningProxyServer {
|
|
14
|
+
authToken?: string;
|
|
15
|
+
config: ProxyConfig;
|
|
16
|
+
applyHarnessEnv(env: Record<string, string>): Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
export declare function applyTransportMuxToHarnessEnv(env: Record<string, string>, transport: TransportId, proxyUrl: string, authToken: string): Record<string, string>;
|
|
19
|
+
export declare function startTransportMuxRuntime(options: StartTransportMuxRuntimeOptions): Promise<TransportMuxRuntime>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,WAAW,EACZ,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,+BAA+B;IAC9C,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,WAAW,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAED,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,WAAW,CAAC;IACpB,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtE;AAED,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC3B,SAAS,EAAE,WAAW,EACtB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAwBxB;AAED,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,mBAAmB,CAAC,CAe9B"}
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { createProxyConfig } from './config.js';
|
|
3
|
+
import { startProxyServer } from './server.js';
|
|
4
|
+
export function applyTransportMuxToHarnessEnv(env, transport, proxyUrl, authToken) {
|
|
5
|
+
env['AMUX_PROXY_BASE_URL'] = proxyUrl;
|
|
6
|
+
env['AMUX_PROXY_AUTH_TOKEN'] = authToken;
|
|
7
|
+
switch (transport) {
|
|
8
|
+
case 'anthropic':
|
|
9
|
+
env['ANTHROPIC_BASE_URL'] = proxyUrl;
|
|
10
|
+
env['ANTHROPIC_API_KEY'] = authToken;
|
|
11
|
+
env['ANTHROPIC_AUTH_TOKEN'] = authToken;
|
|
12
|
+
break;
|
|
13
|
+
case 'openai-chat':
|
|
14
|
+
case 'openai-responses':
|
|
15
|
+
case 'azure-foundry':
|
|
16
|
+
env['OPENAI_BASE_URL'] = proxyUrl;
|
|
17
|
+
env['OPENAI_API_KEY'] = authToken;
|
|
18
|
+
break;
|
|
19
|
+
case 'google':
|
|
20
|
+
case 'vertex-native':
|
|
21
|
+
env['CODE_ASSIST_ENDPOINT'] = proxyUrl;
|
|
22
|
+
env['GEMINI_API_KEY'] = authToken;
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
return env;
|
|
26
|
+
}
|
|
27
|
+
export async function startTransportMuxRuntime(options) {
|
|
28
|
+
const authToken = options.authToken ?? randomUUID();
|
|
29
|
+
const config = createProxyConfig({
|
|
30
|
+
targetProvider: options.targetProvider,
|
|
31
|
+
targetModel: options.targetModel,
|
|
32
|
+
exposedTransport: options.exposedTransport,
|
|
33
|
+
authToken,
|
|
34
|
+
apiBase: options.apiBase,
|
|
35
|
+
host: options.host,
|
|
36
|
+
port: options.port,
|
|
37
|
+
stream: options.stream,
|
|
38
|
+
});
|
|
39
|
+
const server = await startProxyServer(config, options.completionEngine);
|
|
40
|
+
return createTransportMuxRuntime(server, config);
|
|
41
|
+
}
|
|
42
|
+
function createTransportMuxRuntime(server, config) {
|
|
43
|
+
return {
|
|
44
|
+
...server,
|
|
45
|
+
authToken: config.authToken,
|
|
46
|
+
config,
|
|
47
|
+
applyHarnessEnv(env) {
|
|
48
|
+
if (!config.authToken) {
|
|
49
|
+
return env;
|
|
50
|
+
}
|
|
51
|
+
return applyTransportMuxToHarnessEnv(env, config.exposedTransport, server.url, config.authToken);
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO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B,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAExE,OAAO,yBAAyB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACnD,CAAC;AAED,SAAS,yBAAyB,CAChC,MAA0B,EAC1B,MAAmB;IAEnB,OAAO;QACL,GAAG,MAAM;QACT,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,MAAM;QACN,eAAe,CAAC,GAAG;YACjB,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;gBACtB,OAAO,GAAG,CAAC;YACb,CAAC;YACD,OAAO,6BAA6B,CAClC,GAAG,EACH,MAAM,CAAC,gBAAgB,EACvB,MAAM,CAAC,GAAG,EACV,MAAM,CAAC,SAAS,CACjB,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
2
|
+
import type { CompletionEngine, CreateTransportMuxAppOptions, ProxyConfig, RunningProxyServer } from './types.js';
|
|
3
|
+
export declare function createTransportMuxApp({ config, completionEngine }: CreateTransportMuxAppOptions): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
|
|
4
|
+
export declare function startProxyServer(config: ProxyConfig, completionEngine?: CompletionEngine): Promise<RunningProxyServer>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,KAAK,EACV,gBAAgB,EAIhB,4BAA4B,EAC5B,WAAW,EACX,kBAAkB,EAEnB,MAAM,YAAY,CAAC;AAo1BpB,wBAAgB,qBAAqB,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,EAAE,4BAA4B,8EAsL/F;AAyCD,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,WAAW,EACnB,gBAAgB,CAAC,EAAE,gBAAgB,GAClC,OAAO,CAAC,kBAAkB,CAAC,CAwC7B"}
|