@vellumai/assistant 0.8.11-dev.202606112241.9ae2fdc → 0.8.11-dev.202606120012.5656fc7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/assistant",
3
- "version": "0.8.11-dev.202606112241.9ae2fdc",
3
+ "version": "0.8.11-dev.202606120012.5656fc7",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -0,0 +1,185 @@
1
+ import {
2
+ existsSync,
3
+ mkdirSync,
4
+ readFileSync,
5
+ rmSync,
6
+ writeFileSync,
7
+ } from "node:fs";
8
+ import { tmpdir } from "node:os";
9
+ import { join } from "node:path";
10
+ import { afterEach, beforeEach, describe, expect, test } from "bun:test";
11
+
12
+ import { repairAdaptiveThinkingOnManagedProfiles } from "../workspace/adaptive-thinking-repair.js";
13
+ import { enableAdaptiveThinkingManagedProfilesMigration } from "../workspace/migrations/097-enable-adaptive-thinking-managed-profiles.js";
14
+
15
+ const ADAPTIVE = { enabled: true, streamThinking: true };
16
+
17
+ let workspaceDir: string;
18
+
19
+ beforeEach(() => {
20
+ workspaceDir = join(
21
+ tmpdir(),
22
+ `vellum-adaptive-thinking-repair-test-${Date.now()}-${Math.random().toString(36).slice(2)}`,
23
+ );
24
+ mkdirSync(workspaceDir, { recursive: true });
25
+ });
26
+
27
+ afterEach(() => {
28
+ if (existsSync(workspaceDir)) {
29
+ rmSync(workspaceDir, { recursive: true, force: true });
30
+ }
31
+ });
32
+
33
+ function writeConfig(data: Record<string, unknown>): void {
34
+ writeFileSync(
35
+ join(workspaceDir, "config.json"),
36
+ JSON.stringify(data, null, 2) + "\n",
37
+ );
38
+ }
39
+
40
+ function readConfig(): Record<string, unknown> {
41
+ return JSON.parse(readFileSync(join(workspaceDir, "config.json"), "utf-8"));
42
+ }
43
+
44
+ function profile(name: string): Record<string, unknown> {
45
+ const config = readConfig();
46
+ const llm = config.llm as Record<string, unknown>;
47
+ const profiles = llm.profiles as Record<string, unknown>;
48
+ return profiles[name] as Record<string, unknown>;
49
+ }
50
+
51
+ // The startup repair and migration 097 keep frozen copies of the same logic
52
+ // (migration modules must stay self-contained). Run every scenario against
53
+ // both so the copies can't drift.
54
+ const implementations: Array<[string, (dir: string) => void]> = [
55
+ ["startup repair", repairAdaptiveThinkingOnManagedProfiles],
56
+ [
57
+ "migration 097",
58
+ (dir) => enableAdaptiveThinkingManagedProfilesMigration.run(dir),
59
+ ],
60
+ ];
61
+
62
+ describe.each(implementations)("%s", (_label, run) => {
63
+ test("patches managed Anthropic profiles missing thinking", () => {
64
+ writeConfig({
65
+ llm: {
66
+ default: { provider: "anthropic", model: "claude-sonnet-4-6" },
67
+ profiles: {
68
+ balanced: { source: "managed", provider: "anthropic" },
69
+ "quality-optimized": {
70
+ source: "managed",
71
+ provider: "anthropic",
72
+ thinking: { enabled: false },
73
+ },
74
+ },
75
+ },
76
+ });
77
+
78
+ run(workspaceDir);
79
+
80
+ expect(profile("balanced").thinking).toEqual(ADAPTIVE);
81
+ expect(profile("quality-optimized").thinking).toEqual(ADAPTIVE);
82
+ });
83
+
84
+ test("skips source-less empty shells when llm.default.provider is non-Anthropic", () => {
85
+ // Migration 052 seeds empty {} shells (no source, no provider) on legacy
86
+ // non-Anthropic workspaces. They inherit the non-Anthropic provider from
87
+ // llm.default and must stay off the Anthropic-specific repair.
88
+ writeConfig({
89
+ llm: {
90
+ default: { provider: "gemini", model: "gemini-2.5-pro" },
91
+ profiles: {
92
+ balanced: {},
93
+ "quality-optimized": {},
94
+ },
95
+ },
96
+ });
97
+
98
+ run(workspaceDir);
99
+
100
+ expect(profile("balanced")).toEqual({});
101
+ expect(profile("quality-optimized")).toEqual({});
102
+ });
103
+
104
+ test("treats absent llm.default.provider as Anthropic for source-less profiles", () => {
105
+ writeConfig({
106
+ llm: {
107
+ default: { model: "claude-sonnet-4-6" },
108
+ profiles: {
109
+ balanced: {},
110
+ },
111
+ },
112
+ });
113
+
114
+ run(workspaceDir);
115
+
116
+ expect(profile("balanced").thinking).toEqual(ADAPTIVE);
117
+ });
118
+
119
+ test("explicit Anthropic provider on the profile wins over a non-Anthropic default", () => {
120
+ writeConfig({
121
+ llm: {
122
+ default: { provider: "gemini" },
123
+ profiles: {
124
+ balanced: { provider: "anthropic" },
125
+ },
126
+ },
127
+ });
128
+
129
+ run(workspaceDir);
130
+
131
+ expect(profile("balanced").thinking).toEqual(ADAPTIVE);
132
+ });
133
+
134
+ test("skips profiles with an explicit non-Anthropic provider", () => {
135
+ writeConfig({
136
+ llm: {
137
+ default: { provider: "anthropic" },
138
+ profiles: {
139
+ balanced: { provider: "gemini" },
140
+ },
141
+ },
142
+ });
143
+
144
+ run(workspaceDir);
145
+
146
+ expect(profile("balanced").thinking).toBeUndefined();
147
+ });
148
+
149
+ test("skips source: user profiles", () => {
150
+ writeConfig({
151
+ llm: {
152
+ default: { provider: "anthropic" },
153
+ profiles: {
154
+ balanced: { source: "user", provider: "anthropic" },
155
+ },
156
+ },
157
+ });
158
+
159
+ run(workspaceDir);
160
+
161
+ expect(profile("balanced").thinking).toBeUndefined();
162
+ });
163
+
164
+ test("is idempotent when thinking is already enabled", () => {
165
+ const config = {
166
+ llm: {
167
+ default: { provider: "anthropic" },
168
+ profiles: {
169
+ balanced: {
170
+ source: "managed",
171
+ thinking: { enabled: true, streamThinking: false },
172
+ },
173
+ },
174
+ },
175
+ };
176
+ writeConfig(config);
177
+
178
+ run(workspaceDir);
179
+
180
+ expect(profile("balanced").thinking).toEqual({
181
+ enabled: true,
182
+ streamThinking: false,
183
+ });
184
+ });
185
+ });
@@ -1364,6 +1364,40 @@ describe("custom baseURL initialization", () => {
1364
1364
  timeout: DEFAULT_SDK_TIMEOUT_MS,
1365
1365
  });
