triflux 10.3.2 → 10.3.3

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.
Files changed (55) hide show
  1. package/.claude-plugin/plugin.json +22 -22
  2. package/LICENSE +21 -21
  3. package/README.ko.md +16 -0
  4. package/README.md +8 -0
  5. package/hooks/hook-registry.json +256 -256
  6. package/hub/adaptive-inject.mjs +1 -1
  7. package/hub/assign-callbacks.mjs +120 -120
  8. package/hub/delegator/index.mjs +14 -14
  9. package/hub/delegator/tool-definitions.mjs +35 -35
  10. package/hub/hitl.mjs +143 -143
  11. package/hub/router.mjs +791 -791
  12. package/hub/session-fingerprint.mjs +1 -1
  13. package/hub/team/cli/commands/attach.mjs +37 -37
  14. package/hub/team/cli/commands/debug.mjs +74 -74
  15. package/hub/team/cli/commands/focus.mjs +53 -53
  16. package/hub/team/cli/commands/list.mjs +24 -24
  17. package/hub/team/cli/commands/start/start-in-process.mjs +40 -40
  18. package/hub/team/cli/commands/start/start-mux.mjs +73 -73
  19. package/hub/team/cli/commands/start/start-wt.mjs +69 -69
  20. package/hub/team/cli/commands/tasks.mjs +13 -13
  21. package/hub/team/cli/render.mjs +30 -30
  22. package/hub/team/cli/services/attach-fallback.mjs +54 -54
  23. package/hub/team/cli/services/member-selector.mjs +30 -30
  24. package/hub/team/cli/services/native-control.mjs +116 -116
  25. package/hub/team/cli/services/task-model.mjs +30 -30
  26. package/hub/team/notify.mjs +1 -1
  27. package/hub/team/orchestrator.mjs +161 -161
  28. package/hub/team/session.mjs +611 -611
  29. package/hub/team/shared.mjs +13 -13
  30. package/hub/tray.mjs +368 -368
  31. package/hub/workers/codex-mcp.mjs +507 -507
  32. package/hub/workers/factory.mjs +21 -21
  33. package/mesh/index.mjs +63 -0
  34. package/mesh/mesh-budget.mjs +128 -0
  35. package/mesh/mesh-heartbeat.mjs +100 -0
  36. package/mesh/mesh-protocol.mjs +96 -0
  37. package/mesh/mesh-queue.mjs +165 -0
  38. package/mesh/mesh-registry.mjs +78 -0
  39. package/mesh/mesh-router.mjs +76 -0
  40. package/package.json +2 -1
  41. package/scripts/completions/tfx.bash +47 -47
  42. package/scripts/completions/tfx.fish +44 -44
  43. package/scripts/completions/tfx.zsh +83 -83
  44. package/scripts/hub-ensure.mjs +120 -120
  45. package/scripts/keyword-detector.mjs +272 -272
  46. package/scripts/keyword-rules-expander.mjs +521 -521
  47. package/scripts/lib/mcp-server-catalog.mjs +118 -118
  48. package/scripts/notion-read.mjs +553 -553
  49. package/scripts/test-tfx-route-no-claude-native.mjs +57 -57
  50. package/scripts/tfx-batch-stats.mjs +96 -96
  51. package/skills/.omc/state/agent-replay-8f0e10a9-9693-4410-96f5-a6b07e8ed995.jsonl +0 -1
  52. package/skills/.omc/state/idle-notif-cooldown.json +0 -3
  53. package/skills/.omc/state/last-tool-error.json +0 -7
  54. package/skills/.omc/state/subagent-tracking.json +0 -7
  55. package/skills/tfx-remote-spawn/references/hosts.json +0 -16
