@neta-art/cohub-cli 9.1.2 → 10.0.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.
- package/dist/board-export.d.ts +14 -0
- package/dist/board-export.js +136 -80
- package/dist/board-kernel/lexer.js +84 -0
- package/dist/board-kernel.d.ts +4 -2
- package/dist/board-kernel.js +2913 -803
- package/dist/board-time.js +6 -0
- package/dist/commands/boards/authoring.d.ts +2 -0
- package/dist/commands/boards/authoring.js +90 -0
- package/dist/commands/boards/examples.js +12 -7
- package/dist/commands/boards.js +46 -11
- package/dist/commands/rooms.d.ts +3 -0
- package/dist/commands/rooms.js +232 -0
- package/dist/index.js +3 -0
- package/dist/runtime/model-catalog.d.ts +1 -1
- package/dist/runtime/model-catalog.js +2 -4
- package/dist/safe-remote-image.d.ts +4 -0
- package/dist/safe-remote-image.js +30 -15
- package/package.json +3 -3
|
@@ -13,6 +13,11 @@ const IMAGE_MIME_TYPES = new Set([
|
|
|
13
13
|
"image/png",
|
|
14
14
|
"image/webp",
|
|
15
15
|
]);
|
|
16
|
+
const AUDIO_MIME_TYPES = new Set([
|
|
17
|
+
"audio/mpeg", "audio/mp3", "audio/mp4", "audio/aac", "audio/ogg",
|
|
18
|
+
"audio/wav", "audio/x-wav", "audio/wave", "audio/flac", "audio/x-flac",
|
|
19
|
+
"audio/webm", "audio/opus", "application/ogg",
|
|
20
|
+
]);
|
|
16
21
|
const REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308]);
|
|
17
22
|
async function defaultLookup(hostname) {
|
|
18
23
|
const records = await dns.lookup(hostname, { all: true, verbatim: true });
|
|
@@ -48,7 +53,7 @@ function requestPinned(url, addresses, timeoutMs, maxBytes) {
|
|
|
48
53
|
const client = url.protocol === "https:" ? https : http;
|
|
49
54
|
const request = client.request(url, {
|
|
50
55
|
agent: false,
|
|
51
|
-
headers: { Accept: "image/
|
|
56
|
+
headers: { Accept: "image/*,audio/*,application/ogg" },
|
|
52
57
|
lookup: pinnedLookup(addresses),
|
|
53
58
|
}, (response) => {
|
|
54
59
|
const status = response.statusCode ?? 0;
|
|
@@ -61,7 +66,7 @@ function requestPinned(url, addresses, timeoutMs, maxBytes) {
|
|
|
61
66
|
const declaredLength = Number(headers.get("content-length") ?? 0);
|
|
62
67
|
if (Number.isFinite(declaredLength) && declaredLength > maxBytes) {
|
|
63
68
|
response.destroy();
|
|
64
|
-
reject(new Error(`
|
|
69
|
+
reject(new Error(`Media exceeds the ${maxBytes} byte download limit`));
|
|
65
70
|
return;
|
|
66
71
|
}
|
|
67
72
|
const chunks = [];
|
|
@@ -69,7 +74,7 @@ function requestPinned(url, addresses, timeoutMs, maxBytes) {
|
|
|
69
74
|
response.on("data", (chunk) => {
|
|
70
75
|
total += chunk.byteLength;
|
|
71
76
|
if (total > maxBytes) {
|
|
72
|
-
response.destroy(new Error(`
|
|
77
|
+
response.destroy(new Error(`Media exceeds the ${maxBytes} byte download limit`));
|
|
73
78
|
return;
|
|
74
79
|
}
|
|
75
80
|
chunks.push(chunk);
|
|
@@ -86,7 +91,7 @@ function requestPinned(url, addresses, timeoutMs, maxBytes) {
|
|
|
86
91
|
});
|
|
87
92
|
});
|
|
88
93
|
request.setTimeout(timeoutMs, () => {
|
|
89
|
-
request.destroy(new Error(`
|
|
94
|
+
request.destroy(new Error(`Media download timed out after ${timeoutMs}ms`));
|
|
90
95
|
});
|
|
91
96
|
request.once("error", reject);
|
|
92
97
|
request.end();
|
|
@@ -95,7 +100,7 @@ function requestPinned(url, addresses, timeoutMs, maxBytes) {
|
|
|
95
100
|
function remainingMs(deadline) {
|
|
96
101
|
const remaining = deadline - Date.now();
|
|
97
102
|
if (remaining <= 0)
|
|
98
|
-
throw new Error("
|
|
103
|
+
throw new Error("Media download timed out");
|
|
99
104
|
return remaining;
|
|
100
105
|
}
|
|
101
106
|
async function withDeadline(promise, deadline) {
|
|
@@ -105,7 +110,7 @@ async function withDeadline(promise, deadline) {
|
|
|
105
110
|
return await Promise.race([
|
|
106
111
|
promise,
|
|
107
112
|
new Promise((_, reject) => {
|
|
108
|
-
timer = setTimeout(() => reject(new Error(`
|
|
113
|
+
timer = setTimeout(() => reject(new Error(`Media download timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
109
114
|
}),
|
|
110
115
|
]);
|
|
111
116
|
}
|
|
@@ -117,7 +122,7 @@ async function withDeadline(promise, deadline) {
|
|
|
117
122
|
async function resolvePublicUrl(value, lookup, deadline) {
|
|
118
123
|
const normalized = normalizeBoardRemoteUrl(value);
|
|
119
124
|
if (!normalized)
|
|
120
|
-
throw new Error("
|
|
125
|
+
throw new Error("Media URL must be a public HTTP(S) URL");
|
|
121
126
|
const url = new URL(normalized);
|
|
122
127
|
const hostname = url.hostname.replace(/^\[|\]$/g, "");
|
|
123
128
|
const addresses = isIP(hostname)
|
|
@@ -126,11 +131,21 @@ async function resolvePublicUrl(value, lookup, deadline) {
|
|
|
126
131
|
const [first, ...rest] = addresses;
|
|
127
132
|
if (!first ||
|
|
128
133
|
addresses.some((entry) => !isPublicBoardRemoteAddress(entry.address))) {
|
|
129
|
-
throw new Error("
|
|
134
|
+
throw new Error("Media URL resolves to a private address");
|
|
130
135
|
}
|
|
131
136
|
return { url, addresses: [first, ...rest] };
|
|
132
137
|
}
|
|
133
|
-
export
|
|
138
|
+
export function downloadPublicImage(input, options = {}) {
|
|
139
|
+
return downloadPublicMedia(input, IMAGE_MIME_TYPES, options);
|
|
140
|
+
}
|
|
141
|
+
export function downloadPublicAudio(input, options = {}) {
|
|
142
|
+
return downloadPublicMedia(input, AUDIO_MIME_TYPES, {
|
|
143
|
+
maxBytes: 64 * 1024 * 1024,
|
|
144
|
+
timeoutMs: 30_000,
|
|
145
|
+
...options,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
async function downloadPublicMedia(input, mimeTypes, options) {
|
|
134
149
|
const lookup = options.lookup ?? defaultLookup;
|
|
135
150
|
const requester = options.requester ?? requestPinned;
|
|
136
151
|
const maxBytes = options.maxBytes ?? REMOTE_IMAGE_MAX_BYTES;
|
|
@@ -142,9 +157,9 @@ export async function downloadPublicImage(input, options = {}) {
|
|
|
142
157
|
if (REDIRECT_STATUSES.has(response.status)) {
|
|
143
158
|
const location = response.headers.get("location");
|
|
144
159
|
if (!location)
|
|
145
|
-
throw new Error("
|
|
160
|
+
throw new Error("Media redirect is missing a location");
|
|
146
161
|
if (redirect === MAX_REDIRECTS)
|
|
147
|
-
throw new Error("Too many
|
|
162
|
+
throw new Error("Too many media redirects");
|
|
148
163
|
current = new URL(location, url).toString();
|
|
149
164
|
continue;
|
|
150
165
|
}
|
|
@@ -152,17 +167,17 @@ export async function downloadPublicImage(input, options = {}) {
|
|
|
152
167
|
throw new Error(`HTTP ${response.status}`);
|
|
153
168
|
}
|
|
154
169
|
if (response.bytes.byteLength > maxBytes) {
|
|
155
|
-
throw new Error(`
|
|
170
|
+
throw new Error(`Media exceeds the ${maxBytes} byte download limit`);
|
|
156
171
|
}
|
|
157
172
|
const mimeType = response.headers
|
|
158
173
|
.get("content-type")
|
|
159
174
|
?.split(";", 1)[0]
|
|
160
175
|
?.trim()
|
|
161
176
|
.toLowerCase();
|
|
162
|
-
if (!mimeType || !
|
|
163
|
-
throw new Error("Remote
|
|
177
|
+
if (!mimeType || !mimeTypes.has(mimeType)) {
|
|
178
|
+
throw new Error("Remote resource has an unsupported media type");
|
|
164
179
|
}
|
|
165
180
|
return { bytes: response.bytes, mimeType };
|
|
166
181
|
}
|
|
167
|
-
throw new Error("Too many
|
|
182
|
+
throw new Error("Too many media redirects");
|
|
168
183
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neta-art/cohub-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "CLI for Cohub — spaces, sessions, and agent collaboration.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"NOTICE"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@neta-art/cohub": "
|
|
22
|
-
"@neta-art/generation": "^0.1.
|
|
21
|
+
"@neta-art/cohub": "11.0.0",
|
|
22
|
+
"@neta-art/generation": "^0.1.33",
|
|
23
23
|
"commander": "^15.0.0",
|
|
24
24
|
"sharp": "^0.35.4",
|
|
25
25
|
"ws": "^8.21.3"
|