feat(server): add user add target defaults#2888
Open
qin-ctx wants to merge 3 commits into
Open
Conversation
Allow deployments and per-user settings to provide default add targets while keeping explicit request targets authoritative.
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.
Description
本 PR 增加“用户默认添加目标”能力,用于让部署配置或用户个人配置决定
add_resource/add_skill在未显式传目标时写到哪里,同时保持旧行为兼容:如果没有配置默认值,现有调用路径不变。配置示例:
{ "server": { "user_config_defaults": { "add_targets": { "resource_uri": "viking://user/resources", "skill_uri": "viking://user/skills" } } } }解析规则:
add_resource:显式to/parent优先;否则使用当前用户配置里的add_targets.resource_uri;再否则使用server.user_config_defaults.add_targets.resource_uri;都没有时保持旧行为。add_skill:显式target_uri优先;否则使用当前用户配置里的add_targets.skill_uri;再否则使用server.user_config_defaults.add_targets.skill_uri;都没有时保持旧行为。resource_uri按默认父目录处理,等价于parent=<uri>, create_parent=true。viking://user/...会按请求用户解析,例如 Alice 的viking://user/resources会落到 Alice 的 user resource 根。resource_uri支持可写 resource 目录:viking://resources/viking://resources/...、viking://user/resources/viking://user/resources/...、viking://user/{user_id}/resources/...、viking://user/{user_id}/peers/{peer_id}/resources/...。skill_uriv1 只允许viking://user/skills和viking://agent/skills。用户覆盖配置通过 HTTP 管理:
创建账号或注册用户时也可写入初始用户配置,字段统一为
user_config。在创建账号场景中,user_config作用于admin_user_id指定的首个管理员用户。创建账号并初始化首个管理员用户配置:
在已有账号下注册用户并初始化用户配置:
对应 CLI 示例:
Python SDK 示例:
Go SDK 示例:
Related Issue
无。
Type of Change
Changes Made
server.user_config_defaults.add_targets配置模型、运行时校验和服务端默认目标解析逻辑。GET/PATCH/DELETE /api/v1/user-settings/add-locations,并将用户配置存储为viking://user/{user_id}/settings/user_config.json。ResourceService.add_resource/add_skill接入默认目标解析,CLI、SDK、MCP、Web 等调用方省略目标时自动受益。user_config。Testing
已执行:
Go 测试在本地需要 loopback 监听权限,已在提升权限后通过。
Checklist
Screenshots (if applicable)
不适用。
Additional Notes
本 PR 没有新增独立的 CLI/SDK “设置 add locations”接口;CLI/SDK 只在创建/注册用户路径支持初始化用户配置。普通 add 调用继续通过服务端解析默认目标,避免客户端各自保存默认值造成语义分叉。