@cleocode/contracts 2026.4.69 → 2026.4.70
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/dist/__tests__/acceptance-gate.test.d.ts +14 -0
- package/dist/__tests__/acceptance-gate.test.d.ts.map +1 -0
- package/dist/__tests__/acceptance-gate.test.js +642 -0
- package/dist/__tests__/acceptance-gate.test.js.map +1 -0
- package/dist/__tests__/attachment.test.d.ts +17 -0
- package/dist/__tests__/attachment.test.d.ts.map +1 -0
- package/dist/__tests__/attachment.test.js +505 -0
- package/dist/__tests__/attachment.test.js.map +1 -0
- package/dist/acceptance-gate-schema.d.ts +624 -0
- package/dist/acceptance-gate-schema.d.ts.map +1 -0
- package/dist/acceptance-gate-schema.js +244 -0
- package/dist/acceptance-gate-schema.js.map +1 -0
- package/dist/acceptance-gate.d.ts +253 -0
- package/dist/acceptance-gate.d.ts.map +1 -0
- package/dist/acceptance-gate.js +22 -0
- package/dist/acceptance-gate.js.map +1 -0
- package/dist/attachment-schema.d.ts +243 -0
- package/dist/attachment-schema.d.ts.map +1 -0
- package/dist/attachment-schema.js +200 -0
- package/dist/attachment-schema.js.map +1 -0
- package/dist/attachment.d.ts +224 -0
- package/dist/attachment.d.ts.map +1 -0
- package/dist/attachment.js +21 -0
- package/dist/attachment.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/task.d.ts +23 -4
- package/dist/task.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/acceptance-gate.test.ts +736 -0
- package/src/__tests__/attachment.test.ts +601 -0
- package/src/acceptance-gate-schema.ts +283 -0
- package/src/acceptance-gate.ts +264 -0
- package/src/attachment-schema.ts +223 -0
- package/src/attachment.ts +245 -0
- package/src/index.ts +49 -0
- package/src/task.ts +24 -4
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod validation schemas for {@link Attachment} and related types.
|
|
3
|
+
*
|
|
4
|
+
* Kept in a separate file from the plain TypeScript types so that consumers
|
|
5
|
+
* that do not need runtime validation (e.g. type-only imports) pay zero cost.
|
|
6
|
+
*
|
|
7
|
+
* All schemas are named `*Schema` and their inferred types are compatible with
|
|
8
|
+
* the canonical TypeScript interfaces in `./attachment.ts`.
|
|
9
|
+
*
|
|
10
|
+
* Uses `z.discriminatedUnion('kind', [...])` for O(1) variant lookup on the
|
|
11
|
+
* `kind` discriminant.
|
|
12
|
+
*
|
|
13
|
+
* @epic T760
|
|
14
|
+
* @task T795
|
|
15
|
+
*/
|
|
16
|
+
import { z } from 'zod';
|
|
17
|
+
/**
|
|
18
|
+
* Zod schema for {@link LocalFileAttachment}.
|
|
19
|
+
*
|
|
20
|
+
* Validates that `path` is non-empty, `sha256` is a 64-character hex string,
|
|
21
|
+
* and `size` is a non-negative integer.
|
|
22
|
+
*/
|
|
23
|
+
export declare const localFileAttachmentSchema: z.ZodObject<{
|
|
24
|
+
description: z.ZodOptional<z.ZodString>;
|
|
25
|
+
labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
26
|
+
kind: z.ZodLiteral<"local-file">;
|
|
27
|
+
path: z.ZodString;
|
|
28
|
+
sha256: z.ZodString;
|
|
29
|
+
mime: z.ZodString;
|
|
30
|
+
size: z.ZodNumber;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
/**
|
|
33
|
+
* Zod schema for {@link UrlAttachment}.
|
|
34
|
+
*
|
|
35
|
+
* Validates that `url` is a well-formed absolute URL. The optional `cachedSha256`
|
|
36
|
+
* is validated as a 64-character hex string when present.
|
|
37
|
+
*/
|
|
38
|
+
export declare const urlAttachmentSchema: z.ZodObject<{
|
|
39
|
+
description: z.ZodOptional<z.ZodString>;
|
|
40
|
+
labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
41
|
+
kind: z.ZodLiteral<"url">;
|
|
42
|
+
url: z.ZodString;
|
|
43
|
+
cachedSha256: z.ZodOptional<z.ZodString>;
|
|
44
|
+
cachedAt: z.ZodOptional<z.ZodString>;
|
|
45
|
+
mime: z.ZodOptional<z.ZodString>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
/**
|
|
48
|
+
* Zod schema for {@link BlobAttachment}.
|
|
49
|
+
*
|
|
50
|
+
* Validates that `sha256` is 64 hex characters, `storageKey` is non-empty,
|
|
51
|
+
* and `size` is a non-negative integer.
|
|
52
|
+
*/
|
|
53
|
+
export declare const blobAttachmentSchema: z.ZodObject<{
|
|
54
|
+
description: z.ZodOptional<z.ZodString>;
|
|
55
|
+
labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
56
|
+
kind: z.ZodLiteral<"blob">;
|
|
57
|
+
sha256: z.ZodString;
|
|
58
|
+
storageKey: z.ZodString;
|
|
59
|
+
mime: z.ZodString;
|
|
60
|
+
size: z.ZodNumber;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
/**
|
|
63
|
+
* Zod schema for {@link LlmsTxtAttachment}.
|
|
64
|
+
*
|
|
65
|
+
* Validates that `content` is non-empty, `sha256` is 64 hex characters, and
|
|
66
|
+
* `source` is one of the two allowed literal values.
|
|
67
|
+
*/
|
|
68
|
+
export declare const llmsTxtAttachmentSchema: z.ZodObject<{
|
|
69
|
+
description: z.ZodOptional<z.ZodString>;
|
|
70
|
+
labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
71
|
+
kind: z.ZodLiteral<"llms-txt">;
|
|
72
|
+
source: z.ZodEnum<{
|
|
73
|
+
url: "url";
|
|
74
|
+
generated: "generated";
|
|
75
|
+
}>;
|
|
76
|
+
content: z.ZodString;
|
|
77
|
+
sha256: z.ZodString;
|
|
78
|
+
}, z.core.$strip>;
|
|
79
|
+
/**
|
|
80
|
+
* Zod schema for {@link LlmtxtDocAttachment}.
|
|
81
|
+
*
|
|
82
|
+
* Validates that `slug` is non-empty and `backend` is one of the two allowed
|
|
83
|
+
* literal values. `pinnedVersion` is an opaque string when present.
|
|
84
|
+
*/
|
|
85
|
+
export declare const llmtxtDocAttachmentSchema: z.ZodObject<{
|
|
86
|
+
description: z.ZodOptional<z.ZodString>;
|
|
87
|
+
labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
88
|
+
kind: z.ZodLiteral<"llmtxt-doc">;
|
|
89
|
+
slug: z.ZodString;
|
|
90
|
+
backend: z.ZodEnum<{
|
|
91
|
+
local: "local";
|
|
92
|
+
remote: "remote";
|
|
93
|
+
}>;
|
|
94
|
+
pinnedVersion: z.ZodOptional<z.ZodString>;
|
|
95
|
+
}, z.core.$strip>;
|
|
96
|
+
/**
|
|
97
|
+
* Zod discriminated-union schema for {@link Attachment}.
|
|
98
|
+
*
|
|
99
|
+
* Uses `z.discriminatedUnion('kind', [...])` for O(1) variant lookup.
|
|
100
|
+
* Parse with `attachmentSchema.parse(input)` or
|
|
101
|
+
* `attachmentSchema.safeParse(input)`.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* const att = attachmentSchema.parse({
|
|
106
|
+
* kind: 'local-file',
|
|
107
|
+
* path: 'docs/rfc-003.md',
|
|
108
|
+
* sha256: 'a'.repeat(64),
|
|
109
|
+
* mime: 'text/markdown',
|
|
110
|
+
* size: 8192,
|
|
111
|
+
* description: 'RFC draft v3',
|
|
112
|
+
* });
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
export declare const attachmentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
116
|
+
description: z.ZodOptional<z.ZodString>;
|
|
117
|
+
labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
118
|
+
kind: z.ZodLiteral<"local-file">;
|
|
119
|
+
path: z.ZodString;
|
|
120
|
+
sha256: z.ZodString;
|
|
121
|
+
mime: z.ZodString;
|
|
122
|
+
size: z.ZodNumber;
|
|
123
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
124
|
+
description: z.ZodOptional<z.ZodString>;
|
|
125
|
+
labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
126
|
+
kind: z.ZodLiteral<"url">;
|
|
127
|
+
url: z.ZodString;
|
|
128
|
+
cachedSha256: z.ZodOptional<z.ZodString>;
|
|
129
|
+
cachedAt: z.ZodOptional<z.ZodString>;
|
|
130
|
+
mime: z.ZodOptional<z.ZodString>;
|
|
131
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
132
|
+
description: z.ZodOptional<z.ZodString>;
|
|
133
|
+
labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
134
|
+
kind: z.ZodLiteral<"blob">;
|
|
135
|
+
sha256: z.ZodString;
|
|
136
|
+
storageKey: z.ZodString;
|
|
137
|
+
mime: z.ZodString;
|
|
138
|
+
size: z.ZodNumber;
|
|
139
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
140
|
+
description: z.ZodOptional<z.ZodString>;
|
|
141
|
+
labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
142
|
+
kind: z.ZodLiteral<"llms-txt">;
|
|
143
|
+
source: z.ZodEnum<{
|
|
144
|
+
url: "url";
|
|
145
|
+
generated: "generated";
|
|
146
|
+
}>;
|
|
147
|
+
content: z.ZodString;
|
|
148
|
+
sha256: z.ZodString;
|
|
149
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
150
|
+
description: z.ZodOptional<z.ZodString>;
|
|
151
|
+
labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
152
|
+
kind: z.ZodLiteral<"llmtxt-doc">;
|
|
153
|
+
slug: z.ZodString;
|
|
154
|
+
backend: z.ZodEnum<{
|
|
155
|
+
local: "local";
|
|
156
|
+
remote: "remote";
|
|
157
|
+
}>;
|
|
158
|
+
pinnedVersion: z.ZodOptional<z.ZodString>;
|
|
159
|
+
}, z.core.$strip>], "kind">;
|
|
160
|
+
/** Inferred TypeScript type from {@link attachmentSchema}. */
|
|
161
|
+
export type AttachmentSchemaInput = z.input<typeof attachmentSchema>;
|
|
162
|
+
/**
|
|
163
|
+
* Zod schema for {@link AttachmentMetadata}.
|
|
164
|
+
*
|
|
165
|
+
* Validates the persisted registry row. The embedded `attachment` field is
|
|
166
|
+
* validated recursively through the discriminated union.
|
|
167
|
+
*/
|
|
168
|
+
export declare const attachmentMetadataSchema: z.ZodObject<{
|
|
169
|
+
id: z.ZodString;
|
|
170
|
+
sha256: z.ZodString;
|
|
171
|
+
attachment: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
172
|
+
description: z.ZodOptional<z.ZodString>;
|
|
173
|
+
labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
174
|
+
kind: z.ZodLiteral<"local-file">;
|
|
175
|
+
path: z.ZodString;
|
|
176
|
+
sha256: z.ZodString;
|
|
177
|
+
mime: z.ZodString;
|
|
178
|
+
size: z.ZodNumber;
|
|
179
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
180
|
+
description: z.ZodOptional<z.ZodString>;
|
|
181
|
+
labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
182
|
+
kind: z.ZodLiteral<"url">;
|
|
183
|
+
url: z.ZodString;
|
|
184
|
+
cachedSha256: z.ZodOptional<z.ZodString>;
|
|
185
|
+
cachedAt: z.ZodOptional<z.ZodString>;
|
|
186
|
+
mime: z.ZodOptional<z.ZodString>;
|
|
187
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
188
|
+
description: z.ZodOptional<z.ZodString>;
|
|
189
|
+
labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
190
|
+
kind: z.ZodLiteral<"blob">;
|
|
191
|
+
sha256: z.ZodString;
|
|
192
|
+
storageKey: z.ZodString;
|
|
193
|
+
mime: z.ZodString;
|
|
194
|
+
size: z.ZodNumber;
|
|
195
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
196
|
+
description: z.ZodOptional<z.ZodString>;
|
|
197
|
+
labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
198
|
+
kind: z.ZodLiteral<"llms-txt">;
|
|
199
|
+
source: z.ZodEnum<{
|
|
200
|
+
url: "url";
|
|
201
|
+
generated: "generated";
|
|
202
|
+
}>;
|
|
203
|
+
content: z.ZodString;
|
|
204
|
+
sha256: z.ZodString;
|
|
205
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
206
|
+
description: z.ZodOptional<z.ZodString>;
|
|
207
|
+
labels: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
208
|
+
kind: z.ZodLiteral<"llmtxt-doc">;
|
|
209
|
+
slug: z.ZodString;
|
|
210
|
+
backend: z.ZodEnum<{
|
|
211
|
+
local: "local";
|
|
212
|
+
remote: "remote";
|
|
213
|
+
}>;
|
|
214
|
+
pinnedVersion: z.ZodOptional<z.ZodString>;
|
|
215
|
+
}, z.core.$strip>], "kind">;
|
|
216
|
+
createdAt: z.ZodString;
|
|
217
|
+
refCount: z.ZodNumber;
|
|
218
|
+
}, z.core.$strip>;
|
|
219
|
+
/** Inferred TypeScript type from {@link attachmentMetadataSchema}. */
|
|
220
|
+
export type AttachmentMetadataSchemaInput = z.input<typeof attachmentMetadataSchema>;
|
|
221
|
+
/**
|
|
222
|
+
* Zod schema for {@link AttachmentRef}.
|
|
223
|
+
*
|
|
224
|
+
* Validates the junction row linking one attachment to one owner. `ownerType`
|
|
225
|
+
* is restricted to the six supported CLEO entity types.
|
|
226
|
+
*/
|
|
227
|
+
export declare const attachmentRefSchema: z.ZodObject<{
|
|
228
|
+
attachmentId: z.ZodString;
|
|
229
|
+
ownerType: z.ZodEnum<{
|
|
230
|
+
pattern: "pattern";
|
|
231
|
+
task: "task";
|
|
232
|
+
session: "session";
|
|
233
|
+
observation: "observation";
|
|
234
|
+
decision: "decision";
|
|
235
|
+
learning: "learning";
|
|
236
|
+
}>;
|
|
237
|
+
ownerId: z.ZodString;
|
|
238
|
+
attachedAt: z.ZodString;
|
|
239
|
+
attachedBy: z.ZodOptional<z.ZodString>;
|
|
240
|
+
}, z.core.$strip>;
|
|
241
|
+
/** Inferred TypeScript type from {@link attachmentRefSchema}. */
|
|
242
|
+
export type AttachmentRefSchemaInput = z.input<typeof attachmentRefSchema>;
|
|
243
|
+
//# sourceMappingURL=attachment-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment-schema.d.ts","sourceRoot":"","sources":["../src/attachment-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAmBxB;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;iBAUpC,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;iBAU9B,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;iBAU/B,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;iBAQlC,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;iBAYpC,CAAC;AAIH;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAM3B,CAAC;AAEH,8DAA8D;AAC9D,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAIrE;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsBnC,CAAC;AAEH,sEAAsE;AACtE,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAIrF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;iBAmB9B,CAAC;AAEH,iEAAiE;AACjE,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod validation schemas for {@link Attachment} and related types.
|
|
3
|
+
*
|
|
4
|
+
* Kept in a separate file from the plain TypeScript types so that consumers
|
|
5
|
+
* that do not need runtime validation (e.g. type-only imports) pay zero cost.
|
|
6
|
+
*
|
|
7
|
+
* All schemas are named `*Schema` and their inferred types are compatible with
|
|
8
|
+
* the canonical TypeScript interfaces in `./attachment.ts`.
|
|
9
|
+
*
|
|
10
|
+
* Uses `z.discriminatedUnion('kind', [...])` for O(1) variant lookup on the
|
|
11
|
+
* `kind` discriminant.
|
|
12
|
+
*
|
|
13
|
+
* @epic T760
|
|
14
|
+
* @task T795
|
|
15
|
+
*/
|
|
16
|
+
import { z } from 'zod';
|
|
17
|
+
// ─── Shared field schemas ──────────────────────────────────────────────────────
|
|
18
|
+
/**
|
|
19
|
+
* Common optional fields shared by all attachment variants.
|
|
20
|
+
*
|
|
21
|
+
* Not exported as a standalone validator — always composed into full variant
|
|
22
|
+
* schemas via `.extend()`.
|
|
23
|
+
*/
|
|
24
|
+
const attachmentCommonSchema = z.object({
|
|
25
|
+
/** Free-text description of what this attachment contains. */
|
|
26
|
+
description: z.string().optional(),
|
|
27
|
+
/** Labels for filtering (e.g., `["rfc", "spec"]`). */
|
|
28
|
+
labels: z.array(z.string()).optional(),
|
|
29
|
+
});
|
|
30
|
+
// ─── Variant schemas ───────────────────────────────────────────────────────────
|
|
31
|
+
/**
|
|
32
|
+
* Zod schema for {@link LocalFileAttachment}.
|
|
33
|
+
*
|
|
34
|
+
* Validates that `path` is non-empty, `sha256` is a 64-character hex string,
|
|
35
|
+
* and `size` is a non-negative integer.
|
|
36
|
+
*/
|
|
37
|
+
export const localFileAttachmentSchema = attachmentCommonSchema.extend({
|
|
38
|
+
kind: z.literal('local-file'),
|
|
39
|
+
/** Path to the file (absolute or project-root-relative, forward-slashes only). */
|
|
40
|
+
path: z.string().min(1),
|
|
41
|
+
/** SHA-256 hex digest (64 hex characters). */
|
|
42
|
+
sha256: z.string().length(64),
|
|
43
|
+
/** IANA MIME type. */
|
|
44
|
+
mime: z.string().min(1),
|
|
45
|
+
/** File size in bytes (non-negative integer). */
|
|
46
|
+
size: z.number().int().nonnegative(),
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* Zod schema for {@link UrlAttachment}.
|
|
50
|
+
*
|
|
51
|
+
* Validates that `url` is a well-formed absolute URL. The optional `cachedSha256`
|
|
52
|
+
* is validated as a 64-character hex string when present.
|
|
53
|
+
*/
|
|
54
|
+
export const urlAttachmentSchema = attachmentCommonSchema.extend({
|
|
55
|
+
kind: z.literal('url'),
|
|
56
|
+
/** The remote URL — must be a valid absolute URL. */
|
|
57
|
+
url: z.string().url(),
|
|
58
|
+
/** SHA-256 of the cached body (64 hex characters). */
|
|
59
|
+
cachedSha256: z.string().length(64).optional(),
|
|
60
|
+
/** ISO 8601 timestamp when the body was cached. */
|
|
61
|
+
cachedAt: z.string().datetime().optional(),
|
|
62
|
+
/** IANA MIME type detected from the Content-Type header. */
|
|
63
|
+
mime: z.string().optional(),
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* Zod schema for {@link BlobAttachment}.
|
|
67
|
+
*
|
|
68
|
+
* Validates that `sha256` is 64 hex characters, `storageKey` is non-empty,
|
|
69
|
+
* and `size` is a non-negative integer.
|
|
70
|
+
*/
|
|
71
|
+
export const blobAttachmentSchema = attachmentCommonSchema.extend({
|
|
72
|
+
kind: z.literal('blob'),
|
|
73
|
+
/** SHA-256 hex digest of the uncompressed content (64 hex characters). */
|
|
74
|
+
sha256: z.string().length(64),
|
|
75
|
+
/** Storage key inside `.cleo/attachments/sha256/`. */
|
|
76
|
+
storageKey: z.string().min(1),
|
|
77
|
+
/** IANA MIME type. */
|
|
78
|
+
mime: z.string().min(1),
|
|
79
|
+
/** Size of the uncompressed content in bytes. */
|
|
80
|
+
size: z.number().int().nonnegative(),
|
|
81
|
+
});
|
|
82
|
+
/**
|
|
83
|
+
* Zod schema for {@link LlmsTxtAttachment}.
|
|
84
|
+
*
|
|
85
|
+
* Validates that `content` is non-empty, `sha256` is 64 hex characters, and
|
|
86
|
+
* `source` is one of the two allowed literal values.
|
|
87
|
+
*/
|
|
88
|
+
export const llmsTxtAttachmentSchema = attachmentCommonSchema.extend({
|
|
89
|
+
kind: z.literal('llms-txt'),
|
|
90
|
+
/** Where the llms.txt content originated. */
|
|
91
|
+
source: z.enum(['url', 'generated']),
|
|
92
|
+
/** Full markdown content of the llms.txt (stored inline). */
|
|
93
|
+
content: z.string().min(1),
|
|
94
|
+
/** SHA-256 hex digest of `content` (64 hex characters). */
|
|
95
|
+
sha256: z.string().length(64),
|
|
96
|
+
});
|
|
97
|
+
/**
|
|
98
|
+
* Zod schema for {@link LlmtxtDocAttachment}.
|
|
99
|
+
*
|
|
100
|
+
* Validates that `slug` is non-empty and `backend` is one of the two allowed
|
|
101
|
+
* literal values. `pinnedVersion` is an opaque string when present.
|
|
102
|
+
*/
|
|
103
|
+
export const llmtxtDocAttachmentSchema = attachmentCommonSchema.extend({
|
|
104
|
+
kind: z.literal('llmtxt-doc'),
|
|
105
|
+
/** Document slug from the llmtxt backend. */
|
|
106
|
+
slug: z.string().min(1),
|
|
107
|
+
/** Which backend owns the document. */
|
|
108
|
+
backend: z.enum(['local', 'remote']),
|
|
109
|
+
/**
|
|
110
|
+
* Version string pinned at attach time.
|
|
111
|
+
*
|
|
112
|
+
* Opaque: integer version for local backends, API-assigned string for remote.
|
|
113
|
+
*/
|
|
114
|
+
pinnedVersion: z.string().optional(),
|
|
115
|
+
});
|
|
116
|
+
// ─── Discriminated union ──────────────────────────────────────────────────────
|
|
117
|
+
/**
|
|
118
|
+
* Zod discriminated-union schema for {@link Attachment}.
|
|
119
|
+
*
|
|
120
|
+
* Uses `z.discriminatedUnion('kind', [...])` for O(1) variant lookup.
|
|
121
|
+
* Parse with `attachmentSchema.parse(input)` or
|
|
122
|
+
* `attachmentSchema.safeParse(input)`.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```ts
|
|
126
|
+
* const att = attachmentSchema.parse({
|
|
127
|
+
* kind: 'local-file',
|
|
128
|
+
* path: 'docs/rfc-003.md',
|
|
129
|
+
* sha256: 'a'.repeat(64),
|
|
130
|
+
* mime: 'text/markdown',
|
|
131
|
+
* size: 8192,
|
|
132
|
+
* description: 'RFC draft v3',
|
|
133
|
+
* });
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
export const attachmentSchema = z.discriminatedUnion('kind', [
|
|
137
|
+
localFileAttachmentSchema,
|
|
138
|
+
urlAttachmentSchema,
|
|
139
|
+
blobAttachmentSchema,
|
|
140
|
+
llmsTxtAttachmentSchema,
|
|
141
|
+
llmtxtDocAttachmentSchema,
|
|
142
|
+
]);
|
|
143
|
+
// ─── AttachmentMetadata schema ────────────────────────────────────────────────
|
|
144
|
+
/**
|
|
145
|
+
* Zod schema for {@link AttachmentMetadata}.
|
|
146
|
+
*
|
|
147
|
+
* Validates the persisted registry row. The embedded `attachment` field is
|
|
148
|
+
* validated recursively through the discriminated union.
|
|
149
|
+
*/
|
|
150
|
+
export const attachmentMetadataSchema = z.object({
|
|
151
|
+
/**
|
|
152
|
+
* Unique attachment ID.
|
|
153
|
+
*
|
|
154
|
+
* Pattern: `att_<base62>` or UUID fallback. Must be non-empty.
|
|
155
|
+
*/
|
|
156
|
+
id: z.string().min(1),
|
|
157
|
+
/**
|
|
158
|
+
* Content hash — SHA-256 hex (64 chars) for byte-backed kinds, empty string
|
|
159
|
+
* for kinds that delegate content storage externally.
|
|
160
|
+
*/
|
|
161
|
+
sha256: z.string(),
|
|
162
|
+
/** The full attachment value (validated through the discriminated union). */
|
|
163
|
+
attachment: attachmentSchema,
|
|
164
|
+
/** ISO 8601 creation timestamp. */
|
|
165
|
+
createdAt: z.string().datetime(),
|
|
166
|
+
/**
|
|
167
|
+
* Reference count — how many `AttachmentRef` rows point at this attachment.
|
|
168
|
+
*
|
|
169
|
+
* Must be a non-negative integer.
|
|
170
|
+
*/
|
|
171
|
+
refCount: z.number().int().nonnegative(),
|
|
172
|
+
});
|
|
173
|
+
// ─── AttachmentRef schema ─────────────────────────────────────────────────────
|
|
174
|
+
/**
|
|
175
|
+
* Zod schema for {@link AttachmentRef}.
|
|
176
|
+
*
|
|
177
|
+
* Validates the junction row linking one attachment to one owner. `ownerType`
|
|
178
|
+
* is restricted to the six supported CLEO entity types.
|
|
179
|
+
*/
|
|
180
|
+
export const attachmentRefSchema = z.object({
|
|
181
|
+
/** ID of the attachment (→ `attachments.id`). Must be non-empty. */
|
|
182
|
+
attachmentId: z.string().min(1),
|
|
183
|
+
/**
|
|
184
|
+
* The domain entity type that owns this attachment.
|
|
185
|
+
*
|
|
186
|
+
* Restricted to the six supported CLEO entity types.
|
|
187
|
+
*/
|
|
188
|
+
ownerType: z.enum(['task', 'observation', 'session', 'decision', 'learning', 'pattern']),
|
|
189
|
+
/** ID of the owning entity. Must be non-empty. */
|
|
190
|
+
ownerId: z.string().min(1),
|
|
191
|
+
/** ISO 8601 timestamp when the ref was created. */
|
|
192
|
+
attachedAt: z.string().datetime(),
|
|
193
|
+
/**
|
|
194
|
+
* Agent identity (or `"human"`) that created the ref.
|
|
195
|
+
*
|
|
196
|
+
* Optional; populated from the active session credential when available.
|
|
197
|
+
*/
|
|
198
|
+
attachedBy: z.string().optional(),
|
|
199
|
+
});
|
|
200
|
+
//# sourceMappingURL=attachment-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment-schema.js","sourceRoot":"","sources":["../src/attachment-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,kFAAkF;AAElF;;;;;GAKG;AACH,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,8DAA8D;IAC9D,WAAW,E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AAM,EAAE,CAAC,QAAQ,EAAE;IACjC;;;;OAIG;IACH,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAClC,CAAC,CAAC"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attachment discriminated union and metadata types.
|
|
3
|
+
*
|
|
4
|
+
* An `Attachment` represents any content artifact that can be associated
|
|
5
|
+
* with a CLEO owner (task, observation, session, decision, learning, pattern).
|
|
6
|
+
* Five attachment kinds are supported:
|
|
7
|
+
* - `local-file` — a file on disk, tracked by path + SHA-256 hash
|
|
8
|
+
* - `url` — a remote URL, optionally cached to the content-addressed store
|
|
9
|
+
* - `blob` — raw bytes stored content-addressed in `.cleo/attachments/sha256/`
|
|
10
|
+
* - `llms-txt` — a generated or fetched llms.txt site-index snapshot (RFC llmstxt.org)
|
|
11
|
+
* - `llmtxt-doc` — a pointer into an llmtxt document (local or remote backend)
|
|
12
|
+
*
|
|
13
|
+
* `AttachmentMetadata` is the row persisted in the attachment registry.
|
|
14
|
+
* `AttachmentRef` is the junction row linking an attachment to an owner.
|
|
15
|
+
*
|
|
16
|
+
* @epic T760
|
|
17
|
+
* @task T795
|
|
18
|
+
* @see {@link https://github.com/kryptobaseddev/cleo} T760 unified attachments
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* A file on disk inside or adjacent to the CLEO project.
|
|
22
|
+
*
|
|
23
|
+
* The `path` is stored as recorded at attach time; the `sha256` is the content
|
|
24
|
+
* hash computed at that moment. On fetch, the runtime re-hashes the file and
|
|
25
|
+
* emits a warning if the file has drifted from the stored hash.
|
|
26
|
+
*/
|
|
27
|
+
export interface LocalFileAttachment {
|
|
28
|
+
kind: 'local-file';
|
|
29
|
+
/** Path to the file (absolute or project-root-relative, forward-slashes only). */
|
|
30
|
+
path: string;
|
|
31
|
+
/** SHA-256 hex digest of the file at attach time. */
|
|
32
|
+
sha256: string;
|
|
33
|
+
/** IANA MIME type (e.g., `"text/markdown"`, `"application/pdf"`). */
|
|
34
|
+
mime: string;
|
|
35
|
+
/** File size in bytes at attach time. */
|
|
36
|
+
size: number;
|
|
37
|
+
/** Optional free-text description of what this file contains. */
|
|
38
|
+
description?: string;
|
|
39
|
+
/** Labels for filtering (e.g., `["rfc", "spec"]`). */
|
|
40
|
+
labels?: string[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A remote URL, optionally cached to the content-addressed store.
|
|
44
|
+
*
|
|
45
|
+
* When `--cache` is passed on attach, the body is fetched, hashed, and stored
|
|
46
|
+
* at `.cleo/attachments/sha256/<hash[0..2]>/<hash[2..]>.<ext>`. The
|
|
47
|
+
* `cachedSha256` and `cachedAt` fields are populated on a successful cache.
|
|
48
|
+
*/
|
|
49
|
+
export interface UrlAttachment {
|
|
50
|
+
kind: 'url';
|
|
51
|
+
/** The remote URL. Must be a valid absolute URL. */
|
|
52
|
+
url: string;
|
|
53
|
+
/** SHA-256 of the fetched body if the URL has been cached locally. */
|
|
54
|
+
cachedSha256?: string;
|
|
55
|
+
/** ISO 8601 timestamp when the body was cached. */
|
|
56
|
+
cachedAt?: string;
|
|
57
|
+
/** IANA MIME type detected from the Content-Type header. */
|
|
58
|
+
mime?: string;
|
|
59
|
+
/** Optional free-text description. */
|
|
60
|
+
description?: string;
|
|
61
|
+
/** Labels for filtering. */
|
|
62
|
+
labels?: string[];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Raw bytes stored content-addressed in `.cleo/attachments/sha256/`.
|
|
66
|
+
*
|
|
67
|
+
* No external path dependency — the content is always retrievable by
|
|
68
|
+
* `storageKey` as long as the attachment has a positive `refCount`.
|
|
69
|
+
*/
|
|
70
|
+
export interface BlobAttachment {
|
|
71
|
+
kind: 'blob';
|
|
72
|
+
/** SHA-256 hex digest of the uncompressed content. */
|
|
73
|
+
sha256: string;
|
|
74
|
+
/** Storage key inside `.cleo/attachments/sha256/` (e.g., `"ab/abcdef…12.pdf"`). */
|
|
75
|
+
storageKey: string;
|
|
76
|
+
/** IANA MIME type. */
|
|
77
|
+
mime: string;
|
|
78
|
+
/** Size of the uncompressed content in bytes. */
|
|
79
|
+
size: number;
|
|
80
|
+
/** Optional free-text description. */
|
|
81
|
+
description?: string;
|
|
82
|
+
/** Labels for filtering. */
|
|
83
|
+
labels?: string[];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* A generated or fetched llms.txt site-index snapshot (per llmstxt.org spec).
|
|
87
|
+
*
|
|
88
|
+
* The content is stored inline — llms.txt files are small by design.
|
|
89
|
+
* `source: 'url'` means it was fetched from a remote site;
|
|
90
|
+
* `source: 'generated'` means it was produced by `cleo docs generate`.
|
|
91
|
+
*/
|
|
92
|
+
export interface LlmsTxtAttachment {
|
|
93
|
+
kind: 'llms-txt';
|
|
94
|
+
/** Where the llms.txt content originated. */
|
|
95
|
+
source: 'url' | 'generated';
|
|
96
|
+
/**
|
|
97
|
+
* Full markdown content of the llms.txt (stored inline; small by design per
|
|
98
|
+
* the llmstxt.org spec).
|
|
99
|
+
*/
|
|
100
|
+
content: string;
|
|
101
|
+
/** SHA-256 hex digest of `content`. */
|
|
102
|
+
sha256: string;
|
|
103
|
+
/** Optional free-text description. */
|
|
104
|
+
description?: string;
|
|
105
|
+
/** Labels for filtering. */
|
|
106
|
+
labels?: string[];
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* A pointer into an llmtxt document managed by a local or remote backend.
|
|
110
|
+
*
|
|
111
|
+
* `backend: 'local'` — the document lives in `.cleo/llmtxt/` (llmtxt LocalBackend).
|
|
112
|
+
* `backend: 'remote'` — the document lives on an llmtxt.my SaaS instance.
|
|
113
|
+
*
|
|
114
|
+
* This attachment kind delegates content storage to the llmtxt package; CLEO
|
|
115
|
+
* only stores the pointer (slug + backend + optional pinned version).
|
|
116
|
+
*/
|
|
117
|
+
export interface LlmtxtDocAttachment {
|
|
118
|
+
kind: 'llmtxt-doc';
|
|
119
|
+
/** Document slug from the llmtxt backend (e.g., `"9fZLOnf5"`). */
|
|
120
|
+
slug: string;
|
|
121
|
+
/** Which backend owns the document. */
|
|
122
|
+
backend: 'local' | 'remote';
|
|
123
|
+
/**
|
|
124
|
+
* Version string pinned at attach time.
|
|
125
|
+
*
|
|
126
|
+
* For `local` backends this is the integer version number serialised as a
|
|
127
|
+
* string; for `remote` backends it is the version identifier returned by the
|
|
128
|
+
* API.
|
|
129
|
+
*/
|
|
130
|
+
pinnedVersion?: string;
|
|
131
|
+
/** Optional free-text description. */
|
|
132
|
+
description?: string;
|
|
133
|
+
/** Labels for filtering. */
|
|
134
|
+
labels?: string[];
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* A content artifact attachable to any CLEO owner
|
|
138
|
+
* (task, observation, session, decision, learning, or pattern).
|
|
139
|
+
*
|
|
140
|
+
* The `kind` field is the discriminant. All variants share optional
|
|
141
|
+
* `description` and `labels` fields.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts
|
|
145
|
+
* const att: Attachment = {
|
|
146
|
+
* kind: 'local-file',
|
|
147
|
+
* path: 'docs/rfc-003.md',
|
|
148
|
+
* sha256: 'a1b2c3...ff',
|
|
149
|
+
* mime: 'text/markdown',
|
|
150
|
+
* size: 8192,
|
|
151
|
+
* description: 'RFC draft v3',
|
|
152
|
+
* labels: ['rfc', 'spec'],
|
|
153
|
+
* };
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
export type Attachment = LocalFileAttachment | UrlAttachment | BlobAttachment | LlmsTxtAttachment | LlmtxtDocAttachment;
|
|
157
|
+
/** All valid `kind` discriminants for `Attachment`. */
|
|
158
|
+
export type AttachmentKind = Attachment['kind'];
|
|
159
|
+
/**
|
|
160
|
+
* Persisted metadata row for one attachment in the attachment registry
|
|
161
|
+
* (`.cleo/attachments/index.db`).
|
|
162
|
+
*
|
|
163
|
+
* The full {@link Attachment} value is stored as a JSON blob in the `attachment`
|
|
164
|
+
* field so the registry does not need a column per variant.
|
|
165
|
+
*/
|
|
166
|
+
export interface AttachmentMetadata {
|
|
167
|
+
/**
|
|
168
|
+
* Unique attachment ID.
|
|
169
|
+
*
|
|
170
|
+
* Pattern: `att_<base62>` — generated by `llmtxt.generateId()` or a UUID
|
|
171
|
+
* fallback.
|
|
172
|
+
*/
|
|
173
|
+
id: string;
|
|
174
|
+
/**
|
|
175
|
+
* Content hash.
|
|
176
|
+
*
|
|
177
|
+
* For `local-file`, `blob`, and `llms-txt` variants this is the SHA-256
|
|
178
|
+
* of the bytes at attach time. For `url` it is `cachedSha256` when the URL
|
|
179
|
+
* has been cached, or the empty string when it has not. For `llmtxt-doc` it
|
|
180
|
+
* is the empty string (content is managed by the llmtxt backend).
|
|
181
|
+
*/
|
|
182
|
+
sha256: string;
|
|
183
|
+
/** The full attachment value (all kind-specific fields). */
|
|
184
|
+
attachment: Attachment;
|
|
185
|
+
/** ISO 8601 timestamp when this attachment was first registered. */
|
|
186
|
+
createdAt: string;
|
|
187
|
+
/**
|
|
188
|
+
* How many {@link AttachmentRef} rows point at this attachment.
|
|
189
|
+
*
|
|
190
|
+
* When `refCount` drops to zero the blob is eligible for GC via
|
|
191
|
+
* `cleo docs attachments gc`. Blobs are NEVER auto-deleted.
|
|
192
|
+
*/
|
|
193
|
+
refCount: number;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Junction row linking one attachment to one owner.
|
|
197
|
+
*
|
|
198
|
+
* Stored in the `attachment_refs` table of `.cleo/attachments/index.db`.
|
|
199
|
+
* A single attachment can be referenced by multiple owners simultaneously
|
|
200
|
+
* (e.g., the same RFC PDF attached to an epic and to every child task).
|
|
201
|
+
*/
|
|
202
|
+
export interface AttachmentRef {
|
|
203
|
+
/** ID of the attachment (→ `attachments.id`). */
|
|
204
|
+
attachmentId: string;
|
|
205
|
+
/**
|
|
206
|
+
* The domain entity type that owns this attachment.
|
|
207
|
+
*
|
|
208
|
+
* Determines which CLEO store to query when resolving the owner's display
|
|
209
|
+
* name (`tasks.db` for task/session/decision/learning/pattern;
|
|
210
|
+
* `brain.db` for observation).
|
|
211
|
+
*/
|
|
212
|
+
ownerType: 'task' | 'observation' | 'session' | 'decision' | 'learning' | 'pattern';
|
|
213
|
+
/** The ID of the owning entity (e.g., `"T766"`, `"O-abc123"`, `"ses_..."`). */
|
|
214
|
+
ownerId: string;
|
|
215
|
+
/** ISO 8601 timestamp when the ref was created. */
|
|
216
|
+
attachedAt: string;
|
|
217
|
+
/**
|
|
218
|
+
* Agent identity (or `"human"`) that created the ref.
|
|
219
|
+
*
|
|
220
|
+
* Populated from the active session's agent credential when available.
|
|
221
|
+
*/
|
|
222
|
+
attachedBy?: string;
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=attachment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment.d.ts","sourceRoot":"","sources":["../src/attachment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,YAAY,CAAC;IACnB,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sDAAsD;IACtD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,KAAK,CAAC;IACZ,oDAAoD;IACpD,GAAG,EAAE,MAAM,CAAC;IACZ,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4DAA4D;IAC5D,IAAI,CAAC,EAAE,MAAM,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