@camstack/system 1.2.46 → 1.2.48
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/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/dist/builtins/alerts/alerts.addon.js +1 -1
- package/dist/builtins/alerts/alerts.addon.mjs +1 -1
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
- package/dist/builtins/console-logging/index.js +1 -1
- package/dist/builtins/console-logging/index.mjs +1 -1
- package/dist/builtins/core-blocks/core-blocks.addon.js +1 -1
- package/dist/builtins/core-blocks/core-blocks.addon.mjs +1 -1
- package/dist/builtins/device-manager/device-manager.addon.js +1 -1
- package/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
- package/dist/builtins/doorbell/virtual-doorbell.addon.js +1 -1
- package/dist/builtins/doorbell/virtual-doorbell.addon.mjs +1 -1
- package/dist/builtins/hub-forwarder/index.js +1 -1
- package/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/dist/builtins/local-auth/local-auth.addon.js +1 -1
- package/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
- package/dist/builtins/local-network/local-network.addon.js +1 -1
- package/dist/builtins/local-network/local-network.addon.mjs +1 -1
- package/dist/builtins/loki-logging/index.js +1 -1
- package/dist/builtins/loki-logging/index.mjs +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/dist/builtins/platform-probe/index.js +1 -1
- package/dist/builtins/platform-probe/index.mjs +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/dist/builtins/snapshot/index.js +1 -1
- package/dist/builtins/snapshot/index.mjs +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.d.ts +10 -0
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +516 -1
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +516 -1
- package/dist/builtins/sqlite-storage/vector-index.d.ts +172 -0
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/dist/builtins/system-config/system-config.addon.js +1 -1
- package/dist/builtins/system-config/system-config.addon.mjs +1 -1
- package/dist/builtins/winston-logging/index.js +1 -1
- package/dist/builtins/winston-logging/index.mjs +1 -1
- package/dist/{dist-DzSJwsDj.mjs → dist-C7rPTQLR.mjs} +59 -1
- package/dist/{dist-CSMouGGo.js → dist-CH0DyAwh.js} +82 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { IScopedLogger, VectorFilter, VectorItem, VectorMatch, VectorMetadata, VectorMetric } from '@camstack/types';
|
|
2
|
+
/** Metadata keys promoted to real, indexable columns. */
|
|
3
|
+
export declare const PROMOTED_COLUMNS: readonly ["deviceId", "timestamp", "className", "modelId"];
|
|
4
|
+
/** Ceiling on rows compared in one query, so a pathological index cannot wedge the runner. */
|
|
5
|
+
export declare const MAX_SCAN_ROWS = 200000;
|
|
6
|
+
/** Per-index declaration kept in memory; re-declared on boot by each caller. */
|
|
7
|
+
export interface VectorIndexSpec {
|
|
8
|
+
readonly dim: number;
|
|
9
|
+
readonly metric: VectorMetric;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The slice of `SqliteSettingsBackend` this index uses.
|
|
13
|
+
*
|
|
14
|
+
* Narrowed on purpose: the real backend satisfies it structurally and a test
|
|
15
|
+
* fake implements exactly these four methods without a cast. Depending on the
|
|
16
|
+
* whole backend would have forced an `as any` in the fake, which is how a fake
|
|
17
|
+
* ends up quietly diverging from the surface it stands in for.
|
|
18
|
+
*/
|
|
19
|
+
export interface VectorBackend {
|
|
20
|
+
declareCollection(input: {
|
|
21
|
+
collection: string;
|
|
22
|
+
columns: readonly TableColumn[];
|
|
23
|
+
indexes?: readonly TableIndex[];
|
|
24
|
+
}): Promise<void>;
|
|
25
|
+
set(input: {
|
|
26
|
+
collection: string;
|
|
27
|
+
key: string;
|
|
28
|
+
value: unknown;
|
|
29
|
+
}): Promise<void>;
|
|
30
|
+
delete(input: {
|
|
31
|
+
collection: string;
|
|
32
|
+
key: string;
|
|
33
|
+
}): Promise<void>;
|
|
34
|
+
query(input: {
|
|
35
|
+
collection: string;
|
|
36
|
+
filter?: StoreQueryFilter;
|
|
37
|
+
}): Promise<readonly StoreRecord[]>;
|
|
38
|
+
}
|
|
39
|
+
/** Column spec accepted by `declareCollection`. */
|
|
40
|
+
export interface TableColumn {
|
|
41
|
+
readonly name: string;
|
|
42
|
+
readonly type: 'TEXT' | 'INTEGER' | 'REAL' | 'JSON' | 'BOOLEAN';
|
|
43
|
+
readonly primaryKey?: boolean;
|
|
44
|
+
readonly notNull?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/** Index spec accepted by `declareCollection`. */
|
|
47
|
+
export interface TableIndex {
|
|
48
|
+
readonly name: string;
|
|
49
|
+
readonly columns: readonly string[];
|
|
50
|
+
}
|
|
51
|
+
/** The filter shape this index sends to the store. */
|
|
52
|
+
export interface StoreQueryFilter {
|
|
53
|
+
readonly where?: Record<string, unknown>;
|
|
54
|
+
readonly whereBetween?: Record<string, [number, number]>;
|
|
55
|
+
readonly orderBy?: {
|
|
56
|
+
field: string;
|
|
57
|
+
direction: 'asc' | 'desc';
|
|
58
|
+
};
|
|
59
|
+
readonly limit?: number;
|
|
60
|
+
}
|
|
61
|
+
/** A row as the store returns it. */
|
|
62
|
+
export interface StoreRecord {
|
|
63
|
+
readonly id: string;
|
|
64
|
+
readonly data: Record<string, unknown>;
|
|
65
|
+
}
|
|
66
|
+
export interface SqliteVectorIndexDeps {
|
|
67
|
+
readonly store: VectorBackend;
|
|
68
|
+
readonly logger: IScopedLogger;
|
|
69
|
+
}
|
|
70
|
+
interface StoredRow {
|
|
71
|
+
readonly vector: string;
|
|
72
|
+
readonly deviceId: number | null;
|
|
73
|
+
readonly timestamp: number | null;
|
|
74
|
+
readonly className: string | null;
|
|
75
|
+
readonly modelId: string | null;
|
|
76
|
+
readonly extra: VectorMetadata;
|
|
77
|
+
}
|
|
78
|
+
export declare class SqliteVectorIndex {
|
|
79
|
+
private readonly store;
|
|
80
|
+
private readonly logger;
|
|
81
|
+
private readonly specs;
|
|
82
|
+
constructor(deps: SqliteVectorIndexDeps);
|
|
83
|
+
/**
|
|
84
|
+
* Load persisted index declarations. Call once at startup, BEFORE serving:
|
|
85
|
+
* without it every method on an existing index throws until a write
|
|
86
|
+
* re-declares it.
|
|
87
|
+
*/
|
|
88
|
+
loadIndexRegistry(): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Idempotent. Re-declaring an index with a DIFFERENT dim throws rather than
|
|
91
|
+
* wiping: silently dropping a populated index because a caller shipped a new
|
|
92
|
+
* model would destroy history that cannot be rebuilt.
|
|
93
|
+
*/
|
|
94
|
+
declareIndex(index: string, dim: number, metric: VectorMetric): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Resolve an index's spec, recovering it from stored rows when the registry
|
|
97
|
+
* has no entry.
|
|
98
|
+
*
|
|
99
|
+
* The recovery is not belt-and-braces, it is required: indexes created before
|
|
100
|
+
* the registry existed have rows and no declaration, and so would be
|
|
101
|
+
* permanently unqueryable — which is exactly how this was found, with 8,494
|
|
102
|
+
* live vectors that `stats` refused to look at. The dimension is derivable
|
|
103
|
+
* from any stored vector, so derive it and persist it rather than demanding
|
|
104
|
+
* the caller redeclare. The metric is NOT derivable and falls back to
|
|
105
|
+
* `cosine`, which is what every current caller declares.
|
|
106
|
+
*/
|
|
107
|
+
private resolveSpec;
|
|
108
|
+
/** Upsert items, refusing any whose vector length disagrees with the index. */
|
|
109
|
+
upsert(index: string, items: readonly VectorItem[]): Promise<{
|
|
110
|
+
upserted: number;
|
|
111
|
+
rejected: number;
|
|
112
|
+
}>;
|
|
113
|
+
/** Exhaustive ranked search over the rows a prefilter admits. */
|
|
114
|
+
query(params: {
|
|
115
|
+
index: string;
|
|
116
|
+
vector: string;
|
|
117
|
+
topK: number;
|
|
118
|
+
minScore?: number;
|
|
119
|
+
filter?: VectorFilter;
|
|
120
|
+
}): Promise<{
|
|
121
|
+
matches: VectorMatch[];
|
|
122
|
+
scanned: number;
|
|
123
|
+
truncated: boolean;
|
|
124
|
+
}>;
|
|
125
|
+
/**
|
|
126
|
+
* Metadata for the given ids, WITHOUT decoding their vectors.
|
|
127
|
+
*
|
|
128
|
+
* The caller is a best-of gate comparing confidences, so the vector is dead
|
|
129
|
+
* weight on that path — reading it would reintroduce exactly the per-row cost
|
|
130
|
+
* this index exists to remove. Missing ids are absent from the result rather
|
|
131
|
+
* than present with an empty metadata object.
|
|
132
|
+
*/
|
|
133
|
+
getByIds(index: string, ids: readonly string[]): Promise<Array<{
|
|
134
|
+
id: string;
|
|
135
|
+
metadata: VectorMetadata;
|
|
136
|
+
}>>;
|
|
137
|
+
deleteByIds(index: string, ids: readonly string[]): Promise<number>;
|
|
138
|
+
deleteByFilter(index: string, filter: VectorFilter): Promise<number>;
|
|
139
|
+
stats(index: string): Promise<{
|
|
140
|
+
backend: string;
|
|
141
|
+
count: number;
|
|
142
|
+
dim: number;
|
|
143
|
+
metric: VectorMetric;
|
|
144
|
+
exact: boolean;
|
|
145
|
+
}>;
|
|
146
|
+
}
|
|
147
|
+
/** Split caller metadata into promoted columns plus a verbatim remainder. */
|
|
148
|
+
export declare function splitMetadata(metadata: VectorMetadata): {
|
|
149
|
+
deviceId: number | null;
|
|
150
|
+
timestamp: number | null;
|
|
151
|
+
className: string | null;
|
|
152
|
+
modelId: string | null;
|
|
153
|
+
extra: VectorMetadata;
|
|
154
|
+
};
|
|
155
|
+
/** Rebuild the caller's metadata from the promoted columns plus the remainder. */
|
|
156
|
+
export declare function rebuildMetadata(row: StoredRow): VectorMetadata;
|
|
157
|
+
/** The part of a filter SQLite can apply: promoted columns only. */
|
|
158
|
+
export declare function buildSqlFilter(filter: VectorFilter | undefined): {
|
|
159
|
+
where?: Record<string, unknown>;
|
|
160
|
+
whereBetween?: Record<string, [number, number]>;
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Apply the clauses SQL could not.
|
|
164
|
+
*
|
|
165
|
+
* A filter key that is not a promoted column lives inside the `extra` JSON
|
|
166
|
+
* blob, so it is checked here in JS. It is applied rather than ignored — an
|
|
167
|
+
* unapplied filter returns rows the caller will treat as matches.
|
|
168
|
+
*/
|
|
169
|
+
export declare function passesUnpushedFilter(row: StoredRow, filter: VectorFilter | undefined): boolean;
|
|
170
|
+
/** Score two vectors under the index's metric. Higher is nearer in every case. */
|
|
171
|
+
export declare function scoreFor(metric: VectorMetric, a: Float32Array, b: Float32Array): number;
|
|
172
|
+
export {};
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-CH0DyAwh.js");
|
|
7
7
|
let node_path = require("node:path");
|
|
8
8
|
node_path = require_chunk.__toESM(node_path);
|
|
9
9
|
let node_fs_promises = require("node:fs/promises");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Mt as parseJsonObject, f as StorageLocationTypeSchema, ft as BaseAddon, rt as storageCapability, tt as settingsStoreCapability } from "../../dist-C7rPTQLR.mjs";
|
|
2
2
|
import * as path$1 from "node:path";
|
|
3
3
|
import * as fs from "node:fs/promises";
|
|
4
4
|
import { buildStorageLocationRegistry } from "@camstack/system";
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-CH0DyAwh.js");
|
|
7
7
|
//#region src/builtins/system-config/system-config.addon.ts
|
|
8
8
|
/**
|
|
9
9
|
* Built-in `system-config` addon — Phase 4 of the settings redesign.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dt as errMsg, ft as BaseAddon, kt as hydrateSchema } from "../../dist-C7rPTQLR.mjs";
|
|
2
2
|
//#region src/builtins/system-config/system-config.addon.ts
|
|
3
3
|
/**
|
|
4
4
|
* Built-in `system-config` addon — Phase 4 of the settings redesign.
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-CH0DyAwh.js");
|
|
7
7
|
const require_formatter = require("../../formatter-DqAKDlvN.js");
|
|
8
8
|
let node_path = require("node:path");
|
|
9
9
|
node_path = require_chunk.__toESM(node_path);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { W as logDestinationCapability, ft as BaseAddon } from "../../dist-C7rPTQLR.mjs";
|
|
2
2
|
import { t as formatLogLine } from "../../formatter-B7qW8bPJ.mjs";
|
|
3
3
|
import * as path$1 from "node:path";
|
|
4
4
|
import path from "node:path";
|
|
@@ -16162,6 +16162,24 @@ var VectorDeleteByFilterInputSchema = z.object({
|
|
|
16162
16162
|
filter: VectorFilterSchema
|
|
16163
16163
|
});
|
|
16164
16164
|
var VectorDeleteResultSchema = z.object({ deleted: z.number() });
|
|
16165
|
+
var VectorGetInputSchema = z.object({
|
|
16166
|
+
index: z.string(),
|
|
16167
|
+
ids: z.array(z.string())
|
|
16168
|
+
});
|
|
16169
|
+
/**
|
|
16170
|
+
* Metadata for the requested ids, WITHOUT their vectors.
|
|
16171
|
+
*
|
|
16172
|
+
* The only caller is a best-of gate that compares a candidate's confidence
|
|
16173
|
+
* against the stored one, and shipping 512 floats back to answer "is 0.91 >
|
|
16174
|
+
* 0.87" would undo the point of the compact encoding. Ids with no row are
|
|
16175
|
+
* simply absent — a caller distinguishing "not stored" from "stored" reads the
|
|
16176
|
+
* length, and a null placeholder would invite a `?? 0` that treats a missing
|
|
16177
|
+
* row as confidence zero.
|
|
16178
|
+
*/
|
|
16179
|
+
var VectorGetResultSchema = z.object({ items: z.array(z.object({
|
|
16180
|
+
id: z.string(),
|
|
16181
|
+
metadata: VectorMetadataSchema
|
|
16182
|
+
})) });
|
|
16165
16183
|
var VectorStatsInputSchema = z.object({ index: z.string() });
|
|
16166
16184
|
var VectorStatsResultSchema = z.object({
|
|
16167
16185
|
/** Provider id, so an operator can tell brute force from an ANN index. */
|
|
@@ -16184,6 +16202,8 @@ var vectorStoreCapability = {
|
|
|
16184
16202
|
declareIndex: method(VectorDeclareIndexInputSchema, z.void(), { kind: "mutation" }),
|
|
16185
16203
|
upsert: method(VectorUpsertInputSchema, VectorUpsertResultSchema, { kind: "mutation" }),
|
|
16186
16204
|
query: method(VectorQueryInputSchema, VectorQueryResultSchema),
|
|
16205
|
+
/** Metadata by id, no vectors — see {@link VectorGetResultSchema}. */
|
|
16206
|
+
getByIds: method(VectorGetInputSchema, VectorGetResultSchema),
|
|
16187
16207
|
deleteByIds: method(VectorDeleteInputSchema, VectorDeleteResultSchema, { kind: "mutation" }),
|
|
16188
16208
|
deleteByFilter: method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, { kind: "mutation" }),
|
|
16189
16209
|
stats: method(VectorStatsInputSchema, VectorStatsResultSchema)
|
|
@@ -29898,6 +29918,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
|
|
|
29898
29918
|
addonId: null,
|
|
29899
29919
|
access: "delete"
|
|
29900
29920
|
},
|
|
29921
|
+
"vectorStore.getByIds": {
|
|
29922
|
+
capName: "vector-store",
|
|
29923
|
+
capScope: "system",
|
|
29924
|
+
addonId: null,
|
|
29925
|
+
access: "view"
|
|
29926
|
+
},
|
|
29901
29927
|
"vectorStore.query": {
|
|
29902
29928
|
capName: "vector-store",
|
|
29903
29929
|
capScope: "system",
|
|
@@ -30172,6 +30198,38 @@ TimelapseRuleInputSchema.extend({
|
|
|
30172
30198
|
createdAt: z.number(),
|
|
30173
30199
|
updatedAt: z.number()
|
|
30174
30200
|
});
|
|
30201
|
+
/** Cosine similarity between two embedding vectors */
|
|
30202
|
+
function cosineSimilarity(a, b) {
|
|
30203
|
+
if (a.length !== b.length) return 0;
|
|
30204
|
+
let dotProduct = 0;
|
|
30205
|
+
let normA = 0;
|
|
30206
|
+
let normB = 0;
|
|
30207
|
+
for (let i = 0; i < a.length; i++) {
|
|
30208
|
+
dotProduct += a[i] * b[i];
|
|
30209
|
+
normA += a[i] * a[i];
|
|
30210
|
+
normB += b[i] * b[i];
|
|
30211
|
+
}
|
|
30212
|
+
const denom = Math.sqrt(normA) * Math.sqrt(normB);
|
|
30213
|
+
return denom === 0 ? 0 : dotProduct / denom;
|
|
30214
|
+
}
|
|
30215
|
+
/**
|
|
30216
|
+
* Decode base64 little-endian Float32 back into a vector.
|
|
30217
|
+
*
|
|
30218
|
+
* Throws on a byte length that is not a multiple of 4 — a truncated vector
|
|
30219
|
+
* would otherwise silently rank against a shorter one and produce a plausible
|
|
30220
|
+
* score, which is worse than an error.
|
|
30221
|
+
*/
|
|
30222
|
+
function decodeVectorBase64(encoded) {
|
|
30223
|
+
const buffer = Buffer.from(encoded, "base64");
|
|
30224
|
+
if (buffer.byteLength % 4 !== 0) throw new Error(`decodeVectorBase64: ${buffer.byteLength} bytes is not a whole number of Float32 values`);
|
|
30225
|
+
const out = new Float32Array(buffer.byteLength / 4);
|
|
30226
|
+
for (let i = 0; i < out.length; i += 1) out[i] = buffer.readFloatLE(i * 4);
|
|
30227
|
+
return out;
|
|
30228
|
+
}
|
|
30229
|
+
/** Vector length implied by a base64 payload, without decoding it. */
|
|
30230
|
+
function vectorDimFromBase64(encoded) {
|
|
30231
|
+
return Math.floor(Buffer.from(encoded, "base64").byteLength / 4);
|
|
30232
|
+
}
|
|
30175
30233
|
/**
|
|
30176
30234
|
* Scores all applicable inference backends for the given hardware.
|
|
30177
30235
|
*
|
|
@@ -30286,4 +30344,4 @@ function enumerateInferenceDevices(hw) {
|
|
|
30286
30344
|
return out;
|
|
30287
30345
|
}
|
|
30288
30346
|
//#endregion
|
|
30289
|
-
export {
|
|
30347
|
+
export { scoreRuntimes as $, enumerateInferenceDevices as A, isDeviceConfigCap as At, isVoidInput as B, cosineSimilarity as C, asNumber as Ct, deviceStateCapability as D, emitReadiness as Dt, deviceManagerCapability as E, emitDownForOwnedCaps as Et, filesystemBrowseCapability as F, resolveCapMount as Ft, logLevelAtMost as G, lifecycleJobSchema as H, getByPath as I, scopeKey as It, normalizeUnit as J, looseSchema as K, isArrayOutputSchema as L, sleep as Lt, enumerateSchemaFields as M, parseJsonObject as Mt, evaluateLinkExpression as N, parseJsonUnknown as Nt, deviceStatusCapability as O, expandCapMethods as Ot, extractNestedAddonId as P, readinessKey as Pt, procedureAuthKey as Q, isCollectionArrayMethod as R, EventCategory as Rt, coreBlocksCapability as S, asJsonObject as St, decodeVectorBase64 as T, createEvent as Tt, localNetworkCapability as U, kebabToCamel as V, logDestinationCapability as W, parseStreamParamsFormPatch as X, objectInputDeclaresAddonId as Y, platformProbeCapability as Z, alertsCapability as _, DeviceRole as _t, CAP_NAMES_WITH_STATUS as a, streamQualityLabel as at, backupCapability as b, ReadinessTimeoutError as bt, METHOD_ACCESS_MAP as c, validateExpressionSource as ct, ScopedTokenSchema as d, errMsg as dt, setByPath as et, StorageLocationTypeSchema as f, BaseAddon as ft, addonWidgetsCapability as g, DeviceFeature as gt, addonSettingsCapability as h, DEVICE_STATUS_METHOD as ht, BatteryStatusSchema as i, storageProviderCapability as it, enumerateItemArrayFields as j, nodePin as jt, doorbellCapability as k, hydrateSchema as kt, RUNTIME_DEFAULTS as l, vectorDimFromBase64 as lt, addonPagesCapability as m, DEVICE_SETTINGS_CONTRIBUTION_METHODS as mt, AlertSchema as n, snapshotCapability as nt, CoreBlockSchema as o, toExpressionValue as ot, UserRecordSchema as p, DATAPLANE_SECRET_HEADER as pt, metricsProviderCapability as q, ApiKeyRecordSchema as r, storageCapability as rt, DeviceStatusSchema as s, userManagementCapability as st, ALL_CAPABILITY_DEFINITIONS as t, settingsStoreCapability as tt, STREAM_PROFILE_META as u, vectorStoreCapability as ut, applyTransform as v, DeviceType as vt, dataStoreProviderCapability as w, asString as wt, buildStreamParamsConfigSchema as x, WELL_KNOWN_TAB_MAP as xt, authProviderCapability as y, ReadinessRegistry as yt, isObjectInput as z };
|
|
@@ -16162,6 +16162,24 @@ var VectorDeleteByFilterInputSchema = zod.z.object({
|
|
|
16162
16162
|
filter: VectorFilterSchema
|
|
16163
16163
|
});
|
|
16164
16164
|
var VectorDeleteResultSchema = zod.z.object({ deleted: zod.z.number() });
|
|
16165
|
+
var VectorGetInputSchema = zod.z.object({
|
|
16166
|
+
index: zod.z.string(),
|
|
16167
|
+
ids: zod.z.array(zod.z.string())
|
|
16168
|
+
});
|
|
16169
|
+
/**
|
|
16170
|
+
* Metadata for the requested ids, WITHOUT their vectors.
|
|
16171
|
+
*
|
|
16172
|
+
* The only caller is a best-of gate that compares a candidate's confidence
|
|
16173
|
+
* against the stored one, and shipping 512 floats back to answer "is 0.91 >
|
|
16174
|
+
* 0.87" would undo the point of the compact encoding. Ids with no row are
|
|
16175
|
+
* simply absent — a caller distinguishing "not stored" from "stored" reads the
|
|
16176
|
+
* length, and a null placeholder would invite a `?? 0` that treats a missing
|
|
16177
|
+
* row as confidence zero.
|
|
16178
|
+
*/
|
|
16179
|
+
var VectorGetResultSchema = zod.z.object({ items: zod.z.array(zod.z.object({
|
|
16180
|
+
id: zod.z.string(),
|
|
16181
|
+
metadata: VectorMetadataSchema
|
|
16182
|
+
})) });
|
|
16165
16183
|
var VectorStatsInputSchema = zod.z.object({ index: zod.z.string() });
|
|
16166
16184
|
var VectorStatsResultSchema = zod.z.object({
|
|
16167
16185
|
/** Provider id, so an operator can tell brute force from an ANN index. */
|
|
@@ -16184,6 +16202,8 @@ var vectorStoreCapability = {
|
|
|
16184
16202
|
declareIndex: method(VectorDeclareIndexInputSchema, zod.z.void(), { kind: "mutation" }),
|
|
16185
16203
|
upsert: method(VectorUpsertInputSchema, VectorUpsertResultSchema, { kind: "mutation" }),
|
|
16186
16204
|
query: method(VectorQueryInputSchema, VectorQueryResultSchema),
|
|
16205
|
+
/** Metadata by id, no vectors — see {@link VectorGetResultSchema}. */
|
|
16206
|
+
getByIds: method(VectorGetInputSchema, VectorGetResultSchema),
|
|
16187
16207
|
deleteByIds: method(VectorDeleteInputSchema, VectorDeleteResultSchema, { kind: "mutation" }),
|
|
16188
16208
|
deleteByFilter: method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, { kind: "mutation" }),
|
|
16189
16209
|
stats: method(VectorStatsInputSchema, VectorStatsResultSchema)
|
|
@@ -29898,6 +29918,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
|
|
|
29898
29918
|
addonId: null,
|
|
29899
29919
|
access: "delete"
|
|
29900
29920
|
},
|
|
29921
|
+
"vectorStore.getByIds": {
|
|
29922
|
+
capName: "vector-store",
|
|
29923
|
+
capScope: "system",
|
|
29924
|
+
addonId: null,
|
|
29925
|
+
access: "view"
|
|
29926
|
+
},
|
|
29901
29927
|
"vectorStore.query": {
|
|
29902
29928
|
capName: "vector-store",
|
|
29903
29929
|
capScope: "system",
|
|
@@ -30172,6 +30198,38 @@ TimelapseRuleInputSchema.extend({
|
|
|
30172
30198
|
createdAt: zod.z.number(),
|
|
30173
30199
|
updatedAt: zod.z.number()
|
|
30174
30200
|
});
|
|
30201
|
+
/** Cosine similarity between two embedding vectors */
|
|
30202
|
+
function cosineSimilarity(a, b) {
|
|
30203
|
+
if (a.length !== b.length) return 0;
|
|
30204
|
+
let dotProduct = 0;
|
|
30205
|
+
let normA = 0;
|
|
30206
|
+
let normB = 0;
|
|
30207
|
+
for (let i = 0; i < a.length; i++) {
|
|
30208
|
+
dotProduct += a[i] * b[i];
|
|
30209
|
+
normA += a[i] * a[i];
|
|
30210
|
+
normB += b[i] * b[i];
|
|
30211
|
+
}
|
|
30212
|
+
const denom = Math.sqrt(normA) * Math.sqrt(normB);
|
|
30213
|
+
return denom === 0 ? 0 : dotProduct / denom;
|
|
30214
|
+
}
|
|
30215
|
+
/**
|
|
30216
|
+
* Decode base64 little-endian Float32 back into a vector.
|
|
30217
|
+
*
|
|
30218
|
+
* Throws on a byte length that is not a multiple of 4 — a truncated vector
|
|
30219
|
+
* would otherwise silently rank against a shorter one and produce a plausible
|
|
30220
|
+
* score, which is worse than an error.
|
|
30221
|
+
*/
|
|
30222
|
+
function decodeVectorBase64(encoded) {
|
|
30223
|
+
const buffer = Buffer.from(encoded, "base64");
|
|
30224
|
+
if (buffer.byteLength % 4 !== 0) throw new Error(`decodeVectorBase64: ${buffer.byteLength} bytes is not a whole number of Float32 values`);
|
|
30225
|
+
const out = new Float32Array(buffer.byteLength / 4);
|
|
30226
|
+
for (let i = 0; i < out.length; i += 1) out[i] = buffer.readFloatLE(i * 4);
|
|
30227
|
+
return out;
|
|
30228
|
+
}
|
|
30229
|
+
/** Vector length implied by a base64 payload, without decoding it. */
|
|
30230
|
+
function vectorDimFromBase64(encoded) {
|
|
30231
|
+
return Math.floor(Buffer.from(encoded, "base64").byteLength / 4);
|
|
30232
|
+
}
|
|
30175
30233
|
/**
|
|
30176
30234
|
* Scores all applicable inference backends for the given hardware.
|
|
30177
30235
|
*
|
|
@@ -30502,6 +30560,12 @@ Object.defineProperty(exports, "coreBlocksCapability", {
|
|
|
30502
30560
|
return coreBlocksCapability;
|
|
30503
30561
|
}
|
|
30504
30562
|
});
|
|
30563
|
+
Object.defineProperty(exports, "cosineSimilarity", {
|
|
30564
|
+
enumerable: true,
|
|
30565
|
+
get: function() {
|
|
30566
|
+
return cosineSimilarity;
|
|
30567
|
+
}
|
|
30568
|
+
});
|
|
30505
30569
|
Object.defineProperty(exports, "createEvent", {
|
|
30506
30570
|
enumerable: true,
|
|
30507
30571
|
get: function() {
|
|
@@ -30514,6 +30578,12 @@ Object.defineProperty(exports, "dataStoreProviderCapability", {
|
|
|
30514
30578
|
return dataStoreProviderCapability;
|
|
30515
30579
|
}
|
|
30516
30580
|
});
|
|
30581
|
+
Object.defineProperty(exports, "decodeVectorBase64", {
|
|
30582
|
+
enumerable: true,
|
|
30583
|
+
get: function() {
|
|
30584
|
+
return decodeVectorBase64;
|
|
30585
|
+
}
|
|
30586
|
+
});
|
|
30517
30587
|
Object.defineProperty(exports, "deviceManagerCapability", {
|
|
30518
30588
|
enumerable: true,
|
|
30519
30589
|
get: function() {
|
|
@@ -30814,3 +30884,15 @@ Object.defineProperty(exports, "validateExpressionSource", {
|
|
|
30814
30884
|
return validateExpressionSource;
|
|
30815
30885
|
}
|
|
30816
30886
|
});
|
|
30887
|
+
Object.defineProperty(exports, "vectorDimFromBase64", {
|
|
30888
|
+
enumerable: true,
|
|
30889
|
+
get: function() {
|
|
30890
|
+
return vectorDimFromBase64;
|
|
30891
|
+
}
|
|
30892
|
+
});
|
|
30893
|
+
Object.defineProperty(exports, "vectorStoreCapability", {
|
|
30894
|
+
enumerable: true,
|
|
30895
|
+
get: function() {
|
|
30896
|
+
return vectorStoreCapability;
|
|
30897
|
+
}
|
|
30898
|
+
});
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("./chunk-Cek0wNdY.js");
|
|
3
|
-
const require_dist = require("./dist-
|
|
3
|
+
const require_dist = require("./dist-CH0DyAwh.js");
|
|
4
4
|
const require_model_download_service = require("./model-download-service-hf0ookyy.js");
|
|
5
5
|
const require_manifest_python_deps = require("./manifest-python-deps-BqE5j0-O.js");
|
|
6
6
|
const require_resource_monitor = require("./resource-monitor-DNNomR-i.js");
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as __toCommonJS, i as __require, n as __esmMin, o as __toESM$1, r as __exportAll, t as __commonJSMin$1 } from "./chunk-CNf5ZN-e.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { B as isVoidInput, Ct as asNumber, Et as emitDownForOwnedCaps, Ft as resolveCapMount, G as logLevelAtMost, H as lifecycleJobSchema, It as scopeKey, K as looseSchema, L as isArrayOutputSchema, Mt as parseJsonObject, Nt as parseJsonUnknown$1, Ot as expandCapMethods, P as extractNestedAddonId, Pt as readinessKey, Q as procedureAuthKey, R as isCollectionArrayMethod, Rt as EventCategory$1, St as asJsonObject$1, Tt as createEvent, V as kebabToCamel, Y as objectInputDeclaresAddonId, bt as ReadinessTimeoutError, c as METHOD_ACCESS_MAP, dt as errMsg$1, h as addonSettingsCapability, ht as DEVICE_STATUS_METHOD, l as RUNTIME_DEFAULTS, mt as DEVICE_SETTINGS_CONTRIBUTION_METHODS, pt as DATAPLANE_SECRET_HEADER$1, t as ALL_CAPABILITY_DEFINITIONS, wt as asString$1, yt as ReadinessRegistry, z as isObjectInput } from "./dist-C7rPTQLR.mjs";
|
|
3
3
|
import { a as downloadModel, c as getModelFilePath, d as contentTypeFor, f as createAuthenticatedFileServer, h as resolveFilePath, i as downloadFile, l as isModelDownloaded, m as parseTokenizedUrl, n as collectModelFiles, o as ensureModel, p as parseRangeHeader, r as deleteModelFromDisk, s as fetchJson, t as ModelDownloadService, u as createFileDataPlaneHandler } from "./model-download-service-Cp9f4dk6.mjs";
|
|
4
4
|
import { $ as buildNativeCapProxy, A as createHubCapForwardService, B as AGENT_CAP_FWD_ACTION, C as brokerTransportLink, Ct as resolveAddonClass, D as localProviderLink, E as ipcParentLink, F as createUdsLogger, G as callWithServiceDiscovery, H as CapRouteResolver, I as createUdsLoggerWithControl, J as UdsLocalTransportServer, K as createLocalTransport, L as LocalChildClient, M as createUdsEventBridge, N as createUdsEventBus, O as HUB_CAP_FWD_ACTION, P as udsChildLogToWorkerEntry, Q as encodeFrame, R as LocalChildRegistry, S as brokerCallForCap, St as runNpm, T as ipcChildLink, U as CapRouteError, V as AGENT_CAP_FWD_SERVICE, W as classifyCapRoute, X as localEndpointPath, Y as SocketChannel, Z as FrameDecoder, _ as createKernelHwAccel, _t as CapabilityHandle, a as getWorkerDeviceRegistry, b as __resetCapUsageRegistryForTests, bt as installManifestNativeDeps, c as setHubConnected, ct as NATIVE_PROVIDER_SERVICE_INFIX, d as getBrokerEventBus, dt as capBareAction, et as buildUdsNativeCapProxy, f as getMoleculerEventStats, ft as capServiceName, g as AddonDepsManager, gt as DeviceRegistry, h as subscribePassthrough, ht as serializeTypedArrays, i as createUdsAddonContext, it as mountNativeCapService, j as createParentUnownedCallHandler, k as HUB_CAP_FWD_SERVICE, l as EVENT_TOPIC_PREFIX, lt as capActionName, m as setNodeEventInterest, mt as deserializeTypedArrays, n as adaptBrokerToCluster, o as getOrInitReadinessRegistry, ot as createAddonService, p as registerEventBusService, pt as parseCapAction, q as UdsLocalTransportClient, r as createAddonContext, s as getOrInitReadinessRegistryForClient, st as validateProviderRegistrations, t as installManifestPythonDeps, tt as createBrokerDeviceManagerApi, u as clusterEventTopic, ut as capActionSuffix, v as resolveHwAccel, vt as CapabilityUnavailableError, w as buildLinkChain, wt as createAddonDataPlaneFacility, x as getCapUsageRegistry, xt as resolveNpmInvocation, y as CapUsageRegistry, yt as copyBundledNativeModules, z as UDS_NO_ROUTE_PREFIX } from "./manifest-python-deps-Ck4-9K9m.mjs";
|
|
5
5
|
import { n as getSinglePidStats, t as getPidStats } from "./resource-monitor-BkP504Vq.mjs";
|