@fractary/codex 0.1.0 → 0.1.2
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 +266 -161
- package/dist/index.cjs +3956 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +996 -17
- package/dist/index.d.ts +996 -17
- package/dist/index.js +3821 -2
- package/dist/index.js.map +1 -1
- package/package.json +11 -5
package/dist/index.d.ts
CHANGED
|
@@ -12,11 +12,252 @@ declare class ValidationError extends CodexError {
|
|
|
12
12
|
constructor(message: string, options?: ErrorOptions);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
interface ParsedReference {
|
|
16
|
+
uri: string;
|
|
17
|
+
org: string;
|
|
18
|
+
project: string;
|
|
19
|
+
path: string;
|
|
20
|
+
}
|
|
21
|
+
interface ParseOptions {
|
|
22
|
+
sanitize?: boolean;
|
|
23
|
+
strict?: boolean;
|
|
24
|
+
}
|
|
25
|
+
declare const CODEX_URI_PREFIX = "codex://";
|
|
26
|
+
declare const LEGACY_REF_PREFIX = "@codex/";
|
|
27
|
+
declare function isValidUri(uri: string): boolean;
|
|
28
|
+
declare function isLegacyReference(ref: string): boolean;
|
|
29
|
+
declare function convertLegacyReference(ref: string, defaultOrg: string): string | null;
|
|
30
|
+
declare function parseReference(uri: string, options?: ParseOptions): ParsedReference | null;
|
|
31
|
+
declare function buildUri(org: string, project: string, path?: string): string;
|
|
32
|
+
declare function getExtension(uri: string): string;
|
|
33
|
+
declare function getFilename(uri: string): string;
|
|
34
|
+
declare function getDirectory(uri: string): string;
|
|
35
|
+
|
|
36
|
+
interface ResolvedReference extends ParsedReference {
|
|
37
|
+
cachePath: string;
|
|
38
|
+
isCurrentProject: boolean;
|
|
39
|
+
localPath?: string;
|
|
40
|
+
}
|
|
41
|
+
interface ResolveOptions {
|
|
42
|
+
cacheDir?: string;
|
|
43
|
+
currentOrg?: string;
|
|
44
|
+
currentProject?: string;
|
|
45
|
+
cwd?: string;
|
|
46
|
+
}
|
|
47
|
+
declare const DEFAULT_CACHE_DIR = ".fractary/plugins/codex/cache";
|
|
48
|
+
declare function detectCurrentProject(cwd?: string): {
|
|
49
|
+
org: string | null;
|
|
50
|
+
project: string | null;
|
|
51
|
+
};
|
|
52
|
+
declare function getCurrentContext(options?: ResolveOptions): {
|
|
53
|
+
org: string | null;
|
|
54
|
+
project: string | null;
|
|
55
|
+
};
|
|
56
|
+
declare function calculateCachePath(org: string, project: string, filePath: string, cacheDir: string): string;
|
|
57
|
+
declare function resolveReference(uri: string, options?: ResolveOptions): ResolvedReference | null;
|
|
58
|
+
declare function resolveReferences(uris: string[], options?: ResolveOptions): ResolvedReference[];
|
|
59
|
+
declare function isCurrentProjectUri(uri: string, options?: ResolveOptions): boolean;
|
|
60
|
+
declare function getRelativeCachePath(uri: string): string | null;
|
|
61
|
+
|
|
62
|
+
declare function validatePath(filePath: string): boolean;
|
|
63
|
+
declare function sanitizePath(filePath: string): string;
|
|
64
|
+
declare function validateOrg(org: string): boolean;
|
|
65
|
+
declare function validateProject(project: string): boolean;
|
|
66
|
+
declare function validateUri(uri: string): boolean;
|
|
67
|
+
|
|
68
|
+
interface ArtifactType {
|
|
69
|
+
name: string;
|
|
70
|
+
description: string;
|
|
71
|
+
patterns: string[];
|
|
72
|
+
defaultTtl: number;
|
|
73
|
+
archiveAfterDays: number | null;
|
|
74
|
+
archiveStorage: 'local' | 'cloud' | 'drive' | null;
|
|
75
|
+
syncPatterns?: string[];
|
|
76
|
+
excludePatterns?: string[];
|
|
77
|
+
permissions?: {
|
|
78
|
+
include: string[];
|
|
79
|
+
exclude: string[];
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
declare const TTL: {
|
|
83
|
+
readonly ONE_HOUR: 3600;
|
|
84
|
+
readonly ONE_DAY: 86400;
|
|
85
|
+
readonly ONE_WEEK: 604800;
|
|
86
|
+
readonly TWO_WEEKS: 1209600;
|
|
87
|
+
readonly ONE_MONTH: 2592000;
|
|
88
|
+
readonly ONE_YEAR: 31536000;
|
|
89
|
+
};
|
|
90
|
+
declare const BUILT_IN_TYPES: Record<string, ArtifactType>;
|
|
91
|
+
declare const DEFAULT_TYPE: ArtifactType;
|
|
92
|
+
declare function getBuiltInType(name: string): ArtifactType | undefined;
|
|
93
|
+
declare function getBuiltInTypeNames(): string[];
|
|
94
|
+
declare function isBuiltInType(name: string): boolean;
|
|
95
|
+
|
|
96
|
+
interface TypeRegistryOptions {
|
|
97
|
+
includeBuiltIn?: boolean;
|
|
98
|
+
customTypes?: Record<string, Partial<ArtifactType>>;
|
|
99
|
+
}
|
|
100
|
+
declare class TypeRegistry {
|
|
101
|
+
private types;
|
|
102
|
+
private patternCache;
|
|
103
|
+
constructor(options?: TypeRegistryOptions);
|
|
104
|
+
get(name: string): ArtifactType | undefined;
|
|
105
|
+
register(type: ArtifactType): void;
|
|
106
|
+
unregister(name: string): boolean;
|
|
107
|
+
has(name: string): boolean;
|
|
108
|
+
list(): ArtifactType[];
|
|
109
|
+
listNames(): string[];
|
|
110
|
+
detectType(filePath: string): string;
|
|
111
|
+
getTtl(filePath: string, override?: number): number;
|
|
112
|
+
getArchiveConfig(filePath: string): {
|
|
113
|
+
afterDays: number;
|
|
114
|
+
storage: 'local' | 'cloud' | 'drive';
|
|
115
|
+
} | null;
|
|
116
|
+
filterByType(typeName: string, files: string[]): string[];
|
|
117
|
+
isBuiltIn(name: string): boolean;
|
|
118
|
+
get size(): number;
|
|
119
|
+
clearCache(): void;
|
|
120
|
+
}
|
|
121
|
+
declare function createDefaultRegistry(): TypeRegistry;
|
|
122
|
+
|
|
123
|
+
declare const CustomTypeSchema: z.ZodObject<{
|
|
124
|
+
description: z.ZodOptional<z.ZodString>;
|
|
125
|
+
patterns: z.ZodArray<z.ZodString, "many">;
|
|
126
|
+
defaultTtl: z.ZodOptional<z.ZodNumber>;
|
|
127
|
+
archiveAfterDays: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
128
|
+
archiveStorage: z.ZodOptional<z.ZodNullable<z.ZodEnum<["local", "cloud", "drive"]>>>;
|
|
129
|
+
syncPatterns: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
130
|
+
excludePatterns: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
131
|
+
permissions: z.ZodOptional<z.ZodObject<{
|
|
132
|
+
include: z.ZodArray<z.ZodString, "many">;
|
|
133
|
+
exclude: z.ZodArray<z.ZodString, "many">;
|
|
134
|
+
}, "strip", z.ZodTypeAny, {
|
|
135
|
+
include: string[];
|
|
136
|
+
exclude: string[];
|
|
137
|
+
}, {
|
|
138
|
+
include: string[];
|
|
139
|
+
exclude: string[];
|
|
140
|
+
}>>;
|
|
141
|
+
}, "strip", z.ZodTypeAny, {
|
|
142
|
+
patterns: string[];
|
|
143
|
+
description?: string | undefined;
|
|
144
|
+
defaultTtl?: number | undefined;
|
|
145
|
+
archiveAfterDays?: number | null | undefined;
|
|
146
|
+
archiveStorage?: "local" | "cloud" | "drive" | null | undefined;
|
|
147
|
+
syncPatterns?: string[] | undefined;
|
|
148
|
+
excludePatterns?: string[] | undefined;
|
|
149
|
+
permissions?: {
|
|
150
|
+
include: string[];
|
|
151
|
+
exclude: string[];
|
|
152
|
+
} | undefined;
|
|
153
|
+
}, {
|
|
154
|
+
patterns: string[];
|
|
155
|
+
description?: string | undefined;
|
|
156
|
+
defaultTtl?: number | undefined;
|
|
157
|
+
archiveAfterDays?: number | null | undefined;
|
|
158
|
+
archiveStorage?: "local" | "cloud" | "drive" | null | undefined;
|
|
159
|
+
syncPatterns?: string[] | undefined;
|
|
160
|
+
excludePatterns?: string[] | undefined;
|
|
161
|
+
permissions?: {
|
|
162
|
+
include: string[];
|
|
163
|
+
exclude: string[];
|
|
164
|
+
} | undefined;
|
|
165
|
+
}>;
|
|
166
|
+
type CustomTypeConfig = z.infer<typeof CustomTypeSchema>;
|
|
167
|
+
declare const TypesConfigSchema: z.ZodObject<{
|
|
168
|
+
custom: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
169
|
+
description: z.ZodOptional<z.ZodString>;
|
|
170
|
+
patterns: z.ZodArray<z.ZodString, "many">;
|
|
171
|
+
defaultTtl: z.ZodOptional<z.ZodNumber>;
|
|
172
|
+
archiveAfterDays: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
173
|
+
archiveStorage: z.ZodOptional<z.ZodNullable<z.ZodEnum<["local", "cloud", "drive"]>>>;
|
|
174
|
+
syncPatterns: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
175
|
+
excludePatterns: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
176
|
+
permissions: z.ZodOptional<z.ZodObject<{
|
|
177
|
+
include: z.ZodArray<z.ZodString, "many">;
|
|
178
|
+
exclude: z.ZodArray<z.ZodString, "many">;
|
|
179
|
+
}, "strip", z.ZodTypeAny, {
|
|
180
|
+
include: string[];
|
|
181
|
+
exclude: string[];
|
|
182
|
+
}, {
|
|
183
|
+
include: string[];
|
|
184
|
+
exclude: string[];
|
|
185
|
+
}>>;
|
|
186
|
+
}, "strip", z.ZodTypeAny, {
|
|
187
|
+
patterns: string[];
|
|
188
|
+
description?: string | undefined;
|
|
189
|
+
defaultTtl?: number | undefined;
|
|
190
|
+
archiveAfterDays?: number | null | undefined;
|
|
191
|
+
archiveStorage?: "local" | "cloud" | "drive" | null | undefined;
|
|
192
|
+
syncPatterns?: string[] | undefined;
|
|
193
|
+
excludePatterns?: string[] | undefined;
|
|
194
|
+
permissions?: {
|
|
195
|
+
include: string[];
|
|
196
|
+
exclude: string[];
|
|
197
|
+
} | undefined;
|
|
198
|
+
}, {
|
|
199
|
+
patterns: string[];
|
|
200
|
+
description?: string | undefined;
|
|
201
|
+
defaultTtl?: number | undefined;
|
|
202
|
+
archiveAfterDays?: number | null | undefined;
|
|
203
|
+
archiveStorage?: "local" | "cloud" | "drive" | null | undefined;
|
|
204
|
+
syncPatterns?: string[] | undefined;
|
|
205
|
+
excludePatterns?: string[] | undefined;
|
|
206
|
+
permissions?: {
|
|
207
|
+
include: string[];
|
|
208
|
+
exclude: string[];
|
|
209
|
+
} | undefined;
|
|
210
|
+
}>>>;
|
|
211
|
+
}, "strip", z.ZodTypeAny, {
|
|
212
|
+
custom?: Record<string, {
|
|
213
|
+
patterns: string[];
|
|
214
|
+
description?: string | undefined;
|
|
215
|
+
defaultTtl?: number | undefined;
|
|
216
|
+
archiveAfterDays?: number | null | undefined;
|
|
217
|
+
archiveStorage?: "local" | "cloud" | "drive" | null | undefined;
|
|
218
|
+
syncPatterns?: string[] | undefined;
|
|
219
|
+
excludePatterns?: string[] | undefined;
|
|
220
|
+
permissions?: {
|
|
221
|
+
include: string[];
|
|
222
|
+
exclude: string[];
|
|
223
|
+
} | undefined;
|
|
224
|
+
}> | undefined;
|
|
225
|
+
}, {
|
|
226
|
+
custom?: Record<string, {
|
|
227
|
+
patterns: string[];
|
|
228
|
+
description?: string | undefined;
|
|
229
|
+
defaultTtl?: number | undefined;
|
|
230
|
+
archiveAfterDays?: number | null | undefined;
|
|
231
|
+
archiveStorage?: "local" | "cloud" | "drive" | null | undefined;
|
|
232
|
+
syncPatterns?: string[] | undefined;
|
|
233
|
+
excludePatterns?: string[] | undefined;
|
|
234
|
+
permissions?: {
|
|
235
|
+
include: string[];
|
|
236
|
+
exclude: string[];
|
|
237
|
+
} | undefined;
|
|
238
|
+
}> | undefined;
|
|
239
|
+
}>;
|
|
240
|
+
type TypesConfig = z.infer<typeof TypesConfigSchema>;
|
|
241
|
+
interface ValidationResult {
|
|
242
|
+
valid: boolean;
|
|
243
|
+
errors: Array<{
|
|
244
|
+
name: string;
|
|
245
|
+
field: string;
|
|
246
|
+
message: string;
|
|
247
|
+
}>;
|
|
248
|
+
}
|
|
249
|
+
declare function parseTtl(value: string | number): number;
|
|
250
|
+
declare function validateCustomTypes(config: unknown): ValidationResult;
|
|
251
|
+
declare function loadCustomTypes(config: TypesConfig): Map<string, ArtifactType>;
|
|
252
|
+
declare function mergeTypes(builtIn: Record<string, ArtifactType>, custom: Map<string, ArtifactType>): Map<string, ArtifactType>;
|
|
253
|
+
declare function extendType(baseName: string, overrides: Partial<Omit<ArtifactType, 'name'>>): Partial<ArtifactType>;
|
|
254
|
+
|
|
15
255
|
declare const MetadataSchema: z.ZodObject<{
|
|
16
256
|
org: z.ZodOptional<z.ZodString>;
|
|
17
257
|
system: z.ZodOptional<z.ZodString>;
|
|
18
258
|
codex_sync_include: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
19
259
|
codex_sync_exclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
260
|
+
codex_sync_custom: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
20
261
|
title: z.ZodOptional<z.ZodString>;
|
|
21
262
|
description: z.ZodOptional<z.ZodString>;
|
|
22
263
|
visibility: z.ZodOptional<z.ZodEnum<["public", "internal", "private"]>>;
|
|
@@ -29,6 +270,7 @@ declare const MetadataSchema: z.ZodObject<{
|
|
|
29
270
|
system: z.ZodOptional<z.ZodString>;
|
|
30
271
|
codex_sync_include: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
31
272
|
codex_sync_exclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
273
|
+
codex_sync_custom: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
32
274
|
title: z.ZodOptional<z.ZodString>;
|
|
33
275
|
description: z.ZodOptional<z.ZodString>;
|
|
34
276
|
visibility: z.ZodOptional<z.ZodEnum<["public", "internal", "private"]>>;
|
|
@@ -41,6 +283,7 @@ declare const MetadataSchema: z.ZodObject<{
|
|
|
41
283
|
system: z.ZodOptional<z.ZodString>;
|
|
42
284
|
codex_sync_include: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
43
285
|
codex_sync_exclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
286
|
+
codex_sync_custom: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
44
287
|
title: z.ZodOptional<z.ZodString>;
|
|
45
288
|
description: z.ZodOptional<z.ZodString>;
|
|
46
289
|
visibility: z.ZodOptional<z.ZodEnum<["public", "internal", "private"]>>;
|
|
@@ -56,12 +299,12 @@ declare const AutoSyncPatternSchema: z.ZodObject<{
|
|
|
56
299
|
include: z.ZodArray<z.ZodString, "many">;
|
|
57
300
|
exclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
58
301
|
}, "strip", z.ZodTypeAny, {
|
|
59
|
-
pattern: string;
|
|
60
302
|
include: string[];
|
|
303
|
+
pattern: string;
|
|
61
304
|
exclude?: string[] | undefined;
|
|
62
305
|
}, {
|
|
63
|
-
pattern: string;
|
|
64
306
|
include: string[];
|
|
307
|
+
pattern: string;
|
|
65
308
|
exclude?: string[] | undefined;
|
|
66
309
|
}>;
|
|
67
310
|
type AutoSyncPattern = z.infer<typeof AutoSyncPatternSchema>;
|
|
@@ -71,12 +314,12 @@ declare const SyncRulesSchema: z.ZodObject<{
|
|
|
71
314
|
include: z.ZodArray<z.ZodString, "many">;
|
|
72
315
|
exclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
73
316
|
}, "strip", z.ZodTypeAny, {
|
|
74
|
-
pattern: string;
|
|
75
317
|
include: string[];
|
|
318
|
+
pattern: string;
|
|
76
319
|
exclude?: string[] | undefined;
|
|
77
320
|
}, {
|
|
78
|
-
pattern: string;
|
|
79
321
|
include: string[];
|
|
322
|
+
pattern: string;
|
|
80
323
|
exclude?: string[] | undefined;
|
|
81
324
|
}>, "many">>;
|
|
82
325
|
preventSelfSync: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -86,8 +329,8 @@ declare const SyncRulesSchema: z.ZodObject<{
|
|
|
86
329
|
defaultExclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
87
330
|
}, "strip", z.ZodTypeAny, {
|
|
88
331
|
autoSyncPatterns?: {
|
|
89
|
-
pattern: string;
|
|
90
332
|
include: string[];
|
|
333
|
+
pattern: string;
|
|
91
334
|
exclude?: string[] | undefined;
|
|
92
335
|
}[] | undefined;
|
|
93
336
|
preventSelfSync?: boolean | undefined;
|
|
@@ -97,8 +340,8 @@ declare const SyncRulesSchema: z.ZodObject<{
|
|
|
97
340
|
defaultExclude?: string[] | undefined;
|
|
98
341
|
}, {
|
|
99
342
|
autoSyncPatterns?: {
|
|
100
|
-
pattern: string;
|
|
101
343
|
include: string[];
|
|
344
|
+
pattern: string;
|
|
102
345
|
exclude?: string[] | undefined;
|
|
103
346
|
}[] | undefined;
|
|
104
347
|
preventSelfSync?: boolean | undefined;
|
|
@@ -115,13 +358,13 @@ declare const CodexConfigSchema: z.ZodObject<{
|
|
|
115
358
|
target: z.ZodOptional<z.ZodString>;
|
|
116
359
|
systems: z.ZodOptional<z.ZodString>;
|
|
117
360
|
}, "strip", z.ZodTypeAny, {
|
|
361
|
+
systems?: string | undefined;
|
|
118
362
|
source?: string | undefined;
|
|
119
363
|
target?: string | undefined;
|
|
120
|
-
systems?: string | undefined;
|
|
121
364
|
}, {
|
|
365
|
+
systems?: string | undefined;
|
|
122
366
|
source?: string | undefined;
|
|
123
367
|
target?: string | undefined;
|
|
124
|
-
systems?: string | undefined;
|
|
125
368
|
}>>;
|
|
126
369
|
rules: z.ZodOptional<z.ZodObject<{
|
|
127
370
|
autoSyncPatterns: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -129,12 +372,12 @@ declare const CodexConfigSchema: z.ZodObject<{
|
|
|
129
372
|
include: z.ZodArray<z.ZodString, "many">;
|
|
130
373
|
exclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
131
374
|
}, "strip", z.ZodTypeAny, {
|
|
132
|
-
pattern: string;
|
|
133
375
|
include: string[];
|
|
376
|
+
pattern: string;
|
|
134
377
|
exclude?: string[] | undefined;
|
|
135
378
|
}, {
|
|
136
|
-
pattern: string;
|
|
137
379
|
include: string[];
|
|
380
|
+
pattern: string;
|
|
138
381
|
exclude?: string[] | undefined;
|
|
139
382
|
}>, "many">>;
|
|
140
383
|
preventSelfSync: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -144,8 +387,8 @@ declare const CodexConfigSchema: z.ZodObject<{
|
|
|
144
387
|
defaultExclude: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
145
388
|
}, "strip", z.ZodTypeAny, {
|
|
146
389
|
autoSyncPatterns?: {
|
|
147
|
-
pattern: string;
|
|
148
390
|
include: string[];
|
|
391
|
+
pattern: string;
|
|
149
392
|
exclude?: string[] | undefined;
|
|
150
393
|
}[] | undefined;
|
|
151
394
|
preventSelfSync?: boolean | undefined;
|
|
@@ -155,8 +398,8 @@ declare const CodexConfigSchema: z.ZodObject<{
|
|
|
155
398
|
defaultExclude?: string[] | undefined;
|
|
156
399
|
}, {
|
|
157
400
|
autoSyncPatterns?: {
|
|
158
|
-
pattern: string;
|
|
159
401
|
include: string[];
|
|
402
|
+
pattern: string;
|
|
160
403
|
exclude?: string[] | undefined;
|
|
161
404
|
}[] | undefined;
|
|
162
405
|
preventSelfSync?: boolean | undefined;
|
|
@@ -168,14 +411,14 @@ declare const CodexConfigSchema: z.ZodObject<{
|
|
|
168
411
|
}, "strict", z.ZodTypeAny, {
|
|
169
412
|
organizationSlug: string;
|
|
170
413
|
directories?: {
|
|
414
|
+
systems?: string | undefined;
|
|
171
415
|
source?: string | undefined;
|
|
172
416
|
target?: string | undefined;
|
|
173
|
-
systems?: string | undefined;
|
|
174
417
|
} | undefined;
|
|
175
418
|
rules?: {
|
|
176
419
|
autoSyncPatterns?: {
|
|
177
|
-
pattern: string;
|
|
178
420
|
include: string[];
|
|
421
|
+
pattern: string;
|
|
179
422
|
exclude?: string[] | undefined;
|
|
180
423
|
}[] | undefined;
|
|
181
424
|
preventSelfSync?: boolean | undefined;
|
|
@@ -187,14 +430,14 @@ declare const CodexConfigSchema: z.ZodObject<{
|
|
|
187
430
|
}, {
|
|
188
431
|
organizationSlug: string;
|
|
189
432
|
directories?: {
|
|
433
|
+
systems?: string | undefined;
|
|
190
434
|
source?: string | undefined;
|
|
191
435
|
target?: string | undefined;
|
|
192
|
-
systems?: string | undefined;
|
|
193
436
|
} | undefined;
|
|
194
437
|
rules?: {
|
|
195
438
|
autoSyncPatterns?: {
|
|
196
|
-
pattern: string;
|
|
197
439
|
include: string[];
|
|
440
|
+
pattern: string;
|
|
198
441
|
exclude?: string[] | undefined;
|
|
199
442
|
}[] | undefined;
|
|
200
443
|
preventSelfSync?: boolean | undefined;
|
|
@@ -271,4 +514,740 @@ declare function getTargetRepos(options: {
|
|
|
271
514
|
rules?: SyncRules;
|
|
272
515
|
}): string[];
|
|
273
516
|
|
|
274
|
-
|
|
517
|
+
interface CustomSyncDestination {
|
|
518
|
+
repo: string;
|
|
519
|
+
path: string;
|
|
520
|
+
}
|
|
521
|
+
declare function parseCustomDestination(value: string): CustomSyncDestination;
|
|
522
|
+
declare function getCustomSyncDestinations(metadata: Metadata): CustomSyncDestination[];
|
|
523
|
+
|
|
524
|
+
type StorageProviderType = 'local' | 'github' | 'http' | 's3' | 'r2' | 'gcs' | 'drive';
|
|
525
|
+
interface FetchResult {
|
|
526
|
+
content: Buffer;
|
|
527
|
+
contentType: string;
|
|
528
|
+
size: number;
|
|
529
|
+
source: string;
|
|
530
|
+
metadata?: Record<string, unknown>;
|
|
531
|
+
}
|
|
532
|
+
interface FetchOptions {
|
|
533
|
+
timeout?: number;
|
|
534
|
+
maxRetries?: number;
|
|
535
|
+
token?: string;
|
|
536
|
+
branch?: string;
|
|
537
|
+
followRedirects?: boolean;
|
|
538
|
+
maxSize?: number;
|
|
539
|
+
}
|
|
540
|
+
interface StorageProvider {
|
|
541
|
+
readonly name: string;
|
|
542
|
+
readonly type: StorageProviderType;
|
|
543
|
+
fetch(reference: ResolvedReference, options?: FetchOptions): Promise<FetchResult>;
|
|
544
|
+
exists(reference: ResolvedReference, options?: FetchOptions): Promise<boolean>;
|
|
545
|
+
canHandle(reference: ResolvedReference): boolean;
|
|
546
|
+
}
|
|
547
|
+
interface StorageProviderConfig {
|
|
548
|
+
type: StorageProviderType;
|
|
549
|
+
options?: Record<string, unknown>;
|
|
550
|
+
timeout?: number;
|
|
551
|
+
maxRetries?: number;
|
|
552
|
+
auth?: {
|
|
553
|
+
tokenEnv?: string;
|
|
554
|
+
token?: string;
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
declare const DEFAULT_FETCH_OPTIONS: Required<FetchOptions>;
|
|
558
|
+
declare function mergeFetchOptions(options?: FetchOptions): Required<FetchOptions>;
|
|
559
|
+
declare function detectContentType(path: string): string;
|
|
560
|
+
|
|
561
|
+
interface LocalStorageOptions {
|
|
562
|
+
baseDir?: string;
|
|
563
|
+
}
|
|
564
|
+
declare class LocalStorage implements StorageProvider {
|
|
565
|
+
readonly name = "local";
|
|
566
|
+
readonly type: "local";
|
|
567
|
+
private baseDir;
|
|
568
|
+
constructor(options?: LocalStorageOptions);
|
|
569
|
+
canHandle(reference: ResolvedReference): boolean;
|
|
570
|
+
fetch(reference: ResolvedReference, options?: FetchOptions): Promise<FetchResult>;
|
|
571
|
+
exists(reference: ResolvedReference): Promise<boolean>;
|
|
572
|
+
readText(filePath: string): Promise<string>;
|
|
573
|
+
write(filePath: string, content: string | Buffer): Promise<void>;
|
|
574
|
+
delete(filePath: string): Promise<boolean>;
|
|
575
|
+
list(dirPath: string): Promise<string[]>;
|
|
576
|
+
}
|
|
577
|
+
declare function createLocalStorage(options?: LocalStorageOptions): LocalStorage;
|
|
578
|
+
|
|
579
|
+
interface GitHubStorageOptions {
|
|
580
|
+
token?: string;
|
|
581
|
+
tokenEnv?: string;
|
|
582
|
+
apiBaseUrl?: string;
|
|
583
|
+
rawBaseUrl?: string;
|
|
584
|
+
defaultBranch?: string;
|
|
585
|
+
}
|
|
586
|
+
declare class GitHubStorage implements StorageProvider {
|
|
587
|
+
readonly name = "github";
|
|
588
|
+
readonly type: "github";
|
|
589
|
+
private apiBaseUrl;
|
|
590
|
+
private rawBaseUrl;
|
|
591
|
+
private defaultBranch;
|
|
592
|
+
private token?;
|
|
593
|
+
constructor(options?: GitHubStorageOptions);
|
|
594
|
+
canHandle(reference: ResolvedReference): boolean;
|
|
595
|
+
fetch(reference: ResolvedReference, options?: FetchOptions): Promise<FetchResult>;
|
|
596
|
+
private fetchRaw;
|
|
597
|
+
private fetchApi;
|
|
598
|
+
exists(reference: ResolvedReference, options?: FetchOptions): Promise<boolean>;
|
|
599
|
+
getRepoInfo(org: string, project: string): Promise<{
|
|
600
|
+
defaultBranch: string;
|
|
601
|
+
private: boolean;
|
|
602
|
+
size: number;
|
|
603
|
+
} | null>;
|
|
604
|
+
}
|
|
605
|
+
declare function createGitHubStorage(options?: GitHubStorageOptions): GitHubStorage;
|
|
606
|
+
|
|
607
|
+
interface HttpStorageOptions {
|
|
608
|
+
timeout?: number;
|
|
609
|
+
maxSize?: number;
|
|
610
|
+
headers?: Record<string, string>;
|
|
611
|
+
userAgent?: string;
|
|
612
|
+
}
|
|
613
|
+
declare class HttpStorage implements StorageProvider {
|
|
614
|
+
readonly name = "http";
|
|
615
|
+
readonly type: "http";
|
|
616
|
+
private defaultTimeout;
|
|
617
|
+
private defaultMaxSize;
|
|
618
|
+
private defaultHeaders;
|
|
619
|
+
constructor(options?: HttpStorageOptions);
|
|
620
|
+
canHandle(_reference: ResolvedReference): boolean;
|
|
621
|
+
fetch(reference: ResolvedReference, options?: FetchOptions): Promise<FetchResult>;
|
|
622
|
+
fetchUrl(url: string, options?: FetchOptions): Promise<FetchResult>;
|
|
623
|
+
exists(reference: ResolvedReference, options?: FetchOptions): Promise<boolean>;
|
|
624
|
+
urlExists(url: string, options?: FetchOptions): Promise<boolean>;
|
|
625
|
+
}
|
|
626
|
+
declare function createHttpStorage(options?: HttpStorageOptions): HttpStorage;
|
|
627
|
+
|
|
628
|
+
interface StorageManagerConfig {
|
|
629
|
+
local?: LocalStorageOptions;
|
|
630
|
+
github?: GitHubStorageOptions;
|
|
631
|
+
http?: HttpStorageOptions;
|
|
632
|
+
priority?: StorageProviderType[];
|
|
633
|
+
enableCaching?: boolean;
|
|
634
|
+
}
|
|
635
|
+
declare class StorageManager {
|
|
636
|
+
private providers;
|
|
637
|
+
private priority;
|
|
638
|
+
constructor(config?: StorageManagerConfig);
|
|
639
|
+
registerProvider(provider: StorageProvider): void;
|
|
640
|
+
removeProvider(type: StorageProviderType): boolean;
|
|
641
|
+
getProvider(type: StorageProviderType): StorageProvider | undefined;
|
|
642
|
+
getProviders(): StorageProvider[];
|
|
643
|
+
findProvider(reference: ResolvedReference): StorageProvider | null;
|
|
644
|
+
fetch(reference: ResolvedReference, options?: FetchOptions): Promise<FetchResult>;
|
|
645
|
+
exists(reference: ResolvedReference, options?: FetchOptions): Promise<boolean>;
|
|
646
|
+
fetchWith(type: StorageProviderType, reference: ResolvedReference, options?: FetchOptions): Promise<FetchResult>;
|
|
647
|
+
fetchMany(references: ResolvedReference[], options?: FetchOptions): Promise<Map<string, FetchResult | Error>>;
|
|
648
|
+
getStatus(): Array<{
|
|
649
|
+
type: StorageProviderType;
|
|
650
|
+
name: string;
|
|
651
|
+
priority: number;
|
|
652
|
+
}>;
|
|
653
|
+
}
|
|
654
|
+
declare function createStorageManager(config?: StorageManagerConfig): StorageManager;
|
|
655
|
+
declare function getDefaultStorageManager(): StorageManager;
|
|
656
|
+
declare function setDefaultStorageManager(manager: StorageManager): void;
|
|
657
|
+
|
|
658
|
+
type CacheEntryStatus = 'fresh' | 'stale' | 'expired';
|
|
659
|
+
interface CacheEntryMetadata {
|
|
660
|
+
uri: string;
|
|
661
|
+
cachedAt: number;
|
|
662
|
+
expiresAt: number;
|
|
663
|
+
ttl: number;
|
|
664
|
+
etag?: string;
|
|
665
|
+
lastModified?: string;
|
|
666
|
+
contentHash: string;
|
|
667
|
+
size: number;
|
|
668
|
+
contentType: string;
|
|
669
|
+
source: string;
|
|
670
|
+
accessCount: number;
|
|
671
|
+
lastAccessedAt: number;
|
|
672
|
+
providerMetadata?: Record<string, unknown>;
|
|
673
|
+
}
|
|
674
|
+
interface CacheEntry {
|
|
675
|
+
metadata: CacheEntryMetadata;
|
|
676
|
+
content: Buffer;
|
|
677
|
+
}
|
|
678
|
+
interface SerializedCacheEntry {
|
|
679
|
+
metadata: CacheEntryMetadata;
|
|
680
|
+
content: string;
|
|
681
|
+
}
|
|
682
|
+
declare function calculateContentHash(content: Buffer): string;
|
|
683
|
+
declare function createCacheEntry(uri: string, result: FetchResult, ttl: number): CacheEntry;
|
|
684
|
+
declare function getCacheEntryStatus(entry: CacheEntry): CacheEntryStatus;
|
|
685
|
+
declare function isCacheEntryValid(entry: CacheEntry): boolean;
|
|
686
|
+
declare function isCacheEntryFresh(entry: CacheEntry): boolean;
|
|
687
|
+
declare function touchCacheEntry(entry: CacheEntry): void;
|
|
688
|
+
declare function serializeCacheEntry(entry: CacheEntry): SerializedCacheEntry;
|
|
689
|
+
declare function deserializeCacheEntry(serialized: SerializedCacheEntry): CacheEntry;
|
|
690
|
+
declare function getRemainingTtl(entry: CacheEntry): number;
|
|
691
|
+
declare function hasContentChanged(entry: CacheEntry, newContent: Buffer): boolean;
|
|
692
|
+
declare function getCacheEntryAge(entry: CacheEntry): number;
|
|
693
|
+
|
|
694
|
+
interface CachePersistenceOptions {
|
|
695
|
+
cacheDir: string;
|
|
696
|
+
extension?: string;
|
|
697
|
+
atomicWrites?: boolean;
|
|
698
|
+
}
|
|
699
|
+
interface CacheStats {
|
|
700
|
+
entryCount: number;
|
|
701
|
+
totalSize: number;
|
|
702
|
+
freshCount: number;
|
|
703
|
+
staleCount: number;
|
|
704
|
+
expiredCount: number;
|
|
705
|
+
}
|
|
706
|
+
declare class CachePersistence {
|
|
707
|
+
private cacheDir;
|
|
708
|
+
private extension;
|
|
709
|
+
private atomicWrites;
|
|
710
|
+
constructor(options: CachePersistenceOptions);
|
|
711
|
+
getCachePath(uri: string): string;
|
|
712
|
+
getMetadataPath(uri: string): string;
|
|
713
|
+
read(uri: string): Promise<CacheEntry | null>;
|
|
714
|
+
write(entry: CacheEntry): Promise<void>;
|
|
715
|
+
delete(uri: string): Promise<boolean>;
|
|
716
|
+
exists(uri: string): Promise<boolean>;
|
|
717
|
+
list(): Promise<string[]>;
|
|
718
|
+
private listFilesRecursive;
|
|
719
|
+
clear(): Promise<number>;
|
|
720
|
+
clearExpired(): Promise<number>;
|
|
721
|
+
getStats(): Promise<CacheStats>;
|
|
722
|
+
ensureDir(): Promise<void>;
|
|
723
|
+
getCacheDir(): string;
|
|
724
|
+
}
|
|
725
|
+
declare function createCachePersistence(options: CachePersistenceOptions): CachePersistence;
|
|
726
|
+
|
|
727
|
+
interface CacheManagerConfig {
|
|
728
|
+
cacheDir: string;
|
|
729
|
+
defaultTtl?: number;
|
|
730
|
+
maxMemoryEntries?: number;
|
|
731
|
+
maxMemorySize?: number;
|
|
732
|
+
enablePersistence?: boolean;
|
|
733
|
+
staleWhileRevalidate?: boolean;
|
|
734
|
+
backgroundRefreshThreshold?: number;
|
|
735
|
+
}
|
|
736
|
+
interface CacheLookupResult {
|
|
737
|
+
entry: CacheEntry | null;
|
|
738
|
+
hit: boolean;
|
|
739
|
+
fresh: boolean;
|
|
740
|
+
source: 'memory' | 'disk' | 'network' | 'none';
|
|
741
|
+
}
|
|
742
|
+
declare class CacheManager {
|
|
743
|
+
private memoryCache;
|
|
744
|
+
private persistence;
|
|
745
|
+
private storage;
|
|
746
|
+
private config;
|
|
747
|
+
private accessOrder;
|
|
748
|
+
private refreshPromises;
|
|
749
|
+
constructor(config: CacheManagerConfig);
|
|
750
|
+
setStorageManager(storage: StorageManager): void;
|
|
751
|
+
get(reference: ResolvedReference, options?: FetchOptions & {
|
|
752
|
+
ttl?: number;
|
|
753
|
+
}): Promise<FetchResult>;
|
|
754
|
+
has(uri: string): Promise<boolean>;
|
|
755
|
+
lookup(uri: string): Promise<CacheLookupResult>;
|
|
756
|
+
set(uri: string, result: FetchResult, ttl?: number): Promise<CacheEntry>;
|
|
757
|
+
invalidate(uri: string): Promise<boolean>;
|
|
758
|
+
invalidatePattern(pattern: RegExp): Promise<number>;
|
|
759
|
+
clear(): Promise<void>;
|
|
760
|
+
clearExpired(): Promise<number>;
|
|
761
|
+
getStats(): Promise<CacheStats & {
|
|
762
|
+
memoryEntries: number;
|
|
763
|
+
memorySize: number;
|
|
764
|
+
}>;
|
|
765
|
+
preload(references: ResolvedReference[], options?: FetchOptions): Promise<void>;
|
|
766
|
+
getMetadata(uri: string): Promise<CacheEntryMetadata | null>;
|
|
767
|
+
getTtl(uri: string): Promise<number | null>;
|
|
768
|
+
private fetchAndCache;
|
|
769
|
+
private backgroundRefresh;
|
|
770
|
+
private setMemoryEntry;
|
|
771
|
+
private evictIfNeeded;
|
|
772
|
+
private evictOldest;
|
|
773
|
+
private removeFromAccessOrder;
|
|
774
|
+
private entryToResult;
|
|
775
|
+
}
|
|
776
|
+
declare function createCacheManager(config: CacheManagerConfig): CacheManager;
|
|
777
|
+
declare function getDefaultCacheManager(): CacheManager;
|
|
778
|
+
declare function setDefaultCacheManager(manager: CacheManager): void;
|
|
779
|
+
|
|
780
|
+
interface McpTool {
|
|
781
|
+
name: string;
|
|
782
|
+
description: string;
|
|
783
|
+
inputSchema: {
|
|
784
|
+
type: 'object';
|
|
785
|
+
properties: Record<string, unknown>;
|
|
786
|
+
required?: string[];
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
interface McpResource {
|
|
790
|
+
uri: string;
|
|
791
|
+
name: string;
|
|
792
|
+
description?: string;
|
|
793
|
+
mimeType?: string;
|
|
794
|
+
}
|
|
795
|
+
interface McpResourceTemplate {
|
|
796
|
+
uriTemplate: string;
|
|
797
|
+
name: string;
|
|
798
|
+
description?: string;
|
|
799
|
+
mimeType?: string;
|
|
800
|
+
}
|
|
801
|
+
interface FetchToolArgs {
|
|
802
|
+
uri: string;
|
|
803
|
+
branch?: string;
|
|
804
|
+
noCache?: boolean;
|
|
805
|
+
}
|
|
806
|
+
interface SearchToolArgs {
|
|
807
|
+
query: string;
|
|
808
|
+
org?: string;
|
|
809
|
+
project?: string;
|
|
810
|
+
limit?: number;
|
|
811
|
+
type?: string;
|
|
812
|
+
}
|
|
813
|
+
interface ListToolArgs {
|
|
814
|
+
org?: string;
|
|
815
|
+
project?: string;
|
|
816
|
+
includeExpired?: boolean;
|
|
817
|
+
}
|
|
818
|
+
interface InvalidateToolArgs {
|
|
819
|
+
pattern: string;
|
|
820
|
+
}
|
|
821
|
+
interface ToolResult {
|
|
822
|
+
content: Array<{
|
|
823
|
+
type: 'text' | 'resource';
|
|
824
|
+
text?: string;
|
|
825
|
+
resource?: {
|
|
826
|
+
uri: string;
|
|
827
|
+
mimeType?: string;
|
|
828
|
+
text?: string;
|
|
829
|
+
blob?: string;
|
|
830
|
+
};
|
|
831
|
+
}>;
|
|
832
|
+
isError?: boolean;
|
|
833
|
+
}
|
|
834
|
+
interface ResourceContent {
|
|
835
|
+
uri: string;
|
|
836
|
+
mimeType?: string;
|
|
837
|
+
text?: string;
|
|
838
|
+
blob?: string;
|
|
839
|
+
}
|
|
840
|
+
interface McpCapabilities {
|
|
841
|
+
tools?: {
|
|
842
|
+
listChanged?: boolean;
|
|
843
|
+
};
|
|
844
|
+
resources?: {
|
|
845
|
+
subscribe?: boolean;
|
|
846
|
+
listChanged?: boolean;
|
|
847
|
+
};
|
|
848
|
+
prompts?: {
|
|
849
|
+
listChanged?: boolean;
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
interface McpServerInfo {
|
|
853
|
+
name: string;
|
|
854
|
+
version: string;
|
|
855
|
+
capabilities: McpCapabilities;
|
|
856
|
+
}
|
|
857
|
+
interface SearchResult {
|
|
858
|
+
uri: string;
|
|
859
|
+
title?: string;
|
|
860
|
+
snippet?: string;
|
|
861
|
+
score?: number;
|
|
862
|
+
metadata?: Record<string, unknown>;
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
declare const CODEX_TOOLS: McpTool[];
|
|
866
|
+
interface ToolHandlerContext {
|
|
867
|
+
cache: CacheManager;
|
|
868
|
+
storage: StorageManager;
|
|
869
|
+
}
|
|
870
|
+
declare function handleFetch(args: FetchToolArgs, ctx: ToolHandlerContext): Promise<ToolResult>;
|
|
871
|
+
declare function handleSearch(args: SearchToolArgs, ctx: ToolHandlerContext): Promise<ToolResult>;
|
|
872
|
+
declare function handleList(args: ListToolArgs, ctx: ToolHandlerContext): Promise<ToolResult>;
|
|
873
|
+
declare function handleInvalidate(args: InvalidateToolArgs, ctx: ToolHandlerContext): Promise<ToolResult>;
|
|
874
|
+
declare function handleToolCall(name: string, args: Record<string, unknown>, ctx: ToolHandlerContext): Promise<ToolResult>;
|
|
875
|
+
|
|
876
|
+
interface McpServerConfig {
|
|
877
|
+
name?: string;
|
|
878
|
+
version?: string;
|
|
879
|
+
cache: CacheManager;
|
|
880
|
+
storage: StorageManager;
|
|
881
|
+
}
|
|
882
|
+
declare class McpServer {
|
|
883
|
+
private config;
|
|
884
|
+
private toolContext;
|
|
885
|
+
constructor(config: McpServerConfig);
|
|
886
|
+
getServerInfo(): McpServerInfo;
|
|
887
|
+
getCapabilities(): McpCapabilities;
|
|
888
|
+
listTools(): McpTool[];
|
|
889
|
+
callTool(name: string, args: Record<string, unknown>): Promise<ToolResult>;
|
|
890
|
+
listResources(): Promise<McpResource[]>;
|
|
891
|
+
listResourceTemplates(): McpResourceTemplate[];
|
|
892
|
+
readResource(uri: string): Promise<ResourceContent[]>;
|
|
893
|
+
handleRequest(method: string, params?: Record<string, unknown>): Promise<unknown>;
|
|
894
|
+
processMessage(message: string): Promise<string>;
|
|
895
|
+
}
|
|
896
|
+
declare function createMcpServer(config: McpServerConfig): McpServer;
|
|
897
|
+
|
|
898
|
+
type SyncDirection = 'to-codex' | 'from-codex' | 'bidirectional';
|
|
899
|
+
type SyncOperation = 'create' | 'update' | 'delete' | 'skip' | 'conflict';
|
|
900
|
+
interface FileSyncStatus {
|
|
901
|
+
path: string;
|
|
902
|
+
operation: SyncOperation;
|
|
903
|
+
size?: number;
|
|
904
|
+
mtime?: number;
|
|
905
|
+
hash?: string;
|
|
906
|
+
reason?: string;
|
|
907
|
+
}
|
|
908
|
+
interface SyncManifestEntry {
|
|
909
|
+
path: string;
|
|
910
|
+
hash: string;
|
|
911
|
+
size: number;
|
|
912
|
+
syncedAt: number;
|
|
913
|
+
source: 'local' | 'remote';
|
|
914
|
+
}
|
|
915
|
+
interface SyncManifest {
|
|
916
|
+
version: number;
|
|
917
|
+
org: string;
|
|
918
|
+
project: string;
|
|
919
|
+
lastSync: number;
|
|
920
|
+
entries: Record<string, SyncManifestEntry>;
|
|
921
|
+
}
|
|
922
|
+
interface SyncPlan {
|
|
923
|
+
direction: SyncDirection;
|
|
924
|
+
source: string;
|
|
925
|
+
target: string;
|
|
926
|
+
files: FileSyncStatus[];
|
|
927
|
+
totalFiles: number;
|
|
928
|
+
totalBytes: number;
|
|
929
|
+
estimatedTime?: number;
|
|
930
|
+
conflicts: FileSyncStatus[];
|
|
931
|
+
skipped: FileSyncStatus[];
|
|
932
|
+
}
|
|
933
|
+
interface SyncResult {
|
|
934
|
+
success: boolean;
|
|
935
|
+
plan: SyncPlan;
|
|
936
|
+
synced: number;
|
|
937
|
+
failed: number;
|
|
938
|
+
skipped: number;
|
|
939
|
+
errors: Array<{
|
|
940
|
+
path: string;
|
|
941
|
+
error: string;
|
|
942
|
+
}>;
|
|
943
|
+
duration: number;
|
|
944
|
+
timestamp: number;
|
|
945
|
+
}
|
|
946
|
+
interface SyncOptions {
|
|
947
|
+
direction?: SyncDirection;
|
|
948
|
+
dryRun?: boolean;
|
|
949
|
+
force?: boolean;
|
|
950
|
+
delete?: boolean;
|
|
951
|
+
include?: string[];
|
|
952
|
+
exclude?: string[];
|
|
953
|
+
maxFiles?: number;
|
|
954
|
+
timeout?: number;
|
|
955
|
+
onProgress?: (current: number, total: number, file: string) => void;
|
|
956
|
+
}
|
|
957
|
+
interface SyncRule {
|
|
958
|
+
pattern: string;
|
|
959
|
+
include: boolean;
|
|
960
|
+
priority?: number;
|
|
961
|
+
direction?: SyncDirection;
|
|
962
|
+
}
|
|
963
|
+
interface SyncConfig {
|
|
964
|
+
defaultDirection: SyncDirection;
|
|
965
|
+
rules: SyncRule[];
|
|
966
|
+
defaultExcludes: string[];
|
|
967
|
+
deleteOrphans: boolean;
|
|
968
|
+
conflictStrategy: 'newest' | 'local' | 'remote' | 'manual';
|
|
969
|
+
}
|
|
970
|
+
declare const DEFAULT_SYNC_CONFIG: SyncConfig;
|
|
971
|
+
|
|
972
|
+
interface EvaluationResult {
|
|
973
|
+
path: string;
|
|
974
|
+
shouldSync: boolean;
|
|
975
|
+
matchedRule?: SyncRule;
|
|
976
|
+
reason: string;
|
|
977
|
+
}
|
|
978
|
+
declare function evaluatePath(path: string, rules: SyncRule[], direction: SyncDirection, defaultExcludes?: string[]): EvaluationResult;
|
|
979
|
+
declare function evaluatePaths(paths: string[], rules: SyncRule[], direction: SyncDirection, defaultExcludes?: string[]): Map<string, EvaluationResult>;
|
|
980
|
+
declare function filterSyncablePaths(paths: string[], rules: SyncRule[], direction: SyncDirection, defaultExcludes?: string[]): string[];
|
|
981
|
+
declare function createRulesFromPatterns(include?: string[], exclude?: string[]): SyncRule[];
|
|
982
|
+
declare function mergeRules(...ruleSets: SyncRule[][]): SyncRule[];
|
|
983
|
+
interface EvaluationSummary {
|
|
984
|
+
total: number;
|
|
985
|
+
included: number;
|
|
986
|
+
excluded: number;
|
|
987
|
+
byReason: Record<string, number>;
|
|
988
|
+
}
|
|
989
|
+
declare function summarizeEvaluations(results: Map<string, EvaluationResult>): EvaluationSummary;
|
|
990
|
+
declare function validateRules$1(rules: SyncRule[]): string[];
|
|
991
|
+
|
|
992
|
+
interface FileInfo {
|
|
993
|
+
path: string;
|
|
994
|
+
size: number;
|
|
995
|
+
mtime: number;
|
|
996
|
+
hash?: string;
|
|
997
|
+
}
|
|
998
|
+
declare function createSyncPlan(sourceFiles: FileInfo[], targetFiles: FileInfo[], options: SyncOptions, config: SyncConfig): SyncPlan;
|
|
999
|
+
declare function estimateSyncTime(plan: SyncPlan, bytesPerSecond?: number): number;
|
|
1000
|
+
declare function createEmptySyncPlan(direction?: SyncDirection): SyncPlan;
|
|
1001
|
+
declare function filterPlanOperations(plan: SyncPlan, operations: Array<'create' | 'update' | 'delete'>): SyncPlan;
|
|
1002
|
+
interface PlanStats {
|
|
1003
|
+
creates: number;
|
|
1004
|
+
updates: number;
|
|
1005
|
+
deletes: number;
|
|
1006
|
+
skips: number;
|
|
1007
|
+
conflicts: number;
|
|
1008
|
+
totalBytes: number;
|
|
1009
|
+
}
|
|
1010
|
+
declare function getPlanStats(plan: SyncPlan): PlanStats;
|
|
1011
|
+
declare function formatPlanSummary(plan: SyncPlan): string;
|
|
1012
|
+
|
|
1013
|
+
interface SyncManagerConfig {
|
|
1014
|
+
localStorage: LocalStorage;
|
|
1015
|
+
config?: Partial<SyncConfig>;
|
|
1016
|
+
manifestPath?: string;
|
|
1017
|
+
}
|
|
1018
|
+
declare class SyncManager {
|
|
1019
|
+
private localStorage;
|
|
1020
|
+
private config;
|
|
1021
|
+
private manifestPath;
|
|
1022
|
+
private manifest;
|
|
1023
|
+
constructor(options: SyncManagerConfig);
|
|
1024
|
+
loadManifest(): Promise<SyncManifest | null>;
|
|
1025
|
+
saveManifest(manifest: SyncManifest): Promise<void>;
|
|
1026
|
+
getOrCreateManifest(org: string, project: string): Promise<SyncManifest>;
|
|
1027
|
+
listLocalFiles(directory: string): Promise<FileInfo[]>;
|
|
1028
|
+
createPlan(_org: string, _project: string, sourceDir: string, targetFiles: FileInfo[], options?: SyncOptions): Promise<SyncPlan>;
|
|
1029
|
+
executePlan(plan: SyncPlan, options?: SyncOptions): Promise<SyncResult>;
|
|
1030
|
+
updateManifest(org: string, project: string, syncedFiles: FileSyncStatus[]): Promise<void>;
|
|
1031
|
+
getFileStatus(path: string): Promise<SyncManifestEntry | null>;
|
|
1032
|
+
isFileSynced(path: string): Promise<boolean>;
|
|
1033
|
+
getLastSyncTime(): Promise<number | null>;
|
|
1034
|
+
clearManifest(): Promise<void>;
|
|
1035
|
+
getConfig(): SyncConfig;
|
|
1036
|
+
updateConfig(updates: Partial<SyncConfig>): void;
|
|
1037
|
+
}
|
|
1038
|
+
declare function createSyncManager(config: SyncManagerConfig): SyncManager;
|
|
1039
|
+
|
|
1040
|
+
type PermissionLevel = 'none' | 'read' | 'write' | 'admin';
|
|
1041
|
+
type PermissionScope = 'global' | 'org' | 'project' | 'path';
|
|
1042
|
+
type PermissionAction = 'fetch' | 'cache' | 'sync' | 'invalidate' | 'manage';
|
|
1043
|
+
interface PermissionRule {
|
|
1044
|
+
id?: string;
|
|
1045
|
+
pattern: string;
|
|
1046
|
+
actions: PermissionAction[];
|
|
1047
|
+
level: PermissionLevel;
|
|
1048
|
+
scope: PermissionScope;
|
|
1049
|
+
org?: string;
|
|
1050
|
+
project?: string;
|
|
1051
|
+
priority?: number;
|
|
1052
|
+
description?: string;
|
|
1053
|
+
enabled?: boolean;
|
|
1054
|
+
}
|
|
1055
|
+
interface PermissionContext {
|
|
1056
|
+
org?: string;
|
|
1057
|
+
project?: string;
|
|
1058
|
+
environment?: string;
|
|
1059
|
+
identity?: string;
|
|
1060
|
+
metadata?: Record<string, unknown>;
|
|
1061
|
+
}
|
|
1062
|
+
interface PermissionResult {
|
|
1063
|
+
allowed: boolean;
|
|
1064
|
+
level: PermissionLevel;
|
|
1065
|
+
matchedRule?: PermissionRule;
|
|
1066
|
+
reason: string;
|
|
1067
|
+
}
|
|
1068
|
+
interface PermissionConfig {
|
|
1069
|
+
defaultLevel: PermissionLevel;
|
|
1070
|
+
defaultAllow: boolean;
|
|
1071
|
+
rules: PermissionRule[];
|
|
1072
|
+
enforced: boolean;
|
|
1073
|
+
}
|
|
1074
|
+
declare const DEFAULT_PERMISSION_CONFIG: PermissionConfig;
|
|
1075
|
+
declare const PERMISSION_LEVEL_ORDER: PermissionLevel[];
|
|
1076
|
+
declare function levelGrants(granted: PermissionLevel, required: PermissionLevel): boolean;
|
|
1077
|
+
declare function maxLevel(a: PermissionLevel, b: PermissionLevel): PermissionLevel;
|
|
1078
|
+
declare function minLevel(a: PermissionLevel, b: PermissionLevel): PermissionLevel;
|
|
1079
|
+
|
|
1080
|
+
declare function ruleMatchesContext(rule: PermissionRule, context: PermissionContext): boolean;
|
|
1081
|
+
declare function ruleMatchesPath(rule: PermissionRule, path: string): boolean;
|
|
1082
|
+
declare function ruleMatchesAction(rule: PermissionRule, action: PermissionAction): boolean;
|
|
1083
|
+
declare function evaluatePermission(path: string, action: PermissionAction, context: PermissionContext, config: PermissionConfig): PermissionResult;
|
|
1084
|
+
declare function isAllowed(path: string, action: PermissionAction, context: PermissionContext, config: PermissionConfig): boolean;
|
|
1085
|
+
declare function hasPermission(path: string, action: PermissionAction, requiredLevel: PermissionLevel, context: PermissionContext, config: PermissionConfig): boolean;
|
|
1086
|
+
declare function evaluatePermissions(paths: string[], action: PermissionAction, context: PermissionContext, config: PermissionConfig): Map<string, PermissionResult>;
|
|
1087
|
+
declare function filterByPermission(paths: string[], action: PermissionAction, context: PermissionContext, config: PermissionConfig, requiredLevel?: PermissionLevel): string[];
|
|
1088
|
+
declare function validateRules(rules: PermissionRule[]): string[];
|
|
1089
|
+
declare function createRule(options: {
|
|
1090
|
+
pattern: string;
|
|
1091
|
+
actions: PermissionAction[];
|
|
1092
|
+
level: PermissionLevel;
|
|
1093
|
+
scope?: PermissionRule['scope'];
|
|
1094
|
+
org?: string;
|
|
1095
|
+
project?: string;
|
|
1096
|
+
priority?: number;
|
|
1097
|
+
description?: string;
|
|
1098
|
+
}): PermissionRule;
|
|
1099
|
+
declare const CommonRules: {
|
|
1100
|
+
allowDocs: () => PermissionRule;
|
|
1101
|
+
denyPrivate: () => PermissionRule;
|
|
1102
|
+
readOnlySpecs: () => PermissionRule;
|
|
1103
|
+
adminManage: () => PermissionRule;
|
|
1104
|
+
};
|
|
1105
|
+
|
|
1106
|
+
interface PermissionManagerConfig {
|
|
1107
|
+
config?: Partial<PermissionConfig>;
|
|
1108
|
+
defaultContext?: PermissionContext;
|
|
1109
|
+
}
|
|
1110
|
+
declare class PermissionManager {
|
|
1111
|
+
private config;
|
|
1112
|
+
private defaultContext;
|
|
1113
|
+
constructor(options?: PermissionManagerConfig);
|
|
1114
|
+
isAllowed(path: string, action: PermissionAction, context?: PermissionContext): boolean;
|
|
1115
|
+
hasPermission(path: string, action: PermissionAction, requiredLevel: PermissionLevel, context?: PermissionContext): boolean;
|
|
1116
|
+
evaluate(path: string, action: PermissionAction, context?: PermissionContext): PermissionResult;
|
|
1117
|
+
filterAllowed(paths: string[], action: PermissionAction, context?: PermissionContext, requiredLevel?: PermissionLevel): string[];
|
|
1118
|
+
addRule(rule: PermissionRule): void;
|
|
1119
|
+
removeRule(id: string): boolean;
|
|
1120
|
+
getRules(): PermissionRule[];
|
|
1121
|
+
clearRules(): void;
|
|
1122
|
+
setRules(rules: PermissionRule[]): void;
|
|
1123
|
+
getConfig(): PermissionConfig;
|
|
1124
|
+
updateConfig(updates: Partial<Omit<PermissionConfig, 'rules'>>): void;
|
|
1125
|
+
setDefaultContext(context: PermissionContext): void;
|
|
1126
|
+
getDefaultContext(): PermissionContext;
|
|
1127
|
+
enable(): void;
|
|
1128
|
+
disable(): void;
|
|
1129
|
+
isEnforced(): boolean;
|
|
1130
|
+
assertPermission(path: string, action: PermissionAction, requiredLevel?: PermissionLevel, context?: PermissionContext): void;
|
|
1131
|
+
}
|
|
1132
|
+
declare class PermissionDeniedError extends Error {
|
|
1133
|
+
readonly path: string;
|
|
1134
|
+
readonly action: PermissionAction;
|
|
1135
|
+
readonly result: PermissionResult;
|
|
1136
|
+
constructor(message: string, path: string, action: PermissionAction, result: PermissionResult);
|
|
1137
|
+
}
|
|
1138
|
+
declare function createPermissionManager(config?: PermissionManagerConfig): PermissionManager;
|
|
1139
|
+
declare function getDefaultPermissionManager(): PermissionManager;
|
|
1140
|
+
declare function setDefaultPermissionManager(manager: PermissionManager): void;
|
|
1141
|
+
|
|
1142
|
+
interface LegacyCodexConfig {
|
|
1143
|
+
org?: string;
|
|
1144
|
+
defaultOrg?: string;
|
|
1145
|
+
codexRepo?: string;
|
|
1146
|
+
codexPath?: string;
|
|
1147
|
+
autoSync?: LegacyAutoSyncPattern[];
|
|
1148
|
+
syncRules?: {
|
|
1149
|
+
include?: string[];
|
|
1150
|
+
exclude?: string[];
|
|
1151
|
+
};
|
|
1152
|
+
environments?: Record<string, Partial<LegacyCodexConfig>>;
|
|
1153
|
+
}
|
|
1154
|
+
interface LegacyAutoSyncPattern {
|
|
1155
|
+
pattern: string;
|
|
1156
|
+
destination?: string;
|
|
1157
|
+
targets?: string[];
|
|
1158
|
+
bidirectional?: boolean;
|
|
1159
|
+
}
|
|
1160
|
+
interface ModernCodexConfig {
|
|
1161
|
+
version: '3.0';
|
|
1162
|
+
organization: {
|
|
1163
|
+
name: string;
|
|
1164
|
+
codexRepo: string;
|
|
1165
|
+
};
|
|
1166
|
+
sync: {
|
|
1167
|
+
patterns: ModernSyncPattern[];
|
|
1168
|
+
include: string[];
|
|
1169
|
+
exclude: string[];
|
|
1170
|
+
defaultDirection: 'to-codex' | 'from-codex' | 'bidirectional';
|
|
1171
|
+
};
|
|
1172
|
+
cache?: {
|
|
1173
|
+
directory?: string;
|
|
1174
|
+
defaultTtl?: number;
|
|
1175
|
+
maxSize?: number;
|
|
1176
|
+
};
|
|
1177
|
+
environments?: Record<string, Partial<Omit<ModernCodexConfig, 'version'>>>;
|
|
1178
|
+
}
|
|
1179
|
+
interface ModernSyncPattern {
|
|
1180
|
+
pattern: string;
|
|
1181
|
+
target?: string;
|
|
1182
|
+
direction?: 'to-codex' | 'from-codex' | 'bidirectional';
|
|
1183
|
+
priority?: number;
|
|
1184
|
+
}
|
|
1185
|
+
interface MigrationResult {
|
|
1186
|
+
success: boolean;
|
|
1187
|
+
config?: ModernCodexConfig;
|
|
1188
|
+
warnings: string[];
|
|
1189
|
+
errors: string[];
|
|
1190
|
+
changes: MigrationChange[];
|
|
1191
|
+
}
|
|
1192
|
+
interface MigrationChange {
|
|
1193
|
+
type: 'renamed' | 'converted' | 'removed' | 'added' | 'transformed';
|
|
1194
|
+
path: string;
|
|
1195
|
+
oldValue?: unknown;
|
|
1196
|
+
newValue?: unknown;
|
|
1197
|
+
description: string;
|
|
1198
|
+
}
|
|
1199
|
+
interface MigrationOptions {
|
|
1200
|
+
preserveUnknown?: boolean;
|
|
1201
|
+
strict?: boolean;
|
|
1202
|
+
defaultOrg?: string;
|
|
1203
|
+
defaultCodexRepo?: string;
|
|
1204
|
+
}
|
|
1205
|
+
interface VersionDetectionResult {
|
|
1206
|
+
version: '2.x' | '3.0' | 'unknown';
|
|
1207
|
+
confidence: 'high' | 'medium' | 'low';
|
|
1208
|
+
reason: string;
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
declare function detectVersion(config: unknown): VersionDetectionResult;
|
|
1212
|
+
declare function isModernConfig(config: unknown): config is ModernCodexConfig;
|
|
1213
|
+
declare function isLegacyConfig(config: unknown): config is LegacyCodexConfig;
|
|
1214
|
+
declare function needsMigration(config: unknown): boolean;
|
|
1215
|
+
declare function getMigrationRequirements(config: unknown): string[];
|
|
1216
|
+
|
|
1217
|
+
declare const DEFAULT_MIGRATION_OPTIONS: MigrationOptions;
|
|
1218
|
+
declare function migrateConfig(config: unknown, options?: MigrationOptions): MigrationResult;
|
|
1219
|
+
declare function validateMigratedConfig(config: ModernCodexConfig): string[];
|
|
1220
|
+
declare function generateMigrationReport(result: MigrationResult): string;
|
|
1221
|
+
declare function createEmptyModernConfig(org: string, codexRepo: string): ModernCodexConfig;
|
|
1222
|
+
|
|
1223
|
+
declare const LEGACY_PATTERNS: {
|
|
1224
|
+
CODEX_TAG: RegExp;
|
|
1225
|
+
CODEX_BRACKET: RegExp;
|
|
1226
|
+
CODEX_MUSTACHE: RegExp;
|
|
1227
|
+
SIMPLE_PATH: RegExp;
|
|
1228
|
+
};
|
|
1229
|
+
interface ReferenceConversionResult {
|
|
1230
|
+
original: string;
|
|
1231
|
+
converted: string;
|
|
1232
|
+
references: ConvertedReference[];
|
|
1233
|
+
modified: boolean;
|
|
1234
|
+
}
|
|
1235
|
+
interface ConvertedReference {
|
|
1236
|
+
original: string;
|
|
1237
|
+
uri: string;
|
|
1238
|
+
position: number;
|
|
1239
|
+
format: 'codex-tag' | 'codex-bracket' | 'codex-mustache' | 'simple-path';
|
|
1240
|
+
}
|
|
1241
|
+
interface ConversionOptions {
|
|
1242
|
+
defaultOrg?: string;
|
|
1243
|
+
defaultProject?: string;
|
|
1244
|
+
preserveWrapper?: boolean;
|
|
1245
|
+
}
|
|
1246
|
+
declare function convertLegacyReferences(text: string, options?: ConversionOptions): ReferenceConversionResult;
|
|
1247
|
+
declare function convertToUri(reference: string, options?: ConversionOptions): string;
|
|
1248
|
+
declare function findLegacyReferences(text: string): ConvertedReference[];
|
|
1249
|
+
declare function hasLegacyReferences(text: string): boolean;
|
|
1250
|
+
declare function migrateFileReferences(content: string, options?: ConversionOptions): ReferenceConversionResult;
|
|
1251
|
+
declare function generateReferenceMigrationSummary(results: ReferenceConversionResult[]): string;
|
|
1252
|
+
|
|
1253
|
+
export { type ArtifactType, type AutoSyncPattern, AutoSyncPatternSchema, BUILT_IN_TYPES, CODEX_TOOLS, CODEX_URI_PREFIX, type CacheEntry, type CacheEntryMetadata, type CacheEntryStatus, type CacheLookupResult, CacheManager, type CacheManagerConfig, CachePersistence, type CachePersistenceOptions, type CacheStats, type CodexConfig, CodexConfigSchema, CodexError, CommonRules, ConfigurationError, type ConversionOptions, type ConvertedReference, type CustomSyncDestination, type CustomTypeConfig, CustomTypeSchema, DEFAULT_CACHE_DIR, DEFAULT_FETCH_OPTIONS, DEFAULT_MIGRATION_OPTIONS, DEFAULT_PERMISSION_CONFIG, DEFAULT_SYNC_CONFIG, DEFAULT_TYPE, type EvaluationResult, type EvaluationSummary, type FetchOptions, type FetchResult, type FetchToolArgs, type FileInfo, type FileSyncStatus, GitHubStorage, type GitHubStorageOptions, HttpStorage, type HttpStorageOptions, type InvalidateToolArgs, LEGACY_PATTERNS, LEGACY_REF_PREFIX, type LegacyAutoSyncPattern, type LegacyCodexConfig, type ListToolArgs, type LoadConfigOptions, LocalStorage, type LocalStorageOptions, type McpCapabilities, type McpResource, type McpResourceTemplate, McpServer, type McpServerConfig, type McpServerInfo, type McpTool, type Metadata, MetadataSchema, type MigrationChange, type MigrationOptions, type MigrationResult, type ModernCodexConfig, type ModernSyncPattern, PERMISSION_LEVEL_ORDER, type ParseMetadataOptions, type ParseOptions, type ParseResult, type ParsedReference, type PermissionAction, type PermissionConfig, type PermissionContext, PermissionDeniedError, type PermissionLevel, PermissionManager, type PermissionManagerConfig, type PermissionResult, type PermissionRule, type PermissionScope, type PlanStats, type ReferenceConversionResult, type ResolveOptions, type ResolveOrgOptions, type ResolvedReference, type ResourceContent, type SearchResult, type SearchToolArgs, type SerializedCacheEntry, type ShouldSyncOptions, StorageManager, type StorageManagerConfig, type StorageProvider, type StorageProviderConfig, type StorageProviderType, type SyncConfig, type SyncDirection, SyncManager, type SyncManagerConfig, type SyncManifest, type SyncManifestEntry, type SyncOperation, type SyncOptions, type SyncPlan, type SyncResult, type SyncRule, type SyncRules, SyncRulesSchema, TTL, type ToolHandlerContext, type ToolResult, TypeRegistry, type TypeRegistryOptions, type TypesConfig, TypesConfigSchema, ValidationError, type VersionDetectionResult, buildUri, calculateCachePath, calculateContentHash, convertLegacyReference, convertLegacyReferences, convertToUri, createCacheEntry, createCacheManager, createCachePersistence, createDefaultRegistry, createEmptyModernConfig, createEmptySyncPlan, createGitHubStorage, createHttpStorage, createLocalStorage, createMcpServer, createPermissionManager, createRule, createRulesFromPatterns, createStorageManager, createSyncManager, createSyncPlan, deserializeCacheEntry, detectContentType, detectCurrentProject, detectVersion, estimateSyncTime, evaluatePath, evaluatePaths, evaluatePatterns, evaluatePermission, evaluatePermissions, extendType, extractOrgFromRepoName, extractRawFrontmatter, filterByPatterns, filterByPermission, filterPlanOperations, filterSyncablePaths, findLegacyReferences, formatPlanSummary, generateMigrationReport, generateReferenceMigrationSummary, getBuiltInType, getBuiltInTypeNames, getCacheEntryAge, getCacheEntryStatus, getCurrentContext, getCustomSyncDestinations, getDefaultCacheManager, getDefaultConfig, getDefaultDirectories, getDefaultPermissionManager, getDefaultRules, getDefaultStorageManager, getDirectory, getExtension, getFilename, getMigrationRequirements, getPlanStats, getRelativeCachePath, getRemainingTtl, getTargetRepos, handleFetch, handleInvalidate, handleList, handleSearch, handleToolCall, hasContentChanged, hasFrontmatter, hasLegacyReferences, hasPermission as hasPermissionLevel, isBuiltInType, isCacheEntryFresh, isCacheEntryValid, isCurrentProjectUri, isLegacyConfig, isLegacyReference, isModernConfig, isAllowed as isPermissionAllowed, isValidUri, levelGrants, loadConfig, loadCustomTypes, matchAnyPattern, matchPattern, maxLevel, mergeFetchOptions, mergeRules, mergeTypes, migrateConfig, migrateFileReferences, minLevel, needsMigration, parseCustomDestination, parseMetadata, parseReference, parseTtl, resolveOrganization, resolveReference, resolveReferences, ruleMatchesAction, ruleMatchesContext, ruleMatchesPath, sanitizePath, serializeCacheEntry, setDefaultCacheManager, setDefaultPermissionManager, setDefaultStorageManager, shouldSyncToRepo, summarizeEvaluations, touchCacheEntry, validateCustomTypes, validateMetadata, validateMigratedConfig, validateOrg, validatePath, validateRules as validatePermissionRules, validateProject, validateRules$1 as validateRules, validateUri };
|