@serviceme/devtools-shared 0.4.6 → 0.4.7

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.d.mts CHANGED
@@ -194,6 +194,29 @@ interface ProviderModel {
194
194
  */
195
195
  thinkingSchema?: ModelThinkingSchema;
196
196
  }
197
+ /**
198
+ * Per-model vision handling mode (BYOM-depth #3).
199
+ *
200
+ * Borrowed from
201
+ * `docs/references/GLM-for-copilot-main/src/types.ts:167`
202
+ * (`ModelVisionMode = 'proxy' | 'native' | 'mcp'`). v1 ships
203
+ * `native` + `mcp`; `proxy` is reserved for v2 (the recursive-
204
+ * chat vision model description has its own design pass).
205
+ *
206
+ * - `native` (default) — image bytes are passed inline to the
207
+ * adapter, which translates them to the vendor's native
208
+ * wire shape (OpenAI `image_url`, Anthropic `source.base64`).
209
+ * Existing v0 behaviour; byte-identical to the pre-BYOM-depth
210
+ * path.
211
+ * - `mcp` — image bytes are persisted to
212
+ * `<globalStorageUri>/images/<sha256>.<ext>` and the user
213
+ * message is rewritten with a `[Image attached at local file:
214
+ * <path>]` placeholder + a system preamble telling the model
215
+ * to use an image-capable MCP tool to read the file. Useful
216
+ * for text-only models and self-hosted gateways where inline
217
+ * base64 is undesirable.
218
+ */
219
+ type ProviderVisionMode = "native" | "mcp";
197
220
  /**
198
221
  * Persisted provider configuration. `apiKeyRef` is the SecretStorage
199
222
  * key; the actual key never appears in this object after creation
@@ -232,6 +255,16 @@ interface ProviderConfig {
232
255
  * Ignored for non-minimax providers.
233
256
  */
234
257
  minimaxBillingType?: "token_plan" | "pay_as_you_go";
258
+ /**
259
+ * Per-provider vision handling mode (BYOM-depth #3). Defaults
260
+ * to `"native"` when absent — the existing v0 behaviour,
261
+ * byte-identical to the pre-BYOM-depth path. Set to `"mcp"`
262
+ * to route image-bearing requests through the on-disk
263
+ * placeholder path (useful for text-only models and self-
264
+ * hosted gateways). See {@link ProviderVisionMode} for the
265
+ * full contract.
266
+ */
267
+ visionMode?: ProviderVisionMode;
235
268
  /** Created / updated timestamps (informational) */
236
269
  createdAt: string;
237
270
  updatedAt: string;
@@ -408,6 +441,63 @@ interface ProviderBaseUrlPreset {
408
441
  baseUrl: string;
409
442
  }
410
443
 
444
+ /**
445
+ * Wire protocol implied by a `baseUrl`.
446
+ *
447
+ * Used to disambiguate the same vendor's two coexisting endpoints
448
+ * (OpenAI-compatible vs Anthropic-compatible) when the user picks
449
+ * a baseUrl from the ProvidersTab dropdown. Today the only
450
+ * commonly-ambiguous vendor is **Zhipu / 智谱**:
451
+ *
452
+ * - `https://open.bigmodel.cn/api/paas/v4` → openai
453
+ * - `https://open.bigmodel.cn/api/coding/paas/v4` → openai
454
+ * - `https://open.bigmodel.cn/api/anthropic` → anthropic
455
+ * - `https://api.z.ai/api/paas/v4` → openai
456
+ * - `https://api.z.ai/api/coding/paas/v4` → openai
457
+ * - `https://api.z.ai/api/anthropic` → anthropic
458
+ *
459
+ * The reference plugin (`docs/references/GLM-for-copilot-main`)
460
+ * encodes this as an `EndpointPreset` enum literal; we encode it
461
+ * as a path heuristic on the baseUrl. Trade-off: a typo'd path
462
+ * that says "anthropic" would mis-classify, but the same
463
+ * `PROVIDER_BASE_URL_PRESETS.zhipu` dropdown that exposes the
464
+ * Anthropic option ALSO labels it `国内 · Coding Plan · Anthropic 协议`
465
+ * so the user has visual confirmation; a typo in path without
466
+ * matching dropdown is unlikely.
467
+ *
468
+ * Detection rule: a `/anthropic` (or `/anthropic/...`) segment
469
+ * anywhere in the URL **path** — case-insensitive. Hostname
470
+ * matches (e.g. `api.anthropic.com`) are intentionally ignored:
471
+ * we do not currently support routing to Anthropic's own
472
+ * production API (their models are first-class VSCode features).
473
+ */
474
+ type ProviderWireProtocol = "openai" | "anthropic";
475
+ declare function protocolForBaseUrl(baseUrl: string): ProviderWireProtocol;
476
+ /**
477
+ * Resolve the actual `ProviderType` whose adapter should handle a
478
+ * request with the given `configuredType` + `baseUrl`.
479
+ *
480
+ * Most of the time this is just `configuredType`. The exception is
481
+ * the named `zhipu` provider with an Anthropic-protocol baseUrl
482
+ * (`/api/anthropic`); we route it through the `anthropic-compatible`
483
+ * adapter so the URL construction appends `/v1/messages` instead of
484
+ * the OpenAI `/v1/chat/completions`. Without this, the OpenAIAdapter
485
+ * would build `.../api/anthropic/chat/completions` and GLM would
486
+ * 404 (the Anthropic-compatible endpoint only serves
487
+ * `.../api/anthropic/v1/messages`).
488
+ *
489
+ * `minimax` is intentionally NOT in the override list because the
490
+ * curated preset is `https://api.minimaxi.com/anthropic` (already
491
+ * Anthropic-protocol), and the `minimax` case in the adapter
492
+ * factory already wires AnthropicAdapter unconditionally.
493
+ *
494
+ * Everything else (deepseek / kimi / stepfun / agnes / openrouter /
495
+ * novita / openai-compatible / anthropic-compatible) returns
496
+ * `configuredType` unchanged — these vendors don't publish an
497
+ * alternate-protocol endpoint on the same host.
498
+ */
499
+ declare function effectiveAdapterType(configuredType: ProviderType, baseUrl: string): ProviderType;
500
+
411
501
  /**
412
502
  * Provider-type → known baseUrl candidates (e.g. mainland-China vs.
413
503
  * global endpoints for the same vendor, like Agnes/MiniMax/DeepSeek).
@@ -1391,4 +1481,4 @@ declare function asAbortSignal(input: unknown): AbortSignal | undefined;
1391
1481
  */
1392
1482
  declare function safeJson<T>(text: string, fallback: T): T;
1393
1483
 
1394
- export { type AIModelConfig, type AIModelInfo, type AgentPermissionSummary, type AgentToolPermission, type AgentToolRiskLevel, BUILTIN_PROVIDER_PRESETS, type BalanceEntry, type BridgeLinkMode, type BridgeLinkedSkill, type BridgeRepoEntry, type BridgeRepoSyncPull, type BridgeSkillKind, type BridgeSkillRepoEntry, type BridgeSkillRepoFile, type ByomProviderToggles, ByomSettingsResponse, type ByomSettingsSnapshot, type ByomTogglePayload, CERTIFICATE_BUNDLE_FORMATS, CachedServerUrlResponse, type CachedServerUrlSnapshot, type CertificateBundleEnvironmentSupport, type CertificateBundleFormat, type CertificateBundleFormatDescriptor, type CodingPlanUsage, type CommandPayload, type CuratedModelMetadata, type DeepseekBalanceEntry, type DeepseekUsage, type DownloadCertificateBundleRequest, type DownloadCertificateBundleResponse, GIT_REMOTE_HOST_ALIASES, type GenericBalanceUsage, GetByomSettings, GetCachedServerUrl, GetServerProxyState, GetUtilityModels, type GitHubOrgMembershipCheckResult, type GitHubOrgMembershipStatus, type GitHubUser, type GithubCopilotCliPayload, type HttpRequestPayload, type ILogger, type LinkedSkillPayloadEntry, LogLevel, MODEL_METADATA, type MinimaxUsage, type ModelDetail, type ModelPriceCategory, type ModelPricing, type ModelThinkingSchema, PROVIDER_BASE_URL_PRESETS, PROVIDER_CACHE_CONTROL_METADATA, type ProviderBaseUrlPreset, type ProviderCacheControlMetadata, type ProviderConfig, type ProviderModel, type ProviderMutationPayload, type ProviderTestResult, type ProviderType, type ProviderUsageData, type ProviderUsageKind, type ProviderUsageResult, type ProvidersResponsePayload, type PublicProvider, type ScheduledTask, type ScheduledTaskType, type ScheduledTaskV1, type ScheduledTasksConfig, type ScheduledTasksLogFile, type ServerProxyAllowOverridePayload, type ServerProxySnapshot, ServerProxyStateResponse, type ServerProxySupportMode, type ServerProxyTogglePayload, SetCacheControlEnabled, SetServerProxyAllowOverride, SetServerProxyEnabled, type ShellPayload, type TaskExecutionLog, type TaskExecutionState, type TaskExecutionStatus, type TaskPayload, type TaskRunStatus, type TaskWorkspaceRef, UpdateUtilityModels, type UpdateUtilityModelsPayload, type UsageWindow, type UtilityModelScope, type UtilityModelsEffective, UtilityModelsResponse, type UtilityModelsSnapshot, type UtilityModelsSource, type WebviewInboundMessage, WebviewMessageType, __internal, asAbortSignal, buildGitHubLocalEmail, checkGitHubOrgMembership, createConsoleLogger, currencyForBaseUrl, fetchGitHubUser, getBuiltinProviderPreset, getGitHubOrgMembership, getProviderBaseUrlPresets, isGitHubLocalEmail, isProviderCacheControlAware, isValidCanonicalSlug, lookupModelMetadata, normalizeCanonicalSlug, normalizeErrorForLog, normalizeGitUrl, parsePayload, resolvePrimaryEmail, safeJson };
1484
+ export { type AIModelConfig, type AIModelInfo, type AgentPermissionSummary, type AgentToolPermission, type AgentToolRiskLevel, BUILTIN_PROVIDER_PRESETS, type BalanceEntry, type BridgeLinkMode, type BridgeLinkedSkill, type BridgeRepoEntry, type BridgeRepoSyncPull, type BridgeSkillKind, type BridgeSkillRepoEntry, type BridgeSkillRepoFile, type ByomProviderToggles, ByomSettingsResponse, type ByomSettingsSnapshot, type ByomTogglePayload, CERTIFICATE_BUNDLE_FORMATS, CachedServerUrlResponse, type CachedServerUrlSnapshot, type CertificateBundleEnvironmentSupport, type CertificateBundleFormat, type CertificateBundleFormatDescriptor, type CodingPlanUsage, type CommandPayload, type CuratedModelMetadata, type DeepseekBalanceEntry, type DeepseekUsage, type DownloadCertificateBundleRequest, type DownloadCertificateBundleResponse, GIT_REMOTE_HOST_ALIASES, type GenericBalanceUsage, GetByomSettings, GetCachedServerUrl, GetServerProxyState, GetUtilityModels, type GitHubOrgMembershipCheckResult, type GitHubOrgMembershipStatus, type GitHubUser, type GithubCopilotCliPayload, type HttpRequestPayload, type ILogger, type LinkedSkillPayloadEntry, LogLevel, MODEL_METADATA, type MinimaxUsage, type ModelDetail, type ModelPriceCategory, type ModelPricing, type ModelThinkingSchema, PROVIDER_BASE_URL_PRESETS, PROVIDER_CACHE_CONTROL_METADATA, type ProviderBaseUrlPreset, type ProviderCacheControlMetadata, type ProviderConfig, type ProviderModel, type ProviderMutationPayload, type ProviderTestResult, type ProviderType, type ProviderUsageData, type ProviderUsageKind, type ProviderUsageResult, type ProviderVisionMode, type ProviderWireProtocol, type ProvidersResponsePayload, type PublicProvider, type ScheduledTask, type ScheduledTaskType, type ScheduledTaskV1, type ScheduledTasksConfig, type ScheduledTasksLogFile, type ServerProxyAllowOverridePayload, type ServerProxySnapshot, ServerProxyStateResponse, type ServerProxySupportMode, type ServerProxyTogglePayload, SetCacheControlEnabled, SetServerProxyAllowOverride, SetServerProxyEnabled, type ShellPayload, type TaskExecutionLog, type TaskExecutionState, type TaskExecutionStatus, type TaskPayload, type TaskRunStatus, type TaskWorkspaceRef, UpdateUtilityModels, type UpdateUtilityModelsPayload, type UsageWindow, type UtilityModelScope, type UtilityModelsEffective, UtilityModelsResponse, type UtilityModelsSnapshot, type UtilityModelsSource, type WebviewInboundMessage, WebviewMessageType, __internal, asAbortSignal, buildGitHubLocalEmail, checkGitHubOrgMembership, createConsoleLogger, currencyForBaseUrl, effectiveAdapterType, fetchGitHubUser, getBuiltinProviderPreset, getGitHubOrgMembership, getProviderBaseUrlPresets, isGitHubLocalEmail, isProviderCacheControlAware, isValidCanonicalSlug, lookupModelMetadata, normalizeCanonicalSlug, normalizeErrorForLog, normalizeGitUrl, parsePayload, protocolForBaseUrl, resolvePrimaryEmail, safeJson };
package/dist/index.d.ts CHANGED
@@ -194,6 +194,29 @@ interface ProviderModel {
194
194
  */
195
195
  thinkingSchema?: ModelThinkingSchema;
196
196
  }
