@yushaw/sanqian-chat 0.2.2 → 0.2.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.
@@ -8,6 +8,51 @@ import { BrowserWindow } from 'electron';
8
8
  * Application-facing types that hide SDK implementation details.
9
9
  * These provide a stable API even as the underlying SDK evolves.
10
10
  */
11
+ /**
12
+ * Context data returned by a provider
13
+ */
14
+ interface AppContextData {
15
+ /** Resource ID (for getById scenarios) */
16
+ id?: string;
17
+ /** Content to inject into conversation */
18
+ content: string;
19
+ /** Display title */
20
+ title?: string;
21
+ /** Summary for preview */
22
+ summary?: string;
23
+ /** Version for change detection (optional, Sanqian uses content hash if not provided) */
24
+ version?: string;
25
+ }
26
+ /**
27
+ * List item for context provider's getList method
28
+ */
29
+ interface AppContextListItem {
30
+ /** Resource ID */
31
+ id: string;
32
+ /** Display title */
33
+ title: string;
34
+ /** Optional summary */
35
+ summary?: string;
36
+ /** Optional icon */
37
+ icon?: string;
38
+ }
39
+ /**
40
+ * Context provider definition
41
+ */
42
+ interface AppContextProvider {
43
+ /** Provider ID (unique within app) */
44
+ id: string;
45
+ /** Display name */
46
+ name: string;
47
+ /** Description */
48
+ description: string;
49
+ /** Get current state (for dynamic context) */
50
+ getCurrent?: () => Promise<AppContextData | null>;
51
+ /** Get list of available contexts */
52
+ getList?: () => Promise<AppContextListItem[]>;
53
+ /** Get full content by ID */
54
+ getById?: (id: string) => Promise<AppContextData | null>;
55
+ }
11
56
  /**
12
57
  * Application configuration for connecting to Sanqian
13
58
  */
@@ -22,6 +67,8 @@ interface AppConfig {
22
67
  launchCommand?: string;
23
68
  /** Tools provided by this application */
24
69
  tools?: AppToolDefinition[];
70
+ /** Context providers for injecting app state */
71
+ contexts?: AppContextProvider[];
25
72
  /** Enable debug logging */
26
73
  debug?: boolean;
27
74
  }
@@ -66,8 +113,25 @@ interface AppAgentConfig {
66
113
  description?: string;
67
114
  /** System prompt */
68
115
  systemPrompt?: string;
69
- /** Enabled tool names (without app prefix) */
116
+ /**
117
+ * Tools to enable. Supports:
118
+ * - Builtin: "file_ops", "run_bash", "web_search"
119
+ * - SDK: "myapp:tool_name" or just "tool_name" (auto-prefixed)
120
+ * - MCP: "mcp_server_tool"
121
+ * - Wildcard: ["*"]
122
+ */
70
123
  tools?: string[];
124
+ /**
125
+ * Skills to enable.
126
+ * @example ["pdf", "web-research", "xlsx"]
127
+ */
128
+ skills?: string[];
129
+ /**
130
+ * Context providers to attach by default.
131
+ * Uses provider ID without app prefix (auto-prefixed with appName).
132
+ * @example ["editor-state"] -> "sanqian-notes:editor-state"
133
+ */
134
+ attachedContexts?: string[];
71
135
  }
72
136
  /**
73
137
  * Embedding configuration from Sanqian
@@ -207,6 +271,40 @@ declare class SanqianAppClient {
207
271
  * Delete a conversation
208
272
  */
209
273
  deleteConversation(conversationId: string): Promise<void>;
