@atolis-hq/wake 0.3.57 → 0.3.58
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/src/bootstrap/initialise.js +2 -0
- package/dist/src/bootstrap/version.js +1 -1
- package/dist/src/execution/application/execution-service.js +11 -8
- package/dist/src/execution/contracts/config.js +1 -0
- package/dist/src/persistence/application/projection-runner.js +16 -1
- package/package.json +1 -1
|
@@ -33,6 +33,8 @@ execution:
|
|
|
33
33
|
standard: [fake]
|
|
34
34
|
deep: [fake]
|
|
35
35
|
defaultRunnerPool: standard
|
|
36
|
+
# A resumed agent session must have complete durable usage under this limit.
|
|
37
|
+
maxResumableSessionTokens: 200000
|
|
36
38
|
|
|
37
39
|
# Tick dispatch cap and resident-loop idle backoff; the built-in defaults
|
|
38
40
|
# are fine for a first run.
|
|
@@ -39,7 +39,7 @@ async function attemptExecution(runtime, activation, context) {
|
|
|
39
39
|
stage: activation.stage,
|
|
40
40
|
...(context.sessionPolicy === undefined ? {} : { policy: context.sessionPolicy }),
|
|
41
41
|
};
|
|
42
|
-
const resume = resumeContextFor(resumeCandidates, runner, resumeScope);
|
|
42
|
+
const resume = resumeContextFor(resumeCandidates, runner, resumeScope, runtime.config.maxResumableSessionTokens ?? 200_000);
|
|
43
43
|
const existing = existingRun(prior, runtime.dependencies.clock, owner);
|
|
44
44
|
if (existing !== undefined)
|
|
45
45
|
return existing;
|
|
@@ -233,19 +233,22 @@ async function releasePreStartResources(runtime, activation, currentRunId, lease
|
|
|
233
233
|
export function resumeSessionIdFor(prior, cli, scope, runnerName) {
|
|
234
234
|
return resumeRunFor(prior, cli, runnerName, scope)?.agent?.metadata.sessionId;
|
|
235
235
|
}
|
|
236
|
-
function resumeContextFor(candidates, runner, scope) {
|
|
236
|
+
function resumeContextFor(candidates, runner, scope, maximumTokens = 200_000) {
|
|
237
237
|
if (runner.supportsSessionResume !== true)
|
|
238
238
|
return {};
|
|
239
239
|
const resumedRun = resumeRunFor(candidates, runner.cli, runner.name, scope);
|
|
240
240
|
const sessionId = resumedRun?.agent?.metadata.sessionId;
|
|
241
|
+
const usageBaseline = sessionId === undefined
|
|
242
|
+
? undefined
|
|
243
|
+
: usageBaselineFor(candidates, runner.cli, sessionId, scope, runner.name);
|
|
244
|
+
if (sessionId === undefined ||
|
|
245
|
+
usageBaseline === undefined ||
|
|
246
|
+
usageBaseline.input + usageBaseline.output > maximumTokens)
|
|
247
|
+
return {};
|
|
241
248
|
return {
|
|
242
|
-
|
|
249
|
+
sessionId,
|
|
243
250
|
...(resumedRun?.startedAt === undefined ? {} : { startedAt: resumedRun.startedAt }),
|
|
244
|
-
|
|
245
|
-
? {}
|
|
246
|
-
: {
|
|
247
|
-
usageBaseline: usageBaselineFor(candidates, runner.cli, sessionId, scope, runner.name),
|
|
248
|
-
}),
|
|
251
|
+
usageBaseline,
|
|
249
252
|
};
|
|
250
253
|
}
|
|
251
254
|
function resumeRunFor(prior, cli, runnerName, scope) {
|
|
@@ -31,5 +31,6 @@ export const executionConfigSchema = z
|
|
|
31
31
|
leaseDurationMs: z.number().int().positive().optional(),
|
|
32
32
|
leaseRenewalIntervalMs: z.number().int().positive().optional(),
|
|
33
33
|
maxAmbiguityReconciliationAttempts: z.number().int().positive().optional(),
|
|
34
|
+
maxResumableSessionTokens: z.number().int().positive().default(200_000),
|
|
34
35
|
})
|
|
35
36
|
.strict();
|
|
@@ -39,7 +39,22 @@ export class ProjectionRunner {
|
|
|
39
39
|
if (this.caughtUpToGlobalPosition !== undefined &&
|
|
40
40
|
latestGlobalPosition <= this.caughtUpToGlobalPosition)
|
|
41
41
|
return 0;
|
|
42
|
-
|
|
42
|
+
let failed = false;
|
|
43
|
+
let firstFailure;
|
|
44
|
+
const counts = await Promise.all(this.registered.map(async (definition) => {
|
|
45
|
+
try {
|
|
46
|
+
return await this.applyFrom(definition, allEvents, limit);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (!failed) {
|
|
50
|
+
failed = true;
|
|
51
|
+
firstFailure = error;
|
|
52
|
+
}
|
|
53
|
+
return 0;
|
|
54
|
+
}
|
|
55
|
+
}));
|
|
56
|
+
if (failed)
|
|
57
|
+
throw firstFailure;
|
|
43
58
|
if (counts.every((count) => count < limit))
|
|
44
59
|
this.caughtUpToGlobalPosition = latestGlobalPosition;
|
|
45
60
|
return counts.reduce((total, count) => total + count, 0);
|