@moxxy/mode-goal 0.27.0 → 0.28.0
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/constants.d.ts +8 -26
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +9 -26
- package/dist/constants.js.map +1 -1
- package/dist/goal-loop.d.ts +27 -17
- package/dist/goal-loop.d.ts.map +1 -1
- package/dist/goal-loop.js +164 -351
- package/dist/goal-loop.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/constants.ts +11 -29
- package/src/goal-loop.ts +172 -399
- package/src/index.test.ts +186 -145
- package/src/index.ts +6 -1
package/dist/constants.d.ts
CHANGED
|
@@ -4,36 +4,14 @@ export declare const GOAL_PLUGIN_ID: import("@moxxy/sdk").PluginId;
|
|
|
4
4
|
export declare const GOAL_COMPLETE_TOOL = "goal_complete";
|
|
5
5
|
/** Tool the model calls to give up gracefully (blocked, needs the user). */
|
|
6
6
|
export declare const GOAL_ABANDON_TOOL = "goal_abandon";
|
|
7
|
-
/**
|
|
8
|
-
* Hard cap on autonomous iterations. Goal mode keeps re-prompting the model to
|
|
9
|
-
* continue until it calls {@link GOAL_COMPLETE_TOOL}; this is the backstop that
|
|
10
|
-
* guarantees the loop terminates even if the model never declares done. High
|
|
11
|
-
* enough for a substantial multi-step task, low enough to bound a runaway.
|
|
12
|
-
*/
|
|
13
|
-
export declare const GOAL_MAX_ITERATIONS = 150;
|
|
14
7
|
/**
|
|
15
8
|
* Consecutive iterations where the model emits NO tool calls and hasn't
|
|
16
|
-
* completed. After this many we
|
|
17
|
-
*
|
|
9
|
+
* completed. After this many we treat the run as done-in-spirit (the model has
|
|
10
|
+
* clearly decided it's finished without saying so) and end the turn cleanly
|
|
11
|
+
* rather than spin forever nudging — this is goal mode's natural-termination
|
|
12
|
+
* mechanism, not a guardrail: the model is always nudged back to work first.
|
|
18
13
|
*/
|
|
19
14
|
export declare const GOAL_MAX_NOOP_ITERATIONS = 3;
|
|
20
|
-
/**
|
|
21
|
-
* Cumulative token ceiling (full prompt — input + cacheRead + cacheCreation +
|
|
22
|
-
* output — across the whole goal run). A second backstop alongside the
|
|
23
|
-
* iteration cap: a few long-context iterations can burn a lot of tokens even
|
|
24
|
-
* under the iteration limit. Generous; the iteration cap is usually the binding
|
|
25
|
-
* guard.
|
|
26
|
-
*/
|
|
27
|
-
export declare const GOAL_TOKEN_BUDGET = 4000000;
|
|
28
|
-
/**
|
|
29
|
-
* Max consecutive retryable provider errors before goal mode bails with a fatal
|
|
30
|
-
* error. Goal mode runs unattended with auto-approval, so a sustained retryable
|
|
31
|
-
* condition (429 / overloaded / transient 5xx / ECONNRESET) must NOT busy-loop
|
|
32
|
-
* the provider — back off exponentially and give up after this many in a row.
|
|
33
|
-
* The counter resets on any clean provider call, so a long run can still
|
|
34
|
-
* recover from transient blips.
|
|
35
|
-
*/
|
|
36
|
-
export declare const MAX_CONSECUTIVE_RETRIES = 6;
|
|
37
15
|
/**
|
|
38
16
|
* Layered on top of any user system prompt for the whole goal run. The framing
|
|
39
17
|
* is the inverse of normal chat: stopping is NOT the signal to end — the model
|
|
@@ -47,4 +25,8 @@ export declare const GOAL_SYSTEM_PROMPT = "You are operating in GOAL MODE. The u
|
|
|
47
25
|
export declare const CONTINUE_NUDGE: string;
|
|
48
26
|
/** Sharper nudge once the model has idled repeatedly. */
|
|
49
27
|
export declare const STALL_NUDGE: string;
|
|
28
|
+
/** Volatile steer when the stuck-loop detector notices a repetitive pattern.
|
|
29
|
+
* Goal mode never aborts on repetition (unattended runs must not be killed by
|
|
30
|
+
* a heuristic) — it steers instead. */
|
|
31
|
+
export declare const STUCK_NUDGE_SUFFIX: string;
|
|
50
32
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,cAAc,+BAAiC,CAAC;AAE7D,8EAA8E;AAC9E,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;AAClD,4EAA4E;AAC5E,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAEhD
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,cAAc,+BAAiC,CAAC;AAE7D,8EAA8E;AAC9E,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;AAClD,4EAA4E;AAC5E,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAEhD;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,8zDAYuE,CAAC;AAEvG;0EAC0E;AAC1E,eAAO,MAAM,cAAc,QAE8D,CAAC;AAE1F,yDAAyD;AACzD,eAAO,MAAM,WAAW,QAEmG,CAAC;AAE5H;;wCAEwC;AACxC,eAAO,MAAM,kBAAkB,QAES,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -5,36 +5,14 @@ export const GOAL_PLUGIN_ID = asPluginId('@moxxy/mode-goal');
|
|
|
5
5
|
export const GOAL_COMPLETE_TOOL = 'goal_complete';
|
|
6
6
|
/** Tool the model calls to give up gracefully (blocked, needs the user). */
|
|
7
7
|
export const GOAL_ABANDON_TOOL = 'goal_abandon';
|
|
8
|
-
/**
|
|
9
|
-
* Hard cap on autonomous iterations. Goal mode keeps re-prompting the model to
|
|
10
|
-
* continue until it calls {@link GOAL_COMPLETE_TOOL}; this is the backstop that
|
|
11
|
-
* guarantees the loop terminates even if the model never declares done. High
|
|
12
|
-
* enough for a substantial multi-step task, low enough to bound a runaway.
|
|
13
|
-
*/
|
|
14
|
-
export const GOAL_MAX_ITERATIONS = 150;
|
|
15
8
|
/**
|
|
16
9
|
* Consecutive iterations where the model emits NO tool calls and hasn't
|
|
17
|
-
* completed. After this many we
|
|
18
|
-
*
|
|
10
|
+
* completed. After this many we treat the run as done-in-spirit (the model has
|
|
11
|
+
* clearly decided it's finished without saying so) and end the turn cleanly
|
|
12
|
+
* rather than spin forever nudging — this is goal mode's natural-termination
|
|
13
|
+
* mechanism, not a guardrail: the model is always nudged back to work first.
|
|
19
14
|
*/
|
|
20
15
|
export const GOAL_MAX_NOOP_ITERATIONS = 3;
|
|
21
|
-
/**
|
|
22
|
-
* Cumulative token ceiling (full prompt — input + cacheRead + cacheCreation +
|
|
23
|
-
* output — across the whole goal run). A second backstop alongside the
|
|
24
|
-
* iteration cap: a few long-context iterations can burn a lot of tokens even
|
|
25
|
-
* under the iteration limit. Generous; the iteration cap is usually the binding
|
|
26
|
-
* guard.
|
|
27
|
-
*/
|
|
28
|
-
export const GOAL_TOKEN_BUDGET = 4_000_000;
|
|
29
|
-
/**
|
|
30
|
-
* Max consecutive retryable provider errors before goal mode bails with a fatal
|
|
31
|
-
* error. Goal mode runs unattended with auto-approval, so a sustained retryable
|
|
32
|
-
* condition (429 / overloaded / transient 5xx / ECONNRESET) must NOT busy-loop
|
|
33
|
-
* the provider — back off exponentially and give up after this many in a row.
|
|
34
|
-
* The counter resets on any clean provider call, so a long run can still
|
|
35
|
-
* recover from transient blips.
|
|
36
|
-
*/
|
|
37
|
-
export const MAX_CONSECUTIVE_RETRIES = 6;
|
|
38
16
|
/**
|
|
39
17
|
* Layered on top of any user system prompt for the whole goal run. The framing
|
|
40
18
|
* is the inverse of normal chat: stopping is NOT the signal to end — the model
|
|
@@ -62,4 +40,9 @@ export const CONTINUE_NUDGE = `You stopped without calling \`${GOAL_COMPLETE_TOO
|
|
|
62
40
|
/** Sharper nudge once the model has idled repeatedly. */
|
|
63
41
|
export const STALL_NUDGE = `You have produced no tool calls for several turns. Either take a concrete next action toward the goal, ` +
|
|
64
42
|
`or call \`${GOAL_COMPLETE_TOOL}\` (if done) / \`${GOAL_ABANDON_TOOL}\` (if blocked). Do not reply with only text again.`;
|
|
43
|
+
/** Volatile steer when the stuck-loop detector notices a repetitive pattern.
|
|
44
|
+
* Goal mode never aborts on repetition (unattended runs must not be killed by
|
|
45
|
+
* a heuristic) — it steers instead. */
|
|
46
|
+
export const STUCK_NUDGE_SUFFIX = `If you are genuinely blocked and no different approach exists, call \`${GOAL_ABANDON_TOOL}\` ` +
|
|
47
|
+
`with the reason instead of retrying.`;
|
|
65
48
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC;AACrC,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC,kBAAkB,CAAC,CAAC;AAE7D,8EAA8E;AAC9E,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAClD,4EAA4E;AAC5E,MAAM,CAAC,MAAM,iBAAiB,GAAG,cAAc,CAAC;AAEhD
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC;AACrC,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC,kBAAkB,CAAC,CAAC;AAE7D,8EAA8E;AAC9E,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAClD,4EAA4E;AAC5E,MAAM,CAAC,MAAM,iBAAiB,GAAG,cAAc,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;kFAGgD,kBAAkB;qFACf,kBAAkB;sKAC+D,iBAAiB;;;;;6LAKM,iBAAiB;;sGAExG,CAAC;AAEvG;0EAC0E;AAC1E,MAAM,CAAC,MAAM,cAAc,GACzB,iCAAiC,kBAAkB,kDAAkD;IACrG,UAAU,kBAAkB,2DAA2D,CAAC;AAE1F,yDAAyD;AACzD,MAAM,CAAC,MAAM,WAAW,GACtB,yGAAyG;IACzG,aAAa,kBAAkB,oBAAoB,iBAAiB,qDAAqD,CAAC;AAE5H;;wCAEwC;AACxC,MAAM,CAAC,MAAM,kBAAkB,GAC7B,yEAAyE,iBAAiB,KAAK;IAC/F,sCAAsC,CAAC"}
|
package/dist/goal-loop.d.ts
CHANGED
|
@@ -1,25 +1,35 @@
|
|
|
1
1
|
import { type ModeContext, type MoxxyEvent } from '@moxxy/sdk';
|
|
2
|
-
|
|
3
|
-
* Override the retry back-off sleep (test seam). Returns a restore fn that
|
|
4
|
-
* callers MUST invoke (in a `finally`) — `sleepImpl` is a module-scoped
|
|
5
|
-
* singleton shared process-wide, so a leaked override bleeds the fake sleep
|
|
6
|
-
* into every other turn/test running in the same worker. Test-only.
|
|
7
|
-
*/
|
|
8
|
-
export declare function __setRetrySleepForTests(fn: (ms: number, signal: AbortSignal) => Promise<void>): () => void;
|
|
2
|
+
export { __setRetrySleepForTests } from '@moxxy/sdk';
|
|
9
3
|
/**
|
|
10
4
|
* Goal mode driver.
|
|
11
5
|
*
|
|
12
|
-
* Unlike
|
|
13
|
-
* goal mode treats "stopped emitting tools" as a cue to re-prompt: it
|
|
14
|
-
* the model working autonomously across iterations until the model
|
|
15
|
-
* calls `goal_complete` (success) or `goal_abandon` (blocked).
|
|
16
|
-
*
|
|
6
|
+
* Unlike the default mode (which returns the instant the model stops emitting
|
|
7
|
+
* tools), goal mode treats "stopped emitting tools" as a cue to re-prompt: it
|
|
8
|
+
* keeps the model working autonomously across iterations until the model
|
|
9
|
+
* explicitly calls `goal_complete` (success) or `goal_abandon` (blocked).
|
|
10
|
+
*
|
|
11
|
+
* Goal mode is deliberately GUARDRAIL-FREE: the user asked for an outcome and
|
|
12
|
+
* opted into full autonomy, so nothing heuristic may kill the run mid-delivery.
|
|
13
|
+
* There is no iteration cap (unless the embedder set an explicit
|
|
14
|
+
* `ctx.maxIterations`), no token budget, and a stuck-loop trip steers the model
|
|
15
|
+
* instead of aborting. The ONLY ways a run ends:
|
|
16
|
+
*
|
|
17
|
+
* - the model calls `goal_complete` (verified success) or `goal_abandon`
|
|
18
|
+
* (blocked, needs the user),
|
|
19
|
+
* - the model goes idle {@link GOAL_MAX_NOOP_ITERATIONS} rounds in a row
|
|
20
|
+
* despite nudges — it has decided it's done without saying so, so the run
|
|
21
|
+
* ends cleanly as a soft completion,
|
|
22
|
+
* - the user aborts (Esc / stop), or
|
|
23
|
+
* - a genuinely fatal condition (un-compactable context overflow, provider
|
|
24
|
+
* giving up after bounded retries).
|
|
17
25
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
26
|
+
* Goal mode is also ONE-SHOT (`transient: true` on the ModeDef): it arms for a
|
|
27
|
+
* single objective. When the run concludes as DONE — `goal_complete` or the
|
|
28
|
+
* idle soft-completion — the session hands back to the mode that was active
|
|
29
|
+
* before goal mode (via `ctx.requestModeSwitch`), so the user's next message is
|
|
30
|
+
* normal chat again. While the goal is UNFINISHED — `goal_abandon` (the model
|
|
31
|
+
* needs an answer to continue), a fatal error, or a user abort — the mode stays
|
|
32
|
+
* armed so the user's reply resumes the autonomous run.
|
|
23
33
|
*
|
|
24
34
|
* Tool calls are auto-approved for the whole run (the user opted into full
|
|
25
35
|
* autonomy) by swapping in a resolver that replaces only the PROMPT path:
|
package/dist/goal-loop.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goal-loop.d.ts","sourceRoot":"","sources":["../src/goal-loop.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"goal-loop.d.ts","sourceRoot":"","sources":["../src/goal-loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,UAAU,EAGhB,MAAM,YAAY,CAAC;AAiBpB,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAuB,WAAW,CAAC,GAAG,EAAE,WAAW,GAAG,aAAa,CAAC,UAAU,CAAC,CAiO9E"}
|