@seanhogg/builderforce-memory 2026.9.30 → 2026.9.31
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/bridges/FetchBridge.d.ts +12 -5
- package/dist/bridges/FetchBridge.d.ts.map +1 -1
- package/dist/bridges/FetchBridge.js +6 -4
- package/dist/bridges/FetchBridge.js.map +1 -1
- package/dist/bridges/OpenAIBridge.d.ts +17 -4
- package/dist/bridges/OpenAIBridge.d.ts.map +1 -1
- package/dist/bridges/OpenAIBridge.js +68 -57
- package/dist/bridges/OpenAIBridge.js.map +1 -1
- package/dist/bridges/TransformerBridge.d.ts +6 -0
- package/dist/bridges/TransformerBridge.d.ts.map +1 -1
- package/dist/wire/chatClient.d.ts +100 -0
- package/dist/wire/chatClient.d.ts.map +1 -0
- package/dist/wire/chatClient.js +123 -0
- package/dist/wire/chatClient.js.map +1 -0
- package/dist/wire/index.d.ts +3 -1
- package/dist/wire/index.d.ts.map +1 -1
- package/dist/wire/index.js +2 -1
- package/dist/wire/index.js.map +1 -1
- package/dist/wire/sse.d.ts +17 -9
- package/dist/wire/sse.d.ts.map +1 -1
- package/dist/wire/sse.js +45 -22
- package/dist/wire/sse.js.map +1 -1
- package/package.json +3 -3
- package/src/bridges/FetchBridge.ts +15 -6
- package/src/bridges/OpenAIBridge.ts +82 -72
- package/src/bridges/TransformerBridge.ts +6 -0
- package/src/wire/chatClient.ts +196 -0
- package/src/wire/index.ts +3 -1
- package/src/wire/sse.ts +43 -21
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* FetchBridge – generic OpenAI-compatible bridge for local or hosted endpoints.
|
|
3
3
|
*
|
|
4
|
-
* Works with Ollama, LM Studio, vLLM, llama.cpp server, or any
|
|
5
|
-
* exposes a /chat/completions endpoint compatible with the OpenAI
|
|
6
|
-
* and response schema.
|
|
4
|
+
* Works with Ollama, LM Studio, vLLM, llama.cpp server, a routing gateway, or any
|
|
5
|
+
* service that exposes a /chat/completions endpoint compatible with the OpenAI
|
|
6
|
+
* request and response schema.
|
|
7
7
|
*/
|
|
8
8
|
import { OpenAIBridge } from './OpenAIBridge.js';
|
|
9
9
|
import type { BridgeGenerateOptions } from './TransformerBridge.js';
|
|
@@ -12,12 +12,19 @@ export interface FetchBridgeOptions {
|
|
|
12
12
|
baseUrl: string;
|
|
13
13
|
/** API key — many local servers require any non-empty string. Default: 'local'. */
|
|
14
14
|
apiKey?: string;
|
|
15
|
-
/** Model name understood by the server. Default: 'default'. */
|
|
15
|
+
/** Model name understood by the server. Default: 'default' (none with `serverDefaults`). */
|
|
16
16
|
model?: string;
|
|
17
17
|
/** Default system prompt. */
|
|
18
18
|
systemPrompt?: string;
|
|
19
|
-
/** Default max tokens. Default: 512. */
|
|
19
|
+
/** Default max tokens. Default: 512 (none with `serverDefaults`). */
|
|
20
20
|
maxTokens?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Send only what a call states, so a routing gateway picks the model and the
|
|
23
|
+
* sampling settings. Default false.
|
|
24
|
+
*/
|
|
25
|
+
serverDefaults?: boolean;
|
|
26
|
+
/** Abort a request after this long. */
|
|
27
|
+
timeoutMs?: number;
|
|
21
28
|
}
|
|
22
29
|
/**
|
|
23
30
|
* FetchBridge is a thin re-configuration of OpenAIBridge pointed at a custom
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetchBridge.d.ts","sourceRoot":"","sources":["../../src/bridges/FetchBridge.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEpE,MAAM,WAAW,kBAAkB;IAC/B,iFAAiF;IACjF,OAAO,EAAS,MAAM,CAAC;IACvB,mFAAmF;IACnF,MAAM,CAAC,EAAS,MAAM,CAAC;IACvB
|
|
1
|
+
{"version":3,"file":"FetchBridge.d.ts","sourceRoot":"","sources":["../../src/bridges/FetchBridge.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEpE,MAAM,WAAW,kBAAkB;IAC/B,iFAAiF;IACjF,OAAO,EAAS,MAAM,CAAC;IACvB,mFAAmF;IACnF,MAAM,CAAC,EAAS,MAAM,CAAC;IACvB,4FAA4F;IAC5F,KAAK,CAAC,EAAU,MAAM,CAAC;IACvB,6BAA6B;IAC7B,YAAY,CAAC,EAAG,MAAM,CAAC;IACvB,qEAAqE;IACrE,SAAS,CAAC,EAAM,MAAM,CAAC;IACvB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,uCAAuC;IACvC,SAAS,CAAC,EAAM,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,qBAAa,WAAY,SAAQ,YAAY;gBAC7B,IAAI,EAAE,kBAAkB;CAWvC;AAED,YAAY,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* FetchBridge – generic OpenAI-compatible bridge for local or hosted endpoints.
|
|
3
3
|
*
|
|
4
|
-
* Works with Ollama, LM Studio, vLLM, llama.cpp server, or any
|
|
5
|
-
* exposes a /chat/completions endpoint compatible with the OpenAI
|
|
6
|
-
* and response schema.
|
|
4
|
+
* Works with Ollama, LM Studio, vLLM, llama.cpp server, a routing gateway, or any
|
|
5
|
+
* service that exposes a /chat/completions endpoint compatible with the OpenAI
|
|
6
|
+
* request and response schema.
|
|
7
7
|
*/
|
|
8
8
|
import { OpenAIBridge } from './OpenAIBridge.js';
|
|
9
9
|
/**
|
|
@@ -14,10 +14,12 @@ export class FetchBridge extends OpenAIBridge {
|
|
|
14
14
|
constructor(opts) {
|
|
15
15
|
super({
|
|
16
16
|
apiKey: opts.apiKey ?? 'local',
|
|
17
|
-
model: opts.model ?? 'default',
|
|
17
|
+
model: opts.model ?? (opts.serverDefaults ? undefined : 'default'),
|
|
18
18
|
baseUrl: opts.baseUrl,
|
|
19
19
|
systemPrompt: opts.systemPrompt,
|
|
20
20
|
maxTokens: opts.maxTokens,
|
|
21
|
+
serverDefaults: opts.serverDefaults,
|
|
22
|
+
timeoutMs: opts.timeoutMs,
|
|
21
23
|
});
|
|
22
24
|
}
|
|
23
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetchBridge.js","sourceRoot":"","sources":["../../src/bridges/FetchBridge.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"FetchBridge.js","sourceRoot":"","sources":["../../src/bridges/FetchBridge.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAuBjD;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,YAAY;IACzC,YAAY,IAAwB;QAChC,KAAK,CAAC;YACF,MAAM,EAAS,IAAI,CAAC,MAAM,IAAW,OAAO;YAC5C,KAAK,EAAU,IAAI,CAAC,KAAK,IAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;YAClF,OAAO,EAAQ,IAAI,CAAC,OAAO;YAC3B,YAAY,EAAG,IAAI,CAAC,YAAY;YAChC,SAAS,EAAM,IAAI,CAAC,SAAS;YAC7B,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,SAAS,EAAM,IAAI,CAAC,SAAS;SAChC,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Supports both non-streaming and streaming (SSE) completions.
|
|
5
5
|
* Compatible with any OpenAI-compatible endpoint via the `baseUrl` option.
|
|
6
|
+
*
|
|
7
|
+
* The request, error mapping and stream reading are the `/wire` chat client's — the
|
|
8
|
+
* same one a host uses for tool-calling turns — so this class only supplies the
|
|
9
|
+
* bridge's defaults and maps usage onto {@link LlmUsage}.
|
|
6
10
|
*/
|
|
7
11
|
import type { TransformerBridge, BridgeGenerateOptions, BridgeCallInfo } from './TransformerBridge.js';
|
|
8
12
|
export interface OpenAIBridgeOptions {
|
|
@@ -16,21 +20,30 @@ export interface OpenAIBridgeOptions {
|
|
|
16
20
|
systemPrompt?: string;
|
|
17
21
|
/** Default max tokens. Default: 512. */
|
|
18
22
|
maxTokens?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Send only what a call states — no model, max-tokens, temperature or top-p
|
|
25
|
+
* defaults — so a routing gateway picks them. Default false.
|
|
26
|
+
*/
|
|
27
|
+
serverDefaults?: boolean;
|
|
28
|
+
/** Abort a request after this long. */
|
|
29
|
+
timeoutMs?: number;
|
|
19
30
|
}
|
|
20
31
|
export declare class OpenAIBridge implements TransformerBridge {
|
|
21
32
|
private _lastCall;
|
|
22
33
|
readonly supportsStreaming: true;
|
|
23
|
-
private readonly
|
|
34
|
+
private readonly _client;
|
|
24
35
|
private readonly _model;
|
|
25
|
-
private readonly _baseUrl;
|
|
26
36
|
private readonly _systemPrompt;
|
|
27
37
|
private readonly _maxTokens;
|
|
38
|
+
private readonly _serverDefaults;
|
|
28
39
|
constructor(opts: OpenAIBridgeOptions);
|
|
29
40
|
/** Provider-reported usage for the last call — see {@link BridgeCallInfo}. */
|
|
30
41
|
get lastCall(): BridgeCallInfo | undefined;
|
|
31
42
|
generate(prompt: string, opts?: BridgeGenerateOptions): Promise<string>;
|
|
32
43
|
stream(prompt: string, opts?: BridgeGenerateOptions): AsyncIterable<string>;
|
|
33
|
-
|
|
34
|
-
private
|
|
44
|
+
/** Text deltas out; the closing event records usage (sent because of `includeUsage`). */
|
|
45
|
+
private _text;
|
|
46
|
+
private _request;
|
|
47
|
+
private _requestError;
|
|
35
48
|
}
|
|
36
49
|
//# sourceMappingURL=OpenAIBridge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAIBridge.d.ts","sourceRoot":"","sources":["../../src/bridges/OpenAIBridge.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"OpenAIBridge.d.ts","sourceRoot":"","sources":["../../src/bridges/OpenAIBridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAYvG,MAAM,WAAW,mBAAmB;IAChC,kDAAkD;IAClD,MAAM,EAAU,MAAM,CAAC;IACvB,4CAA4C;IAC5C,KAAK,CAAC,EAAU,MAAM,CAAC;IACvB,0DAA0D;IAC1D,OAAO,CAAC,EAAQ,MAAM,CAAC;IACvB,qDAAqD;IACrD,YAAY,CAAC,EAAG,MAAM,CAAC;IACvB,wCAAwC;IACxC,SAAS,CAAC,EAAM,MAAM,CAAC;IACvB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,uCAAuC;IACvC,SAAS,CAAC,EAAM,MAAM,CAAC;CAC1B;AAED,qBAAa,YAAa,YAAW,iBAAiB;IAClD,OAAO,CAAC,SAAS,CAA6B;IAE9C,QAAQ,CAAC,iBAAiB,EAAG,IAAI,CAAU;IAE3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAC3C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA4B;IACnD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAwB;IACnD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAU;gBAE9B,IAAI,EAAE,mBAAmB;IAYrC,8EAA8E;IAC9E,IAAI,QAAQ,IAAI,cAAc,GAAG,SAAS,CAEzC;IAEK,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,qBAA0B,GAAG,OAAO,CAAC,MAAM,CAAC;IAgB1E,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,qBAA0B,GAAG,aAAa,CAAC,MAAM,CAAC;IActF,yFAAyF;IACzF,OAAO,CAAE,KAAK;IAQd,OAAO,CAAC,QAAQ;IAoBhB,OAAO,CAAC,aAAa;CAWxB"}
|
|
@@ -3,97 +3,108 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Supports both non-streaming and streaming (SSE) completions.
|
|
5
5
|
* Compatible with any OpenAI-compatible endpoint via the `baseUrl` option.
|
|
6
|
+
*
|
|
7
|
+
* The request, error mapping and stream reading are the `/wire` chat client's — the
|
|
8
|
+
* same one a host uses for tool-calling turns — so this class only supplies the
|
|
9
|
+
* bridge's defaults and maps usage onto {@link LlmUsage}.
|
|
6
10
|
*/
|
|
7
11
|
import { SSMError } from '../errors/SSMError.js';
|
|
8
|
-
import {
|
|
12
|
+
import { chatComplete, chatStream, ChatCompletionError, readUsageFields, } from '../wire/index.js';
|
|
9
13
|
export class OpenAIBridge {
|
|
10
14
|
_lastCall;
|
|
11
15
|
supportsStreaming = true;
|
|
12
|
-
|
|
16
|
+
_client;
|
|
13
17
|
_model;
|
|
14
|
-
_baseUrl;
|
|
15
18
|
_systemPrompt;
|
|
16
19
|
_maxTokens;
|
|
20
|
+
_serverDefaults;
|
|
17
21
|
constructor(opts) {
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
|
|
22
|
+
this._serverDefaults = opts.serverDefaults ?? false;
|
|
23
|
+
this._client = {
|
|
24
|
+
apiKey: opts.apiKey,
|
|
25
|
+
baseUrl: opts.baseUrl ?? 'https://api.openai.com/v1',
|
|
26
|
+
...(opts.timeoutMs ? { timeoutMs: opts.timeoutMs } : {}),
|
|
27
|
+
};
|
|
28
|
+
this._model = opts.model ?? (this._serverDefaults ? undefined : 'gpt-4o-mini');
|
|
21
29
|
this._systemPrompt = opts.systemPrompt ?? '';
|
|
22
|
-
this._maxTokens = opts.maxTokens ?? 512;
|
|
30
|
+
this._maxTokens = opts.maxTokens ?? (this._serverDefaults ? undefined : 512);
|
|
23
31
|
}
|
|
24
32
|
/** Provider-reported usage for the last call — see {@link BridgeCallInfo}. */
|
|
25
33
|
get lastCall() {
|
|
26
34
|
return this._lastCall;
|
|
27
35
|
}
|
|
28
36
|
async generate(prompt, opts = {}) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const text = await res.text().catch(() => '');
|
|
33
|
-
throw new SSMError('BRIDGE_REQUEST_FAILED', `OpenAI API returned ${res.status}: ${text}`);
|
|
37
|
+
let result;
|
|
38
|
+
try {
|
|
39
|
+
result = await chatComplete(this._client, this._request(prompt, opts));
|
|
34
40
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
catch (err) {
|
|
42
|
+
throw this._requestError('OpenAI API', err);
|
|
43
|
+
}
|
|
44
|
+
if (!result.hasTextContent) {
|
|
38
45
|
throw new SSMError('BRIDGE_RESPONSE_INVALID', 'Unexpected OpenAI response shape.');
|
|
39
46
|
}
|
|
40
47
|
this._lastCall = {
|
|
41
|
-
usage: readOpenAIUsage(
|
|
48
|
+
usage: readOpenAIUsage(result.usage, result.model ?? opts.model ?? this._model ?? ''),
|
|
42
49
|
};
|
|
43
|
-
return content;
|
|
50
|
+
return result.content;
|
|
44
51
|
}
|
|
45
52
|
async *stream(prompt, opts = {}) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
let events;
|
|
54
|
+
try {
|
|
55
|
+
events = chatStream(this._client, { ...this._request(prompt, opts), includeUsage: true });
|
|
56
|
+
// The request is sent on the first pull; surface a failed request as a bridge error.
|
|
57
|
+
const first = await events.next();
|
|
58
|
+
if (first.done)
|
|
59
|
+
return;
|
|
60
|
+
yield* this._text(first.value);
|
|
51
61
|
}
|
|
52
|
-
|
|
53
|
-
throw
|
|
62
|
+
catch (err) {
|
|
63
|
+
throw this._requestError('OpenAI streaming API', err);
|
|
54
64
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
yield delta;
|
|
65
|
+
for await (const event of events)
|
|
66
|
+
yield* this._text(event);
|
|
67
|
+
}
|
|
68
|
+
/** Text deltas out; the closing event records usage (sent because of `includeUsage`). */
|
|
69
|
+
*_text(event) {
|
|
70
|
+
if (event.type === 'text-delta')
|
|
71
|
+
yield event.delta;
|
|
72
|
+
else if (event.type === 'done') {
|
|
73
|
+
const usage = readOpenAIUsage(event.result.usage, event.result.model ?? this._model ?? '');
|
|
74
|
+
this._lastCall = usage ? { usage } : {};
|
|
66
75
|
}
|
|
67
|
-
this._lastCall = usage ? { usage } : {};
|
|
68
76
|
}
|
|
69
|
-
|
|
77
|
+
_request(prompt, opts) {
|
|
70
78
|
const sys = opts.systemPrompt ?? this._systemPrompt;
|
|
71
79
|
const messages = [];
|
|
72
80
|
if (sys)
|
|
73
81
|
messages.push({ role: 'system', content: sys });
|
|
74
82
|
messages.push({ role: 'user', content: prompt });
|
|
75
|
-
|
|
76
|
-
|
|
83
|
+
const d = !this._serverDefaults;
|
|
84
|
+
const model = opts.model ?? this._model;
|
|
85
|
+
const maxTokens = opts.maxTokens ?? this._maxTokens;
|
|
86
|
+
const temperature = opts.temperature ?? (d ? 0.7 : undefined);
|
|
87
|
+
const topP = opts.topP ?? (d ? 0.9 : undefined);
|
|
88
|
+
return {
|
|
77
89
|
messages,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
// estimate. Non-streaming requests reject the field, hence the guard.
|
|
85
|
-
...(stream ? { stream_options: { include_usage: true } } : {}),
|
|
86
|
-
});
|
|
90
|
+
...(model ? { model } : {}),
|
|
91
|
+
...(maxTokens !== undefined ? { maxTokens } : {}),
|
|
92
|
+
...(temperature !== undefined ? { temperature } : {}),
|
|
93
|
+
...(topP !== undefined ? { topP } : {}),
|
|
94
|
+
...(opts.extra ? { extra: opts.extra } : {}),
|
|
95
|
+
};
|
|
87
96
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
_requestError(what, err) {
|
|
98
|
+
if (err instanceof SSMError)
|
|
99
|
+
return err;
|
|
100
|
+
if (err instanceof ChatCompletionError) {
|
|
101
|
+
// A 2xx that still failed is a stream with no body: the server answered, badly.
|
|
102
|
+
if (err.status >= 200 && err.status < 300) {
|
|
103
|
+
return new SSMError('BRIDGE_RESPONSE_INVALID', `${what} returned no response body.`);
|
|
104
|
+
}
|
|
105
|
+
return new SSMError('BRIDGE_REQUEST_FAILED', `${what} returned ${err.status}: ${err.body}`);
|
|
106
|
+
}
|
|
107
|
+
return new SSMError('BRIDGE_REQUEST_FAILED', `${what} request failed: ${err instanceof Error ? err.message : String(err)}`, err);
|
|
97
108
|
}
|
|
98
109
|
}
|
|
99
110
|
/** Maps an OpenAI `usage` object onto the canonical {@link LlmUsage} shape. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAIBridge.js","sourceRoot":"","sources":["../../src/bridges/OpenAIBridge.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"OpenAIBridge.js","sourceRoot":"","sources":["../../src/bridges/OpenAIBridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD,OAAO,EACH,YAAY,EACZ,UAAU,EACV,mBAAmB,EACnB,eAAe,GAKlB,MAAM,kBAAkB,CAAC;AAsB1B,MAAM,OAAO,YAAY;IACb,SAAS,CAA6B;IAErC,iBAAiB,GAAG,IAAa,CAAC;IAE1B,OA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G,eAAe,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,CAAC,CAAC,eAAe,IAAI,CAAC,CAAC;IACtC,OAAO;QACH,KAAK;QACL,2EAA2E;QAC3E,4EAA4E;QAC5E,WAAW,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC;QACxD,YAAY,EAAE,CAAC,CAAC,gBAAgB,IAAI,CAAC;QACrC,iBAAiB,EAAE,MAAM;KAC5B,CAAC;AACN,CAAC"}
|
|
@@ -19,6 +19,12 @@ export interface BridgeGenerateOptions {
|
|
|
19
19
|
systemPrompt?: string;
|
|
20
20
|
/** Model string, overriding the adapter's default. */
|
|
21
21
|
model?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Vendor extras merged into an OpenAI-compatible request body (a gateway's
|
|
24
|
+
* routing `provider`, `response_format`, …). Bridges that do not speak that
|
|
25
|
+
* wire format ignore it.
|
|
26
|
+
*/
|
|
27
|
+
extra?: Record<string, unknown>;
|
|
22
28
|
}
|
|
23
29
|
export interface TransformerBridge {
|
|
24
30
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransformerBridge.d.ts","sourceRoot":"","sources":["../../src/bridges/TransformerBridge.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,YAAY,EAAE,cAAc,EAAE,CAAC;AAE/B,MAAM,WAAW,qBAAqB;IAClC,mEAAmE;IACnE,SAAS,CAAC,EAAM,MAAM,CAAC;IACvB,iEAAiE;IACjE,WAAW,CAAC,EAAI,MAAM,CAAC;IACvB,+DAA+D;IAC/D,IAAI,CAAC,EAAW,MAAM,CAAC;IACvB,wEAAwE;IACxE,YAAY,CAAC,EAAG,MAAM,CAAC;IACvB,sDAAsD;IACtD,KAAK,CAAC,EAAU,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"TransformerBridge.d.ts","sourceRoot":"","sources":["../../src/bridges/TransformerBridge.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,YAAY,EAAE,cAAc,EAAE,CAAC;AAE/B,MAAM,WAAW,qBAAqB;IAClC,mEAAmE;IACnE,SAAS,CAAC,EAAM,MAAM,CAAC;IACvB,iEAAiE;IACjE,WAAW,CAAC,EAAI,MAAM,CAAC;IACvB,+DAA+D;IAC/D,IAAI,CAAC,EAAW,MAAM,CAAC;IACvB,wEAAwE;IACxE,YAAY,CAAC,EAAG,MAAM,CAAC;IACvB,sDAAsD;IACtD,KAAK,CAAC,EAAU,MAAM,CAAC;IACvB;;;;OAIG;IACH,KAAK,CAAC,EAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC3C;AAED,MAAM,WAAW,iBAAiB;IAC9B;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAExE;;;;;;;;;OASG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC;IAEnC;;;OAGG;IACH,MAAM,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,qBAAqB,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IAE7E,4DAA4D;IAC5D,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;CACvC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The OpenAI-compatible chat-completions client — ONE request builder, error mapping
|
|
3
|
+
* and stream reader for every caller that speaks `/chat/completions`: this package's
|
|
4
|
+
* `OpenAIBridge` / `FetchBridge`, and any host that reaches models through an
|
|
5
|
+
* OpenAI-compatible gateway (tools, streamed tool-call deltas, vendor extras).
|
|
6
|
+
*
|
|
7
|
+
* The body carries exactly what the request states — no sampling defaults are added
|
|
8
|
+
* here, so a routing gateway that picks the model and limits can be called with none.
|
|
9
|
+
* Callers that want defaults (the bridges) state them.
|
|
10
|
+
*
|
|
11
|
+
* Zero-dependency and engine-free (part of the `/wire` subpath).
|
|
12
|
+
*/
|
|
13
|
+
/** An OpenAI-compatible chat message. */
|
|
14
|
+
export interface ChatMessage {
|
|
15
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
16
|
+
/** Text, or an OpenAI multi-part array (text + `image_url`, …). */
|
|
17
|
+
content?: string | null | unknown[];
|
|
18
|
+
tool_calls?: unknown;
|
|
19
|
+
tool_call_id?: string;
|
|
20
|
+
[k: string]: unknown;
|
|
21
|
+
}
|
|
22
|
+
/** An OpenAI-compatible function-tool schema. */
|
|
23
|
+
export interface ChatToolSchema {
|
|
24
|
+
type: 'function';
|
|
25
|
+
function: {
|
|
26
|
+
name: string;
|
|
27
|
+
description: string;
|
|
28
|
+
parameters: Record<string, unknown>;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export interface ChatRequest {
|
|
32
|
+
messages: ChatMessage[];
|
|
33
|
+
tools?: ChatToolSchema[];
|
|
34
|
+
model?: string;
|
|
35
|
+
maxTokens?: number;
|
|
36
|
+
temperature?: number;
|
|
37
|
+
topP?: number;
|
|
38
|
+
/**
|
|
39
|
+
* On a stream, ask for the closing usage block (`stream_options.include_usage`).
|
|
40
|
+
* Opt-in: not every OpenAI-compatible server accepts the field.
|
|
41
|
+
*/
|
|
42
|
+
includeUsage?: boolean;
|
|
43
|
+
/** Vendor extras merged into the body last (a routing `provider`, `response_format`, …). */
|
|
44
|
+
extra?: Record<string, unknown>;
|
|
45
|
+
}
|
|
46
|
+
export interface ChatToolCall {
|
|
47
|
+
id?: string;
|
|
48
|
+
type?: string;
|
|
49
|
+
function?: {
|
|
50
|
+
name?: string;
|
|
51
|
+
arguments?: string;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export interface ChatResult {
|
|
55
|
+
/** The reply text ('' when there was none — e.g. a tool-call-only turn). */
|
|
56
|
+
content: string;
|
|
57
|
+
/** True when the server sent text content (a string), false when it sent none. */
|
|
58
|
+
hasTextContent: boolean;
|
|
59
|
+
toolCalls: ChatToolCall[];
|
|
60
|
+
finishReason?: string;
|
|
61
|
+
/** The model the server reports having used. */
|
|
62
|
+
model?: string;
|
|
63
|
+
/** The raw `usage` object, when the server sent one — read it with `readUsageFields`. */
|
|
64
|
+
usage?: unknown;
|
|
65
|
+
}
|
|
66
|
+
/** Incremental events of a streamed completion. */
|
|
67
|
+
export type ChatStreamEvent = {
|
|
68
|
+
type: 'text-delta';
|
|
69
|
+
delta: string;
|
|
70
|
+
} | {
|
|
71
|
+
type: 'tool-call';
|
|
72
|
+
index: number;
|
|
73
|
+
id?: string;
|
|
74
|
+
name?: string;
|
|
75
|
+
argsDelta?: string;
|
|
76
|
+
} | {
|
|
77
|
+
type: 'done';
|
|
78
|
+
result: ChatResult;
|
|
79
|
+
};
|
|
80
|
+
export interface ChatClient {
|
|
81
|
+
/** The OpenAI-style base, e.g. `https://api.openai.com/v1`; `/chat/completions` is appended. */
|
|
82
|
+
baseUrl: string;
|
|
83
|
+
apiKey: string;
|
|
84
|
+
/** Abort a request after this long. Default: no limit beyond the caller's signal. */
|
|
85
|
+
timeoutMs?: number;
|
|
86
|
+
}
|
|
87
|
+
/** A non-2xx answer, with the status and (bounded) body kept apart for the caller's message. */
|
|
88
|
+
export declare class ChatCompletionError extends Error {
|
|
89
|
+
readonly status: number;
|
|
90
|
+
readonly body: string;
|
|
91
|
+
constructor(status: number, body: string);
|
|
92
|
+
}
|
|
93
|
+
/** One non-streamed completion. Throws {@link ChatCompletionError} on a non-2xx answer. */
|
|
94
|
+
export declare function chatComplete(client: ChatClient, req: ChatRequest, signal?: AbortSignal): Promise<ChatResult>;
|
|
95
|
+
/**
|
|
96
|
+
* A streamed completion as events: text and tool-call deltas as they arrive, then one
|
|
97
|
+
* `done` carrying the assembled result (tool-call arguments concatenated per index).
|
|
98
|
+
*/
|
|
99
|
+
export declare function chatStream(client: ChatClient, req: ChatRequest, signal?: AbortSignal): AsyncGenerator<ChatStreamEvent>;
|
|
100
|
+
//# sourceMappingURL=chatClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatClient.d.ts","sourceRoot":"","sources":["../../src/wire/chatClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,yCAAyC;AACzC,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;IAC/C,mEAAmE;IACnE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,EAAE,CAAC;IACpC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,iDAAiD;AACjD,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;CACxF;AAED,MAAM,WAAW,WAAW;IACxB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,4FAA4F;IAC5F,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;A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sB,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAiBlH;AAED;;;GAGG;AACH,wBAAuB,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,cAAc,CAAC,eAAe,CAAC,CA+C7H"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The OpenAI-compatible chat-completions client — ONE request builder, error mapping
|
|
3
|
+
* and stream reader for every caller that speaks `/chat/completions`: this package's
|
|
4
|
+
* `OpenAIBridge` / `FetchBridge`, and any host that reaches models through an
|
|
5
|
+
* OpenAI-compatible gateway (tools, streamed tool-call deltas, vendor extras).
|
|
6
|
+
*
|
|
7
|
+
* The body carries exactly what the request states — no sampling defaults are added
|
|
8
|
+
* here, so a routing gateway that picks the model and limits can be called with none.
|
|
9
|
+
* Callers that want defaults (the bridges) state them.
|
|
10
|
+
*
|
|
11
|
+
* Zero-dependency and engine-free (part of the `/wire` subpath).
|
|
12
|
+
*/
|
|
13
|
+
import { readSseDataFrames } from './sse.js';
|
|
14
|
+
/** A non-2xx answer, with the status and (bounded) body kept apart for the caller's message. */
|
|
15
|
+
export class ChatCompletionError extends Error {
|
|
16
|
+
status;
|
|
17
|
+
body;
|
|
18
|
+
constructor(status, body) {
|
|
19
|
+
super(`chat completion failed with HTTP ${status}: ${body}`);
|
|
20
|
+
this.status = status;
|
|
21
|
+
this.body = body;
|
|
22
|
+
this.name = 'ChatCompletionError';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const ERROR_BODY_CHARS = 300;
|
|
26
|
+
function chatBody(req, stream) {
|
|
27
|
+
return JSON.stringify({
|
|
28
|
+
...(req.model ? { model: req.model } : {}),
|
|
29
|
+
messages: req.messages,
|
|
30
|
+
...(req.tools?.length ? { tools: req.tools, tool_choice: 'auto' } : {}),
|
|
31
|
+
...(typeof req.maxTokens === 'number' ? { max_tokens: req.maxTokens } : {}),
|
|
32
|
+
...(typeof req.temperature === 'number' ? { temperature: req.temperature } : {}),
|
|
33
|
+
...(typeof req.topP === 'number' ? { top_p: req.topP } : {}),
|
|
34
|
+
...(stream ? { stream: true } : {}),
|
|
35
|
+
// Without include_usage a streamed response carries no usage block at all.
|
|
36
|
+
...(stream && req.includeUsage ? { stream_options: { include_usage: true } } : {}),
|
|
37
|
+
...(req.extra ?? {}),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
async function post(client, req, stream, signal) {
|
|
41
|
+
const timeout = client.timeoutMs ? AbortSignal.timeout(client.timeoutMs) : undefined;
|
|
42
|
+
const res = await fetch(`${client.baseUrl.replace(/\/$/, '')}/chat/completions`, {
|
|
43
|
+
method: 'POST',
|
|
44
|
+
headers: {
|
|
45
|
+
'Content-Type': 'application/json',
|
|
46
|
+
Authorization: `Bearer ${client.apiKey}`,
|
|
47
|
+
...(stream ? { Accept: 'text/event-stream' } : {}),
|
|
48
|
+
},
|
|
49
|
+
body: chatBody(req, stream),
|
|
50
|
+
signal: signal && timeout ? AbortSignal.any([signal, timeout]) : (signal ?? timeout),
|
|
51
|
+
});
|
|
52
|
+
if (!res.ok || (stream && !res.body)) {
|
|
53
|
+
const body = await res.text().catch(() => '');
|
|
54
|
+
throw new ChatCompletionError(res.status, body.slice(0, ERROR_BODY_CHARS));
|
|
55
|
+
}
|
|
56
|
+
return res;
|
|
57
|
+
}
|
|
58
|
+
/** One non-streamed completion. Throws {@link ChatCompletionError} on a non-2xx answer. */
|
|
59
|
+
export async function chatComplete(client, req, signal) {
|
|
60
|
+
const res = await post(client, req, false, signal);
|
|
61
|
+
const json = (await res.json().catch(() => null));
|
|
62
|
+
const choice = json?.choices?.[0];
|
|
63
|
+
const msg = choice?.message;
|
|
64
|
+
return {
|
|
65
|
+
content: typeof msg?.content === 'string' ? msg.content : '',
|
|
66
|
+
hasTextContent: typeof msg?.content === 'string',
|
|
67
|
+
toolCalls: Array.isArray(msg?.tool_calls) ? msg.tool_calls : [],
|
|
68
|
+
finishReason: choice?.finish_reason,
|
|
69
|
+
...(typeof json?.model === 'string' ? { model: json.model } : {}),
|
|
70
|
+
...(json?.usage !== undefined ? { usage: json.usage } : {}),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A streamed completion as events: text and tool-call deltas as they arrive, then one
|
|
75
|
+
* `done` carrying the assembled result (tool-call arguments concatenated per index).
|
|
76
|
+
*/
|
|
77
|
+
export async function* chatStream(client, req, signal) {
|
|
78
|
+
const res = await post(client, req, true, signal);
|
|
79
|
+
let content = '';
|
|
80
|
+
let finishReason;
|
|
81
|
+
let model;
|
|
82
|
+
let usage;
|
|
83
|
+
const calls = [];
|
|
84
|
+
for await (const frame of readSseDataFrames(res.body)) {
|
|
85
|
+
const chunk = frame;
|
|
86
|
+
if (typeof chunk.model === 'string')
|
|
87
|
+
model = chunk.model;
|
|
88
|
+
if (chunk.usage)
|
|
89
|
+
usage = chunk.usage;
|
|
90
|
+
const choice = chunk.choices?.[0];
|
|
91
|
+
if (!choice)
|
|
92
|
+
continue;
|
|
93
|
+
if (choice.finish_reason)
|
|
94
|
+
finishReason = choice.finish_reason;
|
|
95
|
+
const delta = choice.delta;
|
|
96
|
+
if (typeof delta?.content === 'string' && delta.content) {
|
|
97
|
+
content += delta.content;
|
|
98
|
+
yield { type: 'text-delta', delta: delta.content };
|
|
99
|
+
}
|
|
100
|
+
for (const tc of Array.isArray(delta?.tool_calls) ? delta.tool_calls : []) {
|
|
101
|
+
const index = typeof tc.index === 'number' ? tc.index : 0;
|
|
102
|
+
const acc = (calls[index] ??= { args: '' });
|
|
103
|
+
if (tc.id)
|
|
104
|
+
acc.id = tc.id;
|
|
105
|
+
if (tc.function?.name)
|
|
106
|
+
acc.name = tc.function.name;
|
|
107
|
+
const argsDelta = tc.function?.arguments;
|
|
108
|
+
if (typeof argsDelta === 'string')
|
|
109
|
+
acc.args += argsDelta;
|
|
110
|
+
yield { type: 'tool-call', index, id: tc.id, name: tc.function?.name, argsDelta };
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const result = {
|
|
114
|
+
content,
|
|
115
|
+
hasTextContent: content !== '',
|
|
116
|
+
finishReason,
|
|
117
|
+
toolCalls: calls.filter(Boolean).map((t) => ({ id: t.id, type: 'function', function: { name: t.name, arguments: t.args } })),
|
|
118
|
+
...(model ? { model } : {}),
|
|
119
|
+
...(usage !== undefined ? { usage } : {}),
|
|
120
|
+
};
|
|
121
|
+
yield { type: 'done', result };
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=chatClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatClient.js","sourceRoot":"","sources":["../../src/wire/chatClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAmE7C,gGAAgG;AAChG,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACrB;IAAyB;IAA9C,YAAqB,MAAc,EAAW,IAAY;QACtD,KAAK,CAAC,oCAAoC,MAAM,KAAK,IAAI,EAAE,CAAC,CAAC;QAD5C,WAAM,GAAN,MAAM,CAAQ;QAAW,SAAI,GAAJ,IAAI,CAAQ;QAEtD,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACtC,CAAC;CACJ;AAED,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B,SAAS,QAAQ,CAAC,GAAgB,EAAE,MAAe;IAC/C,OAAO,IAAI,CAAC,SAAS,CAAC;QAClB,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1C,QAAQ,EAAE,GAAG,CAAC,QAAQ;QACtB,GAAG,CAAC,GAAG,CAAC,KAAK,E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AS,KAAK,QAAQ;gBAAE,GAAG,CAAC,IAAI,IAAI,SAAS,CAAC;YACzD,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QACtF,CAAC;IACL,CAAC;IAED,MAAM,MAAM,GAAe;QACvB,OAAO;QACP,cAAc,EAAE,OAAO,KAAK,EAAE;QAC9B,YAAY;QACZ,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC5H,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3B,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5C,CAAC;IACF,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AACnC,CAAC"}
|
package/dist/wire/index.d.ts
CHANGED
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
* these, so a fix to the line rule (a spaceless `data:{…}` frame, say) lands once.
|
|
13
13
|
* Zero-dependency and engine-free: the `@seanhogg/builderforce-memory/wire` subpath.
|
|
14
14
|
*/
|
|
15
|
-
export { parseSseDataLine, parseSseDataFrames, readSseDataFrames, isSseDoneLine } from './sse.js';
|
|
15
|
+
export { sseDataPayload, parseSseDataLine, parseSseDataFrames, readSseDataPayloads, readSseDataFrames, isSseDoneLine } from './sse.js';
|
|
16
16
|
export { finiteNumber, readUsageFields, AnthropicStreamUsage } from './usage.js';
|
|
17
17
|
export type { UsageFields, AnthropicUsageTotals } from './usage.js';
|
|
18
|
+
export { chatComplete, chatStream, ChatCompletionError } from './chatClient.js';
|
|
19
|
+
export type { ChatClient, ChatMessage, ChatToolSchema, ChatRequest, ChatToolCall, ChatResult, ChatStreamEvent } from './chatClient.js';
|
|
18
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/wire/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wire/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wire/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACvI,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACjF,YAAY,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAChF,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/wire/index.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* these, so a fix to the line rule (a spaceless `data:{…}` frame, say) lands once.
|
|
13
13
|
* Zero-dependency and engine-free: the `@seanhogg/builderforce-memory/wire` subpath.
|
|
14
14
|
*/
|
|
15
|
-
export { parseSseDataLine, parseSseDataFrames, readSseDataFrames, isSseDoneLine } from './sse.js';
|
|
15
|
+
export { sseDataPayload, parseSseDataLine, parseSseDataFrames, readSseDataPayloads, readSseDataFrames, isSseDoneLine } from './sse.js';
|
|
16
16
|
export { finiteNumber, readUsageFields, AnthropicStreamUsage } from './usage.js';
|
|
17
|
+
export { chatComplete, chatStream, ChatCompletionError } from './chatClient.js';
|
|
17
18
|
//# sourceMappingURL=index.js.map
|
package/dist/wire/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/wire/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/wire/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACvI,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEjF,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC"}
|