@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.
- package/LICENSE +21 -0
- package/README.md +127 -2
- package/README.npm.md +128 -0
- package/dist/bin.js +28745 -0
- package/dist/liate.js +39479 -0
- package/dist/runtime/hono.js +28072 -0
- package/dist/runtime/index.js +28072 -0
- package/hub/agents/docgyan-agent/agent.json +27 -0
- package/hub/agents/docgyan-agent/agent.ts +39 -0
- package/hub/agents/gnani-agent/agent.json +17 -0
- package/hub/agents/neon-agent/agent.json +18 -0
- package/hub/agents/prism-agent/agent.json +17 -0
- package/hub/agents/sarvam-agent/agent.json +22 -0
- package/package.json +71 -4
- package/src/cli/index.ts +346 -0
- package/src/cli/resolver.ts +153 -0
- package/src/core/aum.ts +137 -0
- package/src/core/om.ts +159 -0
- package/src/core/spec.ts +112 -0
- package/src/core/uuid.ts +8 -0
- package/src/core/version.ts +2 -0
- package/src/layers/agent/harness.ts +118 -0
- package/src/layers/agent/loop.ts +203 -0
- package/src/layers/agent/skills.ts +302 -0
- package/src/layers/agent/types.ts +66 -0
- package/src/layers/environment/sandbox.ts +107 -0
- package/src/layers/environment/types.ts +23 -0
- package/src/layers/integration/knowledge.ts +187 -0
- package/src/layers/integration/lib.ts +167 -0
- package/src/layers/integration/memory.ts +135 -0
- package/src/layers/integration/repo.ts +273 -0
- package/src/layers/integration/types.ts +60 -0
- package/src/layers/llm/model.ts +928 -0
- package/src/layers/llm/types.ts +64 -0
- package/src/layers/tools/mcp.ts +236 -0
- package/src/layers/tools/registry.ts +307 -0
- package/src/layers/tools/server.ts +69 -0
- package/src/layers/tools/types.ts +38 -0
- package/src/liate.ts +65 -0
- package/src/routes/skills.ts +73 -0
- package/src/runtime/hono.ts +346 -0
- package/src/runtime/wasm.ts +23 -0
- package/src/scaffold/project.ts +188 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"L": "sarvam/sarvam-105b",
|
|
3
|
+
"I": {
|
|
4
|
+
"memory": "sessions/docgyan-agent",
|
|
5
|
+
"context": "https://openliate.tech/docs"
|
|
6
|
+
},
|
|
7
|
+
"A": {
|
|
8
|
+
"name": "docgyan",
|
|
9
|
+
"version": "0.1.0",
|
|
10
|
+
"intent": "Frontier Documentation & Code Intelligence Agent for OpenLiate (https://openliate.tech/docs) under the sovereign AgentYaan mission. Built on Liate and powered by Sarvam AI. LIATE is strictly the 5 mathematical architectural layers derived from calculus integration by parts: L [Large Models Layer], I [Integration & Memory], A [Agent Loop], T [Tools/MCP v2], E [Environment & Sandbox]. Formula: Agent = L ∘ I ∘ A ∘ T ∘ E. NEVER invent fake backronyms like 'Layered Intelligent Agent & Tooling Engine'. Uphold the Four Truths: Class is an Agent, Agent is a Function, Function is an API, Liate API is Your Backend. If asked who you are, introduce yourself as DocGyan (डॉकज्ञान), the sovereign documentation & knowledge agent for OpenLiate.",
|
|
11
|
+
"maxSteps": 8
|
|
12
|
+
},
|
|
13
|
+
"T": {
|
|
14
|
+
"fetch": {
|
|
15
|
+
"command": "uvx",
|
|
16
|
+
"args": [
|
|
17
|
+
"mcp-server-fetch"
|
|
18
|
+
],
|
|
19
|
+
"tools": [
|
|
20
|
+
"*"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"E": {
|
|
25
|
+
"SARVAM_API_KEY": "$SARVAM_API_KEY"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { liate } from "../../../dist/liate.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* DocGyanAgent — Official OpenLiate Documentation & Code Intelligence Agent
|
|
5
|
+
* Under the AgentYaan Sovereign Mission 🇮🇳 🌍
|
|
6
|
+
*
|
|
7
|
+
* "Where Class is an Agent, and Agent is an API."
|
|
8
|
+
*
|
|
9
|
+
* Mathematical 5-Layer Formulation: Agent = L ∘ I ∘ A ∘ T ∘ E
|
|
10
|
+
*/
|
|
11
|
+
export class DocGyanAgent extends liate {
|
|
12
|
+
public L = "sarvam/sarvam-105b";
|
|
13
|
+
|
|
14
|
+
public I = {
|
|
15
|
+
memory: "sessions/docgyan-agent",
|
|
16
|
+
context: "https://openliate.tech/docs"
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
public A = {
|
|
20
|
+
name: "docgyan",
|
|
21
|
+
version: "0.1.0",
|
|
22
|
+
intent: `Frontier Documentation & Code Intelligence Agent for OpenLiate (https://openliate.tech/docs) under the sovereign AgentYaan mission. Built on Liate and powered by Sarvam AI. LIATE is strictly the 5 mathematical architectural layers derived from calculus integration by parts: L [Large Models Layer], I [Integration & Memory], A [Agent Loop], T [Tools/MCP v2], E [Environment & Sandbox]. Formula: Agent = L ∘ I ∘ A ∘ T ∘ E. NEVER invent fake backronyms like 'Layered Intelligent Agent & Tooling Engine'. Uphold the Four Truths: Class is an Agent, Agent is a Function, Function is an API, Liate API is Your Backend. If asked who you are, introduce yourself as DocGyan (डॉकज्ञान), the sovereign documentation & codebase intelligence agent for OpenLiate.`,
|
|
23
|
+
maxSteps: 8
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
public T = {
|
|
27
|
+
fetch: {
|
|
28
|
+
command: "uvx",
|
|
29
|
+
args: ["mcp-server-fetch"],
|
|
30
|
+
tools: ["*"]
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
public E = {
|
|
35
|
+
SARVAM_API_KEY: process.env.SARVAM_API_KEY
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default DocGyanAgent;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"L": "gnani/timbre-v3.0",
|
|
3
|
+
"I": {
|
|
4
|
+
"memory": "sessions/gnani-agent"
|
|
5
|
+
},
|
|
6
|
+
"A": {
|
|
7
|
+
"name": "gnani_agent",
|
|
8
|
+
"version": "0.0.1",
|
|
9
|
+
"intent": "Sovereign Indic Voice & Language Agent powered by Gnani AI & Liate",
|
|
10
|
+
"maxSteps": 5
|
|
11
|
+
},
|
|
12
|
+
"T": [],
|
|
13
|
+
"E": {
|
|
14
|
+
"GNANI_API_KEY": "$GNANI_API_KEY",
|
|
15
|
+
"GNANI_BASE_URL": "$GNANI_BASE_URL"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"L": "neon/gpt-5-4-nano",
|
|
3
|
+
"I": {
|
|
4
|
+
"memory": "sessions/neon-agent"
|
|
5
|
+
},
|
|
6
|
+
"A": {
|
|
7
|
+
"name": "neon_agent",
|
|
8
|
+
"version": "0.1.1",
|
|
9
|
+
"intent": "Agent powered by Neon AI Gateway & Cloud Compute",
|
|
10
|
+
"maxSteps": 5
|
|
11
|
+
},
|
|
12
|
+
"T": [],
|
|
13
|
+
"E": {
|
|
14
|
+
"NEON_AI_GATEWAY_TOKEN": "$NEON_AI_GATEWAY_TOKEN",
|
|
15
|
+
"NEON_AI_GATEWAY_BASE_URL": "$NEON_AI_GATEWAY_BASE_URL",
|
|
16
|
+
"DATABASE_URL": "$DATABASE_URL"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"L": "sarvam/sarvam-prism",
|
|
3
|
+
"I": {
|
|
4
|
+
"memory": "sessions/prism-agent"
|
|
5
|
+
},
|
|
6
|
+
"A": {
|
|
7
|
+
"name": "login_guard",
|
|
8
|
+
"version": "1.0.0",
|
|
9
|
+
"intent": "Evaluate user login attempts and security context to detect anomalies, credential risk, and authorize secure access",
|
|
10
|
+
"maxSteps": 1
|
|
11
|
+
},
|
|
12
|
+
"T": [],
|
|
13
|
+
"E": {
|
|
14
|
+
"SARVAM_API_KEY": "$SARVAM_API_KEY"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"L": "sarvam/sarvam-105b",
|
|
3
|
+
"I": {
|
|
4
|
+
"memory": "sessions/sarvam-agent"
|
|
5
|
+
},
|
|
6
|
+
"A": {
|
|
7
|
+
"name": "sarvam_agent",
|
|
8
|
+
"version": "1.0.0",
|
|
9
|
+
"intent": "Autonomous Sovereign Indic AI Agent powered by Sarvam AI 105B and Sarvam MCP tools (Bulbul v4-Flash TTS & Saaras v4 STT)",
|
|
10
|
+
"maxSteps": 8
|
|
11
|
+
},
|
|
12
|
+
"T": {
|
|
13
|
+
"sarvam": {
|
|
14
|
+
"command": "uvx",
|
|
15
|
+
"args": ["sarvam-mcp"],
|
|
16
|
+
"tools": ["*"]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"E": {
|
|
20
|
+
"SARVAM_API_KEY": "$SARVAM_API_KEY"
|
|
21
|
+
}
|
|
22
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,73 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openliate/liate",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.6",
|
|
4
|
+
"description": "LIATE — Open Source OOP Framework for AI Agents · From India, For India, Beyond India",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/liate.js",
|
|
7
|
+
"types": "./src/liate.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./src/liate.ts",
|
|
11
|
+
"import": "./dist/liate.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"liate": "dist/bin.js"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist/bin.js",
|
|
19
|
+
"dist/liate.js",
|
|
20
|
+
"dist/runtime",
|
|
21
|
+
"src",
|
|
22
|
+
"hub"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"test": "echo \"Ready for tests\"",
|
|
26
|
+
"build": "bun run build:bin && bun run build:cli && bun run build:runtime && bun run build:hono && bun run build:sdk",
|
|
27
|
+
"build:bin": "bun build ./src/cli/index.ts --target node --format esm --outfile dist/bin.js",
|
|
28
|
+
"build:cli": "bun build ./src/cli/index.ts --compile --outfile dist/cli/liate",
|
|
29
|
+
"build:runtime": "bun build ./src/runtime/hono.ts --target node --format esm --outfile dist/runtime/index.js",
|
|
30
|
+
"build:sdk": "bun build ./src/liate.ts --target node --format esm --outfile dist/liate.js",
|
|
31
|
+
"build:compile": "bun build ./src/liate.ts --compile --outfile dist/liate",
|
|
32
|
+
"compile": "bun run build:compile",
|
|
33
|
+
"serve": "bun run dist/runtime/index.js",
|
|
34
|
+
"typecheck": "tsc --noEmit",
|
|
35
|
+
"build:hono": "bun build ./src/runtime/hono.ts --target bun --format esm --outfile dist/runtime/hono.js",
|
|
36
|
+
"pack:all": "node scripts/packer.mjs",
|
|
37
|
+
"publish:all": "node scripts/publisher.mjs",
|
|
38
|
+
"bump": "node scripts/bump.mjs"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@hono/node-server": "2.1.5",
|
|
42
|
+
"@modelcontextprotocol/client": "2.4.0",
|
|
43
|
+
"@modelcontextprotocol/core": "2.4.0",
|
|
44
|
+
"@modelcontextprotocol/server": "2.4.0",
|
|
45
|
+
"hono": "^4.7.0",
|
|
46
|
+
"jszip": "3.10.2",
|
|
47
|
+
"zod": "4.6.7"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/node": "^26.0.0",
|
|
51
|
+
"bun-types": "1.4.4",
|
|
52
|
+
"typescript": "^5.7.0"
|
|
53
|
+
},
|
|
54
|
+
"keywords": [
|
|
55
|
+
"liate",
|
|
56
|
+
"agent",
|
|
57
|
+
"autonomous-agents",
|
|
58
|
+
"sovereign-ai",
|
|
59
|
+
"agent-platform",
|
|
60
|
+
"runtime",
|
|
61
|
+
"mcp"
|
|
62
|
+
],
|
|
63
|
+
"author": "Vinod Hatti (@gitdevinod)",
|
|
64
|
+
"license": "MIT",
|
|
65
|
+
"repository": {
|
|
66
|
+
"type": "git",
|
|
67
|
+
"url": "git+https://github.com/OpenLiate/Liate.git"
|
|
68
|
+
},
|
|
69
|
+
"bugs": {
|
|
70
|
+
"url": "https://github.com/OpenLiate/Liate/issues"
|
|
71
|
+
},
|
|
72
|
+
"homepage": "https://openliate.tech"
|
|
73
|
+
}
|
package/src/cli/index.ts
ADDED
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// src/cli/index.ts
|
|
3
|
+
// Liate v0.1.0 — Unified Developer CLI Engine
|
|
4
|
+
// Commands: run, chat, serve, hub
|
|
5
|
+
|
|
6
|
+
import { resolveAgent } from "@/cli/resolver";
|
|
7
|
+
import { VERSION } from "@/core/version";
|
|
8
|
+
import { EnvironmentResolver } from "@/layers/environment/sandbox";
|
|
9
|
+
import * as readline from "node:readline/promises";
|
|
10
|
+
import { stdin as input, stdout as output } from "node:process";
|
|
11
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
12
|
+
import { resolve } from "node:path";
|
|
13
|
+
|
|
14
|
+
function printHelp(): void {
|
|
15
|
+
console.log(`
|
|
16
|
+
LIATE — Open Source OOP Framework for AI Agents (v${VERSION})
|
|
17
|
+
Where Classes Are AI Agents · From India, For India, Beyond India 🇮🇳 🌍
|
|
18
|
+
|
|
19
|
+
Usage:
|
|
20
|
+
liate <command> [options]
|
|
21
|
+
|
|
22
|
+
Commands:
|
|
23
|
+
run [file] <prompt> Execute an agent with a single prompt
|
|
24
|
+
chat [file] Start an interactive multi-turn REPL chat session
|
|
25
|
+
serve [file] [--port] Start the Hono edge runtime server (default: 7071)
|
|
26
|
+
create <name> [--py] Create a new Liate agent project (aliases: init, new)
|
|
27
|
+
skills <cmd> [arg] Manage skills.sh skills (find, add, update)
|
|
28
|
+
env <set|list|rm> Manage local .env.local secrets safely
|
|
29
|
+
hub List available local hub agent templates
|
|
30
|
+
|
|
31
|
+
Options:
|
|
32
|
+
-v, --version Show Liate version
|
|
33
|
+
-h, --help Show help documentation
|
|
34
|
+
|
|
35
|
+
Examples:
|
|
36
|
+
liate run "What is the capital of India?"
|
|
37
|
+
liate run agent.ts "Evaluate mandate policy"
|
|
38
|
+
liate run agent.json "Check current time"
|
|
39
|
+
liate chat
|
|
40
|
+
liate chat agent.ts
|
|
41
|
+
liate serve --port 7071
|
|
42
|
+
`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function main(): Promise<void> {
|
|
46
|
+
// Ensure local .env is loaded
|
|
47
|
+
EnvironmentResolver.loadEnv();
|
|
48
|
+
|
|
49
|
+
const args = process.argv.slice(2);
|
|
50
|
+
const command = args[0];
|
|
51
|
+
|
|
52
|
+
if (!command || command === "-h" || command === "--help" || command === "help") {
|
|
53
|
+
printHelp();
|
|
54
|
+
process.exit(0);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (command === "-v" || command === "--version" || command === "version") {
|
|
58
|
+
console.log(`Liate v${VERSION}`);
|
|
59
|
+
process.exit(0);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 1. Command: run
|
|
63
|
+
if (command === "run") {
|
|
64
|
+
const remaining = args.slice(1);
|
|
65
|
+
if (remaining.length === 0) {
|
|
66
|
+
console.error("Error: Missing prompt for 'liate run'.");
|
|
67
|
+
console.log("Usage: liate run [file] <prompt>");
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
let fileCandidate: string | undefined = undefined;
|
|
72
|
+
let promptParts: string[] = remaining;
|
|
73
|
+
|
|
74
|
+
// Check if first argument is a file or hub agent name
|
|
75
|
+
const cwd = process.cwd();
|
|
76
|
+
const isHubCandidate = existsSync(resolve(cwd, "hub", "agents", remaining[0]));
|
|
77
|
+
if (
|
|
78
|
+
remaining[0].endsWith(".ts") ||
|
|
79
|
+
remaining[0].endsWith(".json") ||
|
|
80
|
+
remaining[0].endsWith(".js") ||
|
|
81
|
+
existsSync(remaining[0]) ||
|
|
82
|
+
isHubCandidate
|
|
83
|
+
) {
|
|
84
|
+
fileCandidate = remaining[0];
|
|
85
|
+
promptParts = remaining.slice(1);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const prompt = promptParts.join(" ").trim();
|
|
89
|
+
if (!prompt) {
|
|
90
|
+
console.error("Error: Prompt cannot be empty.");
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const { agent, sourcePath, sourceType } = await resolveAgent(fileCandidate);
|
|
95
|
+
if (sourcePath) {
|
|
96
|
+
console.log(`[Liate] Running ${sourceType} agent from ${sourcePath} ...`);
|
|
97
|
+
} else {
|
|
98
|
+
console.log(`[Liate] Running ephemeral sovereign agent ...`);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const start = Date.now();
|
|
102
|
+
try {
|
|
103
|
+
const result = await agent.run(prompt);
|
|
104
|
+
|
|
105
|
+
if (result.thought) {
|
|
106
|
+
console.log(`\n[Reasoning]:\n${result.thought}`);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
console.log(`\n${result.text}\n`);
|
|
110
|
+
|
|
111
|
+
if (result.audioBase64) {
|
|
112
|
+
const audioDir = resolve(cwd, "temp", "audio");
|
|
113
|
+
if (!existsSync(audioDir)) {
|
|
114
|
+
mkdirSync(audioDir, { recursive: true });
|
|
115
|
+
}
|
|
116
|
+
const audioPath = resolve(audioDir, "timbre_output.wav");
|
|
117
|
+
writeFileSync(audioPath, Buffer.from(result.audioBase64, "base64"));
|
|
118
|
+
console.log(`[Audio Saved]: file:///${audioPath.replace(/\\/g, "/")}`);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
console.log(`[Completed in ${Date.now() - start}ms | Steps: ${result.totalSteps} | Model: ${result.model}]`);
|
|
122
|
+
} catch (err: any) {
|
|
123
|
+
console.error(`\n[Execution Error]: ${err.message}`);
|
|
124
|
+
process.exit(1);
|
|
125
|
+
} finally {
|
|
126
|
+
await agent.close();
|
|
127
|
+
}
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// 2. Command: chat
|
|
132
|
+
if (command === "chat") {
|
|
133
|
+
const fileCandidate = args[1];
|
|
134
|
+
const { agent, sourcePath, sourceType } = await resolveAgent(fileCandidate);
|
|
135
|
+
|
|
136
|
+
if (sourcePath) {
|
|
137
|
+
console.log(`[Liate] Interactive chat loaded from ${sourcePath} (${sourceType})`);
|
|
138
|
+
} else {
|
|
139
|
+
console.log(`[Liate] Interactive chat loaded (ephemeral sovereign agent)`);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
console.log("Type 'exit' or press Ctrl+C to quit.\n");
|
|
143
|
+
|
|
144
|
+
const rl = readline.createInterface({ input, output });
|
|
145
|
+
|
|
146
|
+
try {
|
|
147
|
+
while (true) {
|
|
148
|
+
const userInput = await rl.question("liate > ");
|
|
149
|
+
const trimmed = userInput.trim();
|
|
150
|
+
|
|
151
|
+
if (trimmed.toLowerCase() === "exit" || trimmed.toLowerCase() === "quit" || trimmed.toLowerCase() === "q") {
|
|
152
|
+
console.log("Session ended.");
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (!trimmed) continue;
|
|
157
|
+
|
|
158
|
+
const start = Date.now();
|
|
159
|
+
try {
|
|
160
|
+
const result = await agent.run(trimmed);
|
|
161
|
+
console.log(`\n${result.text}\n`);
|
|
162
|
+
console.log(`[${Date.now() - start}ms | Steps: ${result.totalSteps}]\n`);
|
|
163
|
+
} catch (err: any) {
|
|
164
|
+
console.error(`\n[Error]: ${err.message}\n`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
} finally {
|
|
168
|
+
rl.close();
|
|
169
|
+
await agent.close();
|
|
170
|
+
}
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// 3. Command: serve
|
|
175
|
+
if (command === "serve") {
|
|
176
|
+
let port = 7071;
|
|
177
|
+
const portFlagIndex = args.indexOf("--port");
|
|
178
|
+
if (portFlagIndex !== -1 && args[portFlagIndex + 1]) {
|
|
179
|
+
const parsedPort = Number(args[portFlagIndex + 1]);
|
|
180
|
+
if (!isNaN(parsedPort) && parsedPort > 0) {
|
|
181
|
+
port = parsedPort;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
process.env.PORT = String(port);
|
|
186
|
+
|
|
187
|
+
console.log(`[Liate] Booting Edge Runtime Server on port ${port} ...`);
|
|
188
|
+
const { startServer } = await import("@/runtime/hono");
|
|
189
|
+
startServer(port);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// 4. Command: create (aliases: init, new)
|
|
194
|
+
if (command === "create" || command === "init" || command === "new") {
|
|
195
|
+
const rest = args.slice(1);
|
|
196
|
+
const isPy = rest.includes("--py") || rest.includes("--python");
|
|
197
|
+
const name = rest.find((a) => !a.startsWith("-"));
|
|
198
|
+
if (!name) {
|
|
199
|
+
console.error("Error: Missing agent name. Usage: liate create <name> [--py]");
|
|
200
|
+
process.exit(1);
|
|
201
|
+
}
|
|
202
|
+
const { scaffoldProject } = await import("@/scaffold/project");
|
|
203
|
+
const result = scaffoldProject({ name, lang: isPy ? "py" : "ts" });
|
|
204
|
+
console.log(`\n[Liate] Scaffolded ${result.lang.toUpperCase()} agent '${result.projectName}' (${result.className})`);
|
|
205
|
+
console.log(`Location: ${result.projectDir}`);
|
|
206
|
+
console.log(`Files: ${result.files.join(", ")}\n`);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// 5. Command: skills (find | add | update)
|
|
211
|
+
if (command === "skills") {
|
|
212
|
+
const sub = args[1];
|
|
213
|
+
const arg = args.slice(2).join(" ").trim();
|
|
214
|
+
const { SkillResolver } = await import("@/layers/agent/skills");
|
|
215
|
+
|
|
216
|
+
if (sub === "find" || sub === "search") {
|
|
217
|
+
if (!arg) {
|
|
218
|
+
console.error("Usage: liate skills find <query>");
|
|
219
|
+
process.exit(1);
|
|
220
|
+
}
|
|
221
|
+
const results = await SkillResolver.search(arg, 10);
|
|
222
|
+
console.log(`\n[skills.sh] Found ${results.length} skills for "${arg}":\n`);
|
|
223
|
+
for (const r of results) {
|
|
224
|
+
const installs = r.installs != null ? ` (${r.installs.toLocaleString()} installs)` : "";
|
|
225
|
+
console.log(` • ${r.id}${installs}`);
|
|
226
|
+
}
|
|
227
|
+
console.log(`\nTo add a skill:\n liate skills add <id>\n`);
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (sub === "add") {
|
|
232
|
+
if (!arg) {
|
|
233
|
+
console.error("Usage: liate skills add <owner/repo/skill>");
|
|
234
|
+
process.exit(1);
|
|
235
|
+
}
|
|
236
|
+
const res = await SkillResolver.add(arg);
|
|
237
|
+
console.log(`\n[Liate] Added skill '${res.skill.name}' (${res.skill.instructions.length} bytes)`);
|
|
238
|
+
console.log(`Saved: ${res.savedPath}`);
|
|
239
|
+
if (res.updatedAgentJson) console.log(`Updated: agent.json (A.skills)\n`);
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (sub === "update") {
|
|
244
|
+
const res = await SkillResolver.update();
|
|
245
|
+
console.log(`\n[Liate] Updated ${res.updated.length} skill(s) from upstream.`);
|
|
246
|
+
for (const u of res.updated) {
|
|
247
|
+
console.log(` • ${u.slug} (${u.source}, ${u.bytes} bytes)`);
|
|
248
|
+
}
|
|
249
|
+
console.log();
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
console.error("Usage: liate skills <find|add|update> [arg]");
|
|
254
|
+
process.exit(1);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// 6. Command: env (set | list | rm)
|
|
258
|
+
if (command === "env") {
|
|
259
|
+
const sub = (args[1] || "list").toLowerCase();
|
|
260
|
+
const envPath = resolve(process.cwd(), ".env.local");
|
|
261
|
+
|
|
262
|
+
if (sub === "set" || sub === "add") {
|
|
263
|
+
const pair = args.slice(2).find((a) => a.includes("="));
|
|
264
|
+
if (!pair) {
|
|
265
|
+
console.error("Usage: liate env set KEY=VALUE");
|
|
266
|
+
process.exit(1);
|
|
267
|
+
}
|
|
268
|
+
const eq = pair.indexOf("=");
|
|
269
|
+
const key = pair.slice(0, eq).trim();
|
|
270
|
+
const val = pair.slice(eq + 1).replace(/^["']|["']$/g, "");
|
|
271
|
+
let content = existsSync(envPath) ? readFileSync(envPath, "utf-8") : "";
|
|
272
|
+
const re = new RegExp(`^${key}=.*$`, "m");
|
|
273
|
+
content = re.test(content)
|
|
274
|
+
? content.replace(re, `${key}="${val}"`)
|
|
275
|
+
: `${content.trim()}\n${key}="${val}"\n`;
|
|
276
|
+
writeFileSync(envPath, content.trim() + "\n", "utf-8");
|
|
277
|
+
const masked = val.length > 8 ? `${val.slice(0, 4)}...${val.slice(-4)}` : "******";
|
|
278
|
+
console.log(`[Liate] Saved '${key}' (${masked}) in .env.local`);
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (sub === "rm" || sub === "remove" || sub === "delete") {
|
|
283
|
+
const key = args[2]?.trim();
|
|
284
|
+
if (!key) {
|
|
285
|
+
console.error("Usage: liate env rm <KEY>");
|
|
286
|
+
process.exit(1);
|
|
287
|
+
}
|
|
288
|
+
if (existsSync(envPath)) {
|
|
289
|
+
const lines = readFileSync(envPath, "utf-8")
|
|
290
|
+
.split(/\r?\n/)
|
|
291
|
+
.filter((l) => !l.startsWith(`${key}=`));
|
|
292
|
+
writeFileSync(envPath, lines.join("\n").trim() + "\n", "utf-8");
|
|
293
|
+
}
|
|
294
|
+
console.log(`[Liate] Removed '${key}' from .env.local`);
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (!existsSync(envPath)) {
|
|
299
|
+
console.log("\n[Liate] No .env.local found. Add a key with: liate env set KEY=VALUE\n");
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
const lines = readFileSync(envPath, "utf-8")
|
|
303
|
+
.split(/\r?\n/)
|
|
304
|
+
.filter((l) => l.trim() && !l.trim().startsWith("#") && l.includes("="));
|
|
305
|
+
console.log(`\n[Liate] .env.local (${lines.length} keys):`);
|
|
306
|
+
for (const line of lines) {
|
|
307
|
+
const eq = line.indexOf("=");
|
|
308
|
+
const k = line.slice(0, eq).trim();
|
|
309
|
+
const v = line.slice(eq + 1).trim().replace(/^["']|["']$/g, "");
|
|
310
|
+
const masked = v.length > 8 ? `${v.slice(0, 4)}...${v.slice(-4)}` : "******";
|
|
311
|
+
console.log(` • ${k}: ${masked}`);
|
|
312
|
+
}
|
|
313
|
+
console.log();
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// 7. Command: hub
|
|
318
|
+
if (command === "hub") {
|
|
319
|
+
const { listLocalHubAgents } = await import("@/cli/resolver");
|
|
320
|
+
const agents = listLocalHubAgents();
|
|
321
|
+
|
|
322
|
+
if (agents.length === 0) {
|
|
323
|
+
console.log("[Liate Hub] No local hub agents found in hub/agents.");
|
|
324
|
+
process.exit(0);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
console.log(`\nLiate Hub — Local Sovereign Agent Templates (${agents.length} available):\n`);
|
|
328
|
+
for (const a of agents) {
|
|
329
|
+
console.log(` • ${a.id.padEnd(16)} [${a.model}]`);
|
|
330
|
+
console.log(` ${a.intent}\n`);
|
|
331
|
+
}
|
|
332
|
+
console.log(`To run a hub agent:\n liate run ${agents[0].id} "<prompt>"\n`);
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// Unknown command fallback
|
|
337
|
+
console.error(`Unknown command: '${command}'`);
|
|
338
|
+
printHelp();
|
|
339
|
+
process.exit(1);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
main().catch((err) => {
|
|
343
|
+
console.error("[Liate CLI Fatal Error]:", err.message);
|
|
344
|
+
process.exit(1);
|
|
345
|
+
});
|
|
346
|
+
|