@m8tes/sdk 0.1.0-alpha.7 → 0.1.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -13,6 +13,19 @@ All notable changes to `@m8tes/sdk`.
13
13
  > While the version is a `-alpha.N` prerelease, publish with dist-tag `alpha`.
14
14
  > The first stable release is published with `--tag latest` deliberately.
15
15
 
16
+ ## [0.1.0-alpha.8] - 2026-09-06
17
+
18
+ ### Added
19
+
20
+ - **`client.groups` for recursive shared Teams.** Create and move nested groups, inspect visible
21
+ ancestor paths and management capabilities, manage direct and inherited viewer, runner, or
22
+ editor roles, and run the verified-email invitation lifecycle. New invitations default to
23
+ editor, while migrated grants remain viewer. Membership calls are account-scoped and independent
24
+ of organization membership and the legacy bulk Mate visibility operation exposed by
25
+ `groups.share()`.
26
+ - Agent responses expose `can_manage`, `can_execute`, and owner-only `can_share` so clients can
27
+ present the effective capabilities of a scoped Team member.
28
+
16
29
  ## [0.1.0-alpha.7] - 2026-09-06
17
30
 
18
31
  ### Fixed
@@ -34,7 +47,6 @@ All notable changes to `@m8tes/sdk`.
34
47
  "the run already finished, fall back to `get()`" — true for `GET /runs/{id}/stream`,
35
48
  false for POST reply/create. Callers pinning `human_in_the_loop: false` mid-turn would
36
49
  have been told the run ended while it was still executing under the old settings.
37
-
38
50
  ## [0.1.0-alpha.6] - 2026-09-05
39
51
 
40
52
  ### Fixed
