@gugacoder/agentic-sdk 0.2.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 (129) hide show
  1. package/dist/agent.d.ts +2 -0
  2. package/dist/agent.js +463 -0
  3. package/dist/context/compaction.d.ts +27 -0
  4. package/dist/context/compaction.js +219 -0
  5. package/dist/context/models.d.ts +6 -0
  6. package/dist/context/models.js +41 -0
  7. package/dist/context/tokenizer.d.ts +5 -0
  8. package/dist/context/tokenizer.js +11 -0
  9. package/dist/context/usage.d.ts +11 -0
  10. package/dist/context/usage.js +49 -0
  11. package/dist/display-schemas.d.ts +1865 -0
  12. package/dist/display-schemas.js +219 -0
  13. package/dist/index.d.ts +38 -0
  14. package/dist/index.js +28 -0
  15. package/dist/middleware/logging.d.ts +2 -0
  16. package/dist/middleware/logging.js +32 -0
  17. package/dist/prompts/assembly.d.ts +13 -0
  18. package/dist/prompts/assembly.js +229 -0
  19. package/dist/providers.d.ts +19 -0
  20. package/dist/providers.js +44 -0
  21. package/dist/proxy.d.ts +2 -0
  22. package/dist/proxy.js +103 -0
  23. package/dist/schemas.d.ts +228 -0
  24. package/dist/schemas.js +51 -0
  25. package/dist/session.d.ts +7 -0
  26. package/dist/session.js +102 -0
  27. package/dist/structured.d.ts +18 -0
  28. package/dist/structured.js +38 -0
  29. package/dist/tool-repair.d.ts +21 -0
  30. package/dist/tool-repair.js +72 -0
  31. package/dist/tools/api-spec.d.ts +4 -0
  32. package/dist/tools/api-spec.js +123 -0
  33. package/dist/tools/apply-patch.d.ts +484 -0
  34. package/dist/tools/apply-patch.js +157 -0
  35. package/dist/tools/ask-user.d.ts +14 -0
  36. package/dist/tools/ask-user.js +27 -0
  37. package/dist/tools/bash.d.ts +550 -0
  38. package/dist/tools/bash.js +43 -0
  39. package/dist/tools/batch.d.ts +13 -0
  40. package/dist/tools/batch.js +84 -0
  41. package/dist/tools/brave-search.d.ts +6 -0
  42. package/dist/tools/brave-search.js +19 -0
  43. package/dist/tools/code-search.d.ts +20 -0
  44. package/dist/tools/code-search.js +42 -0
  45. package/dist/tools/diagnostics.d.ts +4 -0
  46. package/dist/tools/diagnostics.js +69 -0
  47. package/dist/tools/display.d.ts +483 -0
  48. package/dist/tools/display.js +77 -0
  49. package/dist/tools/edit.d.ts +682 -0
  50. package/dist/tools/edit.js +47 -0
  51. package/dist/tools/glob.d.ts +4 -0
  52. package/dist/tools/glob.js +42 -0
  53. package/dist/tools/grep.d.ts +6 -0
  54. package/dist/tools/grep.js +69 -0
  55. package/dist/tools/http-request.d.ts +7 -0
  56. package/dist/tools/http-request.js +98 -0
  57. package/dist/tools/index.d.ts +1611 -0
  58. package/dist/tools/index.js +46 -0
  59. package/dist/tools/job-tools.d.ts +24 -0
  60. package/dist/tools/job-tools.js +67 -0
  61. package/dist/tools/list-dir.d.ts +5 -0
  62. package/dist/tools/list-dir.js +79 -0
  63. package/dist/tools/multi-edit.d.ts +814 -0
  64. package/dist/tools/multi-edit.js +57 -0
  65. package/dist/tools/read.d.ts +5 -0
  66. package/dist/tools/read.js +33 -0
  67. package/dist/tools/task.d.ts +21 -0
  68. package/dist/tools/task.js +51 -0
  69. package/dist/tools/todo.d.ts +14 -0
  70. package/dist/tools/todo.js +60 -0
  71. package/dist/tools/web-fetch.d.ts +4 -0
  72. package/dist/tools/web-fetch.js +126 -0
  73. package/dist/tools/web-search.d.ts +22 -0
  74. package/dist/tools/web-search.js +48 -0
  75. package/dist/tools/write.d.ts +550 -0
  76. package/dist/tools/write.js +30 -0
  77. package/dist/types.d.ts +201 -0
  78. package/dist/types.js +1 -0
  79. package/package.json +43 -0
  80. package/src/agent.ts +520 -0
  81. package/src/context/compaction.ts +265 -0
  82. package/src/context/models.ts +42 -0
  83. package/src/context/tokenizer.ts +12 -0
  84. package/src/context/usage.ts +65 -0
  85. package/src/display-schemas.ts +276 -0
  86. package/src/index.ts +43 -0
  87. package/src/middleware/logging.ts +37 -0
  88. package/src/prompts/assembly.ts +263 -0
  89. package/src/prompts/identity.md +10 -0
  90. package/src/prompts/patterns.md +7 -0
  91. package/src/prompts/safety.md +7 -0
  92. package/src/prompts/tool-guide.md +9 -0
  93. package/src/prompts/tools/bash.md +7 -0
  94. package/src/prompts/tools/edit.md +7 -0
  95. package/src/prompts/tools/glob.md +7 -0
  96. package/src/prompts/tools/grep.md +7 -0
  97. package/src/prompts/tools/read.md +7 -0
  98. package/src/prompts/tools/write.md +7 -0
  99. package/src/providers.ts +58 -0
  100. package/src/proxy.ts +101 -0
  101. package/src/schemas.ts +58 -0
  102. package/src/session.ts +110 -0
  103. package/src/structured.ts +65 -0
  104. package/src/tool-repair.ts +92 -0
  105. package/src/tools/api-spec.ts +158 -0
  106. package/src/tools/apply-patch.ts +188 -0
  107. package/src/tools/ask-user.ts +40 -0
  108. package/src/tools/bash.ts +51 -0
  109. package/src/tools/batch.ts +103 -0
  110. package/src/tools/brave-search.ts +24 -0
  111. package/src/tools/code-search.ts +69 -0
  112. package/src/tools/diagnostics.ts +93 -0
  113. package/src/tools/display.ts +105 -0
  114. package/src/tools/edit.ts +55 -0
  115. package/src/tools/glob.ts +46 -0
  116. package/src/tools/grep.ts +68 -0
  117. package/src/tools/http-request.ts +103 -0
  118. package/src/tools/index.ts +48 -0
  119. package/src/tools/job-tools.ts +84 -0
  120. package/src/tools/list-dir.ts +102 -0
  121. package/src/tools/multi-edit.ts +65 -0
  122. package/src/tools/read.ts +40 -0
  123. package/src/tools/task.ts +71 -0
  124. package/src/tools/todo.ts +82 -0
  125. package/src/tools/web-fetch.ts +155 -0
  126. package/src/tools/web-search.ts +75 -0
  127. package/src/tools/write.ts +34 -0
  128. package/src/types.ts +145 -0
  129. package/tsconfig.json +17 -0
