@makemind/sdk 0.2.0 → 0.2.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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,21 @@ All notable changes to `@makemind/sdk` will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## 0.2.1 — 2026-10-12
9
+
10
+ ### Fixed
11
+
12
+ - `ai.analyzeDocument()` sends the document. It used to send the words
13
+ "Document URL: …" to a chat model, which never saw the document and answered
14
+ anyway. The document goes as a `document` part (an https address or a data
15
+ URI), and only a model that reads PDFs is chosen for it.
16
+
17
+ ### Added
18
+
19
+ - `ai.ocr(document, { pages?, mediaType?, model? })` — the document's text as
20
+ written, page by page and line by line with confidence and position; at most
21
+ 30 pages per call, `more` while a next window may hold pages.
22
+
8
23
  ## 0.2.0 — 2026-10-09
9
24
 
10
25
  ### Changed — breaking
package/dist/index.d.mts CHANGED
@@ -1907,6 +1907,30 @@ interface ToolDefinition {
1907
1907
  description: string;
1908
1908
  parameters: Record<string, unknown>;
1909
1909
  }
1910
+ /** One line an OCR engine read: its text, confidence and box (0–1: left, top, right, bottom). */
1911
+ interface OcrLine {
1912
+ text: string;
1913
+ confidence: number;
1914
+ box: [number, number, number, number];
1915
+ }
1916
+ /** One page an OCR engine read. */
1917
+ interface OcrPage {
1918
+ number: number;
1919
+ width: number;
1920
+ height: number;
1921
+ text: string;
1922
+ confidence: number;
1923
+ lines: OcrLine[];
1924
+ }
1925
+ /** What `ocr()` answers: the pages read, and whether a next window may hold more. */
1926
+ interface OcrResult {
1927
+ requestId: string;
1928
+ model: string;
1929
+ pages: OcrPage[];
1930
+ more: boolean;
1931
+ cost: number;
1932
+ currency?: string;
1933
+ }
1910
1934
  declare class MAKEMINDAI {
1911
1935
  private apiClient;
1912
1936
  private getTenantId;
@@ -1991,20 +2015,35 @@ declare class MAKEMINDAI {
1991
2015
  }>;
1992
2016
  /**
1993
2017
  * Document analysis (summary, field extraction, or QA).
1994
- * No dedicated onCall exists in the ai domain; implemented via ai-aiChat
1995
- * with a structured system prompt that targets the requested analysis type.
1996
- * The document content must be fetched by the caller and passed as text —
1997
- * the backend has no URL-fetch / OCR pipeline for onCall yet.
2018
+ * The document itself is sent — a PDF as a `document` part, which the
2019
+ * platform hands only to a model that reads PDFs (core-ai 18 §5.2). `document`
2020
+ * is an https address the platform reads, or a `data:application/pdf;base64,…`
2021
+ * URI.
1998
2022
  */
1999
- analyzeDocument(documentUrl: string, analysisType: 'summary' | 'extract' | 'qa', options?: {
2023
+ analyzeDocument(document: string, analysisType: 'summary' | 'extract' | 'qa', options?: {
2000
2024
  question?: string;
2001
2025
  extractFields?: string[];
2026
+ model?: string;
2002
2027
  }): Promise<{
2003
2028
  result: string | Record<string, unknown>;
2004
2029
  usage: {
2005
2030
  totalTokens: number;
2006
2031
  };
2007
2032
  }>;
2033
+ /**
2034
+ * A document's text as written, page by page and line by line, from an OCR
2035
+ * engine — each line with its confidence and its box on the page (core-ai 18
2036
+ * §5.3). One call reads at most 30 pages; read the next window while `more`.
2037
+ * `document` is an https address or a data URI (PDF, PNG, JPEG, TIFF).
2038
+ */
2039
+ ocr(document: string, options?: {
2040
+ pages?: {
2041
+ from?: number;
2042
+ to?: number;
2043
+ };
2044
+ mediaType?: string;
2045
+ model?: string;
2046
+ }): Promise<OcrResult>;
2008
2047
  generate(prompt: string, options?: ChatOptions): Promise<{
2009
2048
  text: string;
2010
2049
  usage: {
@@ -3083,4 +3122,4 @@ declare const ErrorCodes: {
3083
3122
  readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
3084
3123
  };
3085
3124
 
3086
- export { ApiClient, type ApiClientConfig, type ApiRequestOptions, type AuthStateCallback, type AuthUser, type BillingSummary, type CollectionSnapshotCallback, type ConsultResult, type ConsultationConclusion, type CreateOptions, type DeleteOptions, type DocumentResult, ErrorCodes, type ExpertAccess, ExpertChat, type ExpertChatWidget, type ExpertChatWidgetOptions, type ExpertConsultation, ExpertDoorError, type ExpertSession, type ExpertTurn, type FileMetadata, type FlowListItem, type GetOptions, type Invoice, type ListFilesOptions, type ListFilesResult, type ListFlowsParams, type ListFlowsResult, type LogicCallResult, MAKEMINDAI, type MAKEMINDAIConfig, MAKEMINDApps, type MAKEMINDAppsConfig, MAKEMINDAuth, type MAKEMINDAuthConfig, MAKEMINDClient, type MAKEMINDClientConfig, type MAKEMINDConfig, MAKEMINDData, type MAKEMINDDataConfig, MAKEMINDError, MAKEMINDExperts, type MAKEMINDExpertsConfig, MAKEMINDLogic, type MAKEMINDLogicConfig, MAKEMINDMarketplace, type MAKEMINDMarketplaceConfig, MAKEMINDMessaging, type MAKEMINDMessagingConfig, MAKEMINDSearch, type MAKEMINDSearchConfig, MAKEMINDSettlement, type MAKEMINDSettlementConfig, MAKEMINDStorage, type MAKEMINDStorageConfig, MAKEMINDTenant, type MAKEMINDTenantConfig, type Notification, type OrderBy, type PlatformErrorDetails, type QueryCondition, type QueryOptions, type QueryResult, type SendMessageOptions, type SnapshotCallback, type Tenant, type TenantClaims, type TenantMember, type Unsubscribe, type UpdateOptions, type UploadOptions, type UploadResult, type UsageEventOptions, type UsageStats, type WorkflowTransitionOptions, type Workspace, getMAKEMIND, initializeMAKEMIND, mountExpertChat };
3125
+ export { ApiClient, type ApiClientConfig, type ApiRequestOptions, type AuthStateCallback, type AuthUser, type BillingSummary, type CollectionSnapshotCallback, type ConsultResult, type ConsultationConclusion, type CreateOptions, type DeleteOptions, type DocumentResult, ErrorCodes, type ExpertAccess, ExpertChat, type ExpertChatWidget, type ExpertChatWidgetOptions, type ExpertConsultation, ExpertDoorError, type ExpertSession, type ExpertTurn, type FileMetadata, type FlowListItem, type GetOptions, type Invoice, type ListFilesOptions, type ListFilesResult, type ListFlowsParams, type ListFlowsResult, type LogicCallResult, MAKEMINDAI, type MAKEMINDAIConfig, MAKEMINDApps, type MAKEMINDAppsConfig, MAKEMINDAuth, type MAKEMINDAuthConfig, MAKEMINDClient, type MAKEMINDClientConfig, type MAKEMINDConfig, MAKEMINDData, type MAKEMINDDataConfig, MAKEMINDError, MAKEMINDExperts, type MAKEMINDExpertsConfig, MAKEMINDLogic, type MAKEMINDLogicConfig, MAKEMINDMarketplace, type MAKEMINDMarketplaceConfig, MAKEMINDMessaging, type MAKEMINDMessagingConfig, MAKEMINDSearch, type MAKEMINDSearchConfig, MAKEMINDSettlement, type MAKEMINDSettlementConfig, MAKEMINDStorage, type MAKEMINDStorageConfig, MAKEMINDTenant, type MAKEMINDTenantConfig, type Notification, type OcrLine, type OcrPage, type OcrResult, type OrderBy, type PlatformErrorDetails, type QueryCondition, type QueryOptions, type QueryResult, type SendMessageOptions, type SnapshotCallback, type Tenant, type TenantClaims, type TenantMember, type Unsubscribe, type UpdateOptions, type UploadOptions, type UploadResult, type UsageEventOptions, type UsageStats, type WorkflowTransitionOptions, type Workspace, getMAKEMIND, initializeMAKEMIND, mountExpertChat };
package/dist/index.d.ts CHANGED
@@ -1907,6 +1907,30 @@ interface ToolDefinition {
1907
1907
  description: string;
1908
1908
  parameters: Record<string, unknown>;
1909
1909
  }
1910
+ /** One line an OCR engine read: its text, confidence and box (0–1: left, top, right, bottom). */
1911
+ interface OcrLine {
1912
+ text: string;
1913
+ confidence: number;
1914
+ box: [number, number, number, number];
1915
+ }
1916
+ /** One page an OCR engine read. */
1917
+ interface OcrPage {
1918
+ number: number;
1919
+ width: number;
1920
+ height: number;
1921
+ text: string;
1922
+ confidence: number;
1923
+ lines: OcrLine[];
1924
+ }
1925
+ /** What `ocr()` answers: the pages read, and whether a next window may hold more. */
1926
+ interface OcrResult {
1927
+ requestId: string;
1928
+ model: string;
1929
+ pages: OcrPage[];
1930
+ more: boolean;
1931
+ cost: number;
1932
+ currency?: string;
1933
+ }
1910
1934
  declare class MAKEMINDAI {
1911
1935
  private apiClient;
1912
1936
  private getTenantId;
@@ -1991,20 +2015,35 @@ declare class MAKEMINDAI {
1991
2015
  }>;
1992
2016
  /**
1993
2017
  * Document analysis (summary, field extraction, or QA).
1994
- * No dedicated onCall exists in the ai domain; implemented via ai-aiChat
1995
- * with a structured system prompt that targets the requested analysis type.
1996
- * The document content must be fetched by the caller and passed as text —
1997
- * the backend has no URL-fetch / OCR pipeline for onCall yet.
2018
+ * The document itself is sent — a PDF as a `document` part, which the
2019
+ * platform hands only to a model that reads PDFs (core-ai 18 §5.2). `document`
2020
+ * is an https address the platform reads, or a `data:application/pdf;base64,…`
2021
+ * URI.
1998
2022
  */
1999
- analyzeDocument(documentUrl: string, analysisType: 'summary' | 'extract' | 'qa', options?: {
2023
+ analyzeDocument(document: string, analysisType: 'summary' | 'extract' | 'qa', options?: {
2000
2024
  question?: string;
2001
2025
  extractFields?: string[];
2026
+ model?: string;
2002
2027
  }): Promise<{
2003
2028
  result: string | Record<string, unknown>;
2004
2029
  usage: {
2005
2030
  totalTokens: number;
2006
2031
  };
2007
2032
  }>;
2033
+ /**
2034
+ * A document's text as written, page by page and line by line, from an OCR
2035
+ * engine — each line with its confidence and its box on the page (core-ai 18
2036
+ * §5.3). One call reads at most 30 pages; read the next window while `more`.
2037
+ * `document` is an https address or a data URI (PDF, PNG, JPEG, TIFF).
2038
+ */
2039
+ ocr(document: string, options?: {
2040
+ pages?: {
2041
+ from?: number;
2042
+ to?: number;
2043
+ };
2044
+ mediaType?: string;
2045
+ model?: string;
2046
+ }): Promise<OcrResult>;
2008
2047
  generate(prompt: string, options?: ChatOptions): Promise<{
2009
2048
  text: string;
2010
2049
  usage: {
@@ -3083,4 +3122,4 @@ declare const ErrorCodes: {
3083
3122
  readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
3084
3123
  };
3085
3124
 
3086
- export { ApiClient, type ApiClientConfig, type ApiRequestOptions, type AuthStateCallback, type AuthUser, type BillingSummary, type CollectionSnapshotCallback, type ConsultResult, type ConsultationConclusion, type CreateOptions, type DeleteOptions, type DocumentResult, ErrorCodes, type ExpertAccess, ExpertChat, type ExpertChatWidget, type ExpertChatWidgetOptions, type ExpertConsultation, ExpertDoorError, type ExpertSession, type ExpertTurn, type FileMetadata, type FlowListItem, type GetOptions, type Invoice, type ListFilesOptions, type ListFilesResult, type ListFlowsParams, type ListFlowsResult, type LogicCallResult, MAKEMINDAI, type MAKEMINDAIConfig, MAKEMINDApps, type MAKEMINDAppsConfig, MAKEMINDAuth, type MAKEMINDAuthConfig, MAKEMINDClient, type MAKEMINDClientConfig, type MAKEMINDConfig, MAKEMINDData, type MAKEMINDDataConfig, MAKEMINDError, MAKEMINDExperts, type MAKEMINDExpertsConfig, MAKEMINDLogic, type MAKEMINDLogicConfig, MAKEMINDMarketplace, type MAKEMINDMarketplaceConfig, MAKEMINDMessaging, type MAKEMINDMessagingConfig, MAKEMINDSearch, type MAKEMINDSearchConfig, MAKEMINDSettlement, type MAKEMINDSettlementConfig, MAKEMINDStorage, type MAKEMINDStorageConfig, MAKEMINDTenant, type MAKEMINDTenantConfig, type Notification, type OrderBy, type PlatformErrorDetails, type QueryCondition, type QueryOptions, type QueryResult, type SendMessageOptions, type SnapshotCallback, type Tenant, type TenantClaims, type TenantMember, type Unsubscribe, type UpdateOptions, type UploadOptions, type UploadResult, type UsageEventOptions, type UsageStats, type WorkflowTransitionOptions, type Workspace, getMAKEMIND, initializeMAKEMIND, mountExpertChat };
3125
+ export { ApiClient, type ApiClientConfig, type ApiRequestOptions, type AuthStateCallback, type AuthUser, type BillingSummary, type CollectionSnapshotCallback, type ConsultResult, type ConsultationConclusion, type CreateOptions, type DeleteOptions, type DocumentResult, ErrorCodes, type ExpertAccess, ExpertChat, type ExpertChatWidget, type ExpertChatWidgetOptions, type ExpertConsultation, ExpertDoorError, type ExpertSession, type ExpertTurn, type FileMetadata, type FlowListItem, type GetOptions, type Invoice, type ListFilesOptions, type ListFilesResult, type ListFlowsParams, type ListFlowsResult, type LogicCallResult, MAKEMINDAI, type MAKEMINDAIConfig, MAKEMINDApps, type MAKEMINDAppsConfig, MAKEMINDAuth, type MAKEMINDAuthConfig, MAKEMINDClient, type MAKEMINDClientConfig, type MAKEMINDConfig, MAKEMINDData, type MAKEMINDDataConfig, MAKEMINDError, MAKEMINDExperts, type MAKEMINDExpertsConfig, MAKEMINDLogic, type MAKEMINDLogicConfig, MAKEMINDMarketplace, type MAKEMINDMarketplaceConfig, MAKEMINDMessaging, type MAKEMINDMessagingConfig, MAKEMINDSearch, type MAKEMINDSearchConfig, MAKEMINDSettlement, type MAKEMINDSettlementConfig, MAKEMINDStorage, type MAKEMINDStorageConfig, MAKEMINDTenant, type MAKEMINDTenantConfig, type Notification, type OcrLine, type OcrPage, type OcrResult, type OrderBy, type PlatformErrorDetails, type QueryCondition, type QueryOptions, type QueryResult, type SendMessageOptions, type SnapshotCallback, type Tenant, type TenantClaims, type TenantMember, type Unsubscribe, type UpdateOptions, type UploadOptions, type UploadResult, type UsageEventOptions, type UsageStats, type WorkflowTransitionOptions, type Workspace, getMAKEMIND, initializeMAKEMIND, mountExpertChat };
package/dist/index.js CHANGED
@@ -2851,12 +2851,12 @@ var MAKEMINDAI = class {
2851
2851
  }
2852
2852
  /**
2853
2853
  * Document analysis (summary, field extraction, or QA).
2854
- * No dedicated onCall exists in the ai domain; implemented via ai-aiChat
2855
- * with a structured system prompt that targets the requested analysis type.
2856
- * The document content must be fetched by the caller and passed as text —
2857
- * the backend has no URL-fetch / OCR pipeline for onCall yet.
2854
+ * The document itself is sent — a PDF as a `document` part, which the
2855
+ * platform hands only to a model that reads PDFs (core-ai 18 §5.2). `document`
2856
+ * is an https address the platform reads, or a `data:application/pdf;base64,…`
2857
+ * URI.
2858
2858
  */
2859
- async analyzeDocument(documentUrl, analysisType, options) {
2859
+ async analyzeDocument(document2, analysisType, options) {
2860
2860
  const systemPromptMap = {
2861
2861
  summary: "You are a document summarization assistant. Summarize the provided document concisely.",
2862
2862
  extract: `You are a document extraction assistant. Extract the following fields from the document as JSON: ${(options?.extractFields ?? []).join(", ")}.`,
@@ -2864,9 +2864,10 @@ var MAKEMINDAI = class {
2864
2864
  };
2865
2865
  const response = await this.apiClient.dispatch("ai-aiChat", {
2866
2866
  tenantId: this.getTenantId(),
2867
+ ...options?.model ? { model: options.model } : {},
2867
2868
  messages: [
2868
2869
  { role: "system", content: systemPromptMap[analysisType] },
2869
- { role: "user", content: `Document URL: ${documentUrl}` }
2870
+ { role: "user", content: [{ type: "document", document: { url: document2 } }] }
2870
2871
  ]
2871
2872
  });
2872
2873
  let result = response.content;
@@ -2882,6 +2883,20 @@ var MAKEMINDAI = class {
2882
2883
  usage: { totalTokens: response.usage.totalTokens }
2883
2884
  };
2884
2885
  }
2886
+ /**
2887
+ * A document's text as written, page by page and line by line, from an OCR
2888
+ * engine — each line with its confidence and its box on the page (core-ai 18
2889
+ * §5.3). One call reads at most 30 pages; read the next window while `more`.
2890
+ * `document` is an https address or a data URI (PDF, PNG, JPEG, TIFF).
2891
+ */
2892
+ async ocr(document2, options) {
2893
+ return this.apiClient.dispatch("ai-aiOcr", {
2894
+ tenantId: this.getTenantId(),
2895
+ document: { url: document2, ...options?.mediaType ? { mediaType: options.mediaType } : {} },
2896
+ ...options?.pages ? { pages: options.pages } : {},
2897
+ ...options?.model ? { model: options.model } : {}
2898
+ });
2899
+ }
2885
2900
  // Text generation
2886
2901
  async generate(prompt, options) {
2887
2902
  const response = await this.chat(
package/dist/index.mjs CHANGED
@@ -2795,12 +2795,12 @@ var MAKEMINDAI = class {
2795
2795
  }
2796
2796
  /**
2797
2797
  * Document analysis (summary, field extraction, or QA).
2798
- * No dedicated onCall exists in the ai domain; implemented via ai-aiChat
2799
- * with a structured system prompt that targets the requested analysis type.
2800
- * The document content must be fetched by the caller and passed as text —
2801
- * the backend has no URL-fetch / OCR pipeline for onCall yet.
2798
+ * The document itself is sent — a PDF as a `document` part, which the
2799
+ * platform hands only to a model that reads PDFs (core-ai 18 §5.2). `document`
2800
+ * is an https address the platform reads, or a `data:application/pdf;base64,…`
2801
+ * URI.
2802
2802
  */
2803
- async analyzeDocument(documentUrl, analysisType, options) {
2803
+ async analyzeDocument(document2, analysisType, options) {
2804
2804
  const systemPromptMap = {
2805
2805
  summary: "You are a document summarization assistant. Summarize the provided document concisely.",
2806
2806
  extract: `You are a document extraction assistant. Extract the following fields from the document as JSON: ${(options?.extractFields ?? []).join(", ")}.`,
@@ -2808,9 +2808,10 @@ var MAKEMINDAI = class {
2808
2808
  };
2809
2809
  const response = await this.apiClient.dispatch("ai-aiChat", {
2810
2810
  tenantId: this.getTenantId(),
2811
+ ...options?.model ? { model: options.model } : {},
2811
2812
  messages: [
2812
2813
  { role: "system", content: systemPromptMap[analysisType] },
2813
- { role: "user", content: `Document URL: ${documentUrl}` }
2814
+ { role: "user", content: [{ type: "document", document: { url: document2 } }] }
2814
2815
  ]
2815
2816
  });
2816
2817
  let result = response.content;
@@ -2826,6 +2827,20 @@ var MAKEMINDAI = class {
2826
2827
  usage: { totalTokens: response.usage.totalTokens }
2827
2828
  };
2828
2829
  }
2830
+ /**
2831
+ * A document's text as written, page by page and line by line, from an OCR
2832
+ * engine — each line with its confidence and its box on the page (core-ai 18
2833
+ * §5.3). One call reads at most 30 pages; read the next window while `more`.
2834
+ * `document` is an https address or a data URI (PDF, PNG, JPEG, TIFF).
2835
+ */
2836
+ async ocr(document2, options) {
2837
+ return this.apiClient.dispatch("ai-aiOcr", {
2838
+ tenantId: this.getTenantId(),
2839
+ document: { url: document2, ...options?.mediaType ? { mediaType: options.mediaType } : {} },
2840
+ ...options?.pages ? { pages: options.pages } : {},
2841
+ ...options?.model ? { model: options.model } : {}
2842
+ });
2843
+ }
2829
2844
  // Text generation
2830
2845
  async generate(prompt, options) {
2831
2846
  const response = await this.chat(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makemind/sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "MAKEMIND Platform SDK for Web Applications",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",