openliate 0.0.1 → 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 (73) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +73 -241
  3. package/README.npm.md +128 -0
  4. package/dist/bin.js +24644 -42273
  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 +9 -6
  14. package/package.json +33 -21
  15. package/src/cli/index.ts +346 -0
  16. package/src/cli/resolver.ts +153 -0
  17. package/src/core/aum.ts +87 -28
  18. package/src/core/om.ts +159 -0
  19. package/src/core/spec.ts +112 -0
  20. package/src/core/uuid.ts +5 -16
  21. package/src/core/version.ts +2 -0
  22. package/src/layers/agent/harness.ts +118 -0
  23. package/src/{agent → layers/agent}/loop.ts +44 -24
  24. package/src/layers/agent/skills.ts +302 -0
  25. package/src/{agent → layers/agent}/types.ts +14 -1
  26. package/src/{environment/environment.ts → layers/environment/sandbox.ts} +24 -5
  27. package/src/{environment → layers/environment}/types.ts +8 -0
  28. package/src/layers/integration/knowledge.ts +187 -0
  29. package/src/layers/integration/lib.ts +167 -0
  30. package/src/{integration → layers/integration}/memory.ts +49 -67
  31. package/src/layers/integration/repo.ts +273 -0
  32. package/src/{integration → layers/integration}/types.ts +60 -31
  33. package/src/layers/llm/model.ts +928 -0
  34. package/src/layers/llm/types.ts +64 -0
  35. package/src/{tools → layers/tools}/mcp.ts +24 -10
  36. package/src/layers/tools/registry.ts +307 -0
  37. package/src/{tools → layers/tools}/server.ts +12 -13
  38. package/src/{tools → layers/tools}/types.ts +3 -2
  39. package/src/liate.ts +64 -24
  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
  44. package/dist/engine/engine.zip +0 -0
  45. package/dist/engine/index.js +0 -36790
  46. package/hub/agents/email-agent/agent.json +0 -19
  47. package/hub/agents/general-agent/agent.json +0 -18
  48. package/hub/agents/identity-agent/agent.json +0 -19
  49. package/hub/agents/research-agent/agent.json +0 -18
  50. package/hub/llm/sarvam.json +0 -27
  51. package/hub/mcp/agentmail.json +0 -10
  52. package/hub/mcp/fetch.json +0 -9
  53. package/hub/mcp/neon.json +0 -12
  54. package/hub/mcp/sarvam.json +0 -12
  55. package/hub/mcp/supabase.json +0 -12
  56. package/hub/mcp/vercel.json +0 -12
  57. package/src/agent/agent.ts +0 -165
  58. package/src/cli.ts +0 -272
  59. package/src/engine/types.ts +0 -104
  60. package/src/integration/integration.ts +0 -37
  61. package/src/link/index.ts +0 -317
  62. package/src/link/neon.ts +0 -646
  63. package/src/link/supabase.ts +0 -567
  64. package/src/link/vercel.ts +0 -633
  65. package/src/llm/config.ts +0 -46
  66. package/src/llm/hub.ts +0 -59
  67. package/src/llm/llm.ts +0 -60
  68. package/src/llm/sarvam.ts +0 -136
  69. package/src/server/engine.ts +0 -277
  70. package/src/server/index.ts +0 -32
  71. package/src/tools/builtin/fetch.ts +0 -66
  72. package/src/tools/builtin/identity.ts +0 -131
  73. package/src/tools/registry.ts +0 -218
