omp-antigravity-acp-provider 0.1.41 → 0.1.42

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.
@@ -71,16 +71,34 @@ export async function preferNewestAcpRuntime(
71
71
  env: NodeJS.ProcessEnv = process.env,
72
72
  home = os.homedir(),
73
73
  ): Promise<AcpRuntimePreference> {
74
- if (env.AGY_ACP_BIN?.trim()) return { source: "env" };
74
+ const wrapper = path.join(stateDir, "agy-acp-cli.sh");
75
+ const configured = env.AGY_ACP_BIN?.trim();
76
+ // A wrapper written by this adapter is not a user override. A second
77
+ // extension instance can see the first instance's AGY_ACP_BIN and must
78
+ // recover the CLI profile instead of treating it as an explicit env runtime.
79
+ if (configured && path.resolve(configured) === path.resolve(wrapper)) {
80
+ const cli = await findAgyCli(env);
81
+ if (cli) {
82
+ const preference = { source: "cli", cliPath: cli.path, cliVersion: cli.version, managedVersion: readManagedVersion(home) } as const;
83
+ writeCliWrapper(wrapper, cli.path);
84
+ writeRuntimeSourceRecord(stateDir, preference);
85
+ env.AGY_ACP_BIN = wrapper;
86
+ return preference;
87
+ }
88
+ const recorded = readRuntimeSourceRecord(stateDir);
89
+ if (recorded) return recorded;
90
+ } else if (configured) {
91
+ return { source: "env" };
92
+ }
75
93
  // The generated wrapper is a POSIX shell script that upstream launches
76
94
  // directly; Windows cannot execute it, so it stays managed-only there.
77
95
  if (process.platform === "win32") return { source: "managed" };
78
96
  const cli = await findAgyCli(env);
79
97
  const managedVersion = readManagedVersion(home);
80
98
  if (!cli || (managedVersion && compareVersions(cli.version, managedVersion) <= 0)) {
99
+ if (configured) delete env.AGY_ACP_BIN;
81
100
  return { source: "managed", cliPath: cli?.path, cliVersion: cli?.version, managedVersion };
82
101
  }
83
- const wrapper = path.join(stateDir, "agy-acp-cli.sh");
84
102
  const preference = { source: "cli", cliPath: cli.path, cliVersion: cli.version, managedVersion } as const;
85
103
  writeCliWrapper(wrapper, cli.path);
86
104
  writeRuntimeSourceRecord(stateDir, preference);
@@ -88,6 +106,26 @@ export async function preferNewestAcpRuntime(
88
106
  return preference;
89
107
  }
90
108
 
109
+ function readRuntimeSourceRecord(stateDir: string): AcpRuntimePreference | undefined {
110
+ try {
111
+ const value = JSON.parse(fs.readFileSync(path.join(stateDir, "acp-runtime-source.json"), "utf8")) as {
112
+ source?: unknown;
113
+ cliPath?: unknown;
114
+ cliVersion?: unknown;
115
+ managedVersion?: unknown;
116
+ };
117
+ if (value.source !== "cli" || typeof value.cliPath !== "string" || typeof value.cliVersion !== "string") return undefined;
118
+ return {
119
+ source: "cli",
120
+ cliPath: value.cliPath,
121
+ cliVersion: value.cliVersion,
122
+ ...(typeof value.managedVersion === "string" ? { managedVersion: value.managedVersion } : {}),
123
+ };
124
+ } catch {
125
+ return undefined;
126
+ }
127
+ }
128
+
91
129
  async function findAgyCli(env: NodeJS.ProcessEnv): Promise<{ path: string; version: string } | undefined> {
92
130
  const agy = findExecutableOnPath("agy", env) ?? findExecutableOnPath("agy.exe", env);
93
131
  if (!agy) return undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omp-antigravity-acp-provider",
3
- "version": "0.1.41",
3
+ "version": "0.1.42",
4
4
  "ompAcpBundle": 1,
5
5
  "description": "Google Antigravity ACP provider for Oh My Pi (OMP), with tool bridging and per-model thinking; derived from zacbemis/pi-antigravity-acp-provider",
6
6
  "type": "module",