1366
1366
  });
1367
+
1368
+ test("MinimaxProvider sends reasoning_split so reasoning never leaks into content as <think> tags", async () => {
1369
+ fakeChunks = [textChunk("hello", "stop"), usageChunk(10, 5)];
1370
+ const provider = new MinimaxProvider("mm-user-key", "MiniMax-M3");
1371
+
1372
+ await provider.sendMessage([userMsg("hi")]);
1373
+
1374
+ expect(lastCreateParams!.reasoning_split).toBe(true);
1375
+ });
1376
+
1377
+ test("MinimaxProvider replays prior assistant thinking via reasoning_content", async () => {
1378
+ fakeChunks = [textChunk("done", "stop"), usageChunk(10, 5)];
1379
+ const provider = new MinimaxProvider("mm-user-key", "MiniMax-M3");
1380
+
1381
+ await provider.sendMessage([
1382
+ userMsg("question"),
1383
+ {
1384
+ role: "assistant",
1385
+ content: [
1386
+ { type: "thinking", thinking: "prior reasoning", signature: "" },
1387
+ { type: "text", text: "prior answer" },
1388
+ ],
1389
+ },
1390
+ userMsg("follow-up"),
1391
+ ]);
1392
+
1393
+ const sent = lastCreateParams!.messages as Array<Record<string, unknown>>;
1394
+ const assistantTurn = sent.find((m) => m.role === "assistant");
1395
+ expect(assistantTurn).toEqual({
1396
+ role: "assistant",
1397
+ content: "prior answer",
1398
+ reasoning_content: "prior reasoning",
1399
+ });
1400
+ });
1367
1401
  });
