@celljs/ta-channels 4.35.0 → 4.36.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/extension/index.mjs +399 -3
- package/host/index.mjs +495 -10
- package/package.json +5 -4
- package/web/index.js +402 -2
package/host/index.mjs
CHANGED
|
@@ -1,3 +1,398 @@
|
|
|
1
|
+
// ../../packages/core/esm/common/utils/error-util.js
|
|
2
|
+
class ErrorUtil {
|
|
3
|
+
static fixProto(target, prototype) {
|
|
4
|
+
const setPrototypeOf = Object.setPrototypeOf;
|
|
5
|
+
if (setPrototypeOf) {
|
|
6
|
+
setPrototypeOf(target, prototype);
|
|
7
|
+
} else {
|
|
8
|
+
target.__proto__ = prototype;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
static fixStack(target, fn = target.constructor) {
|
|
12
|
+
const captureStackTrace = Error.captureStackTrace;
|
|
13
|
+
if (captureStackTrace) {
|
|
14
|
+
captureStackTrace(target, fn);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
static describe(error) {
|
|
18
|
+
let text = ErrorUtil.describeOne(error);
|
|
19
|
+
let cause = ErrorUtil.causeOf(error);
|
|
20
|
+
for (let depth = 0;cause !== undefined && depth < 5; depth++) {
|
|
21
|
+
text += `
|
|
22
|
+
Caused by: ${ErrorUtil.describeOne(cause)}`;
|
|
23
|
+
cause = ErrorUtil.causeOf(cause);
|
|
24
|
+
}
|
|
25
|
+
return text;
|
|
26
|
+
}
|
|
27
|
+
static causeOf(error) {
|
|
28
|
+
return error instanceof Error ? error.cause : undefined;
|
|
29
|
+
}
|
|
30
|
+
static describeOne(error) {
|
|
31
|
+
var _a;
|
|
32
|
+
if (error instanceof Error) {
|
|
33
|
+
return (_a = error.stack) !== null && _a !== undefined ? _a : `${error.name}: ${error.message}`;
|
|
34
|
+
}
|
|
35
|
+
return String(error);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ../../packages/core/esm/common/utils/event.js
|
|
40
|
+
var Event;
|
|
41
|
+
(function(Event2) {
|
|
42
|
+
const _disposable = { dispose() {} };
|
|
43
|
+
Event2.None = Object.assign(function() {
|
|
44
|
+
return _disposable;
|
|
45
|
+
}, {
|
|
46
|
+
get maxListeners() {
|
|
47
|
+
return 0;
|
|
48
|
+
},
|
|
49
|
+
set maxListeners(maxListeners) {}
|
|
50
|
+
});
|
|
51
|
+
function map(event, mapFunc) {
|
|
52
|
+
return Object.assign((listener, thisArgs, disposables) => event((i) => listener.call(thisArgs, mapFunc(i)), undefined, disposables), {
|
|
53
|
+
maxListeners: 0
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
Event2.map = map;
|
|
57
|
+
})(Event || (Event = {}));
|
|
58
|
+
|
|
59
|
+
class CallbackList {
|
|
60
|
+
get length() {
|
|
61
|
+
return this._callbacks && this._callbacks.length || 0;
|
|
62
|
+
}
|
|
63
|
+
add(callback, context = undefined, bucket) {
|
|
64
|
+
if (!this._callbacks) {
|
|
65
|
+
this._callbacks = [];
|
|
66
|
+
this._contexts = [];
|
|
67
|
+
}
|
|
68
|
+
this._callbacks.push(callback);
|
|
69
|
+
this._contexts.push(context);
|
|
70
|
+
if (Array.isArray(bucket)) {
|
|
71
|
+
bucket.push({ dispose: () => this.remove(callback, context) });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
remove(callback, context = undefined) {
|
|
75
|
+
if (!this._callbacks) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
let foundCallbackWithDifferentContext = false;
|
|
79
|
+
for (let i = 0;i < this._callbacks.length; i++) {
|
|
80
|
+
if (this._callbacks[i] === callback) {
|
|
81
|
+
if (this._contexts[i] === context) {
|
|
82
|
+
this._callbacks.splice(i, 1);
|
|
83
|
+
this._contexts.splice(i, 1);
|
|
84
|
+
return;
|
|
85
|
+
} else {
|
|
86
|
+
foundCallbackWithDifferentContext = true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (foundCallbackWithDifferentContext) {
|
|
91
|
+
throw new Error("When adding a listener with a context, you should remove it with the same context");
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
*[Symbol.iterator]() {
|
|
95
|
+
if (!this._callbacks) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const callbacks = this._callbacks.slice(0);
|
|
99
|
+
const contexts = this._contexts.slice(0);
|
|
100
|
+
for (let i = 0;i < callbacks.length; i++) {
|
|
101
|
+
const callback = callbacks[i];
|
|
102
|
+
const context = contexts[i];
|
|
103
|
+
yield (...args) => callback.apply(context, args);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
invoke(...args) {
|
|
107
|
+
if (!this._callbacks) {
|
|
108
|
+
return [];
|
|
109
|
+
}
|
|
110
|
+
const callbacks = this._callbacks.slice(0);
|
|
111
|
+
const contexts = this._contexts.slice(0);
|
|
112
|
+
const ret = [];
|
|
113
|
+
for (let i = 0;i < callbacks.length; i++) {
|
|
114
|
+
try {
|
|
115
|
+
ret.push(callbacks[i].apply(contexts[i], args));
|
|
116
|
+
} catch (e) {
|
|
117
|
+
console.error(e);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return ret;
|
|
121
|
+
}
|
|
122
|
+
isEmpty() {
|
|
123
|
+
return !this._callbacks || this._callbacks.length === 0;
|
|
124
|
+
}
|
|
125
|
+
dispose() {
|
|
126
|
+
this._callbacks = undefined;
|
|
127
|
+
this._contexts = undefined;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// ../../packages/core/esm/common/utils/emitter.js
|
|
132
|
+
class Emitter {
|
|
133
|
+
constructor(_options) {
|
|
134
|
+
this._options = _options;
|
|
135
|
+
this._disposed = false;
|
|
136
|
+
this._leakWarnCountdown = 0;
|
|
137
|
+
}
|
|
138
|
+
get event() {
|
|
139
|
+
if (!this._event) {
|
|
140
|
+
this._event = Object.assign((listener, thisArgs, disposables) => {
|
|
141
|
+
if (!this._callbacks) {
|
|
142
|
+
this._callbacks = new CallbackList;
|
|
143
|
+
}
|
|
144
|
+
if (this._options && this._options.onFirstListenerAdd && this._callbacks.isEmpty()) {
|
|
145
|
+
this._options.onFirstListenerAdd(this);
|
|
146
|
+
}
|
|
147
|
+
this._callbacks.add(listener, thisArgs);
|
|
148
|
+
const removeMaxListenersCheck = this.checkMaxListeners(this._event.maxListeners);
|
|
149
|
+
const result = {
|
|
150
|
+
dispose: () => {
|
|
151
|
+
if (removeMaxListenersCheck) {
|
|
152
|
+
removeMaxListenersCheck();
|
|
153
|
+
}
|
|
154
|
+
result.dispose = Emitter._noop;
|
|
155
|
+
if (!this._disposed) {
|
|
156
|
+
this._callbacks.remove(listener, thisArgs);
|
|
157
|
+
result.dispose = Emitter._noop;
|
|
158
|
+
if (this._options && this._options.onLastListenerRemove && this._callbacks.isEmpty()) {
|
|
159
|
+
this._options.onLastListenerRemove(this);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
if (Array.isArray(disposables)) {
|
|
165
|
+
disposables.push(result);
|
|
166
|
+
}
|
|
167
|
+
return result;
|
|
168
|
+
}, {
|
|
169
|
+
maxListeners: Emitter.LEAK_WARNING_THRESHHOLD
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
return this._event;
|
|
173
|
+
}
|
|
174
|
+
checkMaxListeners(maxListeners) {
|
|
175
|
+
if (maxListeners === 0 || !this._callbacks) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const listenerCount = this._callbacks.length;
|
|
179
|
+
if (listenerCount <= maxListeners) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const popStack = this.pushLeakingStack();
|
|
183
|
+
this._leakWarnCountdown -= 1;
|
|
184
|
+
if (this._leakWarnCountdown <= 0) {
|
|
185
|
+
this._leakWarnCountdown = maxListeners * 0.5;
|
|
186
|
+
let topStack;
|
|
187
|
+
let topCount = 0;
|
|
188
|
+
this._leakingStacks.forEach((stackCount, stack) => {
|
|
189
|
+
if (!topStack || topCount < stackCount) {
|
|
190
|
+
topStack = stack;
|
|
191
|
+
topCount = stackCount;
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
console.warn(`Possible Emitter memory leak detected. ${listenerCount} listeners added. Use event.maxListeners to increase the limit (${maxListeners}). MOST frequent listener (${topCount}):`);
|
|
195
|
+
console.warn(topStack);
|
|
196
|
+
}
|
|
197
|
+
return popStack;
|
|
198
|
+
}
|
|
199
|
+
pushLeakingStack() {
|
|
200
|
+
if (!this._leakingStacks) {
|
|
201
|
+
this._leakingStacks = new Map;
|
|
202
|
+
}
|
|
203
|
+
const stack = new Error().stack.split(`
|
|
204
|
+
`).slice(3).join(`
|
|
205
|
+
`);
|
|
206
|
+
const count = this._leakingStacks.get(stack) || 0;
|
|
207
|
+
this._leakingStacks.set(stack, count + 1);
|
|
208
|
+
return () => this.popLeakingStack(stack);
|
|
209
|
+
}
|
|
210
|
+
popLeakingStack(stack) {
|
|
211
|
+
if (!this._leakingStacks) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const count = this._leakingStacks.get(stack) || 0;
|
|
215
|
+
this._leakingStacks.set(stack, count - 1);
|
|
216
|
+
}
|
|
217
|
+
get hasListeners() {
|
|
218
|
+
return !!this._callbacks && !this._callbacks.isEmpty();
|
|
219
|
+
}
|
|
220
|
+
fire(event) {
|
|
221
|
+
if (this._callbacks) {
|
|
222
|
+
this._callbacks.invoke(event);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
async sequence(processor) {
|
|
226
|
+
if (this._callbacks) {
|
|
227
|
+
for (const listener of this._callbacks) {
|
|
228
|
+
if (!await processor(listener)) {
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
dispose() {
|
|
235
|
+
if (this._leakingStacks) {
|
|
236
|
+
this._leakingStacks.clear();
|
|
237
|
+
this._leakingStacks = undefined;
|
|
238
|
+
}
|
|
239
|
+
if (this._callbacks) {
|
|
240
|
+
this._callbacks.dispose();
|
|
241
|
+
this._callbacks = undefined;
|
|
242
|
+
}
|
|
243
|
+
this._disposed = true;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
Emitter.LEAK_WARNING_THRESHHOLD = 175;
|
|
247
|
+
Emitter._noop = function() {};
|
|
248
|
+
var WaitUntilEvent;
|
|
249
|
+
(function(WaitUntilEvent2) {
|
|
250
|
+
async function fire(emitter, event, timeout = undefined) {
|
|
251
|
+
const waitables = [];
|
|
252
|
+
const asyncEvent = Object.assign(event, {
|
|
253
|
+
waitUntil: (thenable) => {
|
|
254
|
+
if (Object.isFrozen(waitables)) {
|
|
255
|
+
throw new Error("waitUntil cannot be called asynchronously.");
|
|
256
|
+
}
|
|
257
|
+
waitables.push(thenable);
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
try {
|
|
261
|
+
emitter.fire(asyncEvent);
|
|
262
|
+
Object.freeze(waitables);
|
|
263
|
+
} finally {
|
|
264
|
+
delete asyncEvent.waitUntil;
|
|
265
|
+
}
|
|
266
|
+
if (!waitables.length) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
if (timeout !== undefined) {
|
|
270
|
+
await Promise.race([Promise.all(waitables), new Promise((resolve) => setTimeout(resolve, timeout))]);
|
|
271
|
+
} else {
|
|
272
|
+
await Promise.all(waitables);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
WaitUntilEvent2.fire = fire;
|
|
276
|
+
})(WaitUntilEvent || (WaitUntilEvent = {}));
|
|
277
|
+
|
|
278
|
+
// ../../packages/core/esm/common/logger/logger-protocol.js
|
|
279
|
+
var LOGGER_CONFIG = "logger";
|
|
280
|
+
var LOGGER_LEVEL = `${LOGGER_CONFIG}.level`;
|
|
281
|
+
var Logger = Symbol("Logger");
|
|
282
|
+
var TraceIdProvider = Symbol("TraceIdProvider");
|
|
283
|
+
var LoggerService = Symbol("LoggerService");
|
|
284
|
+
var LOG_LEVELS = ["verbose", "debug", "info", "warn", "error"];
|
|
285
|
+
var onLogEmitter = new Emitter;
|
|
286
|
+
|
|
287
|
+
// ../../packages/core/esm/common/logger/console-logger.js
|
|
288
|
+
var RANK = Object.fromEntries(LOG_LEVELS.map((level, index) => [level, index]));
|
|
289
|
+
var write = {
|
|
290
|
+
error: (text) => console.error(text),
|
|
291
|
+
warn: (text) => console.warn(text),
|
|
292
|
+
info: (text) => console.info(text),
|
|
293
|
+
debug: (text) => console.debug(text)
|
|
294
|
+
};
|
|
295
|
+
var LEVEL = Symbol.for("@celljs/core/logger/level");
|
|
296
|
+
var Loggers;
|
|
297
|
+
(function(Loggers2) {
|
|
298
|
+
function get(context) {
|
|
299
|
+
return new ConsoleLogger(context);
|
|
300
|
+
}
|
|
301
|
+
Loggers2.get = get;
|
|
302
|
+
function level() {
|
|
303
|
+
var _a;
|
|
304
|
+
const set = globalThis[LEVEL];
|
|
305
|
+
if (set) {
|
|
306
|
+
return set;
|
|
307
|
+
}
|
|
308
|
+
const env = typeof process === "undefined" ? undefined : (_a = process.env) === null || _a === undefined ? undefined : _a.CELL_LOGGER__LEVEL;
|
|
309
|
+
return env && env in RANK ? env : "info";
|
|
310
|
+
}
|
|
311
|
+
Loggers2.level = level;
|
|
312
|
+
function setLevel(level2) {
|
|
313
|
+
globalThis[LEVEL] = level2 && level2 in RANK ? level2 : undefined;
|
|
314
|
+
}
|
|
315
|
+
Loggers2.setLevel = setLevel;
|
|
316
|
+
})(Loggers || (Loggers = {}));
|
|
317
|
+
|
|
318
|
+
class ConsoleLogger {
|
|
319
|
+
constructor(context) {
|
|
320
|
+
this.context = context;
|
|
321
|
+
}
|
|
322
|
+
setContext(context) {
|
|
323
|
+
this.context = context;
|
|
324
|
+
}
|
|
325
|
+
isEnabled(level) {
|
|
326
|
+
var _a, _b;
|
|
327
|
+
return RANK[level] >= ((_b = RANK[(_a = this.level) !== null && _a !== undefined ? _a : Loggers.level()]) !== null && _b !== undefined ? _b : RANK.info);
|
|
328
|
+
}
|
|
329
|
+
error(message, context) {
|
|
330
|
+
this.log(message, context, write.error, "error");
|
|
331
|
+
}
|
|
332
|
+
warn(message, context) {
|
|
333
|
+
if (this.isEnabled("warn")) {
|
|
334
|
+
this.log(message, context, write.warn, "warn");
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
info(message, context) {
|
|
338
|
+
if (this.isEnabled("info")) {
|
|
339
|
+
this.log(message, context, write.info, "info");
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
debug(message, context) {
|
|
343
|
+
if (this.isEnabled("debug")) {
|
|
344
|
+
this.log(message, context, write.debug, "debug");
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
time(label) {
|
|
348
|
+
var _a;
|
|
349
|
+
((_a = this.timeRecords) !== null && _a !== undefined ? _a : this.timeRecords = new Map).set(label, Date.now());
|
|
350
|
+
}
|
|
351
|
+
timeEnd(label, context) {
|
|
352
|
+
var _a;
|
|
353
|
+
const start = (_a = this.timeRecords) === null || _a === undefined ? undefined : _a.get(label);
|
|
354
|
+
if (start !== undefined) {
|
|
355
|
+
const duration = Date.now() - start;
|
|
356
|
+
this.timeRecords.delete(label);
|
|
357
|
+
this.log(`${label} [${duration}ms]`, context);
|
|
358
|
+
return duration;
|
|
359
|
+
} else {
|
|
360
|
+
this.log(`No such label: ${label} for timeEnd`, context);
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
resolveContextString(context) {
|
|
365
|
+
if (this.context) {
|
|
366
|
+
return context ? `[${this.context}] [${context}] ` : `[${this.context}] `;
|
|
367
|
+
}
|
|
368
|
+
return context ? `[${context}] ` : "";
|
|
369
|
+
}
|
|
370
|
+
resolvePrefix(level) {
|
|
371
|
+
const time = new Date().toISOString();
|
|
372
|
+
return `${time} [${level}]`;
|
|
373
|
+
}
|
|
374
|
+
log(message, context, logFn = write.info, level = "info") {
|
|
375
|
+
var _a;
|
|
376
|
+
const traceId = (_a = this.traceIdProvider) === null || _a === undefined ? undefined : _a.provide();
|
|
377
|
+
const contextStr = this.resolveContextString(context);
|
|
378
|
+
const text = message instanceof Error ? ErrorUtil.describe(message) : message;
|
|
379
|
+
let head = this.resolvePrefix(level);
|
|
380
|
+
if (traceId) {
|
|
381
|
+
head = head ? `${head} [trace: ${traceId}]` : `[trace: ${traceId}]`;
|
|
382
|
+
}
|
|
383
|
+
logFn(`${head ? `${head} ` : ""}${contextStr}${text}`);
|
|
384
|
+
if (onLogEmitter.hasListeners) {
|
|
385
|
+
onLogEmitter.fire({
|
|
386
|
+
level,
|
|
387
|
+
traceId,
|
|
388
|
+
rootContext: this.context,
|
|
389
|
+
context,
|
|
390
|
+
message
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
1
396
|
// ../ta-protocol/esm/common/language.js
|
|
2
397
|
var TaLanguageUtil;
|
|
3
398
|
(function(TaLanguageUtil2) {
|
|
@@ -267,7 +662,7 @@ var TaTaskNote;
|
|
|
267
662
|
(function(TaTaskNote2) {
|
|
268
663
|
const NOTE = /^<task_(update|adopted|renamed) ((?:[^>"\n]|"[^"]*")*)>\n?([\s\S]*?)\n?<\/task_\1>$/;
|
|
269
664
|
const ATTRIBUTE = /(\w+)="([^"]*)"/g;
|
|
270
|
-
function
|
|
665
|
+
function write2(note) {
|
|
271
666
|
const attributes = [`id="${quote(note.id)}"`];
|
|
272
667
|
if (note.was !== undefined) {
|
|
273
668
|
attributes.push(`was="${quote(note.was)}"`);
|
|
@@ -280,7 +675,7 @@ var TaTaskNote;
|
|
|
280
675
|
${note.body}
|
|
281
676
|
</task_${note.kind}>`;
|
|
282
677
|
}
|
|
283
|
-
TaTaskNote2.write =
|
|
678
|
+
TaTaskNote2.write = write2;
|
|
284
679
|
function parse(text) {
|
|
285
680
|
const match = NOTE.exec(text.trim());
|
|
286
681
|
if (!match) {
|
|
@@ -3282,6 +3677,52 @@ var TaLocation;
|
|
|
3282
3677
|
return squeezed.length > 1 ? squeezed.replace(/\/$/, "") : squeezed;
|
|
3283
3678
|
}
|
|
3284
3679
|
})(TaLocation || (TaLocation = {}));
|
|
3680
|
+
// ../ta-protocol/esm/common/storage-protocol.js
|
|
3681
|
+
var TaStorageUtil;
|
|
3682
|
+
(function(TaStorageUtil2) {
|
|
3683
|
+
TaStorageUtil2.DAYS = [7, 30, 90, 180, 365, 0];
|
|
3684
|
+
TaStorageUtil2.MB = [100, 500, 1024, 2048, 5120, 0];
|
|
3685
|
+
TaStorageUtil2.KEY = "storage";
|
|
3686
|
+
function id(owner, name) {
|
|
3687
|
+
return `${owner}/${name}`;
|
|
3688
|
+
}
|
|
3689
|
+
TaStorageUtil2.id = id;
|
|
3690
|
+
function set(ta, id2, kinds) {
|
|
3691
|
+
const all = ta && typeof ta === "object" ? ta[TaStorageUtil2.KEY] : undefined;
|
|
3692
|
+
const mine = all && typeof all === "object" ? all[id2] : undefined;
|
|
3693
|
+
return check(mine, kinds);
|
|
3694
|
+
}
|
|
3695
|
+
TaStorageUtil2.set = set;
|
|
3696
|
+
function check(given, kinds) {
|
|
3697
|
+
const out = {};
|
|
3698
|
+
const value = given && typeof given === "object" ? given : {};
|
|
3699
|
+
for (const kind of ["keepDays", "maxMB"]) {
|
|
3700
|
+
const n = Number(value[kind]);
|
|
3701
|
+
if (kinds[kind] !== undefined && value[kind] !== undefined && value[kind] !== null && Number.isFinite(n) && n >= 0) {
|
|
3702
|
+
out[kind] = Math.floor(n);
|
|
3703
|
+
}
|
|
3704
|
+
}
|
|
3705
|
+
return out;
|
|
3706
|
+
}
|
|
3707
|
+
TaStorageUtil2.check = check;
|
|
3708
|
+
function limits(defaults = {}, set2 = {}) {
|
|
3709
|
+
return { ...defaults, ...set2 };
|
|
3710
|
+
}
|
|
3711
|
+
TaStorageUtil2.limits = limits;
|
|
3712
|
+
function retention(limits2) {
|
|
3713
|
+
return {
|
|
3714
|
+
keepDays: limits2.keepDays ? limits2.keepDays : undefined,
|
|
3715
|
+
maxBytes: limits2.maxMB ? limits2.maxMB * 1024 * 1024 : undefined
|
|
3716
|
+
};
|
|
3717
|
+
}
|
|
3718
|
+
TaStorageUtil2.retention = retention;
|
|
3719
|
+
function choices(list, value) {
|
|
3720
|
+
const all = value === undefined || list.includes(value) ? [...list] : [...list, value];
|
|
3721
|
+
return all.sort((a, b) => a === 0 ? 1 : b === 0 ? -1 : a - b);
|
|
3722
|
+
}
|
|
3723
|
+
TaStorageUtil2.choices = choices;
|
|
3724
|
+
})(TaStorageUtil || (TaStorageUtil = {}));
|
|
3725
|
+
|
|
3285
3726
|
// ../ta-protocol/esm/common/metrics-protocol.js
|
|
3286
3727
|
var TA_METRICS_BOUNDS = [10, 50, 200, 1000, 5000, 30000];
|
|
3287
3728
|
var NOT_RUNS = new Set(["turn", "section", "tooldef"]);
|
|
@@ -3291,10 +3732,13 @@ var TaMetricsUtil;
|
|
|
3291
3732
|
TaMetricsUtil2.KEEP_DAYS = 90;
|
|
3292
3733
|
TaMetricsUtil2.MAX_DAYS = 365;
|
|
3293
3734
|
TaMetricsUtil2.MAX_MB = 20;
|
|
3735
|
+
TaMetricsUtil2.STORAGE_ID = "ta/metrics";
|
|
3294
3736
|
function limits(ta) {
|
|
3295
|
-
|
|
3296
|
-
const
|
|
3297
|
-
const
|
|
3737
|
+
var _a, _b;
|
|
3738
|
+
const before = ta && typeof ta === "object" ? ta : {};
|
|
3739
|
+
const set = TaStorageUtil.set(ta, TaMetricsUtil2.STORAGE_ID, { keepDays: TaMetricsUtil2.KEEP_DAYS, maxMB: TaMetricsUtil2.MAX_MB });
|
|
3740
|
+
const days = set.keepDays === 0 ? TaMetricsUtil2.MAX_DAYS : Number((_a = set.keepDays) !== null && _a !== undefined ? _a : before.metricsKeepDays);
|
|
3741
|
+
const mb = set.maxMB === 0 ? 1024 : Number((_b = set.maxMB) !== null && _b !== undefined ? _b : before.metricsMaxMB);
|
|
3298
3742
|
return {
|
|
3299
3743
|
keepDays: Number.isFinite(days) && days >= 1 ? Math.min(TaMetricsUtil2.MAX_DAYS, Math.floor(days)) : TaMetricsUtil2.KEEP_DAYS,
|
|
3300
3744
|
maxBytes: Math.round((Number.isFinite(mb) && mb > 0 ? Math.min(1024, Math.max(1, mb)) : TaMetricsUtil2.MAX_MB) * 1024 * 1024)
|
|
@@ -3616,6 +4060,31 @@ ${line}`, TaMessageContext.strip(plain));
|
|
|
3616
4060
|
var TaRelayServer = Symbol("TaRelayServer");
|
|
3617
4061
|
// ../ta-protocol/esm/common/remote-protocol.js
|
|
3618
4062
|
var TaRemoteServer = Symbol("TaRemoteServer");
|
|
4063
|
+
// ../ta-protocol/esm/common/request-error-protocol.js
|
|
4064
|
+
var TaRequestErrorUtil;
|
|
4065
|
+
(function(TaRequestErrorUtil2) {
|
|
4066
|
+
function reason(errorMessage) {
|
|
4067
|
+
const message = errorMessage !== null && errorMessage !== undefined ? errorMessage : "";
|
|
4068
|
+
if (/\b429\b|rate.?limit|too many requests|quota|usage limit/i.test(message)) {
|
|
4069
|
+
return "rateLimit";
|
|
4070
|
+
}
|
|
4071
|
+
if (/overload|\b529\b|\b503\b|capacity|unavailable/i.test(message)) {
|
|
4072
|
+
return "overloaded";
|
|
4073
|
+
}
|
|
4074
|
+
if (/fetch failed|network|socket|ECONN|ETIMEDOUT|ENOTFOUND|EAI_AGAIN|ENETUNREACH|EHOSTUNREACH|timed? ?out|terminated/i.test(message)) {
|
|
4075
|
+
return "network";
|
|
4076
|
+
}
|
|
4077
|
+
return "error";
|
|
4078
|
+
}
|
|
4079
|
+
TaRequestErrorUtil2.reason = reason;
|
|
4080
|
+
function host(errorMessage) {
|
|
4081
|
+
var _a;
|
|
4082
|
+
const message = errorMessage !== null && errorMessage !== undefined ? errorMessage : "";
|
|
4083
|
+
const named = (_a = /\b(?:ENOTFOUND|EAI_AGAIN)\s+([a-z0-9.-]+\.[a-z]{2,})/i.exec(message)) !== null && _a !== undefined ? _a : /https?:\/\/([a-z0-9.-]+\.[a-z]{2,})/i.exec(message);
|
|
4084
|
+
return named === null || named === undefined ? undefined : named[1].toLowerCase();
|
|
4085
|
+
}
|
|
4086
|
+
TaRequestErrorUtil2.host = host;
|
|
4087
|
+
})(TaRequestErrorUtil || (TaRequestErrorUtil = {}));
|
|
3619
4088
|
// ../ta-protocol/esm/common/room-protocol.js
|
|
3620
4089
|
var TaRoomServer = Symbol("TaRoomServer");
|
|
3621
4090
|
var TA_PICTURE = { key: "picture:", maxChars: 16 * 1024 };
|
|
@@ -3752,6 +4221,7 @@ var TA_SETTINGS = [
|
|
|
3752
4221
|
{ key: "compaction.keepRecentTokens", type: "number", default: 20000 },
|
|
3753
4222
|
{ key: "retry.enabled", type: "boolean", default: true },
|
|
3754
4223
|
{ key: "retry.maxRetries", type: "number", default: 3 },
|
|
4224
|
+
{ key: "retry.untilOnline", type: "boolean", default: true },
|
|
3755
4225
|
{ key: "codemode.mode", type: "enum", values: ["only", "on"], default: "only" },
|
|
3756
4226
|
{ key: "enableSkillCommands", type: "boolean", default: true },
|
|
3757
4227
|
{ key: "images.autoResize", type: "boolean", default: true },
|
|
@@ -3759,9 +4229,7 @@ var TA_SETTINGS = [
|
|
|
3759
4229
|
{ key: "shellPath", type: "string" },
|
|
3760
4230
|
{ key: "shellCommandPrefix", type: "string" }
|
|
3761
4231
|
];
|
|
3762
|
-
// ../ta-protocol/esm/common/
|
|
3763
|
-
var TaServer = Symbol("TaServer");
|
|
3764
|
-
var TaClient = Symbol("TaClient");
|
|
4232
|
+
// ../ta-protocol/esm/common/slash-command-protocol.js
|
|
3765
4233
|
var TaSlashCommandUtil;
|
|
3766
4234
|
(function(TaSlashCommandUtil2) {
|
|
3767
4235
|
function description(command2, language) {
|
|
@@ -3771,6 +4239,18 @@ var TaSlashCommandUtil;
|
|
|
3771
4239
|
}
|
|
3772
4240
|
TaSlashCommandUtil2.description = description;
|
|
3773
4241
|
})(TaSlashCommandUtil || (TaSlashCommandUtil = {}));
|
|
4242
|
+
// ../ta-protocol/esm/common/ta-credentials.js
|
|
4243
|
+
var TA_CREDENTIAL_FEATURES = ["desktop", "bot", "relay", "store", "model"];
|
|
4244
|
+
var TaCredentialUtil;
|
|
4245
|
+
(function(TaCredentialUtil2) {
|
|
4246
|
+
function feature(value) {
|
|
4247
|
+
return TA_CREDENTIAL_FEATURES.includes(value) ? value : "desktop";
|
|
4248
|
+
}
|
|
4249
|
+
TaCredentialUtil2.feature = feature;
|
|
4250
|
+
})(TaCredentialUtil || (TaCredentialUtil = {}));
|
|
4251
|
+
// ../ta-protocol/esm/common/ta-protocol.js
|
|
4252
|
+
var TaServer = Symbol("TaServer");
|
|
4253
|
+
var TaClient = Symbol("TaClient");
|
|
3774
4254
|
// ../ta-protocol/esm/common/team-protocol.js
|
|
3775
4255
|
var TA_OWNER = "owner";
|
|
3776
4256
|
var TA_UNDECLARED = "extensions.install";
|
|
@@ -3839,7 +4319,10 @@ var TA_ACTIONS = [
|
|
|
3839
4319
|
];
|
|
3840
4320
|
var TA_OWNER_ACTIONS = [
|
|
3841
4321
|
action("desktop.view", "See remote desktops", "查看远程桌面", "檢視遠端桌面", "リモートデスクトップを見る", { risky: true }),
|
|
3842
|
-
action("desktop.control", "Work remote desktops", "操作远程桌面", "操作遠端桌面", "リモートデスクトップを操作", { risky: true })
|
|
4322
|
+
action("desktop.control", "Work remote desktops", "操作远程桌面", "操作遠端桌面", "リモートデスクトップを操作", { risky: true }),
|
|
4323
|
+
action("models.owner", "Ask models on the owner's keys", "用你的密钥和本机模型做判断", "用你的金鑰和本機模型做判斷", "あなたのキーとローカルモデルで判断", {
|
|
4324
|
+
risky: true
|
|
4325
|
+
})
|
|
3843
4326
|
];
|
|
3844
4327
|
var OWNER_AREAS = ["desktop"];
|
|
3845
4328
|
var TaActionUtil;
|
|
@@ -4703,6 +5186,8 @@ class TeamAnswers extends TeamStore {
|
|
|
4703
5186
|
}
|
|
4704
5187
|
|
|
4705
5188
|
// web-src/team.ts
|
|
5189
|
+
var logger = Loggers.get("ta-channels");
|
|
5190
|
+
|
|
4706
5191
|
class TeamService extends TeamAnswers {
|
|
4707
5192
|
async start() {
|
|
4708
5193
|
this.team = await this.get(Keys.TEAM) ?? ChannelsUtil.emptyTeam();
|
|
@@ -5031,7 +5516,7 @@ class TeamService extends TeamAnswers {
|
|
|
5031
5516
|
this.started.add(job.id);
|
|
5032
5517
|
const next = (this.agents.get(job.agentId) ?? Promise.resolve()).catch(() => {
|
|
5033
5518
|
return;
|
|
5034
|
-
}).then(() => this.work(job)).catch((error) =>
|
|
5519
|
+
}).then(() => this.work(job)).catch((error) => logger.error(error instanceof Error ? error.message : error));
|
|
5035
5520
|
this.agents.set(job.agentId, next);
|
|
5036
5521
|
}
|
|
5037
5522
|
async work(job) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-channels",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.36.0",
|
|
4
4
|
"description": "A pi package for Ta: agents with roles of their own and channels where the user, Ta and the agents talk; Ta builds the team for what the user wants",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
@@ -27,9 +27,10 @@
|
|
|
27
27
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@celljs/
|
|
31
|
-
"@celljs/ta-
|
|
32
|
-
"@celljs/ta-
|
|
30
|
+
"@celljs/core": "4.36.0",
|
|
31
|
+
"@celljs/ta-protocol": "4.36.0",
|
|
32
|
+
"@celljs/ta-relay": "4.36.0",
|
|
33
|
+
"@celljs/ta-web": "4.36.0",
|
|
33
34
|
"@types/react": "^19.3.0"
|
|
34
35
|
},
|
|
35
36
|
"publishConfig": {
|