donobu 5.56.0 → 5.57.1

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 (139) hide show
  1. package/dist/apis/GptConfigsApi.d.ts +5 -5
  2. package/dist/apis/GptConfigsApi.js +14 -14
  3. package/dist/bindings/PageInteractionTracker.d.ts +1 -1
  4. package/dist/bindings/PageInteractionTracker.js +3 -3
  5. package/dist/bindings/SetDonobuAnnotations.d.ts +1 -1
  6. package/dist/bindings/SetDonobuAnnotations.js +3 -3
  7. package/dist/cli/donobu-cli.d.ts +8 -0
  8. package/dist/cli/donobu-cli.js +23 -0
  9. package/dist/clients/AnthropicGptClient.d.ts +2 -2
  10. package/dist/clients/AnthropicGptClient.js +77 -77
  11. package/dist/clients/OpenAiGptClient.d.ts +14 -14
  12. package/dist/clients/OpenAiGptClient.js +183 -183
  13. package/dist/esm/apis/GptConfigsApi.d.ts +5 -5
  14. package/dist/esm/apis/GptConfigsApi.js +14 -14
  15. package/dist/esm/bindings/PageInteractionTracker.d.ts +1 -1
  16. package/dist/esm/bindings/PageInteractionTracker.js +3 -3
  17. package/dist/esm/bindings/SetDonobuAnnotations.d.ts +1 -1
  18. package/dist/esm/bindings/SetDonobuAnnotations.js +3 -3
  19. package/dist/esm/cli/donobu-cli.d.ts +8 -0
  20. package/dist/esm/cli/donobu-cli.js +23 -0
  21. package/dist/esm/clients/AnthropicGptClient.d.ts +2 -2
  22. package/dist/esm/clients/AnthropicGptClient.js +77 -77
  23. package/dist/esm/clients/OpenAiGptClient.d.ts +14 -14
  24. package/dist/esm/clients/OpenAiGptClient.js +183 -183
  25. package/dist/esm/lib/ai/PageAi.js +2 -1
  26. package/dist/esm/lib/page/extendPage.js +2 -1
  27. package/dist/esm/lib/test/utils/TestFileUpdater.d.ts +9 -9
  28. package/dist/esm/lib/test/utils/TestFileUpdater.js +49 -49
  29. package/dist/esm/main.d.ts +2 -0
  30. package/dist/esm/managers/AdminApiController.d.ts +16 -16
  31. package/dist/esm/managers/AdminApiController.js +35 -35
  32. package/dist/esm/managers/DonobuFlow.d.ts +41 -33
  33. package/dist/esm/managers/DonobuFlow.js +362 -532
  34. package/dist/esm/managers/DonobuFlowsManager.js +2 -10
  35. package/dist/esm/managers/FlowDependencyAnalyzer.d.ts +12 -12
  36. package/dist/esm/managers/FlowDependencyAnalyzer.js +77 -77
  37. package/dist/esm/managers/PageInspector.d.ts +38 -38
  38. package/dist/esm/managers/PageInspector.js +745 -745
  39. package/dist/esm/managers/TargetInspector.d.ts +28 -33
  40. package/dist/esm/managers/TestsManager.d.ts +25 -25
  41. package/dist/esm/managers/TestsManager.js +74 -74
  42. package/dist/esm/managers/ToolManager.js +7 -5
  43. package/dist/esm/managers/ToolRegistry.d.ts +5 -1
  44. package/dist/esm/managers/WebTargetInspector.d.ts +9 -5
  45. package/dist/esm/managers/WebTargetInspector.js +45 -47
  46. package/dist/esm/models/AiQuery.d.ts +29 -15
  47. package/dist/esm/models/AiQuery.js +31 -0
  48. package/dist/esm/models/InteractableElement.d.ts +6 -0
  49. package/dist/esm/models/InteractableElement.js +7 -1
  50. package/dist/esm/models/Observation.d.ts +38 -0
  51. package/dist/esm/models/Observation.js +3 -0
  52. package/dist/esm/models/ToolCallContext.d.ts +3 -2
  53. package/dist/esm/persistence/flows/FlowsPersistenceDonobuApi.d.ts +2 -2
  54. package/dist/esm/persistence/flows/FlowsPersistenceDonobuApi.js +19 -18
  55. package/dist/esm/persistence/flows/FlowsPersistenceSqlite.js +2 -1
  56. package/dist/esm/targets/TargetProvider.d.ts +110 -0
  57. package/dist/esm/targets/TargetProvider.js +25 -0
  58. package/dist/esm/targets/TargetRuntime.d.ts +6 -3
  59. package/dist/esm/targets/WebDialogHandler.d.ts +14 -0
  60. package/dist/esm/targets/WebDialogHandler.js +198 -0
  61. package/dist/esm/targets/WebTargetProvider.d.ts +32 -0
  62. package/dist/esm/targets/WebTargetProvider.js +136 -0
  63. package/dist/esm/targets/WebTargetRuntime.d.ts +2 -2
  64. package/dist/esm/targets/WebTargetRuntime.js +2 -1
  65. package/dist/esm/tools/AssertPageTool.d.ts +1 -1
  66. package/dist/esm/tools/AssertPageTool.js +3 -3
  67. package/dist/esm/tools/DetectBrokenLinksTool.d.ts +2 -2
  68. package/dist/esm/tools/DetectBrokenLinksTool.js +44 -44
  69. package/dist/esm/tools/InputFakerTool.d.ts +4 -4
  70. package/dist/esm/tools/InputFakerTool.js +10 -10
  71. package/dist/esm/tools/InputTextTool.d.ts +4 -4
  72. package/dist/esm/tools/InputTextTool.js +7 -7
  73. package/dist/esm/tools/ReplayableInteraction.d.ts +34 -34
  74. package/dist/esm/tools/ReplayableInteraction.js +245 -245
  75. package/dist/esm/utils/BrowserUtils.d.ts +19 -19
  76. package/dist/esm/utils/BrowserUtils.js +57 -57
  77. package/dist/esm/utils/MiscUtils.d.ts +2 -2
  78. package/dist/esm/utils/MiscUtils.js +16 -16
  79. package/dist/esm/utils/PlaywrightUtils.d.ts +1 -1
  80. package/dist/esm/utils/TargetUtils.d.ts +1 -1
  81. package/dist/esm/utils/TargetUtils.js +15 -13
  82. package/dist/lib/ai/PageAi.js +2 -1
  83. package/dist/lib/page/extendPage.js +2 -1
  84. package/dist/lib/test/utils/TestFileUpdater.d.ts +9 -9
  85. package/dist/lib/test/utils/TestFileUpdater.js +49 -49
  86. package/dist/main.d.ts +2 -0
  87. package/dist/managers/AdminApiController.d.ts +16 -16
  88. package/dist/managers/AdminApiController.js +35 -35
  89. package/dist/managers/DonobuFlow.d.ts +41 -33
  90. package/dist/managers/DonobuFlow.js +362 -532
  91. package/dist/managers/DonobuFlowsManager.js +2 -10
  92. package/dist/managers/FlowDependencyAnalyzer.d.ts +12 -12
  93. package/dist/managers/FlowDependencyAnalyzer.js +77 -77
  94. package/dist/managers/PageInspector.d.ts +38 -38
  95. package/dist/managers/PageInspector.js +745 -745
  96. package/dist/managers/TargetInspector.d.ts +28 -33
  97. package/dist/managers/TestsManager.d.ts +25 -25
  98. package/dist/managers/TestsManager.js +74 -74
  99. package/dist/managers/ToolManager.js +7 -5
  100. package/dist/managers/ToolRegistry.d.ts +5 -1
  101. package/dist/managers/WebTargetInspector.d.ts +9 -5
  102. package/dist/managers/WebTargetInspector.js +45 -47
  103. package/dist/models/AiQuery.d.ts +29 -15
  104. package/dist/models/AiQuery.js +31 -0
  105. package/dist/models/InteractableElement.d.ts +6 -0
  106. package/dist/models/InteractableElement.js +7 -1
  107. package/dist/models/Observation.d.ts +38 -0
  108. package/dist/models/Observation.js +3 -0
  109. package/dist/models/ToolCallContext.d.ts +3 -2
  110. package/dist/persistence/flows/FlowsPersistenceDonobuApi.d.ts +2 -2
  111. package/dist/persistence/flows/FlowsPersistenceDonobuApi.js +19 -18
  112. package/dist/persistence/flows/FlowsPersistenceSqlite.js +2 -1
  113. package/dist/targets/TargetProvider.d.ts +110 -0
  114. package/dist/targets/TargetProvider.js +25 -0
  115. package/dist/targets/TargetRuntime.d.ts +6 -3
  116. package/dist/targets/WebDialogHandler.d.ts +14 -0
  117. package/dist/targets/WebDialogHandler.js +198 -0
  118. package/dist/targets/WebTargetProvider.d.ts +32 -0
  119. package/dist/targets/WebTargetProvider.js +136 -0
  120. package/dist/targets/WebTargetRuntime.d.ts +2 -2
  121. package/dist/targets/WebTargetRuntime.js +2 -1
  122. package/dist/tools/AssertPageTool.d.ts +1 -1
  123. package/dist/tools/AssertPageTool.js +3 -3
  124. package/dist/tools/DetectBrokenLinksTool.d.ts +2 -2
  125. package/dist/tools/DetectBrokenLinksTool.js +44 -44
  126. package/dist/tools/InputFakerTool.d.ts +4 -4
  127. package/dist/tools/InputFakerTool.js +10 -10
  128. package/dist/tools/InputTextTool.d.ts +4 -4
  129. package/dist/tools/InputTextTool.js +7 -7
  130. package/dist/tools/ReplayableInteraction.d.ts +34 -34
  131. package/dist/tools/ReplayableInteraction.js +245 -245
  132. package/dist/utils/BrowserUtils.d.ts +19 -19
  133. package/dist/utils/BrowserUtils.js +57 -57
  134. package/dist/utils/MiscUtils.d.ts +2 -2
  135. package/dist/utils/MiscUtils.js +16 -16
  136. package/dist/utils/PlaywrightUtils.d.ts +1 -1
  137. package/dist/utils/TargetUtils.d.ts +1 -1
  138. package/dist/utils/TargetUtils.js +15 -13
  139. package/package.json +2 -1
