@xemahq/kernel-contracts 0.29.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/dist/document-patch/index.d.ts +4 -0
  2. package/dist/document-patch/index.d.ts.map +1 -0
  3. package/dist/document-patch/index.js +20 -0
  4. package/dist/document-patch/index.js.map +1 -0
  5. package/dist/document-patch/lib/patch-anchor.d.ts +7 -0
  6. package/dist/document-patch/lib/patch-anchor.d.ts.map +1 -0
  7. package/dist/document-patch/lib/patch-anchor.js +14 -0
  8. package/dist/document-patch/lib/patch-anchor.js.map +1 -0
  9. package/dist/document-patch/lib/patch-enums.d.ts +11 -0
  10. package/dist/document-patch/lib/patch-enums.d.ts.map +1 -0
  11. package/dist/document-patch/lib/patch-enums.js +16 -0
  12. package/dist/document-patch/lib/patch-enums.js.map +1 -0
  13. package/dist/document-patch/lib/pending-patch.d.ts +22 -0
  14. package/dist/document-patch/lib/pending-patch.d.ts.map +1 -0
  15. package/dist/document-patch/lib/pending-patch.js +3 -0
  16. package/dist/document-patch/lib/pending-patch.js.map +1 -0
  17. package/dist/output/index.d.ts +7 -0
  18. package/dist/output/index.d.ts.map +1 -0
  19. package/dist/output/index.js +23 -0
  20. package/dist/output/index.js.map +1 -0
  21. package/dist/output/lib/output-deliverable-expectation.d.ts +9 -0
  22. package/dist/output/lib/output-deliverable-expectation.d.ts.map +1 -0
  23. package/dist/output/lib/output-deliverable-expectation.js +3 -0
  24. package/dist/output/lib/output-deliverable-expectation.js.map +1 -0
  25. package/dist/output/lib/output-item-dto.d.ts +25 -0
  26. package/dist/output/lib/output-item-dto.d.ts.map +1 -0
  27. package/dist/output/lib/output-item-dto.js +3 -0
  28. package/dist/output/lib/output-item-dto.js.map +1 -0
  29. package/dist/output/lib/output-kind.d.ts +14 -0
  30. package/dist/output/lib/output-kind.d.ts.map +1 -0
  31. package/dist/output/lib/output-kind.js +18 -0
  32. package/dist/output/lib/output-kind.js.map +1 -0
  33. package/dist/output/lib/output-render-hint.d.ts +11 -0
  34. package/dist/output/lib/output-render-hint.d.ts.map +1 -0
  35. package/dist/output/lib/output-render-hint.js +10 -0
  36. package/dist/output/lib/output-render-hint.js.map +1 -0
  37. package/dist/output/lib/output-version-dto.d.ts +10 -0
  38. package/dist/output/lib/output-version-dto.d.ts.map +1 -0
  39. package/dist/output/lib/output-version-dto.js +3 -0
  40. package/dist/output/lib/output-version-dto.js.map +1 -0
  41. package/dist/output/lib/payload-schemas/code-diff.d.ts +7 -0
  42. package/dist/output/lib/payload-schemas/code-diff.d.ts.map +1 -0
  43. package/dist/output/lib/payload-schemas/code-diff.js +11 -0
  44. package/dist/output/lib/payload-schemas/code-diff.js.map +1 -0
  45. package/dist/output/lib/payload-schemas/decision-record.d.ts +19 -0
  46. package/dist/output/lib/payload-schemas/decision-record.d.ts.map +1 -0
  47. package/dist/output/lib/payload-schemas/decision-record.js +39 -0
  48. package/dist/output/lib/payload-schemas/decision-record.js.map +1 -0
  49. package/dist/output/lib/payload-schemas/diagram.d.ts +12 -0
  50. package/dist/output/lib/payload-schemas/diagram.d.ts.map +1 -0
  51. package/dist/output/lib/payload-schemas/diagram.js +34 -0
  52. package/dist/output/lib/payload-schemas/diagram.js.map +1 -0
  53. package/dist/output/lib/payload-schemas/external-blob.d.ts +9 -0
  54. package/dist/output/lib/payload-schemas/external-blob.d.ts.map +1 -0
  55. package/dist/output/lib/payload-schemas/external-blob.js +15 -0
  56. package/dist/output/lib/payload-schemas/external-blob.js.map +1 -0
  57. package/dist/output/lib/payload-schemas/index.d.ts +17 -0
  58. package/dist/output/lib/payload-schemas/index.d.ts.map +1 -0
  59. package/dist/output/lib/payload-schemas/index.js +94 -0
  60. package/dist/output/lib/payload-schemas/index.js.map +1 -0
  61. package/dist/output/lib/payload-schemas/json-payload.d.ts +4 -0
  62. package/dist/output/lib/payload-schemas/json-payload.d.ts.map +1 -0
  63. package/dist/output/lib/payload-schemas/json-payload.js +9 -0
  64. package/dist/output/lib/payload-schemas/json-payload.js.map +1 -0
  65. package/dist/output/lib/payload-schemas/manifest.d.ts +37 -0
  66. package/dist/output/lib/payload-schemas/manifest.d.ts.map +1 -0
  67. package/dist/output/lib/payload-schemas/manifest.js +43 -0
  68. package/dist/output/lib/payload-schemas/manifest.js.map +1 -0
  69. package/dist/output/lib/payload-schemas/markdown-doc.d.ts +8 -0
  70. package/dist/output/lib/payload-schemas/markdown-doc.d.ts.map +1 -0
  71. package/dist/output/lib/payload-schemas/markdown-doc.js +12 -0
  72. package/dist/output/lib/payload-schemas/markdown-doc.js.map +1 -0
  73. package/dist/output/lib/payload-schemas/review-findings.d.ts +30 -0
  74. package/dist/output/lib/payload-schemas/review-findings.d.ts.map +1 -0
  75. package/dist/output/lib/payload-schemas/review-findings.js +39 -0
  76. package/dist/output/lib/payload-schemas/review-findings.js.map +1 -0
  77. package/dist/output/lib/payload-schemas/schema.d.ts +4 -0
  78. package/dist/output/lib/payload-schemas/schema.d.ts.map +1 -0
  79. package/dist/output/lib/payload-schemas/schema.js +10 -0
  80. package/dist/output/lib/payload-schemas/schema.js.map +1 -0
  81. package/dist/output/lib/payload-schemas/test-report.d.ts +33 -0
  82. package/dist/output/lib/payload-schemas/test-report.d.ts.map +1 -0
  83. package/dist/output/lib/payload-schemas/test-report.js +46 -0
  84. package/dist/output/lib/payload-schemas/test-report.js.map +1 -0
  85. package/dist/workspace-image/index.d.ts +5 -0
  86. package/dist/workspace-image/index.d.ts.map +1 -0
  87. package/dist/workspace-image/index.js +21 -0
  88. package/dist/workspace-image/index.js.map +1 -0
  89. package/dist/workspace-image/lib/enums.d.ts +17 -0
  90. package/dist/workspace-image/lib/enums.d.ts.map +1 -0
  91. package/dist/workspace-image/lib/enums.js +22 -0
  92. package/dist/workspace-image/lib/enums.js.map +1 -0
  93. package/dist/workspace-image/lib/hash.d.ts +3 -0
  94. package/dist/workspace-image/lib/hash.d.ts.map +1 -0
  95. package/dist/workspace-image/lib/hash.js +50 -0
  96. package/dist/workspace-image/lib/hash.js.map +1 -0
  97. package/dist/workspace-image/lib/schemas.d.ts +103 -0
  98. package/dist/workspace-image/lib/schemas.d.ts.map +1 -0
  99. package/dist/workspace-image/lib/schemas.js +53 -0
  100. package/dist/workspace-image/lib/schemas.js.map +1 -0
  101. package/dist/workspace-image/lib/types.d.ts +50 -0
  102. package/dist/workspace-image/lib/types.d.ts.map +1 -0
  103. package/dist/workspace-image/lib/types.js +3 -0
  104. package/dist/workspace-image/lib/types.js.map +1 -0
  105. package/package.json +1 -1
  106. package/src/document-patch/index.ts +25 -0
  107. package/src/document-patch/lib/patch-anchor.ts +22 -0
  108. package/src/document-patch/lib/patch-enums.ts +36 -0
  109. package/src/document-patch/lib/pending-patch.ts +31 -0
  110. package/src/output/index.ts +20 -0
  111. package/src/output/lib/output-deliverable-expectation.ts +25 -0
  112. package/src/output/lib/output-item-dto.ts +54 -0
  113. package/src/output/lib/output-kind.ts +44 -0
  114. package/src/output/lib/output-render-hint.ts +28 -0
  115. package/src/output/lib/output-version-dto.ts +21 -0
  116. package/src/output/lib/payload-schemas/code-diff.ts +20 -0
  117. package/src/output/lib/payload-schemas/decision-record.ts +71 -0
  118. package/src/output/lib/payload-schemas/diagram.ts +54 -0
  119. package/src/output/lib/payload-schemas/external-blob.ts +36 -0
  120. package/src/output/lib/payload-schemas/index.ts +133 -0
  121. package/src/output/lib/payload-schemas/json-payload.ts +19 -0
  122. package/src/output/lib/payload-schemas/manifest.ts +81 -0
  123. package/src/output/lib/payload-schemas/markdown-doc.ts +33 -0
  124. package/src/output/lib/payload-schemas/review-findings.ts +75 -0
  125. package/src/output/lib/payload-schemas/schema.ts +22 -0
  126. package/src/output/lib/payload-schemas/test-report.ts +69 -0
  127. package/src/workspace-image/index.ts +13 -0
  128. package/src/workspace-image/lib/enums.ts +38 -0
  129. package/src/workspace-image/lib/hash.ts +95 -0
  130. package/src/workspace-image/lib/schemas.ts +63 -0
  131. package/src/workspace-image/lib/types.ts +79 -0
