@vellumai/assistant 0.12.8 → 0.12.10

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.
@@ -29,6 +29,7 @@
29
29
  "./platform-credential": "./src/platform-credential.ts",
30
30
  "./plan-credit": "./src/plan-credit.ts",
31
31
  "./integration-categories": "./src/integration-categories.ts",
32
+ "./migration-import": "./src/migration-import.ts",
32
33
  "./mcp-oauth": "./src/mcp-oauth.ts"
33
34
  },
34
35
  "scripts": {
@@ -0,0 +1,36 @@
1
+ import { describe, expect, test } from "bun:test";
2
+
3
+ import { parseImportFailure } from "../migration-import.js";
4
+
5
+ describe("parseImportFailure", () => {
6
+ test("parses a validation report", () => {
7
+ const failure = parseImportFailure(
8
+ JSON.stringify({
9
+ success: false,
10
+ reason: "validation_failed",
11
+ errors: [
12
+ {
13
+ code: "entry_hash",
14
+ message: "Checksum mismatch",
15
+ path: "workspace/a.md",
16
+ },
17
+ ],
18
+ }),
19
+ );
20
+ expect(failure).toEqual({
21
+ reason: "validation_failed",
22
+ errors: [{ message: "Checksum mismatch", path: "workspace/a.md" }],
23
+ });
24
+ });
25
+
26
+ test("parses a plain message body", () => {
27
+ expect(parseImportFailure('{"message":"disk full"}')).toEqual({
28
+ message: "disk full",
29
+ });
30
+ });
31
+
32
+ test("returns null for text that is not an import failure", () => {
33
+ expect(parseImportFailure("not json")).toBeNull();
34
+ expect(parseImportFailure('{"job_id":"abc"}')).toBeNull();
35
+ });
36
+ });
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Failure body of a `.vbundle` import from the assistant's migration routes:
3
+ * a structured validation report (`reason` plus per-file `errors`) or a plain
4
+ * `message`. Clients that restore bundles parse it to tell the owner which
5
+ * file failed instead of printing raw JSON.
6
+ */
7
+
8
+ import { z } from "zod";
9
+
10
+ export const importFailureSchema = z.object({
11
+ reason: z.string().optional(),
12
+ message: z.string().optional(),
13
+ errors: z
14
+ .array(z.object({ message: z.string(), path: z.string().optional() }))
15
+ .optional(),
16
+ });
17
+
18
+ export type ImportFailure = z.infer<typeof importFailureSchema>;
19
+
20
+ /** Parse an import failure from JSON text, or null when the text is not one. */
21
+ export function parseImportFailure(text: string): ImportFailure | null {
22
+ try {
23
+ const parsed = importFailureSchema.safeParse(JSON.parse(text));
24
+ return parsed.success &&
25
+ (parsed.data.reason || parsed.data.message || parsed.data.errors)
26
+ ? parsed.data
27
+ : null;
28
+ } catch {
29
+ return null;
30
+ }
31
+ }
@@ -29,6 +29,7 @@
29
29
  "./platform-credential": "./src/platform-credential.ts",
30
30
  "./plan-credit": "./src/plan-credit.ts",
31
31
  "./integration-categories": "./src/integration-categories.ts",
32
+ "./migration-import": "./src/migration-import.ts",
32
33
  "./mcp-oauth": "./src/mcp-oauth.ts"
33
34
  },
