@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
|
@@ -260,40 +260,40 @@ async function readBoundedResponse(body, maximum) {
|
|
|
260
260
|
return result;
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
-
// src/code-runtime.ts
|
|
264
|
-
var
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
if (!
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
263
|
+
// src/code-runtime-overload.ts
|
|
264
|
+
var OVERLOAD_RETRY_DELAYS_MS = [2e3, 4e3, 8e3, 16e3];
|
|
265
|
+
var RETRYABLE_CODES = /* @__PURE__ */ new Set(["control_plane_overloaded", "registry_overloaded", "transport_unavailable"]);
|
|
266
|
+
function overloadedControlFailure(cause) {
|
|
267
|
+
if (!cause || typeof cause !== "object") return false;
|
|
268
|
+
const failure = cause;
|
|
269
|
+
return failure.status === 503 && typeof failure.code === "string" && RETRYABLE_CODES.has(failure.code);
|
|
270
|
+
}
|
|
271
|
+
async function withOverloadRetry(call, wait2, onRetry = () => void 0) {
|
|
272
|
+
for (let attempt = 0; ; attempt += 1) {
|
|
273
273
|
try {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
if (
|
|
278
|
-
await
|
|
279
|
-
|
|
280
|
-
if (options.signal?.aborted) return;
|
|
281
|
-
if (options.once || !retryableControlFailure(error)) throw error;
|
|
282
|
-
await options.onRetry?.(error, retryMs);
|
|
283
|
-
await wait(retryMs, options.signal);
|
|
284
|
-
retryMs = Math.min(retryMs * 2, 3e4);
|
|
274
|
+
return await call();
|
|
275
|
+
} catch (cause) {
|
|
276
|
+
const delayMs = OVERLOAD_RETRY_DELAYS_MS[attempt];
|
|
277
|
+
if (delayMs === void 0 || !overloadedControlFailure(cause)) throw cause;
|
|
278
|
+
await onRetry(cause, delayMs);
|
|
279
|
+
await wait2(delayMs);
|
|
285
280
|
}
|
|
286
|
-
}
|
|
281
|
+
}
|
|
287
282
|
}
|
|
283
|
+
|
|
284
|
+
// src/code-runtime-reconciler.ts
|
|
285
|
+
var sleep = (ms) => new Promise((resolve6) => setTimeout(resolve6, ms));
|
|
288
286
|
var CodeRuntimeReconciler = class {
|
|
289
|
-
constructor(control, engine, onDiagnostic) {
|
|
287
|
+
constructor(control, engine, onDiagnostic, options = {}) {
|
|
290
288
|
this.control = control;
|
|
291
289
|
this.engine = engine;
|
|
292
290
|
this.onDiagnostic = onDiagnostic;
|
|
291
|
+
this.options = options;
|
|
293
292
|
}
|
|
294
293
|
control;
|
|
295
294
|
engine;
|
|
296
295
|
onDiagnostic;
|
|
296
|
+
options;
|
|
297
297
|
results = /* @__PURE__ */ new Map();
|
|
298
298
|
async reconcile(snapshot) {
|
|
299
299
|
for (const command of snapshot.commands) {
|
|
@@ -312,7 +312,15 @@ var CodeRuntimeReconciler = class {
|
|
|
312
312
|
await this.control.acknowledge(command.commandId, completed.result);
|
|
313
313
|
if (!completed.notified) {
|
|
314
314
|
try {
|
|
315
|
-
await
|
|
315
|
+
await withOverloadRetry(
|
|
316
|
+
async () => {
|
|
317
|
+
await this.engine.acknowledged?.(command, completed.result);
|
|
318
|
+
},
|
|
319
|
+
(ms) => (this.options.wait ?? sleep)(ms),
|
|
320
|
+
(cause, delayMs) => this.onDiagnostic?.(
|
|
321
|
+
`command ${command.commandId} acknowledged handling waits ${delayMs}ms for an overloaded control plane \xB7 ${cause instanceof Error ? cause.message : String(cause)}`
|
|
322
|
+
)
|
|
323
|
+
);
|
|
316
324
|
} catch (error) {
|
|
317
325
|
this.onDiagnostic?.(
|
|
318
326
|
`command ${command.commandId} acknowledged handling failed \xB7 ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -323,6 +331,32 @@ var CodeRuntimeReconciler = class {
|
|
|
323
331
|
}
|
|
324
332
|
}
|
|
325
333
|
};
|
|
334
|
+
|
|
335
|
+
// src/code-runtime.ts
|
|
336
|
+
var CODE_RUNTIME_PROTOCOL_VERSION = 3;
|
|
337
|
+
async function runCodeRuntimeHeartbeatLoop(options) {
|
|
338
|
+
const heartbeatMs = options.heartbeatMs ?? 15e3;
|
|
339
|
+
if (!Number.isSafeInteger(heartbeatMs) || heartbeatMs < 1e3 || heartbeatMs > 3e5) {
|
|
340
|
+
throw new TypeError("heartbeatMs must be an integer from 1000 to 300000");
|
|
341
|
+
}
|
|
342
|
+
let retryMs = 1e3;
|
|
343
|
+
do {
|
|
344
|
+
if (options.signal?.aborted) return;
|
|
345
|
+
try {
|
|
346
|
+
const snapshot = await options.control.heartbeat(options.runtimeVersion, options.capabilities);
|
|
347
|
+
await options.onSnapshot?.(snapshot);
|
|
348
|
+
retryMs = 1e3;
|
|
349
|
+
if (options.once) return;
|
|
350
|
+
await wait(heartbeatMs, options.signal);
|
|
351
|
+
} catch (error) {
|
|
352
|
+
if (options.signal?.aborted) return;
|
|
353
|
+
if (options.once || !retryableControlFailure(error)) throw error;
|
|
354
|
+
await options.onRetry?.(error, retryMs);
|
|
355
|
+
await wait(retryMs, options.signal);
|
|
356
|
+
retryMs = Math.min(retryMs * 2, 3e4);
|
|
357
|
+
}
|
|
358
|
+
} while (!options.signal?.aborted);
|
|
359
|
+
}
|
|
326
360
|
function retryableControlFailure(value) {
|
|
327
361
|
if (!value || typeof value !== "object") return false;
|
|
328
362
|
const failure = value;
|
|
@@ -2119,23 +2153,7 @@ async function sessionSkillsFor(options, command) {
|
|
|
2119
2153
|
}
|
|
2120
2154
|
|
|
2121
2155
|
// src/code-runtime-inference.ts
|
|
2122
|
-
var
|
|
2123
|
-
var RETRYABLE_CODES = /* @__PURE__ */ new Set(["control_plane_overloaded", "registry_overloaded", "transport_unavailable"]);
|
|
2124
|
-
function overloadedControlFailure(cause) {
|
|
2125
|
-
return cause instanceof CodeRuntimeControlError && cause.status === 503 && RETRYABLE_CODES.has(cause.code);
|
|
2126
|
-
}
|
|
2127
|
-
async function inferWithBackoff(infer, wait2, onRetry) {
|
|
2128
|
-
for (let attempt = 0; ; attempt += 1) {
|
|
2129
|
-
try {
|
|
2130
|
-
return await infer();
|
|
2131
|
-
} catch (cause) {
|
|
2132
|
-
const delayMs = OVERLOAD_RETRY_DELAYS_MS[attempt];
|
|
2133
|
-
if (delayMs === void 0 || !overloadedControlFailure(cause)) throw cause;
|
|
2134
|
-
await onRetry(cause, delayMs);
|
|
2135
|
-
await wait2(delayMs);
|
|
2136
|
-
}
|
|
2137
|
-
}
|
|
2138
|
-
}
|
|
2156
|
+
var inferWithBackoff = (infer, wait2, onRetry) => withOverloadRetry(infer, wait2, (cause, delayMs) => onRetry(cause, delayMs));
|
|
2139
2157
|
async function handleCodeRuntimeInference(input) {
|
|
2140
2158
|
const { command, request, state } = input;
|
|
2141
2159
|
const startedAt = Date.now();
|
|
@@ -3799,9 +3817,9 @@ export {
|
|
|
3799
3817
|
digestStagedWorkspace,
|
|
3800
3818
|
CodeRuntimeControlError,
|
|
3801
3819
|
createCodeRuntimeControlClient,
|
|
3820
|
+
CodeRuntimeReconciler,
|
|
3802
3821
|
CODE_RUNTIME_PROTOCOL_VERSION,
|
|
3803
3822
|
runCodeRuntimeHeartbeatLoop,
|
|
3804
|
-
CodeRuntimeReconciler,
|
|
3805
3823
|
stripPatchEnvelope,
|
|
3806
3824
|
applyPatchDialectToDiff,
|
|
3807
3825
|
validateCodePatch,
|
|
@@ -3850,4 +3868,4 @@ export {
|
|
|
3850
3868
|
sessionRecipesFor,
|
|
3851
3869
|
TheseusRuntimeEngine
|
|
3852
3870
|
};
|
|
3853
|
-
//# sourceMappingURL=chunk-
|
|
3871
|
+
//# sourceMappingURL=chunk-DP6LOGBF.js.map
|