@40rty/ams-sdk 0.5.12 → 0.5.14

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.
@@ -13,3 +13,4 @@ export { buildBucketLabelsConfig, readBucketLabelsConfig } from './bucket-labels
13
13
  export { registerProductNameLookup, resolveProductNameLookup, clearProductNameLookups, type ProductNameLookup, type ProductNameLookupFactory, type ProductNameMatch, } from './product-lookup';
14
14
  export { registerCodeDiscountSource, resolveCodeDiscountSource, clearCodeDiscountSources, type CodeDiscountSource, type CodeDiscountSourceFactory, type CodeDiscountTerms, type StoreCodeDiscount, } from './code-discounts';
15
15
  export { registerStoreThemeSource, resolveStoreThemeSource, clearStoreThemeSources, StoreThemeAccessError, type StoreThemeSource, type StoreThemeSourceFactory, type StoreThemeFile, type StoreThemeFilesPage, type StoreThemeProduct, } from './store-theme';
16
+ export { installmentOffer, installmentPayment, type InstallmentTerm, type InstallmentPlan, type InstallmentPlans, type InstallmentQuote, type InstallmentOffer, } from './installment-offer';
@@ -0,0 +1,42 @@
1
+ import type { Money } from './commerce-schemas';
2
+ /**
3
+ * A store's pay-over-time plans, as its commerce platform publishes them: the
4
+ * price window financing covers, and per price band the terms on offer.
5
+ * `split` = pay in N interest-free; `zeroPercent` = a 0% loan; `interest` = a
6
+ * loan at `apr` percent. Read once per session by the commerce adapter.
7
+ */
8
+ export interface InstallmentTerm {
9
+ kind: 'split' | 'zeroPercent' | 'interest';
10
+ /** Annual percentage rate, in percent (15 = 15%). */
11
+ apr: number;
12
+ frequency: 'weekly' | 'monthly';
13
+ count: number;
14
+ }
15
+ export interface InstallmentPlan {
16
+ minPrice: Money;
17
+ maxPrice: Money;
18
+ terms: InstallmentTerm[];
19
+ }
20
+ export interface InstallmentPlans {
21
+ minPrice: Money;
22
+ maxPrice: Money;
23
+ plans: InstallmentPlan[];
24
+ }
25
+ /** One term priced for a given amount — `payment` is each installment, to the cent. */
26
+ export interface InstallmentQuote extends InstallmentTerm {
27
+ payment: number;
28
+ }
29
+ /** What a price qualifies for: every term priced, plus the two figures a
30
+ * price line shows — the longest interest-free split and the lowest monthly
31
+ * payment ("from $X/mo"). */
32
+ export interface InstallmentOffer {
33
+ plans: InstallmentQuote[];
34
+ split: InstallmentQuote | undefined;
35
+ lowestMonthly: InstallmentQuote | undefined;
36
+ }
37
+ /** Each installment of `term` on `amount`: an even split at 0%, else the
38
+ * fixed payment of a loan amortized at the term's APR. Rounded to the cent. */
39
+ export declare function installmentPayment(amount: number, term: InstallmentTerm): number;
40
+ /** The offer on `price`, or undefined when it is outside every plan's band
41
+ * (or priced in a currency the plans are not). */
42
+ export declare function installmentOffer(plans: InstallmentPlans, price: Money): InstallmentOffer | undefined;
@@ -0,0 +1,23 @@
1
+ import * as React from 'react';
2
+ export declare function CanvasLeadProvider({ types, children }: {
3
+ types: readonly string[];
4
+ children: React.ReactNode;
5
+ }): React.ReactElement;
6
+ /** Where the lead block renders. Mount it once, inside `CanvasLeadProvider`. */
7
+ export declare function CanvasLeadSlot({ className }: {
8
+ className?: string;
9
+ }): React.ReactElement;
10
+ /** For the brand shell: whether the page on canvas has a lead block in its slot. */
11
+ export declare function useCanvasLead(): {
12
+ present: boolean;
13
+ };
14
+ /**
15
+ * For the engine: the lead types and slot, and a way to say which block leads.
16
+ * Outside a `CanvasLeadProvider` there are no lead types — every block stays in
17
+ * the flow.
18
+ */
19
+ export declare function useCanvasLeadTarget(): {
20
+ types: readonly string[];
21
+ target: HTMLElement | null;
22
+ report: (id: string | null) => void;
23
+ };
@@ -7,6 +7,7 @@ export { GenerationStyleContext, GenerationStyleProvider, useGenerationStyle, }
7
7
  export { ShimmerSweep, type ShimmerSweepProps } from './ShimmerSweep';
