@yukino.js/yukino 0.0.13-dev → 0.0.14

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 (43) hide show
  1. package/README.md +20 -16
  2. package/dist/{a2a-DG2JNM3U.js → a2a-D7KSHNUT.js} +4 -3
  3. package/dist/{acp-DCZDS6FQ.js → acp-W4R5P6CZ.js} +7 -7
  4. package/dist/{anthropic-5BTWVZVT.js → anthropic-DSNN5AE5.js} +1 -1
  5. package/dist/browser/dist/index.html +44 -0
  6. package/dist/browser/dist/static/index.css +2 -0
  7. package/dist/{fe → browser}/dist/static/index.js +48 -48
  8. package/dist/{chunk-4CLD7LEU.js → chunk-A7CJPQC5.js} +1 -1
  9. package/dist/{chunk-COHBT6M7.js → chunk-D2SZ6GQJ.js} +184 -186
  10. package/dist/{chunk-AZQD75PX.js → chunk-GVRZBATW.js} +1 -1
  11. package/dist/{chunk-OI2W6R6H.js → chunk-HWCLMDQF.js} +8 -8
  12. package/dist/{chunk-BDLFNDC4.js → chunk-I356BFD2.js} +1 -1
  13. package/dist/chunk-JDK4YHNF.js +63 -0
  14. package/dist/{chunk-5URXBVET.js → chunk-OREDGNI6.js} +1 -1
  15. package/dist/chunk-T6WQ3Z5J.js +4 -0
  16. package/dist/{chunk-5DK2M7VI.js → chunk-UUWXDH7J.js} +1 -1
  17. package/dist/{chunk-IWMCIYOG.js → chunk-WKSVBXUO.js} +26 -25
  18. package/dist/{chunk-SZXXASVH.js → chunk-Z3EFT645.js} +1 -1
  19. package/dist/lib/{anthropic-AVZIC22O.js → anthropic-TDNNKQMT.js} +4 -4
  20. package/dist/lib/{chunk-O2H6VKKR.js → chunk-56DL5ZYL.js} +2 -2
  21. package/dist/lib/{chunk-TUNZLQLO.js → chunk-BRLCCEU7.js} +1 -1
  22. package/dist/lib/{chunk-EGJKLA2W.js → chunk-EJNKEFE7.js} +2 -2
  23. package/dist/lib/{chunk-XH7D5FLE.js → chunk-IZXMDC5O.js} +3 -3
  24. package/dist/lib/{chunk-QJ32WYQY.js → chunk-UKXGO7AW.js} +264 -324
  25. package/dist/lib/{chunk-GVI5R2DA.js → chunk-WNGF7243.js} +1 -2
  26. package/dist/lib/{chunk-LSI3T24Q.js → chunk-WXR5HNB4.js} +1 -1
  27. package/dist/lib/index.d.ts +118 -298
  28. package/dist/lib/index.js +472 -1235
  29. package/dist/lib/{openai-54IQOU6Y.js → openai-6VYIA7CT.js} +3 -3
  30. package/dist/lib/{providers-MOCB6Y5L.js → providers-UXL5FVF7.js} +2 -2
  31. package/dist/lib/{tool-filter-5Z6UTRRR.js → tool-filter-O6YLSFAS.js} +3 -3
  32. package/dist/{main-IA22XMQR.js → main-FOIMPIOD.js} +232 -223
  33. package/dist/main.js +11 -2
  34. package/dist/{openai-I2TTMBWK.js → openai-7C6BVQ7M.js} +1 -1
  35. package/dist/{providers-DXQRJUIY.js → providers-TH6MQC7V.js} +1 -1
  36. package/dist/{server-QS7CX37F.js → server-TC5GDF6E.js} +1 -1
  37. package/dist/tool-filter-SYH5ZFC2.js +4 -0
  38. package/package.json +6 -6
  39. package/dist/chunk-CW5XFH7H.js +0 -59
  40. package/dist/chunk-UGX62ZSO.js +0 -4
  41. package/dist/fe/dist/index.html +0 -21
  42. package/dist/fe/dist/static/index.css +0 -2
  43. package/dist/tool-filter-KDQMXIDC.js +0 -4
