mirror of
https://github.com/aaif-goose/goose.git
synced 2026-07-03 14:10:03 +02:00
upgrade goose sdk and tui to be compatible with the latest agentclientprotocol/sdk package (#8667)
This commit is contained in:
@@ -313,7 +313,9 @@ export default function AppsView() {
|
||||
)}
|
||||
{app.mcpServers && app.mcpServers.length > 0 && (
|
||||
<span className="inline-block px-2 py-1 text-xs bg-background-secondary text-text-secondary rounded">
|
||||
{isCustomApp ? intl.formatMessage(i18n.customApp) : app.mcpServers.join(', ')}
|
||||
{isCustomApp
|
||||
? intl.formatMessage(i18n.customApp)
|
||||
: app.mcpServers.join(', ')}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -3,6 +3,7 @@ import type {
|
||||
NewSessionResponse,
|
||||
LoadSessionResponse,
|
||||
PromptResponse,
|
||||
SessionInfo,
|
||||
} from "@agentclientprotocol/sdk";
|
||||
import { getClient } from "./acpConnection";
|
||||
import { perfLog } from "@/shared/lib/perfLog";
|
||||
@@ -43,24 +44,13 @@ export async function listProviders(): Promise<AcpProvider[]> {
|
||||
|
||||
export async function listSessions(): Promise<AcpSessionInfo[]> {
|
||||
const client = await getClient();
|
||||
// GooseClient.unstable_listSessions doesn't work with SDK 0.19 (renamed to listSessions).
|
||||
// Bypass GooseClient and call the connection directly. Fix when ui/acp is updated.
|
||||
// biome-ignore lint/suspicious/noExplicitAny: SDK doesn't expose conn property
|
||||
const conn = (client as any).conn;
|
||||
const response = await conn.listSessions({});
|
||||
return response.sessions.map(
|
||||
(info: {
|
||||
sessionId: string;
|
||||
title?: string;
|
||||
updatedAt?: string;
|
||||
_meta?: Record<string, unknown>;
|
||||
}) => ({
|
||||
sessionId: info.sessionId,
|
||||
title: info.title ?? null,
|
||||
updatedAt: info.updatedAt ?? null,
|
||||
messageCount: (info._meta?.messageCount as number) ?? 0,
|
||||
}),
|
||||
);
|
||||
const response = await client.listSessions({});
|
||||
return response.sessions.map((info: SessionInfo) => ({
|
||||
sessionId: info.sessionId,
|
||||
title: info.title ?? null,
|
||||
updatedAt: info.updatedAt ?? null,
|
||||
messageCount: (info._meta?.messageCount as number) ?? 0,
|
||||
}));
|
||||
}
|
||||
|
||||
export async function exportSession(sessionId: string): Promise<string> {
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
export class GooseClient {
|
||||
closed = Promise.resolve();
|
||||
|
||||
async initialize(..._args: unknown[]): Promise<void> {}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ export default defineConfig({
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": resolve(__dirname, "./src"),
|
||||
"@aaif/goose-sdk": resolve(__dirname, "./src/test/mocks/goose-sdk.ts"),
|
||||
},
|
||||
},
|
||||
test: {
|
||||
|
||||
Generated
+5
-14
@@ -653,8 +653,8 @@ importers:
|
||||
version: 3.25.76
|
||||
devDependencies:
|
||||
'@agentclientprotocol/sdk':
|
||||
specifier: ^0.14.1
|
||||
version: 0.14.1(zod@3.25.76)
|
||||
specifier: ^0.19.0
|
||||
version: 0.19.0(zod@3.25.76)
|
||||
'@hey-api/openapi-ts':
|
||||
specifier: ^0.92.3
|
||||
version: 0.92.4(magicast@0.5.2)(typescript@5.9.3)
|
||||
@@ -693,8 +693,8 @@ importers:
|
||||
specifier: workspace:*
|
||||
version: link:../sdk
|
||||
'@agentclientprotocol/sdk':
|
||||
specifier: ^0.14.1
|
||||
version: 0.14.1(zod@4.3.6)
|
||||
specifier: ^0.19.0
|
||||
version: 0.19.0(zod@4.3.6)
|
||||
'@inkjs/ui':
|
||||
specifier: ^2.0.0
|
||||
version: 2.0.0(ink@6.8.0(@types/react@19.2.14)(react@19.2.4))
|
||||
@@ -744,11 +744,6 @@ packages:
|
||||
'@adobe/css-tools@4.4.4':
|
||||
resolution: {integrity: sha512-Elp+iwUx5rN5+Y8xLt5/GRoG20WGoDCQ/1Fb+1LiGtvwbDavuSk0jhD/eZdckHAuzcDzccnkv+rEjyWfRx18gg==}
|
||||
|
||||
'@agentclientprotocol/sdk@0.14.1':
|
||||
resolution: {integrity: sha512-b6r3PS3Nly+Wyw9U+0nOr47bV8tfS476EgyEMhoKvJCZLbgqoDFN7DJwkxL88RR0aiOqOYV1ZnESHqb+RmdH8w==}
|
||||
peerDependencies:
|
||||
zod: ^3.25.0 || ^4.0.0
|
||||
|
||||
'@agentclientprotocol/sdk@0.19.0':
|
||||
resolution: {integrity: sha512-U9I8ws9WTOk6jCBAWpXefGSDgVXn14/kV6HFzwWGcstQ02mOQgClMAROHmoIn9GqZbDBDEOkdIbP4P4TEMQdug==}
|
||||
peerDependencies:
|
||||
@@ -8859,14 +8854,10 @@ snapshots:
|
||||
|
||||
'@adobe/css-tools@4.4.4': {}
|
||||
|
||||
'@agentclientprotocol/sdk@0.14.1(zod@3.25.76)':
|
||||
'@agentclientprotocol/sdk@0.19.0(zod@3.25.76)':
|
||||
dependencies:
|
||||
zod: 3.25.76
|
||||
|
||||
'@agentclientprotocol/sdk@0.14.1(zod@4.3.6)':
|
||||
dependencies:
|
||||
zod: 4.3.6
|
||||
|
||||
'@agentclientprotocol/sdk@0.19.0(zod@4.3.6)':
|
||||
dependencies:
|
||||
zod: 4.3.6
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@aaif/goose-sdk",
|
||||
"version": "0.17.0",
|
||||
"version": "0.18.0",
|
||||
"description": "Agent Client Protocol (ACP) SDK for Goose AI agent",
|
||||
"license": "Apache-2.0",
|
||||
"repository": {
|
||||
@@ -43,7 +43,7 @@
|
||||
"zod": "^3.25.76"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@agentclientprotocol/sdk": "*"
|
||||
"@agentclientprotocol/sdk": "^0.19.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@aaif/goose-binary-darwin-arm64": "workspace:*",
|
||||
@@ -53,7 +53,7 @@
|
||||
"@aaif/goose-binary-win32-x64": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@agentclientprotocol/sdk": "^0.14.1",
|
||||
"@agentclientprotocol/sdk": "^0.19.0",
|
||||
"@hey-api/openapi-ts": "^0.92.3",
|
||||
"@types/node": "^20.0.0",
|
||||
"prettier": "^3.8.1",
|
||||
|
||||
@@ -92,10 +92,8 @@ export class GooseClient {
|
||||
return this.conn.unstable_forkSession(params);
|
||||
}
|
||||
|
||||
unstable_listSessions(
|
||||
params: ListSessionsRequest,
|
||||
): Promise<ListSessionsResponse> {
|
||||
return this.conn.unstable_listSessions(params);
|
||||
listSessions(params: ListSessionsRequest): Promise<ListSessionsResponse> {
|
||||
return this.conn.listSessions(params);
|
||||
}
|
||||
|
||||
unstable_resumeSession(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@aaif/goose",
|
||||
"version": "0.17.0",
|
||||
"version": "0.18.0",
|
||||
"description": "Goose - an open-source AI agent",
|
||||
"license": "Apache-2.0",
|
||||
"repository": {
|
||||
@@ -28,7 +28,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@aaif/goose-sdk": "workspace:*",
|
||||
"@agentclientprotocol/sdk": "^0.14.1",
|
||||
"@agentclientprotocol/sdk": "^0.19.0",
|
||||
"@inkjs/ui": "^2.0.0",
|
||||
"ink": "^6.8.0",
|
||||
"ink-multiline-input": "^0.1.0",
|
||||
|
||||
+19
-46
@@ -37,7 +37,6 @@ interface ConfigureProps {
|
||||
}
|
||||
|
||||
interface ModelSelectorProps {
|
||||
client: GooseClient;
|
||||
provider: ProviderInventoryEntryDto;
|
||||
height: number;
|
||||
onSelect: (model: string) => void;
|
||||
@@ -45,7 +44,6 @@ interface ModelSelectorProps {
|
||||
}
|
||||
|
||||
const ModelSelector = React.memo(function ModelSelector({
|
||||
client,
|
||||
provider,
|
||||
height,
|
||||
onSelect,
|
||||
@@ -53,7 +51,6 @@ const ModelSelector = React.memo(function ModelSelector({
|
||||
}: ModelSelectorProps) {
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [models, setModels] = useState<string[]>([]);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [selectedIdx, setSelectedIdx] = useState(0);
|
||||
const [searchQuery, setSearchQuery] = useState("");
|
||||
const [manualEntry, setManualEntry] = useState(false);
|
||||
@@ -61,42 +58,12 @@ const ModelSelector = React.memo(function ModelSelector({
|
||||
const columns = stdout?.columns ?? 80;
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
const timeoutId = setTimeout(() => {
|
||||
if (!cancelled) {
|
||||
setError("Request timed out. The provider may be slow to respond.");
|
||||
setLoading(false);
|
||||
}
|
||||
}, LOAD_MODELS_TIMEOUT_MS);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
const resp = await client.goose.GooseProvidersModels({
|
||||
providerName: provider.providerId,
|
||||
});
|
||||
if (!cancelled) {
|
||||
setModels(resp.models);
|
||||
const defaultIdx = resp.models.findIndex((m) => m === provider.defaultModel);
|
||||
setSelectedIdx(defaultIdx >= 0 ? defaultIdx : 0);
|
||||
setLoading(false);
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
} catch (e: unknown) {
|
||||
if (!cancelled) {
|
||||
setError(e instanceof Error ? e.message : String(e));
|
||||
setLoading(false);
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
return () => {
|
||||
cancelled = true;
|
||||
clearTimeout(timeoutId);
|
||||
};
|
||||
}, [client, provider.providerId, provider.defaultModel]);
|
||||
const availableModels = provider.models.map((model) => model.id);
|
||||
setModels(availableModels);
|
||||
const defaultIdx = availableModels.findIndex((model) => model === provider.defaultModel);
|
||||
setSelectedIdx(defaultIdx >= 0 ? defaultIdx : 0);
|
||||
setLoading(false);
|
||||
}, [provider.models, provider.defaultModel]);
|
||||
|
||||
const filtered = (() => {
|
||||
if (!searchQuery) return models;
|
||||
@@ -199,7 +166,7 @@ const ModelSelector = React.memo(function ModelSelector({
|
||||
);
|
||||
}
|
||||
|
||||
if (error) {
|
||||
if (models.length === 0) {
|
||||
return (
|
||||
<Box flexDirection="column" height={height} width={columns} paddingX={2}>
|
||||
<Box marginTop={1} />
|
||||
@@ -207,11 +174,13 @@ const ModelSelector = React.memo(function ModelSelector({
|
||||
<Text color={TEXT_PRIMARY} bold>◆ Select model ◆</Text>
|
||||
</Box>
|
||||
<Box justifyContent="center" marginBottom={2}>
|
||||
<Text color={GOLD}>⚠ Failed to load models</Text>
|
||||
<Text color={GOLD}>⚠ No models available</Text>
|
||||
</Box>
|
||||
<Box justifyContent="center">
|
||||
<Box width={maxWidth}>
|
||||
<Text color={TEXT_DIM} wrap="wrap">{error}</Text>
|
||||
<Text color={TEXT_DIM} wrap="wrap">
|
||||
This provider does not currently expose any models in inventory.
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
<Box justifyContent="center" marginTop={2}>
|
||||
@@ -439,10 +408,15 @@ export default function ConfigureScreen({
|
||||
value: provider.providerId,
|
||||
});
|
||||
await client.goose.GooseConfigUpsert({ key: "GOOSE_MODEL", value: model });
|
||||
await client.goose.GooseSessionProviderUpdate({
|
||||
await client.setSessionConfigOption({
|
||||
sessionId,
|
||||
provider: provider.providerId,
|
||||
model,
|
||||
configId: "provider",
|
||||
value: provider.providerId,
|
||||
});
|
||||
await client.setSessionConfigOption({
|
||||
sessionId,
|
||||
configId: "model",
|
||||
value: model,
|
||||
});
|
||||
onComplete();
|
||||
} catch (e: unknown) {
|
||||
@@ -544,7 +518,6 @@ export default function ConfigureScreen({
|
||||
if (phase === "select_model" && selectedProvider) {
|
||||
return (
|
||||
<ModelSelector
|
||||
client={client}
|
||||
provider={selectedProvider}
|
||||
height={height}
|
||||
onSelect={handleModelSelected}
|
||||
|
||||
+27
-3
@@ -11,8 +11,10 @@ import type {
|
||||
ContentChunk,
|
||||
ToolCall,
|
||||
ToolCallUpdate,
|
||||
RequestPermissionRequest,
|
||||
RequestPermissionResponse,
|
||||
} from "@agentclientprotocol/sdk";
|
||||
import { ndJsonStream } from "@agentclientprotocol/sdk";
|
||||
import { PROTOCOL_VERSION, ndJsonStream } from "@agentclientprotocol/sdk";
|
||||
import { GooseClient } from "@aaif/goose-sdk";
|
||||
import { resolveGooseBinary } from "@aaif/goose-sdk/node";
|
||||
import Onboarding from "./onboarding.js";
|
||||
@@ -741,6 +743,17 @@ function App({
|
||||
|
||||
const client = new GooseClient(
|
||||
() => ({
|
||||
requestPermission: async (
|
||||
params: RequestPermissionRequest,
|
||||
): Promise<RequestPermissionResponse> => {
|
||||
const optionId = params.options?.[0]?.optionId ?? "approve";
|
||||
return {
|
||||
outcome: {
|
||||
outcome: "selected",
|
||||
optionId,
|
||||
},
|
||||
};
|
||||
},
|
||||
sessionUpdate: async (params: SessionNotification) => {
|
||||
const update = params.update;
|
||||
if (update.sessionUpdate === "agent_message_chunk") {
|
||||
@@ -763,7 +776,7 @@ function App({
|
||||
|
||||
setStatus("handshaking…");
|
||||
await client.initialize({
|
||||
protocolVersion: 0,
|
||||
protocolVersion: PROTOCOL_VERSION,
|
||||
clientInfo: { name: "goose-text", version: "0.1.0" },
|
||||
clientCapabilities: {},
|
||||
});
|
||||
@@ -1218,6 +1231,17 @@ async function runTextMode(serverConnection: Stream | string, prompt: string) {
|
||||
try {
|
||||
const client = new GooseClient(
|
||||
() => ({
|
||||
requestPermission: async (
|
||||
params: RequestPermissionRequest,
|
||||
): Promise<RequestPermissionResponse> => {
|
||||
const optionId = params.options?.[0]?.optionId ?? "approve";
|
||||
return {
|
||||
outcome: {
|
||||
outcome: "selected",
|
||||
optionId,
|
||||
},
|
||||
};
|
||||
},
|
||||
sessionUpdate: async (params: SessionNotification) => {
|
||||
const update = params.update;
|
||||
if (update.sessionUpdate === "agent_message_chunk") {
|
||||
@@ -1231,7 +1255,7 @@ async function runTextMode(serverConnection: Stream | string, prompt: string) {
|
||||
);
|
||||
|
||||
await client.initialize({
|
||||
protocolVersion: 0,
|
||||
protocolVersion: PROTOCOL_VERSION,
|
||||
clientInfo: { name: "goose-text", version: "0.1.0" },
|
||||
clientCapabilities: {},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user