Skip to content

Commit 8498480

Browse files
committed
feat(sdk)!: align Forward and Managed capability contracts
Add Forward session, A2A and OSS capabilities and Managed streaming, MCP and OAuth accessors. Prevent concurrent response closure during active download reads.
1 parent 156cf5b commit 8498480

44 files changed

Lines changed: 1820 additions & 43 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CHANGELOG.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,24 @@
22

33
## [Unreleased]
44

5+
### Added
6+
7+
- Add Forward Session creation `autoTitle`, Session update `config.multiagent`, Template A2A configuration and authenticated `retrieveAgentCard` discovery for A2A 0.3 and 1.0.
8+
- Add typed Forward OSS storage requests and masked response credentials. Credential omission on update preserves saved credentials; mounting requires the OSS Beta header and server-side authorization.
9+
- Add Managed Thread `eventDeltas` selectors that survive reconnects, OAuth refresh `resource`, expiry and redacted refresh accessors, and top-level MCP `Tool.permissionPolicy` for the default governing unlisted tools.
10+
11+
### Breaking changes
12+
13+
- Forward `SessionUpdateParams.config` now uses `SessionUpdateConfig`, separate from the creation `SessionConfig`. `MultiagentEntry` now implements `JsonSerializable` rather than extending `JsonObject`, so it can preserve string references as well as objects.
14+
15+
### Migration
16+
17+
- Use `SessionUpdateConfig.builder()` for Session update model/environment variables and multiagent settings. Continue using `SessionConfig.builder()` for creation; multiagent is update-only. Replace any `JsonObject` variable holding a `MultiagentEntry` with `MultiagentEntry` or `JsonSerializable`.
18+
519
### Fixed
620

21+
- Cancel active Skill and File downloads before releasing their response bodies, and defer body closure until in-flight reads exit. Closing a client during a blocked download read now raises the SDK abort error instead of an Okio `Unbalanced enter/exit` exception.
22+
- Preserve Forward multiagent string references when decoding a Template or Session override; typed roster access no longer rejects valid string entries.
723
- Send the required `scope: by_schedule_ids` in Forward `schedules().archiveMany(...)`. Earlier releases sent only `schedule_ids`, so every batch archive request was rejected with HTTP 400 `invalid_request`; existing calls work without code changes.
824

925
## [0.3.0]

‎docs/environments-files.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,25 @@ Environment update metadata is a **server-side merge**; this differs from Memory
4141

4242
Environment responses also expose archived time, Identity ownership, icon URL and typed Template binding counts. Archive is separate from deletion. Delete does not silently archive or unbind a referenced Environment. Both Environment and File delete methods return typed JSON deletion results; a legacy HTTP 204/205 returns null data and retains status/headers in `withResponse()`.
4343

