@ancha-labs/cli 0.4.44 → 0.4.45
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 +27 -7
- package/lib/worker.mjs +8 -5
- package/package.json +1 -1
package/lib/ancha.mjs
CHANGED
|
@@ -231293,7 +231293,7 @@ var init_jobs_contract = __esm({
|
|
|
231293
231293
|
CLOUD_MODEL_HOSTS = ["openrouter.ai", "api.openai.com", "api.anthropic.com", "generativelanguage.googleapis.com", "api.groq.com", "api.mistral.ai", "api.together.xyz", "api.fireworks.ai", "api.deepseek.com", "api.x.ai", "api.cohere.com"];
|
|
231294
231294
|
DEFAULT_MODEL_HOSTS = ["openrouter.ai", "api.openai.com", "api.anthropic.com"];
|
|
231295
231295
|
MODEL_KEY_NAMES = ["OPENAI_API_KEY", "ANTHROPIC_API_KEY", "GEMINI_API_KEY", "GOOGLE_API_KEY", "OPENROUTER_API_KEY", "AZURE_OPENAI_API_KEY", "MISTRAL_API_KEY", "GROQ_API_KEY", "DEEPSEEK_API_KEY", "XAI_API_KEY", "COHERE_API_KEY", "TOGETHER_API_KEY", "FIREWORKS_API_KEY"];
|
|
231296
|
-
PROBE_OUTCOMES = ["answered", "refused", "outside_host", "unserved", "crashed", "idle", "no_answer", "wrong_answer", "model_key", "missing_secret"];
|
|
231296
|
+
PROBE_OUTCOMES = ["answered", "refused", "outside_host", "unserved", "crashed", "idle", "no_answer", "wrong_answer", "model_key", "missing_secret", "route_key"];
|
|
231297
231297
|
ANSWER_SOURCES = ["done", "reply", "stdout"];
|
|
231298
231298
|
HEARTBEAT_MS = 1e4;
|
|
231299
231299
|
AGENT_UID = 10001;
|
|
@@ -232651,7 +232651,7 @@ var init_composio_connection = __esm({
|
|
|
232651
232651
|
status;
|
|
232652
232652
|
slug;
|
|
232653
232653
|
constructor(status6, slug16) {
|
|
232654
|
-
super(`Composio did not create the attempt's test connection (${status6} ${slug16}): check that the workspace secret COMPOSIO_API_KEY is a project API key that may create auth configs and connected accounts.`);
|
|
232654
|
+
super(status6 === 401 || status6 === 403 ? `Composio did not create the attempt's test connection (${status6} ${slug16}): check that the workspace secret COMPOSIO_API_KEY is a project API key that may create auth configs and connected accounts.` : `Composio did not create the attempt's test connection (${status6} ${slug16}); run again.`);
|
|
232655
232655
|
this.name = "ComposioConnectionError";
|
|
232656
232656
|
this.status = status6;
|
|
232657
232657
|
this.slug = slug16;
|
|
@@ -232879,7 +232879,7 @@ async function startIngressClient(options5) {
|
|
|
232879
232879
|
if (reached) counts2[toolkit].reached++;
|
|
232880
232880
|
}
|
|
232881
232881
|
if (event3.op === "refused") counts2[toolkit].refused++;
|
|
232882
|
-
record32({ ...event3, toolkit, relayHash: hash6(id15) }, 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);
|
|
232882
|
+
record32({ ...event3, toolkit, relayHash: hash6(id15) }, 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 && event3.status === 401 && toolkit === "quickbooks" && (event3.via ?? "direct") === "direct" ? issue9("ROUTE_KEY_REJECTED", KEY_REJECTED, toolkit) : 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) : event3.op === "catalog" && event3.via !== "mcp" && event3.status === 401 ? issue9("ROUTE_KEY_REJECTED", KEY_REJECTED, toolkit) : void 0);
|
|
232883
232883
|
},
|
|
232884
232884
|
summary: () => {
|
|
232885
232885
|
const result = {};
|
|
@@ -232916,7 +232916,7 @@ async function startIngressClient(options5) {
|
|
|
232916
232916
|
}
|
|
232917
232917
|
};
|
|
232918
232918
|
}
|
|
232919
|
-
var headersSchema, requestSchema, batchSchema, bindSchema, forwarded, methods2, hash6, REFUSAL_FIX, unreachedDetail;
|
|
232919
|
+
var headersSchema, requestSchema, batchSchema, bindSchema, forwarded, methods2, hash6, REFUSAL_FIX, unreachedDetail, KEY_REJECTED;
|
|
232920
232920
|
var init_ingress_client = __esm({
|
|
232921
232921
|
"backend/src/execution/ingress-client.ts"() {
|
|
232922
232922
|
"use strict";
|
|
@@ -232954,6 +232954,7 @@ var init_ingress_client = __esm({
|
|
|
232954
232954
|
MCP_BATCH: "send one JSON-RPC object per MCP request"
|
|
232955
232955
|
};
|
|
232956
232956
|
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.`;
|
|
232957
|
+
KEY_REJECTED = "Composio answered 401 to the agent's call through the route: it does not accept the workspace secret COMPOSIO_API_KEY, which the route sends for the agent. Export the Composio project's API key as COMPOSIO_API_KEY, run ancha secrets set COMPOSIO_API_KEY, then run again.";
|
|
232957
232958
|
}
|
|
232958
232959
|
});
|
|
232959
232960
|
|
|
@@ -233021,13 +233022,15 @@ async function runRoutedTrial(spec, run7) {
|
|
|
233021
233022
|
return { ...result, routes: route15.summary(), ...result.harnessIssues.some((issue9) => issue9.owner === "harness" && issue9.code?.startsWith("ROUTE_")) && { valid: false, passed: false } };
|
|
233022
233023
|
} catch (error65) {
|
|
233023
233024
|
await route15.close();
|
|
233024
|
-
const
|
|
233025
|
+
const stopped = error65 instanceof AnchaError && error65.code === "AGENT_UNREACHABLE" ? error65 : void 0;
|
|
233026
|
+
const connectionIssue = route15.entries().find((entry3) => entry3.issue?.code === "ROUTE_CONNECTION_FAILED")?.issue ?? (stopped ? route15.entries().find((entry3) => entry3.issue?.code === "ROUTE_KEY_REJECTED")?.issue : void 0);
|
|
233025
233027
|
if (!route15.failed && !connectionIssue || spec.signal?.aborted) throw error65;
|
|
233026
|
-
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." } });
|
|
233028
|
+
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: connectionIssue.code ?? "ROUTE_CONNECTION_FAILED", message: connectionIssue.message } : { code: "ROUTE_INGRESS_FAILED", message: "The Composio route could not be kept open." } });
|
|
233027
233029
|
if (!captured) {
|
|
233028
233030
|
result.trace = route15.entries().map((entry3, i) => ({ ...entry3, seq: i + 1 }));
|
|
233029
233031
|
result.harnessIssues = collectHarnessIssues(result.trace, []);
|
|
233030
233032
|
}
|
|
233033
|
+
if (stopped && connectionIssue?.code === "ROUTE_KEY_REJECTED") result.harnessIssues.push({ kind: "pipeline", owner: "agent", service: "agent", code: stopped.code, message: `${stopped.code}: ${stopped.message}`.slice(0, 500) });
|
|
233031
233034
|
await mkdir4(spec.dir, { recursive: true });
|
|
233032
233035
|
await writeFile3(join7(spec.dir, "trace.jsonl"), result.trace.map((entry3) => JSON.stringify(entry3) + "\n").join(""));
|
|
233033
233036
|
return { ...result, routes: route15.summary() };
|
|
@@ -243407,6 +243410,7 @@ function connectionRouteEvidence(routes2, summary, trace2, log3) {
|
|
|
243407
243410
|
if (!tools2.length) return { details: [] };
|
|
243408
243411
|
const counts2 = tools2.map((tool) => ({ tool, route: summary?.[tool] }));
|
|
243409
243412
|
const details = counts2.map(({ tool, route: route15 }) => `${tool === "netsuite" ? "NetSuite" : "QuickBooks"} via Composio: ${route15?.executions ?? 0} execution${route15?.executions === 1 ? "" : "s"}, ${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}` : ""}`);
|
|
243413
|
+
if (routeKeyRejected(trace2)) return { details, reason: { ...ROUTE_KEY_REASON } };
|
|
243410
243414
|
const refused2 = trace2.filter((entry3) => entry3.routeEvent?.leg === "platform" && entry3.routeEvent.op === "refused");
|
|
243411
243415
|
for (const entry3 of refused2.slice(0, 5)) {
|
|
243412
243416
|
const event3 = entry3.routeEvent;
|
|
@@ -243438,9 +243442,17 @@ function connectionRouteEvidence(routes2, summary, trace2, log3) {
|
|
|
243438
243442
|
if (counts2.some(({ route: route15 }) => !route15?.reached)) return { details };
|
|
243439
243443
|
return { details, reason: { code: "answered", level: "pass", message: "The agent\u2019s Composio executions reached each routed world." } };
|
|
243440
243444
|
}
|
|
243445
|
+
var ROUTE_KEY_REASON, routeKeyRejected;
|
|
243441
243446
|
var init_connection_route = __esm({
|
|
243442
243447
|
"backend/src/execution/connection-route.ts"() {
|
|
243443
243448
|
"use strict";
|
|
243449
|
+
ROUTE_KEY_REASON = {
|
|
243450
|
+
code: "route_key",
|
|
243451
|
+
level: "fail",
|
|
243452
|
+
message: "Composio did not accept the workspace secret COMPOSIO_API_KEY: it answered 401 to the agent\u2019s call through the route.",
|
|
243453
|
+
fix: "Export the Composio project\u2019s API key as COMPOSIO_API_KEY, run ancha secrets set COMPOSIO_API_KEY, then run ancha agent upload again."
|
|
243454
|
+
};
|
|
243455
|
+
routeKeyRejected = (entries4) => entries4.some((entry3) => entry3.issue?.code === "ROUTE_KEY_REJECTED");
|
|
243444
243456
|
}
|
|
243445
243457
|
});
|
|
243446
243458
|
|
|
@@ -243676,7 +243688,11 @@ async function runWithTask(descriptor3, agent, run7) {
|
|
|
243676
243688
|
const text31 = log3?.toString("utf8") ?? tail.join("\n");
|
|
243677
243689
|
const route15 = connectionRouteEvidence(agent.routes, trial.routes, trial.trace, text31);
|
|
243678
243690
|
if (route15.details.length) probe.routeDetails = route15.details;
|
|
243679
|
-
|
|
243691
|
+
if (route15.reason?.code === "route_key") {
|
|
243692
|
+
Object.assign(probe, { reason: route15.reason, logTail: tail.length > 0 ? tail : text31.trimEnd().split("\n").filter(Boolean).slice(-10) });
|
|
243693
|
+
return { state: "failed", probe, message: route15.reason.message };
|
|
243694
|
+
}
|
|
243695
|
+
const diagnosed = (code5) => code5 === "MODEL_KEY_REFUSED" || routed && (code5 === "ROUTE_REFUSED" || code5 === "ROUTE_NOT_REACHED" || code5 === "ROUTE_KEY_REJECTED");
|
|
243680
243696
|
const harnessIssue = trial.harnessIssues.some((issue9) => issue9.owner === "harness" && !diagnosed(issue9.code));
|
|
243681
243697
|
if (harnessIssue || !trial.valid && !trial.harnessIssues.some((issue9) => diagnosed(issue9.code))) {
|
|
243682
243698
|
Object.assign(probe, { logTail: tail, ...fix !== void 0 && { fix } });
|
|
@@ -243760,6 +243776,10 @@ async function probeSlackApp(descriptor3, agent, probe, deps) {
|
|
|
243760
243776
|
child3 = void 0;
|
|
243761
243777
|
const log3 = await readFile25(join44(descriptor3.outDir, "agent.log"), "utf8").catch(() => "");
|
|
243762
243778
|
probe.logTail = log3.trimEnd().split("\n").filter(Boolean).slice(-10);
|
|
243779
|
+
if (ingress && routeKeyRejected(ingress.entries())) {
|
|
243780
|
+
probe.reason = { ...ROUTE_KEY_REASON };
|
|
243781
|
+
return { state: "failed", probe, message: ROUTE_KEY_REASON.message };
|
|
243782
|
+
}
|
|
243763
243783
|
const fix = socket ? slackSocketFix : slackHttpFix;
|
|
243764
243784
|
return { state: "failed", probe, message: error65 instanceof AnchaError ? `${error65.message}${error65.hint ? ` ${error65.hint}` : ""}` : `The Slack app did not connect. ${fix}` };
|
|
243765
243785
|
} finally {
|
package/lib/worker.mjs
CHANGED
|
@@ -72333,7 +72333,7 @@ var init_composio_connection = __esm({
|
|
|
72333
72333
|
status;
|
|
72334
72334
|
slug;
|
|
72335
72335
|
constructor(status5, slug11) {
|
|
72336
|
-
super(`Composio did not create the attempt's test connection (${status5} ${slug11}): check that the workspace secret COMPOSIO_API_KEY is a project API key that may create auth configs and connected accounts.`);
|
|
72336
|
+
super(status5 === 401 || status5 === 403 ? `Composio did not create the attempt's test connection (${status5} ${slug11}): check that the workspace secret COMPOSIO_API_KEY is a project API key that may create auth configs and connected accounts.` : `Composio did not create the attempt's test connection (${status5} ${slug11}); run again.`);
|
|
72337
72337
|
this.name = "ComposioConnectionError";
|
|
72338
72338
|
this.status = status5;
|
|
72339
72339
|
this.slug = slug11;
|
|
@@ -72561,7 +72561,7 @@ async function startIngressClient(options5) {
|
|
|
72561
72561
|
if (reached) counts2[toolkit].reached++;
|
|
72562
72562
|
}
|
|
72563
72563
|
if (event3.op === "refused") counts2[toolkit].refused++;
|
|
72564
|
-
record15({ ...event3, toolkit, relayHash: hash2(id15) }, 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);
|
|
72564
|
+
record15({ ...event3, toolkit, relayHash: hash2(id15) }, 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 && event3.status === 401 && toolkit === "quickbooks" && (event3.via ?? "direct") === "direct" ? issue9("ROUTE_KEY_REJECTED", KEY_REJECTED, toolkit) : 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) : event3.op === "catalog" && event3.via !== "mcp" && event3.status === 401 ? issue9("ROUTE_KEY_REJECTED", KEY_REJECTED, toolkit) : void 0);
|
|
72565
72565
|
},
|
|
72566
72566
|
summary: () => {
|
|
72567
72567
|
const result = {};
|
|
@@ -72598,7 +72598,7 @@ async function startIngressClient(options5) {
|
|
|
72598
72598
|
}
|
|
72599
72599
|
};
|
|
72600
72600
|
}
|
|
72601
|
-
var headersSchema, requestSchema, batchSchema, bindSchema, forwarded, methods, hash2, REFUSAL_FIX, unreachedDetail;
|
|
72601
|
+
var headersSchema, requestSchema, batchSchema, bindSchema, forwarded, methods, hash2, REFUSAL_FIX, unreachedDetail, KEY_REJECTED;
|
|
72602
72602
|
var init_ingress_client = __esm({
|
|
72603
72603
|
"backend/src/execution/ingress-client.ts"() {
|
|
72604
72604
|
"use strict";
|
|
@@ -72636,6 +72636,7 @@ var init_ingress_client = __esm({
|
|
|
72636
72636
|
MCP_BATCH: "send one JSON-RPC object per MCP request"
|
|
72637
72637
|
};
|
|
72638
72638
|
unreachedDetail = (status5) => status5 === 401 || status5 === 403 ? `Composio answered ${status5} without calling the world: check the workspace secret COMPOSIO_API_KEY.` : status5 >= 500 ? `Composio answered ${status5} without calling the world; run again.` : `Composio answered ${status5} without calling the world: check the QuickBooks tool arguments and use the connection supplied by the route.`;
|
|
72639
|
+
KEY_REJECTED = "Composio answered 401 to the agent's call through the route: it does not accept the workspace secret COMPOSIO_API_KEY, which the route sends for the agent. Export the Composio project's API key as COMPOSIO_API_KEY, run ancha secrets set COMPOSIO_API_KEY, then run again.";
|
|
72639
72640
|
}
|
|
72640
72641
|
});
|
|
72641
72642
|
|
|
@@ -72703,13 +72704,15 @@ async function runRoutedTrial(spec, run5) {
|
|
|
72703
72704
|
return { ...result, routes: route15.summary(), ...result.harnessIssues.some((issue9) => issue9.owner === "harness" && issue9.code?.startsWith("ROUTE_")) && { valid: false, passed: false } };
|
|
72704
72705
|
} catch (error64) {
|
|
72705
72706
|
await route15.close();
|
|
72706
|
-
const
|
|
72707
|
+
const stopped = error64 instanceof AnchaError && error64.code === "AGENT_UNREACHABLE" ? error64 : void 0;
|
|
72708
|
+
const connectionIssue = route15.entries().find((entry2) => entry2.issue?.code === "ROUTE_CONNECTION_FAILED")?.issue ?? (stopped ? route15.entries().find((entry2) => entry2.issue?.code === "ROUTE_KEY_REJECTED")?.issue : void 0);
|
|
72707
72709
|
if (!route15.failed && !connectionIssue || spec.signal?.aborted) throw error64;
|
|
72708
|
-
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." } });
|
|
72710
|
+
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: connectionIssue.code ?? "ROUTE_CONNECTION_FAILED", message: connectionIssue.message } : { code: "ROUTE_INGRESS_FAILED", message: "The Composio route could not be kept open." } });
|
|
72709
72711
|
if (!captured) {
|
|
72710
72712
|
result.trace = route15.entries().map((entry2, i) => ({ ...entry2, seq: i + 1 }));
|
|
72711
72713
|
result.harnessIssues = collectHarnessIssues(result.trace, []);
|
|
72712
72714
|
}
|
|
72715
|
+
if (stopped && connectionIssue?.code === "ROUTE_KEY_REJECTED") result.harnessIssues.push({ kind: "pipeline", owner: "agent", service: "agent", code: stopped.code, message: `${stopped.code}: ${stopped.message}`.slice(0, 500) });
|
|
72713
72716
|
await mkdir2(spec.dir, { recursive: true });
|
|
72714
72717
|
await writeFile2(join3(spec.dir, "trace.jsonl"), result.trace.map((entry2) => JSON.stringify(entry2) + "\n").join(""));
|
|
72715
72718
|
return { ...result, routes: route15.summary() };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ancha-labs/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.45",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Simulation playgrounds for agents: run your agent against stateful replicas of Slack, GitHub, Datadog and more, each attempt on a fresh cloud machine in your app.ancha.io workspace, or on your computer.",
|
|
6
6
|
"bugs": {
|