@omnixhq/ucp-client 2.2.0 → 2.4.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/README.md +40 -8
- package/dist/adapters/anthropic.d.cts +1 -1
- package/dist/adapters/anthropic.d.ts +1 -1
- package/dist/adapters/langchain.d.cts +1 -1
- package/dist/adapters/langchain.d.ts +1 -1
- package/dist/adapters/mcp.d.cts +1 -1
- package/dist/adapters/mcp.d.ts +1 -1
- package/dist/adapters/openai.d.cts +1 -1
- package/dist/adapters/openai.d.ts +1 -1
- package/dist/adapters/vercel-ai.d.cts +1 -1
- package/dist/adapters/vercel-ai.d.ts +1 -1
- package/dist/catch-errors-C8MBfxB5.d.ts +4774 -0
- package/dist/catch-errors-C8MBfxB5.d.ts.map +1 -0
- package/dist/catch-errors-CO8dAo6Q.d.cts +4774 -0
- package/dist/catch-errors-CO8dAo6Q.d.cts.map +1 -0
- package/dist/errors-C1XqxNmZ.cjs.map +1 -1
- package/dist/errors-DX7yw6Gl.js.map +1 -1
- package/dist/index.cjs +260 -144
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -10382
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +3 -10382
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +239 -143
- package/dist/index.js.map +1 -1
- package/package.json +42 -3
- package/dist/catch-errors-BoytVKBJ.d.cts +0 -446
- package/dist/catch-errors-BoytVKBJ.d.cts.map +0 -1
- package/dist/catch-errors-lijeGf45.d.ts +0 -446
- package/dist/catch-errors-lijeGf45.d.ts.map +0 -1
|
@@ -1,446 +0,0 @@
|
|
|
1
|
-
import { CardCredential, CheckoutResponseStatus, ExtendedCheckoutResponse, Order, TokenCredential, UcpDiscoveryProfile } from "@omnixhq/ucp-js-sdk";
|
|
2
|
-
import { ZodType } from "zod";
|
|
3
|
-
|
|
4
|
-
//#region src/http.d.ts
|
|
5
|
-
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
6
|
-
type LogFn = (message: string, detail?: string) => void;
|
|
7
|
-
interface HttpClientConfig {
|
|
8
|
-
readonly gatewayUrl: string;
|
|
9
|
-
readonly agentProfileUrl: string;
|
|
10
|
-
readonly ucpVersion: string;
|
|
11
|
-
readonly requestSignature?: string;
|
|
12
|
-
readonly accessToken?: string;
|
|
13
|
-
readonly onValidationWarning?: LogFn;
|
|
14
|
-
}
|
|
15
|
-
declare class HttpClient {
|
|
16
|
-
private readonly gatewayUrl;
|
|
17
|
-
private readonly agentProfileUrl;
|
|
18
|
-
private readonly ucpVersion;
|
|
19
|
-
private readonly requestSignature;
|
|
20
|
-
private readonly accessToken;
|
|
21
|
-
private readonly onValidationWarning;
|
|
22
|
-
constructor(config: HttpClientConfig);
|
|
23
|
-
withAccessToken(token: string): HttpClient;
|
|
24
|
-
request(method: HttpMethod, path: string, body?: unknown): Promise<unknown>;
|
|
25
|
-
validate<T>(data: unknown, schema: ZodType<T>): T;
|
|
26
|
-
private throwFromResponse;
|
|
27
|
-
} //#endregion
|
|
28
|
-
//#region src/types/common.d.ts
|
|
29
|
-
interface PostalAddress {
|
|
30
|
-
readonly first_name?: string;
|
|
31
|
-
readonly last_name?: string;
|
|
32
|
-
readonly street_address?: string;
|
|
33
|
-
readonly extended_address?: string;
|
|
34
|
-
readonly address_locality?: string;
|
|
35
|
-
readonly address_region?: string;
|
|
36
|
-
readonly address_country?: string;
|
|
37
|
-
readonly postal_code?: string;
|
|
38
|
-
readonly phone_number?: string;
|
|
39
|
-
}
|
|
40
|
-
interface BuyerConsent {
|
|
41
|
-
readonly analytics?: boolean;
|
|
42
|
-
readonly preferences?: boolean;
|
|
43
|
-
readonly marketing?: boolean;
|
|
44
|
-
readonly sale_of_data?: boolean;
|
|
45
|
-
}
|
|
46
|
-
interface LocalizationContext {
|
|
47
|
-
readonly address_country?: string;
|
|
48
|
-
readonly address_region?: string;
|
|
49
|
-
readonly postal_code?: string;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* A JSON Web Key (RFC 7517).
|
|
53
|
-
* Extends the TypeScript stdlib `JsonWebKey` with the `kid` claim required by UCP for webhook
|
|
54
|
-
* signature verification (the stdlib definition omits `kid`).
|
|
55
|
-
*/
|
|
56
|
-
type JWK = JsonWebKey & {
|
|
57
|
-
readonly kid?: string;
|
|
58
|
-
};
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region src/types/payment.d.ts
|
|
61
|
-
//# sourceMappingURL=common.d.ts.map
|
|
62
|
-
type TokenCredential$1 = TokenCredential;
|
|
63
|
-
type CardCredential$1 = CardCredential;
|
|
64
|
-
type PaymentCredential = TokenCredential$1 | CardCredential$1;
|
|
65
|
-
interface PaymentInstrument {
|
|
66
|
-
readonly id: string;
|
|
67
|
-
readonly handler_id: string;
|
|
68
|
-
readonly type: string;
|
|
69
|
-
readonly brand?: string;
|
|
70
|
-
readonly last_digits?: string;
|
|
71
|
-
readonly handler_name?: string;
|
|
72
|
-
readonly selected?: boolean;
|
|
73
|
-
readonly display?: Readonly<Record<string, unknown>>;
|
|
74
|
-
readonly credential?: PaymentCredential;
|
|
75
|
-
readonly billing_address?: PostalAddress;
|
|
76
|
-
}
|
|
77
|
-
interface PaymentHandlerInstance {
|
|
78
|
-
readonly id: string;
|
|
79
|
-
readonly version: string;
|
|
80
|
-
readonly spec: string;
|
|
81
|
-
readonly schema: string;
|
|
82
|
-
readonly config?: Readonly<Record<string, unknown>>;
|
|
83
|
-
}
|
|
84
|
-
interface PaymentHandlerMap {
|
|
85
|
-
readonly [namespace: string]: readonly PaymentHandlerInstance[];
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
//#endregion
|
|
89
|
-
//#region src/types/checkout.d.ts
|
|
90
|
-
//# sourceMappingURL=payment.d.ts.map
|
|
91
|
-
type CheckoutSession = ExtendedCheckoutResponse;
|
|
92
|
-
type CheckoutSessionStatus = CheckoutResponseStatus;
|
|
93
|
-
interface CheckoutExtensions {
|
|
94
|
-
readonly fulfillment: boolean;
|
|
95
|
-
readonly discount: boolean;
|
|
96
|
-
readonly buyerConsent: boolean;
|
|
97
|
-
readonly ap2Mandate: boolean;
|
|
98
|
-
}
|
|
99
|
-
interface CreateCheckoutPayload {
|
|
100
|
-
readonly line_items: ReadonlyArray<{
|
|
101
|
-
readonly item: {
|
|
102
|
-
readonly id: string;
|
|
103
|
-
};
|
|
104
|
-
readonly quantity: number;
|
|
105
|
-
}>;
|
|
106
|
-
readonly currency?: string;
|
|
107
|
-
readonly buyer?: {
|
|
108
|
-
readonly first_name?: string;
|
|
109
|
-
readonly last_name?: string;
|
|
110
|
-
readonly email?: string;
|
|
111
|
-
readonly phone_number?: string;
|
|
112
|
-
readonly consent?: BuyerConsent;
|
|
113
|
-
};
|
|
114
|
-
readonly context?: LocalizationContext;
|
|
115
|
-
readonly payment?: {
|
|
116
|
-
readonly instruments?: readonly unknown[];
|
|
117
|
-
readonly handlers?: readonly unknown[];
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
interface UpdateCheckoutPayload {
|
|
121
|
-
readonly buyer?: {
|
|
122
|
-
readonly first_name?: string;
|
|
123
|
-
readonly last_name?: string;
|
|
124
|
-
readonly email?: string;
|
|
125
|
-
readonly phone_number?: string;
|
|
126
|
-
readonly consent?: BuyerConsent;
|
|
127
|
-
};
|
|
128
|
-
readonly fulfillment?: {
|
|
129
|
-
readonly destinations?: ReadonlyArray<{
|
|
130
|
-
readonly id: string;
|
|
131
|
-
readonly address: {
|
|
132
|
-
readonly street_address?: string;
|
|
133
|
-
readonly address_locality?: string;
|
|
134
|
-
readonly address_region?: string;
|
|
135
|
-
readonly postal_code?: string;
|
|
136
|
-
readonly address_country?: string;
|
|
137
|
-
};
|
|
138
|
-
}>;
|
|
139
|
-
readonly methods?: ReadonlyArray<{
|
|
140
|
-
readonly id: string;
|
|
141
|
-
readonly type: string;
|
|
142
|
-
readonly line_item_ids?: readonly string[];
|
|
143
|
-
readonly selected_destination_id?: string;
|
|
144
|
-
readonly groups?: ReadonlyArray<{
|
|
145
|
-
readonly id: string;
|
|
146
|
-
readonly selected_option_id?: string;
|
|
147
|
-
}>;
|
|
148
|
-
}>;
|
|
149
|
-
};
|
|
150
|
-
readonly payment?: {
|
|
151
|
-
readonly instruments?: ReadonlyArray<PaymentInstrument>;
|
|
152
|
-
};
|
|
153
|
-
readonly discounts?: {
|
|
154
|
-
readonly codes?: readonly string[];
|
|
155
|
-
};
|
|
156
|
-
readonly context?: LocalizationContext;
|
|
157
|
-
}
|
|
158
|
-
interface CompleteCheckoutPayload {
|
|
159
|
-
readonly payment?: {
|
|
160
|
-
readonly instruments: ReadonlyArray<PaymentInstrument>;
|
|
161
|
-
};
|
|
162
|
-
readonly payment_data?: PaymentInstrument;
|
|
163
|
-
readonly risk_signals?: Readonly<Record<string, unknown>>;
|
|
164
|
-
readonly ap2?: {
|
|
165
|
-
readonly checkout_mandate?: string;
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
//#endregion
|
|
170
|
-
//#region src/capabilities/checkout.d.ts
|
|
171
|
-
//# sourceMappingURL=checkout.d.ts.map
|
|
172
|
-
type FulfillmentPatch = Omit<UpdateCheckoutPayload, 'fulfillment' | 'discounts'>;
|
|
173
|
-
/**
|
|
174
|
-
* Checkout session operations. Available when the server declares `dev.ucp.shopping.checkout`.
|
|
175
|
-
* Check `extensions` to see which optional features (fulfillment, discount, etc.) are supported.
|
|
176
|
-
*/
|
|
177
|
-
declare class CheckoutCapability {
|
|
178
|
-
private readonly http;
|
|
179
|
-
/** Which checkout extensions the server supports. */
|
|
180
|
-
readonly extensions: CheckoutExtensions;
|
|
181
|
-
constructor(http: HttpClient, extensions: CheckoutExtensions);
|
|
182
|
-
create(payload: CreateCheckoutPayload): Promise<CheckoutSession>;
|
|
183
|
-
get(id: string): Promise<CheckoutSession>;
|
|
184
|
-
update(id: string, patch: UpdateCheckoutPayload): Promise<CheckoutSession>;
|
|
185
|
-
complete(id: string, payload: CompleteCheckoutPayload): Promise<CheckoutSession>;
|
|
186
|
-
cancel(id: string): Promise<CheckoutSession>;
|
|
187
|
-
setFulfillment(id: string, type: string, patch?: FulfillmentPatch): Promise<CheckoutSession>;
|
|
188
|
-
selectDestination(id: string, destinationId: string, fulfillmentType?: string, patch?: FulfillmentPatch): Promise<CheckoutSession>;
|
|
189
|
-
selectFulfillmentOption(id: string, optionId: string, destinationId?: string, fulfillmentType?: string, patch?: FulfillmentPatch): Promise<CheckoutSession>;
|
|
190
|
-
applyDiscountCodes(id: string, codes: readonly string[], patch?: FulfillmentPatch): Promise<CheckoutSession>;
|
|
191
|
-
private validateSession;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
//#endregion
|
|
195
|
-
//#region src/types/order.d.ts
|
|
196
|
-
type UCPSpecOrder = Order;
|
|
197
|
-
interface WebhookEvent {
|
|
198
|
-
readonly event_id: string;
|
|
199
|
-
readonly created_time: string;
|
|
200
|
-
readonly order: UCPSpecOrder;
|
|
201
|
-
readonly [key: string]: unknown;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
//#endregion
|
|
205
|
-
//#region src/capabilities/order.d.ts
|
|
206
|
-
//# sourceMappingURL=order.d.ts.map
|
|
207
|
-
/** Order operations. Available when the server declares `dev.ucp.shopping.order`. */
|
|
208
|
-
declare class OrderCapability {
|
|
209
|
-
private readonly http;
|
|
210
|
-
constructor(http: HttpClient);
|
|
211
|
-
/** Retrieve an order by ID. Returns the UCP spec-compliant Order object. */
|
|
212
|
-
get(id: string): Promise<UCPSpecOrder>;
|
|
213
|
-
/** Update an order with fulfillment events, adjustments, or status changes. */
|
|
214
|
-
update(id: string, payload: Record<string, unknown>): Promise<UCPSpecOrder>;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
//#endregion
|
|
218
|
-
//#region src/types/identity-linking.d.ts
|
|
219
|
-
//# sourceMappingURL=order.d.ts.map
|
|
220
|
-
interface OAuthServerMetadata {
|
|
221
|
-
readonly issuer: string;
|
|
222
|
-
readonly authorization_endpoint: string;
|
|
223
|
-
readonly token_endpoint: string;
|
|
224
|
-
readonly revocation_endpoint: string;
|
|
225
|
-
readonly scopes_supported: readonly string[];
|
|
226
|
-
readonly response_types_supported: readonly string[];
|
|
227
|
-
readonly grant_types_supported: readonly string[];
|
|
228
|
-
readonly token_endpoint_auth_methods_supported: readonly string[];
|
|
229
|
-
readonly service_documentation?: string;
|
|
230
|
-
}
|
|
231
|
-
interface AuthorizationParams {
|
|
232
|
-
readonly client_id: string;
|
|
233
|
-
readonly redirect_uri: string;
|
|
234
|
-
readonly scope?: string;
|
|
235
|
-
readonly state?: string;
|
|
236
|
-
}
|
|
237
|
-
interface TokenResponse {
|
|
238
|
-
readonly access_token: string;
|
|
239
|
-
readonly token_type: string;
|
|
240
|
-
readonly expires_in?: number;
|
|
241
|
-
readonly refresh_token?: string;
|
|
242
|
-
readonly scope?: string;
|
|
243
|
-
}
|
|
244
|
-
interface TokenExchangeParams {
|
|
245
|
-
readonly client_id: string;
|
|
246
|
-
readonly client_secret: string;
|
|
247
|
-
readonly code: string;
|
|
248
|
-
readonly redirect_uri: string;
|
|
249
|
-
}
|
|
250
|
-
interface TokenRefreshParams {
|
|
251
|
-
readonly client_id: string;
|
|
252
|
-
readonly client_secret: string;
|
|
253
|
-
readonly refresh_token: string;
|
|
254
|
-
}
|
|
255
|
-
interface TokenRevokeParams {
|
|
256
|
-
readonly client_id: string;
|
|
257
|
-
readonly client_secret: string;
|
|
258
|
-
readonly token: string;
|
|
259
|
-
readonly token_type_hint?: 'access_token' | 'refresh_token';
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
//#endregion
|
|
263
|
-
//#region src/capabilities/identity-linking.d.ts
|
|
264
|
-
//# sourceMappingURL=identity-linking.d.ts.map
|
|
265
|
-
/**
|
|
266
|
-
* OAuth 2.0 identity linking for account linking between platforms and merchants.
|
|
267
|
-
* Available when the server declares `dev.ucp.common.identity_linking`.
|
|
268
|
-
*/
|
|
269
|
-
declare class IdentityLinkingCapability {
|
|
270
|
-
private readonly metadata;
|
|
271
|
-
constructor(metadata: OAuthServerMetadata);
|
|
272
|
-
/** Build the OAuth authorization URL to redirect the buyer to. */
|
|
273
|
-
getAuthorizationUrl(params: AuthorizationParams): string;
|
|
274
|
-
exchangeCode(params: TokenExchangeParams): Promise<TokenResponse>;
|
|
275
|
-
refreshToken(params: TokenRefreshParams): Promise<TokenResponse>;
|
|
276
|
-
revokeToken(params: TokenRevokeParams): Promise<void>;
|
|
277
|
-
getMetadata(): Readonly<OAuthServerMetadata>;
|
|
278
|
-
private tokenRequest;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
//#endregion
|
|
282
|
-
//#region src/types/config.d.ts
|
|
283
|
-
//# sourceMappingURL=identity-linking.d.ts.map
|
|
284
|
-
interface UCPClientConfig {
|
|
285
|
-
readonly gatewayUrl: string;
|
|
286
|
-
readonly agentProfileUrl: string;
|
|
287
|
-
readonly ucpVersion?: string;
|
|
288
|
-
readonly requestSignature?: string;
|
|
289
|
-
}
|
|
290
|
-
declare const DEFAULT_UCP_VERSION = "2026-01-23";
|
|
291
|
-
declare const UCP_CAPABILITIES: {
|
|
292
|
-
readonly CHECKOUT: "dev.ucp.shopping.checkout";
|
|
293
|
-
readonly FULFILLMENT: "dev.ucp.shopping.fulfillment";
|
|
294
|
-
readonly DISCOUNT: "dev.ucp.shopping.discount";
|
|
295
|
-
readonly BUYER_CONSENT: "dev.ucp.shopping.buyer_consent";
|
|
296
|
-
readonly ORDER: "dev.ucp.shopping.order";
|
|
297
|
-
readonly IDENTITY_LINKING: "dev.ucp.common.identity_linking";
|
|
298
|
-
readonly AP2_MANDATE: "dev.ucp.shopping.ap2_mandate";
|
|
299
|
-
};
|
|
300
|
-
|
|
301
|
-
//#endregion
|
|
302
|
-
//#region src/UCPClient.d.ts
|
|
303
|
-
//# sourceMappingURL=config.d.ts.map
|
|
304
|
-
/** UCP discovery profile returned by `GET /.well-known/ucp`. */
|
|
305
|
-
type UCPProfile = UcpDiscoveryProfile;
|
|
306
|
-
/** Describes a single tool the agent can use with the connected server. */
|
|
307
|
-
interface ToolDescriptor {
|
|
308
|
-
readonly name: string;
|
|
309
|
-
readonly capability: string;
|
|
310
|
-
readonly description: string;
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* A connected UCP client. Only capabilities the server declared are non-null.
|
|
314
|
-
* Use `describeTools()` to get the list of available tools for agent registration.
|
|
315
|
-
*/
|
|
316
|
-
interface ConnectedClient {
|
|
317
|
-
/** The server's UCP discovery profile. */
|
|
318
|
-
readonly profile: UCPProfile;
|
|
319
|
-
/** JWK signing keys from the discovery profile. Used for verifying incoming webhook signatures. */
|
|
320
|
-
readonly signingKeys: readonly JWK[];
|
|
321
|
-
/** Checkout operations. Null if server does not support `dev.ucp.shopping.checkout`. */
|
|
322
|
-
readonly checkout: CheckoutCapability | null;
|
|
323
|
-
/** Order operations. Null if server does not support `dev.ucp.shopping.order`. */
|
|
324
|
-
readonly order: OrderCapability | null;
|
|
325
|
-
/** OAuth 2.0 identity linking. Null if server does not support `dev.ucp.common.identity_linking`. */
|
|
326
|
-
readonly identityLinking: IdentityLinkingCapability | null;
|
|
327
|
-
/** Payment handlers declared by the server, keyed by namespace. */
|
|
328
|
-
readonly paymentHandlers: PaymentHandlerMap;
|
|
329
|
-
/** Returns only the tools this server supports (name + description only). */
|
|
330
|
-
describeTools(): readonly ToolDescriptor[];
|
|
331
|
-
/**
|
|
332
|
-
* Returns complete tool definitions with JSON Schema parameters and execute functions.
|
|
333
|
-
* Ready for direct use with any AI agent framework (Claude API, OpenAI, Vercel AI SDK, LangChain, MCP).
|
|
334
|
-
*/
|
|
335
|
-
getAgentTools(): readonly AgentTool[];
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Connect to a UCP server, discover its capabilities, and return a {@link ConnectedClient}.
|
|
339
|
-
*
|
|
340
|
-
* @example
|
|
341
|
-
* ```typescript
|
|
342
|
-
* const client = await connect({
|
|
343
|
-
* gatewayUrl: 'https://store.example.com/ucp',
|
|
344
|
-
* agentProfileUrl: 'https://platform.example.com/.well-known/ucp',
|
|
345
|
-
* });
|
|
346
|
-
*
|
|
347
|
-
* if (client.checkout) {
|
|
348
|
-
* const session = await client.checkout.create({ line_items: [...] });
|
|
349
|
-
* }
|
|
350
|
-
* ```
|
|
351
|
-
*/
|
|
352
|
-
declare function connect(config: UCPClientConfig, options?: {
|
|
353
|
-
readonly onValidationWarning?: LogFn;
|
|
354
|
-
}): Promise<ConnectedClient>;
|
|
355
|
-
/**
|
|
356
|
-
* UCP client entry point. Use `UCPClient.connect()` to discover server capabilities
|
|
357
|
-
* and get a {@link ConnectedClient}.
|
|
358
|
-
*
|
|
359
|
-
* @example
|
|
360
|
-
* ```typescript
|
|
361
|
-
* const client = await UCPClient.connect({
|
|
362
|
-
* gatewayUrl: 'https://store.example.com/ucp',
|
|
363
|
-
* agentProfileUrl: 'https://platform.example.com/.well-known/ucp',
|
|
364
|
-
* });
|
|
365
|
-
* ```
|
|
366
|
-
*/
|
|
367
|
-
declare class UCPClient {
|
|
368
|
-
private constructor();
|
|
369
|
-
static connect: typeof connect;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
//#endregion
|
|
373
|
-
//#region src/agent-tools.d.ts
|
|
374
|
-
//# sourceMappingURL=UCPClient.d.ts.map
|
|
375
|
-
/** JSON Schema type subset used for tool parameter definitions. */
|
|
376
|
-
interface JsonSchema {
|
|
377
|
-
readonly type: string;
|
|
378
|
-
readonly properties?: Readonly<Record<string, JsonSchema>>;
|
|
379
|
-
readonly required?: readonly string[];
|
|
380
|
-
readonly items?: JsonSchema;
|
|
381
|
-
readonly enum?: readonly string[];
|
|
382
|
-
readonly description?: string;
|
|
383
|
-
readonly default?: unknown;
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* A complete tool definition ready for any AI agent framework.
|
|
387
|
-
* Contains everything an LLM needs: name, description, parameter schema, and executor.
|
|
388
|
-
*/
|
|
389
|
-
interface AgentTool {
|
|
390
|
-
readonly name: string;
|
|
391
|
-
readonly description: string;
|
|
392
|
-
readonly parameters: JsonSchema;
|
|
393
|
-
readonly execute: (params: Record<string, unknown>) => Promise<unknown>;
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* Returns ready-to-use tool definitions for agent registration.
|
|
397
|
-
* Only tools supported by the connected server are included.
|
|
398
|
-
*
|
|
399
|
-
* Each tool has:
|
|
400
|
-
* - `name` — unique tool identifier
|
|
401
|
-
* - `description` — what the tool does (for the LLM)
|
|
402
|
-
* - `parameters` — JSON Schema describing the expected input
|
|
403
|
-
* - `execute(params)` — function that calls the right capability method
|
|
404
|
-
*
|
|
405
|
-
* @example
|
|
406
|
-
* ```typescript
|
|
407
|
-
* const client = await UCPClient.connect(config);
|
|
408
|
-
* const tools = getAgentTools(client);
|
|
409
|
-
*
|
|
410
|
-
* // Register with Anthropic Claude API
|
|
411
|
-
* const response = await anthropic.messages.create({
|
|
412
|
-
* tools: tools.map(t => ({
|
|
413
|
-
* name: t.name,
|
|
414
|
-
* description: t.description,
|
|
415
|
-
* input_schema: t.parameters,
|
|
416
|
-
* })),
|
|
417
|
-
* // ...
|
|
418
|
-
* });
|
|
419
|
-
*
|
|
420
|
-
* // Execute tool calls
|
|
421
|
-
* for (const block of response.content) {
|
|
422
|
-
* if (block.type === 'tool_use') {
|
|
423
|
-
* const tool = tools.find(t => t.name === block.name);
|
|
424
|
-
* const result = await tool.execute(block.input);
|
|
425
|
-
* }
|
|
426
|
-
* }
|
|
427
|
-
* ```
|
|
428
|
-
*/
|
|
429
|
-
declare function getAgentTools(client: ConnectedClient): readonly AgentTool[];
|
|
430
|
-
|
|
431
|
-
//#endregion
|
|
432
|
-
//#region src/adapters/catch-errors.d.ts
|
|
433
|
-
//# sourceMappingURL=agent-tools.d.ts.map
|
|
434
|
-
interface AdapterOptions {
|
|
435
|
-
readonly catchErrors?: boolean;
|
|
436
|
-
}
|
|
437
|
-
type ToolErrorResult = {
|
|
438
|
-
readonly error: string;
|
|
439
|
-
} | {
|
|
440
|
-
readonly requires_escalation: true;
|
|
441
|
-
readonly continue_url: string;
|
|
442
|
-
};
|
|
443
|
-
|
|
444
|
-
//#endregion
|
|
445
|
-
export { AdapterOptions, AgentTool, AuthorizationParams, BuyerConsent, CardCredential$1 as CardCredential, CheckoutCapability, CheckoutExtensions, CheckoutSession, CheckoutSessionStatus, CompleteCheckoutPayload, ConnectedClient, CreateCheckoutPayload, DEFAULT_UCP_VERSION, IdentityLinkingCapability, JWK, JsonSchema, LocalizationContext, OAuthServerMetadata, OrderCapability, PaymentCredential, PaymentHandlerInstance, PaymentHandlerMap, PaymentInstrument, PostalAddress, TokenCredential$1 as TokenCredential, TokenExchangeParams, TokenRefreshParams, TokenResponse, TokenRevokeParams, ToolDescriptor, ToolErrorResult, UCPClient, UCPClientConfig, UCPProfile, UCPSpecOrder, UCP_CAPABILITIES, UpdateCheckoutPayload, WebhookEvent, connect, getAgentTools };
|
|
446
|
-
//# sourceMappingURL=catch-errors-BoytVKBJ.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"catch-errors-BoytVKBJ.d.cts","names":[],"sources":["../src/http.ts","../src/types/common.ts","../src/types/payment.ts","../src/types/checkout.ts","../src/capabilities/checkout.ts","../src/types/order.ts","../src/capabilities/order.ts","../src/types/identity-linking.ts","../src/capabilities/identity-linking.ts","../src/types/config.ts","../src/UCPClient.ts","../src/agent-tools.ts","../src/adapters/catch-errors.ts"],"sourcesContent":null,"mappings":";;;;KAMK,UAAA;KAEO,KAAA;UAEK,gBAAA;EAJZ,SAAA,UAAU,EAAA,MAAA;EAEH,SAAK,eAAA,EAAA,MAAA;EAEA,SAAA,UAAgB,EAAA,MAAA;EASpB,SAAA,gBAAU,CAAA,EAAA,MAAA;EAAA,SAAA,WAAA,CAAA,EAAA,MAAA;EAAA,SAQD,mBAAA,CAAA,EAXW,KAWX;;AAsBE,cA9BX,UAAA,CA8BW;EAAU,iBAAi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