@q-agent/agent 0.1.20 → 0.1.22

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.
@@ -957,13 +957,14 @@ async function processAuthoringJob(cfg, job) {
957
957
  }
958
958
  const sess = origin ? (0, session_1.sessionPathsForOrigin)(origin) : null;
959
959
  const profileDir = sess ? path.join(sess.dir, "browser-profile") : "";
960
- const finalize = async (code, discovered, summary, ok) => {
960
+ const finalize = async (code, discovered, summary, ok, costUsd = 0) => {
961
961
  await api
962
962
  .postAuthoringFinalize(cfg, job.sessionId, {
963
963
  code,
964
964
  discovered: discovered || {},
965
965
  summary,
966
966
  ok,
967
+ costUsd,
967
968
  })
968
969
  .catch((err) => console.error("postAuthoringFinalize failed:", err));
969
970
  };
@@ -988,7 +989,7 @@ async function processAuthoringJob(cfg, job) {
988
989
  // (emitted AFTER the replay is armed) so browser-harness never navigates
989
990
  // before the session is restored.
990
991
  const nm = (0, paths_1.agentNodeModules)();
991
- launcher = (0, child_process_1.spawn)((0, paths_1.nodeBin)(), [(0, paths_1.vendorAuthoringScript)(), job.baseUrl, String(port), profileDir, sess ? sess.sessionStoragePath : ""], { env: nodePathEnv(nm), stdio: ["pipe", "pipe", "pipe"] });
992
+ launcher = (0, child_process_1.spawn)((0, paths_1.nodeBin)(), [(0, paths_1.vendorAuthoringScript)(), job.baseUrl, String(port), profileDir, sess ? sess.sessionStoragePath : ""], { env: nodePathEnv(nm), stdio: ["pipe", "pipe", "pipe"], windowsHide: true });
992
993
  activeChild = launcher;
993
994
  let launcherErr = "";
994
995
  launcher.stderr?.on("data", (d) => { launcherErr += String(d); });
@@ -1069,6 +1070,7 @@ async function processAuthoringJob(cfg, job) {
1069
1070
  cwd: workDir,
1070
1071
  env: claudeEnv,
1071
1072
  stdio: ["ignore", "pipe", "pipe"],
1073
+ windowsHide: true,
1072
1074
  });
1073
1075
  activeChild = claude;
1074
1076
  // Surface each step to the agent console + the run WebSocket so the operator
@@ -1085,6 +1087,7 @@ async function processAuthoringJob(cfg, job) {
1085
1087
  };
1086
1088
  let cerr = "";
1087
1089
  let finalResult = "";
1090
+ let costUsd = 0;
1088
1091
  let buf = "";
1089
1092
  const handleEvent = (ev) => {
1090
1093
  if (ev.type === "assistant" && ev.message?.content) {
@@ -1099,8 +1102,11 @@ async function processAuthoringJob(cfg, job) {
1099
1102
  }
1100
1103
  }
1101
1104
  }
1102
- else if (ev.type === "result" && typeof ev.result === "string") {
1103
- finalResult = ev.result;
1105
+ else if (ev.type === "result") {
1106
+ if (typeof ev.result === "string")
1107
+ finalResult = ev.result;
1108
+ if (typeof ev.total_cost_usd === "number")
1109
+ costUsd = ev.total_cost_usd;
1104
1110
  }
1105
1111
  };
1106
1112
  claude.stdout?.on("data", (d) => {
@@ -1141,14 +1147,14 @@ async function processAuthoringJob(cfg, job) {
1141
1147
  summary = `${summary || "Live authoring produced no spec."} (claude exit ${exitCode})` +
1142
1148
  (errTail ? `\n[claude stderr] ${errTail}` : "");
1143
1149
  }
1144
- emitStep(ok ? "✓ spec authored" : `✗ no spec (claude exit ${exitCode})`);
1145
- // Terminal event so the UI can close the live authoring trail.
1150
+ emitStep(ok ? `✓ spec authored · $${costUsd.toFixed(2)}` : `✗ no spec (claude exit ${exitCode})`);
1151
+ // Terminal event (carries the run cost) so the UI can close the trail + show $.
1146
1152
  await api
1147
1153
  .postAuthoringEvent(cfg, job.sessionId, "authoring.progress", {
1148
- case: job.caseId, phase: ok ? "done" : "failed", message: (summary || "").slice(0, 300),
1154
+ case: job.caseId, phase: ok ? "done" : "failed", message: (summary || "").slice(0, 300), costUsd,
1149
1155
  })
1150
1156
  .catch(() => { });
1151
- await finalize(code, discovered, summary, ok);
1157
+ await finalize(code, discovered, summary, ok, costUsd);
1152
1158
  }
1153
1159
  finally {
1154
1160
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@q-agent/agent",
3
- "version": "0.1.20",
3
+ "version": "0.1.22",
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": {
@@ -149,7 +149,7 @@ async function armAuthAndNavigate(chromium, port, byOrigin) {
149
149
  '--no-first-run', '--no-default-browser-check', '--new-window',
150
150
  ...containerFlags(),
151
151
  launchUrl,
152
- ], { detached: false, stdio: 'ignore' });
152
+ ], { detached: false, stdio: 'ignore', windowsHide: true });
153
153
  console.error('authoring_browser launched:', exe, 'port', PORT, 'replay:', Boolean(chromium));
154
154
 
155
155
  if (!(await waitForCDP(PORT, 20000))) {