@independo/inderun-web 0.4.0-rc.2 → 0.5.0-rc.1
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/core/generated/inderun-api.d.ts +2 -2
- package/dist/core/generated/inderun-api.d.ts.map +1 -1
- package/dist/core/provider.d.ts +7 -130
- package/dist/core/provider.d.ts.map +1 -1
- package/dist/core/route-planner.d.ts +5 -5
- package/dist/core/route-planner.d.ts.map +1 -1
- package/dist/core/route-planner.js +16 -29
- package/dist/providers/onnx/runtime.d.ts +2 -2
- package/dist/providers/onnx/runtime.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/core/generated/inderun-api.ts +2 -2
- package/src/core/provider.ts +12 -136
- package/src/core/route-planner.ts +21 -36
- package/src/providers/onnx/runtime.ts +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { TaskRequest, TaskResult } from "@independo/inderun-contracts";
|
|
2
|
-
import type { StreamRun
|
|
1
|
+
import type { TaskRequest, TaskResult, ProviderCapabilitySnapshot } from "@independo/inderun-contracts";
|
|
2
|
+
import type { StreamRun } from "../provider.js";
|
|
3
3
|
export interface IndeRunApi {
|
|
4
4
|
/**
|
|
5
5
|
* Executes a Mode 1 (request/response) text-to-text task against a routed provider and returns the completed TaskResult. Routing (local vs. cloud, which provider) is decided internally from TaskRequest.constraints/preferences — the caller does not select a provider directly. Rejects the request up front on validation failure; otherwise throws an IndeRunException (carrying an IndeRunError) if no eligible provider is found or every attempted provider fails. There is no partial or streaming result in this mode: run() either resolves with a complete TaskResult or throws.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inderun-api.d.ts","sourceRoot":"","sources":["../../../src/core/generated/inderun-api.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"inderun-api.d.ts","sourceRoot":"","sources":["../../../src/core/generated/inderun-api.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AACxG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,GAAG,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC/C;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IACjD;;OAEG;IACH,iBAAiB,IAAI,OAAO,CAAC,0BAA0B,EAAE,CAAC,CAAC;CAC5D"}
|
package/dist/core/provider.d.ts
CHANGED
|
@@ -1,136 +1,13 @@
|
|
|
1
|
-
import type { StreamEvent, StreamRunHandle, TaskRequest, TaskResult } from "@independo/inderun-contracts";
|
|
1
|
+
import type { ProviderDescriptor, ProviderDynamicCapabilities, StreamEvent, StreamRunHandle, TaskRequest, TaskResult } from "@independo/inderun-contracts";
|
|
2
2
|
import type { HostServices } from "./host.js";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* A provider's static declaration, live capability check, and the pair as
|
|
5
|
+
* `checkCapabilities()` returns it. All three are schema-backed contracts
|
|
6
|
+
* (`contracts/schemas/provider-*.schema.json`), shared with the Swift and Kotlin
|
|
7
|
+
* SDKs and with the route planner, so they are re-exported here rather than
|
|
8
|
+
* declared.
|
|
6
9
|
*/
|
|
7
|
-
export
|
|
8
|
-
/**
|
|
9
|
-
* Unique identifier of the provider (e.g., 'openai', 'apple-foundation-models').
|
|
10
|
-
*/
|
|
11
|
-
id: string;
|
|
12
|
-
/**
|
|
13
|
-
* Execution target type: 'local' (on-device), 'edge', or 'cloud'.
|
|
14
|
-
*/
|
|
15
|
-
type: "local" | "edge" | "cloud";
|
|
16
|
-
/**
|
|
17
|
-
* The model this provider instance is bound to, when it can name one. A provider
|
|
18
|
-
* instance bound to one model is a *target* that model profiles list by `id`.
|
|
19
|
-
* Cloud providers report the model id they send; platform-managed models report
|
|
20
|
-
* an opaque platform alias rather than a guessed weight name. Absent means the
|
|
21
|
-
* provider cannot name its model.
|
|
22
|
-
*/
|
|
23
|
-
model?: string;
|
|
24
|
-
/**
|
|
25
|
-
* Connection transport layer protocol.
|
|
26
|
-
*/
|
|
27
|
-
transport: "in_process" | "system_service" | "http" | "sse" | "realtime";
|
|
28
|
-
/**
|
|
29
|
-
* Optional streaming style, if token or chunk streaming is supported.
|
|
30
|
-
*/
|
|
31
|
-
streamingStyle?: "tokens" | "chunks" | "snapshots";
|
|
32
|
-
/**
|
|
33
|
-
* Flags representing the features and modes supported by this provider.
|
|
34
|
-
*/
|
|
35
|
-
supports: {
|
|
36
|
-
/** Whether the provider supports Mode 1 run (request/response). */
|
|
37
|
-
run: boolean;
|
|
38
|
-
/** Whether the provider supports Mode 2 stream. */
|
|
39
|
-
streaming: boolean;
|
|
40
|
-
/** Whether the provider supports Mode 3 realtime session. */
|
|
41
|
-
realtime: boolean;
|
|
42
|
-
/** Whether the provider supports tool calling definition. */
|
|
43
|
-
tools: boolean;
|
|
44
|
-
/** Whether the provider outputs reasoning events alongside contents. */
|
|
45
|
-
reasoningEvents: boolean;
|
|
46
|
-
/** Whether the provider supports structured outputs (JSON schema constraints). */
|
|
47
|
-
structuredOutput: boolean;
|
|
48
|
-
/** Whether the provider supports multimodal inputs (images, audio, etc.). */
|
|
49
|
-
multimodal: boolean;
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Cancellation capabilities support:
|
|
53
|
-
* - 'hard': fully stops processing and interrupts remote operations.
|
|
54
|
-
* - 'soft': stops reading the stream locally, but the remote execution continues.
|
|
55
|
-
* - 'none': cancellation is unsupported.
|
|
56
|
-
*/
|
|
57
|
-
cancel: "hard" | "soft" | "none";
|
|
58
|
-
/**
|
|
59
|
-
* List of supported task kinds (e.g., 'text_to_text', 'embeddings').
|
|
60
|
-
*/
|
|
61
|
-
tasks: string[];
|
|
62
|
-
/**
|
|
63
|
-
* Optional input/output resource boundaries.
|
|
64
|
-
*/
|
|
65
|
-
limits?: {
|
|
66
|
-
maxInputTokens?: number;
|
|
67
|
-
maxOutputTokens?: number;
|
|
68
|
-
maxImageBytes?: number;
|
|
69
|
-
maxAudioSeconds?: number;
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* Privacy settings regarding data egress.
|
|
73
|
-
*/
|
|
74
|
-
privacy?: {
|
|
75
|
-
/** Set to true if the model input leaves the host device. */
|
|
76
|
-
dataLeavesDevice: boolean;
|
|
77
|
-
/** Geographic regions where the cloud service executes. */
|
|
78
|
-
regions?: string[];
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Dynamic capability snapshot evaluated at runtime.
|
|
83
|
-
*/
|
|
84
|
-
export interface ProviderDynamicCapabilities {
|
|
85
|
-
/**
|
|
86
|
-
* Whether the provider is available and functional on the host device now.
|
|
87
|
-
*/
|
|
88
|
-
available: boolean;
|
|
89
|
-
/**
|
|
90
|
-
* Detail message if availability check fails.
|
|
91
|
-
*/
|
|
92
|
-
reason?: string;
|
|
93
|
-
/**
|
|
94
|
-
* Whether the provider can stream (Mode 2) right now on this host. Leave
|
|
95
|
-
* undefined to inherit the static `descriptor.supports.streaming` value —
|
|
96
|
-
* only set it when the runtime environment can take streaming away from a
|
|
97
|
-
* provider that otherwise declares it (e.g. the host has no chunked HTTP
|
|
98
|
-
* capability).
|
|
99
|
-
*/
|
|
100
|
-
streamingAvailable?: boolean;
|
|
101
|
-
/**
|
|
102
|
-
* Detail message used when `streamingAvailable` is false. Omit to let the
|
|
103
|
-
* route planner synthesize a generic message.
|
|
104
|
-
*/
|
|
105
|
-
streamingUnavailableReason?: string;
|
|
106
|
-
/**
|
|
107
|
-
* Whether cancellation is honored right now on this host. Leave undefined to
|
|
108
|
-
* inherit the static `descriptor.cancel` value (anything other than `"none"`
|
|
109
|
-
* means available).
|
|
110
|
-
*/
|
|
111
|
-
cancellationAvailable?: boolean;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* One registered provider's identity, fixed capabilities, and live availability,
|
|
115
|
-
* as of the moment checkCapabilities() was called.
|
|
116
|
-
*/
|
|
117
|
-
export interface ProviderCapabilitySnapshot {
|
|
118
|
-
/**
|
|
119
|
-
* Stable identifier for this provider, matching the value used in routing
|
|
120
|
-
* preferences/constraints.
|
|
121
|
-
*/
|
|
122
|
-
providerId: string;
|
|
123
|
-
/**
|
|
124
|
-
* The provider's static, unchanging capability declaration (supported modes,
|
|
125
|
-
* privacy posture, model info).
|
|
126
|
-
*/
|
|
127
|
-
descriptor: ProviderDescriptor;
|
|
128
|
-
/**
|
|
129
|
-
* The provider's current dynamic availability (e.g. whether it's reachable/loaded
|
|
130
|
-
* right now) — this is the part that can change between calls.
|
|
131
|
-
*/
|
|
132
|
-
capabilities: ProviderDynamicCapabilities;
|
|
133
|
-
}
|
|
10
|
+
export type { ProviderCapabilitySnapshot, ProviderDescriptor, ProviderDynamicCapabilities } from "@independo/inderun-contracts";
|
|
134
11
|
/**
|
|
135
12
|
* Execution context passed to provider run commands.
|
|
136
13
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/core/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EACf,WAAW,EACX,UAAU,EACX,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/core/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,2BAA2B,EAC3B,WAAW,EACX,eAAe,EACf,WAAW,EACX,UAAU,EACX,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MA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aAAa,CAAC,mBAAmB,CAAC,CAAC;CAC3F;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,eAAe,CAAC;IACxB,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IACnC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RoutePlan as SharedPlannerRoutePlan, RoutePlannerInput as SharedPlannerInput, TaskRequest } from "@independo/inderun-contracts";
|
|
2
2
|
import type { HostServices } from "./host.js";
|
|
3
|
-
import type { ProviderAdapter } from "./provider.js";
|
|
3
|
+
import type { ProviderAdapter, ProviderDescriptor, ProviderDynamicCapabilities } from "./provider.js";
|
|
4
4
|
export type { SharedPlannerInput, SharedPlannerRoutePlan };
|
|
5
5
|
/**
|
|
6
6
|
* Interaction mode the caller is requesting a route for. Passed to the shared
|
|
@@ -39,13 +39,13 @@ export interface RoutePlanner {
|
|
|
39
39
|
planRoute(input: SharedPlannerInput): Promise<PlannerOutcome>;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
* A provider paired with
|
|
43
|
-
* planner consumes.
|
|
42
|
+
* A provider paired with its descriptor and the dynamic capabilities the shared
|
|
43
|
+
* route planner consumes (already folded by {@link toSharedPlannerCapabilities}).
|
|
44
44
|
*/
|
|
45
45
|
export interface ProviderRuntimeSnapshot {
|
|
46
46
|
provider: ProviderAdapter;
|
|
47
|
-
descriptor:
|
|
48
|
-
capabilities:
|
|
47
|
+
descriptor: ProviderDescriptor;
|
|
48
|
+
capabilities: ProviderDynamicCapabilities;
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* {@link RoutePlanner} backed by the Rust route core compiled to WASM. The
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-planner.d.ts","sourceRoot":"","sources":["../../src/core/route-planner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,E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WAAW,uBAAuB;IACtC,QAAQ,EAAE,eAAe,CAAC;IAC1B,UAAU,EAAE,kBAAkB,CAAC;IAC/B,YAAY,EAAE,2BAA2B,CAAC;CAC3C;AAED;;;;;;;;;;GAUG;AACH,qBAAa,gBAAiB,YAAW,YAAY;IACnD,OAAO,CAAC,aAAa,CAAC,CAAsC;IAC5D,OAAO,CAAC,WAAW,CAAC,CAAqD;IACzE,OAAO,CAAC,SAAS,CAAS;IAEpB,SAAS,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC;YAoBrD,UAAU;YAOV,YAAY;IA0B1B,OAAO,CAAC,QAAQ;CAOjB;AAED;;;;;;;GAOG;AACH,wBAAsB,+BAA+B,CACnD,iBAAiB,EAAE,eAAe,EAAE,EACpC,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAapC;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,WAAW,EACpB,SAAS,EAAE,uBAAuB,EAAE,EACpC,aAAa,EAAE,OAAO,EACtB,eAAe,GAAE,eAAuB,EACxC,YAAY,CAAC,EAAE,kBAAkB,CAAC,cAAc,CAAC,GAChD,kBAAkB,CAsBpB"}
|
|
@@ -84,7 +84,7 @@ export async function collectProviderRuntimeSnapshots(registryProviders, hostSer
|
|
|
84
84
|
const capabilities = await provider.capabilities(hostServices);
|
|
85
85
|
return {
|
|
86
86
|
provider,
|
|
87
|
-
descriptor
|
|
87
|
+
descriptor,
|
|
88
88
|
capabilities: toSharedPlannerCapabilities(capabilities, descriptor, provider)
|
|
89
89
|
};
|
|
90
90
|
}));
|
|
@@ -98,9 +98,7 @@ export function buildSharedPlannerInput(request, snapshots, networkOnline, inter
|
|
|
98
98
|
const constraints = request.constraints ?? {};
|
|
99
99
|
const preferences = request.preferences ?? {};
|
|
100
100
|
return {
|
|
101
|
-
task:
|
|
102
|
-
kind: request.task.kind
|
|
103
|
-
},
|
|
101
|
+
task: plannerTask(request),
|
|
104
102
|
interactionMode,
|
|
105
103
|
constraints: {
|
|
106
104
|
privacy: constraints.privacy ?? "cloud_allowed",
|
|
@@ -118,25 +116,15 @@ export function buildSharedPlannerInput(request, snapshots, networkOnline, inter
|
|
|
118
116
|
}))
|
|
119
117
|
};
|
|
120
118
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
tasks: descriptor.tasks,
|
|
131
|
-
...(descriptor.privacy
|
|
132
|
-
? {
|
|
133
|
-
privacy: {
|
|
134
|
-
dataLeavesDevice: descriptor.privacy.dataLeavesDevice,
|
|
135
|
-
...(descriptor.privacy.regions ? { regions: descriptor.privacy.regions } : {})
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
: {})
|
|
139
|
-
};
|
|
119
|
+
/**
|
|
120
|
+
* Projects the request's task onto the requirements the planner can check. A text
|
|
121
|
+
* request carries text input; the speech requirements arrive with the speech request
|
|
122
|
+
* shape (#245).
|
|
123
|
+
*/
|
|
124
|
+
function plannerTask(request) {
|
|
125
|
+
return request.task.kind === "text_to_text"
|
|
126
|
+
? { kind: request.task.kind, inputs: ["text"] }
|
|
127
|
+
: { kind: request.task.kind };
|
|
140
128
|
}
|
|
141
129
|
/**
|
|
142
130
|
* Projects the dynamic capability snapshot for the planner.
|
|
@@ -155,13 +143,12 @@ function toSharedPlannerCapabilities(capabilities, descriptor, provider) {
|
|
|
155
143
|
(declaresStreaming && !implementsStream
|
|
156
144
|
? `Provider '${descriptor.id}' declares streaming but does not implement stream().`
|
|
157
145
|
: undefined);
|
|
146
|
+
// Spread rather than pick, so a field added to the schema reaches the planner
|
|
147
|
+
// without touching this function.
|
|
148
|
+
const { streamingUnavailableReason: _declaredReason, ...rest } = capabilities;
|
|
158
149
|
return {
|
|
159
|
-
|
|
160
|
-
...(capabilities.reason ? { reason: capabilities.reason } : {}),
|
|
150
|
+
...rest,
|
|
161
151
|
streamingAvailable,
|
|
162
|
-
...(!streamingAvailable && streamingUnavailableReason ? { streamingUnavailableReason } : {})
|
|
163
|
-
...(capabilities.cancellationAvailable !== undefined
|
|
164
|
-
? { cancellationAvailable: capabilities.cancellationAvailable }
|
|
165
|
-
: {})
|
|
152
|
+
...(!streamingAvailable && streamingUnavailableReason ? { streamingUnavailableReason } : {})
|
|
166
153
|
};
|
|
167
154
|
}
|
|
@@ -7,12 +7,12 @@ import type { ModelPackage, TaskRequest, TaskResult } from "@independo/inderun-c
|
|
|
7
7
|
* flattens every failure into a single `capability_unavailable` route rejection and carries the
|
|
8
8
|
* reason as human-readable text.
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export type OnnxRuntimeAvailability = {
|
|
11
11
|
/** Whether the runtime can execute the given model package on this host right now. */
|
|
12
12
|
available: boolean;
|
|
13
13
|
/** Human-readable detail describing why the runtime is unavailable. */
|
|
14
14
|
reason?: string;
|
|
15
|
-
}
|
|
15
|
+
};
|
|
16
16
|
/**
|
|
17
17
|
* Normalized conversation turn handed to an ONNX text generation runtime.
|
|
18
18
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/providers/onnx/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1F;;;;;;;GAOG;AACH,MAAM,
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/providers/onnx/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1F;;;;;;;GAOG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,sFAAsF;IACtF,SAAS,EAAE,OAAO,CAAC;IACnB,uEAAuE;IACvE,MAAM,CAAC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,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAC3F;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,sFAAsF;IACtF,YAAY,CAAC,EAAE,uBAAuB,CAAC;IACvC,oFAAoF;IACpF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,MAAM,GAAG,oBAAoB,CAAC;IACxE,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,GAAE,yBAA8B,GACtC,yBAAyB,CA4B3B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@independo/inderun-web",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-rc.1",
|
|
4
4
|
"description": "On-device AI with automatic cloud fallback for web apps. Runs ONNX Runtime or the Chrome Prompt API in the browser and falls back to an OpenAI-compatible endpoint, with streaming and cancellation behind one API.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"README.md"
|
|
73
73
|
],
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@independo/inderun-
|
|
76
|
-
"@independo/inderun-
|
|
75
|
+
"@independo/inderun-route-core-wasm": "^0.5.0-rc.1",
|
|
76
|
+
"@independo/inderun-contracts": "^0.5.0-rc.1"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"@huggingface/transformers": "^4.0.0"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* This file was generated from contracts/api/inderun-api.json. Do not edit by hand. */
|
|
2
2
|
|
|
3
|
-
import type { TaskRequest, TaskResult } from "@independo/inderun-contracts";
|
|
4
|
-
import type { StreamRun
|
|
3
|
+
import type { TaskRequest, TaskResult, ProviderCapabilitySnapshot } from "@independo/inderun-contracts";
|
|
4
|
+
import type { StreamRun } from "../provider.js";
|
|
5
5
|
|
|
6
6
|
export interface IndeRunApi {
|
|
7
7
|
/**
|
package/src/core/provider.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
ProviderDescriptor,
|
|
3
|
+
ProviderDynamicCapabilities,
|
|
2
4
|
StreamEvent,
|
|
3
5
|
StreamRunHandle,
|
|
4
6
|
TaskRequest,
|
|
@@ -7,143 +9,17 @@ import type {
|
|
|
7
9
|
import type { HostServices } from "./host.js";
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
+
* A provider's static declaration, live capability check, and the pair as
|
|
13
|
+
* `checkCapabilities()` returns it. All three are schema-backed contracts
|
|
14
|
+
* (`contracts/schemas/provider-*.schema.json`), shared with the Swift and Kotlin
|
|
15
|
+
* SDKs and with the route planner, so they are re-exported here rather than
|
|
16
|
+
* declared.
|
|
12
17
|
*/
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Execution target type: 'local' (on-device), 'edge', or 'cloud'.
|
|
20
|
-
*/
|
|
21
|
-
type: "local" | "edge" | "cloud";
|
|
22
|
-
/**
|
|
23
|
-
* The model this provider instance is bound to, when it can name one. A provider
|
|
24
|
-
* instance bound to one model is a *target* that model profiles list by `id`.
|
|
25
|
-
* Cloud providers report the model id they send; platform-managed models report
|
|
26
|
-
* an opaque platform alias rather than a guessed weight name. Absent means the
|
|
27
|
-
* provider cannot name its model.
|
|
28
|
-
*/
|
|
29
|
-
model?: string;
|
|
30
|
-
/**
|
|
31
|
-
* Connection transport layer protocol.
|
|
32
|
-
*/
|
|
33
|
-
transport: "in_process" | "system_service" | "http" | "sse" | "realtime";
|
|
34
|
-
/**
|
|
35
|
-
* Optional streaming style, if token or chunk streaming is supported.
|
|
36
|
-
*/
|
|
37
|
-
streamingStyle?: "tokens" | "chunks" | "snapshots";
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Flags representing the features and modes supported by this provider.
|
|
41
|
-
*/
|
|
42
|
-
supports: {
|
|
43
|
-
/** Whether the provider supports Mode 1 run (request/response). */
|
|
44
|
-
run: boolean;
|
|
45
|
-
/** Whether the provider supports Mode 2 stream. */
|
|
46
|
-
streaming: boolean;
|
|
47
|
-
/** Whether the provider supports Mode 3 realtime session. */
|
|
48
|
-
realtime: boolean;
|
|
49
|
-
/** Whether the provider supports tool calling definition. */
|
|
50
|
-
tools: boolean;
|
|
51
|
-
/** Whether the provider outputs reasoning events alongside contents. */
|
|
52
|
-
reasoningEvents: boolean;
|
|
53
|
-
/** Whether the provider supports structured outputs (JSON schema constraints). */
|
|
54
|
-
structuredOutput: boolean;
|
|
55
|
-
/** Whether the provider supports multimodal inputs (images, audio, etc.). */
|
|
56
|
-
multimodal: boolean;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Cancellation capabilities support:
|
|
61
|
-
* - 'hard': fully stops processing and interrupts remote operations.
|
|
62
|
-
* - 'soft': stops reading the stream locally, but the remote execution continues.
|
|
63
|
-
* - 'none': cancellation is unsupported.
|
|
64
|
-
*/
|
|
65
|
-
cancel: "hard" | "soft" | "none";
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* List of supported task kinds (e.g., 'text_to_text', 'embeddings').
|
|
69
|
-
*/
|
|
70
|
-
tasks: string[];
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Optional input/output resource boundaries.
|
|
74
|
-
*/
|
|
75
|
-
limits?: {
|
|
76
|
-
maxInputTokens?: number;
|
|
77
|
-
maxOutputTokens?: number;
|
|
78
|
-
maxImageBytes?: number;
|
|
79
|
-
maxAudioSeconds?: number;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Privacy settings regarding data egress.
|
|
84
|
-
*/
|
|
85
|
-
privacy?: {
|
|
86
|
-
/** Set to true if the model input leaves the host device. */
|
|
87
|
-
dataLeavesDevice: boolean;
|
|
88
|
-
/** Geographic regions where the cloud service executes. */
|
|
89
|
-
regions?: string[];
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Dynamic capability snapshot evaluated at runtime.
|
|
95
|
-
*/
|
|
96
|
-
export interface ProviderDynamicCapabilities {
|
|
97
|
-
/**
|
|
98
|
-
* Whether the provider is available and functional on the host device now.
|
|
99
|
-
*/
|
|
100
|
-
available: boolean;
|
|
101
|
-
/**
|
|
102
|
-
* Detail message if availability check fails.
|
|
103
|
-
*/
|
|
104
|
-
reason?: string;
|
|
105
|
-
/**
|
|
106
|
-
* Whether the provider can stream (Mode 2) right now on this host. Leave
|
|
107
|
-
* undefined to inherit the static `descriptor.supports.streaming` value —
|
|
108
|
-
* only set it when the runtime environment can take streaming away from a
|
|
109
|
-
* provider that otherwise declares it (e.g. the host has no chunked HTTP
|
|
110
|
-
* capability).
|
|
111
|
-
*/
|
|
112
|
-
streamingAvailable?: boolean;
|
|
113
|
-
/**
|
|
114
|
-
* Detail message used when `streamingAvailable` is false. Omit to let the
|
|
115
|
-
* route planner synthesize a generic message.
|
|
116
|
-
*/
|
|
117
|
-
streamingUnavailableReason?: string;
|
|
118
|
-
/**
|
|
119
|
-
* Whether cancellation is honored right now on this host. Leave undefined to
|
|
120
|
-
* inherit the static `descriptor.cancel` value (anything other than `"none"`
|
|
121
|
-
* means available).
|
|
122
|
-
*/
|
|
123
|
-
cancellationAvailable?: boolean;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* One registered provider's identity, fixed capabilities, and live availability,
|
|
128
|
-
* as of the moment checkCapabilities() was called.
|
|
129
|
-
*/
|
|
130
|
-
export interface ProviderCapabilitySnapshot {
|
|
131
|
-
/**
|
|
132
|
-
* Stable identifier for this provider, matching the value used in routing
|
|
133
|
-
* preferences/constraints.
|
|
134
|
-
*/
|
|
135
|
-
providerId: string;
|
|
136
|
-
/**
|
|
137
|
-
* The provider's static, unchanging capability declaration (supported modes,
|
|
138
|
-
* privacy posture, model info).
|
|
139
|
-
*/
|
|
140
|
-
descriptor: ProviderDescriptor;
|
|
141
|
-
/**
|
|
142
|
-
* The provider's current dynamic availability (e.g. whether it's reachable/loaded
|
|
143
|
-
* right now) — this is the part that can change between calls.
|
|
144
|
-
*/
|
|
145
|
-
capabilities: ProviderDynamicCapabilities;
|
|
146
|
-
}
|
|
18
|
+
export type {
|
|
19
|
+
ProviderCapabilitySnapshot,
|
|
20
|
+
ProviderDescriptor,
|
|
21
|
+
ProviderDynamicCapabilities
|
|
22
|
+
} from "@independo/inderun-contracts";
|
|
147
23
|
|
|
148
24
|
/**
|
|
149
25
|
* Execution context passed to provider run commands.
|
|
@@ -55,13 +55,13 @@ export interface RoutePlanner {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
* A provider paired with
|
|
59
|
-
* planner consumes.
|
|
58
|
+
* A provider paired with its descriptor and the dynamic capabilities the shared
|
|
59
|
+
* route planner consumes (already folded by {@link toSharedPlannerCapabilities}).
|
|
60
60
|
*/
|
|
61
61
|
export interface ProviderRuntimeSnapshot {
|
|
62
62
|
provider: ProviderAdapter;
|
|
63
|
-
descriptor:
|
|
64
|
-
capabilities:
|
|
63
|
+
descriptor: ProviderDescriptor;
|
|
64
|
+
capabilities: ProviderDynamicCapabilities;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/**
|
|
@@ -161,7 +161,7 @@ export async function collectProviderRuntimeSnapshots(
|
|
|
161
161
|
|
|
162
162
|
return {
|
|
163
163
|
provider,
|
|
164
|
-
descriptor
|
|
164
|
+
descriptor,
|
|
165
165
|
capabilities: toSharedPlannerCapabilities(capabilities, descriptor, provider)
|
|
166
166
|
};
|
|
167
167
|
})
|
|
@@ -184,9 +184,7 @@ export function buildSharedPlannerInput(
|
|
|
184
184
|
const preferences = request.preferences ?? {};
|
|
185
185
|
|
|
186
186
|
return {
|
|
187
|
-
task:
|
|
188
|
-
kind: request.task.kind
|
|
189
|
-
},
|
|
187
|
+
task: plannerTask(request),
|
|
190
188
|
interactionMode,
|
|
191
189
|
constraints: {
|
|
192
190
|
privacy: constraints.privacy ?? "cloud_allowed",
|
|
@@ -205,27 +203,15 @@ export function buildSharedPlannerInput(
|
|
|
205
203
|
};
|
|
206
204
|
}
|
|
207
205
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
},
|
|
218
|
-
cancel: descriptor.cancel,
|
|
219
|
-
tasks: descriptor.tasks,
|
|
220
|
-
...(descriptor.privacy
|
|
221
|
-
? {
|
|
222
|
-
privacy: {
|
|
223
|
-
dataLeavesDevice: descriptor.privacy.dataLeavesDevice,
|
|
224
|
-
...(descriptor.privacy.regions ? { regions: descriptor.privacy.regions } : {})
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
: {})
|
|
228
|
-
};
|
|
206
|
+
/**
|
|
207
|
+
* Projects the request's task onto the requirements the planner can check. A text
|
|
208
|
+
* request carries text input; the speech requirements arrive with the speech request
|
|
209
|
+
* shape (#245).
|
|
210
|
+
*/
|
|
211
|
+
function plannerTask(request: TaskRequest): SharedPlannerInput["task"] {
|
|
212
|
+
return request.task.kind === "text_to_text"
|
|
213
|
+
? { kind: request.task.kind, inputs: ["text"] }
|
|
214
|
+
: { kind: request.task.kind };
|
|
229
215
|
}
|
|
230
216
|
|
|
231
217
|
/**
|
|
@@ -241,7 +227,7 @@ function toSharedPlannerCapabilities(
|
|
|
241
227
|
capabilities: ProviderDynamicCapabilities,
|
|
242
228
|
descriptor: ProviderDescriptor,
|
|
243
229
|
provider: ProviderAdapter
|
|
244
|
-
):
|
|
230
|
+
): ProviderDynamicCapabilities {
|
|
245
231
|
const declaresStreaming = capabilities.streamingAvailable ?? descriptor.supports.streaming;
|
|
246
232
|
const implementsStream = typeof provider.stream === "function";
|
|
247
233
|
const streamingAvailable = declaresStreaming && implementsStream;
|
|
@@ -251,13 +237,12 @@ function toSharedPlannerCapabilities(
|
|
|
251
237
|
? `Provider '${descriptor.id}' declares streaming but does not implement stream().`
|
|
252
238
|
: undefined);
|
|
253
239
|
|
|
240
|
+
// Spread rather than pick, so a field added to the schema reaches the planner
|
|
241
|
+
// without touching this function.
|
|
242
|
+
const { streamingUnavailableReason: _declaredReason, ...rest } = capabilities;
|
|
254
243
|
return {
|
|
255
|
-
|
|
256
|
-
...(capabilities.reason ? { reason: capabilities.reason } : {}),
|
|
244
|
+
...rest,
|
|
257
245
|
streamingAvailable,
|
|
258
|
-
...(!streamingAvailable && streamingUnavailableReason ? { streamingUnavailableReason } : {})
|
|
259
|
-
...(capabilities.cancellationAvailable !== undefined
|
|
260
|
-
? { cancellationAvailable: capabilities.cancellationAvailable }
|
|
261
|
-
: {})
|
|
246
|
+
...(!streamingAvailable && streamingUnavailableReason ? { streamingUnavailableReason } : {})
|
|
262
247
|
};
|
|
263
248
|
}
|
|
@@ -8,12 +8,12 @@ import type { ModelPackage, TaskRequest, TaskResult } from "@independo/inderun-c
|
|
|
8
8
|
* flattens every failure into a single `capability_unavailable` route rejection and carries the
|
|
9
9
|
* reason as human-readable text.
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export type OnnxRuntimeAvailability = {
|
|
12
12
|
/** Whether the runtime can execute the given model package on this host right now. */
|
|
13
13
|
available: boolean;
|
|
14
14
|
/** Human-readable detail describing why the runtime is unavailable. */
|
|
15
15
|
reason?: string;
|
|
16
|
-
}
|
|
16
|
+
};
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Normalized conversation turn handed to an ONNX text generation runtime.
|