@@ -34,6 +34,11 @@ export declare class GptConfigsApi {
34
34
  */
35
35
  private static readonly REDACTED_FIELD_NAMES;
36
36
  constructor(gptConfigsManager: GptConfigsManager, agentsManager: AgentsManager);
37
+ /**
38
+ * Redacts sensative data from the given GPT configuration so that the record
39
+ * can be safely returned through the API.
40
+ */
41
+ static redactSensativeData(config: GptConfigInput): GptConfigInput;
37
42
  /**
38
43
  * Creates or updates a GPT configuration.
39
44
  *
@@ -82,10 +87,5 @@ export declare class GptConfigsApi {
82
87
  * 3. Unlinks the configuration from all dependent agents
83
88
  */
84
89
  delete(req: Request, res: Response): Promise<void>;
85
- /**
86
- * Redacts sensative data from the given GPT configuration so that the record
87
- * can be safely returned through the API.
88
- */
89
- static redactSensativeData(config: GptConfigInput): GptConfigInput;
90
90
  }
91
91
  //# sourceMappingURL=GptConfigsApi.d.ts.map
@@ -27,6 +27,20 @@ class GptConfigsApi {
27
27
  this.gptConfigsManager = gptConfigsManager;
28
28
  this.agentsManager = agentsManager;
29
29
  }
