@pluno/product-agent-web 0.1.230 → 0.1.233

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 (39) hide show
  1. package/dist/adapters/web/backendHttp.d.ts +16 -2
  2. package/dist/adapters/web/backendTransport.d.ts +3 -0
  3. package/dist/adapters/web/conversationAdapters.d.ts +59 -0
  4. package/dist/adapters/web/conversationCheckpoint.d.ts +16 -0
  5. package/dist/adapters/web/conversationInteractionAdapter.d.ts +11 -0
  6. package/dist/adapters/web/conversationPresentation.d.ts +4 -0
  7. package/dist/adapters/web/directoryAdapters.d.ts +2 -2
  8. package/dist/adapters/web/socketIOTransport.d.ts +4 -0
  9. package/dist/chatPresentation.d.ts +7 -0
  10. package/dist/core/conversation/contracts.d.ts +181 -1
  11. package/dist/core/conversation/delivery.d.ts +22 -0
  12. package/dist/core/conversation/deliveryContracts.d.ts +100 -0
  13. package/dist/core/conversation/display.d.ts +134 -0
  14. package/dist/core/conversation/reducer.d.ts +8 -0
  15. package/dist/core/conversation/selectors.d.ts +59 -0
  16. package/dist/core/conversation/state.d.ts +6 -0
  17. package/dist/core/index.d.ts +6 -0
  18. package/dist/core/model-selection/commands.d.ts +1 -1
  19. package/dist/displayedErrors.d.ts +1 -1
  20. package/dist/entrySurface.d.ts +2 -0
  21. package/dist/index.d.ts +48 -115
  22. package/dist/interactionManager.d.ts +3 -0
  23. package/dist/interruptState.d.ts +1 -1
  24. package/dist/operationTiming.d.ts +21 -0
  25. package/dist/product-agent-runtime.cjs +1 -1
  26. package/dist/product-agent-runtime.js +454 -266
  27. package/dist/product-agent-sdk.js +4197 -4655
  28. package/dist/product-agent-widget.js +8722 -9179
  29. package/dist/protocolTrace.d.ts +3 -0
  30. package/dist/public/operationRoutes.d.ts +2 -0
  31. package/dist/renderDiagnostics.d.ts +31 -0
  32. package/dist/responseDiagnostics.d.ts +1 -0
  33. package/dist/runtime/composition.d.ts +13 -5
  34. package/dist/runtime/modelSelection.d.ts +1 -1
  35. package/dist/runtimeClient.d.ts +20 -6
  36. package/dist/shareCard.d.ts +1 -0
  37. package/dist/uiFlightRecorder.d.ts +4 -1
  38. package/dist/uiInvariants.d.ts +1 -0
  39. package/package.json +1 -1
