Skip to content

Commit 6a17ca3

Browse files
authored
Merge pull request #148 from anam-org/feat/explicit-interrupt-command
feat: silence persona command
2 parents f8857e1 + 2143072 commit 6a17ca3

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/AnamClient.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,27 @@ export default class AnamClient {
448448
this.sendDataMessage(body);
449449
}
450450

451+
public interruptPersona(): void {
452+
if (!this._isStreaming) {
453+
throw new Error(
454+
'Failed to send interrupt command: not currently streaming',
455+
);
456+
}
457+
458+
const sessionId = this.getActiveSessionId();
459+
if (!sessionId) {
460+
throw new Error('Failed to send interrupt command: no active session');
461+
}
462+
463+
const body = JSON.stringify({
464+
message_type: 'interrupt',
465+
session_id: sessionId,
466+
timestamp: new Date().toISOString(), // removing Z not needed
467+
});
468+
469+
this.sendDataMessage(body);
470+
}
471+
451472
public async stopStreaming(): Promise<void> {
452473
if (this.streamingClient) {
453474
this.publicEventEmitter.emit(

0 commit comments

Comments
 (0)