@pluno/product-agent-web 0.1.260 → 0.1.262

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 (44) hide show
  1. package/dist/adapters/web/accountPresentation.d.ts +4 -0
  2. package/dist/adapters/web/contextHttpError.d.ts +1 -0
  3. package/dist/adapters/web/conversationAdapters.d.ts +3 -1
  4. package/dist/adapters/web/deviceHints.d.ts +2 -0
  5. package/dist/adapters/web/featureHttp.d.ts +30 -0
  6. package/dist/adapters/web/featureLifecycle.d.ts +18 -0
  7. package/dist/adapters/web/featureOwner.d.ts +15 -0
  8. package/dist/adapters/web/featurePresentation.d.ts +5 -0
  9. package/dist/core/account/contracts.d.ts +56 -0
  10. package/dist/core/account/presentation.d.ts +49 -0
  11. package/dist/core/account/reducer.d.ts +2 -0
  12. package/dist/core/account/selectors.d.ts +3 -0
  13. package/dist/core/account/state.d.ts +2 -0
  14. package/dist/core/conversation/contracts.d.ts +1 -5
  15. package/dist/core/conversation/delivery.d.ts +1 -0
  16. package/dist/core/conversation/reducer.d.ts +4 -2
  17. package/dist/core/features/appearance.d.ts +10 -0
  18. package/dist/core/features/contracts.d.ts +492 -0
  19. package/dist/core/features/reducer.d.ts +16 -0
  20. package/dist/core/features/selectors.d.ts +15 -0
  21. package/dist/core/features/state.d.ts +2 -0
  22. package/dist/core/features/uiFlightEvidence.d.ts +29 -0
  23. package/dist/core/index.d.ts +11 -0
  24. package/dist/core/interactions/actions.d.ts +12 -0
  25. package/dist/core/interactions/contracts.d.ts +139 -0
  26. package/dist/core/interactions/preferenceOpenings.d.ts +22 -0
  27. package/dist/core/interactions/reducer.d.ts +6 -0
  28. package/dist/core/interactions/selectors.d.ts +25 -0
  29. package/dist/core/interactions/state.d.ts +2 -0
  30. package/dist/core/session-directory/membership.d.ts +3 -2
  31. package/dist/core/session-directory/reducer.d.ts +2 -1
  32. package/dist/index.d.ts +28 -16
  33. package/dist/product-agent-runtime.cjs +1 -1
  34. package/dist/product-agent-runtime.js +34 -26
  35. package/dist/product-agent-sdk.js +6711 -5098
  36. package/dist/product-agent-widget.js +6804 -5403
  37. package/dist/public/operationRoutes.d.ts +4 -1
  38. package/dist/runtime/composition.d.ts +10 -7
  39. package/dist/runtimeClient.d.ts +15 -0
  40. package/dist/runtimeState.d.ts +7 -51
  41. package/dist/themeColors.d.ts +7 -0
  42. package/dist/uiFlightRecorder.d.ts +2 -29
  43. package/package.json +1 -1
  44. package/dist/adapters/web/conversationInteractionAdapter.d.ts +0 -11
@@ -0,0 +1,4 @@
1
+ import type { PAAccountData, PAAccountState } from '../../core/account/contracts';
2
+ import type { ProductAgentAccountProjection } from '../../core/account/presentation';
3
+ export declare function accountData(presentation: ProductAgentAccountProjection, user: PAAccountData['user'], communityId: string | null): PAAccountData;
4
+ export declare function projectAccount(state: PAAccountState, sessionId?: string | null): ProductAgentAccountProjection | null;
@@ -0,0 +1 @@
1
+ export declare function contextHttpError(response: Response): Promise<Error>;
@@ -1,3 +1,4 @@
1
+ import type { PAJsonObject } from '../../core/protocol/json';
1
2
  import type { ConversationCancellationState } from "./conversationCancellation";
2
3
  import { type OperationTiming } from "../../operationTiming";
3
4
  import type { ProductAgentPrepareAttachmentUploadInput, ProductAgentAttachmentUpload } from "../../index";
