agentinbox-cli 0.1.0-nightly.6 → 0.1.0-nightly.8

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/dist/cli.js CHANGED
@@ -63,7 +63,7 @@ const configInput = (o) => ({
63
63
  const program = new Command("agentinbox").description("Self-hosted Gmail broker for AI agents: MCP tools, webhooks, guardrails and a web console.").version(version, "-v, --version", "print the version").helpOption("-h, --help", "show help").addHelpText("after", "\nWithout installing: npx agentinbox-cli [command]. To install the command: npm i -g agentinbox-cli").showSuggestionAfterError();
64
64
  withServerOptions(program.command("start", { isDefault: true }).description("run agentinbox in the foreground (default)")).option("--no-open", "don't open a browser on first run").option("--dev", "development: API only, the console runs on Vite (:5173)").allowExcessArguments().action(async (o, cmd) => {
65
65
  if (cmd.args.length) throw new Error(unknownCommand(cmd.args[0]));
66
- const { runForeground } = await import("./server-CL0omdA2.js");
66
+ const { runForeground } = await import("./server-B97P3fiX.js");
67
67
  await runForeground({
68
68
  ...configInput(o),
69
69
  dev: !!o.dev,
@@ -2965,14 +2965,30 @@ const scriptJson = (v) => JSON.stringify(v).replace(/</g, "\\u003c");
2965
2965
  /**
2966
2966
  * The callback page's only executable script. It is static (all dynamic data lives in the JSON block
2967
2967
  * #oauth-result), so the CSP can allow exactly this hash instead of inline scripts in general.
2968
+ *
2969
+ * The result goes to the opener (the console's popup host) and also on a same-origin
2970
+ * BroadcastChannel: Google's pages can sever window.opener (COOP), and the console may run on a
2971
+ * different origin than publicUrl. Without an opener the page stays open with its link to /accounts.
2968
2972
  */
2969
2973
  const OAUTH_CALLBACK_SCRIPT = `(function () {
2970
2974
  try {
2971
2975
  var r = JSON.parse(document.getElementById("oauth-result").textContent);
2976
+ var msg = { type: "agentinbox:oauth", ok: r.ok, email: r.email, error: r.error };
2977
+ var toOpener = false;
2972
2978
  if (window.opener) {
2973
- window.opener.postMessage({ type: "agentinbox:oauth", ok: r.ok, email: r.email, error: r.error }, r.targetOrigin);
2974
- if (r.ok) setTimeout(function () { window.close(); }, 600);
2979
+ try {
2980
+ window.opener.postMessage(msg, r.targetOrigin);
2981
+ toOpener = true;
2982
+ } catch (e) {}
2983
+ }
2984
+ if (typeof BroadcastChannel === "function") {
2985
+ try {
2986
+ var channel = new BroadcastChannel("agentinbox-oauth");
2987
+ channel.postMessage(msg);
2988
+ channel.close();
2989
+ } catch (e) {}
2975
2990
  }
2991
+ if (r.ok && toOpener) setTimeout(function () { window.close(); }, 600);
2976
2992
  } catch (e) {}
2977
2993
  })();`;
2978
2994
  `${createHash("sha256").update(OAUTH_CALLBACK_SCRIPT).digest("base64")}`;
@@ -7180,4 +7196,4 @@ function openBrowser(url) {
7180
7196
  //#endregion
7181
7197
  export { runForeground };
7182
7198
 
7183
- //# sourceMappingURL=server-CL0omdA2.js.map
7199
+ //# sourceMappingURL=server-B97P3fiX.js.map