@jsonstudio/llms 0.4.4 → 0.4.5

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.
Files changed (159) hide show
  1. package/dist/conversion/codec-registry.js +11 -1
  2. package/dist/conversion/codecs/anthropic-openai-codec.d.ts +13 -0
  3. package/dist/conversion/codecs/anthropic-openai-codec.js +18 -473
  4. package/dist/conversion/codecs/gemini-openai-codec.js +91 -48
  5. package/dist/conversion/codecs/responses-openai-codec.js +9 -2
  6. package/dist/conversion/hub/format-adapters/anthropic-format-adapter.js +3 -0
  7. package/dist/conversion/hub/format-adapters/chat-format-adapter.js +3 -0
  8. package/dist/conversion/hub/format-adapters/gemini-format-adapter.js +3 -0
  9. package/dist/conversion/hub/format-adapters/responses-format-adapter.d.ts +19 -0
  10. package/dist/conversion/hub/format-adapters/responses-format-adapter.js +9 -0
  11. package/dist/conversion/hub/node-support.js +3 -1
  12. package/dist/conversion/hub/pipeline/hub-pipeline.js +37 -32
  13. package/dist/conversion/hub/response/provider-response.js +1 -1
  14. package/dist/conversion/hub/response/response-mappers.js +1 -1
  15. package/dist/conversion/hub/response/response-runtime.js +109 -10
  16. package/dist/conversion/hub/semantic-mappers/anthropic-mapper.js +70 -156
  17. package/dist/conversion/hub/semantic-mappers/chat-mapper.js +63 -52
  18. package/dist/conversion/hub/semantic-mappers/gemini-mapper.js +76 -143
  19. package/dist/conversion/hub/semantic-mappers/responses-mapper.js +40 -160
  20. package/dist/conversion/hub/standardized-bridge.js +3 -0
  21. package/dist/conversion/hub/tool-governance/rules.js +2 -2
  22. package/dist/conversion/index.d.ts +5 -0
  23. package/dist/conversion/index.js +5 -0
  24. package/dist/conversion/pipeline/codecs/v2/anthropic-openai-pipeline.d.ts +12 -0
  25. package/dist/conversion/pipeline/codecs/v2/anthropic-openai-pipeline.js +100 -0
  26. package/dist/conversion/pipeline/codecs/v2/openai-openai-pipeline.d.ts +15 -0
  27. package/dist/conversion/pipeline/codecs/v2/openai-openai-pipeline.js +174 -0
  28. package/dist/conversion/pipeline/codecs/v2/responses-openai-pipeline.d.ts +14 -0
  29. package/dist/conversion/pipeline/codecs/v2/responses-openai-pipeline.js +166 -0
  30. package/dist/conversion/pipeline/codecs/v2/shared/openai-chat-helpers.d.ts +13 -0
  31. package/dist/conversion/pipeline/codecs/v2/shared/openai-chat-helpers.js +66 -0
  32. package/dist/conversion/pipeline/hooks/adapter-context.d.ts +7 -0
  33. package/dist/conversion/pipeline/hooks/adapter-context.js +18 -0
  34. package/dist/conversion/pipeline/hooks/protocol-hooks.d.ts +67 -0
  35. package/dist/conversion/pipeline/hooks/protocol-hooks.js +1 -0
  36. package/dist/conversion/pipeline/index.d.ts +35 -0
  37. package/dist/conversion/pipeline/index.js +103 -0
  38. package/dist/conversion/pipeline/meta/meta-bag.d.ts +20 -0
  39. package/dist/conversion/pipeline/meta/meta-bag.js +81 -0
  40. package/dist/conversion/pipeline/schema/canonical-chat.d.ts +18 -0
  41. package/dist/conversion/pipeline/schema/canonical-chat.js +1 -0
  42. package/dist/conversion/pipeline/schema/index.d.ts +1 -0
  43. package/dist/conversion/pipeline/schema/index.js +1 -0
  44. package/dist/conversion/responses/responses-openai-bridge.d.ts +48 -0
  45. package/dist/conversion/responses/responses-openai-bridge.js +157 -1146
  46. package/dist/conversion/shared/anthropic-message-utils.d.ts +12 -0
  47. package/dist/conversion/shared/anthropic-message-utils.js +587 -0
  48. package/dist/conversion/shared/bridge-actions.d.ts +39 -0
  49. package/dist/conversion/shared/bridge-actions.js +709 -0
  50. package/dist/conversion/shared/bridge-conversation-store.d.ts +41 -0
  51. package/dist/conversion/shared/bridge-conversation-store.js +279 -0
  52. package/dist/conversion/shared/bridge-id-utils.d.ts +7 -0
  53. package/dist/conversion/shared/bridge-id-utils.js +42 -0
  54. package/dist/conversion/shared/bridge-instructions.d.ts +1 -0
  55. package/dist/conversion/shared/bridge-instructions.js +113 -0
  56. package/dist/conversion/shared/bridge-message-types.d.ts +39 -0
  57. package/dist/conversion/shared/bridge-message-types.js +1 -0
  58. package/dist/conversion/shared/bridge-message-utils.d.ts +22 -0
  59. package/dist/conversion/shared/bridge-message-utils.js +473 -0
  60. package/dist/conversion/shared/bridge-metadata.d.ts +1 -0
  61. package/dist/conversion/shared/bridge-metadata.js +1 -0
  62. package/dist/conversion/shared/bridge-policies.d.ts +18 -0
  63. package/dist/conversion/shared/bridge-policies.js +276 -0
  64. package/dist/conversion/shared/bridge-request-adapter.d.ts +28 -0
  65. package/dist/conversion/shared/bridge-request-adapter.js +430 -0
  66. package/dist/conversion/shared/chat-output-normalizer.d.ts +4 -0
  67. package/dist/conversion/shared/chat-output-normalizer.js +56 -0
  68. package/dist/conversion/shared/chat-request-filters.js +24 -1
  69. package/dist/conversion/shared/gemini-tool-utils.d.ts +5 -0
  70. package/dist/conversion/shared/gemini-tool-utils.js +130 -0
  71. package/dist/conversion/shared/metadata-passthrough.d.ts +11 -0
  72. package/dist/conversion/shared/metadata-passthrough.js +57 -0
  73. package/dist/conversion/shared/output-content-normalizer.d.ts +12 -0
  74. package/dist/conversion/shared/output-content-normalizer.js +119 -0
  75. package/dist/conversion/shared/reasoning-normalizer.d.ts +21 -0
  76. package/dist/conversion/shared/reasoning-normalizer.js +368 -0
  77. package/dist/conversion/shared/reasoning-tool-normalizer.d.ts +12 -0
  78. package/dist/conversion/shared/reasoning-tool-normalizer.js +132 -0
  79. package/dist/conversion/shared/reasoning-tool-parser.d.ts +10 -0
  80. package/dist/conversion/shared/reasoning-tool-parser.js +95 -0
  81. package/dist/conversion/shared/reasoning-utils.d.ts +2 -0
  82. package/dist/conversion/shared/reasoning-utils.js +42 -0
  83. package/dist/conversion/shared/responses-conversation-store.js +5 -11
  84. package/dist/conversion/shared/responses-message-utils.d.ts +15 -0
  85. package/dist/conversion/shared/responses-message-utils.js +206 -0
  86. package/dist/conversion/shared/responses-output-builder.d.ts +15 -0
  87. package/dist/conversion/shared/responses-output-builder.js +179 -0
  88. package/dist/conversion/shared/responses-output-utils.d.ts +7 -0
  89. package/dist/conversion/shared/responses-output-utils.js +108 -0
  90. package/dist/conversion/shared/responses-request-adapter.d.ts +28 -0
  91. package/dist/conversion/shared/responses-request-adapter.js +9 -40
  92. package/dist/conversion/shared/responses-response-utils.d.ts +3 -0
  93. package/dist/conversion/shared/responses-response-utils.js +209 -0
  94. package/dist/conversion/shared/responses-tool-utils.d.ts +12 -0
  95. package/dist/conversion/shared/responses-tool-utils.js +90 -0
  96. package/dist/conversion/shared/responses-types.d.ts +33 -0
  97. package/dist/conversion/shared/responses-types.js +1 -0
  98. package/dist/conversion/shared/tool-call-utils.d.ts +11 -0
  99. package/dist/conversion/shared/tool-call-utils.js +56 -0
  100. package/dist/conversion/shared/tool-mapping.d.ts +19 -0
  101. package/dist/conversion/shared/tool-mapping.js +124 -0
  102. package/dist/conversion/shared/tool-normalizers.d.ts +4 -0
  103. package/dist/conversion/shared/tool-normalizers.js +84 -0
  104. package/dist/router/virtual-router/bootstrap.js +18 -3
  105. package/dist/router/virtual-router/provider-registry.js +4 -2
  106. package/dist/router/virtual-router/types.d.ts +212 -0
  107. package/dist/sse/index.d.ts +38 -2
  108. package/dist/sse/index.js +27 -0
  109. package/dist/sse/json-to-sse/anthropic-json-to-sse-converter.d.ts +14 -0
  110. package/dist/sse/json-to-sse/anthropic-json-to-sse-converter.js +106 -73
  111. package/dist/sse/json-to-sse/chat-json-to-sse-converter.js +6 -2
  112. package/dist/sse/json-to-sse/gemini-json-to-sse-converter.d.ts +14 -0
  113. package/dist/sse/json-to-sse/gemini-json-to-sse-converter.js +99 -0
  114. package/dist/sse/json-to-sse/index.d.ts +7 -0
  115. package/dist/sse/json-to-sse/index.js +2 -0
  116. package/dist/sse/json-to-sse/sequencers/anthropic-sequencer.d.ts +13 -0
  117. package/dist/sse/json-to-sse/sequencers/anthropic-sequencer.js +150 -0
  118. package/dist/sse/json-to-sse/sequencers/chat-sequencer.d.ts +39 -0
  119. package/dist/sse/json-to-sse/sequencers/chat-sequencer.js +49 -3
  120. package/dist/sse/json-to-sse/sequencers/gemini-sequencer.d.ts +10 -0
  121. package/dist/sse/json-to-sse/sequencers/gemini-sequencer.js +95 -0
  122. package/dist/sse/json-to-sse/sequencers/responses-sequencer.js +31 -5
  123. package/dist/sse/registry/sse-codec-registry.d.ts +32 -0
  124. package/dist/sse/registry/sse-codec-registry.js +30 -1
  125. package/dist/sse/shared/reasoning-dispatcher.d.ts +10 -0
  126. package/dist/sse/shared/reasoning-dispatcher.js +25 -0
  127. package/dist/sse/shared/responses-output-normalizer.d.ts +12 -0
  128. package/dist/sse/shared/responses-output-normalizer.js +45 -0
  129. package/dist/sse/shared/serializers/anthropic-event-serializer.d.ts +2 -0
  130. package/dist/sse/shared/serializers/anthropic-event-serializer.js +9 -0
  131. package/dist/sse/shared/serializers/gemini-event-serializer.d.ts +2 -0
  132. package/dist/sse/shared/serializers/gemini-event-serializer.js +5 -0
  133. package/dist/sse/shared/serializers/index.d.ts +41 -0
  134. package/dist/sse/shared/serializers/index.js +2 -0
  135. package/dist/sse/shared/writer.d.ts +127 -0
  136. package/dist/sse/shared/writer.js +37 -1
  137. package/dist/sse/sse-to-json/anthropic-sse-to-json-converter.d.ts +11 -0
  138. package/dist/sse/sse-to-json/anthropic-sse-to-json-converter.js +92 -127
  139. package/dist/sse/sse-to-json/builders/anthropic-response-builder.d.ts +16 -0
  140. package/dist/sse/sse-to-json/builders/anthropic-response-builder.js +151 -0
  141. package/dist/sse/sse-to-json/builders/response-builder.d.ts +165 -0
  142. package/dist/sse/sse-to-json/builders/response-builder.js +27 -6
  143. package/dist/sse/sse-to-json/chat-sse-to-json-converter.d.ts +114 -0
  144. package/dist/sse/sse-to-json/chat-sse-to-json-converter.js +79 -3
  145. package/dist/sse/sse-to-json/gemini-sse-to-json-converter.d.ts +13 -0
  146. package/dist/sse/sse-to-json/gemini-sse-to-json-converter.js +160 -0
  147. package/dist/sse/sse-to-json/index.d.ts +7 -0
  148. package/dist/sse/sse-to-json/index.js +2 -0
  149. package/dist/sse/sse-to-json/parsers/sse-parser.js +53 -1
  150. package/dist/sse/types/anthropic-types.d.ts +170 -0
  151. package/dist/sse/types/anthropic-types.js +8 -5
  152. package/dist/sse/types/chat-types.d.ts +10 -0
  153. package/dist/sse/types/chat-types.js +2 -1
  154. package/dist/sse/types/core-interfaces.d.ts +1 -1
  155. package/dist/sse/types/gemini-types.d.ts +116 -0
  156. package/dist/sse/types/gemini-types.js +5 -0
  157. package/dist/sse/types/index.d.ts +5 -2
  158. package/dist/sse/types/index.js +2 -0
  159. package/package.json +1 -1
