Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
fix(teamhub): run Discord reads for Agents and send {} for no-argument tools
shoudi zhengfbb43599cc0b
diff --git a/apps/teamhub/internal/agentconnectedapps/access.go b/apps/teamhub/internal/agentconnectedapps/access.goindex 85d7e343..13c6c56a 100644--- a/apps/teamhub/internal/agentconnectedapps/access.go+++ b/apps/teamhub/internal/agentconnectedapps/access.go@@ -68,10 +68,20 @@ func onlyQueries(document any) bool {// readTools are the provider reads the wrapped connector commands make,// including the draft reads TeamHub makes to build a send-draft card, plus the+// Discord reads of the connected guild, its channels, threads, and messages, the// Slack reads Agents make through the generic execute to find direct messages// and the people in them, and the Linear reads, which have no wrapped command.// A read the generic execute names outside this list is held like a write.var readTools = map[string]bool{+ "DISCORDBOT_GET_CONNECTED_GUILD": true,+ "DISCORDBOT_GET_GUILD": true,+ "DISCORDBOT_LIST_GUILD_CHANNELS": true,+ "DISCORDBOT_GET_CHANNEL": true,+ "DISCORDBOT_GET_ACTIVE_GUILD_THREADS": true,+ "DISCORDBOT_LIST_PUBLIC_ARCHIVED_THREADS": true,+ "DISCORDBOT_LIST_MESSAGES": true,+ "DISCORDBOT_GET_MESSAGE": true,+ "DISCORDBOT_LIST_PINNED_MESSAGES": true,"FAL_AI_GET_MODELS": true,"FAL_AI_GET_PRICING": true,"FAL_AI_GET_QUEUE_REQUEST_RESULT": true,diff --git a/apps/teamhub/internal/agentconnectedapps/access_test.go b/apps/teamhub/internal/agentconnectedapps/access_test.goindex 064f1d74..980467fc 100644--- a/apps/teamhub/internal/agentconnectedapps/access_test.go+++ b/apps/teamhub/internal/agentconnectedapps/access_test.go@@ -228,6 +228,17 @@ func TestAccessListsKeepConfirmedWritesHeld(t *testing.T) {}}+func TestAccessRunsDiscordReadsAndHoldsDiscordSends(t *testing.T) {+ for _, slug := range []string{"DISCORDBOT_GET_CONNECTED_GUILD", "DISCORDBOT_LIST_MESSAGES", "DISCORDBOT_LIST_PINNED_MESSAGES"} {+ if accessOf(slug, nil) != accessRead {+ t.Errorf("%s only reads the connected guild and must run at once", slug)+ }+ }+ if accessOf("DISCORDBOT_CREATE_MESSAGE", nil) != accessConfirm {+ t.Error("DISCORDBOT_CREATE_MESSAGE posts to Discord and must wait for confirmation")+ }+}+func TestExecuteRefusesAnUnknownCallTooLargeForItsCard(t *testing.T) {provider, held, err := executeForTest(t, "GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER", "github", map[string]any{"repo": strings.Repeat("x", maxCardInput)})var domain *Errordiff --git a/apps/teamhub/internal/composio/client.go b/apps/teamhub/internal/composio/client.goindex f80ea753..12ef6e39 100644--- a/apps/teamhub/internal/composio/client.go+++ b/apps/teamhub/internal/composio/client.go@@ -389,6 +389,11 @@ func (c *Client) ExecuteTool(ctx context.Context, connectedAccountID, userID, toif binding.UserID != "" && binding.UserID != userID {return ToolExecution{}, ErrConnectionScope}+ // Composio rejects "arguments": null, and a persisted no-argument action+ // decodes back as a nil map, so a tool without arguments sends {}.+ if arguments == nil {+ arguments = map[string]any{}+ }request := struct {ConnectedAccountID string `json:"connected_account_id"`UserID string `json:"user_id"`diff --git a/apps/teamhub/internal/composio/client_test.go b/apps/teamhub/internal/composio/client_test.goindex 8d79dcc9..66dab9a2 100644--- a/apps/teamhub/internal/composio/client_test.go+++ b/apps/teamhub/internal/composio/client_test.go@@ -476,3 +476,30 @@ func authoredProfileSections(profile string) string {}return out.String()}++func TestClientExecuteToolSendsAnObjectForMissingArguments(t *testing.T) {+ var bodies []map[string]json.RawMessage+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ var request map[string]json.RawMessage+ if err := json.NewDecoder(r.Body).Decode(&request); err != nil {+ t.Fatal(err)+ }+ bodies = append(bodies, request)+ _, _ = w.Write([]byte(`{"data":{},"successful":true}`))+ }))+ defer server.Close()+ client, err := newTestClient(Config{BaseURL: server.URL, APIKey: "restricted-key", HTTPClient: server.Client()})+ if err != nil {+ t.Fatal(err)+ }+ userID := client.UserIDForAccount("account_1")+ if _, err = client.ExecuteTool(context.Background(), "ca_1", userID, "DISCORDBOT_GET_CONNECTED_GUILD", "20261116_00", nil); err != nil {+ t.Fatal(err)+ }+ if _, err = client.ExecuteTool(context.Background(), "ca_1", userID, "DISCORDBOT_GET_GUILD", "20261116_00", map[string]any{"guild_id": "g1"}); err != nil {+ t.Fatal(err)+ }+ if len(bodies) != 2 || string(bodies[0]["arguments"]) != `{}` || string(bodies[1]["arguments"]) != `{"guild_id":"g1"}` {+ t.Fatalf("arguments=%s, %s", bodies[0]["arguments"], bodies[1]["arguments"])+ }+}