@openviking/react 0.1.0 → 0.1.2

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 (193) hide show
  1. package/README.md +57 -34
  2. package/dist/3~0.js +2117 -0
  3. package/dist/ark-message-list-view~0.js +310 -0
  4. package/dist/a~0.js +21 -0
  5. package/dist/c7~0.js +24 -0
  6. package/dist/client/client.d.ts +12 -0
  7. package/dist/client/errors.d.ts +30 -0
  8. package/dist/client/index.d.ts +4 -0
  9. package/dist/client/options.d.ts +101 -0
  10. package/dist/client/provider.d.ts +52 -0
  11. package/dist/client/types.d.ts +160 -0
  12. package/dist/client.js +239 -0
  13. package/dist/components/agent-connect/agent-connect-copy.d.ts +34 -0
  14. package/dist/components/agent-connect/agent-connect-design.d.ts +1781 -0
  15. package/dist/components/agent-connect/agent-connect-detail.d.ts +13 -0
  16. package/dist/components/agent-connect/agent-connect-installer.d.ts +3 -0
  17. package/dist/components/agent-connect/agent-connect-instructions-view.d.ts +14 -0
  18. package/dist/components/agent-connect/agent-connect-instructions.d.ts +145 -0
  19. package/dist/components/agent-connect/agent-connect-markdown.d.ts +3 -0
  20. package/dist/components/agent-connect/agent-connect.d.ts +4 -1
  21. package/dist/components/agent-connect/content-en.d.ts +137 -0
  22. package/dist/components/agent-connect/content-zh.d.ts +137 -0
  23. package/dist/components/agent-connect/index.d.ts +1 -0
  24. package/dist/components/agent-connect/style.css +503 -0
  25. package/dist/components/agent-connect/types.d.ts +29 -0
  26. package/dist/components/agent-connect.js +1 -0
  27. package/dist/components/file-preview/file-preview-adapters.d.ts +33 -0
  28. package/dist/components/file-preview/file-preview-body.d.ts +27 -0
  29. package/dist/components/file-preview/file-preview-breadcrumb-menu.d.ts +16 -0
  30. package/dist/components/file-preview/file-preview-breadcrumb.d.ts +21 -0
  31. package/dist/components/file-preview/file-preview-copy-path.d.ts +12 -0
  32. package/dist/components/file-preview/file-preview-editor.d.ts +22 -0
  33. package/dist/components/file-preview/file-preview-handle-adapters.d.ts +26 -0
  34. package/dist/components/file-preview/file-preview-header.d.ts +25 -0
  35. package/dist/components/file-preview/file-preview-labels.d.ts +16 -0
  36. package/dist/components/file-preview/file-preview-lazy-viewer.d.ts +3 -0
  37. package/dist/components/file-preview/file-preview-path.d.ts +30 -0
  38. package/dist/components/file-preview/file-preview-source.d.ts +24 -0
  39. package/dist/components/file-preview/file-preview-state.d.ts +28 -0
  40. package/dist/components/file-preview/file-preview-tab-row.d.ts +16 -0
  41. package/dist/components/file-preview/file-preview-viewer.d.ts +31 -0
  42. package/dist/components/file-preview/file-preview.d.ts +14 -1
  43. package/dist/components/file-preview/index.d.ts +1 -0
  44. package/dist/components/file-preview/style.css +4139 -0
  45. package/dist/components/file-preview/types.d.ts +516 -0
  46. package/dist/components/file-preview/use-file-preview-actions-context.d.ts +23 -0
  47. package/dist/components/file-preview/use-file-preview-actions.d.ts +19 -0
  48. package/dist/components/file-preview/use-file-preview-editing.d.ts +32 -0
  49. package/dist/components/file-preview/use-file-preview-ids.d.ts +24 -0
  50. package/dist/components/file-preview.js +1 -0
  51. package/dist/components/file-tree/file-tree-body.d.ts +18 -0
  52. package/dist/components/file-tree/file-tree-entry-row.d.ts +12 -0
  53. package/dist/components/file-tree/file-tree-icons.d.ts +15 -0
  54. package/dist/components/file-tree/file-tree-info-labels.d.ts +21 -0
  55. package/dist/components/file-tree/file-tree-info-tooltip.d.ts +43 -0
  56. package/dist/components/file-tree/file-tree-info.d.ts +29 -0
  57. package/dist/components/file-tree/file-tree-keyboard.d.ts +14 -0
  58. package/dist/components/file-tree/file-tree-row-context.d.ts +46 -0
  59. package/dist/components/file-tree/file-tree-row-shared.d.ts +11 -0
  60. package/dist/components/file-tree/file-tree-spinner.d.ts +10 -0
  61. package/dist/components/file-tree/file-tree-state-row.d.ts +7 -0
  62. package/dist/components/file-tree/file-tree-tooltip-surface.d.ts +22 -0
  63. package/dist/components/file-tree/file-tree-tooltip.d.ts +17 -0
  64. package/dist/components/file-tree/file-tree.d.ts +15 -1
  65. package/dist/components/file-tree/index.d.ts +1 -0
  66. package/dist/components/file-tree/style.css +410 -0
  67. package/dist/components/file-tree/types.d.ts +589 -0
  68. package/dist/components/file-tree/use-file-tree-actions.d.ts +17 -0
  69. package/dist/components/file-tree.js +1 -0
  70. package/dist/components/scope-switcher/index.d.ts +1 -0
  71. package/dist/components/scope-switcher/scope-keyboard.d.ts +2 -0
  72. package/dist/components/scope-switcher/scope-panel.d.ts +11 -0
  73. package/dist/components/scope-switcher/scope-selector.d.ts +2 -0
  74. package/dist/components/scope-switcher/scope-switcher.d.ts +6 -1
  75. package/dist/components/scope-switcher/style.css +452 -0
  76. package/dist/components/scope-switcher/types.d.ts +489 -0
  77. package/dist/components/scope-switcher.js +3 -0
  78. package/dist/components/style.css +14249 -18
  79. package/dist/components/tui/command-catalog.d.ts +58 -0
  80. package/dist/components/tui/command-completion.d.ts +19 -0
  81. package/dist/components/tui/command-definitions.d.ts +10 -0
  82. package/dist/components/tui/command-input.d.ts +16 -0
  83. package/dist/components/tui/index.d.ts +1 -0
  84. package/dist/components/tui/style.css +1552 -0
  85. package/dist/components/tui/tui-assist.d.ts +15 -0
  86. package/dist/components/tui/tui-code-block.d.ts +8 -0
  87. package/dist/components/tui/tui-command-help.d.ts +9 -0
  88. package/dist/components/tui/tui-command-text.d.ts +6 -0
  89. package/dist/components/tui/tui-composer.d.ts +24 -0
  90. package/dist/components/tui/tui-copy-button.d.ts +9 -0
  91. package/dist/components/tui/tui-input-mirror.d.ts +14 -0
  92. package/dist/components/tui/tui-labels-zh.d.ts +2 -0
  93. package/dist/components/tui/tui-labels.d.ts +5 -0
  94. package/dist/components/tui/tui-markdown-renderers.d.ts +10 -0
  95. package/dist/components/tui/tui-markdown.d.ts +6 -0
  96. package/dist/components/tui/tui-param-hint.d.ts +7 -0
  97. package/dist/components/tui/tui-record-time.d.ts +11 -0
  98. package/dist/components/tui/tui-record.d.ts +13 -0
  99. package/dist/components/tui/tui-resource-preview.d.ts +10 -0
  100. package/dist/components/tui/tui-resource-tree.d.ts +10 -0
  101. package/dist/components/tui/tui-result-header.d.ts +7 -0
  102. package/dist/components/tui/tui-result-text.d.ts +5 -0
  103. package/dist/components/tui/tui-search-list.d.ts +8 -0
  104. package/dist/components/tui/tui-skeleton.d.ts +6 -0
  105. package/dist/components/tui/tui-status-card.d.ts +7 -0
  106. package/dist/components/tui/tui-text.d.ts +10 -0
  107. package/dist/components/tui/tui-uri-text.d.ts +19 -0
  108. package/dist/components/tui/tui-write-result.d.ts +7 -0
  109. package/dist/components/tui/tui.d.ts +11 -1
  110. package/dist/components/tui/types.d.ts +527 -0
  111. package/dist/components/tui/use-tui-assist-position.d.ts +3 -0
  112. package/dist/components/tui/use-tui-completion.d.ts +14 -0
  113. package/dist/components/tui/use-tui-composer-keyboard.d.ts +25 -0
  114. package/dist/components/tui.js +1 -0
  115. package/dist/components/viking-bot/ark-adapter.d.ts +45 -0
  116. package/dist/components/viking-bot/ark-message-body.d.ts +16 -0
  117. package/dist/components/viking-bot/ark-message-list-view.d.ts +7 -0
  118. package/dist/components/viking-bot/ark-message-row.d.ts +19 -0
  119. package/dist/components/viking-bot/index.d.ts +10 -0
  120. package/dist/components/viking-bot/interaction/ask-human-fields.d.ts +10 -0
  121. package/dist/components/viking-bot/interaction/index.d.ts +4 -0
  122. package/dist/components/viking-bot/interaction/labels.d.ts +7 -0
  123. package/dist/components/viking-bot/interaction/lazy-interaction.d.ts +3 -0
  124. package/dist/components/viking-bot/interaction/schedule-input.d.ts +13 -0
  125. package/dist/components/viking-bot/interaction/style.css +189 -0
  126. package/dist/components/viking-bot/interaction/types.d.ts +188 -0
  127. package/dist/components/viking-bot/interaction/viking-bot-interaction.d.ts +9 -0
  128. package/dist/components/viking-bot/interaction.js +2 -0
  129. package/dist/components/viking-bot/labels.d.ts +2 -0
  130. package/dist/components/viking-bot/lazy-composer.d.ts +3 -0
  131. package/dist/components/viking-bot/message-groups.d.ts +12 -0
  132. package/dist/components/viking-bot/model.d.ts +252 -0
  133. package/dist/components/viking-bot/render-part.d.ts +12 -0
  134. package/dist/components/viking-bot/style.css +7133 -0
  135. package/dist/components/viking-bot/types.d.ts +140 -0
  136. package/dist/components/viking-bot/viking-bot-composer.d.ts +6 -0
  137. package/dist/components/viking-bot/viking-bot-message-list.d.ts +3 -0
  138. package/dist/components/viking-bot/viking-bot.d.ts +16 -1
  139. package/dist/components/viking-bot.js +4 -0
  140. package/dist/c~0.js +201 -0
  141. package/dist/file-preview-viewer~0.js +191 -0
  142. package/dist/f~0.js +356 -0
  143. package/dist/g~0.js +1207 -0
  144. package/dist/h~0.js +58 -0
  145. package/dist/icons/file-type-icon.d.ts +31 -0
  146. package/dist/icons/index.d.ts +33 -23
  147. package/dist/icons/nextjs-icon.d.ts +19 -0
  148. package/dist/icons.js +1 -25
  149. package/dist/index.d.ts +16 -2
  150. package/dist/index.js +8 -1
  151. package/dist/k~0.js +1440 -0
  152. package/dist/lk~0.js +233 -0
  153. package/dist/l~0.js +44 -0
  154. package/dist/modules/console/console.d.ts +4 -0
  155. package/dist/modules/console/index.d.ts +1 -0
  156. package/dist/modules/console/style.css +111 -0
  157. package/dist/modules/console/types.d.ts +101 -0
  158. package/dist/modules/console.js +1 -0
  159. package/dist/modules/file-browser/file-browser-toolbar-button.d.ts +10 -0
  160. package/dist/modules/file-browser/file-browser.d.ts +6 -0
  161. package/dist/modules/file-browser/index.d.ts +1 -0
  162. package/dist/modules/file-browser/style.css +158 -0
  163. package/dist/modules/file-browser/types.d.ts +101 -0
  164. package/dist/modules/file-browser.js +1 -0
  165. package/dist/modules/scope-cascade/controller.d.ts +6 -0
  166. package/dist/modules/scope-cascade/index.d.ts +3 -0
  167. package/dist/modules/scope-cascade/scope-cascade.d.ts +3 -0
  168. package/dist/modules/scope-cascade/style.css +456 -0
  169. package/dist/modules/scope-cascade/style.js +0 -0
  170. package/dist/modules/scope-cascade/types.d.ts +39 -0
  171. package/dist/modules/scope-cascade/use-scope-cascade.d.ts +5 -0
  172. package/dist/modules/scope-cascade.js +1 -0
  173. package/dist/modules/style.css +808 -0
  174. package/dist/modules/style.js +0 -0
  175. package/dist/n~0.js +727 -0
  176. package/dist/shared/components/tooltip/index.d.ts +1 -0
  177. package/dist/shared/components/tooltip/tooltip.d.ts +25 -0
  178. package/dist/shared/components/tooltip/types.d.ts +42 -0
  179. package/dist/shared/components/tooltip/use-tooltip-position.d.ts +38 -0
  180. package/dist/style.css +15138 -18
  181. package/dist/u~0.js +1601 -0
  182. package/dist/viking-bot-composer~0.js +164 -0
  183. package/dist/viking-bot-interaction~0.js +284 -0
  184. package/dist/w~0.js +19 -0
  185. package/package.json +46 -22
  186. package/dist/components/resource-import/resource-import.d.ts +0 -1
  187. package/dist/components/resource-import/style.css +0 -2
  188. package/dist/components/status-badge/status-badge.d.ts +0 -8
  189. package/dist/components/status-badge/style.css +0 -37
  190. package/dist/components/status-badge.js +0 -30
  191. /package/dist/components/{resource-import → viking-bot/interaction}/style.js +0 -0
  192. /package/dist/{components/status-badge → modules/console}/style.js +0 -0
  193. /package/dist/{components/resource-import.js → modules/file-browser/style.js} +0 -0
