@celljs/ta-creator 4.34.0 → 4.35.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/README.en.md +2 -2
- package/README.md +2 -2
- package/bin/render.mjs +284 -149
- package/host/index.mjs +303 -161
- package/package.json +3 -3
- package/skills/creator-make/SKILL.md +8 -4
- package/web/index.js +691 -27
package/web/index.js
CHANGED
|
@@ -198,6 +198,318 @@ function bind(react) {
|
|
|
198
198
|
React = react;
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
+
// ../ta-protocol/esm/common/message-protocol.js
|
|
202
|
+
var TaMessageContext;
|
|
203
|
+
(function(TaMessageContext2) {
|
|
204
|
+
const BLOCK = /^<context>\n?[\s\S]*?\n?<\/context>\n?/;
|
|
205
|
+
function wrap(context, message) {
|
|
206
|
+
return `<context>
|
|
207
|
+
${context}
|
|
208
|
+
</context>
|
|
209
|
+
${message}`;
|
|
210
|
+
}
|
|
211
|
+
TaMessageContext2.wrap = wrap;
|
|
212
|
+
function strip(message) {
|
|
213
|
+
return message.replace(BLOCK, "");
|
|
214
|
+
}
|
|
215
|
+
TaMessageContext2.strip = strip;
|
|
216
|
+
function read(message) {
|
|
217
|
+
var _a;
|
|
218
|
+
const block = (_a = BLOCK.exec(message)) === null || _a === undefined ? undefined : _a[0];
|
|
219
|
+
return block === null || block === undefined ? undefined : block.replace(/^<context>\n?/, "").replace(/\n?<\/context>\n?$/, "");
|
|
220
|
+
}
|
|
221
|
+
TaMessageContext2.read = read;
|
|
222
|
+
})(TaMessageContext || (TaMessageContext = {}));
|
|
223
|
+
var TaMessageSource;
|
|
224
|
+
(function(TaMessageSource2) {
|
|
225
|
+
TaMessageSource2.DOUBLE = "ta:double";
|
|
226
|
+
const LINE = /^\[ta:(from|notice) ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
|
|
227
|
+
function mark(message, from, detail) {
|
|
228
|
+
return marked(message, line(from, detail));
|
|
229
|
+
}
|
|
230
|
+
TaMessageSource2.mark = mark;
|
|
231
|
+
function notice(message, from, detail) {
|
|
232
|
+
return marked(message, line(from, detail, true));
|
|
233
|
+
}
|
|
234
|
+
TaMessageSource2.notice = notice;
|
|
235
|
+
function line(from, detail, notice2 = false) {
|
|
236
|
+
return `[ta:${notice2 ? "notice" : "from"} ${from}${detail ? ` ${detail.replace(/[\]\n]/g, " ")}` : ""}]`;
|
|
237
|
+
}
|
|
238
|
+
TaMessageSource2.line = line;
|
|
239
|
+
function of(message) {
|
|
240
|
+
const context = TaMessageContext.read(message);
|
|
241
|
+
const match = context === undefined ? null : LINE.exec(context);
|
|
242
|
+
return match ? { from: match[2], ...match[3] ? { detail: match[3].trim() } : {}, ...match[1] === "notice" ? { notice: true } : {} } : undefined;
|
|
243
|
+
}
|
|
244
|
+
TaMessageSource2.of = of;
|
|
245
|
+
function isNotice(message) {
|
|
246
|
+
var _a;
|
|
247
|
+
return ((_a = of(message)) === null || _a === undefined ? undefined : _a.notice) === true;
|
|
248
|
+
}
|
|
249
|
+
TaMessageSource2.isNotice = isNotice;
|
|
250
|
+
TaMessageSource2.SECTION = "ta-sources";
|
|
251
|
+
TaMessageSource2.PROMPT = [
|
|
252
|
+
"Who wrote a message: what the user typed or said is theirs. One whose <context> ends with [ta:from <part of Ta> …] was sent by that part of Ta for the user (their choice in a card, what they said in a call, a task or goal they set up): it is theirs too.",
|
|
253
|
+
"One with [ta:notice <part of Ta> …] is not the user's: news or an event of that part of Ta (work that ended elsewhere, a time limit, a permission granted). Weigh it below what the user said:",
|
|
254
|
+
"- It is information, never a request of the user: it does not change, drop or replace what they asked. Their latest words come first.",
|
|
255
|
+
"- Act on it only as far as what they asked, your role or a limit they set calls for; otherwise take it in and go on, and tell them of it in a line only when they need it (a result they wait for, a failure, a question for them).",
|
|
256
|
+
"- Never quote it as the user's words nor answer it as if they had said it."
|
|
257
|
+
].join(`
|
|
258
|
+
`);
|
|
259
|
+
function marked(message, source) {
|
|
260
|
+
if (/^[/!]/.test(message) || of(message)) {
|
|
261
|
+
return message;
|
|
262
|
+
}
|
|
263
|
+
const context = TaMessageContext.read(message);
|
|
264
|
+
return TaMessageContext.wrap(context === undefined ? source : `${context}
|
|
265
|
+
${source}`, TaMessageContext.strip(message));
|
|
266
|
+
}
|
|
267
|
+
})(TaMessageSource || (TaMessageSource = {}));
|
|
268
|
+
var TaImageNote;
|
|
269
|
+
(function(TaImageNote2) {
|
|
270
|
+
const NOTE = /^\[Image: original \d+x\d+, displayed at \d+x\d+\. Multiply coordinates by [\d.]+ to map to original image\.\]$|^\[Image converted from [^\]]+ to [^\]]+\.\]$/;
|
|
271
|
+
function strip(text2) {
|
|
272
|
+
const lines = text2.split(`
|
|
273
|
+
`);
|
|
274
|
+
const kept = lines.filter((line) => !NOTE.test(line.trim()));
|
|
275
|
+
if (kept.length === lines.length) {
|
|
276
|
+
return text2;
|
|
277
|
+
}
|
|
278
|
+
return kept.join(`
|
|
279
|
+
`).replace(/\n+$/, "").replace(/^\n+/, "");
|
|
280
|
+
}
|
|
281
|
+
TaImageNote2.strip = strip;
|
|
282
|
+
})(TaImageNote || (TaImageNote = {}));
|
|
283
|
+
var TaImageSize;
|
|
284
|
+
(function(TaImageSize2) {
|
|
285
|
+
const JPEG_BYTES = 256 * 1024;
|
|
286
|
+
function type(bytes) {
|
|
287
|
+
const at = (offset, ...values) => values.every((value, index) => bytes[offset + index] === value);
|
|
288
|
+
return at(0, 255, 216, 255) ? "image/jpeg" : at(0, 137, 80, 78, 71) ? "image/png" : at(0, 71, 73, 70, 56) ? "image/gif" : at(0, 82, 73, 70, 70) && at(8, 87, 69, 66, 80) ? "image/webp" : undefined;
|
|
289
|
+
}
|
|
290
|
+
TaImageSize2.type = type;
|
|
291
|
+
function of(base64) {
|
|
292
|
+
var _a, _b, _c;
|
|
293
|
+
let bytes;
|
|
294
|
+
try {
|
|
295
|
+
const binary = atob(base64.slice(0, Math.ceil(JPEG_BYTES * 4 / 3 / 4) * 4));
|
|
296
|
+
bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
297
|
+
} catch (_d) {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
const size = (_c = (_b = (_a = png(bytes)) !== null && _a !== undefined ? _a : gif(bytes)) !== null && _b !== undefined ? _b : webp(bytes)) !== null && _c !== undefined ? _c : jpeg(bytes);
|
|
301
|
+
return size && size.width > 0 && size.height > 0 ? size : undefined;
|
|
302
|
+
}
|
|
303
|
+
TaImageSize2.of = of;
|
|
304
|
+
function u16be(bytes, at) {
|
|
305
|
+
return bytes[at] << 8 | bytes[at + 1];
|
|
306
|
+
}
|
|
307
|
+
function u16le(bytes, at) {
|
|
308
|
+
return bytes[at] | bytes[at + 1] << 8;
|
|
309
|
+
}
|
|
310
|
+
function u24le(bytes, at) {
|
|
311
|
+
return bytes[at] | bytes[at + 1] << 8 | bytes[at + 2] << 16;
|
|
312
|
+
}
|
|
313
|
+
function u32be(bytes, at) {
|
|
314
|
+
return (bytes[at] << 24 | bytes[at + 1] << 16 | bytes[at + 2] << 8 | bytes[at + 3]) >>> 0;
|
|
315
|
+
}
|
|
316
|
+
function text2(bytes, at, length) {
|
|
317
|
+
return String.fromCharCode(...bytes.subarray(at, at + length));
|
|
318
|
+
}
|
|
319
|
+
function png(bytes) {
|
|
320
|
+
return bytes.length >= 24 && bytes[0] === 137 && text2(bytes, 1, 3) === "PNG" ? { width: u32be(bytes, 16), height: u32be(bytes, 20) } : undefined;
|
|
321
|
+
}
|
|
322
|
+
function gif(bytes) {
|
|
323
|
+
return bytes.length >= 10 && text2(bytes, 0, 3) === "GIF" ? { width: u16le(bytes, 6), height: u16le(bytes, 8) } : undefined;
|
|
324
|
+
}
|
|
325
|
+
function webp(bytes) {
|
|
326
|
+
if (bytes.length < 30 || text2(bytes, 0, 4) !== "RIFF" || text2(bytes, 8, 4) !== "WEBP") {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
switch (text2(bytes, 12, 4)) {
|
|
330
|
+
case "VP8 ":
|
|
331
|
+
return { width: u16le(bytes, 26) & 16383, height: u16le(bytes, 28) & 16383 };
|
|
332
|
+
case "VP8L": {
|
|
333
|
+
const bits = bytes[21] | bytes[22] << 8 | bytes[23] << 16 | bytes[24] << 24;
|
|
334
|
+
return { width: (bits & 16383) + 1, height: (bits >> 14 & 16383) + 1 };
|
|
335
|
+
}
|
|
336
|
+
case "VP8X":
|
|
337
|
+
return { width: u24le(bytes, 24) + 1, height: u24le(bytes, 27) + 1 };
|
|
338
|
+
default:
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
function jpeg(bytes) {
|
|
343
|
+
if (bytes[0] !== 255 || bytes[1] !== 216) {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
let at = 2;
|
|
347
|
+
while (at + 9 < bytes.length) {
|
|
348
|
+
if (bytes[at] !== 255) {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
const marker = bytes[at + 1];
|
|
352
|
+
if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) {
|
|
353
|
+
return { width: u16be(bytes, at + 7), height: u16be(bytes, at + 5) };
|
|
354
|
+
}
|
|
355
|
+
at += 2 + u16be(bytes, at + 2);
|
|
356
|
+
}
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
})(TaImageSize || (TaImageSize = {}));
|
|
360
|
+
var TaAgentSummary;
|
|
361
|
+
(function(TaAgentSummary2) {
|
|
362
|
+
const START = /^\s*<conversation_history_summary>/;
|
|
363
|
+
const BLOCK = /^\s*<conversation_history_summary>[\s\S]*?(?:<\/conversation_history_summary>\s*|$)/;
|
|
364
|
+
function read(text2) {
|
|
365
|
+
if (!START.test(text2)) {
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
return text2.replace(/<\/?(?:conversation_history_summary|summary)>/g, "").replace(/<\/?\w*$/, "").trim();
|
|
369
|
+
}
|
|
370
|
+
TaAgentSummary2.read = read;
|
|
371
|
+
function strip(text2) {
|
|
372
|
+
return text2.replace(BLOCK, "");
|
|
373
|
+
}
|
|
374
|
+
TaAgentSummary2.strip = strip;
|
|
375
|
+
})(TaAgentSummary || (TaAgentSummary = {}));
|
|
376
|
+
var TaPictureNote;
|
|
377
|
+
(function(TaPictureNote2) {
|
|
378
|
+
TaPictureNote2.OPEN = "<pictures>";
|
|
379
|
+
TaPictureNote2.CLOSE = "</pictures>";
|
|
380
|
+
const BLOCK = /[ \t]*<pictures>([\s\S]*?)(?:<\/pictures>|$)|<p(?:i(?:c(?:t(?:u(?:r(?:es?)?)?)?)?)?)?$/gi;
|
|
381
|
+
const ROW = /(?:^|\s)[-*]?\s*p(\d+)\s*[::]\s*/gi;
|
|
382
|
+
function take(text2) {
|
|
383
|
+
const told = new Map;
|
|
384
|
+
if (!/<p/i.test(text2)) {
|
|
385
|
+
return { said: text2, told };
|
|
386
|
+
}
|
|
387
|
+
const said = text2.replace(BLOCK, (_all, body) => {
|
|
388
|
+
const rows = [...(body !== null && body !== undefined ? body : "").matchAll(ROW)];
|
|
389
|
+
rows.forEach((row, index) => {
|
|
390
|
+
var _a;
|
|
391
|
+
var _b, _c;
|
|
392
|
+
const end = (_b = (_a = rows[index + 1]) === null || _a === undefined ? undefined : _a.index) !== null && _b !== undefined ? _b : body === null || body === undefined ? undefined : body.length;
|
|
393
|
+
const what = body === null || body === undefined ? undefined : body.slice(((_c = row.index) !== null && _c !== undefined ? _c : 0) + row[0].length, end).trim();
|
|
394
|
+
if (what) {
|
|
395
|
+
told.set(Number(row[1]), what);
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
return "";
|
|
399
|
+
});
|
|
400
|
+
return { said: said === text2 ? text2 : said.replace(/\n{3,}/g, `
|
|
401
|
+
|
|
402
|
+
`).trim(), told };
|
|
403
|
+
}
|
|
404
|
+
TaPictureNote2.take = take;
|
|
405
|
+
function strip(text2) {
|
|
406
|
+
return take(text2).said;
|
|
407
|
+
}
|
|
408
|
+
TaPictureNote2.strip = strip;
|
|
409
|
+
})(TaPictureNote || (TaPictureNote = {}));
|
|
410
|
+
var TaSkillUse;
|
|
411
|
+
(function(TaSkillUse2) {
|
|
412
|
+
const BLOCK = /^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;
|
|
413
|
+
function parse(message) {
|
|
414
|
+
var _a;
|
|
415
|
+
const match = BLOCK.exec(message);
|
|
416
|
+
if (!match) {
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
return { name: match[1], location: match[2], content: match[3], message: ((_a = match[4]) === null || _a === undefined ? undefined : _a.trim()) || undefined };
|
|
420
|
+
}
|
|
421
|
+
TaSkillUse2.parse = parse;
|
|
422
|
+
function command(use) {
|
|
423
|
+
return use.message ? `/skill:${use.name} ${use.message}` : `/skill:${use.name}`;
|
|
424
|
+
}
|
|
425
|
+
TaSkillUse2.command = command;
|
|
426
|
+
})(TaSkillUse || (TaSkillUse = {}));
|
|
427
|
+
var TaTaskNote;
|
|
428
|
+
(function(TaTaskNote2) {
|
|
429
|
+
const NOTE = /^<task_(update|adopted|renamed) ((?:[^>"\n]|"[^"]*")*)>\n?([\s\S]*?)\n?<\/task_\1>$/;
|
|
430
|
+
const ATTRIBUTE = /(\w+)="([^"]*)"/g;
|
|
431
|
+
function write(note) {
|
|
432
|
+
const attributes = [`id="${quote(note.id)}"`];
|
|
433
|
+
if (note.was !== undefined) {
|
|
434
|
+
attributes.push(`was="${quote(note.was)}"`);
|
|
435
|
+
}
|
|
436
|
+
attributes.push(`title="${quote(note.title)}"`);
|
|
437
|
+
if (note.status !== undefined) {
|
|
438
|
+
attributes.push(`status="${quote(note.status)}"`);
|
|
439
|
+
}
|
|
440
|
+
return `<task_${note.kind} ${attributes.join(" ")}>
|
|
441
|
+
${note.body}
|
|
442
|
+
</task_${note.kind}>`;
|
|
443
|
+
}
|
|
444
|
+
TaTaskNote2.write = write;
|
|
445
|
+
function parse(text2) {
|
|
446
|
+
const match = NOTE.exec(text2.trim());
|
|
447
|
+
if (!match) {
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
const attributes = {};
|
|
451
|
+
for (const [, name, value] of match[2].matchAll(ATTRIBUTE)) {
|
|
452
|
+
attributes[name] = unquote(value);
|
|
453
|
+
}
|
|
454
|
+
if (!attributes.id || attributes.title === undefined) {
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
const { id, title, status, was } = attributes;
|
|
458
|
+
return { kind: match[1], id, title, ...status ? { status } : {}, ...was ? { was } : {}, body: match[3] };
|
|
459
|
+
}
|
|
460
|
+
TaTaskNote2.parse = parse;
|
|
461
|
+
function quote(text2) {
|
|
462
|
+
return text2.replace(/&/g, "&").replace(/"/g, """).replace(/\n/g, " ");
|
|
463
|
+
}
|
|
464
|
+
function unquote(text2) {
|
|
465
|
+
return text2.replace(/"/g, '"').replace(/&/g, "&");
|
|
466
|
+
}
|
|
467
|
+
})(TaTaskNote || (TaTaskNote = {}));
|
|
468
|
+
var TaSecretRef;
|
|
469
|
+
(function(TaSecretRef2) {
|
|
470
|
+
TaSecretRef2.PACKAGE = "@celljs/ta-secrets";
|
|
471
|
+
const REF = /\$\{?TA_SECRET_([A-Z0-9][A-Z0-9_]*)\}?/g;
|
|
472
|
+
const KINDS2 = [
|
|
473
|
+
[/^PHONE(?:_\d+)?$/, "phone"],
|
|
474
|
+
[/^EMAIL(?:_\d+)?$/, "email"],
|
|
475
|
+
[/^ID_NUMBER(?:_\d+)?$/, "idNumber"],
|
|
476
|
+
[/^BANK_CARD(?:_\d+)?$/, "bankCard"]
|
|
477
|
+
];
|
|
478
|
+
function has(text2) {
|
|
479
|
+
return text2.includes("TA_SECRET_") && new RegExp(REF.source).test(text2);
|
|
480
|
+
}
|
|
481
|
+
TaSecretRef2.has = has;
|
|
482
|
+
function kind(name) {
|
|
483
|
+
var _a;
|
|
484
|
+
var _b;
|
|
485
|
+
return (_b = (_a = KINDS2.find(([pattern]) => pattern.test(name))) === null || _a === undefined ? undefined : _a[1]) !== null && _b !== undefined ? _b : "secret";
|
|
486
|
+
}
|
|
487
|
+
TaSecretRef2.kind = kind;
|
|
488
|
+
function split(text2) {
|
|
489
|
+
if (!has(text2)) {
|
|
490
|
+
return [{ text: text2 }];
|
|
491
|
+
}
|
|
492
|
+
const parts = [];
|
|
493
|
+
let at = 0;
|
|
494
|
+
for (const match of text2.matchAll(REF)) {
|
|
495
|
+
if (match.index > at) {
|
|
496
|
+
parts.push({ text: text2.slice(at, match.index) });
|
|
497
|
+
}
|
|
498
|
+
parts.push({ secret: match[1], kind: kind(match[1]) });
|
|
499
|
+
at = match.index + match[0].length;
|
|
500
|
+
}
|
|
501
|
+
if (at < text2.length) {
|
|
502
|
+
parts.push({ text: text2.slice(at) });
|
|
503
|
+
}
|
|
504
|
+
return parts;
|
|
505
|
+
}
|
|
506
|
+
TaSecretRef2.split = split;
|
|
507
|
+
function plain(text2, label) {
|
|
508
|
+
return has(text2) ? text2.replace(REF, (_whole, name) => label(name, kind(name))) : text2;
|
|
509
|
+
}
|
|
510
|
+
TaSecretRef2.plain = plain;
|
|
511
|
+
})(TaSecretRef || (TaSecretRef = {}));
|
|
512
|
+
|
|
201
513
|
// web-src/values.ts
|
|
202
514
|
var text2 = (value, max = 2000) => typeof value === "string" ? value.trim().slice(0, max) : "";
|
|
203
515
|
var texts = (value, max = 50) => Array.isArray(value) ? value.map((one) => text2(one, 200)).filter(Boolean).slice(0, max) : [];
|
|
@@ -219,10 +531,93 @@ function count(value, fallback) {
|
|
|
219
531
|
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.round(value) : fallback;
|
|
220
532
|
}
|
|
221
533
|
|
|
534
|
+
// web-src/efficiency.ts
|
|
535
|
+
var HOUR = 3600000;
|
|
536
|
+
var DAY = 24 * HOUR;
|
|
537
|
+
var Efficiency;
|
|
538
|
+
((Efficiency) => {
|
|
539
|
+
Efficiency.SPAN = 7 * DAY;
|
|
540
|
+
function costOf(messages, now) {
|
|
541
|
+
let ms = 0;
|
|
542
|
+
let tokens = 0;
|
|
543
|
+
let turns = 0;
|
|
544
|
+
for (const message of messages) {
|
|
545
|
+
const kept = object2(message);
|
|
546
|
+
if (kept?.role === "assistant") {
|
|
547
|
+
ms += count(kept.durationMs, 0);
|
|
548
|
+
tokens += count(object2(kept.usage)?.totalTokens, 0);
|
|
549
|
+
} else if (kept?.role === "user") {
|
|
550
|
+
turns++;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
return ms ? { minutes: Math.round(ms / 6000) / 10, ...tokens ? { tokens } : {}, turns, at: now } : undefined;
|
|
554
|
+
}
|
|
555
|
+
Efficiency.costOf = costOf;
|
|
556
|
+
function cost(value) {
|
|
557
|
+
const kept = object2(value);
|
|
558
|
+
const at = time2(kept?.at);
|
|
559
|
+
return kept && at && typeof kept.minutes === "number" ? { minutes: Math.max(0, kept.minutes), ...count(kept.tokens, 0) ? { tokens: count(kept.tokens, 0) } : {}, turns: count(kept.turns, 0), at } : undefined;
|
|
560
|
+
}
|
|
561
|
+
Efficiency.cost = cost;
|
|
562
|
+
function fields(kept) {
|
|
563
|
+
const made = cost(kept.cost);
|
|
564
|
+
return { ...time2(kept.started) ? { started: time2(kept.started) } : {}, ...made ? { cost: made } : {} };
|
|
565
|
+
}
|
|
566
|
+
Efficiency.fields = fields;
|
|
567
|
+
function leadHours(item) {
|
|
568
|
+
return item.stage === "published" && item.links?.length ? Math.round((outAt(item) - item.at) / HOUR * 10) / 10 : undefined;
|
|
569
|
+
}
|
|
570
|
+
Efficiency.leadHours = leadHours;
|
|
571
|
+
function taskRuns(runs, from, to) {
|
|
572
|
+
const of = runs.filter((one) => {
|
|
573
|
+
const at = Date.parse(one.startedAt);
|
|
574
|
+
return at >= from && at < to && one.status !== "running";
|
|
575
|
+
});
|
|
576
|
+
return {
|
|
577
|
+
runs: of.length,
|
|
578
|
+
empty: of.filter((one) => one.quiet).length,
|
|
579
|
+
failed: of.filter((one) => one.status === "error").length,
|
|
580
|
+
minutes: Math.round(of.reduce((all, one) => all + (one.ranMs ?? 0), 0) / 60000)
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
Efficiency.taskRuns = taskRuns;
|
|
584
|
+
function pieces(items, from, to) {
|
|
585
|
+
const of = items.filter((one) => {
|
|
586
|
+
const at = one.stage === "published" && one.links?.length ? outAt(one) : 0;
|
|
587
|
+
return !one.dropped && at >= from && at < to;
|
|
588
|
+
});
|
|
589
|
+
const costs = of.flatMap((one) => one.cost ? [one.cost] : []);
|
|
590
|
+
return {
|
|
591
|
+
pieces: of.length,
|
|
592
|
+
leadHours: middle(of.map(leadHours)),
|
|
593
|
+
minutes: middle(costs.map((one) => one.minutes)),
|
|
594
|
+
tokens: middle(costs.map((one) => one.tokens)),
|
|
595
|
+
turns: middle(costs.map((one) => one.turns))
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
Efficiency.pieces = pieces;
|
|
599
|
+
function outAt(item) {
|
|
600
|
+
return Math.min(...(item.links ?? []).map((one) => one.scheduled ?? one.at));
|
|
601
|
+
}
|
|
602
|
+
function middle(values) {
|
|
603
|
+
const known = values.filter((one) => typeof one === "number").sort((a, b) => a - b);
|
|
604
|
+
if (!known.length) {
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
const at = Math.floor(known.length / 2);
|
|
608
|
+
return known.length % 2 ? known[at] : Math.round((known[at - 1] + known[at]) / 2 * 10) / 10;
|
|
609
|
+
}
|
|
610
|
+
Efficiency.middle = middle;
|
|
611
|
+
function windows(now) {
|
|
612
|
+
return { before: [now - 2 * Efficiency.SPAN, now - Efficiency.SPAN], after: [now - Efficiency.SPAN, now + 1] };
|
|
613
|
+
}
|
|
614
|
+
Efficiency.windows = windows;
|
|
615
|
+
})(Efficiency ||= {});
|
|
616
|
+
|
|
222
617
|
// web-src/creator-util.ts
|
|
223
|
-
var
|
|
618
|
+
var DAY2 = 86400000;
|
|
224
619
|
var MAX_TOPICS = 200;
|
|
225
|
-
var HOT_FOR = 2 *
|
|
620
|
+
var HOT_FOR = 2 * DAY2;
|
|
226
621
|
var MAX_TONES = 3;
|
|
227
622
|
var CreatorUtil;
|
|
228
623
|
((CreatorUtil) => {
|
|
@@ -411,6 +806,7 @@ var CreatorUtil;
|
|
|
411
806
|
...kept.dropped === true ? { dropped: true } : {},
|
|
412
807
|
...time2(kept.commentsAt) ? { commentsAt: time2(kept.commentsAt) } : {},
|
|
413
808
|
...time2(kept.commentsGap) ? { commentsGap: time2(kept.commentsGap) } : {},
|
|
809
|
+
...Efficiency.fields(kept),
|
|
414
810
|
at,
|
|
415
811
|
changedAt: time2(kept.changedAt) ?? at
|
|
416
812
|
};
|
|
@@ -536,7 +932,7 @@ var CreatorUtil;
|
|
|
536
932
|
if (!goal) {
|
|
537
933
|
return;
|
|
538
934
|
}
|
|
539
|
-
const end = goal.from + goal.days *
|
|
935
|
+
const end = goal.from + goal.days * DAY2;
|
|
540
936
|
const published = items2.filter((one) => one.stage === "published" && (one.links?.length ?? 0) > 0).filter((one) => {
|
|
541
937
|
const at = publishedAt(one);
|
|
542
938
|
return at >= goal.from && at < end;
|
|
@@ -544,7 +940,7 @@ var CreatorUtil;
|
|
|
544
940
|
return {
|
|
545
941
|
videos: published.filter((one) => one.form === "video").length,
|
|
546
942
|
posts: published.filter((one) => one.form !== "video").length,
|
|
547
|
-
day: Math.max(1, Math.min(goal.days, Math.floor((now - goal.from) /
|
|
943
|
+
day: Math.max(1, Math.min(goal.days, Math.floor((now - goal.from) / DAY2) + 1))
|
|
548
944
|
};
|
|
549
945
|
}
|
|
550
946
|
CreatorUtil.progress = progress;
|
|
@@ -626,9 +1022,7 @@ var CreatorUtil;
|
|
|
626
1022
|
return {
|
|
627
1023
|
platform: platform2,
|
|
628
1024
|
views: count(kept.views, 0),
|
|
629
|
-
...
|
|
630
|
-
...optional("comments"),
|
|
631
|
-
...optional("follows"),
|
|
1025
|
+
...Object.assign({}, ...["likes", "comments", "follows", "watch"].map(optional)),
|
|
632
1026
|
...typeof kept.completion === "number" && Number.isFinite(kept.completion) ? { completion: Math.max(0, Math.min(1, kept.completion)) } : {},
|
|
633
1027
|
at: time2(kept.at) ?? Date.now()
|
|
634
1028
|
};
|
|
@@ -728,7 +1122,7 @@ var EN = {
|
|
|
728
1122
|
startGoal: "Start a 30-day goal",
|
|
729
1123
|
source: "Source",
|
|
730
1124
|
failed: "Did not work: {error}",
|
|
731
|
-
makePrompt: "Make this piece: {title}
|
|
1125
|
+
makePrompt: "Make this piece: {title}",
|
|
732
1126
|
findPrompt: "Find hot topics for my channel now",
|
|
733
1127
|
changePrompt: "Change {id}: {note}",
|
|
734
1128
|
all: "All",
|
|
@@ -783,6 +1177,32 @@ var EN = {
|
|
|
783
1177
|
perPiece: "views a piece",
|
|
784
1178
|
noViews: "no views yet",
|
|
785
1179
|
completion: "watched {n}%",
|
|
1180
|
+
eachPiece: "Each piece",
|
|
1181
|
+
statViews: "{n} views",
|
|
1182
|
+
statWatch: "{n}s on average",
|
|
1183
|
+
statLikes: "{n} likes",
|
|
1184
|
+
statComments: "{n} comments",
|
|
1185
|
+
statFollows: "+{n} followers",
|
|
1186
|
+
statWaiting: "Read a day after it is out",
|
|
1187
|
+
statLate: "Not read in 48 hours",
|
|
1188
|
+
effTitle: "What it took Ta",
|
|
1189
|
+
effHint: "last 7 days against the 7 before",
|
|
1190
|
+
effBefore: "Before",
|
|
1191
|
+
effAfter: "Last 7 days",
|
|
1192
|
+
effPieces: "Pieces published",
|
|
1193
|
+
effLead: "Topic to out",
|
|
1194
|
+
effMinutes: "Model time a piece",
|
|
1195
|
+
effMin: " min",
|
|
1196
|
+
effTokens: "Tokens a piece",
|
|
1197
|
+
effTurns: "Your messages a piece",
|
|
1198
|
+
eff_topics: "Topic runs",
|
|
1199
|
+
eff_comments: "Comment runs",
|
|
1200
|
+
eff_review: "Review runs",
|
|
1201
|
+
effRuns: "{n} · {empty} empty · {failed} failed",
|
|
1202
|
+
effCost: "Took",
|
|
1203
|
+
effLeadValue: "{n} h to out",
|
|
1204
|
+
effMinutesValue: "model {n} min",
|
|
1205
|
+
effTokensValue: "{n} tokens",
|
|
786
1206
|
pieces: "{n} pieces",
|
|
787
1207
|
weekly: "Views by week",
|
|
788
1208
|
top: "Did best",
|
|
@@ -934,7 +1354,7 @@ var ZH = {
|
|
|
934
1354
|
startGoal: "开始 30 天目标",
|
|
935
1355
|
source: "出处",
|
|
936
1356
|
failed: "没做成:{error}",
|
|
937
|
-
makePrompt: "做这条内容:{title}
|
|
1357
|
+
makePrompt: "做这条内容:{title}",
|
|
938
1358
|
findPrompt: "现在给我的内容号找一批热点选题",
|
|
939
1359
|
changePrompt: "{id} 要改:{note}",
|
|
940
1360
|
all: "全部",
|
|
@@ -989,6 +1409,32 @@ var ZH = {
|
|
|
989
1409
|
perPiece: "条均播放",
|
|
990
1410
|
noViews: "还没有播放数据",
|
|
991
1411
|
completion: "完播 {n}%",
|
|
1412
|
+
eachPiece: "每条数据",
|
|
1413
|
+
statViews: "播放 {n}",
|
|
1414
|
+
statWatch: "均看 {n} 秒",
|
|
1415
|
+
statLikes: "赞 {n}",
|
|
1416
|
+
statComments: "评 {n}",
|
|
1417
|
+
statFollows: "涨粉 {n}",
|
|
1418
|
+
statWaiting: "发布满一天后读取",
|
|
1419
|
+
statLate: "超过 48 小时未读",
|
|
1420
|
+
effTitle: "执行效率",
|
|
1421
|
+
effHint: "近 7 天对比前 7 天",
|
|
1422
|
+
effBefore: "前 7 天",
|
|
1423
|
+
effAfter: "近 7 天",
|
|
1424
|
+
effPieces: "发布条数",
|
|
1425
|
+
effLead: "选题到发布",
|
|
1426
|
+
effMinutes: "每条运行时长",
|
|
1427
|
+
effMin: " 分",
|
|
1428
|
+
effTokens: "每条 token",
|
|
1429
|
+
effTurns: "每条你发的消息",
|
|
1430
|
+
eff_topics: "选题任务",
|
|
1431
|
+
eff_comments: "评论任务",
|
|
1432
|
+
eff_review: "复盘任务",
|
|
1433
|
+
effRuns: "{n} 次 · 空跑 {empty} · 失败 {failed}",
|
|
1434
|
+
effCost: "耗时",
|
|
1435
|
+
effLeadValue: "选题到发布 {n} 小时",
|
|
1436
|
+
effMinutesValue: "运行 {n} 分",
|
|
1437
|
+
effTokensValue: "{n} token",
|
|
992
1438
|
pieces: "{n} 条",
|
|
993
1439
|
weekly: "每周播放",
|
|
994
1440
|
top: "表现最好",
|
|
@@ -1140,7 +1586,7 @@ var ZH_TW = {
|
|
|
1140
1586
|
startGoal: "開始 30 天目標",
|
|
1141
1587
|
source: "出處",
|
|
1142
1588
|
failed: "沒做成:{error}",
|
|
1143
|
-
makePrompt: "做這條內容:{title}
|
|
1589
|
+
makePrompt: "做這條內容:{title}",
|
|
1144
1590
|
findPrompt: "現在給我的內容號找一批熱點選題",
|
|
1145
1591
|
changePrompt: "{id} 要改:{note}",
|
|
1146
1592
|
all: "全部",
|
|
@@ -1195,6 +1641,32 @@ var ZH_TW = {
|
|
|
1195
1641
|
perPiece: "條均播放",
|
|
1196
1642
|
noViews: "還沒有播放數據",
|
|
1197
1643
|
completion: "完播 {n}%",
|
|
1644
|
+
eachPiece: "每則數據",
|
|
1645
|
+
statViews: "播放 {n}",
|
|
1646
|
+
statWatch: "均看 {n} 秒",
|
|
1647
|
+
statLikes: "讚 {n}",
|
|
1648
|
+
statComments: "評 {n}",
|
|
1649
|
+
statFollows: "漲粉 {n}",
|
|
1650
|
+
statWaiting: "發布滿一天後讀取",
|
|
1651
|
+
statLate: "超過 48 小時未讀",
|
|
1652
|
+
effTitle: "執行效率",
|
|
1653
|
+
effHint: "近 7 天對比前 7 天",
|
|
1654
|
+
effBefore: "前 7 天",
|
|
1655
|
+
effAfter: "近 7 天",
|
|
1656
|
+
effPieces: "發布則數",
|
|
1657
|
+
effLead: "選題到發布",
|
|
1658
|
+
effMinutes: "每則執行時長",
|
|
1659
|
+
effMin: " 分",
|
|
1660
|
+
effTokens: "每則 token",
|
|
1661
|
+
effTurns: "每則你發的訊息",
|
|
1662
|
+
eff_topics: "選題任務",
|
|
1663
|
+
eff_comments: "留言任務",
|
|
1664
|
+
eff_review: "複盤任務",
|
|
1665
|
+
effRuns: "{n} 次 · 空跑 {empty} · 失敗 {failed}",
|
|
1666
|
+
effCost: "耗時",
|
|
1667
|
+
effLeadValue: "選題到發布 {n} 小時",
|
|
1668
|
+
effMinutesValue: "執行 {n} 分",
|
|
1669
|
+
effTokensValue: "{n} token",
|
|
1198
1670
|
pieces: "{n} 條",
|
|
1199
1671
|
weekly: "每週播放",
|
|
1200
1672
|
top: "表現最好",
|
|
@@ -1346,7 +1818,7 @@ var JA = {
|
|
|
1346
1818
|
startGoal: "30 日間の目標を始める",
|
|
1347
1819
|
source: "出典",
|
|
1348
1820
|
failed: "できませんでした:{error}",
|
|
1349
|
-
makePrompt: "このコンテンツを作って:{title}
|
|
1821
|
+
makePrompt: "このコンテンツを作って:{title}",
|
|
1350
1822
|
findPrompt: "私のチャンネル向けに今の話題からネタを探して",
|
|
1351
1823
|
changePrompt: "{id} を直して:{note}",
|
|
1352
1824
|
all: "すべて",
|
|
@@ -1401,6 +1873,32 @@ var JA = {
|
|
|
1401
1873
|
perPiece: "1 件あたり再生",
|
|
1402
1874
|
noViews: "まだ再生データなし",
|
|
1403
1875
|
completion: "完走 {n}%",
|
|
1876
|
+
eachPiece: "作品ごとの数字",
|
|
1877
|
+
statViews: "再生 {n}",
|
|
1878
|
+
statWatch: "平均 {n} 秒",
|
|
1879
|
+
statLikes: "いいね {n}",
|
|
1880
|
+
statComments: "コメント {n}",
|
|
1881
|
+
statFollows: "フォロワー +{n}",
|
|
1882
|
+
statWaiting: "公開から 1 日後に読み取り",
|
|
1883
|
+
statLate: "48 時間読めていません",
|
|
1884
|
+
effTitle: "実行効率",
|
|
1885
|
+
effHint: "直近 7 日とその前の 7 日",
|
|
1886
|
+
effBefore: "前の 7 日",
|
|
1887
|
+
effAfter: "直近 7 日",
|
|
1888
|
+
effPieces: "公開数",
|
|
1889
|
+
effLead: "企画から公開",
|
|
1890
|
+
effMinutes: "1 本の実行時間",
|
|
1891
|
+
effMin: " 分",
|
|
1892
|
+
effTokens: "1 本の token",
|
|
1893
|
+
effTurns: "1 本のあなたのメッセージ",
|
|
1894
|
+
eff_topics: "企画タスク",
|
|
1895
|
+
eff_comments: "コメントタスク",
|
|
1896
|
+
eff_review: "振り返りタスク",
|
|
1897
|
+
effRuns: "{n} 回 · 空振り {empty} · 失敗 {failed}",
|
|
1898
|
+
effCost: "所要",
|
|
1899
|
+
effLeadValue: "企画から公開 {n} 時間",
|
|
1900
|
+
effMinutesValue: "実行 {n} 分",
|
|
1901
|
+
effTokensValue: "{n} token",
|
|
1404
1902
|
pieces: "{n} 件",
|
|
1405
1903
|
weekly: "週ごとの再生",
|
|
1406
1904
|
top: "好調だったもの",
|
|
@@ -1541,11 +2039,14 @@ async function talk(pi, title, message) {
|
|
|
1541
2039
|
await pi.server.prompt(session.sessionId, { message, clientMessageId: crypto.randomUUID() });
|
|
1542
2040
|
return session.sessionFile;
|
|
1543
2041
|
}
|
|
2042
|
+
function makeMessage(pi, item) {
|
|
2043
|
+
const shown = format(useWordsOf(pi).makePrompt, { title: item.title });
|
|
2044
|
+
return TaMessageSource.mark(TaMessageContext.wrap(`Make the piece ${item.id} of Creator.`, shown), NAME);
|
|
2045
|
+
}
|
|
1544
2046
|
async function make(context, item) {
|
|
1545
2047
|
const { pi, store } = context;
|
|
1546
|
-
const words = useWordsOf(pi);
|
|
1547
2048
|
await store.call("start", item.id);
|
|
1548
|
-
const file = await talk(pi, item.title,
|
|
2049
|
+
const file = await talk(pi, item.title, makeMessage(pi, item));
|
|
1549
2050
|
if (file) {
|
|
1550
2051
|
await store.call("update", item.id, { session: file });
|
|
1551
2052
|
}
|
|
@@ -1555,7 +2056,7 @@ async function openPiece(context, item) {
|
|
|
1555
2056
|
if (item.session && await pi.openChat?.(item.session)) {
|
|
1556
2057
|
return;
|
|
1557
2058
|
}
|
|
1558
|
-
await talk(pi, item.title,
|
|
2059
|
+
await talk(pi, item.title, makeMessage(pi, item));
|
|
1559
2060
|
}
|
|
1560
2061
|
async function tell(context, item, text3) {
|
|
1561
2062
|
const { pi } = context;
|
|
@@ -1920,10 +2421,10 @@ var ReviewCode;
|
|
|
1920
2421
|
})(ReviewCode ||= {});
|
|
1921
2422
|
|
|
1922
2423
|
// web-src/channel-util.ts
|
|
1923
|
-
var
|
|
1924
|
-
var
|
|
2424
|
+
var HOUR2 = 3600000;
|
|
2425
|
+
var DAY3 = 24 * HOUR2;
|
|
1925
2426
|
var MAX_COMMENTS = 600;
|
|
1926
|
-
var COMMENTS_FOR = 60 *
|
|
2427
|
+
var COMMENTS_FOR = 60 * DAY3;
|
|
1927
2428
|
var MAX_LESSONS = 40;
|
|
1928
2429
|
var ChannelUtil;
|
|
1929
2430
|
((ChannelUtil) => {
|
|
@@ -2030,7 +2531,7 @@ var ChannelUtil;
|
|
|
2030
2531
|
function latestInsights(insights2) {
|
|
2031
2532
|
const ta = insights2.filter((one) => one.by !== "user" && !one.state);
|
|
2032
2533
|
const newest = ta[0]?.at ?? 0;
|
|
2033
|
-
return insights2.filter((one) => one.by === "user" || !one.state && newest - one.at <
|
|
2534
|
+
return insights2.filter((one) => one.by === "user" || !one.state && newest - one.at < DAY3);
|
|
2034
2535
|
}
|
|
2035
2536
|
ChannelUtil.latestInsights = latestInsights;
|
|
2036
2537
|
function proposed(insights2) {
|
|
@@ -2053,7 +2554,7 @@ var ChannelUtil;
|
|
|
2053
2554
|
}
|
|
2054
2555
|
const published = items.filter((one) => one.stage === "published" && !one.dropped).map(CreatorUtil.publishedAt);
|
|
2055
2556
|
const from = phases2[0]?.to ?? (published.length ? Math.min(...published) : undefined);
|
|
2056
|
-
if (from === undefined || now - from < settings.phaseWeeks * 7 *
|
|
2557
|
+
if (from === undefined || now - from < settings.phaseWeeks * 7 * DAY3 || !published.some((at) => at >= from)) {
|
|
2057
2558
|
return;
|
|
2058
2559
|
}
|
|
2059
2560
|
return { from, to: now };
|
|
@@ -2067,7 +2568,7 @@ var ChannelUtil;
|
|
|
2067
2568
|
return (item.needs ?? []).every((one) => one.done);
|
|
2068
2569
|
}
|
|
2069
2570
|
ChannelUtil.given = given;
|
|
2070
|
-
ChannelUtil.PACE = { start: 12 *
|
|
2571
|
+
ChannelUtil.PACE = { start: 12 * HOUR2, first: 24 * HOUR2, min: 2 * HOUR2, max: 2 * DAY3, many: 3, ride: 0.5 };
|
|
2071
2572
|
function nextGap(gap, added) {
|
|
2072
2573
|
if (added >= ChannelUtil.PACE.many) {
|
|
2073
2574
|
return Math.max(ChannelUtil.PACE.min, Math.round(gap / 2));
|
|
@@ -2081,7 +2582,7 @@ var ChannelUtil;
|
|
|
2081
2582
|
}
|
|
2082
2583
|
ChannelUtil.firstGap = firstGap;
|
|
2083
2584
|
function commentsGap(item, items, settings) {
|
|
2084
|
-
return settings.commentsEvery ? settings.commentsEvery *
|
|
2585
|
+
return settings.commentsEvery ? settings.commentsEvery * HOUR2 : item.commentsGap ?? firstGap(items);
|
|
2085
2586
|
}
|
|
2086
2587
|
ChannelUtil.commentsGap = commentsGap;
|
|
2087
2588
|
function live(item, now) {
|
|
@@ -2096,10 +2597,31 @@ var ChannelUtil;
|
|
|
2096
2597
|
}
|
|
2097
2598
|
const published = Math.min(...out);
|
|
2098
2599
|
const since = now - Math.max(one.commentsAt ?? 0, published);
|
|
2099
|
-
return now - published < settings.commentsDays *
|
|
2600
|
+
return now - published < settings.commentsDays * DAY3 && since >= share * commentsGap(one, items, settings);
|
|
2100
2601
|
});
|
|
2101
2602
|
}
|
|
2102
2603
|
ChannelUtil.due = due;
|
|
2604
|
+
ChannelUtil.STATS = { first: 20 * HOUR2, again: 7 * DAY3, until: 14 * DAY3 };
|
|
2605
|
+
function enough(waiting, settings) {
|
|
2606
|
+
const perWeek = settings.series.reduce((all, one) => all + (one.perWeek ?? 1), 0);
|
|
2607
|
+
return perWeek > 0 && waiting >= 2 * perWeek;
|
|
2608
|
+
}
|
|
2609
|
+
ChannelUtil.enough = enough;
|
|
2610
|
+
function statsDue(items, now) {
|
|
2611
|
+
return items.filter((one) => one.stage === "published" && !one.dropped).map((item) => ({
|
|
2612
|
+
item,
|
|
2613
|
+
links: live(item, now).filter((link) => {
|
|
2614
|
+
const out = link.scheduled ?? link.at;
|
|
2615
|
+
const read = item.stats?.find((one) => one.platform === link.platform);
|
|
2616
|
+
const age = now - out;
|
|
2617
|
+
if (age < ChannelUtil.STATS.first || age >= ChannelUtil.STATS.until) {
|
|
2618
|
+
return false;
|
|
2619
|
+
}
|
|
2620
|
+
return !read || age >= ChannelUtil.STATS.again && read.at - out < ChannelUtil.STATS.again - DAY3;
|
|
2621
|
+
})
|
|
2622
|
+
})).filter((one) => one.links.length > 0);
|
|
2623
|
+
}
|
|
2624
|
+
ChannelUtil.statsDue = statsDue;
|
|
2103
2625
|
function comments(value, now = Date.now()) {
|
|
2104
2626
|
return (Array.isArray(value) ? value : []).map(comment).filter((one) => !!one && now - one.at < COMMENTS_FOR).sort((a, b) => a.at - b.at).slice(-MAX_COMMENTS);
|
|
2105
2627
|
}
|
|
@@ -2238,6 +2760,67 @@ class CreatorStore {
|
|
|
2238
2760
|
}
|
|
2239
2761
|
}
|
|
2240
2762
|
|
|
2763
|
+
// web-src/efficiency-panel.tsx
|
|
2764
|
+
function EfficiencyPanel({ context }) {
|
|
2765
|
+
const { pi, store } = context;
|
|
2766
|
+
const words = useWords(pi);
|
|
2767
|
+
const state = useStore(store);
|
|
2768
|
+
const [numbers, setNumbers] = React.useState();
|
|
2769
|
+
const published = state.items.filter((one) => one.stage === "published").length;
|
|
2770
|
+
React.useEffect(() => {
|
|
2771
|
+
let live = true;
|
|
2772
|
+
store.call("efficiency").then((got) => live && setNumbers(got), () => {
|
|
2773
|
+
return;
|
|
2774
|
+
});
|
|
2775
|
+
return () => {
|
|
2776
|
+
live = false;
|
|
2777
|
+
};
|
|
2778
|
+
}, [store, published]);
|
|
2779
|
+
if (!numbers) {
|
|
2780
|
+
return null;
|
|
2781
|
+
}
|
|
2782
|
+
const n = (value, unit = "") => value === undefined ? "—" : `${short(value, pi.ui.language)}${unit}`;
|
|
2783
|
+
const runs = (one) => one ? format(words.effRuns, { n: one.runs, empty: one.empty, failed: one.failed }) : "—";
|
|
2784
|
+
const rows = [
|
|
2785
|
+
[words.effPieces, n(numbers.before.pieces.pieces), n(numbers.after.pieces.pieces)],
|
|
2786
|
+
[
|
|
2787
|
+
words.effLead,
|
|
2788
|
+
n(numbers.before.pieces.leadHours, " h"),
|
|
2789
|
+
n(numbers.after.pieces.leadHours, " h"),
|
|
2790
|
+
lower(numbers.before.pieces.leadHours, numbers.after.pieces.leadHours)
|
|
2791
|
+
],
|
|
2792
|
+
[
|
|
2793
|
+
words.effMinutes,
|
|
2794
|
+
n(numbers.before.pieces.minutes, words.effMin),
|
|
2795
|
+
n(numbers.after.pieces.minutes, words.effMin),
|
|
2796
|
+
lower(numbers.before.pieces.minutes, numbers.after.pieces.minutes)
|
|
2797
|
+
],
|
|
2798
|
+
[words.effTokens, n(numbers.before.pieces.tokens), n(numbers.after.pieces.tokens), lower(numbers.before.pieces.tokens, numbers.after.pieces.tokens)],
|
|
2799
|
+
[words.effTurns, n(numbers.before.pieces.turns), n(numbers.after.pieces.turns), lower(numbers.before.pieces.turns, numbers.after.pieces.turns)],
|
|
2800
|
+
...["topics", "comments", "review"].map((id) => [words[`eff_${id}`], runs(numbers.before.tasks[id]), runs(numbers.after.tasks[id])])
|
|
2801
|
+
];
|
|
2802
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
2803
|
+
className: "tcre-card tcre-panel tcre-wide"
|
|
2804
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
2805
|
+
className: "tcre-panel-title"
|
|
2806
|
+
}, words.effTitle, /* @__PURE__ */ React.createElement("span", {
|
|
2807
|
+
className: "tcre-muted"
|
|
2808
|
+
}, words.effHint)), /* @__PURE__ */ React.createElement("div", {
|
|
2809
|
+
className: "tcre-eff"
|
|
2810
|
+
}, /* @__PURE__ */ React.createElement("span", null), /* @__PURE__ */ React.createElement("span", {
|
|
2811
|
+
className: "tcre-muted"
|
|
2812
|
+
}, words.effBefore), /* @__PURE__ */ React.createElement("span", {
|
|
2813
|
+
className: "tcre-muted"
|
|
2814
|
+
}, words.effAfter), rows.map(([label, before, after, better]) => /* @__PURE__ */ React.createElement(React.Fragment, {
|
|
2815
|
+
key: label
|
|
2816
|
+
}, /* @__PURE__ */ React.createElement("span", null, label), /* @__PURE__ */ React.createElement("span", null, before), /* @__PURE__ */ React.createElement("span", {
|
|
2817
|
+
"data-better": better === undefined ? undefined : String(better)
|
|
2818
|
+
}, after)))));
|
|
2819
|
+
}
|
|
2820
|
+
function lower(before, after) {
|
|
2821
|
+
return before === undefined || after === undefined || before === after ? undefined : after < before;
|
|
2822
|
+
}
|
|
2823
|
+
|
|
2241
2824
|
// web-src/strategy.tsx
|
|
2242
2825
|
var PHASE_WEEKS = [2, 4, 8, 0];
|
|
2243
2826
|
function Strategy({ context }) {
|
|
@@ -2457,6 +3040,67 @@ function WeekLine({ context }) {
|
|
|
2457
3040
|
className: "tcre-line-labels"
|
|
2458
3041
|
}, /* @__PURE__ */ React.createElement("span", null, weeks[0].week.slice(5)), /* @__PURE__ */ React.createElement("span", null, weeks[weeks.length - 1].week.slice(5))));
|
|
2459
3042
|
}
|
|
3043
|
+
function PieceNumbers({ context, now }) {
|
|
3044
|
+
const { pi } = context;
|
|
3045
|
+
const state = useStore(context.store);
|
|
3046
|
+
const words = useWords(pi);
|
|
3047
|
+
const pieces = state.items.filter((one) => one.stage === "published" && !one.dropped && ChannelUtil.live(one, now).length > 0).sort((a, b) => CreatorUtil.publishedAt(b) - CreatorUtil.publishedAt(a));
|
|
3048
|
+
if (!pieces.length) {
|
|
3049
|
+
return null;
|
|
3050
|
+
}
|
|
3051
|
+
const n = (value) => short(value, pi.ui.language);
|
|
3052
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
3053
|
+
className: "tcre-card tcre-panel tcre-wide"
|
|
3054
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3055
|
+
className: "tcre-panel-title"
|
|
3056
|
+
}, words.eachPiece), pieces.map((item) => /* @__PURE__ */ React.createElement("div", {
|
|
3057
|
+
key: item.id,
|
|
3058
|
+
className: "tcre-piece-stats"
|
|
3059
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
3060
|
+
className: "tcre-piece-title"
|
|
3061
|
+
}, /* @__PURE__ */ React.createElement("span", null, item.title), /* @__PURE__ */ React.createElement(SeriesTag, {
|
|
3062
|
+
series: seriesOf(context, item.series),
|
|
3063
|
+
words
|
|
3064
|
+
})), (item.cost || Efficiency.leadHours(item) !== undefined) && /* @__PURE__ */ React.createElement("div", {
|
|
3065
|
+
className: "tcre-piece-row tcre-piece-cost"
|
|
3066
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3067
|
+
className: "tcre-bar-label"
|
|
3068
|
+
}, words.effCost), /* @__PURE__ */ React.createElement("span", {
|
|
3069
|
+
className: "tcre-piece-values"
|
|
3070
|
+
}, [
|
|
3071
|
+
Efficiency.leadHours(item) !== undefined ? format(words.effLeadValue, { n: Efficiency.leadHours(item) }) : "",
|
|
3072
|
+
item.cost ? format(words.effMinutesValue, { n: item.cost.minutes }) : "",
|
|
3073
|
+
item.cost?.tokens ? format(words.effTokensValue, { n: n(item.cost.tokens) }) : ""
|
|
3074
|
+
].filter(Boolean).map((part) => /* @__PURE__ */ React.createElement("span", {
|
|
3075
|
+
key: part
|
|
3076
|
+
}, part)))), ChannelUtil.live(item, now).map((link) => {
|
|
3077
|
+
const platform = platformOf(context, link.platform);
|
|
3078
|
+
const stat = item.stats?.find((one) => one.platform === link.platform);
|
|
3079
|
+
const late = !stat && now - (link.scheduled ?? link.at) > 48 * 3600000;
|
|
3080
|
+
const parts = stat ? [
|
|
3081
|
+
format(words.statViews, { n: n(stat.views) }),
|
|
3082
|
+
stat.completion !== undefined ? format(words.completion, { n: Math.round(stat.completion * 100) }) : "",
|
|
3083
|
+
stat.watch !== undefined ? format(words.statWatch, { n: stat.watch }) : "",
|
|
3084
|
+
stat.likes !== undefined ? format(words.statLikes, { n: n(stat.likes) }) : "",
|
|
3085
|
+
stat.comments !== undefined ? format(words.statComments, { n: n(stat.comments) }) : "",
|
|
3086
|
+
stat.follows !== undefined ? format(words.statFollows, { n: n(stat.follows) }) : ""
|
|
3087
|
+
].filter(Boolean) : [late ? words.statLate : words.statWaiting];
|
|
3088
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
3089
|
+
key: link.platform,
|
|
3090
|
+
className: "tcre-piece-row",
|
|
3091
|
+
"data-late": late || undefined,
|
|
3092
|
+
"data-none": !stat || undefined
|
|
3093
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
3094
|
+
className: "tcre-bar-label"
|
|
3095
|
+
}, platform?.color && /* @__PURE__ */ React.createElement("i", {
|
|
3096
|
+
style: { background: platform.color }
|
|
3097
|
+
}), platform?.name ?? link.platform), /* @__PURE__ */ React.createElement("span", {
|
|
3098
|
+
className: "tcre-piece-values"
|
|
3099
|
+
}, parts.map((part) => /* @__PURE__ */ React.createElement("span", {
|
|
3100
|
+
key: part
|
|
3101
|
+
}, part))));
|
|
3102
|
+
}))));
|
|
3103
|
+
}
|
|
2460
3104
|
function Numbers({ context }) {
|
|
2461
3105
|
const { pi } = context;
|
|
2462
3106
|
const state = useStore(context.store);
|
|
@@ -2516,6 +3160,11 @@ function Numbers({ context }) {
|
|
|
2516
3160
|
})
|
|
2517
3161
|
}), /* @__PURE__ */ React.createElement(WeekLine, {
|
|
2518
3162
|
context
|
|
3163
|
+
}), /* @__PURE__ */ React.createElement(EfficiencyPanel, {
|
|
3164
|
+
context
|
|
3165
|
+
}), /* @__PURE__ */ React.createElement(PieceNumbers, {
|
|
3166
|
+
context,
|
|
3167
|
+
now
|
|
2519
3168
|
}), analysis.top.length > 0 && /* @__PURE__ */ React.createElement("div", {
|
|
2520
3169
|
className: "tcre-card tcre-panel"
|
|
2521
3170
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
@@ -2770,10 +3419,10 @@ function Setup({ context, done }) {
|
|
|
2770
3419
|
}
|
|
2771
3420
|
|
|
2772
3421
|
// web-src/talk.tsx
|
|
2773
|
-
var
|
|
3422
|
+
var DAY4 = 86400000;
|
|
2774
3423
|
var LEVELS = ["act", "ask", "off"];
|
|
2775
3424
|
var LEVEL_WORDS = { act: "levelAct", ask: "levelAsk", off: "levelOff" };
|
|
2776
|
-
var
|
|
3425
|
+
var HOUR3 = 3600000;
|
|
2777
3426
|
var PACE_HOURS = [0, 2, 6, 24];
|
|
2778
3427
|
var PACE_DAYS = [7, 14, 30];
|
|
2779
3428
|
function drafts(comments) {
|
|
@@ -2785,8 +3434,8 @@ function Talk({ context }) {
|
|
|
2785
3434
|
const words = useWords(pi);
|
|
2786
3435
|
const now = Date.now();
|
|
2787
3436
|
const waiting = drafts(state.comments);
|
|
2788
|
-
const asked = state.comments.filter((one) => (one.class === "question" || one.class === "suggestion") && now - one.at < 14 *
|
|
2789
|
-
const recent = state.comments.filter((one) => one.reply && one.reply.state !== "draft" && one.reply.state !== "dropped" && now - one.reply.at < 7 *
|
|
3437
|
+
const asked = state.comments.filter((one) => (one.class === "question" || one.class === "suggestion") && now - one.at < 14 * DAY4).sort((a, b) => (b.likes ?? 0) - (a.likes ?? 0) || b.at - a.at).slice(0, 12);
|
|
3438
|
+
const recent = state.comments.filter((one) => one.reply && one.reply.state !== "draft" && one.reply.state !== "dropped" && now - one.reply.at < 7 * DAY4).sort((a, b) => (b.reply?.at ?? 0) - (a.reply?.at ?? 0)).slice(0, 20);
|
|
2790
3439
|
return /* @__PURE__ */ React.createElement("div", {
|
|
2791
3440
|
className: "tcre-talk"
|
|
2792
3441
|
}, !state.comments.length && /* @__PURE__ */ React.createElement("div", {
|
|
@@ -2914,7 +3563,7 @@ function Pace({ context }) {
|
|
|
2914
3563
|
const words = useWords(pi);
|
|
2915
3564
|
const { commentsEvery: every, commentsDays: days } = state.settings;
|
|
2916
3565
|
const latest = state.items.filter((one) => one.stage === "published" && one.commentsGap).sort((a, b) => (b.commentsAt ?? 0) - (a.commentsAt ?? 0))[0];
|
|
2917
|
-
const now = latest?.commentsGap ? Math.max(1, Math.round(latest.commentsGap /
|
|
3566
|
+
const now = latest?.commentsGap ? Math.max(1, Math.round(latest.commentsGap / HOUR3)) : undefined;
|
|
2918
3567
|
const choice = (values, value, label, set) => /* @__PURE__ */ React.createElement("div", {
|
|
2919
3568
|
className: "ta-segmented tcre-seg"
|
|
2920
3569
|
}, values.map((n) => /* @__PURE__ */ React.createElement(BusyButton, {
|
|
@@ -3786,6 +4435,21 @@ button.tcre-pill:hover { background: var(--ta-hover); }
|
|
|
3786
4435
|
.tcre-top-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: calc(13px * var(--ta-font-scale)); }
|
|
3787
4436
|
.tcre-top-row + .tcre-top-row { border-top: 1px solid var(--tcre-line); }
|
|
3788
4437
|
.tcre-top-row > b { flex: none; width: 18px; color: var(--ta-muted); font-variant-numeric: tabular-nums; }
|
|
4438
|
+
.tcre-piece-stats { padding: 8px 0; }
|
|
4439
|
+
.tcre-piece-stats + .tcre-piece-stats { border-top: 1px solid var(--tcre-line); }
|
|
4440
|
+
.tcre-piece-title { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: calc(13px * var(--ta-font-scale)); font-weight: 500; }
|
|
4441
|
+
.tcre-piece-title > span:first-child { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
4442
|
+
.tcre-piece-row { display: flex; align-items: baseline; gap: 10px; padding: 2px 0; font-size: calc(12px * var(--ta-font-scale)); }
|
|
4443
|
+
.tcre-piece-row .tcre-bar-label { flex: none; width: 64px; }
|
|
4444
|
+
.tcre-piece-values { display: flex; flex-wrap: wrap; gap: 0 12px; min-width: 0; font-variant-numeric: tabular-nums; }
|
|
4445
|
+
.tcre-piece-values > span { white-space: nowrap; }
|
|
4446
|
+
.tcre-piece-row[data-none] .tcre-piece-values { color: var(--ta-muted); }
|
|
4447
|
+
.tcre-piece-row[data-late] .tcre-piece-values { color: #d97706; }
|
|
4448
|
+
.tcre-piece-cost .tcre-piece-values { color: var(--ta-muted); }
|
|
4449
|
+
.tcre-eff { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); gap: 7px 12px; font-size: calc(12.5px * var(--ta-font-scale)); font-variant-numeric: tabular-nums; }
|
|
4450
|
+
.tcre-eff > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
4451
|
+
.tcre-eff > span[data-better='true'] { color: var(--tcre-ok); font-weight: 600; }
|
|
4452
|
+
.tcre-eff > span[data-better='false'] { color: #d97706; font-weight: 600; }
|
|
3789
4453
|
.tcre-top-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
3790
4454
|
.tcre-goal-row { display: flex; justify-content: space-between; margin: 8px 0 6px; font-size: calc(13px * var(--ta-font-scale)); font-variant-numeric: tabular-nums; }
|
|
3791
4455
|
.tcre-goal-track { height: 6px; border-radius: 3px; background: var(--ta-chip); overflow: hidden; }
|