Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
fix(sdk): accept long inline skill content in TypeScript (#5308)
Wenchao An563313ebe10a
diff --git a/sdk/typescript/src/client.ts b/sdk/typescript/src/client.tsindex ec28e7d6c..170985c4e 100644--- a/sdk/typescript/src/client.ts+++ b/sdk/typescript/src/client.ts@@ -181,7 +181,9 @@ export class OpenVikingClient {target_uri: options.targetUri,});const local =- typeof source === "string" ? await nodePathToBlob(source) : undefined;+ typeof source === "string"+ ? await nodePathToBlob(source, { allowInlineContent: true })+ : undefined;if (local)body.temp_file_id = await this.upload(local.blob, local.filename);else body.data = source;@@ -272,7 +274,9 @@ export class OpenVikingClient {telemetry: options.telemetry,});const local =- typeof source === "string" ? await nodePathToBlob(source) : undefined;+ typeof source === "string"+ ? await nodePathToBlob(source, { allowInlineContent: true })+ : undefined;if (local)body.temp_file_id = await this.upload(local.blob, local.filename);else body.data = source;diff --git a/sdk/typescript/src/node-files.ts b/sdk/typescript/src/node-files.tsindex f74bd798d..24b3fff8e 100644--- a/sdk/typescript/src/node-files.ts+++ b/sdk/typescript/src/node-files.ts@@ -63,14 +63,19 @@ export async function nodeImagePathToDataURI(/** Read a Node.js file or zip a directory for temporary upload. */export async function nodePathToBlob(path: string,- options: { allowDirectory?: boolean } = {},+ options: { allowDirectory?: boolean; allowInlineContent?: boolean } = {},): Promise<{ blob: Blob; filename: string; sourceName?: string } | undefined> {// Keep built-in specifiers dynamic so bundled ESM and CommonJS outputs share// this implementation without eager filesystem initialization.const [fs, paths, stat] = await Promise.all([nodeFs(),nodePath(),- statOrUndefined(path),+ statOrUndefined(path).catch((error: NodeJS.ErrnoException) => {+ // Inline skill content can exceed filesystem filename limits.+ if (options.allowInlineContent && error.code === "ENAMETOOLONG")+ return undefined;+ throw error;+ }),]);if (!stat) return undefined;if (stat.isFile())diff --git a/sdk/typescript/tests/client.test.ts b/sdk/typescript/tests/client.test.tsindex f7947b8b7..febbe85fb 100644--- a/sdk/typescript/tests/client.test.ts+++ b/sdk/typescript/tests/client.test.ts@@ -847,6 +847,56 @@ describe("OpenVikingClient", () => {});});+ it.each(["addSkill", "updateSkill"] as const)(+ "%s sends long inline Markdown without a local upload",+ async (method) => {+ const source =+ "---\nname: demo\ndescription: An inline skill\n---\n" ++ "Follow these instructions carefully.\n".repeat(20);+ const fetcher = vi.fn<typeof fetch>().mockResolvedValue(ok({}));+ const client = new OpenVikingClient({+ baseUrl: "https://example.com",+ fetch: fetcher,+ });++ await expect(+ method === "addSkill"+ ? client.addSkill(source)+ : client.updateSkill("demo", source),+ ).resolves.toEqual({});++ expect(fetcher).toHaveBeenCalledTimes(1);+ const [url, init] = fetcher.mock.calls[0]!;+ expect(String(url)).toBe(+ `https://example.com/api/v1/skills${method === "addSkill" ? "" : "/demo"}`,+ );+ expect(init?.method).toBe(method === "addSkill" ? "POST" : "PUT");+ expect(JSON.parse(String(init?.body))).toEqual({+ wait: false,+ data: source,+ });+ },+ );++ it.each(["addResource", "importOVPack", "restoreOVPack"] as const)(+ "%s preserves local path errors before sending a request",+ async (method) => {+ const fetcher = vi.fn<typeof fetch>().mockResolvedValue(ok({}));+ const client = new OpenVikingClient({+ baseUrl: "https://example.com",+ fetch: fetcher,+ });+ const source = join(tmpdir(), "x".repeat(300));++ await expect(+ method === "importOVPack"+ ? client.importOVPack(source, "resources")+ : client[method](source),+ ).rejects.toMatchObject({ code: "ENAMETOOLONG" });+ expect(fetcher).not.toHaveBeenCalled();+ },+ );+it("maps non-JSON upload failures to OpenVikingError", async () => {const directory = await mkdtemp(join(tmpdir(), "openviking-sdk-error-"));const path = join(directory, "resource.md");