@pluno/product-agent-web 0.1.191 → 0.1.196

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.
@@ -0,0 +1,18 @@
1
+ type RunRecoveryItem = {
2
+ id: string;
3
+ data: unknown;
4
+ };
5
+ type RunRecoveryIdentity = {
6
+ type?: unknown;
7
+ status?: unknown;
8
+ reason?: unknown;
9
+ role?: unknown;
10
+ clientMessageId?: unknown;
11
+ respondsToUserMessageId?: unknown;
12
+ runId?: unknown;
13
+ };
14
+ export declare function filterSupersededTaskTabClosedStops<T extends RunRecoveryItem>(items: T[], activeRetryClientMessageId: string | null): T[];
15
+ export declare function isTaskTabClosedStopForClientMessage(items: RunRecoveryItem[], item: RunRecoveryItem, clientMessageId: string): boolean;
16
+ export declare function isTaskTabClosedStop(data: Record<string, unknown>): boolean;
17
+ export declare function isRecoveredTaskTabClosedTurnProgress(stoppedData: RunRecoveryIdentity, candidateData: RunRecoveryIdentity): boolean;
18
+ export {};
@@ -0,0 +1,10 @@
1
+ export { createProductAgentQueryState, mergeProductAgentEntityPages, normalizeProductAgentEntityPage, ProductAgentQueryController, reconcileProductAgentSubmissionGate, resolveProductAgentComposerAction, resolveProductAgentBillingPresentation, resolveProductAgentWidgetPresentation, hasProductAgentPaidCreditFallback, selectProductAgentQueryEntities, } from "./runtimeState";
2
+ export type { ProductAgentAuthProjection, ProductAgentComposerAction, ProductAgentEntity, ProductAgentEntityPage, ProductAgentEntityQueryData, ProductAgentInteraction, ProductAgentInteractionAction, ProductAgentInteractionPresentation, ProductAgentInteractionScope, ProductAgentInteractionStatus, ProductAgentPromptAction, ProductAgentPromptDecision, ProductAgentPromptDecisionScope, ProductAgentQueryLoadMode, ProductAgentQueryState, ProductAgentQueryStatus, ProductAgentSafeUser, ProductAgentSafeWorkspace, ProductAgentSubmissionGate, ProductAgentWidgetPresentation, } from "./runtimeState";
3
+ export { ProductAgentSessionHistoryManager } from "./sessionHistoryState";
4
+ export type { ProductAgentSessionHistoryEntity, ProductAgentSessionHistoryLoader, ProductAgentSessionHistoryPage, } from "./sessionHistoryState";
5
+ export { createLocalStorageInteractionDecisionStorage, ProductAgentInteractionManager, readLocalStorageInteractionDecisions, } from "./interactionManager";
6
+ export type { ProductAgentInteractionDecisionStorage, ProductAgentInteractionDefinition, } from "./interactionManager";
7
+ export { createProductAgentTaskPageTitleDocument, formatProductAgentTaskPageTitle, ProductAgentTaskPageTitleController, } from "./taskPageTitle";
8
+ export { isProductAgentRuntimeCommand, ProductAgentRemoteRuntimeClient } from "./runtimeClient";
9
+ export type { ProductAgentRuntimeClient, ProductAgentRuntimeClientAdapter, ProductAgentRuntimeCommand, ProductAgentRuntimeCommandResult, ProductAgentRuntimeEventName, } from "./runtimeClient";
10
+ export type { ProductAgentTaskPageTitleDocument, ProductAgentTaskStatus, } from "./taskPageTitle";
@@ -0,0 +1,189 @@
1
+ import type { ProductAgentAttachment, ProductAgentEventMap, ProductAgentInvocation, ProductAgentModel, ProductAgentSessionHistoryPage, ProductAgentSessionHistoryEntry, ProductAgentState, ProductAgentWidgetLifecycleAction, ProductAgentWidgetLifecycleTrigger } from "./index";
2
+ import type { ProductAgentAccountProjection, ProductAgentInteraction, ProductAgentInteractionAction } from "./runtimeState";
3
+ import { type ProductAgentEntityQueryData, type ProductAgentQueryState } from "./runtimeState";
4
+ export type ProductAgentRuntimeEventName = keyof ProductAgentEventMap;
5
+ export type ProductAgentRuntimeCommand = {
6
+ type: "runtime.connect";
7
+ } | {
8
+ type: "runtime.warmup";
9
+ reason: "panel_open" | "extension_install" | "composer_input";
10
+ } | {
11
+ type: "runtime.widget_lifecycle";
12
+ action: ProductAgentWidgetLifecycleAction;
13
+ trigger: ProductAgentWidgetLifecycleTrigger;
14
+ } | {
15
+ type: "session.new";
16
+ } | {
17
+ type: "session.load";
18
+ sessionId: string;
19
+ } | {
20
+ type: "session.list";
21
+ cursor?: string | null;
22
+ limit?: number;
23
+ pinned?: boolean;
24
+ } | {
25
+ type: "session.set_model";
26
+ model: ProductAgentModel;
27
+ } | {
28
+ type: "session.pin";
29
+ sessionId: string;
30
+ pinned: boolean;
31
+ } | {
32
+ type: "session.rename";
33
+ sessionId: string;
34
+ title: string;
35
+ } | {
36
+ type: "run.stop";
37
+ } | {
38
+ type: "run.retry";
39
+ } | {
40
+ type: "interaction.act";
41
+ interactionId: string;
42
+ action: ProductAgentInteractionAction;
43
+ expectedRevision: number;
44
+ snoozeUntil?: string;
45
+ feedback?: string;
46
+ } | {
47
+ type: "conversation.stage_proactive_suggestion";
48
+ question: string;
49
+ clientMessageId: string;
50
+ } | {
51
+ type: "conversation.stage";
52
+ content: string;
53
+ clientMessageId: string;
54
+ proactiveSuggestionQuestion?: string;
55
+ attachments?: ProductAgentAttachment[];
56
+ } | {
57
+ type: "conversation.fail_staged";
58
+ clientMessageId: string;
59
+ message: string;
60
+ } | {
61
+ type: "conversation.send";
62
+ content: string;
63
+ clientMessageId: string;
64
+ initiatedBy?: "pluno";
65
+ invocation?: ProductAgentInvocation | "pluno";
66
+ proactiveSuggestionQuestion?: string;
67
+ attachments?: ProductAgentAttachment[];
68
+ };
69
+ export type ProductAgentRuntimeCommandResult = {
70
+ clientMessageId?: string | null;
71
+ };
72
+ export type ProductAgentRuntimeClientAdapter = {
73
+ dispatch(command: ProductAgentRuntimeCommand): Promise<ProductAgentRuntimeCommandResult | void>;
74
+ uploadAttachment?: (file: File, attachment: ProductAgentAttachment, context: {
75
+ clientMessageId: string;
76
+ }) => Promise<ProductAgentAttachment>;
77
+ onDisconnect?: () => void;
78
+ };
79
+ export declare function isProductAgentRuntimeCommand(value: unknown): value is ProductAgentRuntimeCommand;
80
+ export type ProductAgentRuntimeClient = {
81
+ on<T extends ProductAgentRuntimeEventName>(eventName: T, listener: (payload: ProductAgentEventMap[T]) => void): () => void;
82
+ getState(): ProductAgentState;
83
+ connect(): Promise<void>;
84
+ destroy(): void;
85
+ warmup(reason?: "panel_open" | "extension_install" | "composer_input"): void;
86
+ recordWidgetLifecycle(action: ProductAgentWidgetLifecycleAction, trigger: ProductAgentWidgetLifecycleTrigger): void;
87
+ sendMessage(content: string, options?: {
88
+ attachments?: ProductAgentAttachment[];
89
+ clientMessageId?: string;
90
+ initiatedBy?: "pluno";
91
+ invocation?: ProductAgentInvocation | "pluno";
92
+ proactiveSuggestionQuestion?: string;
93
+ }): Promise<string | null>;
94
+ getModel(): ProductAgentModel | undefined;
95
+ setModel(model: ProductAgentModel): void;
96
+ retryLastMessage(): boolean;
97
+ createLocalAttachment(file: File): ProductAgentAttachment;
98
+ stop(): void;
99
+ startNewSession(options?: {
100
+ notifyTransport?: boolean;
101
+ }): void;
102
+ listSessions(options?: {
103
+ cursor?: string | null;
104
+ limit?: number;
105
+ pinned?: boolean;
106
+ }): Promise<ProductAgentSessionHistoryPage>;
107
+ getSessionHistoryState(): ProductAgentQueryState<ProductAgentEntityQueryData<ProductAgentSessionHistoryEntry>>;
108
+ subscribeSessionHistory(listener: (state: ProductAgentQueryState<ProductAgentEntityQueryData<ProductAgentSessionHistoryEntry>>) => void): () => void;
109
+ refreshSessionHistory(): Promise<void>;
110
+ loadMoreSessionHistory(): Promise<void>;
111
+ setSessionPinned(sessionId: string, pinned: boolean): Promise<void>;
112
+ renameSession(sessionId: string, title: string): Promise<void>;
113
+ getInteractions(): readonly ProductAgentInteraction[];
114
+ subscribeInteractions(listener: (interactions: readonly ProductAgentInteraction[]) => void): () => void;
115
+ actOnInteraction(interactionId: string, action: ProductAgentInteractionAction, expectedRevision: number, input?: {
116
+ feedback?: string;
117
+ snoozeUntil?: string;
118
+ }): Promise<void>;
119
+ getAccount(): ProductAgentAccountProjection | null;
120
+ subscribeAccount(listener: (account: ProductAgentAccountProjection | null) => void): () => void;
121
+ refreshAccount(): Promise<void>;
122
+ loadSession(sessionId: string): void;
123
+ stageProactiveSuggestionQuestion(question: string): void;
124
+ };
125
+ export declare class ProductAgentRemoteRuntimeClient implements ProductAgentRuntimeClient {
126
+ private readonly adapter;
127
+ private readonly listeners;
128
+ private readonly attachmentFiles;
129
+ private readonly sessionHistoryListeners;
130
+ private readonly interactionListeners;
131
+ private readonly accountListeners;
132
+ private state;
133
+ private sessionHistoryState;
134
+ private model;
135
+ private interactions;
136
+ private account;
137
+ private stagedProactiveSuggestionClientMessageId;
138
+ private operationQueue;
139
+ private destroyed;
140
+ constructor(initialState: ProductAgentState, adapter: ProductAgentRuntimeClientAdapter, model?: ProductAgentModel);
141
+ on<T extends ProductAgentRuntimeEventName>(eventName: T, listener: (payload: ProductAgentEventMap[T]) => void): () => void;
142
+ getState(): ProductAgentState;
143
+ updateProjection(state: ProductAgentState, model?: ProductAgentModel, sessionHistoryState?: ProductAgentQueryState<ProductAgentEntityQueryData<ProductAgentSessionHistoryEntry>>, interactions?: readonly ProductAgentInteraction[], account?: ProductAgentAccountProjection | null): void;
144
+ connect(): Promise<void>;
145
+ destroy(): void;
146
+ warmup(reason?: "panel_open" | "extension_install" | "composer_input"): Promise<void>;
147
+ recordWidgetLifecycle(action: ProductAgentWidgetLifecycleAction, trigger: ProductAgentWidgetLifecycleTrigger): void;
148
+ sendMessage(content: string, options?: {
149
+ attachments?: ProductAgentAttachment[];
150
+ clientMessageId?: string;
151
+ initiatedBy?: "pluno";
152
+ invocation?: ProductAgentInvocation | "pluno";
153
+ proactiveSuggestionQuestion?: string;
154
+ }): Promise<string | null>;
155
+ private sendMessageNow;
156
+ getModel(): ProductAgentModel | undefined;
157
+ setModel(model: ProductAgentModel): Promise<void>;
158
+ retryLastMessage(): boolean;
159
+ createLocalAttachment(file: File): ProductAgentAttachment;
160
+ stop(): Promise<void>;
161
+ startNewSession(options?: {
162
+ notifyTransport?: boolean;
163
+ }): Promise<void>;
164
+ listSessions(options?: {
165
+ cursor?: string | null;
166
+ limit?: number;
167
+ pinned?: boolean;
168
+ }): Promise<ProductAgentSessionHistoryPage>;
169
+ getSessionHistoryState(): ProductAgentQueryState<ProductAgentEntityQueryData<ProductAgentSessionHistoryEntry>>;
170
+ subscribeSessionHistory(listener: (state: ProductAgentQueryState<ProductAgentEntityQueryData<ProductAgentSessionHistoryEntry>>) => void): () => void;
171
+ refreshSessionHistory(): Promise<void>;
172
+ loadMoreSessionHistory(): Promise<void>;
173
+ setSessionPinned(sessionId: string, pinned: boolean): Promise<void>;
174
+ renameSession(sessionId: string, title: string): Promise<void>;
175
+ getInteractions(): readonly ProductAgentInteraction[];
176
+ subscribeInteractions(listener: (interactions: readonly ProductAgentInteraction[]) => void): () => void;
177
+ actOnInteraction(interactionId: string, action: ProductAgentInteractionAction, expectedRevision: number, input?: {
178
+ feedback?: string;
179
+ snoozeUntil?: string;
180
+ }): Promise<void>;
181
+ getAccount(): ProductAgentAccountProjection | null;
182
+ subscribeAccount(listener: (account: ProductAgentAccountProjection | null) => void): () => void;
183
+ refreshAccount(): Promise<void>;
184
+ loadSession(sessionId: string): Promise<void>;
185
+ stageProactiveSuggestionQuestion(question: string): Promise<void>;
186
+ private dispatch;
187
+ private enqueueOperation;
188
+ private emit;
189
+ }
@@ -0,0 +1,174 @@
1
+ export type ProductAgentQueryStatus = "not_requested" | "loading" | "ready" | "refreshing" | "loading_more" | "error";
2
+ export type ProductAgentQueryState<T> = {
3
+ key: string;
4
+ status: ProductAgentQueryStatus;
5
+ data: T | null;
6
+ error: string | null;
7
+ requestId: number;
8
+ updatedAt: number | null;
9
+ };
10
+ export type ProductAgentEntity = {
11
+ id: string;
12
+ };
13
+ export type ProductAgentEntityPage<T extends ProductAgentEntity> = {
14
+ entities: T[];
15
+ nextCursor: string | null;
16
+ };
17
+ export type ProductAgentEntityQueryData<T extends ProductAgentEntity> = {
18
+ entitiesById: Readonly<Record<string, T>>;
19
+ ids: readonly string[];
20
+ nextCursor: string | null;
21
+ };
22
+ export type ProductAgentQueryLoadMode = "replace" | "append";
23
+ export type ProductAgentQueryLoader<T> = (input: {
24
+ key: string;
25
+ cursor: string | null;
26
+ }) => Promise<T>;
27
+ type ProductAgentQueryListener<T> = (state: ProductAgentQueryState<T>) => void;
28
+ export declare function createProductAgentQueryState<T>(key: string): ProductAgentQueryState<T>;
29
+ export declare class ProductAgentQueryController<T> {
30
+ private readonly loader;
31
+ private readonly merge;
32
+ private state;
33
+ private readonly listeners;
34
+ private inFlight;
35
+ private trailingLoad;
36
+ constructor(key: string, loader: ProductAgentQueryLoader<T>, merge?: (current: T | null, next: T, mode: ProductAgentQueryLoadMode) => T);
37
+ getState(): ProductAgentQueryState<T>;
38
+ subscribe(listener: ProductAgentQueryListener<T>): () => void;
39
+ setKey(key: string): void;
40
+ reset(): void;
41
+ invalidate(): void;
42
+ load(mode?: ProductAgentQueryLoadMode, cursor?: string | null): Promise<void>;
43
+ update(updater: (data: T | null) => T | null): void;
44
+ private runLoads;
45
+ private publish;
46
+ }
47
+ export declare function normalizeProductAgentEntityPage<T extends ProductAgentEntity>(page: ProductAgentEntityPage<T>): ProductAgentEntityQueryData<T>;
48
+ export declare function mergeProductAgentEntityPages<T extends ProductAgentEntity>(current: ProductAgentEntityQueryData<T> | null, next: ProductAgentEntityQueryData<T>, mode: ProductAgentQueryLoadMode): ProductAgentEntityQueryData<T>;
49
+ export declare function selectProductAgentQueryEntities<T extends ProductAgentEntity>(data: ProductAgentEntityQueryData<T> | null): T[];
50
+ export type ProductAgentPromptAction = "dismiss" | "later" | "snooze" | "never" | "dont_show_again";
51
+ export type ProductAgentPromptDecisionScope = ProductAgentInteractionScope;
52
+ export type ProductAgentPromptDecision = {
53
+ promptKey: string;
54
+ category: string;
55
+ action: ProductAgentPromptAction;
56
+ scope: ProductAgentPromptDecisionScope;
57
+ decidedAt: string;
58
+ nextEligibleAt: string | null;
59
+ };
60
+ export type ProductAgentInteractionScope = {
61
+ level: "device" | "user" | "workspace" | "origin" | "tab" | "session" | "turn";
62
+ key: string;
63
+ };
64
+ export type ProductAgentInteractionStatus = "scheduled" | "presentable" | "pending" | "snoozed" | "resolved" | "suppressed" | "expired" | "error";
65
+ export type ProductAgentInteractionAction = ProductAgentPromptAction | "enable" | "run" | "edit" | "connect" | "submit_feedback";
66
+ export type ProductAgentInteractionPresentation = {
67
+ title: string | null;
68
+ body: string;
69
+ actionLabels: Partial<Record<ProductAgentInteractionAction, string>>;
70
+ };
71
+ export type ProductAgentInteraction<TKind extends string = string, TPayload = unknown> = {
72
+ id: string;
73
+ kind: TKind;
74
+ category: string;
75
+ scope: ProductAgentInteractionScope;
76
+ payload: TPayload;
77
+ presentation: ProductAgentInteractionPresentation;
78
+ eligible: boolean;
79
+ status: ProductAgentInteractionStatus;
80
+ allowedActions: readonly ProductAgentInteractionAction[];
81
+ decision: ProductAgentPromptDecision | null;
82
+ eligibleAt: string | null;
83
+ expiresAt: string | null;
84
+ revision: number;
85
+ };
86
+ export type ProductAgentWidgetPresentation = {
87
+ state: "hidden";
88
+ } | {
89
+ state: "minimized";
90
+ } | {
91
+ state: "visible_closed";
92
+ } | {
93
+ state: "visible_open";
94
+ };
95
+ export declare function resolveProductAgentWidgetPresentation(input: {
96
+ visible: boolean;
97
+ minimized: boolean;
98
+ open: boolean;
99
+ }): ProductAgentWidgetPresentation;
100
+ export type ProductAgentSafeUser = {
101
+ id: string;
102
+ email: string | null;
103
+ name: string | null;
104
+ };
105
+ export type ProductAgentSafeWorkspace = {
106
+ id: string;
107
+ name: string | null;
108
+ };
109
+ export type ProductAgentAuthProjection = {
110
+ status: "anonymous" | "checking";
111
+ user: null;
112
+ workspace: null;
113
+ } | {
114
+ status: "refreshing";
115
+ user: ProductAgentSafeUser;
116
+ workspace: ProductAgentSafeWorkspace | null;
117
+ } | {
118
+ status: "authenticated";
119
+ user: ProductAgentSafeUser;
120
+ workspace: ProductAgentSafeWorkspace | null;
121
+ } | {
122
+ status: "error";
123
+ user: null;
124
+ workspace: null;
125
+ errorCode: string;
126
+ message: string;
127
+ };
128
+ export type ProductAgentSubmissionGate = {
129
+ allowed: boolean;
130
+ reason: "allowed" | "authentication_required" | "workspace_required" | "connection_required" | "onboarding_required" | "credits_exhausted" | "payment_issue" | "update_required";
131
+ actions: readonly ("login" | "create_workspace" | "complete_onboarding" | "earn_credits" | "upgrade" | "update")[];
132
+ };
133
+ export type ProductAgentAccountProjection = {
134
+ auth?: ProductAgentAuthProjection;
135
+ actionUrls?: Partial<Record<ProductAgentSubmissionGate["actions"][number], string>>;
136
+ creditsUsed: number | null;
137
+ creditLimit: number | null;
138
+ creditsRemaining: number | null;
139
+ limitExceeded: boolean;
140
+ paymentIssue: string | null;
141
+ pricingUrl: string;
142
+ earnCreditsUrl: string;
143
+ onboardingIncomplete?: boolean;
144
+ onboardingUrl?: string;
145
+ usingPaidCreditFallback?: boolean;
146
+ submissionGate?: ProductAgentSubmissionGate;
147
+ };
148
+ export declare function reconcileProductAgentSubmissionGate(gate: ProductAgentSubmissionGate | undefined, errorCode: string | null | undefined): ProductAgentSubmissionGate;
149
+ export declare function hasProductAgentPaidCreditFallback(metadata: unknown): boolean;
150
+ export type ProductAgentBillingPresentation = {
151
+ state: "hidden";
152
+ } | {
153
+ state: "action_required";
154
+ reason: ProductAgentSubmissionGate["reason"];
155
+ } | {
156
+ state: "paid_credit_fallback";
157
+ } | {
158
+ state: "low_credits";
159
+ } | {
160
+ state: "usage";
161
+ };
162
+ export declare function resolveProductAgentBillingPresentation(account: ProductAgentAccountProjection | null | undefined): ProductAgentBillingPresentation;
163
+ export type ProductAgentComposerAction = {
164
+ action: "send" | "stop";
165
+ disabled: boolean;
166
+ };
167
+ export declare function resolveProductAgentComposerAction(input: {
168
+ hasRunningAssistantTurn: boolean;
169
+ hasDraftMessage: boolean;
170
+ hasPreSubmittedAttachment: boolean;
171
+ canStopRunningTurn: boolean;
172
+ canSubmitMessage: boolean;
173
+ }): ProductAgentComposerAction;
174
+ export {};
@@ -0,0 +1,57 @@
1
+ import { type ProductAgentEntity, type ProductAgentEntityQueryData, type ProductAgentQueryState } from "./runtimeState";
2
+ export type ProductAgentSessionHistoryEntity = ProductAgentEntity & {
3
+ isActive?: boolean;
4
+ isPinned?: boolean;
5
+ customTitle?: string | null;
6
+ };
7
+ export type ProductAgentSessionHistoryPage<T extends ProductAgentSessionHistoryEntity> = {
8
+ sessions: T[];
9
+ nextCursor: string | null;
10
+ };
11
+ export type ProductAgentSessionHistoryLoader<T extends ProductAgentSessionHistoryEntity> = (input: {
12
+ cursor: string | null;
13
+ limit: number;
14
+ pinned: boolean;
15
+ }) => Promise<ProductAgentSessionHistoryPage<T>>;
16
+ type PinnedOverride = {
17
+ pinned: boolean;
18
+ confirmAfterRefresh: number;
19
+ };
20
+ export declare class ProductAgentSessionHistoryManager<T extends ProductAgentSessionHistoryEntity> {
21
+ private readonly loadPage;
22
+ private readonly limit;
23
+ private readonly recentQuery;
24
+ private readonly pinnedQuery;
25
+ private readonly listeners;
26
+ private readonly optimisticEntities;
27
+ private readonly activityOverrides;
28
+ private readonly pinnedOverrides;
29
+ private readonly titleOverrides;
30
+ private refreshSequence;
31
+ private completedRefreshSequence;
32
+ private activityReconciliationScheduled;
33
+ constructor(key: string, loadPage: ProductAgentSessionHistoryLoader<T>, limit?: number);
34
+ getState(): ProductAgentQueryState<ProductAgentEntityQueryData<T>>;
35
+ subscribe(listener: (state: ProductAgentQueryState<ProductAgentEntityQueryData<T>>) => void): () => void;
36
+ getEntity(sessionId: string): T | null;
37
+ setKey(key: string): void;
38
+ refresh(): Promise<void>;
39
+ loadMore(cursor: string): Promise<void>;
40
+ addOptimistic(entity: T): void;
41
+ removeOptimistic(sessionId: string): void;
42
+ acknowledgeOptimistic(optimisticId: string, entity: T): void;
43
+ setActivity(sessionId: string, isActive: boolean): void;
44
+ setPinned(sessionId: string, pinned: boolean): PinnedOverride;
45
+ confirmPinned(sessionId: string, override: PinnedOverride): void;
46
+ rollbackPinned(sessionId: string, override: PinnedOverride, pinned: boolean): void;
47
+ setTitle(sessionId: string, title: string | null): void;
48
+ confirmTitle(sessionId: string): void;
49
+ private reconcileDurableEntities;
50
+ private loadAllPinned;
51
+ private applyOverrides;
52
+ private updateProjection;
53
+ private updateEntity;
54
+ private hasUnconfirmedActivityOverride;
55
+ private publish;
56
+ }
57
+ export {};
@@ -0,0 +1,25 @@
1
+ export type ProductAgentSessionRecoveryPollContext = {
2
+ sessionId: string;
3
+ identityScope: string;
4
+ };
5
+ type ProductAgentSessionRecoveryPollerOptions<Result> = {
6
+ poll: (context: ProductAgentSessionRecoveryPollContext) => Promise<Result>;
7
+ apply?: (result: Result, context: ProductAgentSessionRecoveryPollContext) => void | Promise<void>;
8
+ isActiveTurn: () => boolean;
9
+ activeIntervalMs: number;
10
+ idleIntervalMs: number;
11
+ maxFailureIntervalMs: number;
12
+ };
13
+ export declare class ProductAgentSessionRecoveryPoller<Result = void> {
14
+ private readonly options;
15
+ private timer;
16
+ private context;
17
+ private generation;
18
+ private failureCount;
19
+ constructor(options: ProductAgentSessionRecoveryPollerOptions<Result>);
20
+ start(sessionId: string, identityScope: string): void;
21
+ stop(): void;
22
+ private schedule;
23
+ private run;
24
+ }
25
+ export {};
@@ -4,6 +4,7 @@ export type ProductAgentTaskPageTitleDocument = {
4
4
  setTitle: (title: string) => void;
5
5
  observeTitle: (onTitleChanged: () => void) => () => void;
6
6
  };