30
+ /**
31
+ * Redacts sensative data from the given GPT configuration so that the record
32
+ * can be safely returned through the API.
33
+ */
34
+ static redactSensativeData(config) {
35
+ const configCopy = { ...config };
36
+ for (const redactedFieldName of GptConfigsApi.REDACTED_FIELD_NAMES) {
37
+ if (redactedFieldName in configCopy) {
38
+ // Use type assertion to tell TypeScript this is allowed
39
+ configCopy[redactedFieldName] = '****************';
40
+ }
41
+ }
42
+ return configCopy;
43
+ }
30
44
  /**
31
45
  * Creates or updates a GPT configuration.
32
46
  *
@@ -112,20 +126,6 @@ class GptConfigsApi {
112
126
  }
113
127
  res.json({});
114
128
  }
115
- /**
116
- * Redacts sensative data from the given GPT configuration so that the record
117
- * can be safely returned through the API.
118
- */
119
- static redactSensativeData(config) {
120
- const configCopy = { ...config };
121
- for (const redactedFieldName of GptConfigsApi.REDACTED_FIELD_NAMES) {
122
- if (redactedFieldName in configCopy) {
123
- // Use type assertion to tell TypeScript this is allowed
124
- configCopy[redactedFieldName] = '****************';
125
- }
126
- }
127
- return configCopy;
128
- }
129
129
  }
