aweshare 0.6.5 → 0.6.7
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 +10 -4
- package/apps/agent/dist/cli.js +80 -12
- package/apps/agent/dist/cli.js.map +1 -1
- package/apps/agent/dist/config.d.ts +1 -1
- package/apps/agent/dist/config.js +9 -4
- package/apps/agent/dist/config.js.map +1 -1
- package/apps/agent/dist/connection.js +4 -1
- package/apps/agent/dist/connection.js.map +1 -1
- package/apps/agent/dist/doctor.js +64 -6
- package/apps/agent/dist/doctor.js.map +1 -1
- package/apps/agent/dist/service.d.ts +16 -0
- package/apps/agent/dist/service.js +202 -0
- package/apps/agent/dist/service.js.map +1 -0
- package/apps/hub/dist/landing.d.ts +1 -3
- package/apps/hub/dist/landing.js +2 -3
- package/apps/hub/dist/landing.js.map +1 -1
- package/apps/hub/dist/server.js +1 -1
- package/apps/hub/dist/server.js.map +1 -1
- package/package.json +1 -1
- package/packages/producer-core/dist/catalog.d.ts +7 -0
- package/packages/producer-core/dist/catalog.js +16 -1
- package/packages/producer-core/dist/catalog.js.map +1 -1
- package/packages/producer-core/dist/job.js +2 -2
- package/packages/producer-core/dist/job.js.map +1 -1
- package/packages/producer-core/dist/proxy.d.ts +26 -9
- package/packages/producer-core/dist/proxy.js +74 -23
- package/packages/producer-core/dist/proxy.js.map +1 -1
|
@@ -1,21 +1,38 @@
|
|
|
1
1
|
import type { ResolvedBackend } from './adapters.js';
|
|
2
|
-
export interface
|
|
2
|
+
export interface BackendProxyOptions {
|
|
3
3
|
httpProxy?: string;
|
|
4
4
|
httpsProxy?: string;
|
|
5
5
|
noProxy?: string;
|
|
6
|
-
source: 'HTTP_PROXY' | 'HTTPS_PROXY' | 'ALL_PROXY';
|
|
6
|
+
source: 'config' | 'HTTP_PROXY' | 'HTTPS_PROXY' | 'ALL_PROXY';
|
|
7
7
|
}
|
|
8
|
-
/**
|
|
8
|
+
/** Egress proxy for one backend's upstream requests. Two sources, one rule:
|
|
9
|
+
* an explicit `proxyUrl` in the backend block wins over environment variables.
|
|
10
|
+
*
|
|
11
|
+
* - `proxyUrl` (config.toml, validated by parseCatalog) applies to any backend
|
|
12
|
+
* and fills both the http and the https slot — the user said "this backend's
|
|
13
|
+
* traffic goes through this proxy", and one backend has one egress. NO_PROXY
|
|
14
|
+
* from the environment still applies.
|
|
15
|
+
* - Without `proxyUrl`, environment variables apply to codex-login backends
|
|
16
|
+
* only: a machine-wide HTTPS_PROXY is ambient state (often set for git/npm)
|
|
17
|
+
* and must never capture key-backed backends such as a local Ollama.
|
|
9
18
|
*
|
|
10
19
|
* EnvHttpProxyAgent implements HTTP_PROXY/HTTPS_PROXY/NO_PROXY matching. We
|
|
11
20
|
* also accept ALL_PROXY because coding-agent proxy setups commonly provide it.
|
|
12
21
|
* SOCKS URLs are deliberately ignored: the producer has no SOCKS dependency,
|
|
13
22
|
* and silently treating one as HTTP would send account traffic incorrectly.
|
|
14
23
|
*/
|
|
15
|
-
export declare function
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
|
|
24
|
+
export declare function backendProxyOptions(backend: Pick<ResolvedBackend, 'login' | 'proxyUrl'>, env?: NodeJS.ProcessEnv): BackendProxyOptions | null;
|
|
25
|
+
/** Close and forget routes whose proxy settings no longer belong to any
|
|
26
|
+
* backend. Call after a config (re)load so a replaced proxyUrl releases its
|
|
27
|
+
* pooled connections instead of leaking them for the life of the process.
|
|
28
|
+
* close() reclaims idle sockets only; requests already dispatched through a
|
|
29
|
+
* closed route still complete. */
|
|
30
|
+
export declare function pruneProxyRoutes(backends: ReadonlyArray<Pick<ResolvedBackend, 'login' | 'proxyUrl'>>, env?: NodeJS.ProcessEnv): void;
|
|
31
|
+
/** Fetch an upstream request through the backend's egress proxy when one is
|
|
32
|
+
* configured (config proxyUrl, or proxy environment variables on a codex-login
|
|
33
|
+
* upstream); plain fetch otherwise. */
|
|
34
|
+
export declare function fetchUpstream(backend: Pick<ResolvedBackend, 'login' | 'proxyUrl'>, url: string, init: RequestInit): Promise<Response>;
|
|
19
35
|
/** A safe, actionable suffix for network errors. Never include proxy URLs:
|
|
20
|
-
* they can contain credentials.
|
|
21
|
-
|
|
36
|
+
* they can contain credentials. Read-only — building a hint must not create
|
|
37
|
+
* or close pooled routes as a side effect. */
|
|
38
|
+
export declare function egressNetworkHint(backend: Pick<ResolvedBackend, 'login' | 'proxyUrl'>, env?: NodeJS.ProcessEnv): string;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { EnvHttpProxyAgent } from 'undici';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
// One cached route per distinct proxy settings. A single-slot cache cannot
|
|
3
|
+
// tell "the config changed the proxy" from "a different backend asked": with
|
|
4
|
+
// mixed egress (one proxied backend, one direct) every request would evict —
|
|
5
|
+
// and close — a pooled dispatcher another request may still be about to
|
|
6
|
+
// dispatch through (undici rejects dispatches on a closed dispatcher with
|
|
7
|
+
// UND_ERR_DESTROYED). Direct backends need no route and are never stored.
|
|
8
|
+
const routes = new Map();
|
|
9
|
+
function signatureOf(options) {
|
|
10
|
+
return JSON.stringify(options);
|
|
11
|
+
}
|
|
4
12
|
function envValue(env, lower, upper) {
|
|
5
13
|
// Match the conventional lower-case precedence used by proxy-aware clients.
|
|
6
14
|
return env[lower] ?? env[upper];
|
|
@@ -16,14 +24,32 @@ function httpProxy(value) {
|
|
|
16
24
|
return undefined;
|
|
17
25
|
}
|
|
18
26
|
}
|
|
19
|
-
/**
|
|
27
|
+
/** Egress proxy for one backend's upstream requests. Two sources, one rule:
|
|
28
|
+
* an explicit `proxyUrl` in the backend block wins over environment variables.
|
|
29
|
+
*
|
|
30
|
+
* - `proxyUrl` (config.toml, validated by parseCatalog) applies to any backend
|
|
31
|
+
* and fills both the http and the https slot — the user said "this backend's
|
|
32
|
+
* traffic goes through this proxy", and one backend has one egress. NO_PROXY
|
|
33
|
+
* from the environment still applies.
|
|
34
|
+
* - Without `proxyUrl`, environment variables apply to codex-login backends
|
|
35
|
+
* only: a machine-wide HTTPS_PROXY is ambient state (often set for git/npm)
|
|
36
|
+
* and must never capture key-backed backends such as a local Ollama.
|
|
20
37
|
*
|
|
21
38
|
* EnvHttpProxyAgent implements HTTP_PROXY/HTTPS_PROXY/NO_PROXY matching. We
|
|
22
39
|
* also accept ALL_PROXY because coding-agent proxy setups commonly provide it.
|
|
23
40
|
* SOCKS URLs are deliberately ignored: the producer has no SOCKS dependency,
|
|
24
41
|
* and silently treating one as HTTP would send account traffic incorrectly.
|
|
25
42
|
*/
|
|
26
|
-
export function
|
|
43
|
+
export function backendProxyOptions(backend, env = process.env) {
|
|
44
|
+
const configured = httpProxy(backend.proxyUrl);
|
|
45
|
+
if (configured) {
|
|
46
|
+
return {
|
|
47
|
+
httpProxy: configured,
|
|
48
|
+
httpsProxy: configured,
|
|
49
|
+
noProxy: envValue(env, 'no_proxy', 'NO_PROXY'),
|
|
50
|
+
source: 'config',
|
|
51
|
+
};
|
|
52
|
+
}
|
|
27
53
|
if (backend.login !== 'codex')
|
|
28
54
|
return null;
|
|
29
55
|
const all = httpProxy(envValue(env, 'all_proxy', 'ALL_PROXY'));
|
|
@@ -41,21 +67,42 @@ export function codexProxyOptions(backend, env = process.env) {
|
|
|
41
67
|
source,
|
|
42
68
|
};
|
|
43
69
|
}
|
|
44
|
-
function
|
|
45
|
-
const options =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
70
|
+
function backendProxyRoute(backend, env = process.env) {
|
|
71
|
+
const options = backendProxyOptions(backend, env);
|
|
72
|
+
if (!options)
|
|
73
|
+
return null;
|
|
74
|
+
const signature = signatureOf(options);
|
|
75
|
+
let route = routes.get(signature);
|
|
76
|
+
if (route === undefined) {
|
|
77
|
+
route = { dispatcher: new EnvHttpProxyAgent(options), source: options.source };
|
|
78
|
+
routes.set(signature, route);
|
|
79
|
+
}
|
|
80
|
+
return route;
|
|
54
81
|
}
|
|
55
|
-
/**
|
|
56
|
-
*
|
|
82
|
+
/** Close and forget routes whose proxy settings no longer belong to any
|
|
83
|
+
* backend. Call after a config (re)load so a replaced proxyUrl releases its
|
|
84
|
+
* pooled connections instead of leaking them for the life of the process.
|
|
85
|
+
* close() reclaims idle sockets only; requests already dispatched through a
|
|
86
|
+
* closed route still complete. */
|
|
87
|
+
export function pruneProxyRoutes(backends, env = process.env) {
|
|
88
|
+
const live = new Set();
|
|
89
|
+
for (const backend of backends) {
|
|
90
|
+
const options = backendProxyOptions(backend, env);
|
|
91
|
+
if (options)
|
|
92
|
+
live.add(signatureOf(options));
|
|
93
|
+
}
|
|
94
|
+
for (const [signature, route] of routes) {
|
|
95
|
+
if (live.has(signature))
|
|
96
|
+
continue;
|
|
97
|
+
routes.delete(signature);
|
|
98
|
+
void Promise.resolve(route.dispatcher.close()).catch(() => undefined);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/** Fetch an upstream request through the backend's egress proxy when one is
|
|
102
|
+
* configured (config proxyUrl, or proxy environment variables on a codex-login
|
|
103
|
+
* upstream); plain fetch otherwise. */
|
|
57
104
|
export async function fetchUpstream(backend, url, init) {
|
|
58
|
-
const route =
|
|
105
|
+
const route = backendProxyRoute(backend);
|
|
59
106
|
if (!route)
|
|
60
107
|
return fetch(url, init);
|
|
61
108
|
// Node's built-in fetch honors undici dispatchers at runtime, but its DOM
|
|
@@ -65,13 +112,17 @@ export async function fetchUpstream(backend, url, init) {
|
|
|
65
112
|
return fetch(url, options);
|
|
66
113
|
}
|
|
67
114
|
/** A safe, actionable suffix for network errors. Never include proxy URLs:
|
|
68
|
-
* they can contain credentials.
|
|
69
|
-
|
|
115
|
+
* they can contain credentials. Read-only — building a hint must not create
|
|
116
|
+
* or close pooled routes as a side effect. */
|
|
117
|
+
export function egressNetworkHint(backend, env = process.env) {
|
|
118
|
+
const options = backendProxyOptions(backend, env);
|
|
119
|
+
if (options) {
|
|
120
|
+
return options.source === 'config'
|
|
121
|
+
? ' (backend egress used the proxyUrl from config.toml; check that the proxy is reachable)'
|
|
122
|
+
: ` (Codex account request used ${options.source}; check that its HTTP(S) proxy is reachable)`;
|
|
123
|
+
}
|
|
70
124
|
if (backend.login !== 'codex')
|
|
71
125
|
return '';
|
|
72
|
-
|
|
73
|
-
return route
|
|
74
|
-
? ` (Codex account request used ${route.source}; check that its HTTP(S) proxy is reachable)`
|
|
75
|
-
: ' (Codex account request went direct; set HTTPS_PROXY, HTTP_PROXY, or ALL_PROXY if ChatGPT requires a proxy)';
|
|
126
|
+
return ' (Codex account request went direct; set proxyUrl on the backend in config.toml, or HTTPS_PROXY, HTTP_PROXY, or ALL_PROXY before starting the producer, if the upstream needs a proxy)';
|
|
76
127
|
}
|
|
77
128
|
//# sourceMappingURL=proxy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AAe3D,IAAI,
|
|
1
|
+
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AAe3D,2EAA2E;AAC3E,6EAA6E;AAC7E,6EAA6E;AAC7E,wEAAwE;AACxE,0EAA0E;AAC1E,0EAA0E;AAC1E,MAAM,MAAM,GAAG,IAAI,GAAG,EAA6B,CAAA;AAEnD,SAAS,WAAW,CAAC,OAA4B;IAC/C,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;AAChC,CAAC;AAED,SAAS,QAAQ,CAAC,GAAsB,EAAE,KAAa,EAAE,KAAa;IACpE,4EAA4E;IAC5E,OAAO,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAA;AACjC,CAAC;AAED,SAAS,SAAS,CAAC,KAAyB;IAC1C,I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