agent-relay-runner 0.69.0 → 0.70.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-relay-runner",
3
- "version": "0.69.0",
3
+ "version": "0.70.0",
4
4
  "description": "Unified provider lifecycle runner for Agent Relay",
5
5
  "type": "module",
6
6
  "bin": {
@@ -20,7 +20,7 @@
20
20
  "directory": "runner"
21
21
  },
22
22
  "dependencies": {
23
- "agent-relay-sdk": "0.2.44"
23
+ "agent-relay-sdk": "0.2.45"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/bun": "latest",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agent-relay-runner",
3
3
  "description": "Thin Agent Relay runner bridge for Claude Code",
4
- "version": "0.69.0",
4
+ "version": "0.70.0",
5
5
  "agentRelayContracts": {
6
6
  "providerPluginProtocol": 1
7
7
  }
@@ -0,0 +1,59 @@
1
+ import type { MessageSessionMeta, SendMessageInput } from "agent-relay-sdk";
2
+
3
+ interface ReportOutbox {
4
+ enqueue(record: { kind: string; idempotencyKey?: string; payload: SendMessageInput }): void;
5
+ }
6
+
7
+ type SessionPublisher = (input: {
8
+ from: string;
9
+ to: string;
10
+ body: string;
11
+ session: MessageSessionMeta;
12
+ replyTo?: number;
13
+ }) => void | Promise<void>;
14
+
15
+ export async function publishCapturedResponse(input: {
16
+ publishSessionEvent: SessionPublisher;
17
+ outbox: ReportOutbox;
18
+ provider: string;
19
+ from: string;
20
+ to: string;
21
+ body: string;
22
+ session: MessageSessionMeta;
23
+ replyTo?: number;
24
+ }): Promise<void> {
25
+ await input.publishSessionEvent({
26
+ from: input.from,
27
+ to: input.to,
28
+ body: input.body,
29
+ ...(input.replyTo ? { replyTo: input.replyTo } : {}),
30
+ session: input.session,
31
+ });
32
+ enqueueCapturedResponseReport(input);
33
+ }
34
+
35
+ export function enqueueCapturedResponseReport(input: {
36
+ outbox: ReportOutbox;
37
+ provider: string;
38
+ from: string;
39
+ to: string;
40
+ body: string;
41
+ session: MessageSessionMeta;
42
+ replyTo?: number;
43
+ }): void {
44
+ if (!input.replyTo || input.to === "user") return;
45
+ const turnId = input.session.turnId ?? "";
46
+ input.outbox.enqueue({
47
+ kind: "session-message",
48
+ idempotencyKey: `response-report:${input.from}:${input.replyTo}:${turnId}`,
49
+ payload: {
50
+ from: input.from,
51
+ to: input.to,
52
+ replyTo: input.replyTo,
53
+ kind: "chat",
54
+ body: input.body,
55
+ replyExpected: false,
56
+ payload: { responseCapture: { provider: input.provider, ...input.session } },
57
+ },
58
+ });
59
+ }
@@ -22,6 +22,7 @@ import { ensureSessionScratch, reapSessionScratch, sweepStaleSessions, type Sess
22
22
  import { deliverBufferedMcpCall as deliverBufferedMcpOutboxCall, deliverRunnerOutboxEvent } from "./mcp-outbox";
23
23
  import { RunnerInsights } from "./runner-insights";
24
24
  import { BusyReconciler } from "./busy-reconciler";
25
+ import { publishCapturedResponse } from "./response-capture-report";
25
26
  import { capsFromEnv, contextStateDirFromEnv, logLevelFromEnv, mcpProxyEnabledFromEnv, orchestratorBaseDirFromEnv, orchestratorUrlFromEnv, registrationTimeoutMsFromEnv, runnerInfoFileFromEnv, runnerLogFileFromEnv, runnerOutboxDirWithInfoFallback, sessionDebugEnabled, tagsFromEnv, workspaceModeFromEnv } from "./config";
26
27
  import {
27
28
  appliedAgentProfileMetadata,
@@ -725,6 +726,7 @@ export class AgentRunner {
725
726
  });
726
727
  await this.options.adapter.deliver(this.process, prepared);
727
728
  for (const message of deliverable) {
729
+ await this.http.recordMessageDeliveryAttempt(message.id, { agentId: this.agentId, status: "delivered" }).catch(() => {});
728
730
  await this.http.markRead(message.id, this.agentId).catch(() => {});
729
731
  if (!taskIdFromMessage(message)) this.claims.finishClaim("message", String(message.id));
730
732
  }
@@ -1389,13 +1391,7 @@ export class AgentRunner {
1389
1391
  }
1390
1392
 
1391
1393
  this.sessionLog(`response captured for turn ${turnId ?? "?"} (${body.length} chars${replyToMessageId ? `, replyTo #${replyToMessageId}` : ", no replyTo"})`);
1392
- await this.publishSessionEvent({
1393
- from: this.agentId,
1394
- to: replyTarget,
1395
- body,
1396
- ...(replyToMessageId ? { replyTo: replyToMessageId } : {}),
1397
- session: { type: "response", origin: "provider", ...(turnId ? { turnId } : {}) },
1398
- });
1394
+ await publishCapturedResponse({ publishSessionEvent: (event) => this.publishSessionEvent(event), outbox: this.sessionOutbox, provider: this.options.provider, from: this.agentId, to: replyTarget, body, replyTo: replyToMessageId, session: { type: "response", origin: "provider", ...(turnId ? { turnId } : {}) } });
1399
1395
  // The agent's reply may have cleared an obligation — refresh the snapshot so the next
1400
1396
  // turn-end doesn't re-prompt for a message already answered (#196).
1401
1397
  if (replyToMessageId) this.obligationCache.markDirty();
@@ -1612,13 +1608,7 @@ export class AgentRunner {
1612
1608
  if (!route) return; // The session mirror will satisfy the user obligation; don't double-post (#196).
1613
1609
  replyToMessageId = route.replyToMessageId; replyTarget = route.to;
1614
1610
  }
1615
- await this.publishSessionEvent({
1616
- from: this.agentId,
1617
- to: replyTarget,
1618
- body,
1619
- ...(replyToMessageId ? { replyTo: replyToMessageId } : {}),
1620
- session: { type: "response", origin: event.origin ?? "provider", ...(turnId ? { turnId } : {}) },
1621
- });
1611
+ await publishCapturedResponse({ publishSessionEvent: (sessionEvent) => this.publishSessionEvent(sessionEvent), outbox: this.sessionOutbox, provider: this.options.provider, from: this.agentId, to: replyTarget, body, replyTo: replyToMessageId, session: { type: "response", origin: event.origin ?? "provider", ...(turnId ? { turnId } : {}) } });
1622
1612
  if (replyToMessageId) this.obligationCache.markDirty();
1623
1613
  return;
1624
1614
  }