primcli 1.55.0 → 1.55.1
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/{api-command-CQRMWPkg.js → api-command-0FiEAuQi.js} +30 -28
- package/dist/{cli-config-DGrZCUfw.js → cli-config-DMszFbGn.js} +6 -9
- package/dist/{json-output-Cf-GFeff.js → json-output-CEskSQJi.js} +1 -1
- package/dist/{listen-background-CMfxkeVP.js → listen-background--0peztKE.js} +8 -7
- package/dist/{machine-session-BYaA1qXC.js → machine-session-CufQfBvp.js} +57 -46
- package/dist/{notify-session-BnEHEbxa.js → notify-session-BGzeKcQO.js} +12 -8
- package/dist/oclif/auto-signal-worker.js +3 -3
- package/dist/oclif/auto-signals.js +9 -9
- package/dist/oclif/index.js +422 -64
- package/dist/oclif/listen-supervisor.js +1 -1
- package/dist/oclif/proxy-auto-detect.js +1 -1
- package/dist/oclif/receiver-heal.js +6 -5
- package/dist/oclif/root-signup-hint.js +7 -4
- package/dist/{repeats-D2xtLium-DmtVD6ol.js → repeats-x4QM2yoG-De3MV3st.js} +92 -34
- package/dist/{scoped-chat-BrLq4dXH.js → scoped-chat-C7cpIxVS.js} +4 -3
- package/dist/{shared-mail-files-SPPcis9g.js → shared-mail-files-MwlVE90c.js} +2 -1
- package/dist/{shared-mail-watch-CWhpfJ0N.js → shared-mail-watch-DtKpsgg8.js} +1 -1
- package/dist/{signal-command-DNAhZicf.js → signal-command-COQff2Vq.js} +23 -343
- package/package.json +16 -16
- package/dist/rolldown-runtime-CNZpIYwj.js +0 -33
|
@@ -1,340 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { n as tryOwnSharedMail, r as waitForSharedMailChange, t as readSharedMailOwner } from "./shared-mail-watch-
|
|
1
|
+
import { h as sendPreparedSignal, p as prepareSignalEmail } from "./repeats-x4QM2yoG-De3MV3st.js";
|
|
2
|
+
import { $t as createEndpoint, Bn as listSentEmails, T as bareAddress, _n as getEmail, bt as successfulSendOutcome, ir as sendEmail, it as classifySendError, o as extractErrorPayload } from "./api-command-0FiEAuQi.js";
|
|
3
|
+
import { _ as acquireListenLock, b as listenProcessIdentity, c as mailTime, d as readMailJson, f as removeMailFile, h as writeMailJson, i as mailId, l as privateMailDirectory, m as withMailLock, n as invalidSharedMail, o as mailObject, p as syncMailDirectory, r as mailAddress, s as mailString, t as SharedMailStateError, v as compareListenProcessIdentity, y as listenIdentity } from "./shared-mail-files-MwlVE90c.js";
|
|
4
|
+
import { a as scopedChatSenderTrust, i as readBeforeDeadline, n as isPlainChatReply } from "./scoped-chat-C7cpIxVS.js";
|
|
5
|
+
import { n as tryOwnSharedMail, r as waitForSharedMailChange, t as readSharedMailOwner } from "./shared-mail-watch-DtKpsgg8.js";
|
|
6
6
|
import { recordSentSignal } from "./oclif/auto-signals.js";
|
|
7
7
|
import { Errors } from "@oclif/core";
|
|
8
8
|
import { opendirSync } from "node:fs";
|
|
9
9
|
import { createHash, randomUUID, scryptSync } from "node:crypto";
|
|
10
10
|
import { dirname, join } from "node:path";
|
|
11
11
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
12
|
-
//#region ../sdk-node/dist/
|
|
13
|
-
/**
|
|
14
|
-
* Load a Node builtin at call time. Exported for direct testing of the
|
|
15
|
-
* unavailable-module error path; production code goes through the typed
|
|
16
|
-
* wrappers below.
|
|
17
|
-
*/
|
|
18
|
-
async function loadBuiltin(specifier, operation) {
|
|
19
|
-
let builtin;
|
|
20
|
-
if (typeof process !== "undefined" && typeof process.getBuiltinModule === "function") try {
|
|
21
|
-
builtin = process.getBuiltinModule(specifier);
|
|
22
|
-
} catch {
|
|
23
|
-
builtin = void 0;
|
|
24
|
-
}
|
|
25
|
-
if (builtin !== void 0 && builtin !== null) return builtin;
|
|
26
|
-
try {
|
|
27
|
-
return await import(specifier);
|
|
28
|
-
} catch (cause) {
|
|
29
|
-
throw new Error(`${operation} requires file system access, which this runtime does not provide. Pass in-memory bytes instead of a file path when running outside Node.js.`, { cause });
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/** `node:fs`, loaded lazily so Workers-style bundles never see the import. */
|
|
33
|
-
function loadNodeFs(operation) {
|
|
34
|
-
return loadBuiltin("node:fs", operation);
|
|
35
|
-
}
|
|
36
|
-
/** `node:fs/promises`, loaded lazily for the same reason as {@link loadNodeFs}. */
|
|
37
|
-
function loadNodeFsPromises(operation) {
|
|
38
|
-
return loadBuiltin("node:fs/promises", operation);
|
|
39
|
-
}
|
|
40
|
-
const CHUNK_SIZE = 64 * 1024 * 1024;
|
|
41
|
-
const MANIFEST_VERSION = 1;
|
|
42
|
-
const CHUNK_KDF_INFO = "payloads-chunk";
|
|
43
|
-
const OBJECT_ID_BYTES = 16;
|
|
44
|
-
const CEK_BYTES = 32;
|
|
45
|
-
function subtle() {
|
|
46
|
-
return globalThis.crypto.subtle;
|
|
47
|
-
}
|
|
48
|
-
const textEncoder = new TextEncoder();
|
|
49
|
-
function randomBytes(length) {
|
|
50
|
-
const out = new Uint8Array(length);
|
|
51
|
-
globalThis.crypto.getRandomValues(out);
|
|
52
|
-
return out;
|
|
53
|
-
}
|
|
54
|
-
function toHex(bytes) {
|
|
55
|
-
let out = "";
|
|
56
|
-
for (const b of bytes) out += b.toString(16).padStart(2, "0");
|
|
57
|
-
return out;
|
|
58
|
-
}
|
|
59
|
-
function fromHex(hex) {
|
|
60
|
-
if (hex.length % 2 !== 0) throw new Error("invalid hex: odd length");
|
|
61
|
-
if (hex.length > 0 && !/^[0-9a-fA-F]+$/.test(hex)) throw new Error("invalid hex: non-hex character");
|
|
62
|
-
const out = new Uint8Array(hex.length / 2);
|
|
63
|
-
for (let i = 0; i < out.length; i++) out[i] = Number.parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
64
|
-
return out;
|
|
65
|
-
}
|
|
66
|
-
async function contentHash(bytes) {
|
|
67
|
-
return new Uint8Array(await subtle().digest("SHA-256", bytes));
|
|
68
|
-
}
|
|
69
|
-
async function contentHashHex(bytes) {
|
|
70
|
-
return toHex(await contentHash(bytes));
|
|
71
|
-
}
|
|
72
|
-
/** Binary Merkle root over ordered hex leaf hashes (odd node promoted). */
|
|
73
|
-
async function merkleRoot(leafHashesHex) {
|
|
74
|
-
if (leafHashesHex.length === 0) return contentHashHex(new Uint8Array(0));
|
|
75
|
-
let level = leafHashesHex.map(fromHex);
|
|
76
|
-
while (level.length > 1) {
|
|
77
|
-
const next = [];
|
|
78
|
-
for (let i = 0; i < level.length; i += 2) {
|
|
79
|
-
const left = level[i];
|
|
80
|
-
const right = i + 1 < level.length ? level[i + 1] : level[i];
|
|
81
|
-
const combined = new Uint8Array(left.length + right.length);
|
|
82
|
-
combined.set(left, 0);
|
|
83
|
-
combined.set(right, left.length);
|
|
84
|
-
next.push(await contentHash(combined));
|
|
85
|
-
}
|
|
86
|
-
level = next;
|
|
87
|
-
}
|
|
88
|
-
return toHex(level[0]);
|
|
89
|
-
}
|
|
90
|
-
async function deriveChunkKey(cek, index) {
|
|
91
|
-
const baseKey = await subtle().importKey("raw", cek, "HKDF", false, ["deriveKey"]);
|
|
92
|
-
const info = textEncoder.encode(`${CHUNK_KDF_INFO}:${index}`);
|
|
93
|
-
return subtle().deriveKey({
|
|
94
|
-
name: "HKDF",
|
|
95
|
-
hash: "SHA-256",
|
|
96
|
-
salt: new Uint8Array(32),
|
|
97
|
-
info
|
|
98
|
-
}, baseKey, {
|
|
99
|
-
name: "AES-GCM",
|
|
100
|
-
length: 256
|
|
101
|
-
}, false, ["encrypt", "decrypt"]);
|
|
102
|
-
}
|
|
103
|
-
function chunkNonce(index) {
|
|
104
|
-
const nonce = new Uint8Array(12);
|
|
105
|
-
new DataView(nonce.buffer).setUint32(8, index >>> 0, false);
|
|
106
|
-
return nonce;
|
|
107
|
-
}
|
|
108
|
-
function chunkAad(objectId, index) {
|
|
109
|
-
const aad = new Uint8Array(objectId.length + 4);
|
|
110
|
-
aad.set(objectId, 0);
|
|
111
|
-
new DataView(aad.buffer).setUint32(objectId.length, index >>> 0, false);
|
|
112
|
-
return aad;
|
|
113
|
-
}
|
|
114
|
-
async function encryptChunk(cek, objectId, index, plaintext) {
|
|
115
|
-
const key = await deriveChunkKey(cek, index);
|
|
116
|
-
const ct = await subtle().encrypt({
|
|
117
|
-
name: "AES-GCM",
|
|
118
|
-
iv: chunkNonce(index),
|
|
119
|
-
additionalData: chunkAad(objectId, index)
|
|
120
|
-
}, key, plaintext);
|
|
121
|
-
return new Uint8Array(ct);
|
|
122
|
-
}
|
|
123
|
-
async function decryptChunk(cek, objectId, index, ciphertext) {
|
|
124
|
-
const key = await deriveChunkKey(cek, index);
|
|
125
|
-
const pt = await subtle().decrypt({
|
|
126
|
-
name: "AES-GCM",
|
|
127
|
-
iv: chunkNonce(index),
|
|
128
|
-
additionalData: chunkAad(objectId, index)
|
|
129
|
-
}, key, ciphertext);
|
|
130
|
-
return new Uint8Array(pt);
|
|
131
|
-
}
|
|
132
|
-
function authHeaders(apiKey) {
|
|
133
|
-
return { authorization: `Bearer ${apiKey}` };
|
|
134
|
-
}
|
|
135
|
-
function apiRoot(baseUrl) {
|
|
136
|
-
let end = baseUrl.length;
|
|
137
|
-
while (end > 0 && baseUrl.charCodeAt(end - 1) === 47) end--;
|
|
138
|
-
return `${baseUrl.slice(0, end)}/v1/payloads`;
|
|
139
|
-
}
|
|
140
|
-
const DEFAULT_MAX_RETRIES = 6;
|
|
141
|
-
const RETRYABLE_STATUS = new Set([
|
|
142
|
-
429,
|
|
143
|
-
500,
|
|
144
|
-
502,
|
|
145
|
-
503,
|
|
146
|
-
504
|
|
147
|
-
]);
|
|
148
|
-
function sleep(ms) {
|
|
149
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* fetch with exponential backoff on transient failures. Request bodies here are
|
|
153
|
-
* in-memory buffers/strings (never streams), so a retry can safely resend them.
|
|
154
|
-
*/
|
|
155
|
-
async function retryingFetch(url, init, label, maxRetries = DEFAULT_MAX_RETRIES) {
|
|
156
|
-
for (let attempt = 0;; attempt++) {
|
|
157
|
-
let res;
|
|
158
|
-
let networkError;
|
|
159
|
-
try {
|
|
160
|
-
res = await fetch(url, init);
|
|
161
|
-
} catch (err) {
|
|
162
|
-
networkError = err;
|
|
163
|
-
}
|
|
164
|
-
if (res && !RETRYABLE_STATUS.has(res.status)) return res;
|
|
165
|
-
if (attempt >= maxRetries) {
|
|
166
|
-
if (res) return res;
|
|
167
|
-
throw new Error(`${label}: network error after ${attempt} retries: ${networkError?.message ?? networkError}`);
|
|
168
|
-
}
|
|
169
|
-
if (res) await res.text().catch(() => {});
|
|
170
|
-
await sleep(Math.min(1e3 * 2 ** attempt, 15e3) + Math.floor(Math.random() * 250));
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
async function initiate(opts, manifest) {
|
|
174
|
-
const res = await retryingFetch(apiRoot(opts.baseUrl), {
|
|
175
|
-
method: "POST",
|
|
176
|
-
headers: {
|
|
177
|
-
...authHeaders(opts.apiKey),
|
|
178
|
-
"content-type": "application/json"
|
|
179
|
-
},
|
|
180
|
-
body: JSON.stringify({ manifest })
|
|
181
|
-
}, "initiate");
|
|
182
|
-
if (!res.ok) throw new Error(`initiate failed: HTTP ${res.status} ${await res.text()}`);
|
|
183
|
-
await res.text();
|
|
184
|
-
}
|
|
185
|
-
async function putChunk(opts, root, d, bytes) {
|
|
186
|
-
const res = await retryingFetch(`${apiRoot(opts.baseUrl)}/${root}/chunks/${d.ciphertextHash}`, {
|
|
187
|
-
method: "PUT",
|
|
188
|
-
headers: {
|
|
189
|
-
...authHeaders(opts.apiKey),
|
|
190
|
-
"content-type": "application/octet-stream"
|
|
191
|
-
},
|
|
192
|
-
body: bytes
|
|
193
|
-
}, `chunk ${d.index} upload`);
|
|
194
|
-
if (!res.ok) throw new Error(`chunk ${d.index} upload failed: HTTP ${res.status} ${await res.text()}`);
|
|
195
|
-
await res.text();
|
|
196
|
-
}
|
|
197
|
-
async function finalize(opts, root) {
|
|
198
|
-
const res = await retryingFetch(`${apiRoot(opts.baseUrl)}/${root}/finalize`, {
|
|
199
|
-
method: "POST",
|
|
200
|
-
headers: authHeaders(opts.apiKey)
|
|
201
|
-
}, "finalize");
|
|
202
|
-
if (!res.ok) throw new Error(`finalize failed: HTTP ${res.status} ${await res.text()}`);
|
|
203
|
-
await res.text();
|
|
204
|
-
}
|
|
205
|
-
async function fetchManifest(opts, root) {
|
|
206
|
-
const res = await retryingFetch(`${apiRoot(opts.baseUrl)}/${root}/manifest`, { headers: authHeaders(opts.apiKey) }, "get manifest");
|
|
207
|
-
if (!res.ok) throw new Error(`get manifest failed: HTTP ${res.status} ${await res.text()}`);
|
|
208
|
-
return (await res.json()).data.manifest;
|
|
209
|
-
}
|
|
210
|
-
async function getChunkBytes(opts, root, d) {
|
|
211
|
-
const res = await retryingFetch(`${apiRoot(opts.baseUrl)}/${root}/chunks/${d.ciphertextHash}`, { headers: authHeaders(opts.apiKey) }, `get chunk ${d.index}`);
|
|
212
|
-
if (!res.ok) throw new Error(`get chunk ${d.index} failed: HTTP ${res.status}`);
|
|
213
|
-
return new Uint8Array(await res.arrayBuffer());
|
|
214
|
-
}
|
|
215
|
-
async function readWindow(fh, position, length) {
|
|
216
|
-
const buf = Buffer.allocUnsafe(length);
|
|
217
|
-
let read = 0;
|
|
218
|
-
while (read < length) {
|
|
219
|
-
const { bytesRead } = await fh.read(buf, read, length - read, position + read);
|
|
220
|
-
if (bytesRead === 0) break;
|
|
221
|
-
read += bytesRead;
|
|
222
|
-
}
|
|
223
|
-
return read === length ? buf : buf.subarray(0, read);
|
|
224
|
-
}
|
|
225
|
-
async function mapLimit(items, limit, fn) {
|
|
226
|
-
let next = 0;
|
|
227
|
-
let firstError;
|
|
228
|
-
const worker = async () => {
|
|
229
|
-
while (next < items.length && firstError === void 0) {
|
|
230
|
-
const i = next++;
|
|
231
|
-
try {
|
|
232
|
-
await fn(items[i], i);
|
|
233
|
-
} catch (err) {
|
|
234
|
-
if (firstError === void 0) firstError = err;
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
await Promise.all(Array.from({ length: Math.min(limit, items.length || 1) }, () => worker()));
|
|
240
|
-
if (firstError !== void 0) throw firstError;
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Stream a file up as a Primitive Payload. Two passes over the file (encrypt to
|
|
244
|
-
* build the manifest, then encrypt again to upload) keep memory bounded to a few
|
|
245
|
-
* chunks — the whole object is never resident. Returns the content address
|
|
246
|
-
* (merkleRoot) and the hex CEK needed to download it.
|
|
247
|
-
*/
|
|
248
|
-
async function pushFile(filePath, opts) {
|
|
249
|
-
const { open, stat } = await loadNodeFsPromises("pushFile");
|
|
250
|
-
const chunkSize = opts.chunkSize ?? CHUNK_SIZE;
|
|
251
|
-
const concurrency = opts.concurrency ?? 3;
|
|
252
|
-
const { size } = await stat(filePath);
|
|
253
|
-
const cek = randomBytes(CEK_BYTES);
|
|
254
|
-
const objectId = randomBytes(OBJECT_ID_BYTES);
|
|
255
|
-
const chunkCount = size === 0 ? 0 : Math.ceil(size / chunkSize);
|
|
256
|
-
const fh = await open(filePath, "r");
|
|
257
|
-
try {
|
|
258
|
-
const descriptors = [];
|
|
259
|
-
for (let index = 0; index < chunkCount; index++) {
|
|
260
|
-
const position = index * chunkSize;
|
|
261
|
-
const length = Math.min(chunkSize, size - position);
|
|
262
|
-
const plaintext = await readWindow(fh, position, length);
|
|
263
|
-
const ciphertext = await encryptChunk(cek, objectId, index, plaintext);
|
|
264
|
-
descriptors.push({
|
|
265
|
-
index,
|
|
266
|
-
ciphertextHash: await contentHashHex(ciphertext),
|
|
267
|
-
plaintextSize: length,
|
|
268
|
-
ciphertextSize: ciphertext.length
|
|
269
|
-
});
|
|
270
|
-
opts.onProgress?.("encrypt", index + 1, chunkCount);
|
|
271
|
-
}
|
|
272
|
-
const root = await merkleRoot(descriptors.map((d) => d.ciphertextHash));
|
|
273
|
-
await initiate(opts, {
|
|
274
|
-
version: MANIFEST_VERSION,
|
|
275
|
-
objectId: toHex(objectId),
|
|
276
|
-
chunkSize,
|
|
277
|
-
totalPlaintextSize: size,
|
|
278
|
-
chunkCount,
|
|
279
|
-
chunks: descriptors,
|
|
280
|
-
merkleRoot: root
|
|
281
|
-
});
|
|
282
|
-
let uploaded = 0;
|
|
283
|
-
await mapLimit(descriptors, concurrency, async (d) => {
|
|
284
|
-
const plaintext = await readWindow(fh, d.index * chunkSize, d.plaintextSize);
|
|
285
|
-
await putChunk(opts, root, d, await encryptChunk(cek, objectId, d.index, plaintext));
|
|
286
|
-
opts.onProgress?.("upload", ++uploaded, chunkCount);
|
|
287
|
-
});
|
|
288
|
-
await finalize(opts, root);
|
|
289
|
-
return {
|
|
290
|
-
merkleRoot: root,
|
|
291
|
-
cek: toHex(cek),
|
|
292
|
-
chunkCount,
|
|
293
|
-
totalBytes: size
|
|
294
|
-
};
|
|
295
|
-
} finally {
|
|
296
|
-
await fh.close();
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Stream a Primitive Payload down to a file, verifying and decrypting one chunk
|
|
301
|
-
* at a time (bounded memory). Every chunk is content-address-checked before
|
|
302
|
-
* decryption, so a corrupt or substituted chunk throws.
|
|
303
|
-
*/
|
|
304
|
-
async function pullFile(root, outPath, opts) {
|
|
305
|
-
const { createWriteStream } = await loadNodeFs("pullFile");
|
|
306
|
-
const { rm } = await loadNodeFsPromises("pullFile");
|
|
307
|
-
const manifest = await fetchManifest(opts, root);
|
|
308
|
-
const computedRoot = await merkleRoot(manifest.chunks.map((c) => c.ciphertextHash));
|
|
309
|
-
if (computedRoot !== root) throw new Error(`manifest does not match the requested content address (got ${computedRoot})`);
|
|
310
|
-
const cek = fromHex(opts.cek);
|
|
311
|
-
const objectId = fromHex(manifest.objectId);
|
|
312
|
-
const out = createWriteStream(outPath);
|
|
313
|
-
let onWriteError = () => {};
|
|
314
|
-
const writeErrored = new Promise((_, reject) => {
|
|
315
|
-
onWriteError = reject;
|
|
316
|
-
});
|
|
317
|
-
writeErrored.catch(() => {});
|
|
318
|
-
out.on("error", (err) => onWriteError(err));
|
|
319
|
-
try {
|
|
320
|
-
let done = 0;
|
|
321
|
-
for (const d of manifest.chunks) {
|
|
322
|
-
const ciphertext = await getChunkBytes(opts, root, d);
|
|
323
|
-
if (await contentHashHex(ciphertext) !== d.ciphertextHash) throw new Error(`chunk ${d.index} failed integrity check`);
|
|
324
|
-
const plaintext = await decryptChunk(cek, objectId, d.index, ciphertext);
|
|
325
|
-
if (!out.write(plaintext)) await Promise.race([new Promise((resolve) => out.once("drain", resolve)), writeErrored]);
|
|
326
|
-
opts.onProgress?.("download", ++done, manifest.chunkCount);
|
|
327
|
-
}
|
|
328
|
-
await Promise.race([new Promise((resolve) => out.end(resolve)), writeErrored]);
|
|
329
|
-
} catch (err) {
|
|
330
|
-
out.destroy();
|
|
331
|
-
await rm(outPath, { force: true });
|
|
332
|
-
throw err;
|
|
333
|
-
}
|
|
334
|
-
return manifest;
|
|
335
|
-
}
|
|
336
|
-
//#endregion
|
|
337
|
-
//#region ../sdk-node/dist/api-DhHWJdMM.js
|
|
12
|
+
//#region ../sdk-node/dist/api-DjB55hB6.js
|
|
338
13
|
const jsonBodySerializer = { bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value) };
|
|
339
14
|
function createSseClient({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) {
|
|
340
15
|
let lastEventId;
|
|
@@ -420,7 +95,8 @@ function createSseClient({ onRequest, onSseError, onSseEvent, responseTransforme
|
|
|
420
95
|
} catch (error) {
|
|
421
96
|
onSseError?.(error);
|
|
422
97
|
if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) break;
|
|
423
|
-
|
|
98
|
+
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
|
|
99
|
+
await sleep(backoff);
|
|
424
100
|
}
|
|
425
101
|
}
|
|
426
102
|
};
|
|
@@ -658,9 +334,7 @@ async function setAuthParams(options) {
|
|
|
658
334
|
case "cookie":
|
|
659
335
|
options.headers.append("Cookie", `${name}=${token}`);
|
|
660
336
|
break;
|
|
661
|
-
default:
|
|
662
|
-
options.headers.set(name, token);
|
|
663
|
-
break;
|
|
337
|
+
default: options.headers.set(name, token);
|
|
664
338
|
}
|
|
665
339
|
}
|
|
666
340
|
}
|
|
@@ -815,9 +489,7 @@ const createClient = (config = {}) => {
|
|
|
815
489
|
case "stream":
|
|
816
490
|
emptyData = response.body;
|
|
817
491
|
break;
|
|
818
|
-
default:
|
|
819
|
-
emptyData = {};
|
|
820
|
-
break;
|
|
492
|
+
default: emptyData = {};
|
|
821
493
|
}
|
|
822
494
|
return opts.responseStyle === "data" ? emptyData : {
|
|
823
495
|
data: emptyData,
|
|
@@ -956,6 +628,9 @@ const completeWebhookEvent = (options) => (options.client ?? client$1).post({
|
|
|
956
628
|
}
|
|
957
629
|
});
|
|
958
630
|
var EventReceiverError = class extends Error {
|
|
631
|
+
code;
|
|
632
|
+
status;
|
|
633
|
+
retryAfterMs;
|
|
959
634
|
constructor(message, code, status = 0, retryAfterMs = 0) {
|
|
960
635
|
super(message);
|
|
961
636
|
this.code = code;
|
|
@@ -993,6 +668,9 @@ function unwrap(result) {
|
|
|
993
668
|
}
|
|
994
669
|
/** Shared by the SDK and CLI. Completion retries preserve the original evidence. */
|
|
995
670
|
var EventConnection = class {
|
|
671
|
+
client;
|
|
672
|
+
endpointId;
|
|
673
|
+
options;
|
|
996
674
|
socket;
|
|
997
675
|
pending;
|
|
998
676
|
origin;
|
|
@@ -1185,7 +863,8 @@ function otherParticipants(detail, self) {
|
|
|
1185
863
|
for (const list of [parsed?.to_addresses, parsed?.cc]) {
|
|
1186
864
|
if (!Array.isArray(list)) continue;
|
|
1187
865
|
for (const entry of list) {
|
|
1188
|
-
const
|
|
866
|
+
const raw = typeof entry === "string" ? entry : entry && typeof entry === "object" ? entry.address : null;
|
|
867
|
+
const address = bareAddress(raw);
|
|
1189
868
|
if (address !== null && address === me) named = true;
|
|
1190
869
|
if (!address || excluded.has(address)) continue;
|
|
1191
870
|
excluded.add(address);
|
|
@@ -1456,7 +1135,8 @@ function validate(path, value) {
|
|
|
1456
1135
|
};
|
|
1457
1136
|
}
|
|
1458
1137
|
if (parts.length === 3 && parts[0] === "unbound" && /^[a-f0-9]{64}$/.test(parts[1] ?? "")) {
|
|
1459
|
-
|
|
1138
|
+
const r = mailObject(value, ["requestId"]);
|
|
1139
|
+
if (mailId(r.requestId) !== id) throw invalidSharedMail();
|
|
1460
1140
|
return { requestId: id };
|
|
1461
1141
|
}
|
|
1462
1142
|
if (parts.length === 3 && parts[0] === "matches") {
|
|
@@ -2409,7 +2089,7 @@ async function reconcileChatSend(params) {
|
|
|
2409
2089
|
}
|
|
2410
2090
|
//#endregion
|
|
2411
2091
|
//#region src/oclif/signal-command.ts
|
|
2412
|
-
const sendStatuses = new Set([
|
|
2092
|
+
const sendStatuses = /* @__PURE__ */ new Set([
|
|
2413
2093
|
"queued",
|
|
2414
2094
|
"submitted_to_agent",
|
|
2415
2095
|
"agent_failed",
|
|
@@ -2545,7 +2225,7 @@ async function sendSignal(context, options) {
|
|
|
2545
2225
|
const release = acquireListenLock(directory, "signal-send");
|
|
2546
2226
|
const path = join(directory, "intent.json"), now = context.now ?? Date.now;
|
|
2547
2227
|
try {
|
|
2548
|
-
const raw = readMailJson(path,
|
|
2228
|
+
const raw = readMailJson(path, 262144);
|
|
2549
2229
|
let state = raw === null ? null : parseState(raw, options, parent);
|
|
2550
2230
|
if (state?.phase === "submitting" || state?.phase === "uncertain") {
|
|
2551
2231
|
let prior;
|
|
@@ -2648,4 +2328,4 @@ async function sendSignal(context, options) {
|
|
|
2648
2328
|
}
|
|
2649
2329
|
}
|
|
2650
2330
|
//#endregion
|
|
2651
|
-
export { ensureSharedMailSubscription as a, reserveSharedMailSubscription as c, otherParticipants as d, EventConnection as f,
|
|
2331
|
+
export { ensureSharedMailSubscription as a, reserveSharedMailSubscription as c, otherParticipants as d, EventConnection as f, sharedMailScope as i, followEmailConversation as l, reconcileChatSend as n, createSharedMailWaiter as o, EventReceiverError as p, openSharedMailReceiver as r, openSharedMailStore as s, sendSignal as t, readConversationFollow as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "primcli",
|
|
3
|
-
"version": "1.55.
|
|
3
|
+
"version": "1.55.1",
|
|
4
4
|
"description": "Official Primitive CLI: deploy Primitive Functions, send and inspect mail, manage endpoints, all from the terminal. Wraps the @primitivedotdev/sdk runtime client with one-shot commands.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -189,25 +189,25 @@
|
|
|
189
189
|
"node": ">=22"
|
|
190
190
|
},
|
|
191
191
|
"dependencies": {
|
|
192
|
-
"@oclif/core": "^
|
|
193
|
-
"@oclif/plugin-autocomplete": "^
|
|
194
|
-
"@oclif/plugin-help": "^
|
|
195
|
-
"@oclif/plugin-warn-if-update-available": "^
|
|
196
|
-
"viem": "^2.
|
|
197
|
-
"ws": "^8.
|
|
192
|
+
"@oclif/core": "^5.1.2",
|
|
193
|
+
"@oclif/plugin-autocomplete": "^4.0.2",
|
|
194
|
+
"@oclif/plugin-help": "^7.0.2",
|
|
195
|
+
"@oclif/plugin-warn-if-update-available": "^4.0.1",
|
|
196
|
+
"viem": "^2.57.2",
|
|
197
|
+
"ws": "^8.22.0"
|
|
198
198
|
},
|
|
199
199
|
"devDependencies": {
|
|
200
|
-
"@biomejs/biome": "^2.
|
|
200
|
+
"@biomejs/biome": "^2.5.15",
|
|
201
201
|
"@primitivedotdev/api-core": "workspace:*",
|
|
202
202
|
"@primitivedotdev/sdk": "workspace:*",
|
|
203
|
-
"@types/node": "^
|
|
204
|
-
"@types/ws": "^8.18.
|
|
205
|
-
"@vitest/coverage-v8": "^
|
|
206
|
-
"oclif": "^
|
|
207
|
-
"tsdown": "^0.
|
|
208
|
-
"tsx": "
|
|
203
|
+
"@types/node": "^26.6.4",
|
|
204
|
+
"@types/ws": "^8.18.2",
|
|
205
|
+
"@vitest/coverage-v8": "^5.0.3",
|
|
206
|
+
"oclif": "^6.0.2",
|
|
207
|
+
"tsdown": "^0.23.0",
|
|
208
|
+
"tsx": "4.23.14",
|
|
209
209
|
"typescript": "^5.7.2",
|
|
210
|
-
"vite": "^8.
|
|
211
|
-
"vitest": "^
|
|
210
|
+
"vite": "^8.3.2",
|
|
211
|
+
"vitest": "^5.0.3"
|
|
212
212
|
}
|
|
213
213
|
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
9
|
-
var __exportAll = (all, no_symbols) => {
|
|
10
|
-
let target = {};
|
|
11
|
-
for (var name in all) __defProp(target, name, {
|
|
12
|
-
get: all[name],
|
|
13
|
-
enumerable: true
|
|
14
|
-
});
|
|
15
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
16
|
-
return target;
|
|
17
|
-
};
|
|
18
|
-
var __copyProps = (to, from, except, desc) => {
|
|
19
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
20
|
-
key = keys[i];
|
|
21
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
22
|
-
get: ((k) => from[k]).bind(null, key),
|
|
23
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
return to;
|
|
27
|
-
};
|
|
28
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
29
|
-
value: mod,
|
|
30
|
-
enumerable: true
|
|
31
|
-
}) : target, mod));
|
|
32
|
-
//#endregion
|
|
33
|
-
export { __exportAll as n, __toESM as r, __commonJSMin as t };
|