@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.
Files changed (102) hide show
  1. package/THIRD-PARTY-NOTICES.md +66 -0
  2. package/dist/chunks/{canvas-preview-5hxat7hh.js → canvas-preview-11nadadc.js} +8 -6
  3. package/dist/chunks/{canvas-preview-rp6fz0w5.js → canvas-preview-2jwbe14k.js} +5 -5
  4. package/dist/chunks/{canvas-preview-m02v4yy6.js → canvas-preview-55s0y68g.js} +3 -2
  5. package/dist/chunks/{canvas-preview-xn10d4f8.js → canvas-preview-5ekjx6sw.js} +9 -4
  6. package/dist/chunks/{canvas-preview-75db60xy.js → canvas-preview-8xc0vn7v.js} +5 -4
  7. package/dist/chunks/{canvas-preview-zn2d0k9d.js → canvas-preview-af86jz8t.js} +14 -6
  8. package/dist/chunks/{canvas-preview-d9wwhbtz.js → canvas-preview-aq5j4p25.js} +1 -1
  9. package/dist/chunks/{canvas-preview-j1tnf51w.js → canvas-preview-b2v8wfnz.js} +1 -1
  10. package/dist/chunks/canvas-preview-befkjea2.js +60 -0
  11. package/dist/chunks/canvas-preview-bxnqt8cd.js +103 -0
  12. package/dist/chunks/{canvas-preview-vax9ne4e.js → canvas-preview-cawy6vbz.js} +22 -11
  13. package/dist/chunks/{canvas-preview-senpjwep.js → canvas-preview-crmzxxt8.js} +3 -3
  14. package/dist/chunks/{canvas-preview-ymgz0937.js → canvas-preview-drctegz4.js} +8 -4
  15. package/dist/chunks/{canvas-preview-yrfz2ak6.js → canvas-preview-e3vnkkc5.js} +6 -6
  16. package/dist/chunks/canvas-preview-ec2mt7es.js +108 -0
  17. package/dist/chunks/{canvas-preview-1ta3avah.js → canvas-preview-fxa0rfb0.js} +10 -5
  18. package/dist/chunks/{canvas-preview-8xgt67ka.js → canvas-preview-g5fkjs34.js} +1 -1
  19. package/dist/chunks/{canvas-preview-g3qj3y3k.js → canvas-preview-jeddjex8.js} +13 -3
  20. package/dist/chunks/{canvas-preview-0nrnbt76.js → canvas-preview-k1yg4fgp.js} +199 -125
  21. package/dist/chunks/canvas-preview-kp75gb63.js +141 -0
  22. package/dist/chunks/{canvas-preview-ewgspmsd.js → canvas-preview-n2a35zv5.js} +1 -1
  23. package/dist/chunks/{canvas-preview-h8hshnff.js → canvas-preview-pkzqg96v.js} +1 -1
  24. package/dist/chunks/{canvas-preview-evh92ywd.js → canvas-preview-tnqe7k0b.js} +15 -10
  25. package/dist/chunks/{canvas-preview-ehf3vp31.js → canvas-preview-vm9zdp2t.js} +45 -58
  26. package/dist/chunks/{canvas-preview-76fwvd6e.js → canvas-preview-w54ymtb3.js} +1 -1
  27. package/dist/chunks/canvas-preview-y5y6ghaw.js +125 -0
  28. package/dist/chunks/{canvas-preview-98aj5p34.js → canvas-preview-ycepb05s.js} +1 -1
  29. package/dist/src/canvas-preview.js +7 -3
  30. package/dist/src/deploy/cloudflare/worker.js +1 -1
  31. package/dist/src/deploy/vercel/server/routes/[...].js +2 -2
  32. package/dist/src/deploy/vercel/server/utils/host.js +1 -1
  33. package/dist/src/deploy/vercel/server/workflows/drive.js +3 -3
  34. package/dist/src/images/exif.d.ts +1 -0
  35. package/dist/src/images/exif.js +6 -0
  36. package/dist/src/images/node.d.ts +37 -0
  37. package/dist/src/images/node.js +12 -0
  38. package/dist/src/images/photon.d.ts +3 -0
  39. package/dist/src/images/photon.js +7 -0
  40. package/dist/src/images/worker.d.ts +1 -0
  41. package/dist/src/images/worker.js +23 -0
  42. package/dist/src/index.d.ts +0 -1
  43. package/dist/src/index.js +23 -22
  44. package/dist/src/listen-fetch.js +3 -3
  45. package/dist/src/listen.js +4 -4
  46. package/dist/src/local/command.d.ts +5 -0
  47. package/dist/src/local/command.js +6 -2
  48. package/dist/src/local/files.js +2 -2
  49. package/dist/src/local/git-watch.d.ts +1 -1
  50. package/dist/src/local/git-watch.js +1 -1
  51. package/dist/src/local/git.js +3 -3
  52. package/dist/src/local/github.js +2 -2
  53. package/dist/src/local/jobs.d.ts +1 -1
  54. package/dist/src/local/jobs.js +2 -1
  55. package/dist/src/local/provider.js +9 -9
  56. package/dist/src/local/snapshots.js +2 -2
  57. package/dist/src/local/worktrees.js +2 -2
  58. package/dist/src/mcp/connect.d.ts +0 -13
  59. package/dist/src/mcp/connect.js +1 -1
  60. package/dist/src/mcp/hub.js +2 -2
  61. package/dist/src/open.d.ts +2 -30
  62. package/dist/src/open.js +20 -18
  63. package/dist/src/serve/binding.js +1 -1
  64. package/dist/src/serve/handler.js +2 -2
  65. package/dist/src/sqlite.d.ts +2 -1
  66. package/dist/src/sqlite.js +4 -3
  67. package/dist/src/store-usage.js +4 -1
  68. package/dist/src/usage-history.d.ts +54 -0
  69. package/dist/src/usage-history.js +14 -0
  70. package/dist/src/usage-service.d.ts +2 -1
  71. package/dist/src/usage-service.js +7 -3
  72. package/dist/src/usage-worker.js +8 -4
  73. package/dist/src/usage.d.ts +150 -27
  74. package/dist/src/usage.js +12 -2
  75. package/package.json +16 -8
  76. package/src/canvas-preview.ts +4 -3
  77. package/src/images/exif.ts +69 -0
  78. package/src/images/node.ts +163 -0
  79. package/src/images/photon.ts +141 -0
  80. package/src/images/worker.ts +29 -0
  81. package/src/index.ts +19 -1
  82. package/src/local/command.ts +64 -12
  83. package/src/local/files.ts +8 -3
  84. package/src/local/git-watch.ts +16 -6
  85. package/src/local/git.ts +7 -2
  86. package/src/local/github.ts +3 -4
  87. package/src/local/jobs.ts +55 -69
  88. package/src/local/snapshots.ts +4 -2
  89. package/src/local/worktrees.ts +4 -4
  90. package/src/mcp/connect.ts +1 -14
  91. package/src/open.ts +16 -36
  92. package/src/serve/binding.ts +4 -3
  93. package/src/sqlite.ts +33 -8
  94. package/src/store-usage.ts +5 -2
  95. package/src/usage-history.ts +219 -0
  96. package/src/usage-service.ts +12 -3
  97. package/src/usage.ts +251 -176
  98. package/dist/chunks/canvas-preview-a3yw0j70.js +0 -72
  99. package/dist/chunks/canvas-preview-azg56359.js +0 -68
  100. package/dist/src/store-owner.d.ts +0 -15
  101. package/dist/src/store-owner.js +0 -9
  102. 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-ymgz0937.js";
