@mate-academy/llm-gateway 8.0.0 → 8.2.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.
Files changed (102) hide show
  1. package/README.md +76 -4
  2. package/dist/LLMGateway.d.ts +2 -2
  3. package/dist/LLMGateway.js.map +1 -1
  4. package/dist/LLMGateway.typedefs.d.ts +2 -2
  5. package/dist/LLMService.typedefs.d.ts +20 -0
  6. package/dist/LLMService.typedefs.js.map +1 -1
  7. package/dist/client/LLMAgent.d.ts +17 -4
  8. package/dist/client/LLMAgent.js +4 -0
  9. package/dist/client/LLMAgent.js.map +1 -1
  10. package/dist/client/LLMClientEngine.d.ts +81 -0
  11. package/dist/client/LLMClientEngine.js +350 -0
  12. package/dist/client/LLMClientEngine.js.map +1 -0
  13. package/dist/client/agentRun.typedefs.d.ts +18 -3
  14. package/dist/client/agentRun.typedefs.js +1 -0
  15. package/dist/client/agentRun.typedefs.js.map +1 -1
  16. package/dist/client/agentRunner.d.ts +38 -3
  17. package/dist/client/agentRunner.js +206 -80
  18. package/dist/client/agentRunner.js.map +1 -1
  19. package/dist/client/codegen/fetchPromptRecords.d.ts +1 -1
  20. package/dist/client/codegen/index.d.ts +1 -0
  21. package/dist/client/codegen/index.js +1 -0
  22. package/dist/client/codegen/index.js.map +1 -1
  23. package/dist/client/codegen/renderSnapshot.constants.d.ts +12 -0
  24. package/dist/client/codegen/renderSnapshot.constants.js +21 -0
  25. package/dist/client/codegen/renderSnapshot.constants.js.map +1 -0
  26. package/dist/client/codegen/renderSnapshot.d.ts +6 -18
  27. package/dist/client/codegen/renderSnapshot.js +152 -125
  28. package/dist/client/codegen/renderSnapshot.js.map +1 -1
  29. package/dist/client/codegen/renderSnapshot.typedefs.d.ts +20 -0
  30. package/dist/client/codegen/renderSnapshot.typedefs.js +3 -0
  31. package/dist/client/codegen/renderSnapshot.typedefs.js.map +1 -0
  32. package/dist/client/coerceToolResult.d.ts +10 -0
  33. package/dist/client/coerceToolResult.js +38 -0
  34. package/dist/client/coerceToolResult.js.map +1 -0
  35. package/dist/client/createLLMClient.d.ts +1 -40
  36. package/dist/client/createLLMClient.js +5 -329
  37. package/dist/client/createLLMClient.js.map +1 -1
  38. package/dist/client/index.d.ts +3 -1
  39. package/dist/client/index.js +3 -1
  40. package/dist/client/index.js.map +1 -1
  41. package/dist/client/llmClient.typedefs.d.ts +180 -0
  42. package/dist/client/{createLLMClient.typedefs.js → llmClient.typedefs.js} +1 -1
  43. package/dist/client/llmClient.typedefs.js.map +1 -0
  44. package/dist/client/plainMessages.d.ts +1 -1
  45. package/dist/client/promptRegistry.runtime.d.ts +2 -2
  46. package/dist/client/promptRegistry.runtime.js.map +1 -1
  47. package/dist/client/promptVariables.d.ts +7 -0
  48. package/dist/client/promptVariables.js +13 -0
  49. package/dist/client/promptVariables.js.map +1 -0
  50. package/dist/client/snapshotRuntime.d.ts +17 -0
  51. package/dist/client/snapshotRuntime.js +42 -0
  52. package/dist/client/snapshotRuntime.js.map +1 -0
  53. package/dist/client/snapshotRuntime.typedefs.d.ts +13 -0
  54. package/dist/client/snapshotRuntime.typedefs.js +3 -0
  55. package/dist/client/snapshotRuntime.typedefs.js.map +1 -0
  56. package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAIAssistance.service.js +6 -0
  57. package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAIAssistance.service.js.map +1 -1
  58. package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAICompletion.service.js +6 -0
  59. package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAICompletion.service.js.map +1 -1
  60. package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAISpeechToText.service.js +3 -0
  61. package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAISpeechToText.service.js.map +1 -1
  62. package/dist/providers/LLMAPI/services/LLMAPIAssistance.service.d.ts +0 -2
  63. package/dist/providers/LLMAPI/services/LLMAPIAssistance.service.js +43 -25
  64. package/dist/providers/LLMAPI/services/LLMAPIAssistance.service.js.map +1 -1
  65. package/dist/providers/LLMAPI/services/LLMAPICompletion.service.d.ts +0 -2
  66. package/dist/providers/LLMAPI/services/LLMAPICompletion.service.js +18 -17
  67. package/dist/providers/LLMAPI/services/LLMAPICompletion.service.js.map +1 -1
  68. package/dist/providers/LLMAPI/utilities/index.d.ts +1 -1
  69. package/dist/providers/LLMAPI/utilities/index.js +3 -4
  70. package/dist/providers/LLMAPI/utilities/index.js.map +1 -1
  71. package/dist/providers/LLMAPI/utilities/validateStructuredResponse.d.ts +10 -0
  72. package/dist/providers/LLMAPI/utilities/validateStructuredResponse.js +21 -0
  73. package/dist/providers/LLMAPI/utilities/validateStructuredResponse.js.map +1 -0
  74. package/dist/providers/OpenAI/services/OpenAIAssistance.service.js +6 -0
  75. package/dist/providers/OpenAI/services/OpenAIAssistance.service.js.map +1 -1
  76. package/dist/providers/OpenAICompatible/OpenAICompatibleCompletion.service.js +6 -0
  77. package/dist/providers/OpenAICompatible/OpenAICompatibleCompletion.service.js.map +1 -1
  78. package/dist/providers/OpenAICompatible/OpenAICompatibleSpeechToText.service.js +3 -0
  79. package/dist/providers/OpenAICompatible/OpenAICompatibleSpeechToText.service.js.map +1 -1
  80. package/dist/services/LLMBaseService.abstract.d.ts +4 -3
  81. package/dist/services/LLMBaseService.abstract.js +6 -3
  82. package/dist/services/LLMBaseService.abstract.js.map +1 -1
  83. package/dist/utilities/index.d.ts +0 -1
  84. package/dist/utilities/index.js +0 -1
  85. package/dist/utilities/index.js.map +1 -1
  86. package/dist/utilities/llmTracing/llmTracing.constants.d.ts +5 -4
  87. package/dist/utilities/llmTracing/llmTracing.constants.js +6 -5
  88. package/dist/utilities/llmTracing/llmTracing.constants.js.map +1 -1
  89. package/dist/utilities/llmTracing/llmTracing.typedefs.d.ts +18 -9
  90. package/dist/utilities/llmTracing/noopLLMTracing.d.ts +2 -2
  91. package/dist/utilities/llmTracing/noopLLMTracing.js.map +1 -1
  92. package/dist/utilities/tools/LLMTool.d.ts +3 -12
  93. package/dist/utilities/tools/LLMTool.js.map +1 -1
  94. package/package.json +2 -1
  95. package/dist/client/createLLMClient.typedefs.d.ts +0 -91
  96. package/dist/client/createLLMClient.typedefs.js.map +0 -1
  97. package/dist/providers/LLMAPI/utilities/LLMAPIJsonFixer.d.ts +0 -24
  98. package/dist/providers/LLMAPI/utilities/LLMAPIJsonFixer.js +0 -237
  99. package/dist/providers/LLMAPI/utilities/LLMAPIJsonFixer.js.map +0 -1
  100. package/dist/utilities/traceIO.d.ts +0 -17
  101. package/dist/utilities/traceIO.js +0 -48
  102. package/dist/utilities/traceIO.js.map +0 -1