44+
## OSS buckets (Beta)
45+
46+
```java
47+
EnvironmentStorageBucketParams bucket = EnvironmentStorageBucketParams.builder()
48+
.name("datasets").provider("aliyun-oss").region("cn-hangzhou")
49+
.bucket("your-bucket").access("read_only")
50+
.credential(EnvironmentStorageCredentialParams.builder().type("ram_role")
51+
.roleArn(System.getenv("QODER_OSS_ROLE_ARN")).build()).build();
52+
EnvironmentConfig config = EnvironmentConfig.builder().type("cloud")
53+
.storage(EnvironmentStorageParams.builder().buckets(Collections.singletonList(bucket)).build())
54+
.build();
55+
client.environments().create(EnvironmentCreateParams.builder().name("OSS data").config(config).build(),
56+
RequestOptions.builder().header("X-Qoder-Beta", "oss-bucket-2026-09-23").build());
57+
```
58+
59+
Forward supports at most seven cloud bucket mounts at `/mnt/buckets/<name>`. RAM roles use `roleArn`; access-key requests use `accessKeyId` and `accessKeySecret` from a protected configuration source. Do not log raw request JSON. The service verifies Beta eligibility, bucket authorization and read/write permissions; the SDK does not execute permission changes.
60+
61+
Response `config().storage().buckets()` uses separate `EnvironmentStorageBucket` and `EnvironmentStorageCredential` models. Credentials expose only their type and optional masked key ID, never role ARN or secret getters. During update, omitting a bucket credential preserves its saved credential by name. The entire config replaces the previous config; keep required package/script fields when updating. Removing a bucket or sending an empty bucket list affects new Sessions, not existing mounts. See the [public schema](https://docs.qoder.com/cloud-agents/api/forward/environments/schemas.md).
62+
4463
## Identity ownership and pagination
4564

4665
For PAT access to an Identity-owned resource, use:

‎docs/forward-api-coverage.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ HTTP BaseURL 为 CN `https://api.qoder.com.cn/api/v1/forward` 或 Global `https:
1414

1515
0.2.0 已按 Go `a996a88`、Python `2f8c625`、TypeScript `f4e3a4f` 的 main 补齐 ImageSource `file_id`、创建 Memory Store 时的 mount `access`、Schedule/Run `initial_events_version` 和 ChannelPairing 时间戳。这些字段不新增协议操作;客户端 HTTP 扩展、通用 JSON 请求和配置复制见[客户端配置](client-configuration.md)。
1616

17+
开发中能力补齐(2026-11-21):新增 `GET /templates/{template_id}/a2a/agent-card.json`,方法 `templates().retrieveAgentCard(...)`,同步/异步及 withResponse 均支持;其余变更补齐 Session 更新多智能体、创建自动标题、A2A 配置和 OSS 模型,不新增这些资源的 HTTP 路由。新增测试见 `CapabilityParityTest`;真实环境未在本轮执行。
18+
1719
## 使用指南
1820

1921
- [客户端认证、超时、重试与取消](client-configuration.md)

‎docs/managed-api-coverage.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
Base URL:CN `https://api.qoder.com.cn/api/v1/cloud`,Global `https://api.qoder.com/api/v1/cloud`。使用方法见 [Managed 指南](managed.md);验收范围见 [真实环境测试](managed-live-testing.md)。接口存在与离线通过不等于线上权限或执行结果已验证。
88

9+
开发中能力补齐(2026-11-21):Managed Thread 支持 `event_deltas[]`,允许 `agent.message` / `agent.thinking`;更新模型 `VaultCredentialOAuthRefresh.resource` 和凭据响应的到期时间、脱敏刷新信息。`VaultCredentialOAuthRefreshInfo` / `VaultCredentialTokenEndpointAuthInfo` 不提供刷新令牌或客户端密钥访问器。新增测试见 `CapabilityParityTest`,未新增 Managed HTTP 路由、未执行真实环境测试。
10+
911
OAuth 的浏览器重定向快捷入口 `/oauth/authorize` 不是 SDK JSON 方法;SDK 使用 `/oauth/start` 返回授权 URL。Forward 专用 Webhook、Identity、Channel 等不属于 Managed API。已弃用的 `PUT /skills/{skill_id}` 不提供 SDK 方法;更新 Skill 内容请使用 `skills().versions().create(...)`,该方法不替代 Skill metadata 更新。
1012

1113
| # | Java 资源方法 | HTTP | 相对路径 | 官方文档 |

‎docs/managed.md‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ Budget values are positive decimal strings with up to 12 integer and two fractio
5858

5959
Session environment variables use `Map<String,String>`. Deployment environment variables use a string of `KEY=VALUE` lines. Session metadata updates are merge patches; null values remove keys, while top-level null is a service no-op. Deployment metadata has its own merge-patch rules. The SDK preserves the submitted representation.
6060

61+
## MCP default policies
62+
63+
```java
64+
Tool mcp = Tool.builder().type("mcp_toolset").mcpServerName("server")
65+
.permissionPolicy(PermissionPolicy.builder().type("always_deny").build()).build();
66+
```
67+
68+
MCP tools not listed in `configs` use the toolset's top-level `permission_policy`. The `default_config.permission_policy` metadata does not control this MCP default. Set per-tool overrides with `ToolConfig.permissionPolicy(...)`; use `tool.permissionPolicy()` to read the top-level policy. Built-in tools use their separate default-config and per-tool policies. Policy declarations are sent to the service, not enforced by the SDK.
69+
6170
## Events, resources and pagination
6271

6372
`SessionEventParam` and `EventContent.text(...)` build user events as content-block arrays. List events with `SessionEventListParams.types(...)`, which sends the Managed `types` query key; Session lifecycle filters use `statuses`. Date comparisons use `createdAtGt/Gte/Lt/Lte` where supported.
@@ -76,7 +85,7 @@ try (com.qoder.cloudagents.streaming.EventStream<SessionEvent> stream =
7685
}
7786
```
7887

79-
Session streams accept repeated `event_deltas[]` selectors; thread streams accept no query selectors and use `/sessions/{session}/threads/{thread}/stream`. Both put the resume cursor in `Last-Event-ID`. Per-call headers override parameter/default cursors. `resumableStream(...)` is explicit and never resends user messages. Closing a stream cancels the subscription, not the Session.
88+
Session streams accept repeated `event_deltas[]` selectors; Thread streams accept the same query key for `agent.message` and `agent.thinking` previews and use `/sessions/{session}/threads/{thread}/stream`. Use `SessionThreadEventStreamParams.builder().eventDeltas(...)`; Thread thinking remains event-start-only, and Session-only filters are rejected. Both put the resume cursor in `Last-Event-ID`. Per-call headers override parameter/default cursors. `resumableStream(...)` is explicit and never resends user messages. Closing a stream cancels the subscription, not the Session.
8089

8190
Create-time resources support File, GitHub, generic Git and Memory Store attachments. `SessionResourceSpec` includes checkout, credentials, mount path and memory access as applicable. Existing Sessions can add File resources through `sessions().resources().create(...)`; resource updates rotate repository credentials. Credentials are request fields; responses do not expose them.
8291

‎docs/session-streaming.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ try (EventStream<SessionEvent> stream = client.sessions().threads().events()
6767
}
6868
```
6969

70-
Thread SSE uses `/sessions/{session_id}/threads/{thread_id}/stream`, not the Thread history `/events` path. It does not accept Session query filters; the Java entry point rejects query overrides. The caller must use a cursor valid for this Thread. A terminated/archived Thread that cannot reopen is surfaced as the service's HTTP error; no automatic re-creation occurs.
70+
Thread SSE uses `/sessions/{session_id}/threads/{thread_id}/stream`, not the Thread history `/events` path. Managed `SessionThreadEventStreamParams.eventDeltas(Arrays.asList("agent.message", "agent.thinking"))` enables previews through repeated `event_deltas[]` query entries; thinking is event-start-only on this surface. The copied selector list survives reconnects, while the header-only `Last-Event-ID` advances independently. Managed Thread query overrides accept only `event_deltas[]`, not Session filters; Forward Thread query selectors remain unsupported. The caller must use a cursor valid for this Thread. A terminated/archived Thread that cannot reopen is surfaced as the service's HTTP error; no automatic re-creation occurs.
7171

7272
## Asynchronous callbacks and cancellation
7373

‎docs/sessions.md‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,32 @@ Session session = client.sessions().create(
4242

4343
Creation requires an Identity and Template accessible to the credential. The service compiles the Template and Identity configuration and applies the Session's environment variables. The SDK does not supply source type, resolve ownership or merge configuration locally.
4444

45-
Session update allows title, metadata and `config.environment_variables`. The environment-variable map **replaces the whole Session-level map**, then overlays the Template/Identity base. An empty map clears the Session override; an omitted field leaves it unchanged. The service rejects null config/environment-variable maps. Builders preserve explicit null for wire fidelity; they do not silently turn it into omission or an empty map.
45+
Session update allows title, metadata, budget and `config.model`, `config.environment_variables` and `config.multiagent`. The environment-variable map **replaces the whole Session-level map**, then overlays the Template/Identity base. An empty map clears the Session override; an omitted field leaves it unchanged. The service rejects null config/environment-variable maps. Builders preserve explicit null for wire fidelity; they do not silently turn it into omission or an empty map.
4646

4747
```java
4848
client.sessions().update(session.id(), SessionUpdateParams.builder()
49-
.config(SessionConfig.builder().environmentVariables(Collections.emptyMap()).build())
49+
.config(SessionUpdateConfig.builder().environmentVariables(Collections.emptyMap()).build())
5050
.build());
5151
```
5252

5353
Metadata follows the endpoint's merge behavior. File resources can be supplied on creation with `SessionResourceSpec`; later additions use `sessions().resources().add(...)`, not Session update.
5454

55+
## Automatic titles and multiagent updates
56+
57+
```java
58+
Session automaticallyNamed = client.sessions().create(SessionCreateParams.builder()
59+
.identityId("idn_example").templateId("tmpl_example").autoTitle(true).build());
60+
MultiagentConfig roster = MultiagentConfig.builder().type("coordinator")
61+
.agents(java.util.Arrays.asList(MultiagentEntry.of("tmpl_child"),
62+
MultiagentEntry.builder().type("advisor").model("ultimate").build())).build();
63+
client.sessions().update(automaticallyNamed.id(), SessionUpdateParams.builder()
64+
.config(SessionUpdateConfig.builder().multiagent(roster).build()).build());
65+
```
66+
67+
`autoTitle(true)` is creation-only and cannot be combined with any supplied `title`, including empty or null. The initial title is empty; the first user message starts automatic naming. The response exposes `title`, not an auto-title flag. Manual title updates take over naming.
68+
69+
Initial multiagent configuration is inherited; creation does not accept `config.multiagent`. Updates use `SessionUpdateConfig`, not the creation `SessionConfig`. A supplied roster replaces the entire override; omission preserves it, `multiagent(null)` persistently disables it rather than restoring inheritance, and empty rosters are rejected by the service. The response's `config().multiagent()` contains the authored override. Re-submitting a roster refreshes the pinned child versions; the SDK does not select historical child versions or resolve them locally. Strings, Agent objects (`templateId` or `id`), Self and one Advisor are supported; strings remain strings through `MultiagentEntry.of(...)` and `isString()`.
70+
5571
## Send and read events
5672

5773
```java
@@ -161,7 +177,7 @@ SessionCreateParams create = SessionCreateParams.builder()
161177
.id("ultimate").speed("high").build()).build())
162178
.build();
163179
SessionUpdateParams clear = SessionUpdateParams.builder().budget(null)
164-
.config(SessionConfig.builder().model(null).build()).build();
180+
.config(SessionUpdateConfig.builder().model(null).build()).build();
165181
```
166182

167183
Omitting `budget` keeps the current limit on update; `null` clears it and an object replaces it. It limits cumulative model and sandbox Credits; an active turn can finish, but the server rejects the next user message once the budget is exhausted. A Session model override accepts a model ID string (`ModelConfig.of`) or an object. Omit it on create to inherit; `null` is only valid on update to restore inheritance. Query model capabilities before selecting speed or context windows.

‎docs/templates.md‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Template API
22

3-
Implemented: list, retrieve, create, update, archive and clone. These six operations share the same request engine and credential handling in synchronous and asynchronous clients.
3+
Implemented: list, retrieve, create, update, archive, clone and authenticated Agent Card retrieval. These seven operations share the same request engine and credential handling in synchronous and asynchronous clients.
44

55
## Methods
66

@@ -53,7 +53,8 @@ Use values supported by the selected environment and model; the SDK does not inf
5353
| `managed_tool_config` | `ManagedToolConfig` |
5454
| `mcp_servers` | `List<MCPServer>` |
5555
| `skills` | `List<SkillBinding>` |
56-
| `multiagent` | `MultiagentConfig`, `MultiagentEntry` (including Advisor model) |
56+
| `multiagent` | `MultiagentConfig`, `MultiagentEntry` (string reference, Agent, Self or Advisor) |
57+
| `a2a` | `TemplateA2AConfig`, `TemplateA2ASkill` (Agent Card capabilities, not resource Skill bindings) |
5758
| `vaults`, `files` | `Map<String, ResourceBinding>` |
5859
| `github_repositories` | Request: `GitHubRepositoryConfig`; response: `GitHubRepository` |
5960
| `environment_variables` | `EnvironmentVariables`: object or string |
@@ -134,6 +135,22 @@ if (page.hasNextPage()) {
134135

135136
Forward pagination uses `last_id` as the next `after_id`; a request using `before_id` continues with `first_id`. These two request cursors are mutually exclusive, including request-option overrides. A false `has_more`, empty data or absent cursor ends iteration. Calling next on an exhausted page raises `PaginationException`, as does a repeated cursor that would cause a loop. Async consumers use explicit page futures; no whole-result buffering or async stream API is provided.
136137

138+
## A2A publication and discovery
139+
140+
```java
141+
TemplateA2AConfig a2a = TemplateA2AConfig.builder().enabled(true)
142+
.skills(Collections.singletonList(TemplateA2ASkill.builder()
143+
.id("summary").name("Summarize").description("Summarize supplied text")
144+
.build())).build();
145+
client.templates().update("tmpl_example", TemplateUpdateParams.builder().a2a(a2a).build());
146+
TemplateAgentCard card = client.templates().retrieveAgentCard("tmpl_example",
147+
TemplateAgentCardParams.builder().identityId("idn_example").a2aVersion("1.0").build());
148+
```
149+
150+
A2A is separate from multiagent orchestration. Updating A2A patches supplied object fields; omitted fields and `{}` preserve configuration, `skills: []` clears capabilities, and `a2a: null` clears and disables publication. Members do not accept null. These skills describe Card capabilities, not mounted Qoder Skills.
151+
152+
PAT callers select runtime `identityId`; identity-bound SAT callers omit it. Card retrieval uses the same authentication and request options as other APIs and sends `A2A-Version` as a header. Version 0.3 exposes `card.url()`, while 1.0 exposes `card.supportedInterfaces()`. Read the invocation URL from the Card and pass it to a compatible A2A client; this SDK does not follow that URL or replay A2A tasks. See the [official integration guide](https://docs.qoder.com/cloud-agents/a2a-integration.md).
153+
137154
## Contract sources and validation boundary
138155

139156
Routes and baseline fields follow the pinned Go/Python/TypeScript SDK commits in [coverage](forward-api-coverage.md). Template parameters also expose `speed`, `max_tool_rounds` and Advisor configuration. Java exposes these fields without imposing new defaults.

0 commit comments

Comments
 (0)