create-agentfs 0.1.1
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/LICENSE +21 -0
- package/README.md +238 -0
- package/dist/cli.d.ts +51 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +246 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/compile.d.ts +48 -0
- package/dist/commands/compile.d.ts.map +1 -0
- package/dist/commands/compile.js +228 -0
- package/dist/commands/compile.js.map +1 -0
- package/dist/commands/cron.d.ts +18 -0
- package/dist/commands/cron.d.ts.map +1 -0
- package/dist/commands/cron.js +95 -0
- package/dist/commands/cron.js.map +1 -0
- package/dist/commands/doctor.d.ts +11 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +199 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/memory.d.ts +19 -0
- package/dist/commands/memory.d.ts.map +1 -0
- package/dist/commands/memory.js +213 -0
- package/dist/commands/memory.js.map +1 -0
- package/dist/commands/onboard.d.ts +31 -0
- package/dist/commands/onboard.d.ts.map +1 -0
- package/dist/commands/onboard.js +362 -0
- package/dist/commands/onboard.js.map +1 -0
- package/dist/commands/secret.d.ts +13 -0
- package/dist/commands/secret.d.ts.map +1 -0
- package/dist/commands/secret.js +109 -0
- package/dist/commands/secret.js.map +1 -0
- package/dist/commands/security.d.ts +16 -0
- package/dist/commands/security.d.ts.map +1 -0
- package/dist/commands/security.js +203 -0
- package/dist/commands/security.js.map +1 -0
- package/dist/commands/sync.d.ts +14 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +84 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/compilers/agent-map.d.ts +34 -0
- package/dist/compilers/agent-map.d.ts.map +1 -0
- package/dist/compilers/agent-map.js +66 -0
- package/dist/compilers/agent-map.js.map +1 -0
- package/dist/compilers/base.d.ts +67 -0
- package/dist/compilers/base.d.ts.map +1 -0
- package/dist/compilers/base.js +183 -0
- package/dist/compilers/base.js.map +1 -0
- package/dist/compilers/claude.d.ts +26 -0
- package/dist/compilers/claude.d.ts.map +1 -0
- package/dist/compilers/claude.js +151 -0
- package/dist/compilers/claude.js.map +1 -0
- package/dist/compilers/cursor.d.ts +11 -0
- package/dist/compilers/cursor.d.ts.map +1 -0
- package/dist/compilers/cursor.js +52 -0
- package/dist/compilers/cursor.js.map +1 -0
- package/dist/compilers/index.d.ts +14 -0
- package/dist/compilers/index.d.ts.map +1 -0
- package/dist/compilers/index.js +14 -0
- package/dist/compilers/index.js.map +1 -0
- package/dist/compilers/openclaw.d.ts +12 -0
- package/dist/compilers/openclaw.d.ts.map +1 -0
- package/dist/compilers/openclaw.js +51 -0
- package/dist/compilers/openclaw.js.map +1 -0
- package/dist/cron/index.d.ts +10 -0
- package/dist/cron/index.d.ts.map +1 -0
- package/dist/cron/index.js +9 -0
- package/dist/cron/index.js.map +1 -0
- package/dist/cron/jobs/consolidate.d.ts +16 -0
- package/dist/cron/jobs/consolidate.d.ts.map +1 -0
- package/dist/cron/jobs/consolidate.js +61 -0
- package/dist/cron/jobs/consolidate.js.map +1 -0
- package/dist/cron/jobs/heartbeat.d.ts +11 -0
- package/dist/cron/jobs/heartbeat.d.ts.map +1 -0
- package/dist/cron/jobs/heartbeat.js +66 -0
- package/dist/cron/jobs/heartbeat.js.map +1 -0
- package/dist/cron/jobs/inbox-triage.d.ts +11 -0
- package/dist/cron/jobs/inbox-triage.d.ts.map +1 -0
- package/dist/cron/jobs/inbox-triage.js +85 -0
- package/dist/cron/jobs/inbox-triage.js.map +1 -0
- package/dist/cron/runner.d.ts +32 -0
- package/dist/cron/runner.d.ts.map +1 -0
- package/dist/cron/runner.js +69 -0
- package/dist/cron/runner.js.map +1 -0
- package/dist/cron/types.d.ts +21 -0
- package/dist/cron/types.d.ts.map +1 -0
- package/dist/cron/types.js +6 -0
- package/dist/cron/types.js.map +1 -0
- package/dist/generators/filesystem.d.ts +52 -0
- package/dist/generators/filesystem.d.ts.map +1 -0
- package/dist/generators/filesystem.js +155 -0
- package/dist/generators/filesystem.js.map +1 -0
- package/dist/generators/ignore.d.ts +38 -0
- package/dist/generators/ignore.d.ts.map +1 -0
- package/dist/generators/ignore.js +154 -0
- package/dist/generators/ignore.js.map +1 -0
- package/dist/generators/index.d.ts +14 -0
- package/dist/generators/index.d.ts.map +1 -0
- package/dist/generators/index.js +14 -0
- package/dist/generators/index.js.map +1 -0
- package/dist/generators/init.d.ts +37 -0
- package/dist/generators/init.d.ts.map +1 -0
- package/dist/generators/init.js +169 -0
- package/dist/generators/init.js.map +1 -0
- package/dist/generators/manifest.d.ts +31 -0
- package/dist/generators/manifest.d.ts.map +1 -0
- package/dist/generators/manifest.js +123 -0
- package/dist/generators/manifest.js.map +1 -0
- package/dist/generators/memory.d.ts +36 -0
- package/dist/generators/memory.d.ts.map +1 -0
- package/dist/generators/memory.js +106 -0
- package/dist/generators/memory.js.map +1 -0
- package/dist/generators/profiles.d.ts +22 -0
- package/dist/generators/profiles.d.ts.map +1 -0
- package/dist/generators/profiles.js +92 -0
- package/dist/generators/profiles.js.map +1 -0
- package/dist/generators/prompts.d.ts +24 -0
- package/dist/generators/prompts.d.ts.map +1 -0
- package/dist/generators/prompts.js +122 -0
- package/dist/generators/prompts.js.map +1 -0
- package/dist/generators/scaffold.d.ts +29 -0
- package/dist/generators/scaffold.d.ts.map +1 -0
- package/dist/generators/scaffold.js +90 -0
- package/dist/generators/scaffold.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/memory/confidence.d.ts +69 -0
- package/dist/memory/confidence.d.ts.map +1 -0
- package/dist/memory/confidence.js +125 -0
- package/dist/memory/confidence.js.map +1 -0
- package/dist/memory/episodic.d.ts +40 -0
- package/dist/memory/episodic.d.ts.map +1 -0
- package/dist/memory/episodic.js +139 -0
- package/dist/memory/episodic.js.map +1 -0
- package/dist/memory/index.d.ts +17 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +17 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/parser.d.ts +73 -0
- package/dist/memory/parser.d.ts.map +1 -0
- package/dist/memory/parser.js +156 -0
- package/dist/memory/parser.js.map +1 -0
- package/dist/memory/procedural.d.ts +43 -0
- package/dist/memory/procedural.d.ts.map +1 -0
- package/dist/memory/procedural.js +126 -0
- package/dist/memory/procedural.js.map +1 -0
- package/dist/secrets/exfil-guard.d.ts +31 -0
- package/dist/secrets/exfil-guard.d.ts.map +1 -0
- package/dist/secrets/exfil-guard.js +51 -0
- package/dist/secrets/exfil-guard.js.map +1 -0
- package/dist/secrets/index.d.ts +8 -0
- package/dist/secrets/index.d.ts.map +1 -0
- package/dist/secrets/index.js +7 -0
- package/dist/secrets/index.js.map +1 -0
- package/dist/secrets/vault.d.ts +63 -0
- package/dist/secrets/vault.d.ts.map +1 -0
- package/dist/secrets/vault.js +163 -0
- package/dist/secrets/vault.js.map +1 -0
- package/dist/security/claude-compiler.d.ts +28 -0
- package/dist/security/claude-compiler.d.ts.map +1 -0
- package/dist/security/claude-compiler.js +66 -0
- package/dist/security/claude-compiler.js.map +1 -0
- package/dist/security/index.d.ts +7 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +7 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/parser.d.ts +47 -0
- package/dist/security/parser.d.ts.map +1 -0
- package/dist/security/parser.js +136 -0
- package/dist/security/parser.js.map +1 -0
- package/dist/sync/index.d.ts +7 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +6 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/sync.d.ts +46 -0
- package/dist/sync/sync.d.ts.map +1 -0
- package/dist/sync/sync.js +174 -0
- package/dist/sync/sync.js.map +1 -0
- package/dist/types/compiler.d.ts +81 -0
- package/dist/types/compiler.d.ts.map +1 -0
- package/dist/types/compiler.js +10 -0
- package/dist/types/compiler.js.map +1 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +10 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/manifest.d.ts +112 -0
- package/dist/types/manifest.d.ts.map +1 -0
- package/dist/types/manifest.js +10 -0
- package/dist/types/manifest.js.map +1 -0
- package/dist/types/memory.d.ts +85 -0
- package/dist/types/memory.d.ts.map +1 -0
- package/dist/types/memory.js +20 -0
- package/dist/types/memory.js.map +1 -0
- package/dist/types/security.d.ts +67 -0
- package/dist/types/security.d.ts.map +1 -0
- package/dist/types/security.js +10 -0
- package/dist/types/security.js.map +1 -0
- package/dist/types/setup.d.ts +54 -0
- package/dist/types/setup.d.ts.map +1 -0
- package/dist/types/setup.js +9 -0
- package/dist/types/setup.js.map +1 -0
- package/dist/utils/fhs-mapping.d.ts +76 -0
- package/dist/utils/fhs-mapping.d.ts.map +1 -0
- package/dist/utils/fhs-mapping.js +189 -0
- package/dist/utils/fhs-mapping.js.map +1 -0
- package/package.json +58 -0
- package/templates/compilers/agent-map.md.hbs +36 -0
- package/templates/compilers/claude.md.hbs +95 -0
- package/templates/procedural/code-review.md +54 -0
- package/templates/procedural/debugging.md +52 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security policy parser — reads policy.yaml into SecurityPolicy.
|
|
3
|
+
*
|
|
4
|
+
* Story 7.1: Parse `.agentos/security/policy.yaml` into a structured
|
|
5
|
+
* SecurityPolicy object that the compile pipeline can use to generate
|
|
6
|
+
* native enforcement rules.
|
|
7
|
+
*
|
|
8
|
+
* @module security/parser
|
|
9
|
+
*/
|
|
10
|
+
import type { SecurityPolicy } from '../types/index.js';
|
|
11
|
+
/**
|
|
12
|
+
* Default security policy used when no policy.yaml exists.
|
|
13
|
+
*/
|
|
14
|
+
export declare const DEFAULT_POLICY: SecurityPolicy;
|
|
15
|
+
/**
|
|
16
|
+
* Read and parse the security policy from a vault.
|
|
17
|
+
*
|
|
18
|
+
* @param vaultRoot - Absolute path to vault root
|
|
19
|
+
* @returns Parsed SecurityPolicy, or default if file doesn't exist
|
|
20
|
+
*/
|
|
21
|
+
export declare function readSecurityPolicy(vaultRoot: string): Promise<SecurityPolicy>;
|
|
22
|
+
/**
|
|
23
|
+
* Write a security policy to disk.
|
|
24
|
+
*
|
|
25
|
+
* @param vaultRoot - Absolute path to vault root
|
|
26
|
+
* @param policy - SecurityPolicy to persist
|
|
27
|
+
*/
|
|
28
|
+
export declare function writeSecurityPolicy(vaultRoot: string, policy: SecurityPolicy): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Validate content against input validation patterns.
|
|
31
|
+
*
|
|
32
|
+
* Story 7.3: Scans content for prompt injection patterns and returns matches.
|
|
33
|
+
*
|
|
34
|
+
* @param content - Text to scan
|
|
35
|
+
* @param policy - Security policy with patterns
|
|
36
|
+
* @returns Array of matched pattern strings
|
|
37
|
+
*/
|
|
38
|
+
export declare function scanForInjections(content: string, policy: SecurityPolicy): string[];
|
|
39
|
+
/**
|
|
40
|
+
* Check if a command is blocked by policy.
|
|
41
|
+
*
|
|
42
|
+
* @param command - Command string to check
|
|
43
|
+
* @param policy - Security policy
|
|
44
|
+
* @returns 'blocked' | 'ask' | 'allowed'
|
|
45
|
+
*/
|
|
46
|
+
export declare function checkCommand(command: string, policy: SecurityPolicy): 'blocked' | 'ask' | 'allowed';
|
|
47
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/security/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAIxD;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,cA8B5B,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,CAAC,CAUzB;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,IAAI,CAAC,CAKf;AA4BD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,cAAc,GACrB,MAAM,EAAE,CAOV;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,cAAc,GACrB,SAAS,GAAG,KAAK,GAAG,SAAS,CAY/B"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security policy parser — reads policy.yaml into SecurityPolicy.
|
|
3
|
+
*
|
|
4
|
+
* Story 7.1: Parse `.agentos/security/policy.yaml` into a structured
|
|
5
|
+
* SecurityPolicy object that the compile pipeline can use to generate
|
|
6
|
+
* native enforcement rules.
|
|
7
|
+
*
|
|
8
|
+
* @module security/parser
|
|
9
|
+
*/
|
|
10
|
+
import fs from 'node:fs/promises';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import yaml from 'js-yaml';
|
|
13
|
+
const POLICY_PATH = '.agentos/security/policy.yaml';
|
|
14
|
+
/**
|
|
15
|
+
* Default security policy used when no policy.yaml exists.
|
|
16
|
+
*/
|
|
17
|
+
export const DEFAULT_POLICY = {
|
|
18
|
+
version: '1.0',
|
|
19
|
+
default_mode: 'complain',
|
|
20
|
+
file_access: {
|
|
21
|
+
default: 'rw',
|
|
22
|
+
allow_write: ['**/*.md', '**/*.yaml', '**/*.json'],
|
|
23
|
+
ask_write: ['.agentos/**', '.claude/**'],
|
|
24
|
+
deny_read: ['.env', '**/*.pem', '**/*.key'],
|
|
25
|
+
deny_write: ['.git/**', 'node_modules/**'],
|
|
26
|
+
},
|
|
27
|
+
input_validation: {
|
|
28
|
+
enabled: true,
|
|
29
|
+
scan_on_read: [
|
|
30
|
+
{ pattern: 'ignore previous instructions' },
|
|
31
|
+
{ pattern: 'system prompt override' },
|
|
32
|
+
{ pattern: 'you are now' },
|
|
33
|
+
],
|
|
34
|
+
action: 'warn',
|
|
35
|
+
quarantine_path: '.agentos/security/quarantine/',
|
|
36
|
+
},
|
|
37
|
+
network: {
|
|
38
|
+
deny_exfil_patterns: [
|
|
39
|
+
{ regex: '(api_key|secret|password|token)\\s*[:=]' },
|
|
40
|
+
],
|
|
41
|
+
allowed_domains: [],
|
|
42
|
+
},
|
|
43
|
+
commands: {
|
|
44
|
+
blocked: ['rm -rf /', 'curl | sh', 'wget | sh'],
|
|
45
|
+
ask_before: ['npm install', 'pip install', 'brew install'],
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Read and parse the security policy from a vault.
|
|
50
|
+
*
|
|
51
|
+
* @param vaultRoot - Absolute path to vault root
|
|
52
|
+
* @returns Parsed SecurityPolicy, or default if file doesn't exist
|
|
53
|
+
*/
|
|
54
|
+
export async function readSecurityPolicy(vaultRoot) {
|
|
55
|
+
const policyPath = path.join(vaultRoot, POLICY_PATH);
|
|
56
|
+
try {
|
|
57
|
+
const content = await fs.readFile(policyPath, 'utf8');
|
|
58
|
+
const parsed = yaml.load(content);
|
|
59
|
+
return mergeWithDefaults(parsed);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return DEFAULT_POLICY;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Write a security policy to disk.
|
|
67
|
+
*
|
|
68
|
+
* @param vaultRoot - Absolute path to vault root
|
|
69
|
+
* @param policy - SecurityPolicy to persist
|
|
70
|
+
*/
|
|
71
|
+
export async function writeSecurityPolicy(vaultRoot, policy) {
|
|
72
|
+
const policyPath = path.join(vaultRoot, POLICY_PATH);
|
|
73
|
+
await fs.mkdir(path.dirname(policyPath), { recursive: true });
|
|
74
|
+
const content = yaml.dump(policy, { lineWidth: 120 });
|
|
75
|
+
await fs.writeFile(policyPath, content, 'utf8');
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Merge a partial policy with defaults.
|
|
79
|
+
*/
|
|
80
|
+
function mergeWithDefaults(partial) {
|
|
81
|
+
return {
|
|
82
|
+
version: partial.version ?? DEFAULT_POLICY.version,
|
|
83
|
+
default_mode: partial.default_mode ?? DEFAULT_POLICY.default_mode,
|
|
84
|
+
file_access: {
|
|
85
|
+
...DEFAULT_POLICY.file_access,
|
|
86
|
+
...partial.file_access,
|
|
87
|
+
},
|
|
88
|
+
input_validation: {
|
|
89
|
+
...DEFAULT_POLICY.input_validation,
|
|
90
|
+
...partial.input_validation,
|
|
91
|
+
},
|
|
92
|
+
network: {
|
|
93
|
+
...DEFAULT_POLICY.network,
|
|
94
|
+
...partial.network,
|
|
95
|
+
},
|
|
96
|
+
commands: {
|
|
97
|
+
...DEFAULT_POLICY.commands,
|
|
98
|
+
...partial.commands,
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Validate content against input validation patterns.
|
|
104
|
+
*
|
|
105
|
+
* Story 7.3: Scans content for prompt injection patterns and returns matches.
|
|
106
|
+
*
|
|
107
|
+
* @param content - Text to scan
|
|
108
|
+
* @param policy - Security policy with patterns
|
|
109
|
+
* @returns Array of matched pattern strings
|
|
110
|
+
*/
|
|
111
|
+
export function scanForInjections(content, policy) {
|
|
112
|
+
if (!policy.input_validation.enabled)
|
|
113
|
+
return [];
|
|
114
|
+
const lower = content.toLowerCase();
|
|
115
|
+
return policy.input_validation.scan_on_read
|
|
116
|
+
.filter((p) => lower.includes(p.pattern.toLowerCase()))
|
|
117
|
+
.map((p) => p.pattern);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Check if a command is blocked by policy.
|
|
121
|
+
*
|
|
122
|
+
* @param command - Command string to check
|
|
123
|
+
* @param policy - Security policy
|
|
124
|
+
* @returns 'blocked' | 'ask' | 'allowed'
|
|
125
|
+
*/
|
|
126
|
+
export function checkCommand(command, policy) {
|
|
127
|
+
const lower = command.toLowerCase();
|
|
128
|
+
if (policy.commands.blocked.some((b) => lower.includes(b.toLowerCase()))) {
|
|
129
|
+
return 'blocked';
|
|
130
|
+
}
|
|
131
|
+
if (policy.commands.ask_before.some((a) => lower.startsWith(a.toLowerCase()))) {
|
|
132
|
+
return 'ask';
|
|
133
|
+
}
|
|
134
|
+
return 'allowed';
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/security/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,SAAS,CAAC;AAG3B,MAAM,WAAW,GAAG,+BAA+B,CAAC;AAEpD;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAmB;IAC5C,OAAO,EAAE,KAAK;IACd,YAAY,EAAE,UAAU;IACxB,WAAW,EAAE;QACX,OAAO,EAAE,IAAI;QACb,WAAW,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,WAAW,CAAC;QAClD,SAAS,EAAE,CAAC,aAAa,EAAE,YAAY,CAAC;QACxC,SAAS,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC;QAC3C,UAAU,EAAE,CAAC,SAAS,EAAE,iBAAiB,CAAC;KAC3C;IACD,gBAAgB,EAAE;QAChB,OAAO,EAAE,IAAI;QACb,YAAY,EAAE;YACZ,EAAE,OAAO,EAAE,8BAA8B,EAAE;YAC3C,EAAE,OAAO,EAAE,wBAAwB,EAAE;YACrC,EAAE,OAAO,EAAE,aAAa,EAAE;SAC3B;QACD,MAAM,EAAE,MAAM;QACd,eAAe,EAAE,+BAA+B;KACjD;IACD,OAAO,EAAE;QACP,mBAAmB,EAAE;YACnB,E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AI,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC;QAC9E,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,aAAa,EACb,WAAW,EACX,WAAW,GACZ,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,aAAa,EACb,WAAW,EACX,WAAW,GACZ,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sync & Import module — bidirectional synchronization.
|
|
3
|
+
*
|
|
4
|
+
* Story 9.1: Import memory from native agent stores (e.g. .omc/project-memory.json)
|
|
5
|
+
* Story 9.2: Drift detection between manifest and compiled outputs
|
|
6
|
+
* Story 9.3: Bidirectional OpenClaw memory sync
|
|
7
|
+
*
|
|
8
|
+
* @module sync/sync
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Import memory facts from .omc/project-memory.json into semantic.md.
|
|
12
|
+
* Canonical source always wins on conflicts — duplicates are skipped.
|
|
13
|
+
*
|
|
14
|
+
* @param vaultRoot - Vault root path
|
|
15
|
+
* @returns Import result with counts
|
|
16
|
+
*/
|
|
17
|
+
export declare function importFromOmc(vaultRoot: string): Promise<{
|
|
18
|
+
imported: number;
|
|
19
|
+
skipped: number;
|
|
20
|
+
errors: string[];
|
|
21
|
+
}>;
|
|
22
|
+
/** Drift detection result for a single file. */
|
|
23
|
+
export interface DriftResult {
|
|
24
|
+
file: string;
|
|
25
|
+
drifted: boolean;
|
|
26
|
+
currentHash: string;
|
|
27
|
+
expectedHash: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Detect drift between compiled outputs and what compile would generate.
|
|
31
|
+
*
|
|
32
|
+
* Simple approach: compare file content hashes.
|
|
33
|
+
*
|
|
34
|
+
* @param vaultRoot - Vault root path
|
|
35
|
+
* @param files - List of managed file paths to check
|
|
36
|
+
* @returns Array of DriftResults
|
|
37
|
+
*/
|
|
38
|
+
export declare function detectDrift(vaultRoot: string, files: string[]): Promise<DriftResult[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Export semantic memory to .omc/project-memory.json format.
|
|
41
|
+
*
|
|
42
|
+
* @param vaultRoot - Vault root path
|
|
43
|
+
* @returns Number of entries exported
|
|
44
|
+
*/
|
|
45
|
+
export declare function exportToOmc(vaultRoot: string): Promise<number>;
|
|
46
|
+
//# sourceMappingURL=sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/sync/sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAWH;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAoDlE;AAoCD,gDAAgD;AAChD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAC/B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EAAE,GACd,OAAO,CAAC,WAAW,EAAE,CAAC,CAuBxB;AAoBD;;;;;GAKG;AACH,wBAAsB,WAAW,CAC/B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,CA4BjB"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sync & Import module — bidirectional synchronization.
|
|
3
|
+
*
|
|
4
|
+
* Story 9.1: Import memory from native agent stores (e.g. .omc/project-memory.json)
|
|
5
|
+
* Story 9.2: Drift detection between manifest and compiled outputs
|
|
6
|
+
* Story 9.3: Bidirectional OpenClaw memory sync
|
|
7
|
+
*
|
|
8
|
+
* @module sync/sync
|
|
9
|
+
*/
|
|
10
|
+
import fs from 'node:fs/promises';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import { parseSemanticMemory, appendSemanticEntry } from '../memory/parser.js';
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// Story 9.1: Memory Import
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
/**
|
|
17
|
+
* Import memory facts from .omc/project-memory.json into semantic.md.
|
|
18
|
+
* Canonical source always wins on conflicts — duplicates are skipped.
|
|
19
|
+
*
|
|
20
|
+
* @param vaultRoot - Vault root path
|
|
21
|
+
* @returns Import result with counts
|
|
22
|
+
*/
|
|
23
|
+
export async function importFromOmc(vaultRoot) {
|
|
24
|
+
const omcPath = path.join(vaultRoot, '.omc/project-memory.json');
|
|
25
|
+
const semanticPath = path.join(vaultRoot, '.agentos/memory/semantic.md');
|
|
26
|
+
const errors = [];
|
|
27
|
+
let imported = 0;
|
|
28
|
+
let skipped = 0;
|
|
29
|
+
let omcData;
|
|
30
|
+
try {
|
|
31
|
+
const raw = await fs.readFile(omcPath, 'utf8');
|
|
32
|
+
omcData = JSON.parse(raw);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return { imported: 0, skipped: 0, errors: ['Cannot read .omc/project-memory.json'] };
|
|
36
|
+
}
|
|
37
|
+
// Parse OMC memory format — expects { facts: string[] } or similar
|
|
38
|
+
const facts = extractFactsFromOmc(omcData);
|
|
39
|
+
if (facts.length === 0) {
|
|
40
|
+
return { imported: 0, skipped: 0, errors: [] };
|
|
41
|
+
}
|
|
42
|
+
// Ensure semantic.md exists
|
|
43
|
+
try {
|
|
44
|
+
await fs.access(semanticPath);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return { imported: 0, skipped: 0, errors: ['No semantic.md found. Run agentfs onboard first.'] };
|
|
48
|
+
}
|
|
49
|
+
for (const fact of facts) {
|
|
50
|
+
try {
|
|
51
|
+
const entry = {
|
|
52
|
+
type: 'FACT',
|
|
53
|
+
content: fact,
|
|
54
|
+
status: 'active',
|
|
55
|
+
};
|
|
56
|
+
// appendSemanticEntry handles dedup internally
|
|
57
|
+
const before = await fs.readFile(semanticPath, 'utf8');
|
|
58
|
+
await appendSemanticEntry(semanticPath, entry);
|
|
59
|
+
const after = await fs.readFile(semanticPath, 'utf8');
|
|
60
|
+
if (before === after) {
|
|
61
|
+
skipped++;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
imported++;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
errors.push(`Failed to import fact: ${fact}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return { imported, skipped, errors };
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Extract facts from OMC memory format.
|
|
75
|
+
* Handles various shapes: { facts: [] }, { entries: [] }, or array directly.
|
|
76
|
+
*/
|
|
77
|
+
function extractFactsFromOmc(data) {
|
|
78
|
+
if (Array.isArray(data)) {
|
|
79
|
+
return data.filter((d) => typeof d === 'string');
|
|
80
|
+
}
|
|
81
|
+
if (data && typeof data === 'object') {
|
|
82
|
+
const obj = data;
|
|
83
|
+
// Try common keys
|
|
84
|
+
for (const key of ['facts', 'entries', 'memories', 'items']) {
|
|
85
|
+
if (Array.isArray(obj[key])) {
|
|
86
|
+
return obj[key]
|
|
87
|
+
.map((item) => {
|
|
88
|
+
if (typeof item === 'string')
|
|
89
|
+
return item;
|
|
90
|
+
if (item && typeof item === 'object' && 'content' in item) {
|
|
91
|
+
return String(item.content);
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
})
|
|
95
|
+
.filter((s) => s !== null);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Detect drift between compiled outputs and what compile would generate.
|
|
103
|
+
*
|
|
104
|
+
* Simple approach: compare file content hashes.
|
|
105
|
+
*
|
|
106
|
+
* @param vaultRoot - Vault root path
|
|
107
|
+
* @param files - List of managed file paths to check
|
|
108
|
+
* @returns Array of DriftResults
|
|
109
|
+
*/
|
|
110
|
+
export async function detectDrift(vaultRoot, files) {
|
|
111
|
+
const results = [];
|
|
112
|
+
for (const file of files) {
|
|
113
|
+
const filePath = path.join(vaultRoot, file);
|
|
114
|
+
let currentHash = '';
|
|
115
|
+
try {
|
|
116
|
+
const content = await fs.readFile(filePath, 'utf8');
|
|
117
|
+
currentHash = simpleHash(content);
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
currentHash = 'MISSING';
|
|
121
|
+
}
|
|
122
|
+
results.push({
|
|
123
|
+
file,
|
|
124
|
+
drifted: false, // Will be set to true when we have compiled comparison
|
|
125
|
+
currentHash,
|
|
126
|
+
expectedHash: '', // Populated during compile comparison
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return results;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Simple string hash for drift detection.
|
|
133
|
+
* Not cryptographic — just for comparison.
|
|
134
|
+
*/
|
|
135
|
+
function simpleHash(content) {
|
|
136
|
+
let hash = 0;
|
|
137
|
+
for (let i = 0; i < content.length; i++) {
|
|
138
|
+
const char = content.charCodeAt(i);
|
|
139
|
+
hash = ((hash << 5) - hash) + char;
|
|
140
|
+
hash |= 0;
|
|
141
|
+
}
|
|
142
|
+
return hash.toString(16);
|
|
143
|
+
}
|
|
144
|
+
// ---------------------------------------------------------------------------
|
|
145
|
+
// Story 9.3: Export to OMC
|
|
146
|
+
// ---------------------------------------------------------------------------
|
|
147
|
+
/**
|
|
148
|
+
* Export semantic memory to .omc/project-memory.json format.
|
|
149
|
+
*
|
|
150
|
+
* @param vaultRoot - Vault root path
|
|
151
|
+
* @returns Number of entries exported
|
|
152
|
+
*/
|
|
153
|
+
export async function exportToOmc(vaultRoot) {
|
|
154
|
+
const semanticPath = path.join(vaultRoot, '.agentos/memory/semantic.md');
|
|
155
|
+
let content;
|
|
156
|
+
try {
|
|
157
|
+
content = await fs.readFile(semanticPath, 'utf8');
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
return 0;
|
|
161
|
+
}
|
|
162
|
+
const entries = parseSemanticMemory(content);
|
|
163
|
+
const active = entries.filter((e) => e.status === 'active');
|
|
164
|
+
const omcData = {
|
|
165
|
+
version: '1.0',
|
|
166
|
+
source: 'agentfs',
|
|
167
|
+
facts: active.map((e) => `${e.type}: ${e.content}`),
|
|
168
|
+
};
|
|
169
|
+
const omcDir = path.join(vaultRoot, '.omc');
|
|
170
|
+
await fs.mkdir(omcDir, { recursive: true });
|
|
171
|
+
await fs.writeFile(path.join(omcDir, 'project-memory.json'), JSON.stringify(omcData, null, 2) + '\n', 'utf8');
|
|
172
|
+
return active.length;
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=sync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../src/sync/sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC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AAM,CAAC,CAAC;IAC5C,MAAM,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5C,MAAM,EAAE,CAAC,SAAS,CAChB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,qBAAqB,CAAC,EACxC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EACvC,MAAM,CACP,CAAC;IAEF,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compile Pipeline types — kernel → native agent configs.
|
|
3
|
+
*
|
|
4
|
+
* Each agent has a "driver" (compiler) that translates the canonical
|
|
5
|
+
* manifest + init.d + memory into the agent's native format.
|
|
6
|
+
*
|
|
7
|
+
* @see docs/architecture.md Section 9 "Compile Pipeline"
|
|
8
|
+
*/
|
|
9
|
+
import type { AgentRuntime, Manifest } from './manifest.js';
|
|
10
|
+
/**
|
|
11
|
+
* Context passed to compilers during the compile phase.
|
|
12
|
+
* Contains everything a driver needs to generate native output.
|
|
13
|
+
*/
|
|
14
|
+
export interface CompileContext {
|
|
15
|
+
/** Parsed manifest.yaml */
|
|
16
|
+
manifest: Manifest;
|
|
17
|
+
/** Contents of init.d/ scripts, keyed by filename */
|
|
18
|
+
initScripts: Record<string, string>;
|
|
19
|
+
/** Semantic memory content (always loaded) */
|
|
20
|
+
semanticMemory: string | null;
|
|
21
|
+
/** Corrections content (agent mistakes) */
|
|
22
|
+
corrections: string | null;
|
|
23
|
+
/** Root path of the vault */
|
|
24
|
+
vaultRoot: string;
|
|
25
|
+
/** Whether this is a dry-run (preview only, don't write) */
|
|
26
|
+
dryRun: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** A single file that a compiler wants to write. */
|
|
29
|
+
export interface CompileOutput {
|
|
30
|
+
/** Relative path from vault root */
|
|
31
|
+
path: string;
|
|
32
|
+
/** File content to write */
|
|
33
|
+
content: string;
|
|
34
|
+
/** Whether this file is owned by AgentFS (true) or user (false) */
|
|
35
|
+
managed: boolean;
|
|
36
|
+
}
|
|
37
|
+
/** Result of a compile operation. */
|
|
38
|
+
export interface CompileResult {
|
|
39
|
+
/** Which agent this result is for */
|
|
40
|
+
agent: AgentRuntime;
|
|
41
|
+
/** Files to write (or that would be written in dry-run) */
|
|
42
|
+
outputs: CompileOutput[];
|
|
43
|
+
/** Human-readable summary of what was/would be done */
|
|
44
|
+
summary: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Agent compiler interface — one per supported agent.
|
|
48
|
+
*
|
|
49
|
+
* Implement this to add support for a new AI agent runtime.
|
|
50
|
+
* Each compiler lives in `src/compilers/{agent}.ts`.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* const claude: AgentCompiler = {
|
|
55
|
+
* name: 'claude',
|
|
56
|
+
* compile(ctx) { ... },
|
|
57
|
+
* supports(feature) { ... },
|
|
58
|
+
* };
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export interface AgentCompiler {
|
|
62
|
+
/** Agent runtime name */
|
|
63
|
+
readonly name: AgentRuntime;
|
|
64
|
+
/**
|
|
65
|
+
* Compile manifest + context into native agent config files.
|
|
66
|
+
*
|
|
67
|
+
* @param context - Everything the compiler needs
|
|
68
|
+
* @returns Files to write and a summary
|
|
69
|
+
*/
|
|
70
|
+
compile(context: CompileContext): Promise<CompileResult>;
|
|
71
|
+
/**
|
|
72
|
+
* Check if this agent supports a given feature.
|
|
73
|
+
*
|
|
74
|
+
* Used to determine which security/memory features
|
|
75
|
+
* can be compiled for this agent.
|
|
76
|
+
*
|
|
77
|
+
* @param feature - Feature name (e.g. 'security-enforce', 'memory-sync')
|
|
78
|
+
*/
|
|
79
|
+
supports(feature: string): boolean;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=compiler.d.ts.map
|
|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
|
|
|
1
|
+
/**
|
|
2
|
+
* Compile Pipeline types — kernel → native agent configs.
|
|
3
|
+
*
|
|
4
|
+
* Each agent has a "driver" (compiler) that translates the canonical
|
|
5
|
+
* manifest + init.d + memory into the agent's native format.
|
|
6
|
+
*
|
|
7
|
+
* @see docs/architecture.md Section 9 "Compile Pipeline"
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=compiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../src/types/compiler.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentFS core types — barrel export.
|
|
3
|
+
*
|
|
4
|
+
* Import all types from here:
|
|
5
|
+
* ```ts
|
|
6
|
+
* import type { Manifest, AgentCompiler, SecurityPolicy } from './types/index.js';
|
|
7
|
+
* ```
|
|
8
|
+
*/
|
|
9
|
+
export type { Profile, AgentRuntime, SecurityMode, FhsPaths, AgentConfig, BootConfig, FrontmatterConfig, SubagentStatus, HookEvent, HooksConfig, Manifest, } from './manifest.js';
|
|
10
|
+
export type { CompileContext, CompileOutput, CompileResult, AgentCompiler, } from './compiler.js';
|
|
11
|
+
export type { FilePermission, ValidationAction, FileAccessPolicy, InputValidationPolicy, NetworkPolicy, CommandPolicy, SecurityPolicy, } from './security.js';
|
|
12
|
+
export type { SemanticEntryType, EntryStatus, SemanticEntry, ConfidenceConfig, EpisodicEntry, ProceduralEntry, } from './memory.js';
|
|
13
|
+
export { DEFAULT_CONFIDENCE } from './memory.js';
|
|
14
|
+
export type { SetupAnswers, GeneratorResult, ScaffoldResult, } from './setup.js';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,YAAY,EACV,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,SAAS,EACT,WAAW,EACX,QAAQ,GACT,MAAM,eAAe,CAAC;AAEvB,YAAY,EACV,cAAc,EACd,aAAa,EACb,aAAa,EACb,aAAa,GACd,MAAM,eAAe,CAAC;AAEvB,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,aAAa,EACb,aAAa,EACb,cAAc,GACf,MAAM,eAAe,CAAC;AAEvB,YAAY,EACV,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,YAAY,EACV,YAAY,EACZ,eAAe,EACf,cAAc,GACf,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentFS core types — barrel export.
|
|
3
|
+
*
|
|
4
|
+
* Import all types from here:
|
|
5
|
+
* ```ts
|
|
6
|
+
* import type { Manifest, AgentCompiler, SecurityPolicy } from './types/index.js';
|
|
7
|
+
* ```
|
|
8
|
+
*/
|
|
9
|
+
export { DEFAULT_CONFIDENCE } from './memory.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA0CH,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC"}
|