deepseek-agent-acp 0.2.0 → 0.2.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/dist/index.d.ts CHANGED
@@ -11,3 +11,7 @@
11
11
  * - Full Model Context Protocol (MCP) tool execution.
12
12
  */
13
13
  export declare function loadSecretKey(secretsPath?: string): string;
14
+ /**
15
+ * Extract clean prompt text from ACP params supporting string, ContentBlock[], or nested structures.
16
+ */
17
+ export declare function extractPromptText(params?: Record<string, unknown>): string;
package/dist/index.js CHANGED
@@ -267,12 +267,54 @@ async function handleRpcMessage(rpc) {
267
267
  }
268
268
  }
269
269
  }
270
+ /**
271
+ * Extract clean prompt text from ACP params supporting string, ContentBlock[], or nested structures.
272
+ */
273
+ export function extractPromptText(params) {
274
+ if (!params) {
275
+ return '';
276
+ }
277
+ const prompt = params.prompt ?? params.message ?? params.text;
278
+ if (typeof prompt === 'string') {
279
+ return prompt;
280
+ }
281
+ if (Array.isArray(prompt)) {
282
+ return prompt
283
+ .map((block) => {
284
+ if (typeof block === 'string') {
285
+ return block;
286
+ }
287
+ if (block && typeof block === 'object') {
288
+ const rec = block;
289
+ if (typeof rec.text === 'string') {
290
+ return rec.text;
291
+ }
292
+ if (typeof rec.content === 'string') {
293
+ return rec.content;
294
+ }
295
+ }
296
+ return '';
297
+ })
298
+ .filter(Boolean)
299
+ .join('\n');
300
+ }
301
+ if (prompt && typeof prompt === 'object') {
302
+ const rec = prompt;
303
+ if (typeof rec.text === 'string') {
304
+ return rec.text;
305
+ }
306
+ if (typeof rec.content === 'string') {
307
+ return rec.content;
308
+ }
309
+ }
310
+ return '';
311
+ }
270
312
  /**
271
313
  * Handle ACP session/prompt execution with multi-turn tool loops.
272
314
  */
273
315
  async function handleSessionPrompt(id, params) {
274
316
  const sessionId = params?.sessionId || `session-${Date.now().toString()}`;
275
- const promptText = params?.prompt || params?.message || params?.text || '';
317
+ const promptText = extractPromptText(params);
276
318
  let session = sessions.get(sessionId);
277
319
  if (!session) {
278
320
  session = new Session(sessionId);
@@ -42,7 +42,7 @@ export interface NostrMetadata {
42
42
  * Isolates the active envelope using lastIndexOf('Event ID:') to prevent
43
43
  * capturing cancelled or steered predecessor messages.
44
44
  */
45
- export declare function parseNostrContext(rawText: string): NostrMetadata;
45
+ export declare function parseNostrContext(rawText: unknown): NostrMetadata;
46
46
  /**
47
47
  * Extract the posted Buzz event ID from a reply tool result.
48
48
  * buzz-thread reply tools return `posted (N characters) · event_id <64 hex>`.
package/dist/telemetry.js CHANGED
@@ -153,7 +153,7 @@ export function computeOutputBytes(output) {
153
153
  */
154
154
  export function parseNostrContext(rawText) {
155
155
  const result = {};
156
- if (!rawText) {
156
+ if (typeof rawText !== 'string' || !rawText) {
157
157
  return result;
158
158
  }
159
159
  const lastEventIdx = rawText.lastIndexOf('Event ID:');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepseek-agent-acp",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Agent Client Protocol (ACP) adapter for DeepSeek reasoning and chat models with Model Context Protocol (MCP) tool execution",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",