@gengage/assistant-fe 0.6.27 → 0.6.29

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 (42) hide show
  1. package/dist/agent-ui-steps-WKbTVOS4.js +3197 -0
  2. package/dist/agentic/context/context-store.d.ts +25 -0
  3. package/dist/agentic/index.d.ts +15 -1
  4. package/dist/agentic/index.js +164 -150
  5. package/dist/agentic/types.d.ts +31 -3
  6. package/dist/agentic/worker/agent-ui-steps.d.ts +43 -0
  7. package/dist/agentic/worker/agent-ui.d.ts +44 -0
  8. package/dist/agentic/worker/be-client.d.ts +16 -4
  9. package/dist/agentic/worker/coalesce.d.ts +25 -0
  10. package/dist/agentic/worker/compaction.d.ts +12 -0
  11. package/dist/agentic/worker/pdp-hydrate.d.ts +30 -0
  12. package/dist/agentic/worker/rpc.d.ts +4 -1
  13. package/dist/agentic/worker/tool-schema.d.ts +19 -0
  14. package/dist/agentic/worker.d.ts +15 -1
  15. package/dist/agentic/worker.js +292 -264
  16. package/dist/agentic.iife.js +9 -9
  17. package/dist/{api-paths-C9NwnH29.js → api-paths-DdJr0XJ-.js} +1 -1
  18. package/dist/chat-runtime.js +1 -1
  19. package/dist/chat.iife.js +1 -1
  20. package/dist/chat.js +1 -1
  21. package/dist/{common-Bhl1mzk2.js → common-DlxPSm8-.js} +1 -1
  22. package/dist/common.js +5 -5
  23. package/dist/{connection-warning-D-0Mxk-A.js → connection-warning-B5i-GYl3.js} +1 -1
  24. package/dist/{fastIntent-bAlwVoje.js → fastIntent-BXTc79jM.js} +1 -1
  25. package/dist/index.js +10 -10
  26. package/dist/native.iife.js +1 -1
  27. package/dist/qna-runtime.js +1 -1
  28. package/dist/qna.iife.js +1 -1
  29. package/dist/qna.js +1 -1
  30. package/dist/{runtime-BAFZ7iOP.js → runtime-2RYLgot8.js} +3 -3
  31. package/dist/{runtime-oEtmgT4U.js → runtime-BMBmZgp7.js} +3 -3
  32. package/dist/{runtime-CUNLK1KR.js → runtime-DzSiJPPm.js} +3 -3
  33. package/dist/{simbut-Dt8e5uSk.js → simbut-Bwpt8E03.js} +1 -1
  34. package/dist/simbut.iife.js +1 -1
  35. package/dist/simbut.js +1 -1
  36. package/dist/{simrel-txr23_xG.js → simrel-D0G7CUSn.js} +1 -1
  37. package/dist/simrel-runtime.js +1 -1
  38. package/dist/simrel.iife.js +1 -1
  39. package/dist/simrel.js +2 -2
  40. package/dist/{widget-base-56tkaZZB.js → widget-base-XYJ0Ou6y.js} +1 -1
  41. package/package.json +1 -1
  42. package/dist/route-params-5K4Du1Xa.js +0 -2476
@@ -2,6 +2,7 @@ import type { ProcessActionRequest } from '../common/transport.js';
2
2
  import type { StreamEvent, UISpec } from '../common/types.js';
3
3
  import type { NormalizedProduct } from './events/product-normalize.js';
4
4
  import type { ProductSimilarityProfile } from './algos/similarity.js';
