Add FileAttachment type and wire up file handling across the stack so that files sent in Feishu are downloaded and forwarded to agents. Claude Code saves files locally for tool-based reading; Gemini passes them as temp file references. Other agents log a warning and ignore. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
67 lines
1.4 KiB
Go
67 lines
1.4 KiB
Go
package qoder
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/chenhg5/cc-connect/core"
|
|
)
|
|
|
|
func TestQoderSession(t *testing.T) {
|
|
if os.Getenv("QODER_INTEGRATION") == "" {
|
|
t.Skip("set QODER_INTEGRATION=1 to run")
|
|
}
|
|
|
|
agent, err := New(map[string]any{
|
|
"work_dir": "/tmp",
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("New: %v", err)
|
|
}
|
|
|
|
sess, err := agent.StartSession(context.Background(), "")
|
|
if err != nil {
|
|
t.Fatalf("StartSession: %v", err)
|
|
}
|
|
defer sess.Close()
|
|
|
|
if err := sess.Send("say hello in one word", nil, nil); err != nil {
|
|
t.Fatalf("Send: %v", err)
|
|
}
|
|
|
|
timeout := time.After(30 * time.Second)
|
|
var gotResult bool
|
|
for !gotResult {
|
|
select {
|
|
case ev, ok := <-sess.Events():
|
|
if !ok {
|
|
t.Fatal("events channel closed prematurely")
|
|
}
|
|
switch ev.Type {
|
|
case core.EventText:
|
|
fmt.Printf("[TEXT] %s\n", ev.Content)
|
|
case core.EventToolUse:
|
|
fmt.Printf("[TOOL] %s: %s\n", ev.ToolName, ev.ToolInput)
|
|
case core.EventResult:
|
|
fmt.Printf("[RESULT] sid=%s content=%s\n", ev.SessionID, ev.Content)
|
|
gotResult = true
|
|
case core.EventError:
|
|
t.Fatalf("[ERROR] %v", ev.Error)
|
|
default:
|
|
fmt.Printf("[%s] %s\n", ev.Type, ev.Content)
|
|
}
|
|
case <-timeout:
|
|
t.Fatal("timeout waiting for result")
|
|
}
|
|
}
|
|
|
|
sid := sess.CurrentSessionID()
|
|
if sid == "" {
|
|
t.Error("expected a session ID from init event")
|
|
}
|
|
fmt.Printf("Session ID: %s\n", sid)
|
|
}
|