mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-03 15:12:48 +00:00
fix(client): keep daemon connections lean by default (#4470)
Move supported protocol capabilities into client defaults and make session traffic subscription-driven. Preserve timeline readiness and reconnect recovery across SDK, CLI, and plugin consumers.
This commit is contained in:
@@ -12,7 +12,7 @@ import {
|
||||
} from "../../utils/timeline.js";
|
||||
import type { DaemonClient } from "@getpaseo/client/internal/daemon-client";
|
||||
import type { AgentTimelineItem } from "@getpaseo/protocol/agent-types";
|
||||
import type { AgentStreamEventPayload, AgentStreamMessage } from "@getpaseo/protocol/messages";
|
||||
import type { AgentStreamEventPayload } from "@getpaseo/protocol/messages";
|
||||
|
||||
export interface AgentAttachOptions {
|
||||
host?: string;
|
||||
@@ -134,7 +134,7 @@ export async function runAttachCommand(
|
||||
const resolvedId = fetchResult.agent.id;
|
||||
|
||||
// Print header
|
||||
console.log(`Attaching to agent ${resolvedId.substring(0, 7)}...`);
|
||||
console.log(`Fetching history for agent ${resolvedId.substring(0, 7)}...`);
|
||||
console.log(`(Press Ctrl+C to detach)\n`);
|
||||
|
||||
// Print existing output from timeline fetch.
|
||||
@@ -152,14 +152,17 @@ export async function runAttachCommand(
|
||||
}
|
||||
|
||||
// Subscribe to new events
|
||||
const unsubscribe = client.on("agent_stream", (msg: unknown) => {
|
||||
const message = msg as AgentStreamMessage;
|
||||
if (message.type !== "agent_stream") return;
|
||||
if (message.payload.agentId !== resolvedId) return;
|
||||
|
||||
printStreamEvent(message.payload.event);
|
||||
const unsubscribe = client.subscribeAgentTimeline(resolvedId, (message) => {
|
||||
if (message.type === "agent.timeline.replacement") {
|
||||
console.log("\n[Timeline replaced; earlier output is no longer current]");
|
||||
} else {
|
||||
printStreamEvent(message.payload.event);
|
||||
}
|
||||
});
|
||||
|
||||
await unsubscribe.ready;
|
||||
console.log(`Attached to agent ${resolvedId.substring(0, 7)}.`);
|
||||
|
||||
// Handle Ctrl+C to detach gracefully
|
||||
let detached = false;
|
||||
const detach = () => {
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
} from "../../utils/timeline.js";
|
||||
import type { DaemonClient } from "@getpaseo/client/internal/daemon-client";
|
||||
import type { AgentTimelineItem } from "@getpaseo/protocol/agent-types";
|
||||
import type { AgentStreamMessage } from "@getpaseo/protocol/messages";
|
||||
import { curateAgentActivity } from "@getpaseo/server";
|
||||
|
||||
export function addLogsOptions(cmd: Command): Command {
|
||||
@@ -202,12 +201,12 @@ async function runFollowMode(
|
||||
// Subscribe to new events
|
||||
const tailLabel =
|
||||
tailCount === 0 ? "no history" : `last ${tailCount} entr${tailCount === 1 ? "y" : "ies"}`;
|
||||
console.log(`\n--- Following logs (${tailLabel}; Ctrl+C to stop) ---\n`);
|
||||
|
||||
const unsubscribe = client.on("agent_stream", (msg: unknown) => {
|
||||
const message = msg as AgentStreamMessage;
|
||||
if (message.type !== "agent_stream") return;
|
||||
if (message.payload.agentId !== agentId) return;
|
||||
const unsubscribe = client.subscribeAgentTimeline(agentId, (message) => {
|
||||
if (message.type === "agent.timeline.replacement") {
|
||||
console.log("\n[Timeline replaced; earlier output is no longer current]");
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.payload.event.type === "timeline") {
|
||||
const item = message.payload.event.item;
|
||||
@@ -223,6 +222,9 @@ async function runFollowMode(
|
||||
}
|
||||
});
|
||||
|
||||
await unsubscribe.ready;
|
||||
console.log(`\n--- Following logs (${tailLabel}; Ctrl+C to stop) ---\n`);
|
||||
|
||||
// Wait for interrupt
|
||||
await new Promise<void>((resolve) => {
|
||||
const cleanup = () => {
|
||||
|
||||
Reference in New Issue
Block a user