@@ -0,0 +1,59 @@
1
+ import type { PAConversationScopeId, PAViewId } from "../kernel/state";
2
+ import type { PADirectoryState } from "../session-directory/contracts";
3
+ import type { PAConversationProjection, PAConversationRecord, PAConversationSegment, PAConversationState } from "./contracts";
4
+ export declare function selectConversationScope(state: PAConversationState, directory: PADirectoryState, scope: PAConversationScopeId): PAConversationProjection;
5
+ export declare function selectComposerHandoff(projection: PAConversationProjection, viewId: PAViewId, rendererRevision: number): Readonly<{
6
+ viewId: PAViewId;
7
+ userMessageId: string;
8
+ acceptedRendererRevision: number;
9
+ }> | null;
10
+ export declare function selectConversationRetryTarget(projection: PAConversationProjection, explicitId?: string): {
11
+ type: "delivery";
12
+ userMessageId: string;
13
+ sessionId?: undefined;
14
+ } | {
15
+ type: "execution";
16
+ userMessageId: string;
17
+ sessionId: import("..").PASessionId;
18
+ } | null;
19
+ export declare function selectConversation(state: PAConversationState, directory: PADirectoryState): {
20
+ scopes: {
21
+ [k: string]: Readonly<{
22
+ preparation?: "pending" | "busy" | null;
23
+ selectionKey?: string;
24
+ isDraftSession: boolean;
25
+ proactiveQuestion: Readonly<{
26
+ id: string;
27
+ content: string;
28
+ }> | null;
29
+ followUps: readonly import("./display").PAConversationFollowUp[];
30
+ sessionId: import("..").PASessionId | null;
31
+ submissions: readonly import("./contracts").PAOwnedSubmission[];
32
+ deliveries: Readonly<Record<string, import("./deliveryContracts").PAConversationDelivery>>;
33
+ items: readonly import("./display").PADisplayItem[];
34
+ optimistic: readonly import("./contracts").PAOwnedSubmission[];
35
+ removedItems: Readonly<Record<string, string>>;
36
+ streamStates: Readonly<Record<string, import("./display").PAStreamLifecycle["state"] | "awaiting_content">>;
37
+ stop: (import("./contracts").PAConversationStop & Readonly<{
38
+ pending: boolean;
39
+ }>) | null;
40
+ segments: readonly PAConversationSegment[];
41
+ activity: Readonly<{
42
+ phase: import("./display").PAExecutionState["phase"] | "submitting" | "awaiting_execution";
43
+ activeItemId: string | null;
44
+ userMessageId?: string | null;
45
+ }>;
46
+ receipts: readonly Readonly<{
47
+ viewId: PAViewId;
48
+ userMessageId: string;
49
+ acceptedRendererRevision: number;
50
+ }>[];
51
+ }>;
52
+ };
53
+ };
54
+ export declare function isConversationTurnTerminal(record: PAConversationRecord, userMessageId: string | null): boolean;
55
+ export declare function selectConversationCompletion(projection: PAConversationProjection, record: PAConversationRecord | undefined): {
56
+ version: number;
57
+ userMessageIds: readonly string[];
58
+ answer: string;
59
+ } | null;
@@ -0,0 +1,6 @@
1
+ import { type PAAuthorityId, type PASessionId } from "../kernel/state";
2
+ import type { PAConversationRecord, PAConversationState } from "./contracts";
3
+ export declare function freezeConversationValue<T>(value: T): T;
4
+ export declare function ownConversationValue<T>(value: T): T;
5
+ export declare function createConversationState(authorityId?: PAAuthorityId, generation?: number): PAConversationState;
6
+ export declare function createConversationRecord(sessionId: PASessionId): PAConversationRecord;
@@ -1,5 +1,11 @@
1
1
  export * from "./browser-execution/contracts";
2
2
  export * from "./conversation/contracts";
3
+ export * from "./conversation/display";
4
+ export * from "./conversation/state";
5
+ export * from "./conversation/reducer";
6
+ export * from "./conversation/selectors";
7
+ export * from "./conversation/deliveryContracts";
8
+ export * from "./conversation/delivery";
3
9
  export * from "./interactions/contracts";
4
10
  export * from "./kernel/capabilities";
5
11
  export * from "./kernel/commands";
@@ -16,7 +16,7 @@ export type PAModelCommand = Readonly<{
16
16
  }> | Readonly<{
17
17
  type: "model.submission_capture";
18
18
  clientMessageId: string;
19
- requestedModel?: PAProductAgentModel;
19
+ requestedModel?: PAProductAgentModel | null;
20
20
  }> | Readonly<{
21
21
  type: "model.scope_close";
22
22
  }>);
@@ -1,3 +1,3 @@
1
1
  export declare function reportProductAgentTimelineJump(hasUserScrolled: boolean, report: (reason: string) => void): void;
2
- export declare function observeProductAgentDisplayedErrors(root: HTMLElement, report: (reason: string, errorFingerprint: string, displayedMessage: string) => void): () => void;
2
+ export declare function observeProductAgentDisplayedErrors(root: HTMLElement, report: (reason: string, errorFingerprint: string, displayedMessage: string, itemId?: string) => void): () => void;
3
3
  export declare function observeProductAgentDuplicateProactiveQuestions(root: HTMLElement, report: (reason: string, clientMessageId: string) => void): () => void;
