agenttwin 0.3.2 → 0.3.3
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/api.js +16 -16
- package/dist/cli.js +16 -16
- package/dist/gateway.js +16 -16
- package/package.json +2 -1
package/dist/api.js
CHANGED
|
@@ -245,24 +245,24 @@ var init_files = __esm({
|
|
|
245
245
|
});
|
|
246
246
|
|
|
247
247
|
// src/inventory/entrypoints.ts
|
|
248
|
-
|
|
249
|
-
return source.replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`/g, (part) => part.replace(/[^\n]/g, " "));
|
|
250
|
-
}
|
|
248
|
+
import { parse } from "@babel/parser";
|
|
251
249
|
function exportedEntrypoints(source) {
|
|
252
|
-
const code = codeOnly(source);
|
|
253
|
-
const pattern = /\bexport\s+(?:default\s+)?(?:async\s+)?function\s+(\w+)\s*\([^)]*\)[^{;]*\{|\bexport\s+(?:const|let)\s+(\w+)\s*=\s*(?:async\s*)?\([^)]*\)\s*(?::[^=;]+)?=>\s*\{/g;
|
|
254
250
|
const result = [];
|
|
255
|
-
let
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
251
|
+
let file;
|
|
252
|
+
try {
|
|
253
|
+
file = parse(source, { sourceType: "unambiguous", plugins: ["typescript", "jsx"], errorRecovery: true });
|
|
254
|
+
} catch {
|
|
255
|
+
return result;
|
|
256
|
+
}
|
|
257
|
+
for (const node of file.program.body) {
|
|
258
|
+
if (node.type !== "ExportNamedDeclaration" && node.type !== "ExportDefaultDeclaration") continue;
|
|
259
|
+
const declaration = node.declaration;
|
|
260
|
+
if (!declaration) continue;
|
|
261
|
+
if (declaration.type === "FunctionDeclaration" && declaration.id && declaration.body.loc) result.push({ name: declaration.id.name, startLine: node.loc.start.line, endLine: declaration.body.loc.end.line });
|
|
262
|
+
if (declaration.type === "VariableDeclaration") for (const variable of declaration.declarations) {
|
|
263
|
+
const fn = variable.init;
|
|
264
|
+
if (variable.id.type === "Identifier" && fn && (fn.type === "ArrowFunctionExpression" || fn.type === "FunctionExpression") && fn.body.type === "BlockStatement" && fn.body.loc) result.push({ name: variable.id.name, startLine: node.loc.start.line, endLine: fn.body.loc.end.line });
|
|
262
265
|
}
|
|
263
|
-
if (depth) continue;
|
|
264
|
-
result.push({ name: match[1] || match[2], startLine: code.slice(0, match.index).split("\n").length, endLine: code.slice(0, end).split("\n").length });
|
|
265
|
-
pattern.lastIndex = end;
|
|
266
266
|
}
|
|
267
267
|
return result;
|
|
268
268
|
}
|
|
@@ -821,7 +821,7 @@ async function projectProducts(cwd, data, base) {
|
|
|
821
821
|
const { w, path, fn } = value;
|
|
822
822
|
const source = path ? await files.read(path, 2e5) : void 0;
|
|
823
823
|
const entry = source && fn ? exportedEntrypoints(source).find((e) => e.name === fn) : void 0;
|
|
824
|
-
const body2 = source && entry ? source.split("\n").slice(entry.startLine - 1, entry.endLine).join("\n") : source ?? "";
|
|
824
|
+
const body2 = source && entry ? source.split("\n").slice(entry.startLine - 1, entry.endLine).join("\n") : fn ? "" : source ?? "";
|
|
825
825
|
const matches = products.filter((p) => found.has(p.key) && p.pattern.test(body2)).map((p) => google.id + ":" + p.key);
|
|
826
826
|
if (!matches.length) {
|
|
827
827
|
unresolved = true;
|
package/dist/cli.js
CHANGED
|
@@ -202,24 +202,24 @@ var init_files = __esm({
|
|
|
202
202
|
});
|
|
203
203
|
|
|
204
204
|
// src/inventory/entrypoints.ts
|
|
205
|
-
|
|
206
|
-
return source.replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`/g, (part) => part.replace(/[^\n]/g, " "));
|
|
207
|
-
}
|
|
205
|
+
import { parse } from "@babel/parser";
|
|
208
206
|
function exportedEntrypoints(source) {
|
|
209
|
-
const code = codeOnly(source);
|
|
210
|
-
const pattern = /\bexport\s+(?:default\s+)?(?:async\s+)?function\s+(\w+)\s*\([^)]*\)[^{;]*\{|\bexport\s+(?:const|let)\s+(\w+)\s*=\s*(?:async\s*)?\([^)]*\)\s*(?::[^=;]+)?=>\s*\{/g;
|
|
211
207
|
const result = [];
|
|
212
|
-
let
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
208
|
+
let file;
|
|
209
|
+
try {
|
|
210
|
+
file = parse(source, { sourceType: "unambiguous", plugins: ["typescript", "jsx"], errorRecovery: true });
|
|
211
|
+
} catch {
|
|
212
|
+
return result;
|
|
213
|
+
}
|
|
214
|
+
for (const node of file.program.body) {
|
|
215
|
+
if (node.type !== "ExportNamedDeclaration" && node.type !== "ExportDefaultDeclaration") continue;
|
|
216
|
+
const declaration = node.declaration;
|
|
217
|
+
if (!declaration) continue;
|
|
218
|
+
if (declaration.type === "FunctionDeclaration" && declaration.id && declaration.body.loc) result.push({ name: declaration.id.name, startLine: node.loc.start.line, endLine: declaration.body.loc.end.line });
|
|
219
|
+
if (declaration.type === "VariableDeclaration") for (const variable of declaration.declarations) {
|
|
220
|
+
const fn = variable.init;
|
|
221
|
+
if (variable.id.type === "Identifier" && fn && (fn.type === "ArrowFunctionExpression" || fn.type === "FunctionExpression") && fn.body.type === "BlockStatement" && fn.body.loc) result.push({ name: variable.id.name, startLine: node.loc.start.line, endLine: fn.body.loc.end.line });
|
|
219
222
|
}
|
|
220
|
-
if (depth) continue;
|
|
221
|
-
result.push({ name: match[1] || match[2], startLine: code.slice(0, match.index).split("\n").length, endLine: code.slice(0, end).split("\n").length });
|
|
222
|
-
pattern.lastIndex = end;
|
|
223
223
|
}
|
|
224
224
|
return result;
|
|
225
225
|
}
|
|
@@ -828,7 +828,7 @@ async function projectProducts(cwd, data, base) {
|
|
|
828
828
|
const { w, path, fn } = value;
|
|
829
829
|
const source = path ? await files.read(path, 2e5) : void 0;
|
|
830
830
|
const entry = source && fn ? exportedEntrypoints(source).find((e) => e.name === fn) : void 0;
|
|
831
|
-
const body = source && entry ? source.split("\n").slice(entry.startLine - 1, entry.endLine).join("\n") : source ?? "";
|
|
831
|
+
const body = source && entry ? source.split("\n").slice(entry.startLine - 1, entry.endLine).join("\n") : fn ? "" : source ?? "";
|
|
832
832
|
const matches = products.filter((p) => found.has(p.key) && p.pattern.test(body)).map((p) => google.id + ":" + p.key);
|
|
833
833
|
if (!matches.length) {
|
|
834
834
|
unresolved = true;
|
package/dist/gateway.js
CHANGED
|
@@ -245,24 +245,24 @@ var init_files = __esm({
|
|
|
245
245
|
});
|
|
246
246
|
|
|
247
247
|
// src/inventory/entrypoints.ts
|
|
248
|
-
|
|
249
|
-
return source.replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`/g, (part) => part.replace(/[^\n]/g, " "));
|
|
250
|
-
}
|
|
248
|
+
import { parse } from "@babel/parser";
|
|
251
249
|
function exportedEntrypoints(source) {
|
|
252
|
-
const code = codeOnly(source);
|
|
253
|
-
const pattern = /\bexport\s+(?:default\s+)?(?:async\s+)?function\s+(\w+)\s*\([^)]*\)[^{;]*\{|\bexport\s+(?:const|let)\s+(\w+)\s*=\s*(?:async\s*)?\([^)]*\)\s*(?::[^=;]+)?=>\s*\{/g;
|
|
254
250
|
const result = [];
|
|
255
|
-
let
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
251
|
+
let file;
|
|
252
|
+
try {
|
|
253
|
+
file = parse(source, { sourceType: "unambiguous", plugins: ["typescript", "jsx"], errorRecovery: true });
|
|
254
|
+
} catch {
|
|
255
|
+
return result;
|
|
256
|
+
}
|
|
257
|
+
for (const node of file.program.body) {
|
|
258
|
+
if (node.type !== "ExportNamedDeclaration" && node.type !== "ExportDefaultDeclaration") continue;
|
|
259
|
+
const declaration = node.declaration;
|
|
260
|
+
if (!declaration) continue;
|
|
261
|
+
if (declaration.type === "FunctionDeclaration" && declaration.id && declaration.body.loc) result.push({ name: declaration.id.name, startLine: node.loc.start.line, endLine: declaration.body.loc.end.line });
|
|
262
|
+
if (declaration.type === "VariableDeclaration") for (const variable of declaration.declarations) {
|
|
263
|
+
const fn = variable.init;
|
|
264
|
+
if (variable.id.type === "Identifier" && fn && (fn.type === "ArrowFunctionExpression" || fn.type === "FunctionExpression") && fn.body.type === "BlockStatement" && fn.body.loc) result.push({ name: variable.id.name, startLine: node.loc.start.line, endLine: fn.body.loc.end.line });
|
|
262
265
|
}
|
|
263
|
-
if (depth) continue;
|
|
264
|
-
result.push({ name: match[1] || match[2], startLine: code.slice(0, match.index).split("\n").length, endLine: code.slice(0, end).split("\n").length });
|
|
265
|
-
pattern.lastIndex = end;
|
|
266
266
|
}
|
|
267
267
|
return result;
|
|
268
268
|
}
|
|
@@ -821,7 +821,7 @@ async function projectProducts(cwd, data, base) {
|
|
|
821
821
|
const { w, path, fn } = value;
|
|
822
822
|
const source = path ? await files.read(path, 2e5) : void 0;
|
|
823
823
|
const entry = source && fn ? exportedEntrypoints(source).find((e) => e.name === fn) : void 0;
|
|
824
|
-
const body2 = source && entry ? source.split("\n").slice(entry.startLine - 1, entry.endLine).join("\n") : source ?? "";
|
|
824
|
+
const body2 = source && entry ? source.split("\n").slice(entry.startLine - 1, entry.endLine).join("\n") : fn ? "" : source ?? "";
|
|
825
825
|
const matches = products.filter((p) => found.has(p.key) && p.pattern.test(body2)).map((p) => google.id + ":" + p.key);
|
|
826
826
|
if (!matches.length) {
|
|
827
827
|
unresolved = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agenttwin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Give your agent a test world before it touches the real one.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
+
"@babel/parser": "^8.0.7",
|
|
39
40
|
"e2b": "^2.52.1",
|
|
40
41
|
"yaml": "^2.9.1"
|
|
41
42
|
},
|