@iqai/adk 0.3.2 → 0.3.4

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @iqai/adk
2
2
 
3
+ ## 0.3.4
4
+
5
+ ### Patch Changes
6
+
7
+ - f365669: Fixes ai sdk tool response converstion
8
+
9
+ ## 0.3.3
10
+
11
+ ### Patch Changes
12
+
13
+ - 5d19967: Disables triming on errors for logger
14
+
3
15
  ## 0.3.2
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -35,6 +35,7 @@ declare class Logger {
35
35
  color?: (txt: string) => string;
36
36
  pad?: number;
37
37
  borderChar?: string;
38
+ wrap?: boolean;
38
39
  }): string;
39
40
  /**
40
41
  * Structured warning with code, suggestion, context.
package/dist/index.d.ts CHANGED
@@ -35,6 +35,7 @@ declare class Logger {
35
35
  color?: (txt: string) => string;
36
36
  pad?: number;
37
37
  borderChar?: string;
38
+ wrap?: boolean;
38
39
  }): string;
39
40
  /**
40
41
  * Structured warning with code, suggestion, context.
package/dist/index.js CHANGED
@@ -82,7 +82,8 @@ var init_logger = __esm({
82
82
  title: `${icon} ${this.capitalize(level)} @ ${time} (${this.name})`,
83
83
  description: message,
84
84
  lines,
85
- color
85
+ color,
86
+ wrap: true
86
87
  });
87
88
  method(box);
88
89
  } else {
@@ -109,7 +110,7 @@ var init_logger = __esm({
109
110
  }
110
111
  formatArgs(args, includeStack = false) {
111
112
  const lines = [];
112
- const maxFrames = Number(process.env.ADK_ERROR_STACK_FRAMES || 8);
113
+ const maxFrames = process.env.ADK_ERROR_STACK_FRAMES !== void 0 ? Number(process.env.ADK_ERROR_STACK_FRAMES) : Number.POSITIVE_INFINITY;
113
114
  for (const arg of args) {
114
115
  if (!arg) continue;
115
116
  if (arg instanceof Error) {
@@ -161,7 +162,8 @@ var init_logger = __esm({
161
162
  maxWidthPct = 0.9,
162
163
  color = _chalk2.default.yellow,
163
164
  pad = 1,
164
- borderChar = "\u2500"
165
+ borderChar = "\u2500",
166
+ wrap = false
165
167
  } = params;
166
168
  const isProd = process.env.NODE_ENV === "production";
167
169
  const forceBoxes = process.env.ADK_FORCE_BOXES === "true";
@@ -181,20 +183,41 @@ var init_logger = __esm({
181
183
  const top = `\u250C${horizontal}\u2510`;
182
184
  const separator = `\u251C${horizontal}\u2524`;
183
185
  const bottom = `\u2514${horizontal}\u2518`;
184
- const padLine = (text) => {
185
- const maxContent = innerWidth - pad * 2;
186
- const truncated = text.length > maxContent ? `${text.slice(0, maxContent - 1)}\u2026` : text;
187
- const padded = " ".repeat(pad) + truncated;
188
- return padded + " ".repeat(innerWidth - padded.length);
186
+ const maxContent = innerWidth - pad * 2;
187
+ const wrapText = (text) => {
188
+ if (!wrap) {
189
+ const truncated = text.length > maxContent ? `${text.slice(0, maxContent - 1)}\u2026` : text;
190
+ const padded = " ".repeat(pad) + truncated;
191
+ return [padded + " ".repeat(innerWidth - padded.length)];
192
+ }
193
+ const out = [];
194
+ let remaining = text;
195
+ while (remaining.length > 0) {
196
+ if (remaining.length <= maxContent) {
197
+ const padded2 = " ".repeat(pad) + remaining;
198
+ out.push(padded2 + " ".repeat(innerWidth - padded2.length));
199
+ break;
200
+ }
201
+ let sliceEnd = maxContent;
202
+ const slice = remaining.slice(0, maxContent + 1);
203
+ const lastSpace = slice.lastIndexOf(" ");
204
+ if (lastSpace > -1 && lastSpace >= Math.floor(maxContent * 0.6)) {
205
+ sliceEnd = lastSpace;
206
+ }
207
+ const chunk = remaining.slice(0, sliceEnd).trimEnd();
208
+ const padded = " ".repeat(pad) + chunk;
209
+ out.push(padded + " ".repeat(innerWidth - padded.length));
210
+ remaining = remaining.slice(sliceEnd).trimStart();
211
+ }
212
+ return out;
189
213
  };
190
- const content = [
191
- top,
192
- `\u2502 ${padLine(title)} \u2502`,
193
- separator,
194
- `\u2502 ${padLine(description)} \u2502`,
195
- ...lines.map((line) => `\u2502 ${padLine(line)} \u2502`),
196
- bottom
197
- ];
214
+ const content = [top];
215
+ for (const l of wrapText(title)) content.push(`\u2502 ${l} \u2502`);
216
+ content.push(separator);
217
+ for (const l of wrapText(description)) content.push(`\u2502 ${l} \u2502`);
218
+ for (const line of lines)
219
+ for (const l of wrapText(line)) content.push(`\u2502 ${l} \u2502`);
220
+ content.push(bottom);
198
221
  return `
199
222
  ${content.map((line) => color(line)).join("\n")}`;
200
223
  }
@@ -1751,11 +1774,19 @@ var AiSdkLlm = (_class6 = class extends BaseLlm {
1751
1774
  (part) => part.functionResponse
1752
1775
  );
1753
1776
  const contentParts2 = functionResponses.map((part) => {
1777
+ let output = part.functionResponse.response;
1778
+ if (!output || typeof output === "object" && Object.keys(output).length === 0) {
1779
+ output = JSON.stringify(output || {});
1780
+ } else if (typeof output === "object") {
1781
+ output = JSON.stringify(output);
1782
+ } else if (typeof output !== "string") {
1783
+ output = String(output);
1784
+ }
1754
1785
  return {
1755
1786
  type: "tool-result",
1756
1787
  toolCallId: part.functionResponse.id,
1757
1788
  toolName: part.functionResponse.name || "unknown",
1758
- output: part.functionResponse.response
1789
+ output
1759
1790
  };
1760
1791
  });
1761
1792
  return {
package/dist/index.mjs CHANGED
@@ -82,7 +82,8 @@ var init_logger = __esm({
82
82
  title: `${icon} ${this.capitalize(level)} @ ${time} (${this.name})`,
83
83
  description: message,
84
84
  lines,
85
- color
85
+ color,
86
+ wrap: true
86
87
  });
87
88
  method(box);
88
89
  } else {
@@ -109,7 +110,7 @@ var init_logger = __esm({
109
110
  }
110
111
  formatArgs(args, includeStack = false) {
111
112
  const lines = [];
112
- const maxFrames = Number(process.env.ADK_ERROR_STACK_FRAMES || 8);
113
+ const maxFrames = process.env.ADK_ERROR_STACK_FRAMES !== void 0 ? Number(process.env.ADK_ERROR_STACK_FRAMES) : Number.POSITIVE_INFINITY;
113
114
  for (const arg of args) {
114
115
  if (!arg) continue;
115
116
  if (arg instanceof Error) {
@@ -161,7 +162,8 @@ var init_logger = __esm({
161
162
  maxWidthPct = 0.9,
162
163
  color = chalk.yellow,
163
164
  pad = 1,
164
- borderChar = "\u2500"
165
+ borderChar = "\u2500",
166
+ wrap = false
165
167
  } = params;
166
168
  const isProd = process.env.NODE_ENV === "production";
167
169
  const forceBoxes = process.env.ADK_FORCE_BOXES === "true";
@@ -181,20 +183,41 @@ var init_logger = __esm({
181
183
  const top = `\u250C${horizontal}\u2510`;
182
184
  const separator = `\u251C${horizontal}\u2524`;
183
185
  const bottom = `\u2514${horizontal}\u2518`;
184
- const padLine = (text) => {
185
- const maxContent = innerWidth - pad * 2;
186
- const truncated = text.length > maxContent ? `${text.slice(0, maxContent - 1)}\u2026` : text;
187
- const padded = " ".repeat(pad) + truncated;
188
- return padded + " ".repeat(innerWidth - padded.length);
186
+ const maxContent = innerWidth - pad * 2;
187
+ const wrapText = (text) => {
188
+ if (!wrap) {
189
+ const truncated = text.length > maxContent ? `${text.slice(0, maxContent - 1)}\u2026` : text;
190
+ const padded = " ".repeat(pad) + truncated;
191
+ return [padded + " ".repeat(innerWidth - padded.length)];
192
+ }
193
+ const out = [];
194
+ let remaining = text;
195
+ while (remaining.length > 0) {
196
+ if (remaining.length <= maxContent) {
197
+ const padded2 = " ".repeat(pad) + remaining;
198
+ out.push(padded2 + " ".repeat(innerWidth - padded2.length));
199
+ break;
200
+ }
201
+ let sliceEnd = maxContent;
202
+ const slice = remaining.slice(0, maxContent + 1);
203
+ const lastSpace = slice.lastIndexOf(" ");
204
+ if (lastSpace > -1 && lastSpace >= Math.floor(maxContent * 0.6)) {
205
+ sliceEnd = lastSpace;
206
+ }
207
+ const chunk = remaining.slice(0, sliceEnd).trimEnd();
208
+ const padded = " ".repeat(pad) + chunk;
209
+ out.push(padded + " ".repeat(innerWidth - padded.length));
210
+ remaining = remaining.slice(sliceEnd).trimStart();
211
+ }
212
+ return out;
189
213
  };
190
- const content = [
191
- top,
192
- `\u2502 ${padLine(title)} \u2502`,
193
- separator,
194
- `\u2502 ${padLine(description)} \u2502`,
195
- ...lines.map((line) => `\u2502 ${padLine(line)} \u2502`),
196
- bottom
197
- ];
214
+ const content = [top];
215
+ for (const l of wrapText(title)) content.push(`\u2502 ${l} \u2502`);
216
+ content.push(separator);
217
+ for (const l of wrapText(description)) content.push(`\u2502 ${l} \u2502`);
218
+ for (const line of lines)
219
+ for (const l of wrapText(line)) content.push(`\u2502 ${l} \u2502`);
220
+ content.push(bottom);
198
221
  return `
199
222
  ${content.map((line) => color(line)).join("\n")}`;
200
223
  }
@@ -1751,11 +1774,19 @@ var AiSdkLlm = class extends BaseLlm {
1751
1774
  (part) => part.functionResponse
1752
1775
  );
1753
1776
  const contentParts2 = functionResponses.map((part) => {
1777
+ let output = part.functionResponse.response;
1778
+ if (!output || typeof output === "object" && Object.keys(output).length === 0) {
1779
+ output = JSON.stringify(output || {});
1780
+ } else if (typeof output === "object") {
1781
+ output = JSON.stringify(output);
1782
+ } else if (typeof output !== "string") {
1783
+ output = String(output);
1784
+ }
1754
1785
  return {
1755
1786
  type: "tool-result",
1756
1787
  toolCallId: part.functionResponse.id,
1757
1788
  toolName: part.functionResponse.name || "unknown",
1758
- output: part.functionResponse.response
1789
+ output
1759
1790
  };
1760
1791
  });
1761
1792
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iqai/adk",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "Agent Development Kit for TypeScript with multi-provider LLM support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",