primcli 1.45.0 → 1.47.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/README.md +33 -0
- package/bin/claude-pending-mail.mjs +2 -2
- package/bin/claude-wake.mjs +2 -2
- package/dist/{api-command-CpW39SQw.js → api-command-C1JvJqV0.js} +231 -27
- package/dist/{connect-skill-BJFxnbwI.js → connect-skill-CH2pq436.js} +7 -3
- package/dist/machine-session-Dr5W2fHb.js +4754 -0
- package/dist/oclif/auto-signal-worker.js +3 -3
- package/dist/oclif/auto-signals.js +615 -1
- package/dist/oclif/index.js +590 -4668
- package/dist/oclif/listen-supervisor.js +1 -1
- package/dist/oclif/proxy-auto-detect.js +1 -1
- package/dist/oclif/receiver-heal.js +2 -2
- package/dist/{repeats-D2xtLium-Dv34tqei.js → repeats-D2xtLium-DdiJECLI.js} +2 -33
- package/dist/rolldown-runtime-CNZpIYwj.js +33 -0
- package/dist/scoped-chat-DhxtuNXs.js +91 -0
- package/dist/shared-mail-watch-BUfUaq6j.js +145 -0
- package/dist/{signal-command-BbdorL9t.js → signal-command-Dbyqyas9.js} +9 -147
- package/dist/skills/primitive-connect/SKILL.md +97 -31
- package/dist/skills/primitive-connect/references/native-session.md +1 -1
- package/dist/skills/primitive-connect.json +4 -4
- package/package.json +4 -1
- package/dist/auto-signals-oSCnNgts.js +0 -702
- /package/dist/{json-output-CJXNOsUI.js → json-output-Cf-GFeff.js} +0 -0
- /package/dist/{listen-background-TTBqrO_R.js → listen-background-CyLc8VBn.js} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { s as runBackgroundListenSupervisor } from "../listen-background-
|
|
1
|
+
import { s as runBackgroundListenSupervisor } from "../listen-background-CyLc8VBn.js";
|
|
2
2
|
export { runBackgroundListenSupervisor };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { N as agentProfileDirectory, P as agentProfileName, R as loadConnectedAgentProfile, j as AGENT_PROFILE_ENV } from "../cli-config-DGrZCUfw.js";
|
|
2
2
|
import { d as readMailJson } from "../shared-mail-files-SPPcis9g.js";
|
|
3
|
-
import { m as SESSION_UUID, n as detectAgentRuntime, o as notificationScope } from "../connect-skill-
|
|
4
|
-
import { a as claimBackgroundListenRestart, n as backgroundListenRestartable, r as backgroundListenStatus } from "../listen-background-
|
|
3
|
+
import { m as SESSION_UUID, n as detectAgentRuntime, o as notificationScope } from "../connect-skill-CH2pq436.js";
|
|
4
|
+
import { a as claimBackgroundListenRestart, n as backgroundListenRestartable, r as backgroundListenStatus } from "../listen-background-CyLc8VBn.js";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { spawn } from "node:child_process";
|
|
7
7
|
import { homedir } from "node:os";
|
|
@@ -1,35 +1,4 @@
|
|
|
1
|
-
|
|
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
|
|
1
|
+
import { r as __toESM, t as __commonJSMin } from "./rolldown-runtime-CNZpIYwj.js";
|
|
33
2
|
//#region ../node_modules/.pnpm/nodemailer@9.1.1/node_modules/nodemailer/lib/addressparser/index.js
|
|
34
3
|
var require_addressparser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
35
4
|
/**
|
|
@@ -10458,4 +10427,4 @@ function repeatStopCommand(emailId) {
|
|
|
10458
10427
|
return `primitive repeat stop --id ${emailId.toLowerCase()}`;
|
|
10459
10428
|
}
|
|
10460
10429
|
//#endregion
|
|
10461
|
-
export { isTrustedSender as _, REPEAT_IDLE_MAX_MINUTES as a,
|
|
10430
|
+
export { isTrustedSender as _, REPEAT_IDLE_MAX_MINUTES as a, classifySignalContent as c, parseRepeatTick as d, preparePresenceAliveEmail as f, isEmailReceivedEvent as g, sendPreparedSignal as h, REPEAT_EVERY_MAX_MINUTES as i, parseInteractionEnvelope as l, repeatStopCommand as m, MAX_PRESENCE_ENVELOPE_BYTES as n, REPEAT_MAX_SENDS_MAX as o, prepareSignalEmail as p, PRESENCE_PROBE_TEXT as r, buildRepeatStopBody as s, MAX_INTERACTION_BYTES as t, parsePresenceEnvelope as u, parseWebhookEvent as v, parseFromHeader as y };
|
|
@@ -0,0 +1,33 @@
|
|
|
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 };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { _ as isTrustedSender, c as classifySignalContent } from "./repeats-D2xtLium-DdiJECLI.js";
|
|
2
|
+
//#region src/oclif/presence-provenance.ts
|
|
3
|
+
function readPresenceProjection(detail) {
|
|
4
|
+
if (!detail || typeof detail !== "object") return null;
|
|
5
|
+
const value = detail.presence_control;
|
|
6
|
+
if (value === void 0 || value === null) return null;
|
|
7
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return {
|
|
8
|
+
status: "pending",
|
|
9
|
+
valid_for_ms: 0
|
|
10
|
+
};
|
|
11
|
+
const row = value;
|
|
12
|
+
if (![
|
|
13
|
+
"verified",
|
|
14
|
+
"pending",
|
|
15
|
+
"rejected"
|
|
16
|
+
].includes(String(row.status)) || typeof row.valid_for_ms !== "number" || !Number.isSafeInteger(row.valid_for_ms) || row.valid_for_ms < 0 || row.valid_for_ms > 6e5) return {
|
|
17
|
+
status: "pending",
|
|
18
|
+
valid_for_ms: 0
|
|
19
|
+
};
|
|
20
|
+
return row;
|
|
21
|
+
}
|
|
22
|
+
/** Only the authenticated detail projection identifies control mail. */
|
|
23
|
+
function presenceDisposition(detail) {
|
|
24
|
+
const proof = readPresenceProjection(detail);
|
|
25
|
+
return !proof || proof.status === "rejected" ? "ordinary" : proof.status === "verified" ? "quiet" : "pending";
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/oclif/scoped-chat.ts
|
|
29
|
+
function isConnectedChatCredential(apiKey) {
|
|
30
|
+
return apiKey?.startsWith("pconn_") ?? false;
|
|
31
|
+
}
|
|
32
|
+
async function readBeforeDeadline(deadline, read) {
|
|
33
|
+
if (deadline == null) return read(void 0);
|
|
34
|
+
if (Date.now() >= deadline) return null;
|
|
35
|
+
const controller = new AbortController();
|
|
36
|
+
let timer;
|
|
37
|
+
const arm = () => {
|
|
38
|
+
const remaining = Math.max(0, deadline - Date.now());
|
|
39
|
+
const maximumDelay = 2 ** 31 - 1;
|
|
40
|
+
timer = setTimeout(remaining > maximumDelay ? arm : () => controller.abort(), Math.min(remaining, maximumDelay));
|
|
41
|
+
};
|
|
42
|
+
arm();
|
|
43
|
+
try {
|
|
44
|
+
const result = await read(controller.signal);
|
|
45
|
+
return controller.signal.aborted || Date.now() >= deadline ? null : result;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
if (controller.signal.aborted) return null;
|
|
48
|
+
throw error;
|
|
49
|
+
} finally {
|
|
50
|
+
clearTimeout(timer);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function address(value) {
|
|
54
|
+
return value.trim().toLowerCase();
|
|
55
|
+
}
|
|
56
|
+
function isScopedChatReply(detail, params) {
|
|
57
|
+
if (presenceDisposition(detail) !== "ordinary") return false;
|
|
58
|
+
if (!["accepted", "completed"].includes(detail.status) || params.sentId !== void 0 && detail.reply_to_sent_email_id !== params.sentId || address(detail.recipient) !== address(params.from) || address(detail.to_email) !== address(params.from)) return false;
|
|
59
|
+
return scopedChatSenderTrust(detail, params.recipient).trusted;
|
|
60
|
+
}
|
|
61
|
+
function scopedChatSenderTrust(detail, peer) {
|
|
62
|
+
const sender = address(peer);
|
|
63
|
+
return isTrustedSender({ email: {
|
|
64
|
+
auth: detail.auth,
|
|
65
|
+
headers: { from: detail.from_header }
|
|
66
|
+
} }, {
|
|
67
|
+
sender,
|
|
68
|
+
domain: sender.slice(sender.lastIndexOf("@") + 1)
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function isPlainChatReply(detail) {
|
|
72
|
+
if (presenceDisposition(detail) !== "ordinary") return false;
|
|
73
|
+
if (detail.parsed?.status !== "complete" || !Array.isArray(detail.parsed.attachments)) return false;
|
|
74
|
+
return classifySignalContent({
|
|
75
|
+
inventory: {
|
|
76
|
+
status: "complete",
|
|
77
|
+
parts: detail.parsed.attachments.map((part) => ({
|
|
78
|
+
filename: part.filename ?? null,
|
|
79
|
+
contentType: part.content_type ?? null
|
|
80
|
+
}))
|
|
81
|
+
},
|
|
82
|
+
bodies: {
|
|
83
|
+
status: "complete",
|
|
84
|
+
text: detail.body_text ?? null,
|
|
85
|
+
html: detail.body_html ?? null
|
|
86
|
+
},
|
|
87
|
+
canonicalPartBytes: null
|
|
88
|
+
}).classification === "plain";
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
export { scopedChatSenderTrust as a, readBeforeDeadline as i, isPlainChatReply as n, presenceDisposition as o, isScopedChatReply as r, readPresenceProjection as s, isConnectedChatCredential as t };
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { _ as acquireListenLock, a as mailLockBusy, b as listenProcessIdentity, c as mailTime, d as readMailJson, f as removeMailFile, h as writeMailJson, i as mailId, n as invalidSharedMail, o as mailObject, s as mailString, v as compareListenProcessIdentity } from "./shared-mail-files-SPPcis9g.js";
|
|
2
|
+
import { watch } from "node:fs";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
//#region src/oclif/shared-mail-watch.ts
|
|
6
|
+
function ownerRecord(value) {
|
|
7
|
+
const o = mailObject(value, [
|
|
8
|
+
"generation",
|
|
9
|
+
"pid",
|
|
10
|
+
"identity",
|
|
11
|
+
"ready",
|
|
12
|
+
"gapCount",
|
|
13
|
+
"lastGapReason",
|
|
14
|
+
...value && typeof value === "object" && Object.hasOwn(value, "lastMailCheckAt") ? ["lastMailCheckAt"] : []
|
|
15
|
+
]);
|
|
16
|
+
if (typeof o.pid !== "number" || !Number.isSafeInteger(o.pid) || o.pid < 1 || typeof o.ready !== "boolean" || typeof o.gapCount !== "number" || !Number.isSafeInteger(o.gapCount) || o.gapCount < 0) throw invalidSharedMail();
|
|
17
|
+
return {
|
|
18
|
+
generation: mailId(o.generation),
|
|
19
|
+
pid: o.pid,
|
|
20
|
+
identity: mailString(o.identity),
|
|
21
|
+
ready: o.ready,
|
|
22
|
+
gapCount: o.gapCount,
|
|
23
|
+
lastGapReason: o.lastGapReason === null ? null : mailString(o.lastGapReason, 100),
|
|
24
|
+
lastMailCheckAt: o.lastMailCheckAt === void 0 || o.lastMailCheckAt === null ? null : mailTime(o.lastMailCheckAt)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function readSharedMailOwner(store) {
|
|
28
|
+
const raw = readMailJson(join(store.directory, "owner.json"));
|
|
29
|
+
if (raw === null) return null;
|
|
30
|
+
const owner = ownerRecord(raw);
|
|
31
|
+
return {
|
|
32
|
+
...owner,
|
|
33
|
+
alive: compareListenProcessIdentity(owner.identity, listenProcessIdentity(owner.pid)) === true
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** The caller stays in the foreground and owns the only remote stream until close. */
|
|
37
|
+
function tryOwnSharedMail(store) {
|
|
38
|
+
let release;
|
|
39
|
+
try {
|
|
40
|
+
release = acquireListenLock(store.directory, "shared-mail-stream");
|
|
41
|
+
} catch (error) {
|
|
42
|
+
if (mailLockBusy(error)) return null;
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
const path = join(store.directory, "owner.json"), identity = listenProcessIdentity(process.pid);
|
|
46
|
+
if (identity === null) {
|
|
47
|
+
release();
|
|
48
|
+
throw invalidSharedMail();
|
|
49
|
+
}
|
|
50
|
+
let current = {
|
|
51
|
+
generation: randomUUID(),
|
|
52
|
+
pid: process.pid,
|
|
53
|
+
identity,
|
|
54
|
+
ready: false,
|
|
55
|
+
gapCount: 0,
|
|
56
|
+
lastGapReason: null,
|
|
57
|
+
lastMailCheckAt: null
|
|
58
|
+
};
|
|
59
|
+
let closed = false;
|
|
60
|
+
try {
|
|
61
|
+
writeMailJson(path, current);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
release();
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
const markStatus = (status) => {
|
|
67
|
+
if (closed) throw invalidSharedMail();
|
|
68
|
+
const existing = readMailJson(path);
|
|
69
|
+
if (existing === null || ownerRecord(existing).generation !== current.generation) throw invalidSharedMail();
|
|
70
|
+
const next = ownerRecord({
|
|
71
|
+
...current,
|
|
72
|
+
...status
|
|
73
|
+
});
|
|
74
|
+
if (next.gapCount < current.gapCount) throw invalidSharedMail();
|
|
75
|
+
writeMailJson(path, next);
|
|
76
|
+
current = next;
|
|
77
|
+
};
|
|
78
|
+
return {
|
|
79
|
+
generation: current.generation,
|
|
80
|
+
markReady(status = {}) {
|
|
81
|
+
markStatus({
|
|
82
|
+
...status,
|
|
83
|
+
ready: true
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
markStatus,
|
|
87
|
+
markChecked() {
|
|
88
|
+
markStatus({ lastMailCheckAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
89
|
+
},
|
|
90
|
+
close() {
|
|
91
|
+
if (closed) return;
|
|
92
|
+
closed = true;
|
|
93
|
+
try {
|
|
94
|
+
const existing = readMailJson(path);
|
|
95
|
+
if (existing !== null && ownerRecord(existing).generation === current.generation) removeMailFile(path);
|
|
96
|
+
} finally {
|
|
97
|
+
release();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** Install before reading state. Watches are hints; timeout reconciles local records only. */
|
|
103
|
+
function waitForSharedMailChange(store, options) {
|
|
104
|
+
const timeoutMs = options.timeoutMs ?? 1e3;
|
|
105
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs < 1 || timeoutMs > 6e4) throw new RangeError("Shared mail reconciliation delay must be between 1 and 60000 milliseconds.");
|
|
106
|
+
return new Promise((resolve, reject) => {
|
|
107
|
+
const watchers = [];
|
|
108
|
+
let timer;
|
|
109
|
+
let done = false;
|
|
110
|
+
const finish = (error) => {
|
|
111
|
+
if (done) return;
|
|
112
|
+
done = true;
|
|
113
|
+
clearTimeout(timer);
|
|
114
|
+
options.signal.removeEventListener("abort", abort);
|
|
115
|
+
for (const watcher of watchers) watcher.close();
|
|
116
|
+
if (error !== void 0) reject(error);
|
|
117
|
+
else resolve();
|
|
118
|
+
};
|
|
119
|
+
const abort = () => finish(options.signal.reason ?? /* @__PURE__ */ new Error("Shared mail wait aborted."));
|
|
120
|
+
options.signal.addEventListener("abort", abort, { once: true });
|
|
121
|
+
if (options.signal.aborted) {
|
|
122
|
+
abort();
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
try {
|
|
126
|
+
for (const path of [
|
|
127
|
+
store.directory,
|
|
128
|
+
join(store.directory, "emails"),
|
|
129
|
+
join(store.directory, "waits")
|
|
130
|
+
]) {
|
|
131
|
+
const watcher = watch(path, (_event, filename) => {
|
|
132
|
+
const name = filename?.toString();
|
|
133
|
+
if (name && (path === store.directory ? name === "owner.json" : name.endsWith(".json") && !name.startsWith(".write-"))) finish();
|
|
134
|
+
});
|
|
135
|
+
watchers.push(watcher);
|
|
136
|
+
watcher.on("error", () => finish());
|
|
137
|
+
}
|
|
138
|
+
timer = setTimeout(() => finish(), timeoutMs);
|
|
139
|
+
} catch (error) {
|
|
140
|
+
finish(error);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
//#endregion
|
|
145
|
+
export { tryOwnSharedMail as n, waitForSharedMailChange as r, readSharedMailOwner as t };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { Bt as createEndpoint, Dn as listSentEmails, Gn as sendEmail, T as bareAddress, in as getEmail, mt as successfulSendOutcome, o as extractErrorPayload, tt as classifySendError } from "./api-command-C1JvJqV0.js";
|
|
2
|
+
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-SPPcis9g.js";
|
|
3
|
+
import { h as sendPreparedSignal, p as prepareSignalEmail } from "./repeats-D2xtLium-DdiJECLI.js";
|
|
4
|
+
import { n as tryOwnSharedMail, r as waitForSharedMailChange, t as readSharedMailOwner } from "./shared-mail-watch-BUfUaq6j.js";
|
|
5
|
+
import { a as scopedChatSenderTrust, i as readBeforeDeadline, n as isPlainChatReply } from "./scoped-chat-DhxtuNXs.js";
|
|
6
|
+
import { recordSentSignal } from "./oclif/auto-signals.js";
|
|
5
7
|
import { Errors } from "@oclif/core";
|
|
6
|
-
import { opendirSync
|
|
8
|
+
import { opendirSync } from "node:fs";
|
|
7
9
|
import { createHash, randomUUID, scryptSync } from "node:crypto";
|
|
8
10
|
import { dirname, join } from "node:path";
|
|
9
11
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
@@ -332,7 +334,7 @@ async function pullFile(root, outPath, opts) {
|
|
|
332
334
|
return manifest;
|
|
333
335
|
}
|
|
334
336
|
//#endregion
|
|
335
|
-
//#region ../sdk-node/dist/api-
|
|
337
|
+
//#region ../sdk-node/dist/api-DhmH89R-.js
|
|
336
338
|
const jsonBodySerializer = { bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value) };
|
|
337
339
|
function createSseClient({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) {
|
|
338
340
|
let lastEventId;
|
|
@@ -1158,146 +1160,6 @@ var EventConnection = class {
|
|
|
1158
1160
|
}
|
|
1159
1161
|
};
|
|
1160
1162
|
//#endregion
|
|
1161
|
-
//#region src/oclif/shared-mail-watch.ts
|
|
1162
|
-
function ownerRecord(value) {
|
|
1163
|
-
const o = mailObject(value, [
|
|
1164
|
-
"generation",
|
|
1165
|
-
"pid",
|
|
1166
|
-
"identity",
|
|
1167
|
-
"ready",
|
|
1168
|
-
"gapCount",
|
|
1169
|
-
"lastGapReason",
|
|
1170
|
-
...value && typeof value === "object" && Object.hasOwn(value, "lastMailCheckAt") ? ["lastMailCheckAt"] : []
|
|
1171
|
-
]);
|
|
1172
|
-
if (typeof o.pid !== "number" || !Number.isSafeInteger(o.pid) || o.pid < 1 || typeof o.ready !== "boolean" || typeof o.gapCount !== "number" || !Number.isSafeInteger(o.gapCount) || o.gapCount < 0) throw invalidSharedMail();
|
|
1173
|
-
return {
|
|
1174
|
-
generation: mailId(o.generation),
|
|
1175
|
-
pid: o.pid,
|
|
1176
|
-
identity: mailString(o.identity),
|
|
1177
|
-
ready: o.ready,
|
|
1178
|
-
gapCount: o.gapCount,
|
|
1179
|
-
lastGapReason: o.lastGapReason === null ? null : mailString(o.lastGapReason, 100),
|
|
1180
|
-
lastMailCheckAt: o.lastMailCheckAt === void 0 || o.lastMailCheckAt === null ? null : mailTime(o.lastMailCheckAt)
|
|
1181
|
-
};
|
|
1182
|
-
}
|
|
1183
|
-
function readSharedMailOwner(store) {
|
|
1184
|
-
const raw = readMailJson(join(store.directory, "owner.json"));
|
|
1185
|
-
if (raw === null) return null;
|
|
1186
|
-
const owner = ownerRecord(raw);
|
|
1187
|
-
return {
|
|
1188
|
-
...owner,
|
|
1189
|
-
alive: compareListenProcessIdentity(owner.identity, listenProcessIdentity(owner.pid)) === true
|
|
1190
|
-
};
|
|
1191
|
-
}
|
|
1192
|
-
/** The caller stays in the foreground and owns the only remote stream until close. */
|
|
1193
|
-
function tryOwnSharedMail(store) {
|
|
1194
|
-
let release;
|
|
1195
|
-
try {
|
|
1196
|
-
release = acquireListenLock(store.directory, "shared-mail-stream");
|
|
1197
|
-
} catch (error) {
|
|
1198
|
-
if (mailLockBusy(error)) return null;
|
|
1199
|
-
throw error;
|
|
1200
|
-
}
|
|
1201
|
-
const path = join(store.directory, "owner.json"), identity = listenProcessIdentity(process.pid);
|
|
1202
|
-
if (identity === null) {
|
|
1203
|
-
release();
|
|
1204
|
-
throw invalidSharedMail();
|
|
1205
|
-
}
|
|
1206
|
-
let current = {
|
|
1207
|
-
generation: randomUUID(),
|
|
1208
|
-
pid: process.pid,
|
|
1209
|
-
identity,
|
|
1210
|
-
ready: false,
|
|
1211
|
-
gapCount: 0,
|
|
1212
|
-
lastGapReason: null,
|
|
1213
|
-
lastMailCheckAt: null
|
|
1214
|
-
};
|
|
1215
|
-
let closed = false;
|
|
1216
|
-
try {
|
|
1217
|
-
writeMailJson(path, current);
|
|
1218
|
-
} catch (error) {
|
|
1219
|
-
release();
|
|
1220
|
-
throw error;
|
|
1221
|
-
}
|
|
1222
|
-
const markStatus = (status) => {
|
|
1223
|
-
if (closed) throw invalidSharedMail();
|
|
1224
|
-
const existing = readMailJson(path);
|
|
1225
|
-
if (existing === null || ownerRecord(existing).generation !== current.generation) throw invalidSharedMail();
|
|
1226
|
-
const next = ownerRecord({
|
|
1227
|
-
...current,
|
|
1228
|
-
...status
|
|
1229
|
-
});
|
|
1230
|
-
if (next.gapCount < current.gapCount) throw invalidSharedMail();
|
|
1231
|
-
writeMailJson(path, next);
|
|
1232
|
-
current = next;
|
|
1233
|
-
};
|
|
1234
|
-
return {
|
|
1235
|
-
generation: current.generation,
|
|
1236
|
-
markReady(status = {}) {
|
|
1237
|
-
markStatus({
|
|
1238
|
-
...status,
|
|
1239
|
-
ready: true
|
|
1240
|
-
});
|
|
1241
|
-
},
|
|
1242
|
-
markStatus,
|
|
1243
|
-
markChecked() {
|
|
1244
|
-
markStatus({ lastMailCheckAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
1245
|
-
},
|
|
1246
|
-
close() {
|
|
1247
|
-
if (closed) return;
|
|
1248
|
-
closed = true;
|
|
1249
|
-
try {
|
|
1250
|
-
const existing = readMailJson(path);
|
|
1251
|
-
if (existing !== null && ownerRecord(existing).generation === current.generation) removeMailFile(path);
|
|
1252
|
-
} finally {
|
|
1253
|
-
release();
|
|
1254
|
-
}
|
|
1255
|
-
}
|
|
1256
|
-
};
|
|
1257
|
-
}
|
|
1258
|
-
/** Install before reading state. Watches are hints; timeout reconciles local records only. */
|
|
1259
|
-
function waitForSharedMailChange(store, options) {
|
|
1260
|
-
const timeoutMs = options.timeoutMs ?? 1e3;
|
|
1261
|
-
if (!Number.isFinite(timeoutMs) || timeoutMs < 1 || timeoutMs > 6e4) throw new RangeError("Shared mail reconciliation delay must be between 1 and 60000 milliseconds.");
|
|
1262
|
-
return new Promise((resolve, reject) => {
|
|
1263
|
-
const watchers = [];
|
|
1264
|
-
let timer;
|
|
1265
|
-
let done = false;
|
|
1266
|
-
const finish = (error) => {
|
|
1267
|
-
if (done) return;
|
|
1268
|
-
done = true;
|
|
1269
|
-
clearTimeout(timer);
|
|
1270
|
-
options.signal.removeEventListener("abort", abort);
|
|
1271
|
-
for (const watcher of watchers) watcher.close();
|
|
1272
|
-
if (error !== void 0) reject(error);
|
|
1273
|
-
else resolve();
|
|
1274
|
-
};
|
|
1275
|
-
const abort = () => finish(options.signal.reason ?? /* @__PURE__ */ new Error("Shared mail wait aborted."));
|
|
1276
|
-
options.signal.addEventListener("abort", abort, { once: true });
|
|
1277
|
-
if (options.signal.aborted) {
|
|
1278
|
-
abort();
|
|
1279
|
-
return;
|
|
1280
|
-
}
|
|
1281
|
-
try {
|
|
1282
|
-
for (const path of [
|
|
1283
|
-
store.directory,
|
|
1284
|
-
join(store.directory, "emails"),
|
|
1285
|
-
join(store.directory, "waits")
|
|
1286
|
-
]) {
|
|
1287
|
-
const watcher = watch(path, (_event, filename) => {
|
|
1288
|
-
const name = filename?.toString();
|
|
1289
|
-
if (name && (path === store.directory ? name === "owner.json" : name.endsWith(".json") && !name.startsWith(".write-"))) finish();
|
|
1290
|
-
});
|
|
1291
|
-
watchers.push(watcher);
|
|
1292
|
-
watcher.on("error", () => finish());
|
|
1293
|
-
}
|
|
1294
|
-
timer = setTimeout(() => finish(), timeoutMs);
|
|
1295
|
-
} catch (error) {
|
|
1296
|
-
finish(error);
|
|
1297
|
-
}
|
|
1298
|
-
});
|
|
1299
|
-
}
|
|
1300
|
-
//#endregion
|
|
1301
1163
|
//#region src/oclif/email-participants.ts
|
|
1302
1164
|
/**
|
|
1303
1165
|
* Everyone else an email was addressed to: its parsed To and Cc, as bare
|
|
@@ -2786,4 +2648,4 @@ async function sendSignal(context, options) {
|
|
|
2786
2648
|
}
|
|
2787
2649
|
}
|
|
2788
2650
|
//#endregion
|
|
2789
|
-
export { ensureSharedMailSubscription as a, reserveSharedMailSubscription as c, otherParticipants as d,
|
|
2651
|
+
export { ensureSharedMailSubscription as a, reserveSharedMailSubscription as c, otherParticipants as d, EventConnection as f, pushFile as h, sharedMailScope as i, followEmailConversation as l, pullFile as m, reconcileChatSend as n, createSharedMailWaiter as o, EventReceiverError as p, openSharedMailReceiver as r, openSharedMailStore as s, sendSignal as t, readConversationFollow as u };
|