@bendyline/gezel 1.0.7 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/paths.js CHANGED
@@ -43,158 +43,53 @@ function assertSafeEntityId(value, label = "entity id") {
43
43
  }
44
44
 
45
45
  // src/schemas/knowledge.ts
46
+ import {
47
+ KnowledgeIdSchema,
48
+ KnowledgeVersionSchema,
49
+ Sha256HexSchema
50
+ } from "@bendyline/gezk";
46
51
  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
- });
52
+ import {
53
+ ArtifactDigestSchema,
54
+ CatalogDocumentSchema,
55
+ DEFAULT_EMBEDDING_ONNX_FILE,
56
+ DEFAULT_EMBEDDING_TOKENIZER_FILE,
57
+ GEZK_APPLICATION_ID,
58
+ GEZK_FORMAT_VERSION,
59
+ GEZK_INDEX_SCHEMA_VERSION,
60
+ GEZK_MANIFEST_KIND,
61
+ GEZK_MIME_TYPE,
62
+ GEZK_REGISTRY_KIND,
63
+ KNOWLEDGE_ID_PATTERN,
64
+ KNOWLEDGE_VERSION_PATTERN,
65
+ KnowledgeCatalogManifestSchema,
66
+ KnowledgeChunkUidSchema,
67
+ KnowledgeChunkingProfileSchema,
68
+ KnowledgeDocumentIdSchema,
69
+ KnowledgeEmbeddingProfileSchema,
70
+ KnowledgeIdSchema as KnowledgeIdSchema2,
71
+ KnowledgeManifestFileSchema,
72
+ KnowledgeRegistryEntrySchema as KnowledgeRegistryEntrySchema2,
73
+ KnowledgeRegistryIndexSchema,
74
+ KnowledgeSignatureSchema,
75
+ KnowledgeVectorEncodingSchema,
76
+ KnowledgeVersionSchema as KnowledgeVersionSchema2,
77
+ LICENSE_NOTICE_PATH,
78
+ MANIFEST_PATH,
79
+ MIMETYPE_PATH,
80
+ README_PATH,
81
+ ROUTER_DB_PATH,
82
+ RepoRelativePathSchema,
83
+ SOURCE_NOTICES_PATH,
84
+ Sha256HexSchema as Sha256HexSchema2,
85
+ SourceNoticesSchema,
86
+ embeddingProfileArtifacts,
87
+ formatKnowledgeUri,
88
+ parseKnowledgeUri,
89
+ sameVectorSpace
90
+ } from "@bendyline/gezk";
197
91
  var KnowledgeStorageScopeSchema = z.enum(["machine-shared", "user"]);