197
+ /**
198
+ * Per-model vision handling mode (BYOM-depth #3).
199
+ *
200
+ * Borrowed from
201
+ * `docs/references/GLM-for-copilot-main/src/types.ts:167`
202
+ * (`ModelVisionMode = 'proxy' | 'native' | 'mcp'`). v1 ships
203
+ * `native` + `mcp`; `proxy` is reserved for v2 (the recursive-
204
+ * chat vision model description has its own design pass).
205
+ *
206
+ * - `native` (default) — image bytes are passed inline to the
207
+ * adapter, which translates them to the vendor's native
208
+ * wire shape (OpenAI `image_url`, Anthropic `source.base64`).
209
+ * Existing v0 behaviour; byte-identical to the pre-BYOM-depth
210
+ * path.
211
+ * - `mcp` — image bytes are persisted to
212
+ * `<globalStorageUri>/images/<sha256>.<ext>` and the user
213
+ * message is rewritten with a `[Image attached at local file:
214
+ * <path>]` placeholder + a system preamble telling the model
215
+ * to use an image-capable MCP tool to read the file. Useful
216
+ * for text-only models and self-hosted gateways where inline
217
+ * base64 is undesirable.
218
+ */
219
+ type ProviderVisionMode = "native" | "mcp";
197
220
  /**
198
221
  * Persisted provider configuration. `apiKeyRef` is the SecretStorage
199
222
  * key; the actual key never appears in this object after creation
@@ -232,6 +255,16 @@ interface ProviderConfig {
232
255
  * Ignored for non-minimax providers.
233
256
  */
234
257
  minimaxBillingType?: "token_plan" | "pay_as_you_go";
258
+ /**
259
+ * Per-provider vision handling mode (BYOM-depth #3). Defaults
260
+ * to `"native"` when absent — the existing v0 behaviour,
261
+ * byte-identical to the pre-BYOM-depth path. Set to `"mcp"`
262
+ * to route image-bearing requests through the on-disk
263
+ * placeholder path (useful for text-only models and self-
264
+ * hosted gateways). See {@link ProviderVisionMode} for the
265
+ * full contract.
266
+ */
267
+ visionMode?: ProviderVisionMode;
235
268
  /** Created / updated timestamps (informational) */
236
269
  createdAt: string;
237
270
  updatedAt: string;
@@ -408,6 +441,63 @@ interface ProviderBaseUrlPreset {
408
441
  baseUrl: string;
409
442
  }
410
443
 
444
+ /**
445
+ * Wire protocol implied by a `baseUrl`.
446
+ *
447
+ * Used to disambiguate the same vendor's two coexisting endpoints
448
+ * (OpenAI-compatible vs Anthropic-compatible) when the user picks
449
+ * a baseUrl from the ProvidersTab dropdown. Today the only
450
+ * commonly-ambiguous vendor is **Zhipu / 智谱**:
451
+ *
452
+ * - `https://open.bigmodel.cn/api/paas/v4` → openai
453
+ * - `https://open.bigmodel.cn/api/coding/paas/v4` → openai
454
+ * - `https://open.bigmodel.cn/api/anthropic` → anthropic
455
+ * - `https://api.z.ai/api/paas/v4` → openai
456
+ * - `https://api.z.ai/api/coding/paas/v4` → openai
457
+ * - `https://api.z.ai/api/anthropic` → anthropic
458
+ *
459
+ * The reference plugin (`docs/references/GLM-for-copilot-main`)
460
+ * encodes this as an `EndpointPreset` enum literal; we encode it
461
+ * as a path heuristic on the baseUrl. Trade-off: a typo'd path
462
+ * that says "anthropic" would mis-classify, but the same
463
+ * `PROVIDER_BASE_URL_PRESETS.zhipu` dropdown that exposes the
464
+ * Anthropic option ALSO labels it `国内 · Coding Plan · Anthropic 协议`
465
+ * so the user has visual confirmation; a typo in path without
466
+ * matching dropdown is unlikely.
467
+ *
468
+ * Detection rule: a `/anthropic` (or `/anthropic/...`) segment
469
+ * anywhere in the URL **path** — case-insensitive. Hostname
470
+ * matches (e.g. `api.anthropic.com`) are intentionally ignored:
471
+ * we do not currently support routing to Anthropic's own
472
+ * production API (their models are first-class VSCode features).
473
+ */
474
+ type ProviderWireProtocol = "openai" | "anthropic";
475
+ declare function protocolForBaseUrl(baseUrl: string): ProviderWireProtocol;
476
+ /**
477
+ * Resolve the actual `ProviderType` whose adapter should handle a
478
+ * request with the given `configuredType` + `baseUrl`.
479
+ *
480
+ * Most of the time this is just `configuredType`. The exception is
481
+ * the named `zhipu` provider with an Anthropic-protocol baseUrl
482
+ * (`/api/anthropic`); we route it through the `anthropic-compatible`
483
+ * adapter so the URL construction appends `/v1/messages` instead of
484
+ * the OpenAI `/v1/chat/completions`. Without this, the OpenAIAdapter
485
+ * would build `.../api/anthropic/chat/completions` and GLM would
486
+ * 404 (the Anthropic-compatible endpoint only serves
487
+ * `.../api/anthropic/v1/messages`).
488
+ *
489
+ * `minimax` is intentionally NOT in the override list because the
490
+ * curated preset is `https://api.minimaxi.com/anthropic` (already
491
+ * Anthropic-protocol), and the `minimax` case in the adapter
492
+ * factory already wires AnthropicAdapter unconditionally.
493
+ *
494
+ * Everything else (deepseek / kimi / stepfun / agnes / openrouter /
495
+ * novita / openai-compatible / anthropic-compatible) returns
496
+ * `configuredType` unchanged — these vendors don't publish an
497
+ * alternate-protocol endpoint on the same host.
498
+ */
499
+ declare function effectiveAdapterType(configuredType: ProviderType, baseUrl: string): ProviderType;
500
+
411
501
  /**
412
502
  * Provider-type → known baseUrl candidates (e.g. mainland-China vs.
413
503
  * global endpoints for the same vendor, like Agnes/MiniMax/DeepSeek).
@@ -1391,4 +1481,4 @@ declare function asAbortSignal(input: unknown): AbortSignal | undefined;
1391
1481
  */
1392
1482
  declare function safeJson<T>(text: string, fallback: T): T;
1393
1483
 
