@40rty/ams-sdk 0.3.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/index.js +6655 -5934
  2. package/dist/types/ecommerce/src/review-schemas.d.ts +32 -0
  3. package/dist/types/sdk/src/analytics/scope-context.d.ts +2 -2
  4. package/dist/types/sdk/src/canvas/active-chips.d.ts +8 -0
  5. package/dist/types/sdk/src/canvas/chip-relevance.d.ts +41 -0
  6. package/dist/types/sdk/src/canvas/index.d.ts +6 -1
  7. package/dist/types/sdk/src/canvas/item-motion/index.d.ts +1 -1
  8. package/dist/types/sdk/src/canvas/item-motion/profile.d.ts +0 -3
  9. package/dist/types/sdk/src/canvas/layout-entity-refs.d.ts +12 -0
  10. package/dist/types/sdk/src/canvas/runtime-hooks.d.ts +2 -0
  11. package/dist/types/sdk/src/canvas/runtime-types.d.ts +2 -0
  12. package/dist/types/sdk/src/canvas/use-canvas-actions.d.ts +14 -24
  13. package/dist/types/sdk/src/canvas/use-is-seed-home.d.ts +17 -0
  14. package/dist/types/sdk/src/canvas/use-safe-facts.d.ts +9 -0
  15. package/dist/types/sdk/src/catalog/define.d.ts +1 -1
  16. package/dist/types/sdk/src/catalog/index.d.ts +1 -1
  17. package/dist/types/sdk/src/catalog/interaction-contract.d.ts +3 -3
  18. package/dist/types/sdk/src/catalog/registration/types.d.ts +7 -0
  19. package/dist/types/sdk/src/catalog/render-inline.d.ts +0 -37
  20. package/dist/types/sdk/src/host/host-modules.d.ts +217 -121
  21. package/dist/types/sdk/src/host/types.d.ts +3 -1
  22. package/dist/types/sdk/src/index.d.ts +3 -5
  23. package/dist/types/sdk/src/preview/SpacefrontPreviewProvider.d.ts +65 -0
  24. package/dist/types/sdk/src/preview/index.d.ts +1 -0
  25. package/dist/types/sdk/src/projection/index.d.ts +1 -0
  26. package/dist/types/sdk/src/projection/transform.d.ts +12 -0
  27. package/dist/types/sdk/src/projection/use-projection.d.ts +24 -0
  28. package/dist/types/sdk/src/provider/agent-ask-signal.d.ts +4 -0
  29. package/dist/types/sdk/src/provider/index.d.ts +1 -1
  30. package/dist/types/sdk/src/session/FourtySessionContext.d.ts +1 -1
  31. package/dist/types/sdk/src/shell/composer-attachments/heic-convert.d.ts +6 -0
  32. package/dist/types/sdk/src/shell/composer-attachments/use-composer-attachments.d.ts +37 -0
  33. package/dist/types/sdk/src/shell/conversation/answer-text.d.ts +15 -0
  34. package/dist/types/sdk/src/shell/conversation/index.d.ts +4 -0
  35. package/dist/types/sdk/src/shell/conversation/turn-pages.d.ts +16 -0
  36. package/dist/types/sdk/src/shell/conversation/use-conversation-page.d.ts +65 -0
  37. package/dist/types/sdk/src/shell/conversation/use-conversation-presence.d.ts +31 -0
  38. package/dist/types/sdk/src/shell/index.d.ts +6 -0
  39. package/dist/types/sdk/src/shell/turn-ask-placement.d.ts +17 -0
  40. package/dist/types/sdk/src/shell/use-dock-state.d.ts +58 -0
  41. package/dist/types/sdk/src/shell/use-prompt-composer.d.ts +51 -0
  42. package/dist/types/sdk/src/shell/use-thread-rows.d.ts +3 -1
  43. package/dist/types/sdk/src/shell/use-turn-ask-reply.d.ts +5 -0
  44. package/dist/types/sdk/src/utils/core-utils/index.d.ts +0 -6
  45. package/dist/types/sdk/src/utils/index.d.ts +1 -1
  46. package/dist/types/sdk/src/{commerce/ecommerce → verticals/commerce/cart}/use-cart-drawer.d.ts +1 -1
  47. package/dist/types/sdk/src/{commerce/ecommerce → verticals/commerce/cart}/use-cart-line-row.d.ts +1 -1
  48. package/dist/types/sdk/src/verticals/commerce/cart/use-cart-view.d.ts +51 -0
  49. package/dist/types/sdk/src/verticals/commerce/cart/use-safe-cart.d.ts +16 -0
  50. package/dist/types/sdk/src/{commerce/ecommerce → verticals/commerce/checkout}/buy-now-exit.d.ts +1 -1
  51. package/dist/types/sdk/src/{commerce/ecommerce → verticals/commerce/checkout}/checkout-handoff-reasons.d.ts +2 -2
  52. package/dist/types/sdk/src/{commerce/ecommerce → verticals/commerce/checkout}/checkout-handoff-shape.d.ts +1 -1
  53. package/dist/types/sdk/src/{commerce/ecommerce → verticals/commerce/checkout}/checkout-handoff-store.d.ts +3 -3
  54. package/dist/types/sdk/src/verticals/commerce/chip-relevance.d.ts +1 -0
  55. package/dist/types/sdk/src/{commerce → verticals/commerce}/commerce-context.d.ts +1 -1
  56. package/dist/types/sdk/src/{commerce → verticals/commerce}/commerce-shapes.d.ts +2 -2
  57. package/dist/types/sdk/src/{commerce/ecommerce → verticals/commerce/comparison}/comparison-rows.d.ts +1 -1
  58. package/dist/types/sdk/src/verticals/commerce/index.d.ts +35 -0
  59. package/dist/types/sdk/src/{commerce/ecommerce → verticals/commerce/product}/normalize-collection.d.ts +2 -2
  60. package/dist/types/sdk/src/{commerce/ecommerce → verticals/commerce/product}/product-filters.d.ts +1 -1
  61. package/dist/types/sdk/src/{commerce/ecommerce → verticals/commerce/product}/use-look-card.d.ts +4 -4
  62. package/dist/types/sdk/src/{commerce/ecommerce → verticals/commerce/product}/use-product-card.d.ts +2 -2
  63. package/dist/types/sdk/src/{commerce/ecommerce → verticals/commerce/product}/use-product-detail.d.ts +3 -3
  64. package/dist/types/sdk/src/verticals/commerce/use-commerce-actions.d.ts +18 -0
  65. package/dist/types/sdk/src/{commerce → verticals/commerce/variant}/pending-variant-choice-store.d.ts +2 -2
  66. package/dist/types/sdk/src/{commerce/ecommerce → verticals/commerce/variant}/preselect-from-facts.d.ts +1 -1
  67. package/dist/types/sdk/src/{commerce/ecommerce → verticals/commerce/variant}/use-selected-variants-state.d.ts +1 -1
  68. package/dist/types/sdk/src/{commerce/ecommerce → verticals/commerce/variant}/variant-option-axes.d.ts +1 -1
  69. package/dist/types/sdk/src/{commerce/ecommerce → verticals/commerce/variant}/variant-resolution.d.ts +1 -1
  70. package/dist/types/sdk/src/{commerce/ecommerce → verticals/commerce/variant}/variant-selection.d.ts +1 -1
  71. package/dist/types/sdk/src/verticals/content/index.d.ts +1 -0
  72. package/dist/types/sdk/src/verticals/content/use-content-actions.d.ts +12 -0
  73. package/dist/types/sdk/src/widgets/presence/index.d.ts +1 -0
  74. package/dist/types/sdk/src/widgets/presence/runtime-context.d.ts +1 -1
  75. package/dist/types/sdk/src/widgets/presence/use-forget-fact.d.ts +35 -0
  76. package/dist/types/spacestation/src/analytics/ecommerce/events.d.ts +1 -1
  77. package/dist/types/spacestation/src/catalog/shape-tokens.d.ts +2 -0
  78. package/dist/types/spacestation/src/catalog/wire/index.d.ts +1 -1
  79. package/dist/types/spacestation/src/catalog/wire/package-release.d.ts +24 -1
  80. package/dist/types/spacestation/src/index.d.ts +3 -1
  81. package/dist/types/spacestation/src/layout/conversation.d.ts +5 -0
  82. package/dist/types/spacestation/src/signal/turn-ask.d.ts +94 -0
  83. package/dist/types/spacestation/src/widgets/presence/profile.d.ts +2 -2
  84. package/package.json +2 -1
  85. package/dist/types/sdk/src/animation/index.d.ts +0 -2
  86. package/dist/types/sdk/src/animation/useListTransition.d.ts +0 -16
  87. package/dist/types/sdk/src/animation/useUpdateTransition.d.ts +0 -16
  88. package/dist/types/sdk/src/commerce/ecommerce/agentic-overlay.d.ts +0 -27
  89. package/dist/types/sdk/src/commerce/ecommerce/index.d.ts +0 -21
  90. package/dist/types/sdk/src/commerce/ecommerce/use-product-carousel-scroll.d.ts +0 -13
  91. package/dist/types/sdk/src/commerce/index.d.ts +0 -9
  92. package/dist/types/sdk/src/content/index.d.ts +0 -2
  93. package/dist/types/sdk/src/content/use-faq-accordion.d.ts +0 -11
  94. package/dist/types/sdk/src/content/use-newsletter-form.d.ts +0 -16
  95. package/dist/types/sdk/src/provider/AgentAsk.d.ts +0 -16
  96. package/dist/types/sdk/src/shared/index.d.ts +0 -2
  97. package/dist/types/sdk/src/social/index.d.ts +0 -2
  98. package/dist/types/sdk/src/social/use-review-helpful.d.ts +0 -10
  99. package/dist/types/sdk/src/social/use-testimonials-carousel.d.ts +0 -15
  100. package/dist/types/sdk/src/utils/core-utils/format-distance.d.ts +0 -6
  101. package/dist/types/sdk/src/utils/core-utils/maps-directions-url.d.ts +0 -5
  102. /package/dist/types/sdk/src/{commerce/ecommerce → verticals/commerce/cart}/cart-action-failures.d.ts +0 -0
  103. /package/dist/types/sdk/src/{commerce/ecommerce → verticals/commerce/cart}/cart-drawer-store.d.ts +0 -0
  104. /package/dist/types/sdk/src/{commerce → verticals/commerce/checkout}/external-navigation.d.ts +0 -0
  105. /package/dist/types/sdk/src/{commerce/ecommerce → verticals/commerce/checkout}/use-buy-now.d.ts +0 -0
  106. /package/dist/types/sdk/src/{commerce/ecommerce → verticals/commerce/comparison}/use-comparison-table.d.ts +0 -0
  107. /package/dist/types/sdk/src/{utils/core-utils → verticals/commerce/price}/format-price.d.ts +0 -0
  108. /package/dist/types/sdk/src/{utils/core-utils → verticals/commerce/price}/is-on-sale.d.ts +0 -0
  109. /package/dist/types/sdk/src/{commerce/ecommerce → verticals/commerce/product}/use-product-grid-filter.d.ts +0 -0
  110. /package/dist/types/sdk/src/{commerce → verticals/commerce/variant}/option-selection-store.d.ts +0 -0
  111. /package/dist/types/sdk/src/{utils/core-utils → verticals/commerce/variant}/resolve-swatch-color.d.ts +0 -0
  112. /package/dist/types/sdk/src/{commerce → verticals/commerce/variant}/variant-selection-store.d.ts +0 -0
  113. /package/dist/types/sdk/src/{commerce/ecommerce → verticals/commerce/wishlist}/use-wishlist-drawer.d.ts +0 -0
