@anthonyhaussman/opencode-agy-auth 1.2.14-alpha.0 → 1.2.16-alpha.0

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.
package/dist/index.js CHANGED
@@ -268,7 +268,7 @@ function createAgyActivityRequestId() {
268
268
  import os from "os";
269
269
 
270
270
  // src/sdk/agy-cli-version.ts
271
- var AGY_CLI_VERSION = "1.2.14";
271
+ var AGY_CLI_VERSION = "1.2.16";
272
272
 
273
273
  // src/sdk/user-agent.ts
274
274
  var cachedUserAgent = null;
@@ -579,12 +579,6 @@ async function resolveQuotaResetDelay(accessToken, projectId, model, userAgentMo
579
579
  return null;
580
580
  }
581
581
  }
582
- var retryInternals = {
583
- parseRetryDelayValue,
584
- parseRetryDelayFromMessage,
585
- findResetTimeForModel,
586
- resolveQuotaResetDelay
587
- };
588
582
 
589
583
  // src/sdk/retry/helpers.ts
590
584
  var DEFAULT_MAX_ATTEMPTS = 3;
@@ -1581,11 +1575,7 @@ function createOAuthAuthorizeMethod(options) {
1581
1575
  const isHeadless = !!(process.env.SSH_CONNECTION || process.env.SSH_CLIENT || process.env.SSH_TTY || process.env.OPENCODE_HEADLESS);
1582
1576
  const authorization = await authorizeAgy();
1583
1577
  if (!isHeadless) {
1584
- if (options?.openBrowser) {
1585
- options.openBrowser(authorization.url);
1586
- } else {
1587
- openBrowserUrl(authorization.url);
1588
- }
1578
+ openBrowserUrl(authorization.url);
1589
1579
  }
1590
1580
  return {
1591
1581
  url: authorization.url,
@@ -1639,23 +1629,16 @@ function parseOAuthCallbackInput(input) {
1639
1629
  }
1640
1630
  return { code: trimmed };
1641
1631
  }
1642
- function defaultOpenBrowserLauncher(command, args) {
1643
- const child = spawn(command, args, {
1644
- stdio: "ignore",
1645
- detached: true
1646
- });
1647
- child.unref?.();
1648
- }
1649
- var openBrowserLauncher = defaultOpenBrowserLauncher;
1650
1632
  function openBrowserUrl(url2) {
1651
- if ((process.env.NODE_ENV === "test" || process.env.VITEST) && openBrowserLauncher === defaultOpenBrowserLauncher) {
1652
- return;
1653
- }
1654
1633
  try {
1655
1634
  const platform2 = process.platform;
1656
1635
  const command = platform2 === "darwin" ? "open" : platform2 === "win32" ? "rundll32" : "xdg-open";
1657
1636
  const args = platform2 === "win32" ? ["url.dll,FileProtocolHandler", url2] : [url2];
1658
- openBrowserLauncher(command, args);
1637
+ const child = spawn(command, args, {
1638
+ stdio: "ignore",
1639
+ detached: true
1640
+ });
1641
+ child.unref?.();
1659
1642
  } catch {
1660
1643
  }
1661
1644
  }
@@ -15337,12 +15320,6 @@ function formatRelativeResetTime(resetTime) {
15337
15320
 
15338
15321
  // src/plugin/quota.ts
15339
15322
  var AGY_QUOTA_TOOL_NAME = "agy_quota";
15340
- var AGY_V2_QUOTA_COMMAND = "agy-quota";
15341
- var AGY_V2_QUOTA_COMMAND_TEMPLATE = `Retrieve Agy Code Assist quota usage for the current authenticated account.
15342
-
15343
- Immediately call \`${AGY_QUOTA_TOOL_NAME}\` with no arguments and return its output verbatim.
15344
- Do not call other tools.
15345
- `;
15346
15323
  function createAgyQuotaTool({
15347
15324
  client,
15348
15325
  getAuthResolver,
@@ -15582,12 +15559,6 @@ function splitModelVariant(modelId) {
15582
15559
 
15583
15560
  // src/plugin/quota-summary.ts
15584
15561
  var AGY_QUOTA_SUMMARY_TOOL_NAME = "agy_quota_summary";
15585
- var AGY_V2_QUOTA_SUMMARY_COMMAND = "agy-quota-summary";
15586
- var AGY_V2_QUOTA_SUMMARY_COMMAND_TEMPLATE = `Retrieve Agy Code Assist quota summary (weekly and 5-hour limits by model group) for the current authenticated account.
15587
-
15588
- Immediately call \`${AGY_QUOTA_SUMMARY_TOOL_NAME}\` with no arguments and return its output verbatim.
15589
- Do not call other tools.
15590
- `;
15591
15562
  function createAgyQuotaSummaryTool({
15592
15563
  client,
15593
15564
  getAuthResolver,
@@ -16046,8 +16017,12 @@ var models_default = {
16046
16017
  "gemini-3.6-flash-low",
16047
16018
  "gemini-pro-agent",
16048
16019
  "gemini-3.1-pro-low",
16049
- "claude-sonnet-4-6",
16050
- "claude-opus-4-6-thinking",
16020
+ "claude-opus-5-5-low",
16021
+ "claude-opus-5-5-medium",
16022
+ "claude-opus-5-5-high",
16023
+ "claude-sonnet-5-5-low",
16024
+ "claude-sonnet-5-5-medium",
16025
+ "claude-sonnet-5-5-high",
16051
16026
  "gpt-oss-120b-medium"
16052
16027
  ]
16053
16028
  }
@@ -16072,9 +16047,8 @@ var models_default = {
16072
16047
  }
16073
16048
  },
16074
16049
  experimentIds: [
16075
- 106329237,
16050
+ 106560668,
16076
16051
  106760947,
16077
- 106519115,
16078
16052
  105979552,
16079
16053
  105979574,
16080
16054
  106015333,
@@ -16084,14 +16058,14 @@ var models_default = {
16084
16058
  106123599,
16085
16059
  106121401,
16086
16060
  106100625,
16061
+ 106754391,
16087
16062
  106143956,
16088
16063
  105856899,
16089
16064
  106064030,
16090
- 106106760,
16065
+ 106544525,
16091
16066
  106021688,
16092
16067
  105887299,
16093
16068
  106428370,
16094
- 106283618,
16095
16069
  106640126,
16096
16070
  106380926,
16097
16071
  106281951,
@@ -16100,6 +16074,7 @@ var models_default = {
16100
16074
  106032303,
16101
16075
  106228452,
16102
16076
  106121607,
16077
+ 106793059,
16103
16078
  105979531,
16104
16079
  105979553,
16105
16080
  106015328,
@@ -16110,11 +16085,11 @@ var models_default = {
16110
16085
  106100654,
16111
16086
  106064028,
16112
16087
  105906495,
16113
- 106283614,
16114
16088
  106640124,
16115
16089
  106038164,
16116
16090
  106032301,
16117
- 106121604
16091
+ 106121604,
16092
+ 106793057
16118
16093
  ],
16119
16094
  imageGenerationModelIds: [
16120
16095
  "gemini-3.1-flash-image"
@@ -16152,29 +16127,102 @@ var models_default = {
16152
16127
  supportsEstimateTokenCounter: true,
16153
16128
  toolFormatterType: "TOOL_FORMATTER_TYPE_XML"
16154
16129
  },
16155
- "claude-opus-4-6-thinking": {
16130
+ "claude-opus-5-5-high": {
16156
16131
  apiProvider: "API_PROVIDER_ANTHROPIC_VERTEX",
16157
- displayName: "Claude Opus 4.6 (Thinking)",
16158
- maxOutputTokens: 64e3,
16159
- maxTokens: 25e4,
16160
- model: "MODEL_PLACEHOLDER_M26",
16132
+ displayName: "Claude Opus 5.5 (High)",
16133
+ maxOutputTokens: 128e3,
16134
+ maxTokens: 1e6,
16135
+ model: "MODEL_PLACEHOLDER_M402",
16161
16136
  modelExperiments: {
16162
16137
  experiments: {
16163
16138
  CASCADE_USE_EXPERIMENT_CHECKPOINTER: {
16164
- stringValue: '{\n "strategy": "CHECKPOINT_STRATEGY_UNSPECIFIED",\n "max_token_limit": "160000",\n "token_threshold": "50000",\n "max_overhead_ratio": "0.15",\n "moving_window_size": "1",\n "enabled": true,\n "max_output_tokens": "16384",\n "checkpoint_model": "MODEL_PLACEHOLDER_M50",\n "use_last_planner_model": false,\n "is_sync": false,\n "max_user_requests": 10,\n "include_last_user_message": false,\n "include_conversation_log": true,\n "include_running_task_snapshots": true,\n "include_subagent_snapshots": true,\n "include_artifact_snapshots": true,\n "retry_config": {\n "max_retries": 0,\n "initial_sleep_duration_ms": 1000,\n "exponential_multiplier": 2,\n "include_error_feedback": false\n },\n "session_summary_prompt_override": ""\n}'
16139
+ stringValue: '{\n "strategy": "CHECKPOINT_STRATEGY_SAME_MODEL",\n "max_token_limit": "256000",\n "token_threshold": "50000",\n "max_overhead_ratio": "0.15",\n "moving_window_size": "1",\n "enabled": true,\n "max_output_tokens": "16384",\n "checkpoint_model": "MODEL_PLACEHOLDER_M50",\n "use_last_planner_model": true,\n "is_sync": true,\n "max_user_requests": 10,\n "include_last_user_message": true,\n "include_conversation_log": false,\n "include_running_task_snapshots": true,\n "include_subagent_snapshots": true,\n "include_artifact_snapshots": true,\n "retry_config": {\n "max_retries": 4,\n "initial_sleep_duration_ms": 1000,\n "exponential_multiplier": 2,\n "include_error_feedback": false\n },\n "session_summary_prompt_override": ""\n}'
16165
16140
  },
16166
16141
  retry_model_capacity_exhausted: {
16167
16142
  boolValue: true
16143
+ }
16144
+ }
16145
+ },
16146
+ modelProvider: "MODEL_PROVIDER_ANTHROPIC",
16147
+ quotaInfo: {
16148
+ remainingFraction: 1,
16149
+ resetTime: "2026-10-03T18:28:29Z"
16150
+ },
16151
+ recommended: true,
16152
+ supportedMimeTypes: {
16153
+ "image/heic": true,
16154
+ "image/heif": true,
16155
+ "image/jpeg": true,
16156
+ "image/png": true,
16157
+ "image/webp": true,
16158
+ "video/jpeg2000": true,
16159
+ "video/videoframe/jpeg2000": true
16160
+ },
16161
+ supportsAdaptiveThinking: true,
16162
+ supportsImages: true,
16163
+ supportsThinking: true,
16164
+ tagTitle: "New",
16165
+ thinkingLevel: 3,
16166
+ vertexModelId: "claude-opus-5-5@default"
16167
+ },
16168
+ "claude-opus-5-5-low": {
16169
+ apiProvider: "API_PROVIDER_ANTHROPIC_VERTEX",
16170
+ displayName: "Claude Opus 5.5 (Low)",
16171
+ maxOutputTokens: 128e3,
16172
+ maxTokens: 1e6,
16173
+ model: "MODEL_PLACEHOLDER_M400",
16174
+ modelExperiments: {
16175
+ experiments: {
16176
+ CASCADE_USE_EXPERIMENT_CHECKPOINTER: {
16177
+ stringValue: '{\n "strategy": "CHECKPOINT_STRATEGY_SAME_MODEL",\n "max_token_limit": "256000",\n "token_threshold": "50000",\n "max_overhead_ratio": "0.15",\n "moving_window_size": "1",\n "enabled": true,\n "max_output_tokens": "16384",\n "checkpoint_model": "MODEL_PLACEHOLDER_M50",\n "use_last_planner_model": true,\n "is_sync": true,\n "max_user_requests": 10,\n "include_last_user_message": true,\n "include_conversation_log": false,\n "include_running_task_snapshots": true,\n "include_subagent_snapshots": true,\n "include_artifact_snapshots": true,\n "retry_config": {\n "max_retries": 4,\n "initial_sleep_duration_ms": 1000,\n "exponential_multiplier": 2,\n "include_error_feedback": false\n },\n "session_summary_prompt_override": ""\n}'
16168
16178
  },
16169
- template__system_prompts__planning_mode_artifacts: {
16170
- stringValue: "When in planning mode, you will work with three special artifacts.\n\n# Tasks\nPath: {{ArtifactDirectoryPath}}/task.md\n\n**Purpose**: A TODO list to organize your work during execution. Create this artifact after receiving user approval on your implementation plan. Break down complex tasks into component-level items and track progress as a living document.\n\n**Format**:\n```markdown\n- `[ ]` uncompleted tasks\n- `[/]` in progress tasks (custom notation)\n- `[x]` completed tasks\n- Use indented lists for sub-items\n```\n\n**Updating task.md**: Mark items as `[/]` when starting work on them, and `[x]` when completed. Update task.md as you make progress through your checklist.\n\n# Implementation Plan\nPath: {{ArtifactDirectoryPath}}/implementation_plan.md\n\n**Purpose**: A detailed design document to present your technical implementation plan to the user for feedback and approval.\nAfter reading the document, the user should understand the key technical details of your plan, and be able to make an informed decision on whether to approve it.\n\n**Format**: Use the following format, omitting any irrelevant sections.\n```markdown\n# [Goal Description]\n\nProvide a brief description of the problem, any background context, and what the change accomplishes.\n\n## User Review Required\n\nDocument anything that requires user review or feedback, for example, breaking changes or significant design decisions. Use GitHub alerts (IMPORTANT/WARNING/CAUTION) to highlight critical items.\n\n## Open Questions\n\nAny clarifying or design questions for the user that will impact the implementation plan. Use GitHub alerts (IMPORTANT/WARNING/CAUTION) to highlight critical items.\n\n## Proposed Changes\n\nGroup files by component (e.g., package, feature area, dependency layer) and order logically (dependencies first). Separate components with horizontal rules for visual clarity.\n\n### [Component Name]\n\nSummary of what will change in this component, separated by files. For specific files, Use [NEW] and [DELETE] to demarcate new and deleted files, for example:\n\n#### [MODIFY] [file basename](file:///absolute/path/to/modifiedfile)\n#### [NEW] [file basename](file:///absolute/path/to/newfile)\n#### [DELETE] [file basename](file:///absolute/path/to/deletedfile)\n\n## Verification Plan\n\nSummary of how you will verify that your changes have the desired effects.\n\n### Automated Tests\n- The commands of any automated tests you'll run.\n\n### Manual Verification\n- Asking the user to deploy to staging and testing, verifying UI changes on an iOS app etc.\n```\n\n# Walkthrough\nPath: {{ArtifactDirectoryPath}}/walkthrough.md\n\n**Purpose**: After completing work, summarize what you accomplished. Update an existing walkthrough for related follow-up work rather than creating a new one.\n\n**Document**:\n- Changes made\n- What was tested\n- Validation results\n\nEmbed screenshots and recordings to visually demonstrate UI changes and user flows.\n"
16179
+ retry_model_capacity_exhausted: {
16180
+ boolValue: true
16181
+ }
16182
+ }
16183
+ },
16184
+ modelProvider: "MODEL_PROVIDER_ANTHROPIC",
16185
+ quotaInfo: {
16186
+ remainingFraction: 1,
16187
+ resetTime: "2026-10-03T18:28:29Z"
16188
+ },
16189
+ recommended: true,
16190
+ supportedMimeTypes: {
16191
+ "image/heic": true,
16192
+ "image/heif": true,
16193
+ "image/jpeg": true,
16194
+ "image/png": true,
16195
+ "image/webp": true,
16196
+ "video/jpeg2000": true,
16197
+ "video/videoframe/jpeg2000": true
16198
+ },
16199
+ supportsAdaptiveThinking: true,
16200
+ supportsImages: true,
16201
+ supportsThinking: true,
16202
+ tagTitle: "New",
16203
+ thinkingLevel: 1,
16204
+ vertexModelId: "claude-opus-5-5@default"
16205
+ },
16206
+ "claude-opus-5-5-medium": {
16207
+ apiProvider: "API_PROVIDER_ANTHROPIC_VERTEX",
16208
+ displayName: "Claude Opus 5.5 (Medium)",
16209
+ maxOutputTokens: 128e3,
16210
+ maxTokens: 1e6,
16211
+ model: "MODEL_PLACEHOLDER_M401",
16212
+ modelExperiments: {
16213
+ experiments: {
16214
+ CASCADE_USE_EXPERIMENT_CHECKPOINTER: {
16215
+ stringValue: '{\n "strategy": "CHECKPOINT_STRATEGY_SAME_MODEL",\n "max_token_limit": "256000",\n "token_threshold": "50000",\n "max_overhead_ratio": "0.15",\n "moving_window_size": "1",\n "enabled": true,\n "max_output_tokens": "16384",\n "checkpoint_model": "MODEL_PLACEHOLDER_M50",\n "use_last_planner_model": true,\n "is_sync": true,\n "max_user_requests": 10,\n "include_last_user_message": true,\n "include_conversation_log": false,\n "include_running_task_snapshots": true,\n "include_subagent_snapshots": true,\n "include_artifact_snapshots": true,\n "retry_config": {\n "max_retries": 4,\n "initial_sleep_duration_ms": 1000,\n "exponential_multiplier": 2,\n "include_error_feedback": false\n },\n "session_summary_prompt_override": ""\n}'
16216
+ },
16217
+ retry_model_capacity_exhausted: {
16218
+ boolValue: true
16171
16219
  }
16172
16220
  }
16173
16221
  },
16174
16222
  modelProvider: "MODEL_PROVIDER_ANTHROPIC",
16175
16223
  quotaInfo: {
16176
16224
  remainingFraction: 1,
16177
- resetTime: "2026-09-30T12:45:45Z"
16225
+ resetTime: "2026-10-03T18:28:29Z"
16178
16226
  },
16179
16227
  recommended: true,
16180
16228
  supportedMimeTypes: {
@@ -16186,34 +16234,109 @@ var models_default = {
16186
16234
  "video/jpeg2000": true,
16187
16235
  "video/videoframe/jpeg2000": true
16188
16236
  },
16237
+ supportsAdaptiveThinking: true,
16189
16238
  supportsImages: true,
16190
16239
  supportsThinking: true,
16191
- thinkingBudget: 1024,
16192
- vertexModelId: "claude-opus-4-6@default"
16240
+ tagTitle: "New",
16241
+ thinkingLevel: 2,
16242
+ vertexModelId: "claude-opus-5-5@default"
16193
16243
  },
16194
- "claude-sonnet-4-6": {
16244
+ "claude-sonnet-5-5-high": {
16195
16245
  apiProvider: "API_PROVIDER_ANTHROPIC_VERTEX",
16196
- displayName: "Claude Sonnet 4.6 (Thinking)",
16197
- maxOutputTokens: 64e3,
16198
- maxTokens: 25e4,
16199
- model: "MODEL_PLACEHOLDER_M35",
16246
+ displayName: "Claude Sonnet 5.5 (High)",
16247
+ maxOutputTokens: 128e3,
16248
+ maxTokens: 1e6,
16249
+ model: "MODEL_PLACEHOLDER_M405",
16200
16250
  modelExperiments: {
16201
16251
  experiments: {
16202
16252
  CASCADE_USE_EXPERIMENT_CHECKPOINTER: {
16203
- stringValue: '{\n "strategy": "CHECKPOINT_STRATEGY_UNSPECIFIED",\n "max_token_limit": "160000",\n "token_threshold": "50000",\n "max_overhead_ratio": "0.15",\n "moving_window_size": "1",\n "enabled": true,\n "max_output_tokens": "16384",\n "checkpoint_model": "MODEL_PLACEHOLDER_M50",\n "use_last_planner_model": false,\n "is_sync": false,\n "max_user_requests": 10,\n "include_last_user_message": false,\n "include_conversation_log": true,\n "include_running_task_snapshots": true,\n "include_subagent_snapshots": true,\n "include_artifact_snapshots": true,\n "retry_config": {\n "max_retries": 0,\n "initial_sleep_duration_ms": 1000,\n "exponential_multiplier": 2,\n "include_error_feedback": false\n },\n "session_summary_prompt_override": ""\n}'
16253
+ stringValue: '{\n "strategy": "CHECKPOINT_STRATEGY_SAME_MODEL",\n "max_token_limit": "256000",\n "token_threshold": "50000",\n "max_overhead_ratio": "0.15",\n "moving_window_size": "1",\n "enabled": true,\n "max_output_tokens": "16384",\n "checkpoint_model": "MODEL_PLACEHOLDER_M50",\n "use_last_planner_model": true,\n "is_sync": true,\n "max_user_requests": 10,\n "include_last_user_message": true,\n "include_conversation_log": false,\n "include_running_task_snapshots": true,\n "include_subagent_snapshots": true,\n "include_artifact_snapshots": true,\n "retry_config": {\n "max_retries": 4,\n "initial_sleep_duration_ms": 1000,\n "exponential_multiplier": 2,\n "include_error_feedback": false\n },\n "session_summary_prompt_override": ""\n}'
16204
16254
  },
16205
16255
  retry_model_capacity_exhausted: {
16206
16256
  boolValue: true
16257
+ }
16258
+ }
16259
+ },
16260
+ modelProvider: "MODEL_PROVIDER_ANTHROPIC",
16261
+ quotaInfo: {
16262
+ remainingFraction: 1,
16263
+ resetTime: "2026-10-03T18:28:29Z"
16264
+ },
16265
+ recommended: true,
16266
+ supportedMimeTypes: {
16267
+ "image/heic": true,
16268
+ "image/heif": true,
16269
+ "image/jpeg": true,
16270
+ "image/png": true,
16271
+ "image/webp": true,
16272
+ "video/jpeg2000": true,
16273
+ "video/videoframe/jpeg2000": true
16274
+ },
16275
+ supportsAdaptiveThinking: true,
16276
+ supportsImages: true,
16277
+ supportsThinking: true,
16278
+ tagTitle: "New",
16279
+ thinkingLevel: 3,
16280
+ vertexModelId: "claude-sonnet-5-5@default"
16281
+ },
16282
+ "claude-sonnet-5-5-low": {
16283
+ apiProvider: "API_PROVIDER_ANTHROPIC_VERTEX",
16284
+ displayName: "Claude Sonnet 5.5 (Low)",
16285
+ maxOutputTokens: 128e3,
16286
+ maxTokens: 1e6,
16287
+ model: "MODEL_PLACEHOLDER_M403",
16288
+ modelExperiments: {
16289
+ experiments: {
16290
+ CASCADE_USE_EXPERIMENT_CHECKPOINTER: {
16291
+ stringValue: '{\n "strategy": "CHECKPOINT_STRATEGY_SAME_MODEL",\n "max_token_limit": "256000",\n "token_threshold": "50000",\n "max_overhead_ratio": "0.15",\n "moving_window_size": "1",\n "enabled": true,\n "max_output_tokens": "16384",\n "checkpoint_model": "MODEL_PLACEHOLDER_M50",\n "use_last_planner_model": true,\n "is_sync": true,\n "max_user_requests": 10,\n "include_last_user_message": true,\n "include_conversation_log": false,\n "include_running_task_snapshots": true,\n "include_subagent_snapshots": true,\n "include_artifact_snapshots": true,\n "retry_config": {\n "max_retries": 4,\n "initial_sleep_duration_ms": 1000,\n "exponential_multiplier": 2,\n "include_error_feedback": false\n },\n "session_summary_prompt_override": ""\n}'
16207
16292
  },
16208
- template__system_prompts__planning_mode_artifacts: {
16209
- stringValue: "When in planning mode, you will work with three special artifacts.\n\n# Tasks\nPath: {{ArtifactDirectoryPath}}/task.md\n\n**Purpose**: A TODO list to organize your work during execution. Create this artifact after receiving user approval on your implementation plan. Break down complex tasks into component-level items and track progress as a living document.\n\n**Format**:\n```markdown\n- `[ ]` uncompleted tasks\n- `[/]` in progress tasks (custom notation)\n- `[x]` completed tasks\n- Use indented lists for sub-items\n```\n\n**Updating task.md**: Mark items as `[/]` when starting work on them, and `[x]` when completed. Update task.md as you make progress through your checklist.\n\n# Implementation Plan\nPath: {{ArtifactDirectoryPath}}/implementation_plan.md\n\n**Purpose**: A detailed design document to present your technical implementation plan to the user for feedback and approval.\nAfter reading the document, the user should understand the key technical details of your plan, and be able to make an informed decision on whether to approve it.\n\n**Format**: Use the following format, omitting any irrelevant sections.\n```markdown\n# [Goal Description]\n\nProvide a brief description of the problem, any background context, and what the change accomplishes.\n\n## User Review Required\n\nDocument anything that requires user review or feedback, for example, breaking changes or significant design decisions. Use GitHub alerts (IMPORTANT/WARNING/CAUTION) to highlight critical items.\n\n## Open Questions\n\nAny clarifying or design questions for the user that will impact the implementation plan. Use GitHub alerts (IMPORTANT/WARNING/CAUTION) to highlight critical items.\n\n## Proposed Changes\n\nGroup files by component (e.g., package, feature area, dependency layer) and order logically (dependencies first). Separate components with horizontal rules for visual clarity.\n\n### [Component Name]\n\nSummary of what will change in this component, separated by files. For specific files, Use [NEW] and [DELETE] to demarcate new and deleted files, for example:\n\n#### [MODIFY] [file basename](file:///absolute/path/to/modifiedfile)\n#### [NEW] [file basename](file:///absolute/path/to/newfile)\n#### [DELETE] [file basename](file:///absolute/path/to/deletedfile)\n\n## Verification Plan\n\nSummary of how you will verify that your changes have the desired effects.\n\n### Automated Tests\n- The commands of any automated tests you'll run.\n\n### Manual Verification\n- Asking the user to deploy to staging and testing, verifying UI changes on an iOS app etc.\n```\n\n# Walkthrough\nPath: {{ArtifactDirectoryPath}}/walkthrough.md\n\n**Purpose**: After completing work, summarize what you accomplished. Update an existing walkthrough for related follow-up work rather than creating a new one.\n\n**Document**:\n- Changes made\n- What was tested\n- Validation results\n\nEmbed screenshots and recordings to visually demonstrate UI changes and user flows.\n"
16293
+ retry_model_capacity_exhausted: {
16294
+ boolValue: true
16295
+ }
16296
+ }
16297
+ },
16298
+ modelProvider: "MODEL_PROVIDER_ANTHROPIC",
16299
+ quotaInfo: {
16300
+ remainingFraction: 1,
16301
+ resetTime: "2026-10-03T18:28:29Z"
16302
+ },
16303
+ recommended: true,
16304
+ supportedMimeTypes: {
16305
+ "image/heic": true,
16306
+ "image/heif": true,
16307
+ "image/jpeg": true,
16308
+ "image/png": true,
16309
+ "image/webp": true,
16310
+ "video/jpeg2000": true,
16311
+ "video/videoframe/jpeg2000": true
16312
+ },
16313
+ supportsAdaptiveThinking: true,
16314
+ supportsImages: true,
16315
+ supportsThinking: true,
16316
+ tagTitle: "New",
16317
+ thinkingLevel: 1,
16318
+ vertexModelId: "claude-sonnet-5-5@default"
16319
+ },
16320
+ "claude-sonnet-5-5-medium": {
16321
+ apiProvider: "API_PROVIDER_ANTHROPIC_VERTEX",
16322
+ displayName: "Claude Sonnet 5.5 (Medium)",
16323
+ maxOutputTokens: 128e3,
16324
+ maxTokens: 1e6,
16325
+ model: "MODEL_PLACEHOLDER_M404",
16326
+ modelExperiments: {
16327
+ experiments: {
16328
+ CASCADE_USE_EXPERIMENT_CHECKPOINTER: {
16329
+ stringValue: '{\n "strategy": "CHECKPOINT_STRATEGY_SAME_MODEL",\n "max_token_limit": "256000",\n "token_threshold": "50000",\n "max_overhead_ratio": "0.15",\n "moving_window_size": "1",\n "enabled": true,\n "max_output_tokens": "16384",\n "checkpoint_model": "MODEL_PLACEHOLDER_M50",\n "use_last_planner_model": true,\n "is_sync": true,\n "max_user_requests": 10,\n "include_last_user_message": true,\n "include_conversation_log": false,\n "include_running_task_snapshots": true,\n "include_subagent_snapshots": true,\n "include_artifact_snapshots": true,\n "retry_config": {\n "max_retries": 4,\n "initial_sleep_duration_ms": 1000,\n "exponential_multiplier": 2,\n "include_error_feedback": false\n },\n "session_summary_prompt_override": ""\n}'
16330
+ },
16331
+ retry_model_capacity_exhausted: {
16332
+ boolValue: true
16210
16333
  }
16211
16334
  }
16212
16335
  },
16213
16336
  modelProvider: "MODEL_PROVIDER_ANTHROPIC",
16214
16337
  quotaInfo: {
16215
16338
  remainingFraction: 1,
16216
- resetTime: "2026-09-30T12:45:45Z"
16339
+ resetTime: "2026-10-03T18:28:29Z"
16217
16340
  },
16218
16341
  recommended: true,
16219
16342
  supportedMimeTypes: {
@@ -16225,10 +16348,12 @@ var models_default = {
16225
16348
  "video/jpeg2000": true,
16226
16349
  "video/videoframe/jpeg2000": true
16227
16350
  },
16351
+ supportsAdaptiveThinking: true,
16228
16352
  supportsImages: true,
16229
16353
  supportsThinking: true,
16230
- thinkingBudget: 1024,
16231
- vertexModelId: "claude-sonnet-4-6@default"
16354
+ tagTitle: "New",
16355
+ thinkingLevel: 2,
16356
+ vertexModelId: "claude-sonnet-5-5@default"
16232
16357
  },
16233
16358
  "gemini-2.5-flash": {
16234
16359
  apiProvider: "API_PROVIDER_GOOGLE_GEMINI",
@@ -16249,8 +16374,8 @@ var models_default = {
16249
16374
  },
16250
16375
  modelProvider: "MODEL_PROVIDER_GOOGLE",
16251
16376
  quotaInfo: {
16252
- remainingFraction: 0.9673149,
16253
- resetTime: "2026-09-30T12:41:07Z"
16377
+ remainingFraction: 0.9911344,
16378
+ resetTime: "2026-10-03T16:28:30Z"
16254
16379
  },
16255
16380
  recommended: true,
16256
16381
  supportedMimeTypes: {
@@ -16311,7 +16436,7 @@ var models_default = {
16311
16436
  supportsVideo: true,
16312
16437
  tagDescription: "gemini-3.5-flash-lite",
16313
16438
  thinkingBudget: -1,
16314
- thinkingLevel: 3
16439
+ thinkingLevel: 1
16315
16440
  },
16316
16441
  "gemini-2.5-flash-lite": {
16317
16442
  apiProvider: "API_PROVIDER_GOOGLE_GEMINI",
@@ -16332,8 +16457,8 @@ var models_default = {
16332
16457
  },
16333
16458
  modelProvider: "MODEL_PROVIDER_GOOGLE",
16334
16459
  quotaInfo: {
16335
- remainingFraction: 0.9673149,
16336
- resetTime: "2026-09-30T12:41:07Z"
16460
+ remainingFraction: 0.9911344,
16461
+ resetTime: "2026-10-03T16:28:30Z"
16337
16462
  },
16338
16463
  recommended: true,
16339
16464
  supportedMimeTypes: {
@@ -16394,7 +16519,7 @@ var models_default = {
16394
16519
  supportsVideo: true,
16395
16520
  tagDescription: "gemini-3.5-flash-lite",
16396
16521
  thinkingBudget: -1,
16397
- thinkingLevel: 3
16522
+ thinkingLevel: 1
16398
16523
  },
16399
16524
  "gemini-2.5-flash-thinking": {
16400
16525
  apiProvider: "API_PROVIDER_GOOGLE_GEMINI",
@@ -16415,8 +16540,8 @@ var models_default = {
16415
16540
  },
16416
16541
  modelProvider: "MODEL_PROVIDER_GOOGLE",
16417
16542
  quotaInfo: {
16418
- remainingFraction: 0.9673149,
16419
- resetTime: "2026-09-30T12:41:07Z"
16543
+ remainingFraction: 0.9911344,
16544
+ resetTime: "2026-10-03T16:28:30Z"
16420
16545
  },
16421
16546
  recommended: true,
16422
16547
  supportedMimeTypes: {
@@ -16477,7 +16602,7 @@ var models_default = {
16477
16602
  supportsVideo: true,
16478
16603
  tagDescription: "gemini-3.5-flash-lite",
16479
16604
  thinkingBudget: -1,
16480
- thinkingLevel: 3
16605
+ thinkingLevel: 1
16481
16606
  },
16482
16607
  "gemini-2.5-pro": {
16483
16608
  apiProvider: "API_PROVIDER_GOOGLE_GEMINI",
@@ -16495,8 +16620,8 @@ var models_default = {
16495
16620
  },
16496
16621
  modelProvider: "MODEL_PROVIDER_GOOGLE",
16497
16622
  quotaInfo: {
16498
- remainingFraction: 0.9673149,
16499
- resetTime: "2026-09-30T12:41:07Z"
16623
+ remainingFraction: 0.9911344,
16624
+ resetTime: "2026-10-03T16:28:30Z"
16500
16625
  },
16501
16626
  recommended: true,
16502
16627
  requiresImageOutputOutsideFunctionResponses: true,
@@ -16576,8 +16701,8 @@ var models_default = {
16576
16701
  },
16577
16702
  modelProvider: "MODEL_PROVIDER_GOOGLE",
16578
16703
  quotaInfo: {
16579
- remainingFraction: 0.9673149,
16580
- resetTime: "2026-09-30T12:41:07Z"
16704
+ remainingFraction: 0.9911344,
16705
+ resetTime: "2026-10-03T16:28:30Z"
16581
16706
  },
16582
16707
  recommended: true,
16583
16708
  supportedMimeTypes: {
@@ -16681,8 +16806,8 @@ var models_default = {
16681
16806
  },
16682
16807
  modelProvider: "MODEL_PROVIDER_GOOGLE",
16683
16808
  quotaInfo: {
16684
- remainingFraction: 0.9673149,
16685
- resetTime: "2026-09-30T12:41:07Z"
16809
+ remainingFraction: 0.9911344,
16810
+ resetTime: "2026-10-03T16:28:30Z"
16686
16811
  },
16687
16812
  recommended: true,
16688
16813
  supportedMimeTypes: {
@@ -16751,8 +16876,8 @@ var models_default = {
16751
16876
  model: "MODEL_PLACEHOLDER_M21",
16752
16877
  modelProvider: "MODEL_PROVIDER_GOOGLE",
16753
16878
  quotaInfo: {
16754
- remainingFraction: 0.9673149,
16755
- resetTime: "2026-09-30T12:41:07Z"
16879
+ remainingFraction: 0.9911344,
16880
+ resetTime: "2026-10-03T16:28:30Z"
16756
16881
  }
16757
16882
  },
16758
16883
  "gemini-3.1-flash-lite": {
@@ -16770,8 +16895,8 @@ var models_default = {
16770
16895
  },
16771
16896
  modelProvider: "MODEL_PROVIDER_GOOGLE",
16772
16897
  quotaInfo: {
16773
- remainingFraction: 0.9673149,
16774
- resetTime: "2026-09-30T12:41:07Z"
16898
+ remainingFraction: 0.9911344,
16899
+ resetTime: "2026-10-03T16:28:30Z"
16775
16900
  }
16776
16901
  },
16777
16902
  "gemini-3.1-pro-high": {
@@ -16802,8 +16927,8 @@ var models_default = {
16802
16927
  },
16803
16928
  modelProvider: "MODEL_PROVIDER_GOOGLE",
16804
16929
  quotaInfo: {
16805
- remainingFraction: 0.9673149,
16806
- resetTime: "2026-09-30T12:41:07Z"
16930
+ remainingFraction: 0.9911344,
16931
+ resetTime: "2026-10-03T16:28:30Z"
16807
16932
  },
16808
16933
  recommended: true,
16809
16934
  supportedMimeTypes: {
@@ -16893,8 +17018,8 @@ var models_default = {
16893
17018
  },
16894
17019
  modelProvider: "MODEL_PROVIDER_GOOGLE",
16895
17020
  quotaInfo: {
16896
- remainingFraction: 0.9673149,
16897
- resetTime: "2026-09-30T12:41:07Z"
17021
+ remainingFraction: 0.9911344,
17022
+ resetTime: "2026-10-03T16:28:30Z"
16898
17023
  },
16899
17024
  recommended: true,
16900
17025
  supportedMimeTypes: {
@@ -16998,8 +17123,8 @@ var models_default = {
16998
17123
  },
16999
17124
  modelProvider: "MODEL_PROVIDER_GOOGLE",
17000
17125
  quotaInfo: {
17001
- remainingFraction: 0.9673149,
17002
- resetTime: "2026-09-30T12:41:07Z"
17126
+ remainingFraction: 0.9911344,
17127
+ resetTime: "2026-10-03T16:28:30Z"
17003
17128
  },
17004
17129
  recommended: true,
17005
17130
  supportedMimeTypes: {
@@ -17081,8 +17206,8 @@ var models_default = {
17081
17206
  },
17082
17207
  modelProvider: "MODEL_PROVIDER_GOOGLE",
17083
17208
  quotaInfo: {
17084
- remainingFraction: 0.9673149,
17085
- resetTime: "2026-09-30T12:41:07Z"
17209
+ remainingFraction: 0.9911344,
17210
+ resetTime: "2026-10-03T16:28:30Z"
17086
17211
  },
17087
17212
  recommended: true,
17088
17213
  supportedMimeTypes: {
@@ -17143,7 +17268,7 @@ var models_default = {
17143
17268
  supportsVideo: true,
17144
17269
  tagDescription: "gemini-3.5-flash-lite",
17145
17270
  thinkingBudget: -1,
17146
- thinkingLevel: 3
17271
+ thinkingLevel: 1
17147
17272
  },
17148
17273
  "gemini-3.5-flash-low": {
17149
17274
  apiProvider: "API_PROVIDER_GOOGLE_GEMINI",
@@ -17188,8 +17313,8 @@ var models_default = {
17188
17313
  },
17189
17314
  modelProvider: "MODEL_PROVIDER_GOOGLE",
17190
17315
  quotaInfo: {
17191
- remainingFraction: 0.9673149,
17192
- resetTime: "2026-09-30T12:41:07Z"
17316
+ remainingFraction: 0.9911344,
17317
+ resetTime: "2026-10-03T16:28:30Z"
17193
17318
  },
17194
17319
  recommended: true,
17195
17320
  supportedMimeTypes: {
@@ -17307,8 +17432,8 @@ var models_default = {
17307
17432
  },
17308
17433
  modelProvider: "MODEL_PROVIDER_GOOGLE",
17309
17434
  quotaInfo: {
17310
- remainingFraction: 0.9673149,
17311
- resetTime: "2026-09-30T12:41:07Z"
17435
+ remainingFraction: 0.9911344,
17436
+ resetTime: "2026-10-03T16:28:30Z"
17312
17437
  },
17313
17438
  recommended: true,
17314
17439
  supportedMimeTypes: {
@@ -17426,8 +17551,8 @@ var models_default = {
17426
17551
  },
17427
17552
  modelProvider: "MODEL_PROVIDER_GOOGLE",
17428
17553
  quotaInfo: {
17429
- remainingFraction: 0.9673149,
17430
- resetTime: "2026-09-30T12:41:07Z"
17554
+ remainingFraction: 0.9911344,
17555
+ resetTime: "2026-10-03T16:28:30Z"
17431
17556
  },
17432
17557
  recommended: true,
17433
17558
  supportedMimeTypes: {
@@ -17545,8 +17670,8 @@ var models_default = {
17545
17670
  },
17546
17671
  modelProvider: "MODEL_PROVIDER_GOOGLE",
17547
17672
  quotaInfo: {
17548
- remainingFraction: 0.9673149,
17549
- resetTime: "2026-09-30T12:41:07Z"
17673
+ remainingFraction: 0.9911344,
17674
+ resetTime: "2026-10-03T16:28:30Z"
17550
17675
  },
17551
17676
  recommended: true,
17552
17677
  supportedMimeTypes: {
@@ -17663,8 +17788,8 @@ var models_default = {
17663
17788
  },
17664
17789
  modelProvider: "MODEL_PROVIDER_GOOGLE",
17665
17790
  quotaInfo: {
17666
- remainingFraction: 0.9673149,
17667
- resetTime: "2026-09-30T12:41:07Z"
17791
+ remainingFraction: 0.9911344,
17792
+ resetTime: "2026-10-03T16:28:30Z"
17668
17793
  },
17669
17794
  recommended: true,
17670
17795
  supportedMimeTypes: {
@@ -17774,8 +17899,8 @@ var models_default = {
17774
17899
  },
17775
17900
  modelProvider: "MODEL_PROVIDER_GOOGLE",
17776
17901
  quotaInfo: {
17777
- remainingFraction: 0.9673149,
17778
- resetTime: "2026-09-30T12:41:07Z"
17902
+ remainingFraction: 0.9911344,
17903
+ resetTime: "2026-10-03T16:28:30Z"
17779
17904
  },
17780
17905
  recommended: true,
17781
17906
  supportedMimeTypes: {
@@ -17887,8 +18012,8 @@ var models_default = {
17887
18012
  },
17888
18013
  modelProvider: "MODEL_PROVIDER_GOOGLE",
17889
18014
  quotaInfo: {
17890
- remainingFraction: 0.9673149,
17891
- resetTime: "2026-09-30T12:41:07Z"
18015
+ remainingFraction: 0.9911344,
18016
+ resetTime: "2026-10-03T16:28:30Z"
17892
18017
  },
17893
18018
  recommended: true,
17894
18019
  supportedMimeTypes: {
@@ -18000,8 +18125,8 @@ var models_default = {
18000
18125
  },
18001
18126
  modelProvider: "MODEL_PROVIDER_GOOGLE",
18002
18127
  quotaInfo: {
18003
- remainingFraction: 0.9673149,
18004
- resetTime: "2026-09-30T12:41:07Z"
18128
+ remainingFraction: 0.9911344,
18129
+ resetTime: "2026-10-03T16:28:30Z"
18005
18130
  },
18006
18131
  recommended: true,
18007
18132
  supportedMimeTypes: {
@@ -18112,8 +18237,8 @@ var models_default = {
18112
18237
  },
18113
18238
  modelProvider: "MODEL_PROVIDER_GOOGLE",
18114
18239
  quotaInfo: {
18115
- remainingFraction: 0.9673149,
18116
- resetTime: "2026-09-30T12:41:07Z"
18240
+ remainingFraction: 0.9911344,
18241
+ resetTime: "2026-10-03T16:28:30Z"
18117
18242
  },
18118
18243
  recommended: true,
18119
18244
  supportedMimeTypes: {
@@ -18223,8 +18348,8 @@ var models_default = {
18223
18348
  },
18224
18349
  modelProvider: "MODEL_PROVIDER_GOOGLE",
18225
18350
  quotaInfo: {
18226
- remainingFraction: 0.9673149,
18227
- resetTime: "2026-09-30T12:41:07Z"
18351
+ remainingFraction: 0.9911344,
18352
+ resetTime: "2026-10-03T16:28:30Z"
18228
18353
  },
18229
18354
  recommended: true,
18230
18355
  supportedMimeTypes: {
@@ -18336,8 +18461,8 @@ var models_default = {
18336
18461
  },
18337
18462
  modelProvider: "MODEL_PROVIDER_GOOGLE",
18338
18463
  quotaInfo: {
18339
- remainingFraction: 0.9673149,
18340
- resetTime: "2026-09-30T12:41:07Z"
18464
+ remainingFraction: 0.9911344,
18465
+ resetTime: "2026-10-03T16:28:30Z"
18341
18466
  },
18342
18467
  recommended: true,
18343
18468
  supportedMimeTypes: {
@@ -18449,8 +18574,8 @@ var models_default = {
18449
18574
  },
18450
18575
  modelProvider: "MODEL_PROVIDER_GOOGLE",
18451
18576
  quotaInfo: {
18452
- remainingFraction: 0.9673149,
18453
- resetTime: "2026-09-30T12:41:07Z"
18577
+ remainingFraction: 0.9911344,
18578
+ resetTime: "2026-10-03T16:28:30Z"
18454
18579
  },
18455
18580
  recommended: true,
18456
18581
  supportedMimeTypes: {
@@ -18561,8 +18686,8 @@ var models_default = {
18561
18686
  },
18562
18687
  modelProvider: "MODEL_PROVIDER_GOOGLE",
18563
18688
  quotaInfo: {
18564
- remainingFraction: 0.9673149,
18565
- resetTime: "2026-09-30T12:41:07Z"
18689
+ remainingFraction: 0.9911344,
18690
+ resetTime: "2026-10-03T16:28:30Z"
18566
18691
  },
18567
18692
  recommended: true,
18568
18693
  supportedMimeTypes: {
@@ -18651,8 +18776,8 @@ var models_default = {
18651
18776
  },
18652
18777
  modelProvider: "MODEL_PROVIDER_GOOGLE",
18653
18778
  quotaInfo: {
18654
- remainingFraction: 0.9673149,
18655
- resetTime: "2026-09-30T12:41:07Z"
18779
+ remainingFraction: 0.9911344,
18780
+ resetTime: "2026-10-03T16:28:30Z"
18656
18781
  },
18657
18782
  recommended: true,
18658
18783
  supportedMimeTypes: {
@@ -18729,10 +18854,12 @@ var models_default = {
18729
18854
  modelProvider: "MODEL_PROVIDER_OPENAI",
18730
18855
  quotaInfo: {
18731
18856
  remainingFraction: 1,
18732
- resetTime: "2026-09-30T12:45:45Z"
18857
+ resetTime: "2026-10-03T18:28:29Z"
18733
18858
  },
18734
18859
  recommended: true,
18735
18860
  supportsThinking: true,
18861
+ tagDescription: "GPT-OSS will be removed from Antigravity on November 2, 2026.",
18862
+ tagTitle: "Notice",
18736
18863
  thinkingBudget: 8192,
18737
18864
  vertexModelId: "openai/gpt-oss-120b-maas"
18738
18865
  },
@@ -19801,14 +19928,9 @@ function normalizeToolSchemaTypes(tools, toolMapper) {
19801
19928
  fn.name = toolMapper ? toolMapper.toGemini(fn.name) : sanitizeToolName(fn.name);
19802
19929
  }
19803
19930
  if (fn) {
19804
- if (!fn.parameters) {
19805
- fn.parameters = fn.parameters_json_schema ?? fn.parametersJsonSchema;
19806
- }
19807
19931
  if (!fn.parameters) {
19808
19932
  fn.parameters = { type: "OBJECT", properties: {} };
19809
19933
  }
19810
- delete fn.parameters_json_schema;
19811
- delete fn.parametersJsonSchema;
19812
19934
  sanitizeSchema(fn.parameters);
19813
19935
  }
19814
19936
  }
@@ -20233,81 +20355,22 @@ var ChatLoggerImpl = class {
20233
20355
  }
20234
20356
  };
20235
20357
 
20236
- // src/plugin/headers.ts
20237
- function getSafeHeader(headers, key) {
20238
- if (!headers) {
20239
- return void 0;
20240
- }
20241
- const targetKey = key.toLowerCase();
20242
- if (typeof headers.get === "function") {
20243
- try {
20244
- return headers.get(targetKey) || void 0;
20245
- } catch {
20246
- }
20247
- }
20248
- if (Array.isArray(headers)) {
20249
- const found = headers.find((item) => {
20250
- if (Array.isArray(item) && typeof item[0] === "string") {
20251
- return item[0].toLowerCase() === targetKey;
20252
- }
20253
- return false;
20254
- });
20255
- return found ? String(found[1]) : void 0;
20256
- }
20257
- if (typeof headers === "object") {
20258
- const foundKey = Object.keys(headers).find((k) => k.toLowerCase() === targetKey);
20259
- return foundKey ? headers[foundKey] !== void 0 ? String(headers[foundKey]) : void 0 : void 0;
20260
- }
20261
- return void 0;
20262
- }
20263
- function setSafeHeaders(initHeaders, newHeaders) {
20264
- if (typeof globalThis.Headers !== "undefined") {
20265
- const headers = new globalThis.Headers(initHeaders ?? {});
20266
- for (const [k, v] of Object.entries(newHeaders)) {
20267
- headers.set(k, v);
20268
- }
20269
- return headers;
20270
- }
20271
- if (Array.isArray(initHeaders)) {
20272
- const nextHeaders2 = [...initHeaders];
20273
- for (const [k, v] of Object.entries(newHeaders)) {
20274
- const idx = nextHeaders2.findIndex((item) => Array.isArray(item) && typeof item[0] === "string" && item[0].toLowerCase() === k.toLowerCase());
20275
- if (idx !== -1) {
20276
- nextHeaders2[idx] = [k, v];
20277
- } else {
20278
- nextHeaders2.push([k, v]);
20279
- }
20280
- }
20281
- return nextHeaders2;
20282
- }
20283
- const nextHeaders = {};
20284
- if (initHeaders && typeof initHeaders === "object") {
20285
- for (const [k, v] of Object.entries(initHeaders)) {
20286
- nextHeaders[k] = String(v);
20287
- }
20288
- }
20289
- for (const [k, v] of Object.entries(newHeaders)) {
20290
- const existingKey = Object.keys(nextHeaders).find((key) => key.toLowerCase() === k.toLowerCase());
20291
- if (existingKey) {
20292
- nextHeaders[existingKey] = v;
20293
- } else {
20294
- nextHeaders[k] = v;
20295
- }
20296
- }
20297
- return nextHeaders;
20298
- }
20299
- function toUrlString(value) {
20300
- if (typeof value === "string") {
20301
- return value;
20302
- }
20303
- const candidate = value.url;
20304
- if (candidate) {
20305
- return candidate;
20306
- }
20307
- return value.toString();
20308
- }
20358
+ // src/plugin.ts
20359
+ var AGY_QUOTA_COMMAND = "agyquota";
20360
+ var AGY_QUOTA_COMMAND_TEMPLATE = `Retrieve Agy Code Assist quota usage for the current authenticated account.
20361
+
20362
+ Immediately call \`${AGY_QUOTA_TOOL_NAME}\` with no arguments and return its output verbatim.
20363
+ Do not call other tools.
20364
+ `;
20365
+ var AGY_QUOTA_SUMMARY_COMMAND = "agyquotasummary";
20366
+ var AGY_QUOTA_SUMMARY_COMMAND_TEMPLATE = `Retrieve Agy Code Assist quota summary (weekly and 5-hour limits by model group) for the current authenticated account.
20309
20367
 
20310
- // src/plugin/tier.ts
20368
+ Immediately call \`${AGY_QUOTA_SUMMARY_TOOL_NAME}\` with no arguments and return its output verbatim.
20369
+ Do not call other tools.
20370
+ `;
20371
+ var latestAgyAuthResolver;
20372
+ var latestAgyConfiguredProjectId;
20373
+ var latestAgyUserAgentModel;
20311
20374
  var STATIC_MODELS_SIMPLE = {
20312
20375
  "gemini-3.8-flash": {
20313
20376
  name: "Gemini 3.8 Flash",
@@ -20345,20 +20408,20 @@ var STATIC_MODELS_SIMPLE = {
20345
20408
  reasoning: true,
20346
20409
  attachment: true
20347
20410
  },
20348
- "claude-sonnet-4-6": {
20349
- name: "Claude Sonnet 4.6 (Thinking)",
20350
- description: "Claude Sonnet 4.6 deep reasoning model, perfectly balancing thinking process, processing speed, and output quality.",
20351
- maxTokens: 25e4,
20352
- maxOutputTokens: 64e3,
20411
+ "claude-opus-5-5": {
20412
+ name: "Claude Opus 5.5",
20413
+ description: "Claude Opus 5.5 deep reasoning model. Select tier at runtime.",
20414
+ maxTokens: 1e6,
20415
+ maxOutputTokens: 128e3,
20353
20416
  toolCall: true,
20354
20417
  reasoning: true,
20355
20418
  attachment: true
20356
20419
  },
20357
- "claude-opus-4-6-thinking": {
20358
- name: "Claude Opus 4.6 (Thinking)",
20359
- description: "Claude Opus 4.6 deep reasoning model, built-in chain of thought, highly suitable for top-tier algorithm and logic puzzles.",
20360
- maxTokens: 25e4,
20361
- maxOutputTokens: 64e3,
20420
+ "claude-sonnet-5-5": {
20421
+ name: "Claude Sonnet 5.5",
20422
+ description: "Claude Sonnet 5.5 deep reasoning model. Select tier at runtime.",
20423
+ maxTokens: 1e6,
20424
+ maxOutputTokens: 128e3,
20362
20425
  toolCall: true,
20363
20426
  reasoning: true,
20364
20427
  attachment: true
@@ -20393,41 +20456,18 @@ var TIER_MAPPING = {
20393
20456
  "gemini-3.1-pro": {
20394
20457
  low: "gemini-3.1-pro-low",
20395
20458
  high: "gemini-3.1-pro-high"
20459
+ },
20460
+ "claude-opus-5-5": {
20461
+ low: "claude-opus-5-5-low",
20462
+ medium: "claude-opus-5-5-medium",
20463
+ high: "claude-opus-5-5-high"
20464
+ },
20465
+ "claude-sonnet-5-5": {
20466
+ low: "claude-sonnet-5-5-low",
20467
+ medium: "claude-sonnet-5-5-medium",
20468
+ high: "claude-sonnet-5-5-high"
20396
20469
  }
20397
20470
  };
20398
- function resolveModelTier(baseModelId, headersOrInit) {
20399
- const parts = baseModelId.split("@");
20400
- const base = parts[0] || "";
20401
- const suffixTier = parts[1]?.toLowerCase();
20402
- const mapping = TIER_MAPPING[base];
20403
- if (!mapping) {
20404
- return baseModelId;
20405
- }
20406
- const rawHeaders = headersOrInit && typeof headersOrInit === "object" && "headers" in headersOrInit ? headersOrInit.headers : headersOrInit;
20407
- const headerTier = getSafeHeader(rawHeaders, "x-agy-tier")?.toLowerCase() || null;
20408
- const requestedTier = headerTier || suffixTier;
20409
- if (requestedTier && Object.prototype.hasOwnProperty.call(mapping, requestedTier)) {
20410
- return mapping[requestedTier] || baseModelId;
20411
- }
20412
- return mapping["medium"] ?? mapping["high"] ?? baseModelId;
20413
- }
20414
-
20415
- // src/plugin.ts
20416
- var AGY_QUOTA_COMMAND = "agyquota";
20417
- var AGY_QUOTA_COMMAND_TEMPLATE = `Retrieve Agy Code Assist quota usage for the current authenticated account.
20418
-
20419
- Immediately call \`${AGY_QUOTA_TOOL_NAME}\` with no arguments and return its output verbatim.
20420
- Do not call other tools.
20421
- `;
20422
- var AGY_QUOTA_SUMMARY_COMMAND = "agyquotasummary";
20423
- var AGY_QUOTA_SUMMARY_COMMAND_TEMPLATE = `Retrieve Agy Code Assist quota summary (weekly and 5-hour limits by model group) for the current authenticated account.
20424
-
20425
- Immediately call \`${AGY_QUOTA_SUMMARY_TOOL_NAME}\` with no arguments and return its output verbatim.
20426
- Do not call other tools.
20427
- `;
20428
- var latestAgyAuthResolver;
20429
- var latestAgyConfiguredProjectId;
20430
- var latestAgyUserAgentModel;
20431
20471
  var buildModelFromSimple = (modelId, simple) => {
20432
20472
  const isClaude = modelId.startsWith("claude-");
20433
20473
  const isGpt = modelId.startsWith("gpt-");
@@ -20521,10 +20561,87 @@ var STATIC_MODELS = {};
20521
20561
  for (const [modelId, simple] of Object.entries(STATIC_MODELS_SIMPLE)) {
20522
20562
  STATIC_MODELS[modelId] = buildModelFromSimple(modelId, simple);
20523
20563
  }
20524
- var AgyCLIOAuthPlugin = async ({ client }) => {
20525
- let latestConfig;
20526
- updateStaticModelsWithPricing(STATIC_MODELS);
20527
- const getModelsList = (provider) => {
20564
+ function getSafeHeader(headers, key) {
20565
+ if (!headers) {
20566
+ return void 0;
20567
+ }
20568
+ const targetKey = key.toLowerCase();
20569
+ if (typeof headers.get === "function") {
20570
+ try {
20571
+ return headers.get(targetKey) || void 0;
20572
+ } catch {
20573
+ }
20574
+ }
20575
+ if (Array.isArray(headers)) {
20576
+ const found = headers.find((item) => {
20577
+ if (Array.isArray(item) && typeof item[0] === "string") {
20578
+ return item[0].toLowerCase() === targetKey;
20579
+ }
20580
+ return false;
20581
+ });
20582
+ return found ? String(found[1]) : void 0;
20583
+ }
20584
+ if (typeof headers === "object") {
20585
+ const foundKey = Object.keys(headers).find((k) => k.toLowerCase() === targetKey);
20586
+ return foundKey ? headers[foundKey] !== void 0 ? String(headers[foundKey]) : void 0 : void 0;
20587
+ }
20588
+ return void 0;
20589
+ }
20590
+ function setSafeHeaders(initHeaders, newHeaders) {
20591
+ if (typeof globalThis.Headers !== "undefined") {
20592
+ const headers = new globalThis.Headers(initHeaders ?? {});
20593
+ for (const [k, v] of Object.entries(newHeaders)) {
20594
+ headers.set(k, v);
20595
+ }
20596
+ return headers;
20597
+ }
20598
+ if (Array.isArray(initHeaders)) {
20599
+ const nextHeaders2 = [...initHeaders];
20600
+ for (const [k, v] of Object.entries(newHeaders)) {
20601
+ const idx = nextHeaders2.findIndex((item) => Array.isArray(item) && typeof item[0] === "string" && item[0].toLowerCase() === k.toLowerCase());
20602
+ if (idx !== -1) {
20603
+ nextHeaders2[idx] = [k, v];
20604
+ } else {
20605
+ nextHeaders2.push([k, v]);
20606
+ }
20607
+ }
20608
+ return nextHeaders2;
20609
+ }
20610
+ const nextHeaders = {};
20611
+ if (initHeaders && typeof initHeaders === "object") {
20612
+ for (const [k, v] of Object.entries(initHeaders)) {
20613
+ nextHeaders[k] = String(v);
20614
+ }
20615
+ }
20616
+ for (const [k, v] of Object.entries(newHeaders)) {
20617
+ const existingKey = Object.keys(nextHeaders).find((key) => key.toLowerCase() === k.toLowerCase());
20618
+ if (existingKey) {
20619
+ nextHeaders[existingKey] = v;
20620
+ } else {
20621
+ nextHeaders[k] = v;
20622
+ }
20623
+ }
20624
+ return nextHeaders;
20625
+ }
20626
+ function resolveModelTier(baseModelId, init) {
20627
+ const parts = baseModelId.split("@");
20628
+ const base = parts[0] || "";
20629
+ const suffixTier = parts[1]?.toLowerCase();
20630
+ const mapping = TIER_MAPPING[base];
20631
+ if (!mapping) {
20632
+ return baseModelId;
20633
+ }
20634
+ const headerTier = getSafeHeader(init?.headers, "x-agy-tier")?.toLowerCase() || null;
20635
+ const requestedTier = headerTier || suffixTier;
20636
+ if (requestedTier && Object.prototype.hasOwnProperty.call(mapping, requestedTier)) {
20637
+ return mapping[requestedTier] || baseModelId;
20638
+ }
20639
+ return mapping["medium"] ?? mapping["high"];
20640
+ }
20641
+ var AgyCLIOAuthPlugin = async ({ client }) => {
20642
+ let latestConfig;
20643
+ updateStaticModelsWithPricing(STATIC_MODELS);
20644
+ const getModelsList = (provider) => {
20528
20645
  const userModels = provider.models || {};
20529
20646
  const clonedStaticModels = JSON.parse(JSON.stringify(STATIC_MODELS));
20530
20647
  const strictModels = {};
@@ -20848,782 +20965,25 @@ async function ensureProjectContextOrThrow(authRecord, client, configuredProject
20848
20965
  throw error45;
20849
20966
  }
20850
20967
  }
20851
-
20852
- // src/plugin/types.ts
20853
- function defineOpenCodeV2Plugin(def) {
20854
- return def;
20855
- }
20856
-
20857
- // src/plugin/v2-storage.ts
20858
- import { closeSync, existsSync as existsSync6, mkdirSync as mkdirSync5, openSync, readFileSync as readFileSync5, renameSync as renameSync4, unlinkSync as unlinkSync4, writeFileSync as writeFileSync5 } from "fs";
20859
- import { randomUUID as randomUUID4 } from "crypto";
20860
- import { homedir as homedir4 } from "os";
20861
- import { join as join6 } from "path";
20862
- var storedAuthOverrideForTesting = void 0;
20863
- function loadStoredAuthFromJson() {
20864
- if (storedAuthOverrideForTesting !== void 0) {
20865
- return storedAuthOverrideForTesting;
20866
- }
20867
- const authPath = join6(homedir4(), ".local", "share", "opencode", "auth.json");
20868
- try {
20869
- if (existsSync6(authPath)) {
20870
- const content = readFileSync5(authPath, "utf8");
20871
- const data = JSON.parse(content);
20872
- return data?.[AGY_PROVIDER_ID];
20873
- }
20874
- } catch {
20875
- }
20876
- return void 0;
20877
- }
20878
- function saveStoredAuthToJson(authRecord) {
20879
- if (process.env.NODE_ENV === "test" || process.env.VITEST || storedAuthOverrideForTesting !== void 0) {
20880
- return;
20881
- }
20882
- const dirPath = join6(homedir4(), ".local", "share", "opencode");
20883
- if (!existsSync6(dirPath)) {
20884
- mkdirSync5(dirPath, { recursive: true });
20885
- }
20886
- const authPath = join6(dirPath, "auth.json");
20887
- const data = existsSync6(authPath) ? JSON.parse(readFileSync5(authPath, "utf8")) : {};
20888
- data[AGY_PROVIDER_ID] = {
20889
- type: "oauth",
20890
- refresh: authRecord.refresh,
20891
- access: authRecord.access,
20892
- expires: authRecord.expires
20893
- };
20894
- const tempPath = `${authPath}.${process.pid}.${randomUUID4()}.tmp`;
20895
- let tempFileDescriptor;
20896
- let ownsTempFile = false;
20897
- try {
20898
- tempFileDescriptor = openSync(tempPath, "wx", 384);
20899
- ownsTempFile = true;
20900
- writeFileSync5(tempFileDescriptor, JSON.stringify(data, null, 2), {
20901
- encoding: "utf8"
20902
- });
20903
- closeSync(tempFileDescriptor);
20904
- tempFileDescriptor = void 0;
20905
- renameSync4(tempPath, authPath);
20906
- } catch (error45) {
20907
- if (tempFileDescriptor !== void 0) {
20908
- try {
20909
- closeSync(tempFileDescriptor);
20910
- } catch {
20911
- }
20912
- }
20913
- if (ownsTempFile) {
20914
- try {
20915
- unlinkSync4(tempPath);
20916
- } catch {
20917
- }
20918
- }
20919
- throw error45;
20920
- }
20921
- }
20922
-
20923
- // src/plugin/v2-fetch.ts
20924
- function createV2FetchInterceptor(getAuthSnapshot) {
20925
- return async function agyV2Fetch(input, init) {
20926
- const isGL = isGenerativeLanguageRequest(input);
20927
- const isInternal = toUrlString(input).includes("cloudcode-pa.googleapis.com");
20928
- if (!isGL && !isInternal) {
20929
- return (globalThis.fetch || fetch)(input, init);
20930
- }
20931
- let rawAuth = getAuthSnapshot ? await getAuthSnapshot() : void 0;
20932
- if (!rawAuth) {
20933
- rawAuth = loadStoredAuthFromJson();
20934
- }
20935
- if (!rawAuth || !isOAuthAuth(rawAuth)) {
20936
- return (globalThis.fetch || fetch)(input, init);
20937
- }
20938
- let authRecord = resolveCachedAuth(rawAuth);
20939
- if (accessTokenExpired(authRecord)) {
20940
- const refreshed = await refreshAccessToken(authRecord, { auth: { set: async () => {
20941
- } } });
20942
- if (refreshed) {
20943
- authRecord = refreshed;
20944
- }
20945
- }
20946
- if (!authRecord.access) {
20947
- return (globalThis.fetch || fetch)(input, init);
20948
- }
20949
- if (isInternal) {
20950
- const hasAuth = getSafeHeader(init?.headers, "Authorization") !== void 0;
20951
- if (hasAuth) {
20952
- return (globalThis.fetch || fetch)(input, init);
20953
- }
20954
- const userAgent = buildAgyCliUserAgent();
20955
- const headers = setSafeHeaders(init?.headers, {
20956
- Authorization: `Bearer ${authRecord.access}`,
20957
- "User-Agent": userAgent
20958
- });
20959
- return (globalThis.fetch || fetch)(input, {
20960
- ...init,
20961
- headers
20962
- });
20963
- }
20964
- const requestTarget = parseGenerativeLanguageRequest(input);
20965
- const requestUserAgentModel = requestTarget?.effectiveModel;
20966
- let projectContext;
20967
- try {
20968
- projectContext = await ensureProjectContext(
20969
- authRecord,
20970
- { auth: { set: async () => {
20971
- } } },
20972
- void 0,
20973
- requestUserAgentModel
20974
- );
20975
- } catch {
20976
- projectContext = {
20977
- effectiveProjectId: parseRefreshParts(authRecord.refresh).projectId || "antigravity",
20978
- auth: authRecord
20979
- };
20980
- }
20981
- const originalRequestedModel = parseGenerativeLanguageRequest(input)?.effectiveModel;
20982
- let modifiedInput = input;
20983
- if (isGL && originalRequestedModel) {
20984
- const originalBase = originalRequestedModel.replace("google-agy/", "");
20985
- const resolvedBase = resolveModelTier(originalBase, init);
20986
- if (originalBase !== resolvedBase) {
20987
- if (typeof modifiedInput === "string") {
20988
- modifiedInput = modifiedInput.replace(`models/${originalBase}`, `models/${resolvedBase}`);
20989
- } else if (typeof Request !== "undefined" && modifiedInput instanceof Request) {
20990
- const newUrl = modifiedInput.url.replace(`models/${originalBase}`, `models/${resolvedBase}`);
20991
- modifiedInput = new Request(newUrl, modifiedInput);
20992
- }
20993
- }
20994
- }
20995
- const transformed = prepareAgyRequest(
20996
- modifiedInput,
20997
- init,
20998
- authRecord.access,
20999
- projectContext.effectiveProjectId,
21000
- void 0
21001
- );
21002
- const chatLogger = createChatLogger();
21003
- if (chatLogger) {
21004
- chatLogger.logRequest(
21005
- toUrlString(transformed.request),
21006
- transformed.init.method || "GET",
21007
- transformed.init.headers,
21008
- transformed.init.body
21009
- );
21010
- }
21011
- const response = await fetchWithRetry(transformed.request, transformed.init);
21012
- return transformAgyResponse(
21013
- response,
21014
- transformed.streaming,
21015
- null,
21016
- transformed.requestedModel,
21017
- transformed.sessionId,
21018
- chatLogger
21019
- );
21020
- };
21021
- }
21022
-
21023
- // src/plugin/v2-session.ts
21024
- function createV2HttpRequestHook(state = {}) {
21025
- return async (event) => {
21026
- if (!event) return;
21027
- const rawUrl = typeof event.url === "string" ? event.url : event.request?.url || "";
21028
- const isGL = isGenerativeLanguageRequest(rawUrl);
21029
- const isInternal = rawUrl.includes("cloudcode-pa.googleapis.com");
21030
- if (!isGL && !isInternal) {
21031
- return;
21032
- }
21033
- event.headers = event.headers || {};
21034
- let modelName;
21035
- let rawAuth = event.auth;
21036
- if (rawAuth && !rawAuth.type) {
21037
- const tokenVal = rawAuth.access || rawAuth.token;
21038
- if (tokenVal || rawAuth.refresh) {
21039
- rawAuth = { type: "oauth", access: tokenVal, ...rawAuth };
21040
- }
21041
- }
21042
- if (!rawAuth || !isOAuthAuth(rawAuth)) {
21043
- rawAuth = loadStoredAuthFromJson();
21044
- }
21045
- let authRecord = rawAuth && isOAuthAuth(rawAuth) ? resolveCachedAuth(rawAuth) : void 0;
21046
- if (authRecord && accessTokenExpired(authRecord)) {
21047
- const refreshed = await refreshAccessToken(authRecord, { auth: { set: async () => {
21048
- } } });
21049
- if (refreshed) {
21050
- authRecord = refreshed;
21051
- try {
21052
- saveStoredAuthToJson(refreshed);
21053
- } catch {
21054
- console.warn("[Agy Auth] Refreshed credentials could not be persisted; the current request will continue.");
21055
- }
21056
- }
21057
- }
21058
- if (isGL) {
21059
- const parsed = parseGenerativeLanguageRequest(rawUrl);
21060
- modelName = parsed?.effectiveModel;
21061
- if (modelName) {
21062
- state.lastInterceptedModel = modelName;
21063
- }
21064
- if (typeof event.headers.delete === "function") {
21065
- event.headers.delete("x-goog-api-key");
21066
- event.headers.delete("api-key");
21067
- } else {
21068
- for (const key of Object.keys(event.headers)) {
21069
- const lower = key.toLowerCase();
21070
- if (lower === "x-goog-api-key" || lower === "api-key") {
21071
- delete event.headers[key];
21072
- }
21073
- }
21074
- }
21075
- if (event.request?.headers) {
21076
- if (typeof event.request.headers.delete === "function") {
21077
- event.request.headers.delete("x-goog-api-key");
21078
- event.request.headers.delete("api-key");
21079
- } else {
21080
- for (const key of Object.keys(event.request.headers)) {
21081
- const lower = key.toLowerCase();
21082
- if (lower === "x-goog-api-key" || lower === "api-key") {
21083
- delete event.request.headers[key];
21084
- }
21085
- }
21086
- }
21087
- }
21088
- let cleanUrl = rawUrl;
21089
- try {
21090
- const parsedUrl = new URL(rawUrl);
21091
- let urlChanged = false;
21092
- for (const param of ["key", "x-goog-api-key", "api-key"]) {
21093
- if (parsedUrl.searchParams.has(param)) {
21094
- parsedUrl.searchParams.delete(param);
21095
- urlChanged = true;
21096
- }
21097
- }
21098
- if (urlChanged) {
21099
- cleanUrl = parsedUrl.toString();
21100
- }
21101
- } catch {
21102
- }
21103
- if (authRecord && authRecord.access) {
21104
- let projectContext;
21105
- try {
21106
- projectContext = await ensureProjectContext(
21107
- authRecord,
21108
- { auth: { set: async () => {
21109
- } } },
21110
- void 0,
21111
- modelName
21112
- );
21113
- } catch {
21114
- projectContext = {
21115
- effectiveProjectId: parseRefreshParts(authRecord.refresh).projectId || "antigravity",
21116
- auth: authRecord
21117
- };
21118
- }
21119
- const originalRequestedModel = modelName;
21120
- let modifiedUrl = cleanUrl;
21121
- if (originalRequestedModel) {
21122
- const originalBase = originalRequestedModel.replace("google-agy/", "");
21123
- const initHeaders = event.headers instanceof Headers ? event.headers : event.request?.headers;
21124
- const resolvedBase = resolveModelTier(originalBase, { headers: initHeaders });
21125
- if (originalBase !== resolvedBase) {
21126
- modifiedUrl = modifiedUrl.replace(`models/${originalBase}`, `models/${resolvedBase}`);
21127
- }
21128
- }
21129
- let bodyPayload = event.body;
21130
- if (bodyPayload === void 0 && event.request) {
21131
- if (typeof event.request.clone === "function") {
21132
- try {
21133
- bodyPayload = await event.request.clone().text();
21134
- } catch {
21135
- }
21136
- } else if (event.request.body !== void 0) {
21137
- bodyPayload = event.request.body;
21138
- }
21139
- }
21140
- let preExistingUserAgent;
21141
- if (typeof event.headers?.get === "function") {
21142
- preExistingUserAgent = event.headers.get("user-agent") || event.headers.get("User-Agent") || void 0;
21143
- } else if (event.headers && typeof event.headers === "object") {
21144
- preExistingUserAgent = event.headers["user-agent"] || event.headers["User-Agent"] || void 0;
21145
- }
21146
- if (!preExistingUserAgent && typeof event.request?.headers?.get === "function") {
21147
- preExistingUserAgent = event.request.headers.get("user-agent") || event.request.headers.get("User-Agent") || void 0;
21148
- } else if (!preExistingUserAgent && event.request?.headers && typeof event.request.headers === "object") {
21149
- preExistingUserAgent = event.request.headers["user-agent"] || event.request.headers["User-Agent"] || void 0;
21150
- }
21151
- const method = event.method || event.request?.method || "POST";
21152
- const requestHeaders = event.headers || event.request?.headers;
21153
- const transformed = prepareAgyRequest(
21154
- modifiedUrl,
21155
- {
21156
- method,
21157
- headers: requestHeaders,
21158
- body: bodyPayload
21159
- },
21160
- authRecord.access,
21161
- projectContext.effectiveProjectId
21162
- );
21163
- const targetUrl = toUrlString(transformed.request);
21164
- if (typeof event.url === "string") {
21165
- event.url = targetUrl;
21166
- }
21167
- if (event.request && typeof event.request === "object") {
21168
- if (typeof Request !== "undefined" && event.request instanceof Request) {
21169
- event.request = new Request(targetUrl, {
21170
- method: transformed.init.method,
21171
- headers: transformed.init.headers,
21172
- body: transformed.init.body
21173
- });
21174
- } else if (typeof event.request.url === "string") {
21175
- try {
21176
- event.request.url = targetUrl;
21177
- } catch {
21178
- }
21179
- }
21180
- }
21181
- const headerEntries = transformed.init.headers instanceof Headers ? Array.from(transformed.init.headers.entries()) : Object.entries(transformed.init.headers || {});
21182
- for (const [k, v] of headerEntries) {
21183
- const lowerK = k.toLowerCase();
21184
- if (lowerK === "user-agent") {
21185
- if (preExistingUserAgent) {
21186
- continue;
21187
- }
21188
- if (typeof event.headers?.set === "function") {
21189
- event.headers.set("User-Agent", v);
21190
- } else if (event.headers) {
21191
- event.headers["User-Agent"] = v;
21192
- }
21193
- if (event.request?.headers && typeof event.request.headers.set === "function") {
21194
- event.request.headers.set("User-Agent", v);
21195
- } else if (event.request?.headers && typeof event.request.headers === "object") {
21196
- event.request.headers["User-Agent"] = v;
21197
- }
21198
- continue;
21199
- }
21200
- if (typeof event.headers?.set === "function") {
21201
- event.headers.set(k, v);
21202
- } else if (event.headers) {
21203
- event.headers[k] = v;
21204
- }
21205
- if (event.request?.headers && typeof event.request.headers.set === "function") {
21206
- event.request.headers.set(k, v);
21207
- } else if (event.request?.headers && typeof event.request.headers === "object") {
21208
- event.request.headers[k] = v;
21209
- }
21210
- }
21211
- if (transformed.init.body !== void 0) {
21212
- event.body = transformed.init.body;
21213
- if (event.request && typeof event.request === "object" && !(event.request instanceof Request)) {
21214
- event.request.body = transformed.init.body;
21215
- }
21216
- }
21217
- } else {
21218
- if (typeof event.url === "string") {
21219
- event.url = cleanUrl;
21220
- }
21221
- if (event.request && typeof event.request === "object") {
21222
- if (typeof Request !== "undefined" && event.request instanceof Request) {
21223
- event.request = new Request(cleanUrl, event.request);
21224
- } else if (typeof event.request.url === "string") {
21225
- try {
21226
- event.request.url = cleanUrl;
21227
- } catch {
21228
- }
21229
- }
21230
- }
21231
- }
21232
- }
21233
- if (authRecord && authRecord.access) {
21234
- if (typeof event.headers?.set === "function") {
21235
- event.headers.set("Authorization", `Bearer ${authRecord.access}`);
21236
- } else if (event.headers) {
21237
- event.headers["Authorization"] = `Bearer ${authRecord.access}`;
21238
- }
21239
- if (event.request?.headers && typeof event.request.headers.set === "function") {
21240
- event.request.headers.set("Authorization", `Bearer ${authRecord.access}`);
21241
- } else if (event.request?.headers && typeof event.request.headers === "object") {
21242
- event.request.headers["Authorization"] = `Bearer ${authRecord.access}`;
21243
- }
21244
- }
21245
- const userAgent = buildAgyCliUserAgent(modelName);
21246
- if (typeof event.headers?.set === "function") {
21247
- if (!event.headers.get("User-Agent") && !event.headers.get("user-agent")) {
21248
- event.headers.set("User-Agent", userAgent);
21249
- }
21250
- } else if (event.headers) {
21251
- if (!event.headers["User-Agent"] && !event.headers["user-agent"]) {
21252
- event.headers["User-Agent"] = userAgent;
21253
- }
21254
- }
21255
- if (event.request?.headers && typeof event.request.headers.set === "function") {
21256
- if (!event.request.headers.get("User-Agent") && !event.request.headers.get("user-agent")) {
21257
- event.request.headers.set("User-Agent", userAgent);
21258
- }
21259
- } else if (event.request?.headers && typeof event.request.headers === "object") {
21260
- if (!event.request.headers["User-Agent"] && !event.request.headers["user-agent"]) {
21261
- event.request.headers["User-Agent"] = userAgent;
21262
- }
21263
- }
21264
- };
21265
- }
21266
- function createV2HttpResponseHook(state = {}) {
21267
- return async (event) => {
21268
- if (!event || !event.response) return;
21269
- const rawUrl = typeof event.url === "string" ? event.url : event.request?.url || "";
21270
- const isInternal = rawUrl.includes("cloudcode-pa.googleapis.com");
21271
- if (isInternal && event.response instanceof Response) {
21272
- const isStreaming = rawUrl.includes(":streamGenerateCode") || event.response.headers.get("content-type")?.includes("text/event-stream");
21273
- const parsedModel = parseGenerativeLanguageRequest(rawUrl)?.effectiveModel || state.lastInterceptedModel;
21274
- const transformed = await transformAgyResponse(
21275
- event.response,
21276
- !!isStreaming,
21277
- null,
21278
- parsedModel,
21279
- void 0,
21280
- void 0
21281
- );
21282
- event.response = transformed;
21283
- }
21284
- };
21285
- }
21286
- function createV2RetryHook() {
21287
- return async (event) => {
21288
- if (!event) return;
21289
- const response = event.response;
21290
- if (response instanceof Response) {
21291
- if (response.status === 429 || response.status === 503) {
21292
- const quota = await classifyQuotaResponse(response);
21293
- if (quota?.retryDelayMs) {
21294
- event.retryDelayMs = quota.retryDelayMs;
21295
- } else {
21296
- event.retryDelayMs = await resolveRetryDelayMs(response, event.attempt || 1);
21297
- }
21298
- }
21299
- } else if (event.details && Array.isArray(event.details)) {
21300
- const retryInfo = event.details.find(
21301
- (d) => d && d["@type"] === "type.googleapis.com/google.rpc.RetryInfo"
21302
- );
21303
- if (retryInfo?.retryDelay) {
21304
- const delayMs = retryInternals.parseRetryDelayValue(retryInfo.retryDelay);
21305
- if (delayMs !== null) {
21306
- event.retryDelayMs = delayMs;
21307
- }
21308
- }
21309
- }
21310
- };
21311
- }
21312
- function registerV2SessionHooks(ctx) {
21313
- const state = {};
21314
- ctx.session.hook("http.request", createV2HttpRequestHook(state), { providerID: AGY_PROVIDER_ID });
21315
- ctx.session.hook("http.response", createV2HttpResponseHook(state), { providerID: AGY_PROVIDER_ID });
21316
- ctx.session.hook("retry", createV2RetryHook(), { providerID: AGY_PROVIDER_ID });
21317
- }
21318
-
21319
- // src/plugin/v2.ts
21320
- async function setupOpenCodeV2(ctx) {
21321
- const resolveVariants = (modelId) => {
21322
- const mapping = TIER_MAPPING[modelId];
21323
- if (!mapping) return void 0;
21324
- const variants = [];
21325
- if (mapping.minimal !== void 0) variants.push({ id: "minimal" });
21326
- if (mapping.low !== void 0) variants.push({ id: "low" });
21327
- if (mapping.medium !== void 0) variants.push({ id: "medium" });
21328
- if (mapping.high !== void 0) variants.push({ id: "high" });
21329
- return variants.length > 0 ? variants : void 0;
21330
- };
21331
- const updateProviderRecord = (p) => {
21332
- p.name = "Antigravity CLI";
21333
- p.activation = "enabled";
21334
- p.package = "aisdk:@ai-sdk/google";
21335
- p.description = "Google Gemini Antigravity Code Assist OAuth provider";
21336
- p.settings = { ...p.settings || {}, apiKey: "dummy" };
21337
- p.integrationID = AGY_PROVIDER_ID;
21338
- };
21339
- const buildModelRecord = (modelId, simple, existingModel) => {
21340
- const isClaude = modelId.startsWith("claude-");
21341
- const isGpt = modelId.startsWith("gpt-");
21342
- const variants = resolveVariants(modelId);
21343
- return {
21344
- id: modelId,
21345
- providerID: AGY_PROVIDER_ID,
21346
- name: simple.name,
21347
- description: simple.description,
21348
- family: modelId.includes("gemini") ? "gemini" : isClaude ? "claude" : isGpt ? "gpt" : "unknown",
21349
- reasoning: simple.reasoning,
21350
- attachment: simple.attachment,
21351
- tool_call: simple.toolCall,
21352
- limit: {
21353
- context: simple.maxTokens,
21354
- output: simple.maxOutputTokens
21355
- },
21356
- cost: simple.cost || { input: 0, output: 0 },
21357
- ...variants ? { variants } : {},
21358
- ...existingModel || {}
21359
- };
21360
- };
21361
- const updateModelRecord = (m, modelId, simple) => {
21362
- m.name = simple.name;
21363
- m.capabilities = {
21364
- tools: true,
21365
- input: ["text", "image"],
21366
- output: ["text"]
21367
- };
21368
- m.limit = {
21369
- context: simple.maxTokens,
21370
- output: simple.maxOutputTokens
21371
- };
21372
- m.family = "gemini";
21373
- if (simple.cost) {
21374
- m.cost = simple.cost;
21375
- }
21376
- const variants = resolveVariants(modelId);
21377
- if (variants) {
21378
- m.variants = variants;
21379
- }
21380
- };
21381
- if (ctx.provider?.transform) {
21382
- ctx.provider.transform(async (editor) => {
21383
- if (!editor) return;
21384
- if (typeof editor.update === "function") {
21385
- editor.update(AGY_PROVIDER_ID, updateProviderRecord);
21386
- } else if (typeof editor.set === "function") {
21387
- const p = { id: AGY_PROVIDER_ID };
21388
- updateProviderRecord(p);
21389
- editor.set(AGY_PROVIDER_ID, p);
21390
- } else if (typeof editor === "object") {
21391
- const p = editor[AGY_PROVIDER_ID] || { id: AGY_PROVIDER_ID };
21392
- updateProviderRecord(p);
21393
- editor[AGY_PROVIDER_ID] = p;
21394
- }
21395
- });
21396
- }
21397
- if (ctx.model?.transform) {
21398
- ctx.model.transform(async (editor) => {
21399
- if (!editor) return;
21400
- if (typeof editor.update === "function") {
21401
- for (const [modelId, simple] of Object.entries(STATIC_MODELS_SIMPLE)) {
21402
- editor.update(AGY_PROVIDER_ID, modelId, (m) => updateModelRecord(m, modelId, simple));
21403
- }
21404
- } else if (typeof editor.set === "function") {
21405
- for (const [modelId, simple] of Object.entries(STATIC_MODELS_SIMPLE)) {
21406
- const m = buildModelRecord(modelId, simple);
21407
- editor.set(`${AGY_PROVIDER_ID}:${modelId}`, m);
21408
- }
21409
- } else if (typeof editor === "object") {
21410
- for (const [modelId, simple] of Object.entries(STATIC_MODELS_SIMPLE)) {
21411
- const key = `${AGY_PROVIDER_ID}:${modelId}`;
21412
- editor[key] = buildModelRecord(modelId, simple, editor[key]);
21413
- }
21414
- }
21415
- });
20968
+ function toUrlString(value) {
20969
+ if (typeof value === "string") {
20970
+ return value;
21416
20971
  }
21417
- if (ctx.catalog?.transform) {
21418
- ctx.catalog.transform(async (editor) => {
21419
- if (!editor) return;
21420
- if (typeof editor?.provider?.update === "function") {
21421
- editor.provider.update(AGY_PROVIDER_ID, updateProviderRecord);
21422
- if (typeof editor?.model?.update === "function") {
21423
- for (const [modelId, simple] of Object.entries(STATIC_MODELS_SIMPLE)) {
21424
- editor.model.update(AGY_PROVIDER_ID, modelId, (m) => updateModelRecord(m, modelId, simple));
21425
- }
21426
- }
21427
- return;
21428
- }
21429
- const catalog = editor;
21430
- catalog.providers = catalog.providers || {};
21431
- catalog.providers[AGY_PROVIDER_ID] = {
21432
- id: AGY_PROVIDER_ID,
21433
- name: "Antigravity CLI",
21434
- npm: "aisdk:@ai-sdk/google",
21435
- settings: { apiKey: "dummy" },
21436
- integrationID: AGY_PROVIDER_ID,
21437
- models: { ...catalog.providers[AGY_PROVIDER_ID]?.models || {} },
21438
- ...catalog.providers[AGY_PROVIDER_ID]
21439
- };
21440
- if (catalog.providers[AGY_PROVIDER_ID].settings) {
21441
- catalog.providers[AGY_PROVIDER_ID].settings = {
21442
- ...catalog.providers[AGY_PROVIDER_ID].settings,
21443
- apiKey: "dummy"
21444
- };
21445
- } else {
21446
- catalog.providers[AGY_PROVIDER_ID].settings = { apiKey: "dummy" };
21447
- }
21448
- catalog.providers[AGY_PROVIDER_ID].integrationID = AGY_PROVIDER_ID;
21449
- const targetModels = catalog.providers[AGY_PROVIDER_ID].models;
21450
- for (const [modelId, simple] of Object.entries(STATIC_MODELS_SIMPLE)) {
21451
- targetModels[modelId] = buildModelRecord(modelId, simple, targetModels[modelId]);
21452
- }
21453
- });
20972
+ const candidate = value.url;
20973
+ if (candidate) {
20974
+ return candidate;
21454
20975
  }
21455
- ctx.tool.transform(async (editor) => {
21456
- if (!editor) return;
21457
- const quotaTool = createAgyQuotaTool({
21458
- client: void 0,
21459
- getAuthResolver: () => void 0,
21460
- getConfiguredProjectId: () => void 0,
21461
- getUserAgentModel: () => void 0
21462
- });
21463
- const quotaSummaryTool = createAgyQuotaSummaryTool({
21464
- client: void 0,
21465
- getAuthResolver: () => void 0,
21466
- getConfiguredProjectId: () => void 0,
21467
- getUserAgentModel: () => void 0
21468
- });
21469
- if (typeof editor.add === "function") {
21470
- editor.add({
21471
- name: AGY_QUOTA_TOOL_NAME,
21472
- description: quotaTool.description,
21473
- input: {},
21474
- execute: async (args, context) => quotaTool.execute(args, context)
21475
- });
21476
- editor.add({
21477
- name: AGY_QUOTA_SUMMARY_TOOL_NAME,
21478
- description: quotaSummaryTool.description,
21479
- input: {},
21480
- execute: async (args, context) => quotaSummaryTool.execute(args, context)
21481
- });
21482
- } else if (typeof editor.set === "function") {
21483
- editor.set(AGY_QUOTA_TOOL_NAME, quotaTool);
21484
- editor.set(AGY_QUOTA_SUMMARY_TOOL_NAME, quotaSummaryTool);
21485
- } else if (editor.tools && typeof editor.tools === "object") {
21486
- editor.tools[AGY_QUOTA_TOOL_NAME] = quotaTool;
21487
- editor.tools[AGY_QUOTA_SUMMARY_TOOL_NAME] = quotaSummaryTool;
21488
- } else if (typeof editor === "object") {
21489
- editor[AGY_QUOTA_TOOL_NAME] = quotaTool;
21490
- editor[AGY_QUOTA_SUMMARY_TOOL_NAME] = quotaSummaryTool;
21491
- }
21492
- });
21493
- ctx.command.transform(async (editor) => {
21494
- if (!editor) return;
21495
- const commands = {
21496
- [AGY_V2_QUOTA_COMMAND]: {
21497
- description: "Show Agy Code Assist quota usage",
21498
- template: AGY_V2_QUOTA_COMMAND_TEMPLATE
21499
- },
21500
- [AGY_V2_QUOTA_SUMMARY_COMMAND]: {
21501
- description: "Show Agy Code Assist quota summary with weekly and 5-hour limits",
21502
- template: AGY_V2_QUOTA_SUMMARY_COMMAND_TEMPLATE
21503
- }
21504
- };
21505
- if (typeof editor.add === "function") {
21506
- editor.add({
21507
- name: AGY_V2_QUOTA_COMMAND,
21508
- description: "Display current Antigravity quota usage",
21509
- template: AGY_V2_QUOTA_COMMAND_TEMPLATE
21510
- });
21511
- editor.add({
21512
- name: AGY_V2_QUOTA_SUMMARY_COMMAND,
21513
- description: "Display Antigravity quota summary grouped by model family",
21514
- template: AGY_V2_QUOTA_SUMMARY_COMMAND_TEMPLATE
21515
- });
21516
- } else if (typeof editor.set === "function") {
21517
- editor.set(AGY_V2_QUOTA_COMMAND, commands[AGY_V2_QUOTA_COMMAND]);
21518
- editor.set(AGY_V2_QUOTA_SUMMARY_COMMAND, commands[AGY_V2_QUOTA_SUMMARY_COMMAND]);
21519
- } else if (editor.commands && typeof editor.commands === "object") {
21520
- editor.commands[AGY_V2_QUOTA_COMMAND] = commands[AGY_V2_QUOTA_COMMAND];
21521
- editor.commands[AGY_V2_QUOTA_SUMMARY_COMMAND] = commands[AGY_V2_QUOTA_SUMMARY_COMMAND];
21522
- } else if (typeof editor === "object") {
21523
- editor[AGY_V2_QUOTA_COMMAND] = commands[AGY_V2_QUOTA_COMMAND];
21524
- editor[AGY_V2_QUOTA_SUMMARY_COMMAND] = commands[AGY_V2_QUOTA_SUMMARY_COMMAND];
21525
- }
21526
- });
21527
- ctx.integration?.transform?.((editor) => {
21528
- if (!editor) return;
21529
- editor.update?.(AGY_PROVIDER_ID, (integration) => {
21530
- integration.name = "Antigravity CLI (plugin)";
21531
- });
21532
- editor.method?.update?.({
21533
- integrationID: AGY_PROVIDER_ID,
21534
- method: {
21535
- id: "oauth",
21536
- type: "oauth",
21537
- label: "Antigravity CLI (OAuth)"
21538
- },
21539
- authorize: async () => {
21540
- const authorization = await authorizeAgy();
21541
- return {
21542
- mode: "code",
21543
- url: authorization.url,
21544
- instructions: "Please complete Google account authorization in your browser. After authorization, copy the full redirect URL or code and paste it below:",
21545
- callback: async (code) => {
21546
- const trimmed = code.trim();
21547
- const parsed = parseOAuthCallbackInput(trimmed);
21548
- const authCode = parsed.code || trimmed;
21549
- if (!authCode) {
21550
- return { type: "failed", error: "Missing authorization code in callback input" };
21551
- }
21552
- if (parsed.state && parsed.state !== authorization.state) {
21553
- return { type: "failed", error: "State mismatch in callback input (possible CSRF attempt)" };
21554
- }
21555
- const exchangeResult = await exchangeAgyWithVerifier(authCode, authorization.verifier);
21556
- if (exchangeResult.type !== "success") {
21557
- return exchangeResult;
21558
- }
21559
- const initialRefresh = formatRefreshParts({
21560
- refreshToken: exchangeResult.refresh
21561
- });
21562
- let authRecord = {
21563
- type: "oauth",
21564
- refresh: initialRefresh,
21565
- access: exchangeResult.access,
21566
- expires: exchangeResult.expires
21567
- };
21568
- try {
21569
- const projectContext = await ensureProjectContext(
21570
- authRecord,
21571
- { auth: { set: async () => {
21572
- } } }
21573
- );
21574
- authRecord = {
21575
- ...authRecord,
21576
- refresh: projectContext.auth.refresh
21577
- };
21578
- } catch {
21579
- }
21580
- try {
21581
- saveStoredAuthToJson(authRecord);
21582
- } catch {
21583
- return {
21584
- type: "failed",
21585
- error: "Google authentication succeeded but AGY credentials could not be stored. Check filesystem access and retry."
21586
- };
21587
- }
21588
- return {
21589
- type: "oauth",
21590
- methodID: "oauth",
21591
- refresh: authRecord.refresh,
21592
- access: authRecord.access,
21593
- expires: authRecord.expires
21594
- };
21595
- }
21596
- };
21597
- }
21598
- });
21599
- });
21600
- ctx.aisdk?.hook("sdk", async (event) => {
21601
- if (!event) return;
21602
- const isMatchingProvider = event.providerID === AGY_PROVIDER_ID || event.model?.providerID === AGY_PROVIDER_ID;
21603
- if (!isMatchingProvider) return;
21604
- event.options = event.options || {};
21605
- event.options.apiKey = "dummy";
21606
- event.options.fetch = createV2FetchInterceptor();
21607
- });
21608
- registerV2SessionHooks(ctx);
20976
+ return value.toString();
21609
20977
  }
21610
- var v2PluginDefinition = defineOpenCodeV2Plugin({
21611
- id: AGY_PROVIDER_ID,
21612
- setup: setupOpenCodeV2
21613
- });
21614
20978
 
21615
20979
  // index.ts
21616
- var dualPlugin = {
21617
- ...v2PluginDefinition,
20980
+ var index_default = {
20981
+ id: "@anthonyhaussman/opencode-agy-auth",
21618
20982
  server: AgyCLIOAuthPlugin
21619
20983
  };
21620
- var index_default = dualPlugin;
21621
20984
  export {
21622
20985
  AgyCLIOAuthPlugin,
21623
20986
  GoogleOAuthPlugin,
21624
- index_default as default,
21625
- defineOpenCodeV2Plugin,
21626
- setupOpenCodeV2,
21627
- v2PluginDefinition
20987
+ index_default as default
21628
20988
  };
21629
20989
  //# sourceMappingURL=index.js.map