fourmis-agents-sdk 0.3.0 → 0.4.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 (102) hide show
  1. package/dist/agent-loop.d.ts +21 -3
  2. package/dist/agent-loop.d.ts.map +1 -1
  3. package/dist/agent-loop.js +294 -90
  4. package/dist/agents/index.js +2798 -1857
  5. package/dist/agents/task-manager.js +15 -0
  6. package/dist/agents/tools.d.ts.map +1 -1
  7. package/dist/agents/tools.js +2798 -1857
  8. package/dist/agents/types.d.ts +4 -0
  9. package/dist/agents/types.d.ts.map +1 -1
  10. package/dist/api.d.ts +8 -5
  11. package/dist/api.d.ts.map +1 -1
  12. package/dist/api.js +2394 -886
  13. package/dist/auth/gemini-oauth.js +15 -0
  14. package/dist/auth/login-openai.js +15 -0
  15. package/dist/auth/openai-oauth.js +15 -0
  16. package/dist/hooks.d.ts +19 -1
  17. package/dist/hooks.d.ts.map +1 -1
  18. package/dist/hooks.js +42 -2
  19. package/dist/index.d.ts +10 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +2407 -887
  22. package/dist/mcp/client.d.ts +7 -0
  23. package/dist/mcp/client.d.ts.map +1 -1
  24. package/dist/mcp/client.js +146 -12
  25. package/dist/mcp/index.js +146 -12
  26. package/dist/mcp/server.js +15 -0
  27. package/dist/mcp/types.d.ts +19 -1
  28. package/dist/mcp/types.d.ts.map +1 -1
  29. package/dist/memory/index.js +15 -0
  30. package/dist/memory/memory-handler.js +15 -0
  31. package/dist/permissions.d.ts.map +1 -1
  32. package/dist/permissions.js +22 -3
  33. package/dist/providers/anthropic.d.ts.map +1 -1
  34. package/dist/providers/anthropic.js +56 -2
  35. package/dist/providers/gemini.js +15 -0
  36. package/dist/providers/openai.js +15 -0
  37. package/dist/providers/registry.js +56 -2
  38. package/dist/providers/types.d.ts +4 -1
  39. package/dist/providers/types.d.ts.map +1 -1
  40. package/dist/query.d.ts +21 -2
  41. package/dist/query.d.ts.map +1 -1
  42. package/dist/query.js +84 -1
  43. package/dist/settings.js +15 -0
  44. package/dist/skills/frontmatter.d.ts +15 -0
  45. package/dist/skills/frontmatter.d.ts.map +1 -0
  46. package/dist/skills/frontmatter.js +66 -0
  47. package/dist/skills/index.d.ts +8 -0
  48. package/dist/skills/index.d.ts.map +1 -0
  49. package/dist/skills/index.js +326 -0
  50. package/dist/skills/skills.d.ts +94 -0
  51. package/dist/skills/skills.d.ts.map +1 -0
  52. package/dist/skills/skills.js +324 -0
  53. package/dist/tools/ask-user-question.d.ts +7 -0
  54. package/dist/tools/ask-user-question.d.ts.map +1 -0
  55. package/dist/tools/ask-user-question.js +63 -0
  56. package/dist/tools/bash.d.ts.map +1 -1
  57. package/dist/tools/bash.js +62 -2
  58. package/dist/tools/config.d.ts +7 -0
  59. package/dist/tools/config.d.ts.map +1 -0
  60. package/dist/tools/config.js +129 -0
  61. package/dist/tools/edit.js +15 -0
  62. package/dist/tools/exit-plan-mode.d.ts +7 -0
  63. package/dist/tools/exit-plan-mode.d.ts.map +1 -0
  64. package/dist/tools/exit-plan-mode.js +49 -0
  65. package/dist/tools/glob.js +15 -0
  66. package/dist/tools/grep.js +15 -0
  67. package/dist/tools/index.d.ts +7 -0
  68. package/dist/tools/index.d.ts.map +1 -1
  69. package/dist/tools/index.js +521 -9
  70. package/dist/tools/mcp-resources.js +15 -0
  71. package/dist/tools/notebook-edit.d.ts +7 -0
  72. package/dist/tools/notebook-edit.d.ts.map +1 -0
  73. package/dist/tools/notebook-edit.js +98 -0
  74. package/dist/tools/presets.d.ts +2 -1
  75. package/dist/tools/presets.d.ts.map +1 -1
  76. package/dist/tools/presets.js +37 -4
  77. package/dist/tools/read.d.ts.map +1 -1
  78. package/dist/tools/read.js +27 -1
  79. package/dist/tools/registry.d.ts +2 -0
  80. package/dist/tools/registry.d.ts.map +1 -1
  81. package/dist/tools/registry.js +25 -0
  82. package/dist/tools/todo-write.d.ts +7 -0
  83. package/dist/tools/todo-write.d.ts.map +1 -0
  84. package/dist/tools/todo-write.js +84 -0
  85. package/dist/tools/web-fetch.d.ts +6 -0
  86. package/dist/tools/web-fetch.d.ts.map +1 -0
  87. package/dist/tools/web-fetch.js +100 -0
  88. package/dist/tools/web-search.d.ts +7 -0
  89. package/dist/tools/web-search.d.ts.map +1 -0
  90. package/dist/tools/web-search.js +93 -0
  91. package/dist/tools/write.js +15 -0
  92. package/dist/types.d.ts +360 -42
  93. package/dist/types.d.ts.map +1 -1
  94. package/dist/types.js +15 -0
  95. package/dist/utils/cost.js +15 -0
  96. package/dist/utils/session-store.d.ts +1 -1
  97. package/dist/utils/session-store.d.ts.map +1 -1
  98. package/dist/utils/session-store.js +64 -2
  99. package/dist/utils/system-prompt.d.ts +4 -0
  100. package/dist/utils/system-prompt.d.ts.map +1 -1
  101. package/dist/utils/system-prompt.js +326 -6
  102. package/package.json +4 -2