@@ -4,18 +4,16 @@ export * from './shell';
4
4
  export * from './provider';
5
5
  export * from './canvas';
6
6
  export * from './catalog';
7
- export * from './commerce';
8
7
  export * from './widgets/presence';
9
8
  export * from './chat';
10
9
  export * from './projection';
11
- export * from './content';
12
- export * from './social';
13
- export * from './shared';
14
- export * from './animation';
15
10
  export * from './rendering';
16
11
  export * from './interaction';
17
12
  export * from './voice';
18
13
  export * from './utils';
19
14
  export * from './client-state';
15
+ export * from './preview';
16
+ export * from './verticals/commerce';
17
+ export * from './verticals/content';
20
18
  export * from '../../spacestation/src/index';
21
19
  export * from '../../ecommerce/src/index';
@@ -0,0 +1,65 @@
1
+ import * as React from 'react';
2
+ /** One answered turn: what the visitor asked, the agent's prose (inline markdown). */
3
+ export interface PreviewTurn {
4
+ ask: string;
5
+ answer: string;
6
+ }
7
+ /**
8
+ * A frozen moment of a session, for rendering shell components without an
9
+ * engine: docs playgrounds, design reviews, visual tests. Every field is
10
+ * optional; an empty scene is a fresh session.
11
+ */
12
+ export interface PreviewScene {
13
+ turns?: PreviewTurn[];
14
+ /** A turn in flight: the agent is working (`isRunning`), with `answer` streamed so far. */
15
+ pending?: {
16
+ ask: string;
17
+ answer?: string;
18
+ } | null;
19
+ /** The session error line (`session.error`). */
20
+ error?: string | null;
21
+ /** Suggestion chip labels. */
22
+ suggestions?: string[];
23
+ /** Records the agent is reading while it works — presence thumbs and a count. */
24
+ scan?: {
25
+ images: string[];
26
+ total?: number;
27
+ query?: string;
28
+ } | null;
29
+ /** What the agent understood about the visitor — presence facts. */
30
+ facts?: {
31
+ label: string;
32
+ value: string;
33
+ }[];
34
+ /** The agent's one-line voice in the presence band. */
35
+ voice?: string;
36
+ /** A standing question (the `agent_ask` signal); `replies` empty = confirm only. */
37
+ question?: {
38
+ id: string;
39
+ text: string;
40
+ replies?: string[];
41
+ } | null;
42
+ }
43
+ export interface SpacefrontPreviewProviderProps {
44
+ scene: PreviewScene;
45
+ /** The visitor sent a message, tapped a chip or answered the question. */
46
+ onSend?: (text: string) => void;
47
+ children?: React.ReactNode;
48
+ }
49
+ /**
50
+ * Renders AMS shell components (`SpacefrontIsland`, `SpacefrontThreadPanel`,
51
+ * `SpacefrontPresence`, your own built on the sdk hooks) against a scripted
52
+ * session instead of an engine — no network, no space, no API key. It fills the
53
+ * same three seams `<Spacefront>` does (session, runtime, presence), so the
54
+ * components under it run unmodified.
55
+ *
56
+ * Controlled: pass the `scene` to show; `onSend` hears every visitor message,
57
+ * chip tap and question reply — answer it by passing the next scene.
58
+ *
59
+ * ```tsx
60
+ * <SpacefrontPreviewProvider scene={{ turns: [{ ask: 'A gift?', answer: 'Try **the beanie**.' }] }}>
61
+ * <SpacefrontIsland />
62
+ * </SpacefrontPreviewProvider>
63
+ * ```
64
+ */
65
+ export declare function SpacefrontPreviewProvider({ scene, onSend, children }: SpacefrontPreviewProviderProps): React.ReactElement;
@@ -0,0 +1 @@
1
+ export { SpacefrontPreviewProvider, type SpacefrontPreviewProviderProps, type PreviewScene, type PreviewTurn, } from './SpacefrontPreviewProvider';
@@ -1 +1,2 @@
1
1
  export { ProjectionSignalBridge } from './ProjectionSignalBridge';
