@deployxai/dxc 0.3.2 → 0.3.3

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.
@@ -1,1522 +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({ quote: contentKnowledgeQuoteRecordSchema, synced: z.literal(true) }).strict(),
162
- ok: z.literal(true)
163
- }).strict();
164
- var contentKnowledgeQuoteStatusResultSchema = z.object({
165
- command: z.literal("knowledge.quotes.status"),
166
- data: contentKnowledgeQuoteSummarySchema,
167
- ok: z.literal(true)
168
- }).strict();
169
- var contentKnowledgeSearchItemLegacySchema = z.object({
170
- articleId: z.uuid(),
171
- chunkId: z.uuid(),
172
- chunkSha256: z.string().regex(/^[a-f0-9]{64}$/u),
173
- heading: z.string().trim().min(1).max(300).nullable(),
174
- lanes: z.array(contentKnowledgeMatchLaneSchema).min(1).max(2),
175
- ordinal: z.number().int().nonnegative(),
176
- rank: z.number().int().positive().max(20),
177
- snippet: z.string().trim().min(1).max(420),
178
- sourceLabel: z.string().trim().min(1).max(255),
179
- title: z.string().trim().min(1).max(300)
180
- }).strict();
181
- var contentKnowledgeSearchResultSchema = z.object({
182
- command: z.literal("knowledge.search"),
183
- data: z.object({
184
- mode: contentKnowledgeSearchModeSchema,
185
- model: contentKnowledgeModelSchema.nullable(),
186
- query: z.string().trim().min(1).max(500),
187
- results: z.array(contentKnowledgeSearchItemSchema).max(20)
188
- }).strict(),
189
- ok: z.literal(true)
190
- }).strict();
191
- var contentKnowledgeStatusResultSchema = z.object({
192
- command: z.literal("knowledge.status"),
193
- data: z.object({
194
- articleCount: z.number().int().nonnegative(),
195
- chunkCount: z.number().int().nonnegative(),
196
- databasePath: z.literal("~/.dxc/content-memory.sqlite"),
197
- model: contentKnowledgeModelSchema,
198
- modelCached: z.boolean(),
199
- semanticIndexedChunkCount: z.number().int().nonnegative(),
200
- quotes: contentKnowledgeQuoteSummarySchema
201
- }).strict(),
202
- ok: z.literal(true)
203
- }).strict();
204
- var contentKnowledgeRemoveResultSchema = z.object({
205
- command: z.literal("knowledge.remove"),
206
- data: z.object({
207
- articleId: z.uuid(),
208
- removed: z.boolean()
209
- }).strict(),
210
- ok: z.literal(true)
211
- }).strict();
212
- var contentKnowledgeCommandSchema = z.enum([
213
- "knowledge.import",
214
- "knowledge.remove",
215
- "knowledge.search",
216
- "knowledge.status",
217
- "knowledge.quotes.add",
218
- "knowledge.quotes.archive",
219
- "knowledge.quotes.list",
220
- "knowledge.quotes.status",
221
- "knowledge.quotes.update"
222
- ]);
223
- var contentKnowledgeErrorResultSchema = z.object({
224
- command: contentKnowledgeCommandSchema,
225
- error: z.object({
226
- code: z.enum([
227
- "DXC_KNOWLEDGE_ARTICLE_INVALID",
228
- "DXC_KNOWLEDGE_DIRECTORY_INVALID",
229
- "DXC_KNOWLEDGE_DIRECTORY_TOO_LARGE",
230
- "DXC_KNOWLEDGE_FILE_TOO_LARGE",
231
- "DXC_KNOWLEDGE_INPUT_NOT_FOUND",
232
- "DXC_KNOWLEDGE_IO_FAILED",
233
- "DXC_KNOWLEDGE_MODEL_FAILED",
234
- "DXC_KNOWLEDGE_QUERY_INVALID",
235
- "DXC_KNOWLEDGE_QUOTE_INVALID",
236
- "DXC_KNOWLEDGE_QUOTE_SOURCE_NOT_INITIALIZED",
237
- "DXC_KNOWLEDGE_SCHEMA_UNSUPPORTED",
238
- "DXC_KNOWLEDGE_SEMANTIC_NOT_READY",
239
- "DXC_KNOWLEDGE_STATE_INVALID"
240
- ]),
241
- details: z.object({
242
- nextAction: z.object({
243
- choices: z.array(
244
- z.object({
245
- choiceId: z.string().regex(/^knowledge-choice1_[A-Za-z0-9_-]+\.[a-f0-9]{32}$/u),
246
- label: z.string().trim().min(1).max(120)
247
- }).strict()
248
- ).length(2),
249
- purpose: z.literal("knowledge-model-unavailable"),
250
- type: z.literal("select-choice")
251
- }).strict()
252
- }).strict().optional(),
253
- message: z.string().trim().min(1)
254
- }).strict(),
255
- ok: z.literal(false)
256
- }).strict();
257
-
258
- // packages/contracts/src/index.ts
259
- import { z as z6 } from "zod";
260
-
261
- // packages/contracts/src/publishing.ts
262
- import { z as z2 } from "zod";
263
- var sha256Schema = z2.string().regex(/^[a-f0-9]{64}$/u);
264
- var wechatTemplateIdSchema = z2.enum([
265
- "wechat-minimal@1",
266
- "wechat-academic-paper@1",
267
- "wechat-aurora-glass@1",
268
- "wechat-bauhaus@1",
269
- "wechat-cyberpunk-neon@1",
270
- "wechat-knowledge-base@1",
271
- "wechat-luxury-gold@1",
272
- "wechat-morandi-forest@1",
273
- "wechat-neo-brutalism@1",
274
- "wechat-receipt@1",
275
- "wechat-sunset-film@1"
276
- ]);
277
- var publishingUploadKindSchema = z2.enum(["article-source", "cover-image", "inline-image"]);
278
- var publishingUploadMediaTypeSchema = z2.enum([
279
- "text/markdown",
280
- "text/plain",
281
- "image/jpeg",
282
- "image/png"
283
- ]);
284
- var createPublishingUploadRequestSchema = z2.object({
285
- fileName: z2.string().trim().min(1).max(160),
286
- kind: publishingUploadKindSchema,
287
- mediaType: publishingUploadMediaTypeSchema,
288
- sha256: sha256Schema,
289
- size: z2.number().int().positive().max(5 * 1024 * 1024)
290
- }).strict().superRefine((value, context) => {
291
- if (value.kind === "article-source" && value.mediaType !== "text/markdown" && value.mediaType !== "text/plain") {
292
- context.addIssue({
293
- code: "custom",
294
- message: "article source requires a text media type",
295
- path: ["mediaType"]
296
- });
297
- }
298
- if ((value.kind === "cover-image" || value.kind === "inline-image") && value.mediaType !== "image/jpeg" && value.mediaType !== "image/png") {
299
- context.addIssue({
300
- code: "custom",
301
- message: "image upload requires a supported image media type",
302
- path: ["mediaType"]
303
- });
304
- }
305
- if (value.kind === "article-source" && value.size > 512 * 1024) {
306
- context.addIssue({
307
- code: "custom",
308
- message: "article source exceeds the maximum size",
309
- path: ["size"]
310
- });
311
- }
312
- if (value.kind === "inline-image" && value.size >= 1024 * 1024) {
313
- context.addIssue({
314
- code: "custom",
315
- message: "inline image must be smaller than 1 MiB",
316
- path: ["size"]
317
- });
318
- }
319
- });
320
- var publishingUploadSessionSchema = z2.object({
321
- expiresAt: z2.iso.datetime(),
322
- id: z2.uuid(),
323
- kind: publishingUploadKindSchema,
324
- uploadUrl: z2.url()
325
- }).strict();
326
- var publishingUploadReceiptSchema = z2.object({
327
- id: z2.uuid(),
328
- sha256: sha256Schema,
329
- size: z2.number().int().positive().max(5 * 1024 * 1024),
330
- status: z2.literal("UPLOADED")
331
- }).strict();
332
- var createPublishingArticleRequestSchema = z2.object({
333
- coverUploadId: z2.uuid(),
334
- inlineAssets: z2.array(
335
- z2.object({
336
- logicalPath: z2.string().trim().min(1).max(240),
337
- uploadId: z2.uuid()
338
- }).strict()
339
- ).max(20).optional(),
340
- sourceUploadId: z2.uuid()
341
- }).strict().superRefine((value, context) => {
342
- const inlineAssets = value.inlineAssets ?? [];
343
- const logicalPaths = inlineAssets.map((asset) => asset.logicalPath);
344
- const uploadIds = inlineAssets.map((asset) => asset.uploadId);
345
- if (new Set(logicalPaths).size !== logicalPaths.length) {
346
- context.addIssue({
347
- code: "custom",
348
- message: "inline asset logical paths must be unique",
349
- path: ["inlineAssets"]
350
- });
351
- }
352
- if (new Set(uploadIds).size !== uploadIds.length) {
353
- context.addIssue({
354
- code: "custom",
355
- message: "inline asset uploads must be unique",
356
- path: ["inlineAssets"]
357
- });
358
- }
359
- });
360
- var publishingInlineAssetSchema = z2.object({
361
- logicalPath: z2.string().trim().min(1).max(240),
362
- mediaType: z2.enum(["image/jpeg", "image/png"]),
363
- sha256: sha256Schema
364
- }).strict();
365
- var publishingArticleSchema = z2.object({
366
- cover: z2.object({
367
- height: z2.number().int().positive().max(12e3),
368
- mediaType: z2.enum(["image/jpeg", "image/png"]),
369
- width: z2.number().int().positive().max(12e3)
370
- }).strict(),
371
- coverHash: sha256Schema,
372
- createdAt: z2.iso.datetime(),
373
- id: z2.uuid(),
374
- inlineAssets: z2.array(publishingInlineAssetSchema).max(20).default([]),
375
- sourceHash: sha256Schema
376
- }).strict();
377
- var createPublishingRenderSnapshotRequestSchema = z2.object({
378
- title: z2.string().trim().min(1).max(64).optional()
379
- }).strict();
380
- var publishingPreflightIssueSchema = z2.object({
381
- code: z2.string().trim().min(1),
382
- message: z2.string().trim().min(1),
383
- path: z2.string().trim().min(1).optional()
384
- }).strict();
385
- var publishingPreflightSchema = z2.object({
386
- errors: z2.array(publishingPreflightIssueSchema),
387
- metrics: z2.object({
388
- digestCharacters: z2.number().int().nonnegative(),
389
- externalLinkCount: z2.number().int().nonnegative(),
390
- htmlCharacters: z2.number().int().nonnegative(),
391
- imageCount: z2.number().int().nonnegative(),
392
- tableCount: z2.number().int().nonnegative()
393
- }).strict(),
394
- ok: z2.boolean(),
395
- warnings: z2.array(publishingPreflightIssueSchema)
396
- }).strict();
397
- var publishingRenderSnapshotSchema = z2.object({
398
- articleId: z2.uuid(),
399
- assetManifestHash: sha256Schema,
400
- author: z2.string().trim().min(1).max(16),
401
- commentsEnabled: z2.boolean(),
402
- coverHash: sha256Schema,
403
- createdAt: z2.iso.datetime(),
404
- digest: z2.string().trim().min(1).max(120),
405
- htmlHash: sha256Schema,
406
- id: z2.uuid(),
407
- inlineAssets: z2.array(publishingInlineAssetSchema).max(20).default([]),
408
- preflight: publishingPreflightSchema,
409
- rendererVersion: z2.string().trim().min(1),
410
- snapshotHash: sha256Schema,
411
- sourceHash: sha256Schema,
412
- templateId: wechatTemplateIdSchema,
413
- title: z2.string().trim().min(1).max(32)
414
- }).strict();
415
- var createPublishingPreviewLinkRequestSchema = z2.object({
416
- snapshotHash: sha256Schema
417
- }).strict();
418
- var publishingPreviewLinkSchema = z2.object({
419
- createdAt: z2.iso.datetime().optional(),
420
- expiresAt: z2.iso.datetime(),
421
- expiresInSeconds: z2.number().int().positive().max(24 * 60 * 60).optional(),
422
- snapshotHash: sha256Schema,
423
- url: z2.url()
424
- }).strict();
425
- var publishingPreviewSelectionStateSchema = z2.object({
426
- rootSnapshotHash: sha256Schema,
427
- rootSnapshotId: z2.uuid(),
428
- selectedSnapshotHash: sha256Schema,
429
- selectedSnapshotId: z2.uuid(),
430
- selectionRevision: z2.number().int().nonnegative(),
431
- templateId: wechatTemplateIdSchema,
432
- updatedAt: z2.iso.datetime(),
433
- viewed: z2.boolean(),
434
- viewedAt: z2.iso.datetime().nullable()
435
- }).strict();
436
- var createPublishingApprovalRequestSchema = z2.object({
437
- accountId: z2.uuid(),
438
- confirmed: z2.literal(true),
439
- snapshotHash: sha256Schema
440
- }).strict();
441
- var publishingApprovalSchema = z2.object({
442
- accountId: z2.uuid(),
443
- confirmedAt: z2.iso.datetime(),
444
- id: z2.uuid(),
445
- rootSnapshotHash: sha256Schema,
446
- rootSnapshotId: z2.uuid(),
447
- selectedSnapshotHash: sha256Schema,
448
- selectedSnapshotId: z2.uuid(),
449
- templateId: wechatTemplateIdSchema
450
- }).strict();
451
- var createPublishingDraftIntentRequestSchema = z2.object({
452
- approvalId: z2.uuid(),
453
- previousIntentId: z2.uuid().optional()
454
- }).strict();
455
- var publishingDraftStatusSchema = z2.enum([
456
- "QUEUED",
457
- "PREPARING",
458
- "UPLOADING_ASSETS",
459
- "ASSET_UPLOAD_UNVERIFIED",
460
- "CREATING_DRAFT",
461
- "VERIFYING",
462
- "SUCCEEDED",
463
- "CREATED_UNVERIFIED",
464
- "FAILED"
465
- ]);
466
- var publishingDraftIntentSchema = z2.object({
467
- accountId: z2.uuid(),
468
- approvalId: z2.uuid(),
469
- createdAt: z2.iso.datetime(),
470
- errorCode: z2.string().trim().min(1).optional(),
471
- id: z2.uuid(),
472
- mediaId: z2.string().trim().min(1).max(128).optional(),
473
- progress: z2.object({
474
- label: z2.string().trim().min(1).max(40),
475
- message: z2.string().trim().min(1).max(300),
476
- nextAction: z2.string().trim().min(1).max(300),
477
- pollAfterSeconds: z2.number().int().positive().max(60).nullable(),
478
- terminal: z2.boolean()
479
- }).strict(),
480
- snapshotHash: sha256Schema,
481
- status: publishingDraftStatusSchema,
482
- updatedAt: z2.iso.datetime(),
483
- verification: z2.object({
484
- authorMatched: z2.boolean(),
485
- contentMatched: z2.boolean(),
486
- digestMatched: z2.boolean(),
487
- titleMatched: z2.boolean()
488
- }).strict().optional()
489
- }).strict();
490
- var publishingDraftIntentResponseSchema = z2.object({
491
- intent: publishingDraftIntentSchema
492
- }).strict();
493
- var publishingDraftAttentionDiagnosticsSchema = z2.object({
494
- errorCode: z2.string().trim().min(1).optional(),
495
- intentId: z2.uuid(),
496
- reason: z2.object({
497
- message: z2.string().trim().min(1).max(500),
498
- nextAction: z2.string().trim().min(1).max(500),
499
- phase: z2.enum([
500
- "preparation",
501
- "asset-upload",
502
- "draft-create",
503
- "draft-readback",
504
- "verification",
505
- "unknown"
506
- ]),
507
- retryAllowed: z2.boolean()
508
- }).strict(),
509
- status: publishingDraftStatusSchema,
510
- verification: z2.object({
511
- authorMatched: z2.boolean(),
512
- coverMatched: z2.boolean().nullable(),
513
- contentMatched: z2.boolean(),
514
- digestMatched: z2.boolean(),
515
- firstDifference: z2.enum(["image-count", "image-identity", "image-order", "text"]).nullable().optional(),
516
- imageMismatches: z2.array(
517
- z2.object({
518
- actualIndex: z2.number().int().nonnegative().optional(),
519
- expectedIndex: z2.number().int().nonnegative().optional(),
520
- kind: z2.enum(["identity", "missing", "order", "unexpected"]),
521
- logicalPath: z2.string().trim().min(1).max(240).optional(),
522
- role: z2.enum(["cover", "inline-image"])
523
- }).strict()
524
- ).max(41),
525
- titleMatched: z2.boolean()
526
- }).strict().optional()
527
- }).strict();
528
-
529
- // packages/contracts/src/content-workflow.ts
530
- import { z as z3 } from "zod";
531
- var CONTENT_WORKFLOW_ID = "dxc-article@1";
532
- var CONTENT_PROFILE_QUESTIONNAIRE_VERSION = "dxc-onboarding@1";
533
- var CONTENT_ARTIFACT_KINDS = [
534
- "research",
535
- "brief",
536
- "outline",
537
- "article",
538
- "titles",
539
- "visual-plan",
540
- "quality-review",
541
- "delivery"
542
- ];
543
- var contentArtifactKindSchema = z3.enum(CONTENT_ARTIFACT_KINDS);
544
- var DXC_STAGE_SKILL_NAMES = [
545
- "dxc-research",
546
- "dxc-content-brief",
547
- "dxc-article-outline",
548
- "dxc-article-write",
549
- "dxc-title-write",
550
- "dxc-visual-plan",
551
- "dxc-content-review",
552
- "dxc-wechat-publisher"
553
- ];
554
- var dxcStageSkillNameSchema = z3.enum(DXC_STAGE_SKILL_NAMES);
555
- var CONTENT_STAGE_DEFINITIONS = {
556
- article: {
557
- inputs: { optional: [], required: ["research", "brief", "outline"] },
558
- output: "article",
559
- skill: "dxc-article-write",
560
- stage: "article"
561
- },
562
- brief: {
563
- inputs: { optional: [], required: ["research"] },
564
- output: "brief",
565
- skill: "dxc-content-brief",
566
- stage: "brief"
567
- },
568
- delivery: {
569
- inputs: { optional: [], required: ["article", "titles", "visual-plan", "quality-review"] },
570
- output: "delivery",
571
- skill: "dxc-wechat-publisher",
572
- stage: "delivery"
573
- },
574
- outline: {
575
- inputs: { optional: [], required: ["research", "brief"] },
576
- output: "outline",
577
- skill: "dxc-article-outline",
578
- stage: "outline"
579
- },
580
- "quality-review": {
581
- inputs: { optional: ["visual-plan"], required: ["research", "article", "titles"] },
582
- output: "quality-review",
583
- skill: "dxc-content-review",
584
- stage: "quality-review"
585
- },
586
- research: {
587
- inputs: { optional: [], required: [] },
588
- output: "research",
589
- skill: "dxc-research",
590
- stage: "research"
591
- },
592
- titles: {
593
- inputs: { optional: ["brief"], required: ["article"] },
594
- output: "titles",
595
- skill: "dxc-title-write",
596
- stage: "titles"
597
- },
598
- "visual-plan": {
599
- inputs: { optional: ["outline"], required: ["article", "titles"] },
600
- output: "visual-plan",
601
- skill: "dxc-visual-plan",
602
- stage: "visual-plan"
603
- }
604
- };
605
- var contentWorkflowWorkItemIdSchema = z3.string().regex(/^wi1_[A-Za-z0-9_-]+\.[a-f0-9]{32}$/u);
606
- var contentWorkflowChoiceIdSchema = z3.string().regex(/^choice1_[A-Za-z0-9_-]+\.[a-f0-9]{32}$/u);
607
- var contentWorkflowSectionIdSchema = z3.string().regex(/^sec_[0-9]{2}_[a-f0-9]{8}$/u);
608
- var contentWorkflowAssetIdSchema = z3.enum([
609
- "cover",
610
- ...Array.from({ length: 20 }, (_, index) => `inline-${String(index + 1).padStart(2, "0")}`)
611
- ]);
612
- var contentWorkflowChoiceSchema = z3.object({
613
- choiceId: contentWorkflowChoiceIdSchema,
614
- label: z3.string().trim().min(1).max(120)
615
- }).strict();
616
- var contentWorkflowAssetAssignmentSchema = z3.object({
617
- assetId: contentWorkflowAssetIdSchema,
618
- path: z3.string().trim().min(1).max(4096),
619
- role: z3.enum(["cover", "inline"]),
620
- sectionId: contentWorkflowSectionIdSchema.optional()
621
- }).strict();
622
- var contentWorkflowNextActionSchema = z3.discriminatedUnion("type", [
623
- z3.object({ type: z3.literal("run-stage") }).strict(),
624
- z3.object({
625
- assets: z3.array(contentWorkflowAssetAssignmentSchema).min(1).max(21),
626
- type: z3.literal("generate-assets")
627
- }).strict(),
628
- z3.object({
629
- presentation: z3.object({ path: z3.string().trim().min(1).max(4096), type: z3.literal("artifact") }).strict(),
630
- type: z3.literal("confirm-stage")
631
- }).strict(),
632
- z3.object({
633
- choices: z3.array(contentWorkflowChoiceSchema).min(2).max(100),
634
- purpose: z3.literal("wechat-account"),
635
- type: z3.literal("select-choice")
636
- }).strict(),
637
- z3.object({ type: z3.literal("preview") }).strict(),
638
- z3.object({
639
- expiresAt: z3.iso.datetime(),
640
- type: z3.literal("confirm-delivery")
641
- }).strict(),
642
- z3.object({ type: z3.literal("completed") }).strict()
643
- ]);
644
- var contentWorkflowInputResourceSchema = z3.discriminatedUnion("availability", [
645
- z3.object({ availability: z3.literal("missing") }).strict(),
646
- z3.object({
647
- availability: z3.literal("present"),
648
- path: z3.string().trim().min(1).max(4096)
649
- }).strict()
650
- ]);
651
- var contentWorkflowResourcesSchema = z3.object({
652
- inputs: z3.record(z3.string(), contentWorkflowInputResourceSchema),
653
- output: z3.object({
654
- path: z3.string().trim().min(1).max(4096),
655
- scaffold: z3.enum(["created", "existing", "not-applicable"])
656
- }).strict()
657
- }).strict();
658
- var contentWorkflowConstraintsSchema = z3.object({
659
- authorMaxCharacters: z3.number().int().positive().optional(),
660
- coverMaxBytes: z3.number().int().positive().optional(),
661
- digestMaxCharacters: z3.number().int().positive().optional(),
662
- inlineImageMaxBytes: z3.number().int().positive().optional(),
663
- inlineImageMaxCount: z3.number().int().positive().optional(),
664
- supportedImageTypes: z3.array(z3.enum(["image/jpeg", "image/png"])).optional(),
665
- titleMaxCharacters: z3.number().int().positive().optional()
666
- }).strict();
667
- var contentWorkflowSectionSchema = z3.object({
668
- heading: z3.string().trim().min(1).max(300),
669
- sectionId: contentWorkflowSectionIdSchema
670
- }).strict();
671
- var contentWorkflowProjectSummarySchema = z3.object({
672
- projectId: z3.uuid(),
673
- title: z3.string().trim().min(1).max(160)
674
- }).strict();
675
- var contentWorkflowWorkItemSchema = z3.object({
676
- constraints: contentWorkflowConstraintsSchema.optional(),
677
- nextAction: contentWorkflowNextActionSchema,
678
- resources: contentWorkflowResourcesSchema.optional(),
679
- sections: z3.array(contentWorkflowSectionSchema).max(100).optional(),
680
- skill: dxcStageSkillNameSchema,
681
- stage: contentArtifactKindSchema,
682
- workItemId: contentWorkflowWorkItemIdSchema
683
- }).strict();
684
- var contentWorkflowNextResultSchema = z3.object({
685
- command: z3.literal("workflow.next"),
686
- data: z3.object({
687
- project: contentWorkflowProjectSummarySchema,
688
- workItem: contentWorkflowWorkItemSchema
689
- }).strict(),
690
- ok: z3.literal(true)
691
- }).strict();
692
- function isPortableRelativePath(value) {
693
- if (value.startsWith("/") || value.includes("\\") || /[:*?"<>|\0]/u.test(value)) {
694
- return false;
695
- }
696
- return value.split("/").every((segment) => segment.length > 0 && segment !== "." && segment !== "..");
697
- }
698
- var portableRelativePathSchema = z3.string().trim().min(1).max(240).refine(isPortableRelativePath, "path must stay inside the project directory");
699
- var contentProjectArtifactPathsSchema = z3.object({
700
- article: portableRelativePathSchema,
701
- brief: portableRelativePathSchema,
702
- delivery: portableRelativePathSchema,
703
- outline: portableRelativePathSchema,
704
- "quality-review": portableRelativePathSchema,
705
- research: portableRelativePathSchema,
706
- titles: portableRelativePathSchema,
707
- "visual-plan": portableRelativePathSchema
708
- }).strict();
709
- var contentProjectManifestSchema = z3.object({
710
- artifacts: contentProjectArtifactPathsSchema,
711
- assetsDirectory: portableRelativePathSchema,
712
- // Persisted 0.1.x projects may contain this field. New projects do not create checkpoints.
713
- checkpointsDirectory: portableRelativePathSchema.optional(),
714
- createdAt: z3.iso.datetime(),
715
- projectId: z3.uuid(),
716
- schemaVersion: z3.literal("1"),
717
- title: z3.string().trim().min(1).max(160),
718
- workflowId: z3.literal(CONTENT_WORKFLOW_ID)
719
- }).strict();
720
- var contentProjectIndexEntrySchema = z3.object({
721
- directory: z3.string().trim().min(1).max(4096),
722
- projectId: z3.uuid(),
723
- title: z3.string().trim().min(1).max(160),
724
- updatedAt: z3.iso.datetime()
725
- }).strict();
726
- var contentProjectIndexSchema = z3.object({
727
- projects: z3.array(contentProjectIndexEntrySchema).max(1e3),
728
- schemaVersion: z3.literal("1")
729
- }).strict();
730
- var contentProfileAnswerSchema = z3.object({
731
- note: z3.string().trim().max(500).optional(),
732
- questionId: z3.string().regex(/^[a-z][a-z0-9.-]{1,63}$/u),
733
- selectedOptionIds: z3.array(z3.string().regex(/^[a-z][a-z0-9.-]{1,63}$/u)).min(1).max(8)
734
- }).strict();
735
- var contentConfirmationPolicySchema = z3.enum([
736
- "guided",
737
- "review-every-stage",
738
- "auto-until-delivery"
739
- ]);
740
- var currentProfileUserSchema = z3.object({
741
- confirmationPolicy: contentConfirmationPolicySchema.default("guided"),
742
- contentValuePromise: z3.string().trim().min(1).max(500),
743
- coreValues: z3.string().trim().min(1).max(500).optional(),
744
- creatorRole: z3.string().trim().min(1).max(120),
745
- displayName: z3.string().trim().min(1).max(120),
746
- historyDirectory: z3.string().trim().min(1).max(4096).optional(),
747
- penName: z3.string().trim().min(1).max(120).optional(),
748
- pointOfView: z3.string().trim().min(1).max(120).optional(),
749
- primaryDomains: z3.array(z3.string().trim().min(1).max(120)).min(1).max(5),
750
- primaryPlatform: z3.literal("wechat-official-account"),
751
- publishingCadence: z3.string().trim().min(1).max(120).optional(),
752
- redLines: z3.string().trim().min(1).max(500).optional(),
753
- targetAudience: z3.string().trim().min(1).max(500),
754
- titlePreferences: z3.string().trim().min(1).max(500).optional(),
755
- visualPreferences: z3.string().trim().min(1).max(500).optional(),
756
- writingVoice: z3.string().trim().min(1).max(500).optional()
757
- }).strict();
758
- var storedProfileUserSchema = currentProfileUserSchema.extend({
759
- visualGenerationAuthorization: z3.object({
760
- maxImagesPerRun: z3.number().int().min(1).max(20),
761
- mode: z3.literal("auto-within-limit")
762
- }).strict().optional()
763
- });
764
- var contentProfileInputSchema = z3.object({
765
- answers: z3.array(contentProfileAnswerSchema).max(32).default([]),
766
- questionnaireVersion: z3.literal(CONTENT_PROFILE_QUESTIONNAIRE_VERSION),
767
- user: currentProfileUserSchema
768
- }).strict();
769
- var contentProfileSchema = z3.object({
770
- answers: z3.array(contentProfileAnswerSchema).max(32),
771
- createdAt: z3.iso.datetime(),
772
- profileId: z3.uuid(),
773
- questionnaireVersion: z3.literal(CONTENT_PROFILE_QUESTIONNAIRE_VERSION),
774
- schemaVersion: z3.literal("1"),
775
- updatedAt: z3.iso.datetime(),
776
- user: storedProfileUserSchema
777
- }).strict();
778
- var contentProfileResultDataSchema = z3.object({
779
- profile: contentProfileSchema,
780
- profilePath: z3.literal("~/.dxc/content-profile.json"),
781
- userMemoryPath: z3.literal("~/.dxc/USER.md")
782
- }).strict();
783
- var contentProfileStatusResultSchema = z3.object({
784
- command: z3.literal("profile.status"),
785
- data: z3.discriminatedUnion("configured", [
786
- z3.object({
787
- configured: z3.literal(false),
788
- profilePath: z3.literal("~/.dxc/content-profile.json"),
789
- userMemoryPath: z3.literal("~/.dxc/USER.md")
790
- }).strict(),
791
- contentProfileResultDataSchema.extend({ configured: z3.literal(true) }).strict()
792
- ]),
793
- ok: z3.literal(true)
794
- }).strict();
795
- var contentProfileSessionIdSchema = z3.uuid();
796
- var contentProfileQuestionSchema = z3.object({
797
- choices: z3.array(
798
- z3.object({
799
- choiceId: z3.string().regex(/^profile_[a-z0-9.-]+$/u),
800
- label: z3.string().trim().min(1).max(120)
801
- }).strict()
802
- ).max(12),
803
- inputType: z3.enum(["multi-choice", "single-choice", "text"]),
804
- prompt: z3.string().trim().min(1).max(500),
805
- questionId: z3.string().regex(/^[a-z][a-z0-9.-]{1,63}$/u)
806
- }).strict();
807
- var contentProfileSessionResultSchema = z3.object({
808
- command: z3.enum(["profile.answer", "profile.begin"]),
809
- data: z3.discriminatedUnion("status", [
810
- z3.object({
811
- profileSessionId: contentProfileSessionIdSchema,
812
- question: contentProfileQuestionSchema,
813
- status: z3.literal("question")
814
- }).strict(),
815
- z3.object({
816
- profile: contentProfileSchema,
817
- profilePath: z3.literal("~/.dxc/content-profile.json"),
818
- status: z3.literal("completed"),
819
- userMemoryPath: z3.literal("~/.dxc/USER.md")
820
- }).strict()
821
- ]),
822
- ok: z3.literal(true)
823
- }).strict();
824
- var contentProfileCommandSchema = z3.enum([
825
- "profile.answer",
826
- "profile.begin",
827
- "profile.status"
828
- ]);
829
- var contentProfileErrorResultSchema = z3.object({
830
- command: contentProfileCommandSchema,
831
- error: z3.object({
832
- code: z3.enum(["DXC_PROFILE_INPUT_INVALID", "DXC_PROFILE_INVALID", "DXC_PROFILE_IO_FAILED"]),
833
- fields: z3.array(z3.string().trim().min(1)).optional(),
834
- hint: z3.string().trim().min(1).optional(),
835
- message: z3.string().trim().min(1)
836
- }).strict(),
837
- ok: z3.literal(false)
838
- }).strict();
839
- var CONTENT_MEMORY_KINDS = [
840
- "audience-change",
841
- "brand-context",
842
- "business-context",
843
- "temporary-campaign",
844
- "writing-preference"
845
- ];
846
- var contentMemoryKindSchema = z3.enum(CONTENT_MEMORY_KINDS);
847
- var contentMemoryScopeSchema = z3.enum(["global", "project"]);
848
- var contentMemoryInputSchema = z3.object({
849
- content: z3.string().trim().min(1).max(500),
850
- expiresAt: z3.iso.datetime().optional(),
851
- kind: contentMemoryKindSchema,
852
- scope: contentMemoryScopeSchema
853
- }).strict().refine((input) => input.kind !== "temporary-campaign" || input.expiresAt !== void 0, {
854
- message: "temporary campaign memory requires an expiry time"
855
- });
856
- var contentMemoryRecordSchema = contentMemoryInputSchema.and(
857
- z3.object({
858
- createdAt: z3.iso.datetime(),
859
- id: z3.uuid(),
860
- source: z3.literal("user-stated"),
861
- status: z3.enum(["active", "archived", "expired"]),
862
- updatedAt: z3.iso.datetime()
863
- }).strict()
864
- );
865
- var contentMemoryStoreSchema = z3.object({ memories: z3.array(contentMemoryRecordSchema).max(100), schemaVersion: z3.literal("1") }).strict();
866
- var contentMemoryResultDataSchema = z3.object({
867
- memories: z3.array(contentMemoryRecordSchema),
868
- memoryPath: z3.literal("~/.dxc/content-memory.json")
869
- }).strict();
870
- var contentMemoryAddResultSchema = z3.object({
871
- command: z3.literal("memory.add"),
872
- data: contentMemoryResultDataSchema.extend({ memory: contentMemoryRecordSchema }),
873
- ok: z3.literal(true)
874
- }).strict();
875
- var contentMemoryArchiveResultSchema = z3.object({
876
- command: z3.literal("memory.archive"),
877
- data: contentMemoryResultDataSchema.extend({ memory: contentMemoryRecordSchema }),
878
- ok: z3.literal(true)
879
- }).strict();
880
- var contentMemoryCorrectResultSchema = z3.object({
881
- command: z3.literal("memory.correct"),
882
- data: contentMemoryResultDataSchema.extend({
883
- archivedMemory: contentMemoryRecordSchema,
884
- memory: contentMemoryRecordSchema
885
- }),
886
- ok: z3.literal(true)
887
- }).strict();
888
- var contentMemoryListResultSchema = z3.object({
889
- command: z3.literal("memory.list"),
890
- data: contentMemoryResultDataSchema,
891
- ok: z3.literal(true)
892
- }).strict();
893
- var contentMemoryCommandSchema = z3.enum([
894
- "memory.add",
895
- "memory.archive",
896
- "memory.correct",
897
- "memory.list"
898
- ]);
899
- var contentMemoryErrorResultSchema = z3.object({
900
- command: contentMemoryCommandSchema,
901
- error: z3.object({
902
- code: z3.enum([
903
- "DXC_MEMORY_INPUT_INVALID",
904
- "DXC_MEMORY_INVALID",
905
- "DXC_MEMORY_IO_FAILED",
906
- "DXC_MEMORY_NOT_FOUND"
907
- ]),
908
- message: z3.string().trim().min(1)
909
- }).strict(),
910
- ok: z3.literal(false)
911
- }).strict();
912
-
913
- // packages/contracts/src/content-monitor.ts
914
- import { z as z5 } from "zod";
915
-
916
- // packages/contracts/src/content-source.ts
917
- import { z as z4 } from "zod";
918
- var sourceFetchKindSchema = z4.enum(["rss", "api", "html"]);
919
- var sourceExecutionLocationSchema = z4.literal("local-device");
920
- var sourceDataTransitSchema = z4.literal("local-only");
921
- var sourceCaptureMetadataSchema = z4.object({
922
- capturedAt: z4.iso.datetime(),
923
- contentHash: z4.string().regex(/^[a-f0-9]{64}$/u),
924
- dataTransit: sourceDataTransitSchema,
925
- executionLocation: sourceExecutionLocationSchema,
926
- extractor: z4.string().trim().min(1).max(120),
927
- finalUrl: z4.url(),
928
- mediaType: z4.string().trim().min(1).max(160),
929
- sourceUrl: z4.url()
930
- }).strict();
931
- var sourceFeedItemSchema = z4.object({
932
- id: z4.string().trim().min(1).max(256),
933
- publishedAt: z4.iso.datetime().optional(),
934
- summary: z4.string().trim().min(1).max(2e3).optional(),
935
- title: z4.string().trim().min(1).max(500),
936
- url: z4.url().optional()
937
- }).strict();
938
- var sourceHtmlDocumentSchema = z4.object({
939
- canonicalUrl: z4.url().optional(),
940
- excerpt: z4.string().trim().min(1).max(12e3),
941
- title: z4.string().trim().min(1).max(500)
942
- }).strict();
943
- var sourceFetchDataSchema = z4.discriminatedUnion("kind", [
944
- z4.object({
945
- capture: sourceCaptureMetadataSchema,
946
- items: z4.array(sourceFeedItemSchema).max(100),
947
- kind: z4.literal("rss")
948
- }).strict(),
949
- z4.object({
950
- capture: sourceCaptureMetadataSchema,
951
- kind: z4.literal("api"),
952
- payload: z4.unknown()
953
- }).strict(),
954
- z4.object({
955
- capture: sourceCaptureMetadataSchema,
956
- document: sourceHtmlDocumentSchema,
957
- kind: z4.literal("html")
958
- }).strict()
959
- ]);
960
- var sourceFetchResultSchema = z4.object({
961
- command: z4.literal("source.fetch"),
962
- data: sourceFetchDataSchema,
963
- ok: z4.literal(true)
964
- }).strict();
965
- var sourceFetchErrorResultSchema = z4.object({
966
- command: z4.literal("source.fetch"),
967
- error: z4.object({
968
- code: z4.enum([
969
- "DXC_SOURCE_AUTH_MISSING",
970
- "DXC_SOURCE_CONTENT_INVALID",
971
- "DXC_SOURCE_FETCH_FAILED",
972
- "DXC_SOURCE_REDIRECT_LIMIT",
973
- "DXC_SOURCE_RESPONSE_TOO_LARGE",
974
- "DXC_SOURCE_URL_BLOCKED",
975
- "DXC_SOURCE_URL_INVALID"
976
- ]).or(z4.literal("DXC_SOURCE_FAILED")),
977
- message: z4.string().trim().min(1).max(500),
978
- recovery: z4.string().trim().min(1).max(800).optional()
979
- }).strict(),
980
- ok: z4.literal(false)
981
- }).strict();
982
-
983
- // packages/contracts/src/content-monitor.ts
984
- var contentMonitorSourceSchema = z5.object({
985
- bearerEnvironment: z5.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u).nullable(),
986
- createdAt: z5.iso.datetime(),
987
- enabled: z5.boolean(),
988
- headerEnvironments: z5.array(
989
- z5.object({
990
- environment: z5.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
991
- header: z5.string().regex(/^[A-Za-z0-9-]+$/u)
992
- }).strict()
993
- ).max(12),
994
- id: z5.uuid(),
995
- kind: sourceFetchKindSchema,
996
- name: z5.string().trim().min(1).max(120),
997
- rssLimit: z5.number().int().min(1).max(100).nullable(),
998
- url: z5.url()
999
- }).strict();
1000
- var contentMonitorSourceSummarySchema = contentMonitorSourceSchema.extend({
1001
- lastRunAt: z5.iso.datetime().nullable(),
1002
- lastRunSummary: z5.string().trim().min(1).max(200).nullable(),
1003
- latestItemAt: z5.iso.datetime().nullable(),
1004
- observedItemCount: z5.number().int().nonnegative()
1005
- });
1006
- var contentMonitorRunSourceResultSchema = z5.object({
1007
- failureMessage: z5.string().trim().min(1).max(500).nullable(),
1008
- monitoredItemCount: z5.number().int().nonnegative(),
1009
- newItemCount: z5.number().int().nonnegative(),
1010
- sourceId: z5.uuid(),
1011
- sourceName: z5.string().trim().min(1).max(120),
1012
- summary: z5.string().trim().min(1).max(200),
1013
- unchangedItemCount: z5.number().int().nonnegative(),
1014
- updatedItemCount: z5.number().int().nonnegative()
1015
- }).strict();
1016
- var contentMonitorAddResultSchema = z5.object({
1017
- command: z5.literal("monitor.add"),
1018
- data: z5.object({
1019
- source: contentMonitorSourceSchema,
1020
- summary: z5.string().trim().min(1).max(200)
1021
- }).strict(),
1022
- ok: z5.literal(true)
1023
- }).strict();
1024
- var contentMonitorListResultSchema = z5.object({
1025
- command: z5.literal("monitor.list"),
1026
- data: z5.object({
1027
- sources: z5.array(contentMonitorSourceSummarySchema),
1028
- summary: z5.string().trim().min(1).max(200)
1029
- }).strict(),
1030
- ok: z5.literal(true)
1031
- }).strict();
1032
- var contentMonitorRunResultSchema = z5.object({
1033
- command: z5.literal("monitor.run"),
1034
- data: z5.object({
1035
- failedSourceCount: z5.number().int().nonnegative(),
1036
- finishedAt: z5.iso.datetime(),
1037
- results: z5.array(contentMonitorRunSourceResultSchema),
1038
- startedAt: z5.iso.datetime(),
1039
- summary: z5.string().trim().min(1).max(200)
1040
- }).strict(),
1041
- ok: z5.literal(true)
1042
- }).strict();
1043
- var contentMonitorStatusResultSchema = z5.object({
1044
- command: z5.literal("monitor.status"),
1045
- data: z5.object({
1046
- databasePath: z5.literal("~/.dxc/source-monitor.sqlite"),
1047
- enabledSourceCount: z5.number().int().nonnegative(),
1048
- latestRunAt: z5.iso.datetime().nullable(),
1049
- latestRunSummary: z5.string().trim().min(1).max(200).nullable(),
1050
- sourceCount: z5.number().int().nonnegative(),
1051
- summary: z5.string().trim().min(1).max(200)
1052
- }).strict(),
1053
- ok: z5.literal(true)
1054
- }).strict();
1055
- var contentMonitorRemoveResultSchema = z5.object({
1056
- command: z5.literal("monitor.remove"),
1057
- data: z5.object({
1058
- removed: z5.boolean(),
1059
- sourceId: z5.uuid(),
1060
- summary: z5.string().trim().min(1).max(200)
1061
- }).strict(),
1062
- ok: z5.literal(true)
1063
- }).strict();
1064
- var contentMonitorCommandSchema = z5.enum([
1065
- "monitor.add",
1066
- "monitor.list",
1067
- "monitor.remove",
1068
- "monitor.run",
1069
- "monitor.status"
1070
- ]);
1071
- var contentMonitorErrorResultSchema = z5.object({
1072
- command: contentMonitorCommandSchema,
1073
- error: z5.object({
1074
- code: z5.enum([
1075
- "DXC_MONITOR_IO_FAILED",
1076
- "DXC_MONITOR_SCHEMA_UNSUPPORTED",
1077
- "DXC_MONITOR_SOURCE_INVALID",
1078
- "DXC_MONITOR_SOURCE_NOT_FOUND",
1079
- "DXC_MONITOR_STATE_INVALID"
1080
- ]),
1081
- message: z5.string().trim().min(1).max(500)
1082
- }).strict(),
1083
- ok: z5.literal(false)
1084
- }).strict();
1085
-
1086
- // packages/contracts/src/index.ts
1087
- var liveHealthResponseSchema = z6.object({
1088
- status: z6.literal("ok")
1089
- }).strict();
1090
- var readyHealthResponseSchema = z6.object({
1091
- status: z6.literal("ready"),
1092
- checks: z6.object({
1093
- configuration: z6.literal("ok")
1094
- }).strict()
1095
- }).strict();
1096
- var versionResultSchema = z6.object({
1097
- ok: z6.literal(true),
1098
- command: z6.literal("version"),
1099
- data: z6.object({
1100
- cliVersion: z6.string().min(1),
1101
- nodeVersion: z6.string().min(1)
1102
- }).strict()
1103
- }).strict();
1104
- var doctorCheckSchema = z6.object({
1105
- name: z6.enum(["node-runtime", "working-directory"]),
1106
- status: z6.enum(["ok", "error"]),
1107
- message: z6.string().min(1)
1108
- }).strict();
1109
- var doctorResultSchema = z6.object({
1110
- ok: z6.boolean(),
1111
- command: z6.literal("doctor"),
1112
- data: z6.object({
1113
- status: z6.enum(["ok", "error"]),
1114
- checks: z6.array(doctorCheckSchema)
1115
- }).strict()
1116
- }).strict();
1117
- var articleAssetSchema = z6.object({
1118
- logicalPath: z6.string().trim().min(1),
1119
- role: z6.enum(["cover", "inline"])
1120
- }).strict();
1121
- var articleBundleSchema = z6.object({
1122
- schemaVersion: z6.literal("1"),
1123
- title: z6.string().trim().min(1),
1124
- author: z6.string().trim().min(1),
1125
- digest: z6.string().trim().min(1),
1126
- templateHint: wechatTemplateIdSchema.optional(),
1127
- coverImage: z6.string().trim().min(1).optional(),
1128
- commentsEnabled: z6.boolean(),
1129
- tags: z6.array(z6.string().trim().min(1)),
1130
- markdown: z6.string().trim().min(1),
1131
- assets: z6.array(articleAssetSchema)
1132
- }).strict();
1133
- var preflightIssueSchema = z6.object({
1134
- code: z6.string().trim().min(1),
1135
- path: z6.string().trim().min(1).optional(),
1136
- message: z6.string().trim().min(1)
1137
- }).strict();
1138
- var preflightResultSchema = z6.object({
1139
- ok: z6.boolean(),
1140
- errors: z6.array(preflightIssueSchema),
1141
- warnings: z6.array(preflightIssueSchema),
1142
- metrics: z6.object({
1143
- digestCharacters: z6.number().int().nonnegative(),
1144
- htmlCharacters: z6.number().int().nonnegative(),
1145
- imageCount: z6.number().int().nonnegative(),
1146
- externalLinkCount: z6.number().int().nonnegative(),
1147
- tableCount: z6.number().int().nonnegative()
1148
- }).strict()
1149
- }).strict();
1150
- var wechatRenderResultSchema = z6.object({
1151
- templateId: wechatTemplateIdSchema,
1152
- rendererVersion: z6.string().trim().min(1),
1153
- sourceHash: z6.string().regex(/^[a-f0-9]{64}$/u),
1154
- htmlHash: z6.string().regex(/^[a-f0-9]{64}$/u),
1155
- html: z6.string().min(1),
1156
- preflight: preflightResultSchema
1157
- }).strict();
1158
- var wechatPermissionIdSchema = z6.union([z6.literal(3), z6.literal(11)]);
1159
- var deviceBindingSessionStatusSchema = z6.enum([
1160
- "CREATED",
1161
- "PROVED",
1162
- "AUTHORIZATION_PENDING",
1163
- "BOUND",
1164
- "EXPIRED",
1165
- "FAILED"
1166
- ]);
1167
- var createDeviceBindingSessionRequestSchema = z6.object({
1168
- deviceName: z6.string().trim().min(1).max(80),
1169
- installationId: z6.uuid(),
1170
- publicKeyPem: z6.string().min(80).max(2048)
1171
- }).strict();
1172
- var createDeviceBindingSessionResponseSchema = z6.object({
1173
- challenge: z6.string().regex(/^[A-Za-z0-9_-]{43,128}$/u),
1174
- expiresAt: z6.iso.datetime(),
1175
- id: z6.uuid()
1176
- }).strict();
1177
- var proveDeviceBindingSessionRequestSchema = z6.object({
1178
- challenge: z6.string().regex(/^[A-Za-z0-9_-]{43,128}$/u),
1179
- deviceRefreshTokenHash: z6.string().regex(/^[a-f0-9]{64}$/u).optional(),
1180
- deviceSessionTokenHash: z6.string().regex(/^[a-f0-9]{64}$/u),
1181
- signature: z6.string().regex(/^[A-Za-z0-9_-]{64,256}$/u)
1182
- }).strict();
1183
- var proveDeviceBindingSessionResponseSchema = z6.object({
1184
- bindingToken: z6.string().min(32).max(256),
1185
- expiresAt: z6.iso.datetime(),
1186
- id: z6.uuid(),
1187
- status: z6.literal("PROVED")
1188
- }).strict();
1189
- var deviceSessionIdentitySchema = z6.object({
1190
- deviceId: z6.uuid(),
1191
- deviceName: z6.string().trim().min(1).max(80),
1192
- expiresAt: z6.iso.datetime(),
1193
- tenantId: z6.uuid(),
1194
- userId: z6.uuid()
1195
- }).strict();
1196
- var deviceSessionStatusResponseSchema = z6.object({
1197
- identity: deviceSessionIdentitySchema
1198
- }).strict();
1199
- var deviceSessionCredentialEnrollmentRequestSchema = z6.object({
1200
- refreshTokenHash: z6.string().regex(/^[a-f0-9]{64}$/u),
1201
- signature: z6.string().regex(/^[A-Za-z0-9_-]{64,256}$/u)
1202
- }).strict();
1203
- var deviceSessionRefreshRequestSchema = z6.object({
1204
- nextDeviceSessionTokenHash: z6.string().regex(/^[a-f0-9]{64}$/u),
1205
- nextRefreshTokenHash: z6.string().regex(/^[a-f0-9]{64}$/u),
1206
- refreshToken: z6.string().regex(/^[A-Za-z0-9_-]{43,256}$/u),
1207
- rotationId: z6.uuid(),
1208
- signature: z6.string().regex(/^[A-Za-z0-9_-]{64,256}$/u)
1209
- }).strict();
1210
- var wechatLoginSessionPurposeSchema = z6.enum(["link", "login", "start"]);
1211
- var wechatLoginSessionStatusSchema = z6.enum([
1212
- "URL_READY",
1213
- "EXCHANGING",
1214
- "IDENTIFIED",
1215
- "SUCCEEDED",
1216
- "EXPIRED",
1217
- "FAILED"
1218
- ]);
1219
- var wechatLoginFailureCodeSchema = z6.enum([
1220
- "WECHAT_LOGIN_DEVICE_UNAUTHORIZED",
1221
- "WECHAT_LOGIN_IDENTITY_CONFLICT",
1222
- "WECHAT_LOGIN_IDENTITY_NOT_LINKED",
1223
- "WECHAT_LOGIN_PROVIDER_FAILED",
1224
- "WECHAT_LOGIN_SESSION_INVALID"
1225
- ]);
1226
- var createWechatLoginSessionRequestSchema = z6.object({
1227
- purpose: wechatLoginSessionPurposeSchema
1228
- }).strict();
1229
- var createWechatLoginSessionResponseSchema = z6.object({
1230
- authorizationUrl: z6.url(),
1231
- expiresAt: z6.iso.datetime(),
1232
- id: z6.uuid(),
1233
- pollToken: z6.string().min(32).max(256),
1234
- purpose: wechatLoginSessionPurposeSchema
1235
- }).strict();
1236
- var wechatLoginSessionResponseSchema = z6.object({
1237
- expiresAt: z6.iso.datetime(),
1238
- failureCode: wechatLoginFailureCodeSchema.optional(),
1239
- id: z6.uuid(),
1240
- identity: deviceSessionIdentitySchema.optional(),
1241
- purpose: wechatLoginSessionPurposeSchema,
1242
- status: wechatLoginSessionStatusSchema
1243
- }).strict().superRefine((session, context) => {
1244
- if (session.status === "SUCCEEDED" && session.identity === void 0) {
1245
- context.addIssue({
1246
- code: "custom",
1247
- message: "successful login session requires an identity"
1248
- });
1249
- }
1250
- if (session.status === "FAILED" && session.failureCode === void 0) {
1251
- context.addIssue({
1252
- code: "custom",
1253
- message: "failed login session requires a failure code"
1254
- });
1255
- }
1256
- if (session.status !== "FAILED" && session.failureCode !== void 0) {
1257
- context.addIssue({
1258
- code: "custom",
1259
- message: "only failed login session may expose a failure code"
1260
- });
1261
- }
1262
- });
1263
- var wechatAccountSchema = z6.object({
1264
- id: z6.uuid(),
1265
- displayName: z6.string().trim().min(1),
1266
- accountType: z6.string().trim().min(1),
1267
- status: z6.enum(["ACTIVE", "PERMISSION_CHANGED", "REVOKED"]),
1268
- permissions: z6.array(wechatPermissionIdSchema),
1269
- draftCapability: z6.enum(["available", "missing", "revoked"])
1270
- }).strict();
1271
- var createWechatAuthorizationSessionResponseSchema = z6.object({
1272
- id: z6.uuid(),
1273
- authorizationUrl: z6.url(),
1274
- pollToken: z6.string().min(32).max(256),
1275
- expiresAt: z6.iso.datetime()
1276
- }).strict();
1277
- var wechatAuthorizationSessionResponseSchema = z6.object({
1278
- id: z6.uuid(),
1279
- status: z6.enum(["URL_READY", "EXCHANGING", "AUTHORIZED", "BOUND", "EXPIRED", "FAILED"]),
1280
- expiresAt: z6.iso.datetime(),
1281
- account: wechatAccountSchema.optional()
1282
- }).strict();
1283
- var wechatAccountsResponseSchema = z6.object({
1284
- accounts: z6.array(wechatAccountSchema)
1285
- }).strict();
1286
- var apiErrorResponseSchema = z6.object({
1287
- error: z6.object({
1288
- code: z6.string().trim().min(1),
1289
- message: z6.string().trim().min(1),
1290
- retryable: z6.boolean()
1291
- }).strict()
1292
- }).strict();
1293
-
1294
- // apps/cli/src/local-state.ts
1295
- import { randomUUID } from "node:crypto";
1296
- import { constants as fileConstants } from "node:fs";
1297
- import { chmod, lstat, mkdir, open, rename, unlink } from "node:fs/promises";
1298
- import path from "node:path";
1299
- var LocalStateError = class extends Error {
1300
- constructor(failure) {
1301
- super(failure);
1302
- this.failure = failure;
1303
- this.name = "LocalStateError";
1304
- }
1305
- failure;
1306
- };
1307
- function errorCode(error) {
1308
- return typeof error === "object" && error !== null && "code" in error ? String(error.code) : void 0;
1309
- }
1310
- function ownedByCurrentUser(userId, ownerId) {
1311
- return userId === void 0 || userId === ownerId;
1312
- }
1313
- async function ensurePrivateDirectory(directory) {
1314
- try {
1315
- await mkdir(directory, { mode: 448, recursive: true });
1316
- const metadata = await lstat(directory);
1317
- const userId = typeof process.getuid === "function" ? process.getuid() : void 0;
1318
- if (!metadata.isDirectory() || metadata.isSymbolicLink() || !ownedByCurrentUser(userId, metadata.uid)) {
1319
- throw new LocalStateError("invalid");
1320
- }
1321
- await chmod(directory, 448);
1322
- } catch (error) {
1323
- if (error instanceof LocalStateError) {
1324
- throw error;
1325
- }
1326
- if (errorCode(error) === "ELOOP") {
1327
- throw new LocalStateError("invalid");
1328
- }
1329
- throw new LocalStateError("io");
1330
- }
1331
- }
1332
- async function ensurePrivateRegularFile(target) {
1333
- await ensurePrivateDirectory(path.dirname(target));
1334
- let handle;
1335
- try {
1336
- handle = await open(
1337
- target,
1338
- fileConstants.O_CREAT | fileConstants.O_RDWR | fileConstants.O_NOFOLLOW,
1339
- 384
1340
- );
1341
- const metadata = await handle.stat();
1342
- const userId = typeof process.getuid === "function" ? process.getuid() : void 0;
1343
- if (!metadata.isFile() || !ownedByCurrentUser(userId, metadata.uid)) {
1344
- throw new LocalStateError("invalid");
1345
- }
1346
- await handle.chmod(384);
1347
- } catch (error) {
1348
- if (error instanceof LocalStateError) {
1349
- throw error;
1350
- }
1351
- if (errorCode(error) === "ELOOP") {
1352
- throw new LocalStateError("invalid");
1353
- }
1354
- throw new LocalStateError("io");
1355
- } finally {
1356
- await handle?.close();
1357
- }
1358
- }
1359
- async function readPrivateFile(target, maximumBytes) {
1360
- const contents = await readPrivateBuffer(target, maximumBytes);
1361
- return contents.toString("utf8");
1362
- }
1363
- async function readPrivateBuffer(target, maximumBytes) {
1364
- let handle;
1365
- try {
1366
- handle = await open(target, fileConstants.O_RDONLY | fileConstants.O_NOFOLLOW);
1367
- } catch (error) {
1368
- if (errorCode(error) === "ENOENT") {
1369
- throw new LocalStateError("missing");
1370
- }
1371
- if (errorCode(error) === "ELOOP") {
1372
- throw new LocalStateError("invalid");
1373
- }
1374
- throw new LocalStateError("io");
1375
- }
1376
- try {
1377
- const metadata = await handle.stat();
1378
- const userId = typeof process.getuid === "function" ? process.getuid() : void 0;
1379
- if (!metadata.isFile() || !ownedByCurrentUser(userId, metadata.uid) || metadata.size > maximumBytes || process.platform !== "win32" && (metadata.mode & 63) !== 0) {
1380
- throw new LocalStateError("invalid");
1381
- }
1382
- return await handle.readFile();
1383
- } catch (error) {
1384
- if (error instanceof LocalStateError) {
1385
- throw error;
1386
- }
1387
- throw new LocalStateError("io");
1388
- } finally {
1389
- await handle.close();
1390
- }
1391
- }
1392
- async function writePrivateJson(target, value) {
1393
- await writePrivateBuffer(target, Buffer.from(`${JSON.stringify(value, void 0, 2)}
1394
- `, "utf8"));
1395
- }
1396
- async function writePrivateBuffer(target, value) {
1397
- const directory = path.dirname(target);
1398
- await ensurePrivateDirectory(directory);
1399
- const temporary = path.join(directory, `.${path.basename(target)}.${randomUUID()}.tmp`);
1400
- let handle;
1401
- try {
1402
- handle = await open(
1403
- temporary,
1404
- fileConstants.O_CREAT | fileConstants.O_EXCL | fileConstants.O_WRONLY | fileConstants.O_NOFOLLOW,
1405
- 384
1406
- );
1407
- await handle.writeFile(value);
1408
- await handle.sync();
1409
- await handle.close();
1410
- handle = void 0;
1411
- await rename(temporary, target);
1412
- await chmod(target, 384);
1413
- } catch (error) {
1414
- throw error instanceof LocalStateError ? error : new LocalStateError("io");
1415
- } finally {
1416
- await handle?.close();
1417
- await unlink(temporary).catch(() => void 0);
1418
- }
1419
- }
1420
-
1421
- // apps/cli/src/user-path.ts
1422
- import path2 from "node:path";
1423
- function expandHome(input, homeDirectory, pathApi) {
1424
- if (input === "~") {
1425
- return homeDirectory;
1426
- }
1427
- if (input.startsWith("~/") || input.startsWith("~\\")) {
1428
- return pathApi.join(homeDirectory, input.slice(2));
1429
- }
1430
- return input;
1431
- }
1432
- function windowsShellPath(input) {
1433
- const msys = /^\/([a-z])(?:\/(.*))?$/iu.exec(input);
1434
- if (msys !== null) {
1435
- return `${msys[1]?.toUpperCase()}:\\${(msys[2] ?? "").replaceAll("/", "\\")}`;
1436
- }
1437
- const mounted = /^\/(?:cygdrive|mnt)\/([a-z])(?:\/(.*))?$/iu.exec(input);
1438
- if (mounted !== null) {
1439
- return `${mounted[1]?.toUpperCase()}:\\${(mounted[2] ?? "").replaceAll("/", "\\")}`;
1440
- }
1441
- return input;
1442
- }
1443
- function resolveUserPath(options) {
1444
- const platform = options.platform ?? process.platform;
1445
- const pathApi = platform === "win32" ? path2.win32 : path2.posix;
1446
- const expanded = expandHome(options.input, options.homeDirectory, pathApi);
1447
- if (platform === "win32") {
1448
- return pathApi.resolve(options.currentDirectory, windowsShellPath(expanded));
1449
- }
1450
- return pathApi.resolve(options.currentDirectory, expanded);
1451
- }
1452
-
1453
- export {
1454
- __require,
1455
- __esm,
1456
- __commonJS,
1457
- __export,
1458
- __toESM,
1459
- __toCommonJS,
1460
- publishingUploadSessionSchema,
1461
- publishingUploadReceiptSchema,
1462
- publishingArticleSchema,
1463
- publishingRenderSnapshotSchema,
1464
- publishingPreviewLinkSchema,
1465
- publishingPreviewSelectionStateSchema,
1466
- createPublishingApprovalRequestSchema,
1467
- publishingApprovalSchema,
1468
- publishingDraftIntentResponseSchema,
1469
- publishingDraftAttentionDiagnosticsSchema,
1470
- CONTENT_WORKFLOW_ID,
1471
- CONTENT_ARTIFACT_KINDS,
1472
- CONTENT_STAGE_DEFINITIONS,
1473
- portableRelativePathSchema,
1474
- contentProjectManifestSchema,
1475
- contentProjectIndexSchema,
1476
- contentProfileInputSchema,
1477
- contentProfileSchema,
1478
- contentProfileStatusResultSchema,
1479
- contentProfileSessionResultSchema,
1480
- contentMemoryInputSchema,
1481
- contentMemoryStoreSchema,
1482
- contentMemoryAddResultSchema,
1483
- contentMemoryArchiveResultSchema,
1484
- contentMemoryCorrectResultSchema,
1485
- contentMemoryListResultSchema,
1486
- CONTENT_KNOWLEDGE_SCHEMA_VERSION,
1487
- CONTENT_KNOWLEDGE_EMBEDDING_MODEL,
1488
- CONTENT_KNOWLEDGE_EMBEDDING_REVISION,
1489
- CONTENT_KNOWLEDGE_EMBEDDING_DIMENSIONS,
1490
- CONTENT_KNOWLEDGE_EMBEDDING_QUANTIZATION,
1491
- CONTENT_KNOWLEDGE_CHUNKER_VERSION,
1492
- contentKnowledgeSearchModeSchema,
1493
- contentKnowledgeModelSchema,
1494
- contentKnowledgeImportResultSchema,
1495
- contentKnowledgeQuoteListResultSchema,
1496
- contentKnowledgeQuoteMutationResultSchema,
1497
- contentKnowledgeQuoteStatusResultSchema,
1498
- contentKnowledgeSearchResultSchema,
1499
- contentKnowledgeStatusResultSchema,
1500
- contentKnowledgeRemoveResultSchema,
1501
- doctorResultSchema,
1502
- articleBundleSchema,
1503
- preflightResultSchema,
1504
- wechatRenderResultSchema,
1505
- createDeviceBindingSessionResponseSchema,
1506
- proveDeviceBindingSessionResponseSchema,
1507
- deviceSessionStatusResponseSchema,
1508
- createWechatLoginSessionResponseSchema,
1509
- wechatLoginSessionResponseSchema,
1510
- createWechatAuthorizationSessionResponseSchema,
1511
- wechatAuthorizationSessionResponseSchema,
1512
- wechatAccountsResponseSchema,
1513
- apiErrorResponseSchema,
1514
- LocalStateError,
1515
- ensurePrivateDirectory,
1516
- ensurePrivateRegularFile,
1517
- readPrivateFile,
1518
- readPrivateBuffer,
1519
- writePrivateJson,
1520
- writePrivateBuffer,
1521
- resolveUserPath
1522
- };