Skip to content

Commit 3d5b0e1

Browse files
committed
fix type errors
1 parent cb35023 commit 3d5b0e1

2 files changed

Lines changed: 32 additions & 47 deletions

File tree

sdks/node/src/integrations/piCodingAgent.ts

Lines changed: 21 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,27 @@ function mapPiMessage(msg: PiAgentMessage): WeaveMessage {
180180
finish_reason: msg.stopReason,
181181
};
182182
}
183+
184+
if (msg.role === 'bashExecution') {
185+
return {
186+
role: msg.role,
187+
content: msg.command,
188+
};
189+
}
190+
191+
if (msg.role === 'branchSummary') {
192+
return {
193+
role: msg.role,
194+
content: msg.summary,
195+
};
196+
}
197+
198+
if (msg.role === 'compactionSummary') {
199+
return {
200+
role: msg.role,
201+
content: msg.summary,
202+
};
203+
}
183204
const content = msg.content;
184205
return {
185206
role: msg.role,
@@ -277,8 +298,6 @@ export class PiCodingAgentOtelAdapter {
277298
pi.on('tool_call', this.onToolCall);
278299
pi.on('tool_result', this.onToolResult);
279300
pi.on('session_compact', this.onSessionCompact);
280-
pi.on('auto_retry_start', this.onAutoRetryStart);
281-
pi.on('auto_retry_end', this.onAutoRetryEnd);
282301
}
283302

284303
// ---------------------------------------------------------------------------
@@ -407,26 +426,10 @@ export class PiCodingAgentOtelAdapter {
407426
if (!this.chatSpan || !this.captureContent) {
408427
return;
409428
}
410-
const systemInstructions: string[] = [];
411429
const inputMessages: WeaveMessage[] = [];
412430
for (const msg of event.messages) {
413-
if (msg.role === 'system') {
414-
const content = msg.content;
415-
const text =
416-
typeof content === 'string' ? content : safeStringify(content);
417-
if (text) {
418-
systemInstructions.push(text);
419-
}
420-
continue;
421-
}
422431
inputMessages.push(mapPiMessage(msg));
423432
}
424-
if (systemInstructions.length > 0) {
425-
this.chatSpan.setAttribute(
426-
ATTR_GEN_AI_SYSTEM_INSTRUCTIONS,
427-
JSON.stringify(systemInstructions)
428-
);
429-
}
430433
if (inputMessages.length > 0) {
431434
this.chatSpan.setAttribute(
432435
ATTR_GEN_AI_INPUT_MESSAGES,
@@ -536,9 +539,6 @@ export class PiCodingAgentOtelAdapter {
536539
{
537540
kind: SpanKind.INTERNAL,
538541
attributes: {
539-
[ATTR_PI_COMPACTION_REASON]: event.reason,
540-
[ATTR_PI_COMPACTION_ABORTED]: event.aborted,
541-
[ATTR_PI_COMPACTION_WILL_RETRY]: event.willRetry,
542542
...(this.conversationId
543543
? {[ATTR_GEN_AI_CONVERSATION_ID]: this.conversationId}
544544
: {}),
@@ -549,28 +549,6 @@ export class PiCodingAgentOtelAdapter {
549549
span.end();
550550
};
551551

552-
private onAutoRetryStart = (
553-
event: Extract<PiExtensionEvent, {type: 'auto_retry_start'}>
554-
): void => {
555-
this.invokeAgentSpan?.addEvent('auto_retry_start', {
556-
[ATTR_PI_AUTO_RETRY_ATTEMPT]: event.attempt,
557-
[ATTR_PI_AUTO_RETRY_MAX_ATTEMPTS]: event.maxAttempts,
558-
[ATTR_PI_AUTO_RETRY_ERROR_MESSAGE]: event.errorMessage,
559-
});
560-
};
561-
562-
private onAutoRetryEnd = (
563-
event: Extract<PiExtensionEvent, {type: 'auto_retry_end'}>
564-
): void => {
565-
this.invokeAgentSpan?.addEvent('auto_retry_end', {
566-
[ATTR_PI_AUTO_RETRY_SUCCESS]: event.success,
567-
[ATTR_PI_AUTO_RETRY_ATTEMPT]: event.attempt,
568-
...(event.finalError
569-
? {[ATTR_PI_AUTO_RETRY_FINAL_ERROR]: event.finalError}
570-
: {}),
571-
});
572-
};
573-
574552
// ---------------------------------------------------------------------------
575553
// Span lifecycle helpers
576554
// ---------------------------------------------------------------------------

sdks/node/src/integrations/piCodingAgent.types.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1-
export type {AgentMessage as PiAgentMessage} from "@earendil-works/pi-agent-core";
1+
export type {AgentMessage as PiAgentMessage} from '@earendil-works/pi-agent-core';
22

3-
export type {AssistantMessage as PiAssistantMessage, Model as PiModel} from "@earendil-works/pi-ai";
3+
export type {
4+
AssistantMessage as PiAssistantMessage,
5+
Model as PiModel,
6+
} from '@earendil-works/pi-ai';
47

5-
export type {ExtensionEvent as PiExtensionEvent, ExtensionAPI as PiExtensionApi, ExtensionContext as PiExtensionContext} from "@earendil-works/pi-coding-agent"
8+
export type {
9+
ExtensionEvent as PiExtensionEvent,
10+
ExtensionAPI as PiExtensionApi,
11+
ExtensionContext as PiExtensionContext,
12+
} from '@earendil-works/pi-coding-agent';
613

7-
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
14+
import type {ExtensionAPI} from '@earendil-works/pi-coding-agent';
815

916
/** Shape returned by createOtelExtension — passed to createAgentSession({ extensions: [...] }) */
1017
export interface PiExtensionDefinition {

0 commit comments

Comments
 (0)