@unbrowse/sdk 10.4.0 → 11.1.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unbrowse/sdk",
3
- "version": "10.4.0",
3
+ "version": "11.1.0",
4
4
  "description": "TypeScript SDK for Unbrowse \u2014 auto-spawns the unbrowse binary and talks to it over a local socket. For an HTTP-first, browser/edge-compatible client with zero runtime deps, see @unbrowse/client.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/dist/client.d.ts DELETED
@@ -1,168 +0,0 @@
1
- import type { AttributionLedger, AvailableEndpoint, CreatorTransactionsResponse, Dashboard, ExecuteInput, ExecuteResponse, FeedbackInput, FeedbackResponse, HealthResponse, LoginInput, LoginResponse, RequestOptions, ResolveInput, ResolveResponse, SearchDomainInput, SearchInput, SearchResponse, SearchEndpointsInput, SearchEndpointsResponse, SkillManifest, StatsResponse, StealAuthInput, StealAuthResponse, UnbrowseClientOptions, PublishSkillInput, PublishResponse, AnnotateInput, AnnotateResponse, PaymentProvider, PaymentProviderResponse } from "./contracts.js";
2
- import { type SpawnRuntimeOptions } from "./runtime.js";
3
- export declare class Unbrowse {
4
- readonly baseUrl: string;
5
- readonly apiKey?: string;
6
- readonly clientId?: string;
7
- private readonly defaultHeaders?;
8
- private readonly fetchImpl;
9
- private readonly timeoutMs?;
10
- private _runtimeHandle;
11
- constructor(options?: UnbrowseClientOptions);
12
- /**
13
- * Build a `params` object from an `AvailableEndpoint.input_params` spec, using
14
- * the `example_value` of each declared key. Skips keys without an example.
15
- */
16
- static paramsFromInputSpec(spec: AvailableEndpoint["input_params"] | undefined): Record<string, unknown>;
17
- /**
18
- * Point at an already-running Unbrowse runtime. No probe, no spawn.
19
- * `.close()` is a no-op for the runtime (the caller owns it).
20
- */
21
- static connect(baseUrl: string, opts?: Omit<UnbrowseClientOptions, "baseUrl">): Promise<Unbrowse>;
22
- /**
23
- * Spawn a co-located Unbrowse runtime and return a client pointed at it.
24
- * The client takes ownership of the child process: `.close()` will tear
25
- * it down.
26
- */
27
- static spawn(opts?: SpawnRuntimeOptions & Omit<UnbrowseClientOptions, "baseUrl">): Promise<Unbrowse>;
28
- /**
29
- * Probe 127.0.0.1 on the requested port (default 6969). Adopts a live
30
- * runtime via `connect`; spawns a new one via `spawn` if dead. The
31
- * resulting client only owns the runtime if it had to spawn.
32
- */
33
- static local(opts?: SpawnRuntimeOptions & Omit<UnbrowseClientOptions, "baseUrl">): Promise<Unbrowse>;
34
- /**
35
- * Release any resources owned by this client. If the client spawned its
36
- * own runtime, this kills the child process. Otherwise no-op.
37
- */
38
- close(): Promise<void>;
39
- request<T>(method: string, path: string, body?: unknown, options?: RequestOptions): Promise<T>;
40
- resolve(input: ResolveInput, options?: RequestOptions): Promise<ResolveResponse>;
41
- execute(skill: string | ExecuteInput | ResolveResponse, input?: Omit<ExecuteInput, "skillId">, options?: RequestOptions): Promise<ExecuteResponse>;
42
- getSkill(skillId: string, options?: RequestOptions): Promise<SkillManifest>;
43
- login(input: LoginInput, options?: RequestOptions): Promise<LoginResponse>;
44
- importAuth(input: StealAuthInput, options?: RequestOptions): Promise<StealAuthResponse>;
45
- stealAuth(input: StealAuthInput, options?: RequestOptions): Promise<StealAuthResponse>;
46
- search(input: SearchInput, options?: RequestOptions): Promise<SearchResponse>;
47
- searchDomain(input: SearchDomainInput, options?: RequestOptions): Promise<SearchResponse>;
48
- /**
49
- * Semantic search across ALL indexed endpoints (flat shape).
50
- *
51
- * Returns one row per endpoint, ranked by semantic match against the
52
- * intent string. Use this when you want to pick endpoints across many
53
- * skills (vs `search()` which groups by skill).
54
- *
55
- * Optional `domain` scopes the search to one host's endpoints; omit for
56
- * cross-marketplace search. Authenticated agents are charged the
57
- * standard search fee per the existing x402 economics; anonymous
58
- * callers get free rate-limited public discovery.
59
- *
60
- * @example
61
- * ```ts
62
- * const { endpoints } = await u.searchEndpoints({ intent: "trending repositories", k: 5 });
63
- * for (const ep of endpoints) {
64
- * console.log(ep.score, ep.skill_id, ep.endpoint_id, ep.description);
65
- * }
66
- * ```
67
- */
68
- searchEndpoints(input: SearchEndpointsInput, options?: RequestOptions): Promise<SearchEndpointsResponse>;
69
- feedback(input: FeedbackInput, options?: RequestOptions): Promise<FeedbackResponse>;
70
- stats(options?: RequestOptions): Promise<StatsResponse>;
71
- health(options?: RequestOptions): Promise<HealthResponse>;
72
- /**
73
- * Earnings/spending dashboard for the authenticated agent.
74
- * Requires `apiKey` set on the client. Backend: `GET /v1/dashboard/me`.
75
- */
76
- dashboard(options?: RequestOptions): Promise<Dashboard>;
77
- /**
78
- * Public dashboard for any wallet address. Backend: `GET /v1/dashboard/wallet/:walletAddress`.
79
- */
80
- dashboardByWallet(walletAddress: string, options?: RequestOptions): Promise<Dashboard>;
81
- /**
82
- * Per-transaction earnings ledger for a creator agent.
83
- * Backend: `GET /v1/transactions/creator/:agentId`.
84
- */
85
- creatorTransactions(agentId: string, options?: RequestOptions): Promise<CreatorTransactionsResponse>;
86
- /**
87
- * Fund a Flex escrow on the caller's behalf. Thin wrapper around
88
- * `fundEscrow` in `./flex.ts` — requires the caller to pass
89
- * `signer` + `rpc` for v6.16-preview.0 (until SDK ships its own
90
- * @solana/kit pipeline). For pure tx construction without sending,
91
- * import `buildEscrowCreationTx` from the package root.
92
- */
93
- fundEscrow(params: {
94
- amountUsdc: string;
95
- walletAddress?: string;
96
- facilitatorAddress?: string;
97
- mint?: string;
98
- refundTimeoutSlots?: number;
99
- deadmanTimeoutSlots?: number;
100
- signer?: unknown;
101
- rpc?: unknown;
102
- }): Promise<{
103
- escrowAddress: string;
104
- txSignature: string;
105
- }>;
106
- /**
107
- * Register a session key against the caller's existing Flex escrow.
108
- * Thin wrapper around `registerSessionKey` in `./flex.ts`.
109
- */
110
- registerSessionKey(params: {
111
- sessionKeyAddress: string;
112
- walletAddress?: string;
113
- escrowAddress?: string;
114
- expiresAtSlot?: string;
115
- revocationGracePeriodSlots?: number;
116
- signer?: unknown;
117
- rpc?: unknown;
118
- }): Promise<{
119
- txSignature: string;
120
- }>;
121
- /**
122
- * Execute a skill against a Flex-metered route. preview.0/preview.1 stub:
123
- * the backend metered-execute route (`POST /v1/skills/:id/execute` with
124
- * Flex-shaped 402 + usage_units settlement) ships in v6.16.0-preview.2.
125
- * Callers must use `Unbrowse#execute` against fixed-price skills until
126
- * then. The method signature stays for forward compat; the body refuses
127
- * with a precise version-targeted error.
128
- */
129
- executeMetered<T = unknown>(_skillOrId: string | {
130
- skill_id: string;
131
- }, _input: unknown, _opts?: {
132
- onUsage?: (units: number) => void;
133
- wallet?: import("./flex.js").FlexWalletLike;
134
- }, _options?: RequestOptions): Promise<T>;
135
- /**
136
- * Indexer earnings via delta-based attribution.
137
- * Backend: `GET /v1/attribution/indexer/:indexerId`.
138
- */
139
- indexerAttribution(indexerId: string, options?: RequestOptions): Promise<AttributionLedger>;
140
- /**
141
- * Publish a captured skill to the marketplace.
142
- * Backend: `POST /v1/skills`.
143
- *
144
- * SDK gap-fill (Wave 2 of rebuild-the-unbrowse-sdk-as-a-thin-http-first-ty
145
- * + the parity gate from tests/cli-mcp-sdk-parity.test.ts). Mirrors the
146
- * CLI `unbrowse publish` and the MCP `unbrowse_publish` tool.
147
- */
148
- publish(skill: PublishSkillInput, options?: RequestOptions): Promise<PublishResponse>;
149
- /**
150
- * Annotate an endpoint with a tip, constraint, or gotcha.
151
- * Backend: `POST /v1/skills/:id/endpoints/:eid/annotate`.
152
- *
153
- * SDK gap-fill. Mirrors CLI `unbrowse annotate` + MCP `unbrowse_annotate`.
154
- */
155
- annotate(input: AnnotateInput, options?: RequestOptions): Promise<AnnotateResponse>;
156
- /**
157
- * Persist the agent's chosen x402 payment rail on the backend.
158
- * Backend: `POST /v1/account/payment-provider` (shipped in #691).
159
- *
160
- * SDK gap-fill: surface the Wave 2 backend route as a typed SDK
161
- * method so SDK callers can sync provider choice without rolling
162
- * a raw fetch. Allowed values are the same six the route whitelists:
163
- * pay_sh / lobster_cash / external_solana / privy_embedded /
164
- * privy_embedded_solana / skip.
165
- */
166
- paymentProvider(provider: PaymentProvider, options?: RequestOptions): Promise<PaymentProviderResponse>;
167
- }
168
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,2BAA2B,EAC3B,SAAS,EACT,YAAY,EACZ,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,aAAa,EACb,cAAc,EACd,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,uBAAuB,EACvB,aAAa,EACb,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,uBAAuB,EACxB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAEL,KAAK,mBAAmB,EAGzB,MAAM,cAAc,CAAC;AAuEtB,qBAAa,QAAQ;IACnB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAc;IAC9C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;IACzC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAS;IACpC,OAAO,CAAC,cAAc,CAA8B;gBAExC,OAAO,GAAE,qBAA0B;IAS/C;;;OAGG;IACH,MAAM,CAAC,mBAAmB,CACxB,IAAI,EAAE,iBAAiB,CAAC,cAAc,CAAC,GAAG,SAAS,GAClD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAQ1B;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G;IACG,eAAe,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,uBAAuB,CAAC;CAQ7G"}
package/dist/client.js DELETED
@@ -1,440 +0,0 @@
1
- import { PaymentRequiredError, UnbrowseApiError } from "./errors.js";
2
- import { probeUnbrowseRuntime, spawnUnbrowseRuntime, } from "./runtime.js";
3
- function readEnv(name) {
4
- const globalProcess = typeof globalThis === "object" && "process" in globalThis
5
- ? globalThis.process
6
- : undefined;
7
- if (!globalProcess?.env)
8
- return undefined;
9
- const value = globalProcess.env[name];
10
- return typeof value === "string" && value.length > 0 ? value : undefined;
11
- }
12
- function normalizeBaseUrl(baseUrl) {
13
- return (baseUrl ?? readEnv("UNBROWSE_URL") ?? "http://localhost:6969").replace(/\/+$/, "");
14
- }
15
- function isResolveResponse(value) {
16
- return "trace" in value;
17
- }
18
- function resolveSkillId(value) {
19
- if (typeof value === "string")
20
- return value;
21
- if ("skillId" in value && typeof value.skillId === "string") {
22
- return value.skillId;
23
- }
24
- if (!isResolveResponse(value)) {
25
- throw new Error("Could not determine skill_id from execute input");
26
- }
27
- const fromSkill = value.skill?.skill_id;
28
- if (typeof fromSkill === "string" && fromSkill.length > 0)
29
- return fromSkill;
30
- const fromTrace = value.trace?.skill_id;
31
- if (typeof fromTrace === "string" && fromTrace.length > 0)
32
- return fromTrace;
33
- throw new Error("Could not determine skill_id from execute input");
34
- }
35
- async function parseResponseBody(response) {
36
- const text = await response.text();
37
- if (!text)
38
- return null;
39
- try {
40
- return JSON.parse(text);
41
- }
42
- catch {
43
- return text;
44
- }
45
- }
46
- function buildAbortSignal(timeoutMs, signal) {
47
- if (!timeoutMs && !signal)
48
- return { signal, cleanup: () => { } };
49
- const controller = new AbortController();
50
- const onAbort = () => controller.abort(signal?.reason);
51
- const timer = timeoutMs ? setTimeout(() => controller.abort(new Error(`Request timed out after ${timeoutMs}ms`)), timeoutMs) : undefined;
52
- if (signal) {
53
- if (signal.aborted)
54
- controller.abort(signal.reason);
55
- else
56
- signal.addEventListener("abort", onAbort, { once: true });
57
- }
58
- return {
59
- signal: controller.signal,
60
- cleanup: () => {
61
- if (timer)
62
- clearTimeout(timer);
63
- if (signal)
64
- signal.removeEventListener("abort", onAbort);
65
- },
66
- };
67
- }
68
- export class Unbrowse {
69
- baseUrl;
70
- apiKey;
71
- clientId;
72
- defaultHeaders;
73
- fetchImpl;
74
- timeoutMs;
75
- _runtimeHandle = null;
76
- constructor(options = {}) {
77
- this.baseUrl = normalizeBaseUrl(options.baseUrl);
78
- this.apiKey = options.apiKey ?? readEnv("UNBROWSE_API_KEY");
79
- this.clientId = options.clientId;
80
- this.defaultHeaders = options.headers;
81
- this.fetchImpl = options.fetch ?? fetch;
82
- this.timeoutMs = options.timeoutMs;
83
- }
84
- /**
85
- * Build a `params` object from an `AvailableEndpoint.input_params` spec, using
86
- * the `example_value` of each declared key. Skips keys without an example.
87
- */
88
- static paramsFromInputSpec(spec) {
89
- const out = {};
90
- for (const p of spec ?? []) {
91
- if (p.example_value !== undefined)
92
- out[p.key] = p.example_value;
93
- }
94
- return out;
95
- }
96
- /**
97
- * Point at an already-running Unbrowse runtime. No probe, no spawn.
98
- * `.close()` is a no-op for the runtime (the caller owns it).
99
- */
100
- static async connect(baseUrl, opts = {}) {
101
- return new Unbrowse({ ...opts, baseUrl });
102
- }
103
- /**
104
- * Spawn a co-located Unbrowse runtime and return a client pointed at it.
105
- * The client takes ownership of the child process: `.close()` will tear
106
- * it down.
107
- */
108
- static async spawn(opts = {}) {
109
- const { port, cwd, env, binaryPath, readyTimeoutMs, ...clientOpts } = opts;
110
- const handle = await spawnUnbrowseRuntime({ port, cwd, env, binaryPath, readyTimeoutMs });
111
- const client = new Unbrowse({ ...clientOpts, baseUrl: handle.baseUrl });
112
- if (handle.owned)
113
- client._runtimeHandle = handle;
114
- return client;
115
- }
116
- /**
117
- * Probe 127.0.0.1 on the requested port (default 6969). Adopts a live
118
- * runtime via `connect`; spawns a new one via `spawn` if dead. The
119
- * resulting client only owns the runtime if it had to spawn.
120
- */
121
- static async local(opts = {}) {
122
- const port = opts.port ?? 6969;
123
- const baseUrl = `http://127.0.0.1:${port}`;
124
- if (await probeUnbrowseRuntime(baseUrl, 1_000)) {
125
- const { port: _p, cwd: _c, env: _e, binaryPath: _b, readyTimeoutMs: _r, ...clientOpts } = opts;
126
- return Unbrowse.connect(baseUrl, clientOpts);
127
- }
128
- return Unbrowse.spawn(opts);
129
- }
130
- /**
131
- * Release any resources owned by this client. If the client spawned its
132
- * own runtime, this kills the child process. Otherwise no-op.
133
- */
134
- async close() {
135
- if (this._runtimeHandle) {
136
- const h = this._runtimeHandle;
137
- this._runtimeHandle = null;
138
- await h.kill();
139
- }
140
- }
141
- async request(method, path, body, options = {}) {
142
- const url = `${this.baseUrl}${path}`;
143
- const headers = new Headers(this.defaultHeaders);
144
- headers.set("Accept", "application/json");
145
- if (body !== undefined)
146
- headers.set("Content-Type", "application/json");
147
- if (this.apiKey)
148
- headers.set("Authorization", `Bearer ${this.apiKey}`);
149
- if (this.clientId)
150
- headers.set("x-unbrowse-client-id", this.clientId);
151
- if (options.headers) {
152
- const extra = new Headers(options.headers);
153
- extra.forEach((value, key) => headers.set(key, value));
154
- }
155
- const { signal, cleanup } = buildAbortSignal(options.timeoutMs ?? this.timeoutMs, options.signal);
156
- try {
157
- const response = await this.fetchImpl(url, {
158
- method,
159
- headers,
160
- body: body === undefined ? undefined : JSON.stringify(body),
161
- signal,
162
- });
163
- const data = await parseResponseBody(response);
164
- if (!response.ok) {
165
- // 402 surfaces as PaymentRequiredError so callers can hand the
166
- // typed error to `payAndRetry(error, wallet, retry)`. Accepts the
167
- // standard x402 shape (`{ accepts: [...] }`) and the Unbrowse
168
- // backend shape that nests it under `data.accepts`.
169
- if (response.status === 402) {
170
- const payload = (typeof data === "object" && data !== null) ? data : {};
171
- const acceptsRaw = (() => {
172
- const top = payload["accepts"];
173
- if (Array.isArray(top))
174
- return top;
175
- const nested = payload["data"]?.["accepts"];
176
- return Array.isArray(nested) ? nested : [];
177
- })();
178
- const accepts = acceptsRaw;
179
- const skillIdFromBody = typeof payload["skillId"] === "string"
180
- ? payload["skillId"]
181
- : (typeof payload["skill_id"] === "string" ? payload["skill_id"] : undefined);
182
- const skillIdFromPath = (() => {
183
- const m = path.match(/\/v1\/skills\/([^/?#]+)/);
184
- return m ? decodeURIComponent(m[1]) : undefined;
185
- })();
186
- const message = typeof payload["error"] === "string"
187
- ? payload["error"]
188
- : `${method} ${path} failed with 402`;
189
- throw new PaymentRequiredError(message, accepts, url, skillIdFromBody ?? skillIdFromPath);
190
- }
191
- const message = typeof data === "object" && data && "error" in data && typeof data.error === "string"
192
- ? String(data.error)
193
- : `${method} ${path} failed with ${response.status}`;
194
- throw new UnbrowseApiError(message, {
195
- status: response.status,
196
- path,
197
- data,
198
- headers: response.headers,
199
- });
200
- }
201
- return data;
202
- }
203
- finally {
204
- cleanup();
205
- }
206
- }
207
- async resolve(input, options) {
208
- const body = {
209
- intent: input.intent,
210
- params: { ...(input.params ?? {}) },
211
- context: { ...(input.context ?? {}) },
212
- };
213
- if (input.url) {
214
- const params = body.params;
215
- const context = body.context;
216
- if (typeof params.url !== "string")
217
- params.url = input.url;
218
- if (typeof context.url !== "string")
219
- context.url = input.url;
220
- }
221
- if (input.projection)
222
- body.projection = input.projection;
223
- if (input.confirmUnsafe !== undefined)
224
- body.confirm_unsafe = input.confirmUnsafe;
225
- if (input.confirmThirdPartyTerms !== undefined)
226
- body.confirm_third_party_terms = input.confirmThirdPartyTerms;
227
- if (input.dryRun !== undefined)
228
- body.dry_run = input.dryRun;
229
- if (input.forceCapture !== undefined)
230
- body.force_capture = input.forceCapture;
231
- return this.request("POST", "/v1/intent/resolve", body, options);
232
- }
233
- async execute(skill, input = {}, options) {
234
- const skillId = resolveSkillId(skill);
235
- const bodyInput = typeof skill === "object" && "skillId" in skill ? skill : input;
236
- const body = {};
237
- if (bodyInput.params)
238
- body.params = bodyInput.params;
239
- if (bodyInput.projection)
240
- body.projection = bodyInput.projection;
241
- if (bodyInput.confirmUnsafe !== undefined)
242
- body.confirm_unsafe = bodyInput.confirmUnsafe;
243
- if (bodyInput.confirmThirdPartyTerms !== undefined)
244
- body.confirm_third_party_terms = bodyInput.confirmThirdPartyTerms;
245
- if (bodyInput.dryRun !== undefined)
246
- body.dry_run = bodyInput.dryRun;
247
- if (bodyInput.intent)
248
- body.intent = bodyInput.intent;
249
- if (bodyInput.contextUrl)
250
- body.context_url = bodyInput.contextUrl;
251
- return this.request("POST", `/v1/skills/${encodeURIComponent(skillId)}/execute`, body, options);
252
- }
253
- async getSkill(skillId, options) {
254
- return this.request("GET", `/v1/skills/${encodeURIComponent(skillId)}`, undefined, options);
255
- }
256
- async login(input, options) {
257
- return this.request("POST", "/v1/auth/login", { url: input.url }, options);
258
- }
259
- async importAuth(input, options) {
260
- return this.request("POST", "/v1/auth/steal", {
261
- url: input.url,
262
- browser: input.browser,
263
- chrome_profile: input.chromeProfile,
264
- firefox_profile: input.firefoxProfile,
265
- chromium_profile: input.chromiumProfile,
266
- chromium_user_data_dir: input.chromiumUserDataDir,
267
- chromium_cookie_db_path: input.chromiumCookieDbPath,
268
- safe_storage_service: input.safeStorageService,
269
- browser_name: input.browserName,
270
- }, options);
271
- }
272
- async stealAuth(input, options) {
273
- return this.importAuth(input, options);
274
- }
275
- async search(input, options) {
276
- return this.request("POST", "/v1/search", {
277
- intent: input.intent,
278
- k: input.k,
279
- }, options);
280
- }
281
- async searchDomain(input, options) {
282
- return this.request("POST", "/v1/search/domain", {
283
- intent: input.intent,
284
- domain: input.domain,
285
- k: input.k,
286
- }, options);
287
- }
288
- /**
289
- * Semantic search across ALL indexed endpoints (flat shape).
290
- *
291
- * Returns one row per endpoint, ranked by semantic match against the
292
- * intent string. Use this when you want to pick endpoints across many
293
- * skills (vs `search()` which groups by skill).
294
- *
295
- * Optional `domain` scopes the search to one host's endpoints; omit for
296
- * cross-marketplace search. Authenticated agents are charged the
297
- * standard search fee per the existing x402 economics; anonymous
298
- * callers get free rate-limited public discovery.
299
- *
300
- * @example
301
- * ```ts
302
- * const { endpoints } = await u.searchEndpoints({ intent: "trending repositories", k: 5 });
303
- * for (const ep of endpoints) {
304
- * console.log(ep.score, ep.skill_id, ep.endpoint_id, ep.description);
305
- * }
306
- * ```
307
- */
308
- async searchEndpoints(input, options) {
309
- return this.request("POST", "/v1/search/endpoints", {
310
- intent: input.intent,
311
- k: input.k,
312
- domain: input.domain,
313
- }, options);
314
- }
315
- async feedback(input, options) {
316
- return this.request("POST", "/v1/feedback", {
317
- skill_id: input.skillId,
318
- endpoint_id: input.endpointId,
319
- rating: input.rating,
320
- outcome: input.outcome,
321
- diagnostics: input.diagnostics,
322
- }, options);
323
- }
324
- async stats(options) {
325
- return this.request("GET", "/v1/stats", undefined, options);
326
- }
327
- async health(options) {
328
- return this.request("GET", "/health", undefined, options);
329
- }
330
- /**
331
- * Earnings/spending dashboard for the authenticated agent.
332
- * Requires `apiKey` set on the client. Backend: `GET /v1/dashboard/me`.
333
- */
334
- async dashboard(options) {
335
- return this.request("GET", "/v1/dashboard/me", undefined, options);
336
- }
337
- /**
338
- * Public dashboard for any wallet address. Backend: `GET /v1/dashboard/wallet/:walletAddress`.
339
- */
340
- async dashboardByWallet(walletAddress, options) {
341
- return this.request("GET", `/v1/dashboard/wallet/${encodeURIComponent(walletAddress)}`, undefined, options);
342
- }
343
- /**
344
- * Per-transaction earnings ledger for a creator agent.
345
- * Backend: `GET /v1/transactions/creator/:agentId`.
346
- */
347
- async creatorTransactions(agentId, options) {
348
- return this.request("GET", `/v1/transactions/creator/${encodeURIComponent(agentId)}`, undefined, options);
349
- }
350
- /**
351
- * Fund a Flex escrow on the caller's behalf. Thin wrapper around
352
- * `fundEscrow` in `./flex.ts` — requires the caller to pass
353
- * `signer` + `rpc` for v6.16-preview.0 (until SDK ships its own
354
- * @solana/kit pipeline). For pure tx construction without sending,
355
- * import `buildEscrowCreationTx` from the package root.
356
- */
357
- async fundEscrow(params) {
358
- const { fundEscrow } = await import("./flex.js");
359
- return fundEscrow({
360
- amountUsdc: params.amountUsdc,
361
- walletAddress: params.walletAddress ?? "",
362
- facilitatorAddress: params.facilitatorAddress ?? "",
363
- mint: params.mint,
364
- refundTimeoutSlots: params.refundTimeoutSlots,
365
- deadmanTimeoutSlots: params.deadmanTimeoutSlots,
366
- signer: params.signer,
367
- rpc: params.rpc,
368
- });
369
- }
370
- /**
371
- * Register a session key against the caller's existing Flex escrow.
372
- * Thin wrapper around `registerSessionKey` in `./flex.ts`.
373
- */
374
- async registerSessionKey(params) {
375
- const { registerSessionKey } = await import("./flex.js");
376
- return registerSessionKey({
377
- walletAddress: params.walletAddress ?? "",
378
- escrowAddress: params.escrowAddress ?? "",
379
- sessionKeyAddress: params.sessionKeyAddress,
380
- expiresAtSlot: params.expiresAtSlot,
381
- revocationGracePeriodSlots: params.revocationGracePeriodSlots,
382
- signer: params.signer,
383
- rpc: params.rpc,
384
- });
385
- }
386
- /**
387
- * Execute a skill against a Flex-metered route. preview.0/preview.1 stub:
388
- * the backend metered-execute route (`POST /v1/skills/:id/execute` with
389
- * Flex-shaped 402 + usage_units settlement) ships in v6.16.0-preview.2.
390
- * Callers must use `Unbrowse#execute` against fixed-price skills until
391
- * then. The method signature stays for forward compat; the body refuses
392
- * with a precise version-targeted error.
393
- */
394
- async executeMetered(_skillOrId, _input, _opts, _options) {
395
- throw new Error("Unbrowse#executeMetered requires the backend metered-execute route which ships in v6.16.0-preview.2. " +
396
- "For preview.0/preview.1, use Unbrowse#execute against fixed-price skills.");
397
- }
398
- /**
399
- * Indexer earnings via delta-based attribution.
400
- * Backend: `GET /v1/attribution/indexer/:indexerId`.
401
- */
402
- async indexerAttribution(indexerId, options) {
403
- return this.request("GET", `/v1/attribution/indexer/${encodeURIComponent(indexerId)}`, undefined, options);
404
- }
405
- /**
406
- * Publish a captured skill to the marketplace.
407
- * Backend: `POST /v1/skills`.
408
- *
409
- * SDK gap-fill (Wave 2 of rebuild-the-unbrowse-sdk-as-a-thin-http-first-ty
410
- * + the parity gate from tests/cli-mcp-sdk-parity.test.ts). Mirrors the
411
- * CLI `unbrowse publish` and the MCP `unbrowse_publish` tool.
412
- */
413
- async publish(skill, options) {
414
- return this.request("POST", "/v1/skills", skill, options);
415
- }
416
- /**
417
- * Annotate an endpoint with a tip, constraint, or gotcha.
418
- * Backend: `POST /v1/skills/:id/endpoints/:eid/annotate`.
419
- *
420
- * SDK gap-fill. Mirrors CLI `unbrowse annotate` + MCP `unbrowse_annotate`.
421
- */
422
- async annotate(input, options) {
423
- const { skillId, endpointId, ...body } = input;
424
- return this.request("POST", `/v1/skills/${encodeURIComponent(skillId)}/endpoints/${encodeURIComponent(endpointId)}/annotate`, body, options);
425
- }
426
- /**
427
- * Persist the agent's chosen x402 payment rail on the backend.
428
- * Backend: `POST /v1/account/payment-provider` (shipped in #691).
429
- *
430
- * SDK gap-fill: surface the Wave 2 backend route as a typed SDK
431
- * method so SDK callers can sync provider choice without rolling
432
- * a raw fetch. Allowed values are the same six the route whitelists:
433
- * pay_sh / lobster_cash / external_solana / privy_embedded /
434
- * privy_embedded_solana / skip.
435
- */
436
- async paymentProvider(provider, options) {
437
- return this.request("POST", "/v1/account/payment-provider", { provider }, options);
438
- }
439
- }
440
- //# sourceMappingURL=client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAgCA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAGL,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAKtB,SAAS,OAAO,CAAC,IAAY;IAC3B,MAAM,aAAa,GAAG,OAAO,UAAU,KAAK,QAAQ,IAAI,SAAS,IAAI,UAAU;QAC7E,CAAC,CAAE,UAAyE,CAAC,OAAO;QACpF,CAAC,CAAC,SAAS,CAAC;IACd,IAAI,CAAC,aAAa,EAAE,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