Skip to content

Commit e3806db

Browse files
feat(api): expose lifecycle_hooks on LaunchParameters lifecycle (#9115)
1 parent 891c5ee commit e3806db

6 files changed

Lines changed: 40 additions & 4 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 119
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runloop-ai/runloop-6ec03cfc156036a0758aebc523b469f3007de431312c536c434efe795e1892e7.yml
3-
openapi_spec_hash: 092761a0209e0950cfd8f262a981adb1
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runloop-ai/runloop-d4505c10f86f4ad122bfbc2a82a519278d626ac399c9ef3780496d5d7d1b99b9.yml
3+
openapi_spec_hash: b29dfd448505a0a3a6686202f606b8f7
44
config_hash: 06faf3176c48bf2b258730ce50809f0f

src/resources/shared.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ export interface LaunchParameters {
275275
/**
276276
* Lifecycle configuration for idle and resume behavior. Configure idle policy via
277277
* lifecycle.after_idle (if both this and the top-level after_idle are set, they
278-
* must match) and resume triggers via lifecycle.resume_triggers.
278+
* must match), resume triggers via lifecycle.resume_triggers, and optional
279+
* lifecycle hooks via lifecycle.lifecycle_hooks.
279280
*/
280281
lifecycle?: LaunchParameters.Lifecycle | null;
281282

@@ -321,7 +322,8 @@ export namespace LaunchParameters {
321322
/**
322323
* Lifecycle configuration for idle and resume behavior. Configure idle policy via
323324
* lifecycle.after_idle (if both this and the top-level after_idle are set, they
324-
* must match) and resume triggers via lifecycle.resume_triggers.
325+
* must match), resume triggers via lifecycle.resume_triggers, and optional
326+
* lifecycle hooks via lifecycle.lifecycle_hooks.
325327
*/
326328
export interface Lifecycle {
327329
/**
@@ -331,13 +333,39 @@ export namespace LaunchParameters {
331333
*/
332334
after_idle?: Shared.AfterIdle | null;
333335

336+
/**
337+
* Optional lifecycle hooks. suspend_commands run through the suspend path before
338+
* the Devbox suspends; see launch_commands for work on every startup.
339+
*/
340+
lifecycle_hooks?: Lifecycle.LifecycleHooks | null;
341+
334342
/**
335343
* Triggers that can resume a suspended Devbox.
336344
*/
337345
resume_triggers?: Lifecycle.ResumeTriggers | null;
338346
}
339347

340348
export namespace Lifecycle {
349+
/**
350+
* Optional lifecycle hooks. suspend_commands run through the suspend path before
351+
* the Devbox suspends; see launch_commands for work on every startup.
352+
*/
353+
export interface LifecycleHooks {
354+
/**
355+
* Commands to run through the suspend path before the Devbox suspends (e.g.
356+
* cleanup, quiesce daemons).
357+
*/
358+
suspend_commands?: Array<string> | null;
359+
360+
/**
361+
* Deadline in milliseconds for broker drain and suspend_commands during suspend.
362+
* Defaults to 30000 ms and may not exceed 60000 ms. If exceeded, suspend work is
363+
* abandoned, the timeout is logged, and the Devbox still proceeds to suspend by
364+
* shutting down vmagent and killing the VM.
365+
*/
366+
suspend_deadline_ms?: number | null;
367+
}
368+
341369
/**
342370
* Triggers that can resume a suspended Devbox.
343371
*/

tests/api-resources/benchmarks.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ describe('resource benchmarks', () => {
210210
launch_commands: ['string'],
211211
lifecycle: {
212212
after_idle: { idle_time_seconds: 0, on_idle: 'shutdown' },
213+
lifecycle_hooks: { suspend_commands: ['string'], suspend_deadline_ms: 0 },
213214
resume_triggers: { axon_event: true, http: true },
214215
},
215216
network_policy_id: 'network_policy_id',

tests/api-resources/blueprints.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ describe('resource blueprints', () => {
4949
launch_commands: ['string'],
5050
lifecycle: {
5151
after_idle: { idle_time_seconds: 0, on_idle: 'shutdown' },
52+
lifecycle_hooks: { suspend_commands: ['string'], suspend_deadline_ms: 0 },
5253
resume_triggers: { axon_event: true, http: true },
5354
},
5455
network_policy_id: 'network_policy_id',
@@ -198,6 +199,7 @@ describe('resource blueprints', () => {
198199
launch_commands: ['string'],
199200
lifecycle: {
200201
after_idle: { idle_time_seconds: 0, on_idle: 'shutdown' },
202+
lifecycle_hooks: { suspend_commands: ['string'], suspend_deadline_ms: 0 },
201203
resume_triggers: { axon_event: true, http: true },
202204
},
203205
network_policy_id: 'network_policy_id',
@@ -303,6 +305,7 @@ describe('resource blueprints', () => {
303305
launch_commands: ['string'],
304306
lifecycle: {
305307
after_idle: { idle_time_seconds: 0, on_idle: 'shutdown' },
308+
lifecycle_hooks: { suspend_commands: ['string'], suspend_deadline_ms: 0 },
306309
resume_triggers: { axon_event: true, http: true },
307310
},
308311
network_policy_id: 'network_policy_id',

tests/api-resources/devboxes/devboxes.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ describe('resource devboxes', () => {
5959
launch_commands: ['string'],
6060
lifecycle: {
6161
after_idle: { idle_time_seconds: 0, on_idle: 'shutdown' },
62+
lifecycle_hooks: { suspend_commands: ['string'], suspend_deadline_ms: 0 },
6263
resume_triggers: { axon_event: true, http: true },
6364
},
6465
network_policy_id: 'network_policy_id',

tests/api-resources/scenarios/scenarios.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ describe('resource scenarios', () => {
7070
launch_commands: ['string'],
7171
lifecycle: {
7272
after_idle: { idle_time_seconds: 0, on_idle: 'shutdown' },
73+
lifecycle_hooks: { suspend_commands: ['string'], suspend_deadline_ms: 0 },
7374
resume_triggers: { axon_event: true, http: true },
7475
},
7576
network_policy_id: 'network_policy_id',
@@ -144,6 +145,7 @@ describe('resource scenarios', () => {
144145
launch_commands: ['string'],
145146
lifecycle: {
146147
after_idle: { idle_time_seconds: 0, on_idle: 'shutdown' },
148+
lifecycle_hooks: { suspend_commands: ['string'], suspend_deadline_ms: 0 },
147149
resume_triggers: { axon_event: true, http: true },
148150
},
149151
network_policy_id: 'network_policy_id',
@@ -301,6 +303,7 @@ describe('resource scenarios', () => {
301303
launch_commands: ['string'],
302304
lifecycle: {
303305
after_idle: { idle_time_seconds: 0, on_idle: 'shutdown' },
306+
lifecycle_hooks: { suspend_commands: ['string'], suspend_deadline_ms: 0 },
304307
resume_triggers: { axon_event: true, http: true },
305308
},
306309
network_policy_id: 'network_policy_id',

0 commit comments

Comments
 (0)