@openviking/react 0.1.4 → 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.
- package/README.md +3 -1
- package/dist/28~0.js +15 -0
- package/dist/2~0.js +6 -3
- package/dist/3c~0.js +3 -1
- package/dist/3~0.js +3 -1
- package/dist/ae~0.js +6 -2
- package/dist/a~0.js +77 -70
- package/dist/client/provider.d.ts +10 -6
- package/dist/components/agent-connect/agent-connect-code-block.d.ts +14 -0
- package/dist/components/agent-connect/agent-connect-copy.d.ts +3 -0
- package/dist/components/agent-connect/agent-connect-design.d.ts +1 -1
- package/dist/components/agent-connect/agent-connect-installer.d.ts +1 -0
- package/dist/components/agent-connect/agent-connect-instructions-view.d.ts +4 -6
- package/dist/components/agent-connect/agent-connect-instructions.d.ts +13 -0
- package/dist/components/agent-connect/agent-connect-markdown.d.ts +8 -2
- package/dist/components/agent-connect/agent-connect-mask.d.ts +10 -0
- package/dist/components/agent-connect/agent-connect.d.ts +1 -1
- package/dist/components/agent-connect/locales/en-US.d.ts +3 -0
- package/dist/components/agent-connect/style.css +115 -1
- package/dist/components/agent-connect/types.d.ts +5 -3
- package/dist/components/agent-connect/use-agent-connect-copy.d.ts +6 -0
- package/dist/components/directory-tour/types.d.ts +2 -1
- package/dist/components/file-browser-entries/file-browser-entries.d.ts +1 -1
- package/dist/components/file-browser-entries/style.css +115 -1
- package/dist/components/file-browser-entries/types.d.ts +2 -2
- package/dist/components/file-preview/types.d.ts +2 -2
- package/dist/components/file-tree/types.d.ts +2 -2
- package/dist/components/scope-switcher/scope-switcher.d.ts +2 -2
- package/dist/components/scope-switcher/types.d.ts +5 -5
- package/dist/components/style.css +230 -2
- package/dist/components/tui/tui.d.ts +1 -1
- package/dist/components/tui/types.d.ts +2 -2
- package/dist/components/viking-bot/ark-message-list-view.d.ts +4 -1
- package/dist/components/viking-bot/interaction/types.d.ts +2 -2
- package/dist/components/viking-bot/interaction/viking-bot-interaction.d.ts +1 -1
- package/dist/components/viking-bot/session-actions.d.ts +2 -2
- package/dist/components/viking-bot/types.d.ts +7 -7
- package/dist/components/viking-bot/viking-bot.d.ts +1 -1
- package/dist/c~0.js +168 -154
- package/dist/e~0.js +3 -1
- package/dist/f~0.js +13 -7
- package/dist/lk~0.js +4 -1
- package/dist/l~0.js +77 -71
- package/dist/modules/console/console.d.ts +1 -1
- package/dist/modules/console/types.d.ts +2 -2
- package/dist/modules/console/use-console.d.ts +1 -1
- package/dist/modules/file-browser/file-browser.d.ts +1 -1
- package/dist/modules/file-browser/style.css +115 -1
- package/dist/modules/file-browser/types.d.ts +2 -2
- package/dist/modules/file-browser/use-file-browser.d.ts +3 -3
- package/dist/modules/scope-cascade/scope-cascade.d.ts +2 -2
- package/dist/modules/scope-cascade/types.d.ts +2 -2
- package/dist/modules/style.css +115 -1
- package/dist/n~0.js +3 -1
- package/dist/shared/locale-context.d.ts +8 -0
- package/dist/style.css +345 -3
- package/dist/u~0.js +324 -96
- package/dist/viking-bot-composer~0.js +3 -1
- package/dist/viking-bot-interaction~0.js +3 -1
- package/package.json +3 -1
package/dist/u~0.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { Children, createContext, isValidElement, useCallback, useContext, useId, useRef, useState } from "react";
|
|
3
|
+
import react_markdown from "react-markdown";
|
|
4
|
+
import rehype_raw from "rehype-raw";
|
|
5
|
+
import rehype_sanitize from "rehype-sanitize";
|
|
6
|
+
import remark_gfm from "remark-gfm";
|
|
3
7
|
import { resolveLocale } from "./nx~0.js";
|
|
8
|
+
import { checkreact } from "./0~0.js";
|
|
9
|
+
import { useLocale } from "./28~0.js";
|
|
4
10
|
const SvgCodexDetail = (props)=>/*#__PURE__*/ jsxs("svg", {
|
|
5
11
|
xmlns: "http://www.w3.org/2000/svg",
|
|
6
12
|
xmlnsXlink: "http://www.w3.org/1999/xlink",
|
|
@@ -58,6 +64,9 @@ const messages = {
|
|
|
58
64
|
instructions: 'Full instructions',
|
|
59
65
|
copy: 'Copy and send to Agent',
|
|
60
66
|
copyMarkdown: 'Copy as Markdown',
|
|
67
|
+
copyCode: 'Copy code',
|
|
68
|
+
showApiKey: 'Show API Key',
|
|
69
|
+
hideApiKey: 'Hide API Key',
|
|
61
70
|
copied: 'Copied',
|
|
62
71
|
failed: 'Copy failed. Please retry.',
|
|
63
72
|
notice: 'Connected agents can read content available to you in OpenViking. Overseas services may transfer data abroad.',
|
|
@@ -86,6 +95,9 @@ const zh_CN_messages = {
|
|
|
86
95
|
instructions: '完整指令',
|
|
87
96
|
copy: '复制并发送给 Agent',
|
|
88
97
|
copyMarkdown: '复制为 Markdown',
|
|
98
|
+
copyCode: '复制代码',
|
|
99
|
+
showApiKey: '显示 API Key',
|
|
100
|
+
hideApiKey: '隐藏 API Key',
|
|
89
101
|
copied: '已复制',
|
|
90
102
|
failed: '复制失败,请重试',
|
|
91
103
|
notice: '接入后 Agent 能读到你在 OpenViking 里能看到的内容,若接入境外服务数据有可能传到境外。',
|
|
@@ -490,8 +502,11 @@ const INSTALLER_HARNESSES = {
|
|
|
490
502
|
function shellArgument(value) {
|
|
491
503
|
return `'${value.replace(/'/g, "'\"'\"'")}'`;
|
|
492
504
|
}
|
|
505
|
+
function getInstallerCommand(harness, locale, apiKey, baseUrl) {
|
|
506
|
+
return `curl -fsSL https://openviking.ai/install | bash -s -- --yes --lang ${'zh-CN' === locale ? 'zh' : 'en'} --harness ${harness},cli --url ${shellArgument(baseUrl)} --api-key ${shellArgument(apiKey)}`;
|
|
507
|
+
}
|
|
493
508
|
function getInstallerInstructions(name, harness, locale, apiKey, baseUrl) {
|
|
494
|
-
const command =
|
|
509
|
+
const command = getInstallerCommand(harness, locale, apiKey, baseUrl);
|
|
495
510
|
return resolveAgentConnectLabels(locale).installerInstructions(name, command);
|
|
496
511
|
}
|
|
497
512
|
const DEFAULT_BASE_URL = 'https://api.vikingdb.cn-beijing.volces.com/openviking';
|
|
@@ -510,7 +525,11 @@ function getAgentConnectInstructions(id, locale, apiKey, baseUrl, guideId) {
|
|
|
510
525
|
return {
|
|
511
526
|
fixed: true,
|
|
512
527
|
display: instructions('••••••••'),
|
|
513
|
-
copy: instructions(apiKey)
|
|
528
|
+
copy: instructions(apiKey),
|
|
529
|
+
command: {
|
|
530
|
+
display: getInstallerCommand(harness, locale, '••••••••', baseUrl),
|
|
531
|
+
copy: getInstallerCommand(harness, locale, apiKey, baseUrl)
|
|
532
|
+
}
|
|
514
533
|
};
|
|
515
534
|
}
|
|
516
535
|
const guide = content.guides.find((item)=>item.id === guideId);
|
|
@@ -521,6 +540,12 @@ function getAgentConnectInstructions(id, locale, apiKey, baseUrl, guideId) {
|
|
|
521
540
|
}
|
|
522
541
|
if (!/\{\{OPENVIKING_API_KEY/.test(template)) template += '\n\nBase URL: {{OPENVIKING_BASE_URL}}\n\nAPI Key:\n\n{{OPENVIKING_API_KEY_BLOCK}}';
|
|
523
542
|
const pathBaseUrl = baseUrl.replace(/\/+$/, '');
|
|
543
|
+
let keyToken = 'OV_API_KEY_TOKEN';
|
|
544
|
+
while([
|
|
545
|
+
template,
|
|
546
|
+
baseUrl,
|
|
547
|
+
apiKey
|
|
548
|
+
].some((value)=>value.includes(keyToken)))keyToken += '_';
|
|
524
549
|
function hydrate(key) {
|
|
525
550
|
return template.replace(/\{\{OPENVIKING_BASE_URL\}\}|\{\{OPENVIKING_API_KEY_BLOCK\}\}|\{\{OPENVIKING_API_KEY\}\}|<API_KEY>|https:\/\/api\.vikingdb\.cn-beijing\.volces\.com\/openviking/g, (token, offset)=>{
|
|
526
551
|
if ('{{OPENVIKING_API_KEY_BLOCK}}' === token) {
|
|
@@ -534,7 +559,9 @@ function getAgentConnectInstructions(id, locale, apiKey, baseUrl, guideId) {
|
|
|
534
559
|
return {
|
|
535
560
|
fixed: false,
|
|
536
561
|
display: hydrate('••••••••'),
|
|
537
|
-
copy: hydrate(apiKey)
|
|
562
|
+
copy: hydrate(apiKey),
|
|
563
|
+
markdown: hydrate(keyToken),
|
|
564
|
+
keyToken
|
|
538
565
|
};
|
|
539
566
|
}
|
|
540
567
|
const SvgCopy = (props)=>/*#__PURE__*/ jsxs("svg", {
|
|
@@ -550,7 +577,7 @@ const SvgCopy = (props)=>/*#__PURE__*/ jsxs("svg", {
|
|
|
550
577
|
children: /*#__PURE__*/ jsx("g", {
|
|
551
578
|
clipPath: "url(#copy_svg__b)",
|
|
552
579
|
children: /*#__PURE__*/ jsx("path", {
|
|
553
|
-
fill: "
|
|
580
|
+
fill: "currentColor",
|
|
554
581
|
fillRule: "evenodd",
|
|
555
582
|
d: "M10.667 4c.368 0 .666.299.666.667v9.407c0 .328-.278.593-.622.593H2.622c-.343 0-.622-.265-.622-.593V4.593C2 4.265 2.279 4 2.622 4zM10 5.334H3.333v8H10zm3.333-4c.368 0 .667.298.667.666v8.334c0 .184-.15.333-.333.333H13a.333.333 0 0 1-.333-.333V2.667H6.333A.333.333 0 0 1 6 2.334v-.667c0-.184.15-.334.333-.334z",
|
|
556
583
|
clipRule: "evenodd"
|
|
@@ -578,102 +605,54 @@ const SvgCopy = (props)=>/*#__PURE__*/ jsxs("svg", {
|
|
|
578
605
|
]
|
|
579
606
|
});
|
|
580
607
|
const copyreact = SvgCopy;
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
}, index);
|
|
596
|
-
return /*#__PURE__*/ jsx(external_react_Fragment, {
|
|
597
|
-
children: part
|
|
598
|
-
}, index);
|
|
599
|
-
});
|
|
600
|
-
}
|
|
601
|
-
function Prose({ text }) {
|
|
602
|
-
const lines = text.split('\n').filter((line)=>!/^\s*!\[/.test(line));
|
|
603
|
-
const blocks = [];
|
|
604
|
-
let current = '';
|
|
605
|
-
for (const line of lines)if (line.trim()) if (/^#{1,6}\s/.test(line)) {
|
|
606
|
-
if (current) blocks.push(current);
|
|
607
|
-
blocks.push(line);
|
|
608
|
-
current = '';
|
|
609
|
-
} else current += `${current ? '\n' : ''}${line}`;
|
|
610
|
-
else {
|
|
611
|
-
if (current) blocks.push(current);
|
|
612
|
-
current = '';
|
|
613
|
-
}
|
|
614
|
-
if (current) blocks.push(current);
|
|
615
|
-
return blocks.map((block, index)=>{
|
|
616
|
-
if (/^#{1,6}\s/.test(block)) return /*#__PURE__*/ jsx("h5", {
|
|
617
|
-
children: /*#__PURE__*/ jsx(Inline, {
|
|
618
|
-
text: block.replace(/^#{1,6}\s/, '')
|
|
619
|
-
})
|
|
620
|
-
}, index);
|
|
621
|
-
if (block.startsWith('|')) {
|
|
622
|
-
const rows = block.split('\n').filter((row)=>!/^\|[\s:|-]+\|$/.test(row));
|
|
623
|
-
return /*#__PURE__*/ jsx("table", {
|
|
624
|
-
children: /*#__PURE__*/ jsx("tbody", {
|
|
625
|
-
children: rows.map((row, rowIndex)=>/*#__PURE__*/ jsx("tr", {
|
|
626
|
-
children: row.split('|').slice(1, -1).map((cell, column)=>0 === rowIndex ? /*#__PURE__*/ jsx("th", {
|
|
627
|
-
children: /*#__PURE__*/ jsx(Inline, {
|
|
628
|
-
text: cell.trim()
|
|
629
|
-
})
|
|
630
|
-
}, column) : /*#__PURE__*/ jsx("td", {
|
|
631
|
-
children: /*#__PURE__*/ jsx(Inline, {
|
|
632
|
-
text: cell.trim()
|
|
633
|
-
})
|
|
634
|
-
}, column))
|
|
635
|
-
}, rowIndex))
|
|
636
|
-
})
|
|
637
|
-
}, index);
|
|
638
|
-
}
|
|
639
|
-
return /*#__PURE__*/ jsx("p", {
|
|
640
|
-
children: /*#__PURE__*/ jsx(Inline, {
|
|
641
|
-
text: block
|
|
608
|
+
const SvgEye = (props)=>/*#__PURE__*/ jsxs("svg", {
|
|
609
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
610
|
+
fill: "none",
|
|
611
|
+
stroke: "currentColor",
|
|
612
|
+
strokeWidth: 4,
|
|
613
|
+
viewBox: "0 0 48 48",
|
|
614
|
+
...props,
|
|
615
|
+
children: [
|
|
616
|
+
/*#__PURE__*/ jsx("path", {
|
|
617
|
+
d: "M24 37q9.94 0 18-13-8.06-13-18-13T6 24q8.06 13 18 13Z",
|
|
618
|
+
clipRule: "evenodd"
|
|
619
|
+
}),
|
|
620
|
+
/*#__PURE__*/ jsx("path", {
|
|
621
|
+
d: "M29 24a5 5 0 1 1-10 0 5 5 0 0 1 10 0Z"
|
|
642
622
|
})
|
|
643
|
-
|
|
623
|
+
]
|
|
644
624
|
});
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
625
|
+
const eyereact = SvgEye;
|
|
626
|
+
const SvgEyeInvisible = (props)=>/*#__PURE__*/ jsxs("svg", {
|
|
627
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
628
|
+
fill: "none",
|
|
629
|
+
stroke: "currentColor",
|
|
630
|
+
strokeWidth: 4,
|
|
631
|
+
viewBox: "0 0 48 48",
|
|
632
|
+
...props,
|
|
633
|
+
children: [
|
|
634
|
+
/*#__PURE__*/ jsx("path", {
|
|
635
|
+
d: "M14 14.5c-2.69 2-5.415 5.33-8 9.5q8.06 13 18 13 4.987 0 9.5-3.271M17.463 12.5C19 11 21.75 11 24 11q9.94 0 18 13-2.649 4.272-5.5 7.14"
|
|
636
|
+
}),
|
|
637
|
+
/*#__PURE__*/ jsx("path", {
|
|
638
|
+
d: "M29 24a5 5 0 1 1-10 0 5 5 0 0 1 10 0ZM6.852 7.103l34.294 34.294"
|
|
639
|
+
})
|
|
640
|
+
]
|
|
659
641
|
});
|
|
660
|
-
|
|
661
|
-
function
|
|
642
|
+
const eye_invisiblereact = SvgEyeInvisible;
|
|
643
|
+
function useAgentConnectCopy(text, onCopy) {
|
|
662
644
|
const [status, setStatus] = useState('idle');
|
|
663
645
|
const pending = useRef(false);
|
|
664
646
|
const mounted = useRef(false);
|
|
665
647
|
const setRoot = useCallback((node)=>{
|
|
666
648
|
mounted.current = null !== node;
|
|
667
649
|
}, []);
|
|
668
|
-
|
|
669
|
-
const message = 'copied' === status ? labels.copied : 'failed' === status ? labels.failed : '';
|
|
670
|
-
const copyLabel = instructions.fixed ? labels.copy : labels.copyMarkdown;
|
|
671
|
-
async function handleCopy() {
|
|
650
|
+
async function copy() {
|
|
672
651
|
if (pending.current) return;
|
|
673
652
|
pending.current = true;
|
|
674
653
|
setStatus('pending');
|
|
675
654
|
try {
|
|
676
|
-
await navigator.clipboard.writeText(
|
|
655
|
+
await navigator.clipboard.writeText(text);
|
|
677
656
|
} catch {
|
|
678
657
|
if (mounted.current) setStatus('failed');
|
|
679
658
|
return;
|
|
@@ -682,8 +661,241 @@ function AgentConnectInstructionsView({ instructions, locale, agreementUrl, onCo
|
|
|
682
661
|
}
|
|
683
662
|
if (!mounted.current) return;
|
|
684
663
|
setStatus('copied');
|
|
685
|
-
onCopy?.(
|
|
664
|
+
onCopy?.(text);
|
|
686
665
|
}
|
|
666
|
+
return {
|
|
667
|
+
status,
|
|
668
|
+
setRoot,
|
|
669
|
+
copy
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
function AgentConnectCodeBlock({ display, copyText, language, locale, visibleBlockId, onReveal, onCopy }) {
|
|
673
|
+
const id = useId();
|
|
674
|
+
const revealed = visibleBlockId === id;
|
|
675
|
+
const hasKey = display !== copyText;
|
|
676
|
+
const labels = resolveAgentConnectLabels(locale);
|
|
677
|
+
const { status, setRoot, copy } = useAgentConnectCopy(copyText, onCopy);
|
|
678
|
+
const revealLabel = revealed ? labels.hideApiKey : labels.showApiKey;
|
|
679
|
+
const copyLabel = 'copied' === status ? labels.copied : labels.copyCode;
|
|
680
|
+
const RevealIcon = revealed ? eye_invisiblereact : eyereact;
|
|
681
|
+
const ClipboardIcon = 'copied' === status ? checkreact : copyreact;
|
|
682
|
+
const feedback = 'failed' === status ? labels.failed : 'copied' === status ? labels.copied : '';
|
|
683
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
684
|
+
ref: setRoot,
|
|
685
|
+
className: "ov-agent-connect__code-block",
|
|
686
|
+
children: [
|
|
687
|
+
/*#__PURE__*/ jsxs("div", {
|
|
688
|
+
className: "ov-agent-connect__code-header",
|
|
689
|
+
children: [
|
|
690
|
+
/*#__PURE__*/ jsx("span", {
|
|
691
|
+
children: language || 'text'
|
|
692
|
+
}),
|
|
693
|
+
/*#__PURE__*/ jsxs("div", {
|
|
694
|
+
className: "ov-agent-connect__code-actions",
|
|
695
|
+
children: [
|
|
696
|
+
hasKey ? /*#__PURE__*/ jsx("button", {
|
|
697
|
+
type: "button",
|
|
698
|
+
"aria-pressed": revealed,
|
|
699
|
+
"aria-label": revealLabel,
|
|
700
|
+
title: revealLabel,
|
|
701
|
+
onClick: ()=>onReveal(revealed ? null : id),
|
|
702
|
+
children: /*#__PURE__*/ jsx(RevealIcon, {
|
|
703
|
+
"aria-hidden": "true"
|
|
704
|
+
})
|
|
705
|
+
}) : null,
|
|
706
|
+
/*#__PURE__*/ jsx("button", {
|
|
707
|
+
type: "button",
|
|
708
|
+
disabled: 'pending' === status,
|
|
709
|
+
"aria-label": copyLabel,
|
|
710
|
+
title: copyLabel,
|
|
711
|
+
onClick: ()=>void copy(),
|
|
712
|
+
children: /*#__PURE__*/ jsx(ClipboardIcon, {
|
|
713
|
+
"aria-hidden": "true"
|
|
714
|
+
})
|
|
715
|
+
})
|
|
716
|
+
]
|
|
717
|
+
})
|
|
718
|
+
]
|
|
719
|
+
}),
|
|
720
|
+
/*#__PURE__*/ jsx("pre", {
|
|
721
|
+
children: /*#__PURE__*/ jsx("code", {
|
|
722
|
+
children: revealed ? copyText : display
|
|
723
|
+
})
|
|
724
|
+
}),
|
|
725
|
+
/*#__PURE__*/ jsx("span", {
|
|
726
|
+
className: 'failed' === status ? 'ov-agent-connect__feedback ov-agent-connect__feedback--error' : 'ov-agent-connect__code-feedback',
|
|
727
|
+
role: "status",
|
|
728
|
+
"aria-live": "polite",
|
|
729
|
+
children: feedback
|
|
730
|
+
})
|
|
731
|
+
]
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
function remarkMaskApiKey({ keyToken }) {
|
|
735
|
+
return (tree)=>{
|
|
736
|
+
function mask(node) {
|
|
737
|
+
if (('text' === node.type || 'inlineCode' === node.type || 'html' === node.type) && node.value) node.value = node.value.split(keyToken).join('••••••••');
|
|
738
|
+
node.children?.forEach(mask);
|
|
739
|
+
}
|
|
740
|
+
mask(tree);
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
const markdownHtmlSchema = {
|
|
744
|
+
attributes: {
|
|
745
|
+
a: [
|
|
746
|
+
'href',
|
|
747
|
+
'title'
|
|
748
|
+
],
|
|
749
|
+
code: [
|
|
750
|
+
[
|
|
751
|
+
'className',
|
|
752
|
+
/^language-[\w-]+$/
|
|
753
|
+
]
|
|
754
|
+
],
|
|
755
|
+
details: [
|
|
756
|
+
'open'
|
|
757
|
+
],
|
|
758
|
+
td: [
|
|
759
|
+
'align',
|
|
760
|
+
'colSpan',
|
|
761
|
+
'rowSpan'
|
|
762
|
+
],
|
|
763
|
+
th: [
|
|
764
|
+
'align',
|
|
765
|
+
'colSpan',
|
|
766
|
+
'rowSpan'
|
|
767
|
+
]
|
|
768
|
+
},
|
|
769
|
+
protocols: {
|
|
770
|
+
href: [
|
|
771
|
+
'http',
|
|
772
|
+
'https',
|
|
773
|
+
'mailto'
|
|
774
|
+
]
|
|
775
|
+
},
|
|
776
|
+
tagNames: [
|
|
777
|
+
'a',
|
|
778
|
+
'b',
|
|
779
|
+
'blockquote',
|
|
780
|
+
'br',
|
|
781
|
+
'code',
|
|
782
|
+
'del',
|
|
783
|
+
'details',
|
|
784
|
+
'em',
|
|
785
|
+
'h1',
|
|
786
|
+
'h2',
|
|
787
|
+
'h3',
|
|
788
|
+
'h4',
|
|
789
|
+
'h5',
|
|
790
|
+
'h6',
|
|
791
|
+
'hr',
|
|
792
|
+
'li',
|
|
793
|
+
'ol',
|
|
794
|
+
'p',
|
|
795
|
+
'pre',
|
|
796
|
+
's',
|
|
797
|
+
'strong',
|
|
798
|
+
'summary',
|
|
799
|
+
'table',
|
|
800
|
+
'tbody',
|
|
801
|
+
'td',
|
|
802
|
+
'th',
|
|
803
|
+
'thead',
|
|
804
|
+
'tr',
|
|
805
|
+
'ul'
|
|
806
|
+
]
|
|
807
|
+
};
|
|
808
|
+
const components = {
|
|
809
|
+
h1: ({ children })=>/*#__PURE__*/ jsx("h5", {
|
|
810
|
+
children: children
|
|
811
|
+
}),
|
|
812
|
+
h2: ({ children })=>/*#__PURE__*/ jsx("h5", {
|
|
813
|
+
children: children
|
|
814
|
+
}),
|
|
815
|
+
h3: ({ children })=>/*#__PURE__*/ jsx("h5", {
|
|
816
|
+
children: children
|
|
817
|
+
}),
|
|
818
|
+
h4: ({ children })=>/*#__PURE__*/ jsx("h5", {
|
|
819
|
+
children: children
|
|
820
|
+
}),
|
|
821
|
+
h5: ({ children })=>/*#__PURE__*/ jsx("h5", {
|
|
822
|
+
children: children
|
|
823
|
+
}),
|
|
824
|
+
h6: ({ children })=>/*#__PURE__*/ jsx("h5", {
|
|
825
|
+
children: children
|
|
826
|
+
}),
|
|
827
|
+
a: ({ children, href, title })=>/*#__PURE__*/ jsx("a", {
|
|
828
|
+
href: href,
|
|
829
|
+
title: title,
|
|
830
|
+
target: "_blank",
|
|
831
|
+
rel: "noopener noreferrer",
|
|
832
|
+
children: children
|
|
833
|
+
}),
|
|
834
|
+
pre: MarkdownCodeBlock
|
|
835
|
+
};
|
|
836
|
+
const codeBlockContext = /*#__PURE__*/ createContext(null);
|
|
837
|
+
function MarkdownCodeBlock({ children }) {
|
|
838
|
+
const context = useContext(codeBlockContext);
|
|
839
|
+
const child = Children.toArray(children)[0];
|
|
840
|
+
if (!context || !/*#__PURE__*/ isValidElement(child) || 'string' != typeof child.props.children) return /*#__PURE__*/ jsx("pre", {
|
|
841
|
+
children: children
|
|
842
|
+
});
|
|
843
|
+
const { keyToken, apiKey, ...controls } = context;
|
|
844
|
+
const code = child.props.children.replace(/\n$/, '');
|
|
845
|
+
return /*#__PURE__*/ jsx(AgentConnectCodeBlock, {
|
|
846
|
+
...controls,
|
|
847
|
+
language: child.props.className?.replace(/^language-/, ''),
|
|
848
|
+
display: code.split(keyToken).join('••••••••'),
|
|
849
|
+
copyText: code.split(keyToken).join(apiKey)
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
function AgentConnectMarkdown({ text, ...context }) {
|
|
853
|
+
return /*#__PURE__*/ jsx("div", {
|
|
854
|
+
className: "ov-agent-connect__markdown",
|
|
855
|
+
children: /*#__PURE__*/ jsx(codeBlockContext.Provider, {
|
|
856
|
+
value: context,
|
|
857
|
+
children: /*#__PURE__*/ jsx(react_markdown, {
|
|
858
|
+
remarkPlugins: [
|
|
859
|
+
[
|
|
860
|
+
remark_gfm,
|
|
861
|
+
{
|
|
862
|
+
singleTilde: false
|
|
863
|
+
}
|
|
864
|
+
],
|
|
865
|
+
[
|
|
866
|
+
remarkMaskApiKey,
|
|
867
|
+
{
|
|
868
|
+
keyToken: context.keyToken
|
|
869
|
+
}
|
|
870
|
+
]
|
|
871
|
+
],
|
|
872
|
+
rehypePlugins: [
|
|
873
|
+
rehype_raw,
|
|
874
|
+
[
|
|
875
|
+
rehype_sanitize,
|
|
876
|
+
markdownHtmlSchema
|
|
877
|
+
]
|
|
878
|
+
],
|
|
879
|
+
components: components,
|
|
880
|
+
children: text
|
|
881
|
+
})
|
|
882
|
+
})
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
function AgentConnectInstructionsView({ instructions, apiKey, locale, agreementUrl, onCopy }) {
|
|
886
|
+
const [visibleBlockId, onReveal] = useState(null);
|
|
887
|
+
const { status, setRoot, copy } = useAgentConnectCopy(instructions.copy, onCopy);
|
|
888
|
+
const controls = {
|
|
889
|
+
locale,
|
|
890
|
+
visibleBlockId,
|
|
891
|
+
onReveal,
|
|
892
|
+
onCopy
|
|
893
|
+
};
|
|
894
|
+
const command = instructions.command;
|
|
895
|
+
const commandOffset = command ? instructions.display.indexOf(command.display) : -1;
|
|
896
|
+
const labels = resolveAgentConnectLabels(locale);
|
|
897
|
+
const message = 'copied' === status ? labels.copied : 'failed' === status ? labels.failed : '';
|
|
898
|
+
const copyLabel = instructions.fixed ? labels.copy : labels.copyMarkdown;
|
|
687
899
|
return /*#__PURE__*/ jsxs("div", {
|
|
688
900
|
ref: setRoot,
|
|
689
901
|
className: "ov-agent-connect__instructions",
|
|
@@ -699,7 +911,7 @@ function AgentConnectInstructionsView({ instructions, locale, agreementUrl, onCo
|
|
|
699
911
|
className: "ov-agent-connect__copy",
|
|
700
912
|
type: "button",
|
|
701
913
|
disabled: 'pending' === status,
|
|
702
|
-
onClick: ()=>void
|
|
914
|
+
onClick: ()=>void copy(),
|
|
703
915
|
children: [
|
|
704
916
|
/*#__PURE__*/ jsx(copyreact, {
|
|
705
917
|
"aria-hidden": "true"
|
|
@@ -711,8 +923,22 @@ function AgentConnectInstructionsView({ instructions, locale, agreementUrl, onCo
|
|
|
711
923
|
}),
|
|
712
924
|
/*#__PURE__*/ jsx("div", {
|
|
713
925
|
className: "ov-agent-connect__body",
|
|
714
|
-
children:
|
|
715
|
-
|
|
926
|
+
children: command ? /*#__PURE__*/ jsxs(Fragment, {
|
|
927
|
+
children: [
|
|
928
|
+
instructions.display.slice(0, commandOffset),
|
|
929
|
+
/*#__PURE__*/ jsx(AgentConnectCodeBlock, {
|
|
930
|
+
...controls,
|
|
931
|
+
language: "bash",
|
|
932
|
+
display: command.display,
|
|
933
|
+
copyText: command.copy
|
|
934
|
+
}),
|
|
935
|
+
instructions.display.slice(commandOffset + command.display.length)
|
|
936
|
+
]
|
|
937
|
+
}) : /*#__PURE__*/ jsx(AgentConnectMarkdown, {
|
|
938
|
+
...controls,
|
|
939
|
+
text: instructions.markdown,
|
|
940
|
+
keyToken: instructions.keyToken,
|
|
941
|
+
apiKey: apiKey
|
|
716
942
|
})
|
|
717
943
|
}),
|
|
718
944
|
/*#__PURE__*/ jsx("span", {
|
|
@@ -809,6 +1035,7 @@ function AgentConnectDetailView({ selected, apiKey, locale, baseUrl, agreementUr
|
|
|
809
1035
|
}) : null,
|
|
810
1036
|
/*#__PURE__*/ jsx(AgentConnectInstructionsView, {
|
|
811
1037
|
instructions: instructions,
|
|
1038
|
+
apiKey: apiKey,
|
|
812
1039
|
locale: locale,
|
|
813
1040
|
agreementUrl: agreementUrl,
|
|
814
1041
|
onCopy: onCopy
|
|
@@ -1466,7 +1693,7 @@ const custom = [
|
|
|
1466
1693
|
Icon: sdkreact
|
|
1467
1694
|
}
|
|
1468
1695
|
];
|
|
1469
|
-
function getAgentConnectDesign(locale) {
|
|
1696
|
+
function getAgentConnectDesign(locale, showOverseasTag = false) {
|
|
1470
1697
|
const content = getAgentConnectContent(locale);
|
|
1471
1698
|
const labels = resolveAgentConnectLabels(locale);
|
|
1472
1699
|
return {
|
|
@@ -1485,7 +1712,7 @@ function getAgentConnectDesign(locale) {
|
|
|
1485
1712
|
...content[item.id],
|
|
1486
1713
|
tags: [
|
|
1487
1714
|
...content[item.id].tags,
|
|
1488
|
-
...overseasAgents.has(item.id) ? [
|
|
1715
|
+
...showOverseasTag && overseasAgents.has(item.id) ? [
|
|
1489
1716
|
labels.overseas
|
|
1490
1717
|
] : []
|
|
1491
1718
|
]
|
|
@@ -1496,7 +1723,8 @@ function getAgentConnectDesign(locale) {
|
|
|
1496
1723
|
}))
|
|
1497
1724
|
};
|
|
1498
1725
|
}
|
|
1499
|
-
function AgentConnect({ apiKey, locale, baseUrl = DEFAULT_BASE_URL, agreementUrl, activeTabId: controlledTabId, selectedId: controlledSelectedId, onTabChange, onSelect, onCopy, className, ...rest }) {
|
|
1726
|
+
function AgentConnect({ apiKey, locale: localeProp, baseUrl = DEFAULT_BASE_URL, agreementUrl, showOverseasTag = false, activeTabId: controlledTabId, selectedId: controlledSelectedId, onTabChange, onSelect, onCopy, className, ...rest }) {
|
|
1727
|
+
const locale = useLocale(localeProp);
|
|
1500
1728
|
const id = useId();
|
|
1501
1729
|
const [localTabId, setLocalTabId] = useState('mainstream');
|
|
1502
1730
|
const [localSelection, setLocalSelection] = useState({
|
|
@@ -1505,7 +1733,7 @@ function AgentConnect({ apiKey, locale, baseUrl = DEFAULT_BASE_URL, agreementUrl
|
|
|
1505
1733
|
});
|
|
1506
1734
|
const activeTabId = controlledTabId ?? localTabId;
|
|
1507
1735
|
const selectedId = controlledSelectedId ?? localSelection[activeTabId];
|
|
1508
|
-
const design = getAgentConnectDesign(locale);
|
|
1736
|
+
const design = getAgentConnectDesign(locale, showOverseasTag);
|
|
1509
1737
|
const labels = resolveAgentConnectLabels(locale);
|
|
1510
1738
|
const tabs = design.tabs;
|
|
1511
1739
|
const items = design[activeTabId];
|
|
@@ -6,6 +6,7 @@ import { VikingBotIcon } from "./lg~0.js";
|
|
|
6
6
|
import { resolveVikingBotLabels, BotPopover, useQuickInput, QuickInputs } from "./c~0.js";
|
|
7
7
|
import { usePortalTheme } from "./9~0.js";
|
|
8
8
|
import { FileTree as file_tree_FileTree } from "./n~0.js";
|
|
9
|
+
import { useLocale } from "./28~0.js";
|
|
9
10
|
const SvgSend = (props)=>/*#__PURE__*/ jsx("svg", {
|
|
10
11
|
xmlns: "http://www.w3.org/2000/svg",
|
|
11
12
|
fill: "none",
|
|
@@ -374,7 +375,8 @@ function composerCaret(sender) {
|
|
|
374
375
|
const { doc, selection } = editor.state;
|
|
375
376
|
return doc.textBetween(0, selection.from, '\n', '\n').length;
|
|
376
377
|
}
|
|
377
|
-
const viking_bot_composer_VikingBotComposerView = /*#__PURE__*/ forwardRef(function({ value, locale, className, attachments = [], disabled, disabledReason, isSending, variant = 'default', accept, maxAttachments = 10, actions, quickInputs, onQuickInputSelect, references, onValueChange, onFilesAdded, onAttachmentRemove, onSend, onCancel, labels: overrides }, ref) {
|
|
378
|
+
const viking_bot_composer_VikingBotComposerView = /*#__PURE__*/ forwardRef(function({ value, locale: localeProp, className, attachments = [], disabled, disabledReason, isSending, variant = 'default', accept, maxAttachments = 10, actions, quickInputs, onQuickInputSelect, references, onValueChange, onFilesAdded, onAttachmentRemove, onSend, onCancel, labels: overrides }, ref) {
|
|
379
|
+
const locale = useLocale(localeProp);
|
|
378
380
|
const labels = resolveVikingBotLabels(locale, overrides);
|
|
379
381
|
const senderRef = useRef(null);
|
|
380
382
|
const writing = useRef(false);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { AskHuman } from "@ark-design/ui/ask-human";
|
|
3
3
|
import { useState } from "react";
|
|
4
|
+
import { useLocale } from "./28~0.js";
|
|
4
5
|
import { resolveInteractionLabels } from "./c7~0.js";
|
|
5
6
|
const toFields = (request, other)=>{
|
|
6
7
|
if ('choice' === request.kind) return [
|
|
@@ -193,7 +194,8 @@ const TextInput = ({ request, label, disabled, onChange })=>/*#__PURE__*/ jsxs(F
|
|
|
193
194
|
})
|
|
194
195
|
]
|
|
195
196
|
});
|
|
196
|
-
function VikingBotInteractionView({ request, className, requestKey, index = 0, total = 1, disabled, submitting, error, onSubmit, onCancel, locale, labels: overrides }) {
|
|
197
|
+
function VikingBotInteractionView({ request, className, requestKey, index = 0, total = 1, disabled, submitting, error, onSubmit, onCancel, locale: localeProp, labels: overrides }) {
|
|
198
|
+
const locale = useLocale(localeProp);
|
|
197
199
|
const labels = resolveInteractionLabels(locale, overrides);
|
|
198
200
|
const blocked = Boolean(disabled || submitting);
|
|
199
201
|
const formKey = requestKey ?? `${request.kind}:${index}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openviking/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -122,6 +122,8 @@
|
|
|
122
122
|
"react-focus-lock": "^2.13.7",
|
|
123
123
|
"react-markdown": "^10.1.0",
|
|
124
124
|
"react-transition-group": "^4.4.5",
|
|
125
|
+
"rehype-raw": "^7.0.0",
|
|
126
|
+
"rehype-sanitize": "^6.0.0",
|
|
125
127
|
"remark-gfm": "^4.0.1"
|
|
126
128
|
}
|
|
127
129
|
}
|