ai_co_discuss 0.5.21 → 0.5.23
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/codiscuss-draft-cleanup/SKILL.md +16 -0
- package/.agents/skills/codiscuss-draft-cleanup/cleanup.py +70 -0
- package/.agents/skills/codiscuss-draft-cleanup/scan.py +70 -0
- package/.agents/skills/discuss-host/references/control.md +2 -2
- package/.agents/skills/discuss-host/references/workflow.md +4 -2
- package/.agents/skills/discuss-participant/SKILL.md +2 -0
- package/.agents/skills/local-stt-setup/SKILL.md +9 -8
- package/.agents/skills/local-tts-setup/SKILL.md +10 -9
- package/.agents/skills/share-card/SKILL.md +7 -6
- package/.agents/skills/share-card/references/share-card.md +34 -8
- package/.agents/skills/workflow-creator/SKILL.md +22 -14
- package/README.md +2 -0
- package/README.zh-CN.md +2 -0
- package/backend/free_room.py +64 -8
- package/backend/message_queue.py +9 -0
- package/backend/schema.sql +13 -1
- package/backend/server.py +289 -59
- package/docs/en/guide/admin.md +18 -0
- package/docs/en/guide/members.md +7 -1
- package/docs/en/guide/remote.md +1 -1
- package/docs/en/guide/rooms.md +14 -6
- package/docs/en/guide/voice.md +2 -0
- package/docs/en/guide/workflows.md +9 -5
- package/docs/en/guide/working.md +6 -4
- package/docs/guide/admin.md +18 -0
- package/docs/guide/members.md +7 -1
- package/docs/guide/remote.md +1 -1
- package/docs/guide/rooms.md +13 -6
- package/docs/guide/voice.md +2 -0
- package/docs/guide/workflows.md +9 -5
- package/docs/guide/working.md +6 -4
- package/frontend/locales/en/admin.json +58 -1
- package/frontend/locales/en/app.json +18 -1
- package/frontend/locales/en/backend.json +6 -0
- package/frontend/locales/en/core.json +4 -2
- package/frontend/locales/en/discussion.json +4 -1
- package/frontend/locales/en/room.json +85 -1
- package/gateway/gateway.mjs +49 -9
- package/package.json +3 -1
- package/runner/account_space.mjs +10 -0
- package/runner/adapters/antigravity_app.mjs +31 -4
- package/runner/adapters/antigravity_cli.mjs +9 -2
- package/runner/adapters/api.mjs +3 -2
- package/runner/adapters/api_pi.mjs +3 -2
- package/runner/adapters/api_pi_extension.mjs +5 -3
- package/runner/adapters/claude.mjs +32 -9
- package/runner/adapters/cli.mjs +2 -2
- package/runner/adapters/codex_app.mjs +192 -69
- package/runner/adapters/codex_cli.mjs +10 -5
- package/runner/adapters/common.mjs +414 -11
- package/runner/adapters/index.mjs +6 -0
- package/runner/admin_cli.mjs +22 -5
- package/runner/admin_panel.mjs +118 -5
- package/runner/admin_storage.mjs +105 -0
- package/runner/discussion_launch.mjs +328 -128
- package/runner/discussion_runner.mjs +12 -3
- package/runner/discussion_service.mjs +224 -37
- package/runner/discussion_skills.mjs +1 -1
- package/runner/expert_prompts.mjs +2 -2
- package/runner/experts.mjs +227 -0
- package/runner/file_diff.mjs +1 -1
- package/runner/free_runner.mjs +236 -51
- package/runner/i18n_en.mjs +39 -0
- package/runner/os_users.mjs +33 -1
- package/runner/project_files.mjs +7 -1
- package/runner/project_migration.mjs +245 -0
- package/runner/relay_channel.mjs +1 -1
- package/runner/remote_launch.mjs +4 -3
- package/runner/share_card.mjs +17 -1
- package/runner/share_shared.mjs +26 -9
- package/runner/site_deploy.mjs +2 -1
- package/runner/slash_names.mjs +12 -1
- package/runner/speech_directories.mjs +20 -0
- package/runner/storage_guard.mjs +383 -0
- package/runner/tts_providers.mjs +22 -21
- package/runner/workflows.mjs +211 -57
- package/web/admin.css +1 -1
- package/web/admin.js +8 -8
- package/web/app.js +589 -80
- package/web/i18n.js +4 -4
- package/web/markdown.css +1 -1
- package/web/modern.css +1 -1
- package/web/modern.js +68 -66
- package/workflows/decision-council/flow.json +216 -25
- package/workflows/trpg-classic/flow.json +151 -21
package/runner/workflows.mjs
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { createHash, randomUUID } from 'node:crypto';
|
|
6
6
|
import { cpSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
7
7
|
import { dirname, join, resolve } from 'node:path';
|
|
8
|
+
import { atomic_json } from './files.mjs';
|
|
8
9
|
import { DatabaseSync } from 'node:sqlite';
|
|
9
10
|
import { flow_in_use, normalize_flow } from './workflow_flow.mjs';
|
|
10
11
|
|
|
@@ -31,14 +32,14 @@ const CARD_FIELDS = ['name', 'label', 'description', 'project_access', 'model',
|
|
|
31
32
|
const CARD_FILE_FIELDS = ['name', 'platform', 'label', 'description', 'project_access', 'model', 'effort', 'image_model'];
|
|
32
33
|
const PART_LINE = /^<!-- workflow-part: (\d+)\/(\d+) id: ([a-z0-9_-]{1,40}) -->$/;
|
|
33
34
|
const FILE_LINE = /^<!-- workflow-file: (\S+) -->$/;
|
|
34
|
-
const CARD_PATH = /^agents\/([A-Za-z0-9_]{1,16})\.md$/;
|
|
35
|
+
const CARD_PATH = /^(?:experts|agents)\/([A-Za-z0-9_]{1,16})\.md$/;
|
|
35
36
|
// A card may instead be a folder (user 2026-11-22): `agents/<card>/<card>.md` is its definition, shaped like a card file,
|
|
36
37
|
// and `agents/<card>/skills/<skill>/` its skills (SKILL.md plus references), which the member playing it maintains. Only
|
|
37
38
|
// the skills differ, so the folder is also the expert's export package. One card ID is either a file or a folder.
|
|
38
39
|
const SKILLS_FOLDER = 'skills';
|
|
39
40
|
// A folder card's skills, relative to the workflow folder: the main flow's or a sub-workflow's. A save keeps them as they
|
|
40
41
|
// are on disk and the folder's revision leaves them out, since the member writes them while the workflow is in use.
|
|
41
|
-
const CARD_SKILLS_PATH = /^(?:workflows\/[^/]+\/)?agents\/[^/]+\/skills$/;
|
|
42
|
+
const CARD_SKILLS_PATH = /^(?:workflows\/[^/]+\/)?(?:experts|agents)\/[^/]+\/skills$/;
|
|
42
43
|
// Like a skill folder, a workflow carries any other text files beside SKILL.md (templates, references, examples).
|
|
43
44
|
const MAX_RESOURCE_FILES = 100;
|
|
44
45
|
const MAX_RESOURCE_BYTES = 1000000;
|
|
@@ -116,7 +117,7 @@ function workflow_commands(resources) {
|
|
|
116
117
|
}
|
|
117
118
|
|
|
118
119
|
/** The folder holding every workflow of this computer. */
|
|
119
|
-
export function workflows_home(home) { return join(home, 'workflows'); }
|
|
120
|
+
export function workflows_home(home) { return join(home.project_dir ? join(home.project_dir, '.codiscuss') : home, 'workflows'); }
|
|
120
121
|
|
|
121
122
|
/** A workflow's folder, built from a checked ID and never from a caller's path. */
|
|
122
123
|
// Built-in room modes own these "/" commands, so no workflow may take their names.
|
|
@@ -272,7 +273,7 @@ function split_sub_workflows(resources, ignored = []) {
|
|
|
272
273
|
if (!match || (typeof text !== 'string' && match[3] === undefined)) { rest[path] = text; continue; }
|
|
273
274
|
const [, id, file, card] = match;
|
|
274
275
|
if (!found.has(id)) found.set(id, { cards: {} });
|
|
275
|
-
if (card !== undefined) found.get(id).cards
|
|
276
|
+
if (card !== undefined) add_card_file(found.get(id).cards, card, text);
|
|
276
277
|
else found.get(id)[file] = text;
|
|
277
278
|
}
|
|
278
279
|
const sub_workflows = [...found.keys()].sort().map(id => {
|
|
@@ -381,7 +382,7 @@ export function workflow_cards(workflow) {
|
|
|
381
382
|
// used on demand beside the main flow, its cards join the room only when it is used. It has no sub-workflows of its own.
|
|
382
383
|
const SUB_DIRECTORY = 'workflows';
|
|
383
384
|
// A sub-workflow's cards are everything under its agents/: card files, folder cards and their skills.
|
|
384
|
-
const SUB_FILE = /^workflows\/([^/]+)\/(SKILL\.md|flow\.json|agents\/(.+))$/;
|
|
385
|
+
const SUB_FILE = /^workflows\/([^/]+)\/(SKILL\.md|flow\.json|(?:experts|agents)\/(.+))$/;
|
|
385
386
|
const MAX_SUB_WORKFLOWS = 10;
|
|
386
387
|
// A stage ID a sub-workflow attaches to follows the canvas's node ID rule.
|
|
387
388
|
const STAGE_ID = /^[A-Za-z0-9_-]{1,40}$/;
|
|
@@ -427,14 +428,14 @@ function write_sub_workflows(staging, list, carry) {
|
|
|
427
428
|
for (const name of readdirSync(root)) {
|
|
428
429
|
const folder = join(root, name);
|
|
429
430
|
if (!keep.has(name)) { rmSync(folder, { recursive: true, force: true }); continue; }
|
|
430
|
-
for (const own of ['SKILL.md', FLOW_FILE, 'agents']) rmSync(join(folder, own), { recursive: true, force: true });
|
|
431
|
+
for (const own of ['SKILL.md', FLOW_FILE, 'agents', 'experts']) rmSync(join(folder, own), { recursive: true, force: true });
|
|
431
432
|
}
|
|
432
433
|
}
|
|
433
434
|
for (const sub of list) {
|
|
434
435
|
const folder = join(root, sub.id);
|
|
435
|
-
mkdirSync(join(folder, '
|
|
436
|
+
mkdirSync(join(folder, 'experts'), { recursive: true });
|
|
436
437
|
writeFileSync(join(folder, 'SKILL.md'), serialize_markdown(skill_fields(sub.id, sub.label, sub.description, sub.attach), sub.skill));
|
|
437
|
-
write_cards(join(folder, '
|
|
438
|
+
write_cards(join(folder, 'experts'), sub.agents, carry);
|
|
438
439
|
if (sub.flow) writeFileSync(join(folder, FLOW_FILE), `${JSON.stringify(sub.flow, null, 2)}\n`);
|
|
439
440
|
}
|
|
440
441
|
}
|
|
@@ -471,8 +472,8 @@ function write_cards(directory, agents, carry = { folders: new Map(), replace: t
|
|
|
471
472
|
*/
|
|
472
473
|
function backup_card(home, id, card, folder) {
|
|
473
474
|
const name = `workflow-${id}-${card}-${new Date().toISOString().replace(/[:.]/g, '-')}-${randomUUID().slice(0, 8)}`;
|
|
474
|
-
mkdirSync(join(home, 'backups'), { recursive: true });
|
|
475
|
-
cpSync(folder, join(home, 'backups', name), { recursive: true });
|
|
475
|
+
mkdirSync(join(home.service_home || home, 'backups'), { recursive: true });
|
|
476
|
+
cpSync(folder, join(home.service_home || home, 'backups', name), { recursive: true });
|
|
476
477
|
return name;
|
|
477
478
|
}
|
|
478
479
|
|
|
@@ -486,15 +487,15 @@ function card_folders(directory) {
|
|
|
486
487
|
if (CARD_ID_PATTERN.test(name) && lstatSync(join(agents, name)).isDirectory()) found.set(name, join(agents, name));
|
|
487
488
|
}
|
|
488
489
|
};
|
|
489
|
-
scan(join(directory,
|
|
490
|
+
for (const name of ['agents', 'experts']) scan(join(directory, name));
|
|
490
491
|
const subs = join(directory, SUB_DIRECTORY);
|
|
491
|
-
if (existsSync(subs)) for (const name of readdirSync(subs)) scan(join(subs, name,
|
|
492
|
+
if (existsSync(subs)) for (const name of readdirSync(subs)) for (const layout of ['agents', 'experts']) scan(join(subs, name, layout));
|
|
492
493
|
return found;
|
|
493
494
|
}
|
|
494
495
|
|
|
495
496
|
/** A path, relative to the workflow folder, that a resource may take: inside it, not SKILL.md and not under agents/. */
|
|
496
497
|
function resource_path_allowed(path) {
|
|
497
|
-
return path !== 'SKILL.md' && path !== FLOW_FILE &&
|
|
498
|
+
return path !== 'SKILL.md' && path !== FLOW_FILE && !/^(?:experts|agents)\//.test(path) && path.split('/').every(segment => RESOURCE_SEGMENT.test(segment));
|
|
498
499
|
}
|
|
499
500
|
|
|
500
501
|
/** Check resource files `{ "relative/path": text }`. */
|
|
@@ -519,7 +520,7 @@ function validate_resources(resources) {
|
|
|
519
520
|
function read_resource_folder(directory, prefix, resources, ignored) {
|
|
520
521
|
for (const name of readdirSync(directory).sort()) {
|
|
521
522
|
const relative = `${prefix}${name}`;
|
|
522
|
-
if (relative === 'SKILL.md' ||
|
|
523
|
+
if (relative === 'SKILL.md' || ['agents', 'experts'].includes(relative)) continue;
|
|
523
524
|
// The canvas is read as a resource here and taken out as `flow` with the rest of the folder.
|
|
524
525
|
if (relative === FLOW_FILE) { resources[relative] = readFileSync(join(directory, name), 'utf8'); continue; }
|
|
525
526
|
const path = join(directory, name);
|
|
@@ -545,7 +546,7 @@ function write_resources(directory, resources) {
|
|
|
545
546
|
/** Copy a saved folder's files other than SKILL.md and agents/, for a save that carries none of its own. */
|
|
546
547
|
function keep_resources(directory, staging) {
|
|
547
548
|
for (const name of readdirSync(directory)) {
|
|
548
|
-
if (name === 'SKILL.md' ||
|
|
549
|
+
if (name === 'SKILL.md' || ['agents', 'experts'].includes(name)) continue;
|
|
549
550
|
cpSync(join(directory, name), join(staging, name), { recursive: true });
|
|
550
551
|
}
|
|
551
552
|
}
|
|
@@ -595,26 +596,47 @@ function assert_no_links(directory) {
|
|
|
595
596
|
}
|
|
596
597
|
}
|
|
597
598
|
|
|
599
|
+
const RENAME_TIMEOUT_MS = 1000;
|
|
600
|
+
const RENAME_WAIT_MS = 50;
|
|
601
|
+
const rename_wait = new Int32Array(new SharedArrayBuffer(4));
|
|
602
|
+
|
|
603
|
+
function rename_directory(source, target) {
|
|
604
|
+
const deadline = Date.now() + RENAME_TIMEOUT_MS;
|
|
605
|
+
for (;;) {
|
|
606
|
+
try { return renameSync(source, target); }
|
|
607
|
+
catch (error) {
|
|
608
|
+
if (process.platform !== 'win32' || !['EPERM', 'EACCES', 'EBUSY'].includes(error.code) || Date.now() >= deadline) throw error;
|
|
609
|
+
Atomics.wait(rename_wait, 0, 0, RENAME_WAIT_MS);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
|
|
598
614
|
/** Recover an interrupted replacement before any reader can observe a missing workflow. Called under the library lock. */
|
|
599
615
|
function recover_workflows(home) {
|
|
600
616
|
const root = workflows_home(home);
|
|
601
617
|
for (const name of readdirSync(root)) {
|
|
618
|
+
if (/^\.tmp-[a-z0-9_-]{1,40}-[0-9a-f-]{36}$/.test(name)) {
|
|
619
|
+
rmSync(join(root, name), { recursive: true, force: true });
|
|
620
|
+
continue;
|
|
621
|
+
}
|
|
602
622
|
const match = BACKUP_DIRECTORY.exec(name);
|
|
603
623
|
if (!match) continue;
|
|
604
624
|
const backup = join(root, name), directory = workflow_directory(home, match[1]);
|
|
605
625
|
assert_no_links(backup);
|
|
606
626
|
if (existsSync(directory)) rmSync(backup, { recursive: true, force: true });
|
|
607
|
-
else
|
|
627
|
+
else rename_directory(backup, directory);
|
|
608
628
|
}
|
|
609
629
|
}
|
|
610
630
|
|
|
611
631
|
/** Serialize publication, recovery and reads across processes; SQLite releases the lock even if its owner exits. */
|
|
612
|
-
function with_workflow_lock(home, action) {
|
|
613
|
-
|
|
614
|
-
|
|
632
|
+
function with_workflow_lock(home, action, writing = false) {
|
|
633
|
+
check_library_root(home);
|
|
634
|
+
mkdirSync(home.service_home || home, { recursive: true });
|
|
635
|
+
if (writing || !home.project_dir) mkdirSync(workflows_home(home), { recursive: true });
|
|
636
|
+
const lock = new DatabaseSync(join(home.service_home || home, 'workflows-lock.sqlite3'));
|
|
615
637
|
try {
|
|
616
638
|
lock.exec(`PRAGMA busy_timeout=${WORKFLOW_LOCK_WAIT_MS}; BEGIN IMMEDIATE`);
|
|
617
|
-
recover_workflows(home);
|
|
639
|
+
if (!home.root?.readonly && !home.readonly && existsSync(workflows_home(home))) recover_workflows(home);
|
|
618
640
|
return action();
|
|
619
641
|
} finally { lock.close(); }
|
|
620
642
|
}
|
|
@@ -623,21 +645,28 @@ function with_workflow_lock(home, action) {
|
|
|
623
645
|
export function read_workflow_folder(directory) {
|
|
624
646
|
if (!existsSync(join(directory, 'SKILL.md'))) throw new Error('文件夹里没有 SKILL.md');
|
|
625
647
|
assert_no_links(directory);
|
|
626
|
-
const
|
|
648
|
+
const layouts = ['agents', 'experts'].map(name => join(directory, name));
|
|
627
649
|
const cards = {};
|
|
628
650
|
const resources = {}, ignored = [];
|
|
629
651
|
read_resource_folder(directory, '', resources, ignored);
|
|
630
|
-
if (existsSync(agents)) read_text_files(agents, '', cards);
|
|
652
|
+
for (const agents of layouts) if (existsSync(agents)) read_text_files(agents, '', cards);
|
|
631
653
|
const workflow = workflow_from_files(readFileSync(join(directory, 'SKILL.md'), 'utf8'), cards, resources, ignored);
|
|
632
654
|
return { workflow, ignored: [...new Set(ignored)].sort() };
|
|
633
655
|
}
|
|
634
656
|
|
|
657
|
+
function add_card_file(cards, path, text) {
|
|
658
|
+
if (Object.hasOwn(cards, path)) throw new Error(`experts/ 与 agents/ 重复定义了 ${path}`);
|
|
659
|
+
cards[path] = text;
|
|
660
|
+
}
|
|
661
|
+
|
|
635
662
|
/** Every file below a folder as `{relative path: UTF-8 text, or null when it is not text}`. */
|
|
636
663
|
function read_text_files(directory, prefix, files) {
|
|
637
664
|
for (const name of readdirSync(directory).sort()) {
|
|
638
665
|
const path = join(directory, name);
|
|
639
666
|
if (lstatSync(path).isDirectory()) { read_text_files(path, `${prefix}${name}/`, files); continue; }
|
|
640
|
-
|
|
667
|
+
let text = null;
|
|
668
|
+
try { text = utf8.decode(readFileSync(path)); } catch { /* binary file */ }
|
|
669
|
+
add_card_file(files, `${prefix}${name}`, text);
|
|
641
670
|
}
|
|
642
671
|
}
|
|
643
672
|
|
|
@@ -652,7 +681,7 @@ export function read_workflow_files(files) {
|
|
|
652
681
|
const cards = {}, resources = {}, ignored = [];
|
|
653
682
|
for (const path of Object.keys(files).sort()) {
|
|
654
683
|
if (path === 'SKILL.md') continue;
|
|
655
|
-
if (
|
|
684
|
+
if (/^(?:experts|agents)\//.test(path)) add_card_file(cards, path.slice(path.indexOf('/') + 1), typeof files[path] === 'string' ? files[path] : null);
|
|
656
685
|
else if (SUB_FILE.test(path) && SUB_FILE.exec(path)[3] !== undefined) resources[path] = typeof files[path] === 'string' ? files[path] : null;
|
|
657
686
|
else if (typeof files[path] === 'string' && (path === FLOW_FILE || resource_path_allowed(path))) resources[path] = files[path];
|
|
658
687
|
else ignored.push(path);
|
|
@@ -664,9 +693,10 @@ export function read_workflow_files(files) {
|
|
|
664
693
|
/** Summaries for the library list; a broken folder is listed with its error instead of hiding it. */
|
|
665
694
|
export function list_workflows(home, card_ready = null) {
|
|
666
695
|
return with_workflow_lock(home, () => {
|
|
696
|
+
if (!existsSync(workflows_home(home))) return [];
|
|
667
697
|
const disabled = disabled_workflows(home);
|
|
668
698
|
return readdirSync(workflows_home(home)).filter(name => WORKFLOW_ID_PATTERN.test(name)).sort().map(id => {
|
|
669
|
-
const flag = disabled.includes(id) ? { disabled: true } : {};
|
|
699
|
+
const flag = disabled.includes(disabled_key(home, id)) ? { disabled: true } : {};
|
|
670
700
|
try {
|
|
671
701
|
const workflow = read_saved_workflow(home, id);
|
|
672
702
|
// Cards whose software this computer has not set up: the workflow cannot bring them until they change platform.
|
|
@@ -676,7 +706,7 @@ export function list_workflows(home, card_ready = null) {
|
|
|
676
706
|
return { id, label: workflow.label || id, description: workflow.description,
|
|
677
707
|
...(workflow.author ? { author: workflow.author } : {}),
|
|
678
708
|
...(workflow.source ? { source: workflow.source } : {}),
|
|
679
|
-
cards: workflow.agents.length, directory: workflow.directory,
|
|
709
|
+
cards: workflow.agents.length, directory: workflow.directory, ...project_trust(home, workflow),
|
|
680
710
|
...(unavailable.length ? { unavailable } : {}), ...flag };
|
|
681
711
|
} catch (error) { return { id, label: id, description: '', cards: 0, error: error.message, ...flag }; }
|
|
682
712
|
});
|
|
@@ -685,7 +715,9 @@ export function list_workflows(home, card_ready = null) {
|
|
|
685
715
|
|
|
686
716
|
// IDs of workflows the user switched off on this computer: kept in the library, but no room may use them. It is this
|
|
687
717
|
// computer's choice, so it lives beside the library and never travels with a workflow folder.
|
|
688
|
-
function
|
|
718
|
+
function disabled_key(home, id) { return home.project_id ? `project:${home.project_id}:${id}` : id; }
|
|
719
|
+
|
|
720
|
+
function disabled_path(home) { return join(home.service_home || home, 'workflows-disabled.json'); }
|
|
689
721
|
|
|
690
722
|
/** The disabled workflow IDs. */
|
|
691
723
|
function disabled_workflows(home) {
|
|
@@ -703,15 +735,15 @@ function write_disabled(home, list) {
|
|
|
703
735
|
export function set_workflow_disabled(home, id, disabled) {
|
|
704
736
|
return with_workflow_lock(home, () => {
|
|
705
737
|
if (!existsSync(workflow_directory(home, id))) throw new Error(`工作流不存在:${id}`);
|
|
706
|
-
const others = disabled_workflows(home).filter(item => item !== id);
|
|
707
|
-
write_disabled(home, disabled ? [...others, id] : others);
|
|
738
|
+
const others = disabled_workflows(home).filter(item => item !== disabled_key(home, id));
|
|
739
|
+
write_disabled(home, disabled ? [...others, disabled_key(home, id)] : others);
|
|
708
740
|
return { id, disabled: Boolean(disabled) };
|
|
709
741
|
});
|
|
710
742
|
}
|
|
711
743
|
|
|
712
744
|
/** Refuse a workflow the user disabled, before a room starts using it. */
|
|
713
745
|
export function assert_workflow_enabled(home, id) {
|
|
714
|
-
if (disabled_workflows(home).includes(id)) throw new Error(`工作流 ${id} 已停用;请先在“工作流”页启用`);
|
|
746
|
+
if (disabled_workflows(home).includes(disabled_key(home, id))) throw new Error(`工作流 ${id} 已停用;请先在“工作流”页启用`);
|
|
715
747
|
}
|
|
716
748
|
|
|
717
749
|
/** Change only a workflow's display name; its cards, canvas and files stay as they are. */
|
|
@@ -721,7 +753,9 @@ export function rename_workflow(home, id, label) {
|
|
|
721
753
|
if (text.length > MAX_WORKFLOW_LABEL) throw new Error(`工作流显示名最多 ${MAX_WORKFLOW_LABEL} 字`);
|
|
722
754
|
return with_workflow_lock(home, () => {
|
|
723
755
|
const workflow = read_saved_workflow(home, id);
|
|
756
|
+
const was_trusted = home.project_dir && !project_trust(home, workflow).needs_trust;
|
|
724
757
|
writeFileSync(join(workflow.directory, 'SKILL.md'), serialize_markdown(skill_fields(id, text, workflow.description, [], workflow), workflow.skill));
|
|
758
|
+
if (was_trusted) project_trust(home, read_saved_workflow(home, id), true);
|
|
725
759
|
return { id, label: text };
|
|
726
760
|
});
|
|
727
761
|
}
|
|
@@ -731,12 +765,12 @@ export function rename_workflow(home, id, label) {
|
|
|
731
765
|
* their files, templates, scripts), by relative path and bytes, except folder cards' skills, which their members write
|
|
732
766
|
* while the workflow is in use and a save keeps as they are. Any other change anywhere changes it. Call under the lock.
|
|
733
767
|
*/
|
|
734
|
-
export function folder_revision(directory) {
|
|
768
|
+
export function folder_revision(directory, include_skills = false) {
|
|
735
769
|
const hash = createHash('sha256');
|
|
736
770
|
const walk = relative => {
|
|
737
771
|
for (const name of readdirSync(join(directory, relative)).sort()) {
|
|
738
772
|
const path = relative ? `${relative}/${name}` : name;
|
|
739
|
-
if (lstatSync(join(directory, path)).isDirectory()) { if (!CARD_SKILLS_PATH.test(path)) walk(path); }
|
|
773
|
+
if (lstatSync(join(directory, path)).isDirectory()) { if (include_skills || !CARD_SKILLS_PATH.test(path)) walk(path); }
|
|
740
774
|
else hash.update(`${path}\0`).update(readFileSync(join(directory, path))).update('\0');
|
|
741
775
|
}
|
|
742
776
|
};
|
|
@@ -779,9 +813,70 @@ function check_save_base(directory, id, { base_revision, overwrite } = {}) {
|
|
|
779
813
|
if (exists) throw workflow_failure('workflow_exists', '工作流库里已有「{id}」;要整份覆盖它,请明确选择覆盖', { id });
|
|
780
814
|
}
|
|
781
815
|
|
|
816
|
+
/** Read the local approval for the exact project workflow revision. */
|
|
817
|
+
function project_trust(home, workflow, approve = false) {
|
|
818
|
+
if (!home.project_id) return {};
|
|
819
|
+
const commands = workflow.commands.map(command => command.id);
|
|
820
|
+
const elevated_cards = workflow_cards(workflow).filter(card => card.project_access && card.project_access !== 'read')
|
|
821
|
+
.map(({ card, label, project_access }) => ({ card, label: label || card, project_access }));
|
|
822
|
+
const path = join(home.service_home, 'project-trust.json');
|
|
823
|
+
const records = existsSync(path) ? JSON.parse(readFileSync(path, 'utf8')) : {};
|
|
824
|
+
const key = `workflow:${home.project_id}:${workflow.id}`;
|
|
825
|
+
const digest = folder_revision(workflow.directory, true);
|
|
826
|
+
if (approve) {
|
|
827
|
+
records[key] = digest;
|
|
828
|
+
atomic_json(path, records);
|
|
829
|
+
}
|
|
830
|
+
if ((!commands.length && !elevated_cards.length) || records[key] === digest) return { needs_trust: false };
|
|
831
|
+
return { needs_trust: true, untrusted_reasons: { commands, elevated_cards } };
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
/** Read and approve the same revision under the local publication lock. */
|
|
835
|
+
export function trust_workflow(home, id) {
|
|
836
|
+
return with_workflow_lock(home, () => project_trust(home, read_saved_workflow(home, id), true));
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
function check_library_root(home) {
|
|
840
|
+
if (home.project_dir) {
|
|
841
|
+
for (const path of [join(home.project_dir, '.codiscuss'), workflows_home(home)]) {
|
|
842
|
+
if (lstatSync(path, { throwIfNoEntry: false })?.isSymbolicLink()) throw new Error('项目工作流目录不能是符号链接');
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
/** Publish the complete destination before removing a moved source. */
|
|
848
|
+
export function transfer_workflow(source, target, id, { move, overwrite, after_publish }) {
|
|
849
|
+
check_library_root(source);
|
|
850
|
+
if (resolve(workflows_home(source)).toLowerCase() === resolve(workflows_home(target)).toLowerCase()) throw new Error('来源和目标项目相同');
|
|
851
|
+
return with_workflow_lock(target, () => {
|
|
852
|
+
const flow = read_saved_workflow(source, id);
|
|
853
|
+
const trust = project_trust(source, flow);
|
|
854
|
+
if (trust.needs_trust) throw Object.assign(new Error('项目工作流需要确认信任'), { code: 'workflow_untrusted', details: trust });
|
|
855
|
+
const destination = workflow_directory(target, id);
|
|
856
|
+
check_save_base(destination, id, { overwrite });
|
|
857
|
+
const backups = [];
|
|
858
|
+
if (existsSync(destination)) {
|
|
859
|
+
assert_no_links(destination);
|
|
860
|
+
backups.push(backup_card(target, id, 'workflow', destination));
|
|
861
|
+
}
|
|
862
|
+
publish_directory(target, id, staging => cpSync(flow.directory, staging, { recursive: true }));
|
|
863
|
+
project_trust(target, read_saved_workflow(target, id), true);
|
|
864
|
+
after_publish?.();
|
|
865
|
+
if (move) {
|
|
866
|
+
rmSync(flow.directory, { recursive: true, force: true });
|
|
867
|
+
const key = disabled_key(source, id), disabled = disabled_workflows(source);
|
|
868
|
+
if (disabled.includes(key)) write_disabled(source, [...disabled.filter(item => item !== key), disabled_key(target, id)]);
|
|
869
|
+
}
|
|
870
|
+
return { id, ...(backups.length ? { backups } : {}) };
|
|
871
|
+
}, true);
|
|
872
|
+
}
|
|
873
|
+
|
|
782
874
|
/** One workflow in full, as the editor shows it. */
|
|
783
875
|
export function get_workflow(home, id) {
|
|
784
|
-
return with_workflow_lock(home, () =>
|
|
876
|
+
return with_workflow_lock(home, () => {
|
|
877
|
+
const workflow = read_saved_workflow(home, id);
|
|
878
|
+
return { ...workflow, ...project_trust(home, workflow) };
|
|
879
|
+
});
|
|
785
880
|
}
|
|
786
881
|
|
|
787
882
|
/** Fill a staging folder, then swap it in for the library entry, recoverable if the process dies midway. Call under the lock. */
|
|
@@ -790,12 +885,14 @@ function publish_directory(home, id, fill) {
|
|
|
790
885
|
if (existsSync(directory)) assert_no_links(directory);
|
|
791
886
|
const staging = join(workflows_home(home), `.tmp-${id}-${randomUUID()}`);
|
|
792
887
|
mkdirSync(staging, { recursive: true });
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
888
|
+
try {
|
|
889
|
+
fill(staging, directory);
|
|
890
|
+
const old = existsSync(directory) ? join(workflows_home(home), `.old-${id}-${randomUUID()}`) : '';
|
|
891
|
+
if (old) rename_directory(directory, old);
|
|
892
|
+
try { rename_directory(staging, directory); }
|
|
893
|
+
catch (error) { if (old) rename_directory(old, directory); throw error; }
|
|
894
|
+
if (old) rmSync(old, { recursive: true, force: true });
|
|
895
|
+
} finally { rmSync(staging, { recursive: true, force: true }); }
|
|
799
896
|
}
|
|
800
897
|
|
|
801
898
|
/** Copy a distributed workflow folder into the library as it is, replacing any entry of that ID. */
|
|
@@ -818,9 +915,9 @@ export function save_workflow(home, input, validate_card, base = {}) {
|
|
|
818
915
|
// A folder card whose skills are replaced or that the save drops is backed up first.
|
|
819
916
|
const carry = { folders: card_folders(directory), replace: base.overwrite === true || !existsSync(directory),
|
|
820
917
|
backup: (card, folder) => backups.push(backup_card(home, workflow.id, card, folder)) };
|
|
821
|
-
mkdirSync(join(staging, '
|
|
918
|
+
mkdirSync(join(staging, 'experts'), { recursive: true });
|
|
822
919
|
writeFileSync(join(staging, 'SKILL.md'), serialize_markdown(skill_fields(workflow.id, workflow.label, workflow.description, [], workflow), workflow.skill));
|
|
823
|
-
write_cards(join(staging, '
|
|
920
|
+
write_cards(join(staging, 'experts'), workflow.agents, carry);
|
|
824
921
|
if (workflow.resources) write_resources(staging, workflow.resources);
|
|
825
922
|
else if (existsSync(directory)) keep_resources(directory, staging);
|
|
826
923
|
if (workflow.flow) writeFileSync(join(staging, FLOW_FILE), `${JSON.stringify(workflow.flow, null, 2)}
|
|
@@ -835,8 +932,8 @@ export function save_workflow(home, input, validate_card, base = {}) {
|
|
|
835
932
|
});
|
|
836
933
|
const saved = read_saved_workflow(home, workflow.id);
|
|
837
934
|
const warnings = workflow_warnings(saved);
|
|
838
|
-
return { ...saved, ...(warnings.length ? { warnings } : {}), ...(backups.length ? { backups } : {}) };
|
|
839
|
-
});
|
|
935
|
+
return { ...saved, ...project_trust(home, saved, true), ...(warnings.length ? { warnings } : {}), ...(backups.length ? { backups } : {}) };
|
|
936
|
+
}, true);
|
|
840
937
|
}
|
|
841
938
|
|
|
842
939
|
/**
|
|
@@ -868,7 +965,7 @@ export function delete_workflow(home, id) {
|
|
|
868
965
|
assert_no_links(directory);
|
|
869
966
|
const backups = [...card_folders(directory)].map(([card, folder]) => backup_card(home, id, card, folder));
|
|
870
967
|
rmSync(directory, { recursive: true, force: true });
|
|
871
|
-
if (disabled_workflows(home).includes(id)) write_disabled(home, disabled_workflows(home).filter(item => item !== id));
|
|
968
|
+
if (disabled_workflows(home).includes(disabled_key(home, id))) write_disabled(home, disabled_workflows(home).filter(item => item !== disabled_key(home, id)));
|
|
872
969
|
return { deleted: id, ...(backups.length ? { backups } : {}) };
|
|
873
970
|
});
|
|
874
971
|
}
|
|
@@ -899,7 +996,7 @@ export function parse_workflow_draft(parts) {
|
|
|
899
996
|
for (const line of pieces.flatMap(piece => piece.lines)) {
|
|
900
997
|
const marker = FILE_LINE.exec(line);
|
|
901
998
|
if (!marker) { current?.push(line); continue; }
|
|
902
|
-
const path = marker[1];
|
|
999
|
+
const path = marker[1].replace(/^experts\//, 'agents/');
|
|
903
1000
|
if (path !== 'SKILL.md' && path !== FLOW_FILE && !CARD_PATH.test(path)) throw new Error(`草稿只能包含 SKILL.md、${FLOW_FILE} 和 agents/卡片ID.md:${path}`);
|
|
904
1001
|
if (files.has(path)) throw new Error(`草稿里 ${path} 出现了两次`);
|
|
905
1002
|
current = [];
|
|
@@ -948,12 +1045,34 @@ export function preview_workflow(input, validate_card, known_platform) {
|
|
|
948
1045
|
* What a room's runner needs from its enabled workflow, read fresh for each execution.
|
|
949
1046
|
* Returns null when no workflow is enabled; an unreadable one returns its error so members fall back to room settings.
|
|
950
1047
|
*/
|
|
1048
|
+
export function room_workflow_store(home, config, binding = config.workflow) {
|
|
1049
|
+
if (binding?.scope !== 'project') return home;
|
|
1050
|
+
const roots = [config.cwd, ...(config.extra_directories || [])];
|
|
1051
|
+
for (const item of roots) {
|
|
1052
|
+
const path = typeof item === 'string' ? item : item?.path;
|
|
1053
|
+
if (!path) continue;
|
|
1054
|
+
const project_id = createHash('sha256').update(resolve(path).toLowerCase()).digest('hex').slice(0, 16);
|
|
1055
|
+
if (binding.project_id === project_id || (!binding.project_id && path === config.cwd)) {
|
|
1056
|
+
return { service_home: home, project_id, project_dir: path, readonly: item?.access === 'read' };
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
throw new Error('工作流不属于本房间的项目目录');
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
/** Read a bound workflow only while its current revision is trusted. */
|
|
1063
|
+
export function bound_workflow(home, config) {
|
|
1064
|
+
const store = room_workflow_store(home, config);
|
|
1065
|
+
assert_workflow_enabled(store, config.workflow.id);
|
|
1066
|
+
const flow = get_workflow(store, config.workflow.id);
|
|
1067
|
+
if (flow.needs_trust) throw Object.assign(new Error('项目工作流需要确认信任'), { code: 'workflow_untrusted', details: { untrusted_reasons: flow.untrusted_reasons } });
|
|
1068
|
+
return flow;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
951
1071
|
export function load_room_workflow(config) {
|
|
952
1072
|
const binding = config.workflow;
|
|
953
1073
|
if (!binding?.enabled || !config.api_home) return null;
|
|
954
1074
|
try {
|
|
955
|
-
|
|
956
|
-
const workflow = get_workflow(config.api_home, binding.id);
|
|
1075
|
+
const workflow = bound_workflow(config.api_home, config);
|
|
957
1076
|
const { directory } = workflow;
|
|
958
1077
|
// A sub-workflow's cards play members like the main flow's, so they are looked up in one map.
|
|
959
1078
|
const cards = Object.fromEntries(workflow_cards(workflow).map(agent => [agent.card, agent]));
|
|
@@ -963,7 +1082,7 @@ export function load_room_workflow(config) {
|
|
|
963
1082
|
attach: sub.attach || [] }));
|
|
964
1083
|
// The canvas is for the user to see; the host works from SKILL.md alone, plus the steps' names its sub-workflows attach to.
|
|
965
1084
|
const stages = (workflow.flow?.stages || []).map(stage => ({ id: stage.id, label: stage.label || stage.id }));
|
|
966
|
-
return { id: binding.id, label: workflow.label || binding.id, description: workflow.description || '', directory, skill_path: join(directory, 'SKILL.md'), skill: workflow.skill,
|
|
1085
|
+
return { ...(binding.scope === 'project' ? { readonly: room_workflow_store(config.api_home, config).readonly } : {}), id: binding.id, label: workflow.label || binding.id, description: workflow.description || '', directory, skill_path: join(directory, 'SKILL.md'), skill: workflow.skill,
|
|
967
1086
|
revision: revision_of(workflow.skill), members: binding.members || {}, extra_members: binding.extra_members || {}, cards, sub_workflows, stages,
|
|
968
1087
|
commands: workflow.commands, content_revision: workflow.revision };
|
|
969
1088
|
} catch (error) { return { id: binding.id, error: error.message }; }
|
|
@@ -1001,7 +1120,23 @@ export const SKILL_FILE = 'SKILL.md';
|
|
|
1001
1120
|
export const SKILL_NAME_PATTERN = WORKFLOW_ID_PATTERN;
|
|
1002
1121
|
|
|
1003
1122
|
/** The folder holding panel experts' knowledge on this computer. */
|
|
1004
|
-
export function experts_home(home) { return join(home, 'experts'); }
|
|
1123
|
+
export function experts_home(home) { return join(home.project_dir ? join(home.project_dir, '.codiscuss') : home, 'experts'); }
|
|
1124
|
+
|
|
1125
|
+
/** Resolve a physical expert key without giving another platform its skill directory. */
|
|
1126
|
+
export function expert_disk_key(directory, platform, id) {
|
|
1127
|
+
if (!/^[A-Za-z]+$/.test(platform) || !/^[A-Za-z0-9_]{1,16}$/.test(id)) throw new Error('无效的专家编号');
|
|
1128
|
+
const qualified = platform.toLowerCase() + '-' + id;
|
|
1129
|
+
for (const key of [qualified, id]) {
|
|
1130
|
+
const folder = join(directory, key);
|
|
1131
|
+
const file = existsSync(folder) ? join(folder, key + '.md') : folder + '.md';
|
|
1132
|
+
for (const part of [directory, folder, file]) if (lstatSync(part, { throwIfNoEntry: false })?.isSymbolicLink()) throw new Error('专家路径不能包含符号链接');
|
|
1133
|
+
if (existsSync(file)) {
|
|
1134
|
+
if (parse_markdown(readFileSync(file, 'utf8'), file).fields.platform === platform) return key;
|
|
1135
|
+
if (key === id) return qualified;
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
return id;
|
|
1139
|
+
}
|
|
1005
1140
|
|
|
1006
1141
|
/** The skill names under an expert folder's skills/ that have a SKILL.md; none when the folder is missing. */
|
|
1007
1142
|
export function expert_skills(directory) {
|
|
@@ -1014,12 +1149,13 @@ export function expert_skills(directory) {
|
|
|
1014
1149
|
export function card_folder(workflow, card) {
|
|
1015
1150
|
const source = workflow?.cards?.[card];
|
|
1016
1151
|
if (!source || !Array.isArray(source.skills) || !workflow.directory) return '';
|
|
1017
|
-
|
|
1152
|
+
const root = join(workflow.directory, ...(source.sub_workflow ? [SUB_DIRECTORY, source.sub_workflow] : []));
|
|
1153
|
+
return join(root, existsSync(join(root, 'experts', card)) ? 'experts' : 'agents', card);
|
|
1018
1154
|
}
|
|
1019
1155
|
|
|
1020
1156
|
/** The expert key a member's name gives (`平台-后缀`, as a preset names it; an instance number after it is tried without). */
|
|
1021
1157
|
function name_keys(member_name) {
|
|
1022
|
-
const match = /^[A-Za-z]+-([
|
|
1158
|
+
const match = /^[A-Za-z]+-([A-Za-z0-9_]{1,16})$/.exec(member_name);
|
|
1023
1159
|
return match ? [...new Set([match[1], match[1].replace(/\d+$/, '')])].filter(Boolean) : [];
|
|
1024
1160
|
}
|
|
1025
1161
|
|
|
@@ -1028,18 +1164,36 @@ function name_keys(member_name) {
|
|
|
1028
1164
|
* in the workflow folder (created when missing, so it can write its first skill); one playing a card file has none.
|
|
1029
1165
|
* Any other member gets `experts/<suffix>/skills/` in the service home when it has a skill there.
|
|
1030
1166
|
*/
|
|
1031
|
-
export function member_knowledge(home, member_name, workflow) {
|
|
1167
|
+
export function member_knowledge(home, member_name, workflow, project_dirs = [], profile = {}) {
|
|
1032
1168
|
if (!member_name) return '';
|
|
1033
1169
|
const card = workflow && !workflow.error ? card_of_member(workflow, member_name) : '';
|
|
1034
1170
|
if (card) {
|
|
1035
1171
|
const folder = card_folder(workflow, card);
|
|
1036
1172
|
if (!folder) return '';
|
|
1173
|
+
if (workflow.readonly) return existsSync(join(folder, SKILLS_DIRECTORY)) ? join(folder, SKILLS_DIRECTORY) : '';
|
|
1037
1174
|
mkdirSync(join(folder, SKILLS_DIRECTORY), { recursive: true });
|
|
1038
1175
|
return join(folder, SKILLS_DIRECTORY);
|
|
1039
1176
|
}
|
|
1040
1177
|
if (!home) return '';
|
|
1041
|
-
|
|
1042
|
-
|
|
1178
|
+
const roots = project_dirs.map(item => typeof item === 'string' ? item : item.path).filter(Boolean);
|
|
1179
|
+
for (const path of profile.preset_scope === 'global' ? [] : roots) {
|
|
1180
|
+
const id = createHash('sha256').update(resolve(path).toLowerCase()).digest('hex').slice(0, 16);
|
|
1181
|
+
if (profile.preset_project_id && profile.preset_project_id !== id) continue;
|
|
1182
|
+
for (const key of name_keys(member_name)) {
|
|
1183
|
+
const base = join(path, '.codiscuss');
|
|
1184
|
+
const parent = join(base, 'experts');
|
|
1185
|
+
if (lstatSync(base, { throwIfNoEntry: false })?.isSymbolicLink()) continue;
|
|
1186
|
+
const disk = expert_disk_key(parent, member_name.split('-')[0], key);
|
|
1187
|
+
const folder = join(parent, disk), definition = join(folder, disk + '.md');
|
|
1188
|
+
if ([base, parent, folder, definition].some(part => lstatSync(part, { throwIfNoEntry: false })?.isSymbolicLink()) || !existsSync(definition)) continue;
|
|
1189
|
+
if (parse_markdown(readFileSync(definition, 'utf8'), definition).fields.platform !== member_name.split('-')[0]) continue;
|
|
1190
|
+
assert_no_links(folder);
|
|
1191
|
+
if (expert_skills(folder).length) return join(folder, SKILLS_DIRECTORY);
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
if (profile.preset_scope !== 'project') for (const key of name_keys(member_name)) {
|
|
1195
|
+
const root = experts_home(home);
|
|
1196
|
+
const directory = join(root, expert_disk_key(root, member_name.split('-')[0], key));
|
|
1043
1197
|
if (expert_skills(directory).length) return join(directory, SKILLS_DIRECTORY);
|
|
1044
1198
|
}
|
|
1045
1199
|
return '';
|
|
@@ -1096,7 +1250,7 @@ export function workflow_in_use(workflow, room_members) {
|
|
|
1096
1250
|
}
|
|
1097
1251
|
|
|
1098
1252
|
/** Write a room's workflow binding into its configuration object (the caller saves it). */
|
|
1099
|
-
export function bind_room_workflow(config, { id, enabled, members, extra_members }) {
|
|
1253
|
+
export function bind_room_workflow(config, { id, enabled, members, extra_members, scope, project_id }) {
|
|
1100
1254
|
workflow_directory('.', id);
|
|
1101
1255
|
if (members && (typeof members !== 'object' || Array.isArray(members)
|
|
1102
1256
|
|| Object.entries(members).some(([card, name]) => !CARD_ID_PATTERN.test(card) || typeof name !== 'string' || !name))) {
|
|
@@ -1108,8 +1262,8 @@ export function bind_room_workflow(config, { id, enabled, members, extra_members
|
|
|
1108
1262
|
}
|
|
1109
1263
|
// Further members of a card (`extra_members`, {member name: card ID}) come only from the host's workflow-join --label;
|
|
1110
1264
|
// rebinding the same workflow keeps them.
|
|
1111
|
-
const same = config.workflow?.id === id;
|
|
1265
|
+
const same = config.workflow?.id === id && (config.workflow.scope || 'global') === (scope || 'global') && config.workflow.project_id === project_id;
|
|
1112
1266
|
const extra = extra_members ?? (same ? config.workflow.extra_members : undefined);
|
|
1113
|
-
return { ...config, workflow: { id, enabled: Boolean(enabled), members: { ...(same ? config.workflow.members : {}), ...(members || {}) },
|
|
1267
|
+
return { ...config, workflow: { id, ...(scope === 'project' ? { scope, project_id } : {}), enabled: Boolean(enabled), members: { ...(same ? config.workflow.members : {}), ...(members || {}) },
|
|
1114
1268
|
...(extra && Object.keys(extra).length ? { extra_members: { ...extra } } : {}) } };
|
|
1115
1269
|
}
|