@@ -0,0 +1,35 @@
1
+ import { type CanonicalChatRequest, type CanonicalChatResponse } from './schema/index.js';
2
+ import { type ProtocolPipelineHooks, type ProtocolPipelineContext, type ProtocolValidationErrorDetail } from './hooks/protocol-hooks.js';
3
+ import { ConversionMetaBag, type ConversionMetaInput } from './meta/meta-bag.js';
4
+ export interface ProtocolInboundPipelineOptions<TWire> {
5
+ payload: TWire;
6
+ context?: ProtocolPipelineContext;
7
+ meta?: ConversionMetaInput;
8
+ }
9
+ export interface ProtocolOutboundPipelineOptions<TCanonical> {
10
+ canonical: TCanonical;
11
+ context?: ProtocolPipelineContext;
12
+ meta?: ConversionMetaInput;
13
+ }
14
+ export interface ProtocolInboundPipelineResult<TCanonical> {
15
+ canonical: TCanonical;
16
+ meta: ConversionMetaBag;
17
+ context: ProtocolPipelineContext;
18
+ }
19
+ export interface ProtocolOutboundPipelineResult<TWire> {
20
+ payload: TWire;
21
+ meta: ConversionMetaBag;
22
+ context: ProtocolPipelineContext;
23
+ }
24
+ export declare class PipelineValidationError extends Error {
25
+ readonly stage: string;
26
+ readonly errors: ProtocolValidationErrorDetail[];
27
+ constructor(stage: string, errors: ProtocolValidationErrorDetail[]);
28
+ }
29
+ export declare class ProtocolConversionPipeline<TInboundWire = Record<string, unknown>, TOutboundWire = Record<string, unknown>, TCanonicalInbound = CanonicalChatRequest, TCanonicalOutbound = CanonicalChatResponse> {
30
+ private readonly hooks;
31
+ constructor(hooks: ProtocolPipelineHooks<TInboundWire, TOutboundWire, TCanonicalInbound, TCanonicalOutbound>);
32
+ convertInbound(options: ProtocolInboundPipelineOptions<TInboundWire>): Promise<ProtocolInboundPipelineResult<TCanonicalInbound>>;
33
+ convertOutbound(options: ProtocolOutboundPipelineOptions<TCanonicalOutbound>): Promise<ProtocolOutboundPipelineResult<TOutboundWire>>;
34
+ private runValidation;
35
+ }
@@ -0,0 +1,103 @@
1
+ import { ConversionMetaBag } from './meta/meta-bag.js';
2
+ export class PipelineValidationError extends Error {
3
+ stage;
4
+ errors;
5
+ constructor(stage, errors) {
6
+ super(errors[0]?.message ?? `Validation failed during ${stage}`);
7
+ this.name = 'PipelineValidationError';
8
+ this.stage = stage;
9
+ this.errors = errors;
10
+ }
11
+ }
12
+ function normalizeContext(hooks, ctx) {
13
+ return {
14
+ profileId: ctx?.profileId ?? hooks.id,
15
+ providerProtocol: ctx?.providerProtocol ?? hooks.protocol,
16
+ targetProtocol: ctx?.targetProtocol ?? ctx?.providerProtocol ?? hooks.protocol,
17
+ entryEndpoint: ctx?.entryEndpoint,
18
+ requestId: ctx?.requestId,
19
+ stream: ctx?.stream,
20
+ metadata: ctx?.metadata ?? {}
21
+ };
22
+ }
23
+ function ingestMeta(target, incoming) {
24
+ if (!incoming) {
25
+ return;
26
+ }
27
+ target.ingest(incoming);
28
+ }
29
+ export class ProtocolConversionPipeline {
30
+ hooks;
31
+ constructor(hooks) {
32
+ if (!hooks?.inbound?.parse) {
33
+ throw new Error('ProtocolConversionPipeline requires an inbound.parse hook');
34
+ }
35
+ if (!hooks?.outbound?.serialize) {
36
+ throw new Error('ProtocolConversionPipeline requires an outbound.serialize hook');
37
+ }
38
+ this.hooks = hooks;
39
+ }
40
+ async convertInbound(options) {
41
+ const context = normalizeContext(this.hooks, options.context);
42
+ const meta = new ConversionMetaBag(options.meta);
43
+ await this.runValidation('inbound.preValidate', this.hooks.inbound.preValidate, {
44
+ wire: options.payload,
45
+ meta,
46
+ context
47
+ });
48
+ const parseResult = await this.hooks.inbound.parse({
49
+ wire: options.payload,
50
+ meta,
51
+ context
52
+ });
53
+ ingestMeta(meta, parseResult.meta);
54
+ const canonical = parseResult.canonical;
55
+ if (!canonical) {
56
+ throw new Error('ProtocolConversionPipeline inbound.parse returned an empty canonical payload');
57
+ }
58
+ if (this.hooks.inbound.cleanup) {
59
+ await this.hooks.inbound.cleanup({
60
+ canonical,
61
+ meta,
62
+ context
63
+ });
64
+ }
65
+ return { canonical, meta, context };
66
+ }
67
+ async convertOutbound(options) {
68
+ const context = normalizeContext(this.hooks, options.context);
69
+ const meta = new ConversionMetaBag(options.meta);
70
+ if (this.hooks.outbound.augment) {
71
+ await this.hooks.outbound.augment({
72
+ canonical: options.canonical,
73
+ meta,
74
+ context
75
+ });
76
+ }
77
+ const serialized = await this.hooks.outbound.serialize({
78
+ canonical: options.canonical,
79
+ meta,
80
+ context
81
+ });
82
+ ingestMeta(meta, serialized.meta);
83
+ await this.runValidation('outbound.postValidate', this.hooks.outbound.postValidate, {
84
+ wire: serialized.payload,
85
+ meta,
86
+ context
87
+ });
88
+ return { payload: serialized.payload, meta, context };
89
+ }
90
+ async runValidation(stage, hook, args) {
91
+ if (!hook) {
92
+ return;
93
+ }
94
+ const result = await hook(args);
95
+ if (!result) {
96
+ return;
97
+ }
98
+ const errors = result.errors ?? [];
99
+ if (result.ok === false || errors.length > 0) {
100
+ throw new PipelineValidationError(stage, errors.length ? errors : [{ message: 'Unknown validation error' }]);
101
+ }
102
+ }
103
+ }
@@ -0,0 +1,20 @@
1
+ import { type JsonValue } from '../../hub/types/json.js';
2
+ export type ConversionMetaValue = JsonValue;
3
+ export type ConversionMetaRecord = Record<string, ConversionMetaValue>;
4
+ export type ConversionMetaEntries = Iterable<[string, ConversionMetaValue]>;
5
+ export type ConversionMetaInput = ConversionMetaBag | ConversionMetaRecord | ConversionMetaEntries | undefined;
6
+ export declare class ConversionMetaBag {
7
+ private readonly store;
8
+ constructor(initial?: ConversionMetaInput);
9
+ static from(input?: ConversionMetaInput): ConversionMetaBag;
10
+ keys(): string[];
11
+ has(key: string): boolean;
12
+ get<T extends ConversionMetaValue>(key: string): T | undefined;
13
+ set(key: string, value: ConversionMetaValue | undefined): void;
14
+ consume<T extends ConversionMetaValue>(key: string): T | undefined;
15
+ ingest(input?: ConversionMetaInput): void;
16
+ entries(): ConversionMetaEntries;
17
+ snapshot(): ConversionMetaRecord;
18
+ toJSON(): ConversionMetaRecord;
19
+ clone(): ConversionMetaBag;
20
+ }
@@ -0,0 +1,81 @@
1
+ import { jsonClone } from '../../hub/types/json.js';
2
+ function cloneValue(value) {
3
+ return jsonClone(value);
4
+ }
5
+ function entriesFromInput(input) {
6
+ if (!input) {
7
+ return undefined;
8
+ }
9
+ if (input instanceof ConversionMetaBag) {
10
+ return input.entries();
11
+ }
12
+ if (typeof input[Symbol.iterator] === 'function') {
13
+ return input;
14
+ }
15
+ return Object.entries(input);
16
+ }
17
+ export class ConversionMetaBag {
18
+ store = new Map();
19
+ constructor(initial) {
20
+ if (initial) {
21
+ this.ingest(initial);
22
+ }
23
+ }
24
+ static from(input) {
25
+ return new ConversionMetaBag(input);
26
+ }
27
+ keys() {
28
+ return Array.from(this.store.keys());
29
+ }
30
+ has(key) {
31
+ return this.store.has(key);
32
+ }
33
+ get(key) {
34
+ const value = this.store.get(key);
35
+ return value;
36
+ }
37
+ set(key, value) {
38
+ if (value === undefined) {
39
+ this.store.delete(key);
40
+ return;
41
+ }
42
+ this.store.set(key, cloneValue(value));
43
+ }
44
+ consume(key) {
45
+ const value = this.get(key);
46
+ if (value !== undefined) {
47
+ this.store.delete(key);
48
+ }
49
+ return value;
50
+ }
51
+ ingest(input) {
52
+ const incoming = entriesFromInput(input);
53
+ if (!incoming) {
54
+ return;
55
+ }
56
+ for (const [key, value] of incoming) {
57
+ if (value === undefined) {
58
+ this.store.delete(key);
59
+ }
60
+ else {
61
+ this.store.set(key, cloneValue(value));
62
+ }
63
+ }
64
+ }
65
+ entries() {
66
+ return this.store.entries();
67
+ }
68
+ snapshot() {
69
+ const out = {};
70
+ for (const [key, value] of this.store.entries()) {
71
+ out[key] = cloneValue(value);
72
+ }
73
+ return out;
74
+ }
75
+ toJSON() {
76
+ return this.snapshot();
77
+ }
78
+ clone() {
79
+ return new ConversionMetaBag(this.entries());
80
+ }
81
+ }
@@ -0,0 +1,18 @@
1
+ import type { ProcessedRequest, StandardizedRequest } from '../../hub/types/standardized.js';
2
+ import type { ChatCompletionLike } from '../../hub/response/response-mappers.js';
3
+ /**
4
+ * Canonical request payload used by the Chat Process. The structure already
5
+ * exists inside the hub pipeline (`StandardizedRequest`), so v2 codecs can
6
+ * simply reuse it to avoid redefining similar shapes.
7
+ */
8
+ export type CanonicalChatRequest = StandardizedRequest;
9
+ /**
10
+ * Processed requests (after tool governance/reranking) are also exposed so the
11
+ * outbound side can make decisions that depend on process metadata.
12
+ */
13
+ export type CanonicalProcessedRequest = ProcessedRequest;
14
+ /**
15
+ * Canonical response payloads follow the OpenAI ChatCompletion-like structure
16
+ * that the existing format adapters emit.
17
+ */
18
+ export type CanonicalChatResponse = ChatCompletionLike;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from './canonical-chat.js';
@@ -0,0 +1 @@
1
+ export * from './canonical-chat.js';
@@ -0,0 +1,48 @@
1
+ import type { BridgeInputItem, BridgeToolDefinition } from '../shared/bridge-message-types.js';
2
+ import type { ChatToolDefinition } from '../hub/types/chat-envelope.js';
3
+ import type { BridgeInputBuildResult } from '../shared/bridge-message-utils.js';
4
+ export interface ResponsesRequestContext {
5
+ requestId?: string;
6
+ originalSystemMessages?: string[];
7
+ input?: BridgeInputItem[];
8
+ include?: unknown;
9
+ store?: unknown;
10
+ toolChoice?: unknown;
11
+ parallelToolCalls?: boolean;
12
+ metadata?: Record<string, unknown> | undefined;
13
+ responseFormat?: unknown;
14
+ stream?: boolean;
15
+ isChatPayload?: boolean;
16
+ isResponsesPayload?: boolean;
17
+ historyMessages?: Array<{
18
+ role: string;
19
+ content: string;
20
+ }>;
21
+ currentMessage?: {
22
+ role: string;
23
+ content: string;
24
+ } | null;
25
+ toolsRaw?: BridgeToolDefinition[];
26
+ toolsNormalized?: Array<Record<string, unknown>>;
27
+ }
28
+ export interface BuildChatRequestResult {
29
+ request: Record<string, unknown>;
30
+ toolsNormalized?: ChatToolDefinition[];
31
+ }
32
+ export interface BuildResponsesRequestResult {
33
+ request: Record<string, unknown>;
34
+ originalSystemMessages?: string[];
35
+ }
36
+ export declare function captureResponsesContext(payload: Record<string, unknown>, dto?: {
37
+ route?: {
38
+ requestId?: string;
39
+ };
40
+ }): ResponsesRequestContext;
41
+ export declare function buildChatRequestFromResponses(payload: Record<string, unknown>, context: ResponsesRequestContext): BuildChatRequestResult;
42
+ export declare function buildResponsesRequestFromChat(payload: Record<string, unknown>, ctx?: ResponsesRequestContext, extras?: {
43
+ bridgeHistory?: BridgeInputBuildResult;
44
+ systemInstruction?: string;
45
+ }): BuildResponsesRequestResult;
46
+ export declare function buildResponsesPayloadFromChat(payload: unknown, context?: ResponsesRequestContext): Record<string, unknown> | unknown;
47
+ export declare function extractRequestIdFromResponse(response: any): string | undefined;
48
+ export { buildChatResponseFromResponses } from '../shared/responses-response-utils.js';