@@ -0,0 +1,98 @@
1
+ // @bun
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __toESM = (mod, isNodeMode, target) => {
8
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
9
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
+ for (let key of __getOwnPropNames(mod))
11
+ if (!__hasOwnProp.call(to, key))
12
+ __defProp(to, key, {
13
+ get: () => mod[key],
14
+ enumerable: true
15
+ });
16
+ return to;
17
+ };
18
+ var __export = (target, all) => {
19
+ for (var name in all)
20
+ __defProp(target, name, {
21
+ get: all[name],
22
+ enumerable: true,
23
+ configurable: true,
24
+ set: (newValue) => all[name] = () => newValue
25
+ });
26
+ };
27
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
28
+ var __require = import.meta.require;
29
+
30
+ // src/tools/notebook-edit.ts
31
+ import { readFile, writeFile } from "fs/promises";
32
+ function toSourceLines(text) {
33
+ const lines = text.split(`
34
+ `);
35
+ return lines.map((line, idx) => idx < lines.length - 1 ? `${line}
36
+ ` : line);
37
+ }
38
+ var NotebookEditTool = {
39
+ name: "NotebookEdit",
40
+ description: "Edit a specific Jupyter notebook cell by id or index.",
41
+ inputSchema: {
42
+ type: "object",
43
+ properties: {
44
+ notebook_path: { type: "string", description: "Path to .ipynb file." },
45
+ cell_id: { type: "string", description: "Cell id to edit." },
46
+ cell_index: { type: "number", description: "Cell index to edit if id is not provided." },
47
+ new_source: { type: "string", description: "New cell source content." }
48
+ },
49
+ required: ["notebook_path", "new_source"]
50
+ },
51
+ async execute(input, ctx) {
52
+ const {
53
+ notebook_path,
54
+ cell_id,
55
+ cell_index,
56
+ new_source
57
+ } = input ?? {};
58
+ if (!notebook_path)
59
+ return { content: "Error: notebook_path is required", isError: true };
60
+ if (new_source === undefined)
61
+ return { content: "Error: new_source is required", isError: true };
62
+ const filePath = notebook_path.startsWith("/") ? notebook_path : `${ctx.cwd}/${notebook_path}`;
63
+ try {
64
+ const raw = await readFile(filePath, "utf-8");
65
+ const notebook = JSON.parse(raw);
66
+ if (!Array.isArray(notebook.cells)) {
67
+ return { content: "Error: notebook has no cells array", isError: true };
68
+ }
69
+ let targetIndex = -1;
70
+ if (cell_id) {
71
+ targetIndex = notebook.cells.findIndex((c) => c.id === cell_id);
72
+ } else if (typeof cell_index === "number") {
73
+ targetIndex = cell_index;
74
+ } else {
75
+ targetIndex = 0;
76
+ }
77
+ if (targetIndex < 0 || targetIndex >= notebook.cells.length) {
78
+ return {
79
+ content: `Error: cell not found (id=${cell_id ?? "n/a"}, index=${String(cell_index ?? "n/a")})`,
80
+ isError: true
81
+ };
82
+ }
83
+ const cell = notebook.cells[targetIndex];
84
+ cell.source = toSourceLines(new_source);
85
+ await writeFile(filePath, JSON.stringify(notebook, null, 2) + `
86
+ `, "utf-8");
87
+ return {
88
+ content: `Updated notebook cell ${targetIndex} in ${filePath}`
89
+ };
90
+ } catch (err) {
91
+ const message = err instanceof Error ? err.message : String(err);
92
+ return { content: `Error editing notebook: ${message}`, isError: true };
93
+ }
94
+ }
95
+ };
96
+ export {
97
+ NotebookEditTool
98
+ };
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Named tool presets for common use cases.
3
3
  */
