@moxt-ai/mobius 0.0.456 → 0.0.458
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/THIRD-PARTY-NOTICES.txt +27 -0
- package/dist/{chunk-H3JQ3BX5.js → chunk-BHWFDFZG.js} +3 -2
- package/dist/{chunk-H3JQ3BX5.js.map → chunk-BHWFDFZG.js.map} +2 -2
- package/dist/{chunk-GUE7ZQI6.js → chunk-TDFSYA4U.js} +1567 -87
- package/dist/{chunk-GUE7ZQI6.js.map → chunk-TDFSYA4U.js.map} +4 -4
- package/dist/{cli-E4GLG6NB.js → cli-DHEOX6YM.js} +3 -3
- package/dist/cli.js +2 -2
- package/dist/engine/acp/adapter/antigravity/background-wakeup.d.ts.map +1 -1
- package/dist/engine/acp/adapter/antigravity/background-wakeup.js +58 -6
- package/dist/engine/acp/adapter/antigravity/background-wakeup.js.map +1 -1
- package/dist/engine/runtime/command/registry/index.d.ts.map +1 -1
- package/dist/engine/runtime/command/registry/index.js +3 -0
- package/dist/engine/runtime/command/registry/index.js.map +1 -1
- package/dist/engine/runtime/command/registry/runtime.d.ts.map +1 -1
- package/dist/engine/runtime/command/registry/runtime.js +1 -0
- package/dist/engine/runtime/command/registry/runtime.js.map +1 -1
- package/dist/engine/runtime/command/registry/workspace-files.d.ts +4 -0
- package/dist/engine/runtime/command/registry/workspace-files.d.ts.map +1 -0
- package/dist/engine/runtime/command/registry/workspace-files.js +77 -0
- package/dist/engine/runtime/command/registry/workspace-files.js.map +1 -0
- package/dist/engine/session/content/session-files.d.ts +6 -1
- package/dist/engine/session/content/session-files.d.ts.map +1 -1
- package/dist/engine/session/content/session-files.js +37 -24
- package/dist/engine/session/content/session-files.js.map +1 -1
- package/dist/engine/storage/files/local-files.d.ts +1 -2
- package/dist/engine/storage/files/local-files.d.ts.map +1 -1
- package/dist/engine/storage/files/workspace-files.d.ts +40 -0
- package/dist/engine/storage/files/workspace-files.d.ts.map +1 -0
- package/dist/engine/storage/files/workspace-files.js +505 -0
- package/dist/engine/storage/files/workspace-files.js.map +1 -0
- package/dist/engine.js +2 -2
- package/package.json +3 -2
- /package/dist/{cli-E4GLG6NB.js.map → cli-DHEOX6YM.js.map} +0 -0
|
@@ -1,9 +1,811 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__callDispose,
|
|
3
|
+
__commonJS,
|
|
3
4
|
__export,
|
|
5
|
+
__toESM,
|
|
4
6
|
__using,
|
|
5
7
|
package_default
|
|
6
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-BHWFDFZG.js";
|
|
9
|
+
|
|
10
|
+
// ../../node_modules/.pnpm/ignore@7.0.9/node_modules/ignore/index.js
|
|
11
|
+
var require_ignore = __commonJS({
|
|
12
|
+
"../../node_modules/.pnpm/ignore@7.0.9/node_modules/ignore/index.js"(exports, module) {
|
|
13
|
+
function makeArray(subject) {
|
|
14
|
+
return Array.isArray(subject) ? subject : [subject];
|
|
15
|
+
}
|
|
16
|
+
var UNDEFINED = void 0;
|
|
17
|
+
var EMPTY = "";
|
|
18
|
+
var SPACE = " ";
|
|
19
|
+
var ESCAPE = "\\";
|
|
20
|
+
var REGEX_LITERAL_SPECIAL = /[.*+?()[\]{}^$|\\/]/;
|
|
21
|
+
var REGEX_TEST_BLANK_LINE = /^\uFEFF? *$/;
|
|
22
|
+
var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
|
|
23
|
+
var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
|
|
24
|
+
var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
|
|
25
|
+
var REGEX_SPLITALL_CRLF = /\r?\n/g;
|
|
26
|
+
var DOUBLE_SLASH = "//";
|
|
27
|
+
var SLASH_CODE = 47;
|
|
28
|
+
var DOT_CODE = 46;
|
|
29
|
+
var SLASH = "/";
|
|
30
|
+
var TMP_KEY_IGNORE = "node-ignore";
|
|
31
|
+
if (typeof Symbol !== "undefined") {
|
|
32
|
+
TMP_KEY_IGNORE = /* @__PURE__ */ Symbol.for("node-ignore");
|
|
33
|
+
}
|
|
34
|
+
var KEY_IGNORE = TMP_KEY_IGNORE;
|
|
35
|
+
var define2 = (object2, key, value) => {
|
|
36
|
+
Object.defineProperty(object2, key, { value });
|
|
37
|
+
return value;
|
|
38
|
+
};
|
|
39
|
+
var RETURN_FALSE = () => false;
|
|
40
|
+
var cleanRangeBackSlash = (slashes) => {
|
|
41
|
+
const { length } = slashes;
|
|
42
|
+
return slashes.slice(0, length - length % 2);
|
|
43
|
+
};
|
|
44
|
+
var POSIX_CLASSES = {
|
|
45
|
+
alnum: "0-9A-Za-z",
|
|
46
|
+
alpha: "A-Za-z",
|
|
47
|
+
blank: " \\t",
|
|
48
|
+
cntrl: "\\x00-\\x1f\\x7f",
|
|
49
|
+
digit: "0-9",
|
|
50
|
+
graph: "!-.0-~",
|
|
51
|
+
lower: "a-z",
|
|
52
|
+
print: " -.0-~",
|
|
53
|
+
punct: "!-.:-@\\[-`{-~",
|
|
54
|
+
// git's `sane-ctype.h` classifies \v and \f as control, not space,
|
|
55
|
+
// unlike C's `isspace`
|
|
56
|
+
space: " \\t\\n\\r",
|
|
57
|
+
upper: "A-Z",
|
|
58
|
+
xdigit: "0-9A-Fa-f"
|
|
59
|
+
};
|
|
60
|
+
var CLASS_MEMBERS_TO_ESCAPE = "\\]^-[";
|
|
61
|
+
var escapeMember = (char) => CLASS_MEMBERS_TO_ESCAPE.indexOf(char) < 0 ? char : ESCAPE + char;
|
|
62
|
+
var NON_SLASH = "(?!\\/)";
|
|
63
|
+
var classSource = (negated, body) => {
|
|
64
|
+
if (negated) {
|
|
65
|
+
return `[^\\/${body}]`;
|
|
66
|
+
}
|
|
67
|
+
const source = `[${body}]`;
|
|
68
|
+
return new RegExp(source).test("/") ? NON_SLASH + source : source;
|
|
69
|
+
};
|
|
70
|
+
var scanBracket = (pattern, start) => {
|
|
71
|
+
const { length } = pattern;
|
|
72
|
+
let index2 = start + 1;
|
|
73
|
+
let negated = EMPTY;
|
|
74
|
+
const lead = pattern[index2];
|
|
75
|
+
if (lead === "!" || lead === "^") {
|
|
76
|
+
negated = "^";
|
|
77
|
+
index2++;
|
|
78
|
+
}
|
|
79
|
+
let body = EMPTY;
|
|
80
|
+
let prev = EMPTY;
|
|
81
|
+
for (; ; ) {
|
|
82
|
+
const char = pattern[index2];
|
|
83
|
+
if (char === UNDEFINED) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
if (char === ESCAPE) {
|
|
87
|
+
const escaped = pattern[index2 + 1];
|
|
88
|
+
if (escaped === UNDEFINED) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
body += escapeMember(escaped);
|
|
92
|
+
prev = escaped;
|
|
93
|
+
index2++;
|
|
94
|
+
} else if (char === "-" && prev && index2 + 1 < length && pattern[index2 + 1] !== "]") {
|
|
95
|
+
index2++;
|
|
96
|
+
let to2 = pattern[index2];
|
|
97
|
+
if (to2 === ESCAPE) {
|
|
98
|
+
to2 = pattern[index2 += 1];
|
|
99
|
+
}
|
|
100
|
+
if (prev <= to2) {
|
|
101
|
+
body += `-${escapeMember(to2)}`;
|
|
102
|
+
}
|
|
103
|
+
prev = EMPTY;
|
|
104
|
+
} else if (char === "[" && pattern[index2 + 1] === ":") {
|
|
105
|
+
const nameStart = index2 + 2;
|
|
106
|
+
let end = nameStart;
|
|
107
|
+
while (end < length && pattern[end] !== "]") {
|
|
108
|
+
end++;
|
|
109
|
+
}
|
|
110
|
+
if (end === length) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
if (end > nameStart && pattern[end - 1] === ":") {
|
|
114
|
+
const expanded = POSIX_CLASSES[pattern.slice(nameStart, end - 1)];
|
|
115
|
+
if (expanded === UNDEFINED) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
body += expanded;
|
|
119
|
+
prev = EMPTY;
|
|
120
|
+
index2 = end;
|
|
121
|
+
} else {
|
|
122
|
+
body += escapeMember("[");
|
|
123
|
+
prev = "[";
|
|
124
|
+
index2 = nameStart - 2;
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
body += escapeMember(char);
|
|
128
|
+
prev = char;
|
|
129
|
+
}
|
|
130
|
+
index2++;
|
|
131
|
+
if (pattern[index2] === "]") {
|
|
132
|
+
return {
|
|
133
|
+
end: index2,
|
|
134
|
+
source: classSource(negated, body)
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
var NEVER_MATCH = "[]";
|
|
140
|
+
var PLACEHOLDER = "\0";
|
|
141
|
+
var REGEX_RESTORE_PLACEHOLDER = new RegExp(
|
|
142
|
+
`${PLACEHOLDER}(\\d+)${PLACEHOLDER}`,
|
|
143
|
+
"g"
|
|
144
|
+
);
|
|
145
|
+
var TRAILING_WILDCARD = "\uE000";
|
|
146
|
+
var extractBrackets = (pattern) => {
|
|
147
|
+
const sources = [];
|
|
148
|
+
const hold = (source) => `${PLACEHOLDER}${sources.push(source) - 1}${PLACEHOLDER}`;
|
|
149
|
+
const { length } = pattern;
|
|
150
|
+
let out2 = EMPTY;
|
|
151
|
+
let index2 = 0;
|
|
152
|
+
while (index2 < length) {
|
|
153
|
+
const char = pattern[index2];
|
|
154
|
+
if (char === ESCAPE) {
|
|
155
|
+
const escaped = pattern[index2 + 1];
|
|
156
|
+
if (escaped === "*" || escaped === "[" || escaped === SPACE || escaped === ESCAPE) {
|
|
157
|
+
out2 += pattern.slice(index2, index2 + 2);
|
|
158
|
+
} else {
|
|
159
|
+
out2 += hold(
|
|
160
|
+
REGEX_LITERAL_SPECIAL.test(escaped) ? ESCAPE + escaped : escaped
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
index2 += 2;
|
|
164
|
+
} else if (char === PLACEHOLDER) {
|
|
165
|
+
out2 += hold(`[${PLACEHOLDER}]`);
|
|
166
|
+
index2++;
|
|
167
|
+
} else if (char === "[") {
|
|
168
|
+
const scanned = scanBracket(pattern, index2);
|
|
169
|
+
if (scanned === null) {
|
|
170
|
+
out2 += hold(NEVER_MATCH);
|
|
171
|
+
index2 = length;
|
|
172
|
+
} else {
|
|
173
|
+
out2 += hold(scanned.source);
|
|
174
|
+
index2 = scanned.end + 1;
|
|
175
|
+
}
|
|
176
|
+
} else {
|
|
177
|
+
out2 += char;
|
|
178
|
+
index2++;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return {
|
|
182
|
+
source: out2,
|
|
183
|
+
sources
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
var DIRECT = null;
|
|
187
|
+
var REGEX_INNER_SLASH = /\/(?!$)/;
|
|
188
|
+
var REPLACERS = [
|
|
189
|
+
[
|
|
190
|
+
// Remove BOM
|
|
191
|
+
// TODO:
|
|
192
|
+
// Other similar zero-width characters?
|
|
193
|
+
/^\uFEFF/,
|
|
194
|
+
() => EMPTY,
|
|
195
|
+
"\uFEFF"
|
|
196
|
+
],
|
|
197
|
+
[
|
|
198
|
+
// A trailing line terminator, left on when a whole file's contents are
|
|
199
|
+
// added as one pattern rather than split into lines. git never sees one
|
|
200
|
+
// -- it reads a `.gitignore` line by line -- so it is not part of the
|
|
201
|
+
// pattern and is dropped here, apart from the trailing-space trimming,
|
|
202
|
+
// which follows git in touching spaces and nothing else.
|
|
203
|
+
/[\r\n]+$/,
|
|
204
|
+
() => EMPTY
|
|
205
|
+
],
|
|
206
|
+
// > Trailing spaces are ignored unless they are quoted with backslash ("\")
|
|
207
|
+
[
|
|
208
|
+
// Only spaces, never tabs or other whitespace: git trims a trailing run
|
|
209
|
+
// of `' '` and nothing else (dir.c, `trim_trailing_spaces`, a single
|
|
210
|
+
// `case ' '`), so a pattern ending in a tab keeps it as a literal.
|
|
211
|
+
// (a\ ) -> (a )
|
|
212
|
+
// (a ) -> (a)
|
|
213
|
+
// (a ) -> (a)
|
|
214
|
+
// (a \ ) -> (a )
|
|
215
|
+
/((?:\\\\)*?)(\\? +)$/,
|
|
216
|
+
(_, m12, m22) => m12 + (m22.indexOf("\\") === 0 ? SPACE : EMPTY)
|
|
217
|
+
],
|
|
218
|
+
// Replace (\ ) with ' '
|
|
219
|
+
// Only a space: an escaped tab or other whitespace is already a literal by
|
|
220
|
+
// the time it reaches here, and a bare tab must be left as one, not turned
|
|
221
|
+
// into a space.
|
|
222
|
+
// (\ ) -> ' '
|
|
223
|
+
// (\\ ) -> '\\ '
|
|
224
|
+
// (\\\ ) -> '\\ '
|
|
225
|
+
[
|
|
226
|
+
/(\\+?) /g,
|
|
227
|
+
(_, m12) => {
|
|
228
|
+
const { length } = m12;
|
|
229
|
+
return m12.slice(0, length - length % 2) + SPACE;
|
|
230
|
+
}
|
|
231
|
+
],
|
|
232
|
+
// Escape metacharacters
|
|
233
|
+
// which is written down by users but means special for regular expressions.
|
|
234
|
+
// > There are 12 characters with special meanings:
|
|
235
|
+
// > - the backslash \,
|
|
236
|
+
// > - the caret ^,
|
|
237
|
+
// > - the dollar sign $,
|
|
238
|
+
// > - the period or dot .,
|
|
239
|
+
// > - the vertical bar or pipe symbol |,
|
|
240
|
+
// > - the question mark ?,
|
|
241
|
+
// > - the asterisk or star *,
|
|
242
|
+
// > - the plus sign +,
|
|
243
|
+
// > - the opening parenthesis (,
|
|
244
|
+
// > - the closing parenthesis ),
|
|
245
|
+
// > - and the opening square bracket [,
|
|
246
|
+
// > - the opening curly brace {,
|
|
247
|
+
// > These special characters are often called "metacharacters".
|
|
248
|
+
[
|
|
249
|
+
/[\\$.|*+(){^]/g,
|
|
250
|
+
(match) => `\\${match}`
|
|
251
|
+
],
|
|
252
|
+
[
|
|
253
|
+
// > a question mark (?) matches a single character
|
|
254
|
+
/(?!\\)\?/g,
|
|
255
|
+
() => "[^/]",
|
|
256
|
+
"?"
|
|
257
|
+
],
|
|
258
|
+
// leading slash
|
|
259
|
+
[
|
|
260
|
+
// > A leading slash matches the beginning of the pathname.
|
|
261
|
+
// > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
|
|
262
|
+
// A leading slash matches the beginning of the pathname
|
|
263
|
+
/^\//,
|
|
264
|
+
() => "^",
|
|
265
|
+
SLASH
|
|
266
|
+
],
|
|
267
|
+
// replace special metacharacter slash after the leading slash
|
|
268
|
+
[
|
|
269
|
+
/\//g,
|
|
270
|
+
() => "\\/",
|
|
271
|
+
SLASH
|
|
272
|
+
],
|
|
273
|
+
[
|
|
274
|
+
// > A leading "**" followed by a slash means match in all directories.
|
|
275
|
+
// > For example, "**/foo" matches file or directory "foo" anywhere,
|
|
276
|
+
// > the same as pattern "foo".
|
|
277
|
+
// > "**/foo/bar" matches file or directory "bar" anywhere that is directly
|
|
278
|
+
// > under directory "foo".
|
|
279
|
+
// Notice that the '*'s have been replaced as '\\*'
|
|
280
|
+
/^\^*(?:\\\*\\\*\\\/)+/,
|
|
281
|
+
// '**/foo' <-> 'foo'
|
|
282
|
+
() => "^(?:.*\\/)?",
|
|
283
|
+
"*"
|
|
284
|
+
],
|
|
285
|
+
// starting
|
|
286
|
+
[
|
|
287
|
+
// there will be no leading '/'
|
|
288
|
+
// (which has been replaced by section "leading slash")
|
|
289
|
+
// If starts with '**', adding a '^' to the regular expression also works
|
|
290
|
+
DIRECT,
|
|
291
|
+
(source, pattern) => {
|
|
292
|
+
if (!source || source[0] === "^") {
|
|
293
|
+
return source;
|
|
294
|
+
}
|
|
295
|
+
const anchor2 = !REGEX_INNER_SLASH.test(pattern) ? "(?:^|\\/)" : "^";
|
|
296
|
+
return anchor2 + source;
|
|
297
|
+
}
|
|
298
|
+
],
|
|
299
|
+
// two globstars
|
|
300
|
+
[
|
|
301
|
+
// Use lookahead assertions so that we could match more than one `'/**'`
|
|
302
|
+
/\\\/\\\*\\\*(?=\\\/|$)/g,
|
|
303
|
+
// Zero, one or several directories
|
|
304
|
+
// should not use '*', or it will be replaced by the next replacer
|
|
305
|
+
// Check if it is not the last `'/**'`
|
|
306
|
+
(_, index2, str) => index2 + 6 < str.length ? str.slice(index2 + 6) === "\\/" ? "(?:\\/[^\\/]+)+" : "(?:\\/[^\\/]+)*" : "\\/.+",
|
|
307
|
+
"*"
|
|
308
|
+
],
|
|
309
|
+
// normal intermediate wildcards
|
|
310
|
+
[
|
|
311
|
+
// Never replace escaped '*'
|
|
312
|
+
// ignore rule '\*' will match the path '*'
|
|
313
|
+
// 'abc.*/' -> go
|
|
314
|
+
// 'abc.*' -> skip this rule,
|
|
315
|
+
// coz trailing single wildcard will be handed by [trailing wildcard]
|
|
316
|
+
/(^|[^\\]+)(\\\*)+(?=.+)/g,
|
|
317
|
+
// '*.js' matches '.js'
|
|
318
|
+
// '*.js' doesn't match 'abc'
|
|
319
|
+
(_, p12, p22) => {
|
|
320
|
+
const unescaped = p22.replace(/\\\*/g, "[^\\/]*");
|
|
321
|
+
return p12 + unescaped;
|
|
322
|
+
},
|
|
323
|
+
"*"
|
|
324
|
+
],
|
|
325
|
+
// trailing wildcard, held apart from a literal star
|
|
326
|
+
[
|
|
327
|
+
// The step above leaves a trailing `*` alone, so a single `\*` is all that
|
|
328
|
+
// can be left at the end here. Whether it is a wildcard or a literal
|
|
329
|
+
// turns on the backslashes the user put in front of it: the escaper has
|
|
330
|
+
// since doubled every one, so what stands here is those `2N` doubled
|
|
331
|
+
// backslashes and then the star's own escape. An even number of the
|
|
332
|
+
// original `N` leaves the star unescaped -- a wildcard -- and an odd
|
|
333
|
+
// number escapes it -- a literal. This runs while the two are still
|
|
334
|
+
// distinct, before the unescape steps below collapse the literal onto
|
|
335
|
+
// the very `\*` a wildcard leaves behind.
|
|
336
|
+
/(^|[^\\])((?:\\\\)*)\\\*$/,
|
|
337
|
+
(match, p12, p22) => (
|
|
338
|
+
// `p2` holds the doubled user backslashes; half of them is `N`.
|
|
339
|
+
p22.length / 2 % 2 === 0 ? p12 + p22 + TRAILING_WILDCARD : match
|
|
340
|
+
),
|
|
341
|
+
"*"
|
|
342
|
+
],
|
|
343
|
+
[
|
|
344
|
+
// unescape, revert step 3 except for back slash
|
|
345
|
+
// For example, if a user escape a '\\*',
|
|
346
|
+
// after step 3, the result will be '\\\\\\*'
|
|
347
|
+
/\\\\\\(?=[$.|*+(){^])/g,
|
|
348
|
+
() => ESCAPE,
|
|
349
|
+
ESCAPE + ESCAPE
|
|
350
|
+
],
|
|
351
|
+
[
|
|
352
|
+
// '\\\\' -> '\\'
|
|
353
|
+
/\\\\/g,
|
|
354
|
+
() => ESCAPE,
|
|
355
|
+
ESCAPE + ESCAPE
|
|
356
|
+
],
|
|
357
|
+
[
|
|
358
|
+
// Every real bracket expression -- POSIX classes included -- has already
|
|
359
|
+
// been held aside by `extractBrackets`, so the only `[` left in the
|
|
360
|
+
// pattern is an escaped, literal one.
|
|
361
|
+
// `\` is escaped by step 3
|
|
362
|
+
/\\\[([^\]/]*?)(\\*)($|\])/g,
|
|
363
|
+
// '\\[bar]' -> '\\\\[bar\\]'
|
|
364
|
+
(match, range, endEscape, close) => `\\[${range}${cleanRangeBackSlash(endEscape)}${close}`,
|
|
365
|
+
"["
|
|
366
|
+
],
|
|
367
|
+
// ending
|
|
368
|
+
[
|
|
369
|
+
// 'js' will not match 'js.'
|
|
370
|
+
// 'ab' will not match 'abc'
|
|
371
|
+
DIRECT,
|
|
372
|
+
// WTF!
|
|
373
|
+
// https://git-scm.com/docs/gitignore
|
|
374
|
+
// changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
|
|
375
|
+
// which re-fixes #24, #38
|
|
376
|
+
// > If there is a separator at the end of the pattern then the pattern
|
|
377
|
+
// > will only match directories, otherwise the pattern can match both
|
|
378
|
+
// > files and directories.
|
|
379
|
+
// 'js*' will not match 'a.js'
|
|
380
|
+
// 'js/' will not match 'a.js'
|
|
381
|
+
// 'js' will match 'a.js' and 'a.js/'
|
|
382
|
+
(source) => {
|
|
383
|
+
const last = source[source.length - 1];
|
|
384
|
+
if (!last || last === TRAILING_WILDCARD) {
|
|
385
|
+
return source;
|
|
386
|
+
}
|
|
387
|
+
return last === SLASH ? `${source}$` : `${source}(?=$|\\/$)`;
|
|
388
|
+
}
|
|
389
|
+
]
|
|
390
|
+
];
|
|
391
|
+
var REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\uE000$/;
|
|
392
|
+
var MODE_IGNORE = "regex";
|
|
393
|
+
var MODE_CHECK_IGNORE = "checkRegex";
|
|
394
|
+
var UNDERSCORE = "_";
|
|
395
|
+
var TRAILING_WILD_CARD_REPLACERS = {
|
|
396
|
+
[MODE_IGNORE](_, p12) {
|
|
397
|
+
const prefix = p12 ? `${p12}[^/]+` : "[^/]*";
|
|
398
|
+
return `${prefix}(?=$|\\/$)`;
|
|
399
|
+
},
|
|
400
|
+
[MODE_CHECK_IGNORE](_, p12) {
|
|
401
|
+
const prefix = p12 ? `${p12}[^/]*` : "[^/]*";
|
|
402
|
+
return `${prefix}(?=$|\\/$)`;
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
var WILDCARD = "[^\\/]*";
|
|
406
|
+
var pinWildcards = (source) => {
|
|
407
|
+
if (source.indexOf(WILDCARD) < 0) {
|
|
408
|
+
return source;
|
|
409
|
+
}
|
|
410
|
+
const tokens = [];
|
|
411
|
+
const { length } = source;
|
|
412
|
+
let index2 = 0;
|
|
413
|
+
while (index2 < length) {
|
|
414
|
+
const char = source[index2];
|
|
415
|
+
if (source.startsWith(WILDCARD, index2)) {
|
|
416
|
+
tokens.push({ wildcard: true });
|
|
417
|
+
index2 += WILDCARD.length;
|
|
418
|
+
} else if (char === "[") {
|
|
419
|
+
let end = index2 + 1;
|
|
420
|
+
if (source[end] === "^") {
|
|
421
|
+
end++;
|
|
422
|
+
}
|
|
423
|
+
if (source[end] === "]") {
|
|
424
|
+
end++;
|
|
425
|
+
}
|
|
426
|
+
while (end < length && source[end] !== "]") {
|
|
427
|
+
end += source[end] === ESCAPE ? 2 : 1;
|
|
428
|
+
}
|
|
429
|
+
end++;
|
|
430
|
+
tokens.push({ single: source.slice(index2, end) });
|
|
431
|
+
index2 = end;
|
|
432
|
+
} else if (char === ESCAPE) {
|
|
433
|
+
tokens.push({ single: source.slice(index2, index2 + 2) });
|
|
434
|
+
index2 += 2;
|
|
435
|
+
} else if (char === "(") {
|
|
436
|
+
let depth = 0;
|
|
437
|
+
let end = index2;
|
|
438
|
+
do {
|
|
439
|
+
if (source[end] === ESCAPE) {
|
|
440
|
+
end++;
|
|
441
|
+
} else if (source[end] === "(") {
|
|
442
|
+
depth++;
|
|
443
|
+
} else if (source[end] === ")") {
|
|
444
|
+
depth--;
|
|
445
|
+
}
|
|
446
|
+
end++;
|
|
447
|
+
} while (end < length && depth > 0);
|
|
448
|
+
if ("*+?".indexOf(source[end]) >= 0) {
|
|
449
|
+
end++;
|
|
450
|
+
}
|
|
451
|
+
tokens.push({ boundary: source.slice(index2, end) });
|
|
452
|
+
index2 = end;
|
|
453
|
+
} else if (char === "^" || char === "$") {
|
|
454
|
+
tokens.push({ boundary: char });
|
|
455
|
+
index2++;
|
|
456
|
+
} else {
|
|
457
|
+
tokens.push({ single: char });
|
|
458
|
+
index2++;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
let out2 = EMPTY;
|
|
462
|
+
let run = [];
|
|
463
|
+
const flush = () => {
|
|
464
|
+
let lastWildcard;
|
|
465
|
+
run.forEach((token, at2) => {
|
|
466
|
+
if (token.wildcard) {
|
|
467
|
+
lastWildcard = at2;
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
run.forEach((token, at2) => {
|
|
471
|
+
if (!token.wildcard) {
|
|
472
|
+
out2 += token.single;
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
out2 += at2 === lastWildcard ? WILDCARD : `(?:(?!${run[at2 + 1].single})[^\\/])*`;
|
|
476
|
+
});
|
|
477
|
+
run = [];
|
|
478
|
+
};
|
|
479
|
+
tokens.forEach((token) => {
|
|
480
|
+
if (token.boundary === void 0) {
|
|
481
|
+
run.push(token);
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
flush();
|
|
485
|
+
out2 += token.boundary;
|
|
486
|
+
});
|
|
487
|
+
flush();
|
|
488
|
+
return out2;
|
|
489
|
+
};
|
|
490
|
+
var makeRegexPrefix = (pattern) => {
|
|
491
|
+
const { source, sources } = extractBrackets(pattern);
|
|
492
|
+
const replaced = REPLACERS.reduce(
|
|
493
|
+
// A pass whose matcher finds nothing hands back the very string it was
|
|
494
|
+
// given, so asking first costs a search and saves a rewrite. Ten of the
|
|
495
|
+
// fifteen passes never fire for a typical .gitignore line, and between
|
|
496
|
+
// them they were 45% of this chain.
|
|
497
|
+
(prev, [matcher, replacer, required2]) => {
|
|
498
|
+
if (matcher === DIRECT) {
|
|
499
|
+
return replacer(prev, pattern);
|
|
500
|
+
}
|
|
501
|
+
if (required2 !== UNDEFINED && prev.indexOf(required2) < 0) {
|
|
502
|
+
return prev;
|
|
503
|
+
}
|
|
504
|
+
return matcher.test(prev) ? prev.replace(matcher, replacer.bind(pattern)) : prev;
|
|
505
|
+
},
|
|
506
|
+
source
|
|
507
|
+
);
|
|
508
|
+
return sources.length ? replaced.replace(
|
|
509
|
+
REGEX_RESTORE_PLACEHOLDER,
|
|
510
|
+
(match, index2) => sources[index2]
|
|
511
|
+
) : replaced;
|
|
512
|
+
};
|
|
513
|
+
var matchesBasename = (body) => {
|
|
514
|
+
const index2 = body.indexOf(SLASH);
|
|
515
|
+
return index2 < 0 || index2 === body.length - 1;
|
|
516
|
+
};
|
|
517
|
+
var basenameOf = (path6) => {
|
|
518
|
+
const end = path6.length - 1;
|
|
519
|
+
const index2 = path6.lastIndexOf(
|
|
520
|
+
SLASH,
|
|
521
|
+
path6[end] === SLASH ? end - 1 : end
|
|
522
|
+
);
|
|
523
|
+
return index2 < 0 ? path6 : path6.slice(index2 + 1);
|
|
524
|
+
};
|
|
525
|
+
var parentOf = (path6) => {
|
|
526
|
+
if (path6.charCodeAt(0) === SLASH_CODE || path6.indexOf(DOUBLE_SLASH) >= 0) {
|
|
527
|
+
const slices = path6.split(SLASH).filter(Boolean);
|
|
528
|
+
slices.pop();
|
|
529
|
+
return slices.length ? slices.join(SLASH) + SLASH : EMPTY;
|
|
530
|
+
}
|
|
531
|
+
const end = path6.length - 1;
|
|
532
|
+
const cut = path6.lastIndexOf(
|
|
533
|
+
SLASH,
|
|
534
|
+
path6.charCodeAt(end) === SLASH_CODE ? end - 1 : end
|
|
535
|
+
);
|
|
536
|
+
return cut < 0 ? EMPTY : path6.slice(0, cut + 1);
|
|
537
|
+
};
|
|
538
|
+
var isString = (subject) => typeof subject === "string";
|
|
539
|
+
var checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0;
|
|
540
|
+
var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean);
|
|
541
|
+
var IgnoreRule = class {
|
|
542
|
+
constructor(pattern, mark, body, ignoreCase, negative, prefix) {
|
|
543
|
+
this.pattern = pattern;
|
|
544
|
+
this.mark = mark;
|
|
545
|
+
this.negative = negative;
|
|
546
|
+
define2(this, "body", body);
|
|
547
|
+
define2(this, "ignoreCase", ignoreCase);
|
|
548
|
+
define2(this, "regexPrefix", prefix);
|
|
549
|
+
}
|
|
550
|
+
// Worked out on first use and kept behind an own property, the way `regex`
|
|
551
|
+
// caches itself in `_regex`. Deciding it in the constructor instead would
|
|
552
|
+
// add a fourth `defineProperty` to every rule ever built, which cost 4% of
|
|
553
|
+
// every compile -- including the compiles of rules that are never matched
|
|
554
|
+
// against anything.
|
|
555
|
+
get _basenameOnly() {
|
|
556
|
+
return define2(this, "_basenameOnly", matchesBasename(this.body));
|
|
557
|
+
}
|
|
558
|
+
get regex() {
|
|
559
|
+
const key = UNDERSCORE + MODE_IGNORE;
|
|
560
|
+
if (this[key]) {
|
|
561
|
+
return this[key];
|
|
562
|
+
}
|
|
563
|
+
return this._make(MODE_IGNORE, key);
|
|
564
|
+
}
|
|
565
|
+
get checkRegex() {
|
|
566
|
+
const key = UNDERSCORE + MODE_CHECK_IGNORE;
|
|
567
|
+
if (this[key]) {
|
|
568
|
+
return this[key];
|
|
569
|
+
}
|
|
570
|
+
return this._make(MODE_CHECK_IGNORE, key);
|
|
571
|
+
}
|
|
572
|
+
_make(mode, key) {
|
|
573
|
+
const str = pinWildcards(this.regexPrefix.replace(
|
|
574
|
+
REGEX_REPLACE_TRAILING_WILDCARD,
|
|
575
|
+
// It does not need to bind pattern
|
|
576
|
+
TRAILING_WILD_CARD_REPLACERS[mode]
|
|
577
|
+
));
|
|
578
|
+
const regex = this.ignoreCase ? new RegExp(str, "i") : new RegExp(str);
|
|
579
|
+
return define2(this, key, regex);
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
var createRule = ({
|
|
583
|
+
pattern,
|
|
584
|
+
mark
|
|
585
|
+
}, ignoreCase) => {
|
|
586
|
+
let negative = false;
|
|
587
|
+
let body = pattern;
|
|
588
|
+
if (body.indexOf("!") === 0) {
|
|
589
|
+
negative = true;
|
|
590
|
+
body = body.substr(1);
|
|
591
|
+
}
|
|
592
|
+
body = body.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
|
|
593
|
+
const regexPrefix = makeRegexPrefix(body);
|
|
594
|
+
return new IgnoreRule(
|
|
595
|
+
pattern,
|
|
596
|
+
mark,
|
|
597
|
+
body,
|
|
598
|
+
ignoreCase,
|
|
599
|
+
negative,
|
|
600
|
+
regexPrefix
|
|
601
|
+
);
|
|
602
|
+
};
|
|
603
|
+
var RuleManager = class {
|
|
604
|
+
constructor(ignoreCase) {
|
|
605
|
+
this._ignoreCase = ignoreCase;
|
|
606
|
+
this._rules = [];
|
|
607
|
+
this._basenameCount = 0;
|
|
608
|
+
}
|
|
609
|
+
_add(pattern) {
|
|
610
|
+
if (pattern && pattern[KEY_IGNORE]) {
|
|
611
|
+
this._rules = this._rules.concat(pattern._rules._rules);
|
|
612
|
+
this._basenameCount += pattern._rules._basenameCount;
|
|
613
|
+
this._added = true;
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
if (isString(pattern)) {
|
|
617
|
+
pattern = {
|
|
618
|
+
pattern
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
if (checkPattern(pattern.pattern)) {
|
|
622
|
+
const rule = createRule(pattern, this._ignoreCase);
|
|
623
|
+
this._added = true;
|
|
624
|
+
this._rules.push(rule);
|
|
625
|
+
if (matchesBasename(rule.body)) {
|
|
626
|
+
this._basenameCount++;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
// @param {Array<string> | string | Ignore} pattern
|
|
631
|
+
add(pattern) {
|
|
632
|
+
this._added = false;
|
|
633
|
+
makeArray(
|
|
634
|
+
isString(pattern) ? splitPattern(pattern) : pattern
|
|
635
|
+
).forEach(this._add, this);
|
|
636
|
+
return this._added;
|
|
637
|
+
}
|
|
638
|
+
// Test one single path without recursively checking parent directories
|
|
639
|
+
//
|
|
640
|
+
// - checkUnignored `boolean` whether should check if the path is unignored,
|
|
641
|
+
// setting `checkUnignored` to `false` could reduce additional
|
|
642
|
+
// path matching.
|
|
643
|
+
// - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
|
|
644
|
+
// @returns {TestResult} true if a file is ignored
|
|
645
|
+
test(path6, checkUnignored, mode) {
|
|
646
|
+
let ignored = false;
|
|
647
|
+
let unignored = false;
|
|
648
|
+
let matchedRule;
|
|
649
|
+
const rules = this._rules;
|
|
650
|
+
const { length } = rules;
|
|
651
|
+
const shortcut = this._basenameCount * 2 >= length;
|
|
652
|
+
const basename11 = shortcut ? basenameOf(path6) : path6;
|
|
653
|
+
for (let index2 = 0; index2 < length; index2++) {
|
|
654
|
+
const rule = rules[index2];
|
|
655
|
+
const { negative } = rule;
|
|
656
|
+
const skip = unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored;
|
|
657
|
+
if (!skip && rule[mode].test(
|
|
658
|
+
shortcut && rule._basenameOnly ? basename11 : path6
|
|
659
|
+
)) {
|
|
660
|
+
ignored = !negative;
|
|
661
|
+
unignored = negative;
|
|
662
|
+
matchedRule = negative ? UNDEFINED : rule;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
const ret2 = {
|
|
666
|
+
ignored,
|
|
667
|
+
unignored
|
|
668
|
+
};
|
|
669
|
+
if (matchedRule) {
|
|
670
|
+
ret2.rule = matchedRule;
|
|
671
|
+
}
|
|
672
|
+
return ret2;
|
|
673
|
+
}
|
|
674
|
+
};
|
|
675
|
+
var throwError = (message, Ctor) => {
|
|
676
|
+
throw new Ctor(message);
|
|
677
|
+
};
|
|
678
|
+
var checkPath = (path6, originalPath, doThrow) => {
|
|
679
|
+
if (!isString(path6)) {
|
|
680
|
+
return doThrow(
|
|
681
|
+
`path must be a string, but got \`${originalPath}\``,
|
|
682
|
+
TypeError
|
|
683
|
+
);
|
|
684
|
+
}
|
|
685
|
+
if (!path6) {
|
|
686
|
+
return doThrow(`path must not be empty`, TypeError);
|
|
687
|
+
}
|
|
688
|
+
if (checkPath.isNotRelative(path6)) {
|
|
689
|
+
const r = "`path.relative()`d";
|
|
690
|
+
return doThrow(
|
|
691
|
+
`path should be a ${r} string, but got "${originalPath}"`,
|
|
692
|
+
RangeError
|
|
693
|
+
);
|
|
694
|
+
}
|
|
695
|
+
return true;
|
|
696
|
+
};
|
|
697
|
+
var isNotRelative = (path6) => {
|
|
698
|
+
const first = path6.charCodeAt(0);
|
|
699
|
+
if (first === SLASH_CODE) {
|
|
700
|
+
return true;
|
|
701
|
+
}
|
|
702
|
+
if (first !== DOT_CODE) {
|
|
703
|
+
return false;
|
|
704
|
+
}
|
|
705
|
+
if (path6.length === 1) {
|
|
706
|
+
return true;
|
|
707
|
+
}
|
|
708
|
+
const second = path6.charCodeAt(1);
|
|
709
|
+
if (second === SLASH_CODE) {
|
|
710
|
+
return true;
|
|
711
|
+
}
|
|
712
|
+
if (second !== DOT_CODE) {
|
|
713
|
+
return false;
|
|
714
|
+
}
|
|
715
|
+
return path6.length === 2 || path6.charCodeAt(2) === SLASH_CODE;
|
|
716
|
+
};
|
|
717
|
+
checkPath.isNotRelative = isNotRelative;
|
|
718
|
+
checkPath.convert = (p) => p;
|
|
719
|
+
var Ignore = class {
|
|
720
|
+
constructor({
|
|
721
|
+
ignorecase = true,
|
|
722
|
+
ignoreCase = ignorecase,
|
|
723
|
+
allowRelativePaths = false
|
|
724
|
+
} = {}) {
|
|
725
|
+
define2(this, KEY_IGNORE, true);
|
|
726
|
+
this._rules = new RuleManager(ignoreCase);
|
|
727
|
+
this._strictPathCheck = !allowRelativePaths;
|
|
728
|
+
this._initCache();
|
|
729
|
+
}
|
|
730
|
+
_initCache() {
|
|
731
|
+
this._ignoreCache = /* @__PURE__ */ Object.create(null);
|
|
732
|
+
this._testCache = /* @__PURE__ */ Object.create(null);
|
|
733
|
+
}
|
|
734
|
+
add(pattern) {
|
|
735
|
+
if (this._rules.add(pattern)) {
|
|
736
|
+
this._initCache();
|
|
737
|
+
}
|
|
738
|
+
return this;
|
|
739
|
+
}
|
|
740
|
+
// legacy
|
|
741
|
+
addPattern(pattern) {
|
|
742
|
+
return this.add(pattern);
|
|
743
|
+
}
|
|
744
|
+
// @returns {TestResult}
|
|
745
|
+
_test(originalPath, cache, checkUnignored) {
|
|
746
|
+
const path6 = originalPath && checkPath.convert(originalPath);
|
|
747
|
+
checkPath(
|
|
748
|
+
path6,
|
|
749
|
+
originalPath,
|
|
750
|
+
this._strictPathCheck ? throwError : RETURN_FALSE
|
|
751
|
+
);
|
|
752
|
+
return this._t(path6, cache, checkUnignored);
|
|
753
|
+
}
|
|
754
|
+
checkIgnore(path6) {
|
|
755
|
+
if (path6.charCodeAt(path6.length - 1) !== SLASH_CODE) {
|
|
756
|
+
return this.test(path6);
|
|
757
|
+
}
|
|
758
|
+
const parentPath = parentOf(path6);
|
|
759
|
+
if (parentPath) {
|
|
760
|
+
const parent = this._t(parentPath, this._testCache, true);
|
|
761
|
+
if (parent.ignored) {
|
|
762
|
+
return parent;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
return this._rules.test(path6, false, MODE_CHECK_IGNORE);
|
|
766
|
+
}
|
|
767
|
+
_t(path6, cache, checkUnignored) {
|
|
768
|
+
if (path6 in cache) {
|
|
769
|
+
return cache[path6];
|
|
770
|
+
}
|
|
771
|
+
const parentPath = parentOf(path6);
|
|
772
|
+
const parent = parentPath ? this._t(parentPath, cache, checkUnignored) : UNDEFINED;
|
|
773
|
+
return cache[path6] = parent && parent.ignored ? parent : this._rules.test(path6, checkUnignored, MODE_IGNORE);
|
|
774
|
+
}
|
|
775
|
+
ignores(path6) {
|
|
776
|
+
return this._test(path6, this._ignoreCache, false).ignored;
|
|
777
|
+
}
|
|
778
|
+
createFilter() {
|
|
779
|
+
return (path6) => !this.ignores(path6);
|
|
780
|
+
}
|
|
781
|
+
filter(paths) {
|
|
782
|
+
return makeArray(paths).filter(this.createFilter());
|
|
783
|
+
}
|
|
784
|
+
// @returns {TestResult}
|
|
785
|
+
test(path6) {
|
|
786
|
+
return this._test(path6, this._testCache, true);
|
|
787
|
+
}
|
|
788
|
+
};
|
|
789
|
+
var factory = (options) => new Ignore(options);
|
|
790
|
+
var isPathValid = (path6) => checkPath(path6 && checkPath.convert(path6), path6, RETURN_FALSE);
|
|
791
|
+
var setupWindows = () => {
|
|
792
|
+
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
793
|
+
checkPath.convert = makePosix;
|
|
794
|
+
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
795
|
+
checkPath.isNotRelative = (path6) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path6) || isNotRelative(path6);
|
|
796
|
+
};
|
|
797
|
+
if (
|
|
798
|
+
// Detect `process` so that it can run in browsers.
|
|
799
|
+
typeof process !== "undefined" && process.platform === "win32"
|
|
800
|
+
) {
|
|
801
|
+
setupWindows();
|
|
802
|
+
}
|
|
803
|
+
module.exports = factory;
|
|
804
|
+
factory.default = factory;
|
|
805
|
+
module.exports.isPathValid = isPathValid;
|
|
806
|
+
define2(module.exports, /* @__PURE__ */ Symbol.for("setupWindows"), setupWindows);
|
|
807
|
+
}
|
|
808
|
+
});
|
|
7
809
|
|
|
8
810
|
// src/engine/runtime/relay/runtime-revocation.ts
|
|
9
811
|
var runtimeRevocationCloseCode = 1008;
|
|
@@ -1966,18 +2768,18 @@ var validateAsync = async (schema, value, _ctx) => {
|
|
|
1966
2768
|
return result.issues.length === 0;
|
|
1967
2769
|
};
|
|
1968
2770
|
var _encode = (_Err) => {
|
|
1969
|
-
const
|
|
2771
|
+
const parse6 = _parse(_Err);
|
|
1970
2772
|
const fn2 = (schema, value, _ctx, _params) => {
|
|
1971
2773
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
1972
|
-
return
|
|
2774
|
+
return parse6(schema, value, ctx, finalizeParams(fn2, _params));
|
|
1973
2775
|
};
|
|
1974
2776
|
return fn2;
|
|
1975
2777
|
};
|
|
1976
2778
|
var encode = /* @__PURE__ */ _encode($ZodRealError);
|
|
1977
2779
|
var _decode = (_Err) => {
|
|
1978
|
-
const
|
|
2780
|
+
const parse6 = _parse(_Err);
|
|
1979
2781
|
const fn2 = (schema, value, _ctx, _params) => {
|
|
1980
|
-
return
|
|
2782
|
+
return parse6(schema, value, _ctx, finalizeParams(fn2, _params));
|
|
1981
2783
|
};
|
|
1982
2784
|
return fn2;
|
|
1983
2785
|
};
|
|
@@ -3472,7 +4274,7 @@ function capSize(inst, size) {
|
|
|
3472
4274
|
if (!caps.length)
|
|
3473
4275
|
return;
|
|
3474
4276
|
const cap = Math.min(...caps.map((c) => c[0]));
|
|
3475
|
-
const
|
|
4277
|
+
const parse6 = inst._zod.parse;
|
|
3476
4278
|
inst._zod.parse = (payload, ctx) => {
|
|
3477
4279
|
const n = size(payload.value);
|
|
3478
4280
|
if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
|
|
@@ -3486,7 +4288,7 @@ function capSize(inst, size) {
|
|
|
3486
4288
|
}
|
|
3487
4289
|
}
|
|
3488
4290
|
}
|
|
3489
|
-
return
|
|
4291
|
+
return parse6(payload, ctx);
|
|
3490
4292
|
};
|
|
3491
4293
|
}
|
|
3492
4294
|
var arraySize = (input2) => Array.isArray(input2) ? input2.length : -1;
|
|
@@ -19997,13 +20799,15 @@ function decodeRuntimePongEvent(encoded) {
|
|
|
19997
20799
|
const scopedFileRead = Reflect.get(value, "scopedFileRead");
|
|
19998
20800
|
const promptSuggestions = Reflect.get(value, "promptSuggestions");
|
|
19999
20801
|
const usageQuota = Reflect.get(value, "usageQuota");
|
|
20802
|
+
const workspaceFiles = Reflect.get(value, "workspaceFiles");
|
|
20000
20803
|
return {
|
|
20001
20804
|
kind: RUNTIME_PONG_KIND,
|
|
20002
20805
|
...Reflect.get(value, "sessionTitleGeneration") === true ? { sessionTitleGeneration: true } : {},
|
|
20003
20806
|
...typeof promptSuggestions === "boolean" ? { promptSuggestions } : {},
|
|
20004
20807
|
requestId: readIdentifier(value, "requestId"),
|
|
20005
20808
|
...typeof scopedFileRead === "boolean" ? { scopedFileRead } : {},
|
|
20006
|
-
...typeof usageQuota === "boolean" ? { usageQuota } : {}
|
|
20809
|
+
...typeof usageQuota === "boolean" ? { usageQuota } : {},
|
|
20810
|
+
...typeof workspaceFiles === "boolean" ? { workspaceFiles } : {}
|
|
20007
20811
|
};
|
|
20008
20812
|
}
|
|
20009
20813
|
function encodeRuntimeLivenessReadyEvent(message) {
|
|
@@ -21974,6 +22778,70 @@ function decodeAgentPromptResponse(value) {
|
|
|
21974
22778
|
return result.data;
|
|
21975
22779
|
}
|
|
21976
22780
|
|
|
22781
|
+
// ../mobius-sdk/src/protocol/session/workspace/files.ts
|
|
22782
|
+
var WORKSPACE_FILES_LIST_KIND = "workspace.files.list";
|
|
22783
|
+
var WORKSPACE_FILES_KIND = "workspace.files";
|
|
22784
|
+
var WORKSPACE_FILE_READ_KIND = "workspace.file.read";
|
|
22785
|
+
var WORKSPACE_FILE_REPLY_SESSION_ID = "runtime";
|
|
22786
|
+
var WORKSPACE_FILES_PAGE_MAX_ENTRIES = 200;
|
|
22787
|
+
var WORKSPACE_FILE_PATH_MAX_LENGTH = 1024;
|
|
22788
|
+
var WORKSPACE_FILE_CURSOR_MAX_LENGTH = 128;
|
|
22789
|
+
var WORKSPACE_FILE_NAME_MAX_LENGTH = 255;
|
|
22790
|
+
function isWorkspaceRelativePath(value) {
|
|
22791
|
+
if (value === ".") {
|
|
22792
|
+
return true;
|
|
22793
|
+
}
|
|
22794
|
+
if (value.length === 0 || value.length > WORKSPACE_FILE_PATH_MAX_LENGTH || /[\0\\]/u.test(value)) {
|
|
22795
|
+
return false;
|
|
22796
|
+
}
|
|
22797
|
+
return value.split("/").every((segment) => segment.length > 0 && segment !== "." && segment !== "..");
|
|
22798
|
+
}
|
|
22799
|
+
var workspaceRelativePathSchema = external_exports.string().min(1).max(WORKSPACE_FILE_PATH_MAX_LENGTH).refine(isWorkspaceRelativePath, "The workspace path must stay within its directory");
|
|
22800
|
+
var workspaceFileListCommandSchema = external_exports.object({
|
|
22801
|
+
bindingId: identifierStringSchema,
|
|
22802
|
+
cursor: external_exports.string().min(1).max(WORKSPACE_FILE_CURSOR_MAX_LENGTH).optional(),
|
|
22803
|
+
directory: workspaceRelativePathSchema,
|
|
22804
|
+
directoryId: DIRECTORY_IDENTIFIER,
|
|
22805
|
+
kind: external_exports.literal(WORKSPACE_FILES_LIST_KIND),
|
|
22806
|
+
limit: external_exports.number().int().min(1).max(WORKSPACE_FILES_PAGE_MAX_ENTRIES),
|
|
22807
|
+
requestId: identifierStringSchema
|
|
22808
|
+
}).readonly();
|
|
22809
|
+
var workspaceFileEntrySchema = external_exports.discriminatedUnion("kind", [
|
|
22810
|
+
external_exports.object({
|
|
22811
|
+
kind: external_exports.literal("directory"),
|
|
22812
|
+
name: external_exports.string().min(1).max(WORKSPACE_FILE_NAME_MAX_LENGTH),
|
|
22813
|
+
path: workspaceRelativePathSchema
|
|
22814
|
+
}).readonly(),
|
|
22815
|
+
external_exports.object({
|
|
22816
|
+
kind: external_exports.literal("file"),
|
|
22817
|
+
name: external_exports.string().min(1).max(WORKSPACE_FILE_NAME_MAX_LENGTH),
|
|
22818
|
+
path: workspaceRelativePathSchema,
|
|
22819
|
+
size: external_exports.number().int().nonnegative()
|
|
22820
|
+
}).readonly()
|
|
22821
|
+
]);
|
|
22822
|
+
var workspaceFilesEventSchema = external_exports.object({
|
|
22823
|
+
bindingId: identifierStringSchema,
|
|
22824
|
+
directoryId: DIRECTORY_IDENTIFIER,
|
|
22825
|
+
entries: external_exports.array(workspaceFileEntrySchema).max(WORKSPACE_FILES_PAGE_MAX_ENTRIES).readonly(),
|
|
22826
|
+
kind: external_exports.literal(WORKSPACE_FILES_KIND),
|
|
22827
|
+
nextCursor: external_exports.string().min(1).max(WORKSPACE_FILE_CURSOR_MAX_LENGTH).optional(),
|
|
22828
|
+
requestId: identifierStringSchema
|
|
22829
|
+
}).readonly();
|
|
22830
|
+
var workspaceFileReadCommandSchema = external_exports.object({
|
|
22831
|
+
bindingId: identifierStringSchema,
|
|
22832
|
+
directoryId: DIRECTORY_IDENTIFIER,
|
|
22833
|
+
kind: external_exports.literal(WORKSPACE_FILE_READ_KIND),
|
|
22834
|
+
maxBytes: external_exports.number().int().positive().max(128 * 1024 * 1024),
|
|
22835
|
+
path: workspaceRelativePathSchema.refine((path6) => path6 !== ".", "The workspace path must name a file"),
|
|
22836
|
+
requestId: identifierStringSchema
|
|
22837
|
+
}).readonly();
|
|
22838
|
+
var decodeWorkspaceFileListCommand = (encoded) => decodeZodMessage(encoded, workspaceFileListCommandSchema);
|
|
22839
|
+
var encodeWorkspaceFileListCommand = (message) => encodeZodMessage(message, workspaceFileListCommandSchema);
|
|
22840
|
+
var decodeWorkspaceFilesEvent = (encoded) => decodeZodMessage(encoded, workspaceFilesEventSchema);
|
|
22841
|
+
var encodeWorkspaceFilesEvent = (message) => encodeZodMessage(message, workspaceFilesEventSchema);
|
|
22842
|
+
var decodeWorkspaceFileReadCommand = (encoded) => decodeZodMessage(encoded, workspaceFileReadCommandSchema);
|
|
22843
|
+
var encodeWorkspaceFileReadCommand = (message) => encodeZodMessage(message, workspaceFileReadCommandSchema);
|
|
22844
|
+
|
|
21977
22845
|
// ../mobius-sdk/src/protocol/session/workspace/index.ts
|
|
21978
22846
|
var WORKSPACE_LIST_KIND = "workspace.list";
|
|
21979
22847
|
var WORKSPACE_ENTRIES_KIND = "workspace.entries";
|
|
@@ -22152,6 +23020,16 @@ var serviceToDaemonSignatures = {
|
|
|
22152
23020
|
WORKSPACE_LIST_KIND,
|
|
22153
23021
|
encodeWorkspaceListCommand,
|
|
22154
23022
|
decodeWorkspaceListCommand
|
|
23023
|
+
),
|
|
23024
|
+
[WORKSPACE_FILES_LIST_KIND]: defineMessageSignature(
|
|
23025
|
+
WORKSPACE_FILES_LIST_KIND,
|
|
23026
|
+
encodeWorkspaceFileListCommand,
|
|
23027
|
+
decodeWorkspaceFileListCommand
|
|
23028
|
+
),
|
|
23029
|
+
[WORKSPACE_FILE_READ_KIND]: defineMessageSignature(
|
|
23030
|
+
WORKSPACE_FILE_READ_KIND,
|
|
23031
|
+
encodeWorkspaceFileReadCommand,
|
|
23032
|
+
decodeWorkspaceFileReadCommand
|
|
22155
23033
|
)
|
|
22156
23034
|
};
|
|
22157
23035
|
var serviceToDaemonRegistry = serviceToDaemonSignatures;
|
|
@@ -22308,6 +23186,11 @@ var daemonToServiceSignatures = {
|
|
|
22308
23186
|
WORKSPACE_ENTRIES_KIND,
|
|
22309
23187
|
encodeWorkspaceEntriesEvent,
|
|
22310
23188
|
decodeWorkspaceEntriesEvent
|
|
23189
|
+
),
|
|
23190
|
+
[WORKSPACE_FILES_KIND]: defineMessageSignature(
|
|
23191
|
+
WORKSPACE_FILES_KIND,
|
|
23192
|
+
encodeWorkspaceFilesEvent,
|
|
23193
|
+
decodeWorkspaceFilesEvent
|
|
22311
23194
|
)
|
|
22312
23195
|
};
|
|
22313
23196
|
function encodeDaemonToServiceMessage(message) {
|
|
@@ -25825,13 +26708,13 @@ var ConnectionBuilder = class {
|
|
|
25825
26708
|
/**
|
|
25826
26709
|
* Adds a typed request handler for one method.
|
|
25827
26710
|
*/
|
|
25828
|
-
onReceiveRequest(method,
|
|
26711
|
+
onReceiveRequest(method, parse6, handler) {
|
|
25829
26712
|
return this.withHandler({
|
|
25830
26713
|
handleMessage: async (message, cx2) => {
|
|
25831
26714
|
if (message.kind !== "request" || message.method !== method) {
|
|
25832
26715
|
return Handled.no(message);
|
|
25833
26716
|
}
|
|
25834
|
-
const request =
|
|
26717
|
+
const request = parse6(message.params);
|
|
25835
26718
|
return await handler(request, message.responder, cx2) ?? Handled.yes();
|
|
25836
26719
|
},
|
|
25837
26720
|
describe: () => `${this.connectionName ?? "request"}:${method}`
|
|
@@ -25840,13 +26723,13 @@ var ConnectionBuilder = class {
|
|
|
25840
26723
|
/**
|
|
25841
26724
|
* Adds a typed notification handler for one method.
|
|
25842
26725
|
*/
|
|
25843
|
-
onReceiveNotification(method,
|
|
26726
|
+
onReceiveNotification(method, parse6, handler) {
|
|
25844
26727
|
return this.withHandler({
|
|
25845
26728
|
handleMessage: async (message, cx2) => {
|
|
25846
26729
|
if (message.kind !== "notification" || message.method !== method) {
|
|
25847
26730
|
return Handled.no(message);
|
|
25848
26731
|
}
|
|
25849
|
-
const notification =
|
|
26732
|
+
const notification = parse6(message.params);
|
|
25850
26733
|
return await handler(notification, cx2) ?? Handled.yes();
|
|
25851
26734
|
},
|
|
25852
26735
|
describe: () => `${this.connectionName ?? "notification"}:${method}`
|
|
@@ -28123,6 +29006,7 @@ var SESSION_UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-
|
|
|
28123
29006
|
var SUBAGENT_CONVERSATION_ID_PATTERN = /"conversationId"\s*:\s*"([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})"/giu;
|
|
28124
29007
|
var SUBAGENT_IDLE_ID_PATTERN = /\bSubagent ([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}) (?:has gone|went) idle\b/giu;
|
|
28125
29008
|
var AGENT_EXECUTOR_ERROR_PATTERN = /^\s*⚠ agent executor error:\s*(.+?)\s*$/su;
|
|
29009
|
+
var TASK_RESULT_SENDER_PATTERN = /\bsender=([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\/(task-\d+)\b/giu;
|
|
28126
29010
|
var SUBAGENT_CREATED_MARKER = "Created the following subagent";
|
|
28127
29011
|
var MAXIMUM_TOOL_DESCRIPTION_CHARS = 500;
|
|
28128
29012
|
var transcriptStepSchema = external_exports.object({
|
|
@@ -28177,7 +29061,7 @@ async function readTranscriptTailState(launchEnvironment, sessionId, baselineSte
|
|
|
28177
29061
|
return null;
|
|
28178
29062
|
}
|
|
28179
29063
|
if (tail.bytes.byteLength === 0) {
|
|
28180
|
-
return { maxStepIndex: -1, settledStepIndex: null, steps: [] };
|
|
29064
|
+
return { firstStepIndex: -1, maxStepIndex: -1, settledStepIndex: null, steps: [] };
|
|
28181
29065
|
}
|
|
28182
29066
|
const text2 = new TextDecoder().decode(tail.bytes);
|
|
28183
29067
|
const lines = text2.split("\n");
|
|
@@ -28200,11 +29084,13 @@ async function readTranscriptTailState(launchEnvironment, sessionId, baselineSte
|
|
|
28200
29084
|
}
|
|
28201
29085
|
}
|
|
28202
29086
|
steps.sort((left, right) => left.step_index - right.step_index);
|
|
29087
|
+
const firstStepIndex = steps.at(0)?.step_index ?? -1;
|
|
28203
29088
|
const maxStepIndex = steps.at(-1)?.step_index ?? -1;
|
|
28204
29089
|
const settledStep = steps.find(
|
|
28205
29090
|
(step) => step.step_index > baselineStepIndex && step.type === "PLANNER_RESPONSE" && step.status === "DONE" && (step.tool_calls === void 0 || step.tool_calls.length === 0)
|
|
28206
29091
|
);
|
|
28207
29092
|
return {
|
|
29093
|
+
firstStepIndex,
|
|
28208
29094
|
maxStepIndex,
|
|
28209
29095
|
settledStepIndex: settledStep?.step_index ?? null,
|
|
28210
29096
|
steps
|
|
@@ -28402,6 +29288,8 @@ var AntigravityBackgroundWakeup = class {
|
|
|
28402
29288
|
},
|
|
28403
29289
|
toolMetadata: /* @__PURE__ */ new Map(),
|
|
28404
29290
|
wakeupGeneration: 0,
|
|
29291
|
+
wakeupPendingTaskResults: 0,
|
|
29292
|
+
wakeupSettledStepIndex: null,
|
|
28405
29293
|
wakeupStageSeq: 0
|
|
28406
29294
|
};
|
|
28407
29295
|
this.#sessions.set(sessionId, created);
|
|
@@ -28683,6 +29571,10 @@ var AntigravityBackgroundWakeup = class {
|
|
|
28683
29571
|
}
|
|
28684
29572
|
session.wakeupGeneration += 1;
|
|
28685
29573
|
const generation = session.wakeupGeneration;
|
|
29574
|
+
session.wakeupPendingTaskResults = [...session.backgroundTasks.values()].filter(
|
|
29575
|
+
(task) => task.kind !== "subagent" && task.state === "awaiting-results"
|
|
29576
|
+
).length;
|
|
29577
|
+
session.wakeupSettledStepIndex = null;
|
|
28686
29578
|
this.#setWakeupAwaitingOutput(sessionId, session, generation, /* @__PURE__ */ new Set());
|
|
28687
29579
|
notifications.push(
|
|
28688
29580
|
makeMetaNotification(sessionId, AGENT_TURN_META, {
|
|
@@ -28784,9 +29676,11 @@ var AntigravityBackgroundWakeup = class {
|
|
|
28784
29676
|
this.#syncSubagentCreations(current, tail.steps);
|
|
28785
29677
|
}
|
|
28786
29678
|
if (tail?.settledStepIndex !== null && tail?.settledStepIndex !== void 0) {
|
|
28787
|
-
|
|
28788
|
-
|
|
28789
|
-
|
|
29679
|
+
if (this.#settleWakeupReply(sessionId, current, tail, tail.settledStepIndex)) {
|
|
29680
|
+
this.#emitNotifications(this.#finishWakeup(sessionId, current, "end_turn", false));
|
|
29681
|
+
} else {
|
|
29682
|
+
this.#setWakeupAwaitingOutput(sessionId, current, generation, current.phase.openToolIds);
|
|
29683
|
+
}
|
|
28790
29684
|
return;
|
|
28791
29685
|
}
|
|
28792
29686
|
if (currentStage.kind === "streaming" && currentStage.executorError !== void 0 && currentStage.executorErrorPolls >= 1) {
|
|
@@ -28798,6 +29692,34 @@ var AntigravityBackgroundWakeup = class {
|
|
|
28798
29692
|
}
|
|
28799
29693
|
this.#rescheduleTranscriptCheck(sessionId, current, generation, stageEpoch, currentStage);
|
|
28800
29694
|
};
|
|
29695
|
+
/**
|
|
29696
|
+
* Records that the continuation's reply settled at `settledStepIndex` and counts the task results Antigravity
|
|
29697
|
+
* handed to it up to there. Answers whether the continuation ends: it goes on while results are still owed, since
|
|
29698
|
+
* Antigravity hands each to the run right after the reply it has, and the run continues from it.
|
|
29699
|
+
*/
|
|
29700
|
+
#settleWakeupReply = (sessionId, session, tail, settledStepIndex) => {
|
|
29701
|
+
const sinceStepIndex = session.baselineStepIndex;
|
|
29702
|
+
session.baselineStepIndex = Math.max(session.baselineStepIndex, settledStepIndex);
|
|
29703
|
+
session.wakeupSettledStepIndex = settledStepIndex;
|
|
29704
|
+
this.#consumeSubagentIdlesThrough(session, tail.steps, settledStepIndex);
|
|
29705
|
+
if (tail.firstStepIndex > sinceStepIndex + 1) {
|
|
29706
|
+
session.wakeupPendingTaskResults = 0;
|
|
29707
|
+
return true;
|
|
29708
|
+
}
|
|
29709
|
+
const received = /* @__PURE__ */ new Set();
|
|
29710
|
+
for (const step of tail.steps) {
|
|
29711
|
+
if (step.step_index <= sinceStepIndex || step.step_index > settledStepIndex || step.type !== "SYSTEM_MESSAGE" || step.content === void 0) {
|
|
29712
|
+
continue;
|
|
29713
|
+
}
|
|
29714
|
+
for (const match of step.content.matchAll(TASK_RESULT_SENDER_PATTERN)) {
|
|
29715
|
+
if (match[1]?.toLowerCase() === sessionId.toLowerCase() && match[2] !== void 0) {
|
|
29716
|
+
received.add(match[2]);
|
|
29717
|
+
}
|
|
29718
|
+
}
|
|
29719
|
+
}
|
|
29720
|
+
session.wakeupPendingTaskResults = Math.max(0, session.wakeupPendingTaskResults - received.size);
|
|
29721
|
+
return session.wakeupPendingTaskResults === 0;
|
|
29722
|
+
};
|
|
28801
29723
|
#handleWakeupTimeout = async (sessionId, generation, stageEpoch, message) => {
|
|
28802
29724
|
if (this.#disposed) {
|
|
28803
29725
|
return;
|
|
@@ -28831,8 +29753,11 @@ var AntigravityBackgroundWakeup = class {
|
|
|
28831
29753
|
this.#syncSubagentCreations(current, tail.steps);
|
|
28832
29754
|
}
|
|
28833
29755
|
if (tail?.settledStepIndex !== null && tail?.settledStepIndex !== void 0) {
|
|
28834
|
-
|
|
28835
|
-
this.#
|
|
29756
|
+
this.#settleWakeupReply(sessionId, current, tail, tail.settledStepIndex);
|
|
29757
|
+
this.#emitNotifications(this.#finishWakeup(sessionId, current, "end_turn", false));
|
|
29758
|
+
return;
|
|
29759
|
+
}
|
|
29760
|
+
if (current.wakeupSettledStepIndex !== null && (tail === null || tail.maxStepIndex <= current.wakeupSettledStepIndex)) {
|
|
28836
29761
|
this.#emitNotifications(this.#finishWakeup(sessionId, current, "end_turn", false));
|
|
28837
29762
|
return;
|
|
28838
29763
|
}
|
|
@@ -28937,6 +29862,9 @@ var AntigravityBackgroundWakeup = class {
|
|
|
28937
29862
|
const trackedExisting = session.backgroundTasks.get(toolCallId);
|
|
28938
29863
|
if (trackedExisting !== void 0) {
|
|
28939
29864
|
if (status === "completed") {
|
|
29865
|
+
if (trackedExisting.kind !== "subagent" && trackedExisting.state !== "awaiting-results") {
|
|
29866
|
+
session.wakeupPendingTaskResults += 1;
|
|
29867
|
+
}
|
|
28940
29868
|
session.backgroundTasks.set(toolCallId, { ...trackedExisting, state: "awaiting-results" });
|
|
28941
29869
|
const bg2 = this.#takeBackgroundTasksUpdate(sessionId, session);
|
|
28942
29870
|
if (bg2 !== null) {
|
|
@@ -67659,8 +68587,8 @@ function inputPath(context, key) {
|
|
|
67659
68587
|
return plainString(context.input[key]);
|
|
67660
68588
|
}
|
|
67661
68589
|
function isInside(directory, candidate) {
|
|
67662
|
-
const
|
|
67663
|
-
return
|
|
68590
|
+
const relative5 = path.relative(path.resolve(directory), path.resolve(candidate));
|
|
68591
|
+
return relative5 === "" || !relative5.startsWith(`..${path.sep}`) && relative5 !== "..";
|
|
67664
68592
|
}
|
|
67665
68593
|
function hasSessionAllowRuleFor(changeSet, toolName) {
|
|
67666
68594
|
return !!changeSet?.updates.some((update) => update.type === "addRules" && update.destination === "session" && update.behavior === "allow" && update.rules.some((rule) => rule.toolName === toolName));
|
|
@@ -68341,11 +69269,11 @@ function stripUsageBlock(text2) {
|
|
|
68341
69269
|
if (!body.endsWith(USAGE_CLOSE)) {
|
|
68342
69270
|
return text2;
|
|
68343
69271
|
}
|
|
68344
|
-
const
|
|
68345
|
-
if (
|
|
69272
|
+
const open7 = body.lastIndexOf(USAGE_OPEN, body.length - USAGE_CLOSE.length - USAGE_OPEN.length);
|
|
69273
|
+
if (open7 === -1) {
|
|
68346
69274
|
return text2;
|
|
68347
69275
|
}
|
|
68348
|
-
return body.slice(0,
|
|
69276
|
+
return body.slice(0, open7 > 0 && body[open7 - 1] === "\n" ? open7 - 1 : open7);
|
|
68349
69277
|
}
|
|
68350
69278
|
var AGENT_ID_LINE = /^agentId: [\w-]+ \([^)]*\)$/;
|
|
68351
69279
|
function stripAgentIdLine(text2) {
|
|
@@ -70912,6 +71840,7 @@ var ClaudeAcpAgent = class {
|
|
|
70912
71840
|
const backgroundTasks = /* @__PURE__ */ new Set();
|
|
70913
71841
|
const awaitingBackgroundResults = /* @__PURE__ */ new Set();
|
|
70914
71842
|
let processingBackgroundResults = /* @__PURE__ */ new Set();
|
|
71843
|
+
const deliveredBackgroundResults = /* @__PURE__ */ new Set();
|
|
70915
71844
|
const backgroundTaskDetails = /* @__PURE__ */ new Map();
|
|
70916
71845
|
let publishedBackgroundTasks = "[]";
|
|
70917
71846
|
let hasBackgroundLevel = false;
|
|
@@ -71081,6 +72010,16 @@ var ClaudeAcpAgent = class {
|
|
|
71081
72010
|
}
|
|
71082
72011
|
};
|
|
71083
72012
|
const findUnsettledTurn = (uuid3) => (session.turnQueue ?? []).find((t) => t.promptUuid === uuid3 && !t.settled);
|
|
72013
|
+
const deliveredTaskResults = (message) => {
|
|
72014
|
+
if (!("isReplay" in message) || message.isReplay !== true || message.parent_tool_use_id !== null) {
|
|
72015
|
+
return [];
|
|
72016
|
+
}
|
|
72017
|
+
const notification = message.origin === void 0 ? findUnsettledTurn(message.uuid) === void 0 : isTaskNotificationOrigin(message.origin);
|
|
72018
|
+
if (!notification) {
|
|
72019
|
+
return [];
|
|
72020
|
+
}
|
|
72021
|
+
return parseTaskNotifications(message.message.content, message.uuid).map((task) => task.id).filter((id) => awaitingBackgroundResults.has(id) || backgroundTasks.has(id));
|
|
72022
|
+
};
|
|
71084
72023
|
const firstUnsettledQueuedTurn = () => (session.turnQueue ?? []).find((t) => !t.settled);
|
|
71085
72024
|
const publishBackgroundTasks = async () => {
|
|
71086
72025
|
const report = (taskId, state) => {
|
|
@@ -71156,6 +72095,7 @@ var ClaudeAcpAgent = class {
|
|
|
71156
72095
|
backgroundTasks.clear();
|
|
71157
72096
|
awaitingBackgroundResults.clear();
|
|
71158
72097
|
processingBackgroundResults.clear();
|
|
72098
|
+
deliveredBackgroundResults.clear();
|
|
71159
72099
|
backgroundTaskDetails.clear();
|
|
71160
72100
|
try {
|
|
71161
72101
|
await publishBackgroundTasks();
|
|
@@ -71971,14 +72911,22 @@ ${message.api_refusal_explanation}` : "";
|
|
|
71971
72911
|
}
|
|
71972
72912
|
}
|
|
71973
72913
|
} finally {
|
|
72914
|
+
const handled = [...deliveredBackgroundResults];
|
|
72915
|
+
deliveredBackgroundResults.clear();
|
|
72916
|
+
for (const id of handled) {
|
|
72917
|
+
backgroundTasks.delete(id);
|
|
72918
|
+
}
|
|
71974
72919
|
if (message.origin?.kind === "task-notification") {
|
|
71975
|
-
|
|
71976
|
-
awaitingBackgroundResults.delete(id);
|
|
71977
|
-
if (!backgroundTasks.has(id)) {
|
|
71978
|
-
backgroundTaskDetails.delete(id);
|
|
71979
|
-
}
|
|
71980
|
-
}
|
|
72920
|
+
handled.push(...processingBackgroundResults);
|
|
71981
72921
|
processingBackgroundResults.clear();
|
|
72922
|
+
}
|
|
72923
|
+
for (const id of handled) {
|
|
72924
|
+
awaitingBackgroundResults.delete(id);
|
|
72925
|
+
if (!backgroundTasks.has(id)) {
|
|
72926
|
+
backgroundTaskDetails.delete(id);
|
|
72927
|
+
}
|
|
72928
|
+
}
|
|
72929
|
+
if (handled.length > 0 || message.origin?.kind === "task-notification") {
|
|
71982
72930
|
reportBackgroundActivity();
|
|
71983
72931
|
}
|
|
71984
72932
|
if (!isAutonomousResult) {
|
|
@@ -72068,6 +73016,11 @@ ${message.api_refusal_explanation}` : "";
|
|
|
72068
73016
|
}
|
|
72069
73017
|
case "user":
|
|
72070
73018
|
case "assistant": {
|
|
73019
|
+
if (message.type === "user") {
|
|
73020
|
+
for (const id of deliveredTaskResults(message)) {
|
|
73021
|
+
deliveredBackgroundResults.add(id);
|
|
73022
|
+
}
|
|
73023
|
+
}
|
|
72071
73024
|
if (message.type === "user" && isTaskNotificationOrigin(message.origin)) {
|
|
72072
73025
|
const tasks = parseTaskNotifications(message.message.content, message.uuid ?? "unknown");
|
|
72073
73026
|
for (const task of tasks) {
|
|
@@ -76942,12 +77895,12 @@ var CodexOwnedAcpAgent = class {
|
|
|
76942
77895
|
* cancellation), which clients merge idempotently. The wake rides the enqueued
|
|
76943
77896
|
* emission so the waiting prompt's response never precedes the update. */
|
|
76944
77897
|
#settleCompaction = (status, error62) => {
|
|
76945
|
-
const
|
|
76946
|
-
if (
|
|
77898
|
+
const open7 = this.#openCompaction;
|
|
77899
|
+
if (open7 === null) {
|
|
76947
77900
|
return null;
|
|
76948
77901
|
}
|
|
76949
77902
|
const update = {
|
|
76950
|
-
compactionId:
|
|
77903
|
+
compactionId: open7.compactionId,
|
|
76951
77904
|
...status === "failed" && error62 !== void 0 ? { error: error62 } : {},
|
|
76952
77905
|
sessionUpdate: "compaction_update",
|
|
76953
77906
|
status
|
|
@@ -76955,7 +77908,7 @@ var CodexOwnedAcpAgent = class {
|
|
|
76955
77908
|
this.#finishCompaction(async () => {
|
|
76956
77909
|
await this.#context.emit(update);
|
|
76957
77910
|
});
|
|
76958
|
-
return
|
|
77911
|
+
return open7;
|
|
76959
77912
|
};
|
|
76960
77913
|
/** Clears the tracked compaction and emits the terminal update. Used by both
|
|
76961
77914
|
* #settleCompaction and the item/completed handler, which emits its own
|
|
@@ -77023,8 +77976,8 @@ var CodexOwnedAcpAgent = class {
|
|
|
77023
77976
|
]);
|
|
77024
77977
|
} catch (cause) {
|
|
77025
77978
|
signal.throwIfAborted();
|
|
77026
|
-
const
|
|
77027
|
-
if (
|
|
77979
|
+
const open7 = this.#settleCompaction("failed", cause instanceof Error ? cause.message : String(cause));
|
|
77980
|
+
if (open7 === null && !this.#turnSettledCompaction) {
|
|
77028
77981
|
const compactionId = randomUUID8();
|
|
77029
77982
|
await this.#enqueue(async () => {
|
|
77030
77983
|
await this.#context.emit({
|
|
@@ -79597,8 +80550,8 @@ var PiRpcProcess = class _PiRpcProcess {
|
|
|
79597
80550
|
const sessionFile = typeof state?.sessionFile === "string" ? state.sessionFile : null;
|
|
79598
80551
|
if (sessionFile) {
|
|
79599
80552
|
const { mkdirSync: mkdirSync5 } = await import("node:fs");
|
|
79600
|
-
const { dirname:
|
|
79601
|
-
mkdirSync5(
|
|
80553
|
+
const { dirname: dirname13 } = await import("node:path");
|
|
80554
|
+
mkdirSync5(dirname13(sessionFile), { recursive: true });
|
|
79602
80555
|
}
|
|
79603
80556
|
} catch {
|
|
79604
80557
|
}
|
|
@@ -81104,8 +82057,8 @@ var PiAcpSession = class {
|
|
|
81104
82057
|
* without a matching start (e.g. replayed from a persisted session) has no
|
|
81105
82058
|
* entity to patch, and fabricating an id would report a compaction the
|
|
81106
82059
|
* client never saw open. */
|
|
81107
|
-
compactionId(
|
|
81108
|
-
if (!
|
|
82060
|
+
compactionId(open7) {
|
|
82061
|
+
if (!open7) {
|
|
81109
82062
|
const settled = this.activeCompactionId;
|
|
81110
82063
|
this.activeCompactionId = null;
|
|
81111
82064
|
return settled;
|
|
@@ -88583,7 +89536,7 @@ function sql(strings, ...params) {
|
|
|
88583
89536
|
return new SQL([new StringChunk(str)]);
|
|
88584
89537
|
}
|
|
88585
89538
|
_sql.raw = raw;
|
|
88586
|
-
function
|
|
89539
|
+
function join36(chunks, separator) {
|
|
88587
89540
|
const result = [];
|
|
88588
89541
|
for (const [i, chunk] of chunks.entries()) {
|
|
88589
89542
|
if (i > 0 && separator !== void 0) result.push(separator);
|
|
@@ -88591,7 +89544,7 @@ function sql(strings, ...params) {
|
|
|
88591
89544
|
}
|
|
88592
89545
|
return new SQL(result);
|
|
88593
89546
|
}
|
|
88594
|
-
_sql.join =
|
|
89547
|
+
_sql.join = join36;
|
|
88595
89548
|
function identifier2(value) {
|
|
88596
89549
|
return new Name(value);
|
|
88597
89550
|
}
|
|
@@ -90736,7 +91689,7 @@ var SQLiteSelectBase = class extends TypedQueryBuilder {
|
|
|
90736
91689
|
const baseTableName = this.tableName;
|
|
90737
91690
|
const tableName = getTableLikeName(table);
|
|
90738
91691
|
for (const item of extractUsedTable(table)) this.usedTables.add(item);
|
|
90739
|
-
if (typeof tableName === "string" && this.config.joins?.some((
|
|
91692
|
+
if (typeof tableName === "string" && this.config.joins?.some((join36) => join36.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
90740
91693
|
if (!this.isPartialSelect) {
|
|
90741
91694
|
if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") this.config.fields = { [baseTableName]: this.config.fields };
|
|
90742
91695
|
if (typeof tableName === "string" && !is(table, SQL)) {
|
|
@@ -91575,7 +92528,7 @@ var SQLiteDialect = class {
|
|
|
91575
92528
|
if (!joins2) return;
|
|
91576
92529
|
const withEntries = Object.entries(joins2).filter(([_, v]) => v);
|
|
91577
92530
|
if (!withEntries.length) return;
|
|
91578
|
-
return sql.join(withEntries.map(([k2,
|
|
92531
|
+
return sql.join(withEntries.map(([k2, join36]) => {
|
|
91579
92532
|
const relation = tableConfig.relations[k2];
|
|
91580
92533
|
const isSingle2 = is(relation, One2);
|
|
91581
92534
|
const targetTable = aliasedTable(relation.targetTable, `d${currentDepth + 1}`);
|
|
@@ -91586,7 +92539,7 @@ var SQLiteDialect = class {
|
|
|
91586
92539
|
table: targetTable,
|
|
91587
92540
|
mode: isSingle2 ? "first" : "many",
|
|
91588
92541
|
schema,
|
|
91589
|
-
queryConfig:
|
|
92542
|
+
queryConfig: join36,
|
|
91590
92543
|
tableConfig: schema[relation.targetTableName],
|
|
91591
92544
|
relationWhere: filter,
|
|
91592
92545
|
isNested: true,
|
|
@@ -91600,7 +92553,7 @@ var SQLiteDialect = class {
|
|
|
91600
92553
|
key: k2,
|
|
91601
92554
|
selection: innerQuery.selection,
|
|
91602
92555
|
isArray: !isSingle2,
|
|
91603
|
-
isOptional: (relation.optional ?? false) ||
|
|
92556
|
+
isOptional: (relation.optional ?? false) || join36 !== true && !!join36.where
|
|
91604
92557
|
});
|
|
91605
92558
|
const jsonColumns = sql.join(innerQuery.selection.map((s) => {
|
|
91606
92559
|
return sql`${sql.raw(this.escapeString(s.key))}, ${s.selection ? sql`${jsonb}(${sql.identifier(s.key)})` : sql.identifier(s.key)}`;
|
|
@@ -92216,7 +93169,7 @@ var SQLiteUpdateBase = class {
|
|
|
92216
93169
|
createJoin(joinType) {
|
|
92217
93170
|
return ((table, on2) => {
|
|
92218
93171
|
const tableName = getTableLikeName(table);
|
|
92219
|
-
if (typeof tableName === "string" && this.config.joins.some((
|
|
93172
|
+
if (typeof tableName === "string" && this.config.joins.some((join36) => join36.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
92220
93173
|
if (typeof on2 === "function") {
|
|
92221
93174
|
const from = this.config.from ? is(table, SQLiteTable) ? table[Table.Symbol.Columns] : is(table, Subquery) ? table._.selectedFields : is(table, SQLiteViewBase) ? table[ViewBaseConfig].selectedFields : void 0 : void 0;
|
|
92222
93175
|
on2 = on2(new Proxy(this.config.table[Table.Symbol.Columns], new SelectionProxyHandler({
|
|
@@ -99957,7 +100910,7 @@ var RelayConnectionDiagnostics = class {
|
|
|
99957
100910
|
};
|
|
99958
100911
|
|
|
99959
100912
|
// src/engine/runtime/relay/run-relay-connection.ts
|
|
99960
|
-
import { WebSocket as
|
|
100913
|
+
import { WebSocket as WebSocket10 } from "undici";
|
|
99961
100914
|
|
|
99962
100915
|
// src/engine/runtime/catalog/handle-agent-catalog-discovery.ts
|
|
99963
100916
|
import { WebSocket as WebSocket3 } from "undici";
|
|
@@ -100708,8 +101661,442 @@ function createContentWriteCommands(context) {
|
|
|
100708
101661
|
import { WebSocket as WebSocket5 } from "undici";
|
|
100709
101662
|
|
|
100710
101663
|
// src/engine/session/content/session-files.ts
|
|
100711
|
-
import { basename as basename9, extname as extname3, isAbsolute as
|
|
101664
|
+
import { basename as basename9, extname as extname3, isAbsolute as isAbsolute18, join as join35, normalize as normalize3, resolve as resolve18 } from "node:path";
|
|
100712
101665
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
101666
|
+
|
|
101667
|
+
// src/engine/storage/files/workspace-files.ts
|
|
101668
|
+
var import_ignore = __toESM(require_ignore(), 1);
|
|
101669
|
+
import { constants as constants6 } from "node:fs";
|
|
101670
|
+
import { lstat as lstat5, open as open6, readdir as readdir7, realpath as realpath8 } from "node:fs/promises";
|
|
101671
|
+
import { dirname as dirname12, isAbsolute as isAbsolute17, join as join34, parse as parse5, relative as relative4, sep as sep6 } from "node:path";
|
|
101672
|
+
var MAXIMUM_NAME_LENGTH = 255;
|
|
101673
|
+
var MAXIMUM_PATH_LENGTH = 1024;
|
|
101674
|
+
var MAXIMUM_IGNORE_FILE_BYTES = 1024 * 1024;
|
|
101675
|
+
var IGNORE_FILE_READ_CHUNK_BYTES = 64 * 1024;
|
|
101676
|
+
var WORKSPACE_FILE_LIST_DEADLINE_MILLISECONDS = 2e4;
|
|
101677
|
+
var WORKSPACE_FILE_LIST_ATTEMPTS = 2;
|
|
101678
|
+
var WorkspaceFileError = class extends OperationError {
|
|
101679
|
+
code;
|
|
101680
|
+
constructor(code, message, options = {}) {
|
|
101681
|
+
super(code, message, options);
|
|
101682
|
+
this.code = code;
|
|
101683
|
+
this.name = "WorkspaceFileError";
|
|
101684
|
+
}
|
|
101685
|
+
};
|
|
101686
|
+
async function listWorkspaceFiles(root, directory, cursor, limit, signal, timer) {
|
|
101687
|
+
const offset = cursor === void 0 ? 0 : Number(cursor);
|
|
101688
|
+
if (cursor !== void 0 && (!/^(0|[1-9][0-9]{0,9})$/u.test(cursor) || !Number.isSafeInteger(offset))) {
|
|
101689
|
+
throw new WorkspaceFileError("invalid_cursor", "The workspace file cursor is invalid");
|
|
101690
|
+
}
|
|
101691
|
+
const resolved = await resolveWorkspaceDirectory(root, directory, signal);
|
|
101692
|
+
for (let attempt = 1; ; attempt += 1) {
|
|
101693
|
+
try {
|
|
101694
|
+
return await listResolvedDirectory(root, resolved, offset, limit, signal, timer);
|
|
101695
|
+
} catch (cause) {
|
|
101696
|
+
if (!(cause instanceof DirectoryChangedError) || attempt >= WORKSPACE_FILE_LIST_ATTEMPTS) {
|
|
101697
|
+
throw cause;
|
|
101698
|
+
}
|
|
101699
|
+
}
|
|
101700
|
+
}
|
|
101701
|
+
}
|
|
101702
|
+
async function listResolvedDirectory(root, resolved, offset, limit, signal, timer) {
|
|
101703
|
+
const target = resolved.path;
|
|
101704
|
+
const handle = await openValidatedDirectory(resolved);
|
|
101705
|
+
let task;
|
|
101706
|
+
const deadline = new AbortController();
|
|
101707
|
+
try {
|
|
101708
|
+
const ancestry = await recordAncestry(resolved);
|
|
101709
|
+
signal.throwIfAborted();
|
|
101710
|
+
task = timer.schedule(
|
|
101711
|
+
() => deadline.abort(new DOMException("Reading the workspace directory timed out", "TimeoutError")),
|
|
101712
|
+
WORKSPACE_FILE_LIST_DEADLINE_MILLISECONDS
|
|
101713
|
+
);
|
|
101714
|
+
const page = await readOpenedDirectory(
|
|
101715
|
+
root,
|
|
101716
|
+
target,
|
|
101717
|
+
handle,
|
|
101718
|
+
offset,
|
|
101719
|
+
limit,
|
|
101720
|
+
AbortSignal.any([signal, deadline.signal])
|
|
101721
|
+
);
|
|
101722
|
+
await verifyAncestryUnchanged(ancestry, resolved, handle);
|
|
101723
|
+
return page;
|
|
101724
|
+
} catch (cause) {
|
|
101725
|
+
signal.throwIfAborted();
|
|
101726
|
+
if (deadline.signal.aborted) {
|
|
101727
|
+
throw new WorkspaceFileError("read_timeout", "Reading the workspace directory timed out", { cause });
|
|
101728
|
+
}
|
|
101729
|
+
throw cause;
|
|
101730
|
+
} finally {
|
|
101731
|
+
task?.cancel();
|
|
101732
|
+
await handle.close();
|
|
101733
|
+
}
|
|
101734
|
+
}
|
|
101735
|
+
async function readOpenedDirectory(root, target, handle, offset, limit, signal) {
|
|
101736
|
+
const access4 = process.platform === "linux" ? `/proc/self/fd/${handle.fd}` : target;
|
|
101737
|
+
const matcher = await ignoreMatcher(root, target, target, signal);
|
|
101738
|
+
const children = await readdir7(access4, { withFileTypes: true }).catch((cause) => {
|
|
101739
|
+
if (isDenied(cause)) {
|
|
101740
|
+
throw new WorkspaceFileError("file_unavailable", "The workspace directory cannot be read", { cause });
|
|
101741
|
+
}
|
|
101742
|
+
throw cause;
|
|
101743
|
+
});
|
|
101744
|
+
signal.throwIfAborted();
|
|
101745
|
+
const visible = [];
|
|
101746
|
+
for (const entry of children) {
|
|
101747
|
+
if (entry.name.includes("\\") || entry.name.length > MAXIMUM_NAME_LENGTH) {
|
|
101748
|
+
continue;
|
|
101749
|
+
}
|
|
101750
|
+
const path6 = portable(relative4(root, join34(target, entry.name)));
|
|
101751
|
+
const matchedPath = entry.isDirectory() ? `${path6}/` : path6;
|
|
101752
|
+
if (path6.length > MAXIMUM_PATH_LENGTH || isGitPath(path6) || matcher.ignores(matchedPath)) {
|
|
101753
|
+
continue;
|
|
101754
|
+
}
|
|
101755
|
+
if (entry.isDirectory()) {
|
|
101756
|
+
visible.push({ entry, kind: "directory", path: path6 });
|
|
101757
|
+
} else if (entry.isFile()) {
|
|
101758
|
+
visible.push({ entry, kind: "file", path: path6 });
|
|
101759
|
+
}
|
|
101760
|
+
}
|
|
101761
|
+
visible.sort(
|
|
101762
|
+
(left, right) => left.kind === right.kind ? left.entry.name.localeCompare(right.entry.name, void 0, { numeric: true, sensitivity: "base" }) : left.kind === "directory" ? -1 : 1
|
|
101763
|
+
);
|
|
101764
|
+
const selected = visible.slice(offset, offset + limit);
|
|
101765
|
+
const entries = [];
|
|
101766
|
+
for (const { entry, kind, path: path6 } of selected) {
|
|
101767
|
+
if (kind === "directory") {
|
|
101768
|
+
entries.push({ kind, name: entry.name, path: path6 });
|
|
101769
|
+
continue;
|
|
101770
|
+
}
|
|
101771
|
+
try {
|
|
101772
|
+
const metadata = await lstat5(join34(access4, entry.name));
|
|
101773
|
+
signal.throwIfAborted();
|
|
101774
|
+
if (metadata.isFile()) {
|
|
101775
|
+
entries.push({ kind, name: entry.name, path: path6, size: metadata.size });
|
|
101776
|
+
}
|
|
101777
|
+
} catch (cause) {
|
|
101778
|
+
signal.throwIfAborted();
|
|
101779
|
+
if (!isMissing(cause)) {
|
|
101780
|
+
throw cause;
|
|
101781
|
+
}
|
|
101782
|
+
}
|
|
101783
|
+
}
|
|
101784
|
+
const nextOffset = offset + selected.length;
|
|
101785
|
+
return nextOffset < visible.length ? { entries, nextCursor: String(nextOffset) } : { entries };
|
|
101786
|
+
}
|
|
101787
|
+
async function withWorkspaceFile(root, path6, maximumBytes, signal, useFile) {
|
|
101788
|
+
const requested = requestedTarget(root, path6);
|
|
101789
|
+
const metadata = await lstatOrNotFound(requested);
|
|
101790
|
+
signal.throwIfAborted();
|
|
101791
|
+
if (metadata.isSymbolicLink() || !metadata.isFile()) {
|
|
101792
|
+
throw new WorkspaceFileError("file_unavailable", "The workspace path is not a regular file");
|
|
101793
|
+
}
|
|
101794
|
+
const canonical = await realpathOrNotFound(requested);
|
|
101795
|
+
signal.throwIfAborted();
|
|
101796
|
+
const rootPath = containedPath(root, canonical);
|
|
101797
|
+
const parent = dirname12(canonical);
|
|
101798
|
+
if (isGitPath(rootPath) || (await ignoreMatcher(root, parent, parent, signal)).ignores(rootPath)) {
|
|
101799
|
+
throw new WorkspaceFileError("file_ignored", "The workspace file is hidden by ignore rules");
|
|
101800
|
+
}
|
|
101801
|
+
try {
|
|
101802
|
+
await withScopedLocalFile(root, rootPath, maximumBytes, signal, useFile);
|
|
101803
|
+
} catch (cause) {
|
|
101804
|
+
signal.throwIfAborted();
|
|
101805
|
+
if (cause instanceof ScopedFileReadError) {
|
|
101806
|
+
throw new WorkspaceFileError(cause.code, "The workspace file is unavailable", { cause });
|
|
101807
|
+
}
|
|
101808
|
+
if (isMissing(cause)) {
|
|
101809
|
+
throw new WorkspaceFileError("file_not_found", "The workspace file does not exist", { cause });
|
|
101810
|
+
}
|
|
101811
|
+
throw cause;
|
|
101812
|
+
}
|
|
101813
|
+
}
|
|
101814
|
+
async function resolveWorkspaceDirectory(root, directory, signal) {
|
|
101815
|
+
let canonical = root;
|
|
101816
|
+
if (directory !== ".") {
|
|
101817
|
+
const requested = requestedTarget(root, directory);
|
|
101818
|
+
const metadata = await lstatOrNotFound(requested);
|
|
101819
|
+
signal.throwIfAborted();
|
|
101820
|
+
if (metadata.isSymbolicLink() || !metadata.isDirectory()) {
|
|
101821
|
+
throw new WorkspaceFileError("file_unavailable", "The workspace path is not a regular directory");
|
|
101822
|
+
}
|
|
101823
|
+
canonical = await realpathOrNotFound(requested);
|
|
101824
|
+
signal.throwIfAborted();
|
|
101825
|
+
if (isGitPath(containedPath(root, canonical))) {
|
|
101826
|
+
throw new WorkspaceFileError("file_ignored", "The workspace directory is hidden");
|
|
101827
|
+
}
|
|
101828
|
+
}
|
|
101829
|
+
const identity2 = await ancestorState(canonical);
|
|
101830
|
+
signal.throwIfAborted();
|
|
101831
|
+
return { path: canonical, device: identity2.device, inode: identity2.inode };
|
|
101832
|
+
}
|
|
101833
|
+
async function openValidatedDirectory(resolved) {
|
|
101834
|
+
let handle;
|
|
101835
|
+
try {
|
|
101836
|
+
handle = await open6(resolved.path, constants6.O_RDONLY | constants6.O_DIRECTORY | constants6.O_NOFOLLOW);
|
|
101837
|
+
} catch (cause) {
|
|
101838
|
+
if (hasCode(cause, "ELOOP") || hasCode(cause, "ENOTDIR")) {
|
|
101839
|
+
throw directoryChanged(cause);
|
|
101840
|
+
}
|
|
101841
|
+
if (isMissing(cause)) {
|
|
101842
|
+
throw new WorkspaceFileError("file_not_found", "The workspace path does not exist", { cause });
|
|
101843
|
+
}
|
|
101844
|
+
if (isDenied(cause)) {
|
|
101845
|
+
throw new WorkspaceFileError("file_unavailable", "The workspace directory cannot be read", { cause });
|
|
101846
|
+
}
|
|
101847
|
+
throw cause;
|
|
101848
|
+
}
|
|
101849
|
+
try {
|
|
101850
|
+
if (!sameDirectory(resolved, await handle.stat({ bigint: true }))) {
|
|
101851
|
+
throw directoryChanged();
|
|
101852
|
+
}
|
|
101853
|
+
return handle;
|
|
101854
|
+
} catch (cause) {
|
|
101855
|
+
await handle.close();
|
|
101856
|
+
throw cause;
|
|
101857
|
+
}
|
|
101858
|
+
}
|
|
101859
|
+
async function recordAncestry(resolved) {
|
|
101860
|
+
const top = parse5(resolved.path).root;
|
|
101861
|
+
const below = relative4(top, resolved.path);
|
|
101862
|
+
const paths = [top];
|
|
101863
|
+
for (const segment of below === "" ? [] : below.split(sep6)) {
|
|
101864
|
+
paths.push(join34(paths[paths.length - 1] ?? top, segment));
|
|
101865
|
+
}
|
|
101866
|
+
const ancestry = [];
|
|
101867
|
+
for (const path6 of paths) {
|
|
101868
|
+
ancestry.push(await ancestorState(path6));
|
|
101869
|
+
}
|
|
101870
|
+
const listed = ancestry[ancestry.length - 1];
|
|
101871
|
+
if (listed === void 0 || listed.device !== resolved.device || listed.inode !== resolved.inode) {
|
|
101872
|
+
throw directoryChanged();
|
|
101873
|
+
}
|
|
101874
|
+
return ancestry;
|
|
101875
|
+
}
|
|
101876
|
+
async function verifyAncestryUnchanged(ancestry, resolved, handle) {
|
|
101877
|
+
if (!sameDirectory(resolved, await handle.stat({ bigint: true }))) {
|
|
101878
|
+
throw directoryChanged();
|
|
101879
|
+
}
|
|
101880
|
+
for (const [index2, before] of ancestry.entries()) {
|
|
101881
|
+
const after = await ancestorState(before.path);
|
|
101882
|
+
const holdsNext = index2 < ancestry.length - 1;
|
|
101883
|
+
if (after.device !== before.device || after.inode !== before.inode || holdsNext && (after.changedAt !== before.changedAt || after.modifiedAt !== before.modifiedAt)) {
|
|
101884
|
+
throw directoryChanged();
|
|
101885
|
+
}
|
|
101886
|
+
}
|
|
101887
|
+
try {
|
|
101888
|
+
if (await realpath8(resolved.path) !== resolved.path) {
|
|
101889
|
+
throw directoryChanged();
|
|
101890
|
+
}
|
|
101891
|
+
} catch (cause) {
|
|
101892
|
+
if (isMissing(cause) || hasCode(cause, "ELOOP")) {
|
|
101893
|
+
throw directoryChanged(cause);
|
|
101894
|
+
}
|
|
101895
|
+
throw cause;
|
|
101896
|
+
}
|
|
101897
|
+
}
|
|
101898
|
+
async function ancestorState(path6) {
|
|
101899
|
+
let metadata;
|
|
101900
|
+
try {
|
|
101901
|
+
metadata = await lstat5(path6, { bigint: true });
|
|
101902
|
+
} catch (cause) {
|
|
101903
|
+
if (isMissing(cause) || hasCode(cause, "ELOOP")) {
|
|
101904
|
+
throw directoryChanged(cause);
|
|
101905
|
+
}
|
|
101906
|
+
throw cause;
|
|
101907
|
+
}
|
|
101908
|
+
if (metadata.isSymbolicLink() || !metadata.isDirectory()) {
|
|
101909
|
+
throw directoryChanged();
|
|
101910
|
+
}
|
|
101911
|
+
return {
|
|
101912
|
+
path: path6,
|
|
101913
|
+
device: metadata.dev,
|
|
101914
|
+
inode: metadata.ino,
|
|
101915
|
+
changedAt: metadata.ctimeNs,
|
|
101916
|
+
modifiedAt: metadata.mtimeNs
|
|
101917
|
+
};
|
|
101918
|
+
}
|
|
101919
|
+
function sameDirectory(resolved, metadata) {
|
|
101920
|
+
return metadata.isDirectory() && metadata.dev === resolved.device && metadata.ino === resolved.inode;
|
|
101921
|
+
}
|
|
101922
|
+
var DirectoryChangedError = class extends WorkspaceFileError {
|
|
101923
|
+
constructor(options) {
|
|
101924
|
+
super("file_outside_scope", "The workspace directory changed while it was being read", options);
|
|
101925
|
+
this.name = "DirectoryChangedError";
|
|
101926
|
+
}
|
|
101927
|
+
};
|
|
101928
|
+
function directoryChanged(cause) {
|
|
101929
|
+
return new DirectoryChangedError(cause === void 0 ? {} : { cause });
|
|
101930
|
+
}
|
|
101931
|
+
function requestedTarget(root, path6) {
|
|
101932
|
+
const segments = path6.split("/");
|
|
101933
|
+
if (path6.length === 0 || path6.length > MAXIMUM_PATH_LENGTH || /[\0\\]/u.test(path6) || segments.some((segment) => segment.length === 0 || segment === "." || segment === "..")) {
|
|
101934
|
+
throw new WorkspaceFileError("file_outside_scope", "The workspace path leaves its directory");
|
|
101935
|
+
}
|
|
101936
|
+
return join34(root, ...segments);
|
|
101937
|
+
}
|
|
101938
|
+
function containedPath(root, canonical) {
|
|
101939
|
+
const child = relative4(root, canonical);
|
|
101940
|
+
if (child === "" || child === ".." || child.startsWith(`..${sep6}`) || isAbsolute17(child)) {
|
|
101941
|
+
throw new WorkspaceFileError("file_outside_scope", "The workspace path leaves its directory");
|
|
101942
|
+
}
|
|
101943
|
+
return portable(child);
|
|
101944
|
+
}
|
|
101945
|
+
async function ignoreMatcher(root, throughDirectory, explicitDirectory, signal) {
|
|
101946
|
+
const rules = [{ base: ".", matcher: (0, import_ignore.default)().add(".git/").add(".git/**") }];
|
|
101947
|
+
const through = relative4(root, throughDirectory);
|
|
101948
|
+
const segments = through === "" ? [] : through.split(sep6);
|
|
101949
|
+
let directory = root;
|
|
101950
|
+
for (let index2 = 0; index2 <= segments.length; index2 += 1) {
|
|
101951
|
+
const matcher = (0, import_ignore.default)();
|
|
101952
|
+
for (const name2 of [".gitignore", ".ignore"]) {
|
|
101953
|
+
matcher.add(await readIgnoreFile(join34(directory, name2), signal));
|
|
101954
|
+
}
|
|
101955
|
+
rules.push({ base: portable(relative4(root, directory)), matcher });
|
|
101956
|
+
const segment = segments[index2];
|
|
101957
|
+
if (segment !== void 0) {
|
|
101958
|
+
directory = join34(directory, segment);
|
|
101959
|
+
}
|
|
101960
|
+
}
|
|
101961
|
+
const explicit = portable(relative4(root, explicitDirectory));
|
|
101962
|
+
if (explicit !== ".") {
|
|
101963
|
+
for (const rule of rules) {
|
|
101964
|
+
const local = relativeTo(rule.base, explicit);
|
|
101965
|
+
if (local === void 0 || local === ".") {
|
|
101966
|
+
continue;
|
|
101967
|
+
}
|
|
101968
|
+
const localSegments = local.split("/").map(literalIgnorePattern);
|
|
101969
|
+
for (let index2 = 0; index2 < localSegments.length; index2 += 1) {
|
|
101970
|
+
rule.matcher.add([`!/${localSegments.slice(0, index2 + 1).join("/")}/`]);
|
|
101971
|
+
}
|
|
101972
|
+
}
|
|
101973
|
+
}
|
|
101974
|
+
return {
|
|
101975
|
+
ignores: (rootPath) => {
|
|
101976
|
+
let ignored = false;
|
|
101977
|
+
for (const rule of rules) {
|
|
101978
|
+
const local = relativeTo(rule.base, rootPath);
|
|
101979
|
+
if (local === void 0 || local === ".") {
|
|
101980
|
+
continue;
|
|
101981
|
+
}
|
|
101982
|
+
const result = rule.matcher.test(local);
|
|
101983
|
+
if (result.ignored) {
|
|
101984
|
+
ignored = true;
|
|
101985
|
+
}
|
|
101986
|
+
if (result.unignored) {
|
|
101987
|
+
ignored = false;
|
|
101988
|
+
}
|
|
101989
|
+
}
|
|
101990
|
+
return ignored;
|
|
101991
|
+
}
|
|
101992
|
+
};
|
|
101993
|
+
}
|
|
101994
|
+
async function readIgnoreFile(path6, signal) {
|
|
101995
|
+
let handle;
|
|
101996
|
+
try {
|
|
101997
|
+
handle = await open6(path6, constants6.O_RDONLY | constants6.O_NOFOLLOW | constants6.O_NONBLOCK);
|
|
101998
|
+
} catch (cause) {
|
|
101999
|
+
signal.throwIfAborted();
|
|
102000
|
+
if (isMissing(cause) || hasCode(cause, "ELOOP")) {
|
|
102001
|
+
return "";
|
|
102002
|
+
}
|
|
102003
|
+
throw ignoreRulesUnavailable(cause);
|
|
102004
|
+
}
|
|
102005
|
+
try {
|
|
102006
|
+
const metadata = await handle.stat();
|
|
102007
|
+
signal.throwIfAborted();
|
|
102008
|
+
if (!metadata.isFile()) {
|
|
102009
|
+
return "";
|
|
102010
|
+
}
|
|
102011
|
+
if (metadata.size > MAXIMUM_IGNORE_FILE_BYTES) {
|
|
102012
|
+
throw ignoreRulesUnavailable();
|
|
102013
|
+
}
|
|
102014
|
+
const buffer = Buffer.alloc(MAXIMUM_IGNORE_FILE_BYTES + 1);
|
|
102015
|
+
let length = 0;
|
|
102016
|
+
for (; ; ) {
|
|
102017
|
+
const { bytesRead } = await handle.read(
|
|
102018
|
+
buffer,
|
|
102019
|
+
length,
|
|
102020
|
+
Math.min(IGNORE_FILE_READ_CHUNK_BYTES, buffer.length - length),
|
|
102021
|
+
length
|
|
102022
|
+
);
|
|
102023
|
+
signal.throwIfAborted();
|
|
102024
|
+
if (bytesRead === 0) {
|
|
102025
|
+
break;
|
|
102026
|
+
}
|
|
102027
|
+
length += bytesRead;
|
|
102028
|
+
if (length > MAXIMUM_IGNORE_FILE_BYTES) {
|
|
102029
|
+
throw ignoreRulesUnavailable();
|
|
102030
|
+
}
|
|
102031
|
+
}
|
|
102032
|
+
return buffer.toString("utf8", 0, length);
|
|
102033
|
+
} catch (cause) {
|
|
102034
|
+
signal.throwIfAborted();
|
|
102035
|
+
if (cause instanceof WorkspaceFileError) {
|
|
102036
|
+
throw cause;
|
|
102037
|
+
}
|
|
102038
|
+
throw ignoreRulesUnavailable(cause);
|
|
102039
|
+
} finally {
|
|
102040
|
+
await handle.close();
|
|
102041
|
+
}
|
|
102042
|
+
}
|
|
102043
|
+
function ignoreRulesUnavailable(cause) {
|
|
102044
|
+
return new WorkspaceFileError(
|
|
102045
|
+
"ignore_rules_unavailable",
|
|
102046
|
+
"An ignore file in the workspace cannot be read",
|
|
102047
|
+
cause === void 0 ? {} : { cause }
|
|
102048
|
+
);
|
|
102049
|
+
}
|
|
102050
|
+
function literalIgnorePattern(segment) {
|
|
102051
|
+
return segment.replace(/[\\*?[\]!# ]/gu, (character) => `\\${character}`);
|
|
102052
|
+
}
|
|
102053
|
+
function relativeTo(base, path6) {
|
|
102054
|
+
if (base === ".") {
|
|
102055
|
+
return path6;
|
|
102056
|
+
}
|
|
102057
|
+
if (path6 === base) {
|
|
102058
|
+
return ".";
|
|
102059
|
+
}
|
|
102060
|
+
return path6.startsWith(`${base}/`) ? path6.slice(base.length + 1) : void 0;
|
|
102061
|
+
}
|
|
102062
|
+
function portable(path6) {
|
|
102063
|
+
const value = path6.split(sep6).join("/");
|
|
102064
|
+
return value === "" ? "." : value;
|
|
102065
|
+
}
|
|
102066
|
+
function isGitPath(path6) {
|
|
102067
|
+
return path6.split("/").includes(".git");
|
|
102068
|
+
}
|
|
102069
|
+
function isMissing(error62) {
|
|
102070
|
+
return error62 instanceof Error && "code" in error62 && (error62.code === "ENOENT" || error62.code === "ENOTDIR" || error62.code === "EISDIR");
|
|
102071
|
+
}
|
|
102072
|
+
function hasCode(error62, code) {
|
|
102073
|
+
return error62 instanceof Error && "code" in error62 && error62.code === code;
|
|
102074
|
+
}
|
|
102075
|
+
function isDenied(error62) {
|
|
102076
|
+
return error62 instanceof Error && "code" in error62 && (error62.code === "EACCES" || error62.code === "EPERM");
|
|
102077
|
+
}
|
|
102078
|
+
async function lstatOrNotFound(path6) {
|
|
102079
|
+
try {
|
|
102080
|
+
return await lstat5(path6);
|
|
102081
|
+
} catch (cause) {
|
|
102082
|
+
if (isMissing(cause)) {
|
|
102083
|
+
throw new WorkspaceFileError("file_not_found", "The workspace path does not exist", { cause });
|
|
102084
|
+
}
|
|
102085
|
+
throw cause;
|
|
102086
|
+
}
|
|
102087
|
+
}
|
|
102088
|
+
async function realpathOrNotFound(path6) {
|
|
102089
|
+
try {
|
|
102090
|
+
return await realpath8(path6);
|
|
102091
|
+
} catch (cause) {
|
|
102092
|
+
if (isMissing(cause)) {
|
|
102093
|
+
throw new WorkspaceFileError("file_not_found", "The workspace path does not exist", { cause });
|
|
102094
|
+
}
|
|
102095
|
+
throw cause;
|
|
102096
|
+
}
|
|
102097
|
+
}
|
|
102098
|
+
|
|
102099
|
+
// src/engine/session/content/session-files.ts
|
|
100713
102100
|
function requestedPath(value) {
|
|
100714
102101
|
if (value.includes("\0")) {
|
|
100715
102102
|
return null;
|
|
@@ -100726,21 +102113,21 @@ function requestedPath(value) {
|
|
|
100726
102113
|
}
|
|
100727
102114
|
async function resolveFile(value, workingDirectory, signal) {
|
|
100728
102115
|
const requested = requestedPath(value);
|
|
100729
|
-
if (requested === null || !
|
|
102116
|
+
if (requested === null || !isAbsolute18(requested.path) && workingDirectory === null) {
|
|
100730
102117
|
return null;
|
|
100731
102118
|
}
|
|
100732
|
-
if (
|
|
102119
|
+
if (isAbsolute18(requested.path) && normalize3(requested.path) !== requested.path) {
|
|
100733
102120
|
return null;
|
|
100734
102121
|
}
|
|
100735
|
-
const candidates = requested.explicitUrl || workingDirectory === null ? [requested.path] :
|
|
102122
|
+
const candidates = requested.explicitUrl || workingDirectory === null ? [requested.path] : isAbsolute18(requested.path) ? [join35(workingDirectory, requested.path), requested.path] : [resolve18(workingDirectory, requested.path)];
|
|
100736
102123
|
for (const candidate of candidates) {
|
|
100737
|
-
if (!
|
|
102124
|
+
if (!isAbsolute18(candidate) || normalize3(candidate) !== candidate) {
|
|
100738
102125
|
continue;
|
|
100739
102126
|
}
|
|
100740
102127
|
try {
|
|
100741
102128
|
const target = await canonicalPath(candidate);
|
|
100742
102129
|
signal.throwIfAborted();
|
|
100743
|
-
if (
|
|
102130
|
+
if (isAbsolute18(target) && normalize3(target) === target) {
|
|
100744
102131
|
return target;
|
|
100745
102132
|
}
|
|
100746
102133
|
} catch {
|
|
@@ -100796,31 +102183,39 @@ async function streamScopedFile(command, send2, sendChunk, signal, workingDirect
|
|
|
100796
102183
|
throw new ScopedFileReadError("file_outside_scope");
|
|
100797
102184
|
}
|
|
100798
102185
|
await withScopedLocalFile(workingDirectory, requested.path, command.maxBytes, signal, async (file2) => {
|
|
100799
|
-
|
|
100800
|
-
|
|
100801
|
-
|
|
100802
|
-
|
|
100803
|
-
|
|
100804
|
-
|
|
100805
|
-
modifiedAt: file2.modifiedAt.toISOString(),
|
|
100806
|
-
name: file2.name,
|
|
100807
|
-
requestId: command.requestId,
|
|
100808
|
-
sessionId: command.sessionId
|
|
100809
|
-
});
|
|
100810
|
-
let sequence = 0;
|
|
100811
|
-
let received = 0;
|
|
100812
|
-
for await (const bytes of file2.chunks(CONTENT_CHUNK_MAX_BYTES)) {
|
|
100813
|
-
received += bytes.byteLength;
|
|
100814
|
-
sendChunk(command.requestId, sequence, bytes);
|
|
100815
|
-
sequence += 1;
|
|
100816
|
-
}
|
|
100817
|
-
if (received !== file2.size) {
|
|
100818
|
-
throw new ScopedFileReadError("file_unavailable");
|
|
100819
|
-
}
|
|
100820
|
-
await file2.verifyUnchanged();
|
|
100821
|
-
send2({ kind: FILE_END_KIND, requestId: command.requestId, sessionId: command.sessionId });
|
|
102186
|
+
await streamOpenedFile(file2, command.requestId, command.sessionId, send2, sendChunk, signal);
|
|
102187
|
+
});
|
|
102188
|
+
}
|
|
102189
|
+
async function streamWorkspaceFile(command, root, send2, sendChunk, signal) {
|
|
102190
|
+
await withWorkspaceFile(root, command.path, command.maxBytes, signal, async (file2) => {
|
|
102191
|
+
await streamOpenedFile(file2, command.requestId, WORKSPACE_FILE_REPLY_SESSION_ID, send2, sendChunk, signal);
|
|
100822
102192
|
});
|
|
100823
102193
|
}
|
|
102194
|
+
async function streamOpenedFile(file2, requestId, sessionId, send2, sendChunk, signal) {
|
|
102195
|
+
const header = await file2.readPrefix(16);
|
|
102196
|
+
signal.throwIfAborted();
|
|
102197
|
+
send2({
|
|
102198
|
+
byteLength: file2.size,
|
|
102199
|
+
kind: FILE_BEGIN_KIND,
|
|
102200
|
+
mediaType: sniffRasterMime(header) ?? "application/octet-stream",
|
|
102201
|
+
modifiedAt: file2.modifiedAt.toISOString(),
|
|
102202
|
+
name: file2.name,
|
|
102203
|
+
requestId,
|
|
102204
|
+
sessionId
|
|
102205
|
+
});
|
|
102206
|
+
let sequence = 0;
|
|
102207
|
+
let received = 0;
|
|
102208
|
+
for await (const bytes of file2.chunks(CONTENT_CHUNK_MAX_BYTES)) {
|
|
102209
|
+
received += bytes.byteLength;
|
|
102210
|
+
sendChunk(requestId, sequence, bytes);
|
|
102211
|
+
sequence += 1;
|
|
102212
|
+
}
|
|
102213
|
+
if (received !== file2.size) {
|
|
102214
|
+
throw new ScopedFileReadError("file_unavailable");
|
|
102215
|
+
}
|
|
102216
|
+
await file2.verifyUnchanged();
|
|
102217
|
+
send2({ kind: FILE_END_KIND, requestId, sessionId });
|
|
102218
|
+
}
|
|
100824
102219
|
|
|
100825
102220
|
// src/engine/runtime/command/registry/file-read/index.ts
|
|
100826
102221
|
var fileReadCommand = {
|
|
@@ -101738,7 +103133,8 @@ var runtimePingCommand = {
|
|
|
101738
103133
|
sessionTitleGeneration: true,
|
|
101739
103134
|
requestId: message.requestId,
|
|
101740
103135
|
scopedFileRead: supportsScopedLocalFileRead(),
|
|
101741
|
-
usageQuota: true
|
|
103136
|
+
usageQuota: true,
|
|
103137
|
+
workspaceFiles: supportsScopedLocalFileRead()
|
|
101742
103138
|
});
|
|
101743
103139
|
}
|
|
101744
103140
|
};
|
|
@@ -102176,6 +103572,88 @@ var sessionConfigReadCommand = {
|
|
|
102176
103572
|
}
|
|
102177
103573
|
};
|
|
102178
103574
|
|
|
103575
|
+
// src/engine/runtime/command/registry/workspace-files.ts
|
|
103576
|
+
import { WebSocket as WebSocket8 } from "undici";
|
|
103577
|
+
async function workspaceRoot(context, command) {
|
|
103578
|
+
try {
|
|
103579
|
+
return await context.directories.resolve(command.bindingId, command.directoryId, context.signal);
|
|
103580
|
+
} catch (cause) {
|
|
103581
|
+
context.signal.throwIfAborted();
|
|
103582
|
+
if (cause instanceof LocalAuthorizationError) {
|
|
103583
|
+
throw new WorkspaceFileError("directory_unavailable", cause.message, { cause });
|
|
103584
|
+
}
|
|
103585
|
+
throw cause;
|
|
103586
|
+
}
|
|
103587
|
+
}
|
|
103588
|
+
async function executeWorkspaceFileList(context, command) {
|
|
103589
|
+
try {
|
|
103590
|
+
const root = await workspaceRoot(context, command);
|
|
103591
|
+
const page = await listWorkspaceFiles(
|
|
103592
|
+
root,
|
|
103593
|
+
command.directory,
|
|
103594
|
+
command.cursor,
|
|
103595
|
+
command.limit,
|
|
103596
|
+
context.signal,
|
|
103597
|
+
context.timer
|
|
103598
|
+
);
|
|
103599
|
+
send(context.socket, {
|
|
103600
|
+
bindingId: command.bindingId,
|
|
103601
|
+
directoryId: command.directoryId,
|
|
103602
|
+
entries: page.entries,
|
|
103603
|
+
kind: WORKSPACE_FILES_KIND,
|
|
103604
|
+
...page.nextCursor === void 0 ? {} : { nextCursor: page.nextCursor },
|
|
103605
|
+
requestId: command.requestId
|
|
103606
|
+
});
|
|
103607
|
+
} catch (error62) {
|
|
103608
|
+
if (context.signal.aborted) {
|
|
103609
|
+
return;
|
|
103610
|
+
}
|
|
103611
|
+
reportOperationFailure(context.socket, command.requestId, "", error62);
|
|
103612
|
+
}
|
|
103613
|
+
}
|
|
103614
|
+
async function executeWorkspaceFileRead(context, command) {
|
|
103615
|
+
const { signal, socket } = context;
|
|
103616
|
+
try {
|
|
103617
|
+
const root = await workspaceRoot(context, command);
|
|
103618
|
+
await streamWorkspaceFile(
|
|
103619
|
+
command,
|
|
103620
|
+
root,
|
|
103621
|
+
(response) => send(socket, response),
|
|
103622
|
+
(requestId, sequence, bytes) => sendContentChunk(socket, requestId, sequence, bytes),
|
|
103623
|
+
signal
|
|
103624
|
+
);
|
|
103625
|
+
} catch (error62) {
|
|
103626
|
+
if (socket.readyState !== WebSocket8.OPEN || signal.aborted) {
|
|
103627
|
+
return;
|
|
103628
|
+
}
|
|
103629
|
+
send(socket, {
|
|
103630
|
+
code: error62 instanceof WorkspaceFileError ? error62.code : "file_unavailable",
|
|
103631
|
+
kind: FILE_FAILED_KIND,
|
|
103632
|
+
message: error62 instanceof WorkspaceFileError ? error62.message : "The local file is unavailable",
|
|
103633
|
+
requestId: command.requestId,
|
|
103634
|
+
sessionId: WORKSPACE_FILE_REPLY_SESSION_ID
|
|
103635
|
+
});
|
|
103636
|
+
}
|
|
103637
|
+
}
|
|
103638
|
+
var workspaceFileListCommand = {
|
|
103639
|
+
kind: WORKSPACE_FILES_LIST_KIND,
|
|
103640
|
+
handle: (context, message) => {
|
|
103641
|
+
if (message.kind !== WORKSPACE_FILES_LIST_KIND) {
|
|
103642
|
+
throw new Error("Command kind mismatch");
|
|
103643
|
+
}
|
|
103644
|
+
void executeWorkspaceFileList(context, message);
|
|
103645
|
+
}
|
|
103646
|
+
};
|
|
103647
|
+
var workspaceFileReadCommand = {
|
|
103648
|
+
kind: WORKSPACE_FILE_READ_KIND,
|
|
103649
|
+
handle: (context, message) => {
|
|
103650
|
+
if (message.kind !== WORKSPACE_FILE_READ_KIND) {
|
|
103651
|
+
throw new Error("Command kind mismatch");
|
|
103652
|
+
}
|
|
103653
|
+
void executeWorkspaceFileRead(context, message);
|
|
103654
|
+
}
|
|
103655
|
+
};
|
|
103656
|
+
|
|
102179
103657
|
// src/engine/runtime/command/registry/index.ts
|
|
102180
103658
|
function createCommandRegistry(context) {
|
|
102181
103659
|
const contentWrites = createContentWriteCommands(context);
|
|
@@ -102196,6 +103674,8 @@ function createCommandRegistry(context) {
|
|
|
102196
103674
|
sessionCloseCommand,
|
|
102197
103675
|
promptDispositionCommand,
|
|
102198
103676
|
workspaceListCommand,
|
|
103677
|
+
workspaceFileListCommand,
|
|
103678
|
+
workspaceFileReadCommand,
|
|
102199
103679
|
sessionPrepareCommand,
|
|
102200
103680
|
sessionConfigureCommand,
|
|
102201
103681
|
sessionConfigReadCommand,
|
|
@@ -102244,7 +103724,7 @@ function createRuntimeCommandDispatcher(options) {
|
|
|
102244
103724
|
}
|
|
102245
103725
|
|
|
102246
103726
|
// src/engine/runtime/relay/connect.ts
|
|
102247
|
-
import { WebSocket as
|
|
103727
|
+
import { WebSocket as WebSocket9 } from "undici";
|
|
102248
103728
|
var CONNECTION_TIMEOUT_MILLISECONDS = 6e4;
|
|
102249
103729
|
var RelayConnectionError = class extends Error {
|
|
102250
103730
|
code;
|
|
@@ -102309,7 +103789,7 @@ function connectRelay(url2, signal, transportFailed = () => void 0) {
|
|
|
102309
103789
|
const endpoint = new URL(url2);
|
|
102310
103790
|
const headers = relayAuthorization(endpoint);
|
|
102311
103791
|
endpoint.searchParams.delete("token");
|
|
102312
|
-
const socket = new
|
|
103792
|
+
const socket = new WebSocket9(endpoint, {
|
|
102313
103793
|
dispatcher,
|
|
102314
103794
|
headers
|
|
102315
103795
|
});
|
|
@@ -102554,7 +104034,7 @@ async function runRelayConnection({
|
|
|
102554
104034
|
timer
|
|
102555
104035
|
});
|
|
102556
104036
|
void reportUpgradeAvailability((result) => {
|
|
102557
|
-
if (socket.readyState ===
|
|
104037
|
+
if (socket.readyState === WebSocket10.OPEN) {
|
|
102558
104038
|
send(socket, result);
|
|
102559
104039
|
}
|
|
102560
104040
|
}, signal).catch((cause) => {
|
|
@@ -102605,14 +104085,14 @@ async function runRelayConnection({
|
|
|
102605
104085
|
};
|
|
102606
104086
|
const connectionLiveness = new RelayConnectionLiveness(timer, {
|
|
102607
104087
|
send: (message) => {
|
|
102608
|
-
if (socket.readyState !==
|
|
104088
|
+
if (socket.readyState !== WebSocket10.OPEN) {
|
|
102609
104089
|
return false;
|
|
102610
104090
|
}
|
|
102611
104091
|
try {
|
|
102612
104092
|
send(socket, message);
|
|
102613
104093
|
return true;
|
|
102614
104094
|
} catch (error62) {
|
|
102615
|
-
if (socket.readyState !==
|
|
104095
|
+
if (socket.readyState !== WebSocket10.OPEN) {
|
|
102616
104096
|
return false;
|
|
102617
104097
|
}
|
|
102618
104098
|
throw error62;
|
|
@@ -102714,7 +104194,7 @@ async function runRelayConnection({
|
|
|
102714
104194
|
}
|
|
102715
104195
|
|
|
102716
104196
|
// src/engine/runtime/relay/session-event-publisher.ts
|
|
102717
|
-
import { WebSocket as
|
|
104197
|
+
import { WebSocket as WebSocket11 } from "undici";
|
|
102718
104198
|
var MAX_BUFFERED_BYTES = 32 * 1024 * 1024;
|
|
102719
104199
|
var MAX_PENDING_BYTES2 = 32 * 1024 * 1024;
|
|
102720
104200
|
var MAX_EVENT_BATCH_BYTES = 1024 * 1024;
|
|
@@ -102769,7 +104249,7 @@ var RuntimeSessionEventPublisher = class {
|
|
|
102769
104249
|
};
|
|
102770
104250
|
#send = (message) => {
|
|
102771
104251
|
const connection = this.#connection;
|
|
102772
|
-
if (connection.kind !== "connected" || connection.socket.readyState !==
|
|
104252
|
+
if (connection.kind !== "connected" || connection.socket.readyState !== WebSocket11.OPEN) {
|
|
102773
104253
|
return;
|
|
102774
104254
|
}
|
|
102775
104255
|
const socket = connection.socket;
|
|
@@ -102831,7 +104311,7 @@ var RuntimeSessionEventPublisher = class {
|
|
|
102831
104311
|
});
|
|
102832
104312
|
}
|
|
102833
104313
|
const connection = this.#connection;
|
|
102834
|
-
if (connection.kind !== "connected" || connection.socket.readyState !==
|
|
104314
|
+
if (connection.kind !== "connected" || connection.socket.readyState !== WebSocket11.OPEN) {
|
|
102835
104315
|
return;
|
|
102836
104316
|
}
|
|
102837
104317
|
const socket = connection.socket;
|
|
@@ -102870,7 +104350,7 @@ var RuntimeSessionEventPublisher = class {
|
|
|
102870
104350
|
flushEvents = (socket) => {
|
|
102871
104351
|
this.cancelFlush();
|
|
102872
104352
|
const connection = this.#connection;
|
|
102873
|
-
if (connection.kind !== "connected" || connection.socket !== socket || socket.readyState !==
|
|
104353
|
+
if (connection.kind !== "connected" || connection.socket !== socket || socket.readyState !== WebSocket11.OPEN) {
|
|
102874
104354
|
return;
|
|
102875
104355
|
}
|
|
102876
104356
|
let sent = 0;
|
|
@@ -103372,4 +104852,4 @@ export {
|
|
|
103372
104852
|
* MIT Licensed
|
|
103373
104853
|
*)
|
|
103374
104854
|
*/
|
|
103375
|
-
//# sourceMappingURL=chunk-
|
|
104855
|
+
//# sourceMappingURL=chunk-TDFSYA4U.js.map
|