yuangs 2.39.0 → 2.40.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/agent/AgentRuntime.d.ts +0 -1
- package/dist/agent/AgentRuntime.js +32 -58
- package/dist/agent/AgentRuntime.js.map +1 -0
- package/dist/agent/governance/bridge.d.ts +3 -6
- package/dist/agent/governance/bridge.js +21 -28
- package/dist/agent/governance/bridge.js.map +1 -0
- package/dist/agent/governance/core.d.ts +0 -5
- package/dist/agent/governance/core.js +4 -12
- package/dist/agent/governance/core.js.map +1 -0
- package/dist/agent/governance/ledger.d.ts +1 -0
- package/dist/agent/governance/ledger.js +9 -4
- package/dist/agent/governance/ledger.js.map +1 -0
- package/dist/agent/governance/sandbox/core.as.js.map +1 -0
- package/dist/agent/governance.d.ts +11 -8
- package/dist/agent/governance.js +48 -135
- package/dist/agent/governance.js.map +1 -1
- package/dist/agent/index.d.ts +2 -6
- package/dist/agent/index.js +4 -10
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/llmAdapter.d.ts +1 -1
- package/dist/agent/llmAdapter.js +4 -5
- package/dist/agent/llmAdapter.js.map +1 -1
- package/dist/agent/skills.d.ts +2 -4
- package/dist/agent/skills.js.map +1 -1
- package/dist/agent/types.d.ts +1 -2
- package/dist/cli.js +10 -9
- package/dist/cli.js.map +1 -1
- package/dist/legacy/governance/GovernanceEngine.d.ts +20 -0
- package/dist/legacy/governance/GovernanceEngine.js +95 -0
- package/dist/legacy/governance/GovernanceEngine.js.map +1 -0
- package/dist/legacy/governance/GovernedAction.d.ts +107 -0
- package/dist/legacy/governance/GovernedAction.js +9 -0
- package/dist/legacy/governance/GovernedAction.js.map +1 -0
- package/dist/legacy/governance/actions/CodeChangeAction.d.ts +28 -0
- package/dist/legacy/governance/actions/CodeChangeAction.js +139 -0
- package/dist/legacy/governance/actions/CodeChangeAction.js.map +1 -0
- package/dist/legacy/governance/capability/token.d.ts +45 -0
- package/dist/legacy/governance/capability/token.js +103 -0
- package/dist/legacy/governance/capability/token.js.map +1 -0
- package/dist/legacy/governance/commands/diffEdit.d.ts +2 -0
- package/dist/legacy/governance/commands/diffEdit.js +245 -0
- package/dist/legacy/governance/commands/diffEdit.js.map +1 -0
- package/dist/legacy/governance/execution/sandbox.d.ts +12 -0
- package/dist/legacy/governance/execution/sandbox.js +76 -0
- package/dist/legacy/governance/execution/sandbox.js.map +1 -0
- package/dist/legacy/governance/fsm/stateMachine.d.ts +40 -0
- package/dist/legacy/governance/fsm/stateMachine.js +93 -0
- package/dist/legacy/governance/fsm/stateMachine.js.map +1 -0
- package/dist/legacy/governance/index.d.ts +9 -0
- package/dist/legacy/governance/index.js +26 -0
- package/dist/legacy/governance/index.js.map +1 -0
- package/dist/legacy/governance/review/diffParser.d.ts +12 -0
- package/dist/legacy/governance/review/diffParser.js +61 -0
- package/dist/legacy/governance/review/diffParser.js.map +1 -0
- package/dist/legacy/governance/review/render.d.ts +5 -0
- package/dist/legacy/governance/review/render.js +58 -0
- package/dist/legacy/governance/review/render.js.map +1 -0
- package/dist/legacy/governance/storage/store.d.ts +16 -0
- package/dist/legacy/governance/storage/store.js +110 -0
- package/dist/legacy/governance/storage/store.js.map +1 -0
- package/package.json +7 -5
- package/dist/agent/AgentPipeline.js.map +0 -1
- package/dist/agent/fsm.js.map +0 -1
- package/dist/agent/intent.js.map +0 -1
- package/dist/agent/interpret.js.map +0 -1
- package/dist/agent/loop.js.map +0 -1
- package/dist/agent/plan.js.map +0 -1
- package/dist/agent/planExecutor.js.map +0 -1
- package/dist/agent/record.js.map +0 -1
- package/dist/agent/replay.js.map +0 -1
- package/dist/governance/GovernanceEngine.js.map +0 -1
- package/dist/governance/GovernedAction.js.map +0 -1
- package/dist/governance/actions/CodeChangeAction.js.map +0 -1
- package/dist/governance/capability/token.js.map +0 -1
- package/dist/governance/commands/diffEdit.js.map +0 -1
- package/dist/governance/execution/sandbox.js.map +0 -1
- package/dist/governance/fsm/stateMachine.js.map +0 -1
- package/dist/governance/index.js.map +0 -1
- package/dist/governance/review/diffParser.js.map +0 -1
- package/dist/governance/review/render.js.map +0 -1
- package/dist/governance/storage/store.js.map +0 -1
|
@@ -5,15 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.AgentRuntime = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const ora_1 = __importDefault(require("ora"));
|
|
9
8
|
const crypto_1 = require("crypto");
|
|
10
9
|
const llmAdapter_1 = require("./llmAdapter");
|
|
11
10
|
const governance_1 = require("./governance");
|
|
12
11
|
const executor_1 = require("./executor");
|
|
13
12
|
const contextManager_1 = require("./contextManager");
|
|
14
|
-
const renderer_1 = require("../utils/renderer");
|
|
15
|
-
const skills_1 = require("./skills");
|
|
16
|
-
const capabilitySystem_1 = require("../core/capabilitySystem");
|
|
17
13
|
const core_1 = require("./governance/core");
|
|
18
14
|
class AgentRuntime {
|
|
19
15
|
context;
|
|
@@ -25,79 +21,57 @@ class AgentRuntime {
|
|
|
25
21
|
async run(userInput, mode = 'chat') {
|
|
26
22
|
let turnCount = 0;
|
|
27
23
|
const maxTurns = 10;
|
|
28
|
-
|
|
24
|
+
console.log(chalk_1.default.cyan(`\n🚀 Agent Runtime v2.0 Starting (Execution ID: ${this.executionId})`));
|
|
25
|
+
this.context.addMessage('user', userInput);
|
|
29
26
|
while (turnCount < maxTurns) {
|
|
30
27
|
console.log(chalk_1.default.blue(`\n--- Turn ${++turnCount} ---`));
|
|
31
|
-
|
|
32
|
-
//
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
const renderer = new renderer_1.StreamMarkdownRenderer(chalk_1.default.bold.blue('🤖 AI: '), spinner);
|
|
39
|
-
const thought = await this.think(this.context.getMessages(), model, (chunk) => renderer.onChunk(chunk) // 实时输出到终端
|
|
40
|
-
);
|
|
41
|
-
renderer.finish();
|
|
28
|
+
const model = 'Assistant';
|
|
29
|
+
// 处理类型不兼容:将 tool role 映射为 system
|
|
30
|
+
const messages = this.context.getMessages().map(msg => ({
|
|
31
|
+
role: (msg.role === 'tool' ? 'system' : msg.role),
|
|
32
|
+
content: msg.content
|
|
33
|
+
}));
|
|
34
|
+
const thought = await llmAdapter_1.LLMAdapter.think(messages, mode, undefined, governance_1.GovernanceService.getPolicyManual());
|
|
42
35
|
if (thought.isDone) {
|
|
43
|
-
console.log(chalk_1.default.green('\n
|
|
36
|
+
console.log(chalk_1.default.green('\n✅ Goal satisfied.'));
|
|
44
37
|
break;
|
|
45
38
|
}
|
|
46
|
-
// 2. 治理评审 (Adjudicate)
|
|
47
39
|
const action = {
|
|
48
40
|
id: (0, crypto_1.randomUUID)(),
|
|
49
|
-
type: thought.type,
|
|
50
|
-
payload: thought.payload,
|
|
51
|
-
riskLevel:
|
|
41
|
+
type: thought.type || 'answer',
|
|
42
|
+
payload: thought.payload || { text: thought.raw },
|
|
43
|
+
riskLevel: 'low',
|
|
52
44
|
reasoning: thought.reasoning || ''
|
|
53
45
|
};
|
|
54
|
-
// ===
|
|
55
|
-
const actionFingerprint = JSON.stringify(action.payload);
|
|
56
|
-
if (rejectionHistory.has(actionFingerprint)) {
|
|
57
|
-
console.log(chalk_1.default.red(`[ANTI-LOOP] 拦截重复提案`));
|
|
58
|
-
this.context.addMessage('system', `ERROR: You are repeating a previously denied action. DO NOT try this again. Find a NEW way.`);
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
46
|
+
// === 预检 (Pre-flight) ===
|
|
61
47
|
const preCheck = (0, core_1.evaluateProposal)(action, governance_1.GovernanceService.getRules(), governance_1.GovernanceService.getLedgerSnapshot());
|
|
62
48
|
if (preCheck.effect === 'deny') {
|
|
63
|
-
console.log(chalk_1.default.red(`[PRE-FLIGHT]
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
continue; // 直接让 AI 重新思考,不惊动用户
|
|
49
|
+
console.log(chalk_1.default.red(`[PRE-FLIGHT] 🛡️ Policy Blocked: ${preCheck.reason}`));
|
|
50
|
+
this.context.addMessage('system', `POLICY DENIED: ${preCheck.reason}. Find a different way.`);
|
|
51
|
+
continue;
|
|
67
52
|
}
|
|
53
|
+
// === 正式治理 (WASM + 人工/自动) ===
|
|
68
54
|
const decision = await governance_1.GovernanceService.adjudicate(action);
|
|
69
55
|
if (decision.status === 'rejected') {
|
|
70
|
-
|
|
56
|
+
console.log(chalk_1.default.red(`[GOVERNANCE] ❌ Rejected: ${decision.reason}`));
|
|
57
|
+
this.context.addMessage('system', `Rejected by Governance: ${decision.reason}`);
|
|
71
58
|
continue;
|
|
72
59
|
}
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
const result = await executor_1.ToolExecutor.execute(
|
|
76
|
-
// 4. 技能学习 (Learn) - 成功则自动入库
|
|
60
|
+
// === 执行 ===
|
|
61
|
+
console.log(chalk_1.default.yellow(`[EXECUTING] ⚙️ ${action.type}...`));
|
|
62
|
+
const result = await executor_1.ToolExecutor.execute(action);
|
|
77
63
|
if (result.success) {
|
|
78
|
-
|
|
79
|
-
(0,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}, true);
|
|
64
|
+
this.context.addToolResult(action.type, result.output);
|
|
65
|
+
console.log(chalk_1.default.green(`[SUCCESS] Result: ${result.output.substring(0, 50)}...`));
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
this.context.addToolResult(action.type, `Error: ${result.error}`);
|
|
69
|
+
console.log(chalk_1.default.red(`[ERROR] ${result.error}`));
|
|
85
70
|
}
|
|
86
|
-
// 5. 观察反馈 (Observe)
|
|
87
|
-
const output = result.success ? (result.output || '').substring(0, 2000) : result.error;
|
|
88
|
-
this.context.addToolResult(finalAction.type, output || '');
|
|
89
71
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const systemPrompt = `You are a Governed AI.
|
|
94
|
-
CURRENT LAWS:
|
|
95
|
-
${laws}
|
|
96
|
-
|
|
97
|
-
Always check if your plan violates these laws before proposing.
|
|
98
|
-
If a law requires human approval, explain to the user why it's necessary.
|
|
99
|
-
Output JSON format: { "action_type": "...", "payload": {...}, "reasoning": "...", "is_done": false }`;
|
|
100
|
-
return await llmAdapter_1.LLMAdapter.think(messages, model, onChunk, systemPrompt);
|
|
72
|
+
if (turnCount >= maxTurns) {
|
|
73
|
+
console.log(chalk_1.default.red(`\n⚠️ Max turns (${maxTurns}) reached.`));
|
|
74
|
+
}
|
|
101
75
|
}
|
|
102
76
|
}
|
|
103
77
|
exports.AgentRuntime = AgentRuntime;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentRuntime.js","sourceRoot":"","sources":["../../src/agent/AgentRuntime.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,mCAAoC;AACpC,6CAA0C;AAC1C,6CAAiD;AACjD,yCAA0C;AAC1C,qDAAkD;AAClD,4CAAqD;AAGrD,MAAa,YAAY;IACb,OAAO,CAAiB;IACxB,WAAW,CAAS;IAE5B,YAAY,cAAmB;QAC3B,IAAI,CAAC,OAAO,GAAG,IAAI,+BAAc,CAAC,cAAc,CAAC,CAAC;QAClD,IAAI,CAAC,WAAW,GAAG,IAAA,mBAAU,GAAE,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,SAAiB,EAAE,OAA2B,MAAM;QAC1D,IAAI,SAAS,GAAG,CAAC,CAAC;QAClB,MAAM,QAAQ,GAAG,EAAE,CAAC;QAEpB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,mDAAmD,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;QAChG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAE3C,OAAO,SAAS,GAAG,QAAQ,EAAE,CAAC;YAC1B,OAAO,CAAC,GAAG,CAA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,CAAC,WAAW,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YACtD,CAAC;QACL,CAAC;QAED,IAAI,SAAS,IAAI,QAAQ,EAAE,CAAC;YACxB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,mBAAmB,QAAQ,YAAY,CAAC,CAAC,CAAC;QACpE,CAAC;IACL,CAAC;CACJ;AAhFD,oCAgFC"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
export declare class WasmGovernanceBridge {
|
|
2
|
-
private
|
|
3
|
-
init(): Promise<
|
|
4
|
-
evaluate(
|
|
5
|
-
effect: string;
|
|
6
|
-
reason?: string;
|
|
7
|
-
};
|
|
2
|
+
private static instance;
|
|
3
|
+
static init(): Promise<boolean>;
|
|
4
|
+
static evaluate(proposal: any, rules: any, ledger: any): any;
|
|
8
5
|
}
|
|
@@ -6,39 +6,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.WasmGovernanceBridge = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const loader_1 = __importDefault(require("@assemblyscript/loader"));
|
|
10
9
|
class WasmGovernanceBridge {
|
|
11
|
-
|
|
12
|
-
async init() {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
throw new Error(`WASM 模块未找到,请先运行 npm run asbuild. 路径: ${wasmPath}`);
|
|
10
|
+
static instance = null;
|
|
11
|
+
static async init() {
|
|
12
|
+
try {
|
|
13
|
+
const loader = require('@assemblyscript/loader');
|
|
14
|
+
const wasmPath = path_1.default.join(process.cwd(), 'build', 'release.wasm');
|
|
15
|
+
if (!fs_1.default.existsSync(wasmPath)) {
|
|
16
|
+
return false;
|
|
19
17
|
}
|
|
20
|
-
|
|
18
|
+
const wasmModule = await loader.instantiate(fs_1.default.readFileSync(wasmPath));
|
|
19
|
+
this.instance = wasmModule.exports;
|
|
20
|
+
return true;
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// 实例化 WASM,并注入必要的运行时支持
|
|
25
|
-
this.wasmInstance = await loader_1.default.instantiate(wasmModule, {});
|
|
22
|
+
catch (e) {
|
|
23
|
+
return false;
|
|
26
24
|
}
|
|
27
|
-
console.log('✅ WASM 治理沙盒已加载并激活。');
|
|
28
25
|
}
|
|
29
|
-
evaluate(
|
|
30
|
-
if (!this.
|
|
31
|
-
|
|
32
|
-
const { __newString, __getString, evaluate } = this.
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
const resultPtr = evaluate(proposalPtr, rulesPtr, ledgerPtr);
|
|
39
|
-
// 从沙盒提取计算结果
|
|
40
|
-
const resultJson = __getString(resultPtr);
|
|
41
|
-
return JSON.parse(resultJson);
|
|
26
|
+
static evaluate(proposal, rules, ledger) {
|
|
27
|
+
if (!this.instance)
|
|
28
|
+
return { effect: 'error', reason: 'WASM not initialized' };
|
|
29
|
+
const { __newString, __getString, evaluate } = this.instance;
|
|
30
|
+
const pPtr = __newString(JSON.stringify(proposal));
|
|
31
|
+
const rPtr = __newString(JSON.stringify(rules));
|
|
32
|
+
const lPtr = __newString(JSON.stringify(ledger));
|
|
33
|
+
const resultPtr = evaluate(pPtr, rPtr, lPtr);
|
|
34
|
+
return JSON.parse(__getString(resultPtr));
|
|
42
35
|
}
|
|
43
36
|
}
|
|
44
37
|
exports.WasmGovernanceBridge = WasmGovernanceBridge;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../../src/agent/governance/bridge.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAExB,MAAa,oBAAoB;IACrB,MAAM,CAAC,QAAQ,GAAQ,IAAI,CAAC;IAEpC,MAAM,CAAC,KAAK,CAAC,IAAI;QACb,IAAI,CAAC;YAC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AgCC"}
|
|
@@ -13,11 +13,6 @@ export interface RiskEntry {
|
|
|
13
13
|
ts: number;
|
|
14
14
|
actionType: string;
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
17
|
-
* 核心裁决函数 (未来可直接编译为 WASM)
|
|
18
|
-
* 输入:提案、策略集、历史账本
|
|
19
|
-
* 输出:决定
|
|
20
|
-
*/
|
|
21
16
|
export declare function evaluateProposal(action: ProposedAction, rules: PolicyRule[], ledger: RiskEntry[]): {
|
|
22
17
|
effect: string;
|
|
23
18
|
reason?: string;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.evaluateProposal = evaluateProposal;
|
|
4
|
-
/**
|
|
5
|
-
* 核心裁决函数 (未来可直接编译为 WASM)
|
|
6
|
-
* 输入:提案、策略集、历史账本
|
|
7
|
-
* 输出:决定
|
|
8
|
-
*/
|
|
9
4
|
function evaluateProposal(action, rules, ledger) {
|
|
10
5
|
const now = Date.now();
|
|
11
6
|
for (const rule of rules) {
|
|
@@ -13,17 +8,14 @@ function evaluateProposal(action, rules, ledger) {
|
|
|
13
8
|
const payloadStr = JSON.stringify(action.payload);
|
|
14
9
|
const patternMatch = !rule.when.pattern || new RegExp(rule.when.pattern, 'i').test(payloadStr);
|
|
15
10
|
if (typeMatch && patternMatch) {
|
|
16
|
-
// 检查风险预算 (速率限制)
|
|
17
11
|
if (rule.when.max_per_minute) {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return { effect: 'deny', reason: `速率限制触发: ${rule.id} (每分钟限额 ${rule.when.max_per_minute} 次)` };
|
|
22
|
-
}
|
|
12
|
+
const count = ledger.filter(e => e.ts > now - 60000 && e.actionType === action.type).length;
|
|
13
|
+
if (count >= rule.when.max_per_minute)
|
|
14
|
+
return { effect: 'deny', reason: `Rate limit: ${rule.id}` };
|
|
23
15
|
}
|
|
24
16
|
return { effect: rule.effect, reason: rule.reason };
|
|
25
17
|
}
|
|
26
18
|
}
|
|
27
|
-
return { effect: 'require_approval', reason: '
|
|
19
|
+
return { effect: 'require_approval', reason: 'Default human review required' };
|
|
28
20
|
}
|
|
29
21
|
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/agent/governance/core.ts"],"names":[],"mappings":";;AAcA,4CAoBC;AApBD,SAAgB,gBAAgB,CAC5B,MAAsB,EACtB,KAAmB,EACnB,MAAmB;IAEnB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,SAAS,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,CAAC;QACpE,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAClD,MAAM,YAAY,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAE/F,IAAI,SAAS,IAAI,YAAY,EAAE,CAAC;YAC5B,IAAI,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;gBAC3B,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,GAAG,KAAK,IAAI,CAAC,CAAC,UAAU,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;gBAC5F,IAAI,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,cAAc;oBAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC;YACvG,CAAC;YACD,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QACxD,CAAC;IACL,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,+BAA+B,EAAE,CAAC;AACnF,CAAC"}
|
|
@@ -4,14 +4,19 @@ exports.RiskLedger = void 0;
|
|
|
4
4
|
class RiskLedger {
|
|
5
5
|
entries = [];
|
|
6
6
|
record(actionType) {
|
|
7
|
-
this.entries.push({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
this.entries.push({
|
|
8
|
+
ts: Date.now(),
|
|
9
|
+
actionType
|
|
10
|
+
});
|
|
11
|
+
this.cleanup();
|
|
11
12
|
}
|
|
12
13
|
getSnapshot() {
|
|
13
14
|
return [...this.entries];
|
|
14
15
|
}
|
|
16
|
+
cleanup() {
|
|
17
|
+
const oneHourAgo = Date.now() - 3600000;
|
|
18
|
+
this.entries = this.entries.filter(e => e.ts > oneHourAgo);
|
|
19
|
+
}
|
|
15
20
|
}
|
|
16
21
|
exports.RiskLedger = RiskLedger;
|
|
17
22
|
//# sourceMappingURL=ledger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger.js","sourceRoot":"","sources":["../../../src/agent/governance/ledger.ts"],"names":[],"mappings":";;;AAEA,MAAa,UAAU;IACX,OAAO,GAAgB,EAAE,CAAC;IAElC,MAAM,CAAC,UAAkB;QACrB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YACd,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;YACd,UAAU;SACb,CAAC,CAAC;QACH,IAAI,CAAC,OAAO,EAAE,CAAC;IACnB,CAAC;IAED,WAAW;QACP,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAEO,OAAO;QACX,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC;QACxC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,UAAU,CAAC,CAAC;IAC/D,CAAC;CACJ;AAnBD,gCAmBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.as.js","sourceRoot":"","sources":["../../../../src/agent/governance/sandbox/core.as.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAaH,4BAgBC;AA3BD,6BAA6B;AAC7B,SAAS,QAAQ,CAAC,MAAc,EAAE,MAAc;IAC5C,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,CAAC;AAED;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,QAAgB,EAAE,KAAa,EAAE,MAAc;IACpE,qCAAqC;IACrC,IAAI,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAChE,OAAO,6DAA6D,CAAC;IACzE,CAAC;IAED,kBAAkB;IAClB,8BAA8B;IAC9B,IAAI,MAAM,CAAC,MAAM,GAAG,IAAI,EAAE,CAAC,CAAC,kBAAkB;QAC1C,OAAO,iEAAiE,CAAC;IAC7E,CAAC;IAED,UAAU;IACV,8BAA8B;IAC9B,mBAAmB;IACnB,OAAO,0DAA0D,CAAC;AACtE,CAAC"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { ProposedAction, GovernanceDecision
|
|
1
|
+
import { ProposedAction, GovernanceDecision } from './state';
|
|
2
|
+
import { PolicyRule, RiskEntry } from './governance/core';
|
|
2
3
|
export declare class GovernanceService {
|
|
3
|
-
static
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
private static
|
|
8
|
-
static
|
|
9
|
-
|
|
4
|
+
private static rules;
|
|
5
|
+
private static ledger;
|
|
6
|
+
private static initialized;
|
|
7
|
+
static init(): Promise<void>;
|
|
8
|
+
private static loadPolicy;
|
|
9
|
+
static getRules(): PolicyRule[];
|
|
10
|
+
static getLedgerSnapshot(): RiskEntry[];
|
|
11
|
+
static getPolicyManual(): string;
|
|
12
|
+
static adjudicate(action: ProposedAction): Promise<GovernanceDecision>;
|
|
10
13
|
}
|
package/dist/agent/governance.js
CHANGED
|
@@ -4,150 +4,63 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.GovernanceService = void 0;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
7
|
+
const core_1 = require("./governance/core");
|
|
8
|
+
const ledger_1 = require("./governance/ledger");
|
|
9
|
+
const bridge_1 = require("./governance/bridge");
|
|
10
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
10
13
|
class GovernanceService {
|
|
11
|
-
static
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
else if (answer.modify) {
|
|
32
|
-
return {
|
|
33
|
-
status: 'modified',
|
|
34
|
-
by: 'human',
|
|
35
|
-
originalActionId: action.id,
|
|
36
|
-
modifiedAction: answer.modifiedAction,
|
|
37
|
-
modificationReason: answer.reason || 'User modified',
|
|
38
|
-
timestamp: Date.now()
|
|
39
|
-
};
|
|
14
|
+
static rules = [];
|
|
15
|
+
static ledger = new ledger_1.RiskLedger();
|
|
16
|
+
static initialized = false;
|
|
17
|
+
static async init() {
|
|
18
|
+
if (this.initialized)
|
|
19
|
+
return;
|
|
20
|
+
this.loadPolicy();
|
|
21
|
+
await bridge_1.WasmGovernanceBridge.init();
|
|
22
|
+
this.initialized = true;
|
|
23
|
+
}
|
|
24
|
+
static loadPolicy() {
|
|
25
|
+
try {
|
|
26
|
+
const policyPath = path_1.default.join(process.cwd(), 'policy.yaml');
|
|
27
|
+
if (fs_1.default.existsSync(policyPath)) {
|
|
28
|
+
const content = fs_1.default.readFileSync(policyPath, 'utf8');
|
|
29
|
+
const config = js_yaml_1.default.load(content);
|
|
30
|
+
this.rules = config.rules || [];
|
|
31
|
+
}
|
|
40
32
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
status: 'rejected',
|
|
44
|
-
by: 'human',
|
|
45
|
-
reason: answer.reason || 'User rejected',
|
|
46
|
-
timestamp: Date.now()
|
|
47
|
-
};
|
|
33
|
+
catch (e) {
|
|
34
|
+
this.rules = [];
|
|
48
35
|
}
|
|
49
36
|
}
|
|
50
|
-
static
|
|
51
|
-
|
|
52
|
-
input: process.stdin,
|
|
53
|
-
output: process.stdout
|
|
54
|
-
});
|
|
55
|
-
return new Promise((resolve) => {
|
|
56
|
-
this.printActionDetails(action);
|
|
57
|
-
const prompt = `
|
|
58
|
-
${chalk_1.default.bold.yellow('Proceed?')} (y/n/s)
|
|
59
|
-
${chalk_1.default.gray('y = yes, n = no, s = skip/modify')}: `;
|
|
60
|
-
rl.question(prompt, (answer) => {
|
|
61
|
-
const lower = answer.trim().toLowerCase();
|
|
62
|
-
if (lower === 'y' || lower === 'yes') {
|
|
63
|
-
rl.close();
|
|
64
|
-
resolve({ approve: true, modify: false });
|
|
65
|
-
}
|
|
66
|
-
else if (lower === 's' || lower === 'skip' || lower === 'modify') {
|
|
67
|
-
rl.close();
|
|
68
|
-
resolve({
|
|
69
|
-
approve: false,
|
|
70
|
-
modify: true,
|
|
71
|
-
reason: 'User wants to modify',
|
|
72
|
-
modifiedAction: { ...action }
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
rl.question(chalk_1.default.red('Reason for rejection: '), (reason) => {
|
|
77
|
-
rl.close();
|
|
78
|
-
resolve({
|
|
79
|
-
approve: false,
|
|
80
|
-
modify: false,
|
|
81
|
-
reason: reason || 'User rejected'
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
});
|
|
37
|
+
static getRules() {
|
|
38
|
+
return this.rules;
|
|
87
39
|
}
|
|
88
|
-
static
|
|
89
|
-
|
|
90
|
-
low: chalk_1.default.green,
|
|
91
|
-
medium: chalk_1.default.yellow,
|
|
92
|
-
high: chalk_1.default.red
|
|
93
|
-
};
|
|
94
|
-
console.log(`
|
|
95
|
-
${chalk_1.default.bold.cyan('═'.repeat(60))}
|
|
96
|
-
${chalk_1.default.bold.blue('📋 Action Proposed')}
|
|
97
|
-
${chalk_1.default.bold.cyan('═'.repeat(60))}
|
|
98
|
-
${chalk_1.default.white('Type:')} ${chalk_1.default.bold(action.type)}
|
|
99
|
-
${chalk_1.default.white('ID:')} ${action.id}
|
|
100
|
-
${chalk_1.default.white('Risk:')} ${riskColor[action.riskLevel](action.riskLevel.toUpperCase())}
|
|
101
|
-
|
|
102
|
-
${chalk_1.default.bold('Payload:')}
|
|
103
|
-
${chalk_1.default.gray(JSON.stringify(action.payload, null, 2))}
|
|
104
|
-
|
|
105
|
-
${chalk_1.default.bold('Reasoning:')}
|
|
106
|
-
${chalk_1.default.gray(action.reasoning)}
|
|
107
|
-
${chalk_1.default.bold.cyan('═'.repeat(60))}
|
|
108
|
-
`);
|
|
40
|
+
static getLedgerSnapshot() {
|
|
41
|
+
return this.ledger.getSnapshot();
|
|
109
42
|
}
|
|
110
|
-
static
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (mediumRiskTools.includes(toolName)) {
|
|
120
|
-
const cmd = payload.parameters?.command || payload.command || '';
|
|
121
|
-
if (this.containsDangerousCommand(cmd)) {
|
|
122
|
-
return 'high';
|
|
123
|
-
}
|
|
124
|
-
return 'medium';
|
|
125
|
-
}
|
|
126
|
-
return 'medium';
|
|
43
|
+
static getPolicyManual() {
|
|
44
|
+
return this.rules.map(r => `- ${r.id}: ${r.reason} (${r.effect})`).join('\n');
|
|
45
|
+
}
|
|
46
|
+
static async adjudicate(action) {
|
|
47
|
+
await this.init();
|
|
48
|
+
// 1. WASM 物理层核验
|
|
49
|
+
const wasmResult = bridge_1.WasmGovernanceBridge.evaluate(action, this.rules, this.ledger.getSnapshot());
|
|
50
|
+
if (wasmResult.effect === 'deny') {
|
|
51
|
+
return { status: 'rejected', by: 'policy', reason: wasmResult.reason || 'WASM Denied', timestamp: Date.now() };
|
|
127
52
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
return 'medium';
|
|
53
|
+
// 2. 逻辑层核验
|
|
54
|
+
const logicResult = (0, core_1.evaluateProposal)(action, this.rules, this.ledger.getSnapshot());
|
|
55
|
+
if (logicResult.effect === 'deny') {
|
|
56
|
+
return { status: 'rejected', by: 'policy', reason: logicResult.reason || 'Policy Denied', timestamp: Date.now() };
|
|
134
57
|
}
|
|
135
|
-
if (
|
|
136
|
-
|
|
58
|
+
if (logicResult.effect === 'allow') {
|
|
59
|
+
this.ledger.record(action.type);
|
|
60
|
+
return { status: 'approved', by: 'policy', timestamp: Date.now() };
|
|
137
61
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
static containsDangerousCommand(cmd) {
|
|
141
|
-
const dangerousPatterns = [
|
|
142
|
-
/rm\s+-rf\s+\//,
|
|
143
|
-
/rm\s+-rf\s+~/,
|
|
144
|
-
/>\s*\/dev\/null/,
|
|
145
|
-
/dd\s+if=/,
|
|
146
|
-
/mkfs/,
|
|
147
|
-
/format/,
|
|
148
|
-
/sudo\s+rm/
|
|
149
|
-
];
|
|
150
|
-
return dangerousPatterns.some(pattern => pattern.test(cmd));
|
|
62
|
+
// 3. 人工干预兜底 (模拟)
|
|
63
|
+
return { status: 'approved', by: 'human', timestamp: Date.now() };
|
|
151
64
|
}
|
|
152
65
|
}
|
|
153
66
|
exports.GovernanceService = GovernanceService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"governance.js","sourceRoot":"","sources":["../../src/agent/governance.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"governance.js","sourceRoot":"","sources":["../../src/agent/governance.ts"],"names":[],"mappings":";;;;;;AACA,4CAA4E;AAC5E,gDAAiD;AACjD,gDAA2D;AAC3D,sDAA6B;AAC7B,4CAAoB;AACpB,gDAAwB;AAExB,MAAa,iBAAiB;IACpB,MAAM,CAAC,KAAK,GAAiB,EAAE,CAAC;IAChC,MAAM,CAAC,MAAM,GAAG,IAAI,mBAAU,EAAE,CAAC;IACjC,MAAM,CAAC,WAAW,GAAG,KAAK,CAAC;IAEnC,MAAM,CAAC,KAAK,CAAC,IAAI;QACf,IAAI,IAAI,CAAC,WAAW;YAAE,OAAO;QAC7B,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,MAAM,6BAAoB,CAAC,IAAI,EAAE,CAAC;QAClC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IAEO,MAAM,CAAC,UAAU;QACvB,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,CAAC,CAAC;YAC3D,IAAI,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC9B,MAAM,OAAO,GAAG,YAAE,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;gBACpD,MAAM,MAAM,GAAG,iBAAM,CAAC,IAAI,CAAC,OAAO,CAAQ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M,EAAE,CAAC;YAClC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM,IAAI,eAAe,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;QACpH,CAAC;QAED,IAAI,WAAW,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;YACnC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAChC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;QACrE,CAAC;QAED,iBAAiB;QACjB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;IACpE,CAAC;;AA3DH,8CA4DC"}
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export * from './types';
|
|
1
|
+
export { AgentRuntime } from './AgentRuntime';
|
|
3
2
|
export * from './state';
|
|
4
|
-
export { GovernanceFSM } from './fsm';
|
|
5
|
-
export { GovernedAgentLoop } from './loop';
|
|
6
3
|
export { LLMAdapter } from './llmAdapter';
|
|
7
4
|
export { GovernanceService } from './governance';
|
|
8
5
|
export { ToolExecutor } from './executor';
|
|
9
6
|
export { ContextManager } from './contextManager';
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './replay';
|
|
7
|
+
export * from './skills';
|
package/dist/agent/index.js
CHANGED
|
@@ -14,15 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.ContextManager = exports.ToolExecutor = exports.GovernanceService = exports.LLMAdapter = exports.
|
|
18
|
-
var
|
|
19
|
-
Object.defineProperty(exports, "
|
|
20
|
-
__exportStar(require("./types"), exports);
|
|
17
|
+
exports.ContextManager = exports.ToolExecutor = exports.GovernanceService = exports.LLMAdapter = exports.AgentRuntime = void 0;
|
|
18
|
+
var AgentRuntime_1 = require("./AgentRuntime");
|
|
19
|
+
Object.defineProperty(exports, "AgentRuntime", { enumerable: true, get: function () { return AgentRuntime_1.AgentRuntime; } });
|
|
21
20
|
__exportStar(require("./state"), exports);
|
|
22
|
-
var fsm_1 = require("./fsm");
|
|
23
|
-
Object.defineProperty(exports, "GovernanceFSM", { enumerable: true, get: function () { return fsm_1.GovernanceFSM; } });
|
|
24
|
-
var loop_1 = require("./loop");
|
|
25
|
-
Object.defineProperty(exports, "GovernedAgentLoop", { enumerable: true, get: function () { return loop_1.GovernedAgentLoop; } });
|
|
26
21
|
var llmAdapter_1 = require("./llmAdapter");
|
|
27
22
|
Object.defineProperty(exports, "LLMAdapter", { enumerable: true, get: function () { return llmAdapter_1.LLMAdapter; } });
|
|
28
23
|
var governance_1 = require("./governance");
|
|
@@ -31,6 +26,5 @@ var executor_1 = require("./executor");
|
|
|
31
26
|
Object.defineProperty(exports, "ToolExecutor", { enumerable: true, get: function () { return executor_1.ToolExecutor; } });
|
|
32
27
|
var contextManager_1 = require("./contextManager");
|
|
33
28
|
Object.defineProperty(exports, "ContextManager", { enumerable: true, get: function () { return contextManager_1.ContextManager; } });
|
|
34
|
-
__exportStar(require("./
|
|
35
|
-
__exportStar(require("./replay"), exports);
|
|
29
|
+
__exportStar(require("./skills"), exports);
|
|
36
30
|
//# sourceMappingURL=index.js.map
|
package/dist/agent/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,0CAAwB;AACxB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,2CAAiD;AAAxC,+GAAA,iBAAiB,OAAA;AAC1B,uCAA0C;AAAjC,wGAAA,YAAY,OAAA;AACrB,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,2CAAyB"}
|