mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-14 13:22:37 +00:00
* feat(server): let clients create internal agents The daemon's own branch-name and commit-message generators run as internal agents: never persisted, listed, flagged, announced, or seen by plugin lifecycle hooks. Nothing outside the daemon could ask for one, because the wire config schema strips `internal` and the agent.create transform re-pins it. A plugin that runs a one-turn helper per event therefore left an archived session in History every time. Add an optional `internal` flag to `create_agent_request` (inherited by `agent.create.request`), copy it onto the config in the session's create path, and skip provider session persistence for it like the generators do. The client SDK forwards the flag on both creation paths and gates it once on `server_info.features.internalAgents`. Two daemon paths assumed every agent is public and had to follow: `resolveAgentIdentifier` now accepts a live agent by exact id, since the id set it matched against came from listings that exclude internal agents and left `wait_for_finish` answering "Agent not found"; and archiving an internal agent now closes it without writing the record that `registry.applySnapshot` used to leave behind, so `autoArchive` does not accumulate hidden files on disk. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(server): keep internal agents whole through failure, archive, and wait Review follow-ups for internal agents: - A create that fails after the runtime is registered now closes the internal agent before rethrowing, so a hidden runtime cannot outlive the failed request. Public agents keep today's behaviour. - Archiving an internal agent cascades to attached children like any parent. cascadeArchiveChildren takes the parent record instead of reading it back from storage, where an internal agent never is. - The archived snapshot and last message of an internal agent stay readable by exact id for ten minutes, so create-then-waitForFinish returns the finished turn whether the wait lands before or after an auto-archive. Storage plays that role for public agents. - The internal-agent e2e scenarios live in the existing create_agent_request lifecycle suite rather than a new file. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(server): cascade to live internal children and keep a failed internal create's worktree until it closes Internal children never reach storage, so the parent archive cascade scans live agents for them as well. A failed internal create now clears the created id only after the runtime is archived, so worktree cleanup cannot delete the directory under a runtime that would not close. Stored agent payloads carry lastError, so a retained failed helper reports its error through wait_for_finish instead of the generic message. * feat(cli,mcp): expose internal agents and document --no-wait paseo run gains --internal and create_agent gains internal, both forwarded to the create request. --no-wait becomes the documented spelling for returning immediately, matching paseo send; --background and --detach stay as hidden aliases under COMPAT tags. * test: follow the --no-wait rename and stub getRetiredInternalAgent * feat: list internal agents on request and add internal workspaces Internal agents stay hidden by default, but a caller can now ask for them: `fetch_agents_request` takes `filter.includeInternal`, snapshots carry `internal: true`, and `paseo ls --internal` shows them in an INTERNAL column. The app never passes the flag. Workspaces get the same flag. `workspace.create.request` with `internal: true` persists a hidden workspace: listings, update subscriptions, sync reads, empty-project counting, open-by-path, MCP `list_workspaces`, and plugin workspace hooks all skip it unless the caller opts in with `filter.includeInternal`. Every agent created inside an internal workspace is internal and unpersisted; AgentManager applies that from the workspace id before the plugin hook so creators cannot opt out. Archive and shutdown enumerate internal agents so nothing inside an internal workspace outlives it. Surfaces: `paseo workspace create --internal`, `paseo workspace ls --internal`, `paseo run --internal --new-workspace`, MCP `create_workspace({ internal })`, SDK `workspaces.create({ internal })` and `list({ filter: { includeInternal } })`. Clients gate on `features.internalWorkspaces`. Co-Authored-By: Claude <noreply@anthropic.com> * feat(workspaces): add background visibility with inherited creation defaults * fix(cli): resolve workspace callers on the selected daemon * test(workspaces): keep caller integration coverage in server suite * test(cli): exercise workspace callers through CLI integration harness * test(mcp): remove obsolete execution flags from browser fixtures --------- Co-authored-by: marvin-ambrozio <marvin@gustavo.eng.br> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>
290 lines
8.6 KiB
TypeScript
290 lines
8.6 KiB
TypeScript
import { beforeEach, describe, expect, it } from "vitest";
|
|
import type { StateStorage } from "zustand/middleware";
|
|
import {
|
|
createSidebarViewStorage,
|
|
hasActiveSidebarLabelFilter,
|
|
migrateSidebarViewState,
|
|
SIDEBAR_UNLABELLED_LABEL_KEY,
|
|
useSidebarViewStore,
|
|
} from "./sidebar-view-store";
|
|
|
|
interface MemoryStorage extends StateStorage<Promise<void>> {
|
|
reads: string[];
|
|
}
|
|
|
|
function createMemoryStorage(entries: Record<string, string | null>): MemoryStorage {
|
|
const reads: string[] = [];
|
|
return {
|
|
reads,
|
|
getItem: async (name) => {
|
|
reads.push(name);
|
|
return entries[name] ?? null;
|
|
},
|
|
setItem: async (name, value) => {
|
|
entries[name] = value;
|
|
},
|
|
removeItem: async (name) => {
|
|
entries[name] = null;
|
|
},
|
|
};
|
|
}
|
|
|
|
describe("sidebar view store", () => {
|
|
beforeEach(() => {
|
|
useSidebarViewStore.setState({
|
|
showBackground: false,
|
|
groupMode: "project",
|
|
hostFilters: [],
|
|
projectFilters: [],
|
|
labelFilter: { labels: [] },
|
|
});
|
|
});
|
|
|
|
it("toggles multiple hosts into and out of the filter", () => {
|
|
const store = useSidebarViewStore.getState();
|
|
store.toggleHostFilter("host-a");
|
|
store.toggleHostFilter("host-b");
|
|
|
|
expect(useSidebarViewStore.getState().hostFilters).toEqual(["host-a", "host-b"]);
|
|
|
|
store.toggleHostFilter("host-a");
|
|
|
|
expect(useSidebarViewStore.getState().hostFilters).toEqual(["host-b"]);
|
|
|
|
store.clearHostFilters();
|
|
|
|
expect(useSidebarViewStore.getState().hostFilters).toEqual([]);
|
|
});
|
|
|
|
it("keeps host filters that still point at available hosts", () => {
|
|
const store = useSidebarViewStore.getState();
|
|
store.toggleHostFilter("host-a");
|
|
store.toggleHostFilter("host-b");
|
|
|
|
store.reconcileHostFilters(["host-a", "host-b", "host-c"]);
|
|
|
|
expect(useSidebarViewStore.getState().hostFilters).toEqual(["host-a", "host-b"]);
|
|
});
|
|
|
|
it("drops a host filter after that host is removed", () => {
|
|
const store = useSidebarViewStore.getState();
|
|
store.toggleHostFilter("host-a");
|
|
store.toggleHostFilter("removed-host");
|
|
|
|
store.reconcileHostFilters(["host-a"]);
|
|
|
|
expect(useSidebarViewStore.getState().hostFilters).toEqual(["host-a"]);
|
|
});
|
|
|
|
it("migrates legacy per-host group modes to the new global mode", () => {
|
|
expect(
|
|
migrateSidebarViewState({
|
|
groupModeByServerId: {
|
|
"host-a": "project",
|
|
"host-b": "status",
|
|
},
|
|
}),
|
|
).toEqual({
|
|
showBackground: false,
|
|
groupMode: "status",
|
|
hostFilters: [],
|
|
projectFilters: [],
|
|
labelFilter: { labels: [] },
|
|
});
|
|
});
|
|
|
|
it("migrates a pre-v2 single host filter to the multi-host list", () => {
|
|
expect(
|
|
migrateSidebarViewState({
|
|
groupMode: "status",
|
|
hostFilter: "host-a",
|
|
}),
|
|
).toEqual({
|
|
showBackground: false,
|
|
groupMode: "status",
|
|
hostFilters: ["host-a"],
|
|
projectFilters: [],
|
|
labelFilter: { labels: [] },
|
|
});
|
|
});
|
|
|
|
it("keeps current persisted sidebar view state during version migration", () => {
|
|
expect(
|
|
migrateSidebarViewState({
|
|
groupMode: "status",
|
|
hostFilters: ["host-a", "host-b"],
|
|
}),
|
|
).toEqual({
|
|
showBackground: false,
|
|
groupMode: "status",
|
|
hostFilters: ["host-a", "host-b"],
|
|
projectFilters: [],
|
|
labelFilter: { labels: [] },
|
|
});
|
|
});
|
|
|
|
it("clears only the label facet", () => {
|
|
useSidebarViewStore.setState({
|
|
groupMode: "status",
|
|
hostFilters: ["host-a"],
|
|
labelFilter: { labels: ["urgent", "blocked"] },
|
|
});
|
|
|
|
useSidebarViewStore.getState().clearLabelFilter();
|
|
|
|
expect(useSidebarViewStore.getState()).toMatchObject({
|
|
groupMode: "status",
|
|
hostFilters: ["host-a"],
|
|
labelFilter: { labels: [] },
|
|
});
|
|
});
|
|
|
|
it("toggles a label on and off under one normalized identity", () => {
|
|
const { toggleLabelFilter } = useSidebarViewStore.getState();
|
|
const labels = () => useSidebarViewStore.getState().labelFilter.labels;
|
|
|
|
toggleLabelFilter("Urgent");
|
|
expect(labels()).toEqual(["urgent"]);
|
|
expect(hasActiveSidebarLabelFilter(useSidebarViewStore.getState().labelFilter)).toBe(true);
|
|
|
|
toggleLabelFilter(" URGENT ");
|
|
expect(labels()).toEqual([]);
|
|
expect(hasActiveSidebarLabelFilter(useSidebarViewStore.getState().labelFilter)).toBe(false);
|
|
});
|
|
|
|
it("filters Unlabelled alongside real labels without colliding with one", () => {
|
|
const { toggleLabelFilter } = useSidebarViewStore.getState();
|
|
|
|
toggleLabelFilter(SIDEBAR_UNLABELLED_LABEL_KEY);
|
|
toggleLabelFilter("Urgent");
|
|
expect(useSidebarViewStore.getState().labelFilter).toEqual({
|
|
labels: [SIDEBAR_UNLABELLED_LABEL_KEY, "urgent"],
|
|
});
|
|
});
|
|
|
|
it("drops deleted labels from the active filter but retains Unlabelled", () => {
|
|
useSidebarViewStore.setState({
|
|
labelFilter: { labels: [SIDEBAR_UNLABELLED_LABEL_KEY, "urgent", "removed"] },
|
|
});
|
|
|
|
useSidebarViewStore.getState().reconcileLabelFilter(["Urgent"]);
|
|
|
|
expect(useSidebarViewStore.getState().labelFilter).toEqual({
|
|
labels: [SIDEBAR_UNLABELLED_LABEL_KEY, "urgent"],
|
|
});
|
|
});
|
|
|
|
it("re-keys a persisted label filter through the normalized identity, without duplicates", () => {
|
|
expect(
|
|
migrateSidebarViewState({
|
|
labelFilter: { labels: [" Urgent ", "BLOCKED", "urgent"], match: "all" },
|
|
}).labelFilter,
|
|
).toEqual({ labels: ["urgent", "blocked"] });
|
|
});
|
|
|
|
it("toggles multiple projects into and out of the filter", () => {
|
|
const store = useSidebarViewStore.getState();
|
|
store.toggleProjectFilter("project-a");
|
|
store.toggleProjectFilter("project-b");
|
|
|
|
expect(useSidebarViewStore.getState().projectFilters).toEqual(["project-a", "project-b"]);
|
|
|
|
store.toggleProjectFilter("project-a");
|
|
|
|
expect(useSidebarViewStore.getState().projectFilters).toEqual(["project-b"]);
|
|
|
|
store.clearProjectFilters();
|
|
|
|
expect(useSidebarViewStore.getState().projectFilters).toEqual([]);
|
|
});
|
|
|
|
it("keeps the other facets when the project filter is cleared", () => {
|
|
useSidebarViewStore.setState({
|
|
groupMode: "status",
|
|
hostFilters: ["host-a"],
|
|
projectFilters: ["project-a"],
|
|
labelFilter: { labels: ["urgent"] },
|
|
});
|
|
|
|
useSidebarViewStore.getState().clearProjectFilters();
|
|
|
|
expect(useSidebarViewStore.getState()).toMatchObject({
|
|
groupMode: "status",
|
|
hostFilters: ["host-a"],
|
|
projectFilters: [],
|
|
labelFilter: { labels: ["urgent"] },
|
|
});
|
|
});
|
|
|
|
// The persisted schema is a `z.strictObject` behind `createValidatedPersistStorage`, so a key
|
|
// the schema does not list fails the parse and takes every other sidebar setting down with it.
|
|
it("carries a persisted project filter through the version migration", () => {
|
|
expect(
|
|
migrateSidebarViewState({
|
|
groupMode: "project",
|
|
hostFilters: ["host-a"],
|
|
projectFilters: ["project-a", "project-b"],
|
|
}),
|
|
).toEqual({
|
|
showBackground: false,
|
|
groupMode: "project",
|
|
hostFilters: ["host-a"],
|
|
projectFilters: ["project-a", "project-b"],
|
|
labelFilter: { labels: [] },
|
|
});
|
|
});
|
|
|
|
it("never keeps project filters from state the schema rejects", () => {
|
|
expect(migrateSidebarViewState({ projectFilters: "project-a" })).toEqual({
|
|
showBackground: false,
|
|
groupMode: "project",
|
|
hostFilters: [],
|
|
projectFilters: [],
|
|
labelFilter: { labels: [] },
|
|
});
|
|
});
|
|
|
|
it("falls back to the legacy storage key when the new key is empty", async () => {
|
|
const storage = createMemoryStorage({
|
|
"sidebar-view": null,
|
|
"sidebar-group-mode": JSON.stringify({
|
|
state: { groupModeByServerId: { "host-a": "status" } },
|
|
version: 0,
|
|
}),
|
|
});
|
|
|
|
const value = await createSidebarViewStorage(storage).getItem("sidebar-view");
|
|
|
|
expect(value).toBe(
|
|
JSON.stringify({
|
|
state: { groupModeByServerId: { "host-a": "status" } },
|
|
version: 0,
|
|
}),
|
|
);
|
|
expect(storage.reads).toEqual(["sidebar-view", "sidebar-group-mode"]);
|
|
});
|
|
|
|
it("uses the new storage key without reading the legacy key when current state exists", async () => {
|
|
const storage = createMemoryStorage({
|
|
"sidebar-view": JSON.stringify({
|
|
state: { groupMode: "project", hostFilters: ["host-a"] },
|
|
version: 2,
|
|
}),
|
|
"sidebar-group-mode": JSON.stringify({
|
|
state: { groupModeByServerId: { "host-b": "status" } },
|
|
version: 0,
|
|
}),
|
|
});
|
|
|
|
const value = await createSidebarViewStorage(storage).getItem("sidebar-view");
|
|
|
|
expect(value).toBe(
|
|
JSON.stringify({
|
|
state: { groupMode: "project", hostFilters: ["host-a"] },
|
|
version: 2,
|
|
}),
|
|
);
|
|
expect(storage.reads).toEqual(["sidebar-view"]);
|
|
});
|
|
});
|