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