@@ -0,0 +1,2 @@
1
+ import type { ProductAgentEntrySurface, ProductAgentLegacyEntrySurface } from "./index";
2
+ export declare function normalizeProductAgentEntrySurface(value: ProductAgentEntrySurface | ProductAgentLegacyEntrySurface | undefined): ProductAgentEntrySurface;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
+ import { type OperationTiming } from "./operationTiming";
1
2
  import type { ActiveUsersCounterValue } from "./activeUsersCounter";
3
+ import { type RenderedErrorEvidence, type UiInvariantEvidence } from "./renderDiagnostics";
2
4
  import type { ProductAgentTaskStatus } from "./taskPageTitle";
3
5
  import type { ProductAgentEntityQueryData, ProductAgentAccountProjection, ProductAgentSubmissionContext, ProductAgentInteraction, ProductAgentInteractionAction, ProductAgentQueryState } from "./runtimeState";
4
6
  export type ProductAgentModel = "anthropic/claude-opus-5" | "anthropic/claude-sonnet-5" | "deepseek/deepseek-chat-v3.1" | "deepseek/deepseek-v4-flash" | "gpt-5.4-nano" | "gpt-5.4-mini" | "gpt-5.4" | "gpt-5.6-luna" | "gpt-5.6-terra" | "gpt-5.6-sol";
