dp-worker 0.1.18 → 0.1.20
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/builtin-skills/x.md +27 -0
- package/dist/bird/bird-frontend.d.ts +33 -0
- package/dist/bird/bird-frontend.js +68 -0
- package/dist/bird/bird-frontend.js.map +1 -0
- package/dist/bird/credentials.d.ts +36 -0
- package/dist/bird/credentials.js +82 -0
- package/dist/bird/credentials.js.map +1 -0
- package/dist/bird/ops.d.ts +103 -0
- package/dist/bird/ops.js +523 -0
- package/dist/bird/ops.js.map +1 -0
- package/dist/bird/sidecar-entry.d.ts +25 -0
- package/dist/bird/sidecar-entry.js +192 -0
- package/dist/bird/sidecar-entry.js.map +1 -0
- package/dist/bird/sidecar-host.d.ts +54 -0
- package/dist/bird/sidecar-host.js +318 -0
- package/dist/bird/sidecar-host.js.map +1 -0
- package/dist/bird/socks-connector.d.ts +26 -0
- package/dist/bird/socks-connector.js +49 -0
- package/dist/bird/socks-connector.js.map +1 -0
- package/dist/chrome-extension/omni-flow/manifest.json +1 -1
- package/dist/config/center-config.d.ts +8 -0
- package/dist/config/center-config.js +1 -0
- package/dist/config/center-config.js.map +1 -1
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/node_modules/dp-shared/dist/admin-broadcast.d.ts +1 -1
- package/node_modules/dp-shared/dist/admin-broadcast.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/bird-contracts.d.ts +483 -0
- package/node_modules/dp-shared/dist/bird-contracts.d.ts.map +1 -0
- package/node_modules/dp-shared/dist/bird-contracts.js +372 -0
- package/node_modules/dp-shared/dist/bird-contracts.js.map +1 -0
- package/node_modules/dp-shared/dist/configs-contracts.d.ts +11 -1
- package/node_modules/dp-shared/dist/configs-contracts.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/configs-contracts.js +43 -0
- package/node_modules/dp-shared/dist/configs-contracts.js.map +1 -1
- package/node_modules/dp-shared/dist/index.d.ts +2 -0
- package/node_modules/dp-shared/dist/index.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/index.js +2 -0
- package/node_modules/dp-shared/dist/index.js.map +1 -1
- package/node_modules/dp-shared/dist/post-drafts-contracts.d.ts +9 -3
- package/node_modules/dp-shared/dist/post-drafts-contracts.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/post-drafts-contracts.js +34 -0
- package/node_modules/dp-shared/dist/post-drafts-contracts.js.map +1 -1
- package/node_modules/dp-shared/dist/promo-contracts.d.ts +651 -0
- package/node_modules/dp-shared/dist/promo-contracts.d.ts.map +1 -0
- package/node_modules/dp-shared/dist/promo-contracts.js +566 -0
- package/node_modules/dp-shared/dist/promo-contracts.js.map +1 -0
- package/node_modules/dp-shared/dist/rest-contracts.d.ts +73 -0
- package/node_modules/dp-shared/dist/rest-contracts.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/rest-contracts.js +70 -0
- package/node_modules/dp-shared/dist/rest-contracts.js.map +1 -1
- package/node_modules/dp-shared/dist/smart-money-contracts.d.ts +86 -0
- package/node_modules/dp-shared/dist/smart-money-contracts.d.ts.map +1 -0
- package/node_modules/dp-shared/dist/smart-money-contracts.js +71 -0
- package/node_modules/dp-shared/dist/smart-money-contracts.js.map +1 -0
- package/node_modules/dp-shared/dist/task-history-contracts.d.ts +2 -0
- package/node_modules/dp-shared/dist/task-history-contracts.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/task-history-contracts.js +2 -0
- package/node_modules/dp-shared/dist/task-history-contracts.js.map +1 -1
- package/node_modules/dp-shared/dist/worker-detail-contracts.d.ts +7 -0
- package/node_modules/dp-shared/dist/worker-detail-contracts.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/worker-detail-contracts.js +9 -0
- package/node_modules/dp-shared/dist/worker-detail-contracts.js.map +1 -1
- package/node_modules/dp-shared/dist/ws-protocol.d.ts +52 -0
- package/node_modules/dp-shared/dist/ws-protocol.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/ws-protocol.js +37 -0
- package/node_modules/dp-shared/dist/ws-protocol.js.map +1 -1
- package/package.json +4 -1
- package/node_modules/dp-shared/src/admin-broadcast.ts +0 -41
- package/node_modules/dp-shared/src/audit-contracts.ts +0 -33
- package/node_modules/dp-shared/src/auto-post-contracts.ts +0 -206
- package/node_modules/dp-shared/src/cloak-contracts.ts +0 -110
- package/node_modules/dp-shared/src/configs-contracts.ts +0 -249
- package/node_modules/dp-shared/src/db-rows.ts +0 -303
- package/node_modules/dp-shared/src/deploy-contracts.ts +0 -38
- package/node_modules/dp-shared/src/domain.ts +0 -124
- package/node_modules/dp-shared/src/fingerprint.ts +0 -21
- package/node_modules/dp-shared/src/identities.ts +0 -38
- package/node_modules/dp-shared/src/index.ts +0 -30
- package/node_modules/dp-shared/src/omni-flow-cookie.ts +0 -272
- package/node_modules/dp-shared/src/omni-flow-session.ts +0 -79
- package/node_modules/dp-shared/src/post-drafts-contracts.ts +0 -807
- package/node_modules/dp-shared/src/rest-contracts.ts +0 -592
- package/node_modules/dp-shared/src/task-history-contracts.ts +0 -124
- package/node_modules/dp-shared/src/worker-detail-contracts.ts +0 -236
- package/node_modules/dp-shared/src/ws-protocol.ts +0 -495
|
@@ -1,807 +0,0 @@
|
|
|
1
|
-
import { z } from "zod/v4";
|
|
2
|
-
import { Uuid } from "./domain.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Content workflow: sourcepool article → AI rewrite/score → editable draft →
|
|
6
|
-
* approve → dispatch to worker(s) for posting on X.
|
|
7
|
-
*
|
|
8
|
-
* A draft is a GENERIC, high-quality English X post distilled from a source
|
|
9
|
-
* article (strong hook, essence-not-verbose, original link appended). Persona
|
|
10
|
-
* is NOT baked in at draft time — it is applied per selected account at approval
|
|
11
|
-
* (see ApproveDispatchBodySchema.apply_persona) so one draft can serve several
|
|
12
|
-
* accounts.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
export const PostDraftStatus = z.enum([
|
|
16
|
-
"pending", // freshly generated, awaiting human review
|
|
17
|
-
"approved", // approved + dispatched to worker(s)
|
|
18
|
-
"rejected", // dismissed by operator
|
|
19
|
-
"posted", // worker confirmed publish
|
|
20
|
-
]);
|
|
21
|
-
export type PostDraftStatus = z.infer<typeof PostDraftStatus>;
|
|
22
|
-
|
|
23
|
-
/** One sourcepool tag, mirrored onto the draft for filtering/extensibility. */
|
|
24
|
-
export const PostDraftTag = z.object({
|
|
25
|
-
slug: z.string(),
|
|
26
|
-
name: z.string(),
|
|
27
|
-
kind: z.string(),
|
|
28
|
-
});
|
|
29
|
-
export type PostDraftTag = z.infer<typeof PostDraftTag>;
|
|
30
|
-
|
|
31
|
-
/** An image/video attached to a draft (stored in R2). */
|
|
32
|
-
export const MediaRefSchema = z.object({
|
|
33
|
-
kind: z.enum(["image", "video"]),
|
|
34
|
-
r2_object_key: z.string(),
|
|
35
|
-
filename: z.string(),
|
|
36
|
-
mime: z.string().optional(),
|
|
37
|
-
});
|
|
38
|
-
export type MediaRef = z.infer<typeof MediaRefSchema>;
|
|
39
|
-
|
|
40
|
-
export const MediaPresignRequestSchema = z.object({
|
|
41
|
-
filename: z.string().min(1),
|
|
42
|
-
mime: z.string().optional(),
|
|
43
|
-
size_bytes: z.number().int().nonnegative(),
|
|
44
|
-
});
|
|
45
|
-
export type MediaPresignRequest = z.infer<typeof MediaPresignRequestSchema>;
|
|
46
|
-
|
|
47
|
-
export const MediaPresignResponseSchema = z.object({
|
|
48
|
-
upload_url: z.string(),
|
|
49
|
-
object_key: z.string(),
|
|
50
|
-
expires_at: z.string(),
|
|
51
|
-
});
|
|
52
|
-
export type MediaPresignResponse = z.infer<typeof MediaPresignResponseSchema>;
|
|
53
|
-
|
|
54
|
-
/** Attach an uploaded object to a draft (called after the R2 PUT succeeds). */
|
|
55
|
-
export const MediaAttachBodySchema = z.object({
|
|
56
|
-
kind: z.enum(["image", "video"]),
|
|
57
|
-
r2_object_key: z.string().min(1),
|
|
58
|
-
filename: z.string().min(1),
|
|
59
|
-
mime: z.string().optional(),
|
|
60
|
-
});
|
|
61
|
-
export type MediaAttachBody = z.infer<typeof MediaAttachBodySchema>;
|
|
62
|
-
|
|
63
|
-
export const PostDraftResponseSchema = z.object({
|
|
64
|
-
id: Uuid,
|
|
65
|
-
/** sourcepool item id — stable, used for dedup so we never re-draft it. */
|
|
66
|
-
source_item_id: z.string(),
|
|
67
|
-
source_name: z.string().nullable(),
|
|
68
|
-
/** Original article URL, also appended to the post body. */
|
|
69
|
-
source_url: z.string(),
|
|
70
|
-
/** Primary topic slug (sourcepool topic tag) — the board's main category. */
|
|
71
|
-
topic: z.string().nullable(),
|
|
72
|
-
tags: z.array(PostDraftTag).default([]),
|
|
73
|
-
/** Original article language (en/zh/ja/ko/other). Output body is always en. */
|
|
74
|
-
language: z.string().nullable(),
|
|
75
|
-
/** Editable hook / opening line. */
|
|
76
|
-
hook_title: z.string(),
|
|
77
|
-
/** Editable English X post body. The source link is appended at post time. */
|
|
78
|
-
body: z.string(),
|
|
79
|
-
/** Independent judge score 0-100 of the CURRENT draft. Meaningful only if ai_scored. */
|
|
80
|
-
ai_score: z.number().int(),
|
|
81
|
-
/** false = the judge failed to score (show "未评分", not a fake number). */
|
|
82
|
-
ai_scored: z.boolean().default(true),
|
|
83
|
-
/** Judge's score of the ORIGINAL article headline, for 原文→洗稿 comparison. null = not computed. */
|
|
84
|
-
source_score: z.number().int().nullable().default(null),
|
|
85
|
-
ai_critique: z.string().nullable(),
|
|
86
|
-
/** 'short' (<=280) or 'long' (long-form). */
|
|
87
|
-
format: z.enum(["short", "long"]).default("short"),
|
|
88
|
-
/** Attached image/video refs (R2). */
|
|
89
|
-
media: z.array(MediaRefSchema).default([]),
|
|
90
|
-
/** R2 media was stripped after posting (row kept as record). */
|
|
91
|
-
media_cleaned: z.boolean().default(false),
|
|
92
|
-
status: PostDraftStatus,
|
|
93
|
-
posted_task_run_id: z.string().nullable(),
|
|
94
|
-
/** How the draft was produced: manual sourcepool wash, pasted-url wash, AI 创作,
|
|
95
|
-
* shared autofetch (cron) pool, a personal copy claimed from that pool, a
|
|
96
|
-
* language-translated copy of one of the operator's own drafts, or an AI HOT
|
|
97
|
-
* curated item washed from its third-party original link. */
|
|
98
|
-
origin: z.enum(["sourcepool", "url", "composed", "autofetch", "claimed", "translated", "aihot", "reply", "quote", "interaction", "autopilot"]).default("sourcepool"),
|
|
99
|
-
/** Operator who authored a 'composed' draft (null = system-washed). */
|
|
100
|
-
author_user_id: z.string().nullable().default(null),
|
|
101
|
-
/** Denormalized login email of the author, for the board's 作者 filter/badge. */
|
|
102
|
-
author_email: z.string().nullable().default(null),
|
|
103
|
-
/** Original article publish time (ISO), if the source provided it. */
|
|
104
|
-
source_published_at: z.string().nullable().default(null),
|
|
105
|
-
/** Append the source link to the post at dispatch (default true). false = omit it. */
|
|
106
|
-
append_source_link: z.boolean().default(true),
|
|
107
|
-
/** For origin='reply': the tweet URL this draft is a reply to (else null). */
|
|
108
|
-
reply_to_url: z.string().nullable().default(null),
|
|
109
|
-
created_at: z.string(),
|
|
110
|
-
updated_at: z.string(),
|
|
111
|
-
});
|
|
112
|
-
export type PostDraftResponse = z.infer<typeof PostDraftResponseSchema>;
|
|
113
|
-
|
|
114
|
-
/** Human edits from the board: refine copy, retopic, or change status. */
|
|
115
|
-
export const PostDraftPatchSchema = z
|
|
116
|
-
.object({
|
|
117
|
-
hook_title: z.string().max(400).optional(),
|
|
118
|
-
body: z.string().max(4000).optional(),
|
|
119
|
-
topic: z.string().max(120).nullable().optional(),
|
|
120
|
-
status: PostDraftStatus.optional(),
|
|
121
|
-
/** Per-draft toggle: append the source link at dispatch. */
|
|
122
|
-
append_source_link: z.boolean().optional(),
|
|
123
|
-
})
|
|
124
|
-
.refine((v) => Object.keys(v).length > 0, {
|
|
125
|
-
message: "patch body must contain at least one field",
|
|
126
|
-
});
|
|
127
|
-
export type PostDraftPatch = z.infer<typeof PostDraftPatchSchema>;
|
|
128
|
-
|
|
129
|
-
/** Trigger a rewrite batch: pull sourcepool candidates → AI draft top-N. */
|
|
130
|
-
export const GenerateBatchBodySchema = z
|
|
131
|
-
.object({
|
|
132
|
-
/** sourcepool topic slugs to pull; empty = editor's hot/broad pull. */
|
|
133
|
-
topics: z.array(z.string()).default([]),
|
|
134
|
-
/** Relative window passed to sourcepool (`?within=`), e.g. "48h", "7d". */
|
|
135
|
-
within: z.string().default("48h"),
|
|
136
|
-
/** Articles from the chosen topics. */
|
|
137
|
-
topic_limit: z.number().int().min(0).max(30).default(5),
|
|
138
|
-
/** Articles from general hot/recent (also backfills a topic shortfall). */
|
|
139
|
-
hot_limit: z.number().int().min(0).max(30).default(5),
|
|
140
|
-
/** Draft form: short tweet, long-form, or both (one draft per form). */
|
|
141
|
-
format: z.enum(["short", "long", "both"]).default("short"),
|
|
142
|
-
/** 择优: over-generate and keep only the highest-scoring per quota (more tokens). */
|
|
143
|
-
pick_best: z.boolean().default(false),
|
|
144
|
-
/** 自动打磨: run the judge-chaperone polish loop on each draft (more tokens). */
|
|
145
|
-
auto_polish: z.boolean().default(false),
|
|
146
|
-
/** 评审团: score with the 3-lens review panel instead of the single judge. */
|
|
147
|
-
judge_panel: z.boolean().default(false),
|
|
148
|
-
/** Local model override for this run; null/absent = fall back to the global
|
|
149
|
-
* content llm_profile. Never persisted — the global setting is untouched. */
|
|
150
|
-
llm_profile_id: z.string().uuid().nullish(),
|
|
151
|
-
})
|
|
152
|
-
.refine((v) => v.topic_limit + v.hot_limit >= 1, {
|
|
153
|
-
message: "主题数 + 热点数 至少为 1",
|
|
154
|
-
});
|
|
155
|
-
export type GenerateBatchBody = z.infer<typeof GenerateBatchBodySchema>;
|
|
156
|
-
|
|
157
|
-
/** Wash a draft from a pasted article URL (same rewrite+judge pipeline). */
|
|
158
|
-
export const FromUrlBodySchema = z.object({
|
|
159
|
-
url: z.string().url(),
|
|
160
|
-
format: z.enum(["short", "long", "both"]).default("short"),
|
|
161
|
-
/** Local model override; null/absent = global content profile. Not persisted. */
|
|
162
|
-
llm_profile_id: z.string().uuid().nullish(),
|
|
163
|
-
});
|
|
164
|
-
export type FromUrlBody = z.infer<typeof FromUrlBodySchema>;
|
|
165
|
-
|
|
166
|
-
export const GenerateBatchResultSchema = z.object({
|
|
167
|
-
generated: z.number().int(),
|
|
168
|
-
skipped_existing: z.number().int(),
|
|
169
|
-
scanned: z.number().int(),
|
|
170
|
-
/** Candidates still needing a fresh format (not already washed in this bucket). */
|
|
171
|
-
eligible: z.number().int().default(0),
|
|
172
|
-
/** Winners selected by score to wash. */
|
|
173
|
-
selected: z.number().int().default(0),
|
|
174
|
-
/** source_item_id of each article that produced at least one draft this run. */
|
|
175
|
-
winning_source_item_ids: z.array(z.string()).default([]),
|
|
176
|
-
});
|
|
177
|
-
export type GenerateBatchResult = z.infer<typeof GenerateBatchResultSchema>;
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* STEP 1 — preview the per-WORKER persona-tailored copy before dispatching.
|
|
181
|
-
* Targets = explicit workers (worker_ids) ∪ every member of the chosen worker
|
|
182
|
-
* groups (group_ids). Each worker posts to its OWN cookie-logged-in X account.
|
|
183
|
-
*/
|
|
184
|
-
export const PreviewTailoredBodySchema = z.object({
|
|
185
|
-
/** explicit worker (bot) ids to post from. */
|
|
186
|
-
worker_ids: z.array(Uuid).default([]),
|
|
187
|
-
/** worker-group ids; expanded to their member workers. */
|
|
188
|
-
group_ids: z.array(Uuid).default([]),
|
|
189
|
-
/** platform (default x — worker posts to its logged-in X). */
|
|
190
|
-
platform: z.string().default("x"),
|
|
191
|
-
/** Rewrite the body into each worker's persona voice (still English). */
|
|
192
|
-
apply_persona: z.boolean().default(true),
|
|
193
|
-
});
|
|
194
|
-
export type PreviewTailoredBody = z.infer<typeof PreviewTailoredBodySchema>;
|
|
195
|
-
|
|
196
|
-
/** One resolved worker target with its (editable) tailored text. */
|
|
197
|
-
export const TailoredItemSchema = z.object({
|
|
198
|
-
worker_id: z.string(),
|
|
199
|
-
worker_name: z.string().nullable().default(null),
|
|
200
|
-
platform: z.string(),
|
|
201
|
-
/** the worker's X @handle if known (empty = posts to its logged-in account). */
|
|
202
|
-
handle: z.string(),
|
|
203
|
-
/** persona-tailored (or generic) English post text, editable by the operator. */
|
|
204
|
-
text: z.string(),
|
|
205
|
-
/** whether a persona was applied (false = 直发通稿, no persona on file). */
|
|
206
|
-
has_persona: z.boolean().default(false),
|
|
207
|
-
/** already dispatched this draft to this worker before — UI should warn/skip. */
|
|
208
|
-
already_dispatched: z.boolean().default(false),
|
|
209
|
-
});
|
|
210
|
-
export type TailoredItem = z.infer<typeof TailoredItemSchema>;
|
|
211
|
-
|
|
212
|
-
export const PreviewTailoredResultSchema = z.object({
|
|
213
|
-
items: z.array(TailoredItemSchema),
|
|
214
|
-
});
|
|
215
|
-
export type PreviewTailoredResult = z.infer<typeof PreviewTailoredResultSchema>;
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* STEP 2 — approve + dispatch. Carries the FINAL (operator-edited) text per
|
|
219
|
-
* account. Multiple items = broadcast (群发); dispatch_window_seconds staggers
|
|
220
|
-
* them (错峰); scheduled_at posts once at a future time (定时). Accounts already
|
|
221
|
-
* in the dedup ledger for this draft are skipped server-side.
|
|
222
|
-
*/
|
|
223
|
-
export const ApproveDispatchItemSchema = z.object({
|
|
224
|
-
worker_id: z.string(),
|
|
225
|
-
text: z.string().min(1),
|
|
226
|
-
});
|
|
227
|
-
export type ApproveDispatchItem = z.infer<typeof ApproveDispatchItemSchema>;
|
|
228
|
-
|
|
229
|
-
export const ApproveDispatchBodySchema = z.object({
|
|
230
|
-
items: z.array(ApproveDispatchItemSchema).min(1),
|
|
231
|
-
/** ISO time for a one-shot future post; omit/null = dispatch now. */
|
|
232
|
-
scheduled_at: z.string().datetime().nullable().optional(),
|
|
233
|
-
/** Spread dispatch across this many seconds (0 = all at once). */
|
|
234
|
-
dispatch_window_seconds: z.number().int().min(0).max(86400).default(0),
|
|
235
|
-
/**
|
|
236
|
-
* When true, ignore scheduled_at/window and post each worker at the next
|
|
237
|
-
* "golden hour" in ITS OWN timezone (via the worker's proxy). Best for reach.
|
|
238
|
-
*/
|
|
239
|
-
per_account_timezone: z.boolean().default(false),
|
|
240
|
-
});
|
|
241
|
-
export type ApproveDispatchBody = z.infer<typeof ApproveDispatchBodySchema>;
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Inline AI-assist. Three ORTHOGONAL axes that COMBINE (all applied together in
|
|
245
|
-
* one rewrite), plus one-off ops. Grounded in the original article; always
|
|
246
|
-
* rewrites both title + body and respects the draft's format length.
|
|
247
|
-
*/
|
|
248
|
-
// Structure template — reshapes the WHOLE post (Cole's + wewrite's frameworks).
|
|
249
|
-
export const AssistStructure = z.enum([
|
|
250
|
-
"tpl_story", "tpl_mistakes", "tpl_lessons", "tpl_curation", "tpl_framework",
|
|
251
|
-
"tpl_actionable", "tpl_painpoint", "tpl_compare", "tpl_hottake",
|
|
252
|
-
]);
|
|
253
|
-
export type AssistStructure = z.infer<typeof AssistStructure>;
|
|
254
|
-
// Hook opening style.
|
|
255
|
-
export const AssistHookStyle = z.enum(["hookier", "question", "suspense", "contrarian", "number", "timely", "aphorism", "value_prop", "identity", "discovery", "uncomfortable"]);
|
|
256
|
-
export type AssistHookStyle = z.infer<typeof AssistHookStyle>;
|
|
257
|
-
// Tone.
|
|
258
|
-
export const AssistTone = z.enum(["casual", "professional"]);
|
|
259
|
-
export type AssistTone = z.infer<typeof AssistTone>;
|
|
260
|
-
// One-off transforms (not remembered axes).
|
|
261
|
-
export const AssistOp = z.enum(["rewrite", "shorten"]);
|
|
262
|
-
export type AssistOp = z.infer<typeof AssistOp>;
|
|
263
|
-
|
|
264
|
-
export const AssistBodySchema = z.object({
|
|
265
|
-
/** Current (possibly unsaved) body the operator is editing. */
|
|
266
|
-
text: z.string().min(1),
|
|
267
|
-
/** Current (possibly unsaved) hook/title. */
|
|
268
|
-
hook: z.string().default(""),
|
|
269
|
-
/** Draft form — short is hard-capped at 280 chars; long stays multi-paragraph. */
|
|
270
|
-
format: z.enum(["short", "long"]).default("short"),
|
|
271
|
-
/** The three combinable axes — any subset may be set; all set ones apply together. */
|
|
272
|
-
structure: AssistStructure.nullish(),
|
|
273
|
-
hookStyle: AssistHookStyle.nullish(),
|
|
274
|
-
tone: AssistTone.nullish(),
|
|
275
|
-
/** Optional one-off transform applied on top of the axes. */
|
|
276
|
-
op: AssistOp.nullish(),
|
|
277
|
-
/** Optional target length (chars) for LONG-form drafts — lets the operator cap length. Ignored for short (always <= 280). */
|
|
278
|
-
target_chars: z.number().int().min(100).max(8000).nullish(),
|
|
279
|
-
/** Local model override for this op; null/absent = global content profile. Not persisted. */
|
|
280
|
-
llm_profile_id: z.string().uuid().nullish(),
|
|
281
|
-
});
|
|
282
|
-
export type AssistBody = z.infer<typeof AssistBodySchema>;
|
|
283
|
-
|
|
284
|
-
/** Assist rewrites both the title and the body (grounded in the article). */
|
|
285
|
-
export const AssistResultSchema = z.object({
|
|
286
|
-
hook_title: z.string(),
|
|
287
|
-
body: z.string(),
|
|
288
|
-
});
|
|
289
|
-
export type AssistResult = z.infer<typeof AssistResultSchema>;
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* "AI 优化" — free-form deep optimization of a draft driven by the operator's own
|
|
293
|
-
* prompt plus optional materials (pasted reference text, reference links to
|
|
294
|
-
* fetch, and images for vision-capable models). Like assist, it rewrites both
|
|
295
|
-
* title+body and does NOT persist — the operator reviews the result in the
|
|
296
|
-
* editor and Saves. Reuses AssistResultSchema for the response.
|
|
297
|
-
*/
|
|
298
|
-
export const AiOptimizeBodySchema = z.object({
|
|
299
|
-
/** Current (possibly unsaved) body being edited. */
|
|
300
|
-
text: z.string().min(1),
|
|
301
|
-
/** Current (possibly unsaved) hook/title. */
|
|
302
|
-
hook: z.string().default(""),
|
|
303
|
-
/** Draft form — short is hard-capped at 280 chars; long stays multi-paragraph. */
|
|
304
|
-
format: z.enum(["short", "long"]).default("short"),
|
|
305
|
-
/** The operator's free-form optimization instruction — required. */
|
|
306
|
-
prompt: z.string().min(1).max(4000),
|
|
307
|
-
/** Optional pasted reference material. */
|
|
308
|
-
ref_text: z.string().max(20000).nullish(),
|
|
309
|
-
/** Optional reference links to fetch and ground on (max 3 applied server-side). */
|
|
310
|
-
ref_urls: z.array(z.string().url()).max(3).nullish(),
|
|
311
|
-
/** Optional R2 object keys of uploaded reference images (max 4 applied server-side). */
|
|
312
|
-
image_keys: z.array(z.string().min(1)).max(4).nullish(),
|
|
313
|
-
/** Optional target length (chars) for LONG-form drafts. Ignored for short (<= 280). */
|
|
314
|
-
target_chars: z.number().int().min(100).max(8000).nullish(),
|
|
315
|
-
/** Local model override; null/absent = global content profile. Must be vision-capable if images are sent. */
|
|
316
|
-
llm_profile_id: z.string().uuid().nullish(),
|
|
317
|
-
});
|
|
318
|
-
export type AiOptimizeBody = z.infer<typeof AiOptimizeBodySchema>;
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* "AI 创作" — operator-authored content that runs through the SAME rewrite/judge
|
|
322
|
-
* quality core as washing, but from a brief (and optional reference material)
|
|
323
|
-
* instead of a fetched source. Output posts have no source link. Tagged to the
|
|
324
|
-
* logged-in operator so each person gets their own column on the board.
|
|
325
|
-
*/
|
|
326
|
-
export const ComposeBodySchema = z.object({
|
|
327
|
-
/** The creation instruction / topic — required. */
|
|
328
|
-
brief: z.string().min(1).max(4000),
|
|
329
|
-
/** Optional reference material (a pasted article or notes) to ground the write. */
|
|
330
|
-
material: z.string().max(20000).default(""),
|
|
331
|
-
/** short tweet, long-form, or both (one draft per form). */
|
|
332
|
-
format: z.enum(["short", "long", "both"]).default("short"),
|
|
333
|
-
/** Optional hook opening style (reuses the inline-assist hook axis). */
|
|
334
|
-
hook_style: AssistHookStyle.nullish(),
|
|
335
|
-
/** Optional target length (chars). Short caps at 280; long trims to this. */
|
|
336
|
-
target_chars: z.number().int().min(60).max(8000).nullish(),
|
|
337
|
-
/** 择优: generate several candidates per form and keep the best (more tokens). */
|
|
338
|
-
pick_best: z.boolean().default(false),
|
|
339
|
-
/** Auto-polish the winner one hostile-reader round (more tokens, higher score). */
|
|
340
|
-
auto_polish: z.boolean().default(false),
|
|
341
|
-
/**
|
|
342
|
-
* 复刻爆款: treat `material` as a PROVEN high-performing post to replicate at the
|
|
343
|
-
* STRUCTURE level (hook pattern, rhythm, sequence) while writing about `brief`
|
|
344
|
-
* with fresh wording — never verbatim copy, never reuse its specific facts.
|
|
345
|
-
*/
|
|
346
|
-
replicate: z.boolean().default(false),
|
|
347
|
-
/** Local model override; null/absent = global content profile. Not persisted. */
|
|
348
|
-
llm_profile_id: z.string().uuid().nullish(),
|
|
349
|
-
});
|
|
350
|
-
export type ComposeBody = z.infer<typeof ComposeBodySchema>;
|
|
351
|
-
|
|
352
|
-
export const ComposeResultSchema = z.object({
|
|
353
|
-
/** How many drafts were created (1 for short/long, 2 for both). */
|
|
354
|
-
generated: z.number().int(),
|
|
355
|
-
/** IDs of the created drafts, in creation order — lets the UI open the new
|
|
356
|
-
* draft's editor directly instead of making the user hunt for it in the list. */
|
|
357
|
-
draft_ids: z.array(z.string()).default([]),
|
|
358
|
-
});
|
|
359
|
-
export type ComposeResult = z.infer<typeof ComposeResultSchema>;
|
|
360
|
-
|
|
361
|
-
/** 选题灵感 — generate one-line post ideas from a seed to feed into AI 创作. */
|
|
362
|
-
export const TopicIdeasBodySchema = z.object({
|
|
363
|
-
seed: z.string().max(2000).default(""),
|
|
364
|
-
});
|
|
365
|
-
export type TopicIdeasBody = z.infer<typeof TopicIdeasBodySchema>;
|
|
366
|
-
|
|
367
|
-
export const TopicIdeasResultSchema = z.object({
|
|
368
|
-
ideas: z.array(z.string()),
|
|
369
|
-
});
|
|
370
|
-
export type TopicIdeasResult = z.infer<typeof TopicIdeasResultSchema>;
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* "换一版" — regenerate a draft's copy (fresh angle) through the quality core,
|
|
374
|
-
* re-score it, and either replace the draft in place or save a sibling (A/B).
|
|
375
|
-
*/
|
|
376
|
-
export const RegenerateBodySchema = z.object({
|
|
377
|
-
/** true = keep the original and create a new sibling draft (一稿多版). */
|
|
378
|
-
keep_original: z.boolean().default(false),
|
|
379
|
-
/** Local model override; null/absent = global content profile. Not persisted. */
|
|
380
|
-
llm_profile_id: z.string().uuid().nullish(),
|
|
381
|
-
});
|
|
382
|
-
export type RegenerateBody = z.infer<typeof RegenerateBodySchema>;
|
|
383
|
-
|
|
384
|
-
/** Supported translation targets (mainstream languages). */
|
|
385
|
-
export const TranslateLang = z.enum(["ko", "ja", "zh", "es", "fr", "de", "pt", "ar", "id", "vi", "th", "ru"]);
|
|
386
|
-
export type TranslateLang = z.infer<typeof TranslateLang>;
|
|
387
|
-
export const TranslateBodySchema = z.object({
|
|
388
|
-
lang: TranslateLang,
|
|
389
|
-
/** Local model override; null/absent = global content profile. Not persisted. */
|
|
390
|
-
llm_profile_id: z.string().uuid().nullish(),
|
|
391
|
-
});
|
|
392
|
-
export type TranslateBody = z.infer<typeof TranslateBodySchema>;
|
|
393
|
-
|
|
394
|
-
export const RegenerateResultSchema = z.object({
|
|
395
|
-
/** id of the draft carrying the new copy (same id if replaced, new id if sibling). */
|
|
396
|
-
draft_id: z.string(),
|
|
397
|
-
replaced: z.boolean(),
|
|
398
|
-
});
|
|
399
|
-
export type RegenerateResult = z.infer<typeof RegenerateResultSchema>;
|
|
400
|
-
|
|
401
|
-
/** "一键打磨" input — polishes the current editor text (not necessarily saved). */
|
|
402
|
-
export const PolishBodySchema = z.object({
|
|
403
|
-
text: z.string().min(1),
|
|
404
|
-
hook: z.string().default(""),
|
|
405
|
-
/** Local model override; null/absent = global content profile. Not persisted. */
|
|
406
|
-
llm_profile_id: z.string().uuid().nullish(),
|
|
407
|
-
});
|
|
408
|
-
export type PolishBody = z.infer<typeof PolishBodySchema>;
|
|
409
|
-
|
|
410
|
-
/** Polish result: best version + before/after scores and how many rounds it took. */
|
|
411
|
-
export const PolishResultSchema = z.object({
|
|
412
|
-
hook_title: z.string(),
|
|
413
|
-
body: z.string(),
|
|
414
|
-
from_score: z.number().int().nullable(),
|
|
415
|
-
to_score: z.number().int().nullable(),
|
|
416
|
-
rounds: z.number().int(),
|
|
417
|
-
trace: z.array(z.number().int()),
|
|
418
|
-
});
|
|
419
|
-
export type PolishResult = z.infer<typeof PolishResultSchema>;
|
|
420
|
-
|
|
421
|
-
/** Optional hourly auto-fetch config (off by default). */
|
|
422
|
-
export const AutofetchSettingsSchema = z.object({
|
|
423
|
-
enabled: z.boolean(),
|
|
424
|
-
topics: z.array(z.string()),
|
|
425
|
-
/** Legacy total; kept for compat. New splits below drive generation. */
|
|
426
|
-
fetch_limit: z.number().int().min(1).max(30),
|
|
427
|
-
/** Auto-fetch: articles from the chosen topics. */
|
|
428
|
-
topic_fetch_limit: z.number().int().min(0).max(30).default(5),
|
|
429
|
-
/** Auto-fetch: articles from general hot/recent (also backfills topic shortfall). */
|
|
430
|
-
hot_fetch_limit: z.number().int().min(0).max(30).default(5),
|
|
431
|
-
within: z.string(),
|
|
432
|
-
/** Which form auto-fetch generates: short / long / both. */
|
|
433
|
-
format: z.enum(["short", "long", "both"]).default("short"),
|
|
434
|
-
/** Auto-fetch cadence: run every N hours (default 6). */
|
|
435
|
-
fetch_interval_hours: z.number().int().min(1).max(168),
|
|
436
|
-
/** Full-purge pending/rejected older than this (safety net). */
|
|
437
|
-
draft_retention_days: z.number().int().min(1).max(365),
|
|
438
|
-
/** Strip R2 media from approved/posted drafts older than this. */
|
|
439
|
-
media_retention_days: z.number().int().min(1).max(365),
|
|
440
|
-
/** Hard cap on pending drafts — oldest auto-evicted beyond this. */
|
|
441
|
-
pending_cap: z.number().int().min(10).max(5000),
|
|
442
|
-
/** UI convenience label for the chosen preset. */
|
|
443
|
-
cleanup_preset: z.string(),
|
|
444
|
-
/** LLM profile id for the content workflow; null = oldest profile. */
|
|
445
|
-
llm_profile_id: z.string().nullable(),
|
|
446
|
-
/** best-of-2: write 2 variants per format, keep the higher (opt-in, +cost). */
|
|
447
|
-
pick_best: z.boolean().default(false),
|
|
448
|
-
/** Auto-run the judge-chaperone polish loop on each washed draft (opt-in, +cost). */
|
|
449
|
-
auto_polish: z.boolean().default(false),
|
|
450
|
-
/** Score with the 3-lens review panel instead of the single judge (opt-in, +cost). */
|
|
451
|
-
judge_panel: z.boolean().default(false),
|
|
452
|
-
/** Resolved "name · model" the content workflow actually uses (GET only). */
|
|
453
|
-
effective_model: z.string().nullable().optional(),
|
|
454
|
-
});
|
|
455
|
-
export type AutofetchSettings = z.infer<typeof AutofetchSettingsSchema>;
|
|
456
|
-
|
|
457
|
-
export const AutofetchPatchSchema = z
|
|
458
|
-
.object({
|
|
459
|
-
enabled: z.boolean().optional(),
|
|
460
|
-
topics: z.array(z.string()).optional(),
|
|
461
|
-
fetch_limit: z.number().int().min(1).max(30).optional(),
|
|
462
|
-
topic_fetch_limit: z.number().int().min(0).max(30).optional(),
|
|
463
|
-
hot_fetch_limit: z.number().int().min(0).max(30).optional(),
|
|
464
|
-
within: z.string().optional(),
|
|
465
|
-
format: z.enum(["short", "long", "both"]).optional(),
|
|
466
|
-
fetch_interval_hours: z.number().int().min(1).max(168).optional(),
|
|
467
|
-
draft_retention_days: z.number().int().min(1).max(365).optional(),
|
|
468
|
-
media_retention_days: z.number().int().min(1).max(365).optional(),
|
|
469
|
-
pending_cap: z.number().int().min(10).max(5000).optional(),
|
|
470
|
-
cleanup_preset: z.string().optional(),
|
|
471
|
-
llm_profile_id: z.string().nullable().optional(),
|
|
472
|
-
pick_best: z.boolean().optional(),
|
|
473
|
-
auto_polish: z.boolean().optional(),
|
|
474
|
-
judge_panel: z.boolean().optional(),
|
|
475
|
-
})
|
|
476
|
-
.refine((v) => Object.keys(v).length > 0, {
|
|
477
|
-
message: "patch body must contain at least one field",
|
|
478
|
-
});
|
|
479
|
-
export type AutofetchPatch = z.infer<typeof AutofetchPatchSchema>;
|
|
480
|
-
|
|
481
|
-
/** One autofetch cron run — the audit trail: 抓取→评分→选中→洗出. */
|
|
482
|
-
export const AutofetchRunSchema = z.object({
|
|
483
|
-
id: z.number().int(),
|
|
484
|
-
ran_at: z.string(),
|
|
485
|
-
scanned: z.number().int(),
|
|
486
|
-
eligible: z.number().int(),
|
|
487
|
-
selected: z.number().int(),
|
|
488
|
-
generated: z.number().int(),
|
|
489
|
-
source_item_ids: z.array(z.string()).default([]),
|
|
490
|
-
window_h: z.number().int(),
|
|
491
|
-
});
|
|
492
|
-
export type AutofetchRun = z.infer<typeof AutofetchRunSchema>;
|
|
493
|
-
export const AutofetchRunsResponseSchema = z.object({ runs: z.array(AutofetchRunSchema) });
|
|
494
|
-
export type AutofetchRunsResponse = z.infer<typeof AutofetchRunsResponseSchema>;
|
|
495
|
-
|
|
496
|
-
/** One "已发往" ledger entry for the draft detail side panel. */
|
|
497
|
-
export const PostDispatchLogEntrySchema = z.object({
|
|
498
|
-
account_id: Uuid,
|
|
499
|
-
worker_id: z.string().nullable(),
|
|
500
|
-
platform: z.string(),
|
|
501
|
-
task_run_id: z.string().nullable(),
|
|
502
|
-
created_at: z.string(),
|
|
503
|
-
});
|
|
504
|
-
export type PostDispatchLogEntry = z.infer<typeof PostDispatchLogEntrySchema>;
|
|
505
|
-
|
|
506
|
-
/** A sub-account the operator can post a draft as (approve dialog picker). */
|
|
507
|
-
export const DispatchTargetSchema = z.object({
|
|
508
|
-
account_id: Uuid,
|
|
509
|
-
/** x / youtube / reddit / … — the UI groups the picker by this. */
|
|
510
|
-
platform: z.string(),
|
|
511
|
-
username: z.string().nullable(),
|
|
512
|
-
profile_name: z.string(),
|
|
513
|
-
identity_name: z.string(),
|
|
514
|
-
/** null = identity has no bound worker → cannot post yet. */
|
|
515
|
-
worker_id: z.string().nullable(),
|
|
516
|
-
/** Human worker name (dp_workers.name) — searchable + shown. null if unbound. */
|
|
517
|
-
worker_name: z.string().nullable().default(null),
|
|
518
|
-
});
|
|
519
|
-
export type DispatchTarget = z.infer<typeof DispatchTargetSchema>;
|
|
520
|
-
|
|
521
|
-
export const ApproveDispatchResultSchema = z.object({
|
|
522
|
-
batch_id: z.string(),
|
|
523
|
-
dispatched: z.array(
|
|
524
|
-
z.object({
|
|
525
|
-
worker_id: z.string(),
|
|
526
|
-
task_run_id: z.string(),
|
|
527
|
-
})
|
|
528
|
-
),
|
|
529
|
-
/** Workers skipped (already dispatched this draft). */
|
|
530
|
-
skipped_workers: z.array(z.string()).default([]),
|
|
531
|
-
});
|
|
532
|
-
export type ApproveDispatchResult = z.infer<typeof ApproveDispatchResultSchema>;
|
|
533
|
-
|
|
534
|
-
/* ────────────────────────────────────────────────────────────────────────────
|
|
535
|
-
* AI HOT (aihot.virxact.com) — curated AI-news source, plugged into the content
|
|
536
|
-
* board as an independent "discovery radar". Browsing candidates is LLM-free;
|
|
537
|
-
* washing runs the SAME rewrite/judge quality core as sourcepool/from-url but on
|
|
538
|
-
* the candidate's THIRD-PARTY original link (`url`), not AI HOT's own summary.
|
|
539
|
-
* Everything downstream (edit / persona / multi-account dispatch) is reused as-is.
|
|
540
|
-
* ──────────────────────────────────────────────────────────────────────────── */
|
|
541
|
-
|
|
542
|
-
/** AI HOT item category slugs (openapi enum). */
|
|
543
|
-
export const AihotCategory = z.enum(["ai-models", "ai-products", "industry", "paper", "tip"]);
|
|
544
|
-
export type AihotCategory = z.infer<typeof AihotCategory>;
|
|
545
|
-
|
|
546
|
-
/** Which AI HOT surface the discovery panel is browsing. */
|
|
547
|
-
export const AihotSurface = z.enum([
|
|
548
|
-
"hot", // /api/public/hot-topics — multi-source heat ranking
|
|
549
|
-
"selected", // /api/public/items?mode=selected — editor-curated pool
|
|
550
|
-
"all", // /api/public/items?mode=all — last-7-day public pool
|
|
551
|
-
"daily", // /api/public/daily(/{date}) — LLM-editor daily digest (sections + flashes)
|
|
552
|
-
]);
|
|
553
|
-
export type AihotSurface = z.infer<typeof AihotSurface>;
|
|
554
|
-
|
|
555
|
-
/** One normalized AI HOT candidate for the browse list (pre-wash, no LLM/DB). */
|
|
556
|
-
export const AihotCandidateSchema = z.object({
|
|
557
|
-
/** AI HOT stable item id (also the hot-topic display item id). */
|
|
558
|
-
id: z.string(),
|
|
559
|
-
/** Third-party original article URL — what we wash from and attribute to. */
|
|
560
|
-
url: z.string(),
|
|
561
|
-
/** In-site AI HOT reader page (/items/{id}) — for reference only, not attribution. */
|
|
562
|
-
permalink: z.string().nullable().default(null),
|
|
563
|
-
/** Display title (Chinese-primary). */
|
|
564
|
-
title: z.string(),
|
|
565
|
-
/** Original-language title, when it differs. */
|
|
566
|
-
title_en: z.string().nullable().default(null),
|
|
567
|
-
/** Chinese summary (items surface only; null on hot-topics). */
|
|
568
|
-
summary: z.string().nullable().default(null),
|
|
569
|
-
/** Source name string (e.g. "The Verge:AI(RSS)"). */
|
|
570
|
-
source: z.string().nullable().default(null),
|
|
571
|
-
category: AihotCategory.nullable().default(null),
|
|
572
|
-
/** AI HOT heat score 0-100 (items surface); null on hot-topics. */
|
|
573
|
-
score: z.number().int().nullable().default(null),
|
|
574
|
-
published_at: z.string().nullable().default(null),
|
|
575
|
-
/** hot-topics only: number of independent sources covering the event. */
|
|
576
|
-
source_count: z.number().int().nullable().default(null),
|
|
577
|
-
/** hot-topics only: de-duped list of source names covering the event. */
|
|
578
|
-
source_names: z.array(z.string()).default([]),
|
|
579
|
-
/** items surface: whether the item is in AI HOT's editor-selected pool. */
|
|
580
|
-
selected: z.boolean().nullable().default(null),
|
|
581
|
-
});
|
|
582
|
-
export type AihotCandidate = z.infer<typeof AihotCandidateSchema>;
|
|
583
|
-
|
|
584
|
-
export const AihotCandidatesResultSchema = z.object({
|
|
585
|
-
surface: AihotSurface,
|
|
586
|
-
items: z.array(AihotCandidateSchema),
|
|
587
|
-
count: z.number().int().default(0),
|
|
588
|
-
/** opaque cursor for the next page (items surfaces only); null = no more. */
|
|
589
|
-
next_cursor: z.string().nullable().default(null),
|
|
590
|
-
});
|
|
591
|
-
export type AihotCandidatesResult = z.infer<typeof AihotCandidatesResultSchema>;
|
|
592
|
-
|
|
593
|
-
/** One entry in the AI HOT daily-report archive index (/api/public/dailies). */
|
|
594
|
-
export const AihotDailyEntrySchema = z.object({
|
|
595
|
-
date: z.string(),
|
|
596
|
-
lead_title: z.string().nullable().default(null),
|
|
597
|
-
});
|
|
598
|
-
export type AihotDailyEntry = z.infer<typeof AihotDailyEntrySchema>;
|
|
599
|
-
|
|
600
|
-
export const AihotDailiesResultSchema = z.object({
|
|
601
|
-
items: z.array(AihotDailyEntrySchema),
|
|
602
|
-
});
|
|
603
|
-
export type AihotDailiesResult = z.infer<typeof AihotDailiesResultSchema>;
|
|
604
|
-
|
|
605
|
-
/** Wash a set of operator-picked AI HOT candidates into drafts. */
|
|
606
|
-
export const AihotWashItemSchema = z.object({
|
|
607
|
-
id: z.string(),
|
|
608
|
-
url: z.string(),
|
|
609
|
-
title: z.string().default(""),
|
|
610
|
-
title_en: z.string().nullable().default(null),
|
|
611
|
-
summary: z.string().nullable().default(null),
|
|
612
|
-
source: z.string().nullable().default(null),
|
|
613
|
-
category: AihotCategory.nullable().default(null),
|
|
614
|
-
score: z.number().int().nullable().default(null),
|
|
615
|
-
published_at: z.string().nullable().default(null),
|
|
616
|
-
});
|
|
617
|
-
export type AihotWashItem = z.infer<typeof AihotWashItemSchema>;
|
|
618
|
-
|
|
619
|
-
export const AihotWashBodySchema = z.object({
|
|
620
|
-
items: z.array(AihotWashItemSchema).min(1).max(20),
|
|
621
|
-
format: z.enum(["short", "long", "both"]).default("short"),
|
|
622
|
-
/** Local model override; null/absent = global content profile. Not persisted. */
|
|
623
|
-
llm_profile_id: z.string().uuid().nullish(),
|
|
624
|
-
});
|
|
625
|
-
export type AihotWashBody = z.infer<typeof AihotWashBodySchema>;
|
|
626
|
-
|
|
627
|
-
export const AihotWashResultSchema = z.object({
|
|
628
|
-
generated: z.number().int(),
|
|
629
|
-
skipped: z.number().int(),
|
|
630
|
-
/** ids that produced at least one draft. */
|
|
631
|
-
washed_ids: z.array(z.string()).default([]),
|
|
632
|
-
});
|
|
633
|
-
export type AihotWashResult = z.infer<typeof AihotWashResultSchema>;
|
|
634
|
-
|
|
635
|
-
/** AI HOT polling + auto-wash settings (single-row config). */
|
|
636
|
-
export const AihotSettingsSchema = z.object({
|
|
637
|
-
/** Background fingerprint polling (badge notify). Default on. */
|
|
638
|
-
poll_enabled: z.boolean().default(true),
|
|
639
|
-
/** Minimum minutes between fingerprint polls (AI HOT recommends ≥1min). */
|
|
640
|
-
poll_interval_min: z.number().int().min(1).max(1440).default(5),
|
|
641
|
-
/** High-score auto-wash into the shared pool. Default OFF. */
|
|
642
|
-
autowash_enabled: z.boolean().default(false),
|
|
643
|
-
/** Only auto-wash items with score ≥ this. */
|
|
644
|
-
autowash_min_score: z.number().int().min(0).max(100).default(80),
|
|
645
|
-
/** Skip x.com/twitter originals (no scrapeable full text). */
|
|
646
|
-
autowash_exclude_tweets: z.boolean().default(true),
|
|
647
|
-
autowash_format: z.enum(["short", "long", "both"]).default("short"),
|
|
648
|
-
/** Hard cap on drafts produced per auto-wash run. */
|
|
649
|
-
autowash_max_per_run: z.number().int().min(1).max(20).default(5),
|
|
650
|
-
/** LLM profile for auto-wash; null = global content profile. */
|
|
651
|
-
autowash_profile_id: z.string().nullable().default(null),
|
|
652
|
-
/** Last poll time (GET only, observability). */
|
|
653
|
-
last_polled_at: z.string().nullable().optional(),
|
|
654
|
-
});
|
|
655
|
-
export type AihotSettings = z.infer<typeof AihotSettingsSchema>;
|
|
656
|
-
|
|
657
|
-
export const AihotSettingsPatchSchema = z
|
|
658
|
-
.object({
|
|
659
|
-
poll_enabled: z.boolean().optional(),
|
|
660
|
-
poll_interval_min: z.number().int().min(1).max(1440).optional(),
|
|
661
|
-
autowash_enabled: z.boolean().optional(),
|
|
662
|
-
autowash_min_score: z.number().int().min(0).max(100).optional(),
|
|
663
|
-
autowash_exclude_tweets: z.boolean().optional(),
|
|
664
|
-
autowash_format: z.enum(["short", "long", "both"]).optional(),
|
|
665
|
-
autowash_max_per_run: z.number().int().min(1).max(20).optional(),
|
|
666
|
-
autowash_profile_id: z.string().nullable().optional(),
|
|
667
|
-
})
|
|
668
|
-
.refine((v) => Object.keys(v).length > 0, {
|
|
669
|
-
message: "patch body must contain at least one field",
|
|
670
|
-
});
|
|
671
|
-
export type AihotSettingsPatch = z.infer<typeof AihotSettingsPatchSchema>;
|
|
672
|
-
|
|
673
|
-
/** Broadcast row for the `ai_hot` topic — "new hot content" signal. */
|
|
674
|
-
export const AihotBroadcastRowSchema = z.object({
|
|
675
|
-
selected_changed: z.boolean(),
|
|
676
|
-
all_changed: z.boolean(),
|
|
677
|
-
at: z.string(),
|
|
678
|
-
});
|
|
679
|
-
export type AihotBroadcastRow = z.infer<typeof AihotBroadcastRowSchema>;
|
|
680
|
-
|
|
681
|
-
/* ────────────────────────────────────────────────────────────────────────────
|
|
682
|
-
* Tweet interaction(蹭热度): worker 对某条 X 推文发有观点的评论 — 涨粉引流。
|
|
683
|
-
* kind='reply' 在原推底下评论(进它的 thread);
|
|
684
|
-
* kind='quote' 引用转推到自己时间线并 @原作者(进你粉丝的 feed)。
|
|
685
|
-
* 生成用 tweet 全文,每号不同角度+persona;派发复用错峰/风控/对账链路。
|
|
686
|
-
* ──────────────────────────────────────────────────────────────────────────── */
|
|
687
|
-
|
|
688
|
-
/** reply = comment under the tweet; quote = quote-tweet to your own timeline. */
|
|
689
|
-
export const InteractionKind = z.enum(["reply", "quote"]);
|
|
690
|
-
export type InteractionKind = z.infer<typeof InteractionKind>;
|
|
691
|
-
|
|
692
|
-
/** The X interactions a worker can do on one tweet, done in this order in one visit. */
|
|
693
|
-
export const InteractionAction = z.enum(["like", "repost", "reply", "quote", "follow"]);
|
|
694
|
-
export type InteractionAction = z.infer<typeof InteractionAction>;
|
|
695
|
-
|
|
696
|
-
/** Reply angles — assigned round-robin across workers (auto-diverse) or picked. */
|
|
697
|
-
export const ReplyAngle = z.enum([
|
|
698
|
-
"add_insight", // 补充洞见
|
|
699
|
-
"respectful_challenge", // 提出质疑
|
|
700
|
-
"data_point", // 补数据/案例
|
|
701
|
-
"ask_question", // 真诚反问
|
|
702
|
-
"personal_experience", // 分享经验
|
|
703
|
-
"alt_view", // 另一视角
|
|
704
|
-
"witty", // 玩梗/幽默
|
|
705
|
-
"agree_extend", // 认同并延伸
|
|
706
|
-
]);
|
|
707
|
-
export type ReplyAngle = z.infer<typeof ReplyAngle>;
|
|
708
|
-
|
|
709
|
-
/** STEP 1 — generate one per-worker reply (different angle each). */
|
|
710
|
-
export const GenerateRepliesBodySchema = z.object({
|
|
711
|
-
/** which interactions to perform (content is generated only if reply/quote present). */
|
|
712
|
-
actions: z.array(InteractionAction).min(1).default(["reply"]),
|
|
713
|
-
reply_to_url: z.string().url(),
|
|
714
|
-
/** Tweet full text (client already has it from oEmbed); server refetches if absent. */
|
|
715
|
-
tweet_text: z.string().max(6000).default(""),
|
|
716
|
-
tweet_author: z.string().max(120).default(""),
|
|
717
|
-
worker_ids: z.array(Uuid).default([]),
|
|
718
|
-
group_ids: z.array(Uuid).default([]),
|
|
719
|
-
/** auto = round-robin distinct angles; manual = use `angle` + `direction` for all. */
|
|
720
|
-
mode: z.enum(["auto", "manual"]).default("auto"),
|
|
721
|
-
angle: ReplyAngle.nullish(),
|
|
722
|
-
/** Free-form stance/direction the operator wants the replies to take. */
|
|
723
|
-
direction: z.string().max(600).default(""),
|
|
724
|
-
/** Reply language: "follow" = match the tweet; or an explicit code. */
|
|
725
|
-
lang: z.string().default("follow"),
|
|
726
|
-
llm_profile_id: z.string().uuid().nullish(),
|
|
727
|
-
});
|
|
728
|
-
export type GenerateRepliesBody = z.infer<typeof GenerateRepliesBodySchema>;
|
|
729
|
-
|
|
730
|
-
export const ReplyDraftItemSchema = z.object({
|
|
731
|
-
worker_id: z.string(),
|
|
732
|
-
worker_name: z.string().nullable().default(null),
|
|
733
|
-
handle: z.string(),
|
|
734
|
-
angle: ReplyAngle,
|
|
735
|
-
text: z.string(),
|
|
736
|
-
has_persona: z.boolean().default(false),
|
|
737
|
-
/** this worker already replied to this tweet (skip by default). */
|
|
738
|
-
already_replied: z.boolean().default(false),
|
|
739
|
-
});
|
|
740
|
-
export type ReplyDraftItem = z.infer<typeof ReplyDraftItemSchema>;
|
|
741
|
-
|
|
742
|
-
export const GenerateRepliesResultSchema = z.object({
|
|
743
|
-
items: z.array(ReplyDraftItemSchema),
|
|
744
|
-
});
|
|
745
|
-
export type GenerateRepliesResult = z.infer<typeof GenerateRepliesResultSchema>;
|
|
746
|
-
|
|
747
|
-
/** STEP 2 — approve + dispatch the (operator-edited) replies, staggered. */
|
|
748
|
-
export const ApproveReplyItemSchema = z.object({
|
|
749
|
-
worker_id: z.string(),
|
|
750
|
-
/** reply/quote comment text; empty for pure like/repost combos. */
|
|
751
|
-
text: z.string().max(280).default(""),
|
|
752
|
-
angle: ReplyAngle.nullish(),
|
|
753
|
-
});
|
|
754
|
-
export type ApproveReplyItem = z.infer<typeof ApproveReplyItemSchema>;
|
|
755
|
-
|
|
756
|
-
export const ApproveRepliesBodySchema = z.object({
|
|
757
|
-
actions: z.array(InteractionAction).min(1).default(["reply"]),
|
|
758
|
-
reply_to_url: z.string().url(),
|
|
759
|
-
items: z.array(ApproveReplyItemSchema).min(1).max(100), // sane hard bound
|
|
760
|
-
/** ⚡ Fast mode: skip pre-generation — the WORKER's agent composes the reply/quote
|
|
761
|
-
* at execution time (instant dispatch, no review). The fields below shape that
|
|
762
|
-
* on-worker composition (only read when fast_mode + reply/quote). */
|
|
763
|
-
fast_mode: z.boolean().default(false),
|
|
764
|
-
mode: z.enum(["auto", "manual"]).default("auto"),
|
|
765
|
-
angle: ReplyAngle.nullish(),
|
|
766
|
-
direction: z.string().max(600).default(""),
|
|
767
|
-
lang: z.string().default("follow"),
|
|
768
|
-
/** Dispatch window: spread evenly across this many seconds (0 = off). Mutually
|
|
769
|
-
* exclusive with random_delay_seconds — window wins if both set. */
|
|
770
|
-
dispatch_window_seconds: z.number().int().min(0).max(86400).default(1800),
|
|
771
|
-
/** Random delay: scatter each randomly within this many seconds (0 = off). */
|
|
772
|
-
random_delay_seconds: z.number().int().min(0).max(86400).default(0),
|
|
773
|
-
/** Post each at the next golden hour in its own timezone instead. */
|
|
774
|
-
per_account_timezone: z.boolean().default(false),
|
|
775
|
-
scheduled_at: z.string().datetime().nullable().optional(),
|
|
776
|
-
});
|
|
777
|
-
export type ApproveRepliesBody = z.infer<typeof ApproveRepliesBodySchema>;
|
|
778
|
-
|
|
779
|
-
export const ApproveRepliesResultSchema = z.object({
|
|
780
|
-
batch_id: z.string(),
|
|
781
|
-
dispatched: z.array(z.object({ worker_id: z.string(), task_run_id: z.string() })),
|
|
782
|
-
skipped_workers: z.array(z.string()).default([]),
|
|
783
|
-
/** Estimated dispatch window (ISO): first eligible → last eligible. */
|
|
784
|
-
eta_from: z.string().nullable().default(null),
|
|
785
|
-
eta_to: z.string().nullable().default(null),
|
|
786
|
-
});
|
|
787
|
-
export type ApproveRepliesResult = z.infer<typeof ApproveRepliesResultSchema>;
|
|
788
|
-
|
|
789
|
-
/** Preview the material text that WOULD be washed for one candidate (no LLM, no DB). */
|
|
790
|
-
export const AihotPreviewBodySchema = z.object({
|
|
791
|
-
url: z.string(),
|
|
792
|
-
title: z.string().default(""),
|
|
793
|
-
title_en: z.string().nullable().default(null),
|
|
794
|
-
summary: z.string().nullable().default(null),
|
|
795
|
-
});
|
|
796
|
-
export type AihotPreviewBody = z.infer<typeof AihotPreviewBodySchema>;
|
|
797
|
-
|
|
798
|
-
export const AihotPreviewResultSchema = z.object({
|
|
799
|
-
/** article = scraped third-party full text; tweet = full tweet text via oEmbed;
|
|
800
|
-
* fallback = AI HOT summary+title (unscrapeable); empty = nothing washable. */
|
|
801
|
-
mode: z.enum(["article", "tweet", "fallback", "empty"]),
|
|
802
|
-
/** total material chars available (text below may be truncated for display). */
|
|
803
|
-
chars: z.number().int(),
|
|
804
|
-
/** the material text (truncated for preview display). */
|
|
805
|
-
text: z.string(),
|
|
806
|
-
});
|
|
807
|
-
export type AihotPreviewResult = z.infer<typeof AihotPreviewResultSchema>;
|