274
+ /**
275
+ * List available capabilities (tools, skills, agents)
276
+ *
277
+ * @example
278
+ * ```typescript
279
+ * // List all tools
280
+ * const tools = await client.listCapabilities({ type: 'tool' });
281
+ *
282
+ * // List builtin tools only
283
+ * const builtinTools = await client.listCapabilities({ type: 'tool', source: 'builtin' });
284
+ * ```
285
+ */
286
+ listCapabilities(options?: _yushaw_sanqian_sdk.ListCapabilitiesOptions): Promise<_yushaw_sanqian_sdk.Capability[]>;
287
+ /**
288
+ * Search capabilities by query
289
+ *
290
+ * @example
291
+ * ```typescript
292
+ * const results = await client.searchCapabilities('file operations', { type: 'tool', limit: 5 });
293
+ * ```
294
+ */
295
+ searchCapabilities(query: string, options?: _yushaw_sanqian_sdk.SearchCapabilitiesOptions): Promise<_yushaw_sanqian_sdk.CapabilitySearchResult[]>;
296
+ /**
297
+ * List available tools
298
+ */
299
+ listTools(source?: 'builtin' | 'sdk' | 'mcp'): Promise<_yushaw_sanqian_sdk.ToolCapability[]>;
300
+ /**
301
+ * List available skills
302
+ */
303
+ listSkills(): Promise<_yushaw_sanqian_sdk.SkillCapability[]>;
304
+ /**
305
+ * List all available agents (not just own agents)
306
+ */
307
+ listAvailableAgents(): Promise<_yushaw_sanqian_sdk.AgentCapability[]>;
210
308
  /**
211
309
  * Get the underlying SDK instance
212
310
  * @internal This is for internal use by other sanqian-chat components
@@ -370,4 +468,4 @@ declare class FloatingWindow {
370
468
  getWindow(): BrowserWindow | null;
371
469
  }
372
470
 
373
- export { type AppAgentConfig, type AppClientEvent, type AppClientEventHandlers, type AppConfig, type AppEmbeddingConfig, type AppJsonSchemaProperty, type AppToolDefinition, type ChatUiConfigSerializable, FloatingWindow, type FloatingWindowConfig, type FloatingWindowOptions, SanqianAppClient, type WindowPosition };
471
+ export { type AppAgentConfig, type AppClientEvent, type AppClientEventHandlers, type AppConfig, type AppContextData, type AppContextListItem, type AppContextProvider, type AppEmbeddingConfig, type AppJsonSchemaProperty, type AppToolDefinition, type ChatUiConfigSerializable, FloatingWindow, type FloatingWindowConfig, type FloatingWindowOptions, SanqianAppClient, type WindowPosition };
@@ -8,6 +8,51 @@ import { BrowserWindow } from 'electron';
8
8
  * Application-facing types that hide SDK implementation details.
9
9
  * These provide a stable API even as the underlying SDK evolves.
10
10
  */
11
+ /**
12
+ * Context data returned by a provider
13
+ */
14
+ interface AppContextData {
15
+ /** Resource ID (for getById scenarios) */
16
+ id?: string;
17
+ /** Content to inject into conversation */
18
+ content: string;
19
+ /** Display title */
20
+ title?: string;
21
+ /** Summary for preview */
22
+ summary?: string;
23
+ /** Version for change detection (optional, Sanqian uses content hash if not provided) */
24
+ version?: string;
25
+ }
26
+ /**
27
+ * List item for context provider's getList method
28
+ */
29
+ interface AppContextListItem {
30
+ /** Resource ID */
31
+ id: string;
32
+ /** Display title */
33
+ title: string;
34
+ /** Optional summary */
35
+ summary?: string;
36
+ /** Optional icon */
37
+ icon?: string;
38
+ }
39
+ /**
40
+ * Context provider definition
41
+ */
42
+ interface AppContextProvider {
43
+ /** Provider ID (unique within app) */
44
+ id: string;
45
+ /** Display name */
46
+ name: string;
47
+ /** Description */
48
+ description: string;
49
+ /** Get current state (for dynamic context) */
50
+ getCurrent?: () => Promise<AppContextData | null>;
51
+ /** Get list of available contexts */
52
+ getList?: () => Promise<AppContextListItem[]>;
53
+ /** Get full content by ID */
54
+ getById?: (id: string) => Promise<AppContextData | null>;
55
+ }
11
56
  /**
12
57
  * Application configuration for connecting to Sanqian
13
58
  */
@@ -22,6 +67,8 @@ interface AppConfig {
22
67
  launchCommand?: string;
23
68
  /** Tools provided by this application */
24
69
  tools?: AppToolDefinition[];
70
+ /** Context providers for injecting app state */
71
+ contexts?: AppContextProvider[];
25
72
  /** Enable debug logging */
26
73
  debug?: boolean;
27
74
  }
@@ -66,8 +113,25 @@ interface AppAgentConfig {
66
113
  description?: string;
67
114
  /** System prompt */
68
115
  systemPrompt?: string;
69
- /** Enabled tool names (without app prefix) */
116
+ /**
117
+ * Tools to enable. Supports:
118
+ * - Builtin: "file_ops", "run_bash", "web_search"
119
+ * - SDK: "myapp:tool_name" or just "tool_name" (auto-prefixed)
120
+ * - MCP: "mcp_server_tool"
121
+ * - Wildcard: ["*"]
122
+ */
70
123
  tools?: string[];
124
+ /**
125
+ * Skills to enable.
126
+ * @example ["pdf", "web-research", "xlsx"]
127
+ */
128
+ skills?: string[];
129
+ /**
130
+ * Context providers to attach by default.
131
+ * Uses provider ID without app prefix (auto-prefixed with appName).
132
+ * @example ["editor-state"] -> "sanqian-notes:editor-state"
133
+ */
134
+ attachedContexts?: string[];
71
135
  }
72
136
  /**
73
137
  * Embedding configuration from Sanqian
@@ -207,6 +271,40 @@ declare class SanqianAppClient {
207
271
  * Delete a conversation
208
272
  */
