@kibee/contracts 0.2.0 → 0.7.0
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.
- package/dist/index.d.mts +260 -1
- package/dist/index.d.ts +260 -1
- package/dist/index.js +66 -2
- package/dist/index.mjs +59 -1
- package/package.json +7 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,49 @@
|
|
|
1
|
+
type WidgetDockPreset = "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
2
|
+
type WidgetDockPosition = WidgetDockPreset | {
|
|
3
|
+
preset: WidgetDockPreset;
|
|
4
|
+
offsetX?: number;
|
|
5
|
+
offsetY?: number;
|
|
6
|
+
};
|
|
7
|
+
type AvatarMode = "default" | "preset" | "custom";
|
|
8
|
+
type AvatarPresetId = "orb" | "ring";
|
|
9
|
+
interface WidgetAvatarConfig {
|
|
10
|
+
mode: AvatarMode;
|
|
11
|
+
preset?: AvatarPresetId;
|
|
12
|
+
assetUrl?: string;
|
|
13
|
+
}
|
|
14
|
+
interface WidgetConfigResponse {
|
|
15
|
+
dockPosition: WidgetDockPosition;
|
|
16
|
+
dockSize: number;
|
|
17
|
+
theme: {
|
|
18
|
+
primary: string;
|
|
19
|
+
tooltipBg: string;
|
|
20
|
+
tooltipColor: string;
|
|
21
|
+
};
|
|
22
|
+
avatar: WidgetAvatarConfig;
|
|
23
|
+
}
|
|
24
|
+
/** Flat keys persisted in tenants.settings JSONB */
|
|
25
|
+
interface WidgetSettingsRecord {
|
|
26
|
+
dockPosition?: WidgetDockPreset;
|
|
27
|
+
dockSize?: number;
|
|
28
|
+
primaryColor?: string;
|
|
29
|
+
tooltipBg?: string;
|
|
30
|
+
tooltipColor?: string;
|
|
31
|
+
avatarMode?: AvatarMode;
|
|
32
|
+
avatarPreset?: AvatarPresetId;
|
|
33
|
+
avatarAssetUrl?: string;
|
|
34
|
+
avatarAssetKey?: string;
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
}
|
|
37
|
+
declare function isAvatarMode(value: unknown): value is AvatarMode;
|
|
38
|
+
declare function isAvatarPresetId(value: unknown): value is AvatarPresetId;
|
|
39
|
+
declare function parseWidgetAvatar(settings: WidgetSettingsRecord): WidgetAvatarConfig;
|
|
40
|
+
declare function buildWidgetConfigResponse(settings: WidgetSettingsRecord): WidgetConfigResponse;
|
|
41
|
+
/** Map widget avatar config to ThreeBeeRenderer constructor options. */
|
|
42
|
+
declare function resolveRendererAvatarOptions(avatar: WidgetAvatarConfig): {
|
|
43
|
+
avatarPreset: "bee" | AvatarPresetId;
|
|
44
|
+
assetUrl?: string;
|
|
45
|
+
};
|
|
46
|
+
|
|
1
47
|
/**
|
|
2
48
|
* Frozen Sprint 1 contract. Edits require joint sign-off from Track A
|
|
3
49
|
* (broker) and Track B (macOS) leads.
|
|
@@ -168,6 +214,28 @@ interface IdentityResponse {
|
|
|
168
214
|
issuedAt: number;
|
|
169
215
|
}
|
|
170
216
|
|
|
217
|
+
/** Trust scope of a memory write. In Sprint 5, all writes hardcode "personal".
|
|
218
|
+
* Sprint 6 introduces the tenant-scoped writer during the `tenant:attach` flow. */
|
|
219
|
+
type MemoryScope = "personal" | "tenant-scoped";
|
|
220
|
+
/** A single recalled memory entry. Returned by `GET /v1/memory/recent`. */
|
|
221
|
+
interface MemoryRecallItem {
|
|
222
|
+
/** mem0 entry id — opaque, used as React key on the client. */
|
|
223
|
+
id: string;
|
|
224
|
+
/** mem0-derived short summary (e.g. "Asked about carbon credits on Carbon Hub"). */
|
|
225
|
+
topic: string;
|
|
226
|
+
/** Surface where the memory was recorded — drives the "On X yesterday" badge. */
|
|
227
|
+
surface: SurfaceId;
|
|
228
|
+
/** ISO 8601 timestamp of when the memory was created. */
|
|
229
|
+
capturedAt: string;
|
|
230
|
+
}
|
|
231
|
+
/** Response envelope for `GET /v1/memory/recent`. */
|
|
232
|
+
interface MemoryRecallResponse {
|
|
233
|
+
items: MemoryRecallItem[];
|
|
234
|
+
/** True when mem0 was unreachable / timed out and the items list is incomplete or empty.
|
|
235
|
+
* Clients should treat as empty (silent open) rather than show stale data. */
|
|
236
|
+
degraded?: boolean;
|
|
237
|
+
}
|
|
238
|
+
|
|
171
239
|
type HighlightVariant = "pulse" | "ring" | "soft";
|
|
172
240
|
interface TargetRef {
|
|
173
241
|
kibeeId?: string;
|
|
@@ -583,6 +651,197 @@ interface WidgetConfig {
|
|
|
583
651
|
tooltipBg: string;
|
|
584
652
|
tooltipColor: string;
|
|
585
653
|
};
|
|
654
|
+
avatar?: WidgetAvatarConfig;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/** A row in the per-workspace allowed-domains table. Shown in the admin UI
|
|
658
|
+
* and consumed by the bridge JWT auth path during the trust handshake. */
|
|
659
|
+
interface AllowedDomain {
|
|
660
|
+
id: string;
|
|
661
|
+
workspaceId: string;
|
|
662
|
+
/** Apex domain only (e.g. "acme.com"). Apex-matches subdomains at runtime. */
|
|
663
|
+
domain: string;
|
|
664
|
+
/** Auth0 sub of the admin who added this entry. */
|
|
665
|
+
createdBy: string;
|
|
666
|
+
/** ISO 8601. */
|
|
667
|
+
createdAt: string;
|
|
668
|
+
}
|
|
669
|
+
/** Response for `GET /v1/workspace/allowlist/check?domain=X`.
|
|
670
|
+
* When >1 workspace allowlists the same domain for the same visitor,
|
|
671
|
+
* `workspaces` returns all matches and the macOS Buddy shows a picker. */
|
|
672
|
+
interface AllowlistCheckResponse {
|
|
673
|
+
allowed: boolean;
|
|
674
|
+
workspaces?: Array<{
|
|
675
|
+
id: string;
|
|
676
|
+
name: string;
|
|
677
|
+
}>;
|
|
678
|
+
}
|
|
679
|
+
/** Payload carried by `tenant:attach` and `tenant:detach` BridgeEnvelope.
|
|
680
|
+
* `attachedAt` mirrors the original attach time even on detach so telemetry
|
|
681
|
+
* can compute durationMs server-side. */
|
|
682
|
+
interface TenantAttachPayload {
|
|
683
|
+
workspaceId: string;
|
|
684
|
+
domain: string;
|
|
685
|
+
attachedAt: string;
|
|
686
|
+
}
|
|
687
|
+
/** Response for `GET /v1/tenant/flows`. Returns published flows for the
|
|
688
|
+
* workspace identified by `claims.tenantId` on the bridge JWT. */
|
|
689
|
+
interface TenantFlowsResponse {
|
|
690
|
+
flows: FlowDefinition[];
|
|
691
|
+
}
|
|
692
|
+
type FlowStep = {
|
|
693
|
+
kind: "web_tooltip";
|
|
694
|
+
selector: string;
|
|
695
|
+
instruction: string;
|
|
696
|
+
onPageId?: string;
|
|
697
|
+
} | {
|
|
698
|
+
kind: "desktop_click";
|
|
699
|
+
target: {
|
|
700
|
+
role: string;
|
|
701
|
+
label: string;
|
|
702
|
+
axPath: string;
|
|
703
|
+
};
|
|
704
|
+
modifiers: ReadonlyArray<"shift" | "control" | "option" | "command">;
|
|
705
|
+
description?: string;
|
|
706
|
+
fallbackCoord?: {
|
|
707
|
+
x: number;
|
|
708
|
+
y: number;
|
|
709
|
+
};
|
|
710
|
+
};
|
|
711
|
+
type CaptureStatus = "pending" | "promoted" | "rejected" | "withdrawn";
|
|
712
|
+
interface CaptureSummary {
|
|
713
|
+
id: string;
|
|
714
|
+
workspaceId: string;
|
|
715
|
+
captorVisitorId: string;
|
|
716
|
+
signature: string;
|
|
717
|
+
stepCount: number;
|
|
718
|
+
durationMs: number;
|
|
719
|
+
status: CaptureStatus;
|
|
720
|
+
promotedFlowId?: string;
|
|
721
|
+
rejectionReason?: string;
|
|
722
|
+
createdAt: string;
|
|
723
|
+
}
|
|
724
|
+
interface CaptureUploadPayload {
|
|
725
|
+
v: 2;
|
|
726
|
+
visitorId: string;
|
|
727
|
+
scope: "tenant-scoped";
|
|
728
|
+
capturedAt: string;
|
|
729
|
+
durationMs: number;
|
|
730
|
+
aborted: boolean;
|
|
731
|
+
steps: ReadonlyArray<{
|
|
732
|
+
ts: number;
|
|
733
|
+
type: "mousedown";
|
|
734
|
+
button: 0 | 1 | 2;
|
|
735
|
+
modifiers: ReadonlyArray<string>;
|
|
736
|
+
target: {
|
|
737
|
+
role: string;
|
|
738
|
+
label: string;
|
|
739
|
+
axPath: string;
|
|
740
|
+
};
|
|
741
|
+
fallbackCoord: {
|
|
742
|
+
x: number;
|
|
743
|
+
y: number;
|
|
744
|
+
};
|
|
745
|
+
}>;
|
|
746
|
+
}
|
|
747
|
+
interface CaptureUploadResponse {
|
|
748
|
+
captureId: string;
|
|
749
|
+
signature: string;
|
|
750
|
+
}
|
|
751
|
+
interface CaptureUploadEnvelope {
|
|
752
|
+
payload: CaptureUploadPayload;
|
|
753
|
+
warnings?: ReadonlyArray<string>;
|
|
754
|
+
}
|
|
755
|
+
interface CandidateGroup {
|
|
756
|
+
signature: string;
|
|
757
|
+
captures: ReadonlyArray<CaptureSummary>;
|
|
758
|
+
proposedTitle: string;
|
|
759
|
+
representativeId: string;
|
|
760
|
+
}
|
|
761
|
+
interface PromoteCandidatePayload {
|
|
762
|
+
editedSteps: ReadonlyArray<FlowStep>;
|
|
763
|
+
title: string;
|
|
764
|
+
pageId?: string;
|
|
765
|
+
audience?: string;
|
|
766
|
+
introMessage?: string;
|
|
767
|
+
replaceFlowId?: string;
|
|
768
|
+
}
|
|
769
|
+
type AuditAction = "capture.uploaded" | "capture.withdrawn" | "capture.promoted" | "capture.rejected" | "capture.edited" | "flag.flipped" | "slo.token.minted";
|
|
770
|
+
interface AuditEvent {
|
|
771
|
+
id: string;
|
|
772
|
+
workspaceId: string;
|
|
773
|
+
actor: {
|
|
774
|
+
kind: "visitor" | "admin" | "system";
|
|
775
|
+
id: string;
|
|
776
|
+
};
|
|
777
|
+
action: AuditAction;
|
|
778
|
+
target: {
|
|
779
|
+
kind: "capture" | "flow" | "flag";
|
|
780
|
+
id: string;
|
|
781
|
+
};
|
|
782
|
+
metadata?: Record<string, unknown>;
|
|
783
|
+
ts: string;
|
|
784
|
+
}
|
|
785
|
+
interface DiffPreview {
|
|
786
|
+
matchKind: "new" | "update";
|
|
787
|
+
matchedFlowId?: string;
|
|
788
|
+
matchedFlowTitle?: string;
|
|
789
|
+
stepDiff: ReadonlyArray<{
|
|
790
|
+
kind: "added" | "removed" | "changed" | "unchanged";
|
|
791
|
+
step: FlowStep;
|
|
792
|
+
}>;
|
|
793
|
+
}
|
|
794
|
+
interface FeatureFlag {
|
|
795
|
+
key: string;
|
|
796
|
+
defaultValue: boolean;
|
|
797
|
+
description: string;
|
|
798
|
+
createdAt: string;
|
|
799
|
+
updatedAt: string;
|
|
586
800
|
}
|
|
801
|
+
interface FeatureFlagOverride {
|
|
802
|
+
workspaceId: string;
|
|
803
|
+
key: string;
|
|
804
|
+
value: boolean;
|
|
805
|
+
createdAt: string;
|
|
806
|
+
updatedAt: string;
|
|
807
|
+
}
|
|
808
|
+
interface ResolvedFlagSet {
|
|
809
|
+
workspaceId: string;
|
|
810
|
+
flags: Record<string, boolean>;
|
|
811
|
+
fetchedAt: string;
|
|
812
|
+
}
|
|
813
|
+
interface SloWindow {
|
|
814
|
+
captureUploadSuccessRate: number;
|
|
815
|
+
captureUploadCount: number;
|
|
816
|
+
tenantAttachDeniedRate: number;
|
|
817
|
+
tenantAttachAttemptCount: number;
|
|
818
|
+
adminPromotionLatencyP50Ms: number;
|
|
819
|
+
adminPromotionLatencyP95Ms: number;
|
|
820
|
+
bridgeUptimePerVisitorMedian: number;
|
|
821
|
+
replayFallbackRate: number;
|
|
822
|
+
replayAttemptCount: number;
|
|
823
|
+
}
|
|
824
|
+
interface SloSnapshot {
|
|
825
|
+
computedAt: string;
|
|
826
|
+
workspaceId: string;
|
|
827
|
+
windows: {
|
|
828
|
+
last24h: SloWindow;
|
|
829
|
+
last7d: SloWindow;
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
declare const SLO_THRESHOLDS: {
|
|
833
|
+
readonly captureUploadSuccessRate: {
|
|
834
|
+
readonly min: 0.99;
|
|
835
|
+
};
|
|
836
|
+
readonly tenantAttachDeniedRate: {
|
|
837
|
+
readonly max: 0.01;
|
|
838
|
+
};
|
|
839
|
+
readonly adminPromotionLatencyP95Ms: {
|
|
840
|
+
readonly max: 2000;
|
|
841
|
+
};
|
|
842
|
+
readonly bridgeUptimePerVisitorMedian: {
|
|
843
|
+
readonly min: 0.99;
|
|
844
|
+
};
|
|
845
|
+
};
|
|
587
846
|
|
|
588
|
-
export { type AdminSessionSummary, type AnalyticsEvent, BUDDY_TRANSITIONS, type BridgeClaims, type BridgeEnvelope, type BridgeEventType, type BuddyState, type ChatMessage, type ChatMode, type ChatSender, type CrossSiteFlowQueueItem, type CrossSiteFlowStep, type DockInlineAnchor, type DockPositionConfig, type DockPositionPreset, type EventMetadata, type FlowCommand, type FlowDefinition, type FlowMoveOptions, type HighlightVariant, type IdentityRequest, type IdentityResponse, type IntentMatch, type KiBeePairAccept, type KiBeePairReject, type KiBeePairRequest, type MessageTemplate, type PairingState, type PushFlowRequest, type PushTargetsRequest, type RecoveryRequest, type RecoveryResponse, type RegisteredTarget, type ResolveIntentRequest, type SessionState, type StartSessionRequest, type SurfaceId, type TargetRef, type TrackEventRequest, type VisibleTarget, type VisitorIdentity, type VisitorPollResponse, type WidgetConfig, canTransition, isBridgeEnvelope };
|
|
847
|
+
export { type AdminSessionSummary, type AllowedDomain, type AllowlistCheckResponse, type AnalyticsEvent, type AuditAction, type AuditEvent, type AvatarMode, type AvatarPresetId, BUDDY_TRANSITIONS, type BridgeClaims, type BridgeEnvelope, type BridgeEventType, type BuddyState, type CandidateGroup, type CaptureStatus, type CaptureSummary, type CaptureUploadEnvelope, type CaptureUploadPayload, type CaptureUploadResponse, type ChatMessage, type ChatMode, type ChatSender, type CrossSiteFlowQueueItem, type CrossSiteFlowStep, type DiffPreview, type DockInlineAnchor, type DockPositionConfig, type DockPositionPreset, type EventMetadata, type FeatureFlag, type FeatureFlagOverride, type FlowCommand, type FlowDefinition, type FlowMoveOptions, type FlowStep, type HighlightVariant, type IdentityRequest, type IdentityResponse, type IntentMatch, type KiBeePairAccept, type KiBeePairReject, type KiBeePairRequest, type MemoryRecallItem, type MemoryRecallResponse, type MemoryScope, type MessageTemplate, type PairingState, type PromoteCandidatePayload, type PushFlowRequest, type PushTargetsRequest, type RecoveryRequest, type RecoveryResponse, type RegisteredTarget, type ResolveIntentRequest, type ResolvedFlagSet, SLO_THRESHOLDS, type SessionState, type SloSnapshot, type SloWindow, type StartSessionRequest, type SurfaceId, type TargetRef, type TenantAttachPayload, type TenantFlowsResponse, type TrackEventRequest, type VisibleTarget, type VisitorIdentity, type VisitorPollResponse, type WidgetAvatarConfig, type WidgetConfig, type WidgetConfigResponse, type WidgetDockPosition, type WidgetDockPreset, type WidgetSettingsRecord, buildWidgetConfigResponse, canTransition, isAvatarMode, isAvatarPresetId, isBridgeEnvelope, parseWidgetAvatar, resolveRendererAvatarOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,49 @@
|
|
|
1
|
+
type WidgetDockPreset = "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
2
|
+
type WidgetDockPosition = WidgetDockPreset | {
|
|
3
|
+
preset: WidgetDockPreset;
|
|
4
|
+
offsetX?: number;
|
|
5
|
+
offsetY?: number;
|
|
6
|
+
};
|
|
7
|
+
type AvatarMode = "default" | "preset" | "custom";
|
|
8
|
+
type AvatarPresetId = "orb" | "ring";
|
|
9
|
+
interface WidgetAvatarConfig {
|
|
10
|
+
mode: AvatarMode;
|
|
11
|
+
preset?: AvatarPresetId;
|
|
12
|
+
assetUrl?: string;
|
|
13
|
+
}
|
|
14
|
+
interface WidgetConfigResponse {
|
|
15
|
+
dockPosition: WidgetDockPosition;
|
|
16
|
+
dockSize: number;
|
|
17
|
+
theme: {
|
|
18
|
+
primary: string;
|
|
19
|
+
tooltipBg: string;
|
|
20
|
+
tooltipColor: string;
|
|
21
|
+
};
|
|
22
|
+
avatar: WidgetAvatarConfig;
|
|
23
|
+
}
|
|
24
|
+
/** Flat keys persisted in tenants.settings JSONB */
|
|
25
|
+
interface WidgetSettingsRecord {
|
|
26
|
+
dockPosition?: WidgetDockPreset;
|
|
27
|
+
dockSize?: number;
|
|
28
|
+
primaryColor?: string;
|
|
29
|
+
tooltipBg?: string;
|
|
30
|
+
tooltipColor?: string;
|
|
31
|
+
avatarMode?: AvatarMode;
|
|
32
|
+
avatarPreset?: AvatarPresetId;
|
|
33
|
+
avatarAssetUrl?: string;
|
|
34
|
+
avatarAssetKey?: string;
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
}
|
|
37
|
+
declare function isAvatarMode(value: unknown): value is AvatarMode;
|
|
38
|
+
declare function isAvatarPresetId(value: unknown): value is AvatarPresetId;
|
|
39
|
+
declare function parseWidgetAvatar(settings: WidgetSettingsRecord): WidgetAvatarConfig;
|
|
40
|
+
declare function buildWidgetConfigResponse(settings: WidgetSettingsRecord): WidgetConfigResponse;
|
|
41
|
+
/** Map widget avatar config to ThreeBeeRenderer constructor options. */
|
|
42
|
+
declare function resolveRendererAvatarOptions(avatar: WidgetAvatarConfig): {
|
|
43
|
+
avatarPreset: "bee" | AvatarPresetId;
|
|
44
|
+
assetUrl?: string;
|
|
45
|
+
};
|
|
46
|
+
|
|
1
47
|
/**
|
|
2
48
|
* Frozen Sprint 1 contract. Edits require joint sign-off from Track A
|
|
3
49
|
* (broker) and Track B (macOS) leads.
|
|
@@ -168,6 +214,28 @@ interface IdentityResponse {
|
|
|
168
214
|
issuedAt: number;
|
|
169
215
|
}
|
|
170
216
|
|
|
217
|
+
/** Trust scope of a memory write. In Sprint 5, all writes hardcode "personal".
|
|
218
|
+
* Sprint 6 introduces the tenant-scoped writer during the `tenant:attach` flow. */
|
|
219
|
+
type MemoryScope = "personal" | "tenant-scoped";
|
|
220
|
+
/** A single recalled memory entry. Returned by `GET /v1/memory/recent`. */
|
|
221
|
+
interface MemoryRecallItem {
|
|
222
|
+
/** mem0 entry id — opaque, used as React key on the client. */
|
|
223
|
+
id: string;
|
|
224
|
+
/** mem0-derived short summary (e.g. "Asked about carbon credits on Carbon Hub"). */
|
|
225
|
+
topic: string;
|
|
226
|
+
/** Surface where the memory was recorded — drives the "On X yesterday" badge. */
|
|
227
|
+
surface: SurfaceId;
|
|
228
|
+
/** ISO 8601 timestamp of when the memory was created. */
|
|
229
|
+
capturedAt: string;
|
|
230
|
+
}
|
|
231
|
+
/** Response envelope for `GET /v1/memory/recent`. */
|
|
232
|
+
interface MemoryRecallResponse {
|
|
233
|
+
items: MemoryRecallItem[];
|
|
234
|
+
/** True when mem0 was unreachable / timed out and the items list is incomplete or empty.
|
|
235
|
+
* Clients should treat as empty (silent open) rather than show stale data. */
|
|
236
|
+
degraded?: boolean;
|
|
237
|
+
}
|
|
238
|
+
|
|
171
239
|
type HighlightVariant = "pulse" | "ring" | "soft";
|
|
172
240
|
interface TargetRef {
|
|
173
241
|
kibeeId?: string;
|
|
@@ -583,6 +651,197 @@ interface WidgetConfig {
|
|
|
583
651
|
tooltipBg: string;
|
|
584
652
|
tooltipColor: string;
|
|
585
653
|
};
|
|
654
|
+
avatar?: WidgetAvatarConfig;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/** A row in the per-workspace allowed-domains table. Shown in the admin UI
|
|
658
|
+
* and consumed by the bridge JWT auth path during the trust handshake. */
|
|
659
|
+
interface AllowedDomain {
|
|
660
|
+
id: string;
|
|
661
|
+
workspaceId: string;
|
|
662
|
+
/** Apex domain only (e.g. "acme.com"). Apex-matches subdomains at runtime. */
|
|
663
|
+
domain: string;
|
|
664
|
+
/** Auth0 sub of the admin who added this entry. */
|
|
665
|
+
createdBy: string;
|
|
666
|
+
/** ISO 8601. */
|
|
667
|
+
createdAt: string;
|
|
668
|
+
}
|
|
669
|
+
/** Response for `GET /v1/workspace/allowlist/check?domain=X`.
|
|
670
|
+
* When >1 workspace allowlists the same domain for the same visitor,
|
|
671
|
+
* `workspaces` returns all matches and the macOS Buddy shows a picker. */
|
|
672
|
+
interface AllowlistCheckResponse {
|
|
673
|
+
allowed: boolean;
|
|
674
|
+
workspaces?: Array<{
|
|
675
|
+
id: string;
|
|
676
|
+
name: string;
|
|
677
|
+
}>;
|
|
678
|
+
}
|
|
679
|
+
/** Payload carried by `tenant:attach` and `tenant:detach` BridgeEnvelope.
|
|
680
|
+
* `attachedAt` mirrors the original attach time even on detach so telemetry
|
|
681
|
+
* can compute durationMs server-side. */
|
|
682
|
+
interface TenantAttachPayload {
|
|
683
|
+
workspaceId: string;
|
|
684
|
+
domain: string;
|
|
685
|
+
attachedAt: string;
|
|
686
|
+
}
|
|
687
|
+
/** Response for `GET /v1/tenant/flows`. Returns published flows for the
|
|
688
|
+
* workspace identified by `claims.tenantId` on the bridge JWT. */
|
|
689
|
+
interface TenantFlowsResponse {
|
|
690
|
+
flows: FlowDefinition[];
|
|
691
|
+
}
|
|
692
|
+
type FlowStep = {
|
|
693
|
+
kind: "web_tooltip";
|
|
694
|
+
selector: string;
|
|
695
|
+
instruction: string;
|
|
696
|
+
onPageId?: string;
|
|
697
|
+
} | {
|
|
698
|
+
kind: "desktop_click";
|
|
699
|
+
target: {
|
|
700
|
+
role: string;
|
|
701
|
+
label: string;
|
|
702
|
+
axPath: string;
|
|
703
|
+
};
|
|
704
|
+
modifiers: ReadonlyArray<"shift" | "control" | "option" | "command">;
|
|
705
|
+
description?: string;
|
|
706
|
+
fallbackCoord?: {
|
|
707
|
+
x: number;
|
|
708
|
+
y: number;
|
|
709
|
+
};
|
|
710
|
+
};
|
|
711
|
+
type CaptureStatus = "pending" | "promoted" | "rejected" | "withdrawn";
|
|
712
|
+
interface CaptureSummary {
|
|
713
|
+
id: string;
|
|
714
|
+
workspaceId: string;
|
|
715
|
+
captorVisitorId: string;
|
|
716
|
+
signature: string;
|
|
717
|
+
stepCount: number;
|
|
718
|
+
durationMs: number;
|
|
719
|
+
status: CaptureStatus;
|
|
720
|
+
promotedFlowId?: string;
|
|
721
|
+
rejectionReason?: string;
|
|
722
|
+
createdAt: string;
|
|
723
|
+
}
|
|
724
|
+
interface CaptureUploadPayload {
|
|
725
|
+
v: 2;
|
|
726
|
+
visitorId: string;
|
|
727
|
+
scope: "tenant-scoped";
|
|
728
|
+
capturedAt: string;
|
|
729
|
+
durationMs: number;
|
|
730
|
+
aborted: boolean;
|
|
731
|
+
steps: ReadonlyArray<{
|
|
732
|
+
ts: number;
|
|
733
|
+
type: "mousedown";
|
|
734
|
+
button: 0 | 1 | 2;
|
|
735
|
+
modifiers: ReadonlyArray<string>;
|
|
736
|
+
target: {
|
|
737
|
+
role: string;
|
|
738
|
+
label: string;
|
|
739
|
+
axPath: string;
|
|
740
|
+
};
|
|
741
|
+
fallbackCoord: {
|
|
742
|
+
x: number;
|
|
743
|
+
y: number;
|
|
744
|
+
};
|
|
745
|
+
}>;
|
|
746
|
+
}
|
|
747
|
+
interface CaptureUploadResponse {
|
|
748
|
+
captureId: string;
|
|
749
|
+
signature: string;
|
|
750
|
+
}
|
|
751
|
+
interface CaptureUploadEnvelope {
|
|
752
|
+
payload: CaptureUploadPayload;
|
|
753
|
+
warnings?: ReadonlyArray<string>;
|
|
754
|
+
}
|
|
755
|
+
interface CandidateGroup {
|
|
756
|
+
signature: string;
|
|
757
|
+
captures: ReadonlyArray<CaptureSummary>;
|
|
758
|
+
proposedTitle: string;
|
|
759
|
+
representativeId: string;
|
|
760
|
+
}
|
|
761
|
+
interface PromoteCandidatePayload {
|
|
762
|
+
editedSteps: ReadonlyArray<FlowStep>;
|
|
763
|
+
title: string;
|
|
764
|
+
pageId?: string;
|
|
765
|
+
audience?: string;
|
|
766
|
+
introMessage?: string;
|
|
767
|
+
replaceFlowId?: string;
|
|
768
|
+
}
|
|
769
|
+
type AuditAction = "capture.uploaded" | "capture.withdrawn" | "capture.promoted" | "capture.rejected" | "capture.edited" | "flag.flipped" | "slo.token.minted";
|
|
770
|
+
interface AuditEvent {
|
|
771
|
+
id: string;
|
|
772
|
+
workspaceId: string;
|
|
773
|
+
actor: {
|
|
774
|
+
kind: "visitor" | "admin" | "system";
|
|
775
|
+
id: string;
|
|
776
|
+
};
|
|
777
|
+
action: AuditAction;
|
|
778
|
+
target: {
|
|
779
|
+
kind: "capture" | "flow" | "flag";
|
|
780
|
+
id: string;
|
|
781
|
+
};
|
|
782
|
+
metadata?: Record<string, unknown>;
|
|
783
|
+
ts: string;
|
|
784
|
+
}
|
|
785
|
+
interface DiffPreview {
|
|
786
|
+
matchKind: "new" | "update";
|
|
787
|
+
matchedFlowId?: string;
|
|
788
|
+
matchedFlowTitle?: string;
|
|
789
|
+
stepDiff: ReadonlyArray<{
|
|
790
|
+
kind: "added" | "removed" | "changed" | "unchanged";
|
|
791
|
+
step: FlowStep;
|
|
792
|
+
}>;
|
|
793
|
+
}
|
|
794
|
+
interface FeatureFlag {
|
|
795
|
+
key: string;
|
|
796
|
+
defaultValue: boolean;
|
|
797
|
+
description: string;
|
|
798
|
+
createdAt: string;
|
|
799
|
+
updatedAt: string;
|
|
586
800
|
}
|
|
801
|
+
interface FeatureFlagOverride {
|
|
802
|
+
workspaceId: string;
|
|
803
|
+
key: string;
|
|
804
|
+
value: boolean;
|
|
805
|
+
createdAt: string;
|
|
806
|
+
updatedAt: string;
|
|
807
|
+
}
|
|
808
|
+
interface ResolvedFlagSet {
|
|
809
|
+
workspaceId: string;
|
|
810
|
+
flags: Record<string, boolean>;
|
|
811
|
+
fetchedAt: string;
|
|
812
|
+
}
|
|
813
|
+
interface SloWindow {
|
|
814
|
+
captureUploadSuccessRate: number;
|
|
815
|
+
captureUploadCount: number;
|
|
816
|
+
tenantAttachDeniedRate: number;
|
|
817
|
+
tenantAttachAttemptCount: number;
|
|
818
|
+
adminPromotionLatencyP50Ms: number;
|
|
819
|
+
adminPromotionLatencyP95Ms: number;
|
|
820
|
+
bridgeUptimePerVisitorMedian: number;
|
|
821
|
+
replayFallbackRate: number;
|
|
822
|
+
replayAttemptCount: number;
|
|
823
|
+
}
|
|
824
|
+
interface SloSnapshot {
|
|
825
|
+
computedAt: string;
|
|
826
|
+
workspaceId: string;
|
|
827
|
+
windows: {
|
|
828
|
+
last24h: SloWindow;
|
|
829
|
+
last7d: SloWindow;
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
declare const SLO_THRESHOLDS: {
|
|
833
|
+
readonly captureUploadSuccessRate: {
|
|
834
|
+
readonly min: 0.99;
|
|
835
|
+
};
|
|
836
|
+
readonly tenantAttachDeniedRate: {
|
|
837
|
+
readonly max: 0.01;
|
|
838
|
+
};
|
|
839
|
+
readonly adminPromotionLatencyP95Ms: {
|
|
840
|
+
readonly max: 2000;
|
|
841
|
+
};
|
|
842
|
+
readonly bridgeUptimePerVisitorMedian: {
|
|
843
|
+
readonly min: 0.99;
|
|
844
|
+
};
|
|
845
|
+
};
|
|
587
846
|
|
|
588
|
-
export { type AdminSessionSummary, type AnalyticsEvent, BUDDY_TRANSITIONS, type BridgeClaims, type BridgeEnvelope, type BridgeEventType, type BuddyState, type ChatMessage, type ChatMode, type ChatSender, type CrossSiteFlowQueueItem, type CrossSiteFlowStep, type DockInlineAnchor, type DockPositionConfig, type DockPositionPreset, type EventMetadata, type FlowCommand, type FlowDefinition, type FlowMoveOptions, type HighlightVariant, type IdentityRequest, type IdentityResponse, type IntentMatch, type KiBeePairAccept, type KiBeePairReject, type KiBeePairRequest, type MessageTemplate, type PairingState, type PushFlowRequest, type PushTargetsRequest, type RecoveryRequest, type RecoveryResponse, type RegisteredTarget, type ResolveIntentRequest, type SessionState, type StartSessionRequest, type SurfaceId, type TargetRef, type TrackEventRequest, type VisibleTarget, type VisitorIdentity, type VisitorPollResponse, type WidgetConfig, canTransition, isBridgeEnvelope };
|
|
847
|
+
export { type AdminSessionSummary, type AllowedDomain, type AllowlistCheckResponse, type AnalyticsEvent, type AuditAction, type AuditEvent, type AvatarMode, type AvatarPresetId, BUDDY_TRANSITIONS, type BridgeClaims, type BridgeEnvelope, type BridgeEventType, type BuddyState, type CandidateGroup, type CaptureStatus, type CaptureSummary, type CaptureUploadEnvelope, type CaptureUploadPayload, type CaptureUploadResponse, type ChatMessage, type ChatMode, type ChatSender, type CrossSiteFlowQueueItem, type CrossSiteFlowStep, type DiffPreview, type DockInlineAnchor, type DockPositionConfig, type DockPositionPreset, type EventMetadata, type FeatureFlag, type FeatureFlagOverride, type FlowCommand, type FlowDefinition, type FlowMoveOptions, type FlowStep, type HighlightVariant, type IdentityRequest, type IdentityResponse, type IntentMatch, type KiBeePairAccept, type KiBeePairReject, type KiBeePairRequest, type MemoryRecallItem, type MemoryRecallResponse, type MemoryScope, type MessageTemplate, type PairingState, type PromoteCandidatePayload, type PushFlowRequest, type PushTargetsRequest, type RecoveryRequest, type RecoveryResponse, type RegisteredTarget, type ResolveIntentRequest, type ResolvedFlagSet, SLO_THRESHOLDS, type SessionState, type SloSnapshot, type SloWindow, type StartSessionRequest, type SurfaceId, type TargetRef, type TenantAttachPayload, type TenantFlowsResponse, type TrackEventRequest, type VisibleTarget, type VisitorIdentity, type VisitorPollResponse, type WidgetAvatarConfig, type WidgetConfig, type WidgetConfigResponse, type WidgetDockPosition, type WidgetDockPreset, type WidgetSettingsRecord, buildWidgetConfigResponse, canTransition, isAvatarMode, isAvatarPresetId, isBridgeEnvelope, parseWidgetAvatar, resolveRendererAvatarOptions };
|
package/dist/index.js
CHANGED
|
@@ -21,11 +21,61 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
BUDDY_TRANSITIONS: () => BUDDY_TRANSITIONS,
|
|
24
|
+
SLO_THRESHOLDS: () => SLO_THRESHOLDS,
|
|
25
|
+
buildWidgetConfigResponse: () => buildWidgetConfigResponse,
|
|
24
26
|
canTransition: () => canTransition,
|
|
25
|
-
|
|
27
|
+
isAvatarMode: () => isAvatarMode,
|
|
28
|
+
isAvatarPresetId: () => isAvatarPresetId,
|
|
29
|
+
isBridgeEnvelope: () => isBridgeEnvelope,
|
|
30
|
+
parseWidgetAvatar: () => parseWidgetAvatar,
|
|
31
|
+
resolveRendererAvatarOptions: () => resolveRendererAvatarOptions
|
|
26
32
|
});
|
|
27
33
|
module.exports = __toCommonJS(index_exports);
|
|
28
34
|
|
|
35
|
+
// src/widget.ts
|
|
36
|
+
var AVATAR_MODES = ["default", "preset", "custom"];
|
|
37
|
+
var AVATAR_PRESETS = ["orb", "ring"];
|
|
38
|
+
function isAvatarMode(value) {
|
|
39
|
+
return typeof value === "string" && AVATAR_MODES.includes(value);
|
|
40
|
+
}
|
|
41
|
+
function isAvatarPresetId(value) {
|
|
42
|
+
return typeof value === "string" && AVATAR_PRESETS.includes(value);
|
|
43
|
+
}
|
|
44
|
+
function parseWidgetAvatar(settings) {
|
|
45
|
+
const mode = isAvatarMode(settings.avatarMode) ? settings.avatarMode : "default";
|
|
46
|
+
if (mode === "preset") {
|
|
47
|
+
const preset = isAvatarPresetId(settings.avatarPreset) ? settings.avatarPreset : "orb";
|
|
48
|
+
return { mode, preset };
|
|
49
|
+
}
|
|
50
|
+
if (mode === "custom" && typeof settings.avatarAssetUrl === "string" && settings.avatarAssetUrl.trim()) {
|
|
51
|
+
return { mode, assetUrl: settings.avatarAssetUrl.trim() };
|
|
52
|
+
}
|
|
53
|
+
return { mode: "default" };
|
|
54
|
+
}
|
|
55
|
+
function buildWidgetConfigResponse(settings) {
|
|
56
|
+
const dockPosition = settings.dockPosition ?? "bottom-right";
|
|
57
|
+
const dockSize = typeof settings.dockSize === "number" ? settings.dockSize : 60;
|
|
58
|
+
return {
|
|
59
|
+
dockPosition,
|
|
60
|
+
dockSize,
|
|
61
|
+
theme: {
|
|
62
|
+
primary: typeof settings.primaryColor === "string" ? settings.primaryColor : "#a77a2f",
|
|
63
|
+
tooltipBg: typeof settings.tooltipBg === "string" ? settings.tooltipBg : "#fbf6ec",
|
|
64
|
+
tooltipColor: typeof settings.tooltipColor === "string" ? settings.tooltipColor : "#241b11"
|
|
65
|
+
},
|
|
66
|
+
avatar: parseWidgetAvatar(settings)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function resolveRendererAvatarOptions(avatar) {
|
|
70
|
+
if (avatar.mode === "preset" && avatar.preset) {
|
|
71
|
+
return { avatarPreset: avatar.preset };
|
|
72
|
+
}
|
|
73
|
+
if (avatar.mode === "custom" && avatar.assetUrl) {
|
|
74
|
+
return { avatarPreset: "bee", assetUrl: avatar.assetUrl };
|
|
75
|
+
}
|
|
76
|
+
return { avatarPreset: "bee" };
|
|
77
|
+
}
|
|
78
|
+
|
|
29
79
|
// src/bridge.ts
|
|
30
80
|
var SURFACE_IDS = /* @__PURE__ */ new Set(["web", "extension", "desktop"]);
|
|
31
81
|
var BRIDGE_TARGETS = /* @__PURE__ */ new Set([
|
|
@@ -68,9 +118,23 @@ var BUDDY_TRANSITIONS = {
|
|
|
68
118
|
function canTransition(from, to) {
|
|
69
119
|
return BUDDY_TRANSITIONS[from].includes(to);
|
|
70
120
|
}
|
|
121
|
+
|
|
122
|
+
// src/index.ts
|
|
123
|
+
var SLO_THRESHOLDS = {
|
|
124
|
+
captureUploadSuccessRate: { min: 0.99 },
|
|
125
|
+
tenantAttachDeniedRate: { max: 0.01 },
|
|
126
|
+
adminPromotionLatencyP95Ms: { max: 2e3 },
|
|
127
|
+
bridgeUptimePerVisitorMedian: { min: 0.99 }
|
|
128
|
+
};
|
|
71
129
|
// Annotate the CommonJS export names for ESM import in node:
|
|
72
130
|
0 && (module.exports = {
|
|
73
131
|
BUDDY_TRANSITIONS,
|
|
132
|
+
SLO_THRESHOLDS,
|
|
133
|
+
buildWidgetConfigResponse,
|
|
74
134
|
canTransition,
|
|
75
|
-
|
|
135
|
+
isAvatarMode,
|
|
136
|
+
isAvatarPresetId,
|
|
137
|
+
isBridgeEnvelope,
|
|
138
|
+
parseWidgetAvatar,
|
|
139
|
+
resolveRendererAvatarOptions
|
|
76
140
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,47 @@
|
|
|
1
|
+
// src/widget.ts
|
|
2
|
+
var AVATAR_MODES = ["default", "preset", "custom"];
|
|
3
|
+
var AVATAR_PRESETS = ["orb", "ring"];
|
|
4
|
+
function isAvatarMode(value) {
|
|
5
|
+
return typeof value === "string" && AVATAR_MODES.includes(value);
|
|
6
|
+
}
|
|
7
|
+
function isAvatarPresetId(value) {
|
|
8
|
+
return typeof value === "string" && AVATAR_PRESETS.includes(value);
|
|
9
|
+
}
|
|
10
|
+
function parseWidgetAvatar(settings) {
|
|
11
|
+
const mode = isAvatarMode(settings.avatarMode) ? settings.avatarMode : "default";
|
|
12
|
+
if (mode === "preset") {
|
|
13
|
+
const preset = isAvatarPresetId(settings.avatarPreset) ? settings.avatarPreset : "orb";
|
|
14
|
+
return { mode, preset };
|
|
15
|
+
}
|
|
16
|
+
if (mode === "custom" && typeof settings.avatarAssetUrl === "string" && settings.avatarAssetUrl.trim()) {
|
|
17
|
+
return { mode, assetUrl: settings.avatarAssetUrl.trim() };
|
|
18
|
+
}
|
|
19
|
+
return { mode: "default" };
|
|
20
|
+
}
|
|
21
|
+
function buildWidgetConfigResponse(settings) {
|
|
22
|
+
const dockPosition = settings.dockPosition ?? "bottom-right";
|
|
23
|
+
const dockSize = typeof settings.dockSize === "number" ? settings.dockSize : 60;
|
|
24
|
+
return {
|
|
25
|
+
dockPosition,
|
|
26
|
+
dockSize,
|
|
27
|
+
theme: {
|
|
28
|
+
primary: typeof settings.primaryColor === "string" ? settings.primaryColor : "#a77a2f",
|
|
29
|
+
tooltipBg: typeof settings.tooltipBg === "string" ? settings.tooltipBg : "#fbf6ec",
|
|
30
|
+
tooltipColor: typeof settings.tooltipColor === "string" ? settings.tooltipColor : "#241b11"
|
|
31
|
+
},
|
|
32
|
+
avatar: parseWidgetAvatar(settings)
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function resolveRendererAvatarOptions(avatar) {
|
|
36
|
+
if (avatar.mode === "preset" && avatar.preset) {
|
|
37
|
+
return { avatarPreset: avatar.preset };
|
|
38
|
+
}
|
|
39
|
+
if (avatar.mode === "custom" && avatar.assetUrl) {
|
|
40
|
+
return { avatarPreset: "bee", assetUrl: avatar.assetUrl };
|
|
41
|
+
}
|
|
42
|
+
return { avatarPreset: "bee" };
|
|
43
|
+
}
|
|
44
|
+
|
|
1
45
|
// src/bridge.ts
|
|
2
46
|
var SURFACE_IDS = /* @__PURE__ */ new Set(["web", "extension", "desktop"]);
|
|
3
47
|
var BRIDGE_TARGETS = /* @__PURE__ */ new Set([
|
|
@@ -40,8 +84,22 @@ var BUDDY_TRANSITIONS = {
|
|
|
40
84
|
function canTransition(from, to) {
|
|
41
85
|
return BUDDY_TRANSITIONS[from].includes(to);
|
|
42
86
|
}
|
|
87
|
+
|
|
88
|
+
// src/index.ts
|
|
89
|
+
var SLO_THRESHOLDS = {
|
|
90
|
+
captureUploadSuccessRate: { min: 0.99 },
|
|
91
|
+
tenantAttachDeniedRate: { max: 0.01 },
|
|
92
|
+
adminPromotionLatencyP95Ms: { max: 2e3 },
|
|
93
|
+
bridgeUptimePerVisitorMedian: { min: 0.99 }
|
|
94
|
+
};
|
|
43
95
|
export {
|
|
44
96
|
BUDDY_TRANSITIONS,
|
|
97
|
+
SLO_THRESHOLDS,
|
|
98
|
+
buildWidgetConfigResponse,
|
|
45
99
|
canTransition,
|
|
46
|
-
|
|
100
|
+
isAvatarMode,
|
|
101
|
+
isAvatarPresetId,
|
|
102
|
+
isBridgeEnvelope,
|
|
103
|
+
parseWidgetAvatar,
|
|
104
|
+
resolveRendererAvatarOptions
|
|
47
105
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kibee/contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -11,12 +11,17 @@
|
|
|
11
11
|
"require": "./dist/index.js"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
|
-
"files": [
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
15
17
|
"scripts": {
|
|
16
18
|
"build": "tsup src/index.ts --format cjs,esm --dts --clean --tsconfig tsconfig.build.json",
|
|
17
19
|
"dev": "tsup src/index.ts --format cjs,esm --dts --watch"
|
|
18
20
|
},
|
|
19
21
|
"devDependencies": {
|
|
20
22
|
"tsup": "^8.5.1"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
21
26
|
}
|
|
22
27
|
}
|