2
+ export { useProjection, type ProjectionView } from './use-projection';
@@ -1,4 +1,16 @@
1
1
  import type { PostHydrationTransform } from '../rendering/post-hydration';
2
+ /** Value of the `__projection` reserved prop — the projection result for
3
+ * the component's primary projected entity. Written here; read back by
4
+ * `useProjection` (`./use-projection`). */
5
+ export interface ProjectionResult {
6
+ /** The un-projected entity — the component's "show all" target. */
7
+ full: unknown;
8
+ /** How many items the projection hid (0 ⇒ nothing to show). */
9
+ hiddenCount: number;
10
+ /** Axes the projection narrowed — the renderer shows these as a label
11
+ * and leaves natively single-value axes hidden. */
12
+ trimmedAxes: string[];
13
+ }
2
14
  /**
3
15
  * The projection transform. `use()` returns `null` when no standing
4
16
  * preferences exist — so the no-projection case costs nothing per render.
@@ -0,0 +1,24 @@
1
+ export interface ProjectionView {
2
+ /** True when a standing projection is hiding part of this entity. */
3
+ active: boolean;
4
+ /** True when the visitor toggled "show all" on this element. */
5
+ expanded: boolean;
6
+ /** How many items the projection hides. */
7
+ hiddenCount: number;
8
+ /** Axes the projection narrowed — render these as a label when
9
+ * collapsed; leave natively single-value axes hidden. */
10
+ trimmedAxes: string[];
11
+ /** The un-projected entity — render this instead of the trimmed prop
12
+ * when `expanded`. Typed `unknown`: the caller parses it with its own
13
+ * schema (the same one it already applies to the trimmed prop). */
14
+ fullEntity: unknown;
15
+ /** Flip trimmed ⇄ full for this element. */
16
+ toggle: () => void;
17
+ }
18
+ /**
19
+ * `useProjection(projectionProp, entity)` — projection state for a
20
+ * component's primary entity. Pass the component's `__projection` prop and
21
+ * its (trimmed) entity prop. Returns `active: false` when nothing is
22
+ * projected.
23
+ */
24
+ export declare function useProjection(projectionProp: unknown, entity: unknown): ProjectionView;
@@ -0,0 +1,4 @@
1
+ /** The platform's GENERIC deciding-question signal. There is nothing
2
+ * ask-special about it — a widget consumes this signal type like any other
3
+ * (the default one is `@fourty/ui`'s `<AgentAsk>`). */
4
+ export declare const AGENT_ASK_SIGNAL = "agent_ask";
@@ -1,4 +1,4 @@
1
1
  export { useRegisterSignalHandlers, HandlerRegistryContext, type SignalHandler, type HandlerRegistryValue, } from './providers/handler-registry';
