@baguette-studios/kernl-ui-core 0.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/dist/icons.js ADDED
@@ -0,0 +1,249 @@
1
+ export const agentIconNodes = {
2
+ "archive": [
3
+ ["rect", { width: "20", height: "5", x: "2", y: "3", rx: "1" }],
4
+ ["path", { d: "M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8" }],
5
+ ["path", { d: "M10 12h4" }]
6
+ ],
7
+ "arrow-right": [
8
+ ["path", { d: "M5 12h14" }],
9
+ ["path", { d: "m12 5 7 7-7 7" }]
10
+ ],
11
+ "arrow-up-right": [
12
+ ["path", { d: "M7 7h10v10" }],
13
+ ["path", { d: "M7 17 17 7" }]
14
+ ],
15
+ "badge-dollar-sign": [
16
+ ["path", { d: "M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z" }],
17
+ ["path", { d: "M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8" }],
18
+ ["path", { d: "M12 18V6" }]
19
+ ],
20
+ "bell-ring": [
21
+ ["path", { d: "M10.268 21a2 2 0 0 0 3.464 0" }],
22
+ ["path", { d: "M22 8c0-2.3-.8-4.3-2-6" }],
23
+ ["path", { d: "M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326" }],
24
+ ["path", { d: "M4 2C2.8 3.7 2 5.7 2 8" }]
25
+ ],
26
+ "bot": [
27
+ ["path", { d: "M12 8V4H8" }],
28
+ ["rect", { width: "16", height: "12", x: "4", y: "8", rx: "2" }],
29
+ ["path", { d: "M2 14h2" }],
30
+ ["path", { d: "M20 14h2" }],
31
+ ["path", { d: "M15 13v2" }],
32
+ ["path", { d: "M9 13v2" }]
33
+ ],
34
+ "building-2": [
35
+ ["path", { d: "M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z" }],
36
+ ["path", { d: "M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2" }],
37
+ ["path", { d: "M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2" }],
38
+ ["path", { d: "M10 6h4" }],
39
+ ["path", { d: "M10 10h4" }],
40
+ ["path", { d: "M10 14h4" }],
41
+ ["path", { d: "M10 18h4" }]
42
+ ],
43
+ "calendar-clock": [
44
+ ["path", { d: "M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5" }],
45
+ ["path", { d: "M16 2v4" }],
46
+ ["path", { d: "M8 2v4" }],
47
+ ["path", { d: "M3 10h5" }],
48
+ ["path", { d: "M17.5 17.5 16 16.3V14" }],
49
+ ["circle", { cx: "16", cy: "16", r: "6" }]
50
+ ],
51
+ "check": [
52
+ ["path", { d: "M20 6 9 17l-5-5" }]
53
+ ],
54
+ "check-circle-2": [
55
+ ["circle", { cx: "12", cy: "12", r: "10" }],
56
+ ["path", { d: "m9 12 2 2 4-4" }]
57
+ ],
58
+ "chevron-right": [
59
+ ["path", { d: "m9 18 6-6-6-6" }]
60
+ ],
61
+ "circle-dollar-sign": [
62
+ ["circle", { cx: "12", cy: "12", r: "10" }],
63
+ ["path", { d: "M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8" }],
64
+ ["path", { d: "M12 18V6" }]
65
+ ],
66
+ "clipboard-check": [
67
+ ["rect", { width: "8", height: "4", x: "8", y: "2", rx: "1", ry: "1" }],
68
+ ["path", { d: "M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2" }],
69
+ ["path", { d: "m9 14 2 2 4-4" }]
70
+ ],
71
+ "clock-3": [
72
+ ["circle", { cx: "12", cy: "12", r: "10" }],
73
+ ["polyline", { points: "12 6 12 12 16.5 12" }]
74
+ ],
75
+ "external-link": [
76
+ ["path", { d: "M15 3h6v6" }],
77
+ ["path", { d: "M10 14 21 3" }],
78
+ ["path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" }]
79
+ ],
80
+ "file-text": [
81
+ ["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z" }],
82
+ ["path", { d: "M14 2v4a2 2 0 0 0 2 2h4" }],
83
+ ["path", { d: "M10 9H8" }],
84
+ ["path", { d: "M16 13H8" }],
85
+ ["path", { d: "M16 17H8" }]
86
+ ],
87
+ "filter": [
88
+ ["polygon", { points: "22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3" }]
89
+ ],
90
+ "git-branch": [
91
+ ["line", { x1: "6", x2: "6", y1: "3", y2: "15" }],
92
+ ["circle", { cx: "18", cy: "6", r: "3" }],
93
+ ["circle", { cx: "6", cy: "18", r: "3" }],
94
+ ["path", { d: "M18 9a9 9 0 0 1-9 9" }]
95
+ ],
96
+ "history": [
97
+ ["path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" }],
98
+ ["path", { d: "M3 3v5h5" }],
99
+ ["path", { d: "M12 7v5l4 2" }]
100
+ ],
101
+ "landmark": [
102
+ ["line", { x1: "3", x2: "21", y1: "22", y2: "22" }],
103
+ ["line", { x1: "6", x2: "6", y1: "18", y2: "11" }],
104
+ ["line", { x1: "10", x2: "10", y1: "18", y2: "11" }],
105
+ ["line", { x1: "14", x2: "14", y1: "18", y2: "11" }],
106
+ ["line", { x1: "18", x2: "18", y1: "18", y2: "11" }],
107
+ ["polygon", { points: "12 2 20 7 4 7" }]
108
+ ],
109
+ "life-buoy": [
110
+ ["circle", { cx: "12", cy: "12", r: "10" }],
111
+ ["path", { d: "m4.93 4.93 4.24 4.24" }],
112
+ ["path", { d: "m14.83 9.17 4.24-4.24" }],
113
+ ["path", { d: "m14.83 14.83 4.24 4.24" }],
114
+ ["path", { d: "m9.17 14.83-4.24 4.24" }],
115
+ ["circle", { cx: "12", cy: "12", r: "4" }]
116
+ ],
117
+ "list-checks": [
118
+ ["path", { d: "m3 17 2 2 4-4" }],
119
+ ["path", { d: "m3 7 2 2 4-4" }],
120
+ ["path", { d: "M13 6h8" }],
121
+ ["path", { d: "M13 12h8" }],
122
+ ["path", { d: "M13 18h8" }]
123
+ ],
124
+ "mail-check": [
125
+ ["path", { d: "M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8" }],
126
+ ["path", { d: "m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7" }],
127
+ ["path", { d: "m16 19 2 2 4-4" }]
128
+ ],
129
+ "mail-plus": [
130
+ ["path", { d: "M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8" }],
131
+ ["path", { d: "m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7" }],
132
+ ["path", { d: "M19 16v6" }],
133
+ ["path", { d: "M16 19h6" }]
134
+ ],
135
+ "message-circle": [
136
+ ["path", { d: "M7.9 20A9 9 0 1 0 4 16.1L2 22Z" }]
137
+ ],
138
+ "message-square-text": [
139
+ ["path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" }],
140
+ ["path", { d: "M13 8H7" }],
141
+ ["path", { d: "M17 12H7" }]
142
+ ],
143
+ "notebook-pen": [
144
+ ["path", { d: "M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4" }],
145
+ ["path", { d: "M2 6h4" }],
146
+ ["path", { d: "M2 10h4" }],
147
+ ["path", { d: "M2 14h4" }],
148
+ ["path", { d: "M2 18h4" }],
149
+ ["path", { d: "M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z" }]
150
+ ],
151
+ "panel-right": [
152
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2" }],
153
+ ["path", { d: "M15 3v18" }]
154
+ ],
155
+ "panel-right-open": [
156
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2" }],
157
+ ["path", { d: "M15 3v18" }],
158
+ ["path", { d: "m10 15-3-3 3-3" }]
159
+ ],
160
+ "play": [
161
+ ["polygon", { points: "6 3 20 12 6 21 6 3" }]
162
+ ],
163
+ "plus": [
164
+ ["path", { d: "M5 12h14" }],
165
+ ["path", { d: "M12 5v14" }]
166
+ ],
167
+ "radio": [
168
+ ["path", { d: "M4.9 19.1C1 15.2 1 8.8 4.9 4.9" }],
169
+ ["path", { d: "M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5" }],
170
+ ["circle", { cx: "12", cy: "12", r: "2" }],
171
+ ["path", { d: "M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5" }],
172
+ ["path", { d: "M19.1 4.9C23 8.8 23 15.1 19.1 19" }]
173
+ ],
174
+ "receipt-text": [
175
+ ["path", { d: "M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z" }],
176
+ ["path", { d: "M14 8H8" }],
177
+ ["path", { d: "M16 12H8" }],
178
+ ["path", { d: "M13 16H8" }]
179
+ ],
180
+ "route": [
181
+ ["circle", { cx: "6", cy: "19", r: "3" }],
182
+ ["path", { d: "M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15" }],
183
+ ["circle", { cx: "18", cy: "5", r: "3" }]
184
+ ],
185
+ "search": [
186
+ ["circle", { cx: "11", cy: "11", r: "8" }],
187
+ ["path", { d: "m21 21-4.3-4.3" }]
188
+ ],
189
+ "settings": [
190
+ ["path", { d: "M9.67 2.8a2.2 2.2 0 0 1 4.66 0l.18 1.07a2.2 2.2 0 0 0 3.23 1.86l.96-.45a2.2 2.2 0 0 1 2.33 4.04l-.88.62a2.2 2.2 0 0 0 0 3.72l.88.62a2.2 2.2 0 0 1-2.33 4.04l-.96-.45a2.2 2.2 0 0 0-3.23 1.86l-.18 1.07a2.2 2.2 0 0 1-4.66 0l-.18-1.07a2.2 2.2 0 0 0-3.23-1.86l-.96.45a2.2 2.2 0 0 1-2.33-4.04l.88-.62a2.2 2.2 0 0 0 0-3.72l-.88-.62a2.2 2.2 0 0 1 2.33-4.04l.96.45a2.2 2.2 0 0 0 3.23-1.86Z" }],
191
+ ["circle", { cx: "12", cy: "12", r: "3" }]
192
+ ],
193
+ "send": [
194
+ ["path", { d: "M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z" }],
195
+ ["path", { d: "m21.854 2.147-10.94 10.939" }]
196
+ ],
197
+ "shield-check": [
198
+ ["path", { d: "M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z" }],
199
+ ["path", { d: "m9 12 2 2 4-4" }]
200
+ ],
201
+ "sparkles": [
202
+ ["path", { d: "M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z" }],
203
+ ["path", { d: "M20 3v4" }],
204
+ ["path", { d: "M22 5h-4" }],
205
+ ["path", { d: "M4 17v2" }],
206
+ ["path", { d: "M5 18H3" }]
207
+ ],
208
+ "target": [
209
+ ["circle", { cx: "12", cy: "12", r: "10" }],
210
+ ["circle", { cx: "12", cy: "12", r: "6" }],
211
+ ["circle", { cx: "12", cy: "12", r: "2" }]
212
+ ],
213
+ "terminal-square": [
214
+ ["path", { d: "m7 11 2-2-2-2" }],
215
+ ["path", { d: "M11 13h4" }],
216
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2" }]
217
+ ],
218
+ "trending-up": [
219
+ ["polyline", { points: "22 7 13.5 15.5 8.5 10.5 2 17" }],
220
+ ["polyline", { points: "16 7 22 7 22 13" }]
221
+ ],
222
+ "triangle-alert": [
223
+ ["path", { d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" }],
224
+ ["path", { d: "M12 9v4" }],
225
+ ["path", { d: "M12 17h.01" }]
226
+ ],
227
+ "user-round": [
228
+ ["circle", { cx: "12", cy: "8", r: "5" }],
229
+ ["path", { d: "M20 21a8 8 0 0 0-16 0" }]
230
+ ],
231
+ "wallet-cards": [
232
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2" }],
233
+ ["path", { d: "M3 9a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2" }],
234
+ ["path", { d: "M3 11h3c.8 0 1.6.3 2.1.9l1.1.9c1.6 1.6 4.1 1.6 5.7 0l1.1-.9c.5-.5 1.3-.9 2.1-.9H21" }]
235
+ ],
236
+ "wrench": [
237
+ ["path", { d: "M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z" }]
238
+ ],
239
+ "x": [
240
+ ["path", { d: "M18 6 6 18" }],
241
+ ["path", { d: "m6 6 12 12" }]
242
+ ]
243
+ };
244
+ export function isAgentIconName(name) {
245
+ return name in agentIconNodes;
246
+ }
247
+ export function getAgentIconNode(name) {
248
+ return agentIconNodes[name];
249
+ }
@@ -0,0 +1,12 @@
1
+ export { agentIconNodes, getAgentIconNode, isAgentIconName, } from "./icons";
2
+ export type { AgentAsset } from "@baguette-studios/kernl-core";
3
+ export type { AgentIconAttributes, AgentIconElementName, AgentIconName, AgentIconNode, } from "./icons";
4
+ export { agentConversationBackgroundPresets, agentThemePresets, createAgentThemeAttributes, createAgentThemeVars, isAgentThemeVariable, } from "./theme";
5
+ export type { AgentConversationBackgroundOverride, AgentConversationBackgroundPreset, AgentConversationTheme, AgentTheme, AgentThemeAttributes, AgentThemeColors, AgentThemeInput, AgentThemePresetId, AgentThemeRadius, AgentThemeSpacing, AgentThemeVariable, AgentThemeVars, } from "./theme";
6
+ export { deriveActivity, deriveAgentUiSnapshot, deriveApprovalActions, deriveCommands, deriveQuickActions, deriveStatus, parseCommandArgs, } from "./derive";
7
+ export type { AgentUiApprovalController, AgentUiOverrides, DeriveAgentUiSnapshotOptions, OptionalAgentUiOverride, } from "./derive";
8
+ export { cx, firstPendingAction, formatRelativeAge, formatTimestamp, humanizeStatus, riskTone, statusTone, } from "./utils";
9
+ export { AGENT_UI_PREFERENCES_CHANGE_EVENT, AGENT_UI_PREFERENCES_STORAGE_KEY, DEFAULT_AGENT_UI_PREFERENCES, agentPanelShortcutFromKeyboardEvent, formatAgentPanelShortcut, isAgentPanelPortalTarget, loadAgentUiPreferences, matchesAgentPanelShortcut, normalizeAgentUiPreferences, saveAgentUiPreferences, shouldHandleAgentPanelShortcut, shouldPreventAgentPanelShortcutDefault, } from "./panel";
10
+ export type { AgentPanelStorageLike, AgentPanelShortcut, AgentSidePanelPreferences, AgentUiPreferences, } from "./panel";
11
+ export type { AgentActionRequest, AgentActivityItem, AgentChatMessage, AgentChatRole, AgentChatThread, AgentCommand, AgentComponentProps, AgentPromptSubmitOptions, AgentPromptSubmitResult, AgentQuickAction, AgentRenderable, AgentRisk, AgentStatus, AgentTone, AgentUiSnapshot, } from "./types";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,eAAe,GAChB,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC/D,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,EACb,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,kCAAkC,EAClC,iBAAiB,EACjB,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,mCAAmC,EACnC,iCAAiC,EACjC,sBAAsB,EACtB,UAAU,EACV,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,GACjB,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,yBAAyB,EACzB,gBAAgB,EAChB,4BAA4B,EAC5B,uBAAuB,GACxB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,EAAE,EACF,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,QAAQ,EACR,UAAU,GACX,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,iCAAiC,EACjC,gCAAgC,EAChC,4BAA4B,EAC5B,mCAAmC,EACnC,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,EACtB,yBAAyB,EACzB,2BAA2B,EAC3B,sBAAsB,EACtB,8BAA8B,EAC9B,sCAAsC,GACvC,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,qBAAqB,EACrB,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EACvB,gBAAgB,EAChB,eAAe,EACf,SAAS,EACT,WAAW,EACX,SAAS,EACT,eAAe,GAChB,MAAM,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export { agentIconNodes, getAgentIconNode, isAgentIconName, } from "./icons";
2
+ export { agentConversationBackgroundPresets, agentThemePresets, createAgentThemeAttributes, createAgentThemeVars, isAgentThemeVariable, } from "./theme";
3
+ export { deriveActivity, deriveAgentUiSnapshot, deriveApprovalActions, deriveCommands, deriveQuickActions, deriveStatus, parseCommandArgs, } from "./derive";
4
+ export { cx, firstPendingAction, formatRelativeAge, formatTimestamp, humanizeStatus, riskTone, statusTone, } from "./utils";
5
+ export { AGENT_UI_PREFERENCES_CHANGE_EVENT, AGENT_UI_PREFERENCES_STORAGE_KEY, DEFAULT_AGENT_UI_PREFERENCES, agentPanelShortcutFromKeyboardEvent, formatAgentPanelShortcut, isAgentPanelPortalTarget, loadAgentUiPreferences, matchesAgentPanelShortcut, normalizeAgentUiPreferences, saveAgentUiPreferences, shouldHandleAgentPanelShortcut, shouldPreventAgentPanelShortcutDefault, } from "./panel";
@@ -0,0 +1,31 @@
1
+ export type AgentPanelShortcut = string | {
2
+ key: string;
3
+ altKey?: boolean | undefined;
4
+ ctrlKey?: boolean | undefined;
5
+ metaKey?: boolean | undefined;
6
+ shiftKey?: boolean | undefined;
7
+ preventDefault?: boolean | undefined;
8
+ disabledWhenTyping?: boolean | undefined;
9
+ };
10
+ export type AgentSidePanelPreferences = {
11
+ closeOnOutsideClick: boolean;
12
+ toggleShortcut: string;
13
+ };
14
+ export type AgentUiPreferences = {
15
+ version: 1;
16
+ sidePanel: AgentSidePanelPreferences;
17
+ };
18
+ export type AgentPanelStorageLike = Pick<Storage, "getItem" | "setItem" | "removeItem">;
19
+ export declare const AGENT_UI_PREFERENCES_STORAGE_KEY = "kernl:ui-preferences:v1";
20
+ export declare const AGENT_UI_PREFERENCES_CHANGE_EVENT = "kernl:ui-preferences-change";
21
+ export declare const DEFAULT_AGENT_UI_PREFERENCES: AgentUiPreferences;
22
+ export declare function matchesAgentPanelShortcut(event: Pick<KeyboardEvent, "key" | "altKey" | "ctrlKey" | "metaKey" | "shiftKey">, shortcut: AgentPanelShortcut | false | undefined): boolean;
23
+ export declare function shouldHandleAgentPanelShortcut(event: KeyboardEvent, shortcut: AgentPanelShortcut | false | undefined): boolean;
24
+ export declare function shouldPreventAgentPanelShortcutDefault(shortcut: AgentPanelShortcut | false | undefined): boolean;
25
+ export declare function isAgentPanelPortalTarget(target: EventTarget | null): boolean;
26
+ export declare function loadAgentUiPreferences(storage?: AgentPanelStorageLike | undefined): AgentUiPreferences;
27
+ export declare function saveAgentUiPreferences(preferences: AgentUiPreferences, storage?: AgentPanelStorageLike | undefined): AgentUiPreferences;
28
+ export declare function normalizeAgentUiPreferences(value: unknown): AgentUiPreferences;
29
+ export declare function agentPanelShortcutFromKeyboardEvent(event: KeyboardEvent): string | undefined;
30
+ export declare function formatAgentPanelShortcut(shortcut: string | undefined): string;
31
+ //# sourceMappingURL=panel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panel.d.ts","sourceRoot":"","sources":["../src/panel.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAC1B,MAAM,GACN;IACE,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACrC,kBAAkB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC1C,CAAC;AAEN,MAAM,MAAM,yBAAyB,GAAG;IACtC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,CAAC,CAAC;IACX,SAAS,EAAE,yBAAyB,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,YAAY,CAAC,CAAC;AAExF,eAAO,MAAM,gCAAgC,4BAA4B,CAAC;AAC1E,eAAO,MAAM,iCAAiC,gCAAgC,CAAC;AAE/E,eAAO,MAAM,4BAA4B,EAAE,kBAM1C,CAAC;AAYF,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,CAAC,EACjF,QAAQ,EAAE,kBAAkB,GAAG,KAAK,GAAG,SAAS,GAC/C,OAAO,CAaT;AAED,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,kBAAkB,GAAG,KAAK,GAAG,SAAS,GAC/C,OAAO,CAST;AAED,wBAAgB,sCAAsC,CACpD,QAAQ,EAAE,kBAAkB,GAAG,KAAK,GAAG,SAAS,GAC/C,OAAO,CAET;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,CAE5E;AAED,wBAAgB,sBAAsB,CACpC,OAAO,GAAE,qBAAqB,GAAG,SAAiC,GACjE,kBAAkB,CAUpB;AAED,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,kBAAkB,EAC/B,OAAO,GAAE,qBAAqB,GAAG,SAAiC,GACjE,kBAAkB,CAYpB;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,kBAAkB,CAkB9E;AAED,wBAAgB,mCAAmC,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAY5F;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CA2B7E"}
package/dist/panel.js ADDED
@@ -0,0 +1,262 @@
1
+ export const AGENT_UI_PREFERENCES_STORAGE_KEY = "kernl:ui-preferences:v1";
2
+ export const AGENT_UI_PREFERENCES_CHANGE_EVENT = "kernl:ui-preferences-change";
3
+ export const DEFAULT_AGENT_UI_PREFERENCES = {
4
+ version: 1,
5
+ sidePanel: {
6
+ closeOnOutsideClick: false,
7
+ toggleShortcut: "",
8
+ },
9
+ };
10
+ export function matchesAgentPanelShortcut(event, shortcut) {
11
+ const normalized = normalizeAgentPanelShortcut(shortcut);
12
+ if (!normalized) {
13
+ return false;
14
+ }
15
+ return (normalizeShortcutKey(event.key) === normalized.key &&
16
+ event.altKey === normalized.altKey &&
17
+ event.ctrlKey === normalized.ctrlKey &&
18
+ event.metaKey === normalized.metaKey &&
19
+ event.shiftKey === normalized.shiftKey);
20
+ }
21
+ export function shouldHandleAgentPanelShortcut(event, shortcut) {
22
+ const normalized = normalizeAgentPanelShortcut(shortcut);
23
+ if (!normalized || !matchesAgentPanelShortcut(event, normalized)) {
24
+ return false;
25
+ }
26
+ if (normalized.disabledWhenTyping && isEditableShortcutTarget(event.target)) {
27
+ return false;
28
+ }
29
+ return true;
30
+ }
31
+ export function shouldPreventAgentPanelShortcutDefault(shortcut) {
32
+ return normalizeAgentPanelShortcut(shortcut)?.preventDefault ?? false;
33
+ }
34
+ export function isAgentPanelPortalTarget(target) {
35
+ return target instanceof Element && Boolean(target.closest(".kernl-asset-modal"));
36
+ }
37
+ export function loadAgentUiPreferences(storage = browserLocalStorage()) {
38
+ if (!storage) {
39
+ return DEFAULT_AGENT_UI_PREFERENCES;
40
+ }
41
+ try {
42
+ return normalizeAgentUiPreferences(JSON.parse(storage.getItem(AGENT_UI_PREFERENCES_STORAGE_KEY) ?? "null"));
43
+ }
44
+ catch {
45
+ return DEFAULT_AGENT_UI_PREFERENCES;
46
+ }
47
+ }
48
+ export function saveAgentUiPreferences(preferences, storage = browserLocalStorage()) {
49
+ const normalized = normalizeAgentUiPreferences(preferences);
50
+ if (!storage) {
51
+ return normalized;
52
+ }
53
+ try {
54
+ storage.setItem(AGENT_UI_PREFERENCES_STORAGE_KEY, JSON.stringify(normalized));
55
+ }
56
+ catch {
57
+ return normalized;
58
+ }
59
+ return normalized;
60
+ }
61
+ export function normalizeAgentUiPreferences(value) {
62
+ const record = isRecord(value) ? value : {};
63
+ const sidePanel = isRecord(record.sidePanel) ? record.sidePanel : {};
64
+ const toggleShortcut = typeof sidePanel.toggleShortcut === "string"
65
+ ? normalizeShortcutStringValue(sidePanel.toggleShortcut)
66
+ : DEFAULT_AGENT_UI_PREFERENCES.sidePanel.toggleShortcut;
67
+ return {
68
+ version: 1,
69
+ sidePanel: {
70
+ closeOnOutsideClick: typeof sidePanel.closeOnOutsideClick === "boolean"
71
+ ? sidePanel.closeOnOutsideClick
72
+ : DEFAULT_AGENT_UI_PREFERENCES.sidePanel.closeOnOutsideClick,
73
+ toggleShortcut,
74
+ },
75
+ };
76
+ }
77
+ export function agentPanelShortcutFromKeyboardEvent(event) {
78
+ const key = normalizeShortcutKey(event.key);
79
+ if (!key || isModifierOnlyKey(key)) {
80
+ return undefined;
81
+ }
82
+ const modifiers = [];
83
+ if (event.ctrlKey)
84
+ modifiers.push("ctrl");
85
+ if (event.metaKey)
86
+ modifiers.push("meta");
87
+ if (event.altKey)
88
+ modifiers.push("alt");
89
+ if (event.shiftKey)
90
+ modifiers.push("shift");
91
+ return [...modifiers, shortcutKeyLabel(key)].join("+");
92
+ }
93
+ export function formatAgentPanelShortcut(shortcut) {
94
+ const normalized = normalizeShortcutStringValue(shortcut ?? "");
95
+ if (!normalized) {
96
+ return "";
97
+ }
98
+ return normalized
99
+ .split("+")
100
+ .map((token) => {
101
+ switch (token) {
102
+ case "ctrl":
103
+ return "Ctrl";
104
+ case "meta":
105
+ return isMacLikePlatform() ? "Cmd" : "Meta";
106
+ case "mod":
107
+ return isMacLikePlatform() ? "Cmd" : "Ctrl";
108
+ case "alt":
109
+ return isMacLikePlatform() ? "Option" : "Alt";
110
+ case "shift":
111
+ return "Shift";
112
+ case " ":
113
+ return "Space";
114
+ default:
115
+ return token.length === 1 ? token.toUpperCase() : token;
116
+ }
117
+ })
118
+ .join(" + ");
119
+ }
120
+ function normalizeAgentPanelShortcut(shortcut) {
121
+ if (!shortcut) {
122
+ return undefined;
123
+ }
124
+ if (typeof shortcut === "string") {
125
+ return normalizeShortcutString(shortcut);
126
+ }
127
+ const key = normalizeShortcutKey(shortcut.key);
128
+ if (!key) {
129
+ return undefined;
130
+ }
131
+ return {
132
+ key,
133
+ altKey: shortcut.altKey ?? false,
134
+ ctrlKey: shortcut.ctrlKey ?? false,
135
+ metaKey: shortcut.metaKey ?? false,
136
+ shiftKey: shortcut.shiftKey ?? false,
137
+ preventDefault: shortcut.preventDefault ?? true,
138
+ disabledWhenTyping: shortcut.disabledWhenTyping ?? true,
139
+ };
140
+ }
141
+ function normalizeShortcutString(shortcut) {
142
+ const tokens = shortcut
143
+ .split("+")
144
+ .map((token) => token.trim().toLowerCase())
145
+ .filter(Boolean);
146
+ const keyToken = tokens.at(-1);
147
+ const key = keyToken ? normalizeShortcutKey(keyToken) : "";
148
+ if (!key) {
149
+ return undefined;
150
+ }
151
+ const modifiers = new Set(tokens.slice(0, -1));
152
+ const modIsMeta = isMacLikePlatform();
153
+ return {
154
+ key,
155
+ altKey: modifiers.has("alt") || modifiers.has("option"),
156
+ ctrlKey: modifiers.has("ctrl") || modifiers.has("control") || (modifiers.has("mod") && !modIsMeta),
157
+ metaKey: modifiers.has("meta") || modifiers.has("cmd") || modifiers.has("command") || (modifiers.has("mod") && modIsMeta),
158
+ shiftKey: modifiers.has("shift"),
159
+ preventDefault: true,
160
+ disabledWhenTyping: true,
161
+ };
162
+ }
163
+ function normalizeShortcutStringValue(shortcut) {
164
+ const tokens = shortcut
165
+ .split("+")
166
+ .map((token) => token.trim().toLowerCase())
167
+ .filter(Boolean);
168
+ const keyToken = tokens.at(-1);
169
+ const key = keyToken ? normalizeShortcutKey(keyToken) : "";
170
+ if (!key || isModifierOnlyKey(key)) {
171
+ return "";
172
+ }
173
+ const modifiers = tokens.slice(0, -1).flatMap((token) => {
174
+ switch (token) {
175
+ case "control":
176
+ return ["ctrl"];
177
+ case "cmd":
178
+ case "command":
179
+ return ["meta"];
180
+ case "option":
181
+ return ["alt"];
182
+ case "ctrl":
183
+ case "meta":
184
+ case "mod":
185
+ case "alt":
186
+ case "shift":
187
+ return [token];
188
+ default:
189
+ return [];
190
+ }
191
+ });
192
+ return [...uniqueShortcutTokens(modifiers), shortcutKeyLabel(key)].join("+");
193
+ }
194
+ function normalizeShortcutKey(key) {
195
+ const normalized = key.trim().toLowerCase();
196
+ switch (normalized) {
197
+ case "esc":
198
+ return "escape";
199
+ case "space":
200
+ case "spacebar":
201
+ return " ";
202
+ case "arrowup":
203
+ case "up":
204
+ return "arrowup";
205
+ case "arrowdown":
206
+ case "down":
207
+ return "arrowdown";
208
+ case "arrowleft":
209
+ case "left":
210
+ return "arrowleft";
211
+ case "arrowright":
212
+ case "right":
213
+ return "arrowright";
214
+ default:
215
+ return normalized;
216
+ }
217
+ }
218
+ function shortcutKeyLabel(key) {
219
+ return key === " " ? "space" : key;
220
+ }
221
+ function isModifierOnlyKey(key) {
222
+ return key === "shift" || key === "control" || key === "ctrl" || key === "meta" || key === "alt";
223
+ }
224
+ function uniqueShortcutTokens(tokens) {
225
+ const result = [];
226
+ for (const token of tokens) {
227
+ if (!result.includes(token)) {
228
+ result.push(token);
229
+ }
230
+ }
231
+ return result;
232
+ }
233
+ function isMacLikePlatform() {
234
+ if (typeof navigator === "undefined") {
235
+ return true;
236
+ }
237
+ return /mac|iphone|ipad|ipod/i.test(navigator.platform);
238
+ }
239
+ function isEditableShortcutTarget(target) {
240
+ if (!(target instanceof Element)) {
241
+ return false;
242
+ }
243
+ const element = target.closest("input, textarea, select, [contenteditable]");
244
+ if (!element) {
245
+ return false;
246
+ }
247
+ if (element instanceof HTMLElement && element.isContentEditable) {
248
+ return true;
249
+ }
250
+ return element.matches("input, textarea, select");
251
+ }
252
+ function browserLocalStorage() {
253
+ try {
254
+ return typeof window === "undefined" ? undefined : window.localStorage;
255
+ }
256
+ catch {
257
+ return undefined;
258
+ }
259
+ }
260
+ function isRecord(value) {
261
+ return value !== null && typeof value === "object";
262
+ }