mirror of
https://github.com/koush/scrypted.git
synced 2026-02-03 06:03:27 +00:00
sdk: use mcp for tool call
This commit is contained in:
4
sdk/package-lock.json
generated
4
sdk/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/sdk",
|
||||
"version": "0.5.32",
|
||||
"version": "0.5.33",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/sdk",
|
||||
"version": "0.5.32",
|
||||
"version": "0.5.33",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@babel/preset-typescript": "^7.27.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scrypted/sdk",
|
||||
"version": "0.5.32",
|
||||
"version": "0.5.33",
|
||||
"description": "",
|
||||
"main": "dist/src/index.js",
|
||||
"exports": {
|
||||
|
||||
1
sdk/polyfill/level.js
Normal file
1
sdk/polyfill/level.js
Normal file
@@ -0,0 +1 @@
|
||||
const level = __non_webpack_require__('level'); module.exports = level;
|
||||
4
sdk/types/package-lock.json
generated
4
sdk/types/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/types",
|
||||
"version": "0.5.30",
|
||||
"version": "0.5.31",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/types",
|
||||
"version": "0.5.30",
|
||||
"version": "0.5.31",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"openai": "^5.3.0"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scrypted/types",
|
||||
"version": "0.5.30",
|
||||
"version": "0.5.31",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"author": "",
|
||||
|
||||
@@ -449,6 +449,11 @@ class VideoStreamOptions(TypedDict):
|
||||
quality: float
|
||||
width: float
|
||||
|
||||
class ContentBlock(TypedDict):
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class MediaStreamDestination(TypedDict):
|
||||
|
||||
pass
|
||||
@@ -491,6 +496,14 @@ class AudioVolumes(TypedDict):
|
||||
pass
|
||||
|
||||
|
||||
class CallToolResult(TypedDict):
|
||||
"""https://modelcontextprotocol.io/specification/2025-06-18/schema#blobresourcecontents"""
|
||||
|
||||
_meta: Any
|
||||
content: list[ContentBlock]
|
||||
isError: bool
|
||||
structuredContent: Any
|
||||
|
||||
class ChatCompletionCapabilities(TypedDict):
|
||||
|
||||
audio: bool
|
||||
@@ -1074,7 +1087,7 @@ class TamperState(TypedDict):
|
||||
pass
|
||||
|
||||
|
||||
TYPES_VERSION = "0.5.30"
|
||||
TYPES_VERSION = "0.5.31"
|
||||
|
||||
|
||||
class AirPurifier:
|
||||
@@ -1329,7 +1342,7 @@ class LauncherApplication:
|
||||
|
||||
class LLMTools:
|
||||
|
||||
async def callLLMTool(self, name: str, parameters: Mapping[str, Any]) -> str:
|
||||
async def callLLMTool(self, name: str, parameters: Mapping[str, Any]) -> CallToolResult:
|
||||
pass
|
||||
|
||||
async def getLLMTools(self) -> list[ChatCompletionTool]:
|
||||
|
||||
@@ -79,6 +79,7 @@ ${fs.readFileSync(path.join(__dirname, './types.input.ts'))}
|
||||
`;
|
||||
|
||||
fs.writeFileSync(path.join(__dirname, '../gen/index.ts'), contents);
|
||||
fs.copyFileSync(path.join(__dirname, './mcp.ts'), path.join(__dirname, '../gen/mcp.ts'));
|
||||
|
||||
const discoveredTypes = new Set<string>();
|
||||
discoveredTypes.add('EventDetails');
|
||||
|
||||
74
sdk/types/src/mcp.ts
Normal file
74
sdk/types/src/mcp.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
export interface BlobResourceContents {
|
||||
_meta?: { [key: string]: unknown };
|
||||
blob: string;
|
||||
mimeType?: string;
|
||||
uri: string;
|
||||
}
|
||||
|
||||
export interface Annotations {
|
||||
audience?: "user" | "assistant";
|
||||
lastModified?: string;
|
||||
priority?: number;
|
||||
}
|
||||
|
||||
export interface TextResourceContents {
|
||||
_meta?: { [key: string]: unknown };
|
||||
mimeType?: string;
|
||||
text: string;
|
||||
uri: string;
|
||||
}
|
||||
|
||||
export interface EmbeddedResource {
|
||||
_meta?: { [key: string]: unknown };
|
||||
annotations?: Annotations;
|
||||
resource: TextResourceContents | BlobResourceContents;
|
||||
type: "resource";
|
||||
}
|
||||
|
||||
export interface ResourceLink {
|
||||
_meta?: { [key: string]: unknown };
|
||||
annotations?: Annotations;
|
||||
description?: string;
|
||||
mimeType?: string;
|
||||
name: string;
|
||||
size?: number;
|
||||
title?: string;
|
||||
type: "resource_link";
|
||||
uri: string;
|
||||
}
|
||||
export interface AudioContent {
|
||||
_meta?: { [key: string]: unknown };
|
||||
annotations?: Annotations;
|
||||
data: string;
|
||||
mimeType: string;
|
||||
type: "audio";
|
||||
}
|
||||
|
||||
export interface ImageContent {
|
||||
_meta?: { [key: string]: unknown };
|
||||
annotations?: Annotations;
|
||||
data: string;
|
||||
mimeType: string;
|
||||
type: "image";
|
||||
}
|
||||
|
||||
export interface TextContent {
|
||||
_meta?: { [key: string]: unknown };
|
||||
annotations?: Annotations;
|
||||
text: string;
|
||||
type: "text";
|
||||
}
|
||||
|
||||
export type ContentBlock = TextContent | ImageContent | AudioContent| ResourceLink | EmbeddedResource;
|
||||
|
||||
|
||||
/**
|
||||
* https://modelcontextprotocol.io/specification/2025-06-18/schema#blobresourcecontents
|
||||
*/
|
||||
export interface CallToolResult {
|
||||
_meta?: { [key: string]: unknown };
|
||||
content: ContentBlock[];
|
||||
isError?: boolean;
|
||||
structuredContent?: { [key: string]: unknown };
|
||||
[key: string]: unknown;
|
||||
}
|
||||
@@ -3,7 +3,9 @@ import type { Socket as NodeNetSocket } from 'net';
|
||||
import type { ChatCompletionStreamParams } from 'openai/lib/ChatCompletionStream';
|
||||
import type { ChatCompletionChunk, ChatCompletionCreateParamsNonStreaming, ChatCompletionMessageParam, ChatCompletion as ChatCompletionResponse, ChatCompletionTool } from 'openai/resources';
|
||||
import type { Worker as NodeWorker } from 'worker_threads';
|
||||
import { CallToolResult } from './mcp';
|
||||
export type { ChatCompletionChunk, ChatCompletionCreateParamsNonStreaming, ChatCompletionCreateParamsStreaming, ChatCompletionMessageParam, ChatCompletion as ChatCompletionResponse, ChatCompletionTool } from 'openai/resources';
|
||||
export type * from './mcp';
|
||||
|
||||
export type ScryptedNativeId = string | undefined;
|
||||
|
||||
@@ -1066,9 +1068,10 @@ export interface PanTiltZoomCommand {
|
||||
preset?: string;
|
||||
}
|
||||
|
||||
|
||||
export interface LLMTools {
|
||||
getLLMTools(): Promise<ChatCompletionTool[]>;
|
||||
callLLMTool(name: string, parameters: Record<string, any>): Promise<string>;
|
||||
callLLMTool(name: string, parameters: Record<string, any>): Promise<CallToolResult>;
|
||||
}
|
||||
|
||||
export interface ChatCompletionCapabilities {
|
||||
|
||||
Reference in New Issue
Block a user