@openliate/liate 0.0.0-stage → 0.1.6

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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +127 -2
  3. package/README.npm.md +128 -0
  4. package/dist/bin.js +28745 -0
  5. package/dist/liate.js +39479 -0
  6. package/dist/runtime/hono.js +28072 -0
  7. package/dist/runtime/index.js +28072 -0
  8. package/hub/agents/docgyan-agent/agent.json +27 -0
  9. package/hub/agents/docgyan-agent/agent.ts +39 -0
  10. package/hub/agents/gnani-agent/agent.json +17 -0
  11. package/hub/agents/neon-agent/agent.json +18 -0
  12. package/hub/agents/prism-agent/agent.json +17 -0
  13. package/hub/agents/sarvam-agent/agent.json +22 -0
  14. package/package.json +71 -4
  15. package/src/cli/index.ts +346 -0
  16. package/src/cli/resolver.ts +153 -0
  17. package/src/core/aum.ts +137 -0
  18. package/src/core/om.ts +159 -0
  19. package/src/core/spec.ts +112 -0
  20. package/src/core/uuid.ts +8 -0
  21. package/src/core/version.ts +2 -0
  22. package/src/layers/agent/harness.ts +118 -0
  23. package/src/layers/agent/loop.ts +203 -0
  24. package/src/layers/agent/skills.ts +302 -0
  25. package/src/layers/agent/types.ts +66 -0
  26. package/src/layers/environment/sandbox.ts +107 -0
  27. package/src/layers/environment/types.ts +23 -0
  28. package/src/layers/integration/knowledge.ts +187 -0
  29. package/src/layers/integration/lib.ts +167 -0
  30. package/src/layers/integration/memory.ts +135 -0
  31. package/src/layers/integration/repo.ts +273 -0
  32. package/src/layers/integration/types.ts +60 -0
  33. package/src/layers/llm/model.ts +928 -0
  34. package/src/layers/llm/types.ts +64 -0
  35. package/src/layers/tools/mcp.ts +236 -0
  36. package/src/layers/tools/registry.ts +307 -0
  37. package/src/layers/tools/server.ts +69 -0
  38. package/src/layers/tools/types.ts +38 -0
  39. package/src/liate.ts +65 -0
  40. package/src/routes/skills.ts +73 -0
  41. package/src/runtime/hono.ts +346 -0
  42. package/src/runtime/wasm.ts +23 -0
  43. package/src/scaffold/project.ts +188 -0
