@pinta-ai/mcp-logger 0.4.1 → 0.4.2-dev.1010
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +1 -1
- package/node_modules/@pinta-ai/core/README.md +180 -0
- package/node_modules/@pinta-ai/core/dist/atomic-write.d.ts +9 -0
- package/node_modules/@pinta-ai/core/dist/atomic-write.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/atomic-write.js +20 -0
- package/node_modules/@pinta-ai/core/dist/atomic-write.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/credential-semantics.d.ts +20 -0
- package/node_modules/@pinta-ai/core/dist/credential-semantics.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/credential-semantics.js +156 -0
- package/node_modules/@pinta-ai/core/dist/credential-semantics.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/env-file.d.ts +17 -0
- package/node_modules/@pinta-ai/core/dist/env-file.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/env-file.js +81 -0
- package/node_modules/@pinta-ai/core/dist/env-file.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/export-mask.d.ts +26 -0
- package/node_modules/@pinta-ai/core/dist/export-mask.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/export-mask.js +202 -0
- package/node_modules/@pinta-ai/core/dist/export-mask.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/guard.d.ts +196 -0
- package/node_modules/@pinta-ai/core/dist/guard.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/guard.js +275 -0
- package/node_modules/@pinta-ai/core/dist/guard.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/index.d.ts +23 -0
- package/node_modules/@pinta-ai/core/dist/index.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/index.js +85 -0
- package/node_modules/@pinta-ai/core/dist/index.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/json-text.d.ts +45 -0
- package/node_modules/@pinta-ai/core/dist/json-text.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/json-text.js +116 -0
- package/node_modules/@pinta-ai/core/dist/json-text.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/lifecycle.d.ts +143 -0
- package/node_modules/@pinta-ai/core/dist/lifecycle.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/lifecycle.js +20 -0
- package/node_modules/@pinta-ai/core/dist/lifecycle.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/matches.d.ts +24 -0
- package/node_modules/@pinta-ai/core/dist/matches.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/matches.js +39 -0
- package/node_modules/@pinta-ai/core/dist/matches.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/mysql-password.d.ts +15 -0
- package/node_modules/@pinta-ai/core/dist/mysql-password.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/mysql-password.js +375 -0
- package/node_modules/@pinta-ai/core/dist/mysql-password.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/otlp-types.d.ts +41 -0
- package/node_modules/@pinta-ai/core/dist/otlp-types.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/otlp-types.js +7 -0
- package/node_modules/@pinta-ai/core/dist/otlp-types.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/otlp.d.ts +142 -0
- package/node_modules/@pinta-ai/core/dist/otlp.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/otlp.js +638 -0
- package/node_modules/@pinta-ai/core/dist/otlp.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/output-denial.d.ts +69 -0
- package/node_modules/@pinta-ai/core/dist/output-denial.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/output-denial.js +105 -0
- package/node_modules/@pinta-ai/core/dist/output-denial.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/redact.d.ts +65 -0
- package/node_modules/@pinta-ai/core/dist/redact.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/redact.js +193 -0
- package/node_modules/@pinta-ai/core/dist/redact.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/retry-queue.d.ts +47 -0
- package/node_modules/@pinta-ai/core/dist/retry-queue.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/retry-queue.js +177 -0
- package/node_modules/@pinta-ai/core/dist/retry-queue.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/secret-shapes.d.ts +47 -0
- package/node_modules/@pinta-ai/core/dist/secret-shapes.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/secret-shapes.js +377 -0
- package/node_modules/@pinta-ai/core/dist/secret-shapes.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/session-trace.d.ts +50 -0
- package/node_modules/@pinta-ai/core/dist/session-trace.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/session-trace.js +103 -0
- package/node_modules/@pinta-ai/core/dist/session-trace.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/shape-rules.d.ts +117 -0
- package/node_modules/@pinta-ai/core/dist/shape-rules.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/shape-rules.js +592 -0
- package/node_modules/@pinta-ai/core/dist/shape-rules.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/trace.d.ts +17 -0
- package/node_modules/@pinta-ai/core/dist/trace.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/trace.js +78 -0
- package/node_modules/@pinta-ai/core/dist/trace.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/transport.d.ts +75 -0
- package/node_modules/@pinta-ai/core/dist/transport.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/transport.js +260 -0
- package/node_modules/@pinta-ai/core/dist/transport.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/value-copies.d.ts +46 -0
- package/node_modules/@pinta-ai/core/dist/value-copies.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/value-copies.js +279 -0
- package/node_modules/@pinta-ai/core/dist/value-copies.js.map +1 -0
- package/node_modules/@pinta-ai/core/dist/value-masking.d.ts +22 -0
- package/node_modules/@pinta-ai/core/dist/value-masking.d.ts.map +1 -0
- package/node_modules/@pinta-ai/core/dist/value-masking.js +243 -0
- package/node_modules/@pinta-ai/core/dist/value-masking.js.map +1 -0
- package/node_modules/@pinta-ai/core/package.json +50 -0
- package/package.json +3 -1
|
@@ -0,0 +1,592 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Where a newly masked value may sit (PTA-735, design contract 4 ①-④).
|
|
4
|
+
*
|
|
5
|
+
* The three shapes (a value in quotes, the line after a header/YAML key, the
|
|
6
|
+
* piece after a `\`+newline) are only values when the shell would not run them
|
|
7
|
+
* and the text around them agrees:
|
|
8
|
+
*
|
|
9
|
+
* ① a command word, or a value the shell expands (`$NAME`, `${`, `$(`,
|
|
10
|
+
* backtick; inside the body of a heredoc whose delimiter is not quoted even
|
|
11
|
+
* in quotes), is not a value; a value that is just `$NAME` is a reference
|
|
12
|
+
* even in single quotes;
|
|
13
|
+
* ② a value on a later line needs its key at the start of its line, nothing
|
|
14
|
+
* after the colon, and (unquoted) nothing but a comment after the value;
|
|
15
|
+
* ③ a quote that closes a string opened earlier does not start a value;
|
|
16
|
+
* ④ after a flag, the only line break that goes on is `\`+newline.
|
|
17
|
+
*
|
|
18
|
+
* ③ is decided by the shell state for the text of a command (the value of a
|
|
19
|
+
* tool input's `command`/`cmd`), and by "an odd number of the same quote
|
|
20
|
+
* earlier on this line" for everything else (heredoc bodies included).
|
|
21
|
+
*
|
|
22
|
+
* The comparison tool that checks the result against the real sample uses the
|
|
23
|
+
* same rules, so a change here is a change of the contract: keep them equal.
|
|
24
|
+
* Every function is linear in the text it reads; the per-position questions
|
|
25
|
+
* are answered from tables built once per text.
|
|
26
|
+
*/
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.ShapeText = exports.STR = exports.ROLE = void 0;
|
|
29
|
+
exports.analyzeShell = analyzeShell;
|
|
30
|
+
exports.isKeyLine = isKeyLine;
|
|
31
|
+
exports.ROLE = { NORMAL: 0, OPEN: 1, CLOSE: 2, LIT: 3, COMMENT: 4, BODY: 5, BODY_EXP: 6 };
|
|
32
|
+
exports.STR = { NONE: 0, SQ: 1, DQ: 2, ANSI: 3 };
|
|
33
|
+
/**
|
|
34
|
+
* Follow a shell command from its first character and give every character its
|
|
35
|
+
* role: quotes that open or close a string, escaped characters, comments, and
|
|
36
|
+
* the bodies of heredocs. `$(...)`, backticks and `${...}` count as plain
|
|
37
|
+
* syntax, also inside double quotes.
|
|
38
|
+
*/
|
|
39
|
+
function analyzeShell(o) {
|
|
40
|
+
const n = o.length;
|
|
41
|
+
const role = new Uint8Array(n);
|
|
42
|
+
const str = new Uint8Array(n);
|
|
43
|
+
const st = [{ k: "cmd" }];
|
|
44
|
+
let pending = [];
|
|
45
|
+
let i = 0;
|
|
46
|
+
let wordStart = true;
|
|
47
|
+
while (i < n) {
|
|
48
|
+
const t = st[st.length - 1];
|
|
49
|
+
const c = o[i];
|
|
50
|
+
str[i] = t.k === "sq" ? exports.STR.SQ : t.k === "dq" ? exports.STR.DQ : t.k === "ansi" ? exports.STR.ANSI : 0;
|
|
51
|
+
if (t.k === "sq") {
|
|
52
|
+
if (c === "'") {
|
|
53
|
+
role[i] = exports.ROLE.CLOSE;
|
|
54
|
+
st.pop();
|
|
55
|
+
wordStart = false;
|
|
56
|
+
}
|
|
57
|
+
i++;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (t.k === "ansi") {
|
|
61
|
+
if (c === "\\") {
|
|
62
|
+
role[i] = exports.ROLE.LIT;
|
|
63
|
+
if (i + 1 < n) {
|
|
64
|
+
role[i + 1] = exports.ROLE.LIT;
|
|
65
|
+
str[i + 1] = exports.STR.ANSI;
|
|
66
|
+
}
|
|
67
|
+
i += 2;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (c === "'") {
|
|
71
|
+
role[i] = exports.ROLE.CLOSE;
|
|
72
|
+
st.pop();
|
|
73
|
+
wordStart = false;
|
|
74
|
+
}
|
|
75
|
+
i++;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (t.k === "dq") {
|
|
79
|
+
if (c === "\\") {
|
|
80
|
+
role[i] = exports.ROLE.LIT;
|
|
81
|
+
if (i + 1 < n) {
|
|
82
|
+
role[i + 1] = exports.ROLE.LIT;
|
|
83
|
+
str[i + 1] = exports.STR.DQ;
|
|
84
|
+
}
|
|
85
|
+
i += 2;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (c === '"') {
|
|
89
|
+
role[i] = exports.ROLE.CLOSE;
|
|
90
|
+
st.pop();
|
|
91
|
+
wordStart = false;
|
|
92
|
+
i++;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (c === "'") {
|
|
96
|
+
role[i] = exports.ROLE.LIT;
|
|
97
|
+
i++;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (c === "$" && o[i + 1] === "(") {
|
|
101
|
+
st.push({ k: "cs", d: 1, arith: o[i + 2] === "(" });
|
|
102
|
+
i += 2;
|
|
103
|
+
wordStart = true;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (c === "$" && o[i + 1] === "{") {
|
|
107
|
+
st.push({ k: "pe", d: 1 });
|
|
108
|
+
i += 2;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (c === "`") {
|
|
112
|
+
st.push({ k: "bt" });
|
|
113
|
+
i++;
|
|
114
|
+
wordStart = true;
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
i++;
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
// cmd / cs / bt / pe: plain syntax
|
|
121
|
+
if (pending.length > 0 && c === "\n" && (t.k === "cmd" || t.k === "cs" || t.k === "bt")) {
|
|
122
|
+
i++;
|
|
123
|
+
for (const h of pending) {
|
|
124
|
+
while (i < n) {
|
|
125
|
+
let e = o.indexOf("\n", i);
|
|
126
|
+
if (e < 0)
|
|
127
|
+
e = n;
|
|
128
|
+
const line = o.slice(i, e);
|
|
129
|
+
const cmp = h.strip ? line.replace(/^\t+/, "") : line;
|
|
130
|
+
role.fill(h.quoted ? exports.ROLE.BODY : exports.ROLE.BODY_EXP, i, e);
|
|
131
|
+
i = Math.min(n, e + 1);
|
|
132
|
+
if (cmp === h.delim)
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
pending = [];
|
|
137
|
+
wordStart = true;
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (c === "\\") {
|
|
141
|
+
role[i] = exports.ROLE.LIT;
|
|
142
|
+
if (i + 1 < n) {
|
|
143
|
+
role[i + 1] = exports.ROLE.LIT;
|
|
144
|
+
str[i + 1] = 0;
|
|
145
|
+
}
|
|
146
|
+
i += 2;
|
|
147
|
+
wordStart = false;
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (c === "#" && wordStart) {
|
|
151
|
+
let e = o.indexOf("\n", i);
|
|
152
|
+
if (e < 0)
|
|
153
|
+
e = n;
|
|
154
|
+
role.fill(exports.ROLE.COMMENT, i, e);
|
|
155
|
+
i = e;
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (c === "'") {
|
|
159
|
+
role[i] = exports.ROLE.OPEN;
|
|
160
|
+
st.push({ k: "sq" });
|
|
161
|
+
i++;
|
|
162
|
+
wordStart = false;
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
if (c === '"') {
|
|
166
|
+
role[i] = exports.ROLE.OPEN;
|
|
167
|
+
st.push({ k: "dq" });
|
|
168
|
+
i++;
|
|
169
|
+
wordStart = false;
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (c === "$" && o[i + 1] === "'") {
|
|
173
|
+
role[i + 1] = exports.ROLE.OPEN;
|
|
174
|
+
st.push({ k: "ansi" });
|
|
175
|
+
i += 2;
|
|
176
|
+
wordStart = false;
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
if (c === "$" && o[i + 1] === '"') {
|
|
180
|
+
role[i + 1] = exports.ROLE.OPEN;
|
|
181
|
+
st.push({ k: "dq" });
|
|
182
|
+
i += 2;
|
|
183
|
+
wordStart = false;
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
if (c === "$" && o[i + 1] === "(") {
|
|
187
|
+
st.push({ k: "cs", d: 1, arith: o[i + 2] === "(" });
|
|
188
|
+
i += 2;
|
|
189
|
+
wordStart = true;
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
if (c === "$" && o[i + 1] === "{") {
|
|
193
|
+
st.push({ k: "pe", d: 1 });
|
|
194
|
+
i += 2;
|
|
195
|
+
wordStart = false;
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
if (c === "`") {
|
|
199
|
+
if (t.k === "bt")
|
|
200
|
+
st.pop();
|
|
201
|
+
else
|
|
202
|
+
st.push({ k: "bt" });
|
|
203
|
+
i++;
|
|
204
|
+
wordStart = true;
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
// `((` opens an arithmetic command: a `<<` inside is a shift, not a heredoc.
|
|
208
|
+
if (c === "(" && o[i + 1] === "(" && o[i - 1] !== "$" && wordStart && (t.k === "cmd" || t.k === "cs" || t.k === "bt")) {
|
|
209
|
+
st.push({ k: "cs", d: 1, arith: true });
|
|
210
|
+
i++;
|
|
211
|
+
wordStart = true;
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
if (t.k === "cs") {
|
|
215
|
+
if (c === "(")
|
|
216
|
+
t.d++;
|
|
217
|
+
else if (c === ")") {
|
|
218
|
+
t.d--;
|
|
219
|
+
if (t.d === 0) {
|
|
220
|
+
st.pop();
|
|
221
|
+
i++;
|
|
222
|
+
wordStart = false;
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (t.k === "pe") {
|
|
228
|
+
if (c === "{")
|
|
229
|
+
t.d++;
|
|
230
|
+
else if (c === "}") {
|
|
231
|
+
t.d--;
|
|
232
|
+
if (t.d === 0) {
|
|
233
|
+
st.pop();
|
|
234
|
+
i++;
|
|
235
|
+
wordStart = false;
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
// `<<<` (here-string) is not a heredoc.
|
|
241
|
+
if (c === "<" && o[i + 1] === "<" && o[i + 2] !== "<" && o[i - 1] !== "<" && (t.k === "cmd" || t.k === "cs" || t.k === "bt") && !t.arith) {
|
|
242
|
+
let j = i + 2;
|
|
243
|
+
let strip = false;
|
|
244
|
+
if (o[j] === "-") {
|
|
245
|
+
strip = true;
|
|
246
|
+
j++;
|
|
247
|
+
}
|
|
248
|
+
while (o[j] === " " || o[j] === "\t")
|
|
249
|
+
j++;
|
|
250
|
+
// The delimiter is one shell word. Quotes and backslashes are removed from
|
|
251
|
+
// it, and any of them means the body is not expanded.
|
|
252
|
+
let delim = "";
|
|
253
|
+
let quoted = false;
|
|
254
|
+
while (j < n && delim.length < 200) {
|
|
255
|
+
const ch = o[j];
|
|
256
|
+
if (/[\s;&|()<>]/.test(ch))
|
|
257
|
+
break;
|
|
258
|
+
if (ch === "'" || ch === '"') {
|
|
259
|
+
const e = o.indexOf(ch, j + 1);
|
|
260
|
+
if (e < 0) {
|
|
261
|
+
delim = "";
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
delim += o.slice(j + 1, e);
|
|
265
|
+
quoted = true;
|
|
266
|
+
j = e + 1;
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
if (ch === "\\") {
|
|
270
|
+
if (j + 1 >= n)
|
|
271
|
+
break;
|
|
272
|
+
delim += o[j + 1];
|
|
273
|
+
quoted = true;
|
|
274
|
+
j += 2;
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
delim += ch;
|
|
278
|
+
j++;
|
|
279
|
+
}
|
|
280
|
+
if (delim) {
|
|
281
|
+
pending.push({ delim, strip, quoted });
|
|
282
|
+
i = j;
|
|
283
|
+
wordStart = false;
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
wordStart = /[\s;&|()}<>]/.test(c);
|
|
288
|
+
i++;
|
|
289
|
+
}
|
|
290
|
+
return { role, str };
|
|
291
|
+
}
|
|
292
|
+
const KEYWORDS = ["then", "do", "else", "elif"];
|
|
293
|
+
const KEY_TAIL_BLOCK = /^[|>][+\-0-9]*/;
|
|
294
|
+
/**
|
|
295
|
+
* Is `line` (no line break, no trailing blank) a key and nothing else: indent,
|
|
296
|
+
* optional `- ` markers, a key, a colon, and at most a block-scalar marker?
|
|
297
|
+
* Written as a scan: the same rule as one regular expression would be, but that
|
|
298
|
+
* expression backtracks without bound on a long line of blanks.
|
|
299
|
+
*/
|
|
300
|
+
function isKeyLine(line) {
|
|
301
|
+
const n = line.length;
|
|
302
|
+
const blank = (c) => c === " " || c === "\t";
|
|
303
|
+
let indent = 0;
|
|
304
|
+
while (indent < n && blank(line[indent]))
|
|
305
|
+
indent++;
|
|
306
|
+
let i = indent;
|
|
307
|
+
let dashes = 0;
|
|
308
|
+
while (line[i] === "-" && blank(line[i + 1])) {
|
|
309
|
+
dashes++;
|
|
310
|
+
i++;
|
|
311
|
+
while (i < n && blank(line[i]))
|
|
312
|
+
i++;
|
|
313
|
+
}
|
|
314
|
+
// After the list markers, or (a key may itself start with a dash) right after the indent.
|
|
315
|
+
return keyThenColon(line, i, true) || (dashes > 0 && keyThenColon(line, indent, false));
|
|
316
|
+
}
|
|
317
|
+
function keyThenColon(line, from, quotedKey) {
|
|
318
|
+
const n = line.length;
|
|
319
|
+
const blank = (c) => c === " " || c === "\t";
|
|
320
|
+
let i = from;
|
|
321
|
+
if (i >= n)
|
|
322
|
+
return false;
|
|
323
|
+
const first = line[i];
|
|
324
|
+
if (first === '"' || first === "'") {
|
|
325
|
+
if (!quotedKey)
|
|
326
|
+
return false;
|
|
327
|
+
const close = line.indexOf(first, i + 1);
|
|
328
|
+
if (close < 0)
|
|
329
|
+
return false;
|
|
330
|
+
i = close + 1;
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
if (/[\s:#]/.test(first))
|
|
334
|
+
return false;
|
|
335
|
+
// The key runs to the first colon; a `#` or the end before it is no key.
|
|
336
|
+
let j = i + 1;
|
|
337
|
+
while (j < n && line[j] !== ":" && line[j] !== "#")
|
|
338
|
+
j++;
|
|
339
|
+
if (j >= n || line[j] !== ":")
|
|
340
|
+
return false;
|
|
341
|
+
i = j;
|
|
342
|
+
}
|
|
343
|
+
while (i < n && blank(line[i]))
|
|
344
|
+
i++;
|
|
345
|
+
if (line[i] !== ":")
|
|
346
|
+
return false;
|
|
347
|
+
i++;
|
|
348
|
+
while (i < n && blank(line[i]))
|
|
349
|
+
i++;
|
|
350
|
+
const block = KEY_TAIL_BLOCK.exec(line.slice(i, i + 16));
|
|
351
|
+
if (block)
|
|
352
|
+
i += block[0].length;
|
|
353
|
+
while (i < n && blank(line[i]))
|
|
354
|
+
i++;
|
|
355
|
+
return i === n;
|
|
356
|
+
}
|
|
357
|
+
const isWhite = (c) => c === " " || c === "\n" || c === "\t" || c === "\r" || (c > "\x7f" || c < "!") && /\s/.test(c);
|
|
358
|
+
const isLetter = (c) => c !== undefined && /[A-Za-z]/.test(c);
|
|
359
|
+
/**
|
|
360
|
+
* One text and the answers about its positions. The tables behind the answers
|
|
361
|
+
* (the shell state of a command, the quote parity of each line) are built the
|
|
362
|
+
* first time they are asked for.
|
|
363
|
+
*/
|
|
364
|
+
class ShapeText {
|
|
365
|
+
text;
|
|
366
|
+
command;
|
|
367
|
+
shellState;
|
|
368
|
+
parity;
|
|
369
|
+
/**
|
|
370
|
+
* @param command the text is the value of a tool input's `command`/`cmd`:
|
|
371
|
+
* follow it as shell. Any other text is read line by line.
|
|
372
|
+
*/
|
|
373
|
+
constructor(text, command) {
|
|
374
|
+
this.text = text;
|
|
375
|
+
this.command = command;
|
|
376
|
+
}
|
|
377
|
+
get shell() {
|
|
378
|
+
if (this.shellState === undefined)
|
|
379
|
+
this.shellState = this.command ? analyzeShell(this.text) : null;
|
|
380
|
+
return this.shellState;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* `parity.sq[i]` is the number (mod 2) of single quotes earlier on the line of
|
|
384
|
+
* position `i` that count as quotes: not after a backslash, and for the single
|
|
385
|
+
* quote not an apostrophe between two letters. `dq` is the same for `"`.
|
|
386
|
+
*/
|
|
387
|
+
tables() {
|
|
388
|
+
if (this.parity)
|
|
389
|
+
return this.parity;
|
|
390
|
+
const text = this.text;
|
|
391
|
+
const n = text.length;
|
|
392
|
+
const sq = new Uint8Array(n + 1);
|
|
393
|
+
const dq = new Uint8Array(n + 1);
|
|
394
|
+
let a = 0;
|
|
395
|
+
let b = 0;
|
|
396
|
+
for (let i = 0; i < n; i++) {
|
|
397
|
+
sq[i] = a;
|
|
398
|
+
dq[i] = b;
|
|
399
|
+
const c = text[i];
|
|
400
|
+
if (c === "\n") {
|
|
401
|
+
a = 0;
|
|
402
|
+
b = 0;
|
|
403
|
+
}
|
|
404
|
+
else if (c === "'") {
|
|
405
|
+
if (!(i > 0 && text[i - 1] === "\\") && !(i > 0 && isLetter(text[i - 1]) && isLetter(text[i + 1])))
|
|
406
|
+
a ^= 1;
|
|
407
|
+
}
|
|
408
|
+
else if (c === '"') {
|
|
409
|
+
if (!(i > 0 && text[i - 1] === "\\"))
|
|
410
|
+
b ^= 1;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
sq[n] = a;
|
|
414
|
+
dq[n] = b;
|
|
415
|
+
this.parity = { sq, dq };
|
|
416
|
+
return this.parity;
|
|
417
|
+
}
|
|
418
|
+
/** The quote at `pos` closes a string opened earlier on its line. */
|
|
419
|
+
lineParityCloses(pos) {
|
|
420
|
+
const t = this.tables();
|
|
421
|
+
return ((this.text[pos] === "'" ? t.sq : t.dq)[pos] ?? 0) === 1;
|
|
422
|
+
}
|
|
423
|
+
/** The quote at `pos` closes a string opened before it (so it does not start a value, ③). */
|
|
424
|
+
isClosingQuote(pos) {
|
|
425
|
+
const q = this.text[pos];
|
|
426
|
+
if (q !== "'" && q !== '"')
|
|
427
|
+
return false;
|
|
428
|
+
const shell = this.shell;
|
|
429
|
+
if (shell) {
|
|
430
|
+
const r = shell.role[pos];
|
|
431
|
+
if (r === exports.ROLE.CLOSE)
|
|
432
|
+
return true;
|
|
433
|
+
if (r === exports.ROLE.OPEN)
|
|
434
|
+
return false;
|
|
435
|
+
}
|
|
436
|
+
return this.lineParityCloses(pos);
|
|
437
|
+
}
|
|
438
|
+
/** A value the shell would expand (or that is only a variable) is not a value (①). */
|
|
439
|
+
expansionBlocksValue(s, e) {
|
|
440
|
+
const v = this.text.slice(s, e);
|
|
441
|
+
if (/^\$\{?[A-Za-z_][A-Za-z0-9_]*\}?$/.test(v))
|
|
442
|
+
return true;
|
|
443
|
+
if (!/(?:^|[^\\])(?:\$\(|\$\{|`|\$[A-Za-z_])/.test(v))
|
|
444
|
+
return false;
|
|
445
|
+
const shell = this.shell;
|
|
446
|
+
if (shell) {
|
|
447
|
+
const r = shell.role[s];
|
|
448
|
+
if (r === exports.ROLE.BODY_EXP)
|
|
449
|
+
return true;
|
|
450
|
+
// A heredoc body with a quoted delimiter is not expanded, but it is usually written out and run later (50722,
|
|
451
|
+
// `--password='$(cmd)'` inside a script it writes): a value with an expansion is not a value there either.
|
|
452
|
+
if (r === exports.ROLE.BODY)
|
|
453
|
+
return true;
|
|
454
|
+
const k = shell.str[s];
|
|
455
|
+
return !(k === exports.STR.SQ || k === exports.STR.ANSI);
|
|
456
|
+
}
|
|
457
|
+
return this.text[s - 1] !== "'";
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* The value stands where the shell reads a command word: outside any string,
|
|
461
|
+
* after a line start, `;`, `|`, `&`, `(`, or `then`/`do`/`else`/`elif`, looking
|
|
462
|
+
* over line continuations. Text that is not a command has no command words.
|
|
463
|
+
*/
|
|
464
|
+
commandWordAt(s) {
|
|
465
|
+
const shell = this.shell;
|
|
466
|
+
if (!shell)
|
|
467
|
+
return false;
|
|
468
|
+
const text = this.text;
|
|
469
|
+
const isQ = s > 0 && (text[s - 1] === "'" || text[s - 1] === '"');
|
|
470
|
+
const lead = isQ ? s - 1 : s;
|
|
471
|
+
if (shell.str[lead] !== exports.STR.NONE || shell.role[lead] !== (isQ ? exports.ROLE.OPEN : exports.ROLE.NORMAL))
|
|
472
|
+
return false;
|
|
473
|
+
let q = lead;
|
|
474
|
+
for (;;) {
|
|
475
|
+
while (q > 0 && (text[q - 1] === " " || text[q - 1] === "\t"))
|
|
476
|
+
q--;
|
|
477
|
+
if (q >= 2 && text[q - 1] === "\n" && text[q - 2] === "\\") {
|
|
478
|
+
q -= 2;
|
|
479
|
+
continue;
|
|
480
|
+
}
|
|
481
|
+
break;
|
|
482
|
+
}
|
|
483
|
+
if (q === 0 || text[q - 1] === "\n")
|
|
484
|
+
return true;
|
|
485
|
+
if (";|&(".includes(text[q - 1]))
|
|
486
|
+
return true;
|
|
487
|
+
return this.endsWithKeyword(q, 0, /[\s;&|(){}]/);
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* `text[floor..end)` ends with `then`, `do`, `else` or `elif`, which starts at
|
|
491
|
+
* `floor` or follows a character matching `before`.
|
|
492
|
+
*/
|
|
493
|
+
endsWithKeyword(end, floor, before) {
|
|
494
|
+
for (const w of KEYWORDS) {
|
|
495
|
+
const from = end - w.length;
|
|
496
|
+
if (from < floor || this.text.slice(from, end) !== w)
|
|
497
|
+
continue;
|
|
498
|
+
if (from === floor || before.test(this.text[from - 1]))
|
|
499
|
+
return true;
|
|
500
|
+
}
|
|
501
|
+
return false;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Which of the three shapes the value `[s, e)` stands in, and the first of
|
|
505
|
+
* ①-④ it breaks. `shape` is null when it stands in none.
|
|
506
|
+
*/
|
|
507
|
+
evalShape(s, e) {
|
|
508
|
+
const text = this.text;
|
|
509
|
+
const isQ = s > 0 && (text[s - 1] === "'" || text[s - 1] === '"');
|
|
510
|
+
const lead = isQ ? s - 1 : s;
|
|
511
|
+
let q = lead;
|
|
512
|
+
while (q > 0 && isWhite(text[q - 1]))
|
|
513
|
+
q--;
|
|
514
|
+
// A YAML list item (`token:\n - value`) is the key's next-line value: look past its `-`.
|
|
515
|
+
if (q > 0 && text[q - 1] === "-") {
|
|
516
|
+
let dash = q - 1;
|
|
517
|
+
while (dash > 0 && (text[dash - 1] === " " || text[dash - 1] === "\t"))
|
|
518
|
+
dash--;
|
|
519
|
+
if (dash > 0 && text[dash - 1] === "\n") {
|
|
520
|
+
q = dash;
|
|
521
|
+
while (q > 0 && isWhite(text[q - 1]))
|
|
522
|
+
q--;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
let shape = null;
|
|
526
|
+
let newlines = 0;
|
|
527
|
+
for (let k = q; k < lead; k++)
|
|
528
|
+
if (text[k] === "\n")
|
|
529
|
+
newlines++;
|
|
530
|
+
if (newlines > 0) {
|
|
531
|
+
let backslashes = 0;
|
|
532
|
+
for (let k = q - 1; k >= 0 && text[k] === "\\"; k--)
|
|
533
|
+
backslashes++;
|
|
534
|
+
shape = backslashes % 2 === 1 && newlines === 1 ? "continuation" : "next-line";
|
|
535
|
+
}
|
|
536
|
+
else if (isQ)
|
|
537
|
+
shape = "quoted";
|
|
538
|
+
if (shape === null)
|
|
539
|
+
return { shape: null, violation: null };
|
|
540
|
+
if (isQ && this.isClosingQuote(s - 1))
|
|
541
|
+
return { shape, violation: "③" };
|
|
542
|
+
const shell = this.shell;
|
|
543
|
+
const blocks = () => this.expansionBlocksValue(s, e);
|
|
544
|
+
const commandSlot = !!shell && shell.str[lead] === exports.STR.NONE && shell.role[lead] === (isQ ? exports.ROLE.OPEN : exports.ROLE.NORMAL);
|
|
545
|
+
if (shape === "quoted")
|
|
546
|
+
return { shape, violation: blocks() || this.commandWordAt(s) ? "①" : null };
|
|
547
|
+
if (shape === "next-line") {
|
|
548
|
+
const ls = text.lastIndexOf("\n", q - 1) + 1;
|
|
549
|
+
// A key line is short; a longer one is not read.
|
|
550
|
+
if (q - ls > MAX_KEY_LINE || !isKeyLine(text.slice(ls, q)))
|
|
551
|
+
return { shape, violation: "②" };
|
|
552
|
+
if (!isQ) {
|
|
553
|
+
let le = text.indexOf("\n", e);
|
|
554
|
+
if (le < 0)
|
|
555
|
+
le = text.length;
|
|
556
|
+
if (!/^[ \t]*(?:#.*)?$/.test(text.slice(e, le)))
|
|
557
|
+
return { shape, violation: "②" };
|
|
558
|
+
}
|
|
559
|
+
if (commandSlot)
|
|
560
|
+
return { shape, violation: "①" };
|
|
561
|
+
return { shape, violation: blocks() ? "①" : null };
|
|
562
|
+
}
|
|
563
|
+
// continuation: a separator before the backslash makes the next word a command word.
|
|
564
|
+
if (commandSlot) {
|
|
565
|
+
let end = q - 1;
|
|
566
|
+
const ls = text.lastIndexOf("\n", end - 1) + 1;
|
|
567
|
+
while (end > ls && isWhite(text[end - 1]))
|
|
568
|
+
end--;
|
|
569
|
+
const two = text.slice(Math.max(ls, end - 2), end);
|
|
570
|
+
if (two === "&&" || two === "||" || (end > ls && "&;|({".includes(text[end - 1])))
|
|
571
|
+
return { shape, violation: "①" };
|
|
572
|
+
if (this.endsWithKeyword(end, ls, /\s/))
|
|
573
|
+
return { shape, violation: "①" };
|
|
574
|
+
}
|
|
575
|
+
return { shape, violation: blocks() ? "①" : null };
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* May a literal copy of a value be replaced where it stands at `[s, e)`? The
|
|
579
|
+
* copy is looked at as a new value in the place it landed (⑤): a place in one
|
|
580
|
+
* of the three shapes must keep ①-④, any other place only ①.
|
|
581
|
+
*/
|
|
582
|
+
copyAllowed(s, e) {
|
|
583
|
+
const r = this.evalShape(s, e);
|
|
584
|
+
if (r.shape !== null)
|
|
585
|
+
return r.violation === null;
|
|
586
|
+
return !(this.expansionBlocksValue(s, e) || this.commandWordAt(s));
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
exports.ShapeText = ShapeText;
|
|
590
|
+
/** A key line longer than this is not a key (it also bounds the work per value). */
|
|
591
|
+
const MAX_KEY_LINE = 512;
|
|
592
|
+
//# sourceMappingURL=shape-rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shape-rules.js","sourceRoot":"","sources":["../src/shape-rules.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;AA8BH,oCAkPC;AAWD,8BAcC;AAvSY,QAAA,IAAI,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAW,CAAC;AAC3F,QAAA,GAAG,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAW,CAAC;AAqB/D;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,CAAS;IACpC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IACnB,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IAC9B,MAAM,EAAE,GAAY,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACnC,IAAI,OAAO,GAAc,EAAE,CAAC;IAC5B,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,IAAI,SAAS,GAAG,IAAI,CAAC;IACrB,OAAO,CAAC,GAA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;;;OAIG;IACH,WAAW,CAAC,CAAS,EAAE,CAAS;QAC9B,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC/B,IAAI,CAAC,CAAC,KAAK,KAAK,IAAI;YAAE,OAAO,CAAC,CAAC,SAAS,KAAK,IAAI,CAAC;QAClD,OAAO,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IACrE,CAAC;CACF;AA9LD,8BA8LC;AAED,oFAAoF;AACpF,MAAM,YAAY,GAAG,GAAG,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Generate a 26-char Crockford ULID (48-bit ms timestamp + 80-bit randomness). */
|
|
2
|
+
export declare function generateUlid(): string;
|
|
3
|
+
/**
|
|
4
|
+
* Persists the current trace id to a JSON file so successive short-lived hook
|
|
5
|
+
* processes share one trace per session. `tracePath` is adapter-specific
|
|
6
|
+
* (derived from the adapter's plugin-data dir).
|
|
7
|
+
*/
|
|
8
|
+
export declare class TraceManager {
|
|
9
|
+
private tracePath;
|
|
10
|
+
constructor(tracePath: string);
|
|
11
|
+
/** Generate and persist a fresh trace id (e.g. on UserPromptSubmit). */
|
|
12
|
+
newTrace(): string;
|
|
13
|
+
/** Return the current trace id, generating one if no trace file exists. */
|
|
14
|
+
currentTrace(): string;
|
|
15
|
+
private save;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=trace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../src/trace.ts"],"names":[],"mappings":"AAOA,mFAAmF;AACnF,wBAAgB,YAAY,IAAI,MAAM,CAkBrC;AAED;;;;GAIG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,SAAS,CAAS;gBAEd,SAAS,EAAE,MAAM;IAI7B,wEAAwE;IACxE,QAAQ,IAAI,MAAM;IAMlB,2EAA2E;IAC3E,YAAY,IAAI,MAAM;IAWtB,OAAO,CAAC,IAAI;CAYb"}
|