u-foo 3.1.2 → 3.1.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "u-foo",
3
- "version": "3.1.2",
3
+ "version": "3.1.3",
4
4
  "description": "Multi-Agent Workspace Protocol. Just add u. claude → uclaude, codex → ucodex.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "homepage": "https://ufoo.dev",
@@ -45,7 +45,7 @@
45
45
  ],
46
46
  "type": "commonjs",
47
47
  "engines": {
48
- "node": ">=18"
48
+ "node": ">=18.17"
49
49
  },
50
50
  "scripts": {
51
51
  "postinstall": "node scripts/postinstall.js",
@@ -65,6 +65,7 @@
65
65
  "commander": "^13.1.0",
66
66
  "gray-matter": "^4.0.3",
67
67
  "node-pty": "^1.1.0",
68
+ "undici": "^6.28.0",
68
69
  "ws": "^8.19.0"
69
70
  },
70
71
  "devDependencies": {
@@ -1,5 +1,6 @@
1
1
  const os = require("os");
2
2
  const { randomUUID } = require("crypto");
3
+ const { Agent: UndiciAgent } = require("undici");
3
4
  const { loadConfig, defaultAgentModelForProvider, sameModelProvider } = require("../config");
4
5
  const {
5
6
  readKimiAccessToken,
@@ -115,6 +116,14 @@ const DEFAULT_MAX_NATIVE_TOOL_CALLS = 100;
115
116
  const DEFAULT_MAX_NATIVE_TOOL_ERRORS = 20;
116
117
  const MAX_EMPTY_TERMINAL_RETRIES = 2;
117
118
  const DEFAULT_NATIVE_TIMEOUT_MS = 43200000; // 12 hours
119
+ // Node's fetch is backed by Undici, whose default headers/body idle timeout is
120
+ // 300 seconds. Reasoning providers can legitimately stay silent longer than
121
+ // that between SSE chunks, so leave the absolute deadline to our existing
122
+ // AbortController instead of inheriting Undici's shorter hidden deadline.
123
+ const NATIVE_SSE_DISPATCHER_OPTIONS = Object.freeze({
124
+ headersTimeout: 0,
125
+ bodyTimeout: 0,
126
+ });
118
127
  /** Max text-only auto-continues while a plan is waiting on a task (per user submit). */
119
128
  const DEFAULT_MAX_PLAN_AUTO_CONTINUES = 24;
120
129
  // Anthropic Messages rejects max_tokens above the model's real cap (64K on
@@ -141,6 +150,40 @@ function normalizeTimeoutMs(value) {
141
150
  return Math.max(1000, Math.floor(parsed));
142
151
  }
143
152
 
153
+ let nativeSseDispatcher = null;
154
+
155
+ function createNativeSseDispatcher() {
156
+ return new UndiciAgent({ ...NATIVE_SSE_DISPATCHER_OPTIONS });
157
+ }
158
+
159
+ function getNativeSseDispatcher() {
160
+ if (!nativeSseDispatcher || nativeSseDispatcher.destroyed) {
161
+ nativeSseDispatcher = createNativeSseDispatcher();
162
+ }
163
+ return nativeSseDispatcher;
164
+ }
165
+
166
+ function enrichProviderTransportError(err) {
167
+ if (!err || typeof err !== "object") return err;
168
+
169
+ const cause = err.cause && typeof err.cause === "object" ? err.cause : null;
170
+ const code = String((cause && cause.code) || err.code || "").trim();
171
+ const causeMessage = String((cause && cause.message) || "").trim();
172
+ if (!code && !causeMessage) return err;
173
+
174
+ const message = String(err.message || "provider transport failed").trim();
175
+ const details = [code, causeMessage]
176
+ .filter(Boolean)
177
+ .filter((value, index, values) => values.indexOf(value) === index)
178
+ .join(": ");
179
+ if (!details || message.includes(details)) return err;
180
+
181
+ const enriched = new Error(`${message} (${details})`);
182
+ enriched.code = code || err.code;
183
+ enriched.cause = err;
184
+ return enriched;
185
+ }
186
+
144
187
  function normalizePositiveInt(value, fallback) {
145
188
  const parsed = Number.parseInt(String(value || ""), 10);
146
189
  if (!Number.isFinite(parsed) || parsed <= 0) return fallback;
@@ -1216,6 +1259,7 @@ async function runSseRequest({
1216
1259
  headers,
1217
1260
  body: JSON.stringify(payload),
1218
1261
  signal: request.signal,
1262
+ dispatcher: getNativeSseDispatcher(),
1219
1263
  });
1220
1264
 
1221
1265
  if (!response.ok) {
@@ -1275,7 +1319,7 @@ async function runSseRequest({
1275
1319
  cancelError.code = "cancelled";
1276
1320
  throw cancelError;
1277
1321
  }
1278
- throw err;
1322
+ throw enrichProviderTransportError(err);
1279
1323
  } finally {
1280
1324
  request.cleanup();
1281
1325
  }
@@ -2847,6 +2891,7 @@ module.exports = {
2847
2891
  resolveTransport,
2848
2892
  resolveThinkingBudgetTokens,
2849
2893
  resolveReasoningEffort,
2894
+ createNativeSseDispatcher,
2850
2895
  buildCoreToolSpecs,
2851
2896
  buildAnthropicToolSpecs,
2852
2897
  };