1368
1402
 
1369
1403
  // ---------------------------------------------------------------------------
@@ -2,6 +2,8 @@ import { describe, expect, test } from "bun:test";
2
2
 
3
3
  import {
4
4
  computeNextRunAt,
5
+ describeRRuleExpression,
6
+ isSingleFireRRule,
5
7
  isValidScheduleExpression,
6
8
  } from "../schedule/recurrence-engine.js";
7
9
 
@@ -117,3 +119,46 @@ describe("recurrence engine — rrule", () => {
117
119
  expect(next).toBe(jan2);
118
120
  });
119
121
  });
122
+
123
+ describe("recurrence engine — rrule display helpers", () => {
124
+ const SINGLE_FIRE = "DTSTART:20990612T080000\nRRULE:FREQ=DAILY;COUNT=1";
125
+ const WEEKLY = "DTSTART:20990612T080000\nRRULE:FREQ=WEEKLY;BYDAY=MO,WE";
126
+
127
+ test("isSingleFireRRule detects COUNT=1 rules", () => {
128
+ expect(isSingleFireRRule(SINGLE_FIRE)).toBe(true);
129
+ expect(isSingleFireRRule(WEEKLY)).toBe(false);
130
+ expect(
131
+ isSingleFireRRule("DTSTART:20990612T080000\nRRULE:FREQ=DAILY;COUNT=2"),
132
+ ).toBe(false);
133
+ expect(isSingleFireRRule("not an rrule")).toBe(false);
134
+ });
135
+
136
+ test("isSingleFireRRule is false for set constructs", () => {
137
+ expect(
138
+ isSingleFireRRule(
139
+ "DTSTART:20990612T080000\nRRULE:FREQ=DAILY;COUNT=1\nRDATE:20990613T080000",
140
+ ),
141
+ ).toBe(false);
142
+ });
143
+
144
+ test("describeRRuleExpression humanizes rules", () => {
145
+ expect(describeRRuleExpression(SINGLE_FIRE)).toBe("One-time");
146
+ expect(describeRRuleExpression(WEEKLY)).toBe(
147
+ "Every week on Monday, Wednesday",
148
+ );
149
+ expect(
150
+ describeRRuleExpression(
151
+ "DTSTART:20990612T080000\nRRULE:FREQ=DAILY;COUNT=3",
152
+ ),
153
+ ).toBe("Every day for 3 times");
154
+ });
155
+
156
+ test("describeRRuleExpression falls back instead of leaking raw text", () => {
157
+ expect(
158
+ describeRRuleExpression(
159
+ "DTSTART:20990612T080000\nRRULE:FREQ=DAILY\nEXDATE:20990613T080000",
160
+ ),
161
+ ).toBe("Custom recurrence");
162
+ expect(describeRRuleExpression("garbage")).toBe("Custom recurrence");
163
+ });
164
+ });
@@ -492,6 +492,40 @@ describe("GET /schedules — default defer exclusion", () => {
492
492
  });
493
493
  });
494
494
 
