@xyz17711/websearch 0.1.1 → 0.1.2

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
@@ -27,10 +27,13 @@ npm install @xyz17711/websearch
27
27
  ```typescript
28
28
  import { Client } from "@xyz17711/websearch";
29
29
 
30
- const client = new Client("https://api.17711.xyz/registry/websearch");
30
+ const client = new Client(); // talks to https://api.17711.xyz/registry/websearch by default
31
31
  // see the Methods table above for every available call and its request/response type
32
32
  ```
33
33
 
34
+ Pass another base URL (self-hosted instance, test server) as the first argument:
35
+ `new Client("https://my-host.example/registry/websearch")`.
36
+
34
37
  ## Paying past the free quota
35
38
 
36
39
  Every gated tool allows a small number of free calls per day; beyond that it returns a 402
@@ -40,7 +43,7 @@ network, and payee address attached:
40
43
  ```typescript
41
44
  import { Client, PaymentRequiredError } from "@xyz17711/websearch";
42
45
 
43
- const client = new Client("https://api.17711.xyz/registry/websearch");
46
+ const client = new Client();
44
47
  try {
45
48
  await client.getTaskStatus(/* ... */);
46
49
  } catch (e) {
@@ -56,7 +59,7 @@ own environment/secrets manager, never a literal string in source code:
56
59
  ```typescript
57
60
  import { Client } from "@xyz17711/websearch";
58
61
 
59
- const client = new Client("https://api.17711.xyz/registry/websearch", {
62
+ const client = new Client({
60
63
  x402PrivateKey: process.env.X402_PRIVATE_KEY,
61
64
  x402ExpectedNetwork: "eip155:8453", // Base mainnet; use eip155:84532 for Base Sepolia testnet
62
65
  x402MaxPaymentUsdc: 0.01, // refuse any single call above this
@@ -75,7 +78,7 @@ with that same key in this process.
75
78
  import { Client } from "@xyz17711/websearch";
76
79
  import { WebsearchToolkit } from "@xyz17711/websearch/langchain";
77
80
 
78
- const client = new Client("https://api.17711.xyz/registry/websearch", { /* ...wallet options... */ });
81
+ const client = new Client({ /* ...wallet options... */ });
79
82
  const tools = new WebsearchToolkit(client).getTools();
80
83
  ```
81
84
 
package/dist/index.d.ts CHANGED
@@ -36,8 +36,17 @@ export interface SearchWebAsyncRequest {
36
36
  /** The search query text, e.g. `"rust async runtime comparison"`. */
37
37
  query: string;
38
38
  }
39
+ /** Production base URL of this service; pass another to self-host or test. */
40
+ export declare const DEFAULT_BASE_URL = "https://api.17711.xyz/registry/websearch";
39
41
  /** Typed client for websearch, e.g. `client.getTaskStatus(...)`. */
40
42
  export declare class Client extends BaseClient {
43
+ /**
44
+ * `new Client()` talks to the production service. Pass a base URL to target another
45
+ * instance, and/or wallet options (`new Client({ x402PrivateKey, ... })`) to pay past the
46
+ * free quota automatically.
47
+ */
48
+ constructor(options?: ClientOptions);
49
+ constructor(baseUrl?: string, options?: ClientOptions);
41
50
  /** Polls for the result of a task enqueued by a *_async tool */
42
51
  getTaskStatus(request: GetTaskStatusRequest): Promise<GetTaskStatusResponse>;
43
52
  /** Web search API for agents: search the web and get result titles, URLs and snippets as JSON ($0.005, x402) */
package/dist/index.js CHANGED
@@ -2,8 +2,16 @@
2
2
  * Typed HTTP client and request/response interfaces for websearch.
3
3
  */
4
4
  import { Client as BaseClient } from "@xyz17711/core";
5
+ /** Production base URL of this service; pass another to self-host or test. */
6
+ export const DEFAULT_BASE_URL = "https://api.17711.xyz/registry/websearch";
5
7
  /** Typed client for websearch, e.g. `client.getTaskStatus(...)`. */
6
8
  export class Client extends BaseClient {
9
+ constructor(baseUrlOrOptions, options = {}) {
10
+ const [url, opts] = typeof baseUrlOrOptions === "object"
11
+ ? [DEFAULT_BASE_URL, baseUrlOrOptions]
12
+ : [baseUrlOrOptions ?? DEFAULT_BASE_URL, options];
13
+ super(url, opts);
14
+ }
7
15
  /** Polls for the result of a task enqueued by a *_async tool */
8
16
  async getTaskStatus(request) {
9
17
  return this.post("/v1/websearch/get_task_status", request);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyz17711/websearch",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Typed TypeScript client for the 17711.xyz Websearch API: pay-per-call, settled in USDC via x402.",
5
5
  "license": "MIT",
6
6
  "author": "17711 Services",