Commit 36ba678
feat: SDK API expansion — computer lifecycle, session listing, and cleanup (#51)
* feat: add listMachineTemplates and getMachineTemplate for template discovery
Adds REST API client for the Factory v0 machine templates endpoint,
enabling SDK users to discover available workspace templates
programmatically without needing the web UI.
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
* fix: improve API schema validation and error reporting
Remove .passthrough() from REST API response schemas — these are terminal
types, not proxied protocol messages, so stripping unknown keys is correct.
Fix getMachineTemplate to report schema parse failures accurately instead
of fabricating a 404. Remove unreachable 204 branch from factoryFetch.
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
* feat: auto-provision ephemeral sandboxes in connectDaemon
connectDaemon() now automatically provisions an e2b sandbox when called
with MachineType.Ephemeral and no sandboxId. The SDK calls
POST /api/workspaces/{workspaceId}/sandbox/create, then connects to the
new sandbox with a default retry budget of 30 (60s) to account for
daemon startup time.
Also adds createSandbox() as a standalone exported function, generalizes
factoryFetch to support POST requests, and makes sandboxId optional on
SDKMachineConfig.Ephemeral.
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
* feat: add session management methods to DaemonSession for parity with DroidSession
Adds 15 methods to DaemonClient and 16 passthrough methods to DaemonSession
(including enterSpecMode convenience wrapper) so daemon-mode users have the
same capabilities as exec-mode users: updateSettings, compactSession,
forkSession, getContextBreakdown, renameSession, getRewindInfo, executeRewind,
addMcpServer, removeMcpServer, toggleMcpServer, listMcpServers, listMcpTools,
authenticateMcpServer, listSkills, and enterSpecMode.
Also adds ContextBreakdownResultSchema for the daemon's get_context_breakdown
response (richer than exec-mode's get_context_stats).
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
* feat: add listComputers and getComputer for computer discovery
Wraps GET /api/v0/computers and GET /api/v0/computers/{computerId} so SDK
users can discover their registered computers programmatically, matching
the existing listMachineTemplates/getMachineTemplate pattern.
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
* feat: add computer lifecycle methods, remove non-functional sandbox methods
Add 8 computer lifecycle functions (createComputer, getComputerByName,
updateComputer, deleteComputer, restartComputer, refreshComputer,
getComputerMetrics, retryInstallDeps) with full schemas, types, and tests.
Extend factoryFetch to support PATCH, DELETE, and 204 No Content responses.
Remove createSandbox, downloadSandboxFiles, restartSandbox and associated
auto-provisioning logic — these endpoints use non-v0 auth that rejects API
keys, and the sandbox infrastructure is being deprecated.
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
* feat: add remote session listing to listSessions
Extend listSessions to fetch sessions from the Factory API when an apiKey
is provided, with optional computerId filter and cursor-based pagination.
Local file-based listing is unchanged when apiKey is omitted.
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
* refactor: remove MachineType.Ephemeral
Ephemeral sandbox infrastructure is being deprecated and the endpoints
never accepted Factory API keys. Remove the Ephemeral machine type,
its URL resolution, and associated tests. The SDK now supports Local
and Computer machine types only.
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
* style: fix prettier formatting
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
* refactor: simplify API layer and separate local/remote session listing
- Extract parseResponse helper to deduplicate 11 safeParse+throw blocks in api.ts
- Extract FactoryApiOptions/ComputerApiOptions base interfaces in api-types.ts
- Export listRemoteSessions and related types from public API
- Remove remote API branch from listSessions() to keep it local-only
- Clean up ListSessionsOptions to remove mixed local/remote fields
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
---------
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>1 parent 1c1a37b commit 36ba678
14 files changed
Lines changed: 2718 additions & 45 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
0 commit comments