diff --git a/.github/workflows/publish-theme.yml b/.github/workflows/publish-theme.yml index eb8286a..d0b3777 100644 --- a/.github/workflows/publish-theme.yml +++ b/.github/workflows/publish-theme.yml @@ -11,7 +11,7 @@ permissions: jobs: publish: - name: 发布 @doudou-start/airgate-theme + name: 发布 @devilgenius/airgate-theme runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 @@ -44,7 +44,7 @@ jobs: run: | mkdir -p ../dist pnpm pack --pack-destination ../dist - mv ../dist/doudou-start-airgate-theme-*.tgz "../dist/airgate-theme-${GITHUB_REF_NAME}.tgz" + mv ../dist/devilgenius-airgate-theme-*.tgz "../dist/airgate-theme-${GITHUB_REF_NAME}.tgz" - name: 创建/更新 GitHub Release 并上传资产 if: github.event_name == 'push' diff --git a/.golangci.yml b/.golangci.yml index d756981..4c7ca74 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -22,7 +22,7 @@ formatters: settings: goimports: - local-prefixes: github.com/DouDOU-start + local-prefixes: github.com/DevilGenius issues: max-issues-per-linter: 0 diff --git a/LICENSE b/LICENSE index 30c35bf..18f224f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2026 DouDOU-start +Copyright (c) 2026 DevilGenius Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile b/Makefile index b93ccf0..fe82d32 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ lint: ## 代码检查(需要安装 golangci-lint) fmt: ## 格式化代码 @if command -v goimports > /dev/null 2>&1; then \ - goimports -w -local github.com/DouDOU-start .; \ + goimports -w -local github.com/DevilGenius .; \ else \ $(GO) fmt ./...; \ fi diff --git a/README.md b/README.md index 901b3e3..8834599 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@

AirGate 插件生态的公共契约与开发工具包

- 发布版本 - Go 文档 - 许可证 + 发布版本 + Go 文档 + 许可证 Go 版本 gRPC 插件协议

