@herjarsa/omo-meta-governor 0.1.0 → 0.4.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/README.md +49 -0
- package/dist/config.d.ts +10 -1
- package/dist/decision-store.d.ts +36 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -1048
- package/dist/index.js.map +20 -0
- package/dist/plugin.d.ts +4 -4
- package/dist/types.d.ts +47 -5
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -38,6 +38,55 @@ After every tool call, MetaGovernor:
|
|
|
38
38
|
|
|
39
39
|
See [docs/guide/meta-governor.md](docs/guide/meta-governor.md) for full docs.
|
|
40
40
|
|
|
41
|
+
## Intervention (v0.3.0)
|
|
42
|
+
|
|
43
|
+
MetaGovernor can inject its decisions into the active agent's context
|
|
44
|
+
so the agent is aware of governance warnings, escalations, or stop signals.
|
|
45
|
+
|
|
46
|
+
### Modes
|
|
47
|
+
|
|
48
|
+
| Mode | Mechanism | Effect |
|
|
49
|
+
|------|-----------|--------|
|
|
50
|
+
| `silent` | (none) | Decision is logged only — no injection |
|
|
51
|
+
| `message` | `experimental.chat.messages.transform` | Injects a synthetic user message visible to the LLM |
|
|
52
|
+
| `system` | `experimental.chat.system.transform` | Appends guidance to the system prompt |
|
|
53
|
+
|
|
54
|
+
### Configuration
|
|
55
|
+
|
|
56
|
+
```jsonc
|
|
57
|
+
{
|
|
58
|
+
"meta_governor": {
|
|
59
|
+
"enabled": true,
|
|
60
|
+
"intervention": {
|
|
61
|
+
"mode": "message",
|
|
62
|
+
"includeDecisionHistory": true,
|
|
63
|
+
"maxHistoryMessages": 5,
|
|
64
|
+
"minActionForMessage": "warn"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
| Field | Default | Description |
|
|
72
|
+
|-------|---------|-------------|
|
|
73
|
+
| `mode` | `"silent"` | How to inject: `"silent"`, `"message"`, or `"system"` |
|
|
74
|
+
| `includeDecisionHistory` | `true` | Whether to include recent decision history |
|
|
75
|
+
| `maxHistoryMessages` | `5` | Max history entries when includeDecisionHistory is true |
|
|
76
|
+
| `minActionForMessage` | `"warn"` | Minimum action: `"warn"` (all non-continue), `"escalate"`, or `"stop"` |
|
|
77
|
+
|
|
78
|
+
### How it works
|
|
79
|
+
|
|
80
|
+
1. After every tool call, MetaGovernor runs the orchestrator pipeline.
|
|
81
|
+
2. If the decision is non-continue and meets `minActionForMessage`, it is
|
|
82
|
+
stored in an in-memory decision store keyed by session ID.
|
|
83
|
+
3. When the next LLM call starts, the appropriate transform hook fires:
|
|
84
|
+
- `message` mode: a synthetic `UserMessage` with `synthetic: true` flag
|
|
85
|
+
is prepended to the message list.
|
|
86
|
+
- `system` mode: the decision message is appended to the system prompt.
|
|
87
|
+
4. The decision is removed from the store after injection (one-shot).
|
|
88
|
+
|
|
89
|
+
|
|
41
90
|
## License
|
|
42
91
|
|
|
43
92
|
MIT
|
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { OrchestratorConfig } from "./types";
|
|
1
|
+
import type { ModelOverrideConfig, OrchestratorConfig } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* MetaGovernor config schema exposed to users.
|
|
4
4
|
* This is a Zod-free config interface since Zod parsing is optional
|
|
@@ -38,6 +38,15 @@ export interface MetaGovernorPluginConfig {
|
|
|
38
38
|
saveDecisions?: boolean;
|
|
39
39
|
saveLessons?: boolean;
|
|
40
40
|
};
|
|
41
|
+
/** Model override for MetaGovernor internal LLM usage. */
|
|
42
|
+
modelOverride?: ModelOverrideConfig;
|
|
43
|
+
/** Intervention config for visible decision injection. */
|
|
44
|
+
intervention?: {
|
|
45
|
+
mode?: "silent" | "message" | "system";
|
|
46
|
+
includeDecisionHistory?: boolean;
|
|
47
|
+
maxHistoryMessages?: number;
|
|
48
|
+
minActionForMessage?: "warn" | "escalate" | "stop";
|
|
49
|
+
};
|
|
41
50
|
}
|
|
42
51
|
/**
|
|
43
52
|
* Project the full MetaGovernorPluginConfig into OrchestratorConfig.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MetaGovernor decision store — in-memory Map for intervention feature.
|
|
3
|
+
*
|
|
4
|
+
* Stores decisions produced by tool.execute.after so they can be
|
|
5
|
+
* consumed by experimental.chat.messages.transform and
|
|
6
|
+
* experimental.chat.system.transform hooks.
|
|
7
|
+
*
|
|
8
|
+
* The store is keyed by sessionID. For hooks that receive a sessionID
|
|
9
|
+
* (system.transform), use takeDecision(sessionID). For hooks that
|
|
10
|
+
* receive no sessionID (messages.transform), use takeAnyDecision().
|
|
11
|
+
*/
|
|
12
|
+
import type { DecisionHandlerOutput } from "./types";
|
|
13
|
+
/**
|
|
14
|
+
* Store a decision for a session.
|
|
15
|
+
* Overwrites any previous pending decision for the same session.
|
|
16
|
+
*/
|
|
17
|
+
export declare function storeDecision(sessionID: string, decision: DecisionHandlerOutput): void;
|
|
18
|
+
/**
|
|
19
|
+
* Take (retrieve and remove) the pending decision for a session.
|
|
20
|
+
* Returns undefined if no decision is pending.
|
|
21
|
+
*/
|
|
22
|
+
export declare function takeDecision(sessionID: string): DecisionHandlerOutput | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Check whether a session has a pending decision without consuming it.
|
|
25
|
+
*/
|
|
26
|
+
export declare function hasDecision(sessionID: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Take any pending decision across all sessions.
|
|
29
|
+
* Useful for hooks that do not receive a sessionID.
|
|
30
|
+
* Returns the first pending decision found, or undefined if none.
|
|
31
|
+
*/
|
|
32
|
+
export declare function takeAnyDecision(): DecisionHandlerOutput | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Clear all stored decisions. Useful in tests or when a session ends.
|
|
35
|
+
*/
|
|
36
|
+
export declare function clearAll(): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -29,4 +29,5 @@ export { handleDecision, defaultDecisionHandlerConfig, trimHistory, countConsecu
|
|
|
29
29
|
export { observeAndLearn, defaultClosedLoopConfig } from "./closed-loop-learning";
|
|
30
30
|
export { aggregateRead } from "./memory-aggregator";
|
|
31
31
|
export { recordRecovery, type RecoveryOutcome } from "./post-repair-recorder";
|
|
32
|
-
export
|
|
32
|
+
export { storeDecision, takeDecision, hasDecision, takeAnyDecision, clearAll, } from "./decision-store";
|
|
33
|
+
export type { Decision, DecisionContext, DecisionHandlerConfig, DecisionHandlerInput, DecisionHandlerOutput, Deviation, Evidence, EvidenceContribution, InterventionConfig, InterventionMode, LearnFromOutcomeInput, LearnFromOutcomeOutput, MemoryRead, MemoryBackends, AgentmemoryWriteBackend, MetaGovernorInput, MetaGovernorOutput, OrchestratorConfig, ScoringConfig, ScoringResult, SlotMemory, TokenPredictorConfig, TokenPredictorInput, TokenPredictorOutput, ClosedLoopConfig, } from "./types";
|