@shogo-ai/core 1.4.1 → 1.9.0

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.
@@ -0,0 +1,126 @@
1
+ // src/file-types.ts
2
+ var BINARY_FILE_EXTENSIONS = /* @__PURE__ */ new Set([
3
+ // Images
4
+ "png",
5
+ "jpg",
6
+ "jpeg",
7
+ "gif",
8
+ "webp",
9
+ "bmp",
10
+ "ico",
11
+ "avif",
12
+ "apng",
13
+ "heic",
14
+ "heif",
15
+ "tiff",
16
+ "tif",
17
+ "jxl",
18
+ "cur",
19
+ // Archives
20
+ "zip",
21
+ "gz",
22
+ "tar",
23
+ "tgz",
24
+ "bz2",
25
+ "xz",
26
+ "7z",
27
+ "rar",
28
+ "zst",
29
+ "lz4",
30
+ // Audio / video / docs
31
+ "mp3",
32
+ "mp4",
33
+ "m4a",
34
+ "m4v",
35
+ "mov",
36
+ "avi",
37
+ "mkv",
38
+ "webm",
39
+ "wav",
40
+ "flac",
41
+ "ogg",
42
+ "oga",
43
+ "ogv",
44
+ "aac",
45
+ "opus",
46
+ "pdf",
47
+ // Fonts
48
+ "woff",
49
+ "woff2",
50
+ "ttf",
51
+ "otf",
52
+ "eot",
53
+ // Native / packed
54
+ "exe",
55
+ "dll",
56
+ "so",
57
+ "dylib",
58
+ "bin",
59
+ "class",
60
+ "jar",
61
+ "wasm",
62
+ // Databases
63
+ "db",
64
+ "sqlite",
65
+ "sqlite3",
66
+ "mdb",
67
+ "lmdb",
68
+ // Misc binary
69
+ "pack",
70
+ "idx",
71
+ "psd",
72
+ "ai",
73
+ "sketch",
74
+ "fig",
75
+ "blend",
76
+ "obj",
77
+ "fbx",
78
+ "pyc",
79
+ "pyo",
80
+ "pyd",
81
+ // 3D / scene / point cloud (binary variants — `.usda` and `.gltf` are
82
+ // text and intentionally NOT listed; users can still edit those)
83
+ "usd",
84
+ "usdc",
85
+ "usdz",
86
+ "glb",
87
+ "stl",
88
+ "ply",
89
+ // Robotics logs
90
+ "bag",
91
+ "mcap",
92
+ // ML weights / saved models / serialized arrays
93
+ "pt",
94
+ "pth",
95
+ "ckpt",
96
+ "safetensors",
97
+ "onnx",
98
+ "pb",
99
+ "tflite",
100
+ "mlmodel",
101
+ "npy",
102
+ "npz",
103
+ "joblib",
104
+ "pkl",
105
+ // Tabular / scientific containers
106
+ "parquet",
107
+ "arrow",
108
+ "feather",
109
+ "h5",
110
+ "hdf5",
111
+ "nc",
112
+ "tfrecord"
113
+ ]);
114
+ function isBinaryFilePath(path) {
115
+ const dot = path.lastIndexOf(".");
116
+ if (dot < 0) return false;
117
+ const slash = Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
118
+ if (dot < slash) return false;
119
+ return BINARY_FILE_EXTENSIONS.has(path.slice(dot + 1).toLowerCase());
120
+ }
121
+
122
+ export {
123
+ BINARY_FILE_EXTENSIONS,
124
+ isBinaryFilePath
125
+ };
126
+ //# sourceMappingURL=chunk-HKX3MEJN.js.map
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/file-types.ts
21
+ var file_types_exports = {};
22
+ __export(file_types_exports, {
23
+ BINARY_FILE_EXTENSIONS: () => BINARY_FILE_EXTENSIONS,
24
+ isBinaryFilePath: () => isBinaryFilePath
25
+ });
26
+ module.exports = __toCommonJS(file_types_exports);
27
+ var BINARY_FILE_EXTENSIONS = /* @__PURE__ */ new Set([
28
+ // Images
29
+ "png",
30
+ "jpg",
31
+ "jpeg",
32
+ "gif",
33
+ "webp",
34
+ "bmp",
35
+ "ico",
36
+ "avif",
37
+ "apng",
38
+ "heic",
39
+ "heif",
40
+ "tiff",
41
+ "tif",
42
+ "jxl",
43
+ "cur",
44
+ // Archives
45
+ "zip",
46
+ "gz",
47
+ "tar",
48
+ "tgz",
49
+ "bz2",
50
+ "xz",
51
+ "7z",
52
+ "rar",
53
+ "zst",
54
+ "lz4",
55
+ // Audio / video / docs
56
+ "mp3",
57
+ "mp4",
58
+ "m4a",
59
+ "m4v",
60
+ "mov",
61
+ "avi",
62
+ "mkv",
63
+ "webm",
64
+ "wav",
65
+ "flac",
66
+ "ogg",
67
+ "oga",
68
+ "ogv",
69
+ "aac",
70
+ "opus",
71
+ "pdf",
72
+ // Fonts
73
+ "woff",
74
+ "woff2",
75
+ "ttf",
76
+ "otf",
77
+ "eot",
78
+ // Native / packed
79
+ "exe",
80
+ "dll",
81
+ "so",
82
+ "dylib",
83
+ "bin",
84
+ "class",
85
+ "jar",
86
+ "wasm",
87
+ // Databases
88
+ "db",
89
+ "sqlite",
90
+ "sqlite3",
91
+ "mdb",
92
+ "lmdb",
93
+ // Misc binary
94
+ "pack",
95
+ "idx",
96
+ "psd",
97
+ "ai",
98
+ "sketch",
99
+ "fig",
100
+ "blend",
101
+ "obj",
102
+ "fbx",
103
+ "pyc",
104
+ "pyo",
105
+ "pyd",
106
+ // 3D / scene / point cloud (binary variants — `.usda` and `.gltf` are
107
+ // text and intentionally NOT listed; users can still edit those)
108
+ "usd",
109
+ "usdc",
110
+ "usdz",
111
+ "glb",
112
+ "stl",
113
+ "ply",
114
+ // Robotics logs
115
+ "bag",
116
+ "mcap",
117
+ // ML weights / saved models / serialized arrays
118
+ "pt",
119
+ "pth",
120
+ "ckpt",
121
+ "safetensors",
122
+ "onnx",
123
+ "pb",
124
+ "tflite",
125
+ "mlmodel",
126
+ "npy",
127
+ "npz",
128
+ "joblib",
129
+ "pkl",
130
+ // Tabular / scientific containers
131
+ "parquet",
132
+ "arrow",
133
+ "feather",
134
+ "h5",
135
+ "hdf5",
136
+ "nc",
137
+ "tfrecord"
138
+ ]);
139
+ function isBinaryFilePath(path) {
140
+ const dot = path.lastIndexOf(".");
141
+ if (dot < 0) return false;
142
+ const slash = Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
143
+ if (dot < slash) return false;
144
+ return BINARY_FILE_EXTENSIONS.has(path.slice(dot + 1).toLowerCase());
145
+ }
146
+ // Annotate the CommonJS export names for ESM import in node:
147
+ 0 && (module.exports = {
148
+ BINARY_FILE_EXTENSIONS,
149
+ isBinaryFilePath
150
+ });
151
+ //# sourceMappingURL=file-types.cjs.map
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Canonical "is this file binary on disk?" predicate.
3
+ *
4
+ * One source of truth for the agent-runtime, the IDE Workbench, the live-
5
+ * agent-edit sync, and the local filesystem layer. Before this module
6
+ * existed, four parallel extension sets had drifted apart:
7
+ *
8
+ * - `packages/agent-runtime/src/server.ts:BINARY_FILE_EXTENSIONS`
9
+ * - `apps/mobile/.../useLiveAgentEdits.ts:NON_TEXT_EXTENSIONS`
10
+ * - `apps/mobile/.../Workbench.tsx:BINARY_EXTENSIONS`
11
+ * - `apps/mobile/.../workspace/localFs.ts:BINARY_EXT`
12
+ *
13
+ * That drift caused real corruption bugs (e.g. `.usd` files silently
14
+ * round-tripped as utf-8, then `EUNKNOWN` on writeFileSync; `.mp4` /
15
+ * `.zip` doubled in size on the agent-runtime PUT path).
16
+ *
17
+ * Why an extension allow-list and not a content sniff: the write path
18
+ * has to decide encoding *before* it sees bytes. A content sniff is
19
+ * useful as a secondary signal on read (see `localFs.looksLikeText`),
20
+ * but the wire-format encoding is fundamentally a property of the path.
21
+ *
22
+ * Zero peers, zero deps, runs in Bun / Node / Metro / browser.
23
+ */
24
+ /** Extensions that must be sent over the wire as base64 (binary) instead
25
+ * of utf-8. A file with one of these extensions:
26
+ *
27
+ * - cannot be read as utf-8 without producing U+FFFD replacement chars,
28
+ * - cannot be written from utf-8 string content without corrupting the
29
+ * on-disk bytes (the classic "2x bloat" round-trip bug),
30
+ * - should not be opened in Monaco unless we have a dedicated previewer
31
+ * for it (image/pdf/audio/video/font/sqlite — handled at call sites).
32
+ *
33
+ * Conservative additions only: a format goes in here when its **binary
34
+ * encoding is the dominant on-disk form**. Formats with widely-used
35
+ * ASCII variants (`.usda`, `.gltf`, `.dae`, `.urdf`, `.mjcf`, plain
36
+ * `.svg`, plain `.obj`) are intentionally absent so users can still
37
+ * edit them as text.
38
+ *
39
+ * When you add a new entry, prefer adding it to the right category
40
+ * comment so the next person reading this file can tell at a glance
41
+ * whether they need to add their own format. */
42
+ declare const BINARY_FILE_EXTENSIONS: ReadonlySet<string>;
43
+ /** True iff `path`'s extension is in {@link BINARY_FILE_EXTENSIONS}.
44
+ * Case-insensitive; tolerant of paths with no extension (returns
45
+ * false). Operates purely on the suffix — does not stat the file. */
46
+ declare function isBinaryFilePath(path: string): boolean;
47
+
48
+ export { BINARY_FILE_EXTENSIONS, isBinaryFilePath };
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Canonical "is this file binary on disk?" predicate.
3
+ *
4
+ * One source of truth for the agent-runtime, the IDE Workbench, the live-
5
+ * agent-edit sync, and the local filesystem layer. Before this module
6
+ * existed, four parallel extension sets had drifted apart:
7
+ *
8
+ * - `packages/agent-runtime/src/server.ts:BINARY_FILE_EXTENSIONS`
9
+ * - `apps/mobile/.../useLiveAgentEdits.ts:NON_TEXT_EXTENSIONS`
10
+ * - `apps/mobile/.../Workbench.tsx:BINARY_EXTENSIONS`
11
+ * - `apps/mobile/.../workspace/localFs.ts:BINARY_EXT`
12
+ *
13
+ * That drift caused real corruption bugs (e.g. `.usd` files silently
14
+ * round-tripped as utf-8, then `EUNKNOWN` on writeFileSync; `.mp4` /
15
+ * `.zip` doubled in size on the agent-runtime PUT path).
16
+ *
17
+ * Why an extension allow-list and not a content sniff: the write path
18
+ * has to decide encoding *before* it sees bytes. A content sniff is
19
+ * useful as a secondary signal on read (see `localFs.looksLikeText`),
20
+ * but the wire-format encoding is fundamentally a property of the path.
21
+ *
22
+ * Zero peers, zero deps, runs in Bun / Node / Metro / browser.
23
+ */
24
+ /** Extensions that must be sent over the wire as base64 (binary) instead
25
+ * of utf-8. A file with one of these extensions:
26
+ *
27
+ * - cannot be read as utf-8 without producing U+FFFD replacement chars,
28
+ * - cannot be written from utf-8 string content without corrupting the
29
+ * on-disk bytes (the classic "2x bloat" round-trip bug),
30
+ * - should not be opened in Monaco unless we have a dedicated previewer
31
+ * for it (image/pdf/audio/video/font/sqlite — handled at call sites).
32
+ *
33
+ * Conservative additions only: a format goes in here when its **binary
34
+ * encoding is the dominant on-disk form**. Formats with widely-used
35
+ * ASCII variants (`.usda`, `.gltf`, `.dae`, `.urdf`, `.mjcf`, plain
36
+ * `.svg`, plain `.obj`) are intentionally absent so users can still
37
+ * edit them as text.
38
+ *
39
+ * When you add a new entry, prefer adding it to the right category
40
+ * comment so the next person reading this file can tell at a glance
41
+ * whether they need to add their own format. */
42
+ declare const BINARY_FILE_EXTENSIONS: ReadonlySet<string>;
43
+ /** True iff `path`'s extension is in {@link BINARY_FILE_EXTENSIONS}.
44
+ * Case-insensitive; tolerant of paths with no extension (returns
45
+ * false). Operates purely on the suffix — does not stat the file. */
46
+ declare function isBinaryFilePath(path: string): boolean;
47
+
48
+ export { BINARY_FILE_EXTENSIONS, isBinaryFilePath };
@@ -0,0 +1,9 @@
1
+ import {
2
+ BINARY_FILE_EXTENSIONS,
3
+ isBinaryFilePath
4
+ } from "./chunk-HKX3MEJN.js";
5
+ export {
6
+ BINARY_FILE_EXTENSIONS,
7
+ isBinaryFilePath
8
+ };
9
+ //# sourceMappingURL=file-types.js.map
package/dist/index.cjs CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ BINARY_FILE_EXTENSIONS: () => BINARY_FILE_EXTENSIONS,
23
24
  StreamBufferStore: () => StreamBufferStore,
