deepseek-agent-acp 0.2.2 → 0.2.3
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/telemetry.d.ts +2 -1
- package/dist/telemetry.js +35 -4
- package/package.json +1 -1
package/dist/telemetry.d.ts
CHANGED
|
@@ -44,8 +44,9 @@ export interface NostrMetadata {
|
|
|
44
44
|
*/
|
|
45
45
|
export declare function parseNostrContext(rawText: unknown): NostrMetadata;
|
|
46
46
|
/**
|
|
47
|
-
* Regex matching posted Nostr event ID across text and JSON formats:
|
|
47
|
+
* Regex matching posted Nostr event ID across text, JSON, and escaped JSON formats:
|
|
48
48
|
* - buzz messages send / relay stdout: {"accepted":true,"event_id":"<64 hex>",...}
|
|
49
|
+
* - escaped JSON stdout: {\"accepted\":true,\"event_id\":\"<64 hex>\"}
|
|
49
50
|
* - reply tools: `posted (N characters) · event_id <64 hex>`
|
|
50
51
|
* - shell assignments: `event_id=<64 hex>` or `event_id: <64 hex>`
|
|
51
52
|
*/
|
package/dist/telemetry.js
CHANGED
|
@@ -195,12 +195,13 @@ export function parseNostrContext(rawText) {
|
|
|
195
195
|
return result;
|
|
196
196
|
}
|
|
197
197
|
/**
|
|
198
|
-
* Regex matching posted Nostr event ID across text and JSON formats:
|
|
198
|
+
* Regex matching posted Nostr event ID across text, JSON, and escaped JSON formats:
|
|
199
199
|
* - buzz messages send / relay stdout: {"accepted":true,"event_id":"<64 hex>",...}
|
|
200
|
+
* - escaped JSON stdout: {\"accepted\":true,\"event_id\":\"<64 hex>\"}
|
|
200
201
|
* - reply tools: `posted (N characters) · event_id <64 hex>`
|
|
201
202
|
* - shell assignments: `event_id=<64 hex>` or `event_id: <64 hex>`
|
|
202
203
|
*/
|
|
203
|
-
export const POSTED_OUTPUT_PATTERN = /\bevent_id["']?\s*[:=]?\s
|
|
204
|
+
export const POSTED_OUTPUT_PATTERN = /\bevent_id\\?["']?\s*[:=]?\s*\\?["']?([0-9a-f]{64})(?![0-9a-f])/i;
|
|
204
205
|
/**
|
|
205
206
|
* Extract the posted Buzz event ID from a reply tool result or shell output.
|
|
206
207
|
*/
|
|
@@ -208,9 +209,22 @@ export function extractPostedEventId(output) {
|
|
|
208
209
|
let text = '';
|
|
209
210
|
if (typeof output === 'string') {
|
|
210
211
|
text = output;
|
|
212
|
+
try {
|
|
213
|
+
const parsed = JSON.parse(output);
|
|
214
|
+
if (parsed && typeof parsed.stdout === 'string') {
|
|
215
|
+
text += ` ${parsed.stdout}`;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
catch {
|
|
219
|
+
// Ignored
|
|
220
|
+
}
|
|
211
221
|
}
|
|
212
222
|
else if (output && typeof output === 'object') {
|
|
223
|
+
const rec = output;
|
|
213
224
|
text = JSON.stringify(output);
|
|
225
|
+
if (typeof rec.stdout === 'string') {
|
|
226
|
+
text += ` ${rec.stdout}`;
|
|
227
|
+
}
|
|
214
228
|
}
|
|
215
229
|
if (!text) {
|
|
216
230
|
return undefined;
|
|
@@ -312,7 +326,16 @@ export function initTelemetry(options) {
|
|
|
312
326
|
const tracer = trace.getTracer('deepseek-agent-acp', getPackageVersion());
|
|
313
327
|
return {
|
|
314
328
|
startTurnSpan(sessionId, promptText, modelName, nostrMeta) {
|
|
315
|
-
|
|
329
|
+
// Extract the event message block if present for cleaner prompt preview in Phoenix & buzz-trace
|
|
330
|
+
let promptForSpan = promptText;
|
|
331
|
+
if (promptText.includes('\n') && promptText.includes('Event ID:')) {
|
|
332
|
+
const blocks = promptText.split(/\n{2,}/);
|
|
333
|
+
const eventBlock = blocks.find((b) => b.includes('Event ID:'));
|
|
334
|
+
if (eventBlock) {
|
|
335
|
+
promptForSpan = eventBlock;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
const sanitizedPrompt = truncatePayload(redactSecrets(promptForSpan), 8192);
|
|
316
339
|
const resolvedSessionId = nostrMeta?.threadRootId ?? sessionId;
|
|
317
340
|
const rootSpan = tracer.startSpan('agent_turn', {
|
|
318
341
|
attributes: {
|
|
@@ -436,14 +459,22 @@ export function initTelemetry(options) {
|
|
|
436
459
|
const outputBytes = computeOutputBytes(output);
|
|
437
460
|
toolSpan.setAttribute('tool.output_bytes', outputBytes);
|
|
438
461
|
// Extract posted_event_id for any posting tool (reply, buzz-thread__reply, shell, etc.)
|
|
462
|
+
let hasPostedId = false;
|
|
439
463
|
if (!isError) {
|
|
440
464
|
const postedId = extractPostedEventId(output);
|
|
441
465
|
if (postedId) {
|
|
466
|
+
hasPostedId = true;
|
|
442
467
|
toolSpan.setAttribute('nostr.posted_event_id', postedId);
|
|
443
468
|
rootSpan.setAttribute('nostr.posted_event_id', postedId);
|
|
469
|
+
// Ensure output.value and tool.output are captured on the posting span for trace fidelity
|
|
470
|
+
const rawStr = typeof output === 'string' ? output : JSON.stringify(output);
|
|
471
|
+
const sanitizedOut = truncatePayload(redactSecrets(rawStr), 8192);
|
|
472
|
+
toolSpan.setAttribute('output.value', sanitizedOut);
|
|
473
|
+
toolSpan.setAttribute('tool.output', sanitizedOut);
|
|
474
|
+
toolSpan.setAttribute('output.mime_type', 'text/plain');
|
|
444
475
|
}
|
|
445
476
|
}
|
|
446
|
-
if (process.env.OTEL_CAPTURE_TOOL_OUTPUT === 'true' && output !== undefined) {
|
|
477
|
+
if (process.env.OTEL_CAPTURE_TOOL_OUTPUT === 'true' && output !== undefined && !hasPostedId) {
|
|
447
478
|
const sanitizedOut = truncatePayload(redactSecrets(output), 8192);
|
|
448
479
|
toolSpan.setAttribute('output.value', sanitizedOut);
|
|
449
480
|
toolSpan.setAttribute('output.mime_type', 'text/plain');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deepseek-agent-acp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
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",
|