@robosystems/core 0.13.4 → 0.13.5
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.
|
@@ -64,7 +64,14 @@ const WRITE_LABELS = {
|
|
|
64
64
|
'create-agent': 'Created counterparty',
|
|
65
65
|
'update-agent': 'Updated counterparty',
|
|
66
66
|
remember: 'Saved memory',
|
|
67
|
+
'create-report': 'Created report',
|
|
68
|
+
'update-event-block': 'Classified inbox line',
|
|
69
|
+
// The sweep reports counts, not objects, and may find nothing due.
|
|
70
|
+
'promote-obligations': 'Swept due schedule obligations',
|
|
67
71
|
};
|
|
72
|
+
// The worker gives an operator run 600s. A lock older than this is a stream
|
|
73
|
+
// that dropped without settling, not a run, so it stops refusing requests.
|
|
74
|
+
const RUN_LOCK_MS = 11 * 60 * 1000;
|
|
68
75
|
function describeWrite(write) {
|
|
69
76
|
var _a, _b;
|
|
70
77
|
const label = (_a = WRITE_LABELS[write.operation]) !== null && _a !== void 0 ? _a : write.operation;
|
|
@@ -105,6 +112,10 @@ export function ConsoleContent({ config, variant = 'page', }) {
|
|
|
105
112
|
const hasInitialized = useRef(false);
|
|
106
113
|
const previousGraphId = useRef(null);
|
|
107
114
|
const operatorProgressMessageId = useRef(null);
|
|
115
|
+
// Graphs with an operator run in flight, by when it started. A second
|
|
116
|
+
// request to the same graph is refused: two /do runs writing at once would
|
|
117
|
+
// race each other.
|
|
118
|
+
const runningGraphsRef = useRef(new Map());
|
|
108
119
|
// ── Helpers ──────────────────────────────────────────────────────────
|
|
109
120
|
const getWelcomeMessage = useCallback(() => {
|
|
110
121
|
var _a;
|
|
@@ -359,8 +370,14 @@ export function ConsoleContent({ config, variant = 'page', }) {
|
|
|
359
370
|
addErrorMessage(config.noSelectionError);
|
|
360
371
|
return;
|
|
361
372
|
}
|
|
373
|
+
const runningSince = runningGraphsRef.current.get(graphId);
|
|
374
|
+
if (runningSince !== undefined && Date.now() - runningSince < RUN_LOCK_MS) {
|
|
375
|
+
addErrorMessage('A request is still running on this graph. Wait for it to finish before sending another.');
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
362
378
|
const startTime = Date.now();
|
|
363
379
|
const requestGraphId = graphId;
|
|
380
|
+
runningGraphsRef.current.set(requestGraphId, startTime);
|
|
364
381
|
const requestEpoch = graphEpochRef.current;
|
|
365
382
|
const isStale = () => currentGraphRef.current !== requestGraphId ||
|
|
366
383
|
graphEpochRef.current !== requestEpoch;
|
|
@@ -460,6 +477,14 @@ export function ConsoleContent({ config, variant = 'page', }) {
|
|
|
460
477
|
if (creditsUsed != null && Number(creditsUsed) > 0) {
|
|
461
478
|
footer += `\nCredits used: ${Number(creditsUsed).toFixed(1)}`;
|
|
462
479
|
}
|
|
480
|
+
// A run cut short still answers, so say it stopped early.
|
|
481
|
+
if (metadata.hit_credit_ceiling) {
|
|
482
|
+
footer +=
|
|
483
|
+
'\nStopped at the credit limit for this request; the work may be incomplete';
|
|
484
|
+
}
|
|
485
|
+
else if (metadata.hit_step_limit) {
|
|
486
|
+
footer += '\nStopped at the step limit; the work may be incomplete';
|
|
487
|
+
}
|
|
463
488
|
// Natural-language answers come back as enriched markdown, so render them
|
|
464
489
|
// as such and keep the query-stats footer separate (its line breaks would
|
|
465
490
|
// otherwise collapse under markdown). With no narrative, fall back to the
|
|
@@ -505,6 +530,12 @@ export function ConsoleContent({ config, variant = 'page', }) {
|
|
|
505
530
|
}
|
|
506
531
|
reportStoppedWrites(requestGraphId, landed);
|
|
507
532
|
}
|
|
533
|
+
finally {
|
|
534
|
+
// Only this run's own entry: a later run may hold the lock by now.
|
|
535
|
+
if (runningGraphsRef.current.get(requestGraphId) === startTime) {
|
|
536
|
+
runningGraphsRef.current.delete(requestGraphId);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
508
539
|
};
|
|
509
540
|
const reportStoppedWrites = (writtenGraphId, writes) => {
|
|
510
541
|
if (writes.length === 0)
|
package/package.json
CHANGED