@@ -32,8 +33,9 @@ export declare function createConversationPorts(options: Boundary & {
32
33
  now: () => number;
33
34
  onUploaded?: (sourceId: string, sessionId: string, attachment: PAUploadedAttachment) => Promise<void>;
34
35
  prepareUpload?: (input: ProductAgentPrepareAttachmentUploadInput) => Promise<ProductAgentAttachmentUpload>;
36
+ snapshotContext?: (sessionId: string) => PAJsonObject;
35
37
  persistUpload?: (input: ProductAgentPrepareAttachmentUploadInput, bytes: File) => Promise<Pick<ProductAgentAttachmentUpload, "sessionId" | "attachment">>;
36
- }): Omit<PAConversationPorts, "conversation.interactions">;
38
+ }): PAConversationPorts;
37
39
  export declare class ProductAgentConversationObservationAdapter {
38
40
  private readonly options;
39
41
  private readonly observations;
@@ -0,0 +1,2 @@
1
+ export declare function readDeviceHints(storage: Storage): Record<string, boolean>;
2
+ export declare function dismissDeviceHint(storage: Storage, id: string): void;
@@ -0,0 +1,30 @@
1
+ import type { ProductAgentHttpTransport } from './backendHttp';
2
+ import type { PAAccountData, PAFeatureAuthority, PAFeaturePreferences } from '../../core/account/contracts';
3
+ import type { PAFeatureResult, PAStage7Ports, PAFeatureQuery } from '../../core/features/contracts';
4
+ import type { PAPreferencePrompt, PAPreferencePrompts, PAUserDecision } from '../../core/interactions/contracts';
5
+ export declare function decodeFeaturePreferences(value: unknown): PAFeaturePreferences;
6
+ export declare function decodePreferencePrompt(value: unknown): PAPreferencePrompt;
7
+ export declare function decodePreferencePrompts(value: unknown): PAPreferencePrompts;
8
+ export declare function decodeUserDecision(value: unknown): PAUserDecision;
9
+ export type PAFeatureHttpOptions = Readonly<{
10
+ http: Pick<ProductAgentHttpTransport, 'request'>;
11
+ now: () => number;
12
+ authority: () => PAFeatureAuthority | null;
13
+ onContextStatusRead?: (event: Readonly<{
14
+ requestId: string;
15
+ origin: string;
16
+ trigger: string;
17
+ phase: 'started' | 'ready' | 'failed';
18
+ code?: string;
19
+ retryable?: boolean;
20
+ }>) => void;
21
+ sampleStyle?: (page: import('../../core/features/contracts').PAFeaturePage) => Promise<import('../../core/features/contracts').PAOriginAppearance>;
22
+ readAccount: (authority: PAFeatureAuthority) => Promise<PAAccountData>;
23
+ embedded: Readonly<{
24
+ appearance: (query: Extract<PAFeatureQuery, {
25
+ kind: 'originContext' | 'appearance';
26
+ }>) => Promise<PAFeatureResult>;
27
+ feedback: (message: string) => Promise<boolean>;
28
+ }>;
29
+ }>;
30
+ export declare function createFeatureHttpPorts(options: PAFeatureHttpOptions): Pick<PAStage7Ports, 'stage7.query' | 'stage7.mutate'>;
@@ -0,0 +1,18 @@
1
+ import type { PAClientRuntime } from '../../runtime/composition';
2
+ import type { PAFeatureAuthority } from '../../core/account/contracts';
3
+ import type { PAStage7Ports } from '../../core/features/contracts';
4
+ import type { PAFeatureName, PADeviceFact } from '../../core/interactions/contracts';
5
+ export declare function createFeatureScheduler(now: () => number): Readonly<{
6
+ wait: PAStage7Ports['stage7.wait'];
7
+ dispose: () => void;
8
+ }>;
9
+ export type PAFeatureDeviceAdapter = Readonly<{
10
+ authority: () => PAFeatureAuthority | null;
11
+ enabled: (feature: PAFeatureName) => boolean;
12
+ now: () => number;
13
+ check: (authority: PAFeatureAuthority, feature: PAFeatureName) => Promise<PADeviceFact>;
14
+ allow: (authority: PAFeatureAuthority, feature: PAFeatureName, requestId: string) => Promise<PADeviceFact>;
15
+ postpone: (authority: PAFeatureAuthority, feature: PAFeatureName, requestId: string) => Promise<PADeviceFact>;
16
+ }>;
17
+ export declare function createFeatureDevicePort(adapter: PAFeatureDeviceAdapter): PAStage7Ports['stage7.device'];
18
+ export declare function observeFeatureWork(runtime: PAClientRuntime, now: () => number): () => void;
@@ -0,0 +1,15 @@
1
+ import type { PAClientRuntime } from '../../runtime/composition';
2
+ import type { PAFeatureAuthority } from '../../core/account/contracts';
3
+ import type { PAFeatureMutation, PAFeatureQuery, PAFeatureResult, PAStage7Command } from '../../core/features/contracts';
4
+ export declare function initializeFeatureOwner(runtime: PAClientRuntime, authority: PAFeatureAuthority, now: number): Promise<void>;
5
+ export declare function featureQuery(runtime: PAClientRuntime, query: PAFeatureQuery, options?: {
6
+ force?: boolean;
7
+ }): Promise<PAFeatureResult>;
8
+ export declare function featureMutation(runtime: PAClientRuntime, mutation: PAFeatureMutation, requestId?: string): Promise<PAFeatureResult>;
9
+ export declare function observeContextRun(runtime: PAClientRuntime, runId: string, signal: AbortSignal, timeoutMs: number): Promise<import('../../core/features/contracts').PAContextStatus | null>;
10
+ export type FeatureAction = Omit<Extract<PAStage7Command, {
11
+ type: 'stage7.act';
12
+ }>, 'type' | 'authority' | 'now' | 'requestId' | 'sourceVersion'> & {
13
+ expectedSourceVersion?: number | null;
14
+ };
15
+ export declare function featureAction(runtime: PAClientRuntime, action: FeatureAction, newRequestId?: string): Promise<void>;
@@ -0,0 +1,5 @@
1
+ import type { PAStage7Slices } from '../../core/features/contracts';
2
+ import type { PAConversationState } from '../../core/conversation/contracts';
3
+ import type { PADirectoryState } from '../../core/session-directory/contracts';
4
+ import type { ProductAgentInteraction } from '../../runtimeState';
5
+ export declare function projectFeatureInteractions(state: PAStage7Slices, conversation: PAConversationState, directory: PADirectoryState, clientScopeId: string): readonly ProductAgentInteraction[];
@@ -0,0 +1,56 @@
1
+ import type { ProductAgentAccountProjection, ProductAgentSubmissionGate } from './presentation';
2
+ import type { PAClientCapabilityProfile, PAOperation } from '../kernel/capabilities';
3
+ import type { PAQueryState } from '../kernel/state';
4
+ export type PAFeatureAuthority = Readonly<{
5
+ authorityId: string;
6
+ generation: number;
7
+ userId: string;
8
+ communityId: string | null;
9
+ installationId: string | null;
10
+ profile: PAClientCapabilityProfile;
11
+ interactionAdapters?: Readonly<{
12
+ integrationAuth: boolean;
13
+ personalChannel: boolean;
14
+ }>;
15
+ }>;
16
+ export type PAFeaturePreferences = Readonly<{
17
+ taskNotificationsEnabled: boolean | null;
18
+ tabGroupingEnabled: boolean | null;
19
+ preferencesVersion: number;
20
+ scribbleStyleEnabled: boolean | null;
21
+ blockedOrigins: readonly string[];
22
+ personalInstructions: string | null;
23
+ securityPolicyVersion?: number;
24
+ }>;
25
+ export type PAAccountData = Readonly<{
26
+ presentation?: ProductAgentAccountProjection;
27
+ referralLink?: string;
28
+ plan?: string | null;
29
+ loadedAt?: string;
30
+ user: Readonly<{
31
+ id: string;
32
+ email: string | null;
33
+ name: string | null;
34
+ isSuperuser: boolean;
35
+ }> | null;
36
+ communityId: string | null;
37
+ workspaceName: string | null;
38
+ credits: number | null;
39
+ usage: number | null;
40
+ billing: 'available' | 'required' | 'exhausted' | 'unknown';
41
+ submissionAllowed: boolean;
42
+ hostedBrowserEligible: boolean | null;
43
+ }>;
44
+ export type PAAccountState = Readonly<{
45
+ authority: PAFeatureAuthority | null;
46
+ refusal: ProductAgentSubmissionGate | null;
47
+ paidFallbackBySession: Readonly<Record<string, boolean>>;
48
+ query: PAQueryState<string, PAAccountData>;
49
+ preferences: PAFeaturePreferences | null;
50
+ }>;
51
+ export type PAAccessDecision = Readonly<{
52
+ operation: PAOperation;
53
+ allowed: boolean;
54
+ reason: 'allowed' | 'capability' | 'authentication' | 'workspace' | 'billing' | 'unavailable' | 'blocked_origin' | 'device';
55
+ recovery: 'none' | 'login' | 'select_workspace' | 'billing' | 'refresh' | 'settings';
56
+ }>;
@@ -0,0 +1,49 @@
1
+ export type ProductAgentSafeUser = {
2
+ id: string;
3
+ email: string | null;
4
+ name: string | null;
5
+ };
6
+ export type ProductAgentSafeWorkspace = {
7
+ id: string;
8
+ name: string | null;
9
+ };
10
+ export type ProductAgentAuthProjection = {
11
+ status: "anonymous" | "checking";
12
+ user: null;
13
+ workspace: null;
14
+ } | {
15
+ status: "refreshing";
16
+ user: ProductAgentSafeUser;
17
+ workspace: ProductAgentSafeWorkspace | null;
18
+ } | {
19
+ status: "authenticated";
20
+ user: ProductAgentSafeUser;
21
+ workspace: ProductAgentSafeWorkspace | null;
22
+ } | {
23
+ status: "error";
24
+ user: null;
25
+ workspace: null;
26
+ errorCode: string;
27
+ message: string;
28
+ };
29
+ export type ProductAgentSubmissionGate = {
30
+ allowed: boolean;
31
+ reason: "allowed" | "authentication_required" | "workspace_required" | "connection_required" | "onboarding_required" | "credits_exhausted" | "payment_issue" | "update_required";
32
+ actions: readonly ("login" | "create_workspace" | "complete_onboarding" | "earn_credits" | "upgrade" | "update")[];
33
+ };
34
+ export type ProductAgentAccountProjection = {
35
+ auth?: ProductAgentAuthProjection;
36
+ actionUrls?: Partial<Record<ProductAgentSubmissionGate["actions"][number], string>>;
37
+ creditsUsed: number | null;
38
+ creditLimit: number | null;
39
+ creditsRemaining: number | null;
40
+ limitExceeded: boolean;
41
+ paymentIssue: string | null;
42
+ pricingUrl: string;
43
+ earnCreditsUrl: string;
44
+ onboardingIncomplete?: boolean;
45
+ onboardingUrl?: string;
46
+ usingPaidCreditFallback?: boolean;
47
+ submissionGate?: ProductAgentSubmissionGate;
48
+ };
49
+ export declare function reconcileProductAgentSubmissionGate(gate: ProductAgentSubmissionGate | undefined, errorCode: string | null | undefined): ProductAgentSubmissionGate;
@@ -0,0 +1,2 @@
1
+ import type { PAAccountState, PAFeaturePreferences } from './contracts';
2
+ export declare function mergeFeaturePreferences(state: PAAccountState, value: PAFeaturePreferences): PAAccountState;
@@ -0,0 +1,3 @@
1
+ import { type PAOperation } from '../kernel/capabilities';
2
+ import type { PAAccessDecision, PAAccountState } from './contracts';
3
+ export declare function selectAccountAccess(state: PAAccountState, operation: PAOperation, origin?: string | null, deviceAvailable?: boolean): PAAccessDecision;
@@ -0,0 +1,2 @@
1
+ import type { PAAccountState, PAFeatureAuthority } from './contracts';
2
+ export declare function createAccountState(authority?: PAFeatureAuthority | null): PAAccountState;
@@ -64,15 +64,11 @@ export type PAConversationSnapshotRequest = PADirectoryAuthority & Readonly<{
64
64
  before: string | null;
65
65
  refreshItemIds: readonly string[];
66
66
  }>;
67
- export type PAConversationInteractionHandoff = PADirectoryAuthority & Readonly<{
67
+ export type PAConversationInteractionSources = PADirectoryAuthority & Readonly<{
68
68
  sessionId: PASessionId;
69
69
  sources: readonly PAConversationInteractionSource[];
70
70
  }>;
71
71
  export type PAConversationEffects = PAConversationDeliveryEffects & {
72
- "conversation.interactions": {
73
- input: PAConversationInteractionHandoff;
74
- output: null;
75
- };
76
72
  "conversation.snapshot": {
77
73
  input: PAConversationSnapshotRequest;
78
74
  output: Readonly<{
@@ -18,5 +18,6 @@ export declare function scheduleConversationDelivery(state: PAConversationState)
18
18
  export declare function reduceConversationWithDelivery(state: PAConversationState, input: Input, directory: PADirectoryState, models: PAModelSelectionState): {
19
19
  state: PAConversationState;
20
20
  effects: PAEffect<PAConversationEffects>[];
21
+ interactionSources: import("./contracts").PAConversationInteractionSources | undefined;
21
22
  };
22
23
  export {};
@@ -2,7 +2,9 @@ import type { PAEffectResultEvent } from "../kernel/effects";
2
2
  import type { PAReduction } from "../kernel/reducer";
3
3
  import type { PAModelSelectionState } from "../model-selection/state";
4
4
  import type { PADirectoryState } from "../session-directory/contracts";
5
- import type { PAConversationCommand, PAConversationEffects, PAConversationEvent, PAConversationState, PAOwnedSubmission } from "./contracts";
5
+ import type { PAConversationInteractionSources, PAConversationCommand, PAConversationEffects, PAConversationEvent, PAConversationState, PAOwnedSubmission } from "./contracts";
6
6
  export declare function submissionHasLocalPresence(submission: PAOwnedSubmission, directory: PADirectoryState): boolean;
7
7
  export declare function synchronizeConversationDirectory(state: PAConversationState, directory: PADirectoryState): PAConversationState;
8
- export declare function reduceConversation(state: PAConversationState, input: PAConversationCommand | PAConversationEvent | PAEffectResultEvent<PAConversationEffects>, directory: PADirectoryState, models: PAModelSelectionState): PAReduction<PAConversationState, PAConversationEffects>;
8
+ export declare function reduceConversation(state: PAConversationState, input: PAConversationCommand | PAConversationEvent | PAEffectResultEvent<PAConversationEffects>, directory: PADirectoryState, models: PAModelSelectionState): PAReduction<PAConversationState, PAConversationEffects> & {
9
+ interactionSources?: PAConversationInteractionSources;
10
+ };
@@ -0,0 +1,10 @@
1
+ import type { PAFeatureAuthority } from '../account/contracts';
2
+ import type { PAEffect } from '../kernel/effects';
3
+ import { type PAFeatureQuery, type PAFeatureState, type PAStage7Effects, type PAStage7Input } from './contracts';
4
+ export declare function isAppearanceOperation(operation: {
5
+ kind: string;
6
+ }): boolean;
7
+ export declare function reduceAppearance(initial: PAFeatureState, authority: PAFeatureAuthority, input: PAStage7Input, queryKey: (query: PAFeatureQuery) => string): {
8
+ state: PAFeatureState;
9
+ effects: readonly PAEffect<PAStage7Effects>[];
10
+ };