yuangs 2.28.0 → 2.30.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 +290 -0
- package/dist/agent/contextManager.d.ts +30 -0
- package/dist/agent/contextManager.js +65 -0
- package/dist/agent/contextManager.js.map +1 -0
- package/dist/agent/executor.d.ts +11 -0
- package/dist/agent/executor.js +191 -0
- package/dist/agent/executor.js.map +1 -0
- package/dist/agent/fsm.d.ts +23 -0
- package/dist/agent/fsm.js +95 -0
- package/dist/agent/fsm.js.map +1 -0
- package/dist/agent/governance.d.ts +10 -0
- package/dist/agent/governance.js +154 -0
- package/dist/agent/governance.js.map +1 -0
- package/dist/agent/index.d.ts +9 -0
- package/dist/agent/index.js +16 -1
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/llmAdapter.d.ts +6 -0
- package/dist/agent/llmAdapter.js +88 -0
- package/dist/agent/llmAdapter.js.map +1 -0
- package/dist/agent/loop.d.ts +21 -0
- package/dist/agent/loop.js +214 -0
- package/dist/agent/loop.js.map +1 -0
- package/dist/agent/policy/engine.d.ts +14 -0
- package/dist/agent/policy/engine.js +76 -0
- package/dist/agent/policy/engine.js.map +1 -0
- package/dist/agent/policy/index.d.ts +3 -0
- package/dist/agent/policy/index.js +20 -0
- package/dist/agent/policy/index.js.map +1 -0
- package/dist/agent/policy/policies/noDangerousShell.d.ts +7 -0
- package/dist/agent/policy/policies/noDangerousShell.js +45 -0
- package/dist/agent/policy/policies/noDangerousShell.js.map +1 -0
- package/dist/agent/policy/types.d.ts +23 -0
- package/dist/agent/policy/types.js +3 -0
- package/dist/agent/policy/types.js.map +1 -0
- package/dist/agent/replay/events.d.ts +21 -0
- package/dist/agent/replay/events.js +3 -0
- package/dist/agent/replay/events.js.map +1 -0
- package/dist/agent/replay/index.d.ts +3 -0
- package/dist/agent/replay/index.js +20 -0
- package/dist/agent/replay/index.js.map +1 -0
- package/dist/agent/replay/recorder.d.ts +11 -0
- package/dist/agent/replay/recorder.js +51 -0
- package/dist/agent/replay/recorder.js.map +1 -0
- package/dist/agent/replay/replayer.d.ts +21 -0
- package/dist/agent/replay/replayer.js +65 -0
- package/dist/agent/replay/replayer.js.map +1 -0
- package/dist/agent/selectModel.js +4 -11
- package/dist/agent/selectModel.js.map +1 -1
- package/dist/agent/skills.d.ts +5 -0
- package/dist/agent/skills.js +7 -3
- package/dist/agent/skills.js.map +1 -1
- package/dist/agent/state.d.ts +99 -0
- package/dist/agent/state.js +3 -0
- package/dist/agent/state.js.map +1 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +18 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/registryAPI.d.ts +22 -0
- package/dist/api/registryAPI.js +66 -0
- package/dist/api/registryAPI.js.map +1 -0
- package/dist/audit/index.d.ts +1 -0
- package/dist/audit/index.js +18 -0
- package/dist/audit/index.js.map +1 -0
- package/dist/audit/timeline.d.ts +75 -0
- package/dist/audit/timeline.js +254 -0
- package/dist/audit/timeline.js.map +1 -0
- package/dist/cli.js +10 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/explainCommands.d.ts +2 -0
- package/dist/commands/explainCommands.js +36 -0
- package/dist/commands/explainCommands.js.map +1 -0
- package/dist/commands/registryCommands.d.ts +2 -0
- package/dist/commands/registryCommands.js +243 -0
- package/dist/commands/registryCommands.js.map +1 -0
- package/dist/commands/replayCommands.d.ts +2 -0
- package/dist/commands/replayCommands.js +75 -0
- package/dist/commands/replayCommands.js.map +1 -0
- package/dist/commands/skillsCommands.d.ts +2 -0
- package/dist/commands/skillsCommands.js +114 -0
- package/dist/commands/skillsCommands.js.map +1 -0
- package/dist/core/executionRecord.d.ts +8 -0
- package/dist/core/executionRecord.js +2 -0
- package/dist/core/executionRecord.js.map +1 -1
- package/dist/core/explain.d.ts +8 -0
- package/dist/core/explain.js +84 -0
- package/dist/core/explain.js.map +1 -0
- package/dist/core/replayDiff.d.ts +55 -0
- package/dist/core/replayDiff.js +205 -0
- package/dist/core/replayDiff.js.map +1 -0
- package/dist/core/replayEngine.d.ts +3 -0
- package/dist/core/replayEngine.js +23 -1
- package/dist/core/replayEngine.js.map +1 -1
- package/dist/core/validation.d.ts +1 -1
- package/dist/core/validation.js +1 -1
- package/dist/core/validation.js.map +1 -1
- package/dist/registry/errors.d.ts +21 -0
- package/dist/registry/errors.js +35 -0
- package/dist/registry/errors.js.map +1 -0
- package/dist/registry/index.d.ts +3 -0
- package/dist/registry/index.js +20 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/manifest.d.ts +43 -0
- package/dist/registry/manifest.js +32 -0
- package/dist/registry/manifest.js.map +1 -0
- package/dist/registry/registry.d.ts +20 -0
- package/dist/registry/registry.js +201 -0
- package/dist/registry/registry.js.map +1 -0
- package/dist/risk/explainer.d.ts +39 -0
- package/dist/risk/explainer.js +214 -0
- package/dist/risk/explainer.js.map +1 -0
- package/dist/risk/index.d.ts +1 -0
- package/dist/risk/index.js +18 -0
- package/dist/risk/index.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -634,6 +634,296 @@ Then `yuangs` is for you.
|
|
|
634
634
|
|
|
635
635
|
## Status
|
|
636
636
|
|
|
637
|
+
`yuangs` is actively evolving.
|
|
638
|
+
The core governance model is stable; interfaces are still sharpening.
|
|
639
|
+
|
|
640
|
+
Contributions, ideas, and principled criticism are welcome.
|
|
641
|
+
|
|
642
|
+
> **"AI should never appear smarter than input unless explicitly asked."**
|
|
643
|
+
|
|
644
|
+
---
|
|
645
|
+
|
|
646
|
+
# Phase 2: Explainability & Governance (v1)
|
|
647
|
+
|
|
648
|
+
## 🎯 Overview
|
|
649
|
+
|
|
650
|
+
Phase 2 introduces **system observability and control** without changing core behavior:
|
|
651
|
+
- ✅ Explainability: Human-readable execution explanations
|
|
652
|
+
- ✅ Replay++: Dry-run, explain, and diff capabilities
|
|
653
|
+
- ✅ Skill Control: Enable/disable skills for fine-grained control
|
|
654
|
+
|
|
655
|
+
---
|
|
656
|
+
|
|
657
|
+
## 📦 New Commands
|
|
658
|
+
|
|
659
|
+
### `yuangs explain [id | last]`
|
|
660
|
+
|
|
661
|
+
**Purpose**: Explain why the system made a decision
|
|
662
|
+
|
|
663
|
+
**Usage**:
|
|
664
|
+
```bash
|
|
665
|
+
# Explain the most recent execution
|
|
666
|
+
yuangs explain last
|
|
667
|
+
|
|
668
|
+
# Explain a specific execution by ID
|
|
669
|
+
yuangs explain exec_1768820380225_rgts34981
|
|
670
|
+
```
|
|
671
|
+
|
|
672
|
+
**Output Format (v1)**:
|
|
673
|
+
```
|
|
674
|
+
=== Execution Explanation ===
|
|
675
|
+
[1] Command
|
|
676
|
+
- Name: ai-command
|
|
677
|
+
- Args: echo "hello"
|
|
678
|
+
|
|
679
|
+
[2] Decision
|
|
680
|
+
- Strategy: capability-match
|
|
681
|
+
- Selected Model: gemini-2.5-flash-lite
|
|
682
|
+
- Reason: Capability-based selection with fallback support
|
|
683
|
+
|
|
684
|
+
[3] Model
|
|
685
|
+
- Name: gemini-2.5-flash-lite
|
|
686
|
+
- Provider: aiproxy
|
|
687
|
+
- Context Window: 8000
|
|
688
|
+
- Cost Profile: low
|
|
689
|
+
|
|
690
|
+
[4] Skills
|
|
691
|
+
- (none)
|
|
692
|
+
|
|
693
|
+
[5] Meta
|
|
694
|
+
- Execution ID: exec_1768820380225_rgts34981
|
|
695
|
+
- Timestamp: 2026-01-19T10:59:40.225Z
|
|
696
|
+
- Replayable: true
|
|
697
|
+
- Version: unknown
|
|
698
|
+
=============================
|
|
699
|
+
```
|
|
700
|
+
|
|
701
|
+
**Key Features**:
|
|
702
|
+
- ✅ Pure read-only operation (no side effects)
|
|
703
|
+
- ✅ Stable, snapshot-able output
|
|
704
|
+
- ✅ Future-proof for diff/audit workflows
|
|
705
|
+
|
|
706
|
+
---
|
|
707
|
+
|
|
708
|
+
### `yuangs replay <id> [options]`
|
|
709
|
+
|
|
710
|
+
**Purpose**: Replay an execution with control flags
|
|
711
|
+
|
|
712
|
+
**Options**:
|
|
713
|
+
| Option | Description |
|
|
714
|
+
|--------|-------------|
|
|
715
|
+
| `-s, --strict` | Strict replay (use exact model) |
|
|
716
|
+
| `-c, --compatible` | Compatible replay (allow fallback) |
|
|
717
|
+
| `-r, --re-evaluate` | Re-evaluate with current config |
|
|
718
|
+
| `-v, --verbose` | Verbose output |
|
|
719
|
+
| `--dry` | Dry run - show what would happen without executing |
|
|
720
|
+
| `--explain` | Show explanation before replay |
|
|
721
|
+
| `--diff` | Show diff between original and current config |
|
|
722
|
+
|
|
723
|
+
**Usage Examples**:
|
|
724
|
+
```bash
|
|
725
|
+
# Dry run with explanation
|
|
726
|
+
yuangs replay exec_1768820380225_rgts34981 --dry --explain
|
|
727
|
+
|
|
728
|
+
# Show diff only (no execution)
|
|
729
|
+
yuangs replay exec_1768820380225_rgts34981 --diff --dry
|
|
730
|
+
|
|
731
|
+
# Full replay with diff
|
|
732
|
+
yuangs replay exec_1768820380225_rgts34981 --diff
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
**Replay Behavior Matrix**:
|
|
736
|
+
| explain | dry | strict | Behavior |
|
|
737
|
+
|--------|-----|--------|----------|
|
|
738
|
+
| ✅ | ✅ | any | Explain only, no execution |
|
|
739
|
+
| ✅ | ❌ | ✅ | Explain → Replay |
|
|
740
|
+
| ❌ | ✅ | ✅ | Print strict info → Exit |
|
|
741
|
+
| ❌ | ❌ | ✅ | Normal replay |
|
|
742
|
+
|
|
743
|
+
**Diff Output**:
|
|
744
|
+
```
|
|
745
|
+
=== Replay Diff ===
|
|
746
|
+
[Decision]
|
|
747
|
+
- no change
|
|
748
|
+
|
|
749
|
+
[Model]
|
|
750
|
+
- no change
|
|
751
|
+
|
|
752
|
+
[Skills]
|
|
753
|
+
- no change
|
|
754
|
+
===================
|
|
755
|
+
```
|
|
756
|
+
|
|
757
|
+
---
|
|
758
|
+
|
|
759
|
+
### `yuangs skills <subcommand>`
|
|
760
|
+
|
|
761
|
+
**Purpose**: Manage skill library
|
|
762
|
+
|
|
763
|
+
**Subcommands**:
|
|
764
|
+
```bash
|
|
765
|
+
# List all skills with scores
|
|
766
|
+
yuangs skills list
|
|
767
|
+
|
|
768
|
+
# Explain a specific skill
|
|
769
|
+
yuangs skills explain <skill-name>
|
|
770
|
+
|
|
771
|
+
# Disable a skill
|
|
772
|
+
yuangs skills disable <skill-name>
|
|
773
|
+
|
|
774
|
+
# Enable a skill
|
|
775
|
+
yuangs skills enable <skill-name>
|
|
776
|
+
```
|
|
777
|
+
|
|
778
|
+
**Output Example** (`skills list`):
|
|
779
|
+
```
|
|
780
|
+
📦 Skills (3)
|
|
781
|
+
|
|
782
|
+
✔ deploy-production
|
|
783
|
+
Confidence: 72%
|
|
784
|
+
Success: 8 / Failure: 1
|
|
785
|
+
Last used: 2 days ago
|
|
786
|
+
|
|
787
|
+
✔ cleanup-logs
|
|
788
|
+
Confidence: 41%
|
|
789
|
+
Success: 5 / Failure: 7
|
|
790
|
+
Last used: 1 day ago
|
|
791
|
+
|
|
792
|
+
⊘ legacy-search (disabled)
|
|
793
|
+
Confidence: 23%
|
|
794
|
+
Success: 2 / Failure: 6
|
|
795
|
+
Last used: 7 days ago
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
**Key Features**:
|
|
799
|
+
- ✅ Skills can be disabled without deletion
|
|
800
|
+
- ✅ Skills are scored and sorted by relevance
|
|
801
|
+
- ✅ Disabled skills don't affect new decisions
|
|
802
|
+
- ✅ All skills remain visible in `explain` output
|
|
803
|
+
|
|
804
|
+
---
|
|
805
|
+
|
|
806
|
+
## 🧭 Explain Output Spec v1
|
|
807
|
+
|
|
808
|
+
The explain output follows a strict format designed for:
|
|
809
|
+
- ✅ Human readability
|
|
810
|
+
- ✅ Stability and snapshot compatibility
|
|
811
|
+
- ✅ Future diff/audit workflows
|
|
812
|
+
- ✅ No implementation coupling
|
|
813
|
+
|
|
814
|
+
**Structure** (5 sections, immutable order):
|
|
815
|
+
1. `[1] Command` - User input layer
|
|
816
|
+
2. `[2] Decision` - Decision-making core
|
|
817
|
+
3. `[3] Model` - Execution environment
|
|
818
|
+
4. `[4] Skills` - Skills that influenced decision
|
|
819
|
+
5. `[5] Meta` - Audit/replay metadata
|
|
820
|
+
|
|
821
|
+
**Important Notes**:
|
|
822
|
+
- ⚠️ Do NOT change format without bumping spec version
|
|
823
|
+
- ✅ Output is pure text (no color for snapshots)
|
|
824
|
+
- ✅ Same execution record = 100% reproducible output
|
|
825
|
+
|
|
826
|
+
---
|
|
827
|
+
|
|
828
|
+
## 🔒 Skills & Enabled State
|
|
829
|
+
|
|
830
|
+
Skills now have an `enabled` field that controls their participation in new decisions:
|
|
831
|
+
|
|
832
|
+
**Default Behavior**:
|
|
833
|
+
- ✅ New skills: `enabled: true`
|
|
834
|
+
- ✅ Legacy skills: `enabled: true` (if field missing)
|
|
835
|
+
- ❌ Disabled skills: Not included in `getRelevantSkills()`
|
|
836
|
+
|
|
837
|
+
**Use Cases**:
|
|
838
|
+
1. **Governance**: Temporarily disable risky skills
|
|
839
|
+
2. **A/B Testing**: Compare different skill configurations
|
|
840
|
+
3. **Rollback**: Disable a newly-added skill without deletion
|
|
841
|
+
4. **Audit**: View disabled skills in explain output
|
|
842
|
+
|
|
843
|
+
**CLI Commands**:
|
|
844
|
+
```bash
|
|
845
|
+
# Disable a skill
|
|
846
|
+
yuangs skills disable risky-operation
|
|
847
|
+
|
|
848
|
+
# List to verify
|
|
849
|
+
yuangs skills list
|
|
850
|
+
|
|
851
|
+
# Re-enable if needed
|
|
852
|
+
yuangs skills enable risky-operation
|
|
853
|
+
```
|
|
854
|
+
|
|
855
|
+
---
|
|
856
|
+
|
|
857
|
+
## 🧪 Testing & Snapshots
|
|
858
|
+
|
|
859
|
+
### Creating Explain Snapshots
|
|
860
|
+
|
|
861
|
+
```bash
|
|
862
|
+
# Create a snapshot of the last execution
|
|
863
|
+
yuangs replay exec_1768820380225_rgts34981 --explain --dry > snapshot.txt
|
|
864
|
+
```
|
|
865
|
+
|
|
866
|
+
Snapshots are useful for:
|
|
867
|
+
- ✅ Regression testing
|
|
868
|
+
- ✅ Output format verification
|
|
869
|
+
- ✅ Documentation examples
|
|
870
|
+
- ✅ Audit trails
|
|
871
|
+
|
|
872
|
+
---
|
|
873
|
+
|
|
874
|
+
## 📝 Implementation Notes
|
|
875
|
+
|
|
876
|
+
### Explain Output v1
|
|
877
|
+
|
|
878
|
+
**File**: `src/core/explain.ts`
|
|
879
|
+
|
|
880
|
+
**Key Design**:
|
|
881
|
+
- Pure function (no side effects)
|
|
882
|
+
- No external dependencies on global state
|
|
883
|
+
- Uses existing `ExecutionRecord` structure
|
|
884
|
+
- Stable formatting (versioned)
|
|
885
|
+
|
|
886
|
+
---
|
|
887
|
+
|
|
888
|
+
### Replay Diff
|
|
889
|
+
|
|
890
|
+
**File**: `src/core/replayDiff.ts`
|
|
891
|
+
|
|
892
|
+
**Key Design**:
|
|
893
|
+
- Compares Decision, Model, and Skills layers
|
|
894
|
+
- Shows added/removed/changed skills
|
|
895
|
+
- Semantic diff (not token-level)
|
|
896
|
+
- Compatible with Explain v1 format
|
|
897
|
+
|
|
898
|
+
---
|
|
899
|
+
|
|
900
|
+
### Skills Control
|
|
901
|
+
|
|
902
|
+
**File**: `src/agent/skills.ts`
|
|
903
|
+
|
|
904
|
+
**Key Changes**:
|
|
905
|
+
- Added `enabled: boolean` field to `Skill` interface
|
|
906
|
+
- Exported `computeSkillScore()` for CLI usage
|
|
907
|
+
- `getRelevantSkills()` filters disabled skills
|
|
908
|
+
|
|
909
|
+
---
|
|
910
|
+
|
|
911
|
+
## ✅ Phase 2 Completion
|
|
912
|
+
|
|
913
|
+
All Phase 2 objectives are complete:
|
|
914
|
+
|
|
915
|
+
- [x] Explainability (ExecutionRecord-level)
|
|
916
|
+
- [x] Replay dry / explain / strict
|
|
917
|
+
- [x] Skill scoring & enable flag
|
|
918
|
+
- [x] CLI wiring for all three
|
|
919
|
+
- [x] Replay diff implementation
|
|
920
|
+
- [x] Skills enabled filtering
|
|
921
|
+
- [x] Explain v1 specification
|
|
922
|
+
- [x] Snapshot testing capability
|
|
923
|
+
|
|
924
|
+
**Next Phase**: Phase 3 - Advanced governance & project-level intelligence
|
|
925
|
+
|
|
926
|
+
|
|
637
927
|
`yuangs` is actively evolving.
|
|
638
928
|
The core governance model is stable; interfaces are still sharpening.
|
|
639
929
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { GovernanceContext } from './state';
|
|
2
|
+
export declare class ContextManager {
|
|
3
|
+
private messages;
|
|
4
|
+
private maxHistorySize;
|
|
5
|
+
constructor(initialContext?: GovernanceContext);
|
|
6
|
+
addMessage(role: string, content: string): void;
|
|
7
|
+
addToolResult(toolName: string, result: string): void;
|
|
8
|
+
addObservation(observation: string): void;
|
|
9
|
+
getMessages(): Array<{
|
|
10
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
11
|
+
content: string;
|
|
12
|
+
}>;
|
|
13
|
+
getRecentMessages(count: number): Array<{
|
|
14
|
+
role: string;
|
|
15
|
+
content: string;
|
|
16
|
+
timestamp: number;
|
|
17
|
+
}>;
|
|
18
|
+
getHash(): string;
|
|
19
|
+
getSnapshot(): {
|
|
20
|
+
inputHash: string;
|
|
21
|
+
systemPromptVersion: string;
|
|
22
|
+
toolSetVersion: string;
|
|
23
|
+
recentMessages: {
|
|
24
|
+
role: string;
|
|
25
|
+
content: string;
|
|
26
|
+
timestamp: number;
|
|
27
|
+
}[];
|
|
28
|
+
};
|
|
29
|
+
clear(): void;
|
|
30
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ContextManager = void 0;
|
|
7
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
+
class ContextManager {
|
|
9
|
+
messages = [];
|
|
10
|
+
maxHistorySize = 50;
|
|
11
|
+
constructor(initialContext) {
|
|
12
|
+
if (initialContext?.history) {
|
|
13
|
+
this.messages = initialContext.history.map(msg => ({
|
|
14
|
+
...msg,
|
|
15
|
+
timestamp: Date.now()
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
if (initialContext?.input) {
|
|
19
|
+
this.addMessage('user', initialContext.input);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
addMessage(role, content) {
|
|
23
|
+
this.messages.push({
|
|
24
|
+
role,
|
|
25
|
+
content,
|
|
26
|
+
timestamp: Date.now()
|
|
27
|
+
});
|
|
28
|
+
if (this.messages.length > this.maxHistorySize) {
|
|
29
|
+
this.messages = this.messages.slice(-this.maxHistorySize);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
addToolResult(toolName, result) {
|
|
33
|
+
const content = `Tool ${toolName} returned:\n${result}`;
|
|
34
|
+
this.addMessage('tool', content);
|
|
35
|
+
}
|
|
36
|
+
addObservation(observation) {
|
|
37
|
+
this.addMessage('system', observation);
|
|
38
|
+
}
|
|
39
|
+
getMessages() {
|
|
40
|
+
return this.messages.map(({ role, content }) => ({
|
|
41
|
+
role: role,
|
|
42
|
+
content
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
getRecentMessages(count) {
|
|
46
|
+
return this.messages.slice(-count);
|
|
47
|
+
}
|
|
48
|
+
getHash() {
|
|
49
|
+
const content = JSON.stringify(this.messages);
|
|
50
|
+
return crypto_1.default.createHash('sha256').update(content).digest('hex');
|
|
51
|
+
}
|
|
52
|
+
getSnapshot() {
|
|
53
|
+
return {
|
|
54
|
+
inputHash: this.getHash(),
|
|
55
|
+
systemPromptVersion: 'v1.0.0',
|
|
56
|
+
toolSetVersion: 'v1.0.0',
|
|
57
|
+
recentMessages: this.getRecentMessages(10)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
clear() {
|
|
61
|
+
this.messages = [];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.ContextManager = ContextManager;
|
|
65
|
+
//# sourceMappingURL=contextManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextManager.js","sourceRoot":"","sources":["../../src/agent/contextManager.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAG5B,MAAa,cAAc;IACjB,QAAQ,GAAgE,EAAE,CAAC;IAC3E,cAAc,GAAG,EAAE,CAAC;IAE5B,YAAY,cAAkC;QAC5C,IAAI,cAAc,EAAE,OAAO,EAAE,CAAC;YAC5B,IAAI,CAAC,QAAQ,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBACjD,GAAG,GAAG;gBACN,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;aACtB,CAAC,CAAC,CAAC;QACN,CAAC;QAED,IAAI,cAAc,EAAE,KAAK,EAAE,CAAC;YAC1B,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED,UAAU,CAAC,IAAY,EAAE,OAAe;QACtC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YACjB,IAAI;YACJ,OAAO;YACP,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;SACtB,CAAC,CAAC;QAEH,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;YAC/C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,aAAa,CAAC,QAAgB,EAAE,MAAc;QAC5C,MAAM,OAAO,GAAG,QAAQ,QAAQ,eAAe,MAAM,EAAE,CAAC;QACxD,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,cAAc,CAAC,WAAmB;QAChC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;IACzC,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;YAC/C,IAAI,EAAE,IAAgD;YACtD,OAAO;SACR,CAAC,CAAC,CAAC;IACN,CAAC;IAED,iBAAiB,CAAC,KAAa;QAC7B,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED,OAAO;QACL,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9C,OAAO,gBAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACnE,CAAC;IAED,WAAW;QACT,OAAO;YACL,SAAS,EAAE,IAAI,CAAC,OAAO,EAAE;YACzB,mBAAmB,EAAE,QAAQ;YAC7B,cAAc,EAAE,QAAQ;YACxB,cAAc,EAAE,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAAC;SAC3C,CAAC;IACJ,CAAC;IAED,KAAK;QACH,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;IACrB,CAAC;CACF;AAlED,wCAkEC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ProposedAction, ToolExecutionResult } from './state';
|
|
2
|
+
export declare class ToolExecutor {
|
|
3
|
+
static execute(action: ProposedAction): Promise<ToolExecutionResult>;
|
|
4
|
+
private static executeTool;
|
|
5
|
+
private static toolReadFile;
|
|
6
|
+
private static toolWriteFile;
|
|
7
|
+
private static toolListFiles;
|
|
8
|
+
private static getFiles;
|
|
9
|
+
private static executeShell;
|
|
10
|
+
private static executeDiff;
|
|
11
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ToolExecutor = void 0;
|
|
7
|
+
const child_process_1 = require("child_process");
|
|
8
|
+
const util_1 = require("util");
|
|
9
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
12
|
+
class ToolExecutor {
|
|
13
|
+
static async execute(action) {
|
|
14
|
+
const { type, payload } = action;
|
|
15
|
+
try {
|
|
16
|
+
switch (type) {
|
|
17
|
+
case 'tool_call':
|
|
18
|
+
return await this.executeTool(payload);
|
|
19
|
+
case 'shell_cmd':
|
|
20
|
+
return await this.executeShell(payload.command);
|
|
21
|
+
case 'code_diff':
|
|
22
|
+
return await this.executeDiff(payload.diff);
|
|
23
|
+
case 'answer':
|
|
24
|
+
return {
|
|
25
|
+
success: true,
|
|
26
|
+
output: payload.content || '',
|
|
27
|
+
artifacts: []
|
|
28
|
+
};
|
|
29
|
+
default:
|
|
30
|
+
return {
|
|
31
|
+
success: false,
|
|
32
|
+
error: `Unknown action type: ${type}`,
|
|
33
|
+
output: ''
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
return {
|
|
39
|
+
success: false,
|
|
40
|
+
error: error.message || String(error),
|
|
41
|
+
output: ''
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
static async executeTool(payload) {
|
|
46
|
+
const toolName = payload.tool_name;
|
|
47
|
+
switch (toolName) {
|
|
48
|
+
case 'read_file':
|
|
49
|
+
return await this.toolReadFile(payload.parameters);
|
|
50
|
+
case 'write_file':
|
|
51
|
+
return await this.toolWriteFile(payload.parameters);
|
|
52
|
+
case 'list_files':
|
|
53
|
+
return await this.toolListFiles(payload.parameters);
|
|
54
|
+
case 'web_search':
|
|
55
|
+
return {
|
|
56
|
+
success: false,
|
|
57
|
+
error: 'web_search not implemented yet',
|
|
58
|
+
output: ''
|
|
59
|
+
};
|
|
60
|
+
default:
|
|
61
|
+
return {
|
|
62
|
+
success: false,
|
|
63
|
+
error: `Unknown tool: ${toolName}`,
|
|
64
|
+
output: ''
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
static async toolReadFile(params) {
|
|
69
|
+
const filePath = params.path;
|
|
70
|
+
try {
|
|
71
|
+
const content = await promises_1.default.readFile(filePath, 'utf-8');
|
|
72
|
+
return {
|
|
73
|
+
success: true,
|
|
74
|
+
output: content,
|
|
75
|
+
artifacts: [filePath]
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
return {
|
|
80
|
+
success: false,
|
|
81
|
+
error: error.message,
|
|
82
|
+
output: ''
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
static async toolWriteFile(params) {
|
|
87
|
+
const filePath = params.path;
|
|
88
|
+
const content = params.content;
|
|
89
|
+
try {
|
|
90
|
+
await promises_1.default.mkdir(path_1.default.dirname(filePath), { recursive: true });
|
|
91
|
+
await promises_1.default.writeFile(filePath, content, 'utf-8');
|
|
92
|
+
return {
|
|
93
|
+
success: true,
|
|
94
|
+
output: `Successfully wrote ${filePath}`,
|
|
95
|
+
artifacts: [filePath]
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
return {
|
|
100
|
+
success: false,
|
|
101
|
+
error: error.message,
|
|
102
|
+
output: ''
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
static async toolListFiles(params) {
|
|
107
|
+
const dirPath = params.path || '.';
|
|
108
|
+
const recursive = params.recursive || false;
|
|
109
|
+
try {
|
|
110
|
+
const files = await this.getFiles(dirPath, recursive);
|
|
111
|
+
return {
|
|
112
|
+
success: true,
|
|
113
|
+
output: JSON.stringify(files, null, 2),
|
|
114
|
+
artifacts: files.map(f => f.path)
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
return {
|
|
119
|
+
success: false,
|
|
120
|
+
error: error.message,
|
|
121
|
+
output: ''
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
static async getFiles(dir, recursive) {
|
|
126
|
+
const entries = await promises_1.default.readdir(dir, { withFileTypes: true });
|
|
127
|
+
const files = [];
|
|
128
|
+
for (const entry of entries) {
|
|
129
|
+
const fullPath = path_1.default.join(dir, entry.name);
|
|
130
|
+
if (entry.isDirectory()) {
|
|
131
|
+
files.push({ path: fullPath, type: 'directory' });
|
|
132
|
+
if (recursive) {
|
|
133
|
+
const subFiles = await this.getFiles(fullPath, recursive);
|
|
134
|
+
files.push(...subFiles);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
files.push({ path: fullPath, type: 'file' });
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return files;
|
|
142
|
+
}
|
|
143
|
+
static async executeShell(command) {
|
|
144
|
+
try {
|
|
145
|
+
const { stdout, stderr } = await execAsync(command, {
|
|
146
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
147
|
+
cwd: process.cwd()
|
|
148
|
+
});
|
|
149
|
+
const output = stdout || stderr || '';
|
|
150
|
+
return {
|
|
151
|
+
success: true,
|
|
152
|
+
output,
|
|
153
|
+
artifacts: []
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
return {
|
|
158
|
+
success: false,
|
|
159
|
+
error: error.message,
|
|
160
|
+
output: error.stdout || error.stderr || ''
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
static async executeDiff(diff) {
|
|
165
|
+
try {
|
|
166
|
+
const tempFile = path_1.default.join(process.cwd(), '.yuangs_temp.patch');
|
|
167
|
+
await promises_1.default.writeFile(tempFile, diff, 'utf-8');
|
|
168
|
+
const { stdout, stderr } = await execAsync(`git apply --check ${tempFile}`, {
|
|
169
|
+
cwd: process.cwd()
|
|
170
|
+
});
|
|
171
|
+
const { stdout: applyOutput } = await execAsync(`git apply ${tempFile}`, {
|
|
172
|
+
cwd: process.cwd()
|
|
173
|
+
});
|
|
174
|
+
await promises_1.default.unlink(tempFile);
|
|
175
|
+
return {
|
|
176
|
+
success: true,
|
|
177
|
+
output: applyOutput || 'Diff applied successfully',
|
|
178
|
+
artifacts: ['.yuangs_temp.patch']
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
return {
|
|
183
|
+
success: false,
|
|
184
|
+
error: error.message,
|
|
185
|
+
output: error.stdout || error.stderr || 'Failed to apply diff'
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
exports.ToolExecutor = ToolExecutor;
|
|
191
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/agent/executor.ts"],"names":[],"mappings":";;;;;;AAAA,iDAAqC;AACrC,+BAAiC;AACjC,2DAA6B;AAC7B,gDAAwB;AAGxB,MAAM,SAAS,GAAG,IAAA,gBAAS,EAAC,oBAAI,CAAC,CAAC;AAElC,MAAa,YAAY;IACvB,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAsB;QACzC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;QAEjC,IAAI,CAAC;YACH,QAAQ,IAAI,EAAE,CAAC;gBACb,KAAK,WAAW;oBACd,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;gBAEzC,KAAK,WAAW;oBACd,OAAO,MAAM,IA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AAQ,EAAE,EAAE;gBAC1E,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;aACnB,CAAC,CAAC;YAEH,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,SAAS,CAAC,aAAa,QAAQ,EAAE,EAAE;gBACvE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;aACnB,CAAC,CAAC;YAEH,MAAM,kBAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAE1B,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,MAAM,EAAE,WAAW,IAAI,2BAA2B;gBAClD,SAAS,EAAE,CAAC,oBAAoB,CAAC;aAClC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,KAAK,CAAC,OAAO;gBACpB,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,IAAI,sBAAsB;aAC/D,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAtMD,oCAsMC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AgentState } from './state';
|
|
2
|
+
export declare class GovernanceFSM {
|
|
3
|
+
private _state;
|
|
4
|
+
private _history;
|
|
5
|
+
private _transitionLog;
|
|
6
|
+
get current(): AgentState;
|
|
7
|
+
get history(): AgentState[];
|
|
8
|
+
get transitionLog(): Array<{
|
|
9
|
+
from: AgentState;
|
|
10
|
+
to: AgentState;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
payload?: any;
|
|
13
|
+
}>;
|
|
14
|
+
transitionTo(target: AgentState, payload?: any): void;
|
|
15
|
+
private canTransition;
|
|
16
|
+
isTerminal(): boolean;
|
|
17
|
+
reset(): void;
|
|
18
|
+
getStateInfo(): {
|
|
19
|
+
current: AgentState;
|
|
20
|
+
history: AgentState[];
|
|
21
|
+
transitionCount: number;
|
|
22
|
+
};
|
|
23
|
+
}
|