6
+ } from "./canvas-preview-drctegz4.js";
7
7
  import {
8
8
  localGit2
9
- } from "./canvas-preview-xn10d4f8.js";
9
+ } from "./canvas-preview-5ekjx6sw.js";
10
10
  import {
11
11
  localGitHub2
12
- } from "./canvas-preview-75db60xy.js";
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-ehf3vp31.js";
18
+ } from "./canvas-preview-vm9zdp2t.js";
19
19
  import {
20
20
  localSnapshots2
21
- } from "./canvas-preview-senpjwep.js";
21
+ } from "./canvas-preview-crmzxxt8.js";
22
22
  import {
23
23
  localWorktrees2
24
- } from "./canvas-preview-rp6fz0w5.js";
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-5hxat7hh.js";
3
+ } from "./canvas-preview-11nadadc.js";
4
4
  import {
5
- createUsageScanCaches2,
5
+ loadUsageScanCaches2,
6
+ saveUsageScanCaches2,
6
7
  readLocalUsage2
7
- } from "./canvas-preview-0nrnbt76.js";
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
- caches = createUsageScanCaches2();
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 local = await readLocalUsage2({ models, caches: this.caches });
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,
@@ -15,7 +15,7 @@ import {
15
15
  import {
16
16
  connectServer2,
17
17
  oauthSettings2
18
- } from "./canvas-preview-h8hshnff.js";
18
+ } from "./canvas-preview-pkzqg96v.js";
19
19
  import {
20
20
  toolExposure2,
21
21
  checkToolSchemas2,
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "@nyte-ai/host",
4
- version: "0.0.18",
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: "tsgo --noEmit && tsgo --noEmit -p src/deploy/vercel",
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",