@almadar/std 16.245.0 → 16.246.1
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/behaviors/behaviors-registry.json +534 -176
- package/behaviors/lolo/agent/atoms/std-agent-context.lolo +9 -4
- package/behaviors/lolo/agent/atoms/std-agent-memory.lolo +9 -4
- package/behaviors/lolo/agent/atoms/std-agent-proposal.lolo +9 -4
- package/behaviors/lolo/agent/atoms/std-agent-session.lolo +9 -4
- package/behaviors/lolo/agent/atoms/std-agent-suggestions.lolo +9 -4
- package/behaviors/lolo/agent/atoms/std-agent-tool-loop.lolo +9 -4
- package/behaviors/lolo/agent/organisms/std-agent-assistant.lolo +9 -4
- package/behaviors/lolo/ui/core/atoms/ui-svg-flow.lolo +1 -1
- package/behaviors/lolo/ui/core/molecules/ui-import-progress.lolo +1 -1
- package/behaviors/lolo/ui/game/atoms/ui-canvas.lolo +3 -3
- package/behaviors/lolo/ui/game/atoms/ui-control-grid.lolo +3 -3
- package/behaviors/lolo/ui/game/atoms/ui-draw-group.lolo +1 -1
- package/behaviors/lolo/ui/game/atoms/ui-draw-mesh.lolo +1 -1
- package/behaviors/lolo/ui/game/atoms/ui-draw-skinned-mesh.lolo +3 -3
- package/behaviors/lolo/ui/learning/atoms/ui-biology-canvas.lolo +3 -3
- package/behaviors/lolo/ui/learning/atoms/ui-chemistry-canvas.lolo +3 -3
- package/behaviors/lolo/ui/learning/atoms/ui-physics-canvas.lolo +3 -3
- package/behaviors/lolo-behavior-contracts.json +1 -1
- package/behaviors/registry/agent/atoms/std-agent-context.orb +53 -67
- package/behaviors/registry/agent/atoms/std-agent-memory.orb +14 -51
- package/behaviors/registry/agent/atoms/std-agent-proposal.orb +50 -20
- package/behaviors/registry/agent/atoms/std-agent-session.orb +84 -91
- package/behaviors/registry/agent/atoms/std-agent-suggestions.orb +61 -24
- package/behaviors/registry/agent/atoms/std-agent-tool-loop.orb +61 -45
- package/behaviors/registry/agent/organisms/std-agent-assistant.orb +63 -26
- package/behaviors/registry/factory-signatures.json +1 -1
- package/behaviors/registry/ui/avl/atoms/ui-avl-state-machine.orb +2 -2
- package/behaviors/registry/ui/avl/atoms/ui-avl-transition-explainer.orb +2 -2
- package/behaviors/registry/ui/avl/atoms/ui-behavior-view.orb +2 -2
- package/behaviors/registry/ui/avl/atoms/ui-module-card.orb +2 -2
- package/behaviors/registry/ui/core/atoms/ui-svg-flow.orb +11 -4
- package/behaviors/registry/ui/core/molecules/ui-agent-chat-feed.orb +1 -1
- package/behaviors/registry/ui/core/molecules/ui-data-grid.orb +2 -2
- package/behaviors/registry/ui/core/molecules/ui-import-progress.orb +1 -1
- package/behaviors/registry/ui/core/molecules/ui-swipeable-row.orb +2 -2
- package/behaviors/registry/ui/core/molecules/ui-table-view.orb +2 -2
- package/behaviors/registry/ui/core/molecules/ui-wizard-container.orb +3 -3
- package/behaviors/registry/ui/core/organisms/ui-detail-panel.orb +4 -4
- package/behaviors/registry/ui/core/organisms/ui-form-section.orb +4 -4
- package/behaviors/registry/ui/core/organisms/ui-form.orb +4 -4
- package/behaviors/registry/ui/core/organisms/ui-state-machine-view.orb +136 -2
- package/behaviors/registry/ui/core/templates/ui-dashboard-layout.orb +3 -2
- package/behaviors/registry/ui/game/atoms/ui-canvas.orb +51 -18
- package/behaviors/registry/ui/game/atoms/ui-control-grid.orb +3 -3
- package/behaviors/registry/ui/game/atoms/ui-draw-group.orb +12 -5
- package/behaviors/registry/ui/game/atoms/ui-draw-mesh.orb +12 -5
- package/behaviors/registry/ui/game/atoms/ui-draw-skinned-mesh.orb +39 -14
- package/behaviors/registry/ui/learning/atoms/ui-biology-canvas.orb +51 -18
- package/behaviors/registry/ui/learning/atoms/ui-chemistry-canvas.orb +51 -18
- package/behaviors/registry/ui/learning/atoms/ui-physics-canvas.orb +51 -18
- package/canonical-operators.json +5 -5
- package/dist/behaviors/exports-reader.js +228 -218
- package/dist/behaviors/functions/index.d.ts +8 -8
- package/dist/behaviors/functions/index.js +228 -218
- package/dist/behaviors/index.js +274 -255
- package/dist/behaviors/knob-embeddings.d.ts +16 -2
- package/dist/behaviors/knob-embeddings.js +47 -38
- package/dist/behaviors/query.js +228 -218
- package/dist/behaviors-embeddings.hash.json +3 -3
- package/dist/behaviors-embeddings.json +1 -1
- package/dist/behaviors-registry.json +534 -176
- package/dist/index.js +278 -259
- package/dist/knob-embeddings.hash.json +3 -3
- package/dist/knob-embeddings.json +7 -3
- package/dist/modules/array.js +4 -4
- package/dist/modules/index.js +4 -4
- package/dist/registry/factory-signatures.json +1 -1
- package/dist/registry.js +4 -4
- package/package.json +2 -2
|
@@ -15,11 +15,15 @@
|
|
|
15
15
|
*
|
|
16
16
|
* @packageDocumentation
|
|
17
17
|
*/
|
|
18
|
+
/** Each knob's vector as int8, all views over one shared buffer — the on-disk
|
|
19
|
+
* bytes, never widened to a float per dimension (that was 8× the memory and
|
|
20
|
+
* OOM-killed the builder server). The per-vector scale is dropped, so a
|
|
21
|
+
* vector here is a direction: compare it with cosine similarity only. */
|
|
18
22
|
interface KnobEmbeddingsManifest {
|
|
19
23
|
version: string;
|
|
20
24
|
model: string;
|
|
21
25
|
dimensions: number;
|
|
22
|
-
vectors: Record<string,
|
|
26
|
+
vectors: Readonly<Record<string, Int8Array>>;
|
|
23
27
|
}
|
|
24
28
|
/** Int8-quantized vector: `d` = base64 of one signed byte per dimension,
|
|
25
29
|
* `s` = per-vector max-abs scale; value = byte × s ÷ 127. Landed when the
|
|
@@ -43,6 +47,16 @@ interface StoredKnobEmbeddingsFile {
|
|
|
43
47
|
table?: StoredKnobVector[];
|
|
44
48
|
keys?: Record<string, number>;
|
|
45
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Decode a parsed `knob-embeddings.json` into int8 vectors over one buffer
|
|
52
|
+
* sized (stored vectors × dimensions). Interned table entries are written
|
|
53
|
+
* once and shared by every key that points at them. Returns `null` for a
|
|
54
|
+
* file missing its model, dimensions or vectors, or holding a vector whose
|
|
55
|
+
* length is not `dimensions`.
|
|
56
|
+
*/
|
|
57
|
+
declare function decodeKnobEmbeddingsFile(parsed: Partial<StoredKnobEmbeddingsFile>): KnobEmbeddingsManifest | null;
|
|
58
|
+
/** Read and decode a `knob-embeddings.json` at `path`; `null` when it is missing or invalid. */
|
|
59
|
+
declare function readKnobEmbeddingsFile(path: string): Promise<KnobEmbeddingsManifest | null>;
|
|
46
60
|
/**
|
|
47
61
|
* Return the typed knob embeddings manifest. Returns `null` when the
|
|
48
62
|
* JSON sidecar is missing (older std checkout, or a dev build with
|
|
@@ -51,4 +65,4 @@ interface StoredKnobEmbeddingsFile {
|
|
|
51
65
|
*/
|
|
52
66
|
declare function getKnobEmbeddings(): Promise<KnobEmbeddingsManifest | null>;
|
|
53
67
|
|
|
54
|
-
export { type KnobEmbeddingsManifest, type QuantizedKnobVector, type StoredKnobEmbeddingsFile, type StoredKnobVector, getKnobEmbeddings };
|
|
68
|
+
export { type KnobEmbeddingsManifest, type QuantizedKnobVector, type StoredKnobEmbeddingsFile, type StoredKnobVector, decodeKnobEmbeddingsFile, getKnobEmbeddings, readKnobEmbeddingsFile };
|
|
@@ -23,29 +23,56 @@ async function resolveStdDataDirUncached() {
|
|
|
23
23
|
|
|
24
24
|
// behaviors/knob-embeddings.ts
|
|
25
25
|
var pending2 = null;
|
|
26
|
-
function
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
function writeVector(stored, slot) {
|
|
27
|
+
if ("d" in stored) {
|
|
28
|
+
const bytes = Buffer.from(stored.d, "base64");
|
|
29
|
+
if (bytes.length !== slot.length) return false;
|
|
30
|
+
slot.set(new Int8Array(bytes.buffer, bytes.byteOffset, bytes.length));
|
|
31
|
+
return true;
|
|
32
32
|
}
|
|
33
|
-
return
|
|
33
|
+
if (stored.length !== slot.length) return false;
|
|
34
|
+
let maxAbs = 0;
|
|
35
|
+
for (const v of stored) maxAbs = Math.max(maxAbs, Math.abs(v));
|
|
36
|
+
for (let i = 0; i < stored.length; i++) {
|
|
37
|
+
slot[i] = maxAbs === 0 ? 0 : Math.round(stored[i] * 127 / maxAbs);
|
|
38
|
+
}
|
|
39
|
+
return true;
|
|
34
40
|
}
|
|
35
|
-
function
|
|
41
|
+
function decodeKnobEmbeddingsFile(parsed) {
|
|
42
|
+
const interned = typeof parsed?.table === "object" && typeof parsed?.keys === "object";
|
|
43
|
+
const nonInterned = typeof parsed?.vectors === "object" && parsed.vectors !== null;
|
|
44
|
+
if (typeof parsed?.model !== "string" || typeof parsed?.dimensions !== "number" || !interned && !nonInterned) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const dims = parsed.dimensions;
|
|
48
|
+
const stored = interned ? parsed.table ?? [] : Object.values(parsed.vectors ?? {});
|
|
49
|
+
const backing = new Int8Array(stored.length * dims);
|
|
50
|
+
const slots = [];
|
|
51
|
+
for (let i = 0; i < stored.length; i++) {
|
|
52
|
+
const slot = backing.subarray(i * dims, (i + 1) * dims);
|
|
53
|
+
if (!writeVector(stored[i], slot)) return null;
|
|
54
|
+
slots.push(slot);
|
|
55
|
+
}
|
|
36
56
|
const vectors = {};
|
|
37
|
-
if (
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (vec) vectors[key] = vec;
|
|
57
|
+
if (interned) {
|
|
58
|
+
for (const [key, idx] of Object.entries(parsed.keys ?? {})) {
|
|
59
|
+
const slot = slots[idx];
|
|
60
|
+
if (slot) vectors[key] = slot;
|
|
42
61
|
}
|
|
43
|
-
|
|
62
|
+
} else {
|
|
63
|
+
Object.keys(parsed.vectors ?? {}).forEach((key, i) => {
|
|
64
|
+
vectors[key] = slots[i];
|
|
65
|
+
});
|
|
44
66
|
}
|
|
45
|
-
|
|
46
|
-
|
|
67
|
+
return { version: parsed.version ?? "", model: parsed.model, dimensions: dims, vectors };
|
|
68
|
+
}
|
|
69
|
+
async function readKnobEmbeddingsFile(path) {
|
|
70
|
+
try {
|
|
71
|
+
const { readFileSync } = await import('fs');
|
|
72
|
+
return decodeKnobEmbeddingsFile(JSON.parse(readFileSync(path, "utf-8")));
|
|
73
|
+
} catch {
|
|
74
|
+
return null;
|
|
47
75
|
}
|
|
48
|
-
return vectors;
|
|
49
76
|
}
|
|
50
77
|
function loadManifest() {
|
|
51
78
|
pending2 ?? (pending2 = loadManifestUncached().then((m) => {
|
|
@@ -55,29 +82,11 @@ function loadManifest() {
|
|
|
55
82
|
return pending2;
|
|
56
83
|
}
|
|
57
84
|
async function loadManifestUncached() {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const { resolve } = await import('path');
|
|
61
|
-
const dir = await resolveStdDataDir();
|
|
62
|
-
const raw = readFileSync(resolve(dir, "knob-embeddings.json"), "utf-8");
|
|
63
|
-
const parsed = JSON.parse(raw);
|
|
64
|
-
const interned = typeof parsed?.table === "object" && typeof parsed?.keys === "object";
|
|
65
|
-
const nonInterned = typeof parsed?.vectors === "object" && parsed.vectors !== null;
|
|
66
|
-
if (typeof parsed?.model !== "string" || typeof parsed?.dimensions !== "number" || !interned && !nonInterned) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
return {
|
|
70
|
-
version: parsed.version,
|
|
71
|
-
model: parsed.model,
|
|
72
|
-
dimensions: parsed.dimensions,
|
|
73
|
-
vectors: reconstructVectors(parsed)
|
|
74
|
-
};
|
|
75
|
-
} catch {
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
85
|
+
const { resolve } = await import('path');
|
|
86
|
+
return readKnobEmbeddingsFile(resolve(await resolveStdDataDir(), "knob-embeddings.json"));
|
|
78
87
|
}
|
|
79
88
|
async function getKnobEmbeddings() {
|
|
80
89
|
return loadManifest();
|
|
81
90
|
}
|
|
82
91
|
|
|
83
|
-
export { getKnobEmbeddings };
|
|
92
|
+
export { decodeKnobEmbeddingsFile, getKnobEmbeddings, readKnobEmbeddingsFile };
|