Skip to content

Commit f732c71

Browse files
Make Daytona sandbox lifecycle configurable and right-size Blacksmith runners (#22)
* Make Daytona sandbox lifecycle policies configurable and stop hardcoding auto-stop/delete values, while right-sizing standard Blacksmith CI jobs to 2 vCPU to lower cost for this lightweight workload. * Set a fixed Daytona lifecycle policy so sandboxes auto-stop/archive by default and remove lifecycle flags/env overrides from start/analyze CLI flows to keep managed usage simple.
1 parent 61ad673 commit f732c71

File tree

6 files changed

+38
-22
lines changed

6 files changed

+38
-22
lines changed

.github/workflows/check.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ env:
1717
jobs:
1818
Check:
1919
name: Check
20-
runs-on: blacksmith-4vcpu-ubuntu-2404
20+
runs-on: blacksmith-2vcpu-ubuntu-2404
2121
steps:
2222
- name: Checkout
2323
uses: actions/checkout@v4
@@ -47,7 +47,7 @@ jobs:
4747
4848
BuildPackage:
4949
name: Build Package Artifact
50-
runs-on: blacksmith-4vcpu-ubuntu-2404
50+
runs-on: blacksmith-2vcpu-ubuntu-2404
5151
needs: Check
5252
steps:
5353
- name: Checkout
@@ -84,7 +84,7 @@ jobs:
8484

8585
PackageE2E:
8686
name: Package Install E2E
87-
runs-on: blacksmith-4vcpu-ubuntu-2404
87+
runs-on: blacksmith-2vcpu-ubuntu-2404
8888
needs: BuildPackage
8989
steps:
9090
- name: Setup Node

.github/workflows/publish-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ permissions:
1616
jobs:
1717
resolve-merge-context:
1818
name: Resolve Merge Context
19-
runs-on: blacksmith-4vcpu-ubuntu-2404
19+
runs-on: blacksmith-2vcpu-ubuntu-2404
2020
permissions:
2121
contents: read
2222
pull-requests: read
@@ -122,7 +122,7 @@ jobs:
122122
123123
publish-and-manage-bump:
124124
name: Publish Package + Manage Bump PR
125-
runs-on: blacksmith-4vcpu-ubuntu-2404
125+
runs-on: blacksmith-2vcpu-ubuntu-2404
126126
needs: resolve-merge-context
127127
permissions:
128128
contents: write

.github/workflows/validate-pr-title.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ permissions:
1010
jobs:
1111
ValidatePrTitle:
1212
name: ValidatePrTitle
13-
runs-on: blacksmith-4vcpu-ubuntu-2404
13+
runs-on: blacksmith-2vcpu-ubuntu-2404
1414
steps:
1515
- name: Validate pull request title
1616
env:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ bun run start -- --no-open
185185
- Auto-installs missing `git` and `node/npm` inside sandbox
186186
- Forwards provider env vars (`OPENAI_*`, `ANTHROPIC_*`, `XAI_*`, `OPENROUTER_*`, `ZHIPU_*`, `MINIMAX_*`, etc.)
187187
- Syncs local OpenCode config files from `~/.config/opencode` when present
188+
- Uses a fixed Daytona lifecycle policy: auto-stop after 15 minutes, auto-archive after 30 minutes, auto-delete disabled
188189
- Auto-catalogs findings into Obsidian when enabled via `shpit.toml`, with optional automatic `ob sync` in headless mode
189190

190191
### Examples

src/analyze-repos.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ type CliOptions = {
2222
urls: string[];
2323
};
2424

25+
const SANDBOX_LIFECYCLE_POLICY = {
26+
autoStopInterval: 15,
27+
autoArchiveInterval: 30,
28+
autoDeleteInterval: -1,
29+
} as const;
30+
2531
type DaytonaCompatClient = {
2632
configApi: {
2733
configControllerGetConfig: () => Promise<{
@@ -615,14 +621,16 @@ async function analyzeOneRepo(params: {
615621
const sandboxName = sanitizeSlug(
616622
`audit-${slug}-${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}`,
617623
).slice(0, 63);
618-
sandbox = await daytona.create(
619-
{
620-
name: sandboxName,
621-
language: "typescript",
622-
autoStopInterval: 0,
623-
},
624-
{ timeout: options.createTimeoutSec },
625-
);
624+
625+
const createParams = {
626+
name: sandboxName,
627+
language: "typescript",
628+
autoStopInterval: SANDBOX_LIFECYCLE_POLICY.autoStopInterval,
629+
autoArchiveInterval: SANDBOX_LIFECYCLE_POLICY.autoArchiveInterval,
630+
autoDeleteInterval: SANDBOX_LIFECYCLE_POLICY.autoDeleteInterval,
631+
};
632+
633+
sandbox = await daytona.create(createParams, { timeout: options.createTimeoutSec });
626634
console.log(`[analyze] (${runPrefix}) Sandbox ready: ${sandbox.id}`);
627635

628636
const userHome = (await sandbox.getUserHomeDir()) ?? "/home/daytona";

src/start-opencode-daytona.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ type CliOptions = {
1717
openUi: boolean;
1818
};
1919

20+
const SANDBOX_LIFECYCLE_POLICY = {
21+
autoStopInterval: 15,
22+
autoArchiveInterval: 30,
23+
autoDeleteInterval: -1,
24+
} as const;
25+
2026
type LogCursor = { value: string };
2127
type DaytonaCompatClient = {
2228
configApi: {
@@ -410,14 +416,15 @@ async function main(): Promise<void> {
410416

411417
try {
412418
console.log("[local] Creating Daytona sandbox...");
413-
sandbox = await daytona.create(
414-
{
415-
name: options.sandboxName,
416-
language: "typescript",
417-
autoStopInterval: 0,
418-
},
419-
{ timeout: options.createTimeoutSec },
420-
);
419+
const createParams = {
420+
name: options.sandboxName,
421+
language: "typescript",
422+
autoStopInterval: SANDBOX_LIFECYCLE_POLICY.autoStopInterval,
423+
autoArchiveInterval: SANDBOX_LIFECYCLE_POLICY.autoArchiveInterval,
424+
autoDeleteInterval: SANDBOX_LIFECYCLE_POLICY.autoDeleteInterval,
425+
};
426+
427+
sandbox = await daytona.create(createParams, { timeout: options.createTimeoutSec });
421428
console.log(`[local] Sandbox ready: ${sandbox.id}`);
422429

423430
const userHome = (await sandbox.getUserHomeDir()) ?? "/home/daytona";

0 commit comments

Comments
 (0)