@odla-ai/harness 0.11.0 → 0.11.1
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/dist/{chunk-IXYKIPRA.js → chunk-DP6LOGBF.js} +61 -43
- package/dist/chunk-DP6LOGBF.js.map +1 -0
- package/dist/code-runtime-cli.cjs +59 -41
- package/dist/code-runtime-cli.cjs.map +1 -1
- package/dist/code-runtime-cli.js +1 -1
- package/dist/node.cjs +59 -41
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +20 -13
- package/dist/node.d.ts +20 -13
- package/dist/node.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-IXYKIPRA.js.map +0 -1
package/dist/code-runtime-cli.js
CHANGED
package/dist/node.cjs
CHANGED
|
@@ -1321,40 +1321,40 @@ async function readBoundedResponse(body, maximum) {
|
|
|
1321
1321
|
return result;
|
|
1322
1322
|
}
|
|
1323
1323
|
|
|
1324
|
-
// src/code-runtime.ts
|
|
1325
|
-
var
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
if (!
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1324
|
+
// src/code-runtime-overload.ts
|
|
1325
|
+
var OVERLOAD_RETRY_DELAYS_MS = [2e3, 4e3, 8e3, 16e3];
|
|
1326
|
+
var RETRYABLE_CODES = /* @__PURE__ */ new Set(["control_plane_overloaded", "registry_overloaded", "transport_unavailable"]);
|
|
1327
|
+
function overloadedControlFailure(cause) {
|
|
1328
|
+
if (!cause || typeof cause !== "object") return false;
|
|
1329
|
+
const failure = cause;
|
|
1330
|
+
return failure.status === 503 && typeof failure.code === "string" && RETRYABLE_CODES.has(failure.code);
|
|
1331
|
+
}
|
|
1332
|
+
async function withOverloadRetry(call, wait2, onRetry = () => void 0) {
|
|
1333
|
+
for (let attempt = 0; ; attempt += 1) {
|
|
1334
1334
|
try {
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
if (
|
|
1339
|
-
await
|
|
1340
|
-
|
|
1341
|
-
if (options.signal?.aborted) return;
|
|
1342
|
-
if (options.once || !retryableControlFailure(error)) throw error;
|
|
1343
|
-
await options.onRetry?.(error, retryMs);
|
|
1344
|
-
await wait(retryMs, options.signal);
|
|
1345
|
-
retryMs = Math.min(retryMs * 2, 3e4);
|
|
1335
|
+
return await call();
|
|
1336
|
+
} catch (cause) {
|
|
1337
|
+
const delayMs = OVERLOAD_RETRY_DELAYS_MS[attempt];
|
|
1338
|
+
if (delayMs === void 0 || !overloadedControlFailure(cause)) throw cause;
|
|
1339
|
+
await onRetry(cause, delayMs);
|
|
1340
|
+
await wait2(delayMs);
|
|
1346
1341
|
}
|
|
1347
|
-
}
|
|
1342
|
+
}
|
|
1348
1343
|
}
|
|
1344
|
+
|
|
1345
|
+
// src/code-runtime-reconciler.ts
|
|
1346
|
+
var sleep = (ms) => new Promise((resolve8) => setTimeout(resolve8, ms));
|
|
1349
1347
|
var CodeRuntimeReconciler = class {
|
|
1350
|
-
constructor(control, engine, onDiagnostic) {
|
|
1348
|
+
constructor(control, engine, onDiagnostic, options = {}) {
|
|
1351
1349
|
this.control = control;
|
|
1352
1350
|
this.engine = engine;
|
|
1353
1351
|
this.onDiagnostic = onDiagnostic;
|
|
1352
|
+
this.options = options;
|
|
1354
1353
|
}
|
|
1355
1354
|
control;
|
|
1356
1355
|
engine;
|
|
1357
1356
|
onDiagnostic;
|
|
1357
|
+
options;
|
|
1358
1358
|
results = /* @__PURE__ */ new Map();
|
|
1359
1359
|
async reconcile(snapshot) {
|
|
1360
1360
|
for (const command of snapshot.commands) {
|
|
@@ -1373,7 +1373,15 @@ var CodeRuntimeReconciler = class {
|
|
|
1373
1373
|
await this.control.acknowledge(command.commandId, completed.result);
|
|
1374
1374
|
if (!completed.notified) {
|
|
1375
1375
|
try {
|
|
1376
|
-
await
|
|
1376
|
+
await withOverloadRetry(
|
|
1377
|
+
async () => {
|
|
1378
|
+
await this.engine.acknowledged?.(command, completed.result);
|
|
1379
|
+
},
|
|
1380
|
+
(ms) => (this.options.wait ?? sleep)(ms),
|
|
1381
|
+
(cause, delayMs) => this.onDiagnostic?.(
|
|
1382
|
+
`command ${command.commandId} acknowledged handling waits ${delayMs}ms for an overloaded control plane \xB7 ${cause instanceof Error ? cause.message : String(cause)}`
|
|
1383
|
+
)
|
|
1384
|
+
);
|
|
1377
1385
|
} catch (error) {
|
|
1378
1386
|
this.onDiagnostic?.(
|
|
1379
1387
|
`command ${command.commandId} acknowledged handling failed \xB7 ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -1384,6 +1392,32 @@ var CodeRuntimeReconciler = class {
|
|
|
1384
1392
|
}
|
|
1385
1393
|
}
|
|
1386
1394
|
};
|
|
1395
|
+
|
|
1396
|
+
// src/code-runtime.ts
|
|
1397
|
+
var CODE_RUNTIME_PROTOCOL_VERSION = 3;
|
|
1398
|
+
async function runCodeRuntimeHeartbeatLoop(options) {
|
|
1399
|
+
const heartbeatMs = options.heartbeatMs ?? 15e3;
|
|
1400
|
+
if (!Number.isSafeInteger(heartbeatMs) || heartbeatMs < 1e3 || heartbeatMs > 3e5) {
|
|
1401
|
+
throw new TypeError("heartbeatMs must be an integer from 1000 to 300000");
|
|
1402
|
+
}
|
|
1403
|
+
let retryMs = 1e3;
|
|
1404
|
+
do {
|
|
1405
|
+
if (options.signal?.aborted) return;
|
|
1406
|
+
try {
|
|
1407
|
+
const snapshot = await options.control.heartbeat(options.runtimeVersion, options.capabilities);
|
|
1408
|
+
await options.onSnapshot?.(snapshot);
|
|
1409
|
+
retryMs = 1e3;
|
|
1410
|
+
if (options.once) return;
|
|
1411
|
+
await wait(heartbeatMs, options.signal);
|
|
1412
|
+
} catch (error) {
|
|
1413
|
+
if (options.signal?.aborted) return;
|
|
1414
|
+
if (options.once || !retryableControlFailure(error)) throw error;
|
|
1415
|
+
await options.onRetry?.(error, retryMs);
|
|
1416
|
+
await wait(retryMs, options.signal);
|
|
1417
|
+
retryMs = Math.min(retryMs * 2, 3e4);
|
|
1418
|
+
}
|
|
1419
|
+
} while (!options.signal?.aborted);
|
|
1420
|
+
}
|
|
1387
1421
|
function retryableControlFailure(value) {
|
|
1388
1422
|
if (!value || typeof value !== "object") return false;
|
|
1389
1423
|
const failure = value;
|
|
@@ -2978,23 +3012,7 @@ async function sessionSkillsFor(options, command) {
|
|
|
2978
3012
|
}
|
|
2979
3013
|
|
|
2980
3014
|
// src/code-runtime-inference.ts
|
|
2981
|
-
var
|
|
2982
|
-
var RETRYABLE_CODES = /* @__PURE__ */ new Set(["control_plane_overloaded", "registry_overloaded", "transport_unavailable"]);
|
|
2983
|
-
function overloadedControlFailure(cause) {
|
|
2984
|
-
return cause instanceof CodeRuntimeControlError && cause.status === 503 && RETRYABLE_CODES.has(cause.code);
|
|
2985
|
-
}
|
|
2986
|
-
async function inferWithBackoff(infer, wait2, onRetry) {
|
|
2987
|
-
for (let attempt = 0; ; attempt += 1) {
|
|
2988
|
-
try {
|
|
2989
|
-
return await infer();
|
|
2990
|
-
} catch (cause) {
|
|
2991
|
-
const delayMs = OVERLOAD_RETRY_DELAYS_MS[attempt];
|
|
2992
|
-
if (delayMs === void 0 || !overloadedControlFailure(cause)) throw cause;
|
|
2993
|
-
await onRetry(cause, delayMs);
|
|
2994
|
-
await wait2(delayMs);
|
|
2995
|
-
}
|
|
2996
|
-
}
|
|
2997
|
-
}
|
|
3015
|
+
var inferWithBackoff = (infer, wait2, onRetry) => withOverloadRetry(infer, wait2, (cause, delayMs) => onRetry(cause, delayMs));
|
|
2998
3016
|
async function handleCodeRuntimeInference(input) {
|
|
2999
3017
|
const { command, request, state } = input;
|
|
3000
3018
|
const startedAt = Date.now();
|