@nyte-ai/host 0.0.18 → 0.0.19
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/THIRD-PARTY-NOTICES.md +66 -0
- package/dist/chunks/{canvas-preview-5hxat7hh.js → canvas-preview-11nadadc.js} +8 -6
- package/dist/chunks/{canvas-preview-rp6fz0w5.js → canvas-preview-2jwbe14k.js} +5 -5
- package/dist/chunks/{canvas-preview-m02v4yy6.js → canvas-preview-55s0y68g.js} +3 -2
- package/dist/chunks/{canvas-preview-xn10d4f8.js → canvas-preview-5ekjx6sw.js} +9 -4
- package/dist/chunks/{canvas-preview-75db60xy.js → canvas-preview-8xc0vn7v.js} +5 -4
- package/dist/chunks/{canvas-preview-zn2d0k9d.js → canvas-preview-af86jz8t.js} +14 -6
- package/dist/chunks/{canvas-preview-d9wwhbtz.js → canvas-preview-aq5j4p25.js} +1 -1
- package/dist/chunks/{canvas-preview-j1tnf51w.js → canvas-preview-b2v8wfnz.js} +1 -1
- package/dist/chunks/canvas-preview-befkjea2.js +60 -0
- package/dist/chunks/canvas-preview-bxnqt8cd.js +103 -0
- package/dist/chunks/{canvas-preview-vax9ne4e.js → canvas-preview-cawy6vbz.js} +22 -11
- package/dist/chunks/{canvas-preview-senpjwep.js → canvas-preview-crmzxxt8.js} +3 -3
- package/dist/chunks/{canvas-preview-ymgz0937.js → canvas-preview-drctegz4.js} +8 -4
- package/dist/chunks/{canvas-preview-yrfz2ak6.js → canvas-preview-e3vnkkc5.js} +6 -6
- package/dist/chunks/canvas-preview-ec2mt7es.js +108 -0
- package/dist/chunks/{canvas-preview-1ta3avah.js → canvas-preview-fxa0rfb0.js} +10 -5
- package/dist/chunks/{canvas-preview-8xgt67ka.js → canvas-preview-g5fkjs34.js} +1 -1
- package/dist/chunks/{canvas-preview-g3qj3y3k.js → canvas-preview-jeddjex8.js} +13 -3
- package/dist/chunks/{canvas-preview-0nrnbt76.js → canvas-preview-k1yg4fgp.js} +199 -125
- package/dist/chunks/canvas-preview-kp75gb63.js +141 -0
- package/dist/chunks/{canvas-preview-ewgspmsd.js → canvas-preview-n2a35zv5.js} +1 -1
- package/dist/chunks/{canvas-preview-h8hshnff.js → canvas-preview-pkzqg96v.js} +1 -1
- package/dist/chunks/{canvas-preview-evh92ywd.js → canvas-preview-tnqe7k0b.js} +15 -10
- package/dist/chunks/{canvas-preview-ehf3vp31.js → canvas-preview-vm9zdp2t.js} +45 -58
- package/dist/chunks/{canvas-preview-76fwvd6e.js → canvas-preview-w54ymtb3.js} +1 -1
- package/dist/chunks/canvas-preview-y5y6ghaw.js +125 -0
- package/dist/chunks/{canvas-preview-98aj5p34.js → canvas-preview-ycepb05s.js} +1 -1
- package/dist/src/canvas-preview.js +7 -3
- package/dist/src/deploy/cloudflare/worker.js +1 -1
- package/dist/src/deploy/vercel/server/routes/[...].js +2 -2
- package/dist/src/deploy/vercel/server/utils/host.js +1 -1
- package/dist/src/deploy/vercel/server/workflows/drive.js +3 -3
- package/dist/src/images/exif.d.ts +1 -0
- package/dist/src/images/exif.js +6 -0
- package/dist/src/images/node.d.ts +37 -0
- package/dist/src/images/node.js +12 -0
- package/dist/src/images/photon.d.ts +3 -0
- package/dist/src/images/photon.js +7 -0
- package/dist/src/images/worker.d.ts +1 -0
- package/dist/src/images/worker.js +23 -0
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js +23 -22
- package/dist/src/listen-fetch.js +3 -3
- package/dist/src/listen.js +4 -4
- package/dist/src/local/command.d.ts +5 -0
- package/dist/src/local/command.js +6 -2
- package/dist/src/local/files.js +2 -2
- package/dist/src/local/git-watch.d.ts +1 -1
- package/dist/src/local/git-watch.js +1 -1
- package/dist/src/local/git.js +3 -3
- package/dist/src/local/github.js +2 -2
- package/dist/src/local/jobs.d.ts +1 -1
- package/dist/src/local/jobs.js +2 -1
- package/dist/src/local/provider.js +9 -9
- package/dist/src/local/snapshots.js +2 -2
- package/dist/src/local/worktrees.js +2 -2
- package/dist/src/mcp/connect.d.ts +0 -13
- package/dist/src/mcp/connect.js +1 -1
- package/dist/src/mcp/hub.js +2 -2
- package/dist/src/open.d.ts +2 -30
- package/dist/src/open.js +20 -18
- package/dist/src/serve/binding.js +1 -1
- package/dist/src/serve/handler.js +2 -2
- package/dist/src/sqlite.d.ts +2 -1
- package/dist/src/sqlite.js +4 -3
- package/dist/src/store-usage.js +4 -1
- package/dist/src/usage-history.d.ts +54 -0
- package/dist/src/usage-history.js +14 -0
- package/dist/src/usage-service.d.ts +2 -1
- package/dist/src/usage-service.js +7 -3
- package/dist/src/usage-worker.js +8 -4
- package/dist/src/usage.d.ts +150 -27
- package/dist/src/usage.js +12 -2
- package/package.json +16 -8
- package/src/canvas-preview.ts +4 -3
- package/src/images/exif.ts +69 -0
- package/src/images/node.ts +163 -0
- package/src/images/photon.ts +141 -0
- package/src/images/worker.ts +29 -0
- package/src/index.ts +19 -1
- package/src/local/command.ts +64 -12
- package/src/local/files.ts +8 -3
- package/src/local/git-watch.ts +16 -6
- package/src/local/git.ts +7 -2
- package/src/local/github.ts +3 -4
- package/src/local/jobs.ts +55 -69
- package/src/local/snapshots.ts +4 -2
- package/src/local/worktrees.ts +4 -4
- package/src/mcp/connect.ts +1 -14
- package/src/open.ts +16 -36
- package/src/serve/binding.ts +4 -3
- package/src/sqlite.ts +33 -8
- package/src/store-usage.ts +5 -2
- package/src/usage-history.ts +219 -0
- package/src/usage-service.ts +12 -3
- package/src/usage.ts +251 -176
- package/dist/chunks/canvas-preview-a3yw0j70.js +0 -72
- package/dist/chunks/canvas-preview-azg56359.js +0 -68
- package/dist/src/store-owner.d.ts +0 -15
- package/dist/src/store-owner.js +0 -9
- package/src/store-owner.ts +0 -98
|
@@ -3,25 +3,25 @@ import {
|
|
|
3
3
|
} from "./canvas-preview-0nq75h9k.js";
|
|
4
4
|
import {
|
|
5
5
|
localFiles2
|
|
6
|
-
} from "./canvas-preview-
|
|
6
|
+
} from "./canvas-preview-drctegz4.js";
|
|
7
7
|
import {
|
|
8
8
|
localGit2
|
|
9
|
-
} from "./canvas-preview-
|
|
9
|
+
} from "./canvas-preview-5ekjx6sw.js";
|
|
10
10
|
import {
|
|
11
11
|
localGitHub2
|
|
12
|
-
} from "./canvas-preview-
|
|
12
|
+
} from "./canvas-preview-8xc0vn7v.js";
|
|
13
13
|
import {
|
|
14
14
|
folderIdentity2
|
|
15
15
|
} from "./canvas-preview-1sq7z9jq.js";
|
|
16
16
|
import {
|
|
17
17
|
localExec2
|
|
18
|
-
} from "./canvas-preview-
|
|
18
|
+
} from "./canvas-preview-vm9zdp2t.js";
|
|
19
19
|
import {
|
|
20
20
|
localSnapshots2
|
|
21
|
-
} from "./canvas-preview-
|
|
21
|
+
} from "./canvas-preview-crmzxxt8.js";
|
|
22
22
|
import {
|
|
23
23
|
localWorktrees2
|
|
24
|
-
} from "./canvas-preview-
|
|
24
|
+
} from "./canvas-preview-2jwbe14k.js";
|
|
25
25
|
|
|
26
26
|
// src/local/provider.ts
|
|
27
27
|
import { constants, realpathSync } from "node:fs";
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import {
|
|
2
|
+
exifOrientation2
|
|
3
|
+
} from "./canvas-preview-befkjea2.js";
|
|
4
|
+
|
|
5
|
+
// src/images/photon.ts
|
|
6
|
+
import {
|
|
7
|
+
PhotonImage,
|
|
8
|
+
SamplingFilter,
|
|
9
|
+
fliph,
|
|
10
|
+
flipv,
|
|
11
|
+
initSync,
|
|
12
|
+
resize
|
|
13
|
+
} from "@silvia-odwyer/photon/photon_rs.js";
|
|
14
|
+
var INLINE_IMAGE_TYPES = new Set([
|
|
15
|
+
"image/png",
|
|
16
|
+
"image/jpeg",
|
|
17
|
+
"image/gif",
|
|
18
|
+
"image/webp"
|
|
19
|
+
]);
|
|
20
|
+
var JPEG_QUALITIES = [80, 70, 55, 40];
|
|
21
|
+
function photonImages2(wasm) {
|
|
22
|
+
initSync({ module: wasm });
|
|
23
|
+
return {
|
|
24
|
+
prepare: (bytes, mimeType, limits) => Promise.resolve(prepare(bytes, mimeType, limits))
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function prepare(bytes, mimeType, limits) {
|
|
28
|
+
const orientation = exifOrientation2(bytes);
|
|
29
|
+
let image;
|
|
30
|
+
try {
|
|
31
|
+
image = PhotonImage.new_from_byteslice(bytes);
|
|
32
|
+
if (INLINE_IMAGE_TYPES.has(mimeType) && orientation === 1 && image.get_width() <= limits.maxWidth && image.get_height() <= limits.maxHeight && base64Length(bytes.byteLength) <= limits.maxBase64Bytes)
|
|
33
|
+
return { data: bytes.toBase64(), mimeType };
|
|
34
|
+
if (orientation >= 5) {
|
|
35
|
+
const upright = transposed(image, orientation);
|
|
36
|
+
image.free();
|
|
37
|
+
image = undefined;
|
|
38
|
+
image = new PhotonImage(upright.pixels, upright.width, upright.height);
|
|
39
|
+
} else if (orientation !== 1) {
|
|
40
|
+
if (orientation !== 4)
|
|
41
|
+
fliph(image);
|
|
42
|
+
if (orientation !== 2)
|
|
43
|
+
flipv(image);
|
|
44
|
+
}
|
|
45
|
+
const width = image.get_width();
|
|
46
|
+
const height = image.get_height();
|
|
47
|
+
const scale = Math.min(1, limits.maxWidth / width, limits.maxHeight / height);
|
|
48
|
+
let target = {
|
|
49
|
+
width: Math.max(1, Math.round(width * scale)),
|
|
50
|
+
height: Math.max(1, Math.round(height * scale))
|
|
51
|
+
};
|
|
52
|
+
for (;; ) {
|
|
53
|
+
const encoded = encodeWithin(image, target, limits.maxBase64Bytes, mimeType === "image/jpeg");
|
|
54
|
+
if (encoded !== undefined)
|
|
55
|
+
return target.width === width && target.height === height ? encoded : { ...encoded, resized: { from: { width, height }, to: target } };
|
|
56
|
+
if (target.width === 1 && target.height === 1)
|
|
57
|
+
return;
|
|
58
|
+
target = {
|
|
59
|
+
width: Math.max(1, Math.floor(target.width * 0.75)),
|
|
60
|
+
height: Math.max(1, Math.floor(target.height * 0.75))
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
} catch {
|
|
64
|
+
return;
|
|
65
|
+
} finally {
|
|
66
|
+
image?.free();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function encodeWithin(image, size, maxBase64Bytes, jpegFirst) {
|
|
70
|
+
const same = size.width === image.get_width() && size.height === image.get_height();
|
|
71
|
+
const scaled = same ? image : resize(image, size.width, size.height, SamplingFilter.Lanczos3);
|
|
72
|
+
try {
|
|
73
|
+
const png = { mimeType: "image/png", encode: () => scaled.get_bytes() };
|
|
74
|
+
const jpegs = JPEG_QUALITIES.map((quality) => ({
|
|
75
|
+
mimeType: "image/jpeg",
|
|
76
|
+
encode: () => scaled.get_bytes_jpeg(quality)
|
|
77
|
+
}));
|
|
78
|
+
for (const candidate of jpegFirst ? [...jpegs, png] : [png, ...jpegs]) {
|
|
79
|
+
const encoded = candidate.encode();
|
|
80
|
+
if (base64Length(encoded.byteLength) <= maxBase64Bytes)
|
|
81
|
+
return { data: encoded.toBase64(), mimeType: candidate.mimeType };
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
} finally {
|
|
85
|
+
if (!same)
|
|
86
|
+
scaled.free();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function transposed(image, orientation) {
|
|
90
|
+
const width = image.get_width();
|
|
91
|
+
const height = image.get_height();
|
|
92
|
+
const source = image.get_raw_pixels();
|
|
93
|
+
const pixels = new Uint8Array(source.length);
|
|
94
|
+
for (let y = 0;y < height; y++) {
|
|
95
|
+
for (let x = 0;x < width; x++) {
|
|
96
|
+
const outX = orientation === 5 || orientation === 8 ? y : height - 1 - y;
|
|
97
|
+
const outY = orientation === 5 || orientation === 6 ? x : width - 1 - x;
|
|
98
|
+
const from = (y * width + x) * 4;
|
|
99
|
+
pixels.set(source.subarray(from, from + 4), (outY * height + outX) * 4);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return { pixels, width: height, height: width };
|
|
103
|
+
}
|
|
104
|
+
function base64Length(byteLength) {
|
|
105
|
+
return Math.ceil(byteLength / 3) * 4;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export { photonImages2 };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
readNyteUsage2
|
|
3
|
-
} from "./canvas-preview-
|
|
3
|
+
} from "./canvas-preview-11nadadc.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
loadUsageScanCaches2,
|
|
6
|
+
saveUsageScanCaches2,
|
|
6
7
|
readLocalUsage2
|
|
7
|
-
} from "./canvas-preview-
|
|
8
|
+
} from "./canvas-preview-k1yg4fgp.js";
|
|
8
9
|
|
|
9
10
|
// src/usage-service.ts
|
|
10
11
|
import { join } from "node:path";
|
|
@@ -17,11 +18,13 @@ function catalogForUsage2(models) {
|
|
|
17
18
|
|
|
18
19
|
class UsageScanner2 {
|
|
19
20
|
home;
|
|
20
|
-
|
|
21
|
+
cachePath;
|
|
22
|
+
caches;
|
|
21
23
|
models;
|
|
22
24
|
scans = serial();
|
|
23
25
|
constructor(home) {
|
|
24
26
|
this.home = home;
|
|
27
|
+
this.cachePath = join(home, ".nyte", "usage-scan-cache.json");
|
|
25
28
|
this.models = createModels({
|
|
26
29
|
modelsStore: new FileModelsStore(join(home, ".nyte", "models-store.json"))
|
|
27
30
|
});
|
|
@@ -39,8 +42,10 @@ class UsageScanner2 {
|
|
|
39
42
|
const models = catalog === undefined ? this.models : {
|
|
40
43
|
getModels: (provider) => catalog.filter((model) => provider === undefined || model.provider === provider)
|
|
41
44
|
};
|
|
42
|
-
const
|
|
45
|
+
const caches = this.caches ??= await loadUsageScanCaches2(this.cachePath);
|
|
46
|
+
const local = await readLocalUsage2({ models, window: request.window, caches });
|
|
43
47
|
const report = readNyteUsage2(this.home, request.window);
|
|
48
|
+
this.scans.run(() => saveUsageScanCaches2(this.cachePath, caches));
|
|
44
49
|
return {
|
|
45
50
|
...report,
|
|
46
51
|
...local,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var package_default = {
|
|
3
3
|
name: "@nyte-ai/host",
|
|
4
|
-
version: "0.0.
|
|
4
|
+
version: "0.0.19",
|
|
5
5
|
private: false,
|
|
6
6
|
license: "MIT",
|
|
7
7
|
repository: {
|
|
@@ -22,6 +22,8 @@ var package_default = {
|
|
|
22
22
|
"./credentials": "./src/credentials.ts",
|
|
23
23
|
"./durable-object": "./src/durable-object.ts",
|
|
24
24
|
"./identity": "./src/identity.ts",
|
|
25
|
+
"./images": "./src/images/node.ts",
|
|
26
|
+
"./image-worker": "./src/images/worker.ts",
|
|
25
27
|
"./listen-fetch": "./src/listen-fetch.ts",
|
|
26
28
|
"./providers": "./src/providers.ts",
|
|
27
29
|
"./secrets": "./src/secrets.ts",
|
|
@@ -56,6 +58,14 @@ var package_default = {
|
|
|
56
58
|
types: "./dist/src/identity.d.ts",
|
|
57
59
|
import: "./dist/src/identity.js"
|
|
58
60
|
},
|
|
61
|
+
"./images": {
|
|
62
|
+
types: "./dist/src/images/node.d.ts",
|
|
63
|
+
import: "./dist/src/images/node.js"
|
|
64
|
+
},
|
|
65
|
+
"./image-worker": {
|
|
66
|
+
types: "./dist/src/images/worker.d.ts",
|
|
67
|
+
import: "./dist/src/images/worker.js"
|
|
68
|
+
},
|
|
59
69
|
"./listen-fetch": {
|
|
60
70
|
types: "./dist/src/listen-fetch.d.ts",
|
|
61
71
|
import: "./dist/src/listen-fetch.js"
|
|
@@ -106,10 +116,9 @@ var package_default = {
|
|
|
106
116
|
},
|
|
107
117
|
scripts: {
|
|
108
118
|
clean: "rm -rf node_modules .turbo",
|
|
109
|
-
typecheck: "
|
|
119
|
+
typecheck: "tsrs --noEmit && tsrs --noEmit -p src/deploy/vercel",
|
|
110
120
|
test: "vitest --run",
|
|
111
121
|
"check:store": "node scripts/check-store.ts",
|
|
112
|
-
"compact:store": "node scripts/compact-store.ts",
|
|
113
122
|
"build:package": "bun ../../scripts/sdk-packages.mjs build host"
|
|
114
123
|
},
|
|
115
124
|
dependencies: {
|
|
@@ -120,6 +129,7 @@ var package_default = {
|
|
|
120
129
|
"@nyte-ai/plugin": "workspace:*",
|
|
121
130
|
"@nyte-ai/protocol": "workspace:*",
|
|
122
131
|
"@nyte-ai/schema": "workspace:*",
|
|
132
|
+
"@silvia-odwyer/photon": "0.3.3",
|
|
123
133
|
fflate: "0.8.3",
|
|
124
134
|
ignore: "7.0.9",
|
|
125
135
|
pg: "8.23.0",
|