ContractHttpServer
public final class ContractHttpServer implements AutoCloseable
源码Source
io/agentscope/extensions/controlplane/transport/ContractHttpServer.java:57–358契约 HTTP 服务端,承载智能体的部署、调度与服务化运行。位于 io.agentscope.extensions.controlplane.transport 包,实现 AutoCloseable。核心成员包括 getPort、start、close、ContractHttpServer。
In-process HTTP server for the /agentscope/* contract, letting the control plane pull
on demand and issue session commands.
Routes mirror the Go connector.ContractServer and the Python SDK one for one:
GET /agentscope/info
GET /agentscope/health
GET /agentscope/sessions
GET /agentscope/sessions/{id}/state
GET /agentscope/sessions/{id}/context
GET /agentscope/sessions/{id}/messages?offset=&limit=
GET /agentscope/sessions/{id}/tasks
GET /agentscope/subagents
GET /agentscope/workspaces
POST /agentscope/sessions/{id}/compress
POST /agentscope/sessions/{id}/terminate
POST /agentscope/sessions/{id}/abort
Built on the JDK's com.sun.net.httpserver so that instrumenting an agent never drags
in a web framework or collides with the application's own server.
构造器摘要Constructor Summary
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public int getPort() | 获取 `getPort`。 Actual bound port, which matters when the configured port was 0. |
public void start() | 执行启动相关操作。 Returns the start. |
public void close() | 关闭连接并释放相关资源。 Releases resources and connections. |
构造器详情Constructor Detail
ContractHttpServer
public ContractHttpServer(String host, int port, ContractProvider provider) throws IOException
初始化 ContractHttpServer 实例。
Creates a new instance.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
host | String | host(类型 `String`)。The host. |
port | int | port(类型 `int`)。The port. |
provider | ContractProvider | 提供者(类型 `ContractProvider`)。The provider. |
IOException可能抛出 `IOException`。Thrown when the operation cannot be completed.
源码Source
io/agentscope/extensions/controlplane/transport/ContractHttpServer.java:67–69ContractHttpServer
public ContractHttpServer(String host, int port, ContractProvider provider, String internalToken) throws IOException
初始化 ContractHttpServer 实例。
Creates a new instance.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
host | String | host(类型 `String`)。The host. |
port | int | port(类型 `int`)。The port. |
provider | ContractProvider | 提供者(类型 `ContractProvider`)。The provider. |
internalToken | String | 内部令牌(类型 `String`)。The internal token. |
IOException可能抛出 `IOException`。Thrown when the operation cannot be completed.
源码Source
io/agentscope/extensions/controlplane/transport/ContractHttpServer.java:71–89方法详情Method Detail
getPort
public int getPort()
获取 getPort。
Actual bound port, which matters when the configured port was 0.
int返回数值结果。Returns a numeric result.
源码Source
io/agentscope/extensions/controlplane/transport/ContractHttpServer.java:92–94start
public void start()
执行启动相关操作。
Returns the start.
源码Source
io/agentscope/extensions/controlplane/transport/ContractHttpServer.java:96–98close
public void close()
关闭连接并释放相关资源。
Releases resources and connections.
源码Source
io/agentscope/extensions/controlplane/transport/ContractHttpServer.java:100–103