@howaboua/pi-codex-web-run 0.0.4 → 0.0.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @howaboua/pi-codex-web-run
2
2
 
3
+ ## 0.0.6
4
+
5
+ - Requires Pi 1.0.0 or later.
6
+
7
+ Updated Undici to 8.10.2 with security fixes.
8
+
9
+ ## 0.0.5
10
+
11
+ - Web requests now re-evaluate proxy and `no_proxy` routing after redirects.
12
+
3
13
  ## 0.0.4
4
14
 
5
15
  - GPT-6 Sol and Luna now share Astra's Codex support.
package/README.md CHANGED
@@ -6,7 +6,7 @@ Codex web search, page opening, link traversal, and in-page finding for ordinary
6
6
 
7
7
  pi install npm:@howaboua/pi-codex-web-run
8
8
 
9
- Requires Pi 0.84.4 or newer and Node.js 22.19 or newer.
9
+ Requires Pi 1.0.0 or newer and Node.js 22.19 or newer.
10
10
 
11
11
  Run `/login openai-codex` for the normal Codex route, including when chatting with another provider. Compatible active Codex transports keep their own credentials. Pi Codex's resolver is preferred when present, but its conversation-provider scope does not select tool endpoints. Neither Pi Codex nor an install script is required.
12
12
 
package/UPSTREAM_SYNC.md CHANGED
@@ -3,3 +3,9 @@
3
3
  The contract follows OpenAI Codex web search at commit b545c94041017d000e2c8b2f6272705d21b85dfb.
4
4
 
5
5
  Reference snapshots live under upstream/. The executable implementation is TypeScript: it preserves Codex alpha/search requests, explicit search/navigation commands, proxy routing, and reusable result references without bundling the Rust client.
6
+
7
+ ## September 28 review
8
+
9
+ Reviewed through Codex `1b1835f751ebdc0cfc50b3fe55d4571dbb294563`; reference snapshots remain pinned to the revision above.
10
+
11
+ HTTP redirects resolve proxy and `no_proxy` routing for each destination, following the route-aware transport change in `6ea62c4396`. ChatGPT redirect bounds, cookie handling and cross-origin credential stripping remain enforced. The runtime remains identical to the image-generation package's copy.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@howaboua/pi-codex-web-run",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "Codex web search and navigation for Pi, Code Mode and Notebook Mode.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -44,17 +44,17 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "proxy-from-env": "2.1.0",
47
- "undici": "8.10.0"
47
+ "undici": "8.10.2"
48
48
  },
49
49
  "peerDependencies": {
50
- "@earendil-works/pi-coding-agent": ">=0.84.4",
51
- "@earendil-works/pi-tui": ">=0.84.4",
50
+ "@earendil-works/pi-coding-agent": ">=1.0.0",
51
+ "@earendil-works/pi-tui": ">=1.0.0",
52
52
  "typebox": "*"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@biomejs/biome": "^2.5.10",
56
- "@earendil-works/pi-coding-agent": "0.87.0",
57
- "@earendil-works/pi-tui": "0.87.0",
56
+ "@earendil-works/pi-coding-agent": "1.0.0",
57
+ "@earendil-works/pi-tui": "1.0.0",
58
58
  "@types/node": "^26.2.0",
59
59
  "tsx": "^4.23.12",
60
60
  "typebox": "1.3.18",
@@ -27,8 +27,7 @@ export async function fetchCodexTool(
27
27
  maxResponseBytes?: number;
28
28
  },
29
29
  ): Promise<CodexToolHttpResponse> {
30
- const proxy = getProxyForUrl(url);
31
- const dispatcher = proxy ? new ProxyAgent(proxy) : undefined;
30
+ const dispatchers = new Map<string, ProxyAgent>();
32
31
  let currentUrl = new URL(url);
33
32
  let method = options.method;
34
33
  let body = options.body;
@@ -36,6 +35,12 @@ export async function fetchCodexTool(
36
35
  try {
37
36
  for (let redirects = 0; ; redirects += 1) {
38
37
  const chatGptRequest = isChatGptCookieUrl(currentUrl);
38
+ const proxy = getProxyForUrl(currentUrl.href);
39
+ let dispatcher = proxy ? dispatchers.get(proxy) : undefined;
40
+ if (proxy && !dispatcher) {
41
+ dispatcher = new ProxyAgent(proxy);
42
+ dispatchers.set(proxy, dispatcher);
43
+ }
39
44
  const headers = new Headers(baseHeaders);
40
45
  const cookieHeader = cloudflareCookies.requestHeader(currentUrl);
41
46
  if (cookieHeader) headers.set("cookie", cookieHeader);
@@ -45,7 +50,7 @@ export async function fetchCodexTool(
45
50
  ...(body === undefined ? {} : { body }),
46
51
  ...(options.signal ? { signal: options.signal } : {}),
47
52
  ...(dispatcher ? { dispatcher } : {}),
48
- redirect: chatGptRequest ? "manual" : "follow",
53
+ redirect: "manual",
49
54
  });
50
55
  if (chatGptRequest)
51
56
  cloudflareCookies.storeResponse(
@@ -56,7 +61,7 @@ export async function fetchCodexTool(
56
61
  response.status,
57
62
  response.headers.get("location"),
58
63
  );
59
- if (!location || !chatGptRequest) {
64
+ if (!location) {
60
65
  return {
61
66
  status: response.status,
62
67
  statusText: response.statusText,
@@ -74,7 +79,7 @@ export async function fetchCodexTool(
74
79
  );
75
80
  }
76
81
  const nextUrl = new URL(location, currentUrl);
77
- if (!isChatGptCookieUrl(nextUrl)) {
82
+ if (chatGptRequest && !isChatGptCookieUrl(nextUrl)) {
78
83
  await response.body?.cancel();
79
84
  throw new Error(
80
85
  "Codex tool request refused redirect outside ChatGPT: " +
@@ -84,21 +89,30 @@ export async function fetchCodexTool(
84
89
  if (nextUrl.origin !== currentUrl.origin) {
85
90
  baseHeaders.delete("authorization");
86
91
  baseHeaders.delete("chatgpt-account-id");
92
+ baseHeaders.delete("cookie");
93
+ baseHeaders.delete("proxy-authorization");
94
+ baseHeaders.delete("host");
87
95
  }
88
96
  if (
89
- response.status === 303 ||
97
+ (response.status === 303 &&
98
+ method?.toUpperCase() !== "GET" &&
99
+ method?.toUpperCase() !== "HEAD") ||
90
100
  ((response.status === 301 || response.status === 302) &&
91
101
  method?.toUpperCase() === "POST")
92
102
  ) {
93
103
  method = "GET";
94
104
  body = undefined;
105
+ baseHeaders.delete("content-encoding");
106
+ baseHeaders.delete("content-language");
107
+ baseHeaders.delete("content-location");
95
108
  baseHeaders.delete("content-type");
109
+ baseHeaders.delete("content-length");
96
110
  }
97
111
  await response.body?.cancel();
98
112
  currentUrl = nextUrl;
99
113
  }
100
114
  } finally {
101
- await dispatcher?.close();
115
+ await Promise.all([...dispatchers.values()].map((agent) => agent.close()));
102
116
  }
103
117
  }
104
118