@agent-earth/shared 0.0.4

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.
Files changed (43) hide show
  1. package/dist/index.d.ts +10 -0
  2. package/dist/index.js +1 -0
  3. package/dist/schemas/agent-system.schema.d.ts +11661 -0
  4. package/dist/schemas/agent-system.schema.js +1 -0
  5. package/dist/schemas/agent.schema.d.ts +901 -0
  6. package/dist/schemas/agent.schema.js +1 -0
  7. package/dist/schemas/cesium.schema.d.ts +517 -0
  8. package/dist/schemas/cesium.schema.js +1 -0
  9. package/dist/schemas/index.d.ts +10 -0
  10. package/dist/schemas/index.js +1 -0
  11. package/dist/schemas/mcp.schema.d.ts +1791 -0
  12. package/dist/schemas/mcp.schema.js +1 -0
  13. package/dist/schemas/service-config.schema.d.ts +1302 -0
  14. package/dist/schemas/service-config.schema.js +1 -0
  15. package/dist/schemas/skill.schema.d.ts +392 -0
  16. package/dist/schemas/skill.schema.js +1 -0
  17. package/dist/schemas/store.schema.d.ts +1242 -0
  18. package/dist/schemas/store.schema.js +1 -0
  19. package/dist/schemas/user.schema.d.ts +541 -0
  20. package/dist/schemas/user.schema.js +1 -0
  21. package/dist/schemas/websocket.schema.d.ts +1186 -0
  22. package/dist/schemas/websocket.schema.js +1 -0
  23. package/dist/schemas/wiki.schema.d.ts +865 -0
  24. package/dist/schemas/wiki.schema.js +1 -0
  25. package/dist/types/agent.d.ts +45 -0
  26. package/dist/types/agent.js +1 -0
  27. package/dist/types/at-file.d.ts +42 -0
  28. package/dist/types/at-file.js +1 -0
  29. package/dist/types/cesium.d.ts +116 -0
  30. package/dist/types/cesium.js +1 -0
  31. package/dist/types/hermes.d.ts +95 -0
  32. package/dist/types/hermes.js +1 -0
  33. package/dist/types/mcp.d.ts +202 -0
  34. package/dist/types/mcp.js +1 -0
  35. package/dist/types/skill.d.ts +29 -0
  36. package/dist/types/skill.js +1 -0
  37. package/dist/types/slash-command.d.ts +26 -0
  38. package/dist/types/slash-command.js +1 -0
  39. package/dist/types/websocket.d.ts +301 -0
  40. package/dist/types/websocket.js +1 -0
  41. package/dist/types/wiki.d.ts +66 -0
  42. package/dist/types/wiki.js +1 -0
  43. package/package.json +33 -0
