@herbertgao/pi-extensions 2026.11.18 → 2026.11.19

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 (151) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +3 -3
  3. package/THIRD_PARTY_NOTICES.md +2 -23
  4. package/node_modules/@estebanforge/pi-antigravity-bridge/CHANGELOG.md +956 -0
  5. package/node_modules/{pi-antigravity → @estebanforge/pi-antigravity-bridge}/LICENSE +1 -1
  6. package/node_modules/@estebanforge/pi-antigravity-bridge/README.md +240 -0
  7. package/node_modules/@estebanforge/pi-antigravity-bridge/extensions/index.ts +2117 -0
  8. package/node_modules/@estebanforge/pi-antigravity-bridge/package.json +61 -0
  9. package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/connection.ts +644 -0
  10. package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/driver.ts +1043 -0
  11. package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/events.ts +323 -0
  12. package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/home.ts +145 -0
  13. package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/jsonrpc.ts +243 -0
  14. package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/setup.ts +107 -0
  15. package/node_modules/@estebanforge/pi-antigravity-bridge/src/acp/usage-estimate.ts +61 -0
  16. package/node_modules/@estebanforge/pi-antigravity-bridge/src/agents.ts +64 -0
  17. package/node_modules/@estebanforge/pi-antigravity-bridge/src/agy-install.ts +93 -0
  18. package/node_modules/@estebanforge/pi-antigravity-bridge/src/agy-paths.ts +30 -0
  19. package/node_modules/@estebanforge/pi-antigravity-bridge/src/agy-setup.ts +81 -0
  20. package/node_modules/@estebanforge/pi-antigravity-bridge/src/agy-version.ts +289 -0
  21. package/node_modules/@estebanforge/pi-antigravity-bridge/src/approval-detect.ts +161 -0
  22. package/node_modules/@estebanforge/pi-antigravity-bridge/src/approval-gate.ts +233 -0
  23. package/node_modules/@estebanforge/pi-antigravity-bridge/src/approval-hook.ts +325 -0
  24. package/node_modules/@estebanforge/pi-antigravity-bridge/src/artifacts-ui.ts +88 -0
  25. package/node_modules/@estebanforge/pi-antigravity-bridge/src/artifacts.ts +144 -0
  26. package/node_modules/@estebanforge/pi-antigravity-bridge/src/ask-tool.ts +1221 -0
  27. package/node_modules/@estebanforge/pi-antigravity-bridge/src/background-watch.ts +225 -0
  28. package/node_modules/@estebanforge/pi-antigravity-bridge/src/bridge-catalog.ts +197 -0
  29. package/node_modules/@estebanforge/pi-antigravity-bridge/src/config.ts +523 -0
  30. package/node_modules/@estebanforge/pi-antigravity-bridge/src/daily-log.ts +196 -0
  31. package/node_modules/@estebanforge/pi-antigravity-bridge/src/dialog-lock.ts +48 -0
  32. package/node_modules/@estebanforge/pi-antigravity-bridge/src/diff-render.ts +207 -0
  33. package/node_modules/@estebanforge/pi-antigravity-bridge/src/driver-types.ts +168 -0
  34. package/node_modules/@estebanforge/pi-antigravity-bridge/src/driver.ts +907 -0
  35. package/node_modules/@estebanforge/pi-antigravity-bridge/src/engine-picker.ts +160 -0
  36. package/node_modules/@estebanforge/pi-antigravity-bridge/src/frame-guard.ts +38 -0
  37. package/node_modules/@estebanforge/pi-antigravity-bridge/src/handoff-toast.ts +21 -0
  38. package/node_modules/@estebanforge/pi-antigravity-bridge/src/mcp-registration.ts +376 -0
  39. package/node_modules/@estebanforge/pi-antigravity-bridge/src/mcp-server.ts +618 -0
  40. package/node_modules/@estebanforge/pi-antigravity-bridge/src/models.ts +404 -0
  41. package/node_modules/@estebanforge/pi-antigravity-bridge/src/native-tools.ts +104 -0
  42. package/node_modules/@estebanforge/pi-antigravity-bridge/src/parked-turn.ts +125 -0
  43. package/node_modules/@estebanforge/pi-antigravity-bridge/src/patch-cleanup.ts +523 -0
  44. package/node_modules/@estebanforge/pi-antigravity-bridge/src/poll-fold.ts +55 -0
  45. package/node_modules/@estebanforge/pi-antigravity-bridge/src/prompt-images.ts +92 -0
  46. package/node_modules/@estebanforge/pi-antigravity-bridge/src/provider.ts +2214 -0
  47. package/node_modules/@estebanforge/pi-antigravity-bridge/src/queued-messages.ts +152 -0
  48. package/node_modules/@estebanforge/pi-antigravity-bridge/src/quota-notice.ts +40 -0
  49. package/node_modules/@estebanforge/pi-antigravity-bridge/src/redact.ts +27 -0
  50. package/node_modules/@estebanforge/pi-antigravity-bridge/src/sessions.ts +197 -0
  51. package/node_modules/@estebanforge/pi-antigravity-bridge/src/skills.ts +207 -0
  52. package/node_modules/@estebanforge/pi-antigravity-bridge/src/stream-events.ts +161 -0
  53. package/node_modules/@estebanforge/pi-antigravity-bridge/src/stream-sanitizer.ts +180 -0
  54. package/node_modules/@estebanforge/pi-antigravity-bridge/src/subagent-roster.ts +245 -0
  55. package/node_modules/@estebanforge/pi-antigravity-bridge/src/sysprompt-agent.ts +130 -0
  56. package/node_modules/@estebanforge/pi-antigravity-bridge/src/tasks-ui.ts +90 -0
  57. package/node_modules/@estebanforge/pi-antigravity-bridge/src/tasks.ts +174 -0
  58. package/node_modules/@estebanforge/pi-antigravity-bridge/src/usage.ts +174 -0
  59. package/node_modules/@estebanforge/pi-antigravity-bridge/src/web-tools.ts +320 -0
  60. package/node_modules/@herbertgao/pi-cc-extensions/CHANGELOG.md +6 -0
  61. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +1 -1
  62. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/prompt-editor.ts +3 -1
  63. package/node_modules/@herbertgao/pi-cc-extensions/package.json +1 -1
  64. package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +317 -105
  65. package/node_modules/@herbertgao/pi-subagents/SECURITY.md +2 -2
  66. package/node_modules/@herbertgao/pi-subagents/docs/rpc.md +240 -36
  67. package/node_modules/@herbertgao/pi-subagents/docs/translations.md +63 -0
  68. package/node_modules/@herbertgao/pi-subagents/docs/workflows.md +1 -1
  69. package/node_modules/@herbertgao/pi-subagents/package.json +4 -4
  70. package/node_modules/@herbertgao/pi-subagents/src/agent-file-toggle.ts +2 -0
  71. package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +89 -6
  72. package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +6 -2
  73. package/node_modules/@herbertgao/pi-subagents/src/agent-types.ts +20 -11
  74. package/node_modules/@herbertgao/pi-subagents/src/cache-retention.ts +39 -0
  75. package/node_modules/@herbertgao/pi-subagents/src/completion-outbox.ts +5 -0
  76. package/node_modules/@herbertgao/pi-subagents/src/cross-extension-rpc.ts +185 -44
  77. package/node_modules/@herbertgao/pi-subagents/src/custom-agents.ts +7 -0
  78. package/node_modules/@herbertgao/pi-subagents/src/group-join.ts +9 -0
  79. package/node_modules/@herbertgao/pi-subagents/src/index.ts +126 -116
  80. package/node_modules/@herbertgao/pi-subagents/src/mention-clone.ts +3 -2
  81. package/node_modules/@herbertgao/pi-subagents/src/settings.ts +21 -0
  82. package/node_modules/@herbertgao/pi-subagents/src/subagent-info.ts +115 -0
  83. package/node_modules/@herbertgao/pi-subagents/src/types.ts +11 -7
  84. package/node_modules/@herbertgao/pi-subagents/src/ui/agent-widget.ts +2 -3
  85. package/node_modules/@herbertgao/pi-subagents/src/ui/conversation-viewer.ts +1 -1
  86. package/node_modules/@herbertgao/pi-subagents/src/workflow/meta.ts +2 -2
  87. package/node_modules/@herbertgao/pi-subagents/src/workflow-info.ts +184 -0
  88. package/node_modules/pi-commandcode-provider/CHANGELOG.md +10 -0
  89. package/node_modules/pi-commandcode-provider/README.md +3 -2
  90. package/node_modules/pi-commandcode-provider/index.ts +120 -13
  91. package/node_modules/pi-commandcode-provider/package.json +4 -3
  92. package/node_modules/pi-commandcode-provider/src/commandcode-catalog.ts +11 -2
  93. package/node_modules/pi-commandcode-provider/src/pricing.ts +17 -1
  94. package/node_modules/pi-commandcode-provider/src/quota-command.ts +3 -2
  95. package/node_modules/pi-commandcode-provider/src/zdr.ts +163 -0
  96. package/package.json +11 -14
  97. package/node_modules/pi-antigravity/README.md +0 -298
  98. package/node_modules/pi-antigravity/docs/reader-guarantees.md +0 -35
  99. package/node_modules/pi-antigravity/package.json +0 -87
  100. package/node_modules/pi-antigravity/src/auth/accounts.ts +0 -327
  101. package/node_modules/pi-antigravity/src/auth/index.ts +0 -23
  102. package/node_modules/pi-antigravity/src/auth/oauth.ts +0 -445
  103. package/node_modules/pi-antigravity/src/client/client.ts +0 -602
  104. package/node_modules/pi-antigravity/src/client/enterprise.ts +0 -150
  105. package/node_modules/pi-antigravity/src/client/index.ts +0 -2
  106. package/node_modules/pi-antigravity/src/diagnostics/diagnostics.ts +0 -104
  107. package/node_modules/pi-antigravity/src/diagnostics/index.ts +0 -1
  108. package/node_modules/pi-antigravity/src/features/generate-image.ts +0 -132
  109. package/node_modules/pi-antigravity/src/features/google-search.ts +0 -72
  110. package/node_modules/pi-antigravity/src/features/read-url-content.ts +0 -124
  111. package/node_modules/pi-antigravity/src/image/image.ts +0 -427
  112. package/node_modules/pi-antigravity/src/image/index.ts +0 -1
  113. package/node_modules/pi-antigravity/src/image/native.ts +0 -69
  114. package/node_modules/pi-antigravity/src/index.ts +0 -547
  115. package/node_modules/pi-antigravity/src/models/discovery.ts +0 -176
  116. package/node_modules/pi-antigravity/src/models/grouping.ts +0 -487
  117. package/node_modules/pi-antigravity/src/models/index.ts +0 -3
  118. package/node_modules/pi-antigravity/src/models/models.ts +0 -647
  119. package/node_modules/pi-antigravity/src/search/index.ts +0 -1
  120. package/node_modules/pi-antigravity/src/search/search.ts +0 -967
  121. package/node_modules/pi-antigravity/src/stream/index.ts +0 -1
  122. package/node_modules/pi-antigravity/src/stream/stream.ts +0 -1961
  123. package/node_modules/pi-antigravity/src/types/enums.ts +0 -52
  124. package/node_modules/pi-antigravity/src/types/index.ts +0 -2
  125. package/node_modules/pi-antigravity/src/types/types.ts +0 -329
  126. package/node_modules/pi-antigravity/src/usage/index.ts +0 -1
  127. package/node_modules/pi-antigravity/src/usage/usage.ts +0 -437
  128. package/node_modules/pi-antigravity/src/utils/address.ts +0 -180
  129. package/node_modules/pi-antigravity/src/utils/credits.ts +0 -149
  130. package/node_modules/pi-antigravity/src/utils/html.ts +0 -31
  131. package/node_modules/pi-antigravity/src/utils/http.ts +0 -96
  132. package/node_modules/pi-antigravity/src/utils/index.ts +0 -5
  133. package/node_modules/pi-antigravity/src/utils/security.ts +0 -278
  134. package/node_modules/pi-antigravity/src/utils/text.ts +0 -66
  135. package/node_modules/pi-antigravity/src/utils/util.ts +0 -217
  136. package/node_modules/pi-antigravity/src/web-fetch/document.ts +0 -83
  137. package/node_modules/pi-antigravity/src/web-fetch/fences.ts +0 -24
  138. package/node_modules/pi-antigravity/src/web-fetch/header.ts +0 -97
  139. package/node_modules/pi-antigravity/src/web-fetch/index.ts +0 -3
  140. package/node_modules/pi-antigravity/src/web-fetch/inspect.ts +0 -328
  141. package/node_modules/pi-antigravity/src/web-fetch/limits.ts +0 -4
  142. package/node_modules/pi-antigravity/src/web-fetch/markdown.ts +0 -744
  143. package/node_modules/pi-antigravity/src/web-fetch/mdn.ts +0 -164
  144. package/node_modules/pi-antigravity/src/web-fetch/media.ts +0 -11
  145. package/node_modules/pi-antigravity/src/web-fetch/metadata.ts +0 -9
  146. package/node_modules/pi-antigravity/src/web-fetch/representation.ts +0 -93
  147. package/node_modules/pi-antigravity/src/web-fetch/save.ts +0 -71
  148. package/node_modules/pi-antigravity/src/web-fetch/sites.ts +0 -138
  149. package/node_modules/pi-antigravity/src/web-fetch/vendor.d.ts +0 -9
  150. package/node_modules/pi-antigravity/src/web-fetch/web-fetch.ts +0 -957
  151. package/node_modules/pi-antigravity/tsconfig.json +0 -21
