@agent-api/sdk 1.0.5 → 1.0.6
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/CHANGELOG.md +7 -0
- package/README.md +1 -1
- package/dist/local-skills.js +15 -7
- package/dist/types/skills.d.ts +1 -1
- package/dist/version.d.ts +2 -2
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Production JavaScript/TypeScript SDK for the Managed Agent API.
|
|
4
4
|
|
|
5
|
-
**Published on npm:** [`@agent-api/sdk`](https://www.npmjs.com/package/@agent-api/sdk) (v1.0.
|
|
5
|
+
**Published on npm:** [`@agent-api/sdk`](https://www.npmjs.com/package/@agent-api/sdk) (v1.0.6)
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
package/dist/local-skills.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { functionCallOutputInput, pendingFunctionCalls } from "./local-functions.js";
|
|
2
|
+
const DEFAULT_FOCUS_MANIFEST_CHARS = 16000;
|
|
2
3
|
export async function localSkillFromDirectory(rootDir, options = {}) {
|
|
3
4
|
const fs = await import("node:fs/promises");
|
|
4
5
|
const path = await import("node:path");
|
|
@@ -37,7 +38,7 @@ export async function runLocalSkillHandlers(response, localSkills) {
|
|
|
37
38
|
return outputs;
|
|
38
39
|
}
|
|
39
40
|
async function focusLocalSkills(args, byID) {
|
|
40
|
-
const
|
|
41
|
+
const maxManifestChars = manifestCharLimit(args);
|
|
41
42
|
const items = Array.isArray(args.skills) ? args.skills : [];
|
|
42
43
|
if (!Array.isArray(args.skills)) {
|
|
43
44
|
return { data: [{ ok: false, error: { code: "invalid_skill_focus", message: "skills must be an array" } }] };
|
|
@@ -58,7 +59,7 @@ async function focusLocalSkills(args, byID) {
|
|
|
58
59
|
continue;
|
|
59
60
|
}
|
|
60
61
|
try {
|
|
61
|
-
result.skill = await focusedLocalSkill(descriptor,
|
|
62
|
+
result.skill = await focusedLocalSkill(descriptor, maxManifestChars);
|
|
62
63
|
result.ok = true;
|
|
63
64
|
}
|
|
64
65
|
catch (error) {
|
|
@@ -68,9 +69,10 @@ async function focusLocalSkills(args, byID) {
|
|
|
68
69
|
}
|
|
69
70
|
return { data };
|
|
70
71
|
}
|
|
71
|
-
async function focusedLocalSkill(descriptor,
|
|
72
|
+
async function focusedLocalSkill(descriptor, maxManifestChars) {
|
|
72
73
|
const fs = await import("node:fs/promises");
|
|
73
74
|
const path = await import("node:path");
|
|
75
|
+
const { TextDecoder } = await import("node:util");
|
|
74
76
|
const root = path.resolve(descriptor.root_hint || ".");
|
|
75
77
|
const stat = await fs.stat(root);
|
|
76
78
|
if (!stat.isDirectory()) {
|
|
@@ -79,12 +81,13 @@ async function focusedLocalSkill(descriptor, maxManifestBytes) {
|
|
|
79
81
|
let manifest = "";
|
|
80
82
|
let manifestTruncated = false;
|
|
81
83
|
try {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
const manifestBytes = await fs.readFile(path.join(root, "SKILL.md"));
|
|
85
|
+
manifest = new TextDecoder("utf-8", { fatal: true }).decode(manifestBytes);
|
|
86
|
+
const manifestChars = Array.from(manifest);
|
|
87
|
+
if (maxManifestChars > 0 && manifestChars.length > maxManifestChars) {
|
|
88
|
+
manifest = manifestChars.slice(0, maxManifestChars).join("");
|
|
85
89
|
manifestTruncated = true;
|
|
86
90
|
}
|
|
87
|
-
manifest = manifestBytes.toString("utf8");
|
|
88
91
|
}
|
|
89
92
|
catch (error) {
|
|
90
93
|
if (error?.code !== "ENOENT") {
|
|
@@ -120,6 +123,11 @@ async function focusedLocalSkill(descriptor, maxManifestBytes) {
|
|
|
120
123
|
metadata: descriptor.metadata || {},
|
|
121
124
|
};
|
|
122
125
|
}
|
|
126
|
+
function manifestCharLimit(args) {
|
|
127
|
+
const raw = args.max_manifest_chars ?? DEFAULT_FOCUS_MANIFEST_CHARS;
|
|
128
|
+
const value = Number(raw);
|
|
129
|
+
return Number.isFinite(value) ? value : DEFAULT_FOCUS_MANIFEST_CHARS;
|
|
130
|
+
}
|
|
123
131
|
async function walkFiles(fs, path, root, dir) {
|
|
124
132
|
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
125
133
|
const out = [];
|
package/dist/types/skills.d.ts
CHANGED
|
@@ -102,7 +102,7 @@ export interface DiscoverSkillsParams {
|
|
|
102
102
|
export interface FocusSkillParams {
|
|
103
103
|
skills: SkillFocusItem[];
|
|
104
104
|
fallback_to_main?: boolean;
|
|
105
|
-
|
|
105
|
+
max_manifest_chars?: number;
|
|
106
106
|
}
|
|
107
107
|
export interface SkillFileMutation {
|
|
108
108
|
path: string;
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "1.0.
|
|
2
|
-
export declare const USER_AGENT = "@agent-api/sdk/1.0.
|
|
1
|
+
export declare const VERSION = "1.0.6";
|
|
2
|
+
export declare const USER_AGENT = "@agent-api/sdk/1.0.6";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = "1.0.
|
|
1
|
+
export const VERSION = "1.0.6";
|
|
2
2
|
export const USER_AGENT = `@agent-api/sdk/${VERSION}`;
|