@@ -0,0 +1,153 @@
1
+ // src/cli/resolver.ts
2
+ // Liate CLI Dynamic Agent Resolver & Local Hub
3
+
4
+ import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
5
+ import { resolve, isAbsolute, extname, join } from "node:path";
6
+ import { liate } from "@/core/om";
7
+
8
+ export interface ResolvedAgentTarget {
9
+ agent: liate;
10
+ sourcePath?: string;
11
+ sourceType: "typescript" | "javascript" | "json" | "hub" | "ephemeral";
12
+ }
13
+
14
+ export interface HubAgentSummary {
15
+ id: string;
16
+ name: string;
17
+ model: string;
18
+ intent: string;
19
+ path: string;
20
+ }
21
+
22
+ /**
23
+ * Lists all local agent templates available in hub/agents
24
+ */
25
+ export function listLocalHubAgents(): HubAgentSummary[] {
26
+ const cwd = process.cwd();
27
+ const hubDir = resolve(cwd, "hub", "agents");
28
+
29
+ if (!existsSync(hubDir)) {
30
+ return [];
31
+ }
32
+
33
+ const list: HubAgentSummary[] = [];
34
+ const entries = readdirSync(hubDir, { withFileTypes: true });
35
+
36
+ for (const entry of entries) {
37
+ if (entry.isDirectory()) {
38
+ const agentJsonPath = join(hubDir, entry.name, "agent.json");
39
+ if (existsSync(agentJsonPath)) {
40
+ try {
41
+ const raw = JSON.parse(readFileSync(agentJsonPath, "utf-8"));
42
+ list.push({
43
+ id: entry.name,
44
+ name: raw.A?.name || entry.name,
45
+ model: typeof raw.L === "string" ? raw.L : (raw.L?.model || "sarvam/sarvam-105b"),
46
+ intent: raw.A?.intent || "Autonomous Sovereign Agent",
47
+ path: agentJsonPath
48
+ });
49
+ } catch {
50
+ // Skip invalid json
51
+ }
52
+ }
53
+ }
54
+ }
55
+
56
+ return list;
57
+ }
58
+
59
+ /**
60
+ * Discovers and loads an agent from an explicit file path, local hub, or current directory
61
+ */
62
+ export async function resolveAgent(customTarget?: string): Promise<ResolvedAgentTarget> {
63
+ const cwd = process.cwd();
64
+
65
+ // 1. Explicit path or hub agent name passed by user
66
+ if (customTarget && customTarget.trim().length > 0) {
67
+ let candidatePath = isAbsolute(customTarget) ? customTarget : resolve(cwd, customTarget);
68
+
69
+ // Check if target is a hub agent directory name (e.g. "sarvam-agent" or "prism-agent")
70
+ const hubCandidate = resolve(cwd, "hub", "agents", customTarget, "agent.json");
71
+ if (existsSync(hubCandidate)) {
72
+ const agent = await liate.load(hubCandidate);
73
+ return { agent, sourcePath: hubCandidate, sourceType: "hub" };
74
+ }
75
+
76
+ // Check if candidatePath is a directory containing agent.json
77
+ if (existsSync(candidatePath) && statSync(candidatePath).isDirectory()) {
78
+ const dirJson = join(candidatePath, "agent.json");
79
+ if (existsSync(dirJson)) {
80
+ const agent = await liate.load(dirJson);
81
+ return { agent, sourcePath: dirJson, sourceType: "json" };
82
+ }
83
+ }
84
+
85
+ if (existsSync(candidatePath)) {
86
+ const ext = extname(candidatePath).toLowerCase();
87
+
88
+ if (ext === ".json") {
89
+ const agent = await liate.load(candidatePath);
90
+ return { agent, sourcePath: candidatePath, sourceType: "json" };
91
+ }
92
+
93
+ if (ext === ".ts" || ext === ".js" || ext === ".mjs") {
94
+ const imported = await import(candidatePath);
95
+ const ExportedClass = imported.default || Object.values(imported).find(
96
+ (val: any) => typeof val === "function" && (val.prototype instanceof liate || val === liate)
97
+ );
98
+
99
+ if (ExportedClass && typeof ExportedClass === "function") {
100
+ const instance = new (ExportedClass as any)();
101
+ return { agent: instance, sourcePath: candidatePath, sourceType: ext === ".ts" ? "typescript" : "javascript" };
102
+ }
103
+
104
+ if (imported.default instanceof liate) {
105
+ return { agent: imported.default, sourcePath: candidatePath, sourceType: ext === ".ts" ? "typescript" : "javascript" };
106
+ }
107
+ }
108
+ }
109
+ }
110
+
111
+ // 2. Automatic discovery in current directory: agent.ts -> agent.json -> agent.js
112
+ const tsCandidate = resolve(cwd, "agent.ts");
113
+ if (existsSync(tsCandidate)) {
114
+ try {
115
+ const imported = await import(tsCandidate);
116
+ const ExportedClass = imported.default || Object.values(imported).find(
117
+ (val: any) => typeof val === "function" && (val.prototype instanceof liate || val === liate)
118
+ );
119
+
120
+ if (ExportedClass && typeof ExportedClass === "function") {
121
+ return { agent: new (ExportedClass as any)(), sourcePath: tsCandidate, sourceType: "typescript" };
122
+ }
123
+ } catch {
124
+ // Fall through to json
125
+ }
126
+ }
127
+
128
+ const jsonCandidate = resolve(cwd, "agent.json");
129
+ if (existsSync(jsonCandidate)) {
130
+ const agent = await liate.load(jsonCandidate);
131
+ return { agent, sourcePath: jsonCandidate, sourceType: "json" };
132
+ }
133
+
134
+ const jsCandidate = resolve(cwd, "agent.js");
135
+ if (existsSync(jsCandidate)) {
136
+ const imported = await import(jsCandidate);
137
+ const ExportedClass = imported.default || Object.values(imported).find(
138
+ (val: any) => typeof val === "function" && (val.prototype instanceof liate || val === liate)
139
+ );
140
+ if (ExportedClass && typeof ExportedClass === "function") {
141
+ return { agent: new (ExportedClass as any)(), sourcePath: jsCandidate, sourceType: "javascript" };
142
+ }
143
+ }
144
+
145
+ // 3. Fallback: Ephemeral sovereign agent
146
+ const fallbackAgent = liate.from({
147
+ L: "sarvam/sarvam-105b-conversations",
148
+ A: { name: "liate-agent", intent: "Autonomous Sovereign Agent" },
149
+ E: { SARVAM_API_KEY: "$SARVAM_API_KEY" }
150
+ });
151
+
152
+ return { agent: fallbackAgent, sourceType: "ephemeral" };
153
+ }
package/src/core/aum.ts CHANGED
@@ -1,67 +1,125 @@
1
1
  import { z } from "zod";