@@ -0,0 +1,103 @@
1
+ import { z } from 'zod';
2
+ import { ImageLayerKind, VariantStatus } from './enums';
3
+ export declare const imageLayerKindSchema: z.ZodEnum<typeof ImageLayerKind>;
4
+ export declare const variantStatusSchema: z.ZodEnum<typeof VariantStatus>;
5
+ export declare const imageLayerSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
6
+ kind: z.ZodLiteral<ImageLayerKind.Apt>;
7
+ packages: z.ZodArray<z.ZodString>;
8
+ }, z.core.$strip>, z.ZodObject<{
9
+ kind: z.ZodLiteral<ImageLayerKind.Dnf>;
10
+ packages: z.ZodArray<z.ZodString>;
11
+ }, z.core.$strip>, z.ZodObject<{
12
+ kind: z.ZodLiteral<ImageLayerKind.Apk>;
13
+ packages: z.ZodArray<z.ZodString>;
14
+ }, z.core.$strip>, z.ZodObject<{
15
+ kind: z.ZodLiteral<ImageLayerKind.Pip>;
16
+ packages: z.ZodArray<z.ZodString>;
17
+ pythonVersion: z.ZodOptional<z.ZodString>;
18
+ }, z.core.$strip>, z.ZodObject<{
19
+ kind: z.ZodLiteral<ImageLayerKind.NpmGlobal>;
20
+ packages: z.ZodArray<z.ZodString>;
21
+ }, z.core.$strip>, z.ZodObject<{
22
+ kind: z.ZodLiteral<ImageLayerKind.Env>;
23
+ vars: z.ZodRecord<z.ZodString, z.ZodString>;
24
+ }, z.core.$strip>, z.ZodObject<{
25
+ kind: z.ZodLiteral<ImageLayerKind.File>;
26
+ path: z.ZodString;
27
+ contentBase64: z.ZodString;
28
+ mode: z.ZodOptional<z.ZodNumber>;
29
+ }, z.core.$strip>], "kind">;
30
+ export declare const workspaceImageManifestSchema: z.ZodObject<{
31
+ layers: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
32
+ kind: z.ZodLiteral<ImageLayerKind.Apt>;
33
+ packages: z.ZodArray<z.ZodString>;
34
+ }, z.core.$strip>, z.ZodObject<{
35
+ kind: z.ZodLiteral<ImageLayerKind.Dnf>;
36
+ packages: z.ZodArray<z.ZodString>;
37
+ }, z.core.$strip>, z.ZodObject<{
38
+ kind: z.ZodLiteral<ImageLayerKind.Apk>;
39
+ packages: z.ZodArray<z.ZodString>;
40
+ }, z.core.$strip>, z.ZodObject<{
41
+ kind: z.ZodLiteral<ImageLayerKind.Pip>;
42
+ packages: z.ZodArray<z.ZodString>;
43
+ pythonVersion: z.ZodOptional<z.ZodString>;
44
+ }, z.core.$strip>, z.ZodObject<{
45
+ kind: z.ZodLiteral<ImageLayerKind.NpmGlobal>;
46
+ packages: z.ZodArray<z.ZodString>;
47
+ }, z.core.$strip>, z.ZodObject<{
48
+ kind: z.ZodLiteral<ImageLayerKind.Env>;
49
+ vars: z.ZodRecord<z.ZodString, z.ZodString>;
50
+ }, z.core.$strip>, z.ZodObject<{
51
+ kind: z.ZodLiteral<ImageLayerKind.File>;
52
+ path: z.ZodString;
53
+ contentBase64: z.ZodString;
54
+ mode: z.ZodOptional<z.ZodNumber>;
55
+ }, z.core.$strip>], "kind">>;
56
+ workdir: z.ZodOptional<z.ZodString>;
57
+ }, z.core.$strip>;
58
+ export declare const workspaceImageVariantSchema: z.ZodObject<{
59
+ id: z.ZodString;
60
+ orgId: z.ZodString;
61
+ slug: z.ZodString;
62
+ description: z.ZodString;
63
+ runtimeKind: z.ZodEnum<typeof import("../../worker-runtime").WorkerRuntimeKind>;
64
+ baseImage: z.ZodString;
65
+ manifest: z.ZodObject<{
66
+ layers: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
67
+ kind: z.ZodLiteral<ImageLayerKind.Apt>;
68
+ packages: z.ZodArray<z.ZodString>;
69
+ }, z.core.$strip>, z.ZodObject<{
70
+ kind: z.ZodLiteral<ImageLayerKind.Dnf>;
71
+ packages: z.ZodArray<z.ZodString>;
72
+ }, z.core.$strip>, z.ZodObject<{
73
+ kind: z.ZodLiteral<ImageLayerKind.Apk>;
74
+ packages: z.ZodArray<z.ZodString>;
75
+ }, z.core.$strip>, z.ZodObject<{
76
+ kind: z.ZodLiteral<ImageLayerKind.Pip>;
77
+ packages: z.ZodArray<z.ZodString>;
78
+ pythonVersion: z.ZodOptional<z.ZodString>;
79
+ }, z.core.$strip>, z.ZodObject<{
80
+ kind: z.ZodLiteral<ImageLayerKind.NpmGlobal>;
81
+ packages: z.ZodArray<z.ZodString>;
82
+ }, z.core.$strip>, z.ZodObject<{
83
+ kind: z.ZodLiteral<ImageLayerKind.Env>;
84
+ vars: z.ZodRecord<z.ZodString, z.ZodString>;
85
+ }, z.core.$strip>, z.ZodObject<{
86
+ kind: z.ZodLiteral<ImageLayerKind.File>;
87
+ path: z.ZodString;
88
+ contentBase64: z.ZodString;
89
+ mode: z.ZodOptional<z.ZodNumber>;
90
+ }, z.core.$strip>], "kind">>;
91
+ workdir: z.ZodOptional<z.ZodString>;
92
+ }, z.core.$strip>;
93
+ contentHash: z.ZodString;
94
+ registryRef: z.ZodOptional<z.ZodString>;
95
+ status: z.ZodEnum<typeof VariantStatus>;
96
+ isOrgDefault: z.ZodBoolean;
97
+ autoRebake: z.ZodBoolean;
98
+ regions: z.ZodArray<z.ZodString>;
99
+ buildLog: z.ZodOptional<z.ZodString>;
100
+ builtAt: z.ZodOptional<z.ZodString>;
101
+ createdAt: z.ZodString;
102
+ }, z.core.$strip>;
103
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/workspace-image/lib/schemas.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExD,eAAO,MAAM,oBAAoB,kCAA+B,CAAC;AACjE,eAAO,MAAM,mBAAmB,iCAA8B,CAAC;AAI/D,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;2BAoB3B,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAGvC,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiBtC,CAAC"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.workspaceImageVariantSchema = exports.workspaceImageManifestSchema = exports.imageLayerSchema = exports.variantStatusSchema = exports.imageLayerKindSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const worker_runtime_1 = require("../../worker-runtime");
6
+ const enums_1 = require("./enums");
7
+ exports.imageLayerKindSchema = zod_1.z.nativeEnum(enums_1.ImageLayerKind);
8
+ exports.variantStatusSchema = zod_1.z.nativeEnum(enums_1.VariantStatus);
9
+ const packagesArray = zod_1.z.array(zod_1.z.string().min(1));
10
+ exports.imageLayerSchema = zod_1.z.discriminatedUnion('kind', [
11
+ zod_1.z.object({ kind: zod_1.z.literal(enums_1.ImageLayerKind.Apt), packages: packagesArray }),
12
+ zod_1.z.object({ kind: zod_1.z.literal(enums_1.ImageLayerKind.Dnf), packages: packagesArray }),
13
+ zod_1.z.object({ kind: zod_1.z.literal(enums_1.ImageLayerKind.Apk), packages: packagesArray }),
14
+ zod_1.z.object({
15
+ kind: zod_1.z.literal(enums_1.ImageLayerKind.Pip),
16
+ packages: packagesArray,
17
+ pythonVersion: zod_1.z.string().min(1).optional(),
18
+ }),
19
+ zod_1.z.object({ kind: zod_1.z.literal(enums_1.ImageLayerKind.NpmGlobal), packages: packagesArray }),
20
+ zod_1.z.object({
21
+ kind: zod_1.z.literal(enums_1.ImageLayerKind.Env),
22
+ vars: zod_1.z.record(zod_1.z.string().min(1), zod_1.z.string()),
23
+ }),
24
+ zod_1.z.object({
25
+ kind: zod_1.z.literal(enums_1.ImageLayerKind.File),
26
+ path: zod_1.z.string().min(1),
27
+ contentBase64: zod_1.z.string().min(1),
28
+ mode: zod_1.z.number().int().nonnegative().optional(),
29
+ }),
30
+ ]);
31
+ exports.workspaceImageManifestSchema = zod_1.z.object({
32
+ layers: zod_1.z.array(exports.imageLayerSchema),
33
+ workdir: zod_1.z.string().min(1).optional(),
34
+ });
35
+ exports.workspaceImageVariantSchema = zod_1.z.object({
36
+ id: zod_1.z.string().min(1),
37
+ orgId: zod_1.z.string().min(1),
38
+ slug: zod_1.z.string().min(1),
39
+ description: zod_1.z.string(),
40
+ runtimeKind: worker_runtime_1.workerRuntimeKindSchema,
41
+ baseImage: zod_1.z.string().min(1),
42
+ manifest: exports.workspaceImageManifestSchema,
43
+ contentHash: zod_1.z.string().min(1),
44
+ registryRef: zod_1.z.string().min(1).optional(),
45
+ status: exports.variantStatusSchema,
46
+ isOrgDefault: zod_1.z.boolean(),
47
+ autoRebake: zod_1.z.boolean(),
48
+ regions: zod_1.z.array(zod_1.z.string().min(1)),
49
+ buildLog: zod_1.z.string().optional(),
50
+ builtAt: zod_1.z.string().min(1).optional(),
51
+ createdAt: zod_1.z.string().min(1),
52
+ });
53
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/workspace-image/lib/schemas.ts"],"names":[],"mappings":";;;AAQA,6BAAwB;AACxB,yDAA+D;AAE/D,mCAAwD;AAE3C,QAAA,oBAAoB,GAAG,OAAC,CAAC,UAAU,CAAC,sBAAc,CAAC,CAAC;AACpD,QAAA,mBAAmB,GAAG,OAAC,CAAC,UAAU,CAAC,qBAAa,CAAC,CAAC;AAE/D,MAAM,aAAa,GAAG,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAEpC,QAAA,gBAAgB,GAAG,OAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IAC3D,OAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,sBAAc,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1E,OA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C,GAAG,CAAC,CAAC,CAAC;CAC7B,CAAC,CAAC"}
@@ -0,0 +1,50 @@
1
+ import type { WorkerRuntimeKind } from '../../worker-runtime';
2
+ import type { ImageLayerKind, VariantStatus } from './enums';
3
+ export type ImageLayer = {
4
+ readonly kind: ImageLayerKind.Apt;
5
+ readonly packages: readonly string[];
6
+ } | {
7
+ readonly kind: ImageLayerKind.Dnf;
8
+ readonly packages: readonly string[];
9
+ } | {
10
+ readonly kind: ImageLayerKind.Apk;
11
+ readonly packages: readonly string[];
12
+ } | {
13
+ readonly kind: ImageLayerKind.Pip;
14
+ readonly packages: readonly string[];
15
+ readonly pythonVersion?: string;
16
+ } | {
17
+ readonly kind: ImageLayerKind.NpmGlobal;
18
+ readonly packages: readonly string[];
19
+ } | {
20
+ readonly kind: ImageLayerKind.Env;
21
+ readonly vars: Readonly<Record<string, string>>;
22
+ } | {
23
+ readonly kind: ImageLayerKind.File;
24
+ readonly path: string;
25
+ readonly contentBase64: string;
26
+ readonly mode?: number;
27
+ };
28
+ export interface WorkspaceImageManifest {
29
+ readonly layers: readonly ImageLayer[];
30
+ readonly workdir?: string;
31
+ }
32
+ export interface WorkspaceImageVariant {
33
+ readonly id: string;
34
+ readonly orgId: string;
35
+ readonly slug: string;
36
+ readonly description: string;
37
+ readonly runtimeKind: WorkerRuntimeKind;
38
+ readonly baseImage: string;
39
+ readonly manifest: WorkspaceImageManifest;
40
+ readonly contentHash: string;
41
+ readonly registryRef?: string;
42
+ readonly status: VariantStatus;
43
+ readonly isOrgDefault: boolean;
44
+ readonly autoRebake: boolean;
45
+ readonly regions: readonly string[];
46
+ readonly buildLog?: string;
47
+ readonly builtAt?: string;
48
+ readonly createdAt: string;
49
+ }
50
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/workspace-image/lib/types.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBA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AAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAMD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC;IAExC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,CAAC;IAE1C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAE7B,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAEpC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAE3B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/workspace-image/lib/types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xemahq/kernel-contracts",
3
- "version": "0.29.0",
3
+ "version": "0.30.0",
4
4
  "description": "Consolidated Xema OS kernel wire contracts — pure types + zod schemas for the kernel protocol surfaces. One package, one npm scope, wildcard per-surface subpath exports. No framework/runtime deps.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Neuralchowder Inc. <developer@xema.dev> (https://xema.dev)",
