@q-agent/agent 0.1.28 → 0.1.29

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/src/runner.js +29 -2
  2. package/package.json +1 -1
@@ -399,6 +399,13 @@ async function processJob(cfg, job) {
399
399
  * the workDir is always removed, even if some uploads fail or time out.
400
400
  */
401
401
  async function uploadEvidenceThenCleanup(cfg, executionId, pendingEvidence, workDir) {
402
+ // Tell the UI evidence is still incoming so it can show a loader instead of an
403
+ // empty panel while these deferred uploads land (results are already visible).
404
+ if (pendingEvidence.length > 0) {
405
+ await api
406
+ .postEvent(cfg, executionId, "exec.evidence.uploading", { count: pendingEvidence.length })
407
+ .catch(() => { });
408
+ }
402
409
  try {
403
410
  for (const ev of pendingEvidence) {
404
411
  await api
@@ -414,6 +421,13 @@ async function uploadEvidenceThenCleanup(cfg, executionId, pendingEvidence, work
414
421
  }
415
422
  finally {
416
423
  fs.rmSync(workDir, { recursive: true, force: true });
424
+ // Signal completion so the UI drops the loader and refetches the now-uploaded
425
+ // evidence — always fire (even on partial failure) so the loader never sticks.
426
+ if (pendingEvidence.length > 0) {
427
+ await api
428
+ .postEvent(cfg, executionId, "exec.evidence.done", {})
429
+ .catch(() => { });
430
+ }
417
431
  }
418
432
  }
419
433
  /**
@@ -980,7 +994,7 @@ async function processAuthoringJob(cfg, job) {
980
994
  }
981
995
  const sess = origin ? (0, session_1.sessionPathsForOrigin)(origin) : null;
982
996
  const profileDir = sess ? path.join(sess.dir, "browser-profile") : "";
983
- const finalize = async (code, discovered, summary, ok, costUsd = 0) => {
997
+ const finalize = async (code, discovered, summary, ok, costUsd = 0, refreshedCredentials = "") => {
984
998
  await api
985
999
  .postAuthoringFinalize(cfg, job.sessionId, {
986
1000
  code,
@@ -988,6 +1002,7 @@ async function processAuthoringJob(cfg, job) {
988
1002
  summary,
989
1003
  ok,
990
1004
  costUsd,
1005
+ refreshedCredentials,
991
1006
  })
992
1007
  .catch((err) => console.error("postAuthoringFinalize failed:", err));
993
1008
  };
@@ -1197,7 +1212,19 @@ async function processAuthoringJob(cfg, job) {
1197
1212
  case: job.caseId, phase: ok ? "done" : "failed", message: (summary || "").slice(0, 300), costUsd,
1198
1213
  })
1199
1214
  .catch(() => { });
1200
- await finalize(code, discovered, summary, ok, costUsd);
1215
+ // Auto-rotation (#cred-rotate): if we ran with the app's saved credential and
1216
+ // the CLI refreshed the OAuth token in our temp config dir, post the rotated
1217
+ // .credentials.json back so the server captures it before workDir is deleted.
1218
+ let refreshedCredentials = "";
1219
+ if (claudeConfigDir) {
1220
+ try {
1221
+ const credFile = path.join(claudeConfigDir, ".credentials.json");
1222
+ if (fs.existsSync(credFile))
1223
+ refreshedCredentials = fs.readFileSync(credFile, "utf-8");
1224
+ }
1225
+ catch { /* best-effort — a missing/unreadable file just skips rotation */ }
1226
+ }
1227
+ await finalize(code, discovered, summary, ok, costUsd, refreshedCredentials);
1201
1228
  }
1202
1229
  finally {
1203
1230
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@q-agent/agent",
3
- "version": "0.1.28",
3
+ "version": "0.1.29",
4
4
  "description": "Q-Agent Local Agent — claims execution jobs from the Q-Agent server and runs Playwright locally, so manual login/MFA happens on the user's own machine and session credentials never leave it.",
5
5
  "license": "UNLICENSED",
6
6
  "bin": {