130
130
  exports.GptConfigsApi = GptConfigsApi;
131
131
  /**
@@ -46,8 +46,8 @@ export interface InteractionTrackingHost {
46
46
  export declare class PageInteractionTracker implements NamedBindingCallback {
47
47
  private readonly host;
48
48
  static readonly NAME = "__donobuTrackInteraction";
49
- static register(host: InteractionTrackingHost, browserContext: BrowserContext): Promise<PageInteractionTracker>;
50
49
  private constructor();
50
+ static register(host: InteractionTrackingHost, browserContext: BrowserContext): Promise<PageInteractionTracker>;
51
51
  name(): string;
52
52
  /**
53
53
  * Handles tracking of page interactions.
@@ -38,6 +38,9 @@ exports.InteractionEventSchema = v4_1.z.object({
38
38
  * This tracker records direct user actions for reliable replay and GPT visibility.
39
39
  */
40
40
  class PageInteractionTracker {
41
+ constructor(host) {
42
+ this.host = host;
43
+ }
41
44
  static async register(host, browserContext) {
42
45
  const instance = new PageInteractionTracker(host);
43
46
  try {
@@ -62,9 +65,6 @@ class PageInteractionTracker {
62
65
  }
63
66
  return instance;
64
67
  }
65
- constructor(host) {
66
- this.host = host;
67
- }
68
68
  name() {
69
69
  return PageInteractionTracker.NAME;
70
70
  }
@@ -9,8 +9,8 @@ import type { NamedBindingCallback } from './NamedBindingCallback';
9
9
  export declare class SetDonobuAnnotations implements NamedBindingCallback {
10
10
  private readonly pageInspector;
11
11
  static readonly NAME = "__donobuSetAnnotations";
12
- static register(pageInspector: PageInspector, browserContext: BrowserContext): Promise<SetDonobuAnnotations>;
13
12
  constructor(pageInspector: PageInspector);
13
+ static register(pageInspector: PageInspector, browserContext: BrowserContext): Promise<SetDonobuAnnotations>;
14
14
  name(): string;
15
15
  call(source: {
16
16
  context: BrowserContext;
@@ -9,6 +9,9 @@ const JsonUtils_1 = require("../utils/JsonUtils");
9
9
  * as understood by the Donobu engine.
10
10
  */
11
11
  class SetDonobuAnnotations {
12
+ constructor(pageInspector) {
13
+ this.pageInspector = pageInspector;
14
+ }
12
15
  static async register(pageInspector, browserContext) {
13
16
  const instance = new SetDonobuAnnotations(pageInspector);
14
17
  try {
@@ -19,9 +22,6 @@ class SetDonobuAnnotations {
19
22
  }
20
23
  return instance;
21
24
  }
22
- constructor(pageInspector) {
23
- this.pageInspector = pageInspector;
24
- }
25
25
  name() {
26
26
  return SetDonobuAnnotations.NAME;
27
27
  }
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { type DonobuReport } from '../reporter/model';
2
3
  declare function hasReporterArg(args: string[]): boolean;
3
4
  declare function injectJsonReporterIntoArgs(args: string[]): {
4
5
  /** True when the args contained any `--reporter` / `-r` flag. */
@@ -11,8 +12,15 @@ declare function ensureReporterValueHasJson(value: string): {
11
12
  value: string;
12
13
  changed: boolean;
13
14
  };
15
+ /**
16
+ * Read the count of still-failing tests from a merged report's stats. Returns
17
+ * `undefined` when the report lacks a numeric `unexpected` stat, signalling the
18
+ * caller to fall back to the rerun's own exit code rather than assume success.
19
+ */
20
+ declare function countUnexpectedTests(report: DonobuReport): number | undefined;
14
21
  /** @internal Exposed for unit tests only — not part of the public API. */
15
22
  export declare const _forTesting: {
23
+ countUnexpectedTests: typeof countUnexpectedTests;
16
24
  ensureReporterValueHasJson: typeof ensureReporterValueHasJson;
17
25
  hasReporterArg: typeof hasReporterArg;
18
26
  injectJsonReporterIntoArgs: typeof injectJsonReporterIntoArgs;
@@ -1416,6 +1416,18 @@ async function attemptAutoHealRun(params) {
1416
1416
  if (mergedReport) {
1417
1417
  await regenerateDonobuReports(mergedReport);
1418
1418
  await writeAutoHealPullRequestBody(mergedReport, params.playwrightOutputDir);
1419
+ // The heal rerun only re-runs the grep-filtered subset of healable
1420
+ // tests, so `healExitCode` is blind to failures triage declined to
1421
+ // retry (e.g. real product bugs). Re-derive the status from the merged
1422
+ // report so those remaining failures still fail CI. We only escalate
1423
+ // (never downgrade a non-zero heal exit) to preserve infra/crash codes.
1424
+ const remainingFailures = countUnexpectedTests(mergedReport);
1425
+ if (healExitCode === 0 &&
1426
+ remainingFailures !== undefined &&
1427
+ remainingFailures > 0) {
1428
+ Logger_1.appLogger.warn(`Auto-heal rerun passed for the healed subset, but ${remainingFailures} test(s) remain failing in the merged report. Exiting non-zero.`);
1429
+ healExitCode = 1;
1430
+ }
1419
1431
  }
1420
1432
  }
1421
1433
  }
@@ -1424,6 +1436,16 @@ async function attemptAutoHealRun(params) {
1424
1436
  }
1425
1437
  return { attempted: true, exitCode: healExitCode };
1426
1438
  }
1439
+ /**
1440
+ * Read the count of still-failing tests from a merged report's stats. Returns
1441
+ * `undefined` when the report lacks a numeric `unexpected` stat, signalling the
1442
+ * caller to fall back to the rerun's own exit code rather than assume success.
1443
+ */
1444
+ function countUnexpectedTests(report) {
1445
+ const stats = report.stats;
1446
+ const unexpected = stats?.unexpected;
1447
+ return typeof unexpected === 'number' ? unexpected : undefined;
1448
+ }
1427
1449
  /**
1428
1450
  * Filename of the auto-heal PR body artifact. Lands in the Playwright output
1429
1451
  * directory alongside the merged JSON / HTML / Markdown reports so the
@@ -2135,6 +2157,7 @@ main().catch((error) => {
2135
2157
  });
2136
2158
  /** @internal Exposed for unit tests only — not part of the public API. */
2137
2159
  exports._forTesting = {
2160
+ countUnexpectedTests,
2138
2161
  ensureReporterValueHasJson,
2139
2162
  hasReporterArg,
2140
2163
  injectJsonReporterIntoArgs,
@@ -18,6 +18,8 @@ export declare class AnthropicGptClient extends GptClient {
18
18
  private static readonly MAX_TOKENS;
19
19
  private readonly headers;
20
20
  constructor(anthropicConfig: AnthropicConfig);
21
+ private static chatRequestMessageFromGptMessage;
22
+ private static toolChoiceFromTool;
21
23
  ping(options?: {
22
24
  signal?: AbortSignal;
23
25
  }): Promise<void>;
@@ -32,7 +34,5 @@ export declare class AnthropicGptClient extends GptClient {
32
34
  }): Promise<ProposedToolCallsMessage>;
33
35
  private mapErrorResponseToDonobuException;
34
36
  private makeRequest;
35
- private static chatRequestMessageFromGptMessage;
36
- private static toolChoiceFromTool;
37
37
  }
38
38
  //# sourceMappingURL=AnthropicGptClient.d.ts.map
@@ -29,6 +29,83 @@ class AnthropicGptClient extends GptClient_1.GptClient {
29
29
  'Content-Type': AnthropicGptClient.CONTENT_TYPE_HEADER_VALUE,
30
30
  });
31
31
  }
32
+ static chatRequestMessageFromGptMessage(gptMessage) {
33
+ if (gptMessage.type === 'assistant') {
34
+ return {
35
+ role: 'assistant',
36
+ content: gptMessage.text,
37
+ };
38
+ }
39
+ if (gptMessage.type === 'structured_output') {
40
+ const output = gptMessage.output;
41
+ return {
42
+ role: 'assistant',
43
+ content: JSON.stringify(JsonUtils_1.JsonUtils.objectToJson(output), null, 2),
44
+ };
45
+ }
46
+ if (gptMessage.type === 'proposed_tool_calls') {
47
+ return {
48
+ role: 'assistant',
49
+ content: gptMessage.proposedToolCalls.map((tc) => ({
50
+ type: 'tool_use',
51
+ id: tc.toolCallId,
52
+ name: tc.name,
53
+ input: JsonUtils_1.JsonUtils.objectToJson(tc.parameters),
54
+ })),
55
+ };
56
+ }
57
+ if (gptMessage.type === 'system') {
58
+ return {
59
+ type: 'text',
60
+ text: gptMessage.text,
61
+ };
62
+ }
63
+ if (gptMessage.type === 'user') {
64
+ return {
65
+ role: 'user',
66
+ content: gptMessage.items.map((item) => {
67
+ if ('bytes' in item) {
68
+ const imageType = MiscUtils_1.MiscUtils.detectImageType(item.bytes);
69
+ const mimeType = `image/${imageType}`;
70
+ return {
71
+ type: 'image',
72
+ source: {
73
+ type: 'base64',
74
+ media_type: mimeType,
75
+ data: Buffer.from(item.bytes).toString('base64'),
76
+ },
77
+ };
78
+ }
79
+ else {
80
+ return {
81
+ type: 'text',
82
+ text: item.text,
83
+ };
84
+ }
85
+ }),
86
+ };
87
+ }
88
+ if (gptMessage.type === 'tool_call_result') {
89
+ return {
90
+ role: 'user',
91
+ content: [
92
+ {
93
+ type: 'tool_result',
94
+ tool_use_id: gptMessage.toolCallId,
95
+ content: gptMessage.data,
96
+ },
97
+ ],
98
+ };
99
+ }
100
+ throw new Error(`Unsupported message type: ${JsonUtils_1.JsonUtils.objectToJson(gptMessage)}`);
101
+ }
102
+ static toolChoiceFromTool(tool) {
103
+ return {
104
+ name: tool.name,
105
+ description: tool.description,
106
+ input_schema: v4_1.z.toJSONSchema(tool.inputSchema),
107
+ };
108
+ }
32
109
  async ping(options) {
33
110
  const resp = await this.makeRequest(`/v1/models/${this.anthropicConfig.modelName}`, 'GET', undefined, undefined, options?.signal);
34
111
  if (resp.status === 404) {
@@ -216,83 +293,6 @@ class AnthropicGptClient extends GptClient_1.GptClient {
216
293
  }
217
294
  }
218
295
  }
219
- static chatRequestMessageFromGptMessage(gptMessage) {
220
- if (gptMessage.type === 'assistant') {
221
- return {
222
- role: 'assistant',
223
- content: gptMessage.text,
224
- };
225
- }
226
- if (gptMessage.type === 'structured_output') {
227
- const output = gptMessage.output;
228
- return {
229
- role: 'assistant',
230
- content: JSON.stringify(JsonUtils_1.JsonUtils.objectToJson(output), null, 2),
231
- };
232
- }
233
- if (gptMessage.type === 'proposed_tool_calls') {
234
- return {
235
- role: 'assistant',
236
- content: gptMessage.proposedToolCalls.map((tc) => ({
237
- type: 'tool_use',
238
- id: tc.toolCallId,
239
- name: tc.name,
240
- input: JsonUtils_1.JsonUtils.objectToJson(tc.parameters),
241
- })),
242
- };
243
- }
244
- if (gptMessage.type === 'system') {
245
- return {
246
- type: 'text',
247
- text: gptMessage.text,
248
- };
249
- }
250
- if (gptMessage.type === 'user') {
251
- return {
252
- role: 'user',
253
- content: gptMessage.items.map((item) => {
254
- if ('bytes' in item) {
255
- const imageType = MiscUtils_1.MiscUtils.detectImageType(item.bytes);
256
- const mimeType = `image/${imageType}`;
257
- return {
258
- type: 'image',
259
- source: {
260
- type: 'base64',
261
- media_type: mimeType,
262
- data: Buffer.from(item.bytes).toString('base64'),
263
- },
264
- };
265
- }
266
- else {
267
- return {
268
- type: 'text',
269
- text: item.text,
270
- };
271
- }
272
- }),
273
- };
274
- }
275
- if (gptMessage.type === 'tool_call_result') {
276
- return {
277
- role: 'user',
278
- content: [
279
- {
280
- type: 'tool_result',
281
- tool_use_id: gptMessage.toolCallId,
282
- content: gptMessage.data,
283
- },
284
- ],
285
- };
286
- }
287
- throw new Error(`Unsupported message type: ${JsonUtils_1.JsonUtils.objectToJson(gptMessage)}`);
288
- }
289
- static toolChoiceFromTool(tool) {
290
- return {
291
- name: tool.name,
292
- description: tool.description,
293
- input_schema: v4_1.z.toJSONSchema(tool.inputSchema),
294
- };
295
- }
296
296
  }
297
297
  exports.AnthropicGptClient = AnthropicGptClient;
298
298
  AnthropicGptClient.API_URL = 'https://api.anthropic.com';
@@ -14,6 +14,20 @@ export declare class OpenAiGptClient extends GptClient {
14
14
  private static readonly REQUEST_TIMEOUT_MILLISECONDS;
15
15
  private readonly headers;
16
16
  constructor(openAiConfig: OpenAiConfig, apiUrl?: string);
17
+ /**
18
+ * Transform a general JSON Schema into one that fits the OpenAI Structured Outputs subset.
19
+ * Key behaviors:
20
+ * - Enforce additionalProperties:false on objects and require all defined properties.
21
+ * - Remove unsupported validation keywords.
22
+ * - Convert tuple `items: [A,B]` into `items: { anyOf: [A,B] }`.
23
+ * - Preserve $ref and $defs, cleaning nested definitions recursively.
24
+ * - If the root is `anyOf`, wrap it into an object schema with a single `value` property.
25
+ *
26
+ * Notes for optional fields:
27
+ * - Since all fields must be required, emulate optionals with union types that include "null".
28
+ * e.g., `type: ["string", "null"]` while keeping the field in `required`.
29
+ */
30
+ private static createOpenAiCompatibleJsonSchema;
17
31
  ping(options?: {
18
32
  signal?: AbortSignal;
19
33
  }): Promise<void>;
@@ -36,19 +50,5 @@ export declare class OpenAiGptClient extends GptClient {
36
50
  * Makes an HTTP request to the OpenAI API with standard configuration.
37
51
  */
38
52
  private makeRequest;
39
- /**
40
- * Transform a general JSON Schema into one that fits the OpenAI Structured Outputs subset.
41
- * Key behaviors:
42
- * - Enforce additionalProperties:false on objects and require all defined properties.
43
- * - Remove unsupported validation keywords.
44
- * - Convert tuple `items: [A,B]` into `items: { anyOf: [A,B] }`.
45
- * - Preserve $ref and $defs, cleaning nested definitions recursively.
46
- * - If the root is `anyOf`, wrap it into an object schema with a single `value` property.
47
- *
48
- * Notes for optional fields:
49
- * - Since all fields must be required, emulate optionals with union types that include "null".
50
- * e.g., `type: ["string", "null"]` while keeping the field in `required`.
51
- */
52
- private static createOpenAiCompatibleJsonSchema;
53
53
  }
54
54
  //# sourceMappingURL=OpenAiGptClient.d.ts.map