@openviking/react 0.1.3 → 0.1.5

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 (209) hide show
  1. package/LICENSE.arco-design +21 -0
  2. package/README.md +27 -15
  3. package/dist/0~0.js +19 -0
  4. package/dist/28~0.js +15 -0
  5. package/dist/2~0.js +2270 -29
  6. package/dist/2~0.js.LICENSE.txt +23 -0
  7. package/dist/3c~0.js +2208 -0
  8. package/dist/3~0.js +1207 -1982
  9. package/dist/4~0.js +18 -0
  10. package/dist/9~0.js +43 -0
  11. package/dist/{1~0.js → ae~0.js} +11 -26
  12. package/dist/ark-message-list-view~0.js +530 -119
  13. package/dist/a~0.js +1300 -14
  14. package/dist/c7~0.js +38 -2
  15. package/dist/ck~0.js +23 -0
  16. package/dist/client/provider.d.ts +15 -9
  17. package/dist/client/types.d.ts +5 -5
  18. package/dist/client.js +2 -1
  19. package/dist/components/agent-connect/agent-connect-code-block.d.ts +14 -0
  20. package/dist/components/agent-connect/agent-connect-copy.d.ts +22 -33
  21. package/dist/components/agent-connect/agent-connect-design.d.ts +1936 -168
  22. package/dist/components/agent-connect/agent-connect-installer.d.ts +1 -0
  23. package/dist/components/agent-connect/agent-connect-instructions-view.d.ts +4 -6
  24. package/dist/components/agent-connect/agent-connect-instructions.d.ts +148 -0
  25. package/dist/components/agent-connect/agent-connect-markdown.d.ts +8 -2
  26. package/dist/components/agent-connect/agent-connect-mask.d.ts +10 -0
  27. package/dist/components/agent-connect/agent-connect.d.ts +1 -1
  28. package/dist/components/agent-connect/locales/en-US.d.ts +23 -0
  29. package/dist/components/agent-connect/locales/zh-CN.d.ts +3 -0
  30. package/dist/components/agent-connect/style.css +129 -3
  31. package/dist/components/agent-connect/types.d.ts +7 -4
  32. package/dist/components/agent-connect/use-agent-connect-copy.d.ts +6 -0
  33. package/dist/components/directory-tour/directory-tour.d.ts +3 -0
  34. package/dist/components/directory-tour/index.d.ts +3 -0
  35. package/dist/components/directory-tour/locales/en-US.d.ts +3 -0
  36. package/dist/components/directory-tour/locales/zh-CN.d.ts +3 -0
  37. package/dist/components/directory-tour/steps.d.ts +5 -0
  38. package/dist/components/directory-tour/style.css +237 -0
  39. package/dist/components/directory-tour/style.js +0 -0
  40. package/dist/components/directory-tour/types.d.ts +43 -0
  41. package/dist/components/directory-tour/use-tour-anchor.d.ts +5 -0
  42. package/dist/components/directory-tour/use-tour-position.d.ts +12 -0
  43. package/dist/components/directory-tour.js +40 -0
  44. package/dist/components/file-browser-entries/file-browser-entries.d.ts +5 -5
  45. package/dist/components/file-browser-entries/labels.d.ts +3 -0
  46. package/dist/components/file-browser-entries/locales/en-US.d.ts +6 -0
  47. package/dist/components/file-browser-entries/locales/zh-CN.d.ts +6 -0
  48. package/dist/components/file-browser-entries/style.css +866 -2
  49. package/dist/components/file-browser-entries/types.d.ts +34 -16
  50. package/dist/components/file-preview/file-preview-adapters.d.ts +2 -1
  51. package/dist/components/file-preview/file-preview-body.d.ts +2 -1
  52. package/dist/components/file-preview/file-preview-breadcrumb-menu.d.ts +2 -1
  53. package/dist/components/file-preview/file-preview-breadcrumb.d.ts +2 -1
  54. package/dist/components/file-preview/file-preview-directory.d.ts +2 -1
  55. package/dist/components/file-preview/file-preview-handle-adapters.d.ts +2 -1
  56. package/dist/components/file-preview/file-preview-header.d.ts +6 -2
  57. package/dist/components/file-preview/file-preview-image-frame.d.ts +5 -0
  58. package/dist/components/file-preview/file-preview-labels.d.ts +2 -14
  59. package/dist/components/file-preview/file-preview-level-tabs.d.ts +7 -0
  60. package/dist/components/file-preview/file-preview-markdown-images.d.ts +13 -0
  61. package/dist/components/file-preview/file-preview-panels.d.ts +5 -2
  62. package/dist/components/file-preview/file-preview-viewer.d.ts +2 -1
  63. package/dist/components/file-preview/file-preview.d.ts +0 -1
  64. package/dist/components/file-preview/index.d.ts +2 -1
  65. package/dist/components/file-preview/locales/en-US.d.ts +16 -0
  66. package/dist/components/file-preview/locales/zh-CN.d.ts +16 -0
  67. package/dist/components/file-preview/style.css +160 -2
  68. package/dist/components/file-preview/types.d.ts +34 -10
  69. package/dist/components/file-preview/use-file-preview-levels.d.ts +7 -0
  70. package/dist/components/file-preview/use-file-preview-view-state.d.ts +15 -0
  71. package/dist/components/file-preview.js +1 -1
  72. package/dist/components/file-tree/file-tree-info-labels.d.ts +0 -15
  73. package/dist/components/file-tree/file-tree-labels.d.ts +4 -0
  74. package/dist/components/file-tree/file-tree-row-shared.d.ts +2 -12
  75. package/dist/components/file-tree/file-tree-toolbar.d.ts +11 -0
  76. package/dist/components/file-tree/locales/en-US.d.ts +69 -0
  77. package/dist/components/file-tree/locales/zh-CN.d.ts +69 -0
  78. package/dist/components/file-tree/style.css +143 -15
  79. package/dist/components/file-tree/types.d.ts +38 -10
  80. package/dist/components/file-tree/use-file-tree-actions.d.ts +4 -1
  81. package/dist/components/scope-switcher/labels.d.ts +3 -0
  82. package/dist/components/scope-switcher/locales/en-US.d.ts +8 -0
  83. package/dist/components/scope-switcher/locales/zh-CN.d.ts +8 -0
  84. package/dist/components/scope-switcher/scope-panel.d.ts +1 -1
  85. package/dist/components/scope-switcher/scope-switcher.d.ts +2 -2
  86. package/dist/components/scope-switcher/style.css +14 -2
  87. package/dist/components/scope-switcher/types.d.ts +12 -6
  88. package/dist/components/style.css +10030 -6763
  89. package/dist/components/tui/locales/en-US.d.ts +35 -0
  90. package/dist/components/tui/locales/zh-CN.d.ts +35 -0
  91. package/dist/components/tui/style.css +310 -18
  92. package/dist/components/tui/tui-copy-button.d.ts +1 -1
  93. package/dist/components/tui/tui-empty.d.ts +25 -0
  94. package/dist/components/tui/tui-labels.d.ts +2 -2
  95. package/dist/components/tui/tui.d.ts +1 -1
  96. package/dist/components/tui/types.d.ts +35 -12
  97. package/dist/components/tui.js +1 -1
  98. package/dist/components/viking-bot/ark-adapter.d.ts +2 -0
  99. package/dist/components/viking-bot/ark-message-body.d.ts +1 -7
  100. package/dist/components/viking-bot/ark-message-list-view.d.ts +4 -1
  101. package/dist/components/viking-bot/ark-message-row.d.ts +3 -1
  102. package/dist/components/viking-bot/bot-popover.d.ts +9 -0
  103. package/dist/components/viking-bot/capabilities.d.ts +49 -0
  104. package/dist/components/viking-bot/composer-attachments.d.ts +13 -0
  105. package/dist/components/viking-bot/composer-controls.d.ts +10 -0
  106. package/dist/components/viking-bot/composer-footer.d.ts +17 -0
  107. package/dist/components/viking-bot/composer-references.d.ts +20 -0
  108. package/dist/components/viking-bot/composer-text.d.ts +10 -0
  109. package/dist/components/viking-bot/index.d.ts +3 -1
  110. package/dist/components/viking-bot/interaction/ask-human-fields.d.ts +1 -1
  111. package/dist/components/viking-bot/interaction/labels.d.ts +2 -1
  112. package/dist/components/viking-bot/interaction/locales/en-US.d.ts +17 -0
  113. package/dist/components/viking-bot/interaction/locales/zh-CN.d.ts +17 -0
  114. package/dist/components/viking-bot/interaction/types.d.ts +8 -3
  115. package/dist/components/viking-bot/interaction/viking-bot-interaction.d.ts +1 -1
  116. package/dist/components/viking-bot/labels.d.ts +2 -0
  117. package/dist/components/viking-bot/locales/en-US.d.ts +40 -0
  118. package/dist/components/viking-bot/locales/zh-CN.d.ts +40 -0
  119. package/dist/components/viking-bot/markdown-links.d.ts +27 -0
  120. package/dist/components/viking-bot/message-activity.d.ts +7 -0
  121. package/dist/components/viking-bot/message-code-block.d.ts +8 -0
  122. package/dist/components/viking-bot/message-footer.d.ts +8 -0
  123. package/dist/components/viking-bot/message-markdown.d.ts +9 -0
  124. package/dist/components/viking-bot/model.d.ts +37 -3
  125. package/dist/components/viking-bot/quick-input-tracker.d.ts +16 -0
  126. package/dist/components/viking-bot/quick-inputs.d.ts +6 -0
  127. package/dist/components/viking-bot/reference-picker.d.ts +16 -0
  128. package/dist/components/viking-bot/session-actions.d.ts +11 -0
  129. package/dist/components/viking-bot/style.css +1486 -48
  130. package/dist/components/viking-bot/tool-activity.d.ts +9 -0
  131. package/dist/components/viking-bot/tool-result-links.d.ts +6 -0
  132. package/dist/components/viking-bot/types.d.ts +20 -8
  133. package/dist/components/viking-bot/use-quick-input.d.ts +17 -0
  134. package/dist/components/viking-bot/viking-bot.d.ts +1 -6
  135. package/dist/components/viking-bot/welcome.d.ts +8 -0
  136. package/dist/components/viking-bot.js +1 -1
  137. package/dist/c~0.js +550 -69
  138. package/dist/e~0.js +335 -0
  139. package/dist/file-preview-viewer~0.js +90 -8
  140. package/dist/f~0.js +49 -51
  141. package/dist/h~0.js +5 -1
  142. package/dist/icons/console-icons.d.ts +12 -0
  143. package/dist/icons/index.d.ts +2 -0
  144. package/dist/icons/viking-bot-icons.d.ts +6 -0
  145. package/dist/icons.js +1 -0
  146. package/dist/index.d.ts +2 -0
  147. package/dist/index.js +2 -1
  148. package/dist/k~0.js +1 -0
  149. package/dist/lg~0.js +155 -0
  150. package/dist/lk~0.js +40 -8
  151. package/dist/l~0.js +170 -181
  152. package/dist/modules/console/command-messages.d.ts +19 -0
  153. package/dist/modules/console/command-parser.d.ts +15 -0
  154. package/dist/modules/console/command-specs.d.ts +15 -0
  155. package/dist/modules/console/commands.d.ts +6 -0
  156. package/dist/modules/console/console-history.d.ts +10 -0
  157. package/dist/modules/console/console-toolbar.d.ts +18 -0
  158. package/dist/modules/console/console.d.ts +1 -3
  159. package/dist/modules/console/controller.d.ts +17 -0
  160. package/dist/modules/console/index.d.ts +2 -0
  161. package/dist/modules/console/labels.d.ts +61 -0
  162. package/dist/modules/console/locales/en-US.d.ts +49 -0
  163. package/dist/modules/console/locales/zh-CN.d.ts +3 -0
  164. package/dist/modules/console/localize-records.d.ts +11 -0
  165. package/dist/modules/console/results.d.ts +2 -0
  166. package/dist/modules/console/style.css +10905 -15
  167. package/dist/modules/console/types.d.ts +59 -80
  168. package/dist/modules/console/use-console.d.ts +3 -0
  169. package/dist/modules/console.js +1 -1
  170. package/dist/modules/file-browser/file-browser-detail.d.ts +2 -1
  171. package/dist/modules/file-browser/file-browser-labels.d.ts +11 -12
  172. package/dist/modules/file-browser/file-browser-toolbar.d.ts +3 -4
  173. package/dist/modules/file-browser/file-browser-tree-pane.d.ts +7 -5
  174. package/dist/modules/file-browser/file-browser.d.ts +1 -1
  175. package/dist/modules/file-browser/fs-read-directory.d.ts +2 -6
  176. package/dist/modules/file-browser/locales/en-US.d.ts +25 -0
  177. package/dist/modules/file-browser/locales/zh-CN.d.ts +25 -0
  178. package/dist/modules/file-browser/style.css +1695 -126
  179. package/dist/modules/file-browser/types.d.ts +38 -29
  180. package/dist/modules/file-browser/use-file-browser.d.ts +6 -1
  181. package/dist/modules/file-browser/use-fs-preview.d.ts +15 -1
  182. package/dist/modules/scope-cascade/labels.d.ts +6 -0
  183. package/dist/modules/scope-cascade/locales/en-US.d.ts +6 -0
  184. package/dist/modules/scope-cascade/locales/zh-CN.d.ts +3 -0
  185. package/dist/modules/scope-cascade/scope-cascade.d.ts +2 -2
  186. package/dist/modules/scope-cascade/style.css +14 -2
  187. package/dist/modules/scope-cascade/types.d.ts +3 -0
  188. package/dist/modules/style.css +15938 -3455
  189. package/dist/nx~0.js +15 -0
  190. package/dist/n~0.js +240 -83
  191. package/dist/o~0.js +10 -7
  192. package/dist/p~0.js +27 -0
  193. package/dist/rslib-runtime~0.js +42 -0
  194. package/dist/r~0.js +152 -0
  195. package/dist/shared/components/drawer/drawer.d.ts +13 -0
  196. package/dist/shared/components/drawer/index.d.ts +1 -0
  197. package/dist/shared/components/overlay/use-overlay-position.d.ts +2 -2
  198. package/dist/shared/components/tooltip/use-portal-theme.d.ts +3 -0
  199. package/dist/shared/locale-context.d.ts +8 -0
  200. package/dist/shared/locale.d.ts +6 -0
  201. package/dist/style.css +26339 -10577
  202. package/dist/u~0.js +397 -152
  203. package/dist/viking-bot-composer~0.js +436 -77
  204. package/dist/viking-bot-interaction~0.js +13 -11
  205. package/package.json +15 -4
  206. package/dist/30~0.js +0 -1332
  207. package/dist/components/tui/tui-labels-zh.d.ts +0 -2
  208. package/dist/modules/file-browser/tree-info-copy.d.ts +0 -15
  209. package/dist/modules/file-browser/tree-info-copy.zh-CN.d.ts +0 -15
