@scout9/app 1.0.0-alpha.0.1.9 → 1.0.0-alpha.0.1.90
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/README.md +32 -0
- package/dist/{index-92deaa5f.cjs → exports-e7d51b70.cjs} +46618 -4591
- package/dist/index.cjs +58 -15
- package/dist/{multipart-parser-090f08a9.cjs → multipart-parser-e09a67c9.cjs} +13 -7
- package/dist/spirits-3b603262.cjs +1218 -0
- package/dist/spirits.cjs +9 -0
- package/dist/testing-tools.cjs +48 -0
- package/package.json +30 -8
- package/src/cli.js +162 -69
- package/src/core/config/agents.js +300 -7
- package/src/core/config/entities.js +58 -28
- package/src/core/config/index.js +37 -15
- package/src/core/config/project.js +160 -6
- package/src/core/config/workflow.js +13 -12
- package/src/core/data.js +27 -0
- package/src/core/index.js +386 -137
- package/src/core/sync.js +71 -0
- package/src/core/templates/Dockerfile +22 -0
- package/src/core/templates/app.js +453 -0
- package/src/core/templates/project-files.js +36 -0
- package/src/core/templates/template-package.json +13 -0
- package/src/exports.js +21 -17
- package/src/platform.js +189 -33
- package/src/public.d.ts.text +330 -0
- package/src/report.js +117 -0
- package/src/runtime/client/api.js +56 -159
- package/src/runtime/client/config.js +60 -11
- package/src/runtime/client/entity.js +19 -6
- package/src/runtime/client/index.js +5 -3
- package/src/runtime/client/message.js +13 -3
- package/src/runtime/client/platform.js +86 -0
- package/src/runtime/client/{agent.js → users.js} +35 -3
- package/src/runtime/client/utils.js +10 -9
- package/src/runtime/client/workflow.js +131 -9
- package/src/runtime/entry.js +2 -2
- package/src/testing-tools/dev.js +373 -0
- package/src/testing-tools/index.js +1 -0
- package/src/testing-tools/mocks.js +37 -5
- package/src/testing-tools/spirits.js +530 -0
- package/src/utils/audio-buffer.js +16 -0
- package/src/utils/audio-type.js +27 -0
- package/src/utils/configs/agents.js +68 -0
- package/src/utils/configs/entities.js +145 -0
- package/src/utils/configs/project.js +23 -0
- package/src/utils/configs/workflow.js +47 -0
- package/src/utils/file-type.js +569 -0
- package/src/utils/file.js +158 -0
- package/src/utils/glob.js +30 -0
- package/src/utils/image-buffer.js +23 -0
- package/src/utils/image-type.js +39 -0
- package/src/utils/index.js +1 -0
- package/src/utils/is-svg.js +37 -0
- package/src/utils/logger.js +111 -0
- package/src/utils/module.js +14 -25
- package/src/utils/project-templates.js +191 -0
- package/src/utils/project.js +387 -0
- package/src/utils/video-type.js +29 -0
- package/types/index.d.ts +7588 -206
- package/types/index.d.ts.map +97 -22
- package/dist/index-1b8d7dd2.cjs +0 -49555
- package/dist/index-2ccb115e.cjs +0 -49514
- package/dist/index-66b06a30.cjs +0 -49549
- package/dist/index-bc029a1d.cjs +0 -49528
- package/dist/index-d9a93523.cjs +0 -49527
- package/dist/multipart-parser-1508046a.cjs +0 -413
- package/dist/multipart-parser-7007403a.cjs +0 -413
- package/dist/multipart-parser-70c32c1d.cjs +0 -413
- package/dist/multipart-parser-71dec101.cjs +0 -413
- package/dist/multipart-parser-f15bf2e0.cjs +0 -414
- package/src/public.d.ts +0 -209
|
@@ -1,413 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
require('node:fs');
|
|
4
|
-
require('node:path');
|
|
5
|
-
var index = require("./index-bc029a1d.cjs");
|
|
6
|
-
require('fs');
|
|
7
|
-
require('events');
|
|
8
|
-
require('path');
|
|
9
|
-
require('constants');
|
|
10
|
-
require('stream');
|
|
11
|
-
require('util');
|
|
12
|
-
require('assert');
|
|
13
|
-
require('buffer');
|
|
14
|
-
require('zlib');
|
|
15
|
-
require('url');
|
|
16
|
-
require('fs/promises');
|
|
17
|
-
require('string_decoder');
|
|
18
|
-
require('node:child_process');
|
|
19
|
-
require('node:fs/promises');
|
|
20
|
-
require('node:http');
|
|
21
|
-
require('node:https');
|
|
22
|
-
require('node:zlib');
|
|
23
|
-
require('node:stream');
|
|
24
|
-
require('node:buffer');
|
|
25
|
-
require('node:util');
|
|
26
|
-
require('node:url');
|
|
27
|
-
require('node:net');
|
|
28
|
-
require('node:vm');
|
|
29
|
-
require('os');
|
|
30
|
-
require('crypto');
|
|
31
|
-
|
|
32
|
-
let s = 0;
|
|
33
|
-
const S = {
|
|
34
|
-
START_BOUNDARY: s++,
|
|
35
|
-
HEADER_FIELD_START: s++,
|
|
36
|
-
HEADER_FIELD: s++,
|
|
37
|
-
HEADER_VALUE_START: s++,
|
|
38
|
-
HEADER_VALUE: s++,
|
|
39
|
-
HEADER_VALUE_ALMOST_DONE: s++,
|
|
40
|
-
HEADERS_ALMOST_DONE: s++,
|
|
41
|
-
PART_DATA_START: s++,
|
|
42
|
-
PART_DATA: s++,
|
|
43
|
-
END: s++
|
|
44
|
-
};
|
|
45
|
-
let f = 1;
|
|
46
|
-
const F = {
|
|
47
|
-
PART_BOUNDARY: f,
|
|
48
|
-
LAST_BOUNDARY: f *= 2
|
|
49
|
-
};
|
|
50
|
-
const LF = 10;
|
|
51
|
-
const CR = 13;
|
|
52
|
-
const SPACE = 32;
|
|
53
|
-
const HYPHEN = 45;
|
|
54
|
-
const COLON = 58;
|
|
55
|
-
const A = 97;
|
|
56
|
-
const Z = 122;
|
|
57
|
-
const lower = c => c | 0x20;
|
|
58
|
-
const noop = () => {};
|
|
59
|
-
class MultipartParser {
|
|
60
|
-
/**
|
|
61
|
-
* @param {string} boundary
|
|
62
|
-
*/
|
|
63
|
-
constructor(boundary) {
|
|
64
|
-
this.index = 0;
|
|
65
|
-
this.flags = 0;
|
|
66
|
-
this.onHeaderEnd = noop;
|
|
67
|
-
this.onHeaderField = noop;
|
|
68
|
-
this.onHeadersEnd = noop;
|
|
69
|
-
this.onHeaderValue = noop;
|
|
70
|
-
this.onPartBegin = noop;
|
|
71
|
-
this.onPartData = noop;
|
|
72
|
-
this.onPartEnd = noop;
|
|
73
|
-
this.boundaryChars = {};
|
|
74
|
-
boundary = '\r\n--' + boundary;
|
|
75
|
-
const ui8a = new Uint8Array(boundary.length);
|
|
76
|
-
for (let i = 0; i < boundary.length; i++) {
|
|
77
|
-
ui8a[i] = boundary.charCodeAt(i);
|
|
78
|
-
this.boundaryChars[ui8a[i]] = true;
|
|
79
|
-
}
|
|
80
|
-
this.boundary = ui8a;
|
|
81
|
-
this.lookbehind = new Uint8Array(this.boundary.length + 8);
|
|
82
|
-
this.state = S.START_BOUNDARY;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* @param {Uint8Array} data
|
|
87
|
-
*/
|
|
88
|
-
write(data) {
|
|
89
|
-
let i = 0;
|
|
90
|
-
const length_ = data.length;
|
|
91
|
-
let previousIndex = this.index;
|
|
92
|
-
let {
|
|
93
|
-
lookbehind,
|
|
94
|
-
boundary,
|
|
95
|
-
boundaryChars,
|
|
96
|
-
index,
|
|
97
|
-
state,
|
|
98
|
-
flags
|
|
99
|
-
} = this;
|
|
100
|
-
const boundaryLength = this.boundary.length;
|
|
101
|
-
const boundaryEnd = boundaryLength - 1;
|
|
102
|
-
const bufferLength = data.length;
|
|
103
|
-
let c;
|
|
104
|
-
let cl;
|
|
105
|
-
const mark = name => {
|
|
106
|
-
this[name + 'Mark'] = i;
|
|
107
|
-
};
|
|
108
|
-
const clear = name => {
|
|
109
|
-
delete this[name + 'Mark'];
|
|
110
|
-
};
|
|
111
|
-
const callback = (callbackSymbol, start, end, ui8a) => {
|
|
112
|
-
if (start === undefined || start !== end) {
|
|
113
|
-
this[callbackSymbol](ui8a && ui8a.subarray(start, end));
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
const dataCallback = (name, clear) => {
|
|
117
|
-
const markSymbol = name + 'Mark';
|
|
118
|
-
if (!(markSymbol in this)) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
if (clear) {
|
|
122
|
-
callback(name, this[markSymbol], i, data);
|
|
123
|
-
delete this[markSymbol];
|
|
124
|
-
} else {
|
|
125
|
-
callback(name, this[markSymbol], data.length, data);
|
|
126
|
-
this[markSymbol] = 0;
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
for (i = 0; i < length_; i++) {
|
|
130
|
-
c = data[i];
|
|
131
|
-
switch (state) {
|
|
132
|
-
case S.START_BOUNDARY:
|
|
133
|
-
if (index === boundary.length - 2) {
|
|
134
|
-
if (c === HYPHEN) {
|
|
135
|
-
flags |= F.LAST_BOUNDARY;
|
|
136
|
-
} else if (c !== CR) {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
index++;
|
|
140
|
-
break;
|
|
141
|
-
} else if (index - 1 === boundary.length - 2) {
|
|
142
|
-
if (flags & F.LAST_BOUNDARY && c === HYPHEN) {
|
|
143
|
-
state = S.END;
|
|
144
|
-
flags = 0;
|
|
145
|
-
} else if (!(flags & F.LAST_BOUNDARY) && c === LF) {
|
|
146
|
-
index = 0;
|
|
147
|
-
callback('onPartBegin');
|
|
148
|
-
state = S.HEADER_FIELD_START;
|
|
149
|
-
} else {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
break;
|
|
153
|
-
}
|
|
154
|
-
if (c !== boundary[index + 2]) {
|
|
155
|
-
index = -2;
|
|
156
|
-
}
|
|
157
|
-
if (c === boundary[index + 2]) {
|
|
158
|
-
index++;
|
|
159
|
-
}
|
|
160
|
-
break;
|
|
161
|
-
case S.HEADER_FIELD_START:
|
|
162
|
-
state = S.HEADER_FIELD;
|
|
163
|
-
mark('onHeaderField');
|
|
164
|
-
index = 0;
|
|
165
|
-
// falls through
|
|
166
|
-
case S.HEADER_FIELD:
|
|
167
|
-
if (c === CR) {
|
|
168
|
-
clear('onHeaderField');
|
|
169
|
-
state = S.HEADERS_ALMOST_DONE;
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
172
|
-
index++;
|
|
173
|
-
if (c === HYPHEN) {
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
|
-
if (c === COLON) {
|
|
177
|
-
if (index === 1) {
|
|
178
|
-
// empty header field
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
dataCallback('onHeaderField', true);
|
|
182
|
-
state = S.HEADER_VALUE_START;
|
|
183
|
-
break;
|
|
184
|
-
}
|
|
185
|
-
cl = lower(c);
|
|
186
|
-
if (cl < A || cl > Z) {
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
break;
|
|
190
|
-
case S.HEADER_VALUE_START:
|
|
191
|
-
if (c === SPACE) {
|
|
192
|
-
break;
|
|
193
|
-
}
|
|
194
|
-
mark('onHeaderValue');
|
|
195
|
-
state = S.HEADER_VALUE;
|
|
196
|
-
// falls through
|
|
197
|
-
case S.HEADER_VALUE:
|
|
198
|
-
if (c === CR) {
|
|
199
|
-
dataCallback('onHeaderValue', true);
|
|
200
|
-
callback('onHeaderEnd');
|
|
201
|
-
state = S.HEADER_VALUE_ALMOST_DONE;
|
|
202
|
-
}
|
|
203
|
-
break;
|
|
204
|
-
case S.HEADER_VALUE_ALMOST_DONE:
|
|
205
|
-
if (c !== LF) {
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
state = S.HEADER_FIELD_START;
|
|
209
|
-
break;
|
|
210
|
-
case S.HEADERS_ALMOST_DONE:
|
|
211
|
-
if (c !== LF) {
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
callback('onHeadersEnd');
|
|
215
|
-
state = S.PART_DATA_START;
|
|
216
|
-
break;
|
|
217
|
-
case S.PART_DATA_START:
|
|
218
|
-
state = S.PART_DATA;
|
|
219
|
-
mark('onPartData');
|
|
220
|
-
// falls through
|
|
221
|
-
case S.PART_DATA:
|
|
222
|
-
previousIndex = index;
|
|
223
|
-
if (index === 0) {
|
|
224
|
-
// boyer-moore derrived algorithm to safely skip non-boundary data
|
|
225
|
-
i += boundaryEnd;
|
|
226
|
-
while (i < bufferLength && !(data[i] in boundaryChars)) {
|
|
227
|
-
i += boundaryLength;
|
|
228
|
-
}
|
|
229
|
-
i -= boundaryEnd;
|
|
230
|
-
c = data[i];
|
|
231
|
-
}
|
|
232
|
-
if (index < boundary.length) {
|
|
233
|
-
if (boundary[index] === c) {
|
|
234
|
-
if (index === 0) {
|
|
235
|
-
dataCallback('onPartData', true);
|
|
236
|
-
}
|
|
237
|
-
index++;
|
|
238
|
-
} else {
|
|
239
|
-
index = 0;
|
|
240
|
-
}
|
|
241
|
-
} else if (index === boundary.length) {
|
|
242
|
-
index++;
|
|
243
|
-
if (c === CR) {
|
|
244
|
-
// CR = part boundary
|
|
245
|
-
flags |= F.PART_BOUNDARY;
|
|
246
|
-
} else if (c === HYPHEN) {
|
|
247
|
-
// HYPHEN = end boundary
|
|
248
|
-
flags |= F.LAST_BOUNDARY;
|
|
249
|
-
} else {
|
|
250
|
-
index = 0;
|
|
251
|
-
}
|
|
252
|
-
} else if (index - 1 === boundary.length) {
|
|
253
|
-
if (flags & F.PART_BOUNDARY) {
|
|
254
|
-
index = 0;
|
|
255
|
-
if (c === LF) {
|
|
256
|
-
// unset the PART_BOUNDARY flag
|
|
257
|
-
flags &= ~F.PART_BOUNDARY;
|
|
258
|
-
callback('onPartEnd');
|
|
259
|
-
callback('onPartBegin');
|
|
260
|
-
state = S.HEADER_FIELD_START;
|
|
261
|
-
break;
|
|
262
|
-
}
|
|
263
|
-
} else if (flags & F.LAST_BOUNDARY) {
|
|
264
|
-
if (c === HYPHEN) {
|
|
265
|
-
callback('onPartEnd');
|
|
266
|
-
state = S.END;
|
|
267
|
-
flags = 0;
|
|
268
|
-
} else {
|
|
269
|
-
index = 0;
|
|
270
|
-
}
|
|
271
|
-
} else {
|
|
272
|
-
index = 0;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
if (index > 0) {
|
|
276
|
-
// when matching a possible boundary, keep a lookbehind reference
|
|
277
|
-
// in case it turns out to be a false lead
|
|
278
|
-
lookbehind[index - 1] = c;
|
|
279
|
-
} else if (previousIndex > 0) {
|
|
280
|
-
// if our boundary turned out to be rubbish, the captured lookbehind
|
|
281
|
-
// belongs to partData
|
|
282
|
-
const _lookbehind = new Uint8Array(lookbehind.buffer, lookbehind.byteOffset, lookbehind.byteLength);
|
|
283
|
-
callback('onPartData', 0, previousIndex, _lookbehind);
|
|
284
|
-
previousIndex = 0;
|
|
285
|
-
mark('onPartData');
|
|
286
|
-
|
|
287
|
-
// reconsider the current character even so it interrupted the sequence
|
|
288
|
-
// it could be the beginning of a new sequence
|
|
289
|
-
i--;
|
|
290
|
-
}
|
|
291
|
-
break;
|
|
292
|
-
case S.END:
|
|
293
|
-
break;
|
|
294
|
-
default:
|
|
295
|
-
throw new Error(`Unexpected state entered: ${state}`);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
dataCallback('onHeaderField');
|
|
299
|
-
dataCallback('onHeaderValue');
|
|
300
|
-
dataCallback('onPartData');
|
|
301
|
-
|
|
302
|
-
// Update properties for the next call
|
|
303
|
-
this.index = index;
|
|
304
|
-
this.state = state;
|
|
305
|
-
this.flags = flags;
|
|
306
|
-
}
|
|
307
|
-
end() {
|
|
308
|
-
if (this.state === S.HEADER_FIELD_START && this.index === 0 || this.state === S.PART_DATA && this.index === this.boundary.length) {
|
|
309
|
-
this.onPartEnd();
|
|
310
|
-
} else if (this.state !== S.END) {
|
|
311
|
-
throw new Error('MultipartParser.end(): stream ended unexpectedly');
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
function _fileName(headerValue) {
|
|
316
|
-
// matches either a quoted-string or a token (RFC 2616 section 19.5.1)
|
|
317
|
-
const m = headerValue.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);
|
|
318
|
-
if (!m) {
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
const match = m[2] || m[3] || '';
|
|
322
|
-
let filename = match.slice(match.lastIndexOf('\\') + 1);
|
|
323
|
-
filename = filename.replace(/%22/g, '"');
|
|
324
|
-
filename = filename.replace(/&#(\d{4});/g, (m, code) => {
|
|
325
|
-
return String.fromCharCode(code);
|
|
326
|
-
});
|
|
327
|
-
return filename;
|
|
328
|
-
}
|
|
329
|
-
async function toFormData(Body, ct) {
|
|
330
|
-
if (!/multipart/i.test(ct)) {
|
|
331
|
-
throw new TypeError('Failed to fetch');
|
|
332
|
-
}
|
|
333
|
-
const m = ct.match(/boundary=(?:"([^"]+)"|([^;]+))/i);
|
|
334
|
-
if (!m) {
|
|
335
|
-
throw new TypeError('no or bad content-type header, no multipart boundary');
|
|
336
|
-
}
|
|
337
|
-
const parser = new MultipartParser(m[1] || m[2]);
|
|
338
|
-
let headerField;
|
|
339
|
-
let headerValue;
|
|
340
|
-
let entryValue;
|
|
341
|
-
let entryName;
|
|
342
|
-
let contentType;
|
|
343
|
-
let filename;
|
|
344
|
-
const entryChunks = [];
|
|
345
|
-
const formData = new index.FormData();
|
|
346
|
-
const onPartData = ui8a => {
|
|
347
|
-
entryValue += decoder.decode(ui8a, {
|
|
348
|
-
stream: true
|
|
349
|
-
});
|
|
350
|
-
};
|
|
351
|
-
const appendToFile = ui8a => {
|
|
352
|
-
entryChunks.push(ui8a);
|
|
353
|
-
};
|
|
354
|
-
const appendFileToFormData = () => {
|
|
355
|
-
const file = new index.File(entryChunks, filename, {
|
|
356
|
-
type: contentType
|
|
357
|
-
});
|
|
358
|
-
formData.append(entryName, file);
|
|
359
|
-
};
|
|
360
|
-
const appendEntryToFormData = () => {
|
|
361
|
-
formData.append(entryName, entryValue);
|
|
362
|
-
};
|
|
363
|
-
const decoder = new TextDecoder('utf-8');
|
|
364
|
-
decoder.decode();
|
|
365
|
-
parser.onPartBegin = function () {
|
|
366
|
-
parser.onPartData = onPartData;
|
|
367
|
-
parser.onPartEnd = appendEntryToFormData;
|
|
368
|
-
headerField = '';
|
|
369
|
-
headerValue = '';
|
|
370
|
-
entryValue = '';
|
|
371
|
-
entryName = '';
|
|
372
|
-
contentType = '';
|
|
373
|
-
filename = null;
|
|
374
|
-
entryChunks.length = 0;
|
|
375
|
-
};
|
|
376
|
-
parser.onHeaderField = function (ui8a) {
|
|
377
|
-
headerField += decoder.decode(ui8a, {
|
|
378
|
-
stream: true
|
|
379
|
-
});
|
|
380
|
-
};
|
|
381
|
-
parser.onHeaderValue = function (ui8a) {
|
|
382
|
-
headerValue += decoder.decode(ui8a, {
|
|
383
|
-
stream: true
|
|
384
|
-
});
|
|
385
|
-
};
|
|
386
|
-
parser.onHeaderEnd = function () {
|
|
387
|
-
headerValue += decoder.decode();
|
|
388
|
-
headerField = headerField.toLowerCase();
|
|
389
|
-
if (headerField === 'content-disposition') {
|
|
390
|
-
// matches either a quoted-string or a token (RFC 2616 section 19.5.1)
|
|
391
|
-
const m = headerValue.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);
|
|
392
|
-
if (m) {
|
|
393
|
-
entryName = m[2] || m[3] || '';
|
|
394
|
-
}
|
|
395
|
-
filename = _fileName(headerValue);
|
|
396
|
-
if (filename) {
|
|
397
|
-
parser.onPartData = appendToFile;
|
|
398
|
-
parser.onPartEnd = appendFileToFormData;
|
|
399
|
-
}
|
|
400
|
-
} else if (headerField === 'content-type') {
|
|
401
|
-
contentType = headerValue;
|
|
402
|
-
}
|
|
403
|
-
headerValue = '';
|
|
404
|
-
headerField = '';
|
|
405
|
-
};
|
|
406
|
-
for await (const chunk of Body) {
|
|
407
|
-
parser.write(chunk);
|
|
408
|
-
}
|
|
409
|
-
parser.end();
|
|
410
|
-
return formData;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
exports.toFormData = toFormData;
|