@freecallai/pro 0.0.0-stage → 0.0.1
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/LICENSE +21 -0
- package/README.md +16 -2
- package/dist/FkpRichText.vue_vue_type_script_setup_true_lang-DnknqQTh.js +4115 -0
- package/dist/KnowledgeArea-OPR7smbt.js +923 -0
- package/dist/ToolForm-CWpUIVTl.js +185 -0
- package/dist/choice-DDg5gNtS.js +29 -0
- package/dist/guard-BCatAeT4.js +749 -0
- package/dist/index-5a9mHHzg.js +41 -0
- package/dist/index-BsQLwz91.js +5 -0
- package/dist/index-CJlAseSN.js +15 -0
- package/dist/index-CzpY61Qj.js +6 -0
- package/dist/index-D8bcFtWR.js +6 -0
- package/dist/index-DOEijEGU.js +49 -0
- package/dist/index-DSgEWJGP.js +6 -0
- package/dist/index-DxxX09iY.js +6 -0
- package/dist/index-nnvfy5q0.js +31 -0
- package/dist/index-urNonkMH.js +6 -0
- package/dist/index-xAjlBylT.js +5 -0
- package/dist/index.js +16 -0
- package/dist/inline-TT_dl8Y3.js +17 -0
- package/dist/knowledge-BZCmalF_.js +6 -0
- package/dist/knowledge-DnYGicjn.js +13 -0
- package/dist/media-extensions-ZoxmhIhH.js +276 -0
- package/dist/media-migration-CGOFwdYm.js +59 -0
- package/dist/media-upload-Dx45yv6a.js +69 -0
- package/dist/operations-JgnjGx3H.js +19 -0
- package/dist/question-D1--acV8.js +10 -0
- package/dist/question-DGC6JHy5.js +6 -0
- package/dist/rich-text/index.js +224 -0
- package/dist/rich-text/legacy-converter/index.js +485 -0
- package/dist/selection-state-D47jhx0U.js +20 -0
- package/dist/state-KfOqha3d.js +16 -0
- package/dist/style.css +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/rich-text/FkpRichText.vue.d.ts +242 -0
- package/dist/types/rich-text/MediaView.vue.d.ts +92 -0
- package/dist/types/rich-text/__demo__/conversion-fixtures.d.ts +35 -0
- package/dist/types/rich-text/config/catalog.d.ts +3 -0
- package/dist/types/rich-text/config/descriptor.d.ts +58 -0
- package/dist/types/rich-text/config/media-options.d.ts +6 -0
- package/dist/types/rich-text/config/resolve.d.ts +17 -0
- package/dist/types/rich-text/config/selection-options.d.ts +6 -0
- package/dist/types/rich-text/extensions.d.ts +6 -0
- package/dist/types/rich-text/index.d.ts +17 -0
- package/dist/types/rich-text/legacy-converter/index.d.ts +45 -0
- package/dist/types/rich-text/media-extensions.d.ts +4 -0
- package/dist/types/rich-text/media-id.d.ts +2 -0
- package/dist/types/rich-text/model/agent-context.d.ts +7 -0
- package/dist/types/rich-text/model/capability-diff.d.ts +14 -0
- package/dist/types/rich-text/model/condition-contract.d.ts +10 -0
- package/dist/types/rich-text/model/convert.d.ts +6 -0
- package/dist/types/rich-text/model/guard.d.ts +7 -0
- package/dist/types/rich-text/model/json-value.d.ts +2 -0
- package/dist/types/rich-text/model/media-migration.d.ts +8 -0
- package/dist/types/rich-text/model/node-contract.d.ts +10 -0
- package/dist/types/rich-text/model/node-identity.d.ts +8 -0
- package/dist/types/rich-text/model/persistence-contract.d.ts +25 -0
- package/dist/types/rich-text/model/preview.d.ts +2 -0
- package/dist/types/rich-text/model/question-text.d.ts +15 -0
- package/dist/types/rich-text/model/reasoning-context.d.ts +24 -0
- package/dist/types/rich-text/model/scene-snapshot.d.ts +4 -0
- package/dist/types/rich-text/model/validate.d.ts +19 -0
- package/dist/types/rich-text/model/web-url.d.ts +2 -0
- package/dist/types/rich-text/plugins/agentSelect/descriptor.d.ts +2 -0
- package/dist/types/rich-text/plugins/attribute/descriptor.d.ts +2 -0
- package/dist/types/rich-text/plugins/attribute/index.d.ts +2 -0
- package/dist/types/rich-text/plugins/block.d.ts +3 -0
- package/dist/types/rich-text/plugins/choice.d.ts +4 -0
- package/dist/types/rich-text/plugins/image/descriptor.d.ts +2 -0
- package/dist/types/rich-text/plugins/image/index.d.ts +2 -0
- package/dist/types/rich-text/plugins/inline.d.ts +3 -0
- package/dist/types/rich-text/plugins/media-upload.d.ts +3 -0
- package/dist/types/rich-text/plugins/memory/descriptor.d.ts +2 -0
- package/dist/types/rich-text/plugins/memory/index.d.ts +2 -0
- package/dist/types/rich-text/plugins/operations.d.ts +86 -0
- package/dist/types/rich-text/plugins/originalReply/descriptor.d.ts +2 -0
- package/dist/types/rich-text/plugins/originalReply/knowledge.d.ts +2 -0
- package/dist/types/rich-text/plugins/originalReply/question.d.ts +2 -0
- package/dist/types/rich-text/plugins/reasoningPolish/descriptor.d.ts +2 -0
- package/dist/types/rich-text/plugins/reasoningPolish/index.d.ts +3 -0
- package/dist/types/rich-text/plugins/reasoningTemplate/descriptor.d.ts +2 -0
- package/dist/types/rich-text/plugins/reasoningTemplate/index.d.ts +3 -0
- package/dist/types/rich-text/plugins/registry.d.ts +14 -0
- package/dist/types/rich-text/plugins/selection-state.d.ts +4 -0
- package/dist/types/rich-text/plugins/separator/descriptor.d.ts +2 -0
- package/dist/types/rich-text/plugins/separator/index.d.ts +2 -0
- package/dist/types/rich-text/plugins/state.d.ts +3 -0
- package/dist/types/rich-text/plugins/tagged/descriptor.d.ts +2 -0
- package/dist/types/rich-text/plugins/tagged/index.d.ts +2 -0
- package/dist/types/rich-text/plugins/ticket/descriptor.d.ts +2 -0
- package/dist/types/rich-text/plugins/ticket/index.d.ts +2 -0
- package/dist/types/rich-text/plugins/todo/descriptor.d.ts +2 -0
- package/dist/types/rich-text/plugins/todo/knowledge.d.ts +2 -0
- package/dist/types/rich-text/plugins/todo/question.d.ts +2 -0
- package/dist/types/rich-text/plugins/tool/descriptor.d.ts +2 -0
- package/dist/types/rich-text/plugins/tool/index.d.ts +2 -0
- package/dist/types/rich-text/plugins/tool/operations.d.ts +4 -0
- package/dist/types/rich-text/plugins/tool/presentation.d.ts +7 -0
- package/dist/types/rich-text/plugins/variable/descriptor.d.ts +2 -0
- package/dist/types/rich-text/plugins/variable/index.d.ts +2 -0
- package/dist/types/rich-text/plugins/video/descriptor.d.ts +2 -0
- package/dist/types/rich-text/plugins/video/index.d.ts +2 -0
- package/dist/types/rich-text/public/types.d.ts +588 -0
- package/dist/types/rich-text/runtime/action-ports.d.ts +15 -0
- package/dist/types/rich-text/runtime/media-state.d.ts +6 -0
- package/dist/types/rich-text/runtime/media-target.d.ts +8 -0
- package/dist/types/rich-text/runtime/media-upload-session.d.ts +59 -0
- package/dist/types/rich-text/runtime/operations.d.ts +48 -0
- package/dist/types/rich-text/runtime/option-menu-session.d.ts +28 -0
- package/dist/types/rich-text/runtime/option-source.d.ts +10 -0
- package/dist/types/rich-text/runtime/port-result.d.ts +21 -0
- package/dist/types/rich-text/runtime/schema-plan.d.ts +17 -0
- package/dist/types/rich-text/runtime/tool-form-session.d.ts +39 -0
- package/dist/types/rich-text/runtime/tool-params.d.ts +5 -0
- package/dist/types/rich-text/types.d.ts +40 -0
- package/dist/types/rich-text/ui/CapabilityHelp.vue.d.ts +9 -0
- package/dist/types/rich-text/ui/KnowledgeArea.vue.d.ts +117 -0
- package/dist/types/rich-text/ui/ToolForm.vue.d.ts +14 -0
- package/dist/types/rich-text/ui/VariableOptionList.vue.d.ts +15 -0
- package/package.json +70 -3
|
@@ -0,0 +1,588 @@
|
|
|
1
|
+
import { JSONContent } from '@tiptap/core';
|
|
2
|
+
export type KnowledgeType = 'normal' | 'reasoning' | 'agent';
|
|
3
|
+
export type CapabilitySlot = 'questionAction' | 'knowledgeInline' | 'knowledgeBlock' | 'sceneAction' | 'toolbarOnly';
|
|
4
|
+
export type CapabilityId = 'todo' | 'ticket' | 'originalReply' | 'memory' | 'tagged' | 'variable' | 'image' | 'video' | 'separator' | 'attribute' | 'tool' | 'agentSelect' | 'reasoningPolish' | 'reasoningTemplate';
|
|
5
|
+
export interface KnowledgeSceneV1 {
|
|
6
|
+
/** 场景数据版本,固定为 1。
|
|
7
|
+
* @en Scene schema version, currently 1.
|
|
8
|
+
*/
|
|
9
|
+
schemaVersion: 1;
|
|
10
|
+
/** 已持久化的场景 ID,新建时可省略。
|
|
11
|
+
* @en Persisted scene ID; omit for a new scene.
|
|
12
|
+
*/
|
|
13
|
+
id?: string;
|
|
14
|
+
/** 知识类型:常规、推理或 Agent。
|
|
15
|
+
* @en Knowledge type: normal, reasoning, or Agent.
|
|
16
|
+
*/
|
|
17
|
+
type: KnowledgeType;
|
|
18
|
+
/** 顾客问法纯文本,不包含显示标签或模型协议标记。
|
|
19
|
+
* @en Plain customer intent, without display tags or model protocol tokens.
|
|
20
|
+
*/
|
|
21
|
+
question: {
|
|
22
|
+
text: string;
|
|
23
|
+
};
|
|
24
|
+
/** Tiptap JSON 正文、Agent 选择及切换类型时保留的正文。
|
|
25
|
+
* @en Tiptap JSON content, Agent selection, and content retained during type changes.
|
|
26
|
+
*/
|
|
27
|
+
knowledge: {
|
|
28
|
+
doc: JSONContent | null;
|
|
29
|
+
retainedDoc?: JSONContent | null;
|
|
30
|
+
agentRef?: {
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
} | null;
|
|
34
|
+
};
|
|
35
|
+
/** 按能力 ID 保存的版本化插件状态,不与问法文本混写。
|
|
36
|
+
* @en Versioned plugin state keyed by capability ID, separate from question text.
|
|
37
|
+
*/
|
|
38
|
+
extensionState: Record<string, {
|
|
39
|
+
version: number;
|
|
40
|
+
data: unknown;
|
|
41
|
+
}>;
|
|
42
|
+
}
|
|
43
|
+
/** Backend-neutral condition envelope owned by the consuming page. */
|
|
44
|
+
export interface KnowledgeConditionV1 {
|
|
45
|
+
/** 条件数据版本,固定为 1。
|
|
46
|
+
* @en Condition schema version, currently 1.
|
|
47
|
+
*/
|
|
48
|
+
schemaVersion: 1;
|
|
49
|
+
/** 已持久化的条件 ID。
|
|
50
|
+
* @en Persisted condition ID.
|
|
51
|
+
*/
|
|
52
|
+
id?: string;
|
|
53
|
+
/** 条件中的场景列表;sceneKey 在同一条件内唯一。
|
|
54
|
+
* @en Ordered scenes; sceneKey is unique within the condition.
|
|
55
|
+
*/
|
|
56
|
+
scenes: Array<{
|
|
57
|
+
sceneKey: string;
|
|
58
|
+
scene: KnowledgeSceneV1;
|
|
59
|
+
}>;
|
|
60
|
+
}
|
|
61
|
+
/** 迁移诊断必须保留原始字段或节点位置。
|
|
62
|
+
* @en Migration issue with a required original field or node path.
|
|
63
|
+
*/
|
|
64
|
+
export type MigrationIssueV1 = EditorDiagnostic & {
|
|
65
|
+
source: 'migration';
|
|
66
|
+
path: string;
|
|
67
|
+
};
|
|
68
|
+
/** Target structured persistence contract implemented by the consuming app. */
|
|
69
|
+
export interface LoadedConditionV1 {
|
|
70
|
+
/** 结构化结果无 kind,可与旧版只读分支按 kind 收窄。
|
|
71
|
+
* @en Structured results omit kind so callers can narrow the legacy branch.
|
|
72
|
+
*/
|
|
73
|
+
kind?: never;
|
|
74
|
+
/** 已加载的完整结构化条件。
|
|
75
|
+
* @en Complete structured condition returned by loading.
|
|
76
|
+
*/
|
|
77
|
+
condition: KnowledgeConditionV1;
|
|
78
|
+
/** 服务端不透明版本号,用于后续更新。
|
|
79
|
+
* @en Opaque server revision for the next update.
|
|
80
|
+
*/
|
|
81
|
+
revision: string;
|
|
82
|
+
/** 无损迁移中的提示或警告,每条都带来源路径;错误须走旧版只读分支。
|
|
83
|
+
* @en Path-based info or warnings from lossless migration; errors require the legacy read-only branch.
|
|
84
|
+
*/
|
|
85
|
+
migrationIssues: Array<MigrationIssueV1 & {
|
|
86
|
+
severity: 'info' | 'warning';
|
|
87
|
+
}>;
|
|
88
|
+
}
|
|
89
|
+
/** Old condition that cannot be represented without losing data. Never pass it to the V1 save input. */
|
|
90
|
+
export interface LegacyReadonlyConditionV1 {
|
|
91
|
+
/** 旧版条件只读分支标识。
|
|
92
|
+
* @en Discriminant for an unmigratable legacy condition.
|
|
93
|
+
*/
|
|
94
|
+
kind: 'legacyReadonly';
|
|
95
|
+
/** Stable ID of the original condition. */
|
|
96
|
+
conditionId: string;
|
|
97
|
+
/** Complete JSON response data kept outside the new editor schema. */
|
|
98
|
+
rawCondition: Record<string, unknown>;
|
|
99
|
+
/** At least one error with a source path explains why editing is unavailable. */
|
|
100
|
+
migrationIssues: MigrationIssueV1[];
|
|
101
|
+
}
|
|
102
|
+
export type ConditionLoadV1 = LoadedConditionV1 | LegacyReadonlyConditionV1;
|
|
103
|
+
export interface SaveConditionInputV1 {
|
|
104
|
+
/** 待保存的完整条件。
|
|
105
|
+
* @en Complete condition to save.
|
|
106
|
+
*/
|
|
107
|
+
condition: KnowledgeConditionV1;
|
|
108
|
+
/** 新建时为 null,更新时为上次读取的服务端版本号。
|
|
109
|
+
* @en Null for creation; the last server revision for an update.
|
|
110
|
+
*/
|
|
111
|
+
expectedRevision: string | null;
|
|
112
|
+
/** 一次保存请求的幂等键。
|
|
113
|
+
* @en Idempotency key for one save request.
|
|
114
|
+
*/
|
|
115
|
+
idempotencyKey: string;
|
|
116
|
+
}
|
|
117
|
+
export interface SavedConditionV1 {
|
|
118
|
+
/** 服务端回读的完整条件。
|
|
119
|
+
* @en Complete condition echoed by the server.
|
|
120
|
+
*/
|
|
121
|
+
condition: KnowledgeConditionV1;
|
|
122
|
+
/** 本次保存后的新版本号。
|
|
123
|
+
* @en New server revision after saving.
|
|
124
|
+
*/
|
|
125
|
+
revision: string;
|
|
126
|
+
}
|
|
127
|
+
export interface KnowledgePersistenceAdapterV1 {
|
|
128
|
+
/** 按条件 ID 载入完整结构化数据。
|
|
129
|
+
* @en Load complete structured data by condition ID.
|
|
130
|
+
*/
|
|
131
|
+
load(conditionId: string, signal: AbortSignal): Promise<PortResult<ConditionLoadV1>>;
|
|
132
|
+
/** 使用版本号与幂等键保存完整条件。
|
|
133
|
+
* @en Save the complete condition with revision and idempotency key.
|
|
134
|
+
*/
|
|
135
|
+
save(input: SaveConditionInputV1, signal: AbortSignal): Promise<PortResult<SavedConditionV1>>;
|
|
136
|
+
}
|
|
137
|
+
export interface CapabilityRuleV1 {
|
|
138
|
+
/** 能力标识,应与 slot 一起匹配内置能力目录。
|
|
139
|
+
* @en Capability ID; match together with slot against the built-in catalog.
|
|
140
|
+
*/
|
|
141
|
+
id: CapabilityId;
|
|
142
|
+
/** 能力所在位置。
|
|
143
|
+
* @en Capability placement.
|
|
144
|
+
*/
|
|
145
|
+
slot: CapabilitySlot;
|
|
146
|
+
/** 是否允许此能力参与编辑。
|
|
147
|
+
* @en Whether this capability may be used while editing.
|
|
148
|
+
* @defaultValue -
|
|
149
|
+
*/
|
|
150
|
+
enabled?: boolean;
|
|
151
|
+
/** 是否在工具栏中显示;不改变已存节点。
|
|
152
|
+
* @en Toolbar visibility; does not delete stored nodes.
|
|
153
|
+
* @defaultValue -
|
|
154
|
+
*/
|
|
155
|
+
visible?: boolean;
|
|
156
|
+
/** 覆盖工具栏显示名称;提供时必须包含非空白字符。
|
|
157
|
+
* @en Override the displayed toolbar label; it must be nonblank when provided.
|
|
158
|
+
*/
|
|
159
|
+
label?: string;
|
|
160
|
+
/** 覆盖工具栏排序权重。
|
|
161
|
+
* @en Override toolbar ordering weight.
|
|
162
|
+
*/
|
|
163
|
+
order?: number;
|
|
164
|
+
/** 选项分页或媒体限制;形状由能力类型决定。
|
|
165
|
+
* @en Selection paging or media limits, depending on capability kind.
|
|
166
|
+
*/
|
|
167
|
+
options?: unknown;
|
|
168
|
+
}
|
|
169
|
+
export interface SceneConfigInputV1 {
|
|
170
|
+
/** 配置版本,固定为 1。
|
|
171
|
+
* @en Configuration schema version, currently 1.
|
|
172
|
+
*/
|
|
173
|
+
schemaVersion: 1;
|
|
174
|
+
/** 宿主配置修订号,用于标识配置快照。
|
|
175
|
+
* @en Host configuration revision identifying the snapshot.
|
|
176
|
+
*/
|
|
177
|
+
revision?: string;
|
|
178
|
+
/** 能力规则;同一 id 与 slot 不得重复。
|
|
179
|
+
* @en Capability rules; each id and slot pair must be unique.
|
|
180
|
+
*/
|
|
181
|
+
rules: CapabilityRuleV1[];
|
|
182
|
+
}
|
|
183
|
+
export interface SceneConfigLayersV1 {
|
|
184
|
+
/** 配置中心快照;当前实现中只要不可用或过期就锁定编辑。
|
|
185
|
+
* @en Remote configuration snapshot; this version locks editing whenever it is unavailable or expired.
|
|
186
|
+
*/
|
|
187
|
+
remote?: {
|
|
188
|
+
status: 'ready';
|
|
189
|
+
snapshot: SceneConfigInputV1;
|
|
190
|
+
expiresAt: number;
|
|
191
|
+
required: boolean;
|
|
192
|
+
} | {
|
|
193
|
+
status: 'unavailable';
|
|
194
|
+
required: boolean;
|
|
195
|
+
};
|
|
196
|
+
/** 页面级能力覆盖,不能扩大上层权限或限制。
|
|
197
|
+
* @en Page-level capability overrides cannot widen upstream permissions or limits.
|
|
198
|
+
*/
|
|
199
|
+
page?: SceneConfigInputV1;
|
|
200
|
+
}
|
|
201
|
+
export interface HostPolicySnapshotV1 {
|
|
202
|
+
/** 权限快照修订号。
|
|
203
|
+
* @en Authorization snapshot revision.
|
|
204
|
+
*/
|
|
205
|
+
revision: string;
|
|
206
|
+
/** 权限过期时间,Unix 毫秒时间戳。
|
|
207
|
+
* @en Authorization expiry as Unix milliseconds.
|
|
208
|
+
*/
|
|
209
|
+
expiresAt: number;
|
|
210
|
+
/** 允许的能力与可选限制;不在列表中的能力不可插入。
|
|
211
|
+
* @en Allowed capabilities and optional limits; omitted capabilities cannot be inserted.
|
|
212
|
+
*/
|
|
213
|
+
allowed: Array<{
|
|
214
|
+
id: CapabilityId;
|
|
215
|
+
slot: CapabilitySlot;
|
|
216
|
+
options?: unknown;
|
|
217
|
+
}>;
|
|
218
|
+
}
|
|
219
|
+
export interface EditorDiagnostic {
|
|
220
|
+
/** 机器可读的问题代码。
|
|
221
|
+
* @en Machine-readable issue code.
|
|
222
|
+
*/
|
|
223
|
+
code: string;
|
|
224
|
+
/** 提示级别。
|
|
225
|
+
* @en Diagnostic severity.
|
|
226
|
+
*/
|
|
227
|
+
severity: 'info' | 'warning' | 'error';
|
|
228
|
+
/** 问题来源。
|
|
229
|
+
* @en Source of the issue.
|
|
230
|
+
*/
|
|
231
|
+
source: 'config' | 'plugin' | 'port' | 'validation' | 'migration';
|
|
232
|
+
/** 可直接展示的说明。
|
|
233
|
+
* @en Human-readable message.
|
|
234
|
+
*/
|
|
235
|
+
message: string;
|
|
236
|
+
/** 相关场景键。
|
|
237
|
+
* @en Related scene key.
|
|
238
|
+
*/
|
|
239
|
+
sceneKey?: string;
|
|
240
|
+
/** 相关能力 ID。
|
|
241
|
+
* @en Related capability ID.
|
|
242
|
+
*/
|
|
243
|
+
capabilityId?: CapabilityId;
|
|
244
|
+
/** 相关能力位置。
|
|
245
|
+
* @en Related capability placement.
|
|
246
|
+
*/
|
|
247
|
+
slot?: CapabilitySlot;
|
|
248
|
+
/** 出错的数据路径。
|
|
249
|
+
* @en Path to invalid data.
|
|
250
|
+
*/
|
|
251
|
+
path?: string;
|
|
252
|
+
/** 是否可重试。
|
|
253
|
+
* @en Whether the operation may be retried.
|
|
254
|
+
*/
|
|
255
|
+
retryable?: boolean;
|
|
256
|
+
}
|
|
257
|
+
export interface ChangeMeta {
|
|
258
|
+
/** 发生变更的场景键。
|
|
259
|
+
* @en Key of the changed scene.
|
|
260
|
+
*/
|
|
261
|
+
sceneKey: string;
|
|
262
|
+
/** 本实例递增的变更修订号,用于 ackRevision。
|
|
263
|
+
* @en Instance-local change revision used by ackRevision.
|
|
264
|
+
*/
|
|
265
|
+
revision: number;
|
|
266
|
+
/** 变更来源。
|
|
267
|
+
* @en Origin of the change.
|
|
268
|
+
*/
|
|
269
|
+
origin: 'user' | 'plugin' | 'typeSwitch' | 'undo';
|
|
270
|
+
/** 插件变更时的能力 ID。
|
|
271
|
+
* @en Capability ID for a plugin-origin change.
|
|
272
|
+
*/
|
|
273
|
+
capabilityId?: CapabilityId;
|
|
274
|
+
}
|
|
275
|
+
export type PortErrorCode = 'ABORTED' | 'UNAVAILABLE' | 'FORBIDDEN' | 'INVALID_RESPONSE' | 'CONFLICT' | 'TIMEOUT' | 'NETWORK' | 'UNKNOWN';
|
|
276
|
+
export type PortResult<T> = {
|
|
277
|
+
ok: true;
|
|
278
|
+
data: T;
|
|
279
|
+
} | {
|
|
280
|
+
ok: false;
|
|
281
|
+
error: {
|
|
282
|
+
code: PortErrorCode;
|
|
283
|
+
message: string;
|
|
284
|
+
retryable: boolean;
|
|
285
|
+
traceId?: string;
|
|
286
|
+
issues?: EditorDiagnostic[];
|
|
287
|
+
};
|
|
288
|
+
};
|
|
289
|
+
export interface PortRequestContext {
|
|
290
|
+
/** 发起请求的场景键。
|
|
291
|
+
* @en Scene key that initiated the request.
|
|
292
|
+
*/
|
|
293
|
+
sceneKey: string;
|
|
294
|
+
/** 发起请求的能力标识。
|
|
295
|
+
* @en Capability that initiated the request.
|
|
296
|
+
*/
|
|
297
|
+
capabilityId: CapabilityId;
|
|
298
|
+
/** 单次请求标识,可用于日志追踪。
|
|
299
|
+
* @en Per-request ID for tracing.
|
|
300
|
+
*/
|
|
301
|
+
requestId: string;
|
|
302
|
+
/** 场景切换或请求失效时触发的取消信号。
|
|
303
|
+
* @en Abort signal triggered when the scene or request becomes stale.
|
|
304
|
+
*/
|
|
305
|
+
signal: AbortSignal;
|
|
306
|
+
/** 上传端口可调用此函数报告 0–100 的进度。
|
|
307
|
+
* @en Upload ports may report progress from 0 to 100 through this callback.
|
|
308
|
+
*/
|
|
309
|
+
reportProgress?: (percent: number) => void;
|
|
310
|
+
}
|
|
311
|
+
export interface Page<T> {
|
|
312
|
+
/** 当前页的选项,数量不得超过请求的 limit。
|
|
313
|
+
* @en Items in this page; length must not exceed the requested limit.
|
|
314
|
+
*/
|
|
315
|
+
items: T[];
|
|
316
|
+
/** 下一页游标;没有更多数据时省略。同一次查询中不得返回当前或已用过的游标。
|
|
317
|
+
* @en Next-page cursor; omit when complete. Never repeat the current or an earlier cursor in one query.
|
|
318
|
+
*/
|
|
319
|
+
nextCursor?: string;
|
|
320
|
+
}
|
|
321
|
+
export interface CapabilityOption {
|
|
322
|
+
/** 非空白的稳定选项 ID,分页间不得重复。
|
|
323
|
+
* @en Nonblank stable option ID, unique across pages.
|
|
324
|
+
*/
|
|
325
|
+
id: string;
|
|
326
|
+
/** 非空白的显示名称;待办/打标方案名不得含花括号或换行。
|
|
327
|
+
* @en Nonblank display label; todo and tag plan names cannot contain braces or line breaks.
|
|
328
|
+
*/
|
|
329
|
+
label: string;
|
|
330
|
+
/** 禁止选择此项。
|
|
331
|
+
* @en Disable selection of this item.
|
|
332
|
+
* @defaultValue -
|
|
333
|
+
*/
|
|
334
|
+
disabled?: boolean;
|
|
335
|
+
/** 是否有子项;点击后以此项 ID 作为 parentId 请求下级。
|
|
336
|
+
* @en Whether this is a category; request children using its ID as parentId.
|
|
337
|
+
* @defaultValue -
|
|
338
|
+
*/
|
|
339
|
+
hasChildren?: boolean;
|
|
340
|
+
/** 推理模板的可选纯文本预览。
|
|
341
|
+
* @en Optional plain-text preview for a reasoning template.
|
|
342
|
+
*/
|
|
343
|
+
preview?: string;
|
|
344
|
+
}
|
|
345
|
+
export interface ToolFormField {
|
|
346
|
+
/** 字段键,对应工具节点 params 的属性名。
|
|
347
|
+
* @en Field key in the tool node's params.
|
|
348
|
+
*/
|
|
349
|
+
id: string;
|
|
350
|
+
/** 非空白的字段显示名,也用作隐藏视觉标签时的无障碍名称。
|
|
351
|
+
* @en Nonblank field label, also used as the accessible name when visually hidden.
|
|
352
|
+
*/
|
|
353
|
+
label: string;
|
|
354
|
+
/** 字段输入形式。
|
|
355
|
+
* @en Field input control.
|
|
356
|
+
*/
|
|
357
|
+
kind: 'text' | 'number' | 'switch' | 'textarea' | 'radio' | 'checkbox';
|
|
358
|
+
/** 是否必填。
|
|
359
|
+
* @en Whether the field is required.
|
|
360
|
+
* @defaultValue -
|
|
361
|
+
*/
|
|
362
|
+
required?: boolean;
|
|
363
|
+
/** 输入提示。
|
|
364
|
+
* @en Input placeholder.
|
|
365
|
+
*/
|
|
366
|
+
placeholder?: string;
|
|
367
|
+
/** 数值下限。
|
|
368
|
+
* @en Numeric minimum.
|
|
369
|
+
*/
|
|
370
|
+
min?: number;
|
|
371
|
+
/** 数值上限。
|
|
372
|
+
* @en Numeric maximum.
|
|
373
|
+
*/
|
|
374
|
+
max?: number;
|
|
375
|
+
/** 文本最大字符数。
|
|
376
|
+
* @en Maximum text length.
|
|
377
|
+
*/
|
|
378
|
+
maxLength?: number;
|
|
379
|
+
/** 单选项;旗帜色仅接受十六进制颜色。
|
|
380
|
+
* @en Radio choices; flag colors accept hexadecimal values only.
|
|
381
|
+
*/
|
|
382
|
+
options?: Array<{
|
|
383
|
+
value: string;
|
|
384
|
+
label: string;
|
|
385
|
+
color?: string;
|
|
386
|
+
}>;
|
|
387
|
+
/** 初次插入时的默认值。
|
|
388
|
+
* @en Default value for a new tool token.
|
|
389
|
+
*/
|
|
390
|
+
defaultValue?: string | boolean;
|
|
391
|
+
/** 隐藏视觉标签,保留输入控件的无障碍名称。
|
|
392
|
+
* @en Hide the visual label while keeping the control's accessible name.
|
|
393
|
+
*/
|
|
394
|
+
hideLabel?: boolean;
|
|
395
|
+
/** 旗帜色单选项样式。
|
|
396
|
+
* @en Flag-style radio choices.
|
|
397
|
+
*/
|
|
398
|
+
appearance?: 'flag';
|
|
399
|
+
/** 仅当前置字段等于指定值时显示此字段。
|
|
400
|
+
* @en Show this field only when an earlier field matches the value.
|
|
401
|
+
*/
|
|
402
|
+
visibleWhen?: {
|
|
403
|
+
fieldId: string;
|
|
404
|
+
equals: string | boolean;
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
export interface ToolFormDefinition {
|
|
408
|
+
/** 工具 ID,应与请求一致。
|
|
409
|
+
* @en Tool ID, matching the request.
|
|
410
|
+
*/
|
|
411
|
+
toolId: string;
|
|
412
|
+
/** 当前用户是否有权插入此工具。
|
|
413
|
+
* @en Whether the current user may insert this tool.
|
|
414
|
+
* @defaultValue -
|
|
415
|
+
*/
|
|
416
|
+
permitted: boolean;
|
|
417
|
+
/** 表单字段列表;未声明的字段及嵌套配置会被拒绝,避免静默忽略业务设置。
|
|
418
|
+
* @en Dynamic form fields; undeclared fields and nested settings are rejected rather than silently ignored.
|
|
419
|
+
*/
|
|
420
|
+
fields: ToolFormField[];
|
|
421
|
+
}
|
|
422
|
+
export interface VariableOption extends CapabilityOption {
|
|
423
|
+
/** 可选的变量分组;同组变量在选择浮层右栏展示,未分组变量留在左栏。
|
|
424
|
+
* @en Optional display group; grouped variables appear in the right column, ungrouped variables in the left.
|
|
425
|
+
*/
|
|
426
|
+
group?: string;
|
|
427
|
+
/** 非空白的变量协议文本,插入知识正文。
|
|
428
|
+
* @en Nonblank variable token inserted into the knowledge document.
|
|
429
|
+
*/
|
|
430
|
+
token: string;
|
|
431
|
+
}
|
|
432
|
+
export interface AgentSummary {
|
|
433
|
+
/** 自定义 Agent 的稳定 ID。
|
|
434
|
+
* @en Stable custom Agent ID.
|
|
435
|
+
*/
|
|
436
|
+
id: string;
|
|
437
|
+
/** 非空白的 Agent 显示名称。
|
|
438
|
+
* @en Nonblank Agent display name.
|
|
439
|
+
*/
|
|
440
|
+
name: string;
|
|
441
|
+
}
|
|
442
|
+
export interface AgentPrompt extends AgentSummary {
|
|
443
|
+
/** Agent 的只读提示词预览。
|
|
444
|
+
* @en Read-only preview of the Agent prompt.
|
|
445
|
+
*/
|
|
446
|
+
prompt: string;
|
|
447
|
+
/** 可选的 Agent 提示词版本。
|
|
448
|
+
* @en Optional Agent prompt revision.
|
|
449
|
+
*/
|
|
450
|
+
revision?: string;
|
|
451
|
+
}
|
|
452
|
+
export interface MediaAsset {
|
|
453
|
+
/** 持久化资源 ID。
|
|
454
|
+
* @en Persisted asset ID.
|
|
455
|
+
*/
|
|
456
|
+
id?: string;
|
|
457
|
+
/** 可展示的资源 URL。
|
|
458
|
+
* @en Renderable asset URL.
|
|
459
|
+
*/
|
|
460
|
+
url: string;
|
|
461
|
+
/** 资源类型。
|
|
462
|
+
* @en Asset kind.
|
|
463
|
+
*/
|
|
464
|
+
kind: 'image' | 'video';
|
|
465
|
+
/** 视频封面 URL。
|
|
466
|
+
* @en Video poster URL.
|
|
467
|
+
*/
|
|
468
|
+
posterUrl?: string;
|
|
469
|
+
}
|
|
470
|
+
export interface RichTextHostPorts {
|
|
471
|
+
/** 分页查询变量,返回含 token 的平铺变量选项;可用 group 在前端分栏。
|
|
472
|
+
* @en Search flat, paged variable options with tokens; group controls the client-side columns.
|
|
473
|
+
*/
|
|
474
|
+
listVariables?: (query: {
|
|
475
|
+
search?: string;
|
|
476
|
+
cursor?: string;
|
|
477
|
+
limit: number;
|
|
478
|
+
}, ctx: PortRequestContext) => Promise<PortResult<Page<VariableOption>>>;
|
|
479
|
+
/** 上传图片或视频,返回可保存的资源标识与 URL。
|
|
480
|
+
* @en Upload an image or video and return its persisted asset identity and URL.
|
|
481
|
+
*/
|
|
482
|
+
uploadMedia?: (input: {
|
|
483
|
+
file: File;
|
|
484
|
+
kind: 'image' | 'video';
|
|
485
|
+
}, ctx: PortRequestContext) => Promise<PortResult<MediaAsset>>;
|
|
486
|
+
/** 分页搜索可选的自定义 Agent。
|
|
487
|
+
* @en Search selectable custom Agents with pagination.
|
|
488
|
+
*/
|
|
489
|
+
searchAgents?: (query: {
|
|
490
|
+
search?: string;
|
|
491
|
+
cursor?: string;
|
|
492
|
+
limit: number;
|
|
493
|
+
}, ctx: PortRequestContext) => Promise<PortResult<Page<AgentSummary>>>;
|
|
494
|
+
/** 获取所选 Agent 的名称与提示词。
|
|
495
|
+
* @en Load the selected Agent's name and prompt.
|
|
496
|
+
*/
|
|
497
|
+
getAgentPrompt?: (input: {
|
|
498
|
+
agentId: string;
|
|
499
|
+
}, ctx: PortRequestContext) => Promise<PortResult<AgentPrompt>>;
|
|
500
|
+
/** 查询待办、工单、打标、属性、工具和推理模板等能力选项;工单使用 capabilityId: 'ticket'。
|
|
501
|
+
* @en Query options for todo, tickets, tagging, attributes, tools, and reasoning templates; tickets use capabilityId: 'ticket'.
|
|
502
|
+
*/
|
|
503
|
+
listCapabilityOptions?: (input: {
|
|
504
|
+
capabilityId: string;
|
|
505
|
+
parentId?: string;
|
|
506
|
+
search?: string;
|
|
507
|
+
cursor?: string;
|
|
508
|
+
limit: number;
|
|
509
|
+
}, ctx: PortRequestContext) => Promise<PortResult<Page<CapabilityOption>>>;
|
|
510
|
+
/** 提出润色后的推理正文,不直接覆盖当前内容。
|
|
511
|
+
* @en Propose polished reasoning content without directly replacing the current document.
|
|
512
|
+
*/
|
|
513
|
+
proposeReasoning?: (input: {
|
|
514
|
+
scene: KnowledgeSceneV1;
|
|
515
|
+
}, ctx: PortRequestContext) => Promise<PortResult<{
|
|
516
|
+
proposedDoc: JSONContent;
|
|
517
|
+
explanation?: string;
|
|
518
|
+
}>>;
|
|
519
|
+
/** 根据模板 ID 获取问法与 Tiptap JSON 正文。
|
|
520
|
+
* @en Load a template's question and Tiptap JSON document by ID.
|
|
521
|
+
*/
|
|
522
|
+
getReasoningTemplate?: (input: {
|
|
523
|
+
templateId: string;
|
|
524
|
+
}, ctx: PortRequestContext) => Promise<PortResult<{
|
|
525
|
+
question: string;
|
|
526
|
+
doc: JSONContent;
|
|
527
|
+
}>>;
|
|
528
|
+
/** 获取工具权限及动态表单字段;宿主须在此校验业务权限。
|
|
529
|
+
* @en Load tool permission and dynamic fields; the host must enforce business access here.
|
|
530
|
+
*/
|
|
531
|
+
getToolForm?: (input: {
|
|
532
|
+
toolId: string;
|
|
533
|
+
}, ctx: PortRequestContext) => Promise<PortResult<ToolFormDefinition>>;
|
|
534
|
+
/** 打开已选 Agent 的配置页;应在点击回调开始时同步新开标签页。
|
|
535
|
+
* @en Open the selected Agent's configuration in a new tab synchronously on click.
|
|
536
|
+
*/
|
|
537
|
+
openAgentConfig?: (input: {
|
|
538
|
+
agentId: string;
|
|
539
|
+
target: '_blank';
|
|
540
|
+
}, ctx: PortRequestContext) => Promise<PortResult<void>>;
|
|
541
|
+
}
|
|
542
|
+
export interface FkpRichTextProps {
|
|
543
|
+
/** 场景的稳定键,同一条件内唯一;切换键会重置当前交互状态。
|
|
544
|
+
* @en Stable scene key, unique within a condition; changing it resets transient UI state.
|
|
545
|
+
* @defaultValue 'default'
|
|
546
|
+
*/
|
|
547
|
+
sceneKey: string;
|
|
548
|
+
/** 受控的单场景数据;通过 update:modelValue 回写。
|
|
549
|
+
* @en Controlled single-scene data, updated through update:modelValue.
|
|
550
|
+
* @defaultValue emptyScene()
|
|
551
|
+
*/
|
|
552
|
+
modelValue: KnowledgeSceneV1;
|
|
553
|
+
/** 配置中心和页面级能力规则。
|
|
554
|
+
* @en Remote and page-level capability rules.
|
|
555
|
+
*/
|
|
556
|
+
config?: SceneConfigLayersV1;
|
|
557
|
+
/** 宿主权限快照;过期或无效时禁止编辑。
|
|
558
|
+
* @en Host authorization snapshot; expired or invalid snapshots lock editing.
|
|
559
|
+
*/
|
|
560
|
+
policy?: HostPolicySnapshotV1;
|
|
561
|
+
/** 宿主提供的异步业务接口;组件不直接发 HTTP 请求。
|
|
562
|
+
* @en Asynchronous host business ports; the component makes no direct HTTP calls.
|
|
563
|
+
*/
|
|
564
|
+
ports?: RichTextHostPorts;
|
|
565
|
+
/** 宿主已接收的 change 修订号;配合受控回显避免旧值覆盖新编辑。
|
|
566
|
+
* @en Last acknowledged change revision, preventing stale controlled echoes.
|
|
567
|
+
* @defaultValue 0
|
|
568
|
+
*/
|
|
569
|
+
ackRevision?: number;
|
|
570
|
+
/** 只读展示。
|
|
571
|
+
* @en Read-only rendering.
|
|
572
|
+
* @defaultValue false
|
|
573
|
+
*/
|
|
574
|
+
readonly?: boolean;
|
|
575
|
+
/** 禁用编辑交互。
|
|
576
|
+
* @en Disable editing interactions.
|
|
577
|
+
* @defaultValue false
|
|
578
|
+
*/
|
|
579
|
+
disabled?: boolean;
|
|
580
|
+
}
|
|
581
|
+
export interface FkpRichTextHandle {
|
|
582
|
+
/** 撤销最近一次尚未被后续编辑覆盖的知识类型切换。
|
|
583
|
+
* @en Undo the most recent uninterrupted knowledge type switch.
|
|
584
|
+
*/
|
|
585
|
+
undoTypeSwitch(): boolean;
|
|
586
|
+
}
|
|
587
|
+
export declare const emptyDoc: () => JSONContent;
|
|
588
|
+
export declare const emptyScene: (type?: KnowledgeType) => KnowledgeSceneV1;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { hostActions, CapabilityDescriptor } from '../config/descriptor';
|
|
2
|
+
import { RichTextHostPorts } from '../public/types';
|
|
3
|
+
type HostAction = (typeof hostActions)[keyof typeof hostActions];
|
|
4
|
+
export type HostActionId = HostAction['id'];
|
|
5
|
+
type HostActionPort<A extends HostActionId> = Extract<HostAction, {
|
|
6
|
+
id: A;
|
|
7
|
+
}>['requiredPorts'][number];
|
|
8
|
+
export type ActionPorts<A extends HostActionId> = Readonly<Required<Pick<RichTextHostPorts, HostActionPort<A>>>>;
|
|
9
|
+
/** Only callbacks named by this action enter its execution context. */
|
|
10
|
+
export declare function projectDeclaredPorts(descriptor: CapabilityDescriptor, actionId: string, ports: RichTextHostPorts | undefined): Readonly<Partial<RichTextHostPorts>> | null;
|
|
11
|
+
/** Read-only view data is projected without creating an editor action. */
|
|
12
|
+
export declare function projectReadPorts(descriptor: CapabilityDescriptor, ports: RichTextHostPorts | undefined): Readonly<Partial<RichTextHostPorts>> | null;
|
|
13
|
+
/** Typed host wrapper; the runtime port list comes from the descriptor. */
|
|
14
|
+
export declare function projectActionPorts<A extends HostActionId>(actionId: A, ports: RichTextHostPorts | undefined): ActionPorts<A> | null;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Editor, JSONContent } from '@tiptap/core';
|
|
2
|
+
export interface MediaTarget {
|
|
3
|
+
insert(content: JSONContent | JSONContent[]): boolean;
|
|
4
|
+
status(): 'ready' | 'lost' | 'disposed';
|
|
5
|
+
dispose(): void;
|
|
6
|
+
}
|
|
7
|
+
export declare function captureMediaTarget(editor: Editor): MediaTarget;
|
|
8
|
+
export declare function captureMediaTargetAt(editor: Editor, clientX: number, clientY: number): MediaTarget | null;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ResolvedCapability } from '../config/resolve';
|
|
2
|
+
import { MediaTarget } from './media-target';
|
|
3
|
+
import { MediaNodeState } from './media-state';
|
|
4
|
+
import { PluginPlan } from './operations';
|
|
5
|
+
import { KnowledgeSceneV1, PortRequestContext, PortResult, RichTextHostPorts } from '../public/types';
|
|
6
|
+
import { MediaKind } from '../model/node-contract';
|
|
7
|
+
type PortError = Extract<PortResult<unknown>, {
|
|
8
|
+
ok: false;
|
|
9
|
+
}>['error'];
|
|
10
|
+
type UpdatePlan = Extract<PluginPlan, {
|
|
11
|
+
kind: 'updateNode';
|
|
12
|
+
}>;
|
|
13
|
+
interface MediaEditor {
|
|
14
|
+
insertPendingMedia(file: File, kind: MediaKind, target: MediaTarget): string | null;
|
|
15
|
+
getMediaState(id: string): MediaNodeState | null;
|
|
16
|
+
failMedia(id: string, message: string, expectedVersion: number): boolean;
|
|
17
|
+
retryMedia(id: string, expectedVersion: number): boolean;
|
|
18
|
+
reportMediaProgress(id: string, expectedVersion: number, percent: number): boolean;
|
|
19
|
+
focus(): void;
|
|
20
|
+
}
|
|
21
|
+
export interface UploadRetention {
|
|
22
|
+
active: Set<string>;
|
|
23
|
+
files: Set<string>;
|
|
24
|
+
markFailed: Array<{
|
|
25
|
+
id: string;
|
|
26
|
+
nodeVersion: number;
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
export interface MediaUploadSessionHost {
|
|
30
|
+
editor(): MediaEditor | undefined;
|
|
31
|
+
capability(kind: MediaKind): ResolvedCapability | undefined;
|
|
32
|
+
canUse(kind: MediaKind): boolean;
|
|
33
|
+
scene(): {
|
|
34
|
+
scene: KnowledgeSceneV1;
|
|
35
|
+
sceneKey: string;
|
|
36
|
+
revision: number;
|
|
37
|
+
};
|
|
38
|
+
sceneKey(): string;
|
|
39
|
+
ports(): RichTextHostPorts | undefined;
|
|
40
|
+
context(kind: MediaKind, controller: AbortController): PortRequestContext;
|
|
41
|
+
track(controller: AbortController, start: boolean): void;
|
|
42
|
+
diagnostic(code: string, message: string, source: 'config' | 'plugin' | 'port' | 'validation', kind?: MediaKind): void;
|
|
43
|
+
portDiagnostic(error: PortError, kind: MediaKind): void;
|
|
44
|
+
applyNodeUpdate(plan: UpdatePlan, kind: MediaKind): boolean;
|
|
45
|
+
}
|
|
46
|
+
/** Owns upload files, selection bookmark, and async completion across scene changes. */
|
|
47
|
+
export declare function createMediaUploadSession(host: MediaUploadSessionHost): {
|
|
48
|
+
selectTarget: (target: MediaTarget | null) => void;
|
|
49
|
+
takeTarget: () => MediaTarget | null;
|
|
50
|
+
clearTarget: () => void;
|
|
51
|
+
has: (id: string) => boolean;
|
|
52
|
+
removeAbsent: (present: ReadonlySet<string>) => void;
|
|
53
|
+
classify: (currentScene: KnowledgeSceneV1, next: KnowledgeSceneV1) => UploadRetention;
|
|
54
|
+
activeControllers: (active: ReadonlySet<string>) => Set<AbortController>;
|
|
55
|
+
retain: (retention?: UploadRetention) => void;
|
|
56
|
+
enqueue: (files: File[], target: MediaTarget, requestedKind?: MediaKind, restoreFocus?: boolean) => Promise<void>;
|
|
57
|
+
retry: (id: string) => void;
|
|
58
|
+
};
|
|
59
|
+
export {};
|