@@ -14,7 +14,7 @@ --- -AirGate SDK 是 [AirGate Core](https://github.com/DouDOU-start/airgate-core) 和插件之间的公共契约。它定义插件要实现什么接口、Core 如何启动插件进程、双方如何通过 gRPC 通信,以及插件前端如何复用统一主题和公共组件。 +AirGate SDK 是 [AirGate Core](https://github.com/DevilGenius/airgate-core) 和插件之间的公共契约。它定义插件要实现什么接口、Core 如何启动插件进程、双方如何通过 gRPC 通信,以及插件前端如何复用统一主题和公共组件。 简单理解: @@ -25,15 +25,15 @@ AirGate SDK 是 [AirGate Core](https://github.com/DouDOU-start/airgate-core) 和 ## 安装 ```bash -go get github.com/DouDOU-start/airgate-sdk@latest +go get github.com/DevilGenius/airgate-sdk@latest ``` Go 插件通常只需要两个包: ```go import ( - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" - runtime "github.com/DouDOU-start/airgate-sdk/runtimego/grpc" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" + runtime "github.com/DevilGenius/airgate-sdk/runtimego/grpc" ) ``` @@ -42,7 +42,7 @@ import ( ```json { "dependencies": { - "@doudou-start/airgate-theme": "^0.2.1" + "@devilgenius/airgate-theme": "^0.2.1" } } ``` @@ -52,7 +52,7 @@ import ( ```json { "dependencies": { - "@doudou-start/airgate-theme": "file:../../airgate-sdk/theme" + "@devilgenius/airgate-theme": "file:../../airgate-sdk/theme" } } ``` @@ -65,7 +65,7 @@ import ( | `protocol/proto/` | `airgate.plugin.v1` protobuf 协议和生成代码 | Core / runtime | | `runtimego/grpc/` | hashicorp/go-plugin、gRPC bridge、proto 转换、Core 反向调用通道 | 插件入口 / Core 加载器 | | `devkit/devserver/` | 本地开发服务器,无需启动完整 Core 即可调试插件 | 插件作者 | -| `theme/` | `@doudou-start/airgate-theme`:主题 token、样式隔离、Tailwind helper、公共组件 | 插件前端 | +| `theme/` | `@devilgenius/airgate-theme`:主题 token、样式隔离、Tailwind helper、公共组件 | 插件前端 | | `docs/` | 设计边界和前端样式规范 | 维护者 | 普通插件业务代码不直接依赖 `protocol/proto`。 @@ -96,8 +96,8 @@ Gateway 插件的核心工作只有三件事: package main import ( - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" - runtime "github.com/DouDOU-start/airgate-sdk/runtimego/grpc" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" + runtime "github.com/DevilGenius/airgate-sdk/runtimego/grpc" ) type Gateway struct{} @@ -169,17 +169,15 @@ func (g *Gateway) Forward(ctx context.Context, req *sdk.ForwardRequest) (sdk.For AccountCost: 0.000035, Currency: "USD", Summary: "输入 10 token,输出 5 token", - Attributes: []sdk.UsageAttribute{ - {Key: "reasoning_effort", Label: "思考层级", Kind: "reasoning", Value: "high"}, - {Key: "resolution", Label: "分辨率", Kind: "resolution", Value: "1024x1024"}, - }, - Metrics: []sdk.UsageMetric{ - {Key: "input_tokens", Label: "输入 token", Kind: "token", Unit: "token", Value: 10}, - {Key: "output_tokens", Label: "输出 token", Kind: "token", Unit: "token", Value: 5}, - }, - CostDetails: []sdk.UsageCostDetail{ - {Key: "input", Label: "输入费用", AccountCost: 0.00001, Currency: "USD"}, - {Key: "output", Label: "输出费用", AccountCost: 0.000025, Currency: "USD"}, + InputTokens: 10, + OutputTokens: 5, + InputPrice: 1, + OutputPrice: 5, + InputCost: 0.00001, + OutputCost: 0.000025, + ReasoningEffort: "high", + Metadata: map[string]string{ + "openai.image.size": "1024x1024", }, }, }, nil @@ -199,7 +197,7 @@ func (g *Gateway) Forward(ctx context.Context, req *sdk.ForwardRequest) (sdk.For ```go package main -import "github.com/DouDOU-start/airgate-sdk/devkit/devserver" +import "github.com/DevilGenius/airgate-sdk/devkit/devserver" func main() { if err := devserver.Run(devserver.Config{Plugin: &Gateway{}}); err != nil { @@ -229,7 +227,7 @@ Core 启动插件子进程 - Core 默认只管理插件生命周期、页面入口、静态资源、schema、健康检查和 API 代理。 - Gateway 插件是主请求链路,Core 会主动调用 `Forward`、账号验证和 WebSocket 处理。 -- SDK 不内置平台计费规则;网关插件计算标准账号成本并填入 `Usage.AccountCost`、`Usage.Attributes`、`Usage.Metrics`、`Usage.CostDetails`。 +- SDK 不内置平台计费规则;网关插件计算标准 token、单价、成本字段并填入 `Usage`,插件专属展示数据放入 `Usage.Metadata`。 - Core 统一入库后,根据用户、分组、模型等倍率写入 `UserCost` / `BillingMultiplier`;倍率规则不进入 SDK。 - 账号管理和使用记录 UI 由插件提供静态资源,Core 只加载页面、插槽和插件 API 代理,不解释平台字段。 - Middleware、扩展路由、后台任务、事件订阅、异步任务处理都属于插件显式暴露的能力;没有暴露就不会被 Core 调度。 @@ -331,14 +329,14 @@ func (p *Plugin) Init(ctx sdk.PluginContext) error { ## 前端插件 SDK -`theme/` 发布为 npm 公共包 `@doudou-start/airgate-theme`,用于插件前端复用 AirGate 的主题和公共组件。 +`theme/` 发布为 npm 公共包 `@devilgenius/airgate-theme`,用于插件前端复用 AirGate 的主题和公共组件。 | 入口 | 用途 | |---|---| -| `@doudou-start/airgate-theme` | token、CSS 工具、Tailwind bridge、插件前端类型和公共组件统一出口 | -| `@doudou-start/airgate-theme/plugin` | 插件样式隔离、主题同步、Tailwind helper、公共 UI 组件 | -| `@doudou-start/airgate-theme/css` | CSS 变量生成和运行时主题注入 | -| `@doudou-start/airgate-theme/tailwind` | Tailwind 主题桥接 | +| `@devilgenius/airgate-theme` | token、CSS 工具、Tailwind bridge、插件前端类型和公共组件统一出口 | +| `@devilgenius/airgate-theme/plugin` | 插件样式隔离、主题同步、Tailwind helper、公共 UI 组件 | +| `@devilgenius/airgate-theme/css` | CSS 变量生成和运行时主题注入 | +| `@devilgenius/airgate-theme/tailwind` | Tailwind 主题桥接 | 推荐插件前端使用: @@ -350,7 +348,7 @@ import { createPluginTailwindConfig, ensurePluginStyleFoundation, useScopedPluginTheme, -} from "@doudou-start/airgate-theme/plugin"; +} from "@devilgenius/airgate-theme/plugin"; ``` 完整样式规则见 [插件前端样式规范](docs/plugin-style-guide.md)。 @@ -374,7 +372,7 @@ import { make ci # 运行 Go、proto、前端和主题漂移检查 make proto # 重新生成 protocol/proto make theme # 重新生成 DevServer 主题 CSS -cd theme && pnpm build # 构建 @doudou-start/airgate-theme +cd theme && pnpm build # 构建 @devilgenius/airgate-theme ``` ## License diff --git a/devkit/devserver/context.go b/devkit/devserver/context.go index 1f7f016..a7e45a2 100644 --- a/devkit/devserver/context.go +++ b/devkit/devserver/context.go @@ -5,7 +5,7 @@ import ( "os" "time" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) // devPluginContext 开发模式的 PluginContext 实现 diff --git a/devkit/devserver/proxy.go b/devkit/devserver/proxy.go index 7bbf369..5661afe 100644 --- a/devkit/devserver/proxy.go +++ b/devkit/devserver/proxy.go @@ -10,7 +10,7 @@ import ( "github.com/gorilla/websocket" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) // ProxyHandler 将请求代理给插件 diff --git a/devkit/devserver/proxy_test.go b/devkit/devserver/proxy_test.go index 11f9e96..d104085 100644 --- a/devkit/devserver/proxy_test.go +++ b/devkit/devserver/proxy_test.go @@ -7,7 +7,7 @@ import ( "path/filepath" "testing" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) type proxyTestGateway struct { diff --git a/devkit/devserver/scheduler.go b/devkit/devserver/scheduler.go index 916df7a..3e5f096 100644 --- a/devkit/devserver/scheduler.go +++ b/devkit/devserver/scheduler.go @@ -9,7 +9,7 @@ import ( "sync" "time" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) // SchedulePolicy 调度策略 @@ -123,6 +123,10 @@ func (s *Scheduler) ReportResult(accountID int64, outcome sdk.ForwardOutcome) { s.cooldown[accountID] = time.Now().Add(5 * time.Minute) log.Printf("[调度] 账号 %d 凭证失效,冷却 5 分钟", accountID) + case sdk.OutcomeAccountUnavailable: + s.cooldown[accountID] = time.Now().Add(60 * time.Second) + log.Printf("[调度] 账号 %d 暂时 403,冷却 60 秒", accountID) + default: delete(s.cooldown, accountID) } diff --git a/devkit/devserver/scheduler_test.go b/devkit/devserver/scheduler_test.go new file mode 100644 index 0000000..3a0b32a --- /dev/null +++ b/devkit/devserver/scheduler_test.go @@ -0,0 +1,54 @@ +package devserver + +import ( + "path/filepath" + "strconv" + "testing" + + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" +) + +func TestSchedulerReportResultCoolsDownAccountUnavailable(t *testing.T) { + t.Parallel() + + store := NewAccountStore(filepath.Join(t.TempDir(), "accounts.json")) + account := store.Create(DevAccount{Name: "oauth", AccountType: "oauth"}) + accountKey := strconv.FormatInt(account.ID, 10) + s := NewScheduler(store, ScheduleWeightedRR) + s.ReportResult(account.ID, sdk.ForwardOutcome{Kind: sdk.OutcomeAccountUnavailable}) + + status := s.Status() + cooldowns, ok := status["cooldowns"].(map[string]string) + if !ok { + t.Fatalf("cooldowns has type %T, want map[string]string", status["cooldowns"]) + } + if cooldowns[accountKey] == "" { + t.Fatalf("expected account %s to be in cooldown, got %v", accountKey, cooldowns) + } + + s.ReportResult(account.ID, sdk.ForwardOutcome{Kind: sdk.OutcomeSuccess}) + status = s.Status() + cooldowns = status["cooldowns"].(map[string]string) + if cooldowns[accountKey] != "" { + t.Fatalf("expected success to clear cooldown, got %v", cooldowns) + } +} + +func TestSchedulerReportResultCoolsDownAccountUnavailableForAPIKey(t *testing.T) { + t.Parallel() + + store := NewAccountStore(filepath.Join(t.TempDir(), "accounts.json")) + account := store.Create(DevAccount{Name: "api key", AccountType: "apikey"}) + accountKey := strconv.FormatInt(account.ID, 10) + s := NewScheduler(store, ScheduleWeightedRR) + s.ReportResult(account.ID, sdk.ForwardOutcome{Kind: sdk.OutcomeAccountUnavailable}) + + status := s.Status() + cooldowns, ok := status["cooldowns"].(map[string]string) + if !ok { + t.Fatalf("cooldowns has type %T, want map[string]string", status["cooldowns"]) + } + if cooldowns[accountKey] == "" { + t.Fatalf("expected api key account to enter cooldown, got %v", cooldowns) + } +} diff --git a/devkit/devserver/server.go b/devkit/devserver/server.go index f41ea30..ac86dc6 100644 --- a/devkit/devserver/server.go +++ b/devkit/devserver/server.go @@ -16,7 +16,7 @@ import ( "strings" "time" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) //go:embed static diff --git a/devkit/devserver/server_test.go b/devkit/devserver/server_test.go index 0ad6019..12cd158 100644 --- a/devkit/devserver/server_test.go +++ b/devkit/devserver/server_test.go @@ -5,7 +5,7 @@ import ( "net/http/httptest" "testing" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) func TestRoutePrefixesDeduplicates(t *testing.T) { diff --git a/docs/async-task-state-machine.md b/docs/async-task-state-machine.md index f84c934..4370a92 100644 --- a/docs/async-task-state-machine.md +++ b/docs/async-task-state-machine.md @@ -82,7 +82,7 @@ Core 固定字段必须保持最小化,只包含任务生命周期、归属和 | `input.model` | 任务请求里的模型,用于任务复现 | `gpt-image-2` | | `attributes.model` | 未完成任务列表里的展示/粗筛选 | `gpt-image-2` | | `execution.*` | 插件内部工具链细节,不作为用户侧模型维度 | `tool_model=gpt-5.4` | -| `usage.Model` / `usage.Attributes.model` | 完成后的审计、计费、统计事实 | `gpt-5.4` | +| `usage.Model` / `usage.Metadata` | 完成后的审计、计费、统计事实 | `gpt-5.4` | `Usage` 是最终事实来源。任务完成前可以用 `attributes` 暂存展示值;任务完成后应以关联的使用记录为准。 @@ -853,16 +853,16 @@ SDK 已经提供通用用量结构: ```go type Usage struct { - Model string - Summary string - Attributes []UsageAttribute - Metrics []UsageMetric - CostDetails []UsageCostDetail - Metadata map[string]string + Model string + Summary string + InputTokens int + OutputTokens int + AccountCost float64 + Metadata map[string]string } ``` -模型和扩展参数应进入 Usage,而不是 Core 任务固定列。对话类调用也使用同一个 Usage 结构,但不经过 Task。 +模型和跨插件通用计费事实应进入 Usage 标准字段,插件专属参数进入 `Metadata`,而不是 Core 任务固定列。对话类调用也使用同一个 Usage 结构,但不经过 Task。 图片生成示例: @@ -870,16 +870,15 @@ type Usage struct { { "model": "gpt-image-2", "summary": "图片生成 · gpt-image-2 · 1024x1024", - "attributes": [ - { "key": "modality", "kind": "custom", "label": "类型", "value": "image" }, - { "key": "model", "kind": "model", "label": "模型", "value": "gpt-image-2" }, - { "key": "resolution", "kind": "resolution", "label": "分辨率", "value": "1024x1024" }, - { "key": "quality", "kind": "quality", "label": "质量", "value": "high" } - ], - "metrics": [ - { "key": "image_count", "kind": "image", "label": "图片张数", "unit": "image", "value": 1 }, - { "key": "output_tokens", "kind": "token", "label": "图像输出 Token", "unit": "token", "value": 4160 } - ] + "output_tokens": 4160, + "output_cost": 0.1, + "account_cost": 0.1, + "metadata": { + "openai.image.size": "1024x1024", + "openai.image.count": "1", + "openai.image.unit_price": "0.1", + "openai.image.unit": "USD/image" + } } ``` @@ -889,15 +888,12 @@ type Usage struct { { "model": "video-model", "summary": "视频生成 · 8s · 1080p", - "attributes": [ - { "key": "modality", "kind": "custom", "label": "类型", "value": "video" }, - { "key": "model", "kind": "model", "label": "模型", "value": "video-model" }, - { "key": "resolution", "kind": "resolution", "label": "分辨率", "value": "1080p" }, - { "key": "quality", "kind": "quality", "label": "质量", "value": "standard" } - ], - "metrics": [ - { "key": "video_seconds", "kind": "video", "label": "视频时长", "unit": "second", "value": 8 } - ] + "account_cost": 0.02, + "metadata": { + "video.resolution": "1080p", + "video.seconds": "8", + "video.quality": "standard" + } } ``` @@ -907,15 +903,12 @@ type Usage struct { { "model": "music-model", "summary": "音乐生成 · 30s · high", - "attributes": [ - { "key": "modality", "kind": "custom", "label": "类型", "value": "music" }, - { "key": "model", "kind": "model", "label": "模型", "value": "music-model" }, - { "key": "quality", "kind": "quality", "label": "质量", "value": "high" }, - { "key": "format", "kind": "custom", "label": "格式", "value": "mp3" } - ], - "metrics": [ - { "key": "audio_seconds", "kind": "audio", "label": "音频时长", "unit": "second", "value": 30 } - ] + "account_cost": 0.01, + "metadata": { + "audio.seconds": "30", + "audio.quality": "high", + "audio.format": "mp3" + } } ``` @@ -924,12 +917,12 @@ type Usage struct { | 信息 | Task 中的位置 | Usage 中的位置 | 说明 | | --- | --- | --- | --- | | 生命周期状态 | `status`、`progress`、`stage` | 不存 | Task 独有 | -| 客户端请求参数 | `input` | 可按需复制到 `Attributes` | 完整参数以 Task input 为准 | +| 客户端请求参数 | `input` | 可按需复制到 `Metadata` | 完整参数以 Task input 为准 | | 上游执行细节 | `execution` | 可脱敏后进入 `Metadata` | 普通用户默认不看 execution | -| 模型 | `input.model` / `attributes.model` 临时展示 | `Model` / `Attributes` | 计费与审计以 Usage 为准 | -| 分辨率、时长、质量 | `input` / `attributes` 临时展示 | `Attributes` / `Metrics` | 统计以 Usage 为准 | -| token、图片张数、视频秒数 | 不建议存 Task 固定列 | `Metrics` | 统一统计入口 | -| 成本 | 不建议存 Task 固定列 | `AccountCost` / `CostDetails` | 统一扣费入口 | +| 模型 | `input.model` / `attributes.model` 临时展示 | `Model` | 计费与审计以 Usage 为准 | +| 分辨率、时长、质量 | `input` / `attributes` 临时展示 | `Metadata` | 统计以 Usage 为准 | +| token、图片张数、视频秒数 | 不建议存 Task 固定列 | 标准 token 字段 / `Metadata` | 统一统计入口 | +| 成本 | 不建议存 Task 固定列 | `AccountCost` / 标准成本字段 | 统一扣费入口 | | 使用记录关联 | `usage_id` | `id` | Task 完成后关联 | 列表页如果要展示未完成任务,可以读取 Task 的 `attributes`,或按插件声明的 schema 组合展示文案。完成后的历史账单、统计图、成本明细必须读取 Usage。 diff --git a/docs/plugin-style-guide.md b/docs/plugin-style-guide.md index 8497dc4..cebb75a 100644 --- a/docs/plugin-style-guide.md +++ b/docs/plugin-style-guide.md @@ -27,7 +27,7 @@ your-plugin/ ## 2. 依赖配置 -插件前端 SDK 的正式包名是 `@doudou-start/airgate-theme`。插件业务代码优先使用 `@doudou-start/airgate-theme/plugin`,该入口提供主题初始化、样式作用域、Tailwind bridge、插件前端类型和公共 UI 组件。 +插件前端 SDK 的正式包名是 `@devilgenius/airgate-theme`。插件业务代码优先使用 `@devilgenius/airgate-theme/plugin`,该入口提供主题初始化、样式作用域、Tailwind bridge、插件前端类型和公共 UI 组件。 ### package.json @@ -39,7 +39,7 @@ your-plugin/ "dev": "vite build --watch" }, "dependencies": { - "@doudou-start/airgate-theme": "^1.0.0", + "@devilgenius/airgate-theme": "^1.0.0", "react": "^19.0.0", "react-dom": "^19.0.0" }, @@ -84,7 +84,7 @@ export default defineConfig({ ```ts import type { Config } from 'tailwindcss'; -import { createPluginTailwindConfig } from '@doudou-start/airgate-theme/plugin'; +import { createPluginTailwindConfig } from '@devilgenius/airgate-theme/plugin'; const config: Config = { content: ['./src/**/*.{ts,tsx}'], @@ -118,7 +118,7 @@ module.exports = { ### theme/runtime.ts ```ts -import { ensurePluginStyleFoundation } from '@doudou-start/airgate-theme/plugin'; +import { ensurePluginStyleFoundation } from '@devilgenius/airgate-theme/plugin'; import tailwindCssText from '../styles/tailwind.css?inline'; export const THEME_SCOPE_SELECTOR = '[data-ag-YOUR_PLUGIN-root]'; @@ -165,7 +165,7 @@ export default { 2. 使用 `useScopedPluginTheme` 跟随 Core 的明暗切换 ```tsx -import { useScopedPluginTheme } from '@doudou-start/airgate-theme/plugin'; +import { useScopedPluginTheme } from '@devilgenius/airgate-theme/plugin'; const THEME_ATTRIBUTE = 'data-theme'; const STORAGE_KEY = 'ag-YOUR_PLUGIN-theme'; @@ -249,7 +249,7 @@ export function YourComponent(props) { ## 6. SDK 提供的 UI 组件 -SDK 提供了一套预制组件(`@doudou-start/airgate-theme/plugin`),样式与 Core 保持一致,属于插件前端稳定公共契约。插件业务 UI **优先使用这些组件**: +SDK 提供了一套预制组件(`@devilgenius/airgate-theme/plugin`),样式与 Core 保持一致,属于插件前端稳定公共契约。插件业务 UI **优先使用这些组件**: ```tsx import { @@ -265,7 +265,7 @@ import { FormActions, // 表单操作区(flex wrap) Badge, // 标签徽章(neutral / success / violet / info) StatusText, // 内联状态文字(info / success / error) -} from '@doudou-start/airgate-theme/plugin'; +} from '@devilgenius/airgate-theme/plugin'; ``` ### 使用示例 diff --git a/docs/sdk-package-boundaries.md b/docs/sdk-package-boundaries.md index f5c02fb..eb9d5a6 100644 --- a/docs/sdk-package-boundaries.md +++ b/docs/sdk-package-boundaries.md @@ -43,20 +43,18 @@ ## 弱契约扩展点 -SDK 提供少量弱契约扩展点,用来承接展示、分类和通用计量等变化,避免为每个插件需求新增强类型字段: +SDK 提供少量弱契约扩展点,用来承接展示、分类和插件专属数据等变化,避免为每个插件需求新增强类型字段: - `PluginInfo.Metadata`:插件市场分类、标签、展示提示等。 - `ModelInfo.Metadata`:模型家族、展示分组、供应商标签等。 - `RouteDefinition.Metadata`:路由文档链接、展示分组、调试提示等。 -- `Usage.Attributes`:模型、思考层级、分辨率、质量档、服务档位等非数值审计维度。 -- `Usage.Metrics`:图片张数、视频秒数、音频分钟数、工具调用次数、token 等插件计算后的通用计量结果。 -- `Usage.CostDetails`:费用明细;插件填账号成本,Core 填用户扣费和倍率。 -- `Usage.Metadata`:单次调用的展示或审计辅助信息。 +- `Usage` 标准标量字段:模型、token、单价、账号成本、首 token 耗时、思考强度等跨插件通用事实。 +- `Usage.Metadata`:单次调用的插件专属展示或审计辅助信息,使用插件命名空间 key。 - `EventHandler`:Core 向插件推送标准事件。 - `Host.Invoke` / `Host.InvokeStream`:插件用 `method + payload` 调用 Core 开放的方法,必须由 `host.invoke` 或 `host.invoke.` capability 门控。 - `SchemaProvider`:插件声明 routes、tasks、events、invokes 的 payload schema;流式 Host method 用 `InvokeSchema.Transport`、`ClientFrame`、`ServerFrame` 描述传输模式和帧结构。 -这些字段不能用于权限、调度、账号状态机或敏感数据传递。平台计费规则不得进入 SDK;网关插件负责计算标准账号成本 `Usage.AccountCost` / `Currency` 和审计明细。Core 统一入库、索引、汇总,并写入 `UserCost` / `BillingMultiplier`。 +这些字段不能用于权限、调度、账号状态机或敏感数据传递。平台计费规则不得进入 SDK;网关插件负责计算标准账号成本 `Usage.AccountCost` / `Currency` 和标准计费字段。Core 统一入库、索引、汇总,并写入 `UserCost` / `BillingMultiplier`。 ## 用量与计费边界 @@ -65,9 +63,9 @@ SDK 不提供 `CalculateCost`、价格档位、token 拆分公式或平台套餐 - 模型声明只包含 `ID`、`Name`、上下文窗口、最大输出和能力标签。 - 单次调用的标准账号成本由网关插件写入 `Usage.AccountCost` / `Usage.Currency`。 - Core 根据用户、分组、模型等倍率计算用户侧扣费,写入 `Usage.UserCost` / `Usage.BillingMultiplier`。 -- 模型、思考层级、分辨率、质量档等非数值维度统一放入 `Usage.Attributes`。 -- token、图片、音频、视频、请求数等数值明细统一放入 `Usage.Metrics`。 -- 标准账号成本和用户扣费拆分统一放入 `Usage.CostDetails`:插件填 `AccountCost`,Core 填 `UserCost` / `BillingMultiplier`。 +- 跨插件通用维度优先使用 `Usage` 标准字段,例如 `Model`、token 字段、单价、成本和 `ReasoningEffort`。 +- 插件专属维度放入 `Usage.Metadata`,例如 `openai.image.size` 或 `claude.cache_creation_1h_tokens`。 +- 费用拆分由前端从标准成本、单价、倍率字段和 metadata 计算展示,不再通过 SDK 传输明细数组。 - 使用记录和账号管理页面由插件前端与插件私有 API 实现,SDK 不定义账号用量查询 RPC。 - Core 不应把平台规则写入 SDK 或 Core 公共逻辑;Core 统一入库 `Usage`,需要页面时加载插件的静态资源和 API 代理。 @@ -103,9 +101,9 @@ SDK 只提供传输契约和自检 helper,不承载 Core 方法枚举。这样 ## 当前导入路径 -- 插件业务代码使用 `github.com/DouDOU-start/airgate-sdk/sdkgo`。 -- 插件运行入口使用 `github.com/DouDOU-start/airgate-sdk/runtimego/grpc`。 -- 本地开发工具使用 `github.com/DouDOU-start/airgate-sdk/devkit/devserver`。 +- 插件业务代码使用 `github.com/DevilGenius/airgate-sdk/sdkgo`。 +- 插件运行入口使用 `github.com/DevilGenius/airgate-sdk/runtimego/grpc`。 +- 本地开发工具使用 `github.com/DevilGenius/airgate-sdk/devkit/devserver`。 - 普通插件业务代码不直接导入 `protocol/proto`。 -- 插件前端使用 `@doudou-start/airgate-theme/plugin` 引用样式隔离、主题同步、Tailwind helper 和公共 UI 组件。 -- 宿主前端或工具代码可使用 `@doudou-start/airgate-theme`、`@doudou-start/airgate-theme/css`、`@doudou-start/airgate-theme/tailwind` 引用 token 与主题桥接能力。 +- 插件前端使用 `@devilgenius/airgate-theme/plugin` 引用样式隔离、主题同步、Tailwind helper 和公共 UI 组件。 +- 宿主前端或工具代码可使用 `@devilgenius/airgate-theme`、`@devilgenius/airgate-theme/css`、`@devilgenius/airgate-theme/tailwind` 引用 token 与主题桥接能力。 diff --git a/go.mod b/go.mod index 98d176b..a719f2d 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/DouDOU-start/airgate-sdk +module github.com/DevilGenius/airgate-sdk go 1.25.7 diff --git a/protocol/proto/plugin.pb.go b/protocol/proto/plugin.pb.go index 52c4782..6ab43cd 100644 --- a/protocol/proto/plugin.pb.go +++ b/protocol/proto/plugin.pb.go @@ -34,6 +34,7 @@ const ( OutcomeKind_OUTCOME_UPSTREAM_TRANSIENT OutcomeKind = 5 OutcomeKind_OUTCOME_STREAM_ABORTED OutcomeKind = 6 OutcomeKind_OUTCOME_ACCOUNT_MODEL_UNSUPPORTED OutcomeKind = 7 + OutcomeKind_OUTCOME_ACCOUNT_UNAVAILABLE OutcomeKind = 8 ) // Enum value maps for OutcomeKind. @@ -47,6 +48,7 @@ var ( 5: "OUTCOME_UPSTREAM_TRANSIENT", 6: "OUTCOME_STREAM_ABORTED", 7: "OUTCOME_ACCOUNT_MODEL_UNSUPPORTED", + 8: "OUTCOME_ACCOUNT_UNAVAILABLE", } OutcomeKind_value = map[string]int32{ "OUTCOME_UNKNOWN": 0, @@ -57,6 +59,7 @@ var ( "OUTCOME_UPSTREAM_TRANSIENT": 5, "OUTCOME_STREAM_ABORTED": 6, "OUTCOME_ACCOUNT_MODEL_UNSUPPORTED": 7, + "OUTCOME_ACCOUNT_UNAVAILABLE": 8, } ) @@ -139,7 +142,7 @@ func (x WebSocketFrame_FrameType) Number() protoreflect.EnumNumber { // Deprecated: Use WebSocketFrame_FrameType.Descriptor instead. func (WebSocketFrame_FrameType) EnumDescriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{30, 0} + return file_plugin_proto_rawDescGZIP(), []int{27, 0} } type MiddlewareDecision_Action int32 @@ -188,7 +191,7 @@ func (x MiddlewareDecision_Action) Number() protoreflect.EnumNumber { // Deprecated: Use MiddlewareDecision_Action.Descriptor instead. func (MiddlewareDecision_Action) EnumDescriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{42, 0} + return file_plugin_proto_rawDescGZIP(), []int{39, 0} } type Empty struct { @@ -1391,32 +1394,49 @@ func (x *UpstreamResponse) GetBody() []byte { return nil } -// UsageAttribute 是插件计算后的通用审计维度。 -type UsageAttribute struct { - state protoimpl.MessageState `protogen:"open.v1"` - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Label string `protobuf:"bytes,2,opt,name=label,proto3" json:"label,omitempty"` - Kind string `protobuf:"bytes,3,opt,name=kind,proto3" json:"kind,omitempty"` - Value string `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty"` - Metadata map[string]string `protobuf:"bytes,5,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache +// Usage 单次调用的用量与费用结果。非 Success 判决下应为空。 +type Usage struct { + state protoimpl.MessageState `protogen:"open.v1"` + Model string `protobuf:"bytes,1,opt,name=model,proto3" json:"model,omitempty"` + AccountCost float64 `protobuf:"fixed64,2,opt,name=account_cost,json=accountCost,proto3" json:"account_cost,omitempty"` + UserCost float64 `protobuf:"fixed64,3,opt,name=user_cost,json=userCost,proto3" json:"user_cost,omitempty"` + BillingMultiplier float64 `protobuf:"fixed64,4,opt,name=billing_multiplier,json=billingMultiplier,proto3" json:"billing_multiplier,omitempty"` + Currency string `protobuf:"bytes,5,opt,name=currency,proto3" json:"currency,omitempty"` + Summary string `protobuf:"bytes,6,opt,name=summary,proto3" json:"summary,omitempty"` + FirstTokenMs int64 `protobuf:"varint,7,opt,name=first_token_ms,json=firstTokenMs,proto3" json:"first_token_ms,omitempty"` + Metadata map[string]string `protobuf:"bytes,11,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + InputTokens int64 `protobuf:"varint,12,opt,name=input_tokens,json=inputTokens,proto3" json:"input_tokens,omitempty"` + OutputTokens int64 `protobuf:"varint,13,opt,name=output_tokens,json=outputTokens,proto3" json:"output_tokens,omitempty"` + CachedInputTokens int64 `protobuf:"varint,14,opt,name=cached_input_tokens,json=cachedInputTokens,proto3" json:"cached_input_tokens,omitempty"` + CacheCreationTokens int64 `protobuf:"varint,15,opt,name=cache_creation_tokens,json=cacheCreationTokens,proto3" json:"cache_creation_tokens,omitempty"` + ReasoningOutputTokens int64 `protobuf:"varint,18,opt,name=reasoning_output_tokens,json=reasoningOutputTokens,proto3" json:"reasoning_output_tokens,omitempty"` + InputPrice float64 `protobuf:"fixed64,22,opt,name=input_price,json=inputPrice,proto3" json:"input_price,omitempty"` + OutputPrice float64 `protobuf:"fixed64,23,opt,name=output_price,json=outputPrice,proto3" json:"output_price,omitempty"` + CachedInputPrice float64 `protobuf:"fixed64,24,opt,name=cached_input_price,json=cachedInputPrice,proto3" json:"cached_input_price,omitempty"` + CacheCreationPrice float64 `protobuf:"fixed64,25,opt,name=cache_creation_price,json=cacheCreationPrice,proto3" json:"cache_creation_price,omitempty"` + InputCost float64 `protobuf:"fixed64,27,opt,name=input_cost,json=inputCost,proto3" json:"input_cost,omitempty"` + OutputCost float64 `protobuf:"fixed64,28,opt,name=output_cost,json=outputCost,proto3" json:"output_cost,omitempty"` + CachedInputCost float64 `protobuf:"fixed64,29,opt,name=cached_input_cost,json=cachedInputCost,proto3" json:"cached_input_cost,omitempty"` + CacheCreationCost float64 `protobuf:"fixed64,30,opt,name=cache_creation_cost,json=cacheCreationCost,proto3" json:"cache_creation_cost,omitempty"` + ReasoningEffort string `protobuf:"bytes,35,opt,name=reasoning_effort,json=reasoningEffort,proto3" json:"reasoning_effort,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } -func (x *UsageAttribute) Reset() { - *x = UsageAttribute{} +func (x *Usage) Reset() { + *x = Usage{} mi := &file_plugin_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *UsageAttribute) String() string { +func (x *Usage) String() string { return protoimpl.X.MessageStringOf(x) } -func (*UsageAttribute) ProtoMessage() {} +func (*Usage) ProtoMessage() {} -func (x *UsageAttribute) ProtoReflect() protoreflect.Message { +func (x *Usage) ProtoReflect() protoreflect.Message { mi := &file_plugin_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -1428,363 +1448,163 @@ func (x *UsageAttribute) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use UsageAttribute.ProtoReflect.Descriptor instead. -func (*UsageAttribute) Descriptor() ([]byte, []int) { +// Deprecated: Use Usage.ProtoReflect.Descriptor instead. +func (*Usage) Descriptor() ([]byte, []int) { return file_plugin_proto_rawDescGZIP(), []int{17} } -func (x *UsageAttribute) GetKey() string { - if x != nil { - return x.Key - } - return "" -} - -func (x *UsageAttribute) GetLabel() string { - if x != nil { - return x.Label - } - return "" -} - -func (x *UsageAttribute) GetKind() string { - if x != nil { - return x.Kind - } - return "" -} - -func (x *UsageAttribute) GetValue() string { +func (x *Usage) GetModel() string { if x != nil { - return x.Value + return x.Model } return "" } -func (x *UsageAttribute) GetMetadata() map[string]string { - if x != nil { - return x.Metadata - } - return nil -} - -// UsageMetric 是插件计算后的通用计量结果。 -type UsageMetric struct { - state protoimpl.MessageState `protogen:"open.v1"` - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Label string `protobuf:"bytes,2,opt,name=label,proto3" json:"label,omitempty"` - Kind string `protobuf:"bytes,3,opt,name=kind,proto3" json:"kind,omitempty"` - Unit string `protobuf:"bytes,4,opt,name=unit,proto3" json:"unit,omitempty"` - Value float64 `protobuf:"fixed64,5,opt,name=value,proto3" json:"value,omitempty"` - AccountCost float64 `protobuf:"fixed64,6,opt,name=account_cost,json=accountCost,proto3" json:"account_cost,omitempty"` - Currency string `protobuf:"bytes,7,opt,name=currency,proto3" json:"currency,omitempty"` - Metadata map[string]string `protobuf:"bytes,8,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UsageMetric) Reset() { - *x = UsageMetric{} - mi := &file_plugin_proto_msgTypes[18] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UsageMetric) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UsageMetric) ProtoMessage() {} - -func (x *UsageMetric) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[18] +func (x *Usage) GetAccountCost() float64 { if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms + return x.AccountCost } - return mi.MessageOf(x) -} - -// Deprecated: Use UsageMetric.ProtoReflect.Descriptor instead. -func (*UsageMetric) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{18} + return 0 } -func (x *UsageMetric) GetKey() string { +func (x *Usage) GetUserCost() float64 { if x != nil { - return x.Key + return x.UserCost } - return "" + return 0 } -func (x *UsageMetric) GetLabel() string { +func (x *Usage) GetBillingMultiplier() float64 { if x != nil { - return x.Label + return x.BillingMultiplier } - return "" + return 0 } -func (x *UsageMetric) GetKind() string { +func (x *Usage) GetCurrency() string { if x != nil { - return x.Kind + return x.Currency } return "" } -func (x *UsageMetric) GetUnit() string { +func (x *Usage) GetSummary() string { if x != nil { - return x.Unit + return x.Summary } return "" } -func (x *UsageMetric) GetValue() float64 { - if x != nil { - return x.Value - } - return 0 -} - -func (x *UsageMetric) GetAccountCost() float64 { +func (x *Usage) GetFirstTokenMs() int64 { if x != nil { - return x.AccountCost + return x.FirstTokenMs } return 0 } -func (x *UsageMetric) GetCurrency() string { - if x != nil { - return x.Currency - } - return "" -} - -func (x *UsageMetric) GetMetadata() map[string]string { +func (x *Usage) GetMetadata() map[string]string { if x != nil { return x.Metadata } return nil } -// UsageCostDetail 是通用费用明细。 -type UsageCostDetail struct { - state protoimpl.MessageState `protogen:"open.v1"` - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Label string `protobuf:"bytes,2,opt,name=label,proto3" json:"label,omitempty"` - AccountCost float64 `protobuf:"fixed64,3,opt,name=account_cost,json=accountCost,proto3" json:"account_cost,omitempty"` - UserCost float64 `protobuf:"fixed64,4,opt,name=user_cost,json=userCost,proto3" json:"user_cost,omitempty"` - BillingMultiplier float64 `protobuf:"fixed64,5,opt,name=billing_multiplier,json=billingMultiplier,proto3" json:"billing_multiplier,omitempty"` - Currency string `protobuf:"bytes,6,opt,name=currency,proto3" json:"currency,omitempty"` - Metadata map[string]string `protobuf:"bytes,7,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UsageCostDetail) Reset() { - *x = UsageCostDetail{} - mi := &file_plugin_proto_msgTypes[19] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UsageCostDetail) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UsageCostDetail) ProtoMessage() {} - -func (x *UsageCostDetail) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[19] +func (x *Usage) GetInputTokens() int64 { if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UsageCostDetail.ProtoReflect.Descriptor instead. -func (*UsageCostDetail) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{19} -} - -func (x *UsageCostDetail) GetKey() string { - if x != nil { - return x.Key - } - return "" -} - -func (x *UsageCostDetail) GetLabel() string { - if x != nil { - return x.Label - } - return "" -} - -func (x *UsageCostDetail) GetAccountCost() float64 { - if x != nil { - return x.AccountCost + return x.InputTokens } return 0 } -func (x *UsageCostDetail) GetUserCost() float64 { +func (x *Usage) GetOutputTokens() int64 { if x != nil { - return x.UserCost + return x.OutputTokens } return 0 } -func (x *UsageCostDetail) GetBillingMultiplier() float64 { +func (x *Usage) GetCachedInputTokens() int64 { if x != nil { - return x.BillingMultiplier + return x.CachedInputTokens } return 0 } -func (x *UsageCostDetail) GetCurrency() string { - if x != nil { - return x.Currency - } - return "" -} - -func (x *UsageCostDetail) GetMetadata() map[string]string { - if x != nil { - return x.Metadata - } - return nil -} - -// Usage 单次调用的用量与费用结果。非 Success 判决下应为空。 -type Usage struct { - state protoimpl.MessageState `protogen:"open.v1"` - Model string `protobuf:"bytes,1,opt,name=model,proto3" json:"model,omitempty"` - AccountCost float64 `protobuf:"fixed64,2,opt,name=account_cost,json=accountCost,proto3" json:"account_cost,omitempty"` - UserCost float64 `protobuf:"fixed64,3,opt,name=user_cost,json=userCost,proto3" json:"user_cost,omitempty"` - BillingMultiplier float64 `protobuf:"fixed64,4,opt,name=billing_multiplier,json=billingMultiplier,proto3" json:"billing_multiplier,omitempty"` - Currency string `protobuf:"bytes,5,opt,name=currency,proto3" json:"currency,omitempty"` - Summary string `protobuf:"bytes,6,opt,name=summary,proto3" json:"summary,omitempty"` - FirstTokenMs int64 `protobuf:"varint,7,opt,name=first_token_ms,json=firstTokenMs,proto3" json:"first_token_ms,omitempty"` - Metrics []*UsageMetric `protobuf:"bytes,8,rep,name=metrics,proto3" json:"metrics,omitempty"` - Attributes []*UsageAttribute `protobuf:"bytes,9,rep,name=attributes,proto3" json:"attributes,omitempty"` - CostDetails []*UsageCostDetail `protobuf:"bytes,10,rep,name=cost_details,json=costDetails,proto3" json:"cost_details,omitempty"` - Metadata map[string]string `protobuf:"bytes,11,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Usage) Reset() { - *x = Usage{} - mi := &file_plugin_proto_msgTypes[20] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Usage) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Usage) ProtoMessage() {} - -func (x *Usage) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[20] +func (x *Usage) GetCacheCreationTokens() int64 { if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms + return x.CacheCreationTokens } - return mi.MessageOf(x) -} - -// Deprecated: Use Usage.ProtoReflect.Descriptor instead. -func (*Usage) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{20} -} - -func (x *Usage) GetModel() string { - if x != nil { - return x.Model - } - return "" + return 0 } -func (x *Usage) GetAccountCost() float64 { +func (x *Usage) GetReasoningOutputTokens() int64 { if x != nil { - return x.AccountCost + return x.ReasoningOutputTokens } return 0 } -func (x *Usage) GetUserCost() float64 { +func (x *Usage) GetInputPrice() float64 { if x != nil { - return x.UserCost + return x.InputPrice } return 0 } -func (x *Usage) GetBillingMultiplier() float64 { +func (x *Usage) GetOutputPrice() float64 { if x != nil { - return x.BillingMultiplier + return x.OutputPrice } return 0 } -func (x *Usage) GetCurrency() string { +func (x *Usage) GetCachedInputPrice() float64 { if x != nil { - return x.Currency + return x.CachedInputPrice } - return "" + return 0 } -func (x *Usage) GetSummary() string { +func (x *Usage) GetCacheCreationPrice() float64 { if x != nil { - return x.Summary + return x.CacheCreationPrice } - return "" + return 0 } -func (x *Usage) GetFirstTokenMs() int64 { +func (x *Usage) GetInputCost() float64 { if x != nil { - return x.FirstTokenMs + return x.InputCost } return 0 } -func (x *Usage) GetMetrics() []*UsageMetric { +func (x *Usage) GetOutputCost() float64 { if x != nil { - return x.Metrics + return x.OutputCost } - return nil + return 0 } -func (x *Usage) GetAttributes() []*UsageAttribute { +func (x *Usage) GetCachedInputCost() float64 { if x != nil { - return x.Attributes + return x.CachedInputCost } - return nil + return 0 } -func (x *Usage) GetCostDetails() []*UsageCostDetail { +func (x *Usage) GetCacheCreationCost() float64 { if x != nil { - return x.CostDetails + return x.CacheCreationCost } - return nil + return 0 } -func (x *Usage) GetMetadata() map[string]string { +func (x *Usage) GetReasoningEffort() string { if x != nil { - return x.Metadata + return x.ReasoningEffort } - return nil + return "" } // ForwardOutcome 插件对一次 Forward 的完整判决结果。 @@ -1803,7 +1623,7 @@ type ForwardOutcome struct { func (x *ForwardOutcome) Reset() { *x = ForwardOutcome{} - mi := &file_plugin_proto_msgTypes[21] + mi := &file_plugin_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1815,7 +1635,7 @@ func (x *ForwardOutcome) String() string { func (*ForwardOutcome) ProtoMessage() {} func (x *ForwardOutcome) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[21] + mi := &file_plugin_proto_msgTypes[18] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1828,7 +1648,7 @@ func (x *ForwardOutcome) ProtoReflect() protoreflect.Message { // Deprecated: Use ForwardOutcome.ProtoReflect.Descriptor instead. func (*ForwardOutcome) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{21} + return file_plugin_proto_rawDescGZIP(), []int{18} } func (x *ForwardOutcome) GetKind() OutcomeKind { @@ -1893,7 +1713,7 @@ type ForwardChunk struct { func (x *ForwardChunk) Reset() { *x = ForwardChunk{} - mi := &file_plugin_proto_msgTypes[22] + mi := &file_plugin_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1905,7 +1725,7 @@ func (x *ForwardChunk) String() string { func (*ForwardChunk) ProtoMessage() {} func (x *ForwardChunk) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[22] + mi := &file_plugin_proto_msgTypes[19] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1918,7 +1738,7 @@ func (x *ForwardChunk) ProtoReflect() protoreflect.Message { // Deprecated: Use ForwardChunk.ProtoReflect.Descriptor instead. func (*ForwardChunk) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{22} + return file_plugin_proto_rawDescGZIP(), []int{19} } func (x *ForwardChunk) GetData() []byte { @@ -1965,7 +1785,7 @@ type CredentialsRequest struct { func (x *CredentialsRequest) Reset() { *x = CredentialsRequest{} - mi := &file_plugin_proto_msgTypes[23] + mi := &file_plugin_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1977,7 +1797,7 @@ func (x *CredentialsRequest) String() string { func (*CredentialsRequest) ProtoMessage() {} func (x *CredentialsRequest) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[23] + mi := &file_plugin_proto_msgTypes[20] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1990,7 +1810,7 @@ func (x *CredentialsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CredentialsRequest.ProtoReflect.Descriptor instead. func (*CredentialsRequest) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{23} + return file_plugin_proto_rawDescGZIP(), []int{20} } func (x *CredentialsRequest) GetCredentials() map[string]string { @@ -2014,7 +1834,7 @@ type HttpRequest struct { func (x *HttpRequest) Reset() { *x = HttpRequest{} - mi := &file_plugin_proto_msgTypes[24] + mi := &file_plugin_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2026,7 +1846,7 @@ func (x *HttpRequest) String() string { func (*HttpRequest) ProtoMessage() {} func (x *HttpRequest) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[24] + mi := &file_plugin_proto_msgTypes[21] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2039,7 +1859,7 @@ func (x *HttpRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use HttpRequest.ProtoReflect.Descriptor instead. func (*HttpRequest) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{24} + return file_plugin_proto_rawDescGZIP(), []int{21} } func (x *HttpRequest) GetMethod() string { @@ -2095,7 +1915,7 @@ type HttpResponse struct { func (x *HttpResponse) Reset() { *x = HttpResponse{} - mi := &file_plugin_proto_msgTypes[25] + mi := &file_plugin_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2107,7 +1927,7 @@ func (x *HttpResponse) String() string { func (*HttpResponse) ProtoMessage() {} func (x *HttpResponse) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[25] + mi := &file_plugin_proto_msgTypes[22] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2120,7 +1940,7 @@ func (x *HttpResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use HttpResponse.ProtoReflect.Descriptor instead. func (*HttpResponse) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{25} + return file_plugin_proto_rawDescGZIP(), []int{22} } func (x *HttpResponse) GetStatusCode() int32 { @@ -2156,7 +1976,7 @@ type HttpResponseChunk struct { func (x *HttpResponseChunk) Reset() { *x = HttpResponseChunk{} - mi := &file_plugin_proto_msgTypes[26] + mi := &file_plugin_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2168,7 +1988,7 @@ func (x *HttpResponseChunk) String() string { func (*HttpResponseChunk) ProtoMessage() {} func (x *HttpResponseChunk) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[26] + mi := &file_plugin_proto_msgTypes[23] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2181,7 +2001,7 @@ func (x *HttpResponseChunk) ProtoReflect() protoreflect.Message { // Deprecated: Use HttpResponseChunk.ProtoReflect.Descriptor instead. func (*HttpResponseChunk) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{26} + return file_plugin_proto_rawDescGZIP(), []int{23} } func (x *HttpResponseChunk) GetData() []byte { @@ -2222,7 +2042,7 @@ type BackgroundTaskProto struct { func (x *BackgroundTaskProto) Reset() { *x = BackgroundTaskProto{} - mi := &file_plugin_proto_msgTypes[27] + mi := &file_plugin_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2234,7 +2054,7 @@ func (x *BackgroundTaskProto) String() string { func (*BackgroundTaskProto) ProtoMessage() {} func (x *BackgroundTaskProto) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[27] + mi := &file_plugin_proto_msgTypes[24] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2247,7 +2067,7 @@ func (x *BackgroundTaskProto) ProtoReflect() protoreflect.Message { // Deprecated: Use BackgroundTaskProto.ProtoReflect.Descriptor instead. func (*BackgroundTaskProto) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{27} + return file_plugin_proto_rawDescGZIP(), []int{24} } func (x *BackgroundTaskProto) GetName() string { @@ -2273,7 +2093,7 @@ type BackgroundTasksResponse struct { func (x *BackgroundTasksResponse) Reset() { *x = BackgroundTasksResponse{} - mi := &file_plugin_proto_msgTypes[28] + mi := &file_plugin_proto_msgTypes[25] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2285,7 +2105,7 @@ func (x *BackgroundTasksResponse) String() string { func (*BackgroundTasksResponse) ProtoMessage() {} func (x *BackgroundTasksResponse) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[28] + mi := &file_plugin_proto_msgTypes[25] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2298,7 +2118,7 @@ func (x *BackgroundTasksResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use BackgroundTasksResponse.ProtoReflect.Descriptor instead. func (*BackgroundTasksResponse) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{28} + return file_plugin_proto_rawDescGZIP(), []int{25} } func (x *BackgroundTasksResponse) GetTasks() []*BackgroundTaskProto { @@ -2317,7 +2137,7 @@ type RunBackgroundTaskRequest struct { func (x *RunBackgroundTaskRequest) Reset() { *x = RunBackgroundTaskRequest{} - mi := &file_plugin_proto_msgTypes[29] + mi := &file_plugin_proto_msgTypes[26] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2329,7 +2149,7 @@ func (x *RunBackgroundTaskRequest) String() string { func (*RunBackgroundTaskRequest) ProtoMessage() {} func (x *RunBackgroundTaskRequest) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[29] + mi := &file_plugin_proto_msgTypes[26] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2342,7 +2162,7 @@ func (x *RunBackgroundTaskRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RunBackgroundTaskRequest.ProtoReflect.Descriptor instead. func (*RunBackgroundTaskRequest) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{29} + return file_plugin_proto_rawDescGZIP(), []int{26} } func (x *RunBackgroundTaskRequest) GetName() string { @@ -2369,7 +2189,7 @@ type WebSocketFrame struct { func (x *WebSocketFrame) Reset() { *x = WebSocketFrame{} - mi := &file_plugin_proto_msgTypes[30] + mi := &file_plugin_proto_msgTypes[27] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2381,7 +2201,7 @@ func (x *WebSocketFrame) String() string { func (*WebSocketFrame) ProtoMessage() {} func (x *WebSocketFrame) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[30] + mi := &file_plugin_proto_msgTypes[27] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2394,7 +2214,7 @@ func (x *WebSocketFrame) ProtoReflect() protoreflect.Message { // Deprecated: Use WebSocketFrame.ProtoReflect.Descriptor instead. func (*WebSocketFrame) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{30} + return file_plugin_proto_rawDescGZIP(), []int{27} } func (x *WebSocketFrame) GetType() WebSocketFrame_FrameType { @@ -2453,7 +2273,7 @@ type WebSocketConnectInfo struct { func (x *WebSocketConnectInfo) Reset() { *x = WebSocketConnectInfo{} - mi := &file_plugin_proto_msgTypes[31] + mi := &file_plugin_proto_msgTypes[28] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2465,7 +2285,7 @@ func (x *WebSocketConnectInfo) String() string { func (*WebSocketConnectInfo) ProtoMessage() {} func (x *WebSocketConnectInfo) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[31] + mi := &file_plugin_proto_msgTypes[28] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2478,7 +2298,7 @@ func (x *WebSocketConnectInfo) ProtoReflect() protoreflect.Message { // Deprecated: Use WebSocketConnectInfo.ProtoReflect.Descriptor instead. func (*WebSocketConnectInfo) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{31} + return file_plugin_proto_rawDescGZIP(), []int{28} } func (x *WebSocketConnectInfo) GetPath() string { @@ -2533,7 +2353,7 @@ type WebAssetFile struct { func (x *WebAssetFile) Reset() { *x = WebAssetFile{} - mi := &file_plugin_proto_msgTypes[32] + mi := &file_plugin_proto_msgTypes[29] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2545,7 +2365,7 @@ func (x *WebAssetFile) String() string { func (*WebAssetFile) ProtoMessage() {} func (x *WebAssetFile) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[32] + mi := &file_plugin_proto_msgTypes[29] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2558,7 +2378,7 @@ func (x *WebAssetFile) ProtoReflect() protoreflect.Message { // Deprecated: Use WebAssetFile.ProtoReflect.Descriptor instead. func (*WebAssetFile) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{32} + return file_plugin_proto_rawDescGZIP(), []int{29} } func (x *WebAssetFile) GetPath() string { @@ -2585,7 +2405,7 @@ type WebAssetsResponse struct { func (x *WebAssetsResponse) Reset() { *x = WebAssetsResponse{} - mi := &file_plugin_proto_msgTypes[33] + mi := &file_plugin_proto_msgTypes[30] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2597,7 +2417,7 @@ func (x *WebAssetsResponse) String() string { func (*WebAssetsResponse) ProtoMessage() {} func (x *WebAssetsResponse) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[33] + mi := &file_plugin_proto_msgTypes[30] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2610,7 +2430,7 @@ func (x *WebAssetsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use WebAssetsResponse.ProtoReflect.Descriptor instead. func (*WebAssetsResponse) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{33} + return file_plugin_proto_rawDescGZIP(), []int{30} } func (x *WebAssetsResponse) GetFiles() []*WebAssetFile { @@ -2639,7 +2459,7 @@ type PayloadSchemaProto struct { func (x *PayloadSchemaProto) Reset() { *x = PayloadSchemaProto{} - mi := &file_plugin_proto_msgTypes[34] + mi := &file_plugin_proto_msgTypes[31] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2651,7 +2471,7 @@ func (x *PayloadSchemaProto) String() string { func (*PayloadSchemaProto) ProtoMessage() {} func (x *PayloadSchemaProto) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[34] + mi := &file_plugin_proto_msgTypes[31] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2664,7 +2484,7 @@ func (x *PayloadSchemaProto) ProtoReflect() protoreflect.Message { // Deprecated: Use PayloadSchemaProto.ProtoReflect.Descriptor instead. func (*PayloadSchemaProto) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{34} + return file_plugin_proto_rawDescGZIP(), []int{31} } func (x *PayloadSchemaProto) GetContentType() string { @@ -2709,7 +2529,7 @@ type RouteSchemaProto struct { func (x *RouteSchemaProto) Reset() { *x = RouteSchemaProto{} - mi := &file_plugin_proto_msgTypes[35] + mi := &file_plugin_proto_msgTypes[32] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2721,7 +2541,7 @@ func (x *RouteSchemaProto) String() string { func (*RouteSchemaProto) ProtoMessage() {} func (x *RouteSchemaProto) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[35] + mi := &file_plugin_proto_msgTypes[32] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2734,7 +2554,7 @@ func (x *RouteSchemaProto) ProtoReflect() protoreflect.Message { // Deprecated: Use RouteSchemaProto.ProtoReflect.Descriptor instead. func (*RouteSchemaProto) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{35} + return file_plugin_proto_rawDescGZIP(), []int{32} } func (x *RouteSchemaProto) GetMethod() string { @@ -2792,7 +2612,7 @@ type TaskSchemaProto struct { func (x *TaskSchemaProto) Reset() { *x = TaskSchemaProto{} - mi := &file_plugin_proto_msgTypes[36] + mi := &file_plugin_proto_msgTypes[33] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2804,7 +2624,7 @@ func (x *TaskSchemaProto) String() string { func (*TaskSchemaProto) ProtoMessage() {} func (x *TaskSchemaProto) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[36] + mi := &file_plugin_proto_msgTypes[33] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2817,7 +2637,7 @@ func (x *TaskSchemaProto) ProtoReflect() protoreflect.Message { // Deprecated: Use TaskSchemaProto.ProtoReflect.Descriptor instead. func (*TaskSchemaProto) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{36} + return file_plugin_proto_rawDescGZIP(), []int{33} } func (x *TaskSchemaProto) GetType() string { @@ -2868,7 +2688,7 @@ type EventSchemaProto struct { func (x *EventSchemaProto) Reset() { *x = EventSchemaProto{} - mi := &file_plugin_proto_msgTypes[37] + mi := &file_plugin_proto_msgTypes[34] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2880,7 +2700,7 @@ func (x *EventSchemaProto) String() string { func (*EventSchemaProto) ProtoMessage() {} func (x *EventSchemaProto) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[37] + mi := &file_plugin_proto_msgTypes[34] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2893,7 +2713,7 @@ func (x *EventSchemaProto) ProtoReflect() protoreflect.Message { // Deprecated: Use EventSchemaProto.ProtoReflect.Descriptor instead. func (*EventSchemaProto) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{37} + return file_plugin_proto_rawDescGZIP(), []int{34} } func (x *EventSchemaProto) GetType() string { @@ -2947,7 +2767,7 @@ type InvokeSchemaProto struct { func (x *InvokeSchemaProto) Reset() { *x = InvokeSchemaProto{} - mi := &file_plugin_proto_msgTypes[38] + mi := &file_plugin_proto_msgTypes[35] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2959,7 +2779,7 @@ func (x *InvokeSchemaProto) String() string { func (*InvokeSchemaProto) ProtoMessage() {} func (x *InvokeSchemaProto) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[38] + mi := &file_plugin_proto_msgTypes[35] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2972,7 +2792,7 @@ func (x *InvokeSchemaProto) ProtoReflect() protoreflect.Message { // Deprecated: Use InvokeSchemaProto.ProtoReflect.Descriptor instead. func (*InvokeSchemaProto) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{38} + return file_plugin_proto_rawDescGZIP(), []int{35} } func (x *InvokeSchemaProto) GetMethod() string { @@ -3044,7 +2864,7 @@ type PluginSchemaResponse struct { func (x *PluginSchemaResponse) Reset() { *x = PluginSchemaResponse{} - mi := &file_plugin_proto_msgTypes[39] + mi := &file_plugin_proto_msgTypes[36] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3056,7 +2876,7 @@ func (x *PluginSchemaResponse) String() string { func (*PluginSchemaResponse) ProtoMessage() {} func (x *PluginSchemaResponse) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[39] + mi := &file_plugin_proto_msgTypes[36] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3069,7 +2889,7 @@ func (x *PluginSchemaResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use PluginSchemaResponse.ProtoReflect.Descriptor instead. func (*PluginSchemaResponse) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{39} + return file_plugin_proto_rawDescGZIP(), []int{36} } func (x *PluginSchemaResponse) GetRoutes() []*RouteSchemaProto { @@ -3111,14 +2931,13 @@ func (x *PluginSchemaResponse) GetMetadata() map[string]string { type MiddlewareRequest struct { state protoimpl.MessageState `protogen:"open.v1"` // === 核心元数据(默认总是填充)=== - RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` // core 为本次请求分配的唯一 ID(便于跨 Begin/End 关联) - UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` - GroupId int64 `protobuf:"varint,3,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` - AccountId int64 `protobuf:"varint,4,opt,name=account_id,json=accountId,proto3" json:"account_id,omitempty"` // 已由 scheduler 选出 - Platform string `protobuf:"bytes,5,opt,name=platform,proto3" json:"platform,omitempty"` - Model string `protobuf:"bytes,6,opt,name=model,proto3" json:"model,omitempty"` - Stream bool `protobuf:"varint,7,opt,name=stream,proto3" json:"stream,omitempty"` - Estimates []*UsageMetric `protobuf:"bytes,8,rep,name=estimates,proto3" json:"estimates,omitempty"` // Core 或插件提供的通用预估值,仅用于早期决策 + RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` // core 为本次请求分配的唯一 ID(便于跨 Begin/End 关联) + UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + GroupId int64 `protobuf:"varint,3,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` + AccountId int64 `protobuf:"varint,4,opt,name=account_id,json=accountId,proto3" json:"account_id,omitempty"` // 已由 scheduler 选出 + Platform string `protobuf:"bytes,5,opt,name=platform,proto3" json:"platform,omitempty"` + Model string `protobuf:"bytes,6,opt,name=model,proto3" json:"model,omitempty"` + Stream bool `protobuf:"varint,7,opt,name=stream,proto3" json:"stream,omitempty"` // metadata KV bag:供多个 middleware 之间传递上下文。 // 命名空间规则由 Core 管理,插件不应依赖未声明的敏感字段。 Metadata map[string]string `protobuf:"bytes,9,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` @@ -3131,7 +2950,7 @@ type MiddlewareRequest struct { func (x *MiddlewareRequest) Reset() { *x = MiddlewareRequest{} - mi := &file_plugin_proto_msgTypes[40] + mi := &file_plugin_proto_msgTypes[37] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3143,7 +2962,7 @@ func (x *MiddlewareRequest) String() string { func (*MiddlewareRequest) ProtoMessage() {} func (x *MiddlewareRequest) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[40] + mi := &file_plugin_proto_msgTypes[37] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3156,7 +2975,7 @@ func (x *MiddlewareRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use MiddlewareRequest.ProtoReflect.Descriptor instead. func (*MiddlewareRequest) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{40} + return file_plugin_proto_rawDescGZIP(), []int{37} } func (x *MiddlewareRequest) GetRequestId() string { @@ -3208,13 +3027,6 @@ func (x *MiddlewareRequest) GetStream() bool { return false } -func (x *MiddlewareRequest) GetEstimates() []*UsageMetric { - if x != nil { - return x.Estimates - } - return nil -} - func (x *MiddlewareRequest) GetMetadata() map[string]string { if x != nil { return x.Metadata @@ -3240,14 +3052,13 @@ func (x *MiddlewareRequest) GetRequestHeaders() map[string]*HeaderValues { type MiddlewareEvent struct { state protoimpl.MessageState `protogen:"open.v1"` // === 核心元数据(与 MiddlewareRequest 对齐)=== - RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` - UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` - GroupId int64 `protobuf:"varint,3,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` - AccountId int64 `protobuf:"varint,4,opt,name=account_id,json=accountId,proto3" json:"account_id,omitempty"` - Platform string `protobuf:"bytes,5,opt,name=platform,proto3" json:"platform,omitempty"` - Model string `protobuf:"bytes,6,opt,name=model,proto3" json:"model,omitempty"` - Stream bool `protobuf:"varint,7,opt,name=stream,proto3" json:"stream,omitempty"` - Estimates []*UsageMetric `protobuf:"bytes,8,rep,name=estimates,proto3" json:"estimates,omitempty"` // 与 MiddlewareRequest 字段对齐,便于 estimate vs actual 比对。 + RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + GroupId int64 `protobuf:"varint,3,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` + AccountId int64 `protobuf:"varint,4,opt,name=account_id,json=accountId,proto3" json:"account_id,omitempty"` + Platform string `protobuf:"bytes,5,opt,name=platform,proto3" json:"platform,omitempty"` + Model string `protobuf:"bytes,6,opt,name=model,proto3" json:"model,omitempty"` + Stream bool `protobuf:"varint,7,opt,name=stream,proto3" json:"stream,omitempty"` // === 响应结果 === StatusCode int64 `protobuf:"varint,20,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` DurationMs int64 `protobuf:"varint,21,opt,name=duration_ms,json=durationMs,proto3" json:"duration_ms,omitempty"` @@ -3266,7 +3077,7 @@ type MiddlewareEvent struct { func (x *MiddlewareEvent) Reset() { *x = MiddlewareEvent{} - mi := &file_plugin_proto_msgTypes[41] + mi := &file_plugin_proto_msgTypes[38] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3278,7 +3089,7 @@ func (x *MiddlewareEvent) String() string { func (*MiddlewareEvent) ProtoMessage() {} func (x *MiddlewareEvent) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[41] + mi := &file_plugin_proto_msgTypes[38] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3291,7 +3102,7 @@ func (x *MiddlewareEvent) ProtoReflect() protoreflect.Message { // Deprecated: Use MiddlewareEvent.ProtoReflect.Descriptor instead. func (*MiddlewareEvent) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{41} + return file_plugin_proto_rawDescGZIP(), []int{38} } func (x *MiddlewareEvent) GetRequestId() string { @@ -3343,13 +3154,6 @@ func (x *MiddlewareEvent) GetStream() bool { return false } -func (x *MiddlewareEvent) GetEstimates() []*UsageMetric { - if x != nil { - return x.Estimates - } - return nil -} - func (x *MiddlewareEvent) GetStatusCode() int64 { if x != nil { return x.StatusCode @@ -3423,7 +3227,7 @@ type MiddlewareDecision struct { func (x *MiddlewareDecision) Reset() { *x = MiddlewareDecision{} - mi := &file_plugin_proto_msgTypes[42] + mi := &file_plugin_proto_msgTypes[39] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3435,7 +3239,7 @@ func (x *MiddlewareDecision) String() string { func (*MiddlewareDecision) ProtoMessage() {} func (x *MiddlewareDecision) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[42] + mi := &file_plugin_proto_msgTypes[39] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3448,7 +3252,7 @@ func (x *MiddlewareDecision) ProtoReflect() protoreflect.Message { // Deprecated: Use MiddlewareDecision.ProtoReflect.Descriptor instead. func (*MiddlewareDecision) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{42} + return file_plugin_proto_rawDescGZIP(), []int{39} } func (x *MiddlewareDecision) GetAction() MiddlewareDecision_Action { @@ -3498,7 +3302,7 @@ type EventSubscriptionProto struct { func (x *EventSubscriptionProto) Reset() { *x = EventSubscriptionProto{} - mi := &file_plugin_proto_msgTypes[43] + mi := &file_plugin_proto_msgTypes[40] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3510,7 +3314,7 @@ func (x *EventSubscriptionProto) String() string { func (*EventSubscriptionProto) ProtoMessage() {} func (x *EventSubscriptionProto) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[43] + mi := &file_plugin_proto_msgTypes[40] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3523,7 +3327,7 @@ func (x *EventSubscriptionProto) ProtoReflect() protoreflect.Message { // Deprecated: Use EventSubscriptionProto.ProtoReflect.Descriptor instead. func (*EventSubscriptionProto) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{43} + return file_plugin_proto_rawDescGZIP(), []int{40} } func (x *EventSubscriptionProto) GetType() string { @@ -3563,7 +3367,7 @@ type EventSubscriptionsResponse struct { func (x *EventSubscriptionsResponse) Reset() { *x = EventSubscriptionsResponse{} - mi := &file_plugin_proto_msgTypes[44] + mi := &file_plugin_proto_msgTypes[41] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3575,7 +3379,7 @@ func (x *EventSubscriptionsResponse) String() string { func (*EventSubscriptionsResponse) ProtoMessage() {} func (x *EventSubscriptionsResponse) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[44] + mi := &file_plugin_proto_msgTypes[41] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3588,7 +3392,7 @@ func (x *EventSubscriptionsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use EventSubscriptionsResponse.ProtoReflect.Descriptor instead. func (*EventSubscriptionsResponse) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{44} + return file_plugin_proto_rawDescGZIP(), []int{41} } func (x *EventSubscriptionsResponse) GetSubscriptions() []*EventSubscriptionProto { @@ -3615,7 +3419,7 @@ type PluginEvent struct { func (x *PluginEvent) Reset() { *x = PluginEvent{} - mi := &file_plugin_proto_msgTypes[45] + mi := &file_plugin_proto_msgTypes[42] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3627,7 +3431,7 @@ func (x *PluginEvent) String() string { func (*PluginEvent) ProtoMessage() {} func (x *PluginEvent) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[45] + mi := &file_plugin_proto_msgTypes[42] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3640,7 +3444,7 @@ func (x *PluginEvent) ProtoReflect() protoreflect.Message { // Deprecated: Use PluginEvent.ProtoReflect.Descriptor instead. func (*PluginEvent) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{45} + return file_plugin_proto_rawDescGZIP(), []int{42} } func (x *PluginEvent) GetId() string { @@ -3716,7 +3520,7 @@ type EventHandleResponse struct { func (x *EventHandleResponse) Reset() { *x = EventHandleResponse{} - mi := &file_plugin_proto_msgTypes[46] + mi := &file_plugin_proto_msgTypes[43] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3728,7 +3532,7 @@ func (x *EventHandleResponse) String() string { func (*EventHandleResponse) ProtoMessage() {} func (x *EventHandleResponse) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[46] + mi := &file_plugin_proto_msgTypes[43] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3741,7 +3545,7 @@ func (x *EventHandleResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use EventHandleResponse.ProtoReflect.Descriptor instead. func (*EventHandleResponse) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{46} + return file_plugin_proto_rawDescGZIP(), []int{43} } func (x *EventHandleResponse) GetSuccess() bool { @@ -3770,7 +3574,7 @@ type HostInvokeRequest struct { func (x *HostInvokeRequest) Reset() { *x = HostInvokeRequest{} - mi := &file_plugin_proto_msgTypes[47] + mi := &file_plugin_proto_msgTypes[44] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3782,7 +3586,7 @@ func (x *HostInvokeRequest) String() string { func (*HostInvokeRequest) ProtoMessage() {} func (x *HostInvokeRequest) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[47] + mi := &file_plugin_proto_msgTypes[44] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3795,7 +3599,7 @@ func (x *HostInvokeRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use HostInvokeRequest.ProtoReflect.Descriptor instead. func (*HostInvokeRequest) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{47} + return file_plugin_proto_rawDescGZIP(), []int{44} } func (x *HostInvokeRequest) GetMethod() string { @@ -3837,7 +3641,7 @@ type HostInvokeResponse struct { func (x *HostInvokeResponse) Reset() { *x = HostInvokeResponse{} - mi := &file_plugin_proto_msgTypes[48] + mi := &file_plugin_proto_msgTypes[45] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3849,7 +3653,7 @@ func (x *HostInvokeResponse) String() string { func (*HostInvokeResponse) ProtoMessage() {} func (x *HostInvokeResponse) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[48] + mi := &file_plugin_proto_msgTypes[45] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3862,7 +3666,7 @@ func (x *HostInvokeResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use HostInvokeResponse.ProtoReflect.Descriptor instead. func (*HostInvokeResponse) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{48} + return file_plugin_proto_rawDescGZIP(), []int{45} } func (x *HostInvokeResponse) GetStatus() string { @@ -3901,7 +3705,7 @@ type HostStreamFrame struct { func (x *HostStreamFrame) Reset() { *x = HostStreamFrame{} - mi := &file_plugin_proto_msgTypes[49] + mi := &file_plugin_proto_msgTypes[46] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3913,7 +3717,7 @@ func (x *HostStreamFrame) String() string { func (*HostStreamFrame) ProtoMessage() {} func (x *HostStreamFrame) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[49] + mi := &file_plugin_proto_msgTypes[46] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3926,7 +3730,7 @@ func (x *HostStreamFrame) ProtoReflect() protoreflect.Message { // Deprecated: Use HostStreamFrame.ProtoReflect.Descriptor instead. func (*HostStreamFrame) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{49} + return file_plugin_proto_rawDescGZIP(), []int{46} } func (x *HostStreamFrame) GetMethod() string { @@ -3990,7 +3794,7 @@ type ProcessTaskRequest struct { func (x *ProcessTaskRequest) Reset() { *x = ProcessTaskRequest{} - mi := &file_plugin_proto_msgTypes[50] + mi := &file_plugin_proto_msgTypes[47] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -4002,7 +3806,7 @@ func (x *ProcessTaskRequest) String() string { func (*ProcessTaskRequest) ProtoMessage() {} func (x *ProcessTaskRequest) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[50] + mi := &file_plugin_proto_msgTypes[47] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4015,7 +3819,7 @@ func (x *ProcessTaskRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ProcessTaskRequest.ProtoReflect.Descriptor instead. func (*ProcessTaskRequest) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{50} + return file_plugin_proto_rawDescGZIP(), []int{47} } func (x *ProcessTaskRequest) GetTaskId() int64 { @@ -4056,7 +3860,7 @@ type ProcessTaskResponse struct { func (x *ProcessTaskResponse) Reset() { *x = ProcessTaskResponse{} - mi := &file_plugin_proto_msgTypes[51] + mi := &file_plugin_proto_msgTypes[48] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -4068,7 +3872,7 @@ func (x *ProcessTaskResponse) String() string { func (*ProcessTaskResponse) ProtoMessage() {} func (x *ProcessTaskResponse) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[51] + mi := &file_plugin_proto_msgTypes[48] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4081,7 +3885,7 @@ func (x *ProcessTaskResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ProcessTaskResponse.ProtoReflect.Descriptor instead. func (*ProcessTaskResponse) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{51} + return file_plugin_proto_rawDescGZIP(), []int{48} } func (x *ProcessTaskResponse) GetSuccess() bool { @@ -4107,7 +3911,7 @@ type TaskTypesResponse struct { func (x *TaskTypesResponse) Reset() { *x = TaskTypesResponse{} - mi := &file_plugin_proto_msgTypes[52] + mi := &file_plugin_proto_msgTypes[49] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -4119,7 +3923,7 @@ func (x *TaskTypesResponse) String() string { func (*TaskTypesResponse) ProtoMessage() {} func (x *TaskTypesResponse) ProtoReflect() protoreflect.Message { - mi := &file_plugin_proto_msgTypes[52] + mi := &file_plugin_proto_msgTypes[49] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4132,7 +3936,7 @@ func (x *TaskTypesResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use TaskTypesResponse.ProtoReflect.Descriptor instead. func (*TaskTypesResponse) Descriptor() ([]byte, []int) { - return file_plugin_proto_rawDescGZIP(), []int{52} + return file_plugin_proto_rawDescGZIP(), []int{49} } func (x *TaskTypesResponse) GetTypes() []string { @@ -4258,39 +4062,7 @@ const file_plugin_proto_rawDesc = "" + "\x04body\x18\x03 \x01(\fR\x04body\x1a[\n" + "\fHeadersEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x125\n" + - "\x05value\x18\x02 \x01(\v2\x1f.airgate.plugin.v1.HeaderValuesR\x05value:\x028\x01\"\xec\x01\n" + - "\x0eUsageAttribute\x12\x10\n" + - "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05label\x18\x02 \x01(\tR\x05label\x12\x12\n" + - "\x04kind\x18\x03 \x01(\tR\x04kind\x12\x14\n" + - "\x05value\x18\x04 \x01(\tR\x05value\x12K\n" + - "\bmetadata\x18\x05 \x03(\v2/.airgate.plugin.v1.UsageAttribute.MetadataEntryR\bmetadata\x1a;\n" + - "\rMetadataEntry\x12\x10\n" + - "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xb9\x02\n" + - "\vUsageMetric\x12\x10\n" + - "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05label\x18\x02 \x01(\tR\x05label\x12\x12\n" + - "\x04kind\x18\x03 \x01(\tR\x04kind\x12\x12\n" + - "\x04unit\x18\x04 \x01(\tR\x04unit\x12\x14\n" + - "\x05value\x18\x05 \x01(\x01R\x05value\x12!\n" + - "\faccount_cost\x18\x06 \x01(\x01R\vaccountCost\x12\x1a\n" + - "\bcurrency\x18\a \x01(\tR\bcurrency\x12H\n" + - "\bmetadata\x18\b \x03(\v2,.airgate.plugin.v1.UsageMetric.MetadataEntryR\bmetadata\x1a;\n" + - "\rMetadataEntry\x12\x10\n" + - "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xcf\x02\n" + - "\x0fUsageCostDetail\x12\x10\n" + - "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05label\x18\x02 \x01(\tR\x05label\x12!\n" + - "\faccount_cost\x18\x03 \x01(\x01R\vaccountCost\x12\x1b\n" + - "\tuser_cost\x18\x04 \x01(\x01R\buserCost\x12-\n" + - "\x12billing_multiplier\x18\x05 \x01(\x01R\x11billingMultiplier\x12\x1a\n" + - "\bcurrency\x18\x06 \x01(\tR\bcurrency\x12L\n" + - "\bmetadata\x18\a \x03(\v20.airgate.plugin.v1.UsageCostDetail.MetadataEntryR\bmetadata\x1a;\n" + - "\rMetadataEntry\x12\x10\n" + - "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xad\x04\n" + + "\x05value\x18\x02 \x01(\v2\x1f.airgate.plugin.v1.HeaderValuesR\x05value:\x028\x01\"\x86\b\n" + "\x05Usage\x12\x14\n" + "\x05model\x18\x01 \x01(\tR\x05model\x12!\n" + "\faccount_cost\x18\x02 \x01(\x01R\vaccountCost\x12\x1b\n" + @@ -4298,17 +4070,30 @@ const file_plugin_proto_rawDesc = "" + "\x12billing_multiplier\x18\x04 \x01(\x01R\x11billingMultiplier\x12\x1a\n" + "\bcurrency\x18\x05 \x01(\tR\bcurrency\x12\x18\n" + "\asummary\x18\x06 \x01(\tR\asummary\x12$\n" + - "\x0efirst_token_ms\x18\a \x01(\x03R\ffirstTokenMs\x128\n" + - "\ametrics\x18\b \x03(\v2\x1e.airgate.plugin.v1.UsageMetricR\ametrics\x12A\n" + + "\x0efirst_token_ms\x18\a \x01(\x03R\ffirstTokenMs\x12B\n" + + "\bmetadata\x18\v \x03(\v2&.airgate.plugin.v1.Usage.MetadataEntryR\bmetadata\x12!\n" + + "\finput_tokens\x18\f \x01(\x03R\vinputTokens\x12#\n" + + "\routput_tokens\x18\r \x01(\x03R\foutputTokens\x12.\n" + + "\x13cached_input_tokens\x18\x0e \x01(\x03R\x11cachedInputTokens\x122\n" + + "\x15cache_creation_tokens\x18\x0f \x01(\x03R\x13cacheCreationTokens\x126\n" + + "\x17reasoning_output_tokens\x18\x12 \x01(\x03R\x15reasoningOutputTokens\x12\x1f\n" + + "\vinput_price\x18\x16 \x01(\x01R\n" + + "inputPrice\x12!\n" + + "\foutput_price\x18\x17 \x01(\x01R\voutputPrice\x12,\n" + + "\x12cached_input_price\x18\x18 \x01(\x01R\x10cachedInputPrice\x120\n" + + "\x14cache_creation_price\x18\x19 \x01(\x01R\x12cacheCreationPrice\x12\x1d\n" + "\n" + - "attributes\x18\t \x03(\v2!.airgate.plugin.v1.UsageAttributeR\n" + - "attributes\x12E\n" + - "\fcost_details\x18\n" + - " \x03(\v2\".airgate.plugin.v1.UsageCostDetailR\vcostDetails\x12B\n" + - "\bmetadata\x18\v \x03(\v2&.airgate.plugin.v1.Usage.MetadataEntryR\bmetadata\x1a;\n" + + "input_cost\x18\x1b \x01(\x01R\tinputCost\x12\x1f\n" + + "\voutput_cost\x18\x1c \x01(\x01R\n" + + "outputCost\x12*\n" + + "\x11cached_input_cost\x18\x1d \x01(\x01R\x0fcachedInputCost\x12.\n" + + "\x13cache_creation_cost\x18\x1e \x01(\x01R\x11cacheCreationCost\x12)\n" + + "\x10reasoning_effort\x18# \x01(\tR\x0freasoningEffort\x1a;\n" + "\rMetadataEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xc7\x03\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01J\x04\b\b\x10\tJ\x04\b\t\x10\n" + + "J\x04\b\n" + + "\x10\vJ\x04\b\x10\x10\x11J\x04\b\x11\x10\x12J\x04\b\x13\x10\x14J\x04\b\x14\x10\x15J\x04\b\x15\x10\x16J\x04\b\x1a\x10\x1bJ\x04\b\x1f\x10 J\x04\b \x10!J\x04\b!\x10\"J\x04\b\"\x10#\"\xc7\x03\n" + "\x0eForwardOutcome\x122\n" + "\x04kind\x18\x01 \x01(\x0e2\x1e.airgate.plugin.v1.OutcomeKindR\x04kind\x12?\n" + "\bupstream\x18\x02 \x01(\v2#.airgate.plugin.v1.UpstreamResponseR\bupstream\x12.\n" + @@ -4464,7 +4249,7 @@ const file_plugin_proto_rawDesc = "" + "\bmetadata\x18\x05 \x03(\v25.airgate.plugin.v1.PluginSchemaResponse.MetadataEntryR\bmetadata\x1a;\n" + "\rMetadataEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\x84\x05\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xcc\x04\n" + "\x11MiddlewareRequest\x12\x1d\n" + "\n" + "request_id\x18\x01 \x01(\tR\trequestId\x12\x17\n" + @@ -4474,8 +4259,7 @@ const file_plugin_proto_rawDesc = "" + "account_id\x18\x04 \x01(\x03R\taccountId\x12\x1a\n" + "\bplatform\x18\x05 \x01(\tR\bplatform\x12\x14\n" + "\x05model\x18\x06 \x01(\tR\x05model\x12\x16\n" + - "\x06stream\x18\a \x01(\bR\x06stream\x12<\n" + - "\testimates\x18\b \x03(\v2\x1e.airgate.plugin.v1.UsageMetricR\testimates\x12N\n" + + "\x06stream\x18\a \x01(\bR\x06stream\x12N\n" + "\bmetadata\x18\t \x03(\v22.airgate.plugin.v1.MiddlewareRequest.MetadataEntryR\bmetadata\x12!\n" + "\frequest_body\x18d \x01(\fR\vrequestBody\x12a\n" + "\x0frequest_headers\x18e \x03(\v28.airgate.plugin.v1.MiddlewareRequest.RequestHeadersEntryR\x0erequestHeaders\x1a;\n" + @@ -4484,7 +4268,7 @@ const file_plugin_proto_rawDesc = "" + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\x1ab\n" + "\x13RequestHeadersEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x125\n" + - "\x05value\x18\x02 \x01(\v2\x1f.airgate.plugin.v1.HeaderValuesR\x05value:\x028\x01\"\xb2\x06\n" + + "\x05value\x18\x02 \x01(\v2\x1f.airgate.plugin.v1.HeaderValuesR\x05value:\x028\x01J\x04\b\b\x10\t\"\xfa\x05\n" + "\x0fMiddlewareEvent\x12\x1d\n" + "\n" + "request_id\x18\x01 \x01(\tR\trequestId\x12\x17\n" + @@ -4494,8 +4278,7 @@ const file_plugin_proto_rawDesc = "" + "account_id\x18\x04 \x01(\x03R\taccountId\x12\x1a\n" + "\bplatform\x18\x05 \x01(\tR\bplatform\x12\x14\n" + "\x05model\x18\x06 \x01(\tR\x05model\x12\x16\n" + - "\x06stream\x18\a \x01(\bR\x06stream\x12<\n" + - "\testimates\x18\b \x03(\v2\x1e.airgate.plugin.v1.UsageMetricR\testimates\x12\x1f\n" + + "\x06stream\x18\a \x01(\bR\x06stream\x12\x1f\n" + "\vstatus_code\x18\x14 \x01(\x03R\n" + "statusCode\x12\x1f\n" + "\vduration_ms\x18\x15 \x01(\x03R\n" + @@ -4512,7 +4295,7 @@ const file_plugin_proto_rawDesc = "" + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\x1ac\n" + "\x14ResponseHeadersEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x125\n" + - "\x05value\x18\x02 \x01(\v2\x1f.airgate.plugin.v1.HeaderValuesR\x05value:\x028\x01\"\x98\x04\n" + + "\x05value\x18\x02 \x01(\v2\x1f.airgate.plugin.v1.HeaderValuesR\x05value:\x028\x01J\x04\b\b\x10\t\"\x98\x04\n" + "\x12MiddlewareDecision\x12D\n" + "\x06action\x18\x01 \x01(\x0e2,.airgate.plugin.v1.MiddlewareDecision.ActionR\x06action\x12(\n" + "\x10deny_status_code\x18\n" + @@ -4597,7 +4380,7 @@ const file_plugin_proto_rawDesc = "" + "\asuccess\x18\x01 \x01(\bR\asuccess\x12#\n" + "\rerror_message\x18\x02 \x01(\tR\ferrorMessage\")\n" + "\x11TaskTypesResponse\x12\x14\n" + - "\x05types\x18\x01 \x03(\tR\x05types*\xf0\x01\n" + + "\x05types\x18\x01 \x03(\tR\x05types*\x91\x02\n" + "\vOutcomeKind\x12\x13\n" + "\x0fOUTCOME_UNKNOWN\x10\x00\x12\x13\n" + "\x0fOUTCOME_SUCCESS\x10\x01\x12\x18\n" + @@ -4606,7 +4389,8 @@ const file_plugin_proto_rawDesc = "" + "\x14OUTCOME_ACCOUNT_DEAD\x10\x04\x12\x1e\n" + "\x1aOUTCOME_UPSTREAM_TRANSIENT\x10\x05\x12\x1a\n" + "\x16OUTCOME_STREAM_ABORTED\x10\x06\x12%\n" + - "!OUTCOME_ACCOUNT_MODEL_UNSUPPORTED\x10\a2\xcb\x04\n" + + "!OUTCOME_ACCOUNT_MODEL_UNSUPPORTED\x10\a\x12\x1f\n" + + "\x1bOUTCOME_ACCOUNT_UNAVAILABLE\x10\b2\xcb\x04\n" + "\rPluginService\x12J\n" + "\aGetInfo\x12\x18.airgate.plugin.v1.Empty\x1a%.airgate.plugin.v1.PluginInfoResponse\x12@\n" + "\x04Init\x12\x1e.airgate.plugin.v1.InitRequest\x1a\x18.airgate.plugin.v1.Empty\x12;\n" + @@ -4640,7 +4424,7 @@ const file_plugin_proto_rawDesc = "" + "\vHandleEvent\x12\x1e.airgate.plugin.v1.PluginEvent\x1a&.airgate.plugin.v1.EventHandleResponse2\xc6\x01\n" + "\x11CoreInvokeService\x12U\n" + "\x06Invoke\x12$.airgate.plugin.v1.HostInvokeRequest\x1a%.airgate.plugin.v1.HostInvokeResponse\x12Z\n" + - "\fInvokeStream\x12\".airgate.plugin.v1.HostStreamFrame\x1a\".airgate.plugin.v1.HostStreamFrame(\x010\x01B4Z2github.com/DouDOU-start/airgate-sdk/protocol/protob\x06proto3" + "\fInvokeStream\x12\".airgate.plugin.v1.HostStreamFrame\x1a\".airgate.plugin.v1.HostStreamFrame(\x010\x01B4Z2github.com/DevilGenius/airgate-sdk/protocol/protob\x06proto3" var ( file_plugin_proto_rawDescOnce sync.Once @@ -4655,7 +4439,7 @@ func file_plugin_proto_rawDescGZIP() []byte { } var file_plugin_proto_enumTypes = make([]protoimpl.EnumInfo, 3) -var file_plugin_proto_msgTypes = make([]protoimpl.MessageInfo, 88) +var file_plugin_proto_msgTypes = make([]protoimpl.MessageInfo, 82) var file_plugin_proto_goTypes = []any{ (OutcomeKind)(0), // 0: airgate.plugin.v1.OutcomeKind (WebSocketFrame_FrameType)(0), // 1: airgate.plugin.v1.WebSocketFrame.FrameType @@ -4677,224 +4461,210 @@ var file_plugin_proto_goTypes = []any{ (*AccountProto)(nil), // 17: airgate.plugin.v1.AccountProto (*ForwardRequest)(nil), // 18: airgate.plugin.v1.ForwardRequest (*UpstreamResponse)(nil), // 19: airgate.plugin.v1.UpstreamResponse - (*UsageAttribute)(nil), // 20: airgate.plugin.v1.UsageAttribute - (*UsageMetric)(nil), // 21: airgate.plugin.v1.UsageMetric - (*UsageCostDetail)(nil), // 22: airgate.plugin.v1.UsageCostDetail - (*Usage)(nil), // 23: airgate.plugin.v1.Usage - (*ForwardOutcome)(nil), // 24: airgate.plugin.v1.ForwardOutcome - (*ForwardChunk)(nil), // 25: airgate.plugin.v1.ForwardChunk - (*CredentialsRequest)(nil), // 26: airgate.plugin.v1.CredentialsRequest - (*HttpRequest)(nil), // 27: airgate.plugin.v1.HttpRequest - (*HttpResponse)(nil), // 28: airgate.plugin.v1.HttpResponse - (*HttpResponseChunk)(nil), // 29: airgate.plugin.v1.HttpResponseChunk - (*BackgroundTaskProto)(nil), // 30: airgate.plugin.v1.BackgroundTaskProto - (*BackgroundTasksResponse)(nil), // 31: airgate.plugin.v1.BackgroundTasksResponse - (*RunBackgroundTaskRequest)(nil), // 32: airgate.plugin.v1.RunBackgroundTaskRequest - (*WebSocketFrame)(nil), // 33: airgate.plugin.v1.WebSocketFrame - (*WebSocketConnectInfo)(nil), // 34: airgate.plugin.v1.WebSocketConnectInfo - (*WebAssetFile)(nil), // 35: airgate.plugin.v1.WebAssetFile - (*WebAssetsResponse)(nil), // 36: airgate.plugin.v1.WebAssetsResponse - (*PayloadSchemaProto)(nil), // 37: airgate.plugin.v1.PayloadSchemaProto - (*RouteSchemaProto)(nil), // 38: airgate.plugin.v1.RouteSchemaProto - (*TaskSchemaProto)(nil), // 39: airgate.plugin.v1.TaskSchemaProto - (*EventSchemaProto)(nil), // 40: airgate.plugin.v1.EventSchemaProto - (*InvokeSchemaProto)(nil), // 41: airgate.plugin.v1.InvokeSchemaProto - (*PluginSchemaResponse)(nil), // 42: airgate.plugin.v1.PluginSchemaResponse - (*MiddlewareRequest)(nil), // 43: airgate.plugin.v1.MiddlewareRequest - (*MiddlewareEvent)(nil), // 44: airgate.plugin.v1.MiddlewareEvent - (*MiddlewareDecision)(nil), // 45: airgate.plugin.v1.MiddlewareDecision - (*EventSubscriptionProto)(nil), // 46: airgate.plugin.v1.EventSubscriptionProto - (*EventSubscriptionsResponse)(nil), // 47: airgate.plugin.v1.EventSubscriptionsResponse - (*PluginEvent)(nil), // 48: airgate.plugin.v1.PluginEvent - (*EventHandleResponse)(nil), // 49: airgate.plugin.v1.EventHandleResponse - (*HostInvokeRequest)(nil), // 50: airgate.plugin.v1.HostInvokeRequest - (*HostInvokeResponse)(nil), // 51: airgate.plugin.v1.HostInvokeResponse - (*HostStreamFrame)(nil), // 52: airgate.plugin.v1.HostStreamFrame - (*ProcessTaskRequest)(nil), // 53: airgate.plugin.v1.ProcessTaskRequest - (*ProcessTaskResponse)(nil), // 54: airgate.plugin.v1.ProcessTaskResponse - (*TaskTypesResponse)(nil), // 55: airgate.plugin.v1.TaskTypesResponse - nil, // 56: airgate.plugin.v1.PluginInfoResponse.MetadataEntry - nil, // 57: airgate.plugin.v1.InitRequest.ConfigEntry - nil, // 58: airgate.plugin.v1.ModelInfoProto.MetadataEntry - nil, // 59: airgate.plugin.v1.RouteDefinitionProto.MetadataEntry - nil, // 60: airgate.plugin.v1.ForwardRequest.HeadersEntry - nil, // 61: airgate.plugin.v1.UpstreamResponse.HeadersEntry - nil, // 62: airgate.plugin.v1.UsageAttribute.MetadataEntry - nil, // 63: airgate.plugin.v1.UsageMetric.MetadataEntry - nil, // 64: airgate.plugin.v1.UsageCostDetail.MetadataEntry - nil, // 65: airgate.plugin.v1.Usage.MetadataEntry - nil, // 66: airgate.plugin.v1.ForwardOutcome.UpdatedCredentialsEntry - nil, // 67: airgate.plugin.v1.ForwardChunk.HeadersEntry - nil, // 68: airgate.plugin.v1.CredentialsRequest.CredentialsEntry - nil, // 69: airgate.plugin.v1.HttpRequest.HeadersEntry - nil, // 70: airgate.plugin.v1.HttpResponse.HeadersEntry - nil, // 71: airgate.plugin.v1.HttpResponseChunk.HeadersEntry - nil, // 72: airgate.plugin.v1.WebSocketConnectInfo.HeadersEntry - nil, // 73: airgate.plugin.v1.PayloadSchemaProto.MetadataEntry - nil, // 74: airgate.plugin.v1.RouteSchemaProto.MetadataEntry - nil, // 75: airgate.plugin.v1.TaskSchemaProto.MetadataEntry - nil, // 76: airgate.plugin.v1.EventSchemaProto.MetadataEntry - nil, // 77: airgate.plugin.v1.InvokeSchemaProto.MetadataEntry - nil, // 78: airgate.plugin.v1.PluginSchemaResponse.MetadataEntry - nil, // 79: airgate.plugin.v1.MiddlewareRequest.MetadataEntry - nil, // 80: airgate.plugin.v1.MiddlewareRequest.RequestHeadersEntry - nil, // 81: airgate.plugin.v1.MiddlewareEvent.MetadataEntry - nil, // 82: airgate.plugin.v1.MiddlewareEvent.ResponseHeadersEntry - nil, // 83: airgate.plugin.v1.MiddlewareDecision.SetHeadersEntry - nil, // 84: airgate.plugin.v1.MiddlewareDecision.MetadataEntry - nil, // 85: airgate.plugin.v1.EventSubscriptionProto.FilterEntry - nil, // 86: airgate.plugin.v1.EventSubscriptionProto.MetadataEntry - nil, // 87: airgate.plugin.v1.PluginEvent.MetadataEntry - nil, // 88: airgate.plugin.v1.HostInvokeRequest.MetadataEntry - nil, // 89: airgate.plugin.v1.HostInvokeResponse.MetadataEntry - nil, // 90: airgate.plugin.v1.HostStreamFrame.MetadataEntry + (*Usage)(nil), // 20: airgate.plugin.v1.Usage + (*ForwardOutcome)(nil), // 21: airgate.plugin.v1.ForwardOutcome + (*ForwardChunk)(nil), // 22: airgate.plugin.v1.ForwardChunk + (*CredentialsRequest)(nil), // 23: airgate.plugin.v1.CredentialsRequest + (*HttpRequest)(nil), // 24: airgate.plugin.v1.HttpRequest + (*HttpResponse)(nil), // 25: airgate.plugin.v1.HttpResponse + (*HttpResponseChunk)(nil), // 26: airgate.plugin.v1.HttpResponseChunk + (*BackgroundTaskProto)(nil), // 27: airgate.plugin.v1.BackgroundTaskProto + (*BackgroundTasksResponse)(nil), // 28: airgate.plugin.v1.BackgroundTasksResponse + (*RunBackgroundTaskRequest)(nil), // 29: airgate.plugin.v1.RunBackgroundTaskRequest + (*WebSocketFrame)(nil), // 30: airgate.plugin.v1.WebSocketFrame + (*WebSocketConnectInfo)(nil), // 31: airgate.plugin.v1.WebSocketConnectInfo + (*WebAssetFile)(nil), // 32: airgate.plugin.v1.WebAssetFile + (*WebAssetsResponse)(nil), // 33: airgate.plugin.v1.WebAssetsResponse + (*PayloadSchemaProto)(nil), // 34: airgate.plugin.v1.PayloadSchemaProto + (*RouteSchemaProto)(nil), // 35: airgate.plugin.v1.RouteSchemaProto + (*TaskSchemaProto)(nil), // 36: airgate.plugin.v1.TaskSchemaProto + (*EventSchemaProto)(nil), // 37: airgate.plugin.v1.EventSchemaProto + (*InvokeSchemaProto)(nil), // 38: airgate.plugin.v1.InvokeSchemaProto + (*PluginSchemaResponse)(nil), // 39: airgate.plugin.v1.PluginSchemaResponse + (*MiddlewareRequest)(nil), // 40: airgate.plugin.v1.MiddlewareRequest + (*MiddlewareEvent)(nil), // 41: airgate.plugin.v1.MiddlewareEvent + (*MiddlewareDecision)(nil), // 42: airgate.plugin.v1.MiddlewareDecision + (*EventSubscriptionProto)(nil), // 43: airgate.plugin.v1.EventSubscriptionProto + (*EventSubscriptionsResponse)(nil), // 44: airgate.plugin.v1.EventSubscriptionsResponse + (*PluginEvent)(nil), // 45: airgate.plugin.v1.PluginEvent + (*EventHandleResponse)(nil), // 46: airgate.plugin.v1.EventHandleResponse + (*HostInvokeRequest)(nil), // 47: airgate.plugin.v1.HostInvokeRequest + (*HostInvokeResponse)(nil), // 48: airgate.plugin.v1.HostInvokeResponse + (*HostStreamFrame)(nil), // 49: airgate.plugin.v1.HostStreamFrame + (*ProcessTaskRequest)(nil), // 50: airgate.plugin.v1.ProcessTaskRequest + (*ProcessTaskResponse)(nil), // 51: airgate.plugin.v1.ProcessTaskResponse + (*TaskTypesResponse)(nil), // 52: airgate.plugin.v1.TaskTypesResponse + nil, // 53: airgate.plugin.v1.PluginInfoResponse.MetadataEntry + nil, // 54: airgate.plugin.v1.InitRequest.ConfigEntry + nil, // 55: airgate.plugin.v1.ModelInfoProto.MetadataEntry + nil, // 56: airgate.plugin.v1.RouteDefinitionProto.MetadataEntry + nil, // 57: airgate.plugin.v1.ForwardRequest.HeadersEntry + nil, // 58: airgate.plugin.v1.UpstreamResponse.HeadersEntry + nil, // 59: airgate.plugin.v1.Usage.MetadataEntry + nil, // 60: airgate.plugin.v1.ForwardOutcome.UpdatedCredentialsEntry + nil, // 61: airgate.plugin.v1.ForwardChunk.HeadersEntry + nil, // 62: airgate.plugin.v1.CredentialsRequest.CredentialsEntry + nil, // 63: airgate.plugin.v1.HttpRequest.HeadersEntry + nil, // 64: airgate.plugin.v1.HttpResponse.HeadersEntry + nil, // 65: airgate.plugin.v1.HttpResponseChunk.HeadersEntry + nil, // 66: airgate.plugin.v1.WebSocketConnectInfo.HeadersEntry + nil, // 67: airgate.plugin.v1.PayloadSchemaProto.MetadataEntry + nil, // 68: airgate.plugin.v1.RouteSchemaProto.MetadataEntry + nil, // 69: airgate.plugin.v1.TaskSchemaProto.MetadataEntry + nil, // 70: airgate.plugin.v1.EventSchemaProto.MetadataEntry + nil, // 71: airgate.plugin.v1.InvokeSchemaProto.MetadataEntry + nil, // 72: airgate.plugin.v1.PluginSchemaResponse.MetadataEntry + nil, // 73: airgate.plugin.v1.MiddlewareRequest.MetadataEntry + nil, // 74: airgate.plugin.v1.MiddlewareRequest.RequestHeadersEntry + nil, // 75: airgate.plugin.v1.MiddlewareEvent.MetadataEntry + nil, // 76: airgate.plugin.v1.MiddlewareEvent.ResponseHeadersEntry + nil, // 77: airgate.plugin.v1.MiddlewareDecision.SetHeadersEntry + nil, // 78: airgate.plugin.v1.MiddlewareDecision.MetadataEntry + nil, // 79: airgate.plugin.v1.EventSubscriptionProto.FilterEntry + nil, // 80: airgate.plugin.v1.EventSubscriptionProto.MetadataEntry + nil, // 81: airgate.plugin.v1.PluginEvent.MetadataEntry + nil, // 82: airgate.plugin.v1.HostInvokeRequest.MetadataEntry + nil, // 83: airgate.plugin.v1.HostInvokeResponse.MetadataEntry + nil, // 84: airgate.plugin.v1.HostStreamFrame.MetadataEntry } var file_plugin_proto_depIdxs = []int32{ 8, // 0: airgate.plugin.v1.PluginInfoResponse.account_types:type_name -> airgate.plugin.v1.AccountTypeProto 10, // 1: airgate.plugin.v1.PluginInfoResponse.frontend_pages:type_name -> airgate.plugin.v1.FrontendPageProto 11, // 2: airgate.plugin.v1.PluginInfoResponse.frontend_widgets:type_name -> airgate.plugin.v1.FrontendWidgetProto 7, // 3: airgate.plugin.v1.PluginInfoResponse.config_schema:type_name -> airgate.plugin.v1.ConfigFieldProto - 56, // 4: airgate.plugin.v1.PluginInfoResponse.metadata:type_name -> airgate.plugin.v1.PluginInfoResponse.MetadataEntry + 53, // 4: airgate.plugin.v1.PluginInfoResponse.metadata:type_name -> airgate.plugin.v1.PluginInfoResponse.MetadataEntry 9, // 5: airgate.plugin.v1.AccountTypeProto.fields:type_name -> airgate.plugin.v1.CredentialFieldProto - 57, // 6: airgate.plugin.v1.InitRequest.config:type_name -> airgate.plugin.v1.InitRequest.ConfigEntry - 58, // 7: airgate.plugin.v1.ModelInfoProto.metadata:type_name -> airgate.plugin.v1.ModelInfoProto.MetadataEntry + 54, // 6: airgate.plugin.v1.InitRequest.config:type_name -> airgate.plugin.v1.InitRequest.ConfigEntry + 55, // 7: airgate.plugin.v1.ModelInfoProto.metadata:type_name -> airgate.plugin.v1.ModelInfoProto.MetadataEntry 13, // 8: airgate.plugin.v1.ModelsResponse.models:type_name -> airgate.plugin.v1.ModelInfoProto - 59, // 9: airgate.plugin.v1.RouteDefinitionProto.metadata:type_name -> airgate.plugin.v1.RouteDefinitionProto.MetadataEntry + 56, // 9: airgate.plugin.v1.RouteDefinitionProto.metadata:type_name -> airgate.plugin.v1.RouteDefinitionProto.MetadataEntry 15, // 10: airgate.plugin.v1.RoutesResponse.routes:type_name -> airgate.plugin.v1.RouteDefinitionProto - 60, // 11: airgate.plugin.v1.ForwardRequest.headers:type_name -> airgate.plugin.v1.ForwardRequest.HeadersEntry + 57, // 11: airgate.plugin.v1.ForwardRequest.headers:type_name -> airgate.plugin.v1.ForwardRequest.HeadersEntry 17, // 12: airgate.plugin.v1.ForwardRequest.account:type_name -> airgate.plugin.v1.AccountProto - 61, // 13: airgate.plugin.v1.UpstreamResponse.headers:type_name -> airgate.plugin.v1.UpstreamResponse.HeadersEntry - 62, // 14: airgate.plugin.v1.UsageAttribute.metadata:type_name -> airgate.plugin.v1.UsageAttribute.MetadataEntry - 63, // 15: airgate.plugin.v1.UsageMetric.metadata:type_name -> airgate.plugin.v1.UsageMetric.MetadataEntry - 64, // 16: airgate.plugin.v1.UsageCostDetail.metadata:type_name -> airgate.plugin.v1.UsageCostDetail.MetadataEntry - 21, // 17: airgate.plugin.v1.Usage.metrics:type_name -> airgate.plugin.v1.UsageMetric - 20, // 18: airgate.plugin.v1.Usage.attributes:type_name -> airgate.plugin.v1.UsageAttribute - 22, // 19: airgate.plugin.v1.Usage.cost_details:type_name -> airgate.plugin.v1.UsageCostDetail - 65, // 20: airgate.plugin.v1.Usage.metadata:type_name -> airgate.plugin.v1.Usage.MetadataEntry - 0, // 21: airgate.plugin.v1.ForwardOutcome.kind:type_name -> airgate.plugin.v1.OutcomeKind - 19, // 22: airgate.plugin.v1.ForwardOutcome.upstream:type_name -> airgate.plugin.v1.UpstreamResponse - 23, // 23: airgate.plugin.v1.ForwardOutcome.usage:type_name -> airgate.plugin.v1.Usage - 66, // 24: airgate.plugin.v1.ForwardOutcome.updated_credentials:type_name -> airgate.plugin.v1.ForwardOutcome.UpdatedCredentialsEntry - 24, // 25: airgate.plugin.v1.ForwardChunk.final_outcome:type_name -> airgate.plugin.v1.ForwardOutcome - 67, // 26: airgate.plugin.v1.ForwardChunk.headers:type_name -> airgate.plugin.v1.ForwardChunk.HeadersEntry - 68, // 27: airgate.plugin.v1.CredentialsRequest.credentials:type_name -> airgate.plugin.v1.CredentialsRequest.CredentialsEntry - 69, // 28: airgate.plugin.v1.HttpRequest.headers:type_name -> airgate.plugin.v1.HttpRequest.HeadersEntry - 70, // 29: airgate.plugin.v1.HttpResponse.headers:type_name -> airgate.plugin.v1.HttpResponse.HeadersEntry - 71, // 30: airgate.plugin.v1.HttpResponseChunk.headers:type_name -> airgate.plugin.v1.HttpResponseChunk.HeadersEntry - 30, // 31: airgate.plugin.v1.BackgroundTasksResponse.tasks:type_name -> airgate.plugin.v1.BackgroundTaskProto - 1, // 32: airgate.plugin.v1.WebSocketFrame.type:type_name -> airgate.plugin.v1.WebSocketFrame.FrameType - 34, // 33: airgate.plugin.v1.WebSocketFrame.connect_info:type_name -> airgate.plugin.v1.WebSocketConnectInfo - 24, // 34: airgate.plugin.v1.WebSocketFrame.outcome:type_name -> airgate.plugin.v1.ForwardOutcome - 72, // 35: airgate.plugin.v1.WebSocketConnectInfo.headers:type_name -> airgate.plugin.v1.WebSocketConnectInfo.HeadersEntry - 17, // 36: airgate.plugin.v1.WebSocketConnectInfo.account:type_name -> airgate.plugin.v1.AccountProto - 35, // 37: airgate.plugin.v1.WebAssetsResponse.files:type_name -> airgate.plugin.v1.WebAssetFile - 73, // 38: airgate.plugin.v1.PayloadSchemaProto.metadata:type_name -> airgate.plugin.v1.PayloadSchemaProto.MetadataEntry - 37, // 39: airgate.plugin.v1.RouteSchemaProto.request:type_name -> airgate.plugin.v1.PayloadSchemaProto - 37, // 40: airgate.plugin.v1.RouteSchemaProto.response:type_name -> airgate.plugin.v1.PayloadSchemaProto - 74, // 41: airgate.plugin.v1.RouteSchemaProto.metadata:type_name -> airgate.plugin.v1.RouteSchemaProto.MetadataEntry - 37, // 42: airgate.plugin.v1.TaskSchemaProto.input:type_name -> airgate.plugin.v1.PayloadSchemaProto - 37, // 43: airgate.plugin.v1.TaskSchemaProto.output:type_name -> airgate.plugin.v1.PayloadSchemaProto - 75, // 44: airgate.plugin.v1.TaskSchemaProto.metadata:type_name -> airgate.plugin.v1.TaskSchemaProto.MetadataEntry - 37, // 45: airgate.plugin.v1.EventSchemaProto.payload:type_name -> airgate.plugin.v1.PayloadSchemaProto - 76, // 46: airgate.plugin.v1.EventSchemaProto.metadata:type_name -> airgate.plugin.v1.EventSchemaProto.MetadataEntry - 37, // 47: airgate.plugin.v1.InvokeSchemaProto.request:type_name -> airgate.plugin.v1.PayloadSchemaProto - 37, // 48: airgate.plugin.v1.InvokeSchemaProto.response:type_name -> airgate.plugin.v1.PayloadSchemaProto - 77, // 49: airgate.plugin.v1.InvokeSchemaProto.metadata:type_name -> airgate.plugin.v1.InvokeSchemaProto.MetadataEntry - 37, // 50: airgate.plugin.v1.InvokeSchemaProto.client_frame:type_name -> airgate.plugin.v1.PayloadSchemaProto - 37, // 51: airgate.plugin.v1.InvokeSchemaProto.server_frame:type_name -> airgate.plugin.v1.PayloadSchemaProto - 38, // 52: airgate.plugin.v1.PluginSchemaResponse.routes:type_name -> airgate.plugin.v1.RouteSchemaProto - 39, // 53: airgate.plugin.v1.PluginSchemaResponse.tasks:type_name -> airgate.plugin.v1.TaskSchemaProto - 40, // 54: airgate.plugin.v1.PluginSchemaResponse.events:type_name -> airgate.plugin.v1.EventSchemaProto - 41, // 55: airgate.plugin.v1.PluginSchemaResponse.invokes:type_name -> airgate.plugin.v1.InvokeSchemaProto - 78, // 56: airgate.plugin.v1.PluginSchemaResponse.metadata:type_name -> airgate.plugin.v1.PluginSchemaResponse.MetadataEntry - 21, // 57: airgate.plugin.v1.MiddlewareRequest.estimates:type_name -> airgate.plugin.v1.UsageMetric - 79, // 58: airgate.plugin.v1.MiddlewareRequest.metadata:type_name -> airgate.plugin.v1.MiddlewareRequest.MetadataEntry - 80, // 59: airgate.plugin.v1.MiddlewareRequest.request_headers:type_name -> airgate.plugin.v1.MiddlewareRequest.RequestHeadersEntry - 21, // 60: airgate.plugin.v1.MiddlewareEvent.estimates:type_name -> airgate.plugin.v1.UsageMetric - 23, // 61: airgate.plugin.v1.MiddlewareEvent.usage:type_name -> airgate.plugin.v1.Usage - 81, // 62: airgate.plugin.v1.MiddlewareEvent.metadata:type_name -> airgate.plugin.v1.MiddlewareEvent.MetadataEntry - 82, // 63: airgate.plugin.v1.MiddlewareEvent.response_headers:type_name -> airgate.plugin.v1.MiddlewareEvent.ResponseHeadersEntry - 2, // 64: airgate.plugin.v1.MiddlewareDecision.action:type_name -> airgate.plugin.v1.MiddlewareDecision.Action - 83, // 65: airgate.plugin.v1.MiddlewareDecision.set_headers:type_name -> airgate.plugin.v1.MiddlewareDecision.SetHeadersEntry - 84, // 66: airgate.plugin.v1.MiddlewareDecision.metadata:type_name -> airgate.plugin.v1.MiddlewareDecision.MetadataEntry - 85, // 67: airgate.plugin.v1.EventSubscriptionProto.filter:type_name -> airgate.plugin.v1.EventSubscriptionProto.FilterEntry - 86, // 68: airgate.plugin.v1.EventSubscriptionProto.metadata:type_name -> airgate.plugin.v1.EventSubscriptionProto.MetadataEntry - 46, // 69: airgate.plugin.v1.EventSubscriptionsResponse.subscriptions:type_name -> airgate.plugin.v1.EventSubscriptionProto - 87, // 70: airgate.plugin.v1.PluginEvent.metadata:type_name -> airgate.plugin.v1.PluginEvent.MetadataEntry - 88, // 71: airgate.plugin.v1.HostInvokeRequest.metadata:type_name -> airgate.plugin.v1.HostInvokeRequest.MetadataEntry - 89, // 72: airgate.plugin.v1.HostInvokeResponse.metadata:type_name -> airgate.plugin.v1.HostInvokeResponse.MetadataEntry - 90, // 73: airgate.plugin.v1.HostStreamFrame.metadata:type_name -> airgate.plugin.v1.HostStreamFrame.MetadataEntry - 5, // 74: airgate.plugin.v1.ForwardRequest.HeadersEntry.value:type_name -> airgate.plugin.v1.HeaderValues - 5, // 75: airgate.plugin.v1.UpstreamResponse.HeadersEntry.value:type_name -> airgate.plugin.v1.HeaderValues - 5, // 76: airgate.plugin.v1.ForwardChunk.HeadersEntry.value:type_name -> airgate.plugin.v1.HeaderValues - 5, // 77: airgate.plugin.v1.HttpRequest.HeadersEntry.value:type_name -> airgate.plugin.v1.HeaderValues - 5, // 78: airgate.plugin.v1.HttpResponse.HeadersEntry.value:type_name -> airgate.plugin.v1.HeaderValues - 5, // 79: airgate.plugin.v1.HttpResponseChunk.HeadersEntry.value:type_name -> airgate.plugin.v1.HeaderValues - 5, // 80: airgate.plugin.v1.WebSocketConnectInfo.HeadersEntry.value:type_name -> airgate.plugin.v1.HeaderValues - 5, // 81: airgate.plugin.v1.MiddlewareRequest.RequestHeadersEntry.value:type_name -> airgate.plugin.v1.HeaderValues - 5, // 82: airgate.plugin.v1.MiddlewareEvent.ResponseHeadersEntry.value:type_name -> airgate.plugin.v1.HeaderValues - 5, // 83: airgate.plugin.v1.MiddlewareDecision.SetHeadersEntry.value:type_name -> airgate.plugin.v1.HeaderValues - 3, // 84: airgate.plugin.v1.PluginService.GetInfo:input_type -> airgate.plugin.v1.Empty - 12, // 85: airgate.plugin.v1.PluginService.Init:input_type -> airgate.plugin.v1.InitRequest - 3, // 86: airgate.plugin.v1.PluginService.Start:input_type -> airgate.plugin.v1.Empty - 3, // 87: airgate.plugin.v1.PluginService.Stop:input_type -> airgate.plugin.v1.Empty - 3, // 88: airgate.plugin.v1.PluginService.GetWebAssets:input_type -> airgate.plugin.v1.Empty - 3, // 89: airgate.plugin.v1.PluginService.GetSchema:input_type -> airgate.plugin.v1.Empty - 3, // 90: airgate.plugin.v1.PluginService.HealthCheck:input_type -> airgate.plugin.v1.Empty - 27, // 91: airgate.plugin.v1.PluginService.HandleRequest:input_type -> airgate.plugin.v1.HttpRequest - 3, // 92: airgate.plugin.v1.GatewayService.GetPlatform:input_type -> airgate.plugin.v1.Empty - 3, // 93: airgate.plugin.v1.GatewayService.GetModels:input_type -> airgate.plugin.v1.Empty - 3, // 94: airgate.plugin.v1.GatewayService.GetRoutes:input_type -> airgate.plugin.v1.Empty - 18, // 95: airgate.plugin.v1.GatewayService.Forward:input_type -> airgate.plugin.v1.ForwardRequest - 18, // 96: airgate.plugin.v1.GatewayService.ForwardStream:input_type -> airgate.plugin.v1.ForwardRequest - 26, // 97: airgate.plugin.v1.GatewayService.ValidateAccount:input_type -> airgate.plugin.v1.CredentialsRequest - 33, // 98: airgate.plugin.v1.GatewayService.HandleWebSocket:input_type -> airgate.plugin.v1.WebSocketFrame - 3, // 99: airgate.plugin.v1.ExtensionService.Migrate:input_type -> airgate.plugin.v1.Empty - 3, // 100: airgate.plugin.v1.ExtensionService.GetBackgroundTasks:input_type -> airgate.plugin.v1.Empty - 32, // 101: airgate.plugin.v1.ExtensionService.RunBackgroundTask:input_type -> airgate.plugin.v1.RunBackgroundTaskRequest - 27, // 102: airgate.plugin.v1.ExtensionService.HandleRequest:input_type -> airgate.plugin.v1.HttpRequest - 27, // 103: airgate.plugin.v1.ExtensionService.HandleStreamRequest:input_type -> airgate.plugin.v1.HttpRequest - 53, // 104: airgate.plugin.v1.ExtensionService.ProcessTask:input_type -> airgate.plugin.v1.ProcessTaskRequest - 3, // 105: airgate.plugin.v1.ExtensionService.GetTaskTypes:input_type -> airgate.plugin.v1.Empty - 43, // 106: airgate.plugin.v1.MiddlewareService.OnForwardBegin:input_type -> airgate.plugin.v1.MiddlewareRequest - 44, // 107: airgate.plugin.v1.MiddlewareService.OnForwardEnd:input_type -> airgate.plugin.v1.MiddlewareEvent - 3, // 108: airgate.plugin.v1.EventService.GetEventSubscriptions:input_type -> airgate.plugin.v1.Empty - 48, // 109: airgate.plugin.v1.EventService.HandleEvent:input_type -> airgate.plugin.v1.PluginEvent - 50, // 110: airgate.plugin.v1.CoreInvokeService.Invoke:input_type -> airgate.plugin.v1.HostInvokeRequest - 52, // 111: airgate.plugin.v1.CoreInvokeService.InvokeStream:input_type -> airgate.plugin.v1.HostStreamFrame - 6, // 112: airgate.plugin.v1.PluginService.GetInfo:output_type -> airgate.plugin.v1.PluginInfoResponse - 3, // 113: airgate.plugin.v1.PluginService.Init:output_type -> airgate.plugin.v1.Empty - 3, // 114: airgate.plugin.v1.PluginService.Start:output_type -> airgate.plugin.v1.Empty - 3, // 115: airgate.plugin.v1.PluginService.Stop:output_type -> airgate.plugin.v1.Empty - 36, // 116: airgate.plugin.v1.PluginService.GetWebAssets:output_type -> airgate.plugin.v1.WebAssetsResponse - 42, // 117: airgate.plugin.v1.PluginService.GetSchema:output_type -> airgate.plugin.v1.PluginSchemaResponse - 3, // 118: airgate.plugin.v1.PluginService.HealthCheck:output_type -> airgate.plugin.v1.Empty - 28, // 119: airgate.plugin.v1.PluginService.HandleRequest:output_type -> airgate.plugin.v1.HttpResponse - 4, // 120: airgate.plugin.v1.GatewayService.GetPlatform:output_type -> airgate.plugin.v1.StringResponse - 14, // 121: airgate.plugin.v1.GatewayService.GetModels:output_type -> airgate.plugin.v1.ModelsResponse - 16, // 122: airgate.plugin.v1.GatewayService.GetRoutes:output_type -> airgate.plugin.v1.RoutesResponse - 24, // 123: airgate.plugin.v1.GatewayService.Forward:output_type -> airgate.plugin.v1.ForwardOutcome - 25, // 124: airgate.plugin.v1.GatewayService.ForwardStream:output_type -> airgate.plugin.v1.ForwardChunk - 3, // 125: airgate.plugin.v1.GatewayService.ValidateAccount:output_type -> airgate.plugin.v1.Empty - 33, // 126: airgate.plugin.v1.GatewayService.HandleWebSocket:output_type -> airgate.plugin.v1.WebSocketFrame - 3, // 127: airgate.plugin.v1.ExtensionService.Migrate:output_type -> airgate.plugin.v1.Empty - 31, // 128: airgate.plugin.v1.ExtensionService.GetBackgroundTasks:output_type -> airgate.plugin.v1.BackgroundTasksResponse - 3, // 129: airgate.plugin.v1.ExtensionService.RunBackgroundTask:output_type -> airgate.plugin.v1.Empty - 28, // 130: airgate.plugin.v1.ExtensionService.HandleRequest:output_type -> airgate.plugin.v1.HttpResponse - 29, // 131: airgate.plugin.v1.ExtensionService.HandleStreamRequest:output_type -> airgate.plugin.v1.HttpResponseChunk - 54, // 132: airgate.plugin.v1.ExtensionService.ProcessTask:output_type -> airgate.plugin.v1.ProcessTaskResponse - 55, // 133: airgate.plugin.v1.ExtensionService.GetTaskTypes:output_type -> airgate.plugin.v1.TaskTypesResponse - 45, // 134: airgate.plugin.v1.MiddlewareService.OnForwardBegin:output_type -> airgate.plugin.v1.MiddlewareDecision - 3, // 135: airgate.plugin.v1.MiddlewareService.OnForwardEnd:output_type -> airgate.plugin.v1.Empty - 47, // 136: airgate.plugin.v1.EventService.GetEventSubscriptions:output_type -> airgate.plugin.v1.EventSubscriptionsResponse - 49, // 137: airgate.plugin.v1.EventService.HandleEvent:output_type -> airgate.plugin.v1.EventHandleResponse - 51, // 138: airgate.plugin.v1.CoreInvokeService.Invoke:output_type -> airgate.plugin.v1.HostInvokeResponse - 52, // 139: airgate.plugin.v1.CoreInvokeService.InvokeStream:output_type -> airgate.plugin.v1.HostStreamFrame - 112, // [112:140] is the sub-list for method output_type - 84, // [84:112] is the sub-list for method input_type - 84, // [84:84] is the sub-list for extension type_name - 84, // [84:84] is the sub-list for extension extendee - 0, // [0:84] is the sub-list for field type_name + 58, // 13: airgate.plugin.v1.UpstreamResponse.headers:type_name -> airgate.plugin.v1.UpstreamResponse.HeadersEntry + 59, // 14: airgate.plugin.v1.Usage.metadata:type_name -> airgate.plugin.v1.Usage.MetadataEntry + 0, // 15: airgate.plugin.v1.ForwardOutcome.kind:type_name -> airgate.plugin.v1.OutcomeKind + 19, // 16: airgate.plugin.v1.ForwardOutcome.upstream:type_name -> airgate.plugin.v1.UpstreamResponse + 20, // 17: airgate.plugin.v1.ForwardOutcome.usage:type_name -> airgate.plugin.v1.Usage + 60, // 18: airgate.plugin.v1.ForwardOutcome.updated_credentials:type_name -> airgate.plugin.v1.ForwardOutcome.UpdatedCredentialsEntry + 21, // 19: airgate.plugin.v1.ForwardChunk.final_outcome:type_name -> airgate.plugin.v1.ForwardOutcome + 61, // 20: airgate.plugin.v1.ForwardChunk.headers:type_name -> airgate.plugin.v1.ForwardChunk.HeadersEntry + 62, // 21: airgate.plugin.v1.CredentialsRequest.credentials:type_name -> airgate.plugin.v1.CredentialsRequest.CredentialsEntry + 63, // 22: airgate.plugin.v1.HttpRequest.headers:type_name -> airgate.plugin.v1.HttpRequest.HeadersEntry + 64, // 23: airgate.plugin.v1.HttpResponse.headers:type_name -> airgate.plugin.v1.HttpResponse.HeadersEntry + 65, // 24: airgate.plugin.v1.HttpResponseChunk.headers:type_name -> airgate.plugin.v1.HttpResponseChunk.HeadersEntry + 27, // 25: airgate.plugin.v1.BackgroundTasksResponse.tasks:type_name -> airgate.plugin.v1.BackgroundTaskProto + 1, // 26: airgate.plugin.v1.WebSocketFrame.type:type_name -> airgate.plugin.v1.WebSocketFrame.FrameType + 31, // 27: airgate.plugin.v1.WebSocketFrame.connect_info:type_name -> airgate.plugin.v1.WebSocketConnectInfo + 21, // 28: airgate.plugin.v1.WebSocketFrame.outcome:type_name -> airgate.plugin.v1.ForwardOutcome + 66, // 29: airgate.plugin.v1.WebSocketConnectInfo.headers:type_name -> airgate.plugin.v1.WebSocketConnectInfo.HeadersEntry + 17, // 30: airgate.plugin.v1.WebSocketConnectInfo.account:type_name -> airgate.plugin.v1.AccountProto + 32, // 31: airgate.plugin.v1.WebAssetsResponse.files:type_name -> airgate.plugin.v1.WebAssetFile + 67, // 32: airgate.plugin.v1.PayloadSchemaProto.metadata:type_name -> airgate.plugin.v1.PayloadSchemaProto.MetadataEntry + 34, // 33: airgate.plugin.v1.RouteSchemaProto.request:type_name -> airgate.plugin.v1.PayloadSchemaProto + 34, // 34: airgate.plugin.v1.RouteSchemaProto.response:type_name -> airgate.plugin.v1.PayloadSchemaProto + 68, // 35: airgate.plugin.v1.RouteSchemaProto.metadata:type_name -> airgate.plugin.v1.RouteSchemaProto.MetadataEntry + 34, // 36: airgate.plugin.v1.TaskSchemaProto.input:type_name -> airgate.plugin.v1.PayloadSchemaProto + 34, // 37: airgate.plugin.v1.TaskSchemaProto.output:type_name -> airgate.plugin.v1.PayloadSchemaProto + 69, // 38: airgate.plugin.v1.TaskSchemaProto.metadata:type_name -> airgate.plugin.v1.TaskSchemaProto.MetadataEntry + 34, // 39: airgate.plugin.v1.EventSchemaProto.payload:type_name -> airgate.plugin.v1.PayloadSchemaProto + 70, // 40: airgate.plugin.v1.EventSchemaProto.metadata:type_name -> airgate.plugin.v1.EventSchemaProto.MetadataEntry + 34, // 41: airgate.plugin.v1.InvokeSchemaProto.request:type_name -> airgate.plugin.v1.PayloadSchemaProto + 34, // 42: airgate.plugin.v1.InvokeSchemaProto.response:type_name -> airgate.plugin.v1.PayloadSchemaProto + 71, // 43: airgate.plugin.v1.InvokeSchemaProto.metadata:type_name -> airgate.plugin.v1.InvokeSchemaProto.MetadataEntry + 34, // 44: airgate.plugin.v1.InvokeSchemaProto.client_frame:type_name -> airgate.plugin.v1.PayloadSchemaProto + 34, // 45: airgate.plugin.v1.InvokeSchemaProto.server_frame:type_name -> airgate.plugin.v1.PayloadSchemaProto + 35, // 46: airgate.plugin.v1.PluginSchemaResponse.routes:type_name -> airgate.plugin.v1.RouteSchemaProto + 36, // 47: airgate.plugin.v1.PluginSchemaResponse.tasks:type_name -> airgate.plugin.v1.TaskSchemaProto + 37, // 48: airgate.plugin.v1.PluginSchemaResponse.events:type_name -> airgate.plugin.v1.EventSchemaProto + 38, // 49: airgate.plugin.v1.PluginSchemaResponse.invokes:type_name -> airgate.plugin.v1.InvokeSchemaProto + 72, // 50: airgate.plugin.v1.PluginSchemaResponse.metadata:type_name -> airgate.plugin.v1.PluginSchemaResponse.MetadataEntry + 73, // 51: airgate.plugin.v1.MiddlewareRequest.metadata:type_name -> airgate.plugin.v1.MiddlewareRequest.MetadataEntry + 74, // 52: airgate.plugin.v1.MiddlewareRequest.request_headers:type_name -> airgate.plugin.v1.MiddlewareRequest.RequestHeadersEntry + 20, // 53: airgate.plugin.v1.MiddlewareEvent.usage:type_name -> airgate.plugin.v1.Usage + 75, // 54: airgate.plugin.v1.MiddlewareEvent.metadata:type_name -> airgate.plugin.v1.MiddlewareEvent.MetadataEntry + 76, // 55: airgate.plugin.v1.MiddlewareEvent.response_headers:type_name -> airgate.plugin.v1.MiddlewareEvent.ResponseHeadersEntry + 2, // 56: airgate.plugin.v1.MiddlewareDecision.action:type_name -> airgate.plugin.v1.MiddlewareDecision.Action + 77, // 57: airgate.plugin.v1.MiddlewareDecision.set_headers:type_name -> airgate.plugin.v1.MiddlewareDecision.SetHeadersEntry + 78, // 58: airgate.plugin.v1.MiddlewareDecision.metadata:type_name -> airgate.plugin.v1.MiddlewareDecision.MetadataEntry + 79, // 59: airgate.plugin.v1.EventSubscriptionProto.filter:type_name -> airgate.plugin.v1.EventSubscriptionProto.FilterEntry + 80, // 60: airgate.plugin.v1.EventSubscriptionProto.metadata:type_name -> airgate.plugin.v1.EventSubscriptionProto.MetadataEntry + 43, // 61: airgate.plugin.v1.EventSubscriptionsResponse.subscriptions:type_name -> airgate.plugin.v1.EventSubscriptionProto + 81, // 62: airgate.plugin.v1.PluginEvent.metadata:type_name -> airgate.plugin.v1.PluginEvent.MetadataEntry + 82, // 63: airgate.plugin.v1.HostInvokeRequest.metadata:type_name -> airgate.plugin.v1.HostInvokeRequest.MetadataEntry + 83, // 64: airgate.plugin.v1.HostInvokeResponse.metadata:type_name -> airgate.plugin.v1.HostInvokeResponse.MetadataEntry + 84, // 65: airgate.plugin.v1.HostStreamFrame.metadata:type_name -> airgate.plugin.v1.HostStreamFrame.MetadataEntry + 5, // 66: airgate.plugin.v1.ForwardRequest.HeadersEntry.value:type_name -> airgate.plugin.v1.HeaderValues + 5, // 67: airgate.plugin.v1.UpstreamResponse.HeadersEntry.value:type_name -> airgate.plugin.v1.HeaderValues + 5, // 68: airgate.plugin.v1.ForwardChunk.HeadersEntry.value:type_name -> airgate.plugin.v1.HeaderValues + 5, // 69: airgate.plugin.v1.HttpRequest.HeadersEntry.value:type_name -> airgate.plugin.v1.HeaderValues + 5, // 70: airgate.plugin.v1.HttpResponse.HeadersEntry.value:type_name -> airgate.plugin.v1.HeaderValues + 5, // 71: airgate.plugin.v1.HttpResponseChunk.HeadersEntry.value:type_name -> airgate.plugin.v1.HeaderValues + 5, // 72: airgate.plugin.v1.WebSocketConnectInfo.HeadersEntry.value:type_name -> airgate.plugin.v1.HeaderValues + 5, // 73: airgate.plugin.v1.MiddlewareRequest.RequestHeadersEntry.value:type_name -> airgate.plugin.v1.HeaderValues + 5, // 74: airgate.plugin.v1.MiddlewareEvent.ResponseHeadersEntry.value:type_name -> airgate.plugin.v1.HeaderValues + 5, // 75: airgate.plugin.v1.MiddlewareDecision.SetHeadersEntry.value:type_name -> airgate.plugin.v1.HeaderValues + 3, // 76: airgate.plugin.v1.PluginService.GetInfo:input_type -> airgate.plugin.v1.Empty + 12, // 77: airgate.plugin.v1.PluginService.Init:input_type -> airgate.plugin.v1.InitRequest + 3, // 78: airgate.plugin.v1.PluginService.Start:input_type -> airgate.plugin.v1.Empty + 3, // 79: airgate.plugin.v1.PluginService.Stop:input_type -> airgate.plugin.v1.Empty + 3, // 80: airgate.plugin.v1.PluginService.GetWebAssets:input_type -> airgate.plugin.v1.Empty + 3, // 81: airgate.plugin.v1.PluginService.GetSchema:input_type -> airgate.plugin.v1.Empty + 3, // 82: airgate.plugin.v1.PluginService.HealthCheck:input_type -> airgate.plugin.v1.Empty + 24, // 83: airgate.plugin.v1.PluginService.HandleRequest:input_type -> airgate.plugin.v1.HttpRequest + 3, // 84: airgate.plugin.v1.GatewayService.GetPlatform:input_type -> airgate.plugin.v1.Empty + 3, // 85: airgate.plugin.v1.GatewayService.GetModels:input_type -> airgate.plugin.v1.Empty + 3, // 86: airgate.plugin.v1.GatewayService.GetRoutes:input_type -> airgate.plugin.v1.Empty + 18, // 87: airgate.plugin.v1.GatewayService.Forward:input_type -> airgate.plugin.v1.ForwardRequest + 18, // 88: airgate.plugin.v1.GatewayService.ForwardStream:input_type -> airgate.plugin.v1.ForwardRequest + 23, // 89: airgate.plugin.v1.GatewayService.ValidateAccount:input_type -> airgate.plugin.v1.CredentialsRequest + 30, // 90: airgate.plugin.v1.GatewayService.HandleWebSocket:input_type -> airgate.plugin.v1.WebSocketFrame + 3, // 91: airgate.plugin.v1.ExtensionService.Migrate:input_type -> airgate.plugin.v1.Empty + 3, // 92: airgate.plugin.v1.ExtensionService.GetBackgroundTasks:input_type -> airgate.plugin.v1.Empty + 29, // 93: airgate.plugin.v1.ExtensionService.RunBackgroundTask:input_type -> airgate.plugin.v1.RunBackgroundTaskRequest + 24, // 94: airgate.plugin.v1.ExtensionService.HandleRequest:input_type -> airgate.plugin.v1.HttpRequest + 24, // 95: airgate.plugin.v1.ExtensionService.HandleStreamRequest:input_type -> airgate.plugin.v1.HttpRequest + 50, // 96: airgate.plugin.v1.ExtensionService.ProcessTask:input_type -> airgate.plugin.v1.ProcessTaskRequest + 3, // 97: airgate.plugin.v1.ExtensionService.GetTaskTypes:input_type -> airgate.plugin.v1.Empty + 40, // 98: airgate.plugin.v1.MiddlewareService.OnForwardBegin:input_type -> airgate.plugin.v1.MiddlewareRequest + 41, // 99: airgate.plugin.v1.MiddlewareService.OnForwardEnd:input_type -> airgate.plugin.v1.MiddlewareEvent + 3, // 100: airgate.plugin.v1.EventService.GetEventSubscriptions:input_type -> airgate.plugin.v1.Empty + 45, // 101: airgate.plugin.v1.EventService.HandleEvent:input_type -> airgate.plugin.v1.PluginEvent + 47, // 102: airgate.plugin.v1.CoreInvokeService.Invoke:input_type -> airgate.plugin.v1.HostInvokeRequest + 49, // 103: airgate.plugin.v1.CoreInvokeService.InvokeStream:input_type -> airgate.plugin.v1.HostStreamFrame + 6, // 104: airgate.plugin.v1.PluginService.GetInfo:output_type -> airgate.plugin.v1.PluginInfoResponse + 3, // 105: airgate.plugin.v1.PluginService.Init:output_type -> airgate.plugin.v1.Empty + 3, // 106: airgate.plugin.v1.PluginService.Start:output_type -> airgate.plugin.v1.Empty + 3, // 107: airgate.plugin.v1.PluginService.Stop:output_type -> airgate.plugin.v1.Empty + 33, // 108: airgate.plugin.v1.PluginService.GetWebAssets:output_type -> airgate.plugin.v1.WebAssetsResponse + 39, // 109: airgate.plugin.v1.PluginService.GetSchema:output_type -> airgate.plugin.v1.PluginSchemaResponse + 3, // 110: airgate.plugin.v1.PluginService.HealthCheck:output_type -> airgate.plugin.v1.Empty + 25, // 111: airgate.plugin.v1.PluginService.HandleRequest:output_type -> airgate.plugin.v1.HttpResponse + 4, // 112: airgate.plugin.v1.GatewayService.GetPlatform:output_type -> airgate.plugin.v1.StringResponse + 14, // 113: airgate.plugin.v1.GatewayService.GetModels:output_type -> airgate.plugin.v1.ModelsResponse + 16, // 114: airgate.plugin.v1.GatewayService.GetRoutes:output_type -> airgate.plugin.v1.RoutesResponse + 21, // 115: airgate.plugin.v1.GatewayService.Forward:output_type -> airgate.plugin.v1.ForwardOutcome + 22, // 116: airgate.plugin.v1.GatewayService.ForwardStream:output_type -> airgate.plugin.v1.ForwardChunk + 3, // 117: airgate.plugin.v1.GatewayService.ValidateAccount:output_type -> airgate.plugin.v1.Empty + 30, // 118: airgate.plugin.v1.GatewayService.HandleWebSocket:output_type -> airgate.plugin.v1.WebSocketFrame + 3, // 119: airgate.plugin.v1.ExtensionService.Migrate:output_type -> airgate.plugin.v1.Empty + 28, // 120: airgate.plugin.v1.ExtensionService.GetBackgroundTasks:output_type -> airgate.plugin.v1.BackgroundTasksResponse + 3, // 121: airgate.plugin.v1.ExtensionService.RunBackgroundTask:output_type -> airgate.plugin.v1.Empty + 25, // 122: airgate.plugin.v1.ExtensionService.HandleRequest:output_type -> airgate.plugin.v1.HttpResponse + 26, // 123: airgate.plugin.v1.ExtensionService.HandleStreamRequest:output_type -> airgate.plugin.v1.HttpResponseChunk + 51, // 124: airgate.plugin.v1.ExtensionService.ProcessTask:output_type -> airgate.plugin.v1.ProcessTaskResponse + 52, // 125: airgate.plugin.v1.ExtensionService.GetTaskTypes:output_type -> airgate.plugin.v1.TaskTypesResponse + 42, // 126: airgate.plugin.v1.MiddlewareService.OnForwardBegin:output_type -> airgate.plugin.v1.MiddlewareDecision + 3, // 127: airgate.plugin.v1.MiddlewareService.OnForwardEnd:output_type -> airgate.plugin.v1.Empty + 44, // 128: airgate.plugin.v1.EventService.GetEventSubscriptions:output_type -> airgate.plugin.v1.EventSubscriptionsResponse + 46, // 129: airgate.plugin.v1.EventService.HandleEvent:output_type -> airgate.plugin.v1.EventHandleResponse + 48, // 130: airgate.plugin.v1.CoreInvokeService.Invoke:output_type -> airgate.plugin.v1.HostInvokeResponse + 49, // 131: airgate.plugin.v1.CoreInvokeService.InvokeStream:output_type -> airgate.plugin.v1.HostStreamFrame + 104, // [104:132] is the sub-list for method output_type + 76, // [76:104] is the sub-list for method input_type + 76, // [76:76] is the sub-list for extension type_name + 76, // [76:76] is the sub-list for extension extendee + 0, // [0:76] is the sub-list for field type_name } func init() { file_plugin_proto_init() } @@ -4908,7 +4678,7 @@ func file_plugin_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_plugin_proto_rawDesc), len(file_plugin_proto_rawDesc)), NumEnums: 3, - NumMessages: 88, + NumMessages: 82, NumExtensions: 0, NumServices: 6, }, diff --git a/protocol/proto/plugin.proto b/protocol/proto/plugin.proto index ce2dda3..531bdbe 100644 --- a/protocol/proto/plugin.proto +++ b/protocol/proto/plugin.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package airgate.plugin.v1; -option go_package = "github.com/DouDOU-start/airgate-sdk/protocol/proto"; +option go_package = "github.com/DevilGenius/airgate-sdk/protocol/proto"; // ==================== 插件基础服务 ==================== @@ -234,6 +234,7 @@ enum OutcomeKind { OUTCOME_UPSTREAM_TRANSIENT = 5; OUTCOME_STREAM_ABORTED = 6; OUTCOME_ACCOUNT_MODEL_UNSUPPORTED = 7; + OUTCOME_ACCOUNT_UNAVAILABLE = 8; } // UpstreamResponse 上游返回的原始 HTTP 快照。 @@ -243,38 +244,6 @@ message UpstreamResponse { bytes body = 3; } -// UsageAttribute 是插件计算后的通用审计维度。 -message UsageAttribute { - string key = 1; - string label = 2; - string kind = 3; - string value = 4; - map metadata = 5; -} - -// UsageMetric 是插件计算后的通用计量结果。 -message UsageMetric { - string key = 1; - string label = 2; - string kind = 3; - string unit = 4; - double value = 5; - double account_cost = 6; - string currency = 7; - map metadata = 8; -} - -// UsageCostDetail 是通用费用明细。 -message UsageCostDetail { - string key = 1; - string label = 2; - double account_cost = 3; - double user_cost = 4; - double billing_multiplier = 5; - string currency = 6; - map metadata = 7; -} - // Usage 单次调用的用量与费用结果。非 Success 判决下应为空。 message Usage { string model = 1; @@ -284,10 +253,22 @@ message Usage { string currency = 5; string summary = 6; int64 first_token_ms = 7; - repeated UsageMetric metrics = 8; - repeated UsageAttribute attributes = 9; - repeated UsageCostDetail cost_details = 10; map metadata = 11; + int64 input_tokens = 12; + int64 output_tokens = 13; + int64 cached_input_tokens = 14; + int64 cache_creation_tokens = 15; + int64 reasoning_output_tokens = 18; + double input_price = 22; + double output_price = 23; + double cached_input_price = 24; + double cache_creation_price = 25; + double input_cost = 27; + double output_cost = 28; + double cached_input_cost = 29; + double cache_creation_cost = 30; + string reasoning_effort = 35; + reserved 8, 9, 10, 16, 17, 19, 20, 21, 26, 31, 32, 33, 34; } // ForwardOutcome 插件对一次 Forward 的完整判决结果。 @@ -466,7 +447,7 @@ message MiddlewareRequest { string platform = 5; string model = 6; bool stream = 7; - repeated UsageMetric estimates = 8; // Core 或插件提供的通用预估值,仅用于早期决策 + reserved 8; // metadata KV bag:供多个 middleware 之间传递上下文。 // 命名空间规则由 Core 管理,插件不应依赖未声明的敏感字段。 @@ -487,7 +468,7 @@ message MiddlewareEvent { string platform = 5; string model = 6; bool stream = 7; - repeated UsageMetric estimates = 8; // 与 MiddlewareRequest 字段对齐,便于 estimate vs actual 比对。 + reserved 8; // === 响应结果 === int64 status_code = 20; diff --git a/runtimego/grpc/common.go b/runtimego/grpc/common.go index d071f1b..bb16a20 100644 --- a/runtimego/grpc/common.go +++ b/runtimego/grpc/common.go @@ -6,8 +6,8 @@ import ( "net/http" "time" - pb "github.com/DouDOU-start/airgate-sdk/protocol/proto" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + pb "github.com/DevilGenius/airgate-sdk/protocol/proto" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) // defaultGRPCTimeout gRPC 内部调用的默认超时时间 diff --git a/runtimego/grpc/context.go b/runtimego/grpc/context.go index cadbd09..fecc93a 100644 --- a/runtimego/grpc/context.go +++ b/runtimego/grpc/context.go @@ -9,8 +9,8 @@ import ( goplugin "github.com/hashicorp/go-plugin" - pb "github.com/DouDOU-start/airgate-sdk/protocol/proto" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + pb "github.com/DevilGenius/airgate-sdk/protocol/proto" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) // grpcPluginContext 通过 gRPC 传入的插件上下文(插件进程侧)。 diff --git a/runtimego/grpc/convert_test.go b/runtimego/grpc/convert_test.go index 65fdd04..2a50b90 100644 --- a/runtimego/grpc/convert_test.go +++ b/runtimego/grpc/convert_test.go @@ -7,8 +7,8 @@ import ( "testing" "time" - pb "github.com/DouDOU-start/airgate-sdk/protocol/proto" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + pb "github.com/DevilGenius/airgate-sdk/protocol/proto" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) // --------------------------------------------------------------------------- @@ -91,46 +91,29 @@ func TestForwardOutcome_RoundTrip(t *testing.T) { Body: []byte(`{"ok":true}`), }, Usage: &sdk.Usage{ - Model: "claude-opus-4-20250514", - AccountCost: 0.026875, - UserCost: 0.05375, - BillingMultiplier: 2, - Currency: "USD", - Summary: "输入 150 token,输出 300 token", - FirstTokenMs: 120, - Attributes: []sdk.UsageAttribute{ - {Key: "reasoning_effort", Label: "思考层级", Kind: "reasoning", Value: "high"}, - {Key: "resolution", Label: "分辨率", Kind: "resolution", Value: "1024x1024"}, - }, - Metrics: []sdk.UsageMetric{ - { - Key: "image_generation", - Label: "图片生成", - Kind: "image", - Unit: "image", - Value: 2, - AccountCost: 0.08, - Currency: "USD", - Metadata: map[string]string{ - "size": "1024x1024", - }, - }, - }, - CostDetails: []sdk.UsageCostDetail{ - { - Key: "image_generation", - Label: "图片生成费用", - AccountCost: 0.08, - UserCost: 0.16, - BillingMultiplier: 2, - Currency: "USD", - Metadata: map[string]string{ - "tier": "standard", - }, - }, - }, + Model: "claude-opus-4-20250514", + AccountCost: 0.026875, + UserCost: 0.05375, + BillingMultiplier: 2, + Currency: "USD", + Summary: "输入 150 token,输出 300 token", + FirstTokenMs: 120, + InputTokens: 150, + OutputTokens: 300, + CachedInputTokens: 20, + ReasoningEffort: "high", + InputPrice: 3, + OutputPrice: 15, + CacheCreationPrice: 3.75, + InputCost: 0.00045, + OutputCost: 0.0045, Metadata: map[string]string{ - "billing_mode": "mixed", + "billing_mode": "mixed", + "service_tier": "priority", + "openai.image.size": "1024x1024", + "openai.image.count": "2", + "openai.image.unit_price": "0.04", + "openai.image.unit": "USD/image", }, }, Duration: 2500 * time.Millisecond, @@ -183,6 +166,7 @@ func TestForwardOutcome_KindPreserved(t *testing.T) { sdk.OutcomeAccountDead, sdk.OutcomeUpstreamTransient, sdk.OutcomeStreamAborted, + sdk.OutcomeAccountUnavailable, } for _, k := range kinds { original := sdk.ForwardOutcome{Kind: k} diff --git a/runtimego/grpc/event_schema_test.go b/runtimego/grpc/event_schema_test.go index ef55a64..28fc352 100644 --- a/runtimego/grpc/event_schema_test.go +++ b/runtimego/grpc/event_schema_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) func TestPluginEventRoundTrip(t *testing.T) { diff --git a/runtimego/grpc/event_server.go b/runtimego/grpc/event_server.go index 45919b6..ae48f3a 100644 --- a/runtimego/grpc/event_server.go +++ b/runtimego/grpc/event_server.go @@ -5,8 +5,8 @@ import ( "errors" "time" - pb "github.com/DouDOU-start/airgate-sdk/protocol/proto" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + pb "github.com/DevilGenius/airgate-sdk/protocol/proto" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) // EventGRPCServer 将可选 EventHandler 包装为 gRPC 服务。 diff --git a/runtimego/grpc/extension_client.go b/runtimego/grpc/extension_client.go index 2148d7b..f9fbedb 100644 --- a/runtimego/grpc/extension_client.go +++ b/runtimego/grpc/extension_client.go @@ -4,8 +4,8 @@ import ( "context" "time" - pb "github.com/DouDOU-start/airgate-sdk/protocol/proto" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + pb "github.com/DevilGenius/airgate-sdk/protocol/proto" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) // migrateTimeout 数据库迁移的超时时间(迁移可能涉及大量数据,需要较长时间) diff --git a/runtimego/grpc/extension_router.go b/runtimego/grpc/extension_router.go index db80eb0..0596215 100644 --- a/runtimego/grpc/extension_router.go +++ b/runtimego/grpc/extension_router.go @@ -5,7 +5,7 @@ import ( "strings" "sync" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) // extensionRouter 实现 sdk.RouteRegistrar,用于在 gRPC 模式下将 HTTP 请求分发到注册的处理函数 diff --git a/runtimego/grpc/extension_server.go b/runtimego/grpc/extension_server.go index efd2766..e345f4e 100644 --- a/runtimego/grpc/extension_server.go +++ b/runtimego/grpc/extension_server.go @@ -10,8 +10,8 @@ import ( "strings" "sync" - pb "github.com/DouDOU-start/airgate-sdk/protocol/proto" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + pb "github.com/DevilGenius/airgate-sdk/protocol/proto" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) // streamResponseWriter 把每次 Write 调用转为 gRPC HttpResponseChunk 发送。 diff --git a/runtimego/grpc/gateway_client.go b/runtimego/grpc/gateway_client.go index 133275c..c5ab7c6 100644 --- a/runtimego/grpc/gateway_client.go +++ b/runtimego/grpc/gateway_client.go @@ -8,8 +8,8 @@ import ( "net/http" "sync" - pb "github.com/DouDOU-start/airgate-sdk/protocol/proto" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + pb "github.com/DevilGenius/airgate-sdk/protocol/proto" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) // GatewayGRPCClient 把 gRPC 客户端包装成 GatewayPlugin 接口,供 Core 消费。 diff --git a/runtimego/grpc/gateway_server.go b/runtimego/grpc/gateway_server.go index d702ca6..20e506e 100644 --- a/runtimego/grpc/gateway_server.go +++ b/runtimego/grpc/gateway_server.go @@ -6,8 +6,8 @@ import ( "net/http" "time" - pb "github.com/DouDOU-start/airgate-sdk/protocol/proto" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + pb "github.com/DevilGenius/airgate-sdk/protocol/proto" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) // GatewayGRPCServer 将 GatewayPlugin 包装为 gRPC 服务端。 @@ -129,6 +129,8 @@ func outcomeKindToProto(k sdk.OutcomeKind) pb.OutcomeKind { return pb.OutcomeKind_OUTCOME_STREAM_ABORTED case sdk.OutcomeAccountModelUnsupported: //nolint:staticcheck // 兼容旧插件 return pb.OutcomeKind_OUTCOME_CLIENT_ERROR + case sdk.OutcomeAccountUnavailable: + return pb.OutcomeKind_OUTCOME_ACCOUNT_UNAVAILABLE default: return pb.OutcomeKind_OUTCOME_UNKNOWN } @@ -150,6 +152,8 @@ func outcomeKindFromProto(k pb.OutcomeKind) sdk.OutcomeKind { return sdk.OutcomeStreamAborted case pb.OutcomeKind_OUTCOME_ACCOUNT_MODEL_UNSUPPORTED: return sdk.OutcomeClientError + case pb.OutcomeKind_OUTCOME_ACCOUNT_UNAVAILABLE: + return sdk.OutcomeAccountUnavailable default: return sdk.OutcomeUnknown } @@ -176,183 +180,60 @@ func upstreamFromProto(p *pb.UpstreamResponse) sdk.UpstreamResponse { func usageToProto(u sdk.Usage) *pb.Usage { out := &pb.Usage{ - Model: u.Model, - AccountCost: u.AccountCost, - UserCost: u.UserCost, - BillingMultiplier: u.BillingMultiplier, - Currency: u.Currency, - Summary: u.Summary, - FirstTokenMs: u.FirstTokenMs, - Metadata: u.Metadata, - } - out.Attributes = usageAttributesToProto(u.Attributes) - out.Metrics = usageMetricsToProto(u.Metrics) - out.CostDetails = usageCostDetailsToProto(u.CostDetails) + Model: u.Model, + AccountCost: u.AccountCost, + UserCost: u.UserCost, + BillingMultiplier: u.BillingMultiplier, + Currency: u.Currency, + Summary: u.Summary, + FirstTokenMs: u.FirstTokenMs, + Metadata: u.Metadata, + InputTokens: int64(u.InputTokens), + OutputTokens: int64(u.OutputTokens), + CachedInputTokens: int64(u.CachedInputTokens), + CacheCreationTokens: int64(u.CacheCreationTokens), + ReasoningOutputTokens: int64(u.ReasoningOutputTokens), + ReasoningEffort: u.ReasoningEffort, + InputPrice: u.InputPrice, + OutputPrice: u.OutputPrice, + CachedInputPrice: u.CachedInputPrice, + CacheCreationPrice: u.CacheCreationPrice, + InputCost: u.InputCost, + OutputCost: u.OutputCost, + CachedInputCost: u.CachedInputCost, + CacheCreationCost: u.CacheCreationCost, + } return out } func usageFromProto(p *pb.Usage) sdk.Usage { out := sdk.Usage{ - Model: p.Model, - AccountCost: p.AccountCost, - UserCost: p.UserCost, - BillingMultiplier: p.BillingMultiplier, - Currency: p.Currency, - Summary: p.Summary, - FirstTokenMs: p.FirstTokenMs, - Metadata: p.Metadata, - } - out.Attributes = usageAttributesFromProto(p.Attributes) - out.Metrics = usageMetricsFromProto(p.Metrics) - out.CostDetails = usageCostDetailsFromProto(p.CostDetails) - return out -} - -func usageAttributesToProto(attrs []sdk.UsageAttribute) []*pb.UsageAttribute { - if len(attrs) == 0 { - return nil - } - out := make([]*pb.UsageAttribute, 0, len(attrs)) - for _, a := range attrs { - out = append(out, usageAttributeToProto(a)) - } - return out -} - -func usageAttributesFromProto(attrs []*pb.UsageAttribute) []sdk.UsageAttribute { - if len(attrs) == 0 { - return nil - } - out := make([]sdk.UsageAttribute, 0, len(attrs)) - for _, a := range attrs { - out = append(out, usageAttributeFromProto(a)) - } - return out -} - -func usageAttributeToProto(a sdk.UsageAttribute) *pb.UsageAttribute { - return &pb.UsageAttribute{ - Key: a.Key, - Label: a.Label, - Kind: a.Kind, - Value: a.Value, - Metadata: a.Metadata, - } -} - -func usageAttributeFromProto(p *pb.UsageAttribute) sdk.UsageAttribute { - if p == nil { - return sdk.UsageAttribute{} - } - return sdk.UsageAttribute{ - Key: p.Key, - Label: p.Label, - Kind: p.Kind, - Value: p.Value, - Metadata: p.Metadata, - } -} - -func usageMetricsToProto(metrics []sdk.UsageMetric) []*pb.UsageMetric { - if len(metrics) == 0 { - return nil - } - out := make([]*pb.UsageMetric, 0, len(metrics)) - for _, m := range metrics { - out = append(out, usageMetricToProto(m)) + Model: p.Model, + AccountCost: p.AccountCost, + UserCost: p.UserCost, + BillingMultiplier: p.BillingMultiplier, + Currency: p.Currency, + Summary: p.Summary, + FirstTokenMs: p.FirstTokenMs, + Metadata: p.Metadata, + InputTokens: int(p.InputTokens), + OutputTokens: int(p.OutputTokens), + CachedInputTokens: int(p.CachedInputTokens), + CacheCreationTokens: int(p.CacheCreationTokens), + ReasoningOutputTokens: int(p.ReasoningOutputTokens), + ReasoningEffort: p.ReasoningEffort, + InputPrice: p.InputPrice, + OutputPrice: p.OutputPrice, + CachedInputPrice: p.CachedInputPrice, + CacheCreationPrice: p.CacheCreationPrice, + InputCost: p.InputCost, + OutputCost: p.OutputCost, + CachedInputCost: p.CachedInputCost, + CacheCreationCost: p.CacheCreationCost, } return out } -func usageMetricsFromProto(metrics []*pb.UsageMetric) []sdk.UsageMetric { - if len(metrics) == 0 { - return nil - } - out := make([]sdk.UsageMetric, 0, len(metrics)) - for _, m := range metrics { - out = append(out, usageMetricFromProto(m)) - } - return out -} - -func usageMetricToProto(m sdk.UsageMetric) *pb.UsageMetric { - return &pb.UsageMetric{ - Key: m.Key, - Label: m.Label, - Kind: m.Kind, - Unit: m.Unit, - Value: m.Value, - AccountCost: m.AccountCost, - Currency: m.Currency, - Metadata: m.Metadata, - } -} - -func usageMetricFromProto(p *pb.UsageMetric) sdk.UsageMetric { - if p == nil { - return sdk.UsageMetric{} - } - return sdk.UsageMetric{ - Key: p.Key, - Label: p.Label, - Kind: p.Kind, - Unit: p.Unit, - Value: p.Value, - AccountCost: p.AccountCost, - Currency: p.Currency, - Metadata: p.Metadata, - } -} - -func usageCostDetailsToProto(details []sdk.UsageCostDetail) []*pb.UsageCostDetail { - if len(details) == 0 { - return nil - } - out := make([]*pb.UsageCostDetail, 0, len(details)) - for _, c := range details { - out = append(out, usageCostDetailToProto(c)) - } - return out -} - -func usageCostDetailsFromProto(details []*pb.UsageCostDetail) []sdk.UsageCostDetail { - if len(details) == 0 { - return nil - } - out := make([]sdk.UsageCostDetail, 0, len(details)) - for _, c := range details { - out = append(out, usageCostDetailFromProto(c)) - } - return out -} - -func usageCostDetailToProto(c sdk.UsageCostDetail) *pb.UsageCostDetail { - return &pb.UsageCostDetail{ - Key: c.Key, - Label: c.Label, - AccountCost: c.AccountCost, - UserCost: c.UserCost, - BillingMultiplier: c.BillingMultiplier, - Currency: c.Currency, - Metadata: c.Metadata, - } -} - -func usageCostDetailFromProto(p *pb.UsageCostDetail) sdk.UsageCostDetail { - if p == nil { - return sdk.UsageCostDetail{} - } - return sdk.UsageCostDetail{ - Key: p.Key, - Label: p.Label, - AccountCost: p.AccountCost, - UserCost: p.UserCost, - BillingMultiplier: p.BillingMultiplier, - Currency: p.Currency, - Metadata: p.Metadata, - } -} - func protoHeadersToHTTP(ph map[string]*pb.HeaderValues) http.Header { h := make(http.Header, len(ph)) for k, v := range ph { diff --git a/runtimego/grpc/gateway_stream_test.go b/runtimego/grpc/gateway_stream_test.go index e3b3482..e18c329 100644 --- a/runtimego/grpc/gateway_stream_test.go +++ b/runtimego/grpc/gateway_stream_test.go @@ -10,8 +10,8 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/metadata" - pb "github.com/DouDOU-start/airgate-sdk/protocol/proto" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + pb "github.com/DevilGenius/airgate-sdk/protocol/proto" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) type stubForwardStreamServer struct { diff --git a/runtimego/grpc/go_plugin.go b/runtimego/grpc/go_plugin.go index f386c60..9b9301b 100644 --- a/runtimego/grpc/go_plugin.go +++ b/runtimego/grpc/go_plugin.go @@ -8,8 +8,8 @@ import ( goplugin "github.com/hashicorp/go-plugin" "google.golang.org/grpc" - pb "github.com/DouDOU-start/airgate-sdk/protocol/proto" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + pb "github.com/DevilGenius/airgate-sdk/protocol/proto" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) // 确保所有 Plugin 类型都实现了 goplugin.GRPCPlugin 接口 diff --git a/runtimego/grpc/go_plugin_test.go b/runtimego/grpc/go_plugin_test.go index f97b849..b3bb994 100644 --- a/runtimego/grpc/go_plugin_test.go +++ b/runtimego/grpc/go_plugin_test.go @@ -6,8 +6,8 @@ import ( gogrpc "google.golang.org/grpc" - pb "github.com/DouDOU-start/airgate-sdk/protocol/proto" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + pb "github.com/DevilGenius/airgate-sdk/protocol/proto" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) type taskGatewayPlugin struct{} diff --git a/runtimego/grpc/host_client.go b/runtimego/grpc/host_client.go index e85a7e5..888a740 100644 --- a/runtimego/grpc/host_client.go +++ b/runtimego/grpc/host_client.go @@ -7,8 +7,8 @@ import ( "google.golang.org/grpc" - pb "github.com/DouDOU-start/airgate-sdk/protocol/proto" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + pb "github.com/DevilGenius/airgate-sdk/protocol/proto" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) // hostClient 把 pb.CoreInvokeServiceClient 包装成 sdk.Host 接口。 diff --git a/runtimego/grpc/host_client_test.go b/runtimego/grpc/host_client_test.go index 85303f6..4534257 100644 --- a/runtimego/grpc/host_client_test.go +++ b/runtimego/grpc/host_client_test.go @@ -9,8 +9,8 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/metadata" - pb "github.com/DouDOU-start/airgate-sdk/protocol/proto" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + pb "github.com/DevilGenius/airgate-sdk/protocol/proto" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) type stubCoreInvokeClient struct { diff --git a/runtimego/grpc/logging_interceptor.go b/runtimego/grpc/logging_interceptor.go index 5c371cc..232031e 100644 --- a/runtimego/grpc/logging_interceptor.go +++ b/runtimego/grpc/logging_interceptor.go @@ -11,7 +11,7 @@ import ( "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) // MetadataRequestIDKey 是 gRPC metadata 中 request_id 的键。 diff --git a/runtimego/grpc/middleware_client.go b/runtimego/grpc/middleware_client.go index b5e27b0..7b90e98 100644 --- a/runtimego/grpc/middleware_client.go +++ b/runtimego/grpc/middleware_client.go @@ -4,8 +4,8 @@ import ( "context" "time" - pb "github.com/DouDOU-start/airgate-sdk/protocol/proto" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + pb "github.com/DevilGenius/airgate-sdk/protocol/proto" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) // MiddlewareGRPCClient 把 pb.MiddlewareServiceClient 包装成给 core 用的 plain Go API。 @@ -56,7 +56,6 @@ func middlewareRequestToProto(req *sdk.MiddlewareRequest) *pb.MiddlewareRequest Platform: req.Platform, Model: req.Model, Stream: req.Stream, - Estimates: usageMetricsToProto(req.Estimates), Metadata: cloneStringMapMW(req.Metadata), RequestBody: req.RequestBody, } @@ -78,7 +77,6 @@ func middlewareEventToProto(evt *sdk.MiddlewareEvent) *pb.MiddlewareEvent { Platform: evt.Platform, Model: evt.Model, Stream: evt.Stream, - Estimates: usageMetricsToProto(evt.Estimates), StatusCode: int64(evt.StatusCode), DurationMs: int64(evt.Duration / time.Millisecond), ErrorKind: evt.ErrorKind, diff --git a/runtimego/grpc/middleware_server.go b/runtimego/grpc/middleware_server.go index 23c4b74..bd521e2 100644 --- a/runtimego/grpc/middleware_server.go +++ b/runtimego/grpc/middleware_server.go @@ -4,8 +4,8 @@ import ( "context" "time" - pb "github.com/DouDOU-start/airgate-sdk/protocol/proto" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + pb "github.com/DevilGenius/airgate-sdk/protocol/proto" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) // MiddlewareGRPCServer 把 sdk.MiddlewarePlugin 实现包成 gRPC server。 @@ -69,7 +69,6 @@ func middlewareRequestFromProto(req *pb.MiddlewareRequest) *sdk.MiddlewareReques Platform: req.Platform, Model: req.Model, Stream: req.Stream, - Estimates: usageMetricsFromProto(req.Estimates), Metadata: cloneStringMapMW(req.Metadata), RequestBody: req.RequestBody, } @@ -91,7 +90,6 @@ func middlewareEventFromProto(evt *pb.MiddlewareEvent) *sdk.MiddlewareEvent { Platform: evt.Platform, Model: evt.Model, Stream: evt.Stream, - Estimates: usageMetricsFromProto(evt.Estimates), StatusCode: int32(evt.StatusCode), Duration: time.Duration(evt.DurationMs) * time.Millisecond, ErrorKind: evt.ErrorKind, diff --git a/runtimego/grpc/plugin_server.go b/runtimego/grpc/plugin_server.go index 2659fd9..0301aa0 100644 --- a/runtimego/grpc/plugin_server.go +++ b/runtimego/grpc/plugin_server.go @@ -7,8 +7,8 @@ import ( goplugin "github.com/hashicorp/go-plugin" - pb "github.com/DouDOU-start/airgate-sdk/protocol/proto" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + pb "github.com/DevilGenius/airgate-sdk/protocol/proto" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) // PluginGRPCServer 将 sdk.Plugin 实现包装为 gRPC 服务端 diff --git a/runtimego/grpc/schema.go b/runtimego/grpc/schema.go index 68a0a5a..7cd8aed 100644 --- a/runtimego/grpc/schema.go +++ b/runtimego/grpc/schema.go @@ -1,8 +1,8 @@ package grpc import ( - pb "github.com/DouDOU-start/airgate-sdk/protocol/proto" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + pb "github.com/DevilGenius/airgate-sdk/protocol/proto" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) func payloadSchemaToProto(s sdk.PayloadSchema) *pb.PayloadSchemaProto { diff --git a/runtimego/grpc/ws_server.go b/runtimego/grpc/ws_server.go index c7d9670..1aef019 100644 --- a/runtimego/grpc/ws_server.go +++ b/runtimego/grpc/ws_server.go @@ -5,8 +5,8 @@ import ( "fmt" "io" - pb "github.com/DouDOU-start/airgate-sdk/protocol/proto" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + pb "github.com/DevilGenius/airgate-sdk/protocol/proto" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) // HandleWebSocket 处理核心发来的 WebSocket 双向流 diff --git a/sdkgo/capability_test.go b/sdkgo/capability_test.go index a35744c..3db5511 100644 --- a/sdkgo/capability_test.go +++ b/sdkgo/capability_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) func TestIsKnownCapability(t *testing.T) { diff --git a/sdkgo/errors_test.go b/sdkgo/errors_test.go index 68d05ac..3bf4a38 100644 --- a/sdkgo/errors_test.go +++ b/sdkgo/errors_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) func TestSentinelErrorsAreDistinct(t *testing.T) { diff --git a/sdkgo/middleware.go b/sdkgo/middleware.go index 370de54..40e940e 100644 --- a/sdkgo/middleware.go +++ b/sdkgo/middleware.go @@ -48,7 +48,6 @@ type MiddlewareRequest struct { Platform string Model string Stream bool - Estimates []UsageMetric // Metadata 贯穿 Begin/End 的 KV bag,多个 middleware 之间共享。 Metadata map[string]string @@ -67,7 +66,6 @@ type MiddlewareEvent struct { Platform string Model string Stream bool - Estimates []UsageMetric StatusCode int32 Duration time.Duration diff --git a/sdkgo/models_test.go b/sdkgo/models_test.go index c9f79c1..cc3fbc9 100644 --- a/sdkgo/models_test.go +++ b/sdkgo/models_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) func TestConfigFieldJSONRoundTrip(t *testing.T) { diff --git a/sdkgo/outcome.go b/sdkgo/outcome.go index f86e619..f957995 100644 --- a/sdkgo/outcome.go +++ b/sdkgo/outcome.go @@ -42,6 +42,10 @@ const ( // Deprecated: OutcomeAccountModelUnsupported 已归入 OutcomeClientError。 // 保留常量避免编译失败,运行时等同于 ClientError。 OutcomeAccountModelUnsupported + + // OutcomeAccountUnavailable 账号暂时不可用(例如 OpenAI 账号临时 403)。 + // Core 会短暂降级并累计次数,连续达到阈值后再升级为 AccountDead。 + OutcomeAccountUnavailable ) // String 返回人类可读名称,用于日志。 @@ -59,6 +63,8 @@ func (k OutcomeKind) String() string { return "upstream_transient" case OutcomeStreamAborted: return "stream_aborted" + case OutcomeAccountUnavailable: + return "account_unavailable" case OutcomeAccountModelUnsupported: return "client_error" default: @@ -72,7 +78,7 @@ func (k OutcomeKind) IsSuccess() bool { return k == OutcomeSuccess } // IsAccountFault 本次判决是否归咎于账号自身(RateLimited / Dead)。 // Core 据此决定是否推进账号状态机。 func (k OutcomeKind) IsAccountFault() bool { - return k == OutcomeAccountRateLimited || k == OutcomeAccountDead + return k == OutcomeAccountRateLimited || k == OutcomeAccountDead || k == OutcomeAccountUnavailable } // ShouldFailover 是否允许换账号重试。 @@ -80,7 +86,7 @@ func (k OutcomeKind) IsAccountFault() bool { // Success / Unknown 显然不该 failover。 func (k OutcomeKind) ShouldFailover() bool { switch k { - case OutcomeAccountRateLimited, OutcomeAccountDead, OutcomeUpstreamTransient: + case OutcomeAccountRateLimited, OutcomeAccountDead, OutcomeUpstreamTransient, OutcomeAccountUnavailable: return true } return false @@ -103,20 +109,32 @@ type UpstreamResponse struct { // 后仍计 token)可填;其他 Kind 下应为 nil。 // // 平台价格、token 拆分、图片分档等标准计费规则全部由网关插件自己实现。 -// 插件填 AccountCost / Currency;Core 统一入库后按用户、分组、模型等倍率 -// 写入 UserCost / BillingMultiplier。 +// 插件填通用 token、单价和账号成本字段;Core 只读取这些通用标量字段并按用户、 +// 分组、模型等倍率写入自己的 usage_log 标准列。插件特有维度(如 service_tier、 +// Claude cache TTL 拆分、OpenAI 图片尺寸/数量/单价)放入 Metadata。 type Usage struct { - Model string `json:"model,omitempty"` - AccountCost float64 `json:"account_cost,omitempty"` - UserCost float64 `json:"user_cost,omitempty"` - BillingMultiplier float64 `json:"billing_multiplier,omitempty"` - Currency string `json:"currency,omitempty"` - Summary string `json:"summary,omitempty"` - FirstTokenMs int64 `json:"first_token_ms,omitempty"` - Attributes []UsageAttribute `json:"attributes,omitempty"` - Metrics []UsageMetric `json:"metrics,omitempty"` - CostDetails []UsageCostDetail `json:"cost_details,omitempty"` - Metadata map[string]string `json:"metadata,omitempty"` + Model string `json:"model,omitempty"` + AccountCost float64 `json:"account_cost,omitempty"` + UserCost float64 `json:"user_cost,omitempty"` + BillingMultiplier float64 `json:"billing_multiplier,omitempty"` + Currency string `json:"currency,omitempty"` + Summary string `json:"summary,omitempty"` + FirstTokenMs int64 `json:"first_token_ms,omitempty"` + InputTokens int `json:"input_tokens,omitempty"` + OutputTokens int `json:"output_tokens,omitempty"` + CachedInputTokens int `json:"cached_input_tokens,omitempty"` + CacheCreationTokens int `json:"cache_creation_tokens,omitempty"` + ReasoningOutputTokens int `json:"reasoning_output_tokens,omitempty"` + ReasoningEffort string `json:"reasoning_effort,omitempty"` + InputPrice float64 `json:"input_price,omitempty"` + OutputPrice float64 `json:"output_price,omitempty"` + CachedInputPrice float64 `json:"cached_input_price,omitempty"` + CacheCreationPrice float64 `json:"cache_creation_price,omitempty"` + InputCost float64 `json:"input_cost,omitempty"` + OutputCost float64 `json:"output_cost,omitempty"` + CachedInputCost float64 `json:"cached_input_cost,omitempty"` + CacheCreationCost float64 `json:"cache_creation_cost,omitempty"` + Metadata map[string]string `json:"metadata,omitempty"` } // ForwardOutcome 是插件对一次 Forward 的完整判决结果。 diff --git a/sdkgo/outcome_test.go b/sdkgo/outcome_test.go index e0317a2..6f6fbad 100644 --- a/sdkgo/outcome_test.go +++ b/sdkgo/outcome_test.go @@ -3,7 +3,7 @@ package sdk_test import ( "testing" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) func TestOutcomeKind_String(t *testing.T) { @@ -18,6 +18,7 @@ func TestOutcomeKind_String(t *testing.T) { {sdk.OutcomeAccountDead, "account_dead"}, {sdk.OutcomeUpstreamTransient, "upstream_transient"}, {sdk.OutcomeStreamAborted, "stream_aborted"}, + {sdk.OutcomeAccountUnavailable, "account_unavailable"}, {sdk.OutcomeAccountModelUnsupported, "client_error"}, {sdk.OutcomeKind(99), "unknown"}, // 非枚举值回退到 unknown } @@ -52,6 +53,7 @@ func TestOutcomeKind_IsAccountFault(t *testing.T) { accountFaults := []sdk.OutcomeKind{ sdk.OutcomeAccountRateLimited, sdk.OutcomeAccountDead, + sdk.OutcomeAccountUnavailable, } for _, k := range accountFaults { if !k.IsAccountFault() { @@ -78,6 +80,7 @@ func TestOutcomeKind_ShouldFailover(t *testing.T) { sdk.OutcomeAccountRateLimited, sdk.OutcomeAccountDead, sdk.OutcomeUpstreamTransient, + sdk.OutcomeAccountUnavailable, } for _, k := range failover { if !k.ShouldFailover() { diff --git a/sdkgo/plugin_test.go b/sdkgo/plugin_test.go index 4481cd7..d821a7b 100644 --- a/sdkgo/plugin_test.go +++ b/sdkgo/plugin_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) func TestSDKVersion(t *testing.T) { diff --git a/sdkgo/usage.go b/sdkgo/usage.go deleted file mode 100644 index 5c176c3..0000000 --- a/sdkgo/usage.go +++ /dev/null @@ -1,42 +0,0 @@ -package sdk - -// UsageAttribute 是一次调用的通用审计维度。 -// -// 适合存储模型、思考层级、分辨率、质量档、服务档位等非数值或枚举型信息。 -// Core 可统一入库和检索,但不根据这些字段推导平台计费规则。 -type UsageAttribute struct { - Key string `json:"key,omitempty"` - Label string `json:"label"` - Kind string `json:"kind,omitempty"` // model / reasoning / resolution / tier / quality / custom - Value string `json:"value"` - Metadata map[string]string `json:"metadata,omitempty"` -} - -// UsageMetric 是一次调用的通用计量结果。 -// -// 插件负责根据平台标准计费规则计算 Value 和 AccountCost。SDK 不提供价格字段、倍率规则或 token -// 公式,Core 不应基于 Key 推导平台计费语义。 -type UsageMetric struct { - Key string `json:"key,omitempty"` - Label string `json:"label"` - Kind string `json:"kind,omitempty"` // token / request / image / audio / video / custom - Unit string `json:"unit,omitempty"` - Value float64 `json:"value"` - AccountCost float64 `json:"account_cost,omitempty"` - Currency string `json:"currency,omitempty"` - Metadata map[string]string `json:"metadata,omitempty"` -} - -// UsageCostDetail 是一次调用的通用费用明细。 -// -// 插件负责把平台价格、套餐规则和折扣计算成 AccountCost。Core 可统一入库, -// 再按用户、分组、模型等倍率写入 UserCost / BillingMultiplier。 -type UsageCostDetail struct { - Key string `json:"key,omitempty"` - Label string `json:"label"` - AccountCost float64 `json:"account_cost"` - UserCost float64 `json:"user_cost,omitempty"` - BillingMultiplier float64 `json:"billing_multiplier,omitempty"` - Currency string `json:"currency,omitempty"` - Metadata map[string]string `json:"metadata,omitempty"` -} diff --git a/sdkgo/usage_test.go b/sdkgo/usage_test.go index 572800c..b33ca50 100644 --- a/sdkgo/usage_test.go +++ b/sdkgo/usage_test.go @@ -5,37 +5,36 @@ import ( "strings" "testing" - sdk "github.com/DouDOU-start/airgate-sdk/sdkgo" + sdk "github.com/DevilGenius/airgate-sdk/sdkgo" ) func TestUsageJSONRoundTrip(t *testing.T) { usage := sdk.Usage{ - Model: "demo-model", - AccountCost: 0.042, - UserCost: 0.084, - BillingMultiplier: 2, - Currency: "USD", - Summary: "输入 10 token,输出 5 token", - FirstTokenMs: 120, - Attributes: []sdk.UsageAttribute{ - {Key: "reasoning_effort", Label: "思考层级", Kind: "reasoning", Value: "high"}, - {Key: "resolution", Label: "分辨率", Kind: "resolution", Value: "1024x1024"}, + Model: "demo-model", + AccountCost: 0.042, + UserCost: 0.084, + BillingMultiplier: 2, + Currency: "USD", + Summary: "输入 10 token,输出 5 token", + FirstTokenMs: 120, + InputTokens: 10, + OutputTokens: 5, + CachedInputTokens: 2, + ReasoningEffort: "high", + InputPrice: 1.25, + OutputPrice: 10, + CacheCreationPrice: 1.5, + InputCost: 0.0000125, + OutputCost: 0.00005, + Metadata: map[string]string{ + "provider": "demo", + "service_tier": "priority", + "openai.image.size": "1024x1024", + "openai.image.count": "1", + "openai.image.unit_price": "0.1", + "openai.image.unit": "USD/image", + "openai.image.input_text_tokens": "7", }, - Metrics: []sdk.UsageMetric{ - { - Key: "input_tokens", - Label: "输入 token", - Kind: "token", - Unit: "token", - Value: 10, - AccountCost: 0.01, - Currency: "USD", - }, - }, - CostDetails: []sdk.UsageCostDetail{ - {Key: "input", Label: "输入费用", AccountCost: 0.01, UserCost: 0.02, BillingMultiplier: 2, Currency: "USD"}, - }, - Metadata: map[string]string{"provider": "demo"}, } data, err := json.Marshal(usage) @@ -50,24 +49,29 @@ func TestUsageJSONRoundTrip(t *testing.T) { if got.Model != usage.Model || got.AccountCost != usage.AccountCost || got.UserCost != usage.UserCost || got.BillingMultiplier != usage.BillingMultiplier || got.Currency != usage.Currency { t.Fatalf("Usage round-trip mismatch: got %+v, want %+v", got, usage) } + if got.InputTokens != usage.InputTokens || got.OutputTokens != usage.OutputTokens || got.InputCost != usage.InputCost || got.OutputCost != usage.OutputCost { + t.Fatalf("Usage round-trip mismatch: got %+v, want %+v", got, usage) + } + if got.ReasoningEffort != "high" { + t.Fatalf("Usage reasoning_effort round-trip mismatch: %q", got.ReasoningEffort) + } + if got.Metadata["openai.image.count"] != "1" || got.Metadata["openai.image.unit_price"] != "0.1" { + t.Fatalf("Usage metadata round-trip mismatch: %+v", got.Metadata) + } raw := string(data) - for _, key := range []string{"account_cost", "user_cost", "billing_multiplier", "first_token_ms", "cost_details"} { + for _, key := range []string{"account_cost", "user_cost", "billing_multiplier", "first_token_ms", "input_tokens", "output_tokens", "cache_creation_price", "input_cost", "output_cost", "metadata"} { if !strings.Contains(raw, `"`+key+`"`) { t.Fatalf("Usage JSON 缺少 snake_case key %q: %s", key, raw) } } + for _, key := range []string{"openai.image.unit_price", "reasoning_effort", "service_tier"} { + if !strings.Contains(raw, `"`+key+`"`) { + t.Fatalf("Usage JSON metadata 缺少 key %q: %s", key, raw) + } + } for _, key := range []string{"AccountCost", "UserCost", "BillingMultiplier", "FirstTokenMs", "CostDetails"} { if strings.Contains(raw, `"`+key+`"`) { t.Fatalf("Usage JSON 不应包含 PascalCase key %q: %s", key, raw) } } - if len(got.Metrics) != 1 || got.Metrics[0].Key != "input_tokens" { - t.Fatalf("Metrics round-trip mismatch: %+v", got.Metrics) - } - if len(got.Attributes) != 2 || got.Attributes[0].Key != "reasoning_effort" { - t.Fatalf("Attributes round-trip mismatch: %+v", got.Attributes) - } - if len(got.CostDetails) != 1 || got.CostDetails[0].Key != "input" { - t.Fatalf("CostDetails round-trip mismatch: %+v", got.CostDetails) - } } diff --git a/theme/package.json b/theme/package.json index 1a3f51e..5347662 100644 --- a/theme/package.json +++ b/theme/package.json @@ -1,5 +1,5 @@ { - "name": "@doudou-start/airgate-theme", + "name": "@devilgenius/airgate-theme", "version": "0.2.1", "description": "AirGate 插件前端主题、样式隔离和公共组件包", "type": "module", @@ -7,7 +7,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "git+https://github.com/DouDOU-start/airgate-sdk.git", + "url": "git+https://github.com/DevilGenius/airgate-sdk.git", "directory": "theme" }, "publishConfig": {