github / github/copilot-sdk

Provide an opt-in managed-runtime launcher hook for host-controlled process ownership

オープン
#2,582 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
enhancement
主要言語
Java
スター
10.5k
フォーク
1.5k
平均マージ
1日 11時間
マージ済み PR(30日)
128

説明

## Summary

The SDK's managed runtime connections are excellent for most applications: the SDK starts a compatible Copilot runtime, connects to it, and cleans it up automatically.

Some embedding hosts need to retain ownership of the runtime process from the instant it is created. Examples include desktop applications, long-lived services, worker hosts, managed execution environments, and applications with OS-level process containment or resource-governance requirements.

Could the SDK expose an opt-in launcher/lifecycle hook for managed runtime connections?

## Problem

Today an application can choose between two models:

1. Let the SDK launch and own the runtime process.
2. Launch a headless runtime independently and attach through a network connection.

The first model does not give the host a supported way to apply process containment, resource governance, or host-specific lifecycle handling at process creation.

The second model can add deployment and connection-management complexity. A host may also need a stronger way to establish that the runtime it connects to is the exact process it launched, rather than merely a process listening on a local endpoint.

There is no need to change the default SDK behavior. This is an advanced embedding requirement for hosts that already have mature process supervision.

## Proposed capability

Expose an optional factory or lifecycle interface used only when the SDK would otherwise launch a local runtime.

Illustrative Python shape:

```python
from copilot import CopilotClient, RuntimeConnection

def launch_runtime(command, options):
# Host launches the supplied command using its own process supervisor.
# Returns a process/lifecycle handle understood by the SDK.
...

client = CopilotClient(
connection=RuntimeConnection.for_stdio(
runtime_launcher=launch_runtime,
),
)
```

Or, if a lifecycle object is preferable:

```python
class RuntimeProcess:
def wait_ready(self, timeout: float) -> None: ...
def terminate(self, grace_period: float) -> None: ...
def wait(self, timeout: float | None = None) -> int | None: ...
@property
def stdin(self): ...
@property
def stdout(self): ...
@property
def stderr(self): ...

client = CopilotClient(
connection=RuntimeConnection.for_stdio(
runtime_factory=create_runtime_process,
),
)
```

The exact API shape is less important than these properties:

- The host receives the final runtime command and launch options **before** the runtime starts.
- The SDK retains ownership of protocol negotiation, session management, and normal client cleanup.
- The host can apply OS-native containment and observability at process birth.
- Process termination responsibilities are explicit and cannot result in double ownership.
- The default managed-runtime behavior remains unchanged.
- The abstraction works with local stdio first; it should not require an application to expose a TCP listener merely to control child-process ownership.

## Why stdio matters

A host-controlled stdio launcher avoids introducing a network endpoint solely for local embedding. It also keeps the runtime connection bound directly to the process the host created, which simplifies lifecycle, containment, and cleanup reasoning.

## Non-goals

- Changing default SDK startup behavior.
- Requiring applications to implement their own JSON-RPC transport.
- Replacing the SDK's runtime provisioning or compatibility management.
- Adding remote-runtime deployment features.
- Exposing private SDK process internals after startup.

## Questions for maintainers

1. Is there an existing supported extension point for host-owned runtime creation that I may have missed?
2. Would a launcher callback or a small lifecycle protocol be more consistent with the SDK's cross-language design?
3. Should this apply only to stdio transport, or also to SDK-managed TCP and in-process transports?
4. What lifecycle boundary would maintainers want the host to own versus the SDK to own?

I can provide a small implementation proposal once there is agreement on the intended API and cross-language scope.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

The proposed entry points are CopilotClient and RuntimeConnection.for_stdio; begin by tracing the existing managed-runtime launch and cleanup path, which the issue does not locate in files. Done means an agreed opt-in stdio launcher or lifecycle API with explicit ownership semantics, unchanged default behavior, and a defined cross-language scope.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java, python
領域
api, backend
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
活発
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。