This commit is contained in:
Shawn Morreau
2025-11-20 14:04:50 -05:00
10 changed files with 40 additions and 30 deletions
-1
View File
@@ -6,7 +6,6 @@ import { agent, installFromNpmTarball } from "./shared.ts";
export const claude = agent({
name: "claude",
inputKeys: ["anthropic_api_key"],
install: async () => {
const versionRange = packageJson.dependencies["@anthropic-ai/claude-agent-sdk"] || "latest";
return await installFromNpmTarball({
-1
View File
@@ -6,7 +6,6 @@ import { agent, type ConfigureMcpServersParams, installFromNpmTarball } from "./
export const codex = agent({
name: "codex",
inputKeys: ["openai_api_key"],
install: async () => {
return await installFromNpmTarball({
packageName: "@openai/codex",
-1
View File
@@ -7,7 +7,6 @@ import { agent, type ConfigureMcpServersParams, installFromCurl } from "./shared
export const cursor = agent({
name: "cursor",
inputKeys: ["cursor_api_key"],
install: async () => {
return await installFromCurl({
installUrl: "https://cursor.com/install",
-1
View File
@@ -6,7 +6,6 @@ import { agent, type ConfigureMcpServersParams, installFromGithub } from "./shar
export const gemini = agent({
name: "gemini",
inputKeys: ["google_api_key", "gemini_api_key"],
install: async () => {
return await installFromGithub({
owner: "google-gemini",
-2
View File
@@ -11,5 +11,3 @@ export const agents = {
cursor,
gemini,
} satisfies Record<AgentName, Agent>;
export type AgentInputKey = (typeof agents)[keyof typeof agents]["inputKeys"][number];
+13 -7
View File
@@ -5,7 +5,8 @@ import { tmpdir } from "node:os";
import { join } from "node:path";
import { pipeline } from "node:stream/promises";
import type { McpStdioServerConfig } from "@anthropic-ai/claude-agent-sdk";
import type { Payload } from "../external.ts";
import type { show } from "@ark/util";
import { type AgentManifest, type AgentName, agentsManifest, type Payload } from "../external.ts";
import { log } from "../utils/cli.ts";
/**
@@ -330,13 +331,18 @@ export async function installFromCurl({
return cliPath;
}
export const agent = <const agent extends Agent>(agent: agent): agent => {
return agent;
export const agent = <const input extends AgentInput>(input: input): defineAgent<input> => {
return { ...input, ...agentsManifest[input.name] } as never;
};
export type Agent = {
name: string;
inputKeys: string[];
export interface AgentInput {
name: AgentName;
install: () => Promise<string>;
run: (config: AgentConfig) => Promise<AgentResult>;
};
}
export interface Agent extends AgentInput, AgentManifest {}
type agentManifest<name extends AgentName> = (typeof agentsManifest)[name];
type defineAgent<input extends AgentInput> = show<input & agentManifest<input["name"]>>;