@@ -50,6 +52,7 @@ export type ProductAgentMessage = {
50
52
  sharePromptAllowed?: boolean;
51
53
  attachments?: ProductAgentAttachment[];
52
54
  loading?: boolean;
55
+ streamState?: "open" | "awaiting_content" | "finished" | "failed" | "stopped";
53
56
  steered?: boolean;
54
57
  retryable?: boolean;
55
58
  integrationAuthRequest?: ProductAgentIntegrationAuthRequest;
@@ -130,6 +133,8 @@ export type ProductAgentAppearance = {
130
133
  };
131
134
  export type ProductAgentTurnPhase = "sending" | "starting" | "thinking";
132
135
  export type ProductAgentState = {
136
+ selectionKey?: string;
137
+ isDraftSession?: boolean;
133
138
  submissionContext?: ProductAgentSubmissionContext;
134
139
  activeUsersCount?: number | null;
135
140
  status: "idle" | "connecting" | "connected" | "reconnecting" | "closed" | "error";
@@ -139,7 +144,25 @@ export type ProductAgentState = {
139
144
  starterPromptsLoading: boolean;
140
145
  appearance: ProductAgentAppearance | null;
141
146
  messages: ProductAgentMessage[];
147
+ removedItems?: Readonly<Record<string, string>>;
148
+ segments?: readonly Readonly<{
149
+ id: string;
150
+ userMessageId: string | null;
151
+ activityIds: readonly string[];
152
+ outcomeIds: readonly string[];
153
+ collapsed: boolean;
154
+ }>[];
155
+ activity?: Readonly<{
156
+ phase: "idle" | "queued" | "thinking" | "steering" | "stopping" | "completed" | "failed" | "stopped" | "submitting" | "awaiting_execution";
157
+ activeItemId: string | null;
158
+ }>;
159
+ receipts?: readonly Readonly<{
160
+ viewId: string;
161
+ userMessageId: string;
162
+ acceptedRendererRevision: number;
163
+ }>[];
142
164
  activeScheduledFollowUps: ProductAgentActiveScheduledFollowUp[] | null;
165
+ historyPreparation?: "pending" | "busy" | null;
143
166
  isLoadingSession: boolean;
144
167
  assistantDraft: string;
145
168
  assistantDraftItemId: string | null;
@@ -276,8 +299,12 @@ export declare const PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT = ".pdf,.png
276
299
  export declare function calculateReconnectDelay(attempt: number, random?: () => number): number;
277
300
  export declare class ProductAgentSessionEngine {
278
301
  private readonly options;
279
- private readonly assistantDeltaReplayGuard;
280
302
  private readonly clientRuntime;
303
+ private conversationObservation;
304
+ private conversationAdapterGeneration;
305
+ private conversationUnsubscribe;
306
+ private composerRevision;
307
+ private submissionIntentRevision;
281
308
  private readonly listeners;
282
309
  private socket;
283
310
  private reconnectTimer;
@@ -291,6 +318,9 @@ export declare class ProductAgentSessionEngine {
291
318
  private token;
292
319
  private rejectedTransportToken;
293
320
  private refreshingDefaultCredentials;
321
+ private credentialRecovery;
322
+ private credentialRecoveryFailure;
323
+ private authenticationFailure;
294
324
  private tokenExpiresAtMs;
295
325
  private tokenRequest;
296
326
  private tokenAbortController;
@@ -302,18 +332,14 @@ export declare class ProductAgentSessionEngine {
302
332
  private queuedClientEvents;
303
333
  private readonly pendingRetainedCommandDeliveries;
304
334
  private pendingWidgetLifecycleEvents;
305
- private pendingPassiveWarmupEvent;
306
- private pendingComposerWarmup;
307
335
  private activeComposerWarmupId;
308
- private activeComposerWarmupScope;
309
- private pendingWarmupAckTimer;
336
+ private readonly authenticatingWarmupHints;
310
337
  private directoryAuthority;
311
338
  private readonly directoryHttp;
312
339
  private directoryScope;
313
340
  private directoryObservation;
314
341
  private directoryConversationScopeId;
315
342
  private directoryProvisionalId;
316
- private readonly conversationRecoveries;
317
343
  private account;
318
344
  private usingPaidCreditFallback;
319
345
  private readonly accountListeners;
@@ -324,57 +350,15 @@ export declare class ProductAgentSessionEngine {
324
350
  private integrationAuthStatusByRequestId;
325
351
  private integrationAuthErrorByRequestId;
326
352
  private tabGroupsPermissionNeeded;
327
- private sessionLoadRequestId;
328
- private sessionLoadRequestTimer;
329
- private pendingSessionSubscription;
330
- private sessionHistoryHydration;
331
- private sessionActivityRequestId;
332
353
  private readonly transportIdentity;
333
- private retryAttemptsByClientMessageId;
334
- private pendingDeliveryIssued;
335
- private queuedDeliveryRetryAttempt;
336
- private retryTimersByClientMessageId;
337
354
  private readonly reportedHealthSignalKeys;
338
355
  private readonly firstResponseTimersByClientMessageId;
339
- private lastProjectedTurnPhase;
340
- private lastProjectedTurnClientMessageId;
341
- private readonly clientMessageIdsByUserMessageItemId;
342
- private readonly backgroundSessionIds;
343
- private readonly backgroundClientMessageIds;
344
- private readonly deferredSessionUpdatedSessionIds;
345
- private readonly sessionTimelineCache;
346
- private readonly detachedSessionIds;
347
- private readonly detachedClientMessageIds;
348
- private readonly deferredDetachedSessionEvents;
349
- private readonly retryableFailureRunIdsAwaitingDone;
350
- private thinkingWatchdogTimer;
351
- private runAckWatchdogTimer;
352
- private runAckResyncRetryTimer;
353
- private pendingDeliveryAckTimer;
354
- private pendingDeliveryRetryTimer;
355
- private pendingDeliveryReconciliationRequestId;
356
- private pendingClientMessageId;
357
- private pendingUserMessageEvent;
358
- private failedUserMessageEvent;
359
356
  private readonly modelClientScopeId;
360
- private activeClientMessageId;
361
- private activeRunAckObserved;
362
- private activeResponseUserMessageId;
363
- private activeResponseRunId;
364
- private activeUserMessageEvent;
365
- private latestRecoverableClientMessageId;
366
357
  private lastUserMessagePageUrl;
367
- private thinkingWatchdogResyncAttemptsByClientMessageId;
368
- private retryableClientMessageId;
369
- private stagedProactiveSuggestionQuestionMessageId;
370
358
  private runtimeHelperJavascript;
371
359
  private readonly attachmentFiles;
372
360
  private sessionBrowserApisCleanup;
373
361
  private readonly activeBrowserToolCalls;
374
- private readonly cancelledSubmissions;
375
- private readonly stoppedTurns;
376
- private readonly pendingToolLoadingByCallId;
377
- private readonly terminalToolCallIds;
378
362
  private readonly nonTranscriptToolCallIds;
379
363
  private pageLifecycleCleanup;
380
364
  private transientStarterPromptsRequestInFlight;
@@ -382,15 +366,19 @@ export declare class ProductAgentSessionEngine {
382
366
  private locationChangeCleanup;
383
367
  private starterPromptUrlRefreshTimer;
384
368
  private lastStarterPromptPageUrl;
385
- private state;
369
+ private platformState;
370
+ private get state();
371
+ private set state(value);
386
372
  private constructor();
387
373
  static init(options: ProductAgentInitOptions): Promise<ProductAgentSessionEngine>;
388
- private createConversationRecovery;
389
374
  private createDirectoryAdapters;
375
+ private operationTimingReporter;
376
+ reportOperationTiming(timing: OperationTiming): void;
377
+ private initializeConversation;
390
378
  private initializeDirectory;
391
379
  private handleDirectoryTransportError;
380
+ private retainNavigatedConversation;
392
381
  private beginDirectoryProvisional;
393
- private selectDirectorySession;
394
382
  on<T extends EventName>(eventName: T, listener: Listener<T>): () => void;
395
383
  getState(): ProductAgentState;
396
384
  stageProactiveSuggestionQuestion(question: string): void;
@@ -411,22 +399,20 @@ export declare class ProductAgentSessionEngine {
411
399
  submittedAt?: number;
412
400
  }): Promise<string | null>;
413
401
  reportResponseVisibility(observation: ResponseVisibilityObservation): void;
414
- reportInvalidStateTransition(reason: string, clientMessageId?: string): void;
415
- reportDisplayedError(reason: string, errorFingerprint: string, displayedMessage?: string): void;
402
+ reportInvalidStateTransition(reason: string, clientMessageId?: string, uiInvariant?: UiInvariantEvidence): void;
403
+ reportDisplayedError(reason: string, errorFingerprint: string, displayedMessage?: string, renderedError?: RenderedErrorEvidence): void;
416
404
  getModel(): ProductAgentModel | undefined;
417
405
  setModel(model: ProductAgentModel): void;
418
406
  retryLastMessage(): boolean;
419
407
  createLocalAttachment(file: File): ProductAgentAttachment;
420
408
  uploadAttachment(file: File): Promise<ProductAgentAttachment>;
421
- private uploadAttachmentForMessage;
422
- private updateAttachmentInState;
423
409
  private prepareEmbedAttachmentUpload;
424
- private fetchEmbedAttachmentUpload;
425
- private getStopClientMessageId;
426
410
  stop(): void;
411
+ private stopConversation;
427
412
  startNewSession(options?: {
428
413
  notifyTransport?: boolean;
429
414
  }): void;
415
+ private resetConversationSelection;
430
416
  listSessions(options?: {
431
417
  cursor?: string | null;
432
418
  limit?: number;
@@ -447,21 +433,14 @@ export declare class ProductAgentSessionEngine {
447
433
  feedback?: string;
448
434
  snoozeUntil?: string;
449
435
  }): Promise<void>;
436
+ private createConversationInteractionPort;
450
437
  private refreshRuntimeInteractions;
451
438
  private rebuildRuntimeInteractions;
452
439
  getAccount(): ProductAgentAccountProjection | null;
453
440
  subscribeAccount(listener: (account: ProductAgentAccountProjection | null) => void): () => void;
454
441
  refreshAccount(): Promise<void>;
455
442
  loadSession(sessionId: string): void;
456
- private canLoadSessionHistoryOverHttp;
457
- private loadSessionHistoryOverHttp;
458
- private subscribeToSessionBeforeHistory;
459
- private autoLoadSessionActivity;
460
- private fetchSessionHistoryPageUntilCurrent;
461
- private fetchSessionHistoryPageOnce;
462
- private failSessionHistoryRequest;
463
443
  private send;
464
- private getUploadToken;
465
444
  private sendNow;
466
445
  private reportHealthSignal;
467
446
  private startFirstResponseTimer;
@@ -469,9 +448,6 @@ export declare class ProductAgentSessionEngine {
469
448
  private reportFirstResponseSlow;
470
449
  private clearFirstResponseTimer;
471
450
  private clearAllFirstResponseTimers;
472
- private rememberPendingDeliveryForRecovery;
473
- private persistCurrentPendingDeliveryRecovery;
474
- private clearPersistedPendingDelivery;
475
451
  private requestTransientStarterPrompts;
476
452
  private startStarterPromptUrlWatcher;
477
453
  private handleStarterPromptUrlChange;
@@ -480,56 +456,13 @@ export declare class ProductAgentSessionEngine {
480
456
  private flushQueuedClientEvents;
481
457
  private resetForAuthenticationScopeChange;
482
458
  private applyAuthenticatedDirectoryIdentity;
483
- private rememberSessionTimeline;
484
- private getCachedSessionTimeline;
459
+ private waitForAuthentication;
485
460
  private flushPendingWidgetLifecycleEvents;
486
- private flushPendingPassiveWarmup;
487
- private flushPendingComposerWarmup;
488
- private findStoppedTurn;
489
- private findStoppedTurnForEvent;
490
- private rememberDurablyStoppedTurn;
491
- private forgetSupersededTaskTabClosedTurn;
492
- private shouldIgnoreStoppedTurnEvent;
493
- private filterStoppedSnapshotItems;
494
461
  private handleServerEvent;
495
462
  private applyAccountSubmissionError;
496
463
  private updatePersonalModelFromSession;
497
464
  private updateAccountFallbackFromSession;
498
- private shouldIgnoreBackgroundSessionEvent;
499
- private updateInactiveSessionTimelineCache;
500
- private shouldIgnoreDetachedSessionEvent;
501
- private shouldDeferDetachedSessionEvent;
502
- private rememberCurrentRunAsDetached;
503
- private rememberCurrentRunAsBackground;
504
- private handleRetryableRecoveryError;
505
- private clearRetryTimers;
506
- private rememberUserMessageClientMessageIds;
507
- private clearSessionLoadRequest;
508
- private markThinkingProgress;
509
- private scheduleThinkingWatchdog;
510
- private clearThinkingWatchdog;
511
- private handleRunAck;
512
- private promotePendingDelivery;
513
- private promotePendingDeliveryFromResponseEvidence;
514
- private getResponseEvidenceUserMessageId;
515
- private getResponseEvidenceClientMessageId;
516
- private promotePendingDeliveryFromSnapshotResponseEvidence;
517
- private acknowledgePendingDeliveryAcceptance;
518
- private shouldDeferPendingDeliveryPromotion;
519
- private schedulePendingDeliveryAck;
520
- private retryPendingDelivery;
521
- private requestPendingDeliveryReconciliation;
522
- private failPendingDelivery;
523
- private clearPendingDeliveryTimers;
524
- private handleRunSteered;
525
- private scheduleRunAckWatchdog;
526
- private recoverMissedRunAck;
527
- private clearRunAckResyncRetryTimer;
528
- private clearRunAckTimers;
529
- private recoverStuckThinking;
530
- private resyncThinkingSession;
531
465
  private executeToolCall;
532
- private setToolMessageLoading;
533
466
  private startPageLifecycleRecovery;
534
467
  private installSessionBrowserApis;
535
468
  private cleanupSessionBrowserApis;
@@ -538,19 +471,19 @@ export declare class ProductAgentSessionEngine {
538
471
  private enqueueNetworkEvent;
539
472
  private scheduleReconnect;
540
473
  private replaceDefaultTransportCredentials;
474
+ private stopAuthentication;
475
+ private recoverHttpAuthentication;
476
+ private refreshCredentials;
541
477
  private refreshDefaultTransportCredentials;
542
478
  private startHeartbeat;
543
479
  private stopHeartbeat;
544
480
  private clearHeartbeatAckTimer;
545
- private clearPendingWarmupAckTimer;
546
- private clearPendingComposerWarmup;
547
481
  private clearSocketConnectTimer;
548
482
  private clearSocketAuthTimer;
549
483
  private clearSocketPhaseTimers;
550
484
  private replaceTimedOutSocket;
551
485
  private setState;
552
486
  private setReconnectingState;
553
- private applySessionRecoverySnapshot;
554
487
  private emit;
555
488
  }
556
489
  declare global {
@@ -12,6 +12,9 @@ export type ProductAgentInteractionDecisionStorage = {
12
12
  };
13
13
  export declare class ProductAgentInteractionManager {
14
14
  private readonly storage;
15
+ private conversationReader;
16
+ private sources;
17
+ private invalidateAuth;
15
18
  private decisions;
16
19
  private scheduledEligibility;
17
20
  private initialized;
@@ -1,2 +1,2 @@
1
1
  import type { ProductAgentState } from "./index";
2
- export declare function projectInterruptedState(state: ProductAgentState, stoppedAt: string): ProductAgentState;
2
+ export declare function projectInterruptedState<T extends Pick<ProductAgentState, "messages" | "assistantDraftRespondsToUserMessageId" | "activeResponseUserMessageId" | "segments" | "isLoadingSession">>(state: T, stoppedAt: string, phase?: "stopping" | "stopped", userMessageIds?: readonly string[]): T;
@@ -0,0 +1,21 @@
1
+ export declare const OPERATION_TIMING_STAGES: readonly ["submit", "stop", "staging_ipc", "send_ipc", "stop_ipc", "attachment_transfer", "tab_lookup", "tab_recovery", "session_recovery", "conversation_scope", "local_stage", "view_publication", "page_access", "authentication", "community", "preferences", "page_capture", "session_tabs", "context_ready", "first_frame", "checkpoint", "command_http", "http_authentication", "http_request", "receipt_http", "attachment_upload", "runtime_reading", "runtime_stopping", "runtime_progress", "runtime_stopped", "message_painted", "reading_painted", "stopping_painted", "progress_painted", "stopped_painted"];
2
+ export type OperationTimingStage = typeof OPERATION_TIMING_STAGES[number];
3
+ export type OperationTiming = {
4
+ entrySurface?: "extension_sidepanel" | "extension_widget" | "main_web_chat" | "embedded_widget" | "embedded_custom_ui" | "automation" | "mcp" | "whatsapp";
5
+ operation: "send" | "stop";
6
+ layer: "renderer" | "sdk" | "extension" | "http";
7
+ stage: OperationTimingStage;
8
+ status: "started" | "completed" | "failed" | "observed";
9
+ spanId: string;
10
+ requestId: string;
11
+ clientMessageId: string | null;
12
+ sessionId: string | null;
13
+ occurredAt: string;
14
+ durationMs: number;
15
+ };
16
+ export declare function isOperationTiming(value: unknown): value is OperationTiming;
17
+ export declare function createOperationTimer(report: ((timing: OperationTiming) => void) | undefined, identity: Pick<OperationTiming, "operation" | "layer" | "requestId" | "clientMessageId" | "sessionId" | "entrySurface">): {
18
+ mark: (stage: OperationTimingStage) => void;
19
+ measure<T>(stage: OperationTimingStage, work: () => Promise<T>): Promise<T>;
20
+ };
21
+ export declare function batchOperationTimings(report: (timings: OperationTiming[]) => void): (timing: OperationTiming) => void;