@mcoda/mswarm 0.1.133 → 0.1.134
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 +4 -0
- package/dist/codali-executor.d.ts +3 -1
- package/dist/codali-executor.d.ts.map +1 -1
- package/dist/codali-executor.js +5 -0
- package/dist/codali-executor.js.map +1 -1
- package/dist/runtime.d.ts +2 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +39 -5
- package/dist/runtime.js.map +1 -1
- package/dist/vendor/codali/gateway/CodaliGateway.d.ts.map +1 -1
- package/dist/vendor/codali/gateway/CodaliGateway.js +5 -3
- package/dist/vendor/codali/gateway/LocalGatewayTaskRunner.d.ts.map +1 -1
- package/dist/vendor/codali/gateway/LocalGatewayTaskRunner.js +13 -1
- package/dist/vendor/codali/providers/OpenAiCompatibleProvider.d.ts.map +1 -1
- package/dist/vendor/codali/providers/OpenAiCompatibleProvider.js +44 -3
- package/dist/vendor/codali/providers/ProviderTypes.d.ts +2 -0
- package/dist/vendor/codali/providers/ProviderTypes.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/CodaliRuntime.d.ts +2 -0
- package/dist/vendor/codali/runtime/CodaliRuntime.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/CodaliRuntime.js +2 -0
- package/dist/vendor/codali/runtime/Runner.d.ts +6 -0
- package/dist/vendor/codali/runtime/Runner.d.ts.map +1 -1
- package/dist/vendor/codali/runtime/Runner.js +22 -4
- package/package.json +3 -3
package/dist/runtime.js
CHANGED
|
@@ -202,6 +202,7 @@ function resolvePersistentNodePath(nodePath) {
|
|
|
202
202
|
const DEFAULT_EXPOSE_ALL_MODELS = true;
|
|
203
203
|
const LOCAL_OPENAI_COMPATIBLE_ADAPTERS = new Set([
|
|
204
204
|
"openai-compatible-local",
|
|
205
|
+
"strata-local",
|
|
205
206
|
"vllm-local",
|
|
206
207
|
"llama-cpp-local",
|
|
207
208
|
"llamacpp-local"
|
|
@@ -244,6 +245,7 @@ const DEFAULT_VIDEO_GENERATIVE_OUTPUT_BYTES = 256 * 1024 * 1024;
|
|
|
244
245
|
const GENERATIVE_RESPONSE_JSON_OVERHEAD_BYTES = 64 * 1024;
|
|
245
246
|
const LOCAL_RUNNER_KIND_ALIASES = {
|
|
246
247
|
vllm: "vllm",
|
|
248
|
+
strata: "strata",
|
|
247
249
|
"llama-cpp": "llama-cpp",
|
|
248
250
|
"llama.cpp": "llama-cpp",
|
|
249
251
|
llamacpp: "llama-cpp",
|
|
@@ -526,6 +528,8 @@ function defaultLocalRunnerKindForAdapter(adapter) {
|
|
|
526
528
|
const lookupKey = normalizeLookupKey(normalized);
|
|
527
529
|
if (lookupKey === "vllm-local")
|
|
528
530
|
return "vllm";
|
|
531
|
+
if (lookupKey === "strata-local")
|
|
532
|
+
return "strata";
|
|
529
533
|
if (lookupKey === "llama-cpp-local" || lookupKey === "llamacpp-local")
|
|
530
534
|
return "llama-cpp";
|
|
531
535
|
return undefined;
|
|
@@ -4472,6 +4476,7 @@ export class SelfHostedNodeRuntime {
|
|
|
4472
4476
|
this.activeRequestIds = new Set();
|
|
4473
4477
|
this.lastModels = [];
|
|
4474
4478
|
this.loadRuntimeToken = null;
|
|
4479
|
+
this.loadReportQueue = Promise.resolve();
|
|
4475
4480
|
this.fastLoadUnsupported = false;
|
|
4476
4481
|
this.nativeActiveJobs = 0;
|
|
4477
4482
|
this.nativeProbeKeys = new Map();
|
|
@@ -5684,6 +5689,9 @@ export class SelfHostedNodeRuntime {
|
|
|
5684
5689
|
}
|
|
5685
5690
|
finally {
|
|
5686
5691
|
this.activeRequestIds.delete(job.request_id);
|
|
5692
|
+
// A product often starts its next stage immediately after this result.
|
|
5693
|
+
// Publish the newly free native slot before the gateway delivers it.
|
|
5694
|
+
await this.reportLoad().catch(() => undefined);
|
|
5687
5695
|
}
|
|
5688
5696
|
}
|
|
5689
5697
|
async executeTrackedJob(job, options) {
|
|
@@ -6057,14 +6065,15 @@ export class SelfHostedNodeRuntime {
|
|
|
6057
6065
|
async refreshNativeLoad() {
|
|
6058
6066
|
const runners = new Map();
|
|
6059
6067
|
for (const model of this.lastModels) {
|
|
6068
|
+
const isStrata = model.runner_kind === "strata" || model.adapter === "strata-local";
|
|
6060
6069
|
if (model.exposed === false || !model.base_url ||
|
|
6061
|
-
(model.runner_kind !== "llama-cpp" && model.adapter !== "llama-cpp-local"))
|
|
6070
|
+
(!isStrata && model.runner_kind !== "llama-cpp" && model.adapter !== "llama-cpp-local"))
|
|
6062
6071
|
continue;
|
|
6063
6072
|
try {
|
|
6064
6073
|
const url = new URL(model.base_url);
|
|
6065
6074
|
if (!["127.0.0.1", "localhost", "[::1]"].includes(url.hostname))
|
|
6066
6075
|
continue;
|
|
6067
|
-
const endpoint = new URL("/slots", url).toString();
|
|
6076
|
+
const endpoint = new URL(isStrata ? "/v1/status" : "/slots", url).toString();
|
|
6068
6077
|
const models = runners.get(endpoint) || [];
|
|
6069
6078
|
models.push(model);
|
|
6070
6079
|
runners.set(endpoint, models);
|
|
@@ -6089,12 +6098,30 @@ export class SelfHostedNodeRuntime {
|
|
|
6089
6098
|
}
|
|
6090
6099
|
const response = await this.fetchImpl(endpoint, { signal: AbortSignal.timeout(1500),
|
|
6091
6100
|
...(apiKey ? { headers: { authorization: `Bearer ${apiKey}` } } : {}) });
|
|
6092
|
-
|
|
6093
|
-
|
|
6101
|
+
const isStrata = new URL(endpoint).pathname === "/v1/status";
|
|
6102
|
+
// llama.cpp slot introspection is optional. Strata status also proves the model is loaded.
|
|
6103
|
+
if (!isStrata && [401, 403, 404].includes(response.status))
|
|
6094
6104
|
return;
|
|
6095
6105
|
if (!response.ok)
|
|
6096
6106
|
throw new Error("runner_load_unavailable");
|
|
6097
6107
|
const slots = await response.json();
|
|
6108
|
+
if (isStrata) {
|
|
6109
|
+
const concurrency = isRecord(slots) && isRecord(slots.concurrency) ? slots.concurrency.serving : undefined;
|
|
6110
|
+
const inFlight = isRecord(slots) && isRecord(slots.activity) ? slots.activity.in_flight : undefined;
|
|
6111
|
+
if (!isRecord(slots) || slots.loaded !== true ||
|
|
6112
|
+
typeof concurrency !== "number" || !Number.isSafeInteger(concurrency) || concurrency < 1 ||
|
|
6113
|
+
typeof inFlight !== "number" || !Number.isSafeInteger(inFlight) || inFlight < 0) {
|
|
6114
|
+
throw new Error("runner_load_unavailable");
|
|
6115
|
+
}
|
|
6116
|
+
const processing = Math.min(concurrency, inFlight);
|
|
6117
|
+
active += processing;
|
|
6118
|
+
const capacity = { max_concurrency: concurrency, active_jobs: processing,
|
|
6119
|
+
queued_jobs: Math.max(0, inFlight - concurrency), free_slots: Math.max(0, concurrency - inFlight),
|
|
6120
|
+
pool: `runner:${createHash("sha256").update(endpoint).digest("hex").slice(0, 16)}` };
|
|
6121
|
+
for (const model of models)
|
|
6122
|
+
modelCapacity[model.model_id || model.model || model.name] = capacity;
|
|
6123
|
+
return;
|
|
6124
|
+
}
|
|
6098
6125
|
if (!Array.isArray(slots))
|
|
6099
6126
|
return;
|
|
6100
6127
|
const processing = slots.filter((slot) => isRecord(slot) && slot.is_processing === true).length;
|
|
@@ -6114,7 +6141,14 @@ export class SelfHostedNodeRuntime {
|
|
|
6114
6141
|
this.nativeModelCapacity = modelCapacity;
|
|
6115
6142
|
this.unavailableModelIds = [...new Set(unavailable)];
|
|
6116
6143
|
}
|
|
6117
|
-
|
|
6144
|
+
reportLoad() {
|
|
6145
|
+
// Serialize probes and writes so an older busy snapshot cannot overwrite
|
|
6146
|
+
// the completion snapshot when the periodic reporter is already running.
|
|
6147
|
+
const pending = this.loadReportQueue.then(() => this.reportLoadSnapshot());
|
|
6148
|
+
this.loadReportQueue = pending.catch(() => undefined);
|
|
6149
|
+
return pending;
|
|
6150
|
+
}
|
|
6151
|
+
async reportLoadSnapshot() {
|
|
6118
6152
|
if (this.config.loadReportingEnabled === false || this.fastLoadUnsupported || !this.loadRuntimeToken)
|
|
6119
6153
|
return;
|
|
6120
6154
|
await this.refreshNativeLoad();
|