+29
-20
@@ -70,6 +70,19 @@ interface FixtureSession {
|
||||
permissions: Agent.Info["permissions"];
|
||||
}
|
||||
|
||||
const defaultInput = {
|
||||
agent: "coordinate",
|
||||
description: "test",
|
||||
prompt: "work",
|
||||
worktree: { base: "main" },
|
||||
};
|
||||
|
||||
function required<T>(map: Map<string, T>, key: string) {
|
||||
const value = map.get(key);
|
||||
if (value === undefined) throw new Error(`Missing fixture entry ${key}`);
|
||||
return value;
|
||||
}
|
||||
|
||||
function fixture() {
|
||||
const herdr = new FixtureHerdr();
|
||||
const storage = new Map<string, Parameters<Context["storage"]["set"]>[1]>();
|
||||
@@ -112,7 +125,7 @@ function fixture() {
|
||||
})
|
||||
.parse(raw);
|
||||
const id = Session.ID.make(input.sessionID ?? `ses_child${++serial}`);
|
||||
if (!input.sessionID)
|
||||
if (input.sessionID === undefined || input.sessionID === "")
|
||||
sessions.set(id, {
|
||||
...parent,
|
||||
id,
|
||||
@@ -122,7 +135,7 @@ function fixture() {
|
||||
});
|
||||
order.push("create");
|
||||
yield* call.progress({ sessionID: id, status: "running" });
|
||||
order.push(`prompt:${sessions.get(id)!.location.directory}`);
|
||||
order.push(`prompt:${required(sessions, id).location.directory}`);
|
||||
prompts++;
|
||||
entered.resolve();
|
||||
if (hold)
|
||||
@@ -135,7 +148,10 @@ function fixture() {
|
||||
);
|
||||
return {
|
||||
content: "native result",
|
||||
metadata: { sessionID: id, status: input.background ? "running" : "completed" },
|
||||
metadata: {
|
||||
sessionID: id,
|
||||
status: input.background === true ? "running" : "completed",
|
||||
},
|
||||
};
|
||||
}),
|
||||
};
|
||||
@@ -144,7 +160,7 @@ function fixture() {
|
||||
[];
|
||||
const hooks: ((event: SessionContext) => Effect.Effect<void>)[] = [];
|
||||
let prompt!: (event: Pick<SessionContext, "sessionID">) => Effect.Effect<void>;
|
||||
let transform!: (editor: AgentEditor) => void;
|
||||
let transform: ((editor: AgentEditor) => void) | undefined;
|
||||
const registration = Effect.succeed({ dispose: Effect.void });
|
||||
const editAgents = (): AgentEditor => ({
|
||||
get: (id) => agents.get(id),
|
||||
@@ -185,16 +201,16 @@ function fixture() {
|
||||
}),
|
||||
},
|
||||
agent: {
|
||||
transform: (callback: typeof transform) =>
|
||||
transform: (callback: (editor: AgentEditor) => void) =>
|
||||
Effect.sync(() => {
|
||||
transform = callback;
|
||||
callback(editAgents());
|
||||
}).pipe(Effect.andThen(registration)),
|
||||
reload: () =>
|
||||
Effect.sync(() => {
|
||||
if (transform) transform(editAgents());
|
||||
transform?.(editAgents());
|
||||
}),
|
||||
get: () => Effect.succeed({ data: agents.get("multi-work")! }),
|
||||
get: () => Effect.succeed({ data: required(agents, "multi-work") }),
|
||||
list: () =>
|
||||
Effect.sync(() => {
|
||||
agentReads++;
|
||||
@@ -204,14 +220,15 @@ function fixture() {
|
||||
},
|
||||
session: {
|
||||
get: ({ sessionID }: { sessionID: string }) =>
|
||||
Effect.sync(() => sessions.get(sessionID)!),
|
||||
Effect.sync(() => required(sessions, sessionID)),
|
||||
move: ({ sessionID, directory }: { sessionID: string; directory: string }) =>
|
||||
Effect.sync(() => {
|
||||
order.push("move-request");
|
||||
if (!delayMove) {
|
||||
sessions.get(sessionID)!.location.directory = directory;
|
||||
required(sessions, sessionID).location.directory = directory;
|
||||
order.push("moved");
|
||||
if (crossProject) sessions.get(sessionID)!.projectID = "another-project";
|
||||
if (crossProject)
|
||||
required(sessions, sessionID).projectID = "another-project";
|
||||
}
|
||||
entered.resolve();
|
||||
}),
|
||||
@@ -272,15 +289,7 @@ function fixture() {
|
||||
Agent.Info.default(Agent.ID.make("build")).permissions,
|
||||
herdr,
|
||||
),
|
||||
invoke: (
|
||||
input = {
|
||||
agent: "coordinate",
|
||||
description: "test",
|
||||
prompt: "work",
|
||||
worktree: { base: "main" },
|
||||
},
|
||||
caller = call,
|
||||
) => tool.execute(input, caller),
|
||||
invoke: (input = defaultInput, caller = call) => tool.execute(input, caller),
|
||||
execute: (input: z.infer<typeof request>, caller = call) => tool.execute(input, caller),
|
||||
hold() {
|
||||
hold = true;
|
||||
@@ -381,7 +390,7 @@ test("root-local resume rejects location, binding, and live-root changes", async
|
||||
prompt: "work",
|
||||
});
|
||||
if (tamper === "session")
|
||||
f.sessions.get("ses_child1")!.location.directory = "/other";
|
||||
required(f.sessions, "ses_child1").location.directory = "/other";
|
||||
else if (tamper === "live-root") f.herdr.rootWorkspaceID = "foreign";
|
||||
else {
|
||||
const binding = bindingSchema.parse(
|
||||
|
||||
Reference in New Issue
Block a user