Skip to content

合入 DevBox SDK、CLI 与文档更新 - #7

Open
lizhicheng00 wants to merge 102 commits into
mainfrom
dev
Open

lizhicheng00 wants to merge 102 commits into
mainfrom
dev

Conversation

@lizhicheng00

Copy link
Copy Markdown
Collaborator

变更内容

  • 合入 Python / JavaScript SDK:模板与列表、沙箱生命周期、EnvD 操作、Connect Token 更新及 E2B 兼容参数。
  • 合入 CLI:沙箱操作、安装发布流程、版本提示和入站访问策略参数。
  • 更新用户文档、API 参考和验证示例。

验证说明

  • SDK public traffic 与 full snapshot 适配提交已通过本地 Python / JS 回归。
  • 私有应用端口的匿名访问拦截依赖 Gateway 通配端口策略,端到端待复测;不以本 PR 作为 Gateway 修复。
  • 请以本 PR 的 CI 结果为合入依据。本申请不包含 Manager / Gateway 部署变更。

17673651504 and others added 19 commits November 3, 2026 19:48
严重:
- S1/S2: client 各方法判空 JSON200/JSON201,空响应体返回错误而非 panic/nil
- S3: exec 退出码经 ExitCodeError 传递,main 统一退出,不再 os.Exit 跳过 defer
- S4: 登录回调 fail-closed 校验 Origin 头,伪造 origin/缺失 origin 一律 403
- S5: sandbox list -f json 复用 SandboxJSON 脱敏,不再泄漏 connectToken

中等:
- M1: config 原子写(临时文件+rename);M2: 沙箱域名端口按最后一个 - 解析
- M3: loggingTransport 防重复包装;M4: 超 1MiB 的 body 不再全量缓冲进日志
- M9: kill 部分失败退出码非 0(对齐 e2b);M11: stdin 转发错误输出 stderr

轻微:
- L1/L2: 登录超时与回调响应体接入 i18n
- L3: 新建 internal/mask 统一 maskAPIKey 双实现
- L4-L10/L13/L16-L24: SandboxJSON 测试守护、死代码清理、JoinList、
  printTable 行列校验、空 Data 帧不误标输出、overrideAPIKey 原子化、
  api.Pause 常量、list 校验前置、defer Close 前置等

其他:
- 撤销 create/connect/exec 的 -u/--user 支持
- 清理代码中的 devbridge 引用(保留门户登录路由字符串)
- 新增 helpers/mask/auth 回调单测
- sandbox create 新增 --network.allow-public-traffic(显式传入才随请求提交,格式与 SDK 对齐)
- 精简 newClient(移除从未生效的 timeout 逻辑);errors.As 改用 errors.AsType
- 删除无调用的 Client.BaseURL;ExecForeground 补 stream.Close
- 移除类型别名冗余转换 x5;打印错误统一显式丢弃 x9
- 提取 MissingDomainError 消除重复;注释开头对齐标识符;统一美式拼写
lizhicheng00 and others added 4 commits November 11, 2026 17:04
- install.sh/install.ps1 默认 DEFAULT_ARTIFACT_URL 改为 OBS,保留 __*__ 占位符运行时回退
- bake-install.sh 新增第 3 参数 obs_release_url,产出 dist-extra/obs/ 烤制脚本
- goreleaser prod/test 的 bake hook 传入 OBS 地址,Release 附带 OBS 烤制脚本
- .gitignore 补 dist/、dist-extra/ 构建产物
// Package api provides primitives to interact with the openapi HTTP API.
//
// Typed client for the DevBox Manager API (originally generated from openapi.yaml by oapi-codegen, now hand-maintained).
package api

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api路径下只能有:api定义的代码和以及根据api定义生成的代码


package process;

option go_package = "github.com/huaweicloud/devspace-devbox/cli/internal/api/processgen/process";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

简化嵌套的路径,参考

image

Comment thread cli/internal/auth/auth_test.go Outdated

// newVerifyServer mocks the API key check endpoint on the bridge domain.
// Only requests carrying validKey succeed with 204; everything else gets 401.
func newVerifyServer(t *testing.T, validKey string) *httptest.Server {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

单元测试的文件名最好能和业务的文件名对应上

Comment thread cli/.gitignore
@@ -0,0 +1,14 @@
# Build artifacts
bin/
/distbox

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

新增ai相关的ignore

Comment thread cli/internal/term/vt_other.go Outdated
import "os"

// enableVT is a no-op on Unix terminals, which process ANSI escapes by default.
func enableVT(f *os.File) error { return nil }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

合并到term

Comment thread cli/internal/term/vt_windows.go Outdated

// enableVT enables ANSI escape sequence processing on a Windows console
// output handle so remote PTY output renders correctly.
func enableVT(f *os.File) error {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

合并到term

Comment thread cli/internal/term/term.go Outdated
// Package term wires the local terminal to a sandbox PTY: it puts the local
// terminal into raw mode, forwards keystrokes to the remote process and
// renders remote output locally, like an SSH session.
package term

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

包名改成terminal,term和terminal有不同的语义

Comment thread cli/internal/parse/parse.go Outdated
}

// ParseMetadata parses the --metadata argument; empty returns nil.
func ParseMetadata(pairs []string) (*map[string]string, error) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

合并到其他模块或者文件

Comment thread js-sdk/src/commands.ts
type TransportProvider = () => Promise<Transport>;
export type OutputHandler = (value: string) => void | Promise<void>;

export interface RunOptions {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对外暴露的方法或者变量,适当补充注释

- -u 经 Authorization Basic 头传递给 envd(用户不存在时显式报 invalid_argument),移除无效的 ProcessConfig.user 通路
- 数据面新增 -v 调试日志(envdLoggingTransport:记录 Basic 用户、relay token 长度与错误体;流式响应不缓冲避免卡死),并切换 JSON codec 对齐 processes API 文档
- 检视意见修复:proto 拍平(proto/process.proto 与 processgen 同层)、term 包更名 terminal 并合并 vt 平台文件、parse 包并入 helpers、auth 单测按业务文件拆分(verify/login/apikey_test)、.gitignore 增加 AI 忽略
- 帮助输出隐藏 Aliases 段:Use 管道写法已展示缩写,避免 Name 派生项造成的重复展示

This branch was successfully deployed

1 active (outdated) deployment
github-pages — 28376836 Deployed Nov 13, 2026 by lizhicheng00 via deploy #22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants