pi-fabric 0.76.0 → 0.76.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{chunk-NI3ZXJZD.js → chunk-PAAXKXWT.js} +293 -1
- package/dist/chunks/{chunk-NI3ZXJZD.js.map → chunk-PAAXKXWT.js.map} +3 -3
- package/dist/chunks/{fabric-runtime-state-FBAJTXB2.js → fabric-runtime-state-VCLWTB55.js} +7 -5
- package/dist/chunks/fabric-runtime-state-VCLWTB55.js.map +7 -0
- package/dist/core/system-guidance.d.ts.map +1 -1
- package/dist/execution-service.d.ts.map +1 -1
- package/dist/fabric-exec-arguments.d.ts.map +1 -1
- package/dist/fabric-exec-tool.d.ts.map +1 -1
- package/dist/index.js +71 -32
- package/dist/index.js.map +3 -3
- package/dist/runtime/guest-code-repair.d.ts +2 -0
- package/dist/runtime/guest-code-repair.d.ts.map +1 -0
- package/dist/type-error-guidance.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/fabric-runtime-state-FBAJTXB2.js.map +0 -7
|
@@ -2114,6 +2114,297 @@ var MainAgentController = class {
|
|
|
2114
2114
|
}
|
|
2115
2115
|
};
|
|
2116
2116
|
|
|
2117
|
+
// src/runtime/guest-code-repair.ts
|
|
2118
|
+
var PATH_POSITIONAL_TOOLS = /* @__PURE__ */ new Set(["read", "ls", "write", "edit"]);
|
|
2119
|
+
var PATH_OBJECT_TOOLS = /* @__PURE__ */ new Set(["read", "ls", "write", "edit", "grep", "find"]);
|
|
2120
|
+
var PATH_KEYS = /* @__PURE__ */ new Set([
|
|
2121
|
+
"path",
|
|
2122
|
+
"file",
|
|
2123
|
+
"filepath",
|
|
2124
|
+
"file_path",
|
|
2125
|
+
"filePath",
|
|
2126
|
+
"pathname",
|
|
2127
|
+
"target_file",
|
|
2128
|
+
"targetFile",
|
|
2129
|
+
"absolutePath",
|
|
2130
|
+
"absolute_path",
|
|
2131
|
+
"dir",
|
|
2132
|
+
"directory",
|
|
2133
|
+
"folder",
|
|
2134
|
+
"directoryPath",
|
|
2135
|
+
"fileAbsolutePath"
|
|
2136
|
+
]);
|
|
2137
|
+
var UNICODE_QUOTE_PAIRS = [
|
|
2138
|
+
["\u201C", "\u201D"],
|
|
2139
|
+
["\u2018", "\u2019"],
|
|
2140
|
+
["\xAB", "\xBB"]
|
|
2141
|
+
];
|
|
2142
|
+
var isIdentChar = (char) => char !== void 0 && /[A-Za-z0-9_$]/.test(char);
|
|
2143
|
+
var skipWs = (code, index, end) => {
|
|
2144
|
+
let i = index;
|
|
2145
|
+
while (i < end && /[ \t\r\n]/.test(code[i] ?? "")) i++;
|
|
2146
|
+
return i;
|
|
2147
|
+
};
|
|
2148
|
+
var skipQuoted = (code, index, quote) => {
|
|
2149
|
+
let i = index + 1;
|
|
2150
|
+
while (i < code.length) {
|
|
2151
|
+
const char = code[i];
|
|
2152
|
+
if (char === "\\") {
|
|
2153
|
+
i += 2;
|
|
2154
|
+
continue;
|
|
2155
|
+
}
|
|
2156
|
+
if (char === quote) return i + 1;
|
|
2157
|
+
i++;
|
|
2158
|
+
}
|
|
2159
|
+
return code.length;
|
|
2160
|
+
};
|
|
2161
|
+
var readIdent = (code, index, end) => {
|
|
2162
|
+
const start = code[index];
|
|
2163
|
+
if (start === void 0 || !/[A-Za-z_$]/.test(start)) return void 0;
|
|
2164
|
+
let i = index + 1;
|
|
2165
|
+
while (i < end && isIdentChar(code[i])) i++;
|
|
2166
|
+
return { name: code.slice(index, i), end: i };
|
|
2167
|
+
};
|
|
2168
|
+
var isUnquotedPathStart = (code, index) => {
|
|
2169
|
+
const rest = code.slice(index);
|
|
2170
|
+
if (rest.startsWith("https://") || rest.startsWith("http://")) return true;
|
|
2171
|
+
if (rest.startsWith("./") || rest.startsWith("../") || rest.startsWith("~/")) return true;
|
|
2172
|
+
if (/^[A-Za-z]:[\\/]/.test(rest)) return true;
|
|
2173
|
+
if (rest.startsWith("/") && !rest.startsWith("//") && !rest.startsWith("/*")) return true;
|
|
2174
|
+
return false;
|
|
2175
|
+
};
|
|
2176
|
+
var consumeUnquotedPath = (code, index, end) => {
|
|
2177
|
+
let i = index;
|
|
2178
|
+
while (i < end) {
|
|
2179
|
+
const char = code[i];
|
|
2180
|
+
if (char === void 0) break;
|
|
2181
|
+
if (char === "," || char === ")" || char === "}" || char === "]" || char === ";") break;
|
|
2182
|
+
if (char === "'" || char === '"' || char === "`") break;
|
|
2183
|
+
if (char === " " || char === " " || char === "\n" || char === "\r") break;
|
|
2184
|
+
if (char === "&" && code[i + 1] === "&") break;
|
|
2185
|
+
if (char === "|" && code[i + 1] === "|") break;
|
|
2186
|
+
i++;
|
|
2187
|
+
}
|
|
2188
|
+
return i;
|
|
2189
|
+
};
|
|
2190
|
+
var quoteSlice = (code, start, end) => {
|
|
2191
|
+
if (end <= start) return void 0;
|
|
2192
|
+
return { start, end, text: JSON.stringify(code.slice(start, end)) };
|
|
2193
|
+
};
|
|
2194
|
+
var unicodeQuoteRepair = (code, index, end) => {
|
|
2195
|
+
for (const [open, close] of UNICODE_QUOTE_PAIRS) {
|
|
2196
|
+
if (!code.startsWith(open, index)) continue;
|
|
2197
|
+
const innerStart = index + open.length;
|
|
2198
|
+
const innerEnd = code.indexOf(close, innerStart);
|
|
2199
|
+
if (innerEnd === -1 || innerEnd >= end) return void 0;
|
|
2200
|
+
return {
|
|
2201
|
+
start: index,
|
|
2202
|
+
end: innerEnd + close.length,
|
|
2203
|
+
text: JSON.stringify(code.slice(innerStart, innerEnd))
|
|
2204
|
+
};
|
|
2205
|
+
}
|
|
2206
|
+
return void 0;
|
|
2207
|
+
};
|
|
2208
|
+
var repairPathValue = (code, index, end) => {
|
|
2209
|
+
const unicode = unicodeQuoteRepair(code, index, end);
|
|
2210
|
+
if (unicode) return unicode;
|
|
2211
|
+
if (!isUnquotedPathStart(code, index)) return void 0;
|
|
2212
|
+
return quoteSlice(code, index, consumeUnquotedPath(code, index, end));
|
|
2213
|
+
};
|
|
2214
|
+
var repairObjectPathKeys = (code, openIndex, end) => {
|
|
2215
|
+
const repairs = [];
|
|
2216
|
+
let depth = 1;
|
|
2217
|
+
let i = openIndex;
|
|
2218
|
+
while (i < end && depth > 0) {
|
|
2219
|
+
const char = code[i];
|
|
2220
|
+
if (char === "/" && code[i + 1] === "/") {
|
|
2221
|
+
while (i < end && code[i] !== "\n") i++;
|
|
2222
|
+
continue;
|
|
2223
|
+
}
|
|
2224
|
+
if (char === "/" && code[i + 1] === "*") {
|
|
2225
|
+
const close = code.indexOf("*/", i + 2);
|
|
2226
|
+
i = close === -1 || close >= end ? end : close + 2;
|
|
2227
|
+
continue;
|
|
2228
|
+
}
|
|
2229
|
+
if (char === "'" || char === '"') {
|
|
2230
|
+
const quotedEnd = skipQuoted(code, i, char);
|
|
2231
|
+
if (depth === 1) {
|
|
2232
|
+
const name = code.slice(i + 1, quotedEnd - 1);
|
|
2233
|
+
if (PATH_KEYS.has(name)) {
|
|
2234
|
+
let j = skipWs(code, quotedEnd, end);
|
|
2235
|
+
if (code[j] === ":") {
|
|
2236
|
+
j = skipWs(code, j + 1, end);
|
|
2237
|
+
const repair = repairPathValue(code, j, end);
|
|
2238
|
+
if (repair) {
|
|
2239
|
+
repairs.push(repair);
|
|
2240
|
+
i = repair.end;
|
|
2241
|
+
continue;
|
|
2242
|
+
}
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
i = quotedEnd;
|
|
2247
|
+
continue;
|
|
2248
|
+
}
|
|
2249
|
+
if (char === "`") {
|
|
2250
|
+
i = skipTemplateLiteral(code, i, end);
|
|
2251
|
+
continue;
|
|
2252
|
+
}
|
|
2253
|
+
if (char === "{") {
|
|
2254
|
+
depth++;
|
|
2255
|
+
i++;
|
|
2256
|
+
continue;
|
|
2257
|
+
}
|
|
2258
|
+
if (char === "}") {
|
|
2259
|
+
depth--;
|
|
2260
|
+
i++;
|
|
2261
|
+
continue;
|
|
2262
|
+
}
|
|
2263
|
+
if (depth === 1) {
|
|
2264
|
+
const ident = readIdent(code, i, end);
|
|
2265
|
+
if (ident && PATH_KEYS.has(ident.name)) {
|
|
2266
|
+
let j = skipWs(code, ident.end, end);
|
|
2267
|
+
if (code[j] === ":") {
|
|
2268
|
+
j = skipWs(code, j + 1, end);
|
|
2269
|
+
const repair = repairPathValue(code, j, end);
|
|
2270
|
+
if (repair) {
|
|
2271
|
+
repairs.push(repair);
|
|
2272
|
+
i = repair.end;
|
|
2273
|
+
continue;
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2276
|
+
i = ident.end;
|
|
2277
|
+
continue;
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
i++;
|
|
2281
|
+
}
|
|
2282
|
+
return repairs;
|
|
2283
|
+
};
|
|
2284
|
+
var skipTemplateLiteral = (code, index, end) => {
|
|
2285
|
+
let i = index + 1;
|
|
2286
|
+
while (i < end) {
|
|
2287
|
+
const char = code[i];
|
|
2288
|
+
if (char === "\\") {
|
|
2289
|
+
i += 2;
|
|
2290
|
+
continue;
|
|
2291
|
+
}
|
|
2292
|
+
if (char === "`") return i + 1;
|
|
2293
|
+
if (char === "$" && code[i + 1] === "{") {
|
|
2294
|
+
i = skipBalanced(code, i + 2, end, "{", "}");
|
|
2295
|
+
continue;
|
|
2296
|
+
}
|
|
2297
|
+
i++;
|
|
2298
|
+
}
|
|
2299
|
+
return end;
|
|
2300
|
+
};
|
|
2301
|
+
var skipBalanced = (code, index, end, open, close) => {
|
|
2302
|
+
let depth = 1;
|
|
2303
|
+
let i = index;
|
|
2304
|
+
while (i < end && depth > 0) {
|
|
2305
|
+
const char = code[i];
|
|
2306
|
+
if (char === "/" && code[i + 1] === "/") {
|
|
2307
|
+
while (i < end && code[i] !== "\n") i++;
|
|
2308
|
+
continue;
|
|
2309
|
+
}
|
|
2310
|
+
if (char === "/" && code[i + 1] === "*") {
|
|
2311
|
+
const stop = code.indexOf("*/", i + 2);
|
|
2312
|
+
i = stop === -1 || stop >= end ? end : stop + 2;
|
|
2313
|
+
continue;
|
|
2314
|
+
}
|
|
2315
|
+
if (char === "'" || char === '"') {
|
|
2316
|
+
i = skipQuoted(code, i, char);
|
|
2317
|
+
continue;
|
|
2318
|
+
}
|
|
2319
|
+
if (char === "`") {
|
|
2320
|
+
i = skipTemplateLiteral(code, i, end);
|
|
2321
|
+
continue;
|
|
2322
|
+
}
|
|
2323
|
+
if (char === open) depth++;
|
|
2324
|
+
else if (char === close) depth--;
|
|
2325
|
+
i++;
|
|
2326
|
+
}
|
|
2327
|
+
return i;
|
|
2328
|
+
};
|
|
2329
|
+
var repairCallArgs = (code, argStart, end, tool) => {
|
|
2330
|
+
const i = skipWs(code, argStart, end);
|
|
2331
|
+
if (i >= end) return [];
|
|
2332
|
+
if (code[i] === "{") {
|
|
2333
|
+
return PATH_OBJECT_TOOLS.has(tool) ? repairObjectPathKeys(code, i + 1, end) : [];
|
|
2334
|
+
}
|
|
2335
|
+
if (!PATH_POSITIONAL_TOOLS.has(tool)) return [];
|
|
2336
|
+
const repair = repairPathValue(code, i, end);
|
|
2337
|
+
return repair ? [repair] : [];
|
|
2338
|
+
};
|
|
2339
|
+
var collectRepairs = (code, start, end) => {
|
|
2340
|
+
const repairs = [];
|
|
2341
|
+
let i = start;
|
|
2342
|
+
while (i < end) {
|
|
2343
|
+
const char = code[i];
|
|
2344
|
+
if (char === "/" && code[i + 1] === "/") {
|
|
2345
|
+
while (i < end && code[i] !== "\n") i++;
|
|
2346
|
+
continue;
|
|
2347
|
+
}
|
|
2348
|
+
if (char === "/" && code[i + 1] === "*") {
|
|
2349
|
+
const close = code.indexOf("*/", i + 2);
|
|
2350
|
+
i = close === -1 || close >= end ? end : close + 2;
|
|
2351
|
+
continue;
|
|
2352
|
+
}
|
|
2353
|
+
if (char === "'" || char === '"') {
|
|
2354
|
+
i = Math.min(end, skipQuoted(code, i, char));
|
|
2355
|
+
continue;
|
|
2356
|
+
}
|
|
2357
|
+
if (char === "`") {
|
|
2358
|
+
i = collectTemplateRepairs(code, i, end, repairs);
|
|
2359
|
+
continue;
|
|
2360
|
+
}
|
|
2361
|
+
if (char === "p" && code.startsWith("pi.", i) && !isIdentChar(code[i - 1])) {
|
|
2362
|
+
const tool = readIdent(code, i + 3, end);
|
|
2363
|
+
if (tool && PATH_OBJECT_TOOLS.has(tool.name)) {
|
|
2364
|
+
const paren = skipWs(code, tool.end, end);
|
|
2365
|
+
if (code[paren] === "(") {
|
|
2366
|
+
repairs.push(...repairCallArgs(code, paren + 1, end, tool.name));
|
|
2367
|
+
i = paren + 1;
|
|
2368
|
+
continue;
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
i++;
|
|
2373
|
+
}
|
|
2374
|
+
return repairs;
|
|
2375
|
+
};
|
|
2376
|
+
var collectTemplateRepairs = (code, index, end, repairs) => {
|
|
2377
|
+
let i = index + 1;
|
|
2378
|
+
while (i < end) {
|
|
2379
|
+
const char = code[i];
|
|
2380
|
+
if (char === "\\") {
|
|
2381
|
+
i += 2;
|
|
2382
|
+
continue;
|
|
2383
|
+
}
|
|
2384
|
+
if (char === "`") return i + 1;
|
|
2385
|
+
if (char === "$" && code[i + 1] === "{") {
|
|
2386
|
+
const exprStart = i + 2;
|
|
2387
|
+
const exprEnd = skipBalanced(code, exprStart, end, "{", "}");
|
|
2388
|
+
repairs.push(...collectRepairs(code, exprStart, exprEnd - 1));
|
|
2389
|
+
i = exprEnd;
|
|
2390
|
+
continue;
|
|
2391
|
+
}
|
|
2392
|
+
i++;
|
|
2393
|
+
}
|
|
2394
|
+
return end;
|
|
2395
|
+
};
|
|
2396
|
+
var repairFabricGuestCode = (code) => {
|
|
2397
|
+
const repairs = collectRepairs(code, 0, code.length);
|
|
2398
|
+
if (repairs.length === 0) return code;
|
|
2399
|
+
let result = code;
|
|
2400
|
+
for (let index = repairs.length - 1; index >= 0; index--) {
|
|
2401
|
+
const repair = repairs[index];
|
|
2402
|
+
if (!repair) continue;
|
|
2403
|
+
result = result.slice(0, repair.start) + repair.text + result.slice(repair.end);
|
|
2404
|
+
}
|
|
2405
|
+
return result;
|
|
2406
|
+
};
|
|
2407
|
+
|
|
2117
2408
|
export {
|
|
2118
2409
|
CapturedToolCatalog,
|
|
2119
2410
|
PREWALK_ARMED_MESSAGE_TYPE,
|
|
@@ -2131,6 +2422,7 @@ export {
|
|
|
2131
2422
|
FabricAutoApprovalClassifier,
|
|
2132
2423
|
FabricSessionApprovals,
|
|
2133
2424
|
ApprovalController,
|
|
2425
|
+
repairFabricGuestCode,
|
|
2134
2426
|
FabricActivityStore,
|
|
2135
2427
|
FABRIC_PROVIDER_COMPONENT_PREFIX,
|
|
2136
2428
|
FABRIC_COMPONENT_PROVIDER_NAMES,
|
|
@@ -2141,4 +2433,4 @@ export {
|
|
|
2141
2433
|
resolveFabricIdentity,
|
|
2142
2434
|
MainAgentController
|
|
2143
2435
|
};
|
|
2144
|
-
//# sourceMappingURL=chunk-
|
|
2436
|
+
//# sourceMappingURL=chunk-PAAXKXWT.js.map
|