@@ -2,7 +2,7 @@ import {
2
2
  MCP_TOOL_PREFIX,
3
3
  McpCallTool,
4
4
  mcpCallPermissionContent
5
- } from "./chunk-LSI3T24Q.js";
5
+ } from "./chunk-WXR5HNB4.js";
6
6
  import {
7
7
  asErrorString,
8
8
  asRecord,
@@ -17,7 +17,7 @@ import {
17
17
  sessionPath,
18
18
  strArg,
19
19
  yukinoPath
20
- } from "./chunk-GVI5R2DA.js";
20
+ } from "./chunk-WNGF7243.js";
21
21
  import {
22
22
  __export,
23
23
  canonicalPath,
@@ -117,7 +117,7 @@ var YamlFrontmatterSchema = z.looseObject({
117
117
  system_prompt: z.string().optional(),
118
118
  max_turns: z.number().int().positive().optional(),
119
119
  model: z.string().optional(),
120
- permission_mode: z.literal("plan").optional(),
120
+ permission_mode: z.enum(["default", "acceptEdits", "plan", "bypassPermissions"]).optional(),
121
121
  background: z.boolean().optional(),
122
122
  isolation: z.literal("worktree").optional()
123
123
  });
@@ -616,7 +616,6 @@ __export(protocol_exports, {
616
616
  MSG_TEXT: () => MSG_TEXT,
617
617
  SHUTDOWN_PREFIX: () => SHUTDOWN_PREFIX,
618
618
  TEAMMATE_COORDINATION_TOOLS: () => TEAMMATE_COORDINATION_TOOLS,
619
- approved: () => approved,
620
619
  isShutdownRequest: () => isShutdownRequest,
621
620
  isValidTeammateName: () => isValidTeammateName,
622
621
  newRequestId: () => newRequestId,
@@ -672,8 +671,8 @@ function shutdownResponse(from, requestId, approve, reason = "") {
672
671
  function planApprovalRequest(from, plan) {
673
672
  return typed(from, MSG_PLAN_APPROVAL_REQUEST, newRequestId(), plan);
674
673
  }
675
- function planApprovalResponse(from, requestId, approve, feedback = "") {
676
- return typed(from, MSG_PLAN_APPROVAL_RESPONSE, requestId, feedback, approve);
674
+ function planApprovalResponse(from, requestId, feedback = "") {
675
+ return typed(from, MSG_PLAN_APPROVAL_RESPONSE, requestId, feedback, true);
677
676
  }
678
677
  function isShutdownRequest(m) {
679
678
  if (m.type === MSG_SHUTDOWN_REQUEST) {
@@ -681,16 +680,13 @@ function isShutdownRequest(m) {
681
680
  }
682
681
  return (m.text ?? "").trim().startsWith(SHUTDOWN_PREFIX);
683
682
  }
684
- function approved(m) {
685
- return m.approve === true;
686
- }
687
683
 
688
684
  // src/permissions/request.ts
689
685
  var request_exports = {};
690
686
  __export(request_exports, {
691
687
  requestToolPermission: () => requestToolPermission
692
688
  });
693
- async function requestToolPermission(handler, toolName, args, decision, toolCallId, signal) {
689
+ async function requestToolPermission(handler, toolName, args, decision, toolCallId, signal, source) {
694
690
  if (signal?.aborted) {
695
691
  return "deny";
696
692
  }
@@ -703,7 +699,7 @@ async function requestToolPermission(handler, toolName, args, decision, toolCall
703
699
  });
704
700
  try {
705
701
  return await Promise.race([
706
- handler(toolName, args, decision, toolCallId, signal),
702
+ handler(toolName, args, decision, toolCallId, signal, source),
707
703
  cancelled
708
704
  ]);
709
705
  } finally {
@@ -715,188 +711,94 @@ async function requestToolPermission(handler, toolName, args, decision, toolCall
715
711
  var log3 = createChildLogger({ module: "permissions" });
716
712
  var DANGEROUS_PATTERNS = [];
717
713
  var SAFE_PREFIXES = [
718
- "basename",
719
- "cat",
720
- "cksum",
721
- "cmp",
722
- "column",
723
- "comm",
724
- "cut",
725
- "df",
726
- "dirname",
727
- "du",
728
714
  "echo",
729
- "expr",
730
- "false",
731
- "fold",
732
- "fmt",
715
+ // Output only, no dangerous flags
716
+ "printf",
717
+ // xargs runs /usr/bin/printf (binary), not bash builtin — no -v support
718
+ "wc",
719
+ // Read-only counting, no dangerous flags
733
720
  "grep",
734
- "groups",
721
+ // Read-only search, no dangerous flags
735
722
  "head",
736
- "id",
737
- "jq",
738
- "locate",
739
- "ls",
740
- "md5",
741
- "md5sum",
742
- "nl",
743
- "od",
744
- "paste",
745
- "pgrep",
746
- "printenv",
747
- "printf",
748
- "ps",
749
- "pwd",
750
- "readlink",
751
- "realpath",
752
- "sha1sum",
753
- "sha224sum",
754
- "sha256sum",
755
- "sha384sum",
756
- "sha512sum",
757
- "shasum",
758
- "stat",
759
- "strings",
760
- "tac",
723
+ // Read-only, no dangerous flags
761
724
  "tail",
762
- "tr",
763
- "true",
764
- "tty",
765
- "type",
766
- "uname",
725
+ // Read-only (including -f follow), no dangerous flags
726
+ // Cross-platform commands from shared validation
727
+ /docker\s+(?:ps|images)\b/,
728
+ // Unix/bash-specific read-only commands (not shared because they don't exist in PowerShell)
729
+ // Time and date
730
+ "cal",
767
731
  "uptime",
768
- "w",
732
+ // File content viewing (relative paths handled separately)
733
+ "cat",
734
+ "head",
735
+ "tail",
769
736
  "wc",
770
- "whereis",
771
- "which",
772
- "who",
773
- "whoami",
774
- "ack",
775
- "ag",
776
- "alias",
777
- "arch",
778
- "base64",
779
- "bat",
780
- "bzcat",
781
- "cal",
782
- "col",
783
- "cloc",
784
- "diff",
785
- "diff3",
786
- "dig",
787
- "dmesg",
788
- "expand",
789
- "factor",
790
- "free",
791
- "help",
737
+ "stat",
738
+ "strings",
792
739
  "hexdump",
793
- "host",
794
- "iconv",
795
- "info",
740
+ "od",
741
+ "nl",
742
+ // System info
743
+ "id",
744
+ "uname",
745
+ "free",
746
+ "df",
747
+ "du",
796
748
  "locale",
797
- "lscpu",
798
- "lsblk",
799
- "lsof",
800
- "lspci",
801
- "lsusb",
802
- "man",
803
- "mdfind",
804
- "mdls",
805
- "ncal",
806
- "netstat",
749
+ "groups",
807
750
  "nproc",
808
- "nslookup",
809
- "objdump",
810
- "otool",
811
- "pbpaste",
812
- "ping",
813
- "readelf",
751
+ // Path information
752
+ "basename",
753
+ "dirname",
754
+ "realpath",
755
+ // Text processing
756
+ "cut",
757
+ "paste",
758
+ "tr",
759
+ "column",
760
+ "tac",
761
+ // Reverse cat — displays file contents in reverse line order
814
762
  "rev",
815
- "sdiff",
816
- "seq",
817
- "sum",
818
- "sw_vers",
819
- "tldr",
820
- "traceroute",
763
+ // Reverse characters in each line
764
+ "fold",
765
+ // Wrap lines to specified width
766
+ "expand",
767
+ // Convert tabs to spaces
821
768
  "unexpand",
822
- "vm_stat",
823
- "whois",
824
- "xxd",
825
- "xzcat",
826
- "zcat",
827
- "zgrep",
828
- "zipinfo",
829
- /^command\s+(?:-v|-V)\s+\S+(?:\s+\S+)*$/,
830
- /^date(?!.*\s(?:-s|--set)(?:=|\s|$))(?:\s.*)?$/,
831
- /^file(?!.*(?:\s--compile(?:=|\s|$)|\s-[^-\s]*C))(?:\s.*)?$/,
832
- /^find(?!.*\s(?:-delete|-exec(?:dir)?|-ok(?:dir)?|-fls|-fprint(?:0)?|-fprintf)(?:\s|$))(?:\s.*)?$/,
833
- /^fd(?!.*\s(?:-x|-X|--exec|--exec-batch)(?:=|\s|$))(?:\s.*)?$/,
834
- /^hostname(?:\s+(?:-[adfFiIsyVh]|--(?:alias|all-fqdns|all-ip-addresses|domain|fqdn|help|ip-address|long|nis|short|version|yp)))*$/,
835
- /^rg(?!.*\s(?:--pre|--pre-glob|--hostname-bin)(?:=|\s|$))(?:\s.*)?$/,
836
- /^sort(?!.*\s(?:-o|--output|--compress-program)(?:=|\s|$))(?:\s.*)?$/,
837
- /^ss(?!.*\s(?:--kill|-[^-\s]*K)(?:\s|$))(?:\s.*)?$/,
838
- /^tree(?!.*\s(?:-o|--output)(?:=|\s|$))(?:\s.*)?$/,
839
- /^git\s+(?:--version|version)$/,
840
- /^git\s+(?:blame|cat-file|count-objects|describe|for-each-ref|ls-files|ls-tree|merge-base|name-rev|rev-parse|shortlog|show-ref|status|verify-pack)(?:\s.*)?$/,
841
- /^git\s+(?:diff|log|show)(?!.*\s(?:--ext-diff|--output)(?:=|\s|$))(?:\s.*)?$/,
842
- /^git\s+branch$/,
843
- /^git\s+branch(?=.*\s(?:-a|--all|-r|--remotes|--list|--show-current|--contains|--no-contains|--merged|--no-merged)(?:=|\s|$))(?!.*\s(?:-[dDmMcCf]|--(?:copy|create-reflog|delete|edit-description|move|set-upstream-to|unset-upstream))(?:=|\s|$))(?:\s.*)?$/,
844
- /^git\s+config(?:\s+(?:--blob(?:=|\s)\S+|--file(?:=|\s)\S+|--fixed-value|--global|--local|--null|--show-names|--show-origin|--show-scope|--system|--worktree|-z))*\s+(?:--get|--get-all|--get-regexp|--get-urlmatch|--list|-l)(?:\s.*)?$/,
845
- /^git\s+notes\s+(?:list|show)(?:\s.*)?$/,
846
- /^git\s+reflog\s+show(?:\s.*)?$/,
847
- /^git\s+remote(?:\s+-v)?$/,
848
- /^git\s+remote\s+get-url(?:\s+(?:--all|--push))*\s+\S+$/,
849
- /^git\s+remote\s+show(?:\s+-n)?(?:\s+\S+)?$/,
850
- /^git\s+stash\s+(?:list|show)(?:\s.*)?$/,
851
- /^git\s+submodule\s+(?:status|summary)(?:\s.*)?$/,
852
- /^git\s+tag(?:\s+(?:-l|--list)(?:\s.*)?)?$/,
853
- /^git\s+worktree\s+list(?:\s.*)?$/,
854
- /^(?:bun|npm|pnpm|yarn)\s+(?:explain|help|info|list|ls|outdated|prefix|query|root|search|show|view|why)(?:\s.*)?$/,
855
- /^(?:npm|pnpm|yarn)\s+config\s+(?:get|list)(?:\s.*)?$/,
856
- /^npm\s+pkg\s+get(?:\s.*)?$/,
857
- /^bun\s+pm\s+ls(?:\s.*)?$/,
858
- /^(?:bun|cargo|clang|cmake|composer|deno|gcc|gem|node|npm|php|pip|pip3|pnpm|python|python3|ruby|rustc|swift|yarn)\s+(?:--version|-V)$/,
859
- /^(?:go|helm|kubectl|podman|terraform)\s+version(?:\s.*)?$/,
860
- /^(?:java|javac)\s+-version$/,
861
- /^dotnet\s+(?:--info|--list-runtimes|--list-sdks|--version)$/,
862
- /^(?:docker|podman)\s+(?:diff|events|images|info|inspect|logs|port|ps|stats|top|version)(?:\s.*)?$/,
863
- /^(?:docker|podman)\s+(?:container|image|network|volume)\s+(?:inspect|ls)(?:\s.*)?$/,
864
- /^docker\s+compose\s+(?:config|images|logs|ps|top|version)(?:\s.*)?$/,
865
- /^kubectl\s+(?:api-resources|api-versions|cluster-info|describe|explain|get|logs|top|version)(?:\s.*)?$/,
866
- /^kubectl\s+config\s+(?:current-context|get-contexts|view)(?:\s.*)?$/,
867
- /^helm\s+(?:env|get|history|list|search|show|status|version)(?:\s.*)?$/,
868
- /^terraform\s+(?:output|providers|show|version)(?:\s.*)?$/,
869
- /^terraform\s+workspace\s+(?:list|show)(?:\s.*)?$/,
870
- /^systemctl\s+(?:is-active|is-enabled|is-failed|list-dependencies|list-jobs|list-sockets|list-timers|list-unit-files|list-units|show|show-environment|status)(?:\s.*)?$/,
871
- /^launchctl\s+(?:error|hostinfo|list|managername|managerpid|manageruid|print|print-cache|procinfo|variant|version)(?:\s.*)?$/,
872
- /^journalctl(?!.*\s--(?:rotate|vacuum|flush|sync))(?:\s.*)?$/,
873
- /^defaults\s+read(?:\s.*)?$/,
874
- /^ifconfig$/,
875
- /^ipconfig(?:\s+\/(?:all|allcompartments|displaydns))?\s*$/,
876
- /^ip\s+(?:addr(?:ess)?|route)$/,
877
- /^ip\s+(?:addr(?:ess)?|link|route|neigh(?:bor)?)\s+(?:show|list)\b(?:\s.*)?$/,
878
- /^tar\s+(?:--list\b|-[a-zA-Z]*t[a-zA-Z]*)(?:\s.*)?$/,
879
- /^unzip\s+-[a-zA-Z]*l(?:\s.*)?$/,
880
- /^git\s+(?:grep|fsck|rev-list|whatchanged|help|diff-tree|diff-index|diff-files|ls-remote|verify-tag|verify-commit)(?:\s.*)?$/,
881
- /^git\s+archive(?!.*\s(?:-o|--output)(?:=|\s|$))(?:\s.*)?$/,
882
- /^svn\s+(?:status|stat|st|diff|di|log|info|list|ls|cat|blame|ann|annotate|proplist|propget|pg)(?:\s.*)?$/,
883
- /^hg\s+(?:status|st|log|diff|summary|id|identify|branches|tags|manifest|cat|files|locate|heads|tip|parents|paths|root)(?:\s.*)?$/,
884
- /^cargo\s+(?:tree|search|locate-project|verify-project|config\s+get)(?:\s.*)?$/,
885
- /^gem\s+(?:list|search|info|env|dependency|contents|specification|sources\s+(?:-l|--list))(?:\s.*)?$/,
886
- /^brew\s+(?:--version|-v|list|info|search|outdated|deps|uses|config|leaves|doctor)(?:\s.*)?$/,
887
- /^choco\s+(?:--version|list|info|search|outdated)(?:\s.*)?$/,
888
- /^apt(?:-get)?\s+list(?:\s.*)?$/,
889
- /^apt-cache\s+(?:search|show|showpkg|policy|depends|rdepends|pkgnames)(?:\s.*)?$/,
890
- /^dpkg\s+(?:-l|-L|-s|-S|--list|--listfiles|--status|--search)\b(?:\s.*)?$/,
891
- /^rpm\s+-q[a-zA-Z]*(?:\s.*)?$/,
892
- /^(?:aws|gh|gcloud|az)\s+--version$/,
893
- /^aws\s+(?:\S+\s+)?(?:describe|list|get|wait)-\S+(?:\s.*)?$/,
894
- /^aws\s+s3\s+ls(?:\s.*)?$/,
895
- /^gcloud\s+\S+(?:\s+\S+)*\s+(?:list|describe)(?:\s.*)?$/,
896
- /^az\s+\S+(?:\s+\S+)*\s+(?:list|show)(?:\s.*)?$/,
897
- /^gh\s+(?:pr|issue|repo|run|release|gist)\s+(?:view|list|status|checks|diff)(?:\s.*)?$/,
898
- /^(?:docker|podman)\s+(?:system\s+(?:df|info)|history|context\s+(?:ls|list|show|inspect))(?:\s.*)?$/,
899
- /^(?:Get-(?:Acl|Alias|AuthenticodeSignature|ChildItem|CimInstance|Clipboard|Command|ComputerInfo|Content|Counter|Culture|Date|DnsClientCache|EventLog|ExecutionPolicy|FileHash|Help|History|Host|HotFix|Item|ItemProperty|Location|Member|Module|NetAdapter|NetIPAddress|NetNeighbor|NetIPConfiguration|NetRoute|NetTCPConnection|NetUDPEndpoint|Package|PackageProvider|PnpDevice|Printer|Process|PSDrive|PSProvider|PSRepository|PSSnapin|ScheduledTask|Service|TimeZone|UICulture|Variable|Verb|WinEvent|WmiObject)|Compare-Object|Format-(?:Custom|Hex|List|Table|Wide)|Group-Object|Measure-Object|Out-String|Resolve-Path|Select-Object|Select-String|Sort-Object|Test-Path|Where-Object|Write-(?:Debug|Error|Host|Information|Output|Progress|Verbose|Warning))(?:\s.*)?$/i
769
+ // Convert spaces to tabs
770
+ "fmt",
771
+ // Simple text formatter — output to stdout only
772
+ "comm",
773
+ // Compare sorted files line by line
774
+ "cmp",
775
+ // Byte-by-byte file comparison
776
+ "numfmt",
777
+ // Number format conversion
778
+ // Path information (additional)
779
+ "readlink",
780
+ // Resolve symlinks — displays target of symbolic link
781
+ // File comparison
782
+ "diff",
783
+ // true and false, used to silence or create errors
784
+ "true",
785
+ "false",
786
+ // Misc. safe commands
787
+ "sleep",
788
+ "which",
789
+ "type",
790
+ "expr",
791
+ // Evaluate expressions (arithmetic, string matching)
792
+ "test",
793
+ // Conditional evaluation (file checks, comparisons)
794
+ "getconf",
795
+ // Get system configuration values
796
+ "seq",
797
+ // Generate number sequences
798
+ "tsort",
799
+ // Topological sort
800
+ "pr"
801
+ // Paginate files for printing
900
802
  ];
901
803
  var CONTENT_FIELDS = {
902
804
  Bash: "command",
@@ -913,6 +815,17 @@ var CONTENT_FIELDS = {
913
815
  Grep: "pattern",
914
816
  InstallSkill: "source"
915
817
  };
818
+ var PLAN_COORDINATION_TOOLS = /* @__PURE__ */ new Set([
819
+ "AskUserQuestion",
820
+ "ExitPlanMode",
821
+ "Agent",
822
+ "Goal",
823
+ "TodoWrite",
824
+ "TaskStop",
825
+ "TeamCreate",
826
+ "TeamDelete",
827
+ ...TEAMMATE_COORDINATION_TOOLS
828
+ ]);
916
829
  function extractContent(toolName, args) {
917
830
  if (toolName === "McpCall") {
918
831
  return mcpCallPermissionContent(
@@ -1111,7 +1024,7 @@ function modeDecide(mode, category) {
1111
1024
  case "bypassPermissions":
1112
1025
  return "allow";
1113
1026
  case "plan":
1114
- return category === "read" ? "allow" : "ask";
1027
+ return category === "read" ? "allow" : "deny";
1115
1028
  case "acceptEdits":
1116
1029
  return category === "command" ? "ask" : "allow";
1117
1030
  case "default":
@@ -1120,12 +1033,10 @@ function modeDecide(mode, category) {
1120
1033
  }
1121
1034
  }
1122
1035
  var PermissionChecker = class _PermissionChecker {
1123
- constructor(cwd, mode = "default", modeSource) {
1036
+ constructor(cwd, mode = "default") {
1124
1037
  this.cwd = cwd;
1125
1038
  this.modeState = {
1126
1039
  value: mode,
1127
- delegatedValue: mode === "plan" ? "default" : mode,
1128
- source: modeSource,
1129
1040
  listeners: /* @__PURE__ */ new Set()
1130
1041
  };
1131
1042
  this.sandbox = new PathSandbox(cwd);
@@ -1133,12 +1044,8 @@ var PermissionChecker = class _PermissionChecker {
1133
1044
  }
1134
1045
  cwd;
1135
1046
  modeState;
1136
- delegated = false;
1137
- planModeLocked = false;
1047
+ parent;
1138
1048
  planFilePath = "";
1139
- // Set for teammate checkers: unattended agents have no approval channel, so
1140
- // team-internal coordination tools (messaging, shared task board) are allowed
1141
- // outright instead of falling through to an auto-denied "ask".
1142
1049
  teammate = false;
1143
1050
  // Sandbox mode: when enabled, Bash commands run through OS sandbox isolation, with optional auto-allow
1144
1051
  sandboxEnabled = false;
@@ -1146,25 +1053,25 @@ var PermissionChecker = class _PermissionChecker {
1146
1053
  sandbox;
1147
1054
  ruleEngine;
1148
1055
  get mode() {
1149
- return this.planModeLocked ? "plan" : this.delegated ? this.delegatedMode : this.modeState.source?.() ?? this.modeState.value;
1056
+ if (!this.parent) {
1057
+ return this.modeState.value ?? "default";
1058
+ }
1059
+ const parentMode = this.parent.mode;
1060
+ if (parentMode === "acceptEdits" || parentMode === "bypassPermissions") {
1061
+ return parentMode;
1062
+ }
1063
+ const mode = this.modeState.value;
1064
+ return mode === "bypassPermissions" ? parentMode : mode ?? parentMode;
1150
1065
  }
1151
1066
  set mode(mode) {
1152
- if (this.modeState.value === mode && !this.modeState.source) {
1067
+ if (this.modeState.value === mode) {
1153
1068
  return;
1154
1069
  }
1155
1070
  this.modeState.value = mode;
1156
- if (mode !== "plan") {
1157
- this.modeState.delegatedValue = mode;
1158
- }
1159
- this.modeState.source = void 0;
1160
1071
  for (const listener of this.modeState.listeners) {
1161
1072
  listener();
1162
1073
  }
1163
1074
  }
1164
- get delegatedMode() {
1165
- const mode = this.modeState.source?.();
1166
- return mode && mode !== "plan" ? mode : this.modeState.delegatedValue;
1167
- }
1168
1075
  subscribeMode(listener) {
1169
1076
  this.modeState.listeners.add(listener);
1170
1077
  return () => {
@@ -1174,8 +1081,7 @@ var PermissionChecker = class _PermissionChecker {
1174
1081
  forCwd(cwd) {
1175
1082
  const checker = new _PermissionChecker(cwd, this.mode);
1176
1083
  checker.modeState = this.modeState;
1177
- checker.delegated = this.delegated;
1178
- checker.planModeLocked = this.planModeLocked;
1084
+ checker.parent = this.parent;
1179
1085
  checker.planFilePath = this.planFilePath;
1180
1086
  checker.ruleEngine = this.ruleEngine;
1181
1087
  checker.teammate = this.teammate;
@@ -1183,9 +1089,10 @@ var PermissionChecker = class _PermissionChecker {
1183
1089
  checker.sandboxAutoAllow = this.sandboxAutoAllow;
1184
1090
  return checker;
1185
1091
  }
1186
- forSubagent(cwd) {
1092
+ forSubagent(cwd, mode) {
1187
1093
  const checker = this.forCwd(cwd);
1188
- checker.delegated = true;
1094
+ checker.parent = this;
1095
+ checker.modeState = { value: mode, listeners: this.modeState.listeners };
1189
1096
  if (!this.teammate) {
1190
1097
  checker.planFilePath = "";
1191
1098
  }
@@ -1195,11 +1102,12 @@ var PermissionChecker = class _PermissionChecker {
1195
1102
  const content = extractContent(toolName, args);
1196
1103
  const coordination = this.teammate && TEAMMATE_COORDINATION_TOOLS.has(toolName);
1197
1104
  const filePath = strArg(args, "file_path", strArg(args, "path", ""));
1105
+ const planControl = this.mode === "plan" && PLAN_COORDINATION_TOOLS.has(toolName);
1198
1106
  const planFileWrite = this.mode === "plan" && (toolName === "WriteFile" || toolName === "EditFile") && !!this.planFilePath && canonicalPath(resolveToolPath(this.cwd, filePath)) === canonicalPath(resolveToolPath(this.cwd, this.planFilePath));
1199
- if (this.planModeLocked && category !== "read" && !coordination && !planFileWrite && !(category === "command" && isSafeCommand(content))) {
1107
+ if (this.mode === "plan" && category !== "read" && !coordination && !planControl && !planFileWrite && !(category === "command" && isSafeCommand(content))) {
1200
1108
  return {
1201
1109
  effect: "deny",
1202
- reason: "Plan approval is required before executing mutations"
1110
+ reason: "Plan mode forbids mutations"
1203
1111
  };
1204
1112
  }
1205
1113
  let snapshot = null;
@@ -1211,6 +1119,9 @@ var PermissionChecker = class _PermissionChecker {
1211
1119
  reason: `Permission rule: ${explicitEffect}`
1212
1120
  };
1213
1121
  }
1122
+ if (planControl) {
1123
+ return { effect: "allow", reason: "Plan coordination tool" };
1124
+ }
1214
1125
  if (coordination) {
1215
1126
  return { effect: "allow", reason: "Teammate coordination tool" };
1216
1127
  }
@@ -1335,7 +1246,8 @@ __export(task_tools_exports, {
1335
1246
  TeamTaskGetTool: () => TeamTaskGetTool,
1336
1247
  TeamTaskListTool: () => TeamTaskListTool,
1337
1248
  TeamTaskUpdateTool: () => TeamTaskUpdateTool,
1338
- registerLeaderTaskTools: () => registerLeaderTaskTools
1249
+ registerLeaderTaskTools: () => registerLeaderTaskTools,
1250
+ subscribeLeaderTasks: () => subscribeLeaderTasks
1339
1251
  });
1340
1252
 
1341
1253
  // src/todo/tools.ts
@@ -1418,6 +1330,20 @@ function validateTaskDependencies(nodes) {
1418
1330
  }
1419
1331
  }
1420
1332
 
1333
+ // src/todo/progress.ts
1334
+ var progress_exports = {};
1335
+ __export(progress_exports, {
1336
+ taskProgress: () => taskProgress
1337
+ });
1338
+ function taskProgress(tasks) {
1339
+ const completed = tasks.filter((task) => task.status === "completed").length;
1340
+ return {
1341
+ completed,
1342
+ total: tasks.length,
1343
+ label: `TODO ${completed}/${tasks.length}`
1344
+ };
1345
+ }
1346
+
1421
1347
  // src/todo/store.ts
1422
1348
  var store_exports = {};
1423
1349
  __export(store_exports, {
@@ -1551,7 +1477,8 @@ var TaskCreateTool = class _TaskCreateTool {
1551
1477
  ctx.abortSignal?.throwIfAborted();
1552
1478
  const task = this.list.create(subject, description, activeForm, metadata);
1553
1479
  return Promise.resolve({
1554
- output: `Task #${task.id} created successfully: ${task.subject}`,
1480
+ output: `Task #${task.id} created successfully: ${task.subject}
1481
+ ${taskProgress(this.list.list()).label}`,
1555
1482
  isError: false
1556
1483
  });
1557
1484
  } catch (error) {
@@ -1634,13 +1561,20 @@ var TaskListTool = class _TaskListTool {
1634
1561
  });
1635
1562
  }
1636
1563
  if (tasks.length === 0) {
1637
- return Promise.resolve({ output: "No tasks found", isError: false });
1564
+ return Promise.resolve({
1565
+ output: `No tasks found
1566
+ ${taskProgress(tasks).label}`,
1567
+ isError: false
1568
+ });
1638
1569
  }
1639
1570
  const lines = tasks.map((t) => {
1640
1571
  const blockers = unresolvedTaskDependencies(t, tasks);
1641
1572
  return `#${t.id}. [${t.status}] ${t.subject}${t.owner ? ` (${t.owner})` : ""}${blockers.length ? ` (blocked by: ${blockers.join(", ")})` : ""}`;
1642
1573
  });
1643
- return Promise.resolve({ output: lines.join("\n"), isError: false });
1574
+ return Promise.resolve({
1575
+ output: [taskProgress(tasks).label, ...lines].join("\n"),
1576
+ isError: false
1577
+ });
1644
1578
  }
1645
1579
  forList(list) {
1646
1580
  return new _TaskListTool(list);
@@ -1711,7 +1645,11 @@ var TaskUpdateTool = class _TaskUpdateTool {
1711
1645
  ctx.abortSignal?.throwIfAborted();
1712
1646
  if (status === "deleted") {
1713
1647
  return Promise.resolve(
1714
- this.list.delete(taskId) ? { output: `Task #${taskId} deleted`, isError: false } : { output: "Task not found", isError: true }
1648
+ this.list.delete(taskId) ? {
1649
+ output: `Task #${taskId} deleted
1650
+ ${taskProgress(this.list.list()).label}`,
1651
+ isError: false
1652
+ } : { output: "Task not found", isError: true }
1715
1653
  );
1716
1654
  }
1717
1655
  const task = this.list.update(taskId, {
@@ -1722,7 +1660,8 @@ var TaskUpdateTool = class _TaskUpdateTool {
1722
1660
  });
1723
1661
  return Promise.resolve(
1724
1662
  task ? {
1725
- output: `Updated task #${taskId}: ${task.status}${task.owner ? ` (owner: ${task.owner})` : ""}.${status === "completed" ? " Call TaskList to find the next available task; verify the completed work before reporting success." : ""}`,
1663
+ output: `Updated task #${taskId}: ${task.status}${task.owner ? ` (owner: ${task.owner})` : ""}.${status === "completed" ? " Call TaskList to find the next available task; verify the completed work before reporting success." : ""}
1664
+ ${taskProgress(this.list.list()).label}`,
1726
1665
  isError: false
1727
1666
  } : { output: "Task not found", isError: true }
1728
1667
  );
@@ -1755,7 +1694,7 @@ var TodoWriteTool = class _TodoWriteTool {
1755
1694
  }
1756
1695
  list;
1757
1696
  name = "TodoWrite";
1758
- description = "Replace this agent's entire task/TODO list in one atomic update. Include all items to retain; reuse returned IDs to preserve metadata and dependency links. An empty array clears the list. Track complex work, not trivial requests; this tool never launches work.";
1697
+ description = "Replace this agent's entire private TODO list in one atomic update. Include all items to retain; reuse returned IDs to preserve metadata and dependency links. Returns todos with IDs and TODO completed/total progress. An empty array clears the list; completing all items retains them. Track complex work, not trivial requests; this tool never launches work.";
1759
1698
  category = "read";
1760
1699
  isConcurrencySafe() {
1761
1700
  return false;
@@ -1800,7 +1739,7 @@ var TodoWriteTool = class _TodoWriteTool {
1800
1739
  const parsed = z5.object({
1801
1740
  todos: z5.array(
1802
1741
  z5.object({
1803
- id: z5.string().min(1).optional(),
1742
+ id: z5.string().trim().min(1).optional(),
1804
1743
  subject: z5.string().trim().min(1),
1805
1744
  description: z5.string().optional(),
1806
1745
  status: StoredTaskStatusSchema,
@@ -1814,8 +1753,13 @@ var TodoWriteTool = class _TodoWriteTool {
1814
1753
  }
1815
1754
  try {
1816
1755
  ctx.abortSignal?.throwIfAborted();
1756
+ const todos = this.list.replace(parsed.data.todos);
1817
1757
  return Promise.resolve({
1818
- output: JSON.stringify(this.list.replace(parsed.data.todos), null, 2),
1758
+ output: JSON.stringify(
1759
+ { todos, progress: taskProgress(todos).label },
1760
+ null,
1761
+ 2
1762
+ ),
1819
1763
  isError: false
1820
1764
  });
1821
1765
  } catch (error) {
@@ -1927,19 +1871,72 @@ var TeamTaskUpdateTool = class extends TaskUpdateTool {
1927
1871
  super(new TeamTaskBoard(manager, teamName, agentName, fallback));
1928
1872
  }
1929
1873
  };
1930
- function registerLeaderTaskTools(registry, manager, fallback) {
1931
- registry.register(
1932
- new TeamTaskCreateTool(manager, void 0, LEADER_NAME, fallback)
1933
- );
1934
- registry.register(
1935
- new TeamTaskGetTool(manager, void 0, LEADER_NAME, fallback)
1936
- );
1937
- registry.register(
1938
- new TeamTaskListTool(manager, void 0, LEADER_NAME, fallback)
1939
- );
1940
- registry.register(
1874
+ function registerLeaderTaskTools(registry, manager, fallback, mode) {
1875
+ const tools = [
1876
+ new TeamTaskCreateTool(manager, void 0, LEADER_NAME, fallback),
1877
+ new TeamTaskGetTool(manager, void 0, LEADER_NAME, fallback),
1878
+ new TeamTaskListTool(manager, void 0, LEADER_NAME, fallback),
1941
1879
  new TeamTaskUpdateTool(manager, void 0, LEADER_NAME, fallback)
1942
- );
1880
+ ];
1881
+ const todo = new TodoWriteTool(fallback);
1882
+ let currentMode;
1883
+ const sync = () => {
1884
+ const nextMode = mode === "tasks" || manager.list().length ? "tasks" : "todos";
1885
+ if (nextMode === currentMode) {
1886
+ return;
1887
+ }
1888
+ currentMode = nextMode;
1889
+ if (nextMode === "tasks") {
1890
+ registry.unregister(todo.name);
1891
+ for (const tool of tools) {
1892
+ registry.register(tool);
1893
+ }
1894
+ } else {
1895
+ for (const tool of tools) {
1896
+ registry.unregister(tool.name);
1897
+ }
1898
+ registry.register(todo);
1899
+ }
1900
+ };
1901
+ registry.addCleanup(manager.subscribe(sync));
1902
+ sync();
1903
+ }
1904
+ function subscribeLeaderTasks(manager, fallback, listener) {
1905
+ let team;
1906
+ let unsubscribeStore;
1907
+ let signature = "";
1908
+ let generation = 0;
1909
+ let disposed = false;
1910
+ const refresh = () => {
1911
+ if (disposed) {
1912
+ return;
1913
+ }
1914
+ const nextTeam = manager.list()[0];
1915
+ if (nextTeam !== team) {
1916
+ unsubscribeStore?.();
1917
+ team = nextTeam;
1918
+ generation++;
1919
+ unsubscribeStore = team ? manager.getTaskStore(team.name).subscribe(refresh) : void 0;
1920
+ }
1921
+ const tasks = team ? manager.getTaskStore(team.name).listTasks() : fallback.list();
1922
+ const boardId = `${team ? `team:${team.name}` : "private"}:${generation}`;
1923
+ const nextSignature = JSON.stringify([boardId, tasks]);
1924
+ if (signature !== nextSignature) {
1925
+ signature = nextSignature;
1926
+ listener(tasks, boardId);
1927
+ }
1928
+ };
1929
+ const unsubscribePrivate = fallback.subscribe(refresh);
1930
+ const unsubscribeTeams = manager.subscribe(refresh);
1931
+ const timer = setInterval(refresh, 500);
1932
+ timer.unref();
1933
+ return () => {
1934
+ disposed = true;
1935
+ clearInterval(timer);
1936
+ unsubscribeStore?.();
1937
+ unsubscribePrivate();
1938
+ unsubscribeTeams();
1939
+ };
1943
1940
  }
1944
1941
 
1945
1942
  // src/teams/tools.ts
@@ -1999,7 +1996,6 @@ __export(team_file_exports, {
1999
1996
  listTeamNames: () => listTeamNames,
2000
1997
  readTeamFile: () => readTeamFile,
2001
1998
  readTeamFileAtPath: () => readTeamFileAtPath,
2002
- registerTeammateProcess: () => registerTeammateProcess,
2003
1999
  sanitizeTeamName: () => sanitizeTeamName,
2004
2000
  teamConfigPath: () => teamConfigPath,
2005
2001
  teamDir: () => teamDir,
@@ -2025,14 +2021,10 @@ var TeamMemberEntrySchema = z6.object({
2025
2021
  model: z6.string().optional(),
2026
2022
  joinedAt: z6.number(),
2027
2023
  worktreePath: z6.string().optional(),
2028
- backendType: z6.enum(["in-process", "tmux", "iterm"]),
2029
- paneId: z6.string().optional(),
2030
- workerPid: z6.number().int().positive().optional(),
2031
2024
  isActive: z6.boolean()
2032
2025
  });
2033
2026
  var TeamFileSchema = z6.object({
2034
2027
  name: z6.string(),
2035
- mode: z6.enum(["in-process", "tmux", "iterm"]),
2036
2028
  description: z6.string().optional(),
2037
2029
  createdAt: z6.number(),
2038
2030
  leaderAgentId: z6.string(),
@@ -2042,8 +2034,6 @@ var TeamFileSchema = z6.object({
2042
2034
  "plan",
2043
2035
  "bypassPermissions"
2044
2036
  ]),
2045
- /** PID of the process currently acting as leader; written by leader-side TeamManager.get()/create(). */
2046
- leaderPid: z6.number().optional(),
2047
2037
  members: z6.array(TeamMemberEntrySchema)
2048
2038
  });
2049
2039
  function teamsBaseDir(cwd) {
@@ -2105,12 +2095,6 @@ function writeTeamFile(cwd, name, file, removedMembers = []) {
2105
2095
  ...file.members
2106
2096
  ]
2107
2097
  };
2108
- next.members = next.members.map((member) => ({
2109
- ...member,
2110
- workerPid: member.isActive ? member.workerPid ?? current.members.find(
2111
- (existing) => existing.name === member.name
2112
- )?.workerPid : void 0
2113
- }));
2114
2098
  } catch {
2115
2099
  }
2116
2100
  }
@@ -2125,23 +2109,6 @@ function writeTeamFile(cwd, name, file, removedMembers = []) {
2125
2109
  } catch {
2126
2110
  }
2127
2111
  }
2128
- function registerTeammateProcess(configPath, memberName, pid) {
2129
- withFileSyncLock(configPath, () => {
2130
- const config = readTeamFileAtPath(configPath);
2131
- const member = config?.members.find((entry) => entry.name === memberName);
2132
- if (!config || !member) {
2133
- return;
2134
- }
2135
- member.workerPid = z6.number().int().positive().parse(pid);
2136
- const temporary = `${configPath}.${String(pid)}.${randomBytes3(8).toString("hex")}.tmp`;
2137
- try {
2138
- writeFileSync4(temporary, JSON.stringify(config, null, 2), "utf-8");
2139
- renameSync3(temporary, configPath);
2140
- } finally {
2141
- rmSync3(temporary, { force: true });
2142
- }
2143
- });
2144
- }
2145
2112
 
2146
2113
  // src/teams/tools.ts
2147
2114
  var log5 = createChildLogger({ module: "teams" });
@@ -2185,12 +2152,12 @@ var TeamCreateTool = class {
2185
2152
  }
2186
2153
  await this.mgr.deleteAll();
2187
2154
  const description = strArg(args, "description");
2188
- const team = this.mgr.create(requested, void 0, {
2155
+ const team = this.mgr.create(requested, {
2189
2156
  leaderAgentId: LEADER_NAME,
2190
2157
  description
2191
2158
  });
2192
2159
  return {
2193
- output: `Team '${team.name}' created (mode: ${team.mode}). Use Agent tool with team_name='${team.name}' to add teammates.`,
2160
+ output: `Team '${team.name}' created. Use Agent tool with team_name='${team.name}' to add teammates.`,
2194
2161
  isError: false
2195
2162
  };
2196
2163
  }
@@ -2229,25 +2196,20 @@ var SendMessageTool = class {
2229
2196
  },
2230
2197
  content: {
2231
2198
  type: "string",
2232
- description: "Message content. For shutdown_request this is the reason; for plan_approval_response this is your feedback when rejecting."
2199
+ description: "Message content, or the reason for a shutdown request."
2233
2200
  },
2234
2201
  type: {
2235
2202
  type: "string",
2236
- enum: [
2237
- MSG_TEXT,
2238
- MSG_SHUTDOWN_REQUEST,
2239
- MSG_SHUTDOWN_RESPONSE,
2240
- MSG_PLAN_APPROVAL_RESPONSE
2241
- ],
2242
- description: "Message kind, defaults to 'text'. Use 'shutdown_request' to ask a teammate to wrap up (it replies with shutdown_response). Use 'plan_approval_response' to answer a teammate's plan, together with 'approve' and, when rejecting, feedback in 'content'."
2203
+ enum: [MSG_TEXT, MSG_SHUTDOWN_REQUEST, MSG_SHUTDOWN_RESPONSE],
2204
+ description: "Message kind, defaults to 'text'. Use 'shutdown_request' to ask a teammate to wrap up (it replies with shutdown_response). Teammate plans are automatically approved by the runtime."
2243
2205
  },
2244
2206
  request_id: {
2245
2207
  type: "string",
2246
- description: "Required for plan_approval_response: copy the requestId from the teammate's plan approval request so it knows which plan you are answering."
2208
+ description: "Copy the requestId from the shutdown request when responding."
2247
2209
  },
2248
2210
  approve: {
2249
2211
  type: "boolean",
2250
- description: "Required for plan_approval_response: true to let the teammate start executing, false to send it back to revise."
2212
+ description: "Required for shutdown_response: whether the shutdown request was accepted."
2251
2213
  }
2252
2214
  },
2253
2215
  required: ["to", "content"]
@@ -2284,26 +2246,6 @@ var SendMessageTool = class {
2284
2246
  message
2285
2247
  );
2286
2248
  break;
2287
- case MSG_PLAN_APPROVAL_RESPONSE:
2288
- if (this.senderName !== LEADER_NAME) {
2289
- return {
2290
- output: "Only the leader can approve or reject a teammate's plan.",
2291
- isError: true
2292
- };
2293
- }
2294
- if (!requestId || approve === void 0) {
2295
- return {
2296
- output: "plan_approval_response requires both 'request_id' and 'approve'.",
2297
- isError: true
2298
- };
2299
- }
2300
- structured = planApprovalResponse(
2301
- this.senderName,
2302
- requestId,
2303
- approve,
2304
- message
2305
- );
2306
- break;
2307
2249
  default:
2308
2250
  return {
2309
2251
  output: `Unsupported message type ${msgType}.`,
@@ -2383,7 +2325,7 @@ var ListTeamsTool = class {
2383
2325
  }
2384
2326
  const lines = teams.map((t) => {
2385
2327
  const members = t.listMembers().map((m) => `${m.name}${m.active ? " (active)" : ""}`).join(", ") || "(no members)";
2386
- return `${t.name} [${t.mode}]: ${members}`;
2328
+ return `${t.name}: ${members}`;
2387
2329
  });
2388
2330
  return Promise.resolve({
2389
2331
  output: lines.join("\n"),
@@ -2872,7 +2814,6 @@ var AgentTool = class _AgentTool {
2872
2814
  * and returns the callback that runs the teammate agent's main loop.
2873
2815
  */
2874
2816
  teamRunAgentFactory;
2875
- teamProviderIndex;
2876
2817
  spawnHandler;
2877
2818
  forkHandler;
2878
2819
  constructor(cwd, registry, spawnHandler, conversation, forkHandler, taskManager = new TaskManager()) {
@@ -2888,10 +2829,9 @@ var AgentTool = class _AgentTool {
2888
2829
  * Sets the team manager and teammate run callback, enabling the team_name parameter
2889
2830
  * so teammates can be spawned directly through the Agent tool.
2890
2831
  */
2891
- setTeamManager(mgr, runAgentFactory, providerIndex) {
2832
+ setTeamManager(mgr, runAgentFactory) {
2892
2833
  this.teamManager = mgr;
2893
2834
  this.teamRunAgentFactory = runAgentFactory;
2894
- this.teamProviderIndex = providerIndex;
2895
2835
  }
2896
2836
  forFork(registry) {
2897
2837
  const agent = new _AgentTool(
@@ -2946,7 +2886,7 @@ var AgentTool = class _AgentTool {
2946
2886
  },
2947
2887
  plan_mode_required: {
2948
2888
  type: "boolean",
2949
- description: "Only meaningful together with team_name. When true, the teammate starts in plan mode: it can read and investigate but cannot modify anything until it submits a plan and you approve it via SendMessage with type='plan_approval_response'. Use it for risky or ambiguous tasks where a wrong direction would cost a lot of rework."
2889
+ description: "Only meaningful together with team_name. Requests plan mode, subject to parent acceptEdits/bypassPermissions overrides. In plan mode, the teammate investigates and writes its plan; the runtime automatically approves the submitted plan and resumes execution under the current tool permissions."
2950
2890
  },
2951
2891
  team_name: {
2952
2892
  type: "string",
@@ -3133,8 +3073,7 @@ Worktree retained at: ${cwdOverride}` : ""}`,
3133
3073
  }
3134
3074
  /**
3135
3075
  * Team-member mode: Spawns a persistent teammate in the specified team.
3136
- * Delegates to Team.spawnTeammate(), which dispatches by team backend mode
3137
- * (in-process idle-poll loop, or an external pane/tab process).
3076
+ * Runs persistently within this process.
3138
3077
  */
3139
3078
  async runAsTeammate(teamName, requestedName, description, prompt, planModeRequired, worktreeIsolation, ctx, definition, modelOverride) {
3140
3079
  if (!this.teamManager) {
@@ -3157,7 +3096,7 @@ Worktree retained at: ${cwdOverride}` : ""}`,
3157
3096
  isError: true
3158
3097
  };
3159
3098
  }
3160
- team = this.teamManager.create(teamName, void 0, {
3099
+ team = this.teamManager.create(teamName, {
3161
3100
  leaderAgentId: LEADER_NAME,
3162
3101
  description
3163
3102
  });
@@ -3191,6 +3130,7 @@ Worktree retained at: ${cwdOverride}` : ""}`,
3191
3130
  teammateRegistry.register(
3192
3131
  new SendMessageTool(this.teamManager, memberName)
3193
3132
  );
3133
+ teammateRegistry.unregister("TodoWrite");
3194
3134
  teammateRegistry.register(
3195
3135
  new TeamTaskCreateTool(this.teamManager, teamName, memberName)
3196
3136
  );
@@ -3223,8 +3163,10 @@ ${prompt}`;
3223
3163
  }
3224
3164
  const parentChecker = ctx.permissionChecker ?? new PermissionChecker(this.cwd);
3225
3165
  this.teamManager.setPermissionChecker(parentChecker);
3226
- const checker = parentChecker.forSubagent(memberCwd);
3227
- checker.planModeLocked ||= planModeRequired || definition.permissionMode === "plan";
3166
+ const checker = parentChecker.forSubagent(
3167
+ memberCwd,
3168
+ planModeRequired ? "plan" : definition.permissionMode
3169
+ );
3228
3170
  checker.teammate = true;
3229
3171
  try {
3230
3172
  const runAgent = this.teamRunAgentFactory?.(
@@ -3232,33 +3174,29 @@ ${prompt}`;
3232
3174
  checker,
3233
3175
  memberCwd,
3234
3176
  {
3177
+ agentName: memberName,
3235
3178
  definition,
3236
3179
  modelOverride,
3237
3180
  onPermissionRequest: ctx.onPermissionRequest
3238
3181
  }
3239
3182
  );
3240
3183
  if (runAgent) {
3241
- const actualMode = team.spawnTeammate(
3184
+ team.spawnTeammate(
3242
3185
  memberName,
3243
3186
  teammatePrompt,
3244
3187
  runAgent,
3245
3188
  checker,
3246
- this.teamProviderIndex,
3247
3189
  ctx.toolCallId,
3248
3190
  memberCwd,
3249
3191
  {
3250
3192
  agentType: definition.name,
3251
3193
  model: modelOverride || definition.model,
3252
3194
  planApprovalRequired: planModeRequired,
3253
- readOnly: definition.permissionMode === "plan",
3254
3195
  cleanup: () => teammateRegistry.dispose()
3255
3196
  }
3256
3197
  );
3257
- if (actualMode !== "in-process") {
3258
- await teammateRegistry.dispose();
3259
- }
3260
3198
  return {
3261
- output: `Teammate '${memberName}' spawned in team '${teamName}' (mode: ${actualMode})${planModeRequired ? ", starting in plan mode" : ""}`,
3199
+ output: `Teammate '${memberName}' spawned in team '${teamName}' (in-process)${checker.mode === "plan" ? ", starting in plan mode" : ""}`,
3262
3200
  isError: false
3263
3201
  };
3264
3202
  }
@@ -3327,7 +3265,7 @@ ${prompt}`;
3327
3265
  permissionChecker: ctx.permissionChecker?.forCwd(worktree.path)
3328
3266
  };
3329
3267
  }
3330
- const { cloneRegistryForFork: cloneRegistryForFork2 } = await import("./tool-filter-5Z6UTRRR.js");
3268
+ const { cloneRegistryForFork: cloneRegistryForFork2 } = await import("./tool-filter-O6YLSFAS.js");
3331
3269
  const clonedRegistry = cloneRegistryForFork2(this.registry);
3332
3270
  forkedRegistry = isAsync ? filterToolsForAgent(clonedRegistry, void 0, void 0, true) : clonedRegistry;
3333
3271
  const snapshot = conversationSnapshot ?? this.conversation.fork();
@@ -3873,6 +3811,7 @@ var TaskStopTool = class _TaskStopTool {
3873
3811
  var todo_exports = {};
3874
3812
  __export(todo_exports, {
3875
3813
  Dependencies: () => dependencies_exports,
3814
+ Progress: () => progress_exports,
3876
3815
  Store: () => store_exports,
3877
3816
  TaskList: () => TaskList,
3878
3817
  Tools: () => tools_exports,
@@ -4080,6 +4019,7 @@ var ToolRegistry = class {
4080
4019
  tools = /* @__PURE__ */ new Map();
4081
4020
  owned = /* @__PURE__ */ new Set();
4082
4021
  disposal;
4022
+ cleanup = /* @__PURE__ */ new Set();
4083
4023
  discovered = /* @__PURE__ */ new Set();
4084
4024
  /**
4085
4025
  * How MCP tools are loaded, written by mcp/strategy after connecting to the
@@ -4128,12 +4068,20 @@ var ToolRegistry = class {
4128
4068
  }
4129
4069
  }
4130
4070
  }
4071
+ addCleanup(cleanup) {
4072
+ if (this.disposal) {
4073
+ throw new Error("Cannot add cleanup to a disposed registry");
4074
+ }
4075
+ this.cleanup.add(cleanup);
4076
+ }
4131
4077
  dispose() {
4132
4078
  this.disposal ??= (async () => {
4133
4079
  const owned = [...this.owned];
4134
- const results = await Promise.allSettled(
4135
- owned.map(async (tool) => tool.dispose?.())
4136
- );
4080
+ const results = await Promise.allSettled([
4081
+ ...[...this.cleanup].map((cleanup) => Promise.resolve().then(cleanup)),
4082
+ ...owned.map(async (tool) => tool.dispose?.())
4083
+ ]);
4084
+ this.cleanup.clear();
4137
4085
  this.tools.clear();
4138
4086
  this.owned.clear();
4139
4087
  this.discovered.clear();
@@ -4504,23 +4452,22 @@ export {
4504
4452
  StoredTaskSchema,
4505
4453
  TaskStore,
4506
4454
  requestToolPermission,
4507
- TaskFailure,
4508
- TaskManager,
4509
- formatAgentTaskNotification,
4510
- task_manager_exports,
4511
- MSG_PLAN_APPROVAL_RESPONSE,
4512
4455
  LEADER_NAME,
4513
4456
  isValidTeammateName,
4514
4457
  SHUTDOWN_PREFIX,
4515
4458
  shutdownRequest,
4516
4459
  shutdownResponse,
4517
4460
  planApprovalRequest,
4461
+ planApprovalResponse,
4518
4462
  isShutdownRequest,
4519
- approved,
4520
4463
  protocol_exports,
4521
4464
  isSafeCommand,
4522
4465
  PermissionChecker,
4523
4466
  permissions_exports,
4467
+ TaskFailure,
4468
+ TaskManager,
4469
+ formatAgentTaskNotification,
4470
+ task_manager_exports,
4524
4471
  SkillCatalog,
4525
4472
  parseSkillFile,
4526
4473
  buildSkillSection,
@@ -4534,10 +4481,6 @@ export {
4534
4481
  TaskListTool,
4535
4482
  TaskUpdateTool,
4536
4483
  TodoWriteTool,
4537
- TeamTaskCreateTool,
4538
- TeamTaskGetTool,
4539
- TeamTaskListTool,
4540
- TeamTaskUpdateTool,
4541
4484
  registerLeaderTaskTools,
4542
4485
  task_tools_exports,
4543
4486
  createAgentWorktree,
@@ -4552,7 +4495,6 @@ export {
4552
4495
  load_skill_tool_exports,
4553
4496
  BUILTIN_AGENTS,
4554
4497
  definition_exports,
4555
- loadAgentDefinitions,
4556
4498
  loader_exports,
4557
4499
  TaskStopTool,
4558
4500
  task_stop_exports,
@@ -4573,9 +4515,7 @@ export {
4573
4515
  teamDir,
4574
4516
  listTeamNames,
4575
4517
  readTeamFile,
4576
- readTeamFileAtPath,
4577
4518
  writeTeamFile,
4578
- registerTeammateProcess,
4579
4519
  team_file_exports,
4580
4520
  TeamCreateTool,
4581
4521
  SendMessageTool,