@@ -1,146 +1,173 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderSnapshotFile = renderSnapshotFile;
4
+ const ts_morph_1 = require("ts-morph");
4
5
  const promptName_1 = require("../../client/codegen/promptName");
5
- const FILE_HEADER = `/* eslint-disable */
6
- // AUTO-GENERATED by \`npm run langfuse:generate\`. DO NOT EDIT, DO NOT COMMIT.
7
- // Regenerated locally on demand, in CI before image builds, and refreshed
8
- // non-blocking at API pod boot. Gitignored exactly like GraphQL generated files.
9
-
10
- import {
11
- type LLMPromptMessage,
12
- type LLMPromptSnapshot,
13
- type LLMVariableValue,
14
- } from '@mate-academy/llm-gateway';
15
- `;
16
- const TS_IDENTIFIER_PATTERN = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
6
+ const renderSnapshot_constants_1 = require("../../client/codegen/renderSnapshot.constants");
17
7
  /**
18
8
  * Renders the full `langfusePrompts.generated.ts` content from fetched prompt
19
9
  * records: the `LLMPrompt` enum, per-prompt required-variable unions, the
20
10
  * `LLMPromptVariableMap` the client infers from, typed `compile()` helpers
21
11
  * (strict on required vars, tolerant of extras), and the snapshot constant used
22
- * as the outage fallback. A prompt whose enum member is not a valid TS
23
- * identifier is skipped with a warning rather than emitted a hostile prompt
24
- * name can never produce a file that fails the build.
12
+ * as the outage fallback. The emitted file is declarations only it compiles
13
+ * against the runtime helpers the package exports rather than carrying its own
14
+ * copy of them. A prompt whose enum member is not a valid TS identifier is
15
+ * skipped with a warning rather than emitted — a hostile prompt name can never
16
+ * produce a file that fails the build.
25
17
  */