495
+ test("humanizes rrule cadences and flags single-fire rrules as one-shot", () => {
496
+ createSchedule({
497
+ name: "RRule single fire",
498
+ cronExpression: "DTSTART:20990612T080000\nRRULE:FREQ=DAILY;COUNT=1",
499
+ syntax: "rrule",
500
+ message: "brush teeth",
501
+ });
502
+ createSchedule({
503
+ name: "RRule weekly",
504
+ cronExpression: "DTSTART:20990612T080000\nRRULE:FREQ=WEEKLY;BYDAY=MO,WE",
505
+ syntax: "rrule",
506
+ message: "standup",
507
+ });
508
+
509
+ const route = findRoute("schedules", "GET");
510
+ const result = route.handler({}) as {
511
+ schedules: Array<{
512
+ name: string;
513
+ cadenceDescription: string;
514
+ isOneShot: boolean;
515
+ }>;
516
+ };
517
+ const byName = new Map(result.schedules.map((s) => [s.name, s]));
518
+
519
+ expect(byName.get("RRule single fire")).toMatchObject({
520
+ cadenceDescription: "One-time",
521
+ isOneShot: true,
522
+ });
523
+ expect(byName.get("RRule weekly")).toMatchObject({
524
+ cadenceDescription: "Every week on Monday, Wednesday",
525
+ isOneShot: false,
526
+ });
527
+ });
528
+
495
529
  test("mutation responses also exclude deferred wakes", () => {
496
530
  createSchedule({
497
531
  name: "Agent schedule",
@@ -247,13 +247,18 @@ describe("session-manager", () => {
247
247
  await startSession(session.id);
248
248
  expect(getActiveSession(CONV_ID)).toBeDefined();
249
249
 
250
- // Wait for the idle timeout to fire
251
- await new Promise((r) => setTimeout(r, 200));
250
+ // Wait for the idle timeout to fire and the async stop to finish.
251
+ // The session passes through "stopping" while the server closes, so
252
+ // poll for the terminal state rather than sleeping a fixed interval.
253
+ const deadline = Date.now() + 5000;
254
+ const findSession = () =>
255
+ getSessionsForConversation(CONV_ID).find((x) => x.id === session.id);
256
+ while (findSession()?.status !== "stopped" && Date.now() < deadline) {
257
+ await new Promise((r) => setTimeout(r, 20));
258
+ }
252
259
 
253
260
  expect(getActiveSession(CONV_ID)).toBeUndefined();
254
- const all = getSessionsForConversation(CONV_ID);
255
- const s = all.find((x) => x.id === session.id);
256
- expect(s?.status).toBe("stopped");
261
+ expect(findSession()?.status).toBe("stopped");
257
262
  });
258
263
  });
259
264
 
@@ -347,6 +347,55 @@ describe("createSkillTool — required/type/enum validation", () => {
347
347
  expect(result.content).toContain('mode must be one of "a", "b"');
348
348
  });
349
349
 
350
+ test("coerces string booleans before validation and passes the coerced value to the executor", async () => {
351
+ const hash = computeSkillVersionHash(tempDir);
352
+ const tool = createSkillTool(
353
+ makeEntry({
354
+ executor: "echo.ts",
355
+ input_schema: {
356
+ type: "object",
357
+ properties: {
358
+ auto_open: { type: "boolean" },
359
+ name: { type: "string" },
360
+ },
361
+ },
362
+ }),
363
+ tempDir,
364
+ hash,
365
+ );
366
+
367
+ const result = await tool.execute(
368
+ { auto_open: "false", name: "x" },
369
+ makeContext(),
370
+ );
371
+
372
+ expect(result.isError).toBe(false);
373
+ const parsed = JSON.parse(result.content);
374
+ expect(parsed.input).toEqual({ auto_open: false, name: "x" });
375
+ });
376
+
377
+ test("rejects non-coercible boolean strings with a self-correcting message", async () => {
378
+ const hash = computeSkillVersionHash(tempDir);
379
+ const tool = createSkillTool(
380
+ makeEntry({
381
+ executor: "echo.ts",
382
+ input_schema: {
383
+ type: "object",
384
+ properties: { auto_open: { type: "boolean" } },
385
+ },
386
+ }),
387
+ tempDir,
388
+ hash,
389
+ );
390
+
391
+ const result = await tool.execute({ auto_open: "yes" }, makeContext());
392
+
393
+ expect(result.isError).toBe(true);
394
+ expect(result.content).toContain(
395
+ "auto_open must be a boolean — pass true or false as a JSON boolean, not a string",
396
+ );
397
+ });
398
+
350
399
  test("passes valid input through to the executor unchanged", async () => {
351
400
  const hash = computeSkillVersionHash(tempDir);
352
401
  const tool = createSkillTool(
@@ -1,6 +1,9 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
 
3
- import { validateInputAgainstSchema } from "../skills/validate-input.js";
3
+ import {
4
+ coerceStringBooleans,
5
+ validateInputAgainstSchema,
6
+ } from "../skills/validate-input.js";
4
7
 
5
8
  // ---------------------------------------------------------------------------
6
9
  // required
@@ -355,6 +358,97 @@ describe("validateInputAgainstSchema — permissive paths", () => {
355
358
  });
356
359
  });
357
360
 
361
+ // ---------------------------------------------------------------------------
362
+ // string-boolean coercion (pre-validation pass)
363
+ // ---------------------------------------------------------------------------
364
+
365
+ describe("coerceStringBooleans", () => {
366
+ const schema = {
367
+ type: "object",
368
+ properties: {
369
+ auto_open: { type: "boolean" },
370
+ name: { type: "string" },
371
+ flags: { type: ["boolean", "null"] },
372
+ },
373
+ };
374
+
375
+ test.each([
376
+ ["false", false],
377
+ ["true", true],
378
+ ["False", false],
379
+ ["TRUE", true],
380
+ [" true ", true],
381
+ ] as const)("coerces %p to %p for boolean-typed properties", (raw, want) => {
382
+ const result = coerceStringBooleans({ auto_open: raw }, schema);
383
+ expect(result.auto_open).toBe(want);
384
+ });
385
+
386
+ test("coerced input passes validation and preserves intent", () => {
387
+ const coerced = coerceStringBooleans(
388
+ { auto_open: "false", name: "x" },
389
+ schema,
390
+ );
391
+ expect(validateInputAgainstSchema("app_create", coerced, schema)).toEqual({
392
+ ok: true,
393
+ });
394
+ expect(coerced.auto_open).toBe(false);
395
+ });
396
+
397
+ test("leaves non-coercible strings alone (validation still rejects)", () => {
398
+ const input = { auto_open: "yes" };
399
+ const result = coerceStringBooleans(input, schema);
400
+ expect(result).toBe(input);
401
+ const validation = validateInputAgainstSchema("app_create", result, schema);
402
+ expect(validation.ok).toBe(false);
403
+ });
404
+
405
+ test("does not touch string-typed or union-typed properties", () => {
406
+ const input = { name: "true", flags: "false" };
407
+ const result = coerceStringBooleans(input, schema);
408
+ expect(result).toBe(input);
409
+ expect(result.name).toBe("true");
410
+ expect(result.flags).toBe("false");
411
+ });
412
+
413
+ test("does not touch real booleans or other types", () => {
414
+ const input = { auto_open: true };
415
+ expect(coerceStringBooleans(input, schema)).toBe(input);
416
+ const inputNum = { auto_open: 1 };
417
+ expect(coerceStringBooleans(inputNum, schema)).toBe(inputNum);
418
+ });
419
+
420
+ test("returns the same object when there is nothing to coerce", () => {
421
+ const input = { name: "x" };
422
+ expect(coerceStringBooleans(input, schema)).toBe(input);
423
+ expect(coerceStringBooleans(input, undefined)).toBe(input);
424
+ expect(coerceStringBooleans(input, { type: "object" })).toBe(input);
425
+ });
426
+
427
+ test("returns a new object and never mutates the original input", () => {
428
+ const input = { auto_open: "false", name: "x" };
429
+ const snapshot = JSON.parse(JSON.stringify(input));
430
+ const result = coerceStringBooleans(input, schema);
431
+ expect(result).not.toBe(input);
432
+ expect(input).toEqual(snapshot);
433
+ expect(result.name).toBe("x");
434
+ });
435
+ });
436
+
437
+ describe("validateInputAgainstSchema — boolean string error message", () => {
438
+ test("points at the JSON boolean form when a string is passed", () => {
439
+ const result = validateInputAgainstSchema(
440
+ "app_create",
441
+ { auto_open: "yes" },
442
+ { type: "object", properties: { auto_open: { type: "boolean" } } },
443
+ );
444
+ expect(result.ok).toBe(false);
445
+ if (result.ok) return;
446
+ expect(result.errors).toContain(
447
+ "auto_open must be a boolean — pass true or false as a JSON boolean, not a string",
448
+ );
449
+ });
450
+ });
451
+
358
452
  // ---------------------------------------------------------------------------
359
453
  // purity
360
454
  // ---------------------------------------------------------------------------