@fxz26284407/yuanma-gateway 0.1.13 → 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.
@@ -62,10 +62,22 @@ export class AntigravityNative {
62
62
  await this.connect();
63
63
  const authority = this.#authority;
64
64
  try {
65
- if (method === 'GetAllCascadeTrajectories' && authority.version === '2.31.0') {
66
- const snapshot = await this.readState('JetboxSubscribeToSummaries', {});
67
- requireValue(snapshot.updates && typeof snapshot.updates === 'object' && !Array.isArray(snapshot.updates), 'PROTOCOL_INCOMPATIBLE', '桌面会话订阅格式已变化', 503);
68
- return { trajectorySummaries: snapshot.updates };
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
+ }
69
81
  }
70
82
  const result = await this.rpc(authority, method, params, timeout, signal);
71
83
  if (method === 'GetCascadeTrajectorySteps') {
@@ -114,7 +126,7 @@ export class AntigravityNative {
114
126
  } onEnd(error); };
115
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 => {
116
128
  if (res.statusCode !== 200) {
117
- 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' }));
118
130
  return;
119
131
  }
120
132
  if (!res.headers['content-type']?.startsWith('application/connect+json')) {
@@ -136,7 +148,7 @@ export class AntigravityNative {
136
148
  const value = JSON.parse(buffer.subarray(5, 5 + length).toString('utf8'));
137
149
  buffer = buffer.subarray(5 + length);
138
150
  if (flags === 2) {
139
- 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);
140
152
  return;
141
153
  }
142
154
  if (flags !== 0)
@@ -153,7 +153,6 @@ export class MacOsAdapter extends HostAdapter {
153
153
  discover: async () => {
154
154
  const binary = '/Applications/Antigravity.app/Contents/Resources/bin/language_server';
155
155
  const { stdout: version } = await exec('/usr/libexec/PlistBuddy', ['-c', 'Print :CFBundleShortVersionString', '/Applications/Antigravity.app/Contents/Info.plist']);
156
- requireValue(['2.29.0', '2.31.0'].includes(version.trim()), 'PROTOCOL_INCOMPATIBLE', '当前适配 Antigravity App 2.29.0、2.31.0,请核对桌面版本', 503);
157
156
  const { stdout } = await exec('/bin/ps', ['-axo', 'uid,pid,ppid,command'], { maxBuffer: 4 * 1024 * 1024 });
158
157
  const rows = stdout.split('\n').flatMap(line => {
159
158
  const match = /^\s*(\d+)\s+(\d+)\s+(\d+)\s+(.*)$/.exec(line);
@@ -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.13",
3
+ "version": "0.1.14",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": "22.x || 26.x"