7
+ export declare function formatProductAgentTaskPageTitle(title: string, status: ProductAgentTaskStatus | null): string;
7
8
  export declare class ProductAgentTaskPageTitleController {
8
9
  private readonly titleDocument;
9
10
  private status;
package/dist/widget.d.ts CHANGED
@@ -1,7 +1,10 @@
1
- import { PlunoProductAgent, type ProductAgentAttachment, type ProductAgentIntegrationAuthRequest, type ProductAgentPersonalChannelConnectionRequest, type ProductAgentInitOptions, type ProductAgentModel, type ProductAgentWidgetLifecycleTrigger } from "./index";
1
+ import { type ProductAgentAttachment, type ProductAgentIntegrationAuthRequest, type ProductAgentPersonalChannelConnectionRequest, type ProductAgentInitOptions, type ProductAgentModel, type ProductAgentRuntimeAdapters, type ProductAgentRuntimeClient, type ProductAgentWidgetLifecycleTrigger } from "./index";
2
2
  import { type PersonalProductAgentModel } from "./modelSelection";
3
+ import { type ProductAgentShareCandidate } from "./shareCard";
3
4
  import { type ActiveUsersCounterValue } from "./activeUsersCounter";
5
+ import { type ProductAgentInteraction, type ProductAgentAccountProjection } from "./runtimeState";
4
6
  export type ProductAgentWidgetOptions = {
7
+ runtimeClient?: ProductAgentRuntimeClient;
5
8
  layout?: "floating" | "page";
6
9
  mountTarget?: HTMLElement;
7
10
  token?: string;
@@ -46,29 +49,17 @@ export type ProductAgentWidgetOptions = {
46
49
  referralLinkLoader?: () => Promise<string>;
47
50
  billingStatus?: ProductAgentWidgetBillingStatus | null;
48
51
  billingStatusLoader?: () => Promise<ProductAgentWidgetBillingStatus | null>;
52
+ runtimeAdapters?: ProductAgentRuntimeAdapters;
49
53
  activeUsersLoader?: () => Promise<ActiveUsersCounterValue>;
50
54
  socialPostRewardsUrl?: string;
51
- loadSharePromptsDisabled?: () => boolean | Promise<boolean>;
52
- persistSharePromptsDisabled?: (disabled: boolean) => void | Promise<void>;
53
- sdkPreviewChannelId?: string;
55
+ extensionRuntime?: {
56
+ ownerId: string;
57
+ markHostOwner?: (host: HTMLElement) => void;
58
+ };
54
59
  initialDisplayState?: "shown" | "minimized";
55
60
  onDisplayStateChange?: (state: "shown" | "minimized", trigger: ProductAgentWidgetLifecycleTrigger) => void;
56
61
  onPanelOpenChange?: (open: boolean, trigger: ProductAgentWidgetLifecycleTrigger) => void;
57
62
  showLauncherMinimizeButton?: boolean;
58
- morningReport?: ProductAgentWidgetMorningReport | null;
59
- onMorningReportSnooze?: () => void;
60
- onMorningReportTaskStart?: () => void;
61
- proactiveSuggestion?: ProductAgentWidgetProactiveSuggestion | null;
62
- proactiveSuggestionPreparing?: boolean;
63
- onProactiveSuggestionDismiss?: (suggestionId: string, reason: "dismiss") => void;
64
- onProactiveSuggestionEdit?: (suggestionId: string) => void;
65
- onProactiveSuggestionNeverShow?: (suggestionId: string) => void;
66
- onProactiveSuggestionFeedbackSubmit?: (interactionId: string, suggestionId: string, genericQuestion: string, question: string, feedback: string) => void | Promise<void>;
67
- taskNotifications?: WidgetTaskNotificationsBridge;
68
- tabGroups?: WidgetTabGroupsBridge;
69
- integrationAuthStatusLoader?: (request: ProductAgentIntegrationAuthRequest) => Promise<ProductAgentIntegrationAuthStatus>;
70
- integrationAuthHandler?: (request: ProductAgentIntegrationAuthRequest) => Promise<void>;
71
- personalChannelConnectionHandler?: (request: ProductAgentPersonalChannelConnectionRequest) => Promise<void>;
72
63
  };
73
64
  export type ProductAgentIntegrationAuthStatus = "pending" | "completed" | "cancelled" | "expired";
74
65
  export type ProductAgentWidgetMorningReport = {
@@ -81,54 +72,36 @@ export type ProductAgentWidgetProactiveSuggestion = {
81
72
  genericQuestion: string;
82
73
  question: string;
83
74
  };
84
- type WidgetTaskNotificationsBridge = {
85
- getState: () => Promise<{
86
- enabled: boolean;
87
- neverSuggest: boolean;
88
- }>;
89
- enable: () => Promise<boolean>;
90
- dismissForever: () => Promise<void>;
91
- };
92
- type WidgetTabGroupsBridge = {
93
- getState: () => Promise<{
94
- permissionNeeded: boolean;
95
- }>;
96
- enable: () => Promise<void>;
97
- dismiss: () => Promise<void>;
98
- };
99
- export type ProductAgentWidgetBillingStatus = {
100
- creditsUsed: number | null;
101
- creditLimit: number | null;
102
- creditsRemaining: number | null;
103
- limitExceeded: boolean;
104
- paymentIssue: string | null;
105
- pricingUrl: string;
106
- earnCreditsUrl: string;
107
- onboardingIncomplete?: boolean;
108
- onboardingUrl?: string;
109
- usingPaidCreditFallback?: boolean;
110
- };
75
+ export type ProductAgentWidgetRuntimeInteraction = ProductAgentInteraction<"social_share", {
76
+ candidate: ProductAgentShareCandidate;
77
+ }> | ProductAgentInteraction<"task_notifications", {
78
+ enabled: boolean;
79
+ }> | ProductAgentInteraction<"tab_group_permission", {
80
+ permissionNeeded: boolean;
81
+ }> | ProductAgentInteraction<"proactive_suggestion", {
82
+ suggestion: ProductAgentWidgetProactiveSuggestion;
83
+ }> | ProductAgentInteraction<"morning_report", ProductAgentWidgetMorningReport> | ProductAgentInteraction<"integration_connection", {
84
+ request: ProductAgentIntegrationAuthRequest;
85
+ status: ProductAgentIntegrationAuthStatus | "checking" | "error";
86
+ error?: string | null;
87
+ }> | ProductAgentInteraction<"personal_channel_connection", {
88
+ request: ProductAgentPersonalChannelConnectionRequest;
89
+ }>;
90
+ export type ProductAgentWidgetBillingStatus = ProductAgentAccountProjection;
111
91
  export type ProductAgentWidgetHandle = {
112
- agent: PlunoProductAgent;
92
+ agent: ProductAgentRuntimeClient;
113
93
  host: HTMLElement;
114
94
  startNewChat: (options?: {
115
95
  notifyTransport?: boolean;
116
96
  }) => void;
117
97
  updateAppearance: (appearance: Pick<ProductAgentWidgetOptions, "accentColor" | "colorScheme" | "fontFamily" | "scribbleStyle">) => void;
118
- updateBillingStatus: (billingStatus: ProductAgentWidgetBillingStatus | null | undefined) => void;
119
- updateModel: (model: PersonalProductAgentModel) => void;
120
- updateAuthGate: (options: Pick<ProductAgentWidgetOptions, "loginRequired" | "loginButtonLabel" | "loginUrl" | "signupRequired" | "signupButtonLabel" | "signupUrl">) => void;
121
98
  openPanel: (initialValueOrOptions?: string | {
122
99
  focusComposer?: boolean;
123
100
  trigger?: ProductAgentWidgetLifecycleTrigger;
124
101
  }) => void;
125
102
  closePanel: (trigger?: ProductAgentWidgetLifecycleTrigger) => void;
126
103
  updateDisplayState: (displayState: "shown" | "minimized") => void;
127
- updateMorningReport: (morningReport: ProductAgentWidgetMorningReport | null | undefined) => void;
128
- updateProactiveSuggestion: (suggestion: ProductAgentWidgetProactiveSuggestion | null | undefined) => void;
129
- updateProactiveSuggestionPreparing: (preparing: boolean) => void;
130
104
  destroy: () => void;
131
105
  };
132
106
  export declare function createProductAgentPreviewBridgeWebSocketFactory(channelId: string): ProductAgentInitOptions["webSocketFactory"];
133
107
  export declare function mountPlunoProductAgentWidget(options?: ProductAgentWidgetOptions): Promise<ProductAgentWidgetHandle>;
134
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluno/product-agent-web",
3
- "version": "0.1.191",
3
+ "version": "0.1.196",
4
4
  "description": "Browser SDK and default widget for embedding Pluno Product Agent into customer web apps.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -24,9 +24,11 @@
24
24
  "INTEGRATION.md"
25
25
  ],
26
26
  "scripts": {
27
- "build": "vite build --mode sdk && vite build --mode widget && tsc --emitDeclarationOnly",
27
+ "build": "vite build --mode sdk && vite build --mode widget && vite build --mode runtime && tsc --emitDeclarationOnly",
28
28
  "check": "tsc --noEmit",
29
- "test": "vitest run"
29
+ "test": "vitest run",
30
+ "verify:package": "node scripts/verify-package-contents.mjs",
31
+ "prepack": "npm run verify:package"
30
32
  },
31
33
  "publishConfig": {
32
34
  "access": "public"
@@ -39,12 +41,17 @@
39
41
  "./widget": {
40
42
  "types": "./dist/widget.d.ts",
41
43
  "import": "./dist/product-agent-widget.js"
44
+ },
45
+ "./runtime": {
46
+ "types": "./dist/runtime.d.ts",
47
+ "import": "./dist/product-agent-runtime.js",
48
+ "require": "./dist/product-agent-runtime.cjs"
42
49
  }
43
50
  },
44
51
  "devDependencies": {
45
52
  "jsdom": "^26.1.0",
46
53
  "typescript": "^5.9.2",
47
- "vite": "^7.1.3",
48
- "vitest": "3.2.4"
54
+ "vite": "^7.3.6",
55
+ "vitest": "^3.2.7"
49
56
  }
50
57
  }