@vellumai/cli 0.10.4-dev.202607010028.1a4efcc → 0.10.4-dev.202607010119.ad15dbb
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/node_modules/@vellumai/local-mode/src/lockfile-contract.test.ts +11 -2
- package/node_modules/@vellumai/local-mode/src/lockfile-contract.ts +6 -0
- package/node_modules/@vellumai/local-mode/src/lockfile.test.ts +29 -1
- package/package.json +1 -1
- package/src/__tests__/retire.test.ts +61 -0
- package/src/__tests__/teleport.test.ts +8 -0
- package/src/commands/login.ts +10 -2
- package/src/commands/retire.ts +64 -12
- package/src/commands/teleport.ts +9 -2
|
@@ -21,6 +21,9 @@ describe("parseLockfile", () => {
|
|
|
21
21
|
species: "vellum",
|
|
22
22
|
hatchedAt: "2026-01-01T00:00:00.000Z",
|
|
23
23
|
organizationId: "org_1",
|
|
24
|
+
platformAssistantId: "platform-assistant-1",
|
|
25
|
+
platformBaseUrl: "https://platform.example.com",
|
|
26
|
+
platformOrganizationId: "org_1",
|
|
24
27
|
resources: { gatewayPort: 7777, daemonPort: 7778 },
|
|
25
28
|
},
|
|
26
29
|
],
|
|
@@ -274,13 +277,19 @@ describe("parseLockfile", () => {
|
|
|
274
277
|
expect(parseLockfile(raw).assistants).toEqual([
|
|
275
278
|
{ assistantId: "gcp_1", cloud: "gcp", runtimeUrl: "https://a" },
|
|
276
279
|
{ assistantId: "ssh_1", cloud: "custom", runtimeUrl: "https://b" },
|
|
277
|
-
{
|
|
280
|
+
{
|
|
281
|
+
assistantId: "local_1",
|
|
282
|
+
cloud: "local",
|
|
283
|
+
runtimeUrl: "http://localhost:7830",
|
|
284
|
+
},
|
|
278
285
|
]);
|
|
279
286
|
});
|
|
280
287
|
|
|
281
288
|
test("prefers an explicit cloud over legacy remote markers", () => {
|
|
282
289
|
const raw = {
|
|
283
|
-
assistants: [
|
|
290
|
+
assistants: [
|
|
291
|
+
{ assistantId: "a", cloud: "vellum", project: "stale-proj" },
|
|
292
|
+
],
|
|
284
293
|
activeAssistant: null,
|
|
285
294
|
};
|
|
286
295
|
expect(parseLockfile(raw).assistants).toEqual([
|
|
@@ -109,6 +109,12 @@ export const LockfileAssistantSchema = z.object({
|
|
|
109
109
|
hatchedAt: z.string().optional(),
|
|
110
110
|
/** Owning org for platform assistants; absent for local ones. */
|
|
111
111
|
organizationId: z.string().optional(),
|
|
112
|
+
/** Platform assistant UUID for a self-hosted local assistant registration. */
|
|
113
|
+
platformAssistantId: z.string().optional(),
|
|
114
|
+
/** Platform base URL used for a self-hosted local assistant registration. */
|
|
115
|
+
platformBaseUrl: z.string().optional(),
|
|
116
|
+
/** Platform organization UUID used for a self-hosted local assistant registration. */
|
|
117
|
+
platformOrganizationId: z.string().optional(),
|
|
112
118
|
resources: LocalAssistantResourcesSchema.optional(),
|
|
113
119
|
});
|
|
114
120
|
|
|
@@ -171,6 +171,32 @@ describe("upsertLockfileAssistant", () => {
|
|
|
171
171
|
name: "Renamed",
|
|
172
172
|
});
|
|
173
173
|
});
|
|
174
|
+
|
|
175
|
+
test("preserves activeAssistant when no active id is provided", () => {
|
|
176
|
+
writeOnDisk({
|
|
177
|
+
activeAssistant: "asst_active",
|
|
178
|
+
assistants: [
|
|
179
|
+
{
|
|
180
|
+
assistantId: "asst_active",
|
|
181
|
+
cloud: "local",
|
|
182
|
+
runtimeUrl: "http://active",
|
|
183
|
+
},
|
|
184
|
+
{ assistantId: "asst_1", cloud: "local", runtimeUrl: "http://a" },
|
|
185
|
+
],
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
const result = upsertLockfileAssistant(
|
|
189
|
+
[lockfilePath],
|
|
190
|
+
{ assistantId: "asst_1", name: "Renamed" },
|
|
191
|
+
undefined,
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
expect(result.ok).toBe(true);
|
|
195
|
+
expect(readOnDisk().activeAssistant).toBe("asst_active");
|
|
196
|
+
if (result.ok) {
|
|
197
|
+
expect(result.lockfile.activeAssistant).toBe("asst_active");
|
|
198
|
+
}
|
|
199
|
+
});
|
|
174
200
|
});
|
|
175
201
|
|
|
176
202
|
describe("replacePlatformAssistants", () => {
|
|
@@ -270,7 +296,9 @@ describe("replacePlatformAssistants", () => {
|
|
|
270
296
|
"org_a",
|
|
271
297
|
);
|
|
272
298
|
|
|
273
|
-
const assistants = readOnDisk().assistants as Array<
|
|
299
|
+
const assistants = readOnDisk().assistants as Array<
|
|
300
|
+
Record<string, unknown>
|
|
301
|
+
>;
|
|
274
302
|
expect(assistants).toHaveLength(1);
|
|
275
303
|
expect(assistants[0]).toMatchObject({
|
|
276
304
|
assistantId: "asst_dup",
|
package/package.json
CHANGED
|
@@ -341,6 +341,67 @@ describe("vellum retire", () => {
|
|
|
341
341
|
expect(retireLocalMock).toHaveBeenCalledWith("assistant-1", entry);
|
|
342
342
|
});
|
|
343
343
|
|
|
344
|
+
test("local retire uses saved platform registration when local credentials are unreachable", async () => {
|
|
345
|
+
const entry = makeEntry("assistant-1", {
|
|
346
|
+
name: "Example Assistant",
|
|
347
|
+
platformAssistantId: "platform-assistant-1",
|
|
348
|
+
platformBaseUrl: "https://platform.example.test",
|
|
349
|
+
platformOrganizationId: "org-123",
|
|
350
|
+
});
|
|
351
|
+
writeLockfile([entry]);
|
|
352
|
+
readPlatformTokenMock.mockReturnValue("session-token");
|
|
353
|
+
getPlatformUrlMock.mockReturnValue("https://platform.example.test");
|
|
354
|
+
readGatewayCredentialMock.mockResolvedValue({
|
|
355
|
+
value: null,
|
|
356
|
+
unreachable: true,
|
|
357
|
+
});
|
|
358
|
+
process.argv = ["bun", "vellum", "retire", "assistant-1", "--yes"];
|
|
359
|
+
|
|
360
|
+
await retire();
|
|
361
|
+
|
|
362
|
+
expect(readGatewayCredentialMock).toHaveBeenCalledWith(
|
|
363
|
+
entry.localUrl ?? entry.runtimeUrl,
|
|
364
|
+
"vellum:platform_assistant_id",
|
|
365
|
+
entry.bearerToken,
|
|
366
|
+
);
|
|
367
|
+
expect(loopbackSafeFetchMock).toHaveBeenCalledWith(
|
|
368
|
+
"https://platform.example.test/v1/assistants/platform-assistant-1/retire/",
|
|
369
|
+
{
|
|
370
|
+
method: "DELETE",
|
|
371
|
+
headers: {
|
|
372
|
+
"Content-Type": "application/json",
|
|
373
|
+
"X-Session-Token": "session-token",
|
|
374
|
+
"Vellum-Organization-Id": "org-123",
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
);
|
|
378
|
+
expect(consoleWarnSpy.mock.calls.flat().join("\n")).toContain(
|
|
379
|
+
"using saved platform registration",
|
|
380
|
+
);
|
|
381
|
+
expect(retireLocalMock).toHaveBeenCalledWith("assistant-1", entry);
|
|
382
|
+
expect(loadAllAssistants()).toEqual([]);
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
test("local retire continues when local credentials are unreachable and no saved platform registration exists", async () => {
|
|
386
|
+
const entry = makeEntry("assistant-1", { name: "Example Assistant" });
|
|
387
|
+
writeLockfile([entry]);
|
|
388
|
+
readPlatformTokenMock.mockReturnValue("session-token");
|
|
389
|
+
readGatewayCredentialMock.mockResolvedValue({
|
|
390
|
+
value: null,
|
|
391
|
+
unreachable: true,
|
|
392
|
+
});
|
|
393
|
+
process.argv = ["bun", "vellum", "retire", "assistant-1", "--yes"];
|
|
394
|
+
|
|
395
|
+
await retire();
|
|
396
|
+
|
|
397
|
+
expect(loopbackSafeFetchMock).not.toHaveBeenCalled();
|
|
398
|
+
expect(consoleWarnSpy.mock.calls.flat().join("\n")).toContain(
|
|
399
|
+
"no saved platform registration is available",
|
|
400
|
+
);
|
|
401
|
+
expect(retireLocalMock).toHaveBeenCalledWith("assistant-1", entry);
|
|
402
|
+
expect(loadAllAssistants()).toEqual([]);
|
|
403
|
+
});
|
|
404
|
+
|
|
344
405
|
test("local retire skips platform unregister when stored platform URL origin mismatches", async () => {
|
|
345
406
|
const entry = makeEntry("assistant-1", { name: "Example Assistant" });
|
|
346
407
|
writeLockfile([entry]);
|
|
@@ -2266,6 +2266,14 @@ describe("platform credential injection", () => {
|
|
|
2266
2266
|
userId: "user-1",
|
|
2267
2267
|
webhookSecret: "webhook-secret-123",
|
|
2268
2268
|
});
|
|
2269
|
+
expect(saveAssistantEntryMock).toHaveBeenCalledWith(
|
|
2270
|
+
expect.objectContaining({
|
|
2271
|
+
assistantId: "my-local",
|
|
2272
|
+
platformAssistantId: "platform-assistant-1",
|
|
2273
|
+
platformBaseUrl: "https://platform.vellum.ai",
|
|
2274
|
+
platformOrganizationId: "org-1",
|
|
2275
|
+
}),
|
|
2276
|
+
);
|
|
2269
2277
|
} finally {
|
|
2270
2278
|
restoreFetch();
|
|
2271
2279
|
}
|
package/src/commands/login.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
loadAllAssistants,
|
|
8
8
|
removeAssistantEntry,
|
|
9
9
|
resolveAssistant,
|
|
10
|
+
saveAssistantEntry,
|
|
10
11
|
setActiveAssistant,
|
|
11
12
|
} from "../lib/assistant-config";
|
|
12
13
|
import { computeDeviceId } from "../lib/guardian-token";
|
|
@@ -383,6 +384,7 @@ export async function login(): Promise<void> {
|
|
|
383
384
|
fetchCurrentVersion(entry.runtimeUrl),
|
|
384
385
|
fetchAssistantIngressUrl(entry.runtimeUrl, entry.bearerToken),
|
|
385
386
|
]);
|
|
387
|
+
const platformUrl = getPlatformUrl();
|
|
386
388
|
const registration = await ensureSelfHostedLocalRegistration(
|
|
387
389
|
token,
|
|
388
390
|
orgId,
|
|
@@ -390,9 +392,15 @@ export async function login(): Promise<void> {
|
|
|
390
392
|
entry.assistantId,
|
|
391
393
|
"cli",
|
|
392
394
|
assistantVersion,
|
|
393
|
-
|
|
395
|
+
platformUrl,
|
|
394
396
|
ingressUrl,
|
|
395
397
|
);
|
|
398
|
+
saveAssistantEntry({
|
|
399
|
+
...entry,
|
|
400
|
+
platformAssistantId: registration.assistant.id,
|
|
401
|
+
platformBaseUrl: platformUrl,
|
|
402
|
+
platformOrganizationId: orgId,
|
|
403
|
+
});
|
|
396
404
|
console.log(
|
|
397
405
|
`Registered assistant: ${registration.assistant.name} (${registration.assistant.id})`,
|
|
398
406
|
);
|
|
@@ -433,7 +441,7 @@ export async function login(): Promise<void> {
|
|
|
433
441
|
bearerToken: entry.bearerToken,
|
|
434
442
|
assistantApiKey,
|
|
435
443
|
platformAssistantId: registration.assistant.id,
|
|
436
|
-
platformBaseUrl:
|
|
444
|
+
platformBaseUrl: platformUrl,
|
|
437
445
|
organizationId: orgId,
|
|
438
446
|
userId: user.id,
|
|
439
447
|
webhookSecret: registration.webhook_secret,
|
package/src/commands/retire.ts
CHANGED
|
@@ -47,6 +47,12 @@ interface RetireArgs {
|
|
|
47
47
|
yes: boolean;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
interface SelfHostedPlatformRegistration {
|
|
51
|
+
platformAssistantId: string;
|
|
52
|
+
platformBaseUrl: string | null;
|
|
53
|
+
organizationId: string | null;
|
|
54
|
+
}
|
|
55
|
+
|
|
50
56
|
const PLATFORM_TOKEN_ENV = "VELLUM_PLATFORM_TOKEN";
|
|
51
57
|
|
|
52
58
|
function readPlatformRetireToken(): string | null {
|
|
@@ -81,6 +87,24 @@ function resolveTrustedSelfHostedPlatformUrl(
|
|
|
81
87
|
return null;
|
|
82
88
|
}
|
|
83
89
|
|
|
90
|
+
function nonEmptyString(value: string | null | undefined): string | null {
|
|
91
|
+
const trimmed = value?.trim();
|
|
92
|
+
return trimmed ? trimmed : null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function lockfileSelfHostedPlatformRegistration(
|
|
96
|
+
entry: AssistantEntry,
|
|
97
|
+
): SelfHostedPlatformRegistration | null {
|
|
98
|
+
const platformAssistantId = nonEmptyString(entry.platformAssistantId);
|
|
99
|
+
if (!platformAssistantId) return null;
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
platformAssistantId,
|
|
103
|
+
platformBaseUrl: nonEmptyString(entry.platformBaseUrl),
|
|
104
|
+
organizationId: nonEmptyString(entry.platformOrganizationId),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
84
108
|
async function deletePlatformAssistant(
|
|
85
109
|
assistantId: string,
|
|
86
110
|
options: {
|
|
@@ -115,12 +139,10 @@ async function deletePlatformAssistant(
|
|
|
115
139
|
}
|
|
116
140
|
}
|
|
117
141
|
|
|
118
|
-
async function
|
|
142
|
+
async function readSelfHostedPlatformRegistration(
|
|
119
143
|
entry: AssistantEntry,
|
|
120
|
-
): Promise<
|
|
121
|
-
const
|
|
122
|
-
if (!token) return;
|
|
123
|
-
|
|
144
|
+
): Promise<SelfHostedPlatformRegistration | null> {
|
|
145
|
+
const fallback = lockfileSelfHostedPlatformRegistration(entry);
|
|
124
146
|
const gatewayUrl = entry.localUrl ?? entry.runtimeUrl;
|
|
125
147
|
const platformAssistant = await readGatewayCredential(
|
|
126
148
|
gatewayUrl,
|
|
@@ -128,12 +150,21 @@ async function unregisterSelfHostedLocalPlatformRecord(
|
|
|
128
150
|
entry.bearerToken,
|
|
129
151
|
);
|
|
130
152
|
if (platformAssistant.unreachable) {
|
|
153
|
+
if (fallback) {
|
|
154
|
+
console.warn(
|
|
155
|
+
"\u26a0\ufe0f Could not read platform registration from the local assistant; using saved platform registration.",
|
|
156
|
+
);
|
|
157
|
+
return fallback;
|
|
158
|
+
}
|
|
131
159
|
console.warn(
|
|
132
|
-
"\u26a0\ufe0f Could not read platform registration from the local assistant; skipping platform unregister.",
|
|
160
|
+
"\u26a0\ufe0f Could not read platform registration from the local assistant and no saved platform registration is available; skipping platform unregister.",
|
|
133
161
|
);
|
|
134
|
-
return;
|
|
162
|
+
return null;
|
|
135
163
|
}
|
|
136
|
-
|
|
164
|
+
|
|
165
|
+
const platformAssistantId =
|
|
166
|
+
nonEmptyString(platformAssistant.value) ?? fallback?.platformAssistantId;
|
|
167
|
+
if (!platformAssistantId) return null;
|
|
137
168
|
|
|
138
169
|
const [platformBaseUrl, organizationId] = await Promise.all([
|
|
139
170
|
readGatewayCredential(
|
|
@@ -147,21 +178,42 @@ async function unregisterSelfHostedLocalPlatformRecord(
|
|
|
147
178
|
entry.bearerToken,
|
|
148
179
|
),
|
|
149
180
|
]);
|
|
181
|
+
|
|
182
|
+
return {
|
|
183
|
+
platformAssistantId,
|
|
184
|
+
platformBaseUrl:
|
|
185
|
+
nonEmptyString(platformBaseUrl.value) ??
|
|
186
|
+
fallback?.platformBaseUrl ??
|
|
187
|
+
null,
|
|
188
|
+
organizationId:
|
|
189
|
+
nonEmptyString(organizationId.value) ?? fallback?.organizationId ?? null,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
async function unregisterSelfHostedLocalPlatformRecord(
|
|
194
|
+
entry: AssistantEntry,
|
|
195
|
+
): Promise<void> {
|
|
196
|
+
const token = readPlatformRetireToken();
|
|
197
|
+
if (!token) return;
|
|
198
|
+
|
|
199
|
+
const registration = await readSelfHostedPlatformRegistration(entry);
|
|
200
|
+
if (!registration) return;
|
|
201
|
+
|
|
150
202
|
const platformUrl = resolveTrustedSelfHostedPlatformUrl(
|
|
151
|
-
platformBaseUrl
|
|
203
|
+
registration.platformBaseUrl,
|
|
152
204
|
);
|
|
153
205
|
if (!platformUrl) return;
|
|
154
|
-
if (!organizationId
|
|
206
|
+
if (!registration.organizationId) {
|
|
155
207
|
console.warn(
|
|
156
208
|
"⚠️ Could not read platform organization ID from the local assistant; skipping platform unregister.",
|
|
157
209
|
);
|
|
158
210
|
return;
|
|
159
211
|
}
|
|
160
212
|
|
|
161
|
-
await deletePlatformAssistant(
|
|
213
|
+
await deletePlatformAssistant(registration.platformAssistantId, {
|
|
162
214
|
token,
|
|
163
215
|
platformUrl,
|
|
164
|
-
organizationId: organizationId
|
|
216
|
+
organizationId: registration.organizationId,
|
|
165
217
|
label: "Platform self-hosted unregister",
|
|
166
218
|
successMessage: "\u2705 Platform self-hosted registration unregistered.",
|
|
167
219
|
alreadyGoneMessage:
|
package/src/commands/teleport.ts
CHANGED
|
@@ -1123,6 +1123,7 @@ async function tryInjectPlatformCredentials(
|
|
|
1123
1123
|
fetchCurrentVersion(entry.runtimeUrl),
|
|
1124
1124
|
fetchAssistantIngressUrl(entry.runtimeUrl, entry.bearerToken),
|
|
1125
1125
|
]);
|
|
1126
|
+
const platformUrl = getPlatformUrl();
|
|
1126
1127
|
const registration = await ensureSelfHostedLocalRegistration(
|
|
1127
1128
|
token,
|
|
1128
1129
|
orgId,
|
|
@@ -1130,9 +1131,15 @@ async function tryInjectPlatformCredentials(
|
|
|
1130
1131
|
entry.assistantId,
|
|
1131
1132
|
"cli",
|
|
1132
1133
|
assistantVersion,
|
|
1133
|
-
|
|
1134
|
+
platformUrl,
|
|
1134
1135
|
ingressUrl,
|
|
1135
1136
|
);
|
|
1137
|
+
saveAssistantEntry({
|
|
1138
|
+
...entry,
|
|
1139
|
+
platformAssistantId: registration.assistant.id,
|
|
1140
|
+
platformBaseUrl: platformUrl,
|
|
1141
|
+
platformOrganizationId: orgId,
|
|
1142
|
+
});
|
|
1136
1143
|
|
|
1137
1144
|
// Resolve the API key: 1) fresh from registration, 2) existing from
|
|
1138
1145
|
// daemon credential store, 3) reprovision as last resort (revokes old key).
|
|
@@ -1164,7 +1171,7 @@ async function tryInjectPlatformCredentials(
|
|
|
1164
1171
|
bearerToken: entry.bearerToken,
|
|
1165
1172
|
assistantApiKey,
|
|
1166
1173
|
platformAssistantId: registration.assistant.id,
|
|
1167
|
-
platformBaseUrl:
|
|
1174
|
+
platformBaseUrl: platformUrl,
|
|
1168
1175
|
organizationId: orgId,
|
|
1169
1176
|
userId: user.id,
|
|
1170
1177
|
webhookSecret: registration.webhook_secret,
|