@@ -0,0 +1,310 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { ChatMessageList } from "@ark-design/ui/message-list";
3
+ import { Bubble } from "@ark-design/ui/bubble";
4
+ import { ErrorCard } from "@ark-design/ui/error-card";
5
+ import { ActivityTimeline } from "@ark-design/ui/activity-timeline";
6
+ import { MDRenderer } from "@ark-design/ui/markdown-renderer";
7
+ import { useState } from "react";
8
+ import { groupActivityParts, toRenderItems, DEFAULT_LABELS } from "./c~0.js";
9
+ import { messageText, groupMessages } from "./h~0.js";
10
+ function renderPart(part, context) {
11
+ const { labels, onOpenUri } = context;
12
+ if ('text' === part.type) return 'markdown' === part.format ? /*#__PURE__*/ jsx("div", {
13
+ className: "ov-viking-bot__text ov-viking-bot__text--markdown",
14
+ children: part.text
15
+ }) : /*#__PURE__*/ jsx("div", {
16
+ className: "ov-viking-bot__text",
17
+ children: part.text
18
+ });
19
+ if ('reasoning' === part.type) return /*#__PURE__*/ jsxs("details", {
20
+ className: "ov-viking-bot__reasoning",
21
+ open: part.running,
22
+ children: [
23
+ /*#__PURE__*/ jsxs("summary", {
24
+ children: [
25
+ labels.reasoning,
26
+ part.durationMs ? ` · ${Math.round(part.durationMs / 1000)}s` : ''
27
+ ]
28
+ }),
29
+ /*#__PURE__*/ jsx("div", {
30
+ className: "ov-viking-bot__reasoning-body",
31
+ children: part.text
32
+ })
33
+ ]
34
+ });
35
+ if ('iteration' === part.type) return /*#__PURE__*/ jsxs("div", {
36
+ className: "ov-viking-bot__iteration",
37
+ role: "separator",
38
+ children: [
39
+ "#",
40
+ part.iteration
41
+ ]
42
+ });
43
+ if ('context' === part.type) return /*#__PURE__*/ jsx("button", {
44
+ type: "button",
45
+ className: "ov-viking-bot__context",
46
+ title: part.abstract,
47
+ onClick: ()=>onOpenUri?.(part.uri),
48
+ children: part.label ?? part.uri
49
+ });
50
+ if ('tool' === part.type) return /*#__PURE__*/ jsxs("details", {
51
+ className: "ov-viking-bot__tool",
52
+ open: 'running' === part.status,
53
+ children: [
54
+ /*#__PURE__*/ jsxs("summary", {
55
+ children: [
56
+ /*#__PURE__*/ jsx("span", {
57
+ className: "ov-viking-bot__tool-name",
58
+ children: part.name
59
+ }),
60
+ /*#__PURE__*/ jsx("span", {
61
+ className: "ov-viking-bot__tool-status",
62
+ children: labels[`tool${capitalize(part.status)}`] ?? part.status
63
+ }),
64
+ part.durationMs ? /*#__PURE__*/ jsx("span", {
65
+ children: `${part.durationMs}ms`
66
+ }) : null
67
+ ]
68
+ }),
69
+ part.input ? /*#__PURE__*/ jsx("pre", {
70
+ className: "ov-viking-bot__tool-input",
71
+ children: JSON.stringify(part.input, null, 2)
72
+ }) : null,
73
+ part.output ? /*#__PURE__*/ jsx("pre", {
74
+ className: "ov-viking-bot__tool-output",
75
+ children: part.output
76
+ }) : null
77
+ ]
78
+ });
79
+ if ('tool_result' === part.type) return /*#__PURE__*/ jsx("pre", {
80
+ className: part.isError ? 'ov-viking-bot__tool-output ov-viking-bot__tool-output--error' : 'ov-viking-bot__tool-output',
81
+ children: part.output
82
+ });
83
+ if ('image' === part.type) return /*#__PURE__*/ jsx("img", {
84
+ className: "ov-viking-bot__image",
85
+ src: part.src,
86
+ alt: part.alt ?? ''
87
+ });
88
+ return /*#__PURE__*/ jsx("button", {
89
+ type: "button",
90
+ className: "ov-viking-bot__attachment",
91
+ onClick: ()=>part.uri && onOpenUri?.(part.uri),
92
+ children: part.name
93
+ });
94
+ }
95
+ function capitalize(value) {
96
+ return value.charAt(0).toUpperCase() + value.slice(1);
97
+ }
98
+ function MessageText({ text, streaming, format }) {
99
+ if ('plain' === format) return /*#__PURE__*/ jsx("div", {
100
+ className: "ov-viking-bot__text",
101
+ children: text
102
+ });
103
+ return /*#__PURE__*/ jsx(MDRenderer, {
104
+ className: "ov-viking-bot__text ov-viking-bot__text--markdown",
105
+ markdown: text,
106
+ showIndicator: streaming
107
+ });
108
+ }
109
+ function ActivityGroup({ id, items, running, labels, onOpenUri }) {
110
+ const [expanded, setExpanded] = useState(running);
111
+ const duration = items.reduce((total, item)=>total + (item.durationMs ?? 0), 0);
112
+ const summary = running ? labels.thinking : duration > 0 ? `${labels.reasoning} · ${Math.round(duration / 1000)}s` : labels.reasoning;
113
+ return /*#__PURE__*/ jsxs("section", {
114
+ className: "ov-viking-bot__activity",
115
+ "data-group": id,
116
+ children: [
117
+ /*#__PURE__*/ jsx("button", {
118
+ type: "button",
119
+ className: "ov-viking-bot__activity-toggle",
120
+ "aria-expanded": expanded,
121
+ onClick: ()=>setExpanded((current)=>!current),
122
+ children: summary
123
+ }),
124
+ expanded ? /*#__PURE__*/ jsx(ActivityTimeline, {
125
+ items: items,
126
+ density: "compact",
127
+ defaultExpanded: true,
128
+ onOpenSearchResult: (result)=>onOpenUri?.(result.url)
129
+ }) : null
130
+ ]
131
+ });
132
+ }
133
+ function MessageBody({ message, labels, onOpenUri }) {
134
+ const activity = message.parts.filter((part)=>'reasoning' === part.type || 'tool' === part.type);
135
+ const rest = message.parts.filter((part)=>'reasoning' !== part.type && 'tool' !== part.type);
136
+ const { groups, order } = groupActivityParts(activity);
137
+ return /*#__PURE__*/ jsxs(Fragment, {
138
+ children: [
139
+ order.map((key)=>{
140
+ const group = groups.get(key);
141
+ if (!group) return null;
142
+ return /*#__PURE__*/ jsx(ActivityGroup, {
143
+ id: group.id,
144
+ items: group.items,
145
+ running: group.items.some((item)=>'running' === item.status),
146
+ labels: labels,
147
+ onOpenUri: onOpenUri
148
+ }, group.id);
149
+ }),
150
+ rest.map((part, index)=>'text' === part.type ? /*#__PURE__*/ jsx(MessageText, {
151
+ text: part.text,
152
+ format: part.format,
153
+ streaming: message.streaming
154
+ }, index) : /*#__PURE__*/ jsx("div", {
155
+ children: renderPart(part, {
156
+ labels,
157
+ onOpenUri
158
+ })
159
+ }, index))
160
+ ]
161
+ });
162
+ }
163
+ function MessageActions({ message, labels, onCopy, onMessageAction }) {
164
+ const text = messageText(message);
165
+ const actions = message.actions ?? (message.action ? [
166
+ {
167
+ messageId: message.id,
168
+ action: message.action
169
+ }
170
+ ] : []);
171
+ if (0 === actions.length && !onCopy) return null;
172
+ return /*#__PURE__*/ jsxs("div", {
173
+ className: "ov-viking-bot__message-actions",
174
+ children: [
175
+ actions.map(({ messageId, action })=>/*#__PURE__*/ jsx("button", {
176
+ type: "button",
177
+ className: "ov-viking-bot__message-action",
178
+ disabled: Boolean(action.disabledReason) || 'pending' === action.status || 'success' === action.status,
179
+ title: action.disabledReason,
180
+ onClick: ()=>onMessageAction?.(messageId, action.key),
181
+ children: action.label ?? action.key
182
+ }, `${messageId}:${action.key}`)),
183
+ onCopy && text ? /*#__PURE__*/ jsx("button", {
184
+ type: "button",
185
+ className: "ov-viking-bot__copy",
186
+ onClick: ()=>onCopy(text),
187
+ children: labels.copy
188
+ }) : null
189
+ ]
190
+ });
191
+ }
192
+ function VikingBotMessageRow({ message, labels, onOpenUri, onCopy, onMessageAction, renderMessage }) {
193
+ if (renderMessage) return /*#__PURE__*/ jsx("div", {
194
+ className: "ov-viking-bot__message",
195
+ children: renderMessage(message)
196
+ });
197
+ if ('system' === message.role) return /*#__PURE__*/ jsx(ErrorCard, {
198
+ className: 'error' === message.tone ? 'ov-viking-bot__notice ov-viking-bot__notice--error' : 'ov-viking-bot__notice',
199
+ content: messageText(message)
200
+ });
201
+ return /*#__PURE__*/ jsx(Bubble, {
202
+ className: `ov-viking-bot__message ov-viking-bot__message--${message.role}`,
203
+ placement: 'user' === message.role ? 'end' : 'start',
204
+ variant: 'user' === message.role ? 'filled' : 'text',
205
+ content: null,
206
+ footer: /*#__PURE__*/ jsx(MessageActions, {
207
+ message: message,
208
+ labels: labels,
209
+ onCopy: onCopy,
210
+ onMessageAction: onMessageAction
211
+ }),
212
+ children: /*#__PURE__*/ jsx(MessageBody, {
213
+ message: message,
214
+ labels: labels,
215
+ onOpenUri: onOpenUri
216
+ })
217
+ });
218
+ }
219
+ function VikingBotStreamingRow({ streaming, labels, onOpenUri }) {
220
+ if (0 === streaming.parts.length) return /*#__PURE__*/ jsx(Bubble, {
221
+ className: "ov-viking-bot__message ov-viking-bot__message--assistant",
222
+ placement: "start",
223
+ variant: "text",
224
+ loading: true
225
+ });
226
+ return /*#__PURE__*/ jsx(Bubble, {
227
+ className: "ov-viking-bot__message ov-viking-bot__message--assistant",
228
+ placement: "start",
229
+ variant: "text",
230
+ content: null,
231
+ children: /*#__PURE__*/ jsx(MessageBody, {
232
+ message: {
233
+ id: '__streaming__',
234
+ role: 'assistant',
235
+ parts: streaming.parts,
236
+ streaming: true
237
+ },
238
+ labels: labels,
239
+ onOpenUri: onOpenUri
240
+ })
241
+ });
242
+ }
243
+ const INITIAL_TARGET = {
244
+ kind: 'end',
245
+ behavior: 'auto'
246
+ };
247
+ const SCROLLER_STYLE = {
248
+ paddingLeft: 16,
249
+ paddingRight: 16,
250
+ paddingBottom: 24
251
+ };
252
+ const TURN_ANCHOR = {
253
+ behavior: 'smooth',
254
+ mode: 'bottom'
255
+ };
256
+ const AT_END_THRESHOLD = 8;
257
+ const estimateSize = (item)=>{
258
+ if (item.streaming) return 96;
259
+ const message = item.message;
260
+ if (!message) return 96;
261
+ if ('system' === message.role) return 56;
262
+ const textLength = message.parts.reduce((total, part)=>total + ('text' === part.type ? part.text.length : 0), 0);
263
+ const activityCount = message.parts.filter((part)=>'reasoning' === part.type || 'tool' === part.type).length;
264
+ return Math.max(72, Math.min(640, 72 + 0.4 * textLength + 48 * activityCount));
265
+ };
266
+ function VikingBotMessageListView({ messages, className, streaming, footer, listKey, onOpenUri, onCopy, onMessageAction, renderMessage, labels: overrides }) {
267
+ const labels = {
268
+ ...DEFAULT_LABELS,
269
+ ...overrides
270
+ };
271
+ const items = toRenderItems(messages, streaming, groupMessages);
272
+ return /*#__PURE__*/ jsxs("div", {
273
+ className: [
274
+ 'ov-viking-bot__list',
275
+ className
276
+ ].filter(Boolean).join(' '),
277
+ children: [
278
+ /*#__PURE__*/ jsx(ChatMessageList, {
279
+ listKey: listKey ?? 'viking-bot',
280
+ items: items,
281
+ getItemKey: (item)=>item.id,
282
+ estimateItemSize: estimateSize,
283
+ initialTarget: INITIAL_TARGET,
284
+ followOutput: streaming ? 'smooth' : false,
285
+ turnAnchor: TURN_ANCHOR,
286
+ atEndThreshold: AT_END_THRESHOLD,
287
+ scrollerStyle: SCROLLER_STYLE,
288
+ shortContentAlign: "start",
289
+ overscan: 480,
290
+ renderItem: ({ item })=>item.streaming ? /*#__PURE__*/ jsx(VikingBotStreamingRow, {
291
+ streaming: item.streaming,
292
+ labels: labels,
293
+ onOpenUri: onOpenUri
294
+ }) : item.message ? /*#__PURE__*/ jsx(VikingBotMessageRow, {
295
+ message: item.message,
296
+ labels: labels,
297
+ onOpenUri: onOpenUri,
298
+ onCopy: onCopy,
299
+ onMessageAction: onMessageAction,
300
+ renderMessage: renderMessage
301
+ }) : null
302
+ }),
303
+ footer ? /*#__PURE__*/ jsx("div", {
304
+ className: "ov-viking-bot__footer",
305
+ children: footer
306
+ }) : null
307
+ ]
308
+ });
309
+ }
310
+ export { VikingBotMessageListView };
package/dist/a~0.js ADDED
@@ -0,0 +1,21 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ function Console({ className, style, labels }) {
3
+ return /*#__PURE__*/ jsxs("div", {
4
+ className: [
5
+ 'ov-module-placeholder',
6
+ className
7
+ ].filter(Boolean).join(' '),
8
+ style: style,
9
+ children: [
10
+ /*#__PURE__*/ jsx("p", {
11
+ className: "ov-module-placeholder__title",
12
+ children: labels?.conversation ?? 'Console'
13
+ }),
14
+ /*#__PURE__*/ jsx("p", {
15
+ className: "ov-module-placeholder__description",
16
+ children: labels?.description ?? 'Placeholder. Functionality is not available yet.'
17
+ })
18
+ ]
19
+ });
20
+ }
21
+ export { Console };
package/dist/c7~0.js ADDED
@@ -0,0 +1,24 @@
1
+ const DEFAULT_INTERACTION_LABELS = {
2
+ title: 'Needs your input',
3
+ submit: 'Submit',
4
+ cancel: 'Cancel',
5
+ other: 'Other',
6
+ submitted: 'Submitted',
7
+ cancelled: 'Cancelled',
8
+ progress: (index, total)=>`${index + 1} / ${total}`,
9
+ scheduleNone: 'Do not schedule',
10
+ scheduleDaily: 'Every day',
11
+ scheduleWeekly: 'Every week',
12
+ scheduleTime: 'Time',
13
+ scheduleWeekday: 'Weekday',
14
+ weekdays: [
15
+ 'Monday',
16
+ 'Tuesday',
17
+ 'Wednesday',
18
+ 'Thursday',
19
+ 'Friday',
20
+ 'Saturday',
21
+ 'Sunday'
22
+ ]
23
+ };
24
+ export { DEFAULT_INTERACTION_LABELS };
@@ -0,0 +1,12 @@
1
+ import type { OvClient, OvClientOptions } from './types.js';
2
+ /**
3
+ * 用 `fetch` 实现 {@link OvClient}。这是库自带的默认传输层,调用方只需给服务
4
+ * 地址和身份字段;要换传输方式(例如复用宿主已有的 axios 实例)时才需要自己
5
+ * 实现 {@link OvClient}。
6
+ *
7
+ * Implements {@link OvClient} with `fetch`. This is the library's default
8
+ * transport, so a caller supplies only the service address and identity fields.
9
+ * Implement {@link OvClient} yourself only to replace the transport, for example
10
+ * to reuse the host's existing axios instance.
11
+ */
12
+ export declare function createOvClient(options?: OvClientOptions): OvClient;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * 请求失败的统一错误。区分 HTTP 失败与原生响应里的 `status: 'error'`,
3
+ * 保留服务端错误码、状态与请求标识。
4
+ * The single error a failed request raises. It distinguishes an HTTP failure
5
+ * from a native `status: 'error'` response and keeps the server error code,
6
+ * status and request identifier.
7
+ */
8
+ export declare class OvClientError extends Error {
9
+ /** 服务端错误码,HTTP 失败时为 `HTTP_<status>` 或 `NETWORK_ERROR`。 */
10
+ readonly code: string;
11
+ /** HTTP 状态码;请求未到达服务端时省略。 */
12
+ readonly statusCode?: number;
13
+ /** 服务端返回的附加信息。 */
14
+ readonly details?: unknown;
15
+ /** 服务端请求标识,便于与服务端日志对应。 */
16
+ readonly requestId?: string;
17
+ /** 原始响应体,便于诊断无法归一的响应。 */
18
+ readonly responseBody?: unknown;
19
+ constructor(options: {
20
+ code: string;
21
+ message: string;
22
+ statusCode?: number;
23
+ details?: unknown;
24
+ requestId?: string;
25
+ responseBody?: unknown;
26
+ cause?: unknown;
27
+ });
28
+ }
29
+ /** 判断一个值是否为 {@link OvClientError}。 */
30
+ export declare function isOvClientError(value: unknown): value is OvClientError;
@@ -0,0 +1,4 @@
1
+ export { createOvClient } from './client.js';
2
+ export { OvClientError, isOvClientError } from './errors.js';
3
+ export { OpenVikingProvider, type OpenVikingProviderProps, } from './provider.js';
4
+ export type { OvClient, OvClientOptions, OvErrorEnvelope, OvIdentityValue, OvQueryValue, OvRequestOptions, OvRequestSpec, OvResolvedOptions, OvSuccessEnvelope, } from './types.js';
@@ -0,0 +1,101 @@
1
+ import type { OvClientOptions, OvIdentityValue, OvQueryValue, OvRequestOptions, OvResolvedOptions } from './types.js';
2
+ /**
3
+ * 身份字段到请求头的映射。宿主传字段值,Client 负责组装,不暴露 header 名称。
4
+ * Mapping from identity fields to request headers. A host passes field values and
5
+ * the Client assembles the headers, so header names stay internal.
6
+ */
7
+ export declare const IDENTITY_HEADERS: {
8
+ readonly apiKey: 'X-API-Key';
9
+ readonly accountId: 'X-OpenViking-Account';
10
+ readonly userId: 'X-OpenViking-User';
11
+ readonly resourceId: 'V-Resource-Id';
12
+ };
13
+ export type OvIdentityField = keyof typeof IDENTITY_HEADERS;
14
+ /**
15
+ * 求值一层身份字段,保留空字符串,以便区分「未提供」与「显式清除」。
16
+ * Evaluates one identity layer, keeping empty strings so that "absent" and
17
+ * "explicitly cleared" stay distinguishable.
18
+ */
19
+ export declare function resolveIdentityLayer(options: OvRequestOptions | undefined): Promise<OvIdentityLayer>;
20
+ /**
21
+ * 合并两层身份字段:近的一层覆盖远的一层,近层显式传空字符串即清除该字段。
22
+ * Merges two identity layers: the nearer one wins, and an explicit empty string
23
+ * in it clears the field.
24
+ */
25
+ export declare function mergeIdentityLayers(far: OvIdentityLayer, near: OvIdentityLayer): OvIdentityLayer;
26
+ /**
27
+ * 把身份字段转成请求头。空字符串表示清除,不发送对应请求头。
28
+ * Turns identity fields into headers. An empty string means cleared, so that
29
+ * header is not sent.
30
+ */
31
+ export declare function toHeaders(layer: OvIdentityLayer): Record<string, string>;
32
+ /**
33
+ * 解析客户端级配置。`baseURL` 缺省为空字符串,表示浏览器同源请求。
34
+ *
35
+ * 身份层由调用方求值后传入:函数形式的身份字段每次请求只应求值一次,父层配置
36
+ * 与请求覆盖必须复用同一份结果,否则会重复刷新凭证并可能发出旧值。
37
+ *
38
+ * Resolves client-level configuration. A missing `baseURL` is an empty string,
39
+ * meaning a same-origin browser request.
40
+ *
41
+ * The caller passes an already-evaluated identity layer: a function-form
42
+ * identity field must be evaluated once per request, and both the parent
43
+ * configuration and the request override must reuse that one result. Evaluating
44
+ * twice would refresh a credential twice and could send the older value.
45
+ */
46
+ export declare function resolveClientOptions(options: OvClientOptions, identity: OvIdentityLayer): OvResolvedOptions;
47
+ /**
48
+ * 在已解析的客户端配置上叠加一次请求的覆盖。`baseURL` 传空字符串表示同源,
49
+ * 只有 `undefined` 才继承。
50
+ *
51
+ * Applies one request's override on top of resolved client configuration. An
52
+ * empty `baseURL` means same origin; only `undefined` inherits.
53
+ */
54
+ export declare function resolveRequestOptions(local: OvRequestOptions | undefined, parent: OvResolvedOptions, mergedLayer: OvIdentityLayer): OvResolvedOptions;
55
+ /**
56
+ * 拼接服务地址与接口路径。拼接只在这里做:`/gateway/ov` 加 `/api/v1/fs/ls`
57
+ * 得到 `/gateway/ov/api/v1/fs/ls`,接口路径以 `/` 开头也不会丢掉前缀。
58
+ *
59
+ * Joins the service address and the API path. Joining happens only here:
60
+ * `/gateway/ov` plus `/api/v1/fs/ls` yields `/gateway/ov/api/v1/fs/ls`, and a
61
+ * leading `/` in the path never drops the prefix.
62
+ */
63
+ export declare function joinUrl(baseURL: string, path: string): string;
64
+ /**
65
+ * 把查询参数序列化为查询串,跳过 `undefined` 与 `null`,数组按键重复。
66
+ * Serialises query parameters, skipping `undefined` and `null`; arrays repeat
67
+ * the key.
68
+ */
69
+ export declare function buildQuery(query: Readonly<Record<string, OvQueryValue>> | undefined): string;
70
+ /**
71
+ * 一层已求值的身份字段:`undefined` 表示未提供,空字符串表示显式清除,其余
72
+ * 为要发送的值。
73
+ * One evaluated identity layer: `undefined` means absent, an empty string means
74
+ * explicitly cleared, anything else is the value to send.
75
+ */
76
+ export type OvIdentityLayer = Partial<Record<OvIdentityField, string>>;
77
+ /**
78
+ * 一层未求值的身份字段,供 Provider 逐层合并。函数形式原样保留,由客户端在
79
+ * 每次请求时求值。
80
+ * One unevaluated identity layer for Provider merging. Function values are kept
81
+ * as-is so the client evaluates them per request.
82
+ */
83
+ export type OvIdentityConfig = Partial<Record<OvIdentityField, OvIdentityValue>>;
84
+ /** Provider 已解析的配置,供嵌套 Provider 继续继承。 */
85
+ export interface OvProviderBase {
86
+ baseURL?: string;
87
+ credentials?: RequestCredentials;
88
+ signal?: AbortSignal;
89
+ /** 传输层覆盖。内层未声明时继承外层,否则内层会丢掉外层的自定义 fetch。 */
90
+ fetch?: typeof globalThis.fetch;
91
+ identity: OvIdentityConfig;
92
+ }
93
+ /**
94
+ * 把本层配置叠加到父层之上。只覆盖本层显式声明的字段:`undefined` 表示继承,
95
+ * 空字符串表示清除继承到的值。
96
+ *
97
+ * Applies one layer of configuration on top of its parent. Only fields this
98
+ * layer declares are overridden: `undefined` inherits, and an empty string
99
+ * clears the inherited value.
100
+ */
101
+ export declare function mergeProviderConfig(inherited: OvProviderBase | undefined, local: OvClientOptions): OvProviderBase;
@@ -0,0 +1,52 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { OvClient, OvClientOptions } from './types.js';
3
+ /**
4
+ * {@link OpenVikingProvider} 的属性。字段与 {@link OvClientOptions} 同形:
5
+ * 服务地址、身份与作用域、Cookie 策略,都按字段传值。
6
+ * Props of {@link OpenVikingProvider}, the same shape as {@link OvClientOptions}:
7
+ * the service address, identity and scope, and the cookie policy are all passed
8
+ * as fields.
9
+ */
10
+ export interface OpenVikingProviderProps extends OvClientOptions {
11
+ children?: ReactNode;
12
+ }
13
+ /**
14
+ * 向子树下发请求配置。模块通过内部的 `useOvClient` 取用,宿主只需在应用根部
15
+ * 配置一次服务地址与身份字段,不必自己组装请求头。
16
+ *
17
+ * 开源版传 `apiKey`、`accountId`、`userId`;商业版由浏览器 Cookie 鉴权,只传
18
+ * `accountId`、`userId`、`resourceId`,并按需把 `credentials` 设为 `include`。
19
+ *
20
+ * 嵌套时内层只覆盖自己声明的字段,其余继承外层:外层配好服务地址与凭证后,
21
+ * 内层可以只改 `userId`。显式传空字符串表示清除继承到的值。
22
+ *
23
+ * 不传 `baseURL` 时按浏览器同源请求。挂载本身不发请求,也不读取浏览器里保存
24
+ * 的凭证。
25
+ *
26
+ * Provides request configuration to a subtree. Modules read it through the
27
+ * internal `useOvClient`, so a host configures the service address and identity
28
+ * fields once at the application root and never assembles headers itself.
29
+ *
30
+ * The open-source edition passes `apiKey`, `accountId` and `userId`; the
31
+ * commercial edition authenticates with a browser cookie, so it passes
32
+ * `accountId`, `userId` and `resourceId`, and sets `credentials` to `include`
33
+ * where needed.
34
+ *
35
+ * Nesting overrides only the fields the inner Provider declares and inherits the
36
+ * rest, so an outer Provider can own the service address and credential while an
37
+ * inner one changes only `userId`. An explicit empty string clears an inherited
38
+ * value.
39
+ *
40
+ * Without `baseURL` it targets the browser's own origin. Mounting it sends no
41
+ * request and reads no credential stored in the browser.
42
+ */
43
+ export declare function OpenVikingProvider({ baseURL, apiKey, accountId, userId, resourceId, credentials, signal, fetch, children, }: OpenVikingProviderProps): import("react").JSX.Element;
44
+ /**
45
+ * 读取最近的 Provider 提供的客户端。仅供模块内部使用,不从包入口导出:
46
+ * 调用方不需要知道该发什么请求,也就不会直接用它。
47
+ *
48
+ * Reads the client from the nearest Provider. Internal to modules and not
49
+ * exported from the package: a caller does not need to know which requests to
50
+ * send, so it has no reason to use this directly.
51
+ */
52
+ export declare function useOvClient(): OvClient | null;