kern-ai 0.1.0

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 (66) hide show
  1. package/README.md +111 -0
  2. package/dist/app.d.ts +2 -0
  3. package/dist/app.d.ts.map +1 -0
  4. package/dist/app.js +34 -0
  5. package/dist/app.js.map +1 -0
  6. package/dist/config.d.ts +12 -0
  7. package/dist/config.d.ts.map +1 -0
  8. package/dist/config.js +48 -0
  9. package/dist/config.js.map +1 -0
  10. package/dist/index.d.ts +3 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +33 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/init.d.ts +2 -0
  15. package/dist/init.d.ts.map +1 -0
  16. package/dist/init.js +187 -0
  17. package/dist/init.js.map +1 -0
  18. package/dist/interfaces/cli.d.ts +14 -0
  19. package/dist/interfaces/cli.d.ts.map +1 -0
  20. package/dist/interfaces/cli.js +142 -0
  21. package/dist/interfaces/cli.js.map +1 -0
  22. package/dist/interfaces/telegram.d.ts +10 -0
  23. package/dist/interfaces/telegram.d.ts.map +1 -0
  24. package/dist/interfaces/telegram.js +55 -0
  25. package/dist/interfaces/telegram.js.map +1 -0
  26. package/dist/interfaces/types.d.ts +17 -0
  27. package/dist/interfaces/types.d.ts.map +1 -0
  28. package/dist/interfaces/types.js +2 -0
  29. package/dist/interfaces/types.js.map +1 -0
  30. package/dist/runtime.d.ts +22 -0
  31. package/dist/runtime.d.ts.map +1 -0
  32. package/dist/runtime.js +99 -0
  33. package/dist/runtime.js.map +1 -0
  34. package/dist/session.d.ts +21 -0
  35. package/dist/session.d.ts.map +1 -0
  36. package/dist/session.js +102 -0
  37. package/dist/session.js.map +1 -0
  38. package/dist/tools/bash.d.ts +5 -0
  39. package/dist/tools/bash.d.ts.map +1 -0
  40. package/dist/tools/bash.js +30 -0
  41. package/dist/tools/bash.js.map +1 -0
  42. package/dist/tools/edit.d.ts +7 -0
  43. package/dist/tools/edit.d.ts.map +1 -0
  44. package/dist/tools/edit.js +37 -0
  45. package/dist/tools/edit.js.map +1 -0
  46. package/dist/tools/glob.d.ts +5 -0
  47. package/dist/tools/glob.d.ts.map +1 -0
  48. package/dist/tools/glob.js +29 -0
  49. package/dist/tools/glob.js.map +1 -0
  50. package/dist/tools/grep.d.ts +6 -0
  51. package/dist/tools/grep.d.ts.map +1 -0
  52. package/dist/tools/grep.js +38 -0
  53. package/dist/tools/grep.js.map +1 -0
  54. package/dist/tools/index.d.ts +32 -0
  55. package/dist/tools/index.d.ts.map +1 -0
  56. package/dist/tools/index.js +15 -0
  57. package/dist/tools/index.js.map +1 -0
  58. package/dist/tools/read.d.ts +6 -0
  59. package/dist/tools/read.d.ts.map +1 -0
  60. package/dist/tools/read.js +36 -0
  61. package/dist/tools/read.js.map +1 -0
  62. package/dist/tools/write.d.ts +5 -0
  63. package/dist/tools/write.d.ts.map +1 -0
  64. package/dist/tools/write.js +22 -0
  65. package/dist/tools/write.js.map +1 -0
  66. package/package.json +51 -0