package/dist/l~0.js CHANGED
@@ -1,9 +1,14 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
3
- import { Tooltip, FilePreview as file_preview_FilePreview } from "./30~0.js";
3
+ import { FilePreview as file_preview_FilePreview } from "./3~0.js";
4
+ import { Tooltip } from "./r~0.js";
4
5
  import { getFileTypeColor, resolveFileTypeIconKey, FolderIcon, getFileTypeIcon } from "./k~0.js";
6
+ import { FileBrowserEntries } from "./2~0.js";
5
7
  import { FileTree as file_tree_FileTree } from "./n~0.js";
6
- import { OV_PATHS, useOvClient } from "./1~0.js";
8
+ import { resolveLocale } from "./nx~0.js";
9
+ import { OV_PATHS } from "./ck~0.js";
10
+ import { useLocale, LocaleProvider } from "./28~0.js";
11
+ import { useOvClient } from "./ae~0.js";
7
12
  function clampResizableWidth(width, min, max) {
8
13
  const rounded = Math.round(width);
9
14
  const lower = Math.max(min, rounded);
@@ -315,13 +320,14 @@ function directoryIcon() {
315
320
  className: "ov-file-tree__file-type-icon"
316
321
  });
317
322
  }
318
- function FileBrowserTreePane({ toolbarActions, searchId, browser, treeLabels, searchPlaceholder, refreshLabel, searchLoading, searchEmpty, searchErrorLabel, retryLabel }) {
323
+ function FileBrowserTreePane({ entries, locale, searchId, browser, treeLabels, searchPlaceholder, refreshLabel, searchLoading, searchEmpty, searchErrorLabel, retryLabel }) {
319
324
  return /*#__PURE__*/ jsxs(Fragment, {
320
325
  children: [
321
- toolbarActions ? /*#__PURE__*/ jsx("div", {
322
- className: "ov-file-browser__entries",
323
- children: toolbarActions
324
- }) : null,
326
+ /*#__PURE__*/ jsx(FileBrowserEntries, {
327
+ ...entries,
328
+ locale: locale,
329
+ className: "ov-file-browser__entries"
330
+ }),
325
331
  /*#__PURE__*/ jsx(FileBrowserToolbar, {
326
332
  searchId: searchId,
327
333
  query: browser.query,
@@ -335,6 +341,7 @@ function FileBrowserTreePane({ toolbarActions, searchId, browser, treeLabels, se
335
341
  /*#__PURE__*/ jsx("div", {
336
342
  className: "ov-file-browser__tree-scroll",
337
343
  children: /*#__PURE__*/ jsx(file_tree_FileTree, {
344
+ locale: locale,
338
345
  rows: browser.rows,
339
346
  selectedId: browser.selectedId,
340
347
  isReady: browser.isReady,
@@ -373,7 +380,8 @@ function FileBrowserTreePane({ toolbarActions, searchId, browser, treeLabels, se
373
380
  ]
374
381
  });
375
382
  }
376
- const DEFAULT_LABELS = {
383
+ const messages = {
384
+ formatCharacterCount: (count)=>`${count.toLocaleString('en-US')} ${1 === count ? 'character' : 'characters'}`,
377
385
  empty: 'Select a file to preview',
378
386
  error: 'Failed to load the directory',
379
387
  retry: 'Retry',
@@ -396,10 +404,39 @@ const DEFAULT_LABELS = {
396
404
  summaryEmpty: 'No summary generated yet',
397
405
  summaryFailed: 'The summary could not be loaded.'
398
406
  };
399
- function resolveLabels(labels) {
407
+ const en_US = messages;
408
+ const zh_CN_messages = {
409
+ formatCharacterCount: (count)=>`${count.toLocaleString('zh-CN')} 个字符`,
410
+ empty: '选择一个文件查看内容',
411
+ error: '目录加载失败',
412
+ retry: '重试',
413
+ refresh: '刷新',
414
+ searchPlaceholder: '搜索文件 ⌘+K...',
415
+ searchEmpty: '没有匹配的资源',
416
+ searchFailed: '搜索失败',
417
+ loading: '加载中…',
418
+ searchLoading: '搜索中…',
419
+ previewMode: '预览',
420
+ sourceMode: '源码',
421
+ copyPath: '复制路径',
422
+ copyContent: '复制正文',
423
+ download: '下载',
424
+ history: '版本历史',
425
+ viewSwitch: '切换视图',
426
+ resizeTree: '调整目录树宽度',
427
+ l0Summary: 'L0 摘要',
428
+ l1Overview: 'L1 总览',
429
+ summaryEmpty: '暂无生成内容',
430
+ summaryFailed: '摘要加载失败。'
431
+ };
432
+ const zh_CN = zh_CN_messages;
433
+ const LOCALES = {
434
+ 'en-US': en_US,
435
+ 'zh-CN': zh_CN
436
+ };
437
+ function resolveLabels(labels, locale) {
400
438
  return {
401
- ...DEFAULT_LABELS,
402
- ...labels,
439
+ ...resolveLocale(LOCALES, locale, labels),
403
440
  tree: labels?.tree,
404
441
  previewLabels: labels?.preview
405
442
  };
@@ -412,84 +449,12 @@ function resolvePreviewLabels(text) {
412
449
  ...text.previewLabels
413
450
  };
414
451
  }
415
- const TREE_INFO_LABELS_ZH_CN = {
416
- description: {
417
- userRoot: '当前用户的上下文数据',
418
- memories: '跨会话沉淀的长期记忆',
419
- peers: '按应用或工作区隔离的上下文',
420
- privacy: '密钥等敏感配置',
421
- userResources: '该用户的私有知识资料',
422
- sessions: '对话与任务运行记录',
423
- skills: 'Agent 可用的技能与工具',
424
- profile: '用户身份与背景',
425
- preferences: '个性化偏好',
426
- entities: '人物、项目、组织等实体',
427
- events: '按日期归档的关键事件',
428
- identity: 'Agent 名称与人设',
429
- soul: 'Agent 行为准则与边界',
430
- cases: '用于训练经验的交互案例',
431
- trajectories: '可复用的任务执行轨迹',
432
- experiences: '自动提炼的执行经验',
433
- sharedResources: 'Agent 可引用的外部资料',
434
- agentRoot: 'Agent 的能力、工具与经验',
435
- agentEndpoints: '账号内共享的通信端点配置',
436
- agentPayments: '账号内共享的支付能力配置',
437
- agentSkills: '账号内可调用的技能定义',
438
- agentTools: '账号内共享的工具配置',
439
- memoryRoot: '长期记忆与累积信息',
440
- resourceRoot: 'Agent 可引用的外部知识',
441
- sessionRoot: '用户的原始会话记录',
442
- systemRoot: '系统内置资源'
443
- },
444
- triggerBehavior: {
445
- userRoot: '根据当前用户身份自动建立,无需手动创建',
446
- memories: '提交会话、主动要求记住信息,或从会话中持续抽取',
447
- peers: '以特定 peer 身份连接时建立,按 peer_id 隔离记忆与资料',
448
- userResources: '导入资料时上传到该用户的私有资源目录',
449
- sessions: '会话调用 OpenViking 时建立,消息、工具调用与归档持续写入',
450
- skills: '作为个人技能被创建、安装或导入',
451
- profile: '对话中出现稳定、明确的用户背景或工作方式',
452
- preferences: '用户明确表达某个偏好、习惯或风格',
453
- entities: '对话中出现值得保留的人物、项目或组织',
454
- events: '对话中出现重要决定、承诺、安排、进展或结果',
455
- identity: '首次记忆抽取时初始化,之后由写入操作更新',
456
- soul: '首次记忆抽取时初始化,之后由写入操作调整',
457
- cases: '提交了任务明确、执行结果可评估的会话',
458
- trajectories: '提交了包含决策、工具调用或多步执行的任务',
459
- experiences: '从任务案例与执行轨迹中提炼',
460
- sharedResources: '导入资料时上传到共享资源空间',
461
- agentEndpoints: '为账号注册集成端点时配置',
462
- agentPayments: '为账号开通支付能力时配置',
463
- agentSkills: '作为共享技能安装或导入,供所有 Agent 使用',
464
- agentTools: '为账号注册工具时配置'
465
- },
466
- field: {
467
- description: '说明',
468
- triggerBehavior: '触发行为',
469
- path: '路径'
470
- }
471
- };
472
- function resolveTreeLabels(locale, hostLabels) {
473
- if ('zh-CN' !== locale) return hostLabels;
474
- const hostInfo = hostLabels?.info;
452
+ function resolveSummaryLabels(locale, labels) {
453
+ const text = resolveLabels(labels, locale);
475
454
  return {
476
- ...hostLabels,
477
- info: {
478
- ...TREE_INFO_LABELS_ZH_CN,
479
- ...hostInfo,
480
- description: {
481
- ...TREE_INFO_LABELS_ZH_CN.description,
482
- ...hostInfo?.description
483
- },
484
- triggerBehavior: {
485
- ...TREE_INFO_LABELS_ZH_CN.triggerBehavior,
486
- ...hostInfo?.triggerBehavior
487
- },
488
- field: {
489
- ...TREE_INFO_LABELS_ZH_CN.field,
490
- ...hostInfo?.field
491
- }
492
- }
455
+ l0: text.l0Summary,
456
+ l1: text.l1Overview,
457
+ failure: text.summaryFailed
493
458
  };
494
459
  }
495
460
  function useContainerWidth() {
@@ -730,7 +695,7 @@ function toBinaryTab(uri, name, file, icon, openParent) {
730
695
  }
731
696
  };
732
697
  }
733
- async function readDirectory(client, uri, options, labels, openParent) {
698
+ async function readDirectory(client, uri, options) {
734
699
  const read = (path)=>client.request({
735
700
  method: 'GET',
736
701
  path,
@@ -756,12 +721,12 @@ async function readDirectory(client, uri, options, labels, openParent) {
756
721
  if (aborted && !aborted.ok) throw aborted.cause;
757
722
  if (!abstractResult.ok && !overviewResult.ok) throw abstractResult.cause;
758
723
  const reason = (result)=>result.ok ? void 0 : result.cause instanceof Error ? result.cause.message : String(result.cause);
759
- return toDirectoryTab(uri, {
724
+ return {
760
725
  abstract: abstractResult.ok ? abstractResult.text : '',
761
726
  overview: overviewResult.ok ? overviewResult.text : '',
762
727
  abstractError: reason(abstractResult),
763
728
  overviewError: reason(overviewResult)
764
- }, labels, openParent, directoryIcon());
729
+ };
765
730
  }
766
731
  async function resolveIsDirectory(client, uri, options) {
767
732
  try {
@@ -784,22 +749,19 @@ function abortError() {
784
749
  return error;
785
750
  }
786
751
  const MAX_LINES = 2000;
787
- const DEFAULT_SUMMARY_LABELS = {
788
- l0: 'L0 Summary',
789
- l1: 'L1 Overview',
790
- failure: 'The summary could not be loaded.'
791
- };
792
- function useFsPreview({ client, uri, resourceType = 'file', labels = DEFAULT_SUMMARY_LABELS, openParent, generation = 0, requestOptions }) {
752
+ function useFsPreview({ client, uri, resourceType = 'file', labels = resolveSummaryLabels('en-US'), formatCharacterCount = resolveLabels(void 0, 'en-US').formatCharacterCount, openParent, generation = 0, requestOptions }) {
753
+ const [directory, setDirectory] = useState(null);
793
754
  const [tabs, setTabs] = useState(null);
794
755
  const [activeKey, setActiveKey] = useState(null);
795
756
  const [error, setError] = useState(null);
796
- const [footer, setFooter] = useState(void 0);
757
+ const [characterCount, setCharacterCount] = useState();
797
758
  useEffect(()=>{
759
+ setDirectory(null);
798
760
  if (!client || !uri) {
799
761
  setTabs(null);
800
762
  setActiveKey(null);
801
763
  setError(null);
802
- setFooter(void 0);
764
+ setCharacterCount(void 0);
803
765
  return;
804
766
  }
805
767
  const controller = new AbortController();
@@ -809,7 +771,7 @@ function useFsPreview({ client, uri, resourceType = 'file', labels = DEFAULT_SUM
809
771
  setActiveKey(uri);
810
772
  setActiveKey(null);
811
773
  setError(null);
812
- setFooter(void 0);
774
+ setCharacterCount(void 0);
813
775
  const options = {
814
776
  ...requestOptions,
815
777
  signal: controller.signal
@@ -817,16 +779,29 @@ function useFsPreview({ client, uri, resourceType = 'file', labels = DEFAULT_SUM
817
779
  const read = (async ()=>{
818
780
  const isDir = 'unknown' === resourceType ? await resolveIsDirectory(client, uri, options) : 'directory' === resourceType;
819
781
  if (controller.signal.aborted) throw abortError();
820
- return isDir ? readDirectory(client, uri, options, labels, openParent) : readFile(client, uri, options, openParent);
782
+ return isDir ? {
783
+ summary: await readDirectory(client, uri, options)
784
+ } : {
785
+ tab: await readFile(client, uri, options, openParent)
786
+ };
821
787
  })();
822
- read.then((tab)=>{
788
+ read.then((result)=>{
823
789
  if (controller.signal.aborted) return;
790
+ if (result.summary) {
791
+ setDirectory({
792
+ uri,
793
+ summary: result.summary
794
+ });
795
+ setActiveKey(uri);
796
+ return;
797
+ }
798
+ const tab = result.tab;
824
799
  setTabs([
825
800
  tab
826
801
  ]);
827
802
  setActiveKey(tab.key);
828
- const body = 'directory' === tab.kind ? tab.levels[0].source.content ?? '' : 'file' === tab.kind ? tab.source.content ?? '' : '';
829
- setFooter(`${body.length} characters`);
803
+ const body = tab.source.content ?? '';
804
+ setCharacterCount(body.length);
830
805
  }, (cause)=>{
831
806
  if (isAbort(cause) || controller.signal.aborted) return;
832
807
  setTabs([]);
@@ -837,16 +812,19 @@ function useFsPreview({ client, uri, resourceType = 'file', labels = DEFAULT_SUM
837
812
  client,
838
813
  uri,
839
814
  resourceType,
840
- labels,
841
815
  openParent,
842
816
  generation,
843
817
  requestOptions
844
818
  ]);
819
+ const directoryTab = directory?.uri === uri ? toDirectoryTab(directory.uri, directory.summary, labels, openParent, directoryIcon()) : void 0;
820
+ const count = directoryTab ? (directoryTab.levels[0].source.content ?? '').length : characterCount;
845
821
  return {
846
- tabs,
822
+ tabs: directoryTab ? [
823
+ directoryTab
824
+ ] : tabs,
847
825
  activeKey,
848
826
  error,
849
- footer,
827
+ footer: void 0 === count ? void 0 : formatCharacterCount(count),
850
828
  setActiveKey
851
829
  };
852
830
  }
@@ -1262,7 +1240,8 @@ function useFsTree({ client, rootUri, defaultExpandedUri, requestOptions }) {
1262
1240
  ...state
1263
1241
  };
1264
1242
  }
1265
- function useFileBrowser({ rootUri, controlled = false, summaryLabels, defaultExpandedUri, currentUri, requestOptions, onUriChange }) {
1243
+ function useFileBrowser({ rootUri, locale: localeProp, controlled = false, summaryLabels, formatCharacterCount, defaultExpandedUri, currentUri, requestOptions, onUriChange }) {
1244
+ const locale = useLocale(localeProp);
1266
1245
  const client = useOvClient();
1267
1246
  const [query, setQuery] = useState('');
1268
1247
  const [pendingUri, setPendingUri] = useState(currentUri);
@@ -1297,7 +1276,8 @@ function useFileBrowser({ rootUri, controlled = false, summaryLabels, defaultExp
1297
1276
  client,
1298
1277
  uri: activeUri,
1299
1278
  resourceType,
1300
- labels: summaryLabels,
1279
+ labels: summaryLabels ?? resolveSummaryLabels(locale),
1280
+ formatCharacterCount: formatCharacterCount ?? resolveLabels(void 0, locale).formatCharacterCount,
1301
1281
  openParent,
1302
1282
  generation: refreshGeneration,
1303
1283
  requestOptions
@@ -1371,13 +1351,14 @@ function useFileBrowser({ rootUri, controlled = false, summaryLabels, defaultExp
1371
1351
  actions
1372
1352
  };
1373
1353
  }
1374
- function FileBrowser({ uri, defaultUri, rootUri = 'viking://', defaultExpandedUri, locale, toolbarActions, onUriChange, labels, requestOptions, className, style, ...rest }) {
1354
+ function FileBrowser({ uri, defaultUri, rootUri = 'viking://', defaultExpandedUri, locale: localeProp, agentConnect, onUriChange, onImportResources, renderImportResources, labels, requestOptions, className, style, ...rest }) {
1355
+ const locale = useLocale(localeProp);
1375
1356
  const [internalUri, setInternalUri] = useState(()=>defaultUri ?? null);
1376
1357
  const [preferredTreeWidth, setPreferredTreeWidth] = useState(352);
1377
1358
  const searchId = useId();
1378
1359
  const isControlled = void 0 !== uri;
1379
1360
  const currentUri = isControlled ? uri : internalUri;
1380
- const text = resolveLabels(labels);
1361
+ const text = resolveLabels(labels, locale);
1381
1362
  const { ref: layoutRef, width: layoutWidth } = useContainerWidth();
1382
1363
  const treeMaxWidth = resolveTreeMaxWidth(layoutWidth);
1383
1364
  const treeWidth = Math.min(preferredTreeWidth, treeMaxWidth);
@@ -1397,87 +1378,95 @@ function FileBrowser({ uri, defaultUri, rootUri = 'viking://', defaultExpandedUr
1397
1378
  text.l1Overview,
1398
1379
  text.summaryFailed
1399
1380
  ]);
1400
- const previewLabels = useMemo(()=>resolvePreviewLabels(resolveLabels(labels)), [
1401
- labels
1402
- ]);
1403
- const treeLabels = useMemo(()=>resolveTreeLabels(locale, text.tree), [
1404
- locale,
1405
- text.tree
1381
+ const previewLabels = useMemo(()=>resolvePreviewLabels(resolveLabels(labels, locale)), [
1382
+ labels,
1383
+ locale
1406
1384
  ]);
1407
1385
  const browser = useFileBrowser({
1408
1386
  rootUri,
1387
+ locale,
1409
1388
  controlled: isControlled,
1410
1389
  summaryLabels,
1390
+ formatCharacterCount: text.formatCharacterCount,
1411
1391
  defaultExpandedUri,
1412
1392
  currentUri,
1413
1393
  requestOptions,
1414
1394
  onUriChange: changeUri
1415
1395
  });
1416
- return /*#__PURE__*/ jsxs("div", {
1417
- ...rest,
1418
- ref: layoutRef,
1419
- className: [
1420
- 'ov-file-browser',
1421
- className
1422
- ].filter(Boolean).join(' '),
1423
- style: {
1424
- ...style,
1425
- '--ov-file-browser-tree-width': `${treeWidth}px`
1426
- },
1427
- children: [
1428
- /*#__PURE__*/ jsx("div", {
1429
- className: "ov-file-browser__tree",
1430
- children: /*#__PURE__*/ jsx(FileBrowserTreePane, {
1431
- toolbarActions: toolbarActions,
1432
- searchId: searchId,
1433
- browser: browser,
1434
- treeLabels: treeLabels,
1435
- searchPlaceholder: text.searchPlaceholder,
1436
- refreshLabel: text.refresh,
1437
- searchLoading: text.searchLoading,
1438
- searchEmpty: text.searchEmpty,
1439
- searchErrorLabel: text.searchFailed,
1440
- retryLabel: text.retry
1441
- })
1442
- }),
1443
- /*#__PURE__*/ jsx(ResizableHandle, {
1444
- label: text.resizeTree,
1445
- min: 200,
1446
- max: treeMaxWidth,
1447
- value: treeWidth,
1448
- onResize: setPreferredTreeWidth,
1449
- className: "ov-file-browser__resizer"
1450
- }),
1451
- browser.previewTabs && browser.previewTabs.length > 0 ? /*#__PURE__*/ jsx(FileBrowserDetail, {
1452
- tabs: browser.previewTabs,
1453
- activeKey: browser.previewKey,
1454
- locale: locale,
1455
- labels: previewLabels,
1456
- footer: browser.previewFooter,
1457
- viewLabels: {
1458
- preview: text.previewMode,
1459
- source: text.sourceMode,
1460
- copyPath: text.copyPath,
1461
- copyContent: text.copyContent,
1462
- download: text.download,
1463
- viewSwitch: text.viewSwitch
1464
- },
1465
- onActiveKeyChange: browser.actions.setPreviewKey
1466
- }) : browser.currentUri && browser.previewError ? /*#__PURE__*/ jsx("div", {
1467
- className: "ov-file-browser__detail",
1468
- children: /*#__PURE__*/ jsx(FileBrowserFailure, {
1469
- message: text.error,
1470
- detail: browser.previewError.message,
1471
- retryLabel: text.retry,
1472
- onRetry: ()=>void browser.actions.refresh()
1473
- })
1474
- }) : /*#__PURE__*/ jsx("div", {
1475
- className: "ov-file-browser__detail",
1476
- children: /*#__PURE__*/ jsx(FileBrowserEmpty, {
1477
- label: text.empty
1396
+ return /*#__PURE__*/ jsx(LocaleProvider, {
1397
+ locale: locale,
1398
+ children: /*#__PURE__*/ jsxs("div", {
1399
+ ...rest,
1400
+ ref: layoutRef,
1401
+ className: [
1402
+ 'ov-file-browser',
1403
+ className
1404
+ ].filter(Boolean).join(' '),
1405
+ style: {
1406
+ ...style,
1407
+ '--ov-file-browser-tree-width': `${treeWidth}px`
1408
+ },
1409
+ children: [
1410
+ /*#__PURE__*/ jsx("div", {
1411
+ className: "ov-file-browser__tree",
1412
+ children: /*#__PURE__*/ jsx(FileBrowserTreePane, {
1413
+ entries: {
1414
+ agentConnect,
1415
+ onImportResources,
1416
+ renderImportResources,
1417
+ labels: labels?.entries
1418
+ },
1419
+ searchId: searchId,
1420
+ browser: browser,
1421
+ treeLabels: text.tree,
1422
+ locale: locale,
1423
+ searchPlaceholder: text.searchPlaceholder,
1424
+ refreshLabel: text.refresh,
1425
+ searchLoading: text.searchLoading,
1426
+ searchEmpty: text.searchEmpty,
1427
+ searchErrorLabel: text.searchFailed,
1428
+ retryLabel: text.retry
1429
+ })
1430
+ }),
1431
+ /*#__PURE__*/ jsx(ResizableHandle, {
1432
+ label: text.resizeTree,
1433
+ min: 200,
1434
+ max: treeMaxWidth,
1435
+ value: treeWidth,
1436
+ onResize: setPreferredTreeWidth,
1437
+ className: "ov-file-browser__resizer"
1438
+ }),
1439
+ browser.previewTabs && browser.previewTabs.length > 0 ? /*#__PURE__*/ jsx(FileBrowserDetail, {
1440
+ tabs: browser.previewTabs,
1441
+ activeKey: browser.previewKey,
1442
+ locale: locale,
1443
+ labels: previewLabels,
1444
+ footer: browser.previewFooter,
1445
+ viewLabels: {
1446
+ preview: text.previewMode,
1447
+ source: text.sourceMode,
1448
+ copyPath: text.copyPath,
1449
+ copyContent: text.copyContent,
1450
+ download: text.download,
1451
+ viewSwitch: text.viewSwitch
1452
+ },
1453
+ onActiveKeyChange: browser.actions.setPreviewKey
1454
+ }) : browser.currentUri && browser.previewError ? /*#__PURE__*/ jsx("div", {
1455
+ className: "ov-file-browser__detail",
1456
+ children: /*#__PURE__*/ jsx(FileBrowserFailure, {
1457
+ message: text.error,
1458
+ detail: browser.previewError.message,
1459
+ retryLabel: text.retry,
1460
+ onRetry: ()=>void browser.actions.refresh()
1461
+ })
1462
+ }) : /*#__PURE__*/ jsx("div", {
1463
+ className: "ov-file-browser__detail",
1464
+ children: /*#__PURE__*/ jsx(FileBrowserEmpty, {
1465
+ label: text.empty
1466
+ })
1478
1467
  })
1479
- })
1480
- ]
1468
+ ]
1469
+ })
1481
1470
  });
1482
1471
  }
1483
1472
  export { FileBrowser, useFileBrowser };
@@ -0,0 +1,19 @@
1
+ import type { TuiRecord } from '../../components/tui/index.js';
2
+ import type { Locale } from '../../shared/locale.js';
3
+ import { resolveConsoleLocale } from './labels.js';
4
+ export interface ConsoleMessage {
5
+ code: keyof ReturnType<typeof resolveConsoleLocale>['messages'];
6
+ value?: string;
7
+ usage?: string;
8
+ }
9
+ /** Internal metadata is formatted by the Hook and never exposed in its records. */
10
+ export type ConsoleRecord = TuiRecord & {
11
+ localMessage?: ConsoleMessage;
12
+ };
13
+ export declare function formatConsoleMessage(message: ConsoleMessage, locale: Locale): string;
14
+ export declare class ConsoleCommandError extends Error implements ConsoleMessage {
15
+ readonly code: ConsoleMessage['code'];
16
+ readonly value?: string | undefined;
17
+ readonly usage?: string | undefined;
18
+ constructor(code: ConsoleMessage['code'], value?: string | undefined, usage?: string | undefined, locale?: Locale);
19
+ }
@@ -0,0 +1,15 @@
1
+ interface CommandToken {
2
+ value: string;
3
+ literal: boolean;
4
+ }
5
+ /** Parses arguments as data; never invokes a shell. */
6
+ export declare function tokenize(input: string): CommandToken[];
7
+ export interface Argument {
8
+ name: string;
9
+ kind?: 'uri' | 'integer' | 'boolean';
10
+ optional?: boolean;
11
+ choices?: readonly string[];
12
+ min?: number;
13
+ }
14
+ export declare function parseArguments(tokens: readonly CommandToken[], positional: readonly Argument[], flags?: readonly Argument[]): Record<string, string | number | boolean>;
15
+ export {};
@@ -0,0 +1,15 @@
1
+ import type enUS from './locales/en-US.js';
2
+ import type { OvRequestSpec } from '../../client/types.js';
3
+ import type { TuiSkeletonKind } from '../../components/tui/index.js';
4
+ import type { Argument } from './command-parser.js';
5
+ type Values = Record<string, string | number | boolean>;
6
+ export interface CommandSpec {
7
+ name: keyof typeof enUS.commands;
8
+ positional?: readonly Argument[];
9
+ flags?: readonly Argument[];
10
+ skeleton?: TuiSkeletonKind;
11
+ request?: (values: Values) => OvRequestSpec;
12
+ }
13
+ /** One catalogue drives validation, execution, completion and help. */
14
+ export declare const COMMAND_SPECS: readonly CommandSpec[];
15
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { OvClient, OvRequestOptions } from '../../client/types.js';
2
+ import type { TuiCommandDefinition, TuiRecordContent } from '../../components/tui/index.js';
3
+ import type { Locale } from '../../shared/locale.js';
4
+ export declare function consoleCommands(locale: Locale): readonly TuiCommandDefinition[];
5
+ export declare function createCommandHelp(locale: Locale): TuiRecordContent;
6
+ export declare function executeCommand(input: string, client: OvClient, options: OvRequestOptions, locale: Locale): Promise<TuiRecordContent>;
@@ -0,0 +1,10 @@
1
+ import type { Locale } from '../../shared/locale.js';
2
+ import type { TuiRecord } from '../../components/tui/index.js';
3
+ import type { consoleLabels } from './labels.js';
4
+ export declare function ConsoleHistory({ records, isExecuting, locale, labels, onRecall, }: {
5
+ records: readonly TuiRecord[];
6
+ isExecuting: boolean;
7
+ locale: Locale;
8
+ labels: ReturnType<typeof consoleLabels>;
9
+ onRecall: (command: string) => void;
10
+ }): import("react").JSX.Element;
@@ -0,0 +1,18 @@
1
+ import type { Locale } from '../../shared/locale.js';
2
+ import type { ReactNode } from 'react';
3
+ import type { TuiRecord } from '../../components/tui/index.js';
4
+ import type { ConsoleMode } from './types.js';
5
+ import type { consoleLabels } from './labels.js';
6
+ export declare function ConsoleToolbar({ mode, panelId, locale, labels, records, isExecuting, onModeChange, onClear, onRecall, children, conversationActions, }: {
7
+ mode: ConsoleMode;
8
+ panelId: string;
9
+ locale: Locale;
10
+ labels: ReturnType<typeof consoleLabels>;
11
+ records: readonly TuiRecord[];
12
+ isExecuting: boolean;
13
+ onModeChange: (mode: ConsoleMode) => void;
14
+ onClear: () => void;
15
+ onRecall: (command: string) => void;
16
+ children?: ReactNode;
17
+ conversationActions?: ReactNode;
18
+ }): import("react").JSX.Element;
@@ -1,4 +1,2 @@
1
1
  import type { ConsoleProps } from './types.js';
2
- export type { ConsoleLabels, ConsoleMode, ConsoleProps, ConsoleSlots, } from './types.js';
3
- /** 占位组件:渲染一个带模块名的空容器,真实实现随模块 Hook 与组合视图迁入。 */
4
- export declare function Console({ className, style, labels }: ConsoleProps): import("react").JSX.Element;
2
+ export declare function Console({ mode, defaultMode, locale: localeProp, quickCommands, scopeKey, requestOptions, onModeChange, onOpenUri, conversation, slots, labels: overrides, className, ...rest }: ConsoleProps): import("react").JSX.Element;
@@ -0,0 +1,17 @@
1
+ import type { Locale } from '../../shared/locale.js';
2
+ import { type ConsoleRecord } from './command-messages.js';
3
+ import type { OvClient, OvRequestOptions } from '../../client/types.js';
4
+ import type { ConsoleState } from './types.js';
5
+ export declare function createConsoleController(client: OvClient, options?: OvRequestOptions): {
6
+ subscribe: (listener: () => void) => () => void;
7
+ getSnapshot: () => Omit<ConsoleState, "records"> & {
8
+ records: readonly ConsoleRecord[];
9
+ };
10
+ start(): () => void;
11
+ execute: (input?: string, locale?: Locale) => Promise<void>;
12
+ cancel: () => void | undefined;
13
+ clear: () => void;
14
+ setCommand: (command: string) => void;
15
+ setConversationDraft: (conversationDraft: string) => void;
16
+ retry: (locale: Locale) => Promise<void>;
17
+ };
@@ -1 +1,3 @@
1
1
  export * from './console.js';
2
+ export { useConsole } from './use-console.js';
3
+ export type { ConsoleLabels, ConsoleMode, ConsoleOptions, ConsoleResult, ConsoleState, ConsoleProps, ConsoleSlots, } from './types.js';