Skip to content

Commit aa2d34a

Browse files
authored
variable: call the new /v1/variables routes (#86)
* variable: call the new /v1/variables routes The API moved variables out of the sandboxes namespace (ellipsis#6002, live in prod), matching where the CLI verb and the dashboard page already put them. The old paths now 404, so this is the client half of the same move. No fallback to the old paths: variables are pre-customer and this CLI is their only client. * deps: @ellipsis-dev/sdk 0.5.0 Picks up missing_sandbox_variables in AgentSessionExitStatus. Nothing here narrows to that union yet (exit_status is still a plain string), but the CLI should track the published SDK rather than drift a major behind.
1 parent 1b8e0ff commit aa2d34a

5 files changed

Lines changed: 15 additions & 20 deletions

File tree

bun.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"test:watch": "vitest"
2121
},
2222
"dependencies": {
23-
"@ellipsis-dev/sdk": "^0.4.0",
23+
"@ellipsis-dev/sdk": "^0.5.0",
2424
"chalk": "^5.6.2",
2525
"cli-table3": "^0.6.5",
2626
"commander": "^12.1.0",

src/commands/variable.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function registerVariable(program: Command): void {
2020
variable.command('list').description('List the variable names (never their values)'),
2121
'ls',
2222
),
23-
'GET /v1/sandboxes/variables',
23+
'GET /v1/variables',
2424
)
2525
.option('--json', 'output raw JSON')
2626
.action(async (opts: { json?: boolean }) => {
@@ -34,7 +34,7 @@ export function registerVariable(program: Command): void {
3434
variable
3535
.command('set [assignments...]')
3636
.description('Create or update variables, e.g. `set A=1 B=2`'),
37-
'PUT /v1/sandboxes/variables',
37+
'PUT /v1/variables',
3838
)
3939
.option('-f, --from-file <path>', 'load variables from a .env or .json file')
4040
.option('--json', 'output raw JSON')
@@ -52,7 +52,7 @@ export function registerVariable(program: Command): void {
5252

5353
apiRoutes(
5454
alsoKnownAs(variable.command('delete <name>').description('Delete a variable'), 'rm'),
55-
'DELETE /v1/sandboxes/variables/{name}',
55+
'DELETE /v1/variables/{name}',
5656
)
5757
.option('--json', 'output raw JSON')
5858
.action(async (name: string, opts: { json?: boolean }) => {

src/lib/api.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -400,33 +400,28 @@ export class ApiClient {
400400
return this.request('DELETE', '/v1/defaults', undefined, { repository })
401401
}
402402

403-
// -------------------------- sandbox variables ---------------------------
403+
// ------------------------------- variables --------------------------------
404404
// All three return the full current list (the backend echoes it after every
405405
// mutation), so callers can render the resulting state.
406406

407407
async listSandboxVariables(): Promise<SandboxVariableSummary[]> {
408-
const res = await this.request<GetSandboxVariablesResponse>(
409-
'GET',
410-
'/v1/sandboxes/variables',
411-
)
408+
const res = await this.request<GetSandboxVariablesResponse>('GET', '/v1/variables')
412409
return res.variables
413410
}
414411

415412
async putSandboxVariables(
416413
variables: SandboxVariableInput[],
417414
): Promise<SandboxVariableSummary[]> {
418-
const res = await this.request<GetSandboxVariablesResponse>(
419-
'PUT',
420-
'/v1/sandboxes/variables',
421-
{ variables },
422-
)
415+
const res = await this.request<GetSandboxVariablesResponse>('PUT', '/v1/variables', {
416+
variables,
417+
})
423418
return res.variables
424419
}
425420

426421
async deleteSandboxVariable(name: string): Promise<SandboxVariableSummary[]> {
427422
const res = await this.request<GetSandboxVariablesResponse>(
428423
'DELETE',
429-
`/v1/sandboxes/variables/${encodeURIComponent(name)}`,
424+
`/v1/variables/${encodeURIComponent(name)}`,
430425
)
431426
return res.variables
432427
}

test/api.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ describe('ApiClient sandbox variables', () => {
160160

161161
const out = await new ApiClient('http://api.test', 't').listSandboxVariables()
162162
expect(out).toEqual([{ name: 'A', created_at: '', updated_at: '' }])
163-
expect(fetchMock.mock.calls[0][0]).toBe('http://api.test/v1/sandboxes/variables')
163+
expect(fetchMock.mock.calls[0][0]).toBe('http://api.test/v1/variables')
164164
expect((fetchMock.mock.calls[0][1] as RequestInit).method).toBe('GET')
165165
})
166166

@@ -172,7 +172,7 @@ describe('ApiClient sandbox variables', () => {
172172

173173
await new ApiClient('http://api.test', 't').putSandboxVariables([{ name: 'TOKEN', value: 'x' }])
174174
const [url, init] = fetchMock.mock.calls[0]
175-
expect(url).toBe('http://api.test/v1/sandboxes/variables')
175+
expect(url).toBe('http://api.test/v1/variables')
176176
expect((init as RequestInit).method).toBe('PUT')
177177
expect(JSON.parse((init as RequestInit).body as string)).toEqual({
178178
variables: [{ name: 'TOKEN', value: 'x' }],
@@ -187,7 +187,7 @@ describe('ApiClient sandbox variables', () => {
187187

188188
await new ApiClient('http://api.test', 't').deleteSandboxVariable('MY/VAR')
189189
const [url, init] = fetchMock.mock.calls[0]
190-
expect(url).toBe('http://api.test/v1/sandboxes/variables/MY%2FVAR')
190+
expect(url).toBe('http://api.test/v1/variables/MY%2FVAR')
191191
expect((init as RequestInit).method).toBe('DELETE')
192192
})
193193
})

0 commit comments

Comments
 (0)