5
+ import type { ToolArgSchema } from './worker/tool-schema.js';
5
6
  export interface ChatThread {
6
7
  id: string;
7
8
  started_at: string;
@@ -9,8 +10,10 @@ export interface ChatThread {
9
10
  }
10
11
  export type ChatPanel = Record<string, unknown>;
11
12
  export interface ChatMessage {
12
- role: 'user' | 'assistant';
13
+ role: 'user' | 'assistant' | 'tool_result';
13
14
  content: string;
15
+ name?: string;
16
+ details?: unknown;
14
17
  }
15
18
  export interface ChatMeta {
16
19
  locale: string;
@@ -89,6 +92,7 @@ export interface ToolStep {
89
92
  kind: 'tool';
90
93
  name: string;
91
94
  input: FlowValue<unknown>;
95
+ parameters?: ToolArgSchema;
92
96
  timeoutMs?: FlowValue<number | undefined>;
93
97
  confirm?: FlowConfirmationGate;
94
98
  out?: string;
@@ -150,7 +154,30 @@ export type ToolFn = (input: unknown) => unknown | Promise<unknown>;
150
154
  export type ToolMap = Record<string, ToolFn>;
151
155
  export type CatalogMapper = (raw: Record<string, unknown>) => NormalizedProduct | null;
152
156
  export type SimilarityMapper = (raw: Record<string, unknown>) => ProductSimilarityProfile | null;
153
- export interface AccountModule {
157
+ export interface BeforeToolCallResult {
158
+ block?: boolean;
159
+ reason?: string;
160
+ args?: unknown;
161
+ }
162
+ export interface AfterToolCallResult {
163
+ result?: unknown;
164
+ terminate?: boolean;
165
+ }
166
+ export interface BeforeBeOpResult {
167
+ input?: unknown;
168
+ cached?: unknown;
169
+ }
170
+ export interface AfterBeOpResult {
171
+ result?: unknown;
172
+ }
173
+ export interface AgentHooks {
174
+ beforeToolCall?(name: string, args: unknown, ctx: FlowStepCtx): Awaitable<BeforeToolCallResult | void | undefined>;
175
+ afterToolCall?(name: string, result: unknown, ctx: FlowStepCtx): Awaitable<AfterToolCallResult | void | undefined>;
176
+ transformContext?(ctx: ChatContext): Awaitable<ChatContext | void | undefined>;
177
+ beforeBeOp?(op: string, input: unknown, ctx: FlowStepCtx): Awaitable<BeforeBeOpResult | void | undefined>;
178
+ afterBeOp?(op: string, result: unknown, ctx: FlowStepCtx): Awaitable<AfterBeOpResult | void | undefined>;
179
+ }
180
+ export interface AccountModule<TAccountConfig extends Record<string, unknown> = Record<string, unknown>> {
154
181
  accountId?: string;
155
182
  defaultLocale?: string;
156
183
  flows: Record<string, Flow>;
@@ -158,8 +185,9 @@ export interface AccountModule {
158
185
  adapters?: FlowAdapterMap;
159
186
  catalogMapper?: CatalogMapper;
160
187
  similarityMapper?: SimilarityMapper;
161
- accountConfig?: Record<string, unknown>;
188
+ accountConfig?: TAccountConfig;
162
189
  trace?: AgentTraceCallback;
190
+ hooks?: AgentHooks;
163
191
  contextPersistence?: {
164
192
  panelKeys?: readonly string[];
165
193
  panelKeyLimits?: Record<string, number>;
@@ -0,0 +1,43 @@
1
+ import type { ChatContext, FlowStep, UiSpecEnvelope } from '../types.js';
2
+ import type { StreamEvent } from '../../common/types.js';
3
+ import { type RoundObservation, type SearchFollowUpPill } from './agent-ui.js';
4
+ export interface ToolObservationEnvelope extends RoundObservation {
5
+ name?: string;
6
+ arguments?: Record<string, unknown>;
7
+ observation?: {
8
+ status?: string;
9
+ products?: unknown[];
10
+ query?: unknown;
11
+ source?: unknown;
12
+ count?: unknown;
13
+ comparison_table?: unknown;
14
+ key_differences?: unknown;
15
+ recommendation?: {
16
+ sku?: unknown;
17
+ reason?: unknown;
18
+ };
19
+ surface?: {
20
+ product?: unknown;
21
+ };
22
+ [key: string]: unknown;
23
+ };
24
+ }
25
+ export interface ToolUiStepsDeps {
26
+ obsKey?: string;
27
+ uiSpec: (envelope: UiSpecEnvelope) => StreamEvent;
28
+ productsUiSpec: (products: unknown[]) => UiSpecEnvelope;
29
+ actionButtonsUiSpec: (pills: SearchFollowUpPill[]) => UiSpecEnvelope;
30
+ comparisonUiSpec: (input: {
31
+ products: unknown[];
32
+ comparison_table?: unknown;
33
+ key_differences?: unknown;
34
+ recommended_choice_sku?: unknown;
35
+ recommended_choice?: unknown;
36
+ }) => UiSpecEnvelope;
37
+ productDetailsUiSpec: (product: unknown) => UiSpecEnvelope;
38
+ similarsFollowupSteps?: () => readonly FlowStep[];
39
+ pdpFollowupProduct?: (bag: Record<string, unknown>, context: ChatContext) => unknown;
40
+ gridLimit?: number;
41
+ }
42
+ export declare function buildToolUiSteps(deps: ToolUiStepsDeps): FlowStep[];
43
+ export declare function buildPdpFollowupSteps(deps: ToolUiStepsDeps): FlowStep[];
@@ -0,0 +1,44 @@
1
+ interface UiSpecLike {
2
+ spec?: {
3
+ root?: string;
4
+ elements?: Record<string, {
5
+ type?: string;
6
+ props?: Record<string, unknown>;
7
+ } | undefined>;
8
+ };
9
+ [key: string]: unknown;
10
+ }
11
+ export interface SearchFollowUpProduct {
12
+ sku?: unknown;
13
+ url?: unknown;
14
+ [key: string]: unknown;
15
+ }
16
+ export interface SearchFollowUpContext {
17
+ meta?: {
18
+ locale?: unknown;
19
+ };
20
+ }
21
+ export interface SearchFollowUpAccountConfig {
22
+ locale?: unknown;
23
+ defaultLocale?: unknown;
24
+ }
25
+ export interface SearchFollowUpPill {
26
+ label: string;
27
+ action: {
28
+ type: string;
29
+ payload: Record<string, unknown>;
30
+ };
31
+ }
32
+ export declare function searchFollowUpPills(products: readonly SearchFollowUpProduct[] | null | undefined, options?: {
33
+ context?: SearchFollowUpContext;
34
+ accountConfig?: SearchFollowUpAccountConfig;
35
+ }): SearchFollowUpPill[];
36
+ export interface RoundObservation {
37
+ observation?: {
38
+ products?: readonly unknown[];
39
+ };
40
+ [key: string]: unknown;
41
+ }
42
+ export declare function mergeRoundProducts(observations: readonly (RoundObservation | null | undefined)[] | null | undefined, limit?: number): Record<string, unknown>[];
43
+ export declare function withSimilarsAppend<T extends UiSpecLike>(envelope: T): T;
44
+ export {};
@@ -1,6 +1,18 @@
1
1
  import { type JwtProvider } from './jwt-mint.js';
2
- import type { BrowserCachePolicy } from '../types.js';
3
- interface InvokeBeOpArgs {
2
+ import type { Awaitable, BrowserCachePolicy } from '../types.js';
3
+ export interface BeClientInterceptors {
4
+ beforeRequest?(args: InvokeBeOpArgs, request: {
5
+ url: string;
6
+ init: RequestInit;
7
+ }): Awaitable<{
8
+ init?: RequestInit;
9
+ cached?: Record<string, unknown>;
10
+ } | void | undefined>;
11
+ afterResponse?(args: InvokeBeOpArgs, result: Record<string, unknown>): Awaitable<{
12
+ result?: Record<string, unknown>;
13
+ } | void | undefined>;
14
+ }
15
+ export interface InvokeBeOpArgs {
4
16
  beUrl: string;
5
17
  accountId: string;
6
18
  devJwtSecret?: string | undefined;
@@ -14,6 +26,6 @@ interface InvokeBeOpArgs {
14
26
  cacheKey?: string | undefined;
15
27
  browserCache?: BrowserCachePolicy | undefined;
16
28
  signal?: AbortSignal | undefined;
29
+ interceptors?: BeClientInterceptors | undefined;
17
30
  }
18
- export declare function invokeBeOp({ beUrl, accountId, devJwtSecret, tokenBrokerUrl, tokenBrokerAudience, jwtProvider, parentUrl, op, input, cacheTtlS, cacheKey, browserCache, signal, }: InvokeBeOpArgs): Promise<Record<string, unknown>>;
19
- export {};
31
+ export declare function invokeBeOp(args: InvokeBeOpArgs): Promise<Record<string, unknown>>;
@@ -0,0 +1,25 @@
1
+ export interface SingleFlightOptions {
2
+ ttlMs?: number;
3
+ clock?: () => number;
4
+ }
5
+ export type SingleFlightExecutor<TInput, TResult> = (input: TInput) => Promise<TResult>;
6
+ export type SingleFlightKeyFn<TInput> = (input: TInput) => string | null | undefined;
7
+ export declare function singleFlight<TInput, TResult>(executor: SingleFlightExecutor<TInput, TResult>, keyFn: SingleFlightKeyFn<TInput>, options?: SingleFlightOptions): SingleFlightExecutor<TInput, TResult>;
8
+ interface CartInput {
9
+ cartCode?: unknown;
10
+ sku?: unknown;
11
+ productCode?: unknown;
12
+ quantity?: unknown;
13
+ qty?: unknown;
14
+ variantId?: unknown;
15
+ variantCode?: unknown;
16
+ product?: {
17
+ sku?: unknown;
18
+ cart_code?: unknown;
19
+ variantId?: unknown;
20
+ };
21
+ }
22
+ type CartImpl<TResult> = (input: CartInput) => Promise<TResult>;
23
+ export declare function coalesceAddToCart<TResult>(impl: CartImpl<TResult>): (input?: CartInput) => Promise<TResult>;
24
+ export declare function __resetAllCartCoalescersForTesting(): void;
25
+ export {};
@@ -0,0 +1,12 @@
1
+ import type { ChatContext, ChatMessage } from '../types.js';
2
+ export interface CompactionOptions {
3
+ threshold?: number;
4
+ retainTail?: number;
5
+ }
6
+ export interface CompactionRequest {
7
+ messagesToSummarize: readonly ChatMessage[];
8
+ retainedTail: readonly ChatMessage[];
9
+ }
10
+ export declare function shouldCompact(messages: readonly ChatMessage[] | null | undefined, options?: CompactionOptions): boolean;
11
+ export declare function buildCompactionRequest(messages: readonly ChatMessage[], options?: CompactionOptions): CompactionRequest | null;
12
+ export declare function applyCompactionResult(context: ChatContext, summary: string, options?: CompactionOptions): ChatContext;
@@ -0,0 +1,30 @@
1
+ type ResolveProductsResult<TProduct> = {
2
+ products?: TProduct[];
3
+ } & Record<string, unknown>;
4
+ type ResolveProductsInput = {
5
+ hydrateFromPdp?: boolean;
6
+ [key: string]: unknown;
7
+ };
8
+ export interface PdpHydrationOptions<TProduct extends {
9
+ sku?: unknown;
10
+ url?: unknown;
11
+ }> {
12
+ accountId: string;
13
+ allowedHostnames: readonly string[];
14
+ productFromPage: (doc: Document, url: string) => TProduct | null;
15
+ mergeProduct?: (base: TProduct, parsed: TProduct) => TProduct;
16
+ needsHydration?: (product: TProduct) => boolean;
17
+ fetchOptions?: RequestInit;
18
+ maxConcurrency?: number;
19
+ }
20
+ export interface WrappedResolveProducts<TProduct, TResult extends ResolveProductsResult<TProduct>> {
21
+ (input?: ResolveProductsInput): Promise<TResult>;
22
+ __resetCacheForTesting(): void;
23
+ __cacheSizeForTesting(): number;
24
+ }
25
+ export declare function wrapResolveProductsWithPdpHydration<TProduct extends {
26
+ sku?: unknown;
27
+ url?: unknown;
28
+ }, TResult extends ResolveProductsResult<TProduct>>(baseResolveProducts: (input: ResolveProductsInput) => Promise<TResult>, options: PdpHydrationOptions<TProduct>): WrappedResolveProducts<TProduct, TResult>;
29
+ export declare function __resetAllPdpHydratorsForTesting(): void;
30
+ export {};
@@ -29,7 +29,10 @@ interface RpcScope {
29
29
  addEventListener: (type: 'message', listener: (event: MessageEvent) => void) => void;
30
30
  postMessage: (message: unknown, transfer?: Transferable[]) => void;
31
31
  }
32
- export declare function createWorkerRpc(scope?: RpcScope): RpcFn;
32
+ export interface WorkerRpcOptions {
33
+ timeoutMs?: number;
34
+ }
35
+ export declare function createWorkerRpc(scope?: RpcScope, options?: WorkerRpcOptions): RpcFn;
33
36
  interface HandleMainRpcArgs {
34
37
  worker: Worker;
35
38
  tools?: ToolMap;
@@ -0,0 +1,19 @@
1
+ export interface ToolArgSchema {
2
+ type?: 'string' | 'number' | 'boolean' | 'array' | 'object';
3
+ required?: readonly string[];
4
+ properties?: Readonly<Record<string, ToolArgSchema>>;
5
+ items?: ToolArgSchema;
6
+ enum?: readonly unknown[];
7
+ minItems?: number;
8
+ maxItems?: number;
9
+ minLength?: number;
10
+ minimum?: number;
11
+ maximum?: number;
12
+ }
13
+ export type ToolArgValidationResult = {
14
+ ok: true;
15
+ } | {
16
+ ok: false;
17
+ error: string;
18
+ };
19
+ export declare function validateToolArgs(schema: ToolArgSchema | undefined, args: unknown): ToolArgValidationResult;
@@ -34,5 +34,19 @@ export { createPrivacyHelpers, plainMessageContent } from './util/common/privacy
34
34
  export { compactProductSurfaceForLlm, mergeProductSurfaceEvidence, productSurfaceReviewText, } from './util/common/product-surface.js';
35
35
  export { anonymousRequestText as retailAnonymousRequestText, anonymizeMessages as retailAnonymizeMessages, redactPii as retailRedactPii, } from './util/common/retail-privacy.js';
36
36
  export { firstArrayValue, routeFlowParams, routeSkuList } from './util/common/route-params.js';
37
- export type { AccountModule, AgentLoopPatch, AgentLoopPredicate, AgentLoopStep, AgentConfirmationRequest, AgentConfirmationResult, AgentMemoryProvider, AgentTraceCallback, AgentTraceEvent, AdapterStep, AgentBeaconPayload, Awaitable, BeClient, BeOpStep, BranchStep, BrowserCachePolicy, ChatContext, CommitStep, EmitStep, Flow, FlowAdapterFn, FlowAdapterMap, FlowConfirmationGate, FlowConfirmationRequest, FlowConfirmationValue, FlowPatch, FlowStep, FlowStepCtx, FlowValue, MemoryTier, ParallelStep, RefusalStep, ToolFn, ToolMap, ToolStep, } from './types.js';
37
+ export type { AccountModule, AfterBeOpResult, AfterToolCallResult, AgentHooks, AgentLoopPatch, AgentLoopPredicate, AgentLoopStep, AgentConfirmationRequest, AgentConfirmationResult, AgentMemoryProvider, AgentTraceCallback, AgentTraceEvent, AdapterStep, AgentBeaconPayload, BeforeBeOpResult, BeforeToolCallResult, Awaitable, BeClient, BeOpStep, BranchStep, BrowserCachePolicy, ChatContext, CommitStep, EmitStep, Flow, FlowAdapterFn, FlowAdapterMap, FlowConfirmationGate, FlowConfirmationRequest, FlowConfirmationValue, FlowPatch, FlowStep, FlowStepCtx, FlowValue, MemoryTier, ParallelStep, RefusalStep, ToolFn, ToolMap, ToolStep, } from './types.js';
38
38
  export type { BeOpInputBase, CompareInput, CompareOutput, GssInstallmentOption, GssProductDetails, GssProductFeature, GssProductQuestionAnswer, GssProductReview, GssProductSeller, GssShippingOption, IntentOpInput, IntentOpOutput, LocaleCode, MoneyValue, ProductAnswerInput, ProductAnswerOutput, RefPayload, UiSpec, UiSpecElement, UiSpecElementType, UiSpecEvent, } from './contracts/agentic-contracts.js';
39
+ export { validateToolArgs } from './worker/tool-schema.js';
40
+ export type { ToolArgSchema, ToolArgValidationResult } from './worker/tool-schema.js';
41
+ export { __resetAllCartCoalescersForTesting, coalesceAddToCart, singleFlight } from './worker/coalesce.js';
42
+ export type { SingleFlightExecutor, SingleFlightKeyFn, SingleFlightOptions } from './worker/coalesce.js';
43
+ export { __resetAllPdpHydratorsForTesting, wrapResolveProductsWithPdpHydration } from './worker/pdp-hydrate.js';
44
+ export type { PdpHydrationOptions, WrappedResolveProducts } from './worker/pdp-hydrate.js';
45
+ export type { BeClientInterceptors, InvokeBeOpArgs } from './worker/be-client.js';
46
+ export type { PendingMessage, PendingMessageKind, QueueMode, SavePointEntry } from './context/context-store.js';
47
+ export { mergeRoundProducts, searchFollowUpPills, withSimilarsAppend } from './worker/agent-ui.js';
48
+ export type { RoundObservation, SearchFollowUpAccountConfig, SearchFollowUpContext, SearchFollowUpPill, SearchFollowUpProduct, } from './worker/agent-ui.js';
49
+ export { applyCompactionResult, buildCompactionRequest, shouldCompact } from './worker/compaction.js';
50
+ export type { CompactionOptions, CompactionRequest } from './worker/compaction.js';
51
+ export { buildPdpFollowupSteps, buildToolUiSteps } from './worker/agent-ui-steps.js';
52
+ export type { ToolObservationEnvelope, ToolUiStepsDeps } from './worker/agent-ui-steps.js';