209
273
  deleteConversation(conversationId: string): Promise<void>;
274
+ /**
275
+ * List available capabilities (tools, skills, agents)
276
+ *
277
+ * @example
278
+ * ```typescript
279
+ * // List all tools
280
+ * const tools = await client.listCapabilities({ type: 'tool' });
281
+ *
282
+ * // List builtin tools only
283
+ * const builtinTools = await client.listCapabilities({ type: 'tool', source: 'builtin' });
284
+ * ```
285
+ */
286
+ listCapabilities(options?: _yushaw_sanqian_sdk.ListCapabilitiesOptions): Promise<_yushaw_sanqian_sdk.Capability[]>;
287
+ /**
288
+ * Search capabilities by query
289
+ *
290
+ * @example
291
+ * ```typescript
292
+ * const results = await client.searchCapabilities('file operations', { type: 'tool', limit: 5 });
293
+ * ```
294
+ */
295
+ searchCapabilities(query: string, options?: _yushaw_sanqian_sdk.SearchCapabilitiesOptions): Promise<_yushaw_sanqian_sdk.CapabilitySearchResult[]>;
296
+ /**
297
+ * List available tools
298
+ */
299
+ listTools(source?: 'builtin' | 'sdk' | 'mcp'): Promise<_yushaw_sanqian_sdk.ToolCapability[]>;
300
+ /**
301
+ * List available skills
302
+ */
303
+ listSkills(): Promise<_yushaw_sanqian_sdk.SkillCapability[]>;
304
+ /**
305
+ * List all available agents (not just own agents)
306
+ */
307
+ listAvailableAgents(): Promise<_yushaw_sanqian_sdk.AgentCapability[]>;
210
308
  /**
211
309
  * Get the underlying SDK instance
212
310
  * @internal This is for internal use by other sanqian-chat components
@@ -370,4 +468,4 @@ declare class FloatingWindow {
370
468
  getWindow(): BrowserWindow | null;
371
469
  }
372
470
 
373
- export { type AppAgentConfig, type AppClientEvent, type AppClientEventHandlers, type AppConfig, type AppEmbeddingConfig, type AppJsonSchemaProperty, type AppToolDefinition, type ChatUiConfigSerializable, FloatingWindow, type FloatingWindowConfig, type FloatingWindowOptions, SanqianAppClient, type WindowPosition };
471
+ export { type AppAgentConfig, type AppClientEvent, type AppClientEventHandlers, type AppConfig, type AppContextData, type AppContextListItem, type AppContextProvider, type AppEmbeddingConfig, type AppJsonSchemaProperty, type AppToolDefinition, type ChatUiConfigSerializable, FloatingWindow, type FloatingWindowConfig, type FloatingWindowOptions, SanqianAppClient, type WindowPosition };
@@ -45,13 +45,22 @@ var SanqianAppClient = class {
45
45
  parameters: t.parameters,
46
46
  handler: t.handler
47
47
  }));
48
+ const contexts = config.contexts?.map((c) => ({
49
+ id: c.id,
50
+ name: c.name,
51
+ description: c.description,
52
+ getCurrent: c.getCurrent,
53
+ getList: c.getList,
54
+ getById: c.getById
55
+ }));
48
56
  const sdkConfig = {
49
57
  appName: config.appName,
50
58
  appVersion: config.appVersion,
51
59
  displayName: config.displayName,
52
60
  launchCommand: config.launchCommand,
53
61
  debug: config.debug,
54
- tools
62
+ tools,
63
+ contexts
55
64
  };
56
65
  this.sdk = new import_sanqian_sdk.SanqianSDK(sdkConfig);
57
66
  }
@@ -112,7 +121,9 @@ var SanqianAppClient = class {
112
121
  name: config.name,
113
122
  description: config.description,
114
123
  system_prompt: config.systemPrompt,
115
- tools: config.tools
124
+ tools: config.tools,
125
+ skills: config.skills,
126
+ attached_contexts: config.attachedContexts
116
127
  };
117
128
  const result = await this.sdk.createAgent(sdkConfig);
118
129
  return { agentId: result.agent_id };
@@ -191,6 +202,53 @@ var SanqianAppClient = class {
191
202
  return this.sdk.deleteConversation(conversationId);
192
203
  }
193
204
  // ============================================================
205
+ // Capability Discovery
206
+ // ============================================================
207
+ /**
208
+ * List available capabilities (tools, skills, agents)
209
+ *
210
+ * @example
211
+ * ```typescript
212
+ * // List all tools
213
+ * const tools = await client.listCapabilities({ type: 'tool' });
214
+ *
215
+ * // List builtin tools only
216
+ * const builtinTools = await client.listCapabilities({ type: 'tool', source: 'builtin' });
217
+ * ```
218
+ */
219
+ async listCapabilities(options) {
220
+ return this.sdk.listCapabilities(options);
221
+ }
222
+ /**
223
+ * Search capabilities by query
224
+ *
225
+ * @example
226
+ * ```typescript
227
+ * const results = await client.searchCapabilities('file operations', { type: 'tool', limit: 5 });
228
+ * ```
229
+ */
230
+ async searchCapabilities(query, options) {
231
+ return this.sdk.searchCapabilities(query, options);
232
+ }
233
+ /**
234
+ * List available tools
235
+ */
236
+ async listTools(source) {
237
+ return this.sdk.listTools(source);
238
+ }
239
+ /**
240
+ * List available skills
241
+ */
242
+ async listSkills() {
243
+ return this.sdk.listSkills();
244
+ }
245
+ /**
246
+ * List all available agents (not just own agents)
247
+ */
248
+ async listAvailableAgents() {
249
+ return this.sdk.listAvailableAgents();
250
+ }
251
+ // ============================================================
194
252
  // Internal Access (for FloatingWindow and other internal components)
