@gengage/assistant-fe 0.6.26 → 0.6.28

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-Dc4ByfZo.js +3161 -0
  2. package/dist/agentic/context/context-store.d.ts +25 -0
  3. package/dist/agentic/debug/activity-collector.d.ts +1 -0
  4. package/dist/agentic/index.d.ts +15 -1
  5. package/dist/agentic/index.js +415 -380
  6. package/dist/agentic/types.d.ts +34 -3
  7. package/dist/agentic/worker/agent-ui-steps.d.ts +43 -0
  8. package/dist/agentic/worker/agent-ui.d.ts +44 -0
  9. package/dist/agentic/worker/be-client.d.ts +16 -4
  10. package/dist/agentic/worker/coalesce.d.ts +25 -0
  11. package/dist/agentic/worker/compaction.d.ts +12 -0
  12. package/dist/agentic/worker/pdp-hydrate.d.ts +30 -0
  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 +10 -9
  17. package/dist/{api-paths-CmFRzaMd.js → api-paths-PFiXYIey.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-uHKZ-s5H.js → common-DyAcz33-.js} +1 -1
  22. package/dist/common.js +5 -5
  23. package/dist/{connection-warning-xRmq7uJ3.js → connection-warning-nWEUv5bp.js} +1 -1
  24. package/dist/{fastIntent-B3qZhCis.js → fastIntent-BiHAWBIa.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-Cpi9hXiL.js → runtime-BIA5sGno.js} +3 -3
  31. package/dist/{runtime-C1mVW5y1.js → runtime-BuzZUB0i.js} +3 -3
  32. package/dist/{runtime-DhhnaNUQ.js → runtime-PHarcyNZ.js} +3 -3
  33. package/dist/{simbut-csGdfd9_.js → simbut-CiPq-niE.js} +1 -1
  34. package/dist/simbut.iife.js +1 -1
  35. package/dist/simbut.js +1 -1
  36. package/dist/{simrel-B1VHfhBf.js → simrel-XWtKe-OG.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-DNT8SYtf.js → widget-base-DSl6thOx.js} +1 -1
  41. package/package.json +1 -1
  42. package/dist/route-params-UDemctx_.js +0 -2471
@@ -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;
@@ -46,6 +49,9 @@ export interface FlowStepCtx {
46
49
  accountConfig: Record<string, unknown>;
47
50
  catalogMapper?: CatalogMapper | undefined;
48
51
  similarityMapper?: SimilarityMapper | undefined;
52
+ beClient?: BeClient;
53
+ toolBridge?: ToolBridge;
54
+ signal?: AbortSignal;
49
55
  }
50
56
  export type FlowValue<T> = T | ((ctx: FlowStepCtx) => Awaitable<T>);
51
57
  export type FlowPatch = (ctx: ChatContext, result: unknown, snapshot: FlowStepCtx) => Awaitable<Partial<ChatContext> | null | undefined>;
@@ -86,6 +92,7 @@ export interface ToolStep {
86
92
  kind: 'tool';
87
93
  name: string;
88
94
  input: FlowValue<unknown>;
95
+ parameters?: ToolArgSchema;
89
96
  timeoutMs?: FlowValue<number | undefined>;
90
97
  confirm?: FlowConfirmationGate;
91
98
  out?: string;
@@ -147,7 +154,30 @@ export type ToolFn = (input: unknown) => unknown | Promise<unknown>;
147
154
  export type ToolMap = Record<string, ToolFn>;
148
155
  export type CatalogMapper = (raw: Record<string, unknown>) => NormalizedProduct | null;
149
156
  export type SimilarityMapper = (raw: Record<string, unknown>) => ProductSimilarityProfile | null;
150
- 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>> {
151
181
  accountId?: string;
152
182
  defaultLocale?: string;
153
183
  flows: Record<string, Flow>;
@@ -155,8 +185,9 @@ export interface AccountModule {
155
185
  adapters?: FlowAdapterMap;
156
186
  catalogMapper?: CatalogMapper;
157
187
  similarityMapper?: SimilarityMapper;
158
- accountConfig?: Record<string, unknown>;
188
+ accountConfig?: TAccountConfig;
159
189
  trace?: AgentTraceCallback;
190
+ hooks?: AgentHooks;
160
191
  contextPersistence?: {
161
192
  panelKeys?: readonly string[];
162
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 {};
@@ -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';