Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
charm.land/bubbles/v2 v2.2.1
charm.land/bubbletea/v2 v2.1.0
charm.land/lipgloss/v2 v2.0.6
github.com/basecamp/basecamp-sdk/go v0.37.0
github.com/basecamp/basecamp-sdk/go v0.39.0
github.com/basecamp/cli v0.2.2-0.20261023171439-c9bce8206df9
github.com/basecamp/mcp v0.0.0-20261118214004-663b2e5d2836
github.com/basecamp/surfguard/go v0.1.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
github.com/basecamp/actioncable-go v1.2.0 h1:t0MxlfMTcmaGXZ5ztgKRs7ZiY1MwXtBRwSSSAh1ofVg=
github.com/basecamp/actioncable-go v1.2.0/go.mod h1:ezaV5z1GXQAsqyejqTs6wCFl2D8Wj+COLQkHc/kwoRs=
github.com/basecamp/basecamp-sdk/go v0.37.0 h1:/Tv7GALbwmj0/gk8y2kwAi9/OiiWEQlJcVDH9PfMHWM=
github.com/basecamp/basecamp-sdk/go v0.37.0/go.mod h1:ynVJME8mVV3UHMUMnzBgygTnMtadQFxz1iYg7fqwUeM=
github.com/basecamp/basecamp-sdk/go v0.39.0 h1:s9963I0FFXxLcldw5/faiAUvTi3j3IYc5/47sdg6o/g=
github.com/basecamp/basecamp-sdk/go v0.39.0/go.mod h1:ynVJME8mVV3UHMUMnzBgygTnMtadQFxz1iYg7fqwUeM=
github.com/basecamp/cli v0.2.2-0.20261023171439-c9bce8206df9 h1:3NfGs+zx23Tp6cf+97+UewrJHlzZMLzmvEXOmOJyQAk=
github.com/basecamp/cli v0.2.2-0.20261023171439-c9bce8206df9/go.mod h1:iTBTaWvsPEFIcZfkxQHEfISyJ6sZ7036K6bNx0RY3EE=
github.com/basecamp/mcp v0.0.0-20261118214004-663b2e5d2836 h1:ND4te8b+HVFFrgcm7+n8P83MKKPqBpIyoJ63tT9liRU=
Expand Down
57 changes: 57 additions & 0 deletions internal/commands/chat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2443,3 +2443,60 @@ func TestChatPostPostsHTMLWithAMention(t *testing.T) {
assert.Contains(t, content, "<ul><li>one</li></ul>")
assert.NotContains(t, content, "&lt;")
}

// mockChatCreatorTransport serves one line whose creator is creatorJSON.
type mockChatCreatorTransport struct {
creatorJSON string
}

func (t *mockChatCreatorTransport) RoundTrip(req *http.Request) (*http.Response, error) {
header := make(http.Header)
header.Set("Content-Type", "application/json")
if req.Method != "GET" || !strings.Contains(req.URL.Path, "/lines/") {
return nil, errors.New("unexpected request " + req.Method + " " + req.URL.Path)
}
body := `{"id": 111, "content": "Hello", "type": "Chat::Lines::Text", "creator": ` + t.creatorJSON + `}`
return &http.Response{StatusCode: 200, Body: io.NopCloser(strings.NewReader(body)), Header: header}, nil
}