24
25
  TECH_STACK_REGISTRY: () => TECH_STACK_REGISTRY,
25
26
  createBufferingTransform: () => createBufferingTransform,
@@ -28,6 +29,7 @@ __export(index_exports, {
28
29
  findLastUserMessage: () => findLastUserMessage,
29
30
  getStackEntry: () => getStackEntry,
30
31
  initInstrumentation: () => initInstrumentation,
32
+ isBinaryFilePath: () => isBinaryFilePath,
31
33
  isMacOSJunkName: () => isMacOSJunkName,
32
34
  isMacOSJunkPath: () => isMacOSJunkPath,
33
35
  isMobileTechStack: () => isMobileTechStack,
@@ -489,8 +491,130 @@ function usesMetroBundler(techStackId) {
489
491
  function stackSeedsItself(techStackId) {
490
492
  return getStackEntry(techStackId)?.seedsOwnTemplate === true;
491
493
  }
494
+
495
+ // src/file-types.ts
496
+ var BINARY_FILE_EXTENSIONS = /* @__PURE__ */ new Set([
497
+ // Images
498
+ "png",
499
+ "jpg",
500
+ "jpeg",
501
+ "gif",
502
+ "webp",
503
+ "bmp",
504
+ "ico",
505
+ "avif",
506
+ "apng",
507
+ "heic",
508
+ "heif",
509
+ "tiff",
510
+ "tif",
511
+ "jxl",
512
+ "cur",
513
+ // Archives
514
+ "zip",
515
+ "gz",
516
+ "tar",
517
+ "tgz",
518
+ "bz2",
519
+ "xz",
520
+ "7z",
521
+ "rar",
522
+ "zst",
523
+ "lz4",
524
+ // Audio / video / docs
525
+ "mp3",
526
+ "mp4",
527
+ "m4a",
528
+ "m4v",
529
+ "mov",
530
+ "avi",
531
+ "mkv",
532
+ "webm",
533
+ "wav",
534
+ "flac",
535
+ "ogg",
536
+ "oga",
537
+ "ogv",
538
+ "aac",
539
+ "opus",
540
+ "pdf",
541
+ // Fonts
542
+ "woff",
543
+ "woff2",
544
+ "ttf",
545
+ "otf",
546
+ "eot",
547
+ // Native / packed
548
+ "exe",
549
+ "dll",
550
+ "so",
551
+ "dylib",
552
+ "bin",
553
+ "class",
554
+ "jar",
555
+ "wasm",
556
+ // Databases
557
+ "db",
558
+ "sqlite",
559
+ "sqlite3",
560
+ "mdb",
561
+ "lmdb",
562
+ // Misc binary
563
+ "pack",
564
+ "idx",
565
+ "psd",
566
+ "ai",
567
+ "sketch",
568
+ "fig",
569
+ "blend",
570
+ "obj",
571
+ "fbx",
572
+ "pyc",
573
+ "pyo",
574
+ "pyd",
575
+ // 3D / scene / point cloud (binary variants — `.usda` and `.gltf` are
576
+ // text and intentionally NOT listed; users can still edit those)
577
+ "usd",
578
+ "usdc",
579
+ "usdz",
580
+ "glb",
581
+ "stl",
582
+ "ply",
583
+ // Robotics logs
584
+ "bag",
585
+ "mcap",
586
+ // ML weights / saved models / serialized arrays
587
+ "pt",
588
+ "pth",
589
+ "ckpt",
590
+ "safetensors",
591
+ "onnx",
592
+ "pb",
593
+ "tflite",
594
+ "mlmodel",
595
+ "npy",
596
+ "npz",
597
+ "joblib",
598
+ "pkl",
599
+ // Tabular / scientific containers
600
+ "parquet",
601
+ "arrow",
602
+ "feather",
603
+ "h5",
604
+ "hdf5",
605
+ "nc",
606
+ "tfrecord"
607
+ ]);
608
+ function isBinaryFilePath(path) {
609
+ const dot = path.lastIndexOf(".");
610
+ if (dot < 0) return false;
611
+ const slash = Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\"));
612
+ if (dot < slash) return false;
613
+ return BINARY_FILE_EXTENSIONS.has(path.slice(dot + 1).toLowerCase());
614
+ }
492
615
  // Annotate the CommonJS export names for ESM import in node:
493
616
  0 && (module.exports = {
617
+ BINARY_FILE_EXTENSIONS,
494
618
  StreamBufferStore,
495
619
  TECH_STACK_REGISTRY,
496
620
  createBufferingTransform,
@@ -499,6 +623,7 @@ function stackSeedsItself(techStackId) {
499
623
  findLastUserMessage,
500
624
  getStackEntry,
501
625
  initInstrumentation,
626
+ isBinaryFilePath,
502
627
  isMacOSJunkName,
503
628
  isMacOSJunkPath,
504
629
  isMobileTechStack,
package/dist/index.d.cts CHANGED
@@ -4,4 +4,5 @@ export { ReplayOptions, StreamBufferStore, StreamBufferWriter, TurnSnapshot, Tur
4
4
  export { extractUserText, findLastUserMessage } from './chat-message.cjs';
5
5
  export { isMacOSJunkName, isMacOSJunkPath } from './macos-junk.cjs';
6
6
  export { StackRegistryEntry, StackTarget, TECH_STACK_REGISTRY, getStackEntry, isMobileTechStack, stackSeedsItself, usesMetroBundler } from './tech-stack-registry.cjs';
7
+ export { BINARY_FILE_EXTENSIONS, isBinaryFilePath } from './file-types.cjs';
7
8
  import '@opentelemetry/api';
package/dist/index.d.ts CHANGED
@@ -4,4 +4,5 @@ export { ReplayOptions, StreamBufferStore, StreamBufferWriter, TurnSnapshot, Tur
4
4
  export { extractUserText, findLastUserMessage } from './chat-message.js';
5
5
  export { isMacOSJunkName, isMacOSJunkPath } from './macos-junk.js';
6
6
  export { StackRegistryEntry, StackTarget, TECH_STACK_REGISTRY, getStackEntry, isMobileTechStack, stackSeedsItself, usesMetroBundler } from './tech-stack-registry.js';
7
+ export { BINARY_FILE_EXTENSIONS, isBinaryFilePath } from './file-types.js';
7
8
  import '@opentelemetry/api';
package/dist/index.js CHANGED
@@ -2,6 +2,10 @@ import {
2
2
  extractUserText,
3
3
  findLastUserMessage
4
4
  } from "./chunk-4J7NH2WJ.js";
5
+ import {
6
+ BINARY_FILE_EXTENSIONS,
7
+ isBinaryFilePath
8
+ } from "./chunk-HKX3MEJN.js";
5
9
  import {
6
10
  initInstrumentation,
7
11
  shutdownInstrumentation,
@@ -26,6 +30,7 @@ import {
26
30
  usesMetroBundler
27
31
  } from "./chunk-KTDDFWXM.js";
28
32
  export {
33
+ BINARY_FILE_EXTENSIONS,
29
34
  StreamBufferStore,
30
35
  TECH_STACK_REGISTRY,
31
36
  createBufferingTransform,
@@ -34,6 +39,7 @@ export {
34
39
  findLastUserMessage,
35
40
  getStackEntry,
36
41
  initInstrumentation,
42
+ isBinaryFilePath,
37
43
  isMacOSJunkName,
38
44
  isMacOSJunkPath,
39
45
  isMobileTechStack,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shogo-ai/core",
3
- "version": "1.4.1",
3
+ "version": "1.9.0",
4
4
  "description": "Shogo Core — generic utilities (logger, instrumentation, stream-buffer, chat-message). Zero required peers.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -43,6 +43,11 @@
43
43
  "types": "./dist/tech-stack-registry.d.ts",
44
44
  "import": "./dist/tech-stack-registry.js",
45
45
  "require": "./dist/tech-stack-registry.cjs"
46
+ },
47
+ "./file-types": {
48
+ "types": "./dist/file-types.d.ts",
49
+ "import": "./dist/file-types.js",
50
+ "require": "./dist/file-types.cjs"
46
51
  }
47
52
  },
48
53
  "files": [