@@ -1,647 +0,0 @@
1
- import type { AntigravityModelConfig, AntigravityRouting, ThinkingWire } from "../types/types.js";
2
- import { ThinkingEffort } from "../types/enums.js";
3
- import type { AntigravityCatalog } from "./grouping.js";
4
-
5
- export const PROVIDER_ID = "antigravity";
6
- export const PROVIDER_NAME = "Antigravity";
7
-
8
- /**
9
- * Public selectable model IDs → backend request model IDs by thinking effort.
10
- *
11
- * Catalog mirrors `agy models` (Antigravity CLI), which currently advertises:
12
- * - Gemini 3.8 Flash (Low / Medium / High)
13
- * - Gemini 3.7 Flash (Low / Medium / High)
14
- * - Gemini 3.6 Flash (Low / Medium / High)
15
- * - Gemini 3.5 Flash (Low / Medium / High)
16
- * - Gemini 3.1 Pro (Low / High)
17
- * - Claude Sonnet 4.6 (Thinking)
18
- * - Claude Opus 4.6 (Thinking)
19
- * - GPT-OSS 120B (Medium)
20
- *
21
- * Pi exposes those as public model IDs and only surfaces the exact thinking levels
22
- * advertised by the backend for each model.
23
- */
24
- export const ANTIGRAVITY_ROUTING: Record<string, AntigravityRouting> = {
25
- "claude-opus-4-6": {
26
- routing: {
27
- minimal: "claude-opus-4-6-thinking",
28
- low: "claude-opus-4-6-thinking",
29
- medium: "claude-opus-4-6-thinking",
30
- high: "claude-opus-4-6-thinking",
31
- },
32
- defaultRequestId: "claude-opus-4-6-thinking",
33
- },
34
- // Live fetchAvailableModels exposes `claude-sonnet-4-6` (display: Thinking), not a separate *-thinking id.
35
- "claude-sonnet-4-6": {
36
- off: "claude-sonnet-4-6",
37
- routing: {
38
- minimal: "claude-sonnet-4-6",
39
- low: "claude-sonnet-4-6",
40
- medium: "claude-sonnet-4-6",
41
- high: "claude-sonnet-4-6",
42
- xhigh: "claude-sonnet-4-6",
43
- },
44
- defaultRequestId: "claude-sonnet-4-6",
45
- },
46
- "gemini-3.1-pro": {
47
- // `gemini-3.1-pro-high` is advertised but currently 400s for agent streamGenerateContent;
48
- // `gemini-pro-agent` is the working High runtime id (same display name in fetchAvailableModels).
49
- off: "gemini-3.1-pro-low",
50
- routing: {
51
- minimal: "gemini-3.1-pro-low",
52
- low: "gemini-3.1-pro-low",
53
- medium: "gemini-3.1-pro-low",
54
- high: "gemini-pro-agent",
55
- xhigh: "gemini-pro-agent",
56
- },
57
- defaultRequestId: "gemini-3.1-pro-low",
58
- },
59
- "gemini-3.8-flash": {
60
- off: "gemini-3.8-flash-low",
61
- routing: {
62
- minimal: "gemini-3.8-flash-low",
63
- low: "gemini-3.8-flash-low",
64
- medium: "gemini-3.8-flash-medium",
65
- high: "gemini-3.8-flash-high",
66
- xhigh: "gemini-3.8-flash-high",
67
- },
68
- defaultRequestId: "gemini-3.8-flash-low",
69
- },
70
- "gemini-3.7-flash": {
71
- off: "gemini-3.7-flash-low",
72
- routing: {
73
- minimal: "gemini-3.7-flash-low",
74
- low: "gemini-3.7-flash-low",
75
- medium: "gemini-3.7-flash-medium",
76
- high: "gemini-3.7-flash-high",
77
- xhigh: "gemini-3.7-flash-high",
78
- },
79
- defaultRequestId: "gemini-3.7-flash-low",
80
- },
81
- "gemini-3.6-flash": {
82
- // agy models: gemini-3.6-flash-low / -medium / -high
83
- off: "gemini-3.6-flash-low",
84
- routing: {
85
- minimal: "gemini-3.6-flash-low",
86
- low: "gemini-3.6-flash-low",
87
- medium: "gemini-3.6-flash-medium",
88
- high: "gemini-3.6-flash-high",
89
- xhigh: "gemini-3.6-flash-high",
90
- },
91
- defaultRequestId: "gemini-3.6-flash-low",
92
- },
93
- "gemini-3.5-flash": {
94
- off: "gemini-3.5-flash-extra-low",
95
- routing: {
96
- minimal: "gemini-3.5-flash-extra-low",
97
- low: "gemini-3.5-flash-extra-low",
98
- medium: "gemini-3.5-flash-low",
99
- high: "gemini-3-flash-agent",
100
- xhigh: "gemini-3-flash-agent",
101
- },
102
- defaultRequestId: "gemini-3.5-flash-extra-low",
103
- },
104
- "gpt-oss-120b": {
105
- off: "gpt-oss-120b-medium",
106
- routing: {
107
- minimal: "gpt-oss-120b-medium",
108
- low: "gpt-oss-120b-medium",
109
- medium: "gpt-oss-120b-medium",
110
- high: "gpt-oss-120b-medium",
111
- },
112
- defaultRequestId: "gpt-oss-120b-medium",
113
- },
114
- };
115
-
116
- /**
117
- * Verified maximum output tokens accepted by the Cloud Code Assist backend per model/runtime ID.
118
- * Requesting more than these limits returns a 400 Bad Request from the API.
119
- */
120
- export const RUNTIME_MAX_OUTPUT_TOKENS: Record<string, number> = {
121
- "gemini-4-hydrogen": 262144,
122
- "gemini-4-hydrogen-low": 262144,
123
- "gemini-4-hydrogen-medium": 262144,
124
- "gemini-4-hydrogen-high": 262144,
125
- "gemini-4-hydrogen-xhigh": 262144,
126
- "gemini-3.8-flash": 65536,
127
- "gemini-3.8-flash-low": 65536,
128
- "gemini-3.8-flash-medium": 65536,
129
- "gemini-3.8-flash-high": 65536,
130
- "gemini-3.7-flash": 65536,
131
- "gemini-3.7-flash-tiered": 65536,
132
- // Retain rollout-era IDs for compatibility with pinned runtime overrides.
133
- "gemini-3.7-flash-low": 65536,
134
- "gemini-3.7-flash-medium": 65536,
135
- "gemini-3.7-flash-high": 65536,
136
- "gemini-3.6-flash": 65536,
137
- "gemini-3.6-flash-low": 65536,
138
- "gemini-3.6-flash-medium": 65536,
139
- "gemini-3.6-flash-high": 65536,
140
- "gemini-3.5-flash": 65536,
141
- "gemini-3.5-flash-extra-low": 65536,
142
- "gemini-3.5-flash-low": 65536,
143
- "gemini-3-flash-agent": 65536,
144
- "gemini-3.1-pro": 65535,
145
- "gemini-3.1-pro-low": 65535,
146
- "gemini-3.1-pro-high": 65535,
147
- "gemini-pro-agent": 65535,
148
- "claude-opus-4-6": 64000,
149
- "claude-opus-4-6-thinking": 64000,
150
- "claude-sonnet-4-6": 64000,
151
- "gpt-oss-120b": 32768,
152
- "gpt-oss-120b-medium": 32768,
153
- };
154
-
155
- export function getMaxOutputTokens(modelId: string, runtimeModel?: string): number {
156
- // Refreshed (and restored) catalog limits take precedence over static defaults.
157
- const discovered = currentModels.find((model) => model.id === modelId);
158
- if (currentModels !== ANTIGRAVITY_MODELS && discovered) return discovered.maxTokens;
159
- if (runtimeModel && RUNTIME_MAX_OUTPUT_TOKENS[runtimeModel] !== undefined) {
160
- return RUNTIME_MAX_OUTPUT_TOKENS[runtimeModel];
161
- }
162
- if (RUNTIME_MAX_OUTPUT_TOKENS[modelId] !== undefined) {
163
- return RUNTIME_MAX_OUTPUT_TOKENS[modelId];
164
- }
165
- if (runtimeModel) {
166
- if (runtimeModel.startsWith("claude-")) return 64000;
167
- if (runtimeModel.startsWith("gpt-oss-")) return 32768;
168
- if (runtimeModel.startsWith("gemini-3.1-pro") || runtimeModel === "gemini-pro-agent")
169
- return 65535;
170
- if (runtimeModel.startsWith("gemini-")) return 65536;
171
- }
172
- return 8192;
173
- }
174
-
175
- /**
176
- * Per-model list prices, in USD per million tokens.
177
- *
178
- * Every Flash model used to share one flat placeholder ($0.10 / $0.40 / $0.025),
179
- * which understated Gemini usage by roughly 4-7x. Rates below come from the
180
- * LiteLLM public catalog (the same source Pi's own cost reporting uses), which
181
- * tracks Google's published per-model pricing:
182
- * https://ai.google.dev/gemini-api/docs/pricing
183
- *
184
- * gemini-3.8-flash sits on Google's 50%-off launch rate ($0.75 / $3.75 / $0.075),
185
- * which is valid through 2026-12-31 and becomes $1.50 / $7.50 / $0.15 on
186
- * 2027-01-01. Revisit this table when that date passes.
187
- *
188
- * Gemini bills cached content for storage per hour rather than per token, so
189
- * there is no cache-write rate to publish; the input rate is used.
190
- */
191
- const gemini38FlashCost = { input: 0.75, output: 3.75, cacheRead: 0.075, cacheWrite: 0.75 };
192
- const gemini4HydrogenCost = { input: 1.5, output: 7.5, cacheRead: 0.075, cacheWrite: 1.5 };
193
- const gemini37FlashCost = { input: 0.75, output: 3.75, cacheRead: 0.075, cacheWrite: 0.75 };
194
- const gemini36FlashCost = { input: 0.75, output: 3.75, cacheRead: 0.075, cacheWrite: 0.75 };
195
- const gemini35FlashCost = { input: 1.5, output: 9.0, cacheRead: 0.15, cacheWrite: 1.5 };
196
- const gemini35FlashLiteCost = { input: 0.3, output: 2.5, cacheRead: 0.03, cacheWrite: 0.3 };
197
- const gemini31FlashLiteCost = { input: 0.25, output: 1.5, cacheRead: 0.025, cacheWrite: 0.25 };
198
- const gemini25FlashCost = { input: 0.3, output: 2.5, cacheRead: 0.03, cacheWrite: 0.3 };
199
- const gemini25FlashLiteCost = { input: 0.1, output: 0.4, cacheRead: 0.01, cacheWrite: 0.1 };
200
- const gemini31ProCost = { input: 2.0, output: 12.0, cacheRead: 0.2, cacheWrite: 2.0 };
201
- const gemini25ProCost = { input: 1.25, output: 10.0, cacheRead: 0.125, cacheWrite: 1.25 };
202
- const claudeSonnetCost = { input: 3.0, output: 15.0, cacheRead: 0.3, cacheWrite: 3.75 };
203
- const claudeOpusCost = { input: 5.0, output: 25.0, cacheRead: 0.5, cacheWrite: 6.25 };
204
- const gptOssCost = { input: 0.6, output: 2.4, cacheRead: 0.15, cacheWrite: 0.6 };
205
-
206
- /**
207
- * Prices for models this package can discover dynamically but does not ship as
208
- * a static entry. Keyed by public model id.
209
- */
210
- export const ANTIGRAVITY_DISCOVERED_MODEL_COSTS: Record<
211
- string,
212
- { input: number; output: number; cacheRead: number; cacheWrite: number }
213
- > = {
214
- "gemini-4-hydrogen": gemini4HydrogenCost,
215
- "gemini-3.5-flash": gemini35FlashCost,
216
- "gemini-3.5-flash-lite": gemini35FlashLiteCost,
217
- "gemini-3.1-flash-lite": gemini31FlashLiteCost,
218
- "gemini-2.5-flash": gemini25FlashCost,
219
- "gemini-2.5-flash-lite": gemini25FlashLiteCost,
220
- "gemini-2.5-pro": gemini25ProCost,
221
- };
222
-
223
- /**
224
- * Look up a model's list price by public id. Returns undefined when the model
225
- * is not priced here, so callers can fall back rather than publish a guess.
226
- */
227
- export function getAntigravityModelCost(
228
- publicId: string,
229
- ): { input: number; output: number; cacheRead: number; cacheWrite: number } | undefined {
230
- const discovered = ANTIGRAVITY_DISCOVERED_MODEL_COSTS[publicId];
231
- if (discovered) return discovered;
232
- const staticModel = ANTIGRAVITY_MODELS.find((model) => model.id === publicId);
233
- return staticModel?.cost;
234
- }
235
-
236
- // A null entry is intentionally hidden by Pi. Do not collapse levels that happen to
237
- // route to the same runtime ID: the UI must reflect the levels the backend advertises.
238
- const thinkingLevelMaps = {
239
- lowMediumHigh: {
240
- off: null,
241
- minimal: null,
242
- low: "low",
243
- medium: "medium",
244
- high: "high",
245
- xhigh: null,
246
- max: null,
247
- },
248
- lowHigh: {
249
- off: null,
250
- minimal: null,
251
- low: "low",
252
- medium: null,
253
- high: "high",
254
- xhigh: null,
255
- max: null,
256
- },
257
- thinking: {
258
- off: null,
259
- minimal: null,
260
- low: null,
261
- medium: null,
262
- high: "high",
263
- xhigh: null,
264
- max: null,
265
- },
266
- medium: {
267
- off: null,
268
- minimal: null,
269
- low: null,
270
- medium: "medium",
271
- high: null,
272
- xhigh: null,
273
- max: null,
274
- },
275
- } satisfies Record<string, AntigravityModelConfig["thinkingLevelMap"]>;
276
-
277
- /** Same set as `agy models`, collapsed to public Pi model IDs. */
278
- export const ANTIGRAVITY_MODELS: AntigravityModelConfig[] = [
279
- {
280
- id: "gemini-3.8-flash",
281
- name: "Gemini 3.8 Flash (Antigravity)",
282
- reasoning: true,
283
- thinkingLevelMap: thinkingLevelMaps.lowMediumHigh,
284
- input: ["text", "image"],
285
- cost: gemini38FlashCost,
286
- contextWindow: 1048576,
287
- maxTokens: 65536,
288
- },
289
- {
290
- id: "gemini-3.7-flash",
291
- name: "Gemini 3.7 Flash (Antigravity)",
292
- reasoning: true,
293
- thinkingLevelMap: thinkingLevelMaps.lowMediumHigh,
294
- input: ["text", "image"],
295
- cost: gemini37FlashCost,
296
- contextWindow: 1048576,
297
- maxTokens: 65536,
298
- },
299
- {
300
- id: "gemini-3.6-flash",
301
- name: "Gemini 3.6 Flash (Antigravity)",
302
- reasoning: true,
303
- thinkingLevelMap: thinkingLevelMaps.lowMediumHigh,
304
- input: ["text", "image"],
305
- cost: gemini36FlashCost,
306
- contextWindow: 1048576,
307
- maxTokens: 65536,
308
- },
309
- {
310
- id: "claude-opus-4-6",
311
- name: "Claude Opus 4.6 (Antigravity)",
312
- reasoning: true,
313
- thinkingLevelMap: thinkingLevelMaps.thinking,
314
- input: ["text", "image"],
315
- cost: claudeOpusCost,
316
- contextWindow: 250000,
317
- maxTokens: 64000,
318
- },
319
- {
320
- id: "claude-sonnet-4-6",
321
- name: "Claude Sonnet 4.6 (Antigravity)",
322
- reasoning: true,
323
- thinkingLevelMap: thinkingLevelMaps.thinking,
324
- input: ["text", "image"],
325
- cost: claudeSonnetCost,
326
- contextWindow: 200000,
327
- maxTokens: 64000,
328
- },
329
- {
330
- id: "gemini-3.1-pro",
331
- name: "Gemini 3.1 Pro (Antigravity)",
332
- reasoning: true,
333
- thinkingLevelMap: thinkingLevelMaps.lowHigh,
334
- input: ["text", "image"],
335
- cost: gemini31ProCost,
336
- contextWindow: 1048576,
337
- maxTokens: 65535,
338
- },
339
- {
340
- id: "gemini-3.5-flash",
341
- name: "Gemini 3.5 Flash (Antigravity)",
342
- reasoning: true,
343
- thinkingLevelMap: thinkingLevelMaps.lowMediumHigh,
344
- input: ["text", "image"],
345
- cost: gemini35FlashCost,
346
- contextWindow: 1048576,
347
- maxTokens: 65536,
348
- },
349
- {
350
- id: "gpt-oss-120b",
351
- name: "GPT-OSS 120B (Antigravity)",
352
- reasoning: true,
353
- thinkingLevelMap: thinkingLevelMaps.medium,
354
- input: ["text"],
355
- cost: gptOssCost,
356
- contextWindow: 131072,
357
- maxTokens: 32768,
358
- },
359
- ];
360
-
361
- let currentModels: AntigravityModelConfig[] = ANTIGRAVITY_MODELS;
362
- let currentRouting: Record<string, AntigravityRouting> = { ...ANTIGRAVITY_ROUTING };
363
-
364
- export function getCurrentAntigravityModels(): AntigravityModelConfig[] {
365
- return currentModels;
366
- }
367
-
368
- export function getCurrentAntigravityRouting(): Record<string, AntigravityRouting> {
369
- return currentRouting;
370
- }
371
-
372
- export function getCurrentAntigravityCatalog(): AntigravityCatalog {
373
- return { models: currentModels, routing: currentRouting };
374
- }
375
-
376
- export function applyAntigravityCatalog(catalog: AntigravityCatalog): void {
377
- currentModels = catalog.models;
378
- currentRouting = catalog.routing;
379
- }
380
-
381
- export function resetAntigravityCatalogForTests(): void {
382
- currentModels = ANTIGRAVITY_MODELS;
383
- currentRouting = { ...ANTIGRAVITY_ROUTING };
384
- }
385
-
386
- /** Resolve public model id + thinking effort to Antigravity runtime model id. */
387
- export function getAntigravityRequestModelId(modelId: string, effort: string | undefined): string {
388
- // A selected model can outlive a catalog refresh (for example in a resumed
389
- // session). Do not resurrect a retired route from the bootstrap catalog.
390
- if (
391
- currentModels !== ANTIGRAVITY_MODELS &&
392
- !currentRouting[modelId] &&
393
- ANTIGRAVITY_ROUTING[modelId]
394
- ) {
395
- throw new Error(
396
- `Antigravity model ${modelId} is absent from the current catalog. Next: run /antigravity.refresh and select an available model.`,
397
- );
398
- }
399
- const r = currentRouting[modelId];
400
- if (!r) return modelId;
401
-
402
- if (effort === undefined || effort === "off") {
403
- return r.off ?? r.routing?.minimal ?? r.routing?.low ?? r.defaultRequestId ?? modelId;
404
- }
405
-
406
- const effortKey = effort as ThinkingEffort;
407
- if (effortKey === ThinkingEffort.Xhigh) {
408
- return (
409
- r.routing?.xhigh ??
410
- r.routing?.high ??
411
- r.routing?.low ??
412
- r.routing?.minimal ??
413
- r.off ??
414
- r.defaultRequestId ??
415
- modelId
416
- );
417
- }
418
-
419
- return (
420
- r.routing?.[effortKey] ??
421
- r.routing?.low ??
422
- r.routing?.minimal ??
423
- r.off ??
424
- r.defaultRequestId ??
425
- modelId
426
- );
427
- }
428
-
429
- /**
430
- * If a next-gen model (e.g. Gemini 3.8 Flash) is not yet available on the backend,
431
- * provide a fallback runtime model ID (e.g. Gemini 3.7 Flash) to maintain availability.
432
- */
433
- export function getFallbackRuntimeModel(runtimeModel: string, effort?: string): string | undefined {
434
- const fallback = legacyFallbackRuntimeModel(runtimeModel, effort);
435
- if (!fallback || currentModels === ANTIGRAVITY_MODELS) return fallback;
436
- // Compatibility fallbacks are only valid while the backend still advertises
437
- // their runtime ID. Never downgrade into a retired Flash generation.
438
- return Object.values(currentRouting).some((route) =>
439
- [route.off, route.defaultRequestId, ...Object.values(route.routing ?? {})].includes(fallback),
440
- )
441
- ? fallback
442
- : undefined;
443
- }
444
-
445
- /** Return the legacy Flash downgrade candidate before checking current catalog availability. */
446
- function legacyFallbackRuntimeModel(runtimeModel: string, effort?: string): string | undefined {
447
- if (runtimeModel.startsWith("gemini-3.8-flash-")) {
448
- return runtimeModel.replace("gemini-3.8-flash-", "gemini-3.7-flash-");
449
- }
450
- if (runtimeModel === "gemini-3.8-flash") {
451
- return "gemini-3.7-flash-low";
452
- }
453
- if (runtimeModel === "gemini-3.7-flash-tiered") {
454
- const route = currentRouting["gemini-3.6-flash"];
455
- return route ? getAntigravityRequestModelId("gemini-3.6-flash", effort) : undefined;
456
- }
457
- if (runtimeModel.startsWith("gemini-3.7-flash-")) {
458
- return runtimeModel.replace("gemini-3.7-flash-", "gemini-3.6-flash-");
459
- }
460
- if (runtimeModel === "gemini-3.7-flash") {
461
- return "gemini-3.6-flash-low";
462
- }
463
- return undefined;
464
- }
465
-
466
- const RUNTIME_TIER_SUFFIXES = ["-extra-low", "-low", "-medium", "-high", "-max", "-xhigh"] as const;
467
-
468
- /** Split `gemini-3.8-flash-low` into its family and tier. Thinking-only ids are not tiers. */
469
- export function runtimeTier(runtimeModel: string): { base: string; suffix: string } | undefined {
470
- for (const suffix of RUNTIME_TIER_SUFFIXES) {
471
- if (runtimeModel.endsWith(suffix) && runtimeModel.length > suffix.length) {
472
- return { base: runtimeModel.slice(0, -suffix.length), suffix };
473
- }
474
- }
475
- return undefined;
476
- }
477
-
478
- /**
479
- * Same-generation tiers to try after one tier answers with a generic
480
- * RESOURCE_EXHAUSTED. Highest remaining tier first, so a dead `-low` route
481
- * (Gemini 3.8 Flash with reasoning off, #125) moves to `-high` / `-medium`,
482
- * and `gemini-4-argon-high` can step down to `-medium` (#122).
483
- */
484
- export function siblingRuntimeModels(runtimeModel: string): string[] {
485
- const tier = runtimeTier(runtimeModel);
486
- if (!tier) return [];
487
- const preferred = ["-high", "-medium", "-xhigh", "-low", "-extra-low", "-max"];
488
- return preferred.filter((suffix) => suffix !== tier.suffix).map((suffix) => tier.base + suffix);
489
- }
490
-
491
- /** Sibling tiers this process already knows how to route, capped for dynamic families. */
492
- export function advertisedSiblingRuntimes(runtimeModel: string): string[] {
493
- const candidates = siblingRuntimeModels(runtimeModel);
494
- if (!candidates.length) return [];
495
- const known = new Set<string>();
496
- for (const route of Object.values(currentRouting)) {
497
- if (route.off) known.add(route.off);
498
- if (route.defaultRequestId) known.add(route.defaultRequestId);
499
- for (const id of Object.values(route.routing ?? {})) {
500
- if (id) known.add(id);
501
- }
502
- }
503
- const routed = candidates.filter((id) => known.has(id));
504
- if (routed.length) return routed;
505
- const tier = runtimeTier(runtimeModel);
506
- if (!tier) return [];
507
- if (tier.base.startsWith("gemini-") || tier.base.startsWith("claude-")) {
508
- return candidates.slice(0, 2);
509
- }
510
- return [];
511
- }
512
-
513
- export type { ThinkingWire };
514
-
515
- export const ANTIGRAVITY_MODEL_ENUM: Record<string, string> = {
516
- // Gemini 4 Hydrogen
517
- "gemini-4-hydrogen": "MODEL_PLACEHOLDER_M527",
518
- "gemini-4-hydrogen-high": "MODEL_PLACEHOLDER_M525",
519
- "gemini-4-hydrogen-xhigh": "MODEL_PLACEHOLDER_M528",
520
- "gemini-4-hydrogen-medium": "MODEL_PLACEHOLDER_M526",
521
- "gemini-4-hydrogen-low": "MODEL_PLACEHOLDER_M527",
522
- // Gemini 3.8 Flash
523
- "gemini-3.8-flash": "MODEL_PLACEHOLDER_M318",
524
- "gemini-3.8-flash-high": "MODEL_PLACEHOLDER_M318",
525
- "gemini-3.8-flash-medium": "MODEL_PLACEHOLDER_M319",
526
- "gemini-3.8-flash-low": "MODEL_PLACEHOLDER_M320",
527
- "gemini-3.8-flash-tiered": "MODEL_PLACEHOLDER_M322",
528
- // Gemini 3.7 Flash
529
- "gemini-3.7-flash": "MODEL_PLACEHOLDER_M298",
530
- "gemini-3.7-flash-high": "MODEL_PLACEHOLDER_M298",
531
- "gemini-3.7-flash-medium": "MODEL_PLACEHOLDER_M299",
532
- "gemini-3.7-flash-low": "MODEL_PLACEHOLDER_M300",
533
- "gemini-3.7-flash-tiered": "MODEL_PLACEHOLDER_M301",
534
- // Gemini 3.6 Flash
535
- "gemini-3.6-flash": "MODEL_PLACEHOLDER_M71",
536
- "gemini-3.6-flash-high": "MODEL_PLACEHOLDER_M71",
537
- "gemini-3.6-flash-medium": "MODEL_PLACEHOLDER_M72",
538
- "gemini-3.6-flash-low": "MODEL_PLACEHOLDER_M73",
539
- "gemini-3.6-flash-tiered": "MODEL_PLACEHOLDER_M196",
540
- // Gemini 3.5 Flash
541
- "gemini-3.5-flash": "MODEL_PLACEHOLDER_M20",
542
- "gemini-3.5-flash-extra-low": "MODEL_PLACEHOLDER_M187",
543
- "gemini-3.5-flash-low": "MODEL_PLACEHOLDER_M20",
544
- "gemini-3-flash-agent": "MODEL_PLACEHOLDER_M84",
545
- // Gemini 3.1 Pro
546
- "gemini-3.1-pro": "MODEL_PLACEHOLDER_M36",
547
- "gemini-3.1-pro-low": "MODEL_PLACEHOLDER_M36",
548
- "gemini-3.1-pro-high": "MODEL_PLACEHOLDER_M37",
549
- "gemini-pro-agent": "MODEL_PLACEHOLDER_M16",
550
- // Claude
551
- "claude-sonnet-4-6": "MODEL_PLACEHOLDER_M35",
552
- "claude-opus-4-6": "MODEL_PLACEHOLDER_M26",
553
- "claude-opus-4-6-thinking": "MODEL_PLACEHOLDER_M26",
554
- // GPT-OSS
555
- "gpt-oss-120b": "MODEL_OPENAI_GPT_OSS_120B_MEDIUM",
556
- "gpt-oss-120b-medium": "MODEL_OPENAI_GPT_OSS_120B_MEDIUM",
557
- };
558
-
559
- const modelEnumCache = new Map<string, string>();
560
-
561
- /** Register dynamically discovered model enum (e.g. from fetchAvailableModels). */
562
- export function registerModelEnum(wireModelId: string, modelEnum: string): void {
563
- if (wireModelId && modelEnum) {
564
- modelEnumCache.set(wireModelId, modelEnum);
565
- }
566
- }
567
-
568
- /** Register batch of discovered model enums from fetchAvailableModels raw models dictionary. */
569
- export function registerDiscoveredModelEnums(
570
- models: Record<string, { model?: unknown }> | undefined,
571
- ): void {
572
- if (!models) return;
573
- for (const [wireId, info] of Object.entries(models)) {
574
- if (typeof info?.model === "string" && info.model) {
575
- modelEnumCache.set(wireId, info.model);
576
- }
577
- }
578
- }
579
-
580
- /** Get model_enum label for a given wire model id (dynamic cache first, then static fallback). */
581
- export function getModelEnum(wireModelId: string): string | undefined {
582
- const direct = modelEnumCache.get(wireModelId) || ANTIGRAVITY_MODEL_ENUM[wireModelId];
583
- if (direct) return direct;
584
-
585
- // Runtime overrides may name a public/base model while discovery only returned
586
- // an enum for its selected runtime variant (for example `-low`).
587
- const routed = getAntigravityRequestModelId(wireModelId, undefined);
588
- return modelEnumCache.get(routed) || ANTIGRAVITY_MODEL_ENUM[routed];
589
- }
590
-
591
- /** Return a serializable snapshot of model enums learned from discovery. */
592
- export function snapshotDynamicModelEnums(): Record<string, string> {
593
- return Object.fromEntries(modelEnumCache);
594
- }
595
-
596
- /** Replace dynamically learned model enums with a previously persisted snapshot. */
597
- export function restoreDynamicModelEnums(modelEnums: Record<string, string>): void {
598
- modelEnumCache.clear();
599
- for (const [wireModelId, modelEnum] of Object.entries(modelEnums)) {
600
- if (wireModelId && modelEnum) modelEnumCache.set(wireModelId, modelEnum);
601
- }
602
- }
603
-
604
- export function clearModelEnumCache(): void {
605
- modelEnumCache.clear();
606
- }
607
-
608
- export function getThinkingConfig(
609
- modelId: string,
610
- effort: string | undefined,
611
- ): ThinkingWire | undefined {
612
- if (modelId.startsWith("claude-")) {
613
- if (!effort || effort === "off") return { includeThoughts: false, thinkingBudget: 0 };
614
- return { includeThoughts: true, thinkingBudget: 1024 };
615
- }
616
- if (modelId.startsWith("gpt-oss-")) {
617
- if (!effort || effort === "off") return { includeThoughts: false, thinkingBudget: 0 };
618
- return { includeThoughts: true, thinkingBudget: 8192 };
619
- }
620
- if (modelId.startsWith("gemini-3.5-flash") || modelId === "gemini-3-flash-agent") {
621
- if (!effort || effort === "off") return { includeThoughts: false, thinkingBudget: 0 };
622
- const thinkingBudget =
623
- effort === "high" || effort === "xhigh" ? 10_000 : effort === "medium" ? 4_000 : 1_000;
624
- return { includeThoughts: true, thinkingBudget };
625
- }
626
- if (modelId.startsWith("gemini-3.1-pro") || modelId === "gemini-pro-agent") {
627
- if (!effort || effort === "off") return { includeThoughts: false, thinkingBudget: 0 };
628
- return {
629
- includeThoughts: true,
630
- thinkingBudget: effort === "high" || effort === "xhigh" ? 10_001 : 1_001,
631
- };
632
- }
633
- // Gemini 4 Argon rejects thinkingBudget 0 and any budget under 1000 (#93).
634
- if (modelId.includes("argon") || modelId.startsWith("gemini-4")) {
635
- if (!effort || effort === "off") return undefined;
636
- const thinkingBudget =
637
- effort === "high" || effort === "xhigh" ? -1 : effort === "medium" ? 4_000 : 1_000;
638
- return { includeThoughts: true, thinkingBudget };
639
- }
640
- if (modelId.startsWith("gemini-")) {
641
- if (!effort || effort === "off") return { includeThoughts: false, thinkingBudget: 0 };
642
- const thinkingBudget =
643
- effort === "high" || effort === "xhigh" ? -1 : effort === "medium" ? 4_000 : 1_000;
644
- return { includeThoughts: true, thinkingBudget };
645
- }
646
- return undefined;
647
- }
@@ -1 +0,0 @@
1
- export * from "./search.js";