Files
gsfdc/demo-dify/dify/dify-agent-runtime/internal/agentcli/connect.go
T
wuzilongandCursor 6519682885 chore: 纳入本地 Dify 1.19.0 源码及品牌与免登改动
演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-18 13:59:25 +08:00

36 lines
725 B
Go

package agentcli
import (
"context"
"encoding/json"
"fmt"
)
// ConnectResponse is the JSON output for `dify-agent connect --json`.
type ConnectResponse struct {
ConnectionID string `json:"connection_id"`
Status string `json:"status"`
}
// RunConnect executes the connect command.
func RunConnect(env *Environment, argv []string, jsonOutput bool) error {
client, err := NewStubClient(env)
if err != nil {
return err
}
defer func() { _ = client.Close() }()
resp, err := client.Connect(context.Background(), argv, "{}")
if err != nil {
return err
}
if jsonOutput {
out, _ := json.Marshal(resp)
fmt.Println(string(out))
} else {
fmt.Printf("connected %s\n", resp.ConnectionID)
}
return nil
}