92
+ var KnowledgeInstallSourceKindSchema = z.enum(["gilde", "file", "url"]);
198
93
  var KnowledgeCatalogRefSchema = z.object({
199
94
  publisherId: KnowledgeIdSchema,
200
95
  catalogId: KnowledgeIdSchema,
@@ -210,6 +105,8 @@ var KnowledgeUserRegistrySchema = z.object({
210
105
  enabled: z.boolean(),
211
106
  addedAt: z.string(),
212
107
  autoUpdate: z.boolean().optional(),
108
+ /** Where the install came from; entries written before it was recorded carry none. */
109
+ source: KnowledgeInstallSourceKindSchema.optional(),
213
110
  /** Set when the manager quarantined this catalog (with the reason). */
214
111
  disabledReason: z.string().optional()
215
112
  })
@@ -242,38 +139,11 @@ var ProjectKnowledgeCatalogsSchema = z.object({
242
139
  */
243
140
  refs: z.array(z.object({ publisherId: KnowledgeIdSchema, catalogId: KnowledgeIdSchema })).optional()
244
141
  });
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()
142
+ var KnowledgeHuggingfaceFileSchema = z.object({
143
+ repo: z.string(),
144
+ /** A 40-hex commit sha, so the pinned URL is immutable. */
145
+ revision: z.string(),
146
+ path: z.string()
277
147
  });
278
148
  var KnowledgeUpdateCandidateSchema = z.object({
279
149
  publisherId: KnowledgeIdSchema,
@@ -281,24 +151,140 @@ var KnowledgeUpdateCandidateSchema = z.object({
281
151
  name: z.string(),
282
152
  installedVersion: z.string(),
283
153
  availableVersion: z.string(),
154
+ releasedAt: z.string(),
155
+ archiveBytes: z.number().int().nonnegative(),
156
+ contentDigest: Sha256HexSchema,
157
+ huggingface: KnowledgeHuggingfaceFileSchema
158
+ });
159
+ var KnowledgeUpdatesResponseSchema = z.object({
160
+ source: z.literal("gilde"),
161
+ checkedAt: z.string(),
162
+ updates: z.array(KnowledgeUpdateCandidateSchema)
163
+ });
164
+ var KnowledgeSemanticSearchModeSchema = z.enum(["shared", "profile", "keyword-only"]);
165
+ var KnowledgeCatalogStatusSchema = z.object({
166
+ ref: KnowledgeCatalogRefSchema,
167
+ enabled: z.boolean(),
168
+ addedAt: z.string(),
169
+ disabledReason: z.string().optional(),
170
+ mounted: z.boolean(),
171
+ name: z.string().optional(),
172
+ description: z.string().optional(),
173
+ language: z.string().optional(),
174
+ license: z.string().optional(),
175
+ documents: z.number().int().nonnegative().optional(),
176
+ chunks: z.number().int().nonnegative().optional(),
177
+ sizeBytes: z.number().int().nonnegative().optional(),
178
+ /** False only for `keyword-only` catalogs (an unregistered embedding profile). */
179
+ vectorCompatible: z.boolean().optional(),
180
+ /**
181
+ * `shared` — queries reuse the daemon's own embedder; `profile` — the
182
+ * catalog's model is loaded to embed queries; `keyword-only` — no model
183
+ * gezel can run matches the profile, so only full-text search applies.
184
+ */
185
+ semanticSearch: KnowledgeSemanticSearchModeSchema.optional(),
186
+ source: KnowledgeInstallSourceKindSchema,
187
+ /** A strictly newer version exists in the shipped catalog content. */
188
+ updateAvailable: z.boolean(),
189
+ availableVersion: z.string().optional()
190
+ });
191
+ var KnowledgeAvailableCatalogSchema = z.object({
192
+ id: KnowledgeIdSchema,
193
+ publisherId: KnowledgeIdSchema,
194
+ name: z.string(),
195
+ description: z.string(),
196
+ tags: z.array(z.string()),
197
+ language: z.string(),
198
+ category: z.string().optional(),
199
+ license: z.string().optional(),
200
+ licenseUrl: z.string().optional(),
201
+ version: z.string(),
202
+ releasedAt: z.string(),
203
+ formatVersion: z.string(),
204
+ huggingface: KnowledgeHuggingfaceFileSchema,
205
+ upstream: z.string().optional(),
206
+ parquet: z.object({ repo: z.string(), revision: z.string(), dir: z.string() }).optional(),
207
+ sha256: Sha256HexSchema,
284
208
  archiveBytes: z.number().int().nonnegative(),
285
- contentDigest: z.string().regex(/^[0-9a-f]{64}$/),
286
- url: z.string().url()
209
+ uncompressedBytes: z.number().int().nonnegative(),
210
+ documents: z.number().int().nonnegative(),
211
+ chunks: z.number().int().nonnegative(),
212
+ embeddingProfile: z.object({ id: z.string(), modelRepo: z.string() }),
213
+ topics: z.array(z.object({ id: z.string(), name: z.string() })),
214
+ minGezelVersion: z.string().optional(),
215
+ /** Present when this user's registry holds a version of the catalog. */
216
+ installed: z.object({
217
+ version: z.string(),
218
+ contentDigest: Sha256HexSchema,
219
+ storageScope: KnowledgeStorageScopeSchema,
220
+ enabled: z.boolean(),
221
+ updateAvailable: z.boolean()
222
+ }).optional(),
223
+ /** The pinned bytes already sit in the machine-shared asset store. */
224
+ sharedOnDevice: z.boolean(),
225
+ installing: z.boolean(),
226
+ /** A resumable partial download of the pinned archive exists. */
227
+ incompleteDownload: z.boolean()
287
228
  });
288
- var KnowledgeUpdatesResponseSchema = z.discriminatedUnion("available", [
229
+ var KnowledgeInstallPhaseSchema = z.enum(["download", "extract", "embedder"]);
230
+ var KnowledgeInstallEventSchema = z.discriminatedUnion("type", [
231
+ z.object({
232
+ type: z.literal("progress"),
233
+ phase: KnowledgeInstallPhaseSchema,
234
+ bytesDone: z.number().nonnegative(),
235
+ bytesTotal: z.number().nonnegative()
236
+ }),
237
+ z.object({ type: z.literal("verifying") }),
289
238
  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()
239
+ type: z.literal("retrying"),
240
+ attempt: z.number().int(),
241
+ maxAttempts: z.number().int(),
242
+ delayMs: z.number().nonnegative(),
243
+ reason: z.string()
293
244
  }),
294
245
  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)
246
+ type: z.literal("done"),
247
+ ref: KnowledgeCatalogRefSchema,
248
+ rootDir: z.string(),
249
+ storageScope: KnowledgeStorageScopeSchema,
250
+ /** Installed and mounted, but an optional step (the query embedder) did not complete. */
251
+ warning: z.string().optional()
252
+ }),
253
+ z.object({
254
+ type: z.literal("error"),
255
+ error: z.string(),
256
+ /** Set when the downloaded bytes did not match the pinned digest. */
257
+ mismatch: z.object({ expected: Sha256HexSchema, actual: Sha256HexSchema }).optional()
300
258
  })
301
259
  ]);
260
+ var KnowledgeInstallJobSchema = z.object({
261
+ id: z.string(),
262
+ startedAt: z.string(),
263
+ finished: z.boolean(),
264
+ error: z.string().optional(),
265
+ /** The latest progress event and, once finished, the terminal event. */
266
+ events: z.array(KnowledgeInstallEventSchema)
267
+ });
268
+ var KnowledgeActiveInstallSchema = z.object({
269
+ jobId: z.string(),
270
+ /** Known up front for catalog installs; a file/URL install learns it at `done`. */
271
+ catalogId: KnowledgeIdSchema.optional(),
272
+ startedAt: z.string(),
273
+ phase: z.enum(["download", "verifying", "extract", "embedder", "retrying"]),
274
+ bytesDone: z.number().nonnegative(),
275
+ bytesTotal: z.number().nonnegative()
276
+ });
277
+ var IncompleteKnowledgeDownloadSchema = z.object({
278
+ /** The temp-file stem: the pinned sha256's first 16 hex chars, or a hash of the URL. */
279
+ key: z.string().regex(/^[0-9a-f]{16}$/),
280
+ bytes: z.number().int().nonnegative(),
281
+ updatedAt: z.string(),
282
+ /** True when the key still matches a catalog entry, so a re-install resumes it. */
283
+ resumable: z.boolean(),
284
+ catalogId: KnowledgeIdSchema.optional(),
285
+ name: z.string().optional(),
286
+ archiveBytes: z.number().int().nonnegative().optional()
287
+ });
302
288
  var KnowledgeInstallRequestSchema = z.object({
303
289
  source: z.discriminatedUnion("kind", [
304
290
  z.object({ kind: z.literal("file"), path: z.string().min(1) }),
@@ -308,6 +294,14 @@ var KnowledgeInstallRequestSchema = z.object({
308
294
  /** Optional out-of-band identity for remote imports. When present, the
309
295
  * daemon rejects bytes that do not match before extracting the archive. */
310
296
  expectedSha256: z.string().regex(/^[0-9a-fA-F]{64}$/).optional()
297
+ }),
298
+ z.object({
299
+ kind: z.literal("catalog"),
300
+ /** A gilde `knowledge-catalog` id; its pinned sha256 + commit are the trust root. */
301
+ id: KnowledgeIdSchema,
302
+ version: z.string().optional(),
303
+ /** `auto` (default) prefers the machine-shared store when a machine engine is adopted. */
304
+ placement: z.enum(["auto", "user"]).optional()
311
305
  })
312
306
  ])
313
307
  });
@@ -537,6 +531,13 @@ function projectDiffpacksDir(root, projectId, external) {
537
531
  function projectDiffpackDir(root, projectId, packId, external) {
538
532
  return join(projectDiffpacksDir(root, projectId, external), packId);
539
533
  }
534
+ var PROJECT_PROMPTS_DIR_NAME = "prompts";
535
+ function projectPromptsDir(root, projectId, external) {
536
+ return join(projectArtifactsDir(root, projectId, external), PROJECT_PROMPTS_DIR_NAME);
537
+ }
538
+ function projectPromptDraftDir(root, projectId, draftId, external) {
539
+ return join(projectPromptsDir(root, projectId, external), draftId);
540
+ }
540
541
  function projectMemoriesDir(root, projectId, external) {
541
542
  return join(projectDir(root, projectId, external), "memories");
542
543
  }
@@ -586,9 +587,9 @@ function knowledgeCatalogsDir(root) {
586
587
  return join(knowledgeDir(root), "catalogs");
587
588
  }
588
589
  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);
590
+ const publisher = KnowledgeIdSchema2.parse(publisherId);
591
+ const catalog = KnowledgeIdSchema2.parse(catalogId);
592
+ const catalogVersion = KnowledgeVersionSchema2.parse(version);
592
593
  if (!/^[0-9a-f]{64}$/i.test(contentDigest)) {
593
594
  throw new Error("knowledge catalog content digest must be a sha256");
594
595
  }
@@ -878,6 +879,7 @@ export {
878
879
  OBSERVATION_TABLE_MANIFEST_FILE,
879
880
  OBSERVATION_TABLE_STATE_FILE,
880
881
  PROJECT_DIFFPACKS_DIR_NAME,
882
+ PROJECT_PROMPTS_DIR_NAME,
881
883
  PROJECT_SHADOW_DIR_NAME,
882
884
  PROJECT_TABULAR_DIR_NAME,
883
885
  TABULAR_COMPANION_SUFFIX,
@@ -981,6 +983,8 @@ export {
981
983
  projectMemoryIndexDir,
982
984
  projectMetaFile,
983
985
  projectPrivateDir,
986
+ projectPromptDraftDir,
987
+ projectPromptsDir,
984
988
  projectQuestionsFile,
985
989
  projectReportActionsFile,
986
990
  projectScriptFile,