opencode-ag-auth 1.5.2

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.
Files changed (235) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +749 -0
  3. package/dist/index.d.ts +4 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +3 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/src/antigravity/oauth.d.ts +31 -0
  8. package/dist/src/antigravity/oauth.d.ts.map +1 -0
  9. package/dist/src/antigravity/oauth.js +171 -0
  10. package/dist/src/antigravity/oauth.js.map +1 -0
  11. package/dist/src/constants.d.ts +138 -0
  12. package/dist/src/constants.d.ts.map +1 -0
  13. package/dist/src/constants.js +220 -0
  14. package/dist/src/constants.js.map +1 -0
  15. package/dist/src/hooks/auto-update-checker/cache.d.ts +3 -0
  16. package/dist/src/hooks/auto-update-checker/cache.d.ts.map +1 -0
  17. package/dist/src/hooks/auto-update-checker/cache.js +71 -0
  18. package/dist/src/hooks/auto-update-checker/cache.js.map +1 -0
  19. package/dist/src/hooks/auto-update-checker/checker.d.ts +16 -0
  20. package/dist/src/hooks/auto-update-checker/checker.d.ts.map +1 -0
  21. package/dist/src/hooks/auto-update-checker/checker.js +237 -0
  22. package/dist/src/hooks/auto-update-checker/checker.js.map +1 -0
  23. package/dist/src/hooks/auto-update-checker/constants.d.ts +9 -0
  24. package/dist/src/hooks/auto-update-checker/constants.d.ts.map +1 -0
  25. package/dist/src/hooks/auto-update-checker/constants.js +23 -0
  26. package/dist/src/hooks/auto-update-checker/constants.js.map +1 -0
  27. package/dist/src/hooks/auto-update-checker/index.d.ts +34 -0
  28. package/dist/src/hooks/auto-update-checker/index.d.ts.map +1 -0
  29. package/dist/src/hooks/auto-update-checker/index.js +125 -0
  30. package/dist/src/hooks/auto-update-checker/index.js.map +1 -0
  31. package/dist/src/hooks/auto-update-checker/types.d.ts +25 -0
  32. package/dist/src/hooks/auto-update-checker/types.d.ts.map +1 -0
  33. package/dist/src/hooks/auto-update-checker/types.js +1 -0
  34. package/dist/src/hooks/auto-update-checker/types.js.map +1 -0
  35. package/dist/src/plugin/accounts.d.ts +173 -0
  36. package/dist/src/plugin/accounts.d.ts.map +1 -0
  37. package/dist/src/plugin/accounts.js +1035 -0
  38. package/dist/src/plugin/accounts.js.map +1 -0
  39. package/dist/src/plugin/auth.d.ts +21 -0
  40. package/dist/src/plugin/auth.d.ts.map +1 -0
  41. package/dist/src/plugin/auth.js +46 -0
  42. package/dist/src/plugin/auth.js.map +1 -0
  43. package/dist/src/plugin/cache/index.d.ts +5 -0
  44. package/dist/src/plugin/cache/index.d.ts.map +1 -0
  45. package/dist/src/plugin/cache/index.js +5 -0
  46. package/dist/src/plugin/cache/index.js.map +1 -0
  47. package/dist/src/plugin/cache/signature-cache.d.ts +111 -0
  48. package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -0
  49. package/dist/src/plugin/cache/signature-cache.js +375 -0
  50. package/dist/src/plugin/cache/signature-cache.js.map +1 -0
  51. package/dist/src/plugin/cache.d.ts +44 -0
  52. package/dist/src/plugin/cache.d.ts.map +1 -0
  53. package/dist/src/plugin/cache.js +200 -0
  54. package/dist/src/plugin/cache.js.map +1 -0
  55. package/dist/src/plugin/cli.d.ts +27 -0
  56. package/dist/src/plugin/cli.d.ts.map +1 -0
  57. package/dist/src/plugin/cli.js +130 -0
  58. package/dist/src/plugin/cli.js.map +1 -0
  59. package/dist/src/plugin/config/index.d.ts +16 -0
  60. package/dist/src/plugin/config/index.d.ts.map +1 -0
  61. package/dist/src/plugin/config/index.js +16 -0
  62. package/dist/src/plugin/config/index.js.map +1 -0
  63. package/dist/src/plugin/config/loader.d.ts +37 -0
  64. package/dist/src/plugin/config/loader.d.ts.map +1 -0
  65. package/dist/src/plugin/config/loader.js +196 -0
  66. package/dist/src/plugin/config/loader.js.map +1 -0
  67. package/dist/src/plugin/config/models.d.ts +27 -0
  68. package/dist/src/plugin/config/models.d.ts.map +1 -0
  69. package/dist/src/plugin/config/models.js +70 -0
  70. package/dist/src/plugin/config/models.js.map +1 -0
  71. package/dist/src/plugin/config/schema.d.ts +133 -0
  72. package/dist/src/plugin/config/schema.d.ts.map +1 -0
  73. package/dist/src/plugin/config/schema.js +438 -0
  74. package/dist/src/plugin/config/schema.js.map +1 -0
  75. package/dist/src/plugin/config/updater.d.ts +55 -0
  76. package/dist/src/plugin/config/updater.d.ts.map +1 -0
  77. package/dist/src/plugin/config/updater.js +125 -0
  78. package/dist/src/plugin/config/updater.js.map +1 -0
  79. package/dist/src/plugin/core/streaming/index.d.ts +3 -0
  80. package/dist/src/plugin/core/streaming/index.d.ts.map +1 -0
  81. package/dist/src/plugin/core/streaming/index.js +3 -0
  82. package/dist/src/plugin/core/streaming/index.js.map +1 -0
  83. package/dist/src/plugin/core/streaming/transformer.d.ts +10 -0
  84. package/dist/src/plugin/core/streaming/transformer.d.ts.map +1 -0
  85. package/dist/src/plugin/core/streaming/transformer.js +271 -0
  86. package/dist/src/plugin/core/streaming/transformer.js.map +1 -0
  87. package/dist/src/plugin/core/streaming/types.d.ts +27 -0
  88. package/dist/src/plugin/core/streaming/types.d.ts.map +1 -0
  89. package/dist/src/plugin/core/streaming/types.js +1 -0
  90. package/dist/src/plugin/core/streaming/types.js.map +1 -0
  91. package/dist/src/plugin/debug.d.ts +94 -0
  92. package/dist/src/plugin/debug.d.ts.map +1 -0
  93. package/dist/src/plugin/debug.js +418 -0
  94. package/dist/src/plugin/debug.js.map +1 -0
  95. package/dist/src/plugin/errors.d.ts +28 -0
  96. package/dist/src/plugin/errors.d.ts.map +1 -0
  97. package/dist/src/plugin/errors.js +42 -0
  98. package/dist/src/plugin/errors.js.map +1 -0
  99. package/dist/src/plugin/fingerprint.d.ts +64 -0
  100. package/dist/src/plugin/fingerprint.d.ts.map +1 -0
  101. package/dist/src/plugin/fingerprint.js +125 -0
  102. package/dist/src/plugin/fingerprint.js.map +1 -0
  103. package/dist/src/plugin/image-saver.d.ts +25 -0
  104. package/dist/src/plugin/image-saver.d.ts.map +1 -0
  105. package/dist/src/plugin/image-saver.js +86 -0
  106. package/dist/src/plugin/image-saver.js.map +1 -0
  107. package/dist/src/plugin/logger.d.ts +54 -0
  108. package/dist/src/plugin/logger.d.ts.map +1 -0
  109. package/dist/src/plugin/logger.js +120 -0
  110. package/dist/src/plugin/logger.js.map +1 -0
  111. package/dist/src/plugin/project.d.ts +33 -0
  112. package/dist/src/plugin/project.d.ts.map +1 -0
  113. package/dist/src/plugin/project.js +234 -0
  114. package/dist/src/plugin/project.js.map +1 -0
  115. package/dist/src/plugin/proxy.d.ts +2 -0
  116. package/dist/src/plugin/proxy.d.ts.map +1 -0
  117. package/dist/src/plugin/proxy.js +20 -0
  118. package/dist/src/plugin/proxy.js.map +1 -0
  119. package/dist/src/plugin/quota.d.ts +35 -0
  120. package/dist/src/plugin/quota.d.ts.map +1 -0
  121. package/dist/src/plugin/quota.js +273 -0
  122. package/dist/src/plugin/quota.js.map +1 -0
  123. package/dist/src/plugin/recovery/constants.d.ts +22 -0
  124. package/dist/src/plugin/recovery/constants.d.ts.map +1 -0
  125. package/dist/src/plugin/recovery/constants.js +43 -0
  126. package/dist/src/plugin/recovery/constants.js.map +1 -0
  127. package/dist/src/plugin/recovery/index.d.ts +12 -0
  128. package/dist/src/plugin/recovery/index.d.ts.map +1 -0
  129. package/dist/src/plugin/recovery/index.js +12 -0
  130. package/dist/src/plugin/recovery/index.js.map +1 -0
  131. package/dist/src/plugin/recovery/storage.d.ts +24 -0
  132. package/dist/src/plugin/recovery/storage.d.ts.map +1 -0
  133. package/dist/src/plugin/recovery/storage.js +354 -0
  134. package/dist/src/plugin/recovery/storage.js.map +1 -0
  135. package/dist/src/plugin/recovery/types.d.ts +116 -0
  136. package/dist/src/plugin/recovery/types.d.ts.map +1 -0
  137. package/dist/src/plugin/recovery/types.js +6 -0
  138. package/dist/src/plugin/recovery/types.js.map +1 -0
  139. package/dist/src/plugin/recovery.d.ts +61 -0
  140. package/dist/src/plugin/recovery.d.ts.map +1 -0
  141. package/dist/src/plugin/recovery.js +378 -0
  142. package/dist/src/plugin/recovery.js.map +1 -0
  143. package/dist/src/plugin/refresh-queue.d.ts +101 -0
  144. package/dist/src/plugin/refresh-queue.d.ts.map +1 -0
  145. package/dist/src/plugin/refresh-queue.js +248 -0
  146. package/dist/src/plugin/refresh-queue.js.map +1 -0
  147. package/dist/src/plugin/request-helpers.d.ts +282 -0
  148. package/dist/src/plugin/request-helpers.d.ts.map +1 -0
  149. package/dist/src/plugin/request-helpers.js +2319 -0
  150. package/dist/src/plugin/request-helpers.js.map +1 -0
  151. package/dist/src/plugin/request.d.ts +93 -0
  152. package/dist/src/plugin/request.d.ts.map +1 -0
  153. package/dist/src/plugin/request.js +1352 -0
  154. package/dist/src/plugin/request.js.map +1 -0
  155. package/dist/src/plugin/rotation.d.ts +169 -0
  156. package/dist/src/plugin/rotation.d.ts.map +1 -0
  157. package/dist/src/plugin/rotation.js +328 -0
  158. package/dist/src/plugin/rotation.js.map +1 -0
  159. package/dist/src/plugin/search.d.ts +32 -0
  160. package/dist/src/plugin/search.d.ts.map +1 -0
  161. package/dist/src/plugin/search.js +195 -0
  162. package/dist/src/plugin/search.js.map +1 -0
  163. package/dist/src/plugin/server.d.ts +23 -0
  164. package/dist/src/plugin/server.d.ts.map +1 -0
  165. package/dist/src/plugin/server.js +324 -0
  166. package/dist/src/plugin/server.js.map +1 -0
  167. package/dist/src/plugin/storage.d.ts +136 -0
  168. package/dist/src/plugin/storage.d.ts.map +1 -0
  169. package/dist/src/plugin/storage.js +588 -0
  170. package/dist/src/plugin/storage.js.map +1 -0
  171. package/dist/src/plugin/stores/signature-store.d.ts +5 -0
  172. package/dist/src/plugin/stores/signature-store.d.ts.map +1 -0
  173. package/dist/src/plugin/stores/signature-store.js +25 -0
  174. package/dist/src/plugin/stores/signature-store.js.map +1 -0
  175. package/dist/src/plugin/thinking-recovery.d.ts +90 -0
  176. package/dist/src/plugin/thinking-recovery.d.ts.map +1 -0
  177. package/dist/src/plugin/thinking-recovery.js +316 -0
  178. package/dist/src/plugin/thinking-recovery.js.map +1 -0
  179. package/dist/src/plugin/token.d.ts +19 -0
  180. package/dist/src/plugin/token.d.ts.map +1 -0
  181. package/dist/src/plugin/token.js +128 -0
  182. package/dist/src/plugin/token.js.map +1 -0
  183. package/dist/src/plugin/transform/claude.d.ts +80 -0
  184. package/dist/src/plugin/transform/claude.d.ts.map +1 -0
  185. package/dist/src/plugin/transform/claude.js +265 -0
  186. package/dist/src/plugin/transform/claude.js.map +1 -0
  187. package/dist/src/plugin/transform/cross-model-sanitizer.d.ts +35 -0
  188. package/dist/src/plugin/transform/cross-model-sanitizer.d.ts.map +1 -0
  189. package/dist/src/plugin/transform/cross-model-sanitizer.js +225 -0
  190. package/dist/src/plugin/transform/cross-model-sanitizer.js.map +1 -0
  191. package/dist/src/plugin/transform/gemini.d.ts +100 -0
  192. package/dist/src/plugin/transform/gemini.d.ts.map +1 -0
  193. package/dist/src/plugin/transform/gemini.js +465 -0
  194. package/dist/src/plugin/transform/gemini.js.map +1 -0
  195. package/dist/src/plugin/transform/index.d.ts +15 -0
  196. package/dist/src/plugin/transform/index.d.ts.map +1 -0
  197. package/dist/src/plugin/transform/index.js +14 -0
  198. package/dist/src/plugin/transform/index.js.map +1 -0
  199. package/dist/src/plugin/transform/model-resolver.d.ts +104 -0
  200. package/dist/src/plugin/transform/model-resolver.d.ts.map +1 -0
  201. package/dist/src/plugin/transform/model-resolver.js +361 -0
  202. package/dist/src/plugin/transform/model-resolver.js.map +1 -0
  203. package/dist/src/plugin/transform/types.d.ts +111 -0
  204. package/dist/src/plugin/transform/types.d.ts.map +1 -0
  205. package/dist/src/plugin/transform/types.js +1 -0
  206. package/dist/src/plugin/transform/types.js.map +1 -0
  207. package/dist/src/plugin/types.d.ts +97 -0
  208. package/dist/src/plugin/types.d.ts.map +1 -0
  209. package/dist/src/plugin/types.js +1 -0
  210. package/dist/src/plugin/types.js.map +1 -0
  211. package/dist/src/plugin/ui/ansi.d.ts +32 -0
  212. package/dist/src/plugin/ui/ansi.d.ts.map +1 -0
  213. package/dist/src/plugin/ui/ansi.js +52 -0
  214. package/dist/src/plugin/ui/ansi.js.map +1 -0
  215. package/dist/src/plugin/ui/auth-menu.d.ts +33 -0
  216. package/dist/src/plugin/ui/auth-menu.d.ts.map +1 -0
  217. package/dist/src/plugin/ui/auth-menu.js +110 -0
  218. package/dist/src/plugin/ui/auth-menu.js.map +1 -0
  219. package/dist/src/plugin/ui/confirm.d.ts +2 -0
  220. package/dist/src/plugin/ui/confirm.d.ts.map +1 -0
  221. package/dist/src/plugin/ui/confirm.js +15 -0
  222. package/dist/src/plugin/ui/confirm.js.map +1 -0
  223. package/dist/src/plugin/ui/select.d.ts +23 -0
  224. package/dist/src/plugin/ui/select.d.ts.map +1 -0
  225. package/dist/src/plugin/ui/select.js +254 -0
  226. package/dist/src/plugin/ui/select.js.map +1 -0
  227. package/dist/src/plugin/version.d.ts +19 -0
  228. package/dist/src/plugin/version.d.ts.map +1 -0
  229. package/dist/src/plugin/version.js +80 -0
  230. package/dist/src/plugin/version.js.map +1 -0
  231. package/dist/src/plugin.d.ts +30 -0
  232. package/dist/src/plugin.d.ts.map +1 -0
  233. package/dist/src/plugin.js +3050 -0
  234. package/dist/src/plugin.js.map +1 -0
  235. package/package.json +68 -0
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Device Fingerprint Generator for Rate Limit Mitigation
3
+ *
4
+ * Ported from antigravity-claude-proxy PR #170
5
+ * https://github.com/badrisnarayanan/antigravity-claude-proxy/pull/170
6
+ *
7
+ * Generates randomized device fingerprints to help distribute API usage
8
+ * across different apparent device identities.
9
+ */
10
+ import * as crypto from "node:crypto";
11
+ import * as os from "node:os";
12
+ import { getAntigravityVersion } from "../constants";
13
+ const OS_VERSIONS = {
14
+ darwin: ["10.15.7", "11.6.8", "12.6.3", "13.5.2", "14.2.1", "14.5"],
15
+ win32: ["10.0.19041", "10.0.19042", "10.0.19043", "10.0.22000", "10.0.22621", "10.0.22631"],
16
+ linux: ["5.15.0", "5.19.0", "6.1.0", "6.2.0", "6.5.0", "6.6.0"],
17
+ };
18
+ const ARCHITECTURES = ["x64", "arm64"];
19
+ const IDE_TYPES = [
20
+ "ANTIGRAVITY",
21
+ ];
22
+ const PLATFORMS = [
23
+ "WINDOWS",
24
+ "MACOS",
25
+ ];
26
+ const SDK_CLIENTS = [
27
+ "google-cloud-sdk vscode_cloudshelleditor/0.1",
28
+ "google-cloud-sdk vscode/1.86.0",
29
+ "google-cloud-sdk vscode/1.87.0",
30
+ "google-cloud-sdk vscode/1.96.0",
31
+ ];
32
+ /** Maximum number of fingerprint versions to keep per account */
33
+ export const MAX_FINGERPRINT_HISTORY = 5;
34
+ function randomFrom(arr) {
35
+ return arr[Math.floor(Math.random() * arr.length)];
36
+ }
37
+ function generateDeviceId() {
38
+ return crypto.randomUUID();
39
+ }
40
+ function generateSessionToken() {
41
+ return crypto.randomBytes(16).toString("hex");
42
+ }
43
+ /**
44
+ * Generate a randomized device fingerprint.
45
+ * Each fingerprint represents a unique "device" identity.
46
+ */
47
+ export function generateFingerprint() {
48
+ const platform = randomFrom(["darwin", "win32"]);
49
+ const arch = randomFrom(ARCHITECTURES);
50
+ const osVersion = randomFrom(OS_VERSIONS[platform] ?? OS_VERSIONS.darwin);
51
+ const matchingPlatform = platform === "win32"
52
+ ? "WINDOWS"
53
+ : "MACOS";
54
+ return {
55
+ deviceId: generateDeviceId(),
56
+ sessionToken: generateSessionToken(),
57
+ userAgent: `antigravity/${getAntigravityVersion()} ${platform}/${arch}`,
58
+ apiClient: randomFrom(SDK_CLIENTS),
59
+ clientMetadata: {
60
+ ideType: randomFrom(IDE_TYPES),
61
+ platform: matchingPlatform,
62
+ pluginType: "GEMINI",
63
+ },
64
+ createdAt: Date.now(),
65
+ };
66
+ }
67
+ /**
68
+ * Collect fingerprint based on actual current system.
69
+ * Uses real OS info instead of randomized values.
70
+ */
71
+ export function collectCurrentFingerprint() {
72
+ const platform = os.platform();
73
+ const arch = os.arch();
74
+ const matchingPlatform = platform === "win32"
75
+ ? "WINDOWS"
76
+ : "MACOS";
77
+ return {
78
+ deviceId: generateDeviceId(),
79
+ sessionToken: generateSessionToken(),
80
+ userAgent: `antigravity/${getAntigravityVersion()} ${platform}/${arch}`,
81
+ apiClient: "google-cloud-sdk vscode_cloudshelleditor/0.1",
82
+ clientMetadata: {
83
+ ideType: "ANTIGRAVITY",
84
+ platform: matchingPlatform,
85
+ pluginType: "GEMINI",
86
+ },
87
+ createdAt: Date.now(),
88
+ };
89
+ }
90
+ /**
91
+ * Build HTTP headers from a fingerprint object.
92
+ * These headers are used to identify the "device" making API requests.
93
+ */
94
+ export function buildFingerprintHeaders(fingerprint) {
95
+ if (!fingerprint) {
96
+ return {};
97
+ }
98
+ return {
99
+ "User-Agent": fingerprint.userAgent,
100
+ };
101
+ }
102
+ /**
103
+ * Session-level fingerprint instance.
104
+ * Generated once at module load, persists for the lifetime of the process.
105
+ */
106
+ let sessionFingerprint = null;
107
+ /**
108
+ * Get or create the session fingerprint.
109
+ * Returns the same fingerprint for all calls within a session.
110
+ */
111
+ export function getSessionFingerprint() {
112
+ if (!sessionFingerprint) {
113
+ sessionFingerprint = generateFingerprint();
114
+ }
115
+ return sessionFingerprint;
116
+ }
117
+ /**
118
+ * Regenerate the session fingerprint.
119
+ * Call this to get a fresh identity (e.g., after rate limiting).
120
+ */
121
+ export function regenerateSessionFingerprint() {
122
+ sessionFingerprint = generateFingerprint();
123
+ return sessionFingerprint;
124
+ }
125
+ //# sourceMappingURL=fingerprint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fingerprint.js","sourceRoot":"","sources":["../../../src/plugin/fingerprint.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,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CAAC;IACZ,CAAC;IAED,OAAO;QACL,YAAY,EAAE,WAAW,CAAC,SAAS;KACpC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,IAAI,kBAAkB,GAAuB,IAAI,CAAC;AAElD;;;GAGG;AACH,MAAM,UAAU,qBAAqB;IACnC,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,kBAAkB,GAAG,mBAAmB,EAAE,CAAC;IAC7C,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,4BAA4B;IAC1C,kBAAkB,GAAG,mBAAmB,EAAE,CAAC;IAC3C,OAAO,kBAAkB,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Image Saving Utility
3
+ *
4
+ * Handles saving generated images to disk and returning file paths.
5
+ */
6
+ /**
7
+ * Save base64 image data to disk and return the file path.
8
+ *
9
+ * @param base64Data - The base64-encoded image data
10
+ * @param mimeType - The MIME type of the image (e.g., "image/jpeg")
11
+ * @returns The absolute path to the saved image file
12
+ */
13
+ export declare function saveImageToDisk(base64Data: string, mimeType: string): string;
14
+ /**
15
+ * Process inlineData and return either a file path or base64 data URL.
16
+ * Attempts to save to disk first, falls back to base64 if saving fails.
17
+ *
18
+ * @param inlineData - Object containing mimeType and base64 data
19
+ * @returns Markdown image string with either file path or data URL
20
+ */
21
+ export declare function processImageData(inlineData: {
22
+ mimeType?: string;
23
+ data?: string;
24
+ }): string | null;
25
+ //# sourceMappingURL=image-saver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-saver.d.ts","sourceRoot":"","sources":["../../../src/plugin/image-saver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA0CH;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAgB5E;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,GAAG,IAAI,CAkBhG"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Image Saving Utility
3
+ *
4
+ * Handles saving generated images to disk and returning file paths.
5
+ */
6
+ import * as fs from 'fs';
7
+ import * as path from 'path';
8
+ import * as os from 'os';
9
+ /**
10
+ * Default directory for saving generated images.
11
+ * Uses ~/.opencode/generated-images/
12
+ */
13
+ function getImageOutputDir() {
14
+ const homeDir = os.homedir();
15
+ const outputDir = path.join(homeDir, '.opencode', 'generated-images');
16
+ // Create directory if it doesn't exist
17
+ if (!fs.existsSync(outputDir)) {
18
+ fs.mkdirSync(outputDir, { recursive: true });
19
+ }
20
+ return outputDir;
21
+ }
22
+ /**
23
+ * Generate a unique filename for the image.
24
+ */
25
+ function generateImageFilename(mimeType) {
26
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
27
+ const random = Math.random().toString(36).substring(2, 8);
28
+ // Determine extension from mime type
29
+ let ext = 'png';
30
+ if (mimeType.includes('jpeg') || mimeType.includes('jpg')) {
31
+ ext = 'jpg';
32
+ }
33
+ else if (mimeType.includes('gif')) {
34
+ ext = 'gif';
35
+ }
36
+ else if (mimeType.includes('webp')) {
37
+ ext = 'webp';
38
+ }
39
+ return `image-${timestamp}-${random}.${ext}`;
40
+ }
41
+ /**
42
+ * Save base64 image data to disk and return the file path.
43
+ *
44
+ * @param base64Data - The base64-encoded image data
45
+ * @param mimeType - The MIME type of the image (e.g., "image/jpeg")
46
+ * @returns The absolute path to the saved image file
47
+ */
48
+ export function saveImageToDisk(base64Data, mimeType) {
49
+ try {
50
+ const outputDir = getImageOutputDir();
51
+ const filename = generateImageFilename(mimeType);
52
+ const filePath = path.join(outputDir, filename);
53
+ // Decode base64 and write to file
54
+ const buffer = Buffer.from(base64Data, 'base64');
55
+ fs.writeFileSync(filePath, buffer);
56
+ return filePath;
57
+ }
58
+ catch (error) {
59
+ // If saving fails, return empty string (caller will fall back to base64)
60
+ console.error('[image-saver] Failed to save image:', error);
61
+ return '';
62
+ }
63
+ }
64
+ /**
65
+ * Process inlineData and return either a file path or base64 data URL.
66
+ * Attempts to save to disk first, falls back to base64 if saving fails.
67
+ *
68
+ * @param inlineData - Object containing mimeType and base64 data
69
+ * @returns Markdown image string with either file path or data URL
70
+ */
71
+ export function processImageData(inlineData) {
72
+ const mimeType = inlineData.mimeType || 'image/png';
73
+ const data = inlineData.data;
74
+ if (!data) {
75
+ return null;
76
+ }
77
+ // Try to save to disk first
78
+ const filePath = saveImageToDisk(data, mimeType);
79
+ if (filePath) {
80
+ // Successfully saved - return file path with open command hint
81
+ return `![Generated Image](${filePath})\n\nImage saved to: \`${filePath}\`\n\nTo view: \`open "${filePath}"\``;
82
+ }
83
+ // Fall back to base64 data URL
84
+ return `![Generated Image](data:${mimeType};base64,${data})`;
85
+ }
86
+ //# sourceMappingURL=image-saver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-saver.js","sourceRoot":"","sources":["../../../src/plugin/image-saver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB;;;GAGG;AACH,SAAS,iBAAiB;IACxB,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;IAC7B,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,kBAAkB,CAAC,CAAC;IAEtE,uCAAuC;IACvC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC9B,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,SAAS,CAAC;AACnB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AAC,OAAO,KAAK,EAAE,CAAC;QACf,yEAAyE;QACzE,OAAO,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAC;QAC5D,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAgD;IAC/E,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,IAAI,WAAW,CAAC;IACpD,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;IAE7B,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,IAAI,CAAC;IACd,CAAC;IAED,4BAA4B;IAC5B,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAEjD,IAAI,QAAQ,EAAE,CAAC;QACb,+DAA+D;QAC/D,OAAO,sBAAsB,QAAQ,0BAA0B,QAAQ,0BAA0B,QAAQ,KAAK,CAAC;IACjH,CAAC;IAED,+BAA+B;IAC/B,OAAO,2BAA2B,QAAQ,WAAW,IAAI,GAAG,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Structured Logger for Antigravity Plugin
3
+ *
4
+ * Provides TUI-integrated logging that is silent by default.
5
+ * Logs are only visible when:
6
+ * 1. TUI client is available (logs to app log panel)
7
+ * 2. OPENCODE_ANTIGRAVITY_CONSOLE_LOG=1 is set (logs to console)
8
+ *
9
+ * Ported from opencode-google-antigravity-auth/src/plugin/logger.ts
10
+ */
11
+ import type { PluginClient } from "./types";
12
+ type LogLevel = "debug" | "info" | "warn" | "error";
13
+ export interface Logger {
14
+ debug(message: string, extra?: Record<string, unknown>): void;
15
+ info(message: string, extra?: Record<string, unknown>): void;
16
+ warn(message: string, extra?: Record<string, unknown>): void;
17
+ error(message: string, extra?: Record<string, unknown>): void;
18
+ }
19
+ /**
20
+ * Initialize the logger with the plugin client.
21
+ * Must be called during plugin initialization to enable TUI logging.
22
+ */
23
+ export declare function initLogger(client: PluginClient): void;
24
+ /**
25
+ * Get the current client (for testing or advanced usage).
26
+ */
27
+ export declare function getLoggerClient(): PluginClient | null;
28
+ /**
29
+ * Create a logger instance for a specific module.
30
+ *
31
+ * @param module - The module name (e.g., "refresh-queue", "transform.claude")
32
+ * @returns Logger instance with debug, info, warn, error methods
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * const log = createLogger("refresh-queue");
37
+ * log.debug("Checking tokens", { count: 5 });
38
+ * log.warn("Token expired", { accountIndex: 0 });
39
+ * ```
40
+ */
41
+ export declare function createLogger(module: string): Logger;
42
+ /**
43
+ * Print a message to the console with Antigravity prefix.
44
+ * Only outputs when OPENCODE_ANTIGRAVITY_CONSOLE_LOG=1 is set.
45
+ *
46
+ * Use this for standalone messages that don't belong to a specific module.
47
+ *
48
+ * @param level - Log level
49
+ * @param message - Message to print
50
+ * @param extra - Optional extra data
51
+ */
52
+ export declare function printAntigravityConsole(level: LogLevel, message: string, extra?: unknown): void;
53
+ export {};
54
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/plugin/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,KAAK,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAKpD,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC9D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC7D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC7D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC/D;AAYD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAErD;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,YAAY,GAAG,IAAI,CAErD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CA0CnD;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,OAAO,GACd,IAAI,CAsBN"}
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Structured Logger for Antigravity Plugin
3
+ *
4
+ * Provides TUI-integrated logging that is silent by default.
5
+ * Logs are only visible when:
6
+ * 1. TUI client is available (logs to app log panel)
7
+ * 2. OPENCODE_ANTIGRAVITY_CONSOLE_LOG=1 is set (logs to console)
8
+ *
9
+ * Ported from opencode-google-antigravity-auth/src/plugin/logger.ts
10
+ */
11
+ const ENV_CONSOLE_LOG = "OPENCODE_ANTIGRAVITY_CONSOLE_LOG";
12
+ const ANTIGRAVITY_CONSOLE_PREFIX = "[Antigravity]";
13
+ let _client = null;
14
+ /**
15
+ * Check if console logging is enabled via environment variable.
16
+ */
17
+ function isConsoleLogEnabled() {
18
+ const val = process.env[ENV_CONSOLE_LOG];
19
+ return val === "1" || val?.toLowerCase() === "true";
20
+ }
21
+ /**
22
+ * Initialize the logger with the plugin client.
23
+ * Must be called during plugin initialization to enable TUI logging.
24
+ */
25
+ export function initLogger(client) {
26
+ _client = client;
27
+ }
28
+ /**
29
+ * Get the current client (for testing or advanced usage).
30
+ */
31
+ export function getLoggerClient() {
32
+ return _client;
33
+ }
34
+ /**
35
+ * Create a logger instance for a specific module.
36
+ *
37
+ * @param module - The module name (e.g., "refresh-queue", "transform.claude")
38
+ * @returns Logger instance with debug, info, warn, error methods
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const log = createLogger("refresh-queue");
43
+ * log.debug("Checking tokens", { count: 5 });
44
+ * log.warn("Token expired", { accountIndex: 0 });
45
+ * ```
46
+ */
47
+ export function createLogger(module) {
48
+ const service = `antigravity.${module}`;
49
+ const log = (level, message, extra) => {
50
+ // Try TUI logging first
51
+ const app = _client?.app;
52
+ if (app && typeof app.log === "function") {
53
+ app
54
+ .log({
55
+ body: { service, level, message, extra },
56
+ })
57
+ .catch(() => {
58
+ // Silently ignore logging errors
59
+ });
60
+ }
61
+ else if (isConsoleLogEnabled()) {
62
+ // Fallback to console if env var is set
63
+ const prefix = `[${service}]`;
64
+ const args = extra ? [prefix, message, extra] : [prefix, message];
65
+ switch (level) {
66
+ case "debug":
67
+ console.debug(...args);
68
+ break;
69
+ case "info":
70
+ console.info(...args);
71
+ break;
72
+ case "warn":
73
+ console.warn(...args);
74
+ break;
75
+ case "error":
76
+ console.error(...args);
77
+ break;
78
+ }
79
+ }
80
+ // If neither TUI nor console logging is enabled, log is silently discarded
81
+ };
82
+ return {
83
+ debug: (message, extra) => log("debug", message, extra),
84
+ info: (message, extra) => log("info", message, extra),
85
+ warn: (message, extra) => log("warn", message, extra),
86
+ error: (message, extra) => log("error", message, extra),
87
+ };
88
+ }
89
+ /**
90
+ * Print a message to the console with Antigravity prefix.
91
+ * Only outputs when OPENCODE_ANTIGRAVITY_CONSOLE_LOG=1 is set.
92
+ *
93
+ * Use this for standalone messages that don't belong to a specific module.
94
+ *
95
+ * @param level - Log level
96
+ * @param message - Message to print
97
+ * @param extra - Optional extra data
98
+ */
99
+ export function printAntigravityConsole(level, message, extra) {
100
+ if (!isConsoleLogEnabled()) {
101
+ return;
102
+ }
103
+ const prefixedMessage = `${ANTIGRAVITY_CONSOLE_PREFIX} ${message}`;
104
+ const args = extra === undefined ? [prefixedMessage] : [prefixedMessage, extra];
105
+ switch (level) {
106
+ case "debug":
107
+ console.debug(...args);
108
+ break;
109
+ case "info":
110
+ console.info(...args);
111
+ break;
112
+ case "warn":
113
+ console.warn(...args);
114
+ break;
115
+ case "error":
116
+ console.error(...args);
117
+ break;
118
+ }
119
+ }
120
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/plugin/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,MAAM,eAAe,GAAG,kCAAkC,CAAC;AAC3D,MAAM,0BAA0B,GAAG,eAAe,CAAC;AASnD,IAAI,OAAO,GAAwB,IAAI,CAAC;AAExC;;GAEG;AACH,SAAS,mBAAmB;IAC1B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IACzC,OAAO,GAAG,KAAK,GAAG,IAAI,GAAG,EAAE,WAAW,EAAE,KAAK,MAAM,CAAC;AACtD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,MAAoB;IAC7C,OAAO,GAAG,MAAM,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,MAAM,OAAO,GAAG,eAAe,MAAM,EAAE,CAAC;IAExC,MAAM,GAAG,GAAG,CAAC,KAAe,EAAE,OAAe,EAAE,KAA+B,EAAQ,EAAE;QACtF,wBAAwB;QACxB,MAAM,GAAG,GAAG,OAAO,EAAE,GAAG,CAAC;QACzB,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,GAAG,KAAK,UAAU,EAAE,CAAC;YACzC,GAAG;iBACA,GAAG,CAAC;gBACH,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE;aACzC,CAAC;i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;;GASG;AACH,MAAM,UAAU,uBAAuB,CACrC,KAAe,EACf,OAAe,EACf,KAAe;IAEf,IAAI,CAAC,mBAAmB,EAAE,EAAE,CAAC;QAC3B,OAAO;IACT,CAAC;IAED,MAAM,eAAe,GAAG,GAAG,0BAA0B,IAAI,OAAO,EAAE,CAAC;IACnE,MAAM,IAAI,GAAG,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;IAEhF,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,OAAO;YACV,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;YACvB,MAAM;QACR,KAAK,MAAM;YACT,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;YACtB,MAAM;QACR,KAAK,MAAM;YACT,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;YACtB,MAAM;QACR,KAAK,OAAO;YACV,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;YACvB,MAAM;IACV,CAAC;AACH,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { OAuthAuthDetails, ProjectContextResult } from "./types";
2
+ interface AntigravityUserTier {
3
+ id?: string;
4
+ isDefault?: boolean;
5
+ userDefinedCloudaicompanionProject?: boolean;
6
+ }
7
+ interface LoadCodeAssistPayload {
8
+ cloudaicompanionProject?: string | {
9
+ id?: string;
10
+ };
11
+ currentTier?: {
12
+ id?: string;
13
+ };
14
+ allowedTiers?: AntigravityUserTier[];
15
+ }
16
+ /**
17
+ * Clears cached project context results and pending promises, globally or for a refresh key.
18
+ */
19
+ export declare function invalidateProjectContextCache(refresh?: string): void;
20
+ /**
21
+ * Loads managed project information for the given access token and optional project.
22
+ */
23
+ export declare function loadManagedProject(accessToken: string, projectId?: string): Promise<LoadCodeAssistPayload | null>;
24
+ /**
25
+ * Onboards a managed project for the user, optionally retrying until completion.
26
+ */
27
+ export declare function onboardManagedProject(accessToken: string, tierId: string, projectId?: string, attempts?: number, delayMs?: number): Promise<string | undefined>;
28
+ /**
29
+ * Resolves an effective project ID for the current auth state, caching results per refresh token.
30
+ */
31
+ export declare function ensureProjectContext(auth: OAuthAuthDetails): Promise<ProjectContextResult>;
32
+ export {};
33
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../src/plugin/project.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAatE,UAAU,mBAAmB;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kCAAkC,CAAC,EAAE,OAAO,CAAC;CAC9C;AAED,UAAU,qBAAqB;IAC7B,uBAAuB,CAAC,EAAE,MAAM,GAAG;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnD,WAAW,CAAC,EAAE;QACZ,EAAE,CAAC,EAAE,MAAM,CAAC;KACb,CAAC;IACF,YAAY,CAAC,EAAE,mBAAmB,EAAE,CAAC;CACtC;AAuED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAQpE;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAuCvC;AAGD;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,MAAM,EAClB,QAAQ,SAAK,EACb,OAAO,SAAO,GACb,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CA6C7B;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA+FhG"}