ai_co_discuss 0.2.88 → 0.2.89
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/.agents/skills/discuss-host/SKILL.md +37 -131
- package/.agents/skills/discuss-host/references/dev-flow.md +10 -0
- package/.agents/skills/discuss-host/references/discussion.md +107 -0
- package/.agents/skills/discuss-host/references/free.md +22 -0
- package/.agents/skills/discuss-host/references/manual.md +6 -6
- package/.agents/skills/discuss-participant/SKILL.md +21 -53
- package/.agents/skills/discuss-participant/references/discussion.md +41 -0
- package/.agents/skills/discuss-participant/references/free.md +7 -23
- package/.agents/skills/discuss-participant/references/manual.md +1 -1
- package/.agents/skills/discuss-participant/references/writing.md +1 -3
- package/backend/free_room.py +56 -24
- package/backend/runtime.py +5 -4
- package/backend/schema.sql +6 -0
- package/backend/server.py +2 -2
- package/docs/en/workflow.md +2 -2
- package/docs/runner.md +1 -1
- package/docs/workflow.md +3 -3
- package/package.json +1 -1
- package/runner/api_participant.mjs +10 -7
- package/runner/codiscuss.mjs +1 -0
- package/runner/discuss.py +4 -0
- package/runner/discussion_adapters.mjs +36 -18
- package/runner/discussion_runner.mjs +8 -6
- package/runner/discussion_service.mjs +81 -4
- package/runner/free_runner.mjs +19 -22
- package/web/app.js +21 -2
- package/web/modern.css +1 -1
- package/web/modern.js +1197 -801
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Resident local service that dispatches registered rooms to software or configured API participants. */
|
|
2
2
|
import { spawn, spawnSync } from 'node:child_process';
|
|
3
3
|
import { createHash, randomUUID } from 'node:crypto';
|
|
4
|
-
import { appendFileSync, closeSync, existsSync, mkdirSync, openSync, readdirSync, readFileSync, realpathSync, renameSync, unlinkSync } from 'node:fs';
|
|
4
|
+
import { appendFileSync, closeSync, existsSync, mkdirSync, openSync, readdirSync, readFileSync, readSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
5
5
|
import { homedir } from 'node:os';
|
|
6
6
|
import { dirname, join, resolve } from 'node:path';
|
|
7
7
|
import { DatabaseSync } from 'node:sqlite';
|
|
@@ -17,12 +17,18 @@ const REMOTE_SYNC_MS = 3000;
|
|
|
17
17
|
const START_WAIT_MS = 5000;
|
|
18
18
|
const STOP_WAIT_MS = 20_000;
|
|
19
19
|
const REGISTRY_WAIT_MS = 5000;
|
|
20
|
+
// Housekeeping: logs above the limit keep only their newest part; a launch folder no room uses is removed once it is this old.
|
|
21
|
+
const SWEEP_MS = 6 * 60 * 60 * 1000;
|
|
22
|
+
const LOG_LIMIT_BYTES = 5 * 1024 * 1024;
|
|
23
|
+
const LOG_KEEP_BYTES = 1024 * 1024;
|
|
24
|
+
const STALE_LAUNCH_MS = 7 * 24 * 60 * 60 * 1000;
|
|
25
|
+
const SERVICE_LOGS = ['service.log', join('local', 'website.log'), join('local', 'supervisor.log')];
|
|
20
26
|
const SCRIPT = fileURLToPath(import.meta.url);
|
|
21
27
|
const REPO_ROOT = dirname(dirname(SCRIPT));
|
|
22
28
|
const SHORTCUT_NAME = 'AI CoDiscuss 讨论服务.lnk';
|
|
23
29
|
const TICK_STATES = { undefined: 'running', waiting: 'paused', false: 'idle' };
|
|
24
30
|
const STATUS_LABELS = { running: '运行中', paused: '已暂停', idle: '等待启动', error: '异常' };
|
|
25
|
-
const USAGE = '用法: discussion_service.mjs start|stop|status|open|run|list|add|remove|shortcut|autostart [--config 私有配置.json] [on|off]';
|
|
31
|
+
const USAGE = '用法: discussion_service.mjs start|stop|status|open|run|list|add|remove|clean|shortcut|autostart [--config 私有配置.json] [on|off]';
|
|
26
32
|
export const CONNECTION_FIELDS = ['executable', 'ipc_directory'];
|
|
27
33
|
|
|
28
34
|
/** Read one atomic configuration version for editing and worker acknowledgement. */
|
|
@@ -351,10 +357,13 @@ export class DiscussionService {
|
|
|
351
357
|
await worker.tick();
|
|
352
358
|
if (!worker.removed) continue;
|
|
353
359
|
// The room no longer exists on its website, so there is nothing to pause; drop the registration once.
|
|
360
|
+
const directory = worker.config?.directory;
|
|
354
361
|
await worker.close(false);
|
|
355
362
|
this.workers.delete(path);
|
|
356
363
|
try { unregister_room(this.home, path); } catch { /* Already removed by another command. */ }
|
|
357
|
-
|
|
364
|
+
// Its runtime, task files and answer drafts serve no one now; a file still held is left to the periodic sweep.
|
|
365
|
+
try { remove_room_files(this.home, path, directory); } catch (error) { this.log(`${worker.state.room || path}: 本机文件未能删除,稍后清理:${error.message}`); }
|
|
366
|
+
this.log(`${worker.state.site || ''}/${worker.state.room || path}: 房间已在网站删除,已撤销登记并删除本机文件`);
|
|
358
367
|
}
|
|
359
368
|
atomic_json(join(this.home, 'status.json'), { pid: process.pid, updated_at: Math.floor(Date.now() / 1000),
|
|
360
369
|
rooms: [...this.workers.values()].map(worker => worker.state) });
|
|
@@ -366,6 +375,64 @@ export class DiscussionService {
|
|
|
366
375
|
}
|
|
367
376
|
}
|
|
368
377
|
|
|
378
|
+
/** Delete one room's local files: its answer drafts, and its launch folder when the service created it under launches/. */
|
|
379
|
+
export function remove_room_files(home, config_path, data_directory) {
|
|
380
|
+
const folder = dirname(resolve(config_path));
|
|
381
|
+
for (const directory of [data_directory, folder, join(folder, 'runtime')].filter(Boolean)) {
|
|
382
|
+
rmSync(service_drafts(home, directory), { recursive: true, force: true });
|
|
383
|
+
}
|
|
384
|
+
if (dirname(folder) === resolve(home, 'launches')) rmSync(folder, { recursive: true, force: true });
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/** Keep only the newest part of a log that grew past the limit; writers append, so they continue at its new end. */
|
|
388
|
+
function trim_log(path) {
|
|
389
|
+
if (!existsSync(path) || statSync(path).size <= LOG_LIMIT_BYTES) return false;
|
|
390
|
+
const size = statSync(path).size, tail = Buffer.alloc(LOG_KEEP_BYTES);
|
|
391
|
+
const handle = openSync(path, 'r');
|
|
392
|
+
try { readSync(handle, tail, 0, LOG_KEEP_BYTES, size - LOG_KEEP_BYTES); } finally { closeSync(handle); }
|
|
393
|
+
// Start at a whole line so the kept part does not open mid-entry.
|
|
394
|
+
writeFileSync(path, tail.subarray(tail.indexOf(10) + 1));
|
|
395
|
+
return true;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/** The newest change time of a launch folder's own records, which a pending launch still updates. */
|
|
399
|
+
function launch_touched(folder) {
|
|
400
|
+
return Math.max(...[folder, join(folder, 'launch.json'), join(folder, 'config.json')].filter(existsSync).map(path => statSync(path).mtimeMs));
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Remove what no registered room uses: launch folders left by rooms deleted while the service was off, or launches
|
|
405
|
+
* never confirmed, once they are a week old and no process holds them; answer drafts whose folder is gone; and the
|
|
406
|
+
* oversized part of the service's logs. Registered rooms, settings and the local website's database are never touched.
|
|
407
|
+
*/
|
|
408
|
+
export function sweep_service_home(home, now = Date.now()) {
|
|
409
|
+
const registered = read_registry(home).map(path => dirname(resolve(path)));
|
|
410
|
+
const launches = join(home, 'launches'), removed = { launches: [], drafts: [], logs: [] };
|
|
411
|
+
for (const name of existsSync(launches) ? readdirSync(launches) : []) {
|
|
412
|
+
const folder = join(launches, name);
|
|
413
|
+
if (registered.includes(folder) || service_pid(folder) || service_pid(join(folder, 'runtime')) || now - launch_touched(folder) < STALE_LAUNCH_MS) continue;
|
|
414
|
+
try { remove_room_files(home, join(folder, 'config.json')); removed.launches.push(name); } catch { /* Still held; the next sweep retries. */ }
|
|
415
|
+
}
|
|
416
|
+
// A draft folder is keyed by its room's data directory; one matching no remaining folder or registered room is orphaned.
|
|
417
|
+
const live = new Set();
|
|
418
|
+
for (const path of read_registry(home)) {
|
|
419
|
+
const folder = dirname(resolve(path));
|
|
420
|
+
for (const directory of [folder, join(folder, 'runtime')]) live.add(service_drafts(home, directory));
|
|
421
|
+
try { live.add(service_drafts(home, validate_config(JSON.parse(readFileSync(path, 'utf8')), folder).directory)); } catch { /* Covered by the folder keys. */ }
|
|
422
|
+
}
|
|
423
|
+
for (const name of existsSync(launches) ? readdirSync(launches) : []) {
|
|
424
|
+
for (const directory of [join(launches, name), join(launches, name, 'runtime')]) live.add(service_drafts(home, directory));
|
|
425
|
+
}
|
|
426
|
+
const drafts = join(home, 'drafts');
|
|
427
|
+
for (const name of existsSync(drafts) ? readdirSync(drafts) : []) {
|
|
428
|
+
if (live.has(join(drafts, name))) continue;
|
|
429
|
+
rmSync(join(drafts, name), { recursive: true, force: true });
|
|
430
|
+
removed.drafts.push(name);
|
|
431
|
+
}
|
|
432
|
+
for (const log of SERVICE_LOGS) if (trim_log(join(home, log))) removed.logs.push(log);
|
|
433
|
+
return removed;
|
|
434
|
+
}
|
|
435
|
+
|
|
369
436
|
/** Return the live service PID, or 0 when no service owns the home lock. */
|
|
370
437
|
export function service_pid(home) {
|
|
371
438
|
const path = join(home, 'runner.lock');
|
|
@@ -405,9 +472,18 @@ export async function run_service(home, output = () => {}) {
|
|
|
405
472
|
updated_at: Math.floor(Date.now() / 1000), rooms: [] });
|
|
406
473
|
// Loaded lazily: the relay runs launches, and the launch module itself depends on this one.
|
|
407
474
|
const { sync_remote_launches } = await import('./remote_launch.mjs');
|
|
408
|
-
let synced_at = 0;
|
|
475
|
+
let synced_at = 0, swept_at = 0;
|
|
409
476
|
while (!stopped && !existsSync(stop_path)) {
|
|
410
477
|
try { await service.tick(); } catch (error) { log_line(`服务检查失败:${error.message}`); }
|
|
478
|
+
if (Date.now() - swept_at >= SWEEP_MS) {
|
|
479
|
+
swept_at = Date.now();
|
|
480
|
+
try {
|
|
481
|
+
const removed = sweep_service_home(home);
|
|
482
|
+
if (removed.launches.length || removed.drafts.length || removed.logs.length) {
|
|
483
|
+
log_line(`清理本机文件:启动目录 ${removed.launches.length} 个,草稿 ${removed.drafts.length} 个,日志 ${removed.logs.join('、') || '无'}`);
|
|
484
|
+
}
|
|
485
|
+
} catch (error) { log_line(`清理本机文件失败:${error.message}`); }
|
|
486
|
+
}
|
|
411
487
|
if (Date.now() - synced_at >= REMOTE_SYNC_MS) {
|
|
412
488
|
synced_at = Date.now();
|
|
413
489
|
try { await sync_remote_launches(home, { log: log_line }); } catch (error) { log_line(`远程启动检查失败:${error.message}`); }
|
|
@@ -531,6 +607,7 @@ export async function main(args = process.argv.slice(2), print = value => proces
|
|
|
531
607
|
case 'list': return print({ home, configs: read_registry(home) });
|
|
532
608
|
case 'add': { const config = register_room(home, require_config()); return print({ added: config.room, site: config.site }); }
|
|
533
609
|
case 'remove': unregister_room(home, require_config()); return print({ removed: resolve(values.config) });
|
|
610
|
+
case 'clean': return print(sweep_service_home(home));
|
|
534
611
|
case 'shortcut': return print({ shortcut: write_shortcut('Desktop', 'open') });
|
|
535
612
|
case 'autostart':
|
|
536
613
|
if (option === 'on') return print({ autostart: write_shortcut('Startup', 'start') });
|
package/runner/free_runner.mjs
CHANGED
|
@@ -12,10 +12,8 @@ const PACKAGE_VERSION = JSON.parse(readFileSync(new URL('../package.json', impor
|
|
|
12
12
|
const RENEW_MS = 30_000;
|
|
13
13
|
/** A changed phase is reported early, but no more often than this, since each report refreshes open pages. */
|
|
14
14
|
const ACTIVITY_REPORT_MS = 10_000;
|
|
15
|
-
/**
|
|
16
|
-
const
|
|
17
|
-
const MAX_NOTE_LENGTH = 500;
|
|
18
|
-
const MAX_NOTES_PER_RENEW = 10;
|
|
15
|
+
/** Segments and progress notes are reported quietly, waking no page, so they may go every tick. */
|
|
16
|
+
const PROGRESS_REPORT_MS = 2_000;
|
|
19
17
|
const MAX_DELIVERY_ATTEMPTS = 3;
|
|
20
18
|
const LIVE = ['reserving', 'delivering', 'sidecar_pending', 'running'];
|
|
21
19
|
const MAX_HASHED_BYTES = 5 * 1024 * 1024;
|
|
@@ -79,13 +77,16 @@ export function free_task_files(config, member, execution, binding) {
|
|
|
79
77
|
// The host routes unnamed messages and receives hand-backs; it may name members in its answer.
|
|
80
78
|
const discussion = config.mode !== 'free';
|
|
81
79
|
const host_rule = member.role === 'host' && !discussion
|
|
82
|
-
?
|
|
80
|
+
? `你是本房间的主持人:按任务 skills 中 discuss-host 的自由协作主持说明处理 route、handoff 与 all 请求。先用 ${cli} room view ${config.room} 查看成员与状态;派活在回答中加 --to 成员名(不能点名自己),只点名一位且还要它交回时加 --handoff。`
|
|
83
81
|
: '';
|
|
84
82
|
atomic_json(task_path, { site: config.site, room: config.room, mode: 'free', member: member.name,
|
|
85
83
|
execution_id: execution.id, request_messages: execution.requests.map(item => item.message_id),
|
|
86
84
|
request_purposes: execution.requests.map(item => item.purpose || 'ask'), role: member.role || 'member',
|
|
87
85
|
read_after: execution.read_until, cwd: profile.cwd || null, project_access: profile.project_access, draft_directory,
|
|
88
|
-
|
|
86
|
+
// Each skill's core plus its free-room page; the host also gets the host skill (its development page is read on demand).
|
|
87
|
+
skills: [...['discuss-participant/SKILL.md', 'discuss-participant/references/free.md'],
|
|
88
|
+
...member.role === 'host' ? ['discuss-host/SKILL.md', 'discuss-host/references/free.md'] : []].map(file => join(config.project, '.agents/skills', file)),
|
|
89
|
+
cli, subcommands: TASK_SUBCOMMANDS,
|
|
89
90
|
...(bound_access ? { access_env: 'DISCUSS_ACCESS_FILE' } : { access_file: access_path }),
|
|
90
91
|
instructions: `${agy_command_rule(profile.adapter, cli)}${discussion ? '讨论房间:用户直接向你提问(' + messages + ')。这不是你的发言安排,不要领取发言权、不要安排他人,也不改变讨论进度,只回答这个提问。' : '自由协作房间:用户点名了你(' + messages + ')。'}${access_rule}先用 ${cli} message list ${config.room} --after ${execution.read_until}${access_arg} 读取新消息,按时间顺序处理,后面的消息可能修正前面的,以最新指令为准。${host_rule}完成后用 ${cli} message post ${config.room} --as ${member.name} --kind chat --execution ${execution.id} --body-file 草稿 --submission-id 新UUID${access_arg} 提交一次回答。提交被拒绝说明本次执行已被打断或过期:保留草稿并结束,不要去掉 --execution 改作普通发言。草稿只写入 draft_directory;${project_rule}不读取或打印凭据内容,不建定时任务。` });
|
|
91
92
|
const prompt = `用户在${discussion ? '讨论' : '自由协作'}房间点名了你(${member.name}),对应消息 ${messages}。请先读取任务文件:${task_path},按其中说明读取新消息、完成请求,并用 ${cli} message post 带 --execution ${execution.id} 提交一次回答后结束。命令只用任务内 subcommands 列出的 ${cli} 子命令;${project_rule}不读取凭据内容。`;
|
|
@@ -138,8 +139,7 @@ export class FreeRoomRunner {
|
|
|
138
139
|
// Execution id -> why its session ended on its own, such as a command refused in unattended mode ('' when unknown).
|
|
139
140
|
this.exited = new Map();
|
|
140
141
|
this.snapshots = new Map();
|
|
141
|
-
// Execution id -> { phase, at, sent_phase, sent_at
|
|
142
|
-
// and the progress notes not yet on the website.
|
|
142
|
+
// Execution id -> { phase, at, sent_phase, sent_at }: what the member's software last showed it doing.
|
|
143
143
|
this.activity = new Map();
|
|
144
144
|
this.segments = new SegmentLog();
|
|
145
145
|
this.context_errors = new Map();
|
|
@@ -404,38 +404,35 @@ export class FreeRoomRunner {
|
|
|
404
404
|
return this.save(member.name, { status: 'idle' });
|
|
405
405
|
}
|
|
406
406
|
if (Date.now() >= execution.created_at * 1000 + minutes * 60_000) return this.fail(member.name, execution.id, `超过单次执行时限 ${minutes} 分钟;请核对原会话确认是否已有内容`);
|
|
407
|
+
// Segments and notes go first, quietly and often, so a renewal in the same tick already shows the notes it announces.
|
|
408
|
+
if (this.segments.due(execution.id, PROGRESS_REPORT_MS)) await this.report_segments(execution.id);
|
|
407
409
|
const activity = this.activity.get(execution.id);
|
|
408
|
-
const changed = activity && (activity.phase !== activity.sent_phase || activity.at !== activity.sent_at
|
|
410
|
+
const changed = activity && (activity.phase !== activity.sent_phase || activity.at !== activity.sent_at);
|
|
409
411
|
const elapsed = Date.now() - row.last_renew;
|
|
410
412
|
if (elapsed >= RENEW_MS || (changed && elapsed >= ACTIVITY_REPORT_MS)) {
|
|
411
|
-
const notes = activity?.notes.slice(0, MAX_NOTES_PER_RENEW) || [];
|
|
412
413
|
await api(this.config, `/executions/${execution.id}`, { action: 'renew',
|
|
413
|
-
...(activity ? { activity: activity.phase, activity_at: Math.floor(activity.at / 1000) } : {})
|
|
414
|
-
if (activity) Object.assign(activity, { sent_phase: activity.phase, sent_at: activity.at
|
|
414
|
+
...(activity ? { activity: activity.phase, activity_at: Math.floor(activity.at / 1000) } : {}) });
|
|
415
|
+
if (activity) Object.assign(activity, { sent_phase: activity.phase, sent_at: activity.at });
|
|
415
416
|
this.save(member.name, { last_renew: Date.now() });
|
|
416
417
|
}
|
|
417
|
-
if (this.segments.due(execution.id, ACTIVITY_REPORT_MS)) await this.report_segments(execution.id);
|
|
418
418
|
}
|
|
419
|
-
/** Send the execution's recorded
|
|
419
|
+
/** Send the execution's recorded segments and progress notes; `final` sends the rest once it has ended. */
|
|
420
420
|
report_segments(execution_id, final = false) {
|
|
421
|
-
return this.segments.report(execution_id, final,
|
|
421
|
+
return this.segments.report(execution_id, final, ({ segments, notes }) =>
|
|
422
|
+
api(this.config, `/executions/${execution_id}`, { action: 'segments', segments, ...(notes.length ? { notes } : {}) }));
|
|
422
423
|
}
|
|
423
424
|
/** Note that the software produced output now, and its phase when the output names one. */
|
|
424
425
|
touch(execution_id, phase) {
|
|
425
426
|
// Updated in place: a renewal in flight marks what it sent on this same record.
|
|
426
|
-
if (!this.activity.has(execution_id)) this.activity.set(execution_id, { phase: ''
|
|
427
|
+
if (!this.activity.has(execution_id)) this.activity.set(execution_id, { phase: '' });
|
|
427
428
|
const current = this.activity.get(execution_id);
|
|
428
429
|
if (phase) current.phase = phase;
|
|
429
430
|
current.at = Date.now();
|
|
430
431
|
}
|
|
431
|
-
/** Queue one progress note for the next
|
|
432
|
+
/** Queue one progress note for the next progress report; numbering makes a retried report harmless. */
|
|
432
433
|
note(execution_id, text) {
|
|
433
434
|
this.touch(execution_id);
|
|
434
|
-
|
|
435
|
-
if (current.next_seq >= MAX_EXECUTION_NOTES) return;
|
|
436
|
-
current.next_seq += 1;
|
|
437
|
-
// Cut by UTF-16 units like the website's check, without leaving half of a surrogate pair.
|
|
438
|
-
current.notes.push({ seq: current.next_seq, text: text.slice(0, MAX_NOTE_LENGTH).replace(/[\uD800-\uDBFF]$/, '') });
|
|
435
|
+
this.segments.note(execution_id, text);
|
|
439
436
|
}
|
|
440
437
|
/** Report observed file changes once an execution has ended and its member's processes have exited. */
|
|
441
438
|
async report_finished(active) {
|
package/web/app.js
CHANGED
|
@@ -997,6 +997,7 @@ function reset_create_form() {
|
|
|
997
997
|
state.launch.scheduler = default_scheduler();
|
|
998
998
|
state.named_followup = false;
|
|
999
999
|
state.create_discussion = false;
|
|
1000
|
+
state.create_auto_hops = DEFAULT_AUTO_HOPS;
|
|
1000
1001
|
state.launch.profiles = JSON.parse(JSON.stringify(state.launch.saved_profiles || {}));
|
|
1001
1002
|
Object.values(state.launch.profiles).forEach(fill_api_key);
|
|
1002
1003
|
state.launch.notice = "";
|
|
@@ -1173,6 +1174,13 @@ async function send_descriptions(room_id, token, descriptions) {
|
|
|
1173
1174
|
catch (error) { state.free_notice = `成员描述未保存:${error.message},可在发言顺序的成员菜单里重新填写。`; }
|
|
1174
1175
|
}
|
|
1175
1176
|
|
|
1177
|
+
/** Save the new room's chain budget with the room credential; a failure leaves the room on the default. */
|
|
1178
|
+
async function send_auto_hops(room_id, token, max_auto_hops) {
|
|
1179
|
+
if (!room_id || !token || max_auto_hops === DEFAULT_AUTO_HOPS) return;
|
|
1180
|
+
try { await request_json(`/api/rooms/${room_id}/budget`, { max_auto_hops }, token); }
|
|
1181
|
+
catch (error) { state.free_notice = `派活上限未保存:${error.message},房间沿用默认 ${DEFAULT_AUTO_HOPS} 次,可在房间页修改。`; }
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1176
1184
|
/** Edit one member's description inside the room; the next decision by the scheduler or host uses it. */
|
|
1177
1185
|
async function describe_member(name, text) {
|
|
1178
1186
|
const room_id = state.room.id;
|
|
@@ -1869,6 +1877,7 @@ async function submit_local_launch(input, title, direct = false, signature) {
|
|
|
1869
1877
|
const names = [...(record.input.room?.members || []).map(member => member.name), ...Object.keys(result.room?.experts || {})];
|
|
1870
1878
|
await send_descriptions(result.room?.id, record.input.token, Object.fromEntries(names.map(name => [name, description_draft(name)])));
|
|
1871
1879
|
for (const name of names) delete description_drafts[name];
|
|
1880
|
+
await send_auto_hops(result.room?.id, record.input.token, state.create_auto_hops);
|
|
1872
1881
|
return result;
|
|
1873
1882
|
} catch (error) {
|
|
1874
1883
|
const stage = error.launch?.stage || (record.direct && error.preflight ? "not_started" : undefined);
|
|
@@ -2216,6 +2225,16 @@ function write_named_followup(value) {
|
|
|
2216
2225
|
publish_view();
|
|
2217
2226
|
}
|
|
2218
2227
|
|
|
2228
|
+
// The server's default chain budget; a new room sends its own only when the form changed it.
|
|
2229
|
+
const DEFAULT_AUTO_HOPS = 8;
|
|
2230
|
+
state.create_auto_hops = DEFAULT_AUTO_HOPS;
|
|
2231
|
+
|
|
2232
|
+
/** Change the new room's chain budget; it is saved right after the room is created. */
|
|
2233
|
+
function write_create_auto_hops(value) {
|
|
2234
|
+
state.create_auto_hops = value;
|
|
2235
|
+
publish_view();
|
|
2236
|
+
}
|
|
2237
|
+
|
|
2219
2238
|
/** Choose whether a new room opens a discussion right away; the room itself is always the same collaboration room. */
|
|
2220
2239
|
function write_create_discussion(value) {
|
|
2221
2240
|
state.create_discussion = Boolean(value);
|
|
@@ -3425,7 +3444,7 @@ function view_snapshot() {
|
|
|
3425
3444
|
free_notice: state.free_notice, free_error: state.free_error, free_proxy: state.free_proxy, order_error: state.order_error,
|
|
3426
3445
|
create_parent: state.create_parent, access: access_snapshot(), admin: admin_snapshot(),
|
|
3427
3446
|
tab: state.tab, snapshot_id: state.snapshot_id, context_dirty: state.context_dirty,
|
|
3428
|
-
theme: document.documentElement.dataset.theme, fields, experts, launch: structuredClone(state.launch), named_followup: state.named_followup, create_discussion: state.create_discussion };
|
|
3447
|
+
theme: document.documentElement.dataset.theme, fields, experts, launch: structuredClone(state.launch), named_followup: state.named_followup, create_discussion: state.create_discussion, create_auto_hops: state.create_auto_hops };
|
|
3429
3448
|
}
|
|
3430
3449
|
|
|
3431
3450
|
/** Update a shared draft using the same input events as the original controls. */
|
|
@@ -3658,7 +3677,7 @@ function change_view_theme(theme) {
|
|
|
3658
3677
|
|
|
3659
3678
|
window.discuss_view = { snapshot: view_snapshot, write_field: write_view_field,
|
|
3660
3679
|
write_launch: write_launch_field, description_template, save_description_template, description_draft, write_description_draft, describe_member, set_auto_hops, expert_presets, apply_expert_preset, unique_instance, save_expert_preset, delete_expert_preset, write_room_connection, write_room_adapter, launch_clients: LAUNCH_CLIENTS,
|
|
3661
|
-
launch_model_state, load_launch_models, write_launch_model, save_launch_api_key, write_scheduler, save_scheduler_api_key, check_scheduler, write_named_followup, write_create_discussion, check_launch_api, launch_summary, launch_can_set_access, launch_can_bind_session, pick_launch_directory, browse_local_directory, save_launch_projects, restore_launch_profile, reset_create_form, empty_discussion_message,
|
|
3680
|
+
launch_model_state, load_launch_models, write_launch_model, save_launch_api_key, write_scheduler, save_scheduler_api_key, check_scheduler, write_named_followup, write_create_discussion, write_create_auto_hops, check_launch_api, launch_summary, launch_can_set_access, launch_can_bind_session, pick_launch_directory, browse_local_directory, save_launch_projects, restore_launch_profile, reset_create_form, empty_discussion_message,
|
|
3662
3681
|
start_drag: start_directory_drag,
|
|
3663
3682
|
attachment_markup, attachment_size, attachment_file_icon, drop_attachments, paste_attachments,
|
|
3664
3683
|
write_expert: write_view_expert, add_instance: add_view_instance, add_preset: add_preset_instance, platform_of, execute: execute_view_action, theme: change_view_theme,
|