@@ -0,0 +1,6 @@
1
+ export declare const readTool: import("ai").Tool<{
2
+ path: string;
3
+ offset?: number | undefined;
4
+ limit?: number | undefined;
5
+ }, string>;
6
+ //# sourceMappingURL=read.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/tools/read.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,QAAQ;;;;UA+BnB,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { tool } from "ai";
2
+ import { z } from "zod";
3
+ import { readFile, readdir, stat } from "fs/promises";
4
+ export const readTool = tool({
5
+ description: "Read a file or list a directory. Returns file contents with line numbers, or directory entries with trailing / for subdirectories.",
6
+ inputSchema: z.object({
7
+ path: z.string().describe("Absolute or relative path to read"),
8
+ offset: z
9
+ .number()
10
+ .optional()
11
+ .describe("Line number to start from (1-indexed, default: 1)"),
12
+ limit: z
13
+ .number()
14
+ .optional()
15
+ .describe("Maximum number of lines to read (default: 2000)"),
16
+ }),
17
+ execute: async ({ path, offset = 1, limit = 2000 }) => {
18
+ try {
19
+ const s = await stat(path);
20
+ if (s.isDirectory()) {
21
+ const entries = await readdir(path, { withFileTypes: true });
22
+ return entries
23
+ .map((e) => (e.isDirectory() ? `${e.name}/` : e.name))
24
+ .join("\n");
25
+ }
26
+ const content = await readFile(path, "utf-8");
27
+ const lines = content.split("\n");
28
+ const slice = lines.slice(offset - 1, offset - 1 + limit);
29
+ return slice.map((line, i) => `${offset + i}: ${line}`).join("\n");
30
+ }
31
+ catch (e) {
32
+ return `Error: ${e.message}`;
33
+ }
34
+ },
35
+ });
36
+ //# sourceMappingURL=read.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.js","sourceRoot":"","sources":["../../src/tools/read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC;IAC3B,WAAW,EACT,oIAAoI;IACtI,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;QAC9D,MAAM,EAAE,CAAC;aACN,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CAAC,mDAAmD,CAAC;QAChE,KAAK,EAAE,CAAC;aACL,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CAAC,iDAAiD,CAAC;KAC/D,CAAC;IACF,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,EAAE,EAAE,EAAE;QACpD,IAAI,CAAC;YACH,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;YAC3B,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;gBACpB,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC7D,OAAO,OAAO;qBACX,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;qBACrD,IAAI,CAAC,IAAI,CAAC,CAAC;YAChB,CAAC;YACD,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAC9C,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAClC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC;YAC1D,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,MAAM,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrE,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,OAAO,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC;QAC/B,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const writeTool: import("ai").Tool<{
2
+ path: string;
3
+ content: string;
4
+ }, string>;
5
+ //# sourceMappingURL=write.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../src/tools/write.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,SAAS;;;UAgBpB,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { tool } from "ai";
2
+ import { z } from "zod";
3
+ import { writeFile, mkdir } from "fs/promises";
4
+ import { dirname } from "path";
5
+ export const writeTool = tool({
6
+ description: "Write content to a file. Creates the file if it doesn't exist. Creates parent directories as needed. Overwrites existing content.",
7
+ inputSchema: z.object({
8
+ path: z.string().describe("Absolute or relative path to write"),
9
+ content: z.string().describe("The content to write to the file"),
10
+ }),
11
+ execute: async ({ path, content }) => {
12
+ try {
13
+ await mkdir(dirname(path), { recursive: true });
14
+ await writeFile(path, content, "utf-8");
15
+ return `Wrote ${content.split("\n").length} lines to ${path}`;
16
+ }
17
+ catch (e) {
18
+ return `Error: ${e.message}`;
19
+ }
20
+ },
21
+ });
22
+ //# sourceMappingURL=write.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write.js","sourceRoot":"","sources":["../../src/tools/write.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC;IAC5B,WAAW,EACT,mIAAmI;IACrI,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;QAC/D,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC;KACjE,CAAC;IACF,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;QACnC,IAAI,CAAC;YACH,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAChD,MAAM,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YACxC,OAAO,SAAS,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,aAAa,IAAI,EAAE,CAAC;QAChE,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,OAAO,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC;QAC/B,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "kern-ai",
3
+ "version": "0.1.0",
4
+ "description": "Simple agent runtime. Persistent memory, tools, Telegram.",
5
+ "type": "module",
6
+ "bin": {
7
+ "kern": "./dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "build": "tsc",
14
+ "prepublishOnly": "npm run build",
15
+ "dev": "tsx src/index.ts",
16
+ "start": "node dist/index.js"
17
+ },
18
+ "keywords": [
19
+ "ai",
20
+ "agent",
21
+ "llm",
22
+ "telegram",
23
+ "cli",
24
+ "runtime",
25
+ "memory",
26
+ "stateful"
27
+ ],
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "https://github.com/oguzbilgic/kern"
31
+ },
32
+ "author": "Oguz Bilgic",
33
+ "dependencies": {
34
+ "@ai-sdk/anthropic": "^2.0.0",
35
+ "@ai-sdk/openai": "^3.0.48",
36
+ "ai": "^6.0.0",
37
+ "dotenv": "^16.4.0",
38
+ "glob": "^11.0.0",
39
+ "grammy": "^1.35.0",
40
+ "zod": "^3.24.0"
41
+ },
42
+ "devDependencies": {
43
+ "@types/node": "^22.0.0",
44
+ "tsx": "^4.19.0",
45
+ "typescript": "^5.7.0"
46
+ },
47
+ "engines": {
48
+ "node": ">=18"
49
+ },
50
+ "license": "MIT"
51
+ }