@jeffusion/bungee-llms 5.19.0 → 5.20.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/dist/index.d.ts +1 -0
- package/dist/index.js +916 -0
- package/dist/plugin-api.d.ts +1 -0
- package/dist/plugin-api.js +916 -0
- package/dist/responses-codec/common.d.ts +48 -0
- package/dist/responses-codec/events.d.ts +43 -0
- package/dist/responses-codec/index.d.ts +4 -0
- package/dist/responses-codec/request.d.ts +7 -0
- package/dist/responses-codec/result.d.ts +3 -0
- package/package.json +2 -2
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export type ResponsesProtocol = 'chat_completions' | 'anthropic_messages';
|
|
2
|
+
export type JsonRecord = Record<string, unknown>;
|
|
3
|
+
export interface ResponsesToolName {
|
|
4
|
+
name: string;
|
|
5
|
+
namespace?: string;
|
|
6
|
+
custom: boolean;
|
|
7
|
+
}
|
|
8
|
+
/** Per-request wire-name authority; never infer namespaces by splitting a provider name. */
|
|
9
|
+
export type ResponsesToolNames = ReadonlyMap<string, ResponsesToolName>;
|
|
10
|
+
export interface ResponsesCodecLimits {
|
|
11
|
+
maxRequestBytes: number;
|
|
12
|
+
maxOutputBytes: number;
|
|
13
|
+
maxArgumentBytes: number;
|
|
14
|
+
maxItems: number;
|
|
15
|
+
}
|
|
16
|
+
export declare const DEFAULT_RESPONSES_CODEC_LIMITS: Readonly<ResponsesCodecLimits>;
|
|
17
|
+
export interface ResponsesCodecCapabilities {
|
|
18
|
+
reasoningEffort?: boolean;
|
|
19
|
+
/** Explicit provider-approved thinking budget; do not guess budgets from effort labels. */
|
|
20
|
+
anthropicThinkingBudget?: number;
|
|
21
|
+
maxOutputTokens?: number;
|
|
22
|
+
limits?: Partial<ResponsesCodecLimits>;
|
|
23
|
+
}
|
|
24
|
+
export declare class ResponsesCodecError extends Error {
|
|
25
|
+
readonly code: string;
|
|
26
|
+
constructor(code: string, message: string);
|
|
27
|
+
}
|
|
28
|
+
export declare function fail(code: string, message: string): never;
|
|
29
|
+
export declare function record(value: unknown, where: string): JsonRecord;
|
|
30
|
+
export declare function string(value: unknown, where: string, nonempty?: boolean): string;
|
|
31
|
+
export declare function list(value: unknown, where: string): unknown[];
|
|
32
|
+
export declare function limits(overrides?: Partial<ResponsesCodecLimits>): ResponsesCodecLimits;
|
|
33
|
+
export declare function bytes(value: string): number;
|
|
34
|
+
export declare function bounded(value: string, max: number, where: string): string;
|
|
35
|
+
export declare function serialized(value: unknown, max: number, where: string): string;
|
|
36
|
+
export declare function argumentObject(text: string): JsonRecord;
|
|
37
|
+
export declare function restoreTool(name: string, names: ResponsesToolNames): ResponsesToolName;
|
|
38
|
+
export declare function customInput(text: string): string;
|
|
39
|
+
/** Decode only complete JSON-string characters. A split escape remains buffered. */
|
|
40
|
+
export declare function customInputPrefix(text: string): string;
|
|
41
|
+
export interface Terminal {
|
|
42
|
+
status: 'completed' | 'incomplete' | 'failed';
|
|
43
|
+
reason: string;
|
|
44
|
+
}
|
|
45
|
+
export declare function terminal(reason: unknown, protocol: ResponsesProtocol): Terminal;
|
|
46
|
+
export declare function normalizeUsage(raw: unknown, protocol: ResponsesProtocol, prior?: JsonRecord): JsonRecord;
|
|
47
|
+
export declare function toolItem(id: string, name: string, args: string, names: ResponsesToolNames, status?: string): JsonRecord;
|
|
48
|
+
export declare function responsePayload(id: string, model: string, output: JsonRecord[], end: Terminal, usage: JsonRecord, error?: unknown, createdAt?: number): JsonRecord;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type JsonRecord, type ResponsesCodecLimits, type ResponsesProtocol, type ResponsesToolNames } from './common';
|
|
2
|
+
/** Incremental payload codec. SSE framing and transport cancellation remain caller-owned.
|
|
3
|
+
* Chat terminal is deferred until finish() so trailing usage-only chunks are retained.
|
|
4
|
+
* Anthropic additionally requires message_stop, not merely a stop_reason in message_delta.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ResponsesEventEncoder {
|
|
7
|
+
readonly protocol: ResponsesProtocol;
|
|
8
|
+
readonly model: string;
|
|
9
|
+
readonly toolNames: ResponsesToolNames;
|
|
10
|
+
private readonly budget;
|
|
11
|
+
private readonly id;
|
|
12
|
+
private readonly createdAt;
|
|
13
|
+
private readonly output;
|
|
14
|
+
private readonly states;
|
|
15
|
+
private readonly anthropicBlocks;
|
|
16
|
+
private usage;
|
|
17
|
+
private end?;
|
|
18
|
+
private error?;
|
|
19
|
+
private started;
|
|
20
|
+
private anthropicStarted;
|
|
21
|
+
private anthropicStopped;
|
|
22
|
+
private finalized;
|
|
23
|
+
private poisoned;
|
|
24
|
+
private sequence;
|
|
25
|
+
private retained;
|
|
26
|
+
constructor(protocol: ResponsesProtocol, model: string, toolNames?: ResponsesToolNames, configuredLimits?: Partial<ResponsesCodecLimits>);
|
|
27
|
+
private event;
|
|
28
|
+
private start;
|
|
29
|
+
private retain;
|
|
30
|
+
private state;
|
|
31
|
+
private fields;
|
|
32
|
+
private item;
|
|
33
|
+
private part;
|
|
34
|
+
private add;
|
|
35
|
+
private appendText;
|
|
36
|
+
private emitArgs;
|
|
37
|
+
private toolDelta;
|
|
38
|
+
push(raw: unknown): JsonRecord[];
|
|
39
|
+
private chat;
|
|
40
|
+
private anthropic;
|
|
41
|
+
private complete;
|
|
42
|
+
finish(): JsonRecord[];
|
|
43
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { decodeResponsesRequest, type DecodedResponsesRequest } from './request';
|
|
2
|
+
export { encodeResponsesResult } from './result';
|
|
3
|
+
export { ResponsesEventEncoder } from './events';
|
|
4
|
+
export { ResponsesCodecError, DEFAULT_RESPONSES_CODEC_LIMITS, type ResponsesProtocol, type ResponsesToolName, type ResponsesToolNames, type ResponsesCodecCapabilities, type ResponsesCodecLimits } from './common';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type JsonRecord, type ResponsesCodecCapabilities, type ResponsesProtocol, type ResponsesToolNames } from './common';
|
|
2
|
+
export interface DecodedResponsesRequest {
|
|
3
|
+
body: JsonRecord;
|
|
4
|
+
toolNames: ResponsesToolNames;
|
|
5
|
+
}
|
|
6
|
+
/** Converts only self-contained history. Reference resolution belongs to the caller. */
|
|
7
|
+
export declare function decodeResponsesRequest(raw: unknown, protocol: ResponsesProtocol, capabilities?: ResponsesCodecCapabilities): DecodedResponsesRequest;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type JsonRecord, type ResponsesCodecLimits, type ResponsesProtocol, type ResponsesToolNames } from './common';
|
|
2
|
+
/** JSON and SSE share the same validation and item/terminal semantics. */
|
|
3
|
+
export declare function encodeResponsesResult(raw: unknown, protocol: ResponsesProtocol, model: string, toolNames?: ResponsesToolNames, configuredLimits?: Partial<ResponsesCodecLimits>): JsonRecord;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jeffusion/bungee-llms",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.20.0",
|
|
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.
|
|
14
|
+
"@jeffusion/bungee-types": "^5.20.0"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"bun-types": "^1.3.2",
|