@yukino.js/yukino 0.0.13 → 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 (38) hide show
  1. package/README.md +12 -10
  2. package/dist/{a2a-DKWMWGID.js → a2a-D7KSHNUT.js} +4 -3
  3. package/dist/{acp-RL6DKS3R.js → acp-W4R5P6CZ.js} +7 -7
  4. package/dist/{anthropic-74ALYMH2.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-A5G5NTDB.js → chunk-D2SZ6GQJ.js} +184 -186
  9. package/dist/{chunk-APJAUOF6.js → chunk-GVRZBATW.js} +1 -1
  10. package/dist/{chunk-CJSMVCUF.js → chunk-I356BFD2.js} +1 -1
  11. package/dist/chunk-JDK4YHNF.js +63 -0
  12. package/dist/{chunk-NEU4ER5V.js → chunk-T6WQ3Z5J.js} +1 -1
  13. package/dist/{chunk-6JUOKMSJ.js → chunk-UUWXDH7J.js} +1 -1
  14. package/dist/{chunk-6FSIG63T.js → chunk-WKSVBXUO.js} +10 -9
  15. package/dist/{chunk-556TRLPT.js → chunk-Z3EFT645.js} +1 -1
  16. package/dist/lib/{anthropic-EQRUGP2C.js → anthropic-TDNNKQMT.js} +4 -4
  17. package/dist/lib/{chunk-EGT7BJRD.js → chunk-56DL5ZYL.js} +2 -2
  18. package/dist/lib/{chunk-WWCSFKMR.js → chunk-BRLCCEU7.js} +1 -1
  19. package/dist/lib/{chunk-JYCSWXCR.js → chunk-EJNKEFE7.js} +2 -2
  20. package/dist/lib/{chunk-CDMR25FD.js → chunk-IZXMDC5O.js} +3 -3
  21. package/dist/lib/{chunk-UBVKYJFI.js → chunk-UKXGO7AW.js} +143 -300
  22. package/dist/lib/{chunk-HUTUNNDX.js → chunk-WNGF7243.js} +0 -1
  23. package/dist/lib/{chunk-FUJDUZTH.js → chunk-WXR5HNB4.js} +1 -1
  24. package/dist/lib/index.d.ts +70 -275
  25. package/dist/lib/index.js +385 -1243
  26. package/dist/lib/{openai-B3I5WBFT.js → openai-6VYIA7CT.js} +3 -3
  27. package/dist/lib/{providers-EJ4VBHNP.js → providers-UXL5FVF7.js} +2 -2
  28. package/dist/lib/{tool-filter-TURPCYFR.js → tool-filter-O6YLSFAS.js} +3 -3
  29. package/dist/{main-JEEKFCGX.js → main-FOIMPIOD.js} +220 -221
  30. package/dist/main.js +2 -2
  31. package/dist/{providers-U23PWAHG.js → providers-TH6MQC7V.js} +1 -1
  32. package/dist/{server-EOSEQPNY.js → server-TC5GDF6E.js} +1 -1
  33. package/dist/tool-filter-SYH5ZFC2.js +4 -0
  34. package/package.json +6 -6
  35. package/dist/chunk-SCR7NDDL.js +0 -63
  36. package/dist/fe/dist/index.html +0 -21
  37. package/dist/fe/dist/static/index.css +0 -2
  38. package/dist/tool-filter-UDSHRE5F.js +0 -4
@@ -2,7 +2,7 @@ import {
2
2
  MCP_TOOL_PREFIX,
3
3
  McpCallTool,
4
4
  mcpCallPermissionContent
5
- } from "./chunk-FUJDUZTH.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-HUTUNNDX.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
  }
@@ -2085,7 +1996,6 @@ __export(team_file_exports, {
2085
1996
  listTeamNames: () => listTeamNames,
2086
1997
  readTeamFile: () => readTeamFile,
2087
1998
  readTeamFileAtPath: () => readTeamFileAtPath,
2088
- registerTeammateProcess: () => registerTeammateProcess,
2089
1999
  sanitizeTeamName: () => sanitizeTeamName,
2090
2000
  teamConfigPath: () => teamConfigPath,
2091
2001
  teamDir: () => teamDir,
@@ -2111,14 +2021,10 @@ var TeamMemberEntrySchema = z6.object({
2111
2021
  model: z6.string().optional(),
2112
2022
  joinedAt: z6.number(),
2113
2023
  worktreePath: z6.string().optional(),
2114
- backendType: z6.enum(["in-process", "tmux", "iterm"]),
2115
- paneId: z6.string().optional(),
2116
- workerPid: z6.number().int().positive().optional(),
2117
2024
  isActive: z6.boolean()
2118
2025
  });
2119
2026
  var TeamFileSchema = z6.object({
2120
2027
  name: z6.string(),
2121
- mode: z6.enum(["in-process", "tmux", "iterm"]),
2122
2028
  description: z6.string().optional(),
2123
2029
  createdAt: z6.number(),
2124
2030
  leaderAgentId: z6.string(),
@@ -2128,8 +2034,6 @@ var TeamFileSchema = z6.object({
2128
2034
  "plan",
2129
2035
  "bypassPermissions"
2130
2036
  ]),
2131
- /** PID of the process currently acting as leader; written by leader-side TeamManager.get()/create(). */
2132
- leaderPid: z6.number().optional(),
2133
2037
  members: z6.array(TeamMemberEntrySchema)
2134
2038
  });
2135
2039
  function teamsBaseDir(cwd) {
@@ -2191,12 +2095,6 @@ function writeTeamFile(cwd, name, file, removedMembers = []) {
2191
2095
  ...file.members
2192
2096
  ]
2193
2097
  };
2194
- next.members = next.members.map((member) => ({
2195
- ...member,
2196
- workerPid: member.isActive ? member.workerPid ?? current.members.find(
2197
- (existing) => existing.name === member.name
2198
- )?.workerPid : void 0
2199
- }));
2200
2098
  } catch {
2201
2099
  }
2202
2100
  }
@@ -2211,23 +2109,6 @@ function writeTeamFile(cwd, name, file, removedMembers = []) {
2211
2109
  } catch {
2212
2110
  }
2213
2111
  }
2214
- function registerTeammateProcess(configPath, memberName, pid) {
2215
- withFileSyncLock(configPath, () => {
2216
- const config = readTeamFileAtPath(configPath);
2217
- const member = config?.members.find((entry) => entry.name === memberName);
2218
- if (!config || !member) {
2219
- return;
2220
- }
2221
- member.workerPid = z6.number().int().positive().parse(pid);
2222
- const temporary = `${configPath}.${String(pid)}.${randomBytes3(8).toString("hex")}.tmp`;
2223
- try {
2224
- writeFileSync4(temporary, JSON.stringify(config, null, 2), "utf-8");
2225
- renameSync3(temporary, configPath);
2226
- } finally {
2227
- rmSync3(temporary, { force: true });
2228
- }
2229
- });
2230
- }
2231
2112
 
2232
2113
  // src/teams/tools.ts
2233
2114
  var log5 = createChildLogger({ module: "teams" });
@@ -2271,12 +2152,12 @@ var TeamCreateTool = class {
2271
2152
  }
2272
2153
  await this.mgr.deleteAll();
2273
2154
  const description = strArg(args, "description");
2274
- const team = this.mgr.create(requested, void 0, {
2155
+ const team = this.mgr.create(requested, {
2275
2156
  leaderAgentId: LEADER_NAME,
2276
2157
  description
2277
2158
  });
2278
2159
  return {
2279
- 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.`,
2280
2161
  isError: false
2281
2162
  };
2282
2163
  }
@@ -2315,25 +2196,20 @@ var SendMessageTool = class {
2315
2196
  },
2316
2197
  content: {
2317
2198
  type: "string",
2318
- 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."
2319
2200
  },
2320
2201
  type: {
2321
2202
  type: "string",
2322
- enum: [
2323
- MSG_TEXT,
2324
- MSG_SHUTDOWN_REQUEST,
2325
- MSG_SHUTDOWN_RESPONSE,
2326
- MSG_PLAN_APPROVAL_RESPONSE
2327
- ],
2328
- 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."
2329
2205
  },
2330
2206
  request_id: {
2331
2207
  type: "string",
2332
- 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."
2333
2209
  },
2334
2210
  approve: {
2335
2211
  type: "boolean",
2336
- 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."
2337
2213
  }
2338
2214
  },
2339
2215
  required: ["to", "content"]
@@ -2370,26 +2246,6 @@ var SendMessageTool = class {
2370
2246
  message
2371
2247
  );
2372
2248
  break;
2373
- case MSG_PLAN_APPROVAL_RESPONSE:
2374
- if (this.senderName !== LEADER_NAME) {
2375
- return {
2376
- output: "Only the leader can approve or reject a teammate's plan.",
2377
- isError: true
2378
- };
2379
- }
2380
- if (!requestId || approve === void 0) {
2381
- return {
2382
- output: "plan_approval_response requires both 'request_id' and 'approve'.",
2383
- isError: true
2384
- };
2385
- }
2386
- structured = planApprovalResponse(
2387
- this.senderName,
2388
- requestId,
2389
- approve,
2390
- message
2391
- );
2392
- break;
2393
2249
  default:
2394
2250
  return {
2395
2251
  output: `Unsupported message type ${msgType}.`,
@@ -2469,7 +2325,7 @@ var ListTeamsTool = class {
2469
2325
  }
2470
2326
  const lines = teams.map((t) => {
2471
2327
  const members = t.listMembers().map((m) => `${m.name}${m.active ? " (active)" : ""}`).join(", ") || "(no members)";
2472
- return `${t.name} [${t.mode}]: ${members}`;
2328
+ return `${t.name}: ${members}`;
2473
2329
  });
2474
2330
  return Promise.resolve({
2475
2331
  output: lines.join("\n"),
@@ -2958,7 +2814,6 @@ var AgentTool = class _AgentTool {
2958
2814
  * and returns the callback that runs the teammate agent's main loop.
2959
2815
  */
2960
2816
  teamRunAgentFactory;
2961
- teamProviderIndex;
2962
2817
  spawnHandler;
2963
2818
  forkHandler;
2964
2819
  constructor(cwd, registry, spawnHandler, conversation, forkHandler, taskManager = new TaskManager()) {
@@ -2974,10 +2829,9 @@ var AgentTool = class _AgentTool {
2974
2829
  * Sets the team manager and teammate run callback, enabling the team_name parameter
2975
2830
  * so teammates can be spawned directly through the Agent tool.
2976
2831
  */
2977
- setTeamManager(mgr, runAgentFactory, providerIndex) {
2832
+ setTeamManager(mgr, runAgentFactory) {
2978
2833
  this.teamManager = mgr;
2979
2834
  this.teamRunAgentFactory = runAgentFactory;
2980
- this.teamProviderIndex = providerIndex;
2981
2835
  }
2982
2836
  forFork(registry) {
2983
2837
  const agent = new _AgentTool(
@@ -3032,7 +2886,7 @@ var AgentTool = class _AgentTool {
3032
2886
  },
3033
2887
  plan_mode_required: {
3034
2888
  type: "boolean",
3035
- 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."
3036
2890
  },
3037
2891
  team_name: {
3038
2892
  type: "string",
@@ -3219,8 +3073,7 @@ Worktree retained at: ${cwdOverride}` : ""}`,
3219
3073
  }
3220
3074
  /**
3221
3075
  * Team-member mode: Spawns a persistent teammate in the specified team.
3222
- * Delegates to Team.spawnTeammate(), which dispatches by team backend mode
3223
- * (in-process idle-poll loop, or an external pane/tab process).
3076
+ * Runs persistently within this process.
3224
3077
  */
3225
3078
  async runAsTeammate(teamName, requestedName, description, prompt, planModeRequired, worktreeIsolation, ctx, definition, modelOverride) {
3226
3079
  if (!this.teamManager) {
@@ -3243,7 +3096,7 @@ Worktree retained at: ${cwdOverride}` : ""}`,
3243
3096
  isError: true
3244
3097
  };
3245
3098
  }
3246
- team = this.teamManager.create(teamName, void 0, {
3099
+ team = this.teamManager.create(teamName, {
3247
3100
  leaderAgentId: LEADER_NAME,
3248
3101
  description
3249
3102
  });
@@ -3310,8 +3163,10 @@ ${prompt}`;
3310
3163
  }
3311
3164
  const parentChecker = ctx.permissionChecker ?? new PermissionChecker(this.cwd);
3312
3165
  this.teamManager.setPermissionChecker(parentChecker);
3313
- const checker = parentChecker.forSubagent(memberCwd);
3314
- checker.planModeLocked ||= planModeRequired || definition.permissionMode === "plan";
3166
+ const checker = parentChecker.forSubagent(
3167
+ memberCwd,
3168
+ planModeRequired ? "plan" : definition.permissionMode
3169
+ );
3315
3170
  checker.teammate = true;
3316
3171
  try {
3317
3172
  const runAgent = this.teamRunAgentFactory?.(
@@ -3319,33 +3174,29 @@ ${prompt}`;
3319
3174
  checker,
3320
3175
  memberCwd,
3321
3176
  {
3177
+ agentName: memberName,
3322
3178
  definition,
3323
3179
  modelOverride,
3324
3180
  onPermissionRequest: ctx.onPermissionRequest
3325
3181
  }
3326
3182
  );
3327
3183
  if (runAgent) {
3328
- const actualMode = team.spawnTeammate(
3184
+ team.spawnTeammate(
3329
3185
  memberName,
3330
3186
  teammatePrompt,
3331
3187
  runAgent,
3332
3188
  checker,
3333
- this.teamProviderIndex,
3334
3189
  ctx.toolCallId,
3335
3190
  memberCwd,
3336
3191
  {
3337
3192
  agentType: definition.name,
3338
3193
  model: modelOverride || definition.model,
3339
3194
  planApprovalRequired: planModeRequired,
3340
- readOnly: definition.permissionMode === "plan",
3341
3195
  cleanup: () => teammateRegistry.dispose()
3342
3196
  }
3343
3197
  );
3344
- if (actualMode !== "in-process") {
3345
- await teammateRegistry.dispose();
3346
- }
3347
3198
  return {
3348
- 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" : ""}`,
3349
3200
  isError: false
3350
3201
  };
3351
3202
  }
@@ -3414,7 +3265,7 @@ ${prompt}`;
3414
3265
  permissionChecker: ctx.permissionChecker?.forCwd(worktree.path)
3415
3266
  };
3416
3267
  }
3417
- const { cloneRegistryForFork: cloneRegistryForFork2 } = await import("./tool-filter-TURPCYFR.js");
3268
+ const { cloneRegistryForFork: cloneRegistryForFork2 } = await import("./tool-filter-O6YLSFAS.js");
3418
3269
  const clonedRegistry = cloneRegistryForFork2(this.registry);
3419
3270
  forkedRegistry = isAsync ? filterToolsForAgent(clonedRegistry, void 0, void 0, true) : clonedRegistry;
3420
3271
  const snapshot = conversationSnapshot ?? this.conversation.fork();
@@ -4601,23 +4452,22 @@ export {
4601
4452
  StoredTaskSchema,
4602
4453
  TaskStore,
4603
4454
  requestToolPermission,
4604
- TaskFailure,
4605
- TaskManager,
4606
- formatAgentTaskNotification,
4607
- task_manager_exports,
4608
- MSG_PLAN_APPROVAL_RESPONSE,
4609
4455
  LEADER_NAME,
4610
4456
  isValidTeammateName,
4611
4457
  SHUTDOWN_PREFIX,
4612
4458
  shutdownRequest,
4613
4459
  shutdownResponse,
4614
4460
  planApprovalRequest,
4461
+ planApprovalResponse,
4615
4462
  isShutdownRequest,
4616
- approved,
4617
4463
  protocol_exports,
4618
4464
  isSafeCommand,
4619
4465
  PermissionChecker,
4620
4466
  permissions_exports,
4467
+ TaskFailure,
4468
+ TaskManager,
4469
+ formatAgentTaskNotification,
4470
+ task_manager_exports,
4621
4471
  SkillCatalog,
4622
4472
  parseSkillFile,
4623
4473
  buildSkillSection,
@@ -4631,10 +4481,6 @@ export {
4631
4481
  TaskListTool,
4632
4482
  TaskUpdateTool,
4633
4483
  TodoWriteTool,
4634
- TeamTaskCreateTool,
4635
- TeamTaskGetTool,
4636
- TeamTaskListTool,
4637
- TeamTaskUpdateTool,
4638
4484
  registerLeaderTaskTools,
4639
4485
  task_tools_exports,
4640
4486
  createAgentWorktree,
@@ -4649,7 +4495,6 @@ export {
4649
4495
  load_skill_tool_exports,
4650
4496
  BUILTIN_AGENTS,
4651
4497
  definition_exports,
4652
- loadAgentDefinitions,
4653
4498
  loader_exports,
4654
4499
  TaskStopTool,
4655
4500
  task_stop_exports,
@@ -4670,9 +4515,7 @@ export {
4670
4515
  teamDir,
4671
4516
  listTeamNames,
4672
4517
  readTeamFile,
4673
- readTeamFileAtPath,
4674
4518
  writeTeamFile,
4675
- registerTeammateProcess,
4676
4519
  team_file_exports,
4677
4520
  TeamCreateTool,
4678
4521
  SendMessageTool,