mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-22 16:25:39 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2ca56ee73 | ||
|
|
59f19e4e5e |
@@ -1,14 +0,0 @@
|
||||
# Tab switcher sheet drag on iPhone
|
||||
|
||||
Run on a task-owned iPhone 17 simulator (402×874 points, portrait) with the development bundle loaded and a connected isolated host. Select a workspace whose first tab is an agent and whose next 11 tabs are terminals, and select the agent tab. Dismiss the notification entitlement toast.
|
||||
|
||||
The sheet exposes its rows to XCUITest as one "Bottom Sheet" element, so the flow taps fixed points and asserts which tab opens. The sheet opens at 60%, where its handle is at y=350, and expands to 90%, where its handle is at y=87.
|
||||
|
||||
1. A swipe up on the list must expand the sheet. The tap at y=300 then lands on the fourth row and opens a terminal. Without the expansion it lands on the backdrop, and no terminal opens.
|
||||
2. A swipe down on the list at 90% must collapse the sheet. The tap at y=424 then lands on the first row and opens the agent. Without the collapse it lands on the sixth row, which is a terminal.
|
||||
|
||||
The flow ends on the agent tab, so you can replay it. Replay it on the Namespace Mac with an explicit device:
|
||||
|
||||
```sh
|
||||
agent-device replay packages/app/e2e/mobile/agent-device/native-tab-switcher-sheet-drag.ios.ad --platform ios --device 'iPhone 17'
|
||||
```
|
||||
@@ -1,20 +0,0 @@
|
||||
context platform=ios timeout=60000 retries=0
|
||||
env APP_ID=sh.paseo.debug
|
||||
|
||||
open "${APP_ID}"
|
||||
wait "id=\"agent-chat-scroll\"" 20000
|
||||
press "id=\"workspace-tab-switcher-trigger\""
|
||||
wait "label=\"Bottom Sheet\"" 10000
|
||||
gesture pan 200 650 0 -300 500
|
||||
wait 1000
|
||||
press 200 300
|
||||
wait "id=\"terminal-surface\"" 10000
|
||||
press "id=\"workspace-tab-switcher-trigger\""
|
||||
wait "label=\"Bottom Sheet\"" 10000
|
||||
gesture pan 200 650 0 -300 500
|
||||
wait 1000
|
||||
gesture pan 200 400 0 300 500
|
||||
wait 1000
|
||||
press 200 424
|
||||
wait "id=\"agent-chat-scroll\"" 10000
|
||||
close
|
||||
@@ -132,7 +132,7 @@ using namespace facebook::react;
|
||||
if (!props.maintainVisibleContentPosition || scrollView.contentSize.width > self.frame.size.width) {
|
||||
return nil;
|
||||
}
|
||||
NSArray<UIView *> *children = [self paseoScrollContentView].subviews;
|
||||
NSArray<UIView *> *children = [self contentView].subviews;
|
||||
NSUInteger first = props.maintainVisibleContentPosition.value().minIndexForVisible;
|
||||
for (NSUInteger index = first; index < children.count; ++index) {
|
||||
UIView *child = children[index];
|
||||
@@ -149,11 +149,7 @@ using namespace facebook::react;
|
||||
[((RCTViewComponentView *)view).nativeId isEqualToString:@"paseo-end-pin"];
|
||||
}
|
||||
|
||||
// Not `contentView`: that name would override RCTViewComponentView's getter, which
|
||||
// react-native-gesture-handler reads to pick the view a gesture binds to. Bound to the content
|
||||
// child, a bottom sheet's scroll gesture loses its pairing with the scroll view, so body drags
|
||||
// neither expand the sheet nor scroll the list until the sheet is at its top detent.
|
||||
- (UIView *)paseoScrollContentView
|
||||
- (UIView *)contentView
|
||||
{
|
||||
for (UIView *child in self.containerView.subviews) {
|
||||
if (![child conformsToProtocol:@protocol(RCTCustomPullToRefreshViewProtocol)]) {
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
createFloatingPanelHosts,
|
||||
type FloatingPanelHostRect,
|
||||
type MeasurableFloatingPanelHost,
|
||||
} from "./floating-panel-hosts";
|
||||
|
||||
function createHost(rect: FloatingPanelHostRect): MeasurableFloatingPanelHost {
|
||||
return {
|
||||
measureInWindow: (callback) => callback(rect.x, rect.y, rect.width, rect.height),
|
||||
};
|
||||
}
|
||||
|
||||
const WORKSPACE_RECT: FloatingPanelHostRect = { x: 10, y: 20, width: 800, height: 600 };
|
||||
const RETAINED_VIEWPORT: FloatingPanelHostRect = { x: 0, y: 0, width: 1200, height: 900 };
|
||||
|
||||
describe("floating panel hosts", () => {
|
||||
it("measures the newest host registered under the name", async () => {
|
||||
const hosts = createFloatingPanelHosts();
|
||||
hosts.register("workspace", createHost(WORKSPACE_RECT));
|
||||
hosts.register("workspace", createHost(RETAINED_VIEWPORT));
|
||||
|
||||
expect(await hosts.measure("workspace")).toEqual(RETAINED_VIEWPORT);
|
||||
});
|
||||
|
||||
it("keeps measuring a survivor after the newest host unregisters", async () => {
|
||||
const hosts = createFloatingPanelHosts();
|
||||
const unregisterSurvivor = hosts.register("workspace", createHost(WORKSPACE_RECT));
|
||||
const unregisterNewest = hosts.register("workspace", createHost(RETAINED_VIEWPORT));
|
||||
|
||||
unregisterNewest();
|
||||
|
||||
expect(await hosts.measure("workspace")).toEqual(WORKSPACE_RECT);
|
||||
unregisterSurvivor();
|
||||
});
|
||||
|
||||
it("returns null once every host under the name is gone", async () => {
|
||||
const hosts = createFloatingPanelHosts();
|
||||
const unregisterFirst = hosts.register("workspace", createHost(WORKSPACE_RECT));
|
||||
const unregisterSecond = hosts.register("workspace", createHost(RETAINED_VIEWPORT));
|
||||
|
||||
unregisterFirst();
|
||||
unregisterSecond();
|
||||
|
||||
expect(await hosts.measure("workspace")).toBeNull();
|
||||
});
|
||||
|
||||
it("skips hosts that are not laid out", async () => {
|
||||
const hosts = createFloatingPanelHosts();
|
||||
hosts.register("workspace", createHost(WORKSPACE_RECT));
|
||||
hosts.register("workspace", createHost({ x: 0, y: 0, width: 0, height: 0 }));
|
||||
|
||||
expect(await hosts.measure("workspace")).toEqual(WORKSPACE_RECT);
|
||||
});
|
||||
|
||||
it("ignores a repeated unregister of the same host", async () => {
|
||||
const hosts = createFloatingPanelHosts();
|
||||
const unregister = hosts.register("workspace", createHost(WORKSPACE_RECT));
|
||||
|
||||
unregister();
|
||||
unregister();
|
||||
|
||||
expect(await hosts.measure("workspace")).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -1,57 +0,0 @@
|
||||
export interface FloatingPanelHostRect {
|
||||
x: number;
|
||||
y: number;
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
export interface MeasurableFloatingPanelHost {
|
||||
measureInWindow(callback: (x: number, y: number, width: number, height: number) => void): void;
|
||||
}
|
||||
|
||||
export interface FloatingPanelHosts<T extends MeasurableFloatingPanelHost> {
|
||||
register(name: string, host: T): () => void;
|
||||
measure(name: string): Promise<FloatingPanelHostRect | null>;
|
||||
}
|
||||
|
||||
function measureHost(host: MeasurableFloatingPanelHost): Promise<FloatingPanelHostRect> {
|
||||
return new Promise((resolve) => {
|
||||
host.measureInWindow((x, y, width, height) => resolve({ x, y, width, height }));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Hosts are addressed by name, and one name can have several live hosts: a workspace
|
||||
* screen mounts its own host while retained copies of that screen stay mounted. Track
|
||||
* every host so unmounting one leaves the others measurable.
|
||||
*/
|
||||
export function createFloatingPanelHosts<
|
||||
T extends MeasurableFloatingPanelHost,
|
||||
>(): FloatingPanelHosts<T> {
|
||||
const hostsByName = new Map<string, T[]>();
|
||||
|
||||
function register(name: string, host: T): () => void {
|
||||
const hosts = hostsByName.get(name) ?? [];
|
||||
hostsByName.set(name, hosts);
|
||||
hosts.push(host);
|
||||
|
||||
return () => {
|
||||
const index = hosts.indexOf(host);
|
||||
if (index === -1) return;
|
||||
hosts.splice(index, 1);
|
||||
if (hosts.length === 0 && hostsByName.get(name) === hosts) {
|
||||
hostsByName.delete(name);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
async function measure(name: string): Promise<FloatingPanelHostRect | null> {
|
||||
const hosts = hostsByName.get(name);
|
||||
if (!hosts || hosts.length === 0) return null;
|
||||
|
||||
const rects = await Promise.all(hosts.toReversed().map(measureHost));
|
||||
return rects.find((rect) => rect.width > 0 && rect.height > 0) ?? rects[0];
|
||||
}
|
||||
|
||||
return { register, measure };
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
import React, { act } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { Portal, PortalProvider } from "@gorhom/portal";
|
||||
import { FloatingPanelPortalHost, measureFloatingPanelPortalHost } from "./floating-panel-portal";
|
||||
|
||||
describe("Floating panel host lifetime", () => {
|
||||
test("removing the newest host preserves the surviving host measurement", async () => {
|
||||
const container = document.createElement("div");
|
||||
container.style.cssText = "position:relative;width:800px;height:600px";
|
||||
document.body.appendChild(container);
|
||||
const root = createRoot(container);
|
||||
function Content({ overlap }: { overlap: boolean }) {
|
||||
return (
|
||||
<PortalProvider shouldAddRootHost={false}>
|
||||
<FloatingPanelPortalHost name="workspace" />
|
||||
{overlap && <FloatingPanelPortalHost name="workspace" />}
|
||||
<Portal hostName="workspace" name="picker">
|
||||
<div data-testid="picker">Commands</div>
|
||||
</Portal>
|
||||
</PortalProvider>
|
||||
);
|
||||
}
|
||||
try {
|
||||
await act(async () => root.render(<Content overlap={true} />));
|
||||
expect(await measureFloatingPanelPortalHost("workspace")).toMatchObject({
|
||||
width: 800,
|
||||
height: 600,
|
||||
});
|
||||
await act(async () => root.render(<Content overlap={false} />));
|
||||
expect(await measureFloatingPanelPortalHost("workspace")).toMatchObject({
|
||||
width: 800,
|
||||
height: 600,
|
||||
});
|
||||
} finally {
|
||||
await act(async () => root.unmount());
|
||||
container.remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -8,21 +8,32 @@ import {
|
||||
} from "react";
|
||||
import { StyleSheet, View } from "react-native";
|
||||
import { PortalHost } from "@gorhom/portal";
|
||||
import {
|
||||
createFloatingPanelHosts,
|
||||
type FloatingPanelHostRect,
|
||||
} from "@/components/ui/floating-panel-hosts";
|
||||
|
||||
export const DEFAULT_FLOATING_PANEL_PORTAL_HOST = "content-floating-panels";
|
||||
|
||||
const FloatingPanelPortalHostNameContext = createContext(DEFAULT_FLOATING_PANEL_PORTAL_HOST);
|
||||
|
||||
const portalHosts = createFloatingPanelHosts<View>();
|
||||
interface Rect {
|
||||
x: number;
|
||||
y: number;
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
export function measureFloatingPanelPortalHost(
|
||||
name: string,
|
||||
): Promise<FloatingPanelHostRect | null> {
|
||||
return portalHosts.measure(name);
|
||||
const portalHostElements = new Map<string, View>();
|
||||
|
||||
function measureElement(element: View): Promise<Rect> {
|
||||
return new Promise((resolve) => {
|
||||
element.measureInWindow((x, y, width, height) => {
|
||||
resolve({ x, y, width, height });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function measureFloatingPanelPortalHost(name: string): Promise<Rect | null> {
|
||||
const element = portalHostElements.get(name);
|
||||
if (!element) return Promise.resolve(null);
|
||||
return measureElement(element);
|
||||
}
|
||||
|
||||
export function FloatingPanelPortalHostNameProvider({
|
||||
@@ -53,7 +64,12 @@ export function FloatingPanelPortalHost({
|
||||
useEffect(() => {
|
||||
const host = hostRef.current;
|
||||
if (!host) return undefined;
|
||||
return portalHosts.register(name, host);
|
||||
portalHostElements.set(name, host);
|
||||
return () => {
|
||||
if (portalHostElements.get(name) === host) {
|
||||
portalHostElements.delete(name);
|
||||
}
|
||||
};
|
||||
}, [name]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -46,7 +46,6 @@ import {
|
||||
type ProviderEvent,
|
||||
type ProviderInput,
|
||||
type ProviderLaunch,
|
||||
type ProviderModel,
|
||||
type ProviderPermissionResponse,
|
||||
type ProviderPersistence,
|
||||
type ProviderSessionConfig,
|
||||
@@ -695,10 +694,7 @@ class AcpRuntime {
|
||||
this.nativeSessionId = response.sessionId;
|
||||
this.modes = response.modes ?? null;
|
||||
this.configOptions = response.configOptions ?? [];
|
||||
let catalog = toProviderCatalog(this.modes, this.configOptions);
|
||||
if (this.options.options.acpOptions?.perModelThinkingOptions) {
|
||||
catalog = { ...catalog, models: await this.modelsWithOwnThinkingOptions(catalog) };
|
||||
}
|
||||
const catalog = toProviderCatalog(this.modes, this.configOptions);
|
||||
const autoAcceptMode = this.options.options.acpOptions?.autoAcceptMode;
|
||||
if (!autoAcceptMode) return catalog;
|
||||
return {
|
||||
@@ -708,33 +704,6 @@ class AcpRuntime {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects each model in the discovery session to read the thinking options the agent lists for
|
||||
* it, then selects the opening model again for the transformers that run after discovery.
|
||||
*/
|
||||
private async modelsWithOwnThinkingOptions(catalog: ProviderCatalog): Promise<ProviderModel[]> {
|
||||
const models: ProviderModel[] = [];
|
||||
for (const model of catalog.models) {
|
||||
await this.selectModel(model.id);
|
||||
const { thinkingOptions, thinkingOption } = toProviderConfigState(
|
||||
this.modes,
|
||||
this.configOptions,
|
||||
);
|
||||
models.push({
|
||||
...model,
|
||||
thinkingOptions: [...thinkingOptions],
|
||||
defaultThinkingOptionId: thinkingOption,
|
||||
});
|
||||
}
|
||||
if (catalog.defaultModel) await this.selectModel(catalog.defaultModel);
|
||||
return models;
|
||||
}
|
||||
|
||||
private async selectModel(model: string): Promise<void> {
|
||||
if (selectedValue(modelOption(this.configOptions)) === model) return;
|
||||
await this.applyNativeConfigChange({ target: "model", value: model });
|
||||
}
|
||||
|
||||
async prompt(input: Extract<ProviderInput, { type: "session.prompt" }>): Promise<void> {
|
||||
if (this.closing || this.processFailed || this.deferredRetirement) {
|
||||
throw new Error("ACP session is closed");
|
||||
|
||||
@@ -65,24 +65,6 @@ async function waitForEvent(
|
||||
return events.find(predicate)!;
|
||||
}
|
||||
|
||||
interface ModelThinking {
|
||||
id: string;
|
||||
thinkingOptions?: readonly { id: string }[];
|
||||
defaultThinkingOptionId?: string;
|
||||
}
|
||||
|
||||
function modelThinking(model: ModelThinking) {
|
||||
return {
|
||||
id: model.id,
|
||||
thinkingOptions: model.thinkingOptions?.map(optionId),
|
||||
defaultThinkingOptionId: model.defaultThinkingOptionId,
|
||||
};
|
||||
}
|
||||
|
||||
function optionId(option: { id: string }): string {
|
||||
return option.id;
|
||||
}
|
||||
|
||||
type AcpRequestMessage = Extract<AcpStreamMessage, { id: string | number | null; method: string }>;
|
||||
|
||||
interface ConnectorInstance {
|
||||
@@ -2015,70 +1997,6 @@ lines.on("line", (line) => {
|
||||
},
|
||||
);
|
||||
|
||||
it("discovers each model's own thinking options when the agent describes only the selected model", async () => {
|
||||
const executable = await fakeAcp(`const readline = require("node:readline");
|
||||
const lines = readline.createInterface({ input: process.stdin });
|
||||
const send = (message) => process.stdout.write(JSON.stringify(message) + "\\n");
|
||||
const levels = (values) => values.map((value) => ({ name: value[0].toUpperCase() + value.slice(1), value }));
|
||||
const thinking = {
|
||||
neon: { currentValue: "high", options: levels(["low", "high", "xhigh"]) },
|
||||
carbon: { currentValue: "medium", options: levels(["low", "medium", "high"]) },
|
||||
};
|
||||
let model = "neon";
|
||||
const options = () => [
|
||||
{ id: "model", name: "Model", category: "model", type: "select", currentValue: model, options: [{ name: "Neon", value: "neon" }, { name: "Carbon", value: "carbon" }, { name: "Orchestrator", value: "orchestrator" }] },
|
||||
...(thinking[model] ? [{ id: "thought_level", name: "Thinking", category: "thought_level", type: "select", ...thinking[model] }] : []),
|
||||
];
|
||||
lines.on("line", (line) => {
|
||||
const message = JSON.parse(line);
|
||||
if (message.method === "initialize") send({ jsonrpc: "2.0", id: message.id, result: { protocolVersion: message.params.protocolVersion, agentCapabilities: {} } });
|
||||
else if (message.method === "session/new") send({ jsonrpc: "2.0", id: message.id, result: { sessionId: "native-1", modes: null, configOptions: options() } });
|
||||
else if (message.method === "session/set_config_option") {
|
||||
if (message.params.configId === "model") model = message.params.value;
|
||||
send({ jsonrpc: "2.0", id: message.id, result: { configOptions: options() } });
|
||||
}
|
||||
});`);
|
||||
let modelSeenByTransformer: unknown;
|
||||
const registration = runAcpProvider({
|
||||
id: "test-acp",
|
||||
label: "Test ACP",
|
||||
command: [process.execPath, executable],
|
||||
acpOptions: { perModelThinkingOptions: true },
|
||||
transformers: [
|
||||
{
|
||||
async discover(catalog, { config }) {
|
||||
modelSeenByTransformer = (await config.read()).model;
|
||||
return catalog;
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
const connection = await registration.connect({ versions: [1], capabilities: [] });
|
||||
const events: ProviderEvent[] = [];
|
||||
connection.onEvent((event) => events.push(event));
|
||||
try {
|
||||
await connection.send({ type: "catalog", requestId: "catalog-1", cwd: process.cwd() });
|
||||
const event = await waitForEvent(
|
||||
events,
|
||||
(candidate) => candidate.type === "catalog" || candidate.type === "request.failed",
|
||||
);
|
||||
if (event.type !== "catalog") throw new Error(`Expected catalog, got ${event.type}`);
|
||||
expect(event.catalog.defaultModel).toBe("neon");
|
||||
expect(event.catalog.models.map(modelThinking)).toEqual([
|
||||
{ id: "neon", thinkingOptions: ["low", "high", "xhigh"], defaultThinkingOptionId: "high" },
|
||||
{
|
||||
id: "carbon",
|
||||
thinkingOptions: ["low", "medium", "high"],
|
||||
defaultThinkingOptionId: "medium",
|
||||
},
|
||||
{ id: "orchestrator", thinkingOptions: [], defaultThinkingOptionId: undefined },
|
||||
]);
|
||||
expect(modelSeenByTransformer).toBe("neon");
|
||||
} finally {
|
||||
await connection.close();
|
||||
}
|
||||
});
|
||||
|
||||
it("selects the model control when an agent files several controls under the model category", async () => {
|
||||
const executable = await fakeAcp(`const readline = require("node:readline");
|
||||
const lines = readline.createInterface({ input: process.stdin });
|
||||
|
||||
@@ -49,11 +49,6 @@ export interface AcpOptions {
|
||||
startupTimeoutMs?: number;
|
||||
/** Global discovery initializes ACP but returns an empty catalog without opening a session. */
|
||||
workspaceOnlyCatalog?: boolean;
|
||||
/**
|
||||
* For an agent that lists thinking options only for the selected model: discovery selects each
|
||||
* model in turn and records the thinking options the agent lists for it, or none.
|
||||
*/
|
||||
perModelThinkingOptions?: boolean;
|
||||
waitForInitialCommands?: boolean;
|
||||
initialCommandsTimeoutMs?: number;
|
||||
/**
|
||||
|
||||
@@ -60,24 +60,6 @@ interface ProviderHarnessOptions {
|
||||
handleInput?: (input: ProviderInput, emit: (event: ProviderEvent) => void) => Promise<boolean>;
|
||||
}
|
||||
|
||||
interface ModelThinking {
|
||||
id: string;
|
||||
thinkingOptions?: readonly { id: string }[];
|
||||
defaultThinkingOptionId?: string;
|
||||
}
|
||||
|
||||
function modelThinking(model: ModelThinking) {
|
||||
return {
|
||||
id: model.id,
|
||||
thinkingOptions: model.thinkingOptions?.map(optionId),
|
||||
defaultThinkingOptionId: model.defaultThinkingOptionId,
|
||||
};
|
||||
}
|
||||
|
||||
function optionId(option: { id: string }): string {
|
||||
return option.id;
|
||||
}
|
||||
|
||||
function controlKey(control: { key: string }): string {
|
||||
return control.key;
|
||||
}
|
||||
@@ -2149,48 +2131,6 @@ describe("PluginAgentClientRegistry", () => {
|
||||
}
|
||||
});
|
||||
|
||||
test("keeps a model's own thinking options and default instead of the catalog's", async () => {
|
||||
const harness = createProviderHarness({
|
||||
async handleInput(input, emit) {
|
||||
if (input.type !== "catalog") return false;
|
||||
emit({
|
||||
type: "catalog",
|
||||
requestId: input.requestId,
|
||||
catalog: {
|
||||
models: [
|
||||
{ id: "shared", label: "Shared" },
|
||||
{
|
||||
id: "fast",
|
||||
label: "Fast",
|
||||
thinkingOptions: [{ id: "light", label: "Light" }],
|
||||
defaultThinkingOptionId: "light",
|
||||
},
|
||||
{ id: "planner", label: "Planner", thinkingOptions: [] },
|
||||
],
|
||||
modes: [],
|
||||
thinkingOptions: [{ id: "deep", label: "Deep" }],
|
||||
defaultModel: "shared",
|
||||
defaultThinkingOption: "deep",
|
||||
},
|
||||
});
|
||||
return true;
|
||||
},
|
||||
});
|
||||
const registry = new PluginAgentClientRegistry(createTestLogger());
|
||||
registry.replace([harness.registration]);
|
||||
try {
|
||||
const client = registry.clients()[harness.registration.id]!;
|
||||
const catalog = await client.fetchCatalog({ scope: "global", force: false });
|
||||
expect(catalog.models.map(modelThinking)).toEqual([
|
||||
{ id: "shared", thinkingOptions: ["deep"], defaultThinkingOptionId: "deep" },
|
||||
{ id: "fast", thinkingOptions: ["light"], defaultThinkingOptionId: "light" },
|
||||
{ id: "planner", thinkingOptions: [], defaultThinkingOptionId: undefined },
|
||||
]);
|
||||
} finally {
|
||||
await registry.shutdown();
|
||||
}
|
||||
});
|
||||
|
||||
test("adapts callback providers into the existing AgentClient and AgentSession path", async () => {
|
||||
const harness = createProviderHarness();
|
||||
const registry = new PluginAgentClientRegistry(createTestLogger());
|
||||
|
||||
@@ -2092,21 +2092,14 @@ function mapModel(
|
||||
catalogThinkingOptions: Extract<ProviderEvent, { type: "catalog" }>["catalog"]["thinkingOptions"],
|
||||
catalogDefaultThinkingOption: string | undefined,
|
||||
): AgentModelDefinition {
|
||||
// A default belongs to the options it was chosen from, so a model with its own options never
|
||||
// takes the catalog's default.
|
||||
const thinking = model.thinkingOptions
|
||||
? { options: model.thinkingOptions, defaultId: model.defaultThinkingOptionId }
|
||||
: {
|
||||
options: catalogThinkingOptions,
|
||||
defaultId: model.defaultThinkingOptionId ?? catalogDefaultThinkingOption,
|
||||
};
|
||||
const thinkingOptions = model.thinkingOptions ?? catalogThinkingOptions;
|
||||
return {
|
||||
...model,
|
||||
provider,
|
||||
isDefault: model.isDefault ?? model.id === defaultModel,
|
||||
metadata: model.metadata ? { ...model.metadata } : undefined,
|
||||
thinkingOptions: thinking.options?.map((option) => Object.assign({}, option)),
|
||||
defaultThinkingOptionId: thinking.defaultId,
|
||||
thinkingOptions: thinkingOptions?.map((option) => Object.assign({}, option)),
|
||||
defaultThinkingOptionId: model.defaultThinkingOptionId ?? catalogDefaultThinkingOption,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1123,10 +1123,12 @@ export default function contribute(plugin: unknown) {
|
||||
});
|
||||
|
||||
it("rejects provider input while a connection is closing", async () => {
|
||||
const releaseDirectory = await mkdtemp(path.join(tmpdir(), "paseo-provider-close-"));
|
||||
const releaseFile = path.join(releaseDirectory, "release");
|
||||
const directory = await createPlugin(
|
||||
"closing-provider",
|
||||
`import type { ProviderRegistration } from "@getpaseo/plugin/server/provider";
|
||||
const closeReleased = Promise.withResolvers<void>();
|
||||
`import { readFile, writeFile } from "node:fs/promises";
|
||||
import type { ProviderRegistration } from "@getpaseo/plugin/server/provider";
|
||||
const provider: ProviderRegistration = {
|
||||
id: "delayed",
|
||||
label: "Delayed",
|
||||
@@ -1138,7 +1140,10 @@ const provider: ProviderRegistration = {
|
||||
onEvent() { return () => undefined; },
|
||||
async close() {
|
||||
console.log("provider close started");
|
||||
await closeReleased.promise;
|
||||
while (true) {
|
||||
try { await readFile(${JSON.stringify(releaseFile)}); break; }
|
||||
catch { await new Promise((resolve) => setTimeout(resolve, 10)); }
|
||||
}
|
||||
console.log("provider close completed");
|
||||
},
|
||||
};
|
||||
@@ -1146,11 +1151,7 @@ const provider: ProviderRegistration = {
|
||||
};
|
||||
export default function contribute(server: { registerProvider(provider: ProviderRegistration): void }) {
|
||||
server.registerProvider(provider);
|
||||
return () => {
|
||||
console.log("plugin cleanup started");
|
||||
// Let shutdown reach the pending close before releasing it.
|
||||
setImmediate(closeReleased.resolve);
|
||||
};
|
||||
return () => console.log("plugin cleanup started");
|
||||
}`,
|
||||
);
|
||||
const closedReports: unknown[] = [];
|
||||
@@ -1173,14 +1174,20 @@ export default function contribute(server: { registerProvider(provider: Provider
|
||||
await expect(connection.send({ type: "catalog", requestId: "during-close" })).rejects.toThrow(
|
||||
"Provider connection is closing",
|
||||
);
|
||||
await Promise.all([closing, runtime.stopPluginById("closing-provider")]);
|
||||
const stopping = runtime.stopPluginById("closing-provider");
|
||||
await expect
|
||||
.poll(() => pluginMessages(runtime, "closing-provider"))
|
||||
.toContain("plugin cleanup started");
|
||||
await writeFile(releaseFile, "release");
|
||||
await Promise.all([closing, stopping]);
|
||||
const messages = pluginMessages(runtime, "closing-provider");
|
||||
expect(messages).toContain("plugin cleanup started");
|
||||
expect(messages).toContain("provider close completed");
|
||||
expect(messages).not.toContain("provider accepted input");
|
||||
expect(closedReports).toHaveLength(1);
|
||||
} finally {
|
||||
await writeFile(releaseFile, "release");
|
||||
await runtime.stopAll();
|
||||
await rm(releaseDirectory, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -517,112 +517,6 @@ it.each(["live", "replay"] as const)(
|
||||
},
|
||||
);
|
||||
|
||||
// agy 1.5.14 lists `thought_level` only for the selected model and omits it for Orchestrator.
|
||||
it("offers each model its own thinking options and opens Orchestrator with its default", async () => {
|
||||
const { directory, launch } = await launchAgent(`
|
||||
const { createInterface } = require("node:readline");
|
||||
const levels = (...values) => values.map((value) => ({ value, name: value }));
|
||||
const thinking = {
|
||||
"gemini-4-neon": { currentValue: "high", options: levels("low", "medium", "high", "xhigh") },
|
||||
"gemini-4-carbon": { currentValue: "high", options: levels("low", "medium", "high") },
|
||||
"claude-opus-5-5": { currentValue: "medium", options: levels("low", "medium", "high") },
|
||||
};
|
||||
let model = "gemini-4-neon";
|
||||
const configOptions = () => [
|
||||
{ id: "model", name: "Model", category: "model", type: "select", currentValue: model, options: [
|
||||
{ value: "gemini-4-neon", name: "Gemini 4 Neon" },
|
||||
{ value: "gemini-4-carbon", name: "Gemini 4 Carbon" },
|
||||
{ value: "gemini-pro-orchestrator-neon", name: "Orchestrator (Neon)" },
|
||||
{ value: "claude-opus-5-5", name: "Claude Opus 5.5" },
|
||||
] },
|
||||
...(thinking[model] ? [{ id: "thought_level", name: "Thinking", category: "thought_level", type: "select", ...thinking[model] }] : []),
|
||||
{ id: "mode", name: "Mode", category: "mode", type: "select", currentValue: "default",
|
||||
options: [{ value: "default", name: "Default" }, { value: "plan", name: "Plan" }] },
|
||||
];
|
||||
const send = (message) => process.stdout.write(JSON.stringify({ jsonrpc: "2.0", ...message }) + "\\n");
|
||||
createInterface({ input: process.stdin }).on("line", (line) => {
|
||||
const { id, method, params } = JSON.parse(line);
|
||||
if (method === "initialize") send({ id, result: { protocolVersion: 1, agentCapabilities: {} } });
|
||||
if (method === "session/new") {
|
||||
model = "gemini-4-neon";
|
||||
send({ id, result: { sessionId: "native", configOptions: configOptions() } });
|
||||
}
|
||||
if (method === "session/set_config_option") {
|
||||
if (params.configId === "thought_level" && !thinking[model]) {
|
||||
send({ id, error: { code: -32602, message: "unknown config option" } });
|
||||
return;
|
||||
}
|
||||
if (params.configId === "model") model = params.value;
|
||||
else if (params.configId === "thought_level") thinking[model].currentValue = params.value;
|
||||
send({ id, result: { configOptions: configOptions() } });
|
||||
}
|
||||
if (method === "session/close") send({ id, result: {} });
|
||||
});
|
||||
`);
|
||||
const connection = await createAntigravityProvider().connect({
|
||||
launch,
|
||||
versions: [1],
|
||||
capabilities: ["session.configure"],
|
||||
});
|
||||
const events: ProviderEvent[] = [];
|
||||
connection.onEvent((event) => events.push(event));
|
||||
try {
|
||||
await connection.send({ type: "catalog", requestId: "catalog", cwd: directory });
|
||||
await expect
|
||||
.poll(() =>
|
||||
events.find((event) => event.type === "catalog" || event.type === "request.failed"),
|
||||
)
|
||||
.toMatchObject({ type: "catalog" });
|
||||
const catalog = events.find((event) => event.type === "catalog");
|
||||
if (catalog?.type !== "catalog") throw new Error("Expected a catalog");
|
||||
const thinkingByModel = Object.fromEntries(
|
||||
catalog.catalog.models.map((model) => [
|
||||
model.id,
|
||||
{
|
||||
options: model.thinkingOptions?.map((option) => option.id),
|
||||
default: model.defaultThinkingOptionId,
|
||||
},
|
||||
]),
|
||||
);
|
||||
expect(thinkingByModel).toEqual({
|
||||
"gemini-4-neon": { options: ["low", "medium", "high", "xhigh"], default: "high" },
|
||||
"gemini-4-carbon": { options: ["low", "medium", "high"], default: "high" },
|
||||
"gemini-pro-orchestrator-neon": { options: [], default: undefined },
|
||||
"claude-opus-5-5": { options: ["low", "medium", "high"], default: "medium" },
|
||||
});
|
||||
|
||||
await connection.send({
|
||||
type: "session.open",
|
||||
requestId: "open",
|
||||
sessionId: "orchestrator",
|
||||
history: "skip",
|
||||
config: {
|
||||
cwd: directory,
|
||||
model: "gemini-pro-orchestrator-neon",
|
||||
mode: "full-access",
|
||||
thinkingOption: thinkingByModel["gemini-pro-orchestrator-neon"]!.default,
|
||||
env: {},
|
||||
mcpServers: {},
|
||||
settings: {},
|
||||
persist: true,
|
||||
},
|
||||
});
|
||||
await expect
|
||||
.poll(
|
||||
() =>
|
||||
events.find(
|
||||
(event) =>
|
||||
(event.type === "session.ready" && event.sessionId === "orchestrator") ||
|
||||
(event.type === "request.failed" && event.requestId === "open"),
|
||||
),
|
||||
{ timeout: 3_000 },
|
||||
)
|
||||
.toMatchObject({ type: "session.ready" });
|
||||
} finally {
|
||||
await connection.close();
|
||||
}
|
||||
});
|
||||
|
||||
describe("installation", () => {
|
||||
const signal = new AbortController().signal;
|
||||
|
||||
|
||||
@@ -109,8 +109,6 @@ export function createAntigravityProvider(): ProviderRegistration {
|
||||
icon: "icon.svg",
|
||||
command: ["agy", "acp", "--disable-telemetry"],
|
||||
acpOptions: {
|
||||
// agy 1.5.14 lists thinking options for the selected model only, and none for Orchestrator.
|
||||
perModelThinkingOptions: true,
|
||||
waitForInitialCommands: true,
|
||||
loadReplayQuietPeriodMs: 200,
|
||||
// COMPAT(antigravityAcpV1DeferredTurn): added in v0.18.0, remove once Antigravity CLI supports ACP v2 state_update.
|
||||
|
||||
@@ -711,10 +711,6 @@ The adapter selects an unambiguous ACP `allow_once` action without opening a Pas
|
||||
Set `default: true` to make this the default for new sessions. The adapter requires an idle
|
||||
session without pending approvals before it switches to or from this mode.
|
||||
|
||||
Set `acpOptions.perModelThinkingOptions` for an agent that lists `thought_level` choices only for
|
||||
the selected model. Catalog discovery selects each model in turn and gives it the thinking options
|
||||
the agent lists for it. A model without a `thought_level` option gets no thinking picker.
|
||||
|
||||
## Test and publish
|
||||
|
||||
Test the provider against the real agent, not only mocked frames:
|
||||
|
||||
@@ -573,8 +573,6 @@ export const vendorEdits: AcpTransformer = {
|
||||
};
|
||||
```
|
||||
|
||||
如果 Agent 只为当前选中的模型列出 `thought_level` 选项,请设置 `acpOptions.perModelThinkingOptions`。目录发现会依次选中每个模型,并为它记录 Agent 列出的思考选项。没有 `thought_level` 选项的模型不会显示思考选择器。
|
||||
|
||||
## 测试与发布 {#test-and-publish}
|
||||
|
||||
用真实的 Agent 测试 Provider,而不只是模拟的数据帧:
|
||||
|
||||
Reference in New Issue
Block a user