@celljs/ta-rooms 4.22.0 → 4.24.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 +273 -10
- package/host/index.mjs +2871 -1304
- package/package.json +4 -4
- package/web/index.js +1339 -107
package/extension/index.mjs
CHANGED
|
@@ -264,6 +264,8 @@ var TASK_MESSAGE_TYPE = "ta-rooms:task";
|
|
|
264
264
|
var ROOM_CAPABILITIES = ["files", "commands"];
|
|
265
265
|
var DoubleKeys;
|
|
266
266
|
((DoubleKeys) => {
|
|
267
|
+
DoubleKeys.PICTURES = "pictures.came";
|
|
268
|
+
DoubleKeys.FILES = "files.came";
|
|
267
269
|
DoubleKeys.QUIET = "doubles.quiet";
|
|
268
270
|
DoubleKeys.REPLY = "doubles.reply";
|
|
269
271
|
DoubleKeys.DRAFTS = "doubles.drafts";
|
|
@@ -281,6 +283,54 @@ var DRAFTS_MAX = 50;
|
|
|
281
283
|
var DRAFT_MS = 24 * 60 * 60 * 1000;
|
|
282
284
|
var GRANT_HOURS = [1, 24, 24 * 7];
|
|
283
285
|
|
|
286
|
+
// ../ta-protocol/esm/common/confine-protocol.js
|
|
287
|
+
var TA_CONFINED_MARK = "[ta:confined]";
|
|
288
|
+
var AT = String.raw`(?:^|[;&|(\`]|\$\()\s*(?:sudo\s+|env\s+(?:\S+=\S*\s+)*|npx\s+|bunx\s+|pnpm\s+(?:exec|dlx)\s+|yarn\s+dlx\s+|exec\s+|xargs\s+(?:-\S+\s+)*)*`;
|
|
289
|
+
var command = (names) => new RegExp(`${AT}(?:${names})(?=\\s|$|[;&|)])`, "m");
|
|
290
|
+
var BLOCKED = [
|
|
291
|
+
[/\bgit\b[^\n;&|]*\s(?:push|send-email|request-pull)\b/, "pushing: the user puts the work out once they looked at it"],
|
|
292
|
+
[/\bgit\b[^\n;&|]*\sremote\s+(?:add|set-url|rename|remove|rm)\b/, "changing the remotes"],
|
|
293
|
+
[/\bgit\b[^\n;&|]*\sconfig\b[^\n;&|]*(?:credential|url\.|core\.sshcommand|core\.hookspath)/i, "changing how git reaches others"],
|
|
294
|
+
[/\b(?:publish|unpublish|deprecate)\b/, "publishing"],
|
|
295
|
+
[
|
|
296
|
+
command("wrangler|vercel|netlify|flyctl|fly|firebase|heroku|gh|aws|gcloud|az|kubectl|helm|terraform|pulumi|docker|podman|eas|fastlane|xcrun\\s+altool|twine"),
|
|
297
|
+
"deploying, or the tools of a cloud"
|
|
298
|
+
],
|
|
299
|
+
[command("ssh|scp|sftp|rsync|nc|ncat|netcat|telnet|ftp|socat"), "reaching other machines"],
|
|
300
|
+
[
|
|
301
|
+
/\b(?:curl|wget|http|https|Invoke-WebRequest|Invoke-RestMethod|iwr|irm)\b[^\n;&|]*(?:\s-[a-zA-Z]*[dFT]\b|\s--(?:data|upload|form|post|put|json)|\s-X\s*(?:POST|PUT|PATCH|DELETE)|\s-Method\s+(?:Post|Put|Patch|Delete)|\s-Body\b|\s-InFile\b)/i,
|
|
302
|
+
"sending data out"
|
|
303
|
+
],
|
|
304
|
+
[
|
|
305
|
+
/(?:~|\$HOME|\$\{HOME\}|\$env:USERPROFILE|\/Users\/[^/\s]+|\/home\/[^/\s]+|\/root)[\\/]\.(?:ssh|aws|gnupg|netrc|npmrc|yarnrc|pypirc|zshenv|zshrc|zprofile|bashrc|bash_profile|profile|docker|kube|ta|codebuddy|claude|cursor|config[\\/](?:gh|gcloud|hub))\b/i,
|
|
306
|
+
"the user's secrets and settings"
|
|
307
|
+
],
|
|
308
|
+
[/\bsecurity\s+(?:find|dump|export)-/, "the keychain"],
|
|
309
|
+
[command("printenv|env|set|export\\s+-p|declare\\s+-x|Get-ChildItem\\s+env:|gci\\s+env:|dir\\s+env:"), "printing the environment (it holds tokens)"],
|
|
310
|
+
[command("sudo|su|doas|osascript|launchctl|crontab|defaults\\s+write|schtasks|reg"), "acting as the system"],
|
|
311
|
+
[/\brm\s+-[a-zA-Z]*[rR][a-zA-Z]*\s+(?:-[a-zA-Z]+\s+)*(?:\/|~|\$HOME|\$\{HOME\})(?:\s|$|\/\s|\/\*)/, "deleting outside its directory"]
|
|
312
|
+
];
|
|
313
|
+
var TaConfineUtil;
|
|
314
|
+
(function(TaConfineUtil2) {
|
|
315
|
+
TaConfineUtil2.FILE_TOOLS = ["read", "edit", "write", "grep", "find", "ls"];
|
|
316
|
+
TaConfineUtil2.COMMAND_TOOLS = ["bash", "powershell"];
|
|
317
|
+
function confine(role) {
|
|
318
|
+
return role.includes(TA_CONFINED_MARK) ? role : `${TA_CONFINED_MARK}
|
|
319
|
+
${role}`;
|
|
320
|
+
}
|
|
321
|
+
TaConfineUtil2.confine = confine;
|
|
322
|
+
function confined(systemPrompt) {
|
|
323
|
+
return TaHostUtil.marked(systemPrompt, TA_CONFINED_MARK);
|
|
324
|
+
}
|
|
325
|
+
TaConfineUtil2.confined = confined;
|
|
326
|
+
function blocked(commandText) {
|
|
327
|
+
var _a;
|
|
328
|
+
const text = String(commandText !== null && commandText !== undefined ? commandText : "");
|
|
329
|
+
return (_a = BLOCKED.find(([pattern]) => pattern.test(text))) === null || _a === undefined ? undefined : _a[1];
|
|
330
|
+
}
|
|
331
|
+
TaConfineUtil2.blocked = blocked;
|
|
332
|
+
})(TaConfineUtil || (TaConfineUtil = {}));
|
|
333
|
+
|
|
284
334
|
// ../ta-protocol/esm/common/language.js
|
|
285
335
|
var TaLanguageUtil;
|
|
286
336
|
(function(TaLanguageUtil2) {
|
|
@@ -320,15 +370,161 @@ var TaLanguageUtil;
|
|
|
320
370
|
TaLanguageUtil2.list = list;
|
|
321
371
|
})(TaLanguageUtil || (TaLanguageUtil = {}));
|
|
322
372
|
|
|
373
|
+
// ../ta-relay/esm/common/relay-room-chat.js
|
|
374
|
+
var RELAY_CHAT_FILE_BYTES = { file: 50 * 1024 * 1024, video: 30 * 1024 * 1024, voice: 2 * 1024 * 1024 };
|
|
375
|
+
var RELAY_CHAT_VOICE_MS = 60000;
|
|
376
|
+
var RELAY_CHAT_VIDEO_MS = 3 * 60000;
|
|
377
|
+
var RELAY_CHAT_FILES = 9;
|
|
378
|
+
var RELAY_CHAT_KEY = "chat:";
|
|
379
|
+
var RELAY_CHAT_PART_BYTES = 8 * 1024;
|
|
380
|
+
var RELAY_CHAT_TEXT_MAX = 2000;
|
|
381
|
+
var RELAY_CHAT_IMAGES = 9;
|
|
382
|
+
var RELAY_CHAT_IMAGE_BYTES = 2 * 1024 * 1024;
|
|
383
|
+
var RELAY_CHAT_THUMB_CHARS = 900;
|
|
384
|
+
var IMAGE_TYPES = ["image/jpeg", "image/png", "image/gif", "image/webp"];
|
|
385
|
+
var RelayRoomChatUtil;
|
|
386
|
+
(function(RelayRoomChatUtil2) {
|
|
387
|
+
function key(member, part) {
|
|
388
|
+
return `${RELAY_CHAT_KEY}${member}:${part}`;
|
|
389
|
+
}
|
|
390
|
+
RelayRoomChatUtil2.key = key;
|
|
391
|
+
function parse(key2) {
|
|
392
|
+
const match = /^chat:([^:]+):(\d+)$/.exec(key2);
|
|
393
|
+
return match ? { member: match[1], part: Number(match[2]) } : undefined;
|
|
394
|
+
}
|
|
395
|
+
RelayRoomChatUtil2.parse = parse;
|
|
396
|
+
function lines(member, value, by) {
|
|
397
|
+
if (by !== member || !Array.isArray(value)) {
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
const lines2 = [];
|
|
401
|
+
for (const line of value) {
|
|
402
|
+
if (line && typeof line.id === "string" && typeof line.text === "string" && typeof line.at === "number") {
|
|
403
|
+
lines2.push({ id: line.id, from: member, name: typeof line.name === "string" ? line.name : "", text: line.text, at: line.at, ...extra(line) });
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
return lines2;
|
|
407
|
+
}
|
|
408
|
+
RelayRoomChatUtil2.lines = lines;
|
|
409
|
+
function extra(line) {
|
|
410
|
+
const to = Array.isArray(line.to) ? line.to.filter((each) => typeof each === "string").slice(0, 16) : [];
|
|
411
|
+
const agent = line.agent;
|
|
412
|
+
return {
|
|
413
|
+
...line.double === true ? { double: true } : {},
|
|
414
|
+
...agent && typeof agent.id === "string" && agent.id && typeof agent.name === "string" && line.double !== true ? { agent: { id: agent.id.slice(0, 64), name: agent.name.slice(0, 64) } } : {},
|
|
415
|
+
...to.length ? { to } : {},
|
|
416
|
+
...line.person === true && to.length && line.double !== true && !line.agent ? { person: true } : {},
|
|
417
|
+
...typeof line.re === "string" ? { re: line.re } : {},
|
|
418
|
+
...line.task === true && to.length ? { task: true } : {},
|
|
419
|
+
...images(line.images),
|
|
420
|
+
...files(line.files)
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
RelayRoomChatUtil2.extra = extra;
|
|
424
|
+
function files(value) {
|
|
425
|
+
if (!Array.isArray(value)) {
|
|
426
|
+
return {};
|
|
427
|
+
}
|
|
428
|
+
const files2 = [];
|
|
429
|
+
for (const file of value.slice(0, RELAY_CHAT_FILES)) {
|
|
430
|
+
const kind = file === null || file === undefined ? undefined : file.kind;
|
|
431
|
+
if (!file || kind !== "file" && kind !== "voice" && kind !== "video" || typeof file.id !== "string" || !/^[a-f0-9]{24}$/.test(file.id) || typeof file.sha !== "string" || !/^[0-9a-f]{64}$/.test(file.sha) || !Number.isInteger(file.bytes) || file.bytes <= 0 || file.bytes > RELAY_CHAT_FILE_BYTES[kind]) {
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
const name = [...typeof file.name === "string" ? file.name : ""].filter((char) => char.charCodeAt(0) >= 32 && char !== "/" && char !== "\\").join("").slice(0, 120) || kind;
|
|
435
|
+
const type = typeof file.type === "string" && /^[\w.+-]+\/[\w.+-]+$/.test(file.type) ? file.type.slice(0, 100) : "application/octet-stream";
|
|
436
|
+
const most = kind === "voice" ? RELAY_CHAT_VOICE_MS : RELAY_CHAT_VIDEO_MS;
|
|
437
|
+
const ms = kind !== "file" && Number.isFinite(file.ms) ? Math.min(Math.max(Math.round(file.ms), 0), most) : undefined;
|
|
438
|
+
const size = kind === "video" && Number.isInteger(file.w) && Number.isInteger(file.h) && file.w > 0 && file.h > 0;
|
|
439
|
+
const thumb = kind === "video" && typeof file.thumb === "string" && file.thumb.length <= RELAY_CHAT_THUMB_CHARS && /^data:image\/(jpeg|png|webp);base64,/.test(file.thumb) ? file.thumb : undefined;
|
|
440
|
+
files2.push({
|
|
441
|
+
id: file.id,
|
|
442
|
+
kind,
|
|
443
|
+
name,
|
|
444
|
+
type,
|
|
445
|
+
bytes: file.bytes,
|
|
446
|
+
sha: file.sha,
|
|
447
|
+
...ms !== undefined ? { ms } : {},
|
|
448
|
+
...size ? { w: file.w, h: file.h } : {},
|
|
449
|
+
...thumb ? { thumb } : {}
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
return files2.length ? { files: files2 } : {};
|
|
453
|
+
}
|
|
454
|
+
RelayRoomChatUtil2.files = files;
|
|
455
|
+
function images(value) {
|
|
456
|
+
if (!Array.isArray(value)) {
|
|
457
|
+
return {};
|
|
458
|
+
}
|
|
459
|
+
const images2 = [];
|
|
460
|
+
for (const image of value.slice(0, RELAY_CHAT_IMAGES)) {
|
|
461
|
+
if (image && typeof image.id === "string" && /^[A-Za-z0-9-]{8,64}$/.test(image.id) && typeof image.type === "string" && IMAGE_TYPES.includes(image.type) && typeof image.sha === "string" && /^[0-9a-f]{64}$/.test(image.sha) && Number.isInteger(image.w) && Number.isInteger(image.h) && Number.isInteger(image.bytes) && image.w > 0 && image.h > 0 && image.bytes > 0 && image.bytes <= RELAY_CHAT_IMAGE_BYTES) {
|
|
462
|
+
const thumb = typeof image.thumb === "string" && image.thumb.length <= RELAY_CHAT_THUMB_CHARS && /^data:image\/(jpeg|png|webp);base64,/.test(image.thumb) ? image.thumb : undefined;
|
|
463
|
+
const blob = image.blob;
|
|
464
|
+
const ok = !!blob && typeof blob.id === "string" && /^[A-Za-z0-9_-]{16,64}$/.test(blob.id) && typeof blob.read === "string" && /^[A-Za-z0-9_-]{43}$/.test(blob.read) && typeof blob.key === "string" && /^[A-Za-z0-9_-]{43}$/.test(blob.key) && Number.isFinite(blob.until);
|
|
465
|
+
images2.push({
|
|
466
|
+
id: image.id,
|
|
467
|
+
type: image.type,
|
|
468
|
+
w: image.w,
|
|
469
|
+
h: image.h,
|
|
470
|
+
bytes: image.bytes,
|
|
471
|
+
sha: image.sha,
|
|
472
|
+
...thumb ? { thumb } : {},
|
|
473
|
+
...ok && blob ? { blob: { id: blob.id, read: blob.read, key: blob.key, until: blob.until } } : {}
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
return images2.length ? { images: images2 } : {};
|
|
478
|
+
}
|
|
479
|
+
function preview(line, picture, words = { file: "[file]", voice: "[voice]", video: "[video]" }) {
|
|
480
|
+
var _a;
|
|
481
|
+
var _b;
|
|
482
|
+
const pictures = ((_a = line.images) === null || _a === undefined ? undefined : _a.length) ? line.images.length > 1 ? `${picture}×${line.images.length}` : picture : "";
|
|
483
|
+
const files2 = ((_b = line.files) !== null && _b !== undefined ? _b : []).map((file) => file.kind === "file" ? `${words.file} ${file.name}` : words[file.kind]);
|
|
484
|
+
return [pictures, ...files2, line.text].filter(Boolean).join(" ");
|
|
485
|
+
}
|
|
486
|
+
RelayRoomChatUtil2.preview = preview;
|
|
487
|
+
function stored(lines2) {
|
|
488
|
+
return lines2.map(({ from: _from, seq: _seq, pending: _pending, failed: _failed, ...line }) => line);
|
|
489
|
+
}
|
|
490
|
+
RelayRoomChatUtil2.stored = stored;
|
|
491
|
+
function signed(member, value, seq) {
|
|
492
|
+
const line = value;
|
|
493
|
+
if (!line || typeof line.id !== "string" || typeof line.text !== "string" || typeof line.at !== "number") {
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
const name = typeof line.name === "string" ? line.name.slice(0, 64) : "";
|
|
497
|
+
const text = line.text.slice(0, RELAY_CHAT_TEXT_MAX);
|
|
498
|
+
return { id: line.id.slice(0, 40), from: member, name, text, at: line.at, ...extra(line), ...seq ? { seq } : {} };
|
|
499
|
+
}
|
|
500
|
+
RelayRoomChatUtil2.signed = signed;
|
|
501
|
+
function bytes(lines2) {
|
|
502
|
+
return new TextEncoder().encode(JSON.stringify(lines2)).length;
|
|
503
|
+
}
|
|
504
|
+
RelayRoomChatUtil2.bytes = bytes;
|
|
505
|
+
function unknownMethod(error) {
|
|
506
|
+
var _a;
|
|
507
|
+
const found = error;
|
|
508
|
+
return (found === null || found === undefined ? undefined : found.code) === -32601 || /method not found|not a function|unknown method|no such method/i.test(String((_a = found === null || found === undefined ? undefined : found.message) !== null && _a !== undefined ? _a : error));
|
|
509
|
+
}
|
|
510
|
+
RelayRoomChatUtil2.unknownMethod = unknownMethod;
|
|
511
|
+
function id() {
|
|
512
|
+
return `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
|
|
513
|
+
}
|
|
514
|
+
RelayRoomChatUtil2.id = id;
|
|
515
|
+
})(RelayRoomChatUtil || (RelayRoomChatUtil = {}));
|
|
516
|
+
|
|
323
517
|
// web-src/double-util.ts
|
|
324
518
|
var STALE_MS = 10 * 60 * 1000;
|
|
325
519
|
var HOURLY = 30;
|
|
326
520
|
var LOG_MAX = 300;
|
|
327
521
|
var ASK_MS = 24 * 60 * 60 * 1000;
|
|
328
|
-
var CONTEXT_LINES = 20;
|
|
329
522
|
var TASK_MS = 60 * 60 * 1000;
|
|
330
523
|
var TASKS_KEPT = 50;
|
|
331
|
-
var
|
|
524
|
+
var CONTEXT_CHARS = 6000;
|
|
525
|
+
var CONTEXT_LINES = 40;
|
|
526
|
+
var MERGE_GAP_MS = 60000;
|
|
527
|
+
var ROOM_TOOLS = ["room_state", "room_set_state", "room_history", "ask_permission"];
|
|
332
528
|
var CAPABILITY_TOOLS = {
|
|
333
529
|
files: ["read", "edit", "write", "grep", "find", "ls"],
|
|
334
530
|
commands: ["bash"]
|
|
@@ -452,6 +648,10 @@ var DoubleUtil;
|
|
|
452
648
|
`);
|
|
453
649
|
}
|
|
454
650
|
DoubleUtil.role = role;
|
|
651
|
+
function taskRole(me, title, approved) {
|
|
652
|
+
return approved ? role(me, title) : TaConfineUtil.confine(role(me, title));
|
|
653
|
+
}
|
|
654
|
+
DoubleUtil.taskRole = taskRole;
|
|
455
655
|
function agentRole(me, title, agent) {
|
|
456
656
|
const lines = [
|
|
457
657
|
`${ROOM_DOUBLE_MARK} ${TA_WITH_OTHERS_MARK}`,
|
|
@@ -480,20 +680,69 @@ var DoubleUtil;
|
|
|
480
680
|
}
|
|
481
681
|
DoubleUtil.permits = permits;
|
|
482
682
|
function prompt(input) {
|
|
483
|
-
const
|
|
484
|
-
const
|
|
485
|
-
const
|
|
683
|
+
const describe = input.describe ?? ((line) => RelayRoomChatUtil.preview(line, "[picture]"));
|
|
684
|
+
const said = (line) => `${DoubleUtil.quote(input.nameOf(line))}${line.double ? " (double)" : ""}: ${DoubleUtil.quote(describe(line))}`;
|
|
685
|
+
const asked = [...input.earlier ?? [], input.line];
|
|
686
|
+
const { before, cut: cut2, again } = window(input.lines, asked[0], said, input.window);
|
|
687
|
+
const answered2 = input.line.re && !before.some((each) => each.id === input.line.re) ? input.lines.find((each) => each.id === input.line.re) : undefined;
|
|
688
|
+
const readable = answered2 && !(input.window?.since !== undefined && answered2.at < input.window.since);
|
|
486
689
|
return [
|
|
487
690
|
input.permits,
|
|
488
691
|
`<room_request room="${DoubleUtil.quote(input.title)}" from="${DoubleUtil.quote(input.asker.name)}"${input.asker.guest ? ' guest="true"' : ""}>`,
|
|
489
|
-
...before.length ? ["The chat before it:", ...before.map(said), ""] : [],
|
|
490
|
-
|
|
491
|
-
|
|
692
|
+
...before.length ? [again ? "Said since you last read the chat:" : "The chat before it:", ...before.map(said), ""] : [],
|
|
693
|
+
...cut2 ? ["(Earlier lines are not shown: room_history finds them.)", ""] : [],
|
|
694
|
+
...readable && answered2 ? [`It answers this line: ${said(answered2)}`, ""] : [],
|
|
695
|
+
`${DoubleUtil.quote(input.asker.name)} asks you${asked.length > 1 ? ", in several lines one after another" : ""}:`,
|
|
696
|
+
...asked.map((line) => DoubleUtil.quote(describe(line))),
|
|
697
|
+
...asked.some((line) => line.images?.length) ? ["(Its pictures are attached, as far as they came.)"] : [],
|
|
492
698
|
"</room_request>"
|
|
493
699
|
].join(`
|
|
494
700
|
`);
|
|
495
701
|
}
|
|
496
702
|
DoubleUtil.prompt = prompt;
|
|
703
|
+
function window(lines, line, said, options = {}) {
|
|
704
|
+
const index = lines.findIndex((each) => each.id === line.id);
|
|
705
|
+
const end = index < 0 ? lines.length : index;
|
|
706
|
+
const seenAt = options.seen ? lines.findIndex((each) => each.id === options.seen) : -1;
|
|
707
|
+
const before = [];
|
|
708
|
+
let chars = 0;
|
|
709
|
+
let at = end - 1;
|
|
710
|
+
for (;at > seenAt && at >= 0; at--) {
|
|
711
|
+
const each = lines[at];
|
|
712
|
+
if (options.since !== undefined && each.at < options.since) {
|
|
713
|
+
break;
|
|
714
|
+
}
|
|
715
|
+
const size = said(each).length;
|
|
716
|
+
if (before.length >= CONTEXT_LINES || before.length && chars + size > CONTEXT_CHARS) {
|
|
717
|
+
break;
|
|
718
|
+
}
|
|
719
|
+
before.unshift(each);
|
|
720
|
+
chars += size;
|
|
721
|
+
}
|
|
722
|
+
const older = at > seenAt && at >= 0 && (options.since === undefined || lines[at].at >= options.since);
|
|
723
|
+
return { before, cut: older, again: seenAt >= 0 };
|
|
724
|
+
}
|
|
725
|
+
DoubleUtil.window = window;
|
|
726
|
+
function bursts(asking2) {
|
|
727
|
+
const groups = [];
|
|
728
|
+
const kind = (each) => `${each.line.from}|${each.agent?.id ?? ""}|${each.call ? "call" : "ask"}`;
|
|
729
|
+
for (const each of asking2) {
|
|
730
|
+
const group = groups.at(-1);
|
|
731
|
+
const last = group?.at(-1);
|
|
732
|
+
if (group && last && !each.line.task && !last.line.task && kind(last) === kind(each) && each.line.at - last.line.at <= MERGE_GAP_MS) {
|
|
733
|
+
group.push(each);
|
|
734
|
+
} else {
|
|
735
|
+
groups.push([each]);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
return groups;
|
|
739
|
+
}
|
|
740
|
+
DoubleUtil.bursts = bursts;
|
|
741
|
+
function describeNote(count, wanted) {
|
|
742
|
+
const ids = wanted.map((at) => `p${at + 1}`).join(", ");
|
|
743
|
+
return `[Ta] ${count} picture(s) are attached, p1 to p${count} in order. After your reply, on lines of their own, write <pictures>, then for each of ${ids} a line "pN: what it shows, in one sentence, with any words in it", then </pictures>. Ta keeps that for later and takes it out of what is said.`;
|
|
744
|
+
}
|
|
745
|
+
DoubleUtil.describeNote = describeNote;
|
|
497
746
|
function taskNote(me, name) {
|
|
498
747
|
return `[Ta] This is a task ${name} handed you, not a question: do it, as far as you may, then reply with what came of it, short. If it needs something ${me} has not let you do, call ask_permission and reply what you need: the task waits, and goes on by itself once ${me} lets you.`;
|
|
499
748
|
}
|
|
@@ -545,14 +794,28 @@ var DOUBLE_TOOLS = [
|
|
|
545
794
|
label: "Room state",
|
|
546
795
|
description: "Reads the shared state of the room you are answering in (what its game or app keeps), by key: all of it, or the keys that start with prefix.",
|
|
547
796
|
parameters: { type: "object", properties: { prefix: { type: "string" } } },
|
|
548
|
-
run: (doubles, params, file) => doubles.
|
|
797
|
+
run: (doubles, params, file) => doubles.context.state(file, typeof params.prefix === "string" ? params.prefix : undefined)
|
|
549
798
|
},
|
|
550
799
|
{
|
|
551
800
|
name: "room_set_state",
|
|
552
801
|
label: "Set room state",
|
|
553
802
|
description: "Sets a key of the shared state of the room you are answering in, as its game or app keeps it (null clears it). Say things in your reply, not here.",
|
|
554
803
|
parameters: { type: "object", properties: { key: { type: "string" }, value: {} }, required: ["key", "value"] },
|
|
555
|
-
run: (doubles, params, file) => doubles.
|
|
804
|
+
run: (doubles, params, file) => doubles.context.setState(file, String(params.key ?? ""), params.value)
|
|
805
|
+
},
|
|
806
|
+
{
|
|
807
|
+
name: "room_history",
|
|
808
|
+
label: "Room history",
|
|
809
|
+
description: 'Finds what was said earlier in the room you are answering in, further back than the chat you were given: lines with every word of query (two languages if unsure: "发布 release"), or the latest without one; before a line (its #id) to read further back. This room alone.',
|
|
810
|
+
parameters: {
|
|
811
|
+
type: "object",
|
|
812
|
+
properties: {
|
|
813
|
+
query: { type: "string" },
|
|
814
|
+
before: { type: "string", description: "The #id of a line, without #: what was said before it." },
|
|
815
|
+
limit: { type: "number", description: "Lines at most, 20 by default, 50 at most." }
|
|
816
|
+
}
|
|
817
|
+
},
|
|
818
|
+
run: (doubles, params, file) => doubles.context.history(file, params)
|
|
556
819
|
},
|
|
557
820
|
{
|
|
558
821
|
name: "ask_permission",
|