package/README.md CHANGED
@@ -109,6 +109,35 @@ await client.tasks.triggers.create(task.id, { type: "app", app: "github", trigge
109
109
  const { url } = await client.tasks.enableWebhook(task.id);
110
110
  ```
111
111
 
112
+ ## Recursive Teams
113
+
114
+ Organize agents into nested Teams and grant a role across one subtree:
115
+
116
+ ```ts
117
+ const marketing = await client.groups.create({ name: "Marketing" });
118
+ const paidAds = await client.groups.create({ name: "Paid Ads", parent_id: marketing.id });
119
+ const google = await client.groups.create({ name: "Google", parent_id: paidAds.id });
120
+ await client.agents.update(agent.id, { group_id: google.id });
121
+
122
+ const invite = await client.groups.invite(marketing.id, {
123
+ email: "ada@example.com",
124
+ role: "runner",
125
+ });
126
+ const members = await client.groups.members(google.id); // includes inherited roles
127
+ await client.groups.updateMember(marketing.id, members.data[0]!.member_id, { role: "editor" });
128
+ ```
129
+
130
+ New invitations default to `editor`; choose `viewer` for read access or `runner` for read plus
131
+ run/chat/reply/cancel/approve. Editors can also edit Mates, tasks, documents, and work inside the
132
+ subtree. Existing grants remain `viewer`. Roles inherit through child Teams. Editors cannot manage
133
+ members or roles, self-escalate, reorganize Teams, or move a Mate out of the shared scope.
134
+
135
+ Team sharing is account-scoped and does not make someone an organization member. Runs use the
136
+ shared Mate owner's bound tools and billing while auditing the human requester separately;
137
+ credentials stay opaque. Group CRUD still accepts `user_id` for end-user isolation, while
138
+ membership and invitation methods do not. `groups.share()` remains the separate legacy bulk
139
+ operation for direct Mates' visibility.
140
+
112
141
  ## Human-in-the-loop
113
142
 
114
143
  When a run pauses, the stream emits an `approval-request` or `question` event. Answer it and the run resumes.
package/dist/index.cjs CHANGED
@@ -1334,19 +1334,19 @@ var Page = class {
1334
1334
  * it did see rather than a hung process.
1335
1335
  */
1336
1336
  async *[Symbol.asyncIterator]() {
1337
- let page = this;
1337
+ let page2 = this;
1338
1338
  const seen = /* @__PURE__ */ new Set();
1339
1339
  for (; ; ) {
1340
- yield* page.data;
1341
- const last = page.data.at(-1);
1342
- if (!page.hasMore || !last || !page.fetchNext) return;
1343
- let cursor = page.nextStartingAfter === null || page.nextStartingAfter === void 0 ? void 0 : page.nextStartingAfter;
1340
+ yield* page2.data;
1341
+ const last = page2.data.at(-1);
1342
+ if (!page2.hasMore || !last || !page2.fetchNext) return;
1343
+ let cursor = page2.nextStartingAfter === null || page2.nextStartingAfter === void 0 ? void 0 : page2.nextStartingAfter;
1344
1344
  if (cursor === void 0) {
1345
1345
  cursor = typeof last.id === "number" || typeof last.id === "string" ? last.id : typeof last.name === "string" ? last.name : void 0;
1346
1346
  }
1347
1347
  if (cursor === void 0 || seen.has(cursor)) return;
1348
1348
  seen.add(cursor);
1349
- page = await page.fetchNext(cursor);
1349
+ page2 = await page2.fetchNext(cursor);
1350
1350
  }
1351
1351
  }
1352
1352
  /** Every item across every page, collected. Prefer iteration for large sets. */
@@ -1629,6 +1629,69 @@ function createMemoriesResource(http) {
1629
1629
  };
1630
1630
  }
1631
1631
 
1632
+ // src/resources/groups.ts
1633
+ var page = (res) => new Page(res.data ?? [], res.has_more ?? false, void 0, res.next_starting_after);
1634
+ function createGroupsResource(http) {
1635
+ const members = async (groupId) => page(await http.request("GET", `/groups/${seg(groupId)}/members`));
1636
+ const invites = async (groupId) => page(await http.request("GET", `/groups/${seg(groupId)}/invites`));
1637
+ return {
1638
+ create(params) {
1639
+ return http.request("POST", "/groups", { body: toBody({ ...params }) });
1640
+ },
1641
+ async list(params = {}) {
1642
+ return page(await http.request("GET", "/groups", { query: toQuery(params) }));
1643
+ },
1644
+ get(groupId, params = {}) {
1645
+ return http.request("GET", `/groups/${seg(groupId)}`, { query: toQuery(params) });
1646
+ },
1647
+ update(groupId, params) {
1648
+ const { user_id, ...body } = params;
1649
+ return http.request("PATCH", `/groups/${seg(groupId)}`, {
1650
+ query: toQuery({ user_id }),
1651
+ body: toBody(body)
1652
+ });
1653
+ },
1654
+ async delete(groupId, params = {}) {
1655
+ await http.request("DELETE", `/groups/${seg(groupId)}`, { query: toQuery(params) });
1656
+ },
1657
+ share(groupId, params) {
1658
+ const { user_id, ...body } = params;
1659
+ return http.request("POST", `/groups/${seg(groupId)}/share`, {
1660
+ query: toQuery({ user_id }),
1661
+ body: toBody(body)
1662
+ });
1663
+ },
1664
+ members,
1665
+ listMembers: members,
1666
+ updateMember(groupId, memberId, params) {
1667
+ return http.request(
1668
+ "PATCH",
1669
+ `/groups/${seg(groupId)}/members/${seg(memberId)}`,
1670
+ { body: toBody(params) }
1671
+ );
1672
+ },
1673
+ async removeMember(groupId, memberId) {
1674
+ await http.request("DELETE", `/groups/${seg(groupId)}/members/${seg(memberId)}`);
1675
+ },
1676
+ invites,
1677
+ listInvites: invites,
1678
+ invite(groupId, params) {
1679
+ return http.request("POST", `/groups/${seg(groupId)}/invites`, {
1680
+ body: toBody({ role: "editor", ...params })
1681
+ });
1682
+ },
1683
+ async cancelInvite(inviteId) {
1684
+ await http.request("DELETE", `/groups/invites/${seg(inviteId)}`);
1685
+ },
1686
+ previewInvite(token) {
1687
+ return http.request("GET", `/groups/invites/${seg(token)}`);
1688
+ },
1689
+ acceptInvite(token) {
1690
+ return http.request("POST", "/groups/invites/accept", { body: { token } });
1691
+ }
1692
+ };
1693
+ }
1694
+
1632
1695
  // src/resources/models.ts
1633
1696
  function createModelsResource(http) {
1634
1697
  return {
@@ -2415,7 +2478,7 @@ function createWebhooksResource(http) {
2415
2478
  }
2416
2479
 
2417
2480
  // src/index.ts
2418
- var M8TES_SDK_VERSION = "0.1.0-alpha.7";
2481
+ var M8TES_SDK_VERSION = "0.1.0-alpha.8";
2419
2482
  var M8tes = class {
2420
2483
  runs;
2421
2484
  agents;
@@ -2427,6 +2490,7 @@ var M8tes = class {
2427
2490
  webhooks;
2428
2491
  settings;
2429
2492
  memories;
2493
+ groups;
2430
2494
  permissions;
2431
2495
  models;
2432
2496
  modelConnections;
@@ -2445,6 +2509,7 @@ var M8tes = class {
2445
2509
  this.webhooks = createWebhooksResource(this.http);
2446
2510
  this.settings = createSettingsResource(this.http);
2447
2511
  this.memories = createMemoriesResource(this.http);
2512
+ this.groups = createGroupsResource(this.http);
2448
2513
  this.permissions = createPermissionsResource(this.http);
2449
2514
  this.models = createModelsResource(this.http);
2450
2515
  this.modelConnections = createModelConnectionsResource(this.http);