modality-ai 0.7.3 → 0.7.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.
package/dist/index.js CHANGED
@@ -126465,16 +126465,31 @@ class ModalityClientImpl {
126465
126465
  }
126466
126466
  }
126467
126467
  parseContent(toolResult) {
126468
- try {
126469
- const content = toolResult?.content?.[0];
126470
- if (content?.type === "text" && content.text) {
126471
- return JSON.parse(content.text);
126468
+ const blocks = Array.isArray(toolResult?.content) ? toolResult.content : [];
126469
+ const parsed = blocks.filter((b) => b?.type === "text" && b.text).map((b) => {
126470
+ try {
126471
+ return JSON.parse(b.text);
126472
+ } catch {
126473
+ return b.text;
126472
126474
  }
126473
- return content ?? toolResult;
126474
- } catch {
126475
- const content = toolResult?.content?.[0];
126476
- return content?.text ?? content ?? toolResult;
126475
+ });
126476
+ if (parsed.length === 0) {
126477
+ return toolResult?.content?.[0] ?? toolResult;
126478
+ }
126479
+ const objects = parsed.filter((p) => typeof p === "object" && p !== null && !Array.isArray(p));
126480
+ const extras = parsed.filter((p) => typeof p !== "object" || p === null || Array.isArray(p));
126481
+ if (objects.length === 0) {
126482
+ return parsed.length === 1 ? parsed[0] : parsed;
126483
+ }
126484
+ const merged = Object.assign({}, ...objects);
126485
+ if (extras.length > 0) {
126486
+ const key = objects.some((o) => ("_extra" in o)) ? "__extra" : "_extra";
126487
+ merged[key] = extras.length === 1 ? extras[0] : extras;
126488
+ }
126489
+ if (merged.success === undefined) {
126490
+ merged.success = toolResult?.isError !== true;
126477
126491
  }
126492
+ return merged;
126478
126493
  }
126479
126494
  }
126480
126495
  function http(url3, timeout, options) {
@@ -126898,6 +126913,12 @@ ${contentString}
126898
126913
  }
126899
126914
  }
126900
126915
 
126916
+ // src/const.ts
126917
+ var GeminiDefaultModels = [
126918
+ "gemini-3.1-flash-lite",
126919
+ "gemini-3.1-flash-lite-preview"
126920
+ ];
126921
+
126901
126922
  // src/util_ai_model.ts
126902
126923
  var evictKey = [];
126903
126924
  function getRandomApiKey(baseKeyName, keyCount) {
@@ -126972,11 +126993,6 @@ class OllamaProvider {
126972
126993
  }
126973
126994
  }
126974
126995
  }
126975
- var GeminiDefaultModels = [
126976
- "gemini-3-flash",
126977
- "gemini-3.1-flash-lite",
126978
- "gemini-flash-latest"
126979
- ];
126980
126996
 
126981
126997
  class GeminiProvider {
126982
126998
  config;
@@ -47,6 +47,19 @@ declare class ModalityClientImpl {
47
47
  callStream(method: string, params?: any, callback?: (p: any) => void): ReadableStream;
48
48
  close(): Promise<void>;
49
49
  listTools(): Promise<ListToolsResult>;
50
+ /**
51
+ * Parse a CallToolResult into a plain value.
52
+ *
53
+ * modality-kit's `formatSuccessResponse(data, meta)` splits results across
54
+ * text blocks — block 0 is the envelope (`{message}`), blocks 1+ carry the
55
+ * payload — so ALL text blocks are parsed and object blocks shallow-merged
56
+ * (later blocks win on key collisions). Non-object blocks (e.g. the
57
+ * `DEBUG=1` "Response size" note) are collected under `_extra` (or
58
+ * `__extra` when the tool's payload already carries `_extra`).
59
+ *
60
+ * The merged object always carries `success`: derived from the MCP-level
61
+ * `isError` flag unless the tool set it explicitly.
62
+ */
50
63
  parseContent(toolResult: any): unknown;
51
64
  }
52
65
  export type ModalityClientInstance = ModalityClientImpl;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Shared Constants
3
+ */
4
+ export declare const GeminiDefaultModels: string[];
@@ -63,6 +63,9 @@ export declare class OllamaProvider implements AIProviderInterface {
63
63
  */
64
64
  chat(messages: ModelMessage[], options?: ChatOptions): Promise<ChatResponse>;
65
65
  }
66
+ /**
67
+ * Gemini AI Provider Implementation
68
+ */
66
69
  export declare class GeminiProvider implements AIProviderInterface {
67
70
  private config;
68
71
  private model;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.7.3",
2
+ "version": "0.7.5",
3
3
  "name": "modality-ai",
4
4
  "repository": {
5
5
  "type": "git",