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
|
@@ -52,6 +52,7 @@ import { homedir } from "os";
|
|
|
52
52
|
import { basename, dirname, isAbsolute, join, resolve } from "path";
|
|
53
53
|
var MAX_NAME_LENGTH = 64;
|
|
54
54
|
var MAX_DESCRIPTION_LENGTH = 1024;
|
|
55
|
+
var MAX_COMPATIBILITY_LENGTH = 500;
|
|
55
56
|
var CONFIG_DIR_NAME = ".claude";
|
|
56
57
|
function shouldIgnore(name) {
|
|
57
58
|
return name.startsWith(".") || name === "node_modules";
|
|
@@ -84,6 +85,14 @@ function validateDescription(description) {
|
|
|
84
85
|
}
|
|
85
86
|
return errors;
|
|
86
87
|
}
|
|
88
|
+
function validateCompatibility(compatibility) {
|
|
89
|
+
if (!compatibility)
|
|
90
|
+
return [];
|
|
91
|
+
if (compatibility.length > MAX_COMPATIBILITY_LENGTH) {
|
|
92
|
+
return [`compatibility exceeds ${MAX_COMPATIBILITY_LENGTH} characters (${compatibility.length})`];
|
|
93
|
+
}
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
87
96
|
function loadSkillsFromDir(options) {
|
|
88
97
|
return loadSkillsFromDirInternal(options.dir, options.source, true);
|
|
89
98
|
}
|
|
@@ -148,9 +157,15 @@ function loadSkillFromFile(filePath, source) {
|
|
|
148
157
|
for (const error of nameErrors) {
|
|
149
158
|
diagnostics.push({ type: "warning", message: error, path: filePath });
|
|
150
159
|
}
|
|
160
|
+
const compatErrors = validateCompatibility(frontmatter.compatibility);
|
|
161
|
+
for (const error of compatErrors) {
|
|
162
|
+
diagnostics.push({ type: "warning", message: error, path: filePath });
|
|
163
|
+
}
|
|
151
164
|
if (!frontmatter.description || frontmatter.description.trim() === "") {
|
|
152
165
|
return { skill: null, diagnostics };
|
|
153
166
|
}
|
|
167
|
+
const allowedToolsRaw = frontmatter["allowed-tools"];
|
|
168
|
+
const allowedTools = allowedToolsRaw ? allowedToolsRaw.split(/\s+/).filter(Boolean) : undefined;
|
|
154
169
|
return {
|
|
155
170
|
skill: {
|
|
156
171
|
name,
|
|
@@ -158,7 +173,11 @@ function loadSkillFromFile(filePath, source) {
|
|
|
158
173
|
filePath,
|
|
159
174
|
baseDir: skillDir,
|
|
160
175
|
source,
|
|
161
|
-
disableModelInvocation: frontmatter["disable-model-invocation"] === true
|
|
176
|
+
disableModelInvocation: frontmatter["disable-model-invocation"] === true,
|
|
177
|
+
license: frontmatter.license,
|
|
178
|
+
compatibility: frontmatter.compatibility,
|
|
179
|
+
metadata: frontmatter.metadata,
|
|
180
|
+
allowedTools
|
|
162
181
|
},
|
|
163
182
|
diagnostics
|
|
164
183
|
};
|
|
@@ -274,6 +293,9 @@ function formatSkillsForPrompt(skills) {
|
|
|
274
293
|
lines.push(` <name>${escapeXml(skill.name)}</name>`);
|
|
275
294
|
lines.push(` <description>${escapeXml(skill.description)}</description>`);
|
|
276
295
|
lines.push(` <location>${escapeXml(skill.filePath)}</location>`);
|
|
296
|
+
if (skill.allowedTools?.length) {
|
|
297
|
+
lines.push(` <allowed-tools>${escapeXml(skill.allowedTools.join(" "))}</allowed-tools>`);
|
|
298
|
+
}
|
|
277
299
|
lines.push(" </skill>");
|
|
278
300
|
}
|
|
279
301
|
lines.push("</available_skills>");
|
|
@@ -346,11 +368,18 @@ function buildSystemPrompt(context) {
|
|
|
346
368
|
sections.push(`# Environment
|
|
347
369
|
|
|
348
370
|
Working directory: ${context.cwd}`);
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
371
|
+
if (context.additionalDirectories && context.additionalDirectories.length > 0) {
|
|
372
|
+
sections.push(`Additional allowed directories:
|
|
373
|
+
${context.additionalDirectories.map((d) => `- ${d}`).join(`
|
|
374
|
+
`)}`);
|
|
375
|
+
}
|
|
376
|
+
if (context.loadProjectInstructions) {
|
|
377
|
+
const instructions = readProjectInstructions(context.cwd);
|
|
378
|
+
if (instructions) {
|
|
379
|
+
sections.push(`# Project Instructions
|
|
352
380
|
|
|
353
381
|
${instructions}`);
|
|
382
|
+
}
|
|
354
383
|
}
|
|
355
384
|
}
|
|
356
385
|
if (context.skills && context.skills.length > 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fourmis-agents-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Multi-provider AI agent SDK with direct API access and in-process tool execution",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -58,7 +58,8 @@
|
|
|
58
58
|
"typecheck": "tsc --noEmit",
|
|
59
59
|
"test": "bun test",
|
|
60
60
|
"test:tools": "bun test tests/tools/",
|
|
61
|
-
"test:integration": "bun test tests/integration.test.ts"
|
|
61
|
+
"test:integration": "bun test tests/integration.test.ts",
|
|
62
|
+
"test:compat": "bun run tests/compat/run-compat.ts"
|
|
62
63
|
},
|
|
63
64
|
"dependencies": {
|
|
64
65
|
"@anthropic-ai/sdk": "^0.74.0",
|