@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,273 @@
|
|
|
1
|
+
// src/layers/integration/repo.ts
|
|
2
|
+
// Layer [I] GitHub & Local Git Repository Context Resolver
|
|
3
|
+
|
|
4
|
+
import { execSync } from "node:child_process";
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
|
|
8
|
+
export interface RepoIssue {
|
|
9
|
+
number: number;
|
|
10
|
+
title: string;
|
|
11
|
+
state: string;
|
|
12
|
+
author?: string;
|
|
13
|
+
labels?: string[];
|
|
14
|
+
createdAt?: string;
|
|
15
|
+
url?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface RepoPullRequest {
|
|
19
|
+
number: number;
|
|
20
|
+
title: string;
|
|
21
|
+
state: string;
|
|
22
|
+
author?: string;
|
|
23
|
+
draft?: boolean;
|
|
24
|
+
createdAt?: string;
|
|
25
|
+
url?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface RepoRelease {
|
|
29
|
+
tag: string;
|
|
30
|
+
name: string;
|
|
31
|
+
publishedAt?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface RepoContext {
|
|
35
|
+
repo: string;
|
|
36
|
+
branch?: string;
|
|
37
|
+
files?: string[];
|
|
38
|
+
readme?: string;
|
|
39
|
+
recentCommits?: string[];
|
|
40
|
+
issues?: RepoIssue[];
|
|
41
|
+
pullRequests?: RepoPullRequest[];
|
|
42
|
+
releases?: RepoRelease[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface RepoOptions {
|
|
46
|
+
issues?: boolean | number;
|
|
47
|
+
pulls?: boolean | number;
|
|
48
|
+
commits?: boolean | number;
|
|
49
|
+
releases?: boolean | number;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export class Repo {
|
|
53
|
+
/**
|
|
54
|
+
* Resolves repository context either from a local git repo or via public GitHub API.
|
|
55
|
+
*/
|
|
56
|
+
public static async resolveContext(repoNameOrPath: string, options?: RepoOptions): Promise<RepoContext> {
|
|
57
|
+
const isLocalDir =
|
|
58
|
+
fs.existsSync(repoNameOrPath) ||
|
|
59
|
+
repoNameOrPath === "." ||
|
|
60
|
+
repoNameOrPath.startsWith("./") ||
|
|
61
|
+
repoNameOrPath.startsWith("../");
|
|
62
|
+
|
|
63
|
+
if (isLocalDir) {
|
|
64
|
+
return this.getLocalContext(repoNameOrPath, options);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
try {
|
|
68
|
+
const gitRemote = execSync("git remote get-url origin", {
|
|
69
|
+
encoding: "utf-8",
|
|
70
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
71
|
+
}).trim();
|
|
72
|
+
if (gitRemote.includes(repoNameOrPath)) {
|
|
73
|
+
return this.getLocalContext(".", options);
|
|
74
|
+
}
|
|
75
|
+
} catch {
|
|
76
|
+
// Not in a matching local git repo
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return this.getRemoteContext(repoNameOrPath, options);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public static getLocalContext(dir: string, options?: RepoOptions): RepoContext {
|
|
83
|
+
let branch = "main";
|
|
84
|
+
let recentCommits: string[] = [];
|
|
85
|
+
let files: string[] = [];
|
|
86
|
+
let readme = "";
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
branch = execSync("git rev-parse --abbrev-ref HEAD", {
|
|
90
|
+
cwd: dir,
|
|
91
|
+
encoding: "utf-8",
|
|
92
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
93
|
+
}).trim();
|
|
94
|
+
} catch {}
|
|
95
|
+
|
|
96
|
+
try {
|
|
97
|
+
const commitLimit = typeof options?.commits === "number" ? options.commits : 5;
|
|
98
|
+
const commitLog = execSync(`git log -n ${commitLimit} --oneline`, {
|
|
99
|
+
cwd: dir,
|
|
100
|
+
encoding: "utf-8",
|
|
101
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
102
|
+
}).trim();
|
|
103
|
+
recentCommits = commitLog.split("\n").filter(Boolean);
|
|
104
|
+
} catch {}
|
|
105
|
+
|
|
106
|
+
try {
|
|
107
|
+
const gitFiles = execSync("git ls-files", {
|
|
108
|
+
cwd: dir,
|
|
109
|
+
encoding: "utf-8",
|
|
110
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
111
|
+
}).trim();
|
|
112
|
+
files = gitFiles.split("\n").filter(Boolean).slice(0, 100);
|
|
113
|
+
} catch {}
|
|
114
|
+
|
|
115
|
+
if (files.length === 0 && fs.existsSync(dir)) {
|
|
116
|
+
try {
|
|
117
|
+
files = fs.readdirSync(dir).filter((f) => !f.startsWith(".")).slice(0, 100);
|
|
118
|
+
} catch {}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
for (const rName of ["README.md", "readme.md", "README", "readme.txt"]) {
|
|
122
|
+
const readmePath = path.join(dir, rName);
|
|
123
|
+
if (fs.existsSync(readmePath)) {
|
|
124
|
+
try {
|
|
125
|
+
readme = fs.readFileSync(readmePath, "utf-8").slice(0, 2000);
|
|
126
|
+
break;
|
|
127
|
+
} catch {}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return { repo: dir, branch, files, readme, recentCommits };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
public static async getRemoteContext(repoSlug: string, options?: RepoOptions): Promise<RepoContext> {
|
|
135
|
+
const cleanRepo = repoSlug
|
|
136
|
+
.replace(/^https?:\/\/github\.com\//, "")
|
|
137
|
+
.replace(/^github\.com\//, "")
|
|
138
|
+
.replace(/\.git$/, "");
|
|
139
|
+
let branch = "main";
|
|
140
|
+
let files: string[] = [];
|
|
141
|
+
let readme = "";
|
|
142
|
+
let recentCommits: string[] = [];
|
|
143
|
+
let issues: RepoIssue[] = [];
|
|
144
|
+
let pullRequests: RepoPullRequest[] = [];
|
|
145
|
+
let releases: RepoRelease[] = [];
|
|
146
|
+
|
|
147
|
+
const headers: Record<string, string> = {
|
|
148
|
+
"User-Agent": "Liate-Agent-Runtime",
|
|
149
|
+
Accept: "application/vnd.github+json",
|
|
150
|
+
};
|
|
151
|
+
if (process.env.GITHUB_TOKEN) {
|
|
152
|
+
headers.Authorization = `Bearer ${process.env.GITHUB_TOKEN}`;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
try {
|
|
156
|
+
const repoRes = await fetch(`https://api.github.com/repos/${cleanRepo}`, { headers });
|
|
157
|
+
if (repoRes.ok) {
|
|
158
|
+
const repoData: any = await repoRes.json();
|
|
159
|
+
if (repoData.default_branch) branch = repoData.default_branch;
|
|
160
|
+
}
|
|
161
|
+
} catch {}
|
|
162
|
+
|
|
163
|
+
try {
|
|
164
|
+
const treeRes = await fetch(
|
|
165
|
+
`https://api.github.com/repos/${cleanRepo}/git/trees/${branch}?recursive=1`,
|
|
166
|
+
{ headers }
|
|
167
|
+
);
|
|
168
|
+
if (treeRes.ok) {
|
|
169
|
+
const treeData: any = await treeRes.json();
|
|
170
|
+
if (Array.isArray(treeData.tree)) {
|
|
171
|
+
files = treeData.tree.map((f: any) => f.path).slice(0, 100);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
} catch {}
|
|
175
|
+
|
|
176
|
+
try {
|
|
177
|
+
const commitLimit = typeof options?.commits === "number" ? options.commits : 5;
|
|
178
|
+
const commitsRes = await fetch(
|
|
179
|
+
`https://api.github.com/repos/${cleanRepo}/commits?per_page=${commitLimit}`,
|
|
180
|
+
{ headers }
|
|
181
|
+
);
|
|
182
|
+
if (commitsRes.ok) {
|
|
183
|
+
const commitsData: any = await commitsRes.json();
|
|
184
|
+
if (Array.isArray(commitsData)) {
|
|
185
|
+
recentCommits = commitsData.map(
|
|
186
|
+
(c: any) => `${String(c.sha || "").slice(0, 7)} ${String(c.commit?.message || "").split("\n")[0]}`
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
} catch {}
|
|
191
|
+
|
|
192
|
+
try {
|
|
193
|
+
const readmeRes = await fetch(`https://raw.githubusercontent.com/${cleanRepo}/${branch}/README.md`);
|
|
194
|
+
if (readmeRes.ok) readme = (await readmeRes.text()).slice(0, 2000);
|
|
195
|
+
} catch {}
|
|
196
|
+
|
|
197
|
+
if (options?.issues) {
|
|
198
|
+
const limit = typeof options.issues === "number" ? options.issues : 5;
|
|
199
|
+
try {
|
|
200
|
+
const res = await fetch(
|
|
201
|
+
`https://api.github.com/repos/${cleanRepo}/issues?state=open&per_page=${limit}`,
|
|
202
|
+
{ headers }
|
|
203
|
+
);
|
|
204
|
+
if (res.ok) {
|
|
205
|
+
const data: any[] = await res.json();
|
|
206
|
+
issues = data
|
|
207
|
+
.filter((i) => !i.pull_request)
|
|
208
|
+
.map((i) => ({
|
|
209
|
+
number: i.number,
|
|
210
|
+
title: i.title,
|
|
211
|
+
state: i.state,
|
|
212
|
+
author: i.user?.login,
|
|
213
|
+
labels: (i.labels || []).map((l: any) => l.name),
|
|
214
|
+
createdAt: i.created_at,
|
|
215
|
+
url: i.html_url,
|
|
216
|
+
}));
|
|
217
|
+
}
|
|
218
|
+
} catch {}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (options?.pulls) {
|
|
222
|
+
const limit = typeof options.pulls === "number" ? options.pulls : 5;
|
|
223
|
+
try {
|
|
224
|
+
const res = await fetch(
|
|
225
|
+
`https://api.github.com/repos/${cleanRepo}/pulls?state=open&per_page=${limit}`,
|
|
226
|
+
{ headers }
|
|
227
|
+
);
|
|
228
|
+
if (res.ok) {
|
|
229
|
+
const data: any[] = await res.json();
|
|
230
|
+
pullRequests = data.map((p) => ({
|
|
231
|
+
number: p.number,
|
|
232
|
+
title: p.title,
|
|
233
|
+
state: p.state,
|
|
234
|
+
author: p.user?.login,
|
|
235
|
+
draft: p.draft,
|
|
236
|
+
createdAt: p.created_at,
|
|
237
|
+
url: p.html_url,
|
|
238
|
+
}));
|
|
239
|
+
}
|
|
240
|
+
} catch {}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (options?.releases) {
|
|
244
|
+
const limit = typeof options.releases === "number" ? options.releases : 3;
|
|
245
|
+
try {
|
|
246
|
+
const res = await fetch(
|
|
247
|
+
`https://api.github.com/repos/${cleanRepo}/releases?per_page=${limit}`,
|
|
248
|
+
{ headers }
|
|
249
|
+
);
|
|
250
|
+
if (res.ok) {
|
|
251
|
+
const data: any[] = await res.json();
|
|
252
|
+
releases = data.map((r) => ({
|
|
253
|
+
tag: r.tag_name,
|
|
254
|
+
name: r.name || r.tag_name,
|
|
255
|
+
publishedAt: r.published_at,
|
|
256
|
+
}));
|
|
257
|
+
}
|
|
258
|
+
} catch {}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return {
|
|
262
|
+
repo: cleanRepo,
|
|
263
|
+
branch,
|
|
264
|
+
files,
|
|
265
|
+
readme,
|
|
266
|
+
recentCommits,
|
|
267
|
+
issues: issues.length ? issues : undefined,
|
|
268
|
+
pullRequests: pullRequests.length ? pullRequests : undefined,
|
|
269
|
+
releases: releases.length ? releases : undefined,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export type MessageRole = "system" | "user" | "assistant" | "tool";
|
|
2
|
+
|
|
3
|
+
export interface AgentMessage {
|
|
4
|
+
role: MessageRole;
|
|
5
|
+
content: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
toolCallId?: string;
|
|
8
|
+
toolCalls?: Array<{ id: string; name: string; arguments: Record<string, any> }>;
|
|
9
|
+
reasoningContent?: string;
|
|
10
|
+
timestamp?: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface SessionData {
|
|
14
|
+
sessionId: string;
|
|
15
|
+
createdAt: string;
|
|
16
|
+
updatedAt: string;
|
|
17
|
+
metadata?: Record<string, any>;
|
|
18
|
+
messages: AgentMessage[];
|
|
19
|
+
state: Record<string, any>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface MemoryProvider {
|
|
23
|
+
readonly sessionId: string;
|
|
24
|
+
load(): Promise<SessionData>;
|
|
25
|
+
save(): Promise<void>;
|
|
26
|
+
getMessages(): AgentMessage[];
|
|
27
|
+
append(message: AgentMessage | AgentMessage[]): Promise<void>;
|
|
28
|
+
getState(key: string): any;
|
|
29
|
+
setState(key: string, value: any): Promise<void>;
|
|
30
|
+
clear(): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface KnowledgeDoc {
|
|
34
|
+
id: string;
|
|
35
|
+
source: string;
|
|
36
|
+
title?: string;
|
|
37
|
+
content: string;
|
|
38
|
+
metadata?: Record<string, any>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface KnowledgeContext {
|
|
42
|
+
sources: string[];
|
|
43
|
+
documents: KnowledgeDoc[];
|
|
44
|
+
totalChars: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface AgentTool {
|
|
48
|
+
name: string;
|
|
49
|
+
description: string;
|
|
50
|
+
parameters?: Record<string, any>;
|
|
51
|
+
execute: (args: Record<string, any>, context?: any) => Promise<string | Record<string, any>>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface IntegrationConfig {
|
|
55
|
+
memory?: string;
|
|
56
|
+
knowledge?: string | string[] | Record<string, any>;
|
|
57
|
+
state?: Record<string, any>;
|
|
58
|
+
[key: string]: any;
|
|
59
|
+
}
|
|
60
|
+
|