@howaboua/pi-codex-web-run 0.0.6 → 0.0.8
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 +9 -0
- package/UPSTREAM_SYNC.md +2 -2
- package/biome.json +1 -1
- package/index.ts +46 -3
- package/package.json +17 -10
- package/src/codex-runtime/auth-diagnostics.ts +47 -0
- package/src/codex-runtime/resolve.ts +32 -11
- package/src/codex-runtime/types.ts +2 -2
- package/src/contract.ts +0 -2
- package/src/execute.ts +28 -15
- package/src/tool.ts +2 -2
- package/upstream/codex-api-endpoint/search.rs +0 -318
- package/upstream/codex-api-endpoint/search_types.rs +0 -305
- package/upstream/web-search/extension.rs +0 -220
- package/upstream/web-search/history.rs +0 -205
- package/upstream/web-search/lib.rs +0 -7
- package/upstream/web-search/output.rs +0 -74
- package/upstream/web-search/schema.rs +0 -36
- package/upstream/web-search/tool.rs +0 -332
- package/upstream/web-search/web_run_description.md +0 -105
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @howaboua/pi-codex-web-run
|
|
2
2
|
|
|
3
|
+
## 0.0.8
|
|
4
|
+
|
|
5
|
+
- - Added compact tool guidance for PCC GPT prompt mode. Other modes are unchanged.
|
|
6
|
+
- Removed unused Rust reference sources from the package download. Web search behaviour is unchanged.
|
|
7
|
+
|
|
8
|
+
## 0.0.7
|
|
9
|
+
|
|
10
|
+
- Explain when image generation and web search need a separate legacy OpenAI Codex login rather than ChatGPT sign-in. Access failures now give concise guidance without exposing backend responses or addresses. Existing provider routing is unchanged.
|
|
11
|
+
|
|
3
12
|
## 0.0.6
|
|
4
13
|
|
|
5
14
|
- Requires Pi 1.0.0 or later.
|
package/UPSTREAM_SYNC.md
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
The contract follows OpenAI Codex web search at commit b545c94041017d000e2c8b2f6272705d21b85dfb.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The upstream source is `codex-rs/ext/web-search/`, `codex-rs/codex-api/src/endpoint/search.rs` and `codex-rs/codex-api/src/search.rs` in [OpenAI Codex](https://github.com/openai/codex). Use Git at the revision above for the baseline, then compare relevant changes. `upstream/` retains attribution and the revision only. 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
6
|
|
|
7
7
|
## September 28 review
|
|
8
8
|
|
|
9
|
-
Reviewed through Codex `1b1835f751ebdc0cfc50b3fe55d4571dbb294563`; reference
|
|
9
|
+
Reviewed through Codex `1b1835f751ebdc0cfc50b3fe55d4571dbb294563`; the reference baseline remains the revision above.
|
|
10
10
|
|
|
11
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/biome.json
CHANGED
package/index.ts
CHANGED
|
@@ -19,21 +19,64 @@ export default async function webRunExtension(pi: ExtensionAPI): Promise<void> {
|
|
|
19
19
|
promptSnippet: false,
|
|
20
20
|
});
|
|
21
21
|
pi.registerTool(tool);
|
|
22
|
-
|
|
22
|
+
let gpt = false;
|
|
23
|
+
let registration: Awaited<ReturnType<typeof registerWebRunInCodeMode>>;
|
|
24
|
+
const ordinary = {
|
|
25
|
+
description: tool.description,
|
|
26
|
+
guidelines: tool.promptGuidelines,
|
|
27
|
+
};
|
|
28
|
+
try {
|
|
29
|
+
const { registerGptPromptMode } = await import(
|
|
30
|
+
"@howaboua/pi-codex-conversion/prompt-mode"
|
|
31
|
+
);
|
|
32
|
+
registerGptPromptMode(pi, (active) => {
|
|
33
|
+
if (gpt !== active) {
|
|
34
|
+
gpt = active;
|
|
35
|
+
tool.description = active
|
|
36
|
+
? "Web search/navigation"
|
|
37
|
+
: ordinary.description;
|
|
38
|
+
if (active)
|
|
39
|
+
tool.promptGuidelines = [
|
|
40
|
+
"web_run: Calls: returned turn refs. Final citations: Markdown result URLs, never refs or cite….",
|
|
41
|
+
];
|
|
42
|
+
else if (ordinary.guidelines)
|
|
43
|
+
tool.promptGuidelines = ordinary.guidelines;
|
|
44
|
+
else delete tool.promptGuidelines;
|
|
45
|
+
pi.registerTool(tool);
|
|
46
|
+
registration?.refresh();
|
|
47
|
+
}
|
|
48
|
+
return [tool];
|
|
49
|
+
});
|
|
50
|
+
} catch (error) {
|
|
51
|
+
if (
|
|
52
|
+
!(error instanceof Error) ||
|
|
53
|
+
!("code" in error) ||
|
|
54
|
+
![
|
|
55
|
+
"ERR_MODULE_NOT_FOUND",
|
|
56
|
+
"MODULE_NOT_FOUND",
|
|
57
|
+
"ERR_PACKAGE_PATH_NOT_EXPORTED",
|
|
58
|
+
].includes(String(error.code)) ||
|
|
59
|
+
!error.message.includes(CODE_MODE_PACKAGE)
|
|
60
|
+
)
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
registration = await registerWebRunInCodeMode(pi, tool, () => gpt);
|
|
23
64
|
pi.on("session_shutdown", () => registration?.unregister());
|
|
24
65
|
}
|
|
25
66
|
|
|
26
67
|
async function registerWebRunInCodeMode(
|
|
27
68
|
pi: ExtensionAPI,
|
|
28
69
|
tool: ReturnType<typeof createWebSearchTool>,
|
|
70
|
+
gpt: () => boolean,
|
|
29
71
|
) {
|
|
30
72
|
try {
|
|
31
73
|
const { adaptToolForCodeMode, registerCodeModeExtensionTools } =
|
|
32
74
|
await import(CODE_MODE_MODULE);
|
|
33
75
|
return registerCodeModeExtensionTools(pi, () => [
|
|
34
76
|
adaptToolForCodeMode(tool, {
|
|
35
|
-
usage:
|
|
36
|
-
'await tools.web__run({search_query?:[{q:string,recency?:number,domains?:string[]}],image_query?:[{q:string}],open?:[{ref_id:string,lineno?:number}],click?:[{ref_id:string,id:number}],find?:[{ref_id:string,pattern:string}],response_length?:"short"|"medium"|"long"}) // calls
|
|
77
|
+
usage: gpt()
|
|
78
|
+
? 'await tools.web__run({search_query?:[{q:string,recency?:number,domains?:string[]}],image_query?:[{q:string}],open?:[{ref_id:string,lineno?:number}],click?:[{ref_id:string,id:number}],find?:[{ref_id:string,pattern:string}],response_length?:"short"|"medium"|"long"}) // calls: returned ref_ids; final citations: Markdown result URLs, never refs/cite markers'
|
|
79
|
+
: 'await tools.web__run({search_query?:[{q:string,recency?:number,domains?:string[]}],image_query?:[{q:string}],open?:[{ref_id:string,lineno?:number}],click?:[{ref_id:string,id:number}],find?:[{ref_id:string,pattern:string}],response_length?:"short"|"medium"|"long"}) // calls use returned ref_ids; final answers use Markdown result URLs, never refs/cite markers',
|
|
37
80
|
promptMetadata: false,
|
|
38
81
|
toolName: { namespace: "web", name: "run" },
|
|
39
82
|
resultValue: webRunCodeModeResult,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@howaboua/pi-codex-web-run",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Codex web search and navigation for Pi, Code Mode and Notebook Mode.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,21 +44,23 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"proxy-from-env": "2.1.0",
|
|
47
|
-
"undici": "8.
|
|
47
|
+
"undici": "8.12.2"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"@earendil-works/pi-coding-agent": ">=1.0.0",
|
|
51
51
|
"@earendil-works/pi-tui": ">=1.0.0",
|
|
52
|
-
"typebox": "*"
|
|
52
|
+
"typebox": "*",
|
|
53
|
+
"@howaboua/pi-codex-conversion": ">=4.0.2"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
|
-
"@biomejs/biome": "^2.5.
|
|
56
|
-
"@earendil-works/pi-coding-agent": "1.
|
|
57
|
-
"@earendil-works/pi-tui": "1.
|
|
58
|
-
"@types/node": "^26.
|
|
59
|
-
"tsx": "^4.23.
|
|
60
|
-
"typebox": "1.3.
|
|
61
|
-
"typescript": "^7.0.2"
|
|
56
|
+
"@biomejs/biome": "^2.5.15",
|
|
57
|
+
"@earendil-works/pi-coding-agent": "1.3.0",
|
|
58
|
+
"@earendil-works/pi-tui": "1.3.0",
|
|
59
|
+
"@types/node": "^26.6.5",
|
|
60
|
+
"tsx": "^4.23.15",
|
|
61
|
+
"typebox": "1.3.37",
|
|
62
|
+
"typescript": "^7.0.2",
|
|
63
|
+
"@howaboua/pi-codex-conversion": "4.0.2"
|
|
62
64
|
},
|
|
63
65
|
"pi": {
|
|
64
66
|
"extensions": [
|
|
@@ -72,5 +74,10 @@
|
|
|
72
74
|
"exports": "./index.ts",
|
|
73
75
|
"publishConfig": {
|
|
74
76
|
"access": "public"
|
|
77
|
+
},
|
|
78
|
+
"peerDependenciesMeta": {
|
|
79
|
+
"@howaboua/pi-codex-conversion": {
|
|
80
|
+
"optional": true
|
|
81
|
+
}
|
|
75
82
|
}
|
|
76
83
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { readStoredCredential } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
|
|
3
|
+
/** Inspect stored metadata only after an authentication or route failure. */
|
|
4
|
+
export function codexLoginDiagnostic(rejected = false): string {
|
|
5
|
+
try {
|
|
6
|
+
const legacy = readStoredCredential("openai-codex");
|
|
7
|
+
const current = readStoredCredential("openai");
|
|
8
|
+
if (legacy) {
|
|
9
|
+
if (rejected || (legacy.type === "oauth" && legacy.expires <= Date.now()))
|
|
10
|
+
return "Legacy Codex login expired or was rejected. Explain to the user that they need to renew their separate OpenAI Codex login.";
|
|
11
|
+
return "This tool needs a Codex-compatible route. A separate OpenAI Codex login is stored, but unavailable for this request.";
|
|
12
|
+
}
|
|
13
|
+
if (current?.type === "oauth")
|
|
14
|
+
return "ChatGPT sign-in does not authorize this tool. Explain to the user that they need a separate legacy OpenAI Codex login.";
|
|
15
|
+
return "This tool needs a separate OpenAI Codex login. Ask the user to sign in.";
|
|
16
|
+
} catch {
|
|
17
|
+
return "Login status could not be read. Ask the user to check their OpenAI Codex login.";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Preserve the failure class without exposing backend details. */
|
|
22
|
+
export function codexProviderFailure(error: unknown, legacy = true): Error {
|
|
23
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
24
|
+
if (/timeout|timed out/i.test(message))
|
|
25
|
+
return new Error("Provider request timed out. Try again later.");
|
|
26
|
+
if (/quota|rate.limit|\b429\b/i.test(message))
|
|
27
|
+
return new Error("Provider quota or rate limit reached. Try again later.");
|
|
28
|
+
if (/server|\b5\d\d\b/i.test(message))
|
|
29
|
+
return new Error("Provider service failed. Try again later.");
|
|
30
|
+
if (/network|fetch|connect|socket|dns/i.test(message))
|
|
31
|
+
return new Error("Provider connection failed. Try again later.");
|
|
32
|
+
if (
|
|
33
|
+
/auth|credential|login|token|api.?key|accountId|Codex-compatible/i.test(
|
|
34
|
+
message,
|
|
35
|
+
)
|
|
36
|
+
)
|
|
37
|
+
return new Error(
|
|
38
|
+
legacy
|
|
39
|
+
? codexLoginDiagnostic(
|
|
40
|
+
/expired|rejected|invalid.grant|unauthorized|accountId/i.test(
|
|
41
|
+
message,
|
|
42
|
+
),
|
|
43
|
+
)
|
|
44
|
+
: "Provider authentication unavailable. Ask the user to check their configured provider access.",
|
|
45
|
+
);
|
|
46
|
+
return new Error("Provider request failed.");
|
|
47
|
+
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { Model, ProviderHeaders } from "@earendil-works/pi-ai";
|
|
2
2
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import {
|
|
4
|
+
codexLoginDiagnostic,
|
|
5
|
+
codexProviderFailure,
|
|
6
|
+
} from "./auth-diagnostics.js";
|
|
3
7
|
import {
|
|
4
8
|
type AllowConfiguredCodexToolProvider,
|
|
5
|
-
CODEX_TOOL_PROVIDER_UNSUPPORTED_MESSAGE,
|
|
6
9
|
type CodexToolProvider,
|
|
7
10
|
OPENAI_CODEX_PROVIDER,
|
|
8
11
|
} from "./types.js";
|
|
@@ -56,7 +59,7 @@ function headerValue(
|
|
|
56
59
|
return undefined;
|
|
57
60
|
}
|
|
58
61
|
|
|
59
|
-
function extractAccountId(token: string): string {
|
|
62
|
+
function extractAccountId(token: string, legacy: boolean): string {
|
|
60
63
|
try {
|
|
61
64
|
const payload = token.split(".")[1];
|
|
62
65
|
if (!payload) throw new Error("Invalid token");
|
|
@@ -72,7 +75,11 @@ function extractAccountId(token: string): string {
|
|
|
72
75
|
throw new Error("No account ID in token");
|
|
73
76
|
return accountId;
|
|
74
77
|
} catch {
|
|
75
|
-
throw new Error(
|
|
78
|
+
throw new Error(
|
|
79
|
+
legacy
|
|
80
|
+
? codexLoginDiagnostic(true)
|
|
81
|
+
: "Account identity unavailable. Ask the user to check their provider access.",
|
|
82
|
+
);
|
|
76
83
|
}
|
|
77
84
|
}
|
|
78
85
|
|
|
@@ -112,10 +119,7 @@ export function resolveAuthModel(
|
|
|
112
119
|
return ctx.model as Model<any>;
|
|
113
120
|
const fallback = resolveOpenAICodexAuthModel(ctx);
|
|
114
121
|
if (fallback) return fallback;
|
|
115
|
-
throw new Error(
|
|
116
|
-
CODEX_TOOL_PROVIDER_UNSUPPORTED_MESSAGE +
|
|
117
|
-
"; run /login openai-codex or select an OpenAI Codex-compatible provider",
|
|
118
|
-
);
|
|
122
|
+
throw new Error(codexLoginDiagnostic());
|
|
119
123
|
}
|
|
120
124
|
|
|
121
125
|
function resolveConfiguredResponsesUrl(
|
|
@@ -137,8 +141,17 @@ export async function resolveCodexToolProvider(
|
|
|
137
141
|
allowConfiguredProvider,
|
|
138
142
|
isConfiguredCodexTransport,
|
|
139
143
|
);
|
|
140
|
-
const auth = await ctx.modelRegistry
|
|
141
|
-
|
|
144
|
+
const auth = await ctx.modelRegistry
|
|
145
|
+
.getApiKeyAndHeaders(model)
|
|
146
|
+
.catch((error) => {
|
|
147
|
+
throw codexProviderFailure(error, isOpenAICodexModel(model));
|
|
148
|
+
});
|
|
149
|
+
if (!auth.ok) {
|
|
150
|
+
throw codexProviderFailure(
|
|
151
|
+
new Error(auth.error),
|
|
152
|
+
isOpenAICodexModel(model),
|
|
153
|
+
);
|
|
154
|
+
}
|
|
142
155
|
const resolvedBaseUrl = auth.baseUrl ?? model.baseUrl;
|
|
143
156
|
const codexTransport = isCodexTransportModel(
|
|
144
157
|
model,
|
|
@@ -150,7 +163,12 @@ export async function resolveCodexToolProvider(
|
|
|
150
163
|
const token = codexTransport
|
|
151
164
|
? (auth.apiKey ?? authorization)
|
|
152
165
|
: (authorization ?? auth.apiKey);
|
|
153
|
-
if (!token)
|
|
166
|
+
if (!token)
|
|
167
|
+
throw new Error(
|
|
168
|
+
isOpenAICodexModel(model)
|
|
169
|
+
? codexLoginDiagnostic()
|
|
170
|
+
: "Provider authentication unavailable. Ask the user to check their configured provider access.",
|
|
171
|
+
);
|
|
154
172
|
const baseUrl = codexTransport
|
|
155
173
|
? resolveCodexApiProviderBaseUrl(resolvedBaseUrl)
|
|
156
174
|
: resolvedBaseUrl?.trim().replace(/\/+$/, "");
|
|
@@ -160,6 +178,7 @@ export async function resolveCodexToolProvider(
|
|
|
160
178
|
? resolveCodexResponsesUrl(baseUrl)
|
|
161
179
|
: resolveConfiguredResponsesUrl(baseUrl);
|
|
162
180
|
return {
|
|
181
|
+
authProvider: model.provider,
|
|
163
182
|
route: codexTransport ? "openai-codex" : "configured-responses",
|
|
164
183
|
baseUrl,
|
|
165
184
|
responsesUrl,
|
|
@@ -168,6 +187,8 @@ export async function resolveCodexToolProvider(
|
|
|
168
187
|
token,
|
|
169
188
|
accountId:
|
|
170
189
|
headerValue(auth.headers, "chatgpt-account-id") ??
|
|
171
|
-
(codexTransport
|
|
190
|
+
(codexTransport
|
|
191
|
+
? extractAccountId(token, isOpenAICodexModel(model))
|
|
192
|
+
: ""),
|
|
172
193
|
};
|
|
173
194
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
|
|
3
|
-
export const CODEX_TOOL_PROVIDER_UNSUPPORTED_MESSAGE =
|
|
4
|
-
"Codex-backed tool requires an OpenAI Codex-compatible Responses provider or /login openai-codex";
|
|
5
3
|
export const CODEX_TOOL_ORIGINATOR = "codex_cli_rs";
|
|
6
4
|
export const OPENAI_CODEX_PROVIDER = "openai-codex";
|
|
7
5
|
export const DEFAULT_CODEX_BASE_URL = "https://chatgpt.com/backend-api";
|
|
8
6
|
|
|
9
7
|
export interface CodexToolProvider {
|
|
8
|
+
/** Provider whose credentials were selected, when resolved locally. */
|
|
9
|
+
authProvider?: string;
|
|
10
10
|
route: "openai-codex" | "configured-responses";
|
|
11
11
|
baseUrl: string;
|
|
12
12
|
responsesUrl: string;
|
package/src/contract.ts
CHANGED
|
@@ -3,8 +3,6 @@ import { Type } from "typebox";
|
|
|
3
3
|
import type { CodexToolProvider } from "./codex-runtime/types.js";
|
|
4
4
|
|
|
5
5
|
export const WEB_SEARCH_TOOL_NAME = "web_run";
|
|
6
|
-
export const WEB_SEARCH_UNSUPPORTED_MESSAGE =
|
|
7
|
-
"web_run requires an OpenAI Codex-compatible Responses provider or /login openai-codex";
|
|
8
6
|
export const DEFAULT_WEB_SEARCH_MODEL = "gpt-6-luna";
|
|
9
7
|
export const WEB_SEARCH_MAX_OUTPUT_TOKENS = 2_500;
|
|
10
8
|
export const WEB_SEARCH_MAX_RESPONSE_BYTES = 8 * 1024 * 1024;
|
package/src/execute.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import {
|
|
4
|
+
codexLoginDiagnostic,
|
|
5
|
+
codexProviderFailure,
|
|
6
|
+
} from "./codex-runtime/auth-diagnostics.js";
|
|
3
7
|
import type { CodexToolRouteConfig } from "./codex-runtime/config.js";
|
|
4
8
|
import {
|
|
5
9
|
DEFAULT_WEB_SEARCH_MODEL,
|
|
@@ -58,7 +62,18 @@ async function resolveProvider(
|
|
|
58
62
|
isConfiguredCodexTransport,
|
|
59
63
|
);
|
|
60
64
|
}
|
|
61
|
-
|
|
65
|
+
let hosted;
|
|
66
|
+
try {
|
|
67
|
+
hosted = await options.resolveProvider?.(ctx);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
const legacy =
|
|
70
|
+
ctx.model?.provider === "openai-codex" ||
|
|
71
|
+
!(
|
|
72
|
+
ctx.model?.api === "openai-codex-responses" ||
|
|
73
|
+
options.allowConfiguredProvider?.(ctx.model)
|
|
74
|
+
);
|
|
75
|
+
throw codexProviderFailure(error, legacy);
|
|
76
|
+
}
|
|
62
77
|
if (hosted) return hosted;
|
|
63
78
|
const { resolveCodexToolProvider } = await import(
|
|
64
79
|
"./codex-runtime/resolve.js"
|
|
@@ -115,24 +130,22 @@ export async function executeCodexWebSearch(
|
|
|
115
130
|
response.text.toLowerCase().includes("cloudflare"))
|
|
116
131
|
)
|
|
117
132
|
throw new Error(
|
|
118
|
-
"
|
|
119
|
-
provider.searchUrl +
|
|
120
|
-
": HTTP 403 Cloudflare challenge",
|
|
133
|
+
"Web search was blocked by an access challenge. Try again later.",
|
|
121
134
|
);
|
|
122
135
|
if (response.status === 404 && response.text.includes('"Not Found"'))
|
|
136
|
+
throw new Error("Web search is unavailable on this route.");
|
|
137
|
+
if (
|
|
138
|
+
response.status === 401 ||
|
|
139
|
+
(response.status === 403 &&
|
|
140
|
+
/auth|token|credential|access_enforcement|oauth/i.test(response.text))
|
|
141
|
+
)
|
|
123
142
|
throw new Error(
|
|
124
|
-
|
|
125
|
-
provider.
|
|
126
|
-
|
|
143
|
+
provider.route === "openai-codex" &&
|
|
144
|
+
provider.authProvider === "openai-codex"
|
|
145
|
+
? codexLoginDiagnostic(true)
|
|
146
|
+
: "Web search access was rejected. Ask the user to check access for their configured provider.",
|
|
127
147
|
);
|
|
128
|
-
throw new Error(
|
|
129
|
-
"web_run search failed for " +
|
|
130
|
-
provider.searchUrl +
|
|
131
|
-
": HTTP " +
|
|
132
|
-
response.status +
|
|
133
|
-
" " +
|
|
134
|
-
response.text,
|
|
135
|
-
);
|
|
148
|
+
throw new Error("Web search failed: HTTP " + response.status);
|
|
136
149
|
}
|
|
137
150
|
let parsed: unknown;
|
|
138
151
|
try {
|
package/src/tool.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import type { ToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
3
3
|
import { Container, Text } from "@earendil-works/pi-tui";
|
|
4
|
+
import { codexLoginDiagnostic } from "./codex-runtime/auth-diagnostics.js";
|
|
4
5
|
import {
|
|
5
6
|
WEB_SEARCH_PARAMETERS,
|
|
6
7
|
WEB_SEARCH_TOOL_NAME,
|
|
7
|
-
WEB_SEARCH_UNSUPPORTED_MESSAGE,
|
|
8
8
|
type WebSearchToolOptions,
|
|
9
9
|
} from "./contract.js";
|
|
10
10
|
import {
|
|
@@ -62,7 +62,7 @@ export function createWebSearchTool(
|
|
|
62
62
|
args && typeof args === "object" ? (args as Record<string, unknown>) : {},
|
|
63
63
|
async execute(_toolCallId, params, signal, _onUpdate, ctx) {
|
|
64
64
|
if (!supportsExecutableWebSearch(ctx.model, toolOptions))
|
|
65
|
-
throw new Error(
|
|
65
|
+
throw new Error(codexLoginDiagnostic());
|
|
66
66
|
const output = await executeCodexWebSearch(
|
|
67
67
|
params,
|
|
68
68
|
ctx,
|