@archal/cli 0.3.0 → 0.3.1

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.
Files changed (2) hide show
  1. package/dist/index.js +32 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1411,6 +1411,33 @@ async function collectStateFromHttp(twinUrls, bearerToken, adminAuth) {
1411
1411
  }
1412
1412
  return state;
1413
1413
  }
1414
+ var HTTP_PUSH_TIMEOUT_MS = 1e4;
1415
+ async function pushStateToCloud(twinUrls, seedSelections, bearerToken, adminAuth) {
1416
+ const headers = adminAuth ? { "x-archal-admin-token": adminAuth.token, ...adminAuth.userId ? { "x-archal-user-id": adminAuth.userId } : {}, "Content-Type": "application/json" } : bearerToken ? { "Authorization": `Bearer ${bearerToken}`, "Content-Type": "application/json" } : { "Content-Type": "application/json" };
1417
+ for (const sel of seedSelections) {
1418
+ if (!sel.seedData) continue;
1419
+ const baseUrl = twinUrls[sel.twinName];
1420
+ if (!baseUrl) {
1421
+ warn(`No cloud URL for twin "${sel.twinName}", skipping state push`);
1422
+ continue;
1423
+ }
1424
+ const url = `${twinBasePath(baseUrl)}/state`;
1425
+ debug(`Pushing dynamic seed to ${sel.twinName}`, { url });
1426
+ const response = await fetch(url, {
1427
+ method: "PUT",
1428
+ headers,
1429
+ body: JSON.stringify(sel.seedData),
1430
+ signal: AbortSignal.timeout(HTTP_PUSH_TIMEOUT_MS)
1431
+ });
1432
+ if (!response.ok) {
1433
+ const text = await response.text().catch(() => "");
1434
+ throw new Error(
1435
+ `Failed to push dynamic seed to twin "${sel.twinName}": HTTP ${response.status}${text ? ` \u2014 ${text}` : ""}`
1436
+ );
1437
+ }
1438
+ debug(`Pushed dynamic seed to ${sel.twinName} successfully`);
1439
+ }
1440
+ }
1414
1441
  async function collectTraceFromHttp(twinUrls, bearerToken, adminAuth) {
1415
1442
  const allTraces = [];
1416
1443
  const headers = adminAuth ? { "x-archal-admin-token": adminAuth.token, ...adminAuth.userId ? { "x-archal-user-id": adminAuth.userId } : {} } : bearerToken ? { "Authorization": `Bearer ${bearerToken}` } : {};
@@ -5267,6 +5294,11 @@ async function executeSingleRun(runIndex, scenario, agentConfig, seedSelections,
5267
5294
  try {
5268
5295
  let beforeState;
5269
5296
  if (useCloud) {
5297
+ const hasDynamicSeeds = seedSelections.some((s) => s.seedData);
5298
+ if (hasDynamicSeeds) {
5299
+ progress("Pushing dynamic seeds to cloud twins...");
5300
+ await pushStateToCloud(cloudTwinUrls, seedSelections, apiBearerToken, adminAuth);
5301
+ }
5270
5302
  progress("Fetching seed state from cloud twins...");
5271
5303
  beforeState = await collectStateFromHttp(cloudTwinUrls, apiBearerToken, adminAuth);
5272
5304
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archal/cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "The archal CLI — test AI agents against digital twins",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",