8
8
  export { FadeTransition, TransitionProvider, useLayoutTransition, type LayoutTransitionItemProps, type LayoutTransitionGroupProps, type LayoutTransition, } from './TransitionContext';
9
9
  export { CanvasArrangementProvider, useCanvasArrangement, type CanvasArrangementValue } from './canvas-arrangement';
10
+ export { CanvasLeadProvider, CanvasLeadSlot, useCanvasLead, useCanvasLeadTarget } from './canvas-lead';
10
11
  export { CanvasMotionStyleProvider, useCanvasMotionStyle, type CanvasMotionStyle } from './canvas-motion-style';
11
12
  export { ElementIdContext, useElementId } from './ElementIdContext';
12
13
  export { buildEntranceProps, type EntranceMotionProps } from './generation-entrance';
@@ -119,9 +119,12 @@ export declare const HOST_MODULES: {
119
119
  useThreadLanding: typeof sdk.useThreadLanding;
120
120
  THREAD_ROW_ATTR: "data-fourty-thread-row";
121
121
  threadRowAttrs: typeof sdk.threadRowAttrs;
122
+ takeSubmitOrigin: typeof sdk.takeSubmitOrigin;
123
+ useWaitingSubmitOrigin: typeof sdk.useWaitingSubmitOrigin;
122
124
  useConversationPage: typeof sdk.useConversationPage;
123
125
  useConversationPresence: typeof sdk.useConversationPresence;
124
126
  splitAnswer: typeof sdk.splitAnswer;
127
+ withoutClosingQuestion: typeof sdk.withoutClosingQuestion;
125
128
  useRegisterSignalHandlers: typeof sdk.useRegisterSignalHandlers;
126
129
  HandlerRegistryContext: react.Context<sdk.HandlerRegistryValue | null>;
127
130
  AGENT_ASK_SIGNAL: "agent_ask";
@@ -175,6 +178,10 @@ export declare const HOST_MODULES: {
175
178
  useLayoutTransition: typeof sdk.useLayoutTransition;
176
179
  CanvasArrangementProvider: typeof sdk.CanvasArrangementProvider;
177
180
  useCanvasArrangement: typeof sdk.useCanvasArrangement;
181
+ CanvasLeadProvider: typeof sdk.CanvasLeadProvider;
182
+ CanvasLeadSlot: typeof sdk.CanvasLeadSlot;
183
+ useCanvasLead: typeof sdk.useCanvasLead;
184
+ useCanvasLeadTarget: typeof sdk.useCanvasLeadTarget;
178
185
  CanvasMotionStyleProvider: typeof sdk.CanvasMotionStyleProvider;
179
186
  useCanvasMotionStyle: typeof sdk.useCanvasMotionStyle;
180
187
  ElementIdContext: react.Context<string | null>;
@@ -374,6 +381,7 @@ export declare const HOST_MODULES: {
374
381
  useCollectionByHandle: typeof sdk.useCollectionByHandle;
375
382
  useProductReviews: typeof sdk.useProductReviews;
376
383
  useCustomerAccount: typeof sdk.useCustomerAccount;
384
+ useInstallmentOffer: typeof sdk.useInstallmentOffer;
377
385
  useCommerceRuntime: typeof sdk.useCommerceRuntime;
378
386
  FourtyCommerceRuntimeProvider: react.Provider<sdk.FourtyCommerceRuntime>;
379
387
  navigateToExternalCommerceUrl: typeof sdk.navigateToExternalCommerceUrl;
@@ -1155,6 +1163,8 @@ export declare const HOST_MODULES: {
1155
1163
  EXTEND_FLOW: "extend.status";
1156
1164
  DIRECTION_FLOW: "direction.standing";
1157
1165
  EPHEMERAL_FACT_FLOWS: readonly string[];
1166
+ CHIP_SHOW_SIGNAL: "chip.show";
1167
+ chipsFromShowSignal: typeof spacestation.chipsFromShowSignal;
1158
1168
  TURN_ASK_SIGNAL: "turn.ask";
1159
1169
  TurnAskSchema: zod.ZodUnion<[zod.ZodEffects<zod.ZodEffects<zod.ZodObject<{
1160
1170
  kind: zod.ZodEnum<["choice", "open"]>;
@@ -4768,6 +4778,8 @@ export declare const HOST_MODULES: {
4768
4778
  resolveStoreThemeSource: typeof ecommerce.resolveStoreThemeSource;
4769
4779
  clearStoreThemeSources: typeof ecommerce.clearStoreThemeSources;
4770
4780
  StoreThemeAccessError: typeof ecommerce.StoreThemeAccessError;
4781
+ installmentOffer: typeof ecommerce.installmentOffer;
4782
+ installmentPayment: typeof ecommerce.installmentPayment;
4771
4783
  orderedVideoSources(video: ecommerce.ProductVideo): ecommerce.VideoSource[];
4772
4784
  createUnavailableProduct(gid: string): ecommerce.Product;
4773
4785
  isGhostEntity(value: unknown): boolean;
@@ -13,3 +13,10 @@ export interface AnswerText {
13
13
  * headline line (or sentence) closes it is all headline.
14
14
  */
15
15
  export declare function splitAnswer(prose: string): AnswerText;
16
+ /**
17
+ * The body without a closing question — for a turn whose question is already
18
+ * its own line (`turn.ask`): the prose is told never to end on one, and when it
19
+ * does anyway the page would ask the same thing twice. Only a question that is
20
+ * the body's LAST sentence goes; one mid-body is part of the answer.
21
+ */
22
+ export declare function withoutClosingQuestion(body: string): string;
@@ -2,4 +2,4 @@ export { useConversationPage } from './use-conversation-page';
2
2
  export type { ConversationPage, ConversationCrumb, ConversationPhase, ConversationPlace, ConversationTurn } from './use-conversation-page';
3
3
  export { useConversationPresence } from './use-conversation-presence';
4
4
  export type { ConversationActivity, ConversationFact, ConversationPresence } from './use-conversation-presence';
5
- export { splitAnswer, type AnswerText } from './answer-text';
5
+ export { splitAnswer, withoutClosingQuestion, type AnswerText } from './answer-text';
@@ -17,3 +17,4 @@ export { useOverridableToggle, type OverridableToggle } from './use-overridable-
17
17
  export { useThreadRows, type ThreadRow, type ThreadRows } from './use-thread-rows';
18
18
  export * from './conversation';
19
19
  export { ThreadHeadroom, usePinTurnToTop, useScrollHasMoreBelow, useThreadJumpMarks, useThreadLanding, THREAD_ROW_ATTR, threadRowAttrs, type PinTurnToTopOptions, type ThreadJumpMark, } from './thread-scroll';
20
+ export { takeSubmitOrigin, useWaitingSubmitOrigin, type SubmitOrigin } from './submit-origin';
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Where the visitor's words WERE when they sent them — so the answer can take
3
+ * them from the composer into its own place instead of the sentence appearing
4
+ * twice, once in the box and once on the page (a shared-element move).
5
+ *
6
+ * The composer notes it at send (`usePromptComposer({ origin })`); the shell
7
+ * that shows the turn takes it once, for the question it is about to show.
8
+ * Only a send seconds ago counts, and only for the same words, so a restored
9
+ * or later turn never flies in from a composer that has moved on.
10
+ *
11
+ * Between the send and the take, a composer keeps the words on screen where
12
+ * they were (`useWaitingSubmitOrigin`), so they never blink out while the
13
+ * answer mounts.
14
+ */
15
+ export interface SubmitOrigin {
16
+ text: string;
17
+ /** The TEXT's box in the viewport at send (the field less its padding), in CSS px. */
18
+ rect: {
19
+ left: number;
20
+ top: number;
21
+ width: number;
22
+ height: number;
23
+ };
24
+ /** The words' computed font size at send, in CSS px. */
25
+ fontSizePx: number;
26
+ /** Their computed line height, in CSS px. */
27
+ lineHeightPx: number;
28
+ /** Their computed font family and colour, so a copy of them reads as them. */
29
+ fontFamily: string;
30
+ color: string;
31
+ }
32
+ export declare function noteSubmitOrigin(text: string, el: HTMLElement): void;
33
+ /** The origin of `text`'s send, once — null when it was not just sent from a composer. */
34
+ export declare function takeSubmitOrigin(text: string): SubmitOrigin | null;
35
+ /**
36
+ * The words just sent, while no shell has taken them yet — a composer draws
37
+ * them where they were, so the sentence holds still until the answer lifts it.
38
+ * Null once taken, and once the send is too old to be.
39
+ */
40
+ export declare function useWaitingSubmitOrigin(): SubmitOrigin | null;
@@ -10,6 +10,12 @@ export interface UsePromptComposerOptions {
10
10
  * harmless) since hooks can't be conditional.
11
11
  */
12
12
  attachments?: ComposerAttachmentsApi;
13
+ /**
14
+ * The element showing the draft — noted at send (`submit-origin.ts`) so the
15
+ * turn can move the visitor's words from here into its own place. Omit and
16
+ * the turn shows them in place, without the move.
17
+ */
18
+ origin?: React.RefObject<HTMLElement | null>;
13
19
  }
14
20
  export interface UsePromptComposerApi {
15
21
  /** Current draft text. */
@@ -1,4 +1,4 @@
1
- import type { Product } from '../../../../ecommerce/src/index';
1
+ import type { InstallmentOffer, Money, Product } from '../../../../ecommerce/src/index';
2
2
  export type { AddToCartApi, CartAddHints, CartAddOptions, CartApi, CustomerAccountApi, ProductReviewHighlight, ProductReviewItem, ProductReviewsResult, ProductsQuery, ToggleWishlistApi, WishlistApi, WishlistState, } from './commerce-shapes';
3
3
  import type { AddToCartApi, CartAddHints, CartApi, CustomerAccountApi, ProductReviewsResult, ProductsQuery, ToggleWishlistApi, WishlistApi } from './commerce-shapes';
4
4
  /**
@@ -29,6 +29,8 @@ export interface FourtyCommerceRuntime {
29
29
  * description, so the hook needs that context, not just the id. */
30
30
  useProductReviews: (product: Product | undefined, intent?: string) => ProductReviewsResult;
31
31
  useCustomerAccount: () => CustomerAccountApi;
32
+ /** What `price` qualifies for under the store's pay-over-time plans. */
33
+ useInstallmentOffer: (price: Money) => InstallmentOffer | undefined;
32
34
  }
33
35
  /**
34
36
  * Provider for the commerce-hook surface. Mounted by the SDK's
@@ -64,3 +66,9 @@ export declare function useProductReviews(product: Product | undefined, intent?:
64
66
  /** The visitor's sign-in to the store's customer accounts. Inert (not
65
67
  * available) without a `<CommerceProvider>`. */
66
68
  export declare function useCustomerAccount(): CustomerAccountApi;
69
+ /** What `price` qualifies for under the store's pay-over-time plans —
70
+ * `{ plans, split, lowestMonthly }`, each term priced to the cent. Undefined
71
+ * while the plans load, when the store offers none (or has not granted the
72
+ * read), when `price` is outside every plan's band, and without a
73
+ * `<CommerceProvider>`. */
74
+ export declare function useInstallmentOffer(price: Money): InstallmentOffer | undefined;
@@ -183,7 +183,8 @@ export interface CustomerAccountApi {
183
183
  signIn: () => void;
184
184
  /** Drop this session's sign-in. */
185
185
  signOut: () => Promise<void>;
186
- /** False where the page has no customer sign-in to offer (no session yet,
187
- * or a space addressed by id, as in a console preview). */
186
+ /** False where the page has no customer sign-in to offer: the space has not
187
+ * attached Customer Accounts (so its agent could not read the account), no
188
+ * session yet, or a space addressed by id, as in a console preview. */
188
189
  available: boolean;
189
190
  }
@@ -1,5 +1,5 @@
1
1
  import './chip-relevance';
2
- export { useCart, useAddToCart, useWishlist, useToggleWishlist, useProducts, useCollectionByHandle, useProductReviews, useCustomerAccount, useCommerceRuntime, FourtyCommerceRuntimeProvider, } from './commerce-context';
2
+ export { useCart, useAddToCart, useWishlist, useToggleWishlist, useProducts, useCollectionByHandle, useProductReviews, useCustomerAccount, useInstallmentOffer, useCommerceRuntime, FourtyCommerceRuntimeProvider, } from './commerce-context';
3
3
  export type { FourtyCommerceRuntime, CartApi, AddToCartApi, WishlistApi, ToggleWishlistApi, ProductsQuery, ProductReviewItem, ProductReviewHighlight, ProductReviewsResult, CustomerAccountApi, CartAddOptions, CartAddHints, WishlistState, } from './commerce-context';
4
4
  export { navigateToExternalCommerceUrl } from './checkout/external-navigation';
5
5
  export type { ExternalNavigationResult } from './checkout/external-navigation';
@@ -13,6 +13,7 @@ export { type ChatMessage, type ConversationSummary, type StreamRecord, type Rea
13
13
  export { type StepName, type TraceEvent, type EmitFn, type TraceStartInfo, type StepConfig, type SystemPromptSnapshot, type VisitorIdentity, type PhaseProgress, type PhaseProgressPreview, } from './trace/trace-events';
14
14
  export { type TraceDiagnostic, type DiagnosticKind, type TraceStage, } from './trace/trace-diagnostics';
15
15
  export { type SuggestionAction, type SuggestionActions, type SuggestionRendererProps, SuggestionActionSchema, SuggestionActionsSchema, SIGNAL_PATCH_PREFIX, type SuggestionActionInput, type AgentSignal, type AgentSignalInput, AgentSignalSchema, InteractionSignalSchema, MAX_VISITOR_PROMPT_CHARS, type ToolCallHint, ToolCallHintSchema, type ActionDefinition, type ActionConfirmation, type ActionGuardEntities, type ActionPrepareContext, type ActionNamedEntity, type ActionPrepared, type ActionManifest, type AskDefinition, type AskManifest, NAVIGATE_SIGNAL, FLOW_OUTPUT_SIGNAL, PRESENCE_FLOW, PRESENCE_OPTIMISTIC_FACTS_FLOW, EXTEND_FLOW, DIRECTION_FLOW, EPHEMERAL_FACT_FLOWS, type FlowSpec, type FacultyFlowSpec, } from './signal/agent-signals';
16
+ export { CHIP_SHOW_SIGNAL, chipsFromShowSignal } from './signal/chip-show';
16
17
  export { TURN_ASK_SIGNAL, TurnAskSchema, turnAskFromSignal, turnAskSegments, turnAskAnswers, turnAskPlainText, type TurnAsk, type TurnAskSegment } from './signal/turn-ask';
17
18
  export { type TraceSpanData, type TraceData, type Trace, type TraceLatency, type TraceEventLogEntry, type LayoutChangeEntry, } from './trace/trace-data';
18
19
  export { type TraceSnapshotEnvelope, type SystemPromptSnapshotEnvelope, type LayoutSnapshotEnvelope, type SuggestionsSnapshotEnvelope, type TurnSnapshotEnvelope, type AssemblyInputsEnvelope, type AssemblyInputComponent, type AssemblyInputTool, type AssemblyInputPrompt, } from './trace/trace-envelopes';
@@ -0,0 +1,10 @@
1
+ import { type AgentSignal, type SuggestionAction } from './agent-signals';
2
+ /** The follow-up rail a turn closes with — one `/signals/chip.show` fence line. */
3
+ export declare const CHIP_SHOW_SIGNAL = "chip.show";
4
+ /**
5
+ * Validate a `chip.show` signal payload and return the chip array.
6
+ * Returns null when the signal isn't `chip.show` or the payload doesn't
7
+ * match the strict chip shape (id+label+type+payload required). One reader for
8
+ * both ends: the client shows the rail, the agent persists it for a restore.
9
+ */
10
+ export declare function chipsFromShowSignal(signal: AgentSignal): SuggestionAction[] | null;
package/package.json CHANGED
@@ -26,7 +26,7 @@
26
26
  "react": "^18.3.0 || ^19.0.0",
27
27
  "react-dom": "^18.3.0 || ^19.0.0"
28
28
  },
29
- "version": "0.5.12",
29
+ "version": "0.5.14",
30
30
  "homepage": "https://docs.40rty.ai",
31
31
  "license": "UNLICENSED",
32
32
  "engines": {