@spendguard/sdk 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +190 -0
- package/LICENSE_NOTICES.md +127 -0
- package/README.md +151 -0
- package/dist/adapter-D9T3yEEw.d.ts +3441 -0
- package/dist/cache-DOnw8QtJ.d.ts +1164 -0
- package/dist/cache.d.ts +6 -0
- package/dist/cache.js +74 -0
- package/dist/client.d.ts +6 -0
- package/dist/client.js +4815 -0
- package/dist/errors.d.ts +269 -0
- package/dist/errors.js +148 -0
- package/dist/ids.d.ts +69 -0
- package/dist/ids.js +61 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.js +5295 -0
- package/dist/otel.d.ts +118 -0
- package/dist/otel.js +84 -0
- package/dist/pricing/demo.d.ts +26 -0
- package/dist/pricing/demo.js +138 -0
- package/dist/pricing.d.ts +70 -0
- package/dist/pricing.js +92 -0
- package/dist/promptHash.d.ts +23 -0
- package/dist/promptHash.js +25 -0
- package/dist/proto.d.ts +609 -0
- package/dist/proto.js +3055 -0
- package/dist/retry.d.ts +121 -0
- package/dist/retry.js +92 -0
- package/dist/runPlan.d.ts +69 -0
- package/dist/runPlan.js +35 -0
- package/fixtures/cross-language/v1.json +327 -0
- package/package.json +123 -0
package/dist/proto.d.ts
ADDED
|
@@ -0,0 +1,609 @@
|
|
|
1
|
+
import { H as HandshakeRequest, b as HandshakeResponse, D as DecisionRequest, c as DecisionResponse, P as PublishOutcomeRequest, d as PublishOutcomeResponse, e as TraceEvent, f as TraceEventAck, I as IssueBudgetGrantRequest, g as IssueBudgetGrantResponse, h as RevokeBudgetGrantRequest, i as RevokeBudgetGrantResponse, j as ConsumeBudgetGrantRequest, k as ConsumeBudgetGrantResponse, l as DrainSubscribeRequest, m as DrainSignal, n as ResumeAfterApprovalRequest, o as ResumeAfterApprovalResponse, p as ReleaseReservationRequest, q as ReleaseReservationResponse, a as ReserveSessionRequest, r as ReserveSessionOutcome, C as CommitSessionDeltaRequest, s as CommitSessionDeltaOutcome, R as ReleaseSessionRequest, t as ReleaseSessionOutcome } from './adapter-D9T3yEEw.js';
|
|
2
|
+
export { u as adapter, v as common } from './adapter-D9T3yEEw.js';
|
|
3
|
+
import { RpcOptions, UnaryCall, DuplexStreamingCall, ServerStreamingCall, ServiceInfo, RpcTransport, ServiceType } from '@protobuf-ts/runtime-rpc';
|
|
4
|
+
import { MessageType } from '@protobuf-ts/runtime';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* -- Handshake (per Sidecar §5 protocol_handshake) ------------------------
|
|
8
|
+
*
|
|
9
|
+
* @generated from protobuf service spendguard.sidecar_adapter.v1.SidecarAdapter
|
|
10
|
+
*/
|
|
11
|
+
interface ISidecarAdapterClient {
|
|
12
|
+
/**
|
|
13
|
+
* Initial handshake; mandatory before any other RPC. Negotiates SDK version,
|
|
14
|
+
* runtime kind, capability level, tenant_id assertion, key epochs.
|
|
15
|
+
*
|
|
16
|
+
* @generated from protobuf rpc: Handshake
|
|
17
|
+
*/
|
|
18
|
+
handshake(input: HandshakeRequest, options?: RpcOptions): UnaryCall<HandshakeRequest, HandshakeResponse>;
|
|
19
|
+
/**
|
|
20
|
+
* Adapter requests a decision at a *.pre trigger point.
|
|
21
|
+
* Sidecar runs Contract §6 stages 1-5 and returns DecisionResult.
|
|
22
|
+
* Sidecar may take up to Contract §14 latency budget (50ms p99 warm).
|
|
23
|
+
*
|
|
24
|
+
* @generated from protobuf rpc: RequestDecision
|
|
25
|
+
*/
|
|
26
|
+
requestDecision(input: DecisionRequest, options?: RpcOptions): UnaryCall<DecisionRequest, DecisionResponse>;
|
|
27
|
+
/**
|
|
28
|
+
* Adapter confirms publish_effect outcome (per Contract §6 stage 7).
|
|
29
|
+
* Idempotent via effect_hash (Stage 2 §4.6).
|
|
30
|
+
*
|
|
31
|
+
* @generated from protobuf rpc: ConfirmPublishOutcome
|
|
32
|
+
*/
|
|
33
|
+
confirmPublishOutcome(input: PublishOutcomeRequest, options?: RpcOptions): UnaryCall<PublishOutcomeRequest, PublishOutcomeResponse>;
|
|
34
|
+
/**
|
|
35
|
+
* Adapter emits canonical/lifecycle events (agent.run.start, agent.step.post
|
|
36
|
+
* tool.call.post, llm.call.post for commit, etc.). Server-streamed because
|
|
37
|
+
* sidecar may emit follow-up acks or correction events.
|
|
38
|
+
*
|
|
39
|
+
* @generated from protobuf rpc: EmitTraceEvents
|
|
40
|
+
*/
|
|
41
|
+
emitTraceEvents(options?: RpcOptions): DuplexStreamingCall<TraceEvent, TraceEventAck>;
|
|
42
|
+
/**
|
|
43
|
+
* Parent agent requests budget_grant JWT to delegate to child agent.
|
|
44
|
+
*
|
|
45
|
+
* @generated from protobuf rpc: IssueBudgetGrant
|
|
46
|
+
*/
|
|
47
|
+
issueBudgetGrant(input: IssueBudgetGrantRequest, options?: RpcOptions): UnaryCall<IssueBudgetGrantRequest, IssueBudgetGrantResponse>;
|
|
48
|
+
/**
|
|
49
|
+
* Parent revokes a previously issued grant.
|
|
50
|
+
*
|
|
51
|
+
* @generated from protobuf rpc: RevokeBudgetGrant
|
|
52
|
+
*/
|
|
53
|
+
revokeBudgetGrant(input: RevokeBudgetGrantRequest, options?: RpcOptions): UnaryCall<RevokeBudgetGrantRequest, RevokeBudgetGrantResponse>;
|
|
54
|
+
/**
|
|
55
|
+
* Child agent uses grant to bootstrap budget context.
|
|
56
|
+
*
|
|
57
|
+
* @generated from protobuf rpc: ConsumeBudgetGrant
|
|
58
|
+
*/
|
|
59
|
+
consumeBudgetGrant(input: ConsumeBudgetGrantRequest, options?: RpcOptions): UnaryCall<ConsumeBudgetGrantRequest, ConsumeBudgetGrantResponse>;
|
|
60
|
+
/**
|
|
61
|
+
* Sidecar signals adapter that drain has begun; adapter should stop
|
|
62
|
+
* initiating new decision boundaries and let in-flight finish.
|
|
63
|
+
*
|
|
64
|
+
* @generated from protobuf rpc: StreamDrainSignal
|
|
65
|
+
*/
|
|
66
|
+
streamDrainSignal(input: DrainSubscribeRequest, options?: RpcOptions): ServerStreamingCall<DrainSubscribeRequest, DrainSignal>;
|
|
67
|
+
/**
|
|
68
|
+
* Adapter calls this AFTER the human approver has approved/denied the
|
|
69
|
+
* pending approval (REQUIRE_APPROVAL outcome from RequestDecision).
|
|
70
|
+
* Sidecar:
|
|
71
|
+
* 1. Looks up the approval by (tenant_id, decision_id, approval_id).
|
|
72
|
+
* 2. Reads the current state (must be `approved` or `denied`).
|
|
73
|
+
* 3. For `approved`: re-runs Contract evaluation + Ledger.ReserveSet
|
|
74
|
+
* with a NEW idempotency key derived from approval_id (so a
|
|
75
|
+
* replay can never double-publish the effect).
|
|
76
|
+
* 4. For `denied`: emits the deny audit row + returns Decision::STOP.
|
|
77
|
+
* 5. For other states (pending/expired/cancelled): returns the
|
|
78
|
+
* typed Error code so the adapter raises the right exception.
|
|
79
|
+
*
|
|
80
|
+
* Idempotent: repeated ResumeAfterApproval calls with the same
|
|
81
|
+
* (decision_id, approval_id) produce the same DecisionResponse
|
|
82
|
+
* because the idempotency key includes both.
|
|
83
|
+
*
|
|
84
|
+
* @generated from protobuf rpc: ResumeAfterApproval
|
|
85
|
+
*/
|
|
86
|
+
resumeAfterApproval(input: ResumeAfterApprovalRequest, options?: RpcOptions): UnaryCall<ResumeAfterApprovalRequest, ResumeAfterApprovalResponse>;
|
|
87
|
+
/**
|
|
88
|
+
* Adapter-initiated release of a held reservation before commit.
|
|
89
|
+
* Use when the provider call is aborted, the client times out, or the
|
|
90
|
+
* agent run is cancelled — and the adapter wants to surface that
|
|
91
|
+
* explicitly rather than waiting for an outcome-driven (APPLY_FAILED
|
|
92
|
+
* or trace-event-driven) implicit release.
|
|
93
|
+
*
|
|
94
|
+
* Coexists with the implicit release paths in ConfirmPublishOutcome and
|
|
95
|
+
* EmitTraceEvents; those remain unchanged. Implicit paths are still the
|
|
96
|
+
* default for adapters that report outcomes naturally; the explicit RPC
|
|
97
|
+
* is for adapters that want to match the Agent Spend Protocol Draft-01
|
|
98
|
+
* wire shape (docs/specs/agent-spend-protocol/draft-01.md §4).
|
|
99
|
+
*
|
|
100
|
+
* Idempotent: repeated ReleaseReservation calls with the same
|
|
101
|
+
* (reservation_id, idempotency_key) pair return the original outcome.
|
|
102
|
+
*
|
|
103
|
+
* @generated from protobuf rpc: ReleaseReservation
|
|
104
|
+
*/
|
|
105
|
+
releaseReservation(input: ReleaseReservationRequest, options?: RpcOptions): UnaryCall<ReleaseReservationRequest, ReleaseReservationResponse>;
|
|
106
|
+
/**
|
|
107
|
+
* Reserve a session-scoped ledger hold before a realtime voice session
|
|
108
|
+
* connects to paid model providers. Idempotent by
|
|
109
|
+
* (tenant_id, session_id, route, idempotency_key).
|
|
110
|
+
*
|
|
111
|
+
* @generated from protobuf rpc: ReserveSession
|
|
112
|
+
*/
|
|
113
|
+
reserveSession(input: ReserveSessionRequest, options?: RpcOptions): UnaryCall<ReserveSessionRequest, ReserveSessionOutcome>;
|
|
114
|
+
/**
|
|
115
|
+
* Commit one positive streaming spend delta against an existing session
|
|
116
|
+
* reservation. Idempotent by (session_reservation_id,
|
|
117
|
+
* streaming_commit_id). amount_atomic_delta MUST be > 0.
|
|
118
|
+
*
|
|
119
|
+
* @generated from protobuf rpc: CommitSessionDelta
|
|
120
|
+
*/
|
|
121
|
+
commitSessionDelta(input: CommitSessionDeltaRequest, options?: RpcOptions): UnaryCall<CommitSessionDeltaRequest, CommitSessionDeltaOutcome>;
|
|
122
|
+
/**
|
|
123
|
+
* Release the uncommitted remainder of a session-scoped reservation.
|
|
124
|
+
* Idempotent by (session_reservation_id, idempotency_key).
|
|
125
|
+
*
|
|
126
|
+
* @generated from protobuf rpc: ReleaseSession
|
|
127
|
+
*/
|
|
128
|
+
releaseSession(input: ReleaseSessionRequest, options?: RpcOptions): UnaryCall<ReleaseSessionRequest, ReleaseSessionOutcome>;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* -- Handshake (per Sidecar §5 protocol_handshake) ------------------------
|
|
132
|
+
*
|
|
133
|
+
* @generated from protobuf service spendguard.sidecar_adapter.v1.SidecarAdapter
|
|
134
|
+
*/
|
|
135
|
+
declare class SidecarAdapterClient implements ISidecarAdapterClient, ServiceInfo {
|
|
136
|
+
private readonly _transport;
|
|
137
|
+
typeName: any;
|
|
138
|
+
methods: any;
|
|
139
|
+
options: any;
|
|
140
|
+
constructor(_transport: RpcTransport);
|
|
141
|
+
/**
|
|
142
|
+
* Initial handshake; mandatory before any other RPC. Negotiates SDK version,
|
|
143
|
+
* runtime kind, capability level, tenant_id assertion, key epochs.
|
|
144
|
+
*
|
|
145
|
+
* @generated from protobuf rpc: Handshake
|
|
146
|
+
*/
|
|
147
|
+
handshake(input: HandshakeRequest, options?: RpcOptions): UnaryCall<HandshakeRequest, HandshakeResponse>;
|
|
148
|
+
/**
|
|
149
|
+
* Adapter requests a decision at a *.pre trigger point.
|
|
150
|
+
* Sidecar runs Contract §6 stages 1-5 and returns DecisionResult.
|
|
151
|
+
* Sidecar may take up to Contract §14 latency budget (50ms p99 warm).
|
|
152
|
+
*
|
|
153
|
+
* @generated from protobuf rpc: RequestDecision
|
|
154
|
+
*/
|
|
155
|
+
requestDecision(input: DecisionRequest, options?: RpcOptions): UnaryCall<DecisionRequest, DecisionResponse>;
|
|
156
|
+
/**
|
|
157
|
+
* Adapter confirms publish_effect outcome (per Contract §6 stage 7).
|
|
158
|
+
* Idempotent via effect_hash (Stage 2 §4.6).
|
|
159
|
+
*
|
|
160
|
+
* @generated from protobuf rpc: ConfirmPublishOutcome
|
|
161
|
+
*/
|
|
162
|
+
confirmPublishOutcome(input: PublishOutcomeRequest, options?: RpcOptions): UnaryCall<PublishOutcomeRequest, PublishOutcomeResponse>;
|
|
163
|
+
/**
|
|
164
|
+
* Adapter emits canonical/lifecycle events (agent.run.start, agent.step.post
|
|
165
|
+
* tool.call.post, llm.call.post for commit, etc.). Server-streamed because
|
|
166
|
+
* sidecar may emit follow-up acks or correction events.
|
|
167
|
+
*
|
|
168
|
+
* @generated from protobuf rpc: EmitTraceEvents
|
|
169
|
+
*/
|
|
170
|
+
emitTraceEvents(options?: RpcOptions): DuplexStreamingCall<TraceEvent, TraceEventAck>;
|
|
171
|
+
/**
|
|
172
|
+
* Parent agent requests budget_grant JWT to delegate to child agent.
|
|
173
|
+
*
|
|
174
|
+
* @generated from protobuf rpc: IssueBudgetGrant
|
|
175
|
+
*/
|
|
176
|
+
issueBudgetGrant(input: IssueBudgetGrantRequest, options?: RpcOptions): UnaryCall<IssueBudgetGrantRequest, IssueBudgetGrantResponse>;
|
|
177
|
+
/**
|
|
178
|
+
* Parent revokes a previously issued grant.
|
|
179
|
+
*
|
|
180
|
+
* @generated from protobuf rpc: RevokeBudgetGrant
|
|
181
|
+
*/
|
|
182
|
+
revokeBudgetGrant(input: RevokeBudgetGrantRequest, options?: RpcOptions): UnaryCall<RevokeBudgetGrantRequest, RevokeBudgetGrantResponse>;
|
|
183
|
+
/**
|
|
184
|
+
* Child agent uses grant to bootstrap budget context.
|
|
185
|
+
*
|
|
186
|
+
* @generated from protobuf rpc: ConsumeBudgetGrant
|
|
187
|
+
*/
|
|
188
|
+
consumeBudgetGrant(input: ConsumeBudgetGrantRequest, options?: RpcOptions): UnaryCall<ConsumeBudgetGrantRequest, ConsumeBudgetGrantResponse>;
|
|
189
|
+
/**
|
|
190
|
+
* Sidecar signals adapter that drain has begun; adapter should stop
|
|
191
|
+
* initiating new decision boundaries and let in-flight finish.
|
|
192
|
+
*
|
|
193
|
+
* @generated from protobuf rpc: StreamDrainSignal
|
|
194
|
+
*/
|
|
195
|
+
streamDrainSignal(input: DrainSubscribeRequest, options?: RpcOptions): ServerStreamingCall<DrainSubscribeRequest, DrainSignal>;
|
|
196
|
+
/**
|
|
197
|
+
* Adapter calls this AFTER the human approver has approved/denied the
|
|
198
|
+
* pending approval (REQUIRE_APPROVAL outcome from RequestDecision).
|
|
199
|
+
* Sidecar:
|
|
200
|
+
* 1. Looks up the approval by (tenant_id, decision_id, approval_id).
|
|
201
|
+
* 2. Reads the current state (must be `approved` or `denied`).
|
|
202
|
+
* 3. For `approved`: re-runs Contract evaluation + Ledger.ReserveSet
|
|
203
|
+
* with a NEW idempotency key derived from approval_id (so a
|
|
204
|
+
* replay can never double-publish the effect).
|
|
205
|
+
* 4. For `denied`: emits the deny audit row + returns Decision::STOP.
|
|
206
|
+
* 5. For other states (pending/expired/cancelled): returns the
|
|
207
|
+
* typed Error code so the adapter raises the right exception.
|
|
208
|
+
*
|
|
209
|
+
* Idempotent: repeated ResumeAfterApproval calls with the same
|
|
210
|
+
* (decision_id, approval_id) produce the same DecisionResponse
|
|
211
|
+
* because the idempotency key includes both.
|
|
212
|
+
*
|
|
213
|
+
* @generated from protobuf rpc: ResumeAfterApproval
|
|
214
|
+
*/
|
|
215
|
+
resumeAfterApproval(input: ResumeAfterApprovalRequest, options?: RpcOptions): UnaryCall<ResumeAfterApprovalRequest, ResumeAfterApprovalResponse>;
|
|
216
|
+
/**
|
|
217
|
+
* Adapter-initiated release of a held reservation before commit.
|
|
218
|
+
* Use when the provider call is aborted, the client times out, or the
|
|
219
|
+
* agent run is cancelled — and the adapter wants to surface that
|
|
220
|
+
* explicitly rather than waiting for an outcome-driven (APPLY_FAILED
|
|
221
|
+
* or trace-event-driven) implicit release.
|
|
222
|
+
*
|
|
223
|
+
* Coexists with the implicit release paths in ConfirmPublishOutcome and
|
|
224
|
+
* EmitTraceEvents; those remain unchanged. Implicit paths are still the
|
|
225
|
+
* default for adapters that report outcomes naturally; the explicit RPC
|
|
226
|
+
* is for adapters that want to match the Agent Spend Protocol Draft-01
|
|
227
|
+
* wire shape (docs/specs/agent-spend-protocol/draft-01.md §4).
|
|
228
|
+
*
|
|
229
|
+
* Idempotent: repeated ReleaseReservation calls with the same
|
|
230
|
+
* (reservation_id, idempotency_key) pair return the original outcome.
|
|
231
|
+
*
|
|
232
|
+
* @generated from protobuf rpc: ReleaseReservation
|
|
233
|
+
*/
|
|
234
|
+
releaseReservation(input: ReleaseReservationRequest, options?: RpcOptions): UnaryCall<ReleaseReservationRequest, ReleaseReservationResponse>;
|
|
235
|
+
/**
|
|
236
|
+
* Reserve a session-scoped ledger hold before a realtime voice session
|
|
237
|
+
* connects to paid model providers. Idempotent by
|
|
238
|
+
* (tenant_id, session_id, route, idempotency_key).
|
|
239
|
+
*
|
|
240
|
+
* @generated from protobuf rpc: ReserveSession
|
|
241
|
+
*/
|
|
242
|
+
reserveSession(input: ReserveSessionRequest, options?: RpcOptions): UnaryCall<ReserveSessionRequest, ReserveSessionOutcome>;
|
|
243
|
+
/**
|
|
244
|
+
* Commit one positive streaming spend delta against an existing session
|
|
245
|
+
* reservation. Idempotent by (session_reservation_id,
|
|
246
|
+
* streaming_commit_id). amount_atomic_delta MUST be > 0.
|
|
247
|
+
*
|
|
248
|
+
* @generated from protobuf rpc: CommitSessionDelta
|
|
249
|
+
*/
|
|
250
|
+
commitSessionDelta(input: CommitSessionDeltaRequest, options?: RpcOptions): UnaryCall<CommitSessionDeltaRequest, CommitSessionDeltaOutcome>;
|
|
251
|
+
/**
|
|
252
|
+
* Release the uncommitted remainder of a session-scoped reservation.
|
|
253
|
+
* Idempotent by (session_reservation_id, idempotency_key).
|
|
254
|
+
*
|
|
255
|
+
* @generated from protobuf rpc: ReleaseSession
|
|
256
|
+
*/
|
|
257
|
+
releaseSession(input: ReleaseSessionRequest, options?: RpcOptions): UnaryCall<ReleaseSessionRequest, ReleaseSessionOutcome>;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
type adapter_client_ISidecarAdapterClient = ISidecarAdapterClient;
|
|
261
|
+
type adapter_client_SidecarAdapterClient = SidecarAdapterClient;
|
|
262
|
+
declare const adapter_client_SidecarAdapterClient: typeof SidecarAdapterClient;
|
|
263
|
+
declare namespace adapter_client {
|
|
264
|
+
export { type adapter_client_ISidecarAdapterClient as ISidecarAdapterClient, adapter_client_SidecarAdapterClient as SidecarAdapterClient };
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
declare class TokenizeRequest$Type extends MessageType<TokenizeRequest> {
|
|
268
|
+
constructor();
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Round-2 fix M6 + Round-3 fix N3 (DoS protection): the server-side
|
|
272
|
+
* TokenizerSvc rejects requests that exceed the following per-field
|
|
273
|
+
* caps with gRPC InvalidArgument:
|
|
274
|
+
* model.len() <= 256 bytes
|
|
275
|
+
* raw_text.len() <= 4 MiB
|
|
276
|
+
* messages.len() <= 1000 elements
|
|
277
|
+
* message.content <= 4 MiB each
|
|
278
|
+
* Plus a protocol-layer cap configured in main.rs:
|
|
279
|
+
* max_decoding_message_size = 4 MiB (matches field caps)
|
|
280
|
+
* The protocol cap is the dominant hard cap — anything larger than
|
|
281
|
+
* 4 MiB is rejected by tonic with ResourceExhausted BEFORE proto
|
|
282
|
+
* deserialisation. The field caps are redundant defense-in-depth that
|
|
283
|
+
* also defend the in-process library form (no tonic protocol layer)
|
|
284
|
+
* and provide more specific InvalidArgument errors for callers that
|
|
285
|
+
* want to metric per-field violations. Real workloads sit far below.
|
|
286
|
+
*
|
|
287
|
+
* @generated from protobuf message spendguard.tokenizer.v1.TokenizeRequest
|
|
288
|
+
*/
|
|
289
|
+
interface TokenizeRequest {
|
|
290
|
+
/**
|
|
291
|
+
* Required. Model string as appears in the LLM request body
|
|
292
|
+
* (e.g., "gpt-4o-mini", "claude-3-5-sonnet-20240620").
|
|
293
|
+
* Server rejects with InvalidArgument if len > 256 bytes (M6).
|
|
294
|
+
*
|
|
295
|
+
* @generated from protobuf field: string model = 1
|
|
296
|
+
*/
|
|
297
|
+
model: string;
|
|
298
|
+
/**
|
|
299
|
+
* Messages array per OpenAI Chat Completions shape; tokenizer
|
|
300
|
+
* applies model-specific message envelope tokens (system + user +
|
|
301
|
+
* assistant role markers + content separators) where applicable.
|
|
302
|
+
* For non-chat models or alternate envelope shapes, use raw_text.
|
|
303
|
+
* Server rejects with InvalidArgument if len > 1000 (M6).
|
|
304
|
+
*
|
|
305
|
+
* @generated from protobuf field: repeated spendguard.tokenizer.v1.TokenizeRequest.Message messages = 2
|
|
306
|
+
*/
|
|
307
|
+
messages: TokenizeRequest_Message[];
|
|
308
|
+
/**
|
|
309
|
+
* Mutually exclusive with messages; for text-completion shape.
|
|
310
|
+
* PROTOCOL CAP: 4 MiB.
|
|
311
|
+
* Server rejects with InvalidArgument if len > 4 MiB (M6 / R3 N3 / POST_GA_03 #114).
|
|
312
|
+
*
|
|
313
|
+
* @generated from protobuf field: string raw_text = 3
|
|
314
|
+
*/
|
|
315
|
+
rawText: string;
|
|
316
|
+
/**
|
|
317
|
+
* Caller-supplied request_id for tracing/audit; mints UUIDv7 if
|
|
318
|
+
* empty. Non-empty ids must parse as UUIDv7; UUIDv4 remains accepted
|
|
319
|
+
* for backward compatibility and increments a migration metric.
|
|
320
|
+
* Surfaced in tokenize span (per trace-schema-spec §3.1).
|
|
321
|
+
*
|
|
322
|
+
* @generated from protobuf field: string request_id = 4
|
|
323
|
+
*/
|
|
324
|
+
requestId: string;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* @generated MessageType for protobuf message spendguard.tokenizer.v1.TokenizeRequest
|
|
328
|
+
*/
|
|
329
|
+
declare const TokenizeRequest: TokenizeRequest$Type;
|
|
330
|
+
declare class TokenizeRequest_Message$Type extends MessageType<TokenizeRequest_Message> {
|
|
331
|
+
constructor();
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* @generated from protobuf message spendguard.tokenizer.v1.TokenizeRequest.Message
|
|
335
|
+
*/
|
|
336
|
+
interface TokenizeRequest_Message {
|
|
337
|
+
/**
|
|
338
|
+
* "system" | "user" | "assistant" | "tool"
|
|
339
|
+
*
|
|
340
|
+
* @generated from protobuf field: string role = 1
|
|
341
|
+
*/
|
|
342
|
+
role: string;
|
|
343
|
+
/**
|
|
344
|
+
* Text content; vision/multimodal v2 will add binary
|
|
345
|
+
* content_parts as a separate additive field.
|
|
346
|
+
* PROTOCOL CAP: 4 MiB.
|
|
347
|
+
* Server rejects with InvalidArgument if len > 4 MiB (M6 / R3 N3 / POST_GA_03 #114).
|
|
348
|
+
*
|
|
349
|
+
* @generated from protobuf field: string content = 2
|
|
350
|
+
*/
|
|
351
|
+
content: string;
|
|
352
|
+
/**
|
|
353
|
+
* Tool call payload tokens count for tool-using agents.
|
|
354
|
+
* Tokenizer adds function name + arguments JSON encoding to
|
|
355
|
+
* total count using the model's tokenizer.
|
|
356
|
+
*
|
|
357
|
+
* @generated from protobuf field: repeated spendguard.tokenizer.v1.TokenizeRequest.Message.ToolCall tool_calls = 3
|
|
358
|
+
*/
|
|
359
|
+
toolCalls: TokenizeRequest_Message_ToolCall[];
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* @generated MessageType for protobuf message spendguard.tokenizer.v1.TokenizeRequest.Message
|
|
363
|
+
*/
|
|
364
|
+
declare const TokenizeRequest_Message: TokenizeRequest_Message$Type;
|
|
365
|
+
declare class TokenizeRequest_Message_ToolCall$Type extends MessageType<TokenizeRequest_Message_ToolCall> {
|
|
366
|
+
constructor();
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* @generated from protobuf message spendguard.tokenizer.v1.TokenizeRequest.Message.ToolCall
|
|
370
|
+
*/
|
|
371
|
+
interface TokenizeRequest_Message_ToolCall {
|
|
372
|
+
/**
|
|
373
|
+
* @generated from protobuf field: string name = 1
|
|
374
|
+
*/
|
|
375
|
+
name: string;
|
|
376
|
+
/**
|
|
377
|
+
* Canonical JSON encoding of arguments (already serialised).
|
|
378
|
+
*
|
|
379
|
+
* @generated from protobuf field: string arguments_json = 2
|
|
380
|
+
*/
|
|
381
|
+
argumentsJson: string;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* @generated MessageType for protobuf message spendguard.tokenizer.v1.TokenizeRequest.Message.ToolCall
|
|
385
|
+
*/
|
|
386
|
+
declare const TokenizeRequest_Message_ToolCall: TokenizeRequest_Message_ToolCall$Type;
|
|
387
|
+
declare class TokenizeResponse$Type extends MessageType<TokenizeResponse> {
|
|
388
|
+
constructor();
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* @generated from protobuf message spendguard.tokenizer.v1.TokenizeResponse
|
|
392
|
+
*/
|
|
393
|
+
interface TokenizeResponse {
|
|
394
|
+
/**
|
|
395
|
+
* Authoritative token count for the input.
|
|
396
|
+
*
|
|
397
|
+
* @generated from protobuf field: int64 input_tokens = 1
|
|
398
|
+
*/
|
|
399
|
+
inputTokens: string;
|
|
400
|
+
/**
|
|
401
|
+
* Which tier was used. Always one of T2 | T3 (T1 never on hot
|
|
402
|
+
* path per §1.3 invariant).
|
|
403
|
+
* "T2" | "T3"
|
|
404
|
+
*
|
|
405
|
+
* @generated from protobuf field: string tier = 2
|
|
406
|
+
*/
|
|
407
|
+
tier: string;
|
|
408
|
+
/**
|
|
409
|
+
* Encoder version that produced this count. Empty string for
|
|
410
|
+
* Tier 3 (no versioned encoder used). Maps to audit_outbox
|
|
411
|
+
* tokenizer_version_id via the mirror crate
|
|
412
|
+
* (spendguard-prediction-mirror).
|
|
413
|
+
* UUIDv7 of tokenizer_versions row.
|
|
414
|
+
*
|
|
415
|
+
* @generated from protobuf field: string tokenizer_version_id = 3
|
|
416
|
+
*/
|
|
417
|
+
tokenizerVersionId: string;
|
|
418
|
+
/**
|
|
419
|
+
* Encoder kind for diagnostics; redundant with version_id but
|
|
420
|
+
* cheap. Mirrors tokenizer_versions.kind CHECK constraint.
|
|
421
|
+
* "OPENAI_TIKTOKEN" | "ANTHROPIC_BPE" | "GEMINI_BPE" |
|
|
422
|
+
* "COHERE_BPE" | "SENTENCEPIECE_LLAMA" | "HEURISTIC"
|
|
423
|
+
*
|
|
424
|
+
* @generated from protobuf field: string kind = 4
|
|
425
|
+
*/
|
|
426
|
+
kind: string;
|
|
427
|
+
/**
|
|
428
|
+
* For Tier 3 fallback only: the underlying char count + the
|
|
429
|
+
* conservative margin applied; lets caller log / metric.
|
|
430
|
+
* Both are zero for Tier 2 (proto3 default).
|
|
431
|
+
*
|
|
432
|
+
* @generated from protobuf field: int64 fallback_char_count = 5
|
|
433
|
+
*/
|
|
434
|
+
fallbackCharCount: string;
|
|
435
|
+
/**
|
|
436
|
+
* e.g., 1.05 for 5% conservative (per spec §5.1).
|
|
437
|
+
*
|
|
438
|
+
* @generated from protobuf field: float fallback_margin_ratio = 6
|
|
439
|
+
*/
|
|
440
|
+
fallbackMarginRatio: number;
|
|
441
|
+
/**
|
|
442
|
+
* Time spent inside Tokenize (excludes RPC overhead). Useful for
|
|
443
|
+
* SLO tracking; not on audit chain.
|
|
444
|
+
*
|
|
445
|
+
* @generated from protobuf field: int64 latency_ns = 7
|
|
446
|
+
*/
|
|
447
|
+
latencyNs: string;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* @generated MessageType for protobuf message spendguard.tokenizer.v1.TokenizeResponse
|
|
451
|
+
*/
|
|
452
|
+
declare const TokenizeResponse: TokenizeResponse$Type;
|
|
453
|
+
declare class ShadowVerifyRequest$Type extends MessageType<ShadowVerifyRequest> {
|
|
454
|
+
constructor();
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* @generated from protobuf message spendguard.tokenizer.v1.ShadowVerifyRequest
|
|
458
|
+
*/
|
|
459
|
+
interface ShadowVerifyRequest {
|
|
460
|
+
/**
|
|
461
|
+
* Same shape as TokenizeRequest; shadow worker passes through.
|
|
462
|
+
*
|
|
463
|
+
* @generated from protobuf field: string model = 1
|
|
464
|
+
*/
|
|
465
|
+
model: string;
|
|
466
|
+
/**
|
|
467
|
+
* @generated from protobuf field: repeated spendguard.tokenizer.v1.TokenizeRequest.Message messages = 2
|
|
468
|
+
*/
|
|
469
|
+
messages: TokenizeRequest_Message[];
|
|
470
|
+
/**
|
|
471
|
+
* @generated from protobuf field: string raw_text = 3
|
|
472
|
+
*/
|
|
473
|
+
rawText: string;
|
|
474
|
+
/**
|
|
475
|
+
* Tier 2 result captured at hot-path time, for drift comparison.
|
|
476
|
+
*
|
|
477
|
+
* @generated from protobuf field: int64 t2_input_tokens = 4
|
|
478
|
+
*/
|
|
479
|
+
t2InputTokens: string;
|
|
480
|
+
/**
|
|
481
|
+
* @generated from protobuf field: string t2_tokenizer_version_id = 5
|
|
482
|
+
*/
|
|
483
|
+
t2TokenizerVersionId: string;
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* @generated MessageType for protobuf message spendguard.tokenizer.v1.ShadowVerifyRequest
|
|
487
|
+
*/
|
|
488
|
+
declare const ShadowVerifyRequest: ShadowVerifyRequest$Type;
|
|
489
|
+
declare class ShadowVerifyResponse$Type extends MessageType<ShadowVerifyResponse> {
|
|
490
|
+
constructor();
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* @generated from protobuf message spendguard.tokenizer.v1.ShadowVerifyResponse
|
|
494
|
+
*/
|
|
495
|
+
interface ShadowVerifyResponse {
|
|
496
|
+
/**
|
|
497
|
+
* Provider-reported count.
|
|
498
|
+
*
|
|
499
|
+
* @generated from protobuf field: int64 t1_input_tokens = 1
|
|
500
|
+
*/
|
|
501
|
+
t1InputTokens: string;
|
|
502
|
+
/**
|
|
503
|
+
* Absolute drift |T1 - T2| / T1; alert threshold compare against
|
|
504
|
+
* configured per-kind threshold (default 1.0%).
|
|
505
|
+
*
|
|
506
|
+
* @generated from protobuf field: float drift_ratio = 2
|
|
507
|
+
*/
|
|
508
|
+
driftRatio: number;
|
|
509
|
+
/**
|
|
510
|
+
* Whether this sample triggered a drift_alert event emission.
|
|
511
|
+
*
|
|
512
|
+
* @generated from protobuf field: bool drift_alert_emitted = 3
|
|
513
|
+
*/
|
|
514
|
+
driftAlertEmitted: boolean;
|
|
515
|
+
/**
|
|
516
|
+
* Latency to provider; for circuit-breaker metrics.
|
|
517
|
+
*
|
|
518
|
+
* @generated from protobuf field: int64 provider_latency_ms = 4
|
|
519
|
+
*/
|
|
520
|
+
providerLatencyMs: string;
|
|
521
|
+
/**
|
|
522
|
+
* Provider response identifiers for debugging.
|
|
523
|
+
*
|
|
524
|
+
* @generated from protobuf field: string provider_request_id = 5
|
|
525
|
+
*/
|
|
526
|
+
providerRequestId: string;
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* @generated MessageType for protobuf message spendguard.tokenizer.v1.ShadowVerifyResponse
|
|
530
|
+
*/
|
|
531
|
+
declare const ShadowVerifyResponse: ShadowVerifyResponse$Type;
|
|
532
|
+
/**
|
|
533
|
+
* @generated ServiceType for protobuf service spendguard.tokenizer.v1.Tokenizer
|
|
534
|
+
*/
|
|
535
|
+
declare const Tokenizer: ServiceType;
|
|
536
|
+
|
|
537
|
+
declare const tokenizer_ShadowVerifyRequest: typeof ShadowVerifyRequest;
|
|
538
|
+
declare const tokenizer_ShadowVerifyResponse: typeof ShadowVerifyResponse;
|
|
539
|
+
declare const tokenizer_TokenizeRequest: typeof TokenizeRequest;
|
|
540
|
+
declare const tokenizer_TokenizeRequest_Message: typeof TokenizeRequest_Message;
|
|
541
|
+
declare const tokenizer_TokenizeRequest_Message_ToolCall: typeof TokenizeRequest_Message_ToolCall;
|
|
542
|
+
declare const tokenizer_TokenizeResponse: typeof TokenizeResponse;
|
|
543
|
+
declare const tokenizer_Tokenizer: typeof Tokenizer;
|
|
544
|
+
declare namespace tokenizer {
|
|
545
|
+
export { tokenizer_ShadowVerifyRequest as ShadowVerifyRequest, tokenizer_ShadowVerifyResponse as ShadowVerifyResponse, tokenizer_TokenizeRequest as TokenizeRequest, tokenizer_TokenizeRequest_Message as TokenizeRequest_Message, tokenizer_TokenizeRequest_Message_ToolCall as TokenizeRequest_Message_ToolCall, tokenizer_TokenizeResponse as TokenizeResponse, tokenizer_Tokenizer as Tokenizer };
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* @generated from protobuf service spendguard.tokenizer.v1.Tokenizer
|
|
550
|
+
*/
|
|
551
|
+
interface ITokenizerClient {
|
|
552
|
+
/**
|
|
553
|
+
* Hot-path tokenize. Synchronous; returns Tier 2 result (or Tier 3
|
|
554
|
+
* fallback) under 1ms p99 (library form) / 3ms p99 (gRPC over UDS).
|
|
555
|
+
* Per spec §10.1 latency SLO.
|
|
556
|
+
*
|
|
557
|
+
* @generated from protobuf rpc: Tokenize
|
|
558
|
+
*/
|
|
559
|
+
tokenize(input: TokenizeRequest, options?: RpcOptions): UnaryCall<TokenizeRequest, TokenizeResponse>;
|
|
560
|
+
/**
|
|
561
|
+
* Async shadow check via provider count_tokens API. Caller is
|
|
562
|
+
* expected to be the shadow sampling worker, NOT the hot path.
|
|
563
|
+
* Returns Tier 1 (provider-reported) count.
|
|
564
|
+
*
|
|
565
|
+
* SLICE_03: stub — returns gRPC UNIMPLEMENTED. SLICE_05 wires the
|
|
566
|
+
* real shadow worker + Anthropic / Gemini provider clients.
|
|
567
|
+
*
|
|
568
|
+
* @generated from protobuf rpc: ShadowVerify
|
|
569
|
+
*/
|
|
570
|
+
shadowVerify(input: ShadowVerifyRequest, options?: RpcOptions): UnaryCall<ShadowVerifyRequest, ShadowVerifyResponse>;
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* @generated from protobuf service spendguard.tokenizer.v1.Tokenizer
|
|
574
|
+
*/
|
|
575
|
+
declare class TokenizerClient implements ITokenizerClient, ServiceInfo {
|
|
576
|
+
private readonly _transport;
|
|
577
|
+
typeName: any;
|
|
578
|
+
methods: any;
|
|
579
|
+
options: any;
|
|
580
|
+
constructor(_transport: RpcTransport);
|
|
581
|
+
/**
|
|
582
|
+
* Hot-path tokenize. Synchronous; returns Tier 2 result (or Tier 3
|
|
583
|
+
* fallback) under 1ms p99 (library form) / 3ms p99 (gRPC over UDS).
|
|
584
|
+
* Per spec §10.1 latency SLO.
|
|
585
|
+
*
|
|
586
|
+
* @generated from protobuf rpc: Tokenize
|
|
587
|
+
*/
|
|
588
|
+
tokenize(input: TokenizeRequest, options?: RpcOptions): UnaryCall<TokenizeRequest, TokenizeResponse>;
|
|
589
|
+
/**
|
|
590
|
+
* Async shadow check via provider count_tokens API. Caller is
|
|
591
|
+
* expected to be the shadow sampling worker, NOT the hot path.
|
|
592
|
+
* Returns Tier 1 (provider-reported) count.
|
|
593
|
+
*
|
|
594
|
+
* SLICE_03: stub — returns gRPC UNIMPLEMENTED. SLICE_05 wires the
|
|
595
|
+
* real shadow worker + Anthropic / Gemini provider clients.
|
|
596
|
+
*
|
|
597
|
+
* @generated from protobuf rpc: ShadowVerify
|
|
598
|
+
*/
|
|
599
|
+
shadowVerify(input: ShadowVerifyRequest, options?: RpcOptions): UnaryCall<ShadowVerifyRequest, ShadowVerifyResponse>;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
type tokenizer_client_ITokenizerClient = ITokenizerClient;
|
|
603
|
+
type tokenizer_client_TokenizerClient = TokenizerClient;
|
|
604
|
+
declare const tokenizer_client_TokenizerClient: typeof TokenizerClient;
|
|
605
|
+
declare namespace tokenizer_client {
|
|
606
|
+
export { type tokenizer_client_ITokenizerClient as ITokenizerClient, tokenizer_client_TokenizerClient as TokenizerClient };
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
export { adapter_client as adapterClient, tokenizer, tokenizer_client as tokenizerClient };
|