@atomic-chat/core 0.19.0 → 0.20.5
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/app-daemon.js +5 -0
- package/dist/app-daemon.js.map +1 -1
- package/dist/cli/bin.js +0 -0
- package/dist/cli/launch.js +2 -0
- package/dist/cli/launch.js.map +1 -1
- package/dist/cli/main.d.ts +1 -1
- package/dist/cli/main.js +5 -0
- package/dist/cli/main.js.map +1 -1
- package/dist/cloud/registry.js +1 -0
- package/dist/cloud/registry.js.map +1 -1
- package/dist/config/paths.d.ts +1 -1
- package/dist/config/paths.js +12 -0
- package/dist/config/paths.js.map +1 -1
- package/dist/contracts/engine-builds.d.ts +6 -1
- package/dist/contracts/engine-builds.js +1 -1
- package/dist/contracts/engine-builds.js.map +1 -1
- package/dist/contracts/engines.d.ts +1 -1
- package/dist/contracts/engines.js +2 -0
- package/dist/contracts/engines.js.map +1 -1
- package/dist/contracts/errors.d.ts +7 -1
- package/dist/contracts/errors.js.map +1 -1
- package/dist/contracts/events.d.ts +3 -1
- package/dist/contracts/geniex.d.ts +98 -0
- package/dist/contracts/geniex.js +15 -0
- package/dist/contracts/geniex.js.map +1 -0
- package/dist/contracts/index.d.ts +1 -0
- package/dist/contracts/index.js +1 -0
- package/dist/contracts/index.js.map +1 -1
- package/dist/contracts/model-yml.d.ts +40 -0
- package/dist/contracts/model-yml.js +7 -0
- package/dist/contracts/model-yml.js.map +1 -1
- package/dist/contracts/session.d.ts +6 -1
- package/dist/contracts/session.js.map +1 -1
- package/dist/contracts/settings.d.ts +12 -1
- package/dist/contracts/settings.js.map +1 -1
- package/dist/core/app-lease.d.ts +56 -0
- package/dist/core/app-lease.js +50 -0
- package/dist/core/app-lease.js.map +1 -0
- package/dist/core/atomic-core.d.ts +1 -1
- package/dist/core/create.js +109 -5
- package/dist/core/create.js.map +1 -1
- package/dist/engine-builds/engines.d.ts +28 -7
- package/dist/engine-builds/engines.js +49 -5
- package/dist/engine-builds/engines.js.map +1 -1
- package/dist/engine-builds/geniex.d.ts +35 -0
- package/dist/engine-builds/geniex.js +111 -0
- package/dist/engine-builds/geniex.js.map +1 -0
- package/dist/engine-builds/manifest.d.ts +43 -0
- package/dist/engine-builds/manifest.js +92 -0
- package/dist/engine-builds/manifest.js.map +1 -1
- package/dist/engine-builds/order.d.ts +2 -1
- package/dist/engine-builds/order.js +2 -0
- package/dist/engine-builds/order.js.map +1 -1
- package/dist/engine-builds/select.d.ts +15 -0
- package/dist/engine-builds/select.js +14 -0
- package/dist/engine-builds/select.js.map +1 -1
- package/dist/engine-builds/service.d.ts +5 -3
- package/dist/engine-builds/service.js +21 -2
- package/dist/engine-builds/service.js.map +1 -1
- package/dist/engines/service.d.ts +2 -1
- package/dist/engines/service.js +3 -1
- package/dist/engines/service.js.map +1 -1
- package/dist/engines/versions.js +3 -0
- package/dist/engines/versions.js.map +1 -1
- package/dist/integrations/catalog.d.ts +3 -1
- package/dist/integrations/catalog.js +8 -2
- package/dist/integrations/catalog.js.map +1 -1
- package/dist/integrations/config-io.d.ts +45 -4
- package/dist/integrations/config-io.js +91 -6
- package/dist/integrations/config-io.js.map +1 -1
- package/dist/integrations/configure/codex-repair.d.ts +75 -0
- package/dist/integrations/configure/codex-repair.js +254 -0
- package/dist/integrations/configure/codex-repair.js.map +1 -0
- package/dist/integrations/configure/codex.d.ts +48 -10
- package/dist/integrations/configure/codex.js +126 -32
- package/dist/integrations/configure/codex.js.map +1 -1
- package/dist/integrations/configure/registry.d.ts +4 -1
- package/dist/integrations/configure/registry.js +1 -0
- package/dist/integrations/configure/registry.js.map +1 -1
- package/dist/models/gguf/kv-cache.d.ts +5 -0
- package/dist/models/gguf/kv-cache.js +35 -2
- package/dist/models/gguf/kv-cache.js.map +1 -1
- package/dist/models/gguf/reader.d.ts +5 -0
- package/dist/models/gguf/reader.js +15 -3
- package/dist/models/gguf/reader.js.map +1 -1
- package/dist/router/resolve.d.ts +3 -2
- package/dist/router/resolve.js +3 -1
- package/dist/router/resolve.js.map +1 -1
- package/dist/runtime/geniex/accelerators.d.ts +20 -0
- package/dist/runtime/geniex/accelerators.js +53 -0
- package/dist/runtime/geniex/accelerators.js.map +1 -0
- package/dist/runtime/geniex/check.d.ts +34 -0
- package/dist/runtime/geniex/check.js +117 -0
- package/dist/runtime/geniex/check.js.map +1 -0
- package/dist/runtime/geniex/chip.d.ts +29 -0
- package/dist/runtime/geniex/chip.js +35 -0
- package/dist/runtime/geniex/chip.js.map +1 -0
- package/dist/runtime/geniex/devices.d.ts +13 -0
- package/dist/runtime/geniex/devices.js +32 -0
- package/dist/runtime/geniex/devices.js.map +1 -0
- package/dist/runtime/geniex/geniex-host.d.ts +17 -0
- package/dist/runtime/geniex/geniex-host.js +26 -0
- package/dist/runtime/geniex/geniex-host.js.map +1 -0
- package/dist/runtime/geniex/host/args.d.ts +56 -0
- package/dist/runtime/geniex/host/args.js +115 -0
- package/dist/runtime/geniex/host/args.js.map +1 -0
- package/dist/runtime/geniex/host/engine.d.ts +76 -0
- package/dist/runtime/geniex/host/engine.js +122 -0
- package/dist/runtime/geniex/host/engine.js.map +1 -0
- package/dist/runtime/geniex/host/ffi-bun.d.ts +15 -0
- package/dist/runtime/geniex/host/ffi-bun.js +415 -0
- package/dist/runtime/geniex/host/ffi-bun.js.map +1 -0
- package/dist/runtime/geniex/host/grammar.d.ts +11 -0
- package/dist/runtime/geniex/host/grammar.js +223 -0
- package/dist/runtime/geniex/host/grammar.js.map +1 -0
- package/dist/runtime/geniex/host/inspect.d.ts +25 -0
- package/dist/runtime/geniex/host/inspect.js +177 -0
- package/dist/runtime/geniex/host/inspect.js.map +1 -0
- package/dist/runtime/geniex/host/library.d.ts +117 -0
- package/dist/runtime/geniex/host/library.js +38 -0
- package/dist/runtime/geniex/host/library.js.map +1 -0
- package/dist/runtime/geniex/host/openai.d.ts +62 -0
- package/dist/runtime/geniex/host/openai.js +458 -0
- package/dist/runtime/geniex/host/openai.js.map +1 -0
- package/dist/runtime/geniex/host/run.d.ts +48 -0
- package/dist/runtime/geniex/host/run.js +208 -0
- package/dist/runtime/geniex/host/run.js.map +1 -0
- package/dist/runtime/geniex/host/server.d.ts +39 -0
- package/dist/runtime/geniex/host/server.js +232 -0
- package/dist/runtime/geniex/host/server.js.map +1 -0
- package/dist/runtime/geniex/host/worker-protocol.d.ts +76 -0
- package/dist/runtime/geniex/host/worker-protocol.js +116 -0
- package/dist/runtime/geniex/host/worker-protocol.js.map +1 -0
- package/dist/runtime/geniex/host/worker-source.generated.d.ts +1 -0
- package/dist/runtime/geniex/host/worker-source.generated.js +4 -0
- package/dist/runtime/geniex/host/worker-source.generated.js.map +1 -0
- package/dist/runtime/geniex/host/worker.d.ts +7 -0
- package/dist/runtime/geniex/host/worker.js +19 -0
- package/dist/runtime/geniex/host/worker.js.map +1 -0
- package/dist/runtime/geniex/host-process.d.ts +48 -0
- package/dist/runtime/geniex/host-process.js +104 -0
- package/dist/runtime/geniex/host-process.js.map +1 -0
- package/dist/runtime/geniex/index.d.ts +11 -0
- package/dist/runtime/geniex/index.js +12 -0
- package/dist/runtime/geniex/index.js.map +1 -0
- package/dist/runtime/geniex/model-yml.d.ts +8 -0
- package/dist/runtime/geniex/model-yml.js +98 -0
- package/dist/runtime/geniex/model-yml.js.map +1 -0
- package/dist/runtime/geniex/runtime.d.ts +94 -0
- package/dist/runtime/geniex/runtime.js +366 -0
- package/dist/runtime/geniex/runtime.js.map +1 -0
- package/dist/runtime/litert-lm/host/openai.d.ts +4 -37
- package/dist/runtime/litert-lm/host/openai.js +11 -96
- package/dist/runtime/litert-lm/host/openai.js.map +1 -1
- package/dist/runtime/litert-lm/host/pool.d.ts +1 -7
- package/dist/runtime/litert-lm/host/pool.js +1 -17
- package/dist/runtime/litert-lm/host/pool.js.map +1 -1
- package/dist/runtime/litert-lm/host/server.js +11 -53
- package/dist/runtime/litert-lm/host/server.js.map +1 -1
- package/dist/runtime/llamacpp/args.d.ts +5 -0
- package/dist/runtime/llamacpp/args.js +2 -0
- package/dist/runtime/llamacpp/args.js.map +1 -1
- package/dist/runtime/llamacpp/fit-margin.d.ts +44 -0
- package/dist/runtime/llamacpp/fit-margin.js +50 -0
- package/dist/runtime/llamacpp/fit-margin.js.map +1 -1
- package/dist/runtime/llamacpp/load-plan.d.ts +5 -0
- package/dist/runtime/llamacpp/load-plan.js +57 -22
- package/dist/runtime/llamacpp/load-plan.js.map +1 -1
- package/dist/runtime/llamacpp/runtime.d.ts +5 -1
- package/dist/runtime/llamacpp/runtime.js +6 -1
- package/dist/runtime/llamacpp/runtime.js.map +1 -1
- package/dist/runtime/shared/external-sessions.js +1 -0
- package/dist/runtime/shared/external-sessions.js.map +1 -1
- package/dist/runtime/shared/fifo-lock.d.ts +10 -0
- package/dist/runtime/shared/fifo-lock.js +21 -0
- package/dist/runtime/shared/fifo-lock.js.map +1 -0
- package/dist/runtime/shared/index.d.ts +2 -0
- package/dist/runtime/shared/index.js +2 -0
- package/dist/runtime/shared/index.js.map +1 -1
- package/dist/runtime/shared/openai-sse.d.ts +112 -0
- package/dist/runtime/shared/openai-sse.js +178 -0
- package/dist/runtime/shared/openai-sse.js.map +1 -0
- package/dist/server/clients.d.ts +6 -0
- package/dist/server/clients.js +11 -0
- package/dist/server/clients.js.map +1 -1
- package/dist/server/control/router.js +2 -0
- package/dist/server/control/router.js.map +1 -1
- package/dist/server/control/routes/geniex.d.ts +7 -0
- package/dist/server/control/routes/geniex.js +22 -0
- package/dist/server/control/routes/geniex.js.map +1 -0
- package/dist/server/control/types.d.ts +11 -1
- package/dist/server/control/types.js.map +1 -1
- package/dist/server/http.js +2 -0
- package/dist/server/http.js.map +1 -1
- package/dist/server/public/embedding.d.ts +8 -7
- package/dist/server/public/embedding.js +15 -7
- package/dist/server/public/embedding.js.map +1 -1
- package/dist/server/public/forward.js +23 -6
- package/dist/server/public/forward.js.map +1 -1
- package/dist/server/public/listing.js +1 -0
- package/dist/server/public/listing.js.map +1 -1
- package/dist/server/public/responses.js +9 -0
- package/dist/server/public/responses.js.map +1 -1
- package/dist/server/public/telemetry.d.ts +7 -1
- package/dist/server/public/telemetry.js +11 -3
- package/dist/server/public/telemetry.js.map +1 -1
- package/dist/server/public/trace.d.ts +8 -4
- package/dist/server/public/trace.js +15 -7
- package/dist/server/public/trace.js.map +1 -1
- package/dist/server/public/validate.d.ts +32 -0
- package/dist/server/public/validate.js +146 -0
- package/dist/server/public/validate.js.map +1 -0
- package/dist/settings/schema/geniex.json +63 -0
- package/dist/settings/schema/mlx.json +1 -1
- package/dist/settings/schema.js +11 -0
- package/dist/settings/schema.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -2
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GenieX's devices as accelerators (openspec change `add-geniex-runtime`, task 6.4, design D3): what
|
|
3
|
+
* the active build's library found at its install — the Hexagon NPU (`HTP0`) and the Adreno GPU
|
|
4
|
+
* (`GPUOpenCL`) — in LiteRT-LM's shape, so the clients reuse their UI. Everything a device needs
|
|
5
|
+
* ships inside the SDK build, so each is `prepared` the moment it is listed and `prepare` has
|
|
6
|
+
* nothing to download; it answers so without an event.
|
|
7
|
+
*/
|
|
8
|
+
import type { GeniexAccelerators, GeniexChip, GeniexPrepareRequest, GeniexPrepareResult } from '../../contracts/index.js';
|
|
9
|
+
import type { GeniexBuild } from './runtime.js';
|
|
10
|
+
export interface GeniexAcceleratorDeps {
|
|
11
|
+
resolveBuild: () => Promise<GeniexBuild | undefined>;
|
|
12
|
+
chip: GeniexChip;
|
|
13
|
+
}
|
|
14
|
+
export declare class GeniexAcceleratorService {
|
|
15
|
+
private readonly deps;
|
|
16
|
+
constructor(deps: GeniexAcceleratorDeps);
|
|
17
|
+
list(): Promise<GeniexAccelerators>;
|
|
18
|
+
/** Every name answers at once: prepared when the library found it, with why it is not otherwise. */
|
|
19
|
+
prepare(request: GeniexPrepareRequest): Promise<GeniexPrepareResult>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GenieX's devices as accelerators (openspec change `add-geniex-runtime`, task 6.4, design D3): what
|
|
3
|
+
* the active build's library found at its install — the Hexagon NPU (`HTP0`) and the Adreno GPU
|
|
4
|
+
* (`GPUOpenCL`) — in LiteRT-LM's shape, so the clients reuse their UI. Everything a device needs
|
|
5
|
+
* ships inside the SDK build, so each is `prepared` the moment it is listed and `prepare` has
|
|
6
|
+
* nothing to download; it answers so without an event.
|
|
7
|
+
*/
|
|
8
|
+
import { acceleratorsFound } from './devices.js';
|
|
9
|
+
const NOTHING_TO_PREPARE = "Nothing to prepare: GenieX's NPU and GPU libraries are part of the installed build.";
|
|
10
|
+
export class GeniexAcceleratorService {
|
|
11
|
+
deps;
|
|
12
|
+
constructor(deps) {
|
|
13
|
+
this.deps = deps;
|
|
14
|
+
}
|
|
15
|
+
async list() {
|
|
16
|
+
const build = await this.deps.resolveBuild();
|
|
17
|
+
if (!build)
|
|
18
|
+
return { installed: false, build: null, chip: this.deps.chip, accelerators: [], error: null };
|
|
19
|
+
return {
|
|
20
|
+
installed: true,
|
|
21
|
+
build: `${build.version}/${build.dir.split(/[\\/]/).at(-1) ?? ''}`,
|
|
22
|
+
chip: this.deps.chip,
|
|
23
|
+
accelerators: acceleratorsFound(build.devices).map((device) => ({
|
|
24
|
+
name: device,
|
|
25
|
+
device,
|
|
26
|
+
version: build.version,
|
|
27
|
+
size_bytes: 0,
|
|
28
|
+
prepared: true,
|
|
29
|
+
})),
|
|
30
|
+
error: null,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** Every name answers at once: prepared when the library found it, with why it is not otherwise. */
|
|
34
|
+
async prepare(request) {
|
|
35
|
+
const listed = await this.list();
|
|
36
|
+
const offered = new Set(listed.accelerators.map((accelerator) => accelerator.name));
|
|
37
|
+
const wanted = request.accelerators && request.accelerators.length > 0 ? request.accelerators : [...offered];
|
|
38
|
+
return {
|
|
39
|
+
accelerators: wanted.map((name) => offered.has(name)
|
|
40
|
+
? { name, prepared: true, reason: NOTHING_TO_PREPARE }
|
|
41
|
+
: {
|
|
42
|
+
name,
|
|
43
|
+
prepared: false,
|
|
44
|
+
reason: !listed.installed
|
|
45
|
+
? 'GenieX is not installed on this computer.'
|
|
46
|
+
: name === 'npu' || name === 'gpu'
|
|
47
|
+
? `GenieX found no ${name.toUpperCase()} on this computer.`
|
|
48
|
+
: `GenieX has no ${name} accelerator.`,
|
|
49
|
+
}),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=accelerators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accelerators.js","sourceRoot":"","sources":["../../../src/runtime/geniex/accelerators.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAQhD,MAAM,kBAAkB,GACtB,qFAAqF,CAAA;AAEvF,MAAM,OAAO,wBAAwB;IACN;IAA7B,YAA6B,IAA2B;QAA3B,SAAI,GAAJ,IAAI,CAAuB;IAAG,CAAC;IAE5D,KAAK,CAAC,IAAI;QACR,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAA;QAC5C,IAAI,CAAC,KAAK;YAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;QACzG,OAAO;YACL,SAAS,EAAE,IAAI;YACf,KAAK,EAAE,GAAG,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE;YAClE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI;Y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C,CACN;SACF,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `POST /models/geniex/check` (openspec change `add-geniex-runtime`, task 6.5): whether a variant
|
|
3
|
+
* would run here. Before a download, from what core already knows — this machine's chip, the
|
|
4
|
+
* active build and the devices its probe found — never the network. For a model on disk, also from
|
|
5
|
+
* the model itself (`geniex-host inspect`, no library needed), whose facts come back in the answer
|
|
6
|
+
* for the client to write into `model.yml`.
|
|
7
|
+
*/
|
|
8
|
+
import type { GeniexCheckRequest, GeniexCheckResult, GeniexChip, GeniexModelMetadata } from '../../contracts/index.js';
|
|
9
|
+
import type { ModelRegistry } from '../../models/index.js';
|
|
10
|
+
import type { GeniexBuild } from './runtime.js';
|
|
11
|
+
export interface GeniexCheckFacts {
|
|
12
|
+
chip: GeniexChip;
|
|
13
|
+
build: GeniexBuild | null;
|
|
14
|
+
}
|
|
15
|
+
/** The verdict for a variant (`plugin`, `device`, `chip`, `min_runtime_version`), and for a model its facts. */
|
|
16
|
+
export declare function geniexVerdict(facts: GeniexCheckFacts, request: Pick<GeniexCheckRequest, 'plugin' | 'device' | 'chip' | 'min_runtime_version'>, model: GeniexModelMetadata | null): GeniexCheckResult;
|
|
17
|
+
/** The request body, strictly: a variant, a path with its plugin and device, or a model id. */
|
|
18
|
+
export declare function parseGeniexCheckRequest(body: unknown): GeniexCheckRequest;
|
|
19
|
+
export interface GeniexCheckDeps {
|
|
20
|
+
chip: GeniexChip;
|
|
21
|
+
/** `<data>/geniex/models`: the only place a checked path may be. */
|
|
22
|
+
modelsDir: string;
|
|
23
|
+
registry: ModelRegistry;
|
|
24
|
+
resolveBuild: () => Promise<GeniexBuild | undefined>;
|
|
25
|
+
/** The runtime's cached `inspect` (by path and mtime); needs no build. */
|
|
26
|
+
inspect: (path: string) => Promise<GeniexModelMetadata>;
|
|
27
|
+
}
|
|
28
|
+
export declare class GeniexCheckService {
|
|
29
|
+
private readonly deps;
|
|
30
|
+
constructor(deps: GeniexCheckDeps);
|
|
31
|
+
/** A path inside the models root, links resolved, or `INVALID_ARGUMENT`. */
|
|
32
|
+
private inRoot;
|
|
33
|
+
check(request: GeniexCheckRequest): Promise<GeniexCheckResult>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `POST /models/geniex/check` (openspec change `add-geniex-runtime`, task 6.5): whether a variant
|
|
3
|
+
* would run here. Before a download, from what core already knows — this machine's chip, the
|
|
4
|
+
* active build and the devices its probe found — never the network. For a model on disk, also from
|
|
5
|
+
* the model itself (`geniex-host inspect`, no library needed), whose facts come back in the answer
|
|
6
|
+
* for the client to write into `model.yml`.
|
|
7
|
+
*/
|
|
8
|
+
import { realpath } from 'node:fs/promises';
|
|
9
|
+
import { isAbsolute, relative, resolve } from 'node:path';
|
|
10
|
+
import { AtomicCoreError, GENIEX_CHIPS, GENIEX_DEVICES, GENIEX_PLUGINS } from '../../contracts/index.js';
|
|
11
|
+
import { compareVersions } from '../../backend/index.js';
|
|
12
|
+
import { deviceFound, deviceMissingReason } from './devices.js';
|
|
13
|
+
import { readGeniexBlock } from './model-yml.js';
|
|
14
|
+
const verdict = (v, reason, metadata) => ({
|
|
15
|
+
verdict: v,
|
|
16
|
+
reason,
|
|
17
|
+
...(metadata ? { metadata } : {}),
|
|
18
|
+
});
|
|
19
|
+
/** The verdict for a variant (`plugin`, `device`, `chip`, `min_runtime_version`), and for a model its facts. */
|
|
20
|
+
export function geniexVerdict(facts, request, model) {
|
|
21
|
+
const plugin = request.plugin ?? '';
|
|
22
|
+
if (!GENIEX_PLUGINS.some((known) => known === plugin))
|
|
23
|
+
return verdict('platform-unsupported', `This core runs no GenieX model with the "${plugin}" plugin.`, model);
|
|
24
|
+
const device = request.device ?? '';
|
|
25
|
+
if (!GENIEX_DEVICES.some((known) => known === device))
|
|
26
|
+
return verdict('platform-unsupported', `This core runs no GenieX model on the "${device}" device.`, model);
|
|
27
|
+
if (plugin === 'qairt') {
|
|
28
|
+
if (device !== 'npu')
|
|
29
|
+
return verdict('platform-unsupported', 'AI Hub bundles run on the NPU only.', model);
|
|
30
|
+
const chip = model?.kind === 'qairt' && model.chip ? model.chip : request.chip;
|
|
31
|
+
if (chip === undefined || chip === null)
|
|
32
|
+
return verdict('platform-unsupported', 'This bundle does not say which Snapdragon chip it is built for.', model);
|
|
33
|
+
if (!GENIEX_CHIPS.some((known) => known === chip))
|
|
34
|
+
return verdict('platform-unsupported', `This core knows no Snapdragon "${chip}".`, model);
|
|
35
|
+
if (chip !== facts.chip)
|
|
36
|
+
return verdict('platform-unsupported', `This bundle is built for the Snapdragon ${chip}; this computer has the ${facts.chip}.`, model);
|
|
37
|
+
}
|
|
38
|
+
if (model && (model.kind === 'qairt') !== (plugin === 'qairt'))
|
|
39
|
+
return verdict('platform-unsupported', model.kind === 'qairt'
|
|
40
|
+
? 'This folder holds an AI Hub bundle, which runs with the qairt plugin.'
|
|
41
|
+
: 'This file is a GGUF, which runs with the llama_cpp plugin.', model);
|
|
42
|
+
if (!facts.build)
|
|
43
|
+
return verdict('engine-not-installed', 'GenieX is not installed on this computer.', model);
|
|
44
|
+
if (!deviceFound(device, facts.build.devices))
|
|
45
|
+
return verdict('accelerator-unavailable', deviceMissingReason(device), model);
|
|
46
|
+
const needs = (model?.kind === 'qairt' ? model.min_runtime_version : null) ?? request.min_runtime_version ?? null;
|
|
47
|
+
if (needs && compareVersions(needs, facts.build.version) > 0)
|
|
48
|
+
return verdict('requires-newer-engine', `This model needs GenieX ${needs}; the installed one is ${facts.build.version}.`, model);
|
|
49
|
+
return verdict('ok', null, model);
|
|
50
|
+
}
|
|
51
|
+
const VERSION_RE = /^\d+\.\d+(\.\d+)?$/;
|
|
52
|
+
const FIELDS = ['plugin', 'device', 'chip', 'min_runtime_version', 'path', 'model_id'];
|
|
53
|
+
/** The request body, strictly: a variant, a path with its plugin and device, or a model id. */
|
|
54
|
+
export function parseGeniexCheckRequest(body) {
|
|
55
|
+
const invalid = (why) => {
|
|
56
|
+
throw new AtomicCoreError('INVALID_ARGUMENT', why);
|
|
57
|
+
};
|
|
58
|
+
if (typeof body !== 'object' || body === null || Array.isArray(body))
|
|
59
|
+
return invalid('The request body must be a JSON object.');
|
|
60
|
+
const record = body;
|
|
61
|
+
const extra = Object.keys(record).filter((key) => !FIELDS.some((field) => field === key));
|
|
62
|
+
if (extra.length > 0)
|
|
63
|
+
invalid(`The request has fields this core does not know: ${extra.sort().join(', ')}.`);
|
|
64
|
+
const out = {};
|
|
65
|
+
for (const key of FIELDS) {
|
|
66
|
+
const value = record[key];
|
|
67
|
+
if (value === undefined)
|
|
68
|
+
continue;
|
|
69
|
+
if (typeof value !== 'string' || value === '')
|
|
70
|
+
invalid(`${key} must be text.`);
|
|
71
|
+
out[key] = value;
|
|
72
|
+
}
|
|
73
|
+
if (out.min_runtime_version !== undefined && !VERSION_RE.test(out.min_runtime_version))
|
|
74
|
+
invalid('min_runtime_version must be X.Y or X.Y.Z.');
|
|
75
|
+
if (out.model_id !== undefined) {
|
|
76
|
+
if (Object.keys(out).length > 1)
|
|
77
|
+
invalid('model_id is checked alone: its variant comes from model.yml.');
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
if (out.plugin === undefined || out.device === undefined)
|
|
81
|
+
invalid('plugin and device are required for a variant or a path.');
|
|
82
|
+
return out;
|
|
83
|
+
}
|
|
84
|
+
export class GeniexCheckService {
|
|
85
|
+
deps;
|
|
86
|
+
constructor(deps) {
|
|
87
|
+
this.deps = deps;
|
|
88
|
+
}
|
|
89
|
+
/** A path inside the models root, links resolved, or `INVALID_ARGUMENT`. */
|
|
90
|
+
async inRoot(path) {
|
|
91
|
+
const refuse = () => new AtomicCoreError('INVALID_ARGUMENT', 'path must be a file or folder inside the GenieX models folder.');
|
|
92
|
+
if (!isAbsolute(path))
|
|
93
|
+
throw new AtomicCoreError('INVALID_ARGUMENT', 'path must be absolute.');
|
|
94
|
+
const root = await realpath(this.deps.modelsDir).catch(() => resolve(this.deps.modelsDir));
|
|
95
|
+
// A model that is not there yet is judged by its spelling; one that is, by where its links lead.
|
|
96
|
+
const full = await realpath(path).catch(() => resolve(path));
|
|
97
|
+
const rel = relative(root, full);
|
|
98
|
+
if (rel === '' || rel.startsWith('..') || isAbsolute(rel))
|
|
99
|
+
throw refuse();
|
|
100
|
+
return resolve(path);
|
|
101
|
+
}
|
|
102
|
+
async check(request) {
|
|
103
|
+
let variant = request;
|
|
104
|
+
let path = request.path !== undefined ? await this.inRoot(request.path) : null;
|
|
105
|
+
if (request.model_id !== undefined) {
|
|
106
|
+
const yml = await this.deps.registry.read(request.model_id);
|
|
107
|
+
const block = readGeniexBlock(yml);
|
|
108
|
+
variant = { plugin: block.plugin, device: block.backend, ...(block.chip ? { chip: block.chip } : {}) };
|
|
109
|
+
// The registry's own path: an installed model may be a link, which the runtime loads as it is.
|
|
110
|
+
path = this.deps.registry.resolvePaths(yml).modelPath;
|
|
111
|
+
}
|
|
112
|
+
const facts = { chip: this.deps.chip, build: (await this.deps.resolveBuild()) ?? null };
|
|
113
|
+
const metadata = path ? await this.deps.inspect(path) : null;
|
|
114
|
+
return geniexVerdict(facts, variant, metadata);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../../src/runtime/geniex/check.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AASxG,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAA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,KAAK,EAAE,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,IAAI,IAAI,EAAE,CAAA;QACzG,MAAM,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QAC5D,OAAO,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAA;IAChD,CAAC;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the `geniex` provider registers, and which Snapdragon chip the machine has (openspec change
|
|
3
|
+
* `add-geniex-runtime`, task 4.3, design D3): Windows arm64 whose processor string names a Snapdragon
|
|
4
|
+
* X of either generation. The AI Hub bundles are compiled per Hexagon generation, not per SKU, and
|
|
5
|
+
* conf spells the generations `x-elite` (Hexagon v73: X Elite `X1E…`, X Plus `X1P…`, X `X1-…`) and
|
|
6
|
+
* `x2-elite` (v81: X2 Elite `X2E…`, X2 Plus `X2P…`) — AI Hub itself points the X Plus at the X Elite
|
|
7
|
+
* zip. Other arm64 Windows machines (virtual machines, 8cx: Hexagon v69, which the SDK has no HTP
|
|
8
|
+
* library for) keep the provider off.
|
|
9
|
+
*
|
|
10
|
+
* The same table shape as LiteRT-LM's Intel NPU generations (`litert-lm/npu.ts`). Verified on an X2
|
|
11
|
+
* Elite (rulings/core.md, spike S1); the first generation is read off the part numbers only.
|
|
12
|
+
*/
|
|
13
|
+
import type { GeniexChip } from '../../contracts/index.js';
|
|
14
|
+
export declare function geniexChip(cpuName: string): GeniexChip | null;
|
|
15
|
+
export interface GeniexHostFacts {
|
|
16
|
+
platform: NodeJS.Platform;
|
|
17
|
+
arch: string;
|
|
18
|
+
/** `Win32_Processor.Name` on Windows, as the hardware probe reports it. */
|
|
19
|
+
cpuName: string;
|
|
20
|
+
}
|
|
21
|
+
/** Which SDK zip this host runs and which chip it has, or why none (`EngineHostPlatform` for engine-builds). */
|
|
22
|
+
export type GeniexHostPlatform = {
|
|
23
|
+
platform: 'win-arm64';
|
|
24
|
+
chip: GeniexChip;
|
|
25
|
+
} | {
|
|
26
|
+
platform: null;
|
|
27
|
+
reason: string;
|
|
28
|
+
};
|
|
29
|
+
export declare function geniexHostPlatform(host: GeniexHostFacts): GeniexHostPlatform;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the `geniex` provider registers, and which Snapdragon chip the machine has (openspec change
|
|
3
|
+
* `add-geniex-runtime`, task 4.3, design D3): Windows arm64 whose processor string names a Snapdragon
|
|
4
|
+
* X of either generation. The AI Hub bundles are compiled per Hexagon generation, not per SKU, and
|
|
5
|
+
* conf spells the generations `x-elite` (Hexagon v73: X Elite `X1E…`, X Plus `X1P…`, X `X1-…`) and
|
|
6
|
+
* `x2-elite` (v81: X2 Elite `X2E…`, X2 Plus `X2P…`) — AI Hub itself points the X Plus at the X Elite
|
|
7
|
+
* zip. Other arm64 Windows machines (virtual machines, 8cx: Hexagon v69, which the SDK has no HTP
|
|
8
|
+
* library for) keep the provider off.
|
|
9
|
+
*
|
|
10
|
+
* The same table shape as LiteRT-LM's Intel NPU generations (`litert-lm/npu.ts`). Verified on an X2
|
|
11
|
+
* Elite (rulings/core.md, spike S1); the first generation is read off the part numbers only.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* The part numbers as a bare word, not a suffix: `X1E80100`, `X1E78100` (X Elite), `X1P64100` (X Plus),
|
|
15
|
+
* `X1-26-100` (X), `X2E88100` (X2 Elite), `X2P…` (X2 Plus).
|
|
16
|
+
*/
|
|
17
|
+
const PART_RE = /(?:^|[^A-Za-z0-9])(X1E|X1P|X1(?=-\d)|X2E|X2P)\d*(?![A-Za-z])/;
|
|
18
|
+
export function geniexChip(cpuName) {
|
|
19
|
+
const part = PART_RE.exec(cpuName)?.[1];
|
|
20
|
+
if (!part)
|
|
21
|
+
return null;
|
|
22
|
+
return part.startsWith('X1') ? 'x-elite' : 'x2-elite';
|
|
23
|
+
}
|
|
24
|
+
export function geniexHostPlatform(host) {
|
|
25
|
+
if (host.platform !== 'win32' || host.arch !== 'arm64')
|
|
26
|
+
return { platform: null, reason: `GenieX runs on Windows arm64 only, not ${host.platform} ${host.arch}.` };
|
|
27
|
+
const chip = geniexChip(host.cpuName);
|
|
28
|
+
if (!chip)
|
|
29
|
+
return {
|
|
30
|
+
platform: null,
|
|
31
|
+
reason: `GenieX runs on Snapdragon X (X Elite, X Plus, X, X2 Elite, X2 Plus) only; this processor is "${host.cpuName}".`,
|
|
32
|
+
};
|
|
33
|
+
return { platform: 'win-arm64', chip };
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=chip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chip.js","sourceRoot":"","sources":["../../../src/runtime/geniex/chip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH;;;GAGG;AACH,MAAM,OAAO,GAAG,8DAA8D,CAAA;AAE9E,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IACvC,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IACtB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAA;AACvD,CAAC;AAaD,MAAM,UAAU,kBAAkB,CAAC,IAAqB;IACtD,IAAI,IAAI,CAAC,QAAQ,KAAK,OAAO,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO;QACpD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,0CAA0C,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,IAAI,GAAG,EAAE,CAAA;IAC5G,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACrC,IAAI,CAAC,IAAI;QACP,OAAO;YACL,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,gGAAgG,IAAI,CAAC,OAAO,IAAI;SACzH,CAAA;IACH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,CAAA;AACxC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GenieX's device ids and the devices a model names (openspec change `add-geniex-runtime`, design
|
|
3
|
+
* D3): `geniex_get_device_list` of the `llama_cpp` plugin answers ids such as `HTP0` (the Hexagon
|
|
4
|
+
* NPU), `GPUOpenCL` (the Adreno GPU) and `CPU`; a model asks for `npu`, `gpu`, `cpu` or `hybrid`
|
|
5
|
+
* (NPU and GPU together). The ids are what `probe` recorded at the build's install.
|
|
6
|
+
*/
|
|
7
|
+
import type { GeniexDevice } from '../../contracts/index.js';
|
|
8
|
+
/** Whether the library found what `device` needs; the CPU is always there. */
|
|
9
|
+
export declare function deviceFound(device: GeniexDevice, ids: readonly string[]): boolean;
|
|
10
|
+
/** Why `device` is not there, in words a card can show. */
|
|
11
|
+
export declare function deviceMissingReason(device: GeniexDevice): string;
|
|
12
|
+
/** The accelerators the library found, in the order the clients list them: the NPU, then the GPU. */
|
|
13
|
+
export declare function acceleratorsFound(ids: readonly string[]): Array<Extract<GeniexDevice, 'npu' | 'gpu'>>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GenieX's device ids and the devices a model names (openspec change `add-geniex-runtime`, design
|
|
3
|
+
* D3): `geniex_get_device_list` of the `llama_cpp` plugin answers ids such as `HTP0` (the Hexagon
|
|
4
|
+
* NPU), `GPUOpenCL` (the Adreno GPU) and `CPU`; a model asks for `npu`, `gpu`, `cpu` or `hybrid`
|
|
5
|
+
* (NPU and GPU together). The ids are what `probe` recorded at the build's install.
|
|
6
|
+
*/
|
|
7
|
+
const hasNpu = (ids) => ids.some((id) => /^HTP/i.test(id));
|
|
8
|
+
const hasGpu = (ids) => ids.some((id) => /^GPU/i.test(id));
|
|
9
|
+
/** Whether the library found what `device` needs; the CPU is always there. */
|
|
10
|
+
export function deviceFound(device, ids) {
|
|
11
|
+
switch (device) {
|
|
12
|
+
case 'npu':
|
|
13
|
+
return hasNpu(ids);
|
|
14
|
+
case 'gpu':
|
|
15
|
+
return hasGpu(ids);
|
|
16
|
+
case 'hybrid':
|
|
17
|
+
return hasNpu(ids) && hasGpu(ids);
|
|
18
|
+
case 'cpu':
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/** Why `device` is not there, in words a card can show. */
|
|
23
|
+
export function deviceMissingReason(device) {
|
|
24
|
+
if (device === 'gpu')
|
|
25
|
+
return 'GenieX found no Adreno GPU (no OpenCL device) on this computer.';
|
|
26
|
+
return `GenieX found no Hexagon NPU (no HTP device) on this computer${device === 'hybrid' ? ', which hybrid needs with the GPU' : ''}; check the Qualcomm NPU driver.`;
|
|
27
|
+
}
|
|
28
|
+
/** The accelerators the library found, in the order the clients list them: the NPU, then the GPU. */
|
|
29
|
+
export function acceleratorsFound(ids) {
|
|
30
|
+
return [...(hasNpu(ids) ? ['npu'] : []), ...(hasGpu(ids) ? ['gpu'] : [])];
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=devices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devices.js","sourceRoot":"","sources":["../../../src/runtime/geniex/devices.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,MAAM,GAAG,CAAC,GAAsB,EAAW,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;AACtF,MAAM,MAAM,GAAG,CAAC,GAAsB,EAAW,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;AAEtF,8EAA8E;AAC9E,MAAM,UAAU,WAAW,CAAC,MAAoB,EAAE,GAAsB;IACtE,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,KAAK;YACR,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA;QACpB,KAAK,KAAK;YACR,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA;QACpB,KAAK,QAAQ;YACX,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAA;QACnC,KAAK,KAAK;YACR,OAAO,IAAI,CAAA;IACf,CAAC;AACH,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,mBAAmB,CAAC,MAAoB;IACtD,IAAI,MAAM,KAAK,KAAK;QAAE,OAAO,iEAAiE,CAAA;IAC9F,OAAO,+DAA+D,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,mCAAmC,CAAC,CAAC,CAAC,EAAE,kCAAkC,CAAA;AACxK,CAAC;AAED,qGAAqG;AACrG,MAAM,UAAU,iBAAiB,CAAC,GAAsB;IACtD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAc,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAc,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAC7F,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@atomic-chat/core/geniex-host`: the one entry of the hidden `geniex-host` mode (change
|
|
3
|
+
* `add-geniex-runtime`, design D1). The core binaries and any program that embeds the core as a
|
|
4
|
+
* library (`atc`) hand it the arguments after `geniex-host` before they parse their own commands,
|
|
5
|
+
* because `geniexHostCommand` starts the host as `<this program> geniex-host …`.
|
|
6
|
+
*
|
|
7
|
+
* Importing this file loads no `bun:*`: the library lives in a Worker the mode alone starts.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Runs `geniex-host <argv…>` and returns its exit code (`EXIT` in `host/run.ts`). Lines go to this
|
|
11
|
+
* process's stdout and stderr through writers that go quiet instead of crashing the host when the
|
|
12
|
+
* core closed its end of a pipe (EPIPE).
|
|
13
|
+
*/
|
|
14
|
+
export declare function runGeniexHostMain(argv: readonly string[], io?: {
|
|
15
|
+
stdout: (text: string) => void;
|
|
16
|
+
stderr: (text: string) => void;
|
|
17
|
+
}): Promise<number>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@atomic-chat/core/geniex-host`: the one entry of the hidden `geniex-host` mode (change
|
|
3
|
+
* `add-geniex-runtime`, design D1). The core binaries and any program that embeds the core as a
|
|
4
|
+
* library (`atc`) hand it the arguments after `geniex-host` before they parse their own commands,
|
|
5
|
+
* because `geniexHostCommand` starts the host as `<this program> geniex-host …`.
|
|
6
|
+
*
|
|
7
|
+
* Importing this file loads no `bun:*`: the library lives in a Worker the mode alone starts.
|
|
8
|
+
*/
|
|
9
|
+
import { detachableWriter } from '../../cli/io.js';
|
|
10
|
+
import { WorkerEngine, spawnGeniexWorker } from './host/engine.js';
|
|
11
|
+
import { lineIo, runGeniexHost } from './host/run.js';
|
|
12
|
+
/**
|
|
13
|
+
* Runs `geniex-host <argv…>` and returns its exit code (`EXIT` in `host/run.ts`). Lines go to this
|
|
14
|
+
* process's stdout and stderr through writers that go quiet instead of crashing the host when the
|
|
15
|
+
* core closed its end of a pipe (EPIPE).
|
|
16
|
+
*/
|
|
17
|
+
export async function runGeniexHostMain(argv, io = {
|
|
18
|
+
stdout: detachableWriter(process.stdout),
|
|
19
|
+
stderr: detachableWriter(process.stderr),
|
|
20
|
+
}) {
|
|
21
|
+
return runGeniexHost(argv, {
|
|
22
|
+
...lineIo(io),
|
|
23
|
+
startEngine: async () => new WorkerEngine(await spawnGeniexWorker()),
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=geniex-host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geniex-host.js","sourceRoot":"","sources":["../../../src/runtime/geniex/geniex-host.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAErD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,IAAuB,EACvB,KAAyE;IACvE,MAAM,EAAE,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAC;IACxC,MAAM,EAAE,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAC;CACzC;IAED,OAAO,aAAa,CAAC,IAAI,EAAE;QACzB,GAAG,MAAM,CAAC,EAAE,CAAC;QACb,WAAW,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI,YAAY,CAAC,MAAM,iBAAiB,EAAE,CAAC;KACrE,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The arguments of the hidden `geniex-host` mode (openspec change `add-geniex-runtime`, task 5.1).
|
|
3
|
+
* Core is the only caller, so the parse is strict: anything unknown is a bug on core's side.
|
|
4
|
+
*
|
|
5
|
+
* geniex-host probe --lib <build>
|
|
6
|
+
* geniex-host inspect <file | bundle folder>
|
|
7
|
+
* geniex-host serve --lib <build> --engine-version <v> --model <file | bundle folder>
|
|
8
|
+
* --plugin llama_cpp|qairt --device npu|gpu|cpu|hybrid [--mmproj <file>]
|
|
9
|
+
* --nctx <n> [--threads <n>] --max-tokens <n> --power-mode <mode> --port <p, 0 for any>
|
|
10
|
+
* --tmp <dir> --id <model id> [--reasoning]
|
|
11
|
+
*/
|
|
12
|
+
import type { GeniexDevice, GeniexPlugin } from '../../../contracts/index.js';
|
|
13
|
+
import type { GeniexPowerMode } from './library.js';
|
|
14
|
+
export type GeniexHostArgs = {
|
|
15
|
+
mode: 'probe';
|
|
16
|
+
lib: string;
|
|
17
|
+
} | {
|
|
18
|
+
mode: 'inspect';
|
|
19
|
+
path: string;
|
|
20
|
+
} | {
|
|
21
|
+
mode: 'serve';
|
|
22
|
+
/** The build directory, holding `lib/`. */
|
|
23
|
+
lib: string;
|
|
24
|
+
/** The build's GenieX version, checked against a bundle's `min_runtime_version`. */
|
|
25
|
+
engineVersion: string;
|
|
26
|
+
/** A GGUF file (`llama_cpp`) or an AI Hub bundle folder (`qairt`). */
|
|
27
|
+
model: string;
|
|
28
|
+
plugin: GeniexPlugin;
|
|
29
|
+
device: GeniexDevice;
|
|
30
|
+
/** `llama_cpp` only: the vision projector beside the GGUF file. */
|
|
31
|
+
mmproj?: string;
|
|
32
|
+
/** `n_ctx`, already cut to what the model allows. */
|
|
33
|
+
nCtx: number;
|
|
34
|
+
threads: number;
|
|
35
|
+
/** The default `max_tokens` of a request that names none. */
|
|
36
|
+
maxTokens: number;
|
|
37
|
+
/** The NPU power mode; ignored off the NPU. */
|
|
38
|
+
powerMode: GeniexPowerMode;
|
|
39
|
+
port: number;
|
|
40
|
+
/** Where request images are written for the library; created when missing. */
|
|
41
|
+
tmp: string;
|
|
42
|
+
/** The id `/v1/models` lists: core's session id. */
|
|
43
|
+
id: string;
|
|
44
|
+
/** Think by default (`model.yml` `reasoning`); a request may still turn it off. */
|
|
45
|
+
reasoning: boolean;
|
|
46
|
+
};
|
|
47
|
+
export declare class GeniexHostUsageError extends Error {
|
|
48
|
+
constructor(message: string);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Threads for the `llama_cpp` plugin when `--threads` is not given. Spike S3 on an 18-core X2 Elite
|
|
52
|
+
* (Qwen3 4B Q4_0, cpu): the plugin's own default decoded at 17.7 tok/s, 12 threads at 40.7 (conf's
|
|
53
|
+
* llama.cpp with `-t 12`: 39.5), 18 threads at 21.1 — the efficiency cores drag the pool down.
|
|
54
|
+
*/
|
|
55
|
+
export declare function defaultGeniexThreads(): number;
|
|
56
|
+
export declare function parseGeniexHostArgs(argv: readonly string[]): GeniexHostArgs;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The arguments of the hidden `geniex-host` mode (openspec change `add-geniex-runtime`, task 5.1).
|
|
3
|
+
* Core is the only caller, so the parse is strict: anything unknown is a bug on core's side.
|
|
4
|
+
*
|
|
5
|
+
* geniex-host probe --lib <build>
|
|
6
|
+
* geniex-host inspect <file | bundle folder>
|
|
7
|
+
* geniex-host serve --lib <build> --engine-version <v> --model <file | bundle folder>
|
|
8
|
+
* --plugin llama_cpp|qairt --device npu|gpu|cpu|hybrid [--mmproj <file>]
|
|
9
|
+
* --nctx <n> [--threads <n>] --max-tokens <n> --power-mode <mode> --port <p, 0 for any>
|
|
10
|
+
* --tmp <dir> --id <model id> [--reasoning]
|
|
11
|
+
*/
|
|
12
|
+
import { availableParallelism } from 'node:os';
|
|
13
|
+
import { parseArgs } from 'node:util';
|
|
14
|
+
import { GENIEX_DEVICES, GENIEX_PLUGINS } from '../../../contracts/index.js';
|
|
15
|
+
import { GENIEX_POWER_MODES } from './library.js';
|
|
16
|
+
export class GeniexHostUsageError extends Error {
|
|
17
|
+
constructor(message) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.name = 'GeniexHostUsageError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const required = (values, key) => {
|
|
23
|
+
const value = values[key];
|
|
24
|
+
if (typeof value !== 'string' || value === '')
|
|
25
|
+
throw new GeniexHostUsageError(`--${key} is required`);
|
|
26
|
+
return value;
|
|
27
|
+
};
|
|
28
|
+
const VERSION_RE = /^\d+\.\d+\.\d+$/;
|
|
29
|
+
function wholeNumber(values, key, min, max) {
|
|
30
|
+
const raw = required(values, key);
|
|
31
|
+
const value = Number(raw);
|
|
32
|
+
if (!Number.isSafeInteger(value) || value < min || value > max)
|
|
33
|
+
throw new GeniexHostUsageError(`--${key} ${raw} is not a whole number from ${min} to ${max}`);
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
function oneOf(values, key, known, said) {
|
|
37
|
+
const value = required(values, key);
|
|
38
|
+
if (!known.some((candidate) => candidate === value))
|
|
39
|
+
throw new GeniexHostUsageError(`--${key} ${value} is not ${said}`);
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Threads for the `llama_cpp` plugin when `--threads` is not given. Spike S3 on an 18-core X2 Elite
|
|
44
|
+
* (Qwen3 4B Q4_0, cpu): the plugin's own default decoded at 17.7 tok/s, 12 threads at 40.7 (conf's
|
|
45
|
+
* llama.cpp with `-t 12`: 39.5), 18 threads at 21.1 — the efficiency cores drag the pool down.
|
|
46
|
+
*/
|
|
47
|
+
export function defaultGeniexThreads() {
|
|
48
|
+
return Math.max(1, Math.min(12, availableParallelism()));
|
|
49
|
+
}
|
|
50
|
+
export function parseGeniexHostArgs(argv) {
|
|
51
|
+
const [mode, ...rest] = argv;
|
|
52
|
+
try {
|
|
53
|
+
if (mode === 'probe') {
|
|
54
|
+
const { values } = parseArgs({ args: rest, options: { lib: { type: 'string' } }, strict: true });
|
|
55
|
+
return { mode, lib: required(values, 'lib') };
|
|
56
|
+
}
|
|
57
|
+
if (mode === 'inspect') {
|
|
58
|
+
const { positionals } = parseArgs({ args: rest, options: {}, strict: true, allowPositionals: true });
|
|
59
|
+
if (positionals.length !== 1 || !positionals[0])
|
|
60
|
+
throw new GeniexHostUsageError('inspect takes one path');
|
|
61
|
+
return { mode, path: positionals[0] };
|
|
62
|
+
}
|
|
63
|
+
if (mode === 'serve') {
|
|
64
|
+
const { values } = parseArgs({
|
|
65
|
+
args: rest,
|
|
66
|
+
options: {
|
|
67
|
+
'lib': { type: 'string' },
|
|
68
|
+
'engine-version': { type: 'string' },
|
|
69
|
+
'model': { type: 'string' },
|
|
70
|
+
'plugin': { type: 'string' },
|
|
71
|
+
'device': { type: 'string' },
|
|
72
|
+
'mmproj': { type: 'string' },
|
|
73
|
+
'nctx': { type: 'string' },
|
|
74
|
+
'threads': { type: 'string' },
|
|
75
|
+
'max-tokens': { type: 'string' },
|
|
76
|
+
'power-mode': { type: 'string' },
|
|
77
|
+
'port': { type: 'string' },
|
|
78
|
+
'tmp': { type: 'string' },
|
|
79
|
+
'id': { type: 'string' },
|
|
80
|
+
'reasoning': { type: 'boolean' },
|
|
81
|
+
},
|
|
82
|
+
strict: true,
|
|
83
|
+
});
|
|
84
|
+
const lib = required(values, 'lib');
|
|
85
|
+
const engineVersion = required(values, 'engine-version');
|
|
86
|
+
if (!VERSION_RE.test(engineVersion))
|
|
87
|
+
throw new GeniexHostUsageError(`--engine-version ${engineVersion} is not X.Y.Z`);
|
|
88
|
+
const mmproj = values['mmproj'];
|
|
89
|
+
return {
|
|
90
|
+
mode,
|
|
91
|
+
lib,
|
|
92
|
+
engineVersion,
|
|
93
|
+
model: required(values, 'model'),
|
|
94
|
+
plugin: oneOf(values, 'plugin', GENIEX_PLUGINS, 'llama_cpp or qairt'),
|
|
95
|
+
device: oneOf(values, 'device', GENIEX_DEVICES, 'npu, gpu, cpu or hybrid'),
|
|
96
|
+
...(mmproj ? { mmproj } : {}),
|
|
97
|
+
nCtx: wholeNumber(values, 'nctx', 1, 16_777_216),
|
|
98
|
+
threads: values['threads'] === undefined ? defaultGeniexThreads() : wholeNumber(values, 'threads', 1, 1024),
|
|
99
|
+
maxTokens: wholeNumber(values, 'max-tokens', 1, 16_777_216),
|
|
100
|
+
powerMode: oneOf(values, 'power-mode', GENIEX_POWER_MODES, `one of ${GENIEX_POWER_MODES.join(', ')}`),
|
|
101
|
+
port: wholeNumber(values, 'port', 0, 65535),
|
|
102
|
+
tmp: required(values, 'tmp'),
|
|
103
|
+
id: required(values, 'id'),
|
|
104
|
+
reasoning: values['reasoning'] === true,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
if (error instanceof GeniexHostUsageError)
|
|
110
|
+
throw error;
|
|
111
|
+
throw new GeniexHostUsageError(error instanceof Error ? error.message : String(error));
|
|
112
|
+
}
|
|
113
|
+
throw new GeniexHostUsageError(`geniex-host: unknown mode ${JSON.stringify(mode ?? '')} (probe, inspect, serve)`);
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=args.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args.js","sourceRoot":"","sources":["../../../../src/runtime/geniex/host/args.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAE5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAkCjD,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAA;IACpC,CAAC;CACF;AAED,MAAM,QAAQ,GAAG,CAAC,MAA+B,EAAE,GAAW,EAAU,EAAE;IACxE,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;IACzB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE;QAAE,MAAM,IAAI,oBAAoB,CAAC,KAAK,GAAG,cAAc,CAAC,CAAA;IACrG,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED,MAAM,UAAU,GAAG,iBAAiB,CAAA;AAEpC,SAAS,WAAW,CAAC,MAA+B,EAAE,GAAW,EAAE,GAAW,EAAE,GAAW;IACzF,MAAM,GAAG,GAAG,QAAQ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