@tiens.nguyen/gonext-local-worker 1.0.77 → 1.0.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -268,17 +268,22 @@ def run_agent_chat(cfg):
268
268
  # Prepend explicit tool instructions so small models use http_request correctly
269
269
  # and always terminate with final_answer() rather than looping forever.
270
270
  tool_hint = (
271
- "You have ONE built-in function: `http_request(method, url, headers='', body='')`. "
272
- "It returns a STRING with the HTTP status and body. "
273
- "Call it, then immediately call `final_answer(response)` inside the same code block.\n"
271
+ "You have ONE built-in function:\n"
272
+ " `http_request(method, url, headers='', body='', username='', password='')`\n"
273
+ "RETURN FORMAT: the function returns a string like:\n"
274
+ " 'HTTP 200\\n{\"key\": \"value\"}'\n"
275
+ " First line is 'HTTP <code>' (e.g. 'HTTP 200'). Body follows after the first newline.\n"
276
+ "CORRECT USAGE — always just pass response directly to final_answer:\n"
277
+ " response = http_request('GET', url)\n"
278
+ " final_answer(response)\n"
279
+ "Do NOT try to parse or split the response string.\n"
274
280
  "IMPORTANT RULES:\n"
275
- "- `headers` must be a JSON string, e.g. headers='{\"Content-Type\": \"application/json\"}'\n"
276
- "- For Basic Auth: import base64; "
277
- "creds = base64.b64encode(b'user:password').decode(); "
278
- "headers = '{\"Authorization\": \"Basic ' + creds + '\"}'\n"
279
- "- For Bearer token: headers='{\"Authorization\": \"Bearer YOUR_TOKEN\"}'\n"
280
- "- Python's `datetime` and `base64` modules are available.\n"
281
- "- If http_request returns an error starting with 'Error:', do NOT retry the same URL. Try a different one.\n"
281
+ "- If you get HTTP 2xx (200, 201, etc.) in the first line, the request SUCCEEDED. "
282
+ "Call final_answer immediately do NOT retry.\n"
283
+ "- For Basic Auth: username= and password= params handle encoding automatically.\n"
284
+ "- For Bearer token: headers='{\"Authorization\": \"Bearer TOKEN\"}'\n"
285
+ "- If http_request returns an error (starts with 'Error:'), try a different URL.\n"
286
+ "- Python's `datetime` module is available for date/time tasks.\n"
282
287
  "- Do NOT put final_answer outside the code block.\n\n"
283
288
  )
284
289
  task_with_hint = tool_hint + "Task: " + task_text
@@ -287,7 +292,8 @@ def run_agent_chat(cfg):
287
292
  _failed_urls: set = set()
288
293
 
289
294
  @tool
290
- def http_request(method: str, url: str, headers: str = "", body: str = "") -> str:
295
+ def http_request(method: str, url: str, headers: str = "", body: str = "",
296
+ username: str = "", password: str = "") -> str:
291
297
  """Perform an HTTP request and return the status code and body preview.
292
298
 
293
299
  Args:
@@ -295,11 +301,18 @@ def run_agent_chat(cfg):
295
301
  url: Full URL to request
296
302
  headers: Optional JSON object string of request headers
297
303
  body: Optional request body string
304
+ username: Username for Basic Authentication (avoids manual base64 encoding)
305
+ password: Password for Basic Authentication
298
306
  """
307
+ import base64 as _b64
299
308
  parsed_headers = {}
309
+ # Basic Auth: encode credentials automatically if provided.
310
+ if username or password:
311
+ creds = _b64.b64encode(f"{username}:{password}".encode()).decode()
312
+ parsed_headers["Authorization"] = f"Basic {creds}"
300
313
  if headers:
301
314
  try:
302
- parsed_headers = json.loads(headers)
315
+ parsed_headers.update(json.loads(headers))
303
316
  except Exception: # noqa: BLE001
304
317
  pass
305
318
  url_key = f"{method.upper()}:{url}"
@@ -322,6 +335,9 @@ def run_agent_chat(cfg):
322
335
  "Try a DIFFERENT URL or use Python's datetime/math/etc. module instead."
323
336
  )
324
337
  status_line = result.split("\n")[0][:150] if result else "no response"
338
+ # Append a success tag to 2xx responses so the model knows to stop and call final_answer.
339
+ if result and result.startswith("HTTP 2"):
340
+ result = result + "\n[SUCCESS — call final_answer(response) now, do not parse or retry]"
325
341
  _emit({"type": "step", "text": f"HTTP {method.upper()} {url} → {status_line}"})
326
342
  _log(f"http_request {method.upper()} {url} → {result[:80]}")
327
343
  return result
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiens.nguyen/gonext-local-worker",
3
- "version": "1.0.77",
3
+ "version": "1.0.78",
4
4
  "description": "Polls GoNext cloud API for async local LLM jobs and runs them against Ollama/OpenAI-compatible servers on this Mac",
5
5
  "type": "module",
6
6
  "license": "MIT",