34
35
  "scripts": {
@@ -0,0 +1,36 @@
1
+ import { describe, expect, test } from "bun:test";
2
+
3
+ import { parseImportFailure } from "../migration-import.js";
4
+
5
+ describe("parseImportFailure", () => {
6
+ test("parses a validation report", () => {
7
+ const failure = parseImportFailure(
8
+ JSON.stringify({
9
+ success: false,
10
+ reason: "validation_failed",
11
+ errors: [
12
+ {
13
+ code: "entry_hash",
14
+ message: "Checksum mismatch",
15
+ path: "workspace/a.md",
16
+ },
17
+ ],
18
+ }),
19
+ );
20
+ expect(failure).toEqual({
21
+ reason: "validation_failed",
22
+ errors: [{ message: "Checksum mismatch", path: "workspace/a.md" }],
23
+ });
24
+ });
25
+
26
+ test("parses a plain message body", () => {
27
+ expect(parseImportFailure('{"message":"disk full"}')).toEqual({
28
+ message: "disk full",
29
+ });
30
+ });
31
+
32
+ test("returns null for text that is not an import failure", () => {
33
+ expect(parseImportFailure("not json")).toBeNull();
34
+ expect(parseImportFailure('{"job_id":"abc"}')).toBeNull();
35
+ });
36
+ });
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Failure body of a `.vbundle` import from the assistant's migration routes:
3
+ * a structured validation report (`reason` plus per-file `errors`) or a plain
4
+ * `message`. Clients that restore bundles parse it to tell the owner which
5
+ * file failed instead of printing raw JSON.
6
+ */
7
+
8
+ import { z } from "zod";
9
+
10
+ export const importFailureSchema = z.object({
11
+ reason: z.string().optional(),
12
+ message: z.string().optional(),
13
+ errors: z
14
+ .array(z.object({ message: z.string(), path: z.string().optional() }))
15
+ .optional(),
16
+ });
17
+
18
+ export type ImportFailure = z.infer<typeof importFailureSchema>;
19
+
20
+ /** Parse an import failure from JSON text, or null when the text is not one. */
21
+ export function parseImportFailure(text: string): ImportFailure | null {
22
+ try {
23
+ const parsed = importFailureSchema.safeParse(JSON.parse(text));
24
+ return parsed.success &&
25
+ (parsed.data.reason || parsed.data.message || parsed.data.errors)
26
+ ? parsed.data
27
+ : null;
28
+ } catch {
29
+ return null;
30
+ }
31
+ }
@@ -29,6 +29,7 @@
29
29
  "./platform-credential": "./src/platform-credential.ts",
30
30
  "./plan-credit": "./src/plan-credit.ts",
31
31
  "./integration-categories": "./src/integration-categories.ts",
32
+ "./migration-import": "./src/migration-import.ts",
32
33
  "./mcp-oauth": "./src/mcp-oauth.ts"
33
34
  },
