jacky-creator 0.1.0-beta.6

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.
@@ -0,0 +1,1006 @@
1
+ import { z } from "zod";
2
+ const PUBLISH_PLATFORMS = Object.freeze(Object.keys({
3
+ xiaohongshu: {
4
+ name: "小红书",
5
+ icon: "xhs",
6
+ settingsLabel: "settings.platform.xiaohongshu",
7
+ inspectorLabel: "inspector.platform.xhs",
8
+ collectUrl: "https://creator.xiaohongshu.com/new/note-manager"
9
+ },
10
+ douyin: {
11
+ name: "抖音",
12
+ icon: "douyin",
13
+ settingsLabel: "settings.platform.douyin",
14
+ inspectorLabel: "inspector.platform.douyin",
15
+ collectUrl: "https://creator.douyin.com/creator-micro/content/manage"
16
+ },
17
+ bilibili: {
18
+ name: "B站",
19
+ icon: "bilibili",
20
+ settingsLabel: "settings.platform.bilibili",
21
+ inspectorLabel: "inspector.platform.bilibili",
22
+ collectUrl: "https://member.bilibili.com/platform/upload-manager/article"
23
+ },
24
+ wechat: {
25
+ name: "视频号",
26
+ icon: "wechat",
27
+ settingsLabel: "settings.platform.wechat",
28
+ inspectorLabel: "inspector.platform.wechat",
29
+ collectUrl: "https://channels.weixin.qq.com/platform/post/list"
30
+ }
31
+ }));
32
+ //#endregion
33
+ //#region src/schemas.ts
34
+ const contentCoversSchema = z.object({
35
+ "3x4": z.string().optional(),
36
+ "4x3": z.string().optional(),
37
+ "16x9": z.string().optional()
38
+ });
39
+ const contentSubtitlesSchema = z.object({
40
+ srt: z.string().optional(),
41
+ ass: z.string().optional(),
42
+ transcript: z.string().optional()
43
+ });
44
+ const contentPresentationsSchema = z.object({
45
+ "16x9": z.string().optional(),
46
+ "3x4": z.string().optional()
47
+ });
48
+ const pipelineSchema = z.union([
49
+ z.literal("raw"),
50
+ z.literal("subtitled"),
51
+ z.literal("covered"),
52
+ z.literal("packaged")
53
+ ]);
54
+ const workflowSchema = z.union([
55
+ z.literal("idle"),
56
+ z.literal("record"),
57
+ z.literal("cut"),
58
+ z.literal("finish"),
59
+ z.literal("publish"),
60
+ z.literal("live")
61
+ ]);
62
+ const contentOptionalStepSchema = z.union([
63
+ z.literal("presentation"),
64
+ z.literal("subtitle"),
65
+ z.literal("article")
66
+ ]);
67
+ const publishMarkSchema = z.union([
68
+ z.literal("unpublished"),
69
+ z.literal("draft"),
70
+ z.literal("published")
71
+ ]);
72
+ const publishPlatformSchema = z.enum(PUBLISH_PLATFORMS);
73
+ const platformPublishSchema = z.object({
74
+ status: publishMarkSchema,
75
+ source: z.union([
76
+ z.literal("none"),
77
+ z.literal("publisher"),
78
+ z.literal("overlay"),
79
+ z.literal("sync")
80
+ ]),
81
+ url: z.string().optional(),
82
+ remoteId: z.string().optional(),
83
+ views: z.number().optional(),
84
+ likes: z.number().optional(),
85
+ comments: z.number().optional(),
86
+ publishedAt: z.number().optional(),
87
+ syncedAt: z.number().optional()
88
+ });
89
+ const contentPublishSchema = z.object(Object.fromEntries(PUBLISH_PLATFORMS.map((platform) => [platform, platformPublishSchema])));
90
+ const burnJobSchema = z.object({
91
+ status: z.union([
92
+ z.literal("idle"),
93
+ z.literal("running"),
94
+ z.literal("done"),
95
+ z.literal("error")
96
+ ]),
97
+ startedAt: z.number().optional(),
98
+ output: z.string().optional(),
99
+ error: z.string().optional(),
100
+ pid: z.number().optional()
101
+ });
102
+ const contentSummarySchema = z.object({
103
+ id: z.string().min(1),
104
+ folderPath: z.string().min(1),
105
+ title: z.string(),
106
+ date: z.string().optional(),
107
+ recordedAt: z.number(),
108
+ createdMs: z.number(),
109
+ videoRaw: z.string().optional(),
110
+ videoSubtitled: z.string().optional(),
111
+ covers: contentCoversSchema,
112
+ subtitles: contentSubtitlesSchema,
113
+ presentations: contentPresentationsSchema,
114
+ hasPublishPackage: z.boolean(),
115
+ hasArticle: z.boolean(),
116
+ studioPath: z.string().optional(),
117
+ waitingForExport: z.boolean(),
118
+ exportTimedOut: z.boolean().optional(),
119
+ articlePath: z.string().optional(),
120
+ skippedSteps: z.array(contentOptionalStepSchema).optional(),
121
+ tags: z.array(z.string()),
122
+ pipeline: pipelineSchema,
123
+ workflow: workflowSchema,
124
+ publish: contentPublishSchema,
125
+ burn: burnJobSchema,
126
+ subtitleJob: burnJobSchema,
127
+ coverJob: burnJobSchema
128
+ });
129
+ const creatorProfileSchema = z.object({ enabledPlatforms: z.array(publishPlatformSchema) });
130
+ const secretViewSchema = z.object({
131
+ kind: z.union([z.literal("subtitle"), z.literal("cover")]),
132
+ ref: z.string(),
133
+ configured: z.boolean(),
134
+ writable: z.boolean(),
135
+ source: z.string().optional()
136
+ });
137
+ const librarySettingsSchema = z.object({
138
+ libraryRoot: z.string(),
139
+ profile: creatorProfileSchema,
140
+ secrets: z.object({
141
+ subtitle: secretViewSchema,
142
+ cover: secretViewSchema
143
+ }),
144
+ scriptRules: z.string().optional()
145
+ });
146
+ const listContentsRequestSchema = z.object({
147
+ query: z.string(),
148
+ filter: z.union([
149
+ z.literal("all"),
150
+ z.literal("cover"),
151
+ z.literal("subtitle"),
152
+ z.literal("article")
153
+ ])
154
+ });
155
+ const listContentsResultSchema = z.object({
156
+ settings: librarySettingsSchema,
157
+ items: z.array(contentSummarySchema),
158
+ counts: z.object({
159
+ total: z.number().int().nonnegative(),
160
+ cover: z.number().int().nonnegative(),
161
+ subtitle: z.number().int().nonnegative(),
162
+ article: z.number().int().nonnegative()
163
+ }),
164
+ revision: z.number().int().nonnegative()
165
+ });
166
+ const idRequestSchema$1 = z.object({ id: z.string().min(1) });
167
+ const contentDetailSchema = contentSummarySchema.and(z.object({
168
+ publishCopy: z.string(),
169
+ topicNote: z.string(),
170
+ script: z.string(),
171
+ article: z.string(),
172
+ secrets: z.object({
173
+ subtitle: secretViewSchema,
174
+ cover: secretViewSchema
175
+ })
176
+ }));
177
+ const coverThumbResultSchema = z.object({
178
+ found: z.boolean(),
179
+ mime: z.string(),
180
+ base64: z.string()
181
+ });
182
+ const videoPlaybackResultSchema = z.object({
183
+ found: z.boolean(),
184
+ url: z.string(),
185
+ kind: z.union([z.literal("raw"), z.literal("subtitled")])
186
+ });
187
+ const articleMediaResultSchema = z.object({
188
+ found: z.boolean(),
189
+ origin: z.string()
190
+ });
191
+ const subtitleTextResultSchema = z.object({
192
+ text: z.string(),
193
+ cues: z.array(z.object({
194
+ text: z.string(),
195
+ at: z.string().optional()
196
+ }))
197
+ });
198
+ const setContentStageRequestSchema = z.object({
199
+ id: z.string().min(1),
200
+ readyToRecord: z.boolean()
201
+ });
202
+ const setContentSkipRequestSchema = z.object({
203
+ id: z.string().min(1),
204
+ step: contentOptionalStepSchema,
205
+ skipped: z.boolean()
206
+ });
207
+ const bindStudioRequestSchema = z.object({
208
+ id: z.string().min(1),
209
+ path: z.string().min(1)
210
+ });
211
+ const setPublishRequestSchema = z.object({
212
+ id: z.string().min(1),
213
+ platform: publishPlatformSchema,
214
+ status: publishMarkSchema,
215
+ url: z.string().optional(),
216
+ publishedAt: z.number().int().nonnegative().optional()
217
+ });
218
+ const subtitlePreviewResultSchema = z.object({
219
+ url: z.string().min(1),
220
+ port: z.number().int().positive()
221
+ });
222
+ const syncPublishRequestSchema = z.object({
223
+ id: z.string().min(1).optional(),
224
+ platform: publishPlatformSchema.optional(),
225
+ force: z.boolean().optional()
226
+ });
227
+ const syncPublishResultSchema = z.object({
228
+ matched: z.number().int().nonnegative(),
229
+ cached: z.boolean().optional(),
230
+ platforms: z.array(z.object({
231
+ platform: publishPlatformSchema,
232
+ count: z.number().int().nonnegative(),
233
+ loginRequired: z.boolean().optional(),
234
+ error: z.string().optional()
235
+ }))
236
+ });
237
+ const revisionResultSchema = z.object({ revision: z.number().int().nonnegative() });
238
+ const creatorInstallTargetSchema = z.union([
239
+ z.literal("subtitle"),
240
+ z.literal("coverBase"),
241
+ z.literal("editing"),
242
+ z.literal("publisher")
243
+ ]);
244
+ const capabilitySchema = z.object({
245
+ state: z.union([
246
+ z.literal("ready"),
247
+ z.literal("missing"),
248
+ z.literal("unsupported")
249
+ ]),
250
+ required: z.boolean(),
251
+ detail: z.string(),
252
+ path: z.string().optional(),
253
+ skillName: z.string().optional(),
254
+ installTarget: creatorInstallTargetSchema.optional()
255
+ });
256
+ const capabilitiesResultSchema = z.object({ capabilities: z.object({
257
+ library: capabilitySchema,
258
+ screenStudio: capabilitySchema,
259
+ subtitleSkill: capabilitySchema,
260
+ subtitleCredential: capabilitySchema,
261
+ coverSkill: capabilitySchema,
262
+ coverCredential: capabilitySchema,
263
+ publishSync: capabilitySchema,
264
+ editingSkill: capabilitySchema,
265
+ publishSkill: capabilitySchema,
266
+ presentationSkill: capabilitySchema,
267
+ articleSkill: capabilitySchema
268
+ }) });
269
+ const installCapabilityRequestSchema = z.object({
270
+ target: creatorInstallTargetSchema,
271
+ confirmed: z.literal(true)
272
+ });
273
+ const installCapabilityResultSchema = z.object({
274
+ target: creatorInstallTargetSchema,
275
+ changed: z.boolean(),
276
+ detail: z.string(),
277
+ capabilities: capabilitiesResultSchema.shape.capabilities
278
+ });
279
+ const platformLoginRequestSchema = z.object({ platforms: z.array(publishPlatformSchema).optional() });
280
+ const platformLoginResultSchema = z.object({ platforms: z.array(z.object({
281
+ platform: publishPlatformSchema,
282
+ state: z.union([
283
+ z.literal("authenticated"),
284
+ z.literal("loginRequired"),
285
+ z.literal("unknown"),
286
+ z.literal("error")
287
+ ]),
288
+ detail: z.string().optional()
289
+ })) });
290
+ const openPlatformLoginRequestSchema = z.object({ platform: publishPlatformSchema });
291
+ const openPlatformLoginResultSchema = z.object({ opened: z.boolean() });
292
+ const waitExportRequestSchema = z.object({
293
+ id: z.string().min(1),
294
+ timeoutMs: z.number().optional()
295
+ });
296
+ const setLibraryRootRequestSchema = z.object({ path: z.string().min(1) });
297
+ const createContentRequestSchema = z.object({ title: z.string().min(1) });
298
+ const createContentResultSchema = z.object({
299
+ id: z.string().min(1),
300
+ folderPath: z.string().min(1)
301
+ });
302
+ const setProfileRequestSchema = z.object({ profile: creatorProfileSchema });
303
+ const setScriptRulesRequestSchema = z.object({ text: z.string() });
304
+ const setTopicNoteRequestSchema = z.object({
305
+ id: z.string().min(1),
306
+ text: z.string()
307
+ });
308
+ const setScriptRequestSchema = z.object({
309
+ id: z.string().min(1),
310
+ text: z.string()
311
+ });
312
+ z.object({
313
+ apply: z.boolean(),
314
+ ids: z.array(z.string())
315
+ });
316
+ z.object({
317
+ moves: z.array(z.object({
318
+ from: z.string().min(1),
319
+ to: z.string().min(1),
320
+ reason: z.union([
321
+ z.literal("add-date"),
322
+ z.literal("readable-title"),
323
+ z.literal("both")
324
+ ])
325
+ })),
326
+ unchanged: z.number().int().nonnegative()
327
+ });
328
+ //#endregion
329
+ //#region src/remote-contract.ts
330
+ const PACKAGE_NAME = "jacky-creator";
331
+ const REMOTE_NAMESPACE = "oilCreator";
332
+ const emptyObjectSchema = z.object({});
333
+ function codec$1(typeSymbol, schema) {
334
+ return {
335
+ mode: "strict",
336
+ typeSymbol,
337
+ schema
338
+ };
339
+ }
340
+ function jsonParam$1(name, typeSymbol, schema) {
341
+ return {
342
+ name,
343
+ wire: name,
344
+ source: "json",
345
+ codec: codec$1(typeSymbol, schema)
346
+ };
347
+ }
348
+ function invocation$1(method, request, result) {
349
+ return {
350
+ id: `${PACKAGE_NAME}#${REMOTE_NAMESPACE}/${method}`,
351
+ service: REMOTE_NAMESPACE,
352
+ namespace: REMOTE_NAMESPACE,
353
+ method,
354
+ invocation: { kind: "direct" },
355
+ parameters: [jsonParam$1("request", `${PACKAGE_NAME}#${method}Request`, request)],
356
+ cancellation: { parameter: "signal" },
357
+ result: codec$1(`${PACKAGE_NAME}#${method}Result`, result),
358
+ sourceLocation: {
359
+ file: "src/service.ts",
360
+ line: 1,
361
+ column: 1
362
+ }
363
+ };
364
+ }
365
+ const OIL_CREATOR_INVOCATIONS = [
366
+ invocation$1("listContents", listContentsRequestSchema, listContentsResultSchema),
367
+ invocation$1("getContent", idRequestSchema$1, contentDetailSchema),
368
+ invocation$1("getCoverThumb", idRequestSchema$1, coverThumbResultSchema),
369
+ invocation$1("getVideoPlayback", idRequestSchema$1, videoPlaybackResultSchema),
370
+ invocation$1("getArticleMedia", idRequestSchema$1, articleMediaResultSchema),
371
+ invocation$1("getSubtitleText", idRequestSchema$1, subtitleTextResultSchema),
372
+ invocation$1("getSettings", emptyObjectSchema, librarySettingsSchema),
373
+ invocation$1("getCapabilities", emptyObjectSchema, capabilitiesResultSchema),
374
+ invocation$1("installCapability", installCapabilityRequestSchema, installCapabilityResultSchema),
375
+ invocation$1("checkPlatformLogins", platformLoginRequestSchema, platformLoginResultSchema),
376
+ invocation$1("openPlatformLogin", openPlatformLoginRequestSchema, openPlatformLoginResultSchema),
377
+ invocation$1("getRevision", emptyObjectSchema, revisionResultSchema),
378
+ invocation$1("setLibraryRoot", setLibraryRootRequestSchema, librarySettingsSchema),
379
+ invocation$1("refreshCatalog", emptyObjectSchema, listContentsResultSchema),
380
+ invocation$1("createContent", createContentRequestSchema, createContentResultSchema),
381
+ invocation$1("setContentStage", setContentStageRequestSchema, contentDetailSchema),
382
+ invocation$1("setContentSkip", setContentSkipRequestSchema, contentDetailSchema),
383
+ invocation$1("setProfile", setProfileRequestSchema, librarySettingsSchema),
384
+ invocation$1("setScriptRules", setScriptRulesRequestSchema, librarySettingsSchema),
385
+ invocation$1("bindStudio", bindStudioRequestSchema, contentDetailSchema),
386
+ invocation$1("openStudio", idRequestSchema$1, contentDetailSchema),
387
+ invocation$1("setPublish", setPublishRequestSchema, contentDetailSchema),
388
+ invocation$1("syncPublish", syncPublishRequestSchema, syncPublishResultSchema),
389
+ invocation$1("setScript", setScriptRequestSchema, contentDetailSchema),
390
+ invocation$1("setTopicNote", setTopicNoteRequestSchema, contentDetailSchema),
391
+ invocation$1("waitForExport", waitExportRequestSchema, contentDetailSchema),
392
+ invocation$1("openSubtitlePreview", idRequestSchema$1, subtitlePreviewResultSchema),
393
+ invocation$1("startSubtitleBurn", idRequestSchema$1, contentDetailSchema),
394
+ invocation$1("startSubtitleGenerate", idRequestSchema$1, contentDetailSchema),
395
+ invocation$1("startCoverGenerate", idRequestSchema$1, contentDetailSchema)
396
+ ];
397
+ const ideaStatusSchema = z.enum([
398
+ "inbox",
399
+ "considering",
400
+ "promoted",
401
+ "archived"
402
+ ]);
403
+ const prioritySchema = z.enum([
404
+ "low",
405
+ "normal",
406
+ "high"
407
+ ]);
408
+ const hookTypeSchema = z.enum([
409
+ "information-gap",
410
+ "nonconsensus",
411
+ "pain",
412
+ "result",
413
+ "value-promise",
414
+ "identity",
415
+ "contrast",
416
+ "proof",
417
+ "custom"
418
+ ]);
419
+ const structureTypeSchema = z.enum([
420
+ "pyramid",
421
+ "problem-cause-solution",
422
+ "result-method-proof",
423
+ "pain-misconception-solution",
424
+ "value-steps-delivery",
425
+ "comparison-judgment",
426
+ "story-turn-insight",
427
+ "list",
428
+ "case-study",
429
+ "custom"
430
+ ]);
431
+ const scheduleKindSchema = z.enum([
432
+ "content",
433
+ "review",
434
+ "live",
435
+ "custom"
436
+ ]);
437
+ const scheduleMilestoneSchema = z.enum([
438
+ "topic",
439
+ "script",
440
+ "recording",
441
+ "editing",
442
+ "publishing",
443
+ "review",
444
+ "custom"
445
+ ]);
446
+ const knowledgeKindSchema = z.enum(["rule", "template"]);
447
+ const goalMetricSchema = z.enum([
448
+ "published",
449
+ "views",
450
+ "likes",
451
+ "comments",
452
+ "followers",
453
+ "custom"
454
+ ]);
455
+ const evaluationScoresSchema = z.object({
456
+ audience: z.number().int().min(0).max(5),
457
+ pain: z.number().int().min(0).max(5),
458
+ differentiation: z.number().int().min(0).max(5),
459
+ assets: z.number().int().min(0).max(5),
460
+ hook: z.number().int().min(0).max(5),
461
+ structure: z.number().int().min(0).max(5)
462
+ }).strict();
463
+ const contentEvaluationSchema = z.object({
464
+ id: z.string().min(1),
465
+ contentId: z.string().min(1),
466
+ rubricVersion: z.string().min(1),
467
+ scores: evaluationScoresSchema,
468
+ total: z.number().int().min(0).max(30),
469
+ evidence: z.record(z.string(), z.string()),
470
+ suggestions: z.array(z.string()),
471
+ inputFingerprint: z.string().min(1),
472
+ createdAt: z.number().int().nonnegative(),
473
+ confirmedAt: z.number().int().nonnegative().optional()
474
+ }).strict().superRefine((evaluation, context) => {
475
+ const total = Object.values(evaluation.scores).reduce((sum, score) => sum + score, 0);
476
+ if (evaluation.total !== total) context.addIssue({
477
+ code: "custom",
478
+ message: "evaluation total must equal score sum",
479
+ path: ["total"]
480
+ });
481
+ });
482
+ const contentReviewSchema = z.object({
483
+ id: z.string().min(1),
484
+ contentId: z.string().min(1),
485
+ status: z.enum(["draft", "confirmed"]),
486
+ rating: z.number().int().min(1).max(5).optional(),
487
+ analysis: z.string(),
488
+ learnedRule: z.string().optional(),
489
+ inputFingerprint: z.string().min(1),
490
+ createdAt: z.number().int().nonnegative(),
491
+ confirmedAt: z.number().int().nonnegative().optional()
492
+ }).strict().superRefine((review, context) => {
493
+ if (review.status === "confirmed" && review.confirmedAt === void 0) context.addIssue({
494
+ code: "custom",
495
+ message: "confirmed review requires confirmedAt",
496
+ path: ["confirmedAt"]
497
+ });
498
+ if (review.status === "draft" && review.confirmedAt !== void 0) context.addIssue({
499
+ code: "custom",
500
+ message: "draft review cannot have confirmedAt",
501
+ path: ["confirmedAt"]
502
+ });
503
+ });
504
+ const supplementalMetricsSchema = z.object({
505
+ saves: z.number().int().nonnegative().optional(),
506
+ followerGain: z.number().int().optional(),
507
+ clickRate: z.number().min(0).max(100).optional(),
508
+ retentionRate: z.number().min(0).max(100).optional(),
509
+ note: z.string().optional()
510
+ }).strict();
511
+ const ideaSchema = z.object({
512
+ id: z.string().min(1),
513
+ title: z.string().min(1),
514
+ note: z.string(),
515
+ source: z.string().optional(),
516
+ tags: z.array(z.string()),
517
+ contentType: z.string().optional(),
518
+ tier: z.string().optional(),
519
+ status: ideaStatusSchema,
520
+ goalId: z.string().min(1).optional(),
521
+ promotedContentId: z.string().min(1).optional(),
522
+ createdAt: z.number().int().nonnegative(),
523
+ updatedAt: z.number().int().nonnegative()
524
+ }).strict();
525
+ const contentOperationsMetaSchema = z.object({
526
+ contentId: z.string().min(1),
527
+ contentType: z.string().optional(),
528
+ tier: z.string().optional(),
529
+ priority: prioritySchema.optional(),
530
+ nextAction: z.string().optional(),
531
+ tags: z.array(z.string()),
532
+ hookType: hookTypeSchema.optional(),
533
+ customHook: z.string().optional(),
534
+ structureType: structureTypeSchema.optional(),
535
+ customStructure: z.string().optional(),
536
+ knowledgeIds: z.array(z.string().min(1)),
537
+ goalIds: z.array(z.string().min(1)),
538
+ supplementalMetrics: supplementalMetricsSchema.optional(),
539
+ evaluations: z.array(contentEvaluationSchema),
540
+ reviews: z.array(contentReviewSchema),
541
+ updatedAt: z.number().int().nonnegative()
542
+ }).strict();
543
+ const scheduleItemSchema = z.object({
544
+ id: z.string().min(1),
545
+ kind: scheduleKindSchema,
546
+ milestone: scheduleMilestoneSchema,
547
+ title: z.string().min(1),
548
+ contentId: z.string().min(1).optional(),
549
+ typeId: z.string().min(1).optional(),
550
+ plannedAt: z.number().int().nonnegative(),
551
+ rank: z.number().int().nonnegative(),
552
+ completedAt: z.number().int().nonnegative().optional(),
553
+ note: z.string(),
554
+ createdAt: z.number().int().nonnegative(),
555
+ updatedAt: z.number().int().nonnegative()
556
+ }).strict();
557
+ const knowledgeItemSchema = z.object({
558
+ id: z.string().min(1),
559
+ kind: knowledgeKindSchema,
560
+ title: z.string().min(1),
561
+ body: z.string().min(1),
562
+ tags: z.array(z.string()),
563
+ sourceContentId: z.string().min(1),
564
+ sourceReviewId: z.string().min(1),
565
+ markdownPath: z.string().min(1),
566
+ active: z.boolean(),
567
+ createdAt: z.number().int().nonnegative(),
568
+ updatedAt: z.number().int().nonnegative()
569
+ }).strict();
570
+ const goalSchema = z.object({
571
+ id: z.string().min(1),
572
+ name: z.string().min(1),
573
+ metric: goalMetricSchema,
574
+ target: z.number().nonnegative(),
575
+ manualCurrent: z.number().optional(),
576
+ startAt: z.number().int().nonnegative(),
577
+ endAt: z.number().int().nonnegative(),
578
+ contentIds: z.array(z.string().min(1)),
579
+ primary: z.boolean(),
580
+ contentTypeTargets: z.array(z.object({
581
+ contentType: z.string().trim().min(1).max(120),
582
+ target: z.number().int().nonnegative()
583
+ }).strict()),
584
+ followerStart: z.number().int().nonnegative().optional(),
585
+ followerTarget: z.number().int().nonnegative().optional(),
586
+ archivedAt: z.number().int().nonnegative().optional(),
587
+ note: z.string(),
588
+ createdAt: z.number().int().nonnegative(),
589
+ updatedAt: z.number().int().nonnegative()
590
+ }).strict().superRefine((goal, context) => {
591
+ if (goal.endAt < goal.startAt) context.addIssue({
592
+ code: "custom",
593
+ message: "endAt must not be earlier than startAt",
594
+ path: ["endAt"]
595
+ });
596
+ if (goal.metric !== "custom" && goal.manualCurrent !== void 0) context.addIssue({
597
+ code: "custom",
598
+ message: "manualCurrent is only valid for custom goals",
599
+ path: ["manualCurrent"]
600
+ });
601
+ const quotaTotal = goal.contentTypeTargets.reduce((sum, item) => sum + item.target, 0);
602
+ if (goal.primary && quotaTotal > goal.target) context.addIssue({
603
+ code: "custom",
604
+ message: "content type targets cannot exceed the output target",
605
+ path: ["contentTypeTargets"]
606
+ });
607
+ });
608
+ const followerSnapshotSchema = z.object({
609
+ id: z.string().min(1),
610
+ followers: z.number().int().nonnegative(),
611
+ capturedAt: z.number().int().nonnegative(),
612
+ note: z.string().optional()
613
+ }).strict();
614
+ const scheduleTypeSchema = z.object({
615
+ id: z.string().trim().min(1).max(80),
616
+ name: z.string().trim().min(1).max(120),
617
+ color: z.string().regex(/^#[0-9a-f]{6}$/i),
618
+ archived: z.boolean()
619
+ }).strict();
620
+ const milestoneColorsSchema = z.object({
621
+ topic: z.string().regex(/^#[0-9a-f]{6}$/i),
622
+ script: z.string().regex(/^#[0-9a-f]{6}$/i),
623
+ recording: z.string().regex(/^#[0-9a-f]{6}$/i),
624
+ editing: z.string().regex(/^#[0-9a-f]{6}$/i),
625
+ publishing: z.string().regex(/^#[0-9a-f]{6}$/i),
626
+ review: z.string().regex(/^#[0-9a-f]{6}$/i),
627
+ custom: z.string().regex(/^#[0-9a-f]{6}$/i)
628
+ }).strict();
629
+ const cockpitSettingsSchema = z.object({
630
+ reviewDelayDays: z.number().int().min(0).max(30),
631
+ contentTypes: z.array(z.string().trim().min(1).max(120)).max(100),
632
+ tiers: z.array(z.string().trim().min(1).max(80)).max(100),
633
+ tags: z.array(z.string().trim().min(1).max(80)).max(300),
634
+ scheduleTypes: z.array(scheduleTypeSchema).max(100),
635
+ milestoneColors: milestoneColorsSchema
636
+ }).strict();
637
+ const cockpitStateSchema = z.object({
638
+ schemaVersion: z.literal(3),
639
+ revision: z.number().int().nonnegative(),
640
+ ideas: z.array(ideaSchema),
641
+ contentMeta: z.record(z.string(), contentOperationsMetaSchema),
642
+ goals: z.array(goalSchema),
643
+ followerSnapshots: z.array(followerSnapshotSchema),
644
+ scheduleItems: z.array(scheduleItemSchema),
645
+ knowledgeItems: z.array(knowledgeItemSchema),
646
+ settings: cockpitSettingsSchema
647
+ }).strict().superRefine((state, context) => {
648
+ const goalIds = new Set(state.goals.map((goal) => goal.id));
649
+ const uniqueIds = (values, path) => {
650
+ if (new Set(values).size !== values.length) context.addIssue({
651
+ code: "custom",
652
+ message: "ids must be unique",
653
+ path
654
+ });
655
+ };
656
+ uniqueIds(state.ideas.map((idea) => idea.id), ["ideas"]);
657
+ uniqueIds(state.goals.map((goal) => goal.id), ["goals"]);
658
+ uniqueIds(state.followerSnapshots.map((snapshot) => snapshot.id), ["followerSnapshots"]);
659
+ uniqueIds(state.scheduleItems.map((item) => item.id), ["scheduleItems"]);
660
+ uniqueIds(state.knowledgeItems.map((item) => item.id), ["knowledgeItems"]);
661
+ uniqueIds(state.settings.scheduleTypes.map((item) => item.id), ["settings", "scheduleTypes"]);
662
+ if (state.goals.filter((goal) => goal.primary && goal.archivedAt === void 0).length > 1) context.addIssue({
663
+ code: "custom",
664
+ message: "only one active primary goal is allowed",
665
+ path: ["goals"]
666
+ });
667
+ const knowledgeIds = new Set(state.knowledgeItems.map((item) => item.id));
668
+ for (const [index, idea] of state.ideas.entries()) {
669
+ if (idea.goalId !== void 0 && !goalIds.has(idea.goalId)) context.addIssue({
670
+ code: "custom",
671
+ message: "idea goalId must reference a goal",
672
+ path: [
673
+ "ideas",
674
+ index,
675
+ "goalId"
676
+ ]
677
+ });
678
+ if (idea.status === "promoted" !== (idea.promotedContentId !== void 0)) context.addIssue({
679
+ code: "custom",
680
+ message: "promoted status and promotedContentId must agree",
681
+ path: [
682
+ "ideas",
683
+ index,
684
+ "promotedContentId"
685
+ ]
686
+ });
687
+ }
688
+ for (const [key, meta] of Object.entries(state.contentMeta)) {
689
+ if (key !== meta.contentId) context.addIssue({
690
+ code: "custom",
691
+ message: "contentMeta key must match contentId",
692
+ path: [
693
+ "contentMeta",
694
+ key,
695
+ "contentId"
696
+ ]
697
+ });
698
+ uniqueIds(meta.goalIds, [
699
+ "contentMeta",
700
+ key,
701
+ "goalIds"
702
+ ]);
703
+ uniqueIds(meta.evaluations.map((evaluation) => evaluation.id), [
704
+ "contentMeta",
705
+ key,
706
+ "evaluations"
707
+ ]);
708
+ uniqueIds(meta.reviews.map((review) => review.id), [
709
+ "contentMeta",
710
+ key,
711
+ "reviews"
712
+ ]);
713
+ uniqueIds(meta.tags, [
714
+ "contentMeta",
715
+ key,
716
+ "tags"
717
+ ]);
718
+ uniqueIds(meta.knowledgeIds, [
719
+ "contentMeta",
720
+ key,
721
+ "knowledgeIds"
722
+ ]);
723
+ for (const goalId of meta.goalIds) if (!goalIds.has(goalId)) context.addIssue({
724
+ code: "custom",
725
+ message: "content goalId must reference a goal",
726
+ path: [
727
+ "contentMeta",
728
+ key,
729
+ "goalIds"
730
+ ]
731
+ });
732
+ for (const knowledgeId of meta.knowledgeIds) if (!knowledgeIds.has(knowledgeId)) context.addIssue({
733
+ code: "custom",
734
+ message: "content knowledgeId must reference knowledge",
735
+ path: [
736
+ "contentMeta",
737
+ key,
738
+ "knowledgeIds"
739
+ ]
740
+ });
741
+ }
742
+ });
743
+ const createIdeaRequestSchema = z.object({
744
+ title: z.string().trim().min(1).max(240),
745
+ note: z.string().max(2e4),
746
+ source: z.string().max(2e3).optional(),
747
+ tags: z.array(z.string().trim().min(1).max(80)).max(50),
748
+ contentType: z.string().trim().min(1).max(120).optional(),
749
+ tier: z.string().trim().min(1).max(80).optional(),
750
+ goalId: z.string().min(1).optional()
751
+ }).strict();
752
+ const updateIdeaRequestSchema = z.object({
753
+ id: z.string().min(1),
754
+ patch: z.object({
755
+ title: z.string().trim().min(1).max(240).optional(),
756
+ note: z.string().max(2e4).optional(),
757
+ source: z.string().max(2e3).nullable().optional(),
758
+ tags: z.array(z.string().trim().min(1).max(80)).max(50).optional(),
759
+ contentType: z.string().trim().min(1).max(120).nullable().optional(),
760
+ tier: z.string().trim().min(1).max(80).nullable().optional(),
761
+ status: z.enum([
762
+ "inbox",
763
+ "considering",
764
+ "archived"
765
+ ]).optional(),
766
+ goalId: z.string().min(1).nullable().optional()
767
+ }).strict()
768
+ }).strict();
769
+ const idRequestSchema = z.object({ id: z.string().min(1) }).strict();
770
+ const setContentMetaRequestSchema = z.object({
771
+ contentId: z.string().min(1),
772
+ patch: z.object({
773
+ contentType: z.string().max(120).nullable().optional(),
774
+ tier: z.string().max(80).nullable().optional(),
775
+ priority: prioritySchema.nullable().optional(),
776
+ nextAction: z.string().max(2e3).nullable().optional(),
777
+ tags: z.array(z.string().trim().min(1).max(80)).max(100).optional(),
778
+ hookType: hookTypeSchema.nullable().optional(),
779
+ customHook: z.string().max(2e3).nullable().optional(),
780
+ structureType: structureTypeSchema.nullable().optional(),
781
+ customStructure: z.string().max(2e3).nullable().optional(),
782
+ knowledgeIds: z.array(z.string().min(1)).max(200).optional(),
783
+ goalIds: z.array(z.string().min(1)).max(100).optional(),
784
+ supplementalMetrics: supplementalMetricsSchema.nullable().optional()
785
+ }).strict()
786
+ }).strict();
787
+ const createGoalRequestSchema = z.object({
788
+ name: z.string().trim().min(1).max(240),
789
+ metric: goalMetricSchema,
790
+ target: z.number().nonnegative(),
791
+ manualCurrent: z.number().optional(),
792
+ startAt: z.number().int().nonnegative(),
793
+ endAt: z.number().int().nonnegative(),
794
+ contentIds: z.array(z.string().min(1)).max(500),
795
+ primary: z.boolean().optional(),
796
+ contentTypeTargets: z.array(z.object({
797
+ contentType: z.string().trim().min(1).max(120),
798
+ target: z.number().int().nonnegative()
799
+ }).strict()).max(100).optional(),
800
+ followerStart: z.number().int().nonnegative().optional(),
801
+ followerTarget: z.number().int().nonnegative().optional(),
802
+ note: z.string().max(2e4)
803
+ }).strict().superRefine((goal, context) => {
804
+ if (goal.endAt < goal.startAt) context.addIssue({
805
+ code: "custom",
806
+ message: "endAt must not be earlier than startAt",
807
+ path: ["endAt"]
808
+ });
809
+ if (goal.metric !== "custom" && goal.manualCurrent !== void 0) context.addIssue({
810
+ code: "custom",
811
+ message: "manualCurrent is only valid for custom goals",
812
+ path: ["manualCurrent"]
813
+ });
814
+ });
815
+ const updateGoalRequestSchema = z.object({
816
+ id: z.string().min(1),
817
+ patch: z.object({
818
+ name: z.string().min(1).max(240).optional(),
819
+ target: z.number().nonnegative().optional(),
820
+ manualCurrent: z.number().nullable().optional(),
821
+ startAt: z.number().int().nonnegative().optional(),
822
+ endAt: z.number().int().nonnegative().optional(),
823
+ contentIds: z.array(z.string().min(1)).max(500).optional(),
824
+ primary: z.boolean().optional(),
825
+ contentTypeTargets: z.array(z.object({
826
+ contentType: z.string().trim().min(1).max(120),
827
+ target: z.number().int().nonnegative()
828
+ }).strict()).max(100).optional(),
829
+ followerStart: z.number().int().nonnegative().nullable().optional(),
830
+ followerTarget: z.number().int().nonnegative().nullable().optional(),
831
+ archived: z.boolean().optional(),
832
+ note: z.string().max(2e4).optional()
833
+ }).strict()
834
+ }).strict();
835
+ const createFollowerSnapshotRequestSchema = followerSnapshotSchema.pick({
836
+ followers: true,
837
+ capturedAt: true,
838
+ note: true
839
+ }).strict();
840
+ const createScheduleItemRequestSchema = scheduleItemSchema.pick({
841
+ kind: true,
842
+ milestone: true,
843
+ title: true,
844
+ contentId: true,
845
+ typeId: true,
846
+ plannedAt: true,
847
+ rank: true,
848
+ note: true
849
+ }).extend({ rank: z.number().int().nonnegative().optional() }).strict();
850
+ const updateScheduleItemRequestSchema = z.object({
851
+ id: z.string().min(1),
852
+ patch: z.object({
853
+ kind: scheduleKindSchema.optional(),
854
+ milestone: scheduleMilestoneSchema.optional(),
855
+ title: z.string().trim().min(1).max(240).optional(),
856
+ contentId: z.string().min(1).nullable().optional(),
857
+ typeId: z.string().min(1).nullable().optional(),
858
+ plannedAt: z.number().int().nonnegative().optional(),
859
+ rank: z.number().int().nonnegative().optional(),
860
+ completed: z.boolean().optional(),
861
+ note: z.string().max(2e4).optional()
862
+ }).strict()
863
+ }).strict();
864
+ const updateCockpitSettingsRequestSchema = z.object({
865
+ reviewDelayDays: z.number().int().min(0).max(30).optional(),
866
+ contentTypes: z.array(z.string().trim().min(1).max(120)).max(100).optional(),
867
+ tiers: z.array(z.string().trim().min(1).max(80)).max(100).optional(),
868
+ tags: z.array(z.string().trim().min(1).max(80)).max(300).optional(),
869
+ scheduleTypes: z.array(scheduleTypeSchema).max(100).optional(),
870
+ milestoneColors: milestoneColorsSchema.optional()
871
+ }).strict();
872
+ const restoreCockpitStateRequestSchema = z.object({
873
+ expectedRevision: z.number().int().nonnegative(),
874
+ state: z.unknown()
875
+ }).strict();
876
+ z.object({
877
+ contentId: z.string().min(1),
878
+ rubricVersion: z.string().min(1),
879
+ scores: evaluationScoresSchema,
880
+ evidence: z.record(z.string(), z.string().max(1e4)),
881
+ suggestions: z.array(z.string().max(1e4)).max(50),
882
+ inputFingerprint: z.string().min(1)
883
+ }).strict();
884
+ const saveManualReviewDraftRequestSchema = z.object({
885
+ contentId: z.string().min(1),
886
+ rating: z.number().int().min(1).max(5).optional(),
887
+ analysis: z.string().min(1).max(5e4),
888
+ learnedRule: z.string().max(2e4).optional(),
889
+ inputFingerprint: z.string().min(1)
890
+ }).strict().omit({ inputFingerprint: true });
891
+ const contentRecordRequestSchema = z.object({
892
+ contentId: z.string().min(1),
893
+ id: z.string().min(1)
894
+ }).strict();
895
+ const promoteIdeaRequestSchema = z.object({
896
+ ideaId: z.string().min(1),
897
+ expectedRevision: z.number().int().nonnegative(),
898
+ title: z.string().trim().min(1).max(240),
899
+ topicNote: z.string().max(5e4)
900
+ }).strict();
901
+ const knowledgeRequestSchema = z.object({
902
+ contentId: z.string().min(1),
903
+ reviewId: z.string().min(1),
904
+ title: z.string().trim().min(1).max(240),
905
+ body: z.string().min(1).max(5e4),
906
+ tags: z.array(z.string().trim().min(1).max(80)).max(50).optional()
907
+ }).strict();
908
+ const updateKnowledgeRequestSchema = z.object({
909
+ id: z.string().min(1),
910
+ patch: z.object({
911
+ title: z.string().trim().min(1).max(240).optional(),
912
+ body: z.string().min(1).max(5e4).optional(),
913
+ tags: z.array(z.string().trim().min(1).max(80)).max(50).optional(),
914
+ active: z.boolean().optional()
915
+ }).strict()
916
+ }).strict();
917
+ const promotionResultSchema = z.object({
918
+ state: cockpitStateSchema,
919
+ contentId: z.string().min(1),
920
+ folderPath: z.string().min(1).optional(),
921
+ topicWritten: z.boolean(),
922
+ recovery: z.string().optional()
923
+ }).strict();
924
+ const knowledgeResultSchema = z.object({
925
+ state: cockpitStateSchema,
926
+ path: z.string().min(1),
927
+ entryId: z.string().min(1)
928
+ }).strict();
929
+ const cockpitRevisionSchema = z.object({ revision: z.number().int().nonnegative() }).strict();
930
+ const emptyRequestSchema = z.object({}).strict();
931
+ //#endregion
932
+ //#region src/cockpit/remote-contract.ts
933
+ const CREATOR_COCKPIT_NAMESPACE = "creatorCockpit";
934
+ function codec(typeSymbol, schema) {
935
+ return {
936
+ mode: "strict",
937
+ typeSymbol,
938
+ schema
939
+ };
940
+ }
941
+ function jsonParam(name, typeSymbol, schema) {
942
+ return {
943
+ name,
944
+ wire: name,
945
+ source: "json",
946
+ codec: codec(typeSymbol, schema)
947
+ };
948
+ }
949
+ function invocation(method, request, result) {
950
+ return {
951
+ id: `${PACKAGE_NAME}#${CREATOR_COCKPIT_NAMESPACE}/${method}`,
952
+ service: CREATOR_COCKPIT_NAMESPACE,
953
+ namespace: CREATOR_COCKPIT_NAMESPACE,
954
+ method,
955
+ invocation: { kind: "direct" },
956
+ parameters: [jsonParam("request", `${PACKAGE_NAME}#cockpit/${method}Request`, request)],
957
+ cancellation: { parameter: "signal" },
958
+ result: codec(`${PACKAGE_NAME}#cockpit/${method}Result`, result),
959
+ sourceLocation: {
960
+ file: "src/cockpit/service.ts",
961
+ line: 1,
962
+ column: 1
963
+ }
964
+ };
965
+ }
966
+ const CREATOR_COCKPIT_INVOCATIONS = [
967
+ invocation("getState", emptyRequestSchema, cockpitStateSchema),
968
+ invocation("getRevision", emptyRequestSchema, cockpitRevisionSchema),
969
+ invocation("restoreState", restoreCockpitStateRequestSchema, cockpitStateSchema),
970
+ invocation("createIdea", createIdeaRequestSchema, cockpitStateSchema),
971
+ invocation("updateIdea", updateIdeaRequestSchema, cockpitStateSchema),
972
+ invocation("deleteIdea", idRequestSchema, cockpitStateSchema),
973
+ invocation("setContentMeta", setContentMetaRequestSchema, cockpitStateSchema),
974
+ invocation("deleteContentMeta", idRequestSchema, cockpitStateSchema),
975
+ invocation("createGoal", createGoalRequestSchema, cockpitStateSchema),
976
+ invocation("updateGoal", updateGoalRequestSchema, cockpitStateSchema),
977
+ invocation("deleteGoal", idRequestSchema, cockpitStateSchema),
978
+ invocation("createFollowerSnapshot", createFollowerSnapshotRequestSchema, cockpitStateSchema),
979
+ invocation("deleteFollowerSnapshot", idRequestSchema, cockpitStateSchema),
980
+ invocation("createScheduleItem", createScheduleItemRequestSchema, cockpitStateSchema),
981
+ invocation("updateScheduleItem", updateScheduleItemRequestSchema, cockpitStateSchema),
982
+ invocation("deleteScheduleItem", idRequestSchema, cockpitStateSchema),
983
+ invocation("updateSettings", updateCockpitSettingsRequestSchema, cockpitStateSchema),
984
+ invocation("saveManualReviewDraft", saveManualReviewDraftRequestSchema, cockpitStateSchema),
985
+ invocation("confirmReview", contentRecordRequestSchema, cockpitStateSchema),
986
+ invocation("saveRule", knowledgeRequestSchema, knowledgeResultSchema),
987
+ invocation("saveTemplate", knowledgeRequestSchema, knowledgeResultSchema),
988
+ invocation("updateKnowledge", updateKnowledgeRequestSchema, cockpitStateSchema),
989
+ invocation("promoteIdea", promoteIdeaRequestSchema, promotionResultSchema)
990
+ ];
991
+ //#endregion
992
+ //#region src/typert.host.ts
993
+ const ALL_INVOCATIONS = [...OIL_CREATOR_INVOCATIONS, ...CREATOR_COCKPIT_INVOCATIONS];
994
+ const TYPERT = {
995
+ package: PACKAGE_NAME,
996
+ face: "host",
997
+ schemas: [],
998
+ model: {
999
+ services: [],
1000
+ events: [],
1001
+ objects: []
1002
+ },
1003
+ invocations: ALL_INVOCATIONS
1004
+ };
1005
+ //#endregion
1006
+ export { ALL_INVOCATIONS, TYPERT };