fourmis-agents-sdk 0.3.1 → 0.4.1
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/README.md +126 -198
- package/dist/agent-loop.d.ts +21 -3
- package/dist/agent-loop.d.ts.map +1 -1
- package/dist/agent-loop.js +279 -90
- package/dist/agents/index.js +1079 -124
- package/dist/agents/tools.d.ts.map +1 -1
- package/dist/agents/tools.js +1079 -124
- package/dist/agents/types.d.ts +4 -0
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/api.d.ts +8 -5
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +1663 -430
- package/dist/hooks.d.ts +19 -1
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +27 -2
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1671 -431
- package/dist/mcp/client.d.ts +8 -1
- package/dist/mcp/client.d.ts.map +1 -1
- package/dist/mcp/client.js +134 -13
- package/dist/mcp/index.js +134 -13
- package/dist/mcp/types.d.ts +21 -1
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/permissions.d.ts.map +1 -1
- package/dist/permissions.js +7 -3
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +41 -2
- package/dist/providers/openai.d.ts +6 -0
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +36 -6
- package/dist/providers/registry.js +76 -8
- package/dist/providers/types.d.ts +4 -1
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/query.d.ts +21 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +69 -1
- package/dist/skills/index.js +23 -1
- package/dist/skills/skills.d.ts +16 -0
- package/dist/skills/skills.d.ts.map +1 -1
- package/dist/skills/skills.js +23 -1
- package/dist/tools/ask-user-question.d.ts +7 -0
- package/dist/tools/ask-user-question.d.ts.map +1 -0
- package/dist/tools/ask-user-question.js +48 -0
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +47 -2
- package/dist/tools/config.d.ts +7 -0
- package/dist/tools/config.d.ts.map +1 -0
- package/dist/tools/config.js +114 -0
- package/dist/tools/exit-plan-mode.d.ts +7 -0
- package/dist/tools/exit-plan-mode.d.ts.map +1 -0
- package/dist/tools/exit-plan-mode.js +34 -0
- package/dist/tools/index.d.ts +7 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +506 -9
- package/dist/tools/notebook-edit.d.ts +7 -0
- package/dist/tools/notebook-edit.d.ts.map +1 -0
- package/dist/tools/notebook-edit.js +83 -0
- package/dist/tools/presets.d.ts +2 -1
- package/dist/tools/presets.d.ts.map +1 -1
- package/dist/tools/presets.js +22 -4
- package/dist/tools/read.d.ts.map +1 -1
- package/dist/tools/read.js +12 -1
- package/dist/tools/registry.d.ts +2 -0
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/registry.js +10 -0
- package/dist/tools/todo-write.d.ts +7 -0
- package/dist/tools/todo-write.d.ts.map +1 -0
- package/dist/tools/todo-write.js +69 -0
- package/dist/tools/web-fetch.d.ts +6 -0
- package/dist/tools/web-fetch.d.ts.map +1 -0
- package/dist/tools/web-fetch.js +85 -0
- package/dist/tools/web-search.d.ts +7 -0
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +78 -0
- package/dist/types.d.ts +344 -42
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/session-store.d.ts +1 -1
- package/dist/utils/session-store.d.ts.map +1 -1
- package/dist/utils/session-store.js +49 -2
- package/dist/utils/system-prompt.d.ts +2 -0
- package/dist/utils/system-prompt.d.ts.map +1 -1
- package/dist/utils/system-prompt.js +33 -4
- package/package.json +3 -2
package/dist/tools/bash.js
CHANGED
|
@@ -33,17 +33,58 @@ var BashTool = {
|
|
|
33
33
|
timeout: {
|
|
34
34
|
type: "number",
|
|
35
35
|
description: "Timeout in milliseconds (max 600000)"
|
|
36
|
+
},
|
|
37
|
+
run_in_background: {
|
|
38
|
+
type: "boolean",
|
|
39
|
+
description: "Run command asynchronously and return immediately."
|
|
40
|
+
},
|
|
41
|
+
dangerouslyDisableSandbox: {
|
|
42
|
+
type: "boolean",
|
|
43
|
+
description: "If true, explicitly request unsandboxed execution."
|
|
44
|
+
},
|
|
45
|
+
_simulatedSedEdit: {
|
|
46
|
+
type: "object",
|
|
47
|
+
properties: {
|
|
48
|
+
filePath: { type: "string" },
|
|
49
|
+
newContent: { type: "string" }
|
|
50
|
+
},
|
|
51
|
+
description: "Internal field for precomputed edit previews."
|
|
36
52
|
}
|
|
37
53
|
},
|
|
38
54
|
required: ["command"]
|
|
39
55
|
},
|
|
40
56
|
async execute(input, ctx) {
|
|
41
|
-
const {
|
|
57
|
+
const {
|
|
58
|
+
command,
|
|
59
|
+
timeout: timeoutMs,
|
|
60
|
+
run_in_background,
|
|
61
|
+
description,
|
|
62
|
+
dangerouslyDisableSandbox,
|
|
63
|
+
_simulatedSedEdit
|
|
64
|
+
} = input;
|
|
42
65
|
if (!command || typeof command !== "string") {
|
|
43
66
|
return { content: "Error: command is required", isError: true };
|
|
44
67
|
}
|
|
45
68
|
const timeout = Math.min(timeoutMs ?? DEFAULT_TIMEOUT, MAX_TIMEOUT);
|
|
46
69
|
try {
|
|
70
|
+
if (run_in_background) {
|
|
71
|
+
const proc2 = Bun.spawn(["bash", "-c", command], {
|
|
72
|
+
cwd: ctx.cwd,
|
|
73
|
+
stdout: "ignore",
|
|
74
|
+
stderr: "ignore",
|
|
75
|
+
stdin: "ignore",
|
|
76
|
+
env: { ...process.env, ...ctx.env }
|
|
77
|
+
});
|
|
78
|
+
return {
|
|
79
|
+
content: `Background command started (pid ${proc2.pid ?? "unknown"}).`,
|
|
80
|
+
metadata: {
|
|
81
|
+
pid: proc2.pid ?? null,
|
|
82
|
+
run_in_background: true,
|
|
83
|
+
dangerouslyDisableSandbox: dangerouslyDisableSandbox === true,
|
|
84
|
+
hasSimulatedSedEdit: !!_simulatedSedEdit
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
47
88
|
const proc = Bun.spawn(["bash", "-c", command], {
|
|
48
89
|
cwd: ctx.cwd,
|
|
49
90
|
stdout: "pipe",
|
|
@@ -75,7 +116,11 @@ var BashTool = {
|
|
|
75
116
|
return {
|
|
76
117
|
content: output,
|
|
77
118
|
isError: exitCode !== 0 ? true : undefined,
|
|
78
|
-
metadata: {
|
|
119
|
+
metadata: {
|
|
120
|
+
exitCode,
|
|
121
|
+
dangerouslyDisableSandbox: dangerouslyDisableSandbox === true,
|
|
122
|
+
hasSimulatedSedEdit: !!_simulatedSedEdit
|
|
123
|
+
}
|
|
79
124
|
};
|
|
80
125
|
} catch (err) {
|
|
81
126
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/tools/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAA2B,MAAM,eAAe,CAAC;AAmCjF,eAAO,MAAM,UAAU,EAAE,kBA4ExB,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
set: (newValue) => all[name] = () => newValue
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
13
|
+
var __require = import.meta.require;
|
|
14
|
+
|
|
15
|
+
// src/tools/config.ts
|
|
16
|
+
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
17
|
+
import { join, dirname } from "path";
|
|
18
|
+
function scopePath(cwd, scope) {
|
|
19
|
+
if (scope === "project")
|
|
20
|
+
return join(cwd, ".claude", "settings.json");
|
|
21
|
+
return join(cwd, ".claude", "settings.local.json");
|
|
22
|
+
}
|
|
23
|
+
function setByPath(obj, keyPath, value) {
|
|
24
|
+
const keys = keyPath.split(".").filter(Boolean);
|
|
25
|
+
if (keys.length === 0)
|
|
26
|
+
return;
|
|
27
|
+
let current = obj;
|
|
28
|
+
for (let i = 0;i < keys.length - 1; i++) {
|
|
29
|
+
const key = keys[i];
|
|
30
|
+
const next = current[key];
|
|
31
|
+
if (!next || typeof next !== "object" || Array.isArray(next)) {
|
|
32
|
+
current[key] = {};
|
|
33
|
+
}
|
|
34
|
+
current = current[key];
|
|
35
|
+
}
|
|
36
|
+
current[keys[keys.length - 1]] = value;
|
|
37
|
+
}
|
|
38
|
+
function getByPath(obj, keyPath) {
|
|
39
|
+
const keys = keyPath.split(".").filter(Boolean);
|
|
40
|
+
let current = obj;
|
|
41
|
+
for (const key of keys) {
|
|
42
|
+
if (!current || typeof current !== "object" || Array.isArray(current))
|
|
43
|
+
return;
|
|
44
|
+
current = current[key];
|
|
45
|
+
}
|
|
46
|
+
return current;
|
|
47
|
+
}
|
|
48
|
+
var ConfigTool = {
|
|
49
|
+
name: "Config",
|
|
50
|
+
description: "Read or update .claude settings values.",
|
|
51
|
+
inputSchema: {
|
|
52
|
+
type: "object",
|
|
53
|
+
properties: {
|
|
54
|
+
action: {
|
|
55
|
+
type: "string",
|
|
56
|
+
enum: ["get", "set", "list"]
|
|
57
|
+
},
|
|
58
|
+
key: {
|
|
59
|
+
type: "string",
|
|
60
|
+
description: "Dot-path key (for get/set)."
|
|
61
|
+
},
|
|
62
|
+
value: {
|
|
63
|
+
description: "Value for set action."
|
|
64
|
+
},
|
|
65
|
+
scope: {
|
|
66
|
+
type: "string",
|
|
67
|
+
enum: ["local", "project"]
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
required: ["action"]
|
|
71
|
+
},
|
|
72
|
+
async execute(input, ctx) {
|
|
73
|
+
const {
|
|
74
|
+
action,
|
|
75
|
+
key,
|
|
76
|
+
value,
|
|
77
|
+
scope = "local"
|
|
78
|
+
} = input ?? {};
|
|
79
|
+
if (!action) {
|
|
80
|
+
return { content: "Error: action is required", isError: true };
|
|
81
|
+
}
|
|
82
|
+
const filePath = scopePath(ctx.cwd, scope);
|
|
83
|
+
let data = {};
|
|
84
|
+
try {
|
|
85
|
+
const raw = await readFile(filePath, "utf-8");
|
|
86
|
+
data = JSON.parse(raw);
|
|
87
|
+
} catch {
|
|
88
|
+
data = {};
|
|
89
|
+
}
|
|
90
|
+
if (action === "list") {
|
|
91
|
+
return { content: JSON.stringify(data, null, 2) };
|
|
92
|
+
}
|
|
93
|
+
if (!key) {
|
|
94
|
+
return { content: "Error: key is required for get/set", isError: true };
|
|
95
|
+
}
|
|
96
|
+
if (action === "get") {
|
|
97
|
+
const out = getByPath(data, key);
|
|
98
|
+
return { content: out === undefined ? "undefined" : JSON.stringify(out, null, 2) };
|
|
99
|
+
}
|
|
100
|
+
setByPath(data, key, value);
|
|
101
|
+
try {
|
|
102
|
+
await mkdir(dirname(filePath), { recursive: true });
|
|
103
|
+
await writeFile(filePath, JSON.stringify(data, null, 2) + `
|
|
104
|
+
`, "utf-8");
|
|
105
|
+
return { content: `Updated ${key} in ${filePath}` };
|
|
106
|
+
} catch (err) {
|
|
107
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
108
|
+
return { content: `Error writing config: ${message}`, isError: true };
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
export {
|
|
113
|
+
ConfigTool
|
|
114
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ExitPlanMode tool.
|
|
3
|
+
* Signals the runtime to leave plan mode and return to default permissions.
|
|
4
|
+
*/
|
|
5
|
+
import type { ToolImplementation } from "./registry.js";
|
|
6
|
+
export declare const ExitPlanModeTool: ToolImplementation;
|
|
7
|
+
//# sourceMappingURL=exit-plan-mode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exit-plan-mode.d.ts","sourceRoot":"","sources":["../../src/tools/exit-plan-mode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAc,MAAM,eAAe,CAAC;AAEpE,eAAO,MAAM,gBAAgB,EAAE,kBAgB9B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
set: (newValue) => all[name] = () => newValue
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
13
|
+
var __require = import.meta.require;
|
|
14
|
+
|
|
15
|
+
// src/tools/exit-plan-mode.ts
|
|
16
|
+
var ExitPlanModeTool = {
|
|
17
|
+
name: "ExitPlanMode",
|
|
18
|
+
description: "Exit plan mode and resume normal execution permissions.",
|
|
19
|
+
inputSchema: {
|
|
20
|
+
type: "object",
|
|
21
|
+
properties: {}
|
|
22
|
+
},
|
|
23
|
+
async execute() {
|
|
24
|
+
return {
|
|
25
|
+
content: "Exiting plan mode.",
|
|
26
|
+
metadata: {
|
|
27
|
+
setPermissionMode: "default"
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
ExitPlanModeTool
|
|
34
|
+
};
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -10,6 +10,13 @@ export { WriteTool } from "./write.js";
|
|
|
10
10
|
export { EditTool } from "./edit.js";
|
|
11
11
|
export { GlobTool } from "./glob.js";
|
|
12
12
|
export { GrepTool } from "./grep.js";
|
|
13
|
+
export { NotebookEditTool } from "./notebook-edit.js";
|
|
14
|
+
export { WebFetchTool } from "./web-fetch.js";
|
|
15
|
+
export { WebSearchTool } from "./web-search.js";
|
|
16
|
+
export { AskUserQuestionTool } from "./ask-user-question.js";
|
|
17
|
+
export { TodoWriteTool } from "./todo-write.js";
|
|
18
|
+
export { ConfigTool } from "./config.js";
|
|
19
|
+
export { ExitPlanModeTool } from "./exit-plan-mode.js";
|
|
13
20
|
import { ToolRegistry } from "./registry.js";
|
|
14
21
|
/**
|
|
15
22
|
* Build a ToolRegistry populated with the requested tools.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAgC7C;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EAAE,EACnB,YAAY,CAAC,EAAE,MAAM,EAAE,EACvB,eAAe,CAAC,EAAE,MAAM,EAAE,GACzB,YAAY,CAad"}
|