WeKnora/internal/handler/skill_handler.go

92 lines
3.2 KiB
Go
Raw Normal View History

package handler
import (
feat(sandbox): expose tenant skill management over HTTP and in the console (#2789) * feat(sandbox): enhance skill management in sandbox configurations Updated the skill management system to allow listing, installing, and removing skills within sandbox configurations. The ListSkills function now accepts a sandboxConfigID to filter skills based on the selected configuration. Introduced a new SandboxSkillsDrawer component for managing skills through the UI, along with necessary updates to the API and localization files to support these features. Co-authored-by: Cursor <cursoragent@cursor.com> * fix: keep skill maintenance sessions out of the console session list Co-authored-by: Cursor <cursoragent@cursor.com> * feat: store and expose the installer transcript locators Co-authored-by: Cursor <cursoragent@cursor.com> * feat: record the skill installer agent's conversation Co-authored-by: Cursor <cursoragent@cursor.com> * feat: stream and persist the installer transcript during a skill install Co-authored-by: Cursor <cursoragent@cursor.com> * feat: expose install transcript locators on the skill type Co-authored-by: Cursor <cursoragent@cursor.com> * feat: add the floating skill install transcript window Co-authored-by: Cursor <cursoragent@cursor.com> * feat: open the install transcript from the sandbox skills drawer Co-authored-by: Cursor <cursoragent@cursor.com> * feat(sandbox): 重构技能安装体验,支持内联时间线、编辑第4步及保留镜像指针 - 替换右下角浮窗为内联安装时间线 (SkillInstallTimeline.vue) - 新增 GET /api/v1/sandbox-configs/:id/skills/:skillId/transcript 接口,支持回放与追尾 - 移除 /sessions/continue-stream 依赖,避免 404 问题 - 事件日志以 install_prompt 开头,不再将工具调用 preamble 拼入最终答案 - 删除 SkillInstallTranscript.vue,技能条目下可展开/折叠时间线 - 编辑向导新增第 4 步「管理技能」 - Cube/E2B 环境:连接 → 模板 → 运行配置 → 技能(第4步) - Docker/Local 环境:无第4步(无快照镜像) - 首次创建必须按 1→2→3 顺序,第3步保存成功后自动进入第4步 - 已有配置支持步骤条数字跳转,可直接访问任意步骤 - 卡片菜单「管理技能」打开同一抽屉并定位至第4步 - SandboxSkillsDrawer.vue 重命名为 SandboxSkillsPanel.vue,去除独立抽屉壳 - 修复保存运行配置时冲掉 skill_image 的问题 - 顶部展示信息(基础模板/快照ID/版本/构建时间)读取 config.skill_image - 编辑器保存 payload 不再包含 skill_image,合并时保留已有 SkillImage 和 VolumeMount - MergeSandboxConfigForUpdate 增加对 SkillImage 和 VolumeMount 的保护 - 已冲掉的配置需重新安装技能才能恢复镜像指针 - 「查看安装过程」在安装开始时即显示 - 技能列表中出现「正在安装」状态即展示按钮 - 若记录尚未写入,展示等待提示并自动重试,避免误报「没有留下记录」 * 沙盒内技能目录从 UUID 改成 SKILL.md 的 name。 * fix(sandbox): heal stuck skill rows and block planted maintenance sessions The reaper left a mid-upgrade install spinning forever when the old snapshot was still live, and restored removals to ready after the pointer had already moved. Client session create/update can no longer hide chats behind the skill_maintenance: prefix. * style: gofumpt the skill reaper test stubs * style: satisfy golangci on the tenant skill admin API * feat(sandbox): rebuild skill images at turn boundaries, not mid-exec Hold a session turn lease through AgentQA so an install cannot tear down the live sandbox between tool calls; the next turn's first resolve picks up the new image. Configs can instead keep existing sandboxes and boot the new snapshot only for new sessions. * fix(sandbox): judge stuck skill runs from the snapshot chain InstalledSnapshotID only records the generation that installed a skill; later installs of other skills advance the live pointer without rewriting older rows. Comparing those IDs made the reaper fail healthy installs and delete live skills whose removal had stalled. --------- Co-authored-by: hailongzhao <hailongzhao@tencent.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-08-25 03:28:12 +00:00
"context"
"net/http"
"github.com/Tencent/WeKnora/internal/application/service"
feat(sandbox): expose tenant skill management over HTTP and in the console (#2789) * feat(sandbox): enhance skill management in sandbox configurations Updated the skill management system to allow listing, installing, and removing skills within sandbox configurations. The ListSkills function now accepts a sandboxConfigID to filter skills based on the selected configuration. Introduced a new SandboxSkillsDrawer component for managing skills through the UI, along with necessary updates to the API and localization files to support these features. Co-authored-by: Cursor <cursoragent@cursor.com> * fix: keep skill maintenance sessions out of the console session list Co-authored-by: Cursor <cursoragent@cursor.com> * feat: store and expose the installer transcript locators Co-authored-by: Cursor <cursoragent@cursor.com> * feat: record the skill installer agent's conversation Co-authored-by: Cursor <cursoragent@cursor.com> * feat: stream and persist the installer transcript during a skill install Co-authored-by: Cursor <cursoragent@cursor.com> * feat: expose install transcript locators on the skill type Co-authored-by: Cursor <cursoragent@cursor.com> * feat: add the floating skill install transcript window Co-authored-by: Cursor <cursoragent@cursor.com> * feat: open the install transcript from the sandbox skills drawer Co-authored-by: Cursor <cursoragent@cursor.com> * feat(sandbox): 重构技能安装体验,支持内联时间线、编辑第4步及保留镜像指针 - 替换右下角浮窗为内联安装时间线 (SkillInstallTimeline.vue) - 新增 GET /api/v1/sandbox-configs/:id/skills/:skillId/transcript 接口,支持回放与追尾 - 移除 /sessions/continue-stream 依赖,避免 404 问题 - 事件日志以 install_prompt 开头,不再将工具调用 preamble 拼入最终答案 - 删除 SkillInstallTranscript.vue,技能条目下可展开/折叠时间线 - 编辑向导新增第 4 步「管理技能」 - Cube/E2B 环境:连接 → 模板 → 运行配置 → 技能(第4步) - Docker/Local 环境:无第4步(无快照镜像) - 首次创建必须按 1→2→3 顺序,第3步保存成功后自动进入第4步 - 已有配置支持步骤条数字跳转,可直接访问任意步骤 - 卡片菜单「管理技能」打开同一抽屉并定位至第4步 - SandboxSkillsDrawer.vue 重命名为 SandboxSkillsPanel.vue,去除独立抽屉壳 - 修复保存运行配置时冲掉 skill_image 的问题 - 顶部展示信息(基础模板/快照ID/版本/构建时间)读取 config.skill_image - 编辑器保存 payload 不再包含 skill_image,合并时保留已有 SkillImage 和 VolumeMount - MergeSandboxConfigForUpdate 增加对 SkillImage 和 VolumeMount 的保护 - 已冲掉的配置需重新安装技能才能恢复镜像指针 - 「查看安装过程」在安装开始时即显示 - 技能列表中出现「正在安装」状态即展示按钮 - 若记录尚未写入,展示等待提示并自动重试,避免误报「没有留下记录」 * 沙盒内技能目录从 UUID 改成 SKILL.md 的 name。 * fix(sandbox): heal stuck skill rows and block planted maintenance sessions The reaper left a mid-upgrade install spinning forever when the old snapshot was still live, and restored removals to ready after the pointer had already moved. Client session create/update can no longer hide chats behind the skill_maintenance: prefix. * style: gofumpt the skill reaper test stubs * style: satisfy golangci on the tenant skill admin API * feat(sandbox): rebuild skill images at turn boundaries, not mid-exec Hold a session turn lease through AgentQA so an install cannot tear down the live sandbox between tool calls; the next turn's first resolve picks up the new image. Configs can instead keep existing sandboxes and boot the new snapshot only for new sessions. * fix(sandbox): judge stuck skill runs from the snapshot chain InstalledSnapshotID only records the generation that installed a skill; later installs of other skills advance the live pointer without rewriting older rows. Comparing those IDs made the reaper fail healthy installs and delete live skills whose removal had stalled. --------- Co-authored-by: hailongzhao <hailongzhao@tencent.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-08-25 03:28:12 +00:00
"github.com/Tencent/WeKnora/internal/types"
"github.com/gin-gonic/gin"
)
feat(sandbox): expose tenant skill management over HTTP and in the console (#2789) * feat(sandbox): enhance skill management in sandbox configurations Updated the skill management system to allow listing, installing, and removing skills within sandbox configurations. The ListSkills function now accepts a sandboxConfigID to filter skills based on the selected configuration. Introduced a new SandboxSkillsDrawer component for managing skills through the UI, along with necessary updates to the API and localization files to support these features. Co-authored-by: Cursor <cursoragent@cursor.com> * fix: keep skill maintenance sessions out of the console session list Co-authored-by: Cursor <cursoragent@cursor.com> * feat: store and expose the installer transcript locators Co-authored-by: Cursor <cursoragent@cursor.com> * feat: record the skill installer agent's conversation Co-authored-by: Cursor <cursoragent@cursor.com> * feat: stream and persist the installer transcript during a skill install Co-authored-by: Cursor <cursoragent@cursor.com> * feat: expose install transcript locators on the skill type Co-authored-by: Cursor <cursoragent@cursor.com> * feat: add the floating skill install transcript window Co-authored-by: Cursor <cursoragent@cursor.com> * feat: open the install transcript from the sandbox skills drawer Co-authored-by: Cursor <cursoragent@cursor.com> * feat(sandbox): 重构技能安装体验,支持内联时间线、编辑第4步及保留镜像指针 - 替换右下角浮窗为内联安装时间线 (SkillInstallTimeline.vue) - 新增 GET /api/v1/sandbox-configs/:id/skills/:skillId/transcript 接口,支持回放与追尾 - 移除 /sessions/continue-stream 依赖,避免 404 问题 - 事件日志以 install_prompt 开头,不再将工具调用 preamble 拼入最终答案 - 删除 SkillInstallTranscript.vue,技能条目下可展开/折叠时间线 - 编辑向导新增第 4 步「管理技能」 - Cube/E2B 环境:连接 → 模板 → 运行配置 → 技能(第4步) - Docker/Local 环境:无第4步(无快照镜像) - 首次创建必须按 1→2→3 顺序,第3步保存成功后自动进入第4步 - 已有配置支持步骤条数字跳转,可直接访问任意步骤 - 卡片菜单「管理技能」打开同一抽屉并定位至第4步 - SandboxSkillsDrawer.vue 重命名为 SandboxSkillsPanel.vue,去除独立抽屉壳 - 修复保存运行配置时冲掉 skill_image 的问题 - 顶部展示信息(基础模板/快照ID/版本/构建时间)读取 config.skill_image - 编辑器保存 payload 不再包含 skill_image,合并时保留已有 SkillImage 和 VolumeMount - MergeSandboxConfigForUpdate 增加对 SkillImage 和 VolumeMount 的保护 - 已冲掉的配置需重新安装技能才能恢复镜像指针 - 「查看安装过程」在安装开始时即显示 - 技能列表中出现「正在安装」状态即展示按钮 - 若记录尚未写入,展示等待提示并自动重试,避免误报「没有留下记录」 * 沙盒内技能目录从 UUID 改成 SKILL.md 的 name。 * fix(sandbox): heal stuck skill rows and block planted maintenance sessions The reaper left a mid-upgrade install spinning forever when the old snapshot was still live, and restored removals to ready after the pointer had already moved. Client session create/update can no longer hide chats behind the skill_maintenance: prefix. * style: gofumpt the skill reaper test stubs * style: satisfy golangci on the tenant skill admin API * feat(sandbox): rebuild skill images at turn boundaries, not mid-exec Hold a session turn lease through AgentQA so an install cannot tear down the live sandbox between tool calls; the next turn's first resolve picks up the new image. Configs can instead keep existing sandboxes and boot the new snapshot only for new sessions. * fix(sandbox): judge stuck skill runs from the snapshot chain InstalledSnapshotID only records the generation that installed a skill; later installs of other skills advance the live pointer without rewriting older rows. Comparing those IDs made the reaper fail healthy installs and delete live skills whose removal had stalled. --------- Co-authored-by: hailongzhao <hailongzhao@tencent.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-08-25 03:28:12 +00:00
// usableSkillLister returns the installed skills a chat turn can actually
// invoke on one sandbox config. The @ picker and the agent editor both read
// this set so they cannot offer a skill the running image does not carry.
type usableSkillLister interface {
ListUsableSkills(ctx context.Context, tenantID uint64, configID string) []*types.TenantSkillEntity
}
// SkillHandler handles skill-related HTTP requests
type SkillHandler struct {
feat(sandbox): expose tenant skill management over HTTP and in the console (#2789) * feat(sandbox): enhance skill management in sandbox configurations Updated the skill management system to allow listing, installing, and removing skills within sandbox configurations. The ListSkills function now accepts a sandboxConfigID to filter skills based on the selected configuration. Introduced a new SandboxSkillsDrawer component for managing skills through the UI, along with necessary updates to the API and localization files to support these features. Co-authored-by: Cursor <cursoragent@cursor.com> * fix: keep skill maintenance sessions out of the console session list Co-authored-by: Cursor <cursoragent@cursor.com> * feat: store and expose the installer transcript locators Co-authored-by: Cursor <cursoragent@cursor.com> * feat: record the skill installer agent's conversation Co-authored-by: Cursor <cursoragent@cursor.com> * feat: stream and persist the installer transcript during a skill install Co-authored-by: Cursor <cursoragent@cursor.com> * feat: expose install transcript locators on the skill type Co-authored-by: Cursor <cursoragent@cursor.com> * feat: add the floating skill install transcript window Co-authored-by: Cursor <cursoragent@cursor.com> * feat: open the install transcript from the sandbox skills drawer Co-authored-by: Cursor <cursoragent@cursor.com> * feat(sandbox): 重构技能安装体验,支持内联时间线、编辑第4步及保留镜像指针 - 替换右下角浮窗为内联安装时间线 (SkillInstallTimeline.vue) - 新增 GET /api/v1/sandbox-configs/:id/skills/:skillId/transcript 接口,支持回放与追尾 - 移除 /sessions/continue-stream 依赖,避免 404 问题 - 事件日志以 install_prompt 开头,不再将工具调用 preamble 拼入最终答案 - 删除 SkillInstallTranscript.vue,技能条目下可展开/折叠时间线 - 编辑向导新增第 4 步「管理技能」 - Cube/E2B 环境:连接 → 模板 → 运行配置 → 技能(第4步) - Docker/Local 环境:无第4步(无快照镜像) - 首次创建必须按 1→2→3 顺序,第3步保存成功后自动进入第4步 - 已有配置支持步骤条数字跳转,可直接访问任意步骤 - 卡片菜单「管理技能」打开同一抽屉并定位至第4步 - SandboxSkillsDrawer.vue 重命名为 SandboxSkillsPanel.vue,去除独立抽屉壳 - 修复保存运行配置时冲掉 skill_image 的问题 - 顶部展示信息(基础模板/快照ID/版本/构建时间)读取 config.skill_image - 编辑器保存 payload 不再包含 skill_image,合并时保留已有 SkillImage 和 VolumeMount - MergeSandboxConfigForUpdate 增加对 SkillImage 和 VolumeMount 的保护 - 已冲掉的配置需重新安装技能才能恢复镜像指针 - 「查看安装过程」在安装开始时即显示 - 技能列表中出现「正在安装」状态即展示按钮 - 若记录尚未写入,展示等待提示并自动重试,避免误报「没有留下记录」 * 沙盒内技能目录从 UUID 改成 SKILL.md 的 name。 * fix(sandbox): heal stuck skill rows and block planted maintenance sessions The reaper left a mid-upgrade install spinning forever when the old snapshot was still live, and restored removals to ready after the pointer had already moved. Client session create/update can no longer hide chats behind the skill_maintenance: prefix. * style: gofumpt the skill reaper test stubs * style: satisfy golangci on the tenant skill admin API * feat(sandbox): rebuild skill images at turn boundaries, not mid-exec Hold a session turn lease through AgentQA so an install cannot tear down the live sandbox between tool calls; the next turn's first resolve picks up the new image. Configs can instead keep existing sandboxes and boot the new snapshot only for new sessions. * fix(sandbox): judge stuck skill runs from the snapshot chain InstalledSnapshotID only records the generation that installed a skill; later installs of other skills advance the live pointer without rewriting older rows. Comparing those IDs made the reaper fail healthy installs and delete live skills whose removal had stalled. --------- Co-authored-by: hailongzhao <hailongzhao@tencent.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-08-25 03:28:12 +00:00
usableSkills usableSkillLister
catalog skillCatalogService
}
type skillCatalogService interface {
ListCatalog(ctx context.Context, tenantID uint64) ([]service.SkillCatalogView, error)
RegisterCatalogFromArchive(ctx context.Context, tenantID uint64, archive []byte) (*types.TenantSkillCatalogEntity, error)
RegisterCatalogFromSource(ctx context.Context, tenantID uint64, source string) (*types.TenantSkillCatalogEntity, error)
InstallCatalogToConfigs(ctx context.Context, tenantID uint64, catalogID string, configIDs []string) (*service.CatalogInstallResult, error)
DeleteCatalog(ctx context.Context, tenantID uint64, catalogID string) error
ListCatalogFiles(ctx context.Context, tenantID uint64, catalogID string) ([]service.SkillFileEntry, error)
ReadCatalogFile(ctx context.Context, tenantID uint64, catalogID, relativePath string) (*service.SkillFileContent, error)
}
// NewSkillHandler creates a new skill handler. catalog may be nil in tests
// that only exercise the chat picker.
func NewSkillHandler(usableSkills usableSkillLister, catalog skillCatalogService) *SkillHandler {
return &SkillHandler{
feat(sandbox): expose tenant skill management over HTTP and in the console (#2789) * feat(sandbox): enhance skill management in sandbox configurations Updated the skill management system to allow listing, installing, and removing skills within sandbox configurations. The ListSkills function now accepts a sandboxConfigID to filter skills based on the selected configuration. Introduced a new SandboxSkillsDrawer component for managing skills through the UI, along with necessary updates to the API and localization files to support these features. Co-authored-by: Cursor <cursoragent@cursor.com> * fix: keep skill maintenance sessions out of the console session list Co-authored-by: Cursor <cursoragent@cursor.com> * feat: store and expose the installer transcript locators Co-authored-by: Cursor <cursoragent@cursor.com> * feat: record the skill installer agent's conversation Co-authored-by: Cursor <cursoragent@cursor.com> * feat: stream and persist the installer transcript during a skill install Co-authored-by: Cursor <cursoragent@cursor.com> * feat: expose install transcript locators on the skill type Co-authored-by: Cursor <cursoragent@cursor.com> * feat: add the floating skill install transcript window Co-authored-by: Cursor <cursoragent@cursor.com> * feat: open the install transcript from the sandbox skills drawer Co-authored-by: Cursor <cursoragent@cursor.com> * feat(sandbox): 重构技能安装体验,支持内联时间线、编辑第4步及保留镜像指针 - 替换右下角浮窗为内联安装时间线 (SkillInstallTimeline.vue) - 新增 GET /api/v1/sandbox-configs/:id/skills/:skillId/transcript 接口,支持回放与追尾 - 移除 /sessions/continue-stream 依赖,避免 404 问题 - 事件日志以 install_prompt 开头,不再将工具调用 preamble 拼入最终答案 - 删除 SkillInstallTranscript.vue,技能条目下可展开/折叠时间线 - 编辑向导新增第 4 步「管理技能」 - Cube/E2B 环境:连接 → 模板 → 运行配置 → 技能(第4步) - Docker/Local 环境:无第4步(无快照镜像) - 首次创建必须按 1→2→3 顺序,第3步保存成功后自动进入第4步 - 已有配置支持步骤条数字跳转,可直接访问任意步骤 - 卡片菜单「管理技能」打开同一抽屉并定位至第4步 - SandboxSkillsDrawer.vue 重命名为 SandboxSkillsPanel.vue,去除独立抽屉壳 - 修复保存运行配置时冲掉 skill_image 的问题 - 顶部展示信息(基础模板/快照ID/版本/构建时间)读取 config.skill_image - 编辑器保存 payload 不再包含 skill_image,合并时保留已有 SkillImage 和 VolumeMount - MergeSandboxConfigForUpdate 增加对 SkillImage 和 VolumeMount 的保护 - 已冲掉的配置需重新安装技能才能恢复镜像指针 - 「查看安装过程」在安装开始时即显示 - 技能列表中出现「正在安装」状态即展示按钮 - 若记录尚未写入,展示等待提示并自动重试,避免误报「没有留下记录」 * 沙盒内技能目录从 UUID 改成 SKILL.md 的 name。 * fix(sandbox): heal stuck skill rows and block planted maintenance sessions The reaper left a mid-upgrade install spinning forever when the old snapshot was still live, and restored removals to ready after the pointer had already moved. Client session create/update can no longer hide chats behind the skill_maintenance: prefix. * style: gofumpt the skill reaper test stubs * style: satisfy golangci on the tenant skill admin API * feat(sandbox): rebuild skill images at turn boundaries, not mid-exec Hold a session turn lease through AgentQA so an install cannot tear down the live sandbox between tool calls; the next turn's first resolve picks up the new image. Configs can instead keep existing sandboxes and boot the new snapshot only for new sessions. * fix(sandbox): judge stuck skill runs from the snapshot chain InstalledSnapshotID only records the generation that installed a skill; later installs of other skills advance the live pointer without rewriting older rows. Comparing those IDs made the reaper fail healthy installs and delete live skills whose removal had stalled. --------- Co-authored-by: hailongzhao <hailongzhao@tencent.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-08-25 03:28:12 +00:00
usableSkills: usableSkills,
catalog: catalog,
}
}
// SkillInfoResponse represents the skill info returned to frontend
type SkillInfoResponse struct {
Name string `json:"name"`
Description string `json:"description"`
}
// ListSkills godoc
// @Summary 获取当前沙箱配置上可执行的 Skills
// @Description 返回指定沙箱配置镜像内、智能体实际能调用的已安装技能(ready 且启用)。不传 sandbox_config_id 时列表为空。
// @Tags Skills
// @Accept json
// @Produce json
feat(sandbox): expose tenant skill management over HTTP and in the console (#2789) * feat(sandbox): enhance skill management in sandbox configurations Updated the skill management system to allow listing, installing, and removing skills within sandbox configurations. The ListSkills function now accepts a sandboxConfigID to filter skills based on the selected configuration. Introduced a new SandboxSkillsDrawer component for managing skills through the UI, along with necessary updates to the API and localization files to support these features. Co-authored-by: Cursor <cursoragent@cursor.com> * fix: keep skill maintenance sessions out of the console session list Co-authored-by: Cursor <cursoragent@cursor.com> * feat: store and expose the installer transcript locators Co-authored-by: Cursor <cursoragent@cursor.com> * feat: record the skill installer agent's conversation Co-authored-by: Cursor <cursoragent@cursor.com> * feat: stream and persist the installer transcript during a skill install Co-authored-by: Cursor <cursoragent@cursor.com> * feat: expose install transcript locators on the skill type Co-authored-by: Cursor <cursoragent@cursor.com> * feat: add the floating skill install transcript window Co-authored-by: Cursor <cursoragent@cursor.com> * feat: open the install transcript from the sandbox skills drawer Co-authored-by: Cursor <cursoragent@cursor.com> * feat(sandbox): 重构技能安装体验,支持内联时间线、编辑第4步及保留镜像指针 - 替换右下角浮窗为内联安装时间线 (SkillInstallTimeline.vue) - 新增 GET /api/v1/sandbox-configs/:id/skills/:skillId/transcript 接口,支持回放与追尾 - 移除 /sessions/continue-stream 依赖,避免 404 问题 - 事件日志以 install_prompt 开头,不再将工具调用 preamble 拼入最终答案 - 删除 SkillInstallTranscript.vue,技能条目下可展开/折叠时间线 - 编辑向导新增第 4 步「管理技能」 - Cube/E2B 环境:连接 → 模板 → 运行配置 → 技能(第4步) - Docker/Local 环境:无第4步(无快照镜像) - 首次创建必须按 1→2→3 顺序,第3步保存成功后自动进入第4步 - 已有配置支持步骤条数字跳转,可直接访问任意步骤 - 卡片菜单「管理技能」打开同一抽屉并定位至第4步 - SandboxSkillsDrawer.vue 重命名为 SandboxSkillsPanel.vue,去除独立抽屉壳 - 修复保存运行配置时冲掉 skill_image 的问题 - 顶部展示信息(基础模板/快照ID/版本/构建时间)读取 config.skill_image - 编辑器保存 payload 不再包含 skill_image,合并时保留已有 SkillImage 和 VolumeMount - MergeSandboxConfigForUpdate 增加对 SkillImage 和 VolumeMount 的保护 - 已冲掉的配置需重新安装技能才能恢复镜像指针 - 「查看安装过程」在安装开始时即显示 - 技能列表中出现「正在安装」状态即展示按钮 - 若记录尚未写入,展示等待提示并自动重试,避免误报「没有留下记录」 * 沙盒内技能目录从 UUID 改成 SKILL.md 的 name。 * fix(sandbox): heal stuck skill rows and block planted maintenance sessions The reaper left a mid-upgrade install spinning forever when the old snapshot was still live, and restored removals to ready after the pointer had already moved. Client session create/update can no longer hide chats behind the skill_maintenance: prefix. * style: gofumpt the skill reaper test stubs * style: satisfy golangci on the tenant skill admin API * feat(sandbox): rebuild skill images at turn boundaries, not mid-exec Hold a session turn lease through AgentQA so an install cannot tear down the live sandbox between tool calls; the next turn's first resolve picks up the new image. Configs can instead keep existing sandboxes and boot the new snapshot only for new sessions. * fix(sandbox): judge stuck skill runs from the snapshot chain InstalledSnapshotID only records the generation that installed a skill; later installs of other skills advance the live pointer without rewriting older rows. Comparing those IDs made the reaper fail healthy installs and delete live skills whose removal had stalled. --------- Co-authored-by: hailongzhao <hailongzhao@tencent.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-08-25 03:28:12 +00:00
// @Param sandbox_config_id query string false "Sandbox config ID"
// @Success 200 {object} map[string]interface{} "Skills列表"
// @Security Bearer
// @Security ApiKeyAuth
// @Router /skills [get]
func (h *SkillHandler) ListSkills(c *gin.Context) {
feat(sandbox): expose tenant skill management over HTTP and in the console (#2789) * feat(sandbox): enhance skill management in sandbox configurations Updated the skill management system to allow listing, installing, and removing skills within sandbox configurations. The ListSkills function now accepts a sandboxConfigID to filter skills based on the selected configuration. Introduced a new SandboxSkillsDrawer component for managing skills through the UI, along with necessary updates to the API and localization files to support these features. Co-authored-by: Cursor <cursoragent@cursor.com> * fix: keep skill maintenance sessions out of the console session list Co-authored-by: Cursor <cursoragent@cursor.com> * feat: store and expose the installer transcript locators Co-authored-by: Cursor <cursoragent@cursor.com> * feat: record the skill installer agent's conversation Co-authored-by: Cursor <cursoragent@cursor.com> * feat: stream and persist the installer transcript during a skill install Co-authored-by: Cursor <cursoragent@cursor.com> * feat: expose install transcript locators on the skill type Co-authored-by: Cursor <cursoragent@cursor.com> * feat: add the floating skill install transcript window Co-authored-by: Cursor <cursoragent@cursor.com> * feat: open the install transcript from the sandbox skills drawer Co-authored-by: Cursor <cursoragent@cursor.com> * feat(sandbox): 重构技能安装体验,支持内联时间线、编辑第4步及保留镜像指针 - 替换右下角浮窗为内联安装时间线 (SkillInstallTimeline.vue) - 新增 GET /api/v1/sandbox-configs/:id/skills/:skillId/transcript 接口,支持回放与追尾 - 移除 /sessions/continue-stream 依赖,避免 404 问题 - 事件日志以 install_prompt 开头,不再将工具调用 preamble 拼入最终答案 - 删除 SkillInstallTranscript.vue,技能条目下可展开/折叠时间线 - 编辑向导新增第 4 步「管理技能」 - Cube/E2B 环境:连接 → 模板 → 运行配置 → 技能(第4步) - Docker/Local 环境:无第4步(无快照镜像) - 首次创建必须按 1→2→3 顺序,第3步保存成功后自动进入第4步 - 已有配置支持步骤条数字跳转,可直接访问任意步骤 - 卡片菜单「管理技能」打开同一抽屉并定位至第4步 - SandboxSkillsDrawer.vue 重命名为 SandboxSkillsPanel.vue,去除独立抽屉壳 - 修复保存运行配置时冲掉 skill_image 的问题 - 顶部展示信息(基础模板/快照ID/版本/构建时间)读取 config.skill_image - 编辑器保存 payload 不再包含 skill_image,合并时保留已有 SkillImage 和 VolumeMount - MergeSandboxConfigForUpdate 增加对 SkillImage 和 VolumeMount 的保护 - 已冲掉的配置需重新安装技能才能恢复镜像指针 - 「查看安装过程」在安装开始时即显示 - 技能列表中出现「正在安装」状态即展示按钮 - 若记录尚未写入,展示等待提示并自动重试,避免误报「没有留下记录」 * 沙盒内技能目录从 UUID 改成 SKILL.md 的 name。 * fix(sandbox): heal stuck skill rows and block planted maintenance sessions The reaper left a mid-upgrade install spinning forever when the old snapshot was still live, and restored removals to ready after the pointer had already moved. Client session create/update can no longer hide chats behind the skill_maintenance: prefix. * style: gofumpt the skill reaper test stubs * style: satisfy golangci on the tenant skill admin API * feat(sandbox): rebuild skill images at turn boundaries, not mid-exec Hold a session turn lease through AgentQA so an install cannot tear down the live sandbox between tool calls; the next turn's first resolve picks up the new image. Configs can instead keep existing sandboxes and boot the new snapshot only for new sessions. * fix(sandbox): judge stuck skill runs from the snapshot chain InstalledSnapshotID only records the generation that installed a skill; later installs of other skills advance the live pointer without rewriting older rows. Comparing those IDs made the reaper fail healthy installs and delete live skills whose removal had stalled. --------- Co-authored-by: hailongzhao <hailongzhao@tencent.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-08-25 03:28:12 +00:00
configID := c.Query("sandbox_config_id")
if configID == "" || h.usableSkills == nil {
c.JSON(http.StatusOK, gin.H{
"success": true,
"data": []SkillInfoResponse{},
"skills_available": false,
})
return
}
feat(sandbox): expose tenant skill management over HTTP and in the console (#2789) * feat(sandbox): enhance skill management in sandbox configurations Updated the skill management system to allow listing, installing, and removing skills within sandbox configurations. The ListSkills function now accepts a sandboxConfigID to filter skills based on the selected configuration. Introduced a new SandboxSkillsDrawer component for managing skills through the UI, along with necessary updates to the API and localization files to support these features. Co-authored-by: Cursor <cursoragent@cursor.com> * fix: keep skill maintenance sessions out of the console session list Co-authored-by: Cursor <cursoragent@cursor.com> * feat: store and expose the installer transcript locators Co-authored-by: Cursor <cursoragent@cursor.com> * feat: record the skill installer agent's conversation Co-authored-by: Cursor <cursoragent@cursor.com> * feat: stream and persist the installer transcript during a skill install Co-authored-by: Cursor <cursoragent@cursor.com> * feat: expose install transcript locators on the skill type Co-authored-by: Cursor <cursoragent@cursor.com> * feat: add the floating skill install transcript window Co-authored-by: Cursor <cursoragent@cursor.com> * feat: open the install transcript from the sandbox skills drawer Co-authored-by: Cursor <cursoragent@cursor.com> * feat(sandbox): 重构技能安装体验,支持内联时间线、编辑第4步及保留镜像指针 - 替换右下角浮窗为内联安装时间线 (SkillInstallTimeline.vue) - 新增 GET /api/v1/sandbox-configs/:id/skills/:skillId/transcript 接口,支持回放与追尾 - 移除 /sessions/continue-stream 依赖,避免 404 问题 - 事件日志以 install_prompt 开头,不再将工具调用 preamble 拼入最终答案 - 删除 SkillInstallTranscript.vue,技能条目下可展开/折叠时间线 - 编辑向导新增第 4 步「管理技能」 - Cube/E2B 环境:连接 → 模板 → 运行配置 → 技能(第4步) - Docker/Local 环境:无第4步(无快照镜像) - 首次创建必须按 1→2→3 顺序,第3步保存成功后自动进入第4步 - 已有配置支持步骤条数字跳转,可直接访问任意步骤 - 卡片菜单「管理技能」打开同一抽屉并定位至第4步 - SandboxSkillsDrawer.vue 重命名为 SandboxSkillsPanel.vue,去除独立抽屉壳 - 修复保存运行配置时冲掉 skill_image 的问题 - 顶部展示信息(基础模板/快照ID/版本/构建时间)读取 config.skill_image - 编辑器保存 payload 不再包含 skill_image,合并时保留已有 SkillImage 和 VolumeMount - MergeSandboxConfigForUpdate 增加对 SkillImage 和 VolumeMount 的保护 - 已冲掉的配置需重新安装技能才能恢复镜像指针 - 「查看安装过程」在安装开始时即显示 - 技能列表中出现「正在安装」状态即展示按钮 - 若记录尚未写入,展示等待提示并自动重试,避免误报「没有留下记录」 * 沙盒内技能目录从 UUID 改成 SKILL.md 的 name。 * fix(sandbox): heal stuck skill rows and block planted maintenance sessions The reaper left a mid-upgrade install spinning forever when the old snapshot was still live, and restored removals to ready after the pointer had already moved. Client session create/update can no longer hide chats behind the skill_maintenance: prefix. * style: gofumpt the skill reaper test stubs * style: satisfy golangci on the tenant skill admin API * feat(sandbox): rebuild skill images at turn boundaries, not mid-exec Hold a session turn lease through AgentQA so an install cannot tear down the live sandbox between tool calls; the next turn's first resolve picks up the new image. Configs can instead keep existing sandboxes and boot the new snapshot only for new sessions. * fix(sandbox): judge stuck skill runs from the snapshot chain InstalledSnapshotID only records the generation that installed a skill; later installs of other skills advance the live pointer without rewriting older rows. Comparing those IDs made the reaper fail healthy installs and delete live skills whose removal had stalled. --------- Co-authored-by: hailongzhao <hailongzhao@tencent.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-08-25 03:28:12 +00:00
rows := h.usableSkills.ListUsableSkills(
c.Request.Context(), sandboxConfigTenantID(c), configID,
)
response := make([]SkillInfoResponse, 0, len(rows))
for _, row := range rows {
if row == nil {
continue
}
response = append(response, SkillInfoResponse{
feat(sandbox): expose tenant skill management over HTTP and in the console (#2789) * feat(sandbox): enhance skill management in sandbox configurations Updated the skill management system to allow listing, installing, and removing skills within sandbox configurations. The ListSkills function now accepts a sandboxConfigID to filter skills based on the selected configuration. Introduced a new SandboxSkillsDrawer component for managing skills through the UI, along with necessary updates to the API and localization files to support these features. Co-authored-by: Cursor <cursoragent@cursor.com> * fix: keep skill maintenance sessions out of the console session list Co-authored-by: Cursor <cursoragent@cursor.com> * feat: store and expose the installer transcript locators Co-authored-by: Cursor <cursoragent@cursor.com> * feat: record the skill installer agent's conversation Co-authored-by: Cursor <cursoragent@cursor.com> * feat: stream and persist the installer transcript during a skill install Co-authored-by: Cursor <cursoragent@cursor.com> * feat: expose install transcript locators on the skill type Co-authored-by: Cursor <cursoragent@cursor.com> * feat: add the floating skill install transcript window Co-authored-by: Cursor <cursoragent@cursor.com> * feat: open the install transcript from the sandbox skills drawer Co-authored-by: Cursor <cursoragent@cursor.com> * feat(sandbox): 重构技能安装体验,支持内联时间线、编辑第4步及保留镜像指针 - 替换右下角浮窗为内联安装时间线 (SkillInstallTimeline.vue) - 新增 GET /api/v1/sandbox-configs/:id/skills/:skillId/transcript 接口,支持回放与追尾 - 移除 /sessions/continue-stream 依赖,避免 404 问题 - 事件日志以 install_prompt 开头,不再将工具调用 preamble 拼入最终答案 - 删除 SkillInstallTranscript.vue,技能条目下可展开/折叠时间线 - 编辑向导新增第 4 步「管理技能」 - Cube/E2B 环境:连接 → 模板 → 运行配置 → 技能(第4步) - Docker/Local 环境:无第4步(无快照镜像) - 首次创建必须按 1→2→3 顺序,第3步保存成功后自动进入第4步 - 已有配置支持步骤条数字跳转,可直接访问任意步骤 - 卡片菜单「管理技能」打开同一抽屉并定位至第4步 - SandboxSkillsDrawer.vue 重命名为 SandboxSkillsPanel.vue,去除独立抽屉壳 - 修复保存运行配置时冲掉 skill_image 的问题 - 顶部展示信息(基础模板/快照ID/版本/构建时间)读取 config.skill_image - 编辑器保存 payload 不再包含 skill_image,合并时保留已有 SkillImage 和 VolumeMount - MergeSandboxConfigForUpdate 增加对 SkillImage 和 VolumeMount 的保护 - 已冲掉的配置需重新安装技能才能恢复镜像指针 - 「查看安装过程」在安装开始时即显示 - 技能列表中出现「正在安装」状态即展示按钮 - 若记录尚未写入,展示等待提示并自动重试,避免误报「没有留下记录」 * 沙盒内技能目录从 UUID 改成 SKILL.md 的 name。 * fix(sandbox): heal stuck skill rows and block planted maintenance sessions The reaper left a mid-upgrade install spinning forever when the old snapshot was still live, and restored removals to ready after the pointer had already moved. Client session create/update can no longer hide chats behind the skill_maintenance: prefix. * style: gofumpt the skill reaper test stubs * style: satisfy golangci on the tenant skill admin API * feat(sandbox): rebuild skill images at turn boundaries, not mid-exec Hold a session turn lease through AgentQA so an install cannot tear down the live sandbox between tool calls; the next turn's first resolve picks up the new image. Configs can instead keep existing sandboxes and boot the new snapshot only for new sessions. * fix(sandbox): judge stuck skill runs from the snapshot chain InstalledSnapshotID only records the generation that installed a skill; later installs of other skills advance the live pointer without rewriting older rows. Comparing those IDs made the reaper fail healthy installs and delete live skills whose removal had stalled. --------- Co-authored-by: hailongzhao <hailongzhao@tencent.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-08-25 03:28:12 +00:00
Name: row.Name,
Description: row.Description,
})
}
c.JSON(http.StatusOK, gin.H{
feat(sandbox): expose tenant skill management over HTTP and in the console (#2789) * feat(sandbox): enhance skill management in sandbox configurations Updated the skill management system to allow listing, installing, and removing skills within sandbox configurations. The ListSkills function now accepts a sandboxConfigID to filter skills based on the selected configuration. Introduced a new SandboxSkillsDrawer component for managing skills through the UI, along with necessary updates to the API and localization files to support these features. Co-authored-by: Cursor <cursoragent@cursor.com> * fix: keep skill maintenance sessions out of the console session list Co-authored-by: Cursor <cursoragent@cursor.com> * feat: store and expose the installer transcript locators Co-authored-by: Cursor <cursoragent@cursor.com> * feat: record the skill installer agent's conversation Co-authored-by: Cursor <cursoragent@cursor.com> * feat: stream and persist the installer transcript during a skill install Co-authored-by: Cursor <cursoragent@cursor.com> * feat: expose install transcript locators on the skill type Co-authored-by: Cursor <cursoragent@cursor.com> * feat: add the floating skill install transcript window Co-authored-by: Cursor <cursoragent@cursor.com> * feat: open the install transcript from the sandbox skills drawer Co-authored-by: Cursor <cursoragent@cursor.com> * feat(sandbox): 重构技能安装体验,支持内联时间线、编辑第4步及保留镜像指针 - 替换右下角浮窗为内联安装时间线 (SkillInstallTimeline.vue) - 新增 GET /api/v1/sandbox-configs/:id/skills/:skillId/transcript 接口,支持回放与追尾 - 移除 /sessions/continue-stream 依赖,避免 404 问题 - 事件日志以 install_prompt 开头,不再将工具调用 preamble 拼入最终答案 - 删除 SkillInstallTranscript.vue,技能条目下可展开/折叠时间线 - 编辑向导新增第 4 步「管理技能」 - Cube/E2B 环境:连接 → 模板 → 运行配置 → 技能(第4步) - Docker/Local 环境:无第4步(无快照镜像) - 首次创建必须按 1→2→3 顺序,第3步保存成功后自动进入第4步 - 已有配置支持步骤条数字跳转,可直接访问任意步骤 - 卡片菜单「管理技能」打开同一抽屉并定位至第4步 - SandboxSkillsDrawer.vue 重命名为 SandboxSkillsPanel.vue,去除独立抽屉壳 - 修复保存运行配置时冲掉 skill_image 的问题 - 顶部展示信息(基础模板/快照ID/版本/构建时间)读取 config.skill_image - 编辑器保存 payload 不再包含 skill_image,合并时保留已有 SkillImage 和 VolumeMount - MergeSandboxConfigForUpdate 增加对 SkillImage 和 VolumeMount 的保护 - 已冲掉的配置需重新安装技能才能恢复镜像指针 - 「查看安装过程」在安装开始时即显示 - 技能列表中出现「正在安装」状态即展示按钮 - 若记录尚未写入,展示等待提示并自动重试,避免误报「没有留下记录」 * 沙盒内技能目录从 UUID 改成 SKILL.md 的 name。 * fix(sandbox): heal stuck skill rows and block planted maintenance sessions The reaper left a mid-upgrade install spinning forever when the old snapshot was still live, and restored removals to ready after the pointer had already moved. Client session create/update can no longer hide chats behind the skill_maintenance: prefix. * style: gofumpt the skill reaper test stubs * style: satisfy golangci on the tenant skill admin API * feat(sandbox): rebuild skill images at turn boundaries, not mid-exec Hold a session turn lease through AgentQA so an install cannot tear down the live sandbox between tool calls; the next turn's first resolve picks up the new image. Configs can instead keep existing sandboxes and boot the new snapshot only for new sessions. * fix(sandbox): judge stuck skill runs from the snapshot chain InstalledSnapshotID only records the generation that installed a skill; later installs of other skills advance the live pointer without rewriting older rows. Comparing those IDs made the reaper fail healthy installs and delete live skills whose removal had stalled. --------- Co-authored-by: hailongzhao <hailongzhao@tencent.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-08-25 03:28:12 +00:00
"success": true,
"data": response,
feat(sandbox): 沙箱后端改为按空间配置,并补齐 E2B 模板与检测诊断 沙箱的后端类型、凭据、模板、超时和私网访问策略此前分散在部署级 WEKNORA_SANDBOX_* 环境变量里,一个实例只能有一套,租户之间无法各用 自己的 E2B 账号或自建 Cube 集群。现在这些配置全部落到空间维度的具名 沙箱配置上:部署环境不再提供覆盖项,未选择配置的智能体直接不启用脚本 执行,而不是静默回落到某个部署默认值——后者会让「这个智能体到底跑在 哪」无从判断。 同时把连接检测从「能不能连上控制面」扩展成可解释的诊断: - E2B 标准模板显式带上 default 标签构建。创建沙箱时裸模板名/ID 只解析 default 标签,构建带了别的标签就永远拿不到,表现为一个与「模板不存在」 无法区分的 404。 - 模板状态不再从历史构建或 spawn 次数反推就绪,只认当前构建;构建完成 却没有 default 标签的模板单独报成 untagged,因为它在列表里和「仍在构建」 长得一样,但等待永远不会有结果。 - 创建失败带上 HTTP 状态,404 走模板解释路径,给出具体到「重建模板」还是 「Key 属于其他团队」的结论。 - 探针脚本改在进程工作目录下暂存。系统临时目录在 macOS 上位于 /var/folders,Docker 虚拟机并不共享,挂载进容器后是空目录,真实技能执行 (脚本在 skills/ 下)却不会踩到,检测因此报假失败。 - 检测失败不再只说「命令输出与预期不符」,带上退出码与 stderr 首行。 前端把沙箱设置页与配置抽屉重做:凭据按「是否已配置」展示而非回显掩码, 删除与停用改为就地确认,占用情况走右侧抽屉,列表卡片展示模板状态、凭据、 超时等可判断健康度的事实。
2026-08-11 07:31:58 +00:00
"skills_available": true,
})
}