@@ -0,0 +1,188 @@
1
+ // src/scaffold/project.ts
2
+ // Liate v0.1.2 — Project Scaffolder (TypeScript & Python L·I·A·T·E Agent Templates)
3
+
4
+ import fs from "node:fs";
5
+ import path from "node:path";
6
+
7
+ export interface ScaffoldOptions {
8
+ name: string;
9
+ targetDir?: string;
10
+ lang?: "ts" | "py";
11
+ skills?: string[];
12
+ }
13
+
14
+ export interface ScaffoldResult {
15
+ projectName: string;
16
+ className: string;
17
+ lang: "ts" | "py";
18
+ projectDir: string;
19
+ files: string[];
20
+ }
21
+
22
+ function toPascalCase(str: string): string {
23
+ return str
24
+ .split(/[-_]+/)
25
+ .filter(Boolean)
26
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
27
+ .join("");
28
+ }
29
+
30
+ export function scaffoldProject(options: ScaffoldOptions): ScaffoldResult {
31
+ const rawName = options.name.trim();
32
+ if (!rawName) {
33
+ throw new Error("Agent project name is required.");
34
+ }
35
+
36
+ const cleanName = rawName
37
+ .toLowerCase()
38
+ .replace(/[^a-z0-9_-]/g, "-")
39
+ .replace(/^-+|-+$/g, "");
40
+
41
+ if (!cleanName) {
42
+ throw new Error(
43
+ `Invalid agent project name '${rawName}'. Use alphanumeric characters and hyphens.`
44
+ );
45
+ }
46
+
47
+ const className =
48
+ toPascalCase(cleanName) + (cleanName.toLowerCase().endsWith("agent") ? "" : "Agent");
49
+ const targetDir = options.targetDir
50
+ ? path.resolve(options.targetDir)
51
+ : path.resolve(process.cwd(), cleanName);
52
+ const lang: "ts" | "py" = options.lang === "py" ? "py" : "ts";
53
+ const skills = options.skills?.length ? options.skills : ["vercel-labs/skills/find-skills"];
54
+
55
+ if (fs.existsSync(targetDir)) {
56
+ const existing = fs.readdirSync(targetDir);
57
+ if (existing.length > 0) {
58
+ throw new Error(`Target directory '${targetDir}' already exists and is not empty.`);
59
+ }
60
+ } else {
61
+ fs.mkdirSync(targetDir, { recursive: true });
62
+ }
63
+
64
+ let filesToWrite: Record<string, string>;
65
+
66
+ if (lang === "py") {
67
+ const pyprojectContent = `[project]
68
+ name = "${cleanName}"
69
+ version = "0.1.0"
70
+ description = "AI Agent built with Liate"
71
+ requires-python = ">=3.9"
72
+ dependencies = [
73
+ "liate>=0.1.0"
74
+ ]
75
+ `;
76
+
77
+ const agentPyContent = `import os
78
+ import sys
79
+ from liate import liate
80
+
81
+ class ${className}(liate):
82
+ """${className} — Sovereign AI Agent (L · I · A · T · E)"""
83
+
84
+ L = "sarvam/sarvam-105b-conversations"
85
+ I = { "memory": "sessions/${cleanName}" }
86
+ A = {
87
+ "name": "${cleanName}",
88
+ "intent": "AI Agent built with OpenLiate",
89
+ "max_steps": 5,
90
+ "skills": ${JSON.stringify(skills)},
91
+ }
92
+ T = {}
93
+ E = { "SARVAM_API_KEY": os.environ.get("SARVAM_API_KEY", "$SARVAM_API_KEY") }
94
+
95
+ def main():
96
+ agent = ${className}()
97
+ prompt = sys.argv[1] if len(sys.argv) > 1 else "Namaste, who are you?"
98
+ result = agent.run(prompt)
99
+ print(result)
100
+
101
+ if __name__ == "__main__":
102
+ main()
103
+ `;
104
+
105
+ filesToWrite = {
106
+ "pyproject.toml": pyprojectContent,
107
+ "agent.py": agentPyContent,
108
+ ".env.example": "SARVAM_API_KEY=your_sarvam_api_key_here\n",
109
+ "README.md": `# ${cleanName}\n\nAI Agent scaffolded with **Liate**.\n\n\`\`\`bash\npython agent.py "Hello!"\n\`\`\`\n`,
110
+ };
111
+ } else {
112
+ const pkgJson = {
113
+ name: cleanName,
114
+ version: "0.1.0",
115
+ private: true,
116
+ type: "module",
117
+ scripts: {
118
+ start: "bun run agent.ts",
119
+ serve: "liate serve agent.json --port 7071",
120
+ },
121
+ dependencies: {
122
+ "@openliate/liate": "^0.1.0",
123
+ },
124
+ };
125
+
126
+ const agentJson = {
127
+ L: "sarvam/sarvam-105b-conversations",
128
+ I: { memory: `sessions/${cleanName}` },
129
+ A: {
130
+ name: cleanName,
131
+ intent: "Sovereign AI Agent built with Liate",
132
+ maxSteps: 5,
133
+ skills,
134
+ },
135
+ T: {},
136
+ E: { SARVAM_API_KEY: "$SARVAM_API_KEY" },
137
+ };
138
+
139
+ const agentTsContent = `import { liate } from "@openliate/liate";
140
+
141
+ export class ${className} extends liate {
142
+ L = "sarvam/sarvam-105b-conversations";
143
+ I = { memory: "sessions/${cleanName}" };
144
+ A = {
145
+ name: "${cleanName}",
146
+ intent: "Sovereign AI Agent built with Liate",
147
+ maxSteps: 5,
148
+ skills: ${JSON.stringify(skills)},
149
+ };
150
+ T = {};
151
+ E = { SARVAM_API_KEY: "$SARVAM_API_KEY" };
152
+ }
153
+
154
+ if (import.meta.main) {
155
+ const agent = new ${className}();
156
+ const prompt = process.argv.slice(2).join(" ") || "Namaste, confirm you are running Liate.";
157
+ const result = await agent.run(prompt);
158
+ console.log(result.text);
159
+ await agent.close();
160
+ }
161
+ `;
162
+
163
+ filesToWrite = {
164
+ "package.json": JSON.stringify(pkgJson, null, 2) + "\n",
165
+ "agent.json": JSON.stringify(agentJson, null, 2) + "\n",
166
+ "agent.ts": agentTsContent,
167
+ ".env.example": "SARVAM_API_KEY=your_sarvam_api_key_here\n",
168
+ "README.md": `# ${cleanName}\n\nAI Agent scaffolded with **Liate**.\n\n\`\`\`bash\nliate run agent.json "Hello!"\n\`\`\`\n`,
169
+ };
170
+ }
171
+
172
+ const createdFiles: string[] = [];
173
+ for (const [relPath, content] of Object.entries(filesToWrite)) {
174
+ const fullPath = path.join(targetDir, relPath);
175
+ fs.mkdirSync(path.dirname(fullPath), { recursive: true });
176
+ fs.writeFileSync(fullPath, content, "utf-8");
177
+ createdFiles.push(relPath);
178
+ }
179
+
180
+ return {
181
+ projectName: cleanName,
182
+ className,
183
+ lang,
184
+ projectDir: targetDir,
185
+ files: createdFiles,
186
+ };
187
+ }
188
+