@openllmsh/sdk 2.10.18-alpha.0 → 2.10.18-alpha.2
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/dist/openapi/openapi.json +75 -0
- package/dist/protocol/config.d.ts +6 -0
- package/dist/protocol/config.js +2 -0
- package/dist/protocol/daemon.d.ts +4 -0
- package/dist/protocol/daemon.js +2 -0
- package/dist/protocol/fusion-chain.d.ts +15 -0
- package/dist/protocol/fusion-chain.js +39 -0
- package/package.json +1 -1
|
@@ -14553,6 +14553,31 @@
|
|
|
14553
14553
|
"items": {
|
|
14554
14554
|
"type": "string"
|
|
14555
14555
|
}
|
|
14556
|
+
},
|
|
14557
|
+
"fusion": {
|
|
14558
|
+
"anyOf": [
|
|
14559
|
+
{
|
|
14560
|
+
"type": "boolean"
|
|
14561
|
+
},
|
|
14562
|
+
{
|
|
14563
|
+
"type": "null"
|
|
14564
|
+
}
|
|
14565
|
+
]
|
|
14566
|
+
},
|
|
14567
|
+
"cutoff_tokens": {
|
|
14568
|
+
"anyOf": [
|
|
14569
|
+
{
|
|
14570
|
+
"type": "array",
|
|
14571
|
+
"items": {
|
|
14572
|
+
"type": "integer",
|
|
14573
|
+
"maximum": 9007199254740991,
|
|
14574
|
+
"exclusiveMinimum": 0
|
|
14575
|
+
}
|
|
14576
|
+
},
|
|
14577
|
+
{
|
|
14578
|
+
"type": "null"
|
|
14579
|
+
}
|
|
14580
|
+
]
|
|
14556
14581
|
}
|
|
14557
14582
|
},
|
|
14558
14583
|
"required": [
|
|
@@ -14993,6 +15018,31 @@
|
|
|
14993
15018
|
"items": {
|
|
14994
15019
|
"type": "string"
|
|
14995
15020
|
}
|
|
15021
|
+
},
|
|
15022
|
+
"fusion": {
|
|
15023
|
+
"anyOf": [
|
|
15024
|
+
{
|
|
15025
|
+
"type": "boolean"
|
|
15026
|
+
},
|
|
15027
|
+
{
|
|
15028
|
+
"type": "null"
|
|
15029
|
+
}
|
|
15030
|
+
]
|
|
15031
|
+
},
|
|
15032
|
+
"cutoff_tokens": {
|
|
15033
|
+
"anyOf": [
|
|
15034
|
+
{
|
|
15035
|
+
"type": "array",
|
|
15036
|
+
"items": {
|
|
15037
|
+
"type": "integer",
|
|
15038
|
+
"maximum": 9007199254740991,
|
|
15039
|
+
"exclusiveMinimum": 0
|
|
15040
|
+
}
|
|
15041
|
+
},
|
|
15042
|
+
{
|
|
15043
|
+
"type": "null"
|
|
15044
|
+
}
|
|
15045
|
+
]
|
|
14996
15046
|
}
|
|
14997
15047
|
},
|
|
14998
15048
|
"required": [
|
|
@@ -72784,6 +72834,31 @@
|
|
|
72784
72834
|
"items": {
|
|
72785
72835
|
"type": "string"
|
|
72786
72836
|
}
|
|
72837
|
+
},
|
|
72838
|
+
"fusion": {
|
|
72839
|
+
"anyOf": [
|
|
72840
|
+
{
|
|
72841
|
+
"type": "boolean"
|
|
72842
|
+
},
|
|
72843
|
+
{
|
|
72844
|
+
"type": "null"
|
|
72845
|
+
}
|
|
72846
|
+
]
|
|
72847
|
+
},
|
|
72848
|
+
"cutoff_tokens": {
|
|
72849
|
+
"anyOf": [
|
|
72850
|
+
{
|
|
72851
|
+
"type": "array",
|
|
72852
|
+
"items": {
|
|
72853
|
+
"type": "integer",
|
|
72854
|
+
"maximum": 9007199254740991,
|
|
72855
|
+
"exclusiveMinimum": 0
|
|
72856
|
+
}
|
|
72857
|
+
},
|
|
72858
|
+
{
|
|
72859
|
+
"type": "null"
|
|
72860
|
+
}
|
|
72861
|
+
]
|
|
72787
72862
|
}
|
|
72788
72863
|
},
|
|
72789
72864
|
"required": [
|
|
@@ -41,6 +41,8 @@ export type TCustomApiModelKind = S.Schema.Type<typeof CustomApiModelKind>;
|
|
|
41
41
|
export declare const FallbackGroup: S.Struct<{
|
|
42
42
|
readonly name: S.String;
|
|
43
43
|
readonly models: S.$Array<S.String>;
|
|
44
|
+
readonly fusion: S.optional<S.Boolean>;
|
|
45
|
+
readonly cutoff_tokens: S.optional<S.$Array<S.Int>>;
|
|
44
46
|
}>;
|
|
45
47
|
export type TFallbackGroup = S.Schema.Type<typeof FallbackGroup>;
|
|
46
48
|
/** LiteLLM-style `[trigger, alternateModels]` rows (`*` = default alternates). */
|
|
@@ -216,6 +218,8 @@ export declare const UserConfig: S.Struct<{
|
|
|
216
218
|
readonly fallback_groups: S.$Array<S.Struct<{
|
|
217
219
|
readonly name: S.String;
|
|
218
220
|
readonly models: S.$Array<S.String>;
|
|
221
|
+
readonly fusion: S.optional<S.Boolean>;
|
|
222
|
+
readonly cutoff_tokens: S.optional<S.$Array<S.Int>>;
|
|
219
223
|
}>>;
|
|
220
224
|
readonly model_fallback_bindings: S.optional<S.$Array<S.Tuple<readonly [S.String, S.$Array<S.String>]>>>;
|
|
221
225
|
readonly extra: S.Struct<{
|
|
@@ -493,6 +497,8 @@ export declare const UserConfigPatch: S.Struct<{
|
|
|
493
497
|
readonly fallback_groups: S.optional<S.$Array<S.Struct<{
|
|
494
498
|
readonly name: S.String;
|
|
495
499
|
readonly models: S.$Array<S.String>;
|
|
500
|
+
readonly fusion: S.optional<S.Boolean>;
|
|
501
|
+
readonly cutoff_tokens: S.optional<S.$Array<S.Int>>;
|
|
496
502
|
}>>>;
|
|
497
503
|
readonly model_fallback_bindings: S.optional<S.NullOr<S.$Array<S.Tuple<readonly [S.String, S.$Array<S.String>]>>>>;
|
|
498
504
|
readonly extra: S.optional<S.$Record<S.String, S.Unknown>>;
|
package/dist/protocol/config.js
CHANGED
|
@@ -47,6 +47,8 @@ export const CustomApiModelKind = S.Literals([
|
|
|
47
47
|
export const FallbackGroup = S.Struct({
|
|
48
48
|
name: S.String,
|
|
49
49
|
models: S.Array(S.String),
|
|
50
|
+
fusion: S.optional(S.Boolean),
|
|
51
|
+
cutoff_tokens: S.optional(S.Array(S.Int.check(S.isGreaterThan(0)))),
|
|
50
52
|
});
|
|
51
53
|
/** LiteLLM-style `[trigger, alternateModels]` rows (`*` = default alternates). */
|
|
52
54
|
export const ModelFallbackBinding = S.Tuple([S.String, S.Array(S.String)]);
|
|
@@ -292,6 +292,8 @@ export declare const DaemonBootstrap: S.Struct<{
|
|
|
292
292
|
readonly user_fallback_groups: S.$Array<S.Struct<{
|
|
293
293
|
readonly name: S.String;
|
|
294
294
|
readonly models: S.$Array<S.String>;
|
|
295
|
+
readonly fusion: S.optional<S.Boolean>;
|
|
296
|
+
readonly cutoff_tokens: S.optional<S.$Array<S.Int>>;
|
|
295
297
|
}>>;
|
|
296
298
|
readonly user_model_fallback_bindings: S.$Array<S.Tuple<readonly [S.String, S.$Array<S.String>]>>;
|
|
297
299
|
readonly model_settings: S.optional<S.$Record<S.String, S.Struct<{
|
|
@@ -1927,6 +1929,8 @@ export declare const DaemonPlanResponse: S.Struct<{
|
|
|
1927
1929
|
readonly origin: S.String;
|
|
1928
1930
|
/** Context-overflow strategy for this plan. Absent means hop-to-larger-context. */
|
|
1929
1931
|
readonly context_overflow_strategy: S.optional<S.Literals<readonly ["hop_to_larger_context", "compact_in_place"]>>;
|
|
1932
|
+
/** This plan depends on the request's estimated input tokens. */
|
|
1933
|
+
readonly fusion: S.optional<S.Boolean>;
|
|
1930
1934
|
/** Reservation for a capped one-hop plan, included in the signed payload. */
|
|
1931
1935
|
readonly hold_nonce: S.optional<S.String>;
|
|
1932
1936
|
/** Largest output the hold allows (held plans only; signed). The daemon
|
package/dist/protocol/daemon.js
CHANGED
|
@@ -1214,6 +1214,8 @@ export const DaemonPlanResponse = S.Struct({
|
|
|
1214
1214
|
origin: S.String,
|
|
1215
1215
|
/** Context-overflow strategy for this plan. Absent means hop-to-larger-context. */
|
|
1216
1216
|
context_overflow_strategy: S.optional(ContextOverflowStrategy),
|
|
1217
|
+
/** This plan depends on the request's estimated input tokens. */
|
|
1218
|
+
fusion: S.optional(S.Boolean),
|
|
1217
1219
|
/** Reservation for a capped one-hop plan, included in the signed payload. */
|
|
1218
1220
|
hold_nonce: S.optional(HoldNonce),
|
|
1219
1221
|
/** Largest output the hold allows (held plans only; signed). The daemon
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** A fusion step may omit its cutoff to use its full input window. */
|
|
2
|
+
export type TFusionEntry = {
|
|
3
|
+
readonly cutoff_tokens?: number;
|
|
4
|
+
};
|
|
5
|
+
export type TFusionWindowOf<T> = (entry: T) => number;
|
|
6
|
+
/**
|
|
7
|
+
* Stable ascending hand-off order: a step's cutoff (its window when unset,
|
|
8
|
+
* never above it), so a 1M model handing off at 50k leads a 250k model.
|
|
9
|
+
* Equal hand-offs retain their original order.
|
|
10
|
+
*/
|
|
11
|
+
export declare function sortChainForFusion<T extends TFusionEntry>(entries: readonly T[], windowOf: TFusionWindowOf<T>): T[];
|
|
12
|
+
/** Clamp cutoffs after sorting. The last step's stored cutoff is left untouched. */
|
|
13
|
+
export declare function normalizeFusionCutoffs<T extends TFusionEntry>(entries: readonly T[], windowOf: TFusionWindowOf<T>): T[];
|
|
14
|
+
/** Choose a starting step; an empty chain has no step and returns -1. */
|
|
15
|
+
export declare function fusionStartIndex<T extends TFusionEntry>(entries: readonly T[], windowOf: TFusionWindowOf<T>, inputTokens: number): number;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable ascending hand-off order: a step's cutoff (its window when unset,
|
|
3
|
+
* never above it), so a 1M model handing off at 50k leads a 250k model.
|
|
4
|
+
* Equal hand-offs retain their original order.
|
|
5
|
+
*/
|
|
6
|
+
export function sortChainForFusion(entries, windowOf) {
|
|
7
|
+
return entries
|
|
8
|
+
.map((entry, index) => {
|
|
9
|
+
const window = windowOf(entry);
|
|
10
|
+
const handOff = Math.min(window, entry.cutoff_tokens ?? window);
|
|
11
|
+
return { entry, index, handOff };
|
|
12
|
+
})
|
|
13
|
+
.sort((a, b) => a.handOff - b.handOff || a.index - b.index)
|
|
14
|
+
.map(({ entry }) => entry);
|
|
15
|
+
}
|
|
16
|
+
/** Clamp cutoffs after sorting. The last step's stored cutoff is left untouched. */
|
|
17
|
+
export function normalizeFusionCutoffs(entries, windowOf) {
|
|
18
|
+
let previous = 0;
|
|
19
|
+
return entries.map((entry, index) => {
|
|
20
|
+
if (index === entries.length - 1)
|
|
21
|
+
return entry;
|
|
22
|
+
const window = windowOf(entry);
|
|
23
|
+
const cutoff = Math.min(window, Math.max(previous, entry.cutoff_tokens ?? window));
|
|
24
|
+
previous = cutoff;
|
|
25
|
+
return { ...entry, cutoff_tokens: cutoff };
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/** Choose a starting step; an empty chain has no step and returns -1. */
|
|
29
|
+
export function fusionStartIndex(entries, windowOf, inputTokens) {
|
|
30
|
+
if (entries.length === 0)
|
|
31
|
+
return -1;
|
|
32
|
+
for (let index = 0; index < entries.length - 1; index++) {
|
|
33
|
+
const entry = entries[index];
|
|
34
|
+
if (entry !== undefined &&
|
|
35
|
+
inputTokens < (entry.cutoff_tokens ?? windowOf(entry)))
|
|
36
|
+
return index;
|
|
37
|
+
}
|
|
38
|
+
return entries.length - 1;
|
|
39
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openllmsh/sdk",
|
|
3
|
-
"version": "2.10.18-alpha.
|
|
3
|
+
"version": "2.10.18-alpha.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The OpenLLM SDK: typed API contracts, wire-format adapters, the device tunnel, client-side vault crypto, the OpenAPI spec and MCP tools.",
|
|
6
6
|
"keywords": [
|