@yoonion/mimi-seed-mcp 0.25.3 → 0.25.5
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 +2 -1
- package/assets/agent-guide.md +37 -9
- package/dist/auth/cli.js +2 -2
- package/dist/auth/constants.js +4 -3
- package/dist/auth/errors.js +4 -1
- package/dist/auth/google-auth.d.ts +14 -0
- package/dist/auth/google-auth.js +19 -1
- package/dist/core/console-url.d.ts +17 -2
- package/dist/core/console-url.js +54 -16
- package/dist/core/credential-store.js +2 -0
- package/dist/crosspost/ledger.d.ts +52 -0
- package/dist/crosspost/ledger.js +269 -0
- package/dist/crosspost/tools.d.ts +136 -0
- package/dist/crosspost/tools.js +821 -0
- package/dist/drive/tools.d.ts +0 -1
- package/dist/drive/tools.js +19 -1
- package/dist/facebook/api.d.ts +3 -2
- package/dist/facebook/api.js +6 -2
- package/dist/i18n/manifest-en.js +3 -0
- package/dist/i18n/tools-en/android.d.ts +2 -2
- package/dist/i18n/tools-en/android.js +2 -2
- package/dist/i18n/tools-en/crosspost.d.ts +23 -0
- package/dist/i18n/tools-en/crosspost.js +22 -0
- package/dist/i18n/tools-en/index.js +2 -0
- package/dist/i18n/tools-en/jenkins.d.ts +4 -4
- package/dist/i18n/tools-en/jenkins.js +4 -4
- package/dist/instagram/api.d.ts +3 -2
- package/dist/instagram/api.js +6 -2
- package/dist/instagram/browser-login.js +2 -5
- package/dist/jenkins/credentials.d.ts +7 -3
- package/dist/jenkins/credentials.js +4 -0
- package/dist/jenkins/messages.d.ts +2 -0
- package/dist/jenkins/messages.js +15 -0
- package/dist/lib/human-approval.d.ts +1 -1
- package/dist/lib/human-approval.js +4 -3
- package/dist/lib/meta-auth.d.ts +9 -0
- package/dist/lib/meta-auth.js +12 -3
- package/dist/lib/tool-menu.js +2 -1
- package/dist/lib/tool-registrar.js +13 -5
- package/dist/registers/android.js +10 -7
- package/dist/registers/auth.js +11 -5
- package/dist/registers/crosspost.d.ts +2 -0
- package/dist/registers/crosspost.js +81 -0
- package/dist/registers/jenkins.js +20 -8
- package/dist/remote-sync.js +8 -4
- package/dist/server.js +2 -0
- package/dist/social/broker-base.d.ts +7 -0
- package/dist/social/broker-base.js +11 -0
- package/dist/social/meta-app-config.d.ts +19 -0
- package/dist/social/meta-app-config.js +83 -0
- package/dist/social/meta-direct-login.d.ts +45 -0
- package/dist/social/meta-direct-login.js +307 -0
- package/dist/social/setup-cli.js +228 -20
- package/dist/threads/api.d.ts +4 -3
- package/dist/threads/api.js +9 -7
- package/dist/threads/browser-login.js +2 -5
- package/dist/tiktok-business/posting.d.ts +11 -1
- package/dist/tiktok-business/posting.js +18 -1
- package/dist/video/youtube-publish.d.ts +41 -1
- package/dist/video/youtube-publish.js +16 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/tool-manifest.json +28 -8
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
// social_publish's at-most-once records.
|
|
2
|
+
//
|
|
3
|
+
// ~/.mimi-seed/social-publish/targets/<sha256(platform:postKey)>.json one per **post** (platform + account +
|
|
4
|
+
// exact content): { state, at, id?, url?, error?,
|
|
5
|
+
// settledAttempt? }
|
|
6
|
+
// ~/.mimi-seed/social-publish/accounts/<sha256(platform:account)>.json one per **account** while a send to it is
|
|
7
|
+
// unresolved: { postKey, state, at, attempt? }
|
|
8
|
+
// ~/.mimi-seed/social-publish/accounts/<sha256(platform:account)>.lock/ held while publishing to that account
|
|
9
|
+
//
|
|
10
|
+
// The account marker exists from just before a publishing call until its outcome is known. A `sending` or `unknown`
|
|
11
|
+
// marker blocks every post to that account — even edited content — until a person checks the platform and passes
|
|
12
|
+
// markPosted (it is live) or resendUnknown (it is not), so a post whose outcome is unknown can never go out a second
|
|
13
|
+
// time in another form.
|
|
14
|
+
// Not a credential, but it lives under ~/.mimi-seed and uses the same atomic 0600 writer. This module is its only
|
|
15
|
+
// writer.
|
|
16
|
+
import fs from 'node:fs';
|
|
17
|
+
import os from 'node:os';
|
|
18
|
+
import path from 'node:path';
|
|
19
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
20
|
+
import { CREDENTIAL_DIR_MODE, writeCredentialFile, writeCredentialJson } from '#core/atomic-write.js';
|
|
21
|
+
import { readCredentialFileSync } from '#core/credential-read.js';
|
|
22
|
+
import { catalog } from '#core/lang.js';
|
|
23
|
+
const M = catalog({
|
|
24
|
+
unreadable: (file) => `게시 기록 파일을 읽을 수 없어 이미 게시됐는지 판단할 수 없습니다: ${file}. 파일을 확인한 뒤 다시 시도하세요.`,
|
|
25
|
+
inProgress: '이 계정에 지금 다른 호출이 게시하고 있습니다. 끝난 뒤 다시 보내세요 — 이미 게시된 곳은 건너뜁니다.',
|
|
26
|
+
deadBreaker: (dir) => `이전 실행이 잠금 정리 도중 종료되어 표시가 남았습니다. 다른 게시가 진행 중이 아니라면 ${dir} 폴더를 지우고 다시 보내세요.`,
|
|
27
|
+
}, {
|
|
28
|
+
unreadable: (file) => `Cannot read the publish record, so it is unknown whether this was already posted: ${file}. Check the file, then try again.`,
|
|
29
|
+
inProgress: 'Another call is publishing to this account right now. Send again once it finishes — whatever it posted is skipped.',
|
|
30
|
+
deadBreaker: (dir) => `An earlier run stopped while clearing a lock and left a marker behind. If nothing else is publishing, delete the folder ${dir} and send again.`,
|
|
31
|
+
});
|
|
32
|
+
/** Without a heartbeat for this long, a lock's owner is gone (it refreshes the lock every HEARTBEAT_MS). */
|
|
33
|
+
const STALE_LOCK_MS = 30 * 60 * 1000;
|
|
34
|
+
const HEARTBEAT_MS = 60 * 1000;
|
|
35
|
+
/** A breaker held longer than this belongs to a process that died while replacing a stale lock (it takes ms). */
|
|
36
|
+
const STALE_BREAKER_MS = 60 * 1000;
|
|
37
|
+
function root() {
|
|
38
|
+
return path.join(os.homedir(), '.mimi-seed', 'social-publish');
|
|
39
|
+
}
|
|
40
|
+
function hashed(dir, platform, id) {
|
|
41
|
+
return path.join(root(), dir, createHash('sha256').update(`${platform}:${id}`).digest('hex'));
|
|
42
|
+
}
|
|
43
|
+
export function recordPath(platform, postKey) {
|
|
44
|
+
return `${hashed('targets', platform, postKey)}.json`;
|
|
45
|
+
}
|
|
46
|
+
function pendingPath(platform, account) {
|
|
47
|
+
return `${hashed('accounts', platform, account)}.json`;
|
|
48
|
+
}
|
|
49
|
+
function lockPath(platform, account) {
|
|
50
|
+
return `${hashed('accounts', platform, account)}.lock`;
|
|
51
|
+
}
|
|
52
|
+
/** Missing → null. Unreadable → throw: treating it as missing could post again what it recorded. */
|
|
53
|
+
function readJsonRecord(file, valid) {
|
|
54
|
+
if (!fs.existsSync(file))
|
|
55
|
+
return null;
|
|
56
|
+
let parsed;
|
|
57
|
+
try {
|
|
58
|
+
parsed = JSON.parse(readCredentialFileSync(file));
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
throw new Error(M().unreadable(file), { cause: error });
|
|
62
|
+
}
|
|
63
|
+
if (!parsed || typeof parsed !== 'object' || !valid(parsed))
|
|
64
|
+
throw new Error(M().unreadable(file));
|
|
65
|
+
return parsed;
|
|
66
|
+
}
|
|
67
|
+
export function readRecord(platform, postKey) {
|
|
68
|
+
return readJsonRecord(recordPath(platform, postKey), (r) => typeof r.state === 'string' && typeof r.at === 'string');
|
|
69
|
+
}
|
|
70
|
+
export function writeRecord(platform, postKey, record) {
|
|
71
|
+
writeCredentialJson(recordPath(platform, postKey), record);
|
|
72
|
+
}
|
|
73
|
+
export function readPending(platform, account) {
|
|
74
|
+
return readJsonRecord(pendingPath(platform, account), (r) => typeof r.postKey === 'string' && (r.state === 'sending' || r.state === 'unknown') && typeof r.at === 'string'
|
|
75
|
+
&& (r.attempt === undefined || typeof r.attempt === 'string'));
|
|
76
|
+
}
|
|
77
|
+
export function writePending(platform, account, pending) {
|
|
78
|
+
writeCredentialJson(pendingPath(platform, account), pending);
|
|
79
|
+
}
|
|
80
|
+
export function clearPending(platform, account) {
|
|
81
|
+
fs.rmSync(pendingPath(platform, account), { force: true });
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Compare-and-set on the account marker: replace it with `next` (or remove it, for null) only if it is still the
|
|
85
|
+
* one this send wrote (same postKey, `at`, and attempt). Returns false — and changes nothing — when another call has replaced
|
|
86
|
+
* it meanwhile (possible only after this call's lock went stale), so one call's outcome never erases another's.
|
|
87
|
+
*/
|
|
88
|
+
export function replacePendingIfOurs(platform, account, ours, next) {
|
|
89
|
+
const current = readPending(platform, account);
|
|
90
|
+
if (!current || current.postKey !== ours.postKey || current.at !== ours.at || current.attempt !== ours.attempt)
|
|
91
|
+
return false;
|
|
92
|
+
if (next)
|
|
93
|
+
writePending(platform, account, next);
|
|
94
|
+
else
|
|
95
|
+
clearPending(platform, account);
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
// ── account lock ─────────────────────────────────────────────────────────────
|
|
99
|
+
/** Locks this process holds right now. A lock naming our pid that is not here was left by an earlier run. */
|
|
100
|
+
const heldHere = new Set();
|
|
101
|
+
const isCode = (error, code) => error.code === code;
|
|
102
|
+
/** The owner file holds "<pid> <token>": the pid says whether the holder is alive, the token which acquisition it is. */
|
|
103
|
+
function readOwner(lock) {
|
|
104
|
+
try {
|
|
105
|
+
const [pidText, token = ''] = readCredentialFileSync(path.join(lock, 'owner')).trim().split(' ');
|
|
106
|
+
const pid = Number(pidText);
|
|
107
|
+
return Number.isInteger(pid) && pid > 0 ? { pid, token } : null;
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
// No owner file: one caught between mkdir and the owner write. Decided by age instead.
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function lockOwner(lock) {
|
|
115
|
+
return readOwner(lock)?.pid ?? null;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* 'missing' (released meanwhile), true (its owner is gone), or false (in use). A holder refreshes the lock's mtime
|
|
119
|
+
* every minute, so a lock not refreshed for STALE_LOCK_MS is stale whatever its pid says (pids are reused).
|
|
120
|
+
*/
|
|
121
|
+
function lockState(lock) {
|
|
122
|
+
let age;
|
|
123
|
+
try {
|
|
124
|
+
age = Date.now() - fs.statSync(lock).mtimeMs;
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
if (isCode(error, 'ENOENT'))
|
|
128
|
+
return 'missing';
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
if (age >= STALE_LOCK_MS)
|
|
132
|
+
return true;
|
|
133
|
+
const pid = lockOwner(lock);
|
|
134
|
+
if (pid === null)
|
|
135
|
+
return false;
|
|
136
|
+
// Our own pid: ours only if we hold it now. Otherwise an earlier run of this server, with the same pid, died.
|
|
137
|
+
if (pid === process.pid)
|
|
138
|
+
return !heldHere.has(lock);
|
|
139
|
+
try {
|
|
140
|
+
process.kill(pid, 0);
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
// EPERM: the process exists but belongs to someone else — still in use. ESRCH: gone.
|
|
145
|
+
return !isCode(error, 'EPERM');
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function takeLock(lock) {
|
|
149
|
+
fs.mkdirSync(lock, { mode: CREDENTIAL_DIR_MODE });
|
|
150
|
+
// A pid alone cannot tell two acquisitions in this same process apart (e.g. after a long suspend, another call
|
|
151
|
+
// here judged this lock stale and took it): the token can.
|
|
152
|
+
const token = randomUUID();
|
|
153
|
+
const ours = () => {
|
|
154
|
+
const owner = readOwner(lock);
|
|
155
|
+
return owner?.pid === process.pid && owner.token === token;
|
|
156
|
+
};
|
|
157
|
+
try {
|
|
158
|
+
writeCredentialFile(path.join(lock, 'owner'), `${process.pid} ${token}`);
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
// Without the owner file the lock would block this account until it ages out; drop it before rethrowing.
|
|
162
|
+
fs.rmSync(lock, { recursive: true, force: true });
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
165
|
+
heldHere.add(lock);
|
|
166
|
+
const refresh = () => {
|
|
167
|
+
const now = new Date();
|
|
168
|
+
fs.utimesSync(lock, now, now);
|
|
169
|
+
};
|
|
170
|
+
// Keep the lock fresh while a long upload runs, so it never looks stale to another caller.
|
|
171
|
+
const heartbeat = setInterval(() => {
|
|
172
|
+
try {
|
|
173
|
+
refresh();
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
// Removed under us (judged stale after a long suspend): confirmHeld() before each send catches that.
|
|
177
|
+
}
|
|
178
|
+
}, HEARTBEAT_MS);
|
|
179
|
+
heartbeat.unref();
|
|
180
|
+
return {
|
|
181
|
+
confirmHeld() {
|
|
182
|
+
// Before every publishing call: after a suspend, another caller may have judged this lock stale and taken it.
|
|
183
|
+
if (!ours())
|
|
184
|
+
throw new Error(M().inProgress);
|
|
185
|
+
refresh();
|
|
186
|
+
},
|
|
187
|
+
release() {
|
|
188
|
+
clearInterval(heartbeat);
|
|
189
|
+
// Remove it (and its in-process entry) only if it is still this acquisition: after a suspend, another caller —
|
|
190
|
+
// possibly in this same process — may have replaced it legitimately.
|
|
191
|
+
if (ours()) {
|
|
192
|
+
heldHere.delete(lock);
|
|
193
|
+
fs.rmSync(lock, { recursive: true, force: true });
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
/** True while a live call holds this account's lock (it is publishing to it right now). */
|
|
199
|
+
export function isAccountLocked(platform, account) {
|
|
200
|
+
return lockState(lockPath(platform, account)) === false;
|
|
201
|
+
}
|
|
202
|
+
export function inProgressMessage() {
|
|
203
|
+
return M().inProgress;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Reserve an account for this process; throws "in progress" if another live call holds it. A stale lock is replaced
|
|
207
|
+
* only while holding a breaker directory (mkdir, so one caller at a time) and after re-checking it. A breaker is never
|
|
208
|
+
* removed by anyone but its creator; one left by a run that died is reported for a person to delete.
|
|
209
|
+
*/
|
|
210
|
+
export function acquireAccountLock(platform, account) {
|
|
211
|
+
fs.mkdirSync(path.join(root(), 'accounts'), { recursive: true, mode: CREDENTIAL_DIR_MODE });
|
|
212
|
+
const lock = lockPath(platform, account);
|
|
213
|
+
const breaker = `${lock}.break`;
|
|
214
|
+
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
215
|
+
try {
|
|
216
|
+
return takeLock(lock);
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
if (!isCode(error, 'EEXIST'))
|
|
220
|
+
throw error;
|
|
221
|
+
}
|
|
222
|
+
const state = lockState(lock);
|
|
223
|
+
if (state === 'missing')
|
|
224
|
+
continue;
|
|
225
|
+
if (!state)
|
|
226
|
+
throw new Error(M().inProgress);
|
|
227
|
+
try {
|
|
228
|
+
fs.mkdirSync(breaker, { mode: CREDENTIAL_DIR_MODE });
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
if (!isCode(error, 'EEXIST'))
|
|
232
|
+
throw error;
|
|
233
|
+
let breakerAge;
|
|
234
|
+
try {
|
|
235
|
+
breakerAge = Date.now() - fs.statSync(breaker).mtimeMs;
|
|
236
|
+
}
|
|
237
|
+
catch (statError) {
|
|
238
|
+
if (!isCode(statError, 'ENOENT'))
|
|
239
|
+
throw statError;
|
|
240
|
+
continue; // the other breaker finished: look again
|
|
241
|
+
}
|
|
242
|
+
// A breaker is held for milliseconds; an old one means a run died in that instant. Removing it automatically
|
|
243
|
+
// cannot be made race-free (whatever is at the path may already be someone else's fresh one), so a person does.
|
|
244
|
+
if (breakerAge >= STALE_BREAKER_MS)
|
|
245
|
+
throw new Error(M().deadBreaker(breaker), { cause: error });
|
|
246
|
+
throw new Error(M().inProgress, { cause: error });
|
|
247
|
+
}
|
|
248
|
+
try {
|
|
249
|
+
const again = lockState(lock);
|
|
250
|
+
if (again === false)
|
|
251
|
+
throw new Error(M().inProgress);
|
|
252
|
+
if (again === true)
|
|
253
|
+
fs.rmSync(lock, { recursive: true, force: true });
|
|
254
|
+
try {
|
|
255
|
+
return takeLock(lock);
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
// Someone took it the ordinary way after we removed the stale one: it is theirs.
|
|
259
|
+
if (isCode(error, 'EEXIST'))
|
|
260
|
+
throw new Error(M().inProgress, { cause: error });
|
|
261
|
+
throw error;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
finally {
|
|
265
|
+
fs.rmSync(breaker, { recursive: true, force: true });
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
throw new Error(M().inProgress);
|
|
269
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { type PendingRecord, type PostRecord, type SocialTarget } from './ledger.js';
|
|
2
|
+
export declare const SOCIAL_TARGETS: readonly ["facebook", "instagram", "threads", "youtube", "tiktok"];
|
|
3
|
+
export interface SocialPublishInput {
|
|
4
|
+
targets: SocialTarget[];
|
|
5
|
+
text: string;
|
|
6
|
+
imageUrls?: string[];
|
|
7
|
+
videoUrl?: string;
|
|
8
|
+
videoFilePath?: string;
|
|
9
|
+
facebook?: {
|
|
10
|
+
profile?: string;
|
|
11
|
+
text?: string;
|
|
12
|
+
};
|
|
13
|
+
instagram?: {
|
|
14
|
+
profile?: string;
|
|
15
|
+
text?: string;
|
|
16
|
+
};
|
|
17
|
+
threads?: {
|
|
18
|
+
profile?: string;
|
|
19
|
+
text?: string;
|
|
20
|
+
};
|
|
21
|
+
youtube?: {
|
|
22
|
+
profile?: string;
|
|
23
|
+
expectedChannelId: string;
|
|
24
|
+
title?: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
tags?: string[];
|
|
27
|
+
privacyStatus?: 'private' | 'unlisted' | 'public';
|
|
28
|
+
madeForKids?: boolean;
|
|
29
|
+
containsSyntheticMedia?: boolean;
|
|
30
|
+
};
|
|
31
|
+
tiktok?: {
|
|
32
|
+
planId: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Unknown outcomes a person has checked are not live, each named by the platform and the `at` the plan showed for
|
|
36
|
+
* it: send again. A newer unknown outcome (a different `at`) stays blocked.
|
|
37
|
+
*/
|
|
38
|
+
resendUnknown?: Approval[];
|
|
39
|
+
/** Posts to make again on purpose though that content already went out, each named by the posted record's `at`. */
|
|
40
|
+
repost?: Approval[];
|
|
41
|
+
/**
|
|
42
|
+
* Unknown outcomes a person checked and found **live**, each named by the `at` the plan showed: they are recorded as
|
|
43
|
+
* posted (nothing is sent for them) and their account is no longer blocked.
|
|
44
|
+
*/
|
|
45
|
+
markPosted?: Approval[];
|
|
46
|
+
}
|
|
47
|
+
/** An approval for one specific record: the platform and the `at` the plan showed for that record. */
|
|
48
|
+
export interface Approval {
|
|
49
|
+
platform: SocialTarget;
|
|
50
|
+
at: string;
|
|
51
|
+
}
|
|
52
|
+
export interface PlannedPost {
|
|
53
|
+
platform: SocialTarget;
|
|
54
|
+
/** What would be called, e.g. "threads carousel (3 images)". */
|
|
55
|
+
action: string;
|
|
56
|
+
text?: string;
|
|
57
|
+
media?: string[];
|
|
58
|
+
/** Why this target cannot be posted. Any problem in any target blocks the whole publish. */
|
|
59
|
+
problems: string[];
|
|
60
|
+
/** What an earlier call recorded for this exact post, if anything. */
|
|
61
|
+
record?: PostRecord;
|
|
62
|
+
/** An unresolved send to this account (its `at` is what resendUnknown must name). */
|
|
63
|
+
pending?: PendingRecord;
|
|
64
|
+
}
|
|
65
|
+
export interface PublishPlan {
|
|
66
|
+
ok: boolean;
|
|
67
|
+
posts: PlannedPost[];
|
|
68
|
+
}
|
|
69
|
+
export type PublishOutcome = {
|
|
70
|
+
platform: SocialTarget;
|
|
71
|
+
status: 'posted';
|
|
72
|
+
id?: string;
|
|
73
|
+
url?: string;
|
|
74
|
+
warning?: string;
|
|
75
|
+
} | {
|
|
76
|
+
platform: SocialTarget;
|
|
77
|
+
status: 'already_posted';
|
|
78
|
+
id?: string;
|
|
79
|
+
url?: string;
|
|
80
|
+
at: string;
|
|
81
|
+
} | {
|
|
82
|
+
platform: SocialTarget;
|
|
83
|
+
status: 'unknown_outcome';
|
|
84
|
+
error?: string;
|
|
85
|
+
at: string;
|
|
86
|
+
} | {
|
|
87
|
+
platform: SocialTarget;
|
|
88
|
+
status: 'failed';
|
|
89
|
+
error: string;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* The identity of one post: exactly what one platform would receive (the account, text, media, and options). Null
|
|
93
|
+
* when a Meta target's account cannot be resolved (not connected): its identity is unknown, and the plan blocks it.
|
|
94
|
+
*/
|
|
95
|
+
export declare function targetKey(platform: SocialTarget, input: SocialPublishInput,
|
|
96
|
+
/** The video file's identity, captured once per call so the key and the upload check describe the same file. */
|
|
97
|
+
videoFile?: {
|
|
98
|
+
size: number;
|
|
99
|
+
mtimeMs: number;
|
|
100
|
+
} | {
|
|
101
|
+
missing: true;
|
|
102
|
+
} | null): string | null;
|
|
103
|
+
/**
|
|
104
|
+
* The account a target posts to: the resolved Page/user (Meta), the channel (YouTube), the TikTok account the plan
|
|
105
|
+
* belongs to. Null when it cannot be resolved; the plan blocks such a target.
|
|
106
|
+
*/
|
|
107
|
+
export declare function accountKey(platform: SocialTarget, input: SocialPublishInput): string | null;
|
|
108
|
+
type Decision = {
|
|
109
|
+
kind: 'send';
|
|
110
|
+
note?: string;
|
|
111
|
+
} | {
|
|
112
|
+
kind: 'skip';
|
|
113
|
+
outcome: PublishOutcome;
|
|
114
|
+
} | {
|
|
115
|
+
kind: 'block';
|
|
116
|
+
problem: string;
|
|
117
|
+
};
|
|
118
|
+
interface DecideOptions {
|
|
119
|
+
resendUnknown: readonly Approval[];
|
|
120
|
+
repost: readonly Approval[];
|
|
121
|
+
markPosted: readonly Approval[];
|
|
122
|
+
}
|
|
123
|
+
/** The single rule — the table at the top of this file. Same answer in the plan, under the lock, and before each send. */
|
|
124
|
+
export declare function decide(platform: SocialTarget, record: PostRecord | null, pending: PendingRecord | null, { resendUnknown, repost }: DecideOptions): Decision;
|
|
125
|
+
/** No network: config files, the TikTok plan file, and the post and account records are all local. */
|
|
126
|
+
export declare function planPublish(input: SocialPublishInput): PublishPlan;
|
|
127
|
+
/**
|
|
128
|
+
* Publish to every target in order. Call only with an approved plan whose `ok` is true.
|
|
129
|
+
* 1. Lock every account that a post will be sent to (posts that are only skipped need no lock), then re-apply
|
|
130
|
+
* decide() to the records under the locks.
|
|
131
|
+
* 2. Preflight every post that will be sent; if one fails, nothing is sent.
|
|
132
|
+
* 3. Before each publishing call, confirm the lock is still ours and decide() once more (a long earlier upload, or
|
|
133
|
+
* a suspend, may have let another call in); mark the account pending; send; record the outcome.
|
|
134
|
+
*/
|
|
135
|
+
export declare function executePublish(input: SocialPublishInput, plan: PublishPlan): Promise<PublishOutcome[]>;
|
|
136
|
+
export {};
|