@@ -0,0 +1,76 @@
1
+ import { validate } from "./mesh-protocol.mjs";
2
+
3
+ /**
4
+ * Routes a mesh message to target agent(s) based on the `to` field.
5
+ *
6
+ * Addressing modes:
7
+ * - "agent-id" → direct delivery (registry lookup)
8
+ * - "*" → broadcast to all registered agents
9
+ * - "capability:X" → discover agents with capability X
10
+ *
11
+ * @param {object} message - A mesh-protocol message
12
+ * @param {object} registry - A mesh-registry instance
13
+ * @returns {{ routed: boolean, targets?: string[], reason?: string }}
14
+ */
15
+ export function routeMessage(message, registry) {
16
+ const { valid, errors } = validate(message);
17
+ if (!valid) {
18
+ return { routed: false, reason: `invalid message: ${errors.join(", ")}` };
19
+ }
20
+
21
+ const { to, from } = message;
22
+
23
+ // Broadcast
24
+ if (to === "*") {
25
+ const all = registry.listAll();
26
+ const targets = all
27
+ .map((a) => a.agentId)
28
+ .filter((id) => id !== from);
29
+ if (targets.length === 0) {
30
+ return { routed: false, reason: "broadcast: no agents registered" };
31
+ }
32
+ return { routed: true, targets };
33
+ }
34
+
35
+ // Capability-based routing
36
+ if (to.startsWith("capability:")) {
37
+ const capability = to.slice("capability:".length);
38
+ if (!capability) {
39
+ return { routed: false, reason: "capability: empty capability name" };
40
+ }
41
+ const targets = registry.discover(capability);
42
+ if (targets.length === 0) {
43
+ return { routed: false, reason: `capability: no agents with "${capability}"` };
44
+ }
45
+ return { routed: true, targets };
46
+ }
47
+
48
+ // Direct addressing
49
+ const agent = registry.getAgent(to);
50
+ if (!agent) {
51
+ return { routed: false, reason: `agent not found: "${to}"` };
52
+ }
53
+ return { routed: true, targets: [to] };
54
+ }
55
+
56
+ /**
57
+ * Routes a message and collects dead-letter info when delivery fails.
58
+ *
59
+ * @param {object} message
60
+ * @param {object} registry
61
+ * @returns {{ routed: boolean, targets?: string[], deadLetter?: object }}
62
+ */
63
+ export function routeOrDeadLetter(message, registry) {
64
+ const result = routeMessage(message, registry);
65
+ if (!result.routed) {
66
+ return {
67
+ ...result,
68
+ deadLetter: {
69
+ originalMessage: message,
70
+ reason: result.reason,
71
+ timestamp: new Date().toISOString(),
72
+ },
73
+ };
74
+ }
75
+ return result;
76
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triflux",
3
- "version": "10.3.2",
3
+ "version": "10.3.3",
4
4
  "description": "CLI-first multi-model orchestrator for Claude Code — route tasks to Codex, Gemini, and Claude",
5
5
  "type": "module",
6
6
  "bin": {
@@ -24,6 +24,7 @@
24
24
  "scripts",
25
25
  "hooks",
26
26
  "hud",
27
+ "mesh",
27
28
  ".claude-plugin",
28
29
  "README.md",
29
30
  "README.ko.md",
@@ -1,47 +1,47 @@
1
- #!/usr/bin/env bash
2
- # Installation: source /path/to/tfx.bash 또는 ~/.bashrc에 추가
3
-
4
- _tfx_completion() {
5
- local cur prev words cword
6
- COMPREPLY=()
7
- cur="${COMP_WORDS[COMP_CWORD]}"
8
- prev="${COMP_WORDS[COMP_CWORD-1]}"
9
- words=("${COMP_WORDS[@]}")
10
- cword=$COMP_CWORD
11
-
12
- local commands="setup doctor multi hub auto codex gemini"
13
- local multi_cmds="status stop kill attach list"
14
- local hub_cmds="start stop status restart"
15
- local flags="--thorough --quick --tmux --psmux --agents --no-attach --timeout"
16
-
17
- if [[ $cword -eq 1 ]]; then
18
- COMPREPLY=( $(compgen -W "${commands}" -- "$cur") )
19
- return 0
20
- fi
21
-
22
- local cmd="${words[1]}"
23
- case "${cmd}" in
24
- multi)
25
- if [[ $cword -eq 2 && ! "$cur" == -* ]]; then
26
- COMPREPLY=( $(compgen -W "${multi_cmds}" -- "$cur") )
27
- else
28
- COMPREPLY=( $(compgen -W "${flags}" -- "$cur") )
29
- fi
30
- ;;
31
- hub)
32
- if [[ $cword -eq 2 ]]; then
33
- COMPREPLY=( $(compgen -W "${hub_cmds}" -- "$cur") )
34
- fi
35
- ;;
36
- doctor)
37
- COMPREPLY=( $(compgen -W "--fix --reset" -- "$cur") )
38
- ;;
39
- setup|auto|codex|gemini)
40
- if [[ "$cur" == -* ]]; then
41
- COMPREPLY=( $(compgen -W "${flags}" -- "$cur") )
42
- fi
43
- ;;
44
- esac
45
- }
46
-
47
- complete -F _tfx_completion tfx
1
+ #!/usr/bin/env bash
2
+ # Installation: source /path/to/tfx.bash 또는 ~/.bashrc에 추가
3
+
4
+ _tfx_completion() {
5
+ local cur prev words cword
6
+ COMPREPLY=()
7
+ cur="${COMP_WORDS[COMP_CWORD]}"
8
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
9
+ words=("${COMP_WORDS[@]}")
10
+ cword=$COMP_CWORD
11
+
12
+ local commands="setup doctor multi hub auto codex gemini"
13
+ local multi_cmds="status stop kill attach list"
14
+ local hub_cmds="start stop status restart"
15
+ local flags="--thorough --quick --tmux --psmux --agents --no-attach --timeout"
16
+
17
+ if [[ $cword -eq 1 ]]; then
18
+ COMPREPLY=( $(compgen -W "${commands}" -- "$cur") )
19
+ return 0
20
+ fi
21
+
22
+ local cmd="${words[1]}"
23
+ case "${cmd}" in
24
+ multi)
25
+ if [[ $cword -eq 2 && ! "$cur" == -* ]]; then
26
+ COMPREPLY=( $(compgen -W "${multi_cmds}" -- "$cur") )
27
+ else
28
+ COMPREPLY=( $(compgen -W "${flags}" -- "$cur") )
29
+ fi
30
+ ;;
31
+ hub)
32
+ if [[ $cword -eq 2 ]]; then
33
+ COMPREPLY=( $(compgen -W "${hub_cmds}" -- "$cur") )
34
+ fi
35
+ ;;
36
+ doctor)
37
+ COMPREPLY=( $(compgen -W "--fix --reset" -- "$cur") )
38
+ ;;
39
+ setup|auto|codex|gemini)
40
+ if [[ "$cur" == -* ]]; then
41
+ COMPREPLY=( $(compgen -W "${flags}" -- "$cur") )
42
+ fi
43
+ ;;
44
+ esac
45
+ }
46
+
47
+ complete -F _tfx_completion tfx
@@ -1,44 +1,44 @@
1
- # Installation: ~/.config/fish/completions/에 복사
2
- # e.g., cp /path/to/tfx.fish ~/.config/fish/completions/tfx.fish
3
-
4
- set -l commands setup doctor multi hub auto codex gemini
5
- set -l multi_cmds status stop kill attach list
6
- set -l hub_cmds start stop status restart
7
-
8
- complete -c tfx -f
9
-
10
- # Subcommands
11
- complete -c tfx -n "not __fish_seen_subcommand_from $commands" -a "setup" -d "Setup and sync files"
12
- complete -c tfx -n "not __fish_seen_subcommand_from $commands" -a "doctor" -d "Diagnose CLI and issues"
13
- complete -c tfx -n "not __fish_seen_subcommand_from $commands" -a "multi" -d "Multi-CLI team mode"
14
- complete -c tfx -n "not __fish_seen_subcommand_from $commands" -a "hub" -d "MCP message bus management"
15
- complete -c tfx -n "not __fish_seen_subcommand_from $commands" -a "auto" -d "Auto mode"
16
- complete -c tfx -n "not __fish_seen_subcommand_from $commands" -a "codex" -d "Codex mode"
17
- complete -c tfx -n "not __fish_seen_subcommand_from $commands" -a "gemini" -d "Gemini mode"
18
-
19
- # Doctor flags
20
- complete -c tfx -n "__fish_seen_subcommand_from doctor" -l fix -d "Auto fix issues"
21
- complete -c tfx -n "__fish_seen_subcommand_from doctor" -l reset -d "Reset all caches"
22
-
23
- # Multi subcommands
24
- complete -c tfx -n "__fish_seen_subcommand_from multi; and not __fish_seen_subcommand_from $multi_cmds" -a "status"
25
- complete -c tfx -n "__fish_seen_subcommand_from multi; and not __fish_seen_subcommand_from $multi_cmds" -a "stop"
26
- complete -c tfx -n "__fish_seen_subcommand_from multi; and not __fish_seen_subcommand_from $multi_cmds" -a "kill"
27
- complete -c tfx -n "__fish_seen_subcommand_from multi; and not __fish_seen_subcommand_from $multi_cmds" -a "attach"
28
- complete -c tfx -n "__fish_seen_subcommand_from multi; and not __fish_seen_subcommand_from $multi_cmds" -a "list"
29
-
30
- # Hub subcommands
31
- complete -c tfx -n "__fish_seen_subcommand_from hub; and not __fish_seen_subcommand_from $hub_cmds" -a "start"
32
- complete -c tfx -n "__fish_seen_subcommand_from hub; and not __fish_seen_subcommand_from $hub_cmds" -a "stop"
33
- complete -c tfx -n "__fish_seen_subcommand_from hub; and not __fish_seen_subcommand_from $hub_cmds" -a "status"
34
- complete -c tfx -n "__fish_seen_subcommand_from hub; and not __fish_seen_subcommand_from $hub_cmds" -a "restart"
35
-
36
- # Global or multi flags
37
- set -l flags_cond "__fish_seen_subcommand_from setup multi auto codex gemini"
38
- complete -c tfx -n "$flags_cond" -l thorough -d "Thorough execution"
39
- complete -c tfx -n "$flags_cond" -l quick -d "Quick execution"
40
- complete -c tfx -n "$flags_cond" -l tmux -d "Use tmux"
41
- complete -c tfx -n "$flags_cond" -l psmux -d "Use psmux"
42
- complete -c tfx -n "$flags_cond" -l agents -d "Specify agents"
43
- complete -c tfx -n "$flags_cond" -l no-attach -d "Do not attach"
44
- complete -c tfx -n "$flags_cond" -l timeout -d "Set timeout"
1
+ # Installation: ~/.config/fish/completions/에 복사
2
+ # e.g., cp /path/to/tfx.fish ~/.config/fish/completions/tfx.fish
3
+
4
+ set -l commands setup doctor multi hub auto codex gemini
5
+ set -l multi_cmds status stop kill attach list
6
+ set -l hub_cmds start stop status restart
7
+
8
+ complete -c tfx -f
9
+
10
+ # Subcommands
11
+ complete -c tfx -n "not __fish_seen_subcommand_from $commands" -a "setup" -d "Setup and sync files"
12
+ complete -c tfx -n "not __fish_seen_subcommand_from $commands" -a "doctor" -d "Diagnose CLI and issues"
13
+ complete -c tfx -n "not __fish_seen_subcommand_from $commands" -a "multi" -d "Multi-CLI team mode"
14
+ complete -c tfx -n "not __fish_seen_subcommand_from $commands" -a "hub" -d "MCP message bus management"
15
+ complete -c tfx -n "not __fish_seen_subcommand_from $commands" -a "auto" -d "Auto mode"
16
+ complete -c tfx -n "not __fish_seen_subcommand_from $commands" -a "codex" -d "Codex mode"
17
+ complete -c tfx -n "not __fish_seen_subcommand_from $commands" -a "gemini" -d "Gemini mode"
18
+
19
+ # Doctor flags
20
+ complete -c tfx -n "__fish_seen_subcommand_from doctor" -l fix -d "Auto fix issues"
21
+ complete -c tfx -n "__fish_seen_subcommand_from doctor" -l reset -d "Reset all caches"
22
+
23
+ # Multi subcommands
24
+ complete -c tfx -n "__fish_seen_subcommand_from multi; and not __fish_seen_subcommand_from $multi_cmds" -a "status"
25
+ complete -c tfx -n "__fish_seen_subcommand_from multi; and not __fish_seen_subcommand_from $multi_cmds" -a "stop"
26
+ complete -c tfx -n "__fish_seen_subcommand_from multi; and not __fish_seen_subcommand_from $multi_cmds" -a "kill"
27
+ complete -c tfx -n "__fish_seen_subcommand_from multi; and not __fish_seen_subcommand_from $multi_cmds" -a "attach"
28
+ complete -c tfx -n "__fish_seen_subcommand_from multi; and not __fish_seen_subcommand_from $multi_cmds" -a "list"
29
+
30
+ # Hub subcommands
31
+ complete -c tfx -n "__fish_seen_subcommand_from hub; and not __fish_seen_subcommand_from $hub_cmds" -a "start"
32
+ complete -c tfx -n "__fish_seen_subcommand_from hub; and not __fish_seen_subcommand_from $hub_cmds" -a "stop"
33
+ complete -c tfx -n "__fish_seen_subcommand_from hub; and not __fish_seen_subcommand_from $hub_cmds" -a "status"
34
+ complete -c tfx -n "__fish_seen_subcommand_from hub; and not __fish_seen_subcommand_from $hub_cmds" -a "restart"
35
+
36
+ # Global or multi flags
37
+ set -l flags_cond "__fish_seen_subcommand_from setup multi auto codex gemini"
38
+ complete -c tfx -n "$flags_cond" -l thorough -d "Thorough execution"
39
+ complete -c tfx -n "$flags_cond" -l quick -d "Quick execution"
40
+ complete -c tfx -n "$flags_cond" -l tmux -d "Use tmux"
41
+ complete -c tfx -n "$flags_cond" -l psmux -d "Use psmux"
42
+ complete -c tfx -n "$flags_cond" -l agents -d "Specify agents"
43
+ complete -c tfx -n "$flags_cond" -l no-attach -d "Do not attach"
44
+ complete -c tfx -n "$flags_cond" -l timeout -d "Set timeout"
@@ -1,83 +1,83 @@
1
- #compdef tfx
2
- # Installation: fpath에 추가 후 compinit
3
- # e.g., fpath=(/path/to/dir $fpath) && compinit
4
-
5
- _tfx() {
6
- local line state
7
- local -a commands multi_cmds hub_cmds flags
8
-
9
- commands=(
10
- 'setup:Setup and sync files'
11
- 'doctor:Diagnose CLI and issues'
12
- 'multi:Multi-CLI team mode'
13
- 'hub:MCP message bus management'
14
- 'auto:Auto mode'
15
- 'codex:Codex mode'
16
- 'gemini:Gemini mode'
17
- )
18
-
19
- multi_cmds=(
20
- 'status:Show status'
21
- 'stop:Stop multi'
22
- 'kill:Kill multi'
23
- 'attach:Attach to multi'
24
- 'list:List multi sessions'
25
- )
26
-
27
- hub_cmds=(
28
- 'start:Start hub'
29
- 'stop:Stop hub'
30
- 'status:Show hub status'
31
- 'restart:Restart hub'
32
- )
33
-
34
- _arguments -C \
35
- '1: :->cmds' \
36
- '*: :->args'
37
-
38
- case $state in
39
- cmds)
40
- _describe -t commands 'tfx commands' commands
41
- ;;
42
- args)
43
- case $words[2] in
44
- multi)
45
- if (( CURRENT == 3 )) && [[ $words[CURRENT] != -* ]]; then
46
- _describe -t multi_cmds 'multi commands' multi_cmds
47
- else
48
- _arguments \
49
- '--thorough[Thorough execution]' \
50
- '--quick[Quick execution]' \
51
- '--tmux[Use tmux]' \
52
- '--psmux[Use psmux]' \
53
- '--agents[Specify agents]' \
54
- '--no-attach[Do not attach]' \
55
- '--timeout[Set timeout]'
56
- fi
57
- ;;
58
- hub)
59
- if (( CURRENT == 3 )); then
60
- _describe -t hub_cmds 'hub commands' hub_cmds
61
- fi
62
- ;;
63
- doctor)
64
- _arguments \
65
- '--fix[Auto fix issues]' \
66
- '--reset[Reset all caches]'
67
- ;;
68
- *)
69
- _arguments \
70
- '--thorough[Thorough execution]' \
71
- '--quick[Quick execution]' \
72
- '--tmux[Use tmux]' \
73
- '--psmux[Use psmux]' \
74
- '--agents[Specify agents]' \
75
- '--no-attach[Do not attach]' \
76
- '--timeout[Set timeout]'
77
- ;;
78
- esac
79
- ;;
80
- esac
81
- }
82
-
83
- _tfx "$@"
1
+ #compdef tfx
2
+ # Installation: fpath에 추가 후 compinit
3
+ # e.g., fpath=(/path/to/dir $fpath) && compinit
4
+
5
+ _tfx() {
6
+ local line state
7
+ local -a commands multi_cmds hub_cmds flags
8
+
9
+ commands=(
10
+ 'setup:Setup and sync files'
11
+ 'doctor:Diagnose CLI and issues'
12
+ 'multi:Multi-CLI team mode'
13
+ 'hub:MCP message bus management'
14
+ 'auto:Auto mode'
15
+ 'codex:Codex mode'
16
+ 'gemini:Gemini mode'
17
+ )
18
+
19
+ multi_cmds=(
20
+ 'status:Show status'
21
+ 'stop:Stop multi'
22
+ 'kill:Kill multi'
23
+ 'attach:Attach to multi'
24
+ 'list:List multi sessions'
25
+ )
26
+
27
+ hub_cmds=(
28
+ 'start:Start hub'
29
+ 'stop:Stop hub'
30
+ 'status:Show hub status'
31
+ 'restart:Restart hub'
32
+ )
33
+
34
+ _arguments -C \
35
+ '1: :->cmds' \
36
+ '*: :->args'
37
+
38
+ case $state in
39
+ cmds)
40
+ _describe -t commands 'tfx commands' commands
41
+ ;;
42
+ args)
43
+ case $words[2] in
44
+ multi)
45
+ if (( CURRENT == 3 )) && [[ $words[CURRENT] != -* ]]; then
46
+ _describe -t multi_cmds 'multi commands' multi_cmds
47
+ else
48
+ _arguments \
49
+ '--thorough[Thorough execution]' \
50
+ '--quick[Quick execution]' \
51
+ '--tmux[Use tmux]' \
52
+ '--psmux[Use psmux]' \
53
+ '--agents[Specify agents]' \
54
+ '--no-attach[Do not attach]' \
55
+ '--timeout[Set timeout]'
56
+ fi
57
+ ;;
58
+ hub)
59
+ if (( CURRENT == 3 )); then
60
+ _describe -t hub_cmds 'hub commands' hub_cmds
61
+ fi
62
+ ;;
63
+ doctor)
64
+ _arguments \
65
+ '--fix[Auto fix issues]' \
66
+ '--reset[Reset all caches]'
67
+ ;;
68
+ *)
69
+ _arguments \
70
+ '--thorough[Thorough execution]' \
71
+ '--quick[Quick execution]' \
72
+ '--tmux[Use tmux]' \
73
+ '--psmux[Use psmux]' \
74
+ '--agents[Specify agents]' \
75
+ '--no-attach[Do not attach]' \
76
+ '--timeout[Set timeout]'
77
+ ;;
78
+ esac
79
+ ;;
80
+ esac
81
+ }
82
+
83
+ _tfx "$@"