@ancha-labs/cli 0.4.40 → 0.4.41
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/lib/ancha.mjs +1170 -584
- package/lib/assets/SKILL.md +4 -1
- package/lib/assets/agents-section.md +4 -1
- package/lib/assets/data/pellmont/pellmont-approved-merge.yaml +75 -0
- package/lib/assets/data/pellmont/pellmont-building-services.yaml +1704 -0
- package/lib/assets/data/pellmont/pellmont-duplicates.yaml +21 -0
- package/lib/assets/docs/cloud.md +26 -9
- package/lib/assets/docs/run.md +1 -1
- package/lib/assets/docs/setup.md +4 -1
- package/lib/assets/harbor/companion.mjs +209 -18
- package/lib/assets/ui/app.js +8 -6
- package/lib/mcp-entry.mjs +1 -1
- package/lib/worker.mjs +354 -84
- package/lib/world-server.mjs +1 -1
- package/package.json +1 -1
package/lib/ancha.mjs
CHANGED
|
@@ -322,11 +322,11 @@ var require_help = __commonJS({
|
|
|
322
322
|
*/
|
|
323
323
|
visibleArguments(cmd) {
|
|
324
324
|
if (cmd._argsDescription) {
|
|
325
|
-
cmd.registeredArguments.forEach((
|
|
326
|
-
|
|
325
|
+
cmd.registeredArguments.forEach((argument2) => {
|
|
326
|
+
argument2.description = argument2.description || cmd._argsDescription[argument2.name()] || "";
|
|
327
327
|
});
|
|
328
328
|
}
|
|
329
|
-
if (cmd.registeredArguments.find((
|
|
329
|
+
if (cmd.registeredArguments.find((argument2) => argument2.description)) {
|
|
330
330
|
return cmd.registeredArguments;
|
|
331
331
|
}
|
|
332
332
|
return [];
|
|
@@ -357,8 +357,8 @@ var require_help = __commonJS({
|
|
|
357
357
|
* @param {Argument} argument
|
|
358
358
|
* @returns {string}
|
|
359
359
|
*/
|
|
360
|
-
argumentTerm(
|
|
361
|
-
return
|
|
360
|
+
argumentTerm(argument2) {
|
|
361
|
+
return argument2.name();
|
|
362
362
|
}
|
|
363
363
|
/**
|
|
364
364
|
* Get the longest command term length.
|
|
@@ -415,11 +415,11 @@ var require_help = __commonJS({
|
|
|
415
415
|
* @returns {number}
|
|
416
416
|
*/
|
|
417
417
|
longestArgumentTermLength(cmd, helper) {
|
|
418
|
-
return helper.visibleArguments(cmd).reduce((max,
|
|
418
|
+
return helper.visibleArguments(cmd).reduce((max, argument2) => {
|
|
419
419
|
return Math.max(
|
|
420
420
|
max,
|
|
421
421
|
this.displayWidth(
|
|
422
|
-
helper.styleArgumentTerm(helper.argumentTerm(
|
|
422
|
+
helper.styleArgumentTerm(helper.argumentTerm(argument2))
|
|
423
423
|
)
|
|
424
424
|
);
|
|
425
425
|
}, 0);
|
|
@@ -503,27 +503,27 @@ var require_help = __commonJS({
|
|
|
503
503
|
* @param {Argument} argument
|
|
504
504
|
* @return {string}
|
|
505
505
|
*/
|
|
506
|
-
argumentDescription(
|
|
506
|
+
argumentDescription(argument2) {
|
|
507
507
|
const extraInfo = [];
|
|
508
|
-
if (
|
|
508
|
+
if (argument2.argChoices) {
|
|
509
509
|
extraInfo.push(
|
|
510
510
|
// use stringify to match the display of the default value
|
|
511
|
-
`choices: ${
|
|
511
|
+
`choices: ${argument2.argChoices.map((choice5) => JSON.stringify(choice5)).join(", ")}`
|
|
512
512
|
);
|
|
513
513
|
}
|
|
514
|
-
if (
|
|
514
|
+
if (argument2.defaultValue !== void 0) {
|
|
515
515
|
extraInfo.push(
|
|
516
|
-
`default: ${
|
|
516
|
+
`default: ${argument2.defaultValueDescription || JSON.stringify(argument2.defaultValue)}`
|
|
517
517
|
);
|
|
518
518
|
}
|
|
519
519
|
if (extraInfo.length > 0) {
|
|
520
520
|
const extraDescription = `(${extraInfo.join(", ")})`;
|
|
521
|
-
if (
|
|
522
|
-
return `${
|
|
521
|
+
if (argument2.description) {
|
|
522
|
+
return `${argument2.description} ${extraDescription}`;
|
|
523
523
|
}
|
|
524
524
|
return extraDescription;
|
|
525
525
|
}
|
|
526
|
-
return
|
|
526
|
+
return argument2.description;
|
|
527
527
|
}
|
|
528
528
|
/**
|
|
529
529
|
* Format a list of items, given a heading and an array of formatted items.
|
|
@@ -587,10 +587,10 @@ var require_help = __commonJS({
|
|
|
587
587
|
""
|
|
588
588
|
]);
|
|
589
589
|
}
|
|
590
|
-
const argumentList = helper.visibleArguments(cmd).map((
|
|
590
|
+
const argumentList = helper.visibleArguments(cmd).map((argument2) => {
|
|
591
591
|
return callFormatItem(
|
|
592
|
-
helper.styleArgumentTerm(helper.argumentTerm(
|
|
593
|
-
helper.styleArgumentDescription(helper.argumentDescription(
|
|
592
|
+
helper.styleArgumentTerm(helper.argumentTerm(argument2)),
|
|
593
|
+
helper.styleArgumentDescription(helper.argumentDescription(argument2))
|
|
594
594
|
);
|
|
595
595
|
});
|
|
596
596
|
output2 = output2.concat(
|
|
@@ -1494,13 +1494,13 @@ var require_command = __commonJS({
|
|
|
1494
1494
|
* @return {Command} `this` command for chaining
|
|
1495
1495
|
*/
|
|
1496
1496
|
argument(name5, description2, parseArg, defaultValue) {
|
|
1497
|
-
const
|
|
1497
|
+
const argument2 = this.createArgument(name5, description2);
|
|
1498
1498
|
if (typeof parseArg === "function") {
|
|
1499
|
-
|
|
1499
|
+
argument2.default(defaultValue).argParser(parseArg);
|
|
1500
1500
|
} else {
|
|
1501
|
-
|
|
1501
|
+
argument2.default(parseArg);
|
|
1502
1502
|
}
|
|
1503
|
-
this.addArgument(
|
|
1503
|
+
this.addArgument(argument2);
|
|
1504
1504
|
return this;
|
|
1505
1505
|
}
|
|
1506
1506
|
/**
|
|
@@ -1526,19 +1526,19 @@ var require_command = __commonJS({
|
|
|
1526
1526
|
* @param {Argument} argument
|
|
1527
1527
|
* @return {Command} `this` command for chaining
|
|
1528
1528
|
*/
|
|
1529
|
-
addArgument(
|
|
1529
|
+
addArgument(argument2) {
|
|
1530
1530
|
const previousArgument = this.registeredArguments.slice(-1)[0];
|
|
1531
1531
|
if (previousArgument?.variadic) {
|
|
1532
1532
|
throw new Error(
|
|
1533
1533
|
`only the last argument can be variadic '${previousArgument.name()}'`
|
|
1534
1534
|
);
|
|
1535
1535
|
}
|
|
1536
|
-
if (
|
|
1536
|
+
if (argument2.required && argument2.defaultValue !== void 0 && argument2.parseArg === void 0) {
|
|
1537
1537
|
throw new Error(
|
|
1538
|
-
`a default value for a required argument is never used: '${
|
|
1538
|
+
`a default value for a required argument is never used: '${argument2.name()}'`
|
|
1539
1539
|
);
|
|
1540
1540
|
}
|
|
1541
|
-
this.registeredArguments.push(
|
|
1541
|
+
this.registeredArguments.push(argument2);
|
|
1542
1542
|
return this;
|
|
1543
1543
|
}
|
|
1544
1544
|
/**
|
|
@@ -2399,12 +2399,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2399
2399
|
* @private
|
|
2400
2400
|
*/
|
|
2401
2401
|
_processArguments() {
|
|
2402
|
-
const myParseArg = (
|
|
2402
|
+
const myParseArg = (argument2, value6, previous) => {
|
|
2403
2403
|
let parsedValue = value6;
|
|
2404
|
-
if (value6 !== null &&
|
|
2405
|
-
const invalidValueMessage = `error: command-argument value '${value6}' is invalid for argument '${
|
|
2404
|
+
if (value6 !== null && argument2.parseArg) {
|
|
2405
|
+
const invalidValueMessage = `error: command-argument value '${value6}' is invalid for argument '${argument2.name()}'.`;
|
|
2406
2406
|
parsedValue = this._callParseArg(
|
|
2407
|
-
|
|
2407
|
+
argument2,
|
|
2408
2408
|
value6,
|
|
2409
2409
|
previous,
|
|
2410
2410
|
invalidValueMessage
|
|
@@ -3066,9 +3066,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3066
3066
|
* @param {string[]} [aliases]
|
|
3067
3067
|
* @return {(string[]|Command)}
|
|
3068
3068
|
*/
|
|
3069
|
-
aliases(
|
|
3070
|
-
if (
|
|
3071
|
-
|
|
3069
|
+
aliases(aliases2) {
|
|
3070
|
+
if (aliases2 === void 0) return this._aliases;
|
|
3071
|
+
aliases2.forEach((alias) => this.alias(alias));
|
|
3072
3072
|
return this;
|
|
3073
3073
|
}
|
|
3074
3074
|
/**
|
|
@@ -4774,18 +4774,18 @@ var init_parse = __esm({
|
|
|
4774
4774
|
return result.issues.length === 0;
|
|
4775
4775
|
};
|
|
4776
4776
|
_encode = (_Err) => {
|
|
4777
|
-
const
|
|
4777
|
+
const parse28 = _parse(_Err);
|
|
4778
4778
|
const fn = (schema4, value6, _ctx, _params) => {
|
|
4779
4779
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
4780
|
-
return
|
|
4780
|
+
return parse28(schema4, value6, ctx, finalizeParams(fn, _params));
|
|
4781
4781
|
};
|
|
4782
4782
|
return fn;
|
|
4783
4783
|
};
|
|
4784
4784
|
encode = /* @__PURE__ */ _encode($ZodRealError);
|
|
4785
4785
|
_decode = (_Err) => {
|
|
4786
|
-
const
|
|
4786
|
+
const parse28 = _parse(_Err);
|
|
4787
4787
|
const fn = (schema4, value6, _ctx, _params) => {
|
|
4788
|
-
return
|
|
4788
|
+
return parse28(schema4, value6, _ctx, finalizeParams(fn, _params));
|
|
4789
4789
|
};
|
|
4790
4790
|
return fn;
|
|
4791
4791
|
};
|
|
@@ -5710,7 +5710,7 @@ function capSize(inst, size2) {
|
|
|
5710
5710
|
if (!caps2.length)
|
|
5711
5711
|
return;
|
|
5712
5712
|
const cap = Math.min(...caps2.map((c) => c[0]));
|
|
5713
|
-
const
|
|
5713
|
+
const parse28 = inst._zod.parse;
|
|
5714
5714
|
inst._zod.parse = (payload3, ctx) => {
|
|
5715
5715
|
const n2 = size2(payload3.value);
|
|
5716
5716
|
if (n2 > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
|
|
@@ -5724,7 +5724,7 @@ function capSize(inst, size2) {
|
|
|
5724
5724
|
}
|
|
5725
5725
|
}
|
|
5726
5726
|
}
|
|
5727
|
-
return
|
|
5727
|
+
return parse28(payload3, ctx);
|
|
5728
5728
|
};
|
|
5729
5729
|
}
|
|
5730
5730
|
function handleArrayResult(result, final, index) {
|
|
@@ -23959,37 +23959,42 @@ var init_errors3 = __esm({
|
|
|
23959
23959
|
// packages/core/src/agent-routes.ts
|
|
23960
23960
|
function parseAgentRoutes(value6) {
|
|
23961
23961
|
const parsed5 = agentRoutesSchema.safeParse(value6);
|
|
23962
|
-
if (!parsed5.success) throw new AnchaError("CONFIG_INVALID", "agent.routes must be a mapping containing
|
|
23962
|
+
if (!parsed5.success) throw new AnchaError("CONFIG_INVALID", "agent.routes must be a mapping containing quickbooks: composio and/or netsuite: composio");
|
|
23963
23963
|
return parsed5.data;
|
|
23964
23964
|
}
|
|
23965
|
-
function validateAgentRoutes(agent,
|
|
23965
|
+
function validateAgentRoutes(agent, _twins) {
|
|
23966
23966
|
if (agent.routes === void 0) return;
|
|
23967
23967
|
const routes2 = parseAgentRoutes(agent.routes);
|
|
23968
|
-
|
|
23969
|
-
|
|
23970
|
-
|
|
23968
|
+
for (const toolkit of ["quickbooks", "netsuite"]) {
|
|
23969
|
+
if (!routes2[toolkit]) continue;
|
|
23970
|
+
if (!agent.passEnv?.includes("COMPOSIO_API_KEY")) throw new AnchaError("CONFIG_INVALID", `agent.routes.${toolkit} requires COMPOSIO_API_KEY in agent.pass_env`);
|
|
23971
|
+
}
|
|
23971
23972
|
}
|
|
23972
23973
|
function mergeRouteSummaries(values3) {
|
|
23973
|
-
const
|
|
23974
|
-
|
|
23975
|
-
|
|
23976
|
-
|
|
23977
|
-
|
|
23978
|
-
|
|
23979
|
-
|
|
23980
|
-
|
|
23981
|
-
|
|
23982
|
-
|
|
23983
|
-
|
|
23984
|
-
|
|
23985
|
-
|
|
23986
|
-
|
|
23987
|
-
|
|
23988
|
-
|
|
23989
|
-
}
|
|
23990
|
-
|
|
23974
|
+
const result = {};
|
|
23975
|
+
for (const toolkit of ["quickbooks", "netsuite"]) {
|
|
23976
|
+
const routes2 = values3.flatMap((value6) => value6?.[toolkit] ? [value6[toolkit]] : []);
|
|
23977
|
+
if (!routes2.length) continue;
|
|
23978
|
+
const via = { direct: 0, session: 0, mcp: 0 };
|
|
23979
|
+
for (const route15 of routes2) for (const path9 of ["direct", "session", "mcp"]) via[path9] += route15.via?.[path9] ?? 0;
|
|
23980
|
+
const narrowed = [...new Set(routes2.flatMap((route15) => route15.narrowed ?? []))].sort();
|
|
23981
|
+
result[toolkit] = {
|
|
23982
|
+
platform: "composio",
|
|
23983
|
+
executions: routes2.reduce((n2, r2) => n2 + r2.executions, 0),
|
|
23984
|
+
reached: routes2.reduce((n2, r2) => n2 + r2.reached, 0),
|
|
23985
|
+
refused: routes2.reduce((n2, r2) => n2 + r2.refused, 0),
|
|
23986
|
+
...routes2.some((r2) => r2.via !== void 0) && { via },
|
|
23987
|
+
...routes2.some((r2) => r2.sessions !== void 0) && { sessions: routes2.reduce((n2, r2) => n2 + (r2.sessions ?? 0), 0) },
|
|
23988
|
+
...narrowed.length && { narrowed },
|
|
23989
|
+
...routes2.some((r2) => r2.connection) && { connection: routes2.some((r2) => r2.connection === "failed") ? "failed" : "created" },
|
|
23990
|
+
...routes2.some((r2) => r2.cleanup) && { cleanup: routes2.some((r2) => r2.cleanup === "failed") ? "failed" : "done" }
|
|
23991
|
+
};
|
|
23992
|
+
}
|
|
23993
|
+
return Object.keys(result).length ? result : void 0;
|
|
23994
|
+
}
|
|
23995
|
+
function formatRouteSummary(route15, toolkit = "quickbooks") {
|
|
23991
23996
|
return [
|
|
23992
|
-
|
|
23997
|
+
`${toolkit === "quickbooks" ? "QuickBooks" : "NetSuite"} via Composio: ${route15.executions} executions, ${route15.reached} reached the world, ${route15.refused} refused`,
|
|
23993
23998
|
...route15.via ? [`via direct ${route15.via.direct} / session ${route15.via.session} / MCP ${route15.via.mcp}`] : [],
|
|
23994
23999
|
...route15.sessions !== void 0 ? [`${route15.sessions} sessions`] : [],
|
|
23995
24000
|
...route15.narrowed?.length ? [`narrowed: ${route15.narrowed.join(", ")}`] : [],
|
|
@@ -24003,7 +24008,7 @@ var init_agent_routes = __esm({
|
|
|
24003
24008
|
"use strict";
|
|
24004
24009
|
init_zod();
|
|
24005
24010
|
init_errors3();
|
|
24006
|
-
agentRoutesSchema = external_exports.strictObject({ quickbooks: external_exports.literal("composio").optional() });
|
|
24011
|
+
agentRoutesSchema = external_exports.strictObject({ quickbooks: external_exports.literal("composio").optional(), netsuite: external_exports.literal("composio").optional() });
|
|
24007
24012
|
}
|
|
24008
24013
|
});
|
|
24009
24014
|
|
|
@@ -24263,7 +24268,7 @@ function expectedNumber(number7) {
|
|
|
24263
24268
|
return { value: read7.value, tolerance: number7.tolerance ?? 0.5 * 10 ** -read7.decimals };
|
|
24264
24269
|
}
|
|
24265
24270
|
function answerTokens(text31) {
|
|
24266
|
-
const
|
|
24271
|
+
const tokens7 = [];
|
|
24267
24272
|
let cursor4 = 0;
|
|
24268
24273
|
const quotes = [];
|
|
24269
24274
|
const gap8 = (end) => {
|
|
@@ -24271,7 +24276,7 @@ function answerTokens(text31) {
|
|
|
24271
24276
|
const start2 = cursor4 + match3.index, word2 = match3[0];
|
|
24272
24277
|
const apostrophe = (word2 === "'" || word2 === "\u2019") && (WORD_CHAR.test(text31[start2 - 1] ?? "") && (WORD_CHAR.test(text31[start2 + 1] ?? "") || quotes.at(-1) !== word2) || text31[start2 - 1] === "." && /^s\b/i.test(text31.slice(start2 + 1)));
|
|
24273
24278
|
const quote6 = !apostrophe && ['"', "'", "\u201C", "\u201D", "\u2018", "\u2019"].includes(word2);
|
|
24274
|
-
|
|
24279
|
+
tokens7.push({ text: word2.toLowerCase(), start: start2, end: start2 + word2.length, quoted: quotes.length > 0 || quote6 });
|
|
24275
24280
|
if (quote6) {
|
|
24276
24281
|
if (quotes.at(-1) === word2) quotes.pop();
|
|
24277
24282
|
else if (word2 !== "\u201D" && word2 !== "\u2019") quotes.push(word2 === "\u201C" ? "\u201D" : word2 === "\u2018" ? "\u2019" : word2);
|
|
@@ -24280,28 +24285,28 @@ function answerTokens(text31) {
|
|
|
24280
24285
|
};
|
|
24281
24286
|
for (const number7 of readNumberSpans(text31)) {
|
|
24282
24287
|
gap8(number7.start);
|
|
24283
|
-
|
|
24288
|
+
tokens7.push({ text: number7.text, start: number7.start, end: number7.end, number: number7, quoted: quotes.length > 0 });
|
|
24284
24289
|
cursor4 = number7.end;
|
|
24285
24290
|
}
|
|
24286
24291
|
gap8(text31.length);
|
|
24287
|
-
return
|
|
24292
|
+
return tokens7;
|
|
24288
24293
|
}
|
|
24289
24294
|
function distinctLabels(labels2) {
|
|
24290
24295
|
return labels2.every((label7, i) => labels2.every((other, j) => i === j || !labelPattern(label7).test(other)));
|
|
24291
24296
|
}
|
|
24292
24297
|
function inferNumberLabels(text31, numbers3 = readNumberSpans(text31)) {
|
|
24293
|
-
const
|
|
24298
|
+
const tokens7 = answerTokens(text31.normalize("NFKC"));
|
|
24294
24299
|
const labels2 = numbers3.map((number7) => {
|
|
24295
|
-
let i =
|
|
24300
|
+
let i = tokens7.findIndex((token5) => token5.start === number7.start) - 1;
|
|
24296
24301
|
while (i >= 0) {
|
|
24297
|
-
const word2 =
|
|
24302
|
+
const word2 = tokens7[i].text, before = tokens7[i - 1]?.text;
|
|
24298
24303
|
if (word2 === "at" && before === "stands" || word2 === "to" && (before === "comes" || before === "came")) i -= 2;
|
|
24299
24304
|
else if (LINK_WORDS.has(word2) || CURRENCY_TOKEN.test(word2) || word2 === ":" || word2 === "=") i--;
|
|
24300
24305
|
else break;
|
|
24301
24306
|
}
|
|
24302
24307
|
const words9 = [];
|
|
24303
24308
|
while (i >= 0 && words9.length < 2) {
|
|
24304
|
-
const token5 =
|
|
24309
|
+
const token5 = tokens7[i--];
|
|
24305
24310
|
if (token5.number || !WORD.test(token5.text) || ARTICLES.has(token5.text) || LINK_WORDS.has(token5.text) || CLAUSE_WORDS.has(token5.text)) break;
|
|
24306
24311
|
words9.unshift(token5.text);
|
|
24307
24312
|
}
|
|
@@ -24319,12 +24324,12 @@ function fieldRows(text31) {
|
|
|
24319
24324
|
}
|
|
24320
24325
|
function readLabelEvidence(text31, labels2) {
|
|
24321
24326
|
text31 = fieldRows(text31.normalize("NFKC"));
|
|
24322
|
-
const
|
|
24327
|
+
const tokens7 = answerTokens(text31);
|
|
24323
24328
|
const occurrences2 = labels2.flatMap((label7) => [...text31.matchAll(labelPattern(normalizedLabel(label7)))].map((match3) => ({ label: label7, start: match3.index, end: match3.index + match3[0].length }))).sort((a, b) => a.start - b.start);
|
|
24324
24329
|
const evidence3 = [];
|
|
24325
24330
|
occurrences2.forEach((occurrence, index) => {
|
|
24326
24331
|
const next2 = occurrences2[index + 1]?.start ?? text31.length;
|
|
24327
|
-
const after =
|
|
24332
|
+
const after = tokens7.filter((token5) => token5.start >= occurrence.end && token5.start < next2);
|
|
24328
24333
|
const clause2 = [];
|
|
24329
24334
|
let previous = occurrence.end;
|
|
24330
24335
|
for (const token5 of after) {
|
|
@@ -24340,7 +24345,7 @@ function readLabelEvidence(text31, labels2) {
|
|
|
24340
24345
|
label: occurrence.label,
|
|
24341
24346
|
number: token5.number,
|
|
24342
24347
|
clauseNumbers: clause2.flatMap((t) => t.number ? [t.number] : []),
|
|
24343
|
-
quoted: token5.quoted ||
|
|
24348
|
+
quoted: token5.quoted || tokens7.some((t) => t.start >= occurrence.start && t.start < occurrence.end && t.quoted)
|
|
24344
24349
|
});
|
|
24345
24350
|
break;
|
|
24346
24351
|
}
|
|
@@ -24647,6 +24652,16 @@ var init_clock = __esm({
|
|
|
24647
24652
|
|
|
24648
24653
|
// packages/core/src/ids.ts
|
|
24649
24654
|
import { createHash } from "node:crypto";
|
|
24655
|
+
function memoryCounters() {
|
|
24656
|
+
const counts2 = /* @__PURE__ */ new Map();
|
|
24657
|
+
return {
|
|
24658
|
+
next(namespace) {
|
|
24659
|
+
const n2 = counts2.get(namespace) ?? 0;
|
|
24660
|
+
counts2.set(namespace, n2 + 1);
|
|
24661
|
+
return n2;
|
|
24662
|
+
}
|
|
24663
|
+
};
|
|
24664
|
+
}
|
|
24650
24665
|
function validateLength(len) {
|
|
24651
24666
|
if (!Number.isInteger(len) || len < 1 || len > 4096) throw new RangeError("ID length must be an integer from 1 to 4096");
|
|
24652
24667
|
}
|
|
@@ -26732,10 +26747,10 @@ function parseRate(text31) {
|
|
|
26732
26747
|
if (maxPerHour > MAX_NOISE_PER_HOUR) throw new AnchaError("SCENE_INVALID", `invalid rate "${text31}": at most ${MAX_NOISE_PER_HOUR} per hour`, { hint: RATE_HINT });
|
|
26733
26748
|
return { minPerHour, maxPerHour };
|
|
26734
26749
|
}
|
|
26735
|
-
function parsed(
|
|
26750
|
+
function parsed(parse28, description2) {
|
|
26736
26751
|
return external_exports.string().superRefine((value6, ctx) => {
|
|
26737
26752
|
try {
|
|
26738
|
-
|
|
26753
|
+
parse28(value6);
|
|
26739
26754
|
} catch (error65) {
|
|
26740
26755
|
if (!(error65 instanceof AnchaError)) throw error65;
|
|
26741
26756
|
ctx.addIssue({ code: "custom", message: error65.message, params: { hint: error65.hint } });
|
|
@@ -34650,10 +34665,10 @@ function tokenize(text31) {
|
|
|
34650
34665
|
return out;
|
|
34651
34666
|
}
|
|
34652
34667
|
function parseFormula(text31) {
|
|
34653
|
-
const
|
|
34668
|
+
const tokens7 = tokenize(text31);
|
|
34654
34669
|
let at6 = 0;
|
|
34655
34670
|
const isOp = (value6) => {
|
|
34656
|
-
const token5 =
|
|
34671
|
+
const token5 = tokens7[at6];
|
|
34657
34672
|
return token5.kind === "op" && token5.value === value6;
|
|
34658
34673
|
};
|
|
34659
34674
|
const expect = (value6) => {
|
|
@@ -34663,14 +34678,14 @@ function parseFormula(text31) {
|
|
|
34663
34678
|
const level3 = (ops, next2) => () => {
|
|
34664
34679
|
let left = next2();
|
|
34665
34680
|
for (; ; ) {
|
|
34666
|
-
const token5 =
|
|
34681
|
+
const token5 = tokens7[at6];
|
|
34667
34682
|
if (token5.kind !== "op" || !ops.includes(token5.value)) return left;
|
|
34668
34683
|
at6++;
|
|
34669
34684
|
left = { type: "binary", op: token5.value, left, right: next2() };
|
|
34670
34685
|
}
|
|
34671
34686
|
};
|
|
34672
34687
|
const primary3 = () => {
|
|
34673
|
-
const token5 =
|
|
34688
|
+
const token5 = tokens7[at6++];
|
|
34674
34689
|
if (token5.kind === "num") return { type: "number", value: token5.value };
|
|
34675
34690
|
if (token5.kind === "str") return { type: "text", value: token5.value };
|
|
34676
34691
|
if (token5.kind === "field") return { type: "field", name: token5.value };
|
|
@@ -34695,14 +34710,14 @@ function parseFormula(text31) {
|
|
|
34695
34710
|
};
|
|
34696
34711
|
const unary = () => {
|
|
34697
34712
|
if (isOp("-") || isOp("+")) {
|
|
34698
|
-
const op2 =
|
|
34713
|
+
const op2 = tokens7[at6++].value;
|
|
34699
34714
|
return { type: "unary", op: op2, arg: unary() };
|
|
34700
34715
|
}
|
|
34701
34716
|
return primary3();
|
|
34702
34717
|
};
|
|
34703
34718
|
const comparison3 = level3(["=", "!=", "<", ">", "<=", ">="], level3(["&"], level3(["+", "-"], level3(["*", "/"], unary))));
|
|
34704
34719
|
const node5 = comparison3();
|
|
34705
|
-
if (
|
|
34720
|
+
if (tokens7[at6].kind !== "end") throw new FormulaSyntaxError("unexpected text after the formula");
|
|
34706
34721
|
return node5;
|
|
34707
34722
|
}
|
|
34708
34723
|
function formulaFieldNames(node5) {
|
|
@@ -43140,7 +43155,7 @@ ${pointer2}
|
|
|
43140
43155
|
var require_resolve_props = __commonJS({
|
|
43141
43156
|
"node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/compose/resolve-props.js"(exports) {
|
|
43142
43157
|
"use strict";
|
|
43143
|
-
function resolveProps(
|
|
43158
|
+
function resolveProps(tokens7, { flow, indicator, next: next2, offset: offset20, onError, parentIndent, startOnNewline }) {
|
|
43144
43159
|
let spaceBefore = false;
|
|
43145
43160
|
let atNewline = startOnNewline;
|
|
43146
43161
|
let hasSpace = startOnNewline;
|
|
@@ -43155,7 +43170,7 @@ var require_resolve_props = __commonJS({
|
|
|
43155
43170
|
let comma = null;
|
|
43156
43171
|
let found = null;
|
|
43157
43172
|
let start2 = null;
|
|
43158
|
-
for (const token5 of
|
|
43173
|
+
for (const token5 of tokens7) {
|
|
43159
43174
|
if (reqSpace) {
|
|
43160
43175
|
if (token5.type !== "space" && token5.type !== "newline" && token5.type !== "comma")
|
|
43161
43176
|
onError(token5.offset, "MISSING_CHAR", "Tags and anchors must be separated from the next token by white space");
|
|
@@ -43246,7 +43261,7 @@ var require_resolve_props = __commonJS({
|
|
|
43246
43261
|
hasSpace = false;
|
|
43247
43262
|
}
|
|
43248
43263
|
}
|
|
43249
|
-
const last =
|
|
43264
|
+
const last = tokens7[tokens7.length - 1];
|
|
43250
43265
|
const end = last ? last.offset + last.source.length : offset20;
|
|
43251
43266
|
if (reqSpace && next2 && next2.type !== "space" && next2.type !== "newline" && next2.type !== "comma" && (next2.type !== "scalar" || next2.source !== "")) {
|
|
43252
43267
|
onError(next2.offset, "MISSING_CHAR", "Tags and anchors must be separated from the next token by white space");
|
|
@@ -44586,8 +44601,8 @@ ${cb}` : comment10;
|
|
|
44586
44601
|
* @param forceDoc - If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document.
|
|
44587
44602
|
* @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly.
|
|
44588
44603
|
*/
|
|
44589
|
-
*compose(
|
|
44590
|
-
for (const token5 of
|
|
44604
|
+
*compose(tokens7, forceDoc = false, endOffset = -1) {
|
|
44605
|
+
for (const token5 of tokens7)
|
|
44591
44606
|
yield* this.next(token5);
|
|
44592
44607
|
yield* this.end(forceDoc, endOffset);
|
|
44593
44608
|
}
|
|
@@ -46632,7 +46647,7 @@ var require_public_api = __commonJS({
|
|
|
46632
46647
|
}
|
|
46633
46648
|
return doc;
|
|
46634
46649
|
}
|
|
46635
|
-
function
|
|
46650
|
+
function parse28(src, reviver, options5) {
|
|
46636
46651
|
let _reviver = void 0;
|
|
46637
46652
|
if (typeof reviver === "function") {
|
|
46638
46653
|
_reviver = reviver;
|
|
@@ -46673,7 +46688,7 @@ var require_public_api = __commonJS({
|
|
|
46673
46688
|
return value6.toString(options5);
|
|
46674
46689
|
return new Document2.Document(value6, _replacer, options5).toString(options5);
|
|
46675
46690
|
}
|
|
46676
|
-
exports.parse =
|
|
46691
|
+
exports.parse = parse28;
|
|
46677
46692
|
exports.parseAllDocuments = parseAllDocuments;
|
|
46678
46693
|
exports.parseDocument = parseDocument9;
|
|
46679
46694
|
exports.stringify = stringify8;
|
|
@@ -58842,8 +58857,8 @@ var init_src_DdvbAHrR = __esm({
|
|
|
58842
58857
|
var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g;
|
|
58843
58858
|
var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g;
|
|
58844
58859
|
var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
58845
|
-
exports.parse =
|
|
58846
|
-
function
|
|
58860
|
+
exports.parse = parse28;
|
|
58861
|
+
function parse28(string11) {
|
|
58847
58862
|
if (!string11) throw new TypeError("argument string is required");
|
|
58848
58863
|
var header4 = typeof string11 === "object" ? getcontenttype(string11) : string11;
|
|
58849
58864
|
if (typeof header4 !== "string") throw new TypeError("argument string is required to be a string");
|
|
@@ -62227,7 +62242,7 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
62227
62242
|
}
|
|
62228
62243
|
function normalize4(uri, options5) {
|
|
62229
62244
|
if (typeof uri === "string") uri = normalizeString(uri, options5);
|
|
62230
|
-
else if (typeof uri === "object") uri =
|
|
62245
|
+
else if (typeof uri === "object") uri = parse28(serialize2(uri, options5), options5);
|
|
62231
62246
|
return uri;
|
|
62232
62247
|
}
|
|
62233
62248
|
function resolve61(baseURI, relativeURI, options5) {
|
|
@@ -62248,8 +62263,8 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
62248
62263
|
function resolveComponent(base6, relative29, options5, skipNormalization) {
|
|
62249
62264
|
const target6 = {};
|
|
62250
62265
|
if (!skipNormalization) {
|
|
62251
|
-
base6 =
|
|
62252
|
-
relative29 =
|
|
62266
|
+
base6 = parse28(serialize2(base6, options5), options5);
|
|
62267
|
+
relative29 = parse28(serialize2(relative29, options5), options5);
|
|
62253
62268
|
}
|
|
62254
62269
|
options5 = options5 || {};
|
|
62255
62270
|
if (!options5.tolerant && relative29.scheme) {
|
|
@@ -62481,7 +62496,7 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
62481
62496
|
malformedScheme
|
|
62482
62497
|
};
|
|
62483
62498
|
}
|
|
62484
|
-
function
|
|
62499
|
+
function parse28(uri, opts) {
|
|
62485
62500
|
return parseWithStatus(uri, opts).parsed;
|
|
62486
62501
|
}
|
|
62487
62502
|
function normalizeString(uri, opts) {
|
|
@@ -62516,7 +62531,7 @@ var init_ajvProvider_DyjnscPj = __esm({
|
|
|
62516
62531
|
resolveComponent,
|
|
62517
62532
|
equal: equal3,
|
|
62518
62533
|
serialize: serialize2,
|
|
62519
|
-
parse:
|
|
62534
|
+
parse: parse28
|
|
62520
62535
|
};
|
|
62521
62536
|
module.exports = fastUri;
|
|
62522
62537
|
module.exports.default = fastUri;
|
|
@@ -71966,9 +71981,9 @@ var require_lexer2 = __commonJS({
|
|
|
71966
71981
|
}
|
|
71967
71982
|
if (code5 === 92) {
|
|
71968
71983
|
value6 += body8.slice(chunkStart, position);
|
|
71969
|
-
const
|
|
71970
|
-
value6 +=
|
|
71971
|
-
position +=
|
|
71984
|
+
const escape18 = body8.charCodeAt(position + 1) === 117 ? body8.charCodeAt(position + 2) === 123 ? readEscapedUnicodeVariableWidth(lexer, position) : readEscapedUnicodeFixedWidth(lexer, position) : readEscapedCharacter(lexer, position);
|
|
71985
|
+
value6 += escape18.value;
|
|
71986
|
+
position += escape18.size;
|
|
71972
71987
|
chunkStart = position;
|
|
71973
71988
|
continue;
|
|
71974
71989
|
}
|
|
@@ -72551,7 +72566,7 @@ var require_parser2 = __commonJS({
|
|
|
72551
72566
|
value: true
|
|
72552
72567
|
});
|
|
72553
72568
|
exports.Parser = void 0;
|
|
72554
|
-
exports.parse =
|
|
72569
|
+
exports.parse = parse28;
|
|
72555
72570
|
exports.parseConstValue = parseConstValue;
|
|
72556
72571
|
exports.parseSchemaCoordinate = parseSchemaCoordinate;
|
|
72557
72572
|
exports.parseType = parseType;
|
|
@@ -72564,7 +72579,7 @@ var require_parser2 = __commonJS({
|
|
|
72564
72579
|
var _schemaCoordinateLexer = require_schemaCoordinateLexer();
|
|
72565
72580
|
var _source = require_source();
|
|
72566
72581
|
var _tokenKind = require_tokenKind();
|
|
72567
|
-
function
|
|
72582
|
+
function parse28(source, options5) {
|
|
72568
72583
|
const parser = new Parser2(source, options5);
|
|
72569
72584
|
const document2 = parser.parseDocument();
|
|
72570
72585
|
Object.defineProperty(document2, "tokenCount", {
|
|
@@ -90747,7 +90762,7 @@ function graphqlRoots(input5) {
|
|
|
90747
90762
|
const visit4 = (set2) => {
|
|
90748
90763
|
for (const selection2 of set2.selections) {
|
|
90749
90764
|
if (selection2.directives?.some((d) => {
|
|
90750
|
-
const
|
|
90765
|
+
const argument2 = d.arguments?.find((a) => a.name.value === "if"), value6 = argument2 && (0, import_graphql.valueFromASTUntyped)(argument2.value, variables2);
|
|
90751
90766
|
return d.name.value === "skip" && value6 === true || d.name.value === "include" && value6 === false;
|
|
90752
90767
|
})) continue;
|
|
90753
90768
|
if (selection2.kind === import_graphql.Kind.INLINE_FRAGMENT) visit4(selection2.selectionSet);
|
|
@@ -92339,10 +92354,10 @@ var init_node = __esm({
|
|
|
92339
92354
|
#index;
|
|
92340
92355
|
#varIndex;
|
|
92341
92356
|
#children = createNullObject();
|
|
92342
|
-
insert(
|
|
92357
|
+
insert(tokens7, index, paramMap, context3, isStatic) {
|
|
92343
92358
|
let node5 = this;
|
|
92344
|
-
for (let i = 0, len =
|
|
92345
|
-
const token5 =
|
|
92359
|
+
for (let i = 0, len = tokens7.length; i < len; i++) {
|
|
92360
|
+
const token5 = tokens7[i];
|
|
92346
92361
|
const pattern = token5.length === 1 ? token5 === "*" ? i === len - 1 ? [
|
|
92347
92362
|
"",
|
|
92348
92363
|
"",
|
|
@@ -92434,15 +92449,15 @@ var init_trie = __esm({
|
|
|
92434
92449
|
});
|
|
92435
92450
|
if (!replaced3) break;
|
|
92436
92451
|
}
|
|
92437
|
-
const
|
|
92452
|
+
const tokens7 = markedPath.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
|
|
92438
92453
|
for (let i = groups.length - 1; i >= 0; i--) {
|
|
92439
92454
|
const [mark] = groups[i];
|
|
92440
|
-
for (let j =
|
|
92441
|
-
|
|
92455
|
+
for (let j = tokens7.length - 1; j >= 0; j--) if (tokens7[j].indexOf(mark) !== -1) {
|
|
92456
|
+
tokens7[j] = tokens7[j].replace(mark, groups[i][1]);
|
|
92442
92457
|
break;
|
|
92443
92458
|
}
|
|
92444
92459
|
}
|
|
92445
|
-
this.#root.insert(
|
|
92460
|
+
this.#root.insert(tokens7, this.#index, paramAssoc, this.#context, false);
|
|
92446
92461
|
this.paths[path9] = [this.#index++, paramAssoc];
|
|
92447
92462
|
}
|
|
92448
92463
|
buildRegExp() {
|
|
@@ -104140,7 +104155,7 @@ function decodeQuotedPrintable(text31) {
|
|
|
104140
104155
|
return Buffer.from(bytes4);
|
|
104141
104156
|
}
|
|
104142
104157
|
function parseHeaderParams(value6) {
|
|
104143
|
-
const
|
|
104158
|
+
const tokens7 = [];
|
|
104144
104159
|
let current = "", quoted4 = false;
|
|
104145
104160
|
for (let i = 0; i < value6.length; i++) {
|
|
104146
104161
|
const ch = value6[i];
|
|
@@ -104153,16 +104168,16 @@ function parseHeaderParams(value6) {
|
|
|
104153
104168
|
continue;
|
|
104154
104169
|
}
|
|
104155
104170
|
if (ch === ";" && !quoted4) {
|
|
104156
|
-
|
|
104171
|
+
tokens7.push(current);
|
|
104157
104172
|
current = "";
|
|
104158
104173
|
continue;
|
|
104159
104174
|
}
|
|
104160
104175
|
current += ch;
|
|
104161
104176
|
}
|
|
104162
|
-
|
|
104177
|
+
tokens7.push(current);
|
|
104163
104178
|
const params10 = {};
|
|
104164
104179
|
const extended2 = {};
|
|
104165
|
-
for (const token5 of
|
|
104180
|
+
for (const token5 of tokens7.slice(1)) {
|
|
104166
104181
|
const eq = token5.indexOf("=");
|
|
104167
104182
|
if (eq < 1) continue;
|
|
104168
104183
|
const key5 = token5.slice(0, eq).trim().toLowerCase(), val = token5.slice(eq + 1).trim();
|
|
@@ -104190,7 +104205,7 @@ function parseHeaderParams(value6) {
|
|
|
104190
104205
|
});
|
|
104191
104206
|
params10[name5] = decodeCharset(Buffer.concat(bytes4), charset);
|
|
104192
104207
|
}
|
|
104193
|
-
return { value:
|
|
104208
|
+
return { value: tokens7[0].trim(), params: params10 };
|
|
104194
104209
|
}
|
|
104195
104210
|
function splitHeaders(block2) {
|
|
104196
104211
|
const headers = [];
|
|
@@ -111584,7 +111599,7 @@ import { createHash as createHash21 } from "node:crypto";
|
|
|
111584
111599
|
function parse5(source) {
|
|
111585
111600
|
if (source.length > 2e4)
|
|
111586
111601
|
invalid9("Query too long");
|
|
111587
|
-
const
|
|
111602
|
+
const tokens7 = [];
|
|
111588
111603
|
let pos = 0;
|
|
111589
111604
|
const scanner = /\s*(?:([A-Za-z_][A-Za-z_0-9.]*)|(-?\d+(?:\.\d+)?)|('(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*")|(>=|<=|!=|=|>|<|,|\(|\)))/y;
|
|
111590
111605
|
while (pos < source.length) {
|
|
@@ -111595,14 +111610,14 @@ function parse5(source) {
|
|
|
111595
111610
|
break;
|
|
111596
111611
|
gap(`GAQL syntax near ${source.slice(pos, pos + 30)}`);
|
|
111597
111612
|
}
|
|
111598
|
-
|
|
111613
|
+
tokens7.push(m[1] ?? m[2] ?? m[3] ?? m[4]);
|
|
111599
111614
|
pos = scanner.lastIndex;
|
|
111600
111615
|
}
|
|
111601
111616
|
let i = 0;
|
|
111602
|
-
const peek = () =>
|
|
111603
|
-
if (i >=
|
|
111617
|
+
const peek = () => tokens7[i]?.toUpperCase(), take2 = () => {
|
|
111618
|
+
if (i >= tokens7.length)
|
|
111604
111619
|
invalid9("Unexpected end of query");
|
|
111605
|
-
return
|
|
111620
|
+
return tokens7[i++];
|
|
111606
111621
|
}, expect = (s3) => {
|
|
111607
111622
|
if (take2().toUpperCase() !== s3)
|
|
111608
111623
|
invalid9(`Expected ${s3}`);
|
|
@@ -111681,8 +111696,8 @@ function parse5(source) {
|
|
|
111681
111696
|
invalid9("LIMIT must be 1..100000");
|
|
111682
111697
|
limit2 = Number(n2);
|
|
111683
111698
|
}
|
|
111684
|
-
if (i !==
|
|
111685
|
-
gap(`GAQL clause ${
|
|
111699
|
+
if (i !== tokens7.length)
|
|
111700
|
+
gap(`GAQL clause ${tokens7.slice(i).join(" ")}`);
|
|
111686
111701
|
const joins = { customer: [], customer_client: [], campaign_budget: ["customer"], campaign: ["customer", "campaign_budget", "metrics", "segments"], ad_group: ["customer", "campaign", "campaign_budget"], ad_group_ad: ["customer", "ad_group", "campaign", "campaign_budget"], ad_group_criterion: ["customer", "ad_group", "campaign", "campaign_budget"] };
|
|
111687
111702
|
for (const f2 of [...select4, ...where3.map((p2) => p2.field), ...order6.map((o) => o.field)]) {
|
|
111688
111703
|
const [prefix2, ...path9] = f2.split(".");
|
|
@@ -116481,7 +116496,7 @@ var require_root = __commonJS({
|
|
|
116481
116496
|
var OneOf = require_oneof();
|
|
116482
116497
|
var util = require_util2();
|
|
116483
116498
|
var Type;
|
|
116484
|
-
var
|
|
116499
|
+
var parse28;
|
|
116485
116500
|
var common4;
|
|
116486
116501
|
function Root(options5) {
|
|
116487
116502
|
Namespace.call(this, "", options5);
|
|
@@ -116545,8 +116560,8 @@ var require_root = __commonJS({
|
|
|
116545
116560
|
if (!util.isString(source))
|
|
116546
116561
|
self2.setOptions(source.options).addJSON(source.nested);
|
|
116547
116562
|
else {
|
|
116548
|
-
|
|
116549
|
-
var parsed5 =
|
|
116563
|
+
parse28.filename = filename2;
|
|
116564
|
+
var parsed5 = parse28(source, self2, options5), resolved2, i2 = 0;
|
|
116550
116565
|
if (parsed5.imports) {
|
|
116551
116566
|
for (; i2 < parsed5.imports.length; ++i2)
|
|
116552
116567
|
if (resolved2 = getBundledFileName(parsed5.imports[i2]) || self2.resolvePath(filename2, parsed5.imports[i2]))
|
|
@@ -116719,7 +116734,7 @@ var require_root = __commonJS({
|
|
|
116719
116734
|
};
|
|
116720
116735
|
Root._configure = function(Type_, parse_, common_) {
|
|
116721
116736
|
Type = Type_;
|
|
116722
|
-
|
|
116737
|
+
parse28 = parse_;
|
|
116723
116738
|
common4 = common_;
|
|
116724
116739
|
};
|
|
116725
116740
|
}
|
|
@@ -117992,9 +118007,9 @@ var require_tokenize = __commonJS({
|
|
|
117992
118007
|
var require_parse = __commonJS({
|
|
117993
118008
|
"node_modules/.pnpm/protobufjs@7.6.6/node_modules/protobufjs/src/parse.js"(exports, module) {
|
|
117994
118009
|
"use strict";
|
|
117995
|
-
module.exports =
|
|
117996
|
-
|
|
117997
|
-
|
|
118010
|
+
module.exports = parse28;
|
|
118011
|
+
parse28.filename = null;
|
|
118012
|
+
parse28.defaults = { keepCase: false };
|
|
117998
118013
|
var tokenize10 = require_tokenize();
|
|
117999
118014
|
var Root = require_root();
|
|
118000
118015
|
var Type = require_type2();
|
|
@@ -118016,13 +118031,13 @@ var require_parse = __commonJS({
|
|
|
118016
118031
|
var numberRe = util.patterns.numberRe;
|
|
118017
118032
|
var nameRe = /^[a-zA-Z_][a-zA-Z_0-9]*$/;
|
|
118018
118033
|
var typeRefRe = util.patterns.typeRefRe;
|
|
118019
|
-
function
|
|
118034
|
+
function parse28(source, root3, options5) {
|
|
118020
118035
|
if (!(root3 instanceof Root)) {
|
|
118021
118036
|
options5 = root3;
|
|
118022
118037
|
root3 = new Root();
|
|
118023
118038
|
}
|
|
118024
118039
|
if (!options5)
|
|
118025
|
-
options5 =
|
|
118040
|
+
options5 = parse28.defaults;
|
|
118026
118041
|
var preferTrailingComment = options5.preferTrailingComment || false;
|
|
118027
118042
|
var tn = tokenize10(source, options5.alternateCommentMode || false), next2 = tn.next, push = tn.push, peek = tn.peek, skip = tn.skip, cmnt = tn.cmnt;
|
|
118028
118043
|
var head = true, pkg, imports2, weakImports, edition = "proto2";
|
|
@@ -118042,9 +118057,9 @@ var require_parse = __commonJS({
|
|
|
118042
118057
|
});
|
|
118043
118058
|
}
|
|
118044
118059
|
function illegal(token6, name5, insideTryCatch) {
|
|
118045
|
-
var filename =
|
|
118060
|
+
var filename = parse28.filename;
|
|
118046
118061
|
if (!insideTryCatch)
|
|
118047
|
-
|
|
118062
|
+
parse28.filename = null;
|
|
118048
118063
|
return Error("illegal " + (name5 || "token") + " '" + token6 + "' (" + (filename ? filename + ", " : "") + "line " + tn.line + ")");
|
|
118049
118064
|
}
|
|
118050
118065
|
function readString() {
|
|
@@ -118244,7 +118259,7 @@ var require_parse = __commonJS({
|
|
|
118244
118259
|
if (typeof obj.comment !== "string") {
|
|
118245
118260
|
obj.comment = cmnt();
|
|
118246
118261
|
}
|
|
118247
|
-
obj.filename =
|
|
118262
|
+
obj.filename = parse28.filename;
|
|
118248
118263
|
}
|
|
118249
118264
|
if (skip("{", true)) {
|
|
118250
118265
|
var token6;
|
|
@@ -118370,7 +118385,7 @@ var require_parse = __commonJS({
|
|
|
118370
118385
|
var type = new Type(name5);
|
|
118371
118386
|
type.group = true;
|
|
118372
118387
|
var field6 = new Field(fieldName2, id14, name5, rule);
|
|
118373
|
-
field6.filename =
|
|
118388
|
+
field6.filename = parse28.filename;
|
|
118374
118389
|
ifBlock(type, function parseGroup_block(token6) {
|
|
118375
118390
|
switch (token6) {
|
|
118376
118391
|
case "option":
|
|
@@ -118514,9 +118529,9 @@ var require_parse = __commonJS({
|
|
|
118514
118529
|
if (isOption) {
|
|
118515
118530
|
isOption = false;
|
|
118516
118531
|
if (token6.includes(".") && !token6.includes("(")) {
|
|
118517
|
-
var
|
|
118518
|
-
option4 =
|
|
118519
|
-
token6 =
|
|
118532
|
+
var tokens7 = token6.split(".");
|
|
118533
|
+
option4 = tokens7[0] + ".";
|
|
118534
|
+
token6 = tokens7[1];
|
|
118520
118535
|
continue;
|
|
118521
118536
|
}
|
|
118522
118537
|
option4 = token6;
|
|
@@ -118718,7 +118733,7 @@ var require_parse = __commonJS({
|
|
|
118718
118733
|
}
|
|
118719
118734
|
}
|
|
118720
118735
|
resolveFileFeatures();
|
|
118721
|
-
|
|
118736
|
+
parse28.filename = null;
|
|
118722
118737
|
return {
|
|
118723
118738
|
"package": pkg,
|
|
118724
118739
|
"imports": imports2,
|
|
@@ -125767,7 +125782,7 @@ var require_client = __commonJS({
|
|
|
125767
125782
|
return { metadata: arg1, options: arg2, callback: arg3 };
|
|
125768
125783
|
}
|
|
125769
125784
|
}
|
|
125770
|
-
makeUnaryRequest(method2, serialize2, deserialize,
|
|
125785
|
+
makeUnaryRequest(method2, serialize2, deserialize, argument2, metadata8, options5, callback2) {
|
|
125771
125786
|
var _a7, _b;
|
|
125772
125787
|
const checkedArguments = this.checkOptionalUnaryResponseArguments(metadata8, options5, callback2);
|
|
125773
125788
|
const methodDefinition = {
|
|
@@ -125778,7 +125793,7 @@ var require_client = __commonJS({
|
|
|
125778
125793
|
responseDeserialize: deserialize
|
|
125779
125794
|
};
|
|
125780
125795
|
let callProperties = {
|
|
125781
|
-
argument,
|
|
125796
|
+
argument: argument2,
|
|
125782
125797
|
metadata: checkedArguments.metadata,
|
|
125783
125798
|
call: new call_1.ClientUnaryCallImpl(),
|
|
125784
125799
|
channel: this[CHANNEL_SYMBOL],
|
|
@@ -125836,7 +125851,7 @@ var require_client = __commonJS({
|
|
|
125836
125851
|
emitter.emit("status", status6);
|
|
125837
125852
|
}
|
|
125838
125853
|
});
|
|
125839
|
-
call4.sendMessage(
|
|
125854
|
+
call4.sendMessage(argument2);
|
|
125840
125855
|
call4.halfClose();
|
|
125841
125856
|
return emitter;
|
|
125842
125857
|
}
|
|
@@ -125931,7 +125946,7 @@ var require_client = __commonJS({
|
|
|
125931
125946
|
}
|
|
125932
125947
|
return { metadata: metadata8, options: options5 };
|
|
125933
125948
|
}
|
|
125934
|
-
makeServerStreamRequest(method2, serialize2, deserialize,
|
|
125949
|
+
makeServerStreamRequest(method2, serialize2, deserialize, argument2, metadata8, options5) {
|
|
125935
125950
|
var _a7, _b;
|
|
125936
125951
|
const checkedArguments = this.checkMetadataAndOptions(metadata8, options5);
|
|
125937
125952
|
const methodDefinition = {
|
|
@@ -125942,7 +125957,7 @@ var require_client = __commonJS({
|
|
|
125942
125957
|
responseDeserialize: deserialize
|
|
125943
125958
|
};
|
|
125944
125959
|
let callProperties = {
|
|
125945
|
-
argument,
|
|
125960
|
+
argument: argument2,
|
|
125946
125961
|
metadata: checkedArguments.metadata,
|
|
125947
125962
|
call: new call_1.ClientReadableStreamImpl(deserialize),
|
|
125948
125963
|
channel: this[CHANNEL_SYMBOL],
|
|
@@ -125985,7 +126000,7 @@ var require_client = __commonJS({
|
|
|
125985
126000
|
stream2.emit("status", status6);
|
|
125986
126001
|
}
|
|
125987
126002
|
});
|
|
125988
|
-
call4.sendMessage(
|
|
126003
|
+
call4.sendMessage(argument2);
|
|
125989
126004
|
call4.halfClose();
|
|
125990
126005
|
return stream2;
|
|
125991
126006
|
}
|
|
@@ -140212,9 +140227,9 @@ var init_coverage2 = __esm({
|
|
|
140212
140227
|
|
|
140213
140228
|
// packages/server/src/twins/datadog/methods/search.ts
|
|
140214
140229
|
function terms(text31) {
|
|
140215
|
-
const
|
|
140230
|
+
const tokens7 = text31.match(/(?:[^\s"]|"[^"]*")+/g) ?? [];
|
|
140216
140231
|
if ((text31.match(/"/g)?.length ?? 0) % 2) throw new DatadogError(400, "Invalid search query");
|
|
140217
|
-
return
|
|
140232
|
+
return tokens7.filter((token5) => token5 !== "AND").map((token5) => {
|
|
140218
140233
|
if (/^(OR|NOT)$|[()!]|^-/.test(token5)) unsupported6("monitor search expressions");
|
|
140219
140234
|
const colon = token5.indexOf(":");
|
|
140220
140235
|
const field6 = colon < 0 ? void 0 : token5.slice(0, colon).toLowerCase();
|
|
@@ -142582,26 +142597,26 @@ var init_store3 = __esm({
|
|
|
142582
142597
|
function tokenize3(q2) {
|
|
142583
142598
|
if (!q2 || q2.length > 2e4) throw new SalesforceError(400, "MALFORMED_QUERY", "Query must contain 1\u201320,000 characters.");
|
|
142584
142599
|
const pattern = /\s*(?:('(?:\\.|[^'\\])*')|(\d{4}-\d{2}-\d{2}(?![T\d-]))|([A-Za-z_][A-Za-z0-9_]*)|(-?\d+(?:\.\d+)?)|(>=|<=|!=|=|>|<)|([(),]))/gy;
|
|
142585
|
-
const
|
|
142600
|
+
const tokens7 = [];
|
|
142586
142601
|
let position = 0;
|
|
142587
142602
|
while (position < q2.trimEnd().length) {
|
|
142588
142603
|
pattern.lastIndex = position;
|
|
142589
142604
|
const match3 = pattern.exec(q2);
|
|
142590
142605
|
if (!match3) unsupported11("SOQL expression outside the documented subset", "MALFORMED_QUERY");
|
|
142591
142606
|
const raw3 = match3[1] ?? match3[2] ?? match3[3] ?? match3[4] ?? match3[5] ?? match3[6];
|
|
142592
|
-
|
|
142607
|
+
tokens7.push(match3[1] ? { raw: raw3, value: raw3.slice(1, -1).replace(/\\(['\\])/g, "$1"), literal: true } : match3[2] ? { raw: raw3, value: raw3, literal: true } : match3[4] ? { raw: raw3, value: Number(raw3), literal: true } : { raw: raw3 });
|
|
142593
142608
|
position = pattern.lastIndex;
|
|
142594
|
-
if (
|
|
142609
|
+
if (tokens7.length > 500) unsupported11("SOQL expression exceeds the 500-token subset", "MALFORMED_QUERY");
|
|
142595
142610
|
}
|
|
142596
|
-
return
|
|
142611
|
+
return tokens7;
|
|
142597
142612
|
}
|
|
142598
142613
|
function executeQuery(ctx, q2) {
|
|
142599
142614
|
permission5(ctx);
|
|
142600
|
-
const
|
|
142615
|
+
const tokens7 = tokenize3(q2);
|
|
142601
142616
|
let at6 = 0;
|
|
142602
|
-
const peek = (word2) =>
|
|
142617
|
+
const peek = (word2) => tokens7[at6]?.raw.toUpperCase() === word2;
|
|
142603
142618
|
const take2 = () => {
|
|
142604
|
-
const token5 =
|
|
142619
|
+
const token5 = tokens7[at6++];
|
|
142605
142620
|
if (!token5) throw new SalesforceError(400, "MALFORMED_QUERY", "Incomplete query.");
|
|
142606
142621
|
return token5;
|
|
142607
142622
|
};
|
|
@@ -142692,7 +142707,7 @@ function executeQuery(ctx, q2) {
|
|
|
142692
142707
|
at6++;
|
|
142693
142708
|
offset20 = integer17(2e3);
|
|
142694
142709
|
}
|
|
142695
|
-
if (at6 !==
|
|
142710
|
+
if (at6 !== tokens7.length) unsupported11(`SOQL ${tokens7[at6].raw}; relationships, aggregation, OR and additional clauses are outside this subset`, "MALFORMED_QUERY");
|
|
142696
142711
|
let result = rows29(ctx, type).filter((record31) => visible2(ctx, type, record31)).map((record31) => project6(type, record31)).filter((record31) => predicates.every((test3) => test3(record31)));
|
|
142697
142712
|
if (order6) result.sort((a, b) => {
|
|
142698
142713
|
const left = a[order6] ?? null, right = b[order6] ?? null;
|
|
@@ -144599,7 +144614,7 @@ var init_request13 = __esm({
|
|
|
144599
144614
|
|
|
144600
144615
|
// packages/server/src/twins/google-drive/query.ts
|
|
144601
144616
|
function tokenize4(source) {
|
|
144602
|
-
const
|
|
144617
|
+
const tokens7 = [];
|
|
144603
144618
|
let at6 = 0;
|
|
144604
144619
|
while (at6 < source.length) {
|
|
144605
144620
|
const char = source[at6];
|
|
@@ -144608,7 +144623,7 @@ function tokenize4(source) {
|
|
|
144608
144623
|
continue;
|
|
144609
144624
|
}
|
|
144610
144625
|
if (char === "(" || char === ")") {
|
|
144611
|
-
|
|
144626
|
+
tokens7.push({ kind: "paren", value: char });
|
|
144612
144627
|
at6++;
|
|
144613
144628
|
continue;
|
|
144614
144629
|
}
|
|
@@ -144631,25 +144646,25 @@ function tokenize4(source) {
|
|
|
144631
144646
|
value6 += next2;
|
|
144632
144647
|
at6++;
|
|
144633
144648
|
}
|
|
144634
|
-
|
|
144649
|
+
tokens7.push({ kind: "string", value: value6 });
|
|
144635
144650
|
continue;
|
|
144636
144651
|
}
|
|
144637
144652
|
const op2 = /^(?:!=|<=|>=|=|<|>)/.exec(source.slice(at6));
|
|
144638
144653
|
if (op2) {
|
|
144639
|
-
|
|
144654
|
+
tokens7.push({ kind: "op", value: op2[0] });
|
|
144640
144655
|
at6 += op2[0].length;
|
|
144641
144656
|
continue;
|
|
144642
144657
|
}
|
|
144643
144658
|
const word2 = /^[A-Za-z_][A-Za-z0-9_.]*/.exec(source.slice(at6));
|
|
144644
144659
|
if (word2) {
|
|
144645
|
-
|
|
144660
|
+
tokens7.push({ kind: "word", value: word2[0] });
|
|
144646
144661
|
at6 += word2[0].length;
|
|
144647
144662
|
continue;
|
|
144648
144663
|
}
|
|
144649
144664
|
if (char === "{" || char === "}") unsupported14("properties and appProperties search with has");
|
|
144650
144665
|
throw invalid16("q");
|
|
144651
144666
|
}
|
|
144652
|
-
return
|
|
144667
|
+
return tokens7;
|
|
144653
144668
|
}
|
|
144654
144669
|
function namePrefix(name5, value6) {
|
|
144655
144670
|
if (!value6) return true;
|
|
@@ -144690,13 +144705,13 @@ function compare4(left, op2, right) {
|
|
|
144690
144705
|
throw invalid16("q");
|
|
144691
144706
|
}
|
|
144692
144707
|
}
|
|
144693
|
-
function parseQuery(source,
|
|
144694
|
-
const
|
|
144708
|
+
function parseQuery(source, aliases2) {
|
|
144709
|
+
const tokens7 = tokenize4(source);
|
|
144695
144710
|
let at6 = 0;
|
|
144696
|
-
const peek = () =>
|
|
144711
|
+
const peek = () => tokens7[at6];
|
|
144697
144712
|
const isWord = (token5, value6) => token5?.kind === "word" && token5.value.toLowerCase() === value6;
|
|
144698
144713
|
const expect = () => {
|
|
144699
|
-
const token5 =
|
|
144714
|
+
const token5 = tokens7[at6++];
|
|
144700
144715
|
if (!token5) throw invalid16("q");
|
|
144701
144716
|
return token5;
|
|
144702
144717
|
};
|
|
@@ -144753,7 +144768,7 @@ function parseQuery(source, aliases) {
|
|
|
144753
144768
|
if (!isWord(expect(), "in")) throw invalid16("q");
|
|
144754
144769
|
const field7 = expect();
|
|
144755
144770
|
if (field7.kind !== "word") throw invalid16("q");
|
|
144756
|
-
const value6 = first2.value === "me" ?
|
|
144771
|
+
const value6 = first2.value === "me" ? aliases2.me : first2.value === "root" ? aliases2.root : first2.value;
|
|
144757
144772
|
switch (field7.value) {
|
|
144758
144773
|
case "parents":
|
|
144759
144774
|
return (file3) => file3.parents.includes(value6);
|
|
@@ -144833,9 +144848,9 @@ function parseQuery(source, aliases) {
|
|
|
144833
144848
|
throw invalid16("q");
|
|
144834
144849
|
}
|
|
144835
144850
|
};
|
|
144836
|
-
if (!
|
|
144851
|
+
if (!tokens7.length) return () => true;
|
|
144837
144852
|
const predicate2 = or();
|
|
144838
|
-
if (at6 !==
|
|
144853
|
+
if (at6 !== tokens7.length) throw invalid16("q");
|
|
144839
144854
|
return predicate2;
|
|
144840
144855
|
}
|
|
144841
144856
|
var init_query4 = __esm({
|
|
@@ -146200,7 +146215,7 @@ var init_batch = __esm({
|
|
|
146200
146215
|
|
|
146201
146216
|
// packages/server/src/twins/gmail/search.ts
|
|
146202
146217
|
function tokenize5(q2) {
|
|
146203
|
-
const
|
|
146218
|
+
const tokens7 = [];
|
|
146204
146219
|
let i = 0;
|
|
146205
146220
|
while (i < q2.length) {
|
|
146206
146221
|
const ch = q2[i];
|
|
@@ -146209,39 +146224,39 @@ function tokenize5(q2) {
|
|
|
146209
146224
|
continue;
|
|
146210
146225
|
}
|
|
146211
146226
|
if (ch === "(") {
|
|
146212
|
-
|
|
146227
|
+
tokens7.push({ type: "open", value: ch });
|
|
146213
146228
|
i++;
|
|
146214
146229
|
continue;
|
|
146215
146230
|
}
|
|
146216
146231
|
if (ch === ")") {
|
|
146217
|
-
|
|
146232
|
+
tokens7.push({ type: "close", value: ch });
|
|
146218
146233
|
i++;
|
|
146219
146234
|
continue;
|
|
146220
146235
|
}
|
|
146221
146236
|
if (ch === "{") {
|
|
146222
|
-
|
|
146237
|
+
tokens7.push({ type: "openBrace", value: ch });
|
|
146223
146238
|
i++;
|
|
146224
146239
|
continue;
|
|
146225
146240
|
}
|
|
146226
146241
|
if (ch === "}") {
|
|
146227
|
-
|
|
146242
|
+
tokens7.push({ type: "closeBrace", value: ch });
|
|
146228
146243
|
i++;
|
|
146229
146244
|
continue;
|
|
146230
146245
|
}
|
|
146231
146246
|
if (ch === "|") {
|
|
146232
|
-
|
|
146247
|
+
tokens7.push({ type: "or", value: ch });
|
|
146233
146248
|
i++;
|
|
146234
146249
|
continue;
|
|
146235
146250
|
}
|
|
146236
146251
|
if (ch === "-" && i + 1 < q2.length && !/\s/.test(q2[i + 1])) {
|
|
146237
|
-
|
|
146252
|
+
tokens7.push({ type: "minus", value: ch });
|
|
146238
146253
|
i++;
|
|
146239
146254
|
continue;
|
|
146240
146255
|
}
|
|
146241
146256
|
if (ch === '"') {
|
|
146242
146257
|
const end = q2.indexOf('"', i + 1);
|
|
146243
146258
|
const value6 = end < 0 ? q2.slice(i + 1) : q2.slice(i + 1, end);
|
|
146244
|
-
|
|
146259
|
+
tokens7.push({ type: "phrase", value: value6 });
|
|
146245
146260
|
i = end < 0 ? q2.length : end + 1;
|
|
146246
146261
|
continue;
|
|
146247
146262
|
}
|
|
@@ -146262,13 +146277,13 @@ function tokenize5(q2) {
|
|
|
146262
146277
|
value6 = end < 0 ? q2.slice(i + 1) : q2.slice(i + 1, end);
|
|
146263
146278
|
i = end < 0 ? q2.length : end + 1;
|
|
146264
146279
|
}
|
|
146265
|
-
|
|
146280
|
+
tokens7.push({ type: "op", op: op2, value: value6 });
|
|
146266
146281
|
continue;
|
|
146267
146282
|
}
|
|
146268
|
-
if (word2 === "OR")
|
|
146269
|
-
else if (word2 !== "AND")
|
|
146283
|
+
if (word2 === "OR") tokens7.push({ type: "or", value: word2 });
|
|
146284
|
+
else if (word2 !== "AND") tokens7.push({ type: "word", value: word2 });
|
|
146270
146285
|
}
|
|
146271
|
-
return
|
|
146286
|
+
return tokens7;
|
|
146272
146287
|
}
|
|
146273
146288
|
function containsWords(haystack, needle) {
|
|
146274
146289
|
const want = words3(needle);
|
|
@@ -146400,13 +146415,13 @@ function operator(op2, value6) {
|
|
|
146400
146415
|
return unsupported7(`Gmail search operator ${op2}:`);
|
|
146401
146416
|
}
|
|
146402
146417
|
}
|
|
146403
|
-
function parse9(
|
|
146418
|
+
function parse9(tokens7) {
|
|
146404
146419
|
let i = 0;
|
|
146405
146420
|
const sequence = (until) => {
|
|
146406
146421
|
const items2 = [];
|
|
146407
|
-
while (i <
|
|
146422
|
+
while (i < tokens7.length && tokens7[i].type !== until) {
|
|
146408
146423
|
let item2 = unary();
|
|
146409
|
-
while (
|
|
146424
|
+
while (tokens7[i]?.type === "or") {
|
|
146410
146425
|
i++;
|
|
146411
146426
|
const next2 = unary();
|
|
146412
146427
|
item2 = { kind: "or", items: [item2, next2] };
|
|
@@ -146416,7 +146431,7 @@ function parse9(tokens6) {
|
|
|
146416
146431
|
return items2;
|
|
146417
146432
|
};
|
|
146418
146433
|
const unary = () => {
|
|
146419
|
-
const token5 =
|
|
146434
|
+
const token5 = tokens7[i++];
|
|
146420
146435
|
if (!token5) return { kind: "and", items: [] };
|
|
146421
146436
|
switch (token5.type) {
|
|
146422
146437
|
case "minus":
|
|
@@ -149972,7 +149987,7 @@ var init_checks12 = __esm({
|
|
|
149972
149987
|
|
|
149973
149988
|
// packages/server/src/twins/okta/filter.ts
|
|
149974
149989
|
function tokenize6(source) {
|
|
149975
|
-
const
|
|
149990
|
+
const tokens7 = [];
|
|
149976
149991
|
let at6 = 0;
|
|
149977
149992
|
while (at6 < source.length) {
|
|
149978
149993
|
const char = source[at6];
|
|
@@ -149981,7 +149996,7 @@ function tokenize6(source) {
|
|
|
149981
149996
|
continue;
|
|
149982
149997
|
}
|
|
149983
149998
|
if (char === "(" || char === ")") {
|
|
149984
|
-
|
|
149999
|
+
tokens7.push({ kind: "paren", value: char });
|
|
149985
150000
|
at6++;
|
|
149986
150001
|
continue;
|
|
149987
150002
|
}
|
|
@@ -150001,21 +150016,21 @@ function tokenize6(source) {
|
|
|
150001
150016
|
}
|
|
150002
150017
|
value6 += source[at6++];
|
|
150003
150018
|
}
|
|
150004
|
-
|
|
150019
|
+
tokens7.push({ kind: "string", value: value6 });
|
|
150005
150020
|
continue;
|
|
150006
150021
|
}
|
|
150007
150022
|
const number7 = /^-?\d+(?:\.\d+)?/.exec(source.slice(at6));
|
|
150008
150023
|
if (number7) {
|
|
150009
|
-
|
|
150024
|
+
tokens7.push({ kind: "number", value: number7[0] });
|
|
150010
150025
|
at6 += number7[0].length;
|
|
150011
150026
|
continue;
|
|
150012
150027
|
}
|
|
150013
150028
|
const word2 = /^[A-Za-z_][A-Za-z0-9_.$]*/.exec(source.slice(at6));
|
|
150014
150029
|
if (!word2) throw new FilterError(`unexpected ${char}`);
|
|
150015
|
-
|
|
150030
|
+
tokens7.push({ kind: "word", value: word2[0] });
|
|
150016
150031
|
at6 += word2[0].length;
|
|
150017
150032
|
}
|
|
150018
|
-
return
|
|
150033
|
+
return tokens7;
|
|
150019
150034
|
}
|
|
150020
150035
|
function compare6(actual, op2, expected) {
|
|
150021
150036
|
if (op2 === "pr") return actual !== void 0 && actual !== null && actual !== "";
|
|
@@ -150049,9 +150064,9 @@ function compare6(actual, op2, expected) {
|
|
|
150049
150064
|
}
|
|
150050
150065
|
}
|
|
150051
150066
|
function parseFilter(source, attributes3) {
|
|
150052
|
-
const
|
|
150067
|
+
const tokens7 = tokenize6(source);
|
|
150053
150068
|
let at6 = 0;
|
|
150054
|
-
const keyword = (value6) =>
|
|
150069
|
+
const keyword = (value6) => tokens7[at6]?.kind === "word" && tokens7[at6].value.toLowerCase() === value6;
|
|
150055
150070
|
const or = () => {
|
|
150056
150071
|
const terms2 = [and()];
|
|
150057
150072
|
while (keyword("or")) {
|
|
@@ -150074,21 +150089,21 @@ function parseFilter(source, attributes3) {
|
|
|
150074
150089
|
const inner2 = unary();
|
|
150075
150090
|
return (lookup7) => !inner2(lookup7);
|
|
150076
150091
|
}
|
|
150077
|
-
if (
|
|
150092
|
+
if (tokens7[at6]?.kind === "paren" && tokens7[at6].value === "(") {
|
|
150078
150093
|
at6++;
|
|
150079
150094
|
const inner2 = or();
|
|
150080
|
-
if (
|
|
150095
|
+
if (tokens7[at6]?.kind !== "paren" || tokens7[at6].value !== ")") throw new FilterError("missing )");
|
|
150081
150096
|
at6++;
|
|
150082
150097
|
return inner2;
|
|
150083
150098
|
}
|
|
150084
|
-
const path9 =
|
|
150099
|
+
const path9 = tokens7[at6++];
|
|
150085
150100
|
if (!path9 || path9.kind !== "word") throw new FilterError("expected an attribute");
|
|
150086
150101
|
if (attributes3 && !attributes3(path9.value)) throw new FilterError(`unsupported attribute ${path9.value}`);
|
|
150087
|
-
const operator2 =
|
|
150102
|
+
const operator2 = tokens7[at6++];
|
|
150088
150103
|
if (!operator2 || operator2.kind !== "word" || !OPERATORS.has(operator2.value.toLowerCase())) throw new FilterError("expected an operator");
|
|
150089
150104
|
const op2 = operator2.value.toLowerCase();
|
|
150090
150105
|
if (op2 === "pr") return (lookup7) => compare6(lookup7(path9.value), "pr", null);
|
|
150091
|
-
const value6 =
|
|
150106
|
+
const value6 = tokens7[at6++];
|
|
150092
150107
|
if (!value6) throw new FilterError("expected a value");
|
|
150093
150108
|
let expected;
|
|
150094
150109
|
if (value6.kind === "string") expected = value6.value;
|
|
@@ -150097,9 +150112,9 @@ function parseFilter(source, attributes3) {
|
|
|
150097
150112
|
else throw new FilterError("expected a value");
|
|
150098
150113
|
return (lookup7) => compare6(lookup7(path9.value), op2, expected);
|
|
150099
150114
|
};
|
|
150100
|
-
if (!
|
|
150115
|
+
if (!tokens7.length) throw new FilterError("empty expression");
|
|
150101
150116
|
const expression4 = or();
|
|
150102
|
-
if (at6 !==
|
|
150117
|
+
if (at6 !== tokens7.length) throw new FilterError("unexpected trailing input");
|
|
150103
150118
|
return expression4;
|
|
150104
150119
|
}
|
|
150105
150120
|
function lookupIn(value6) {
|
|
@@ -154713,8 +154728,8 @@ function expression2(input5, alias, bind) {
|
|
|
154713
154728
|
}
|
|
154714
154729
|
if (castParts[1]) {
|
|
154715
154730
|
const requested2 = castParts[1];
|
|
154716
|
-
const
|
|
154717
|
-
const type = (
|
|
154731
|
+
const aliases2 = { int: "int4", integer: "int4", bigint: "int8", smallint: "int2", boolean: "bool", decimal: "numeric", real: "float4" };
|
|
154732
|
+
const type = (aliases2[requested2.replace(/\[\]$/, "")] ?? requested2.replace(/\[\]$/, "")) + (requested2.endsWith("[]") ? "[]" : "");
|
|
154718
154733
|
if (!/^[a-zA-Z_][a-zA-Z_0-9]*(\[\])?$/.test(type)) return parseError(input5);
|
|
154719
154734
|
sql6 = `(${sql6})::${ident2(type.replace(/\[\]$/, ""))}${type.endsWith("[]") ? "[]" : ""}`;
|
|
154720
154735
|
}
|
|
@@ -155180,8 +155195,8 @@ function verify(call4, data7, browser) {
|
|
|
155180
155195
|
else if (browser && typeof data7.token === "string") tokenHash = data7.token;
|
|
155181
155196
|
else if (typeof data7.token === "string") tokenHash = hash2(email12(data7.email) + data7.token);
|
|
155182
155197
|
else throw authError2(422, "validation_failed", "Verify requires either a token or a token hash");
|
|
155183
|
-
const
|
|
155184
|
-
const row2 =
|
|
155198
|
+
const tokens7 = query2(call4.ctx, "select * from auth.one_time_tokens where token_hash = $1 and consumed_at is null order by created_at desc", [tokenHash]);
|
|
155199
|
+
const row2 = tokens7.find((t) => t.token_type === type || type === "email" && ["signup", "magiclink"].includes(t.token_type) || type === "email_change" && t.token_type.startsWith("email_change_"));
|
|
155185
155200
|
if (!row2 || Date.parse(row2.expires_at) <= call4.nowMs) throw expired();
|
|
155186
155201
|
let user9 = byId(call4.ctx, row2.user_id);
|
|
155187
155202
|
usable(call4.ctx, user9);
|
|
@@ -159694,13 +159709,13 @@ function serveTemporary(ctx, token5) {
|
|
|
159694
159709
|
return new Response(new Uint8Array(revision2.content), { status: 200, headers: { "content-type": "application/octet-stream" } });
|
|
159695
159710
|
}
|
|
159696
159711
|
function searchPage(call4, cursor4) {
|
|
159697
|
-
const
|
|
159712
|
+
const tokens7 = cursor4.q.toLowerCase().split(/\s+/).filter(Boolean);
|
|
159698
159713
|
const words9 = (value6) => value6.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean);
|
|
159699
159714
|
const candidates = cursor4.s === "deleted" ? call4.ctx.store.db.prepare("SELECT * FROM dbx_deleted ORDER BY path_lower").all().filter((row2) => !getEntry(call4.ctx, row2.path_lower)).map((row2) => ({ key: row2.path_lower, name: nameOf3(row2.path_display), text: "", value: deletedMetadata(row2) })) : childrenOf(call4.ctx, cursor4.p, true).map((entry3) => ({ key: entry3.path_lower, name: nameOf3(entry3.path_display), text: entry3.kind === "file" && /\.(txt|csv|md|json|html|xml|pdf)$/i.test(entry3.path_lower) ? (entry3.content ?? Buffer.alloc(0)).toString("utf8") : "", value: metadata7(call4.ctx, entry3) }));
|
|
159700
159715
|
const matches11 = candidates.filter((item2) => (cursor4.p === "" || item2.key.startsWith(`${cursor4.p}/`)) && (!cursor4.x || cursor4.x.some((ext) => item2.key.endsWith(`.${ext.toLowerCase()}`)))).flatMap((item2) => {
|
|
159701
159716
|
const nameWords = words9(item2.name);
|
|
159702
|
-
const byName =
|
|
159703
|
-
const byContent = !cursor4.f &&
|
|
159717
|
+
const byName = tokens7.every((token5) => nameWords.some((word2) => word2.startsWith(token5)));
|
|
159718
|
+
const byContent = !cursor4.f && tokens7.every((token5) => item2.text.toLowerCase().includes(token5));
|
|
159704
159719
|
if (!byName && !byContent) return [];
|
|
159705
159720
|
return [{ match_type: { ".tag": byName && byContent ? "filename_and_content" : byName ? "filename" : "file_content" }, metadata: { ".tag": "metadata", metadata: item2.value } }];
|
|
159706
159721
|
});
|
|
@@ -160962,8 +160977,8 @@ function restoreVersion(call4, id14) {
|
|
|
160962
160977
|
}
|
|
160963
160978
|
function search7(call4, query12) {
|
|
160964
160979
|
odata(call4, ["$top", "$skiptoken", "$orderby"]);
|
|
160965
|
-
const
|
|
160966
|
-
if (!
|
|
160980
|
+
const tokens7 = query12.toLowerCase().split(/\s+/).filter(Boolean);
|
|
160981
|
+
if (!tokens7.length) throw invalid22("The search query is empty.");
|
|
160967
160982
|
const scope3 = target4(call4), all9 = [];
|
|
160968
160983
|
const visit4 = (node5) => {
|
|
160969
160984
|
for (const child3 of childrenOf2(call4.ctx, node5.id)) {
|
|
@@ -160975,7 +160990,7 @@ function search7(call4, query12) {
|
|
|
160975
160990
|
const matches11 = all9.filter((item2) => {
|
|
160976
160991
|
const text31 = `${item2.name}
|
|
160977
160992
|
${textOf2(item2) ?? ""}`.toLowerCase();
|
|
160978
|
-
return
|
|
160993
|
+
return tokens7.every((token5) => text31.includes(token5));
|
|
160979
160994
|
});
|
|
160980
160995
|
const response6 = collection(call4, "Collection(driveItem)", matches11);
|
|
160981
160996
|
return response6;
|
|
@@ -161265,19 +161280,19 @@ function project9(row2, url4, headers) {
|
|
|
161265
161280
|
return result;
|
|
161266
161281
|
}
|
|
161267
161282
|
function filterPredicate(source) {
|
|
161268
|
-
const
|
|
161283
|
+
const tokens7 = [];
|
|
161269
161284
|
const re = /\s*(startswith|and\b|or\b|not\b|eq\b|ne\b|ge\b|gt\b|le\b|lt\b|true\b|false\b|null\b|'(?:[^']|'')*'|\d{4}-\d\d-\d\dT[\d:.]+(?:Z|[+-]\d\d:\d\d)|[A-Za-z][\w/]*|[(),])\s*/gy;
|
|
161270
161285
|
let at6 = 0;
|
|
161271
161286
|
while (at6 < source.length) {
|
|
161272
161287
|
re.lastIndex = at6;
|
|
161273
161288
|
const m = re.exec(source);
|
|
161274
161289
|
if (!m) throw invalid23("Invalid filter clause.");
|
|
161275
|
-
|
|
161290
|
+
tokens7.push(m[1]);
|
|
161276
161291
|
at6 = re.lastIndex;
|
|
161277
161292
|
}
|
|
161278
161293
|
let i = 0;
|
|
161279
161294
|
const take2 = (want) => {
|
|
161280
|
-
const v =
|
|
161295
|
+
const v = tokens7[i++];
|
|
161281
161296
|
if (!v || want && v !== want) throw invalid23("Invalid filter clause.");
|
|
161282
161297
|
return v;
|
|
161283
161298
|
};
|
|
@@ -161296,18 +161311,18 @@ function filterPredicate(source) {
|
|
|
161296
161311
|
return key5;
|
|
161297
161312
|
};
|
|
161298
161313
|
const atom2 = () => {
|
|
161299
|
-
if (
|
|
161314
|
+
if (tokens7[i] === "(") {
|
|
161300
161315
|
take2();
|
|
161301
161316
|
const p2 = or();
|
|
161302
161317
|
take2(")");
|
|
161303
161318
|
return p2;
|
|
161304
161319
|
}
|
|
161305
|
-
if (
|
|
161320
|
+
if (tokens7[i] === "not") {
|
|
161306
161321
|
take2();
|
|
161307
161322
|
const p2 = atom2();
|
|
161308
161323
|
return (r2) => !p2(r2);
|
|
161309
161324
|
}
|
|
161310
|
-
if (
|
|
161325
|
+
if (tokens7[i] === "startswith") {
|
|
161311
161326
|
take2();
|
|
161312
161327
|
take2("(");
|
|
161313
161328
|
const key6 = property4();
|
|
@@ -161345,7 +161360,7 @@ function filterPredicate(source) {
|
|
|
161345
161360
|
};
|
|
161346
161361
|
const and = () => {
|
|
161347
161362
|
let p2 = atom2();
|
|
161348
|
-
while (
|
|
161363
|
+
while (tokens7[i] === "and") {
|
|
161349
161364
|
take2();
|
|
161350
161365
|
const a = p2, b = atom2();
|
|
161351
161366
|
p2 = (r2) => a(r2) && b(r2);
|
|
@@ -161354,7 +161369,7 @@ function filterPredicate(source) {
|
|
|
161354
161369
|
};
|
|
161355
161370
|
const or = () => {
|
|
161356
161371
|
let p2 = and();
|
|
161357
|
-
while (
|
|
161372
|
+
while (tokens7[i] === "or") {
|
|
161358
161373
|
take2();
|
|
161359
161374
|
const a = p2, b = and();
|
|
161360
161375
|
p2 = (r2) => a(r2) || b(r2);
|
|
@@ -161362,7 +161377,7 @@ function filterPredicate(source) {
|
|
|
161362
161377
|
return p2;
|
|
161363
161378
|
};
|
|
161364
161379
|
const result = or();
|
|
161365
|
-
if (i !==
|
|
161380
|
+
if (i !== tokens7.length) throw invalid23("Invalid filter clause.");
|
|
161366
161381
|
return result;
|
|
161367
161382
|
}
|
|
161368
161383
|
function searchPredicate(source) {
|
|
@@ -161389,16 +161404,16 @@ function searchPredicate(source) {
|
|
|
161389
161404
|
if (key5 === "received" || key5 === "sent") {
|
|
161390
161405
|
const [operator2, term2] = /^(>=|<=|>|<|=)?(.*)$/.exec(value6).slice(1);
|
|
161391
161406
|
const at6 = Date.parse(r2[key5 === "received" ? "receivedDateTime" : "sentDateTime"]);
|
|
161392
|
-
const
|
|
161407
|
+
const parse28 = (v) => {
|
|
161393
161408
|
const ms2 = Date.parse(v);
|
|
161394
161409
|
if (!Number.isFinite(ms2)) throw invalid23("Invalid search date.");
|
|
161395
161410
|
return ms2;
|
|
161396
161411
|
};
|
|
161397
161412
|
if (term2.includes("..")) {
|
|
161398
161413
|
const [a, b] = term2.split("..");
|
|
161399
|
-
return at6 >=
|
|
161414
|
+
return at6 >= parse28(a) && at6 < parse28(b) + 864e5;
|
|
161400
161415
|
}
|
|
161401
|
-
const target6 =
|
|
161416
|
+
const target6 = parse28(term2);
|
|
161402
161417
|
switch (operator2) {
|
|
161403
161418
|
case ">=":
|
|
161404
161419
|
return at6 >= target6;
|
|
@@ -161993,7 +162008,7 @@ async function handle18(c) {
|
|
|
161993
162008
|
}
|
|
161994
162009
|
function microsoftWordTwin() {
|
|
161995
162010
|
const app2 = new Hono3();
|
|
161996
|
-
const
|
|
162011
|
+
const aliases2 = microsoftWordCoverage.flatMap((entry3) => {
|
|
161997
162012
|
if (!entry3.path.startsWith("/v1.0/me/drive")) return [];
|
|
161998
162013
|
const paths3 = [entry3.path];
|
|
161999
162014
|
if (entry3.path.includes("/items/{item-id}")) {
|
|
@@ -162004,7 +162019,7 @@ function microsoftWordTwin() {
|
|
|
162004
162019
|
}
|
|
162005
162020
|
return paths3.flatMap((path9) => [path9, path9.replace("/v1.0/me/drive", "/v1.0/drive"), path9.replace("/v1.0/me/drive", "/v1.0/drives/{drive-id}")]).filter((path9) => path9 !== entry3.path).map((path9) => ({ ...entry3, path: path9, operation: `${entry3.method} ${entry3.path}` }));
|
|
162006
162021
|
});
|
|
162007
|
-
registerOperationRoutes(app2, [...microsoftWordCoverage, ...
|
|
162022
|
+
registerOperationRoutes(app2, [...microsoftWordCoverage, ...aliases2], handle18);
|
|
162008
162023
|
app2.all("*", handle18);
|
|
162009
162024
|
return { name: "microsoft-word", basePath: "", app: app2, migrate: migrate28, seed: seed27, credentials: credentials26, dumpState: dumpState27, actions: {}, checks: {}, coverage: microsoftWordCoverage };
|
|
162010
162025
|
}
|
|
@@ -168893,7 +168908,7 @@ function evaluate2(q2, w2) {
|
|
|
168893
168908
|
comment: { kind: "text", get: (i) => w2.comments(i.id).map((c) => adfToText(c.body)).join("\n") },
|
|
168894
168909
|
text: { kind: "text", get: (i) => [i.summary, adfToText(i.description), ...w2.comments(i.id).map((c) => adfToText(c.body))].join("\n") }
|
|
168895
168910
|
};
|
|
168896
|
-
const
|
|
168911
|
+
const aliases2 = {
|
|
168897
168912
|
issuekey: "key",
|
|
168898
168913
|
id: "key",
|
|
168899
168914
|
issue: "key",
|
|
@@ -168907,7 +168922,7 @@ function evaluate2(q2, w2) {
|
|
|
168907
168922
|
"cf[10016]": "story point estimate"
|
|
168908
168923
|
};
|
|
168909
168924
|
const fieldOf = (name5) => {
|
|
168910
|
-
const n2 = name5.toLowerCase(), key5 =
|
|
168925
|
+
const n2 = name5.toLowerCase(), key5 = aliases2[n2] ?? n2;
|
|
168911
168926
|
if (fields13[key5]) return fields13[key5];
|
|
168912
168927
|
if (UNMODELED2.has(n2) || /^cf\[\d+\]$/.test(n2)) throw new JqlGap(`the JQL field ${name5}`);
|
|
168913
168928
|
throw new JqlError(`Field '${name5}' does not exist or you do not have permission to view it.`);
|
|
@@ -168975,7 +168990,7 @@ function evaluate2(q2, w2) {
|
|
|
168975
168990
|
};
|
|
168976
168991
|
const found = q2.where ? w2.issues.filter((i) => test3(q2.where, i)) : [...w2.issues];
|
|
168977
168992
|
const sortKey = (name5) => {
|
|
168978
|
-
const n2 = name5.toLowerCase(), key5 =
|
|
168993
|
+
const n2 = name5.toLowerCase(), key5 = aliases2[n2] ?? n2;
|
|
168979
168994
|
switch (key5) {
|
|
168980
168995
|
case "key":
|
|
168981
168996
|
return (i) => `${w2.projects.find((p2) => p2.id === i.project_id).key}-${String(i.number).padStart(10, "0")}`;
|
|
@@ -178825,7 +178840,7 @@ var init_routes28 = __esm({
|
|
|
178825
178840
|
|
|
178826
178841
|
// packages/server/src/twins/sentry/search.ts
|
|
178827
178842
|
function parseSearch2(query12, where3) {
|
|
178828
|
-
const
|
|
178843
|
+
const tokens7 = [];
|
|
178829
178844
|
for (let i = 0; i < query12.length; ) {
|
|
178830
178845
|
if (/\s/.test(query12[i])) {
|
|
178831
178846
|
i++;
|
|
@@ -178840,11 +178855,11 @@ function parseSearch2(query12, where3) {
|
|
|
178840
178855
|
else if (!quoted4 && depth <= 0 && /\s/.test(ch)) break;
|
|
178841
178856
|
}
|
|
178842
178857
|
if (quoted4) fail5(400, `Error parsing search query: Missing closing quote in ${query12.slice(i, j)}`);
|
|
178843
|
-
|
|
178858
|
+
tokens7.push(query12.slice(i, j));
|
|
178844
178859
|
i = j;
|
|
178845
178860
|
}
|
|
178846
178861
|
const filters2 = [], text31 = [];
|
|
178847
|
-
for (const token5 of
|
|
178862
|
+
for (const token5 of tokens7) {
|
|
178848
178863
|
if (token5 === "OR" || token5 === "AND") {
|
|
178849
178864
|
if (where3 === "issues") fail5(400, 'Error parsing search query: Boolean statements containing "OR" or "AND" are not supported in this search');
|
|
178850
178865
|
unsupported33("OR and AND in the events query");
|
|
@@ -186486,16 +186501,16 @@ function dateModel(model2) {
|
|
|
186486
186501
|
return parts3;
|
|
186487
186502
|
}
|
|
186488
186503
|
function parseDate2(value6, model2) {
|
|
186489
|
-
const parts3 = dateModel(model2),
|
|
186504
|
+
const parts3 = dateModel(model2), tokens7 = [];
|
|
186490
186505
|
const pattern = parts3.map((p2) => {
|
|
186491
186506
|
if (!p2.token) return escapeRegex3(p2.literal);
|
|
186492
186507
|
if (p2.token === "FM") return "";
|
|
186493
|
-
|
|
186508
|
+
tokens7.push(p2.token);
|
|
186494
186509
|
return p2.token === "YYYY" ? "(\\d{4})" : ["MON", "MONTH"].includes(p2.token) ? "([A-Za-z]+)" : ["AM", "PM"].includes(p2.token) ? "(AM|PM)" : "(\\d{1,2})";
|
|
186495
186510
|
}).join("");
|
|
186496
186511
|
const match3 = new RegExp(`^${pattern}$`, "i").exec(value6.trim());
|
|
186497
186512
|
if (!match3) invalid29("Invalid date value for the format model.");
|
|
186498
|
-
const values3 = new Map(
|
|
186513
|
+
const values3 = new Map(tokens7.map((t, i) => [t, match3[i + 1]]));
|
|
186499
186514
|
if (!values3.has("YYYY") || !values3.has("DD") || !["MM", "MON", "MONTH"].some((t) => values3.has(t))) invalid29("TO_DATE requires year, month and day.", true);
|
|
186500
186515
|
const month = values3.has("MM") ? Number(values3.get("MM")) : MONTHS3.findIndex((m) => values3.has("MON") ? m.slice(0, 3).toLowerCase() === values3.get("MON").toLowerCase() : m.toLowerCase() === values3.get("MONTH").toLowerCase()) + 1;
|
|
186501
186516
|
const date11 = calendar3(Number(values3.get("YYYY")), month, Number(values3.get("DD")));
|
|
@@ -186507,7 +186522,7 @@ function parseDate2(value6, model2) {
|
|
|
186507
186522
|
}
|
|
186508
186523
|
if (hour2 > 23 || minute3 > 59 || second > 59) invalid29("Invalid time value.");
|
|
186509
186524
|
date11.setUTCHours(hour2, minute3, second);
|
|
186510
|
-
return
|
|
186525
|
+
return tokens7.some((t) => t.startsWith("HH") || ["MI", "SS"].includes(t)) ? date11.toISOString() : date11.toISOString().slice(0, 10);
|
|
186511
186526
|
}
|
|
186512
186527
|
function readDate(value6) {
|
|
186513
186528
|
const text31 = String(value6);
|
|
@@ -186595,9 +186610,9 @@ function formatNumber(value6, model2) {
|
|
|
186595
186610
|
}
|
|
186596
186611
|
return (number7 < 0 ? "-" : " ") + result.padStart(spec.integer.length + (spec.decimals ? spec.decimals.length + 1 : 0), " ");
|
|
186597
186612
|
}
|
|
186598
|
-
function like(value6, pattern, ...
|
|
186599
|
-
if (value6 == null || pattern == null ||
|
|
186600
|
-
const esc3 =
|
|
186613
|
+
function like(value6, pattern, ...escape18) {
|
|
186614
|
+
if (value6 == null || pattern == null || escape18.length > 0 && escape18[0] == null) return null;
|
|
186615
|
+
const esc3 = escape18.length ? Array.from(String(escape18[0])) : void 0;
|
|
186601
186616
|
if (esc3 && esc3.length !== 1) invalid29("The LIKE escape character must be one character.");
|
|
186602
186617
|
const mask2 = [], chars = Array.from(String(pattern));
|
|
186603
186618
|
for (let k = 0; k < chars.length; k++) {
|
|
@@ -187295,8 +187310,8 @@ var init_suiteql = __esm({
|
|
|
187295
187310
|
this.need(")");
|
|
187296
187311
|
left = this.node({ kind: "in", arg: left, query: query12, values: query12 ? void 0 : values3, not: negated });
|
|
187297
187312
|
} else if (actual === "like") {
|
|
187298
|
-
const pattern = this.expr(prec + 1),
|
|
187299
|
-
left = this.node({ kind: "like", arg: left, pattern, escape:
|
|
187313
|
+
const pattern = this.expr(prec + 1), escape18 = this.eat("escape") ? this.expr(prec + 1) : void 0;
|
|
187314
|
+
left = this.node({ kind: "like", arg: left, pattern, escape: escape18, not: negated });
|
|
187300
187315
|
} else left = this.node({ kind: "binary", op: actual, left, right: this.expr(prec + 1) });
|
|
187301
187316
|
}
|
|
187302
187317
|
this.depth--;
|
|
@@ -196704,7 +196719,7 @@ var require_extension = __commonJS({
|
|
|
196704
196719
|
if (dest[name5] === void 0) dest[name5] = [elem];
|
|
196705
196720
|
else dest[name5].push(elem);
|
|
196706
196721
|
}
|
|
196707
|
-
function
|
|
196722
|
+
function parse28(header4) {
|
|
196708
196723
|
const offers = /* @__PURE__ */ Object.create(null);
|
|
196709
196724
|
let params10 = /* @__PURE__ */ Object.create(null);
|
|
196710
196725
|
let mustUnescape = false;
|
|
@@ -196844,7 +196859,7 @@ var require_extension = __commonJS({
|
|
|
196844
196859
|
}).join(", ");
|
|
196845
196860
|
}).join(", ");
|
|
196846
196861
|
}
|
|
196847
|
-
module.exports = { format: format2, parse:
|
|
196862
|
+
module.exports = { format: format2, parse: parse28 };
|
|
196848
196863
|
}
|
|
196849
196864
|
});
|
|
196850
196865
|
|
|
@@ -196878,7 +196893,7 @@ var require_websocket = __commonJS({
|
|
|
196878
196893
|
var {
|
|
196879
196894
|
EventTarget: { addEventListener: addEventListener2, removeEventListener }
|
|
196880
196895
|
} = require_event_target();
|
|
196881
|
-
var { format: format2, parse:
|
|
196896
|
+
var { format: format2, parse: parse28 } = require_extension();
|
|
196882
196897
|
var { toBuffer } = require_buffer_util();
|
|
196883
196898
|
var kAborted = /* @__PURE__ */ Symbol("kAborted");
|
|
196884
196899
|
var protocolVersions = [8, 13];
|
|
@@ -197568,7 +197583,7 @@ var require_websocket = __commonJS({
|
|
|
197568
197583
|
}
|
|
197569
197584
|
let extensions;
|
|
197570
197585
|
try {
|
|
197571
|
-
extensions =
|
|
197586
|
+
extensions = parse28(secWebSocketExtensions);
|
|
197572
197587
|
} catch (err2) {
|
|
197573
197588
|
const message8 = "Invalid Sec-WebSocket-Extensions header";
|
|
197574
197589
|
abortHandshake(websocket, socket, message8);
|
|
@@ -197860,7 +197875,7 @@ var require_subprotocol = __commonJS({
|
|
|
197860
197875
|
"node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/subprotocol.js"(exports, module) {
|
|
197861
197876
|
"use strict";
|
|
197862
197877
|
var { tokenChars } = require_validation3();
|
|
197863
|
-
function
|
|
197878
|
+
function parse28(header4) {
|
|
197864
197879
|
const protocols = /* @__PURE__ */ new Set();
|
|
197865
197880
|
let start2 = -1;
|
|
197866
197881
|
let end = -1;
|
|
@@ -197896,7 +197911,7 @@ var require_subprotocol = __commonJS({
|
|
|
197896
197911
|
protocols.add(protocol2);
|
|
197897
197912
|
return protocols;
|
|
197898
197913
|
}
|
|
197899
|
-
module.exports = { parse:
|
|
197914
|
+
module.exports = { parse: parse28 };
|
|
197900
197915
|
}
|
|
197901
197916
|
});
|
|
197902
197917
|
|
|
@@ -202475,8 +202490,8 @@ function noticeOlderServer(clientVersion, tell) {
|
|
|
202475
202490
|
olderServer = { clientVersion, tell, told: false };
|
|
202476
202491
|
}
|
|
202477
202492
|
function compareReleases(a, b) {
|
|
202478
|
-
const
|
|
202479
|
-
const [x, y] = [
|
|
202493
|
+
const parse28 = (version6) => /^(\d+)\.(\d+)\.(\d+)/.exec(version6)?.slice(1).map(Number);
|
|
202494
|
+
const [x, y] = [parse28(a), parse28(b)];
|
|
202480
202495
|
if (x === void 0 || y === void 0 || x.every((part) => part === 0) || y.every((part) => part === 0)) return void 0;
|
|
202481
202496
|
return x[0] - y[0] || x[1] - y[1] || x[2] - y[2];
|
|
202482
202497
|
}
|
|
@@ -203031,7 +203046,7 @@ var require_scan = __commonJS({
|
|
|
203031
203046
|
const length = input5.length - 1;
|
|
203032
203047
|
const scanToEnd = opts.parts === true || opts.tokens === true || opts.scanToEnd === true;
|
|
203033
203048
|
const slashes = [];
|
|
203034
|
-
const
|
|
203049
|
+
const tokens7 = [];
|
|
203035
203050
|
const parts3 = [];
|
|
203036
203051
|
let str5 = input5;
|
|
203037
203052
|
let index = -1;
|
|
@@ -203115,7 +203130,7 @@ var require_scan = __commonJS({
|
|
|
203115
203130
|
}
|
|
203116
203131
|
if (code5 === CHAR_FORWARD_SLASH) {
|
|
203117
203132
|
slashes.push(index);
|
|
203118
|
-
|
|
203133
|
+
tokens7.push(token5);
|
|
203119
203134
|
token5 = { value: "", depth: 0, isGlob: false };
|
|
203120
203135
|
if (finished === true) continue;
|
|
203121
203136
|
if (prev === CHAR_DOT && index === start2 + 1) {
|
|
@@ -203277,9 +203292,9 @@ var require_scan = __commonJS({
|
|
|
203277
203292
|
if (opts.tokens === true) {
|
|
203278
203293
|
state3.maxDepth = 0;
|
|
203279
203294
|
if (!isPathSeparator(code5)) {
|
|
203280
|
-
|
|
203295
|
+
tokens7.push(token5);
|
|
203281
203296
|
}
|
|
203282
|
-
state3.tokens =
|
|
203297
|
+
state3.tokens = tokens7;
|
|
203283
203298
|
}
|
|
203284
203299
|
if (opts.parts === true || opts.tokens === true) {
|
|
203285
203300
|
let prevIndex;
|
|
@@ -203289,13 +203304,13 @@ var require_scan = __commonJS({
|
|
|
203289
203304
|
const value7 = input5.slice(n3, i);
|
|
203290
203305
|
if (opts.tokens) {
|
|
203291
203306
|
if (idx === 0 && start2 !== 0) {
|
|
203292
|
-
|
|
203293
|
-
|
|
203307
|
+
tokens7[idx].isPrefix = true;
|
|
203308
|
+
tokens7[idx].value = prefix2;
|
|
203294
203309
|
} else {
|
|
203295
|
-
|
|
203310
|
+
tokens7[idx].value = value7;
|
|
203296
203311
|
}
|
|
203297
|
-
depth(
|
|
203298
|
-
state3.maxDepth +=
|
|
203312
|
+
depth(tokens7[idx]);
|
|
203313
|
+
state3.maxDepth += tokens7[idx].depth;
|
|
203299
203314
|
}
|
|
203300
203315
|
if (i >= start2) {
|
|
203301
203316
|
parts3.push(value7);
|
|
@@ -203306,9 +203321,9 @@ var require_scan = __commonJS({
|
|
|
203306
203321
|
const value6 = input5.slice(n2);
|
|
203307
203322
|
parts3.push(value6);
|
|
203308
203323
|
if (opts.tokens && prevIndex && prevIndex + 1 < input5.length) {
|
|
203309
|
-
|
|
203310
|
-
depth(
|
|
203311
|
-
state3.maxDepth +=
|
|
203324
|
+
tokens7[tokens7.length - 1].value = value6;
|
|
203325
|
+
depth(tokens7[tokens7.length - 1]);
|
|
203326
|
+
state3.maxDepth += tokens7[tokens7.length - 1].depth;
|
|
203312
203327
|
}
|
|
203313
203328
|
state3.slashes = slashes;
|
|
203314
203329
|
state3.parts = parts3;
|
|
@@ -203572,7 +203587,7 @@ var require_parse2 = __commonJS({
|
|
|
203572
203587
|
}
|
|
203573
203588
|
return { risky: false };
|
|
203574
203589
|
};
|
|
203575
|
-
var
|
|
203590
|
+
var parse28 = (input5, options5) => {
|
|
203576
203591
|
if (typeof input5 !== "string") {
|
|
203577
203592
|
throw new TypeError("Expected a string");
|
|
203578
203593
|
}
|
|
@@ -203584,7 +203599,7 @@ var require_parse2 = __commonJS({
|
|
|
203584
203599
|
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
203585
203600
|
}
|
|
203586
203601
|
const bos = { type: "bos", value: "", output: opts.prepend || "" };
|
|
203587
|
-
const
|
|
203602
|
+
const tokens7 = [bos];
|
|
203588
203603
|
const capture4 = opts.capture ? "" : "?:";
|
|
203589
203604
|
const PLATFORM_CHARS = constants15.globChars(opts.windows);
|
|
203590
203605
|
const EXTGLOB_CHARS = constants15.extglobChars(PLATFORM_CHARS);
|
|
@@ -203629,7 +203644,7 @@ var require_parse2 = __commonJS({
|
|
|
203629
203644
|
parens: 0,
|
|
203630
203645
|
quotes: 0,
|
|
203631
203646
|
globstar: false,
|
|
203632
|
-
tokens:
|
|
203647
|
+
tokens: tokens7
|
|
203633
203648
|
};
|
|
203634
203649
|
input5 = utils.removePrefix(input5, state3);
|
|
203635
203650
|
len = input5.length;
|
|
@@ -203694,7 +203709,7 @@ var require_parse2 = __commonJS({
|
|
|
203694
203709
|
return;
|
|
203695
203710
|
}
|
|
203696
203711
|
tok.prev = prev;
|
|
203697
|
-
|
|
203712
|
+
tokens7.push(tok);
|
|
203698
203713
|
prev = tok;
|
|
203699
203714
|
};
|
|
203700
203715
|
const extglobOpen = (type, value7) => {
|
|
@@ -203703,7 +203718,7 @@ var require_parse2 = __commonJS({
|
|
|
203703
203718
|
token5.parens = state3.parens;
|
|
203704
203719
|
token5.output = state3.output;
|
|
203705
203720
|
token5.startIndex = state3.index;
|
|
203706
|
-
token5.tokensIndex =
|
|
203721
|
+
token5.tokensIndex = tokens7.length;
|
|
203707
203722
|
const output2 = (opts.capture ? "(" : "") + token5.open;
|
|
203708
203723
|
increment("parens");
|
|
203709
203724
|
push({ type, value: value7, output: state3.output ? "" : ONE_CHAR });
|
|
@@ -203716,14 +203731,14 @@ var require_parse2 = __commonJS({
|
|
|
203716
203731
|
const analysis = analyzeRepeatedExtglob(body8, opts);
|
|
203717
203732
|
if ((token5.type === "plus" || token5.type === "star") && analysis.risky) {
|
|
203718
203733
|
const safeOutput = analysis.safeOutput ? (token5.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : void 0;
|
|
203719
|
-
const open16 =
|
|
203734
|
+
const open16 = tokens7[token5.tokensIndex];
|
|
203720
203735
|
open16.type = "text";
|
|
203721
203736
|
open16.value = literal4;
|
|
203722
203737
|
open16.output = safeOutput || utils.escapeRegex(literal4);
|
|
203723
|
-
for (let i = token5.tokensIndex + 1; i <
|
|
203724
|
-
|
|
203725
|
-
|
|
203726
|
-
delete
|
|
203738
|
+
for (let i = token5.tokensIndex + 1; i < tokens7.length; i++) {
|
|
203739
|
+
tokens7[i].value = "";
|
|
203740
|
+
tokens7[i].output = "";
|
|
203741
|
+
delete tokens7[i].suffix;
|
|
203727
203742
|
}
|
|
203728
203743
|
state3.output = token5.output + open16.output;
|
|
203729
203744
|
state3.backtrack = true;
|
|
@@ -203742,7 +203757,7 @@ var require_parse2 = __commonJS({
|
|
|
203742
203757
|
output2 = token5.close = `)$))${extglobStar}`;
|
|
203743
203758
|
}
|
|
203744
203759
|
if (token5.inner.includes("*") && (rest2 = remaining()) && /^\.[^\\/.]+$/.test(rest2)) {
|
|
203745
|
-
const expression4 =
|
|
203760
|
+
const expression4 = parse28(rest2, { ...options5, fastpaths: false }).output;
|
|
203746
203761
|
output2 = token5.close = `)${expression4})${extglobStar})`;
|
|
203747
203762
|
}
|
|
203748
203763
|
if (token5.prev.type === "bos") {
|
|
@@ -203846,7 +203861,7 @@ var require_parse2 = __commonJS({
|
|
|
203846
203861
|
prev.value = pre + posix5;
|
|
203847
203862
|
state3.backtrack = true;
|
|
203848
203863
|
advance();
|
|
203849
|
-
if (!bos.output &&
|
|
203864
|
+
if (!bos.output && tokens7.indexOf(prev) === 1) {
|
|
203850
203865
|
bos.output = ONE_CHAR;
|
|
203851
203866
|
}
|
|
203852
203867
|
continue;
|
|
@@ -203964,10 +203979,10 @@ var require_parse2 = __commonJS({
|
|
|
203964
203979
|
}
|
|
203965
203980
|
let output2 = ")";
|
|
203966
203981
|
if (brace.dots === true) {
|
|
203967
|
-
const arr =
|
|
203982
|
+
const arr = tokens7.slice();
|
|
203968
203983
|
const range3 = [];
|
|
203969
203984
|
for (let i = arr.length - 1; i >= 0; i--) {
|
|
203970
|
-
|
|
203985
|
+
tokens7.pop();
|
|
203971
203986
|
if (arr[i].type === "brace") {
|
|
203972
203987
|
break;
|
|
203973
203988
|
}
|
|
@@ -204015,7 +204030,7 @@ var require_parse2 = __commonJS({
|
|
|
204015
204030
|
state3.start = state3.index + 1;
|
|
204016
204031
|
state3.consumed = "";
|
|
204017
204032
|
state3.output = "";
|
|
204018
|
-
|
|
204033
|
+
tokens7.pop();
|
|
204019
204034
|
prev = bos;
|
|
204020
204035
|
continue;
|
|
204021
204036
|
}
|
|
@@ -204265,7 +204280,7 @@ var require_parse2 = __commonJS({
|
|
|
204265
204280
|
}
|
|
204266
204281
|
return state3;
|
|
204267
204282
|
};
|
|
204268
|
-
|
|
204283
|
+
parse28.fastpaths = (input5, options5) => {
|
|
204269
204284
|
const opts = { ...options5 };
|
|
204270
204285
|
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
204271
204286
|
const len = input5.length;
|
|
@@ -204330,7 +204345,7 @@ var require_parse2 = __commonJS({
|
|
|
204330
204345
|
}
|
|
204331
204346
|
return source;
|
|
204332
204347
|
};
|
|
204333
|
-
module.exports =
|
|
204348
|
+
module.exports = parse28;
|
|
204334
204349
|
}
|
|
204335
204350
|
});
|
|
204336
204351
|
|
|
@@ -204339,7 +204354,7 @@ var require_picomatch = __commonJS({
|
|
|
204339
204354
|
"node_modules/.pnpm/picomatch@4.0.7/node_modules/picomatch/lib/picomatch.js"(exports, module) {
|
|
204340
204355
|
"use strict";
|
|
204341
204356
|
var scan2 = require_scan();
|
|
204342
|
-
var
|
|
204357
|
+
var parse28 = require_parse2();
|
|
204343
204358
|
var utils = require_utils2();
|
|
204344
204359
|
var constants15 = require_constants3();
|
|
204345
204360
|
var isObject8 = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
@@ -204427,7 +204442,7 @@ var require_picomatch = __commonJS({
|
|
|
204427
204442
|
picomatch2.isMatch = (str5, patterns, options5) => picomatch2(patterns, options5)(str5);
|
|
204428
204443
|
picomatch2.parse = (pattern, options5) => {
|
|
204429
204444
|
if (Array.isArray(pattern)) return pattern.map((p2) => picomatch2.parse(p2, options5));
|
|
204430
|
-
return
|
|
204445
|
+
return parse28(pattern, { ...options5, fastpaths: false });
|
|
204431
204446
|
};
|
|
204432
204447
|
picomatch2.scan = (input5, options5) => scan2(input5, options5);
|
|
204433
204448
|
picomatch2.compileRe = (state3, options5, returnOutput = false, returnState = false) => {
|
|
@@ -204453,10 +204468,10 @@ var require_picomatch = __commonJS({
|
|
|
204453
204468
|
}
|
|
204454
204469
|
let parsed5 = { negated: false, fastpaths: true };
|
|
204455
204470
|
if (options5.fastpaths !== false && (input5[0] === "." || input5[0] === "*")) {
|
|
204456
|
-
parsed5.output =
|
|
204471
|
+
parsed5.output = parse28.fastpaths(input5, options5);
|
|
204457
204472
|
}
|
|
204458
204473
|
if (!parsed5.output) {
|
|
204459
|
-
parsed5 =
|
|
204474
|
+
parsed5 = parse28(input5, options5);
|
|
204460
204475
|
}
|
|
204461
204476
|
return picomatch2.compileRe(parsed5, options5, returnOutput, returnState);
|
|
204462
204477
|
};
|
|
@@ -210234,9 +210249,9 @@ var init_EventStream = __esm({
|
|
|
210234
210249
|
if (typeof value6 === "object" && value6 !== null && sdkOwnedBufferedEventArguments.has(value6)) {
|
|
210235
210250
|
const argumentsTuple = value6;
|
|
210236
210251
|
for (let index = 0; index < argumentsTuple.length; index += 1) {
|
|
210237
|
-
const
|
|
210238
|
-
if (typeof
|
|
210239
|
-
argumentsTuple[index] = bufferedJSONParse(bufferedJSONStringify(
|
|
210252
|
+
const argument2 = argumentsTuple[index];
|
|
210253
|
+
if (typeof argument2 === "string") {
|
|
210254
|
+
argumentsTuple[index] = bufferedJSONParse(bufferedJSONStringify(argument2));
|
|
210240
210255
|
}
|
|
210241
210256
|
}
|
|
210242
210257
|
}
|
|
@@ -211083,21 +211098,21 @@ var init_parser2 = __esm({
|
|
|
211083
211098
|
};
|
|
211084
211099
|
const parseStr = () => {
|
|
211085
211100
|
const start2 = index;
|
|
211086
|
-
let
|
|
211101
|
+
let escape18 = false;
|
|
211087
211102
|
index++;
|
|
211088
|
-
while (index < length && (jsonString[index] !== '"' ||
|
|
211089
|
-
|
|
211103
|
+
while (index < length && (jsonString[index] !== '"' || escape18 && jsonString[index - 1] === "\\")) {
|
|
211104
|
+
escape18 = jsonString[index] === "\\" ? !escape18 : false;
|
|
211090
211105
|
index++;
|
|
211091
211106
|
}
|
|
211092
211107
|
if (jsonString.charAt(index) === '"') {
|
|
211093
211108
|
try {
|
|
211094
|
-
return JSON.parse(jsonString.substring(start2, ++index - Number(
|
|
211109
|
+
return JSON.parse(jsonString.substring(start2, ++index - Number(escape18)));
|
|
211095
211110
|
} catch (e) {
|
|
211096
211111
|
throwMalformedError(String(e));
|
|
211097
211112
|
}
|
|
211098
211113
|
} else if (Allow.STR & allow) {
|
|
211099
211114
|
try {
|
|
211100
|
-
return JSON.parse(jsonString.substring(start2, index - Number(
|
|
211115
|
+
return JSON.parse(jsonString.substring(start2, index - Number(escape18)) + '"');
|
|
211101
211116
|
} catch {
|
|
211102
211117
|
return JSON.parse(jsonString.substring(start2, jsonString.lastIndexOf("\\")) + '"');
|
|
211103
211118
|
}
|
|
@@ -219023,8 +219038,8 @@ function agentFormatParser(format2) {
|
|
|
219023
219038
|
if (ownJSONValue(format2, "type") !== "json_schema" || !schema4) {
|
|
219024
219039
|
throw new OpenAIError("Typed agent formats require own enumerable type and schema data properties");
|
|
219025
219040
|
}
|
|
219026
|
-
const
|
|
219027
|
-
return { type: "json_schema", schema: schema4, $parseRaw: (text31) =>
|
|
219041
|
+
const parse28 = descriptor3.value;
|
|
219042
|
+
return { type: "json_schema", schema: schema4, $parseRaw: (text31) => parse28.call(format2, text31) };
|
|
219028
219043
|
}
|
|
219029
219044
|
function snapshotJSONProperty(object28, key5, capture4 = (value6) => value6) {
|
|
219030
219045
|
const descriptor3 = Object.getOwnPropertyDescriptor(object28, key5);
|
|
@@ -228617,17 +228632,17 @@ var init_client = __esm({
|
|
|
228617
228632
|
const request2 = authentication instanceof X509WorkloadIdentityAuth ? Promise.resolve(options5).then((resolved) => authentication.runRequest(() => this.makeRequest(resolved, remainingRetries, void 0), this)) : this.makeRequest(options5, remainingRetries, void 0);
|
|
228618
228633
|
return this.responsePromise(request2);
|
|
228619
228634
|
}
|
|
228620
|
-
responsePromise(request2,
|
|
228635
|
+
responsePromise(request2, parse28 = (client2, props) => this.parseResponseWithTimeout(client2, props)) {
|
|
228621
228636
|
const promise3 = new APIPromise(this, request2, (client2, props) => {
|
|
228622
228637
|
const resume = __classPrivateFieldGet(this, _OpenAI_responseAttempts, "f").get(props.controller)?.continueRequest;
|
|
228623
|
-
return resume ? resume(() =>
|
|
228638
|
+
return resume ? resume(() => parse28(client2, props)) : parse28(client2, props);
|
|
228624
228639
|
});
|
|
228625
228640
|
promise3.withResponse = async () => {
|
|
228626
228641
|
const data7 = await promise3;
|
|
228627
228642
|
const { response: response6 } = await request2;
|
|
228628
228643
|
return { data: data7, response: response6, request_id: response6.headers.get("x-request-id") };
|
|
228629
228644
|
};
|
|
228630
|
-
promise3._thenUnwrap = (transform3) => this.responsePromise(request2, async (client2, props) => addRequestID(transform3(await
|
|
228645
|
+
promise3._thenUnwrap = (transform3) => this.responsePromise(request2, async (client2, props) => addRequestID(transform3(await parse28(client2, props), props), props.response));
|
|
228631
228646
|
return promise3;
|
|
228632
228647
|
}
|
|
228633
228648
|
async parseResponseWithTimeout(client2, props) {
|
|
@@ -230685,9 +230700,9 @@ function validateEditedTest(edit) {
|
|
|
230685
230700
|
return edit;
|
|
230686
230701
|
}
|
|
230687
230702
|
function validateRoutes(routes2 = {}) {
|
|
230688
|
-
if (!routes2 || typeof routes2 !== "object" || Array.isArray(routes2) || Object.
|
|
230689
|
-
throw new CloudError(400, "USAGE",
|
|
230690
|
-
return Object.
|
|
230703
|
+
if (!routes2 || typeof routes2 !== "object" || Array.isArray(routes2) || Object.entries(routes2).some(([key5, value6]) => !["quickbooks", "netsuite"].includes(key5) || value6 !== "composio"))
|
|
230704
|
+
throw new CloudError(400, "USAGE", "routes must map quickbooks and/or netsuite to composio.");
|
|
230705
|
+
return Object.fromEntries(["quickbooks", "netsuite"].filter((key5) => Object.hasOwn(routes2, key5)).map((key5) => [key5, "composio"]));
|
|
230691
230706
|
}
|
|
230692
230707
|
function validateSpec(spec) {
|
|
230693
230708
|
object24(spec, ["options", "cases", "imageDigest", "caps", "secretNames", "modelHosts", "agentId", "routes"], "job spec");
|
|
@@ -230924,6 +230939,14 @@ var init_jobs_contract = __esm({
|
|
|
230924
230939
|
|
|
230925
230940
|
// backend/src/execution/composio.ts
|
|
230926
230941
|
import { timingSafeEqual as timingSafeEqual11 } from "node:crypto";
|
|
230942
|
+
function noWorldMessage(toolkit) {
|
|
230943
|
+
const name5 = toolkit === "quickbooks" ? "QuickBooks" : "NetSuite";
|
|
230944
|
+
return `This test's world has no ${name5}. Add ${name5} to the test's world or run this call in a test whose world has it.`;
|
|
230945
|
+
}
|
|
230946
|
+
function requireWorld(name5, route15) {
|
|
230947
|
+
const toolkit = name5.startsWith("QUICKBOOKS_") ? "quickbooks" : name5.startsWith("NETSUITE_") ? "netsuite" : void 0;
|
|
230948
|
+
if (toolkit && (route15.toolkits ?? { quickbooks: "composio" })[toolkit] && !activeComposioToolkits(route15)[toolkit]) throw new RouteRefusal("NO_WORLD", toolkit);
|
|
230949
|
+
}
|
|
230927
230950
|
function parsed3(schema4, value6) {
|
|
230928
230951
|
const result = schema4.safeParse(value6);
|
|
230929
230952
|
return result.success ? result.data : refuse("SCHEMA");
|
|
@@ -230937,12 +230960,16 @@ function jsonBody3(body8, contentType) {
|
|
|
230937
230960
|
return refuse("JSON");
|
|
230938
230961
|
}
|
|
230939
230962
|
}
|
|
230940
|
-
function toolArguments(name5, value6 = {}, metaOnly = false) {
|
|
230963
|
+
function toolArguments(route15, name5, value6 = {}, metaOnly = false) {
|
|
230964
|
+
requireWorld(name5, route15);
|
|
230965
|
+
if (name5.startsWith("NETSUITE_")) refuse("NETSUITE_TOOL");
|
|
230941
230966
|
if (!meta5.has(name5) && (metaOnly || !quickbooks.test(name5))) refuse(name5.startsWith("COMPOSIO_") || metaOnly ? "META_TOOL" : "TOOL");
|
|
230942
230967
|
const { account: _account, ...args } = value6;
|
|
230943
230968
|
if (name5 === multi) {
|
|
230944
230969
|
const items2 = parsed3(external_exports.array(external_exports.object({ tool_slug: external_exports.string(), arguments: record26.optional() }).passthrough()).min(1), args.tools);
|
|
230970
|
+
for (const item2 of items2) requireWorld(item2.tool_slug, route15);
|
|
230945
230971
|
args.tools = items2.map(({ account: _account2, connected_account_id: _id, user_id: _user, ...item2 }) => {
|
|
230972
|
+
if (item2.tool_slug.startsWith("NETSUITE_")) refuse("NETSUITE_TOOL");
|
|
230946
230973
|
if (!quickbooks.test(item2.tool_slug)) refuse(item2.tool_slug.startsWith("COMPOSIO_") ? "META_TOOL" : "TOOL");
|
|
230947
230974
|
return item2;
|
|
230948
230975
|
});
|
|
@@ -230968,18 +230995,32 @@ function validateComposio(method2, target6, apiKey, body8, contentType, route15,
|
|
|
230968
230995
|
if (typeof apiKey !== "string" || !route15.agentKey || Buffer.byteLength(apiKey) !== Buffer.byteLength(route15.agentKey) || !timingSafeEqual11(Buffer.from(apiKey), Buffer.from(route15.agentKey))) refuse("API_KEY");
|
|
230969
230996
|
if (!target6.startsWith("/") || target6.length > 8192 || target6.includes("#") || /[%\\\x00-\x20\x7f#]/.test(target6.split("?")[0]) || target6.includes("//") || target6.split("?")[0].split("/").some((part) => part === "." || part === "..")) refuse("PATH");
|
|
230970
230997
|
const url4 = new URL(target6, "https://backend.composio.dev");
|
|
230971
|
-
const
|
|
230998
|
+
const qb = !!activeComposioToolkits(route15).quickbooks;
|
|
230999
|
+
const base6 = { toolkit: qb ? "quickbooks" : "netsuite", op: "catalog", via: composioVia(target6), target: target6 };
|
|
230972
231000
|
const noQuery = () => {
|
|
230973
231001
|
if (url4.search) refuse("QUERY");
|
|
230974
231002
|
};
|
|
230975
231003
|
const empty3 = () => {
|
|
230976
231004
|
if (body8.length) refuse("SCHEMA");
|
|
230977
231005
|
};
|
|
231006
|
+
if (/^\/api\/v3(?:\.1)?\/tools\/execute\/COMPOSIO_MULTI_EXECUTE_TOOL$/.test(url4.pathname)) {
|
|
231007
|
+
if (method2 !== "POST") refuse("METHOD");
|
|
231008
|
+
noQuery();
|
|
231009
|
+
const value6 = parsed3(bodySchema, jsonBody3(body8, contentType));
|
|
231010
|
+
toolArguments(route15, multi, value6.arguments);
|
|
231011
|
+
refuse("META_TOOL");
|
|
231012
|
+
}
|
|
230978
231013
|
const match3 = execution.exec(url4.pathname);
|
|
230979
231014
|
if (match3) {
|
|
230980
231015
|
if (method2 !== "POST") refuse("METHOD");
|
|
230981
231016
|
noQuery();
|
|
230982
231017
|
const value6 = parsed3(bodySchema, jsonBody3(body8, contentType));
|
|
231018
|
+
requireWorld(match3[1], route15);
|
|
231019
|
+
if (match3[1].startsWith("NETSUITE_")) {
|
|
231020
|
+
if (!route15.netsuite || match3[1] !== "NETSUITE_RUN_SUITEQL_QUERY") refuse("NETSUITE_TOOL");
|
|
231021
|
+
return { ...base6, toolkit: "netsuite", op: "execute", local: "netsuite", slug: match3[1], arguments: value6.arguments ?? {} };
|
|
231022
|
+
}
|
|
231023
|
+
if (!qb) refuse("TOOL");
|
|
230983
231024
|
const { connected_account_id: _id, custom_connection_data: _data, entity_id: _entity, custom_auth_params: _auth, ...kept } = value6;
|
|
230984
231025
|
return { ...base6, op: "execute", slug: match3[1], body: bytes3({ ...kept, user_id: route15.user, custom_auth_params: {
|
|
230985
231026
|
base_url: route15.publicUrl,
|
|
@@ -230997,11 +231038,13 @@ function validateComposio(method2, target6, apiKey, body8, contentType, route15,
|
|
|
230997
231038
|
if (!["initialize", "notifications/initialized", "notifications/cancelled", "ping", "tools/list", "tools/call"].includes(value6.method)) refuse("MCP_METHOD");
|
|
230998
231039
|
if (value6.method === "tools/call") {
|
|
230999
231040
|
const params10 = parsed3(external_exports.strictObject({ name: external_exports.string(), arguments: record26.optional(), account: external_exports.unknown().optional(), _meta: record26.optional() }), value6.params);
|
|
231000
|
-
const call4 = toolArguments(params10.name, params10.arguments);
|
|
231041
|
+
const call4 = toolArguments(route15, params10.name, params10.arguments);
|
|
231042
|
+
if (!qb) refuse("SESSION_ENDPOINT");
|
|
231001
231043
|
const { account: _account, ...kept } = params10;
|
|
231002
231044
|
value6.params = { ...kept, arguments: call4.arguments };
|
|
231003
231045
|
return { ...base6, op: call4.op, slug: params10.name, headers: forwarded2, body: bytes3(value6) };
|
|
231004
231046
|
}
|
|
231047
|
+
if (!qb) refuse("SESSION_ENDPOINT");
|
|
231005
231048
|
return { ...base6, headers: forwarded2, body: bytes3(value6) };
|
|
231006
231049
|
}
|
|
231007
231050
|
const session2 = /^\/api\/v3(?:\.1)?\/tool_router\/session(?:\/([^/]+)(.*))?$/.exec(url4.pathname);
|
|
@@ -231012,13 +231055,14 @@ function validateComposio(method2, target6, apiKey, body8, contentType, route15,
|
|
|
231012
231055
|
noQuery();
|
|
231013
231056
|
const value7 = parsed3(sessionSchema, jsonBody3(body8, contentType));
|
|
231014
231057
|
const narrowed = /* @__PURE__ */ new Set();
|
|
231058
|
+
const declared = route15.toolkits ?? { quickbooks: "composio" };
|
|
231015
231059
|
const note2 = (name6) => {
|
|
231016
|
-
if (name6.toLowerCase()
|
|
231060
|
+
if (!(name6.toLowerCase() === "quickbooks" && declared.quickbooks) && !(name6.toLowerCase() === "netsuite" && declared.netsuite)) narrowed.add(name6);
|
|
231017
231061
|
};
|
|
231018
231062
|
const toolkitApprovals = slugList.safeParse(value7.toolkits?.require_approval);
|
|
231019
231063
|
for (const name6 of [...Object.keys(value7.auth_configs ?? {}), ...Object.keys(value7.connected_accounts ?? {}), ...Object.keys(value7.tools ?? {}), ...value7.toolkits?.enable ?? [], ...toolkitApprovals.success ? toolkitApprovals.data : []]) note2(name6);
|
|
231020
231064
|
const keepSlugs = (slugs2) => slugs2.filter((name6) => {
|
|
231021
|
-
if (quickbooks.test(name6)) return true;
|
|
231065
|
+
if (qb && quickbooks.test(name6)) return true;
|
|
231022
231066
|
const toolkit2 = /^([A-Z0-9]+)_/.exec(name6)?.[1]?.toLowerCase();
|
|
231023
231067
|
if (toolkit2) note2(toolkit2);
|
|
231024
231068
|
return false;
|
|
@@ -231040,6 +231084,7 @@ function validateComposio(method2, target6, apiKey, body8, contentType, route15,
|
|
|
231040
231084
|
const preload = listed2.success ? { tools: listed2.data.tools === "all" ? "all" : keepSlugs(listed2.data.tools) } : void 0;
|
|
231041
231085
|
const search10 = switchOf(value7.search, "enable"), multiExecute = switchOf(value7.execute, "enable_multi_execute");
|
|
231042
231086
|
const approveToolkit = toolkitApprovals.success && toolkitApprovals.data.some((name6) => name6.toLowerCase() === "quickbooks");
|
|
231087
|
+
if (!qb) return { ...base6, local: "session", response: "session-create", narrowed: [...narrowed] };
|
|
231043
231088
|
return { ...base6, connection: "session", response: "session-create", narrowed: [...narrowed], body: bytes3({
|
|
231044
231089
|
user_id: route15.user,
|
|
231045
231090
|
toolkits: { enable: ["quickbooks"], ...approveToolkit && { require_approval: ["quickbooks"] } },
|
|
@@ -231057,12 +231102,13 @@ function validateComposio(method2, target6, apiKey, body8, contentType, route15,
|
|
|
231057
231102
|
if (!identifier4.test(sid) || !route15.sessions.has(sid)) refuse("SESSION");
|
|
231058
231103
|
if (method2 === "PATCH") refuse("SESSION_MUTATION");
|
|
231059
231104
|
if (!["", "/tools", "/toolkits", "/execute", "/execute_meta", "/search"].includes(suffix)) refuse("SESSION_ENDPOINT");
|
|
231105
|
+
if (!qb && suffix !== "" && suffix !== "/execute" && suffix !== "/execute_meta") refuse("SESSION_ENDPOINT");
|
|
231060
231106
|
if (suffix === "" || suffix === "/tools" || suffix === "/toolkits") {
|
|
231061
231107
|
if (method2 !== "GET" && !(suffix === "" && method2 === "DELETE")) refuse("METHOD");
|
|
231062
231108
|
empty3();
|
|
231063
231109
|
if (suffix === "") {
|
|
231064
231110
|
noQuery();
|
|
231065
|
-
return { ...base6, response: method2 === "GET" ? "session-get" : "session-delete", sessionId: sid };
|
|
231111
|
+
return { ...base6, ...!qb && { local: "session" }, response: method2 === "GET" ? "session-get" : "session-delete", sessionId: sid };
|
|
231066
231112
|
}
|
|
231067
231113
|
return base6;
|
|
231068
231114
|
}
|
|
@@ -231073,12 +231119,19 @@ function validateComposio(method2, target6, apiKey, body8, contentType, route15,
|
|
|
231073
231119
|
const extra2 = { input_responses: external_exports.unknown().optional(), request_state: external_exports.unknown().optional(), experimental: external_exports.unknown().optional() };
|
|
231074
231120
|
const call4 = suffix === "/execute" ? parsed3(external_exports.strictObject({ tool_slug: external_exports.string(), arguments: record26.optional(), account: external_exports.unknown().optional(), enable_auto_workbench_offload: external_exports.boolean().optional(), ...extra2 }), value6) : parsed3(external_exports.strictObject({ slug: external_exports.string(), arguments: record26.optional(), ...extra2 }), value6);
|
|
231075
231121
|
const name5 = "tool_slug" in call4 ? call4.tool_slug : call4.slug;
|
|
231076
|
-
|
|
231122
|
+
requireWorld(name5, route15);
|
|
231123
|
+
if (name5.startsWith("NETSUITE_")) {
|
|
231124
|
+
if (!route15.netsuite || name5 !== "NETSUITE_RUN_SUITEQL_QUERY" || suffix !== "/execute") refuse("NETSUITE_TOOL");
|
|
231125
|
+
return { ...base6, toolkit: "netsuite", op: "execute", local: "netsuite", slug: name5, arguments: call4.arguments ?? {} };
|
|
231126
|
+
}
|
|
231127
|
+
const checked = toolArguments(route15, name5, call4.arguments, suffix === "/execute_meta");
|
|
231128
|
+
if (!qb) refuse("SESSION_ENDPOINT");
|
|
231077
231129
|
const kept = { ...call4.input_responses !== void 0 && { input_responses: call4.input_responses }, ...call4.request_state !== void 0 && { request_state: call4.request_state } };
|
|
231078
231130
|
return { ...base6, op: checked.op, slug: name5, body: bytes3(suffix === "/execute" ? { tool_slug: name5, arguments: checked.arguments, ..."enable_auto_workbench_offload" in call4 && { enable_auto_workbench_offload: false }, ...kept } : { slug: name5, arguments: checked.arguments, ...kept }) };
|
|
231079
231131
|
}
|
|
231080
231132
|
const accounts2 = /^\/api\/v3(?:\.1)?\/connected_accounts(?:\/(.*))?$/.exec(url4.pathname);
|
|
231081
231133
|
if (accounts2) {
|
|
231134
|
+
if (!qb) refuse("ACCOUNT");
|
|
231082
231135
|
if (method2 !== "GET") refuse("ACCOUNT");
|
|
231083
231136
|
empty3();
|
|
231084
231137
|
const id14 = accounts2[1];
|
|
@@ -231095,6 +231148,16 @@ function validateComposio(method2, target6, apiKey, body8, contentType, route15,
|
|
|
231095
231148
|
}
|
|
231096
231149
|
return { ...base6, connection: "accounts", target: url4.pathname + "?" + query12.toString() };
|
|
231097
231150
|
}
|
|
231151
|
+
const schema4 = /^\/api\/v3(?:\.1)?\/tools\/(NETSUITE_RUN_SUITEQL_QUERY)$/.exec(url4.pathname);
|
|
231152
|
+
if (schema4) {
|
|
231153
|
+
requireWorld(schema4[1], route15);
|
|
231154
|
+
if (!route15.netsuite) refuse("NETSUITE_TOOL");
|
|
231155
|
+
if (method2 !== "GET") refuse("METHOD");
|
|
231156
|
+
empty3();
|
|
231157
|
+
return { ...base6, toolkit: "netsuite", slug: schema4[1] };
|
|
231158
|
+
}
|
|
231159
|
+
if (/NETSUITE_/i.test(url4.pathname)) refuse("NETSUITE_TOOL");
|
|
231160
|
+
if (!qb) refuse("SESSION_ENDPOINT");
|
|
231098
231161
|
const tool = catalogTool.exec(url4.pathname), toolkit = /^\/api\/v3(?:\.1)?\/toolkits\/quickbooks$/i.test(url4.pathname);
|
|
231099
231162
|
const list19 = /^\/api\/v3(?:\.1)?\/tools$/.test(url4.pathname);
|
|
231100
231163
|
if (!tool && !toolkit && !list19) refuse("PATH");
|
|
@@ -231133,27 +231196,114 @@ async function readComposioBody(req) {
|
|
|
231133
231196
|
}
|
|
231134
231197
|
return Buffer.concat(chunks);
|
|
231135
231198
|
}
|
|
231136
|
-
function refuseComposio(res, reason2) {
|
|
231199
|
+
function refuseComposio(res, reason2, toolkit) {
|
|
231137
231200
|
res.writeHead(403, { "content-type": "application/json", connection: "close" });
|
|
231138
|
-
res.end(JSON.stringify({ error: { code: "COMPOSIO_ROUTE_REFUSED", reason: reason2, message:
|
|
231201
|
+
res.end(JSON.stringify({ error: { code: "COMPOSIO_ROUTE_REFUSED", reason: reason2, message: new RouteRefusal(reason2, toolkit).message } }));
|
|
231202
|
+
}
|
|
231203
|
+
function nextRouteId(route15, kind2) {
|
|
231204
|
+
let ids2 = routeIds.get(route15);
|
|
231205
|
+
if (!ids2) {
|
|
231206
|
+
ids2 = new IdStream(route15.attemptId, "composio-route", memoryCounters());
|
|
231207
|
+
routeIds.set(route15, ids2);
|
|
231208
|
+
}
|
|
231209
|
+
return `${kind2}_${ids2.fork(kind2).alnumUpper(16)}`;
|
|
231210
|
+
}
|
|
231211
|
+
async function executeLocalComposio(call4, route15, origin, fetcher = fetch, signal) {
|
|
231212
|
+
if (call4.local === "session") {
|
|
231213
|
+
route15.narrowed(call4.narrowed ?? []);
|
|
231214
|
+
if (call4.response === "session-delete") {
|
|
231215
|
+
route15.sessions.delete(call4.sessionId);
|
|
231216
|
+
return { status: 204 };
|
|
231217
|
+
}
|
|
231218
|
+
const id14 = call4.sessionId ?? nextRouteId(route15, "trs");
|
|
231219
|
+
if (call4.response === "session-create") route15.sessions.add(id14);
|
|
231220
|
+
return { status: call4.response === "session-create" ? 201 : 200, body: {
|
|
231221
|
+
session_id: id14,
|
|
231222
|
+
mcp: { type: "http", url: `${origin}/_tool/composio/tool_router/${id14}/mcp` },
|
|
231223
|
+
tool_router_tools: [],
|
|
231224
|
+
config_version: 1,
|
|
231225
|
+
config: {
|
|
231226
|
+
user_id: route15.user,
|
|
231227
|
+
toolkits: { enabled: ["netsuite"] },
|
|
231228
|
+
preload: { tools: [] },
|
|
231229
|
+
search: { enable: false },
|
|
231230
|
+
execute: { enable_multi_execute: false },
|
|
231231
|
+
manage_connections: { enabled: false },
|
|
231232
|
+
multi_account: { enable: false },
|
|
231233
|
+
workbench: { enable: false }
|
|
231234
|
+
}
|
|
231235
|
+
} };
|
|
231236
|
+
}
|
|
231237
|
+
const log_id = nextRouteId(route15, "log");
|
|
231238
|
+
const envelope = (data7, error65, reached2) => ({ status: 200, reached: reached2, body: {
|
|
231239
|
+
data: data7,
|
|
231240
|
+
error: error65,
|
|
231241
|
+
log_id,
|
|
231242
|
+
...call4.via === "session" ? { result_type: error65 === null ? "completed" : "failed" } : { successful: error65 === null }
|
|
231243
|
+
} });
|
|
231244
|
+
const failure6 = (message8, status_code, reached2 = false) => {
|
|
231245
|
+
for (const secret of [route15.agentKey, route15.apiKey, route15.token, route15.netsuite?.token]) if (secret) message8 = message8.replaceAll(secret, "[redacted]");
|
|
231246
|
+
return envelope({ message: message8, status_code }, message8, reached2);
|
|
231247
|
+
};
|
|
231248
|
+
const args = suiteqlArguments.safeParse(call4.arguments ?? {});
|
|
231249
|
+
if (!args.success) return { ...failure6(call4.arguments?.q === void 0 ? "Invalid request data provided\n- Following fields are missing: {'q'}" : "Invalid request data provided: q must be a string, limit an integer >= 1, and offset an integer >= 0; use only q, limit and offset.", 400), invalidArguments: true };
|
|
231250
|
+
if (args.data.limit !== void 0 && args.data.offset !== void 0 && args.data.offset % args.data.limit !== 0)
|
|
231251
|
+
return { ...failure6("Invalid request data provided: offset must be a multiple of limit.", 400), invalidArguments: true };
|
|
231252
|
+
const connection4 = route15.netsuite;
|
|
231253
|
+
const url4 = new URL(connection4.url.replace(/\/$/, "") + "/services/rest/query/v1/suiteql");
|
|
231254
|
+
for (const key5 of ["limit", "offset"]) if (args.data[key5] !== void 0) url4.searchParams.set(key5, String(args.data[key5]));
|
|
231255
|
+
let reached = false;
|
|
231256
|
+
try {
|
|
231257
|
+
const reply6 = await fetcher(url4, {
|
|
231258
|
+
method: "POST",
|
|
231259
|
+
redirect: "error",
|
|
231260
|
+
signal: AbortSignal.any([AbortSignal.timeout(55e3), ...signal ? [signal] : []]),
|
|
231261
|
+
headers: { authorization: `Bearer ${connection4.token}`, "content-type": "application/json", accept: "application/json", prefer: "transient" },
|
|
231262
|
+
body: JSON.stringify({ q: args.data.q })
|
|
231263
|
+
});
|
|
231264
|
+
reached = true;
|
|
231265
|
+
const chunks = [];
|
|
231266
|
+
let size2 = 0;
|
|
231267
|
+
if (Number(reply6.headers.get("content-length") ?? 0) > 8 * 1024 * 1024) {
|
|
231268
|
+
await reply6.body?.cancel();
|
|
231269
|
+
throw new Error("Response bound");
|
|
231270
|
+
}
|
|
231271
|
+
if (reply6.body) for await (const chunk of reply6.body) {
|
|
231272
|
+
size2 += chunk.length;
|
|
231273
|
+
if (size2 > 8 * 1024 * 1024) throw new Error("Response bound");
|
|
231274
|
+
chunks.push(chunk);
|
|
231275
|
+
}
|
|
231276
|
+
const data7 = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
231277
|
+
if (reply6.ok) return envelope(data7, null, true);
|
|
231278
|
+
const details = external_exports.object({ "o:errorDetails": external_exports.array(external_exports.object({ detail: external_exports.string() })) }).safeParse(data7);
|
|
231279
|
+
const message8 = details.success ? details.data["o:errorDetails"].map((item2) => item2.detail).join("\n") : `NetSuite answered ${reply6.status}.`;
|
|
231280
|
+
return failure6(message8, reply6.status, true);
|
|
231281
|
+
} catch {
|
|
231282
|
+
return failure6("The NetSuite world request could not be completed.", 502, reached);
|
|
231283
|
+
}
|
|
231139
231284
|
}
|
|
231140
|
-
var RouteRefusal, refuse, slug11, quickbooks, execution, catalogTool, identifier4, multi, meta5, record26, bodySchema, slugList, sessionSchema, toolFilter, preloadSchema, switchOf, connections2, bytes3;
|
|
231285
|
+
var RouteRefusal, activeComposioToolkits, refuse, NETSUITE_FIX, slug11, quickbooks, execution, catalogTool, identifier4, multi, meta5, record26, bodySchema, slugList, sessionSchema, toolFilter, preloadSchema, switchOf, connections2, bytes3, routeIds, suiteqlArguments;
|
|
231141
231286
|
var init_composio = __esm({
|
|
231142
231287
|
"backend/src/execution/composio.ts"() {
|
|
231143
231288
|
"use strict";
|
|
231289
|
+
init_src();
|
|
231144
231290
|
init_zod();
|
|
231145
231291
|
RouteRefusal = class extends Error {
|
|
231146
231292
|
reason;
|
|
231147
|
-
|
|
231148
|
-
|
|
231293
|
+
toolkit;
|
|
231294
|
+
constructor(reason2, toolkit) {
|
|
231295
|
+
super(reason2 === "NO_WORLD" && toolkit ? noWorldMessage(toolkit) : reason2 === "NETSUITE_TOOL" ? NETSUITE_FIX : "Configure this call to use the declared QuickBooks or NetSuite route.");
|
|
231149
231296
|
this.reason = reason2;
|
|
231297
|
+
this.toolkit = toolkit;
|
|
231150
231298
|
}
|
|
231151
231299
|
};
|
|
231300
|
+
activeComposioToolkits = (route15) => route15.activeToolkits ?? route15.toolkits ?? { quickbooks: "composio" };
|
|
231152
231301
|
refuse = (reason2) => {
|
|
231153
231302
|
throw new RouteRefusal(reason2);
|
|
231154
231303
|
};
|
|
231155
|
-
|
|
231156
|
-
|
|
231304
|
+
NETSUITE_FIX = "Use session.execute or tools.execute with NETSUITE_RUN_SUITEQL_QUERY.";
|
|
231305
|
+
slug11 = "(?:QUICKBOOKS|NETSUITE)_[A-Z0-9_]{1,96}";
|
|
231306
|
+
quickbooks = new RegExp("^QUICKBOOKS_[A-Z0-9_]{1,96}$");
|
|
231157
231307
|
execution = new RegExp(`^/api/v3(?:\\.1)?/tools/execute/(${slug11})$`);
|
|
231158
231308
|
catalogTool = new RegExp(`^/api/v3(?:\\.1)?/tools/(${slug11}|COMPOSIO_MULTI_EXECUTE_TOOL|COMPOSIO_SEARCH_TOOLS|COMPOSIO_GET_TOOL_SCHEMAS)$`);
|
|
231159
231309
|
identifier4 = /^[a-zA-Z0-9_-]{1,256}$/;
|
|
@@ -231190,6 +231340,8 @@ var init_composio = __esm({
|
|
|
231190
231340
|
};
|
|
231191
231341
|
connections2 = /* @__PURE__ */ new WeakMap();
|
|
231192
231342
|
bytes3 = (value6) => Buffer.from(JSON.stringify(value6));
|
|
231343
|
+
routeIds = /* @__PURE__ */ new WeakMap();
|
|
231344
|
+
suiteqlArguments = external_exports.strictObject({ q: external_exports.string(), limit: external_exports.number().int().min(1).optional(), offset: external_exports.number().int().min(0).optional() });
|
|
231193
231345
|
}
|
|
231194
231346
|
});
|
|
231195
231347
|
|
|
@@ -231292,6 +231444,7 @@ async function startIsolationGateway(options5) {
|
|
|
231292
231444
|
const sockets = /* @__PURE__ */ new Set();
|
|
231293
231445
|
const upstreamRequests = /* @__PURE__ */ new Set();
|
|
231294
231446
|
const modelActivity = /* @__PURE__ */ new Set();
|
|
231447
|
+
const localRequests = /* @__PURE__ */ new Set();
|
|
231295
231448
|
let exposedOrigin, closed = false;
|
|
231296
231449
|
const mapped = (origin) => ({
|
|
231297
231450
|
env: { ...structuredClone(env2), ...env2.mcp && { mcp: Object.fromEntries(Object.entries(env2.mcp).map(([tool, connection4]) => [tool, { ...connection4, url: origin + new URL(connection4.url).pathname }])) }, services: Object.fromEntries(Object.entries(env2.services).map(([service, connection4]) => [service, {
|
|
@@ -231318,16 +231471,59 @@ async function startIsolationGateway(options5) {
|
|
|
231318
231471
|
toolCall = validateComposio(req.method ?? "", req.url.slice("/_tool/composio".length), req.headers["x-api-key"], toolBody, req.headers["content-type"], route15, req.headers);
|
|
231319
231472
|
} catch (error65) {
|
|
231320
231473
|
const reason2 = error65 instanceof RouteRefusal ? error65.reason : "JSON";
|
|
231321
|
-
|
|
231322
|
-
|
|
231474
|
+
const toolkit = (error65 instanceof RouteRefusal ? error65.toolkit : void 0) ?? (reason2 === "NETSUITE_TOOL" || /NETSUITE_/.test(toolBody?.toString("utf8") ?? "") || /NETSUITE_/.test(req.url ?? "") || route15?.toolkits && !route15.toolkits.quickbooks ? "netsuite" : "quickbooks");
|
|
231475
|
+
route15?.record({ leg: "platform", op: "refused", toolkit, via: composioVia((req.url ?? "").slice("/_tool/composio".length)), method: ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"].includes(req.method ?? "") ? req.method : "OTHER", status: 403, ms: Math.round(performance.now() - toolStarted), reason: reason2 });
|
|
231476
|
+
refuseComposio(res, reason2, toolkit);
|
|
231323
231477
|
return;
|
|
231324
231478
|
}
|
|
231325
231479
|
}
|
|
231480
|
+
if (toolCall?.local && route15) {
|
|
231481
|
+
const call4 = toolCall, controller = new AbortController();
|
|
231482
|
+
const cancel4 = () => {
|
|
231483
|
+
controller.abort();
|
|
231484
|
+
};
|
|
231485
|
+
localRequests.add(controller);
|
|
231486
|
+
res.once("close", cancel4);
|
|
231487
|
+
const operation = (async () => {
|
|
231488
|
+
let reached, invalidArguments = false, busy = false;
|
|
231489
|
+
const activity3 = options5.onModelActivity ?? route15.activity;
|
|
231490
|
+
try {
|
|
231491
|
+
if (call4.op === "execute") {
|
|
231492
|
+
await activity3(true);
|
|
231493
|
+
busy = true;
|
|
231494
|
+
}
|
|
231495
|
+
controller.signal.throwIfAborted();
|
|
231496
|
+
if (closed || !route15.available()) throw new Error("Route closed");
|
|
231497
|
+
const result = await executeLocalComposio(call4, route15, exposedOrigin, fetch, controller.signal);
|
|
231498
|
+
reached = result.reached;
|
|
231499
|
+
invalidArguments = result.invalidArguments === true;
|
|
231500
|
+
if (!res.destroyed) {
|
|
231501
|
+
res.writeHead(result.status, { "content-type": "application/json" });
|
|
231502
|
+
res.end(result.body === void 0 ? void 0 : JSON.stringify(result.body));
|
|
231503
|
+
}
|
|
231504
|
+
} catch {
|
|
231505
|
+
if (!res.destroyed) reject3(res, 502, "The routed world request could not be completed.");
|
|
231506
|
+
} finally {
|
|
231507
|
+
route15.record({ leg: "platform", toolkit: call4.toolkit, op: call4.op, via: call4.via, method: req.method, ...call4.slug && { slug: call4.slug }, ...invalidArguments && { reason: "ARGUMENTS" }, status: res.destroyed && !res.writableFinished ? 502 : res.statusCode, ms: Math.round(performance.now() - toolStarted) }, reached);
|
|
231508
|
+
if (busy) await activity3(false).catch(() => {
|
|
231509
|
+
});
|
|
231510
|
+
localRequests.delete(controller);
|
|
231511
|
+
res.removeListener("close", cancel4);
|
|
231512
|
+
}
|
|
231513
|
+
})();
|
|
231514
|
+
modelActivity.add(operation);
|
|
231515
|
+
try {
|
|
231516
|
+
await operation;
|
|
231517
|
+
} finally {
|
|
231518
|
+
modelActivity.delete(operation);
|
|
231519
|
+
}
|
|
231520
|
+
return;
|
|
231521
|
+
}
|
|
231326
231522
|
if (toolCall && route15) {
|
|
231327
231523
|
try {
|
|
231328
231524
|
await prepareComposio(toolCall, route15);
|
|
231329
231525
|
} catch {
|
|
231330
|
-
route15.record({ leg: "platform", op: "catalog", via: toolCall.via, method: req.method, status: 502, ms: Math.round(performance.now() - toolStarted) });
|
|
231526
|
+
route15.record({ leg: "platform", toolkit: toolCall.toolkit, op: "catalog", via: toolCall.via, method: req.method, status: 502, ms: Math.round(performance.now() - toolStarted) });
|
|
231331
231527
|
res.writeHead(502, { "content-type": "application/json" });
|
|
231332
231528
|
res.end(JSON.stringify({ error: { code: "COMPOSIO_ROUTE_CONNECTION", message: "The attempt's test connection is not available." } }));
|
|
231333
231529
|
return;
|
|
@@ -231351,7 +231547,7 @@ async function startIsolationGateway(options5) {
|
|
|
231351
231547
|
const record31 = () => {
|
|
231352
231548
|
if (recorded2) return;
|
|
231353
231549
|
recorded2 = true;
|
|
231354
|
-
route15.record({ leg: "platform", op: call4.op, via: call4.via, method: req.method, ...call4.slug && { slug: call4.slug }, status: res.writableFinished ? res.statusCode : 502, ms: Math.round(performance.now() - toolStarted) }, endWindow?.());
|
|
231550
|
+
route15.record({ leg: "platform", toolkit: call4.toolkit, op: call4.op, via: call4.via, method: req.method, ...call4.slug && { slug: call4.slug }, status: res.writableFinished ? res.statusCode : 502, ms: Math.round(performance.now() - toolStarted) }, endWindow?.());
|
|
231355
231551
|
};
|
|
231356
231552
|
res.once("finish", record31);
|
|
231357
231553
|
res.once("close", record31);
|
|
@@ -231642,6 +231838,7 @@ ${Object.entries(reply6.headers).map(([name5, value6]) => `${name5}: ${value6}`)
|
|
|
231642
231838
|
closed = true;
|
|
231643
231839
|
socketGrants.clear();
|
|
231644
231840
|
options5.signal?.removeEventListener("abort", abort);
|
|
231841
|
+
for (const controller of localRequests) controller.abort();
|
|
231645
231842
|
for (const target6 of upstreamRequests) target6.destroy();
|
|
231646
231843
|
for (const socket of sockets) socket.destroy();
|
|
231647
231844
|
await new Promise((resolve61) => server.close(() => resolve61()));
|
|
@@ -232066,30 +232263,49 @@ async function bounded(response6, cap) {
|
|
|
232066
232263
|
}
|
|
232067
232264
|
return Buffer.concat(chunks);
|
|
232068
232265
|
}
|
|
232266
|
+
function refusedDetail(reason2 = "REFUSED", toolkit) {
|
|
232267
|
+
const fix = REFUSAL_FIX[reason2] ?? "use the declared QuickBooks route";
|
|
232268
|
+
return `a Composio call was refused (${reason2}): ${typeof fix === "function" ? fix(toolkit) : `${fix}.`}`;
|
|
232269
|
+
}
|
|
232069
232270
|
async function startIngressClient(options5) {
|
|
232070
|
-
const { descriptor: descriptor3, env: env2 } = options5,
|
|
232071
|
-
|
|
232271
|
+
const { descriptor: descriptor3, env: env2 } = options5, toolkits = options5.routes ?? { quickbooks: "composio" };
|
|
232272
|
+
const twins = options5.twins ?? Object.keys(env2.services);
|
|
232273
|
+
const activeToolkits = {};
|
|
232274
|
+
for (const toolkit of ["quickbooks", "netsuite"]) if (toolkits[toolkit] && twins.includes(toolkit)) activeToolkits[toolkit] = "composio";
|
|
232275
|
+
const qb = !!activeToolkits.quickbooks;
|
|
232276
|
+
const connection4 = qb ? env2.services.quickbooks : { url: "http://127.0.0.1", token: "", accountId: "" };
|
|
232277
|
+
if (!connection4 || qb && (!connection4.accountId || !connection4.token) || !descriptor3.secretValues.COMPOSIO_API_KEY) throw new AnchaError("CONFIG_INVALID", "Composio route credentials are required");
|
|
232072
232278
|
const local2 = new URL(connection4.url);
|
|
232073
|
-
if (local2.protocol !== "http:" || local2.hostname !== "127.0.0.1" || local2.username || local2.password || local2.search || local2.hash || local2.pathname.replace(/\/$/, "") !== `/e/${env2.id}/quickbooks`) throw new Error("QuickBooks route must target its local world");
|
|
232279
|
+
if (qb && (local2.protocol !== "http:" || local2.hostname !== "127.0.0.1" || local2.username || local2.password || local2.search || local2.hash || local2.pathname.replace(/\/$/, "") !== `/e/${env2.id}/quickbooks`)) throw new Error("QuickBooks route must target its local world");
|
|
232280
|
+
const ns = activeToolkits.netsuite ? env2.services.netsuite : void 0;
|
|
232281
|
+
if (activeToolkits.netsuite) {
|
|
232282
|
+
if (!ns?.token) throw new AnchaError("CONFIG_INVALID", "NetSuite route credentials are required");
|
|
232283
|
+
const url4 = new URL(ns.url);
|
|
232284
|
+
if (url4.protocol !== "http:" || url4.hostname !== "127.0.0.1" || url4.username || url4.password || url4.search || url4.hash || url4.pathname.replace(/\/$/, "") !== `/e/${env2.id}/netsuite`) throw new AnchaError("CONFIG_INVALID", "NetSuite route must target its local world");
|
|
232285
|
+
}
|
|
232074
232286
|
const base6 = new URL(descriptor3.relay.baseUrl);
|
|
232075
232287
|
if (base6.username || base6.password || base6.search || base6.hash || !["https:", "http:"].includes(base6.protocol)) throw new Error("Invalid relay");
|
|
232076
232288
|
const endpoint2 = `${base6.origin}/_attempts/${encodeURIComponent(descriptor3.attemptId)}/ingress`;
|
|
232077
232289
|
const stop = new AbortController(), failure6 = new AbortController();
|
|
232078
232290
|
const signal = AbortSignal.any([stop.signal, ...options5.signal ? [options5.signal] : []]);
|
|
232079
|
-
let id14 = "", instance = "", publicUrl = "", expires = 0, closed = false, failed2 = false, probe = "";
|
|
232291
|
+
let id14 = "", instance = "", publicUrl = "", expires = qb ? 0 : Infinity, closed = false, failed2 = false, probe = "";
|
|
232080
232292
|
let closing;
|
|
232081
232293
|
let polls = [];
|
|
232082
232294
|
const windows = /* @__PURE__ */ new Set(), records5 = [];
|
|
232083
|
-
const
|
|
232295
|
+
const counters = () => ({ platform: "composio", executions: 0, reached: 0, refused: 0 });
|
|
232296
|
+
const counts2 = { quickbooks: counters(), netsuite: counters() };
|
|
232297
|
+
const paths3 = () => ({ direct: 0, session: 0, mcp: 0 });
|
|
232298
|
+
const via = { quickbooks: paths3(), netsuite: paths3() };
|
|
232084
232299
|
const record31 = (event3, status6, issue10) => {
|
|
232085
|
-
|
|
232300
|
+
const toolkit = event3?.toolkit ?? (qb ? "quickbooks" : "netsuite");
|
|
232301
|
+
records5.push({ seq: 0, source: "world", service: toolkit, method: event3?.leg === "platform" ? event3.method : "RELAY", path: `/_route/${toolkit}`, tSim: env2.startTime, tReal: Date.now(), status: status6, routeEvent: event3 && { ...event3, toolkit }, ...issue10 && { issue: issue10 } });
|
|
232086
232302
|
};
|
|
232087
|
-
const issue9 = (code5, detail3) => ({ kind: "world", owner:
|
|
232303
|
+
const issue9 = (code5, detail3, toolkit = qb ? "quickbooks" : "netsuite", owner5 = "harness") => ({ kind: "world", owner: owner5, service: toolkit, code: code5, message: `${code5}: ${detail3}` });
|
|
232088
232304
|
const fail9 = () => {
|
|
232089
232305
|
if (failed2 || closed || options5.signal?.aborted) return;
|
|
232090
232306
|
failed2 = true;
|
|
232091
|
-
record31({ leg: "ingress", relayHash: hash6(id14), path: "/_route", ms: 0 }, 502, issue9("ROUTE_INGRESS_FAILED", "the world's public QuickBooks address stopped answering; run again."));
|
|
232092
|
-
failure6.abort(new Error("
|
|
232307
|
+
record31({ leg: "ingress", relayHash: hash6(id14), path: "/_route", ms: 0 }, 502, issue9("ROUTE_INGRESS_FAILED", qb ? "the world's public QuickBooks address stopped answering; run again." : "the NetSuite world route could not be kept open; run again."));
|
|
232308
|
+
failure6.abort(new Error("Composio route failed"));
|
|
232093
232309
|
stop.abort();
|
|
232094
232310
|
};
|
|
232095
232311
|
async function call4(path9, method2, body8, cleanup = false) {
|
|
@@ -232152,7 +232368,7 @@ async function startIngressClient(options5) {
|
|
|
232152
232368
|
fail9();
|
|
232153
232369
|
}
|
|
232154
232370
|
}
|
|
232155
|
-
try {
|
|
232371
|
+
if (qb) try {
|
|
232156
232372
|
const response6 = await call4("", "POST", { service: "quickbooks" });
|
|
232157
232373
|
if (response6.status !== 201) {
|
|
232158
232374
|
await response6.body?.cancel();
|
|
@@ -232187,8 +232403,19 @@ async function startIngressClient(options5) {
|
|
|
232187
232403
|
record31({ leg: "ingress", relayHash: hash6(id14), path: "/_connection", ms: 0 }, 502, issue9("ROUTE_CONNECTION_FAILED", error65.message));
|
|
232188
232404
|
}
|
|
232189
232405
|
});
|
|
232190
|
-
const
|
|
232406
|
+
const narrowed = /* @__PURE__ */ new Set(), localSessions = /* @__PURE__ */ new Set(), seenSessions = /* @__PURE__ */ new Set();
|
|
232407
|
+
const sessions2 = qb ? lifecycle2.sessions : { add(id15) {
|
|
232408
|
+
if (!closed) {
|
|
232409
|
+
localSessions.add(id15);
|
|
232410
|
+
seenSessions.add(id15);
|
|
232411
|
+
}
|
|
232412
|
+
}, has: (id15) => !closed && localSessions.has(id15), delete(id15) {
|
|
232413
|
+
localSessions.delete(id15);
|
|
232414
|
+
} };
|
|
232191
232415
|
return {
|
|
232416
|
+
toolkits,
|
|
232417
|
+
activeToolkits,
|
|
232418
|
+
...ns && { netsuite: { url: ns.url, token: ns.token } },
|
|
232192
232419
|
publicUrl,
|
|
232193
232420
|
token: connection4.token,
|
|
232194
232421
|
realm: connection4.accountId,
|
|
@@ -232196,10 +232423,10 @@ async function startIngressClient(options5) {
|
|
|
232196
232423
|
attemptId: descriptor3.attemptId,
|
|
232197
232424
|
agentKey,
|
|
232198
232425
|
user: user9,
|
|
232199
|
-
connection: () => closed || failed2 || signal.aborted || Date.now() >= expires ? Promise.reject(new ComposioConnectionError(503, "ROUTE_CLOSED")) : lifecycle2.connection(),
|
|
232200
|
-
sessions:
|
|
232201
|
-
narrowed: (
|
|
232202
|
-
for (const toolkit of
|
|
232426
|
+
connection: () => !qb || closed || failed2 || signal.aborted || Date.now() >= expires ? Promise.reject(new ComposioConnectionError(503, "ROUTE_CLOSED")) : lifecycle2.connection(),
|
|
232427
|
+
sessions: sessions2,
|
|
232428
|
+
narrowed: (toolkits2) => {
|
|
232429
|
+
for (const toolkit of toolkits2) if (![agentKey, descriptor3.secretValues.COMPOSIO_API_KEY, connection4.token, ns?.token, publicUrl].some((secret) => secret && toolkit.includes(secret))) narrowed.add(toolkit);
|
|
232203
232430
|
},
|
|
232204
232431
|
signal: failure6.signal,
|
|
232205
232432
|
get failed() {
|
|
@@ -232223,19 +232450,30 @@ async function startIngressClient(options5) {
|
|
|
232223
232450
|
};
|
|
232224
232451
|
},
|
|
232225
232452
|
record(event3, reached) {
|
|
232453
|
+
const toolkit = event3.toolkit ?? (qb ? "quickbooks" : "netsuite");
|
|
232226
232454
|
if (event3.op === "execute") {
|
|
232227
|
-
via[event3.via ?? "direct"]++;
|
|
232228
|
-
counts2.executions++;
|
|
232229
|
-
if (reached) counts2.reached++;
|
|
232455
|
+
via[toolkit][event3.via ?? "direct"]++;
|
|
232456
|
+
counts2[toolkit].executions++;
|
|
232457
|
+
if (reached) counts2[toolkit].reached++;
|
|
232230
232458
|
}
|
|
232231
|
-
if (event3.op === "refused") counts2.refused++;
|
|
232232
|
-
record31({ ...event3, relayHash: hash6(id14) }, event3.status, event3.op === "refused" ? issue9("ROUTE_REFUSED", refusedDetail(event3.reason)) : event3.op === "execute" && !reached ? issue9("ROUTE_NOT_REACHED", unreachedDetail(event3.status)) : void 0);
|
|
232459
|
+
if (event3.op === "refused") counts2[toolkit].refused++;
|
|
232460
|
+
record31({ ...event3, toolkit, relayHash: hash6(id14) }, event3.status, event3.op === "refused" ? issue9("ROUTE_REFUSED", refusedDetail(event3.reason, toolkit), toolkit, event3.reason === "NO_WORLD" ? "agent" : "harness") : event3.op === "execute" && !reached && event3.reason === "ARGUMENTS" ? issue9("ROUTE_ARGUMENTS", "The agent's NETSUITE_RUN_SUITEQL_QUERY arguments were invalid; it got Composio's failure response.", toolkit, "agent") : event3.op === "execute" && !reached ? issue9("ROUTE_NOT_REACHED", toolkit === "netsuite" ? "The SuiteQL call did not reach the NetSuite world: check q, limit and offset, then run again." : unreachedDetail(event3.status), toolkit) : void 0);
|
|
232461
|
+
},
|
|
232462
|
+
summary: () => {
|
|
232463
|
+
const result = {};
|
|
232464
|
+
for (const toolkit of ["quickbooks", "netsuite"]) if (activeToolkits[toolkit] || counts2[toolkit].refused) result[toolkit] = {
|
|
232465
|
+
...counts2[toolkit],
|
|
232466
|
+
...counts2[toolkit].executions && { via: { ...via[toolkit] } },
|
|
232467
|
+
...activeToolkits[toolkit] && (toolkit === "quickbooks" ? lifecycle2.summary() : qb ? { ...lifecycle2.summary().sessions && { sessions: lifecycle2.summary().sessions }, ...lifecycle2.summary().cleanup && { cleanup: lifecycle2.summary().cleanup } } : { ...seenSessions.size && { sessions: seenSessions.size }, ...closed && { cleanup: "done" } }),
|
|
232468
|
+
...activeToolkits[toolkit] && narrowed.size && { narrowed: [...narrowed].sort() }
|
|
232469
|
+
};
|
|
232470
|
+
return result;
|
|
232233
232471
|
},
|
|
232234
|
-
summary: () => ({ quickbooks: { ...counts2, ...counts2.executions && { via: { ...via } }, ...lifecycle2.summary(), ...narrowed.size && { narrowed: [...narrowed].sort() } } }),
|
|
232235
232472
|
entries: () => records5,
|
|
232236
232473
|
close() {
|
|
232237
232474
|
return closing ??= (async () => {
|
|
232238
232475
|
closed = true;
|
|
232476
|
+
localSessions.clear();
|
|
232239
232477
|
lifecycle2.stopAccepting();
|
|
232240
232478
|
stop.abort();
|
|
232241
232479
|
await Promise.all(polls);
|
|
@@ -232256,12 +232494,13 @@ async function startIngressClient(options5) {
|
|
|
232256
232494
|
}
|
|
232257
232495
|
};
|
|
232258
232496
|
}
|
|
232259
|
-
var headersSchema, requestSchema, batchSchema, bindSchema, forwarded, methods2, hash6, REFUSAL_FIX,
|
|
232497
|
+
var headersSchema, requestSchema, batchSchema, bindSchema, forwarded, methods2, hash6, REFUSAL_FIX, unreachedDetail;
|
|
232260
232498
|
var init_ingress_client = __esm({
|
|
232261
232499
|
"backend/src/execution/ingress-client.ts"() {
|
|
232262
232500
|
"use strict";
|
|
232263
232501
|
init_zod();
|
|
232264
232502
|
init_src();
|
|
232503
|
+
init_composio();
|
|
232265
232504
|
init_composio_connection();
|
|
232266
232505
|
headersSchema = external_exports.record(external_exports.string(), external_exports.string());
|
|
232267
232506
|
requestSchema = external_exports.strictObject({ rid: external_exports.string().min(1).max(256), method: external_exports.enum(["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE"]), path: external_exports.string().max(8192), query: external_exports.string().max(8192), headers: headersSchema, body_b64: external_exports.string().max(87384) });
|
|
@@ -232271,6 +232510,8 @@ var init_ingress_client = __esm({
|
|
|
232271
232510
|
methods2 = /* @__PURE__ */ new Set(["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE"]);
|
|
232272
232511
|
hash6 = (value6) => createHash60("sha256").update(value6).digest("hex").slice(0, 16);
|
|
232273
232512
|
REFUSAL_FIX = {
|
|
232513
|
+
NO_WORLD: noWorldMessage,
|
|
232514
|
+
NETSUITE_TOOL: "use session.execute or tools.execute with NETSUITE_RUN_SUITEQL_QUERY",
|
|
232274
232515
|
ROUTE_UNAVAILABLE: "the route had closed; run again",
|
|
232275
232516
|
PATH: "use QuickBooks tools, sessions and session MCP through COMPOSIO_BASE_URL",
|
|
232276
232517
|
METHOD: "use POST for executions and MCP, GET for catalogs, and DELETE to close a session",
|
|
@@ -232281,7 +232522,7 @@ var init_ingress_client = __esm({
|
|
|
232281
232522
|
JSON: "send a JSON body",
|
|
232282
232523
|
SCHEMA: "use the SDK request fields for this endpoint; the route supplies the world connection",
|
|
232283
232524
|
SESSION: "create a session through COMPOSIO_BASE_URL and use its returned session",
|
|
232284
|
-
SESSION_ENDPOINT: "use session tools, toolkits, search, execute or execute_meta",
|
|
232525
|
+
SESSION_ENDPOINT: (toolkit) => toolkit === "netsuite" ? "this session serves NetSuite: use session.execute with NETSUITE_RUN_SUITEQL_QUERY, and create, get or delete the session." : "use session tools, toolkits, search, execute or execute_meta.",
|
|
232285
232526
|
SESSION_MUTATION: "create a new session through the route instead of modifying its connection",
|
|
232286
232527
|
TOOL: "execute a QUICKBOOKS_ tool",
|
|
232287
232528
|
META_TOOL: "use COMPOSIO_MULTI_EXECUTE_TOOL, COMPOSIO_SEARCH_TOOLS or COMPOSIO_GET_TOOL_SCHEMAS; multi-execute items must be QUICKBOOKS_ tools",
|
|
@@ -232289,7 +232530,6 @@ var init_ingress_client = __esm({
|
|
|
232289
232530
|
MCP_METHOD: "use initialize, notifications/initialized, notifications/cancelled, ping, tools/list or tools/call",
|
|
232290
232531
|
MCP_BATCH: "send one JSON-RPC object per MCP request"
|
|
232291
232532
|
};
|
|
232292
|
-
refusedDetail = (reason2 = "REFUSED") => `a Composio call was refused (${reason2}): ${REFUSAL_FIX[reason2] ?? "use the declared QuickBooks route"}.`;
|
|
232293
232533
|
unreachedDetail = (status6) => status6 === 401 || status6 === 403 ? `Composio answered ${status6} without calling the world: check the workspace secret COMPOSIO_API_KEY.` : status6 >= 500 ? `Composio answered ${status6} without calling the world; run again.` : `Composio answered ${status6} without calling the world: check the QuickBooks tool arguments and use the connection supplied by the route.`;
|
|
232294
232534
|
}
|
|
232295
232535
|
});
|
|
@@ -232304,7 +232544,7 @@ function attachTrialIngress(env2, route15) {
|
|
|
232304
232544
|
};
|
|
232305
232545
|
}
|
|
232306
232546
|
function validateRouteRuntime(agent) {
|
|
232307
|
-
if (!agent.routes?.quickbooks) return;
|
|
232547
|
+
if (!agent.routes?.quickbooks && !agent.routes?.netsuite) return;
|
|
232308
232548
|
const runtime2 = trustedRuntime();
|
|
232309
232549
|
if (runtime2 !== "fly-vm" && runtime2 !== "unsafe-local") throw new AnchaError("CONFIG_INVALID", "agent.routes requires ancha run --on cloud");
|
|
232310
232550
|
if (!attemptDescriptor()) throw new AnchaError("CONFIG_INVALID", "agent.routes requires a cloud attempt");
|
|
@@ -232317,11 +232557,13 @@ function appendRouteEvidence(capture4, route15) {
|
|
|
232317
232557
|
async function runRoutedTrial(spec, run7) {
|
|
232318
232558
|
validateAgentRoutes(spec.agent, spec.scene.twins);
|
|
232319
232559
|
validateRouteRuntime(spec.agent);
|
|
232320
|
-
if (!spec.agent.routes?.quickbooks) return run7(spec);
|
|
232560
|
+
if (!spec.agent.routes?.quickbooks && !spec.agent.routes?.netsuite) return run7(spec);
|
|
232321
232561
|
const descriptor3 = attemptDescriptor();
|
|
232322
232562
|
const startedAt = performance.now();
|
|
232323
232563
|
let sessionId, captured;
|
|
232324
232564
|
const route15 = await startIngressClient({
|
|
232565
|
+
routes: spec.agent.routes,
|
|
232566
|
+
twins: spec.scene.twins,
|
|
232325
232567
|
descriptor: descriptor3,
|
|
232326
232568
|
env: spec.env,
|
|
232327
232569
|
...spec.signal && { signal: spec.signal },
|
|
@@ -232358,7 +232600,7 @@ async function runRoutedTrial(spec, run7) {
|
|
|
232358
232600
|
await route15.close();
|
|
232359
232601
|
const connectionIssue = route15.entries().find((entry3) => entry3.issue?.code === "ROUTE_CONNECTION_FAILED")?.issue;
|
|
232360
232602
|
if (!route15.failed && !connectionIssue || spec.signal?.aborted) throw error65;
|
|
232361
|
-
const result = await invalidTrial({ scene: spec.scene, trial: spec.trial, dir: spec.dir, startedAt, envId: spec.env.id, ...sessionId && { sessionId }, ...captured && { capture: captured }, service: "quickbooks", error: connectionIssue ? { code: "ROUTE_CONNECTION_FAILED", message: connectionIssue.message } : { code: "ROUTE_INGRESS_FAILED", message: "The
|
|
232603
|
+
const result = await invalidTrial({ scene: spec.scene, trial: spec.trial, dir: spec.dir, startedAt, envId: spec.env.id, ...sessionId && { sessionId }, ...captured && { capture: captured }, service: spec.agent.routes.quickbooks ? "quickbooks" : "netsuite", error: connectionIssue ? { code: "ROUTE_CONNECTION_FAILED", message: connectionIssue.message } : { code: "ROUTE_INGRESS_FAILED", message: "The Composio route could not be kept open." } });
|
|
232362
232604
|
if (!captured) {
|
|
232363
232605
|
result.trace = route15.entries().map((entry3, i) => ({ ...entry3, seq: i + 1 }));
|
|
232364
232606
|
result.harnessIssues = collectHarnessIssues(result.trace, []);
|
|
@@ -232581,7 +232823,7 @@ function agentTask(scene2, runtime2) {
|
|
|
232581
232823
|
return runtime2?.task ?? scene2.trigger?.task ?? scene2.task ?? "";
|
|
232582
232824
|
}
|
|
232583
232825
|
function agentTemplateVars(envId, services2, task2, trial, session2, runtime2, mcp) {
|
|
232584
|
-
const vars = { task: task2, "env.id": envId, trial: String(trial) };
|
|
232826
|
+
const vars = { task: task2, task_json: JSON.stringify(task2), "env.id": envId, trial: String(trial) };
|
|
232585
232827
|
if (runtime2?.taskFile !== void 0) vars.task_file = runtime2.taskFile;
|
|
232586
232828
|
for (const [tool, connection4] of Object.entries(mcp ?? {})) Object.assign(vars, { [`${tool}.mcp_url`]: connection4.url, [`${tool}.mcp_token`]: connection4.token });
|
|
232587
232829
|
for (const [twin, s3] of Object.entries(services2)) {
|
|
@@ -233907,7 +234149,7 @@ async function startVmAgent(command, opts, deps = {}) {
|
|
|
233907
234149
|
const unsafe = runtime2 === "unsafe-local";
|
|
233908
234150
|
validateRouteRuntime(opts.agent);
|
|
233909
234151
|
const composio = trialIngress(opts.env);
|
|
233910
|
-
if (opts.agent.routes?.quickbooks && !composio?.available()) throw new AnchaError("CONFIG_INVALID", "The
|
|
234152
|
+
if ((opts.agent.routes?.quickbooks || opts.agent.routes?.netsuite) && !composio?.available()) throw new AnchaError("CONFIG_INVALID", "The Composio route must be bound before launching the agent.");
|
|
233911
234153
|
const names8 = vmEnvironmentNames(opts.agent);
|
|
233912
234154
|
explicitEnvironment(names8, descriptor3.secretValues);
|
|
233913
234155
|
const modelHosts = vmModelHosts(descriptor3.modelHosts);
|
|
@@ -233976,7 +234218,7 @@ async function startVmAgent(command, opts, deps = {}) {
|
|
|
233976
234218
|
runtime: agentRuntime,
|
|
233977
234219
|
paths: { ...paths3, path: [...descriptor3.pathPrepend, VM_PATH].join(":") }
|
|
233978
234220
|
});
|
|
233979
|
-
if (composio) Object.assign(values3, { COMPOSIO_BASE_URL: `${unsafe ? gateway2.url : VM_GATEWAY_ORIGIN}/_tool/composio`, QUICKBOOKS_PUBLIC_URL: composio.publicUrl, COMPOSIO_API_KEY: composio.agentKey });
|
|
234221
|
+
if (composio) Object.assign(values3, { COMPOSIO_BASE_URL: `${unsafe ? gateway2.url : VM_GATEWAY_ORIGIN}/_tool/composio`, ...activeComposioToolkits(composio).quickbooks ? { QUICKBOOKS_PUBLIC_URL: composio.publicUrl } : {}, COMPOSIO_API_KEY: composio.agentKey });
|
|
233980
234222
|
if (composio) {
|
|
233981
234223
|
for (const [name5, value6] of Object.entries(values3)) if (value6 && composio.apiKey) values3[name5] = value6.replaceAll(composio.apiKey, composio.agentKey);
|
|
233982
234224
|
}
|
|
@@ -233992,7 +234234,7 @@ async function startVmAgent(command, opts, deps = {}) {
|
|
|
233992
234234
|
const protectedValues = [
|
|
233993
234235
|
...Object.values(descriptor3.secretValues),
|
|
233994
234236
|
descriptor3.relay.token,
|
|
233995
|
-
...composio ? [composio.apiKey, composio.agentKey, composio.publicUrl, new URL(composio.publicUrl).pathname.split("/").at(-1)] : [],
|
|
234237
|
+
...composio ? [composio.apiKey, composio.agentKey, ...composio.publicUrl ? [composio.publicUrl, new URL(composio.publicUrl).pathname.split("/").at(-1)] : []] : [],
|
|
233996
234238
|
...Object.entries(values3).filter(([name5]) => /(?:KEY|TOKEN|SECRET|PASSWORD|CREDENTIAL)/i.test(name5)).map(([, value6]) => value6 ?? "")
|
|
233997
234239
|
];
|
|
233998
234240
|
const writer = vmLog(protectedValues, (text31) => writeSync3(opts.logFd, text31));
|
|
@@ -234102,6 +234344,7 @@ var LOG_LIMIT2, KILL_GRACE_MS2, exec2, directories;
|
|
|
234102
234344
|
var init_vm = __esm({
|
|
234103
234345
|
"backend/src/execution/vm.ts"() {
|
|
234104
234346
|
"use strict";
|
|
234347
|
+
init_composio();
|
|
234105
234348
|
init_routed_trial();
|
|
234106
234349
|
init_src();
|
|
234107
234350
|
init_agent_env();
|
|
@@ -235035,7 +235278,7 @@ function attemptOutcome(view3, ctx) {
|
|
|
235035
235278
|
code: "crashed",
|
|
235036
235279
|
level: "fail",
|
|
235037
235280
|
message: `The agent exited with code ${view3.exitCode ?? "unknown"} after ${view3.realMs} ms while parsing the connection check's plain-text task.`,
|
|
235038
|
-
fix: "read ANCHA_TASK as text, or map the task with agent.env in ancha.yaml to the input your agent expects"
|
|
235281
|
+
fix: ctx.jsonTaskFix ?? "read ANCHA_TASK as text, or map the task with agent.env in ancha.yaml to the input your agent expects"
|
|
235039
235282
|
});
|
|
235040
235283
|
const fix = ctx.taskFix ?? likelyFix(tail, { target: ctx.target ?? "cloud", ...ctx.command !== void 0 && { command: ctx.command } });
|
|
235041
235284
|
const key5 = ctx.taskFix === void 0 ? missingKey(tail) : void 0;
|
|
@@ -235945,7 +236188,7 @@ function nonDefaultOut(cwd, out) {
|
|
|
235945
236188
|
}
|
|
235946
236189
|
function renderSummaryText(s3, opts = {}) {
|
|
235947
236190
|
const lines2 = s3.replayOf === void 0 ? [] : [`replay of ${s3.replayOf}`];
|
|
235948
|
-
if (s3.routes?.
|
|
236191
|
+
for (const toolkit of ["quickbooks", "netsuite"]) if (s3.routes?.[toolkit]) lines2.push(formatRouteSummary(s3.routes[toolkit], toolkit));
|
|
235949
236192
|
const never2 = agentNeverRan(s3);
|
|
235950
236193
|
if (never2 === void 0) {
|
|
235951
236194
|
for (const scene2 of s3.scenes) for (const t of scene2.trialsDetail) if (t.diagnosis) lines2.push(`${scene2.sceneId} trial ${t.trial}`, ...toolDiagnosticLines(t).map((line2) => ` ${line2}`));
|
|
@@ -236837,6 +237080,80 @@ var init_run = __esm({
|
|
|
236837
237080
|
}
|
|
236838
237081
|
});
|
|
236839
237082
|
|
|
237083
|
+
// backend/src/kit/json-task-input.ts
|
|
237084
|
+
function argument(text31, start2) {
|
|
237085
|
+
let depth = 1, quote6 = "";
|
|
237086
|
+
for (let i = start2; i < text31.length && i - start2 < 2e3; i++) {
|
|
237087
|
+
const c = text31[i];
|
|
237088
|
+
if (c === "\\" && quote6) {
|
|
237089
|
+
i++;
|
|
237090
|
+
continue;
|
|
237091
|
+
}
|
|
237092
|
+
if (quote6) {
|
|
237093
|
+
if (c === quote6) quote6 = "";
|
|
237094
|
+
continue;
|
|
237095
|
+
}
|
|
237096
|
+
if (c === '"' || c === "'") {
|
|
237097
|
+
quote6 = c;
|
|
237098
|
+
continue;
|
|
237099
|
+
}
|
|
237100
|
+
if (c === "(") depth++;
|
|
237101
|
+
if (c === ")" && --depth === 0) return { text: text31.slice(start2, i), end: i + 1 };
|
|
237102
|
+
}
|
|
237103
|
+
return void 0;
|
|
237104
|
+
}
|
|
237105
|
+
function jsonTaskInputs(text31, source) {
|
|
237106
|
+
const found = [];
|
|
237107
|
+
for (const match3 of text31.matchAll(/\b(?:json\.loads?|JSON\.parse)\s*\(/g)) {
|
|
237108
|
+
const call4 = argument(text31, match3.index + match3[0].length);
|
|
237109
|
+
if (!call4) continue;
|
|
237110
|
+
const before = text31.slice(0, match3.index).split("\n").at(-1);
|
|
237111
|
+
const variable = /\b([A-Za-z_]\w*)\s*=\s*$/.exec(before)?.[1];
|
|
237112
|
+
const chain = `(?:\\[\\s*['"][\\w-]+['"]\\s*\\]|\\.get\\(\\s*['"][\\w-]+['"]\\s*\\)|\\.(?!get\\b)[A-Za-z_]\\w*)+`;
|
|
237113
|
+
const accesses = variable ? [...text31.slice(call4.end).matchAll(new RegExp(`\\b${escape17(variable)}(${chain})`, "g"))] : [];
|
|
237114
|
+
const immediate = new RegExp(`^\\s*(${chain})`).exec(text31.slice(call4.end));
|
|
237115
|
+
if (immediate) accesses.push(immediate);
|
|
237116
|
+
const paths3 = accesses.flatMap((access16) => {
|
|
237117
|
+
const fields13 = [...access16[1].matchAll(/\[\s*['"]([\w-]+)['"]\s*\]|\.get\(\s*['"]([\w-]+)['"]\s*\)|\.([A-Za-z_]\w*)/g)].map((m) => m[1] ?? m[2] ?? m[3]);
|
|
237118
|
+
return /^(task|prompt|message|query|question|instruction|instructions|input|request|text|input_text)$/.test(fields13.at(-1) ?? "") ? [fields13] : [];
|
|
237119
|
+
});
|
|
237120
|
+
const unique5 = [...new Map(paths3.map((path9) => [JSON.stringify(path9), path9])).values()];
|
|
237121
|
+
if (unique5.length !== 1) continue;
|
|
237122
|
+
let input5 = call4.text;
|
|
237123
|
+
for (let n2 = 0; n2 < 3 && /^\s*[A-Za-z_]\w*\s*$/.test(input5); n2++) {
|
|
237124
|
+
const assignments = [...text31.slice(0, match3.index).matchAll(new RegExp(`(?:^|\\n)\\s*(?:(?:const|let|var)\\s+)?${escape17(input5.trim())}\\s*=\\s*([^\\n;]+)`, "g"))];
|
|
237125
|
+
const value6 = assignments.at(-1)?.[1];
|
|
237126
|
+
if (!value6) break;
|
|
237127
|
+
input5 = value6;
|
|
237128
|
+
}
|
|
237129
|
+
const mark = { source, line: text31.slice(0, match3.index).split("\n").length, fields: unique5[0] };
|
|
237130
|
+
const file3 = /\bopen\s*\(|readFileSync\s*\(/.test(input5);
|
|
237131
|
+
if (/\bsys\.stdin\b|\binput\s*\(|\bprocess\.stdin\b|readFileSync\(\s*0\b/.test(input5)) {
|
|
237132
|
+
found.push({ ...mark, via: "stdin", name: "stdin", file: false });
|
|
237133
|
+
continue;
|
|
237134
|
+
}
|
|
237135
|
+
const env2 = /(?:os\.environ\[|os\.environ\.get\(|os\.getenv\(|process\.env\[)\s*['"]([A-Za-z_]\w*)['"]|process\.env\.([A-Za-z_]\w*)/.exec(input5);
|
|
237136
|
+
if (env2) {
|
|
237137
|
+
found.push({ ...mark, via: "env", name: env2[1] ?? env2[2], file: file3 });
|
|
237138
|
+
continue;
|
|
237139
|
+
}
|
|
237140
|
+
if (/\bsys\.argv\[1\]|\bprocess\.argv\[2\]/.test(input5)) {
|
|
237141
|
+
found.push({ ...mark, via: "argv", name: "argv", file: file3 });
|
|
237142
|
+
continue;
|
|
237143
|
+
}
|
|
237144
|
+
const flag5 = /\b(?:args|values)\.([a-z][a-z_]*)/.exec(input5)?.[1]?.replaceAll("_", "-");
|
|
237145
|
+
if (flag5 && text31.includes(`--${flag5}`)) found.push({ ...mark, via: "flag", name: `--${flag5}`, file: file3 });
|
|
237146
|
+
}
|
|
237147
|
+
return found;
|
|
237148
|
+
}
|
|
237149
|
+
var escape17;
|
|
237150
|
+
var init_json_task_input = __esm({
|
|
237151
|
+
"backend/src/kit/json-task-input.ts"() {
|
|
237152
|
+
"use strict";
|
|
237153
|
+
escape17 = (value6) => value6.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
237154
|
+
}
|
|
237155
|
+
});
|
|
237156
|
+
|
|
236840
237157
|
// backend/src/kit/task-input.ts
|
|
236841
237158
|
import { open as open6, stat as stat6 } from "node:fs/promises";
|
|
236842
237159
|
import { basename as basename7, dirname as dirname10, extname, isAbsolute as isAbsolute6, join as join24, relative as relative9, resolve as resolve18, sep as sep4 } from "node:path";
|
|
@@ -237175,6 +237492,7 @@ async function scanTaskInput(root3, command, options5 = {}) {
|
|
|
237175
237492
|
const seen = /* @__PURE__ */ new Set(), scanned = [], found = [], variables2 = /* @__PURE__ */ new Map();
|
|
237176
237493
|
const order6 = { next: 0 }, marks = { stdin: null, done: null };
|
|
237177
237494
|
let native3 = null;
|
|
237495
|
+
const jsonInputs = [];
|
|
237178
237496
|
while (queue.length && scanned.length < maxFiles) {
|
|
237179
237497
|
const file3 = normal(queue.shift());
|
|
237180
237498
|
if (seen.has(file3) || !inside(p2.root, resolve18(p2.root, file3))) continue;
|
|
@@ -237184,10 +237502,11 @@ async function scanTaskInput(root3, command, options5 = {}) {
|
|
|
237184
237502
|
scanned.push(file3);
|
|
237185
237503
|
const python = extname(file3) === ".py" || /^#!.*python/.test(text31);
|
|
237186
237504
|
const own2 = scanSource(text31, file3, python, found, order6, variables2, marks);
|
|
237505
|
+
jsonInputs.push(...jsonTaskInputs(text31, file3));
|
|
237187
237506
|
if (own2 && !native3) native3 = { name: own2.name, source: file3 };
|
|
237188
237507
|
queue.push(...(await imports(p2, file3, text31)).map(normal));
|
|
237189
237508
|
}
|
|
237190
|
-
return { native: native3, inputs: native3 ? [] : rank(found), scanned, variables: [...variables2.keys()].sort(), variableSources: Object.fromEntries(variables2), ...marks };
|
|
237509
|
+
return { native: native3, inputs: native3 ? [] : rank(found), scanned, variables: [...variables2.keys()].sort(), variableSources: Object.fromEntries(variables2), ...marks, ...jsonInputs.length && { jsonInputs } };
|
|
237191
237510
|
}
|
|
237192
237511
|
function answerSource(scan2, http) {
|
|
237193
237512
|
return scan2.done !== null ? "done" : http ? "reply" : "stdout";
|
|
@@ -237220,17 +237539,42 @@ function netsuiteMappings(variables2) {
|
|
|
237220
237539
|
return field6 === void 0 ? [] : [{ name: name5, value: NETSUITE_VALUE[field6] ?? `{{netsuite.${field6}}}` }];
|
|
237221
237540
|
});
|
|
237222
237541
|
}
|
|
237223
|
-
function taskWiring(input5, command) {
|
|
237542
|
+
function taskWiring(input5, command, value6) {
|
|
237224
237543
|
if (input5.via === "env") {
|
|
237225
|
-
const
|
|
237226
|
-
return { input: input5, env: { [input5.name]:
|
|
237544
|
+
const mapped = value6 ?? (input5.file ? "{{task_file}}" : "{{task}}");
|
|
237545
|
+
return { input: input5, env: { [input5.name]: mapped }, yaml: `env: { ${input5.name}: ${JSON.stringify(mapped)} }` };
|
|
237227
237546
|
}
|
|
237228
237547
|
const base6 = NPM_SCRIPT2.test(command) ? `${command.trim()} --` : command.trim();
|
|
237229
237548
|
const next2 = `${base6} ${input5.name} "${input5.file ? "$ANCHA_TASK_FILE" : "$ANCHA_TASK"}"`;
|
|
237230
237549
|
return { input: input5, command: next2, yaml: `command: ${/^[\w./@+-]/.test(next2) && !/: | #/.test(next2) ? next2 : JSON.stringify(next2)}` };
|
|
237231
237550
|
}
|
|
237551
|
+
function jsonTaskWiring(scan2, command) {
|
|
237552
|
+
const inputs2 = scan2?.jsonInputs ?? [];
|
|
237553
|
+
if (inputs2.length !== 1) return void 0;
|
|
237554
|
+
const input5 = inputs2[0], payload3 = input5.fields.reduceRight((value7, field6) => `{${JSON.stringify(field6)}: ${value7}}`, "{{task_json}}");
|
|
237555
|
+
if (input5.via === "env" && !input5.file) return taskWiring({ ...input5, via: "env" }, command, payload3).yaml;
|
|
237556
|
+
const env2 = `env: { ANCHA_JSON_TASK: ${JSON.stringify(payload3)} }`;
|
|
237557
|
+
const value6 = input5.file ? "$ANCHA_STATE_DIR/ancha-task.json" : "$ANCHA_JSON_TASK";
|
|
237558
|
+
let next2 = command;
|
|
237559
|
+
if (input5.via === "stdin") next2 = `printf '%s' "$ANCHA_JSON_TASK" | ${command}`;
|
|
237560
|
+
else if (input5.via === "env") return `${env2}
|
|
237561
|
+
command: >-
|
|
237562
|
+
printf '%s' "$ANCHA_JSON_TASK" > "$ANCHA_STATE_DIR/ancha-task.json" && ${input5.name}="$ANCHA_STATE_DIR/ancha-task.json" ${command}`;
|
|
237563
|
+
else if (/\$(?:ANCHA_TASK(?:_FILE)?\b|\{ANCHA_TASK(?:_FILE)?\})/.test(command)) next2 = command.replace(/\$(?:ANCHA_TASK(?:_FILE)?\b|\{ANCHA_TASK(?:_FILE)?\})/g, () => value6);
|
|
237564
|
+
else if (input5.via === "flag") {
|
|
237565
|
+
if (command.includes(input5.name)) return void 0;
|
|
237566
|
+
next2 = taskWiring({ ...input5, via: "flag" }, command).command.replace(/\$ANCHA_TASK(?:_FILE)?/g, () => value6);
|
|
237567
|
+
} else {
|
|
237568
|
+
const parsed5 = words7(command);
|
|
237569
|
+
if (parsed5.length !== 1 || !/\.(?:py|[cm]?js|tsx?)$/.test(parsed5[0]?.at(-1) ?? "")) return void 0;
|
|
237570
|
+
next2 = `${command} "${value6}"`;
|
|
237571
|
+
}
|
|
237572
|
+
if (input5.file) next2 = `printf '%s' "$ANCHA_JSON_TASK" > "$ANCHA_STATE_DIR/ancha-task.json" && ${next2}`;
|
|
237573
|
+
return `${env2}
|
|
237574
|
+
command: ${JSON.stringify(next2)}`;
|
|
237575
|
+
}
|
|
237232
237576
|
function mappedTaskInput(agent) {
|
|
237233
|
-
const mapped = Object.entries(agent.env ?? {}).find(([, value6]) => /\{\{\s*task(?:_file)?\s*\}\}/.test(value6));
|
|
237577
|
+
const mapped = Object.entries(agent.env ?? {}).find(([, value6]) => /\{\{\s*task(?:_file|_json)?\s*\}\}/.test(value6));
|
|
237234
237578
|
if (mapped) return mapped[0];
|
|
237235
237579
|
const command = agent.command ?? "";
|
|
237236
237580
|
const flag5 = /(--[\w-]+)(?:\s+|=)["']?\$\{?ANCHA_TASK(?:_FILE)?\b/.exec(command);
|
|
@@ -237247,6 +237591,7 @@ var init_task_input = __esm({
|
|
|
237247
237591
|
"use strict";
|
|
237248
237592
|
init_src();
|
|
237249
237593
|
init_agent_env();
|
|
237594
|
+
init_json_task_input();
|
|
237250
237595
|
STRONG = /* @__PURE__ */ new Set(["TASK", "PROMPT", "INSTRUCTION", "INSTRUCTIONS"]);
|
|
237251
237596
|
WEAK = /* @__PURE__ */ new Set(["QUERY", "QUESTION", "MESSAGE", "REQUEST", "INPUT"]);
|
|
237252
237597
|
FILE_WORDS = /* @__PURE__ */ new Set(["FILE", "PATH"]);
|
|
@@ -237583,14 +237928,14 @@ function functionToolsIn(text31, source) {
|
|
|
237583
237928
|
}
|
|
237584
237929
|
return start2;
|
|
237585
237930
|
};
|
|
237586
|
-
const
|
|
237587
|
-
for (let i = 0; i < v.length; i++) if (
|
|
237931
|
+
const aliases2 = /* @__PURE__ */ new Set(["tool", "function_tool", "wrapTool"]);
|
|
237932
|
+
for (let i = 0; i < v.length; i++) if (aliases2.has(v[i]) && v[i + 1] === "as" && identifier5(v[i + 2])) aliases2.add(v[i + 2]);
|
|
237588
237933
|
const definitions3 = /* @__PURE__ */ new Map();
|
|
237589
237934
|
for (let i = 0; i < v.length; i++) {
|
|
237590
237935
|
if (python && v[i] === "@") {
|
|
237591
237936
|
let decorator = i + 1;
|
|
237592
237937
|
while (v[decorator + 1] === ".") decorator += 2;
|
|
237593
|
-
if (!
|
|
237938
|
+
if (!aliases2.has(v[decorator])) continue;
|
|
237594
237939
|
const close3 = v[decorator + 1] === "(" ? end(decorator + 1) : decorator;
|
|
237595
237940
|
let d = close3 + 1;
|
|
237596
237941
|
while (v[d] === "@") {
|
|
@@ -237610,7 +237955,7 @@ function functionToolsIn(text31, source) {
|
|
|
237610
237955
|
const symbol2 = v[i - 1];
|
|
237611
237956
|
let c = i + 1;
|
|
237612
237957
|
while (v[c + 1] === ".") c += 2;
|
|
237613
|
-
if (!(
|
|
237958
|
+
if (!(aliases2.has(v[c]) || v[c] === "StructuredTool" || v[c] === "from_function") || v[c + 1] !== "(") continue;
|
|
237614
237959
|
const close2 = end(c + 1), args = v.slice(c + 2, close2);
|
|
237615
237960
|
const named5 = args.findIndex((x) => x === "name" || x === "name_override");
|
|
237616
237961
|
const name5 = literal2(args[named5 + 2]) ?? (v[c] === "wrapTool" ? literal2(args[0]) : void 0) ?? symbol2;
|
|
@@ -237814,6 +238159,75 @@ var init_tool_signals = __esm({
|
|
|
237814
238159
|
}
|
|
237815
238160
|
});
|
|
237816
238161
|
|
|
238162
|
+
// backend/src/kit/composio-signals.ts
|
|
238163
|
+
function tokens5(text31, python) {
|
|
238164
|
+
const out = [];
|
|
238165
|
+
const pattern = python ? /#[^\n]*|"""[\s\S]*?"""|'''[\s\S]*?'''|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[A-Za-z_$][\w$]*|[^\s]/g : /\/\/[^\n]*|\/\*[\s\S]*?\*\/|`(?:\\.|[^`\\])*`|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[A-Za-z_$][\w$]*|[^\s]/g;
|
|
238166
|
+
let line2 = 1, end = 0;
|
|
238167
|
+
for (const match3 of text31.matchAll(pattern)) {
|
|
238168
|
+
line2 += text31.slice(end, match3.index).split("\n").length - 1;
|
|
238169
|
+
const value6 = match3[0];
|
|
238170
|
+
if (!/^(?:#|\/\/|\/\*|"""|'''|`)/.test(value6)) {
|
|
238171
|
+
const string11 = /^["']/.test(value6);
|
|
238172
|
+
out.push({ value: string11 ? value6.slice(1, -1) : value6, string: string11, line: line2 });
|
|
238173
|
+
}
|
|
238174
|
+
line2 += value6.split("\n").length - 1;
|
|
238175
|
+
end = match3.index + value6.length;
|
|
238176
|
+
}
|
|
238177
|
+
return out;
|
|
238178
|
+
}
|
|
238179
|
+
function composioToolSignals(text31, file3) {
|
|
238180
|
+
const source = tokens5(text31, file3.endsWith(".py"));
|
|
238181
|
+
const found = /* @__PURE__ */ new Map();
|
|
238182
|
+
const add = (token5, slug16 = false) => {
|
|
238183
|
+
const name5 = slug16 ? token5.value.slice(0, token5.value.indexOf("_")).toLowerCase() : token5.value.toLowerCase();
|
|
238184
|
+
const tool = Object.hasOwn(aliases, name5) ? aliases[name5] : void 0;
|
|
238185
|
+
if (tool && !found.has(tool)) found.set(tool, `Composio ${slug16 ? "tool slug" : "toolkit"} ${name5} in ${file3}:${token5.line}`);
|
|
238186
|
+
};
|
|
238187
|
+
const calls2 = [];
|
|
238188
|
+
let depth = 0;
|
|
238189
|
+
for (let i = 0; i < source.length; i++) {
|
|
238190
|
+
const token5 = source[i];
|
|
238191
|
+
if (token5.string) {
|
|
238192
|
+
if (/^[A-Z][A-Z0-9]*_[A-Z0-9_]+$/.test(token5.value)) add(token5, true);
|
|
238193
|
+
} else if (token5.value === "(") {
|
|
238194
|
+
depth++;
|
|
238195
|
+
if (source[i - 2]?.value === "." && !source[i - 1]?.string) calls2.push({ method: source[i - 1].value, depth });
|
|
238196
|
+
} else if (token5.value === ")") {
|
|
238197
|
+
if (calls2.at(-1)?.depth === depth) calls2.pop();
|
|
238198
|
+
depth--;
|
|
238199
|
+
}
|
|
238200
|
+
if (token5.value !== "toolkits" || !["create", "get"].includes(calls2.at(-1)?.method ?? "") || ![":", "="].includes(source[i + 1]?.value ?? "")) continue;
|
|
238201
|
+
let start2 = i + 2;
|
|
238202
|
+
if (source[start2]?.value === "{" && source[start2 + 1]?.value === "enable" && source[start2 + 2]?.value === ":") start2 += 3;
|
|
238203
|
+
if (source[start2]?.value !== "[") continue;
|
|
238204
|
+
for (let j = start2 + 1; j < source.length; j++) {
|
|
238205
|
+
const item2 = source[j];
|
|
238206
|
+
if (item2.value === "]") break;
|
|
238207
|
+
if (item2.string) add(item2);
|
|
238208
|
+
else if (item2.value !== ",") break;
|
|
238209
|
+
}
|
|
238210
|
+
}
|
|
238211
|
+
return found;
|
|
238212
|
+
}
|
|
238213
|
+
var isComposioSdk, aliases;
|
|
238214
|
+
var init_composio_signals = __esm({
|
|
238215
|
+
"backend/src/kit/composio-signals.ts"() {
|
|
238216
|
+
"use strict";
|
|
238217
|
+
init_src();
|
|
238218
|
+
isComposioSdk = (name5) => ["composio", "composio-client", "@composio/core"].includes(name5.toLowerCase().replaceAll("_", "-"));
|
|
238219
|
+
aliases = Object.fromEntries(SUPPORTED_TWINS.flatMap((tool) => [[tool, tool], [tool.replaceAll("-", ""), tool], [tool.replaceAll("-", "_"), tool]]));
|
|
238220
|
+
Object.assign(aliases, {
|
|
238221
|
+
googledrive: "google-drive",
|
|
238222
|
+
googlecalendar: "google-calendar",
|
|
238223
|
+
googleads: "google-ads",
|
|
238224
|
+
googleanalytics: "ga4",
|
|
238225
|
+
amazons3: "amazon-s3",
|
|
238226
|
+
s3: "amazon-s3"
|
|
238227
|
+
});
|
|
238228
|
+
}
|
|
238229
|
+
});
|
|
238230
|
+
|
|
237817
238231
|
// backend/src/kit/detect.ts
|
|
237818
238232
|
function pythonDependencies(body8, file3) {
|
|
237819
238233
|
if (/requirements[^/]*\.txt$/.test(file3)) return body8.split(/\r?\n/).flatMap((line2) => /^\s*([A-Za-z0-9][\w.-]*)(?:\[|\s*[<>=!~;@]|\s*$)/.exec(line2)?.[1] ?? []);
|
|
@@ -237833,7 +238247,7 @@ function pythonDependencies(body8, file3) {
|
|
|
237833
238247
|
if (name5 && name5 !== "python") names8.push(name5);
|
|
237834
238248
|
continue;
|
|
237835
238249
|
}
|
|
237836
|
-
const array4 = section3 === "project.optional-dependencies" || section3 === "dependency-groups" || section3 === "project" && (/^\s*dependencies\s*=/.test(line2) || dependencies);
|
|
238250
|
+
const array4 = section3 === "project.optional-dependencies" || section3 === "dependency-groups" || section3 === "project" && (/^\s*dependencies\s*=/.test(line2) || dependencies) || section3 === "tool.uv" && (/^\s*dev-dependencies\s*=/.test(line2) || dependencies);
|
|
237837
238251
|
if (!array4) continue;
|
|
237838
238252
|
for (const match3 of line2.matchAll(/["']([a-zA-Z0-9][\w.-]*)(?:\[[^\]]*\])?(?:[ <>=!~;@][^"']*)?["']/g)) names8.push(match3[1]);
|
|
237839
238253
|
dependencies = !/\]\s*,?\s*$/.test(line2);
|
|
@@ -237844,6 +238258,8 @@ async function detectProject(cwd, agent) {
|
|
|
237844
238258
|
if (agent !== void 0 && agent.trim() === "") throw new AnchaError("USAGE", "--agent must be a non-empty command", { hint: 'e.g. --agent "node agent.mjs"' });
|
|
237845
238259
|
const evidence3 = [];
|
|
237846
238260
|
const found = /* @__PURE__ */ new Map();
|
|
238261
|
+
let composioSource;
|
|
238262
|
+
const composio = /* @__PURE__ */ new Map();
|
|
237847
238263
|
const files2 = await projectFiles2(cwd);
|
|
237848
238264
|
const read7 = (name5) => readProjectFile(cwd, name5);
|
|
237849
238265
|
let node5 = false, python = false;
|
|
@@ -237864,7 +238280,13 @@ async function detectProject(cwd, agent) {
|
|
|
237864
238280
|
python = true;
|
|
237865
238281
|
dependencies = pythonDependencies(body8, name5);
|
|
237866
238282
|
}
|
|
237867
|
-
for (const dependency of dependencies)
|
|
238283
|
+
for (const dependency of dependencies) {
|
|
238284
|
+
if (isComposioSdk(dependency) && composioSource === void 0) {
|
|
238285
|
+
const line2 = body8.split(/\r?\n/).findIndex((line3) => line3.includes(dependency)) + 1;
|
|
238286
|
+
composioSource = `${dependency} in ${name5}:${line2}`;
|
|
238287
|
+
}
|
|
238288
|
+
for (const twin of toolsForSdk(dependency)) if (!found.has(twin)) found.set(twin, `${dependency.toLowerCase()} in ${name5}`);
|
|
238289
|
+
}
|
|
237868
238290
|
}
|
|
237869
238291
|
let sourceNode = false, sourcePython = false;
|
|
237870
238292
|
const apps = [];
|
|
@@ -237877,6 +238299,10 @@ async function detectProject(cwd, agent) {
|
|
|
237877
238299
|
for (const tool of functionToolsIn(body8, name5)) if (!functions.has(tool.name)) functions.set(tool.name, tool);
|
|
237878
238300
|
if (name5.endsWith(".py")) sourcePython = true;
|
|
237879
238301
|
else sourceNode = true;
|
|
238302
|
+
if (composioSource) for (const [twin, signal] of composioToolSignals(body8, name5)) {
|
|
238303
|
+
if (!composio.has(twin)) composio.set(twin, signal);
|
|
238304
|
+
if (!found.has(twin)) found.set(twin, signal);
|
|
238305
|
+
}
|
|
237880
238306
|
for (const [twin, signal] of sourceToolSignals(body8, name5.endsWith(".py"))) if (!found.has(twin)) found.set(twin, `${signal} in ${name5}`);
|
|
237881
238307
|
}
|
|
237882
238308
|
if (!node5 && !python) {
|
|
@@ -237891,7 +238317,12 @@ async function detectProject(cwd, agent) {
|
|
|
237891
238317
|
Object.assign(start2, { agent: `${file3.endsWith(".py") ? "python" : /\.ts$/.test(file3) ? "npx tsx" : "node"} '${file3.replaceAll("'", "'\\''")}'`, agentSource: "entry-file", agentEvidence: file3 });
|
|
237892
238318
|
}
|
|
237893
238319
|
const sdks = SUPPORTED_TWINS.filter((twin) => found.has(twin));
|
|
237894
|
-
|
|
238320
|
+
const sdkSources = Object.fromEntries(sdks.map((twin) => [twin, found.get(twin)]));
|
|
238321
|
+
if (composioSource) {
|
|
238322
|
+
sdks.push("composio");
|
|
238323
|
+
sdkSources.composio = composioSource;
|
|
238324
|
+
}
|
|
238325
|
+
return { language: node5 === python ? "unknown" : node5 ? "ts" : "py", sdks, sdkSources, ...composioSource && { composio: { tools: SUPPORTED_TWINS.filter((twin) => composio.has(twin)), from: Object.fromEntries(composio) } }, evidence: evidence3, functionTools: [...functions.values()], ...start2, ...slackApp && { slackApp } };
|
|
237895
238326
|
}
|
|
237896
238327
|
var init_detect = __esm({
|
|
237897
238328
|
"backend/src/kit/detect.ts"() {
|
|
@@ -237902,6 +238333,7 @@ var init_detect = __esm({
|
|
|
237902
238333
|
init_project_files();
|
|
237903
238334
|
init_function_tools();
|
|
237904
238335
|
init_tool_signals();
|
|
238336
|
+
init_composio_signals();
|
|
237905
238337
|
}
|
|
237906
238338
|
});
|
|
237907
238339
|
|
|
@@ -237915,7 +238347,7 @@ function toolsOf(found) {
|
|
|
237915
238347
|
if (!from.has(twin)) from.set(twin, `${name5} in ${found.scan?.variableSources[name5]?.source ?? "its source"}`);
|
|
237916
238348
|
}
|
|
237917
238349
|
}
|
|
237918
|
-
for (const twin of found.detection?.sdks ?? []) if (!from.has(twin)) from.set(twin, found.detection?.sdkSources[twin] ?? "its dependencies");
|
|
238350
|
+
for (const twin of found.detection?.sdks ?? []) if (twin !== "composio" && !from.has(twin)) from.set(twin, found.detection?.sdkSources[twin] ?? "its dependencies");
|
|
237919
238351
|
for (const [name5, value6] of Object.entries(found.env ?? {})) {
|
|
237920
238352
|
for (const template3 of templateNames(value6)) {
|
|
237921
238353
|
const twin = template3.split(".")[0];
|
|
@@ -239164,7 +239596,7 @@ var init_tools = __esm({
|
|
|
239164
239596
|
|
|
239165
239597
|
// cloud/rebuild/readers/suiteql.mjs
|
|
239166
239598
|
function tokenize9(sql6) {
|
|
239167
|
-
const
|
|
239599
|
+
const tokens7 = [];
|
|
239168
239600
|
for (let i = 0; i < sql6.length; ) {
|
|
239169
239601
|
const c = sql6[i];
|
|
239170
239602
|
if (/\s/.test(c)) {
|
|
@@ -239193,43 +239625,43 @@ function tokenize9(sql6) {
|
|
|
239193
239625
|
}
|
|
239194
239626
|
text31 += sql6[j++];
|
|
239195
239627
|
}
|
|
239196
|
-
|
|
239628
|
+
tokens7.push({ t: "str", v: text31 });
|
|
239197
239629
|
i = j + 1;
|
|
239198
239630
|
continue;
|
|
239199
239631
|
}
|
|
239200
239632
|
if (c === '"') {
|
|
239201
239633
|
const end = sql6.indexOf('"', i + 1), stop = end < 0 ? sql6.length : end;
|
|
239202
|
-
|
|
239634
|
+
tokens7.push({ t: "id", v: sql6.slice(i + 1, stop).toLowerCase(), quoted: true });
|
|
239203
239635
|
i = stop + 1;
|
|
239204
239636
|
continue;
|
|
239205
239637
|
}
|
|
239206
239638
|
const number7 = /^\d*\.?\d+(?:e[+-]?\d+)?/i.exec(sql6.slice(i));
|
|
239207
239639
|
if (/[0-9.]/.test(c) && number7) {
|
|
239208
|
-
|
|
239640
|
+
tokens7.push({ t: "num", v: Number(number7[0]) });
|
|
239209
239641
|
i += number7[0].length;
|
|
239210
239642
|
continue;
|
|
239211
239643
|
}
|
|
239212
239644
|
const word2 = /^[A-Za-z_][\w$#]*/.exec(sql6.slice(i));
|
|
239213
239645
|
if (word2) {
|
|
239214
|
-
|
|
239646
|
+
tokens7.push({ t: "id", v: word2[0].toLowerCase() });
|
|
239215
239647
|
i += word2[0].length;
|
|
239216
239648
|
continue;
|
|
239217
239649
|
}
|
|
239218
239650
|
const two = sql6.slice(i, i + 2);
|
|
239219
239651
|
if (["<=", ">=", "<>", "!=", "||"].includes(two)) {
|
|
239220
|
-
|
|
239652
|
+
tokens7.push({ t: "op", v: two });
|
|
239221
239653
|
i += 2;
|
|
239222
239654
|
continue;
|
|
239223
239655
|
}
|
|
239224
|
-
|
|
239656
|
+
tokens7.push({ t: "op", v: c });
|
|
239225
239657
|
i++;
|
|
239226
239658
|
}
|
|
239227
|
-
return
|
|
239659
|
+
return tokens7;
|
|
239228
239660
|
}
|
|
239229
|
-
function split2(
|
|
239661
|
+
function split2(tokens7, isSeparator) {
|
|
239230
239662
|
const parts3 = [[]];
|
|
239231
239663
|
let depth = 0;
|
|
239232
|
-
for (const token5 of
|
|
239664
|
+
for (const token5 of tokens7) {
|
|
239233
239665
|
if (op(token5, "(")) depth++;
|
|
239234
239666
|
if (op(token5, ")")) depth--;
|
|
239235
239667
|
if (depth === 0 && isSeparator(token5)) {
|
|
@@ -239240,30 +239672,30 @@ function split2(tokens6, isSeparator) {
|
|
|
239240
239672
|
}
|
|
239241
239673
|
return parts3.filter((part) => part.length);
|
|
239242
239674
|
}
|
|
239243
|
-
function columnRef(
|
|
239244
|
-
if (
|
|
239245
|
-
if (
|
|
239675
|
+
function columnRef(tokens7) {
|
|
239676
|
+
if (tokens7.length === 1 && tokens7[0].t === "id" && !RESERVED2.has(tokens7[0].v)) return [void 0, tokens7[0].v];
|
|
239677
|
+
if (tokens7.length === 3 && tokens7[0].t === "id" && op(tokens7[1], ".") && tokens7[2].t === "id") return [tokens7[0].v, tokens7[2].v];
|
|
239246
239678
|
return void 0;
|
|
239247
239679
|
}
|
|
239248
|
-
function selectItem(
|
|
239680
|
+
function selectItem(tokens7) {
|
|
239249
239681
|
let alias;
|
|
239250
|
-
if (
|
|
239251
|
-
alias =
|
|
239252
|
-
|
|
239253
|
-
} else if (
|
|
239254
|
-
alias =
|
|
239255
|
-
|
|
239256
|
-
}
|
|
239257
|
-
if (
|
|
239258
|
-
if (
|
|
239259
|
-
const ref23 = columnRef(
|
|
239682
|
+
if (tokens7.length >= 3 && word(tokens7.at(-2), "as") && tokens7.at(-1).t === "id") {
|
|
239683
|
+
alias = tokens7.at(-1).v;
|
|
239684
|
+
tokens7 = tokens7.slice(0, -2);
|
|
239685
|
+
} else if (tokens7.length >= 2 && tokens7.at(-1).t === "id" && !RESERVED2.has(tokens7.at(-1).v) && !op(tokens7.at(-2), ".") && (tokens7.at(-2).t === "id" || op(tokens7.at(-2), ")") || tokens7.at(-2).t === "str" || tokens7.at(-2).t === "num" || word(tokens7.at(-2), "end"))) {
|
|
239686
|
+
alias = tokens7.at(-1).v;
|
|
239687
|
+
tokens7 = tokens7.slice(0, -1);
|
|
239688
|
+
}
|
|
239689
|
+
if (tokens7.length === 1 && op(tokens7[0], "*")) return { star: "*" };
|
|
239690
|
+
if (tokens7.length === 3 && tokens7[0].t === "id" && op(tokens7[1], ".") && op(tokens7[2], "*")) return { star: tokens7[0].v };
|
|
239691
|
+
const ref23 = columnRef(tokens7);
|
|
239260
239692
|
if (ref23) return { key: alias ?? ref23[1], table: ref23[0], column: ref23[1] };
|
|
239261
|
-
const call4 =
|
|
239262
|
-
if (call4 === "builtin" && op(
|
|
239263
|
-
const args2 = inner(
|
|
239693
|
+
const call4 = tokens7[0]?.t === "id" ? tokens7[0].v : void 0;
|
|
239694
|
+
if (call4 === "builtin" && op(tokens7[1], ".") && word(tokens7[2], "df")) {
|
|
239695
|
+
const args2 = inner(tokens7.slice(3)), column3 = args2 && columnRef(args2);
|
|
239264
239696
|
if (column3) return { key: alias, table: column3[0], column: column3[1], display: true };
|
|
239265
239697
|
}
|
|
239266
|
-
const args = call4 && inner(
|
|
239698
|
+
const args = call4 && inner(tokens7.slice(1));
|
|
239267
239699
|
if (args) {
|
|
239268
239700
|
const [first2, second] = split2(args, (t) => op(t, ","));
|
|
239269
239701
|
const column3 = first2 && columnRef(first2);
|
|
@@ -239272,10 +239704,10 @@ function selectItem(tokens6) {
|
|
|
239272
239704
|
}
|
|
239273
239705
|
return { key: alias };
|
|
239274
239706
|
}
|
|
239275
|
-
function conjuncts(
|
|
239276
|
-
if (split2(
|
|
239707
|
+
function conjuncts(tokens7, into) {
|
|
239708
|
+
if (split2(tokens7, (t) => word(t, "or")).length > 1) return;
|
|
239277
239709
|
let between = false;
|
|
239278
|
-
const terms2 = split2(
|
|
239710
|
+
const terms2 = split2(tokens7, (t) => {
|
|
239279
239711
|
if (word(t, "between")) between = true;
|
|
239280
239712
|
else if (word(t, "and")) {
|
|
239281
239713
|
if (between) {
|
|
@@ -239302,9 +239734,9 @@ function conjuncts(tokens6, into) {
|
|
|
239302
239734
|
}
|
|
239303
239735
|
}
|
|
239304
239736
|
}
|
|
239305
|
-
function fromClause(
|
|
239737
|
+
function fromClause(tokens7, into) {
|
|
239306
239738
|
const tables = /* @__PURE__ */ new Map();
|
|
239307
|
-
const items2 = split2(
|
|
239739
|
+
const items2 = split2(tokens7, (t) => op(t, ","));
|
|
239308
239740
|
for (const item2 of items2) {
|
|
239309
239741
|
let i = 0;
|
|
239310
239742
|
const table6 = () => {
|
|
@@ -239338,11 +239770,11 @@ function fromClause(tokens6, into) {
|
|
|
239338
239770
|
}
|
|
239339
239771
|
function lineage2(sql6) {
|
|
239340
239772
|
if (typeof sql6 !== "string") return void 0;
|
|
239341
|
-
const
|
|
239342
|
-
if (!word(
|
|
239773
|
+
const tokens7 = tokenize9(sql6.trim().replace(/;\s*$/, ""));
|
|
239774
|
+
if (!word(tokens7[0], "select")) return void 0;
|
|
239343
239775
|
const top = [];
|
|
239344
239776
|
let depth = 0;
|
|
239345
|
-
|
|
239777
|
+
tokens7.forEach((t, i) => {
|
|
239346
239778
|
if (op(t, "(")) depth++;
|
|
239347
239779
|
else if (op(t, ")")) depth--;
|
|
239348
239780
|
else if (depth === 0 && t.t === "id" && !t.quoted) top.push([t.v, i]);
|
|
@@ -239350,26 +239782,26 @@ function lineage2(sql6) {
|
|
|
239350
239782
|
if (top.some(([v]) => ["union", "minus", "intersect", "with"].includes(v))) return void 0;
|
|
239351
239783
|
const from = top.find(([v]) => v === "from")?.[1];
|
|
239352
239784
|
if (from === void 0) return void 0;
|
|
239353
|
-
const after = (start2) => top.filter(([v, i]) => i > start2 && ["where", "group", "order", "having", "fetch", "offset", "limit"].includes(v)).map(([, i]) => i)[0] ??
|
|
239785
|
+
const after = (start2) => top.filter(([v, i]) => i > start2 && ["where", "group", "order", "having", "fetch", "offset", "limit"].includes(v)).map(([, i]) => i)[0] ?? tokens7.length;
|
|
239354
239786
|
const into = { constants: [], equal: [] };
|
|
239355
|
-
let list19 =
|
|
239787
|
+
let list19 = tokens7.slice(1, from);
|
|
239356
239788
|
while (word(list19[0], "distinct", "all")) list19 = list19.slice(1);
|
|
239357
239789
|
if (word(list19[0], "top") && list19[1]?.t === "num") list19 = list19.slice(2);
|
|
239358
|
-
const tables = fromClause(
|
|
239790
|
+
const tables = fromClause(tokens7.slice(from + 1, after(from)), into);
|
|
239359
239791
|
if (!tables?.size) return void 0;
|
|
239360
239792
|
const where3 = top.find(([v]) => v === "where")?.[1];
|
|
239361
|
-
if (where3 !== void 0) conjuncts(
|
|
239362
|
-
const
|
|
239793
|
+
if (where3 !== void 0) conjuncts(tokens7.slice(where3 + 1, after(where3)), into);
|
|
239794
|
+
const aliases2 = [...tables.keys()];
|
|
239363
239795
|
const place2 = (alias, column3) => {
|
|
239364
239796
|
if (alias !== void 0) return tables.has(alias) ? alias : void 0;
|
|
239365
|
-
if (
|
|
239366
|
-
const owners =
|
|
239797
|
+
if (aliases2.length === 1) return aliases2[0];
|
|
239798
|
+
const owners = aliases2.filter((a) => COLUMNS[tables.get(a)]?.includes(column3));
|
|
239367
239799
|
return owners.length === 1 ? owners[0] : void 0;
|
|
239368
239800
|
};
|
|
239369
239801
|
const columns = [], stars = /* @__PURE__ */ new Set();
|
|
239370
239802
|
for (const item2 of split2(list19, (t) => op(t, ",")).map(selectItem)) {
|
|
239371
239803
|
if (item2.star) {
|
|
239372
|
-
if (item2.star === "*" ?
|
|
239804
|
+
if (item2.star === "*" ? aliases2.length === 1 : tables.has(item2.star)) stars.add(item2.star === "*" ? aliases2[0] : item2.star);
|
|
239373
239805
|
continue;
|
|
239374
239806
|
}
|
|
239375
239807
|
if (item2.column === void 0) continue;
|
|
@@ -239469,12 +239901,12 @@ var init_suiteql2 = __esm({
|
|
|
239469
239901
|
"first",
|
|
239470
239902
|
"next"
|
|
239471
239903
|
]);
|
|
239472
|
-
literal3 = (
|
|
239473
|
-
if (
|
|
239474
|
-
if (
|
|
239904
|
+
literal3 = (tokens7) => {
|
|
239905
|
+
if (tokens7.length === 1 && (tokens7[0].t === "str" || tokens7[0].t === "num")) return { value: tokens7[0].v };
|
|
239906
|
+
if (tokens7.length === 2 && op(tokens7[0], "-") && tokens7[1].t === "num") return { value: -tokens7[1].v };
|
|
239475
239907
|
return void 0;
|
|
239476
239908
|
};
|
|
239477
|
-
inner = (
|
|
239909
|
+
inner = (tokens7) => op(tokens7[0], "(") && op(tokens7.at(-1), ")") ? tokens7.slice(1, -1) : void 0;
|
|
239478
239910
|
COLUMNS = {
|
|
239479
239911
|
transaction: [
|
|
239480
239912
|
"id",
|
|
@@ -242385,6 +242817,56 @@ var init_dependency_plan = __esm({
|
|
|
242385
242817
|
}
|
|
242386
242818
|
});
|
|
242387
242819
|
|
|
242820
|
+
// backend/src/execution/connection-route.ts
|
|
242821
|
+
function routedTools(routes2) {
|
|
242822
|
+
return ["quickbooks", "netsuite"].filter((tool) => routes2?.[tool] === "composio");
|
|
242823
|
+
}
|
|
242824
|
+
function routedProbeTask(routes2) {
|
|
242825
|
+
const systems = routedTools(routes2).map((tool) => tool === "netsuite" ? "NetSuite (NETSUITE_RUN_SUITEQL_QUERY)" : "QuickBooks (QUICKBOOKS_QUERY_ENTITIES)");
|
|
242826
|
+
return `Ancha connection check: read one customer in each of these systems and reply with their names: ${systems.join(", ")}. Change nothing.`;
|
|
242827
|
+
}
|
|
242828
|
+
function connectionRouteEvidence(routes2, summary, trace2, log3) {
|
|
242829
|
+
const tools2 = routedTools(routes2);
|
|
242830
|
+
if (!tools2.length) return { details: [] };
|
|
242831
|
+
const counts2 = tools2.map((tool) => ({ tool, route: summary?.[tool] }));
|
|
242832
|
+
const details = counts2.map(({ tool, route: route15 }) => `${tool === "netsuite" ? "NetSuite" : "QuickBooks"} via Composio: ${route15?.executions ?? 0} executions, ${route15?.reached ?? 0} reached the world, ${route15?.refused ?? 0} refused${route15?.via ? ` \xB7 via direct ${route15.via.direct} / session ${route15.via.session} / MCP ${route15.via.mcp}` : ""}`);
|
|
242833
|
+
const refused2 = trace2.filter((entry3) => entry3.routeEvent?.leg === "platform" && entry3.routeEvent.op === "refused");
|
|
242834
|
+
for (const entry3 of refused2.slice(0, 5)) {
|
|
242835
|
+
const event3 = entry3.routeEvent;
|
|
242836
|
+
if (event3.leg !== "platform") continue;
|
|
242837
|
+
details.push(`refused: ${event3.method} ${event3.slug ?? "Composio call"}${event3.via ? ` via ${event3.via}` : ""} (${event3.reason ?? "REFUSED"})`);
|
|
242838
|
+
}
|
|
242839
|
+
const first2 = refused2[0];
|
|
242840
|
+
if (first2 || counts2.some(({ route: route15 }) => (route15?.refused ?? 0) > 0)) return { details, reason: {
|
|
242841
|
+
code: "refused",
|
|
242842
|
+
level: "fail",
|
|
242843
|
+
message: "The Composio route refused a call.",
|
|
242844
|
+
fix: first2?.issue?.message ?? "Use the tools declared in agent.routes through COMPOSIO_BASE_URL."
|
|
242845
|
+
} };
|
|
242846
|
+
const platformCalled = trace2.some((entry3) => entry3.routeEvent?.leg === "platform") || counts2.some(({ route: route15 }) => (route15?.executions ?? 0) > 0 || (route15?.sessions ?? 0) > 0);
|
|
242847
|
+
if (!platformCalled && /\b(?:backend|api)\.composio\.(?:dev|ai)\b/i.test(log3)) return { details, reason: {
|
|
242848
|
+
code: "outside_host",
|
|
242849
|
+
level: "fail",
|
|
242850
|
+
message: "The agent called Composio\u2019s own API host without reaching the Ancha gateway.",
|
|
242851
|
+
fix: "The Composio client pins its API URL. Configure the client to take its API URL from COMPOSIO_BASE_URL, then run ancha agent upload again."
|
|
242852
|
+
} };
|
|
242853
|
+
const missed = counts2.filter(({ route: route15 }) => (route15?.executions ?? 0) > (route15?.reached ?? 0));
|
|
242854
|
+
const issue9 = trace2.find((entry3) => entry3.issue?.code === "ROUTE_NOT_REACHED" || entry3.issue?.code === "ROUTE_ARGUMENTS")?.issue;
|
|
242855
|
+
if (missed.length) return { details, reason: {
|
|
242856
|
+
code: "unserved",
|
|
242857
|
+
level: "warning",
|
|
242858
|
+
message: `The check\u2019s Composio executions did not reach ${missed.map(({ tool }) => tool === "netsuite" ? "NetSuite" : "QuickBooks").join(" or ")}.`,
|
|
242859
|
+
fix: issue9?.code === "ROUTE_ARGUMENTS" ? "Send NETSUITE_RUN_SUITEQL_QUERY its SuiteQL query in q, with integer limit and offset when paging." : issue9?.message ?? "Run ancha agent upload again."
|
|
242860
|
+
} };
|
|
242861
|
+
if (counts2.some(({ route: route15 }) => !route15?.reached)) return { details };
|
|
242862
|
+
return { details, reason: { code: "answered", level: "pass", message: "The agent\u2019s Composio executions reached each routed world." } };
|
|
242863
|
+
}
|
|
242864
|
+
var init_connection_route = __esm({
|
|
242865
|
+
"backend/src/execution/connection-route.ts"() {
|
|
242866
|
+
"use strict";
|
|
242867
|
+
}
|
|
242868
|
+
});
|
|
242869
|
+
|
|
242388
242870
|
// backend/src/execution/vm-connection.ts
|
|
242389
242871
|
var vm_connection_exports = {};
|
|
242390
242872
|
__export(vm_connection_exports, {
|
|
@@ -242464,8 +242946,8 @@ async function probeVmConnection(descriptor3, deps = {}) {
|
|
|
242464
242946
|
}
|
|
242465
242947
|
const http = agent.mode === "endpoint" || agent.taskInput?.kind === "http";
|
|
242466
242948
|
probe.kind = http ? "http" : agent.taskInput?.kind === "per_event" ? "per_event" : "command";
|
|
242467
|
-
const twins = await probeTwins(descriptor3.agentDir, agent.mode === "endpoint" ? { command: agent.start ?? "", env: agent.env } : agent, await connectionTools(descriptor3.projectDir));
|
|
242468
|
-
const asked2 = agent.mode !== "endpoint" && agent.taskInput?.kind === "http" && twins.includes("netsuite");
|
|
242949
|
+
const twins = [.../* @__PURE__ */ new Set([...routedTools(agent.routes), ...await probeTwins(descriptor3.agentDir, agent.mode === "endpoint" ? { command: agent.start ?? "", env: agent.env } : agent, await connectionTools(descriptor3.projectDir))])].slice(0, 6);
|
|
242950
|
+
const asked2 = routedTools(agent.routes).length > 0 || agent.mode !== "endpoint" && agent.taskInput?.kind === "http" && twins.includes("netsuite");
|
|
242469
242951
|
let scene2 = parseScene({ id: "connection", title: "Agent connection", twins: [], start_time: "2026-01-01T00:00:00Z", seed: {}, checks: [] });
|
|
242470
242952
|
let env2 = { id: "connection", sceneId: scene2.id, services: {}, startTime: scene2.start_time, timeScale: 1 };
|
|
242471
242953
|
await mkdir20(descriptor3.outDir, { recursive: true });
|
|
@@ -242473,14 +242955,15 @@ async function probeVmConnection(descriptor3, deps = {}) {
|
|
|
242473
242955
|
fd = openSync7(logPath, "w", 384);
|
|
242474
242956
|
const timeout = AbortSignal.timeout(http ? agent.mode === "endpoint" ? agent.startupTimeoutMs : agent.taskInput?.kind === "http" ? agent.taskInput.startupTimeoutMs ?? 12e4 : 3e4 : 1e4);
|
|
242475
242957
|
if (!http || asked2) {
|
|
242476
|
-
const
|
|
242958
|
+
const command2 = agent.mode === "endpoint" ? agent.start ?? "" : agent.command;
|
|
242959
|
+
const word2 = executable(command2);
|
|
242477
242960
|
const quoted4 = "'" + word2.replaceAll("'", "'\\''") + "'";
|
|
242478
242961
|
child3 = await startVmAgent(`command -v ${quoted4} >/dev/null 2>&1`, { agent: { ...agent, routes: void 0, env: {} }, env: env2, scene: scene2, trial: 1, logFd: fd, dir: descriptor3.outDir, signal: timeout }, deps);
|
|
242479
242962
|
const resolved = await child3.exited;
|
|
242480
242963
|
child3 = void 0;
|
|
242481
242964
|
probe.exitCode = resolved.kind === "exit" ? resolved.code : null;
|
|
242482
242965
|
if (!(resolved.kind === "exit" && resolved.code === 0 && !timeout.aborted)) return { state: "failed", probe, message: "The agent executable did not resolve in the prepared environment." };
|
|
242483
|
-
const missing10 = await deps.entryCheck?.(
|
|
242966
|
+
const missing10 = await deps.entryCheck?.(command2);
|
|
242484
242967
|
if (missing10 !== void 0) return { state: "failed", probe, message: missing10 };
|
|
242485
242968
|
if (probe.kind === "per_event" || agent.taskInput?.kind === "events") {
|
|
242486
242969
|
probe.passed = true;
|
|
@@ -242508,10 +242991,10 @@ async function probeVmConnection(descriptor3, deps = {}) {
|
|
|
242508
242991
|
const ready3 = agent.mode === "endpoint" ? renderAgentUrl(agent.readyUrl ?? "", { "agent.port": String(port), "env.id": env2.id }) : `http://127.0.0.1:${port}${agent.taskInput?.kind === "http" ? agent.taskInput.readyPath : "/"}`;
|
|
242509
242992
|
const url4 = new URL(ready3);
|
|
242510
242993
|
if (url4.protocol !== "http:" || !["127.0.0.1", "localhost", "[::1]"].includes(url4.hostname)) throw new Error("A local HTTP readiness URL is required");
|
|
242511
|
-
if (agent.routes?.quickbooks) {
|
|
242512
|
-
if (!backend || !session2) throw new AnchaError("CONFIG_INVALID", "The
|
|
242513
|
-
ingress = await startIngressClient({ descriptor: descriptor3, env: env2, signal: timeout, activity: (busy) => backend.agentBusy(env2.id, session2.id, busy) });
|
|
242514
|
-
if (ingress.failed) throw new AnchaError("SERVER_UNREACHABLE", "ROUTE_INGRESS_FAILED: the
|
|
242994
|
+
if (agent.routes?.quickbooks || agent.routes?.netsuite) {
|
|
242995
|
+
if (!backend || !session2) throw new AnchaError("CONFIG_INVALID", "The Composio route requires a prepared world.");
|
|
242996
|
+
ingress = await startIngressClient({ routes: agent.routes, twins: scene2.twins, descriptor: descriptor3, env: env2, signal: timeout, activity: (busy) => backend.agentBusy(env2.id, session2.id, busy) });
|
|
242997
|
+
if (ingress.failed) throw new AnchaError("SERVER_UNREACHABLE", "ROUTE_INGRESS_FAILED: the Composio route could not be opened.");
|
|
242515
242998
|
detachIngress = attachTrialIngress(env2, ingress);
|
|
242516
242999
|
}
|
|
242517
243000
|
child3 = await startVmAgent(command, { agent: { ...agent, connectionOnly: true }, env: env2, scene: scene2, ...session2 !== void 0 && { session: session2 }, trial: 1, runtime: { port }, logFd: fd, dir: descriptor3.outDir, signal: timeout }, deps);
|
|
@@ -242566,10 +243049,12 @@ function unfinished(trial) {
|
|
|
242566
243049
|
}
|
|
242567
243050
|
async function runWithTask(descriptor3, agent, run7) {
|
|
242568
243051
|
const { probe } = run7;
|
|
243052
|
+
const command = agent.mode === "endpoint" ? agent.start ?? "" : agent.command;
|
|
242569
243053
|
const twins = run7.twins;
|
|
242570
243054
|
probe.tools = probeToolCalls(twins, []);
|
|
242571
|
-
const netsuite = twins.includes("netsuite"),
|
|
242572
|
-
const
|
|
243055
|
+
const netsuite = twins.includes("netsuite"), routed = routedTools(agent.routes).length > 0;
|
|
243056
|
+
const task2 = routed ? routedProbeTask(agent.routes) : netsuite ? NETSUITE_PROBE_TASK : PROBE_TASK;
|
|
243057
|
+
const limit2 = run7.limit ?? (netsuite || routed ? NETSUITE_PROBE_MS : PROBE_MS);
|
|
242573
243058
|
const scene2 = parseScene({
|
|
242574
243059
|
id: "connection",
|
|
242575
243060
|
title: "Agent connection",
|
|
@@ -242610,9 +243095,13 @@ async function runWithTask(descriptor3, agent, run7) {
|
|
|
242610
243095
|
probe.exitCode = trial?.exitCode ?? null;
|
|
242611
243096
|
if (trial === void 0) return { state: "failed", probe, message: "The connection check could not start." };
|
|
242612
243097
|
probe.tools = probeToolCalls(twins, trial.trace);
|
|
242613
|
-
const tail = trial.logTail, fix = taskFixFromLog(tail, agent);
|
|
242614
|
-
const
|
|
242615
|
-
|
|
243098
|
+
const tail = trial.logTail, fix = taskFixFromLog(tail, { command, env: agent.env });
|
|
243099
|
+
const text31 = log3?.toString("utf8") ?? tail.join("\n");
|
|
243100
|
+
const route15 = connectionRouteEvidence(agent.routes, trial.routes, trial.trace, text31);
|
|
243101
|
+
if (route15.details.length) probe.routeDetails = route15.details;
|
|
243102
|
+
const diagnosed = (code5) => code5 === "MODEL_KEY_REFUSED" || routed && (code5 === "ROUTE_REFUSED" || code5 === "ROUTE_NOT_REACHED");
|
|
243103
|
+
const harnessIssue = trial.harnessIssues.some((issue9) => issue9.owner === "harness" && !diagnosed(issue9.code));
|
|
243104
|
+
if (harnessIssue || !trial.valid && !trial.harnessIssues.some((issue9) => diagnosed(issue9.code))) {
|
|
242616
243105
|
Object.assign(probe, { logTail: tail, ...fix !== void 0 && { fix } });
|
|
242617
243106
|
return { state: "failed", probe, message: unfinished(trial) };
|
|
242618
243107
|
}
|
|
@@ -242620,19 +243109,23 @@ async function runWithTask(descriptor3, agent, run7) {
|
|
|
242620
243109
|
probe.logTail = tail;
|
|
242621
243110
|
return { state: "failed", probe, message: trial.taskDelivery?.message ?? "The agent did not pass its HTTP readiness check." };
|
|
242622
243111
|
}
|
|
242623
|
-
const scan2 = await scanTaskInput(descriptor3.agentDir,
|
|
243112
|
+
const scan2 = await scanTaskInput(descriptor3.agentDir, command).catch(() => void 0);
|
|
242624
243113
|
const own2 = netsuiteMappings(scan2?.variables ?? []).filter((mapping) => !Object.hasOwn(agent.env, mapping.name));
|
|
242625
|
-
const
|
|
243114
|
+
const suggestedJson = plainTextTaskParseError(tail) ? jsonTaskWiring(scan2, command) : void 0;
|
|
243115
|
+
const jsonMapping = suggestedJson && suggestedJson.length <= 430 ? suggestedJson : void 0;
|
|
242626
243116
|
const outcome4 = attemptOutcome({ exit: trial.exit, exitCode: trial.exitCode, realMs: trial.realMs, trace: trial.trace, log: text31, logTail: tail, modelReplies: trial.modelReplies }, {
|
|
242627
243117
|
check: netsuite ? "netsuite" : "start",
|
|
242628
243118
|
answerChecked: false,
|
|
242629
243119
|
stdin: agent.taskInput?.kind === "stdin" ? null : scan2?.stdin,
|
|
242630
243120
|
given: Object.keys(descriptor3.secretValues),
|
|
242631
|
-
command
|
|
243121
|
+
command,
|
|
242632
243122
|
target: "cloud",
|
|
242633
243123
|
taskMark: task2.split(":")[0],
|
|
243124
|
+
...jsonMapping && { jsonTaskFix: `In ancha.yaml under agent:, set:
|
|
243125
|
+
${jsonMapping.split("\n").map((line2) => ` ${line2}`).join("\n")}` },
|
|
242634
243126
|
...fix !== void 0 ? { taskFix: taskFixLine(fix) } : own2.length > 0 ? { taskFix: `add to ancha.yaml under agent: env: { ${own2.map((mapping) => `${mapping.name}: "${mapping.value}"`).join(", ")} }` } : {}
|
|
242635
243127
|
});
|
|
243128
|
+
if (route15.reason && (route15.reason.level === "fail" || outcome4.reason.level !== "fail" && outcome4.reason.code !== "crashed")) outcome4.reason = route15.reason;
|
|
242636
243129
|
Object.assign(probe, { reason: outcome4.reason, calls: outcome4.calls, ...outcome4.answer !== void 0 && { answer: outcome4.answer } });
|
|
242637
243130
|
if (trial.exitCode !== null && trial.exitCode !== 0 || outcome4.reason.code === "no_answer") {
|
|
242638
243131
|
probe.logTail = tail.length > 0 ? tail : text31.trimEnd().split("\n").filter(Boolean).slice(-10);
|
|
@@ -242640,7 +243133,7 @@ async function runWithTask(descriptor3, agent, run7) {
|
|
|
242640
243133
|
if (outcome4.reason.level !== "fail") {
|
|
242641
243134
|
probe.passed = true;
|
|
242642
243135
|
probe.readyAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
242643
|
-
return { state: agent.taskInput?.kind === "http" ? "connected" : "ready", probe };
|
|
243136
|
+
return { state: agent.mode === "endpoint" || agent.taskInput?.kind === "http" ? "connected" : "ready", probe };
|
|
242644
243137
|
}
|
|
242645
243138
|
Object.assign(probe, { logTail: tail.length > 0 ? tail : text31.trimEnd().split("\n").filter(Boolean).slice(-10), ...fix !== void 0 && { fix } });
|
|
242646
243139
|
return { state: "failed", probe, message: outcome4.reason.message };
|
|
@@ -242655,7 +243148,7 @@ async function probeSlackApp(descriptor3, agent, probe, deps) {
|
|
|
242655
243148
|
let backend, env2, child3, fd;
|
|
242656
243149
|
const began = performance.now();
|
|
242657
243150
|
try {
|
|
242658
|
-
const twins = [.../* @__PURE__ */ new Set(["slack", ...await probeTwins(descriptor3.agentDir, { command, env: agent.env }, await connectionTools(descriptor3.projectDir))])];
|
|
243151
|
+
const twins = [.../* @__PURE__ */ new Set(["slack", ...routedTools(agent.routes), ...await probeTwins(descriptor3.agentDir, { command, env: agent.env }, await connectionTools(descriptor3.projectDir))])];
|
|
242659
243152
|
const scene2 = parseScene({ id: "connection", title: "Slack app connection", twins, seed: Object.fromEntries(twins.map((twin) => [twin, toolStarterSeed(twin)])), start_time: "2026-01-01T00:00:00Z", checks: [] });
|
|
242660
243153
|
validateAgentEnv(scene2, agent);
|
|
242661
243154
|
backend = await (deps.openBackend ?? (() => openBackend({ peopleRelay: cloudModelAccess(descriptor3.relay).peopleRelay })))();
|
|
@@ -242666,9 +243159,9 @@ async function probeSlackApp(descriptor3, agent, probe, deps) {
|
|
|
242666
243159
|
await mkdir20(descriptor3.outDir, { recursive: true });
|
|
242667
243160
|
fd = openSync7(join44(descriptor3.outDir, "agent.log"), "w", 384);
|
|
242668
243161
|
const deadline3 = AbortSignal.timeout(deps.probeMs ?? (agent.mode === "endpoint" ? agent.startupTimeoutMs : 3e4));
|
|
242669
|
-
if (agent.routes?.quickbooks) {
|
|
242670
|
-
ingress = await startIngressClient({ descriptor: descriptor3, env: env2, signal: deadline3, activity: (busy) => backend.agentBusy(env2.id, session2.id, busy) });
|
|
242671
|
-
if (ingress.failed) throw new AnchaError("SERVER_UNREACHABLE", "ROUTE_INGRESS_FAILED: the
|
|
243162
|
+
if (agent.routes?.quickbooks || agent.routes?.netsuite) {
|
|
243163
|
+
ingress = await startIngressClient({ routes: agent.routes, twins: scene2.twins, descriptor: descriptor3, env: env2, signal: deadline3, activity: (busy) => backend.agentBusy(env2.id, session2.id, busy) });
|
|
243164
|
+
if (ingress.failed) throw new AnchaError("SERVER_UNREACHABLE", "ROUTE_INGRESS_FAILED: the Composio route could not be opened.");
|
|
242672
243165
|
detachIngress = attachTrialIngress(env2, ingress);
|
|
242673
243166
|
}
|
|
242674
243167
|
const signal = ingress ? AbortSignal.any([deadline3, ingress.signal]) : deadline3;
|
|
@@ -242713,6 +243206,7 @@ var init_vm_connection = __esm({
|
|
|
242713
243206
|
"backend/src/execution/vm-connection.ts"() {
|
|
242714
243207
|
"use strict";
|
|
242715
243208
|
init_ingress_client();
|
|
243209
|
+
init_connection_route();
|
|
242716
243210
|
init_routed_trial();
|
|
242717
243211
|
init_slack_app();
|
|
242718
243212
|
init_agent_env();
|
|
@@ -247721,8 +248215,8 @@ function customerFacts(facts, transcript3, world5 = []) {
|
|
|
247721
248215
|
for (const fact2 of facts) {
|
|
247722
248216
|
const value6 = norm(fact2.value);
|
|
247723
248217
|
const first2 = value6.length >= 3 && exactLike(fact2) ? transcript3.find((line2) => norm(line2.content).includes(value6)) : void 0;
|
|
247724
|
-
const at6 = Date.parse(first2?.t ?? ""), key5 =
|
|
247725
|
-
const read7 = first2?.role === "assistant" && key5.trim().length >= 3 && world5.some((answer) => (!Number.isFinite(at6) || !Number.isFinite(Date.parse(answer.t ?? "")) || Date.parse(answer.t) <= at6) &&
|
|
248218
|
+
const at6 = Date.parse(first2?.t ?? ""), key5 = tokens6(fact2.value);
|
|
248219
|
+
const read7 = first2?.role === "assistant" && key5.trim().length >= 3 && world5.some((answer) => (!Number.isFinite(at6) || !Number.isFinite(Date.parse(answer.t ?? "")) || Date.parse(answer.t) <= at6) && tokens6(answer.text).includes(key5));
|
|
247726
248220
|
(first2?.role === "assistant" && !read7 ? dropped : kept).push(fact2);
|
|
247727
248221
|
}
|
|
247728
248222
|
return { kept, dropped };
|
|
@@ -247788,14 +248282,14 @@ function placePerson(cx, person5, { agent, opener, userTurns }) {
|
|
|
247788
248282
|
...knows.length && { knows }
|
|
247789
248283
|
}];
|
|
247790
248284
|
}
|
|
247791
|
-
var EMAIL24, norm, exactLike,
|
|
248285
|
+
var EMAIL24, norm, exactLike, tokens6, slug15;
|
|
247792
248286
|
var init_person = __esm({
|
|
247793
248287
|
"cloud/rebuild/person.mjs"() {
|
|
247794
248288
|
"use strict";
|
|
247795
248289
|
EMAIL24 = /[\w.+-]+@[\w-]+(?:\.[\w-]+)+/g;
|
|
247796
248290
|
norm = (text31) => String(text31 ?? "").toLowerCase().replace(/\s+/g, " ").trim();
|
|
247797
248291
|
exactLike = (fact2) => fact2.exact === true || fact2.match === "exact" || /[\d$€£¥]/.test(String(fact2.value ?? ""));
|
|
247798
|
-
|
|
248292
|
+
tokens6 = (text31) => ` ${String(text31 ?? "").toLowerCase().replace(/[^a-z0-9]+/g, " ").trim()} `;
|
|
247799
248293
|
slug15 = (text31, sep9) => String(text31 ?? "").toLowerCase().replace(/[^a-z0-9]+/g, sep9).replace(new RegExp(`^\\${sep9}+|\\${sep9}+$`, "g"), "");
|
|
247800
248294
|
}
|
|
247801
248295
|
});
|
|
@@ -248092,14 +248586,14 @@ function toolOf2(a, span3) {
|
|
|
248092
248586
|
return record31;
|
|
248093
248587
|
}
|
|
248094
248588
|
function outputOf(a) {
|
|
248095
|
-
const listed2 =
|
|
248589
|
+
const listed2 = parse27(a["gen_ai.output.messages"]);
|
|
248096
248590
|
if (Array.isArray(listed2)) return lastAnswer(conversation2(listed2).messages) || void 0;
|
|
248097
248591
|
const text31 = a["llm.output_messages.0.message.content"] ?? a["gen_ai.completion.0.content"] ?? a["ai.response.text"];
|
|
248098
248592
|
return typeof text31 === "string" && text31.trim() ? text31 : void 0;
|
|
248099
248593
|
}
|
|
248100
248594
|
function inputOf(a, span3) {
|
|
248101
248595
|
const event3 = span3.events?.find((e) => e.name === "gen_ai.content.prompt")?.attributes?.find((x) => x.key === "gen_ai.prompt")?.value;
|
|
248102
|
-
let messages7 =
|
|
248596
|
+
let messages7 = parse27(a["gen_ai.input.messages"] ?? a["gen_ai.prompt"] ?? a["ai.prompt.messages"] ?? value5(event3));
|
|
248103
248597
|
if (!Array.isArray(messages7)) {
|
|
248104
248598
|
messages7 = [];
|
|
248105
248599
|
for (const [key5, v] of Object.entries(a)) {
|
|
@@ -248112,9 +248606,9 @@ function inputOf(a, span3) {
|
|
|
248112
248606
|
return out.length ? out : void 0;
|
|
248113
248607
|
}
|
|
248114
248608
|
function toolDefinitions(a) {
|
|
248115
|
-
let list19 =
|
|
248609
|
+
let list19 = parse27(a["gen_ai.tool.definitions"]);
|
|
248116
248610
|
if (!Array.isArray(list19)) {
|
|
248117
|
-
list19 = Object.entries(a).filter(([k]) => /^llm\.tools\.\d+\.tool\.json_schema$/.test(k)).map(([, v]) =>
|
|
248611
|
+
list19 = Object.entries(a).filter(([k]) => /^llm\.tools\.\d+\.tool\.json_schema$/.test(k)).map(([, v]) => parse27(v)).map((d) => d?.function ?? d);
|
|
248118
248612
|
}
|
|
248119
248613
|
const tools2 = list19.filter((d) => d && typeof d === "object" && d.name).map((d) => ({
|
|
248120
248614
|
name: d.name,
|
|
@@ -248124,11 +248618,11 @@ function toolDefinitions(a) {
|
|
|
248124
248618
|
return tools2.length ? tools2 : void 0;
|
|
248125
248619
|
}
|
|
248126
248620
|
function invocationOf(a) {
|
|
248127
|
-
const prompt =
|
|
248128
|
-
const rawInput =
|
|
248621
|
+
const prompt = parse27(a["ai.prompt"]);
|
|
248622
|
+
const rawInput = parse27(a["gen_ai.input.messages"] ?? a["input.value"] ?? a["traceloop.entity.input"]) ?? (prompt && typeof prompt === "object" ? prompt.messages ?? (prompt.prompt !== void 0 ? [{ role: "user", content: prompt.prompt }] : void 0) : prompt);
|
|
248129
248623
|
const list19 = typeof rawInput === "string" ? [{ role: "user", content: rawInput }] : Array.isArray(rawInput) ? rawInput : rawInput?.messages ?? (rawInput?.input !== void 0 ? [{ role: "user", content: rawInput.input }] : []);
|
|
248130
248624
|
const input5 = conversation2(list19);
|
|
248131
|
-
const rawOutput =
|
|
248625
|
+
const rawOutput = parse27(a["gen_ai.output.messages"] ?? a["output.value"] ?? a["traceloop.entity.output"] ?? a["ai.response.text"]);
|
|
248132
248626
|
const output2 = typeof rawOutput === "string" ? rawOutput : lastAnswer(conversation2(Array.isArray(rawOutput) ? rawOutput : rawOutput?.messages ?? [rawOutput]).messages);
|
|
248133
248627
|
const instructions = a["gen_ai.system_instructions"] ?? prompt?.system;
|
|
248134
248628
|
return { input: input5, output: output2, system: input5.system || instructions !== void 0, namesUser: input5.namesUser || namesSomeone(instructions) };
|
|
@@ -248163,7 +248657,7 @@ function traceToIr3(traceId, { agent, environment: environment3, spans }, { offs
|
|
|
248163
248657
|
id: span3.spanId,
|
|
248164
248658
|
ms: ms2,
|
|
248165
248659
|
service: a["ancha.inbound.service"],
|
|
248166
|
-
payload:
|
|
248660
|
+
payload: parse27(a["ancha.http.request.body"]),
|
|
248167
248661
|
// The app's own endpoints are told apart by route; vendor webhooks by their service.
|
|
248168
248662
|
...a["ancha.inbound.service"] === "app" && a["http.route"] && { route: a["http.route"], method: a["http.request.method"] }
|
|
248169
248663
|
});
|
|
@@ -248175,12 +248669,12 @@ function traceToIr3(traceId, { agent, environment: environment3, spans }, { offs
|
|
|
248175
248669
|
service: a["ancha.service"] ?? serviceOf(a["url.full"]),
|
|
248176
248670
|
method: a["http.request.method"],
|
|
248177
248671
|
url: a["url.full"],
|
|
248178
|
-
request: { body:
|
|
248179
|
-
response: { status: a["http.response.status_code"], body:
|
|
248672
|
+
request: { body: parse27(a["ancha.http.request.body"]) },
|
|
248673
|
+
response: { status: a["http.response.status_code"], body: parse27(a["ancha.http.response.body"]) }
|
|
248180
248674
|
});
|
|
248181
248675
|
else if (kind2 === "tool") {
|
|
248182
248676
|
records5.push({ id: span3.spanId, source_index: sourceIndex.get(span3), ms: ms2, endMs, ...toolOf2(a, span3) });
|
|
248183
|
-
if (a["url.full"]) records5.push({ kind: "call", id: `${span3.spanId}:http`, parent: span3.spanId, ms: ms2, endMs, service: a["ancha.service"] ?? serviceOf(a["url.full"]), method: a["http.request.method"], url: a["url.full"], request: { body:
|
|
248677
|
+
if (a["url.full"]) records5.push({ kind: "call", id: `${span3.spanId}:http`, parent: span3.spanId, ms: ms2, endMs, service: a["ancha.service"] ?? serviceOf(a["url.full"]), method: a["http.request.method"], url: a["url.full"], request: { body: parse27(a["ancha.http.request.body"]) }, response: { status: a["http.response.status_code"], body: parse27(a["ancha.http.response.body"]) } });
|
|
248184
248678
|
} else if (kind2 === "invocation") {
|
|
248185
248679
|
const isRoot3 = !span3.parentSpanId || !ids2.has(span3.parentSpanId);
|
|
248186
248680
|
if (!invocation || isRoot3 && !invocationIsRoot) {
|
|
@@ -248189,7 +248683,7 @@ function traceToIr3(traceId, { agent, environment: environment3, spans }, { offs
|
|
|
248189
248683
|
}
|
|
248190
248684
|
} else if (kind2 === "llm") {
|
|
248191
248685
|
const input5 = inputOf(a, span3), tools2 = toolDefinitions(a), output2 = outputOf(a);
|
|
248192
|
-
const messages7 = [...conversation2(
|
|
248686
|
+
const messages7 = [...conversation2(parse27(a["gen_ai.input.messages"] ?? a["gen_ai.prompt"] ?? a["ai.prompt.messages"])).messages, ...conversation2(parse27(a["gen_ai.output.messages"])).messages];
|
|
248193
248687
|
records5.push({
|
|
248194
248688
|
kind: "llm",
|
|
248195
248689
|
id: span3.spanId,
|
|
@@ -248233,7 +248727,7 @@ function traceToIr3(traceId, { agent, environment: environment3, spans }, { offs
|
|
|
248233
248727
|
function otlpToIr(batches) {
|
|
248234
248728
|
return [...spansByTrace(batches)].map(([traceId, trace2]) => ({ traceId, lines: traceToIr3(traceId, trace2) }));
|
|
248235
248729
|
}
|
|
248236
|
-
var value5,
|
|
248730
|
+
var value5, parse27, nanos, endNanos, MODEL_OPERATIONS, AI_SDK_CALL, AI_SDK_MODEL;
|
|
248237
248731
|
var init_otlp = __esm({
|
|
248238
248732
|
"cloud/rebuild/adapters/otlp.mjs"() {
|
|
248239
248733
|
"use strict";
|
|
@@ -248241,7 +248735,7 @@ var init_otlp = __esm({
|
|
|
248241
248735
|
init_messages3();
|
|
248242
248736
|
init_tool_evidence();
|
|
248243
248737
|
value5 = (v) => v?.stringValue ?? (v?.intValue !== void 0 ? Number(v.intValue) : v?.doubleValue ?? v?.boolValue);
|
|
248244
|
-
|
|
248738
|
+
parse27 = (text31) => {
|
|
248245
248739
|
if (typeof text31 !== "string") return text31;
|
|
248246
248740
|
try {
|
|
248247
248741
|
return JSON.parse(text31);
|
|
@@ -248920,7 +249414,7 @@ function readTraceImport(text31, name5 = "upload") {
|
|
|
248920
249414
|
function readImportChecks(text31) {
|
|
248921
249415
|
let doc;
|
|
248922
249416
|
try {
|
|
248923
|
-
doc = (0,
|
|
249417
|
+
doc = (0, import_yaml19.parse)(text31);
|
|
248924
249418
|
} catch {
|
|
248925
249419
|
throw new AnchaError("USAGE", "--checks must contain a YAML or JSON list of checks");
|
|
248926
249420
|
}
|
|
@@ -248939,14 +249433,14 @@ function rebuildTraceImport(lines2, options5 = {}) {
|
|
|
248939
249433
|
parseScene(made.scene);
|
|
248940
249434
|
return made;
|
|
248941
249435
|
}
|
|
248942
|
-
var
|
|
249436
|
+
var import_yaml19;
|
|
248943
249437
|
var init_trace_import = __esm({
|
|
248944
249438
|
"backend/src/trace-import.ts"() {
|
|
248945
249439
|
"use strict";
|
|
248946
249440
|
init_src();
|
|
248947
249441
|
init_load();
|
|
248948
249442
|
init_rebuild();
|
|
248949
|
-
|
|
249443
|
+
import_yaml19 = __toESM(require_dist(), 1);
|
|
248950
249444
|
}
|
|
248951
249445
|
});
|
|
248952
249446
|
|
|
@@ -251711,7 +252205,7 @@ function attemptBlock(test3, a, open16) {
|
|
|
251711
252205
|
`<span>${a.exit === "exited" ? `exited ${a.exitCode === null ? "" : num4(a.exitCode)}` : code2(a.exit)}</span>`
|
|
251712
252206
|
].filter(Boolean).join("");
|
|
251713
252207
|
const summary = `<summary>${pill(o.cls, o.title)}<span class="att">Attempt ${a.n}</span><span class="meta">${meta6}</span></summary>`;
|
|
251714
|
-
const route15 = a.routes?.
|
|
252208
|
+
const route15 = ["quickbooks", "netsuite"].map((toolkit) => a.routes?.[toolkit] ? `<p class="muted" data-q>${esc2(formatRouteSummary(a.routes[toolkit], toolkit))}</p>` : "").join("");
|
|
251715
252209
|
const checks2 = a.checks.length ? `<div class="scroll"><table class="check-fields"><thead><tr><th scope="col">Check</th><th scope="col">Expected</th><th scope="col">Actual</th><th scope="col">Outcome</th></tr></thead><tbody>${a.checks.map((check4) => `<tr><th scope="row">${code2(check4.id)}</th><td>${q(check4.expected)}</td><td class="${check4.state === "failed" ? "fail-t" : ""}">${q(check4.actual)}${check4.why && check4.why !== check4.actual ? `<span class="why">${q(check4.why)}</span>` : ""}</td><td>${pill(check4.state === "passed" ? "ok" : check4.state === "failed" ? "no" : "ung", check4.state)}</td></tr>`).join("")}</tbody></table></div>` : '<p class="muted">\u2014</p>';
|
|
251716
252210
|
const issues = a.issues.length ? `<h4>Issues</h4><ul class="plain">${a.issues.map((issue9) => `<li>${q(issue9)}</li>`).join("")}</ul>` : "";
|
|
251717
252211
|
if (!a.recorded) return `<details class="attempt" id="${a.anchor}"${open16 ? " open" : ""}>${summary}<div class="att-body">${route15}${a.checks.length ? `<h4>Checks</h4>${checks2}` : ""}${issues}<p class="muted">No records for this attempt.</p></div></details>`;
|
|
@@ -251748,7 +252242,7 @@ function renderHtmlReport(input5) {
|
|
|
251748
252242
|
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="color-scheme" content="light dark"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'"><title>Run report ${esc2(d.runId)}</title><style>${CSS}</style></head>
|
|
251749
252243
|
<body><main class="page">
|
|
251750
252244
|
<header class="top"><div class="brand"><span class="wordmark">ancha</span><span class="what">Run report</span></div><code class="id">${esc2(d.runId)}</code>${verdictBlock(d)}</header>
|
|
251751
|
-
${d.routes?.
|
|
252245
|
+
${["quickbooks", "netsuite"].map((toolkit) => d.routes?.[toolkit] ? `<p class="muted" data-q>${esc2(formatRouteSummary(d.routes[toolkit], toolkit))}</p>` : "").join("")}
|
|
251752
252246
|
${failureAlert(d)}
|
|
251753
252247
|
${matrix(d)}
|
|
251754
252248
|
${machines(d)}
|
|
@@ -255842,6 +256336,10 @@ function connectionReport(detail3, logTail3, readsAnswer = false) {
|
|
|
255842
256336
|
});
|
|
255843
256337
|
}
|
|
255844
256338
|
}
|
|
256339
|
+
if (probe?.routeDetails?.length) {
|
|
256340
|
+
const agentCheck = checks2.find((check4) => check4.name === "agent");
|
|
256341
|
+
if (agentCheck) agentCheck.details = [...agentCheck.details ?? [], ...probe.routeDetails];
|
|
256342
|
+
}
|
|
255845
256343
|
if (probe?.tools !== void 0) {
|
|
255846
256344
|
checks2.push(...connectionToolChecks(probe));
|
|
255847
256345
|
if (probe.tools.length === 0) checks2.push({
|
|
@@ -257186,10 +257684,10 @@ init_scenes();
|
|
|
257186
257684
|
|
|
257187
257685
|
// packages/cli/src/kit/init.ts
|
|
257188
257686
|
import { constants as constants12 } from "node:fs";
|
|
257189
|
-
import { lstat as lstat10, mkdir as mkdir25, open as open11, readFile as
|
|
257687
|
+
import { lstat as lstat10, mkdir as mkdir25, open as open11, readFile as readFile42, rm as rm12, writeFile as writeFile26 } from "node:fs/promises";
|
|
257190
257688
|
import { join as join58 } from "node:path";
|
|
257191
257689
|
import { Writable } from "node:stream";
|
|
257192
|
-
var
|
|
257690
|
+
var import_yaml18 = __toESM(require_dist(), 1);
|
|
257193
257691
|
init_src();
|
|
257194
257692
|
|
|
257195
257693
|
// packages/cli/src/kit/seeds.ts
|
|
@@ -258472,6 +258970,26 @@ function netsuiteData(size2, options5 = {}) {
|
|
|
258472
258970
|
};
|
|
258473
258971
|
}
|
|
258474
258972
|
|
|
258973
|
+
// backend/src/kit/quickbooks-examples.ts
|
|
258974
|
+
var import_yaml14 = __toESM(require_dist(), 1);
|
|
258975
|
+
init_assets();
|
|
258976
|
+
import { readFile as readFile38 } from "node:fs/promises";
|
|
258977
|
+
var QUICKBOOKS_EXAMPLES = { world: "pellmont-building-services", tests: ["pellmont-duplicates", "pellmont-approved-merge"] };
|
|
258978
|
+
async function quickbooksExamples() {
|
|
258979
|
+
const read7 = (name5) => readFile38(new URL(`data/pellmont/${name5}.yaml`, assetRoot()), "utf8");
|
|
258980
|
+
const world5 = `ancha/worlds/${QUICKBOOKS_EXAMPLES.world}.yaml`;
|
|
258981
|
+
const tests = await Promise.all(QUICKBOOKS_EXAMPLES.tests.map(async (id14) => {
|
|
258982
|
+
const content2 = await read7(id14);
|
|
258983
|
+
return { file: `ancha/tests/${id14}.yaml`, title: String((0, import_yaml14.parse)(content2).title), content: content2 };
|
|
258984
|
+
}));
|
|
258985
|
+
return {
|
|
258986
|
+
id: QUICKBOOKS_EXAMPLES.world,
|
|
258987
|
+
world: world5,
|
|
258988
|
+
tests: tests.map(({ file: file3, title: title2 }) => ({ file: file3, title: title2 })),
|
|
258989
|
+
files: [{ relativePath: world5, content: await read7(QUICKBOOKS_EXAMPLES.world) }, ...tests.map(({ file: file3, content: content2 }) => ({ relativePath: file3, content: content2 }))]
|
|
258990
|
+
};
|
|
258991
|
+
}
|
|
258992
|
+
|
|
258475
258993
|
// packages/cli/src/kit/init.ts
|
|
258476
258994
|
init_task_input();
|
|
258477
258995
|
init_config();
|
|
@@ -258481,11 +258999,11 @@ init_agent_tools3();
|
|
|
258481
258999
|
init_src2();
|
|
258482
259000
|
|
|
258483
259001
|
// packages/cli/src/commands/world-gen.ts
|
|
258484
|
-
var
|
|
259002
|
+
var import_yaml15 = __toESM(require_dist(), 1);
|
|
258485
259003
|
init_src();
|
|
258486
259004
|
import { createHash as createHash74 } from "node:crypto";
|
|
258487
259005
|
import { existsSync as existsSync2 } from "node:fs";
|
|
258488
|
-
import { mkdir as mkdir23, readFile as
|
|
259006
|
+
import { mkdir as mkdir23, readFile as readFile39, writeFile as writeFile24 } from "node:fs/promises";
|
|
258489
259007
|
import { dirname as dirname22, join as join56, relative as relative19, resolve as resolve44 } from "node:path";
|
|
258490
259008
|
async function model(ctx) {
|
|
258491
259009
|
const env2 = ctx.io.env;
|
|
@@ -258555,11 +259073,11 @@ async function worldGen(ctx, description2, options5) {
|
|
|
258555
259073
|
const request2 = { description: description2, id: options5.id ?? null, tools: tools2 ?? null, size: size2, variants, from: options5.from ?? null };
|
|
258556
259074
|
const keyFile = options5.idempotencyKey === void 0 ? void 0 : join56(ctx.io.cwd, ".ancha", "world-gen", `${createHash74("sha256").update(options5.idempotencyKey).digest("hex").slice(0, 32)}.json`);
|
|
258557
259075
|
if (keyFile && existsSync2(keyFile)) {
|
|
258558
|
-
const saved = JSON.parse(await
|
|
259076
|
+
const saved = JSON.parse(await readFile39(keyFile, "utf8"));
|
|
258559
259077
|
if (JSON.stringify(saved.request) !== JSON.stringify(request2)) throw new AnchaError("USAGE", "this --idempotency-key was used with different arguments", { hint: "use a new key for a new request" });
|
|
258560
259078
|
if (saved.result.files.every((file3) => existsSync2(resolve44(ctx.io.cwd, file3)))) return report5(ctx, { ...saved.result, reused: true });
|
|
258561
259079
|
}
|
|
258562
|
-
const from = options5.from === void 0 ? void 0 : parseWorldFile((0,
|
|
259080
|
+
const from = options5.from === void 0 ? void 0 : parseWorldFile((0, import_yaml15.parse)(await readFile39(resolve44(ctx.io.cwd, options5.from), "utf8")));
|
|
258563
259081
|
if (options5.id && !options5.force && existsSync2(join56(outDir, `${options5.id}.yaml`))) throw exists4(join56(outDir, `${options5.id}.yaml`), ctx);
|
|
258564
259082
|
const { client: client2, credit } = await model(ctx);
|
|
258565
259083
|
ctx.out.info(`generating a world from the description (size ${size2}${variants ? `, ${variants} variant${variants === 1 ? "" : "s"}` : ""})`);
|
|
@@ -258616,17 +259134,17 @@ function report5(ctx, result) {
|
|
|
258616
259134
|
}
|
|
258617
259135
|
|
|
258618
259136
|
// packages/cli/src/commands/test-new.ts
|
|
258619
|
-
var
|
|
259137
|
+
var import_yaml17 = __toESM(require_dist(), 1);
|
|
258620
259138
|
import { createHash as createHash76 } from "node:crypto";
|
|
258621
259139
|
import { existsSync as existsSync3 } from "node:fs";
|
|
258622
|
-
import { mkdir as mkdir24, readFile as
|
|
259140
|
+
import { mkdir as mkdir24, readFile as readFile40, readdir as readdir10, writeFile as writeFile25 } from "node:fs/promises";
|
|
258623
259141
|
import { join as join57, relative as relative20, resolve as resolve45 } from "node:path";
|
|
258624
259142
|
init_src();
|
|
258625
259143
|
|
|
258626
259144
|
// backend/src/kit/test-draft.ts
|
|
258627
259145
|
init_src();
|
|
258628
259146
|
init_src2();
|
|
258629
|
-
var
|
|
259147
|
+
var import_yaml16 = __toESM(require_dist(), 1);
|
|
258630
259148
|
init_backend();
|
|
258631
259149
|
import { createHash as createHash75 } from "node:crypto";
|
|
258632
259150
|
var MAX_REFS = 80;
|
|
@@ -259000,7 +259518,7 @@ function testYaml2(test3, intent) {
|
|
|
259000
259518
|
const order6 = ["version", "id", "title", "world", "start", "attempts", "until", "deadline", "timeout", "checks", "pass", "generated"];
|
|
259001
259519
|
const sorted2 = Object.fromEntries(order6.filter((key5) => test3[key5] !== void 0).map((key5) => [key5, test3[key5]]));
|
|
259002
259520
|
return `# ${intent.replace(/\s+/g, " ").trim()}
|
|
259003
|
-
${(0,
|
|
259521
|
+
${(0, import_yaml16.stringify)(sorted2, { lineWidth: 0 })}`;
|
|
259004
259522
|
}
|
|
259005
259523
|
|
|
259006
259524
|
// packages/cli/src/commands/test-new.ts
|
|
@@ -259029,7 +259547,7 @@ async function chooseWorld(ctx, id14, command = 'ancha test new "<sentence>"') {
|
|
|
259029
259547
|
const path9 = join57(dir2, `${chosen}.yaml`);
|
|
259030
259548
|
if (!existsSync3(path9)) throw new AnchaError("USAGE", `no world ${chosen} in ancha/worlds`, { hint: ids2.length ? `worlds: ${ids2.join(", ")}` : noWorldHint });
|
|
259031
259549
|
try {
|
|
259032
|
-
return parseWorldFile((0,
|
|
259550
|
+
return parseWorldFile((0, import_yaml17.parse)(await readFile40(path9, "utf8")));
|
|
259033
259551
|
} catch (error65) {
|
|
259034
259552
|
throw new AnchaError("SCENE_INVALID", `ancha/worlds/${chosen}.yaml: ${error65 instanceof Error ? error65.message : String(error65)}`, { hint: "run `ancha schema world` for the world file format" });
|
|
259035
259553
|
}
|
|
@@ -259064,7 +259582,7 @@ async function testNew(ctx, intent, options5) {
|
|
|
259064
259582
|
const request2 = { intent, world: world5.id, id: options5.id ?? null, out: relative20(ctx.io.cwd, outDir) };
|
|
259065
259583
|
const keyFile = options5.idempotencyKey === void 0 ? void 0 : join57(ctx.io.cwd, ".ancha", "test-new", `${createHash76("sha256").update(options5.idempotencyKey).digest("hex").slice(0, 32)}.json`);
|
|
259066
259584
|
if (keyFile && existsSync3(keyFile)) {
|
|
259067
|
-
const saved = JSON.parse(await
|
|
259585
|
+
const saved = JSON.parse(await readFile40(keyFile, "utf8"));
|
|
259068
259586
|
if (JSON.stringify(saved.request) !== JSON.stringify(request2)) throw new AnchaError("USAGE", "this --idempotency-key was used with different arguments", { hint: "use a new key for a new request" });
|
|
259069
259587
|
if ([saved.result.file, saved.result.record].every((file4) => existsSync3(resolve45(ctx.io.cwd, file4)))) return report6(ctx, { ...saved.result, reused: true });
|
|
259070
259588
|
}
|
|
@@ -259074,7 +259592,7 @@ async function testNew(ctx, intent, options5) {
|
|
|
259074
259592
|
const draft2 = await draftTest({ intent, world: world5, model: client2, ...options5.id && { id: options5.id }, onProgress: (line2) => ctx.out.info(` ${line2}`) });
|
|
259075
259593
|
const path9 = join57(outDir, `${draft2.test.id}.yaml`), recordPath = join57(outDir, `${draft2.test.id}.gen.json`);
|
|
259076
259594
|
if (existsSync3(path9) && !options5.force) throw exists5(ctx, path9);
|
|
259077
|
-
const before = existsSync3(path9) ? await
|
|
259595
|
+
const before = existsSync3(path9) ? await readFile40(path9, "utf8") : "";
|
|
259078
259596
|
const at6 = (/* @__PURE__ */ new Date()).toISOString();
|
|
259079
259597
|
const yaml = testYaml2({ ...draft2.test, generated: { by: "ancha test new", at: at6, from: intent, record: `${draft2.test.id}.gen.json` } }, intent);
|
|
259080
259598
|
const cost = Math.round(draft2.calls.reduce((sum6, call4) => sum6 + call4.costUsd, 0) * 1e6) / 1e6;
|
|
@@ -259141,14 +259659,17 @@ function sceneWorld(scene2, id14 = scene2.id) {
|
|
|
259141
259659
|
});
|
|
259142
259660
|
}
|
|
259143
259661
|
|
|
259662
|
+
// packages/cli/src/kit/init.ts
|
|
259663
|
+
init_scenes();
|
|
259664
|
+
|
|
259144
259665
|
// packages/cli/src/kit/docs.ts
|
|
259145
259666
|
init_src();
|
|
259146
259667
|
init_assets();
|
|
259147
|
-
import { readFile as
|
|
259668
|
+
import { readFile as readFile41 } from "node:fs/promises";
|
|
259148
259669
|
var DOC_TOPICS = ["setup", "apps", "run", "traces", "explain", "compare", "tests", "scenes", "integrations", "cloud", "playgrounds", "cli-quickstart", "tools", "datasets", "company"];
|
|
259149
259670
|
async function loadDoc(topic = "setup") {
|
|
259150
259671
|
if (!DOC_TOPICS.includes(topic)) throw new AnchaError("USAGE", `unknown docs topic: ${topic}`, { hint: `available topics: ${DOC_TOPICS.join(", ")}` });
|
|
259151
|
-
return { topics: [...DOC_TOPICS], topic, markdown: await
|
|
259672
|
+
return { topics: [...DOC_TOPICS], topic, markdown: await readFile41(new URL(`docs/${topic === "tests" ? "scenes" : topic}.md`, assetRoot()), "utf8") };
|
|
259152
259673
|
}
|
|
259153
259674
|
function registerDocs(program2, ctx) {
|
|
259154
259675
|
program2.command("docs").description("read the bundled documentation: setup, the run loop, checks, SDK settings and the hosted workspace").argument("[topic]", `available: ${DOC_TOPICS.join(", ")}`).action(async (topic) => {
|
|
@@ -259169,7 +259690,7 @@ function step2(ctx) {
|
|
|
259169
259690
|
}
|
|
259170
259691
|
var BEGIN = "<!-- ancha:begin -->";
|
|
259171
259692
|
var END = "<!-- ancha:end -->";
|
|
259172
|
-
var managedSection = () =>
|
|
259693
|
+
var managedSection = () => readFile42(new URL("agents-section.md", assetRoot()), "utf8");
|
|
259173
259694
|
async function installAgents(cwd, tools2) {
|
|
259174
259695
|
const target6 = join58(cwd, "AGENTS.md");
|
|
259175
259696
|
const base6 = await managedSection();
|
|
@@ -259182,7 +259703,7 @@ Read \`ancha docs tools\` for function checks and registration.
|
|
|
259182
259703
|
const managed = base6.replace(END, wiring + END);
|
|
259183
259704
|
let original2;
|
|
259184
259705
|
try {
|
|
259185
|
-
original2 = await
|
|
259706
|
+
original2 = await readFile42(target6, "utf8");
|
|
259186
259707
|
} catch (error65) {
|
|
259187
259708
|
if (error65.code !== "ENOENT") throw error65;
|
|
259188
259709
|
const result = await applyScaffold(cwd, [{ relativePath: "AGENTS.md", content: managed }]);
|
|
@@ -259211,7 +259732,7 @@ async function ignoreAnchaDirectory(cwd) {
|
|
|
259211
259732
|
const target6 = join58(cwd, ".gitignore");
|
|
259212
259733
|
let original2;
|
|
259213
259734
|
try {
|
|
259214
|
-
original2 = await
|
|
259735
|
+
original2 = await readFile42(target6, "utf8");
|
|
259215
259736
|
} catch (error65) {
|
|
259216
259737
|
if (error65.code !== "ENOENT") throw error65;
|
|
259217
259738
|
const result = await applyScaffold(cwd, [{ relativePath: ".gitignore", content: ".ancha/\n" }]);
|
|
@@ -259269,10 +259790,11 @@ var ACCESS = {
|
|
|
259269
259790
|
};
|
|
259270
259791
|
var accessId = (twin) => `${twin.replace(/-/g, "_")}_access`;
|
|
259271
259792
|
var hasAccessCheck = (twin) => STARTER_TWINS.includes(twin) || ACCESS[twin] !== void 0;
|
|
259272
|
-
|
|
259793
|
+
var ROUTED_TASKS = { quickbooks: "QuickBooks Online: list the company's open invoices.", netsuite: "NetSuite: list five customers by name." };
|
|
259794
|
+
async function starterPack(id14, title2, twins, routed = []) {
|
|
259273
259795
|
const files2 = await templateFiles("starter");
|
|
259274
259796
|
const source = files2.find((file3) => file3.relativePath === "scene.yaml");
|
|
259275
|
-
const raw3 = (0,
|
|
259797
|
+
const raw3 = (0, import_yaml18.parse)(source.content);
|
|
259276
259798
|
const tasks = JSON.parse(files2.find((file3) => file3.relativePath === "tasks.json").content);
|
|
259277
259799
|
const checks2 = twins.flatMap((twin) => STARTER_TWINS.includes(twin) ? raw3.checks.filter((check4) => check4.id === accessId(twin)) : ACCESS[twin] === void 0 ? [] : [{ id: accessId(twin), trace: { called: ACCESS[twin] } }]);
|
|
259278
259800
|
const scene2 = {
|
|
@@ -259280,26 +259802,26 @@ async function starterPack(id14, title2, twins) {
|
|
|
259280
259802
|
id: id14,
|
|
259281
259803
|
title: title2,
|
|
259282
259804
|
twins,
|
|
259283
|
-
task:
|
|
259284
|
-
${twins.map((twin) => tasks[twin] ?? `${toolName(twin)}: read its data through the native API.`).join("\n")}`,
|
|
259805
|
+
task: `${routed.length ? "Read from each system below and report what you found. Change nothing." : "Discover resources through the declared native service APIs. Use only Ancha's runtime-provided local URLs and fake credentials."}
|
|
259806
|
+
${twins.map((twin) => (routed.includes(twin) ? ROUTED_TASKS[twin] : void 0) ?? tasks[twin] ?? `${toolName(twin)}: read its data through the native API.`).join("\n")}`,
|
|
259285
259807
|
seed: Object.fromEntries(twins.map((twin) => [twin, raw3.seed[twin] ?? exampleSeed(twin)])),
|
|
259286
259808
|
checks: checks2,
|
|
259287
259809
|
pass: checks2.map((check4) => check4.id)
|
|
259288
259810
|
};
|
|
259289
259811
|
parseScene(scene2);
|
|
259290
|
-
source.content = (0,
|
|
259812
|
+
source.content = (0, import_yaml18.stringify)(scene2, { lineWidth: 0 });
|
|
259291
259813
|
const oracle = files2.find((file3) => file3.relativePath === "oracle.mjs");
|
|
259292
259814
|
if (oracle) oracle.content = oracle.content.replace("const graphTools = ['microsoft-word'];", `const graphTools = ${JSON.stringify(twins.filter((t) => t === "microsoft-word" || t === "outlook"))};`);
|
|
259293
259815
|
return files2;
|
|
259294
259816
|
}
|
|
259295
259817
|
var STARTER_FILES = ["scene.yaml", "oracle.mjs", "null.mjs"];
|
|
259296
259818
|
async function ownStarter(cwd) {
|
|
259297
|
-
const read7 = (name5) =>
|
|
259819
|
+
const read7 = (name5) => readFile42(join58(cwd, "scenes/starter", name5), "utf8").catch(() => void 0);
|
|
259298
259820
|
const scene2 = await read7("scene.yaml");
|
|
259299
259821
|
if (scene2 === void 0) return void 0;
|
|
259300
259822
|
let twins;
|
|
259301
259823
|
try {
|
|
259302
|
-
twins = (0,
|
|
259824
|
+
twins = (0, import_yaml18.parse)(scene2).twins;
|
|
259303
259825
|
} catch {
|
|
259304
259826
|
return void 0;
|
|
259305
259827
|
}
|
|
@@ -259315,6 +259837,56 @@ function parseData(value6) {
|
|
|
259315
259837
|
return { size: match3[1] ?? "m" };
|
|
259316
259838
|
}
|
|
259317
259839
|
var TESTS_GLOB = "ancha/tests/*.yaml";
|
|
259840
|
+
var composioStarterNext = (cloud, all9 = false) => [
|
|
259841
|
+
...cloud ? [] : ["ancha login"],
|
|
259842
|
+
"ancha secrets set COMPOSIO_API_KEY",
|
|
259843
|
+
"ancha agent upload",
|
|
259844
|
+
all9 ? "ancha run" : "ancha run scenes/starter/scene.yaml"
|
|
259845
|
+
];
|
|
259846
|
+
async function wireComposio(cwd, candidates) {
|
|
259847
|
+
const added = [], pending = [];
|
|
259848
|
+
const result = { added, pending, passEnvAdded: false };
|
|
259849
|
+
if (!candidates.length) return result;
|
|
259850
|
+
const text31 = await readFile42(join58(cwd, "ancha.yaml"), "utf8");
|
|
259851
|
+
let config12;
|
|
259852
|
+
try {
|
|
259853
|
+
config12 = parseConfigText(text31);
|
|
259854
|
+
} catch {
|
|
259855
|
+
pending.push(...candidates.map((tool) => ({ tool, fix: `Validate ancha.yaml, then set agent.routes.${tool}: composio and add COMPOSIO_API_KEY to agent.pass_env.` })));
|
|
259856
|
+
return result;
|
|
259857
|
+
}
|
|
259858
|
+
if (config12.agent?.mode === "endpoint" || !config12.agent?.command) {
|
|
259859
|
+
pending.push(...candidates.map((tool) => ({ tool, fix: `Set agent.command, then run ancha init to wire agent.routes.${tool}.` })));
|
|
259860
|
+
return result;
|
|
259861
|
+
}
|
|
259862
|
+
const paths3 = await glob3(config12.scenes, { cwd, onlyFiles: true, followSymbolicLinks: false });
|
|
259863
|
+
const worlds2 = await loadScenes(cwd, paths3).then((scenes) => scenes.map(({ scene: scene2 }) => scene2.twins), () => []);
|
|
259864
|
+
const doc = (0, import_yaml18.parseDocument)(text31);
|
|
259865
|
+
for (const tool of candidates) {
|
|
259866
|
+
if (doc.hasIn(["agent", "routes", tool])) continue;
|
|
259867
|
+
if (!worlds2.some((tools2) => tools2.includes(tool))) {
|
|
259868
|
+
pending.push({ tool, fix: `Add a test whose world has ${toolName(tool)}, then run ancha init to set agent.routes.${tool}: composio.` });
|
|
259869
|
+
continue;
|
|
259870
|
+
}
|
|
259871
|
+
doc.setIn(["agent", "routes", tool], "composio");
|
|
259872
|
+
added.push(tool);
|
|
259873
|
+
}
|
|
259874
|
+
if (!added.length) return result;
|
|
259875
|
+
const passEnv = doc.getIn(["agent", "pass_env"]);
|
|
259876
|
+
if ((0, import_yaml18.isSeq)(passEnv)) {
|
|
259877
|
+
if (!passEnv.items.some((item2) => String(item2) === "COMPOSIO_API_KEY")) {
|
|
259878
|
+
passEnv.add("COMPOSIO_API_KEY");
|
|
259879
|
+
result.passEnvAdded = true;
|
|
259880
|
+
}
|
|
259881
|
+
} else {
|
|
259882
|
+
doc.setIn(["agent", "pass_env"], ["COMPOSIO_API_KEY"]);
|
|
259883
|
+
result.passEnvAdded = true;
|
|
259884
|
+
}
|
|
259885
|
+
const next2 = doc.toString({ lineWidth: 0 });
|
|
259886
|
+
parseConfigText(next2);
|
|
259887
|
+
await rewrite(cwd, "ancha.yaml", next2);
|
|
259888
|
+
return result;
|
|
259889
|
+
}
|
|
259318
259890
|
async function rewrite(cwd, relativePath, content2) {
|
|
259319
259891
|
await preflightFiles(cwd, [{ relativePath, content: "" }]);
|
|
259320
259892
|
const handle31 = await open11(join58(cwd, relativePath), constants12.O_WRONLY | constants12.O_TRUNC | constants12.O_NOFOLLOW);
|
|
@@ -259325,7 +259897,7 @@ async function rewrite(cwd, relativePath, content2) {
|
|
|
259325
259897
|
}
|
|
259326
259898
|
}
|
|
259327
259899
|
async function listTests(cwd, tests) {
|
|
259328
|
-
const text31 = await
|
|
259900
|
+
const text31 = await readFile42(join58(cwd, "ancha.yaml"), "utf8");
|
|
259329
259901
|
let scenes;
|
|
259330
259902
|
try {
|
|
259331
259903
|
scenes = parseConfigText(text31).scenes;
|
|
@@ -259334,9 +259906,9 @@ async function listTests(cwd, tests) {
|
|
|
259334
259906
|
}
|
|
259335
259907
|
const found = new Set(await glob3(scenes, { cwd, onlyFiles: true, followSymbolicLinks: false }));
|
|
259336
259908
|
if (tests.every((test3) => found.has(test3))) return false;
|
|
259337
|
-
const doc = (0,
|
|
259909
|
+
const doc = (0, import_yaml18.parseDocument)(text31);
|
|
259338
259910
|
const node5 = doc.get("scenes", true);
|
|
259339
|
-
if ((0,
|
|
259911
|
+
if ((0, import_yaml18.isSeq)(node5)) node5.add(doc.createNode(TESTS_GLOB));
|
|
259340
259912
|
else {
|
|
259341
259913
|
const list19 = doc.createNode([...scenes, TESTS_GLOB]);
|
|
259342
259914
|
list19.flow = true;
|
|
@@ -259352,7 +259924,7 @@ async function listTests(cwd, tests) {
|
|
|
259352
259924
|
return true;
|
|
259353
259925
|
}
|
|
259354
259926
|
async function addExampleSeeds(file3, twins) {
|
|
259355
|
-
const doc = (0,
|
|
259927
|
+
const doc = (0, import_yaml18.parseDocument)(await readFile42(file3, "utf8"));
|
|
259356
259928
|
const added = [], skipped = [];
|
|
259357
259929
|
for (const twin of twins) {
|
|
259358
259930
|
if (doc.hasIn(["seed", twin])) continue;
|
|
@@ -259427,7 +259999,7 @@ async function wireExistingConfig(cwd, fillMissing) {
|
|
|
259427
259999
|
const target6 = join58(cwd, "ancha.yaml");
|
|
259428
260000
|
let text31;
|
|
259429
260001
|
try {
|
|
259430
|
-
text31 = await
|
|
260002
|
+
text31 = await readFile42(target6, "utf8");
|
|
259431
260003
|
} catch {
|
|
259432
260004
|
return void 0;
|
|
259433
260005
|
}
|
|
@@ -259442,7 +260014,7 @@ async function wireExistingConfig(cwd, fillMissing) {
|
|
|
259442
260014
|
if (!fillMissing || task2.wiring?.command !== void 0 || Object.keys(task2.wiring?.env ?? {}).some((name5) => Object.hasOwn(agent.env ?? {}, name5))) task2.wiring = null;
|
|
259443
260015
|
if (!fillMissing) task2.stdin = null;
|
|
259444
260016
|
if (task2.wiring === null && task2.stdin === null) return task2;
|
|
259445
|
-
const doc = (0,
|
|
260017
|
+
const doc = (0, import_yaml18.parseDocument)(text31);
|
|
259446
260018
|
for (const [name5, value6] of Object.entries(task2.wiring?.env ?? {})) doc.setIn(["agent", "env", name5], value6);
|
|
259447
260019
|
if (task2.stdin !== null) doc.setIn(["agent", "input"], "stdin");
|
|
259448
260020
|
const next2 = doc.toString({ lineWidth: 0 });
|
|
@@ -259461,7 +260033,7 @@ async function wireExistingConfig(cwd, fillMissing) {
|
|
|
259461
260033
|
return task2;
|
|
259462
260034
|
}
|
|
259463
260035
|
function registerKit(program2, ctx) {
|
|
259464
|
-
program2.command("init").description("set up agent tests in this project: ancha.yaml, a starter test for the tools it uses, coding-agent instructions; installs and runs nothing").option("--on <target>", "use local setup and starter tests: local").option("--agent <command>", "the command that starts your agent (default: project scripts, README usage, Procfile, Dockerfile, langgraph.json or a single entry file)").option("--template <template>", "starter or incidents", "starter").option("--tools <tools>", "the tools your agent uses, comma-separated (e.g. netsuite,slack), in place of the ones init finds in its dependencies and source").option("--data <data>", "for an agent that uses NetSuite, in a project with no tests: netsuite-pe:s, netsuite-pe:m (the default) or netsuite-pe:l, the NetSuite world init writes with its 25 tests; none leaves them out").option("--intent <description>", "also generate a world (company, people, tool history) from this description and draft a first test with people for it (uses a model)").option("--idempotency-key <key>", "with --intent: return the first world and test for a repeated request instead of generating again").action(async (opts, command) => {
|
|
260036
|
+
program2.command("init").description("set up agent tests in this project: ancha.yaml, a starter test for the tools it uses, coding-agent instructions; installs and runs nothing").option("--on <target>", "use local setup and starter tests: local").option("--agent <command>", "the command that starts your agent (default: project scripts, README usage, Procfile, Dockerfile, langgraph.json or a single entry file)").option("--template <template>", "starter or incidents", "starter").option("--tools <tools>", "the tools your agent uses, comma-separated (e.g. netsuite,slack), in place of the ones init finds in its dependencies and source").option("--data <data>", "for an agent that uses NetSuite, in a project with no tests: netsuite-pe:s, netsuite-pe:m (the default) or netsuite-pe:l, the NetSuite world init writes with its 25 tests; none leaves them out, and the QuickBooks examples too").option("--intent <description>", "also generate a world (company, people, tool history) from this description and draft a first test with people for it (uses a model)").option("--idempotency-key <key>", "with --intent: return the first world and test for a repeated request instead of generating again").action(async (opts, command) => {
|
|
259465
260037
|
if (opts.on !== void 0 && opts.on !== "local") throw new AnchaError("USAGE", "init --on expects local", { hint: "run ancha init --on local for local setup, or ancha init for your linked workspace" });
|
|
259466
260038
|
if (opts.template !== "starter" && opts.template !== "incidents") throw new AnchaError("USAGE", `unknown template: ${opts.template}`, { hint: "available templates: starter, incidents" });
|
|
259467
260039
|
const given2 = opts.tools === void 0 ? void 0 : parseTools(opts.tools);
|
|
@@ -259470,7 +260042,7 @@ function registerKit(program2, ctx) {
|
|
|
259470
260042
|
throw new AnchaError("CONFIG_INVALID", "init --intent needs a model key", { hint: "set OPENROUTER_API_KEY, or log in to your workspace with ancha login; or run ancha init without --intent" });
|
|
259471
260043
|
}
|
|
259472
260044
|
const detection = await detectProject(ctx.io.cwd, opts.agent);
|
|
259473
|
-
const configText = await
|
|
260045
|
+
const configText = await readFile42(join58(ctx.io.cwd, "ancha.yaml"), "utf8").catch(() => void 0);
|
|
259474
260046
|
const configured = configText !== void 0;
|
|
259475
260047
|
let task2 = configured || detection.slackApp !== void 0 || detection.agent === null ? void 0 : await taskSetup(ctx.io.cwd, detection.agent, { command: detection.agent });
|
|
259476
260048
|
const existingConfig = (() => {
|
|
@@ -259484,44 +260056,47 @@ function registerKit(program2, ctx) {
|
|
|
259484
260056
|
const scan2 = task2?.scan ?? (existingAgent?.command ? await scanTaskInput(ctx.io.cwd, existingAgent.command).catch(() => void 0) : void 0);
|
|
259485
260057
|
const found = toolsOf({ detection, scan: scan2, env: existingAgent?.env });
|
|
259486
260058
|
const used = given2 ?? found.tools;
|
|
260059
|
+
const routeTools = (detection.composio?.tools ?? []).filter((tool) => tool in agentRoutesSchema.shape && used.includes(tool));
|
|
259487
260060
|
const twins = used.length > 0 ? [...used] : [...STARTER_TWINS];
|
|
259488
260061
|
const unchecked = twins.filter((twin) => !hasAccessCheck(twin));
|
|
259489
260062
|
const defaultTemplate = opts.template === "starter" && command.getOptionValueSource("template") !== "cli";
|
|
259490
260063
|
const own2 = opts.template === "starter" ? await ownStarter(ctx.io.cwd) : void 0;
|
|
259491
260064
|
const existing2 = defaultTemplate ? (await glob3(["scenes/**/scene.yaml", "ancha/tests/**/*.{yaml,yml}", ...existingConfig?.scenes ?? []], { cwd: ctx.io.cwd, onlyFiles: true, followSymbolicLinks: false })).sort().filter((path9) => own2 === void 0 || path9 !== "scenes/starter/scene.yaml") : [];
|
|
259492
260065
|
const cloud = opts.on === "local" ? false : await cloudWorkspace(ctx, { code: "USAGE", message: "no workspace", hint: "" }).then(() => true, () => false);
|
|
259493
|
-
const
|
|
260066
|
+
const traces = await lstat10(join58(ctx.io.cwd, "traces")).then((stat22) => stat22.isDirectory(), () => false);
|
|
260067
|
+
const noStarter = defaultTemplate && (existing2.length > 0 || cloud && !(routeTools.length > 0 && !traces));
|
|
259494
260068
|
const starter = opts.template === "starter" && (!noStarter || own2 !== void 0);
|
|
259495
260069
|
const tests = (await glob3(["scenes/**/scene.yaml", "ancha/tests/**/*.yaml", ...existingConfig?.scenes ?? []], { cwd: ctx.io.cwd, onlyFiles: true, followSymbolicLinks: false })).filter((path9) => own2 === void 0 || path9 !== "scenes/starter/scene.yaml");
|
|
259496
|
-
const
|
|
259497
|
-
const dataSize = data7 === "none" ? void 0 : data7 !== void 0 ? data7.size : used.includes("netsuite") && opts.intent === void 0 && tests.length === 0 && !traces ? "m" : void 0;
|
|
260070
|
+
const dataSize = data7 === "none" ? void 0 : data7 !== void 0 ? data7.size : used.includes("netsuite") && !routeTools.includes("netsuite") && opts.intent === void 0 && tests.length === 0 && !traces ? "m" : void 0;
|
|
259498
260071
|
const pe = dataSize === void 0 ? void 0 : netsuiteData(dataSize);
|
|
260072
|
+
const examples2 = data7 !== "none" && used.includes("quickbooks") && opts.intent === void 0 && tests.length === 0 && !traces ? await quickbooksExamples() : void 0;
|
|
259499
260073
|
const existingTwins = await Promise.all(existing2.map((path9) => loadSceneFile(join58(ctx.io.cwd, path9)).then((scene2) => scene2.twins, () => [])));
|
|
259500
260074
|
const mapsNetsuite = task2 !== void 0 && task2.netsuite.length > 0 && opts.template === "starter" && existingTwins.every((list19) => list19.includes("netsuite")) && (!starter || twins.includes("netsuite"));
|
|
259501
260075
|
const env2 = { ...detection.slackApp?.env, ...task2?.wiring?.env, ...mapsNetsuite && Object.fromEntries(task2.netsuite.map((mapping) => [mapping.name, mapping.value])) };
|
|
259502
260076
|
const agentConfig = detection.agent === null ? void 0 : { command: task2?.wiring?.command ?? detection.agent, ...detection.slackApp && { slack_transport: detection.slackApp.transport, ...detection.slackApp.url && { url: detection.slackApp.url } }, ...Object.keys(env2).length > 0 && { env: env2 }, ...task2?.stdin && { input: "stdin" } };
|
|
259503
|
-
const templates = opts.template !== "starter" ? await templateFiles(opts.template) : !starter ? [] : (await starterPack("starter", `Reach ${twins.map(toolName).join(", ")}`, twins)).filter((file3) => STARTER_FILES.includes(file3.relativePath));
|
|
260077
|
+
const templates = opts.template !== "starter" ? await templateFiles(opts.template) : !starter ? [] : (await starterPack("starter", `Reach ${twins.map(toolName).join(", ")}`, twins, routeTools)).filter((file3) => STARTER_FILES.includes(file3.relativePath));
|
|
259504
260078
|
const worldFiles = await glob3("ancha/worlds/*.yaml", { cwd: ctx.io.cwd, onlyFiles: true, followSymbolicLinks: false });
|
|
259505
|
-
const starterWorld = starter && !opts.intent && (!pe && worldFiles.length === 0 || worldFiles.includes("ancha/worlds/starter.yaml")) ? {
|
|
260079
|
+
const starterWorld = starter && !opts.intent && (!pe && !examples2 && worldFiles.length === 0 || worldFiles.includes("ancha/worlds/starter.yaml")) ? {
|
|
259506
260080
|
relativePath: "ancha/worlds/starter.yaml",
|
|
259507
|
-
content: worldFileYaml(sceneWorld(parseScene((0,
|
|
260081
|
+
content: worldFileYaml(sceneWorld(parseScene((0, import_yaml18.parse)(templates.find((file3) => file3.relativePath === "scene.yaml").content))))
|
|
259508
260082
|
} : void 0;
|
|
259509
260083
|
const files2 = [
|
|
259510
|
-
{ relativePath: "ancha.yaml", content: `${agentConfig === void 0 ? "# Set agent.command to the command that starts your agent.\n" : (0,
|
|
260084
|
+
{ relativePath: "ancha.yaml", content: `${agentConfig === void 0 ? "# Set agent.command to the command that starts your agent.\n" : (0, import_yaml18.stringify)({ agent: agentConfig })}scenes: [scenes/**/scene.yaml, ${TESTS_GLOB}]
|
|
259511
260085
|
trials: 1
|
|
259512
260086
|
parallel: ${detection.slackApp?.transport === "http" ? 1 : 3}
|
|
259513
260087
|
min_pass_rate: 1
|
|
259514
260088
|
` },
|
|
259515
260089
|
...templates.map((file3) => ({ ...file3, relativePath: `scenes/${opts.template}/${file3.relativePath}` })),
|
|
259516
260090
|
...starterWorld ? [starterWorld] : [],
|
|
259517
|
-
{ relativePath: ".claude/skills/ancha/SKILL.md", content: await
|
|
259518
|
-
...pe?.files ?? []
|
|
260091
|
+
{ relativePath: ".claude/skills/ancha/SKILL.md", content: await readFile42(new URL("SKILL.md", assetRoot()), "utf8") },
|
|
260092
|
+
...pe?.files ?? [],
|
|
260093
|
+
...examples2?.files ?? []
|
|
259519
260094
|
];
|
|
259520
260095
|
await preflightFiles(ctx.io.cwd, [...files2, { relativePath: "AGENTS.md", content: "" }, { relativePath: ".gitignore", content: "" }]);
|
|
259521
260096
|
const updated = [];
|
|
259522
|
-
const rewritten = own2 === void 0 ? [] : await Promise.all(files2.filter((file3) => file3.relativePath.startsWith("scenes/starter/")).map(async (file3) => await
|
|
260097
|
+
const rewritten = own2 === void 0 ? [] : await Promise.all(files2.filter((file3) => file3.relativePath.startsWith("scenes/starter/")).map(async (file3) => await readFile42(join58(ctx.io.cwd, file3.relativePath), "utf8").catch(() => void 0) === file3.content ? void 0 : file3)).then((list19) => list19.filter((file3) => file3 !== void 0));
|
|
259523
260098
|
if (starterWorld && own2 !== void 0) {
|
|
259524
|
-
const before = await
|
|
260099
|
+
const before = await readFile42(join58(ctx.io.cwd, starterWorld.relativePath), "utf8").catch(() => void 0);
|
|
259525
260100
|
const previous = await loadSceneFile(join58(ctx.io.cwd, "scenes/starter/scene.yaml"));
|
|
259526
260101
|
if (before === worldFileYaml(sceneWorld(previous)) && before !== starterWorld.content) rewritten.push(starterWorld);
|
|
259527
260102
|
}
|
|
@@ -259534,7 +260109,7 @@ min_pass_rate: 1
|
|
|
259534
260109
|
let savedCommand;
|
|
259535
260110
|
if (configured) {
|
|
259536
260111
|
if (opts.agent !== void 0 && existingConfig !== void 0 && existingConfig.agent?.mode !== "endpoint" && !existingAgent?.command) {
|
|
259537
|
-
const doc = (0,
|
|
260112
|
+
const doc = (0, import_yaml18.parseDocument)(configText);
|
|
259538
260113
|
doc.setIn(["agent", "command"], opts.agent);
|
|
259539
260114
|
const next3 = doc.toString({ lineWidth: 0, flowCollectionPadding: false });
|
|
259540
260115
|
parseConfigText(next3);
|
|
@@ -259544,6 +260119,7 @@ min_pass_rate: 1
|
|
|
259544
260119
|
} else task2 = await wireExistingConfig(ctx.io.cwd, opts.agent === void 0);
|
|
259545
260120
|
if (task2?.wiring || task2?.stdin) updated.push("ancha.yaml");
|
|
259546
260121
|
if (pe && await listTests(ctx.io.cwd, pe.tests) && !updated.includes("ancha.yaml")) updated.push("ancha.yaml");
|
|
260122
|
+
if (examples2 && await listTests(ctx.io.cwd, examples2.tests.map((test3) => test3.file)) && !updated.includes("ancha.yaml")) updated.push("ancha.yaml");
|
|
259547
260123
|
}
|
|
259548
260124
|
if (agents === "created") result.created.push("AGENTS.md");
|
|
259549
260125
|
else if (agents === "updated") updated.push("AGENTS.md");
|
|
@@ -259564,7 +260140,9 @@ min_pass_rate: 1
|
|
|
259564
260140
|
generated = { world: { id: world5.id, file: world5.world, people: world5.people, ...notGenerated.added.length > 0 && { exampleData: notGenerated.added } }, test: { id: test3.id, file: test3.file, checks: test3.checks }, ...(world5.modelCredit ?? test3.modelCredit) && { modelCredit: "workspace" } };
|
|
259565
260141
|
result.created.push(...world5.files, test3.file, test3.record);
|
|
259566
260142
|
}
|
|
259567
|
-
const
|
|
260143
|
+
const routeWiring = await wireComposio(ctx.io.cwd, routeTools);
|
|
260144
|
+
if (routeWiring.added.length && !result.created.includes("ancha.yaml") && !updated.includes("ancha.yaml")) updated.push("ancha.yaml");
|
|
260145
|
+
const savedConfig = await readFile42(join58(ctx.io.cwd, "ancha.yaml"), "utf8").then((text31) => {
|
|
259568
260146
|
try {
|
|
259569
260147
|
return parseConfigText(text31);
|
|
259570
260148
|
} catch {
|
|
@@ -259572,9 +260150,12 @@ min_pass_rate: 1
|
|
|
259572
260150
|
}
|
|
259573
260151
|
});
|
|
259574
260152
|
const savedAgent = savedConfig?.agent;
|
|
260153
|
+
const routes2 = savedAgent?.mode === "endpoint" ? {} : savedAgent?.routes ?? {};
|
|
260154
|
+
const question = detection.composio?.tools.length === 0 ? "Which tools does your agent reach through Composio? Set agent.routes.<tool>: composio for each routed tool and add COMPOSIO_API_KEY to agent.pass_env in ancha.yaml." : void 0;
|
|
260155
|
+
const composio = detection.composio ? { tools: detection.composio.tools, routes: routes2, ...routeWiring, ...question && { question } } : void 0;
|
|
259575
260156
|
const savedLaunch = savedAgent?.mode === "endpoint" ? savedAgent.start : savedAgent?.command;
|
|
259576
260157
|
const runs = savedLaunch ? { command: savedLaunch, source: "ancha.yaml" } : void 0;
|
|
259577
|
-
const next2 = runs === void 0 ? ["set agent.command in ancha.yaml", cloud ? "ancha agent upload" : "ancha run"] : generated ? cloud ? ["ancha agent upload", `ancha run ${generated.test.file}`] : [`ancha run ${generated.test.file}`] : cloud ? ["ancha agent upload", starter || existing2.length > 0 || pe ? "ancha run" : "ancha traces upload ./traces"] : ["ancha run"];
|
|
260158
|
+
const next2 = runs === void 0 ? ["set agent.command in ancha.yaml", cloud ? "ancha agent upload" : "ancha run"] : Object.keys(routes2).length > 0 && starter && !traces && existing2.length === 0 ? composioStarterNext(cloud, examples2 !== void 0) : generated ? cloud ? ["ancha agent upload", `ancha run ${generated.test.file}`] : [`ancha run ${generated.test.file}`] : cloud ? ["ancha agent upload", starter || existing2.length > 0 || pe || examples2 ? "ancha run" : "ancha traces upload ./traces"] : ["ancha run"];
|
|
259578
260159
|
next2.unshift(...functionToolWiring(detection.functionTools));
|
|
259579
260160
|
const taskInput = task2 === void 0 ? void 0 : {
|
|
259580
260161
|
native: task2.scan.native,
|
|
@@ -259587,12 +260168,16 @@ min_pass_rate: 1
|
|
|
259587
260168
|
};
|
|
259588
260169
|
const agentTools3 = { tools: used, given: given2 !== void 0, ...given2 === void 0 && { from: found.from } };
|
|
259589
260170
|
const dataOutput = pe && { dataset: `netsuite-pe@${NETSUITE_PE_VERSION}`, size: pe.size, world: pe.world, evals: pe.evals, tests: pe.tests.length, subsidiaries: pe.counts.subsidiaries ?? 0, transactions: pe.counts.transactions ?? 0 };
|
|
259590
|
-
const output2 = { ...result, updated, detection, ...savedCommand !== void 0 && { savedCommand }, template: opts.template, agentTools: agentTools3, ...starter && { tools: twins, ...unchecked.length > 0 && { unchecked } }, ...existing2.length > 0 && { scenes: existing2 }, ...dataOutput && { data: dataOutput }, ...generated, ...taskInput && { taskInput }, next: next2 };
|
|
260171
|
+
const output2 = { ...result, updated, detection, ...composio && { composio }, ...savedCommand !== void 0 && { savedCommand }, template: opts.template, agentTools: agentTools3, ...starter && { tools: twins, ...unchecked.length > 0 && { unchecked } }, ...existing2.length > 0 && { scenes: existing2 }, ...dataOutput && { data: dataOutput }, ...examples2 && { examples: { quickbooks: { world: examples2.world, tests: examples2.tests } } }, ...generated, ...taskInput && { taskInput }, next: next2 };
|
|
259591
260172
|
const agent = runs === void 0 ? "no start command in ancha.yaml; set agent.command to start your agent" : `${runs.command} (from ${!configured && detection.agentEvidence ? detection.agentEvidence : runs.source})`;
|
|
259592
260173
|
const names8 = (list19) => list19.map(toolName).join(", ");
|
|
259593
260174
|
ctx.out.result(output2, () => [
|
|
259594
260175
|
`Created ${result.created.length} files; updated ${updated.length}; preserved ${result.skipped.length}.`,
|
|
259595
260176
|
`agent: ${agent}`,
|
|
260177
|
+
...detection.composio ? [`sdk: Composio (from ${detection.sdkSources.composio})`] : [],
|
|
260178
|
+
...composio && Object.keys(routes2).length ? [`routes: ${Object.keys(routes2).map((tool) => `${tool}: composio`).join(", ")} in ancha.yaml${routeWiring.added.length ? `; added ${routeWiring.added.join(", ")}` : ""}${routeWiring.passEnvAdded ? "; added COMPOSIO_API_KEY to agent.pass_env" : ""}`] : [],
|
|
260179
|
+
...question ? [question] : [],
|
|
260180
|
+
...routeWiring.pending.map((item2) => item2.fix),
|
|
259596
260181
|
...detection.functionTools.length ? [`function tools: ${detection.functionTools.map((t) => t.name).join(", ")}`] : [],
|
|
259597
260182
|
...savedCommand !== void 0 ? ["Saved agent.command in ancha.yaml."] : [],
|
|
259598
260183
|
// The tools it uses, and where each one showed: what the coding agent confirms with the person (SPEC-053, Jay).
|
|
@@ -259602,6 +260187,7 @@ min_pass_rate: 1
|
|
|
259602
260187
|
...starter ? [`starter: ${names8(twins)}${used.length > 0 ? "" : " (the template's tools)"}${rewritten.length > 0 && own2 !== void 0 ? `; rewritten from the one an earlier ancha init wrote for ${names8(own2)}` : ""}`] : [],
|
|
259603
260188
|
...existing2.length > 0 ? [`scenes: ${existing2.length} already in this project (${existing2.slice(0, 2).join(", ")}${existing2.length > 2 ? ", \u2026" : ""}); ancha init --template starter adds the starter test`] : [],
|
|
259604
260189
|
...starter && unchecked.length > 0 ? [` ${names8(unchecked)}: seeded; no access check, since ${unchecked.length === 1 ? "its" : "their"} requests need signing or a token exchange; add checks of your own`] : [],
|
|
260190
|
+
...examples2 ? [`examples: QuickBooks world ${examples2.id} (Pellmont Building Services' 2025 books) and ${examples2.tests.length} tests:`, ...examples2.tests.map((test3) => ` ${test3.file}: ${test3.title}`)] : [],
|
|
259605
260191
|
...dataOutput ? [`data: NetSuite world ${pe.id} (${dataOutput.subsidiaries} subsidiaries, ${dataOutput.transactions.toLocaleString("en-US")} transactions) and ${dataOutput.tests} tests (10 read tasks, 15 write workflows)`] : [],
|
|
259606
260192
|
...generated ? [`world: ${generated.world.file} (people: ${generated.world.people.join(", ") || "none"})`] : [],
|
|
259607
260193
|
...notGenerated?.added.length ? [` world gen populates ${gen_exports.GENERATED_TOOLS.join(", ")}; ${names8(notGenerated.added)} got ${notGenerated.added.length === 1 ? "its" : "their"} example data instead (ancha twins seed <tool> shows the fields)`] : [],
|
|
@@ -259848,7 +260434,7 @@ init_assets();
|
|
|
259848
260434
|
init_src();
|
|
259849
260435
|
import { execFile as execFile9 } from "node:child_process";
|
|
259850
260436
|
import { createHash as createHash78, randomUUID as randomUUID18 } from "node:crypto";
|
|
259851
|
-
import { mkdir as mkdir27, mkdtemp as mkdtemp10, readFile as
|
|
260437
|
+
import { mkdir as mkdir27, mkdtemp as mkdtemp10, readFile as readFile44, readdir as readdir12, rename as rename8, rm as rm14, writeFile as writeFile28 } from "node:fs/promises";
|
|
259852
260438
|
import { tmpdir as tmpdir9 } from "node:os";
|
|
259853
260439
|
import { join as join60 } from "node:path";
|
|
259854
260440
|
init_detect();
|
|
@@ -259859,7 +260445,7 @@ init_policy();
|
|
|
259859
260445
|
|
|
259860
260446
|
// backend/src/execution/runtime-cache.ts
|
|
259861
260447
|
import { createHash as createHash77, randomUUID as randomUUID17 } from "node:crypto";
|
|
259862
|
-
import { mkdir as mkdir26, readFile as
|
|
260448
|
+
import { mkdir as mkdir26, readFile as readFile43, readdir as readdir11, realpath as realpath13, rename as rename7, rm as rm13, writeFile as writeFile27 } from "node:fs/promises";
|
|
259863
260449
|
import { join as join59 } from "node:path";
|
|
259864
260450
|
init_assets();
|
|
259865
260451
|
async function runtimeCacheKey(source, project14, command, context3) {
|
|
@@ -259868,7 +260454,7 @@ async function runtimeCacheKey(source, project14, command, context3) {
|
|
|
259868
260454
|
for (const entry3 of (await readdir11(path9, { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
259869
260455
|
const relative29 = prefix2 + entry3.name;
|
|
259870
260456
|
if (entry3.isDirectory()) await visit4(join59(path9, entry3.name), relative29 + "/");
|
|
259871
|
-
else hash10.update(relative29).update("\0").update(await
|
|
260457
|
+
else hash10.update(relative29).update("\0").update(await readFile43(join59(path9, entry3.name))).update("\0");
|
|
259872
260458
|
}
|
|
259873
260459
|
}
|
|
259874
260460
|
await visit4(source);
|
|
@@ -259900,7 +260486,7 @@ async function rememberRuntime(workspace4, key5, image2) {
|
|
|
259900
260486
|
}
|
|
259901
260487
|
|
|
259902
260488
|
// backend/src/execution/prepare-agent.ts
|
|
259903
|
-
var read6 = (directory, file3) =>
|
|
260489
|
+
var read6 = (directory, file3) => readFile44(join60(directory, file3), "utf8").catch((error65) => {
|
|
259904
260490
|
if (error65.code === "ENOENT") return void 0;
|
|
259905
260491
|
throw error65;
|
|
259906
260492
|
});
|
|
@@ -260036,13 +260622,13 @@ async function prepareAgent(workspace4, agentId2, options5 = {}) {
|
|
|
260036
260622
|
for (const entry3 of (await readdir12(path9, { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
260037
260623
|
const relative29 = prefix2 + entry3.name;
|
|
260038
260624
|
if (entry3.isDirectory()) await hashTree(join60(path9, entry3.name), relative29 + "/");
|
|
260039
|
-
else digest4.update(relative29).update("\0").update(await
|
|
260625
|
+
else digest4.update(relative29).update("\0").update(await readFile44(join60(path9, entry3.name))).update("\0");
|
|
260040
260626
|
}
|
|
260041
260627
|
}
|
|
260042
260628
|
await hashTree(source);
|
|
260043
260629
|
const fingerprint = digest4.digest("hex"), cacheRelative = `.ancha/agent-images/${fingerprint}.json`;
|
|
260044
260630
|
await preflightFiles(workspace4, [{ relativePath: cacheRelative, content: "" }]);
|
|
260045
|
-
const cached3 = await
|
|
260631
|
+
const cached3 = await readFile44(join60(workspace4, cacheRelative), "utf8").then((text31) => JSON.parse(text31)).catch(() => void 0);
|
|
260046
260632
|
let cachedImage;
|
|
260047
260633
|
if (cached3?.image && /^sha256:[a-f0-9]{64}$/.test(cached3.image)) {
|
|
260048
260634
|
try {
|
|
@@ -260511,7 +261097,7 @@ init_backend();
|
|
|
260511
261097
|
init_assets();
|
|
260512
261098
|
import { createServer as createServer6 } from "node:http";
|
|
260513
261099
|
import { randomBytes as randomBytes10 } from "node:crypto";
|
|
260514
|
-
import { readFile as
|
|
261100
|
+
import { readFile as readFile45, realpath as realpath14, stat as stat15 } from "node:fs/promises";
|
|
260515
261101
|
import { isAbsolute as isAbsolute11 } from "node:path";
|
|
260516
261102
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
260517
261103
|
|
|
@@ -261917,12 +262503,12 @@ async function startConsole(opts) {
|
|
|
261917
262503
|
const files2 = /* @__PURE__ */ new Map();
|
|
261918
262504
|
if (opts.assets !== false) {
|
|
261919
262505
|
const assets = opts.assets ?? fileURLToPath7(new URL("ui/", assetRoot()));
|
|
261920
|
-
const html4 = await
|
|
262506
|
+
const html4 = await readFile45(`${assets}/index.html`).catch(() => {
|
|
261921
262507
|
throw new AnchaError("USAGE", "console assets are missing; reinstall Ancha with `npm install -g @ancha-labs/cli`");
|
|
261922
262508
|
});
|
|
261923
262509
|
files2.set("/", { body: html4, mime: "text/html; charset=utf-8" });
|
|
261924
|
-
files2.set("/app.js", { body: await
|
|
261925
|
-
files2.set("/style.css", { body: await
|
|
262510
|
+
files2.set("/app.js", { body: await readFile45(`${assets}/app.js`), mime: "text/javascript; charset=utf-8" });
|
|
262511
|
+
files2.set("/style.css", { body: await readFile45(`${assets}/style.css`), mime: "text/css; charset=utf-8" });
|
|
261926
262512
|
}
|
|
261927
262513
|
const backend = opts.backend ?? await openBackend();
|
|
261928
262514
|
const catalog3 = new ScenarioCatalog(workspace4, opts.configPath);
|
|
@@ -262477,7 +263063,7 @@ function registerConnection(program2, ctx) {
|
|
|
262477
263063
|
// packages/cli/src/commands/test-pull.ts
|
|
262478
263064
|
init_src();
|
|
262479
263065
|
import { createHash as createHash82, randomUUID as randomUUID22 } from "node:crypto";
|
|
262480
|
-
import { lstat as lstat11, mkdir as mkdir29, readFile as
|
|
263066
|
+
import { lstat as lstat11, mkdir as mkdir29, readFile as readFile46, realpath as realpath15, rename as rename10, rm as rm19, writeFile as writeFile31 } from "node:fs/promises";
|
|
262481
263067
|
import { dirname as dirname23, join as join66 } from "node:path";
|
|
262482
263068
|
var hash8 = (text31) => createHash82("sha256").update(text31).digest("hex");
|
|
262483
263069
|
var safePath4 = (path9) => typeof path9 === "string" && path9.length > 0 && path9.length <= 1024 && !path9.startsWith("/") && !/[\\\x00-\x1f\x7f:]/.test(path9) && path9.split("/").every((p2) => p2 && !p2.startsWith("."));
|
|
@@ -262502,7 +263088,7 @@ async function writePulledTest(cwd, input5, force = false) {
|
|
|
262502
263088
|
});
|
|
262503
263089
|
if (!info2) return null;
|
|
262504
263090
|
if (!info2.isFile() || info2.isSymbolicLink()) throw new AnchaError("USAGE", "The test path must be a regular file.");
|
|
262505
|
-
return
|
|
263091
|
+
return readFile46(target6, "utf8");
|
|
262506
263092
|
};
|
|
262507
263093
|
const before = await current();
|
|
262508
263094
|
if (!force && before !== null && before !== input5.yaml && hash8(before) !== input5.baseSha256 && hash8(before) !== input5.previousSha256)
|
|
@@ -262538,17 +263124,17 @@ init_trace_import();
|
|
|
262538
263124
|
// packages/cli/src/commands/traces.ts
|
|
262539
263125
|
init_trace_import();
|
|
262540
263126
|
import { createHash as createHash83 } from "node:crypto";
|
|
262541
|
-
import { access as access13, readFile as
|
|
263127
|
+
import { access as access13, readFile as readFile49, mkdir as mkdir30, stat as stat17, writeFile as writeFile32 } from "node:fs/promises";
|
|
262542
263128
|
import { basename as basename15, dirname as dirname24, join as join68, relative as relative23, resolve as resolve48 } from "node:path";
|
|
262543
263129
|
import { isDeepStrictEqual as isDeepStrictEqual6 } from "node:util";
|
|
262544
|
-
var
|
|
263130
|
+
var import_yaml20 = __toESM(require_dist(), 1);
|
|
262545
263131
|
init_src();
|
|
262546
263132
|
init_credentials();
|
|
262547
263133
|
init_run_store();
|
|
262548
263134
|
|
|
262549
263135
|
// backend/src/trace-ir.ts
|
|
262550
263136
|
init_src();
|
|
262551
|
-
import { readFile as
|
|
263137
|
+
import { readFile as readFile47 } from "node:fs/promises";
|
|
262552
263138
|
import { join as join67 } from "node:path";
|
|
262553
263139
|
var VENDOR_API_BASES2 = {
|
|
262554
263140
|
slack: "https://slack.com",
|
|
@@ -262621,7 +263207,7 @@ function attemptToIr(entries4, traceId, agent, saved) {
|
|
|
262621
263207
|
return [{ ir: "ancha.trace/v1", trace_id: traceId, ...agent !== void 0 && { agent }, source: "ancha-run", started_at: entries4[0]?.tSim ?? saved?.scene?.start_time, ...saved?.scene && { test: saved.scene, input: saved.scene.trigger?.input ?? { messages: [{ role: "user", content: saved.scene.task ?? saved.scene.trigger?.task ?? "" }] } }, ...output2?.output !== void 0 && { output: output2.output } }, ...records5];
|
|
262622
263208
|
}
|
|
262623
263209
|
async function readAttemptTrace(dir2) {
|
|
262624
|
-
const text31 = (await
|
|
263210
|
+
const text31 = (await readFile47(join67(dir2, "trace.jsonl"), "utf8")).trim();
|
|
262625
263211
|
return text31 ? text31.split("\n").map((line2) => JSON.parse(line2)) : [];
|
|
262626
263212
|
}
|
|
262627
263213
|
|
|
@@ -262744,7 +263330,7 @@ async function listTraces(source, { limit: limit2, since, name: name5 }, env2, f
|
|
|
262744
263330
|
}
|
|
262745
263331
|
|
|
262746
263332
|
// packages/cli/src/trace-files.ts
|
|
262747
|
-
import { readFile as
|
|
263333
|
+
import { readFile as readFile48, stat as stat16 } from "node:fs/promises";
|
|
262748
263334
|
import { basename as basename14, relative as relative21, resolve as resolve47 } from "node:path";
|
|
262749
263335
|
init_src();
|
|
262750
263336
|
var MB3 = 1024 * 1024;
|
|
@@ -262773,7 +263359,7 @@ async function findTraceFiles(cwd, args) {
|
|
|
262773
263359
|
return [...found].sort();
|
|
262774
263360
|
}
|
|
262775
263361
|
async function readTraceTexts(cwd, paths3) {
|
|
262776
|
-
return Promise.all(paths3.map(async (path9) => ({ file: relative21(cwd, path9) || basename14(path9), name: basename14(path9), text: await
|
|
263362
|
+
return Promise.all(paths3.map(async (path9) => ({ file: relative21(cwd, path9) || basename14(path9), name: basename14(path9), text: await readFile48(path9, "utf8").catch(() => void 0) })));
|
|
262777
263363
|
}
|
|
262778
263364
|
function readTraceUnits(texts4, { fileToIr: fileToIr2, sourceOf: sourceOf2 }) {
|
|
262779
263365
|
const drafts = /* @__PURE__ */ new Map(), skipped = [], read7 = [];
|
|
@@ -263235,18 +263821,18 @@ var importedCheckLines = (scene2, production3) => [
|
|
|
263235
263821
|
...importedChecks(scene2, production3).map((c) => ` ${c.id}: ${c.required ? "required" : "optional"}, ${c.production} in production`)
|
|
263236
263822
|
];
|
|
263237
263823
|
async function localChanges(dir2) {
|
|
263238
|
-
const text31 = await
|
|
263824
|
+
const text31 = await readFile49(join68(dir2, "scene.yaml"), "utf8").catch(() => void 0);
|
|
263239
263825
|
if (text31 === void 0) return void 0;
|
|
263240
263826
|
const local2 = (() => {
|
|
263241
263827
|
try {
|
|
263242
|
-
return (0,
|
|
263828
|
+
return (0, import_yaml20.parse)(text31);
|
|
263243
263829
|
} catch {
|
|
263244
263830
|
return void 0;
|
|
263245
263831
|
}
|
|
263246
263832
|
})(), mark = MARK.exec(text31)?.[1];
|
|
263247
263833
|
if (local2 === void 0 || mark === void 0) return { added: [], other: true };
|
|
263248
263834
|
if (digest3(local2) === mark) return { added: [], other: false };
|
|
263249
|
-
const production3 = await
|
|
263835
|
+
const production3 = await readFile49(join68(dir2, "production.json"), "utf8").then((t) => JSON.parse(t).checks, () => void 0);
|
|
263250
263836
|
const added = production3 ? checksOf2(local2).filter((c) => !Object.hasOwn(production3, c.id)) : [];
|
|
263251
263837
|
const addedIds = new Set(added.map((c) => c.id));
|
|
263252
263838
|
const required6 = (Array.isArray(local2.pass) ? local2.pass : checksOf2(local2).map((c) => c.id)).filter((id14) => addedIds.has(id14));
|
|
@@ -263292,7 +263878,7 @@ async function writeWorld(ctx, world5, dest, changes) {
|
|
|
263292
263878
|
const files2 = sceneFiles2(content2);
|
|
263293
263879
|
await writeFile32(scene2, `# Rebuilt by Ancha from a production trace (world ${world5.id}). Where each part came from: provenance.json.
|
|
263294
263880
|
# ancha pull: ${world5.id} ${digest3(sceneFiles2(world5.scene).scene)}
|
|
263295
|
-
${(0,
|
|
263881
|
+
${(0, import_yaml20.stringify)(files2.scene)}`);
|
|
263296
263882
|
if (files2.observations !== void 0) await writeFile32(join68(dir2, "observations.jsonl"), files2.observations);
|
|
263297
263883
|
if (world5.record) await writeFile32(join68(dir2, "production.jsonl"), productionLines(world5.record));
|
|
263298
263884
|
await writeFile32(join68(dir2, "provenance.json"), JSON.stringify(world5.provenance, null, 2) + "\n");
|
|
@@ -263816,7 +264402,7 @@ function registerTraces(program2, ctx) {
|
|
|
263816
264402
|
});
|
|
263817
264403
|
}
|
|
263818
264404
|
async function traceSource(ctx, trace2, from) {
|
|
263819
|
-
if (!from) return { text: await
|
|
264405
|
+
if (!from) return { text: await readFile49(resolve48(ctx.io.cwd, trace2), "utf8").catch(() => {
|
|
263820
264406
|
throw new AnchaError("USAGE", `cannot read ${trace2}`, { hint: "pass the path of a trace file: ancha import --offline <trace.jsonl>" });
|
|
263821
264407
|
}), name: basename15(trace2), label: basename15(trace2) };
|
|
263822
264408
|
const doc = await fetchTrace(from, trace2, ctx.io.env);
|
|
@@ -263824,7 +264410,7 @@ async function traceSource(ctx, trace2, from) {
|
|
|
263824
264410
|
return { text: JSON.stringify(doc), name: `${from}-${id14}`.slice(0, 80), label: `${from === "langfuse" ? "Langfuse" : "LangSmith"} trace ${id14}` };
|
|
263825
264411
|
}
|
|
263826
264412
|
async function traceFileLines(ctx, file3) {
|
|
263827
|
-
const text31 = await
|
|
264413
|
+
const text31 = await readFile49(resolve48(ctx.io.cwd, file3), "utf8").catch(() => {
|
|
263828
264414
|
throw new AnchaError("USAGE", `cannot read ${file3}`, { hint: "pass the path of a trace file: ancha traces diff <trace.jsonl> latest" });
|
|
263829
264415
|
});
|
|
263830
264416
|
return { text: text31, lines: await traceTextLines(text31, basename15(file3)) };
|
|
@@ -263897,7 +264483,7 @@ async function writeRecords(ctx, conversations, dest) {
|
|
|
263897
264483
|
const seen = conversations.flatMap((c) => recordsOf2(toolCallsOf(c.lines), { conversation: c.id }));
|
|
263898
264484
|
if (!seen.length) return void 0;
|
|
263899
264485
|
const path9 = resolve48(ctx.io.cwd, dest, "records.jsonl");
|
|
263900
|
-
const merged = mergeRecords2(readRecordLines2(await
|
|
264486
|
+
const merged = mergeRecords2(readRecordLines2(await readFile49(path9, "utf8").catch(() => "")), seen);
|
|
263901
264487
|
await mkdir30(dirname24(path9), { recursive: true });
|
|
263902
264488
|
await writeFile32(path9, recordLines2(merged));
|
|
263903
264489
|
const types = merged.reduce((all9, r2) => all9.set(r2.type, (all9.get(r2.type) ?? 0) + 1), /* @__PURE__ */ new Map());
|
|
@@ -263911,7 +264497,7 @@ async function importLocally(ctx, source, options5) {
|
|
|
263911
264497
|
const { text: text31 } = source, all9 = await traceConversations(text31, source.name);
|
|
263912
264498
|
const { sceneFiles: sceneFiles2 } = await Promise.resolve().then(() => (init_trace_import(), trace_import_exports));
|
|
263913
264499
|
const rebuild3 = rebuildTraceImport;
|
|
263914
|
-
const checks2 = options5.checks ? readImportChecks(await
|
|
264500
|
+
const checks2 = options5.checks ? readImportChecks(await readFile49(resolve48(ctx.io.cwd, options5.checks), "utf8").catch(() => {
|
|
263915
264501
|
throw new AnchaError("USAGE", `cannot read checks file ${options5.checks}`);
|
|
263916
264502
|
})) : void 0;
|
|
263917
264503
|
const picked = options5.conversation === void 0 ? all9 : all9.filter((c) => c.id === options5.conversation || c.traces.includes(options5.conversation));
|
|
@@ -263930,7 +264516,7 @@ async function importLocally(ctx, source, options5) {
|
|
|
263930
264516
|
const made = [], skipped = [];
|
|
263931
264517
|
for (const [i, conversation3] of picked.entries()) {
|
|
263932
264518
|
const examples2 = [...all9.filter((c) => c !== conversation3).map((c) => c.lines), ...files2], customer3 = customers3.people[i];
|
|
263933
|
-
const earlier2 = options5.resetAnswers ? {} : await
|
|
264519
|
+
const earlier2 = options5.resetAnswers ? {} : await readFile49(resolve48(ctx.io.cwd, options5.dest, named5.get(conversation3), "answers.json"), "utf8").then((text32) => JSON.parse(text32), () => ({}));
|
|
263934
264520
|
try {
|
|
263935
264521
|
const preview = rebuild3(conversation3.lines, { id: named5.get(conversation3), withRecords: true, examples: examples2, useReportedResults: options5.useReportedResults });
|
|
263936
264522
|
const answers = { ...answersFor(preview.questions, earlier2, options5.answer), ...options5.expect && { "checks.expect": options5.expect } };
|
|
@@ -263943,13 +264529,13 @@ async function importLocally(ctx, source, options5) {
|
|
|
263943
264529
|
}
|
|
263944
264530
|
const paths3 = made.map((m) => join68(resolve48(ctx.io.cwd, options5.dest, m.id), "scene.yaml"));
|
|
263945
264531
|
if (!options5.force) {
|
|
263946
|
-
for (const path9 of paths3) if (await
|
|
264532
|
+
for (const path9 of paths3) if (await readFile49(path9, "utf8").then(() => true, () => false)) throw new AnchaError("USAGE", `${relative23(ctx.io.cwd, path9)} exists; --force replaces it`);
|
|
263947
264533
|
}
|
|
263948
264534
|
for (const [i, m] of made.entries()) {
|
|
263949
264535
|
const path9 = paths3[i], dir2 = dirname24(path9);
|
|
263950
264536
|
await mkdir30(dir2, { recursive: true });
|
|
263951
264537
|
const files3 = sceneFiles2(m.made.scene);
|
|
263952
|
-
await writeFile32(path9, (0,
|
|
264538
|
+
await writeFile32(path9, (0, import_yaml20.stringify)(files3.scene, { lineWidth: 0 }));
|
|
263953
264539
|
await writeFile32(join68(dir2, "candidates.json"), JSON.stringify(m.made.candidates, null, 2) + "\n");
|
|
263954
264540
|
await writeFile32(join68(dir2, "answers.json"), JSON.stringify(m.answers, null, 2) + "\n");
|
|
263955
264541
|
if (files3.observations !== void 0) await writeFile32(join68(dir2, "observations.jsonl"), files3.observations);
|
|
@@ -264033,7 +264619,7 @@ function evidenceLines2(made) {
|
|
|
264033
264619
|
|
|
264034
264620
|
// packages/cli/src/commands/test-import.ts
|
|
264035
264621
|
import { existsSync as existsSync4 } from "node:fs";
|
|
264036
|
-
import { access as access14, mkdir as mkdir31, readFile as
|
|
264622
|
+
import { access as access14, mkdir as mkdir31, readFile as readFile50, writeFile as writeFile33 } from "node:fs/promises";
|
|
264037
264623
|
import { basename as basename16, dirname as dirname25, extname as extname2, isAbsolute as isAbsolute12, relative as relative24, resolve as resolve49 } from "node:path";
|
|
264038
264624
|
init_src();
|
|
264039
264625
|
init_detect();
|
|
@@ -264067,7 +264653,7 @@ async function testImport(ctx, file3, options5) {
|
|
|
264067
264653
|
}
|
|
264068
264654
|
let text31, encoding;
|
|
264069
264655
|
try {
|
|
264070
|
-
({ text: text31, encoding } = decodeEvalText(await
|
|
264656
|
+
({ text: text31, encoding } = decodeEvalText(await readFile50(path9)));
|
|
264071
264657
|
} catch (error65) {
|
|
264072
264658
|
throw new AnchaError("USAGE", `cannot read ${file3}: ${error65.code === "ENOENT" ? "no such file" : error65 instanceof Error ? error65.message : String(error65)}`, { hint: "ancha test import <evals file> --world <id>" });
|
|
264073
264659
|
}
|
|
@@ -264101,7 +264687,7 @@ ${skipped.slice(0, 10).map((s3) => `item ${s3.item}: ${s3.reason}`).join("\n")}`
|
|
|
264101
264687
|
const tests = [];
|
|
264102
264688
|
for (const test3 of imported2.tests) {
|
|
264103
264689
|
const target6 = resolve49(ctx.io.cwd, test3.path);
|
|
264104
|
-
const before = existsSync4(target6) ? await
|
|
264690
|
+
const before = existsSync4(target6) ? await readFile50(target6, "utf8") : void 0;
|
|
264105
264691
|
const status6 = before === void 0 ? "written" : before === test3.yaml ? "unchanged" : !editedSinceImport(before) ? "updated" : options5.force ? "written" : "kept";
|
|
264106
264692
|
if (status6 === "written" || status6 === "updated") {
|
|
264107
264693
|
await mkdir31(dirname25(target6), { recursive: true });
|
|
@@ -264153,7 +264739,7 @@ function registerTestImport(tests, ctx) {
|
|
|
264153
264739
|
}
|
|
264154
264740
|
|
|
264155
264741
|
// packages/cli/src/commands/test-files.ts
|
|
264156
|
-
import { readFile as
|
|
264742
|
+
import { readFile as readFile51, stat as stat18 } from "node:fs/promises";
|
|
264157
264743
|
import { basename as basename17, relative as relative25, resolve as resolve50 } from "node:path";
|
|
264158
264744
|
init_src();
|
|
264159
264745
|
init_scenes();
|
|
@@ -264175,7 +264761,7 @@ async function showTestFile(ctx, ref23) {
|
|
|
264175
264761
|
const matches11 = [];
|
|
264176
264762
|
for (const file3 of await projectTestFiles(ctx)) {
|
|
264177
264763
|
try {
|
|
264178
|
-
const doc2 = parseSceneYaml(await
|
|
264764
|
+
const doc2 = parseSceneYaml(await readFile51(resolve50(ctx.io.cwd, file3), "utf8"));
|
|
264179
264765
|
if (doc2 && typeof doc2 === "object" && "id" in doc2 && doc2.id === ref23) matches11.push(file3);
|
|
264180
264766
|
} catch {
|
|
264181
264767
|
}
|
|
@@ -264186,7 +264772,7 @@ async function showTestFile(ctx, ref23) {
|
|
|
264186
264772
|
path9 = matches11[0];
|
|
264187
264773
|
}
|
|
264188
264774
|
const [{ scene: scene2, world: worldPath }] = await loadScenes(ctx.io.cwd, [path9]);
|
|
264189
|
-
const doc = parseSceneYaml(await
|
|
264775
|
+
const doc = parseSceneYaml(await readFile51(resolve50(ctx.io.cwd, path9), "utf8"));
|
|
264190
264776
|
const world5 = {
|
|
264191
264777
|
...worldPath !== void 0 && { id: basename17(worldPath, ".yaml"), path: relative25(ctx.io.cwd, worldPath) },
|
|
264192
264778
|
tools: scene2.twins
|
|
@@ -264466,9 +265052,9 @@ Run again with ancha test run ${saved.id}`);
|
|
|
264466
265052
|
}
|
|
264467
265053
|
|
|
264468
265054
|
// packages/cli/src/commands/sandbox.ts
|
|
264469
|
-
var
|
|
265055
|
+
var import_yaml21 = __toESM(require_dist(), 1);
|
|
264470
265056
|
init_src();
|
|
264471
|
-
import { readFile as
|
|
265057
|
+
import { readFile as readFile52 } from "node:fs/promises";
|
|
264472
265058
|
import { resolve as resolve52 } from "node:path";
|
|
264473
265059
|
init_backend();
|
|
264474
265060
|
function tools(value6) {
|
|
@@ -264515,7 +265101,7 @@ Use --json to export this configuration.`);
|
|
|
264515
265101
|
if ([opts.tools, opts.preset, opts.definition].filter(Boolean).length > 1) throw new AnchaError("USAGE", "choose --tools, --preset or --definition");
|
|
264516
265102
|
let input5;
|
|
264517
265103
|
if (opts.definition) {
|
|
264518
|
-
const doc = (0,
|
|
265104
|
+
const doc = (0, import_yaml21.parseDocument)(await readFile52(resolve52(ctx.io.cwd, opts.definition), "utf8"));
|
|
264519
265105
|
if (doc.errors.length) throw new AnchaError("CONFIG_INVALID", doc.errors.map((error65) => error65.message).join("; "));
|
|
264520
265106
|
input5 = doc.toJS({ maxAliasCount: 100 });
|
|
264521
265107
|
if (opts.name && input5 && typeof input5 === "object" && !Array.isArray(input5)) input5 = { ...input5, name: opts.name };
|
|
@@ -269321,8 +269907,8 @@ var require_content_type2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
269321
269907
|
var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g;
|
|
269322
269908
|
var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g;
|
|
269323
269909
|
var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
269324
|
-
exports.parse =
|
|
269325
|
-
function
|
|
269910
|
+
exports.parse = parse28;
|
|
269911
|
+
function parse28(string11) {
|
|
269326
269912
|
if (!string11) throw new TypeError("argument string is required");
|
|
269327
269913
|
var header4 = typeof string11 === "object" ? getcontenttype(string11) : string11;
|
|
269328
269914
|
if (typeof header4 !== "string") throw new TypeError("argument string is required to be a string");
|
|
@@ -272746,7 +273332,7 @@ var require_fast_uri2 = /* @__PURE__ */ __commonJSMin2(((exports, module) => {
|
|
|
272746
273332
|
}
|
|
272747
273333
|
function normalize4(uri, options5) {
|
|
272748
273334
|
if (typeof uri === "string") uri = normalizeString(uri, options5);
|
|
272749
|
-
else if (typeof uri === "object") uri =
|
|
273335
|
+
else if (typeof uri === "object") uri = parse28(serialize2(uri, options5), options5);
|
|
272750
273336
|
return uri;
|
|
272751
273337
|
}
|
|
272752
273338
|
function resolve61(baseURI, relativeURI, options5) {
|
|
@@ -272767,8 +273353,8 @@ var require_fast_uri2 = /* @__PURE__ */ __commonJSMin2(((exports, module) => {
|
|
|
272767
273353
|
function resolveComponent(base6, relative29, options5, skipNormalization) {
|
|
272768
273354
|
const target6 = {};
|
|
272769
273355
|
if (!skipNormalization) {
|
|
272770
|
-
base6 =
|
|
272771
|
-
relative29 =
|
|
273356
|
+
base6 = parse28(serialize2(base6, options5), options5);
|
|
273357
|
+
relative29 = parse28(serialize2(relative29, options5), options5);
|
|
272772
273358
|
}
|
|
272773
273359
|
options5 = options5 || {};
|
|
272774
273360
|
if (!options5.tolerant && relative29.scheme) {
|
|
@@ -273000,7 +273586,7 @@ var require_fast_uri2 = /* @__PURE__ */ __commonJSMin2(((exports, module) => {
|
|
|
273000
273586
|
malformedScheme
|
|
273001
273587
|
};
|
|
273002
273588
|
}
|
|
273003
|
-
function
|
|
273589
|
+
function parse28(uri, opts) {
|
|
273004
273590
|
return parseWithStatus(uri, opts).parsed;
|
|
273005
273591
|
}
|
|
273006
273592
|
function normalizeString(uri, opts) {
|
|
@@ -273035,7 +273621,7 @@ var require_fast_uri2 = /* @__PURE__ */ __commonJSMin2(((exports, module) => {
|
|
|
273035
273621
|
resolveComponent,
|
|
273036
273622
|
equal: equal3,
|
|
273037
273623
|
serialize: serialize2,
|
|
273038
|
-
parse:
|
|
273624
|
+
parse: parse28
|
|
273039
273625
|
};
|
|
273040
273626
|
module.exports = fastUri;
|
|
273041
273627
|
module.exports.default = fastUri;
|
|
@@ -277312,22 +277898,22 @@ async function authInternal(provider, { serverUrl: serverUrl3, authorizationCode
|
|
|
277312
277898
|
}, infoCtx);
|
|
277313
277899
|
return "AUTHORIZED";
|
|
277314
277900
|
}
|
|
277315
|
-
let
|
|
277316
|
-
if (
|
|
277317
|
-
|
|
277318
|
-
...
|
|
277901
|
+
let tokens7 = discardIfIssuerMismatch(await provider.tokens(infoCtx), issuer);
|
|
277902
|
+
if (tokens7 && tokens7.issuer === void 0) {
|
|
277903
|
+
tokens7 = {
|
|
277904
|
+
...tokens7,
|
|
277319
277905
|
issuer
|
|
277320
277906
|
};
|
|
277321
|
-
await provider.saveTokens(
|
|
277907
|
+
await provider.saveTokens(tokens7, infoCtx);
|
|
277322
277908
|
}
|
|
277323
|
-
if (
|
|
277324
|
-
const refreshScope = await provider.scopeForRefresh?.(
|
|
277909
|
+
if (tokens7?.refresh_token && !forceReauthorization) {
|
|
277910
|
+
const refreshScope = await provider.scopeForRefresh?.(tokens7);
|
|
277325
277911
|
let newTokens;
|
|
277326
277912
|
try {
|
|
277327
277913
|
newTokens = await refreshAuthorization(authorizationServerUrl, {
|
|
277328
277914
|
metadata: metadata8,
|
|
277329
277915
|
clientInformation,
|
|
277330
|
-
refreshToken:
|
|
277916
|
+
refreshToken: tokens7.refresh_token,
|
|
277331
277917
|
scope: refreshScope,
|
|
277332
277918
|
resource: resource2,
|
|
277333
277919
|
addClientAuthentication: provider.addClientAuthentication,
|
|
@@ -277622,7 +278208,7 @@ async function refreshAuthorization(authorizationServerUrl, { metadata: metadata
|
|
|
277622
278208
|
refresh_token: refreshToken
|
|
277623
278209
|
});
|
|
277624
278210
|
if (scope3) tokenRequestParams.set("scope", scope3);
|
|
277625
|
-
const
|
|
278211
|
+
const tokens7 = await executeTokenRequest(authorizationServerUrl, {
|
|
277626
278212
|
metadata: metadata8,
|
|
277627
278213
|
tokenRequestParams,
|
|
277628
278214
|
clientInformation,
|
|
@@ -277633,8 +278219,8 @@ async function refreshAuthorization(authorizationServerUrl, { metadata: metadata
|
|
|
277633
278219
|
});
|
|
277634
278220
|
return {
|
|
277635
278221
|
refresh_token: refreshToken,
|
|
277636
|
-
...
|
|
277637
|
-
...scope3 && !
|
|
278222
|
+
...tokens7,
|
|
278223
|
+
...scope3 && !tokens7.scope && { scope: scope3 }
|
|
277638
278224
|
};
|
|
277639
278225
|
}
|
|
277640
278226
|
async function fetchToken(provider, authorizationServerUrl, { metadata: metadata8, resource: resource2, authorizationCode, iss, scope: scope3, fetchFn } = {}) {
|
|
@@ -280309,13 +280895,13 @@ var withDpopFromProvider = (provider) => withDpop(async () => {
|
|
|
280309
280895
|
throw markAuthSeamEscape(error65);
|
|
280310
280896
|
}
|
|
280311
280897
|
}, async () => {
|
|
280312
|
-
let
|
|
280898
|
+
let tokens7;
|
|
280313
280899
|
try {
|
|
280314
|
-
|
|
280900
|
+
tokens7 = await provider.tokens();
|
|
280315
280901
|
} catch (error65) {
|
|
280316
280902
|
throw markAuthSeamEscape(error65);
|
|
280317
280903
|
}
|
|
280318
|
-
return
|
|
280904
|
+
return tokens7?.token_type?.toLowerCase() === "dpop" ? tokens7.access_token : void 0;
|
|
280319
280905
|
});
|
|
280320
280906
|
var SseError = class extends Error {
|
|
280321
280907
|
static {
|
|
@@ -280464,10 +281050,10 @@ var StreamableHTTPClientTransport = class {
|
|
|
280464
281050
|
text: challenge.text
|
|
280465
281051
|
});
|
|
280466
281052
|
if (challenge.resourceMetadataUrl) this._resourceMetadataUrl = challenge.resourceMetadataUrl;
|
|
280467
|
-
const
|
|
280468
|
-
const unionScope = computeScopeUnion(this._scope,
|
|
281053
|
+
const tokens7 = await this._oauthProvider.tokens();
|
|
281054
|
+
const unionScope = computeScopeUnion(this._scope, tokens7?.scope, challenge.scope);
|
|
280469
281055
|
this._scope = unionScope;
|
|
280470
|
-
const forceReauthorization = isStrictScopeSuperset(unionScope,
|
|
281056
|
+
const forceReauthorization = isStrictScopeSuperset(unionScope, tokens7?.scope);
|
|
280471
281057
|
return auth(this._oauthProvider, {
|
|
280472
281058
|
serverUrl: this._url,
|
|
280473
281059
|
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
@@ -281118,7 +281704,7 @@ init_src();
|
|
|
281118
281704
|
init_backend();
|
|
281119
281705
|
import { fork as fork2 } from "node:child_process";
|
|
281120
281706
|
import { randomBytes as randomBytes11 } from "node:crypto";
|
|
281121
|
-
import { mkdir as mkdir32, open as open13, readFile as
|
|
281707
|
+
import { mkdir as mkdir32, open as open13, readFile as readFile53, rename as rename11, rm as rm20, stat as stat19, writeFile as writeFile34 } from "node:fs/promises";
|
|
281122
281708
|
import { createRequire as createRequire6 } from "node:module";
|
|
281123
281709
|
import { join as join69 } from "node:path";
|
|
281124
281710
|
var WORLD_SERVER_IDLE_MS = 10 * 6e4;
|
|
@@ -281134,7 +281720,7 @@ async function writePrivate(path9, value6) {
|
|
|
281134
281720
|
}
|
|
281135
281721
|
async function readJson2(path9) {
|
|
281136
281722
|
try {
|
|
281137
|
-
return JSON.parse(await
|
|
281723
|
+
return JSON.parse(await readFile53(path9, "utf8"));
|
|
281138
281724
|
} catch {
|
|
281139
281725
|
return void 0;
|
|
281140
281726
|
}
|
|
@@ -281714,7 +282300,7 @@ init_src();
|
|
|
281714
282300
|
// packages/cli/src/commands/world-company.ts
|
|
281715
282301
|
init_src();
|
|
281716
282302
|
import { constants as constants13 } from "node:fs";
|
|
281717
|
-
import { lstat as lstat12, mkdir as mkdir34, open as open14, readFile as
|
|
282303
|
+
import { lstat as lstat12, mkdir as mkdir34, open as open14, readFile as readFile54, rm as rm21 } from "node:fs/promises";
|
|
281718
282304
|
import { dirname as dirname26, join as join71, resolve as resolve54 } from "node:path";
|
|
281719
282305
|
|
|
281720
282306
|
// backend/src/company/fetch.ts
|
|
@@ -281974,7 +282560,7 @@ async function writeCompanyFiles(cwd, files2, force) {
|
|
|
281974
282560
|
try {
|
|
281975
282561
|
const stat22 = await lstat12(target6);
|
|
281976
282562
|
if (stat22.isFile() && !force) throw new AnchaError("USAGE", `${file3.relativePath} already exists`, { hint: "pass --force to overwrite generated files" });
|
|
281977
|
-
previous.set(target6, await
|
|
282563
|
+
previous.set(target6, await readFile54(target6));
|
|
281978
282564
|
} catch (error65) {
|
|
281979
282565
|
if (error65.code !== "ENOENT") throw error65;
|
|
281980
282566
|
previous.set(target6, void 0);
|
|
@@ -282030,7 +282616,7 @@ async function worldCompany(ctx, url4, options5, deps = {}) {
|
|
|
282030
282616
|
let source = null, fetched = [], modelCredit = null;
|
|
282031
282617
|
if (options5.profile) {
|
|
282032
282618
|
try {
|
|
282033
|
-
profile2 = parseCompanyProfile(JSON.parse(await
|
|
282619
|
+
profile2 = parseCompanyProfile(JSON.parse(await readFile54(resolve54(ctx.io.cwd, options5.profile), "utf8")));
|
|
282034
282620
|
} catch {
|
|
282035
282621
|
throw new AnchaError("CONFIG_INVALID", "company profile file must contain a valid version 1 profile", { hint: "see ancha docs company" });
|
|
282036
282622
|
}
|
|
@@ -282114,7 +282700,7 @@ function registerWorldFrom(command, ctx) {
|
|
|
282114
282700
|
// packages/cli/src/commands/world-import.ts
|
|
282115
282701
|
init_src();
|
|
282116
282702
|
import { existsSync as existsSync5 } from "node:fs";
|
|
282117
|
-
import { mkdir as mkdir35, readdir as readdir16, readFile as
|
|
282703
|
+
import { mkdir as mkdir35, readdir as readdir16, readFile as readFile56, stat as stat20, writeFile as writeFile36 } from "node:fs/promises";
|
|
282118
282704
|
import { extname as extname3, join as join72, relative as relative27, resolve as resolve56 } from "node:path";
|
|
282119
282705
|
|
|
282120
282706
|
// backend/src/kit/netsuite-import.ts
|
|
@@ -282606,7 +283192,7 @@ function realmOf(href2) {
|
|
|
282606
283192
|
const m = href2 === void 0 ? null : /^https?:\/\/(\d{4,10})(?:[-_]sb(\d{1,2}))?\.suitetalk\.api\.netsuite\.com/i.exec(href2);
|
|
282607
283193
|
return m ? `${m[1]}${m[2] ? `_SB${m[2]}` : ""}` : void 0;
|
|
282608
283194
|
}
|
|
282609
|
-
function
|
|
283195
|
+
function readFile55(file3, type, notes7) {
|
|
282610
283196
|
const text31 = file3.text.replace(/^/, ""), start2 = text31.trimStart();
|
|
282611
283197
|
if (!/^[[{]/.test(start2)) return readCsv2(file3.path, text31, type, notes7);
|
|
282612
283198
|
let values3;
|
|
@@ -283832,7 +284418,7 @@ function importNetsuite(files2, options5) {
|
|
|
283832
284418
|
const notes7 = [], problems = [], read7 = [], type = options5.type === void 0 ? void 0 : canonical10(options5.type);
|
|
283833
284419
|
let raws = [];
|
|
283834
284420
|
for (const file3 of files2) {
|
|
283835
|
-
let rows35 =
|
|
284421
|
+
let rows35 = readFile55(file3, type, notes7).map((raw3) => ({ ...raw3, type: rowType(raw3) }));
|
|
283836
284422
|
const untyped = rows35.filter((raw3) => raw3.type === "record" || raw3.type === TRANSACTION || raw3.type === ENTITY2);
|
|
283837
284423
|
if (untyped.length) problems.push(`${file3.path}: ${untyped.length === 1 ? "a record" : `${untyped.length} records`} with no record type: name the file after its type (customers.csv, invoice.json) or pass --type`);
|
|
283838
284424
|
rows35 = rows35.filter((raw3) => !untyped.includes(raw3));
|
|
@@ -284003,7 +284589,7 @@ async function worldImportNetsuite(ctx, paths3, options5) {
|
|
|
284003
284589
|
if (existsSync5(worldPath) && !options5.force) throw new AnchaError("USAGE", `${rel(worldPath)} already exists`, { hint: "pass --force to overwrite it, or choose another --id" });
|
|
284004
284590
|
const names8 = [...new Set((await Promise.all(paths3.map((path9) => exportFiles(ctx.io.cwd, path9)))).flat())];
|
|
284005
284591
|
if (!names8.length) throw new AnchaError("USAGE", `no export files in ${paths3.join(", ")}`, { hint: "NetSuite exports are .json (REST records, SuiteQL results) and .csv (saved searches)" });
|
|
284006
|
-
const files2 = await Promise.all(names8.map(async (name5) => ({ path: rel(name5), text: decodeEvalText(await
|
|
284592
|
+
const files2 = await Promise.all(names8.map(async (name5) => ({ path: rel(name5), text: decodeEvalText(await readFile56(name5)).text })));
|
|
284007
284593
|
const imported2 = importNetsuite(files2, {
|
|
284008
284594
|
id: options5.id,
|
|
284009
284595
|
now: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -284094,7 +284680,7 @@ init_privacy();
|
|
|
284094
284680
|
init_assets();
|
|
284095
284681
|
init_report2();
|
|
284096
284682
|
import { createHash as createHash85, randomBytes as randomBytes12 } from "node:crypto";
|
|
284097
|
-
import { lstat as lstat13, mkdir as mkdir36, mkdtemp as mkdtemp12, readFile as
|
|
284683
|
+
import { lstat as lstat13, mkdir as mkdir36, mkdtemp as mkdtemp12, readFile as readFile57, rename as rename12, rm as rm22, writeFile as writeFile37 } from "node:fs/promises";
|
|
284098
284684
|
import { dirname as dirname27, join as join73, resolve as resolve57 } from "node:path";
|
|
284099
284685
|
var object27 = external_exports.record(external_exports.string(), external_exports.unknown());
|
|
284100
284686
|
var instant = external_exports.string().max(80).refine((value6) => /^\d{4}-\d\d-\d\dT.+(?:Z|[+-]\d\d:\d\d)$/.test(value6) && Number.isFinite(Date.parse(value6)));
|
|
@@ -284262,7 +284848,7 @@ async function recordPytestRun(cwd, input5, env2 = {}) {
|
|
|
284262
284848
|
const exists7 = async () => {
|
|
284263
284849
|
await preflightFiles(cwd, [{ relativePath: `${relative29}/record.json`, content: "" }]);
|
|
284264
284850
|
const completed = async () => {
|
|
284265
|
-
const text31 = await
|
|
284851
|
+
const text31 = await readFile57(join73(runDir, "record.json"), "utf8");
|
|
284266
284852
|
let previous;
|
|
284267
284853
|
try {
|
|
284268
284854
|
previous = JSON.parse(text31);
|
|
@@ -284396,9 +284982,9 @@ ${formatTable(value6.configuration.preset.datasets.map((data7) => [data7.tool, d
|
|
|
284396
284982
|
}
|
|
284397
284983
|
|
|
284398
284984
|
// packages/cli/src/commands/secrets.ts
|
|
284399
|
-
var
|
|
284985
|
+
var import_yaml22 = __toESM(require_dist(), 1);
|
|
284400
284986
|
init_src();
|
|
284401
|
-
import { readFile as
|
|
284987
|
+
import { readFile as readFile58, writeFile as writeFile38 } from "node:fs/promises";
|
|
284402
284988
|
import { resolve as resolve59 } from "node:path";
|
|
284403
284989
|
init_credentials();
|
|
284404
284990
|
var NAME_RE2 = /^[A-Z][A-Z0-9_]{0,63}$/;
|
|
@@ -284406,15 +284992,15 @@ var DEFERRED_SYNC = "Saved in the workspace; the workspace machine picks it up w
|
|
|
284406
284992
|
async function nameInConfig(ctx, names8) {
|
|
284407
284993
|
const label7 = ctx.globals().config ?? "ancha.yaml", file3 = resolve59(ctx.io.cwd, label7);
|
|
284408
284994
|
const them = names8.length === 1 ? "it" : "them", list19 = names8.join(", ");
|
|
284409
|
-
const text31 = await
|
|
284995
|
+
const text31 = await readFile58(file3, "utf8").catch(() => void 0);
|
|
284410
284996
|
if (text31 === void 0) return { passEnvHint: `no ${label7} here: list ${list19} under agent.pass_env in the agent's ${label7} so its cloud runs get ${them}` };
|
|
284411
|
-
const doc = (0,
|
|
284997
|
+
const doc = (0, import_yaml22.parseDocument)(text31);
|
|
284412
284998
|
const listed2 = (path9) => {
|
|
284413
284999
|
const node5 = doc.getIn(path9);
|
|
284414
|
-
return (0,
|
|
285000
|
+
return (0, import_yaml22.isSeq)(node5) ? node5.items.map((item2) => String((0, import_yaml22.isScalar)(item2) ? item2.value : item2)) : [];
|
|
284415
285001
|
};
|
|
284416
285002
|
const passEnv = doc.getIn(["agent", "pass_env"]);
|
|
284417
|
-
if (doc.errors.length > 0 || !(0,
|
|
285003
|
+
if (doc.errors.length > 0 || !(0, import_yaml22.isMap)(doc.get("agent")) || passEnv !== void 0 && !(0, import_yaml22.isSeq)(passEnv)) return { passEnvHint: `list ${list19} under agent.pass_env in ${label7} so the agent's cloud runs get ${them}` };
|
|
284418
285004
|
const named5 = /* @__PURE__ */ new Set([...listed2(["agent", "pass_env"]), ...listed2(["agent", "execution", "env"])]);
|
|
284419
285005
|
const added = names8.filter((name5) => !named5.has(name5));
|
|
284420
285006
|
if (added.length === 0) return { passEnv: { file: label7, added } };
|
|
@@ -284828,9 +285414,9 @@ function registerSchema(program2, ctx) {
|
|
|
284828
285414
|
// packages/cli/src/commands/runs.ts
|
|
284829
285415
|
import { randomUUID as randomUUID23 } from "node:crypto";
|
|
284830
285416
|
init_run_metadata();
|
|
284831
|
-
var
|
|
285417
|
+
var import_yaml23 = __toESM(require_dist(), 1);
|
|
284832
285418
|
init_src();
|
|
284833
|
-
import { mkdir as mkdir37, readFile as
|
|
285419
|
+
import { mkdir as mkdir37, readFile as readFile59, stat as stat21, writeFile as writeFile39 } from "node:fs/promises";
|
|
284834
285420
|
import { basename as basename18, join as join74, relative as relative28, resolve as resolve60 } from "node:path";
|
|
284835
285421
|
init_report2();
|
|
284836
285422
|
init_run_store();
|
|
@@ -284861,7 +285447,7 @@ async function testTask(ctx, file3, worldOverride) {
|
|
|
284861
285447
|
const path9 = resolve60(ctx.io.cwd, file3);
|
|
284862
285448
|
let doc;
|
|
284863
285449
|
try {
|
|
284864
|
-
doc = (0,
|
|
285450
|
+
doc = (0, import_yaml23.parse)(await readFile59(path9, "utf8"));
|
|
284865
285451
|
} catch (error65) {
|
|
284866
285452
|
throw new AnchaError("CONFIG_INVALID", `cannot read ${file3}: ${error65 instanceof Error ? error65.message.split("\n")[0] : String(error65)}`, { hint: "pass a task file (version 2) or a test file (scene.yaml)" });
|
|
284867
285453
|
}
|
|
@@ -284965,7 +285551,7 @@ next page: ancha runs list --cursor ${page20.nextCursor}`}`);
|
|
|
284965
285551
|
const workspace4 = await uploadWorkspace(ctx);
|
|
284966
285552
|
const summary = await loadRunSummary(ctx.io.cwd, ref23, options5.out);
|
|
284967
285553
|
const runDir = join74(resolve60(ctx.io.cwd, options5.out ?? DEFAULT_RUNS_DIR), summary.runId);
|
|
284968
|
-
const inputs2 = JSON.parse(await
|
|
285554
|
+
const inputs2 = JSON.parse(await readFile59(join74(runDir, "inputs.json"), "utf8").catch(() => "{}"));
|
|
284969
285555
|
const passEnv = inputs2.agentEnvironment?.passEnv ?? (await ctx.loadConfig().catch(() => void 0))?.agent?.passEnv ?? [];
|
|
284970
285556
|
const inheritEnv = inputs2.agentEnvironment?.inheritEnv ?? summary.agentEnvironment?.inheritAll === true;
|
|
284971
285557
|
const upload6 = await uploadRun(ctx, workspace4, { runId: summary.runId, runDir, passEnv, inheritEnv });
|
|
@@ -284987,13 +285573,13 @@ next page: ancha runs list --cursor ${page20.nextCursor}`}`);
|
|
|
284987
285573
|
});
|
|
284988
285574
|
}
|
|
284989
285575
|
await mkdir37(dest, { recursive: true });
|
|
284990
|
-
const inputs2 = await
|
|
285576
|
+
const inputs2 = await readFile59(join74(resolve60(ctx.io.cwd, options5.out ?? DEFAULT_RUNS_DIR), summary.runId, "inputs.json"), "utf8").then((text31) => JSON.parse(text31), () => ({}));
|
|
284991
285577
|
const files2 = [], cases = withSeeds(inputs2.cases ?? []);
|
|
284992
285578
|
for (const scene2 of summary.scenes) for (const trial of scene2.trialsDetail) {
|
|
284993
285579
|
const dir2 = resolve60(ctx.io.cwd, trial.dir), name5 = basename18(dir2), file3 = join74(dest, `${name5}.ir.jsonl`);
|
|
284994
285580
|
await writeFile39(file3, attemptToIr(await readAttemptTrace(dir2), `${summary.runId}/${name5}`, summary.agent, {
|
|
284995
285581
|
scene: cases.find((c) => c.id === scene2.sceneId)?.scene,
|
|
284996
|
-
checks: await
|
|
285582
|
+
checks: await readFile59(join74(dir2, "checks.json"), "utf8").then((text31) => JSON.parse(text31), () => void 0),
|
|
284997
285583
|
outcome: trial.outcome ?? (trial.valid === false ? "invalid" : trial.passed ? "passed" : "failed"),
|
|
284998
285584
|
exit: trial.exit,
|
|
284999
285585
|
exitCode: trial.exitCode
|