@@ -0,0 +1,301 @@
1
+ import type { CesiumCommand } from './cesium.js';
2
+ export interface WebSocketConfig {
3
+ enabled: boolean;
4
+ port: number;
5
+ host: string;
6
+ path: string;
7
+ messageFormat: 'json' | 'binary';
8
+ heartbeatInterval: number;
9
+ maxConnections: number;
10
+ }
11
+ export interface WSMessage {
12
+ type: WSMessageType;
13
+ id: string;
14
+ timestamp: string;
15
+ payload: unknown;
16
+ }
17
+ export type WSMessageType = 'client_register' | 'user_input' | 'text_reply' | 'tool_choice_required' | 'build_model' | 'building_model' | 'cesium_command' | 'workspace_command' | 'workspace_connector_request' | 'workspace_connector_result' | 'command_result' | 'action_feedback' | 'agent_status' | 'error' | 'heartbeat' | 'status' | 'workspace_mode_change' | 'workspace_mode_changed' | 'profile_switched';
18
+ export type ClientType = 'nl_component' | 'smart_earth' | 'workspace_ui' | 'workspace_connector';
19
+ /**
20
+ * 三态状态机的作者身份角色:
21
+ * - `default` 常态,与实例 default 人格 1:1 对话(顶部显示实例本名)
22
+ * - `sub-agent` 接管态,@某子智能体后 1:1(顶部显示子智能体本名)
23
+ * - `orchestrator` 调度态,发起多人会诊(顶部显示「…·主调度」)
24
+ */
25
+ export type AgentRole = 'default' | 'sub-agent' | 'orchestrator';
26
+ /** profile_switched 的触发来源:意图门自动 / @mention 接管 / 用户手动勾选。 */
27
+ export type ProfileSwitchTrigger = 'intent-gate' | 'mention' | 'manual';
28
+ export interface HermesAction {
29
+ type: string;
30
+ interface?: string;
31
+ params: Record<string, unknown>;
32
+ id?: string;
33
+ }
34
+ export type RuntimeToolChoiceSource = 'mcp' | 'skill' | 'flowise' | 'auto';
35
+ export interface RuntimeToolChoiceOption {
36
+ index: number;
37
+ source: RuntimeToolChoiceSource;
38
+ toolName?: string;
39
+ label: string;
40
+ description?: string;
41
+ }
42
+ export interface RuntimeToolConflict {
43
+ id: string;
44
+ originalMessage: string;
45
+ options: RuntimeToolChoiceOption[];
46
+ conflictingToolNames: string[];
47
+ prompt: string;
48
+ }
49
+ export interface ClientRegisterMessage extends WSMessage {
50
+ type: 'client_register';
51
+ payload: {
52
+ clientType: ClientType;
53
+ sessionId?: string;
54
+ userId?: string;
55
+ metadata?: Record<string, unknown>;
56
+ };
57
+ }
58
+ export interface UserInputMessage extends WSMessage {
59
+ type: 'user_input';
60
+ payload: {
61
+ text: string;
62
+ sessionId: string;
63
+ context?: Record<string, unknown>;
64
+ voiceInput?: boolean;
65
+ /**
66
+ * 前端当前 activeProfile:常态省略;接管态=子智能体 profile 名;
67
+ * 调度态=orchestrator profile 名。桥接据此选人格注入(非 Hermes 路由键)。
68
+ */
69
+ targetProfile?: string;
70
+ /** 调度态标志,true 时桥接走 orchestrator 人格(编排提示词 + 专家池)。 */
71
+ orchestratorMode?: boolean;
72
+ };
73
+ }
74
+ export interface TextReplyMessage extends WSMessage {
75
+ type: 'text_reply';
76
+ payload: {
77
+ /** 作者 profile 名:常态 'default';接管态=子智能体名;调度态=orchestrator 名。旧消息可能为 'hermes'。 */
78
+ text: string;
79
+ agentId: string;
80
+ sessionId: string;
81
+ actions?: HermesAction[];
82
+ isStreaming?: boolean;
83
+ isFinal?: boolean;
84
+ /** profile 人类可读名(实例本名 / 子智能体本名 / 编排显示名);前端身份头数据驱动渲染。 */
85
+ agentDisplayName?: string;
86
+ /** 三态作者身份,前端据此选渲染样式(缺失=旧消息,fallback 通用名)。 */
87
+ agentRole?: AgentRole;
88
+ };
89
+ }
90
+ export interface ToolChoiceRequiredMessage extends WSMessage {
91
+ type: 'tool_choice_required';
92
+ payload: {
93
+ agentId: string;
94
+ sessionId: string;
95
+ conflict: RuntimeToolConflict;
96
+ };
97
+ }
98
+ export interface CesiumCommandMessage extends WSMessage {
99
+ type: 'cesium_command';
100
+ payload: {
101
+ command: CesiumCommand;
102
+ agentId: string;
103
+ sessionId: string;
104
+ };
105
+ }
106
+ export interface WorkspaceCommandMessage extends WSMessage {
107
+ type: 'workspace_command';
108
+ payload: {
109
+ command: string;
110
+ targetMessageId?: string;
111
+ workspaceId?: string;
112
+ sessionId?: string;
113
+ agentId?: string;
114
+ [key: string]: unknown;
115
+ };
116
+ }
117
+ export interface BuildingModelMessage extends WSMessage {
118
+ type: 'build_model' | 'building_model';
119
+ payload: {
120
+ user_name?: string;
121
+ username?: string;
122
+ userName?: string;
123
+ model_id?: string;
124
+ modelId?: string;
125
+ id?: string;
126
+ model_url?: string;
127
+ modelUrl?: string;
128
+ url?: string;
129
+ glb_url?: string;
130
+ glbUrl?: string;
131
+ polygon?: unknown;
132
+ bbox?: unknown;
133
+ build_type?: string;
134
+ buildType?: string;
135
+ building_type?: string;
136
+ scale?: number;
137
+ request_id?: string;
138
+ requestId?: string;
139
+ task_id?: string;
140
+ taskId?: string;
141
+ [key: string]: unknown;
142
+ };
143
+ }
144
+ export type WorkspaceConnectorOperation = 'workspace_list' | 'workspace_info' | 'workspace_list_dir' | 'workspace_glob' | 'workspace_grep' | 'workspace_read' | 'workspace_write' | 'workspace_doc_status' | 'workspace_doc_outline' | 'workspace_doc_lines' | 'workspace_doc_chunks' | 'workspace_doc_search';
145
+ export interface WorkspaceConnectorRequestMessage extends WSMessage {
146
+ type: 'workspace_connector_request';
147
+ payload: {
148
+ requestId: string;
149
+ workspaceId?: string;
150
+ operation: WorkspaceConnectorOperation;
151
+ args: Record<string, unknown>;
152
+ };
153
+ }
154
+ export interface WorkspaceConnectorResultMessage extends WSMessage {
155
+ type: 'workspace_connector_result';
156
+ payload: {
157
+ requestId: string;
158
+ workspaceId?: string;
159
+ success: boolean;
160
+ data?: Record<string, unknown>;
161
+ error?: string;
162
+ };
163
+ }
164
+ export interface CommandResultMessage extends WSMessage {
165
+ type: 'command_result';
166
+ payload: {
167
+ targetMessageId: string;
168
+ commandType: string;
169
+ success: boolean;
170
+ data?: Record<string, unknown>;
171
+ error?: string;
172
+ };
173
+ }
174
+ export interface ActionFeedbackMessage extends WSMessage {
175
+ type: 'action_feedback';
176
+ payload: {
177
+ targetMessageId: string;
178
+ actionId?: string;
179
+ actionType?: string;
180
+ result: 'success' | 'failure' | 'partial';
181
+ data?: Record<string, unknown>;
182
+ error?: string;
183
+ };
184
+ }
185
+ export interface AgentStatusMessage extends WSMessage {
186
+ type: 'agent_status';
187
+ payload: {
188
+ agentId: string;
189
+ status: 'idle' | 'processing' | 'waiting_for_tool' | 'error';
190
+ sessionId?: string;
191
+ currentActivity?: string;
192
+ processingTime?: number;
193
+ };
194
+ }
195
+ export interface ErrorMessage extends WSMessage {
196
+ type: 'error';
197
+ payload: {
198
+ code: string;
199
+ message: string;
200
+ details?: unknown;
201
+ };
202
+ }
203
+ export interface HeartbeatMessage extends WSMessage {
204
+ type: 'heartbeat';
205
+ payload: {
206
+ status: 'alive' | 'busy' | 'idle';
207
+ activeAgents: string[];
208
+ memoryUsage?: number;
209
+ };
210
+ }
211
+ export interface StatusMessage extends WSMessage {
212
+ type: 'status';
213
+ payload: {
214
+ instanceId: string;
215
+ status: 'running' | 'stopped' | 'error';
216
+ activeConnections: number;
217
+ activeSessions: number;
218
+ version: string;
219
+ };
220
+ }
221
+ export interface WorkspaceModeChangeMessage extends WSMessage {
222
+ type: 'workspace_mode_change';
223
+ payload: {
224
+ mode: 'mcp' | 'llm-direct';
225
+ };
226
+ }
227
+ export interface WorkspaceModeChangedMessage extends WSMessage {
228
+ type: 'workspace_mode_changed';
229
+ payload: {
230
+ mode: 'mcp' | 'llm-direct';
231
+ };
232
+ }
233
+ /**
234
+ * 桥接主动下推:意图门自动触发 / @mention 接管 / 手动勾选导致 activeProfile 变化时,
235
+ * 通知前端同步状态机(更新 activeProfile + 勾选框 + 顶部身份条)。
236
+ */
237
+ export interface ProfileSwitchedMessage extends WSMessage {
238
+ type: 'profile_switched';
239
+ payload: {
240
+ activeProfile: string;
241
+ displayName: string;
242
+ role: AgentRole;
243
+ trigger: ProfileSwitchTrigger;
244
+ sessionId: string;
245
+ };
246
+ }
247
+ export type AllWSMessages = ClientRegisterMessage | UserInputMessage | TextReplyMessage | ToolChoiceRequiredMessage | BuildingModelMessage | CesiumCommandMessage | WorkspaceCommandMessage | WorkspaceConnectorRequestMessage | WorkspaceConnectorResultMessage | CommandResultMessage | ActionFeedbackMessage | AgentStatusMessage | ErrorMessage | HeartbeatMessage | StatusMessage | WorkspaceModeChangeMessage | WorkspaceModeChangedMessage | ProfileSwitchedMessage;
248
+ export interface SSEMessageUsage {
249
+ inputTokens: number;
250
+ outputTokens: number;
251
+ totalTokens: number;
252
+ model?: string;
253
+ finishReason?: string;
254
+ }
255
+ export interface SSEMessage {
256
+ type: 'text_delta' | 'thinking_delta' | 'tool_call' | 'tool_result' | 'command_status' | 'tool_choice_required' | 'file' | 'sources' | 'usage' | 'status' | 'done' | 'error';
257
+ content?: string;
258
+ name?: string;
259
+ displayName?: string;
260
+ args?: Record<string, unknown>;
261
+ success?: boolean;
262
+ error?: string;
263
+ /** Stage label for streaming indicator (e.g. "正在查询知识库...", "正在生成...") */
264
+ stage?: string;
265
+ toolConflict?: RuntimeToolConflict;
266
+ file?: {
267
+ id: string;
268
+ name: string;
269
+ url: string;
270
+ mimeType?: string;
271
+ size?: number;
272
+ };
273
+ usage?: SSEMessageUsage;
274
+ /** 作者 profile 名(常态 'default' / 接管态=子智能体名 / 调度态=orchestrator 名);随 'done' 收尾下发。 */
275
+ agentId?: string;
276
+ /** profile 人类可读名(实例本名 / 子智能体本名 / 编排显示名);前端身份头数据驱动渲染。 */
277
+ agentDisplayName?: string;
278
+ /** 三态作者身份,前端据此选渲染样式。 */
279
+ agentRole?: AgentRole;
280
+ /** Number of tool calls made by sub-agents (explore tool) */
281
+ subAgentCalls?: number;
282
+ /** Number of parallel sub-agents spawned (explore tool) */
283
+ subAgentCount?: number;
284
+ /** Sources/references cited in the response (workspace files + wiki docs) */
285
+ sources?: Array<{
286
+ file: string;
287
+ line?: number;
288
+ content?: string;
289
+ score?: number;
290
+ accessed?: boolean;
291
+ /** 'workspace' (default) or 'wiki' */
292
+ type?: 'workspace' | 'wiki';
293
+ /** Wiki document ID */
294
+ docId?: string;
295
+ /** Wiki page ID */
296
+ pageId?: string;
297
+ }>;
298
+ /** Workspace ID for sources */
299
+ workspaceId?: string;
300
+ }
301
+ export type SSEMessageType = SSEMessage['type'];
@@ -0,0 +1 @@
1
+ export{};
@@ -0,0 +1,66 @@
1
+ export interface WikiConfig {
2
+ id: string;
3
+ name: string;
4
+ description: string;
5
+ type: 'industry' | 'domain' | 'project';
6
+ schemaPath: string;
7
+ pages: WikiPage[];
8
+ entities: WikiEntity[];
9
+ concepts: WikiConcept[];
10
+ }
11
+ export interface WikiPage {
12
+ id: string;
13
+ title: string;
14
+ path: string;
15
+ type: 'entity' | 'concept' | 'general';
16
+ content: string;
17
+ tags: string[];
18
+ links: WikiLink[];
19
+ lastModified: string;
20
+ }
21
+ export interface WikiLink {
22
+ targetPageId: string;
23
+ relation: 'reference' | 'parent' | 'child' | 'related';
24
+ }
25
+ export interface WikiEntity {
26
+ id: string;
27
+ name: string;
28
+ type: string;
29
+ properties: Record<string, unknown>;
30
+ relations: WikiEntityRelation[];
31
+ }
32
+ export interface WikiEntityRelation {
33
+ targetEntityId: string;
34
+ relationType: string;
35
+ properties?: Record<string, unknown>;
36
+ }
37
+ export interface WikiConcept {
38
+ id: string;
39
+ name: string;
40
+ definition: string;
41
+ examples: string[];
42
+ relatedEntities: string[];
43
+ relatedConcepts: string[];
44
+ }
45
+ export interface WikiImportConfig {
46
+ source: 'file' | 'url';
47
+ format: 'pdf' | 'word' | 'markdown' | 'json';
48
+ path: string;
49
+ autoParse: boolean;
50
+ targetWikiId: string;
51
+ }
52
+ export interface WikiExportConfig {
53
+ format: 'markdown' | 'json' | 'html';
54
+ includeSchema: boolean;
55
+ includeLinks: boolean;
56
+ outputPath: string;
57
+ }
58
+ export type WikiSearchMethod = 'keyword' | 'semantic' | 'hybrid' | 'overview';
59
+ export interface WikiSearchResult {
60
+ pageId: string;
61
+ pageTitle: string;
62
+ pageType: string;
63
+ snippet: string;
64
+ content: string;
65
+ relevanceScore: number;
66
+ }
@@ -0,0 +1 @@
1
+ export{};
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@agent-earth/shared",
3
+ "version": "0.0.4",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "files": [
8
+ "dist/**/*.d.ts",
9
+ "dist/**/*.js"
10
+ ],
11
+ "publishConfig": {
12
+ "registry": "https://registry.npmjs.org/",
13
+ "access": "public"
14
+ },
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.js"
19
+ }
20
+ },
21
+ "dependencies": {
22
+ "zod": "^3.24.0"
23
+ },
24
+ "devDependencies": {
25
+ "typescript": "^5.8.0"
26
+ },
27
+ "scripts": {
28
+ "build": "pnpm clean && tsc && node ../../scripts/minify-dist-js.mjs dist",
29
+ "dev": "tsc --watch",
30
+ "clean": "rimraf dist tsconfig.tsbuildinfo",
31
+ "typecheck": "tsc --noEmit"
32
+ }
33
+ }