2
- export { AgentAsk, AGENT_ASK_SIGNAL } from './AgentAsk';
2
+ export { AGENT_ASK_SIGNAL } from './agent-ask-signal';
3
3
  export { useClampToggle, type ClampToggle } from './use-clamp-toggle';
4
4
  export { useTimedFlag } from './use-timed-flag';
@@ -222,7 +222,7 @@ export declare function useOptionalFourtySession(): FourtySessionContextValue |
222
222
  * wants `isRunning`.
223
223
  *
224
224
  * Brands should not normally call this: wire a composer through
225
- * `usePromptComposer()` (`@fourty/ui/shell`), which handles draft, attachments,
225
+ * `usePromptComposer()` (`@fourty/sdk/shell`), which handles draft, attachments,
226
226
  * dictation and submit together. This is the primitive underneath it.
227
227
  */
228
228
  export declare function useComposerDraft(): [string, (text: string) => void];
@@ -0,0 +1,6 @@
1
+ /** True for an iPhone HEIC/HEIF file — by MIME, or by extension when the
2
+ * browser reports an empty type (which it does for HEIC). */
3
+ export declare function isHeic(file: File): boolean;
4
+ /** Decode a HEIC file to a JPEG `File` (renamed `.jpg`). Throws if libheif
5
+ * can't decode it — the caller falls back to the original. */
6
+ export declare function heicToJpeg(file: File): Promise<File>;
@@ -0,0 +1,37 @@
1
+ import { type AttachmentRef } from '../../../../spacestation/src/index';
2
+ export type AttachmentStatus = 'uploading' | 'ready' | 'error';
3
+ /** One composer attachment through its lifecycle: picked → uploading → ready /
4
+ * error. The composer renders these as thumbnails; only `ready` ones are sent. */
5
+ export interface ComposerAttachment {
6
+ localId: string;
7
+ name: string;
8
+ mimeType: string;
9
+ size: number;
10
+ /** Object URL for an image preview; null for non-image files. */
11
+ previewUrl: string | null;
12
+ status: AttachmentStatus;
13
+ /** Set once the upload resolves (`status === 'ready'`). */
14
+ ref: AttachmentRef | null;
15
+ /** Visitor-safe failure message (`status === 'error'`). */
16
+ error: string | null;
17
+ }
18
+ export interface ComposerAttachmentsApi {
19
+ attachments: ComposerAttachment[];
20
+ /** Validate + start uploading each file; rejects show as error thumbnails. */
21
+ addFiles: (files: FileList | File[]) => void;
22
+ remove: (localId: string) => void;
23
+ /** Drop everything (after send) and revoke object URLs. */
24
+ clear: () => void;
25
+ /** True while any upload is in flight — the composer blocks send. */
26
+ hasPending: boolean;
27
+ /** Refs for the successfully-uploaded files, in order. */
28
+ readyRefs: AttachmentRef[];
29
+ }
30
+ /** The accept attribute for a file input — derived from the shared allow-list. */
31
+ export declare const ATTACHMENT_ACCEPT: string;
32
+ /**
33
+ * Composer attachment state machine. Owns picking, client validation, the
34
+ * upload (via `session.uploadAttachment`), removal, and object-URL lifecycle.
35
+ * The composer stays presentational — it renders `attachments` and calls back.
36
+ */
37
+ export declare function useComposerAttachments(): ComposerAttachmentsApi;
@@ -0,0 +1,15 @@
1
+ /** A turn's prose as a page reads it: a headline, and the text that supports it. */
2
+ export interface AnswerText {
3
+ headline: string;
4
+ body: string;
5
+ }
6
+ /**
7
+ * Split a turn's prose into a headline and a body. The agent decides the
8
+ * split: prose that opens with a `# ` line makes that line the headline —
9
+ * as short or as long as the answer needs — and everything after it the
10
+ * body. Prose without one falls back to its first sentence.
11
+ *
12
+ * Streams safely: the first characters say which form it is, and until the
13
+ * headline line (or sentence) closes it is all headline.
14
+ */
15
+ export declare function splitAnswer(prose: string): AnswerText;
@@ -0,0 +1,4 @@
1
+ export { useConversationPage } from './use-conversation-page';
2
+ export type { ConversationPage, ConversationCrumb, ConversationPhase, ConversationPlace, ConversationTurn } from './use-conversation-page';
3
+ export type { ConversationActivity, ConversationFact, ConversationPresence } from './use-conversation-presence';
4
+ export { splitAnswer, type AnswerText } from './answer-text';
@@ -0,0 +1,16 @@
1
+ import type { Message, PendingMessage, Spec } from '../../../../spacestation/src/index';
2
+ /**
3
+ * The committed turns, up to `index`, that opened a PAGE. A turn opens one
4
+ * only when it lays down blocks of its own (every element a turn places
5
+ * carries that turn's id as `__turnId`); a turn that changed the page in
6
+ * place — a swap, an edit — belongs to the page it changed. The first turn
7
+ * always opens one.
8
+ */
9
+ export declare function pageTurns(messages: readonly Message[], index: number): Message[];
10
+ /**
11
+ * Has the live turn touched the page yet — placed its first block, or edited
12
+ * in place a block the previous turn left? Before that it is still thinking.
13
+ */
14
+ export declare function liveTurnTouched(layout: Spec, pending: PendingMessage, messages: readonly Message[]): boolean;
15
+ /** Does the page on screen carry blocks a turn composed? */
16
+ export declare function hasComposedPage(layout: Spec): boolean;
@@ -0,0 +1,65 @@
1
+ import type { TurnAsk } from '../../../../spacestation/src/index';
2
+ import { type ConversationPresence } from './use-conversation-presence';
3
+ /** Where the live turn is: not running, still thinking (the page is untouched), or composing the page. */
4
+ export type ConversationPhase = 'idle' | 'thinking' | 'composing';
5
+ /**
6
+ * Where the visitor is relative to the conversation:
7
+ * - `welcome`: no question yet (or back on the untouched welcome page with nothing live) — the page stands alone.
8
+ * - `turn`: on a turn's page — its question and answer head the page.
9
+ * - `away`: navigated off the turn's page (a product, Home) — the turn folds to a slim bar.
10
+ */
11
+ export type ConversationPlace = 'welcome' | 'turn' | 'away';
12
+ /** The turn the page is about: the one streaming, else the selected committed one. */
13
+ export interface ConversationTurn {
14
+ key: string;
15
+ index: number;
16
+ /** The visitor's own words. */
17
+ question: string;
18
+ /** The answer as a page reads it (`splitAnswer`). */
19
+ headline: string;
20
+ body: string;
21
+ /** The question the turn closed on — set apart from the prose when the brand draws it (`turnAsk: 'shell'`). */
22
+ ask: TurnAsk | undefined;
23
+ /** Only the newest settled turn's answers can be tapped — `reply` sends one. */
24
+ answerable: boolean;
25
+ live: boolean;
26
+ /** The turn produced no answer (`Message.error`). */
27
+ failed: boolean;
28
+ }
29
+ /**
30
+ * One step of the trail back through the conversation. `kind` says what it
31
+ * is — the brand words it (`home` → its own "Home"); a `turn` carries the
32
+ * visitor's words. `open` is `null` for the step the visitor is on.
33
+ */
34
+ export interface ConversationCrumb {
35
+ key: string;
36
+ kind: 'home' | 'turn' | 'here';
37
+ label: string;
38
+ open: (() => void) | null;
39
+ }
40
+ export interface ConversationPage {
41
+ place: ConversationPlace;
42
+ phase: ConversationPhase;
43
+ /** `null` exactly when `place` is `welcome`. */
44
+ turn: ConversationTurn | null;
45
+ crumbs: ConversationCrumb[];
46
+ /** The visitor went Home from a turn (`away`, on the welcome page). */
47
+ visitedHome: boolean;
48
+ /** The page on screen carries blocks a turn composed. */
49
+ hasPage: boolean;
50
+ /** The canvas holds the untouched welcome page under a conversation — hide it, the turn is the page. */
51
+ canvasHidden: boolean;
52
+ presence: ConversationPresence;
53
+ /** Send one of `turn.ask`'s answers as the visitor's reply. */
54
+ reply: (answer: string) => void;
55
+ goHome: () => void;
56
+ startOver: () => void;
57
+ }
58
+ /**
59
+ * The conversation as a PAGE — everything a shell needs to make each turn a
60
+ * page of its own (the concierge pattern): which turn is shown and where it
61
+ * is in its life, the trail back through every page, the closing question
62
+ * and how to answer it, and the agent's presence. One hook; no markup — the
63
+ * brand draws every pixel.
64
+ */
65
+ export declare function useConversationPage(): ConversationPage;
@@ -0,0 +1,31 @@
1
+ /** Something the agent has learned about the visitor this session. */
2
+ export interface ConversationFact {
3
+ label: string;
4
+ value: string;
5
+ }
6
+ /**
7
+ * What the agent is doing right now, most specific first: its own lead line
8
+ * (`voice`), its latest reasoning beat, what it is searching for, else just
9
+ * working. Data, not copy — the brand words each kind in its own voice.
10
+ */
11
+ export type ConversationActivity = {
12
+ kind: 'voice';
13
+ text: string;
14
+ } | {
15
+ kind: 'reasoning';
16
+ text: string;
17
+ } | {
18
+ kind: 'searching';
19
+ query: string;
20
+ } | {
21
+ kind: 'working';
22
+ };
23
+ export interface ConversationPresence {
24
+ running: boolean;
25
+ activity: ConversationActivity;
26
+ /** Everything learned this session, latest value per label, minus what the visitor cleared. */
27
+ facts: ConversationFact[];
28
+ /** Clear a fact: it leaves every surface at once and the agent is told. */
29
+ forgetFact: (fact: ConversationFact) => void;
30
+ }
31
+ export declare function useConversationPresence(): ConversationPresence;
@@ -2,11 +2,17 @@ export { ScrollContainerProvider, useScrollContainerRef, type ScrollContainerRef
2
2
  export { ShellRegistryProvider, useShellRegistry, type ShellComponentProps, type ShellComponent, type ShellRegistry, } from './ShellRegistry';
3
3
  export { ShellRootContext, useShellRoot } from './ShellRootContext';
4
4
  export { DockPersistenceProvider, useDockPersistence, type DockPersistence, } from './dock-persistence';
5
+ export { useDockState, type ShellDockState } from './use-dock-state';
5
6
  export { registerExclusiveOverlay, claimExclusiveOverlay, useExclusiveOverlay, } from './exclusive-overlay';
7
+ export { useComposerAttachments, ATTACHMENT_ACCEPT, type AttachmentStatus, type ComposerAttachmentsApi, type ComposerAttachment, } from './composer-attachments/use-composer-attachments';
8
+ export { usePromptComposer, type UsePromptComposerApi, type UsePromptComposerOptions, } from './use-prompt-composer';
6
9
  export { useComposerChipSelect } from './use-composer-chip-select';
10
+ export { useTurnAskReply } from './use-turn-ask-reply';
11
+ export { TurnAskPlacementProvider, useTurnAskPlacement, type TurnAskPlacement } from './turn-ask-placement';
7
12
  export { useGoHome } from './use-go-home';
8
13
  export { useHydrated } from './use-hydrated';
9
14
  export { useMenuItemSelect } from './use-menu-item-select';
10
15
  export { useOverridableToggle, type OverridableToggle } from './use-overridable-toggle';
11
16
  export { useThreadRows, type ThreadRow, type ThreadRows } from './use-thread-rows';
17
+ export * from './conversation';
12
18
  export { ThreadHeadroom, usePinTurnToTop, useScrollHasMoreBelow, useThreadJumpMarks, useThreadLanding, THREAD_ROW_ATTR, threadRowAttrs, type PinTurnToTopOptions, type ThreadJumpMark, } from './thread-scroll';
@@ -0,0 +1,17 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Who draws the question a turn closes on (`TurnAsk`).
4
+ *
5
+ * - `'prose'` (default): the engine writes the question, brackets removed, as
6
+ * the last line of the turn's prose. Every shell shows it with no code of its
7
+ * own, including one built against an SDK older than the field.
8
+ * - `'shell'`: the brand's shell draws it from `useTurnAsk()` /
9
+ * `ThreadRow.ask` (its bracketed answers tappable), and the prose carries
10
+ * none. A brand opts in by exporting `turnAsk: 'shell'` from its package.
11
+ */
12
+ export type TurnAskPlacement = 'prose' | 'shell';
13
+ export declare function TurnAskPlacementProvider({ placement, children }: {
14
+ placement: TurnAskPlacement;
15
+ children: React.ReactNode;
16
+ }): React.ReactElement;
17
+ export declare function useTurnAskPlacement(): TurnAskPlacement;
@@ -0,0 +1,58 @@
1
+ /** The side dock's live state, as a shell slot receives it. */
2
+ export interface ShellDockState {
3
+ open: boolean;
4
+ toggle: () => void;
5
+ }
6
+ /**
7
+ * When is the side dock open?
8
+ *
9
+ * Four inputs, and the whole difficulty is telling some of them apart:
10
+ *
11
+ * - the HOST's persisted answer (`useDockPersistence`) — the panel as the
12
+ * visitor left it, known on the very first render, server included;
13
+ * - ENGAGEMENT — has the visitor chatted or navigated (`useHasLeftSeedHome`);
14
+ * - a NEW user turn, which reopens the panel for shells that opt in;
15
+ * - whether an external agent is DRIVING the page (`useAgentDriven`).
16
+ *
17
+ * ── WHY AN AGENT TURN IS NOT ENGAGEMENT ────────────────────────────────────
18
+ *
19
+ * The last input is the newest and it exists because of a bug that shipped: a
20
+ * WebMCP client calling `send_message` writes a user message, which trips BOTH
21
+ * of the other two — it reads as the visitor having chatted, and as a brand new
22
+ * user turn. So the side dock opened on every agent call, sliding a chat panel
23
+ * over the canvas while `ComposerDock` was correctly folding its own composer to
24
+ * a bubble. Half the shell stood down and the other half threw itself open.
25
+ *
26
+ * There is nobody on this page to read that panel: the conversation is happening
27
+ * in the agent's client, and the dock is reserving a third of the viewport for
28
+ * it. So an agent-driven page keeps the panel shut — INCLUDING over a persisted
29
+ * "open", because a remembered preference is about the visitor's own browsing,
30
+ * not about a session someone else is driving.
31
+ *
32
+ * The visitor's own toggle still outranks all of it. That is the same contract
33
+ * the composer keeps: agent-driven folds the surface, and it stays folded until
34
+ * the human opens it THEMSELVES, after which nothing an agent does closes it.
35
+ *
36
+ * Engagement is derived from session state that does not exist during the
37
+ * server render and does not exist on the client's first render either: it
38
+ * arrives when the session restores, a few hundred milliseconds after paint.
39
+ * So a returning visitor's page painted dock-shut and then snapped it open,
40
+ * shoving the canvas — and it did that even to someone who had deliberately
41
+ * folded the panel, because replayed history is indistinguishable from live
42
+ * engagement if you only look at the current value.
43
+ *
44
+ * The session becoming known is the moment this load's own history has
45
+ * finished arriving, so it is the BASELINE: engagement already true at the
46
+ * baseline is history (accounted for by the persisted answer), and only what
47
+ * happens after it counts as the visitor engaging now.
48
+ *
49
+ * With NO persisted answer (`initialOpen: null` — a host that persists
50
+ * nothing, or a visitor we have never seen) there is nothing to account for
51
+ * and any engagement latches, exactly as it always did.
52
+ */
53
+ /**
54
+ * `autoOpen: false` — the dock never opens by itself (engagement, a new message):
55
+ * only the visitor's own toggle opens it. For a shell whose conversation already
56
+ * lives in the page, where the dock is an optional view of the thread.
57
+ */
58
+ export declare function useDockState(reopenOnMessage: boolean, autoOpen: boolean): ShellDockState;
@@ -0,0 +1,51 @@
1
+ import * as React from 'react';
2
+ import { type ComposerAttachmentsApi } from './composer-attachments/use-composer-attachments';
3
+ export interface UsePromptComposerOptions {
4
+ /**
5
+ * External attachments controller. Provide it to run in "controlled" mode —
6
+ * a brand shell that LIFTS `useComposerAttachments()` (e.g. the mobile shell
7
+ * sharing one state between a rest-island camera trigger and the composer)
8
+ * passes the shared controller here. Omit and the hook owns its own. The
9
+ * internal instance always runs (an idle controller when controlled —
10
+ * harmless) since hooks can't be conditional.
11
+ */
12
+ attachments?: ComposerAttachmentsApi;
13
+ }
14
+ export interface UsePromptComposerApi {
15
+ /** Current draft text. */
16
+ value: string;
17
+ /** Set the draft. Wire to the textarea `onChange` and any type-to-focus path. */
18
+ setValue: (next: string) => void;
19
+ /** Attachment state machine (controlled or internal — see options). */
20
+ attachments: ComposerAttachmentsApi;
21
+ /** Speech-to-text state for a `DictationButton`. */
22
+ dictation: {
23
+ listening: boolean;
24
+ supported: boolean;
25
+ toggle: () => void;
26
+ };
27
+ /** Clipboard handler — promotes pasted image/file bytes into attachments. */
28
+ onPaste: (e: React.ClipboardEvent<HTMLTextAreaElement>) => void;
29
+ /**
30
+ * Sendable when there's text OR a ready attachment, and no upload is still in
31
+ * flight (so a file never gets left out of the turn it was attached to).
32
+ */
33
+ canSend: boolean;
34
+ /** Send the turn (text + ready attachment refs), then clear draft + strip. */
35
+ submit: () => void;
36
+ }
37
+ /**
38
+ * `usePromptComposer` — the headless behavior shared by every prompt-input
39
+ * surface (the side-dock `Composer`, a hero-embedded entry box, a mobile voice
40
+ * island). Owns the cross-cutting wiring — draft state, attachment
41
+ * upload lifecycle, dictation that appends onto typed text, paste-to-attach,
42
+ * the send gate, and the send-then-clear — over the ONE `FourtySession`.
43
+ *
44
+ * It is presentation-free: a consumer renders its own chrome (textarea, send
45
+ * button, `AttachButton` / `DictationButton` / `AttachmentStrip`) and wires the
46
+ * returned handlers in. Surface-specific behavior (type-to-focus, a streaming
47
+ * stop/abort morph, autosize policy, agent-placeholder rotation) stays in the
48
+ * consumer — this hook is only the shared core, so the brand connects through
49
+ * ONE composition hook rather than re-deriving the upload + dictation plumbing.
50
+ */
51
+ export declare function usePromptComposer(options?: UsePromptComposerOptions): UsePromptComposerApi;
@@ -1,4 +1,4 @@
1
- import type { AttachmentRef } from '../../../spacestation/src/index';
1
+ import type { AttachmentRef, TurnAsk } from '../../../spacestation/src/index';
2
2
  /**
3
3
  * One rendered row of a conversation thread — a committed turn or the
4
4
  * live pending turn. A committed row and its earlier pending twin
@@ -16,6 +16,8 @@ export interface ThreadRow {
16
16
  isPending: boolean;
17
17
  /** Files the visitor attached to this turn — render on the user bubble. */
18
18
  attachments?: AttachmentRef[];
19
+ /** The question the turn closed on — render it after `prose` (`useTurnAskReply` answers it). */
20
+ ask?: TurnAsk;
19
21
  }
