@aragon-agent/core 0.2.73 → 0.2.75
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/engine/agent.d.ts +9 -0
- package/dist/engine/agent.js +38 -0
- package/dist/types.d.ts +26 -0
- package/package.json +1 -1
package/dist/engine/agent.d.ts
CHANGED
|
@@ -109,6 +109,15 @@ export declare class Agent {
|
|
|
109
109
|
private readonly codeTimeout;
|
|
110
110
|
private readonly compactionHardTimeout;
|
|
111
111
|
private abortController;
|
|
112
|
+
/**
|
|
113
|
+
* Set by the idle watchdog immediately before it aborts, because the abort
|
|
114
|
+
* path produces no error event at all: without this bit an engine-interrupted
|
|
115
|
+
* run reaches every host indistinguishable from an answered one
|
|
116
|
+
* (`llm-network-error-dead-run` F).
|
|
117
|
+
*/
|
|
118
|
+
private watchdogFired;
|
|
119
|
+
/** Failure facts for the NEXT `agent_end`; cleared as they are emitted. */
|
|
120
|
+
private endFailure;
|
|
112
121
|
private running;
|
|
113
122
|
private idlePromiseResolvers;
|
|
114
123
|
constructor(config: AgentConfig);
|
package/dist/engine/agent.js
CHANGED
|
@@ -49,6 +49,15 @@ export class Agent {
|
|
|
49
49
|
compactionHardTimeout;
|
|
50
50
|
// --- Runtime state ---
|
|
51
51
|
abortController = null;
|
|
52
|
+
/**
|
|
53
|
+
* Set by the idle watchdog immediately before it aborts, because the abort
|
|
54
|
+
* path produces no error event at all: without this bit an engine-interrupted
|
|
55
|
+
* run reaches every host indistinguishable from an answered one
|
|
56
|
+
* (`llm-network-error-dead-run` F).
|
|
57
|
+
*/
|
|
58
|
+
watchdogFired = false;
|
|
59
|
+
/** Failure facts for the NEXT `agent_end`; cleared as they are emitted. */
|
|
60
|
+
endFailure = null;
|
|
52
61
|
running = false;
|
|
53
62
|
idlePromiseResolvers = [];
|
|
54
63
|
constructor(config) {
|
|
@@ -80,6 +89,8 @@ export class Agent {
|
|
|
80
89
|
// Watchdog — on timeout, abort the agent
|
|
81
90
|
this.watchdog = new IdleWatchdog(this.idleTimeout, () => {
|
|
82
91
|
console.error('[Agent] idle watchdog fired — aborting');
|
|
92
|
+
// BEFORE the abort, so the fact survives the unwind this call starts.
|
|
93
|
+
this.watchdogFired = true;
|
|
83
94
|
this.abort();
|
|
84
95
|
});
|
|
85
96
|
}
|
|
@@ -319,6 +330,7 @@ export class Agent {
|
|
|
319
330
|
*/
|
|
320
331
|
async runLoopWithLifecycle() {
|
|
321
332
|
this.running = true;
|
|
333
|
+
this.watchdogFired = false;
|
|
322
334
|
this.abortController = new AbortController();
|
|
323
335
|
this.watchdog.start();
|
|
324
336
|
this.emit({ type: 'agent_start' });
|
|
@@ -355,14 +367,40 @@ export class Agent {
|
|
|
355
367
|
}
|
|
356
368
|
catch (err) {
|
|
357
369
|
console.error('[Agent] loop error:', err);
|
|
370
|
+
// THE ONE PLACE THE LOOP'S THROW BECOMES A FACT A HOST CAN READ
|
|
371
|
+
// (llm-network-error-dead-run D). `runAgentLoop` re-throws the provider's
|
|
372
|
+
// own error, so the retry ladder's verdict is still on it: a retryable
|
|
373
|
+
// `ECONNRESET` arrives here with `retryable: true` and `errorType:
|
|
374
|
+
// 'network_error'`, which is exactly the pair the host needs to say
|
|
375
|
+
// "resume" instead of "ask the user for a key". Read STRUCTURALLY, never
|
|
376
|
+
// through `instanceof`: the engine may be wrapped by a provider adapter.
|
|
377
|
+
const facts = err;
|
|
378
|
+
this.endFailure = {
|
|
379
|
+
errored: true,
|
|
380
|
+
reason: 'llm_error',
|
|
381
|
+
...(typeof facts?.errorType === 'string' ? { errorType: facts.errorType } : {}),
|
|
382
|
+
...(typeof facts?.retryable === 'boolean' ? { retryable: facts.retryable } : {}),
|
|
383
|
+
};
|
|
358
384
|
}
|
|
359
385
|
finally {
|
|
360
386
|
this.watchdog.stop();
|
|
361
387
|
this.running = false;
|
|
362
388
|
this.abortController = null;
|
|
389
|
+
// THE WATCHDOG'S VERDICT, decided here because the abort path emits no
|
|
390
|
+
// error: a request that went quiet for `idleTimeout` is a TIMEOUT, and it
|
|
391
|
+
// is retryable in the only sense that matters to a host - starting the next
|
|
392
|
+
// turn is safe. `endFailure` wins when both could apply: the loop reached
|
|
393
|
+
// an error of its own, which is the more specific fact.
|
|
394
|
+
const failure = this.watchdogFired && !this.endFailure
|
|
395
|
+
? { errored: true, reason: 'idle_watchdog', errorType: 'timeout', retryable: true }
|
|
396
|
+
: (this.endFailure ?? {});
|
|
397
|
+
this.endFailure = null;
|
|
363
398
|
this.emit({
|
|
364
399
|
type: 'agent_end',
|
|
365
400
|
messages: this.messageManager.getAll(),
|
|
401
|
+
// ABSENT ON THE HAPPY PATH, so an answered run's `agent_end` keeps the
|
|
402
|
+
// exact shape it had before this feature: `['messages', 'type']`.
|
|
403
|
+
...failure,
|
|
366
404
|
});
|
|
367
405
|
// Resolve all pending waitForIdle() callers.
|
|
368
406
|
for (const resolve of this.idlePromiseResolvers) {
|
package/dist/types.d.ts
CHANGED
|
@@ -10,9 +10,35 @@ import type { CompactionTrigger } from './engine/context-manager.js';
|
|
|
10
10
|
export interface AgentStartEvent {
|
|
11
11
|
type: 'agent_start';
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Why a run ended unsuccessfully (`llm-network-error-dead-run` D).
|
|
15
|
+
*
|
|
16
|
+
* A run that ANSWERED carries none of the optional fields below, so a host that
|
|
17
|
+
* only knows about `messages` sees exactly the object it saw before this
|
|
18
|
+
* feature: `Object.keys(end)` is `['messages', 'type']` on the happy path.
|
|
19
|
+
*/
|
|
20
|
+
export type AgentEndReason = 'llm_error' | 'idle_watchdog';
|
|
13
21
|
export interface AgentEndEvent {
|
|
14
22
|
type: 'agent_end';
|
|
15
23
|
messages: Message[];
|
|
24
|
+
/**
|
|
25
|
+
* The run failed. Absent means "nothing went wrong", which is what keeps the
|
|
26
|
+
* happy path byte-identical.
|
|
27
|
+
*
|
|
28
|
+
* BEFORE THIS EXISTED the four hosts (TUI, `-p`, `exec`, desktop) each inferred
|
|
29
|
+
* failure from a DIFFERENT signal - a notice level, a stream event, a local
|
|
30
|
+
* boolean - so a retryable `ECONNRESET` and a missing API key looked the same
|
|
31
|
+
* from every one of them, and `run_end` in the log recorded no reason at all.
|
|
32
|
+
*/
|
|
33
|
+
errored?: boolean;
|
|
34
|
+
/** The provider's `LLMErrorType` when the failure was the model call. */
|
|
35
|
+
errorType?: string;
|
|
36
|
+
/**
|
|
37
|
+
* The provider said this was worth retrying. The single bit a host needs to
|
|
38
|
+
* tell "wait and try again" apart from "ask the user for a key".
|
|
39
|
+
*/
|
|
40
|
+
retryable?: boolean;
|
|
41
|
+
reason?: AgentEndReason;
|
|
16
42
|
}
|
|
17
43
|
export interface TurnStartEvent {
|
|
18
44
|
type: 'turn_start';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aragon-agent/core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.75",
|
|
4
4
|
"description": "AragonAgent core engine — LLM provider adapters, streaming, tool registry/execution, steering, idle watchdog, and an optional isolated-vm sandbox.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "AragonAgent contributors",
|