AS AgentScopeAPI 手册 / API Reference

ContractHttpServer

public final class ContractHttpServer implements AutoCloseable
源码Source io/agentscope/extensions/aistio/transport/ContractHttpServer.java:57–358

契约 HTTP 服务端,承载智能体的部署、调度与服务化运行。位于 io.agentscope.extensions.aistio.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

构造器Constructor说明Description
public ContractHttpServer(String host, int port, ContractProvider provider) throws IOException
初始化 `ContractHttpServer` 实例。
Creates a new instance.
public ContractHttpServer(String host, int port, ContractProvider provider, String internalToken) throws IOException
初始化 `ContractHttpServer` 实例。
Creates a new instance.

方法摘要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
hostStringhost(类型 `String`)。The host.
portintport(类型 `int`)。The port.
providerContractProvider提供者(类型 `ContractProvider`)。The provider.
抛出Throws
  • IOException 可能抛出 `IOException`。Thrown when the operation cannot be completed.
源码Source io/agentscope/extensions/aistio/transport/ContractHttpServer.java:67–69

ContractHttpServer

public ContractHttpServer(String host, int port, ContractProvider provider, String internalToken) throws IOException

初始化 ContractHttpServer 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
hostStringhost(类型 `String`)。The host.
portintport(类型 `int`)。The port.
providerContractProvider提供者(类型 `ContractProvider`)。The provider.
internalTokenString内部令牌(类型 `String`)。The internal token.
抛出Throws
  • IOException 可能抛出 `IOException`。Thrown when the operation cannot be completed.
源码Source io/agentscope/extensions/aistio/transport/ContractHttpServer.java:71–89

方法详情Method Detail

getPort

public int getPort()

获取 getPort。

Actual bound port, which matters when the configured port was 0.

返回Returns int
返回数值结果。Returns a numeric result.
源码Source io/agentscope/extensions/aistio/transport/ContractHttpServer.java:92–94

start

public void start()

执行启动相关操作。

Returns the start.

源码Source io/agentscope/extensions/aistio/transport/ContractHttpServer.java:96–98

close

public void close()

关闭连接并释放相关资源。

Releases resources and connections.

源码Source io/agentscope/extensions/aistio/transport/ContractHttpServer.java:100–103
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.