@deployxai/dxc 0.1.13 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +6 -5
  2. package/dist/chunks/chunk-7DMYDQPR.js +1324 -0
  3. package/dist/chunks/{knowledge-MNDWLVLM.js → knowledge-MHD76CG4.js} +2 -4
  4. package/dist/index.js +28494 -30586
  5. package/package.json +1 -1
  6. package/skills/dxc-article-outline/SKILL.md +14 -57
  7. package/skills/dxc-article-outline/agents/openai.yaml +2 -2
  8. package/skills/dxc-article-outline/references/outline-methods.md +1 -2
  9. package/skills/dxc-article-write/SKILL.md +15 -91
  10. package/skills/dxc-article-write/agents/openai.yaml +2 -2
  11. package/skills/dxc-article-write/references/writing-methods.md +2 -2
  12. package/skills/dxc-content-brief/SKILL.md +17 -56
  13. package/skills/dxc-content-brief/agents/openai.yaml +2 -2
  14. package/skills/dxc-content-brief/references/brief-method.md +3 -3
  15. package/skills/dxc-content-review/SKILL.md +15 -62
  16. package/skills/dxc-content-review/agents/openai.yaml +2 -2
  17. package/skills/dxc-content-review/references/review-checklist.md +3 -4
  18. package/skills/dxc-content-workflow/SKILL.md +92 -243
  19. package/skills/dxc-content-workflow/agents/openai.yaml +2 -2
  20. package/skills/dxc-content-workflow/references/onboarding-questions.md +2 -7
  21. package/skills/dxc-content-workflow/references/stages.md +79 -0
  22. package/skills/dxc-knowledge/SKILL.md +2 -2
  23. package/skills/dxc-memory/SKILL.md +2 -2
  24. package/skills/dxc-profile/SKILL.md +4 -4
  25. package/skills/dxc-project-overview/SKILL.md +26 -0
  26. package/skills/dxc-project-overview/agents/openai.yaml +6 -0
  27. package/skills/dxc-quote-curator/SKILL.md +4 -6
  28. package/skills/dxc-research/SKILL.md +21 -116
  29. package/skills/dxc-research/agents/openai.yaml +2 -2
  30. package/skills/dxc-research/references/research-method.md +11 -14
  31. package/skills/dxc-title-write/SKILL.md +16 -86
  32. package/skills/dxc-title-write/agents/openai.yaml +2 -2
  33. package/skills/dxc-title-write/references/title-methods.md +3 -3
  34. package/skills/dxc-visual-plan/SKILL.md +16 -195
  35. package/skills/dxc-visual-plan/agents/openai.yaml +2 -2
  36. package/skills/dxc-visual-plan/references/visual-methods.md +7 -7
  37. package/skills/dxc-wechat-publisher/SKILL.md +23 -210
  38. package/skills/dxc-wechat-publisher/agents/openai.yaml +2 -2
  39. package/dist/chunks/chunk-DDKUG5EV.js +0 -2126
  40. package/dist/chunks/chunk-RONRJJBC.js +0 -2379
  41. package/dist/chunks/chunk-ZKJQWR2J.js +0 -37
  42. package/dist/chunks/monitor-ACOHQYOE.js +0 -694
  43. package/skills/dxc-content-workflow/references/catalog.json +0 -137
  44. package/skills/dxc-content-workflow/references/stage-contract.md +0 -121
