@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
@@ -1,2379 +0,0 @@
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/content-source.ts
262
- import { z as z2 } from "zod";
263
- var sourceFetchKindSchema = z2.enum(["rss", "api", "html"]);
264
- var sourceExecutionLocationSchema = z2.literal("local-device");
265
- var sourceDataTransitSchema = z2.literal("local-only");
266
- var sourceCaptureMetadataSchema = z2.object({
267
- capturedAt: z2.iso.datetime(),
268
- contentHash: z2.string().regex(/^[a-f0-9]{64}$/u),
269
- dataTransit: sourceDataTransitSchema,
270
- executionLocation: sourceExecutionLocationSchema,
271
- extractor: z2.string().trim().min(1).max(120),
272
- finalUrl: z2.url(),
273
- mediaType: z2.string().trim().min(1).max(160),
274
- sourceUrl: z2.url()
275
- }).strict();
276
- var sourceFeedItemSchema = z2.object({
277
- id: z2.string().trim().min(1).max(256),
278
- publishedAt: z2.iso.datetime().optional(),
279
- summary: z2.string().trim().min(1).max(2e3).optional(),
280
- title: z2.string().trim().min(1).max(500),
281
- url: z2.url().optional()
282
- }).strict();
283
- var sourceHtmlDocumentSchema = z2.object({
284
- canonicalUrl: z2.url().optional(),
285
- excerpt: z2.string().trim().min(1).max(12e3),
286
- title: z2.string().trim().min(1).max(500)
287
- }).strict();
288
- var sourceFetchDataSchema = z2.discriminatedUnion("kind", [
289
- z2.object({
290
- capture: sourceCaptureMetadataSchema,
291
- items: z2.array(sourceFeedItemSchema).max(100),
292
- kind: z2.literal("rss")
293
- }).strict(),
294
- z2.object({
295
- capture: sourceCaptureMetadataSchema,
296
- kind: z2.literal("api"),
297
- payload: z2.unknown()
298
- }).strict(),
299
- z2.object({
300
- capture: sourceCaptureMetadataSchema,
301
- document: sourceHtmlDocumentSchema,
302
- kind: z2.literal("html")
303
- }).strict()
304
- ]);
305
- var sourceFetchResultSchema = z2.object({
306
- command: z2.literal("source.fetch"),
307
- data: sourceFetchDataSchema,
308
- ok: z2.literal(true)
309
- }).strict();
310
- var sourceFetchErrorResultSchema = z2.object({
311
- command: z2.literal("source.fetch"),
312
- error: z2.object({
313
- code: z2.enum([
314
- "DXC_SOURCE_AUTH_MISSING",
315
- "DXC_SOURCE_CONTENT_INVALID",
316
- "DXC_SOURCE_FETCH_FAILED",
317
- "DXC_SOURCE_REDIRECT_LIMIT",
318
- "DXC_SOURCE_RESPONSE_TOO_LARGE",
319
- "DXC_SOURCE_URL_BLOCKED",
320
- "DXC_SOURCE_URL_INVALID"
321
- ]).or(z2.literal("DXC_SOURCE_FAILED")),
322
- message: z2.string().trim().min(1).max(500),
323
- recovery: z2.string().trim().min(1).max(800).optional()
324
- }).strict(),
325
- ok: z2.literal(false)
326
- }).strict();
327
-
328
- // packages/contracts/src/content-monitor.ts
329
- import { z as z3 } from "zod";
330
- var CONTENT_MONITOR_SCHEMA_VERSION = "1";
331
- var contentMonitorSourceSchema = z3.object({
332
- bearerEnvironment: z3.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u).nullable(),
333
- createdAt: z3.iso.datetime(),
334
- enabled: z3.boolean(),
335
- headerEnvironments: z3.array(
336
- z3.object({
337
- environment: z3.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
338
- header: z3.string().regex(/^[A-Za-z0-9-]+$/u)
339
- }).strict()
340
- ).max(12),
341
- id: z3.uuid(),
342
- kind: sourceFetchKindSchema,
343
- name: z3.string().trim().min(1).max(120),
344
- rssLimit: z3.number().int().min(1).max(100).nullable(),
345
- url: z3.url()
346
- }).strict();
347
- var contentMonitorSourceSummarySchema = contentMonitorSourceSchema.extend({
348
- lastRunAt: z3.iso.datetime().nullable(),
349
- lastRunSummary: z3.string().trim().min(1).max(200).nullable(),
350
- latestItemAt: z3.iso.datetime().nullable(),
351
- observedItemCount: z3.number().int().nonnegative()
352
- });
353
- var contentMonitorRunSourceResultSchema = z3.object({
354
- failureMessage: z3.string().trim().min(1).max(500).nullable(),
355
- monitoredItemCount: z3.number().int().nonnegative(),
356
- newItemCount: z3.number().int().nonnegative(),
357
- sourceId: z3.uuid(),
358
- sourceName: z3.string().trim().min(1).max(120),
359
- summary: z3.string().trim().min(1).max(200),
360
- unchangedItemCount: z3.number().int().nonnegative(),
361
- updatedItemCount: z3.number().int().nonnegative()
362
- }).strict();
363
- var contentMonitorAddResultSchema = z3.object({
364
- command: z3.literal("monitor.add"),
365
- data: z3.object({
366
- source: contentMonitorSourceSchema,
367
- summary: z3.string().trim().min(1).max(200)
368
- }).strict(),
369
- ok: z3.literal(true)
370
- }).strict();
371
- var contentMonitorListResultSchema = z3.object({
372
- command: z3.literal("monitor.list"),
373
- data: z3.object({
374
- sources: z3.array(contentMonitorSourceSummarySchema),
375
- summary: z3.string().trim().min(1).max(200)
376
- }).strict(),
377
- ok: z3.literal(true)
378
- }).strict();
379
- var contentMonitorRunResultSchema = z3.object({
380
- command: z3.literal("monitor.run"),
381
- data: z3.object({
382
- failedSourceCount: z3.number().int().nonnegative(),
383
- finishedAt: z3.iso.datetime(),
384
- results: z3.array(contentMonitorRunSourceResultSchema),
385
- startedAt: z3.iso.datetime(),
386
- summary: z3.string().trim().min(1).max(200)
387
- }).strict(),
388
- ok: z3.literal(true)
389
- }).strict();
390
- var contentMonitorStatusResultSchema = z3.object({
391
- command: z3.literal("monitor.status"),
392
- data: z3.object({
393
- databasePath: z3.literal("~/.dxc/source-monitor.sqlite"),
394
- enabledSourceCount: z3.number().int().nonnegative(),
395
- latestRunAt: z3.iso.datetime().nullable(),
396
- latestRunSummary: z3.string().trim().min(1).max(200).nullable(),
397
- sourceCount: z3.number().int().nonnegative(),
398
- summary: z3.string().trim().min(1).max(200)
399
- }).strict(),
400
- ok: z3.literal(true)
401
- }).strict();
402
- var contentMonitorRemoveResultSchema = z3.object({
403
- command: z3.literal("monitor.remove"),
404
- data: z3.object({
405
- removed: z3.boolean(),
406
- sourceId: z3.uuid(),
407
- summary: z3.string().trim().min(1).max(200)
408
- }).strict(),
409
- ok: z3.literal(true)
410
- }).strict();
411
- var contentMonitorCommandSchema = z3.enum([
412
- "monitor.add",
413
- "monitor.list",
414
- "monitor.remove",
415
- "monitor.run",
416
- "monitor.status"
417
- ]);
418
- var contentMonitorErrorResultSchema = z3.object({
419
- command: contentMonitorCommandSchema,
420
- error: z3.object({
421
- code: z3.enum([
422
- "DXC_MONITOR_IO_FAILED",
423
- "DXC_MONITOR_SCHEMA_UNSUPPORTED",
424
- "DXC_MONITOR_SOURCE_INVALID",
425
- "DXC_MONITOR_SOURCE_NOT_FOUND",
426
- "DXC_MONITOR_STATE_INVALID"
427
- ]),
428
- message: z3.string().trim().min(1).max(500)
429
- }).strict(),
430
- ok: z3.literal(false)
431
- }).strict();
432
-
433
- // packages/contracts/src/index.ts
434
- import { z as z6 } from "zod";
435
-
436
- // packages/contracts/src/publishing.ts
437
- import { z as z4 } from "zod";
438
- var sha256Schema = z4.string().regex(/^[a-f0-9]{64}$/u);
439
- var wechatTemplateIdSchema = z4.enum([
440
- "wechat-minimal@1",
441
- "wechat-academic-paper@1",
442
- "wechat-aurora-glass@1",
443
- "wechat-bauhaus@1",
444
- "wechat-cyberpunk-neon@1",
445
- "wechat-knowledge-base@1",
446
- "wechat-luxury-gold@1",
447
- "wechat-morandi-forest@1",
448
- "wechat-neo-brutalism@1",
449
- "wechat-receipt@1",
450
- "wechat-sunset-film@1"
451
- ]);
452
- var publishingUploadKindSchema = z4.enum(["article-source", "cover-image", "inline-image"]);
453
- var publishingUploadMediaTypeSchema = z4.enum([
454
- "text/markdown",
455
- "text/plain",
456
- "image/jpeg",
457
- "image/png"
458
- ]);
459
- var createPublishingUploadRequestSchema = z4.object({
460
- fileName: z4.string().trim().min(1).max(160),
461
- kind: publishingUploadKindSchema,
462
- mediaType: publishingUploadMediaTypeSchema,
463
- sha256: sha256Schema,
464
- size: z4.number().int().positive().max(5 * 1024 * 1024)
465
- }).strict().superRefine((value, context) => {
466
- if (value.kind === "article-source" && value.mediaType !== "text/markdown" && value.mediaType !== "text/plain") {
467
- context.addIssue({
468
- code: "custom",
469
- message: "article source requires a text media type",
470
- path: ["mediaType"]
471
- });
472
- }
473
- if ((value.kind === "cover-image" || value.kind === "inline-image") && value.mediaType !== "image/jpeg" && value.mediaType !== "image/png") {
474
- context.addIssue({
475
- code: "custom",
476
- message: "image upload requires a supported image media type",
477
- path: ["mediaType"]
478
- });
479
- }
480
- if (value.kind === "article-source" && value.size > 512 * 1024) {
481
- context.addIssue({
482
- code: "custom",
483
- message: "article source exceeds the maximum size",
484
- path: ["size"]
485
- });
486
- }
487
- if (value.kind === "inline-image" && value.size >= 1024 * 1024) {
488
- context.addIssue({
489
- code: "custom",
490
- message: "inline image must be smaller than 1 MiB",
491
- path: ["size"]
492
- });
493
- }
494
- });
495
- var publishingUploadSessionSchema = z4.object({
496
- expiresAt: z4.iso.datetime(),
497
- id: z4.uuid(),
498
- kind: publishingUploadKindSchema,
499
- uploadUrl: z4.url()
500
- }).strict();
501
- var publishingUploadReceiptSchema = z4.object({
502
- id: z4.uuid(),
503
- sha256: sha256Schema,
504
- size: z4.number().int().positive().max(5 * 1024 * 1024),
505
- status: z4.literal("UPLOADED")
506
- }).strict();
507
- var createPublishingArticleRequestSchema = z4.object({
508
- coverUploadId: z4.uuid(),
509
- inlineAssets: z4.array(
510
- z4.object({
511
- logicalPath: z4.string().trim().min(1).max(240),
512
- uploadId: z4.uuid()
513
- }).strict()
514
- ).max(20).optional(),
515
- sourceUploadId: z4.uuid()
516
- }).strict().superRefine((value, context) => {
517
- const inlineAssets = value.inlineAssets ?? [];
518
- const logicalPaths = inlineAssets.map((asset) => asset.logicalPath);
519
- const uploadIds = inlineAssets.map((asset) => asset.uploadId);
520
- if (new Set(logicalPaths).size !== logicalPaths.length) {
521
- context.addIssue({
522
- code: "custom",
523
- message: "inline asset logical paths must be unique",
524
- path: ["inlineAssets"]
525
- });
526
- }
527
- if (new Set(uploadIds).size !== uploadIds.length) {
528
- context.addIssue({
529
- code: "custom",
530
- message: "inline asset uploads must be unique",
531
- path: ["inlineAssets"]
532
- });
533
- }
534
- });
535
- var publishingInlineAssetSchema = z4.object({
536
- logicalPath: z4.string().trim().min(1).max(240),
537
- mediaType: z4.enum(["image/jpeg", "image/png"]),
538
- sha256: sha256Schema
539
- }).strict();
540
- var publishingArticleSchema = z4.object({
541
- cover: z4.object({
542
- height: z4.number().int().positive().max(12e3),
543
- mediaType: z4.enum(["image/jpeg", "image/png"]),
544
- width: z4.number().int().positive().max(12e3)
545
- }).strict(),
546
- coverHash: sha256Schema,
547
- createdAt: z4.iso.datetime(),
548
- id: z4.uuid(),
549
- inlineAssets: z4.array(publishingInlineAssetSchema).max(20).default([]),
550
- sourceHash: sha256Schema
551
- }).strict();
552
- var createPublishingRenderSnapshotRequestSchema = z4.object({
553
- title: z4.string().trim().min(1).max(64).optional()
554
- }).strict();
555
- var publishingPreflightIssueSchema = z4.object({
556
- code: z4.string().trim().min(1),
557
- message: z4.string().trim().min(1),
558
- path: z4.string().trim().min(1).optional()
559
- }).strict();
560
- var publishingPreflightSchema = z4.object({
561
- errors: z4.array(publishingPreflightIssueSchema),
562
- metrics: z4.object({
563
- digestCharacters: z4.number().int().nonnegative(),
564
- externalLinkCount: z4.number().int().nonnegative(),
565
- htmlCharacters: z4.number().int().nonnegative(),
566
- imageCount: z4.number().int().nonnegative(),
567
- tableCount: z4.number().int().nonnegative()
568
- }).strict(),
569
- ok: z4.boolean(),
570
- warnings: z4.array(publishingPreflightIssueSchema)
571
- }).strict();
572
- var publishingRenderSnapshotSchema = z4.object({
573
- articleId: z4.uuid(),
574
- assetManifestHash: sha256Schema,
575
- author: z4.string().trim().min(1).max(16),
576
- commentsEnabled: z4.boolean(),
577
- coverHash: sha256Schema,
578
- createdAt: z4.iso.datetime(),
579
- digest: z4.string().trim().min(1).max(120),
580
- htmlHash: sha256Schema,
581
- id: z4.uuid(),
582
- inlineAssets: z4.array(publishingInlineAssetSchema).max(20).default([]),
583
- preflight: publishingPreflightSchema,
584
- rendererVersion: z4.string().trim().min(1),
585
- snapshotHash: sha256Schema,
586
- sourceHash: sha256Schema,
587
- templateId: wechatTemplateIdSchema,
588
- title: z4.string().trim().min(1).max(32)
589
- }).strict();
590
- var createPublishingPreviewLinkRequestSchema = z4.object({
591
- snapshotHash: sha256Schema
592
- }).strict();
593
- var publishingPreviewLinkSchema = z4.object({
594
- createdAt: z4.iso.datetime().optional(),
595
- expiresAt: z4.iso.datetime(),
596
- expiresInSeconds: z4.number().int().positive().max(24 * 60 * 60).optional(),
597
- snapshotHash: sha256Schema,
598
- url: z4.url()
599
- }).strict();
600
- var publishingPreviewSelectionStateSchema = z4.object({
601
- rootSnapshotHash: sha256Schema,
602
- rootSnapshotId: z4.uuid(),
603
- selectedSnapshotHash: sha256Schema,
604
- selectedSnapshotId: z4.uuid(),
605
- selectionRevision: z4.number().int().nonnegative(),
606
- templateId: wechatTemplateIdSchema,
607
- updatedAt: z4.iso.datetime(),
608
- viewed: z4.boolean(),
609
- viewedAt: z4.iso.datetime().nullable()
610
- }).strict();
611
- var createPublishingApprovalRequestSchema = z4.object({
612
- accountId: z4.uuid(),
613
- confirmed: z4.literal(true),
614
- snapshotHash: sha256Schema
615
- }).strict();
616
- var publishingApprovalSchema = z4.object({
617
- accountId: z4.uuid(),
618
- confirmedAt: z4.iso.datetime(),
619
- id: z4.uuid(),
620
- rootSnapshotHash: sha256Schema,
621
- rootSnapshotId: z4.uuid(),
622
- selectedSnapshotHash: sha256Schema,
623
- selectedSnapshotId: z4.uuid(),
624
- snapshotHash: sha256Schema,
625
- snapshotId: z4.uuid(),
626
- templateId: wechatTemplateIdSchema
627
- }).strict().superRefine((approval, context) => {
628
- if (approval.snapshotId !== approval.selectedSnapshotId || approval.snapshotHash !== approval.selectedSnapshotHash) {
629
- context.addIssue({
630
- code: "custom",
631
- message: "legacy snapshot aliases must identify the selected snapshot"
632
- });
633
- }
634
- });
635
- var createPublishingDraftIntentRequestSchema = z4.object({
636
- approvalId: z4.uuid(),
637
- previousIntentId: z4.uuid().optional()
638
- }).strict();
639
- var publishingDraftStatusSchema = z4.enum([
640
- "QUEUED",
641
- "PREPARING",
642
- "UPLOADING_ASSETS",
643
- "ASSET_UPLOAD_UNVERIFIED",
644
- "CREATING_DRAFT",
645
- "VERIFYING",
646
- "SUCCEEDED",
647
- "CREATED_UNVERIFIED",
648
- "FAILED"
649
- ]);
650
- var publishingDraftIntentSchema = z4.object({
651
- accountId: z4.uuid(),
652
- approvalId: z4.uuid(),
653
- createdAt: z4.iso.datetime(),
654
- errorCode: z4.string().trim().min(1).optional(),
655
- id: z4.uuid(),
656
- mediaId: z4.string().trim().min(1).max(128).optional(),
657
- progress: z4.object({
658
- label: z4.string().trim().min(1).max(40),
659
- message: z4.string().trim().min(1).max(300),
660
- nextAction: z4.string().trim().min(1).max(300),
661
- pollAfterSeconds: z4.number().int().positive().max(60).nullable(),
662
- terminal: z4.boolean()
663
- }).strict(),
664
- snapshotHash: sha256Schema,
665
- status: publishingDraftStatusSchema,
666
- updatedAt: z4.iso.datetime(),
667
- verification: z4.object({
668
- authorMatched: z4.boolean(),
669
- contentMatched: z4.boolean(),
670
- digestMatched: z4.boolean(),
671
- titleMatched: z4.boolean()
672
- }).strict().optional()
673
- }).strict();
674
- var publishingDraftIntentResponseSchema = z4.object({
675
- intent: publishingDraftIntentSchema
676
- }).strict();
677
-
678
- // packages/contracts/src/content-workflow.ts
679
- import { z as z5 } from "zod";
680
- var CONTENT_WORKFLOW_ID = "dxc-article@1";
681
- var CONTENT_PROFILE_QUESTIONNAIRE_VERSION = "dxc-onboarding@1";
682
- var CONTENT_ARTIFACT_KINDS = [
683
- "research",
684
- "brief",
685
- "outline",
686
- "article",
687
- "titles",
688
- "visual-plan",
689
- "quality-review",
690
- "delivery"
691
- ];
692
- var contentArtifactKindSchema = z5.enum(CONTENT_ARTIFACT_KINDS);
693
- var CONTENT_STAGE_SKILLS = {
694
- article: { name: "dxc-article-write", version: "0.1.0" },
695
- brief: { name: "dxc-content-brief", version: "0.1.0" },
696
- delivery: { name: "dxc-wechat-publisher", version: "0.6.0" },
697
- outline: { name: "dxc-article-outline", version: "0.1.0" },
698
- "quality-review": { name: "dxc-content-review", version: "0.3.0" },
699
- research: { name: "dxc-research", version: "0.2.0" },
700
- titles: { name: "dxc-title-write", version: "0.3.0" },
701
- "visual-plan": { name: "dxc-visual-plan", version: "0.3.0" }
702
- };
703
- var CONTENT_STAGE_INPUTS = {
704
- article: {
705
- optional: [],
706
- required: ["research", "brief", "outline"]
707
- },
708
- brief: {
709
- optional: [],
710
- required: ["research"]
711
- },
712
- delivery: {
713
- optional: [],
714
- required: ["article", "titles", "visual-plan", "quality-review"]
715
- },
716
- outline: {
717
- optional: [],
718
- required: ["research", "brief"]
719
- },
720
- "quality-review": {
721
- optional: ["visual-plan"],
722
- required: ["research", "article", "titles"]
723
- },
724
- research: {
725
- optional: [],
726
- required: []
727
- },
728
- titles: {
729
- optional: ["brief"],
730
- required: ["article"]
731
- },
732
- "visual-plan": {
733
- optional: ["outline"],
734
- required: ["article", "titles"]
735
- }
736
- };
737
- var portableRelativePathSchema = z5.string().trim().min(1).max(240).refine((value) => !value.startsWith("/") && !value.includes("\\"), {
738
- message: "path must use portable relative path syntax"
739
- }).refine((value) => !/[:*?"<>|]/u.test(value) && !value.includes(String.fromCharCode(0)), {
740
- message: "path contains a non-portable character"
741
- }).refine(
742
- (value) => {
743
- const segments = value.split("/");
744
- return segments.every(
745
- (segment) => segment.length > 0 && segment !== "." && segment !== ".." && !segment.endsWith(" ") && !segment.endsWith(".")
746
- );
747
- },
748
- {
749
- message: "path must stay inside the project directory"
750
- }
751
- );
752
- var contentProjectArtifactPathsSchema = z5.object({
753
- article: portableRelativePathSchema,
754
- brief: portableRelativePathSchema,
755
- delivery: portableRelativePathSchema,
756
- outline: portableRelativePathSchema,
757
- "quality-review": portableRelativePathSchema,
758
- research: portableRelativePathSchema,
759
- titles: portableRelativePathSchema,
760
- "visual-plan": portableRelativePathSchema
761
- }).strict().superRefine((paths, context) => {
762
- const values = Object.values(paths);
763
- if (new Set(values).size !== values.length) {
764
- context.addIssue({
765
- code: "custom",
766
- message: "artifact paths must be unique"
767
- });
768
- }
769
- if (values.some(
770
- (value, index) => values.some(
771
- (otherValue, otherIndex) => index !== otherIndex && (value.startsWith(`${otherValue}/`) || otherValue.startsWith(`${value}/`))
772
- )
773
- )) {
774
- context.addIssue({
775
- code: "custom",
776
- message: "artifact paths must not contain one another"
777
- });
778
- }
779
- });
780
- var contentProjectManifestSchema = z5.object({
781
- artifacts: contentProjectArtifactPathsSchema,
782
- assetsDirectory: portableRelativePathSchema,
783
- checkpointsDirectory: portableRelativePathSchema,
784
- createdAt: z5.iso.datetime(),
785
- projectId: z5.uuid(),
786
- schemaVersion: z5.literal("1"),
787
- title: z5.string().trim().min(1).max(160),
788
- workflowId: z5.literal(CONTENT_WORKFLOW_ID)
789
- }).strict().superRefine((manifest, context) => {
790
- const artifactPaths = Object.values(manifest.artifacts);
791
- const overlapsDirectory = (artifactPath, directory) => artifactPath === directory || artifactPath.startsWith(`${directory}/`) || directory.startsWith(`${artifactPath}/`);
792
- if (artifactPaths.some(
793
- (artifactPath) => overlapsDirectory(artifactPath, manifest.assetsDirectory)
794
- )) {
795
- context.addIssue({
796
- code: "custom",
797
- message: "assets directory must not overlap an artifact path"
798
- });
799
- }
800
- if (artifactPaths.some(
801
- (artifactPath) => overlapsDirectory(artifactPath, manifest.checkpointsDirectory)
802
- )) {
803
- context.addIssue({
804
- code: "custom",
805
- message: "checkpoints directory must not overlap an artifact path"
806
- });
807
- }
808
- if (manifest.assetsDirectory === manifest.checkpointsDirectory || manifest.assetsDirectory.startsWith(`${manifest.checkpointsDirectory}/`) || manifest.checkpointsDirectory.startsWith(`${manifest.assetsDirectory}/`)) {
809
- context.addIssue({
810
- code: "custom",
811
- message: "assets and checkpoints directories must not overlap"
812
- });
813
- }
814
- });
815
- var contentProjectArtifactBaseSchema = z5.object({
816
- kind: contentArtifactKindSchema,
817
- path: portableRelativePathSchema
818
- }).strict();
819
- var contentProjectArtifactStatusSchema = z5.discriminatedUnion("status", [
820
- contentProjectArtifactBaseSchema.extend({
821
- status: z5.literal("missing")
822
- }),
823
- contentProjectArtifactBaseSchema.extend({
824
- bytes: z5.literal(0),
825
- status: z5.literal("empty")
826
- }),
827
- contentProjectArtifactBaseSchema.extend({
828
- bytes: z5.number().int().positive(),
829
- sha256: z5.string().regex(/^[a-f0-9]{64}$/u),
830
- status: z5.literal("ready")
831
- })
832
- ]);
833
- var contentStageArtifactStatusSchema = z5.enum(["complete", "awaiting-user", "blocked"]);
834
- var contentStageArtifactInputSchema = z5.object({
835
- kind: contentArtifactKindSchema,
836
- path: portableRelativePathSchema,
837
- sha256: z5.string().regex(/^[a-f0-9]{64}$/u)
838
- }).strict();
839
- var contentQuoteSnapshotSchema = z5.object({
840
- contentSha256: z5.string().regex(/^[a-f0-9]{64}$/u),
841
- quoteId: z5.uuid()
842
- }).strict();
843
- var contentStageMetadataBaseShape = {
844
- artifactStatus: contentStageArtifactStatusSchema,
845
- contract: z5.literal("dxc-content-stage@1"),
846
- createdAt: z5.iso.datetime(),
847
- inputs: z5.array(contentStageArtifactInputSchema).max(CONTENT_ARTIFACT_KINDS.length),
848
- projectId: z5.uuid(),
849
- skill: z5.string().regex(/^dxc-[a-z0-9]+(?:-[a-z0-9]+)*@\d+\.\d+\.\d+$/u),
850
- workflowId: z5.literal(CONTENT_WORKFLOW_ID)
851
- };
852
- var researchSourceSchema = z5.object({
853
- id: z5.string().regex(/^source-[a-z0-9][a-z0-9-]{0,63}$/u),
854
- locator: z5.string().trim().min(1).max(2048),
855
- observedAt: z5.iso.datetime(),
856
- stance: z5.enum(["support", "oppose", "supplement", "neutral", "not-applicable"]),
857
- type: z5.enum(["primary", "public-fact", "public-opinion", "local-history", "user-provided"]),
858
- verification: z5.enum(["verified", "unverified"])
859
- }).strict().superRefine((value, context) => {
860
- if (["primary", "public-fact", "public-opinion"].includes(value.type)) {
861
- try {
862
- const url = new URL(value.locator);
863
- if (url.protocol !== "http:" && url.protocol !== "https:") {
864
- throw new Error("unsupported protocol");
865
- }
866
- } catch {
867
- context.addIssue({
868
- code: "custom",
869
- message: "public research sources require a complete HTTP(S) URL",
870
- path: ["locator"]
871
- });
872
- }
873
- }
874
- if (value.type === "public-opinion" && !["support", "oppose", "supplement"].includes(value.stance)) {
875
- context.addIssue({
876
- code: "custom",
877
- message: "public opinion sources require a stance",
878
- path: ["stance"]
879
- });
880
- }
881
- });
882
- var researchStanceCoverageSchema = z5.object({
883
- oppose: z5.enum(["covered", "not-found", "not-applicable"]),
884
- supplement: z5.enum(["covered", "not-found", "not-applicable"]),
885
- support: z5.enum(["covered", "not-found", "not-applicable"])
886
- }).strict();
887
- var researchStageArtifactFrontmatterSchema = z5.object({
888
- coverageNote: z5.string().trim().min(1).max(1e3),
889
- dxc: z5.object({
890
- ...contentStageMetadataBaseShape,
891
- stage: z5.literal("research")
892
- }).strict(),
893
- externalOpinionStatus: z5.enum(["covered", "not-applicable", "user-skipped"]),
894
- origin: z5.enum(["hotspot", "article", "keywords", "intent"]),
895
- researchMode: z5.enum(["fact-only", "viewpoint-scan"]),
896
- sourceCount: z5.number().int().nonnegative(),
897
- sources: z5.array(researchSourceSchema).max(100),
898
- stanceCoverage: researchStanceCoverageSchema
899
- }).strict().superRefine((value, context) => {
900
- if (value.sourceCount !== value.sources.length) {
901
- context.addIssue({
902
- code: "custom",
903
- message: "sourceCount must equal the number of structured sources",
904
- path: ["sourceCount"]
905
- });
906
- }
907
- if (new Set(value.sources.map((source) => source.id)).size !== value.sources.length) {
908
- context.addIssue({
909
- code: "custom",
910
- message: "research source ids must be unique",
911
- path: ["sources"]
912
- });
913
- }
914
- if (new Set(value.sources.map((source) => source.locator)).size !== value.sources.length) {
915
- context.addIssue({
916
- code: "custom",
917
- message: "research source locators must be unique",
918
- path: ["sources"]
919
- });
920
- }
921
- if (value.researchMode === "fact-only") {
922
- const expectedStatus = value.origin === "hotspot" ? "user-skipped" : "not-applicable";
923
- if (value.externalOpinionStatus !== expectedStatus) {
924
- context.addIssue({
925
- code: "custom",
926
- message: `fact-only ${value.origin} research requires externalOpinionStatus ${expectedStatus}`,
927
- path: ["externalOpinionStatus"]
928
- });
929
- }
930
- if (Object.values(value.stanceCoverage).some((coverage) => coverage !== "not-applicable")) {
931
- context.addIssue({
932
- code: "custom",
933
- message: "fact-only research must mark stance coverage not-applicable",
934
- path: ["stanceCoverage"]
935
- });
936
- }
937
- return;
938
- }
939
- if (value.externalOpinionStatus !== "covered") {
940
- context.addIssue({
941
- code: "custom",
942
- message: "viewpoint-scan research requires covered external opinions",
943
- path: ["externalOpinionStatus"]
944
- });
945
- }
946
- const opinionSources = value.sources.filter(
947
- (source) => source.type === "public-opinion" && source.verification === "verified"
948
- );
949
- if (opinionSources.length < 3) {
950
- context.addIssue({
951
- code: "custom",
952
- message: "viewpoint-scan research requires at least three verified public opinions",
953
- path: ["sources"]
954
- });
955
- }
956
- for (const stance of ["support", "supplement"]) {
957
- if (value.stanceCoverage[stance] !== "covered" || !opinionSources.some((source) => source.stance === stance)) {
958
- context.addIssue({
959
- code: "custom",
960
- message: `viewpoint-scan research requires covered ${stance} material`,
961
- path: ["stanceCoverage", stance]
962
- });
963
- }
964
- }
965
- const hasOpposition = opinionSources.some((source) => source.stance === "oppose");
966
- if (hasOpposition && value.stanceCoverage.oppose !== "covered" || !hasOpposition && value.stanceCoverage.oppose !== "not-found") {
967
- context.addIssue({
968
- code: "custom",
969
- message: "opposition coverage must be covered or explicitly recorded as not-found",
970
- path: ["stanceCoverage", "oppose"]
971
- });
972
- }
973
- });
974
- var briefStageArtifactFrontmatterSchema = z5.object({
975
- dxc: z5.object({
976
- ...contentStageMetadataBaseShape,
977
- stage: z5.literal("brief")
978
- }).strict(),
979
- origin: z5.enum(["hotspot", "article", "keywords", "intent"]),
980
- selectedAngle: z5.string().trim().min(1).nullable()
981
- }).strict().superRefine((value, context) => {
982
- if (value.dxc.artifactStatus === "complete" && value.selectedAngle === null) {
983
- context.addIssue({
984
- code: "custom",
985
- message: "completed brief requires selectedAngle",
986
- path: ["selectedAngle"]
987
- });
988
- }
989
- });
990
- var outlineStageArtifactFrontmatterSchema = z5.object({
991
- dxc: z5.object({
992
- ...contentStageMetadataBaseShape,
993
- stage: z5.literal("outline")
994
- }).strict(),
995
- primaryEmotion: z5.string().trim().min(1),
996
- structure: z5.string().trim().min(1)
997
- }).strict();
998
- var articleStageArtifactFrontmatterSchema = z5.object({
999
- author: z5.string().trim().min(1),
1000
- commentsEnabled: z5.boolean().optional(),
1001
- coverImage: portableRelativePathSchema.optional(),
1002
- digest: z5.string().trim().min(1).optional(),
1003
- dxc: z5.object({
1004
- ...contentStageMetadataBaseShape,
1005
- quoteSnapshots: z5.array(contentQuoteSnapshotSchema).max(50).default([]),
1006
- stage: z5.literal("article")
1007
- }).strict(),
1008
- dxc_wechat_template_hint: z5.string().trim().min(1).optional(),
1009
- goldenLinesPath: portableRelativePathSchema,
1010
- goldenLinesSha256: z5.string().regex(/^[a-f0-9]{64}$/u),
1011
- tags: z5.array(z5.string().trim().min(1)).default([]),
1012
- title: z5.string().trim().min(1)
1013
- }).strict();
1014
- var goldenLinePurposeSchema = z5.enum([
1015
- "cognitive-compression",
1016
- "emotional-resonance",
1017
- "action-prompt",
1018
- "value-statement"
1019
- ]);
1020
- var goldenLinesSidecarSchema = z5.object({
1021
- lines: z5.array(
1022
- z5.object({
1023
- purpose: goldenLinePurposeSchema,
1024
- section: z5.string().trim().min(1).max(200),
1025
- text: z5.string().trim().min(1).max(500)
1026
- }).strict()
1027
- ).max(12),
1028
- schemaVersion: z5.literal("dxc-golden-lines@1")
1029
- }).strict();
1030
- var titlesStageArtifactFrontmatterSchema = z5.object({
1031
- articleSha256: z5.string().regex(/^[a-f0-9]{64}$/u),
1032
- dxc: z5.object({
1033
- ...contentStageMetadataBaseShape,
1034
- stage: z5.literal("titles")
1035
- }).strict(),
1036
- selectedTitle: z5.string().trim().min(1).refine((value) => [...value].length <= 32, {
1037
- message: "selected title must not exceed 32 Unicode characters"
1038
- }).nullable()
1039
- }).strict().superRefine((value, context) => {
1040
- if (value.dxc.artifactStatus === "complete" && value.selectedTitle === null) {
1041
- context.addIssue({
1042
- code: "custom",
1043
- message: "completed title artifact requires selectedTitle",
1044
- path: ["selectedTitle"]
1045
- });
1046
- }
1047
- });
1048
- var visualStageInlineAssetSchema = z5.object({
1049
- path: portableRelativePathSchema,
1050
- placement: z5.string().trim().min(1).max(200),
1051
- placementAnchor: z5.string().regex(/^after-heading:[^\r\n]{1,160}$/u),
1052
- purpose: z5.string().trim().min(1).max(300),
1053
- sha256: z5.string().regex(/^[a-f0-9]{64}$/u),
1054
- source: z5.enum(["agent-generated", "local-material"])
1055
- }).strict();
1056
- var visualPlanMaterializedArtifactFrontmatterSchema = z5.object({
1057
- assetsDirectory: portableRelativePathSchema,
1058
- coverAsset: portableRelativePathSchema,
1059
- coverSha256: z5.string().regex(/^[a-f0-9]{64}$/u),
1060
- coverSource: z5.enum(["agent-generated", "local-material"]),
1061
- dxc: z5.object({
1062
- ...contentStageMetadataBaseShape,
1063
- stage: z5.literal("visual-plan")
1064
- }).strict(),
1065
- inlineAssets: z5.array(visualStageInlineAssetSchema).max(20),
1066
- inlineImagesSupported: z5.literal(true)
1067
- }).strict();
1068
- var visualGenerationPlannedAssetSchema = z5.object({
1069
- placementAnchor: z5.string().regex(/^after-heading:[^\r\n]{1,160}$/u).optional(),
1070
- purpose: z5.string().trim().min(1).max(300),
1071
- role: z5.enum(["cover", "inline"]),
1072
- source: z5.literal("agent-generated")
1073
- }).strict().superRefine((asset, context) => {
1074
- if (asset.role === "inline" && asset.placementAnchor === void 0) {
1075
- context.addIssue({
1076
- code: "custom",
1077
- message: "inline proposal requires placementAnchor",
1078
- path: ["placementAnchor"]
1079
- });
1080
- }
1081
- if (asset.role === "cover" && asset.placementAnchor !== void 0) {
1082
- context.addIssue({
1083
- code: "custom",
1084
- message: "cover proposal must not have placementAnchor",
1085
- path: ["placementAnchor"]
1086
- });
1087
- }
1088
- });
1089
- var visualGenerationPlanSchema = z5.object({
1090
- chargesQuota: z5.boolean(),
1091
- dataTransit: z5.enum(["local-only", "agent-provider", "dxc-cloud"]),
1092
- executionLocation: z5.enum(["local-device", "agent-hosted"]),
1093
- maxAttempts: z5.number().int().min(1).max(2),
1094
- plannedAssets: z5.array(visualGenerationPlannedAssetSchema).min(1).max(20),
1095
- retryPolicy: z5.enum(["never", "verified-no-asset-no-charge-once"])
1096
- }).strict().superRefine((value, context) => {
1097
- if (value.plannedAssets.filter((asset) => asset.role === "cover").length > 1) {
1098
- context.addIssue({
1099
- code: "custom",
1100
- message: "generation proposal allows at most one generated cover",
1101
- path: ["plannedAssets"]
1102
- });
1103
- }
1104
- if (value.maxAttempts === 1 && value.retryPolicy !== "never" || value.maxAttempts === 2 && value.retryPolicy !== "verified-no-asset-no-charge-once") {
1105
- context.addIssue({
1106
- code: "custom",
1107
- message: "maxAttempts=1 requires retryPolicy=never; maxAttempts=2 requires verified-no-asset-no-charge-once",
1108
- path: ["retryPolicy"]
1109
- });
1110
- }
1111
- });
1112
- var visualPlanGenerationProposalFrontmatterSchema = z5.object({
1113
- assetsDirectory: portableRelativePathSchema,
1114
- dxc: z5.object({
1115
- ...contentStageMetadataBaseShape,
1116
- artifactStatus: z5.literal("awaiting-user"),
1117
- stage: z5.literal("visual-plan")
1118
- }).strict(),
1119
- generation: visualGenerationPlanSchema,
1120
- inlineImagesSupported: z5.literal(true),
1121
- planned: z5.literal(true)
1122
- }).strict();
1123
- var visualPlanStageArtifactFrontmatterSchema = z5.union([
1124
- visualPlanMaterializedArtifactFrontmatterSchema,
1125
- visualPlanGenerationProposalFrontmatterSchema
1126
- ]);
1127
- var qualityReviewStageArtifactFrontmatterSchema = z5.object({
1128
- blockerCount: z5.number().int().nonnegative(),
1129
- dxc: z5.object({
1130
- ...contentStageMetadataBaseShape,
1131
- stage: z5.literal("quality-review")
1132
- }).strict(),
1133
- verdict: z5.enum(["pass", "block"]),
1134
- researchCoverage: z5.enum(["not-applicable", "pass", "warning"]),
1135
- warningCount: z5.number().int().nonnegative()
1136
- }).strict().superRefine((value, context) => {
1137
- if (value.verdict === "pass" && value.blockerCount !== 0) {
1138
- context.addIssue({
1139
- code: "custom",
1140
- message: "passing review must have zero blockers",
1141
- path: ["blockerCount"]
1142
- });
1143
- }
1144
- if (value.verdict === "block" && value.blockerCount === 0) {
1145
- context.addIssue({
1146
- code: "custom",
1147
- message: "blocked review must report at least one blocker",
1148
- path: ["blockerCount"]
1149
- });
1150
- }
1151
- if (value.researchCoverage === "warning" && value.warningCount === 0) {
1152
- context.addIssue({
1153
- code: "custom",
1154
- message: "research coverage warnings must be counted",
1155
- path: ["warningCount"]
1156
- });
1157
- }
1158
- });
1159
- var deliveryStageArtifactFrontmatterSchema = z5.object({
1160
- accountId: z5.uuid(),
1161
- dxc: z5.object({
1162
- ...contentStageMetadataBaseShape,
1163
- stage: z5.literal("delivery")
1164
- }).strict(),
1165
- idempotencyKey: z5.string().trim().min(1).max(200),
1166
- intentId: z5.uuid().nullable(),
1167
- mediaId: z5.string().trim().min(1).max(256).nullable().optional(),
1168
- previewExpiresAt: z5.iso.datetime(),
1169
- previewSelectionRevision: z5.number().int().nonnegative(),
1170
- retryAttempt: z5.number().int().nonnegative().default(0),
1171
- retryOfIntentId: z5.uuid().nullable().optional(),
1172
- rootSnapshotHash: z5.string().regex(/^[a-f0-9]{64}$/u),
1173
- rootSnapshotId: z5.uuid(),
1174
- selectedSnapshotHash: z5.string().regex(/^[a-f0-9]{64}$/u),
1175
- selectedSnapshotId: z5.uuid(),
1176
- state: z5.enum(["previewed", "processing", "completed", "requires-attention", "failed"]),
1177
- templateId: z5.string().regex(/^wechat-[a-z0-9-]+@\d+$/u)
1178
- }).strict().superRefine((value, context) => {
1179
- if (value.dxc.artifactStatus === "complete" && (value.state !== "completed" || value.intentId === null || value.mediaId === void 0 || value.mediaId === null)) {
1180
- context.addIssue({
1181
- code: "custom",
1182
- message: "completed delivery requires completed state, intentId, and mediaId",
1183
- path: ["state"]
1184
- });
1185
- }
1186
- if (value.retryAttempt === 0 && value.retryOfIntentId !== void 0 && value.retryOfIntentId !== null || value.retryAttempt > 0 && (value.retryOfIntentId === void 0 || value.retryOfIntentId === null)) {
1187
- context.addIssue({
1188
- code: "custom",
1189
- message: "retryAttempt and retryOfIntentId must describe the same retry generation",
1190
- path: ["retryOfIntentId"]
1191
- });
1192
- }
1193
- });
1194
- function contentStageArtifactFrontmatterSchema(stage) {
1195
- switch (stage) {
1196
- case "research":
1197
- return researchStageArtifactFrontmatterSchema;
1198
- case "brief":
1199
- return briefStageArtifactFrontmatterSchema;
1200
- case "outline":
1201
- return outlineStageArtifactFrontmatterSchema;
1202
- case "article":
1203
- return articleStageArtifactFrontmatterSchema;
1204
- case "titles":
1205
- return titlesStageArtifactFrontmatterSchema;
1206
- case "visual-plan":
1207
- return visualPlanStageArtifactFrontmatterSchema;
1208
- case "quality-review":
1209
- return qualityReviewStageArtifactFrontmatterSchema;
1210
- case "delivery":
1211
- return deliveryStageArtifactFrontmatterSchema;
1212
- }
1213
- }
1214
- var stepCheckpointStatusSchema = z5.enum([
1215
- "running",
1216
- "awaiting-user",
1217
- "completed",
1218
- "failed",
1219
- "skipped"
1220
- ]);
1221
- var executionLocationSchema = z5.enum(["local-device", "agent-hosted", "unknown"]);
1222
- var dataTransitSchema = z5.enum(["local-only", "agent-provider", "dxc-cloud", "unknown"]);
1223
- var stepConfirmationStatusSchema = z5.enum(["not-required", "pending", "confirmed"]);
1224
- var checkpointArtifactSchema = z5.object({
1225
- bytes: z5.number().int().positive(),
1226
- kind: contentArtifactKindSchema,
1227
- path: portableRelativePathSchema,
1228
- sha256: z5.string().regex(/^[a-f0-9]{64}$/u)
1229
- }).strict();
1230
- var stageArtifactReferenceSchema = z5.object({
1231
- bytes: z5.number().int().positive().optional(),
1232
- kind: contentArtifactKindSchema,
1233
- path: portableRelativePathSchema,
1234
- sha256: z5.string().regex(/^[a-f0-9]{64}$/u).optional()
1235
- }).strict();
1236
- var stepCheckpointMetadataSchema = z5.object({
1237
- summary: z5.string().trim().min(1).max(500)
1238
- }).strict();
1239
- var stepConfirmationBindingSchema = z5.object({
1240
- confirmedAt: z5.iso.datetime().nullable(),
1241
- confirmedBy: z5.string().trim().min(1).max(160).nullable(),
1242
- requestedAt: z5.iso.datetime(),
1243
- snapshotHash: z5.string().regex(/^[a-f0-9]{64}$/u),
1244
- snapshotType: z5.enum(["stage-artifact", "render-snapshot"]),
1245
- status: z5.enum(["pending", "confirmed"])
1246
- }).strict().superRefine((binding, context) => {
1247
- if (binding.status === "confirmed" && (binding.confirmedAt === null || binding.confirmedBy === null)) {
1248
- context.addIssue({
1249
- code: "custom",
1250
- message: "confirmed binding requires confirmation actor and time"
1251
- });
1252
- }
1253
- if (binding.status === "pending" && (binding.confirmedAt !== null || binding.confirmedBy !== null)) {
1254
- context.addIssue({
1255
- code: "custom",
1256
- message: "pending binding must not include confirmation actor or time"
1257
- });
1258
- }
1259
- });
1260
- var externalActionAuthorizationSchema = z5.object({
1261
- action: z5.literal("image-generation"),
1262
- confirmedAt: z5.iso.datetime(),
1263
- confirmedBy: z5.string().trim().min(1).max(160),
1264
- planSnapshotHash: z5.string().regex(/^[a-f0-9]{64}$/u),
1265
- plan: visualGenerationPlanSchema,
1266
- requestedAt: z5.iso.datetime()
1267
- }).strict();
1268
- var stepCheckpointBaseShape = {
1269
- artifact: checkpointArtifactSchema.optional(),
1270
- completedAt: z5.iso.datetime().optional(),
1271
- confirmation: stepConfirmationStatusSchema,
1272
- errorCode: z5.string().regex(/^[A-Z][A-Z0-9_]{2,63}$/u).optional(),
1273
- execution: z5.object({
1274
- dataTransit: dataTransitSchema,
1275
- location: executionLocationSchema
1276
- }).strict(),
1277
- projectId: z5.uuid(),
1278
- revision: z5.number().int().positive(),
1279
- skill: z5.object({
1280
- name: z5.string().regex(/^dxc-[a-z0-9]+(?:-[a-z0-9]+)*$/u),
1281
- version: z5.union([z5.string().regex(/^\d+\.\d+\.\d+$/u), z5.literal("unknown")])
1282
- }).strict(),
1283
- stage: contentArtifactKindSchema,
1284
- startedAt: z5.iso.datetime(),
1285
- status: stepCheckpointStatusSchema,
1286
- updatedAt: z5.iso.datetime(),
1287
- workflowId: z5.literal(CONTENT_WORKFLOW_ID)
1288
- };
1289
- var stepCheckpointSchema = z5.discriminatedUnion("checkpointVersion", [
1290
- z5.object({
1291
- ...stepCheckpointBaseShape,
1292
- checkpointVersion: z5.literal("1")
1293
- }).strict(),
1294
- z5.object({
1295
- ...stepCheckpointBaseShape,
1296
- checkpointVersion: z5.literal("2"),
1297
- inputs: z5.array(stageArtifactReferenceSchema).max(CONTENT_ARTIFACT_KINDS.length),
1298
- metadata: stepCheckpointMetadataSchema,
1299
- outputs: z5.array(stageArtifactReferenceSchema).min(1).max(CONTENT_ARTIFACT_KINDS.length),
1300
- waitingFor: z5.string().trim().min(1).max(500).nullable()
1301
- }).strict(),
1302
- z5.object({
1303
- ...stepCheckpointBaseShape,
1304
- checkpointVersion: z5.literal("3"),
1305
- confirmationBinding: stepConfirmationBindingSchema.nullable(),
1306
- inputs: z5.array(stageArtifactReferenceSchema).max(CONTENT_ARTIFACT_KINDS.length),
1307
- metadata: stepCheckpointMetadataSchema,
1308
- outputs: z5.array(stageArtifactReferenceSchema).min(1).max(CONTENT_ARTIFACT_KINDS.length),
1309
- waitingFor: z5.string().trim().min(1).max(500).nullable()
1310
- }).strict(),
1311
- z5.object({
1312
- ...stepCheckpointBaseShape,
1313
- authorizations: z5.array(externalActionAuthorizationSchema).max(20),
1314
- checkpointVersion: z5.literal("4"),
1315
- confirmationBinding: stepConfirmationBindingSchema.nullable(),
1316
- confirmationPurpose: z5.enum(["external-action", "stage-completion"]).nullable(),
1317
- inputs: z5.array(stageArtifactReferenceSchema).max(CONTENT_ARTIFACT_KINDS.length),
1318
- metadata: stepCheckpointMetadataSchema,
1319
- outputs: z5.array(stageArtifactReferenceSchema).min(1).max(CONTENT_ARTIFACT_KINDS.length),
1320
- waitingFor: z5.string().trim().min(1).max(500).nullable()
1321
- }).strict()
1322
- ]).superRefine((checkpoint, context) => {
1323
- if (checkpoint.artifact !== void 0 && checkpoint.artifact.kind !== checkpoint.stage) {
1324
- context.addIssue({
1325
- code: "custom",
1326
- message: "checkpoint artifact kind must match its stage"
1327
- });
1328
- }
1329
- if ((checkpoint.status === "awaiting-user" || checkpoint.status === "completed") && checkpoint.artifact === void 0) {
1330
- context.addIssue({
1331
- code: "custom",
1332
- message: "awaiting-user and completed checkpoints require an artifact"
1333
- });
1334
- }
1335
- if (checkpoint.artifact !== void 0 && checkpoint.status !== "awaiting-user" && checkpoint.status !== "completed" && !(checkpoint.checkpointVersion === "4" && checkpoint.status === "running" && checkpoint.stage === "visual-plan" && checkpoint.authorizations.length > 0)) {
1336
- context.addIssue({
1337
- code: "custom",
1338
- message: "only awaiting-user and completed checkpoints may bind an artifact"
1339
- });
1340
- }
1341
- if (checkpoint.status === "awaiting-user" && checkpoint.confirmation !== "pending") {
1342
- context.addIssue({
1343
- code: "custom",
1344
- message: "awaiting-user checkpoints require pending confirmation"
1345
- });
1346
- }
1347
- if (checkpoint.confirmation === "pending" && checkpoint.status !== "awaiting-user") {
1348
- context.addIssue({
1349
- code: "custom",
1350
- message: "pending confirmation is only valid while awaiting the user"
1351
- });
1352
- }
1353
- if (checkpoint.status === "completed" && (checkpoint.completedAt === void 0 || checkpoint.checkpointVersion === "1" && checkpoint.confirmation !== "confirmed")) {
1354
- context.addIssue({
1355
- code: "custom",
1356
- message: "completed checkpoint is missing required completion metadata"
1357
- });
1358
- }
1359
- if ((checkpoint.status === "failed" || checkpoint.status === "skipped") && checkpoint.completedAt === void 0) {
1360
- context.addIssue({
1361
- code: "custom",
1362
- message: "terminal checkpoints require completion time"
1363
- });
1364
- }
1365
- if (checkpoint.status !== "completed" && checkpoint.status !== "failed" && checkpoint.status !== "skipped" && checkpoint.completedAt !== void 0) {
1366
- context.addIssue({
1367
- code: "custom",
1368
- message: "non-terminal checkpoints must not include completion time"
1369
- });
1370
- }
1371
- if (checkpoint.status === "failed" && checkpoint.errorCode === void 0) {
1372
- context.addIssue({
1373
- code: "custom",
1374
- message: "failed checkpoints require an error code"
1375
- });
1376
- }
1377
- if (checkpoint.status !== "failed" && checkpoint.errorCode !== void 0) {
1378
- context.addIssue({
1379
- code: "custom",
1380
- message: "only failed checkpoints may include an error code"
1381
- });
1382
- }
1383
- if (checkpoint.confirmation === "confirmed" && checkpoint.status !== "completed") {
1384
- context.addIssue({
1385
- code: "custom",
1386
- message: "confirmed checkpoints must be completed"
1387
- });
1388
- }
1389
- if (checkpoint.checkpointVersion === "3" || checkpoint.checkpointVersion === "4") {
1390
- if (checkpoint.confirmation === "pending" && checkpoint.confirmationBinding?.status !== "pending") {
1391
- context.addIssue({
1392
- code: "custom",
1393
- message: "pending confirmation must bind the reviewed snapshot"
1394
- });
1395
- }
1396
- if (checkpoint.confirmation === "confirmed" && checkpoint.confirmationBinding?.status !== "confirmed") {
1397
- context.addIssue({
1398
- code: "custom",
1399
- message: "confirmed checkpoint must bind actor, time, and snapshot"
1400
- });
1401
- }
1402
- if (checkpoint.confirmation === "not-required" && checkpoint.confirmationBinding !== null) {
1403
- context.addIssue({
1404
- code: "custom",
1405
- message: "confirmation binding is only valid for confirmation checkpoints"
1406
- });
1407
- }
1408
- }
1409
- if (checkpoint.checkpointVersion === "4") {
1410
- if (checkpoint.authorizations.length > 0 && checkpoint.stage !== "visual-plan") {
1411
- context.addIssue({
1412
- code: "custom",
1413
- message: "image generation authorizations are only valid for visual-plan"
1414
- });
1415
- }
1416
- if (checkpoint.stage === "visual-plan" && checkpoint.status === "running" && checkpoint.authorizations.length > 0 && checkpoint.artifact === void 0) {
1417
- context.addIssue({
1418
- code: "custom",
1419
- message: "authorized visual-plan running checkpoint must bind its proposal artifact"
1420
- });
1421
- }
1422
- if (checkpoint.confirmationBinding === null && checkpoint.confirmationPurpose !== null) {
1423
- context.addIssue({
1424
- code: "custom",
1425
- message: "confirmation purpose requires a confirmation binding"
1426
- });
1427
- }
1428
- if (checkpoint.confirmationBinding !== null && checkpoint.confirmationPurpose === null) {
1429
- context.addIssue({
1430
- code: "custom",
1431
- message: "confirmation binding requires a confirmation purpose"
1432
- });
1433
- }
1434
- if (checkpoint.confirmationPurpose === "external-action" && (checkpoint.stage !== "visual-plan" || checkpoint.status !== "awaiting-user" || checkpoint.confirmation !== "pending")) {
1435
- context.addIssue({
1436
- code: "custom",
1437
- message: "external-action confirmation is only valid for a pending visual plan"
1438
- });
1439
- }
1440
- }
1441
- });
1442
- var stepCheckpointInspectionSchema = z5.discriminatedUnion("state", [
1443
- z5.object({
1444
- path: portableRelativePathSchema,
1445
- stage: contentArtifactKindSchema,
1446
- state: z5.literal("missing")
1447
- }).strict(),
1448
- z5.object({
1449
- checkpoint: stepCheckpointSchema,
1450
- path: portableRelativePathSchema,
1451
- stage: contentArtifactKindSchema,
1452
- state: z5.literal("valid")
1453
- }).strict(),
1454
- z5.object({
1455
- checkpoint: stepCheckpointSchema,
1456
- path: portableRelativePathSchema,
1457
- reason: z5.enum([
1458
- "artifact-changed",
1459
- "artifact-empty",
1460
- "artifact-missing",
1461
- "input-artifact-changed",
1462
- "input-artifact-empty",
1463
- "input-artifact-missing"
1464
- ]),
1465
- stage: contentArtifactKindSchema,
1466
- state: z5.literal("stale")
1467
- }).strict()
1468
- ]);
1469
- var contentProjectInitResultSchema = z5.object({
1470
- command: z5.literal("project.init"),
1471
- data: z5.object({
1472
- assetsDirectory: portableRelativePathSchema,
1473
- checkpointsDirectory: portableRelativePathSchema,
1474
- knowledgeBootstrap: z5.object({
1475
- articleCount: z5.number().int().nonnegative(),
1476
- recommendedCommand: z5.string().trim().min(1),
1477
- status: z5.enum(["ready", "import-recommended"])
1478
- }).strict(),
1479
- manifest: contentProjectManifestSchema,
1480
- manifestPath: z5.literal("dxc.project.json")
1481
- }).strict(),
1482
- ok: z5.literal(true)
1483
- }).strict();
1484
- var contentProjectStatusResultSchema = z5.object({
1485
- command: z5.literal("project.status"),
1486
- data: z5.object({
1487
- artifacts: z5.array(contentProjectArtifactStatusSchema).length(CONTENT_ARTIFACT_KINDS.length),
1488
- assetsDirectory: portableRelativePathSchema,
1489
- assetsDirectoryReady: z5.boolean(),
1490
- checkpoints: z5.array(stepCheckpointInspectionSchema).length(CONTENT_ARTIFACT_KINDS.length),
1491
- checkpointsDirectory: portableRelativePathSchema,
1492
- manifest: contentProjectManifestSchema,
1493
- manifestPath: z5.literal("dxc.project.json"),
1494
- nextStage: contentArtifactKindSchema.nullable(),
1495
- recoveryPlan: z5.array(
1496
- z5.object({
1497
- action: z5.literal("rerun-stage"),
1498
- command: z5.string().trim().min(1).max(500),
1499
- reason: z5.enum([
1500
- "artifact-changed",
1501
- "artifact-empty",
1502
- "artifact-missing",
1503
- "input-artifact-changed",
1504
- "input-artifact-empty",
1505
- "input-artifact-missing"
1506
- ]),
1507
- stage: contentArtifactKindSchema
1508
- }).strict()
1509
- ),
1510
- workflowStatus: z5.enum([
1511
- "not-started",
1512
- "in-progress",
1513
- "waiting-user",
1514
- "blocked",
1515
- "complete"
1516
- ])
1517
- }).strict(),
1518
- ok: z5.literal(true)
1519
- }).strict();
1520
- var contentProjectIndexEntrySchema = z5.object({
1521
- directory: z5.string().trim().min(1).max(4096),
1522
- projectId: z5.uuid(),
1523
- title: z5.string().trim().min(1).max(160),
1524
- updatedAt: z5.iso.datetime()
1525
- }).strict();
1526
- var contentProjectIndexSchema = z5.object({
1527
- projects: z5.array(contentProjectIndexEntrySchema).max(1e3),
1528
- schemaVersion: z5.literal("1")
1529
- }).strict();
1530
- var contentProjectResolutionSchema = contentProjectIndexEntrySchema.extend({
1531
- nextStage: contentArtifactKindSchema.nullable(),
1532
- workflowStatus: z5.enum(["not-started", "in-progress", "waiting-user", "blocked", "complete"])
1533
- }).strict();
1534
- var contentProjectResolveResultSchema = z5.object({
1535
- command: z5.literal("project.resolve"),
1536
- data: z5.object({
1537
- match: z5.enum(["none", "single", "multiple"]),
1538
- projects: z5.array(contentProjectResolutionSchema).max(1e3),
1539
- query: z5.string().trim().min(1).max(160).nullable()
1540
- }).strict(),
1541
- ok: z5.literal(true)
1542
- }).strict();
1543
- var contentProjectCheckpointResultSchema = z5.object({
1544
- command: z5.literal("project.checkpoint"),
1545
- data: z5.object({
1546
- artifactMutations: z5.array(
1547
- z5.object({
1548
- afterSha256: z5.string().regex(/^[a-f0-9]{64}$/u),
1549
- beforeSha256: z5.string().regex(/^[a-f0-9]{64}$/u).nullable(),
1550
- path: portableRelativePathSchema
1551
- }).strict()
1552
- ),
1553
- checkpoint: stepCheckpointSchema,
1554
- checkpointPath: portableRelativePathSchema,
1555
- guidance: z5.object({
1556
- action: z5.enum(["authorize-external-action", "confirm-stage"]),
1557
- message: z5.string().trim().min(1).max(500),
1558
- suggestedFlag: z5.literal("--confirm")
1559
- }).strict().nullable()
1560
- }).strict(),
1561
- ok: z5.literal(true)
1562
- }).strict();
1563
- var contentProjectCommandSchema = z5.enum([
1564
- "project.init",
1565
- "project.resolve",
1566
- "project.status",
1567
- "project.checkpoint",
1568
- "project.preview"
1569
- ]);
1570
- var contentProjectErrorResultSchema = z5.object({
1571
- command: contentProjectCommandSchema,
1572
- error: z5.object({
1573
- code: z5.enum([
1574
- "DXC_PROJECT_EXISTS",
1575
- "DXC_PROJECT_INVALID",
1576
- "DXC_PROJECT_IO_FAILED",
1577
- "DXC_PROJECT_NOT_FOUND",
1578
- "DXC_PROJECT_STAGE_INVALID"
1579
- ]),
1580
- fields: z5.array(z5.string().trim().min(1).max(200)).max(20).optional(),
1581
- message: z5.string().trim().min(1),
1582
- reason: z5.string().regex(/^[A-Z][A-Z0-9_]{2,63}$/u).optional(),
1583
- recovery: z5.string().trim().min(1).max(500).optional(),
1584
- stage: contentArtifactKindSchema.optional()
1585
- }).strict(),
1586
- ok: z5.literal(false)
1587
- }).strict();
1588
- var contentProfileAnswerSchema = z5.object({
1589
- note: z5.string().trim().max(500).optional(),
1590
- questionId: z5.string().regex(/^[a-z][a-z0-9.-]{1,63}$/u),
1591
- selectedOptionIds: z5.array(z5.string().regex(/^[a-z][a-z0-9.-]{1,63}$/u)).min(1).max(8)
1592
- }).strict().superRefine((answer, context) => {
1593
- if (new Set(answer.selectedOptionIds).size !== answer.selectedOptionIds.length) {
1594
- context.addIssue({
1595
- code: "custom",
1596
- message: "selected options must be unique"
1597
- });
1598
- }
1599
- });
1600
- var contentProfileUserMemorySchema = z5.object({
1601
- confirmationPolicy: z5.enum(["guided", "review-every-stage", "auto-until-delivery"]).optional(),
1602
- contentValuePromise: z5.string().trim().min(1).max(500),
1603
- coreValues: z5.string().trim().min(1).max(500).optional(),
1604
- creatorRole: z5.string().trim().min(1).max(120),
1605
- displayName: z5.string().trim().min(1).max(120),
1606
- historyDirectory: z5.string().trim().min(1).max(4096).optional(),
1607
- penName: z5.string().trim().min(1).max(120).optional(),
1608
- pointOfView: z5.string().trim().min(1).max(120).optional(),
1609
- primaryDomains: z5.array(z5.string().trim().min(1).max(120)).min(1).max(5),
1610
- primaryPlatform: z5.literal("wechat-official-account"),
1611
- publishingCadence: z5.string().trim().min(1).max(120).optional(),
1612
- redLines: z5.string().trim().min(1).max(500).optional(),
1613
- targetAudience: z5.string().trim().min(1).max(500),
1614
- titlePreferences: z5.string().trim().min(1).max(500).optional(),
1615
- visualPreferences: z5.string().trim().min(1).max(500).optional(),
1616
- visualGenerationAuthorization: z5.object({
1617
- maxImagesPerRun: z5.number().int().min(1).max(20),
1618
- mode: z5.literal("auto-within-limit")
1619
- }).strict().optional(),
1620
- writingVoice: z5.string().trim().min(1).max(500).optional()
1621
- }).strict().superRefine((user, context) => {
1622
- if (user.primaryDomains !== void 0 && new Set(user.primaryDomains).size !== user.primaryDomains.length) {
1623
- context.addIssue({
1624
- code: "custom",
1625
- message: "primary domains must be unique",
1626
- path: ["primaryDomains"]
1627
- });
1628
- }
1629
- });
1630
- var contentProfileInputSchema = z5.object({
1631
- answers: z5.array(contentProfileAnswerSchema).max(32).default([]),
1632
- questionnaireVersion: z5.literal(CONTENT_PROFILE_QUESTIONNAIRE_VERSION),
1633
- user: contentProfileUserMemorySchema
1634
- }).strict().superRefine((input, context) => {
1635
- const questionIds = input.answers.map((answer) => answer.questionId);
1636
- if (new Set(questionIds).size !== questionIds.length) {
1637
- context.addIssue({
1638
- code: "custom",
1639
- message: "profile answers must use unique question IDs"
1640
- });
1641
- }
1642
- });
1643
- var { primaryPlatform: ignoredProfileUpdatePrimaryPlatform, ...contentProfileUpdateUserShape } = contentProfileUserMemorySchema.shape;
1644
- var contentProfileUpdateInputSchema = z5.object({
1645
- answers: z5.array(contentProfileAnswerSchema).min(1).max(32).optional(),
1646
- user: z5.object(contentProfileUpdateUserShape).partial().optional()
1647
- }).strict().superRefine((input, context) => {
1648
- if (input.answers === void 0 && input.user === void 0) {
1649
- context.addIssue({
1650
- code: "custom",
1651
- message: "profile update must include answers or user fields"
1652
- });
1653
- }
1654
- if (input.answers === void 0) {
1655
- return;
1656
- }
1657
- const questionIds = input.answers.map((answer) => answer.questionId);
1658
- if (new Set(questionIds).size !== questionIds.length) {
1659
- context.addIssue({
1660
- code: "custom",
1661
- message: "profile answers must use unique question IDs",
1662
- path: ["answers"]
1663
- });
1664
- }
1665
- });
1666
- var contentProfileSchema = contentProfileInputSchema.extend({
1667
- createdAt: z5.iso.datetime(),
1668
- profileId: z5.uuid(),
1669
- schemaVersion: z5.literal("1"),
1670
- updatedAt: z5.iso.datetime()
1671
- }).strict();
1672
- var contentProfileSaveResultSchema = z5.object({
1673
- command: z5.literal("profile.save"),
1674
- data: z5.object({
1675
- profile: contentProfileSchema,
1676
- profilePath: z5.literal("~/.dxc/content-profile.json"),
1677
- userMemoryPath: z5.literal("~/.dxc/USER.md")
1678
- }).strict(),
1679
- ok: z5.literal(true)
1680
- }).strict();
1681
- var contentProfileUpdateResultSchema = contentProfileSaveResultSchema.extend({
1682
- command: z5.literal("profile.update")
1683
- });
1684
- var contentProfileStatusResultSchema = z5.object({
1685
- command: z5.literal("profile.status"),
1686
- data: z5.discriminatedUnion("configured", [
1687
- z5.object({
1688
- configured: z5.literal(false),
1689
- profilePath: z5.literal("~/.dxc/content-profile.json"),
1690
- userMemoryPath: z5.literal("~/.dxc/USER.md")
1691
- }).strict(),
1692
- z5.object({
1693
- configured: z5.literal(true),
1694
- profile: contentProfileSchema,
1695
- profilePath: z5.literal("~/.dxc/content-profile.json"),
1696
- userMemoryPath: z5.literal("~/.dxc/USER.md")
1697
- }).strict()
1698
- ]),
1699
- ok: z5.literal(true)
1700
- }).strict();
1701
- var contentProfileCommandSchema = z5.enum([
1702
- "profile.save",
1703
- "profile.status",
1704
- "profile.update"
1705
- ]);
1706
- var CONTENT_MEMORY_KINDS = [
1707
- "audience-change",
1708
- "brand-context",
1709
- "business-context",
1710
- "temporary-campaign",
1711
- "writing-preference"
1712
- ];
1713
- var contentMemoryKindSchema = z5.enum(CONTENT_MEMORY_KINDS);
1714
- var contentMemoryScopeSchema = z5.enum(["global", "project"]);
1715
- var contentMemoryInputSchema = z5.object({
1716
- content: z5.string().trim().min(1).max(500),
1717
- expiresAt: z5.iso.datetime().optional(),
1718
- kind: contentMemoryKindSchema,
1719
- scope: contentMemoryScopeSchema
1720
- }).strict().superRefine((input, context) => {
1721
- if (input.kind === "temporary-campaign" && input.expiresAt === void 0) {
1722
- context.addIssue({
1723
- code: "custom",
1724
- message: "temporary campaign memory requires an expiry time",
1725
- path: ["expiresAt"]
1726
- });
1727
- }
1728
- });
1729
- var contentMemoryRecordSchema = contentMemoryInputSchema.extend({
1730
- createdAt: z5.iso.datetime(),
1731
- id: z5.uuid(),
1732
- source: z5.literal("user-stated"),
1733
- status: z5.enum(["active", "archived", "expired"]),
1734
- updatedAt: z5.iso.datetime()
1735
- });
1736
- var contentMemoryStoreSchema = z5.object({
1737
- memories: z5.array(contentMemoryRecordSchema).max(100),
1738
- schemaVersion: z5.literal("1")
1739
- }).strict();
1740
- var contentMemoryResultDataSchema = z5.object({
1741
- memories: z5.array(contentMemoryRecordSchema),
1742
- memoryPath: z5.literal("~/.dxc/content-memory.json")
1743
- }).strict();
1744
- var contentMemoryAddResultSchema = z5.object({
1745
- command: z5.literal("memory.add"),
1746
- data: contentMemoryResultDataSchema.extend({ memory: contentMemoryRecordSchema }),
1747
- ok: z5.literal(true)
1748
- }).strict();
1749
- var contentMemoryArchiveResultSchema = z5.object({
1750
- command: z5.literal("memory.archive"),
1751
- data: contentMemoryResultDataSchema.extend({ memory: contentMemoryRecordSchema }),
1752
- ok: z5.literal(true)
1753
- }).strict();
1754
- var contentMemoryListResultSchema = z5.object({
1755
- command: z5.literal("memory.list"),
1756
- data: contentMemoryResultDataSchema,
1757
- ok: z5.literal(true)
1758
- }).strict();
1759
- var contentMemoryCommandSchema = z5.enum(["memory.add", "memory.archive", "memory.list"]);
1760
- var contentMemoryErrorResultSchema = z5.object({
1761
- command: contentMemoryCommandSchema,
1762
- error: z5.object({
1763
- code: z5.enum([
1764
- "DXC_MEMORY_INPUT_INVALID",
1765
- "DXC_MEMORY_INVALID",
1766
- "DXC_MEMORY_IO_FAILED",
1767
- "DXC_MEMORY_NOT_FOUND"
1768
- ]),
1769
- message: z5.string().trim().min(1)
1770
- }).strict(),
1771
- ok: z5.literal(false)
1772
- }).strict();
1773
- var contentProfileErrorResultSchema = z5.object({
1774
- command: contentProfileCommandSchema,
1775
- error: z5.object({
1776
- code: z5.enum(["DXC_PROFILE_INPUT_INVALID", "DXC_PROFILE_INVALID", "DXC_PROFILE_IO_FAILED"]),
1777
- fields: z5.array(z5.string().trim().min(1)).optional(),
1778
- hint: z5.string().trim().min(1).optional(),
1779
- message: z5.string().trim().min(1)
1780
- }).strict(),
1781
- ok: z5.literal(false)
1782
- }).strict();
1783
- var dxcSkillLifecycleSchema = z5.enum(["available", "planned"]);
1784
- var dxcSkillExecutionSchema = z5.enum(["agent", "agent-cli", "agent-cli-cloud"]);
1785
- var dxcSkillImplementationLevelSchema = z5.enum([
1786
- "agent-guided",
1787
- "agent-local-tools",
1788
- "local-cloud-end-to-end"
1789
- ]);
1790
- var dxcSkillVerificationLevelSchema = z5.enum([
1791
- "contract-tested",
1792
- "local-integration-tested",
1793
- "real-platform-smoke"
1794
- ]);
1795
- var dxcContentSkillDescriptorSchema = z5.object({
1796
- description: z5.string().trim().min(1).max(300),
1797
- execution: dxcSkillExecutionSchema,
1798
- implementationLevel: dxcSkillImplementationLevelSchema,
1799
- inputArtifacts: z5.array(contentArtifactKindSchema),
1800
- knownGaps: z5.array(z5.string().trim().min(1).max(300)).max(10),
1801
- name: z5.string().regex(/^dxc-[a-z0-9]+(?:-[a-z0-9]+)*$/u),
1802
- optionalInputArtifacts: z5.array(contentArtifactKindSchema).default([]),
1803
- outputArtifacts: z5.array(contentArtifactKindSchema).min(1),
1804
- requiresHumanConfirmation: z5.boolean(),
1805
- stage: contentArtifactKindSchema,
1806
- status: dxcSkillLifecycleSchema,
1807
- verificationLevel: dxcSkillVerificationLevelSchema,
1808
- version: z5.string().regex(/^\d+\.\d+\.\d+$/u).nullable()
1809
- }).strict().superRefine((descriptor, context) => {
1810
- if (descriptor.status === "available" && descriptor.version === null) {
1811
- context.addIssue({
1812
- code: "custom",
1813
- message: "available skills must declare a version"
1814
- });
1815
- }
1816
- if (descriptor.status === "planned" && descriptor.version !== null) {
1817
- context.addIssue({
1818
- code: "custom",
1819
- message: "planned skills must not declare a released version"
1820
- });
1821
- }
1822
- if (!descriptor.outputArtifacts.includes(descriptor.stage)) {
1823
- context.addIssue({
1824
- code: "custom",
1825
- message: "skill output artifacts must include its workflow stage"
1826
- });
1827
- }
1828
- if (new Set(descriptor.inputArtifacts).size !== descriptor.inputArtifacts.length) {
1829
- context.addIssue({
1830
- code: "custom",
1831
- message: "input artifacts must be unique"
1832
- });
1833
- }
1834
- if (new Set(descriptor.optionalInputArtifacts).size !== descriptor.optionalInputArtifacts.length) {
1835
- context.addIssue({
1836
- code: "custom",
1837
- message: "optional input artifacts must be unique"
1838
- });
1839
- }
1840
- if (descriptor.optionalInputArtifacts.some(
1841
- (artifact) => descriptor.inputArtifacts.includes(artifact)
1842
- )) {
1843
- context.addIssue({
1844
- code: "custom",
1845
- message: "required and optional input artifacts must not overlap"
1846
- });
1847
- }
1848
- if (new Set(descriptor.outputArtifacts).size !== descriptor.outputArtifacts.length) {
1849
- context.addIssue({
1850
- code: "custom",
1851
- message: "output artifacts must be unique"
1852
- });
1853
- }
1854
- });
1855
- var dxcSkillCatalogSchema = z5.object({
1856
- orchestrator: z5.object({
1857
- name: z5.literal("dxc-content-workflow"),
1858
- status: z5.literal("available"),
1859
- version: z5.string().regex(/^\d+\.\d+\.\d+$/u)
1860
- }).strict(),
1861
- schemaVersion: z5.literal("1"),
1862
- steps: z5.array(dxcContentSkillDescriptorSchema).length(CONTENT_ARTIFACT_KINDS.length),
1863
- workflowId: z5.literal(CONTENT_WORKFLOW_ID)
1864
- }).strict().superRefine((catalog, context) => {
1865
- const names = catalog.steps.map((step) => step.name);
1866
- if (new Set(names).size !== names.length) {
1867
- context.addIssue({
1868
- code: "custom",
1869
- message: "skill names must be unique"
1870
- });
1871
- }
1872
- const stages = catalog.steps.map((step) => step.stage);
1873
- if (new Set(stages).size !== CONTENT_ARTIFACT_KINDS.length || !CONTENT_ARTIFACT_KINDS.every((kind) => stages.includes(kind))) {
1874
- context.addIssue({
1875
- code: "custom",
1876
- message: "catalog must define exactly one skill for every workflow stage"
1877
- });
1878
- }
1879
- });
1880
-
1881
- // packages/contracts/src/index.ts
1882
- var PROTOCOL_VERSION = "1";
1883
- var liveHealthResponseSchema = z6.object({
1884
- status: z6.literal("ok")
1885
- }).strict();
1886
- var readyHealthResponseSchema = z6.object({
1887
- status: z6.literal("ready"),
1888
- checks: z6.object({
1889
- configuration: z6.literal("ok")
1890
- }).strict()
1891
- }).strict();
1892
- var versionResultSchema = z6.object({
1893
- ok: z6.literal(true),
1894
- command: z6.literal("version"),
1895
- data: z6.object({
1896
- cliVersion: z6.string().min(1),
1897
- nodeVersion: z6.string().min(1),
1898
- protocolVersion: z6.string().min(1)
1899
- }).strict()
1900
- }).strict();
1901
- var doctorCheckSchema = z6.object({
1902
- name: z6.enum(["node-runtime", "working-directory"]),
1903
- status: z6.enum(["ok", "error"]),
1904
- message: z6.string().min(1)
1905
- }).strict();
1906
- var doctorResultSchema = z6.object({
1907
- ok: z6.boolean(),
1908
- command: z6.literal("doctor"),
1909
- data: z6.object({
1910
- status: z6.enum(["ok", "error"]),
1911
- checks: z6.array(doctorCheckSchema)
1912
- }).strict()
1913
- }).strict();
1914
- var articleAssetSchema = z6.object({
1915
- logicalPath: z6.string().trim().min(1),
1916
- role: z6.enum(["cover", "inline"])
1917
- }).strict();
1918
- var articleBundleSchema = z6.object({
1919
- schemaVersion: z6.literal("1"),
1920
- title: z6.string().trim().min(1),
1921
- author: z6.string().trim().min(1),
1922
- digest: z6.string().trim().min(1),
1923
- templateHint: wechatTemplateIdSchema.optional(),
1924
- coverImage: z6.string().trim().min(1).optional(),
1925
- commentsEnabled: z6.boolean(),
1926
- tags: z6.array(z6.string().trim().min(1)),
1927
- markdown: z6.string().trim().min(1),
1928
- assets: z6.array(articleAssetSchema)
1929
- }).strict();
1930
- var preflightIssueSchema = z6.object({
1931
- code: z6.string().trim().min(1),
1932
- path: z6.string().trim().min(1).optional(),
1933
- message: z6.string().trim().min(1)
1934
- }).strict();
1935
- var preflightResultSchema = z6.object({
1936
- ok: z6.boolean(),
1937
- errors: z6.array(preflightIssueSchema),
1938
- warnings: z6.array(preflightIssueSchema),
1939
- metrics: z6.object({
1940
- digestCharacters: z6.number().int().nonnegative(),
1941
- htmlCharacters: z6.number().int().nonnegative(),
1942
- imageCount: z6.number().int().nonnegative(),
1943
- externalLinkCount: z6.number().int().nonnegative(),
1944
- tableCount: z6.number().int().nonnegative()
1945
- }).strict()
1946
- }).strict();
1947
- var wechatRenderResultSchema = z6.object({
1948
- templateId: wechatTemplateIdSchema,
1949
- rendererVersion: z6.string().trim().min(1),
1950
- sourceHash: z6.string().regex(/^[a-f0-9]{64}$/u),
1951
- htmlHash: z6.string().regex(/^[a-f0-9]{64}$/u),
1952
- html: z6.string().min(1),
1953
- preflight: preflightResultSchema
1954
- }).strict();
1955
- var wechatPermissionIdSchema = z6.union([z6.literal(3), z6.literal(11)]);
1956
- var deviceBindingSessionStatusSchema = z6.enum([
1957
- "CREATED",
1958
- "PROVED",
1959
- "AUTHORIZATION_PENDING",
1960
- "BOUND",
1961
- "EXPIRED",
1962
- "FAILED"
1963
- ]);
1964
- var createDeviceBindingSessionRequestSchema = z6.object({
1965
- deviceName: z6.string().trim().min(1).max(80),
1966
- installationId: z6.uuid(),
1967
- publicKeyPem: z6.string().min(80).max(2048)
1968
- }).strict();
1969
- var createDeviceBindingSessionResponseSchema = z6.object({
1970
- challenge: z6.string().regex(/^[A-Za-z0-9_-]{43,128}$/u),
1971
- expiresAt: z6.iso.datetime(),
1972
- id: z6.uuid()
1973
- }).strict();
1974
- var proveDeviceBindingSessionRequestSchema = z6.object({
1975
- challenge: z6.string().regex(/^[A-Za-z0-9_-]{43,128}$/u),
1976
- deviceRefreshTokenHash: z6.string().regex(/^[a-f0-9]{64}$/u).optional(),
1977
- deviceSessionTokenHash: z6.string().regex(/^[a-f0-9]{64}$/u),
1978
- signature: z6.string().regex(/^[A-Za-z0-9_-]{64,256}$/u)
1979
- }).strict();
1980
- var proveDeviceBindingSessionResponseSchema = z6.object({
1981
- bindingToken: z6.string().min(32).max(256),
1982
- expiresAt: z6.iso.datetime(),
1983
- id: z6.uuid(),
1984
- status: z6.literal("PROVED")
1985
- }).strict();
1986
- var deviceSessionIdentitySchema = z6.object({
1987
- deviceId: z6.uuid(),
1988
- deviceName: z6.string().trim().min(1).max(80),
1989
- expiresAt: z6.iso.datetime(),
1990
- tenantId: z6.uuid(),
1991
- userId: z6.uuid()
1992
- }).strict();
1993
- var deviceSessionStatusResponseSchema = z6.object({
1994
- identity: deviceSessionIdentitySchema
1995
- }).strict();
1996
- var deviceSessionCredentialEnrollmentRequestSchema = z6.object({
1997
- refreshTokenHash: z6.string().regex(/^[a-f0-9]{64}$/u),
1998
- signature: z6.string().regex(/^[A-Za-z0-9_-]{64,256}$/u)
1999
- }).strict();
2000
- var deviceSessionRefreshRequestSchema = z6.object({
2001
- nextDeviceSessionTokenHash: z6.string().regex(/^[a-f0-9]{64}$/u),
2002
- nextRefreshTokenHash: z6.string().regex(/^[a-f0-9]{64}$/u),
2003
- refreshToken: z6.string().regex(/^[A-Za-z0-9_-]{43,256}$/u),
2004
- rotationId: z6.uuid(),
2005
- signature: z6.string().regex(/^[A-Za-z0-9_-]{64,256}$/u)
2006
- }).strict();
2007
- var wechatLoginSessionPurposeSchema = z6.enum(["link", "login", "start"]);
2008
- var wechatLoginSessionStatusSchema = z6.enum([
2009
- "URL_READY",
2010
- "EXCHANGING",
2011
- "IDENTIFIED",
2012
- "SUCCEEDED",
2013
- "EXPIRED",
2014
- "FAILED"
2015
- ]);
2016
- var wechatLoginFailureCodeSchema = z6.enum([
2017
- "WECHAT_LOGIN_DEVICE_UNAUTHORIZED",
2018
- "WECHAT_LOGIN_IDENTITY_CONFLICT",
2019
- "WECHAT_LOGIN_IDENTITY_NOT_LINKED",
2020
- "WECHAT_LOGIN_PROVIDER_FAILED",
2021
- "WECHAT_LOGIN_SESSION_INVALID"
2022
- ]);
2023
- var createWechatLoginSessionRequestSchema = z6.object({
2024
- purpose: wechatLoginSessionPurposeSchema
2025
- }).strict();
2026
- var createWechatLoginSessionResponseSchema = z6.object({
2027
- authorizationUrl: z6.url(),
2028
- expiresAt: z6.iso.datetime(),
2029
- id: z6.uuid(),
2030
- pollToken: z6.string().min(32).max(256),
2031
- purpose: wechatLoginSessionPurposeSchema
2032
- }).strict();
2033
- var wechatLoginSessionResponseSchema = z6.object({
2034
- expiresAt: z6.iso.datetime(),
2035
- failureCode: wechatLoginFailureCodeSchema.optional(),
2036
- id: z6.uuid(),
2037
- identity: deviceSessionIdentitySchema.optional(),
2038
- purpose: wechatLoginSessionPurposeSchema,
2039
- status: wechatLoginSessionStatusSchema
2040
- }).strict().superRefine((session, context) => {
2041
- if (session.status === "SUCCEEDED" && session.identity === void 0) {
2042
- context.addIssue({
2043
- code: "custom",
2044
- message: "successful login session requires an identity"
2045
- });
2046
- }
2047
- if (session.status === "FAILED" && session.failureCode === void 0) {
2048
- context.addIssue({
2049
- code: "custom",
2050
- message: "failed login session requires a failure code"
2051
- });
2052
- }
2053
- if (session.status !== "FAILED" && session.failureCode !== void 0) {
2054
- context.addIssue({
2055
- code: "custom",
2056
- message: "only failed login session may expose a failure code"
2057
- });
2058
- }
2059
- });
2060
- var wechatAccountSchema = z6.object({
2061
- id: z6.uuid(),
2062
- displayName: z6.string().trim().min(1),
2063
- accountType: z6.string().trim().min(1),
2064
- status: z6.enum(["ACTIVE", "PERMISSION_CHANGED", "REVOKED"]),
2065
- permissions: z6.array(wechatPermissionIdSchema),
2066
- draftCapability: z6.enum(["available", "missing", "revoked"])
2067
- }).strict();
2068
- var createWechatAuthorizationSessionResponseSchema = z6.object({
2069
- id: z6.uuid(),
2070
- authorizationUrl: z6.url(),
2071
- pollToken: z6.string().min(32).max(256),
2072
- expiresAt: z6.iso.datetime()
2073
- }).strict();
2074
- var wechatAuthorizationSessionResponseSchema = z6.object({
2075
- id: z6.uuid(),
2076
- status: z6.enum(["URL_READY", "EXCHANGING", "AUTHORIZED", "BOUND", "EXPIRED", "FAILED"]),
2077
- expiresAt: z6.iso.datetime(),
2078
- account: wechatAccountSchema.optional()
2079
- }).strict();
2080
- var wechatAccountsResponseSchema = z6.object({
2081
- accounts: z6.array(wechatAccountSchema)
2082
- }).strict();
2083
- var wechatDraftSmokeStatusSchema = z6.enum([
2084
- "QUEUED",
2085
- "PREPARING",
2086
- "UPLOADING_ASSETS",
2087
- "ASSET_UPLOAD_UNVERIFIED",
2088
- "CREATING_DRAFT",
2089
- "VERIFYING",
2090
- "SUCCEEDED",
2091
- "CREATED_UNVERIFIED",
2092
- "FAILED"
2093
- ]);
2094
- var wechatDraftSmokeSnapshotSchema = z6.object({
2095
- articleVersion: z6.literal("wechat-draft-smoke@1"),
2096
- author: z6.string().trim().min(1),
2097
- commentsEnabled: z6.boolean(),
2098
- coverHash: z6.string().regex(/^[a-f0-9]{64}$/u),
2099
- coverLabel: z6.string().trim().min(1),
2100
- digest: z6.string().trim().min(1),
2101
- htmlHash: z6.string().regex(/^[a-f0-9]{64}$/u),
2102
- rendererVersion: z6.string().trim().min(1),
2103
- snapshotHash: z6.string().regex(/^[a-f0-9]{64}$/u),
2104
- sourceHash: z6.string().regex(/^[a-f0-9]{64}$/u),
2105
- templateId: z6.literal("wechat-minimal@1"),
2106
- title: z6.string().trim().min(1)
2107
- }).strict();
2108
- var createWechatDraftSmokeIntentRequestSchema = z6.object({
2109
- accountId: z6.uuid(),
2110
- confirmed: z6.literal(true),
2111
- snapshotHash: z6.string().regex(/^[a-f0-9]{64}$/u)
2112
- }).strict();
2113
- var wechatDraftSmokePreviewRequestSchema = z6.object({
2114
- accountId: z6.uuid()
2115
- }).strict();
2116
- var wechatDraftSmokePreviewResponseSchema = z6.object({
2117
- account: wechatAccountSchema,
2118
- snapshot: wechatDraftSmokeSnapshotSchema
2119
- }).strict();
2120
- var wechatDraftSmokeIntentSchema = z6.object({
2121
- accountId: z6.uuid(),
2122
- createdAt: z6.iso.datetime(),
2123
- errorCode: z6.string().trim().min(1).optional(),
2124
- id: z6.uuid(),
2125
- mediaId: z6.string().trim().min(1).max(128).optional(),
2126
- snapshotHash: z6.string().regex(/^[a-f0-9]{64}$/u),
2127
- status: wechatDraftSmokeStatusSchema,
2128
- updatedAt: z6.iso.datetime(),
2129
- verification: z6.object({
2130
- authorMatched: z6.boolean(),
2131
- contentMatched: z6.boolean(),
2132
- digestMatched: z6.boolean(),
2133
- titleMatched: z6.boolean()
2134
- }).strict().optional()
2135
- }).strict();
2136
- var wechatDraftSmokeIntentResponseSchema = z6.object({
2137
- intent: wechatDraftSmokeIntentSchema
2138
- }).strict();
2139
- var apiErrorResponseSchema = z6.object({
2140
- error: z6.object({
2141
- code: z6.string().trim().min(1),
2142
- message: z6.string().trim().min(1),
2143
- retryable: z6.boolean()
2144
- }).strict()
2145
- }).strict();
2146
-
2147
- // apps/cli/src/local-state.ts
2148
- import { randomUUID } from "node:crypto";
2149
- import { constants as fileConstants } from "node:fs";
2150
- import { chmod, lstat, mkdir, open, rename, unlink } from "node:fs/promises";
2151
- import path from "node:path";
2152
- var LocalStateError = class extends Error {
2153
- constructor(failure) {
2154
- super(failure);
2155
- this.failure = failure;
2156
- this.name = "LocalStateError";
2157
- }
2158
- failure;
2159
- };
2160
- function errorCode(error) {
2161
- return typeof error === "object" && error !== null && "code" in error ? String(error.code) : void 0;
2162
- }
2163
- function ownedByCurrentUser(userId, ownerId) {
2164
- return userId === void 0 || userId === ownerId;
2165
- }
2166
- async function ensurePrivateDirectory(directory) {
2167
- try {
2168
- await mkdir(directory, { mode: 448, recursive: true });
2169
- const metadata = await lstat(directory);
2170
- const userId = typeof process.getuid === "function" ? process.getuid() : void 0;
2171
- if (!metadata.isDirectory() || metadata.isSymbolicLink() || !ownedByCurrentUser(userId, metadata.uid)) {
2172
- throw new LocalStateError("invalid");
2173
- }
2174
- await chmod(directory, 448);
2175
- } catch (error) {
2176
- if (error instanceof LocalStateError) {
2177
- throw error;
2178
- }
2179
- if (errorCode(error) === "ELOOP") {
2180
- throw new LocalStateError("invalid");
2181
- }
2182
- throw new LocalStateError("io");
2183
- }
2184
- }
2185
- async function ensurePrivateRegularFile(target) {
2186
- await ensurePrivateDirectory(path.dirname(target));
2187
- let handle;
2188
- try {
2189
- handle = await open(
2190
- target,
2191
- fileConstants.O_CREAT | fileConstants.O_RDWR | fileConstants.O_NOFOLLOW,
2192
- 384
2193
- );
2194
- const metadata = await handle.stat();
2195
- const userId = typeof process.getuid === "function" ? process.getuid() : void 0;
2196
- if (!metadata.isFile() || !ownedByCurrentUser(userId, metadata.uid)) {
2197
- throw new LocalStateError("invalid");
2198
- }
2199
- await handle.chmod(384);
2200
- } catch (error) {
2201
- if (error instanceof LocalStateError) {
2202
- throw error;
2203
- }
2204
- if (errorCode(error) === "ELOOP") {
2205
- throw new LocalStateError("invalid");
2206
- }
2207
- throw new LocalStateError("io");
2208
- } finally {
2209
- await handle?.close();
2210
- }
2211
- }
2212
- async function readPrivateFile(target, maximumBytes) {
2213
- const contents = await readPrivateBuffer(target, maximumBytes);
2214
- return contents.toString("utf8");
2215
- }
2216
- async function readPrivateBuffer(target, maximumBytes) {
2217
- let handle;
2218
- try {
2219
- handle = await open(target, fileConstants.O_RDONLY | fileConstants.O_NOFOLLOW);
2220
- } catch (error) {
2221
- if (errorCode(error) === "ENOENT") {
2222
- throw new LocalStateError("missing");
2223
- }
2224
- if (errorCode(error) === "ELOOP") {
2225
- throw new LocalStateError("invalid");
2226
- }
2227
- throw new LocalStateError("io");
2228
- }
2229
- try {
2230
- const metadata = await handle.stat();
2231
- const userId = typeof process.getuid === "function" ? process.getuid() : void 0;
2232
- if (!metadata.isFile() || !ownedByCurrentUser(userId, metadata.uid) || metadata.size > maximumBytes || process.platform !== "win32" && (metadata.mode & 63) !== 0) {
2233
- throw new LocalStateError("invalid");
2234
- }
2235
- return await handle.readFile();
2236
- } catch (error) {
2237
- if (error instanceof LocalStateError) {
2238
- throw error;
2239
- }
2240
- throw new LocalStateError("io");
2241
- } finally {
2242
- await handle.close();
2243
- }
2244
- }
2245
- async function writePrivateJson(target, value) {
2246
- await writePrivateBuffer(target, Buffer.from(`${JSON.stringify(value, void 0, 2)}
2247
- `, "utf8"));
2248
- }
2249
- async function writePrivateBuffer(target, value) {
2250
- const directory = path.dirname(target);
2251
- await ensurePrivateDirectory(directory);
2252
- const temporary = path.join(directory, `.${path.basename(target)}.${randomUUID()}.tmp`);
2253
- let handle;
2254
- try {
2255
- handle = await open(
2256
- temporary,
2257
- fileConstants.O_CREAT | fileConstants.O_EXCL | fileConstants.O_WRONLY | fileConstants.O_NOFOLLOW,
2258
- 384
2259
- );
2260
- await handle.writeFile(value);
2261
- await handle.sync();
2262
- await handle.close();
2263
- handle = void 0;
2264
- await rename(temporary, target);
2265
- await chmod(target, 384);
2266
- } catch (error) {
2267
- throw error instanceof LocalStateError ? error : new LocalStateError("io");
2268
- } finally {
2269
- await handle?.close();
2270
- await unlink(temporary).catch(() => void 0);
2271
- }
2272
- }
2273
-
2274
- export {
2275
- __require,
2276
- __esm,
2277
- __commonJS,
2278
- __export,
2279
- __toESM,
2280
- __toCommonJS,
2281
- publishingUploadSessionSchema,
2282
- publishingUploadReceiptSchema,
2283
- publishingArticleSchema,
2284
- publishingRenderSnapshotSchema,
2285
- publishingPreviewLinkSchema,
2286
- publishingPreviewSelectionStateSchema,
2287
- createPublishingApprovalRequestSchema,
2288
- publishingApprovalSchema,
2289
- createPublishingDraftIntentRequestSchema,
2290
- publishingDraftIntentResponseSchema,
2291
- CONTENT_WORKFLOW_ID,
2292
- CONTENT_ARTIFACT_KINDS,
2293
- contentArtifactKindSchema,
2294
- CONTENT_STAGE_SKILLS,
2295
- CONTENT_STAGE_INPUTS,
2296
- portableRelativePathSchema,
2297
- contentProjectManifestSchema,
2298
- goldenLinesSidecarSchema,
2299
- titlesStageArtifactFrontmatterSchema,
2300
- visualPlanStageArtifactFrontmatterSchema,
2301
- deliveryStageArtifactFrontmatterSchema,
2302
- contentStageArtifactFrontmatterSchema,
2303
- stepCheckpointStatusSchema,
2304
- executionLocationSchema,
2305
- dataTransitSchema,
2306
- stepCheckpointSchema,
2307
- contentProjectInitResultSchema,
2308
- contentProjectStatusResultSchema,
2309
- contentProjectIndexSchema,
2310
- contentProjectResolveResultSchema,
2311
- contentProjectCheckpointResultSchema,
2312
- contentProjectErrorResultSchema,
2313
- contentProfileInputSchema,
2314
- contentProfileUpdateInputSchema,
2315
- contentProfileSchema,
2316
- contentProfileSaveResultSchema,
2317
- contentProfileUpdateResultSchema,
2318
- contentProfileStatusResultSchema,
2319
- contentMemoryInputSchema,
2320
- contentMemoryStoreSchema,
2321
- contentMemoryAddResultSchema,
2322
- contentMemoryArchiveResultSchema,
2323
- contentMemoryListResultSchema,
2324
- contentMemoryErrorResultSchema,
2325
- contentProfileErrorResultSchema,
2326
- CONTENT_KNOWLEDGE_SCHEMA_VERSION,
2327
- CONTENT_KNOWLEDGE_EMBEDDING_MODEL,
2328
- CONTENT_KNOWLEDGE_EMBEDDING_REVISION,
2329
- CONTENT_KNOWLEDGE_EMBEDDING_DIMENSIONS,
2330
- CONTENT_KNOWLEDGE_EMBEDDING_QUANTIZATION,
2331
- CONTENT_KNOWLEDGE_CHUNKER_VERSION,
2332
- contentKnowledgeSearchModeSchema,
2333
- contentKnowledgeModelSchema,
2334
- contentKnowledgeImportResultSchema,
2335
- contentKnowledgeQuoteListResultSchema,
2336
- contentKnowledgeQuoteMutationResultSchema,
2337
- contentKnowledgeQuoteInitResultSchema,
2338
- contentKnowledgeQuoteStatusResultSchema,
2339
- contentKnowledgeQuoteSyncResultSchema,
2340
- contentKnowledgeSearchResultSchema,
2341
- contentKnowledgeStatusResultSchema,
2342
- contentKnowledgeRemoveResultSchema,
2343
- contentKnowledgeErrorResultSchema,
2344
- sourceFetchKindSchema,
2345
- sourceFetchResultSchema,
2346
- sourceFetchErrorResultSchema,
2347
- CONTENT_MONITOR_SCHEMA_VERSION,
2348
- contentMonitorSourceSchema,
2349
- contentMonitorAddResultSchema,
2350
- contentMonitorListResultSchema,
2351
- contentMonitorRunResultSchema,
2352
- contentMonitorStatusResultSchema,
2353
- contentMonitorRemoveResultSchema,
2354
- contentMonitorErrorResultSchema,
2355
- PROTOCOL_VERSION,
2356
- versionResultSchema,
2357
- doctorResultSchema,
2358
- articleBundleSchema,
2359
- preflightResultSchema,
2360
- wechatRenderResultSchema,
2361
- createDeviceBindingSessionResponseSchema,
2362
- proveDeviceBindingSessionResponseSchema,
2363
- deviceSessionStatusResponseSchema,
2364
- createWechatLoginSessionResponseSchema,
2365
- wechatLoginSessionResponseSchema,
2366
- createWechatAuthorizationSessionResponseSchema,
2367
- wechatAuthorizationSessionResponseSchema,
2368
- wechatAccountsResponseSchema,
2369
- wechatDraftSmokePreviewResponseSchema,
2370
- wechatDraftSmokeIntentResponseSchema,
2371
- apiErrorResponseSchema,
2372
- LocalStateError,
2373
- ensurePrivateDirectory,
2374
- ensurePrivateRegularFile,
2375
- readPrivateFile,
2376
- readPrivateBuffer,
2377
- writePrivateJson,
2378
- writePrivateBuffer
2379
- };