@40rty/ams-sdk 0.5.2 → 0.5.4
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 +75 -40
- package/dist/types/ecommerce/src/attribute-buckets.d.ts +2 -2
- package/dist/types/ecommerce/src/base-attributes.d.ts +3 -3
- package/dist/types/ecommerce/src/commerce-schemas.d.ts +1 -1
- package/dist/types/sdk/src/analytics/index.d.ts +1 -1
- package/dist/types/sdk/src/analytics/scope-context.d.ts +4 -0
- package/dist/types/sdk/src/host/host-modules.d.ts +4 -0
- package/dist/types/sdk/src/session/turn-attributed-session.d.ts +4 -0
- package/dist/types/sdk/src/verticals/commerce/commerce-shapes.d.ts +3 -0
- package/dist/types/sdk/src/widgets/presence/core-presence/fact-shape.d.ts +1 -1
- package/dist/types/sdk/src/widgets/presence/core-presence/standing-signal-store.d.ts +1 -1
- package/dist/types/spacestation/src/catalog/catalog-schemas.d.ts +1 -1
- package/dist/types/spacestation/src/commerce/cart-add-signal.d.ts +10 -0
- package/dist/types/spacestation/src/contracts/retrieval/ecommerce/option-values.d.ts +1 -1
- package/dist/types/spacestation/src/layout/layout.d.ts +3 -3
- package/dist/types/spacestation/src/space/space-config.d.ts +1 -1
- package/dist/types/spacestation/src/space/workspace-catalog.d.ts +4 -4
- package/dist/types/spacestation/src/trace/trace-envelopes.d.ts +1 -1
- package/dist/types/spacestation/src/trace/trace-events.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -662,6 +662,7 @@ __export(src_exports3, {
|
|
|
662
662
|
useTurnAsk: () => useTurnAsk,
|
|
663
663
|
useTurnAskPlacement: () => useTurnAskPlacement,
|
|
664
664
|
useTurnAskReply: () => useTurnAskReply,
|
|
665
|
+
useTurnScope: () => useTurnScope,
|
|
665
666
|
useUndismissedFacts: () => useUndismissedFacts,
|
|
666
667
|
useVariantSelections: () => useVariantSelections,
|
|
667
668
|
useViewportWindow: () => useViewportWindow,
|
|
@@ -699,7 +700,8 @@ __export(analytics_exports2, {
|
|
|
699
700
|
surfaceEmits: () => surfaceEmits,
|
|
700
701
|
surfaceSuppressionReason: () => surfaceSuppressionReason,
|
|
701
702
|
useAnalyticsSink: () => useAnalyticsSink,
|
|
702
|
-
useOptionalAnalyticsSink: () => useOptionalAnalyticsSink
|
|
703
|
+
useOptionalAnalyticsSink: () => useOptionalAnalyticsSink,
|
|
704
|
+
useTurnScope: () => useTurnScope
|
|
703
705
|
});
|
|
704
706
|
|
|
705
707
|
// ../spacestation/src/analytics/index.ts
|
|
@@ -1392,6 +1394,9 @@ var AnalyticsSinkContext = createContext(null);
|
|
|
1392
1394
|
var AnalyticsSinkProvider = AnalyticsSinkContext.Provider;
|
|
1393
1395
|
var TurnScopeContext = createContext(null);
|
|
1394
1396
|
var TurnScopeProvider = TurnScopeContext.Provider;
|
|
1397
|
+
function useTurnScope() {
|
|
1398
|
+
return useContext(TurnScopeContext);
|
|
1399
|
+
}
|
|
1395
1400
|
function useTurnAttributed(sink) {
|
|
1396
1401
|
const turnId = useContext(TurnScopeContext);
|
|
1397
1402
|
return useMemo(() => sink === null || turnId === null ? sink : sink.forTurn(turnId), [sink, turnId]);
|
|
@@ -1432,27 +1437,9 @@ __export(session_exports, {
|
|
|
1432
1437
|
|
|
1433
1438
|
// src/session/FourtySessionContext.tsx
|
|
1434
1439
|
import { createContext as createContext2, useContext as useContext2, useSyncExternalStore } from "react";
|
|
1435
|
-
var FourtySessionContext = createContext2(null);
|
|
1436
|
-
function useFourtySession() {
|
|
1437
|
-
const ctx = useContext2(FourtySessionContext);
|
|
1438
|
-
if (!ctx) throw new Error("useFourtySession must be used within a <FourtyProvider>");
|
|
1439
|
-
return ctx;
|
|
1440
|
-
}
|
|
1441
|
-
function useOptionalFourtySession() {
|
|
1442
|
-
return useContext2(FourtySessionContext);
|
|
1443
|
-
}
|
|
1444
|
-
function useComposerDraft() {
|
|
1445
|
-
const { composerDraftStore, setComposerDraft } = useFourtySession();
|
|
1446
|
-
const value = useSyncExternalStore(
|
|
1447
|
-
composerDraftStore.subscribe,
|
|
1448
|
-
composerDraftStore.get,
|
|
1449
|
-
composerDraftStore.get
|
|
1450
|
-
);
|
|
1451
|
-
return [value, setComposerDraft];
|
|
1452
|
-
}
|
|
1453
1440
|
|
|
1454
|
-
// src/session/
|
|
1455
|
-
import {
|
|
1441
|
+
// src/session/turn-attributed-session.ts
|
|
1442
|
+
import { useMemo as useMemo2 } from "react";
|
|
1456
1443
|
|
|
1457
1444
|
// ../spacestation/src/index.ts
|
|
1458
1445
|
var src_exports = {};
|
|
@@ -2215,6 +2202,14 @@ var CartAddSignalPayloadSchema = z13.object({
|
|
|
2215
2202
|
quantity: z13.number().optional(),
|
|
2216
2203
|
selections: z13.record(z13.string()).optional(),
|
|
2217
2204
|
optimisticLine: z13.unknown().optional(),
|
|
2205
|
+
/**
|
|
2206
|
+
* The agent turn whose canvas element the add came from — stamped by the sdk
|
|
2207
|
+
* session hooks for a producer inside a turn (`turn-attributed-session.ts`),
|
|
2208
|
+
* absent for one outside any (the agent's own add, the header cart, WebMCP).
|
|
2209
|
+
* Carried for the same reason as `origin`: the handler that emits the outcome
|
|
2210
|
+
* sees only this payload.
|
|
2211
|
+
*/
|
|
2212
|
+
turnId: z13.string().min(1).optional(),
|
|
2218
2213
|
/**
|
|
2219
2214
|
* Whether a LANDED add announces itself by opening the cart drawer on the
|
|
2220
2215
|
* changed line. Absent means yes, which is every existing producer's
|
|
@@ -4701,7 +4696,46 @@ function stringifyForScoring(v) {
|
|
|
4701
4696
|
}
|
|
4702
4697
|
}
|
|
4703
4698
|
|
|
4699
|
+
// src/session/turn-attributed-session.ts
|
|
4700
|
+
var TURN_ATTRIBUTED_SIGNALS = /* @__PURE__ */ new Set([CART_ADD_SIGNAL]);
|
|
4701
|
+
function withTurn(signal, turnId) {
|
|
4702
|
+
if (!TURN_ATTRIBUTED_SIGNALS.has(signal.type) || "turnId" in signal.payload) return signal;
|
|
4703
|
+
return { ...signal, payload: { ...signal.payload, turnId } };
|
|
4704
|
+
}
|
|
4705
|
+
function useTurnAttributedSession(session) {
|
|
4706
|
+
const turnId = useTurnScope();
|
|
4707
|
+
return useMemo2(() => {
|
|
4708
|
+
if (session === null || turnId === null) return session;
|
|
4709
|
+
return {
|
|
4710
|
+
...session,
|
|
4711
|
+
dispatchSignal: (signal) => session.dispatchSignal(withTurn(signal, turnId)),
|
|
4712
|
+
dispatchSuggestionAction: (action) => session.dispatchSuggestionAction(withTurn(action, turnId))
|
|
4713
|
+
};
|
|
4714
|
+
}, [session, turnId]);
|
|
4715
|
+
}
|
|
4716
|
+
|
|
4717
|
+
// src/session/FourtySessionContext.tsx
|
|
4718
|
+
var FourtySessionContext = createContext2(null);
|
|
4719
|
+
function useFourtySession() {
|
|
4720
|
+
const ctx = useTurnAttributedSession(useContext2(FourtySessionContext));
|
|
4721
|
+
if (!ctx) throw new Error("useFourtySession must be used within a <FourtyProvider>");
|
|
4722
|
+
return ctx;
|
|
4723
|
+
}
|
|
4724
|
+
function useOptionalFourtySession() {
|
|
4725
|
+
return useTurnAttributedSession(useContext2(FourtySessionContext));
|
|
4726
|
+
}
|
|
4727
|
+
function useComposerDraft() {
|
|
4728
|
+
const { composerDraftStore, setComposerDraft } = useFourtySession();
|
|
4729
|
+
const value = useSyncExternalStore(
|
|
4730
|
+
composerDraftStore.subscribe,
|
|
4731
|
+
composerDraftStore.get,
|
|
4732
|
+
composerDraftStore.get
|
|
4733
|
+
);
|
|
4734
|
+
return [value, setComposerDraft];
|
|
4735
|
+
}
|
|
4736
|
+
|
|
4704
4737
|
// src/session/use-action.ts
|
|
4738
|
+
import { useCallback } from "react";
|
|
4705
4739
|
function useAction(label, action) {
|
|
4706
4740
|
const session = useOptionalFourtySession();
|
|
4707
4741
|
return useCallback(() => {
|
|
@@ -6887,7 +6921,7 @@ function useAgentPresenceFresh(flowId = PRESENCE_FLOW) {
|
|
|
6887
6921
|
}
|
|
6888
6922
|
|
|
6889
6923
|
// src/widgets/presence/use-layout-entity-ids.ts
|
|
6890
|
-
import { useMemo as
|
|
6924
|
+
import { useMemo as useMemo5 } from "react";
|
|
6891
6925
|
|
|
6892
6926
|
// src/catalog/CatalogContext.tsx
|
|
6893
6927
|
import { createContext as createContext8, useContext as useContext8 } from "react";
|
|
@@ -6917,7 +6951,7 @@ function collectLayoutGids(layout, catalog) {
|
|
|
6917
6951
|
function useLayoutEntityIds() {
|
|
6918
6952
|
const layout = useLayout();
|
|
6919
6953
|
const catalog = useComponentCatalog();
|
|
6920
|
-
return
|
|
6954
|
+
return useMemo5(() => [...collectLayoutGids(layout, catalog)], [layout, catalog]);
|
|
6921
6955
|
}
|
|
6922
6956
|
|
|
6923
6957
|
// src/widgets/presence/use-presence.ts
|
|
@@ -8874,7 +8908,7 @@ __export(presence_exports2, {
|
|
|
8874
8908
|
});
|
|
8875
8909
|
|
|
8876
8910
|
// src/widgets/presence/use-standing-signal.ts
|
|
8877
|
-
import { useMemo as
|
|
8911
|
+
import { useMemo as useMemo9 } from "react";
|
|
8878
8912
|
|
|
8879
8913
|
// src/widgets/presence/core-presence/standing-signal-store.ts
|
|
8880
8914
|
import { useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
@@ -8958,7 +8992,7 @@ function useConsumeStandingSignal(type) {
|
|
|
8958
8992
|
const session = useFourtySession();
|
|
8959
8993
|
const scope2 = session.sessionId === null ? void 0 : session.sessionId;
|
|
8960
8994
|
useRegisterSignalHandlers(
|
|
8961
|
-
|
|
8995
|
+
useMemo9(
|
|
8962
8996
|
() => ({
|
|
8963
8997
|
[type]: (payload) => {
|
|
8964
8998
|
const id = typeof payload.id === "string" && payload.id.length > 0 ? payload.id : type;
|
|
@@ -8969,7 +9003,7 @@ function useConsumeStandingSignal(type) {
|
|
|
8969
9003
|
)
|
|
8970
9004
|
);
|
|
8971
9005
|
const standing = useStandingOfType(type);
|
|
8972
|
-
return
|
|
9006
|
+
return useMemo9(() => {
|
|
8973
9007
|
if (standing === null) return null;
|
|
8974
9008
|
const id = standing.id;
|
|
8975
9009
|
return {
|
|
@@ -9443,7 +9477,7 @@ function usePostHydrationTransforms() {
|
|
|
9443
9477
|
}
|
|
9444
9478
|
|
|
9445
9479
|
// src/projection/transform.ts
|
|
9446
|
-
import { useMemo as
|
|
9480
|
+
import { useMemo as useMemo11 } from "react";
|
|
9447
9481
|
|
|
9448
9482
|
// src/projection/preferences.ts
|
|
9449
9483
|
import { useSyncExternalStore as useSyncExternalStore4 } from "react";
|
|
@@ -9571,7 +9605,7 @@ var projectionTransform = {
|
|
|
9571
9605
|
use: () => {
|
|
9572
9606
|
const preferences2 = useProjectionPreferences();
|
|
9573
9607
|
const facts = useFacts();
|
|
9574
|
-
return
|
|
9608
|
+
return useMemo11(() => {
|
|
9575
9609
|
if (Object.keys(preferences2).length === 0) return null;
|
|
9576
9610
|
return buildTransform(preferences2, facts);
|
|
9577
9611
|
}, [preferences2, facts]);
|
|
@@ -9833,14 +9867,14 @@ function useFormFactor() {
|
|
|
9833
9867
|
}
|
|
9834
9868
|
|
|
9835
9869
|
// src/utils/use-inline-completion.ts
|
|
9836
|
-
import { useCallback as useCallback15, useMemo as
|
|
9870
|
+
import { useCallback as useCallback15, useMemo as useMemo12, useState as useState8 } from "react";
|
|
9837
9871
|
function useInlineCompletion(opts) {
|
|
9838
9872
|
const { value, candidates } = opts;
|
|
9839
9873
|
const minChars = opts.minChars !== void 0 ? opts.minChars : 2;
|
|
9840
9874
|
const enabled = opts.enabled !== void 0 ? opts.enabled : true;
|
|
9841
9875
|
const [dismissedValue, setDismissedValue] = useState8(null);
|
|
9842
9876
|
const dismiss = useCallback15(() => setDismissedValue(value), [value]);
|
|
9843
|
-
return
|
|
9877
|
+
return useMemo12(() => {
|
|
9844
9878
|
if (!enabled || value.length < minChars || dismissedValue === value) {
|
|
9845
9879
|
return { completion: "", ghost: "", active: false, dismiss };
|
|
9846
9880
|
}
|
|
@@ -10717,14 +10751,14 @@ function isFunnelStep(value) {
|
|
|
10717
10751
|
}
|
|
10718
10752
|
|
|
10719
10753
|
// src/verticals/commerce/product/use-product-grid-filter.ts
|
|
10720
|
-
import { useCallback as useCallback17, useMemo as
|
|
10754
|
+
import { useCallback as useCallback17, useMemo as useMemo14, useState as useState11 } from "react";
|
|
10721
10755
|
function useProductGridFilter(chips) {
|
|
10722
|
-
const labelKey =
|
|
10756
|
+
const labelKey = useMemo14(() => chips.map((c) => c.label).join("|"), [chips]);
|
|
10723
10757
|
const first = chips[0];
|
|
10724
10758
|
const [activeLabel, setActiveLabel] = useState11(
|
|
10725
10759
|
first !== void 0 ? first.label : null
|
|
10726
10760
|
);
|
|
10727
|
-
const activeFromKey =
|
|
10761
|
+
const activeFromKey = useMemo14(() => {
|
|
10728
10762
|
void labelKey;
|
|
10729
10763
|
if (first === void 0) return null;
|
|
10730
10764
|
const found = chips.find((c) => c.label === activeLabel);
|
|
@@ -10737,7 +10771,7 @@ function useProductGridFilter(chips) {
|
|
|
10737
10771
|
}
|
|
10738
10772
|
|
|
10739
10773
|
// src/verticals/commerce/product/use-product-detail.ts
|
|
10740
|
-
import { useCallback as useCallback19, useMemo as
|
|
10774
|
+
import { useCallback as useCallback19, useMemo as useMemo15, useRef as useRef13, useState as useState14 } from "react";
|
|
10741
10775
|
|
|
10742
10776
|
// src/verticals/commerce/checkout/use-buy-now.ts
|
|
10743
10777
|
import { useCallback as useCallback18, useEffect as useEffect16, useState as useState12 } from "react";
|
|
@@ -11032,15 +11066,15 @@ function useProductDetail(product) {
|
|
|
11032
11066
|
}
|
|
11033
11067
|
const { selectedVariants, setSelectedVariants, markTouched } = useSelectedVariantsState(product, facts);
|
|
11034
11068
|
const desc = useExpandable(false);
|
|
11035
|
-
const variantGroups =
|
|
11069
|
+
const variantGroups = useMemo15(
|
|
11036
11070
|
() => deriveVariantGroups(product),
|
|
11037
11071
|
[product]
|
|
11038
11072
|
);
|
|
11039
|
-
const allSelected =
|
|
11073
|
+
const allSelected = useMemo15(
|
|
11040
11074
|
() => variantGroups.every((g) => selectedVariants[g.name] !== void 0),
|
|
11041
11075
|
[variantGroups, selectedVariants]
|
|
11042
11076
|
);
|
|
11043
|
-
const missingGroup =
|
|
11077
|
+
const missingGroup = useMemo15(
|
|
11044
11078
|
() => variantGroups.find((g) => selectedVariants[g.name] === void 0),
|
|
11045
11079
|
[variantGroups, selectedVariants]
|
|
11046
11080
|
);
|
|
@@ -11349,7 +11383,7 @@ function useCartView(cart, onCheckout) {
|
|
|
11349
11383
|
}
|
|
11350
11384
|
|
|
11351
11385
|
// src/verticals/commerce/cart/cart-action-failures.ts
|
|
11352
|
-
import { useMemo as
|
|
11386
|
+
import { useMemo as useMemo16, useSyncExternalStore as useSyncExternalStore11 } from "react";
|
|
11353
11387
|
var FAILURE_TTL_MS = 2 * 6e4;
|
|
11354
11388
|
var FAILURE_CAP = 5;
|
|
11355
11389
|
var failures = [];
|
|
@@ -11401,7 +11435,7 @@ function useCartActionFailures() {
|
|
|
11401
11435
|
function useCartActionFailuresFor(productIdsInCart) {
|
|
11402
11436
|
const all = useCartActionFailures();
|
|
11403
11437
|
const key = productIdsInCart.join("\0");
|
|
11404
|
-
return
|
|
11438
|
+
return useMemo16(() => {
|
|
11405
11439
|
const present = new Set(key.length === 0 ? [] : key.split("\0"));
|
|
11406
11440
|
return all.filter((f) => f.productId !== void 0 && !present.has(f.productId));
|
|
11407
11441
|
}, [all, key]);
|
|
@@ -12195,7 +12229,7 @@ function useContentActions() {
|
|
|
12195
12229
|
import { useEffect as useEffect19, useState as useState18 } from "react";
|
|
12196
12230
|
|
|
12197
12231
|
// package.json
|
|
12198
|
-
var version = "0.5.
|
|
12232
|
+
var version = "0.5.4";
|
|
12199
12233
|
|
|
12200
12234
|
// src/host/host-modules.ts
|
|
12201
12235
|
import * as react from "react";
|
|
@@ -12940,6 +12974,7 @@ export {
|
|
|
12940
12974
|
useTurnAsk,
|
|
12941
12975
|
useTurnAskPlacement,
|
|
12942
12976
|
useTurnAskReply,
|
|
12977
|
+
useTurnScope,
|
|
12943
12978
|
useUndismissedFacts,
|
|
12944
12979
|
useVariantSelections,
|
|
12945
12980
|
useViewportWindow,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Product-type buckets (ecommerce vertical, wire-level).
|
|
3
3
|
*
|
|
4
4
|
* Shopify catalogs expose `product.productType` as free-form merchant
|
|
5
|
-
* vocabulary —
|
|
5
|
+
* vocabulary — a single footwear brand can use ~60 distinct values (`Heels`,
|
|
6
6
|
* `Booties`, `Sneakers`, `Mules`, …). Scoping slot keys by raw
|
|
7
7
|
* productType would explode the registry and prevent a `Heels_Size`
|
|
8
8
|
* fact from helping a visitor browsing `Boots`.
|
|
@@ -48,7 +48,7 @@ export type ProductBucket = 'shoes' | 'bags' | 'apparel' | 'accessories' | 'jewe
|
|
|
48
48
|
* of this got that backwards: hardcoded here, shared by every ecommerce
|
|
49
49
|
* space regardless of what it sells. See `apps/api/src/lib/
|
|
50
50
|
* resolve-bucket-labels.ts` — a brand declares its own words in its own
|
|
51
|
-
* package (`
|
|
51
|
+
* package (its `bucket-labels.ts`), the SAME seam as
|
|
52
52
|
* `baseAttributes`. Absent here ⇒ the bare option name, the safe default —
|
|
53
53
|
* no vertical-wide word gets forced onto a space that never chose it.
|
|
54
54
|
*/
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* WHY CODE, NOT A DB ROW. An earlier version of this made the mistake of
|
|
15
15
|
* declaring nine slots as `ECOMMERCE_BASE_ATTRIBUTES`, shared by every
|
|
16
|
-
* ecommerce space regardless of what it sells —
|
|
16
|
+
* ecommerce space regardless of what it sells — a fashion brand's wedding
|
|
17
17
|
* vocabulary (`venue_surface: grass/sand/pavement/indoor`, `role: ...
|
|
18
18
|
* bridesmaid...`) leaked onto a grocery or electronics space just as readily.
|
|
19
19
|
* The fix isn't "put it in the database instead" — a brand's own attribute
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
* reviewed the same way as everything else it ships, not a DB write a
|
|
24
24
|
* migration or an admin form has to reach in and mutate). This module is the
|
|
25
25
|
* vertical's half of that seam — the KEY convention only; the actual values
|
|
26
|
-
* are each brand's own, declared in that brand's own package (e.g.
|
|
27
|
-
* `
|
|
26
|
+
* are each brand's own, declared in that brand's own package (e.g. its
|
|
27
|
+
* `base-attributes.ts`).
|
|
28
28
|
*/
|
|
29
29
|
import { type AttributeDef } from '../../spacestation/src/index';
|
|
30
30
|
/** Build the `config` blob a brand's `BrandDefinition` should carry to
|
|
@@ -328,7 +328,7 @@ export type ProductVideo = z.infer<typeof ProductVideoSchema>;
|
|
|
328
328
|
export declare function orderedVideoSources(video: ProductVideo): VideoSource[];
|
|
329
329
|
/**
|
|
330
330
|
* Sibling products grouped by a shared parent (typically color). Many
|
|
331
|
-
* Shopify merchants (
|
|
331
|
+
* Many Shopify merchants (fashion and footwear especially) model each color as
|
|
332
332
|
* a standalone product joined to its siblings via a tag / metafield
|
|
333
333
|
* convention — so the "color picker" the visitor sees on a PDP is really
|
|
334
334
|
* a navigator across sibling products, not an in-product variant axis.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { createAnalyticsScope } from './scope';
|
|
2
2
|
export type { AnalyticsScope, AnalyticsScopeConfig, AnalyticsScopeStats, AnalyticsSink, SinkGuard, } from './scope';
|
|
3
|
-
export { AnalyticsSinkProvider, TurnScopeProvider, useAnalyticsSink, useOptionalAnalyticsSink } from './scope-context';
|
|
3
|
+
export { AnalyticsSinkProvider, TurnScopeProvider, useAnalyticsSink, useOptionalAnalyticsSink, useTurnScope } from './scope-context';
|
|
4
4
|
export { SURFACE_DISPOSITION, surfaceEmits, surfaceSuppressionReason } from './surface';
|
|
5
5
|
export type { SurfaceDisposition } from './surface';
|
|
6
6
|
export { CONSENT_DISPOSITION, consentDisposition } from './consent';
|
|
@@ -3,6 +3,10 @@ import type { AnalyticsSink } from './scope';
|
|
|
3
3
|
export declare const AnalyticsSinkProvider: import("react").Provider<AnalyticsSink | null>;
|
|
4
4
|
/** Filled by `@fourty/react`'s `ElementWrapper`, once per canvas element. */
|
|
5
5
|
export declare const TurnScopeProvider: import("react").Provider<string | null>;
|
|
6
|
+
/** The agent turn whose canvas element this subtree renders, or `null` outside
|
|
7
|
+
* one. For a producer whose outcome is emitted elsewhere — a signal handled at
|
|
8
|
+
* the provider, out of this subtree — to carry the turn with it. */
|
|
9
|
+
export declare function useTurnScope(): string | null;
|
|
6
10
|
/**
|
|
7
11
|
* The sink for THIS mount. THROWS when no mount is upstream.
|
|
8
12
|
*
|
|
@@ -39,6 +39,7 @@ export declare const HOST_MODULES: {
|
|
|
39
39
|
TurnScopeProvider: react.Provider<string | null>;
|
|
40
40
|
useAnalyticsSink: typeof sdk.useAnalyticsSink;
|
|
41
41
|
useOptionalAnalyticsSink: typeof sdk.useOptionalAnalyticsSink;
|
|
42
|
+
useTurnScope: typeof sdk.useTurnScope;
|
|
42
43
|
SURFACE_DISPOSITION: Record<"spacefront" | "embed" | "replay" | "lab" | "static-canvas" | "packages-preview" | "console-preview" | "operator-preview", sdk.SurfaceDisposition>;
|
|
43
44
|
surfaceEmits: typeof sdk.surfaceEmits;
|
|
44
45
|
surfaceSuppressionReason: typeof sdk.surfaceSuppressionReason;
|
|
@@ -886,9 +887,11 @@ export declare const HOST_MODULES: {
|
|
|
886
887
|
quantity: zod.ZodOptional<zod.ZodNumber>;
|
|
887
888
|
selections: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodString>>;
|
|
888
889
|
optimisticLine: zod.ZodOptional<zod.ZodUnknown>;
|
|
890
|
+
turnId: zod.ZodOptional<zod.ZodString>;
|
|
889
891
|
acknowledgeInDrawer: zod.ZodOptional<zod.ZodBoolean>;
|
|
890
892
|
}, "strip", zod.ZodTypeAny, {
|
|
891
893
|
origin: "visitor" | "agent" | "webmcp";
|
|
894
|
+
turnId?: string | undefined;
|
|
892
895
|
productId?: string | undefined;
|
|
893
896
|
quantity?: number | undefined;
|
|
894
897
|
variantId?: string | undefined;
|
|
@@ -897,6 +900,7 @@ export declare const HOST_MODULES: {
|
|
|
897
900
|
acknowledgeInDrawer?: boolean | undefined;
|
|
898
901
|
}, {
|
|
899
902
|
origin: "visitor" | "agent" | "webmcp";
|
|
903
|
+
turnId?: string | undefined;
|
|
900
904
|
productId?: string | undefined;
|
|
901
905
|
quantity?: number | undefined;
|
|
902
906
|
variantId?: string | undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { FourtySessionContextValue } from './FourtySessionContext';
|
|
2
|
+
/** The session as a component inside a canvas element sees it: its outcome
|
|
3
|
+
* signals carry that element's turn. Outside a turn, the session unchanged. */
|
|
4
|
+
export declare function useTurnAttributedSession(session: FourtySessionContextValue | null): FourtySessionContextValue | null;
|
|
@@ -74,6 +74,9 @@ export interface CartAddOptions extends CartAddPaint {
|
|
|
74
74
|
* being deleted to make a count easier, so the count is made honest instead.
|
|
75
75
|
*/
|
|
76
76
|
attemptId: string;
|
|
77
|
+
/** The agent turn whose canvas element caused this write, when it came from
|
|
78
|
+
* one — joins `commerce.cart_line_added` to that turn (`client_events.turn_id`). */
|
|
79
|
+
turnId?: string;
|
|
77
80
|
}
|
|
78
81
|
/**
|
|
79
82
|
* What `useAddToCart` needs from its caller — deliberately NOT `CartAddOptions`.
|
|
@@ -49,7 +49,7 @@ export interface FactFigureParts {
|
|
|
49
49
|
* dropped — and whether what is left deserves a size stamp — is a BRAND's reading
|
|
50
50
|
* of its own vocabulary, not something shared infra gets to assert about every
|
|
51
51
|
* space that mounts a notch. It belongs in the registered form (see
|
|
52
|
-
*
|
|
52
|
+
* a footwear brand's figure form), which has the whole fact and its own
|
|
53
53
|
* opinion about shoes.
|
|
54
54
|
*/
|
|
55
55
|
export declare function factFigureParts(fact: PresenceFactRender): FactFigureParts | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export interface StandingSignal {
|
|
2
2
|
/** The signal TYPE — the routing key. A widget consumes the type it owns
|
|
3
|
-
* (`agent_ask`, `
|
|
3
|
+
* (`agent_ask`, `acme.wardrobe.keep-offer`, …). */
|
|
4
4
|
type: string;
|
|
5
5
|
/** Stable id — dedupe + animation key. A resolved id never re-raises. */
|
|
6
6
|
id: string;
|
|
@@ -23,7 +23,7 @@ export interface CatalogEntryStructural {
|
|
|
23
23
|
/** Example prop combinations for LLM context and previews. */
|
|
24
24
|
examples?: Record<string, unknown>[];
|
|
25
25
|
/** Source package id that contributed (and last won) this component — e.g.
|
|
26
|
-
* '@fourty/ui' (baseline) or '@
|
|
26
|
+
* '@fourty/ui' (baseline) or '@acme/spacefront' (brand). Stamped during
|
|
27
27
|
* catalog composition for provenance. Observability only — never affects
|
|
28
28
|
* generation; absent for entries composed before this field existed. */
|
|
29
29
|
source?: string;
|
|
@@ -55,6 +55,14 @@ export declare const CartAddSignalPayloadSchema: z.ZodObject<{
|
|
|
55
55
|
quantity: z.ZodOptional<z.ZodNumber>;
|
|
56
56
|
selections: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
57
57
|
optimisticLine: z.ZodOptional<z.ZodUnknown>;
|
|
58
|
+
/**
|
|
59
|
+
* The agent turn whose canvas element the add came from — stamped by the sdk
|
|
60
|
+
* session hooks for a producer inside a turn (`turn-attributed-session.ts`),
|
|
61
|
+
* absent for one outside any (the agent's own add, the header cart, WebMCP).
|
|
62
|
+
* Carried for the same reason as `origin`: the handler that emits the outcome
|
|
63
|
+
* sees only this payload.
|
|
64
|
+
*/
|
|
65
|
+
turnId: z.ZodOptional<z.ZodString>;
|
|
58
66
|
/**
|
|
59
67
|
* Whether a LANDED add announces itself by opening the cart drawer on the
|
|
60
68
|
* changed line. Absent means yes, which is every existing producer's
|
|
@@ -74,6 +82,7 @@ export declare const CartAddSignalPayloadSchema: z.ZodObject<{
|
|
|
74
82
|
acknowledgeInDrawer: z.ZodOptional<z.ZodBoolean>;
|
|
75
83
|
}, "strip", z.ZodTypeAny, {
|
|
76
84
|
origin: "visitor" | "agent" | "webmcp";
|
|
85
|
+
turnId?: string | undefined;
|
|
77
86
|
productId?: string | undefined;
|
|
78
87
|
quantity?: number | undefined;
|
|
79
88
|
variantId?: string | undefined;
|
|
@@ -82,6 +91,7 @@ export declare const CartAddSignalPayloadSchema: z.ZodObject<{
|
|
|
82
91
|
acknowledgeInDrawer?: boolean | undefined;
|
|
83
92
|
}, {
|
|
84
93
|
origin: "visitor" | "agent" | "webmcp";
|
|
94
|
+
turnId?: string | undefined;
|
|
85
95
|
productId?: string | undefined;
|
|
86
96
|
quantity?: number | undefined;
|
|
87
97
|
variantId?: string | undefined;
|
|
@@ -17,7 +17,7 @@ import type { ProductOptionAxis } from './client';
|
|
|
17
17
|
* Case-folding is REQUIRED, not a convenience. The agent and the client read
|
|
18
18
|
* option values from two different sources — the agent from the catalog
|
|
19
19
|
* connector's `optionAxes` (Title Case: `Tortoise`), the client from the
|
|
20
|
-
* storefront's own variant data (which several catalogs,
|
|
20
|
+
* storefront's own variant data (which several catalogs, a large footwear brand's included,
|
|
21
21
|
* store UPPERCASE as a display convention: `TORTOISE`). Comparing those with
|
|
22
22
|
* `===` finds nothing, and a resolver that REFUSES on no-match then reports a
|
|
23
23
|
* stocked item as unavailable — a false negative that is worse than the silent
|
|
@@ -28,7 +28,7 @@ export interface UIElement<T extends string = string, P = Record<string, unknown
|
|
|
28
28
|
export interface Spec {
|
|
29
29
|
/** Root element key */
|
|
30
30
|
root: string;
|
|
31
|
-
/** Package alias map — short keys to full package names (e.g. { k: "@generated/
|
|
31
|
+
/** Package alias map — short keys to full package names (e.g. { k: "@generated/acme" }) */
|
|
32
32
|
aliases?: Record<string, string>;
|
|
33
33
|
/** Flat map of elements by key */
|
|
34
34
|
elements: Record<string, UIElement>;
|
|
@@ -266,8 +266,8 @@ export type AgentOutput = z.infer<typeof AgentOutputSchema>;
|
|
|
266
266
|
* Resolve a potentially qualified component type.
|
|
267
267
|
*
|
|
268
268
|
* - "hero" (bare) → { packageName: "@fourty/ui", componentType: "hero" }
|
|
269
|
-
* - "@generated/
|
|
270
|
-
* - "g:hero" (alias) → looks up "g" in aliases → { packageName: "@generated/
|
|
269
|
+
* - "@generated/acme:hero" (full path) → { packageName: "@generated/acme", componentType: "hero" }
|
|
270
|
+
* - "g:hero" (alias) → looks up "g" in aliases → { packageName: "@generated/acme", componentType: "hero" }
|
|
271
271
|
*/
|
|
272
272
|
export declare function resolveType(type: string, aliases: Record<string, string> | undefined): {
|
|
273
273
|
packageName: string;
|
|
@@ -29,7 +29,7 @@ export interface SpaceConfig {
|
|
|
29
29
|
vertical?: string;
|
|
30
30
|
/** The catalog: a flat, ordered list of component sources (first = base, e.g.
|
|
31
31
|
* '@fourty/ui'); later sources override earlier. A self-contained brand
|
|
32
|
-
* (e.g. ['@
|
|
32
|
+
* (e.g. ['@acme/spacefront']) may omit the base. Empty = no catalog. */
|
|
33
33
|
componentSources?: string[];
|
|
34
34
|
/** Recipe slug to use for this space. Falls back to 'default' if omitted. */
|
|
35
35
|
recipeSlug?: string;
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
* Workspace-bundled catalog identities.
|
|
3
3
|
*
|
|
4
4
|
* A brand increasingly OWNS its own composition identity — exported from the
|
|
5
|
-
* brand package itself (e.g. `@
|
|
5
|
+
* brand package itself (e.g. `@acme/spacefront/brand` exports a
|
|
6
6
|
* `BrandDefinition`), consumed by the API composition root + the admin client.
|
|
7
7
|
* spacestation stays brand-agnostic: it declares the shared SHAPE
|
|
8
8
|
* (`BrandDefinition`) but names no brand that owns its own definition.
|
|
9
9
|
*
|
|
10
10
|
* The records below are the NOT-YET-MIGRATED set — only the base pack
|
|
11
|
-
* (`@fourty/ui`) still centralizes its ids here. Every workspace brand
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* (`@fourty/ui`) still centralizes its ids here. Every workspace brand
|
|
12
|
+
* migrated to a package-owned `BrandDefinition` (e.g.
|
|
13
|
+
* `@acme/spacefront/brand`), so none are
|
|
14
14
|
* listed here. New brands should follow them, not these records.
|
|
15
15
|
*
|
|
16
16
|
* (Per-tenant / DB-published brands register dynamically and are NOT listed
|
|
@@ -89,7 +89,7 @@ export interface AssemblyInputComponent {
|
|
|
89
89
|
/** True for layout primitives (page/stack/grid/section). */
|
|
90
90
|
alwaysInclude?: boolean;
|
|
91
91
|
/** Source package id that contributed this component — e.g. '@fourty/ui'
|
|
92
|
-
* (baseline) or '@
|
|
92
|
+
* (baseline) or '@acme/spacefront' (brand). Lets the inspector group the
|
|
93
93
|
* catalog by package. Observability only. */
|
|
94
94
|
source?: string;
|
|
95
95
|
/** Render provenance: the package id whose React component actually renders
|
|
@@ -273,7 +273,7 @@ export type TraceEvent = {
|
|
|
273
273
|
* the roll-up, and the AI SDK's `result.usage` is documented as "the
|
|
274
274
|
* token usage of the LAST step" — so the terminal call was counted
|
|
275
275
|
* twice here and a third time off the `done` event. Measured on
|
|
276
|
-
*
|
|
276
|
+
* prod 2026-09-03: a 95,887-token turn (48,169 + 47,718)
|
|
277
277
|
* persisted as 221,689, and `cache_read_tokens` — read only off the
|
|
278
278
|
* roll-up — showed 18% cache coverage where the real figure was 86%.
|
|
279
279
|
* Roll-up spans must therefore report `result.totalUsage`, not
|