34
35
  "scripts": {
@@ -0,0 +1,36 @@
1
+ import { describe, expect, test } from "bun:test";
2
+
3
+ import { parseImportFailure } from "../migration-import.js";
4
+
5
+ describe("parseImportFailure", () => {
6
+ test("parses a validation report", () => {
7
+ const failure = parseImportFailure(
8
+ JSON.stringify({
9
+ success: false,
10
+ reason: "validation_failed",
11
+ errors: [
12
+ {
13
+ code: "entry_hash",
14
+ message: "Checksum mismatch",
15
+ path: "workspace/a.md",
16
+ },
17
+ ],
18
+ }),
19
+ );
20
+ expect(failure).toEqual({
21
+ reason: "validation_failed",
22
+ errors: [{ message: "Checksum mismatch", path: "workspace/a.md" }],
23
+ });
24
+ });
25
+
26
+ test("parses a plain message body", () => {
27
+ expect(parseImportFailure('{"message":"disk full"}')).toEqual({
28
+ message: "disk full",
29
+ });
30
+ });
31
+
32
+ test("returns null for text that is not an import failure", () => {
33
+ expect(parseImportFailure("not json")).toBeNull();
34
+ expect(parseImportFailure('{"job_id":"abc"}')).toBeNull();
35
+ });
36
+ });
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Failure body of a `.vbundle` import from the assistant's migration routes:
3
+ * a structured validation report (`reason` plus per-file `errors`) or a plain
4
+ * `message`. Clients that restore bundles parse it to tell the owner which
5
+ * file failed instead of printing raw JSON.
6
+ */
7
+
8
+ import { z } from "zod";
9
+
10
+ export const importFailureSchema = z.object({
11
+ reason: z.string().optional(),
12
+ message: z.string().optional(),
13
+ errors: z
14
+ .array(z.object({ message: z.string(), path: z.string().optional() }))
15
+ .optional(),
16
+ });
17
+
18
+ export type ImportFailure = z.infer<typeof importFailureSchema>;
19
+
20
+ /** Parse an import failure from JSON text, or null when the text is not one. */
21
+ export function parseImportFailure(text: string): ImportFailure | null {
22
+ try {
23
+ const parsed = importFailureSchema.safeParse(JSON.parse(text));
24
+ return parsed.success &&
25
+ (parsed.data.reason || parsed.data.message || parsed.data.errors)
26
+ ? parsed.data
27
+ : null;
28
+ } catch {
29
+ return null;
30
+ }
31
+ }
package/openapi.yaml CHANGED
@@ -3,7 +3,7 @@
3
3
  openapi: 3.1.0
4
4
  info:
5
5
  title: Vellum Assistant API
6
- version: 0.12.8
6
+ version: 0.12.10
7
7
  description: Auto-generated OpenAPI specification for the Vellum Assistant runtime HTTP server.
8
8
  servers:
9
9
  - url: http://127.0.0.1:7821
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/assistant",
3
- "version": "0.12.8",
3
+ "version": "0.12.10",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -430,10 +430,14 @@ describe("WorkspaceGitService", () => {
430
430
  expect(trackedFiles()).toContain(name);
431
431
  }
432
432
 
433
- const messages = execFileSync("git", ["log", "--pretty=%B", "--reverse"], {
434
- cwd: testDir,
435
- encoding: "utf-8",
436
- });
433
+ const messages = execFileSync(
434
+ "git",
435
+ ["log", "--pretty=%B", "--reverse"],
436
+ {
437
+ cwd: testDir,
438
+ encoding: "utf-8",
439
+ },
440
+ );
437
441
  expect(messages).toContain("batch: 1/3");
438
442
  expect(messages).toContain("batch: 2/3");
439
443
  expect(messages).toContain("batch: 3/3");
@@ -505,7 +509,12 @@ describe("WorkspaceGitService", () => {
505
509
  const service = new WorkspaceGitService(testDir);
506
510
  await service.ensureInitialized();
507
511
 
508
- for (const name of ["keep.txt", "gone-a.txt", "gone-b.txt", "gone-c.txt"]) {
512
+ for (const name of [
513
+ "keep.txt",
514
+ "gone-a.txt",
515
+ "gone-b.txt",
516
+ "gone-c.txt",
517
+ ]) {
509
518
  writeFileSync(join(testDir, name), name);
510
519
  }
511
520
  await service.commitChanges("Seed files");
@@ -765,6 +774,31 @@ describe("WorkspaceGitService", () => {
765
774
  });
766
775
 
767
776
  describe("existing repo normalization", () => {
777
+ test("keeps history when refs/ is missing because every ref is packed", async () => {
778
+ execFileSync("git", ["init", "-b", "main"], { cwd: testDir });
779
+ execFileSync("git", ["config", "user.name", "Test"], { cwd: testDir });
780
+ execFileSync("git", ["config", "user.email", "user@example.com"], {
781
+ cwd: testDir,
782
+ });
783
+ writeFileSync(join(testDir, "file.txt"), "content");
784
+ execFileSync("git", ["add", "-A"], { cwd: testDir });
785
+ execFileSync("git", ["commit", "-m", "restored history"], {
786
+ cwd: testDir,
787
+ });
788
+ execFileSync("git", ["pack-refs", "--all"], { cwd: testDir });
789
+ // A files-only restore drops the now-empty refs/ directory.
790
+ rmSync(join(testDir, ".git", "refs"), { recursive: true, force: true });
791
+
792
+ const service = new WorkspaceGitService(testDir);
793
+ await service.ensureInitialized();
794
+
795
+ const log = execFileSync("git", ["log", "--format=%s"], {
796
+ cwd: testDir,
797
+ encoding: "utf-8",
798
+ });
799
+ expect(log).toContain("restored history");
800
+ });
801
+
768
802
  test("existing repo on feature branch auto-switches to main on init", async () => {
769
803
  // Set up a pre-existing git repo on a feature branch
770
804
  execFileSync("git", ["init", "-b", "main"], { cwd: testDir });
@@ -191,6 +191,10 @@ describe("ManifestSchema — v1 acceptance", () => {
191
191
  });
192
192
  });
193
193
 
194
+ // Building and validating a manifest at the entry cap takes several seconds on
195
+ // shared CI runners, past the default per-test timeout.
196
+ const CAP_SIZED_MANIFEST_TIMEOUT_MS = 60_000;
197
+
194
198
  describe("validateVBundle: streaming manifest limits", () => {
195
199
  test("rejects a manifest over MANIFEST_MAX_BYTES with MANIFEST_TOO_LARGE", () => {
196
200
  const oversized = new Uint8Array(MANIFEST_MAX_BYTES + 1).fill(0x20);
@@ -202,39 +206,47 @@ describe("validateVBundle: streaming manifest limits", () => {
202
206
  expect(result.errors.map((e) => e.code)).toEqual(["MANIFEST_TOO_LARGE"]);
203
207
  });
204
208
 
205
- test("rejects a manifest declaring more than MANIFEST_MAX_ENTRIES with MANIFEST_TOO_MANY_ENTRIES", () => {
206
- const skeleton = v1Skeleton();
207
- const dbEntry = (skeleton.contents as Array<Record<string, unknown>>)[0]!;
208
- const extra = Array.from({ length: MANIFEST_MAX_ENTRIES }, (_, i) => ({
209
- ...dbEntry,
210
- path: `workspace/${i}`,
211
- }));
212
- const archive = gzipTarOf(
213
- withChecksum({ ...skeleton, contents: [dbEntry, ...extra] }),
214
- );
215
- const result = validateVBundle(archive, { enforceStreamingLimits: true });
216
- expect(result.is_valid).toBe(false);
217
- expect(result.errors.map((e) => e.code)).toEqual([
218
- "MANIFEST_TOO_MANY_ENTRIES",
219
- ]);
220
- });
209
+ test(
210
+ "rejects a manifest declaring more than MANIFEST_MAX_ENTRIES with MANIFEST_TOO_MANY_ENTRIES",
211
+ () => {
212
+ const skeleton = v1Skeleton();
213
+ const dbEntry = (skeleton.contents as Array<Record<string, unknown>>)[0]!;
214
+ const extra = Array.from({ length: MANIFEST_MAX_ENTRIES }, (_, i) => ({
215
+ ...dbEntry,
216
+ path: `workspace/${i}`,
217
+ }));
218
+ const archive = gzipTarOf(
219
+ withChecksum({ ...skeleton, contents: [dbEntry, ...extra] }),
220
+ );
221
+ const result = validateVBundle(archive, { enforceStreamingLimits: true });
222
+ expect(result.is_valid).toBe(false);
223
+ expect(result.errors.map((e) => e.code)).toEqual([
224
+ "MANIFEST_TOO_MANY_ENTRIES",
225
+ ]);
226
+ },
227
+ CAP_SIZED_MANIFEST_TIMEOUT_MS,
228
+ );
221
229
 
222
- test("does not apply the limits unless enforceStreamingLimits is set", () => {
223
- const skeleton = v1Skeleton();
224
- const dbEntry = (skeleton.contents as Array<Record<string, unknown>>)[0]!;
225
- const extra = Array.from({ length: MANIFEST_MAX_ENTRIES }, (_, i) => ({
226
- ...dbEntry,
227
- path: `workspace/${i}`,
228
- }));
229
- const archive = gzipTarOf(
230
- withChecksum({ ...skeleton, contents: [dbEntry, ...extra] }),
231
- [{ name: "data/db/assistant.db", data: DB_BYTES }],
232
- );
233
- const result = validateVBundle(archive);
234
- expect(result.errors.map((e) => e.code)).not.toContain(
235
- "MANIFEST_TOO_MANY_ENTRIES",
236
- );
237
- });
230
+ test(
231
+ "does not apply the limits unless enforceStreamingLimits is set",
232
+ () => {
233
+ const skeleton = v1Skeleton();
234
+ const dbEntry = (skeleton.contents as Array<Record<string, unknown>>)[0]!;
235
+ const extra = Array.from({ length: MANIFEST_MAX_ENTRIES }, (_, i) => ({
236
+ ...dbEntry,
237
+ path: `workspace/${i}`,
238
+ }));
239
+ const archive = gzipTarOf(
240
+ withChecksum({ ...skeleton, contents: [dbEntry, ...extra] }),
241
+ [{ name: "data/db/assistant.db", data: DB_BYTES }],
242
+ );
243
+ const result = validateVBundle(archive);
244
+ expect(result.errors.map((e) => e.code)).not.toContain(
245
+ "MANIFEST_TOO_MANY_ENTRIES",
246
+ );
247
+ },
248
+ CAP_SIZED_MANIFEST_TIMEOUT_MS,
249
+ );
238
250
  });
239
251
 
240
252
  describe("ManifestSchema — v1 rejection", () => {
@@ -89,10 +89,11 @@ const log = getLogger("vbundle-streaming-importer");
89
89
 
90
90
  /**
91
91
  * Byte ceiling for the cumulative size of all file data streamed from the
92
- * bundle. 16 GiB gives comfortable headroom over the 8 GB product limit
93
- * while still bounding worst-case disk use for the temp workspace.
92
+ * bundle. Workspaces with years of conversations and large databases reach
93
+ * 35 GiB, so 64 GiB leaves headroom while still bounding worst-case disk
94
+ * use for the temp workspace.
94
95
  */
95
- const DEFAULT_MAX_BUNDLE_BYTES = 16 * 1024 * 1024 * 1024;
96
+ const DEFAULT_MAX_BUNDLE_BYTES = 64 * 1024 * 1024 * 1024;
96
97
 
97
98
  /**
98
99
  * Entry-count ceiling for the bundle, shared with manifest validation so
@@ -394,17 +394,18 @@ export function computeManifestChecksum(manifest: unknown): string {
394
394
  * Hard caps on `manifest.json`, shared by the buffered and streaming
395
395
  * validators so preflight and import agree on what is acceptable. The two
396
396
  * are sized together: the manifest carries one `contents` entry (path,
397
- * sha256, size) per bundled file at roughly 150 bytes each, so 200,000
398
- * entries serialize to about 32 MiB.
397
+ * sha256, size) per bundled file at roughly 150 bytes each, so 800,000
398
+ * entries serialize to about 128 MiB.
399
399
  *
400
- * That absorbs a workspace with a stray dependency install or checked-out
401
- * repo while still bounding the transient memory a hostile "manifest" can
402
- * force the importer to hold (buffer, decoded string, parsed object,
403
- * canonical re-serialization for the self-checksum) and the per-entry work
404
- * it commits to, on a memory-constrained pod.
400
+ * Long-lived workspaces with several checked-out repos, worktrees, and
401
+ * dependency installs reach 275,000 entries and 55 MiB, so the caps leave
402
+ * room for those while still bounding the transient memory a hostile
403
+ * "manifest" can force the importer to hold (buffer, decoded string, parsed
404
+ * object, canonical re-serialization for the self-checksum) and the
405
+ * per-entry work it commits to.
405
406
  */
406
- export const MANIFEST_MAX_BYTES = 32 * 1024 * 1024;
407
- export const MANIFEST_MAX_ENTRIES = 200_000;
407
+ export const MANIFEST_MAX_BYTES = 128 * 1024 * 1024;
408
+ export const MANIFEST_MAX_ENTRIES = 800_000;
408
409
 
409
410
  export interface ValidateVBundleOptions {
410
411
  /**
@@ -254,6 +254,21 @@ interface GitStatus {
254
254
  clean: boolean;
255
255
  }
256
256
 
257
+ /**
258
+ * Recreate the directories every repository has. A files-only copy of the
259
+ * workspace (a `.vbundle` export or a backup) carries no empty directories,
260
+ * so a repo whose refs all live in `packed-refs` arrives without `refs/`, and
261
+ * git then reports "not a git repository" for a repo whose history is intact.
262
+ */
263
+ function ensureRepoSkeletonDirs(gitDir: string): void {
264
+ if (!lstatSync(gitDir).isDirectory()) {
265
+ return;
266
+ }
267
+ for (const dir of ["objects", "refs/heads", "refs/tags"]) {
268
+ mkdirSync(join(gitDir, dir), { recursive: true });
269
+ }
270
+ }
271
+
257
272
  /**
258
273
  * Git service for workspace change management.
259
274
  *
@@ -461,6 +476,7 @@ export class WorkspaceGitService {
461
476
  }
462
477
 
463
478
  if (existsSync(gitDir)) {
479
+ ensureRepoSkeletonDirs(gitDir);
464
480
  // Validate existing repo is not corrupted before marking as ready.
465
481
  // A corrupted .git directory (e.g. missing HEAD) would cause all
466
482
  // subsequent git operations to fail with confusing errors.