1394
- export { type AIModelConfig, type AIModelInfo, type AgentPermissionSummary, type AgentToolPermission, type AgentToolRiskLevel, BUILTIN_PROVIDER_PRESETS, type BalanceEntry, type BridgeLinkMode, type BridgeLinkedSkill, type BridgeRepoEntry, type BridgeRepoSyncPull, type BridgeSkillKind, type BridgeSkillRepoEntry, type BridgeSkillRepoFile, type ByomProviderToggles, ByomSettingsResponse, type ByomSettingsSnapshot, type ByomTogglePayload, CERTIFICATE_BUNDLE_FORMATS, CachedServerUrlResponse, type CachedServerUrlSnapshot, type CertificateBundleEnvironmentSupport, type CertificateBundleFormat, type CertificateBundleFormatDescriptor, type CodingPlanUsage, type CommandPayload, type CuratedModelMetadata, type DeepseekBalanceEntry, type DeepseekUsage, type DownloadCertificateBundleRequest, type DownloadCertificateBundleResponse, GIT_REMOTE_HOST_ALIASES, type GenericBalanceUsage, GetByomSettings, GetCachedServerUrl, GetServerProxyState, GetUtilityModels, type GitHubOrgMembershipCheckResult, type GitHubOrgMembershipStatus, type GitHubUser, type GithubCopilotCliPayload, type HttpRequestPayload, type ILogger, type LinkedSkillPayloadEntry, LogLevel, MODEL_METADATA, type MinimaxUsage, type ModelDetail, type ModelPriceCategory, type ModelPricing, type ModelThinkingSchema, PROVIDER_BASE_URL_PRESETS, PROVIDER_CACHE_CONTROL_METADATA, type ProviderBaseUrlPreset, type ProviderCacheControlMetadata, type ProviderConfig, type ProviderModel, type ProviderMutationPayload, type ProviderTestResult, type ProviderType, type ProviderUsageData, type ProviderUsageKind, type ProviderUsageResult, type ProvidersResponsePayload, type PublicProvider, type ScheduledTask, type ScheduledTaskType, type ScheduledTaskV1, type ScheduledTasksConfig, type ScheduledTasksLogFile, type ServerProxyAllowOverridePayload, type ServerProxySnapshot, ServerProxyStateResponse, type ServerProxySupportMode, type ServerProxyTogglePayload, SetCacheControlEnabled, SetServerProxyAllowOverride, SetServerProxyEnabled, type ShellPayload, type TaskExecutionLog, type TaskExecutionState, type TaskExecutionStatus, type TaskPayload, type TaskRunStatus, type TaskWorkspaceRef, UpdateUtilityModels, type UpdateUtilityModelsPayload, type UsageWindow, type UtilityModelScope, type UtilityModelsEffective, UtilityModelsResponse, type UtilityModelsSnapshot, type UtilityModelsSource, type WebviewInboundMessage, WebviewMessageType, __internal, asAbortSignal, buildGitHubLocalEmail, checkGitHubOrgMembership, createConsoleLogger, currencyForBaseUrl, fetchGitHubUser, getBuiltinProviderPreset, getGitHubOrgMembership, getProviderBaseUrlPresets, isGitHubLocalEmail, isProviderCacheControlAware, isValidCanonicalSlug, lookupModelMetadata, normalizeCanonicalSlug, normalizeErrorForLog, normalizeGitUrl, parsePayload, resolvePrimaryEmail, safeJson };
1484
+ export { type AIModelConfig, type AIModelInfo, type AgentPermissionSummary, type AgentToolPermission, type AgentToolRiskLevel, BUILTIN_PROVIDER_PRESETS, type BalanceEntry, type BridgeLinkMode, type BridgeLinkedSkill, type BridgeRepoEntry, type BridgeRepoSyncPull, type BridgeSkillKind, type BridgeSkillRepoEntry, type BridgeSkillRepoFile, type ByomProviderToggles, ByomSettingsResponse, type ByomSettingsSnapshot, type ByomTogglePayload, CERTIFICATE_BUNDLE_FORMATS, CachedServerUrlResponse, type CachedServerUrlSnapshot, type CertificateBundleEnvironmentSupport, type CertificateBundleFormat, type CertificateBundleFormatDescriptor, type CodingPlanUsage, type CommandPayload, type CuratedModelMetadata, type DeepseekBalanceEntry, type DeepseekUsage, type DownloadCertificateBundleRequest, type DownloadCertificateBundleResponse, GIT_REMOTE_HOST_ALIASES, type GenericBalanceUsage, GetByomSettings, GetCachedServerUrl, GetServerProxyState, GetUtilityModels, type GitHubOrgMembershipCheckResult, type GitHubOrgMembershipStatus, type GitHubUser, type GithubCopilotCliPayload, type HttpRequestPayload, type ILogger, type LinkedSkillPayloadEntry, LogLevel, MODEL_METADATA, type MinimaxUsage, type ModelDetail, type ModelPriceCategory, type ModelPricing, type ModelThinkingSchema, PROVIDER_BASE_URL_PRESETS, PROVIDER_CACHE_CONTROL_METADATA, type ProviderBaseUrlPreset, type ProviderCacheControlMetadata, type ProviderConfig, type ProviderModel, type ProviderMutationPayload, type ProviderTestResult, type ProviderType, type ProviderUsageData, type ProviderUsageKind, type ProviderUsageResult, type ProviderVisionMode, type ProviderWireProtocol, type ProvidersResponsePayload, type PublicProvider, type ScheduledTask, type ScheduledTaskType, type ScheduledTaskV1, type ScheduledTasksConfig, type ScheduledTasksLogFile, type ServerProxyAllowOverridePayload, type ServerProxySnapshot, ServerProxyStateResponse, type ServerProxySupportMode, type ServerProxyTogglePayload, SetCacheControlEnabled, SetServerProxyAllowOverride, SetServerProxyEnabled, type ShellPayload, type TaskExecutionLog, type TaskExecutionState, type TaskExecutionStatus, type TaskPayload, type TaskRunStatus, type TaskWorkspaceRef, UpdateUtilityModels, type UpdateUtilityModelsPayload, type UsageWindow, type UtilityModelScope, type UtilityModelsEffective, UtilityModelsResponse, type UtilityModelsSnapshot, type UtilityModelsSource, type WebviewInboundMessage, WebviewMessageType, __internal, asAbortSignal, buildGitHubLocalEmail, checkGitHubOrgMembership, createConsoleLogger, currencyForBaseUrl, effectiveAdapterType, fetchGitHubUser, getBuiltinProviderPreset, getGitHubOrgMembership, getProviderBaseUrlPresets, isGitHubLocalEmail, isProviderCacheControlAware, isValidCanonicalSlug, lookupModelMetadata, normalizeCanonicalSlug, normalizeErrorForLog, normalizeGitUrl, parsePayload, protocolForBaseUrl, resolvePrimaryEmail, safeJson };
package/dist/index.js CHANGED
@@ -46,6 +46,7 @@ __export(index_exports, {
46
46
  checkGitHubOrgMembership: () => checkGitHubOrgMembership,
47
47
  createConsoleLogger: () => createConsoleLogger,
48
48
  currencyForBaseUrl: () => currencyForBaseUrl,
49
+ effectiveAdapterType: () => effectiveAdapterType,
49
50
  fetchGitHubUser: () => fetchGitHubUser,
50
51
  getBuiltinProviderPreset: () => getBuiltinProviderPreset,
51
52
  getGitHubOrgMembership: () => getGitHubOrgMembership,
@@ -58,11 +59,28 @@ __export(index_exports, {
58
59
  normalizeErrorForLog: () => normalizeErrorForLog,
59
60
  normalizeGitUrl: () => normalizeGitUrl,
60
61
  parsePayload: () => parsePayload,
62
+ protocolForBaseUrl: () => protocolForBaseUrl,
61
63
  resolvePrimaryEmail: () => resolvePrimaryEmail,
62
64
  safeJson: () => safeJson
63
65
  });
64
66
  module.exports = __toCommonJS(index_exports);
65
67
 
68
+ // src/ai/protocol.ts
69
+ function protocolForBaseUrl(baseUrl) {
70
+ try {
71
+ const url = new URL(baseUrl);
72
+ return /(^|\/)anthropic(\/|$)/i.test(url.pathname) ? "anthropic" : "openai";
73
+ } catch {
74
+ return "openai";
75
+ }
76
+ }
77
+ function effectiveAdapterType(configuredType, baseUrl) {
78
+ if (configuredType === "zhipu" && protocolForBaseUrl(baseUrl) === "anthropic") {
79
+ return "anthropic-compatible";
80
+ }
81
+ return configuredType;
82
+ }
83
+
66
84
  // src/ai/providers.base-url.ts
67
85
  var PROVIDER_BASE_URL_PRESETS = {
68
86
  "openai-compatible": [],
@@ -77,19 +95,48 @@ var PROVIDER_BASE_URL_PRESETS = {
77
95
  { label: "\u5168\u7403", baseUrl: "https://api.moonshot.ai/v1" }
78
96
  ],
79
97
  zhipu: [
80
- // Zhipu's OpenAI-compatible Chat Completions endpoint is the
81
- // `/api/paas/v4` path on `open.bigmodel.cn` (per
82
- // https://docs.bigmodel.cn/cn/guide/develop/http/introduction
83
- // "请求端点(通用API)"). Earlier entries on this dropdown were
84
- // wrong:
85
- // - `/api/agent` is Zhipu's *Agent* (intelligent-agent) API
86
- // surface, not chat completions sending GLM model ids
87
- // there returns 4xx.
88
- // - `api.zhipuai.com/v1` was the v3-era host and has since
89
- // been migrated to `bigmodel.cn`.
90
- // Zhipu does not publish a separate regional endpoint, so only
91
- // the official host is offered here (single-entry dropdown).
92
- { label: "\u5B98\u65B9", baseUrl: "https://open.bigmodel.cn/api/paas/v4" }
98
+ // Zhipu / 智谱 GLM 6 endpoint paths × 2 hosts. The 4
99
+ // "credential channels" the GLM-for-copilot reference
100
+ // distinguishes (region × apiMode each with its own API
101
+ // key) collapse to a 6-row baseUrl dropdown here because we
102
+ // keep one API key per provider, not one per channel. The
103
+ // user picks the host + path that matches the API key
104
+ // they actually have; the curated `MODEL_METADATA` prices
105
+ // are host-based (CNY vs USD via `currencyForBaseUrl`).
106
+ //
107
+ // Source: https://bigmodel.cn/pricing (CN platform, CNY) +
108
+ // https://z.ai/pricing (international, USD). The 6 paths
109
+ // map to:
110
+ // - `/api/paas/v4` → 标准 API (Standard)
111
+ // - `/api/coding/paas/v4` → Coding Plan (订阅套餐)
112
+ // - `/api/anthropic` → Anthropic 兼容协议
113
+ //
114
+ // Earlier single-entry dropdown omitted the Coding Plan
115
+ // path and the international Z.ai host entirely — users on
116
+ // the Coding Plan subscription were 404'ing because they
117
+ // pasted `open.bigmodel.cn/api/paas/v4` into a Coding Plan
118
+ // key, and Z.ai users had no preset to pick.
119
+ // ── 国内 (open.bigmodel.cn — CNY) ───────────────────────
120
+ { label: "\u56FD\u5185 \xB7 \u6807\u51C6 API", baseUrl: "https://open.bigmodel.cn/api/paas/v4" },
121
+ { label: "\u56FD\u5185 \xB7 Coding Plan", baseUrl: "https://open.bigmodel.cn/api/coding/paas/v4" },
122
+ // 重要:Anthropic 协议端点 **复用** Coding Plan 的 key(与
123
+ // `/api/coding/paas/v4` 共用同一凭证;不是 Standard API key,
124
+ // 也没有独立的 "Anthropic API key")。
125
+ // Reference: `docs/references/GLM-for-copilot-main/src/i18n.ts:578-579`
126
+ // "Coding Plan and Standard API credentials are independent.
127
+ // OpenAI and Anthropic endpoints in the same region share
128
+ // the Coding Plan key."
129
+ // label 故意重复 "Coding Plan" 两次,让用户从下拉里一眼看出:
130
+ // (a) 这个端点**只能配 Coding Plan key**;
131
+ // (b) 这是 Coding Plan 的**协议变体**,不是 Standard API 的。
132
+ {
133
+ label: "\u56FD\u5185 \xB7 Coding Plan \xB7 Anthropic \u534F\u8BAE",
134
+ baseUrl: "https://open.bigmodel.cn/api/anthropic"
135
+ },
136
+ // ── 国际 (api.z.ai — USD) ───────────────────────────────
137
+ { label: "\u56FD\u9645 \xB7 \u6807\u51C6 API", baseUrl: "https://api.z.ai/api/paas/v4" },
138
+ { label: "\u56FD\u9645 \xB7 Coding Plan", baseUrl: "https://api.z.ai/api/coding/paas/v4" },
139
+ { label: "\u56FD\u9645 \xB7 Coding Plan \xB7 Anthropic \u534F\u8BAE", baseUrl: "https://api.z.ai/api/anthropic" }
93
140
  ],
94
141
  stepfun: [{ label: "\u5B98\u65B9", baseUrl: "https://api.stepfun.com/v1" }],
95
142
  siliconflow: [
@@ -169,8 +216,17 @@ var PRIMARY_METADATA = {
169
216
  detail: "M2.7 high-speed: same quality, faster (~100 TPS)",
170
217
  imageInput: false,
171
218
  toolCalling: true,
219
+ // Per https://minimax-ai.chat/pricing (2026-07 verified):
220
+ // M2.7-highspeed is 2× M2.7 base on input/output, but
221
+ // identical on cache hit (same model + same infra, just a
222
+ // serving-side TPS bump). The CNY values mirror USD at the
223
+ // project's 1:7 CNY-per-USD convention.
224
+ // Previously the CNY input/output were the same as base
225
+ // (¥2.1 / ¥8.4) while USD was already 2× — that left the
226
+ // USD/CNY ratio at 3.5× instead of 7× and silently
227
+ // under-reported CNY cost for users on the China platform.
172
228
  pricingUSD: { input: 0.6, output: 2.4, cacheRead: 0.06 },
173
- pricingCNY: { input: 2.1, output: 8.4, cacheRead: 0.42 },
229
+ pricingCNY: { input: 4.2, output: 16.8, cacheRead: 0.42 },
174
230
  priceCategory: "low",
175
231
  // Inherits M2.7's context window.
176
232
  maxInputTokens: 131072,
@@ -180,8 +236,20 @@ var PRIMARY_METADATA = {
180
236
  detail: "Fast, general-purpose model",
181
237
  imageInput: true,
182
238
  toolCalling: true,
183
- pricingUSD: { input: 0.14, output: 0.28, cacheRead: 28e-4 },
184
- pricingCNY: { input: 1, output: 2, cacheRead: 0.02 },
239
+ // Per https://api-docs.deepseek.com/quick_start/pricing/ and
240
+ // https://new.qq.com/rain/a/20260813A0DROS00 (2026-08-13
241
+ // announcement, effective 2026-08-17 00:00 Beijing): peak/
242
+ // off-peak tiered pricing. Pinned the OFF-PEAK rate since
243
+ // peak hours (01:00–04:00 + 06:00–10:00 UTC = 09:00–12:00 +
244
+ // 14:00–18:00 Beijing) cover only 8 of 24 hours — most chat
245
+ // sessions land off-peak. Peak is exactly 2× off-peak per
246
+ // the official page.
247
+ // Off-peak: $0.007 cache hit / $0.22 input / $0.66 output
248
+ // ¥0.05 cache hit / ¥1.5 input / ¥4.5 output
249
+ // The pre-2026-08-17 rate was 1/3 of the current off-peak;
250
+ // 8/17 调价 raised cache hit 6× and output 2.25×.
251
+ pricingUSD: { input: 0.22, output: 0.66, cacheRead: 7e-3 },
252
+ pricingCNY: { input: 1.5, output: 4.5, cacheRead: 0.05 },
185
253
  priceCategory: "low",
186
254
  // Official docs (api-docs.deepseek.com/quick_start/pricing, fetched
187
255
  // 2026-07-27): "THINKING MODE: Supports both non-thinking and
@@ -197,8 +265,20 @@ var PRIMARY_METADATA = {
197
265
  detail: "Most capable reasoning model",
198
266
  imageInput: true,
199
267
  toolCalling: true,
200
- pricingUSD: { input: 0.435, output: 0.87, cacheRead: 3625e-6 },
201
- pricingCNY: { input: 2.1, output: 4.2, cacheRead: 0.025 },
268
+ // Per https://api-docs.deepseek.com/quick_start/pricing/ and
269
+ // https://new.qq.com/rain/a/20260813A0DROS00 (2026-08-13
270
+ // announcement, effective 2026-08-17 00:00 Beijing): peak/
271
+ // off-peak tiered pricing. Pinned the OFF-PEAK rate (peak
272
+ // hours are 8/24; most chat sessions land off-peak; peak is
273
+ // exactly 2× off-peak per the official page).
274
+ // Off-peak: $0.022 cache hit / $0.66 input / $1.98 output
275
+ // ¥0.15 cache hit / ¥4.5 input / ¥13.5 output
276
+ // The 8/17 调价 raised cache hit 6× (¥0.025 → ¥0.15),
277
+ // input 1.5×, and output 2.25×. The pre-08-17 USD values
278
+ // (0.435/0.87/0.003625) and CNY values (2.1/4.2/0.025) did
279
+ // not correspond to any DeepSeek-published rate; corrected.
280
+ pricingUSD: { input: 0.66, output: 1.98, cacheRead: 0.022 },
281
+ pricingCNY: { input: 4.5, output: 13.5, cacheRead: 0.15 },
202
282
  priceCategory: "low",
203
283
  thinkingSchema: "thinkingEnabled",
204
284
  maxInputTokens: 655360,
@@ -326,10 +406,14 @@ var PRIMARY_METADATA = {
326
406
  // GLM-5's explicit "Agentic 长程规划与执行" description. Corrected
327
407
  // from false (inconsistent with the rest of the GLM-5 family).
328
408
  "glm-5.2": {
329
- detail: "GLM-5.2 \u2014 1M \u4E0A\u4E0B\u6587\uFF0C\u6700\u5927\u8F93\u51FA 128K",
409
+ detail: "GLM-5.2 \u2014 1M \u4E0A\u4E0B\u6587\uFF0C\u6700\u5927\u8F93\u51FA 128K\uFF08\u5355\u6863 pricing\uFF09",
330
410
  imageInput: false,
331
411
  toolCalling: true,
332
- // ¥8 input / ¥28 output / ¥2 cache hit per 1M tokens (输入长度 32K+ 档)
412
+ // Single rate (no input-length tier split) per
413
+ // bigmodel.cn/pricing 2026-08-18:
414
+ // ¥8 input / ¥28 output / ¥2 cache hit per 1M tokens
415
+ // The previous entry's comment said "输入长度 32K+ 档" — that
416
+ // was wrong: GLM-5.2 has no tier split on the official page.
333
417
  pricingUSD: { input: 1.12, output: 3.92, cacheRead: 0.28 },
334
418
  pricingCNY: { input: 8, output: 28, cacheRead: 2 },
335
419
  priceCategory: "high",
@@ -364,74 +448,91 @@ var PRIMARY_METADATA = {
364
448
  // (model id `glm-5.1-highspeed`). Pricing mirrors GLM-5.1 since the
365
449
  // rate is identical architecture — TileRT is a serving-side optim.
366
450
  "glm-5.1-highspeed": {
367
- detail: "GLM-5.1 HighSpeed \u2014 400 TPS \u9AD8\u541E\u5410\u751F\u4EA7\u53D8\u4F53",
451
+ detail: "GLM-5.1 HighSpeed \u2014 400 TPS \u9AD8\u541E\u5410\u751F\u4EA7\u53D8\u4F53\uFF08[0, 32K) tier \u955C\u50CF GLM-5.1\uFF09",
368
452
  imageInput: false,
369
453
  toolCalling: true,
454
+ // Mirrors GLM-5.1 [0, 32K) tier per bigmodel.cn/pricing 2026-08-18.
455
+ // TileRT is a serving-side optim; the per-token rate is the same
456
+ // architecture as the base model.
370
457
  pricingUSD: { input: 0.6, output: 2.2, cacheRead: 0.11 },
371
- pricingCNY: { input: 4.3, output: 15.7, cacheRead: 0.79 },
458
+ pricingCNY: { input: 6, output: 24, cacheRead: 1.3 },
372
459
  priceCategory: "medium",
373
460
  maxInputTokens: 2e5,
374
461
  maxOutputTokens: 128e3
375
462
  },
376
- // GLM-4.7-Flash (2026-01-19) — free-tier version of GLM-4.7, lightweight
377
- // + high-frequency optimised. Coding / writing / translation /
378
- // reasoning at "best-in-class-for-its-size" per the Zhipu release notes;
379
- // the "Flash" tier is distinct from `glm-4.7-flashx` (the latter is the
380
- // 快速版 without tool calling; this Flash is the full-feature lite).
463
+ // GLM-4.7-Flash (2026-01-19) — 200K context, fully-free tier on
464
+ // bigmodel.cn/pricing (fetched 2026-08-18). Lightweight + high-
465
+ // frequency optimised; coding / writing / translation / reasoning
466
+ // at "best-in-class-for-its-size" per the Zhipu release notes.
467
+ // Distinct from `glm-4.7-flashx` (the latter is the 快速版 with
468
+ // paid pricing).
381
469
  "glm-4.7-flash": {
382
- detail: "GLM-4.7 Flash \u2014 \u8F7B\u91CF\u514D\u8D39\u7248\uFF0C200K \u4E0A\u4E0B\u6587",
470
+ detail: "GLM-4.7 Flash \u2014 \u5B8C\u5168\u514D\u8D39\uFF08200K \u4E0A\u4E0B\u6587\uFF09",
383
471
  imageInput: false,
384
472
  toolCalling: true,
385
- // Free tier — public pricing page lists the model as "免费" with no
386
- // input/output rate. Numbers below are conservative estimates based
387
- // on the GLM-3-Turbo "入门级 ¥1/1M tokens" reference; the provider
388
- // has not published a cache rate either, so cacheRead is null.
389
- pricingUSD: { input: 0.06, output: 0.21, cacheRead: null },
390
- pricingCNY: { input: 0.4, output: 1.5, cacheRead: null },
473
+ // Free tier — input / output / cache hit all 0 (bigmodel.cn
474
+ // 2026-08-18 lists "免费" for every column). USD mirrors CNY
475
+ // rather than inventing a rate.
476
+ pricingUSD: { input: 0, output: 0, cacheRead: 0 },
477
+ pricingCNY: { input: 0, output: 0, cacheRead: 0 },
391
478
  priceCategory: "low",
392
479
  maxInputTokens: 2e5,
393
480
  maxOutputTokens: 128e3
394
481
  },
395
482
  "glm-4.7": {
396
- detail: "200K \u4E0A\u4E0B\u6587\uFF0C\u5DE5\u5177\u8C03\u7528",
483
+ detail: "GLM-4.7 \u2014 200K \u4E0A\u4E0B\u6587\uFF0C\u5DE5\u5177\u8C03\u7528\uFF083-tier pricing\uFF09",
397
484
  imageInput: false,
398
485
  toolCalling: true,
399
- // cc-switch 标价:$0.6 input / $2.2 output
400
- pricingUSD: { input: 0.6, output: 2.2, cacheRead: 0.11 },
401
- pricingCNY: { input: 4.3, output: 15.7, cacheRead: 0.79 },
486
+ // Pinned the LOWEST tier per bigmodel.cn/pricing 2026-08-18:
487
+ // [0, 32K) input × [0, 0.2K) output — ¥2 / ¥8 / ¥0.4 cache hit
488
+ // [0, 32K) input × [0.2K+) output ¥3 / ¥14 / ¥0.6 cache hit
489
+ // [32K, 200K) input — ¥4 / ¥16 / ¥0.8 cache hit
490
+ // Most real prompts are < 32K input and < 0.2K output, so the
491
+ // lowest tier is the most representative per-request price.
492
+ // Re-pick from a higher tier if the picker adds a length slider.
493
+ pricingUSD: { input: 0.28, output: 1.12, cacheRead: 0.056 },
494
+ pricingCNY: { input: 2, output: 8, cacheRead: 0.4 },
402
495
  priceCategory: "medium",
403
496
  maxInputTokens: 2e5,
404
497
  maxOutputTokens: 128e3
405
498
  },
406
499
  "glm-5.1": {
407
- detail: "GLM-5.1 \u2014 200K \u4E0A\u4E0B\u6587\uFF0C\u6700\u5927\u8F93\u51FA 128K",
500
+ detail: "GLM-5.1 \u2014 200K \u4E0A\u4E0B\u6587\uFF0C\u6700\u5927\u8F93\u51FA 128K\uFF082-tier pricing\uFF09",
408
501
  imageInput: false,
409
502
  toolCalling: true,
410
- // ¥8 input / ¥28 output / ¥2 cache hit per 1M tokens (输入长度 32K+ 档)
411
- pricingUSD: { input: 1.12, output: 3.92, cacheRead: 0.28 },
412
- pricingCNY: { input: 8, output: 28, cacheRead: 2 },
503
+ // Pinned the LOWER tier per bigmodel.cn/pricing 2026-08-18:
504
+ // [0, 32K) — ¥6 input / ¥24 output / ¥1.3 cache hit
505
+ // [32K+) — ¥8 input / ¥28 output / ¥2 cache hit
506
+ // The previous entry had the higher tier; switched to the lower
507
+ // tier so a typical < 32K prompt shows the more accurate price.
508
+ pricingUSD: { input: 0.84, output: 3.36, cacheRead: 0.182 },
509
+ pricingCNY: { input: 6, output: 24, cacheRead: 1.3 },
413
510
  priceCategory: "high",
414
511
  maxInputTokens: 2e5,
415
512
  maxOutputTokens: 128e3
416
513
  },
417
514
  "glm-5": {
418
- detail: "GLM-5 \u2014 200K \u4E0A\u4E0B\u6587\uFF0CAgentic \u5DE5\u5177\u8C03\u7528\uFF0C\u6700\u5927\u8F93\u51FA 128K",
515
+ detail: "GLM-5 \u2014 200K \u4E0A\u4E0B\u6587\uFF0CAgentic \u5DE5\u5177\u8C03\u7528\uFF0C\u6700\u5927\u8F93\u51FA 128K\uFF082-tier pricing\uFF09",
419
516
  imageInput: false,
420
517
  toolCalling: true,
421
- // ¥6 input / ¥22 output / ¥1.5 cache hit per 1M tokens (输入长度 32K+ 档)
422
- pricingUSD: { input: 0.84, output: 3.08, cacheRead: 0.21 },
423
- pricingCNY: { input: 6, output: 22, cacheRead: 1.5 },
518
+ // Pinned the LOWER tier per bigmodel.cn/pricing 2026-08-18:
519
+ // [0, 32K) — ¥4 input / ¥18 output / ¥1 cache hit
520
+ // [32K+) — ¥6 input / ¥22 output / ¥1.5 cache hit
521
+ pricingUSD: { input: 0.56, output: 2.52, cacheRead: 0.14 },
522
+ pricingCNY: { input: 4, output: 18, cacheRead: 1 },
424
523
  priceCategory: "high",
425
524
  maxInputTokens: 2e5,
426
525
  maxOutputTokens: 128e3
427
526
  },
428
527
  "glm-5-turbo": {
429
- detail: "GLM-5 Turbo \u2014 200K \u4E0A\u4E0B\u6587\uFF0C\u6700\u5927\u8F93\u51FA 128K",
528
+ detail: "GLM-5 Turbo \u2014 200K \u4E0A\u4E0B\u6587\uFF0C\u6700\u5927\u8F93\u51FA 128K\uFF082-tier pricing\uFF09",
430
529
  imageInput: false,
431
530
  toolCalling: true,
432
- // ¥7 input / ¥26 output / ¥1.8 cache hit per 1M tokens (输入长度 32K+ 档)
433
- pricingUSD: { input: 0.98, output: 3.64, cacheRead: 0.252 },
434
- pricingCNY: { input: 7, output: 26, cacheRead: 1.8 },
531
+ // Pinned the LOWER tier per bigmodel.cn/pricing 2026-08-18:
532
+ // [0, 32K) — ¥5 input / ¥22 output / ¥1.2 cache hit
533
+ // [32K+) — ¥7 input / ¥26 output / ¥1.8 cache hit
534
+ pricingUSD: { input: 0.7, output: 3.08, cacheRead: 0.168 },
535
+ pricingCNY: { input: 5, output: 22, cacheRead: 1.2 },
435
536
  priceCategory: "medium",
436
537
  maxInputTokens: 2e5,
437
538
  maxOutputTokens: 128e3
@@ -479,23 +580,34 @@ var PRIMARY_METADATA = {
479
580
  maxOutputTokens: 96e3
480
581
  },
481
582
  "glm-4.5-air": {
482
- detail: "GLM-4.5 Air \u2014 \u5DE5\u5177\u8C03\u7528",
583
+ detail: "GLM-4.5 Air \u2014 \u5DE5\u5177\u8C03\u7528\uFF083-tier pricing\uFF09",
483
584
  imageInput: false,
484
585
  toolCalling: true,
485
- pricingUSD: { input: 0, output: 0, cacheRead: null },
486
- pricingCNY: { input: 0, output: 0, cacheRead: null },
586
+ // Pinned the LOWEST tier per bigmodel.cn/pricing 2026-08-18:
587
+ // [0, 32K) × [0, 0.2K) output — ¥0.8 / ¥2 / ¥0.16 cache hit
588
+ // [0, 32K) × [0.2K+) output — ¥0.8 / ¥6 / ¥0.16 cache hit
589
+ // [32K, 128K) — ¥1.2 / ¥8 / ¥0.24 cache hit
590
+ // All cache-hit rates are 4× lower than input — the
591
+ // explicit-cache-discount half of BYOM-depth #1.
592
+ pricingUSD: { input: 0.112, output: 0.28, cacheRead: 0.0224 },
593
+ pricingCNY: { input: 0.8, output: 2, cacheRead: 0.16 },
487
594
  priceCategory: "low",
488
595
  maxInputTokens: 128e3,
489
596
  maxOutputTokens: 96e3
490
597
  },
491
598
  "glm-4.5-airx": {
492
- detail: "GLM-4.5 AirX \u2014 \u5FEB\u901F\u7248",
599
+ detail: "GLM-4.5 AirX \u2014 \u5FEB\u901F\u7248\uFF08\xA510/M \u5355\u6863\uFF09",
493
600
  imageInput: false,
494
601
  toolCalling: false,
495
- pricingUSD: { input: 0, output: 0, cacheRead: null },
496
- pricingCNY: { input: 0, output: 0, cacheRead: null },
602
+ // ¥10 / M tokens (single rate, input == output) per
603
+ // bigmodel.cn/pricing 2026-08-18 listed under the "模型推理
604
+ // → Language Models" sub-tab, NOT the flagship text section.
605
+ // 8K context window per the same sub-tab; 96K max output is a
606
+ // best-guess from sibling Air-tier models.
607
+ pricingUSD: { input: 1.4, output: 1.4, cacheRead: null },
608
+ pricingCNY: { input: 10, output: 10, cacheRead: null },
497
609
  priceCategory: "low",
498
- maxInputTokens: 128e3,
610
+ maxInputTokens: 8192,
499
611
  maxOutputTokens: 96e3
500
612
  },
501
613
  "glm-4-long": {
@@ -532,24 +644,29 @@ var PRIMARY_METADATA = {
532
644
  maxOutputTokens: 4e3
533
645
  },
534
646
  "glm-4.5v": {
535
- detail: "GLM-4.5V \u89C6\u89C9\u63A8\u7406\u6A21\u578B \u2014 \u56FE\u50CF/\u89C6\u9891/\u6587\u6863/GUI",
647
+ detail: "GLM-4.5V \u89C6\u89C9\u63A8\u7406\u6A21\u578B \u2014 \u56FE\u50CF/\u89C6\u9891/\u6587\u6863/GUI\uFF082-tier pricing\uFF09",
536
648
  imageInput: true,
537
649
  toolCalling: true,
538
- pricingUSD: { input: 0, output: 0, cacheRead: null },
539
- pricingCNY: { input: 0, output: 0, cacheRead: null },
650
+ // Pinned the LOWER tier per bigmodel.cn/pricing 2026-08-18:
651
+ // [0, 32K) — ¥2 input / ¥6 output / ¥0.4 cache hit
652
+ // [32, 64K) — ¥4 input / ¥12 output / ¥0.8 cache hit
653
+ pricingUSD: { input: 0.28, output: 0.84, cacheRead: 0.056 },
654
+ pricingCNY: { input: 2, output: 6, cacheRead: 0.4 },
540
655
  priceCategory: "medium",
541
- maxInputTokens: 128e3,
656
+ maxInputTokens: 64e3,
542
657
  maxOutputTokens: 8192
543
658
  },
544
659
  "glm-5v-turbo": {
545
- detail: "GLM-5V Turbo \u2014 \u591A\u6A21\u6001 Coding \u6A21\u578B",
660
+ detail: "GLM-5V Turbo \u2014 \u591A\u6A21\u6001 Coding \u6A21\u578B\uFF082-tier pricing\uFF09",
546
661
  imageInput: true,
547
662
  toolCalling: true,
548
- pricingUSD: { input: 0, output: 0, cacheRead: null },
549
- pricingCNY: { input: 0, output: 0, cacheRead: null },
663
+ // Pinned the LOWER tier per bigmodel.cn/pricing 2026-08-18:
664
+ // [0, 32K) — ¥5 input / ¥22 output / ¥1.2 cache hit
665
+ // [32K+) — ¥7 input / ¥26 output / ¥1.8 cache hit
666
+ // Vendor-published context: 200K / 128K max output.
667
+ pricingUSD: { input: 0.7, output: 3.08, cacheRead: 0.168 },
668
+ pricingCNY: { input: 5, output: 22, cacheRead: 1.2 },
550
669
  priceCategory: "medium",
551
- // Official model overview: 200K context / 128K max output
552
- // (previously mis-set to 128K/8_192 — corrected 2026-07-27).
553
670
  maxInputTokens: 2e5,
554
671
  maxOutputTokens: 128e3
555
672
  },
@@ -577,8 +694,15 @@ var PRIMARY_METADATA = {
577
694
  // Official model page lists "🛠️ 工具调用: 可靠的工具调用能力,支持多步
578
695
  // 任务分解与计划执行" as a core capability — was mis-set to false.
579
696
  toolCalling: true,
580
- // ¥1.35 input / ¥8.1 output / ¥0.27 cache hit per 1M tokens
581
- pricingUSD: { input: 0.189, output: 1.134, cacheRead: 0.038 },
697
+ // Per https://platform.stepfun.com/docs/zh/pricing/details
698
+ // (2026-08-18 fetched): ¥1.35 input / ¥8.1 output /
699
+ // ¥0.27 cache hit per 1M tokens, USD = $0.20 / $1.15 /
700
+ // $0.04 (StepFun is USD-billed at the same rate as CNY/7
701
+ // with small rounding per the official pricing page).
702
+ // USD values previously 0.189/1.134/0.038 — slightly off
703
+ // from the official page (rounding error from dividing CNY
704
+ // by hand), corrected.
705
+ pricingUSD: { input: 0.2, output: 1.15, cacheRead: 0.04 },
582
706
  pricingCNY: { input: 1.35, output: 8.1, cacheRead: 0.27 },
583
707
  priceCategory: "medium",
584
708
  thinkingSchema: "reasoningEffort",
@@ -594,8 +718,13 @@ var PRIMARY_METADATA = {
594
718
  // Official model page lists "🛠️ 工具调用: 可靠的 tools / tool_choice
595
719
  // 调用能力" as a core capability — was mis-set to false.
596
720
  toolCalling: true,
597
- // ¥0.7 input / ¥2.1 output / ¥0.14 cache hit per 1M tokens
598
- pricingUSD: { input: 0.098, output: 0.294, cacheRead: 0.02 },
721
+ // Per https://platform.stepfun.com/docs/zh/pricing/details
722
+ // (2026-08-18 fetched): ¥0.7 input / ¥2.1 output /
723
+ // ¥0.14 cache hit per 1M tokens, USD = $0.10 / $0.30 /
724
+ // $0.02. USD values previously 0.098/0.294/0.02 — slightly
725
+ // off from the official page (rounding error), corrected
726
+ // to the exact published values.
727
+ pricingUSD: { input: 0.1, output: 0.3, cacheRead: 0.02 },
599
728
  pricingCNY: { input: 0.7, output: 2.1, cacheRead: 0.14 },
600
729
  priceCategory: "low",
601
730
  thinkingSchema: "reasoningEffort",
@@ -606,9 +735,13 @@ var PRIMARY_METADATA = {
606
735
  detail: "Step 1o Turbo Vision \u2014 \u89C6\u89C9\u6A21\u578B",
607
736
  imageInput: true,
608
737
  toolCalling: false,
609
- // ¥2.5 input / ¥8 output per 1M tokens
610
- pricingUSD: { input: 0.35, output: 1.12, cacheRead: null },
611
- pricingCNY: { input: 2.5, output: 8, cacheRead: null },
738
+ // Per https://platform.stepfun.com/docs/zh/pricing/details
739
+ // (2026-08-18 fetched): ¥2.5 cache miss / ¥0.5 cache hit /
740
+ // ¥8 output per 1M tokens. USD = $0.357 / $0.071 / $1.143
741
+ // (CNY/7 with rounding). Cache hit was previously
742
+ // undocumented in the curated entry — added.
743
+ pricingUSD: { input: 0.357, output: 1.143, cacheRead: 0.071 },
744
+ pricingCNY: { input: 2.5, output: 8, cacheRead: 0.5 },
612
745
  priceCategory: "low",
613
746
  // Official model overview: 32K context window.
614
747
  maxInputTokens: 32768,
@@ -648,8 +781,13 @@ var PRIMARY_METADATA = {
648
781
  detail: "MiniMax M2.5 \u2014 229B MoE, SOTA \u7F16\u7A0B / Agent / \u529E\u516C\u751F\u4EA7\u529B\uFF08192K \u4E0A\u4E0B\u6587\uFF09",
649
782
  imageInput: false,
650
783
  toolCalling: true,
651
- // ¥2.1 / ¥8.4 per 1M tokens; cache hit documented at ¥0.21 (按
652
- // 官方 10% cache 命中率回填)
784
+ // Per https://minimax-ai.chat/pricing (M2.5 legacy line):
785
+ // ¥2.1 input / ¥8.4 output / ¥0.21 cache hit per 1M tokens;
786
+ // USD = $0.30 / $1.20 / $0.03 (cloudprice.net 2026-08-13).
787
+ // Cache hit IS the published rate — the previous comment
788
+ // "按官方 10% cache 命中率回填" was wrong (it implied we
789
+ // were estimating, when actually the cache rate is
790
+ // documented at ¥0.21 / $0.03 per 1M tokens).
653
791
  pricingUSD: { input: 0.3, output: 1.2, cacheRead: 0.03 },
654
792
  pricingCNY: { input: 2.1, output: 8.4, cacheRead: 0.21 },
655
793
  priceCategory: "medium",
@@ -718,10 +856,28 @@ function lookupModelMetadata(modelId) {
718
856
  function currencyForBaseUrl(baseUrl) {
719
857
  try {
720
858
  const hostname = new URL(baseUrl).hostname.toLowerCase();
721
- if (hostname === "api.minimaxi.com" || hostname === "api.minimaxi.cn" || hostname === "api.deepseek.com" || hostname === "api.moonshot.cn" || hostname === "open.bigmodel.cn") {
859
+ if (hostname === "api.minimaxi.com" || hostname === "api.minimaxi.cn" || hostname === "api.deepseek.com" || hostname === "api.moonshot.cn" || hostname === "open.bigmodel.cn" || // Zhipu legacy v3 host. Per the GLM-for-copilot reference
860
+ // (`docs/references/GLM-for-copilot-main/src/endpoint.ts:4`)
861
+ // this was retired to `bigmodel.cn` but is still
862
+ // resolvable for accounts that haven't migrated — we
863
+ // don't surface it in the baseUrl dropdown, but a user
864
+ // may paste it from a saved settings.json, so the
865
+ // currency has to match (CNY, same as the new host).
866
+ hostname === "dev.bigmodel.cn") {
722
867
  return "CNY";
723
868
  }
724
- if (hostname === "api.minimax.io" || hostname === "api.minimaxi.io" || hostname === "api.siliconflow.cn" || hostname === "api.siliconflow.com" || hostname === "api.stepfun.com" || hostname === "openrouter.ai" || hostname === "api.novita.ai") {
869
+ if (hostname === "api.minimax.io" || hostname === "api.minimaxi.io" || hostname === "api.siliconflow.cn" || hostname === "api.siliconflow.com" || hostname === "api.stepfun.com" || hostname === "openrouter.ai" || hostname === "api.novita.ai" || // Z.ai / Zhipu international. Billed in USD per the
870
+ // official `bigmodel.cn/pricing` page (the CNY-billed
871
+ // list is the China-domiciled `open.bigmodel.cn` only;
872
+ // the international `api.z.ai` is USD regardless of
873
+ // which apiMode / protocol path the user picked). The
874
+ // GLM-for-copilot reference uses the same split
875
+ // (`docs/references/GLM-for-copilot-main/src/endpoint.ts:160-173`).
876
+ // Without this explicit entry, `api.z.ai` would still
877
+ // resolve to USD via the catch-all below — adding it
878
+ // here makes the intent grep-able and pins the host
879
+ // list against accidental removal.
880
+ hostname === "api.z.ai") {
725
881
  return "USD";
726
882
  }
727
883
  } catch {
@@ -1507,6 +1663,7 @@ function safeJson(text, fallback) {
1507
1663
  checkGitHubOrgMembership,
1508
1664
  createConsoleLogger,
1509
1665
  currencyForBaseUrl,
1666
+ effectiveAdapterType,
1510
1667
  fetchGitHubUser,
1511
1668
  getBuiltinProviderPreset,
1512
1669
  getGitHubOrgMembership,
@@ -1519,6 +1676,7 @@ function safeJson(text, fallback) {
1519
1676
  normalizeErrorForLog,
1520
1677
  normalizeGitUrl,
1521
1678
  parsePayload,
1679
+ protocolForBaseUrl,
1522
1680
  resolvePrimaryEmail,
1523
1681
  safeJson
1524
1682
  });
package/dist/index.mjs CHANGED
@@ -1,3 +1,19 @@
1
+ // src/ai/protocol.ts
2
+ function protocolForBaseUrl(baseUrl) {
3
+ try {
4
+ const url = new URL(baseUrl);
5
+ return /(^|\/)anthropic(\/|$)/i.test(url.pathname) ? "anthropic" : "openai";
6
+ } catch {
7
+ return "openai";
8
+ }
9
+ }
10
+ function effectiveAdapterType(configuredType, baseUrl) {
11
+ if (configuredType === "zhipu" && protocolForBaseUrl(baseUrl) === "anthropic") {
12
+ return "anthropic-compatible";
13
+ }
14
+ return configuredType;
15
+ }
16
+
1
17
  // src/ai/providers.base-url.ts
2
18
  var PROVIDER_BASE_URL_PRESETS = {
3
19
  "openai-compatible": [],
@@ -12,19 +28,48 @@ var PROVIDER_BASE_URL_PRESETS = {
12
28
  { label: "\u5168\u7403", baseUrl: "https://api.moonshot.ai/v1" }
13
29
  ],
14
30
  zhipu: [
15
- // Zhipu's OpenAI-compatible Chat Completions endpoint is the
16
- // `/api/paas/v4` path on `open.bigmodel.cn` (per
17
- // https://docs.bigmodel.cn/cn/guide/develop/http/introduction
18
- // "请求端点(通用API)"). Earlier entries on this dropdown were
19
- // wrong:
20
- // - `/api/agent` is Zhipu's *Agent* (intelligent-agent) API
21
- // surface, not chat completions sending GLM model ids
22
- // there returns 4xx.
23
- // - `api.zhipuai.com/v1` was the v3-era host and has since
24
- // been migrated to `bigmodel.cn`.
25
- // Zhipu does not publish a separate regional endpoint, so only
26
- // the official host is offered here (single-entry dropdown).
27
- { label: "\u5B98\u65B9", baseUrl: "https://open.bigmodel.cn/api/paas/v4" }
31
+ // Zhipu / 智谱 GLM 6 endpoint paths × 2 hosts. The 4
32
+ // "credential channels" the GLM-for-copilot reference
33
+ // distinguishes (region × apiMode each with its own API
34
+ // key) collapse to a 6-row baseUrl dropdown here because we
35
+ // keep one API key per provider, not one per channel. The
36
+ // user picks the host + path that matches the API key
37
+ // they actually have; the curated `MODEL_METADATA` prices
38
+ // are host-based (CNY vs USD via `currencyForBaseUrl`).
39
+ //
40
+ // Source: https://bigmodel.cn/pricing (CN platform, CNY) +
41
+ // https://z.ai/pricing (international, USD). The 6 paths
42
+ // map to:
43
+ // - `/api/paas/v4` → 标准 API (Standard)
44
+ // - `/api/coding/paas/v4` → Coding Plan (订阅套餐)
45
+ // - `/api/anthropic` → Anthropic 兼容协议
46
+ //
47
+ // Earlier single-entry dropdown omitted the Coding Plan
48
+ // path and the international Z.ai host entirely — users on
49
+ // the Coding Plan subscription were 404'ing because they
50
+ // pasted `open.bigmodel.cn/api/paas/v4` into a Coding Plan
51
+ // key, and Z.ai users had no preset to pick.
52
+ // ── 国内 (open.bigmodel.cn — CNY) ───────────────────────
53
+ { label: "\u56FD\u5185 \xB7 \u6807\u51C6 API", baseUrl: "https://open.bigmodel.cn/api/paas/v4" },
54
+ { label: "\u56FD\u5185 \xB7 Coding Plan", baseUrl: "https://open.bigmodel.cn/api/coding/paas/v4" },
55
+ // 重要:Anthropic 协议端点 **复用** Coding Plan 的 key(与
56
+ // `/api/coding/paas/v4` 共用同一凭证;不是 Standard API key,
57
+ // 也没有独立的 "Anthropic API key")。
58
+ // Reference: `docs/references/GLM-for-copilot-main/src/i18n.ts:578-579`
59
+ // "Coding Plan and Standard API credentials are independent.
60
+ // OpenAI and Anthropic endpoints in the same region share
61
+ // the Coding Plan key."
62
+ // label 故意重复 "Coding Plan" 两次,让用户从下拉里一眼看出:
63
+ // (a) 这个端点**只能配 Coding Plan key**;
64
+ // (b) 这是 Coding Plan 的**协议变体**,不是 Standard API 的。
65
+ {
66
+ label: "\u56FD\u5185 \xB7 Coding Plan \xB7 Anthropic \u534F\u8BAE",
67
+ baseUrl: "https://open.bigmodel.cn/api/anthropic"
68
+ },
69
+ // ── 国际 (api.z.ai — USD) ───────────────────────────────
70
+ { label: "\u56FD\u9645 \xB7 \u6807\u51C6 API", baseUrl: "https://api.z.ai/api/paas/v4" },
71
+ { label: "\u56FD\u9645 \xB7 Coding Plan", baseUrl: "https://api.z.ai/api/coding/paas/v4" },
72
+ { label: "\u56FD\u9645 \xB7 Coding Plan \xB7 Anthropic \u534F\u8BAE", baseUrl: "https://api.z.ai/api/anthropic" }
28
73
  ],
29
74
  stepfun: [{ label: "\u5B98\u65B9", baseUrl: "https://api.stepfun.com/v1" }],
30
75
  siliconflow: [
@@ -104,8 +149,17 @@ var PRIMARY_METADATA = {
104
149
  detail: "M2.7 high-speed: same quality, faster (~100 TPS)",
105
150
  imageInput: false,
106
151
  toolCalling: true,
152
+ // Per https://minimax-ai.chat/pricing (2026-07 verified):
153
+ // M2.7-highspeed is 2× M2.7 base on input/output, but
154
+ // identical on cache hit (same model + same infra, just a
155
+ // serving-side TPS bump). The CNY values mirror USD at the
156
+ // project's 1:7 CNY-per-USD convention.
157
+ // Previously the CNY input/output were the same as base
158
+ // (¥2.1 / ¥8.4) while USD was already 2× — that left the
159
+ // USD/CNY ratio at 3.5× instead of 7× and silently
160
+ // under-reported CNY cost for users on the China platform.
107
161
  pricingUSD: { input: 0.6, output: 2.4, cacheRead: 0.06 },
108
- pricingCNY: { input: 2.1, output: 8.4, cacheRead: 0.42 },
162
+ pricingCNY: { input: 4.2, output: 16.8, cacheRead: 0.42 },
109
163
  priceCategory: "low",
110
164
  // Inherits M2.7's context window.
111
165
  maxInputTokens: 131072,
@@ -115,8 +169,20 @@ var PRIMARY_METADATA = {
115
169
  detail: "Fast, general-purpose model",
116
170
  imageInput: true,
117
171
  toolCalling: true,
118
- pricingUSD: { input: 0.14, output: 0.28, cacheRead: 28e-4 },
119
- pricingCNY: { input: 1, output: 2, cacheRead: 0.02 },
172
+ // Per https://api-docs.deepseek.com/quick_start/pricing/ and
173
+ // https://new.qq.com/rain/a/20260813A0DROS00 (2026-08-13
174
+ // announcement, effective 2026-08-17 00:00 Beijing): peak/
175
+ // off-peak tiered pricing. Pinned the OFF-PEAK rate since
176
+ // peak hours (01:00–04:00 + 06:00–10:00 UTC = 09:00–12:00 +
177
+ // 14:00–18:00 Beijing) cover only 8 of 24 hours — most chat
178
+ // sessions land off-peak. Peak is exactly 2× off-peak per
179
+ // the official page.
180
+ // Off-peak: $0.007 cache hit / $0.22 input / $0.66 output
181
+ // ¥0.05 cache hit / ¥1.5 input / ¥4.5 output
182
+ // The pre-2026-08-17 rate was 1/3 of the current off-peak;
183
+ // 8/17 调价 raised cache hit 6× and output 2.25×.
184
+ pricingUSD: { input: 0.22, output: 0.66, cacheRead: 7e-3 },
185
+ pricingCNY: { input: 1.5, output: 4.5, cacheRead: 0.05 },
120
186
  priceCategory: "low",
121
187
  // Official docs (api-docs.deepseek.com/quick_start/pricing, fetched
122
188
  // 2026-07-27): "THINKING MODE: Supports both non-thinking and
@@ -132,8 +198,20 @@ var PRIMARY_METADATA = {
132
198
  detail: "Most capable reasoning model",
133
199
  imageInput: true,
134
200
  toolCalling: true,
135
- pricingUSD: { input: 0.435, output: 0.87, cacheRead: 3625e-6 },
136
- pricingCNY: { input: 2.1, output: 4.2, cacheRead: 0.025 },
201
+ // Per https://api-docs.deepseek.com/quick_start/pricing/ and
202
+ // https://new.qq.com/rain/a/20260813A0DROS00 (2026-08-13
203
+ // announcement, effective 2026-08-17 00:00 Beijing): peak/
204
+ // off-peak tiered pricing. Pinned the OFF-PEAK rate (peak
205
+ // hours are 8/24; most chat sessions land off-peak; peak is
206
+ // exactly 2× off-peak per the official page).
207
+ // Off-peak: $0.022 cache hit / $0.66 input / $1.98 output
208
+ // ¥0.15 cache hit / ¥4.5 input / ¥13.5 output
209
+ // The 8/17 调价 raised cache hit 6× (¥0.025 → ¥0.15),
210
+ // input 1.5×, and output 2.25×. The pre-08-17 USD values
211
+ // (0.435/0.87/0.003625) and CNY values (2.1/4.2/0.025) did
212
+ // not correspond to any DeepSeek-published rate; corrected.
213
+ pricingUSD: { input: 0.66, output: 1.98, cacheRead: 0.022 },
214
+ pricingCNY: { input: 4.5, output: 13.5, cacheRead: 0.15 },
137
215
  priceCategory: "low",
138
216
  thinkingSchema: "thinkingEnabled",
139
217
  maxInputTokens: 655360,
@@ -261,10 +339,14 @@ var PRIMARY_METADATA = {
261
339
  // GLM-5's explicit "Agentic 长程规划与执行" description. Corrected
262
340
  // from false (inconsistent with the rest of the GLM-5 family).
263
341
  "glm-5.2": {
264
- detail: "GLM-5.2 \u2014 1M \u4E0A\u4E0B\u6587\uFF0C\u6700\u5927\u8F93\u51FA 128K",
342
+ detail: "GLM-5.2 \u2014 1M \u4E0A\u4E0B\u6587\uFF0C\u6700\u5927\u8F93\u51FA 128K\uFF08\u5355\u6863 pricing\uFF09",
265
343
  imageInput: false,
266
344
  toolCalling: true,
267
- // ¥8 input / ¥28 output / ¥2 cache hit per 1M tokens (输入长度 32K+ 档)
345
+ // Single rate (no input-length tier split) per
346
+ // bigmodel.cn/pricing 2026-08-18:
347
+ // ¥8 input / ¥28 output / ¥2 cache hit per 1M tokens
348
+ // The previous entry's comment said "输入长度 32K+ 档" — that
349
+ // was wrong: GLM-5.2 has no tier split on the official page.
268
350
  pricingUSD: { input: 1.12, output: 3.92, cacheRead: 0.28 },
269
351
  pricingCNY: { input: 8, output: 28, cacheRead: 2 },
270
352
  priceCategory: "high",
@@ -299,74 +381,91 @@ var PRIMARY_METADATA = {
299
381
  // (model id `glm-5.1-highspeed`). Pricing mirrors GLM-5.1 since the
300
382
  // rate is identical architecture — TileRT is a serving-side optim.
301
383
  "glm-5.1-highspeed": {
302
- detail: "GLM-5.1 HighSpeed \u2014 400 TPS \u9AD8\u541E\u5410\u751F\u4EA7\u53D8\u4F53",
384
+ detail: "GLM-5.1 HighSpeed \u2014 400 TPS \u9AD8\u541E\u5410\u751F\u4EA7\u53D8\u4F53\uFF08[0, 32K) tier \u955C\u50CF GLM-5.1\uFF09",
303
385
  imageInput: false,
304
386
  toolCalling: true,
387
+ // Mirrors GLM-5.1 [0, 32K) tier per bigmodel.cn/pricing 2026-08-18.
388
+ // TileRT is a serving-side optim; the per-token rate is the same
389
+ // architecture as the base model.
305
390
  pricingUSD: { input: 0.6, output: 2.2, cacheRead: 0.11 },
306
- pricingCNY: { input: 4.3, output: 15.7, cacheRead: 0.79 },
391
+ pricingCNY: { input: 6, output: 24, cacheRead: 1.3 },
307
392
  priceCategory: "medium",
308
393
  maxInputTokens: 2e5,
309
394
  maxOutputTokens: 128e3
310
395
  },
311
- // GLM-4.7-Flash (2026-01-19) — free-tier version of GLM-4.7, lightweight
312
- // + high-frequency optimised. Coding / writing / translation /
313
- // reasoning at "best-in-class-for-its-size" per the Zhipu release notes;
314
- // the "Flash" tier is distinct from `glm-4.7-flashx` (the latter is the
315
- // 快速版 without tool calling; this Flash is the full-feature lite).
396
+ // GLM-4.7-Flash (2026-01-19) — 200K context, fully-free tier on
397
+ // bigmodel.cn/pricing (fetched 2026-08-18). Lightweight + high-
398
+ // frequency optimised; coding / writing / translation / reasoning
399
+ // at "best-in-class-for-its-size" per the Zhipu release notes.
400
+ // Distinct from `glm-4.7-flashx` (the latter is the 快速版 with
401
+ // paid pricing).
316
402
  "glm-4.7-flash": {
317
- detail: "GLM-4.7 Flash \u2014 \u8F7B\u91CF\u514D\u8D39\u7248\uFF0C200K \u4E0A\u4E0B\u6587",
403
+ detail: "GLM-4.7 Flash \u2014 \u5B8C\u5168\u514D\u8D39\uFF08200K \u4E0A\u4E0B\u6587\uFF09",
318
404
  imageInput: false,
319
405
  toolCalling: true,
320
- // Free tier — public pricing page lists the model as "免费" with no
321
- // input/output rate. Numbers below are conservative estimates based
322
- // on the GLM-3-Turbo "入门级 ¥1/1M tokens" reference; the provider
323
- // has not published a cache rate either, so cacheRead is null.
324
- pricingUSD: { input: 0.06, output: 0.21, cacheRead: null },
325
- pricingCNY: { input: 0.4, output: 1.5, cacheRead: null },
406
+ // Free tier — input / output / cache hit all 0 (bigmodel.cn
407
+ // 2026-08-18 lists "免费" for every column). USD mirrors CNY
408
+ // rather than inventing a rate.
409
+ pricingUSD: { input: 0, output: 0, cacheRead: 0 },
410
+ pricingCNY: { input: 0, output: 0, cacheRead: 0 },
326
411
  priceCategory: "low",
327
412
  maxInputTokens: 2e5,
328
413
  maxOutputTokens: 128e3
329
414
  },
330
415
  "glm-4.7": {
331
- detail: "200K \u4E0A\u4E0B\u6587\uFF0C\u5DE5\u5177\u8C03\u7528",
416
+ detail: "GLM-4.7 \u2014 200K \u4E0A\u4E0B\u6587\uFF0C\u5DE5\u5177\u8C03\u7528\uFF083-tier pricing\uFF09",
332
417
  imageInput: false,
333
418
  toolCalling: true,
334
- // cc-switch 标价:$0.6 input / $2.2 output
335
- pricingUSD: { input: 0.6, output: 2.2, cacheRead: 0.11 },
336
- pricingCNY: { input: 4.3, output: 15.7, cacheRead: 0.79 },
419
+ // Pinned the LOWEST tier per bigmodel.cn/pricing 2026-08-18:
420
+ // [0, 32K) input × [0, 0.2K) output — ¥2 / ¥8 / ¥0.4 cache hit
421
+ // [0, 32K) input × [0.2K+) output ¥3 / ¥14 / ¥0.6 cache hit
422
+ // [32K, 200K) input — ¥4 / ¥16 / ¥0.8 cache hit
423
+ // Most real prompts are < 32K input and < 0.2K output, so the
424
+ // lowest tier is the most representative per-request price.
425
+ // Re-pick from a higher tier if the picker adds a length slider.
426
+ pricingUSD: { input: 0.28, output: 1.12, cacheRead: 0.056 },
427
+ pricingCNY: { input: 2, output: 8, cacheRead: 0.4 },
337
428
  priceCategory: "medium",
338
429
  maxInputTokens: 2e5,
339
430
  maxOutputTokens: 128e3
340
431
  },
341
432
  "glm-5.1": {
342
- detail: "GLM-5.1 \u2014 200K \u4E0A\u4E0B\u6587\uFF0C\u6700\u5927\u8F93\u51FA 128K",
433
+ detail: "GLM-5.1 \u2014 200K \u4E0A\u4E0B\u6587\uFF0C\u6700\u5927\u8F93\u51FA 128K\uFF082-tier pricing\uFF09",
343
434
  imageInput: false,
344
435
  toolCalling: true,
345
- // ¥8 input / ¥28 output / ¥2 cache hit per 1M tokens (输入长度 32K+ 档)
346
- pricingUSD: { input: 1.12, output: 3.92, cacheRead: 0.28 },
347
- pricingCNY: { input: 8, output: 28, cacheRead: 2 },
436
+ // Pinned the LOWER tier per bigmodel.cn/pricing 2026-08-18:
437
+ // [0, 32K) — ¥6 input / ¥24 output / ¥1.3 cache hit
438
+ // [32K+) — ¥8 input / ¥28 output / ¥2 cache hit
439
+ // The previous entry had the higher tier; switched to the lower
440
+ // tier so a typical < 32K prompt shows the more accurate price.
441
+ pricingUSD: { input: 0.84, output: 3.36, cacheRead: 0.182 },
442
+ pricingCNY: { input: 6, output: 24, cacheRead: 1.3 },
348
443
  priceCategory: "high",
349
444
  maxInputTokens: 2e5,
350
445
  maxOutputTokens: 128e3
351
446
  },
352
447
  "glm-5": {
353
- detail: "GLM-5 \u2014 200K \u4E0A\u4E0B\u6587\uFF0CAgentic \u5DE5\u5177\u8C03\u7528\uFF0C\u6700\u5927\u8F93\u51FA 128K",
448
+ detail: "GLM-5 \u2014 200K \u4E0A\u4E0B\u6587\uFF0CAgentic \u5DE5\u5177\u8C03\u7528\uFF0C\u6700\u5927\u8F93\u51FA 128K\uFF082-tier pricing\uFF09",
354
449
  imageInput: false,
355
450
  toolCalling: true,
356
- // ¥6 input / ¥22 output / ¥1.5 cache hit per 1M tokens (输入长度 32K+ 档)
357
- pricingUSD: { input: 0.84, output: 3.08, cacheRead: 0.21 },
358
- pricingCNY: { input: 6, output: 22, cacheRead: 1.5 },
451
+ // Pinned the LOWER tier per bigmodel.cn/pricing 2026-08-18:
452
+ // [0, 32K) — ¥4 input / ¥18 output / ¥1 cache hit
453
+ // [32K+) — ¥6 input / ¥22 output / ¥1.5 cache hit
454
+ pricingUSD: { input: 0.56, output: 2.52, cacheRead: 0.14 },
455
+ pricingCNY: { input: 4, output: 18, cacheRead: 1 },
359
456
  priceCategory: "high",
360
457
  maxInputTokens: 2e5,
361
458
  maxOutputTokens: 128e3
362
459
  },
363
460
  "glm-5-turbo": {
364
- detail: "GLM-5 Turbo \u2014 200K \u4E0A\u4E0B\u6587\uFF0C\u6700\u5927\u8F93\u51FA 128K",
461
+ detail: "GLM-5 Turbo \u2014 200K \u4E0A\u4E0B\u6587\uFF0C\u6700\u5927\u8F93\u51FA 128K\uFF082-tier pricing\uFF09",
365
462
  imageInput: false,
366
463
  toolCalling: true,
367
- // ¥7 input / ¥26 output / ¥1.8 cache hit per 1M tokens (输入长度 32K+ 档)
368
- pricingUSD: { input: 0.98, output: 3.64, cacheRead: 0.252 },
369
- pricingCNY: { input: 7, output: 26, cacheRead: 1.8 },
464
+ // Pinned the LOWER tier per bigmodel.cn/pricing 2026-08-18:
465
+ // [0, 32K) — ¥5 input / ¥22 output / ¥1.2 cache hit
466
+ // [32K+) — ¥7 input / ¥26 output / ¥1.8 cache hit
467
+ pricingUSD: { input: 0.7, output: 3.08, cacheRead: 0.168 },
468
+ pricingCNY: { input: 5, output: 22, cacheRead: 1.2 },
370
469
  priceCategory: "medium",
371
470
  maxInputTokens: 2e5,
372
471
  maxOutputTokens: 128e3
@@ -414,23 +513,34 @@ var PRIMARY_METADATA = {
414
513
  maxOutputTokens: 96e3
415
514
  },
416
515
  "glm-4.5-air": {
417
- detail: "GLM-4.5 Air \u2014 \u5DE5\u5177\u8C03\u7528",
516
+ detail: "GLM-4.5 Air \u2014 \u5DE5\u5177\u8C03\u7528\uFF083-tier pricing\uFF09",
418
517
  imageInput: false,
419
518
  toolCalling: true,
420
- pricingUSD: { input: 0, output: 0, cacheRead: null },
421
- pricingCNY: { input: 0, output: 0, cacheRead: null },
519
+ // Pinned the LOWEST tier per bigmodel.cn/pricing 2026-08-18:
520
+ // [0, 32K) × [0, 0.2K) output — ¥0.8 / ¥2 / ¥0.16 cache hit
521
+ // [0, 32K) × [0.2K+) output — ¥0.8 / ¥6 / ¥0.16 cache hit
522
+ // [32K, 128K) — ¥1.2 / ¥8 / ¥0.24 cache hit
523
+ // All cache-hit rates are 4× lower than input — the
524
+ // explicit-cache-discount half of BYOM-depth #1.
525
+ pricingUSD: { input: 0.112, output: 0.28, cacheRead: 0.0224 },
526
+ pricingCNY: { input: 0.8, output: 2, cacheRead: 0.16 },
422
527
  priceCategory: "low",
423
528
  maxInputTokens: 128e3,
424
529
  maxOutputTokens: 96e3
425
530
  },
426
531
  "glm-4.5-airx": {
427
- detail: "GLM-4.5 AirX \u2014 \u5FEB\u901F\u7248",
532
+ detail: "GLM-4.5 AirX \u2014 \u5FEB\u901F\u7248\uFF08\xA510/M \u5355\u6863\uFF09",
428
533
  imageInput: false,
429
534
  toolCalling: false,
430
- pricingUSD: { input: 0, output: 0, cacheRead: null },
431
- pricingCNY: { input: 0, output: 0, cacheRead: null },
535
+ // ¥10 / M tokens (single rate, input == output) per
536
+ // bigmodel.cn/pricing 2026-08-18 listed under the "模型推理
537
+ // → Language Models" sub-tab, NOT the flagship text section.
538
+ // 8K context window per the same sub-tab; 96K max output is a
539
+ // best-guess from sibling Air-tier models.
540
+ pricingUSD: { input: 1.4, output: 1.4, cacheRead: null },
541
+ pricingCNY: { input: 10, output: 10, cacheRead: null },
432
542
  priceCategory: "low",
433
- maxInputTokens: 128e3,
543
+ maxInputTokens: 8192,
434
544
  maxOutputTokens: 96e3
435
545
  },
436
546
  "glm-4-long": {
@@ -467,24 +577,29 @@ var PRIMARY_METADATA = {
467
577
  maxOutputTokens: 4e3
468
578
  },
469
579
  "glm-4.5v": {
470
- detail: "GLM-4.5V \u89C6\u89C9\u63A8\u7406\u6A21\u578B \u2014 \u56FE\u50CF/\u89C6\u9891/\u6587\u6863/GUI",
580
+ detail: "GLM-4.5V \u89C6\u89C9\u63A8\u7406\u6A21\u578B \u2014 \u56FE\u50CF/\u89C6\u9891/\u6587\u6863/GUI\uFF082-tier pricing\uFF09",
471
581
  imageInput: true,
472
582
  toolCalling: true,
473
- pricingUSD: { input: 0, output: 0, cacheRead: null },
474
- pricingCNY: { input: 0, output: 0, cacheRead: null },
583
+ // Pinned the LOWER tier per bigmodel.cn/pricing 2026-08-18:
584
+ // [0, 32K) — ¥2 input / ¥6 output / ¥0.4 cache hit
585
+ // [32, 64K) — ¥4 input / ¥12 output / ¥0.8 cache hit
586
+ pricingUSD: { input: 0.28, output: 0.84, cacheRead: 0.056 },
587
+ pricingCNY: { input: 2, output: 6, cacheRead: 0.4 },
475
588
  priceCategory: "medium",
476
- maxInputTokens: 128e3,
589
+ maxInputTokens: 64e3,
477
590
  maxOutputTokens: 8192
478
591
  },
479
592
  "glm-5v-turbo": {
480
- detail: "GLM-5V Turbo \u2014 \u591A\u6A21\u6001 Coding \u6A21\u578B",
593
+ detail: "GLM-5V Turbo \u2014 \u591A\u6A21\u6001 Coding \u6A21\u578B\uFF082-tier pricing\uFF09",
481
594
  imageInput: true,
482
595
  toolCalling: true,
483
- pricingUSD: { input: 0, output: 0, cacheRead: null },
484
- pricingCNY: { input: 0, output: 0, cacheRead: null },
596
+ // Pinned the LOWER tier per bigmodel.cn/pricing 2026-08-18:
597
+ // [0, 32K) — ¥5 input / ¥22 output / ¥1.2 cache hit
598
+ // [32K+) — ¥7 input / ¥26 output / ¥1.8 cache hit
599
+ // Vendor-published context: 200K / 128K max output.
600
+ pricingUSD: { input: 0.7, output: 3.08, cacheRead: 0.168 },
601
+ pricingCNY: { input: 5, output: 22, cacheRead: 1.2 },
485
602
  priceCategory: "medium",
486
- // Official model overview: 200K context / 128K max output
487
- // (previously mis-set to 128K/8_192 — corrected 2026-07-27).
488
603
  maxInputTokens: 2e5,
489
604
  maxOutputTokens: 128e3
490
605
  },
@@ -512,8 +627,15 @@ var PRIMARY_METADATA = {
512
627
  // Official model page lists "🛠️ 工具调用: 可靠的工具调用能力,支持多步
513
628
  // 任务分解与计划执行" as a core capability — was mis-set to false.
514
629
  toolCalling: true,
515
- // ¥1.35 input / ¥8.1 output / ¥0.27 cache hit per 1M tokens
516
- pricingUSD: { input: 0.189, output: 1.134, cacheRead: 0.038 },
630
+ // Per https://platform.stepfun.com/docs/zh/pricing/details
631
+ // (2026-08-18 fetched): ¥1.35 input / ¥8.1 output /
632
+ // ¥0.27 cache hit per 1M tokens, USD = $0.20 / $1.15 /
633
+ // $0.04 (StepFun is USD-billed at the same rate as CNY/7
634
+ // with small rounding per the official pricing page).
635
+ // USD values previously 0.189/1.134/0.038 — slightly off
636
+ // from the official page (rounding error from dividing CNY
637
+ // by hand), corrected.
638
+ pricingUSD: { input: 0.2, output: 1.15, cacheRead: 0.04 },
517
639
  pricingCNY: { input: 1.35, output: 8.1, cacheRead: 0.27 },
518
640
  priceCategory: "medium",
519
641
  thinkingSchema: "reasoningEffort",
@@ -529,8 +651,13 @@ var PRIMARY_METADATA = {
529
651
  // Official model page lists "🛠️ 工具调用: 可靠的 tools / tool_choice
530
652
  // 调用能力" as a core capability — was mis-set to false.
531
653
  toolCalling: true,
532
- // ¥0.7 input / ¥2.1 output / ¥0.14 cache hit per 1M tokens
533
- pricingUSD: { input: 0.098, output: 0.294, cacheRead: 0.02 },
654
+ // Per https://platform.stepfun.com/docs/zh/pricing/details
655
+ // (2026-08-18 fetched): ¥0.7 input / ¥2.1 output /
656
+ // ¥0.14 cache hit per 1M tokens, USD = $0.10 / $0.30 /
657
+ // $0.02. USD values previously 0.098/0.294/0.02 — slightly
658
+ // off from the official page (rounding error), corrected
659
+ // to the exact published values.
660
+ pricingUSD: { input: 0.1, output: 0.3, cacheRead: 0.02 },
534
661
  pricingCNY: { input: 0.7, output: 2.1, cacheRead: 0.14 },
535
662
  priceCategory: "low",
536
663
  thinkingSchema: "reasoningEffort",
@@ -541,9 +668,13 @@ var PRIMARY_METADATA = {
541
668
  detail: "Step 1o Turbo Vision \u2014 \u89C6\u89C9\u6A21\u578B",
542
669
  imageInput: true,
543
670
  toolCalling: false,
544
- // ¥2.5 input / ¥8 output per 1M tokens
545
- pricingUSD: { input: 0.35, output: 1.12, cacheRead: null },
546
- pricingCNY: { input: 2.5, output: 8, cacheRead: null },
671
+ // Per https://platform.stepfun.com/docs/zh/pricing/details
672
+ // (2026-08-18 fetched): ¥2.5 cache miss / ¥0.5 cache hit /
673
+ // ¥8 output per 1M tokens. USD = $0.357 / $0.071 / $1.143
674
+ // (CNY/7 with rounding). Cache hit was previously
675
+ // undocumented in the curated entry — added.
676
+ pricingUSD: { input: 0.357, output: 1.143, cacheRead: 0.071 },
677
+ pricingCNY: { input: 2.5, output: 8, cacheRead: 0.5 },
547
678
  priceCategory: "low",
548
679
  // Official model overview: 32K context window.
549
680
  maxInputTokens: 32768,
@@ -583,8 +714,13 @@ var PRIMARY_METADATA = {
583
714
  detail: "MiniMax M2.5 \u2014 229B MoE, SOTA \u7F16\u7A0B / Agent / \u529E\u516C\u751F\u4EA7\u529B\uFF08192K \u4E0A\u4E0B\u6587\uFF09",
584
715
  imageInput: false,
585
716
  toolCalling: true,
586
- // ¥2.1 / ¥8.4 per 1M tokens; cache hit documented at ¥0.21 (按
587
- // 官方 10% cache 命中率回填)
717
+ // Per https://minimax-ai.chat/pricing (M2.5 legacy line):
718
+ // ¥2.1 input / ¥8.4 output / ¥0.21 cache hit per 1M tokens;
719
+ // USD = $0.30 / $1.20 / $0.03 (cloudprice.net 2026-08-13).
720
+ // Cache hit IS the published rate — the previous comment
721
+ // "按官方 10% cache 命中率回填" was wrong (it implied we
722
+ // were estimating, when actually the cache rate is
723
+ // documented at ¥0.21 / $0.03 per 1M tokens).
588
724
  pricingUSD: { input: 0.3, output: 1.2, cacheRead: 0.03 },
589
725
  pricingCNY: { input: 2.1, output: 8.4, cacheRead: 0.21 },
590
726
  priceCategory: "medium",
@@ -653,10 +789,28 @@ function lookupModelMetadata(modelId) {
653
789
  function currencyForBaseUrl(baseUrl) {
654
790
  try {
655
791
  const hostname = new URL(baseUrl).hostname.toLowerCase();
656
- if (hostname === "api.minimaxi.com" || hostname === "api.minimaxi.cn" || hostname === "api.deepseek.com" || hostname === "api.moonshot.cn" || hostname === "open.bigmodel.cn") {
792
+ if (hostname === "api.minimaxi.com" || hostname === "api.minimaxi.cn" || hostname === "api.deepseek.com" || hostname === "api.moonshot.cn" || hostname === "open.bigmodel.cn" || // Zhipu legacy v3 host. Per the GLM-for-copilot reference
793
+ // (`docs/references/GLM-for-copilot-main/src/endpoint.ts:4`)
794
+ // this was retired to `bigmodel.cn` but is still
795
+ // resolvable for accounts that haven't migrated — we
796
+ // don't surface it in the baseUrl dropdown, but a user
797
+ // may paste it from a saved settings.json, so the
798
+ // currency has to match (CNY, same as the new host).
799
+ hostname === "dev.bigmodel.cn") {
657
800
  return "CNY";
658
801
  }
659
- if (hostname === "api.minimax.io" || hostname === "api.minimaxi.io" || hostname === "api.siliconflow.cn" || hostname === "api.siliconflow.com" || hostname === "api.stepfun.com" || hostname === "openrouter.ai" || hostname === "api.novita.ai") {
802
+ if (hostname === "api.minimax.io" || hostname === "api.minimaxi.io" || hostname === "api.siliconflow.cn" || hostname === "api.siliconflow.com" || hostname === "api.stepfun.com" || hostname === "openrouter.ai" || hostname === "api.novita.ai" || // Z.ai / Zhipu international. Billed in USD per the
803
+ // official `bigmodel.cn/pricing` page (the CNY-billed
804
+ // list is the China-domiciled `open.bigmodel.cn` only;
805
+ // the international `api.z.ai` is USD regardless of
806
+ // which apiMode / protocol path the user picked). The
807
+ // GLM-for-copilot reference uses the same split
808
+ // (`docs/references/GLM-for-copilot-main/src/endpoint.ts:160-173`).
809
+ // Without this explicit entry, `api.z.ai` would still
810
+ // resolve to USD via the catch-all below — adding it
811
+ // here makes the intent grep-able and pins the host
812
+ // list against accidental removal.
813
+ hostname === "api.z.ai") {
660
814
  return "USD";
661
815
  }
662
816
  } catch {
@@ -1441,6 +1595,7 @@ export {
1441
1595
  checkGitHubOrgMembership,
1442
1596
  createConsoleLogger,
1443
1597
  currencyForBaseUrl,
1598
+ effectiveAdapterType,
1444
1599
  fetchGitHubUser,
1445
1600
  getBuiltinProviderPreset,
1446
1601
  getGitHubOrgMembership,
@@ -1453,6 +1608,7 @@ export {
1453
1608
  normalizeErrorForLog,
1454
1609
  normalizeGitUrl,
1455
1610
  parsePayload,
1611
+ protocolForBaseUrl,
1456
1612
  resolvePrimaryEmail,
1457
1613
  safeJson
1458
1614
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serviceme/devtools-shared",
3
- "version": "0.4.6",
3
+ "version": "0.4.7",
4
4
  "description": "Shared webview↔extension message contracts and cross-package data models used by SERVICEME.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "repository": {