@yadsh/dsh-kv-persist 0.1.0
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/LICENSE +21 -0
- package/README.md +110 -0
- package/compatibility.json +16 -0
- package/cordis.patch.yml +4 -0
- package/docs/dsh-kv-persist.md +3311 -0
- package/lib/backends/llama-cpp/backend.d.ts +20 -0
- package/lib/backends/llama-cpp/backend.d.ts.map +1 -0
- package/lib/backends/llama-cpp/backend.js +37 -0
- package/lib/backends/llama-cpp/backend.js.map +1 -0
- package/lib/backends/llama-cpp/client.d.ts +31 -0
- package/lib/backends/llama-cpp/client.d.ts.map +1 -0
- package/lib/backends/llama-cpp/client.js +120 -0
- package/lib/backends/llama-cpp/client.js.map +1 -0
- package/lib/backends/llama-cpp/discovery.d.ts +20 -0
- package/lib/backends/llama-cpp/discovery.d.ts.map +1 -0
- package/lib/backends/llama-cpp/discovery.js +33 -0
- package/lib/backends/llama-cpp/discovery.js.map +1 -0
- package/lib/backends/llama-cpp/types.d.ts +30 -0
- package/lib/backends/llama-cpp/types.d.ts.map +1 -0
- package/lib/backends/llama-cpp/types.js +9 -0
- package/lib/backends/llama-cpp/types.js.map +1 -0
- package/lib/backends/types.d.ts +52 -0
- package/lib/backends/types.d.ts.map +1 -0
- package/lib/backends/types.js +6 -0
- package/lib/backends/types.js.map +1 -0
- package/lib/config.d.ts +258 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +169 -0
- package/lib/config.js.map +1 -0
- package/lib/coordinator/checkpoint-policy.d.ts +19 -0
- package/lib/coordinator/checkpoint-policy.d.ts.map +1 -0
- package/lib/coordinator/checkpoint-policy.js +40 -0
- package/lib/coordinator/checkpoint-policy.js.map +1 -0
- package/lib/coordinator/circuit-breaker.d.ts +29 -0
- package/lib/coordinator/circuit-breaker.d.ts.map +1 -0
- package/lib/coordinator/circuit-breaker.js +62 -0
- package/lib/coordinator/circuit-breaker.js.map +1 -0
- package/lib/coordinator/coordinator.d.ts +74 -0
- package/lib/coordinator/coordinator.d.ts.map +1 -0
- package/lib/coordinator/coordinator.js +542 -0
- package/lib/coordinator/coordinator.js.map +1 -0
- package/lib/coordinator/slot-lease.d.ts +22 -0
- package/lib/coordinator/slot-lease.d.ts.map +1 -0
- package/lib/coordinator/slot-lease.js +38 -0
- package/lib/coordinator/slot-lease.js.map +1 -0
- package/lib/coordinator/state-machine.d.ts +65 -0
- package/lib/coordinator/state-machine.d.ts.map +1 -0
- package/lib/coordinator/state-machine.js +40 -0
- package/lib/coordinator/state-machine.js.map +1 -0
- package/lib/errors.d.ts +82 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +113 -0
- package/lib/errors.js.map +1 -0
- package/lib/index.d.ts +26 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +17 -0
- package/lib/index.js.map +1 -0
- package/lib/logging/dsh-home.d.ts +13 -0
- package/lib/logging/dsh-home.d.ts.map +1 -0
- package/lib/logging/dsh-home.js +18 -0
- package/lib/logging/dsh-home.js.map +1 -0
- package/lib/logging/index.d.ts +10 -0
- package/lib/logging/index.d.ts.map +1 -0
- package/lib/logging/index.js +10 -0
- package/lib/logging/index.js.map +1 -0
- package/lib/logging/plugin-logger.d.ts +94 -0
- package/lib/logging/plugin-logger.d.ts.map +1 -0
- package/lib/logging/plugin-logger.js +397 -0
- package/lib/logging/plugin-logger.js.map +1 -0
- package/lib/observability/diagnostics.d.ts +37 -0
- package/lib/observability/diagnostics.d.ts.map +1 -0
- package/lib/observability/diagnostics.js +75 -0
- package/lib/observability/diagnostics.js.map +1 -0
- package/lib/observability/metrics.d.ts +38 -0
- package/lib/observability/metrics.d.ts.map +1 -0
- package/lib/observability/metrics.js +29 -0
- package/lib/observability/metrics.js.map +1 -0
- package/lib/service.d.ts +231 -0
- package/lib/service.d.ts.map +1 -0
- package/lib/service.js +232 -0
- package/lib/service.js.map +1 -0
- package/lib/snapshots/fingerprint.d.ts +53 -0
- package/lib/snapshots/fingerprint.d.ts.map +1 -0
- package/lib/snapshots/fingerprint.js +69 -0
- package/lib/snapshots/fingerprint.js.map +1 -0
- package/lib/snapshots/manifest.d.ts +51 -0
- package/lib/snapshots/manifest.d.ts.map +1 -0
- package/lib/snapshots/manifest.js +0 -0
- package/lib/snapshots/manifest.js.map +1 -0
- package/lib/snapshots/naming.d.ts +18 -0
- package/lib/snapshots/naming.d.ts.map +1 -0
- package/lib/snapshots/naming.js +33 -0
- package/lib/snapshots/naming.js.map +1 -0
- package/lib/snapshots/repository.d.ts +52 -0
- package/lib/snapshots/repository.d.ts.map +1 -0
- package/lib/snapshots/repository.js +270 -0
- package/lib/snapshots/repository.js.map +1 -0
- package/package.json +83 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* llama.cpp backend (SPEC §6, §12): maps the backend-neutral persistence
|
|
3
|
+
* interface onto the llama-server slot save/restore/erase API.
|
|
4
|
+
*/
|
|
5
|
+
import type { LlamaCppClientOptions } from "./client.js";
|
|
6
|
+
import type { BackendCapabilities, BackendEraseResult, BackendRestoreResult, BackendSaveResult, BackendSlot, KvPersistenceBackend } from "../types.js";
|
|
7
|
+
/** The only backend kind of v0.1 (SPEC §12). */
|
|
8
|
+
export declare const LLAMA_CPP_BACKEND_KIND = "llama.cpp";
|
|
9
|
+
export declare class LlamaCppBackend implements KvPersistenceBackend {
|
|
10
|
+
#private;
|
|
11
|
+
readonly kind = "llama.cpp";
|
|
12
|
+
constructor(clientOptions: LlamaCppClientOptions, requiredSlotId: number);
|
|
13
|
+
/** Health/capability probe (SPEC §34). */
|
|
14
|
+
probe(): Promise<BackendCapabilities>;
|
|
15
|
+
inspectSlots(): Promise<readonly BackendSlot[]>;
|
|
16
|
+
saveSlot(slotId: number, snapshotKey: string): Promise<BackendSaveResult>;
|
|
17
|
+
restoreSlot(slotId: number, snapshotKey: string): Promise<BackendRestoreResult>;
|
|
18
|
+
eraseSlot(slotId: number): Promise<BackendEraseResult>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=backend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../../src/backends/llama-cpp/backend.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGzD,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,WAAW,EACX,oBAAoB,EACrB,MAAM,aAAa,CAAC;AAErB,gDAAgD;AAChD,eAAO,MAAM,sBAAsB,cAAc,CAAC;AAElD,qBAAa,eAAgB,YAAW,oBAAoB;;IAC1D,QAAQ,CAAC,IAAI,eAA0B;gBAK3B,aAAa,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM;IAKxE,0CAA0C;IAC1C,KAAK,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAIrC,YAAY,IAAI,OAAO,CAAC,SAAS,WAAW,EAAE,CAAC;IAMzC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAKzE,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAK/E,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAI7D"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* llama.cpp backend (SPEC §6, §12): maps the backend-neutral persistence
|
|
3
|
+
* interface onto the llama-server slot save/restore/erase API.
|
|
4
|
+
*/
|
|
5
|
+
import { LlamaCppClient } from "./client.js";
|
|
6
|
+
import { probeServer } from "./discovery.js";
|
|
7
|
+
/** The only backend kind of v0.1 (SPEC §12). */
|
|
8
|
+
export const LLAMA_CPP_BACKEND_KIND = "llama.cpp";
|
|
9
|
+
export class LlamaCppBackend {
|
|
10
|
+
kind = LLAMA_CPP_BACKEND_KIND;
|
|
11
|
+
#client;
|
|
12
|
+
#expectation;
|
|
13
|
+
constructor(clientOptions, requiredSlotId) {
|
|
14
|
+
this.#client = new LlamaCppClient(clientOptions);
|
|
15
|
+
this.#expectation = { requiredSlotId };
|
|
16
|
+
}
|
|
17
|
+
/** Health/capability probe (SPEC §34). */
|
|
18
|
+
probe() {
|
|
19
|
+
return probeServer(this.#client, this.#expectation);
|
|
20
|
+
}
|
|
21
|
+
inspectSlots() {
|
|
22
|
+
return this.#client.inspectSlots().then((response) => response.slots.map((slot) => ({ id: slot.id })));
|
|
23
|
+
}
|
|
24
|
+
async saveSlot(slotId, snapshotKey) {
|
|
25
|
+
const result = await this.#client.saveSlot(slotId, snapshotKey);
|
|
26
|
+
return { success: result.success, bytes: null };
|
|
27
|
+
}
|
|
28
|
+
async restoreSlot(slotId, snapshotKey) {
|
|
29
|
+
const result = await this.#client.restoreSlot(slotId, snapshotKey);
|
|
30
|
+
return { success: result.success, nRestored: result.nRestored };
|
|
31
|
+
}
|
|
32
|
+
async eraseSlot(slotId) {
|
|
33
|
+
const result = await this.#client.eraseSlot(slotId);
|
|
34
|
+
return { success: result.success };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=backend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backend.js","sourceRoot":"","sources":["../../../src/backends/llama-cpp/backend.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAW7C,gDAAgD;AAChD,MAAM,CAAC,MAAM,sBAAsB,GAAG,WAAW,CAAC;AAElD,MAAM,OAAO,eAAe;IACjB,IAAI,GAAG,sBAAsB,CAAC;IAE9B,OAAO,CAAiB;IACxB,YAAY,CAAmB;IAExC,YAAY,aAAoC,EAAE,c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
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal HTTP client for the llama.cpp slots management API (SPEC §6).
|
|
3
|
+
*
|
|
4
|
+
* Every call is bounded by its own timeout (SPEC §59): persistence latency
|
|
5
|
+
* must never block or outlive the inference path. Only plugin-generated
|
|
6
|
+
* opaque filenames reach `action=save`/`action=restore` (SPEC §44).
|
|
7
|
+
*/
|
|
8
|
+
import type { LlamaCppEraseResponse, LlamaCppRestoreResponse, LlamaCppSaveResponse, LlamaCppSlotsResponse } from "./types.js";
|
|
9
|
+
export interface LlamaCppClientOptions {
|
|
10
|
+
readonly baseURL: string;
|
|
11
|
+
readonly apiKey: string | null;
|
|
12
|
+
readonly requestTimeoutMs: number;
|
|
13
|
+
/** Injectable fetch for tests. */
|
|
14
|
+
readonly fetchImpl?: typeof fetch;
|
|
15
|
+
}
|
|
16
|
+
/** Normalize the GET /slots payload (array or `{ slots: [...] }`). */
|
|
17
|
+
export declare function normalizeSlotsResponse(payload: unknown): LlamaCppSlotsResponse;
|
|
18
|
+
export declare class LlamaCppClient {
|
|
19
|
+
#private;
|
|
20
|
+
constructor(options: LlamaCppClientOptions);
|
|
21
|
+
get baseURL(): string;
|
|
22
|
+
/** GET /slots — slot discovery and health probing (SPEC §34). */
|
|
23
|
+
inspectSlots(timeoutMs?: number): Promise<LlamaCppSlotsResponse>;
|
|
24
|
+
/** POST /slots/{id}?action=save — persist slot KV state into a file. */
|
|
25
|
+
saveSlot(slotId: number, snapshotFilename: string, timeoutMs?: number): Promise<LlamaCppSaveResponse>;
|
|
26
|
+
/** POST /slots/{id}?action=restore — load a snapshot back into the slot. */
|
|
27
|
+
restoreSlot(slotId: number, snapshotFilename: string, timeoutMs?: number): Promise<LlamaCppRestoreResponse>;
|
|
28
|
+
/** POST /slots/{id}?action=erase — clear slot KV state. */
|
|
29
|
+
eraseSlot(slotId: number, timeoutMs?: number): Promise<LlamaCppEraseResponse>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/backends/llama-cpp/client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE9H,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,kCAAkC;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CACnC;AAuBD,sEAAsE;AACtE,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,qBAAqB,CAS9E;AAED,qBAAa,cAAc;;gBAMb,OAAO,EAAE,qBAAqB;IAO1C,IAAI,OAAO,IAAI,MAAM,CAEpB;IA8BD,iEAAiE;IAC3D,YAAY,CAAC,SAAS,GAAE,MAA+B,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAQ9F,wEAAwE;IAClE,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,SAAS,GAAE,MAA+B,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAenI,4EAA4E;IACtE,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,SAAS,GAAE,MAA+B,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAmBzI,2DAA2D;IACrD,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,GAAE,MAA+B,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAY5G"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal HTTP client for the llama.cpp slots management API (SPEC §6).
|
|
3
|
+
*
|
|
4
|
+
* Every call is bounded by its own timeout (SPEC §59): persistence latency
|
|
5
|
+
* must never block or outlive the inference path. Only plugin-generated
|
|
6
|
+
* opaque filenames reach `action=save`/`action=restore` (SPEC §44).
|
|
7
|
+
*/
|
|
8
|
+
import { KvBackendUnavailableError, KvEraseFailedError, KvRestoreFailedError, KvSaveFailedError } from "../../errors.js";
|
|
9
|
+
function isRecord(value) {
|
|
10
|
+
return typeof value === "object" && value !== null;
|
|
11
|
+
}
|
|
12
|
+
function optionalCount(value) {
|
|
13
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Defensive response parsing: llama.cpp builds differ; anything missing
|
|
17
|
+
* degrades to `null`/`false` rather than throwing parse errors.
|
|
18
|
+
*/
|
|
19
|
+
function parseJsonBody(text) {
|
|
20
|
+
try {
|
|
21
|
+
const parsed = JSON.parse(text);
|
|
22
|
+
return isRecord(parsed) || Array.isArray(parsed) ? parsed : null;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** Normalize the GET /slots payload (array or `{ slots: [...] }`). */
|
|
29
|
+
export function normalizeSlotsResponse(payload) {
|
|
30
|
+
const rawSlots = Array.isArray(payload) ? payload : (isRecord(payload) ? payload.slots : undefined);
|
|
31
|
+
if (!Array.isArray(rawSlots))
|
|
32
|
+
return { slots: [] };
|
|
33
|
+
const slots = rawSlots.flatMap((entry) => {
|
|
34
|
+
if (isRecord(entry) && typeof entry.id === "number")
|
|
35
|
+
return [{ id: entry.id }];
|
|
36
|
+
if (typeof entry === "number")
|
|
37
|
+
return [{ id: entry }];
|
|
38
|
+
return [];
|
|
39
|
+
});
|
|
40
|
+
return { slots };
|
|
41
|
+
}
|
|
42
|
+
export class LlamaCppClient {
|
|
43
|
+
#baseURL;
|
|
44
|
+
#apiKey;
|
|
45
|
+
#requestTimeoutMs;
|
|
46
|
+
#fetchImpl;
|
|
47
|
+
constructor(options) {
|
|
48
|
+
this.#baseURL = options.baseURL.replace(/\/+$/, "");
|
|
49
|
+
this.#apiKey = options.apiKey;
|
|
50
|
+
this.#requestTimeoutMs = options.requestTimeoutMs;
|
|
51
|
+
this.#fetchImpl = options.fetchImpl ?? fetch;
|
|
52
|
+
}
|
|
53
|
+
get baseURL() {
|
|
54
|
+
return this.#baseURL;
|
|
55
|
+
}
|
|
56
|
+
async #request(path, init, timeoutMs) {
|
|
57
|
+
const controller = new AbortController();
|
|
58
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
59
|
+
const headers = {};
|
|
60
|
+
if (this.#apiKey !== null)
|
|
61
|
+
headers["Authorization"] = `Bearer ${this.#apiKey}`;
|
|
62
|
+
if (init.body !== undefined)
|
|
63
|
+
headers["Content-Type"] = "application/json";
|
|
64
|
+
try {
|
|
65
|
+
const response = await this.#fetchImpl(`${this.#baseURL}${path}`, {
|
|
66
|
+
...init,
|
|
67
|
+
headers: { ...headers, ...init.headers },
|
|
68
|
+
signal: controller.signal,
|
|
69
|
+
});
|
|
70
|
+
const body = await response.text();
|
|
71
|
+
return { status: response.status, body };
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
throw new KvBackendUnavailableError(`llama.cpp server at ${this.#baseURL} is unreachable: ${String(error?.message ?? error)}`, { cause: error });
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
clearTimeout(timer);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** GET /slots — slot discovery and health probing (SPEC §34). */
|
|
81
|
+
async inspectSlots(timeoutMs = this.#requestTimeoutMs) {
|
|
82
|
+
const { status, body } = await this.#request("/slots", { method: "GET" }, timeoutMs);
|
|
83
|
+
if (status !== 200) {
|
|
84
|
+
throw new KvBackendUnavailableError(`GET /slots returned HTTP ${status}`);
|
|
85
|
+
}
|
|
86
|
+
return normalizeSlotsResponse(parseJsonBody(body));
|
|
87
|
+
}
|
|
88
|
+
/** POST /slots/{id}?action=save — persist slot KV state into a file. */
|
|
89
|
+
async saveSlot(slotId, snapshotFilename, timeoutMs = this.#requestTimeoutMs) {
|
|
90
|
+
const { status, body } = await this.#request(`/slots/${slotId}?action=save`, { method: "POST", body: JSON.stringify({ filepath: snapshotFilename }) }, timeoutMs);
|
|
91
|
+
const payload = parseJsonBody(body);
|
|
92
|
+
if (status !== 200 || !isRecord(payload) || payload.success !== true) {
|
|
93
|
+
throw new KvSaveFailedError(`save of slot ${slotId} failed (HTTP ${status}): ${body.slice(0, 200)}`);
|
|
94
|
+
}
|
|
95
|
+
return { success: true };
|
|
96
|
+
}
|
|
97
|
+
/** POST /slots/{id}?action=restore — load a snapshot back into the slot. */
|
|
98
|
+
async restoreSlot(slotId, snapshotFilename, timeoutMs = this.#requestTimeoutMs) {
|
|
99
|
+
const { status, body } = await this.#request(`/slots/${slotId}?action=restore`, { method: "POST", body: JSON.stringify({ filepath: snapshotFilename }) }, timeoutMs);
|
|
100
|
+
const payload = parseJsonBody(body);
|
|
101
|
+
if (status !== 200 || !isRecord(payload)) {
|
|
102
|
+
throw new KvRestoreFailedError(`restore of slot ${slotId} failed (HTTP ${status}): ${body.slice(0, 200)}`);
|
|
103
|
+
}
|
|
104
|
+
const nRestored = optionalCount(payload.n_restored) ?? optionalCount(payload.nRestored);
|
|
105
|
+
if (payload.success === false) {
|
|
106
|
+
throw new KvRestoreFailedError(`restore of slot ${slotId} reported success=false`);
|
|
107
|
+
}
|
|
108
|
+
return { success: true, nRestored };
|
|
109
|
+
}
|
|
110
|
+
/** POST /slots/{id}?action=erase — clear slot KV state. */
|
|
111
|
+
async eraseSlot(slotId, timeoutMs = this.#requestTimeoutMs) {
|
|
112
|
+
const { status, body } = await this.#request(`/slots/${slotId}?action=erase`, { method: "POST", body: JSON.stringify({}) }, timeoutMs);
|
|
113
|
+
const payload = parseJsonBody(body);
|
|
114
|
+
if (status !== 200 || (isRecord(payload) && payload.success === false)) {
|
|
115
|
+
throw new KvEraseFailedError(`erase of slot ${slotId} failed (HTTP ${status}): ${body.slice(0, 200)}`);
|
|
116
|
+
}
|
|
117
|
+
return { success: true };
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/backends/llama-cpp/client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAWzH,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5E,CAAC;AAED;;;GAGG;AACH,SAAS,aAAa,CAAC,IAAY;IACjC,IAAI,CAAC;QACH,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACzC,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAE,MAAkC,CAAC,CAAC,CAAC,IAAI,CAAC;IAChG,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,sBAAsB,CAAC,OAAgB;IACrD,MAAM,QAAQ,GAAY,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,C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AC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backend discovery / health probe (SPEC §34).
|
|
3
|
+
*
|
|
4
|
+
* The probe explicitly distinguishes "LLM endpoint alive" from "KV
|
|
5
|
+
* persistence supported": the plugin degrades to cold inference unless the
|
|
6
|
+
* slots endpoint answers with the expected geometry.
|
|
7
|
+
*/
|
|
8
|
+
import type { LlamaCppClient } from "./client.js";
|
|
9
|
+
import type { BackendCapabilities } from "../types.js";
|
|
10
|
+
export interface ProbeExpectation {
|
|
11
|
+
/** Slot that single-slot mode requires (usually 0). */
|
|
12
|
+
readonly requiredSlotId: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Probe the server: reachable, `/slots` available, expected slot present.
|
|
16
|
+
* Throws `KV_BACKEND_UNAVAILABLE` on any hard failure; capability details
|
|
17
|
+
* are returned otherwise.
|
|
18
|
+
*/
|
|
19
|
+
export declare function probeServer(client: LlamaCppClient, expectation: ProbeExpectation): Promise<BackendCapabilities>;
|
|
20
|
+
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../../src/backends/llama-cpp/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,MAAM,WAAW,gBAAgB;IAC/B,uDAAuD;IACvD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,cAAc,EACtB,WAAW,EAAE,gBAAgB,GAC5B,OAAO,CAAC,mBAAmB,CAAC,CAsB9B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backend discovery / health probe (SPEC §34).
|
|
3
|
+
*
|
|
4
|
+
* The probe explicitly distinguishes "LLM endpoint alive" from "KV
|
|
5
|
+
* persistence supported": the plugin degrades to cold inference unless the
|
|
6
|
+
* slots endpoint answers with the expected geometry.
|
|
7
|
+
*/
|
|
8
|
+
import { KvBackendUnavailableError } from "../../errors.js";
|
|
9
|
+
/**
|
|
10
|
+
* Probe the server: reachable, `/slots` available, expected slot present.
|
|
11
|
+
* Throws `KV_BACKEND_UNAVAILABLE` on any hard failure; capability details
|
|
12
|
+
* are returned otherwise.
|
|
13
|
+
*/
|
|
14
|
+
export async function probeServer(client, expectation) {
|
|
15
|
+
let response;
|
|
16
|
+
try {
|
|
17
|
+
response = await client.inspectSlots();
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
throw new KvBackendUnavailableError(`slot probing failed: ${String(error?.message ?? error)}`, { cause: error });
|
|
21
|
+
}
|
|
22
|
+
const slotIds = response.slots.map((slot) => slot.id);
|
|
23
|
+
if (!slotIds.includes(expectation.requiredSlotId)) {
|
|
24
|
+
throw new KvBackendUnavailableError(`server exposes slots [${slotIds.join(", ")}] but configured slot ${expectation.requiredSlotId} is missing; start llama-server with --slots/--parallel >= ${expectation.requiredSlotId + 1}`);
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
kind: "llama.cpp",
|
|
28
|
+
slotsAvailable: true,
|
|
29
|
+
slotIds,
|
|
30
|
+
serverVersion: null,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../../../src/backends/llama-cpp/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAS5D;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAsB,EACtB,WAA6B;IAE7B,IAAI,QAAQ,CAAC;IACb,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,MAAM,CAAC,YAAY,EAAE,CAAC;IACzC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,yBAAyB,CACjC,wBAAwB,MAAM,CAAE,KAAe,EAAE,OAAO,IAAI,KAAK,CAAC,EAAE,EACpE,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;IACJ,CAAC;IACD,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACtD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,cAAc,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,yBAAyB,CACjC,yBAAyB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAyB,WAAW,CAAC,cAAc,8DAA8D,WAAW,CAAC,cAAc,GAAG,CAAC,EAAE,CAC7L,CAAC;IACJ,CAAC;IACD,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,cAAc,EAAE,IAAI;QACpB,OAAO;QACP,aAAa,EAAE,IAAI;KACpB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire types of the llama.cpp `/slots` management API (SPEC §6).
|
|
3
|
+
*
|
|
4
|
+
* Parsing is defensive: fields the plugin cannot rely on across llama.cpp
|
|
5
|
+
* builds are optional, and unknown response shapes degrade to `null`
|
|
6
|
+
* instead of throwing.
|
|
7
|
+
*/
|
|
8
|
+
/** GET /slots response entry (defensive view). */
|
|
9
|
+
export interface LlamaCppSlotView {
|
|
10
|
+
readonly id: number;
|
|
11
|
+
}
|
|
12
|
+
/** Normalized GET /slots response. */
|
|
13
|
+
export interface LlamaCppSlotsResponse {
|
|
14
|
+
readonly slots: readonly LlamaCppSlotView[];
|
|
15
|
+
}
|
|
16
|
+
/** POST /slots/{id}?action=save response. */
|
|
17
|
+
export interface LlamaCppSaveResponse {
|
|
18
|
+
readonly success: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** POST /slots/{id}?action=restore response. */
|
|
21
|
+
export interface LlamaCppRestoreResponse {
|
|
22
|
+
readonly success: boolean;
|
|
23
|
+
/** Token count reported by the server, when present (SPEC §24). */
|
|
24
|
+
readonly nRestored: number | null;
|
|
25
|
+
}
|
|
26
|
+
/** POST /slots/{id}?action=erase response. */
|
|
27
|
+
export interface LlamaCppEraseResponse {
|
|
28
|
+
readonly success: boolean;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/backends/llama-cpp/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,kDAAkD;AAClD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAED,sCAAsC;AACtC,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,KAAK,EAAE,SAAS,gBAAgB,EAAE,CAAC;CAC7C;AAED,6CAA6C;AAC7C,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED,gDAAgD;AAChD,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,mEAAmE;IACnE,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED,8CAA8C;AAC9C,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire types of the llama.cpp `/slots` management API (SPEC §6).
|
|
3
|
+
*
|
|
4
|
+
* Parsing is defensive: fields the plugin cannot rely on across llama.cpp
|
|
5
|
+
* builds are optional, and unknown response shapes degrade to `null`
|
|
6
|
+
* instead of throwing.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/backends/llama-cpp/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backend abstraction (SPEC §12): the coordinator never issues `/slots`
|
|
3
|
+
* HTTP calls directly; it only talks to `KvPersistenceBackend`.
|
|
4
|
+
*/
|
|
5
|
+
/** Server-reported slot view (SPEC §19 input). */
|
|
6
|
+
export interface BackendSlot {
|
|
7
|
+
readonly id: number;
|
|
8
|
+
}
|
|
9
|
+
/** Static + probed capabilities of one backend instance. */
|
|
10
|
+
export interface BackendCapabilities {
|
|
11
|
+
readonly kind: string;
|
|
12
|
+
/** The slots endpoint answered and slot geometry looks usable. */
|
|
13
|
+
readonly slotsAvailable: boolean;
|
|
14
|
+
/** Slot ids the server currently exposes. */
|
|
15
|
+
readonly slotIds: readonly number[];
|
|
16
|
+
/** Raw server build/version string when discoverable, else null. */
|
|
17
|
+
readonly serverVersion: string | null;
|
|
18
|
+
}
|
|
19
|
+
export interface BackendSaveResult {
|
|
20
|
+
readonly success: boolean;
|
|
21
|
+
/** Server-reported snapshot size in bytes when discoverable. */
|
|
22
|
+
readonly bytes: number | null;
|
|
23
|
+
}
|
|
24
|
+
export interface BackendRestoreResult {
|
|
25
|
+
readonly success: boolean;
|
|
26
|
+
/** llama.cpp reports how many tokens were restored (SPEC §24). */
|
|
27
|
+
readonly nRestored: number | null;
|
|
28
|
+
}
|
|
29
|
+
export interface BackendEraseResult {
|
|
30
|
+
readonly success: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Backend-neutral persistence surface (SPEC §12). Core code never issues
|
|
34
|
+
* `/slots` HTTP calls; it only talks to this interface.
|
|
35
|
+
*/
|
|
36
|
+
export interface KvPersistenceBackend {
|
|
37
|
+
readonly kind: string;
|
|
38
|
+
/** Health/capability probe (SPEC §34). */
|
|
39
|
+
probe(signal?: AbortSignal): Promise<BackendCapabilities>;
|
|
40
|
+
/** List the physical slots the server currently exposes. */
|
|
41
|
+
inspectSlots(signal?: AbortSignal): Promise<readonly BackendSlot[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Persist slot KV state into a server-side snapshot file.
|
|
44
|
+
* `snapshotKey` is the opaque plugin-generated filename (SPEC §16, §44).
|
|
45
|
+
*/
|
|
46
|
+
saveSlot(slotId: number, snapshotKey: string, signal?: AbortSignal): Promise<BackendSaveResult>;
|
|
47
|
+
/** Load a snapshot back into the slot. */
|
|
48
|
+
restoreSlot(slotId: number, snapshotKey: string, signal?: AbortSignal): Promise<BackendRestoreResult>;
|
|
49
|
+
/** Clear the slot KV state. */
|
|
50
|
+
eraseSlot(slotId: number, signal?: AbortSignal): Promise<BackendEraseResult>;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/backends/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,kDAAkD;AAClD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAED,4DAA4D;AAC5D,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,6CAA6C;IAC7C,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,oEAAoE;IACpE,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CACvC;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,OAAO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