(server: RuntimeServer, method: string, params: unknown)
| 440 | } |
| 441 | |
| 442 | export function notifyRuntimeNodeAgentBridgeEvent(server: RuntimeServer, method: string, params: unknown): void { |
| 443 | const record = asRecord(params) |
| 444 | const providerId = optionalString(record.providerId) |
| 445 | const threadId = threadIdFromValue(params) |
| 446 | const turnId = turnIdFromValue(params) |
| 447 | if (providerId && threadId && turnId && method === "agent/turn/started") { |
| 448 | createOrUpdateServerProtocolTurnRuntime(server, { providerId, threadId, turnId, status: "running" }) |
| 449 | } else if (providerId && threadId && (method === "agent/turn/completed" || method === "agent/turn/failed")) { |
| 450 | const targetTurnId = turnId ?? latestServerProtocolTurnRuntime(server, providerId, threadId)?.nativeId |
| 451 | if (targetTurnId) { |
| 452 | createOrUpdateServerProtocolTurnRuntime(server, { |
| 453 | providerId, |
| 454 | threadId, |
| 455 | turnId: targetTurnId, |
| 456 | status: method === "agent/turn/completed" ? "completed" : "failed", |
| 457 | error: typeof record.error === "string" ? record.error : undefined, |
| 458 | }) |
| 459 | } |
| 460 | } |
| 461 | server.notify(method, params) |
| 462 | } |
| 463 | |
| 464 | export function registerRuntimeNodeServerProtocolAgentBridge( |
| 465 | bridge: RuntimeNodeServerProtocolAgentBridge, |
no test coverage detected