@bendyline/gezel 1.0.6 → 1.0.7

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/paths.js CHANGED
@@ -42,6 +42,286 @@ function assertSafeEntityId(value, label = "entity id") {
42
42
  }
43
43
  }
44
44
 
45
+ // src/schemas/knowledge.ts
46
+ import { z } from "zod";
47
+ var KNOWLEDGE_ID_PATTERN = /^[a-z0-9]([a-z0-9-]{0,62}[a-z0-9])?$/;
48
+ var KnowledgeIdSchema = z.string().regex(KNOWLEDGE_ID_PATTERN);
49
+ var KNOWLEDGE_VERSION_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9._+-]{0,126}[A-Za-z0-9])?$/;
50
+ var KnowledgeVersionSchema = z.string().min(1).max(128).regex(KNOWLEDGE_VERSION_PATTERN, "catalog version must be one portable path segment").refine(
51
+ (value) => !/^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(value),
52
+ "catalog version must not use a reserved Windows device name"
53
+ );
54
+ var KnowledgeDocumentIdSchema = z.string().min(1).max(256).refine((s) => s === s.normalize("NFC"), "document id must be NFC-normalized").refine((s) => !/[\u0000-\u001f\u007f-\u009f]/u.test(s), "document id must not contain controls").refine((s) => s === s.trim(), "document id must not have leading/trailing whitespace");
55
+ var KnowledgeChunkUidSchema = z.string().regex(/^[0-9a-f]{32}$/);
56
+ var Sha256HexSchema = z.string().regex(/^[0-9a-f]{64}$/);
57
+ var KnowledgeVectorEncodingSchema = z.enum(["bit384+int8"]);
58
+ var KnowledgeEmbeddingProfileSchema = z.object({
59
+ /** e.g. `gezel-multilingual-e5-small@1`. New encoding/model = new id. */
60
+ id: z.string().min(1),
61
+ model: z.object({
62
+ repo: z.string().min(1),
63
+ revision: z.string().min(1),
64
+ onnxDigest: z.string().optional()
65
+ }),
66
+ tokenizer: z.object({
67
+ kind: z.string().min(1),
68
+ digest: z.string().optional()
69
+ }),
70
+ pooling: z.literal("mean"),
71
+ normalized: z.literal(true),
72
+ dimensions: z.number().int().positive(),
73
+ maxTokens: z.number().int().positive(),
74
+ queryInstruction: z.string(),
75
+ passageInstruction: z.string(),
76
+ vectorEncoding: KnowledgeVectorEncodingSchema,
77
+ distance: z.object({
78
+ stage1: z.literal("hamming"),
79
+ stage2: z.literal("cosine")
80
+ }),
81
+ quantization: z.object({
82
+ int8: z.object({
83
+ method: z.literal("symmetric-linear"),
84
+ scale: z.literal(127)
85
+ }),
86
+ binary: z.object({
87
+ method: z.literal("sign"),
88
+ threshold: z.literal(0),
89
+ packing: z.literal("lsb-first")
90
+ })
91
+ })
92
+ });
93
+ var KnowledgeChunkingProfileSchema = z.object({
94
+ /** `gezel-markdown-chunks@2` for knowledge; `@1` names the project chunker. */
95
+ id: z.string().min(1),
96
+ unit: z.literal("tokens"),
97
+ tokenizer: z.literal("profile"),
98
+ targetTokens: z.number().int().positive(),
99
+ overlapTokens: z.number().int().nonnegative(),
100
+ contextHeader: z.object({ maxTokens: z.number().int().nonnegative() })
101
+ });
102
+ var KnowledgeManifestFileSchema = z.object({
103
+ path: z.string().min(1),
104
+ sizeBytes: z.number().int().nonnegative(),
105
+ sha256: Sha256HexSchema
106
+ });
107
+ var KnowledgeCatalogManifestSchema = z.object({
108
+ kind: z.literal("gezel-knowledge-catalog"),
109
+ formatVersion: z.literal(1),
110
+ indexSchemaVersion: z.literal(1),
111
+ id: KnowledgeIdSchema,
112
+ version: KnowledgeVersionSchema,
113
+ name: z.string().min(1),
114
+ description: z.string().optional(),
115
+ language: z.string().min(2),
116
+ publisher: z.object({
117
+ id: KnowledgeIdSchema,
118
+ name: z.string().min(1),
119
+ url: z.string().optional()
120
+ }),
121
+ createdAt: z.string(),
122
+ sourceSnapshot: z.object({
123
+ name: z.string(),
124
+ date: z.string(),
125
+ taxonomyVersion: z.string().optional()
126
+ }).optional(),
127
+ license: z.object({
128
+ name: z.string().min(1),
129
+ noticePath: z.string().optional(),
130
+ attributionRequired: z.boolean()
131
+ }),
132
+ embedding: KnowledgeEmbeddingProfileSchema,
133
+ chunking: KnowledgeChunkingProfileSchema,
134
+ topics: z.array(z.object({ id: KnowledgeIdSchema, name: z.string().min(1) })).min(1, "a catalog must ship a table of contents (at least one topic)"),
135
+ router: z.object({
136
+ shardTargetChunks: z.number().int().positive(),
137
+ shards: z.array(
138
+ z.object({
139
+ id: z.number().int().nonnegative(),
140
+ path: z.string().min(1),
141
+ chunks: z.number().int().nonnegative(),
142
+ documents: z.number().int().nonnegative(),
143
+ centroids: z.number().int().nonnegative(),
144
+ sha256: Sha256HexSchema
145
+ })
146
+ ),
147
+ totalCentroids: z.number().int().nonnegative()
148
+ }),
149
+ counts: z.object({
150
+ documents: z.number().int().nonnegative(),
151
+ chunks: z.number().int().nonnegative(),
152
+ shards: z.number().int().positive()
153
+ }),
154
+ files: z.array(KnowledgeManifestFileSchema).min(1),
155
+ compatibility: z.object({
156
+ minimumGezelVersion: z.string().optional(),
157
+ maximumIndexSchemaVersion: z.number().int().positive()
158
+ }),
159
+ smokeQueries: z.array(
160
+ z.object({
161
+ query: z.string().min(1),
162
+ expectedDocumentIds: z.array(KnowledgeDocumentIdSchema).min(1)
163
+ })
164
+ ).optional(),
165
+ toolchain: z.object({
166
+ compiler: z.string(),
167
+ node: z.string(),
168
+ sqlite: z.string().optional(),
169
+ sqliteVec: z.string().optional(),
170
+ onnxruntime: z.string().optional(),
171
+ platform: z.string(),
172
+ modelDigest: z.string().optional(),
173
+ tokenizerDigest: z.string().optional()
174
+ }).optional(),
175
+ signature: z.object({
176
+ algorithm: z.literal("ed25519"),
177
+ keyId: z.string().min(1),
178
+ canonicalization: z.literal("rfc8785"),
179
+ value: z.string().min(1)
180
+ }).optional()
181
+ });
182
+ var CatalogDocumentSchema = z.object({
183
+ id: KnowledgeDocumentIdSchema,
184
+ title: z.string().min(1),
185
+ slug: z.string().min(1),
186
+ summary: z.string().optional(),
187
+ language: z.string().min(2),
188
+ /** Root→leaf topic id path; the first segment must exist in the manifest. */
189
+ topicPath: z.array(KnowledgeIdSchema).min(1),
190
+ markdown: z.string(),
191
+ sourceUrl: z.string().optional(),
192
+ sourceRevision: z.string().optional(),
193
+ sourceUpdatedAt: z.string().optional(),
194
+ attribution: z.record(z.string(), z.string()).optional(),
195
+ aliases: z.array(z.string()).optional()
196
+ });
197
+ var KnowledgeStorageScopeSchema = z.enum(["machine-shared", "user"]);
198
+ var KnowledgeCatalogRefSchema = z.object({
199
+ publisherId: KnowledgeIdSchema,
200
+ catalogId: KnowledgeIdSchema,
201
+ version: KnowledgeVersionSchema,
202
+ contentDigest: Sha256HexSchema,
203
+ storageScope: KnowledgeStorageScopeSchema
204
+ });
205
+ var KnowledgeUserRegistrySchema = z.object({
206
+ version: z.literal(1),
207
+ catalogs: z.array(
208
+ z.object({
209
+ ref: KnowledgeCatalogRefSchema,
210
+ enabled: z.boolean(),
211
+ addedAt: z.string(),
212
+ autoUpdate: z.boolean().optional(),
213
+ /** Set when the manager quarantined this catalog (with the reason). */
214
+ disabledReason: z.string().optional()
215
+ })
216
+ )
217
+ });
218
+ var KnowledgeMachineInventorySchema = z.object({
219
+ version: z.literal(1),
220
+ catalogs: z.array(
221
+ z.object({
222
+ publisherId: KnowledgeIdSchema,
223
+ catalogId: KnowledgeIdSchema,
224
+ version: KnowledgeVersionSchema,
225
+ contentDigest: Sha256HexSchema,
226
+ publishedAt: z.string(),
227
+ bytes: z.number().int().nonnegative()
228
+ })
229
+ )
230
+ });
231
+ var TrustedKnowledgeCoordinateSchema = z.object({
232
+ publisherId: KnowledgeIdSchema,
233
+ catalogId: KnowledgeIdSchema,
234
+ version: KnowledgeVersionSchema,
235
+ expectedDigest: Sha256HexSchema
236
+ });
237
+ var ProjectKnowledgeCatalogsSchema = z.object({
238
+ mode: z.enum(["inherit", "selected", "off"]),
239
+ /**
240
+ * Only for mode 'selected'. Unresolvable refs are RETAINED (not stripped)
241
+ * so a restored project regains its selection when the catalog returns.
242
+ */
243
+ refs: z.array(z.object({ publisherId: KnowledgeIdSchema, catalogId: KnowledgeIdSchema })).optional()
244
+ });
245
+ var KnowledgeRegistryEntrySchema = z.object({
246
+ catalogId: KnowledgeIdSchema,
247
+ version: z.string().min(1),
248
+ name: z.string().min(1),
249
+ description: z.string().optional(),
250
+ language: z.string().min(2),
251
+ documents: z.number().int().nonnegative(),
252
+ /** Size of the `.gezk` archive itself (download accounting/preflight). */
253
+ archiveBytes: z.number().int().nonnegative(),
254
+ /** sha256 of the `.gezk` archive — the ref's contentDigest after install. */
255
+ contentDigest: z.string().regex(/^[0-9a-f]{64}$/),
256
+ /** Absolute download URL. Uploaded before the registry that names it. */
257
+ url: z.string().url(),
258
+ license: z.object({ name: z.string().min(1), attributionRequired: z.boolean() }),
259
+ sourceSnapshot: z.object({ name: z.string(), date: z.string(), taxonomyVersion: z.string().optional() }).optional()
260
+ });
261
+ var KnowledgeRegistryIndexSchema = z.object({
262
+ kind: z.literal("gezel-knowledge-registry"),
263
+ formatVersion: z.literal(1),
264
+ publisher: z.object({
265
+ id: KnowledgeIdSchema,
266
+ name: z.string().min(1),
267
+ url: z.string().optional()
268
+ }),
269
+ generatedAt: z.string(),
270
+ catalogs: z.array(KnowledgeRegistryEntrySchema),
271
+ signature: z.object({
272
+ algorithm: z.literal("ed25519"),
273
+ keyId: z.string().min(1),
274
+ canonicalization: z.literal("rfc8785"),
275
+ value: z.string().min(1)
276
+ }).optional()
277
+ });
278
+ var KnowledgeUpdateCandidateSchema = z.object({
279
+ publisherId: KnowledgeIdSchema,
280
+ catalogId: KnowledgeIdSchema,
281
+ name: z.string(),
282
+ installedVersion: z.string(),
283
+ availableVersion: z.string(),
284
+ archiveBytes: z.number().int().nonnegative(),
285
+ contentDigest: z.string().regex(/^[0-9a-f]{64}$/),
286
+ url: z.string().url()
287
+ });
288
+ var KnowledgeUpdatesResponseSchema = z.discriminatedUnion("available", [
289
+ z.object({
290
+ available: z.literal(false),
291
+ reason: z.enum(["no-registry-url", "network-blocked", "no-trust-anchors", "fetch-failed"]),
292
+ detail: z.string().optional()
293
+ }),
294
+ z.object({
295
+ available: z.literal(true),
296
+ registryUrl: z.string(),
297
+ publisher: z.object({ id: KnowledgeIdSchema, name: z.string() }),
298
+ checkedAt: z.string(),
299
+ updates: z.array(KnowledgeUpdateCandidateSchema)
300
+ })
301
+ ]);
302
+ var KnowledgeInstallRequestSchema = z.object({
303
+ source: z.discriminatedUnion("kind", [
304
+ z.object({ kind: z.literal("file"), path: z.string().min(1) }),
305
+ z.object({
306
+ kind: z.literal("url"),
307
+ url: z.string().url(),
308
+ /** Optional out-of-band identity for remote imports. When present, the
309
+ * daemon rejects bytes that do not match before extracting the archive. */
310
+ expectedSha256: z.string().regex(/^[0-9a-fA-F]{64}$/).optional()
311
+ })
312
+ ])
313
+ });
314
+ var UpdateKnowledgeCatalogRequestSchema = z.object({
315
+ enabled: z.boolean().optional(),
316
+ autoUpdate: z.boolean().optional()
317
+ });
318
+ var KnowledgeSearchRequestSchema = z.object({
319
+ query: z.string().min(1),
320
+ maxResults: z.number().int().min(1).max(50).optional(),
321
+ /** Restrict to these catalog ids (default: every enabled catalog). */
322
+ catalogs: z.array(KnowledgeIdSchema).optional()
323
+ });
324
+
45
325
  // src/paths.ts
