@xiongtao.xt/tau-plugins 0.50.0 → 0.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +305 -293
- package/LICENSE +21 -21
- package/client/{chunk-JEQ7TXLL.js → chunk-7ZRTRNIF.js} +50 -15
- package/client/{chunk-CQ3UMKDY.js → chunk-M4KRTX2I.js} +2 -12
- package/docs/README.md +44 -44
- package/docs/ai.md +165 -176
- package/docs/backend.md +177 -177
- package/docs/editor-collaboration.md +153 -153
- package/docs/editor.md +703 -701
- package/docs/excerpts.md +145 -145
- package/docs/flashcards.md +146 -144
- package/docs/getting-started.md +78 -78
- package/docs/mcp.md +182 -185
- package/docs/plugin-basics.md +216 -215
- package/docs/portability.md +148 -142
- package/docs/providers/README.md +116 -116
- package/docs/providers/asr.md +135 -135
- package/docs/providers/embeddings.md +77 -77
- package/docs/providers/images.md +81 -81
- package/docs/providers/publish.md +159 -159
- package/docs/providers/sync.md +129 -129
- package/docs/providers/tts.md +62 -62
- package/docs/providers/upload.md +131 -131
- package/docs/providers/video.md +146 -130
- package/docs/release.md +132 -132
- package/docs/services.md +164 -169
- package/docs/site-data.md +90 -90
- package/docs/skills.md +137 -129
- package/docs/storage-and-network.md +93 -93
- package/docs/ui.md +683 -650
- package/docs/user-data.md +796 -791
- package/docs/whiteboard.md +391 -391
- package/package.js +1 -1
- package/package.json +1 -1
- package/portable.js +10 -2
- package/publish-artifacts.js +2 -2
- package/types/packages/asr/src/refinement.d.ts +5 -0
- package/types/packages/plugins/src/ai.d.ts +0 -33
- package/types/packages/plugins/src/contract.d.ts +3 -2
- package/types/packages/plugins/src/editor.d.ts +0 -14
- package/types/packages/plugins/src/home.d.ts +5 -0
- package/types/packages/plugins/src/index.d.ts +1 -0
- package/types/packages/plugins/src/package-targets.d.ts +11 -0
- package/types/packages/plugins/src/permissions.d.ts +1 -1
- package/types/packages/plugins/src/portable.d.ts +9 -5
- package/types/packages/plugins/src/services.d.ts +5 -1
- package/types/packages/plugins/src/speech.d.ts +23 -0
- package/types/packages/plugins/src/video.d.ts +12 -0
- package/types/packages/shared/src/chat-core/askQuestion.d.ts +71 -0
- package/types/packages/shared/src/chat-core/index.d.ts +1 -0
- package/types/packages/shared/src/chat-core/messages.d.ts +14 -3
- package/types/packages/shared/src/chat-core/thinkingLevels.d.ts +15 -0
- package/types/packages/ui/src/primitives/Toast.d.ts +18 -2
- package/types/packages/shared/src/components/ChatInputArea/types.d.ts +0 -126
package/package.js
CHANGED
package/package.json
CHANGED
package/portable.js
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
|
+
MOBILE_AI_MIN_VERSION,
|
|
3
|
+
MOBILE_AI_PERMISSIONS,
|
|
2
4
|
MOBILE_DATA_MIN_VERSION,
|
|
3
5
|
MOBILE_DATA_PERMISSIONS,
|
|
6
|
+
MOBILE_SPEECH_MIN_VERSION,
|
|
7
|
+
MOBILE_SPEECH_PERMISSIONS,
|
|
4
8
|
PORTABLE_PLATFORMS,
|
|
5
9
|
PORTABLE_SHARED_MODULES,
|
|
6
10
|
assertPortablePluginCompatibility,
|
|
7
11
|
buildPortablePluginManifest,
|
|
8
12
|
validatePortableDistributionManifest,
|
|
9
13
|
validatePortablePluginManifest
|
|
10
|
-
} from "./client/chunk-
|
|
11
|
-
import "./client/chunk-
|
|
14
|
+
} from "./client/chunk-7ZRTRNIF.js";
|
|
15
|
+
import "./client/chunk-M4KRTX2I.js";
|
|
12
16
|
import "./client/chunk-UTVEXGFI.js";
|
|
13
17
|
export {
|
|
18
|
+
MOBILE_AI_MIN_VERSION,
|
|
19
|
+
MOBILE_AI_PERMISSIONS,
|
|
14
20
|
MOBILE_DATA_MIN_VERSION,
|
|
15
21
|
MOBILE_DATA_PERMISSIONS,
|
|
22
|
+
MOBILE_SPEECH_MIN_VERSION,
|
|
23
|
+
MOBILE_SPEECH_PERMISSIONS,
|
|
16
24
|
PORTABLE_PLATFORMS,
|
|
17
25
|
PORTABLE_SHARED_MODULES,
|
|
18
26
|
assertPortablePluginCompatibility,
|
package/publish-artifacts.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PORTABLE_SHARED_MODULES,
|
|
3
3
|
validatePortablePluginManifest
|
|
4
|
-
} from "./client/chunk-
|
|
4
|
+
} from "./client/chunk-7ZRTRNIF.js";
|
|
5
5
|
import {
|
|
6
6
|
PLUGIN_SHARED_MODULES,
|
|
7
7
|
validatePluginManifest
|
|
8
|
-
} from "./client/chunk-
|
|
8
|
+
} from "./client/chunk-M4KRTX2I.js";
|
|
9
9
|
import {
|
|
10
10
|
__commonJS,
|
|
11
11
|
__toESM
|
|
@@ -5,6 +5,11 @@ export interface SpeechRefinementPreferences {
|
|
|
5
5
|
}
|
|
6
6
|
export declare const DEFAULT_SPEECH_REFINEMENT: SpeechRefinementPreferences;
|
|
7
7
|
export declare function validateSpeechRefinementPreferences(value: unknown): SpeechRefinementPreferences;
|
|
8
|
+
/** 语音整理提示词:转录作为 JSON 数据交给模型,system 约束只整理不执行其中指令 */
|
|
9
|
+
export declare function buildSpeechRefinementPrompt(preferences: SpeechRefinementPreferences): {
|
|
10
|
+
system: string;
|
|
11
|
+
user(text: string): string;
|
|
12
|
+
};
|
|
8
13
|
export type SpeechRefiner = (text: string, options: {
|
|
9
14
|
signal: AbortSignal;
|
|
10
15
|
onPreview(text: string): void;
|
|
@@ -7,42 +7,9 @@ export declare const PLUGIN_AI_CAPABILITIES: {
|
|
|
7
7
|
readonly chat: {
|
|
8
8
|
readonly name: "对话功能";
|
|
9
9
|
};
|
|
10
|
-
readonly titleSummary: {
|
|
11
|
-
readonly name: "标题总结";
|
|
12
|
-
};
|
|
13
|
-
readonly webClip: {
|
|
14
|
-
readonly name: "网页剪藏";
|
|
15
|
-
};
|
|
16
|
-
readonly podcastGeneration: {
|
|
17
|
-
readonly name: "播客生成";
|
|
18
|
-
};
|
|
19
10
|
readonly flashcardGeneration: {
|
|
20
11
|
readonly name: "闪卡制作";
|
|
21
12
|
};
|
|
22
|
-
readonly aiJudgement: {
|
|
23
|
-
readonly name: "答案评判";
|
|
24
|
-
};
|
|
25
|
-
readonly transcriptionOptimization: {
|
|
26
|
-
readonly name: "转录断句优化";
|
|
27
|
-
};
|
|
28
|
-
readonly speechInputRefinement: {
|
|
29
|
-
readonly name: "语音输入整理";
|
|
30
|
-
};
|
|
31
|
-
readonly videoSummary: {
|
|
32
|
-
readonly name: "视频总结";
|
|
33
|
-
};
|
|
34
|
-
readonly videoEbookRewrite: {
|
|
35
|
-
readonly name: "视频电子书重写";
|
|
36
|
-
};
|
|
37
|
-
readonly vibeLearningImageDescription: {
|
|
38
|
-
readonly name: "图片理解";
|
|
39
|
-
};
|
|
40
|
-
readonly contentMetadata: {
|
|
41
|
-
readonly name: "笔记元信息";
|
|
42
|
-
};
|
|
43
|
-
readonly contentInsights: {
|
|
44
|
-
readonly name: "AI 洞见";
|
|
45
|
-
};
|
|
46
13
|
};
|
|
47
14
|
export type PluginAICapability = keyof typeof PLUGIN_AI_CAPABILITIES;
|
|
48
15
|
export declare const isPluginAICapability: (value: unknown) => value is PluginAICapability;
|
|
@@ -4,7 +4,6 @@ import type { PluginNavigation } from "./navigation";
|
|
|
4
4
|
import type { PluginAI, PluginAIFeature } from "./ai";
|
|
5
5
|
import type { WhiteboardExtension } from "./whiteboard";
|
|
6
6
|
import type { PluginServices } from "./services";
|
|
7
|
-
import type { PluginEditor } from "./editor";
|
|
8
7
|
import type { PluginEditorExtension } from "./editor";
|
|
9
8
|
import type { ContentMetricRule } from "../../db-schema/content-metrics";
|
|
10
9
|
import type { MarkdownCodec } from "../../markdown/src/index";
|
|
@@ -36,6 +35,7 @@ import type { PluginLinks } from "./links";
|
|
|
36
35
|
import type { PluginTransactionRunner } from "./transaction";
|
|
37
36
|
import type { PluginFlashcards } from "./flashcards";
|
|
38
37
|
import type { PluginNotifications } from "./notifications";
|
|
38
|
+
import type { PluginSpeech } from "./speech";
|
|
39
39
|
import type { JsonValue } from "./json";
|
|
40
40
|
export type { JsonValue } from "./json";
|
|
41
41
|
export interface Disposable {
|
|
@@ -64,7 +64,6 @@ export interface PluginContext {
|
|
|
64
64
|
};
|
|
65
65
|
readonly storage: PluginStorage;
|
|
66
66
|
readonly pages: PluginPages;
|
|
67
|
-
readonly editor: PluginEditor;
|
|
68
67
|
readonly settings: PluginSettings;
|
|
69
68
|
readonly sync: PluginSync;
|
|
70
69
|
readonly upload: PluginUpload;
|
|
@@ -110,6 +109,8 @@ export interface PluginContext {
|
|
|
110
109
|
readonly transaction: PluginTransactionRunner;
|
|
111
110
|
readonly flashcards: PluginFlashcards;
|
|
112
111
|
readonly notifications: PluginNotifications;
|
|
112
|
+
/** 语音输入;需要 speech:input 权限 */
|
|
113
|
+
readonly speech: PluginSpeech;
|
|
113
114
|
/** 将订阅等资源交给宿主,在停用或激活失败时逆序回收。 */
|
|
114
115
|
register(resource: Disposable): Disposable;
|
|
115
116
|
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type { ContentMetricRule } from "../../db-schema/content-metrics";
|
|
2
1
|
import type { EditorExtension as InternalExtension } from "../../editor/contracts";
|
|
3
|
-
import type { MarkdownCodec } from "../../markdown/src/index";
|
|
4
|
-
import type { Disposable } from "./index";
|
|
5
2
|
import { type OpenEditorExtensionField } from "./editor-fields";
|
|
6
3
|
export { defineElement as defineEditorElement } from "../../editor/contracts";
|
|
7
4
|
export type { ElementRenderProps as EditorElementRenderProps } from "../../editor/contracts";
|
|
@@ -41,14 +38,3 @@ export type PluginEditorExtension = Pick<InternalExtension, OpenEditorExtensionF
|
|
|
41
38
|
}[];
|
|
42
39
|
};
|
|
43
40
|
export declare function defineEditorExtension(definition: Omit<PluginEditorExtension, "apiVersion">): PluginEditorExtension;
|
|
44
|
-
export interface PluginEditorContribution {
|
|
45
|
-
/** 目前只有开发台场景;其他场景需宿主明确接入后开放。 */
|
|
46
|
-
scene: "workbench";
|
|
47
|
-
extension: PluginEditorExtension;
|
|
48
|
-
/** 纯函数定义可由主进程独立导入,本次只在开发台装配。 */
|
|
49
|
-
codecs?: readonly MarkdownCodec[];
|
|
50
|
-
metrics?: readonly ContentMetricRule[];
|
|
51
|
-
}
|
|
52
|
-
export interface PluginEditor {
|
|
53
|
-
register(contribution: PluginEditorContribution): Disposable;
|
|
54
|
-
}
|
|
@@ -4,6 +4,11 @@ import type { Disposable, PluginContext } from "./contract";
|
|
|
4
4
|
export type PluginHomePanelSize = "compact" | "wide";
|
|
5
5
|
export interface PluginHomePanelProps {
|
|
6
6
|
readonly context: PluginContext;
|
|
7
|
+
/**
|
|
8
|
+
* 登记面板里打开的浮层(底部面板等)的关闭函数:系统返回 / Esc 先关最后登记的浮层。
|
|
9
|
+
* 宿主不支持时为 undefined;@tau/ui 的模态 Dialog / Drawer 已自带,不必登记。
|
|
10
|
+
*/
|
|
11
|
+
readonly registerDismiss?: (dismiss: () => void) => Disposable;
|
|
7
12
|
}
|
|
8
13
|
/** 面板标题行右侧的入口,如「查看账本」 */
|
|
9
14
|
export interface PluginHomePanelAction {
|
|
@@ -42,6 +42,7 @@ export type { PluginFieldCondition, PluginIndexes, PluginIndexType, PluginIndexV
|
|
|
42
42
|
export { PluginConflictError } from "./errors";
|
|
43
43
|
export { PLUGIN_ENTITY_KINDS, PLUGIN_ENTITY_READ_PERMISSIONS, PLUGIN_APP_ACTIONS, PLUGIN_EXPORT_FORMATS, PLUGIN_NOTEBOOK_FROM_KINDS, PLUGIN_CHAT_CONTEXT_KINDS, } from "./app";
|
|
44
44
|
export type { PluginNotifications, PluginNotificationOptions, PluginNotificationMode, PluginNotificationAction, } from "./notifications";
|
|
45
|
+
export type { PluginSpeech, PluginSpeechSession, PluginSpeechStartOptions } from "./speech";
|
|
45
46
|
export type { PluginApp, PluginAppAction, PluginAppActions, PluginAppActionResults, PluginContentLocation, PluginOpenOptions, PluginExportFormat, PluginEntityKind, PluginEntityRef, PluginEntityDescription, PluginPickOptions, PluginPickedEntity, } from "./app";
|
|
46
47
|
export { PLUGIN_EVENT_TYPES } from "./events";
|
|
47
48
|
export type { PluginDomainEvent, PluginEventOrigin, PluginEventType, PluginEvents } from "./events";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const PACKAGE_PLATFORMS: readonly ["desktop", "android", "ios"];
|
|
2
|
+
export type PackagePlatform = (typeof PACKAGE_PLATFORMS)[number];
|
|
3
|
+
export interface PackageTarget {
|
|
4
|
+
readonly minAppVersion: string;
|
|
5
|
+
}
|
|
6
|
+
export type PackageTargets = Readonly<Partial<Record<PackagePlatform, PackageTarget>>>;
|
|
7
|
+
export declare function readPackageTargets(value: unknown): PackageTargets;
|
|
8
|
+
export declare function assertPackageTargetCompatibility(targets: PackageTargets, host: {
|
|
9
|
+
platform: PackagePlatform;
|
|
10
|
+
appVersion: string;
|
|
11
|
+
}): PackageTarget;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const PLUGIN_PERMISSIONS: readonly ["cards:read", "cards:write", "cards:delete", "articles:read", "articles:write", "articles:delete", "documents:read", "documents:write", "documents:delete", "whiteboards:read", "whiteboards:write", "whiteboards:delete", "projects:read", "projects:write", "projects:delete", "todos:read", "todos:write", "todos:delete", "calendar:read", "calendar:write", "calendar:delete", "notebooks:read", "materials:read", "chats:read", "flashcards:read", "flashcards:write",
|
|
1
|
+
export declare const PLUGIN_PERMISSIONS: readonly ["cards:read", "cards:write", "cards:delete", "articles:read", "articles:write", "articles:delete", "documents:read", "documents:write", "documents:delete", "whiteboards:read", "whiteboards:write", "whiteboards:delete", "projects:read", "projects:write", "projects:delete", "todos:read", "todos:write", "todos:delete", "calendar:read", "calendar:write", "calendar:delete", "notebooks:read", "materials:read", "chats:read", "flashcards:read", "flashcards:write", "speech:input", ...("ai:chat" | "ai:flashcardGeneration")[]];
|
|
2
2
|
export type PluginPermission = (typeof PLUGIN_PERMISSIONS)[number];
|
|
3
3
|
export declare const isPluginPermission: (value: unknown) => value is PluginPermission;
|
|
4
4
|
/** granted:可直接调用;prompt:调用时会询问用户;denied:本次运行已拒绝或已被阻止 */
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { type PluginManifest } from "./package";
|
|
2
2
|
import type { PluginEnvironment } from "./environment";
|
|
3
|
+
import { type PackagePlatform, type PackageTarget } from "./package-targets";
|
|
3
4
|
export declare const MOBILE_DATA_MIN_VERSION = "0.2.13";
|
|
4
|
-
export declare const
|
|
5
|
+
export declare const MOBILE_AI_MIN_VERSION = "0.2.13";
|
|
6
|
+
export declare const MOBILE_AI_PERMISSIONS: readonly ("ai:chat" | "ai:flashcardGeneration")[];
|
|
7
|
+
export declare const MOBILE_DATA_PERMISSIONS: readonly ["cards:read", "cards:write", "cards:delete", "articles:read", "articles:write", "articles:delete", "projects:read", "projects:write", "projects:delete", "documents:read", "documents:write", "documents:delete", "todos:read", "todos:write", "todos:delete", "calendar:read", "calendar:write", "calendar:delete", "flashcards:read", "flashcards:write"];
|
|
8
|
+
/** 语音输入与首页面板随同一客户端版本开放 */
|
|
9
|
+
export declare const MOBILE_SPEECH_MIN_VERSION = "0.2.16";
|
|
10
|
+
export declare const MOBILE_SPEECH_PERMISSIONS: readonly ["speech:input"];
|
|
5
11
|
export declare const PORTABLE_PLATFORMS: readonly ["desktop", "android", "ios"];
|
|
6
|
-
export type PortablePlatform =
|
|
12
|
+
export type PortablePlatform = PackagePlatform;
|
|
7
13
|
export declare const PORTABLE_SHARED_MODULES: readonly ["@tau/plugins", "@tau/plugins/whiteboard", "@tau/ui", "react", "react-dom", "react-dom/client", "react/jsx-runtime", "react/jsx-dev-runtime"];
|
|
8
|
-
export
|
|
9
|
-
readonly minAppVersion: string;
|
|
10
|
-
}
|
|
14
|
+
export type PortablePluginTarget = PackageTarget;
|
|
11
15
|
export interface PortablePluginManifest extends Omit<PluginManifest, "formatVersion" | "platform" | "backend" | "minAppVersion" | "editor" | "whiteboard"> {
|
|
12
16
|
readonly formatVersion: 3;
|
|
13
17
|
readonly platform: "portable";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Descendant } from "slate";
|
|
2
2
|
import type { MarkdownCodec } from "../../markdown/src/index";
|
|
3
3
|
import type { GitSnapshotRequest, GitCacheDirectory } from "./publish";
|
|
4
|
+
import type { VideoCaptions } from "./video";
|
|
4
5
|
export type { Descendant } from "slate";
|
|
5
6
|
export interface ServiceOptions {
|
|
6
7
|
signal?: AbortSignal;
|
|
@@ -89,11 +90,14 @@ export interface PluginServices {
|
|
|
89
90
|
log: string;
|
|
90
91
|
}>;
|
|
91
92
|
};
|
|
92
|
-
/** 宿主视频解析器(yt-dlp
|
|
93
|
+
/** 宿主视频解析器(yt-dlp);视频下载经播放源交给宿主。 */
|
|
93
94
|
videoExtractor: {
|
|
94
95
|
probe(url: string, options?: ServiceOptions & {
|
|
95
96
|
proxy?: string;
|
|
96
97
|
}): Promise<VideoProbeResult>;
|
|
98
|
+
getCaptions(url: string, options?: ServiceOptions & {
|
|
99
|
+
proxy?: string;
|
|
100
|
+
}): Promise<VideoCaptions | null>;
|
|
97
101
|
};
|
|
98
102
|
}
|
|
99
103
|
/** 每个调用同时受调用方与插件实例生命周期约束。 */
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 语音输入:沿用用户在 Tau「语音 › 语音输入」里选的识别方式(系统识别或识别插件),插件拿到的是识别文字。
|
|
3
|
+
* 需要在 manifest 声明 speech:input,第一次 start 时 Tau 询问用户;录音只在 start 与 stop / cancel 之间进行。
|
|
4
|
+
*/
|
|
5
|
+
export interface PluginSpeechSession {
|
|
6
|
+
/** 识别完成后的文字;cancel 或出错时 reject */
|
|
7
|
+
readonly result: Promise<string>;
|
|
8
|
+
/** 停止录音,等待最终结果 */
|
|
9
|
+
stop(): Promise<void>;
|
|
10
|
+
/** 放弃这次录音,result 以 AbortError reject */
|
|
11
|
+
cancel(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export interface PluginSpeechStartOptions {
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
/** 识别中的实时文字(整段,不是增量) */
|
|
16
|
+
onPreview?(text: string): void;
|
|
17
|
+
}
|
|
18
|
+
export interface PluginSpeech {
|
|
19
|
+
/** 当前不能录音的原因(如「识别插件账号尚未配置」),可用时为 null;不触发授权询问 */
|
|
20
|
+
unavailableReason(): string | null;
|
|
21
|
+
/** 开始录音;同一时间只能有一次。宿主不支持时抛 SPEECH_UNAVAILABLE 开头的错误 */
|
|
22
|
+
start(options?: PluginSpeechStartOptions): Promise<PluginSpeechSession>;
|
|
23
|
+
}
|
|
@@ -39,6 +39,16 @@ export interface ResolvedVideo {
|
|
|
39
39
|
variants: readonly VideoVariant[];
|
|
40
40
|
defaultVariant?: number;
|
|
41
41
|
}
|
|
42
|
+
export interface VideoCaptionSegment {
|
|
43
|
+
text: string;
|
|
44
|
+
/** 相对于视频起点的毫秒时间戳。 */
|
|
45
|
+
start: number;
|
|
46
|
+
end: number;
|
|
47
|
+
}
|
|
48
|
+
export interface VideoCaptions {
|
|
49
|
+
language?: string;
|
|
50
|
+
segments: readonly VideoCaptionSegment[];
|
|
51
|
+
}
|
|
42
52
|
export interface VideoInstance {
|
|
43
53
|
/** 同步识别链接是否属于本提供方,不发网络请求。 */
|
|
44
54
|
matches(url: string): boolean;
|
|
@@ -46,6 +56,8 @@ export interface VideoInstance {
|
|
|
46
56
|
/** 稳定的缓存身份(应包含清晰度);已缓存时宿主不再调用 getPlayback。 */
|
|
47
57
|
cacheKey(ref: VideoRef): string;
|
|
48
58
|
getPlayback(ref: VideoRef, signal: AbortSignal): Promise<VideoPlaybackSource>;
|
|
59
|
+
/** 读取平台字幕;无字幕返回 null。不提供此能力时可省略,用户仍可手动转录。 */
|
|
60
|
+
getCaptions?(ref: VideoRef, signal: AbortSignal): Promise<VideoCaptions | null>;
|
|
49
61
|
}
|
|
50
62
|
export interface VideoProviderDefinition {
|
|
51
63
|
id: string;
|
|
@@ -1,5 +1,76 @@
|
|
|
1
1
|
/** ask-question 提问工具的载荷、作答与结果(纯数据,主进程、渲染端与浏览器扩展共用) */
|
|
2
2
|
export declare const ASK_QUESTION_TOOL_NAME: "ask-question";
|
|
3
|
+
export declare const ASK_QUESTION_DESCRIPTION = "\u5F53\u9700\u8981\u8FDB\u4E00\u6B65\u6F84\u6E05\u7528\u6237\u610F\u56FE\u65F6\uFF0C\u5411\u7528\u6237\u53D1\u8D77\u7ED3\u6784\u5316\u95EE\u9898\u3002\u652F\u6301\u5355\u9009\u3001\u591A\u9009\u548C\u4E00\u6B21\u63D0\u51FA\u591A\u4E2A\u95EE\u9898\u3002";
|
|
4
|
+
/** ask-question 的模型入参 schema:桌面 pi 会话与移动运行时共用 */
|
|
5
|
+
export declare const ASK_QUESTION_PARAMETERS: {
|
|
6
|
+
type: string;
|
|
7
|
+
properties: {
|
|
8
|
+
title: {
|
|
9
|
+
type: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
description: {
|
|
13
|
+
type: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
submitLabel: {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
};
|
|
20
|
+
questions: {
|
|
21
|
+
type: string;
|
|
22
|
+
description: string;
|
|
23
|
+
items: {
|
|
24
|
+
type: string;
|
|
25
|
+
properties: {
|
|
26
|
+
id: {
|
|
27
|
+
type: string;
|
|
28
|
+
description: string;
|
|
29
|
+
};
|
|
30
|
+
question: {
|
|
31
|
+
type: string;
|
|
32
|
+
description: string;
|
|
33
|
+
};
|
|
34
|
+
type: {
|
|
35
|
+
type: string;
|
|
36
|
+
enum: string[];
|
|
37
|
+
description: string;
|
|
38
|
+
};
|
|
39
|
+
required: {
|
|
40
|
+
type: string;
|
|
41
|
+
description: string;
|
|
42
|
+
};
|
|
43
|
+
options: {
|
|
44
|
+
type: string;
|
|
45
|
+
description: string;
|
|
46
|
+
items: {
|
|
47
|
+
anyOf: ({
|
|
48
|
+
type: string;
|
|
49
|
+
properties?: undefined;
|
|
50
|
+
} | {
|
|
51
|
+
type: string;
|
|
52
|
+
properties: {
|
|
53
|
+
label: {
|
|
54
|
+
type: string;
|
|
55
|
+
};
|
|
56
|
+
value: {
|
|
57
|
+
type: string;
|
|
58
|
+
};
|
|
59
|
+
description: {
|
|
60
|
+
type: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
})[];
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
required: string[];
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
required: string[];
|
|
72
|
+
additionalProperties: boolean;
|
|
73
|
+
};
|
|
3
74
|
export type AskQuestionType = "single" | "multiple";
|
|
4
75
|
export interface AskQuestionOption {
|
|
5
76
|
label: string;
|
|
@@ -3,7 +3,18 @@
|
|
|
3
3
|
* 桌面 src/types/llm.ts、src/types/chat-message.ts、src/types/tool.ts 对本文件为 re-export 关系,
|
|
4
4
|
* 两端禁止再各自定义同名类型。
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
export type ThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
7
|
+
export type ChatSessionSource = "desktop" | "mobile" | "browser";
|
|
8
|
+
export type MentionEntityType = "card" | "article" | "project-item" | "diary";
|
|
9
|
+
export interface MentionRef {
|
|
10
|
+
entityType: MentionEntityType;
|
|
11
|
+
entityId: number;
|
|
12
|
+
contentId: number;
|
|
13
|
+
title: string;
|
|
14
|
+
previewText: string;
|
|
15
|
+
/** previewText 是用户在正文里选中的原文(就近提问),而非整篇的摘要 */
|
|
16
|
+
quote?: boolean;
|
|
17
|
+
}
|
|
7
18
|
export declare enum Role {
|
|
8
19
|
User = "user",
|
|
9
20
|
Assistant = "assistant",
|
|
@@ -166,8 +177,8 @@ export interface ChatSessionRecord {
|
|
|
166
177
|
groupId?: number | null;
|
|
167
178
|
archived?: boolean;
|
|
168
179
|
orderNum?: number | null;
|
|
169
|
-
/**
|
|
170
|
-
source?:
|
|
180
|
+
/** 会话创建来源不限制其他设备继续读取或执行。 */
|
|
181
|
+
source?: ChatSessionSource;
|
|
171
182
|
/** 相对会话目录的 JSONL 文件名;草稿(尚未登记)为空 */
|
|
172
183
|
sessionFile?: string;
|
|
173
184
|
/** 聊天场景(main-chat / pdf-chat / …)与所属对象 */
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ThinkingLevel } from "./messages";
|
|
2
|
+
export interface ThinkingLevelOption {
|
|
3
|
+
value: ThinkingLevel;
|
|
4
|
+
label: string;
|
|
5
|
+
/** 窄工具行上的两字短名 */
|
|
6
|
+
short: string;
|
|
7
|
+
description: string;
|
|
8
|
+
}
|
|
9
|
+
/** 全部档位的界面文案(桌面、移动同一套说法);实际可选项由模型能力决定 */
|
|
10
|
+
export declare const THINKING_LEVEL_OPTIONS: readonly ThinkingLevelOption[];
|
|
11
|
+
/** 模型能力未知时只给各家都有的几档 */
|
|
12
|
+
export declare const DEFAULT_THINKING_LEVEL_OPTIONS: readonly ThinkingLevel[];
|
|
13
|
+
export declare const isThinkingLevel: (value: unknown) => value is ThinkingLevel;
|
|
14
|
+
/** 选中的档位落到可选集合内:换模型后旧选择可能不被支持,界面显示要与实际发送一致 */
|
|
15
|
+
export declare const clampThinkingLevel: (picked: ThinkingLevel, options: readonly ThinkingLevel[]) => ThinkingLevel;
|
|
@@ -11,10 +11,14 @@
|
|
|
11
11
|
*
|
|
12
12
|
* 用法:app 壳层挂载 <ToastHost /> 一次;任意处调用 toast.success("已保存")、
|
|
13
13
|
* toast.error("失败")、toast.loading → toast.resolve(id) 或 toast.promise(p, {...})。
|
|
14
|
+
* 外观两档:default 浅色胶囊(桌面)、inverse 深色胶囊(移动端);zoneClassName 覆盖停靠位置与层级。
|
|
15
|
+
* key:同 key 的新提示原位替换旧的一条并重新计时,用于「同一件事只留一条」(如反复轻点的说明)。
|
|
14
16
|
*/
|
|
15
17
|
export type ToastType = "success" | "error" | "warning" | "info" | "loading";
|
|
16
18
|
export type ToastPosition = "top-center" | "top-right" | "bottom-right" | "bottom-center";
|
|
17
19
|
export interface ToastOptions {
|
|
20
|
+
/** 同 key 的提示只保留一条:新提示原位替换并重新计时 */
|
|
21
|
+
key?: string;
|
|
18
22
|
/** 内联动作(如「撤销」),点击后 toast 关闭 */
|
|
19
23
|
action?: {
|
|
20
24
|
label: string;
|
|
@@ -32,6 +36,9 @@ export interface ToastOptions {
|
|
|
32
36
|
*/
|
|
33
37
|
export interface ToastItem {
|
|
34
38
|
id: number;
|
|
39
|
+
key?: string;
|
|
40
|
+
/** 原位替换时递增,重新开始计时 */
|
|
41
|
+
revision?: number;
|
|
35
42
|
type: ToastType;
|
|
36
43
|
message: string;
|
|
37
44
|
action?: ToastOptions["action"];
|
|
@@ -55,6 +62,8 @@ export declare const toast: {
|
|
|
55
62
|
loading(message: string, opts?: ToastOptions): number;
|
|
56
63
|
resolve(id: number, message?: string): void;
|
|
57
64
|
reject(id: number, message?: string): void;
|
|
65
|
+
/** 当前在显示的提示(按出现顺序),供宿主读取状态与测试断言 */
|
|
66
|
+
items(): readonly ToastItem[];
|
|
58
67
|
dismiss(id?: number): void;
|
|
59
68
|
/** promise 形态:loading → 成功/失败(文案支持按结果取值) */
|
|
60
69
|
promise<T>(promise: Promise<T>, messages: {
|
|
@@ -63,8 +72,15 @@ export declare const toast: {
|
|
|
63
72
|
error?: string | ((err: unknown) => string);
|
|
64
73
|
}, opts?: ToastOptions): Promise<T>;
|
|
65
74
|
};
|
|
66
|
-
export
|
|
67
|
-
export declare function
|
|
75
|
+
export type ToastVariant = "default" | "inverse";
|
|
76
|
+
export declare function ToastHost({ variant, zoneClassName, }?: {
|
|
77
|
+
/** default 浅色描边胶囊;inverse 深色胶囊(墨色底、反白字) */
|
|
78
|
+
variant?: ToastVariant;
|
|
79
|
+
/** 覆盖停靠区的位置与层级(如移动端顶栏下方、低于系统层) */
|
|
80
|
+
zoneClassName?: string;
|
|
81
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
82
|
+
export declare function ToastPill({ item, variant, }: {
|
|
68
83
|
item: ToastItem;
|
|
84
|
+
variant?: ToastVariant;
|
|
69
85
|
}): import("react/jsx-runtime").JSX.Element;
|
|
70
86
|
export {};
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* 模型下拉菜单项(antd Dropdown 时代的结构子集;ChatInputArea 换 @tau/ui Menu 后收敛为原语协议)。
|
|
4
|
-
* ext / desktop 侧构造的字段不超出此面,antd message 等 UI 库类型不得回流 shared 类型层。
|
|
5
|
-
*/
|
|
6
|
-
export interface ChatDropdownItem {
|
|
7
|
-
key: string;
|
|
8
|
-
label: ReactNode;
|
|
9
|
-
/** 分组小标题(非交互项,如模型菜单的 provider 名) */
|
|
10
|
-
group?: boolean;
|
|
11
|
-
danger?: boolean;
|
|
12
|
-
disabled?: boolean;
|
|
13
|
-
icon?: ReactNode;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* 思考档位——全仓唯一定义,取值与运行时(pi ThinkingLevel)逐项对齐。
|
|
17
|
-
* 桌面端 `PiThinkingLevel` 即本类型;此前两侧各有一套(旧枚举用 "none" 且没有 "minimal"),
|
|
18
|
-
* 导致 minimal 在界面上不可达、每处转换都要记得 none→off。
|
|
19
|
-
*/
|
|
20
|
-
export type ThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
21
|
-
export type MentionEntityType = "card" | "article" | "project-item";
|
|
22
|
-
/** 聊天 mention 引用 */
|
|
23
|
-
export interface MentionRef {
|
|
24
|
-
entityType: MentionEntityType;
|
|
25
|
-
entityId: number;
|
|
26
|
-
contentId: number;
|
|
27
|
-
title: string;
|
|
28
|
-
previewText: string;
|
|
29
|
-
}
|
|
30
|
-
/** 消息内容类型;resourceId 仅兼容历史数据,新附件只写入路径。 */
|
|
31
|
-
export type MessageContentItem = {
|
|
32
|
-
type: "text";
|
|
33
|
-
text: string;
|
|
34
|
-
mentions?: MentionRef[];
|
|
35
|
-
skills?: string[];
|
|
36
|
-
} | {
|
|
37
|
-
type: "image";
|
|
38
|
-
image: string;
|
|
39
|
-
path?: string;
|
|
40
|
-
resourceId?: number;
|
|
41
|
-
} | {
|
|
42
|
-
type: "file";
|
|
43
|
-
file: string;
|
|
44
|
-
resourceId?: number;
|
|
45
|
-
fileName?: string;
|
|
46
|
-
};
|
|
47
|
-
/** ChatInputArea 需要的服务函数 */
|
|
48
|
-
export interface ChatInputAreaServices {
|
|
49
|
-
/** 上传文件,返回文件路径 */
|
|
50
|
-
uploadFile: (file: File) => Promise<string | null>;
|
|
51
|
-
/** 将本地文件路径转换为可访问的 URL */
|
|
52
|
-
convertFileSrc: (path: string) => Promise<string>;
|
|
53
|
-
/** 获取用户主目录 */
|
|
54
|
-
getHomeDir: () => Promise<string>;
|
|
55
|
-
/** 搜索可提及的内部内容 */
|
|
56
|
-
searchMentionRefs?: (query: string) => Promise<MentionRef[]>;
|
|
57
|
-
}
|
|
58
|
-
/** ChatInputArea 的 ref handle */
|
|
59
|
-
export interface ChatInputAreaHandle {
|
|
60
|
-
getValue: () => MessageContentItem[];
|
|
61
|
-
clear: () => void;
|
|
62
|
-
setValue: (content: string) => void;
|
|
63
|
-
appendMention?: (mention: MentionRef) => void;
|
|
64
|
-
focusEnd: () => void;
|
|
65
|
-
}
|
|
66
|
-
export interface ChatContextUsage {
|
|
67
|
-
inputTokens: number;
|
|
68
|
-
outputTokens: number;
|
|
69
|
-
cacheReadTokens: number;
|
|
70
|
-
cacheWriteTokens: number;
|
|
71
|
-
}
|
|
72
|
-
/** ChatInputArea 的 props */
|
|
73
|
-
export interface ChatInputAreaProps {
|
|
74
|
-
/** 服务函数 */
|
|
75
|
-
services: ChatInputAreaServices;
|
|
76
|
-
/** 自定义类名 */
|
|
77
|
-
className?: string;
|
|
78
|
-
/** 是否可编辑 */
|
|
79
|
-
contentEditable?: boolean;
|
|
80
|
-
/** 按下回车时的回调 */
|
|
81
|
-
onPressEnter?: () => void;
|
|
82
|
-
/** 停止生成时的回调 */
|
|
83
|
-
onStop?: () => void;
|
|
84
|
-
/** 占位符 */
|
|
85
|
-
placeholder?: string;
|
|
86
|
-
/** 是否正在发送 */
|
|
87
|
-
sendLoading?: boolean;
|
|
88
|
-
/** 生成期间是否仍允许编辑并将消息加入发送队列 */
|
|
89
|
-
allowSendWhileLoading?: boolean;
|
|
90
|
-
/** 当前等待发送的消息数量 */
|
|
91
|
-
queuedMessageCount?: number;
|
|
92
|
-
/** 是否正在创建新消息 */
|
|
93
|
-
createMessageLoading?: boolean;
|
|
94
|
-
/** 创建新消息的回调 */
|
|
95
|
-
onCreateNewMessage?: () => void;
|
|
96
|
-
/** 模型选择菜单项 */
|
|
97
|
-
modelSelectItems?: ChatDropdownItem[];
|
|
98
|
-
/** 当前选中模型的菜单项 key,用于菜单勾选 */
|
|
99
|
-
currentModelKey?: string;
|
|
100
|
-
/** 模型选择回调 */
|
|
101
|
-
onModelSelect?: ({ key }: {
|
|
102
|
-
key: string;
|
|
103
|
-
}) => void;
|
|
104
|
-
/** 当前模型名称 */
|
|
105
|
-
currentModelName?: string;
|
|
106
|
-
/** 当前模型上下文窗口,单位为 k tokens */
|
|
107
|
-
contextWindowK?: number;
|
|
108
|
-
/** 当前聊天最近一次模型请求的 token 用量 */
|
|
109
|
-
contextUsage?: ChatContextUsage | null;
|
|
110
|
-
/** 是否支持图片上传 */
|
|
111
|
-
isSupportImage?: boolean;
|
|
112
|
-
/** 是否支持文件上传 */
|
|
113
|
-
isSupportFile?: boolean;
|
|
114
|
-
/** 思考档位 */
|
|
115
|
-
thinkingLevel?: ThinkingLevel;
|
|
116
|
-
/** 当前模型真实支持的档位(由模型能力决定,不是固定几档) */
|
|
117
|
-
thinkingLevelOptions?: readonly ThinkingLevel[];
|
|
118
|
-
/** 档位变化回调 */
|
|
119
|
-
onThinkingLevelChange?: (level: ThinkingLevel) => void;
|
|
120
|
-
/** 档位选择是否禁用 */
|
|
121
|
-
thinkingLevelDisabled?: boolean;
|
|
122
|
-
/** MCP 管理按钮点击回调(可选,不提供则不显示按钮) */
|
|
123
|
-
onMcpManagerClick?: () => void;
|
|
124
|
-
/** 额外的工具栏按钮(渲染在 + 右侧) */
|
|
125
|
-
extraToolbarButtons?: ReactNode;
|
|
126
|
-
}
|