2
- import type { AgentManifest } from "../engine/types";
2
+ import type { AgentModule } from "@/core/spec";
3
3
 
4
4
  export const AUMSchema = z.object({
5
5
  L: z.union([
6
6
  z.string().min(1, "Model definition cannot be empty"),
7
7
  z.object({
8
- provider: z.string(),
8
+ provider: z.string().optional(),
9
9
  model: z.string(),
10
10
  temperature: z.number().optional(),
11
11
  maxTokens: z.number().optional(),
12
12
  endpoint: z.string().optional()
13
- })
13
+ }).passthrough()
14
14
  ]),
15
15
  I: z.object({
16
16
  memory: z.string().optional(),
17
- system: z.string().optional(),
18
- skills: z.union([z.string(), z.array(z.string())]).optional(),
19
- database: z.string().optional()
20
- }).optional().default({}),
17
+ knowledge: z.union([z.string(), z.array(z.string()), z.record(z.string(), z.any())]).optional(),
18
+ state: z.record(z.string(), z.any()).optional()
19
+ }).passthrough().optional().default({}),
21
20
  A: z.object({
22
21
  name: z.string().min(1, "Agent name is required"),
23
- version: z.string().optional().default("1.0.0"),
22
+ version: z.string().optional().default("0.0.1"),
24
23
  intent: z.string().optional(),
25
- author: z.string().optional(),
26
- skills: z.union([z.string(), z.array(z.string())]).optional(),
27
24
  maxSteps: z.number().optional().default(10),
28
- subagents: z.array(z.string()).optional()
29
- }),
25
+ skills: z.array(z.string()).optional()
26
+ }).passthrough(),
30
27
  T: z.union([
31
- z.array(z.union([z.string(), z.record(z.any())])),
32
- z.record(z.any())
28
+ z.array(z.union([z.string(), z.record(z.string(), z.any())])),
29
+ z.record(z.string(), z.any())
33
30
  ]).optional().default([]),
34
- E: z.record(z.string()).optional().default({})
31
+ E: z.record(z.string(), z.string()).optional().default({})
35
32
  });
36
33
 