46
326
  var MACHINE_SHARED_MARKER = ".gezel-machine-shared-v1.json";
47
327
  function machineSharedHome(platform = process.platform, env = process.env) {
@@ -93,6 +373,9 @@ function userProjectDir(root, projectId) {
93
373
  function projectPrivateDir(root, projectId) {
94
374
  return userProjectDir(root, projectId);
95
375
  }
376
+ function projectTypeOverlayFile(root, projectId) {
377
+ return join(projectPrivateDir(root, projectId), "project-type-overlay.json");
378
+ }
96
379
  function machineSharedGezelDir(gezelId) {
97
380
  assertSafeEntityId(gezelId, "gezel id");
98
381
  const shared = activeMachineSharedHome();
@@ -222,6 +505,9 @@ function projectBoekwachterIssuesFile(root, projectId) {
222
505
  function projectCodeReviewsFile(root, projectId) {
223
506
  return join(projectPrivateDir(root, projectId), "code-reviews.json");
224
507
  }
508
+ function projectDiffpacksFile(root, projectId) {
509
+ return join(projectPrivateDir(root, projectId), "diffpacks.json");
510
+ }
225
511
  function projectReportActionsFile(root, projectId) {
226
512
  return join(projectPrivateDir(root, projectId), "report-actions.json");
227
513
  }
@@ -235,6 +521,22 @@ var PROJECT_SHADOW_DIR_NAME = "shadow";
235
521
  function projectShadowDir(root, projectId, external) {
236
522
  return join(projectArtifactsDir(root, projectId, external), PROJECT_SHADOW_DIR_NAME);
237
523
  }
524
+ var PROJECT_TABULAR_DIR_NAME = "tabular";
525
+ var TABULAR_COMPANION_SUFFIX = "_tables";
526
+ function projectTabularDir(root, projectId, external) {
527
+ return join(projectArtifactsDir(root, projectId, external), PROJECT_TABULAR_DIR_NAME);
528
+ }
529
+ var CONNECTOR_TABLES_DIR_NAME = "tables";
530
+ var CONNECTOR_ROLLUPS_DIR_NAME = "rollups";
531
+ var OBSERVATION_TABLE_MANIFEST_FILE = "manifest.json";
532
+ var OBSERVATION_TABLE_STATE_FILE = "state.json";
533
+ var PROJECT_DIFFPACKS_DIR_NAME = "diffpacks";
534
+ function projectDiffpacksDir(root, projectId, external) {
535
+ return join(projectArtifactsDir(root, projectId, external), PROJECT_DIFFPACKS_DIR_NAME);
536
+ }
537
+ function projectDiffpackDir(root, projectId, packId, external) {
538
+ return join(projectDiffpacksDir(root, projectId, external), packId);
539
+ }
238
540
  function projectMemoriesDir(root, projectId, external) {
239
541
  return join(projectDir(root, projectId, external), "memories");
240
542
  }
@@ -262,6 +564,9 @@ function projectTerminalFile(root, projectId, threadId) {
262
564
  function globalHistoryFile(root) {
263
565
  return join(root, "history.jsonl");
264
566
  }
567
+ function pendingHandoffsFile(root) {
568
+ return join(root, "pending-handoffs.json");
569
+ }
265
570
  function globalIndexDir(root) {
266
571
  return join(root, "index");
267
572
  }
@@ -271,6 +576,33 @@ function globalIndexDbFile(root) {
271
576
  function projectHistoryFile(root, projectId) {
272
577
  return join(projectPrivateDir(root, projectId), "history.jsonl");
273
578
  }
579
+ function knowledgeDir(root) {
580
+ return join(root, "knowledge");
581
+ }
582
+ function knowledgeRegistryFile(root) {
583
+ return join(knowledgeDir(root), "registry.json");
584
+ }
585
+ function knowledgeCatalogsDir(root) {
586
+ return join(knowledgeDir(root), "catalogs");
587
+ }
588
+ function knowledgeCatalogVersionDir(root, publisherId, catalogId, version, contentDigest) {
589
+ const publisher = KnowledgeIdSchema.parse(publisherId);
590
+ const catalog = KnowledgeIdSchema.parse(catalogId);
591
+ const catalogVersion = KnowledgeVersionSchema.parse(version);
592
+ if (!/^[0-9a-f]{64}$/i.test(contentDigest)) {
593
+ throw new Error("knowledge catalog content digest must be a sha256");
594
+ }
595
+ return join(
596
+ knowledgeCatalogsDir(root),
597
+ publisher,
598
+ catalog,
599
+ catalogVersion,
600
+ contentDigest.slice(0, 16)
601
+ );
602
+ }
603
+ function knowledgeDownloadsDir(root) {
604
+ return join(knowledgeDir(root), "downloads");
605
+ }
274
606
  function projectQuestionsFile(root, projectId) {
275
607
  return join(projectPrivateDir(root, projectId), "questions.json");
276
608
  }
@@ -358,6 +690,21 @@ function craftbookTemplateScriptFile(root, prefix, id, version, name) {
358
690
  function craftbookShardPrefix(id) {
359
691
  return id.slice(0, 2).toLowerCase();
360
692
  }
693
+ function aiAppsRoot(root) {
694
+ return join(root, "ai-apps");
695
+ }
696
+ function aiAppsRegistryFile(root) {
697
+ return join(aiAppsRoot(root), "registry.json");
698
+ }
699
+ function aiAppVersionDir(root, appId, version) {
700
+ return join(aiAppsRoot(root), appId, version);
701
+ }
702
+ function aiAppItemsDir(root, appId, version) {
703
+ return join(aiAppVersionDir(root, appId, version), "items");
704
+ }
705
+ function aiAppReceiptFile(root, appId, version) {
706
+ return join(aiAppVersionDir(root, appId, version), "receipt.json");
707
+ }
361
708
  function projectTypesRoot(root) {
362
709
  return join(root, "project-types");
363
710
  }
@@ -525,9 +872,21 @@ async function readConfigRaw(root) {
525
872
  }
526
873
  }
527
874
  export {
875
+ CONNECTOR_ROLLUPS_DIR_NAME,
876
+ CONNECTOR_TABLES_DIR_NAME,
528
877
  MACHINE_SHARED_MARKER,
878
+ OBSERVATION_TABLE_MANIFEST_FILE,
879
+ OBSERVATION_TABLE_STATE_FILE,
880
+ PROJECT_DIFFPACKS_DIR_NAME,
529
881
  PROJECT_SHADOW_DIR_NAME,
882
+ PROJECT_TABULAR_DIR_NAME,
883
+ TABULAR_COMPANION_SUFFIX,
530
884
  activeMachineSharedHome,
885
+ aiAppItemsDir,
886
+ aiAppReceiptFile,
887
+ aiAppVersionDir,
888
+ aiAppsRegistryFile,
889
+ aiAppsRoot,
531
890
  ambientDashboardLatestFile,
532
891
  ambientDashboardStateFile,
533
892
  ambientDir,
@@ -573,6 +932,11 @@ export {
573
932
  keurmeesterDigestStatePath,
574
933
  keurmeesterDigestsDir,
575
934
  keurmeesterDir,
935
+ knowledgeCatalogVersionDir,
936
+ knowledgeCatalogsDir,
937
+ knowledgeDir,
938
+ knowledgeDownloadsDir,
939
+ knowledgeRegistryFile,
576
940
  machineSharedGezelDir,
577
941
  machineSharedHome,
578
942
  machineSharedMarkerFile,
@@ -581,6 +945,7 @@ export {
581
945
  meesterStatusFile,
582
946
  meesterStatusStateFile,
583
947
  pendingGrantsFile,
948
+ pendingHandoffsFile,
584
949
  playwrightBrowsersDir,
585
950
  projectActivityFile,
586
951
  projectArtifactsDir,
@@ -589,6 +954,9 @@ export {
589
954
  projectCodeReviewsFile,
590
955
  projectContentIndexDbFile,
591
956
  projectCreateTransactionsRoot,
957
+ projectDiffpackDir,
958
+ projectDiffpacksDir,
959
+ projectDiffpacksFile,
592
960
  projectDir,
593
961
  projectDocsDir,
594
962
  projectFindingLifecycleFile,
@@ -622,6 +990,7 @@ export {
622
990
  projectShadowDir,
623
991
  projectStorageDir,
624
992
  projectStorageScope,
993
+ projectTabularDir,
625
994
  projectTaskAboutFile,
626
995
  projectTaskDir,
627
996
  projectTaskFile,
@@ -634,6 +1003,7 @@ export {
634
1003
  projectToolsetsInstallDir,
635
1004
  projectTypeDir,
636
1005
  projectTypeManifestFile,
1006
+ projectTypeOverlayFile,
637
1007
  projectTypeShardPrefix,
638
1008
  projectTypeVersionDir,
639
1009
  projectTypeVersionManifestFile,