@@ -0,0 +1,25 @@
1
+ // ═══════════════════════════════════════════════════════════════════════════
2
+ // @xemahq/document-patch-contracts — Kernel layer
3
+ //
4
+ // Wire contracts for the per-hunk edits to a knowledge-base document page.
5
+ //
6
+ // Pending patches are NOT authored by the agent. They are platform-derived:
7
+ // `document-sync` diffs the agent's working file against the accepted base
8
+ // and re-derives the page's `PendingPatch` rows as contiguous line-range
9
+ // hunks. Used by:
10
+ // - knowledge-base-api's pending-patches endpoints (DTO shapes)
11
+ // - the frontend hunk-decoration UI (type-only)
12
+ //
13
+ // Per-hunk accept/reject is the central UX primitive: the user can take any
14
+ // subset of the agent's changes. To make that safe against concurrent user
15
+ // edits, every hunk carries the base version it was computed against and a
16
+ // line-range `anchor` describing WHERE it applies. The accept endpoint
17
+ // refuses the apply if the surrounding text shifted out from under the
18
+ // anchor (`PendingPatchStatus.STALE`), so silent drift is impossible.
19
+ //
20
+ // Pure types + Zod. Zero runtime adapter knowledge.
21
+ // ═══════════════════════════════════════════════════════════════════════════
22
+
23
+ export * from './lib/patch-enums';
24
+ export * from './lib/patch-anchor';
25
+ export * from './lib/pending-patch';
@@ -0,0 +1,22 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Where a pending patch applies in the document: a 1-based inclusive
5
+ * line range in BASE. Pending patches are platform-derived by diffing
6
+ * the agent's working file against the accepted base — every hunk is a
7
+ * contiguous line range, so this is the only anchor shape.
8
+ *
9
+ * `endLine === startLine - 1` is the canonical encoding for a
10
+ * pure-insertion-before-line patch (zero-length range positioned just
11
+ * before `startLine`).
12
+ */
13
+ export const LineRangeAnchorSchema = z
14
+ .object({
15
+ startLine: z.number().int().min(1),
16
+ endLine: z.number().int().min(0),
17
+ })
18
+ .refine((v) => v.endLine >= v.startLine - 1, {
19
+ message: 'LineRangeAnchor requires endLine >= startLine - 1',
20
+ path: ['endLine'],
21
+ });
22
+ export type LineRangeAnchor = z.infer<typeof LineRangeAnchorSchema>;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Closed enums for the patch protocol. Real TS enums (not string-literal
3
+ * unions) so OpenAPI/Orval emit stable enum schemas — see
4
+ * `docs/API_STANDARDS.md` and.
5
+ */
6
+
7
+ /**
8
+ * Where this pending patch came from.
9
+ *
10
+ * - AGENT_SESSION — derived from an interactive Document Buddy
11
+ * session's working-file edits (document-sync).
12
+ * - WORKFLOW_REVIEW — a workflow activity proposing edits on the user's
13
+ * behalf.
14
+ */
15
+ export enum PatchOrigin {
16
+ AGENT_SESSION = 'AGENT_SESSION',
17
+ WORKFLOW_REVIEW = 'WORKFLOW_REVIEW',
18
+ }
19
+
20
+ /**
21
+ * Lifecycle status for a single PendingPatch row.
22
+ *
23
+ * - PENDING — awaiting a user decision.
24
+ * - ACCEPTED — applied to the page (terminal).
25
+ * - REJECTED — discarded by the user (terminal).
26
+ * - STALE — the document moved out from under the patch's anchor
27
+ * before a decision was made; the user must re-propose or
28
+ * discard. Set fail-fast by the accept endpoint when the
29
+ * anchor no longer matches current content.
30
+ */
31
+ export enum PendingPatchStatus {
32
+ PENDING = 'PENDING',
33
+ ACCEPTED = 'ACCEPTED',
34
+ REJECTED = 'REJECTED',
35
+ STALE = 'STALE',
36
+ }
@@ -0,0 +1,31 @@
1
+ import { PatchOrigin, PendingPatchStatus } from './patch-enums';
2
+
3
+ import type { LineRangeAnchor } from './patch-anchor';
4
+
5
+ /**
6
+ * Wire shape of a single PendingPatch row as returned by the
7
+ * knowledge-base-api list/get endpoints and broadcast over the KB
8
+ * realtime SSE stream. Pure type — no runtime validation needed because
9
+ * the producer is trusted server code.
10
+ */
11
+ export interface PendingPatchDto {
12
+ readonly id: string;
13
+ readonly pageId: string;
14
+ readonly proposalId: string;
15
+ readonly sequence: number;
16
+ readonly origin: PatchOrigin;
17
+ readonly sessionId: string | null;
18
+ readonly workflowJobRunId: string | null;
19
+ readonly baseVersion: number;
20
+ readonly anchor: LineRangeAnchor;
21
+ readonly before: string;
22
+ readonly after: string;
23
+ readonly label: string | null;
24
+ readonly rationale: string | null;
25
+ readonly status: PendingPatchStatus;
26
+ readonly decidedBy: string | null;
27
+ /** ISO-8601 timestamp; null until terminal. */
28
+ readonly decidedAt: string | null;
29
+ /** ISO-8601 timestamp. */
30
+ readonly createdAt: string;
31
+ }
@@ -0,0 +1,20 @@
1
+ // ═══════════════════════════════════════════════════════════════════════════
2
+ // @xemahq/output-contracts — Layer 1 / Kernel
3
+ //
4
+ // Wire shapes for the run-detail Outputs panel and the per-kind renderer
5
+ // registry. The legacy
6
+ // JSON-dumping ArtifactContentViewer / OutputPreview pair are replaced by
7
+ // a CLOSED-enum renderer registry. ESLint enforces that every OutputKind
8
+ // value has a registered renderer (xema-fe/output-renderer-coverage).
9
+ //
10
+ // The user reviews deliverables on the canvas — they NEVER see raw JSON
11
+ // unless they click "Show raw". Adding a new output kind is a deliberate
12
+ // extension: enum value → contract type → renderer. No heuristic fallback.
13
+ // ═══════════════════════════════════════════════════════════════════════════
14
+
15
+ export * from './lib/output-kind';
16
+ export * from './lib/output-render-hint';
17
+ export * from './lib/output-deliverable-expectation';
18
+ export * from './lib/output-version-dto';
19
+ export * from './lib/output-item-dto';
20
+ export * from './lib/payload-schemas';
@@ -0,0 +1,25 @@
1
+ import { OutputKind } from './output-kind';
2
+
3
+ /**
4
+ * What the workflow EXPECTED to produce at this slot, derived from the
5
+ * deliverable spec. Compared against {@link OutputItemDto} to detect
6
+ * missing or unexpected outputs in the Overview "Latest deliverables"
7
+ * strip.
8
+ *
9
+ * The engine emits one expectation per declared deliverable slot at
10
+ * dispatch time. A run with `produced.length < expectations.length`
11
+ * is incomplete; the FE renders missing slots as placeholder cards
12
+ * with the expectation summary.
13
+ */
14
+ export interface OutputDeliverableExpectation {
15
+ readonly slug: string;
16
+ readonly displayName: string;
17
+ readonly expectedKind: OutputKind;
18
+ /** Phase that's responsible for producing this slot. */
19
+ readonly stageKey: string;
20
+ /**
21
+ * Whether this deliverable is required for the run to succeed. When
22
+ * `false`, the FE renders a missing slot in muted styling.
23
+ */
24
+ readonly required: boolean;
25
+ }
@@ -0,0 +1,54 @@
1
+ import { OutputKind } from './output-kind';
2
+ import { OutputRenderHint } from './output-render-hint';
3
+ import { OutputVersionDto } from './output-version-dto';
4
+
5
+ /**
6
+ * One card in the run-detail Outputs panel.
7
+ *
8
+ * The CARD is the deliverable while reviewing: the user reads the
9
+ * rendered content
10
+ * directly, not a JSON dump. `contentRef` points at the lazy-loaded
11
+ * payload the kind-specific renderer fetches; `summary` is the
12
+ * always-loaded one-line preview shown collapsed.
13
+ *
14
+ * `kbPublishedAt` is set when the artifact-store has linked this
15
+ * output to a `KB_PAGE` link refType. The FE renders an "Open in
16
+ * Knowledge Base" affordance when present.
17
+ */
18
+ export interface OutputItemDto {
19
+ readonly id: string;
20
+ readonly kind: OutputKind;
21
+ readonly title: string;
22
+ /** One-line collapsed-state preview. Always rendered; never JSON. */
23
+ readonly summary: string;
24
+ /** Phase that produced this output. */
25
+ readonly stageKey: string;
26
+ readonly renderHint: OutputRenderHint;
27
+ /** Versions in descending order; first row is current. */
28
+ readonly versions: readonly OutputVersionDto[];
29
+ /** Lazy-load handle the renderer dereferences. Format is renderer-specific. */
30
+ readonly contentRef: OutputContentRef;
31
+ /** ISO-8601 when the latest version was emitted. */
32
+ readonly latestEmittedAt: string;
33
+ /** ISO-8601 when published to the KB; `null` when not yet (or never to be) published. */
34
+ readonly kbPublishedAt: string | null;
35
+ /** Direct deep-link to the KB page; `null` when not yet published. */
36
+ readonly kbPageUrl: string | null;
37
+ }
38
+
39
+ /**
40
+ * A renderer-agnostic handle the FE dereferences when the user expands
41
+ * a card. Renderers narrow on `kind` to know which flavor of resolver
42
+ * to invoke — there are exactly two flavors:
43
+ *
44
+ * - INLINE — the payload is small enough to ship in the list response
45
+ * and is already inlined (`payload`). Renderer reads directly.
46
+ * - REMOTE — the payload requires a separate fetch (`url`). Renderer
47
+ * queries `useOutputContent({ url })`.
48
+ *
49
+ * Producers MUST pick one. Renderers MUST handle both (the registry
50
+ * provides this glue once per kind, not per renderer).
51
+ */
52
+ export type OutputContentRef =
53
+ | { readonly kind: 'inline'; readonly payload: unknown }
54
+ | { readonly kind: 'remote'; readonly url: string; readonly contentType: string };
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The CLOSED set of output renderer kinds. Adding a new kind:
3
+ *
4
+ * 1. Extend this enum.
5
+ * 2. Register a renderer component in the FE renderer-registry.
6
+ * 3. CI fails until both are done (xema-fe/output-renderer-coverage
7
+ * lints the registry against this enum).
8
+ *
9
+ * No "unknown" fallback that silently dumps JSON — `UNKNOWN` is rendered
10
+ * by an explicit "we don't have a renderer for this yet" component
11
+ * with a "Show raw" toggle. Producers must NEVER emit `UNKNOWN` for a
12
+ * kind that has a real renderer; the engine refuses to materialize an
13
+ * output with `UNKNOWN` if the producer can derive a real kind from
14
+ * the deliverable spec.
15
+ */
16
+ export enum OutputKind {
17
+ /** Markdown document — renders with TOC, code blocks, diagrams. */
18
+ MARKDOWN_DOC = 'markdown_doc',
19
+ /** Code diff — renders with side-by-side or unified view. */
20
+ CODE_DIFF = 'code_diff',
21
+ /** Architectural Decision Record — renders with status + decision context. */
22
+ DECISION_RECORD = 'decision_record',
23
+ /** Findings list from a reviewer agent — renders as severity-grouped table. */
24
+ REVIEW_FINDINGS = 'review_findings',
25
+ /** JSON Schema — renders as type tree with examples. */
26
+ SCHEMA = 'schema',
27
+ /** Manifest (workflow YAML, biome manifest, etc.) — renders as structured form. */
28
+ MANIFEST = 'manifest',
29
+ /** Test report — renders pass/fail summary + failing-case detail. */
30
+ TEST_REPORT = 'test_report',
31
+ /** Diagram (mermaid, drawio, etc.) — renders as SVG. */
32
+ DIAGRAM = 'diagram',
33
+ /**
34
+ * Generic structured JSON payload — used when the value IS the JSON
35
+ * envelope itself (e.g. `xema/http` / `xema/endpoint-fetch` results,
36
+ * or any producer emitting a free-form structured object that
37
+ * doesn't map onto a more specific kind). Rendered as a JSON tree.
38
+ */
39
+ JSON_PAYLOAD = 'json_payload',
40
+ /** External blob (image, binary, etc.) — renders as preview + download. */
41
+ EXTERNAL_BLOB = 'external_blob',
42
+ /** Fallback for outputs without a typed renderer. Renders "no renderer" notice. */
43
+ UNKNOWN = 'unknown',
44
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Per-kind rendering hint the engine attaches to an output. Optional —
3
+ * the renderer has sensible defaults — but lets producers steer
4
+ * presentation without freeform CSS.
5
+ *
6
+ * Closed enum so the renderer registry knows the full hint surface.
7
+ */
8
+ export enum OutputRenderDensity {
9
+ COMPACT = 'compact',
10
+ COMFORTABLE = 'comfortable',
11
+ FULL = 'full',
12
+ }
13
+
14
+ export interface OutputRenderHint {
15
+ readonly density: OutputRenderDensity;
16
+ /**
17
+ * When true, the renderer expands inline by default (no click).
18
+ * When false, the renderer shows a one-line summary card and
19
+ * expands on click.
20
+ */
21
+ readonly expandByDefault: boolean;
22
+ /**
23
+ * Optional preferred starting tab when the renderer has multiple
24
+ * tabs (e.g. code-diff: "unified" vs "split"). The renderer
25
+ * validates this against its known tab set.
26
+ */
27
+ readonly preferredTab: string | null;
28
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * One row in the version history of an output. The Outputs panel
3
+ * renders a dropdown when `versions.length > 1`; clicking a non-current
4
+ * version navigates to the inline VersionCompare view (NOT a drawer).
5
+ *
6
+ *: per-version metadata lives
7
+ * on `ArtifactVersion`. The engine populates this DTO from there.
8
+ * Consumers MUST NOT trust `OutputItemDto.title` for historical
9
+ * versions — read this row's `title` field instead.
10
+ */
11
+ export interface OutputVersionDto {
12
+ readonly id: string;
13
+ readonly version: number;
14
+ readonly title: string;
15
+ readonly hash: string;
16
+ readonly createdAt: string;
17
+ /** Slug of the agent that produced this version. `null` for non-agent producers. */
18
+ readonly producerAgentSlug: string | null;
19
+ /** True when this row is the latest version. Exactly one row has this set. */
20
+ readonly isCurrent: boolean;
21
+ }
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Payload shape for `OutputKind.CODE_DIFF` artifacts — unified-diff
5
+ * text produced by SCM-integration adapters and code-reviewing agents.
6
+ *
7
+ * The convention is a single `body` string carrying the diff in standard
8
+ * unified-diff format. The FE renders it through Monaco's diff-aware
9
+ * tokenizer (`language: 'diff'`) so additions/removals get syntax
10
+ * highlighting.
11
+ */
12
+ export const CodeDiffPayloadSchema = z
13
+ .object({
14
+ body: z.string().min(1, 'code_diff.body must be non-empty'),
15
+ /** Optional: human-readable label for the change (e.g. "Refactor auth flow"). */
16
+ title: z.string().optional(),
17
+ })
18
+ .passthrough();
19
+
20
+ export type CodeDiffPayload = z.infer<typeof CodeDiffPayloadSchema>;
@@ -0,0 +1,71 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Architectural Decision Record (ADR) status — RFC-style lifecycle.
5
+ *
6
+ * Closed enum so the FE can render distinctive pills per state
7
+ * (`accepted` green, `superseded` strikethrough, etc.). Producers
8
+ * MUST pick one; freeform strings are rejected so we don't grow a
9
+ * long tail of bespoke statuses.
10
+ */
11
+ export enum DecisionRecordStatus {
12
+ PROPOSED = 'proposed',
13
+ ACCEPTED = 'accepted',
14
+ REJECTED = 'rejected',
15
+ DEPRECATED = 'deprecated',
16
+ SUPERSEDED = 'superseded',
17
+ }
18
+
19
+ export const DecisionRecordStatusSchema = z.nativeEnum(DecisionRecordStatus);
20
+
21
+ /**
22
+ * Payload shape for `OutputKind.DECISION_RECORD` artifacts.
23
+ *
24
+ * Follows the Michael Nygard ADR template — title, status, context,
25
+ * decision, consequences. Each field is markdown so the FE renderer
26
+ * can present them as separate sections with appropriate framing
27
+ * (status pill, headings, etc.).
28
+ *
29
+ * Backward-compat: producers that pre-date this schema emit a single
30
+ * `body` markdown string (legacy convention shared across all
31
+ * markdown-bearing kinds via `textViewOfPayload`). The schema
32
+ * tolerates that by making every structured field optional and
33
+ * requiring at-least-one-of via `superRefine`. New producers should
34
+ * emit the structured fields so the renderer's rich form lights up.
35
+ */
36
+ export const DecisionRecordPayloadSchema = z
37
+ .object({
38
+ title: z.string().optional(),
39
+ status: DecisionRecordStatusSchema.optional(),
40
+ context: z.string().optional(),
41
+ decision: z.string().optional(),
42
+ consequences: z.string().optional(),
43
+ /**
44
+ * Legacy / fallback: a single markdown document holding the whole
45
+ * ADR. New producers SHOULD prefer the structured fields; this
46
+ * stays for backward-compatibility and for cases where the ADR
47
+ * doesn't map cleanly onto the four-section template.
48
+ */
49
+ body: z.string().optional(),
50
+ })
51
+ .passthrough()
52
+ .superRefine((value, ctx) => {
53
+ const structuredFields = [
54
+ value.context,
55
+ value.decision,
56
+ value.consequences,
57
+ ];
58
+ const hasStructured = structuredFields.some(
59
+ (v) => typeof v === 'string' && v.trim().length > 0,
60
+ );
61
+ const hasBody = typeof value.body === 'string' && value.body.trim().length > 0;
62
+ if (!hasStructured && !hasBody) {
63
+ ctx.addIssue({
64
+ code: 'custom',
65
+ message:
66
+ 'decision_record payload must include at least one of `body` or the structured fields (`context`, `decision`, `consequences`).',
67
+ });
68
+ }
69
+ });
70
+
71
+ export type DecisionRecordPayload = z.infer<typeof DecisionRecordPayloadSchema>;