mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-23 08:45:14 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3389138eb7 |
@@ -94,6 +94,19 @@ describe("Hub session protocol", () => {
|
||||
expect(SessionOutboundMessageSchema.parse(response)).toEqual(response);
|
||||
});
|
||||
|
||||
test("round-trips the working directory on named-agent validation", () => {
|
||||
const request = {
|
||||
type: "hub.execution.agent.validate.request",
|
||||
requestId: "validate-workspace",
|
||||
provider: "opencode",
|
||||
model: "workspace-model",
|
||||
cwd: "/workspace",
|
||||
};
|
||||
|
||||
expect(SessionInboundMessageSchema.parse(request)).toEqual(request);
|
||||
expect(SessionInboundMessageSchema.safeParse({ ...request, cwd: 123 }).success).toBe(false);
|
||||
});
|
||||
|
||||
test("accepts the Hub execution create request", () => {
|
||||
const message = {
|
||||
type: "hub.execution.agent.create.request",
|
||||
|
||||
@@ -3465,6 +3465,7 @@ export const HubExecutionAgentValidateRequestSchema = z.object({
|
||||
type: z.literal("hub.execution.agent.validate.request"),
|
||||
requestId: z.string(),
|
||||
provider: z.string(),
|
||||
cwd: z.string().optional(),
|
||||
model: z.string().optional(),
|
||||
modeId: z.string().optional(),
|
||||
thinkingOptionId: z.string().optional(),
|
||||
|
||||
@@ -6,6 +6,7 @@ import { filterSelectableAgentModels } from "./agent-sdk-types.js";
|
||||
|
||||
export interface AgentConfigurationValidationInput {
|
||||
provider: string;
|
||||
cwd?: string;
|
||||
model?: string;
|
||||
modeId?: string;
|
||||
thinkingOptionId?: string;
|
||||
|
||||
@@ -321,6 +321,40 @@ describe("ProviderSnapshotManager public surface", () => {
|
||||
}
|
||||
});
|
||||
|
||||
test("validates workspace-only models against the requested working directory", async () => {
|
||||
const cwd = resolveSnapshotCwd("/tmp/workspace-models");
|
||||
const model = { provider: "opencode", id: "workspace-model", label: "Workspace model" };
|
||||
const manager = new ProviderSnapshotManager({
|
||||
logger: createTestLogger(),
|
||||
extraClients: {
|
||||
opencode: createExtraClient("opencode", {
|
||||
isAvailable: async () => true,
|
||||
fetchCatalog: async (options) => ({
|
||||
models: options.scope === "workspace" && options.cwd === cwd ? [model] : [],
|
||||
modes: [],
|
||||
}),
|
||||
}),
|
||||
},
|
||||
});
|
||||
const input = { provider: model.provider, model: model.id };
|
||||
const unavailable = [
|
||||
{
|
||||
path: ["model"],
|
||||
message: "Model 'workspace-model' is not available for provider 'opencode'",
|
||||
},
|
||||
];
|
||||
|
||||
try {
|
||||
await expect(manager.validateAgentConfiguration(input)).resolves.toEqual(unavailable);
|
||||
await expect(manager.validateAgentConfiguration({ ...input, cwd })).resolves.toEqual([]);
|
||||
await expect(
|
||||
manager.validateAgentConfiguration({ ...input, cwd: "/tmp/missing-workspace" }),
|
||||
).resolves.toEqual(unavailable);
|
||||
} finally {
|
||||
manager.destroy();
|
||||
}
|
||||
});
|
||||
|
||||
test("accepts a legacy Ultra Code choice on a model with an independent effort catalog", async () => {
|
||||
const manager = new ProviderSnapshotManager({
|
||||
logger: createTestLogger(),
|
||||
|
||||
@@ -650,6 +650,7 @@ export class ProviderSnapshotManager {
|
||||
|
||||
const provider = await this.getProvider({
|
||||
provider: input.provider,
|
||||
cwd: input.cwd,
|
||||
wait: true,
|
||||
});
|
||||
if (!provider.enabled) {
|
||||
|
||||
@@ -86,23 +86,29 @@ class RejectingHubExecutionAgents implements HubExecutionAgents {
|
||||
}
|
||||
|
||||
describe("HubExecutionController", () => {
|
||||
test("validates a named agent through the daemon provider registry", async () => {
|
||||
test.each([
|
||||
{ cwd: "/workspace", valid: true },
|
||||
{ cwd: undefined, valid: false },
|
||||
{ cwd: "/missing-workspace", valid: false },
|
||||
])("validates a named agent with cwd $cwd", async ({ cwd, valid }) => {
|
||||
const messages: SessionOutboundMessage[] = [];
|
||||
const unavailable = { path: ["model"], message: "Model is unavailable" };
|
||||
const validateAgentConfiguration = async (
|
||||
message: Omit<HubExecutionAgentValidateRequest, "type" | "requestId">,
|
||||
) =>
|
||||
message.model === "missing" ? [{ path: ["model"], message: "Model is unavailable" }] : [];
|
||||
input: Omit<HubExecutionAgentValidateRequest, "type" | "requestId">,
|
||||
) => (input.model === "workspace-model" && input.cwd === "/workspace" ? [] : [unavailable]);
|
||||
const controller = new HubExecutionController({
|
||||
agents: new ControlledHubExecutionAgents(),
|
||||
validateAgentConfiguration,
|
||||
send: (message) => messages.push(message),
|
||||
});
|
||||
|
||||
const scope = cwd === undefined ? {} : { cwd };
|
||||
await controller.validateAgent({
|
||||
type: "hub.execution.agent.validate.request",
|
||||
requestId: "validate-agent",
|
||||
provider: "codex",
|
||||
model: "missing",
|
||||
provider: "opencode",
|
||||
model: "workspace-model",
|
||||
...scope,
|
||||
});
|
||||
|
||||
expect(messages).toEqual([
|
||||
@@ -110,8 +116,8 @@ describe("HubExecutionController", () => {
|
||||
type: "hub.execution.agent.validate.response",
|
||||
payload: {
|
||||
requestId: "validate-agent",
|
||||
valid: false,
|
||||
issues: [{ path: ["model"], message: "Model is unavailable" }],
|
||||
valid,
|
||||
issues: valid ? [] : [unavailable],
|
||||
error: null,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -87,6 +87,7 @@ export class HubExecutionController {
|
||||
try {
|
||||
issues = await this.validateAgentConfiguration({
|
||||
provider: message.provider,
|
||||
cwd: message.cwd,
|
||||
model: message.model,
|
||||
modeId: message.modeId,
|
||||
thinkingOptionId: message.thinkingOptionId,
|
||||
|
||||
Reference in New Issue
Block a user