20
22
  export interface ThreadRows {
21
23
  rows: ThreadRow[];
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Returns a callback that sends one of a turn's `ask.answers` as the visitor's
3
+ * reply — the same message they would have typed.
4
+ */
5
+ export declare function useTurnAskReply(): (answer: string) => void;
@@ -1,10 +1,4 @@
1
- export { formatPrice } from './format-price';
2
- export { formatVariantValue } from '../../../../ecommerce/src/index';
3
- export { formatDistance } from './format-distance';
4
- export { isOnSale } from './is-on-sale';
5
1
  export { isVideoUrl } from './is-video-url';
6
- export { resolveSwatchColor } from './resolve-swatch-color';
7
- export { mapsDirectionsUrl } from './maps-directions-url';
8
2
  export { mintId } from './mint-id';
9
3
  export { injectGoogleFonts } from './inject-google-fonts';
10
4
  export { validateAll } from './validate-all';
@@ -7,4 +7,4 @@ export { useSuccessFlash, type UseSuccessFlashOptions, type UseSuccessFlashApi,
7
7
  export { useWakeLock } from './use-wake-lock';
8
8
  export { type StorageAdapter, createSessionStorageAdapter, createLocalStorageAdapter, createMemoryStorageAdapter, resolveStorage, } from './storage';
9
9
  export { applySinglePatch } from '../../../spacestation/src/index';
10
- export { formatPrice, formatVariantValue, formatDistance, isOnSale, isVideoUrl, resolveSwatchColor, mapsDirectionsUrl, mintId, injectGoogleFonts, validateAll, } from './core-utils';
10
+ export { isVideoUrl, mintId, injectGoogleFonts, validateAll, } from './core-utils';
@@ -1,4 +1,4 @@
1
- import type { Cart } from '../../../../ecommerce/src/index';
1
+ import type { Cart } from '../../../../../ecommerce/src/index';
2
2
  /**
3
3
  * The SECOND declared visitor checkout exit used to live here — `checkout()`,
4
4
  * calling `recordVisitorCheckoutExit` — and it had ZERO callers: every brand
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { type CartLine } from '../../../../ecommerce/src/index';
2
+ import { type CartLine } from '../../../../../ecommerce/src/index';
3
3
  export interface CartLineInteraction {
4
4
  onClick: () => void;
5
5
  onKeyDown: (event: React.KeyboardEvent<HTMLElement>) => void;
@@ -0,0 +1,51 @@
1
+ import { type Cart } from '../../../../../ecommerce/src/index';
2
+ /** Which exit CTA is mid-navigation. Both buttons disable while set. */
3
+ export type ExitPending = 'checkout' | 'store' | null;
4
+ /**
5
+ * useCartView — the cart drawer's LOGIC, extracted so any renderer (the base
6
+ * `CartContent`, a brand's own dumb cart markup) shares one implementation of the
7
+ * things that must never diverge: line/count/total derivation, discount-aware
8
+ * money, and the exit-navigation flows (checkout + official-store handoff, with
9
+ * their framed-vs-standalone behavior and the in-flight `exitPending` state).
10
+ *
11
+ * A brand package stays DUMB UI: it calls this hook and renders its own head /
12
+ * body / foot around the returned view-model — it never re-implements checkout,
13
+ * promo, or the money math. `onCheckout` is the host override (framed embeds);
14
+ * when absent the hook navigates `cart.checkoutUrl` itself.
15
+ */
16
+ export interface CartViewModel {
17
+ lines: Cart['lines'];
18
+ count: number;
19
+ /**
20
+ * The backend's pre-discount subtotal — never a client re-derivation.
21
+ *
22
+ * This used to sum the line totals, and that is what let three unsettled
23
+ * lines quietly drag a cart's subtotal below the rows the visitor was
24
+ * looking at: a pending line contributes no money, so the footer showed a
25
+ * confident figure for a cart that did not exist. The adapter already
26
+ * returns `cart.cost.subtotalAmount`; the number the visitor is asked to
27
+ * pay comes from whoever will charge it.
28
+ */
29
+ subtotal: number;
30
+ /**
31
+ * True while any line is still awaiting the backend. The money above
32
+ * describes the SETTLED cart only, so a surface showing totals must say they
33
+ * are still moving rather than present them as final.
34
+ */
35
+ totalsPending: boolean;
36
+ currency: string;
37
+ discountCodes: Cart['discountCodes'];
38
+ /** Backend post-discount total; undefined when the backend doesn't distinguish it. */
39
+ backendTotal: number | undefined;
40
+ /** Discount the applied code actually removed (backend truth), else 0. */
41
+ discountAmount: number;
42
+ /** The real total to charge — backendTotal when present, else subtotal. */
43
+ effectiveTotal: number;
44
+ /** Which exit CTA is mid-navigation; both disable while set. */
45
+ exitPending: ExitPending;
46
+ /** Online-store cart handoff URL — undefined hides the store CTA. */
47
+ storeCartUrl: string | undefined;
48
+ handleCheckout: () => void;
49
+ handleGoToStore: () => void;
50
+ }
51
+ export declare function useCartView(cart: Cart | null, onCheckout?: () => void | Promise<void>): CartViewModel;
@@ -0,0 +1,16 @@
1
+ import type { Cart } from '../../../../../ecommerce/src/index';
2
+ export interface SafeCart {
3
+ cart: Cart | null;
4
+ totalQuantity: number;
5
+ updateLine: (lineId: string, quantity: number) => Promise<unknown> | void;
6
+ removeLine: (lineId: string) => Promise<unknown> | void;
7
+ applyDiscountCode: (code: string) => Promise<unknown> | void;
8
+ removeDiscountCode: (code: string) => Promise<unknown> | void;
9
+ isDiscountPending: boolean;
10
+ }
11
+ /**
12
+ * useSafeCart — calls `useCart()` but degrades to `null` (with one warning)
13
+ * when no CommerceProvider is mounted, so a shell renders cleanly in storybook
14
+ * / preview contexts without a commerce client wired up.
15
+ */
16
+ export declare function useSafeCart(): SafeCart | null;
@@ -1,4 +1,4 @@
1
- import type { Cart } from '../../../../ecommerce/src/index';
1
+ import type { Cart } from '../../../../../ecommerce/src/index';
2
2
  /**
3
3
  * Whether a pending buy-now may leave for checkout yet.
4
4
  *
@@ -17,8 +17,8 @@
17
17
  * mutators take the machine DISCRIMINATOR and derive the sentence from it, and
18
18
  * a fourth `CheckoutRefusal` with no sentence is a compile error.
19
19
  */
20
- import type { CheckoutRefusal } from '../../../../spacestation/src/analytics/ecommerce/index';
21
- import type { ExternalNavigationResult } from '../external-navigation';
20
+ import type { CheckoutRefusal } from '../../../../../spacestation/src/analytics/ecommerce/index';
21
+ import type { ExternalNavigationResult } from './external-navigation';
22
22
  /** The sentence the agent narrates when the browser refused the tab. It says
23
23
  * what is TRUE (they never left) and points at the bag, without asserting
24
24
  * what is on screen: this outcome is only reachable in embedded contexts,