vasanthfeb13 commited on
Commit
ac2dd8c
·
1 Parent(s): 9bdbcd1

Fix: Add node_id routing to commands/execute + update UI to use it

Browse files
src/nacc_orchestrator/server.py CHANGED
@@ -21,6 +21,7 @@ class ListFilesPayload(BaseModel):
21
  class CommandPayload(BaseModel):
22
  description: str = Field(..., description="Human-readable summary of the command")
23
  command: list[str] | str
 
24
  preferred_tags: list[str] | None = None
25
  parallelism: int = Field(default=1, ge=1, le=8)
26
  timeout: float | None = Field(default=None, gt=0.0, le=600.0)
@@ -83,15 +84,28 @@ def create_app(service: OrchestratorService) -> FastAPI:
83
 
84
  @app.post("/commands/execute")
85
  def execute_command(payload: CommandPayload) -> dict[str, object]:
86
- return service.execute_command(
87
- description=payload.description,
88
- command=payload.command,
89
- preferred_tags=payload.preferred_tags,
90
- parallelism=payload.parallelism,
91
- timeout=payload.timeout,
92
- cwd=payload.cwd,
93
- env=payload.env,
94
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
95
 
96
  @app.post("/sync")
97
  def sync(payload: SyncPayload) -> dict[str, object]:
 
21
  class CommandPayload(BaseModel):
22
  description: str = Field(..., description="Human-readable summary of the command")
23
  command: list[str] | str
24
+ node_id: str | None = None # NEW: Specific node to execute on
25
  preferred_tags: list[str] | None = None
26
  parallelism: int = Field(default=1, ge=1, le=8)
27
  timeout: float | None = Field(default=None, gt=0.0, le=600.0)
 
84
 
85
  @app.post("/commands/execute")
86
  def execute_command(payload: CommandPayload) -> dict[str, object]:
87
+ # If node_id is specified, use it directly; otherwise use tags
88
+ if payload.node_id:
89
+ # Execute on specific node
90
+ return service.execute_command_on_node(
91
+ node_id=payload.node_id,
92
+ description=payload.description,
93
+ command=payload.command,
94
+ timeout=payload.timeout,
95
+ cwd=payload.cwd,
96
+ env=payload.env,
97
+ )
98
+ else:
99
+ # Use legacy tag-based routing
100
+ return service.execute_command(
101
+ description=payload.description,
102
+ command=payload.command,
103
+ preferred_tags=payload.preferred_tags,
104
+ parallelism=payload.parallelism,
105
+ timeout=payload.timeout,
106
+ cwd=payload.cwd,
107
+ env=payload.env,
108
+ )
109
 
110
  @app.post("/sync")
111
  def sync(payload: SyncPayload) -> dict[str, object]:
src/nacc_ui/professional_ui_v2.py CHANGED
@@ -163,8 +163,6 @@ class ModernNACCUI(NACCConversationUI):
163
  # No fallback to avoid breaking context switching
164
 
165
  try:
166
- # Determine preferred tags based on node
167
- preferred_tags = ["mac", "local"] if node == "macbook-local" else ["kali", "vm"]
168
  # Get node display name dynamically
169
  try:
170
  node_info = requests.get(f"{ORCHESTRATOR_URL}/nodes/{node}", timeout=5).json()
@@ -172,16 +170,16 @@ class ModernNACCUI(NACCConversationUI):
172
  except:
173
  node_label = node
174
 
175
- # Use orchestrator's execute command endpoint
176
  response = requests.post(
177
  f"{ORCHESTRATOR_URL}/commands/execute",
178
  json={
179
  "description": f"List files in {path} on {node}",
180
  "command": ["ls", "-lah", path],
181
- "preferred_tags": preferred_tags,
182
- "timeout": 30
183
  },
184
- timeout=60 # Increased from 15s to 60s
185
  )
186
 
187
  if response.status_code == 200:
 
163
  # No fallback to avoid breaking context switching
164
 
165
  try:
 
 
166
  # Get node display name dynamically
167
  try:
168
  node_info = requests.get(f"{ORCHESTRATOR_URL}/nodes/{node}", timeout=5).json()
 
170
  except:
171
  node_label = node
172
 
173
+ # Use orchestrator's execute command endpoint WITH node_id
174
  response = requests.post(
175
  f"{ORCHESTRATOR_URL}/commands/execute",
176
  json={
177
  "description": f"List files in {path} on {node}",
178
  "command": ["ls", "-lah", path],
179
+ "node_id": node, # Direct node routing!
180
+ "timeout": 10.0
181
  },
182
+ timeout=12
183
  )
184
 
185
  if response.status_code == 200: