@orchestraai/agent-tools 0.10.16 → 0.10.18

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 (183) hide show
  1. package/.agents/plugins/marketplace.json +1 -1
  2. package/.claude-plugin/marketplace.json +1 -1
  3. package/.claude-plugin/plugin.json +1 -1
  4. package/.codex-plugin/plugin.json +1 -1
  5. package/.cursor-plugin/plugin.json +1 -1
  6. package/.devin/adapter.json +1 -1
  7. package/.hermes/adapter.json +1 -1
  8. package/.opencode/adapter.json +1 -1
  9. package/dist/commands/claude-setup.d.ts +1 -1
  10. package/dist/runtime/conversation/command-guard.js +1347 -63
  11. package/dist/runtime/conversation/command-guard.js.map +1 -1
  12. package/dist/runtime/conversation/shell-parse.d.ts +44 -0
  13. package/dist/runtime/conversation/shell-parse.js +525 -0
  14. package/dist/runtime/conversation/shell-parse.js.map +1 -0
  15. package/docs/security.md +18 -2
  16. package/node_modules/@hono/node-server/dist/index.cjs +63 -17
  17. package/node_modules/@hono/node-server/dist/index.mjs +63 -17
  18. package/node_modules/@hono/node-server/dist/serve-static.cjs +1 -1
  19. package/node_modules/@hono/node-server/dist/serve-static.mjs +1 -1
  20. package/node_modules/@hono/node-server/package.json +1 -1
  21. package/node_modules/cross-spawn/README.md +19 -3
  22. package/node_modules/cross-spawn/lib/parse.js +38 -10
  23. package/node_modules/cross-spawn/lib/util/escape.js +84 -25
  24. package/node_modules/cross-spawn/lib/util/readShebang.js +8 -2
  25. package/node_modules/cross-spawn/lib/util/resolveCommand.js +8 -1
  26. package/node_modules/cross-spawn/package.json +21 -24
  27. package/node_modules/hono/README.md +2 -3
  28. package/node_modules/hono/dist/adapter/aws-lambda/handler.js +2 -2
  29. package/node_modules/hono/dist/adapter/bun/websocket.js +19 -4
  30. package/node_modules/hono/dist/adapter/lambda-edge/handler.js +5 -1
  31. package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +2 -2
  32. package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +19 -4
  33. package/node_modules/hono/dist/cjs/adapter/lambda-edge/handler.js +5 -1
  34. package/node_modules/hono/dist/cjs/client/fetch-result-please.js +1 -1
  35. package/node_modules/hono/dist/cjs/client/utils.js +9 -5
  36. package/node_modules/hono/dist/cjs/context.js +1 -1
  37. package/node_modules/hono/dist/cjs/helper/accepts/accepts.js +7 -1
  38. package/node_modules/hono/dist/cjs/helper/css/common.js +11 -8
  39. package/node_modules/hono/dist/cjs/helper/css/index.js +1 -1
  40. package/node_modules/hono/dist/cjs/helper/proxy/index.js +2 -0
  41. package/node_modules/hono/dist/cjs/helper/route/index.js +3 -1
  42. package/node_modules/hono/dist/cjs/helper/ssg/ssg.js +5 -3
  43. package/node_modules/hono/dist/cjs/helper/streaming/sse.js +6 -2
  44. package/node_modules/hono/dist/cjs/hono-base.js +9 -10
  45. package/node_modules/hono/dist/cjs/hono.js +0 -1
  46. package/node_modules/hono/dist/cjs/jsx/base.js +51 -32
  47. package/node_modules/hono/dist/cjs/jsx/components.js +2 -2
  48. package/node_modules/hono/dist/cjs/jsx/constants.js +2 -0
  49. package/node_modules/hono/dist/cjs/jsx/context.js +15 -2
  50. package/node_modules/hono/dist/cjs/jsx/dom/components.js +1 -1
  51. package/node_modules/hono/dist/cjs/jsx/dom/hooks/index.js +38 -8
  52. package/node_modules/hono/dist/cjs/jsx/dom/intrinsic-element/components.js +8 -5
  53. package/node_modules/hono/dist/cjs/jsx/dom/render.js +9 -3
  54. package/node_modules/hono/dist/cjs/jsx/jsx-runtime.js +13 -17
  55. package/node_modules/hono/dist/cjs/middleware/basic-auth/index.js +3 -1
  56. package/node_modules/hono/dist/cjs/middleware/bearer-auth/index.js +9 -1
  57. package/node_modules/hono/dist/cjs/middleware/body-limit/index.js +9 -10
  58. package/node_modules/hono/dist/cjs/middleware/combine/index.js +4 -0
  59. package/node_modules/hono/dist/cjs/middleware/compress/index.js +2 -3
  60. package/node_modules/hono/dist/cjs/middleware/csrf/index.js +2 -2
  61. package/node_modules/hono/dist/cjs/middleware/etag/index.js +3 -1
  62. package/node_modules/hono/dist/cjs/middleware/jwk/jwk.js +2 -2
  63. package/node_modules/hono/dist/cjs/middleware/jwt/jwt.js +2 -2
  64. package/node_modules/hono/dist/cjs/middleware/method-not-allowed/index.js +1 -1
  65. package/node_modules/hono/dist/cjs/middleware/method-override/index.js +35 -12
  66. package/node_modules/hono/dist/cjs/middleware/mount/index.js +5 -4
  67. package/node_modules/hono/dist/cjs/middleware/pretty-json/index.js +1 -0
  68. package/node_modules/hono/dist/cjs/middleware/request-id/request-id.js +3 -3
  69. package/node_modules/hono/dist/cjs/middleware/secure-headers/secure-headers.js +6 -3
  70. package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +4 -2
  71. package/node_modules/hono/dist/cjs/middleware/timing/timing.js +4 -3
  72. package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +13 -11
  73. package/node_modules/hono/dist/cjs/router/reg-exp-router/prepared-router.js +4 -4
  74. package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +39 -51
  75. package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +15 -5
  76. package/node_modules/hono/dist/cjs/router/trie-router/node.js +6 -4
  77. package/node_modules/hono/dist/cjs/utils/body.js +2 -1
  78. package/node_modules/hono/dist/cjs/utils/cookie.js +3 -3
  79. package/node_modules/hono/dist/cjs/utils/html.js +5 -0
  80. package/node_modules/hono/dist/cjs/utils/jwt/jwt.js +8 -5
  81. package/node_modules/hono/dist/cjs/utils/mime.js +3 -2
  82. package/node_modules/hono/dist/cjs/utils/mount.js +59 -0
  83. package/node_modules/hono/dist/cjs/utils/url.js +23 -11
  84. package/node_modules/hono/dist/cjs/validator/validator.js +5 -5
  85. package/node_modules/hono/dist/client/fetch-result-please.js +1 -1
  86. package/node_modules/hono/dist/client/utils.js +9 -5
  87. package/node_modules/hono/dist/context.js +1 -1
  88. package/node_modules/hono/dist/helper/accepts/accepts.js +7 -1
  89. package/node_modules/hono/dist/helper/css/common.js +11 -8
  90. package/node_modules/hono/dist/helper/css/index.js +1 -1
  91. package/node_modules/hono/dist/helper/proxy/index.js +2 -0
  92. package/node_modules/hono/dist/helper/route/index.js +3 -1
  93. package/node_modules/hono/dist/helper/ssg/ssg.js +5 -3
  94. package/node_modules/hono/dist/helper/streaming/sse.js +6 -2
  95. package/node_modules/hono/dist/hono-base.js +9 -10
  96. package/node_modules/hono/dist/hono.js +0 -1
  97. package/node_modules/hono/dist/jsx/base.js +51 -34
  98. package/node_modules/hono/dist/jsx/components.js +2 -2
  99. package/node_modules/hono/dist/jsx/constants.js +2 -1
  100. package/node_modules/hono/dist/jsx/context.js +15 -2
  101. package/node_modules/hono/dist/jsx/dom/components.js +2 -2
  102. package/node_modules/hono/dist/jsx/dom/hooks/index.js +39 -9
  103. package/node_modules/hono/dist/jsx/dom/intrinsic-element/components.js +8 -5
  104. package/node_modules/hono/dist/jsx/dom/render.js +9 -3
  105. package/node_modules/hono/dist/jsx/jsx-runtime.js +15 -19
  106. package/node_modules/hono/dist/middleware/basic-auth/index.js +3 -1
  107. package/node_modules/hono/dist/middleware/bearer-auth/index.js +9 -1
  108. package/node_modules/hono/dist/middleware/body-limit/index.js +9 -10
  109. package/node_modules/hono/dist/middleware/combine/index.js +4 -0
  110. package/node_modules/hono/dist/middleware/compress/index.js +2 -3
  111. package/node_modules/hono/dist/middleware/csrf/index.js +2 -2
  112. package/node_modules/hono/dist/middleware/etag/index.js +3 -1
  113. package/node_modules/hono/dist/middleware/jwk/jwk.js +2 -2
  114. package/node_modules/hono/dist/middleware/jwt/jwt.js +2 -2
  115. package/node_modules/hono/dist/middleware/method-not-allowed/index.js +1 -1
  116. package/node_modules/hono/dist/middleware/method-override/index.js +35 -12
  117. package/node_modules/hono/dist/middleware/mount/index.js +5 -4
  118. package/node_modules/hono/dist/middleware/pretty-json/index.js +1 -0
  119. package/node_modules/hono/dist/middleware/request-id/request-id.js +3 -3
  120. package/node_modules/hono/dist/middleware/secure-headers/secure-headers.js +6 -3
  121. package/node_modules/hono/dist/middleware/serve-static/index.js +4 -2
  122. package/node_modules/hono/dist/middleware/timing/timing.js +4 -3
  123. package/node_modules/hono/dist/router/reg-exp-router/node.js +13 -11
  124. package/node_modules/hono/dist/router/reg-exp-router/prepared-router.js +5 -5
  125. package/node_modules/hono/dist/router/reg-exp-router/router.js +40 -52
  126. package/node_modules/hono/dist/router/reg-exp-router/trie.js +15 -5
  127. package/node_modules/hono/dist/router/trie-router/node.js +6 -4
  128. package/node_modules/hono/dist/types/adapter/aws-lambda/conninfo.d.ts +1 -1
  129. package/node_modules/hono/dist/types/adapter/bun/conninfo.d.ts +1 -1
  130. package/node_modules/hono/dist/types/adapter/bun/ssg.d.ts +1 -1
  131. package/node_modules/hono/dist/types/adapter/cloudflare-pages/conninfo.d.ts +1 -1
  132. package/node_modules/hono/dist/types/adapter/cloudflare-workers/conninfo.d.ts +1 -1
  133. package/node_modules/hono/dist/types/adapter/deno/conninfo.d.ts +1 -1
  134. package/node_modules/hono/dist/types/adapter/deno/ssg.d.ts +1 -1
  135. package/node_modules/hono/dist/types/adapter/lambda-edge/conninfo.d.ts +1 -1
  136. package/node_modules/hono/dist/types/adapter/netlify/conninfo.d.ts +1 -1
  137. package/node_modules/hono/dist/types/adapter/vercel/conninfo.d.ts +1 -1
  138. package/node_modules/hono/dist/types/helper/accepts/accepts.d.ts +5 -0
  139. package/node_modules/hono/dist/types/helper/factory/index.d.ts +1 -1
  140. package/node_modules/hono/dist/types/helper/ssg/ssg.d.ts +6 -1
  141. package/node_modules/hono/dist/types/helper/streaming/sse.d.ts +1 -1
  142. package/node_modules/hono/dist/types/helper/streaming/stream.d.ts +1 -1
  143. package/node_modules/hono/dist/types/helper/streaming/text.d.ts +1 -1
  144. package/node_modules/hono/dist/types/helper/testing/index.d.ts +2 -1
  145. package/node_modules/hono/dist/types/helper/websocket/index.d.ts +13 -3
  146. package/node_modules/hono/dist/types/hono-base.d.ts +23 -9
  147. package/node_modules/hono/dist/types/index.d.ts +1 -1
  148. package/node_modules/hono/dist/types/jsx/base.d.ts +6 -3
  149. package/node_modules/hono/dist/types/jsx/components.d.ts +2 -2
  150. package/node_modules/hono/dist/types/jsx/constants.d.ts +1 -0
  151. package/node_modules/hono/dist/types/jsx/context.d.ts +2 -2
  152. package/node_modules/hono/dist/types/jsx/dom/components.d.ts +2 -2
  153. package/node_modules/hono/dist/types/jsx/dom/css.d.ts +2 -2
  154. package/node_modules/hono/dist/types/jsx/dom/hooks/index.d.ts +5 -3
  155. package/node_modules/hono/dist/types/jsx/dom/index.d.ts +1 -1
  156. package/node_modules/hono/dist/types/jsx/dom/server.d.ts +1 -1
  157. package/node_modules/hono/dist/types/jsx/index.d.ts +1 -1
  158. package/node_modules/hono/dist/types/jsx/jsx-runtime.d.ts +2 -1
  159. package/node_modules/hono/dist/types/jsx/streaming.d.ts +4 -3
  160. package/node_modules/hono/dist/types/middleware/basic-auth/index.d.ts +1 -0
  161. package/node_modules/hono/dist/types/middleware/bearer-auth/index.d.ts +2 -1
  162. package/node_modules/hono/dist/types/middleware/ip-restriction/index.d.ts +3 -3
  163. package/node_modules/hono/dist/types/middleware/jsx-renderer/index.d.ts +3 -3
  164. package/node_modules/hono/dist/types/middleware/mount/index.d.ts +2 -0
  165. package/node_modules/hono/dist/types/middleware/request-id/request-id.d.ts +3 -3
  166. package/node_modules/hono/dist/types/middleware/secure-headers/secure-headers.d.ts +2 -0
  167. package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +3 -3
  168. package/node_modules/hono/dist/types/router/reg-exp-router/trie.d.ts +1 -1
  169. package/node_modules/hono/dist/types/utils/cookie.d.ts +1 -1
  170. package/node_modules/hono/dist/types/utils/ipaddr.d.ts +1 -1
  171. package/node_modules/hono/dist/types/utils/jwt/jwt.d.ts +4 -2
  172. package/node_modules/hono/dist/types/utils/mount.d.ts +4 -0
  173. package/node_modules/hono/dist/types/utils/types.d.ts +12 -2
  174. package/node_modules/hono/dist/utils/body.js +2 -1
  175. package/node_modules/hono/dist/utils/cookie.js +3 -3
  176. package/node_modules/hono/dist/utils/html.js +5 -0
  177. package/node_modules/hono/dist/utils/jwt/jwt.js +8 -5
  178. package/node_modules/hono/dist/utils/mime.js +3 -2
  179. package/node_modules/hono/dist/utils/mount.js +58 -0
  180. package/node_modules/hono/dist/utils/url.js +23 -11
  181. package/node_modules/hono/dist/validator/validator.js +5 -5
  182. package/node_modules/hono/package.json +1 -1
  183. package/package.json +1 -1
@@ -0,0 +1,525 @@
1
+ // A small POSIX/bash-style shell parser used by the command guard.
2
+ //
3
+ // It does not evaluate anything. It splits a command line into pipelines and
4
+ // simple commands, removes quoting the way the shell would, separates
5
+ // redirects from arguments, reads heredocs, and parses command and process
6
+ // substitutions into nested scripts so that every command the shell would
7
+ // run can be checked.
8
+ export class ShellParseError extends Error {
9
+ }
10
+ export const MAX_SHELL_NESTING = 12;
11
+ const WORD_BREAK = new Set([" ", "\t", "\n", ";", "&", "|", "<", ">", "(", ")"]);
12
+ const REDIRECT_OPS = ["<<<", "<<-", "&>>", "<<", "<>", "<&", ">>", ">|", ">&", "&>", "<", ">"];
13
+ /** Words that can come before `case` at the start of a command. */
14
+ const CASE_PREFIX_WORDS = new Set(["!", "{", "then", "do", "else", "elif", "if", "while", "until", "time", "-p"]);
15
+ const MAX_BRACE_WORDS = 64;
16
+ /** Expands comma brace groups (`a{b,c}d`, several groups) the way bash does, dropping empty results. */
17
+ function expandBraces(value) {
18
+ let words = [value];
19
+ for (let round = 0; round < 8; round += 1) {
20
+ const next = [];
21
+ let changed = false;
22
+ for (const word of words) {
23
+ const group = /\{([^{}]*,[^{}]*)\}/.exec(word);
24
+ if (!group) {
25
+ next.push(word);
26
+ continue;
27
+ }
28
+ changed = true;
29
+ const before = word.slice(0, group.index);
30
+ const after = word.slice(group.index + group[0].length);
31
+ for (const item of group[1].split(","))
32
+ next.push(`${before}${item}${after}`);
33
+ }
34
+ words = next.slice(0, MAX_BRACE_WORDS);
35
+ if (!changed)
36
+ break;
37
+ }
38
+ return words.filter((word) => word !== "");
39
+ }
40
+ class Parser {
41
+ src;
42
+ base;
43
+ depth;
44
+ pos = 0;
45
+ parenDepth = 0;
46
+ /** Paren depth at each open `case`, so `pattern)` is not read as a closing paren. */
47
+ caseStack = [];
48
+ /** Open `( ... )` groups, by number. */
49
+ groups = [];
50
+ groupCount = 0;
51
+ pendingHeredocs = [];
52
+ pipelines = [];
53
+ comments = [];
54
+ commands = [];
55
+ words = [];
56
+ redirects = [];
57
+ constructor(src, base, depth) {
58
+ this.src = src;
59
+ this.base = base;
60
+ this.depth = depth;
61
+ if (depth > MAX_SHELL_NESTING)
62
+ throw new ShellParseError("nesting too deep");
63
+ }
64
+ /** Parse until end of input, or until an unmatched `)` when `untilParen` is set. Returns the script and the index after it. */
65
+ parse(untilParen) {
66
+ const src = this.src;
67
+ while (this.pos < src.length) {
68
+ const c = src[this.pos];
69
+ // Only space and tab are blanks; bash reads a carriage return as an ordinary character.
70
+ if (c === " " || c === "\t") {
71
+ this.pos += 1;
72
+ }
73
+ else if (this.startsWith("\\\n") || this.startsWith("\\\r\n")) {
74
+ // Line continuation.
75
+ this.pos += src[this.pos + 1] === "\r" ? 3 : 2;
76
+ }
77
+ else if (c === "\n") {
78
+ this.endPipeline();
79
+ this.pos += 1;
80
+ this.readHeredocBodies();
81
+ }
82
+ else if (c === "#") {
83
+ const start = this.pos;
84
+ while (this.pos < src.length && src[this.pos] !== "\n")
85
+ this.pos += 1;
86
+ this.comments.push([this.base + start, this.base + this.pos]);
87
+ }
88
+ else if (c === ")") {
89
+ this.pos += 1;
90
+ if (this.caseStack.length && this.caseStack[this.caseStack.length - 1] === this.parenDepth) {
91
+ // End of a case pattern such as `a)` or `a|b)`.
92
+ this.endCommand();
93
+ for (const patternCommand of this.commands)
94
+ patternCommand.casePattern = true;
95
+ this.endPipeline();
96
+ continue;
97
+ }
98
+ if (this.parenDepth === 0 && untilParen) {
99
+ this.endPipeline();
100
+ return { script: this.finish(), end: this.pos };
101
+ }
102
+ // The commands before `)` belong to the subshell it closes.
103
+ this.endPipeline();
104
+ if (this.parenDepth > 0) {
105
+ this.parenDepth -= 1;
106
+ this.groups.pop();
107
+ }
108
+ }
109
+ else if (c === "(") {
110
+ this.pos += 1;
111
+ this.endPipeline();
112
+ this.parenDepth += 1;
113
+ this.groupCount += 1;
114
+ this.groups.push(this.groupCount);
115
+ }
116
+ else if (this.tryRedirect()) {
117
+ // handled
118
+ }
119
+ else if (this.startsWith("<(") || this.startsWith(">(")) {
120
+ this.words.push(this.readWord());
121
+ }
122
+ else if (this.startsWith("||") || this.startsWith("&&") || this.startsWith(";;") || this.startsWith(";&")) {
123
+ this.pos += 2;
124
+ this.endPipeline();
125
+ }
126
+ else if (this.startsWith("|&") || c === "|") {
127
+ this.pos += c === "|" && src[this.pos + 1] === "&" ? 2 : 1;
128
+ this.endCommand();
129
+ }
130
+ else if (c === ";" || c === "&") {
131
+ this.pos += 1;
132
+ this.endPipeline();
133
+ }
134
+ else {
135
+ const word = this.readWord();
136
+ this.words.push(word);
137
+ const leading = this.words.slice(0, -1);
138
+ if (this.redirects.length === 0 && leading.every((w) => CASE_PREFIX_WORDS.has(w.raw)))
139
+ this.trackCase(word);
140
+ }
141
+ }
142
+ if (untilParen)
143
+ throw new ShellParseError("unterminated substitution");
144
+ if (this.pendingHeredocs.length)
145
+ this.readHeredocBodies();
146
+ this.endPipeline();
147
+ return { script: this.finish(), end: this.pos };
148
+ }
149
+ trackCase(word) {
150
+ const raw = word.raw;
151
+ if (raw === "case")
152
+ this.caseStack.push(this.parenDepth);
153
+ else if (raw === "esac" && this.caseStack.length)
154
+ this.caseStack.pop();
155
+ }
156
+ finish() {
157
+ return { pipelines: this.pipelines, comments: this.comments };
158
+ }
159
+ startsWith(token) {
160
+ return this.src.startsWith(token, this.pos);
161
+ }
162
+ endCommand() {
163
+ if (this.words.length || this.redirects.length) {
164
+ this.commands.push({ words: this.words, redirects: this.redirects });
165
+ }
166
+ this.words = [];
167
+ this.redirects = [];
168
+ }
169
+ endPipeline() {
170
+ this.endCommand();
171
+ if (this.commands.length)
172
+ this.pipelines.push({ commands: this.commands, subshells: [...this.groups] });
173
+ this.commands = [];
174
+ }
175
+ tryRedirect() {
176
+ const src = this.src;
177
+ let cursor = this.pos;
178
+ while (cursor < src.length && /[0-9]/.test(src[cursor]))
179
+ cursor += 1;
180
+ if (src.startsWith("<(", cursor) || src.startsWith(">(", cursor))
181
+ return false;
182
+ const op = REDIRECT_OPS.find((candidate) => src.startsWith(candidate, cursor));
183
+ if (!op)
184
+ return false;
185
+ this.pos = cursor + op.length;
186
+ this.skipBlanks();
187
+ const redirect = { op };
188
+ if (op === "<<" || op === "<<-") {
189
+ const delimiterWord = this.readWord();
190
+ const raw = src.slice(delimiterWord.start - this.base, delimiterWord.end - this.base);
191
+ this.pendingHeredocs.push({
192
+ delimiter: delimiterWord.value,
193
+ stripTabs: op === "<<-",
194
+ quoted: /['"\\]/.test(raw),
195
+ redirect,
196
+ });
197
+ }
198
+ else {
199
+ const procSub = this.startsWith("<(") || this.startsWith(">(");
200
+ if (this.pos >= src.length || (WORD_BREAK.has(src[this.pos]) && !procSub)) {
201
+ throw new ShellParseError("redirect without target");
202
+ }
203
+ redirect.target = this.readWord();
204
+ }
205
+ this.redirects.push(redirect);
206
+ return true;
207
+ }
208
+ skipBlanks() {
209
+ while (this.pos < this.src.length && (this.src[this.pos] === " " || this.src[this.pos] === "\t")) {
210
+ this.pos += 1;
211
+ }
212
+ }
213
+ readHeredocBodies() {
214
+ const src = this.src;
215
+ for (const pending of this.pendingHeredocs) {
216
+ const start = this.pos;
217
+ let end = src.length;
218
+ let next = src.length;
219
+ while (this.pos < src.length) {
220
+ const lineEnd = src.indexOf("\n", this.pos);
221
+ const stop = lineEnd === -1 ? src.length : lineEnd;
222
+ let line = src.slice(this.pos, stop);
223
+ if (pending.stripTabs)
224
+ line = line.replace(/^\t+/, "");
225
+ if (line === pending.delimiter) {
226
+ end = this.pos;
227
+ next = lineEnd === -1 ? src.length : lineEnd + 1;
228
+ break;
229
+ }
230
+ this.pos = lineEnd === -1 ? src.length : lineEnd + 1;
231
+ }
232
+ if (next === src.length && end === src.length)
233
+ end = src.length;
234
+ const body = src.slice(start, end);
235
+ pending.redirect.heredoc = {
236
+ body,
237
+ start: this.base + start,
238
+ end: this.base + end,
239
+ quoted: pending.quoted,
240
+ substitutions: pending.quoted ? [] : expansionsIn(body, this.base + start, this.depth),
241
+ };
242
+ this.pos = next;
243
+ }
244
+ this.pendingHeredocs = [];
245
+ }
246
+ readWord() {
247
+ const src = this.src;
248
+ const start = this.pos;
249
+ let value = "";
250
+ let plain = true;
251
+ const substitutions = [];
252
+ while (this.pos < src.length) {
253
+ const c = src[this.pos];
254
+ if (c !== "\\" && c !== "'" && c !== "\"" && c !== "$" && c !== "`" && !WORD_BREAK.has(c)) {
255
+ value += c;
256
+ this.pos += 1;
257
+ continue;
258
+ }
259
+ if (!WORD_BREAK.has(c))
260
+ plain = false;
261
+ if ((c === "<" || c === ">") && src[this.pos + 1] === "(") {
262
+ plain = false;
263
+ const inner = this.readNested(this.pos + 2);
264
+ substitutions.push(inner.script);
265
+ value += src.slice(this.pos, inner.end);
266
+ this.pos = inner.end;
267
+ continue;
268
+ }
269
+ if (WORD_BREAK.has(c))
270
+ break;
271
+ if (c === "\\") {
272
+ const next = src[this.pos + 1];
273
+ if (next === "\n") {
274
+ this.pos += 2;
275
+ continue;
276
+ }
277
+ if (next === "\r" && src[this.pos + 2] === "\n") {
278
+ this.pos += 3;
279
+ continue;
280
+ }
281
+ if (next !== undefined)
282
+ value += next;
283
+ this.pos += 2;
284
+ }
285
+ else if (c === "'") {
286
+ const close = src.indexOf("'", this.pos + 1);
287
+ if (close === -1)
288
+ throw new ShellParseError("unterminated single quote");
289
+ value += src.slice(this.pos + 1, close);
290
+ this.pos = close + 1;
291
+ }
292
+ else if (c === "$" && src[this.pos + 1] === "'") {
293
+ value += this.readAnsiC();
294
+ }
295
+ else if (c === "\"" || (c === "$" && src[this.pos + 1] === "\"")) {
296
+ this.pos += c === "$" ? 2 : 1;
297
+ value += this.readDoubleQuoted(substitutions);
298
+ }
299
+ else if (c === "$" || c === "`") {
300
+ value += this.readExpansion(substitutions);
301
+ }
302
+ else {
303
+ value += c;
304
+ this.pos += 1;
305
+ }
306
+ }
307
+ const word = {
308
+ value,
309
+ raw: src.slice(start, this.pos),
310
+ start: this.base + start,
311
+ end: this.base + this.pos,
312
+ substitutions,
313
+ };
314
+ if (plain && /\{[^{}]*,[^{}]*\}/.test(value))
315
+ word.braceExpansion = expandBraces(value);
316
+ return word;
317
+ }
318
+ readAnsiC() {
319
+ const src = this.src;
320
+ this.pos += 2;
321
+ let out = "";
322
+ while (this.pos < src.length && src[this.pos] !== "'") {
323
+ const c = src[this.pos];
324
+ if (c !== "\\") {
325
+ out += c;
326
+ this.pos += 1;
327
+ continue;
328
+ }
329
+ const next = src[this.pos + 1] ?? "";
330
+ const simple = {
331
+ n: "\n", t: "\t", r: "\r", a: "\x07", b: "\b", e: "\x1b", E: "\x1b", f: "\f", v: "\v",
332
+ "\\": "\\", "'": "'", "\"": "\"", "?": "?",
333
+ };
334
+ if (next in simple) {
335
+ out += simple[next];
336
+ this.pos += 2;
337
+ }
338
+ else if (next === "x") {
339
+ const hex = /^[0-9a-fA-F]{1,2}/.exec(src.slice(this.pos + 2))?.[0] ?? "";
340
+ out += hex ? String.fromCharCode(parseInt(hex, 16)) : "\\x";
341
+ this.pos += 2 + hex.length;
342
+ }
343
+ else if (next === "u" || next === "U") {
344
+ const hex = new RegExp(`^[0-9a-fA-F]{1,${next === "u" ? 4 : 8}}`).exec(src.slice(this.pos + 2))?.[0] ?? "";
345
+ const codePoint = hex ? parseInt(hex, 16) : -1;
346
+ out += codePoint >= 0 && codePoint <= 0x10ffff ? String.fromCodePoint(codePoint) : `\\${next}${hex}`;
347
+ this.pos += 2 + hex.length;
348
+ }
349
+ else if (/[0-7]/.test(next)) {
350
+ const oct = /^[0-7]{1,3}/.exec(src.slice(this.pos + 1))?.[0] ?? "";
351
+ out += String.fromCharCode(parseInt(oct, 8));
352
+ this.pos += 1 + oct.length;
353
+ }
354
+ else {
355
+ out += `\\${next}`;
356
+ this.pos += 2;
357
+ }
358
+ }
359
+ if (this.pos >= src.length)
360
+ throw new ShellParseError("unterminated quote");
361
+ this.pos += 1;
362
+ return out;
363
+ }
364
+ readDoubleQuoted(substitutions) {
365
+ const src = this.src;
366
+ let out = "";
367
+ while (this.pos < src.length && src[this.pos] !== "\"") {
368
+ const c = src[this.pos];
369
+ if (c === "\\") {
370
+ const next = src[this.pos + 1];
371
+ if (next !== undefined && "$`\"\\\n".includes(next)) {
372
+ out += next === "\n" ? "" : next;
373
+ }
374
+ else {
375
+ out += `\\${next ?? ""}`;
376
+ }
377
+ this.pos += 2;
378
+ }
379
+ else if (c === "$" || c === "`") {
380
+ out += this.readExpansion(substitutions);
381
+ }
382
+ else {
383
+ out += c;
384
+ this.pos += 1;
385
+ }
386
+ }
387
+ if (this.pos >= src.length)
388
+ throw new ShellParseError("unterminated double quote");
389
+ this.pos += 1;
390
+ return out;
391
+ }
392
+ /** Reads $..., ${...}, $(...), $((...)) or `...` starting at this.pos; returns its source text. */
393
+ readExpansion(substitutions) {
394
+ const src = this.src;
395
+ const start = this.pos;
396
+ if (src[this.pos] === "`") {
397
+ let raw = "";
398
+ let cursor = this.pos + 1;
399
+ while (cursor < src.length && src[cursor] !== "`") {
400
+ if (src[cursor] === "\\" && cursor + 1 < src.length && "$`\\".includes(src[cursor + 1])) {
401
+ raw += src[cursor + 1];
402
+ cursor += 2;
403
+ }
404
+ else {
405
+ raw += src[cursor];
406
+ cursor += 1;
407
+ }
408
+ }
409
+ if (cursor >= src.length)
410
+ throw new ShellParseError("unterminated backquote");
411
+ substitutions.push(parseShell(raw, this.base + this.pos + 1, this.depth + 1));
412
+ this.pos = cursor + 1;
413
+ return src.slice(start, this.pos);
414
+ }
415
+ if (src.startsWith("$((", this.pos) && this.isArithmetic()) {
416
+ let depth = 0;
417
+ let cursor = this.pos + 1;
418
+ for (; cursor < src.length; cursor += 1) {
419
+ if (src[cursor] === "(")
420
+ depth += 1;
421
+ else if (src[cursor] === ")") {
422
+ depth -= 1;
423
+ if (depth === 0)
424
+ break;
425
+ }
426
+ }
427
+ // Arithmetic can itself contain command substitutions.
428
+ substitutions.push(...expansionsIn(src.slice(this.pos + 3, cursor - 1), this.base + this.pos + 3, this.depth));
429
+ this.pos = cursor + 1;
430
+ return src.slice(start, this.pos);
431
+ }
432
+ if (src.startsWith("$(", this.pos)) {
433
+ const inner = this.readNested(this.pos + 2);
434
+ substitutions.push(inner.script);
435
+ this.pos = inner.end;
436
+ return src.slice(start, this.pos);
437
+ }
438
+ if (src.startsWith("${", this.pos)) {
439
+ this.pos += 2;
440
+ let depth = 1;
441
+ while (this.pos < src.length && depth > 0) {
442
+ const c = src[this.pos];
443
+ if (c === "}") {
444
+ depth -= 1;
445
+ this.pos += 1;
446
+ }
447
+ else if (c === "$" && src[this.pos + 1] === "{") {
448
+ depth += 1;
449
+ this.pos += 2;
450
+ }
451
+ else if (c === "$" || c === "`") {
452
+ this.readExpansion(substitutions);
453
+ }
454
+ else if (c === "'") {
455
+ const close = src.indexOf("'", this.pos + 1);
456
+ if (close === -1)
457
+ throw new ShellParseError("unterminated single quote");
458
+ this.pos = close + 1;
459
+ }
460
+ else if (c === "\"") {
461
+ this.pos += 1;
462
+ this.readDoubleQuoted(substitutions);
463
+ }
464
+ else if (c === "\\") {
465
+ this.pos += 2;
466
+ }
467
+ else {
468
+ this.pos += 1;
469
+ }
470
+ }
471
+ if (depth > 0)
472
+ throw new ShellParseError("unterminated parameter expansion");
473
+ return src.slice(start, this.pos);
474
+ }
475
+ this.pos += 1;
476
+ return "$";
477
+ }
478
+ /**
479
+ * `$((` starts arithmetic only when the matching close is `))`. Otherwise
480
+ * it is a command substitution whose first command is a subshell.
481
+ */
482
+ isArithmetic() {
483
+ const src = this.src;
484
+ let depth = 0;
485
+ for (let cursor = this.pos + 1; cursor < src.length; cursor += 1) {
486
+ if (src[cursor] === "(")
487
+ depth += 1;
488
+ else if (src[cursor] === ")") {
489
+ depth -= 1;
490
+ // The first time the depth falls back to 1 must be the first half of `))`.
491
+ if (depth === 1)
492
+ return src[cursor + 1] === ")";
493
+ }
494
+ }
495
+ return false;
496
+ }
497
+ /** Scans the whole input as double-quote-like text and returns its substitutions. */
498
+ collectExpansions() {
499
+ const found = [];
500
+ while (this.pos < this.src.length) {
501
+ const c = this.src[this.pos];
502
+ if (c === "\\")
503
+ this.pos += 2;
504
+ else if (c === "$" || c === "`")
505
+ this.readExpansion(found);
506
+ else
507
+ this.pos += 1;
508
+ }
509
+ return found;
510
+ }
511
+ readNested(innerStart) {
512
+ const nested = new Parser(this.src, this.base, this.depth + 1);
513
+ nested.pos = innerStart;
514
+ return nested.parse(true);
515
+ }
516
+ }
517
+ /** Finds command substitutions in text that the shell expands like a double-quoted string (unquoted heredocs, arithmetic). */
518
+ function expansionsIn(text, base, depth) {
519
+ return new Parser(text, base, depth).collectExpansions();
520
+ }
521
+ /** Parses a shell command line. `offset` is added to every recorded position. */
522
+ export function parseShell(source, offset = 0, depth = 0) {
523
+ return new Parser(source, offset, depth).parse(false).script;
524
+ }
525
+ //# sourceMappingURL=shell-parse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell-parse.js","sourceRoot":"","sources":["../../../src/runtime/conversation/shell-parse.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,EAAE;AACF,6EAA6E;AAC7E,sEAAsE;AACtE,2EAA2E;AAC3E,0EAA0E;AAC1E,sBAAsB;AA4CtB,MAAM,OAAO,eAAgB,SAAQ,KAAK;CAAG;AAE7C,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAEpC,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GA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MAAM,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC;IAC9D,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC;AAC/D,CAAC"}
package/docs/security.md CHANGED
@@ -83,8 +83,24 @@ aliases), the runtime applies a small app-owned command guard:
83
83
  allowed.
