@huyooo/ai-chat-core 0.3.6 → 0.3.8
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/dist/adapter/index.d.ts +0 -1
- package/dist/adapter/model-adapter.d.ts +0 -1
- package/dist/adapter/model-options.d.ts +0 -1
- package/dist/adapter/types.d.ts +0 -1
- package/dist/chat-runtime.d.ts +0 -1
- package/dist/constants.d.ts +0 -1
- package/dist/events.d.ts +0 -1
- package/dist/extension/index.d.ts +0 -1
- package/dist/extension/types.d.ts +0 -1
- package/dist/families/index.d.ts +0 -1
- package/dist/families/presets.d.ts +0 -1
- package/dist/families/resolver.d.ts +0 -1
- package/dist/families/types.d.ts +0 -1
- package/dist/governance/command-safety.d.ts +0 -1
- package/dist/governance/governance.d.ts +0 -1
- package/dist/governance/index.d.ts +0 -1
- package/dist/governance/types.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/internal/management-args.d.ts +0 -1
- package/dist/internal/management-results.d.ts +0 -1
- package/dist/llm-config.d.ts +0 -1
- package/dist/logger/core.d.ts +0 -1
- package/dist/logger/index.d.ts +0 -1
- package/dist/orchestrator/compression-handler.d.ts +0 -1
- package/dist/orchestrator/context-compressor.d.ts +0 -1
- package/dist/orchestrator/context-summarizer.d.ts +0 -1
- package/dist/orchestrator/index.d.ts +0 -1
- package/dist/orchestrator/orchestrator.d.ts +0 -1
- package/dist/orchestrator/types.d.ts +0 -1
- package/dist/parts/index.d.ts +0 -1
- package/dist/parts/registry.d.ts +0 -1
- package/dist/parts/summaries.d.ts +0 -1
- package/dist/parts/types.d.ts +0 -1
- package/dist/platform.d.ts +0 -1
- package/dist/protocols/anthropic.d.ts +0 -1
- package/dist/protocols/ark.d.ts +0 -1
- package/dist/protocols/deepseek.d.ts +0 -1
- package/dist/protocols/error-utils.d.ts +0 -1
- package/dist/protocols/gemini.d.ts +0 -1
- package/dist/protocols/glm.d.ts +0 -1
- package/dist/protocols/grok.d.ts +0 -1
- package/dist/protocols/index.d.ts +0 -1
- package/dist/protocols/minimax.d.ts +0 -1
- package/dist/protocols/moonshot.d.ts +0 -1
- package/dist/protocols/openai-sse.d.ts +0 -1
- package/dist/protocols/openai.d.ts +0 -1
- package/dist/protocols/qwen.d.ts +0 -1
- package/dist/protocols/responses-sse.d.ts +0 -1
- package/dist/protocols/sse-reader.d.ts +0 -1
- package/dist/protocols/tool-arguments.d.ts +0 -1
- package/dist/protocols/types.d.ts +0 -1
- package/dist/protocols/vercel-gateway.d.ts +0 -1
- package/dist/runtime.d.ts +0 -1
- package/dist/skills/index.d.ts +0 -1
- package/dist/skills/management/admin.d.ts +0 -1
- package/dist/skills/management/index.d.ts +0 -1
- package/dist/skills/management/inputs.d.ts +0 -1
- package/dist/skills/management/operations.d.ts +0 -1
- package/dist/skills/management/types.d.ts +0 -1
- package/dist/skills/registry.d.ts +0 -1
- package/dist/skills/summaries.d.ts +0 -1
- package/dist/skills/types.d.ts +0 -1
- package/dist/test-utils/mock-sse.d.ts +0 -1
- package/dist/tool-manager/define-tool.d.ts +0 -1
- package/dist/tool-manager/formats.d.ts +0 -1
- package/dist/tool-manager/identity.d.ts +0 -1
- package/dist/tool-manager/in-process-provider.d.ts +0 -1
- package/dist/tool-manager/index.d.ts +0 -1
- package/dist/tool-manager/manager.d.ts +0 -1
- package/dist/tool-manager/mcp-provider.d.ts +0 -1
- package/dist/tool-manager/summaries.d.ts +0 -1
- package/dist/tool-manager/types.d.ts +0 -1
- package/dist/types.d.ts +0 -1
- package/package.json +2 -3
- package/dist/adapter/index.d.ts.map +0 -1
- package/dist/adapter/model-adapter.d.ts.map +0 -1
- package/dist/adapter/model-options.d.ts.map +0 -1
- package/dist/adapter/types.d.ts.map +0 -1
- package/dist/chat-runtime.d.ts.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/events.d.ts.map +0 -1
- package/dist/extension/index.d.ts.map +0 -1
- package/dist/extension/types.d.ts.map +0 -1
- package/dist/families/index.d.ts.map +0 -1
- package/dist/families/presets.d.ts.map +0 -1
- package/dist/families/resolver.d.ts.map +0 -1
- package/dist/families/types.d.ts.map +0 -1
- package/dist/governance/command-safety.d.ts.map +0 -1
- package/dist/governance/governance.d.ts.map +0 -1
- package/dist/governance/index.d.ts.map +0 -1
- package/dist/governance/types.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/internal/management-args.d.ts.map +0 -1
- package/dist/internal/management-results.d.ts.map +0 -1
- package/dist/llm-config.d.ts.map +0 -1
- package/dist/logger/core.d.ts.map +0 -1
- package/dist/logger/index.d.ts.map +0 -1
- package/dist/orchestrator/compression-handler.d.ts.map +0 -1
- package/dist/orchestrator/context-compressor.d.ts.map +0 -1
- package/dist/orchestrator/context-summarizer.d.ts.map +0 -1
- package/dist/orchestrator/index.d.ts.map +0 -1
- package/dist/orchestrator/orchestrator.d.ts.map +0 -1
- package/dist/orchestrator/types.d.ts.map +0 -1
- package/dist/parts/index.d.ts.map +0 -1
- package/dist/parts/registry.d.ts.map +0 -1
- package/dist/parts/summaries.d.ts.map +0 -1
- package/dist/parts/types.d.ts.map +0 -1
- package/dist/platform.d.ts.map +0 -1
- package/dist/protocols/anthropic.d.ts.map +0 -1
- package/dist/protocols/ark.d.ts.map +0 -1
- package/dist/protocols/deepseek.d.ts.map +0 -1
- package/dist/protocols/error-utils.d.ts.map +0 -1
- package/dist/protocols/gemini.d.ts.map +0 -1
- package/dist/protocols/glm.d.ts.map +0 -1
- package/dist/protocols/grok.d.ts.map +0 -1
- package/dist/protocols/index.d.ts.map +0 -1
- package/dist/protocols/minimax.d.ts.map +0 -1
- package/dist/protocols/moonshot.d.ts.map +0 -1
- package/dist/protocols/openai-sse.d.ts.map +0 -1
- package/dist/protocols/openai.d.ts.map +0 -1
- package/dist/protocols/qwen.d.ts.map +0 -1
- package/dist/protocols/responses-sse.d.ts.map +0 -1
- package/dist/protocols/sse-reader.d.ts.map +0 -1
- package/dist/protocols/tool-arguments.d.ts.map +0 -1
- package/dist/protocols/types.d.ts.map +0 -1
- package/dist/protocols/vercel-gateway.d.ts.map +0 -1
- package/dist/runtime.d.ts.map +0 -1
- package/dist/skills/index.d.ts.map +0 -1
- package/dist/skills/management/admin.d.ts.map +0 -1
- package/dist/skills/management/index.d.ts.map +0 -1
- package/dist/skills/management/inputs.d.ts.map +0 -1
- package/dist/skills/management/operations.d.ts.map +0 -1
- package/dist/skills/management/types.d.ts.map +0 -1
- package/dist/skills/registry.d.ts.map +0 -1
- package/dist/skills/summaries.d.ts.map +0 -1
- package/dist/skills/types.d.ts.map +0 -1
- package/dist/test-utils/mock-sse.d.ts.map +0 -1
- package/dist/tool-manager/define-tool.d.ts.map +0 -1
- package/dist/tool-manager/formats.d.ts.map +0 -1
- package/dist/tool-manager/identity.d.ts.map +0 -1
- package/dist/tool-manager/in-process-provider.d.ts.map +0 -1
- package/dist/tool-manager/index.d.ts.map +0 -1
- package/dist/tool-manager/manager.d.ts.map +0 -1
- package/dist/tool-manager/mcp-provider.d.ts.map +0 -1
- package/dist/tool-manager/summaries.d.ts.map +0 -1
- package/dist/tool-manager/types.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/src/adapter/index.ts +0 -25
- package/src/adapter/model-adapter.ts +0 -196
- package/src/adapter/model-options.ts +0 -143
- package/src/adapter/types.ts +0 -41
- package/src/chat-runtime.ts +0 -515
- package/src/constants.ts +0 -32
- package/src/events.ts +0 -1084
- package/src/extension/index.ts +0 -24
- package/src/extension/types.ts +0 -49
- package/src/families/index.ts +0 -28
- package/src/families/presets.ts +0 -124
- package/src/families/resolver.ts +0 -22
- package/src/families/types.ts +0 -55
- package/src/governance/command-safety.ts +0 -224
- package/src/governance/governance.ts +0 -125
- package/src/governance/index.ts +0 -38
- package/src/governance/types.ts +0 -44
- package/src/index.ts +0 -426
- package/src/internal/management-args.ts +0 -39
- package/src/internal/management-results.ts +0 -60
- package/src/llm-config.ts +0 -137
- package/src/logger/core.ts +0 -96
- package/src/logger/index.ts +0 -8
- package/src/orchestrator/compression-handler.ts +0 -137
- package/src/orchestrator/context-compressor.ts +0 -249
- package/src/orchestrator/context-summarizer.ts +0 -123
- package/src/orchestrator/index.ts +0 -20
- package/src/orchestrator/orchestrator.ts +0 -1002
- package/src/orchestrator/types.ts +0 -70
- package/src/parts/index.ts +0 -20
- package/src/parts/registry.ts +0 -95
- package/src/parts/summaries.ts +0 -40
- package/src/parts/types.ts +0 -63
- package/src/platform.ts +0 -73
- package/src/protocols/anthropic.ts +0 -377
- package/src/protocols/ark.ts +0 -300
- package/src/protocols/deepseek.ts +0 -192
- package/src/protocols/error-utils.ts +0 -71
- package/src/protocols/gemini.ts +0 -352
- package/src/protocols/glm.ts +0 -212
- package/src/protocols/grok.ts +0 -98
- package/src/protocols/index.ts +0 -48
- package/src/protocols/minimax.ts +0 -308
- package/src/protocols/moonshot.ts +0 -186
- package/src/protocols/openai-sse.ts +0 -156
- package/src/protocols/openai.ts +0 -97
- package/src/protocols/qwen.ts +0 -358
- package/src/protocols/responses-sse.ts +0 -224
- package/src/protocols/sse-reader.ts +0 -54
- package/src/protocols/tool-arguments.ts +0 -32
- package/src/protocols/types.ts +0 -198
- package/src/protocols/vercel-gateway.ts +0 -391
- package/src/runtime.ts +0 -167
- package/src/skills/index.ts +0 -29
- package/src/skills/management/admin.ts +0 -170
- package/src/skills/management/index.ts +0 -27
- package/src/skills/management/inputs.ts +0 -79
- package/src/skills/management/operations.ts +0 -256
- package/src/skills/management/types.ts +0 -57
- package/src/skills/registry.ts +0 -120
- package/src/skills/summaries.ts +0 -48
- package/src/skills/types.ts +0 -65
- package/src/test-utils/mock-sse.ts +0 -32
- package/src/tool-manager/define-tool.ts +0 -201
- package/src/tool-manager/formats.ts +0 -146
- package/src/tool-manager/identity.ts +0 -80
- package/src/tool-manager/in-process-provider.ts +0 -164
- package/src/tool-manager/index.ts +0 -63
- package/src/tool-manager/manager.ts +0 -562
- package/src/tool-manager/mcp-provider.ts +0 -509
- package/src/tool-manager/summaries.ts +0 -136
- package/src/tool-manager/types.ts +0 -389
- package/src/types.ts +0 -1142
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Orchestrator 层类型定义
|
|
3
|
-
*
|
|
4
|
-
* 编排器拥有的类型:配置、上下文、选项、工具执行钩子
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { ChatMessage, Tool, ToolApprovalCallback, AutoRunConfig, ToolGovernanceSnapshot } from '../types';
|
|
8
|
-
import type { ProtocolToolDefinition } from '../protocols/types';
|
|
9
|
-
import type { LLMConfig, CompressionConfig } from '../llm-config';
|
|
10
|
-
import type { ToolDescriptor } from '../tool-manager/types';
|
|
11
|
-
|
|
12
|
-
export interface ToolExecutionHooks {
|
|
13
|
-
toolCallId: string;
|
|
14
|
-
toolName: string;
|
|
15
|
-
allowedToolNames?: readonly string[];
|
|
16
|
-
governance?: ToolGovernanceSnapshot;
|
|
17
|
-
onStdout?: (chunk: string) => void;
|
|
18
|
-
onStderr?: (chunk: string) => void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type OrchestratorToolExecutor = (
|
|
22
|
-
name: string,
|
|
23
|
-
args: Record<string, unknown>,
|
|
24
|
-
signal?: AbortSignal,
|
|
25
|
-
hooks?: ToolExecutionHooks
|
|
26
|
-
) => Promise<object>;
|
|
27
|
-
|
|
28
|
-
export type { ToolApprovalCallback, AutoRunConfig };
|
|
29
|
-
|
|
30
|
-
export type GetAutoRunConfigCallback = () => Promise<AutoRunConfig | undefined>;
|
|
31
|
-
|
|
32
|
-
export interface OrchestratorConfig {
|
|
33
|
-
/** 最大模型轮次;默认不限制 */
|
|
34
|
-
maxIterations?: number;
|
|
35
|
-
/** 最大总执行时长(毫秒);默认不限制 */
|
|
36
|
-
maxDurationMs?: number;
|
|
37
|
-
/** 最大工具调用次数;默认不限制 */
|
|
38
|
-
maxToolCalls?: number;
|
|
39
|
-
/** 最大累计 token 数;默认不限制 */
|
|
40
|
-
maxTotalTokens?: number;
|
|
41
|
-
executeTool: OrchestratorToolExecutor;
|
|
42
|
-
tools?: Map<string, Tool>;
|
|
43
|
-
getToolDescriptor?: (name: string) => ToolDescriptor | undefined;
|
|
44
|
-
autoRunConfig?: AutoRunConfig;
|
|
45
|
-
getAutoRunConfig?: GetAutoRunConfigCallback;
|
|
46
|
-
onToolApprovalRequest?: ToolApprovalCallback;
|
|
47
|
-
summarize?: (systemPrompt: string, userPrompt: string, model: string) => Promise<string>;
|
|
48
|
-
compressionConfig?: CompressionConfig;
|
|
49
|
-
llmConfig?: LLMConfig;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface OrchestratorContext {
|
|
53
|
-
systemPrompt: string;
|
|
54
|
-
history: ChatMessage[];
|
|
55
|
-
tools: ProtocolToolDefinition[];
|
|
56
|
-
refreshTools?: () => Promise<ProtocolToolDefinition[]>;
|
|
57
|
-
signal: AbortSignal;
|
|
58
|
-
images?: string[];
|
|
59
|
-
clientToolNames?: Set<string>;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export interface OrchestratorOptions {
|
|
63
|
-
model: string;
|
|
64
|
-
enableThinking?: boolean;
|
|
65
|
-
autoRunConfig?: AutoRunConfig;
|
|
66
|
-
maxIterations?: number;
|
|
67
|
-
maxDurationMs?: number;
|
|
68
|
-
maxToolCalls?: number;
|
|
69
|
-
maxTotalTokens?: number;
|
|
70
|
-
}
|
package/src/parts/index.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 可管理的「Part 资产」元数据(PartRegistry / PartMeta)
|
|
3
|
-
*
|
|
4
|
-
* 与聊天消息里的 **ContentPart** 不是同一概念:这里只描述 **扩展或本地 Part 工程**
|
|
5
|
-
*(磁盘目录 `parts/<name>/`、构建产物等)在管理面的索引,供宿主(如 SuperX)扩展管理 UI 展示。
|
|
6
|
-
*
|
|
7
|
-
* **市场/用户扩展里的可视化 Part** 由扩展包提供;**不在**本模块里实现具体渲染器。
|
|
8
|
-
* 消息流中的渲染顺序见 `@huyooo/ai-chat-frontend-vue` 的 `PartsRenderer`(`partRenderers` + `loadPartCode`)。
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
export type {
|
|
12
|
-
PartMeta,
|
|
13
|
-
PartSearchQuery,
|
|
14
|
-
PartRegistry,
|
|
15
|
-
ManagedPartSummary,
|
|
16
|
-
ManagedPartDetail,
|
|
17
|
-
} from './types';
|
|
18
|
-
|
|
19
|
-
export { partRegistry } from './registry';
|
|
20
|
-
export { createManagedPartSummary, createManagedPartDetail } from './summaries';
|
package/src/parts/registry.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Part Registry - UI 组件注册表
|
|
3
|
-
*
|
|
4
|
-
* 纯内存索引,存储 PartMeta。
|
|
5
|
-
* 结构与 SkillRegistry 一致:
|
|
6
|
-
* - 有 enabled 状态
|
|
7
|
-
* - 搜索支持 enabledOnly 过滤
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type { PartMeta, PartSearchQuery, PartRegistry } from './types';
|
|
11
|
-
|
|
12
|
-
function matchesKeyword(meta: PartMeta, keyword: string): boolean {
|
|
13
|
-
const lower = keyword.toLowerCase();
|
|
14
|
-
if (meta.name.toLowerCase().includes(lower)) return true;
|
|
15
|
-
if (meta.description.toLowerCase().includes(lower)) return true;
|
|
16
|
-
if (meta.category.toLowerCase().includes(lower)) return true;
|
|
17
|
-
if (meta.tags.some(t => t.toLowerCase().includes(lower))) return true;
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function partRegistry(): PartRegistry {
|
|
22
|
-
const store = new Map<string, PartMeta>();
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
add(meta) {
|
|
26
|
-
store.set(meta.name, { ...meta });
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
remove(name) {
|
|
30
|
-
store.delete(name);
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
search(query) {
|
|
34
|
-
let results = Array.from(store.values());
|
|
35
|
-
|
|
36
|
-
if (query?.keyword) {
|
|
37
|
-
const kw = query.keyword;
|
|
38
|
-
results = results.filter(m => matchesKeyword(m, kw));
|
|
39
|
-
}
|
|
40
|
-
if (query?.category) {
|
|
41
|
-
const cat = query.category.toLowerCase();
|
|
42
|
-
results = results.filter(m => m.category.toLowerCase() === cat);
|
|
43
|
-
}
|
|
44
|
-
if (query?.tags?.length) {
|
|
45
|
-
const required = query.tags.map(t => t.toLowerCase());
|
|
46
|
-
results = results.filter(m => {
|
|
47
|
-
const entryTags = m.tags.map(t => t.toLowerCase());
|
|
48
|
-
return required.every(rt => entryTags.includes(rt));
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
if (query?.source) {
|
|
52
|
-
results = results.filter(m => m.source === query.source);
|
|
53
|
-
}
|
|
54
|
-
if (query?.enabledOnly) {
|
|
55
|
-
results = results.filter(m => m.enabled);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return results;
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
get(name) {
|
|
62
|
-
const meta = store.get(name);
|
|
63
|
-
return meta ? { ...meta } : undefined;
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
setEnabled(name, enabled) {
|
|
67
|
-
const meta = store.get(name);
|
|
68
|
-
if (meta) meta.enabled = enabled;
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
listEnabled() {
|
|
72
|
-
return Array.from(store.values()).filter(m => m.enabled);
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
entries() {
|
|
76
|
-
return Array.from(store.values());
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
has(name) {
|
|
80
|
-
return store.has(name);
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
get size() {
|
|
84
|
-
return store.size;
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
categories() {
|
|
88
|
-
const counts = new Map<string, number>();
|
|
89
|
-
for (const meta of store.values()) {
|
|
90
|
-
counts.set(meta.category, (counts.get(meta.category) ?? 0) + 1);
|
|
91
|
-
}
|
|
92
|
-
return Array.from(counts.entries()).map(([category, count]) => ({ category, count }));
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
}
|
package/src/parts/summaries.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Part 管理摘要 / 详情构造
|
|
3
|
-
*
|
|
4
|
-
* - 从 PartMeta 派生 ManagedPartSummary / Detail,带统一治理字段
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { createAssetSummaryBase, createPartAssetGovernance } from '../governance';
|
|
8
|
-
import type { ManagedPartDetail, ManagedPartSummary, PartMeta } from './types';
|
|
9
|
-
|
|
10
|
-
export function createManagedPartSummary(
|
|
11
|
-
part: PartMeta,
|
|
12
|
-
extra: Partial<ManagedPartSummary> = {},
|
|
13
|
-
): ManagedPartSummary {
|
|
14
|
-
return {
|
|
15
|
-
...createAssetSummaryBase({
|
|
16
|
-
kind: 'part',
|
|
17
|
-
scope: part.source === 'user' ? 'local' : 'core',
|
|
18
|
-
runtime: 'part-render',
|
|
19
|
-
governance: extra.governance ?? createPartAssetGovernance(),
|
|
20
|
-
}),
|
|
21
|
-
ref: part.name,
|
|
22
|
-
name: part.name,
|
|
23
|
-
description: part.description,
|
|
24
|
-
category: part.category,
|
|
25
|
-
tags: part.tags,
|
|
26
|
-
source: part.source,
|
|
27
|
-
enabled: part.enabled,
|
|
28
|
-
...extra,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function createManagedPartDetail(
|
|
33
|
-
part: PartMeta,
|
|
34
|
-
extra: Partial<ManagedPartDetail> & Pick<ManagedPartDetail, 'hasProject' | 'hasBuilt'>,
|
|
35
|
-
): ManagedPartDetail {
|
|
36
|
-
return {
|
|
37
|
-
...createManagedPartSummary(part),
|
|
38
|
-
...extra,
|
|
39
|
-
};
|
|
40
|
-
}
|
package/src/parts/types.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Part「资产」类型定义(管理面)
|
|
3
|
-
*
|
|
4
|
-
* 这里的 **Part** 指可注册、可构建的前端 UI **工程元数据**(见 PartMeta),不是协议内置的
|
|
5
|
-
* `text` / `tool_call` 等 **ContentPart** 枚举项。
|
|
6
|
-
*
|
|
7
|
-
* **扩展/market Part**:目录与产物在扩展包内,由宿主 `loadPartCode(name)` 加载 `dist`;
|
|
8
|
-
* **宿主内嵌卡片**:由宿主注册 `partRenderers[type]`,与 PartRegistry 无必然绑定。
|
|
9
|
-
*
|
|
10
|
-
* 与 Tool:Tool 为可执行逻辑;与 Skill:Skill 为提示词资产。
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import type { AssetSource, ManagedAssetSummaryBase } from '../governance/types';
|
|
14
|
-
|
|
15
|
-
/** Part 元数据(注册表中存储的索引信息) */
|
|
16
|
-
export interface PartMeta {
|
|
17
|
-
name: string;
|
|
18
|
-
description: string;
|
|
19
|
-
category: string;
|
|
20
|
-
tags: string[];
|
|
21
|
-
source: AssetSource;
|
|
22
|
-
enabled: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface ManagedPartSummary extends ManagedAssetSummaryBase {
|
|
26
|
-
ref: string;
|
|
27
|
-
name: string;
|
|
28
|
-
description: string;
|
|
29
|
-
category: string;
|
|
30
|
-
tags: string[];
|
|
31
|
-
source: AssetSource;
|
|
32
|
-
enabled: boolean;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface ManagedPartDetail extends ManagedPartSummary {
|
|
36
|
-
hasProject: boolean;
|
|
37
|
-
hasBuilt: boolean;
|
|
38
|
-
sourceCode?: string;
|
|
39
|
-
dependencies?: Record<string, string>;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/** Part 搜索条件 */
|
|
43
|
-
export interface PartSearchQuery {
|
|
44
|
-
keyword?: string;
|
|
45
|
-
category?: string;
|
|
46
|
-
tags?: string[];
|
|
47
|
-
source?: AssetSource;
|
|
48
|
-
enabledOnly?: boolean;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** Part Registry 接口 */
|
|
52
|
-
export interface PartRegistry {
|
|
53
|
-
add(meta: PartMeta): void;
|
|
54
|
-
remove(name: string): void;
|
|
55
|
-
search(query?: PartSearchQuery): PartMeta[];
|
|
56
|
-
get(name: string): PartMeta | undefined;
|
|
57
|
-
setEnabled(name: string, enabled: boolean): void;
|
|
58
|
-
listEnabled(): PartMeta[];
|
|
59
|
-
entries(): PartMeta[];
|
|
60
|
-
has(name: string): boolean;
|
|
61
|
-
readonly size: number;
|
|
62
|
-
categories(): Array<{ category: string; count: number }>;
|
|
63
|
-
}
|
package/src/platform.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 平台工具 API(Node.js / Electron 环境)
|
|
3
|
-
*
|
|
4
|
-
* 为宿主和扩展提供路径解析、二进制文件名等平台级能力。
|
|
5
|
-
* 路径策略:
|
|
6
|
-
* - Electron 主进程:使用 app.getPath() / app.getAppPath()
|
|
7
|
-
* - 非 Electron(测试/CLI):回退到 OS 标准路径
|
|
8
|
-
*
|
|
9
|
-
* 浏览器自动化能力由独立 browser-agent 工作区提供。
|
|
10
|
-
*/
|
|
11
|
-
import fs from 'node:fs'
|
|
12
|
-
import os from 'node:os'
|
|
13
|
-
import path from 'node:path'
|
|
14
|
-
|
|
15
|
-
function tryGetElectronApp() {
|
|
16
|
-
try {
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
18
|
-
const { app } = require('electron') as typeof import('electron')
|
|
19
|
-
app.getPath('userData')
|
|
20
|
-
return app
|
|
21
|
-
} catch {
|
|
22
|
-
return null
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/* ------------------------------------------------------------------ */
|
|
27
|
-
/* 路径解析 */
|
|
28
|
-
/* ------------------------------------------------------------------ */
|
|
29
|
-
|
|
30
|
-
/** userData 目录:Electron → app.getPath('userData'),非 Electron → ~/.superx */
|
|
31
|
-
export function getUserDataDir(): string {
|
|
32
|
-
const app = tryGetElectronApp()
|
|
33
|
-
return app ? app.getPath('userData') : path.join(os.homedir(), '.superx')
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** 下载目录:Electron → app.getPath('downloads'),非 Electron → ~/Downloads */
|
|
37
|
-
export function getDownloadsDir(): string {
|
|
38
|
-
const app = tryGetElectronApp()
|
|
39
|
-
return app ? app.getPath('downloads') : path.join(os.homedir(), 'Downloads')
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/** assets 根目录:Electron → appPath/assets,非 Electron → cwd/assets */
|
|
43
|
-
export function getAssetsDir(): string {
|
|
44
|
-
const app = tryGetElectronApp()
|
|
45
|
-
const base = app ? app.getAppPath() : process.cwd()
|
|
46
|
-
return path.join(base, 'assets')
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* 用户可写二进制目录:
|
|
51
|
-
* - Electron → userData/bin(从 assets/bin 复制而来)
|
|
52
|
-
* - 非 Electron → assets/bin(直接使用)
|
|
53
|
-
*/
|
|
54
|
-
export function getUserBinDir(): string {
|
|
55
|
-
const app = tryGetElectronApp()
|
|
56
|
-
const dir = app
|
|
57
|
-
? path.join(app.getPath('userData'), 'bin')
|
|
58
|
-
: path.join(process.cwd(), 'assets', 'bin')
|
|
59
|
-
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true })
|
|
60
|
-
return dir
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/** assets/bin 目录(只读,打包资源) */
|
|
64
|
-
export function getBundledBinDir(): string {
|
|
65
|
-
return path.join(getAssetsDir(), 'bin')
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/** 获取平台对应的二进制文件名 */
|
|
69
|
-
export function getBinaryFilename(name: string): string {
|
|
70
|
-
if (process.platform === 'win32') return `${name}.exe`
|
|
71
|
-
if (process.platform === 'darwin') return `${name}_macos`
|
|
72
|
-
return `${name}_linux`
|
|
73
|
-
}
|