@@ -0,0 +1,46 @@
1
+ import { readTool } from "./read.js";
2
+ import { writeTool } from "./write.js";
3
+ import { editTool } from "./edit.js";
4
+ import { bashTool } from "./bash.js";
5
+ import { globTool } from "./glob.js";
6
+ import { grepTool } from "./grep.js";
7
+ import { listDirTool } from "./list-dir.js";
8
+ import { multiEditTool } from "./multi-edit.js";
9
+ import { todoWriteTool, todoReadTool } from "./todo.js";
10
+ import { diagnosticsTool } from "./diagnostics.js";
11
+ import { createAskUserTool } from "./ask-user.js";
12
+ import { webFetchTool } from "./web-fetch.js";
13
+ import { createWebSearchTool } from "./web-search.js";
14
+ import { createTaskTool } from "./task.js";
15
+ import { createBatchTool } from "./batch.js";
16
+ import { applyPatchTool } from "./apply-patch.js";
17
+ import { createCodeSearchTool } from "./code-search.js";
18
+ import { httpRequestTool } from "./http-request.js";
19
+ import { apiSpecTool } from "./api-spec.js";
20
+ export { createBashTool } from "./bash.js";
21
+ export { createWriteTool } from "./write.js";
22
+ export { createEditTool } from "./edit.js";
23
+ export { createMultiEditTool } from "./multi-edit.js";
24
+ export { createApplyPatchTool } from "./apply-patch.js";
25
+ export const codingTools = {
26
+ Read: readTool,
27
+ Write: writeTool,
28
+ Edit: editTool,
29
+ Bash: bashTool,
30
+ Glob: globTool,
31
+ Grep: grepTool,
32
+ ListDir: listDirTool,
33
+ MultiEdit: multiEditTool,
34
+ TodoWrite: todoWriteTool,
35
+ TodoRead: todoReadTool,
36
+ Diagnostics: diagnosticsTool,
37
+ AskUser: createAskUserTool(),
38
+ WebFetch: webFetchTool,
39
+ WebSearch: createWebSearchTool(),
40
+ Task: createTaskTool(),
41
+ Batch: createBatchTool({}),
42
+ ApplyPatch: applyPatchTool,
43
+ CodeSearch: createCodeSearchTool(),
44
+ HttpRequest: httpRequestTool,
45
+ ApiSpec: apiSpecTool,
46
+ };
@@ -0,0 +1,24 @@
1
+ export interface JobToolCallbacks {
2
+ submitJob: (opts: {
3
+ agentId: string;
4
+ command: string;
5
+ timeout?: number;
6
+ }) => unknown;
7
+ listJobs: (agentId?: string) => unknown[];
8
+ getJob: (jobId: string) => unknown | undefined;
9
+ killJob: (jobId: string) => boolean;
10
+ getAgentId: () => string | undefined;
11
+ }
12
+ export declare function createJobTools(callbacks: JobToolCallbacks): {
13
+ submit_job: import("ai").Tool<{
14
+ command: string;
15
+ timeout?: number | undefined;
16
+ }, string>;
17
+ list_jobs: import("ai").Tool<{}, string>;
18
+ get_job: import("ai").Tool<{
19
+ jobId: string;
20
+ }, string>;
21
+ kill_job: import("ai").Tool<{
22
+ jobId: string;
23
+ }, "Job killed successfully" | "Job not found or already finished">;
24
+ };
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Vercel AI SDK tool wrappers for job management.
3
+ * Uses callbacks to avoid coupling to a specific job engine implementation.
4
+ */
5
+ import { tool } from "ai";
6
+ import { z } from "zod";
7
+ export function createJobTools(callbacks) {
8
+ return {
9
+ submit_job: tool({
10
+ description: "Submit a long-running process for backbone supervision. The backbone captures output, applies timeout, and wakes you up when the job finishes.",
11
+ inputSchema: z.object({
12
+ command: z
13
+ .string()
14
+ .describe("Shell command to execute (e.g. 'sleep 30')"),
15
+ timeout: z
16
+ .number()
17
+ .optional()
18
+ .describe("Timeout in seconds. Default: 1800 (30min)"),
19
+ }),
20
+ execute: async ({ command, timeout }) => {
21
+ const agentId = callbacks.getAgentId();
22
+ if (!agentId)
23
+ return "Error: AGENT_ID not available";
24
+ try {
25
+ const summary = callbacks.submitJob({
26
+ agentId,
27
+ command,
28
+ timeout,
29
+ });
30
+ return JSON.stringify(summary);
31
+ }
32
+ catch (err) {
33
+ return `Error: ${err instanceof Error ? err.message : String(err)}`;
34
+ }
35
+ },
36
+ }),
37
+ list_jobs: tool({
38
+ description: "List all jobs for this agent. Returns an array of job summaries.",
39
+ inputSchema: z.object({}),
40
+ execute: async () => {
41
+ const agentId = callbacks.getAgentId();
42
+ return JSON.stringify(callbacks.listJobs(agentId ?? undefined));
43
+ },
44
+ }),
45
+ get_job: tool({
46
+ description: "Get full details of a specific job including output tail, status, exit code, and duration.",
47
+ inputSchema: z.object({
48
+ jobId: z.string().describe("Job ID to query"),
49
+ }),
50
+ execute: async ({ jobId }) => {
51
+ const job = callbacks.getJob(jobId);
52
+ return job ? JSON.stringify(job) : "Job not found";
53
+ },
54
+ }),
55
+ kill_job: tool({
56
+ description: "Kill a running job with SIGKILL.",
57
+ inputSchema: z.object({
58
+ jobId: z.string().describe("Job ID to kill"),
59
+ }),
60
+ execute: async ({ jobId }) => {
61
+ return callbacks.killJob(jobId)
62
+ ? "Job killed successfully"
63
+ : "Job not found or already finished";
64
+ },
65
+ }),
66
+ };
67
+ }
@@ -0,0 +1,5 @@
1
+ export declare const listDirTool: import("ai").Tool<{
2
+ path: string;
3
+ depth: number;
4
+ ignore: string[];
5
+ }, string>;
@@ -0,0 +1,79 @@
1
+ import { tool } from "ai";
2
+ import { z } from "zod";
3
+ import { readdir, stat } from "node:fs/promises";
4
+ import { join, basename } from "node:path";
5
+ const DEFAULT_IGNORE = ["node_modules", ".git", "dist", "build"];
6
+ async function buildTree(dirPath, depth, maxDepth, ignore, prefix) {
7
+ if (depth >= maxDepth)
8
+ return [];
9
+ let entries;
10
+ try {
11
+ entries = await readdir(dirPath, { withFileTypes: true });
12
+ }
13
+ catch {
14
+ return [];
15
+ }
16
+ // Filter ignored entries
17
+ entries = entries.filter((e) => !ignore.includes(e.name));
18
+ // Sort: directories first, then files, alphabetically within each group
19
+ entries.sort((a, b) => {
20
+ if (a.isDirectory() && !b.isDirectory())
21
+ return -1;
22
+ if (!a.isDirectory() && b.isDirectory())
23
+ return 1;
24
+ return a.name.localeCompare(b.name);
25
+ });
26
+ const lines = [];
27
+ for (let i = 0; i < entries.length; i++) {
28
+ const entry = entries[i];
29
+ const isLast = i === entries.length - 1;
30
+ const connector = isLast ? "└── " : "├── ";
31
+ const childPrefix = isLast ? " " : "│ ";
32
+ if (entry.isDirectory()) {
33
+ lines.push(`${prefix}${connector}${entry.name}/`);
34
+ const children = await buildTree(join(dirPath, entry.name), depth + 1, maxDepth, ignore, prefix + childPrefix);
35
+ lines.push(...children);
36
+ }
37
+ else {
38
+ lines.push(`${prefix}${connector}${entry.name}`);
39
+ }
40
+ }
41
+ return lines;
42
+ }
43
+ export const listDirTool = tool({
44
+ description: "Lists files and directories as an indented tree. Use this to understand project structure.",
45
+ inputSchema: z.object({
46
+ path: z.string().describe("Absolute path of the directory to list"),
47
+ depth: z
48
+ .number()
49
+ .optional()
50
+ .default(3)
51
+ .describe("Maximum depth to traverse (default: 3)"),
52
+ ignore: z
53
+ .array(z.string())
54
+ .optional()
55
+ .default(DEFAULT_IGNORE)
56
+ .describe("Directory/file names to ignore (default: node_modules, .git, dist, build)"),
57
+ }),
58
+ execute: async ({ path, depth, ignore }) => {
59
+ try {
60
+ const s = await stat(path);
61
+ if (!s.isDirectory()) {
62
+ return `Error: ${path} is not a directory`;
63
+ }
64
+ const rootName = basename(path) || path;
65
+ const lines = [`${rootName}/`];
66
+ const children = await buildTree(path, 0, depth, ignore, "");
67
+ lines.push(...children);
68
+ const result = lines.join("\n");
69
+ // Respect 50KB output limit
70
+ if (result.length > 50_000) {
71
+ return result.slice(0, 50_000) + "\n... (truncated at 50KB)";
72
+ }
73
+ return result;
74
+ }
75
+ catch (err) {
76
+ return `Error: ${err.message}`;
77
+ }
78
+ },
79
+ });