@letta-ai/letta-code 0.34.46 → 0.34.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letta-ai/letta-code",
3
- "version": "0.34.46",
3
+ "version": "0.34.48",
4
4
  "lockfileVersion": 3,
5
5
  "packages": {
6
6
  "node_modules/@alcalzone/ansi-tokenize": {
@@ -5080,7 +5080,7 @@
5080
5080
  },
5081
5081
  "": {
5082
5082
  "name": "@letta-ai/letta-code",
5083
- "version": "0.34.46",
5083
+ "version": "0.34.48",
5084
5084
  "dependencies": {
5085
5085
  "@cursor/sdk": "1.1.0",
5086
5086
  "@earendil-works/pi-ai": "^0.99.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letta-ai/letta-code",
3
- "version": "0.34.46",
3
+ "version": "0.34.48",
4
4
  "lettaStartupLogProtocol": 1,
5
5
  "lettaConfigDirProtocol": 1,
6
6
  "description": "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
@@ -14,6 +14,8 @@
14
14
  "README.md",
15
15
  "letta.js",
16
16
  "image-resize-worker.js",
17
+ "image-resize.js",
18
+ "image-resize.js.map",
17
19
  "cursor-worker.js",
18
20
  "npm-shrinkwrap.json",
19
21
  "assets/tutor-profile.png",
@@ -136,6 +138,11 @@
136
138
  "browser": "./dist/channels-telegram.js",
137
139
  "import": "./dist/channels-telegram.js",
138
140
  "default": "./dist/channels-telegram.js"
141
+ },
142
+ "./image-resize": {
143
+ "types": "./dist/types/image-resize-public.d.ts",
144
+ "import": "./image-resize.js",
145
+ "default": "./image-resize.js"
139
146
  }
140
147
  },
141
148
  "repository": {
@@ -270,6 +277,9 @@
270
277
  "channels/telegram": [
271
278
  "./dist/types/channels-telegram.d.ts"
272
279
  ],
280
+ "image-resize": [
281
+ "./dist/types/image-resize-public.d.ts"
282
+ ],
273
283
  "protocol": [
274
284
  "./dist/types/types/protocol.d.ts"
275
285
  ]
@@ -0,0 +1,67 @@
1
+ // Install the packed tarball into a throwaway consumer and require() the
2
+ // public image-resize entrypoint from CommonJS, as bundled Node services do.
3
+ // Proves the entry and the worker it spawns both ship, and that the entry has
4
+ // no top-level await (which CommonJS require() of ESM rejects).
5
+ import assert from "node:assert/strict";
6
+ import { execFileSync, spawnSync } from "node:child_process";
7
+ import {
8
+ mkdirSync,
9
+ mkdtempSync,
10
+ rmSync,
11
+ symlinkSync,
12
+ writeFileSync,
13
+ } from "node:fs";
14
+ import { tmpdir } from "node:os";
15
+ import { join, resolve } from "node:path";
16
+
17
+ const repo = resolve(new URL("..", import.meta.url).pathname);
18
+ const consumer = mkdtempSync(join(tmpdir(), "letta-image-resize-export-"));
19
+ try {
20
+ const [{ filename }] = JSON.parse(
21
+ execFileSync("npm", ["pack", "--json", "--pack-destination", consumer], {
22
+ cwd: repo,
23
+ encoding: "utf8",
24
+ }),
25
+ );
26
+ const pkg = join(consumer, "node_modules/@letta-ai/letta-code");
27
+ mkdirSync(pkg, { recursive: true });
28
+ execFileSync("tar", [
29
+ "-xzf",
30
+ join(consumer, filename),
31
+ "-C",
32
+ pkg,
33
+ "--strip-components=1",
34
+ ]);
35
+ // Reuse the repo's installed Sharp instead of a network install.
36
+ for (const dep of ["sharp", "@img"]) {
37
+ symlinkSync(
38
+ join(repo, "node_modules", dep),
39
+ join(consumer, "node_modules", dep),
40
+ );
41
+ }
42
+
43
+ writeFileSync(
44
+ join(consumer, "consumer.cjs"),
45
+ `const { randomBytes } = require("node:crypto");
46
+ const sharp = require("sharp");
47
+ const { MAX_IMAGE_BYTES, resizeImageIfNeeded } = require("@letta-ai/letta-code/image-resize");
48
+ (async () => {
49
+ const width = 1300, height = 1100;
50
+ const png = await sharp(randomBytes(width * height * 3), { raw: { width, height, channels: 3 } }).png().toBuffer();
51
+ if (png.toString("base64").length <= MAX_IMAGE_BYTES) throw new Error("fixture must exceed the base64 limit");
52
+ const result = await resizeImageIfNeeded(png, "image/png");
53
+ process.stdout.write(JSON.stringify({ bytes: result.data.length, limit: MAX_IMAGE_BYTES }));
54
+ })().catch((error) => { console.error(error); process.exit(1); });
55
+ `,
56
+ );
57
+ const run = spawnSync(process.execPath, ["consumer.cjs"], {
58
+ cwd: consumer,
59
+ encoding: "utf8",
60
+ });
61
+ assert.equal(run.status, 0, run.stderr || run.error?.message);
62
+ const { bytes, limit } = JSON.parse(run.stdout);
63
+ assert.ok(bytes <= limit, `resized base64 ${bytes} exceeds ${limit}`);
64
+ console.log(`image-resize export OK (${bytes} <= ${limit} base64 bytes)`);
65
+ } finally {
66
+ rmSync(consumer, { recursive: true, force: true });
67
+ }