@jeffusion/bungee-llms 5.23.0 → 5.23.2

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.
@@ -2,3 +2,4 @@ export { TOKEN_ACCOUNTING_AUTHORITIES, assertCanonicalTokenAccountingEventV2, cr
2
2
  export type { CanonicalTokenAccountingEventV2 } from './token-accounting/types';
3
3
  export * from './responses-codec';
4
4
  export * from './protocol-session';
5
+ export { protocolRequestPath, protocolRequestModel } from './protocol-session/endpoint';
@@ -5242,6 +5242,48 @@ function validateStreamEnvelope(raw, protocol) {
5242
5242
  validateUsage(e.usage, protocol);
5243
5243
  }
5244
5244
  }
5245
+ // src/protocol-session/endpoint.ts
5246
+ function protocolRequestModel(protocol, body, url) {
5247
+ if (protocol === "gemini_generate_content") {
5248
+ let path;
5249
+ try {
5250
+ path = new URL(url).pathname;
5251
+ } catch {
5252
+ return fail("invalid_payload", "A valid Gemini target URL is required", "url");
5253
+ }
5254
+ const match = path.match(/\/models\/([^/]+):(?:streamGenerateContent|generateContent)$/);
5255
+ if (!match)
5256
+ return fail("invalid_payload", "Gemini target URL has no terminal model", "url");
5257
+ try {
5258
+ const model = decodeURIComponent(match[1]);
5259
+ if (model)
5260
+ return model;
5261
+ } catch {
5262
+ return fail("invalid_payload", "Gemini target model encoding is invalid", "url");
5263
+ }
5264
+ return fail("invalid_payload", "Gemini target model is required", "url");
5265
+ }
5266
+ const model = body?.model;
5267
+ if (typeof model !== "string" || !model)
5268
+ return fail("invalid_payload", "Target model is required", "model");
5269
+ return model;
5270
+ }
5271
+ function protocolRequestPath(protocol, model, streaming) {
5272
+ switch (protocol) {
5273
+ case "responses":
5274
+ return "/responses";
5275
+ case "chat_completions":
5276
+ return "/v1/chat/completions";
5277
+ case "anthropic_messages":
5278
+ return "/v1/messages";
5279
+ case "gemini_generate_content":
5280
+ if (typeof model !== "string" || !model)
5281
+ fail("invalid_payload", "Target model is required", "model");
5282
+ return `/v1beta/models/${encodeURIComponent(model)}:${streaming ? "streamGenerateContent" : "generateContent"}`;
5283
+ default:
5284
+ return fail("unsupported_protocol", "Unknown protocol");
5285
+ }
5286
+ }
5245
5287
  export {
5246
5288
  DEFAULT_RESPONSES_CODEC_LIMITS,
5247
5289
  LLM_PROTOCOLS,
@@ -5257,5 +5299,7 @@ export {
5257
5299
  encodeResponsesResult,
5258
5300
  getProviderTokenAccountingCapabilities,
5259
5301
  inspectAgentMessages,
5302
+ protocolRequestModel,
5303
+ protocolRequestPath,
5260
5304
  replaceAgentMessageEncryptedContent
5261
5305
  };
@@ -0,0 +1,5 @@
1
+ import type { LLMProtocol } from './types';
2
+ /** Read the actual generation model. Gemini's URL is authoritative, including base prefixes. */
3
+ export declare function protocolRequestModel(protocol: LLMProtocol, body: unknown, url?: string | URL): string;
4
+ /** Generation endpoint; Responses keeps the host/provider's /responses entry contract. */
5
+ export declare function protocolRequestPath(protocol: LLMProtocol, model: string, streaming: boolean): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jeffusion/bungee-llms",
3
- "version": "5.23.0",
3
+ "version": "5.23.2",
4
4
  "description": "Extensible LLM adapters and protocol conversion package for Bungee",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,7 +11,7 @@
11
11
  "prepublishOnly": "bun run build"
12
12
  },
13
13
  "dependencies": {
14
- "@jeffusion/bungee-types": "^5.23.0"
14
+ "@jeffusion/bungee-types": "^5.23.2"
15
15
  },
16
16
  "devDependencies": {
17
17
  "bun-types": "^1.3.2",