MCPcopy Create free account
hub / github.com/astercloud/aster / initSession

Method initSession

pkg/sandbox/cloud/volcengine.go:174–205  ·  view source on GitHub ↗

initSession 初始化沙箱会话

(ctx context.Context)

Source from the content-addressed store, hash-verified

172
173// initSession 初始化沙箱会话
174func (vs *VolcengineSandbox) initSession(ctx context.Context) error {
175 params := map[string]any{
176 "work_dir": vs.config.WorkDir,
177 "cpu": vs.config.CPU,
178 "memory": vs.config.Memory,
179 }
180
181 if vs.config.Image != "" {
182 params["image"] = vs.config.Image
183 }
184 if vs.config.Environment != nil {
185 params["environment"] = vs.config.Environment
186 }
187
188 result, err := vs.mcpClient.CallTool(ctx, "computer_init", params)
189 if err != nil {
190 return fmt.Errorf("init computer: %w", err)
191 }
192
193 // 解析会话 ID
194 var initResult struct {
195 SessionID string `json:"session_id"`
196 }
197 if err := json.Unmarshal(result, &initResult); err != nil {
198 return fmt.Errorf("parse init result: %w", err)
199 }
200
201 vs.sessionID = initResult.SessionID
202 vs.SetSessionID(initResult.SessionID)
203
204 return nil
205}
206
207// VolcengineFS 火山引擎文件系统
208type VolcengineFS struct {

Callers 1

NewVolcengineSandboxFunction · 0.95

Calls 2

SetSessionIDMethod · 0.80
CallToolMethod · 0.45

Tested by

no test coverage detected