@kl-c/matrixos 0.1.5 → 0.1.7
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/cli/architect.d.ts +16 -0
- package/dist/cli/index.js +285 -107
- package/dist/cli-node/index.js +285 -107
- package/dist/config/schema/oh-my-opencode-config.d.ts +1 -0
- package/dist/config/schema/watchdog.d.ts +1 -0
- package/dist/features/anti-loop/logger.d.ts +15 -0
- package/dist/hooks/agent-anti-loop/hook.d.ts +5 -26
- package/dist/index.js +174 -102
- package/dist/oh-my-opencode.schema.json +7 -0
- package/dist/plugin/agent-anti-loop.d.ts +2 -5
- package/dist/tui.js +1 -0
- package/package.json +1 -1
|
@@ -2449,6 +2449,7 @@ export declare const OhMyOpenCodeConfigSchema: z.ZodObject<{
|
|
|
2449
2449
|
watchdog: z.ZodOptional<z.ZodObject<{
|
|
2450
2450
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
2451
2451
|
doomLoopThreshold: z.ZodDefault<z.ZodNumber>;
|
|
2452
|
+
softDoomLoopThreshold: z.ZodDefault<z.ZodNumber>;
|
|
2452
2453
|
stuckTimeoutSec: z.ZodDefault<z.ZodNumber>;
|
|
2453
2454
|
auditLogPath: z.ZodOptional<z.ZodString>;
|
|
2454
2455
|
recoveryStrategy: z.ZodDefault<z.ZodEnum<{
|
|
@@ -6,6 +6,7 @@ import * as z from "zod";
|
|
|
6
6
|
export declare const WatchdogConfigSchema: z.ZodObject<{
|
|
7
7
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
8
8
|
doomLoopThreshold: z.ZodDefault<z.ZodNumber>;
|
|
9
|
+
softDoomLoopThreshold: z.ZodDefault<z.ZodNumber>;
|
|
9
10
|
stuckTimeoutSec: z.ZodDefault<z.ZodNumber>;
|
|
10
11
|
auditLogPath: z.ZodOptional<z.ZodString>;
|
|
11
12
|
recoveryStrategy: z.ZodDefault<z.ZodEnum<{
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type AntiLoopPattern = "doom_loop" | "soft_doom_loop" | "stuck" | "zombie_session" | "hook_recursion" | "agent_avoidance" | "context_bloat" | "runaway_task";
|
|
2
|
+
export interface AntiLoopEvent {
|
|
3
|
+
timestamp: string;
|
|
4
|
+
sessionId?: string;
|
|
5
|
+
pattern: AntiLoopPattern;
|
|
6
|
+
agent?: string;
|
|
7
|
+
toolName?: string;
|
|
8
|
+
detail: string;
|
|
9
|
+
actionTaken: string;
|
|
10
|
+
outcome?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface AntiLoopLogger {
|
|
13
|
+
log(event: Omit<AntiLoopEvent, "timestamp">): void;
|
|
14
|
+
}
|
|
15
|
+
export declare function createAntiLoopLogger(logsDir: string): AntiLoopLogger;
|
|
@@ -1,49 +1,28 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent-level anti-loop watchdog (§4.12).
|
|
3
|
-
*
|
|
4
|
-
* Attaches to `tool.execute.after` to track tool call signatures and detect
|
|
5
|
-
* doom loops (same tool ≥3x identical). Also monitors a stuck timer (90s
|
|
6
|
-
* default) since the last meaningful tool call.
|
|
7
|
-
*
|
|
8
|
-
* Recovery escalation (CDC §4.12.3):
|
|
9
|
-
* Level 1 — Nudge: inject a message telling the agent it appears stuck
|
|
10
|
-
* Level 2 — Fallback: switch model (delegates to runtime-fallback)
|
|
11
|
-
* Level 3 — Restart: kill + restart session (future phase)
|
|
12
|
-
*
|
|
13
|
-
* The watchdog is opt-in via `watchdog.enabled` in the config.
|
|
14
|
-
*/
|
|
15
1
|
import type { WatchdogConfig } from "../../config/schema/watchdog";
|
|
16
2
|
export interface ToolCallRecord {
|
|
17
|
-
/** Tool name, e.g. "bash", "edit", "read". */
|
|
18
3
|
tool: string;
|
|
19
|
-
/** Stable signature: toolName + sorted JSON args. */
|
|
20
4
|
signature: string;
|
|
21
|
-
/** Timestamp of the call. */
|
|
22
5
|
timestamp: number;
|
|
23
|
-
/** Whether the tool produced meaningful output (text > 0). */
|
|
24
6
|
meaningful: boolean;
|
|
25
7
|
}
|
|
8
|
+
export declare function signaturesSimilar(a: string, b: string): boolean;
|
|
26
9
|
export interface AgentAntiLoopState {
|
|
27
|
-
/** Per-signature consecutive count. */
|
|
28
10
|
consecutiveBySignature: Map<string, number>;
|
|
29
|
-
|
|
11
|
+
recentSignatures: string[];
|
|
30
12
|
lastMeaningfulToolAt: number;
|
|
31
|
-
/** Whether a nudge has already been sent (cooldown). */
|
|
32
13
|
nudged: boolean;
|
|
33
|
-
/** Whether fallback has been triggered. */
|
|
34
14
|
fallbackTriggered: boolean;
|
|
15
|
+
avoidanceCount: number;
|
|
16
|
+
avoidanceEscalated: boolean;
|
|
35
17
|
}
|
|
36
18
|
export interface AgentAntiLoopHooks {
|
|
37
|
-
/** Call on every tool.execute.after. */
|
|
38
19
|
onToolAfter(tool: string, args: unknown, output: unknown): void;
|
|
39
|
-
|
|
20
|
+
onAgentMessage(content: string): void;
|
|
40
21
|
checkStuck(): {
|
|
41
22
|
stuck: boolean;
|
|
42
23
|
secondsSinceLastMeaningful: number;
|
|
43
24
|
};
|
|
44
|
-
/** Reset the state (e.g. on session start). */
|
|
45
25
|
reset(): void;
|
|
46
|
-
/** Get the current state (for audit). */
|
|
47
26
|
getState(): AgentAntiLoopState;
|
|
48
27
|
}
|
|
49
28
|
export declare function createAgentAntiLoopHooks(config: WatchdogConfig): AgentAntiLoopHooks;
|