@volter/twin-pinecone 0.1.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.
@@ -0,0 +1,411 @@
1
+ // Pinecone's CLIENT-SIDE RATE BUDGET — the pack's DECLARATION (the numbers) plus `guardPineconeClient`,
2
+ // the choke point every live Pinecone call goes through. The MECHANISM — the durable token-keyed
3
+ // ledger, the rolling window, reserve-under-lock, the `Retry-After`/429 cooldown, fail-CLOSED on a
4
+ // corrupt ledger — lives ONCE in the vendor-agnostic kernel (`@volter/world-core` → `rateBudget.ts`).
5
+ // Read that module's header for the full rationale AND for the honest list of what the guard does
6
+ // NOT guarantee (an injected clock or ledger path still defeats it — it guards carelessness, not
7
+ // malice). This module is modeled on notion-budget.ts, the reference injected-client decorator.
8
+ //
9
+ // ── WHY PINECONE NEEDS ONE ──────────────────────────────────────────────────────────
10
+ // Pinecone publishes a detailed DATA-PLANE limits table (docs.pinecone.io/reference/api/
11
+ // database-limits): per namespace per second, Query/Upsert/Delete/Update 100 each, and update- or
12
+ // delete-by-metadata only 5/s; per index per second, List 200, Fetch 100, DescribeIndexStats 100;
13
+ // per project, Inference 100/s and 2000/min. Its 429 body names the namespace and the QPS limit.
14
+ // But the CONTROL PLANE — `listIndexes` / `describeIndex`, which is what this connector's index pull
15
+ // actually calls — has NO published row at all. And this connector's `listVectors` is not one vendor
16
+ // endpoint but an AGGREGATION: a real implementation loops `listIndexes()` then `listPaginated()` per
17
+ // index per namespace, so a single call fans out across the whole project.
18
+ //
19
+ // ── HOW THE CEILING WAS CHOSEN ──────────────────────────────────────────────────────────────
20
+ // The control-plane endpoint this connector calls has NO PUBLISHED LIMIT, so the ceiling is not
21
+ // derived from Pinecone's data-plane table (which would be far looser: List alone is 200/s per index).
22
+ // It is pinned to the kernel's conservative fallback instead (DEFAULT_RATE_BUDGET: 60 weighted units
23
+ // / 60s at weight 2 = 30 calls/minute) — no more permissive than an undeclared vendor already gets.
24
+ // Worth recording: the tightest documented Pinecone figure is 5/s for by-metadata mutations, 20x
25
+ // tighter than plain ops, so "Pinecone is generous" is only true endpoint by endpoint.
26
+ //
27
+ // ── WHAT THIS DOES NOT DO: PACE ─────────────────────────────────────────────────────────────
28
+ // It bounds the 60s AVERAGE; it does NOT bound the instantaneous rate. The window has no
29
+ // spacing, so a tight `await` loop can legitimately fire the whole allowance in a fraction of a
30
+ // second. In that shape the vendor's own 429 can arrive BEFORE this ceiling does, and the backstop
31
+ // is then the COOLDOWN: the guard reads the back-off off the thrown error (or the response's
32
+ // exhaustion headers) and refuses every later call without touching the vendor. So the honest claim
33
+ // is "bounds the 60s average, and converts the vendor's first 429 into a hard stop" — never
34
+ // "refuses before the vendor ever 429s". Pacing is the CALLER's job; this module REFUSES, it never
35
+ // sleeps (see the kernel header: it is deliberately not a scheduler). A tighter window would not
36
+ // close the gap, it would only turn every legitimate multi-page pull into a cascade of refusals.
37
+ //
38
+ // ── HOW THE WEIGHTS WERE CHOSEN (and what is a judgement call) ──────────────────────────────
39
+ // `listVectors` costs 4, twice `listIndexes`. A JUDGEMENT CALL about THIS CONNECTOR's shape rather
40
+ // than a published cost: `listVectors` is the pack's own aggregation shape (see
41
+ // pinecone-connector.ts's header), and behind it a real implementation walks every index and every
42
+ // namespace with a cursor, so one call is an unbounded number of requests. Doubling its price halves
43
+ // how far a runaway walk gets while barely touching a normal pull.
44
+ import { declareRateBudget, rateBudgetPath, rateBudgetWeight, RateBudget, RateBudgetError, } from '@volter/world-core';
45
+ const VENDOR = 'pinecone';
46
+ /** Rolling window, in ms. Spend older than this is pruned. */
47
+ export const PINECONE_BUDGET_WINDOW_MS = 60_000;
48
+ /** Weighted units allowed inside one window. See the header for where this number comes from. */
49
+ export const PINECONE_BUDGET_CEILING = 60;
50
+ /** Seconds. A `Retry-After` above this means the credential is throttled hard — fail loudly. */
51
+ export const PINECONE_BUDGET_MAX_RETRY_AFTER_S = 300;
52
+ /** Per-call cost, keyed by the client method the guard is about to invoke. See the header. */
53
+ export const PINECONE_CALL_WEIGHTS = {
54
+ /** `listVectors` — the per-index, per-namespace paginated aggregation. */
55
+ fanout: 4,
56
+ /** Every other modeled call (`listIndexes`, and anything unclassified). */
57
+ other: 2,
58
+ };
59
+ /**
60
+ * The client methods this pack PRICES BY NAME, as dotted paths into the injected client.
61
+ *
62
+ * Two kinds of entry: (a) every method this connector actually calls, and (b) an endpoint the
63
+ * VENDOR documents in a distinct tier which a consumer can reach through the guarded client even
64
+ * though this connector never calls it (see the weights section of the header). Used to build the
65
+ * guarded surface — and, in the pack's own suite, the counting fake.
66
+ *
67
+ * NOT a closed list, and not a claim about the injected client's shape. A path the real client does
68
+ * not have is SKIPPED (this connector's members are optional; inventing one would turn "observe
69
+ * nothing" into "call something that isn't there"), and a method absent from this list is still
70
+ * PRICED at `defaultWeight` when a caller reaches for it — an unmodeled endpoint must never be
71
+ * free, and dropping one would be worse than free because it would be invisible.
72
+ */
73
+ export const PINECONE_BUDGETED_METHODS = [
74
+ 'listIndexes',
75
+ 'listVectors',
76
+ ];
77
+ /** THE PACK'S DECLARATION — pure data, the only Pinecone-specific thing in the whole budget. */
78
+ export const PINECONE_RATE_BUDGET = {
79
+ windowMs: PINECONE_BUDGET_WINDOW_MS,
80
+ ceiling: PINECONE_BUDGET_CEILING,
81
+ defaultWeight: PINECONE_CALL_WEIGHTS.other,
82
+ maxRetryAfterSeconds: PINECONE_BUDGET_MAX_RETRY_AFTER_S,
83
+ // Ordered: the kernel prices FIRST-MATCH-WINS, so the tightest tier is listed first.
84
+ rules: [
85
+ { match: "(^|\\.)listVectors$", weight: PINECONE_CALL_WEIGHTS.fanout },
86
+ ],
87
+ reason: "Pinecone publishes a detailed DATA-plane limits table (per namespace/s: query/upsert/delete/update 100, " +
88
+ "by-metadata mutations only 5; per index/s: List 200, Fetch 100) but NO limit at all for the CONTROL-plane " +
89
+ "listIndexes/describeIndex this connector calls. With no documented figure for the endpoint actually used, " +
90
+ "this ceiling is pinned to the kernel's conservative fallback (60 units / 60s at weight 2 = 30 calls/min) " +
91
+ "rather than borrowed from the looser data-plane rows — no more permissive than an undeclared vendor " +
92
+ "already gets. listVectors costs 4 because it is this pack's own cross-index, per-namespace paginated " +
93
+ "aggregation, not a single vendor endpoint — a judgement call, not a published cost. Pinecone's limits page " +
94
+ "does not document Retry-After; the 429/exhaustion cooldown is the backstop.",
95
+ };
96
+ // Declared at module load, so merely importing this module (which `pinecone-connector.ts` does) is
97
+ // enough to arm the real ceiling. A budget constructed BEFORE this runs falls back to the kernel's
98
+ // DEFAULT_RATE_BUDGET — which is tighter in call COUNT but prices every call at 2, so for a vendor
99
+ // with an expensive endpoint the fallback is CHEAPER there, not safer. `RateBudget` reads its policy
100
+ // LIVE precisely so this declaration takes effect the moment it lands, and constructing through the
101
+ // subclass below (whose module IS this one) makes the ordering a non-issue in practice.
102
+ declareRateBudget(VENDOR, PINECONE_RATE_BUDGET);
103
+ /** Price one Pinecone call by its client method key (a dotted path, e.g. `listIndexes`). */
104
+ export function pineconeCallWeight(method) {
105
+ return rateBudgetWeight(VENDOR, method);
106
+ }
107
+ /** Where Pinecone's ledger lives. Token-keyed and cwd-independent by default (the vendor limits per
108
+ * credential, so a cwd-scoped ledger would hand the same credential a fresh allowance in every
109
+ * checkout, worktree and CI matrix leg); pass `root` to opt into world-scoped accounting. */
110
+ export function pineconeBudgetPath(opts = {}) {
111
+ const o = typeof opts === 'string' ? { root: opts } : opts;
112
+ // VENDOR spread LAST: a loosely-typed `{ vendor: 'other', … }` slipping through (TypeScript's
113
+ // excess-property check only catches object literals) must not redirect this pack's ledger to
114
+ // another vendor's file.
115
+ return rateBudgetPath({ ...o, vendor: VENDOR });
116
+ }
117
+ /**
118
+ * Pinecone's budget — the shared kernel guard bound to this vendor's declaration. A real subclass,
119
+ * not an alias, so `budget instanceof PineconeBudget` means "a budget that accounts against this
120
+ * vendor's ledger under this vendor's ceiling": another vendor's `RateBudget` (with its own,
121
+ * possibly larger, ceiling) is NOT assignable where one of these is required.
122
+ */
123
+ export class PineconeBudget extends RateBudget {
124
+ constructor(opts = {}) {
125
+ super({ ...opts, vendor: VENDOR });
126
+ }
127
+ }
128
+ export { RateBudgetError as PineconeBudgetError } from '@volter/world-core';
129
+ /** Pull the budget wiring out of a caller's opts bag, so an entrypoint can forward it verbatim. */
130
+ export function pineconeBudgetOf(opts) {
131
+ return {
132
+ ...(opts.budget !== undefined ? { budget: opts.budget } : {}),
133
+ ...(opts.budgetOptions !== undefined ? { budgetOptions: opts.budgetOptions } : {}),
134
+ };
135
+ }
136
+ // ── the choke point ─────────────────────────────────────────────────────────────────────────
137
+ /**
138
+ * Marks a client this module has already wrapped, so guarding twice cannot charge twice.
139
+ *
140
+ * A MODULE-PRIVATE `Symbol()`, deliberately not `Symbol.for()`: a global-registry symbol is
141
+ * reachable BY NAME, so any caller could stamp `client[Symbol.for(…)] = anything` on a RAW client and
142
+ * the guard would hand it straight back UNGUARDED — a one-line bypass of the whole budget. With a
143
+ * private symbol the only way to be branded is to have been wrapped by this function. The cost is
144
+ * that two copies of this module in one dependency tree would each wrap (double-charging a call);
145
+ * that is the SAFE direction, and over-charging is the tradeoff this module takes everywhere else.
146
+ */
147
+ const GUARDED = Symbol('@volter/twin-pinecone.budget.guarded');
148
+ /** Is this client already behind a budget? Returns the budget it is behind, if so. */
149
+ export function pineconeClientBudget(client) {
150
+ const mark = client?.[GUARDED];
151
+ // Belt and braces: only a REAL budget counts as "already guarded". A non-RateBudget value here
152
+ // could only come from a forged brand, and the answer to a forgery is to wrap anyway.
153
+ return mark instanceof RateBudget ? mark : undefined;
154
+ }
155
+ /**
156
+ * Wrap an INJECTED Pinecone client so EVERY call it makes is charged against the shared budget
157
+ * BEFORE the request goes out. This pack's connector never constructs the transport itself (the
158
+ * consumer injects a client that satisfies `PineconeLikeClient` structurally), so the guard is a
159
+ * DECORATOR rather than a factory — which is exactly why every connector entrypoint applies it
160
+ * UNCONDITIONALLY instead of trusting the caller to have done it.
161
+ *
162
+ * IDEMPOTENT: wrapping an already-guarded client returns it unchanged, so a caller who forgot is
163
+ * protected and a caller who wrapped deliberately is not double-charged.
164
+ *
165
+ * A method that THROWS is still inspected: an SDK typically RAISES on a 429 rather than returning
166
+ * it, and that error's back-off is exactly the signal that must become a persisted cooldown. Losing
167
+ * it would leave the ledger cheerfully spending into a throttled credential. The original error is
168
+ * always re-raised afterwards — the budget never swallows a vendor failure — EXCEPT when the
169
+ * back-off is beyond the cap, where the budget's own louder "stop calling" error takes precedence.
170
+ */
171
+ export function guardPineconeClient(client, opts = {}) {
172
+ // There is no value a caller can pass to end up with an UNGUARDED client. `null`/`undefined` (or
173
+ // omitting it) build the default budget; anything that is not a REAL `PineconeBudget` is refused
174
+ // loudly rather than trusted — a duck-typed stand-in with a no-op `checkBudget` would otherwise be
175
+ // the one clean way around the guard. Validated BEFORE the already-guarded early return, so
176
+ // `guardPineconeClient(alreadyGuarded, { budget: impostor })` is refused too rather than silently
177
+ // ignoring the impostor.
178
+ if (opts.budget !== undefined && opts.budget !== null && !(opts.budget instanceof PineconeBudget)) {
179
+ throw new Error('guardPineconeClient: `budget` must be a PineconeBudget — refusing to guard a Pinecone client with an unverified rate guard');
180
+ }
181
+ if (pineconeClientBudget(client))
182
+ return client;
183
+ const budget = opts.budget instanceof PineconeBudget
184
+ ? opts.budget
185
+ : new PineconeBudget({
186
+ // The default ledger is keyed by a hash of the credential — the vendor limits per credential,
187
+ // so a cwd-scoped ledger would hand it a fresh allowance per worktree/CI leg.
188
+ //
189
+ // HONESTLY: this pack does NOT hold the credential — the consumer's injected client does — so
190
+ // `PINECONE_API_KEY` is a BEST-EFFORT stand-in for it, not the real thing. If that env var names a
191
+ // different account than the injected client, spend is booked against the wrong ledger; if it
192
+ // is unset, every unattributed Pinecone credential on the machine shares one (over-tight,
193
+ // which is the safe direction). A caller who knows the credential should say so:
194
+ // `budgetOptions: { token }` overrides this, and does so deliberately last in the spread.
195
+ ...(process.env.PINECONE_API_KEY !== undefined ? { token: process.env.PINECONE_API_KEY } : {}),
196
+ ...(opts.budgetOptions ?? {}),
197
+ });
198
+ /** Settle a reservation from whatever the call produced. May THROW (a back-off past the cap). */
199
+ const settle = (weight, reservation, v) => {
200
+ const status = responseStatus(v);
201
+ const headers = responseHeaders(v);
202
+ if (status !== undefined || headers !== undefined)
203
+ budget.recordCall(weight, headers, { status, reservation });
204
+ else
205
+ budget.recordCall(weight, undefined, { reservation });
206
+ };
207
+ /**
208
+ * Settle once the call RESOLVED: the vendor has answered. recordCall arms any cooldown before
209
+ * it throws (a back-off beyond the cap), so that refusal is swallowed and the answer kept — a
210
+ * write the vendor accepted is never reported failed and performed again on retry. A resolved
211
+ * answer that carries a non-2xx status still lets the louder refusal win.
212
+ */
213
+ const settleAnswered = (weight, reservation, v) => {
214
+ try {
215
+ settle(weight, reservation, v);
216
+ }
217
+ catch (e) {
218
+ const status = responseStatus(v);
219
+ if (!(e instanceof RateBudgetError) || (status !== undefined && (status < 200 || status >= 300)))
220
+ throw e;
221
+ }
222
+ };
223
+ /**
224
+ * Charge, call, settle — for a MODELED method, whose interface declares it `async`. Refusing
225
+ * REJECTS rather than throwing synchronously, so `client.x().catch(…)` behaves exactly as it does
226
+ * on an unguarded client. `checkBudget` RESERVES under lock, so nothing after its line runs when
227
+ * the budget refuses: the request is never made.
228
+ */
229
+ const chargeAsync = (method, invoke) => async (...args) => {
230
+ const weight = budget.weightFor(method);
231
+ const reservation = budget.checkBudget(weight);
232
+ try {
233
+ const res = await invoke(...args);
234
+ settleAnswered(weight, reservation, res);
235
+ return res;
236
+ }
237
+ catch (e) {
238
+ settle(weight, reservation, e); // may throw its own louder refusal, which wins
239
+ throw e;
240
+ }
241
+ };
242
+ /**
243
+ * Charge, call, settle — for an UNMODELED member reached through the passthrough Proxy, where the
244
+ * shape is unknown.
245
+ *
246
+ * Deliberately NOT `async`. Some vendor SDKs (twilio-shaped ones) build requests through
247
+ * SYNCHRONOUS chained accessors — `client.a.b('sid').c.create()` — where the intermediate calls
248
+ * return a resource context, not a promise. An `async` wrapper would turn every one of those into
249
+ * a `Promise` and `.c` would come back `undefined`: the guard would BREAK the client instead of
250
+ * guarding it. So a non-thenable return is treated as an accessor — still charged (we cannot know
251
+ * before calling, and over-charging is the safe direction) and wrapped, so the eventual async leaf
252
+ * is charged too rather than escaping the budget. The cost of the sync shape is that a REFUSAL on
253
+ * this path throws synchronously instead of rejecting; that is the honest signal for an accessor,
254
+ * and the modeled surface above (every method this connector actually calls) does not have it.
255
+ */
256
+ const charge = (method, invoke) => (...args) => {
257
+ const weight = budget.weightFor(method);
258
+ const reservation = budget.checkBudget(weight);
259
+ let out;
260
+ try {
261
+ out = invoke(...args);
262
+ }
263
+ catch (e) {
264
+ settle(weight, reservation, e); // may throw its own louder refusal, which wins
265
+ throw e;
266
+ }
267
+ if (!isThenable(out)) {
268
+ settle(weight, reservation, undefined);
269
+ return out !== null && (typeof out === 'object' || typeof out === 'function')
270
+ ? proxyThrough({}, out, method, charge)
271
+ : out;
272
+ }
273
+ return out.then((res) => { settleAnswered(weight, reservation, res); return res; }, (e) => { settle(weight, reservation, e); throw e; });
274
+ };
275
+ // Build the charged surface from PINECONE_BUDGETED_METHODS (see its docstring for why an absent path is
276
+ // SKIPPED rather than stubbed).
277
+ const guarded = {};
278
+ for (const path of PINECONE_BUDGETED_METHODS) {
279
+ const segs = path.split('.');
280
+ const leaf = segs[segs.length - 1];
281
+ let owner = client;
282
+ for (const seg of segs.slice(0, -1))
283
+ owner = owner?.[seg];
284
+ if (typeof owner?.[leaf] !== 'function')
285
+ continue;
286
+ const realOwner = owner;
287
+ let node = guarded;
288
+ for (const seg of segs.slice(0, -1))
289
+ node = (node[seg] ??= {});
290
+ // The method is resolved at CALL time, not here, so a client whose method is swapped later is
291
+ // still charged for whatever it actually runs.
292
+ node[leaf] = chargeAsync(path, (...args) => realOwner[leaf].apply(realOwner, args));
293
+ }
294
+ Object.defineProperty(guarded, GUARDED, { value: budget, enumerable: false });
295
+ // The surface above is what this connector calls. A real client has MORE — and a consumer who
296
+ // needs any of it must not be forced to keep the RAW client alongside, because every call through
297
+ // that would be unbudgeted. So the guarded object is a Proxy: known members come from the map
298
+ // above, anything else is taken from the real client and PRICED at `defaultWeight`.
299
+ return proxyThrough(guarded, client, '', charge);
300
+ }
301
+ /**
302
+ * Members JavaScript itself asks for. Wrapping any of these turns the object into something that
303
+ * looks thenable / mis-reports its own identity, which breaks `await`, `instanceof` and logging —
304
+ * so they always come from the target untouched, never priced.
305
+ */
306
+ const NEVER_WRAP = new Set(['then', 'catch', 'finally', 'constructor', 'prototype', 'toJSON', 'toString', 'valueOf', 'inspect']);
307
+ /** Does this look like a promise? (Only a thenable gets the settle-on-resolution treatment.) */
308
+ function isThenable(v) {
309
+ return v !== null && (typeof v === 'object' || typeof v === 'function') && typeof v.then === 'function';
310
+ }
311
+ /**
312
+ * Symbols that name an ITERATION PROTOCOL. Reaching for one of these on a vendor object is how a
313
+ * paginator is driven (`for await (const page of client.things.list())`), i.e. it is the doorway to
314
+ * an unbounded sequence of REQUESTS — exactly what this budget exists to bound — so they are charged
315
+ * and their result is kept behind the proxy. Every other symbol (`Symbol.toStringTag`,
316
+ * `nodejs.util.inspect.custom`, …) is metadata rather than a request and passes through untouched.
317
+ */
318
+ const ITERATOR_SYMBOLS = new Set([Symbol.asyncIterator, Symbol.iterator]);
319
+ /**
320
+ * Serve `known` where it has the member; otherwise price a passthrough to `real`. Applied
321
+ * recursively, so a namespace member this pack never modeled is charged at `defaultWeight` rather
322
+ * than coming back `undefined`.
323
+ *
324
+ * CALLABLE NAMESPACES (§9 finding): a member can be BOTH a function and a namespace — twilio's
325
+ * `client.messages` is called as `client.messages(sid)` to get one message's context AND read as
326
+ * `client.messages.list()`. An earlier version returned the modeled node as a plain object whenever
327
+ * this pack modeled any child of it, which silently DROPPED the call signature and every unmodeled
328
+ * sibling — the module's own docstring calls a dropped member "worse than free, because it is
329
+ * invisible", and that is what it was doing. So when `real` is callable the proxy target is a
330
+ * function and an `apply` trap charges the call, while `known` stays the source of modeled members.
331
+ */
332
+ function proxyThrough(known, real, prefix, charge, owner) {
333
+ const callable = typeof real === 'function';
334
+ // The target must itself be callable for the `apply` trap to exist at all. `known` stays the
335
+ // source of modeled members, read explicitly below rather than through the target.
336
+ const target = callable ? function proxied() { } : known;
337
+ return new Proxy(target, {
338
+ apply(_t, _thisArg, args) {
339
+ // Calling the namespace is itself a request-builder hop: charge it, and keep the result
340
+ // behind the proxy (charge() re-proxies a non-thenable) so the eventual leaf is charged too.
341
+ // `owner` is the object the function was read from — dropping it would silently break every
342
+ // method that relies on `this`.
343
+ return charge(prefix || 'call', (...a) => real.apply(owner, a))(...args);
344
+ },
345
+ get(_t, prop, receiver) {
346
+ if (typeof prop === 'symbol') {
347
+ const ownSym = Reflect.get(known, prop, receiver);
348
+ if (ownSym !== undefined)
349
+ return ownSym; // the GUARDED brand, and anything we model
350
+ const fromSym = real?.[prop];
351
+ if (ITERATOR_SYMBOLS.has(prop) && typeof fromSym === 'function') {
352
+ return charge(`${prefix}[${prop.description ?? 'iterator'}]`, (...args) => fromSym.apply(real, args));
353
+ }
354
+ return fromSym;
355
+ }
356
+ const name = String(prop);
357
+ if (NEVER_WRAP.has(name))
358
+ return Reflect.get(known, prop, receiver);
359
+ const key = prefix ? `${prefix}.${name}` : name;
360
+ const own = Reflect.get(known, prop, receiver);
361
+ const from = real?.[name];
362
+ // A member we model: the charged wrapper (a function) or a namespace we must keep descending
363
+ // into, so an unmodeled sibling is still priced rather than dropped.
364
+ if (typeof own === 'function')
365
+ return own;
366
+ if (own && typeof own === 'object') {
367
+ // `from` may be an object OR a CALLABLE namespace — both keep descending, which is what
368
+ // preserves `client.messages(sid)` alongside the modeled `client.messages.list()`.
369
+ return from && (typeof from === 'object' || typeof from === 'function')
370
+ ? proxyThrough(own, from, key, charge, real)
371
+ : own;
372
+ }
373
+ if (own !== undefined)
374
+ return own;
375
+ // A member only the real client has. Functions go through proxyThrough too, so one that also
376
+ // carries members (a callable namespace) keeps both its call signature and its siblings.
377
+ if (typeof from === 'function')
378
+ return proxyThrough({}, from, key, charge, real);
379
+ if (from && typeof from === 'object')
380
+ return proxyThrough({}, from, key, charge, real);
381
+ return from;
382
+ },
383
+ has(_t, prop) {
384
+ return Reflect.has(known, prop) || (real !== null && Reflect.has(real, prop));
385
+ },
386
+ });
387
+ }
388
+ /** The HTTP status a value carries, if it looks like one (an SDK error, or a raw response). */
389
+ function responseStatus(v) {
390
+ const s = v?.status;
391
+ return typeof s === 'number' && Number.isFinite(s) ? s : undefined;
392
+ }
393
+ /**
394
+ * Response/error headers as a plain lower-cased record, or `undefined` when there are none. Accepts
395
+ * a `Headers` instance, a `Map`, or a plain object — an SDK's error type changes shape across
396
+ * versions and none of the three is worth depending on.
397
+ */
398
+ function responseHeaders(v) {
399
+ const h = v?.headers;
400
+ if (!h || typeof h !== 'object')
401
+ return undefined;
402
+ const out = {};
403
+ if (typeof h.forEach === 'function') {
404
+ h.forEach((value, key) => { out[String(key).toLowerCase()] = String(value); });
405
+ }
406
+ else {
407
+ for (const [k, value] of Object.entries(h))
408
+ out[k.toLowerCase()] = String(value);
409
+ }
410
+ return Object.keys(out).length > 0 ? out : undefined;
411
+ }
@@ -0,0 +1,4 @@
1
+ import { type CapabilityReport, type CapabilitySpec } from '@volter/world-tooling';
2
+ export declare const PINECONE_CAPABILITIES: CapabilitySpec[];
3
+ export declare const PINECONE_AREAS: readonly ["indexes", "collections", "vectors", "query", "namespaces", "filters", "stats", "control_plane", "data_plane", "auth", "pagination", "errors", "connector", "conformance", "safety", "state"];
4
+ export declare function pineconeCapabilities(): Promise<CapabilityReport>;