@tiens.nguyen/gonext-local-worker 1.0.239 → 1.0.240

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.
@@ -1830,6 +1830,32 @@ async function runAgentChatJob(job) {
1830
1830
  (process.env.GONEXT_PROBE_PYTHON ?? process.env.GONEXT_MLX_LM_PYTHON ?? "")
1831
1831
  .trim() || "python3";
1832
1832
  const scriptPath = join(WORKER_DIR, "gonext_agent_chat.py");
1833
+
1834
+ // Workspace scope depends on WHERE the job came from (task #75). The `gonext`
1835
+ // terminal always sends its launch cwd as activeWorkspace; the web app never does —
1836
+ // that's the discriminator.
1837
+ // • Terminal: the real `gonext-local-worker workspace add` registry + that cwd.
1838
+ // • Web agent chat: ONE isolated temp scratch folder — NOT the Mac's registered
1839
+ // project folders. Inheriting them leaked their paths into the web prompt and
1840
+ // let terminal state drive web routing. run_command stays off (not a code repo).
1841
+ const terminalActiveWs = String(payload?.activeWorkspace ?? "").trim();
1842
+ let jobWorkspaces;
1843
+ let jobActiveWorkspace;
1844
+ if (terminalActiveWs) {
1845
+ jobWorkspaces = await readFile(join(homedir(), ".gonext", "workspaces.json"), "utf8")
1846
+ .then((raw) => {
1847
+ const parsed = JSON.parse(raw);
1848
+ return Array.isArray(parsed?.workspaces) ? parsed.workspaces : [];
1849
+ })
1850
+ .catch(() => []);
1851
+ jobActiveWorkspace = terminalActiveWs;
1852
+ } else {
1853
+ const webWork = join(homedir(), ".gonext", "web-agent-work");
1854
+ await mkdir(webWork, { recursive: true }).catch(() => {});
1855
+ jobWorkspaces = [{ name: "web", path: webWork, allowRun: false }];
1856
+ jobActiveWorkspace = webWork;
1857
+ }
1858
+
1833
1859
  const input = JSON.stringify({
1834
1860
  messages: payload?.messages ?? [],
1835
1861
  agentBaseURL: payload?.agentBaseURL ?? "",
@@ -1889,17 +1915,12 @@ async function runAgentChatJob(job) {
1889
1915
  ragEmbedModel: payload?.ragEmbedModel ?? "",
1890
1916
  ragEmbedUrl: payload?.ragEmbedUrl ?? "",
1891
1917
  ragTopK: payload?.ragTopK ?? 6,
1892
- // Workspaces the agent may read/edit/test code in read fresh each job so a
1893
- // `gonext-local-worker workspace add` applies without restarting the worker.
1894
- workspaces: await readFile(join(homedir(), ".gonext", "workspaces.json"), "utf8")
1895
- .then((raw) => {
1896
- const parsed = JSON.parse(raw);
1897
- return Array.isArray(parsed?.workspaces) ? parsed.workspaces : [];
1898
- })
1899
- .catch(() => []),
1900
- // The `gonext` terminal REPL's launch folder — download_file/unzip_file output
1901
- // lands here (must be a registered workspace; the python side re-validates).
1902
- activeWorkspace: payload?.activeWorkspace ?? "",
1918
+ // Workspaces the agent may read/edit/test code in (see the terminal-vs-web split
1919
+ // computed above): the real registry for the terminal, a lone temp folder for web.
1920
+ workspaces: jobWorkspaces,
1921
+ // download_file/unzip_file output lands here (a registered workspace; python
1922
+ // re-validates). Terminal = its launch cwd; web = the temp scratch folder.
1923
+ activeWorkspace: jobActiveWorkspace,
1903
1924
  });
1904
1925
  // 30 min max for an agent run: multi-step ReAct on a 14B/31B with a cold prompt
1905
1926
  // cache — or a remote Ollama box on slow GPU cold-loading a big model — can run
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiens.nguyen/gonext-local-worker",
3
- "version": "1.0.239",
3
+ "version": "1.0.240",
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",