Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

feat: add profileId to instance launch API

Mario21bb5d731e30
diff --git a/internal/dashboard/dashboard/profiles.js b/internal/dashboard/dashboard/profiles.js
index ae7c359a..7ec7e7d1 100644
--- a/internal/dashboard/dashboard/profiles.js
+++ b/internal/dashboard/dashboard/profiles.js
@@ -247,11 +247,14 @@ function updateLaunchCommand() {
const port = document.getElementById('launch-port').value.trim();
const headless = !!(document.getElementById('launch-headless') && document.getElementById('launch-headless').checked);
- // Modern API: POST /instances/launch with mode + port
+ // Get profile ID
+ const profileId = profileByName[name] ? profileByName[name].id : '';
+
+ // Modern API: POST /instances/launch with profileId + mode + port
const mode = headless ? 'headless' : 'headed';
const curlCmd = 'curl -X POST http://localhost:9867/instances/launch '
+ '-H "Content-Type: application/json" '
- + '-d \'{\"mode\":\"' + mode + '\",\"port\":\"' + (port || 'auto') + '"}\'';
+ + '-d \'{\"profileId\":\"' + profileId + '\",\"mode\":\"' + mode + '\",\"port\":\"' + (port || 'auto') + '"}\'';
document.getElementById('launch-command').value = curlCmd;
}
@@ -283,6 +286,9 @@ async function doLaunch() {
return;
}
+ // Get profile ID from profileByName map
+ const profileId = profileByName[name] ? profileByName[name].id : '';
+
saveProfilePort(name, port);
setLaunchHeadlessPref(headless);
closeLaunchModal();
@@ -292,6 +298,7 @@ async function doLaunch() {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
+ profileId: profileId,
mode: headless ? 'headless' : 'headed',
port: port
})
diff --git a/internal/orchestrator/handlers.go b/internal/orchestrator/handlers.go
index 7e9a5b74..d5157d84 100644
--- a/internal/orchestrator/handlers.go
+++ b/internal/orchestrator/handlers.go
@@ -142,8 +142,9 @@ func (o *Orchestrator) handleStopByID(w http.ResponseWriter, r *http.Request) {
func (o *Orchestrator) handleLaunchByName(w http.ResponseWriter, r *http.Request) {
var req struct {
- Mode string `json:"mode"` // "headed" or "headless" (default: headless)
- Port string `json:"port,omitempty"`
+ ProfileId string `json:"profileId,omitempty"` // Optional: use existing profile
+ Mode string `json:"mode"` // "headed" or "headless" (default: headless)
+ Port string `json:"port,omitempty"`
}
// Decode body if present (empty body is allowed)
@@ -157,8 +158,27 @@ func (o *Orchestrator) handleLaunchByName(w http.ResponseWriter, r *http.Request
// Default: headless=true unless mode="headed"
headless := req.Mode != "headed"
- // Generate unique instance name (internal use only)
- name := fmt.Sprintf("instance-%d", time.Now().UnixNano())
+ // Determine profile name: use provided profileId or generate temporary name
+ var name string
+ if req.ProfileId != "" {
+ // Look up profile by ID to get its name
+ profs := o.pm.List()
+ found := false
+ for _, p := range profs {
+ if p.Id == req.ProfileId {
+ name = p.Name
+ found = true
+ break
+ }
+ }
+ if !found {
+ web.Error(w, 400, fmt.Errorf("profile %q not found", req.ProfileId))
+ return
+ }
+ } else {
+ // Generate unique temporary instance name (internal use only)
+ name = fmt.Sprintf("instance-%d", time.Now().UnixNano())
+ }
// Port is optional - if not provided, Launch() will auto-allocate
inst, err := o.Launch(name, req.Port, headless)