upgrade goose sdk and tui to be compatible with the latest agentclientprotocol/sdk package (#8667)
This commit is contained in:
@@ -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