@@ -0,0 +1,1324 @@
1
+ import { createRequire as __dxcCreateRequire } from "node:module"; const require = __dxcCreateRequire(import.meta.url);
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
+ }) : x)(function(x) {
11
+ if (typeof require !== "undefined") return require.apply(this, arguments);
12
+ throw Error('Dynamic require of "' + x + '" is not supported');
13
+ });
14
+ var __esm = (fn, res, err) => function __init() {
15
+ if (err) throw err[0];
16
+ try {
17
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
18
+ } catch (e) {
19
+ throw err = [e], e;
20
+ }
21
+ };
22
+ var __commonJS = (cb, mod) => function __require2() {
23
+ try {
24
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
25
+ } catch (e) {
26
+ throw mod = 0, e;
27
+ }
28
+ };
29
+ var __export = (target, all) => {
30
+ for (var name in all)
31
+ __defProp(target, name, { get: all[name], enumerable: true });
32
+ };
33
+ var __copyProps = (to, from, except, desc) => {
34
+ if (from && typeof from === "object" || typeof from === "function") {
35
+ for (let key of __getOwnPropNames(from))
36
+ if (!__hasOwnProp.call(to, key) && key !== except)
37
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
38
+ }
39
+ return to;
40
+ };
41
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
42
+ // If the importer is in node compatibility mode or this is not an ESM
43
+ // file that has been converted to a CommonJS file using a Babel-
44
+ // compatible transform (i.e. "__esModule" has not been set), then set
45
+ // "default" to the CommonJS "module.exports" for node compatibility.
46
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
47
+ mod
48
+ ));
49
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
50
+
51
+ // packages/contracts/src/content-knowledge.ts
52
+ import { z } from "zod";
53
+ var CONTENT_KNOWLEDGE_SCHEMA_VERSION = "2";
54
+ var CONTENT_KNOWLEDGE_EMBEDDING_MODEL = "Xenova/bge-small-zh-v1.5";
55
+ var CONTENT_KNOWLEDGE_EMBEDDING_REVISION = "75c43b069aac4d136ba6bc1122f995fedcfd2781";
56
+ var CONTENT_KNOWLEDGE_EMBEDDING_DIMENSIONS = 512;
57
+ var CONTENT_KNOWLEDGE_EMBEDDING_QUANTIZATION = "q8";
58
+ var CONTENT_KNOWLEDGE_CHUNKER_VERSION = "dxc-markdown-chunker@3";
59
+ var contentKnowledgeSearchModeSchema = z.enum(["hybrid", "lexical", "semantic"]);
60
+ var contentKnowledgeQuoteStatusSchema = z.enum(["active", "archived"]);
61
+ var contentKnowledgeQuoteOriginSchema = z.enum(["original", "third-party"]);
62
+ var contentKnowledgeQuoteVerbatimUseSchema = z.enum([
63
+ "original",
64
+ "needs-verification",
65
+ "permitted",
66
+ "do-not-use-verbatim"
67
+ ]);
68
+ var contentKnowledgeModelSchema = z.object({
69
+ dimensions: z.literal(CONTENT_KNOWLEDGE_EMBEDDING_DIMENSIONS),
70
+ id: z.literal(CONTENT_KNOWLEDGE_EMBEDDING_MODEL),
71
+ quantization: z.literal(CONTENT_KNOWLEDGE_EMBEDDING_QUANTIZATION),
72
+ revision: z.literal(CONTENT_KNOWLEDGE_EMBEDDING_REVISION)
73
+ }).strict();
74
+ var contentKnowledgeArticleSummarySchema = z.object({
75
+ articleId: z.uuid(),
76
+ chunkCount: z.number().int().positive(),
77
+ contentSha256: z.string().regex(/^[a-f0-9]{64}$/u),
78
+ importedAt: z.iso.datetime(),
79
+ sourceLabel: z.string().trim().min(1).max(255),
80
+ title: z.string().trim().min(1).max(300),
81
+ updatedAt: z.iso.datetime()
82
+ }).strict();
83
+ var contentKnowledgeImportItemSchema = z.object({
84
+ article: contentKnowledgeArticleSummarySchema,
85
+ semanticIndexed: z.boolean(),
86
+ status: z.enum(["created", "updated", "unchanged"])
87
+ }).strict();
88
+ var contentKnowledgeImportSkippedItemSchema = z.object({
89
+ code: z.enum(["DXC_KNOWLEDGE_ARTICLE_INVALID", "DXC_KNOWLEDGE_FILE_TOO_LARGE"]),
90
+ message: z.string().trim().min(1),
91
+ sourceLabel: z.string().trim().min(1).max(255)
92
+ }).strict();
93
+ var contentKnowledgeImportResultSchema = z.object({
94
+ command: z.literal("knowledge.import"),
95
+ data: z.object({
96
+ imported: z.array(contentKnowledgeImportItemSchema),
97
+ model: contentKnowledgeModelSchema.nullable(),
98
+ skipped: z.array(contentKnowledgeImportSkippedItemSchema)
99
+ }).strict(),
100
+ ok: z.literal(true)
101
+ }).strict();
102
+ var contentKnowledgeMatchLaneSchema = z.enum(["lexical", "semantic"]);
103
+ var contentKnowledgeSearchItemBaseSchema = z.object({
104
+ lanes: z.array(contentKnowledgeMatchLaneSchema).min(1).max(2),
105
+ rank: z.number().int().positive().max(20),
106
+ snippet: z.string().trim().min(1).max(420)
107
+ }).strict();
108
+ var contentKnowledgeHistorySearchItemSchema = contentKnowledgeSearchItemBaseSchema.extend({
109
+ articleId: z.uuid(),
110
+ chunkId: z.uuid(),
111
+ chunkSha256: z.string().regex(/^[a-f0-9]{64}$/u),
112
+ heading: z.string().trim().min(1).max(300).nullable(),
113
+ ordinal: z.number().int().nonnegative(),
114
+ sourceType: z.literal("history-article"),
115
+ sourceLabel: z.string().trim().min(1).max(255),
116
+ title: z.string().trim().min(1).max(300)
117
+ });
118
+ var contentKnowledgeQuoteSearchItemSchema = contentKnowledgeSearchItemBaseSchema.extend({
119
+ attribution: z.string().trim().min(1).max(300).nullable(),
120
+ contentSha256: z.string().regex(/^[a-f0-9]{64}$/u),
121
+ origin: contentKnowledgeQuoteOriginSchema,
122
+ quoteId: z.uuid(),
123
+ sourceLabel: z.string().trim().min(1).max(300).nullable(),
124
+ sourceType: z.literal("quote"),
125
+ status: contentKnowledgeQuoteStatusSchema,
126
+ tags: z.array(z.string().trim().min(1).max(80)).max(20),
127
+ verbatimUse: contentKnowledgeQuoteVerbatimUseSchema
128
+ });
129
+ var contentKnowledgeSearchItemSchema = z.discriminatedUnion("sourceType", [
130
+ contentKnowledgeHistorySearchItemSchema,
131
+ contentKnowledgeQuoteSearchItemSchema
132
+ ]);
133
+ var contentKnowledgeQuoteSummarySchema = z.object({
134
+ activeCount: z.number().int().nonnegative(),
135
+ archivedCount: z.number().int().nonnegative(),
136
+ sourceInitialized: z.boolean(),
137
+ sourcePath: z.literal("~/Documents/DxC/\u91D1\u53E5\u5E93.md"),
138
+ sourceSha256: z.string().regex(/^[a-f0-9]{64}$/u).nullable()
139
+ }).strict();
140
+ var contentKnowledgeQuoteRecordSchema = z.object({
141
+ attribution: z.string().trim().min(1).max(300).nullable(),
142
+ origin: contentKnowledgeQuoteOriginSchema,
143
+ quoteId: z.uuid(),
144
+ source: z.string().trim().min(1).max(300).nullable(),
145
+ status: contentKnowledgeQuoteStatusSchema,
146
+ tags: z.array(z.string().trim().min(1).max(80)).max(20),
147
+ text: z.string().trim().min(1).max(2e3),
148
+ verbatimUse: contentKnowledgeQuoteVerbatimUseSchema
149
+ }).strict();
150
+ var contentKnowledgeQuoteListResultSchema = z.object({
151
+ command: z.literal("knowledge.quotes.list"),
152
+ data: z.object({ quotes: z.array(contentKnowledgeQuoteRecordSchema).max(5e3) }).strict(),
153
+ ok: z.literal(true)
154
+ }).strict();
155
+ var contentKnowledgeQuoteMutationResultSchema = z.object({
156
+ command: z.enum([
157
+ "knowledge.quotes.add",
158
+ "knowledge.quotes.update",
159
+ "knowledge.quotes.archive"
160
+ ]),
161
+ data: z.object({ pendingSync: z.literal(true), quote: contentKnowledgeQuoteRecordSchema }).strict(),
162
+ ok: z.literal(true)
163
+ }).strict();
164
+ var contentKnowledgeQuoteInitResultSchema = z.object({
165
+ command: z.literal("knowledge.quotes.init"),
166
+ data: contentKnowledgeQuoteSummarySchema.extend({ created: z.boolean() }).strict(),
167
+ ok: z.literal(true)
168
+ }).strict();
169
+ var contentKnowledgeQuoteStatusResultSchema = z.object({
170
+ command: z.literal("knowledge.quotes.status"),
171
+ data: contentKnowledgeQuoteSummarySchema,
172
+ ok: z.literal(true)
173
+ }).strict();
174
+ var contentKnowledgeQuoteSyncResultSchema = z.object({
175
+ command: z.literal("knowledge.quotes.sync"),
176
+ data: contentKnowledgeQuoteSummarySchema.extend({
177
+ model: contentKnowledgeModelSchema.nullable(),
178
+ status: z.enum(["created", "updated", "unchanged"])
179
+ }).strict(),
180
+ ok: z.literal(true)
181
+ }).strict();
182
+ var contentKnowledgeSearchItemLegacySchema = z.object({
183
+ articleId: z.uuid(),
184
+ chunkId: z.uuid(),
185
+ chunkSha256: z.string().regex(/^[a-f0-9]{64}$/u),
186
+ heading: z.string().trim().min(1).max(300).nullable(),
187
+ lanes: z.array(contentKnowledgeMatchLaneSchema).min(1).max(2),
188
+ ordinal: z.number().int().nonnegative(),
189
+ rank: z.number().int().positive().max(20),
190
+ snippet: z.string().trim().min(1).max(420),
191
+ sourceLabel: z.string().trim().min(1).max(255),
192
+ title: z.string().trim().min(1).max(300)
193
+ }).strict();
194
+ var contentKnowledgeSearchResultSchema = z.object({
195
+ command: z.literal("knowledge.search"),
196
+ data: z.object({
197
+ mode: contentKnowledgeSearchModeSchema,
198
+ model: contentKnowledgeModelSchema.nullable(),
199
+ query: z.string().trim().min(1).max(500),
200
+ results: z.array(contentKnowledgeSearchItemSchema).max(20)
201
+ }).strict(),
202
+ ok: z.literal(true)
203
+ }).strict();
204
+ var contentKnowledgeStatusResultSchema = z.object({
205
+ command: z.literal("knowledge.status"),
206
+ data: z.object({
207
+ articleCount: z.number().int().nonnegative(),
208
+ chunkCount: z.number().int().nonnegative(),
209
+ databasePath: z.literal("~/.dxc/content-memory.sqlite"),
210
+ model: contentKnowledgeModelSchema,
211
+ modelCached: z.boolean(),
212
+ semanticIndexedChunkCount: z.number().int().nonnegative(),
213
+ quotes: contentKnowledgeQuoteSummarySchema
214
+ }).strict(),
215
+ ok: z.literal(true)
216
+ }).strict();
217
+ var contentKnowledgeRemoveResultSchema = z.object({
218
+ command: z.literal("knowledge.remove"),
219
+ data: z.object({
220
+ articleId: z.uuid(),
221
+ removed: z.boolean()
222
+ }).strict(),
223
+ ok: z.literal(true)
224
+ }).strict();
225
+ var contentKnowledgeCommandSchema = z.enum([
226
+ "knowledge.import",
227
+ "knowledge.remove",
228
+ "knowledge.search",
229
+ "knowledge.status",
230
+ "knowledge.quotes.init",
231
+ "knowledge.quotes.add",
232
+ "knowledge.quotes.archive",
233
+ "knowledge.quotes.list",
234
+ "knowledge.quotes.status",
235
+ "knowledge.quotes.sync",
236
+ "knowledge.quotes.update"
237
+ ]);
238
+ var contentKnowledgeErrorResultSchema = z.object({
239
+ command: contentKnowledgeCommandSchema,
240
+ error: z.object({
241
+ code: z.enum([
242
+ "DXC_KNOWLEDGE_ARTICLE_INVALID",
243
+ "DXC_KNOWLEDGE_DIRECTORY_INVALID",
244
+ "DXC_KNOWLEDGE_DIRECTORY_TOO_LARGE",
245
+ "DXC_KNOWLEDGE_FILE_TOO_LARGE",
246
+ "DXC_KNOWLEDGE_INPUT_NOT_FOUND",
247
+ "DXC_KNOWLEDGE_IO_FAILED",
248
+ "DXC_KNOWLEDGE_MODEL_FAILED",
249
+ "DXC_KNOWLEDGE_QUERY_INVALID",
250
+ "DXC_KNOWLEDGE_QUOTE_INVALID",
251
+ "DXC_KNOWLEDGE_QUOTE_SOURCE_NOT_INITIALIZED",
252
+ "DXC_KNOWLEDGE_SCHEMA_UNSUPPORTED",
253
+ "DXC_KNOWLEDGE_SEMANTIC_NOT_READY",
254
+ "DXC_KNOWLEDGE_STATE_INVALID"
255
+ ]),
256
+ message: z.string().trim().min(1)
257
+ }).strict(),
258
+ ok: z.literal(false)
259
+ }).strict();
260
+
261
+ // packages/contracts/src/index.ts
262
+ import { z as z6 } from "zod";
263
+
264
+ // packages/contracts/src/publishing.ts
265
+ import { z as z2 } from "zod";
266
+ var sha256Schema = z2.string().regex(/^[a-f0-9]{64}$/u);
267
+ var wechatTemplateIdSchema = z2.enum([
268
+ "wechat-minimal@1",
269
+ "wechat-academic-paper@1",
270
+ "wechat-aurora-glass@1",
271
+ "wechat-bauhaus@1",
272
+ "wechat-cyberpunk-neon@1",
273
+ "wechat-knowledge-base@1",
274
+ "wechat-luxury-gold@1",
275
+ "wechat-morandi-forest@1",
276
+ "wechat-neo-brutalism@1",
277
+ "wechat-receipt@1",
278
+ "wechat-sunset-film@1"
279
+ ]);
280
+ var publishingUploadKindSchema = z2.enum(["article-source", "cover-image", "inline-image"]);
281
+ var publishingUploadMediaTypeSchema = z2.enum([
282
+ "text/markdown",
283
+ "text/plain",
284
+ "image/jpeg",
285
+ "image/png"
286
+ ]);
287
+ var createPublishingUploadRequestSchema = z2.object({
288
+ fileName: z2.string().trim().min(1).max(160),
289
+ kind: publishingUploadKindSchema,
290
+ mediaType: publishingUploadMediaTypeSchema,
291
+ sha256: sha256Schema,
292
+ size: z2.number().int().positive().max(5 * 1024 * 1024)
293
+ }).strict().superRefine((value, context) => {
294
+ if (value.kind === "article-source" && value.mediaType !== "text/markdown" && value.mediaType !== "text/plain") {
295
+ context.addIssue({
296
+ code: "custom",
297
+ message: "article source requires a text media type",
298
+ path: ["mediaType"]
299
+ });
300
+ }
301
+ if ((value.kind === "cover-image" || value.kind === "inline-image") && value.mediaType !== "image/jpeg" && value.mediaType !== "image/png") {
302
+ context.addIssue({
303
+ code: "custom",
304
+ message: "image upload requires a supported image media type",
305
+ path: ["mediaType"]
306
+ });
307
+ }
308
+ if (value.kind === "article-source" && value.size > 512 * 1024) {
309
+ context.addIssue({
310
+ code: "custom",
311
+ message: "article source exceeds the maximum size",
312
+ path: ["size"]
313
+ });
314
+ }
315
+ if (value.kind === "inline-image" && value.size >= 1024 * 1024) {
316
+ context.addIssue({
317
+ code: "custom",
318
+ message: "inline image must be smaller than 1 MiB",
319
+ path: ["size"]
320
+ });
321
+ }
322
+ });
323
+ var publishingUploadSessionSchema = z2.object({
324
+ expiresAt: z2.iso.datetime(),
325
+ id: z2.uuid(),
326
+ kind: publishingUploadKindSchema,
327
+ uploadUrl: z2.url()
328
+ }).strict();
329
+ var publishingUploadReceiptSchema = z2.object({
330
+ id: z2.uuid(),
331
+ sha256: sha256Schema,
332
+ size: z2.number().int().positive().max(5 * 1024 * 1024),
333
+ status: z2.literal("UPLOADED")
334
+ }).strict();
335
+ var createPublishingArticleRequestSchema = z2.object({
336
+ coverUploadId: z2.uuid(),
337
+ inlineAssets: z2.array(
338
+ z2.object({
339
+ logicalPath: z2.string().trim().min(1).max(240),
340
+ uploadId: z2.uuid()
341
+ }).strict()
342
+ ).max(20).optional(),
343
+ sourceUploadId: z2.uuid()
344
+ }).strict().superRefine((value, context) => {
345
+ const inlineAssets = value.inlineAssets ?? [];
346
+ const logicalPaths = inlineAssets.map((asset) => asset.logicalPath);
347
+ const uploadIds = inlineAssets.map((asset) => asset.uploadId);
348
+ if (new Set(logicalPaths).size !== logicalPaths.length) {
349
+ context.addIssue({
350
+ code: "custom",
351
+ message: "inline asset logical paths must be unique",
352
+ path: ["inlineAssets"]
353
+ });
354
+ }
355
+ if (new Set(uploadIds).size !== uploadIds.length) {
356
+ context.addIssue({
357
+ code: "custom",
358
+ message: "inline asset uploads must be unique",
359
+ path: ["inlineAssets"]
360
+ });
361
+ }
362
+ });
363
+ var publishingInlineAssetSchema = z2.object({
364
+ logicalPath: z2.string().trim().min(1).max(240),
365
+ mediaType: z2.enum(["image/jpeg", "image/png"]),
366
+ sha256: sha256Schema
367
+ }).strict();
368
+ var publishingArticleSchema = z2.object({
369
+ cover: z2.object({
370
+ height: z2.number().int().positive().max(12e3),
371
+ mediaType: z2.enum(["image/jpeg", "image/png"]),
372
+ width: z2.number().int().positive().max(12e3)
373
+ }).strict(),
374
+ coverHash: sha256Schema,
375
+ createdAt: z2.iso.datetime(),
376
+ id: z2.uuid(),
377
+ inlineAssets: z2.array(publishingInlineAssetSchema).max(20).default([]),
378
+ sourceHash: sha256Schema
379
+ }).strict();
380
+ var createPublishingRenderSnapshotRequestSchema = z2.object({
381
+ title: z2.string().trim().min(1).max(64).optional()
382
+ }).strict();
383
+ var publishingPreflightIssueSchema = z2.object({
384
+ code: z2.string().trim().min(1),
385
+ message: z2.string().trim().min(1),
386
+ path: z2.string().trim().min(1).optional()
387
+ }).strict();
388
+ var publishingPreflightSchema = z2.object({
389
+ errors: z2.array(publishingPreflightIssueSchema),
390
+ metrics: z2.object({
391
+ digestCharacters: z2.number().int().nonnegative(),
392
+ externalLinkCount: z2.number().int().nonnegative(),
393
+ htmlCharacters: z2.number().int().nonnegative(),
394
+ imageCount: z2.number().int().nonnegative(),
395
+ tableCount: z2.number().int().nonnegative()
396
+ }).strict(),
397
+ ok: z2.boolean(),
398
+ warnings: z2.array(publishingPreflightIssueSchema)
399
+ }).strict();
400
+ var publishingRenderSnapshotSchema = z2.object({
401
+ articleId: z2.uuid(),
402
+ assetManifestHash: sha256Schema,
403
+ author: z2.string().trim().min(1).max(16),
404
+ commentsEnabled: z2.boolean(),
405
+ coverHash: sha256Schema,
406
+ createdAt: z2.iso.datetime(),
407
+ digest: z2.string().trim().min(1).max(120),
408
+ htmlHash: sha256Schema,
409
+ id: z2.uuid(),
410
+ inlineAssets: z2.array(publishingInlineAssetSchema).max(20).default([]),
411
+ preflight: publishingPreflightSchema,
412
+ rendererVersion: z2.string().trim().min(1),
413
+ snapshotHash: sha256Schema,
414
+ sourceHash: sha256Schema,
415
+ templateId: wechatTemplateIdSchema,
416
+ title: z2.string().trim().min(1).max(32)
417
+ }).strict();
418
+ var createPublishingPreviewLinkRequestSchema = z2.object({
419
+ snapshotHash: sha256Schema
420
+ }).strict();
421
+ var publishingPreviewLinkSchema = z2.object({
422
+ createdAt: z2.iso.datetime().optional(),
423
+ expiresAt: z2.iso.datetime(),
424
+ expiresInSeconds: z2.number().int().positive().max(24 * 60 * 60).optional(),
425
+ snapshotHash: sha256Schema,
426
+ url: z2.url()
427
+ }).strict();
428
+ var publishingPreviewSelectionStateSchema = z2.object({
429
+ rootSnapshotHash: sha256Schema,
430
+ rootSnapshotId: z2.uuid(),
431
+ selectedSnapshotHash: sha256Schema,
432
+ selectedSnapshotId: z2.uuid(),
433
+ selectionRevision: z2.number().int().nonnegative(),
434
+ templateId: wechatTemplateIdSchema,
435
+ updatedAt: z2.iso.datetime(),
436
+ viewed: z2.boolean(),
437
+ viewedAt: z2.iso.datetime().nullable()
438
+ }).strict();
439
+ var createPublishingApprovalRequestSchema = z2.object({
440
+ accountId: z2.uuid(),
441
+ confirmed: z2.literal(true),
442
+ snapshotHash: sha256Schema
443
+ }).strict();
444
+ var publishingApprovalSchema = z2.object({
445
+ accountId: z2.uuid(),
446
+ confirmedAt: z2.iso.datetime(),
447
+ id: z2.uuid(),
448
+ rootSnapshotHash: sha256Schema,
449
+ rootSnapshotId: z2.uuid(),
450
+ selectedSnapshotHash: sha256Schema,
451
+ selectedSnapshotId: z2.uuid(),
452
+ templateId: wechatTemplateIdSchema
453
+ }).strict();
454
+ var createPublishingDraftIntentRequestSchema = z2.object({
455
+ approvalId: z2.uuid(),
456
+ previousIntentId: z2.uuid().optional()
457
+ }).strict();
458
+ var publishingDraftStatusSchema = z2.enum([
459
+ "QUEUED",
460
+ "PREPARING",
461
+ "UPLOADING_ASSETS",
462
+ "ASSET_UPLOAD_UNVERIFIED",
463
+ "CREATING_DRAFT",
464
+ "VERIFYING",
465
+ "SUCCEEDED",
466
+ "CREATED_UNVERIFIED",
467
+ "FAILED"
468
+ ]);
469
+ var publishingDraftIntentSchema = z2.object({
470
+ accountId: z2.uuid(),
471
+ approvalId: z2.uuid(),
472
+ createdAt: z2.iso.datetime(),
473
+ errorCode: z2.string().trim().min(1).optional(),
474
+ id: z2.uuid(),
475
+ mediaId: z2.string().trim().min(1).max(128).optional(),
476
+ progress: z2.object({
477
+ label: z2.string().trim().min(1).max(40),
478
+ message: z2.string().trim().min(1).max(300),
479
+ nextAction: z2.string().trim().min(1).max(300),
480
+ pollAfterSeconds: z2.number().int().positive().max(60).nullable(),
481
+ terminal: z2.boolean()
482
+ }).strict(),
483
+ snapshotHash: sha256Schema,
484
+ status: publishingDraftStatusSchema,
485
+ updatedAt: z2.iso.datetime(),
486
+ verification: z2.object({
487
+ authorMatched: z2.boolean(),
488
+ contentMatched: z2.boolean(),
489
+ digestMatched: z2.boolean(),
490
+ titleMatched: z2.boolean()
491
+ }).strict().optional()
492
+ }).strict();
493
+ var publishingDraftIntentResponseSchema = z2.object({
494
+ intent: publishingDraftIntentSchema
495
+ }).strict();
496
+
497
+ // packages/contracts/src/content-workflow.ts
498
+ import { z as z3 } from "zod";
499
+ var CONTENT_WORKFLOW_ID = "dxc-article@1";
500
+ var CONTENT_PROFILE_QUESTIONNAIRE_VERSION = "dxc-onboarding@1";
501
+ var CONTENT_ARTIFACT_KINDS = [
502
+ "research",
503
+ "brief",
504
+ "outline",
505
+ "article",
506
+ "titles",
507
+ "visual-plan",
508
+ "quality-review",
509
+ "delivery"
510
+ ];
511
+ var contentArtifactKindSchema = z3.enum(CONTENT_ARTIFACT_KINDS);
512
+ var CONTENT_STAGE_INPUTS = {
513
+ article: { optional: [], required: ["research", "brief", "outline"] },
514
+ brief: { optional: [], required: ["research"] },
515
+ delivery: { optional: [], required: ["article", "titles", "visual-plan", "quality-review"] },
516
+ outline: { optional: [], required: ["research", "brief"] },
517
+ "quality-review": { optional: ["visual-plan"], required: ["research", "article", "titles"] },
518
+ research: { optional: [], required: [] },
519
+ titles: { optional: ["brief"], required: ["article"] },
520
+ "visual-plan": { optional: ["outline"], required: ["article", "titles"] }
521
+ };
522
+ function isPortableRelativePath(value) {
523
+ if (value.startsWith("/") || value.includes("\\") || /[:*?"<>|\0]/u.test(value)) {
524
+ return false;
525
+ }
526
+ return value.split("/").every((segment) => segment.length > 0 && segment !== "." && segment !== "..");
527
+ }
528
+ var portableRelativePathSchema = z3.string().trim().min(1).max(240).refine(isPortableRelativePath, "path must stay inside the project directory");
529
+ var contentProjectArtifactPathsSchema = z3.object({
530
+ article: portableRelativePathSchema,
531
+ brief: portableRelativePathSchema,
532
+ delivery: portableRelativePathSchema,
533
+ outline: portableRelativePathSchema,
534
+ "quality-review": portableRelativePathSchema,
535
+ research: portableRelativePathSchema,
536
+ titles: portableRelativePathSchema,
537
+ "visual-plan": portableRelativePathSchema
538
+ }).strict();
539
+ var contentProjectManifestSchema = z3.object({
540
+ artifacts: contentProjectArtifactPathsSchema,
541
+ assetsDirectory: portableRelativePathSchema,
542
+ // Persisted 0.1.x projects may contain this field. New projects do not create checkpoints.
543
+ checkpointsDirectory: portableRelativePathSchema.optional(),
544
+ createdAt: z3.iso.datetime(),
545
+ projectId: z3.uuid(),
546
+ schemaVersion: z3.literal("1"),
547
+ title: z3.string().trim().min(1).max(160),
548
+ workflowId: z3.literal(CONTENT_WORKFLOW_ID)
549
+ }).strict();
550
+ var contentProjectIndexEntrySchema = z3.object({
551
+ directory: z3.string().trim().min(1).max(4096),
552
+ projectId: z3.uuid(),
553
+ title: z3.string().trim().min(1).max(160),
554
+ updatedAt: z3.iso.datetime()
555
+ }).strict();
556
+ var contentProjectIndexSchema = z3.object({
557
+ projects: z3.array(contentProjectIndexEntrySchema).max(1e3),
558
+ schemaVersion: z3.literal("1")
559
+ }).strict();
560
+ var contentProfileAnswerSchema = z3.object({
561
+ note: z3.string().trim().max(500).optional(),
562
+ questionId: z3.string().regex(/^[a-z][a-z0-9.-]{1,63}$/u),
563
+ selectedOptionIds: z3.array(z3.string().regex(/^[a-z][a-z0-9.-]{1,63}$/u)).min(1).max(8)
564
+ }).strict();
565
+ var currentProfileUserSchema = z3.object({
566
+ contentValuePromise: z3.string().trim().min(1).max(500),
567
+ coreValues: z3.string().trim().min(1).max(500).optional(),
568
+ creatorRole: z3.string().trim().min(1).max(120),
569
+ displayName: z3.string().trim().min(1).max(120),
570
+ historyDirectory: z3.string().trim().min(1).max(4096).optional(),
571
+ penName: z3.string().trim().min(1).max(120).optional(),
572
+ pointOfView: z3.string().trim().min(1).max(120).optional(),
573
+ primaryDomains: z3.array(z3.string().trim().min(1).max(120)).min(1).max(5),
574
+ primaryPlatform: z3.literal("wechat-official-account"),
575
+ publishingCadence: z3.string().trim().min(1).max(120).optional(),
576
+ redLines: z3.string().trim().min(1).max(500).optional(),
577
+ targetAudience: z3.string().trim().min(1).max(500),
578
+ titlePreferences: z3.string().trim().min(1).max(500).optional(),
579
+ visualPreferences: z3.string().trim().min(1).max(500).optional(),
580
+ writingVoice: z3.string().trim().min(1).max(500).optional()
581
+ }).strict();
582
+ var storedProfileUserSchema = currentProfileUserSchema.extend({
583
+ confirmationPolicy: z3.enum(["guided", "review-every-stage", "auto-until-delivery"]).optional(),
584
+ visualGenerationAuthorization: z3.object({
585
+ maxImagesPerRun: z3.number().int().min(1).max(20),
586
+ mode: z3.literal("auto-within-limit")
587
+ }).strict().optional()
588
+ });
589
+ var contentProfileInputSchema = z3.object({
590
+ answers: z3.array(contentProfileAnswerSchema).max(32).default([]),
591
+ questionnaireVersion: z3.literal(CONTENT_PROFILE_QUESTIONNAIRE_VERSION),
592
+ user: currentProfileUserSchema
593
+ }).strict();
594
+ var { primaryPlatform: ignoredPrimaryPlatform, ...profileUpdateUserShape } = currentProfileUserSchema.shape;
595
+ var contentProfileUpdateInputSchema = z3.object({
596
+ answers: z3.array(contentProfileAnswerSchema).min(1).max(32).optional(),
597
+ user: z3.object(profileUpdateUserShape).partial().optional()
598
+ }).strict().refine((input) => input.answers !== void 0 || input.user !== void 0, {
599
+ message: "profile update must include answers or user fields"
600
+ });
601
+ var contentProfileSchema = z3.object({
602
+ answers: z3.array(contentProfileAnswerSchema).max(32),
603
+ createdAt: z3.iso.datetime(),
604
+ profileId: z3.uuid(),
605
+ questionnaireVersion: z3.literal(CONTENT_PROFILE_QUESTIONNAIRE_VERSION),
606
+ schemaVersion: z3.literal("1"),
607
+ updatedAt: z3.iso.datetime(),
608
+ user: storedProfileUserSchema
609
+ }).strict();
610
+ var contentProfileResultDataSchema = z3.object({
611
+ profile: contentProfileSchema,
612
+ profilePath: z3.literal("~/.dxc/content-profile.json"),
613
+ userMemoryPath: z3.literal("~/.dxc/USER.md")
614
+ }).strict();
615
+ var contentProfileSaveResultSchema = z3.object({
616
+ command: z3.literal("profile.save"),
617
+ data: contentProfileResultDataSchema,
618
+ ok: z3.literal(true)
619
+ }).strict();
620
+ var contentProfileUpdateResultSchema = z3.object({
621
+ command: z3.literal("profile.update"),
622
+ data: contentProfileResultDataSchema,
623
+ ok: z3.literal(true)
624
+ }).strict();
625
+ var contentProfileStatusResultSchema = z3.object({
626
+ command: z3.literal("profile.status"),
627
+ data: z3.discriminatedUnion("configured", [
628
+ z3.object({
629
+ configured: z3.literal(false),
630
+ profilePath: z3.literal("~/.dxc/content-profile.json"),
631
+ userMemoryPath: z3.literal("~/.dxc/USER.md")
632
+ }).strict(),
633
+ contentProfileResultDataSchema.extend({ configured: z3.literal(true) }).strict()
634
+ ]),
635
+ ok: z3.literal(true)
636
+ }).strict();
637
+ var contentProfileCommandSchema = z3.enum([
638
+ "profile.save",
639
+ "profile.status",
640
+ "profile.update"
641
+ ]);
642
+ var contentProfileErrorResultSchema = z3.object({
643
+ command: contentProfileCommandSchema,
644
+ error: z3.object({
645
+ code: z3.enum(["DXC_PROFILE_INPUT_INVALID", "DXC_PROFILE_INVALID", "DXC_PROFILE_IO_FAILED"]),
646
+ fields: z3.array(z3.string().trim().min(1)).optional(),
647
+ hint: z3.string().trim().min(1).optional(),
648
+ message: z3.string().trim().min(1)
649
+ }).strict(),
650
+ ok: z3.literal(false)
651
+ }).strict();
652
+ var CONTENT_MEMORY_KINDS = [
653
+ "audience-change",
654
+ "brand-context",
655
+ "business-context",
656
+ "temporary-campaign",
657
+ "writing-preference"
658
+ ];
659
+ var contentMemoryKindSchema = z3.enum(CONTENT_MEMORY_KINDS);
660
+ var contentMemoryScopeSchema = z3.enum(["global", "project"]);
661
+ var contentMemoryInputSchema = z3.object({
662
+ content: z3.string().trim().min(1).max(500),
663
+ expiresAt: z3.iso.datetime().optional(),
664
+ kind: contentMemoryKindSchema,
665
+ scope: contentMemoryScopeSchema
666
+ }).strict().refine((input) => input.kind !== "temporary-campaign" || input.expiresAt !== void 0, {
667
+ message: "temporary campaign memory requires an expiry time"
668
+ });
669
+ var contentMemoryRecordSchema = contentMemoryInputSchema.and(
670
+ z3.object({
671
+ createdAt: z3.iso.datetime(),
672
+ id: z3.uuid(),
673
+ source: z3.literal("user-stated"),
674
+ status: z3.enum(["active", "archived", "expired"]),
675
+ updatedAt: z3.iso.datetime()
676
+ }).strict()
677
+ );
678
+ var contentMemoryStoreSchema = z3.object({ memories: z3.array(contentMemoryRecordSchema).max(100), schemaVersion: z3.literal("1") }).strict();
679
+ var contentMemoryResultDataSchema = z3.object({
680
+ memories: z3.array(contentMemoryRecordSchema),
681
+ memoryPath: z3.literal("~/.dxc/content-memory.json")
682
+ }).strict();
683
+ var contentMemoryAddResultSchema = z3.object({
684
+ command: z3.literal("memory.add"),
685
+ data: contentMemoryResultDataSchema.extend({ memory: contentMemoryRecordSchema }),
686
+ ok: z3.literal(true)
687
+ }).strict();
688
+ var contentMemoryArchiveResultSchema = z3.object({
689
+ command: z3.literal("memory.archive"),
690
+ data: contentMemoryResultDataSchema.extend({ memory: contentMemoryRecordSchema }),
691
+ ok: z3.literal(true)
692
+ }).strict();
693
+ var contentMemoryListResultSchema = z3.object({
694
+ command: z3.literal("memory.list"),
695
+ data: contentMemoryResultDataSchema,
696
+ ok: z3.literal(true)
697
+ }).strict();
698
+ var contentMemoryCommandSchema = z3.enum(["memory.add", "memory.archive", "memory.list"]);
699
+ var contentMemoryErrorResultSchema = z3.object({
700
+ command: contentMemoryCommandSchema,
701
+ error: z3.object({
702
+ code: z3.enum([
703
+ "DXC_MEMORY_INPUT_INVALID",
704
+ "DXC_MEMORY_INVALID",
705
+ "DXC_MEMORY_IO_FAILED",
706
+ "DXC_MEMORY_NOT_FOUND"
707
+ ]),
708
+ message: z3.string().trim().min(1)
709
+ }).strict(),
710
+ ok: z3.literal(false)
711
+ }).strict();
712
+
713
+ // packages/contracts/src/content-monitor.ts
714
+ import { z as z5 } from "zod";
715
+
716
+ // packages/contracts/src/content-source.ts
717
+ import { z as z4 } from "zod";
718
+ var sourceFetchKindSchema = z4.enum(["rss", "api", "html"]);
719
+ var sourceExecutionLocationSchema = z4.literal("local-device");
720
+ var sourceDataTransitSchema = z4.literal("local-only");
721
+ var sourceCaptureMetadataSchema = z4.object({
722
+ capturedAt: z4.iso.datetime(),
723
+ contentHash: z4.string().regex(/^[a-f0-9]{64}$/u),
724
+ dataTransit: sourceDataTransitSchema,
725
+ executionLocation: sourceExecutionLocationSchema,
726
+ extractor: z4.string().trim().min(1).max(120),
727
+ finalUrl: z4.url(),
728
+ mediaType: z4.string().trim().min(1).max(160),
729
+ sourceUrl: z4.url()
730
+ }).strict();
731
+ var sourceFeedItemSchema = z4.object({
732
+ id: z4.string().trim().min(1).max(256),
733
+ publishedAt: z4.iso.datetime().optional(),
734
+ summary: z4.string().trim().min(1).max(2e3).optional(),
735
+ title: z4.string().trim().min(1).max(500),
736
+ url: z4.url().optional()
737
+ }).strict();
738
+ var sourceHtmlDocumentSchema = z4.object({
739
+ canonicalUrl: z4.url().optional(),
740
+ excerpt: z4.string().trim().min(1).max(12e3),
741
+ title: z4.string().trim().min(1).max(500)
742
+ }).strict();
743
+ var sourceFetchDataSchema = z4.discriminatedUnion("kind", [
744
+ z4.object({
745
+ capture: sourceCaptureMetadataSchema,
746
+ items: z4.array(sourceFeedItemSchema).max(100),
747
+ kind: z4.literal("rss")
748
+ }).strict(),
749
+ z4.object({
750
+ capture: sourceCaptureMetadataSchema,
751
+ kind: z4.literal("api"),
752
+ payload: z4.unknown()
753
+ }).strict(),
754
+ z4.object({
755
+ capture: sourceCaptureMetadataSchema,
756
+ document: sourceHtmlDocumentSchema,
757
+ kind: z4.literal("html")
758
+ }).strict()
759
+ ]);
760
+ var sourceFetchResultSchema = z4.object({
761
+ command: z4.literal("source.fetch"),
762
+ data: sourceFetchDataSchema,
763
+ ok: z4.literal(true)
764
+ }).strict();
765
+ var sourceFetchErrorResultSchema = z4.object({
766
+ command: z4.literal("source.fetch"),
767
+ error: z4.object({
768
+ code: z4.enum([
769
+ "DXC_SOURCE_AUTH_MISSING",
770
+ "DXC_SOURCE_CONTENT_INVALID",
771
+ "DXC_SOURCE_FETCH_FAILED",
772
+ "DXC_SOURCE_REDIRECT_LIMIT",
773
+ "DXC_SOURCE_RESPONSE_TOO_LARGE",
774
+ "DXC_SOURCE_URL_BLOCKED",
775
+ "DXC_SOURCE_URL_INVALID"
776
+ ]).or(z4.literal("DXC_SOURCE_FAILED")),
777
+ message: z4.string().trim().min(1).max(500),
778
+ recovery: z4.string().trim().min(1).max(800).optional()
779
+ }).strict(),
780
+ ok: z4.literal(false)
781
+ }).strict();
782
+
783
+ // packages/contracts/src/content-monitor.ts
784
+ var contentMonitorSourceSchema = z5.object({
785
+ bearerEnvironment: z5.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u).nullable(),
786
+ createdAt: z5.iso.datetime(),
787
+ enabled: z5.boolean(),
788
+ headerEnvironments: z5.array(
789
+ z5.object({
790
+ environment: z5.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
791
+ header: z5.string().regex(/^[A-Za-z0-9-]+$/u)
792
+ }).strict()
793
+ ).max(12),
794
+ id: z5.uuid(),
795
+ kind: sourceFetchKindSchema,
796
+ name: z5.string().trim().min(1).max(120),
797
+ rssLimit: z5.number().int().min(1).max(100).nullable(),
798
+ url: z5.url()
799
+ }).strict();
800
+ var contentMonitorSourceSummarySchema = contentMonitorSourceSchema.extend({
801
+ lastRunAt: z5.iso.datetime().nullable(),
802
+ lastRunSummary: z5.string().trim().min(1).max(200).nullable(),
803
+ latestItemAt: z5.iso.datetime().nullable(),
804
+ observedItemCount: z5.number().int().nonnegative()
805
+ });
806
+ var contentMonitorRunSourceResultSchema = z5.object({
807
+ failureMessage: z5.string().trim().min(1).max(500).nullable(),
808
+ monitoredItemCount: z5.number().int().nonnegative(),
809
+ newItemCount: z5.number().int().nonnegative(),
810
+ sourceId: z5.uuid(),
811
+ sourceName: z5.string().trim().min(1).max(120),
812
+ summary: z5.string().trim().min(1).max(200),
813
+ unchangedItemCount: z5.number().int().nonnegative(),
814
+ updatedItemCount: z5.number().int().nonnegative()
815
+ }).strict();
816
+ var contentMonitorAddResultSchema = z5.object({
817
+ command: z5.literal("monitor.add"),
818
+ data: z5.object({
819
+ source: contentMonitorSourceSchema,
820
+ summary: z5.string().trim().min(1).max(200)
821
+ }).strict(),
822
+ ok: z5.literal(true)
823
+ }).strict();
824
+ var contentMonitorListResultSchema = z5.object({
825
+ command: z5.literal("monitor.list"),
826
+ data: z5.object({
827
+ sources: z5.array(contentMonitorSourceSummarySchema),
828
+ summary: z5.string().trim().min(1).max(200)
829
+ }).strict(),
830
+ ok: z5.literal(true)
831
+ }).strict();
832
+ var contentMonitorRunResultSchema = z5.object({
833
+ command: z5.literal("monitor.run"),
834
+ data: z5.object({
835
+ failedSourceCount: z5.number().int().nonnegative(),
836
+ finishedAt: z5.iso.datetime(),
837
+ results: z5.array(contentMonitorRunSourceResultSchema),
838
+ startedAt: z5.iso.datetime(),
839
+ summary: z5.string().trim().min(1).max(200)
840
+ }).strict(),
841
+ ok: z5.literal(true)
842
+ }).strict();
843
+ var contentMonitorStatusResultSchema = z5.object({
844
+ command: z5.literal("monitor.status"),
845
+ data: z5.object({
846
+ databasePath: z5.literal("~/.dxc/source-monitor.sqlite"),
847
+ enabledSourceCount: z5.number().int().nonnegative(),
848
+ latestRunAt: z5.iso.datetime().nullable(),
849
+ latestRunSummary: z5.string().trim().min(1).max(200).nullable(),
850
+ sourceCount: z5.number().int().nonnegative(),
851
+ summary: z5.string().trim().min(1).max(200)
852
+ }).strict(),
853
+ ok: z5.literal(true)
854
+ }).strict();
855
+ var contentMonitorRemoveResultSchema = z5.object({
856
+ command: z5.literal("monitor.remove"),
857
+ data: z5.object({
858
+ removed: z5.boolean(),
859
+ sourceId: z5.uuid(),
860
+ summary: z5.string().trim().min(1).max(200)
861
+ }).strict(),
862
+ ok: z5.literal(true)
863
+ }).strict();
864
+ var contentMonitorCommandSchema = z5.enum([
865
+ "monitor.add",
866
+ "monitor.list",
867
+ "monitor.remove",
868
+ "monitor.run",
869
+ "monitor.status"
870
+ ]);
871
+ var contentMonitorErrorResultSchema = z5.object({
872
+ command: contentMonitorCommandSchema,
873
+ error: z5.object({
874
+ code: z5.enum([
875
+ "DXC_MONITOR_IO_FAILED",
876
+ "DXC_MONITOR_SCHEMA_UNSUPPORTED",
877
+ "DXC_MONITOR_SOURCE_INVALID",
878
+ "DXC_MONITOR_SOURCE_NOT_FOUND",
879
+ "DXC_MONITOR_STATE_INVALID"
880
+ ]),
881
+ message: z5.string().trim().min(1).max(500)
882
+ }).strict(),
883
+ ok: z5.literal(false)
884
+ }).strict();
885
+
886
+ // packages/contracts/src/index.ts
887
+ var liveHealthResponseSchema = z6.object({
888
+ status: z6.literal("ok")
889
+ }).strict();
890
+ var readyHealthResponseSchema = z6.object({
891
+ status: z6.literal("ready"),
892
+ checks: z6.object({
893
+ configuration: z6.literal("ok")
894
+ }).strict()
895
+ }).strict();
896
+ var versionResultSchema = z6.object({
897
+ ok: z6.literal(true),
898
+ command: z6.literal("version"),
899
+ data: z6.object({
900
+ cliVersion: z6.string().min(1),
901
+ nodeVersion: z6.string().min(1)
902
+ }).strict()
903
+ }).strict();
904
+ var doctorCheckSchema = z6.object({
905
+ name: z6.enum(["node-runtime", "working-directory"]),
906
+ status: z6.enum(["ok", "error"]),
907
+ message: z6.string().min(1)
908
+ }).strict();
909
+ var doctorResultSchema = z6.object({
910
+ ok: z6.boolean(),
911
+ command: z6.literal("doctor"),
912
+ data: z6.object({
913
+ status: z6.enum(["ok", "error"]),
914
+ checks: z6.array(doctorCheckSchema)
915
+ }).strict()
916
+ }).strict();
917
+ var articleAssetSchema = z6.object({
918
+ logicalPath: z6.string().trim().min(1),
919
+ role: z6.enum(["cover", "inline"])
920
+ }).strict();
921
+ var articleBundleSchema = z6.object({
922
+ schemaVersion: z6.literal("1"),
923
+ title: z6.string().trim().min(1),
924
+ author: z6.string().trim().min(1),
925
+ digest: z6.string().trim().min(1),
926
+ templateHint: wechatTemplateIdSchema.optional(),
927
+ coverImage: z6.string().trim().min(1).optional(),
928
+ commentsEnabled: z6.boolean(),
929
+ tags: z6.array(z6.string().trim().min(1)),
930
+ markdown: z6.string().trim().min(1),
931
+ assets: z6.array(articleAssetSchema)
932
+ }).strict();
933
+ var preflightIssueSchema = z6.object({
934
+ code: z6.string().trim().min(1),
935
+ path: z6.string().trim().min(1).optional(),
936
+ message: z6.string().trim().min(1)
937
+ }).strict();
938
+ var preflightResultSchema = z6.object({
939
+ ok: z6.boolean(),
940
+ errors: z6.array(preflightIssueSchema),
941
+ warnings: z6.array(preflightIssueSchema),
942
+ metrics: z6.object({
943
+ digestCharacters: z6.number().int().nonnegative(),
944
+ htmlCharacters: z6.number().int().nonnegative(),
945
+ imageCount: z6.number().int().nonnegative(),
946
+ externalLinkCount: z6.number().int().nonnegative(),
947
+ tableCount: z6.number().int().nonnegative()
948
+ }).strict()
949
+ }).strict();
950
+ var wechatRenderResultSchema = z6.object({
951
+ templateId: wechatTemplateIdSchema,
952
+ rendererVersion: z6.string().trim().min(1),
953
+ sourceHash: z6.string().regex(/^[a-f0-9]{64}$/u),
954
+ htmlHash: z6.string().regex(/^[a-f0-9]{64}$/u),
955
+ html: z6.string().min(1),
956
+ preflight: preflightResultSchema
957
+ }).strict();
958
+ var wechatPermissionIdSchema = z6.union([z6.literal(3), z6.literal(11)]);
959
+ var deviceBindingSessionStatusSchema = z6.enum([
960
+ "CREATED",
961
+ "PROVED",
962
+ "AUTHORIZATION_PENDING",
963
+ "BOUND",
964
+ "EXPIRED",
965
+ "FAILED"
966
+ ]);
967
+ var createDeviceBindingSessionRequestSchema = z6.object({
968
+ deviceName: z6.string().trim().min(1).max(80),
969
+ installationId: z6.uuid(),
970
+ publicKeyPem: z6.string().min(80).max(2048)
971
+ }).strict();
972
+ var createDeviceBindingSessionResponseSchema = z6.object({
973
+ challenge: z6.string().regex(/^[A-Za-z0-9_-]{43,128}$/u),
974
+ expiresAt: z6.iso.datetime(),
975
+ id: z6.uuid()
976
+ }).strict();
977
+ var proveDeviceBindingSessionRequestSchema = z6.object({
978
+ challenge: z6.string().regex(/^[A-Za-z0-9_-]{43,128}$/u),
979
+ deviceRefreshTokenHash: z6.string().regex(/^[a-f0-9]{64}$/u).optional(),
980
+ deviceSessionTokenHash: z6.string().regex(/^[a-f0-9]{64}$/u),
981
+ signature: z6.string().regex(/^[A-Za-z0-9_-]{64,256}$/u)
982
+ }).strict();
983
+ var proveDeviceBindingSessionResponseSchema = z6.object({
984
+ bindingToken: z6.string().min(32).max(256),
985
+ expiresAt: z6.iso.datetime(),
986
+ id: z6.uuid(),
987
+ status: z6.literal("PROVED")
988
+ }).strict();
989
+ var deviceSessionIdentitySchema = z6.object({
990
+ deviceId: z6.uuid(),
991
+ deviceName: z6.string().trim().min(1).max(80),
992
+ expiresAt: z6.iso.datetime(),
993
+ tenantId: z6.uuid(),
994
+ userId: z6.uuid()
995
+ }).strict();
996
+ var deviceSessionStatusResponseSchema = z6.object({
997
+ identity: deviceSessionIdentitySchema
998
+ }).strict();
999
+ var deviceSessionCredentialEnrollmentRequestSchema = z6.object({
1000
+ refreshTokenHash: z6.string().regex(/^[a-f0-9]{64}$/u),
1001
+ signature: z6.string().regex(/^[A-Za-z0-9_-]{64,256}$/u)
1002
+ }).strict();
1003
+ var deviceSessionRefreshRequestSchema = z6.object({
1004
+ nextDeviceSessionTokenHash: z6.string().regex(/^[a-f0-9]{64}$/u),
1005
+ nextRefreshTokenHash: z6.string().regex(/^[a-f0-9]{64}$/u),
1006
+ refreshToken: z6.string().regex(/^[A-Za-z0-9_-]{43,256}$/u),
1007
+ rotationId: z6.uuid(),
1008
+ signature: z6.string().regex(/^[A-Za-z0-9_-]{64,256}$/u)
1009
+ }).strict();
1010
+ var wechatLoginSessionPurposeSchema = z6.enum(["link", "login", "start"]);
1011
+ var wechatLoginSessionStatusSchema = z6.enum([
1012
+ "URL_READY",
1013
+ "EXCHANGING",
1014
+ "IDENTIFIED",
1015
+ "SUCCEEDED",
1016
+ "EXPIRED",
1017
+ "FAILED"
1018
+ ]);
1019
+ var wechatLoginFailureCodeSchema = z6.enum([
1020
+ "WECHAT_LOGIN_DEVICE_UNAUTHORIZED",
1021
+ "WECHAT_LOGIN_IDENTITY_CONFLICT",
1022
+ "WECHAT_LOGIN_IDENTITY_NOT_LINKED",
1023
+ "WECHAT_LOGIN_PROVIDER_FAILED",
1024
+ "WECHAT_LOGIN_SESSION_INVALID"
1025
+ ]);
1026
+ var createWechatLoginSessionRequestSchema = z6.object({
1027
+ purpose: wechatLoginSessionPurposeSchema
1028
+ }).strict();
1029
+ var createWechatLoginSessionResponseSchema = z6.object({
1030
+ authorizationUrl: z6.url(),
1031
+ expiresAt: z6.iso.datetime(),
1032
+ id: z6.uuid(),
1033
+ pollToken: z6.string().min(32).max(256),
1034
+ purpose: wechatLoginSessionPurposeSchema
1035
+ }).strict();
1036
+ var wechatLoginSessionResponseSchema = z6.object({
1037
+ expiresAt: z6.iso.datetime(),
1038
+ failureCode: wechatLoginFailureCodeSchema.optional(),
1039
+ id: z6.uuid(),
1040
+ identity: deviceSessionIdentitySchema.optional(),
1041
+ purpose: wechatLoginSessionPurposeSchema,
1042
+ status: wechatLoginSessionStatusSchema
1043
+ }).strict().superRefine((session, context) => {
1044
+ if (session.status === "SUCCEEDED" && session.identity === void 0) {
1045
+ context.addIssue({
1046
+ code: "custom",
1047
+ message: "successful login session requires an identity"
1048
+ });
1049
+ }
1050
+ if (session.status === "FAILED" && session.failureCode === void 0) {
1051
+ context.addIssue({
1052
+ code: "custom",
1053
+ message: "failed login session requires a failure code"
1054
+ });
1055
+ }
1056
+ if (session.status !== "FAILED" && session.failureCode !== void 0) {
1057
+ context.addIssue({
1058
+ code: "custom",
1059
+ message: "only failed login session may expose a failure code"
1060
+ });
1061
+ }
1062
+ });
1063
+ var wechatAccountSchema = z6.object({
1064
+ id: z6.uuid(),
1065
+ displayName: z6.string().trim().min(1),
1066
+ accountType: z6.string().trim().min(1),
1067
+ status: z6.enum(["ACTIVE", "PERMISSION_CHANGED", "REVOKED"]),
1068
+ permissions: z6.array(wechatPermissionIdSchema),
1069
+ draftCapability: z6.enum(["available", "missing", "revoked"])
1070
+ }).strict();
1071
+ var createWechatAuthorizationSessionResponseSchema = z6.object({
1072
+ id: z6.uuid(),
1073
+ authorizationUrl: z6.url(),
1074
+ pollToken: z6.string().min(32).max(256),
1075
+ expiresAt: z6.iso.datetime()
1076
+ }).strict();
1077
+ var wechatAuthorizationSessionResponseSchema = z6.object({
1078
+ id: z6.uuid(),
1079
+ status: z6.enum(["URL_READY", "EXCHANGING", "AUTHORIZED", "BOUND", "EXPIRED", "FAILED"]),
1080
+ expiresAt: z6.iso.datetime(),
1081
+ account: wechatAccountSchema.optional()
1082
+ }).strict();
1083
+ var wechatAccountsResponseSchema = z6.object({
1084
+ accounts: z6.array(wechatAccountSchema)
1085
+ }).strict();
1086
+ var apiErrorResponseSchema = z6.object({
1087
+ error: z6.object({
1088
+ code: z6.string().trim().min(1),
1089
+ message: z6.string().trim().min(1),
1090
+ retryable: z6.boolean()
1091
+ }).strict()
1092
+ }).strict();
1093
+
1094
+ // apps/cli/src/local-state.ts
1095
+ import { randomUUID } from "node:crypto";
1096
+ import { constants as fileConstants } from "node:fs";
1097
+ import { chmod, lstat, mkdir, open, rename, unlink } from "node:fs/promises";
1098
+ import path from "node:path";
1099
+ var LocalStateError = class extends Error {
1100
+ constructor(failure) {
1101
+ super(failure);
1102
+ this.failure = failure;
1103
+ this.name = "LocalStateError";
1104
+ }
1105
+ failure;
1106
+ };
1107
+ function errorCode(error) {
1108
+ return typeof error === "object" && error !== null && "code" in error ? String(error.code) : void 0;
1109
+ }
1110
+ function ownedByCurrentUser(userId, ownerId) {
1111
+ return userId === void 0 || userId === ownerId;
1112
+ }
1113
+ async function ensurePrivateDirectory(directory) {
1114
+ try {
1115
+ await mkdir(directory, { mode: 448, recursive: true });
1116
+ const metadata = await lstat(directory);
1117
+ const userId = typeof process.getuid === "function" ? process.getuid() : void 0;
1118
+ if (!metadata.isDirectory() || metadata.isSymbolicLink() || !ownedByCurrentUser(userId, metadata.uid)) {
1119
+ throw new LocalStateError("invalid");
1120
+ }
1121
+ await chmod(directory, 448);
1122
+ } catch (error) {
1123
+ if (error instanceof LocalStateError) {
1124
+ throw error;
1125
+ }
1126
+ if (errorCode(error) === "ELOOP") {
1127
+ throw new LocalStateError("invalid");
1128
+ }
1129
+ throw new LocalStateError("io");
1130
+ }
1131
+ }
1132
+ async function ensurePrivateRegularFile(target) {
1133
+ await ensurePrivateDirectory(path.dirname(target));
1134
+ let handle;
1135
+ try {
1136
+ handle = await open(
1137
+ target,
1138
+ fileConstants.O_CREAT | fileConstants.O_RDWR | fileConstants.O_NOFOLLOW,
1139
+ 384
1140
+ );
1141
+ const metadata = await handle.stat();
1142
+ const userId = typeof process.getuid === "function" ? process.getuid() : void 0;
1143
+ if (!metadata.isFile() || !ownedByCurrentUser(userId, metadata.uid)) {
1144
+ throw new LocalStateError("invalid");
1145
+ }
1146
+ await handle.chmod(384);
1147
+ } catch (error) {
1148
+ if (error instanceof LocalStateError) {
1149
+ throw error;
1150
+ }
1151
+ if (errorCode(error) === "ELOOP") {
1152
+ throw new LocalStateError("invalid");
1153
+ }
1154
+ throw new LocalStateError("io");
1155
+ } finally {
1156
+ await handle?.close();
1157
+ }
1158
+ }
1159
+ async function readPrivateFile(target, maximumBytes) {
1160
+ const contents = await readPrivateBuffer(target, maximumBytes);
1161
+ return contents.toString("utf8");
1162
+ }
1163
+ async function readPrivateBuffer(target, maximumBytes) {
1164
+ let handle;
1165
+ try {
1166
+ handle = await open(target, fileConstants.O_RDONLY | fileConstants.O_NOFOLLOW);
1167
+ } catch (error) {
1168
+ if (errorCode(error) === "ENOENT") {
1169
+ throw new LocalStateError("missing");
1170
+ }
1171
+ if (errorCode(error) === "ELOOP") {
1172
+ throw new LocalStateError("invalid");
1173
+ }
1174
+ throw new LocalStateError("io");
1175
+ }
1176
+ try {
1177
+ const metadata = await handle.stat();
1178
+ const userId = typeof process.getuid === "function" ? process.getuid() : void 0;
1179
+ if (!metadata.isFile() || !ownedByCurrentUser(userId, metadata.uid) || metadata.size > maximumBytes || process.platform !== "win32" && (metadata.mode & 63) !== 0) {
1180
+ throw new LocalStateError("invalid");
1181
+ }
1182
+ return await handle.readFile();
1183
+ } catch (error) {
1184
+ if (error instanceof LocalStateError) {
1185
+ throw error;
1186
+ }
1187
+ throw new LocalStateError("io");
1188
+ } finally {
1189
+ await handle.close();
1190
+ }
1191
+ }
1192
+ async function writePrivateJson(target, value) {
1193
+ await writePrivateBuffer(target, Buffer.from(`${JSON.stringify(value, void 0, 2)}
1194
+ `, "utf8"));
1195
+ }
1196
+ async function writePrivateBuffer(target, value) {
1197
+ const directory = path.dirname(target);
1198
+ await ensurePrivateDirectory(directory);
1199
+ const temporary = path.join(directory, `.${path.basename(target)}.${randomUUID()}.tmp`);
1200
+ let handle;
1201
+ try {
1202
+ handle = await open(
1203
+ temporary,
1204
+ fileConstants.O_CREAT | fileConstants.O_EXCL | fileConstants.O_WRONLY | fileConstants.O_NOFOLLOW,
1205
+ 384
1206
+ );
1207
+ await handle.writeFile(value);
1208
+ await handle.sync();
1209
+ await handle.close();
1210
+ handle = void 0;
1211
+ await rename(temporary, target);
1212
+ await chmod(target, 384);
1213
+ } catch (error) {
1214
+ throw error instanceof LocalStateError ? error : new LocalStateError("io");
1215
+ } finally {
1216
+ await handle?.close();
1217
+ await unlink(temporary).catch(() => void 0);
1218
+ }
1219
+ }
1220
+
1221
+ // apps/cli/src/user-path.ts
1222
+ import path2 from "node:path";
1223
+ function expandHome(input, homeDirectory, pathApi) {
1224
+ if (input === "~") {
1225
+ return homeDirectory;
1226
+ }
1227
+ if (input.startsWith("~/") || input.startsWith("~\\")) {
1228
+ return pathApi.join(homeDirectory, input.slice(2));
1229
+ }
1230
+ return input;
1231
+ }
1232
+ function windowsShellPath(input) {
1233
+ const msys = /^\/([a-z])(?:\/(.*))?$/iu.exec(input);
1234
+ if (msys !== null) {
1235
+ return `${msys[1]?.toUpperCase()}:\\${(msys[2] ?? "").replaceAll("/", "\\")}`;
1236
+ }
1237
+ const mounted = /^\/(?:cygdrive|mnt)\/([a-z])(?:\/(.*))?$/iu.exec(input);
1238
+ if (mounted !== null) {
1239
+ return `${mounted[1]?.toUpperCase()}:\\${(mounted[2] ?? "").replaceAll("/", "\\")}`;
1240
+ }
1241
+ return input;
1242
+ }
1243
+ function resolveUserPath(options) {
1244
+ const platform = options.platform ?? process.platform;
1245
+ const pathApi = platform === "win32" ? path2.win32 : path2.posix;
1246
+ const expanded = expandHome(options.input, options.homeDirectory, pathApi);
1247
+ if (platform === "win32") {
1248
+ return pathApi.resolve(options.currentDirectory, windowsShellPath(expanded));
1249
+ }
1250
+ return pathApi.resolve(options.currentDirectory, expanded);
1251
+ }
1252
+
1253
+ export {
1254
+ __require,
1255
+ __esm,
1256
+ __commonJS,
1257
+ __export,
1258
+ __toESM,
1259
+ __toCommonJS,
1260
+ publishingUploadSessionSchema,
1261
+ publishingUploadReceiptSchema,
1262
+ publishingArticleSchema,
1263
+ publishingRenderSnapshotSchema,
1264
+ publishingPreviewLinkSchema,
1265
+ publishingPreviewSelectionStateSchema,
1266
+ createPublishingApprovalRequestSchema,
1267
+ publishingApprovalSchema,
1268
+ publishingDraftIntentResponseSchema,
1269
+ CONTENT_WORKFLOW_ID,
1270
+ CONTENT_ARTIFACT_KINDS,
1271
+ CONTENT_STAGE_INPUTS,
1272
+ portableRelativePathSchema,
1273
+ contentProjectManifestSchema,
1274
+ contentProjectIndexSchema,
1275
+ contentProfileInputSchema,
1276
+ contentProfileUpdateInputSchema,
1277
+ contentProfileSchema,
1278
+ contentProfileSaveResultSchema,
1279
+ contentProfileUpdateResultSchema,
1280
+ contentProfileStatusResultSchema,
1281
+ contentMemoryInputSchema,
1282
+ contentMemoryStoreSchema,
1283
+ contentMemoryAddResultSchema,
1284
+ contentMemoryArchiveResultSchema,
1285
+ contentMemoryListResultSchema,
1286
+ CONTENT_KNOWLEDGE_SCHEMA_VERSION,
1287
+ CONTENT_KNOWLEDGE_EMBEDDING_MODEL,
1288
+ CONTENT_KNOWLEDGE_EMBEDDING_REVISION,
1289
+ CONTENT_KNOWLEDGE_EMBEDDING_DIMENSIONS,
1290
+ CONTENT_KNOWLEDGE_EMBEDDING_QUANTIZATION,
1291
+ CONTENT_KNOWLEDGE_CHUNKER_VERSION,
1292
+ contentKnowledgeSearchModeSchema,
1293
+ contentKnowledgeModelSchema,
1294
+ contentKnowledgeImportResultSchema,
1295
+ contentKnowledgeQuoteListResultSchema,
1296
+ contentKnowledgeQuoteMutationResultSchema,
1297
+ contentKnowledgeQuoteInitResultSchema,
1298
+ contentKnowledgeQuoteStatusResultSchema,
1299
+ contentKnowledgeQuoteSyncResultSchema,
1300
+ contentKnowledgeSearchResultSchema,
1301
+ contentKnowledgeStatusResultSchema,
1302
+ contentKnowledgeRemoveResultSchema,
1303
+ doctorResultSchema,
1304
+ articleBundleSchema,
1305
+ preflightResultSchema,
1306
+ wechatRenderResultSchema,
1307
+ createDeviceBindingSessionResponseSchema,
1308
+ proveDeviceBindingSessionResponseSchema,
1309
+ deviceSessionStatusResponseSchema,
1310
+ createWechatLoginSessionResponseSchema,
1311
+ wechatLoginSessionResponseSchema,
1312
+ createWechatAuthorizationSessionResponseSchema,
1313
+ wechatAuthorizationSessionResponseSchema,
1314
+ wechatAccountsResponseSchema,
1315
+ apiErrorResponseSchema,
1316
+ LocalStateError,
1317
+ ensurePrivateDirectory,
1318
+ ensurePrivateRegularFile,
1319
+ readPrivateFile,
1320
+ readPrivateBuffer,
1321
+ writePrivateJson,
1322
+ writePrivateBuffer,
1323
+ resolveUserPath
1324
+ };