4
+ import type { ToolsOption } from "../types.js";
4
5
  export declare const PRESETS: Record<string, string[]>;
5
- export declare function resolveToolNames(tools: string | string[] | undefined): string[];
6
+ export declare function resolveToolNames(tools: ToolsOption | undefined): string[];
6
7
  //# sourceMappingURL=presets.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../../src/tools/presets.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAI5C,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,GAAG,MAAM,EAAE,CAM/E"}
1
+ {"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../../src/tools/presets.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAmB5C,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,EAAE,CASzE"}
@@ -1,5 +1,20 @@
1
1
  // @bun
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
2
4
  var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __toESM = (mod, isNodeMode, target) => {
8
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
9
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
+ for (let key of __getOwnPropNames(mod))
11
+ if (!__hasOwnProp.call(to, key))
12
+ __defProp(to, key, {
13
+ get: () => mod[key],
14
+ enumerable: true
15
+ });
16
+ return to;
17
+ };
3
18
  var __export = (target, all) => {
4
19
  for (var name in all)
5
20
  __defProp(target, name, {
@@ -15,16 +30,34 @@ var __require = import.meta.require;
15
30
  // src/tools/presets.ts
16
31
  var PRESETS = {
17
32
  coding: ["Bash", "Read", "Write", "Edit", "Glob", "Grep"],
33
+ claude_code: [
34
+ "Bash",
35
+ "Read",
36
+ "Write",
37
+ "Edit",
38
+ "Glob",
39
+ "Grep",
40
+ "NotebookEdit",
41
+ "WebFetch",
42
+ "WebSearch",
43
+ "TodoWrite",
44
+ "Config",
45
+ "AskUserQuestion",
46
+ "ExitPlanMode"
47
+ ],
18
48
  readonly: ["Read", "Glob", "Grep"],
19
49
  minimal: ["Read", "Write", "Edit", "Glob", "Grep"]
20
50
  };
21
51
  function resolveToolNames(tools) {
22
52
  if (!tools)
23
- return PRESETS.coding;
24
- if (typeof tools === "string") {
25
- return PRESETS[tools] ?? [tools];
53
+ return PRESETS.claude_code;
54
+ if (Array.isArray(tools)) {
55
+ return tools;
56
+ }
57
+ if (tools.type === "preset") {
58
+ return PRESETS[tools.preset] ?? PRESETS.claude_code;
26
59
  }
27
- return tools;
60
+ throw new Error("Invalid tools option. Expected string[] or { type: 'preset', preset: 'claude_code' }.");
28
61
  }
29
62
  export {
30
63
  resolveToolNames,
@@ -1 +1 @@
1
- {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/tools/read.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAA2B,MAAM,eAAe,CAAC;AAKjF,eAAO,MAAM,QAAQ,EAAE,kBAoEtB,CAAC"}
1
+ {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/tools/read.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAA2B,MAAM,eAAe,CAAC;AAKjF,eAAO,MAAM,QAAQ,EAAE,kBAiFtB,CAAC"}
@@ -1,5 +1,20 @@
1
1
  // @bun
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
2
4
  var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __toESM = (mod, isNodeMode, target) => {
8
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
9
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
+ for (let key of __getOwnPropNames(mod))
11
+ if (!__hasOwnProp.call(to, key))
12
+ __defProp(to, key, {
13
+ get: () => mod[key],
14
+ enumerable: true
15
+ });
16
+ return to;
17
+ };
3
18
  var __export = (target, all) => {
4
19
  for (var name in all)
5
20
  __defProp(target, name, {
@@ -32,12 +47,17 @@ var ReadTool = {
32
47
  limit: {
33
48
  type: "number",
34
49
  description: "Number of lines to read"
50
+ },
51
+ pages: {
52
+ type: "array",
53
+ items: { type: "number" },
54
+ description: "Optional PDF page numbers (1-based)."
35
55
  }
36
56
  },
37
57
  required: ["file_path"]
38
58
  },
39
59
  async execute(input, ctx) {
40
- const { file_path, offset, limit } = input;
60
+ const { file_path, offset, limit, pages } = input;
41
61
  if (!file_path) {
42
62
  return { content: "Error: file_path is required", isError: true };
43
63
  }
@@ -48,6 +68,12 @@ var ReadTool = {
48
68
  if (!exists) {
49
69
  return { content: `Error: File not found: ${resolvedPath}`, isError: true };
50
70
  }
71
+ if (Array.isArray(pages) && pages.length > 0 && resolvedPath.toLowerCase().endsWith(".pdf")) {
72
+ return {
73
+ content: "Error: PDF page extraction is not implemented in this runtime.",
74
+ isError: true
75
+ };
76
+ }
51
77
  const text = await file.text();
52
78
  const lines = text.split(`
53
79
  `);
@@ -22,6 +22,8 @@ export type ToolImplementation = {
22
22
  export declare class ToolRegistry {
23
23
  private tools;
24
24
  register(tool: ToolImplementation): void;
25
+ unregister(name: string): void;
26
+ clearByPrefix(prefix: string): void;
25
27
  get(name: string): ToolImplementation | undefined;
26
28
  has(name: string): boolean;
27
29
  getDefinitions(): ToolDefinition[];
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAI5D,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,WAAW,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAChE,CAAC;AAIF,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAyC;IAEtD,QAAQ,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI;IAIxC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAIjD,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B,cAAc,IAAI,cAAc,EAAE;IAQ5B,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAclF,IAAI,IAAI,MAAM,EAAE;CAGjB"}
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAI5D,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,WAAW,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAChE,CAAC;AAIF,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAyC;IAEtD,QAAQ,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI;IAIxC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI9B,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAQnC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAIjD,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B,cAAc,IAAI,cAAc,EAAE;IAQ5B,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAclF,IAAI,IAAI,MAAM,EAAE;CAGjB"}
@@ -1,5 +1,20 @@
1
1
  // @bun
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
2
4
  var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __toESM = (mod, isNodeMode, target) => {
8
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
9
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
+ for (let key of __getOwnPropNames(mod))
11
+ if (!__hasOwnProp.call(to, key))
12
+ __defProp(to, key, {
13
+ get: () => mod[key],
14
+ enumerable: true
15
+ });
16
+ return to;
17
+ };
3
18
  var __export = (target, all) => {
4
19
  for (var name in all)
5
20
  __defProp(target, name, {
@@ -18,6 +33,16 @@ class ToolRegistry {
18
33
  register(tool) {
19
34
  this.tools.set(tool.name, tool);
20
35
  }
36
+ unregister(name) {
37
+ this.tools.delete(name);
38
+ }
39
+ clearByPrefix(prefix) {
40
+ for (const name of this.tools.keys()) {
41
+ if (name.startsWith(prefix)) {
42
+ this.tools.delete(name);
43
+ }
44
+ }
45
+ }
21
46
  get(name) {
22
47
  return this.tools.get(name);
23
48
  }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * TodoWrite tool.
3
+ * Persists structured task todos to .claude/todos.json in cwd.
4
+ */
5
+ import type { ToolImplementation } from "./registry.js";
6
+ export declare const TodoWriteTool: ToolImplementation;
7
+ //# sourceMappingURL=todo-write.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"todo-write.d.ts","sourceRoot":"","sources":["../../src/tools/todo-write.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAA2B,MAAM,eAAe,CAAC;AAQjF,eAAO,MAAM,aAAa,EAAE,kBAuD3B,CAAC"}
@@ -0,0 +1,84 @@
1
+ // @bun
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __toESM = (mod, isNodeMode, target) => {
8
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
9
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
+ for (let key of __getOwnPropNames(mod))
11
+ if (!__hasOwnProp.call(to, key))
12
+ __defProp(to, key, {
13
+ get: () => mod[key],
14
+ enumerable: true
15
+ });
16
+ return to;
17
+ };
18
+ var __export = (target, all) => {
19
+ for (var name in all)
20
+ __defProp(target, name, {
21
+ get: all[name],
22
+ enumerable: true,
23
+ configurable: true,
24
+ set: (newValue) => all[name] = () => newValue
25
+ });
26
+ };
27
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
28
+ var __require = import.meta.require;
29
+
30
+ // src/tools/todo-write.ts
31
+ import { mkdir, writeFile } from "fs/promises";
32
+ import { dirname, join } from "path";
33
+ var TodoWriteTool = {
34
+ name: "TodoWrite",
35
+ description: "Write/update task todo items for the current session.",
36
+ inputSchema: {
37
+ type: "object",
38
+ properties: {
39
+ todos: {
40
+ type: "array",
41
+ items: {
42
+ type: "object",
43
+ properties: {
44
+ content: { type: "string" },
45
+ status: { type: "string", enum: ["pending", "in_progress", "completed"] },
46
+ activeForm: { type: "string" }
47
+ },
48
+ required: ["content", "status"]
49
+ }
50
+ }
51
+ },
52
+ required: ["todos"]
53
+ },
54
+ async execute(input, ctx) {
55
+ const { todos } = input ?? {};
56
+ if (!Array.isArray(todos)) {
57
+ return { content: "Error: todos must be an array", isError: true };
58
+ }
59
+ for (const todo of todos) {
60
+ if (!todo?.content || !todo?.status) {
61
+ return { content: "Error: each todo requires content and status", isError: true };
62
+ }
63
+ }
64
+ const filePath = join(ctx.cwd, ".claude", "todos.json");
65
+ try {
66
+ await mkdir(dirname(filePath), { recursive: true });
67
+ const payload = {
68
+ updatedAt: new Date().toISOString(),
69
+ todos
70
+ };
71
+ await writeFile(filePath, JSON.stringify(payload, null, 2) + `
72
+ `, "utf-8");
73
+ return {
74
+ content: `Saved ${todos.length} todo item(s) to ${filePath}`
75
+ };
76
+ } catch (err) {
77
+ const message = err instanceof Error ? err.message : String(err);
78
+ return { content: `Error writing todos: ${message}`, isError: true };
79
+ }
80
+ }
81
+ };
82
+ export {
83
+ TodoWriteTool
84
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * WebFetch tool.
3
+ */
4
+ import type { ToolImplementation } from "./registry.js";
5
+ export declare const WebFetchTool: ToolImplementation;
6
+ //# sourceMappingURL=web-fetch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-fetch.d.ts","sourceRoot":"","sources":["../../src/tools/web-fetch.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAc,MAAM,eAAe,CAAC;AAKpE,eAAO,MAAM,YAAY,EAAE,kBAwE1B,CAAC"}
@@ -0,0 +1,100 @@
1
+ // @bun
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __toESM = (mod, isNodeMode, target) => {
8
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
9
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
+ for (let key of __getOwnPropNames(mod))
11
+ if (!__hasOwnProp.call(to, key))
12
+ __defProp(to, key, {
13
+ get: () => mod[key],
14
+ enumerable: true
15
+ });
16
+ return to;
17
+ };
18
+ var __export = (target, all) => {
19
+ for (var name in all)
20
+ __defProp(target, name, {
21
+ get: all[name],
22
+ enumerable: true,
23
+ configurable: true,
24
+ set: (newValue) => all[name] = () => newValue
25
+ });
26
+ };
27
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
28
+ var __require = import.meta.require;
29
+
30
+ // src/tools/web-fetch.ts
31
+ var DEFAULT_TIMEOUT_MS = 20000;
32
+ var MAX_OUTPUT = 80000;
33
+ var WebFetchTool = {
34
+ name: "WebFetch",
35
+ description: "Fetches a URL and returns response text.",
36
+ inputSchema: {
37
+ type: "object",
38
+ properties: {
39
+ url: {
40
+ type: "string",
41
+ description: "The URL to fetch."
42
+ },
43
+ prompt: {
44
+ type: "string",
45
+ description: "Optional fetch intent/instructions."
46
+ },
47
+ timeout_ms: {
48
+ type: "number",
49
+ description: "Timeout in milliseconds (default 20000)."
50
+ },
51
+ max_length: {
52
+ type: "number",
53
+ description: "Maximum output length (default 80000)."
54
+ }
55
+ },
56
+ required: ["url"]
57
+ },
58
+ async execute(input) {
59
+ const { url, timeout_ms, max_length } = input ?? {};
60
+ if (!url)
61
+ return { content: "Error: url is required", isError: true };
62
+ const timeout = Math.max(1000, timeout_ms ?? DEFAULT_TIMEOUT_MS);
63
+ const outLimit = Math.max(1000, max_length ?? MAX_OUTPUT);
64
+ const controller = new AbortController;
65
+ const timer = setTimeout(() => controller.abort(), timeout);
66
+ try {
67
+ const res = await fetch(url, {
68
+ method: "GET",
69
+ signal: controller.signal,
70
+ headers: {
71
+ "user-agent": "fourmis-agent-sdk/1.0"
72
+ }
73
+ });
74
+ const contentType = res.headers.get("content-type") ?? "unknown";
75
+ let body = await res.text();
76
+ if (body.length > outLimit) {
77
+ body = body.slice(0, outLimit) + `
78
+ ... (truncated)`;
79
+ }
80
+ return {
81
+ content: [
82
+ `Status: ${res.status} ${res.statusText}`,
83
+ `Content-Type: ${contentType}`,
84
+ "",
85
+ body
86
+ ].join(`
87
+ `),
88
+ isError: res.ok ? undefined : true
89
+ };
90
+ } catch (err) {
91
+ const message = err instanceof Error ? err.message : String(err);
92
+ return { content: `Error fetching URL: ${message}`, isError: true };
93
+ } finally {
94
+ clearTimeout(timer);
95
+ }
96
+ }
97
+ };
98
+ export {
99
+ WebFetchTool
100
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * WebSearch tool.
3
+ * Uses DuckDuckGo HTML endpoint for lightweight public web search.
4
+ */
5
+ import type { ToolImplementation } from "./registry.js";
6
+ export declare const WebSearchTool: ToolImplementation;
7
+ //# sourceMappingURL=web-search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-search.d.ts","sourceRoot":"","sources":["../../src/tools/web-search.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAc,MAAM,eAAe,CAAC;AAepE,eAAO,MAAM,aAAa,EAAE,kBAiE3B,CAAC"}
@@ -0,0 +1,93 @@
1
+ // @bun
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __toESM = (mod, isNodeMode, target) => {
8
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
9
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
+ for (let key of __getOwnPropNames(mod))
11
+ if (!__hasOwnProp.call(to, key))
12
+ __defProp(to, key, {
13
+ get: () => mod[key],
14
+ enumerable: true
15
+ });
16
+ return to;
17
+ };
18
+ var __export = (target, all) => {
19
+ for (var name in all)
20
+ __defProp(target, name, {
21
+ get: all[name],
22
+ enumerable: true,
23
+ configurable: true,
24
+ set: (newValue) => all[name] = () => newValue
25
+ });
26
+ };
27
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
28
+ var __require = import.meta.require;
29
+
30
+ // src/tools/web-search.ts
31
+ var SEARCH_ENDPOINT = "https://duckduckgo.com/html/";
32
+ function stripTags(input) {
33
+ return input.replace(/<[^>]+>/g, "").replace(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&#39;/g, "'").replace(/&lt;/g, "<").replace(/&gt;/g, ">").trim();
34
+ }
35
+ var WebSearchTool = {
36
+ name: "WebSearch",
37
+ description: "Searches the web and returns top result links.",
38
+ inputSchema: {
39
+ type: "object",
40
+ properties: {
41
+ query: {
42
+ type: "string",
43
+ description: "Search query."
44
+ },
45
+ max_results: {
46
+ type: "number",
47
+ description: "Maximum results to return (default 5)."
48
+ }
49
+ },
50
+ required: ["query"]
51
+ },
52
+ async execute(input) {
53
+ const { query, max_results } = input ?? {};
54
+ if (!query) {
55
+ return { content: "Error: query is required", isError: true };
56
+ }
57
+ const limit = Math.max(1, Math.min(20, max_results ?? 5));
58
+ try {
59
+ const url = `${SEARCH_ENDPOINT}?q=${encodeURIComponent(query)}`;
60
+ const res = await fetch(url, {
61
+ headers: {
62
+ "user-agent": "fourmis-agent-sdk/1.0"
63
+ }
64
+ });
65
+ if (!res.ok) {
66
+ return {
67
+ content: `Error searching web: ${res.status} ${res.statusText}`,
68
+ isError: true
69
+ };
70
+ }
71
+ const html = await res.text();
72
+ const matches = [...html.matchAll(/<a[^>]*class="result__a"[^>]*href="([^"]+)"[^>]*>([\s\S]*?)<\/a>/g)];
73
+ if (matches.length === 0) {
74
+ return { content: "No search results found." };
75
+ }
76
+ const lines = [];
77
+ for (let i = 0;i < Math.min(limit, matches.length); i++) {
78
+ const href = stripTags(matches[i][1]);
79
+ const title = stripTags(matches[i][2]);
80
+ lines.push(`${i + 1}. ${title}
81
+ ${href}`);
82
+ }
83
+ return { content: lines.join(`
84
+ `) };
85
+ } catch (err) {
86
+ const message = err instanceof Error ? err.message : String(err);
87
+ return { content: `Error searching web: ${message}`, isError: true };
88
+ }
89
+ }
90
+ };
91
+ export {
92
+ WebSearchTool
93
+ };
@@ -1,5 +1,20 @@
1
1
  // @bun
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
2
4
  var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __toESM = (mod, isNodeMode, target) => {
8
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
9
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
+ for (let key of __getOwnPropNames(mod))
11
+ if (!__hasOwnProp.call(to, key))
12
+ __defProp(to, key, {
13
+ get: () => mod[key],
14
+ enumerable: true
15
+ });
16
+ return to;
17
+ };
3
18
  var __export = (target, all) => {
4
19
  for (var name in all)
5
20
  __defProp(target, name, {