@simulatte/doppler 0.1.2 → 0.1.4
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 +8 -3
- package/package.json +3 -1
- package/src/client/doppler-api.d.ts +80 -0
- package/src/client/doppler-api.js +298 -0
- package/src/client/doppler-registry.d.ts +23 -0
- package/src/client/doppler-registry.js +88 -0
- package/src/client/doppler-registry.json +39 -0
- package/src/config/execution-contract-check.d.ts +49 -0
- package/src/config/execution-contract-check.js +245 -0
- package/src/config/loader.js +40 -21
- package/src/config/presets/models/janus-text.json +25 -0
- package/src/converter/core.js +22 -9
- package/src/converter/tokenizer-utils.js +17 -3
- package/src/formats/rdrr/validation.js +13 -0
- package/src/index-browser.d.ts +1 -0
- package/src/index-browser.js +1 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/inference/browser-harness.js +102 -16
- package/src/inference/pipelines/text/execution-v0.js +127 -8
- package/src/inference/pipelines/text/finiteness-policy.js +1 -1
- package/src/inference/pipelines/text/init.js +41 -10
- package/src/inference/pipelines/text.js +7 -1
- package/src/tooling/lean-execution-contract.d.ts +16 -0
- package/src/tooling/lean-execution-contract.js +81 -0
- package/src/tooling/node-webgpu.js +22 -1
- package/tools/doppler-cli.js +52 -5
package/tools/doppler-cli.js
CHANGED
|
@@ -13,6 +13,8 @@ import { createToolingErrorEnvelope } from '../src/tooling/command-envelope.js';
|
|
|
13
13
|
|
|
14
14
|
const NODE_WEBGPU_INCOMPLETE_MESSAGE = 'node command: WebGPU runtime is incomplete in Node';
|
|
15
15
|
const CLI_POLICY_PATH = fileURLToPath(new URL('./configs/cli/doppler-cli-policy.json', import.meta.url));
|
|
16
|
+
const DEFAULT_EXTERNAL_MODELS_ROOT = process.env.DOPPLER_EXTERNAL_MODELS_ROOT || '/media/x/models';
|
|
17
|
+
const DEFAULT_EXTERNAL_RDRR_ROOT = path.join(DEFAULT_EXTERNAL_MODELS_ROOT, 'rdrr');
|
|
16
18
|
const DEFAULT_CLI_POLICY = {
|
|
17
19
|
defaults: {
|
|
18
20
|
surface: {
|
|
@@ -413,6 +415,37 @@ async function resolveBrowserModelUrl(request, browserOptions = {}) {
|
|
|
413
415
|
};
|
|
414
416
|
}
|
|
415
417
|
|
|
418
|
+
export async function resolveNodeModelUrl(request, options = {}) {
|
|
419
|
+
if (request.modelUrl || !request.modelId) {
|
|
420
|
+
return request;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
const modelId = String(request.modelId);
|
|
424
|
+
const rdrrRoot = path.resolve(asStringOrNull(options.rdrrRoot) || DEFAULT_EXTERNAL_RDRR_ROOT);
|
|
425
|
+
const manifestPath = path.join(rdrrRoot, modelId, 'manifest.json');
|
|
426
|
+
if (!await pathExists(manifestPath)) {
|
|
427
|
+
return request;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
const modelDir = path.dirname(manifestPath);
|
|
431
|
+
try {
|
|
432
|
+
const files = await fs.readdir(modelDir, { withFileTypes: true });
|
|
433
|
+
const hasShards = files.some((entry) =>
|
|
434
|
+
entry.isFile() && /^shard_\d+\.bin$/u.test(entry.name)
|
|
435
|
+
);
|
|
436
|
+
if (!hasShards) {
|
|
437
|
+
return request;
|
|
438
|
+
}
|
|
439
|
+
} catch {
|
|
440
|
+
return request;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
return {
|
|
444
|
+
...request,
|
|
445
|
+
modelUrl: pathToFileURL(modelDir).href.replace(/\/$/, ''),
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
|
|
416
449
|
function parseSurface(value, command, policy = DEFAULT_CLI_POLICY) {
|
|
417
450
|
const normalizedInput = asStringOrNull(value);
|
|
418
451
|
const normalizedSurface = policy.defaults && policy.defaults.surface && policy.defaults.surface.default
|
|
@@ -616,10 +649,14 @@ function isTrainingCommandFlow(request) {
|
|
|
616
649
|
|
|
617
650
|
async function runCommandOnSurface(request, surface, runConfig, jsonOutput) {
|
|
618
651
|
if (surface === 'node') {
|
|
652
|
+
const nodeRequest = await resolveNodeModelUrl(request);
|
|
619
653
|
if (!jsonOutput) {
|
|
620
654
|
console.error('[surface] running on: node');
|
|
655
|
+
if (nodeRequest.modelUrl && nodeRequest.modelUrl !== request.modelUrl) {
|
|
656
|
+
console.error(`[surface] node resolved modelUrl=${nodeRequest.modelUrl}`);
|
|
657
|
+
}
|
|
621
658
|
}
|
|
622
|
-
return runNodeCommand(
|
|
659
|
+
return runNodeCommand(nodeRequest, buildNodeRunOptions(jsonOutput));
|
|
623
660
|
}
|
|
624
661
|
|
|
625
662
|
const browserOptions = buildBrowserRunOptions(runConfig, jsonOutput, request);
|
|
@@ -1164,7 +1201,17 @@ async function main() {
|
|
|
1164
1201
|
}
|
|
1165
1202
|
}
|
|
1166
1203
|
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1204
|
+
function isMainModule(metaUrl) {
|
|
1205
|
+
const entryPath = process.argv[1];
|
|
1206
|
+
if (!entryPath) {
|
|
1207
|
+
return false;
|
|
1208
|
+
}
|
|
1209
|
+
return path.resolve(fileURLToPath(metaUrl)) === path.resolve(entryPath);
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
if (isMainModule(import.meta.url)) {
|
|
1213
|
+
main().catch((error) => {
|
|
1214
|
+
console.error(`[error] ${error?.message || String(error)}`);
|
|
1215
|
+
process.exit(1);
|
|
1216
|
+
});
|
|
1217
|
+
}
|