編集

GitHub Copilot SDKがテクニカルプレビューとして公開

GitHub Copilot CLIにプログラムからアクセスするためのSDK「Copilot SDK」がテクニカルプレビューとして公開された。

Node.js/TypeScript (@github/copilot-cli-sdk)、Python (copilot)、Go、.NETの4つの言語向けに提供される。

主な特徴:

  • マルチターン会話: セッション履歴を維持したコンテキスト認識型の対話が可能。
  • ツール実行: モデルが会話中に呼び出せるカスタムツールを定義可能。
  • ライフサイクル管理: クライアントとセッションのライフサイクルをプログラムで制御可能。

開発者はこれらのSDKを使用して、Copilotの機能を独自のアプリケーションやワークフローに統合できる。

js
import { CopilotClient } from "@github/copilot-sdk";

// Create and start client
const client = new CopilotClient();
await client.start();

// Create a session
const session = await client.createSession({
    model: "gpt-5",
});

// Wait for response using session.idle event
const done = new Promise<void>((resolve) => {
    session.on((event) => {
        if (event.type === "assistant.message") {
            console.log(event.data.content);
        } else if (event.type === "session.idle") {
            resolve();
        }
    });
});

// Send a message and wait for completion
await session.send({ prompt: "What is 2+2?" });
await done;

// Clean up
await session.destroy();
await client.stop();

出展:Copilot SDK in technical preview - GitHub Changelog, Copilot SDK for Node.js/TypeScript

編集