@40rty/ams-sdk 0.5.17 → 0.5.18
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/dist/index.js +26 -2
- package/dist/types/ecommerce/src/commerce-schemas.d.ts +31 -0
- package/dist/types/sdk/src/host/host-modules.d.ts +2 -0
- package/dist/types/sdk/src/verticals/commerce/commerce-context.d.ts +14 -2
- package/dist/types/sdk/src/verticals/commerce/commerce-shapes.d.ts +23 -1
- package/dist/types/sdk/src/verticals/commerce/index.d.ts +2 -2
- package/dist/types/spacestation/src/contracts/tools/execution-context.d.ts +11 -0
- package/dist/types/spacestation/src/contracts/tools/index.d.ts +1 -1
- package/dist/types/spacestation/src/contracts/tools/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -591,6 +591,7 @@ __export(src_exports3, {
|
|
|
591
591
|
useAgentPresenceFrame: () => useAgentPresenceFrame,
|
|
592
592
|
useAgentPresenceFresh: () => useAgentPresenceFresh,
|
|
593
593
|
useAnalyticsSink: () => useAnalyticsSink,
|
|
594
|
+
useAskStore: () => useAskStore,
|
|
594
595
|
useBotCheckNotice: () => useBotCheckNotice,
|
|
595
596
|
useCanvasActions: () => useCanvasActions,
|
|
596
597
|
useCanvasArrangement: () => useCanvasArrangement,
|
|
@@ -713,6 +714,7 @@ __export(src_exports3, {
|
|
|
713
714
|
useShellRoot: () => useShellRoot,
|
|
714
715
|
useSpaceLocale: () => useSpaceLocale,
|
|
715
716
|
useStandingOfType: () => useStandingOfType,
|
|
717
|
+
useStoreCheckouts: () => useStoreCheckouts,
|
|
716
718
|
useStream: () => useStream,
|
|
717
719
|
useSuccessFlash: () => useSuccessFlash,
|
|
718
720
|
useSuggestionsWithDefaults: () => useSuggestionsWithDefaults,
|
|
@@ -10991,6 +10993,7 @@ __export(commerce_exports, {
|
|
|
10991
10993
|
takeQueuedDiscountCodes: () => takeQueuedDiscountCodes,
|
|
10992
10994
|
toggleCartDrawer: () => toggleCartDrawer,
|
|
10993
10995
|
useAddToCart: () => useAddToCart,
|
|
10996
|
+
useAskStore: () => useAskStore,
|
|
10994
10997
|
useCart: () => useCart,
|
|
10995
10998
|
useCartActionFailures: () => useCartActionFailures,
|
|
10996
10999
|
useCartActionFailuresFor: () => useCartActionFailuresFor,
|
|
@@ -11016,6 +11019,7 @@ __export(commerce_exports, {
|
|
|
11016
11019
|
useProducts: () => useProducts,
|
|
11017
11020
|
useQueuedDiscountCodes: () => useQueuedDiscountCodes,
|
|
11018
11021
|
useSafeCart: () => useSafeCart,
|
|
11022
|
+
useStoreCheckouts: () => useStoreCheckouts,
|
|
11019
11023
|
useToggleWishlist: () => useToggleWishlist,
|
|
11020
11024
|
useVariantSelections: () => useVariantSelections,
|
|
11021
11025
|
useWishlist: () => useWishlist,
|
|
@@ -11101,7 +11105,19 @@ var INERT_COMMERCE_RUNTIME = {
|
|
|
11101
11105
|
}, signOut: async () => {
|
|
11102
11106
|
}, available: false }),
|
|
11103
11107
|
// No store, no plans: a price line simply shows no installment offer.
|
|
11104
|
-
useInstallmentOffer: () => void 0
|
|
11108
|
+
useInstallmentOffer: () => void 0,
|
|
11109
|
+
// No commerce, no stores to check out at.
|
|
11110
|
+
useStoreCheckouts: () => ({
|
|
11111
|
+
available: false,
|
|
11112
|
+
create: () => Promise.reject(new Error("useStoreCheckouts needs a <CommerceProvider>")),
|
|
11113
|
+
pending: false
|
|
11114
|
+
}),
|
|
11115
|
+
// No commerce, no store to ask.
|
|
11116
|
+
useAskStore: () => ({
|
|
11117
|
+
available: false,
|
|
11118
|
+
ask: () => Promise.reject(new Error("useAskStore needs a <CommerceProvider>")),
|
|
11119
|
+
pending: false
|
|
11120
|
+
})
|
|
11105
11121
|
};
|
|
11106
11122
|
var FourtyCommerceRuntimeContext = createContext27(
|
|
11107
11123
|
INERT_COMMERCE_RUNTIME
|
|
@@ -11137,6 +11153,12 @@ function useCustomerAccount() {
|
|
|
11137
11153
|
function useInstallmentOffer(price) {
|
|
11138
11154
|
return useCommerceRuntime().useInstallmentOffer(price);
|
|
11139
11155
|
}
|
|
11156
|
+
function useStoreCheckouts() {
|
|
11157
|
+
return useCommerceRuntime().useStoreCheckouts();
|
|
11158
|
+
}
|
|
11159
|
+
function useAskStore() {
|
|
11160
|
+
return useCommerceRuntime().useAskStore();
|
|
11161
|
+
}
|
|
11140
11162
|
|
|
11141
11163
|
// src/verticals/commerce/checkout/external-navigation.ts
|
|
11142
11164
|
function navigateToExternalCommerceUrl(url) {
|
|
@@ -12861,7 +12883,7 @@ function useContentActions() {
|
|
|
12861
12883
|
import { useEffect as useEffect19, useState as useState19 } from "react";
|
|
12862
12884
|
|
|
12863
12885
|
// package.json
|
|
12864
|
-
var version = "0.5.
|
|
12886
|
+
var version = "0.5.18";
|
|
12865
12887
|
|
|
12866
12888
|
// src/host/host-modules.ts
|
|
12867
12889
|
import * as react from "react";
|
|
@@ -13535,6 +13557,7 @@ export {
|
|
|
13535
13557
|
useAgentPresenceFrame,
|
|
13536
13558
|
useAgentPresenceFresh,
|
|
13537
13559
|
useAnalyticsSink,
|
|
13560
|
+
useAskStore,
|
|
13538
13561
|
useBotCheckNotice,
|
|
13539
13562
|
useCanvasActions,
|
|
13540
13563
|
useCanvasArrangement,
|
|
@@ -13657,6 +13680,7 @@ export {
|
|
|
13657
13680
|
useShellRoot,
|
|
13658
13681
|
useSpaceLocale,
|
|
13659
13682
|
useStandingOfType,
|
|
13683
|
+
useStoreCheckouts,
|
|
13660
13684
|
useStream,
|
|
13661
13685
|
useSuccessFlash,
|
|
13662
13686
|
useSuggestionsWithDefaults,
|
|
@@ -1817,6 +1817,37 @@ export declare const CartSchema: z.ZodObject<{
|
|
|
1817
1817
|
storeCartUrl?: string | undefined;
|
|
1818
1818
|
}>;
|
|
1819
1819
|
export type Cart = z.infer<typeof CartSchema>;
|
|
1820
|
+
/**
|
|
1821
|
+
* One store's checkout for its share of a cart that spans several stores —
|
|
1822
|
+
* what `CommerceAdapter.createStoreCheckouts` answers, one entry per seller.
|
|
1823
|
+
*
|
|
1824
|
+
* A single-store cart exits through `Cart.checkoutUrl`; a marketplace cart
|
|
1825
|
+
* (lines from many sellers, as on the cross-merchant catalog) has no one place
|
|
1826
|
+
* to be paid, so each seller's lines get their own checkout. `ready` carries
|
|
1827
|
+
* the page where the visitor reviews and pays for that store's lines; `failed`
|
|
1828
|
+
* says why that store gave none, so a surface names it instead of dropping it.
|
|
1829
|
+
*/
|
|
1830
|
+
export type StoreCheckout = {
|
|
1831
|
+
status: 'ready';
|
|
1832
|
+
seller: string;
|
|
1833
|
+
lineIds: string[];
|
|
1834
|
+
checkoutUrl: string;
|
|
1835
|
+
} | {
|
|
1836
|
+
status: 'failed';
|
|
1837
|
+
seller: string;
|
|
1838
|
+
lineIds: string[];
|
|
1839
|
+
reason: string;
|
|
1840
|
+
};
|
|
1841
|
+
/**
|
|
1842
|
+
* A store's own answer to a visitor's question about one of its products —
|
|
1843
|
+
* what `CommerceAdapter.askStore` returns. It is the STORE's statement (its
|
|
1844
|
+
* policies, its listing), never a fact the platform checked, so a surface
|
|
1845
|
+
* credits it to `seller`.
|
|
1846
|
+
*/
|
|
1847
|
+
export interface StoreAnswer {
|
|
1848
|
+
seller: string;
|
|
1849
|
+
answer: string;
|
|
1850
|
+
}
|
|
1820
1851
|
/** The backend-accepted cart, or null when all we hold is an optimistic
|
|
1821
1852
|
* paint. The single predicate for "is there a cart id the backend knows?" —
|
|
1822
1853
|
* every cart mutation needs it before it can talk to the backend. */
|
|
@@ -381,6 +381,8 @@ export declare const HOST_MODULES: {
|
|
|
381
381
|
useProductReviews: typeof sdk.useProductReviews;
|
|
382
382
|
useCustomerAccount: typeof sdk.useCustomerAccount;
|
|
383
383
|
useInstallmentOffer: typeof sdk.useInstallmentOffer;
|
|
384
|
+
useStoreCheckouts: typeof sdk.useStoreCheckouts;
|
|
385
|
+
useAskStore: typeof sdk.useAskStore;
|
|
384
386
|
useCommerceRuntime: typeof sdk.useCommerceRuntime;
|
|
385
387
|
FourtyCommerceRuntimeProvider: react.Provider<sdk.FourtyCommerceRuntime>;
|
|
386
388
|
navigateToExternalCommerceUrl: typeof sdk.navigateToExternalCommerceUrl;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { InstallmentOffer, Money, Product } from '../../../../ecommerce/src/index';
|
|
2
|
-
export type { AddToCartApi, CartAddHints, CartAddOptions, CartApi, CustomerAccountApi, ProductReviewHighlight, ProductReviewItem, ProductReviewsResult, ProductsQuery, ToggleWishlistApi, WishlistApi, WishlistState, } from './commerce-shapes';
|
|
3
|
-
import type { AddToCartApi, CartAddHints, CartApi, CustomerAccountApi, ProductReviewsResult, ProductsQuery, ToggleWishlistApi, WishlistApi } from './commerce-shapes';
|
|
2
|
+
export type { AddToCartApi, CartAddHints, CartAddOptions, CartApi, CustomerAccountApi, StoreCheckoutsApi, AskStoreApi, ProductReviewHighlight, ProductReviewItem, ProductReviewsResult, ProductsQuery, ToggleWishlistApi, WishlistApi, WishlistState, } from './commerce-shapes';
|
|
3
|
+
import type { AddToCartApi, CartAddHints, CartApi, CustomerAccountApi, StoreCheckoutsApi, AskStoreApi, ProductReviewsResult, ProductsQuery, ToggleWishlistApi, WishlistApi } from './commerce-shapes';
|
|
4
4
|
/**
|
|
5
5
|
* FourtyCommerceRuntime — the commerce-hook surface the catalog
|
|
6
6
|
* consumes. Same dependency-inversion pattern as `FourtyRuntime`: these
|
|
@@ -31,6 +31,10 @@ export interface FourtyCommerceRuntime {
|
|
|
31
31
|
useCustomerAccount: () => CustomerAccountApi;
|
|
32
32
|
/** What `price` qualifies for under the store's pay-over-time plans. */
|
|
33
33
|
useInstallmentOffer: (price: Money) => InstallmentOffer | undefined;
|
|
34
|
+
/** One checkout per store, for a cart that spans several. */
|
|
35
|
+
useStoreCheckouts: () => StoreCheckoutsApi;
|
|
36
|
+
/** A question put to the store that sells a product. */
|
|
37
|
+
useAskStore: () => AskStoreApi;
|
|
34
38
|
}
|
|
35
39
|
/**
|
|
36
40
|
* Provider for the commerce-hook surface. Mounted by the SDK's
|
|
@@ -72,3 +76,11 @@ export declare function useCustomerAccount(): CustomerAccountApi;
|
|
|
72
76
|
* read), when `price` is outside every plan's band, and without a
|
|
73
77
|
* `<CommerceProvider>`. */
|
|
74
78
|
export declare function useInstallmentOffer(price: Money): InstallmentOffer | undefined;
|
|
79
|
+
/** A cart that spans several stores, checked out one store at a time. Not
|
|
80
|
+
* available (and `create` rejects) on a single-store backend or without a
|
|
81
|
+
* `<CommerceProvider>`. */
|
|
82
|
+
export declare function useStoreCheckouts(): StoreCheckoutsApi;
|
|
83
|
+
/** Put a question to the store that sells a product; the answer is that
|
|
84
|
+
* store's own statement. Not available (and `ask` rejects) where the space is
|
|
85
|
+
* the only store, or without a `<CommerceProvider>`. */
|
|
86
|
+
export declare function useAskStore(): AskStoreApi;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* this path directly from outside the SDK.
|
|
12
12
|
*/
|
|
13
13
|
import type { CartOrigin } from '../../../../spacestation/src/analytics/ecommerce/index';
|
|
14
|
-
import type { Cart, OptimisticCartLine, Product, ProductReviewItem, ProductReviewHighlight } from '../../../../ecommerce/src/index';
|
|
14
|
+
import type { Cart, OptimisticCartLine, Product, ProductReviewItem, ProductReviewHighlight, StoreAnswer, StoreCheckout } from '../../../../ecommerce/src/index';
|
|
15
15
|
/**
|
|
16
16
|
* One review / one intent-matched review. Both are `z.infer` of the review
|
|
17
17
|
* schemas in `@fourty/ecommerce` — the single source of truth for the shape,
|
|
@@ -188,3 +188,25 @@ export interface CustomerAccountApi {
|
|
|
188
188
|
* session yet, or a space addressed by id, as in a console preview. */
|
|
189
189
|
available: boolean;
|
|
190
190
|
}
|
|
191
|
+
/** Return shape of `useStoreCheckouts` — a cart that spans several stores,
|
|
192
|
+
* checked out one store at a time (`CommerceAdapter.createStoreCheckouts`). */
|
|
193
|
+
export interface StoreCheckoutsApi {
|
|
194
|
+
/** False where the backend's cart belongs to one store — that cart exits
|
|
195
|
+
* through `cart.checkoutUrl` (`useCartView().handleCheckout`) instead. */
|
|
196
|
+
available: boolean;
|
|
197
|
+
/** Make one checkout per store in the cart. Places no order; each `ready`
|
|
198
|
+
* entry's `checkoutUrl` is where the visitor pays for that store's lines. */
|
|
199
|
+
create: () => Promise<StoreCheckout[]>;
|
|
200
|
+
/** True while `create` is in flight. */
|
|
201
|
+
pending: boolean;
|
|
202
|
+
}
|
|
203
|
+
/** Return shape of `useAskStore` — a question put to the store that sells a
|
|
204
|
+
* product (`CommerceAdapter.askStore`). The answer is that store's own
|
|
205
|
+
* statement, so a surface credits it to `seller`. */
|
|
206
|
+
export interface AskStoreApi {
|
|
207
|
+
/** False where the space is the only store — there is no one else to ask. */
|
|
208
|
+
available: boolean;
|
|
209
|
+
ask: (productId: string, question: string) => Promise<StoreAnswer>;
|
|
210
|
+
/** True while `ask` is in flight. */
|
|
211
|
+
pending: boolean;
|
|
212
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import './chip-relevance';
|
|
2
|
-
export { useCart, useAddToCart, useWishlist, useToggleWishlist, useProducts, useCollectionByHandle, useProductReviews, useCustomerAccount, useInstallmentOffer, useCommerceRuntime, FourtyCommerceRuntimeProvider, } from './commerce-context';
|
|
3
|
-
export type { FourtyCommerceRuntime, CartApi, AddToCartApi, WishlistApi, ToggleWishlistApi, ProductsQuery, ProductReviewItem, ProductReviewHighlight, ProductReviewsResult, CustomerAccountApi, CartAddOptions, CartAddHints, WishlistState, } from './commerce-context';
|
|
2
|
+
export { useCart, useAddToCart, useWishlist, useToggleWishlist, useProducts, useCollectionByHandle, useProductReviews, useCustomerAccount, useInstallmentOffer, useStoreCheckouts, useAskStore, useCommerceRuntime, FourtyCommerceRuntimeProvider, } from './commerce-context';
|
|
3
|
+
export type { FourtyCommerceRuntime, CartApi, AddToCartApi, WishlistApi, ToggleWishlistApi, ProductsQuery, ProductReviewItem, ProductReviewHighlight, ProductReviewsResult, CustomerAccountApi, StoreCheckoutsApi, AskStoreApi, CartAddOptions, CartAddHints, WishlistState, } from './commerce-context';
|
|
4
4
|
export { navigateToExternalCommerceUrl } from './checkout/external-navigation';
|
|
5
5
|
export type { ExternalNavigationResult } from './checkout/external-navigation';
|
|
6
6
|
export { recordVariantSelection, getVariantSelection, useVariantSelections, } from './variant/variant-selection-store';
|
|
@@ -15,6 +15,13 @@ import type { VisitorLocation, EntityKind } from '../../types';
|
|
|
15
15
|
* agent run (e.g. preflight cache warmup, eval harnesses) — tools
|
|
16
16
|
* that need the channel must guard with `if (context.emit) ...`.
|
|
17
17
|
*/
|
|
18
|
+
/** A file the visitor attached to THIS turn, as the session's own storage
|
|
19
|
+
* returned it (never fetched from a visitor-supplied URL). */
|
|
20
|
+
export interface TurnAttachment {
|
|
21
|
+
id: string;
|
|
22
|
+
mimeType: string;
|
|
23
|
+
bytes: Uint8Array;
|
|
24
|
+
}
|
|
18
25
|
export interface ToolExecutionContext {
|
|
19
26
|
visitorId: string;
|
|
20
27
|
sessionId: string;
|
|
@@ -93,6 +100,10 @@ export interface ToolExecutionContext {
|
|
|
93
100
|
* an optimisation and stay correct without it.
|
|
94
101
|
*/
|
|
95
102
|
primeEntities?: (resolverKey: string, byRef: Record<string, unknown>) => void;
|
|
103
|
+
/** The files the visitor attached to this turn — the same ones the model
|
|
104
|
+
* sees as image/file parts — for a tool whose backend takes the file itself
|
|
105
|
+
* (search by photo). Absent when the turn carries none. */
|
|
106
|
+
attachments?: ReadonlyArray<TurnAttachment>;
|
|
96
107
|
/** Coarse IP-derived geolocation captured at session bind. Available
|
|
97
108
|
* to location-aware tools (storeLocator, nearest-pickup, regional
|
|
98
109
|
* policy). Absent when the route had no IP or geoip returned no
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* as shims; runtime-coupled tool types (`ResolvedToolSet`, `ToolManifest`,
|
|
7
7
|
* `ValidationResult`) stay in `@fourty/agent`.
|
|
8
8
|
*/
|
|
9
|
-
export type { McpToolDescriptor, ToolCategory, ToolTransport, FourtyToolDefDescriptor, FourtyToolDef, ToolExecutionContext, FourtyToolPackageManifest, FourtyToolPackageDescriptor, FourtyToolPackage, ToolPackageProvider, DefineToolOptions, } from './types';
|
|
9
|
+
export type { McpToolDescriptor, ToolCategory, ToolTransport, FourtyToolDefDescriptor, FourtyToolDef, ToolExecutionContext, TurnAttachment, FourtyToolPackageManifest, FourtyToolPackageDescriptor, FourtyToolPackage, ToolPackageProvider, DefineToolOptions, } from './types';
|
|
@@ -17,7 +17,7 @@ import type { ZodTypeAny } from 'zod';
|
|
|
17
17
|
import type { FourtyToolDef, FourtyToolDefDescriptor, ToolCategory } from './definitions';
|
|
18
18
|
import type { ToolExecutionContext } from './execution-context';
|
|
19
19
|
export type { McpToolDescriptor, ToolCategory, ToolTransport, FourtyToolDefDescriptor, FourtyToolDef } from './definitions';
|
|
20
|
-
export type { ToolExecutionContext } from './execution-context';
|
|
20
|
+
export type { ToolExecutionContext, TurnAttachment } from './execution-context';
|
|
21
21
|
/**
|
|
22
22
|
* Tool package manifest — metadata about who ships this tool collection.
|
|
23
23
|
* Mirrors FourtyPackageManifest.
|