@pidgeon-ai/cli 1.1.0 → 1.3.0
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/dist/{chunk-RLDRGO7L.js → chunk-77VBXQPL.js} +140 -4
- package/dist/chunk-77VBXQPL.js.map +1 -0
- package/dist/{chunk-QJTSUFF2.js → chunk-FVN6XCHM.js} +158 -3
- package/dist/chunk-FVN6XCHM.js.map +1 -0
- package/dist/cli.js +2 -2
- package/dist/commands.gen.js +1 -1
- package/dist/index.js +2 -2
- package/package.json +2 -2
- package/dist/chunk-QJTSUFF2.js.map +0 -1
- package/dist/chunk-RLDRGO7L.js.map +0 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
COMMANDS,
|
|
4
4
|
__export
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-FVN6XCHM.js";
|
|
6
6
|
|
|
7
7
|
// ../sdk/dist/index.js
|
|
8
8
|
var dist_exports = {};
|
|
@@ -80,6 +80,7 @@ __export(dist_exports, {
|
|
|
80
80
|
mailboxesListFolder: () => mailboxesListFolder,
|
|
81
81
|
meGet: () => meGet,
|
|
82
82
|
messagesAct: () => messagesAct,
|
|
83
|
+
messagesAwait: () => messagesAwait,
|
|
83
84
|
messagesForward: () => messagesForward,
|
|
84
85
|
messagesGet: () => messagesGet,
|
|
85
86
|
messagesListInThread: () => messagesListInThread,
|
|
@@ -92,10 +93,15 @@ __export(dist_exports, {
|
|
|
92
93
|
messagesUndo: () => messagesUndo,
|
|
93
94
|
messagesUpdate: () => messagesUpdate,
|
|
94
95
|
metricsQuery: () => metricsQuery,
|
|
96
|
+
podsCreate: () => podsCreate,
|
|
97
|
+
podsGet: () => podsGet,
|
|
98
|
+
podsList: () => podsList,
|
|
99
|
+
podsUpdate: () => podsUpdate,
|
|
95
100
|
routingCreate: () => routingCreate,
|
|
96
101
|
routingDelete: () => routingDelete,
|
|
97
102
|
routingList: () => routingList,
|
|
98
103
|
routingUpdate: () => routingUpdate,
|
|
104
|
+
streamEvents: () => streamEvents,
|
|
99
105
|
threadsGet: () => threadsGet,
|
|
100
106
|
threadsLabelsCreate: () => threadsLabelsCreate,
|
|
101
107
|
threadsLabelsDelete: () => threadsLabelsDelete,
|
|
@@ -157,7 +163,7 @@ function createSseClient({
|
|
|
157
163
|
...options
|
|
158
164
|
}) {
|
|
159
165
|
let lastEventId;
|
|
160
|
-
const
|
|
166
|
+
const sleep2 = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
161
167
|
const createStream = async function* () {
|
|
162
168
|
let retryDelay = sseDefaultRetryDelay ?? 3e3;
|
|
163
169
|
let attempt = 0;
|
|
@@ -261,7 +267,7 @@ function createSseClient({
|
|
|
261
267
|
break;
|
|
262
268
|
}
|
|
263
269
|
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
|
|
264
|
-
await
|
|
270
|
+
await sleep2(backoff);
|
|
265
271
|
}
|
|
266
272
|
}
|
|
267
273
|
};
|
|
@@ -1026,6 +1032,34 @@ var identitiesSuspendTenant = (options) => (options.client ?? client).post({
|
|
|
1026
1032
|
url: "/tenants/{id}/suspend",
|
|
1027
1033
|
...options
|
|
1028
1034
|
});
|
|
1035
|
+
var podsList = (options) => (options?.client ?? client).get({
|
|
1036
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1037
|
+
url: "/pods",
|
|
1038
|
+
...options
|
|
1039
|
+
});
|
|
1040
|
+
var podsCreate = (options) => (options.client ?? client).post({
|
|
1041
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1042
|
+
url: "/pods",
|
|
1043
|
+
...options,
|
|
1044
|
+
headers: {
|
|
1045
|
+
"Content-Type": "application/json",
|
|
1046
|
+
...options.headers
|
|
1047
|
+
}
|
|
1048
|
+
});
|
|
1049
|
+
var podsGet = (options) => (options.client ?? client).get({
|
|
1050
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1051
|
+
url: "/pods/{id}",
|
|
1052
|
+
...options
|
|
1053
|
+
});
|
|
1054
|
+
var podsUpdate = (options) => (options.client ?? client).patch({
|
|
1055
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1056
|
+
url: "/pods/{id}",
|
|
1057
|
+
...options,
|
|
1058
|
+
headers: {
|
|
1059
|
+
"Content-Type": "application/json",
|
|
1060
|
+
...options.headers
|
|
1061
|
+
}
|
|
1062
|
+
});
|
|
1029
1063
|
var labelsList = (options) => (options.client ?? client).get({
|
|
1030
1064
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1031
1065
|
url: "/labels",
|
|
@@ -1110,6 +1144,11 @@ var messagesUndo = (options) => (options.client ?? client).post({
|
|
|
1110
1144
|
...options.headers
|
|
1111
1145
|
}
|
|
1112
1146
|
});
|
|
1147
|
+
var messagesAwait = (options) => (options.client ?? client).get({
|
|
1148
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1149
|
+
url: "/messages/await",
|
|
1150
|
+
...options
|
|
1151
|
+
});
|
|
1113
1152
|
var messagesGet = (options) => (options.client ?? client).get({
|
|
1114
1153
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1115
1154
|
url: "/messages/{id}",
|
|
@@ -1613,6 +1652,103 @@ function constantTimeEqual(a, b) {
|
|
|
1613
1652
|
}
|
|
1614
1653
|
return difference === 0;
|
|
1615
1654
|
}
|
|
1655
|
+
async function* streamEvents(options) {
|
|
1656
|
+
const base = (options.baseUrl ?? "https://pidgeon.ai/api/v1").replace(/\/$/, "");
|
|
1657
|
+
let lastEventId;
|
|
1658
|
+
let backoffMs = 1e3;
|
|
1659
|
+
while (!options.signal?.aborted) {
|
|
1660
|
+
const url = new URL(`${base}/events/stream`);
|
|
1661
|
+
if (options.identityId) url.searchParams.set("identity_id", options.identityId);
|
|
1662
|
+
if (options.type) url.searchParams.set("type", options.type);
|
|
1663
|
+
if (options.after && !lastEventId) url.searchParams.set("after", options.after);
|
|
1664
|
+
let response;
|
|
1665
|
+
try {
|
|
1666
|
+
response = await fetch(url, {
|
|
1667
|
+
headers: {
|
|
1668
|
+
authorization: `Bearer ${options.apiKey}`,
|
|
1669
|
+
accept: "text/event-stream",
|
|
1670
|
+
...lastEventId ? { "last-event-id": lastEventId } : {}
|
|
1671
|
+
},
|
|
1672
|
+
signal: options.signal
|
|
1673
|
+
});
|
|
1674
|
+
} catch {
|
|
1675
|
+
if (options.signal?.aborted) return;
|
|
1676
|
+
await sleep(backoffMs, options.signal);
|
|
1677
|
+
backoffMs = Math.min(backoffMs * 2, 3e4);
|
|
1678
|
+
continue;
|
|
1679
|
+
}
|
|
1680
|
+
if (response.status === 401 || response.status === 403 || response.status === 404) {
|
|
1681
|
+
throw new Error(
|
|
1682
|
+
`Pidgeon refused the stream: ${response.status} ${await response.text().catch(() => "")}`.trim()
|
|
1683
|
+
);
|
|
1684
|
+
}
|
|
1685
|
+
if (!response.ok || !response.body) {
|
|
1686
|
+
await sleep(backoffMs, options.signal);
|
|
1687
|
+
backoffMs = Math.min(backoffMs * 2, 3e4);
|
|
1688
|
+
continue;
|
|
1689
|
+
}
|
|
1690
|
+
backoffMs = 1e3;
|
|
1691
|
+
for await (const frame of frames(response.body, options.signal)) {
|
|
1692
|
+
if (frame.id) lastEventId = frame.id;
|
|
1693
|
+
if (!frame.data) continue;
|
|
1694
|
+
if (frame.event === "error") continue;
|
|
1695
|
+
let parsed;
|
|
1696
|
+
try {
|
|
1697
|
+
parsed = JSON.parse(frame.data);
|
|
1698
|
+
} catch {
|
|
1699
|
+
continue;
|
|
1700
|
+
}
|
|
1701
|
+
yield parsed;
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
async function* frames(body, signal) {
|
|
1706
|
+
const reader = body.getReader();
|
|
1707
|
+
const decoder = new TextDecoder();
|
|
1708
|
+
let buffer = "";
|
|
1709
|
+
try {
|
|
1710
|
+
while (!signal?.aborted) {
|
|
1711
|
+
const { done, value } = await reader.read();
|
|
1712
|
+
if (done) return;
|
|
1713
|
+
buffer += decoder.decode(value, { stream: true });
|
|
1714
|
+
let boundary = buffer.indexOf("\n\n");
|
|
1715
|
+
while (boundary !== -1) {
|
|
1716
|
+
const block = buffer.slice(0, boundary);
|
|
1717
|
+
buffer = buffer.slice(boundary + 2);
|
|
1718
|
+
boundary = buffer.indexOf("\n\n");
|
|
1719
|
+
const frame = {};
|
|
1720
|
+
const data = [];
|
|
1721
|
+
for (const line of block.split("\n")) {
|
|
1722
|
+
if (line.startsWith(":")) continue;
|
|
1723
|
+
const colon = line.indexOf(":");
|
|
1724
|
+
if (colon === -1) continue;
|
|
1725
|
+
const field = line.slice(0, colon);
|
|
1726
|
+
const value2 = line.slice(colon + 1).replace(/^ /, "");
|
|
1727
|
+
if (field === "id") frame.id = value2;
|
|
1728
|
+
else if (field === "event") frame.event = value2;
|
|
1729
|
+
else if (field === "data") data.push(value2);
|
|
1730
|
+
}
|
|
1731
|
+
if (data.length > 0) frame.data = data.join("\n");
|
|
1732
|
+
if (frame.id || frame.data) yield frame;
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
} finally {
|
|
1736
|
+
await reader.cancel().catch(() => void 0);
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
function sleep(ms, signal) {
|
|
1740
|
+
return new Promise((resolve) => {
|
|
1741
|
+
const timer = setTimeout(resolve, ms);
|
|
1742
|
+
signal?.addEventListener(
|
|
1743
|
+
"abort",
|
|
1744
|
+
() => {
|
|
1745
|
+
clearTimeout(timer);
|
|
1746
|
+
resolve();
|
|
1747
|
+
},
|
|
1748
|
+
{ once: true }
|
|
1749
|
+
);
|
|
1750
|
+
});
|
|
1751
|
+
}
|
|
1616
1752
|
|
|
1617
1753
|
// src/index.ts
|
|
1618
1754
|
var DEFAULT_BASE_URL = "https://pidgeon.ai/api/v1";
|
|
@@ -1747,4 +1883,4 @@ export {
|
|
|
1747
1883
|
find,
|
|
1748
1884
|
run
|
|
1749
1885
|
};
|
|
1750
|
-
//# sourceMappingURL=chunk-
|
|
1886
|
+
//# sourceMappingURL=chunk-77VBXQPL.js.map
|