fix(bridge): align CLI send body with AgentUserMessageInputDto + add … - #1
Merged
Merged
Conversation
…ARK compat warn
Three issues surfaced from end-to-end bridge testing against a real
Volcengine Ark (Coding Plan / Doubao) deployment. Two of them are user-
facing configuration gotchas captured in reference/harness/ark-models.md;
the third is a real wire-contract bug in scripts/cli/bridge/commands/send.ts
that the 28 server-side tests did not catch because they hit the route
directly, never going through the CLI.
Fixes
1. scripts/cli/bridge/commands/send.ts
- The CLI historically sent `message: {content: [{type:"text",text}]}`
(Anthropic-style), but the DTO
`AgentUserMessageInputDtoSchema = z.object({text: z.string()}).strict()`
only accepts `{text: string}`. Server replies 400 with
"Invalid input: expected string, received undefined" because the
strict zod object has no `text` field. Server-side tests mock harness
directly so they never observe the wire body the CLI writes.
- Switch the body to `message: {text: input.message}` and add a comment
pinning the DTO contract as the single source of truth.
2. scripts/cli/bridge/commands/send.test.ts (new)
- Regression guard: capture the request body via stubbed `fetch` and
assert the shape (mode, message.text, clientMessageId UUID, no
caller/block/queueIfBusy leakage, followup mode, title passthrough,
non-2xx → BridgeHttpError with response body). Prevents future drift
between CLI and DTO.
3. server/agent/harness/model-resolver.ts + model-resolver.test.ts
- Add `warnArkDeveloperRoleCompatIfNeeded` heuristic and
`warnProviderCompatIssues` scan. Detects reasoning+openai-completions
models whose `baseURL` matches `ark.<region>.volces.com` and lack
`compat.supportsDeveloperRole: false` — emits `appLogger.warn` once
per (provider, model) per process. pi-ai 0.80.6 openai-completions
adapter defaults to `developer` role when `model.reasoning &&
compat.supportsDeveloperRole`; ARK rejects `developer` with 400
InvalidParameter. Warning fires best-effort, never blocks harness
startup; users can then patch compat and restart session.
Docs
- reference/harness/ark-models.md (new): config.json template, the
/v3/models lookup workflow for resolving `ark-code-latest`-style UI
aliases to actual model ids, region baseURL table, timeout/retry
recommendations, and a link back to the startup warn.
- reference/harness/invoke-http.md: cross-reference to ark-models.md.
- reference/README.md: add ark-models.md to the bookshelf and reading
order.
Test infra
- vitest.config.ts: include `scripts/cli/**/*.test.ts` so CLI tests
run in the standard `bunx vitest run` invocation (previously excluded).
Verification
- `bunx vitest run scripts/cli/bridge server/agent/bridge server/agent/harness/pi-runtime-resolver`
→ 53/53 tests pass (5 new send + 5 new model-resolver compat + 43 existing)
- `bunx tsc --noEmit -p tsconfig.json` → 7 pre-existing Prisma client
errors, 0 new errors from this change
Refs: end-to-end verification record in
~/.claude/projects/-www-wwwroot-book-neoshen-dpdns-org/memory/bridge-ark-e2e-verified.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…ARK compat warn
Three issues surfaced from end-to-end bridge testing against a real Volcengine Ark (Coding Plan / Doubao) deployment. Two of them are user- facing configuration gotchas captured in reference/harness/ark-models.md; the third is a real wire-contract bug in scripts/cli/bridge/commands/send.ts that the 28 server-side tests did not catch because they hit the route directly, never going through the CLI.
Fixes
scripts/cli/bridge/commands/send.ts
message: {content: [{type:"text",text}]}(Anthropic-style), but the DTOAgentUserMessageInputDtoSchema = z.object({text: z.string()}).strict()only accepts{text: string}. Server replies 400 with "Invalid input: expected string, received undefined" because the strict zod object has notextfield. Server-side tests mock harness directly so they never observe the wire body the CLI writes.message: {text: input.message}and add a comment pinning the DTO contract as the single source of truth.scripts/cli/bridge/commands/send.test.ts (new)
fetchand assert the shape (mode, message.text, clientMessageId UUID, no caller/block/queueIfBusy leakage, followup mode, title passthrough, non-2xx → BridgeHttpError with response body). Prevents future drift between CLI and DTO.server/agent/harness/model-resolver.ts + model-resolver.test.ts
warnArkDeveloperRoleCompatIfNeededheuristic andwarnProviderCompatIssuesscan. Detects reasoning+openai-completions models whosebaseURLmatchesark.<region>.volces.comand lackcompat.supportsDeveloperRole: false— emitsappLogger.warnonce per (provider, model) per process. pi-ai 0.80.6 openai-completions adapter defaults todeveloperrole whenmodel.reasoning && compat.supportsDeveloperRole; ARK rejectsdeveloperwith 400 InvalidParameter. Warning fires best-effort, never blocks harness startup; users can then patch compat and restart session.Docs
ark-code-latest-style UI aliases to actual model ids, region baseURL table, timeout/retry recommendations, and a link back to the startup warn.Test infra
scripts/cli/**/*.test.tsso CLI tests run in the standardbunx vitest runinvocation (previously excluded).Verification
bunx vitest run scripts/cli/bridge server/agent/bridge server/agent/harness/pi-runtime-resolver→ 53/53 tests pass (5 new send + 5 new model-resolver compat + 43 existing)bunx tsc --noEmit -p tsconfig.json→ 7 pre-existing Prisma client errors, 0 new errors from this changeRefs: end-to-end verification record in
~/.claude/projects/-www-wwwroot-book-neoshen-dpdns-org/memory/bridge-ark-e2e-verified.md
关联 Issue / Related issue
解决的问题 / Problem
本次范围 / Scope
包含 / In scope:
不包含 / Out of scope:
用户可见结果与实现 / User-visible result and implementation
验证 / Verification
实际执行的完整命令和结果 / Exact commands and results:
未运行的检查及原因 / Checks not run and why:
界面证据 / UI evidence
文档与记录 / Documentation and records
PROJECT-STATUS.md/ Reference, ADR, andPROJECT-STATUS.mdupdated or not neededRELEASE.md,除非维护者明确要求 / This PR does not change the version orRELEASE.mdunless requested by a maintainer风险与边界 / Risks and boundaries
提交者确认 / Contributor confirmation