195
253
  // ============================================================
196
254
  /**
@@ -8,13 +8,22 @@ var SanqianAppClient = class {
8
8
  parameters: t.parameters,
9
9
  handler: t.handler
10
10
  }));
11
+ const contexts = config.contexts?.map((c) => ({
12
+ id: c.id,
13
+ name: c.name,
14
+ description: c.description,
15
+ getCurrent: c.getCurrent,
16
+ getList: c.getList,
17
+ getById: c.getById
18
+ }));
11
19
  const sdkConfig = {
12
20
  appName: config.appName,
13
21
  appVersion: config.appVersion,
14
22
  displayName: config.displayName,
15
23
  launchCommand: config.launchCommand,
16
24
  debug: config.debug,
17
- tools
25
+ tools,
26
+ contexts
18
27
  };
19
28
  this.sdk = new SanqianSDK(sdkConfig);
20
29
  }
@@ -75,7 +84,9 @@ var SanqianAppClient = class {
75
84
  name: config.name,
76
85
  description: config.description,
77
86
  system_prompt: config.systemPrompt,
78
- tools: config.tools
87
+ tools: config.tools,
88
+ skills: config.skills,
89
+ attached_contexts: config.attachedContexts
79
90
  };
80
91
  const result = await this.sdk.createAgent(sdkConfig);
81
92
  return { agentId: result.agent_id };
@@ -154,6 +165,53 @@ var SanqianAppClient = class {
154
165
  return this.sdk.deleteConversation(conversationId);
155
166
  }
156
167
  // ============================================================
168
+ // Capability Discovery
169
+ // ============================================================
170
+ /**
171
+ * List available capabilities (tools, skills, agents)
172
+ *
173
+ * @example
174
+ * ```typescript
175
+ * // List all tools
176
+ * const tools = await client.listCapabilities({ type: 'tool' });
177
+ *
178
+ * // List builtin tools only
179
+ * const builtinTools = await client.listCapabilities({ type: 'tool', source: 'builtin' });
180
+ * ```
181
+ */
182
+ async listCapabilities(options) {
183
+ return this.sdk.listCapabilities(options);
184
+ }
185
+ /**
186
+ * Search capabilities by query
187
+ *
188
+ * @example
189
+ * ```typescript
190
+ * const results = await client.searchCapabilities('file operations', { type: 'tool', limit: 5 });
191
+ * ```
192
+ */
193
+ async searchCapabilities(query, options) {
194
+ return this.sdk.searchCapabilities(query, options);
195
+ }
196
+ /**
197
+ * List available tools
198
+ */
199
+ async listTools(source) {
200
+ return this.sdk.listTools(source);
201
+ }
202
+ /**
203
+ * List available skills
204
+ */
205
+ async listSkills() {
206
+ return this.sdk.listSkills();
207
+ }
208
+ /**
209
+ * List all available agents (not just own agents)
210
+ */
211
+ async listAvailableAgents() {
212
+ return this.sdk.listAvailableAgents();
213
+ }
214
+ // ============================================================
157
215
  // Internal Access (for FloatingWindow and other internal components)
158
216
  // ============================================================
159
217
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yushaw/sanqian-chat",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "Floating chat window SDK for Sanqian AI Assistant",
5
5
  "main": "./dist/main/index.js",
6
6
  "types": "./dist/main/index.d.ts",
@@ -43,7 +43,7 @@
43
43
  "test:watch": "vitest"
44
44
  },
45
45
  "dependencies": {
46
- "@yushaw/sanqian-sdk": "^0.3.0",
46
+ "@yushaw/sanqian-sdk": "^0.3.1",
47
47
  "react-virtuoso": "^4.15.0",
48
48
  "rehype-harden": "^1.1.6",
49
49
  "remark-gfm": "^4.0.1",