Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(sdk/go): forward remote sources on Windows (#4285)

Wu Shuwen0f68a12dd6c0
diff --git a/sdk/go/client_test.go b/sdk/go/client_test.go
index d6073837f..9c33cb033 100644
--- a/sdk/go/client_test.go
+++ b/sdk/go/client_test.go
@@ -697,6 +697,33 @@ func TestAddResourceExtra(t *testing.T) {
}
}
+func TestAddResourceForwardsRemoteSources(t *testing.T) {
+ remoteSources := []string{
+ "http://example.com/a.md",
+ "https://example.com/a.md",
+ "[email protected]:team/docs.git",
+ "ssh://[email protected]/team/docs.git",
+ "git://example.com/team/docs.git",
+ }
+
+ for _, source := range remoteSources {
+ t.Run(source, func(t *testing.T) {
+ client, closeServer := testClient(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ body := readJSONBody(t, r)
+ if body["path"] != source {
+ t.Fatalf("path = %#v, want %q", body["path"], source)
+ }
+ writeOK(t, w, map[string]any{"root_uri": "viking://resources/a"})
+ }))
+ defer closeServer()
+
+ if _, err := client.AddResource(context.Background(), source, nil); err != nil {
+ t.Fatal(err)
+ }
+ })
+ }
+}
+
func TestAddResourceSendsAddTypeAndProcessingMode(t *testing.T) {
client, closeServer := testClient(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
body := readJSONBody(t, r)
diff --git a/sdk/go/upload.go b/sdk/go/upload.go
index 4bb354b17..eb675a009 100644
--- a/sdk/go/upload.go
+++ b/sdk/go/upload.go
@@ -141,6 +141,13 @@ func (c *Client) uploadTempFile(ctx context.Context, filePath string) (string, e
}
func (c *Client) addLocalUpload(ctx context.Context, payload map[string]any, path string, includeSourceName bool) error {
+ for _, prefix := range []string{"http://", "https://", "git@", "ssh://", "git://"} {
+ if strings.HasPrefix(path, prefix) {
+ payload["path"] = path
+ return nil
+ }
+ }
+
info, err := os.Stat(path)
if err != nil {
if os.IsNotExist(err) {