WeKnora/internal/application/service/tenant_skill_transcript.go

583 lines
18 KiB
Go
Raw Normal View History

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
package service
import (
"context"
"fmt"
perf(skills): batch install verification and live installer progress (#2960) * perf(skills): batch install verification and keep caches under budget The tail of an install (agent_done -> verified) issued one remote exec per check: two for permission normalisation, one per bundled script for the tree check, three for the scratch wipe. A skill with twenty scripts paid thirty- odd round trips, each carrying a hidden bootstrap exec and a distributed- lock resolve, while the console sat on a finished agent with no feedback. - normalizeSkillPermissions sends chmod and chown as one command. - verifySkillTree folds the SKILL.md probe and one test per script into a single command that reports every missing file instead of stopping at the first. Exit codes 0/1/3 carry the verdict, stderr lines are the final messages, and the two existing error texts survive verbatim. - cleanImageScratch merges the workspace reset, the directory restore and the cache pass into one command whose exit code is still owned by the strict workspace half. Package caches are no longer wiped wholesale: uv, npm and pnpm trim their own entries, and the pip/uv/npm/pnpm totals of both accounts are kept while under 256MB and wiped whole over it, so the next install resolves a previous download instead of the network. - The install prompt hands the agent absolute paths for uv, npm, pnpm, pip, python3 and node from the same one-command probe that used to ask only whether uv exists, so it neither burns a turn on `which` nor gambles on the shell PATH. Tests pin the new command shapes exactly, cover quoting of archive-chosen file names, assert the tree check stays one command regardless of script count, exercise the budget guard against a real shell, and keep the workspace-restore failure semantics intact. * fix(skills): credit a script's own sys.path bootstrap for shipped modules The python check resolved every import against the script's directory, its ancestors up to the skill root and the venv - and nothing else. A module the skill ships in a sibling subtree (lib/image_video.py, imported by scripts/generate.py) was invisible to that set, so a skill whose scripts bootstrap their own library directory was refused for a dependency no package provides, and the repair round that followed could not fix it either: it installs packages and is forbidden from editing the tree. One real install spent seven minutes discovering that, three LLM stream timeouts included. The verifier now scans what the tree ships and statically evaluates the sys.path.insert/append calls each script raises before its imports - the os.path and pathlib idioms, with variables tracked in source order. A bootstrap proven to raise the directory that provides the module turns the finding into a note; anything unprovable stays a refusal, now naming the shipped file instead of pretending a dependency is missing. The refusal is unrepairable on purpose: no installer round can fix a shipped module the import cannot reach. Tests pin the incident's exact shape, the pathlib idiom, and the guarantee that makes the evaluator safe: a vendored module still cannot satisfy an import unless the script's own bootstrap provably reaches it, and modules pip placed under .venv never count as shipped. * feat(skills): move the install progress bar while the installer works The progress card sat at the seeded 35% for the whole agent phase and only jumped at agent_done. Every tool call the transcript already sees now advances an asymptotic curve 35 + 44·(1 − e^(−k/12)): monotonic for any round count, converging below the agent_done anchor at 80, topping out around 75 even when max_iterations is exhausted. Each step publishes a one-line command summary (engine hint preferred, 80-rune cap) so the admin can see what the installer is doing. After the first round ends the activity progress is muted — verification and repair rounds own the stage anchors (80/82) from there, and a repair round's tool calls must not drag the bar back under them. * fix(skills): pin the installer agent's thinking mode off installerAgentConfig left AgentConfig.Thinking nil, which most providers read as "defer to the model's own default" — a thinking-capable model would reason on every ReAct round of an install, burning latency and completion tokens on what are short shell-command turns. Set an explicit false so every provider path (Qwen enable_thinking, Ollama think, LKEAP thinking type) receives a deterministic off instead of a default. * style(skills): gofmt tenant_skill_verify_python_test.go CI rejects aligned map keys in this table-driven test; gofmt drops the extra spaces. * docs(skills): drop the duplicated exit 1 line in the python verifier The shipped-module case was appended by repeating the whole exit 1 block instead of extending the existing one. --------- Co-authored-by: hailongzhao <hailongzhao@tencent.com>
2026-09-02 04:23:42 +00:00
"math"
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
"strings"
"sync"
"time"
"github.com/google/uuid"
agenttools "github.com/Tencent/WeKnora/internal/agent/tools"
"github.com/Tencent/WeKnora/internal/event"
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
)
// installTranscript records one installer conversation.
//
// It is the installer's counterpart to handler/session.AgentStreamHandler, not
// a copy of it: that type lives above the service layer (it needs the artifact
// collector), so importing it here would close an import cycle. The overlap is
// bounded on purpose — install mode registers only shell_exec, so the six
// events below are all an install can produce, and references, memories,
// reflection, tool approvals and MCP OAuth are unreachable.
//
// The event shapes deliberately mirror AgentStreamHandler's so the console can
// render an install with the same components it renders a chat turn with.
type installTranscript struct {
// ctx is the run's context, kept for logging and for writes that outlive
// the emitting goroutine. Every write here is best-effort.
ctx context.Context
bus *event.EventBus
streams interfaces.StreamManager
messages interfaces.MessageRepository
sessionID string
assistantMessageID string
mu sync.Mutex
message *types.Message
answers []*installAnswerSegment
starts map[string]time.Time
// closed guards the terminal event and the final write, both of which say
// "this install is over" and must be said once.
closed bool
// Totals accumulated across the run's engine turns, reported on the one
// terminal event Finish emits.
totalSteps int
totalDurationMs int64
perf(skills): batch install verification and live installer progress (#2960) * perf(skills): batch install verification and keep caches under budget The tail of an install (agent_done -> verified) issued one remote exec per check: two for permission normalisation, one per bundled script for the tree check, three for the scratch wipe. A skill with twenty scripts paid thirty- odd round trips, each carrying a hidden bootstrap exec and a distributed- lock resolve, while the console sat on a finished agent with no feedback. - normalizeSkillPermissions sends chmod and chown as one command. - verifySkillTree folds the SKILL.md probe and one test per script into a single command that reports every missing file instead of stopping at the first. Exit codes 0/1/3 carry the verdict, stderr lines are the final messages, and the two existing error texts survive verbatim. - cleanImageScratch merges the workspace reset, the directory restore and the cache pass into one command whose exit code is still owned by the strict workspace half. Package caches are no longer wiped wholesale: uv, npm and pnpm trim their own entries, and the pip/uv/npm/pnpm totals of both accounts are kept while under 256MB and wiped whole over it, so the next install resolves a previous download instead of the network. - The install prompt hands the agent absolute paths for uv, npm, pnpm, pip, python3 and node from the same one-command probe that used to ask only whether uv exists, so it neither burns a turn on `which` nor gambles on the shell PATH. Tests pin the new command shapes exactly, cover quoting of archive-chosen file names, assert the tree check stays one command regardless of script count, exercise the budget guard against a real shell, and keep the workspace-restore failure semantics intact. * fix(skills): credit a script's own sys.path bootstrap for shipped modules The python check resolved every import against the script's directory, its ancestors up to the skill root and the venv - and nothing else. A module the skill ships in a sibling subtree (lib/image_video.py, imported by scripts/generate.py) was invisible to that set, so a skill whose scripts bootstrap their own library directory was refused for a dependency no package provides, and the repair round that followed could not fix it either: it installs packages and is forbidden from editing the tree. One real install spent seven minutes discovering that, three LLM stream timeouts included. The verifier now scans what the tree ships and statically evaluates the sys.path.insert/append calls each script raises before its imports - the os.path and pathlib idioms, with variables tracked in source order. A bootstrap proven to raise the directory that provides the module turns the finding into a note; anything unprovable stays a refusal, now naming the shipped file instead of pretending a dependency is missing. The refusal is unrepairable on purpose: no installer round can fix a shipped module the import cannot reach. Tests pin the incident's exact shape, the pathlib idiom, and the guarantee that makes the evaluator safe: a vendored module still cannot satisfy an import unless the script's own bootstrap provably reaches it, and modules pip placed under .venv never count as shipped. * feat(skills): move the install progress bar while the installer works The progress card sat at the seeded 35% for the whole agent phase and only jumped at agent_done. Every tool call the transcript already sees now advances an asymptotic curve 35 + 44·(1 − e^(−k/12)): monotonic for any round count, converging below the agent_done anchor at 80, topping out around 75 even when max_iterations is exhausted. Each step publishes a one-line command summary (engine hint preferred, 80-rune cap) so the admin can see what the installer is doing. After the first round ends the activity progress is muted — verification and repair rounds own the stage anchors (80/82) from there, and a repair round's tool calls must not drag the bar back under them. * fix(skills): pin the installer agent's thinking mode off installerAgentConfig left AgentConfig.Thinking nil, which most providers read as "defer to the model's own default" — a thinking-capable model would reason on every ReAct round of an install, burning latency and completion tokens on what are short shell-command turns. Set an explicit false so every provider path (Qwen enable_thinking, Ollama think, LKEAP thinking type) receives a deterministic off instead of a default. * style(skills): gofmt tenant_skill_verify_python_test.go CI rejects aligned map keys in this table-driven test; gofmt drops the extra spaces. * docs(skills): drop the duplicated exit 1 line in the python verifier The shipped-module case was appended by repeating the whole exit 1 block instead of extending the existing one. --------- Co-authored-by: hailongzhao <hailongzhao@tencent.com>
2026-09-02 04:23:42 +00:00
// Activity progress fills the long stretch between the seeded anchor (35%)
// and agent_done (80%) while the installer is actually working. Every tool
// call the bus already delivers advances an asymptotic percent, so the bar
// moves without knowing how many rounds the agent will run. onActivity is
// wired only by the install path; the remove path and most tests leave it
// nil and nothing publishes.
onActivity func(steps int, lastCmd string)
toolCalls int
progressMuted bool
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
}
// installAnswerSegment accumulates the prose streamed under one final-answer
// event ID.
//
// The engine has no separate channel for a round's commentary: "the venv is
// missing, so I'll create it" arrives as a final-answer chunk exactly like the
// closing summary does. An install runs dozens of rounds, so keeping every
// chunk would persist dozens of preambles glued end to end. A round that goes
// on to call a tool was, by definition, not the last one, so its prose is
// retracted when that call arrives and only the round that ends the run
// survives as the answer.
type installAnswerSegment struct {
id string
content string
superseded bool
}
func newInstallTranscript(
ctx context.Context,
bus *event.EventBus,
streams interfaces.StreamManager,
messages interfaces.MessageRepository,
sessionID, assistantMessageID string,
perf(skills): batch install verification and live installer progress (#2960) * perf(skills): batch install verification and keep caches under budget The tail of an install (agent_done -> verified) issued one remote exec per check: two for permission normalisation, one per bundled script for the tree check, three for the scratch wipe. A skill with twenty scripts paid thirty- odd round trips, each carrying a hidden bootstrap exec and a distributed- lock resolve, while the console sat on a finished agent with no feedback. - normalizeSkillPermissions sends chmod and chown as one command. - verifySkillTree folds the SKILL.md probe and one test per script into a single command that reports every missing file instead of stopping at the first. Exit codes 0/1/3 carry the verdict, stderr lines are the final messages, and the two existing error texts survive verbatim. - cleanImageScratch merges the workspace reset, the directory restore and the cache pass into one command whose exit code is still owned by the strict workspace half. Package caches are no longer wiped wholesale: uv, npm and pnpm trim their own entries, and the pip/uv/npm/pnpm totals of both accounts are kept while under 256MB and wiped whole over it, so the next install resolves a previous download instead of the network. - The install prompt hands the agent absolute paths for uv, npm, pnpm, pip, python3 and node from the same one-command probe that used to ask only whether uv exists, so it neither burns a turn on `which` nor gambles on the shell PATH. Tests pin the new command shapes exactly, cover quoting of archive-chosen file names, assert the tree check stays one command regardless of script count, exercise the budget guard against a real shell, and keep the workspace-restore failure semantics intact. * fix(skills): credit a script's own sys.path bootstrap for shipped modules The python check resolved every import against the script's directory, its ancestors up to the skill root and the venv - and nothing else. A module the skill ships in a sibling subtree (lib/image_video.py, imported by scripts/generate.py) was invisible to that set, so a skill whose scripts bootstrap their own library directory was refused for a dependency no package provides, and the repair round that followed could not fix it either: it installs packages and is forbidden from editing the tree. One real install spent seven minutes discovering that, three LLM stream timeouts included. The verifier now scans what the tree ships and statically evaluates the sys.path.insert/append calls each script raises before its imports - the os.path and pathlib idioms, with variables tracked in source order. A bootstrap proven to raise the directory that provides the module turns the finding into a note; anything unprovable stays a refusal, now naming the shipped file instead of pretending a dependency is missing. The refusal is unrepairable on purpose: no installer round can fix a shipped module the import cannot reach. Tests pin the incident's exact shape, the pathlib idiom, and the guarantee that makes the evaluator safe: a vendored module still cannot satisfy an import unless the script's own bootstrap provably reaches it, and modules pip placed under .venv never count as shipped. * feat(skills): move the install progress bar while the installer works The progress card sat at the seeded 35% for the whole agent phase and only jumped at agent_done. Every tool call the transcript already sees now advances an asymptotic curve 35 + 44·(1 − e^(−k/12)): monotonic for any round count, converging below the agent_done anchor at 80, topping out around 75 even when max_iterations is exhausted. Each step publishes a one-line command summary (engine hint preferred, 80-rune cap) so the admin can see what the installer is doing. After the first round ends the activity progress is muted — verification and repair rounds own the stage anchors (80/82) from there, and a repair round's tool calls must not drag the bar back under them. * fix(skills): pin the installer agent's thinking mode off installerAgentConfig left AgentConfig.Thinking nil, which most providers read as "defer to the model's own default" — a thinking-capable model would reason on every ReAct round of an install, burning latency and completion tokens on what are short shell-command turns. Set an explicit false so every provider path (Qwen enable_thinking, Ollama think, LKEAP thinking type) receives a deterministic off instead of a default. * style(skills): gofmt tenant_skill_verify_python_test.go CI rejects aligned map keys in this table-driven test; gofmt drops the extra spaces. * docs(skills): drop the duplicated exit 1 line in the python verifier The shipped-module case was appended by repeating the whole exit 1 block instead of extending the existing one. --------- Co-authored-by: hailongzhao <hailongzhao@tencent.com>
2026-09-02 04:23:42 +00:00
onActivity func(steps int, lastCmd string),
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
) *installTranscript {
return &installTranscript{
ctx: ctx,
bus: bus,
streams: streams,
messages: messages,
sessionID: sessionID,
assistantMessageID: assistantMessageID,
starts: map[string]time.Time{},
perf(skills): batch install verification and live installer progress (#2960) * perf(skills): batch install verification and keep caches under budget The tail of an install (agent_done -> verified) issued one remote exec per check: two for permission normalisation, one per bundled script for the tree check, three for the scratch wipe. A skill with twenty scripts paid thirty- odd round trips, each carrying a hidden bootstrap exec and a distributed- lock resolve, while the console sat on a finished agent with no feedback. - normalizeSkillPermissions sends chmod and chown as one command. - verifySkillTree folds the SKILL.md probe and one test per script into a single command that reports every missing file instead of stopping at the first. Exit codes 0/1/3 carry the verdict, stderr lines are the final messages, and the two existing error texts survive verbatim. - cleanImageScratch merges the workspace reset, the directory restore and the cache pass into one command whose exit code is still owned by the strict workspace half. Package caches are no longer wiped wholesale: uv, npm and pnpm trim their own entries, and the pip/uv/npm/pnpm totals of both accounts are kept while under 256MB and wiped whole over it, so the next install resolves a previous download instead of the network. - The install prompt hands the agent absolute paths for uv, npm, pnpm, pip, python3 and node from the same one-command probe that used to ask only whether uv exists, so it neither burns a turn on `which` nor gambles on the shell PATH. Tests pin the new command shapes exactly, cover quoting of archive-chosen file names, assert the tree check stays one command regardless of script count, exercise the budget guard against a real shell, and keep the workspace-restore failure semantics intact. * fix(skills): credit a script's own sys.path bootstrap for shipped modules The python check resolved every import against the script's directory, its ancestors up to the skill root and the venv - and nothing else. A module the skill ships in a sibling subtree (lib/image_video.py, imported by scripts/generate.py) was invisible to that set, so a skill whose scripts bootstrap their own library directory was refused for a dependency no package provides, and the repair round that followed could not fix it either: it installs packages and is forbidden from editing the tree. One real install spent seven minutes discovering that, three LLM stream timeouts included. The verifier now scans what the tree ships and statically evaluates the sys.path.insert/append calls each script raises before its imports - the os.path and pathlib idioms, with variables tracked in source order. A bootstrap proven to raise the directory that provides the module turns the finding into a note; anything unprovable stays a refusal, now naming the shipped file instead of pretending a dependency is missing. The refusal is unrepairable on purpose: no installer round can fix a shipped module the import cannot reach. Tests pin the incident's exact shape, the pathlib idiom, and the guarantee that makes the evaluator safe: a vendored module still cannot satisfy an import unless the script's own bootstrap provably reaches it, and modules pip placed under .venv never count as shipped. * feat(skills): move the install progress bar while the installer works The progress card sat at the seeded 35% for the whole agent phase and only jumped at agent_done. Every tool call the transcript already sees now advances an asymptotic curve 35 + 44·(1 − e^(−k/12)): monotonic for any round count, converging below the agent_done anchor at 80, topping out around 75 even when max_iterations is exhausted. Each step publishes a one-line command summary (engine hint preferred, 80-rune cap) so the admin can see what the installer is doing. After the first round ends the activity progress is muted — verification and repair rounds own the stage anchors (80/82) from there, and a repair round's tool calls must not drag the bar back under them. * fix(skills): pin the installer agent's thinking mode off installerAgentConfig left AgentConfig.Thinking nil, which most providers read as "defer to the model's own default" — a thinking-capable model would reason on every ReAct round of an install, burning latency and completion tokens on what are short shell-command turns. Set an explicit false so every provider path (Qwen enable_thinking, Ollama think, LKEAP thinking type) receives a deterministic off instead of a default. * style(skills): gofmt tenant_skill_verify_python_test.go CI rejects aligned map keys in this table-driven test; gofmt drops the extra spaces. * docs(skills): drop the duplicated exit 1 line in the python verifier The shipped-module case was appended by repeating the whole exit 1 block instead of extending the existing one. --------- Co-authored-by: hailongzhao <hailongzhao@tencent.com>
2026-09-02 04:23:42 +00:00
onActivity: onActivity,
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
}
}
// Create writes the two rows the conversation needs before the engine starts.
//
// The assistant row cannot wait until the run ends: /sessions/continue-stream
// validates the message before it opens the stream, so a console that attaches
// while the install is running would be refused.
func (tr *installTranscript) Create(ctx context.Context, prompt string) error {
if tr == nil || tr.messages == nil {
return nil
}
now := time.Now()
if _, err := tr.messages.CreateMessage(ctx, &types.Message{
ID: uuid.NewString(),
SessionID: tr.sessionID,
Role: "user",
Content: prompt,
IsCompleted: true,
CreatedAt: now,
UpdatedAt: now,
}); err != nil {
return fmt.Errorf("create installer prompt message: %w", err)
}
assistant := &types.Message{
ID: tr.assistantMessageID,
SessionID: tr.sessionID,
Role: "assistant",
CreatedAt: now.Add(time.Millisecond),
UpdatedAt: now.Add(time.Millisecond),
}
if _, err := tr.messages.CreateMessage(ctx, assistant); err != nil {
return fmt.Errorf("create installer answer message: %w", err)
}
tr.mu.Lock()
tr.message = assistant
tr.mu.Unlock()
// The prompt goes into the event log too, ahead of everything the agent
// does, so one replay of the log is the whole conversation. Without it a
// console following a running install would show the agent's side of a
// conversation whose opening line it cannot see.
tr.append(interfaces.StreamEvent{
ID: uuid.NewString(),
Type: types.ResponseTypeInstallPrompt,
Content: prompt,
Done: true,
Timestamp: now,
Data: map[string]interface{}{},
})
return nil
}
// Subscribe wires the six events an install can produce.
func (tr *installTranscript) Subscribe() {
if tr == nil || tr.bus == nil {
return
}
tr.bus.On(event.EventAgentThought, tr.onThought)
tr.bus.On(event.EventAgentToolCall, tr.onToolCall)
tr.bus.On(event.EventAgentCommandOutput, tr.onInstallOutput)
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
tr.bus.On(event.EventAgentToolResult, tr.onToolResult)
tr.bus.On(event.EventAgentFinalAnswer, tr.onAnswer)
tr.bus.On(event.EventError, tr.onError)
tr.bus.On(event.EventAgentComplete, tr.onComplete)
}
// Finish closes the record. runErr is the install's verdict, not just the
// engine's: verification runs after the agent stops, and a failure there is the
// one people actually come to read, so it is written here rather than hoped for.
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
func (tr *installTranscript) Finish(ctx context.Context, runErr error) {
if tr == nil {
return
}
tr.mu.Lock()
alreadyClosed := tr.closed
tr.closed = true
tr.mu.Unlock()
if alreadyClosed {
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
if runErr != nil {
tr.append(interfaces.StreamEvent{
ID: uuid.NewString(),
Type: types.ResponseTypeError,
Content: runErr.Error(),
Done: true,
Timestamp: time.Now(),
Data: map[string]interface{}{
"stage": "install",
"error": runErr.Error(),
},
})
tr.mu.Lock()
// The verdict is never a preamble, so it gets its own segment that no
// later call can retract.
failure := tr.segmentLocked("install-failure")
if prose := tr.composeAnswerLocked(); prose != "" {
failure.content = "\n\n"
}
failure.content += runErr.Error()
tr.mu.Unlock()
}
tr.mu.Lock()
steps, duration := tr.totalSteps, tr.totalDurationMs
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
tr.mu.Unlock()
tr.append(interfaces.StreamEvent{
ID: uuid.NewString(),
Type: types.ResponseTypeComplete,
Done: true,
Timestamp: time.Now(),
Data: map[string]interface{}{
"total_steps": steps,
"total_duration_ms": duration,
},
})
tr.save(ctx)
}
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
// RecordPrompt logs a follow-up instruction the installer was given mid-run.
//
// The transcript exists so one replay of the event log is the whole
// conversation. A repair round whose instruction is missing reads as the agent
// spontaneously deciding to install more packages, which is precisely the
// moment someone is reading this to find out why.
func (tr *installTranscript) RecordPrompt(prompt string) {
if tr == nil {
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
}
tr.append(interfaces.StreamEvent{
ID: uuid.NewString(),
Type: types.ResponseTypeInstallPrompt,
Content: prompt,
Done: true,
Timestamp: time.Now(),
Data: map[string]interface{}{},
})
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
}
func (tr *installTranscript) onThought(_ context.Context, evt event.Event) error {
data, ok := evt.Data.(event.AgentThoughtData)
if !ok {
return nil
}
tr.append(interfaces.StreamEvent{
ID: evt.ID,
Type: types.ResponseTypeThinking,
Content: data.Content,
Done: data.Done,
Timestamp: time.Now(),
Data: tr.spanMeta(evt.ID, data.Done),
})
return nil
}
func (tr *installTranscript) onToolCall(_ context.Context, evt event.Event) error {
data, ok := evt.Data.(event.AgentToolCallData)
if !ok {
return nil
}
tr.mu.Lock()
_, seen := tr.starts[data.ToolCallID]
if seen {
tr.mu.Unlock()
return nil
}
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
tr.starts[data.ToolCallID] = time.Now()
// This round called a tool, so it is not the round that ends the run: any
// prose it streamed was a preamble and must not reach Message.Content.
for _, seg := range tr.answers {
if !seg.superseded && seg.content != "" {
seg.superseded = true
}
}
perf(skills): batch install verification and live installer progress (#2960) * perf(skills): batch install verification and keep caches under budget The tail of an install (agent_done -> verified) issued one remote exec per check: two for permission normalisation, one per bundled script for the tree check, three for the scratch wipe. A skill with twenty scripts paid thirty- odd round trips, each carrying a hidden bootstrap exec and a distributed- lock resolve, while the console sat on a finished agent with no feedback. - normalizeSkillPermissions sends chmod and chown as one command. - verifySkillTree folds the SKILL.md probe and one test per script into a single command that reports every missing file instead of stopping at the first. Exit codes 0/1/3 carry the verdict, stderr lines are the final messages, and the two existing error texts survive verbatim. - cleanImageScratch merges the workspace reset, the directory restore and the cache pass into one command whose exit code is still owned by the strict workspace half. Package caches are no longer wiped wholesale: uv, npm and pnpm trim their own entries, and the pip/uv/npm/pnpm totals of both accounts are kept while under 256MB and wiped whole over it, so the next install resolves a previous download instead of the network. - The install prompt hands the agent absolute paths for uv, npm, pnpm, pip, python3 and node from the same one-command probe that used to ask only whether uv exists, so it neither burns a turn on `which` nor gambles on the shell PATH. Tests pin the new command shapes exactly, cover quoting of archive-chosen file names, assert the tree check stays one command regardless of script count, exercise the budget guard against a real shell, and keep the workspace-restore failure semantics intact. * fix(skills): credit a script's own sys.path bootstrap for shipped modules The python check resolved every import against the script's directory, its ancestors up to the skill root and the venv - and nothing else. A module the skill ships in a sibling subtree (lib/image_video.py, imported by scripts/generate.py) was invisible to that set, so a skill whose scripts bootstrap their own library directory was refused for a dependency no package provides, and the repair round that followed could not fix it either: it installs packages and is forbidden from editing the tree. One real install spent seven minutes discovering that, three LLM stream timeouts included. The verifier now scans what the tree ships and statically evaluates the sys.path.insert/append calls each script raises before its imports - the os.path and pathlib idioms, with variables tracked in source order. A bootstrap proven to raise the directory that provides the module turns the finding into a note; anything unprovable stays a refusal, now naming the shipped file instead of pretending a dependency is missing. The refusal is unrepairable on purpose: no installer round can fix a shipped module the import cannot reach. Tests pin the incident's exact shape, the pathlib idiom, and the guarantee that makes the evaluator safe: a vendored module still cannot satisfy an import unless the script's own bootstrap provably reaches it, and modules pip placed under .venv never count as shipped. * feat(skills): move the install progress bar while the installer works The progress card sat at the seeded 35% for the whole agent phase and only jumped at agent_done. Every tool call the transcript already sees now advances an asymptotic curve 35 + 44·(1 − e^(−k/12)): monotonic for any round count, converging below the agent_done anchor at 80, topping out around 75 even when max_iterations is exhausted. Each step publishes a one-line command summary (engine hint preferred, 80-rune cap) so the admin can see what the installer is doing. After the first round ends the activity progress is muted — verification and repair rounds own the stage anchors (80/82) from there, and a repair round's tool calls must not drag the bar back under them. * fix(skills): pin the installer agent's thinking mode off installerAgentConfig left AgentConfig.Thinking nil, which most providers read as "defer to the model's own default" — a thinking-capable model would reason on every ReAct round of an install, burning latency and completion tokens on what are short shell-command turns. Set an explicit false so every provider path (Qwen enable_thinking, Ollama think, LKEAP thinking type) receives a deterministic off instead of a default. * style(skills): gofmt tenant_skill_verify_python_test.go CI rejects aligned map keys in this table-driven test; gofmt drops the extra spaces. * docs(skills): drop the duplicated exit 1 line in the python verifier The shipped-module case was appended by repeating the whole exit 1 block instead of extending the existing one. --------- Co-authored-by: hailongzhao <hailongzhao@tencent.com>
2026-09-02 04:23:42 +00:00
// One command is one step of the asymptotic progress. Muted runs (after
// the first round ends) stop counting so a repair round cannot drag the
// bar back under the stage anchors that govern it by then.
steps, lastCmd := 0, ""
if !tr.progressMuted {
tr.toolCalls++
steps, lastCmd = tr.toolCalls, installToolCallSummary(data)
}
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
tr.mu.Unlock()
tr.append(interfaces.StreamEvent{
ID: evt.ID,
Type: types.ResponseTypeToolCall,
Content: fmt.Sprintf("Calling tool: %s", data.ToolName),
Timestamp: time.Now(),
Data: map[string]interface{}{
"tool_name": data.ToolName,
"arguments": data.Arguments,
"tool_call_id": data.ToolCallID,
},
})
perf(skills): batch install verification and live installer progress (#2960) * perf(skills): batch install verification and keep caches under budget The tail of an install (agent_done -> verified) issued one remote exec per check: two for permission normalisation, one per bundled script for the tree check, three for the scratch wipe. A skill with twenty scripts paid thirty- odd round trips, each carrying a hidden bootstrap exec and a distributed- lock resolve, while the console sat on a finished agent with no feedback. - normalizeSkillPermissions sends chmod and chown as one command. - verifySkillTree folds the SKILL.md probe and one test per script into a single command that reports every missing file instead of stopping at the first. Exit codes 0/1/3 carry the verdict, stderr lines are the final messages, and the two existing error texts survive verbatim. - cleanImageScratch merges the workspace reset, the directory restore and the cache pass into one command whose exit code is still owned by the strict workspace half. Package caches are no longer wiped wholesale: uv, npm and pnpm trim their own entries, and the pip/uv/npm/pnpm totals of both accounts are kept while under 256MB and wiped whole over it, so the next install resolves a previous download instead of the network. - The install prompt hands the agent absolute paths for uv, npm, pnpm, pip, python3 and node from the same one-command probe that used to ask only whether uv exists, so it neither burns a turn on `which` nor gambles on the shell PATH. Tests pin the new command shapes exactly, cover quoting of archive-chosen file names, assert the tree check stays one command regardless of script count, exercise the budget guard against a real shell, and keep the workspace-restore failure semantics intact. * fix(skills): credit a script's own sys.path bootstrap for shipped modules The python check resolved every import against the script's directory, its ancestors up to the skill root and the venv - and nothing else. A module the skill ships in a sibling subtree (lib/image_video.py, imported by scripts/generate.py) was invisible to that set, so a skill whose scripts bootstrap their own library directory was refused for a dependency no package provides, and the repair round that followed could not fix it either: it installs packages and is forbidden from editing the tree. One real install spent seven minutes discovering that, three LLM stream timeouts included. The verifier now scans what the tree ships and statically evaluates the sys.path.insert/append calls each script raises before its imports - the os.path and pathlib idioms, with variables tracked in source order. A bootstrap proven to raise the directory that provides the module turns the finding into a note; anything unprovable stays a refusal, now naming the shipped file instead of pretending a dependency is missing. The refusal is unrepairable on purpose: no installer round can fix a shipped module the import cannot reach. Tests pin the incident's exact shape, the pathlib idiom, and the guarantee that makes the evaluator safe: a vendored module still cannot satisfy an import unless the script's own bootstrap provably reaches it, and modules pip placed under .venv never count as shipped. * feat(skills): move the install progress bar while the installer works The progress card sat at the seeded 35% for the whole agent phase and only jumped at agent_done. Every tool call the transcript already sees now advances an asymptotic curve 35 + 44·(1 − e^(−k/12)): monotonic for any round count, converging below the agent_done anchor at 80, topping out around 75 even when max_iterations is exhausted. Each step publishes a one-line command summary (engine hint preferred, 80-rune cap) so the admin can see what the installer is doing. After the first round ends the activity progress is muted — verification and repair rounds own the stage anchors (80/82) from there, and a repair round's tool calls must not drag the bar back under them. * fix(skills): pin the installer agent's thinking mode off installerAgentConfig left AgentConfig.Thinking nil, which most providers read as "defer to the model's own default" — a thinking-capable model would reason on every ReAct round of an install, burning latency and completion tokens on what are short shell-command turns. Set an explicit false so every provider path (Qwen enable_thinking, Ollama think, LKEAP thinking type) receives a deterministic off instead of a default. * style(skills): gofmt tenant_skill_verify_python_test.go CI rejects aligned map keys in this table-driven test; gofmt drops the extra spaces. * docs(skills): drop the duplicated exit 1 line in the python verifier The shipped-module case was appended by repeating the whole exit 1 block instead of extending the existing one. --------- Co-authored-by: hailongzhao <hailongzhao@tencent.com>
2026-09-02 04:23:42 +00:00
if steps > 0 && tr.onActivity != nil {
tr.onActivity(steps, lastCmd)
}
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
return nil
}
func (tr *installTranscript) onToolResult(_ context.Context, evt event.Event) error {
data, ok := evt.Data.(event.AgentToolResultData)
if !ok {
return nil
}
tr.mu.Lock()
durationMs := data.Duration
if start, ok := tr.starts[data.ToolCallID]; ok {
durationMs = time.Since(start).Milliseconds()
delete(tr.starts, data.ToolCallID)
}
tr.mu.Unlock()
// A failed command is still a tool result: response_type=error is reserved
// for internal failures (onError), matching the chat path. Failure is
// carried by success=false in the metadata.
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
responseType := types.ResponseTypeToolResult
content := agenttools.StreamContentForToolResult(data.ToolName, data.Success, data.Error, data.Data)
if !data.Success && content == "" && data.Error != "" {
content = data.Error
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
}
meta := map[string]interface{}{
"tool_name": data.ToolName,
"success": data.Success,
"error": data.Error,
"duration_ms": durationMs,
"tool_call_id": data.ToolCallID,
}
for k, v := range agenttools.SanitizeToolResultForClient(data.ToolName, &types.ToolResult{
Success: data.Success,
Output: data.Output,
Error: data.Error,
Data: data.Data,
}) {
meta[k] = v
}
tr.append(interfaces.StreamEvent{
ID: evt.ID,
Type: responseType,
Content: content,
Timestamp: time.Now(),
Data: meta,
})
return nil
}
func (tr *installTranscript) onAnswer(_ context.Context, evt event.Event) error {
data, ok := evt.Data.(event.AgentFinalAnswerData)
if !ok {
return nil
}
tr.mu.Lock()
if data.Content != "" {
tr.segmentLocked(evt.ID).content += data.Content
}
tr.mu.Unlock()
tr.append(interfaces.StreamEvent{
ID: evt.ID,
Type: types.ResponseTypeAnswer,
Content: data.Content,
Done: data.Done,
Timestamp: time.Now(),
Data: tr.spanMeta(evt.ID, data.Done),
})
return nil
}
func (tr *installTranscript) onError(_ context.Context, evt event.Event) error {
data, ok := evt.Data.(event.ErrorData)
if !ok {
return nil
}
tr.append(interfaces.StreamEvent{
ID: evt.ID,
Type: types.ResponseTypeError,
Content: data.Error,
Done: true,
Timestamp: time.Now(),
Data: map[string]interface{}{
"stage": data.Stage,
"error": data.Error,
},
})
return nil
}
// onComplete records what the round finished with. It deliberately emits no
// terminal event: an install may run another installer round after
// verification, and a console that saw "complete" would stop following before
// that round began. Only Finish closes the stream.
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
func (tr *installTranscript) onComplete(_ context.Context, evt event.Event) error {
data, ok := evt.Data.(event.AgentCompleteData)
if !ok {
return nil
}
tr.mu.Lock()
if data.MessageID == tr.assistantMessageID {
msg := tr.ensureMessageLocked()
msg.IsCompleted = true
msg.AgentDurationMs = data.TotalDurationMs
if steps, ok := data.AgentSteps.([]types.AgentStep); ok {
msg.AgentSteps = agenttools.SanitizeAgentStepsForStorage(steps)
}
}
// The engine may finish without ever streaming an answer chunk (it stops
// naturally with plain text). Take the summary from the completion payload
// so the transcript is not left with an empty final message.
if tr.composeAnswerLocked() == "" && data.FinalAnswer != "" {
tr.segmentLocked(evt.ID).content = data.FinalAnswer
}
// Summed rather than overwritten: an install that needed a repair round ran
// two engine turns, and its cost is both of them.
tr.totalSteps += data.TotalSteps
tr.totalDurationMs += data.TotalDurationMs
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
tr.mu.Unlock()
return nil
}
// spanMeta mirrors the chat path's per-chunk metadata so the console can group
// chunks by event ID and show a duration once the span closes.
func (tr *installTranscript) spanMeta(eventID string, done bool) map[string]interface{} {
tr.mu.Lock()
defer tr.mu.Unlock()
if _, ok := tr.starts[eventID]; !ok {
tr.starts[eventID] = time.Now()
}
if !done {
return map[string]interface{}{"event_id": eventID}
}
start := tr.starts[eventID]
delete(tr.starts, eventID)
return map[string]interface{}{
"event_id": eventID,
"duration_ms": time.Since(start).Milliseconds(),
"completed_at": time.Now().Unix(),
}
}
// segmentLocked returns the segment accumulating an answer event ID, creating
// it on first sight. Callers must hold tr.mu.
func (tr *installTranscript) segmentLocked(id string) *installAnswerSegment {
for _, seg := range tr.answers {
if seg.id == id {
return seg
}
}
seg := &installAnswerSegment{id: id}
tr.answers = append(tr.answers, seg)
return seg
}
// composeAnswerLocked rebuilds the answer from the segments no tool call
// retracted, in arrival order. Callers must hold tr.mu.
func (tr *installTranscript) composeAnswerLocked() string {
var b strings.Builder
for _, seg := range tr.answers {
if !seg.superseded {
b.WriteString(seg.content)
}
}
return b.String()
}
func (tr *installTranscript) append(evt interfaces.StreamEvent) {
if tr.streams == nil {
return
}
if err := tr.streams.AppendEvent(tr.ctx, tr.sessionID, tr.assistantMessageID, evt); err != nil {
logger.Warnf(tr.ctx, "[skill] append %s to install transcript %s failed: %v",
evt.Type, tr.sessionID, err)
}
}
// ensureMessageLocked returns the assistant row being accumulated, creating the
// in-memory shell if Create never ran (a transcript whose seeding failed still
// records what it can). Callers must hold tr.mu.
func (tr *installTranscript) ensureMessageLocked() *types.Message {
if tr.message == nil {
tr.message = &types.Message{
ID: tr.assistantMessageID,
SessionID: tr.sessionID,
Role: "assistant",
CreatedAt: time.Now(),
}
}
return tr.message
}
func (tr *installTranscript) save(ctx context.Context) {
if tr.messages == nil {
return
}
tr.mu.Lock()
msg := tr.ensureMessageLocked()
msg.Content = tr.composeAnswerLocked()
msg.IsCompleted = true
msg.UpdatedAt = time.Now()
tr.mu.Unlock()
if err := tr.messages.UpdateMessage(ctx, msg); err != nil {
logger.Warnf(ctx, "[skill] persist install transcript %s failed: %v", tr.sessionID, err)
}
}
perf(skills): batch install verification and live installer progress (#2960) * perf(skills): batch install verification and keep caches under budget The tail of an install (agent_done -> verified) issued one remote exec per check: two for permission normalisation, one per bundled script for the tree check, three for the scratch wipe. A skill with twenty scripts paid thirty- odd round trips, each carrying a hidden bootstrap exec and a distributed- lock resolve, while the console sat on a finished agent with no feedback. - normalizeSkillPermissions sends chmod and chown as one command. - verifySkillTree folds the SKILL.md probe and one test per script into a single command that reports every missing file instead of stopping at the first. Exit codes 0/1/3 carry the verdict, stderr lines are the final messages, and the two existing error texts survive verbatim. - cleanImageScratch merges the workspace reset, the directory restore and the cache pass into one command whose exit code is still owned by the strict workspace half. Package caches are no longer wiped wholesale: uv, npm and pnpm trim their own entries, and the pip/uv/npm/pnpm totals of both accounts are kept while under 256MB and wiped whole over it, so the next install resolves a previous download instead of the network. - The install prompt hands the agent absolute paths for uv, npm, pnpm, pip, python3 and node from the same one-command probe that used to ask only whether uv exists, so it neither burns a turn on `which` nor gambles on the shell PATH. Tests pin the new command shapes exactly, cover quoting of archive-chosen file names, assert the tree check stays one command regardless of script count, exercise the budget guard against a real shell, and keep the workspace-restore failure semantics intact. * fix(skills): credit a script's own sys.path bootstrap for shipped modules The python check resolved every import against the script's directory, its ancestors up to the skill root and the venv - and nothing else. A module the skill ships in a sibling subtree (lib/image_video.py, imported by scripts/generate.py) was invisible to that set, so a skill whose scripts bootstrap their own library directory was refused for a dependency no package provides, and the repair round that followed could not fix it either: it installs packages and is forbidden from editing the tree. One real install spent seven minutes discovering that, three LLM stream timeouts included. The verifier now scans what the tree ships and statically evaluates the sys.path.insert/append calls each script raises before its imports - the os.path and pathlib idioms, with variables tracked in source order. A bootstrap proven to raise the directory that provides the module turns the finding into a note; anything unprovable stays a refusal, now naming the shipped file instead of pretending a dependency is missing. The refusal is unrepairable on purpose: no installer round can fix a shipped module the import cannot reach. Tests pin the incident's exact shape, the pathlib idiom, and the guarantee that makes the evaluator safe: a vendored module still cannot satisfy an import unless the script's own bootstrap provably reaches it, and modules pip placed under .venv never count as shipped. * feat(skills): move the install progress bar while the installer works The progress card sat at the seeded 35% for the whole agent phase and only jumped at agent_done. Every tool call the transcript already sees now advances an asymptotic curve 35 + 44·(1 − e^(−k/12)): monotonic for any round count, converging below the agent_done anchor at 80, topping out around 75 even when max_iterations is exhausted. Each step publishes a one-line command summary (engine hint preferred, 80-rune cap) so the admin can see what the installer is doing. After the first round ends the activity progress is muted — verification and repair rounds own the stage anchors (80/82) from there, and a repair round's tool calls must not drag the bar back under them. * fix(skills): pin the installer agent's thinking mode off installerAgentConfig left AgentConfig.Thinking nil, which most providers read as "defer to the model's own default" — a thinking-capable model would reason on every ReAct round of an install, burning latency and completion tokens on what are short shell-command turns. Set an explicit false so every provider path (Qwen enable_thinking, Ollama think, LKEAP thinking type) receives a deterministic off instead of a default. * style(skills): gofmt tenant_skill_verify_python_test.go CI rejects aligned map keys in this table-driven test; gofmt drops the extra spaces. * docs(skills): drop the duplicated exit 1 line in the python verifier The shipped-module case was appended by repeating the whole exit 1 block instead of extending the existing one. --------- Co-authored-by: hailongzhao <hailongzhao@tencent.com>
2026-09-02 04:23:42 +00:00
// progressLogMaxRunes caps the one-line command summary the progress card
// shows. The card is one line tall; a heredoc would flatten it.
const progressLogMaxRunes = 80
// installToolCallSummary condenses one tool call into the one-line log the
// progress card shows. The engine's own hint (e.g. `shell_exec: uv venv
// .venv`) is preferred when it has one; otherwise the shell command is used.
func installToolCallSummary(data event.AgentToolCallData) string {
summary := strings.TrimSpace(data.Hint)
if summary == "" {
if cmd, ok := data.Arguments["command"].(string); ok && strings.TrimSpace(cmd) != "" {
summary = fmt.Sprintf("%s: %s", data.ToolName, strings.TrimSpace(cmd))
} else {
summary = data.ToolName
}
}
summary = strings.ReplaceAll(summary, "\n", " ")
if runes := []rune(summary); len(runes) > progressLogMaxRunes {
summary = string(runes[:progressLogMaxRunes]) + "…"
}
return summary
}
// muteActivityProgress stops the asymptotic progress wherever it has reached.
// Called once the first installer round ends: everything after it —
// verification and any repair rounds — is covered by the explicit stage
// anchors (agent_done 80, repairing 82), and tool calls from a repair round
// publishing again would drag the bar back below those anchors.
func (tr *installTranscript) muteActivityProgress() {
if tr == nil {
return
}
tr.mu.Lock()
tr.progressMuted = true
tr.mu.Unlock()
}
// asymptoticInstallPercent fills the 35→79 span with no knowledge of the
// total: each command advances the bar by a shrinking share of what is left,
// so the curve is monotonic for any round count and converges below the
// agent_done anchor at 80 — never past it, never stalls on the way.
//
// The shape is 35 + 44·(1 − e^(−k/12)): the first command moves ~4 points, the
// tenth ~60%, the twentieth ~71%, and even a run that exhausts
// max_iterations=30 only reaches ~75, still short of the 79 ceiling.
func asymptoticInstallPercent(k int) int {
if k <= 0 {
return 35
}
p := 35 + int(math.Round(44*(1-math.Exp(-float64(k)/12.0))))
if p > 79 {
return 79
}
return p
}
func (tr *installTranscript) onInstallOutput(_ context.Context, evt event.Event) error {
data, ok := evt.Data.(event.CommandOutputData)
if !ok {
return nil
}
tr.mu.Lock()
closed := tr.closed
tr.mu.Unlock()
if closed {
return nil
}
tr.append(interfaces.StreamEvent{
ID: evt.ID, Type: types.ResponseTypeInstallOutput, Timestamp: time.Now(),
Data: map[string]interface{}{
"tool_call_id": data.ToolCallID, "command": data.Command,
"started_at": data.StartedAt, "output": data.Output, "done": data.Done,
},
})
return nil
}