@fxz26284407/yuanma-gateway 0.1.12 → 0.1.14

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.
@@ -44,7 +44,7 @@ export class AntigravityNative {
44
44
  const desktop = await platform.antigravity.discover();
45
45
  let found;
46
46
  for (const port of desktop.ports) {
47
- const authority = { pid: desktop.pid, port, token: desktop.token };
47
+ const authority = { pid: desktop.pid, port, token: desktop.token, version: desktop.version };
48
48
  try {
49
49
  cascadeSummaries(await this.rpc(authority, 'GetAllCascadeTrajectories', { excludeSubtrajectories: true }, 5000));
50
50
  found = authority;
@@ -62,6 +62,23 @@ export class AntigravityNative {
62
62
  await this.connect();
63
63
  const authority = this.#authority;
64
64
  try {
65
+ if (method === 'GetAllCascadeTrajectories') {
66
+ try {
67
+ const snapshot = await this.readState('JetboxSubscribeToSummaries', {});
68
+ requireValue(snapshot && typeof snapshot === 'object' && !Array.isArray(snapshot) && (snapshot.updates !== undefined || Object.keys(snapshot).length === 0), 'PROTOCOL_INCOMPATIBLE', '桌面会话订阅格式已变化', 503);
69
+ return { trajectorySummaries: cascadeSummaries(snapshot.updates === undefined ? {} : { trajectorySummaries: snapshot.updates }) };
70
+ }
71
+ catch (error) {
72
+ if (error.code !== 'UNSUPPORTED_METHOD')
73
+ throw error;
74
+ // Older servers may expose only the unary catalog.
75
+ const result = await this.rpc(authority, method, params, timeout, signal);
76
+ cascadeSummaries(result);
77
+ this.ready = true;
78
+ this.#checked = Date.now();
79
+ return result;
80
+ }
81
+ }
65
82
  const result = await this.rpc(authority, method, params, timeout, signal);
66
83
  if (method === 'GetCascadeTrajectorySteps') {
67
84
  requireValue(result && typeof result === 'object' && !Array.isArray(result) && (result.steps === undefined || Array.isArray(result.steps)), 'PROTOCOL_INCOMPATIBLE', '原生步骤列表格式已变化', 503);
@@ -109,7 +126,7 @@ export class AntigravityNative {
109
126
  } onEnd(error); };
110
127
  const req = request({ hostname: '127.0.0.1', port: authority.port, path: '/exa.language_server_pb.LanguageServerService/' + method, method: 'POST', rejectUnauthorized: false, headers: { 'content-type': 'application/connect+json', 'connect-protocol-version': '1', 'x-codeium-csrf-token': authority.token } }, res => {
111
128
  if (res.statusCode !== 200) {
112
- finish(new Error('Antigravity 状态订阅不可用(HTTP ' + res.statusCode + ')'));
129
+ finish(Object.assign(new Error('Antigravity 状态订阅不可用(HTTP ' + res.statusCode + ')'), { code: res.statusCode === 404 || res.statusCode === 501 ? 'UNSUPPORTED_METHOD' : 'STREAM_UNAVAILABLE' }));
113
130
  return;
114
131
  }
115
132
  if (!res.headers['content-type']?.startsWith('application/connect+json')) {
@@ -131,7 +148,7 @@ export class AntigravityNative {
131
148
  const value = JSON.parse(buffer.subarray(5, 5 + length).toString('utf8'));
132
149
  buffer = buffer.subarray(5 + length);
133
150
  if (flags === 2) {
134
- finish(value.error ? new Error('Antigravity 状态订阅中断') : undefined);
151
+ finish(value.error ? Object.assign(new Error('Antigravity 状态订阅中断'), { code: value.error.code === 'unimplemented' ? 'UNSUPPORTED_METHOD' : 'STREAM_UNAVAILABLE' }) : undefined);
135
152
  return;
136
153
  }
137
154
  if (flags !== 0)
@@ -151,8 +151,8 @@ export class MacOsAdapter extends HostAdapter {
151
151
  antigravity = {
152
152
  unavailableMessage: 'Antigravity 桌面会话接口未就绪', diffAvailable: true,
153
153
  discover: async () => {
154
- const app = '/Applications/Antigravity.app/Contents/Resources/app', binary = '/Applications/Antigravity.app/Contents/Resources/bin/language_server';
155
- requireValue(JSON.parse(await readFile(join(app, 'package.json'), 'utf8')).version === '2.29.0', 'PROTOCOL_INCOMPATIBLE', '当前仅适配 Antigravity App 2.29.0,请核对桌面版本', 503);
154
+ const binary = '/Applications/Antigravity.app/Contents/Resources/bin/language_server';
155
+ const { stdout: version } = await exec('/usr/libexec/PlistBuddy', ['-c', 'Print :CFBundleShortVersionString', '/Applications/Antigravity.app/Contents/Info.plist']);
156
156
  const { stdout } = await exec('/bin/ps', ['-axo', 'uid,pid,ppid,command'], { maxBuffer: 4 * 1024 * 1024 });
157
157
  const rows = stdout.split('\n').flatMap(line => {
158
158
  const match = /^\s*(\d+)\s+(\d+)\s+(\d+)\s+(.*)$/.exec(line);
@@ -171,7 +171,7 @@ export class MacOsAdapter extends HostAdapter {
171
171
  requireValue(ports.length > 0, 'BACKEND_UNAVAILABLE', '无法核实 Antigravity 桌面监听地址', 503);
172
172
  const file = await stat(binary);
173
173
  requireValue(file.isFile() && !(file.mode & 0o002), 'UNSAFE_STORAGE', 'Antigravity 可执行文件权限异常', 403);
174
- return { ...row, ports };
174
+ return { ...row, ports, version: version.trim() };
175
175
  },
176
176
  diff: async (path, original, modified) => new Promise((ok, no) => {
177
177
  const child = this.spawn('/usr/bin/diff', ['-u', '-L', path, '-L', path, original.length ? '/dev/fd/3' : '/dev/null', modified.length ? '/dev/fd/4' : '/dev/null'], { stdio: ['ignore', 'pipe', 'ignore', 'pipe', 'pipe'] });
@@ -259,8 +259,7 @@ export class WindowsAdapter extends HostAdapter {
259
259
  requireValue(resolve(parent.path).toLowerCase() === resolve(application).toLowerCase(), 'BACKEND_UNAVAILABLE', '无法核实 Antigravity LS 的桌面父进程', 503);
260
260
  await trustedWindowsExecutable(parent.path);
261
261
  const version = await windowsCommand(`(Get-Item -LiteralPath $d.path).VersionInfo.FileVersion|ConvertTo-Json -Compress`, { path: parent.path });
262
- requireValue(version === '2.29.0', 'PROTOCOL_INCOMPATIBLE', '当前仅适配 Antigravity App 2.29.0,请核对 Windows 桌面版本', 503);
263
- return { pid: desktop.pid, ports: desktop.ports, token: desktop.token };
262
+ return { pid: desktop.pid, ports: desktop.ports, token: desktop.token, version: typeof version === 'string' ? version : undefined };
264
263
  },
265
264
  diff: async (path, original, modified) => {
266
265
  const root = join(this.gatewayHome, 'diff');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fxz26284407/yuanma-gateway",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": "22.x || 26.x"