wire: metered connections, protocol 12
The contract for slice S1 of the connectors spec (2026-11-12, rev 3.1): API-key connections (kind api_key, the TensorX row with Pi as harness), the limit and pay-as-you-go confirmations, budget and spend on a connection and in hello and sync, a usage row's cost and price version, the probe's usage, and the model, budget and resume_spend frames. Protocol 12 (ProtocolMetered): below it Encode drops API-key connections and cost fields, says a probe's usage as a check, and refuses the new frames and an API-key connect, so an older runner is refused metered connections. Fixtures for each, under the secret-field guard.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
20 files changed,
+477
−14
internal/wire/connections.go+37 −0internal/wire/connections_test.go+46 −3internal/wire/frames.go+23 −4internal/wire/metered.go+197 −0internal/wire/runners.go+75 −2internal/wire/runners_test.go+77 −1internal/wire/wire_test.go+2 −2internal/wire/wiretest/fixtures.go+8 −2internal/wire/wiretest/testdata/api/budget.json+1 −0internal/wire/wiretest/testdata/api/connect-request-api-key.json+1 −0internal/wire/wiretest/testdata/api/connection-choose-model.json+1 −0internal/wire/wiretest/testdata/api/connection-metered.json+1 −0internal/wire/wiretest/testdata/api/model-request.json+1 −0internal/wire/wiretest/testdata/api/resume-request.json+1 −0internal/wire/wiretest/testdata/frames/budget.json+1 −0internal/wire/wiretest/testdata/frames/connect-api-key.json+1 −0internal/wire/wiretest/testdata/frames/hello-metered.json+1 −0internal/wire/wiretest/testdata/frames/model.json+1 −0internal/wire/wiretest/testdata/frames/resume_spend.json+1 −0internal/wire/wiretest/testdata/frames/usage-probe.json+1 −0
diff --git a/internal/wire/connections.go b/internal/wire/connections.go| index a5114ded..90687a4f 100644 |
| --- a/internal/wire/connections.go |
| +++ b/internal/wire/connections.go |
| @@ -94,6 +94,9 @@ type ConnectPrompt struct { |
| Code string `json:"code"` |
| Attempt int64 `json:"attempt,omitempty"` |
| WrongCode bool `json:"wrong_code,omitempty"` |
| + // Models are the models the provider listed for a pasted API key, |
| + // that Equipo can price (PromptModel): the person picks one. |
| + Models []string `json:"models,omitempty"` |
| } |
| // Connection is GET /api/v1/connections/{id}: one of the person's own |
| @@ -119,6 +122,21 @@ type Connection struct { |
| // date is an estimate (neither the token nor the CLI says it). |
| ExpiresAt *time.Time `json:"expires_at"` |
| ExpiresEstimated bool `json:"expires_estimated"` |
| + // An API-key connection (KindAPIKey, ProtocolMetered): its harness, |
| + // its provider's origin, how it is billed, its one model, when the |
| + // person confirmed the provider-side limit and, for a subscription |
| + // that can bill overflow, that pay-as-you-go is off; its soft budget |
| + // and spend as the runner holds them, and BudgetPending while a |
| + // budget change waits for the runner to apply it. |
| + Harness string `json:"harness,omitempty"` |
| + Upstream string `json:"upstream,omitempty"` |
| + Billing string `json:"billing,omitempty"` |
| + Model string `json:"model,omitempty"` |
| + LimitConfirmedAt *time.Time `json:"limit_confirmed_at,omitempty"` |
| + PaygOffConfirmedAt *time.Time `json:"payg_off_confirmed_at,omitempty"` |
| + Budget *Budget `json:"budget,omitempty"` |
| + Spend *Spend `json:"spend,omitempty"` |
| + BudgetPending bool `json:"budget_pending,omitempty"` |
| } |
| // ConnectionList is GET /api/v1/connections: the person's own, every runner. |
| @@ -135,6 +153,13 @@ type Connect struct { |
| Kind string `json:"kind"` |
| RunnerID string `json:"runner_id"` |
| SameMachine bool `json:"same_machine"` |
| + // An API-key connection (KindAPIKey) needs LimitConfirmed when it is |
| + // metered, and may carry PaygOffConfirmed only for a subscription |
| + // that can bill overflow (APIKeyProvider.CheckConfirmations). Budget |
| + // is a metered connection's day and month figures, both required. |
| + LimitConfirmed bool `json:"limit_confirmed,omitempty"` |
| + PaygOffConfirmed bool `json:"payg_off_confirmed,omitempty"` |
| + Budget *Budget `json:"budget,omitempty"` |
| } |
| // Frames for connections. |
| @@ -199,6 +224,10 @@ type ConnectCommand struct { |
| Provider string `json:"provider"` |
| Kind string `json:"kind"` |
| SameMachine bool `json:"same_machine"` |
| + // Billing and Budget come with an API-key connection |
| + // (ProtocolMetered; Encode refuses the frame below it). |
| + Billing string `json:"billing,omitempty"` |
| + Budget *Budget `json:"budget,omitempty"` |
| } |
| // CancelConnectCommand ends an attempt the person cancelled. |
| @@ -238,6 +267,14 @@ type HeldConnection struct { |
| // ExpiresEstimated says the date is an estimate. |
| ExpiresAt *time.Time `json:"expires_at,omitempty"` |
| ExpiresEstimated bool `json:"expires_estimated,omitempty"` |
| + // An API-key connection's facts (ProtocolMetered): Encode drops the |
| + // connection itself below it. |
| + Harness string `json:"harness,omitempty"` |
| + Upstream string `json:"upstream,omitempty"` |
| + Billing string `json:"billing,omitempty"` |
| + Model string `json:"model,omitempty"` |
| + Budget *Budget `json:"budget,omitempty"` |
| + Spend *Spend `json:"spend,omitempty"` |
| } |
| // Switched is the quiet line under a reply (or on a step) that moved to |
diff --git a/internal/wire/connections_test.go b/internal/wire/connections_test.go| index 8b58e624..75c9de5d 100644 |
| --- a/internal/wire/connections_test.go |
| +++ b/internal/wire/connections_test.go |
| @@ -38,7 +38,7 @@ func fieldNames(t reflect.Type, seen map[reflect.Type]bool, out *[]string) { |
| func TestConnectionTypesCarryNoSecrets(t *testing.T) { |
| var names []string |
| seen := map[reflect.Type]bool{} |
| - for _, v := range []any{wire.Connection{}, wire.ConnectionList{}, wire.Connect{}, wire.ConnectCommand{}, wire.CancelConnectCommand{}, wire.ConnectionReport{}, wire.Hello{}, wire.Reply{}, wire.TurnReport{}, wire.Snapshot{}, wire.StepReport{}, wire.AnswerReport{}, wire.UsageReport{}, wire.DisconnectCommand{}, wire.Sync{}} { |
| + for _, v := range []any{wire.Connection{}, wire.ConnectionList{}, wire.Connect{}, wire.ConnectCommand{}, wire.CancelConnectCommand{}, wire.ConnectionReport{}, wire.Hello{}, wire.Reply{}, wire.TurnReport{}, wire.Snapshot{}, wire.StepReport{}, wire.AnswerReport{}, wire.UsageReport{}, wire.DisconnectCommand{}, wire.Sync{}, wire.ModelCommand{}, wire.BudgetCommand{}, wire.ResumeSpendCommand{}, wire.SetBudget{}, wire.ResumeSpend{}, wire.ChooseModel{}, wire.Budget{}, wire.Spend{}} { |
| fieldNames(reflect.TypeOf(v), seen, &names) |
| } |
| // seal_key is the runner's public key (spec §2.4): public by design. |
| @@ -64,9 +64,11 @@ func TestConnectionTypesCarryNoSecrets(t *testing.T) { |
| // TestConnectionFixturesCarryNoSecrets: the recorded documents a native |
| // app replays hold no secret-shaped key either. |
| func TestConnectionFixturesCarryNoSecrets(t *testing.T) { |
| - for _, name := range []string{"api/connections.json", "api/connection-connecting-codex.json", "api/connection-signing-in-claude.json", "api/connect-request.json", "api/event-connection.json", "frames/connect.json", "frames/cancel_connect.json", "frames/connection.json", "frames/hello.json", "frames/reply-usage.json", "frames/usage.json", "frames/disconnect.json", "frames/sync.json", "frames/preference.json", "api/preferences.json", "api/event-preference.json"} { |
| - // seal_key is public (spec §2.4). |
| + for _, name := range []string{"api/connections.json", "api/connection-connecting-codex.json", "api/connection-signing-in-claude.json", "api/connect-request.json", "api/event-connection.json", "frames/connect.json", "frames/cancel_connect.json", "frames/connection.json", "frames/hello.json", "frames/reply-usage.json", "frames/usage.json", "frames/disconnect.json", "frames/sync.json", "frames/preference.json", "api/preferences.json", "api/event-preference.json", "api/connection-metered.json", "api/connection-choose-model.json", "api/connect-request-api-key.json", "api/budget.json", "api/resume-request.json", "api/model-request.json", "frames/budget.json", "frames/model.json", "frames/resume_spend.json", "frames/connect-api-key.json", "frames/usage-probe.json", "frames/hello-metered.json"} { |
| + // seal_key is public (spec §2.4); api_key is a connection's kind |
| + // and its card's, never a field (connectors spec §10). |
| raw := strings.ReplaceAll(strings.ToLower(string(wiretest.Fixture(name))), `"seal_key"`, "") |
| + raw = strings.ReplaceAll(raw, `"kind":"api_key"`, `"kind":""`) |
| for _, bad := range []string{"token\"", "secret", "credential", "password", "sealed", "_key", "api_key", "access_token", "refresh"} { |
| if strings.Contains(raw, bad) { |
| t.Errorf("%s contains %q", name, bad) |
| @@ -121,3 +123,44 @@ func TestSealedOnlyTowardTheRunner(t *testing.T) { |
| } |
| } |
| } |
| + |
| +// TestMeteredConfirmations is §2.1's add-connection rule: a metered |
| +// connection needs the provider-side limit confirmed; pay-as-you-go off |
| +// makes an overflow subscription a subscription and means nothing for a |
| +// provider billed per token. |
| +func TestMeteredConfirmations(t *testing.T) { |
| + tensorx := wire.APIKeyProviders[wire.ProviderTensorX] |
| + plan := wire.APIKeyProvider{Name: "Plan", Harness: "fake", Upstream: "https://plan.example.com", Endpoint: "https://plan.example.com:443", Overflow: true, Currency: "USD"} |
| + for _, c := range []struct { |
| + p wire.APIKeyProvider |
| + limit, paygOff bool |
| + ok bool |
| + billing string |
| + }{ |
| + {tensorx, false, false, false, wire.BillingMetered}, |
| + {tensorx, true, false, true, wire.BillingMetered}, |
| + {tensorx, true, true, false, wire.BillingMetered}, |
| + {plan, false, false, false, wire.BillingMetered}, |
| + {plan, true, false, true, wire.BillingMetered}, |
| + {plan, false, true, true, wire.BillingSubscription}, |
| + {plan, true, true, true, wire.BillingSubscription}, |
| + } { |
| + if err := c.p.CheckConfirmations(c.limit, c.paygOff); (err == nil) != c.ok { |
| + t.Fatalf("%s limit=%v payg_off=%v: %v", c.p.Name, c.limit, c.paygOff, err) |
| + } |
| + if got := c.p.Billing(c.paygOff); got != c.billing { |
| + t.Fatalf("%s payg_off=%v billed %s", c.p.Name, c.paygOff, got) |
| + } |
| + } |
| + if tensorx.Upstream != "https://api.tensorx.ai" || tensorx.Endpoint != "https://api.tensorx.ai:443" || tensorx.Harness != wire.HarnessPi || !tensorx.PerToken { |
| + t.Fatalf("tensorx %+v", tensorx) |
| + } |
| + for _, b := range []wire.Budget{{Day: 0, Month: 1}, {Day: 2, Month: 1}, {Day: 1, Month: wire.MaxBudgetMonth + 1}, {Day: -1, Month: 5}} { |
| + if wire.ValidBudget(b) { |
| + t.Fatalf("budget %+v accepted", b) |
| + } |
| + } |
| + if !wire.ValidBudget(wire.Budget{Day: wire.DefaultBudgetDay, Month: wire.DefaultBudgetMonth}) { |
| + t.Fatal("the default budget is refused") |
| + } |
| +} |
diff --git a/internal/wire/frames.go b/internal/wire/frames.go| index 7944ff6d..07c0f7ec 100644 |
| --- a/internal/wire/frames.go |
| +++ b/internal/wire/frames.go |
| @@ -60,7 +60,7 @@ type Frame struct { |
| // Durable reports whether a frame must be acked and resent until acked. |
| func (f Frame) Durable() bool { |
| switch f.Type { |
| - case FrameMessage, FrameAttachment, FrameCancel, FrameReply, FrameTurn, FrameToolCall, FrameToolResult, FrameMoveIn, FrameNotebook, FrameReset, FrameDispatch, FrameCancelStep, FrameStep, FrameRecheck, FrameWatchMerge, FrameMerged, FrameAsk, FrameCancelAsk, FrameAnswer, FrameForgetTask, FrameBranch, FrameBlob, FrameSendPack, FramePublish, FramePublished, FrameConnect, FrameCancelConnect, FrameConnection, FrameUsage, FrameDisconnect, FramePreference, FrameSecret, FrameCheck: |
| + case FrameMessage, FrameAttachment, FrameCancel, FrameReply, FrameTurn, FrameToolCall, FrameToolResult, FrameMoveIn, FrameNotebook, FrameReset, FrameDispatch, FrameCancelStep, FrameStep, FrameRecheck, FrameWatchMerge, FrameMerged, FrameAsk, FrameCancelAsk, FrameAnswer, FrameForgetTask, FrameBranch, FrameBlob, FrameSendPack, FramePublish, FramePublished, FrameConnect, FrameCancelConnect, FrameConnection, FrameUsage, FrameDisconnect, FramePreference, FrameSecret, FrameCheck, FrameModel, FrameBudget, FrameResumeSpend: |
| return true |
| } |
| return false |
| @@ -153,6 +153,12 @@ func (f Frame) Decode() (any, error) { |
| v = &SecretCommand{} |
| case FrameCheck: |
| v = &CheckCommand{} |
| + case FrameModel: |
| + v = &ModelCommand{} |
| + case FrameBudget: |
| + v = &BudgetCommand{} |
| + case FrameResumeSpend: |
| + v = &ResumeSpendCommand{} |
| case FrameStepActivity: |
| v = &StepActivityReport{} |
| case FrameBlob: |
| @@ -438,6 +444,14 @@ type Usage struct { |
| // it did not say. A multi-model attempt carries it on one row only. |
| // Protocol 3: never sent to an older instance (Encode). |
| Turns *int64 `json:"turns,omitempty"` |
| + // A metered connection's charge (ProtocolMetered, connectors spec |
| + // §2.3): the cost the runner priced from its table (null when it |
| + // cannot price the row), the table's currency and version, and the |
| + // cost the harness reported itself (null when it reported none). |
| + CostMicros *int64 `json:"cost_micros,omitempty"` |
| + Currency string `json:"currency,omitempty"` |
| + PriceVersion string `json:"price_version,omitempty"` |
| + CostReportedMicros *int64 `json:"cost_reported_micros,omitempty"` |
| } |
| // Usage outcomes: how the attempt the row belongs to ended. |
| @@ -450,8 +464,9 @@ const ( |
| // FrameUsage (runner to instance, durable) carries the usage rows of |
| // attempts that produced no reply (failed, cancelled, refused before a |
| -// failover), and of a token connection's health check. Exactly one of |
| -// TurnID, StepID, QuestionID or CheckID is set. |
| +// failover), of a token connection's health check and of a metered |
| +// connection's probe. Exactly one of TurnID, StepID, QuestionID, CheckID |
| +// or ProbeID is set. |
| const FrameUsage = "usage" |
| // UsageReport is a usage frame. |
| @@ -461,7 +476,11 @@ type UsageReport struct { |
| QuestionID string `json:"question_id"` |
| // CheckID names one health check of a token connection: a minimal |
| // real request whose usage counts like any other (absent otherwise). |
| - CheckID string `json:"check_id,omitempty"` |
| + CheckID string `json:"check_id,omitempty"` |
| + // ProbeID names one health probe of a metered connection: a |
| + // one-token completion on its model, charged to its budget like any |
| + // other (ProtocolMetered; below it, a check). |
| + ProbeID string `json:"probe_id,omitempty"` |
| Rows []Usage `json:"rows"` |
| } |
diff --git a/internal/wire/metered.go b/internal/wire/metered.go| new file mode 100644 |
| index 00000000..2a9ba0de |
| --- /dev/null |
| +++ b/internal/wire/metered.go |
| @@ -0,0 +1,197 @@ |
| +package wire |
| + |
| +import "errors" |
| + |
| +// Metered connections (connectors spec 2026-11-12, §§2.1 to 2.3, §10, |
| +// slice S1). A connection made from a provider API key the person pastes, |
| +// sealed in the page to the runner as a Claude token is (KindAPIKey). |
| +// The provider's own limit is the only hard cap; Equipo keeps a soft |
| +// budget from the usage the harness reported, and a metered connection |
| +// runs one attempt at a time. Nothing here is a secret: the key stays on |
| +// the runner, in the connection's home. |
| + |
| +// KindAPIKey is a connection made from a pasted provider API key. |
| +// PromptAPIKey is its card (paste the key); PromptModel the card that |
| +// follows once the runner has the key and has read the provider's model |
| +// list: the person picks the connection's one model (Models). |
| +const ( |
| + KindAPIKey = "api_key" |
| + PromptAPIKey = "api_key" |
| + PromptModel = "model" |
| +) |
| + |
| +// Billing says how a connection is paid for (§2.1): a subscription, or |
| +// metered (billed per token, or a subscription that can bill overflow |
| +// with pay-as-you-go not confirmed off). |
| +const ( |
| + BillingSubscription = "subscription" |
| + BillingMetered = "metered" |
| +) |
| + |
| +// Harnesses and providers of API-key connections. S1 adds TensorX with |
| +// Pi as its harness (§0 decision 1); later slices add rows. |
| +const ( |
| + HarnessPi = "pi" |
| + ProviderTensorX = "tensorx" |
| +) |
| + |
| +// APIKeyProvider is one provider an API-key connection may be made for: |
| +// its harness, its origin (Upstream, the only host its connection may |
| +// reach) and what a sealed key is bound to (Endpoint). PerToken: billed |
| +// per token, always metered. Overflow: a subscription that can bill |
| +// overflow, metered unless the person confirms a standing setting turns |
| +// overflow off (§0 decision 7). Currency is its price table's. |
| +type APIKeyProvider struct { |
| + Name string |
| + Harness string |
| + Upstream string |
| + Endpoint string |
| + PerToken bool |
| + Overflow bool |
| + Currency string |
| +} |
| + |
| +// APIKeyProviders are the providers an API key connects, by name. |
| +var APIKeyProviders = map[string]APIKeyProvider{ |
| + ProviderTensorX: {Name: "TensorX", Harness: HarnessPi, Upstream: "https://api.tensorx.ai", Endpoint: "https://api.tensorx.ai:443", PerToken: true, Currency: "USD"}, |
| +} |
| + |
| +// Billing is how a new connection for p is billed, given the person's |
| +// pay-as-you-go confirmation: metered unless p is an overflow |
| +// subscription confirmed off. |
| +func (p APIKeyProvider) Billing(paygOff bool) string { |
| + if !p.PerToken && p.Overflow && paygOff { |
| + return BillingSubscription |
| + } |
| + return BillingMetered |
| +} |
| + |
| +// ErrConfirmation refuses an API-key connection without the |
| +// confirmations its billing needs (§2.1). |
| +var ErrConfirmation = errors.New("wire: the connection needs its confirmations") |
| + |
| +// CheckConfirmations is the add-connection rule (§2.1, §0 decisions 3 |
| +// and 7): a metered connection needs the provider-side limit confirmed; |
| +// a pay-as-you-go confirmation only means something for a subscription |
| +// that can bill overflow, so it is refused for any other. |
| +func (p APIKeyProvider) CheckConfirmations(limit, paygOff bool) error { |
| + if paygOff && (p.PerToken || !p.Overflow) { |
| + return ErrConfirmation |
| + } |
| + if p.Billing(paygOff) == BillingMetered && !limit { |
| + return ErrConfirmation |
| + } |
| + return nil |
| +} |
| + |
| +// Budget is a metered connection's soft budget (§2.3): a day's and a |
| +// month's figure in micro-units of Currency, the price table's. Revision |
| +// orders changes: the runner applies a budget frame only above the |
| +// revision it holds. |
| +type Budget struct { |
| + Day int64 `json:"day"` |
| + Month int64 `json:"month"` |
| + Currency string `json:"currency"` |
| + Revision int64 `json:"revision"` |
| +} |
| + |
| +// Budget bounds: at most a thousand units a day and ten thousand a month |
| +// (well past any soft budget a person sets), never zero or negative. |
| +const ( |
| + MaxBudgetDay = 1000 * 1_000_000 |
| + MaxBudgetMonth = 10000 * 1_000_000 |
| + // DefaultBudgetDay and DefaultBudgetMonth pre-fill the form (§0 |
| + // decision 4): 1 and 10 in the price table's currency. |
| + DefaultBudgetDay = 1_000_000 |
| + DefaultBudgetMonth = 10_000_000 |
| +) |
| + |
| +// ValidBudget reports whether b's figures are in bounds. |
| +func ValidBudget(b Budget) bool { |
| + return b.Day > 0 && b.Month > 0 && b.Day <= MaxBudgetDay && b.Month <= MaxBudgetMonth && b.Day <= b.Month && b.Revision >= 0 |
| +} |
| + |
| +// Spend is what the runner holds a metered connection has spent, from |
| +// reported usage priced by its table (§2.3): today's and this month's |
| +// charges in micro-units of Currency (UTC days until a zone is known). |
| +// Unknown: an attempt ended without a complete, priced figure, and |
| +// nothing more is admitted until the person resumes with PauseRevision. |
| +// Running: an attempt holds the connection's one slot now. |
| +type Spend struct { |
| + Day int64 `json:"day"` |
| + Month int64 `json:"month"` |
| + Currency string `json:"currency"` |
| + Unknown bool `json:"unknown"` |
| + PauseRevision int64 `json:"pause_revision"` |
| + Running bool `json:"running"` |
| +} |
| + |
| +// Frames for metered connections (instance to runner, durable). Each is |
| +// refused below ProtocolMetered: an older runner never holds a metered |
| +// connection. |
| +const ( |
| + // FrameModel is the person's pick of a connecting API-key |
| + // connection's one model, from the list the runner read. |
| + FrameModel = "model" |
| + // FrameBudget changes a metered connection's budget; acked once the |
| + // runner applied it (until then the page says it is pending). |
| + FrameBudget = "budget" |
| + // FrameResumeSpend is the person's Resume of a connection paused |
| + // with its spend unknown, bound to the pause it saw. |
| + FrameResumeSpend = "resume_spend" |
| +) |
| + |
| +// ModelCommand picks the model of the person's connecting connection. |
| +type ModelCommand struct { |
| + Connection string `json:"connection"` |
| + Person string `json:"person"` |
| + Model string `json:"model"` |
| +} |
| + |
| +// BudgetCommand sets a metered connection's budget. |
| +type BudgetCommand struct { |
| + Connection string `json:"connection"` |
| + Person string `json:"person"` |
| + LocalID string `json:"local_id"` |
| + Budget Budget `json:"budget"` |
| +} |
| + |
| +// ResumeSpendCommand resumes a connection whose spend is unknown. The |
| +// runner consumes it once, and only while PauseRevision is still the |
| +// connection's pause: a stale or repeated Resume leaves a newer pause. |
| +type ResumeSpendCommand struct { |
| + Connection string `json:"connection"` |
| + Person string `json:"person"` |
| + LocalID string `json:"local_id"` |
| + PauseRevision int64 `json:"pause_revision"` |
| +} |
| + |
| +// SetBudget is PUT /api/v1/connections/{id}/budget: the day's and the |
| +// month's figures (micro-units of the connection's currency) against |
| +// the budget revision the person saw. |
| +type SetBudget struct { |
| + Day int64 `json:"day"` |
| + Month int64 `json:"month"` |
| + Revision int64 `json:"revision"` |
| +} |
| + |
| +// ResumeSpend is POST /api/v1/connections/{id}/resume. |
| +type ResumeSpend struct { |
| + PauseRevision int64 `json:"pause_revision"` |
| +} |
| + |
| +// ChooseModel is POST /api/v1/connections/{id}/model: the connecting |
| +// card's pick. |
| +type ChooseModel struct { |
| + Model string `json:"model"` |
| +} |
| + |
| +// MaxModels bounds a model list on a card; MaxModelName one model id. |
| +const ( |
| + MaxModels = 200 |
| + MaxModelName = 200 |
| +) |
| + |
| +// UsageProbe is the role of a usage row from a metered connection's |
| +// health probe: one billable token on the selected model (§2.2). |
| +const UsageProbe = "probe" |
diff --git a/internal/wire/runners.go b/internal/wire/runners.go| index a2f22ab3..7e266324 100644 |
| --- a/internal/wire/runners.go |
| +++ b/internal/wire/runners.go |
| @@ -37,6 +37,7 @@ const ( |
| Protocol9 = 9 |
| Protocol10 = 10 |
| Protocol11 = 11 |
| + Protocol12 = 12 |
| // ProtocolSpend is the first protocol with a fix round's Feedback and |
| // a usage row's Turns; Encode drops both below it. |
| ProtocolSpend = Protocol3 |
| @@ -79,7 +80,15 @@ const ( |
| // preview host the runner is paired with (Capabilities.PreviewHost). |
| // Encode drops it below; the previews flag stays. |
| ProtocolPreviewHost = Protocol11 |
| - ProtocolCurrent = ProtocolPreviewHost |
| + // ProtocolMetered is the first protocol with metered connections |
| + // (connectors spec 2026-11-12, S1): API-key connections and their |
| + // facts in hello and sync, a usage row's cost, the probe's usage, and |
| + // the model, budget and resume_spend frames. Encode drops an API-key |
| + // connection and the cost fields below it, says a probe's usage as a |
| + // check, and refuses the new frames and an API-key connect: an older |
| + // runner is refused metered connections rather than downgraded. |
| + ProtocolMetered = Protocol12 |
| + ProtocolCurrent = ProtocolMetered |
| ) |
| // Runner roles. A person's first runner is the primary: the coordinator, |
| @@ -464,8 +473,17 @@ func Encode(f Frame, protocol int) (Frame, error) { |
| return Frame{}, err |
| } |
| changed := false |
| + if protocol < ProtocolMetered { |
| + if meteredOnly[f.Type] { |
| + return Frame{}, fmt.Errorf("%w: %s at protocol %d", ErrProtocol, f.Type, protocol) |
| + } |
| + if c, ok := body.(*ConnectCommand); ok && c.Kind == KindAPIKey { |
| + return Frame{}, fmt.Errorf("%w: an API-key connection at protocol %d", ErrProtocol, protocol) |
| + } |
| + changed = downgradeMetered(body) |
| + } |
| if h, ok := body.(*Hello); ok && protocol < ProtocolPreviewHost { |
| - changed = WithoutPreviewHost(h) |
| + changed = WithoutPreviewHost(h) || changed |
| } |
| if protocol < ProtocolExplore { |
| changed = downgradeExplore(body) || changed |
| @@ -508,6 +526,61 @@ func Encode(f Frame, protocol int) (Frame, error) { |
| return f, nil |
| } |
| +// meteredOnly are the frame types below ProtocolMetered never carries. |
| +var meteredOnly = map[string]bool{FrameModel: true, FrameBudget: true, FrameResumeSpend: true} |
| + |
| +// downgradeMetered clears a body's ProtocolMetered fields: API-key |
| +// connections leave hello and sync (an older instance knows none), a |
| +// usage row's cost goes, and a probe's usage is said as a check. It |
| +// reports whether anything changed. |
| +func downgradeMetered(body any) bool { |
| + held := func(cs *[]HeldConnection) bool { |
| + if !slices.ContainsFunc(*cs, func(h HeldConnection) bool { return h.Kind == KindAPIKey || h.Billing != "" }) { |
| + return false |
| + } |
| + *cs = slices.DeleteFunc(slices.Clone(*cs), func(h HeldConnection) bool { return h.Kind == KindAPIKey || h.Billing != "" }) |
| + return true |
| + } |
| + cost := func(rows []Usage) bool { |
| + set := false |
| + for i := range rows { |
| + u := &rows[i] |
| + set = set || u.CostMicros != nil || u.Currency != "" || u.PriceVersion != "" || u.CostReportedMicros != nil |
| + u.CostMicros, u.Currency, u.PriceVersion, u.CostReportedMicros = nil, "", "", nil |
| + } |
| + return set |
| + } |
| + switch v := body.(type) { |
| + case *Hello: |
| + return held(&v.Connections) |
| + case *Sync: |
| + return held(&v.Connections) |
| + case *ConnectionReport: |
| + if v.Prompt == nil || v.Prompt.Models == nil { |
| + return false |
| + } |
| + v.Prompt.Models = nil |
| + return true |
| + case *ConnectCommand: |
| + set := v.Billing != "" || v.Budget != nil |
| + v.Billing, v.Budget = "", nil |
| + return set |
| + case *UsageReport: |
| + set := cost(v.Rows) |
| + if v.ProbeID != "" { |
| + v.CheckID, v.ProbeID, set = v.ProbeID, "", true |
| + } |
| + return set |
| + case *StepReport: |
| + return cost(v.Usage) |
| + case *AnswerReport: |
| + return cost(v.Usage) |
| + case *Reply: |
| + return cost(v.Usage) |
| + } |
| + return false |
| +} |
| + |
| // downgradeSandboxConsent clears a dispatch's consent to run outside the |
| // sandbox (an older peer never carries one), and says a worker's refusal |
| // to run unproven as placement_refused, which an older instance knows: |
diff --git a/internal/wire/runners_test.go b/internal/wire/runners_test.go| index d3743a03..425760d0 100644 |
| --- a/internal/wire/runners_test.go |
| +++ b/internal/wire/runners_test.go |
| @@ -412,7 +412,7 @@ func TestEncodeBelowProtocol9DropsPreviews(t *testing.T) { |
| if _, err := wire.Encode(d, wire.ProtocolPreview); err != nil { |
| t.Fatal(err) |
| } |
| - if wire.ProtocolCurrent != wire.ProtocolPreviewHost || wire.ProtocolPreviewHost != 11 || wire.ProtocolExplore != 10 || wire.ProtocolPreview != 9 { |
| + if wire.ProtocolCurrent != wire.ProtocolMetered || wire.ProtocolPreviewHost != 11 || wire.ProtocolExplore != 10 || wire.ProtocolPreview != 9 { |
| t.Fatalf("current %d", wire.ProtocolCurrent) |
| } |
| } |
| @@ -599,3 +599,79 @@ func TestEncodeBelowProtocol11DropsPreviewHost(t *testing.T) { |
| t.Fatal("a preview host without previews on is valid") |
| } |
| } |
| + |
| +// Protocol 12 adds metered connections (connectors spec S1, §10). An |
| +// older peer never sees one: below 12 the API-key connections leave |
| +// hello and sync, a usage row's cost goes, a probe's usage is said as a |
| +// check, and the model, budget and resume_spend frames and an API-key |
| +// connect are refused, so an older runner is refused metered |
| +// connections rather than downgraded. |
| +func TestEncodeBelowProtocol12DropsMetered(t *testing.T) { |
| + claude := wire.HeldConnection{LocalID: "claude-a", Person: "p", Provider: wire.ProviderClaude, Kind: wire.KindSubscription, State: wire.ConnHealthy} |
| + metered := wire.HeldConnection{LocalID: "tensorx-1", Person: "p", Provider: wire.ProviderTensorX, Kind: wire.KindAPIKey, State: wire.ConnHealthy, Harness: wire.HarnessPi, Upstream: "https://api.tensorx.ai", Billing: wire.BillingMetered, Model: "z-ai/glm-5.3", Budget: &wire.Budget{Day: 1, Month: 2, Currency: "USD"}, Spend: &wire.Spend{Currency: "USD"}} |
| + cost, n := int64(21), int64(9) |
| + row := wire.Usage{Provider: wire.ProviderTensorX, Connection: "tensorx-1", Model: "z-ai/glm-5.3", Attempt: 1, Outcome: wire.OutcomeReplied, Complete: true, InputTokens: &n} |
| + priced := row |
| + priced.CostMicros, priced.Currency, priced.PriceVersion, priced.CostReportedMicros = &cost, "USD", "tensorx-2026-11-12", &cost |
| + for _, c := range []struct { |
| + kind string |
| + new, prev any |
| + decode any |
| + }{ |
| + {wire.FrameHello, wire.Hello{Repos: []string{}, Connections: []wire.HeldConnection{claude, metered}}, wire.Hello{Repos: []string{}, Connections: []wire.HeldConnection{claude}}, &wire.Hello{}}, |
| + {wire.FrameSync, wire.Sync{Connections: []wire.HeldConnection{metered, claude}}, wire.Sync{Connections: []wire.HeldConnection{claude}}, &wire.Sync{}}, |
| + {wire.FrameUsage, wire.UsageReport{ProbeID: "pr_1", Rows: []wire.Usage{priced}}, wire.UsageReport{CheckID: "pr_1", Rows: []wire.Usage{row}}, &wire.UsageReport{}}, |
| + {wire.FrameStep, wire.StepReport{TaskID: "tk", Findings: []wire.Finding{}, Usage: []wire.Usage{priced}}, wire.StepReport{TaskID: "tk", Findings: []wire.Finding{}, Usage: []wire.Usage{row}}, &wire.StepReport{}}, |
| + {wire.FrameAnswer, wire.AnswerReport{QuestionID: "q", Usage: []wire.Usage{priced}}, wire.AnswerReport{QuestionID: "q", Usage: []wire.Usage{row}}, &wire.AnswerReport{}}, |
| + {wire.FrameConnection, wire.ConnectionReport{Connection: "cn", State: wire.ConnConnecting, Prompt: &wire.ConnectPrompt{Kind: wire.PromptModel, Models: []string{"z-ai/glm-5.3"}}}, wire.ConnectionReport{Connection: "cn", State: wire.ConnConnecting, Prompt: &wire.ConnectPrompt{Kind: wire.PromptModel}}, &wire.ConnectionReport{}}, |
| + } { |
| + f, err := wire.NewFrame("f1", c.kind, c.new) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if same, err := wire.Encode(f, wire.ProtocolMetered); err != nil || !bytes.Equal(same.Data, f.Data) { |
| + t.Fatalf("%s changed at protocol 12: %v", c.kind, err) |
| + } |
| + want, _ := wire.NewFrame("f1", c.kind, c.prev) |
| + for _, p := range []int{wire.ProtocolPreviewHost, wire.ProtocolPreview, wire.ProtocolSpend + 1} { |
| + old, err := wire.Encode(f, p) |
| + if err != nil || !bytes.Equal(old.Data, want.Data) { |
| + t.Fatalf("%s at protocol %d: %v\n got %s\nwant %s", c.kind, p, err, old.Data, want.Data) |
| + } |
| + if err := wire.Strict(old.Data, c.decode); err != nil { |
| + t.Fatalf("%s at protocol %d does not decode: %v", c.kind, p, err) |
| + } |
| + if strings.Contains(string(old.Data), "cost") || strings.Contains(string(old.Data), "api_key") || strings.Contains(string(old.Data), "probe") || strings.Contains(string(old.Data), "models") { |
| + t.Fatalf("%s at protocol %d still carries metered fields: %s", c.kind, p, old.Data) |
| + } |
| + } |
| + } |
| + refused := []wire.Frame{} |
| + for kind, body := range map[string]any{ |
| + wire.FrameModel: wire.ModelCommand{Connection: "cn", Person: "p", Model: "m"}, |
| + wire.FrameBudget: wire.BudgetCommand{Connection: "cn", Person: "p", LocalID: "tensorx-1", Budget: wire.Budget{Day: 1, Month: 2}}, |
| + wire.FrameResumeSpend: wire.ResumeSpendCommand{Connection: "cn", Person: "p", LocalID: "tensorx-1", PauseRevision: 1}, |
| + wire.FrameConnect: wire.ConnectCommand{Connection: "cn", Person: "p", Provider: wire.ProviderTensorX, Kind: wire.KindAPIKey, Billing: wire.BillingMetered}, |
| + } { |
| + f, _ := wire.NewFrame("f-"+kind, kind, body) |
| + refused = append(refused, f) |
| + } |
| + for _, f := range refused { |
| + if _, err := wire.Encode(f, wire.ProtocolMetered); err != nil { |
| + t.Fatalf("%s refused at 12: %v", f.Type, err) |
| + } |
| + for _, p := range []int{wire.ProtocolPreviewHost, wire.Protocol2, wire.Protocol1} { |
| + if _, err := wire.Encode(f, p); !errors.Is(err, wire.ErrProtocol) { |
| + t.Fatalf("%s encoded at protocol %d: %v", f.Type, p, err) |
| + } |
| + } |
| + } |
| + // A subscription connect is the old frame, unchanged. |
| + sub, _ := wire.NewFrame("f2", wire.FrameConnect, wire.ConnectCommand{Connection: "cn", Person: "p", Provider: wire.ProviderCodex, Kind: wire.KindSubscription}) |
| + if old, err := wire.Encode(sub, wire.ProtocolPreviewHost); err != nil || !bytes.Equal(old.Data, sub.Data) { |
| + t.Fatalf("a subscription connect changed: %v", err) |
| + } |
| + if wire.ProtocolMetered != 12 || wire.ProtocolCurrent != wire.ProtocolMetered || wire.Spoken(wire.ProtocolPreviewHost) != wire.ProtocolPreviewHost || wire.Spoken(99) != wire.ProtocolMetered { |
| + t.Fatalf("current %d", wire.ProtocolCurrent) |
| + } |
| +} |
diff --git a/internal/wire/wire_test.go b/internal/wire/wire_test.go| index ab0a02ef..dda9d39a 100644 |
| --- a/internal/wire/wire_test.go |
| +++ b/internal/wire/wire_test.go |
| @@ -33,7 +33,7 @@ func TestFrameFixturesRoundTrip(t *testing.T) { |
| t.Fatalf("%s: round trip\n got %s\nwant %s", name, out, raw) |
| } |
| } |
| - for _, kind := range []string{wire.FrameWelcome, wire.FrameMessage, wire.FrameAttachment, wire.FrameCancel, wire.FrameDrain, wire.FrameAck, wire.FrameHello, wire.FrameSync, wire.FrameDelta, wire.FrameReply, wire.FrameTurn, wire.FrameLease, wire.FrameToolCall, wire.FrameToolResult, wire.FrameActivity, wire.FrameMoveIn, wire.FrameNotebook, wire.FrameReset, wire.FrameDispatch, wire.FrameCancelStep, wire.FrameStep, wire.FrameRecheck, wire.FrameWatchMerge, wire.FrameMerged, wire.FrameAsk, wire.FrameCancelAsk, wire.FrameAnswer, wire.FrameForgetTask, wire.FrameBranch, wire.FrameConnect, wire.FrameCancelConnect, wire.FrameConnection, wire.FrameUsage, wire.FrameDisconnect, wire.FrameStepActivity, wire.FramePreference, wire.FrameBlob, wire.FrameSendPack, wire.FramePublish, wire.FramePublished, wire.FrameRefused} { |
| + for _, kind := range []string{wire.FrameWelcome, wire.FrameMessage, wire.FrameAttachment, wire.FrameCancel, wire.FrameDrain, wire.FrameAck, wire.FrameHello, wire.FrameSync, wire.FrameDelta, wire.FrameReply, wire.FrameTurn, wire.FrameLease, wire.FrameToolCall, wire.FrameToolResult, wire.FrameActivity, wire.FrameMoveIn, wire.FrameNotebook, wire.FrameReset, wire.FrameDispatch, wire.FrameCancelStep, wire.FrameStep, wire.FrameRecheck, wire.FrameWatchMerge, wire.FrameMerged, wire.FrameAsk, wire.FrameCancelAsk, wire.FrameAnswer, wire.FrameForgetTask, wire.FrameBranch, wire.FrameConnect, wire.FrameCancelConnect, wire.FrameConnection, wire.FrameUsage, wire.FrameDisconnect, wire.FrameStepActivity, wire.FramePreference, wire.FrameBlob, wire.FrameSendPack, wire.FramePublish, wire.FramePublished, wire.FrameRefused, wire.FrameModel, wire.FrameBudget, wire.FrameResumeSpend} { |
| if !seen[kind] { |
| t.Fatalf("no fixture for frame %s", kind) |
| } |
| @@ -73,7 +73,7 @@ func TestParseFrameRefusesUnknownFieldsAndTypes(t *testing.T) { |
| } |
| func TestDurableFrames(t *testing.T) { |
| - for kind, want := range map[string]bool{wire.FrameMessage: true, wire.FrameCancel: true, wire.FrameReply: true, wire.FrameTurn: true, wire.FrameToolCall: true, wire.FrameToolResult: true, wire.FrameActivity: false, wire.FrameDelta: false, wire.FrameHello: false, wire.FrameSync: false, wire.FrameAck: false, wire.FrameWelcome: false, wire.FrameDrain: false, wire.FramePreference: true, wire.FrameSecret: true, wire.FrameCheck: true} { |
| + for kind, want := range map[string]bool{wire.FrameMessage: true, wire.FrameCancel: true, wire.FrameReply: true, wire.FrameTurn: true, wire.FrameToolCall: true, wire.FrameToolResult: true, wire.FrameActivity: false, wire.FrameDelta: false, wire.FrameHello: false, wire.FrameSync: false, wire.FrameAck: false, wire.FrameWelcome: false, wire.FrameDrain: false, wire.FramePreference: true, wire.FrameSecret: true, wire.FrameCheck: true, wire.FrameModel: true, wire.FrameBudget: true, wire.FrameResumeSpend: true} { |
| if (wire.Frame{Type: kind}).Durable() != want { |
| t.Fatalf("%s durable=%v", kind, !want) |
| } |
diff --git a/internal/wire/wiretest/fixtures.go b/internal/wire/wiretest/fixtures.go| index 06a9995a..fd1b22b7 100644 |
| --- a/internal/wire/wiretest/fixtures.go |
| +++ b/internal/wire/wiretest/fixtures.go |
| @@ -99,10 +99,16 @@ func APIType(name string) any { |
| return &wire.AskQuestion{} |
| case "connections.json": |
| return &wire.ConnectionList{} |
| - case "connection-connecting-codex.json", "connection-signing-in-claude.json": |
| + case "connection-connecting-codex.json", "connection-signing-in-claude.json", "connection-metered.json", "connection-choose-model.json": |
| return &wire.Connection{} |
| - case "connect-request.json": |
| + case "connect-request.json", "connect-request-api-key.json": |
| return &wire.Connect{} |
| + case "budget.json": |
| + return &wire.SetBudget{} |
| + case "resume-request.json": |
| + return &wire.ResumeSpend{} |
| + case "model-request.json": |
| + return &wire.ChooseModel{} |
| case "preferences.json": |
| return &wire.Preferences{} |
| case "connection-secret.json", "connection-code.json": |
diff --git a/internal/wire/wiretest/testdata/api/budget.json b/internal/wire/wiretest/testdata/api/budget.json| new file mode 100644 |
| index 00000000..96019332 |
| --- /dev/null |
| +++ b/internal/wire/wiretest/testdata/api/budget.json |
| @@ -0,0 +1 @@ |
| +{"day":2000000,"month":10000000,"revision":1} |
diff --git a/internal/wire/wiretest/testdata/api/connect-request-api-key.json b/internal/wire/wiretest/testdata/api/connect-request-api-key.json| new file mode 100644 |
| index 00000000..98c6c685 |
| --- /dev/null |
| +++ b/internal/wire/wiretest/testdata/api/connect-request-api-key.json |
| @@ -0,0 +1 @@ |
| +{"provider":"tensorx","kind":"api_key","runner_id":"","same_machine":false,"limit_confirmed":true,"budget":{"day":1000000,"month":10000000,"currency":"USD","revision":0}} |
diff --git a/internal/wire/wiretest/testdata/api/connection-choose-model.json b/internal/wire/wiretest/testdata/api/connection-choose-model.json| new file mode 100644 |
| index 00000000..4164e4cb |
| --- /dev/null |
| +++ b/internal/wire/wiretest/testdata/api/connection-choose-model.json |
| @@ -0,0 +1 @@ |
| +{"id":"cn_0004","revision":3,"runner_id":"rn_0001","local_id":"","provider":"tensorx","kind":"api_key","label":"","state":"connecting","reason":"","plan":"","headroom":null,"prompt":{"kind":"model","url":"","code":"","models":["z-ai/glm-5.3","moonshotai/kimi-k3.1-pro"]},"created_at":"2026-11-12T09:00:00Z","updated_at":"2026-11-12T09:00:20Z","expires_at":null,"expires_estimated":false,"harness":"pi","upstream":"https://api.tensorx.ai","billing":"metered","limit_confirmed_at":"2026-11-12T09:00:00Z","budget":{"day":1000000,"month":10000000,"currency":"USD","revision":1}} |
diff --git a/internal/wire/wiretest/testdata/api/connection-metered.json b/internal/wire/wiretest/testdata/api/connection-metered.json| new file mode 100644 |
| index 00000000..cb3bb5f3 |
| --- /dev/null |
| +++ b/internal/wire/wiretest/testdata/api/connection-metered.json |
| @@ -0,0 +1 @@ |
| +{"id":"cn_0004","revision":6,"runner_id":"rn_0001","local_id":"tensorx-1","provider":"tensorx","kind":"api_key","label":"","state":"healthy","reason":"","plan":"","headroom":null,"prompt":null,"created_at":"2026-11-12T09:00:00Z","updated_at":"2026-11-12T10:30:00Z","expires_at":null,"expires_estimated":false,"harness":"pi","upstream":"https://api.tensorx.ai","billing":"metered","model":"z-ai/glm-5.3","limit_confirmed_at":"2026-11-12T09:00:00Z","budget":{"day":1000000,"month":10000000,"currency":"USD","revision":2},"spend":{"day":840000,"month":6200000,"currency":"USD","unknown":false,"pause_revision":0,"running":false},"budget_pending":true} |
diff --git a/internal/wire/wiretest/testdata/api/model-request.json b/internal/wire/wiretest/testdata/api/model-request.json| new file mode 100644 |
| index 00000000..15a87bdc |
| --- /dev/null |
| +++ b/internal/wire/wiretest/testdata/api/model-request.json |
| @@ -0,0 +1 @@ |
| +{"model":"z-ai/glm-5.3"} |
diff --git a/internal/wire/wiretest/testdata/api/resume-request.json b/internal/wire/wiretest/testdata/api/resume-request.json| new file mode 100644 |
| index 00000000..5f3715a5 |
| --- /dev/null |
| +++ b/internal/wire/wiretest/testdata/api/resume-request.json |
| @@ -0,0 +1 @@ |
| +{"pause_revision":3} |
diff --git a/internal/wire/wiretest/testdata/frames/budget.json b/internal/wire/wiretest/testdata/frames/budget.json| new file mode 100644 |
| index 00000000..cd3244a0 |
| --- /dev/null |
| +++ b/internal/wire/wiretest/testdata/frames/budget.json |
| @@ -0,0 +1 @@ |
| +{"id":"c47","type":"budget","data":{"connection":"cn_0004","person":"owner@example.com","local_id":"tensorx-1","budget":{"day":2000000,"month":10000000,"currency":"USD","revision":2}}} |
diff --git a/internal/wire/wiretest/testdata/frames/connect-api-key.json b/internal/wire/wiretest/testdata/frames/connect-api-key.json| new file mode 100644 |
| index 00000000..0b82fedc |
| --- /dev/null |
| +++ b/internal/wire/wiretest/testdata/frames/connect-api-key.json |
| @@ -0,0 +1 @@ |
| +{"id":"c50","type":"connect","data":{"connection":"cn_0004","person":"owner@example.com","provider":"tensorx","kind":"api_key","same_machine":false,"billing":"metered","budget":{"day":1000000,"month":10000000,"currency":"USD","revision":1}}} |
diff --git a/internal/wire/wiretest/testdata/frames/hello-metered.json b/internal/wire/wiretest/testdata/frames/hello-metered.json| new file mode 100644 |
| index 00000000..4a3ed2dd |
| --- /dev/null |
| +++ b/internal/wire/wiretest/testdata/frames/hello-metered.json |
| @@ -0,0 +1 @@ |
| +{"id":"r-hello-3","type":"hello","data":{"generation":3,"repos":[],"create_in":[],"home":"","agent":"equipo-docs-t1","catalog":[],"connections":[{"local_id":"tensorx-1","person":"owner@example.com","provider":"tensorx","kind":"api_key","label":"","state":"healthy","plan":"","headroom":null,"harness":"pi","upstream":"https://api.tensorx.ai","billing":"metered","model":"z-ai/glm-5.3","budget":{"day":1000000,"month":10000000,"currency":"USD","revision":1},"spend":{"day":0,"month":0,"currency":"USD","unknown":true,"pause_revision":3,"running":false}}],"versions":{"runner":"5eae410"},"protocol":12}} |
diff --git a/internal/wire/wiretest/testdata/frames/model.json b/internal/wire/wiretest/testdata/frames/model.json| new file mode 100644 |
| index 00000000..7e62dfe1 |
| --- /dev/null |
| +++ b/internal/wire/wiretest/testdata/frames/model.json |
| @@ -0,0 +1 @@ |
| +{"id":"c48","type":"model","data":{"connection":"cn_0004","person":"owner@example.com","model":"z-ai/glm-5.3"}} |
diff --git a/internal/wire/wiretest/testdata/frames/resume_spend.json b/internal/wire/wiretest/testdata/frames/resume_spend.json| new file mode 100644 |
| index 00000000..85bcda00 |
| --- /dev/null |
| +++ b/internal/wire/wiretest/testdata/frames/resume_spend.json |
| @@ -0,0 +1 @@ |
| +{"id":"c49","type":"resume_spend","data":{"connection":"cn_0004","person":"owner@example.com","local_id":"tensorx-1","pause_revision":3}} |
diff --git a/internal/wire/wiretest/testdata/frames/usage-probe.json b/internal/wire/wiretest/testdata/frames/usage-probe.json| new file mode 100644 |
| index 00000000..66ab5c97 |
| --- /dev/null |
| +++ b/internal/wire/wiretest/testdata/frames/usage-probe.json |
| @@ -0,0 +1 @@ |
| +{"id":"r-9","type":"usage","data":{"turn_id":"","step_id":"","question_id":"","probe_id":"pr_tensorx-1_1","rows":[{"provider":"tensorx","connection":"tensorx-1","model":"z-ai/glm-5.3","attempt":1,"outcome":"replied","complete":true,"input_tokens":9,"cached_input_tokens":0,"cache_write_tokens":0,"output_tokens":1,"reasoning_output_tokens":null,"cost_micros":21,"currency":"USD","price_version":"tensorx-2026-11-12"}]}} |