26
18
  function renderSnapshotFile(records, options = {}) {
27
- const renderable = records.filter((record) => {
28
- const member = (0, promptName_1.promptNameToEnumMember)(record.name);
29
- if (TS_IDENTIFIER_PATTERN.test(member)) {
30
- return true;
31
- }
32
- options.onWarn?.(`Skipping prompt "${record.name}": its name does not map to a valid `
33
- + `TypeScript identifier (got "${member}").`);
34
- return false;
35
- });
19
+ const renderable = records.filter((record) => isRenderable(record, options));
36
20
  const sorted = [...renderable].sort((left, right) => left.name.localeCompare(right.name));
37
- return [
38
- FILE_HEADER,
39
- renderEnum(sorted),
40
- renderVariableUnions(sorted),
41
- renderVariableMap(sorted),
42
- renderCompilers(sorted),
43
- renderSnapshot(sorted),
44
- ].join('\n');
21
+ return new SnapshotFileBuilder(sorted).build();
45
22
  }
46
- function renderEnum(records) {
47
- if (records.length === 0) {
48
- return 'export enum LLMPrompt {}\n';
23
+ function isRenderable(record, options) {
24
+ const member = (0, promptName_1.promptNameToEnumMember)(record.name);
25
+ if (renderSnapshot_constants_1.TS_IDENTIFIER_PATTERN.test(member)) {
26
+ return true;
49
27
  }
50
- const members = records
51
- .map((record) => ` ${(0, promptName_1.promptNameToEnumMember)(record.name)} = ${JSON.stringify(record.name)},`)
52
- .join('\n');
53
- return `export enum LLMPrompt {\n${members}\n}\n`;
54
- }
55
- function renderVariableUnions(records) {
56
- return records
57
- .map((record) => {
58
- const member = (0, promptName_1.promptNameToEnumMember)(record.name);
59
- const union = record.requiredVariables.length > 0
60
- ? record.requiredVariables.map((name) => JSON.stringify(name)).join(' | ')
61
- : 'never';
62
- return `export type ${member}Variables = ${union};`;
63
- })
64
- .join('\n')
65
- .concat('\n');
28
+ options.onWarn?.(`Skipping prompt "${record.name}": its name does not map to a valid `
29
+ + `TypeScript identifier (got "${member}").`);
30
+ return false;
66
31
  }
67
- function renderVariableMap(records) {
68
- if (records.length === 0) {
69
- return 'export interface LLMPromptVariableMap {}\n';
32
+ /**
33
+ * Builds the generated file through ts-morph's structural API — enum, type
34
+ * aliases, interface, functions and the snapshot constant are declared as
35
+ * structures and printed by the TypeScript emitter, so the codegen never
36
+ * hand-assembles TypeScript source out of strings.
37
+ */
38
+ class SnapshotFileBuilder {
39
+ records;
40
+ sourceFile;
41
+ constructor(records) {
42
+ this.records = records;
43
+ const project = new ts_morph_1.Project({
44
+ useInMemoryFileSystem: true,
45
+ manipulationSettings: {
46
+ indentationText: ts_morph_1.IndentationText.TwoSpaces,
47
+ quoteKind: ts_morph_1.QuoteKind.Single,
48
+ useTrailingCommas: true,
49
+ },
50
+ });
51
+ this.sourceFile = project.createSourceFile(renderSnapshot_constants_1.GENERATED_FILE_NAME);
52
+ }
53
+ build() {
54
+ this.addGatewayImport();
55
+ this.addPromptEnum();
56
+ this.addVariableUnions();
57
+ this.addVariableMap();
58
+ this.addCompilers();
59
+ this.addSnapshotConstant();
60
+ this.sourceFile.formatText({ indentSize: 2, convertTabsToSpaces: true });
61
+ return this.sourceFile.getFullText();
62
+ }
63
+ addGatewayImport() {
64
+ this.sourceFile.addImportDeclaration({
65
+ leadingTrivia: renderSnapshot_constants_1.FILE_HEADER_COMMENT,
66
+ moduleSpecifier: renderSnapshot_constants_1.GATEWAY_MODULE_SPECIFIER,
67
+ namedImports: [
68
+ { name: renderSnapshot_constants_1.MESSAGES_COMPILER_NAME },
69
+ { name: renderSnapshot_constants_1.TEXT_COMPILER_NAME },
70
+ { name: renderSnapshot_constants_1.PROMPT_MESSAGE_TYPE_NAME, isTypeOnly: true },
71
+ { name: renderSnapshot_constants_1.SNAPSHOT_TYPE_NAME, isTypeOnly: true },
72
+ { name: renderSnapshot_constants_1.VARIABLE_VALUE_TYPE_NAME, isTypeOnly: true },
73
+ ],
74
+ });
75
+ }
76
+ addPromptEnum() {
77
+ this.sourceFile.addEnum({
78
+ name: renderSnapshot_constants_1.PROMPT_ENUM_NAME,
79
+ isExported: true,
80
+ members: this.records.map((record) => ({
81
+ name: (0, promptName_1.promptNameToEnumMember)(record.name),
82
+ initializer: JSON.stringify(record.name),
83
+ })),
84
+ });
85
+ }
86
+ addVariableUnions() {
87
+ this.sourceFile.addTypeAliases(this.records.map((record) => ({
88
+ name: `${(0, promptName_1.promptNameToEnumMember)(record.name)}Variables`,
89
+ isExported: true,
90
+ type: toVariablesUnion(record),
91
+ })));
92
+ }
93
+ addVariableMap() {
94
+ this.sourceFile.addInterface({
95
+ name: renderSnapshot_constants_1.VARIABLE_MAP_INTERFACE_NAME,
96
+ isExported: true,
97
+ properties: this.records.map((record) => {
98
+ const member = (0, promptName_1.promptNameToEnumMember)(record.name);
99
+ return {
100
+ name: `[${renderSnapshot_constants_1.PROMPT_ENUM_NAME}.${member}]`,
101
+ type: `${member}Variables`,
102
+ };
103
+ }),
104
+ });
105
+ }
106
+ addCompilers() {
107
+ this.sourceFile.addFunctions(this.records.map((record) => toCompilerStructure(record)));
108
+ }
109
+ addSnapshotConstant() {
110
+ this.sourceFile.addVariableStatement({
111
+ declarationKind: ts_morph_1.VariableDeclarationKind.Const,
112
+ isExported: true,
113
+ declarations: [{
114
+ name: renderSnapshot_constants_1.SNAPSHOT_CONSTANT_NAME,
115
+ type: renderSnapshot_constants_1.SNAPSHOT_TYPE_NAME,
116
+ initializer: (writer) => this.writeSnapshotEntries(writer),
117
+ }],
118
+ });
119
+ }
120
+ writeSnapshotEntries(writer) {
121
+ if (this.records.length === 0) {
122
+ writer.write('{}');
123
+ return;
124
+ }
125
+ writer.inlineBlock(() => {
126
+ this.records.forEach((record) => {
127
+ const member = (0, promptName_1.promptNameToEnumMember)(record.name);
128
+ const entry = JSON.stringify(toSnapshotEntry(record), null, 2);
129
+ writer.writeLine(`[${renderSnapshot_constants_1.PROMPT_ENUM_NAME}.${member}]: ${entry},`);
130
+ });
131
+ });
70
132
  }
71
- const entries = records
72
- .map((record) => {
73
- const member = (0, promptName_1.promptNameToEnumMember)(record.name);
74
- return ` [LLMPrompt.${member}]: ${member}Variables;`;
75
- })
76
- .join('\n');
77
- return `export interface LLMPromptVariableMap {\n${entries}\n}\n`;
78
133
  }
79
- function renderCompilers(records) {
80
- return records
81
- .map((record) => {
82
- const member = (0, promptName_1.promptNameToEnumMember)(record.name);
83
- const strictVars = record.requiredVariables.length > 0
84
- ? `Record<${member}Variables, LLMVariableValue>`
85
- : 'Record<string, never>';
86
- const returnType = record.kind === 'chat' ? 'LLMPromptMessage[]' : 'string';
87
- const compileCall = record.kind === 'chat'
88
- ? 'compileMessagesFromSnapshot'
89
- : 'compileTextFromSnapshot';
90
- return `export function compile${member}(\n`
91
- + ` variables: ${strictVars} & Record<string, LLMVariableValue>,\n`
92
- + `): ${returnType} {\n`
93
- + ` return ${compileCall}(LLMPrompt.${member}, variables);\n`
94
- + '}';
95
- })
96
- .join('\n\n')
97
- .concat('\n');
134
+ function toCompilerStructure(record) {
135
+ const member = (0, promptName_1.promptNameToEnumMember)(record.name);
136
+ const isChatPrompt = record.kind === 'chat';
137
+ const compilerName = isChatPrompt
138
+ ? renderSnapshot_constants_1.MESSAGES_COMPILER_NAME
139
+ : renderSnapshot_constants_1.TEXT_COMPILER_NAME;
140
+ return {
141
+ name: `compile${member}`,
142
+ isExported: true,
143
+ parameters: [{
144
+ name: 'variables',
145
+ type: toVariablesParameterType(record),
146
+ }],
147
+ returnType: isChatPrompt ? `${renderSnapshot_constants_1.PROMPT_MESSAGE_TYPE_NAME}[]` : 'string',
148
+ statements: (writer) => {
149
+ writer.write(`return ${compilerName}(`).inlineBlock(() => {
150
+ writer.writeLine(`snapshot: ${renderSnapshot_constants_1.SNAPSHOT_CONSTANT_NAME},`);
151
+ writer.writeLine(`name: ${renderSnapshot_constants_1.PROMPT_ENUM_NAME}.${member},`);
152
+ writer.writeLine('variables,');
153
+ }).write(');');
154
+ },
155
+ };
156
+ }
157
+ function toVariablesUnion(record) {
158
+ if (record.requiredVariables.length === 0) {
159
+ return 'never';
160
+ }
161
+ return record.requiredVariables
162
+ .map((name) => JSON.stringify(name))
163
+ .join(' | ');
98
164
  }
99
- function renderSnapshot(records) {
100
- const entries = records
101
- .map((record) => {
102
- const member = (0, promptName_1.promptNameToEnumMember)(record.name);
103
- return ` [LLMPrompt.${member}]: ${JSON.stringify(toSnapshotEntry(record), null, 2)
104
- .split('\n')
105
- .map((line, index) => (index === 0 ? line : ` ${line}`))
106
- .join('\n')},`;
107
- })
108
- .join('\n');
109
- const body = records.length > 0 ? `\n${entries}\n` : '';
110
- return `export const langfusePromptSnapshot: LLMPromptSnapshot = {${body}};\n\n`
111
- + 'function escapeRegExp(value: string): string {\n'
112
- + ' return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \'\\\\$&\');\n'
113
- + '}\n\n'
114
- + 'function substituteVariables(\n'
115
- + ' text: string,\n'
116
- + ' variables: Record<string, LLMVariableValue>,\n'
117
- + '): string {\n'
118
- + ' return Object.entries(variables).reduce(\n'
119
- + ' (result, [key, value]) => result.replace(\n'
120
- + ' new RegExp(`{{\\\\s*${escapeRegExp(key)}\\\\s*}}`, \'g\'),\n'
121
- + ' String(value),\n'
122
- + ' ),\n'
123
- + ' text,\n'
124
- + ' );\n'
125
- + '}\n\n'
126
- + 'function compileTextFromSnapshot(\n'
127
- + ' name: LLMPrompt,\n'
128
- + ' variables: Record<string, LLMVariableValue>,\n'
129
- + '): string {\n'
130
- + ' const entry = langfusePromptSnapshot[name];\n'
131
- + ' return substituteVariables(entry ? entry.fallbackText : \'\', variables);\n'
132
- + '}\n\n'
133
- + 'function compileMessagesFromSnapshot(\n'
134
- + ' name: LLMPrompt,\n'
135
- + ' variables: Record<string, LLMVariableValue>,\n'
136
- + '): LLMPromptMessage[] {\n'
137
- + ' const entry = langfusePromptSnapshot[name];\n'
138
- + ' const messages = entry ? entry.fallbackMessages : [];\n'
139
- + ' return messages.map((message) => ({\n'
140
- + ' role: message.role,\n'
141
- + ' content: substituteVariables(message.content, variables),\n'
142
- + ' }));\n'
143
- + '}\n';
165
+ function toVariablesParameterType(record) {
166
+ const member = (0, promptName_1.promptNameToEnumMember)(record.name);
167
+ const strictVariables = record.requiredVariables.length > 0
168
+ ? `Record<${member}Variables, ${renderSnapshot_constants_1.VARIABLE_VALUE_TYPE_NAME}>`
169
+ : 'Record<string, never>';
170
+ return `${strictVariables} & Record<string, ${renderSnapshot_constants_1.VARIABLE_VALUE_TYPE_NAME}>`;
144
171
  }
145
172
  function toSnapshotEntry(record) {
146
173
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"renderSnapshot.js","sourceRoot":"","sources":["../../../src/client/codegen/renderSnapshot.ts"],"names":[],"mappings":";;AA6CA,gDA6BC;AArED,4DAAqE;AAarE,MAAM,WAAW,GAAG;;;;;;;;;;CAUnB,CAAC;AAEF,MAAM,qBAAqB,GAAG,4BAA4B,CAAC;AAM3D;;;;;;;;GAQG;AACH,SAAgB,kBAAkB,CAChC,OAA8B,EAC9B,UAAiC,EAAE;IAEnC,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;QAC3C,MAAM,MAAM,GAAG,IAAA,mCAAsB,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAEnD,IAAI,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACvC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,CAAC,MAAM,EAAE,CACd,oBAAoB,MAAM,CAAC,IAAI,sCAAsC;cACnE,+BAA+B,MAAM,KAAK,CAC7C,CAAC;QAEF,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAE1F,OAAO;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AAC,UAAU,MAAM,cAAc,mDAAwB,GAAG;QAC3D,CAAC,CAAC,uBAAuB,CAAC;IAE5B,OAAO,GAAG,eAAe,qBAAqB,mDAAwB,GAAG,CAAC;AAC5E,CAAC;AAED,SAAS,eAAe,CAAC,MAA2B;IAClD,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;QAC3C,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;QACzC,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { type LLMPromptConfig } from '../../client/llmConfig.schema';
2
+ import { type LLMPromptKind, type LLMPromptMessage } from '../../client/promptSnapshot.typedefs';
3
+ /**
4
+ * One prompt as codegen sees it: the live Langfuse record already validated
5
+ * against the gateway config schema and reduced to exactly what the generated
6
+ * file needs to declare.
7
+ */
8
+ export interface CodegenPromptRecord {
9
+ name: string;
10
+ kind: LLMPromptKind;
11
+ version: number;
12
+ labels: string[];
13
+ requiredVariables: string[];
14
+ fallbackText: string;
15
+ fallbackMessages: LLMPromptMessage[];
16
+ config: LLMPromptConfig;
17
+ }
18
+ export interface RenderSnapshotOptions {
19
+ onWarn?: (message: string) => void;
20
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=renderSnapshot.typedefs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderSnapshot.typedefs.js","sourceRoot":"","sources":["../../../src/client/codegen/renderSnapshot.typedefs.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import { type LLMToolResult } from '../LLMService.typedefs';
2
+ /**
3
+ * The package-level tool-result normalization every tool call and delegation
4
+ * passes through before its value reaches the model. `execute` is typed to
5
+ * return `string | LLMStructuredToolResult`, but a tool is ordinary application
6
+ * code: a mistyped one can hand back an object, a number, or nothing at all.
7
+ * Coercing here keeps `[object Object]` out of the conversation without every
8
+ * tool author serializing by hand.
9
+ */
10
+ export declare function coerceToolResult(value: unknown): LLMToolResult;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.coerceToolResult = coerceToolResult;
4
+ /**
5
+ * The package-level tool-result normalization every tool call and delegation
6
+ * passes through before its value reaches the model. `execute` is typed to
7
+ * return `string | LLMStructuredToolResult`, but a tool is ordinary application
8
+ * code: a mistyped one can hand back an object, a number, or nothing at all.
9
+ * Coercing here keeps `[object Object]` out of the conversation without every
10
+ * tool author serializing by hand.
11
+ */
12
+ function coerceToolResult(value) {
13
+ if (typeof value === 'string') {
14
+ return value;
15
+ }
16
+ if (isStructuredToolResult(value)) {
17
+ return value;
18
+ }
19
+ return stringifyToolResult(value);
20
+ }
21
+ function isStructuredToolResult(value) {
22
+ if (typeof value !== 'object' || value === null || !('content' in value)) {
23
+ return false;
24
+ }
25
+ return typeof value.content === 'string';
26
+ }
27
+ function stringifyToolResult(value) {
28
+ if (value === undefined) {
29
+ return '';
30
+ }
31
+ try {
32
+ return JSON.stringify(value) ?? String(value);
33
+ }
34
+ catch {
35
+ return String(value);
36
+ }
37
+ }
38
+ //# sourceMappingURL=coerceToolResult.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerceToolResult.js","sourceRoot":"","sources":["../../src/client/coerceToolResult.ts"],"names":[],"mappings":";;AAaA,4CAUC;AAlBD;;;;;;;GAOG;AACH,SAAgB,gBAAgB,CAAC,KAAc;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,sBAAsB,CAAC,KAAK,CAAC,EAAE,CAAC;QAClC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC;AAED,SAAS,sBAAsB,CAC7B,KAAc;IAEd,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,CAAC,SAAS,IAAI,KAAK,CAAC,EAAE,CAAC;QACzE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CAAC;AAC3C,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAc;IACzC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
@@ -1,44 +1,5 @@
1
- import { type LLMProviders } from '../LLMService.typedefs';
2
- import { type InferSchema, type LLMSchemaInterface } from '../utilities/schema';
3
1
  import { type LLMPromptRegistry } from '../client/defineLLMPrompts';
4
- import { type LLMAgentInlineRunOptions, type LLMAgentRunOptions, type LLMAgentRunResult } from '../client/agentRun.typedefs';
5
- import { LLMAgent, type LLMAgentDefinition } from '../client/LLMAgent';
6
- import { type CreateLLMClientConfig, type LLMGenerateOptions, type LLMGenerateResult, type LLMPlainMessage } from '../client/createLLMClient.typedefs';
7
- import { type LLMVariableValue } from '../client/promptSnapshot.typedefs';
8
- /**
9
- * Maps each registry key to the union of variable names its prompt requires. The
10
- * generated snapshot supplies this map; defaulting to `string` keeps the client
11
- * usable before codegen has run (every variable is then tolerated).
12
- */
13
- export type LLMPromptVariableMap<Registry extends LLMPromptRegistry> = {
14
- [Key in keyof Registry]: string;
15
- };
16
- export interface LLMClient<Registry extends LLMPromptRegistry, VariableMap extends Record<keyof Registry, string>> {
17
- generate<Key extends keyof Registry, Schema extends LLMSchemaInterface = never>(prompt: Key, options: LLMGenerateOptions<Record<VariableMap[Key], LLMVariableValue> & Record<string, LLMVariableValue>, Schema>): Promise<[
18
- Schema
19
- ] extends [never] ? LLMGenerateResult<Registry[Key]> : InferSchema<Schema>>;
20
- countTokens<Key extends keyof Registry>(prompt: Key, options: {
21
- variables: Record<string, LLMVariableValue>;
22
- history?: LLMPlainMessage[];
23
- }): Promise<number>;
24
- defineAgent<Key extends keyof Registry>(definition: LLMAgentDefinition<Registry, VariableMap, Key>): LLMAgent<Registry, VariableMap, Key>;
25
- runAgent<Key extends keyof Registry>(prompt: Key, options: LLMAgentInlineRunOptions<Record<VariableMap[Key], LLMVariableValue> & Record<string, LLMVariableValue>, Registry, VariableMap>): Promise<LLMAgentRunResult<LLMGenerateResult<Registry[Key]>>>;
26
- runAgent<Key extends keyof Registry>(agent: LLMAgent<Registry, VariableMap, Key>, options: LLMAgentRunOptions<Record<VariableMap[Key], LLMVariableValue> & Record<string, LLMVariableValue>>): Promise<LLMAgentRunResult<LLMGenerateResult<Registry[Key]>>>;
27
- describePrompt<Key extends keyof Registry>(prompt: Key): Promise<LLMPromptDescription>;
28
- }
29
- /**
30
- * Read-only routing metadata for a prompt — the `{ provider, model,
31
- * promptVersion }` the runtime would serve right now (same resolve/cache/fallback
32
- * path `generate` uses). Lets analytics events record the resolved model without
33
- * coupling to `generate`'s data-only return. `isFallback` flags the snapshot
34
- * config was used because the live fetch was unreachable or failed the gate.
35
- */
36
- export interface LLMPromptDescription {
37
- provider: LLMProviders;
38
- model: string;
39
- promptVersion: number;
40
- isFallback: boolean;
41
- }
2
+ import { type CreateLLMClientConfig, type LLMClient, type LLMPromptVariableMap } from '../client/llmClient.typedefs';
42
3
  /**
43
4
  * Builds the v2 gateway client once at the composition root. The client is
44
5
  * generic over `typeof registry` (and the generated variable map), so call sites