@normful/parallel-web-pi-extension 1.0.0 → 1.1.1

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 CHANGED
@@ -196,6 +196,24 @@ pi --no-extensions --no-skills -e ./src/index.ts
196
196
 
197
197
  This changes the browser login endpoints used by `/login parallel`.
198
198
 
199
+ ### Override The API Base URL
200
+
201
+ `PARALLEL_BASE_URL` redirects every Parallel API call the tools make — search,
202
+ extract and research all follow it, so they can be pointed at a staging or local
203
+ host together:
204
+
205
+ ```bash
206
+ export PARALLEL_BASE_URL=https://your-api-host
207
+ pi --no-extensions --no-skills -e ./src/index.ts
208
+ ```
209
+
210
+ The value is an **origin**, not a full URL: the `/v1/search`, `/v1/extract` and
211
+ `/v1/responses` paths are appended to it, and a trailing slash is tolerated.
212
+ Unset it to use `https://api.parallel.ai`.
213
+
214
+ This is separate from `PARALLEL_PLATFORM_URL`, which only affects the OAuth
215
+ login flow (that host is `platform.parallel.ai`, not `api.parallel.ai`).
216
+
199
217
  ## Quick Smoke Test
200
218
 
201
219
  Once Pi is running with the extension loaded, ask something that should force web usage, for example:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@normful/parallel-web-pi-extension",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "Add Parallel web search, fetch, and research tools to your pi agent",
5
5
  "author": "Norman Sue",
6
6
  "license": "MIT",
@@ -18,11 +18,11 @@
18
18
  "README.md"
19
19
  ],
20
20
  "dependencies": {
21
- "parallel-web": "1.3.0",
22
- "typebox": "^1.1.37"
21
+ "parallel-web": "1.3.0"
23
22
  },
24
23
  "peerDependencies": {
25
- "@earendil-works/pi-coding-agent": ">=0.83.0"
24
+ "@earendil-works/pi-coding-agent": ">=0.83.0",
25
+ "typebox": "*"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@earendil-works/pi-ai": ">=0.83.0",
@@ -32,11 +32,13 @@
32
32
  "@vitest/coverage-v8": "^5.0.4",
33
33
  "eslint": "^8.54.0",
34
34
  "prettier": "^3.1.0",
35
+ "typebox": "^1.1.37",
35
36
  "typescript": "^5.3.2",
36
37
  "vitest": "^5.0.4"
37
38
  },
38
39
  "scripts": {
39
40
  "test": "vitest run",
41
+ "coverage": "vitest run --coverage",
40
42
  "typecheck": "tsc --noEmit",
41
43
  "lint": "eslint .",
42
44
  "lint:fix": "eslint . --fix",
@@ -1,6 +1,28 @@
1
1
  import pkg from '../package.json' with { type: 'json' };
2
2
 
3
- export const PARALLEL_RESPONSES_URL = 'https://api.parallel.ai/v1/responses';
3
+ /**
4
+ * Default API origin used when PARALLEL_BASE_URL is unset. Matches the value
5
+ * hardcoded into the parallel-web SDK, so a single variable can point every
6
+ * web tool at the same host.
7
+ */
8
+ export const PARALLEL_API_ORIGIN = 'https://api.parallel.ai';
9
+ export const PARALLEL_RESPONSES_PATH = '/v1/responses';
10
+ /** Responses endpoint on the default origin. */
11
+ export const PARALLEL_RESPONSES_URL = `${PARALLEL_API_ORIGIN}${PARALLEL_RESPONSES_PATH}`;
12
+
13
+ /**
14
+ * Resolve the Responses endpoint, honoring PARALLEL_BASE_URL exactly as the
15
+ * parallel-web SDK does for web_search and web_fetch. The value is an origin:
16
+ * the `/v1/...` path is always appended, and a trailing slash is tolerated.
17
+ */
18
+ export function resolveParallelResponsesUrl(
19
+ baseUrl: string | undefined = process.env.PARALLEL_BASE_URL
20
+ ) {
21
+ const origin = baseUrl?.trim().replace(/\/+$/, '');
22
+ return origin
23
+ ? `${origin}${PARALLEL_RESPONSES_PATH}`
24
+ : PARALLEL_RESPONSES_URL;
25
+ }
4
26
  export const PARALLEL_RESPONSES_MAX_INPUT_CHARS = 20_000;
5
27
  export const PARALLEL_RESPONSES_TIMEOUT_MS = 120_000;
6
28
  export const DEFAULT_RESEARCH_EFFORT = 'medium';
@@ -217,7 +239,7 @@ export async function runParallelResearch(
217
239
  timeout.unref?.();
218
240
  try {
219
241
  requestSignal.throwIfAborted();
220
- const response = await fetch(PARALLEL_RESPONSES_URL, {
242
+ const response = await fetch(resolveParallelResponsesUrl(), {
221
243
  method: 'POST',
222
244
  headers: {
223
245
  Authorization: `Bearer ${apiKey}`,