Files
paseo/packages/app/src/utils/agent-directory-sync.test.ts
T
Mohamed Boudra 53c14d9855 Extract client SDK package (#1052)
* Extract client SDK package

* Polish SDK client identity defaults

* Build client before dependent CI jobs

* Restore daemon client server export

* Extract protocol and client SDK packages

* Fix provider override schema validation

* Fix app test daemon client imports

* Simplify workspace build targets

* Fix CLI test server build bootstrap

* Run SDK package tests in CI

* Fix rebase package split drift

* Restore lockfile registry metadata

* Update SDK config test for prompt default

* Move terminal stream router test to client package

* Fix rebase drift for protocol imports

* Fix SDK agent capability fixture

* Restore legacy server client exports

* Fix server export compatibility test

* Advertise custom mode icon client capability

* Remove server daemon-client exports

* Format rebased mode control import

* Fix rebase drift for protocol imports

Files added by upstream PRs (#893, #1147, #1154) referenced the pre-split
shared/ paths that this branch moves into @getpaseo/protocol. Redirect
those imports to the protocol package so typecheck stays green after the
rebase.
2026-05-28 01:58:18 +08:00

96 lines
2.8 KiB
TypeScript

import { describe, expect, it } from "vitest";
import type { DaemonClient, FetchAgentsEntry } from "@getpaseo/client/internal/daemon-client";
import type { AgentSnapshotPayload } from "@getpaseo/protocol/messages";
import { PARENT_AGENT_ID_LABEL } from "@getpaseo/protocol/agent-labels";
import { useSessionStore } from "@/stores/session-store";
import { replaceFetchedAgentDirectory } from "./agent-directory-sync";
function createAgentPayload(
input: Partial<Omit<AgentSnapshotPayload, "labels">> & {
id: string;
labels?: Record<string, string>;
},
): AgentSnapshotPayload {
return {
id: input.id,
provider: input.provider ?? "codex",
cwd: input.cwd ?? "/repo",
model: input.model ?? null,
createdAt: input.createdAt ?? "2026-04-20T00:00:00.000Z",
updatedAt: input.updatedAt ?? "2026-04-20T00:01:00.000Z",
lastUserMessageAt: input.lastUserMessageAt ?? null,
status: input.status ?? "idle",
capabilities: input.capabilities ?? {
supportsStreaming: true,
supportsSessionPersistence: true,
supportsDynamicModes: true,
supportsMcpServers: true,
supportsReasoningStream: true,
supportsToolInvocations: true,
},
currentModeId: input.currentModeId ?? null,
availableModes: input.availableModes ?? [],
pendingPermissions: input.pendingPermissions ?? [],
persistence: input.persistence ?? null,
title: input.title ?? null,
labels: input.labels ?? {},
};
}
function createEntry(agent: AgentSnapshotPayload): FetchAgentsEntry {
return {
agent,
project: {
projectKey: agent.cwd,
projectName: "repo",
checkout: {
cwd: agent.cwd,
isGit: false,
currentBranch: null,
remoteUrl: null,
worktreeRoot: null,
isPaseoOwnedWorktree: false,
mainRepoRoot: null,
},
},
};
}
describe("replaceFetchedAgentDirectory", () => {
it("re-derives parentAgentId every time an agent snapshot is ingested", () => {
const serverId = "server-1";
const store = useSessionStore.getState();
store.initializeSession(serverId, null as unknown as DaemonClient);
replaceFetchedAgentDirectory({
serverId,
entries: [
createEntry(
createAgentPayload({
id: "child-1",
labels: { [PARENT_AGENT_ID_LABEL]: "parent-a" },
}),
),
],
});
replaceFetchedAgentDirectory({
serverId,
entries: [
createEntry(
createAgentPayload({
id: "child-1",
labels: { [PARENT_AGENT_ID_LABEL]: "parent-b" },
}),
),
],
});
expect(
useSessionStore.getState().sessions[serverId]?.agents.get("child-1")?.parentAgentId,
).toBe("parent-b");
store.clearSession(serverId);
});
});