// TestChatLineKeepsTheCreatorsClientFlag verifies that a line's creator keeps
// what Basecamp said about being a client. A non-client author used to come
// out with no client key at all, so the local agent connector's project
// trust, which requires client == false, refused every Campfire mention from
// anyone but its operator.
func TestChatLineKeepsTheCreatorsClientFlag(t *testing.T) {
for _, tc := range []struct {
name string
creator string
want string // the client key's raw JSON; "" for no key
}{
{"not a client", `{"id": 1, "name": "Tester", "client": false, "employee": true}`, "false"},
{"a client", `{"id": 1, "name": "Tester", "client": true}`, "true"},
{"not said", `{"id": 1, "name": "Tester"}`, ""},
} {
t.Run(tc.name, func(t *testing.T) {
t.Setenv("BASECAMP_NO_KEYRING", "1")

app, buf := newChatDeleteTestApp(&mockChatCreatorTransport{creatorJSON: tc.creator})
err := executeChatCommand(NewChatCmd(), app, "line", "https://3.basecamp.com/99999/buckets/123/chats/456/lines/111")
require.NoError(t, err)

var out struct {
Data struct {
ID int64 `json:"id"`
Creator map[string]json.RawMessage `json:"creator"`
} `json:"data"`
}
require.NoError(t, json.Unmarshal(buf.Bytes(), &out), buf.String())
require.EqualValues(t, 111, out.Data.ID, "the line was printed")
require.NotNil(t, out.Data.Creator, "the line carries its creator")

got, present := out.Data.Creator["client"]
if tc.want == "" {
assert.False(t, present, "client = %s, want no key", got)
return
}
assert.Equal(t, tc.want, string(got))
})
}
}
12 changes: 6 additions & 6 deletions internal/commands/connect_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ func startConnectSetupServer(t *testing.T) *connectSetupServer {
}
writeJSON(w, profile)
case setupOperatorToken:
writeJSON(w, map[string]any{"id": setupOperatorPerson, "name": "Operator", "personable_type": "User"})
writeJSON(w, map[string]any{"id": setupOperatorPerson, "name": "Operator", "personable_type": "User", "client": false})
case setupBotToken:
writeJSON(w, map[string]any{"id": setupBotPerson, "name": "Bot", "personable_type": "User"})
writeJSON(w, map[string]any{"id": setupBotPerson, "name": "Bot", "personable_type": "User", "client": false})
default:
w.WriteHeader(http.StatusUnauthorized)
}
Expand All @@ -178,14 +178,14 @@ func startConnectSetupServer(t *testing.T) *connectSetupServer {
w.WriteHeader(http.StatusForbidden)
return
}
writeJSON(w, map[string]any{"id": setupOperatorPerson, "name": "Operator", "personable_type": "User"})
writeJSON(w, map[string]any{"id": setupOperatorPerson, "name": "Operator", "personable_type": "User", "client": false})
})
mux.HandleFunc(fmt.Sprintf("/999/people/%d", setupOperatorPerson+1), func(w http.ResponseWriter, r *http.Request) {
if bearer(r) != setupOperatorToken {
w.WriteHeader(http.StatusForbidden) // as bc3 refuses an Agent today
return
}
writeJSON(w, map[string]any{"id": setupOperatorPerson + 1, "name": "Colleague", "personable_type": "User"})
writeJSON(w, map[string]any{"id": setupOperatorPerson + 1, "name": "Colleague", "personable_type": "User", "client": false})
})
mux.HandleFunc(fmt.Sprintf("/999/people/%d", setupAgentPerson), func(w http.ResponseWriter, _ *http.Request) {
writeJSON(w, map[string]any{"id": setupAgentPerson, "name": "Marie Chef", "personable_type": "Agent"})
Expand Down Expand Up @@ -1625,8 +1625,8 @@ func TestConnectSetupLetsAPersonIntoOnePing(t *testing.T) {
s.bodies = map[string]any{fmt.Sprintf("/999/circles/%d", ping): map[string]any{
"id": ping, "title": "Launch",
"people": []map[string]any{
{"id": setupOperatorPerson, "name": "Operator", "personable_type": "User"},
{"id": guest, "name": "Jorge", "personable_type": "User"},
{"id": setupOperatorPerson, "name": "Operator", "personable_type": "User", "client": false},
{"id": guest, "name": "Jorge", "personable_type": "User", "client": false},
{"id": setupClientPerson, "name": "Client", "personable_type": "User", "client": true},
{"id": setupPeerAgent, "name": "Peer (agent)", "personable_type": "Agent"},
},
Expand Down
6 changes: 3 additions & 3 deletions internal/commands/people.go
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ func runPeopleList(cmd *cobra.Command, projectID string, limit, page int, all bo
Title: p.Title,
Employee: p.Employee,
Admin: p.Admin,
Client: p.Client,
Client: basecamp.Deref(p.Client),
}
}

Expand Down Expand Up @@ -1148,7 +1148,7 @@ func runPeopleClientsList(cmd *cobra.Command, projectID string) error {
}
items := make([]clientListItem, 0)
for _, p := range result.People {
if !p.Client {
if !basecamp.Deref(p.Client) {
continue
}
item := clientListItem{ID: p.ID, Name: p.Name, EmailAddress: p.EmailAddress, Title: p.Title}
Expand Down Expand Up @@ -1702,7 +1702,7 @@ func clientEnablementError(ctx context.Context, app *appctx.App, bucketID int64,
if roster, listErr := app.Account().People().ListProjectPeople(ctx, bucketID, &basecamp.PeopleListOptions{}); listErr == nil {
var ids []int64
for _, p := range roster.People {
if p.Client {
if basecamp.Deref(p.Client) {
ids = append(ids, p.ID)
}
}
Expand Down
8 changes: 5 additions & 3 deletions internal/connector/admission/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ func NewMembers(client *basecamp.AccountClient, now func() time.Time) *Members {
}

// NonClientMember implements MemberReader. A member for trust is a person the
// project's listing names who is neither a client nor an Agent principal (the
// listing serves agents, with client false).
// project's listing names, says is not a client, and does not mark as an
// Agent principal (the listing serves agents, with client false). A person
// the listing does not say either way about is not a member: trust is not
// given on a field that is missing.
//
// "Yes" is served from a cached listing for its TTL. "No" discards the event,
// so it is served only from a listing read at or after asOf; everyone the
Expand Down Expand Up @@ -198,7 +200,7 @@ func (m *Members) NonClientMember(ctx context.Context, bucketID, personID int64,
}
people := projectPeople{members: make(map[int64]bool, len(res.People))}
for _, p := range res.People {
if p.ID > 0 && !p.Client && p.PersonableType != personableAgent {
if p.ID > 0 && p.Client != nil && !*p.Client && p.PersonableType != personableAgent {
people.members[p.ID] = true
}
}
Expand Down
7 changes: 5 additions & 2 deletions internal/connector/admission/sdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,16 +252,19 @@ func (l *listing) client(t *testing.T) *basecamp.AccountClient {
}

func TestMembershipExcludesClientsAndAgents(t *testing.T) {
// unsaidID is listed without a client flag. Trust is not given on a field
// that is missing, so the listing does not make them a member.
const unsaidID int64 = 1006
l := &listing{}
l.set(fmt.Sprintf(`[{"id":%d,"personable_type":"User","client":false},{"id":%d,"personable_type":"Client","client":true},{"id":%d,"personable_type":"Agent","client":false}]`, memberID, clientID, otherAgent))
l.set(fmt.Sprintf(`[{"id":%d,"personable_type":"User","client":false},{"id":%d,"personable_type":"Client","client":true},{"id":%d,"personable_type":"Agent","client":false},{"id":%d,"personable_type":"User"}]`, memberID, clientID, otherAgent, unsaidID))
c := &clock{now: testNow}
members := NewMembers(l.client(t), c.Now)
seen := testNow.Add(-time.Second)

for _, tc := range []struct {
id int64
want bool
}{{memberID, true}, {clientID, false}, {otherAgent, false}, {strangerID, false}} {
}{{memberID, true}, {clientID, false}, {otherAgent, false}, {strangerID, false}, {unsaidID, false}} {
got, err := members.NonClientMember(context.Background(), servedProj, tc.id, seen)
require.NoError(t, err)
assert.Equal(t, tc.want, got, "person %d", tc.id)
Expand Down
11 changes: 10 additions & 1 deletion internal/connector/setup/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ type Person struct {
Name string
PersonableType string
Client bool
// ClientUnsaid marks a person read through the SDK (fromSDK) whose read
// left the client flag out. The checks refuse them as they refuse a
// client. It is false on a Person built any other way, such as the
// agent's boss taken from its profile, so it says nothing about those.
ClientUnsaid bool
}

// Reader is what the checks read, as the agent, in the agent's account.
Expand Down Expand Up @@ -167,7 +172,7 @@ func fromSDK(p *basecamp.Person) Person {
if p == nil {
return Person{}
}
return Person{ID: p.ID, Name: p.Name, PersonableType: p.PersonableType, Client: p.Client}
return Person{ID: p.ID, Name: p.Name, PersonableType: p.PersonableType, Client: basecamp.Deref(p.Client), ClientUnsaid: p.Client == nil}
}

// httpStatus is the status a failed read answered with, 0 when it did not
Expand Down Expand Up @@ -382,6 +387,8 @@ func verifyPerson(ctx context.Context, r Reader, name string, p Person, agentID
c.Status, c.Message = StatusFail, fmt.Sprintf("Person %d is an Agent; agents never authorize", p.ID)
case p.Client:
c.Status, c.Message = StatusFail, fmt.Sprintf("Person %d is a client of the account; only members are trusted", p.ID)
case p.ClientUnsaid:
c.Status, c.Message = StatusFail, fmt.Sprintf("Basecamp did not say whether person %d is a client; only members are trusted", p.ID)
default:
c.Status = StatusPass
c.Message = fmt.Sprintf("Person %d, %s%s", p.ID, richtext.SanitizeSingleLine(p.Name), source)
Expand Down Expand Up @@ -563,6 +570,8 @@ func verifyPingPerson(ping Ping, readErr error, pingID, id, agentID int64, recor
c.Message = fmt.Sprintf("Person %d is an Agent; agents never authorize, and are allowed only with --allow-agent", id)
case p.Client:
c.Status, c.Message = StatusFail, fmt.Sprintf("Person %d is a client of the account; only members are trusted", id)
case p.ClientUnsaid:
c.Status, c.Message = StatusFail, fmt.Sprintf("Basecamp did not say whether person %d is a client; only members are trusted", id)
default:
c.Status = StatusPass
c.Message = fmt.Sprintf("Person %d, %s, may ask by mention in Ping %d alone", id, richtext.SanitizeSingleLine(p.Name), pingID)
Expand Down
29 changes: 29 additions & 0 deletions internal/connector/setup/checks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ func TestVerifyTrust(t *testing.T) {
7: {ID: 7, PersonableType: PersonableAgent},
8: {ID: 8, Client: true},
9: {ID: 9, Name: "Member"},
11: {ID: 11, Name: "Unsaid", ClientUnsaid: true},
}
r := &fakeReader{people: people}
forbidden := &fakeReader{personErr: status(http.StatusForbidden)}
Expand Down Expand Up @@ -211,6 +212,12 @@ func TestVerifyTrust(t *testing.T) {
t.Run("property 5: not a client", func(t *testing.T) {
assert.Equal(t, []string{"Operator=fail"}, verify(r, Trust{Operator: Person{ID: 8}}))
assert.Equal(t, []string{"Operator=pass", "Allowlist 8=fail"}, verify(r, Trust{Operator: Person{ID: operatorID}, Allowlist: []int64{8}}))
assert.Equal(t, []string{"Operator=pass", "Allowlist 9=pass"}, verify(r, Trust{Operator: Person{ID: operatorID}, Allowlist: []int64{9}}),
"the control: a member the read says is no client passes")
})
t.Run("property 5b: a read that does not say is not a member", func(t *testing.T) {
assert.Equal(t, []string{"Operator=fail"}, verify(r, Trust{Operator: Person{ID: 11}}))
assert.Equal(t, []string{"Operator=pass", "Allowlist 11=fail"}, verify(r, Trust{Operator: Person{ID: operatorID}, Allowlist: []int64{11}}))
})
t.Run("property 6: the read answers for the id asked", func(t *testing.T) {
liar := &fakeReader{people: map[int64]Person{operatorID: {ID: 9, Name: "Someone else"}}}
Expand Down Expand Up @@ -371,3 +378,25 @@ func TestProjectChecksQuoteTheProfileInTheHint(t *testing.T) {
assert.Equal(t, f.Profile, string(out), "first setup %v", firstSetup)
}
}

// fromSDK keeps whether a person's read said they are a client: a read that
// left the flag out is ClientUnsaid, which the checks refuse.
func TestFromSDKKeepsWhetherTheReadSaidClient(t *testing.T) {
for _, tc := range []struct {
name string
client *bool
wantClient bool
wantUnsaid bool
}{
{"not a client", basecamp.Ptr(false), false, false},
{"a client", basecamp.Ptr(true), true, false},
{"not said", nil, false, true},
} {
t.Run(tc.name, func(t *testing.T) {
p := fromSDK(&basecamp.Person{ID: 5, Name: "Annie", Client: tc.client})
assert.Equal(t, int64(5), p.ID)
assert.Equal(t, tc.wantClient, p.Client)
assert.Equal(t, tc.wantUnsaid, p.ClientUnsaid)
})
}
}
2 changes: 2 additions & 0 deletions internal/connector/setup/pings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func TestVerifyPings(t *testing.T) {
{ID: operatorID, Name: "Operator"},
{ID: guest, Name: "Jorge"},
{ID: 9, Name: "A client", Client: true},
{ID: 11, Name: "Unsaid", ClientUnsaid: true},
{ID: peerAgent, Name: "Peer (agent)", PersonableType: PersonableAgent},
}}}}
verify := func(r Reader, id int64, recorded bool) Check {
Expand All @@ -112,6 +113,7 @@ func TestVerifyPings(t *testing.T) {
assert.Equal(t, StatusFail, verify(r, peerAgent, false).Status, "no agent is a participant")
assert.Equal(t, StatusFail, verify(r, peerAgent, true).Status, "recorded or not")
assert.Equal(t, StatusFail, verify(r, 9, false).Status, "a client is refused, as project trust refuses one")
assert.Equal(t, StatusFail, verify(r, 11, false).Status, "so is one the read did not say is no client")
assert.Equal(t, StatusFail, verify(r, agentID, false).Status, "the agent itself")
assert.Equal(t, StatusFail, verify(r, guest2, false).Status, "someone not in the Ping")
assert.Equal(t, StatusWarn, verify(r, guest2, true).Status, "one recorded who has since left is a warning")
Expand Down
4 changes: 2 additions & 2 deletions internal/mcpserver/model/PROVENANCE.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"source": "github.com/basecamp/basecamp-sdk",
"commit": "da4686b0d61a088a86d203d038d8b53637e8efe4",
"ref": "go/v0.37.0",
"commit": "0e8079e728fb08fcedd8aecab9cd692b49f13979",
"ref": "go/v0.39.0",
"files": ["behavior-model.json", "openapi.json"],
"synced_by": "scripts/sync-mcp-model.sh",
"patches": "binary-upload operations dropped because the toolkit refuses their non-JSON bodies (EXCLUDED_OPERATIONS) and the stream-ticket mint dropped by policy (POLICY_EXCLUDED_OPERATIONS); no tag patches applied (PATCHED_TAGS is empty — the export tags every operation) — see the sync script"
Expand Down
2 changes: 1 addition & 1 deletion internal/tui/workspace/data/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ func (h *Hub) People() *Pool[[]PersonInfo] {
Title: pp.Title,
Admin: pp.Admin,
Owner: pp.Owner,
Client: pp.Client,
Client: basecamp.Deref(pp.Client),
PersonType: pp.PersonableType,
Company: company,
})
Expand Down
6 changes: 3 additions & 3 deletions internal/version/sdk-provenance.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"sdk": {
"module": "github.com/basecamp/basecamp-sdk/go",
"version": "v0.37.0",
"revision": "da4686b0d61a",
"updated_at": "2026-11-19T01:35:10Z"
"version": "v0.39.0",
"revision": "0e8079e728fb",
"updated_at": "2026-11-22T22:34:51Z"
},
"api": {
"repo": "basecamp/bc3",
Expand Down
2 changes: 1 addition & 1 deletion nix/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildGoModule.override { go = go_1_26; } (finalAttrs: {
src = lib.cleanSource ./..;

# To update: set to lib.fakeHash, run `nix build`, use the hash from the error.
vendorHash = "sha256-pra9JQdNbQ/gvdQmdeS/QU+n7wqTND3BzVfmSJj+03k=";
vendorHash = "sha256-FFQmX4jugjhNH29btDeowRu6MqP1tKzv21SiIux/zZw=";

subPackages = [ "cmd/basecamp" ];

Expand Down
Loading