@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/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
English / [中文](README_CN.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Public UI components, composed modules and standalone Hooks accept optional `locale: 'zh-CN' | 'en-US'`. Props override the nearest module or Provider; without a configured language, they use `en-US`. Existing `labels` override individual fields; omitted fields follow the current locale and update when it changes. Hosts still provide business content, slots and callback messages.
|
|
6
6
|
|
|
7
7
|
React foundations for OpenViking AI application interfaces: build tooling, documentation, layered directories, and scoped styles. FileTree, Tui and FilePreview provide working views, alongside five file-type icons. FileBrowser supports early layout integration; Console provides a native command panel; ScopeCascade provides a working cascade Hook and composition.
|
|
8
8
|
|
|
@@ -94,3 +94,5 @@ Pass three stable API adapter functions to `useScopeCascade({ loadLibraries, loa
|
|
|
94
94
|
Built-in translations live alongside each component or module in `locales/en-US.ts` and `locales/zh-CN.ts`. The internal `src/shared/locale.ts` contains only shared language types and resolution/override rules, with no business messages or public entry. Modules own workflow copy and reuse the defaults owned by their child components.
|
|
95
95
|
|
|
96
96
|
Dynamic messages use typed formatter functions; dates and numbers use `Intl`. `npm test` checks matching keys, string placeholders and formatter arity across languages, while type checking validates parameter types. Undefined `labels` entries inherit the selected language; empty strings remain explicit overrides.
|
|
97
|
+
|
|
98
|
+
Set `locale` on `OpenVikingProvider` for a subtree. Optional module and component Props override the nearest scope, then fall back to `en-US`. Standalone Hooks also inherit the Provider. The private `src/shared/locale-context.tsx` is shared across public entries and remains separate from request-client configuration, so language changes preserve requests and state.
|
package/dist/28~0.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
const LocaleContext = /*#__PURE__*/ createContext('en-US');
|
|
4
|
+
function useLocale(locale) {
|
|
5
|
+
const inherited = useContext(LocaleContext);
|
|
6
|
+
return locale ?? inherited;
|
|
7
|
+
}
|
|
8
|
+
function LocaleProvider({ locale, children }) {
|
|
9
|
+
const value = useLocale(locale);
|
|
10
|
+
return /*#__PURE__*/ jsx(LocaleContext.Provider, {
|
|
11
|
+
value: value,
|
|
12
|
+
children: children
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
export { LocaleProvider, useLocale };
|
package/dist/2~0.js
CHANGED
|
@@ -7,6 +7,7 @@ import { __webpack_require__ } from "./rslib-runtime~0.js";
|
|
|
7
7
|
import { resolveLocale } from "./nx~0.js";
|
|
8
8
|
import { removereact } from "./4~0.js";
|
|
9
9
|
import { usePortalTheme } from "./9~0.js";
|
|
10
|
+
import { useLocale } from "./28~0.js";
|
|
10
11
|
import { AgentConnect } from "./u~0.js";
|
|
11
12
|
import * as __rspack_external_react from "react";
|
|
12
13
|
__webpack_require__.add({
|
|
@@ -2274,7 +2275,8 @@ function ImportResourcesIcon() {
|
|
|
2274
2275
|
})
|
|
2275
2276
|
});
|
|
2276
2277
|
}
|
|
2277
|
-
function FileBrowserEntries({ locale
|
|
2278
|
+
function FileBrowserEntries({ locale: localeProp, agentConnect, onConnectAgent, onImportResources, renderImportResources, labels, className, ...rest }) {
|
|
2279
|
+
const locale = useLocale(localeProp);
|
|
2278
2280
|
const triggerRef = useRef(null);
|
|
2279
2281
|
const drawerId = useId();
|
|
2280
2282
|
const [drawerOpen, setDrawerOpen] = useState(false);
|
|
@@ -2344,10 +2346,11 @@ function FileBrowserEntries({ locale = 'en-US', agentConnect, onConnectAgent, on
|
|
|
2344
2346
|
closeLabel: text.close,
|
|
2345
2347
|
triggerRef: triggerRef,
|
|
2346
2348
|
className: "ov-file-browser-entries__drawer",
|
|
2347
|
-
lang: agentConnect.locale,
|
|
2349
|
+
lang: agentConnect.locale ?? locale,
|
|
2348
2350
|
onClose: ()=>setDrawerOpen(false),
|
|
2349
2351
|
children: /*#__PURE__*/ jsx(AgentConnect, {
|
|
2350
|
-
...agentConnect
|
|
2352
|
+
...agentConnect,
|
|
2353
|
+
locale: agentConnect.locale ?? locale
|
|
2351
2354
|
})
|
|
2352
2355
|
}) : null,
|
|
2353
2356
|
showImport ? /*#__PURE__*/ jsx("span", {
|
package/dist/3c~0.js
CHANGED
|
@@ -6,6 +6,7 @@ import { ArrowRightIcon } from "./k~0.js";
|
|
|
6
6
|
import { resolveLocale } from "./nx~0.js";
|
|
7
7
|
import { checkreact } from "./0~0.js";
|
|
8
8
|
import { Tooltip } from "./r~0.js";
|
|
9
|
+
import { useLocale } from "./28~0.js";
|
|
9
10
|
function getTuiCommandInputText(command) {
|
|
10
11
|
return command.inputText?.trim() || command.name;
|
|
11
12
|
}
|
|
@@ -2073,7 +2074,8 @@ function useTuiCompletion(value, enabled, commands, groups = [], paletteScope =
|
|
|
2073
2074
|
showSuggestions: enabled && (query.automatic || null !== query.scope && paletteScope === query.scope)
|
|
2074
2075
|
};
|
|
2075
2076
|
}
|
|
2076
|
-
function Tui({ records, value, disabled = false, emptyState, quickCommands, locale
|
|
2077
|
+
function Tui({ records, value, disabled = false, emptyState, quickCommands, locale: localeProp, commands = [], commandGroups = [], onValueChange, onSubmit, onOpenUri, onCopy, labels, className, ...rest }) {
|
|
2078
|
+
const locale = useLocale(localeProp);
|
|
2077
2079
|
const text = resolveTuiLabels(labels, locale);
|
|
2078
2080
|
const bodyRef = useRef(null);
|
|
2079
2081
|
const followOutput = useRef(true);
|
package/dist/3~0.js
CHANGED
|
@@ -2,6 +2,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Fragment as external_react_Fragment, Suspense, forwardRef, lazy, useCallback, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { Tooltip } from "./r~0.js";
|
|
4
4
|
import { resolveLocale, mergeLabels } from "./nx~0.js";
|
|
5
|
+
import { useLocale } from "./28~0.js";
|
|
5
6
|
function FilePreviewImageFrame({ children }) {
|
|
6
7
|
const [dimensions, setDimensions] = useState('');
|
|
7
8
|
return /*#__PURE__*/ jsxs("div", {
|
|
@@ -1214,7 +1215,8 @@ function useFilePreviewEditing(activeTabKey) {
|
|
|
1214
1215
|
function isFileTab(tab) {
|
|
1215
1216
|
return 'file' === tab.kind;
|
|
1216
1217
|
}
|
|
1217
|
-
const file_preview_FilePreview = /*#__PURE__*/ forwardRef(function({ tabs, activeKey, defaultActiveKey, locale, labels, onActiveKeyChange, className, ...rest }, ref) {
|
|
1218
|
+
const file_preview_FilePreview = /*#__PURE__*/ forwardRef(function({ tabs, activeKey, defaultActiveKey, locale: localeProp, labels, onActiveKeyChange, className, ...rest }, ref) {
|
|
1219
|
+
const locale = useLocale(localeProp);
|
|
1218
1220
|
const text = resolveFilePreviewLabels(locale, labels);
|
|
1219
1221
|
const [internalKey, setInternalKey] = useState(()=>defaultActiveKey ?? tabs[0].key);
|
|
1220
1222
|
const currentKey = activeKey ?? internalKey;
|
package/dist/ae~0.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { createContext, useContext, useMemo } from "react";
|
|
3
|
+
import { LocaleProvider } from "./28~0.js";
|
|
3
4
|
class OvClientError extends Error {
|
|
4
5
|
code;
|
|
5
6
|
statusCode;
|
|
@@ -439,7 +440,7 @@ function createOvClient(options = {}) {
|
|
|
439
440
|
return client;
|
|
440
441
|
}
|
|
441
442
|
const OvClientContext = /*#__PURE__*/ createContext(null);
|
|
442
|
-
function OpenVikingProvider({ baseURL, apiKey, accountId, userId, resourceId, credentials, signal, fetch, children }) {
|
|
443
|
+
function OpenVikingProvider({ baseURL, apiKey, accountId, userId, resourceId, credentials, signal, fetch, locale, children }) {
|
|
443
444
|
const parent = useContext(OvClientContext);
|
|
444
445
|
const value = useMemo(()=>{
|
|
445
446
|
const base = mergeProviderConfig(parent?.base, {
|
|
@@ -475,7 +476,10 @@ function OpenVikingProvider({ baseURL, apiKey, accountId, userId, resourceId, cr
|
|
|
475
476
|
]);
|
|
476
477
|
return /*#__PURE__*/ jsx(OvClientContext.Provider, {
|
|
477
478
|
value: value,
|
|
478
|
-
children:
|
|
479
|
+
children: /*#__PURE__*/ jsx(LocaleProvider, {
|
|
480
|
+
locale: locale,
|
|
481
|
+
children: children
|
|
482
|
+
})
|
|
479
483
|
});
|
|
480
484
|
}
|
|
481
485
|
function useOvClient() {
|
package/dist/a~0.js
CHANGED
|
@@ -3,6 +3,7 @@ import { useEffect, useId, useMemo, useRef, useState, useSyncExternalStore } fro
|
|
|
3
3
|
import { createPortal } from "react-dom";
|
|
4
4
|
import { resolveLocale, mergeLabels } from "./nx~0.js";
|
|
5
5
|
import { useOvSignal, useOvClient, createOvClient, isOvClientError } from "./ae~0.js";
|
|
6
|
+
import { useLocale, LocaleProvider } from "./28~0.js";
|
|
6
7
|
import { new_sessionreact, historyreact } from "./lg~0.js";
|
|
7
8
|
import { useOverlayPosition } from "./o~0.js";
|
|
8
9
|
import { Tooltip } from "./r~0.js";
|
|
@@ -842,7 +843,8 @@ function createConsoleController(client, options = {}) {
|
|
|
842
843
|
retry: (locale)=>state.failedCommand ? execute(state.failedCommand, locale) : Promise.resolve()
|
|
843
844
|
};
|
|
844
845
|
}
|
|
845
|
-
function useConsole({ mode: controlledMode, defaultMode = 'conversation', locale
|
|
846
|
+
function useConsole({ mode: controlledMode, defaultMode = 'conversation', locale: localeProp, scopeKey, onModeChange, requestOptions = {} } = {}) {
|
|
847
|
+
const locale = useLocale(localeProp);
|
|
846
848
|
const inherited = useOvClient();
|
|
847
849
|
const inheritedSignal = useOvSignal();
|
|
848
850
|
const [fallback] = useState(()=>createOvClient());
|
|
@@ -1204,7 +1206,8 @@ const DEFAULT_QUICK_COMMANDS = [
|
|
|
1204
1206
|
'read',
|
|
1205
1207
|
'status'
|
|
1206
1208
|
];
|
|
1207
|
-
function Console({ mode, defaultMode, locale
|
|
1209
|
+
function Console({ mode, defaultMode, locale: localeProp, quickCommands = DEFAULT_QUICK_COMMANDS, scopeKey, requestOptions, onModeChange, onOpenUri, conversation, slots, labels: overrides, className, ...rest }) {
|
|
1210
|
+
const locale = useLocale(localeProp);
|
|
1208
1211
|
const state = useConsole({
|
|
1209
1212
|
mode,
|
|
1210
1213
|
defaultMode,
|
|
@@ -1215,8 +1218,9 @@ function Console({ mode, defaultMode, locale = 'en-US', quickCommands = DEFAULT_
|
|
|
1215
1218
|
});
|
|
1216
1219
|
const labels = consoleLabels(locale, overrides);
|
|
1217
1220
|
const { sessions, headerActions, ...conversationProps } = conversation ?? {};
|
|
1221
|
+
const botLocale = conversationProps.locale ?? locale;
|
|
1218
1222
|
const botLabels = {
|
|
1219
|
-
...
|
|
1223
|
+
...consoleLabels(botLocale, overrides).vikingBot,
|
|
1220
1224
|
...conversationProps.labels
|
|
1221
1225
|
};
|
|
1222
1226
|
const id = useId();
|
|
@@ -1227,74 +1231,77 @@ function Console({ mode, defaultMode, locale = 'en-US', quickCommands = DEFAULT_
|
|
|
1227
1231
|
preventScroll: true
|
|
1228
1232
|
});
|
|
1229
1233
|
};
|
|
1230
|
-
return /*#__PURE__*/
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
className
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
state.
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1234
|
+
return /*#__PURE__*/ jsx(LocaleProvider, {
|
|
1235
|
+
locale: locale,
|
|
1236
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
1237
|
+
...rest,
|
|
1238
|
+
className: [
|
|
1239
|
+
'ov-console',
|
|
1240
|
+
className
|
|
1241
|
+
].filter(Boolean).join(' '),
|
|
1242
|
+
children: [
|
|
1243
|
+
/*#__PURE__*/ jsx(ConsoleToolbar, {
|
|
1244
|
+
mode: state.mode,
|
|
1245
|
+
panelId: id,
|
|
1246
|
+
locale: locale,
|
|
1247
|
+
labels: labels,
|
|
1248
|
+
records: state.records,
|
|
1249
|
+
isExecuting: state.isExecuting,
|
|
1250
|
+
onModeChange: (next)=>state.setMode(next),
|
|
1251
|
+
onClear: ()=>{
|
|
1252
|
+
state.clear();
|
|
1253
|
+
fillCommand('');
|
|
1254
|
+
},
|
|
1255
|
+
onRecall: fillCommand,
|
|
1256
|
+
conversationActions: /*#__PURE__*/ jsx(VikingBotSessionActions, {
|
|
1257
|
+
sessions: sessions,
|
|
1258
|
+
extra: headerActions,
|
|
1259
|
+
labels: botLabels,
|
|
1260
|
+
locale: botLocale
|
|
1261
|
+
}),
|
|
1262
|
+
children: slots?.toolbar
|
|
1255
1263
|
}),
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
conversationProps.
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
]
|
|
1264
|
+
/*#__PURE__*/ jsx("div", {
|
|
1265
|
+
id: `${id}-conversation`,
|
|
1266
|
+
className: "ov-console__panel",
|
|
1267
|
+
hidden: 'conversation' !== state.mode,
|
|
1268
|
+
children: 'conversation' === state.mode ? /*#__PURE__*/ jsx(VikingBot, {
|
|
1269
|
+
...conversationProps,
|
|
1270
|
+
onOpenUri: conversationProps.onOpenUri ?? onOpenUri,
|
|
1271
|
+
messages: conversationProps.messages ?? [],
|
|
1272
|
+
draft: conversationProps.draft ?? state.conversationDraft,
|
|
1273
|
+
onDraftChange: void 0 === conversationProps.draft ? (value)=>{
|
|
1274
|
+
state.setConversationDraft(value);
|
|
1275
|
+
conversationProps.onDraftChange?.(value);
|
|
1276
|
+
} : conversationProps.onDraftChange,
|
|
1277
|
+
footer: slots?.conversationContext ?? conversationProps.footer,
|
|
1278
|
+
locale: botLocale,
|
|
1279
|
+
labels: botLabels
|
|
1280
|
+
}) : null
|
|
1281
|
+
}),
|
|
1282
|
+
/*#__PURE__*/ jsxs("div", {
|
|
1283
|
+
id: `${id}-command`,
|
|
1284
|
+
ref: commandPanel,
|
|
1285
|
+
className: "ov-console__panel",
|
|
1286
|
+
hidden: 'command' !== state.mode,
|
|
1287
|
+
children: [
|
|
1288
|
+
slots?.commandHelp,
|
|
1289
|
+
/*#__PURE__*/ jsx(Tui, {
|
|
1290
|
+
records: state.records,
|
|
1291
|
+
value: state.command,
|
|
1292
|
+
commands: state.commands,
|
|
1293
|
+
locale: locale,
|
|
1294
|
+
disabled: state.isExecuting,
|
|
1295
|
+
quickCommands: quickCommands,
|
|
1296
|
+
onValueChange: state.setCommand,
|
|
1297
|
+
onSubmit: (command)=>void state.execute(command),
|
|
1298
|
+
onOpenUri: onOpenUri,
|
|
1299
|
+
labels: labels.tui
|
|
1300
|
+
})
|
|
1301
|
+
]
|
|
1302
|
+
})
|
|
1303
|
+
]
|
|
1304
|
+
})
|
|
1298
1305
|
});
|
|
1299
1306
|
}
|
|
1300
1307
|
export { Console, useConsole };
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
+
import type { Locale } from '../shared/locale.js';
|
|
2
3
|
import type { OvClient, OvClientOptions } from './types.js';
|
|
3
4
|
/**
|
|
4
|
-
* {@link OpenVikingProvider}
|
|
5
|
+
* {@link OpenVikingProvider} 的属性。请求字段与 {@link OvClientOptions} 同形,另可设置界面语言:
|
|
5
6
|
* 服务地址、身份与作用域、Cookie 策略,都按字段传值。
|
|
6
|
-
* Props of {@link OpenVikingProvider}
|
|
7
|
-
*
|
|
7
|
+
* Props of {@link OpenVikingProvider}: request fields follow {@link OvClientOptions},
|
|
8
|
+
* with an optional interface locale.
|
|
9
|
+
* The service address, identity and scope, and the cookie policy are all passed
|
|
8
10
|
* as fields.
|
|
9
11
|
*/
|
|
10
12
|
export interface OpenVikingProviderProps extends OvClientOptions {
|
|
13
|
+
/** 界面语言;省略时继承上层,无配置时默认英文。Subtree locale; inherits or defaults to en-US. */
|
|
14
|
+
locale?: Locale;
|
|
11
15
|
children?: ReactNode;
|
|
12
16
|
}
|
|
13
17
|
/**
|
|
14
|
-
*
|
|
18
|
+
* 向子树下发请求配置与默认语言。模块通过内部的 `useOvClient` 取用,宿主只需在应用根部
|
|
15
19
|
* 配置一次服务地址与身份字段,不必自己组装请求头。
|
|
16
20
|
*
|
|
17
21
|
* 开源版传 `apiKey`、`accountId`、`userId`;商业版由浏览器 Cookie 鉴权,只传
|
|
@@ -23,7 +27,7 @@ export interface OpenVikingProviderProps extends OvClientOptions {
|
|
|
23
27
|
* 不传 `baseURL` 时按浏览器同源请求。挂载本身不发请求,也不读取浏览器里保存
|
|
24
28
|
* 的凭证。
|
|
25
29
|
*
|
|
26
|
-
* Provides request configuration to a subtree. Modules read it through the
|
|
30
|
+
* Provides request configuration and a default language to a subtree. Modules read it through the
|
|
27
31
|
* internal `useOvClient`, so a host configures the service address and identity
|
|
28
32
|
* fields once at the application root and never assembles headers itself.
|
|
29
33
|
*
|
|
@@ -40,7 +44,7 @@ export interface OpenVikingProviderProps extends OvClientOptions {
|
|
|
40
44
|
* Without `baseURL` it targets the browser's own origin. Mounting it sends no
|
|
41
45
|
* request and reads no credential stored in the browser.
|
|
42
46
|
*/
|
|
43
|
-
export declare function OpenVikingProvider({ baseURL, apiKey, accountId, userId, resourceId, credentials, signal, fetch, children, }: OpenVikingProviderProps): import("react").JSX.Element;
|
|
47
|
+
export declare function OpenVikingProvider({ baseURL, apiKey, accountId, userId, resourceId, credentials, signal, fetch, locale, children, }: OpenVikingProviderProps): import("react").JSX.Element;
|
|
44
48
|
/**
|
|
45
49
|
* 读取最近的 Provider 提供的客户端。仅供模块内部使用,不从包入口导出:
|
|
46
50
|
* 调用方不需要知道该发什么请求,也就不会直接用它。
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AgentConnectLocale } from './types.js';
|
|
2
|
+
export interface CodeBlockControls {
|
|
3
|
+
locale: AgentConnectLocale;
|
|
4
|
+
visibleBlockId: string | null;
|
|
5
|
+
onReveal: (id: string | null) => void;
|
|
6
|
+
onCopy?: (text: string) => void;
|
|
7
|
+
}
|
|
8
|
+
interface CodeBlockProps extends CodeBlockControls {
|
|
9
|
+
display: string;
|
|
10
|
+
copyText: string;
|
|
11
|
+
language?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function AgentConnectCodeBlock({ display, copyText, language, locale, visibleBlockId, onReveal, onCopy, }: CodeBlockProps): import("react").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -7,6 +7,9 @@ export declare function resolveAgentConnectLabels(locale: AgentConnectLocale): {
|
|
|
7
7
|
instructions: string;
|
|
8
8
|
copy: string;
|
|
9
9
|
copyMarkdown: string;
|
|
10
|
+
copyCode: string;
|
|
11
|
+
showApiKey: string;
|
|
12
|
+
hideApiKey: string;
|
|
10
13
|
copied: string;
|
|
11
14
|
failed: string;
|
|
12
15
|
notice: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentConnectLocale } from './types.js';
|
|
2
|
-
export declare function getAgentConnectDesign(locale: AgentConnectLocale): {
|
|
2
|
+
export declare function getAgentConnectDesign(locale: AgentConnectLocale, showOverseasTag?: boolean): {
|
|
3
3
|
tabs: readonly [{
|
|
4
4
|
readonly id: 'mainstream';
|
|
5
5
|
readonly label: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { AgentConnectLocale } from './types.js';
|
|
2
2
|
export declare const INSTALLER_HARNESSES: Partial<Record<string, string>>;
|
|
3
|
+
export declare function getInstallerCommand(harness: string, locale: AgentConnectLocale, apiKey: string, baseUrl: string): string;
|
|
3
4
|
export declare function getInstallerInstructions(name: string, harness: string, locale: AgentConnectLocale, apiKey: string, baseUrl: string): string;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import type { AgentConnectLocale } from './types.js';
|
|
2
|
+
import type { getAgentConnectInstructions } from './agent-connect-instructions.js';
|
|
2
3
|
interface InstructionsViewProps {
|
|
3
|
-
instructions:
|
|
4
|
-
|
|
5
|
-
display: string;
|
|
6
|
-
copy: string;
|
|
7
|
-
};
|
|
4
|
+
instructions: ReturnType<typeof getAgentConnectInstructions>;
|
|
5
|
+
apiKey: string;
|
|
8
6
|
locale: AgentConnectLocale;
|
|
9
7
|
agreementUrl?: string;
|
|
10
8
|
onCopy?: (text: string) => void;
|
|
11
9
|
}
|
|
12
10
|
/** 由父视图的 key 隔离指南及凭据的复制生命周期。 */
|
|
13
|
-
export declare function AgentConnectInstructionsView({ instructions, locale, agreementUrl, onCopy, }: InstructionsViewProps): import("react").JSX.Element;
|
|
11
|
+
export declare function AgentConnectInstructionsView({ instructions, apiKey, locale, agreementUrl, onCopy, }: InstructionsViewProps): import("react").JSX.Element;
|
|
14
12
|
export {};
|
|
@@ -277,4 +277,17 @@ export declare function getAgentConnectInstructions(id: keyof typeof contentZh,
|
|
|
277
277
|
fixed: boolean;
|
|
278
278
|
display: string;
|
|
279
279
|
copy: string;
|
|
280
|
+
command: {
|
|
281
|
+
display: string;
|
|
282
|
+
copy: string;
|
|
283
|
+
};
|
|
284
|
+
markdown?: undefined;
|
|
285
|
+
keyToken?: undefined;
|
|
286
|
+
} | {
|
|
287
|
+
command?: undefined;
|
|
288
|
+
fixed: boolean;
|
|
289
|
+
display: string;
|
|
290
|
+
copy: string;
|
|
291
|
+
markdown: string;
|
|
292
|
+
keyToken: string;
|
|
280
293
|
};
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { type CodeBlockControls } from './agent-connect-code-block.js';
|
|
2
|
+
/** 先解析原始 HTML,再清理不允许的标签、属性与协议。 */
|
|
3
|
+
interface MarkdownProps extends CodeBlockControls {
|
|
2
4
|
text: string;
|
|
3
|
-
|
|
5
|
+
keyToken: string;
|
|
6
|
+
apiKey: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function AgentConnectMarkdown({ text, ...context }: MarkdownProps): import("react").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { AgentConnectProps } from './types.js';
|
|
2
2
|
export type { AgentConnectItem, AgentConnectProps, AgentConnectLocale, AgentConnectTabId, } from './types.js';
|
|
3
3
|
/** 按设计稿固定文案与图标;选择与复制保持实例内交互。 */
|
|
4
|
-
export declare function AgentConnect({ apiKey, locale, baseUrl, agreementUrl, activeTabId: controlledTabId, selectedId: controlledSelectedId, onTabChange, onSelect, onCopy, className, ...rest }: AgentConnectProps): import("react").JSX.Element;
|
|
4
|
+
export declare function AgentConnect({ apiKey, locale: localeProp, baseUrl, agreementUrl, showOverseasTag, activeTabId: controlledTabId, selectedId: controlledSelectedId, onTabChange, onSelect, onCopy, className, ...rest }: AgentConnectProps): import("react").JSX.Element;
|
|
@@ -91,6 +91,93 @@
|
|
|
91
91
|
--ov-ui-connect-notice-default: var(--ov-ui-text-2-default);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
.ov-agent-connect__code-block {
|
|
95
|
+
border: 1px solid var(--ov-ui-agent-connect-border);
|
|
96
|
+
background: var(--ov-ui-agent-connect-bg);
|
|
97
|
+
white-space: normal;
|
|
98
|
+
border-radius: 8px;
|
|
99
|
+
margin-bottom: 12px;
|
|
100
|
+
overflow: hidden;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.ov-agent-connect__code-block:last-child {
|
|
104
|
+
margin-bottom: 0;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.ov-agent-connect__code-header {
|
|
108
|
+
border-bottom: 1px solid var(--ov-ui-agent-connect-border);
|
|
109
|
+
color: var(--ov-ui-agent-connect-muted);
|
|
110
|
+
justify-content: space-between;
|
|
111
|
+
align-items: center;
|
|
112
|
+
gap: 8px;
|
|
113
|
+
padding: 6px 12px;
|
|
114
|
+
font-size: 12px;
|
|
115
|
+
display: flex;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.ov-agent-connect__code-actions {
|
|
119
|
+
align-items: center;
|
|
120
|
+
gap: 12px;
|
|
121
|
+
display: flex;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.ov-agent-connect__code-actions button {
|
|
125
|
+
width: 24px;
|
|
126
|
+
height: 24px;
|
|
127
|
+
color: var(--ov-ui-agent-connect-secondary);
|
|
128
|
+
background: none;
|
|
129
|
+
border: 0;
|
|
130
|
+
border-radius: 4px;
|
|
131
|
+
justify-content: center;
|
|
132
|
+
align-items: center;
|
|
133
|
+
padding: 4px;
|
|
134
|
+
font-size: 12px;
|
|
135
|
+
display: inline-flex;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.ov-agent-connect__code-actions button:hover {
|
|
139
|
+
color: var(--ov-ui-agent-connect-primary);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.ov-agent-connect__code-actions button:disabled {
|
|
143
|
+
opacity: .6;
|
|
144
|
+
cursor: wait;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.ov-agent-connect__code-actions svg {
|
|
148
|
+
width: 16px;
|
|
149
|
+
height: 16px;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.ov-agent-connect .ov-agent-connect__code-block pre {
|
|
153
|
+
white-space: pre-wrap;
|
|
154
|
+
overflow-wrap: anywhere;
|
|
155
|
+
background: none;
|
|
156
|
+
border-radius: 0;
|
|
157
|
+
margin: 0;
|
|
158
|
+
padding: 12px;
|
|
159
|
+
font-size: 12px;
|
|
160
|
+
line-height: 20px;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.ov-agent-connect__code-block code {
|
|
164
|
+
font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.ov-agent-connect__code-block > .ov-agent-connect__feedback:not(:empty) {
|
|
168
|
+
padding: 0 12px 8px;
|
|
169
|
+
display: block;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.ov-agent-connect__code-feedback {
|
|
173
|
+
clip-path: inset(50%);
|
|
174
|
+
white-space: nowrap;
|
|
175
|
+
width: 1px;
|
|
176
|
+
height: 1px;
|
|
177
|
+
position: absolute;
|
|
178
|
+
overflow: hidden;
|
|
179
|
+
}
|
|
180
|
+
|
|
94
181
|
.ov-agent-connect {
|
|
95
182
|
--ov-ui-agent-connect-text: var(--ov-ui-color-text-1, var(--ov-ui-text-1-default));
|
|
96
183
|
--ov-ui-agent-connect-secondary: var(--ov-ui-color-text-2, var(--ov-ui-text-2-default));
|
|
@@ -421,7 +508,7 @@
|
|
|
421
508
|
white-space: normal;
|
|
422
509
|
}
|
|
423
510
|
|
|
424
|
-
.ov-agent-connect__markdown :where(p, pre, h5, table) {
|
|
511
|
+
.ov-agent-connect__markdown :where(p, pre, h5, table, ul, ol, blockquote, details) {
|
|
425
512
|
margin: 0 0 12px;
|
|
426
513
|
}
|
|
427
514
|
|
|
@@ -433,6 +520,33 @@
|
|
|
433
520
|
white-space: pre-wrap;
|
|
434
521
|
}
|
|
435
522
|
|
|
523
|
+
.ov-agent-connect__markdown :where(ul, ol) {
|
|
524
|
+
padding-left: 24px;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
.ov-agent-connect__markdown ul {
|
|
528
|
+
list-style-type: disc;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
.ov-agent-connect__markdown ol {
|
|
532
|
+
list-style-type: decimal;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
.ov-agent-connect__markdown blockquote {
|
|
536
|
+
border-left: 2px solid var(--ov-ui-agent-connect-border);
|
|
537
|
+
margin-left: 0;
|
|
538
|
+
padding-left: 12px;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
.ov-agent-connect__markdown summary {
|
|
542
|
+
cursor: pointer;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
.ov-agent-connect__markdown summary:focus-visible {
|
|
546
|
+
outline: 2px solid var(--ov-ui-agent-connect-primary);
|
|
547
|
+
outline-offset: 2px;
|
|
548
|
+
}
|
|
549
|
+
|
|
436
550
|
.ov-agent-connect__markdown h5 {
|
|
437
551
|
color: var(--ov-ui-agent-connect-text);
|
|
438
552
|
font-size: 14px;
|
|
@@ -11,12 +11,14 @@ export interface AgentConnectItem {
|
|
|
11
11
|
export interface AgentConnectProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'onSelect' | 'onCopy'> {
|
|
12
12
|
/** 调用方提供的密钥;展示脱敏,复制保留原值。Host API key. */
|
|
13
13
|
apiKey: string;
|
|
14
|
-
/**
|
|
15
|
-
locale
|
|
14
|
+
/** 内置文案语言;省略时继承上层,最终默认英文。Optional locale; inherits or defaults to en-US. */
|
|
15
|
+
locale?: AgentConnectLocale;
|
|
16
16
|
/** 服务地址,默认 OpenViking 云服务。Optional service endpoint. */
|
|
17
17
|
baseUrl?: string;
|
|
18
18
|
/** 宿主提供的用户协议链接;未传时不显示协议引用。Host agreement URL. */
|
|
19
19
|
agreementUrl?: string;
|
|
20
|
+
/** 是否展示境外标签,默认 false。Show Overseas tags; defaults to false. */
|
|
21
|
+
showOverseasTag?: boolean;
|
|
20
22
|
/** 受控页签;默认 mainstream。Controlled tab; defaults to mainstream. */
|
|
21
23
|
activeTabId?: AgentConnectTabId;
|
|
22
24
|
/** 受控 Agent;默认 codex。Controlled agent; defaults to codex. */
|
|
@@ -25,6 +27,6 @@ export interface AgentConnectProps extends Omit<HTMLAttributes<HTMLDivElement>,
|
|
|
25
27
|
onTabChange?: (tabId: AgentConnectTabId) => void;
|
|
26
28
|
/** 返回内置目录条目的 id 和 name。Reports the built-in item id and name. */
|
|
27
29
|
onSelect?: (item: AgentConnectItem) => void;
|
|
28
|
-
/**
|
|
30
|
+
/** 复制成功后返回代码块或完整正文。Reports copied block or full-guide text. */
|
|
29
31
|
onCopy?: (text: string) => void;
|
|
30
32
|
}
|