@m8tes/sdk 0.1.0-alpha.6 → 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 +34 -0
- package/README.md +29 -0
- package/dist/{chunk-F6B6R3SP.js → chunk-5X7I2XPE.js} +2 -2
- package/dist/{chunk-F6B6R3SP.js.map → chunk-5X7I2XPE.js.map} +1 -1
- package/dist/index.cjs +80 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +176 -3
- package/dist/index.d.ts +176 -3
- package/dist/index.js +82 -11
- package/dist/index.js.map +1 -1
- package/dist/protocol/index.cjs.map +1 -1
- package/dist/protocol/index.d.cts +2 -2
- package/dist/protocol/index.d.ts +2 -2
- package/dist/protocol/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1275,7 +1275,9 @@ function createHttp(options = {}) {
|
|
|
1275
1275
|
return send(method, path, opts);
|
|
1276
1276
|
},
|
|
1277
1277
|
async *stream(method, path, opts = {}) {
|
|
1278
|
-
const res = await send(method, path, opts, {
|
|
1278
|
+
const res = await send(method, path, opts, {
|
|
1279
|
+
conflictIsNotStreaming: method === "GET"
|
|
1280
|
+
});
|
|
1279
1281
|
if (opts.onReplay && res.headers.get(REPLAY_HEADER)) {
|
|
1280
1282
|
const run = await res.json();
|
|
1281
1283
|
yield* opts.onReplay(run);
|
|
@@ -1332,19 +1334,19 @@ var Page = class {
|
|
|
1332
1334
|
* it did see rather than a hung process.
|
|
1333
1335
|
*/
|
|
1334
1336
|
async *[Symbol.asyncIterator]() {
|
|
1335
|
-
let
|
|
1337
|
+
let page2 = this;
|
|
1336
1338
|
const seen = /* @__PURE__ */ new Set();
|
|
1337
1339
|
for (; ; ) {
|
|
1338
|
-
yield*
|
|
1339
|
-
const last =
|
|
1340
|
-
if (!
|
|
1341
|
-
let cursor =
|
|
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;
|
|
1342
1344
|
if (cursor === void 0) {
|
|
1343
1345
|
cursor = typeof last.id === "number" || typeof last.id === "string" ? last.id : typeof last.name === "string" ? last.name : void 0;
|
|
1344
1346
|
}
|
|
1345
1347
|
if (cursor === void 0 || seen.has(cursor)) return;
|
|
1346
1348
|
seen.add(cursor);
|
|
1347
|
-
|
|
1349
|
+
page2 = await page2.fetchNext(cursor);
|
|
1348
1350
|
}
|
|
1349
1351
|
}
|
|
1350
1352
|
/** Every item across every page, collected. Prefer iteration for large sets. */
|
|
@@ -1627,6 +1629,69 @@ function createMemoriesResource(http) {
|
|
|
1627
1629
|
};
|
|
1628
1630
|
}
|
|
1629
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
|
+
|
|
1630
1695
|
// src/resources/models.ts
|
|
1631
1696
|
function createModelsResource(http) {
|
|
1632
1697
|
return {
|
|
@@ -2067,6 +2132,10 @@ function withRunId(err, runId) {
|
|
|
2067
2132
|
}
|
|
2068
2133
|
return err;
|
|
2069
2134
|
}
|
|
2135
|
+
function replyBody(message, options) {
|
|
2136
|
+
const { raiseOnError: _raiseOnError, idempotencyKey: _idempotencyKey, ...overrides } = options ?? {};
|
|
2137
|
+
return toBody({ ...overrides, message, stream: true });
|
|
2138
|
+
}
|
|
2070
2139
|
function items(payload) {
|
|
2071
2140
|
return Array.isArray(payload) ? payload : payload?.data ?? [];
|
|
2072
2141
|
}
|
|
@@ -2170,7 +2239,7 @@ function createRunsResource(http) {
|
|
|
2170
2239
|
reply(runId, message, options) {
|
|
2171
2240
|
return new RunStream(
|
|
2172
2241
|
http.stream("POST", `/runs/${seg(runId)}/reply`, {
|
|
2173
|
-
body:
|
|
2242
|
+
body: replyBody(message, options),
|
|
2174
2243
|
headers: idempotencyHeaders(options?.idempotencyKey),
|
|
2175
2244
|
onReplay: replayJoin(http)
|
|
2176
2245
|
}),
|
|
@@ -2409,7 +2478,7 @@ function createWebhooksResource(http) {
|
|
|
2409
2478
|
}
|
|
2410
2479
|
|
|
2411
2480
|
// src/index.ts
|
|
2412
|
-
var M8TES_SDK_VERSION = "0.1.0-alpha.
|
|
2481
|
+
var M8TES_SDK_VERSION = "0.1.0-alpha.8";
|
|
2413
2482
|
var M8tes = class {
|
|
2414
2483
|
runs;
|
|
2415
2484
|
agents;
|
|
@@ -2421,6 +2490,7 @@ var M8tes = class {
|
|
|
2421
2490
|
webhooks;
|
|
2422
2491
|
settings;
|
|
2423
2492
|
memories;
|
|
2493
|
+
groups;
|
|
2424
2494
|
permissions;
|
|
2425
2495
|
models;
|
|
2426
2496
|
modelConnections;
|
|
@@ -2439,6 +2509,7 @@ var M8tes = class {
|
|
|
2439
2509
|
this.webhooks = createWebhooksResource(this.http);
|
|
2440
2510
|
this.settings = createSettingsResource(this.http);
|
|
2441
2511
|
this.memories = createMemoriesResource(this.http);
|
|
2512
|
+
this.groups = createGroupsResource(this.http);
|
|
2442
2513
|
this.permissions = createPermissionsResource(this.http);
|
|
2443
2514
|
this.models = createModelsResource(this.http);
|
|
2444
2515
|
this.modelConnections = createModelConnectionsResource(this.http);
|