@inploi/plugin-kin 2.7.9 → 3.1.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/cdn/frame/assets/highlighted-body-B3W2YXNL-3225cf48.js +1 -0
- package/cdn/frame/assets/index-94d05bc4.js +128 -0
- package/cdn/frame/assets/mermaid-3ZIDBTTL-848de26a.js +1 -0
- package/cdn/frame/index.html +33 -0
- package/cdn/index.js +1 -129
- package/dist/components/button.d.ts +1 -1
- package/dist/components/launcher-icon.d.ts +8 -0
- package/dist/components/widget.d.ts +14 -3
- package/dist/index.d.ts +1 -1
- package/dist/kin.client.d.ts +2 -3
- package/dist/kin.d.ts +5 -43
- package/dist/kin.protocol.d.ts +118 -0
- package/dist/kin.runtime.d.ts +1 -0
- package/dist/kin.state.d.ts +10 -3
- package/dist/kin.vars.d.ts +1 -1
- package/dist/plugin-kin.cjs +1 -1
- package/dist/plugin-kin.js +196 -3
- package/package.json +6 -5
- package/dist/highlighted-body-B3W2YXNL-4579406d.cjs +0 -1
- package/dist/highlighted-body-B3W2YXNL-aa326909.js +0 -18
- package/dist/index-45f58435.cjs +0 -129
- package/dist/index-d554999b.js +0 -28080
- package/dist/mermaid-3ZIDBTTL-6ffe15f4.js +0 -5
- package/dist/mermaid-3ZIDBTTL-85bdf74f.cjs +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const buttonClass: (props?: ({
|
|
2
2
|
variant?: "ghost" | "neutral" | "accent" | undefined;
|
|
3
|
-
size?: "
|
|
3
|
+
size?: "sm" | "md" | "iconSm" | "iconMd" | "iconLg" | undefined;
|
|
4
4
|
} & ({
|
|
5
5
|
class?: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | {
|
|
6
6
|
[x: string]: any;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { KinFloatingPlacement } from '../kin.protocol';
|
|
2
|
+
|
|
3
|
+
export declare function LauncherIcon({ onOpen, placement, buttonRef, logo, }: {
|
|
4
|
+
onOpen: () => void;
|
|
5
|
+
placement?: KinFloatingPlacement;
|
|
6
|
+
buttonRef?: preact.RefObject<HTMLButtonElement>;
|
|
7
|
+
logo?: string | null;
|
|
8
|
+
}): import("preact").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { KinFloatingPlacement, KinLauncherConfig, StarterPrompt } from '../kin.protocol';
|
|
2
2
|
|
|
3
3
|
export declare const shellClass: (props?: ({
|
|
4
4
|
layout?: "embedded" | "closed" | "open" | undefined;
|
|
@@ -114,7 +114,7 @@ export declare const backdropClass: (props?: ({
|
|
|
114
114
|
[x: string]: any;
|
|
115
115
|
} | null | undefined;
|
|
116
116
|
})) | undefined) => string;
|
|
117
|
-
export declare function Widget({ starterPrompts, onSendMessage, onOpen, onClose, onConnect, onClearData, onUploadFile, placement, }: {
|
|
117
|
+
export declare function Widget({ starterPrompts, onSendMessage, onOpen, onClose, onConnect, onClearData, onUploadFile, onClipInset, placement, launcher, logo, }: {
|
|
118
118
|
starterPrompts: StarterPrompt[];
|
|
119
119
|
onSendMessage: (content: string) => void;
|
|
120
120
|
onOpen: () => void;
|
|
@@ -122,5 +122,16 @@ export declare function Widget({ starterPrompts, onSendMessage, onOpen, onClose,
|
|
|
122
122
|
onConnect: () => void;
|
|
123
123
|
onClearData: () => void;
|
|
124
124
|
onUploadFile: (file: File, fileType: string) => void;
|
|
125
|
-
|
|
125
|
+
onClipInset?: (inset: {
|
|
126
|
+
top: number;
|
|
127
|
+
right: number;
|
|
128
|
+
bottom: number;
|
|
129
|
+
left: number;
|
|
130
|
+
}) => void;
|
|
131
|
+
placement: {
|
|
132
|
+
desktop: KinFloatingPlacement;
|
|
133
|
+
mobile: KinFloatingPlacement;
|
|
134
|
+
};
|
|
135
|
+
launcher?: Required<KinLauncherConfig>;
|
|
136
|
+
logo?: string | null;
|
|
126
137
|
}): import("preact").JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { kinPlugin, type Kin, type KinPlacement, type KinPlugin, type KinPluginParams, type KinRounded, type KinTheme, } from './kin';
|
|
1
|
+
export { kinPlugin, type Kin, type KinAppearance, type KinFloatingPlacement, type KinLauncherConfig, type KinPlacement, type KinPlacementConfig, type KinPlugin, type KinPluginParams, type KinRounded, type KinTheme, type StarterPrompt, } from './kin';
|
package/dist/kin.client.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ type HistoryMessage = {
|
|
|
6
6
|
content: string;
|
|
7
7
|
blocks?: unknown[];
|
|
8
8
|
};
|
|
9
|
-
type KinMessage = {
|
|
9
|
+
export type KinMessage = {
|
|
10
10
|
type: 'user_message' | 'response_start' | 'response_chunk' | 'response_end' | 'tool_call' | 'tool_result' | 'error' | 'system' | 'authenticated' | 'data_cleared' | 'guardrail_block' | 'history' | 'quick_replies' | 'upload_received' | 'file_processing' | 'file_processed' | 'job_detail' | 'job_detail_chunk' | 'job_detail_done' | 'job_detail_error';
|
|
11
11
|
content?: string;
|
|
12
12
|
tool?: string;
|
|
@@ -32,11 +32,10 @@ export declare const FILE_ACCEPT_STRING = ".pdf,.docx,.doc,.txt,.jpg,.jpeg,.png,
|
|
|
32
32
|
type KinClientOptions = {
|
|
33
33
|
url: string;
|
|
34
34
|
onMessage: (message: KinMessage) => void;
|
|
35
|
-
onOpen: () => void;
|
|
36
35
|
onClose: () => void;
|
|
37
36
|
onError: (error: Event) => void;
|
|
38
37
|
};
|
|
39
|
-
export declare function createKinClient({ url, onMessage,
|
|
38
|
+
export declare function createKinClient({ url, onMessage, onClose, onError }: KinClientOptions): {
|
|
40
39
|
sendMessage: (content: string) => void;
|
|
41
40
|
/**
|
|
42
41
|
* Upload a file to the server
|
package/dist/kin.d.ts
CHANGED
|
@@ -1,47 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
label: string;
|
|
5
|
-
/** Message sent when clicked (can differ from label) */
|
|
6
|
-
message: string;
|
|
7
|
-
};
|
|
8
|
-
export type KinTheme = {
|
|
9
|
-
/** Primary accent color as HEX (e.g., "#FF4D00") */
|
|
10
|
-
accentColor: string;
|
|
11
|
-
/** Optional neutral base color as HEX (e.g., "#555555"). Defaults to medium gray. */
|
|
12
|
-
neutralColor?: string;
|
|
13
|
-
/** Light or dark mode */
|
|
14
|
-
mode: 'light' | 'dark';
|
|
15
|
-
/** Global rounding preset */
|
|
16
|
-
rounded?: KinRounded;
|
|
17
|
-
};
|
|
18
|
-
export type KinPlacement = 'left' | 'center' | 'right' | 'embedded';
|
|
19
|
-
export type KinRounded = 'sm' | 'md' | 'lg';
|
|
20
|
-
export type KinPluginParams = {
|
|
21
|
-
/** Override the agents service URL. Defaults to production (wss://agents.inploi.com). Only needed for local development. */
|
|
22
|
-
serviceUrl?: string;
|
|
23
|
-
/** Theme configuration */
|
|
24
|
-
theme?: KinTheme;
|
|
25
|
-
/** Starter prompts shown in empty state to help users begin */
|
|
26
|
-
starterPrompts?: StarterPrompt[];
|
|
27
|
-
/**
|
|
28
|
-
* Widget placement:
|
|
29
|
-
* - 'left' | 'center' | 'right': Floating positions on desktop
|
|
30
|
-
* - 'embedded': Inline mode (fills the provided container)
|
|
31
|
-
*/
|
|
32
|
-
placement?: KinPlacement;
|
|
33
|
-
/**
|
|
34
|
-
* Container element or selector for embedded placement.
|
|
35
|
-
* If not provided in embedded placement, creates its own container.
|
|
36
|
-
*/
|
|
37
|
-
container?: HTMLElement | string;
|
|
38
|
-
};
|
|
1
|
+
import { KinPluginParams, KinTheme } from './kin.protocol';
|
|
2
|
+
|
|
3
|
+
export type { KinAppearance, KinFloatingPlacement, KinLauncherConfig, KinPlacement, KinPlacementConfig, KinPluginParams, KinRounded, KinTheme, StarterPrompt, } from './kin.protocol';
|
|
39
4
|
export type KinPlugin = typeof kinPlugin;
|
|
40
5
|
export type Kin = ReturnType<ReturnType<KinPlugin>>;
|
|
41
|
-
|
|
42
|
-
* Creates the Kin plugin
|
|
43
|
-
*/
|
|
44
|
-
export declare const kinPlugin: ({ serviceUrl, theme, starterPrompts, placement, container: containerOption, }: KinPluginParams) => ({ logger, publishableKey, env }: {
|
|
6
|
+
export declare const kinPlugin: ({ serviceUrl, frameUrl: frameUrlOption, appearance, starterPrompts, container, }: KinPluginParams) => ({ logger, publishableKey, env }: {
|
|
45
7
|
apiClient: import('@inploi/sdk').ApiClient;
|
|
46
8
|
rpcClient: import('@inploi/sdk').InploiRpcClient;
|
|
47
9
|
logger: import('@inploi/sdk').Logger;
|
|
@@ -53,6 +15,6 @@ export declare const kinPlugin: ({ serviceUrl, theme, starterPrompts, placement,
|
|
|
53
15
|
open: () => void;
|
|
54
16
|
close: () => void;
|
|
55
17
|
toggle: () => void;
|
|
56
|
-
|
|
18
|
+
setAppearance: (next?: Partial<KinTheme>) => void;
|
|
57
19
|
destroy: () => void;
|
|
58
20
|
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { MessageBlock } from './message-payload';
|
|
2
|
+
|
|
3
|
+
export type StarterPrompt = {
|
|
4
|
+
label: string;
|
|
5
|
+
message: string;
|
|
6
|
+
};
|
|
7
|
+
export type KinRounded = 'sm' | 'md' | 'lg';
|
|
8
|
+
export type KinTheme = {
|
|
9
|
+
accentColor: string;
|
|
10
|
+
neutralColor?: string;
|
|
11
|
+
mode: 'light' | 'dark';
|
|
12
|
+
rounded?: KinRounded;
|
|
13
|
+
};
|
|
14
|
+
export type KinFloatingPlacement = 'left' | 'center' | 'right';
|
|
15
|
+
export type KinPlacement = KinFloatingPlacement | 'embedded';
|
|
16
|
+
export type KinPlacementConfig = {
|
|
17
|
+
desktop?: KinFloatingPlacement;
|
|
18
|
+
mobile?: KinFloatingPlacement;
|
|
19
|
+
};
|
|
20
|
+
export type KinLauncherConfig = {
|
|
21
|
+
desktop?: 'input' | 'icon';
|
|
22
|
+
mobile?: 'input' | 'icon';
|
|
23
|
+
};
|
|
24
|
+
export type KinAppearance = {
|
|
25
|
+
accentColor?: string;
|
|
26
|
+
neutralColor?: string;
|
|
27
|
+
mode?: 'light' | 'dark';
|
|
28
|
+
rounded?: KinRounded;
|
|
29
|
+
placement?: KinPlacement | KinPlacementConfig;
|
|
30
|
+
launcher?: KinLauncherConfig;
|
|
31
|
+
zIndex?: number;
|
|
32
|
+
logo?: string | null;
|
|
33
|
+
};
|
|
34
|
+
export type KinPluginParams = {
|
|
35
|
+
serviceUrl?: string;
|
|
36
|
+
frameUrl?: string;
|
|
37
|
+
appearance?: KinAppearance;
|
|
38
|
+
starterPrompts?: StarterPrompt[];
|
|
39
|
+
container?: HTMLElement | string;
|
|
40
|
+
};
|
|
41
|
+
export type SyncedMessage = {
|
|
42
|
+
role: 'user' | 'assistant' | 'system';
|
|
43
|
+
content: string;
|
|
44
|
+
timestamp: string;
|
|
45
|
+
attachment?: {
|
|
46
|
+
name: string;
|
|
47
|
+
};
|
|
48
|
+
blocks?: MessageBlock[];
|
|
49
|
+
};
|
|
50
|
+
export type KinSyncSnapshot = {
|
|
51
|
+
syncKey: string;
|
|
52
|
+
sourceInstanceId: string;
|
|
53
|
+
revision: number;
|
|
54
|
+
type: 'messages_updated';
|
|
55
|
+
messages: SyncedMessage[];
|
|
56
|
+
} | {
|
|
57
|
+
syncKey: string;
|
|
58
|
+
sourceInstanceId: string;
|
|
59
|
+
revision: number;
|
|
60
|
+
type: 'messages_cleared';
|
|
61
|
+
};
|
|
62
|
+
export type KinInitPayload = {
|
|
63
|
+
instanceId: string;
|
|
64
|
+
publishableKey: string;
|
|
65
|
+
anonymousId: string;
|
|
66
|
+
serviceUrl: string;
|
|
67
|
+
theme: KinTheme;
|
|
68
|
+
logo: string | null;
|
|
69
|
+
starterPrompts: StarterPrompt[];
|
|
70
|
+
placement: {
|
|
71
|
+
desktop: KinFloatingPlacement;
|
|
72
|
+
mobile: KinFloatingPlacement;
|
|
73
|
+
};
|
|
74
|
+
embedded: boolean;
|
|
75
|
+
launcher: Required<KinLauncherConfig>;
|
|
76
|
+
};
|
|
77
|
+
export type HostToFrameMessage = {
|
|
78
|
+
type: 'kin:init';
|
|
79
|
+
payload: KinInitPayload;
|
|
80
|
+
} | {
|
|
81
|
+
type: 'kin:open';
|
|
82
|
+
} | {
|
|
83
|
+
type: 'kin:close';
|
|
84
|
+
} | {
|
|
85
|
+
type: 'kin:set-appearance';
|
|
86
|
+
payload: KinTheme;
|
|
87
|
+
} | {
|
|
88
|
+
type: 'kin:destroy';
|
|
89
|
+
} | {
|
|
90
|
+
type: 'kin:sync-snapshot';
|
|
91
|
+
payload: KinSyncSnapshot;
|
|
92
|
+
};
|
|
93
|
+
export type FrameToHostMessage = {
|
|
94
|
+
type: 'kin:ready';
|
|
95
|
+
} | {
|
|
96
|
+
type: 'kin:request-close';
|
|
97
|
+
} | {
|
|
98
|
+
type: 'kin:opened';
|
|
99
|
+
} | {
|
|
100
|
+
type: 'kin:clip-inset';
|
|
101
|
+
payload: {
|
|
102
|
+
top: number;
|
|
103
|
+
right: number;
|
|
104
|
+
bottom: number;
|
|
105
|
+
left: number;
|
|
106
|
+
};
|
|
107
|
+
} | {
|
|
108
|
+
type: 'kin:state-snapshot';
|
|
109
|
+
payload: KinSyncSnapshot;
|
|
110
|
+
} | {
|
|
111
|
+
type: 'kin:error';
|
|
112
|
+
payload: {
|
|
113
|
+
message: string;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
export declare const isKinMessage: (v: unknown) => v is {
|
|
117
|
+
type: string;
|
|
118
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/kin.state.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { VNode } from 'preact';
|
|
2
|
+
import { KinSyncSnapshot } from './kin.protocol';
|
|
2
3
|
import { MessageBlock } from './message-payload';
|
|
3
4
|
|
|
4
5
|
export type Message = {
|
|
@@ -41,18 +42,24 @@ export declare const store: {
|
|
|
41
42
|
setJobDetail: (jobId: string, patch: Partial<JobDetailState>) => void;
|
|
42
43
|
appendJobSummaryChunk: (jobId: string, content: string) => void;
|
|
43
44
|
finalizeJobSummary: (jobId: string, summary: string) => void;
|
|
45
|
+
configureSync: (config: {
|
|
46
|
+
syncKey: string;
|
|
47
|
+
sourceInstanceId: string;
|
|
48
|
+
emit: (snapshot: KinSyncSnapshot) => void;
|
|
49
|
+
} | null) => void;
|
|
50
|
+
applySyncSnapshot: (snapshot: KinSyncSnapshot) => void;
|
|
44
51
|
addMessage: (message: Omit<Message, "id" | "timestamp">) => Message;
|
|
45
52
|
removeMessage: (id: string) => void;
|
|
46
53
|
startAssistantResponse: () => void;
|
|
47
54
|
appendToLiveAssistantMessage: (content: string) => void;
|
|
48
55
|
finishAssistantResponse: (options?: {
|
|
49
56
|
commit?: boolean;
|
|
50
|
-
|
|
57
|
+
sync?: boolean;
|
|
51
58
|
blocks?: MessageBlock[];
|
|
52
59
|
}) => void;
|
|
53
60
|
clearAssistantResponse: () => void;
|
|
54
|
-
clearMessages: () => void;
|
|
55
|
-
setMessages: (newMessages: Array<Omit<Message, "id" | "timestamp"
|
|
61
|
+
clearMessages: (sync?: boolean) => void;
|
|
62
|
+
setMessages: (newMessages: Array<Omit<Message, "id" | "timestamp">>, sync?: boolean) => void;
|
|
56
63
|
setUploadState: (state: UploadState, fileName?: string, error?: string) => void;
|
|
57
64
|
resetState: () => void;
|
|
58
65
|
};
|
package/dist/kin.vars.d.ts
CHANGED
package/dist/plugin-kin.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("@inploi/sdk"),Y=r=>typeof r=="object"&&r!==null&&typeof r.type=="string"&&r.type.startsWith("kin:"),ee="inploi-kin-root",te=2147483647,k={accentColor:"#FF4D00",neutralColor:"#555555",mode:"light",rounded:"lg"},ne={production:"wss://agents.inploi.com",sandbox:"wss://agents.staging.inploi.com"},oe=(()=>{var g;if({}.VITE_KIN_FRAME_URL)return{}.VITE_KIN_FRAME_URL;const r=typeof document<"u"?(g=document.currentScript)==null?void 0:g.src:void 0;return r?new URL("./frame/index.html",r).href:null})(),ie=({serviceUrl:r,frameUrl:g,appearance:F={},starterPrompts:K=[],container:v})=>L.createPlugin(({logger:C,publishableKey:E,env:O})=>{const T=r??ne[O??"production"];if(!E)throw new Error("Kin plugin requires a publishableKey. Pass it to initialiseSdk().");const{accentColor:P=k.accentColor,neutralColor:D=k.neutralColor,mode:j=k.mode,rounded:q=k.rounded,placement:u="center",launcher:x={},zIndex:N=te,logo:V=null}=F,R=L.generateUUID(),n=u==="embedded",W=typeof u=="object"?{desktop:u.desktop??"center",mobile:u.mobile??"center"}:{desktop:n?"center":u,mobile:n?"center":u},z={desktop:x.desktop??"input",mobile:x.mobile??"icon"},B=String(N);let d={accentColor:P,neutralColor:D,mode:j,rounded:q},f="",w="",h="",U="",o=null,t=null,s=null,l=!1,I=n,m=n,y=null,p={top:"calc(100% - 64px)",right:"0",bottom:"0",left:"0"};const a=e=>{var i;w&&((i=t==null?void 0:t.contentWindow)==null||i.postMessage(e,w))},S=e=>{n||(e&&y===null?(y=document.documentElement.style.overflow,document.documentElement.style.overflow="hidden"):!e&&y!==null&&(document.documentElement.style.overflow=y,y=null))},_=()=>`inset(${p.top} ${p.right} ${p.bottom} ${p.left})`,c=e=>{m=e,!(e&&!l)&&(S(e),o&&(o.style.clipPath=e?"inset(0)":_(),o.style.pointerEvents=e||l&&I?"all":"none"))},M=e=>{if(e.source!==(t==null?void 0:t.contentWindow)||e.origin!==w||!Y(e.data))return;const i=e.data;switch(i.type){case"kin:ready":l=!0,t&&(t.style.visibility="visible"),m&&!n?(c(!0),a({type:"kin:open"})):n||c(!1);break;case"kin:request-close":c(!1);break;case"kin:opened":n||c(!0);break;case"kin:clip-inset":if(I=!0,!m){const{top:G,right:J,bottom:Q,left:X}=i.payload;p={top:`${G}px`,right:`${J}px`,bottom:`${Q}px`,left:`${X}px`},c(!1)}break;case"kin:state-snapshot":s==null||s.postMessage(i.payload);break;case"kin:error":C.error(i.payload.message);break}},Z=e=>{const i=e.data;!U||!i||i.syncKey!==U||i.sourceInstanceId===R||!l||a({type:"kin:sync-snapshot",payload:i})},b=()=>{if(!t){if(!f){if(f=g||oe||"",!f)throw new Error("Kin frame URL could not be resolved automatically. Pass `frameUrl` when using the npm build, or load the CDN bundle via a <script> tag.");w=new URL(f,window.location.href).origin}h||(h=L.getOrCreateAnonymousId(),U=[E,T,h].join("|")),o=document.createElement("div"),o.id=ee,n?(((typeof v=="string"?document.querySelector(v):v)??document.body).appendChild(o),o.style.cssText="position:relative;width:100%;height:100%"):(document.body.appendChild(o),o.style.cssText=`position:fixed;inset:0;z-index:${B};width:100vw;height:100dvh;pointer-events:none;clip-path:${_()}`),t=document.createElement("iframe"),t.src=f,t.title="Kin AI Chat",t.allow="clipboard-write",t.style.cssText="border:0;background:transparent;visibility:hidden;width:100%;height:100%",n&&(t.style.cssText+=";position:absolute;inset:0"),t.addEventListener("load",()=>a({type:"kin:init",payload:{instanceId:R,publishableKey:E,anonymousId:h,serviceUrl:T,theme:d,logo:V,starterPrompts:K,placement:W,embedded:n,launcher:z}}),{once:!0}),window.addEventListener("message",M),o.appendChild(t),typeof BroadcastChannel<"u"&&(s=new BroadcastChannel("kin-sync"),s.addEventListener("message",Z))}},H=()=>{window.removeEventListener("message",M),s==null||s.close(),s=null,t==null||t.remove(),t=null,o==null||o.remove(),o=null,l=!1,I=n,m=n,p={top:"calc(100% - 64px)",right:"0",bottom:"0",left:"0"},S(!1)},$=()=>{b(),c(!0),l&&a({type:"kin:open"})},A=()=>{c(!1),l&&a({type:"kin:close"})};return{prepare:()=>{typeof window>"u"||(b(),C.info("Kin plugin prepared"))},open:()=>{if(!(typeof window>"u")){if(n){b();return}$()}},close:()=>{typeof window>"u"||n||A()},toggle:()=>{if(!(typeof window>"u")){if(n){b();return}m?A():$()}},setAppearance:(e={})=>{d={accentColor:e.accentColor??d.accentColor,neutralColor:e.neutralColor??d.neutralColor,mode:e.mode??d.mode,rounded:e.rounded??d.rounded},l&&a({type:"kin:set-appearance",payload:d})},destroy:()=>{typeof window>"u"||(l&&a({type:"kin:destroy"}),H(),C.info("Kin plugin destroyed"))}}});exports.kinPlugin=ie;
|
package/dist/plugin-kin.js
CHANGED
|
@@ -1,5 +1,198 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { createPlugin as X, generateUUID as Y, getOrCreateAnonymousId as ee } from "@inploi/sdk";
|
|
2
|
+
const te = (r) => typeof r == "object" && r !== null && typeof r.type == "string" && r.type.startsWith("kin:"), ne = "inploi-kin-root", oe = 2147483647, k = {
|
|
3
|
+
accentColor: "#FF4D00",
|
|
4
|
+
neutralColor: "#555555",
|
|
5
|
+
mode: "light",
|
|
6
|
+
rounded: "lg"
|
|
7
|
+
}, ie = {
|
|
8
|
+
production: "wss://agents.inploi.com",
|
|
9
|
+
sandbox: "wss://agents.staging.inploi.com"
|
|
10
|
+
}, re = (() => {
|
|
11
|
+
var g;
|
|
12
|
+
if ({}.VITE_KIN_FRAME_URL)
|
|
13
|
+
return {}.VITE_KIN_FRAME_URL;
|
|
14
|
+
const r = typeof document < "u" ? (g = document.currentScript) == null ? void 0 : g.src : void 0;
|
|
15
|
+
return r ? new URL("./frame/index.html", r).href : null;
|
|
16
|
+
})(), le = ({
|
|
17
|
+
serviceUrl: r,
|
|
18
|
+
frameUrl: g,
|
|
19
|
+
appearance: F = {},
|
|
20
|
+
starterPrompts: K = [],
|
|
21
|
+
container: v
|
|
22
|
+
}) => X(({
|
|
23
|
+
logger: C,
|
|
24
|
+
publishableKey: E,
|
|
25
|
+
env: M
|
|
26
|
+
}) => {
|
|
27
|
+
const L = r ?? ie[M ?? "production"];
|
|
28
|
+
if (!E)
|
|
29
|
+
throw new Error("Kin plugin requires a publishableKey. Pass it to initialiseSdk().");
|
|
30
|
+
const {
|
|
31
|
+
accentColor: O = k.accentColor,
|
|
32
|
+
neutralColor: D = k.neutralColor,
|
|
33
|
+
mode: P = k.mode,
|
|
34
|
+
rounded: j = k.rounded,
|
|
35
|
+
placement: p = "center",
|
|
36
|
+
launcher: x = {},
|
|
37
|
+
zIndex: q = oe,
|
|
38
|
+
logo: N = null
|
|
39
|
+
} = F, R = Y(), n = p === "embedded", V = typeof p == "object" ? {
|
|
40
|
+
desktop: p.desktop ?? "center",
|
|
41
|
+
mobile: p.mobile ?? "center"
|
|
42
|
+
} : {
|
|
43
|
+
desktop: n ? "center" : p,
|
|
44
|
+
mobile: n ? "center" : p
|
|
45
|
+
}, W = {
|
|
46
|
+
desktop: x.desktop ?? "input",
|
|
47
|
+
mobile: x.mobile ?? "icon"
|
|
48
|
+
}, z = String(q);
|
|
49
|
+
let d = {
|
|
50
|
+
accentColor: O,
|
|
51
|
+
neutralColor: D,
|
|
52
|
+
mode: P,
|
|
53
|
+
rounded: j
|
|
54
|
+
}, f = "", w = "", h = "", U = "", o = null, t = null, s = null, l = !1, I = n, m = n, y = null, u = {
|
|
55
|
+
top: "calc(100% - 64px)",
|
|
56
|
+
right: "0",
|
|
57
|
+
bottom: "0",
|
|
58
|
+
left: "0"
|
|
59
|
+
};
|
|
60
|
+
const a = (e) => {
|
|
61
|
+
var i;
|
|
62
|
+
w && ((i = t == null ? void 0 : t.contentWindow) == null || i.postMessage(e, w));
|
|
63
|
+
}, T = (e) => {
|
|
64
|
+
n || (e && y === null ? (y = document.documentElement.style.overflow, document.documentElement.style.overflow = "hidden") : !e && y !== null && (document.documentElement.style.overflow = y, y = null));
|
|
65
|
+
}, _ = () => `inset(${u.top} ${u.right} ${u.bottom} ${u.left})`, c = (e) => {
|
|
66
|
+
m = e, !(e && !l) && (T(e), o && (o.style.clipPath = e ? "inset(0)" : _(), o.style.pointerEvents = e || l && I ? "all" : "none"));
|
|
67
|
+
}, S = (e) => {
|
|
68
|
+
if (e.source !== (t == null ? void 0 : t.contentWindow) || e.origin !== w || !te(e.data))
|
|
69
|
+
return;
|
|
70
|
+
const i = e.data;
|
|
71
|
+
switch (i.type) {
|
|
72
|
+
case "kin:ready":
|
|
73
|
+
l = !0, t && (t.style.visibility = "visible"), m && !n ? (c(!0), a({
|
|
74
|
+
type: "kin:open"
|
|
75
|
+
})) : n || c(!1);
|
|
76
|
+
break;
|
|
77
|
+
case "kin:request-close":
|
|
78
|
+
c(!1);
|
|
79
|
+
break;
|
|
80
|
+
case "kin:opened":
|
|
81
|
+
n || c(!0);
|
|
82
|
+
break;
|
|
83
|
+
case "kin:clip-inset":
|
|
84
|
+
if (I = !0, !m) {
|
|
85
|
+
const {
|
|
86
|
+
top: H,
|
|
87
|
+
right: G,
|
|
88
|
+
bottom: J,
|
|
89
|
+
left: Q
|
|
90
|
+
} = i.payload;
|
|
91
|
+
u = {
|
|
92
|
+
top: `${H}px`,
|
|
93
|
+
right: `${G}px`,
|
|
94
|
+
bottom: `${J}px`,
|
|
95
|
+
left: `${Q}px`
|
|
96
|
+
}, c(!1);
|
|
97
|
+
}
|
|
98
|
+
break;
|
|
99
|
+
case "kin:state-snapshot":
|
|
100
|
+
s == null || s.postMessage(i.payload);
|
|
101
|
+
break;
|
|
102
|
+
case "kin:error":
|
|
103
|
+
C.error(i.payload.message);
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}, B = (e) => {
|
|
107
|
+
const i = e.data;
|
|
108
|
+
!U || !i || i.syncKey !== U || i.sourceInstanceId === R || !l || a({
|
|
109
|
+
type: "kin:sync-snapshot",
|
|
110
|
+
payload: i
|
|
111
|
+
});
|
|
112
|
+
}, b = () => {
|
|
113
|
+
if (!t) {
|
|
114
|
+
if (!f) {
|
|
115
|
+
if (f = g || re || "", !f)
|
|
116
|
+
throw new Error("Kin frame URL could not be resolved automatically. Pass `frameUrl` when using the npm build, or load the CDN bundle via a <script> tag.");
|
|
117
|
+
w = new URL(f, window.location.href).origin;
|
|
118
|
+
}
|
|
119
|
+
h || (h = ee(), U = [E, L, h].join("|")), o = document.createElement("div"), o.id = ne, n ? (((typeof v == "string" ? document.querySelector(v) : v) ?? document.body).appendChild(o), o.style.cssText = "position:relative;width:100%;height:100%") : (document.body.appendChild(o), o.style.cssText = `position:fixed;inset:0;z-index:${z};width:100vw;height:100dvh;pointer-events:none;clip-path:${_()}`), t = document.createElement("iframe"), t.src = f, t.title = "Kin AI Chat", t.allow = "clipboard-write", t.style.cssText = "border:0;background:transparent;visibility:hidden;width:100%;height:100%", n && (t.style.cssText += ";position:absolute;inset:0"), t.addEventListener("load", () => a({
|
|
120
|
+
type: "kin:init",
|
|
121
|
+
payload: {
|
|
122
|
+
instanceId: R,
|
|
123
|
+
publishableKey: E,
|
|
124
|
+
anonymousId: h,
|
|
125
|
+
serviceUrl: L,
|
|
126
|
+
theme: d,
|
|
127
|
+
logo: N,
|
|
128
|
+
starterPrompts: K,
|
|
129
|
+
placement: V,
|
|
130
|
+
embedded: n,
|
|
131
|
+
launcher: W
|
|
132
|
+
}
|
|
133
|
+
}), {
|
|
134
|
+
once: !0
|
|
135
|
+
}), window.addEventListener("message", S), o.appendChild(t), typeof BroadcastChannel < "u" && (s = new BroadcastChannel("kin-sync"), s.addEventListener("message", B));
|
|
136
|
+
}
|
|
137
|
+
}, Z = () => {
|
|
138
|
+
window.removeEventListener("message", S), s == null || s.close(), s = null, t == null || t.remove(), t = null, o == null || o.remove(), o = null, l = !1, I = n, m = n, u = {
|
|
139
|
+
top: "calc(100% - 64px)",
|
|
140
|
+
right: "0",
|
|
141
|
+
bottom: "0",
|
|
142
|
+
left: "0"
|
|
143
|
+
}, T(!1);
|
|
144
|
+
}, $ = () => {
|
|
145
|
+
b(), c(!0), l && a({
|
|
146
|
+
type: "kin:open"
|
|
147
|
+
});
|
|
148
|
+
}, A = () => {
|
|
149
|
+
c(!1), l && a({
|
|
150
|
+
type: "kin:close"
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
return {
|
|
154
|
+
prepare: () => {
|
|
155
|
+
typeof window > "u" || (b(), C.info("Kin plugin prepared"));
|
|
156
|
+
},
|
|
157
|
+
open: () => {
|
|
158
|
+
if (!(typeof window > "u")) {
|
|
159
|
+
if (n) {
|
|
160
|
+
b();
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
$();
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
close: () => {
|
|
167
|
+
typeof window > "u" || n || A();
|
|
168
|
+
},
|
|
169
|
+
toggle: () => {
|
|
170
|
+
if (!(typeof window > "u")) {
|
|
171
|
+
if (n) {
|
|
172
|
+
b();
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
m ? A() : $();
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
setAppearance: (e = {}) => {
|
|
179
|
+
d = {
|
|
180
|
+
accentColor: e.accentColor ?? d.accentColor,
|
|
181
|
+
neutralColor: e.neutralColor ?? d.neutralColor,
|
|
182
|
+
mode: e.mode ?? d.mode,
|
|
183
|
+
rounded: e.rounded ?? d.rounded
|
|
184
|
+
}, l && a({
|
|
185
|
+
type: "kin:set-appearance",
|
|
186
|
+
payload: d
|
|
187
|
+
});
|
|
188
|
+
},
|
|
189
|
+
destroy: () => {
|
|
190
|
+
typeof window > "u" || (l && a({
|
|
191
|
+
type: "kin:destroy"
|
|
192
|
+
}), Z(), C.info("Kin plugin destroyed"));
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
});
|
|
3
196
|
export {
|
|
4
|
-
|
|
197
|
+
le as kinPlugin
|
|
5
198
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inploi/plugin-kin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Kin - A unified Talent Agent interface for hiring. One system, many roles.",
|
|
6
6
|
"main": "dist/plugin-kin.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@inploi/sdk": ">=1.
|
|
23
|
+
"@inploi/sdk": ">=1.18.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@preact/preset-vite": "2.5.0",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"vite": "^4.4.5",
|
|
36
36
|
"vite-plugin-dts": "^3.7.0",
|
|
37
37
|
"vite-tsconfig-paths": "^4.2.1",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
38
|
+
"tsconfig": "0.1.0",
|
|
39
|
+
"@inploi/sdk": "1.18.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"streamdown": "^2.3.0",
|
|
@@ -45,8 +45,9 @@
|
|
|
45
45
|
"scripts": {
|
|
46
46
|
"dev": "vite",
|
|
47
47
|
"build:cdn": "VITE_MOCKS=false vite build --mode=cdn",
|
|
48
|
+
"build:frame": "VITE_MOCKS=false vite build --mode=frame",
|
|
48
49
|
"build:npm": "VITE_MOCKS=false vite build --mode=production",
|
|
49
|
-
"build": "
|
|
50
|
+
"build": "pnpm build:npm && pnpm build:cdn && pnpm build:frame",
|
|
50
51
|
"check": "tsc"
|
|
51
52
|
}
|
|
52
53
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-45f58435.cjs");require("@inploi/sdk");var c=({code:g,language:l,raw:r,className:u,...s})=>{let{shikiTheme:t}=e.q(e.R),a=e.Ks(),[h,i]=e.h(r);return e.p(()=>{if(!a){i(r);return}let o=a.highlight({code:g,language:l,themes:t},n=>{i(n)});o&&i(o)},[g,l,t,a,r]),e.o(e.Qe,{className:u,language:l,result:h,...s})};exports.HighlightedCodeBlockBody=c;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { q as u, R as c, K as d, h as n, p, o as f, Q as k } from "./index-d554999b.js";
|
|
2
|
-
import "@inploi/sdk";
|
|
3
|
-
var N = ({ code: o, language: e, raw: a, className: s, ...h }) => {
|
|
4
|
-
let { shikiTheme: r } = u(c), l = d(), [t, g] = n(a);
|
|
5
|
-
return p(() => {
|
|
6
|
-
if (!l) {
|
|
7
|
-
g(a);
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
let i = l.highlight({ code: o, language: e, themes: r }, (m) => {
|
|
11
|
-
g(m);
|
|
12
|
-
});
|
|
13
|
-
i && g(i);
|
|
14
|
-
}, [o, e, r, l, a]), f(k, { className: s, language: e, result: t, ...h });
|
|
15
|
-
};
|
|
16
|
-
export {
|
|
17
|
-
N as HighlightedCodeBlockBody
|
|
18
|
-
};
|