84
84
 
85
85
  The guard covers high-confidence destructive filesystem, disk, process, Git,
86
- database, infrastructure, cloud-delete, and remote-script-pipe patterns. It is
87
- not a shell parser or a sandbox. Before arbitrary shell access becomes a public
86
+ database, infrastructure, cloud-delete, and remote-script-pipe patterns, and
87
+ rejects options that make an allowed tool start another program (for example
88
+ `rg --pre`, `git -c core.pager=...` or a `GIT_PAGER`/`PAGER` value that is not a
89
+ plain pager such as `cat` or `less`). It also blocks writes to credential, SSH,
90
+ shell startup, Git config, scheduler and system locations (for example
91
+ `~/.ssh/**`, `~/.bashrc`, `~/.aws/**`, `/etc/**`, `/usr/**`), whether the write
92
+ is a redirect or the destination of `tee`, `dd of=`, `cp`, `mv`, `install` or
93
+ `ln`; it resolves `~`, `$HOME`, quoting, `..` segments and earlier `cd`
94
+ commands to do so. Writes in the workspace, `/tmp` and `/dev/null` stay
95
+ allowed. It parses common shell syntax
96
+ (quoting, redirects, chains, heredocs, substitutions, simple `{a,b}` brace
97
+ lists, and wrappers such as `sudo`, `env`, `xargs` and `sh -c`) and checks the
98
+ commands it finds. A line it cannot parse is blocked, and so is a program name
99
+ that is quoted, escaped or built from an expansion, because the guard cannot
100
+ tell which program it names. It is a best-effort
101
+ check, not a full shell: it does not evaluate variables, aliases or functions
102
+ defined earlier, nested brace or sequence expansion, or follow symlinks, and it
103
+ is not a sandbox. Before arbitrary shell access becomes a public
88
104
  feature, add an explicit consent flow bound to the exact command hash, a scoped
89
105
  working directory, environment filtering, execution timeouts, and output caps.
90
106