@qvac/sdk 0.4.1 → 0.5.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.
- package/README.md +328 -200
- package/dist/client/api/completion-stream.d.ts +15 -5
- package/dist/client/api/completion-stream.js +50 -14
- package/dist/client/api/embed.d.ts +17 -3
- package/dist/client/api/embed.js +0 -8
- package/dist/client/api/get-model-info.d.ts +1 -1
- package/dist/client/api/index.d.ts +0 -1
- package/dist/client/api/index.js +0 -1
- package/dist/client/api/load-model.d.ts +37 -11
- package/dist/client/api/load-model.js +29 -117
- package/dist/client/api/logging-stream.d.ts +6 -3
- package/dist/client/api/logging-stream.js +6 -3
- package/dist/client/api/unload-model.js +5 -2
- package/dist/client/config-loader/config-utils.d.ts +5 -0
- package/dist/client/config-loader/config-utils.js +20 -0
- package/dist/client/config-loader/resolve-config.bare.d.ts +9 -0
- package/dist/client/config-loader/resolve-config.bare.js +87 -0
- package/dist/client/config-loader/resolve-config.expo.d.ts +11 -0
- package/dist/client/config-loader/resolve-config.expo.js +62 -0
- package/dist/client/config-loader/resolve-config.node.d.ts +9 -0
- package/dist/client/config-loader/resolve-config.node.js +118 -0
- package/dist/client/init-hooks.d.ts +17 -3
- package/dist/client/init-hooks.js +37 -18
- package/dist/client/logging-stream-registry.d.ts +1 -1
- package/dist/client/logging-stream-registry.js +14 -13
- package/dist/client/rpc/bare-client.d.ts +10 -14
- package/dist/client/rpc/bare-client.js +28 -2
- package/dist/client/rpc/bare-rpc-client.d.ts +1 -1
- package/dist/client/rpc/bare-rpc-client.js +16 -13
- package/dist/client/rpc/expo-rpc-client.d.ts +2 -2
- package/dist/client/rpc/expo-rpc-client.js +15 -12
- package/dist/client/rpc/node-rpc-client.d.ts +1 -1
- package/dist/client/rpc/node-rpc-client.js +10 -7
- package/dist/client/rpc/rpc-client.js +16 -15
- package/dist/examples/config/config-path.d.ts +8 -0
- package/dist/examples/config/config-path.js +13 -0
- package/dist/examples/config-reload.d.ts +2 -0
- package/dist/examples/config-reload.js +49 -0
- package/dist/examples/download-with-blind-relays.js +20 -20
- package/dist/examples/embed-hyperdrive.js +35 -3
- package/dist/examples/kv-cache-cleanup.js +1 -1
- package/dist/examples/kv-cache-custom-key.js +1 -1
- package/dist/examples/kv-cache-example.js +1 -1
- package/dist/examples/llamacpp-hyperdrive.js +1 -1
- package/dist/examples/llamacpp-sharded.js +1 -1
- package/dist/examples/logging-file-transport.d.ts +2 -0
- package/dist/examples/{llamacpp-file-logging.js → logging-file-transport.js} +3 -7
- package/dist/examples/logging-streaming.d.ts +2 -0
- package/dist/examples/logging-streaming.js +75 -0
- package/dist/examples/mcp-websearch.d.ts +13 -0
- package/dist/examples/mcp-websearch.js +176 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/logging/addon.d.ts +6 -0
- package/dist/logging/addon.js +59 -0
- package/dist/logging/base-logger.js +24 -14
- package/dist/logging/client-logger.d.ts +3 -0
- package/dist/logging/client-logger.js +13 -0
- package/dist/logging/index.d.ts +6 -1
- package/dist/logging/index.js +6 -1
- package/dist/logging/logger.d.ts +0 -2
- package/dist/logging/logger.js +0 -3
- package/dist/logging/namespaces.d.ts +11 -0
- package/dist/logging/namespaces.js +11 -0
- package/dist/logging/registry.d.ts +26 -0
- package/dist/logging/registry.js +36 -0
- package/dist/logging/server-logger.d.ts +3 -0
- package/dist/logging/server-logger.js +16 -0
- package/dist/logging/stream-logger.d.ts +1 -1
- package/dist/logging/stream-logger.js +6 -3
- package/dist/logging/types.d.ts +2 -0
- package/dist/models/hyperdrive/models.d.ts +789 -51
- package/dist/models/hyperdrive/models.js +979 -200
- package/dist/schemas/common.d.ts +86 -23
- package/dist/schemas/common.js +0 -3
- package/dist/schemas/download-asset.d.ts +5 -5
- package/dist/schemas/embed.d.ts +3 -3
- package/dist/schemas/embed.js +9 -2
- package/dist/schemas/get-model-info.d.ts +2 -2
- package/dist/schemas/index.d.ts +5 -1
- package/dist/schemas/index.js +5 -1
- package/dist/schemas/json-schema.d.ts +16 -0
- package/dist/schemas/json-schema.js +2 -0
- package/dist/schemas/llamacpp-config.d.ts +5 -4
- package/dist/schemas/llamacpp-config.js +7 -5
- package/dist/schemas/load-model.d.ts +931 -211
- package/dist/schemas/load-model.js +7 -1
- package/dist/schemas/logging-stream.d.ts +10 -3
- package/dist/schemas/logging-stream.js +4 -3
- package/dist/schemas/mcp-adapter.d.ts +47 -0
- package/dist/schemas/mcp-adapter.js +1 -0
- package/dist/schemas/model-src-utils.d.ts +8 -6
- package/dist/schemas/model-src-utils.js +8 -3
- package/dist/schemas/reload-config.d.ts +344 -0
- package/dist/schemas/reload-config.js +42 -0
- package/dist/schemas/sdk-config.d.ts +22 -0
- package/dist/schemas/sdk-config.js +33 -0
- package/dist/schemas/sdk-errors-client.d.ts +4 -0
- package/dist/schemas/sdk-errors-client.js +20 -0
- package/dist/schemas/sdk-errors-server.d.ts +3 -0
- package/dist/schemas/sdk-errors-server.js +15 -0
- package/dist/schemas/tools.d.ts +3 -0
- package/dist/schemas/translation-config.d.ts +81 -0
- package/dist/schemas/translation-config.js +3 -4
- package/dist/schemas/whispercpp-config.d.ts +9 -1
- package/dist/schemas/whispercpp-config.js +2 -1
- package/dist/server/bare/addons/llamacpp/create-model.js +13 -4
- package/dist/server/bare/addons/llamacpp/handlers/embed.d.ts +9 -1
- package/dist/server/bare/addons/llamacpp/handlers/embed.js +18 -4
- package/dist/server/bare/addons/llamacpp/kv-cache-utils.js +6 -4
- package/dist/server/bare/addons/load-model.js +10 -4
- package/dist/server/bare/addons/unload-model.js +6 -3
- package/dist/server/bare/addons/whispercpp/handlers/transcribe-stream.js +56 -37
- package/dist/server/bare/delegate-rpc-client.js +12 -10
- package/dist/server/bare/hyperswarm.js +7 -5
- package/dist/server/bare/rag-hyperdb/rag-manager.js +3 -1
- package/dist/server/bare/registry/config-registry.d.ts +13 -4
- package/dist/server/bare/registry/config-registry.js +42 -10
- package/dist/server/bare/registry/logging-stream-registry.d.ts +24 -7
- package/dist/server/bare/registry/logging-stream-registry.js +99 -20
- package/dist/server/bare/registry/model-registry.d.ts +3 -0
- package/dist/server/bare/registry/model-registry.js +9 -6
- package/dist/server/rpc/create-server.js +5 -3
- package/dist/server/rpc/handle-request.js +30 -16
- package/dist/server/rpc/handlers/cancelHandler.js +3 -1
- package/dist/server/rpc/handlers/completion-stream-delegated.js +4 -2
- package/dist/server/rpc/handlers/delete-cache.js +3 -1
- package/dist/server/rpc/handlers/download-asset.js +3 -1
- package/dist/server/rpc/handlers/embed.js +3 -1
- package/dist/server/rpc/handlers/index.d.ts +0 -1
- package/dist/server/rpc/handlers/index.js +0 -2
- package/dist/server/rpc/handlers/load-model/download-manager.js +4 -2
- package/dist/server/rpc/handlers/load-model/http.js +20 -18
- package/dist/server/rpc/handlers/load-model/hyperdrive.js +21 -19
- package/dist/server/rpc/handlers/load-model/resolve.js +7 -5
- package/dist/server/rpc/handlers/load-model-delegated.d.ts +2 -2
- package/dist/server/rpc/handlers/load-model-delegated.js +10 -8
- package/dist/server/rpc/handlers/load-model.js +55 -3
- package/dist/server/rpc/handlers/logging-stream.js +4 -4
- package/dist/server/rpc/handlers/provideHandler/connection.js +12 -10
- package/dist/server/rpc/handlers/provideHandler/handler.js +18 -16
- package/dist/server/rpc/handlers/provideHandler/proxy.js +8 -6
- package/dist/server/rpc/handlers/rag.js +3 -1
- package/dist/server/rpc/handlers/stopProvideHandler.js +3 -1
- package/dist/server/rpc/handlers/transcribe-stream.js +3 -1
- package/dist/server/rpc/handlers/translate.js +3 -1
- package/dist/server/rpc/handlers/unload-model.js +4 -2
- package/dist/server/utils/audio/decoder.d.ts +2 -1
- package/dist/server/utils/audio/decoder.js +48 -11
- package/dist/server/utils/cache.js +7 -5
- package/dist/server/utils/config-transform.d.ts +3 -0
- package/dist/server/utils/config-transform.js +21 -0
- package/dist/server/utils/index.d.ts +1 -0
- package/dist/server/utils/index.js +1 -0
- package/dist/server/worker.js +41 -16
- package/dist/utils/errors-client.d.ts +12 -0
- package/dist/utils/errors-client.js +20 -0
- package/dist/utils/errors-server.d.ts +9 -0
- package/dist/utils/errors-server.js +16 -0
- package/dist/utils/getProcessSafe.d.ts +7 -0
- package/dist/utils/getProcessSafe.js +17 -0
- package/dist/utils/mcp-adapter.d.ts +12 -0
- package/dist/utils/mcp-adapter.js +103 -0
- package/dist/utils/object.d.ts +2 -0
- package/dist/utils/object.js +3 -0
- package/dist/utils/runtime.d.ts +30 -0
- package/dist/utils/runtime.js +48 -0
- package/dist/utils/tool-helpers.d.ts +10 -2
- package/dist/utils/tool-helpers.js +24 -11
- package/package.json +46 -33
- package/dist/client/api/set-config.d.ts +0 -7
- package/dist/client/api/set-config.js +0 -20
- package/dist/client/config-manager.d.ts +0 -4
- package/dist/client/config-manager.js +0 -8
- package/dist/examples/llamacpp-file-logging.d.ts +0 -2
- package/dist/schemas/set-config.d.ts +0 -21
- package/dist/schemas/set-config.js +0 -14
- package/dist/server/rpc/handlers/set-config.d.ts +0 -3
- package/dist/server/rpc/handlers/set-config.js +0 -18
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { mapValues } from "./object.js";
|
|
2
|
+
const VALID_TYPES = [
|
|
3
|
+
"string",
|
|
4
|
+
"number",
|
|
5
|
+
"integer",
|
|
6
|
+
"boolean",
|
|
7
|
+
"object",
|
|
8
|
+
"array",
|
|
9
|
+
];
|
|
10
|
+
function isValidType(value) {
|
|
11
|
+
return typeof value === "string" && VALID_TYPES.includes(value);
|
|
12
|
+
}
|
|
13
|
+
function convertMcpToolToTool(mcpTool) {
|
|
14
|
+
const inputSchema = mcpTool.inputSchema;
|
|
15
|
+
const properties = inputSchema.properties ?? {};
|
|
16
|
+
const required = inputSchema.required ?? [];
|
|
17
|
+
const convertedProperties = mapValues(properties, (prop) => {
|
|
18
|
+
const { type, description, enum: enumVal } = prop;
|
|
19
|
+
return {
|
|
20
|
+
type: isValidType(type) ? type : "string",
|
|
21
|
+
...(description && { description }),
|
|
22
|
+
...(enumVal && { enum: enumVal }),
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
type: "function",
|
|
27
|
+
name: mcpTool.name,
|
|
28
|
+
description: mcpTool.description ?? "",
|
|
29
|
+
parameters: {
|
|
30
|
+
type: "object",
|
|
31
|
+
properties: convertedProperties,
|
|
32
|
+
required: required.length > 0 ? required : undefined,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function createMcpToolHandler(client, toolName) {
|
|
37
|
+
return async (args) => {
|
|
38
|
+
return client.callTool({ name: toolName, arguments: args });
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export async function getMcpToolsWithHandlers(clients) {
|
|
42
|
+
const allTools = [];
|
|
43
|
+
const handlers = new Map();
|
|
44
|
+
for (const { client, includeResources } of clients) {
|
|
45
|
+
const { tools: mcpTools } = await client.listTools();
|
|
46
|
+
for (const mcpTool of mcpTools) {
|
|
47
|
+
allTools.push(convertMcpToolToTool(mcpTool));
|
|
48
|
+
handlers.set(mcpTool.name, createMcpToolHandler(client, mcpTool.name));
|
|
49
|
+
}
|
|
50
|
+
if (includeResources !== false && client.listResources) {
|
|
51
|
+
allTools.push({
|
|
52
|
+
type: "function",
|
|
53
|
+
name: "list_resources",
|
|
54
|
+
description: "List available resources from MCP server",
|
|
55
|
+
parameters: {
|
|
56
|
+
type: "object",
|
|
57
|
+
properties: {},
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
handlers.set("list_resources", async () => {
|
|
61
|
+
if (!client.listResources) {
|
|
62
|
+
return { resources: [] };
|
|
63
|
+
}
|
|
64
|
+
const result = await client.listResources();
|
|
65
|
+
return {
|
|
66
|
+
type: "text",
|
|
67
|
+
text: JSON.stringify(result.resources, null, 2),
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
if (client.readResource) {
|
|
71
|
+
allTools.push({
|
|
72
|
+
type: "function",
|
|
73
|
+
name: "read_resource",
|
|
74
|
+
description: "Read content of a specific resource by URI",
|
|
75
|
+
parameters: {
|
|
76
|
+
type: "object",
|
|
77
|
+
properties: {
|
|
78
|
+
uri: {
|
|
79
|
+
type: "string",
|
|
80
|
+
description: "The URI of the resource to read",
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
required: ["uri"],
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
handlers.set("read_resource", async (args) => {
|
|
87
|
+
if (!client.readResource) {
|
|
88
|
+
return { error: "readResource not available" };
|
|
89
|
+
}
|
|
90
|
+
const result = await client.readResource({
|
|
91
|
+
uri: args["uri"],
|
|
92
|
+
});
|
|
93
|
+
return result.contents[0];
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return { tools: allTools, handlers };
|
|
99
|
+
}
|
|
100
|
+
export async function getMcpTools(clients) {
|
|
101
|
+
const { tools } = await getMcpToolsWithHandlers(clients);
|
|
102
|
+
return tools;
|
|
103
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime detection utilities
|
|
3
|
+
* Detects the current JavaScript runtime environment
|
|
4
|
+
*/
|
|
5
|
+
export type Runtime = "node" | "bare" | "expo" | "unknown";
|
|
6
|
+
/**
|
|
7
|
+
* Check if running in Bare runtime
|
|
8
|
+
*/
|
|
9
|
+
export declare const isBare: () => boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Check if running in React Native/Expo
|
|
12
|
+
*/
|
|
13
|
+
export declare const isReactNative: () => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Check if running in Node.js
|
|
16
|
+
*/
|
|
17
|
+
export declare const isNode: () => boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Detects the current runtime environment
|
|
20
|
+
*
|
|
21
|
+
* Detection order:
|
|
22
|
+
* 1. Bare - Check for global Bare object
|
|
23
|
+
* 2. React Native/Expo - Check navigator.product
|
|
24
|
+
* 3. Node.js - Check process.versions.node
|
|
25
|
+
* 4. Unknown - Fallback
|
|
26
|
+
*
|
|
27
|
+
* @returns The detected runtime type
|
|
28
|
+
*/
|
|
29
|
+
export declare const detectRuntime: () => Runtime;
|
|
30
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime detection utilities
|
|
3
|
+
* Detects the current JavaScript runtime environment
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Check if running in Bare runtime
|
|
7
|
+
*/
|
|
8
|
+
export const isBare = () => {
|
|
9
|
+
return typeof globalThis !== "undefined" && "Bare" in globalThis;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Check if running in React Native/Expo
|
|
13
|
+
*/
|
|
14
|
+
export const isReactNative = () => {
|
|
15
|
+
return (typeof navigator !== "undefined" &&
|
|
16
|
+
navigator.product === "ReactNative");
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Check if running in Node.js
|
|
20
|
+
*/
|
|
21
|
+
export const isNode = () => {
|
|
22
|
+
return (typeof process !== "undefined" &&
|
|
23
|
+
process.versions !== undefined &&
|
|
24
|
+
process.versions.node !== undefined);
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Detects the current runtime environment
|
|
28
|
+
*
|
|
29
|
+
* Detection order:
|
|
30
|
+
* 1. Bare - Check for global Bare object
|
|
31
|
+
* 2. React Native/Expo - Check navigator.product
|
|
32
|
+
* 3. Node.js - Check process.versions.node
|
|
33
|
+
* 4. Unknown - Fallback
|
|
34
|
+
*
|
|
35
|
+
* @returns The detected runtime type
|
|
36
|
+
*/
|
|
37
|
+
export const detectRuntime = () => {
|
|
38
|
+
if (isBare()) {
|
|
39
|
+
return "bare";
|
|
40
|
+
}
|
|
41
|
+
if (isReactNative()) {
|
|
42
|
+
return "expo";
|
|
43
|
+
}
|
|
44
|
+
if (isNode()) {
|
|
45
|
+
return "node";
|
|
46
|
+
}
|
|
47
|
+
return "unknown";
|
|
48
|
+
};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { z } from "zod";
|
|
2
|
-
import { type Tool } from "../schemas/tools";
|
|
2
|
+
import { type Tool, type ToolCall, type ToolCallWithCall } from "../schemas/tools";
|
|
3
3
|
type ZodObjectType = z.ZodObject<z.ZodRawShape>;
|
|
4
|
+
export type ToolHandler = (args: Record<string, unknown>) => Promise<unknown>;
|
|
4
5
|
export type ToolInput<T extends ZodObjectType = ZodObjectType> = {
|
|
5
6
|
name: string;
|
|
6
7
|
description: string;
|
|
7
8
|
parameters: T;
|
|
9
|
+
handler?: ToolHandler;
|
|
8
10
|
};
|
|
9
11
|
export declare function convertToolInput(input: ToolInput): Tool;
|
|
10
12
|
export declare function convertTools(inputs: ToolInput[]): Tool[];
|
|
@@ -12,6 +14,12 @@ export declare function convertTools(inputs: ToolInput[]): Tool[];
|
|
|
12
14
|
* Validates and converts tools from either ToolInput (with Zod schemas) or full Tool format.
|
|
13
15
|
* Returns validated Tool[] array.
|
|
14
16
|
*/
|
|
15
|
-
export
|
|
17
|
+
export type ToolHandlerMap = Map<string, ToolHandler>;
|
|
18
|
+
export type ValidateToolsResult = {
|
|
19
|
+
tools: Tool[];
|
|
20
|
+
handlers: ToolHandlerMap;
|
|
21
|
+
};
|
|
22
|
+
export declare function validateTools(tools: Tool[] | ToolInput[]): ValidateToolsResult;
|
|
23
|
+
export declare function attachHandlersToToolCalls(toolCalls: ToolCall[], handlers: ToolHandlerMap): ToolCallWithCall[];
|
|
16
24
|
export {};
|
|
17
25
|
//# sourceMappingURL=tool-helpers.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toolSchema } from "../schemas/tools.js";
|
|
1
|
+
import { toolSchema, } from "../schemas/tools.js";
|
|
2
2
|
import { InvalidToolsArrayError, InvalidToolSchemaError, } from "./errors-client.js";
|
|
3
3
|
function zodTypeToJsonSchemaType(type) {
|
|
4
4
|
switch (type) {
|
|
@@ -66,22 +66,17 @@ export function convertToolInput(input) {
|
|
|
66
66
|
export function convertTools(inputs) {
|
|
67
67
|
return inputs.map(convertToolInput);
|
|
68
68
|
}
|
|
69
|
-
/**
|
|
70
|
-
* Validates and converts tools from either ToolInput (with Zod schemas) or full Tool format.
|
|
71
|
-
* Returns validated Tool[] array.
|
|
72
|
-
*/
|
|
73
69
|
export function validateTools(tools) {
|
|
74
70
|
if (tools.length === 0) {
|
|
75
|
-
return [];
|
|
71
|
+
return { tools: [], handlers: new Map() };
|
|
76
72
|
}
|
|
77
73
|
const firstTool = tools[0];
|
|
78
74
|
if (!firstTool) {
|
|
79
75
|
throw new InvalidToolsArrayError();
|
|
80
76
|
}
|
|
81
|
-
|
|
77
|
+
const handlers = new Map();
|
|
82
78
|
const parseResult = toolSchema.safeParse(firstTool);
|
|
83
79
|
if (parseResult.success) {
|
|
84
|
-
// It's already in full Tool format - validate all tools
|
|
85
80
|
const validatedTools = [];
|
|
86
81
|
for (const tool of tools) {
|
|
87
82
|
const result = toolSchema.safeParse(tool);
|
|
@@ -90,10 +85,28 @@ export function validateTools(tools) {
|
|
|
90
85
|
}
|
|
91
86
|
validatedTools.push(result.data);
|
|
92
87
|
}
|
|
93
|
-
return validatedTools;
|
|
88
|
+
return { tools: validatedTools, handlers };
|
|
94
89
|
}
|
|
95
90
|
else {
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
const toolInputs = tools;
|
|
92
|
+
const convertedTools = convertTools(toolInputs);
|
|
93
|
+
for (const toolInput of toolInputs) {
|
|
94
|
+
if (toolInput.handler) {
|
|
95
|
+
handlers.set(toolInput.name, toolInput.handler);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return { tools: convertedTools, handlers };
|
|
98
99
|
}
|
|
99
100
|
}
|
|
101
|
+
export function attachHandlersToToolCalls(toolCalls, handlers) {
|
|
102
|
+
return toolCalls.map((toolCall) => {
|
|
103
|
+
const handler = handlers.get(toolCall.name);
|
|
104
|
+
if (handler) {
|
|
105
|
+
return {
|
|
106
|
+
...toolCall,
|
|
107
|
+
invoke: async () => await handler(toolCall.arguments),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return toolCall;
|
|
111
|
+
});
|
|
112
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qvac/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -50,20 +50,25 @@
|
|
|
50
50
|
"docs_api:website": "typedoc --out ./docs/api/website --entryPoints index.ts --entryPointStrategy expand --readme none",
|
|
51
51
|
"docs_api:markdown": "typedoc --plugin typedoc-plugin-markdown --out ./docs/api/markdown --entryPoints index.ts --entryPointStrategy expand --readme none && sed -i '1,4d' ./docs/api/markdown/README.md",
|
|
52
52
|
"docs_api": "bun run docs_api:website && bun run docs_api:markdown",
|
|
53
|
-
"
|
|
53
|
+
"check-models": "node ./scripts/update-models.js --check",
|
|
54
|
+
"check-models:hook": "node ./scripts/update-models.js --check --non-blocking",
|
|
55
|
+
"update-models": "node ./scripts/update-models.js",
|
|
56
|
+
"changelog:generate": "node ./scripts/changelog-generate.cjs && prettier --write changelog",
|
|
57
|
+
"docs:gen-pages": "remark \"docs/*.mdx\" --output .docs-build",
|
|
58
|
+
"docs:gen-api": "typedoc --options docs/typedoc.jsonc"
|
|
54
59
|
},
|
|
55
60
|
"dependencies": {
|
|
56
|
-
"@qvac/decoder-audio": "^0.
|
|
57
|
-
"@qvac/dl-filesystem": "^0.1.
|
|
58
|
-
"@qvac/embed-llamacpp": "^0.
|
|
61
|
+
"@qvac/decoder-audio": "^0.3.0",
|
|
62
|
+
"@qvac/dl-filesystem": "^0.1.2",
|
|
63
|
+
"@qvac/embed-llamacpp": "^0.7.5",
|
|
59
64
|
"@qvac/error": "^0.1.0",
|
|
60
65
|
"@qvac/langdetect-text": "^0.1.0",
|
|
61
|
-
"@qvac/llm-llamacpp": "^0.
|
|
66
|
+
"@qvac/llm-llamacpp": "^0.5.6",
|
|
62
67
|
"@qvac/logging": "^0.1.0",
|
|
63
68
|
"@qvac/rag": "^0.2.1",
|
|
64
|
-
"@qvac/transcription-whispercpp": "0.
|
|
65
|
-
"@qvac/translation-nmtcpp": "0.1.
|
|
66
|
-
"@qvac/tts-onnx": "^0.2.
|
|
69
|
+
"@qvac/transcription-whispercpp": "^0.3.8",
|
|
70
|
+
"@qvac/translation-nmtcpp": "^0.1.13",
|
|
71
|
+
"@qvac/tts-onnx": "^0.2.8",
|
|
67
72
|
"fast-safe-stringify": "2.1.1",
|
|
68
73
|
"zod": "^4.0.17"
|
|
69
74
|
},
|
|
@@ -71,55 +76,65 @@
|
|
|
71
76
|
"@eslint/js": "^9.33.0",
|
|
72
77
|
"@expo/config-plugins": "^54.0.1",
|
|
73
78
|
"@lancedb/lancedb": "^0.21.3",
|
|
79
|
+
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
74
80
|
"@sqliteai/sqlite-wasm": "3.50.4-sync.0.8.30-vector.0.9.23",
|
|
75
81
|
"@types/node": "^24.2.1",
|
|
76
|
-
"bare-pack": "^1.
|
|
77
|
-
"bare-readline": "^1.
|
|
82
|
+
"bare-pack": "^1.5.1",
|
|
83
|
+
"bare-readline": "^1.2.0",
|
|
78
84
|
"chromadb": "^3.0.14",
|
|
79
|
-
"expo": "^54.0.0",
|
|
80
85
|
"eslint": "^9.33.0",
|
|
81
86
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
82
87
|
"eslint-plugin-import": "^2.30.0",
|
|
83
88
|
"eslint-plugin-react": "^7.37.5",
|
|
89
|
+
"expo": "^54.0.0",
|
|
90
|
+
"expo-file-system": "^19.0.15",
|
|
84
91
|
"globals": "^16.3.0",
|
|
85
92
|
"husky": "^9.1.7",
|
|
86
93
|
"hyperdb": "^4.16.1",
|
|
87
94
|
"prettier": "^3.6.2",
|
|
95
|
+
"react-native-bare-kit": "^0.11.4",
|
|
96
|
+
"remark-cli": "^12.0.1",
|
|
97
|
+
"remark-code-import": "^1.2.0",
|
|
98
|
+
"remark-frontmatter": "^5.0.0",
|
|
99
|
+
"remark-mdx": "^3.1.1",
|
|
88
100
|
"typedoc": "^0.28.11",
|
|
101
|
+
"typedoc-plugin-frontmatter": "^1.3.1",
|
|
89
102
|
"typedoc-plugin-markdown": "^4.8.1",
|
|
90
103
|
"typescript": "^5.9.2",
|
|
91
|
-
"typescript-eslint": "^8.39.0"
|
|
92
|
-
"expo-file-system": "^19.0.15",
|
|
93
|
-
"react-native-bare-kit": "^0.9.3"
|
|
104
|
+
"typescript-eslint": "^8.39.0"
|
|
94
105
|
},
|
|
95
106
|
"peerDependencies": {
|
|
107
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
96
108
|
"bare-abort-controller": "^1.0.0",
|
|
97
|
-
"bare-buffer": "^3.
|
|
98
|
-
"bare-crypto": "^1.
|
|
99
|
-
"bare-dns": "^2.1.
|
|
109
|
+
"bare-buffer": "^3.4.2",
|
|
110
|
+
"bare-crypto": "^1.11.2",
|
|
111
|
+
"bare-dns": "^2.1.4",
|
|
100
112
|
"bare-fetch": "^2.5.1",
|
|
101
|
-
"bare-fs": "^4.
|
|
102
|
-
"bare-https": "^2.1.1",
|
|
113
|
+
"bare-fs": "^4.5.2",
|
|
103
114
|
"bare-http1": "^4.1.6",
|
|
104
|
-
"bare-
|
|
105
|
-
"bare-
|
|
106
|
-
"bare-
|
|
115
|
+
"bare-https": "^2.1.1",
|
|
116
|
+
"bare-link": "^2.1.10",
|
|
117
|
+
"bare-net": "^2.2.0",
|
|
118
|
+
"bare-os": "^3.6.2",
|
|
107
119
|
"bare-path": "^3.0.0",
|
|
108
|
-
"bare-process": "^4.2.
|
|
109
|
-
"bare-rpc": "^0.
|
|
110
|
-
"bare-runtime": "^1.24.
|
|
111
|
-
"bare-stream": "^2.
|
|
112
|
-
"bare-subprocess": "^5.
|
|
120
|
+
"bare-process": "^4.2.2",
|
|
121
|
+
"bare-rpc": "^1.0.0",
|
|
122
|
+
"bare-runtime": "^1.24.2",
|
|
123
|
+
"bare-stream": "^2.7.0",
|
|
124
|
+
"bare-subprocess": "^5.2.1",
|
|
113
125
|
"corestore": "^7.4.5",
|
|
114
126
|
"events": "^3.3.0",
|
|
127
|
+
"expo-file-system": "^19.0.15",
|
|
115
128
|
"hyperdb": "^4.19.0",
|
|
116
129
|
"hyperdrive": "^13.0.1",
|
|
117
130
|
"hyperswarm": "^4.12.1",
|
|
118
|
-
"expo-file-system": "^19.0.15",
|
|
119
131
|
"llm-splitter": "~0.2.0",
|
|
120
|
-
"react-native-bare-kit": "^0.
|
|
132
|
+
"react-native-bare-kit": "^0.11.4"
|
|
121
133
|
},
|
|
122
134
|
"peerDependenciesMeta": {
|
|
135
|
+
"@modelcontextprotocol/sdk": {
|
|
136
|
+
"optional": true
|
|
137
|
+
},
|
|
123
138
|
"expo-file-system": {
|
|
124
139
|
"optional": true
|
|
125
140
|
},
|
|
@@ -127,7 +142,5 @@
|
|
|
127
142
|
"optional": true
|
|
128
143
|
}
|
|
129
144
|
},
|
|
130
|
-
"patchedDependencies": {
|
|
131
|
-
"bare-rpc@0.2.11": "patches/bare-rpc@0.2.11.patch"
|
|
132
|
-
}
|
|
145
|
+
"patchedDependencies": {}
|
|
133
146
|
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import {} from "../../schemas/index.js";
|
|
2
|
-
import { send } from "../rpc/rpc-client.js";
|
|
3
|
-
import { setCachedConfig } from "../config-manager.js";
|
|
4
|
-
import { InvalidResponseError, SetConfigFailedError, } from "../../utils/errors-client.js";
|
|
5
|
-
export const setConfig = async (config) => {
|
|
6
|
-
// Cache config client-side for automatic replay on worker restart
|
|
7
|
-
setCachedConfig(config);
|
|
8
|
-
const request = {
|
|
9
|
-
type: "setConfig",
|
|
10
|
-
config,
|
|
11
|
-
};
|
|
12
|
-
const response = await send(request);
|
|
13
|
-
if (response.type !== "setConfig") {
|
|
14
|
-
throw new InvalidResponseError("setConfig");
|
|
15
|
-
}
|
|
16
|
-
if (!response.success) {
|
|
17
|
-
throw new SetConfigFailedError(response.error);
|
|
18
|
-
}
|
|
19
|
-
return response;
|
|
20
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const sdkConfigSchema: z.ZodObject<{
|
|
3
|
-
cacheDirectory: z.ZodOptional<z.ZodString>;
|
|
4
|
-
swarmRelays: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
5
|
-
}, z.core.$strip>;
|
|
6
|
-
export declare const setConfigRequestSchema: z.ZodObject<{
|
|
7
|
-
type: z.ZodLiteral<"setConfig">;
|
|
8
|
-
config: z.ZodObject<{
|
|
9
|
-
cacheDirectory: z.ZodOptional<z.ZodString>;
|
|
10
|
-
swarmRelays: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
11
|
-
}, z.core.$strip>;
|
|
12
|
-
}, z.core.$strip>;
|
|
13
|
-
export declare const setConfigResponseSchema: z.ZodObject<{
|
|
14
|
-
type: z.ZodLiteral<"setConfig">;
|
|
15
|
-
success: z.ZodBoolean;
|
|
16
|
-
error: z.ZodOptional<z.ZodString>;
|
|
17
|
-
}, z.core.$strip>;
|
|
18
|
-
export type SDKConfig = z.infer<typeof sdkConfigSchema>;
|
|
19
|
-
export type SetConfigRequest = z.infer<typeof setConfigRequestSchema>;
|
|
20
|
-
export type SetConfigResponse = z.infer<typeof setConfigResponseSchema>;
|
|
21
|
-
//# sourceMappingURL=set-config.d.ts.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export const sdkConfigSchema = z.object({
|
|
3
|
-
cacheDirectory: z.string().optional(),
|
|
4
|
-
swarmRelays: z.array(z.string()).optional(),
|
|
5
|
-
});
|
|
6
|
-
export const setConfigRequestSchema = z.object({
|
|
7
|
-
type: z.literal("setConfig"),
|
|
8
|
-
config: sdkConfigSchema,
|
|
9
|
-
});
|
|
10
|
-
export const setConfigResponseSchema = z.object({
|
|
11
|
-
type: z.literal("setConfig"),
|
|
12
|
-
success: z.boolean(),
|
|
13
|
-
error: z.string().optional(),
|
|
14
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { setSDKConfig } from "../../bare/registry/config-registry.js";
|
|
2
|
-
export const handleSetConfig = (request) => {
|
|
3
|
-
try {
|
|
4
|
-
setSDKConfig(request.config);
|
|
5
|
-
return {
|
|
6
|
-
type: "setConfig",
|
|
7
|
-
success: true,
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
catch (error) {
|
|
11
|
-
console.error("Error setting config:", error);
|
|
12
|
-
return {
|
|
13
|
-
type: "setConfig",
|
|
14
|
-
success: false,
|
|
15
|
-
error: error instanceof Error ? error.message : "Unknown error",
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
};
|