37
34
  export class AUM {
38
- public static parse(manifestOrJson: string | object): AgentManifest {
35
+ /**
36
+ * Normalizes module properties supporting pure LIATE authoring:
37
+ * 1. Shorthand: L, I, A, T, E
38
+ * 2. Full Name: LLM, Integration, Agent, Tools, Environment
39
+ * 3. Lowercase: llm, integration, agent, tools, environment
40
+ */
41
+ public static normalize(rawObj: any): any {
42
+ if (!rawObj || typeof rawObj !== "object") return rawObj;
43
+
44
+ const L = rawObj.L ?? rawObj.LLM ?? rawObj.llm;
45
+ const I = rawObj.I ?? rawObj.Integration ?? rawObj.integration;
46
+ const A = rawObj.A ?? rawObj.Agent ?? rawObj.agent;
47
+ const T = rawObj.T ?? rawObj.Tools ?? rawObj.tools;
48
+ const E = rawObj.E ?? rawObj.Environment ?? rawObj.environment;
49
+
50
+ return {
51
+ ...rawObj,
52
+ L,
53
+ I: I ?? {},
54
+ A: typeof A === "string" ? { name: A } : (A ?? {}),
55
+ T: T ?? [],
56
+ E: E ?? {}
57
+ };
58
+ }
59
+
60
+ public static parse(moduleOrJson: string | object): AgentModule {
39
61
  let rawObj: any;
40
62
 
41
- if (typeof manifestOrJson === "string") {
42
- try {
43
- rawObj = JSON.parse(manifestOrJson);
44
- } catch (err: any) {
45
- throw new Error(`Failed to parse AUM manifest JSON: ${err.message}`);
63
+ if (typeof moduleOrJson === "string") {
64
+ const trimmed = moduleOrJson.trim();
65
+ if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
66
+ try {
67
+ rawObj = JSON.parse(moduleOrJson);
68
+ } catch (err: any) {
69
+ throw new Error(`Failed to parse AUM module JSON: ${err.message}`);
70
+ }
71
+ } else if (trimmed.includes("class ") || trimmed.includes("extends liate") || trimmed.includes("export ")) {
72
+ try {
73
+ let code = trimmed
74
+ .replace(/import\s+[\s\S]*?;/g, "")
75
+ .replace(/export\s+default\s+/g, "")
76
+ .replace(/export\s+/g, "")
77
+ .replace(/extends\s+(liate|Liate)/g, "")
78
+ .replace(/if\s*\(import\.meta\.main\)[\s\S]*$/, "");
79
+
80
+ const match = code.match(/class\s+([A-Za-z0-9_]+)/);
81
+ const className = match ? match[1] : "Agent";
82
+ const fn = new Function(code + `\n return new ${className}();`);
83
+ const inst = fn();
84
+ rawObj = {
85
+ L: inst.L ?? inst.LLM ?? inst.llm,
86
+ I: inst.I ?? inst.Integration ?? inst.integration,
87
+ A: inst.A ?? inst.Agent ?? inst.agent,
88
+ T: inst.T ?? inst.Tools ?? inst.tools,
89
+ E: inst.E ?? inst.Environment ?? inst.environment
90
+ };
91
+ } catch (err: any) {
92
+ throw new Error(`Failed to parse agent TypeScript/JavaScript definition: ${err.message}`);
93
+ }
94
+ } else {
95
+ try {
96
+ rawObj = JSON.parse(moduleOrJson);
97
+ } catch (err: any) {
98
+ throw new Error(`Failed to parse AUM module: ${err.message}`);
99
+ }
46
100
  }
47
101
  } else {
48
- rawObj = manifestOrJson;
102
+ rawObj = moduleOrJson;
49
103
  }
50
104
 
51
- const result = AUMSchema.safeParse(rawObj);
105
+ const normalized = AUM.normalize(rawObj);
106
+ const result = AUMSchema.safeParse(normalized);
52
107
 
53
108
  if (!result.success) {
54
109
  const issues = result.error.issues.map((i) => `[${i.path.join(".")}] ${i.message}`).join(", ");
55
- throw new Error(`Invalid AUM Manifest: ${issues}`);
110
+ throw new Error(`Invalid AUM Module: ${issues}`);
56
111
  }
57
112
 
58
- return result.data as AgentManifest;
113
+ return result.data as AgentModule;
59
114
  }
60
115
 
61
- public static resolveEnvironment(manifest: AgentManifest, customEnv: Record<string, string | undefined> = process.env): AgentManifest {
116
+ public static resolveEnvironment(
117
+ module: AgentModule,
118
+ customEnv: Record<string, string | undefined> = process.env
119
+ ): AgentModule {
62
120
  const resolvedE: Record<string, string> = {};
63
121
 
64
- for (const [key, val] of Object.entries(manifest.E || {})) {
122
+ for (const [key, val] of Object.entries(module.E || {})) {
65
123
  if (typeof val === "string" && val.startsWith("$")) {
66
124
  const envVarName = val.slice(1);
67
125
  resolvedE[key] = customEnv[envVarName] || "";
@@ -71,8 +129,9 @@ export class AUM {
71
129
  }
72
130
 
73
131
  return {
74
- ...manifest,
132
+ ...module,
75
133
  E: resolvedE
76
134
  };
77
135
  }
78
136
  }
137
+
package/src/core/om.ts ADDED
@@ -0,0 +1,159 @@
1
+ import { Agent } from "@/layers/agent/harness";
2
+ import type { AgentRunResult, AgentExecutionOptions } from "@/layers/agent/types";
3
+ import type { AgentModule } from "@/core/spec";
4
+ import { AUM } from "@/core/aum";
5
+ import { ToolRegistry } from "@/layers/tools/registry";
6
+ import { EnvironmentResolver } from "@/layers/environment/sandbox";
7
+ import { Session } from "@/layers/integration/memory";
8
+
9
+ export * from "@/core/spec";
10
+ export * from "@/core/aum";
11
+
12
+ /**
13
+ * Core Orchestration Module (OM)
14
+ *
15
+ * "Where a Class is an Agent"
16
+ *
17
+ * 1 Class = 5 Properties (`L · I · A · T · E`) = 1:1 identical to agent.json
18
+ */
19
+ export class liate {
20
+ // 1. Shorthand: L · I · A · T · E
21
+ public L?: any;
22
+ public I?: any;
23
+ public A?: any;
24
+ public T?: any;
25
+ public E?: Record<string, string | undefined>;
26
+
27
+ // 2. Full Name: LLM · Integration · Agent · Tools · Environment
28
+ public LLM?: any;
29
+ public Integration?: any;
30
+ public Agent?: any;
31
+ public Tools?: any;
32
+ public Environment?: Record<string, string | undefined>;
33
+
34
+ // 3. Lowercase: llm · integration · agent · tools · environment
35
+ public llm?: any;
36
+ public integration?: any;
37
+ public agent?: any;
38
+ public tools?: any;
39
+ public environment?: Record<string, string | undefined>;
40
+
41
+ private _runner?: Agent;
42
+
43
+ /**
44
+ * Initializes and returns the underlying Agent harness instance
45
+ */
46
+ public async getRunner(): Promise<Agent> {
47
+ if (!this._runner) {
48
+ const module = this.toModule();
49
+ EnvironmentResolver.loadEnv();
50
+ const resolvedEnv = EnvironmentResolver.resolve(module.E || {});
51
+
52
+ const memory = new Session(module.I?.memory || "ephemeral");
53
+ const tools = await ToolRegistry.resolveTools(module.T || [], resolvedEnv);
54
+
55
+ const agentName = typeof module.A === "object" ? module.A.name : (module.A || this.constructor.name);
56
+ const agentIntent = typeof module.A === "object" ? module.A.intent : undefined;
57
+ const maxSteps = typeof module.A === "object" ? module.A.maxSteps : 10;
58
+ const skills = typeof module.A === "object" && Array.isArray(module.A.skills) ? module.A.skills : undefined;
59
+ const model = typeof module.L === "string" ? module.L : (module.L?.model || "sarvam/sarvam-105b-conversations");
60
+ const modelExtra = typeof module.L === "object" ? module.L : {};
61
+
62
+ this._runner = new Agent({
63
+ name: agentName,
64
+ intent: agentIntent,
65
+ model,
66
+ maxSteps,
67
+ skills,
68
+ memory,
69
+ tools,
70
+ ...modelExtra
71
+ } as any);
72
+ }
73
+ return this._runner;
74
+ }
75
+
76
+ /**
77
+ * Executes the agent on a user input via the autonomous ReAct reasoning loop
78
+ */
79
+ public async run(input: string, options?: AgentExecutionOptions): Promise<AgentRunResult> {
80
+ const runner = await this.getRunner();
81
+ return runner.run(input, options);
82
+ }
83
+
84
+ /**
85
+ * Gracefully closes all background transports, child processes, and MCP connections
86
+ */
87
+ public async close(): Promise<void> {
88
+ const { MCP } = await import("@/layers/tools/mcp");
89
+ await MCP.closeAll();
90
+ }
91
+
92
+ /**
93
+ * Instantiates an agent directly from an Agent Unified Module (AUM) or agent.json object
94
+ */
95
+ public static from(spec: any): liate {
96
+ const instance = new liate();
97
+ const parsed = AUM.parse(spec);
98
+ instance.L = parsed.L;
99
+ instance.I = parsed.I;
100
+ instance.A = parsed.A;
101
+ instance.T = parsed.T;
102
+ instance.E = parsed.E;
103
+ return instance;
104
+ }
105
+
106
+ /**
107
+ * Loads an agent directly from an agent.json file path or hub agent name
108
+ */
109
+ public static async load(filePath: string): Promise<liate> {
110
+ const fs = await import("fs/promises");
111
+ const { existsSync } = await import("fs");
112
+ const path = await import("path");
113
+
114
+ let resolvedPath = path.isAbsolute(filePath) ? filePath : path.resolve(process.cwd(), filePath);
115
+
116
+ if (!existsSync(resolvedPath)) {
117
+ // Check if it's a directory containing agent.json
118
+ if (existsSync(path.join(resolvedPath, "agent.json"))) {
119
+ resolvedPath = path.join(resolvedPath, "agent.json");
120
+ } else {
121
+ // Check in hub/agents
122
+ const hubCandidate = path.resolve(process.cwd(), "hub", "agents", filePath, "agent.json");
123
+ if (existsSync(hubCandidate)) {
124
+ resolvedPath = hubCandidate;
125
+ }
126
+ }
127
+ } else {
128
+ // If path exists and is a directory, look for agent.json inside
129
+ const stat = await fs.stat(resolvedPath);
130
+ if (stat.isDirectory()) {
131
+ const nested = path.join(resolvedPath, "agent.json");
132
+ if (existsSync(nested)) {
133
+ resolvedPath = nested;
134
+ }
135
+ }
136
+ }
137
+
138
+ const raw = await fs.readFile(resolvedPath, "utf-8");
139
+ const json = JSON.parse(raw);
140
+ return liate.from(json);
141
+ }
142
+
143
+ /**
144
+ * Exports the declarative L·I·A·T·E Agent Unified Module (AUM) representation
145
+ */
146
+ public toModule(): AgentModule {
147
+ const L = this.L ?? this.LLM ?? this.llm;
148
+ const I = this.I ?? this.Integration ?? this.integration;
149
+ const A = this.A ?? this.Agent ?? this.agent ?? { name: this.constructor.name };
150
+ const T = this.T ?? this.Tools ?? this.tools ?? [];
151
+ const E = this.E ?? this.Environment ?? this.environment ?? {};
152
+
153
+ return AUM.parse({ L, I, A, T, E });
154
+ }
155
+ }
156
+
157
+ // Clean alias
158
+ export const Liate = liate;
159
+
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Liate — Open Source AI Agents Framework
3
+ * Built for Sovereign AI Agents From India to the World.
4
+ *
5
+ * The 5 Layers:
6
+ * L[LM] — Sovereign Language Models & Reasoning
7
+ * I[ntegration] — Session Memory, Knowledge Context & State
8
+ * A[gent] — Identity, Name, Intent & Autonomous ReAct Loop
9
+ * T[ools] — Tools of MCP Server V2 (Stdio & Remote HTTP/SSE)
10
+ * E[nvironment] — Environment Variables, Secrets & Sandbox Configuration
11
+ */
12
+
13
+ /**
14
+ * [L] LLM Layer
15
+ * Sovereign Language Models: Sarvam AI 105B & OpenAI-compatible providers.
16
+ */
17
+ export type LayerL =
18
+ | string
19
+ | {
20
+ provider?: string;
21
+ model: string;
22
+ baseUrl?: string;
23
+ apiKey?: string;
24
+ temperature?: number;
25
+ maxTokens?: number;
26
+ };
27
+
28
+ export type ModelConfig = LayerL;
29
+
30
+ /**
31
+ * [I] Integration Layer
32
+ * Memory, Knowledge Context, and Persistence.
33
+ */
34
+ export interface LayerI {
35
+ knowledge?: string | string[] | Record<string, unknown>;
36
+ memory?: string;
37
+ state?: Record<string, unknown>;
38
+ [key: string]: unknown;
39
+ }
40
+
41
+ /**
42
+ * [A] Agent Layer
43
+ * Identity: Name, Intent, Version, maxSteps.
44
+ */
45
+ export interface LayerA {
46
+ name: string;
47
+ intent?: string;
48
+ version?: string;
49
+ system?: string;
50
+ maxSteps?: number;
51
+ skills?: string[];
52
+ [key: string]: unknown;
53
+ }
54
+
55
+ /**
56
+ * [T] Tools Layer
57
+ * Tools of MCP Server V2 (Local Stdio & Remote HTTP/SSE), Custom Handlers.
58
+ */
59
+ export interface ToolDefinition {
60
+ name?: string;
61
+ description?: string;
62
+ command?: string;
63
+ args?: string[];
64
+ url?: string;
65
+ tools?: string[];
66
+ parameters?: Record<string, unknown>;
67
+ execute?: (args: Record<string, unknown>) => Promise<unknown> | unknown;
68
+ [key: string]: unknown;
69
+ }
70
+
71
+ export type LayerT =
72
+ | Array<string | ToolDefinition>
73
+ | Record<string, ToolDefinition | string | Record<string, unknown>>;
74
+
75
+ /**
76
+ * [E] Environment Layer
77
+ * Configuration, API keys, and environment variables (.env).
78
+ */
79
+ export type LayerE = Record<string, string | undefined>;
80
+
81
+ /**
82
+ * The 5 Layers Agent Specification (AgentSpec / AgentModule)
83
+ * Supports authoring across 3 casing conventions:
84
+ * 1. Shorthand: L · I · A · T · E
85
+ * 2. Full Name: LLM · Integration · Agent · Tools · Environment
86
+ * 3. Lowercase: llm · integration · agent · tools · environment
87
+ */
88
+ export interface AgentSpec {
89
+ L: LayerL;
90
+ I?: LayerI;
91
+ A: LayerA | string;
92
+ T?: LayerT;
93
+ E?: LayerE;
94
+
95
+ // Full-name aliases
96
+ LLM?: LayerL;
97
+ llm?: LayerL;
98
+
99
+ Integration?: LayerI;
100
+ integration?: LayerI;
101
+
102
+ Agent?: LayerA | string;
103
+ agent?: LayerA | string;
104
+
105
+ Tools?: LayerT;
106
+ tools?: LayerT;
107
+
108
+ Environment?: LayerE;
109
+ environment?: LayerE;
110
+ }
111
+
112
+ export type AgentModule = AgentSpec;
package/src/core/uuid.ts CHANGED
@@ -1,19 +1,8 @@
1
- /**
2
- * UUIDv7 (RFC 9562) - Time-sorted 128-bit identifiers.
3
- * Guarantees monotonic ordering across deployments, agent execution IDs, and sessions.
4
- */
5
- export function generateUUIDv7(): string {
6
- const timestamp = BigInt(Date.now());
7
- const randA = BigInt(Math.floor(Math.random() * 0x1000));
8
- const randB = BigInt(Math.floor(Math.random() * 0x3fffffff));
9
- const randC = BigInt(Math.floor(Math.random() * 0x3fffffff));
1
+ // src/core/uuid.ts
2
+ import { randomUUID } from "node:crypto";
10
3
 
11
- const high = (timestamp << 16n) | (0x7n << 12n) | (randA & 0xfffn);
12
- const low = (0x2n << 62n) | ((randB & 0x3fffffffn) << 32n) | (randC & 0xffffffffn);
13
-
14
- const hexHigh = high.toString(16).padStart(16, "0");
15
- const hexLow = low.toString(16).padStart(16, "0");
16
-
17
- return `${hexHigh.slice(0, 8)}-${hexHigh.slice(8, 12)}-${hexHigh.slice(12, 16)}-${hexLow.slice(0, 4)}-${hexLow.slice(4, 16)}`.toLowerCase();
4
+ export function generateId(prefix?: string): string {
5
+ const id = randomUUID();
6
+ return prefix ? `${prefix}_${id}` : id;
18
7
  }
19
8
 
@@ -0,0 +1,2 @@
1
+ // src/core/version.ts
2
+ export const VERSION = "0.1.6";