@truefoundry/ai-gateway-sdk 0.0.37 → 0.0.38

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.
@@ -20,6 +20,7 @@
20
20
  * rejects them outright. Uncatalogued models resolve to plain, the stricter default.
21
21
  */
22
22
  import { logger } from '../../logger.js';
23
+ import { collectAdditionalInputTools, flattenFunctionsNamespace } from '../../utils/responsesTools.js';
23
24
  import { usesOpenAIResponsesPath } from './api.js';
24
25
  /** Stripped from `input`: the tools it carried have already been hoisted into `tools`. */
25
26
  const CODEX_LITE_INPUT_TYPES = new Set(['additional_tools']);
@@ -46,15 +47,7 @@ function isSupportedTool(tool, model) {
46
47
  return true;
47
48
  return tool?.type === 'namespace' && tool?.name === SUB_AGENT_NAMESPACE && usesOpenAIResponsesPath(model);
48
49
  }
49
- /** Reserved upstream: forwarding it earns "namespace 'functions' collides with an existing tool namespace". */
50
- const DEFAULT_FUNCTION_NAMESPACE = 'functions';
51
50
  const LOCAL_SHELL_TOOL_NAME = 'local_shell';
52
- /** Unwraps the reserved "functions" namespace; its entries are valid top-level tools as-is. */
53
- function flattenFunctionsNamespace(tools) {
54
- return tools.flatMap((tool) => tool?.type === 'namespace' && tool?.name === DEFAULT_FUNCTION_NAMESPACE && Array.isArray(tool.tools)
55
- ? tool.tools
56
- : [tool]);
57
- }
58
51
  function keepSupportedTools(tools, model) {
59
52
  const kept = tools.filter((t) => isSupportedTool(t, model));
60
53
  if (tools.length && !kept.length) {
@@ -85,13 +78,7 @@ export function hasAdditionalTools(params) {
85
78
  }
86
79
  /** Hoistable tools pulled from additional_tools items (non-standard types filtered out). */
87
80
  export function extractAdditionalTools(params) {
88
- const input = params.input;
89
- if (!Array.isArray(input))
90
- return [];
91
- const tools = input
92
- .filter((it) => it?.type === 'additional_tools' && Array.isArray(it.tools))
93
- .flatMap((it) => it.tools);
94
- return normalizeTools(tools, modelOf(params));
81
+ return normalizeTools(collectAdditionalInputTools(params.input), modelOf(params));
95
82
  }
96
83
  /**
97
84
  * Joined into one string, not one part per source part: Codex splits a single sentence across
@@ -1 +1 @@
1
- {"version":3,"file":"responsesLite.js","sourceRoot":"","sources":["../../../src/providers/aws-bedrock-mantle/responsesLite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,OAAO,CAAC;AAEhD,0FAA0F;AAC1F,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC;AAE7D;;;;GAIG;AACH,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;AAE/E;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,eAAe,CAAC;AAE5C;;;;;GAKG;AACH,SAAS,eAAe,CAAC,IAAS,EAAE,KAAa;IAC/C,IAAI,wBAAwB,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1D,OAAO,IAAI,EAAE,IAAI,KAAK,WAAW,IAAI,IAAI,EAAE,IAAI,KAAK,mBAAmB,IAAI,uBAAuB,CAAC,KAAK,CAAC,CAAC;AAC5G,CAAC;AAED,+GAA+G;AAC/G,MAAM,0BAA0B,GAAG,WAAW,CAAC;AAE/C,MAAM,qBAAqB,GAAG,aAAa,CAAC;AAE5C,+FAA+F;AAC/F,SAAS,yBAAyB,CAAC,KAAY;IAC7C,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,IAAS,EAAE,EAAE,CACjC,IAAI,EAAE,IAAI,KAAK,WAAW,IAAI,IAAI,EAAE,IAAI,KAAK,0BAA0B,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;QAClG,CAAC,CAAC,IAAI,CAAC,KAAK;QACZ,CAAC,CAAC,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CAAC;IACH,CAAC;IAED,eAAe,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACpC,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,MAAc;IACvC,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAE,MAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAE,MAAc,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IACnF,OAAO,CAAC,GAAG,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC;AAC3F,CAAC"}
@@ -77,7 +77,7 @@ export declare const transformInstancesObject: (params: any) => Record<string, a
77
77
  export declare const transformGeminiToolParameters: (parameters: JsonSchema) => JsonSchema;
78
78
  export declare const recursivelyDeleteUnsupportedParameters: (obj: any) => void;
79
79
  export declare const GoogleResponseHandler: (response: Response | string | Record<string, unknown>, status: number) => Response;
80
- export declare const googleBatchStatusToOpenAI: (status: GoogleBatchRecord["state"]) => "cancelled" | "failed" | "cancelling" | "in_progress" | "completed" | "expired" | "validating";
80
+ export declare const googleBatchStatusToOpenAI: (status: GoogleBatchRecord["state"]) => "cancelled" | "failed" | "cancelling" | "completed" | "in_progress" | "expired" | "validating";
81
81
  export declare const googleFinetuneStatusToOpenAI: (status: GoogleFinetuneRecord["state"]) => "cancelled" | "queued" | "failed" | "running" | "succeeded";
82
82
  export declare const GoogleToOpenAIBatch: (response: GoogleBatchRecord) => {
83
83
  errors?: {
@@ -1051,6 +1051,10 @@ export interface ResponseFunctionToolCall {
1051
1051
  * The name of the function to run.
1052
1052
  */
1053
1053
  name: string;
1054
+ /**
1055
+ * The namespace of the function to run, when it was declared inside a `namespace` tool.
1056
+ */
1057
+ namespace?: string;
1054
1058
  /**
1055
1059
  * The type of the function tool call. Always `function_call`.
1056
1060
  */
@@ -1061,6 +1065,89 @@ export interface ResponseFunctionToolCall {
1061
1065
  */
1062
1066
  status?: 'in_progress' | 'completed' | 'incomplete';
1063
1067
  }
1068
+ /**
1069
+ * A call to a custom (freeform) tool. Its payload is raw text, not JSON arguments.
1070
+ */
1071
+ export interface ResponseCustomToolCall {
1072
+ /**
1073
+ * The unique ID of the custom tool call.
1074
+ */
1075
+ id?: string;
1076
+ /**
1077
+ * An identifier used to map this custom tool call to a tool call output.
1078
+ */
1079
+ call_id: string;
1080
+ /**
1081
+ * The input for the custom tool call generated by the model.
1082
+ */
1083
+ input: string;
1084
+ /**
1085
+ * The name of the custom tool being called.
1086
+ */
1087
+ name: string;
1088
+ /**
1089
+ * The namespace of the custom tool, when it was declared inside a `namespace` tool.
1090
+ */
1091
+ namespace?: string;
1092
+ /**
1093
+ * The type of the custom tool call. Always `custom_tool_call`.
1094
+ */
1095
+ type: 'custom_tool_call';
1096
+ /**
1097
+ * `incomplete` when the input was cut off by the output token limit.
1098
+ */
1099
+ status?: 'in_progress' | 'completed' | 'incomplete';
1100
+ }
1101
+ /**
1102
+ * Emitted when there is a partial payload for a custom tool call.
1103
+ */
1104
+ export interface ResponseCustomToolCallInputDeltaEvent {
1105
+ /**
1106
+ * The incremental input data (delta) for the custom tool call.
1107
+ */
1108
+ delta: string;
1109
+ /**
1110
+ * Unique identifier for the API item associated with this event.
1111
+ */
1112
+ item_id: string;
1113
+ /**
1114
+ * The index of the output this delta applies to.
1115
+ */
1116
+ output_index: number;
1117
+ /**
1118
+ * The sequence number of this event.
1119
+ */
1120
+ sequence_number?: number;
1121
+ /**
1122
+ * The event type identifier.
1123
+ */
1124
+ type: 'response.custom_tool_call_input.delta';
1125
+ }
1126
+ /**
1127
+ * Emitted when the payload of a custom tool call is finalized.
1128
+ */
1129
+ export interface ResponseCustomToolCallInputDoneEvent {
1130
+ /**
1131
+ * The complete input data for the custom tool call.
1132
+ */
1133
+ input: string;
1134
+ /**
1135
+ * Unique identifier for the API item associated with this event.
1136
+ */
1137
+ item_id: string;
1138
+ /**
1139
+ * The index of the output this event applies to.
1140
+ */
1141
+ output_index: number;
1142
+ /**
1143
+ * The sequence number of this event.
1144
+ */
1145
+ sequence_number?: number;
1146
+ /**
1147
+ * The event type identifier.
1148
+ */
1149
+ type: 'response.custom_tool_call_input.done';
1150
+ }
1064
1151
  /**
1065
1152
  * The results of a web search tool call. See the
1066
1153
  * [web search guide](https://platform.openai.com/docs/guides/tools-web-search) for
@@ -1195,7 +1282,7 @@ export interface ResponseInputImage {
1195
1282
  * `assistant` role are presumed to have been generated by the model in previous
1196
1283
  * interactions.
1197
1284
  */
1198
- export type ResponseInputItem = EasyInputMessage | ResponseInputItem.Message | ResponseOutputMessage | ResponseFileSearchToolCall | ResponseComputerToolCall | ResponseInputItem.ComputerCallOutput | ResponseFunctionWebSearch | ResponseFunctionToolCall | ResponseInputItem.FunctionCallOutput | ResponseInputItem.Reasoning | ResponseInputItem.ItemReference;
1285
+ export type ResponseInputItem = EasyInputMessage | ResponseInputItem.Message | ResponseOutputMessage | ResponseFileSearchToolCall | ResponseComputerToolCall | ResponseInputItem.ComputerCallOutput | ResponseFunctionWebSearch | ResponseFunctionToolCall | ResponseCustomToolCall | ResponseInputItem.FunctionCallOutput | ResponseInputItem.CustomToolCallOutput | ResponseInputItem.Reasoning | ResponseInputItem.ItemReference;
1199
1286
  export declare namespace ResponseInputItem {
1200
1287
  /**
1201
1288
  * A message input to the model with a role indicating instruction following
@@ -1317,6 +1404,27 @@ export declare namespace ResponseInputItem {
1317
1404
  */
1318
1405
  status?: 'in_progress' | 'completed' | 'incomplete';
1319
1406
  }
1407
+ /**
1408
+ * The output of a custom (freeform) tool call.
1409
+ */
1410
+ interface CustomToolCallOutput {
1411
+ /**
1412
+ * The call ID, used to map this custom tool call output to a custom tool call.
1413
+ */
1414
+ call_id: string;
1415
+ /**
1416
+ * The output of the custom tool call: a string, or a list of text, image or file parts.
1417
+ */
1418
+ output: string | Array<ResponseInputText | ResponseInputImage | ResponseInputFile>;
1419
+ /**
1420
+ * The type of the custom tool call output. Always `custom_tool_call_output`.
1421
+ */
1422
+ type: 'custom_tool_call_output';
1423
+ /**
1424
+ * The unique ID of the custom tool call output.
1425
+ */
1426
+ id?: string;
1427
+ }
1320
1428
  /**
1321
1429
  * A description of the chain of thought used by a reasoning model while generating
1322
1430
  * a response.
@@ -1404,7 +1512,7 @@ export interface ResponseOutputAudio {
1404
1512
  /**
1405
1513
  * An output message from the model.
1406
1514
  */
1407
- export type ResponseOutputItem = ResponseOutputMessage | ResponseFileSearchToolCall | ResponseFunctionToolCall | ResponseFunctionWebSearch | ResponseComputerToolCall | ResponseOutputItemReasoning;
1515
+ export type ResponseOutputItem = ResponseOutputMessage | ResponseFileSearchToolCall | ResponseFunctionToolCall | ResponseCustomToolCall | ResponseFunctionWebSearch | ResponseComputerToolCall | ResponseOutputItemReasoning;
1408
1516
  export interface ResponseOutputItemReasoning {
1409
1517
  /**
1410
1518
  * The unique identifier of the reasoning content.
@@ -1646,7 +1754,7 @@ export type ResponseStatus = 'completed' | 'failed' | 'in_progress' | 'incomplet
1646
1754
  /**
1647
1755
  * Emitted when there is a partial audio response.
1648
1756
  */
1649
- export type ResponseStreamEvent = ResponseAudioDeltaEvent | ResponseAudioDoneEvent | ResponseAudioTranscriptDeltaEvent | ResponseAudioTranscriptDoneEvent | ResponseCodeInterpreterCallCodeDeltaEvent | ResponseCodeInterpreterCallCodeDoneEvent | ResponseCodeInterpreterCallCompletedEvent | ResponseCodeInterpreterCallInProgressEvent | ResponseCodeInterpreterCallInterpretingEvent | ResponseCompletedEvent | ResponseContentPartAddedEvent | ResponseContentPartDoneEvent | ResponseCreatedEvent | ResponseErrorEvent | ResponseFileSearchCallCompletedEvent | ResponseFileSearchCallInProgressEvent | ResponseFileSearchCallSearchingEvent | ResponseFunctionCallArgumentsDeltaEvent | ResponseFunctionCallArgumentsDoneEvent | ResponseInProgressEvent | ResponseFailedEvent | ResponseIncompleteEvent | ResponseOutputItemAddedEvent | ResponseOutputItemDoneEvent | ResponseRefusalDeltaEvent | ResponseRefusalDoneEvent | ResponseTextAnnotationDeltaEvent | ResponseTextDeltaEvent | ResponseTextDoneEvent | ResponseWebSearchCallCompletedEvent | ResponseWebSearchCallInProgressEvent | ResponseWebSearchCallSearchingEvent;
1757
+ export type ResponseStreamEvent = ResponseAudioDeltaEvent | ResponseAudioDoneEvent | ResponseAudioTranscriptDeltaEvent | ResponseAudioTranscriptDoneEvent | ResponseCodeInterpreterCallCodeDeltaEvent | ResponseCodeInterpreterCallCodeDoneEvent | ResponseCodeInterpreterCallCompletedEvent | ResponseCodeInterpreterCallInProgressEvent | ResponseCodeInterpreterCallInterpretingEvent | ResponseCompletedEvent | ResponseContentPartAddedEvent | ResponseContentPartDoneEvent | ResponseCreatedEvent | ResponseErrorEvent | ResponseFileSearchCallCompletedEvent | ResponseFileSearchCallInProgressEvent | ResponseFileSearchCallSearchingEvent | ResponseFunctionCallArgumentsDeltaEvent | ResponseFunctionCallArgumentsDoneEvent | ResponseCustomToolCallInputDeltaEvent | ResponseCustomToolCallInputDoneEvent | ResponseInProgressEvent | ResponseFailedEvent | ResponseIncompleteEvent | ResponseOutputItemAddedEvent | ResponseOutputItemDoneEvent | ResponseRefusalDeltaEvent | ResponseRefusalDoneEvent | ResponseTextAnnotationDeltaEvent | ResponseTextDeltaEvent | ResponseTextDoneEvent | ResponseWebSearchCallCompletedEvent | ResponseWebSearchCallInProgressEvent | ResponseWebSearchCallSearchingEvent;
1650
1758
  /**
1651
1759
  * Emitted when a text annotation is added.
1652
1760
  */
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Responses API tool helpers shared by the Bedrock Mantle native path and the Responses →
3
+ * Chat Completions adapter.
4
+ */
5
+ /** Reserved upstream: forwarding it earns "namespace 'functions' collides with an existing tool namespace". */
6
+ export declare const DEFAULT_FUNCTION_NAMESPACE = "functions";
7
+ /** Unwraps the reserved "functions" namespace; its entries are valid top-level tools as-is. */
8
+ export declare function flattenFunctionsNamespace(tools: any[]): any[];
9
+ /**
10
+ * Tools Codex hides inside `input` as `{ type: 'additional_tools', tools: [...] }` (Responses
11
+ * Lite, from Codex 0.144), in input order and otherwise untouched.
12
+ */
13
+ export declare function collectAdditionalInputTools(input: unknown): any[];
14
+ /**
15
+ * A freeform `custom` tool restated as a function taking a single `input` string, the closest
16
+ * equivalent every provider accepts. JSON schema cannot enforce the grammar, so it goes into the
17
+ * description. The model then answers `{"input":"<payload>"}`.
18
+ *
19
+ * TODO: the description wording mirrors `convertCursorCustomToolsToFunctions` (GATEWAY-3413,
20
+ * #4342). Deduplicate the two once #4342 and #4366 have landed.
21
+ */
22
+ export declare function customToolToFunctionTool(source: Record<string, any>, name?: string): any;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Responses API tool helpers shared by the Bedrock Mantle native path and the Responses →
3
+ * Chat Completions adapter.
4
+ */
5
+ /** Reserved upstream: forwarding it earns "namespace 'functions' collides with an existing tool namespace". */
6
+ export const DEFAULT_FUNCTION_NAMESPACE = 'functions';
7
+ /** Unwraps the reserved "functions" namespace; its entries are valid top-level tools as-is. */
8
+ export function flattenFunctionsNamespace(tools) {
9
+ return tools.flatMap((tool) => tool?.type === 'namespace' && tool?.name === DEFAULT_FUNCTION_NAMESPACE && Array.isArray(tool.tools)
10
+ ? tool.tools
11
+ : [tool]);
12
+ }
13
+ /**
14
+ * Tools Codex hides inside `input` as `{ type: 'additional_tools', tools: [...] }` (Responses
15
+ * Lite, from Codex 0.144), in input order and otherwise untouched.
16
+ */
17
+ export function collectAdditionalInputTools(input) {
18
+ if (!Array.isArray(input))
19
+ return [];
20
+ return input
21
+ .filter((it) => it?.type === 'additional_tools' && Array.isArray(it.tools))
22
+ .flatMap((it) => it.tools);
23
+ }
24
+ /**
25
+ * A freeform `custom` tool restated as a function taking a single `input` string, the closest
26
+ * equivalent every provider accepts. JSON schema cannot enforce the grammar, so it goes into the
27
+ * description. The model then answers `{"input":"<payload>"}`.
28
+ *
29
+ * TODO: the description wording mirrors `convertCursorCustomToolsToFunctions` (GATEWAY-3413,
30
+ * #4342). Deduplicate the two once #4342 and #4366 have landed.
31
+ */
32
+ export function customToolToFunctionTool(source, name = source.name) {
33
+ const format = source.format?.grammar ?? source.format;
34
+ const description = (source.description ?? '') +
35
+ (format?.definition ? `\n\nFormat:\n\`\`\`${format.syntax ?? 'grammar'}\n${format.definition}\n\`\`\`` : '');
36
+ return {
37
+ type: 'function',
38
+ function: {
39
+ name,
40
+ ...(description && { description }),
41
+ parameters: {
42
+ type: 'object',
43
+ properties: {
44
+ input: {
45
+ type: 'string',
46
+ description: 'The complete tool payload, exactly as the tool description specifies.',
47
+ },
48
+ },
49
+ required: ['input'],
50
+ additionalProperties: false,
51
+ },
52
+ },
53
+ };
54
+ }
55
+ //# sourceMappingURL=responsesTools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"responsesTools.js","sourceRoot":"","sources":["../../src/utils/responsesTools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+GAA+G;AAC/G,MAAM,CAAC,MAAM,0BAA0B,GAAG,WAAW,CAAC;AAEtD,+FAA+F;AAC/F,MAAM,UAAU,yBAAyB,CAAC,KAAY;IACpD,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,IAAS,EAAE,EAAE,CACjC,IAAI,EAAE,IAAI,KAAK,WAAW,IAAI,IAAI,EAAE,IAAI,KAAK,0BAA0B,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;QAClG,CAAC,CAAC,IAAI,CAAC,KAAK;QACZ,CAAC,CAAC,CAAC,IAAI,CAAC,CACX,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CAAC,KAAc;IACxD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACrC,OAAO,KAAK;SACT,MAAM,CAAC,CAAC,EAAO,EAAE,EAAE,CAAC,EAAE,EAAE,IAAI,KAAK,kBAAkB,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;SAC/E,OAAO,CAAC,CAAC,EAAO,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAA2B,EAAE,OAAe,MAAM,CAAC,IAAI;IAC9F,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC;IACvD,MAAM,WAAW,GACf,CAAC,MAAM,CAAC,WAAW,IAAI,EAAE,CAAC;QAC1B,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,sBAAsB,MAAM,CAAC,MAAM,IAAI,SAAS,KAAK,MAAM,CAAC,UAAU,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAE/G,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE;YACR,IAAI;YACJ,GAAG,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,CAAC;YACnC,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,uEAAuE;qBACrF;iBACF;gBACD,QAAQ,EAAE,CAAC,OAAO,CAAC;gBACnB,oBAAoB,EAAE,KAAK;aAC5B;SACF;KACF,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truefoundry/ai-gateway-sdk",
3
- "version": "0.0.37",
3
+ "version": "0.0.38",
4
4
  "description": "LLM provider translation SDK",
5
5
  "author": "Truefoundry",
6
6
  "license": "UNLICENSED",