@kernl-sdk/protocol 0.2.8 → 0.3.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +9 -0
- package/README.md +48 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/realtime/events.d.ts +313 -0
- package/dist/realtime/events.d.ts.map +1 -0
- package/dist/realtime/index.d.ts +4 -0
- package/dist/realtime/index.d.ts.map +1 -0
- package/dist/realtime/index.js +3 -0
- package/dist/realtime/model.d.ts +99 -0
- package/dist/realtime/model.d.ts.map +1 -0
- package/dist/realtime/types.d.ts +229 -0
- package/dist/realtime/types.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/realtime/events.ts +397 -0
- package/src/realtime/index.ts +3 -0
- package/src/realtime/model.ts +121 -0
- package/src/realtime/types.ts +276 -0
- package/.turbo/turbo-check-types.log +0 -4
- package/dist/codec.d.ts +0 -22
- package/dist/codec.d.ts.map +0 -1
- package/dist/embedding-model/embedding-model.d.ts +0 -57
- package/dist/embedding-model/embedding-model.d.ts.map +0 -1
- package/dist/embedding-model/embedding-model.js +0 -6
- package/dist/language-model/content.d.ts +0 -141
- package/dist/language-model/content.d.ts.map +0 -1
- package/dist/language-model/language-model.d.ts +0 -114
- package/dist/language-model/language-model.d.ts.map +0 -1
- package/dist/language-model/settings.d.ts +0 -99
- package/dist/language-model/settings.d.ts.map +0 -1
- package/dist/language-model/settings.js +0 -1
- package/dist/provider/metadata.d.ts +0 -21
- package/dist/provider/metadata.d.ts.map +0 -1
- package/dist/provider/metadata.js +0 -1
- /package/dist/{codec.js → realtime/events.js} +0 -0
- /package/dist/{language-model/content.js → realtime/model.js} +0 -0
- /package/dist/{language-model/language-model.js → realtime/types.js} +0 -0
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Language Model Protocol
|
|
3
|
-
*
|
|
4
|
-
* Defines the standard interface for language model providers in Kernl.
|
|
5
|
-
*/
|
|
6
|
-
export type LanguageModel = {
|
|
7
|
-
/**
|
|
8
|
-
* The language model must specify which language model interface version it implements.
|
|
9
|
-
*/
|
|
10
|
-
readonly spec: "1.0";
|
|
11
|
-
/**
|
|
12
|
-
* Provider ID.
|
|
13
|
-
*/
|
|
14
|
-
readonly provider: string;
|
|
15
|
-
/**
|
|
16
|
-
* Provider-specific model ID.
|
|
17
|
-
*/
|
|
18
|
-
readonly modelId: string;
|
|
19
|
-
/**
|
|
20
|
-
* Supported URL patterns by media type for the provider.
|
|
21
|
-
*
|
|
22
|
-
* The keys are media type patterns or full media types (e.g. `*\/*` for everything, `audio/*`, `video/*`, or `application/pdf`).
|
|
23
|
-
* and the values are arrays of regular expressions that match the URL paths.
|
|
24
|
-
*
|
|
25
|
-
* The matching should be against lower-case URLs.
|
|
26
|
-
*
|
|
27
|
-
* Matched URLs are supported natively by the model and are not downloaded.
|
|
28
|
-
*
|
|
29
|
-
* @returns A map of supported URL patterns by media type (as a promise or a plain object).
|
|
30
|
-
*/
|
|
31
|
-
supportedUrls: PromiseLike<Record<string, RegExp[]>> | Record<string, RegExp[]>;
|
|
32
|
-
/**
|
|
33
|
-
* Generates a language model output (non-streaming).
|
|
34
|
-
*
|
|
35
|
-
* Naming: "do" prefix to prevent accidental direct usage of the method
|
|
36
|
-
* by the user.
|
|
37
|
-
*/
|
|
38
|
-
doGenerate(options: LanguageModelV3CallOptions): PromiseLike<{
|
|
39
|
-
/**
|
|
40
|
-
* Ordered content that the model has generated.
|
|
41
|
-
*/
|
|
42
|
-
content: Array<LanguageModelV3Content>;
|
|
43
|
-
/**
|
|
44
|
-
* Finish reason.
|
|
45
|
-
*/
|
|
46
|
-
finishReason: LanguageModelV3FinishReason;
|
|
47
|
-
/**
|
|
48
|
-
* Usage information.
|
|
49
|
-
*/
|
|
50
|
-
usage: LanguageModelV3Usage;
|
|
51
|
-
/**
|
|
52
|
-
* Additional provider-specific metadata. They are passed through
|
|
53
|
-
* from the provider to the AI SDK and enable provider-specific
|
|
54
|
-
* results that can be fully encapsulated in the provider.
|
|
55
|
-
*/
|
|
56
|
-
providerMetadata?: SharedV3ProviderMetadata;
|
|
57
|
-
/**
|
|
58
|
-
* Optional request information for telemetry and debugging purposes.
|
|
59
|
-
*/
|
|
60
|
-
request?: {
|
|
61
|
-
/**
|
|
62
|
-
* Request HTTP body that was sent to the provider API.
|
|
63
|
-
*/
|
|
64
|
-
body?: unknown;
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* Optional response information for telemetry and debugging purposes.
|
|
68
|
-
*/
|
|
69
|
-
response?: LanguageModelV3ResponseMetadata & {
|
|
70
|
-
/**
|
|
71
|
-
* Response headers.
|
|
72
|
-
*/
|
|
73
|
-
headers?: SharedV3Headers;
|
|
74
|
-
/**
|
|
75
|
-
* Response HTTP body.
|
|
76
|
-
*/
|
|
77
|
-
body?: unknown;
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Warnings for the call, e.g. unsupported settings.
|
|
81
|
-
*/
|
|
82
|
-
warnings: Array<LanguageModelV3CallWarning>;
|
|
83
|
-
}>;
|
|
84
|
-
/**
|
|
85
|
-
* Generates a language model output (streaming).
|
|
86
|
-
*
|
|
87
|
-
* Naming: "do" prefix to prevent accidental direct usage of the method
|
|
88
|
-
* by the user.
|
|
89
|
-
*
|
|
90
|
-
* @return A stream of higher-level language model output parts.
|
|
91
|
-
*/
|
|
92
|
-
doStream(options: LanguageModelV3CallOptions): PromiseLike<{
|
|
93
|
-
stream: ReadableStream<LanguageModelV3StreamPart>;
|
|
94
|
-
/**
|
|
95
|
-
* Optional request information for telemetry and debugging purposes.
|
|
96
|
-
*/
|
|
97
|
-
request?: {
|
|
98
|
-
/**
|
|
99
|
-
* Request HTTP body that was sent to the provider API.
|
|
100
|
-
*/
|
|
101
|
-
body?: unknown;
|
|
102
|
-
};
|
|
103
|
-
/**
|
|
104
|
-
* Optional response data.
|
|
105
|
-
*/
|
|
106
|
-
response?: {
|
|
107
|
-
/**
|
|
108
|
-
* Response headers.
|
|
109
|
-
*/
|
|
110
|
-
headers?: SharedV3Headers;
|
|
111
|
-
};
|
|
112
|
-
}>;
|
|
113
|
-
};
|
|
114
|
-
//# sourceMappingURL=language-model.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"language-model.d.ts","sourceRoot":"","sources":["../../src/language-model/language-model.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAErB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB;;;;;;;;;;;OAWG;IACH,aAAa,EACT,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,GACrC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAE7B;;;;;OAKG;IACH,UAAU,CAAC,OAAO,EAAE,0BAA0B,GAAG,WAAW,CAAC;QAC3D;;WAEG;QACH,OAAO,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAEvC;;WAEG;QACH,YAAY,EAAE,2BAA2B,CAAC;QAE1C;;WAEG;QACH,KAAK,EAAE,oBAAoB,CAAC;QAE5B;;;;WAIG;QACH,gBAAgB,CAAC,EAAE,wBAAwB,CAAC;QAE5C;;WAEG;QACH,OAAO,CAAC,EAAE;YACR;;eAEG;YACH,IAAI,CAAC,EAAE,OAAO,CAAC;SAChB,CAAC;QAEF;;WAEG;QACH,QAAQ,CAAC,EAAE,+BAA+B,GAAG;YAC3C;;eAEG;YACH,OAAO,CAAC,EAAE,eAAe,CAAC;YAE1B;;eAEG;YACH,IAAI,CAAC,EAAE,OAAO,CAAC;SAChB,CAAC;QAEF;;WAEG;QACH,QAAQ,EAAE,KAAK,CAAC,0BAA0B,CAAC,CAAC;KAC7C,CAAC,CAAC;IAEH;;;;;;;OAOG;IACH,QAAQ,CAAC,OAAO,EAAE,0BAA0B,GAAG,WAAW,CAAC;QACzD,MAAM,EAAE,cAAc,CAAC,yBAAyB,CAAC,CAAC;QAElD;;WAEG;QACH,OAAO,CAAC,EAAE;YACR;;eAEG;YACH,IAAI,CAAC,EAAE,OAAO,CAAC;SAChB,CAAC;QAEF;;WAEG;QACH,QAAQ,CAAC,EAAE;YACT;;eAEG;YACH,OAAO,CAAC,EAAE,eAAe,CAAC;SAC3B,CAAC;KACH,CAAC,CAAC;CACJ,CAAC"}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Settings to use when calling an LLM.
|
|
3
|
-
*
|
|
4
|
-
* This class holds optional model configuration parameters (e.g. temperature,
|
|
5
|
-
* topP, penalties, truncation, etc.).
|
|
6
|
-
*
|
|
7
|
-
* Not all models/providers support all of these parameters, so please check the API documentation
|
|
8
|
-
* for the specific model and provider you are using.
|
|
9
|
-
*/
|
|
10
|
-
export interface LanguageModelSettings {
|
|
11
|
-
/**
|
|
12
|
-
* The temperature to use when calling the model.
|
|
13
|
-
*/
|
|
14
|
-
temperature?: number;
|
|
15
|
-
/**
|
|
16
|
-
* The topP to use when calling the model.
|
|
17
|
-
*/
|
|
18
|
-
topP?: number;
|
|
19
|
-
/**
|
|
20
|
-
* The frequency penalty to use when calling the model.
|
|
21
|
-
*/
|
|
22
|
-
frequencyPenalty?: number;
|
|
23
|
-
/**
|
|
24
|
-
* The presence penalty to use when calling the model.
|
|
25
|
-
*/
|
|
26
|
-
presencePenalty?: number;
|
|
27
|
-
/**
|
|
28
|
-
* The tool choice to use when calling the model.
|
|
29
|
-
*/
|
|
30
|
-
toolChoice?: ModelSettingsToolChoice;
|
|
31
|
-
/**
|
|
32
|
-
* Whether to use parallel tool calls when calling the model.
|
|
33
|
-
* Defaults to false if not provided.
|
|
34
|
-
*/
|
|
35
|
-
parallelToolCalls?: boolean;
|
|
36
|
-
/**
|
|
37
|
-
* The truncation strategy to use when calling the model.
|
|
38
|
-
*/
|
|
39
|
-
truncation?: "auto" | "disabled";
|
|
40
|
-
/**
|
|
41
|
-
* The maximum number of output tokens to generate.
|
|
42
|
-
*/
|
|
43
|
-
maxTokens?: number;
|
|
44
|
-
/**
|
|
45
|
-
* Whether to store the generated model response for later retrieval.
|
|
46
|
-
* Defaults to true if not provided.
|
|
47
|
-
*/
|
|
48
|
-
store?: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* The reasoning settings to use when calling the model.
|
|
51
|
-
*/
|
|
52
|
-
reasoning?: ModelSettingsReasoning;
|
|
53
|
-
/**
|
|
54
|
-
* The text settings to use when calling the model.
|
|
55
|
-
*/
|
|
56
|
-
text?: ModelSettingsText;
|
|
57
|
-
/**
|
|
58
|
-
* Additional provider specific settings to be passed directly to the model
|
|
59
|
-
* request.
|
|
60
|
-
*/
|
|
61
|
-
providerData?: Record<string, any>;
|
|
62
|
-
}
|
|
63
|
-
export type ModelSettingsToolChoice = "auto" | "required" | "none";
|
|
64
|
-
/**
|
|
65
|
-
* Constrains effort on reasoning for [reasoning models](https://platform.openai.com/docs/guides/reasoning).
|
|
66
|
-
*
|
|
67
|
-
* Supported for providers:
|
|
68
|
-
*
|
|
69
|
-
* - OpenAI
|
|
70
|
-
* - ... ?
|
|
71
|
-
*/
|
|
72
|
-
export type ModelSettingsReasoningEffort = "minimal" | "low" | "medium" | "high" | null;
|
|
73
|
-
/**
|
|
74
|
-
* Configuration options for model reasoning
|
|
75
|
-
*/
|
|
76
|
-
export type ModelSettingsReasoning = {
|
|
77
|
-
/**
|
|
78
|
-
* Constrains effort on reasoning for [reasoning models](https://platform.openai.com/docs/guides/reasoning).
|
|
79
|
-
*/
|
|
80
|
-
effort?: ModelSettingsReasoningEffort | null;
|
|
81
|
-
/**
|
|
82
|
-
* A summary of the reasoning performed by the model.
|
|
83
|
-
* This can be useful for debugging and understanding the model's reasoning process.
|
|
84
|
-
* One of `auto`, `concise`, or `detailed`.
|
|
85
|
-
*/
|
|
86
|
-
summary?: "auto" | "concise" | "detailed" | null;
|
|
87
|
-
};
|
|
88
|
-
export interface ModelSettingsText {
|
|
89
|
-
/**
|
|
90
|
-
* Constrains the verbosity of the model's response.
|
|
91
|
-
*
|
|
92
|
-
* Supported for providers:
|
|
93
|
-
*
|
|
94
|
-
* - OpenAI
|
|
95
|
-
* - ... ?
|
|
96
|
-
*/
|
|
97
|
-
verbosity?: "low" | "medium" | "high" | null;
|
|
98
|
-
}
|
|
99
|
-
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/language-model/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,UAAU,CAAC,EAAE,uBAAuB,CAAC;IAErC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAEjC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,SAAS,CAAC,EAAE,sBAAsB,CAAC;IAEnC;;OAEG;IACH,IAAI,CAAC,EAAE,iBAAiB,CAAC;IAEzB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACpC;AAED,MAAM,MAAM,uBAAuB,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,CAAC;AAEnE;;;;;;;GAOG;AACH,MAAM,MAAM,4BAA4B,GACpC,SAAS,GACT,KAAK,GACL,QAAQ,GACR,MAAM,GACN,IAAI,CAAC;AAET;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC;;OAEG;IACH,MAAM,CAAC,EAAE,4BAA4B,GAAG,IAAI,CAAC;IAE7C;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,IAAI,CAAC;CAClD,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,IAAI,CAAC;CAC9C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { JSONObject } from "../json.js";
|
|
2
|
-
/**
|
|
3
|
-
* Additional provider-specific metadata.
|
|
4
|
-
*
|
|
5
|
-
* They are passed through to the provider from the AI SDK
|
|
6
|
-
* and enable provider-specific functionality
|
|
7
|
-
* that can be fully encapsulated in the provider.
|
|
8
|
-
*
|
|
9
|
-
* The outer record is keyed by the provider name, and the inner
|
|
10
|
-
* record is keyed by the provider-specific metadata key.
|
|
11
|
-
*
|
|
12
|
-
* ```ts
|
|
13
|
-
* {
|
|
14
|
-
* "anthropic": {
|
|
15
|
-
* "cacheControl": { "type": "ephemeral" }
|
|
16
|
-
* }
|
|
17
|
-
* }
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export type SharedProviderMetadata = Record<string, JSONObject>;
|
|
21
|
-
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/provider/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|