@tiens.nguyen/gonext-local-worker 1.0.15 → 1.0.19

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.
@@ -101,6 +101,11 @@ if (!apiBase || !workerKey) {
101
101
  process.exit(1);
102
102
  }
103
103
 
104
+ const CHUNK_PATH = "/api/worker/job-chunk";
105
+ console.log(
106
+ `[gonext-worker] API base ${apiBase} — streaming chunks POST ${apiBase}${CHUNK_PATH}`
107
+ );
108
+
104
109
  function toOpenAIMessages(messages) {
105
110
  return (Array.isArray(messages) ? messages : []).map((m) => {
106
111
  if (m.role === "user" && m.attachments?.length) {
@@ -135,10 +140,16 @@ async function runChatJob(job) {
135
140
  throw new Error("Invalid chat payload: messages array is missing.");
136
141
  }
137
142
  const start = Date.now();
138
- await workerFetch(`/api/worker/jobs/${jobId}`, {
143
+ const runRes = await workerFetch(`/api/worker/jobs/${jobId}`, {
139
144
  method: "PATCH",
140
145
  body: JSON.stringify({ jobStatus: "running" }),
141
146
  });
147
+ if (!runRes.ok) {
148
+ const errBody = await runRes.text().catch(() => "");
149
+ throw new Error(
150
+ `mark running failed ${runRes.status}${errBody ? `: ${errBody}` : ""}`
151
+ );
152
+ }
142
153
 
143
154
  const client = new OpenAI({
144
155
  baseURL: payload.baseURL,
@@ -154,12 +165,22 @@ async function runChatJob(job) {
154
165
  const t = buf;
155
166
  buf = "";
156
167
  if (!t) return;
157
- const res = await workerFetch(`/api/worker/jobs/${jobId}/chunk`, {
168
+ const res = await workerFetch(CHUNK_PATH, {
158
169
  method: "POST",
159
- body: JSON.stringify({ text: t }),
170
+ body: JSON.stringify({ jobId, text: t }),
160
171
  });
161
172
  if (!res.ok && res.status !== 204) {
162
- console.error(`[gonext-worker] chunk POST failed ${res.status} for ${jobId}`);
173
+ const snippet = (await res.text().catch(() => "")).trim().slice(0, 400);
174
+ const url = `${apiBase}${CHUNK_PATH}`;
175
+ console.error(
176
+ `[gonext-worker] job-chunk POST failed status=${res.status} url=${url} jobId=${jobId}` +
177
+ (snippet ? ` response=${snippet}` : "")
178
+ );
179
+ if (res.status === 404) {
180
+ console.error(
181
+ "[gonext-worker] hint: 404 usually means (a) API not redeployed with POST /api/worker/job-chunk, or (b) response JSON {\"error\":\"Job not found\"} = Dynamo lookup failed (wrong worker key user vs job owner)."
182
+ );
183
+ }
163
184
  }
164
185
  };
165
186
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiens.nguyen/gonext-local-worker",
3
- "version": "1.0.15",
3
+ "version": "1.0.19",
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",