@bodhiapp/bodhi-browser-types 0.0.30 → 0.0.32

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.
@@ -110,6 +110,25 @@ export interface BodhiExtPublicApi {
110
110
  * @returns ReadableStream yielding StreamChunk objects
111
111
  */
112
112
  sendStreamRequest<TReq = unknown>(method: string, endpoint: string, body?: TReq, headers?: Record<string, string>): ReadableStream<StreamChunk>;
113
+ /**
114
+ * Send a raw text streaming request through the extension.
115
+ *
116
+ * Unlike sendStreamRequest which parses SSE/JSON, this forwards raw response
117
+ * bytes as text strings without any parsing. Returns response metadata (status,
118
+ * headers) plus a ReadableStream of raw text chunks.
119
+ *
120
+ * @template TReq - Request body type (inferred from body parameter)
121
+ * @param method - HTTP method
122
+ * @param endpoint - API endpoint path
123
+ * @param body - Optional request body
124
+ * @param headers - Optional additional headers
125
+ * @returns Promise with status, headers, and ReadableStream<string> body
126
+ */
127
+ sendStreamText<TReq = unknown>(method: string, endpoint: string, body?: TReq, headers?: Record<string, string>): Promise<{
128
+ status: number;
129
+ headers: Record<string, string>;
130
+ body: ReadableStream<string>;
131
+ }>;
113
132
  /**
114
133
  * Send a generic extension request.
115
134
  *
package/dist/common.d.ts CHANGED
@@ -32,6 +32,7 @@ export type ConnectionErrorType = (typeof ERROR_TYPES)[keyof typeof ERROR_TYPES]
32
32
  export declare const DOCUMENT_STATE_COMPLETE = "complete";
33
33
  export declare const EVENT_INITIALIZED = "bodhiext:initialized";
34
34
  export declare const BODHI_STREAM_PORT = "BODHI_STREAM_PORT";
35
+ export declare const BODHI_STREAM_TEXT_PORT = "BODHI_STREAM_TEXT_PORT";
35
36
  export declare const ORIGIN_WILDCARD = "*";
36
37
  export declare const ERROR_MISSING_REQUEST_ID = "Invalid message format: missing requestId or request";
37
38
  export declare const ERROR_CONNECTION_CLOSED = "Connection closed unexpectedly";
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export type { ApiResponse, StreamChunk, ServerStateInfo, ChatCompletionsApi, ChatApi, BodhiExtPublicApi } from './bodhiext';
2
2
  export { BodhiError, BodhiApiError, unwrapResponse, type BodhiErrorCode } from './errors';
3
- export type { ApiRequest, ApiRequestMessage, OperationErrorResponse, ApiResponseSuccessMessage, OperationErrorResponseMessage, ApiResponseMessage, ErrorMessage, StreamChunkMessage, StreamApiErrorMessage, StreamErrorMessage, StreamMessage, StreamController, SSEChunk, ExtRequest, ExtRequestMessage, ExtError, ExtErrorResponse, ExtResponse, ExtResponseMessage, GetExtensionIdRequest, GetExtensionIdResponse, TestConnectionRequest, TestConnectionResponse, } from './protocol';
3
+ export type { ApiRequest, ApiRequestMessage, OperationErrorResponse, ApiResponseSuccessMessage, OperationErrorResponseMessage, ApiResponseMessage, ErrorMessage, StreamChunkMessage, StreamApiErrorMessage, StreamErrorMessage, StreamMessage, StreamTextStartMessage, StreamTextChunkMessage, StreamTextDoneMessage, StreamTextErrorMessage, StreamTextMessage, StreamController, SSEChunk, ExtRequest, ExtRequestMessage, ExtError, ExtErrorResponse, ExtResponse, ExtResponseMessage, GetExtensionIdRequest, GetExtensionIdResponse, TestConnectionRequest, TestConnectionResponse, } from './protocol';
4
4
  export { MESSAGE_TYPES, isOperationErrorResponse, isApiErrorResponse, isApiSuccessResponse, isStreamChunk, isStreamApiError, isStreamError, isExtError, isOpenAiApiErrorBody, isOperationErrorStructure, } from './protocol';
5
- export { CONTENT_TYPE_JSON, CONTENT_TYPE_EVENT_STREAM, CONTENT_TYPE_HEADER, HTTP_METHOD_GET, HTTP_METHOD_POST, ENDPOINT_PING, ENDPOINT_CHAT_COMPLETIONS, DEFAULT_API_BASE_URL, DEFAULT_API_TIMEOUT, DEFAULT_STREAM_TIMEOUT, STORAGE_KEY_BACKEND_URL, SSE_DONE_MARKER, SSE_DATA_PREFIX, SSE_CHUNK_DELIMITER, EXT_ACTIONS, ERROR_TYPES, DOCUMENT_STATE_COMPLETE, EVENT_INITIALIZED, BODHI_STREAM_PORT, ORIGIN_WILDCARD, ERROR_MISSING_REQUEST_ID, ERROR_CONNECTION_CLOSED, } from './common';
5
+ export { CONTENT_TYPE_JSON, CONTENT_TYPE_EVENT_STREAM, CONTENT_TYPE_HEADER, HTTP_METHOD_GET, HTTP_METHOD_POST, ENDPOINT_PING, ENDPOINT_CHAT_COMPLETIONS, DEFAULT_API_BASE_URL, DEFAULT_API_TIMEOUT, DEFAULT_STREAM_TIMEOUT, STORAGE_KEY_BACKEND_URL, SSE_DONE_MARKER, SSE_DATA_PREFIX, SSE_CHUNK_DELIMITER, EXT_ACTIONS, ERROR_TYPES, DOCUMENT_STATE_COMPLETE, EVENT_INITIALIZED, BODHI_STREAM_PORT, BODHI_STREAM_TEXT_PORT, ORIGIN_WILDCARD, ERROR_MISSING_REQUEST_ID, ERROR_CONNECTION_CLOSED, } from './common';
6
6
  export type { ConnectionErrorType } from './common';
package/dist/index.js CHANGED
@@ -40,6 +40,11 @@ const MESSAGE_TYPES = {
40
40
  STREAM_CHUNK: "BODHI_STREAM_CHUNK",
41
41
  STREAM_ERROR: "BODHI_STREAM_ERROR",
42
42
  STREAM_API_ERROR: "BODHI_STREAM_API_ERROR",
43
+ STREAM_TEXT_REQUEST: "BODHI_STREAM_TEXT_REQUEST",
44
+ STREAM_TEXT_START: "BODHI_STREAM_TEXT_START",
45
+ STREAM_TEXT_CHUNK: "BODHI_STREAM_TEXT_CHUNK",
46
+ STREAM_TEXT_DONE: "BODHI_STREAM_TEXT_DONE",
47
+ STREAM_TEXT_ERROR: "BODHI_STREAM_TEXT_ERROR",
43
48
  ERROR: "BODHI_ERROR",
44
49
  EXT_REQUEST: "BODHI_EXT_REQUEST",
45
50
  EXT_RESPONSE: "BODHI_EXT_RESPONSE"
@@ -92,11 +97,13 @@ const ERROR_TYPES = {
92
97
  const DOCUMENT_STATE_COMPLETE = "complete";
93
98
  const EVENT_INITIALIZED = "bodhiext:initialized";
94
99
  const BODHI_STREAM_PORT = "BODHI_STREAM_PORT";
100
+ const BODHI_STREAM_TEXT_PORT = "BODHI_STREAM_TEXT_PORT";
95
101
  const ORIGIN_WILDCARD = "*";
96
102
  const ERROR_MISSING_REQUEST_ID = "Invalid message format: missing requestId or request";
97
103
  const ERROR_CONNECTION_CLOSED = "Connection closed unexpectedly";
98
104
  export {
99
105
  BODHI_STREAM_PORT,
106
+ BODHI_STREAM_TEXT_PORT,
100
107
  BodhiApiError,
101
108
  BodhiError,
102
109
  CONTENT_TYPE_EVENT_STREAM,
@@ -17,6 +17,11 @@ export declare const MESSAGE_TYPES: {
17
17
  readonly STREAM_CHUNK: "BODHI_STREAM_CHUNK";
18
18
  readonly STREAM_ERROR: "BODHI_STREAM_ERROR";
19
19
  readonly STREAM_API_ERROR: "BODHI_STREAM_API_ERROR";
20
+ readonly STREAM_TEXT_REQUEST: "BODHI_STREAM_TEXT_REQUEST";
21
+ readonly STREAM_TEXT_START: "BODHI_STREAM_TEXT_START";
22
+ readonly STREAM_TEXT_CHUNK: "BODHI_STREAM_TEXT_CHUNK";
23
+ readonly STREAM_TEXT_DONE: "BODHI_STREAM_TEXT_DONE";
24
+ readonly STREAM_TEXT_ERROR: "BODHI_STREAM_TEXT_ERROR";
20
25
  readonly ERROR: "BODHI_ERROR";
21
26
  readonly EXT_REQUEST: "BODHI_EXT_REQUEST";
22
27
  readonly EXT_RESPONSE: "BODHI_EXT_RESPONSE";
@@ -133,6 +138,44 @@ export declare function isStreamApiError(msg: StreamMessage): msg is StreamApiEr
133
138
  * Type guard for stream error
134
139
  */
135
140
  export declare function isStreamError(msg: StreamMessage): msg is StreamErrorMessage;
141
+ /**
142
+ * Stream text start message — response metadata (status + headers)
143
+ * Sent once before any STREAM_TEXT_CHUNK messages
144
+ */
145
+ export interface StreamTextStartMessage {
146
+ type: typeof MESSAGE_TYPES.STREAM_TEXT_START;
147
+ requestId: string;
148
+ status: number;
149
+ headers: Record<string, string>;
150
+ }
151
+ /**
152
+ * Stream text chunk message — raw text from response body
153
+ * No SSE parsing, no JSON.parse, no data: prefix stripping
154
+ */
155
+ export interface StreamTextChunkMessage {
156
+ type: typeof MESSAGE_TYPES.STREAM_TEXT_CHUNK;
157
+ requestId: string;
158
+ chunk: string;
159
+ }
160
+ /**
161
+ * Stream text done message — stream completed
162
+ */
163
+ export interface StreamTextDoneMessage {
164
+ type: typeof MESSAGE_TYPES.STREAM_TEXT_DONE;
165
+ requestId: string;
166
+ }
167
+ /**
168
+ * Stream text error message — network/extension level error
169
+ */
170
+ export interface StreamTextErrorMessage {
171
+ type: typeof MESSAGE_TYPES.STREAM_TEXT_ERROR;
172
+ requestId: string;
173
+ error: OperationErrorResponse;
174
+ }
175
+ /**
176
+ * Union type for all stream text messages
177
+ */
178
+ export type StreamTextMessage = StreamTextStartMessage | StreamTextChunkMessage | StreamTextDoneMessage | StreamTextErrorMessage;
136
179
  /**
137
180
  * Interface for stream controller to handle SSE responses
138
181
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bodhiapp/bodhi-browser-types",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
4
4
  "description": "TypeScript types for Bodhi Browser Extension",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",