@graphysdk/agents-sdk 1.5.0 → 1.5.1-beta.1780051364996

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.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("tslib"),t=require("zod");class r extends Error{constructor(e,t){var r;super(e),Object.setPrototypeOf(this,new.target.prototype),this.name="GraphyApiError",this.status=null==t?void 0:t.status,this.code=null==t?void 0:t.code,this.retryable=null!==(r=null==t?void 0:t.retryable)&&void 0!==r&&r}}const a=e=>"progress"===e.type,s=e=>"complete"===e.type,i=e=>"error"===e.type;class n{constructor(e){if(this.tag="[GRAPHY]",!e.apiKey||0===e.apiKey.trim().length)throw new Error("apiKey is required and must not be empty");const t=new URL(e.baseUrl);if(!["http:","https:"].includes(t.protocol))throw new Error(`Invalid baseUrl protocol: ${t.protocol}. Only http(s) is allowed.`);this.apiKey=e.apiKey,this.baseUrl=t.origin+t.pathname.replace(/\/$/,""),this.timeout=e.timeout||6e4,this.retryConfig=e.retryConfig||{attempts:3,delay:1e3,backoff:2},this.logger=e.logger||{log:console.log,warn:console.warn,error:console.error,debug:console.debug}}static isProgressEvent(e){return a(e)}static isCompleteEvent(e){return s(e)}static isErrorEvent(e){return i(e)}stream(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.makeRequest(t,r,a);return this.parseSSE(e)})}fetch(t,n,o,c){return e.__awaiter(this,void 0,void 0,function*(){var m,l,d,p,u;const g=Date.now();this.logger.debug(`${this.tag} Fetch: ${t}`);try{const b=yield this.makeRequest(t,n,c),x=b.headers.get("content-type");if(null==x?void 0:x.includes("text/event-stream")){try{for(var h,f=!0,y=e.__asyncValues(this.parseSSE(b));!(m=(h=yield y.next()).done);f=!0){p=h.value,f=!1;const e=p;if(a(e)&&o&&o(e),s(e))return e.data;if(i(e)){const a=Date.now()-g;throw this.logger.error(`${this.tag} Server error: ${t} ${a}ms`,e.error),new r(e.error,{code:e.code,retryable:null!==(u=e.retryable)&&void 0!==u&&u})}}}catch(e){l={error:e}}finally{try{f||m||!(d=y.return)||(yield d.call(y))}finally{if(l)throw l.error}}const n=Date.now()-g;throw this.logger.error(`${this.tag} Stream incomplete: ${t} ${n}ms`),new r("Stream ended without completion")}return yield b.json()}catch(e){const a=Date.now()-g;if(this.logger.error(`${this.tag} Fetch failed: ${t} ${a}ms`,e),e instanceof r)throw e;throw e}finally{const e=Date.now()-g;this.logger.debug(`${this.tag} Fetch completed: ${t} ${e}ms`)}})}ping(){return e.__awaiter(this,void 0,void 0,function*(){const e=Date.now();try{return yield this.makeRequest("/health",void 0,void 0,this.retryConfig.attempts,"GET"),{ok:!0,latency:Date.now()-e}}catch(t){return{ok:!1,latency:Date.now()-e}}})}sleep(t){return e.__awaiter(this,void 0,void 0,function*(){return new Promise(e=>setTimeout(e,t))})}parseSSE(t){return e.__asyncGenerator(this,arguments,function*(){if(!t.body)throw new r("Response body is null");const a=t.body.getReader(),s=new TextDecoder;let i="",n="",o="";try{for(;;){const{done:t,value:r}=yield e.__await(a.read());if(t)break;i+=s.decode(r,{stream:!0});const c=i.split(/\r?\n/);i=c.pop()||"";for(const t of c)if(t.startsWith("event: "))n=t.slice(7).trim();else if(t.startsWith("data: "))o+=(o?"\n":"")+t.slice(6);else if(""===t.trim()&&o){try{const t=JSON.parse(o);let r;if("progress"===n){const e=t;r=Object.assign({type:"progress"},e)}else if("complete"===n)r={type:"complete",data:t};else if("error"===n){const e=t;r=Object.assign({type:"error"},e)}else if("preview"===n){const e=t;r=Object.assign(Object.assign({},e),{type:"preview"})}else{if("reasoning"!==n){n="",o="";continue}{const e=t;r=Object.assign(Object.assign({},e),{type:"reasoning"})}}if(yield yield e.__await(r),"complete"===n||"error"===n)return yield e.__await(void 0)}catch(e){this.logger.warn("Invalid SSE data format",o)}n="",o=""}}}finally{a.releaseLock()}})}makeRequest(t,a,s){return e.__awaiter(this,arguments,void 0,function*(e,t,a,s=1,i="POST"){if(!e.startsWith("/"))throw new r("Invalid endpoint: must start with /");const n=new URL(e,this.baseUrl);if(n.origin!==new URL(this.baseUrl).origin)throw new r("Endpoint resolved to unexpected origin");this.logger.debug(`${this.tag} Request ${s}/${this.retryConfig.attempts}: ${n}`);const o=new AbortController,c=setTimeout(()=>o.abort(),this.timeout),m=()=>o.abort();a&&a.addEventListener("abort",m);try{const c=yield fetch(n,Object.assign({method:i,headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream","Cache-Control":"no-cache",Authorization:`Bearer ${this.apiKey}`,"User-Agent":"Graphy-SDK/1.0"},signal:o.signal},"POST"===i&&{body:JSON.stringify(t)}));if(!c.ok){const n=c.status>=500||429===c.status;let o,m=`HTTP ${c.status}`;try{const e=yield c.json();if("object"==typeof e&&null!==e){const t=e;"string"==typeof t.message?m=t.message:"string"==typeof t.error&&(m=t.error),"string"==typeof t.code&&(o=t.code)}}catch(e){}const l=new r(m,{status:c.status,code:o,retryable:n});if(n&&s<this.retryConfig.attempts&&!(null==a?void 0:a.aborted)){const r=this.retryConfig.delay*Math.pow(this.retryConfig.backoff,s-1);return this.logger.warn(`${this.tag} Retrying ${e} in ${r}ms (attempt ${s+1})`),yield this.sleep(r),this.makeRequest(e,t,a,s+1,i)}throw this.logger.error(`${this.tag} Request failed: ${e} (${c.status}) - ${m}`),l}return this.logger.debug(`${this.tag} Connected: ${e}`),c}catch(n){if(n instanceof r)throw n;if(n instanceof Error&&"AbortError"===n.name)throw this.logger.debug(`${this.tag} Aborted: ${e}`),n;if(s<this.retryConfig.attempts&&!(null==a?void 0:a.aborted)){const r=this.retryConfig.delay*Math.pow(this.retryConfig.backoff,s-1);return this.logger.warn(`${this.tag} Network error, retrying ${e} in ${r}ms`),yield this.sleep(r),this.makeRequest(e,t,a,s+1,i)}throw this.logger.error(`${this.tag} Network error: ${e}`,n),new r("Network error",{retryable:!0})}finally{clearTimeout(c),a&&a.removeEventListener("abort",m)}})}}const o=t.z.enum(["EN_GB","EN_US"]),c=t.z.custom(e=>null!=e&&"object"==typeof e),m=t.z.enum(["low","medium","high"]),l=t.z.enum(["none","low","medium","high"]),d=t.z.enum(["agentic","fast"]),p=t.z.object({maxWallClockMs:t.z.number().positive().optional(),maxTotalTokens:t.z.number().int().positive().optional(),maxCostUsd:t.z.number().positive().optional()}),u=t.z.object({callId:t.z.string().max(256).optional(),locale:o.optional(),effort:m.optional(),storytellingEffort:l.optional().default("low"),budget:p.optional(),executionMode:d.optional()}),g=1e4,h=t.z.object({config:c,userPrompt:t.z.string().max(g).optional().default(""),metadata:u.optional()}),f=h.extend({maxSuggestionCount:t.z.number().int().min(1).max(4).optional()}),y=t.z.enum(["line","areaStacked","bar","groupedBar","stackedBar","100StackedBar","column","groupedColumn","stackedColumn","100StackedColumn","combo","pie","donut","funnel","heatmap","scatter","bubble","waterfall","table","mekko"]),b=t.z.object({dataPrepPrompt:t.z.string(),chartType:y,summary:t.z.string()}),x=h.extend({userPrompt:t.z.string().max(g)}),v=t.z.object({response:t.z.object({message:t.z.string()}),config:c}),z=t.z.object({suggestions:t.z.array(b)}),_=t.z.enum(["comparison","relationship","distribution","composition"]),S=t.z.object({finding:t.z.string().describe("Plain-English summary of the finding (no stats jargon)."),confidence:t.z.number().min(0).max(1).describe("Statistical strength of the finding (0..1). Independent of topicality."),relevance:t.z.number().min(0).max(1).describe("Topical fit with the user prompt and chart narrative (0..1). Independent of statistical strength."),topic:t.z.string().min(1).describe("Kebab-case label grouping this finding with related ones; consumers can render findings as threads."),chartHint:t.z.string().min(1).max(240).describe('Natural-language data-prep recipe for a downstream mutate agent: filter → group → aggregate → sort, naming real dataset columns. No chart type or "render as" clause — that is set via chartFamily.'),chartFamily:_.describe("Abela family (comparison | relationship | distribution | composition). Downstream chart-generator picks the concrete chart type from this family + the data shape."),evidenceSummary:t.z.string().max(300).describe("Rigorous statistical back-up with exact numbers.")}),w=t.z.object({topic:t.z.string().min(1).describe("Kebab-case story headline shared by all child findings."),score:t.z.number().min(0).max(1).describe("Max quadrant score (relevance × confidence) across child findings."),count:t.z.number().int().min(1).describe("Number of findings in this story."),findings:t.z.array(S).describe("Child findings, sorted by quadrant score desc.")}),E=t.z.object({response:t.z.object({message:t.z.string(),steps:t.z.array(t.z.string())}),stories:t.z.array(w)}),T=t.z.object({response:t.z.object({message:t.z.string(),steps:t.z.array(t.z.string())}),config:c}),A=t.z.object({response:t.z.object({message:t.z.string(),steps:t.z.array(t.z.string())}),config:c}),C=t.z.enum(["high","medium","low"]),j=t.z.object({confidence:C,needsUserInput:t.z.boolean(),warnings:t.z.array(t.z.string()),cellConfidence:t.z.array(t.z.object({rowIndex:t.z.number().int().nonnegative(),columnKey:t.z.string(),confidence:C,quote:t.z.string().optional()})).optional()}),$=t.z.object({score:t.z.number().min(0).max(1),issues:t.z.array(t.z.string()),sufficient:t.z.boolean(),summary:t.z.string()}),R=5e5,k=2097152,O=7340032,D=6291456,M=8388608,P=D,I=M,G=12582912;function B(e){return 4*Math.ceil(e/3)}const X=B(k),N=B(O),F=B(D),U=B(M),q=B(P),K=B(I),L=B(G);function H(e){return e.replace(/\s+/g,"")}function Y(e){const t=H(e);return 0!==t.length&&t.length%4==0&&/^[A-Za-z0-9+/]+={0,2}$/.test(t)}const W=/^image\/(png|jpeg|jpg|webp|gif)$/i,V=t.z.object({mimeType:t.z.string().min(1).refine(e=>W.test(e.trim()),{message:"mimeType must be image/png, image/jpeg, image/jpg, image/webp, or image/gif"}),dataBase64:t.z.string().min(1).max(X).refine(Y,{message:"dataBase64 must be standard base64 (RFC 4648)"})}),J=t.z.enum(["image","document","spreadsheet"]),Z=V.extend({kind:t.z.literal("image")}),Q=t.z.object({kind:t.z.literal("document"),mimeType:t.z.string().min(1).refine(e=>/^application\/pdf$/i.test(e.trim()),{message:"document mimeType must be application/pdf"}),dataBase64:t.z.string().min(1).max(F).refine(Y,{message:"dataBase64 must be standard base64 (RFC 4648)"})}),ee=t.z.object({kind:t.z.literal("spreadsheet"),mimeType:t.z.string().min(1).refine(e=>/^application\/vnd\.openxmlformats-officedocument\.spreadsheetml\.sheet$/i.test(e.trim()),{message:"spreadsheet mimeType must be application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),dataBase64:t.z.string().min(1).max(q).refine(Y,{message:"dataBase64 must be standard base64 (RFC 4648)"}),filename:t.z.string().max(512).optional()}).refine(e=>void 0===e.filename||e.filename.trim().length>0,{message:"spreadsheet filename must not be empty or whitespace-only",path:["filename"]}),te=t.z.discriminatedUnion("kind",[Z,Q,ee]),re=t.z.object({sourceText:t.z.string().max(R).default(""),images:t.z.array(V).max(8).optional().describe('@deprecated Use attachments[] with kind: "image" instead. Will be removed in a future major release.'),attachments:t.z.array(te).max(12).optional(),metadata:u.optional()}).superRefine((e,t)=>{var r,a;const s=e.sourceText.trim(),i=null!==(r=e.images)&&void 0!==r?r:[],n=null!==(a=e.attachments)&&void 0!==a?a:[];if(i.length>0&&n.length>0)return void t.addIssue({code:"custom",message:'Use either `images` (deprecated) or `attachments`, not both. Migrate to `attachments` with `kind: "image"`.',path:["attachments"]});if(0===s.length&&0===i.length&&0===n.length)return void t.addIssue({code:"custom",message:"Provide non-empty sourceText and/or at least one attachment",path:["sourceText"]});if(i.length>0){i.reduce((e,t)=>e+H(t.dataBase64).length,0)>N&&t.addIssue({code:"custom",message:"Combined image base64 exceeds maximum length for this API (must fit server decode limits)",path:["images"]})}let o=0,c=0,m=0,l=0,d=0,p=0,u=0;for(const e of n){const t=H(e.dataBase64).length;switch(u+=t,e.kind){case"image":o+=1,l+=t;break;case"document":c+=1,d+=t;break;case"spreadsheet":m+=1,p+=t}}o>8&&t.addIssue({code:"custom",message:"Too many images (max 8)",path:["attachments"]}),c>2&&t.addIssue({code:"custom",message:"Too many documents (max 2)",path:["attachments"]}),m>2&&t.addIssue({code:"custom",message:"Too many spreadsheets (max 2)",path:["attachments"]});const g=o<=8&&c<=2&&m<=2;n.length>0&&g&&(l>N&&t.addIssue({code:"custom",message:"Combined image base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),d>U&&t.addIssue({code:"custom",message:"Combined document base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),p>K&&t.addIssue({code:"custom",message:"Combined spreadsheet base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),u>L&&t.addIssue({code:"custom",message:"Combined attachment base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}))});const ae=t.z.object({response:t.z.object({message:t.z.string()}),config:c,extractMeta:j.nullable(),lastAccuracyEvaluation:$.optional()}),se=t.z.object({config:c,response:t.z.object({message:t.z.string(),steps:t.z.array(t.z.string())})}),ie=z,ne=t.z.enum(["deal-breaker","pro","con","family","continuity"]),oe=t.z.object({kind:ne,label:t.z.string(),weight:t.z.number(),reason:t.z.string()}),ce=t.z.enum(["ok","disqualified"]),me=t.z.object({rank:t.z.number().int().positive(),type:y,score:t.z.number(),verdict:ce,factors:t.z.array(oe)}),le=t.z.object({config:c,chartFamily:_.optional(),metadata:u.optional()}),de=t.z.enum(["drop-noisy-dimensions","reshape-for-heatmap","unpivot-wide-format","needs-row-reduction","high-null-columns","constant-columns","outlier-heavy-measures","mixed-scale-measures","needs-metric-filter"]),pe=t.z.object({kind:de,message:t.z.string()}),ue=t.z.enum(["sum","avg","count","min","max"]),ge=t.z.object({dimensionName:t.z.string(),dimensionLabel:t.z.string(),measureName:t.z.string().nullable(),measureLabel:t.z.string().nullable(),fn:ue,chartType:y,score:t.z.number(),message:t.z.string()}),he=t.z.object({ranking:t.z.array(me),observations:t.z.array(pe).optional().default([]),suggestions:t.z.array(ge).optional().default([])}),fe="/api/v0";exports.AggregationFunctionSchema=ue,exports.AggregationSuggestionSchema=ge,exports.AiChartTypeEnum=y,exports.ChartFamilySchema=_,exports.ChartFitEntrySchema=me,exports.ChartFitFactorKindSchema=ne,exports.ChartFitFactorSchema=oe,exports.ChartFitVerdictSchema=ce,exports.DataObservationKindSchema=de,exports.DataObservationSchema=pe,exports.EvaluateParamsSchema=le,exports.EvaluateResponseSchema=he,exports.ExecutionModeSchema=d,exports.ExploreFindingSchema=S,exports.ExploreStorySchema=w,exports.ExtractAccuracyEvaluationSchema=$,exports.ExtractAttachmentInputSchema=te,exports.ExtractAttachmentKindSchema=J,exports.ExtractConfidenceSchema=C,exports.ExtractFromProseParamsSchema=re,exports.ExtractFromProseResponseSchema=ae,exports.ExtractMetaSchema=j,exports.GenerateAnnotationsResponseSchema=T,exports.GenerateExplorationResponseSchema=E,exports.GenerateGraphResponseSchema=se,exports.GenerateGraphSuggestionsResponseSchema=ie,exports.GenerateMutationResponseSchema=A,exports.GenerateNarrativeParamsSchema=x,exports.GenerateNarrativeResponseSchema=v,exports.GenerateSuggestionsParamsSchema=f,exports.GenerateSuggestionsResponseSchema=z,exports.GraphGenerationRequestSchema=h,exports.GraphyAiSdk=class{constructor(e){this.client=new n(e)}generateGraph(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const{storytellingOptions:s}=t,i=e.__rest(t,["storytellingOptions"]),n=yield this.client.fetch(`${fe}/generate`,i,r,a),o=se.parse(n);return this.stripStorytelling(o,s)})}generateGraphStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){const{storytellingOptions:a}=t,s=e.__rest(t,["storytellingOptions"]),i=yield this.client.stream(`${fe}/generate`,s,r);return this.wrapStreamWithStorytellingStripping(i,a)})}generateNarrative(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${fe}/narrate`,t,r,a);return v.parse(e)})}generateNarrativeStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${fe}/narrate`,t,r)})}generateSuggestions(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${fe}/suggestions`,t,r,a);return z.parse(e)})}generateSuggestionsStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${fe}/suggestions`,t,r)})}generateExploration(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${fe}/explore`,t,r,a);return E.parse(e)})}generateExplorationStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${fe}/explore`,t,r)})}generateAnnotations(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${fe}/annotate`,t,r,a);return T.parse(e)})}generateAnnotationsStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${fe}/annotate`,t,r)})}generateMutation(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${fe}/mutate`,t,r,a);return A.parse(e)})}generateMutationStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${fe}/mutate`,t,r)})}evaluate(t,r){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${fe}/evaluate`,t,void 0,r);return he.parse(e)})}extractFromProse(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${fe}/extract`,t,r,a);return ae.parse(e)})}extractFromProseStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${fe}/extract`,t,r)})}stripStorytelling(e,t){return t&&e.config.content?Object.assign(Object.assign({},e),{config:Object.assign(Object.assign({},e.config),{content:Object.assign(Object.assign(Object.assign(Object.assign({},e.config.content),t.excludeTitle&&{title:void 0}),t.excludeSubtitle&&{subtitle:void 0}),t.excludeCaption&&{caption:void 0})})}):e}wrapStreamWithStorytellingStripping(t,r){return e.__asyncGenerator(this,arguments,function*(){var a,i,n,o;try{for(var c,m=!0,l=e.__asyncValues(t);!(a=(c=yield e.__await(l.next())).done);m=!0){o=c.value,m=!1;const t=o;if(s(t)){const a=this.stripStorytelling(t.data,r);yield yield e.__await(Object.assign(Object.assign({},t),{data:a}))}else yield yield e.__await(t)}}catch(e){i={error:e}}finally{try{m||a||!(n=l.return)||(yield e.__await(n.call(l)))}finally{if(i)throw i.error}}})}},exports.GraphyApiError=r,exports.InvocationBudgetSchema=p,exports.InvocationEffortSchema=m,exports.MAX_EXTRACT_ATTACHMENTS=12,exports.MAX_EXTRACT_ATTACHMENTS_COMBINED_DECODED_BYTES=G,exports.MAX_EXTRACT_DOCUMENTS=2,exports.MAX_EXTRACT_DOCUMENTS_TOTAL_DECODED_BYTES=M,exports.MAX_EXTRACT_DOCUMENT_DECODED_BYTES=D,exports.MAX_EXTRACT_IMAGES=8,exports.MAX_EXTRACT_IMAGES_TOTAL_DECODED_BYTES=O,exports.MAX_EXTRACT_IMAGE_DECODED_BYTES=k,exports.MAX_EXTRACT_SPREADSHEETS=2,exports.MAX_EXTRACT_SPREADSHEETS_TOTAL_DECODED_BYTES=I,exports.MAX_EXTRACT_SPREADSHEET_DECODED_BYTES=P,exports.MAX_SOURCE_TEXT_LENGTH=R,exports.MAX_USER_PROMPT_LENGTH=g,exports.MetadataSchema=u,exports.StorytellingEffortSchema=l,exports.SuggestionSchema=b,exports.buildImageAttachment=function(e){return{kind:"image",mimeType:e.mimeType.trim(),dataBase64:H(e.dataBase64)}},exports.buildPdfAttachment=function(e){return{kind:"document",mimeType:"application/pdf",dataBase64:H(e.dataBase64)}},exports.buildSpreadsheetAttachment=function(e){return Object.assign({kind:"spreadsheet",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",dataBase64:H(e.dataBase64)},void 0!==e.filename?{filename:e.filename.trim()}:{})},exports.isCompleteEvent=s,exports.isErrorEvent=i,exports.isGraphyApiError=e=>e instanceof r,exports.isPreviewEvent=e=>"preview"===e.type,exports.isProgressEvent=a,exports.isReasoningEvent=e=>"reasoning"===e.type;
1
+ "use strict";var e=require("tslib"),t=require("zod");class r extends Error{constructor(e,t){var r;super(e),Object.setPrototypeOf(this,new.target.prototype),this.name="GraphyApiError",this.status=null==t?void 0:t.status,this.code=null==t?void 0:t.code,this.retryable=null!==(r=null==t?void 0:t.retryable)&&void 0!==r&&r}}const a=e=>"progress"===e.type,s=e=>"complete"===e.type,i=e=>"error"===e.type;class n{constructor(e){if(this.tag="[GRAPHY]",!e.apiKey||0===e.apiKey.trim().length)throw new Error("apiKey is required and must not be empty");const t=new URL(e.baseUrl);if(!["http:","https:"].includes(t.protocol))throw new Error(`Invalid baseUrl protocol: ${t.protocol}. Only http(s) is allowed.`);this.apiKey=e.apiKey,this.baseUrl=t.origin+t.pathname.replace(/\/$/,""),this.timeout=e.timeout||6e4,this.retryConfig=e.retryConfig||{attempts:3,delay:1e3,backoff:2},this.logger=e.logger||{log:console.log,warn:console.warn,error:console.error,debug:console.debug}}static isProgressEvent(e){return a(e)}static isCompleteEvent(e){return s(e)}static isErrorEvent(e){return i(e)}stream(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.makeRequest(t,r,a);return this.parseSSE(e)})}fetch(t,n,o,c){return e.__awaiter(this,void 0,void 0,function*(){var m,l,d,p,u;const g=Date.now();this.logger.debug(`${this.tag} Fetch: ${t}`);try{const b=yield this.makeRequest(t,n,c),x=b.headers.get("content-type");if(null==x?void 0:x.includes("text/event-stream")){try{for(var h,f=!0,y=e.__asyncValues(this.parseSSE(b));!(m=(h=yield y.next()).done);f=!0){p=h.value,f=!1;const e=p;if(a(e)&&o&&o(e),s(e))return e.data;if(i(e)){const a=Date.now()-g;throw this.logger.error(`${this.tag} Server error: ${t} ${a}ms`,e.error),new r(e.error,{code:e.code,retryable:null!==(u=e.retryable)&&void 0!==u&&u})}}}catch(e){l={error:e}}finally{try{f||m||!(d=y.return)||(yield d.call(y))}finally{if(l)throw l.error}}const n=Date.now()-g;throw this.logger.error(`${this.tag} Stream incomplete: ${t} ${n}ms`),new r("Stream ended without completion")}return yield b.json()}catch(e){const a=Date.now()-g;if(this.logger.error(`${this.tag} Fetch failed: ${t} ${a}ms`,e),e instanceof r)throw e;throw e}finally{const e=Date.now()-g;this.logger.debug(`${this.tag} Fetch completed: ${t} ${e}ms`)}})}ping(){return e.__awaiter(this,void 0,void 0,function*(){const e=Date.now();try{return yield this.makeRequest("/health",void 0,void 0,this.retryConfig.attempts,"GET"),{ok:!0,latency:Date.now()-e}}catch(t){return{ok:!1,latency:Date.now()-e}}})}sleep(t){return e.__awaiter(this,void 0,void 0,function*(){return new Promise(e=>setTimeout(e,t))})}parseSSE(t){return e.__asyncGenerator(this,arguments,function*(){if(!t.body)throw new r("Response body is null");const a=t.body.getReader(),s=new TextDecoder;let i="",n="",o="";try{for(;;){const{done:t,value:r}=yield e.__await(a.read());if(t)break;i+=s.decode(r,{stream:!0});const c=i.split(/\r?\n/);i=c.pop()||"";for(const t of c)if(t.startsWith("event: "))n=t.slice(7).trim();else if(t.startsWith("data: "))o+=(o?"\n":"")+t.slice(6);else if(""===t.trim()&&o){try{const t=JSON.parse(o);let r;if("progress"===n){const e=t;r=Object.assign({type:"progress"},e)}else if("complete"===n)r={type:"complete",data:t};else if("error"===n){const e=t;r=Object.assign({type:"error"},e)}else if("preview"===n){const e=t;r=Object.assign(Object.assign({},e),{type:"preview"})}else{if("reasoning"!==n){n="",o="";continue}{const e=t;r=Object.assign(Object.assign({},e),{type:"reasoning"})}}if(yield yield e.__await(r),"complete"===n||"error"===n)return yield e.__await(void 0)}catch(e){this.logger.warn("Invalid SSE data format",o)}n="",o=""}}}finally{a.releaseLock()}})}makeRequest(t,a,s){return e.__awaiter(this,arguments,void 0,function*(e,t,a,s=1,i="POST"){if(!e.startsWith("/"))throw new r("Invalid endpoint: must start with /");const n=new URL(e,this.baseUrl);if(n.origin!==new URL(this.baseUrl).origin)throw new r("Endpoint resolved to unexpected origin");this.logger.debug(`${this.tag} Request ${s}/${this.retryConfig.attempts}: ${n}`);const o=new AbortController,c=setTimeout(()=>o.abort(),this.timeout),m=()=>o.abort();a&&a.addEventListener("abort",m);try{const c=yield fetch(n,Object.assign({method:i,headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream","Cache-Control":"no-cache",Authorization:`Bearer ${this.apiKey}`,"User-Agent":"Graphy-SDK/1.0"},signal:o.signal},"POST"===i&&{body:JSON.stringify(t)}));if(!c.ok){const n=c.status>=500||429===c.status;let o,m=`HTTP ${c.status}`;try{const e=yield c.json();if("object"==typeof e&&null!==e){const t=e;"string"==typeof t.message?m=t.message:"string"==typeof t.error&&(m=t.error),"string"==typeof t.code&&(o=t.code)}}catch(e){}const l=new r(m,{status:c.status,code:o,retryable:n});if(n&&s<this.retryConfig.attempts&&!(null==a?void 0:a.aborted)){const r=this.retryConfig.delay*Math.pow(this.retryConfig.backoff,s-1);return this.logger.warn(`${this.tag} Retrying ${e} in ${r}ms (attempt ${s+1})`),yield this.sleep(r),this.makeRequest(e,t,a,s+1,i)}throw this.logger.error(`${this.tag} Request failed: ${e} (${c.status}) - ${m}`),l}return this.logger.debug(`${this.tag} Connected: ${e}`),c}catch(n){if(n instanceof r)throw n;if(n instanceof Error&&"AbortError"===n.name)throw this.logger.debug(`${this.tag} Aborted: ${e}`),n;if(s<this.retryConfig.attempts&&!(null==a?void 0:a.aborted)){const r=this.retryConfig.delay*Math.pow(this.retryConfig.backoff,s-1);return this.logger.warn(`${this.tag} Network error, retrying ${e} in ${r}ms`),yield this.sleep(r),this.makeRequest(e,t,a,s+1,i)}throw this.logger.error(`${this.tag} Network error: ${e}`,n),new r("Network error",{retryable:!0})}finally{clearTimeout(c),a&&a.removeEventListener("abort",m)}})}}const o=t.z.enum(["EN_GB","EN_US"]),c=t.z.custom(e=>null!=e&&"object"==typeof e),m=t.z.enum(["low","medium","high"]),l=t.z.enum(["none","low","medium","high"]),d=t.z.enum(["agentic","fast"]),p=3e5,u=5e5,g=t.z.object({maxWallClockMs:t.z.number().positive().max(p).optional(),maxTotalTokens:t.z.number().int().positive().max(u).optional(),maxCostUsd:t.z.number().positive().max(10).optional()}),h=t.z.object({callId:t.z.string().max(256).optional(),locale:o.optional(),effort:m.optional(),storytellingEffort:l.optional().default("low"),budget:g.optional(),executionMode:d.optional()}),f=1e4,y=t.z.object({config:c,userPrompt:t.z.string().max(f).optional().default(""),metadata:h.optional()}),b=y.extend({maxSuggestionCount:t.z.number().int().min(1).max(4).optional()}),x=t.z.enum(["line","areaStacked","bar","groupedBar","stackedBar","100StackedBar","column","groupedColumn","stackedColumn","100StackedColumn","combo","pie","donut","funnel","heatmap","scatter","bubble","waterfall","table","mekko"]),v=t.z.object({dataPrepPrompt:t.z.string(),chartType:x,summary:t.z.string()}),z=y.extend({userPrompt:t.z.string().max(f)}),_=t.z.object({response:t.z.object({message:t.z.string()}),config:c}),S=t.z.object({suggestions:t.z.array(v)}),E=t.z.enum(["comparison","relationship","distribution","composition"]),w=t.z.object({finding:t.z.string().describe("Plain-English summary of the finding (no stats jargon)."),confidence:t.z.number().min(0).max(1).describe("Statistical strength of the finding (0..1). Independent of topicality."),relevance:t.z.number().min(0).max(1).describe("Topical fit with the user prompt and chart narrative (0..1). Independent of statistical strength."),topic:t.z.string().min(1).describe("Kebab-case label grouping this finding with related ones; consumers can render findings as threads."),chartHint:t.z.string().min(1).max(240).describe('Natural-language data-prep recipe for a downstream mutate agent: filter → group → aggregate → sort, naming real dataset columns. No chart type or "render as" clause — that is set via chartFamily.'),chartFamily:E.describe("Abela family (comparison | relationship | distribution | composition). Downstream chart-generator picks the concrete chart type from this family + the data shape."),evidenceSummary:t.z.string().max(300).describe("Rigorous statistical back-up with exact numbers.")}),T=t.z.object({topic:t.z.string().min(1).describe("Kebab-case story headline shared by all child findings."),score:t.z.number().min(0).max(1).describe("Max quadrant score (relevance × confidence) across child findings."),count:t.z.number().int().min(1).describe("Number of findings in this story."),findings:t.z.array(w).describe("Child findings, sorted by quadrant score desc.")}),A=t.z.object({response:t.z.object({message:t.z.string(),steps:t.z.array(t.z.string())}),stories:t.z.array(T)}),C=t.z.object({response:t.z.object({message:t.z.string(),steps:t.z.array(t.z.string())}),config:c}),j=t.z.object({response:t.z.object({message:t.z.string(),steps:t.z.array(t.z.string())}),config:c}),$=t.z.enum(["high","medium","low"]),O=t.z.object({confidence:$,needsUserInput:t.z.boolean(),warnings:t.z.array(t.z.string()),cellConfidence:t.z.array(t.z.object({rowIndex:t.z.number().int().nonnegative(),columnKey:t.z.string(),confidence:$,quote:t.z.string().optional()})).optional()}),R=t.z.object({score:t.z.number().min(0).max(1),issues:t.z.array(t.z.string()),sufficient:t.z.boolean(),summary:t.z.string()}),k=5e5,D=2097152,M=7340032,P=6291456,G=8388608,B=P,I=G,X=12582912;function N(e){return 4*Math.ceil(e/3)}const U=N(D),F=N(M),L=N(P),q=N(G),K=N(B),H=N(I),W=N(X);function Y(e){return e.replace(/\s+/g,"")}function V(e){const t=Y(e);return 0!==t.length&&t.length%4==0&&/^[A-Za-z0-9+/]+={0,2}$/.test(t)}const J=/^image\/(png|jpeg|jpg|webp|gif)$/i,Z=t.z.object({mimeType:t.z.string().min(1).refine(e=>J.test(e.trim()),{message:"mimeType must be image/png, image/jpeg, image/jpg, image/webp, or image/gif"}),dataBase64:t.z.string().min(1).max(U).refine(V,{message:"dataBase64 must be standard base64 (RFC 4648)"})}),Q=t.z.enum(["image","document","spreadsheet"]),ee=Z.extend({kind:t.z.literal("image")}),te=t.z.object({kind:t.z.literal("document"),mimeType:t.z.string().min(1).refine(e=>/^application\/pdf$/i.test(e.trim()),{message:"document mimeType must be application/pdf"}),dataBase64:t.z.string().min(1).max(L).refine(V,{message:"dataBase64 must be standard base64 (RFC 4648)"})}),re=t.z.object({kind:t.z.literal("spreadsheet"),mimeType:t.z.string().min(1).refine(e=>/^application\/vnd\.openxmlformats-officedocument\.spreadsheetml\.sheet$/i.test(e.trim()),{message:"spreadsheet mimeType must be application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),dataBase64:t.z.string().min(1).max(K).refine(V,{message:"dataBase64 must be standard base64 (RFC 4648)"}),filename:t.z.string().max(512).optional()}).refine(e=>void 0===e.filename||e.filename.trim().length>0,{message:"spreadsheet filename must not be empty or whitespace-only",path:["filename"]}),ae=t.z.discriminatedUnion("kind",[ee,te,re]),se=t.z.object({sourceText:t.z.string().max(k).default(""),images:t.z.array(Z).max(8).optional().describe('@deprecated Use attachments[] with kind: "image" instead. Will be removed in a future major release.'),attachments:t.z.array(ae).max(12).optional(),metadata:h.optional()}).superRefine((e,t)=>{var r,a;const s=e.sourceText.trim(),i=null!==(r=e.images)&&void 0!==r?r:[],n=null!==(a=e.attachments)&&void 0!==a?a:[];if(i.length>0&&n.length>0)return void t.addIssue({code:"custom",message:'Use either `images` (deprecated) or `attachments`, not both. Migrate to `attachments` with `kind: "image"`.',path:["attachments"]});if(0===s.length&&0===i.length&&0===n.length)return void t.addIssue({code:"custom",message:"Provide non-empty sourceText and/or at least one attachment",path:["sourceText"]});if(i.length>0){i.reduce((e,t)=>e+Y(t.dataBase64).length,0)>F&&t.addIssue({code:"custom",message:"Combined image base64 exceeds maximum length for this API (must fit server decode limits)",path:["images"]})}let o=0,c=0,m=0,l=0,d=0,p=0,u=0;for(const e of n){const t=Y(e.dataBase64).length;switch(u+=t,e.kind){case"image":o+=1,l+=t;break;case"document":c+=1,d+=t;break;case"spreadsheet":m+=1,p+=t}}o>8&&t.addIssue({code:"custom",message:"Too many images (max 8)",path:["attachments"]}),c>2&&t.addIssue({code:"custom",message:"Too many documents (max 2)",path:["attachments"]}),m>2&&t.addIssue({code:"custom",message:"Too many spreadsheets (max 2)",path:["attachments"]});const g=o<=8&&c<=2&&m<=2;n.length>0&&g&&(l>F&&t.addIssue({code:"custom",message:"Combined image base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),d>q&&t.addIssue({code:"custom",message:"Combined document base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),p>H&&t.addIssue({code:"custom",message:"Combined spreadsheet base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),u>W&&t.addIssue({code:"custom",message:"Combined attachment base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}))});const ie=t.z.object({response:t.z.object({message:t.z.string()}),config:c,extractMeta:O.nullable(),lastAccuracyEvaluation:R.optional()}),ne=t.z.object({config:c,response:t.z.object({message:t.z.string(),steps:t.z.array(t.z.string())})}),oe=S,ce=t.z.enum(["deal-breaker","pro","con","family","continuity"]),me=t.z.object({kind:ce,label:t.z.string(),weight:t.z.number(),reason:t.z.string()}),le=t.z.enum(["ok","disqualified"]),de=t.z.object({rank:t.z.number().int().positive(),type:x,score:t.z.number(),verdict:le,factors:t.z.array(me)}),pe=t.z.object({config:c,chartFamily:E.optional(),metadata:h.optional()}),ue=t.z.enum(["drop-noisy-dimensions","reshape-for-heatmap","unpivot-wide-format","needs-row-reduction","high-null-columns","constant-columns","outlier-heavy-measures","mixed-scale-measures","needs-metric-filter"]),ge=t.z.object({kind:ue,message:t.z.string()}),he=t.z.enum(["sum","avg","count","min","max"]),fe=t.z.object({dimensionName:t.z.string(),dimensionLabel:t.z.string(),measureName:t.z.string().nullable(),measureLabel:t.z.string().nullable(),fn:he,chartType:x,score:t.z.number(),message:t.z.string()}),ye=t.z.object({ranking:t.z.array(de),observations:t.z.array(ge).optional().default([]),suggestions:t.z.array(fe).optional().default([])}),be="/api/v0";exports.AggregationFunctionSchema=he,exports.AggregationSuggestionSchema=fe,exports.AiChartTypeEnum=x,exports.ChartFamilySchema=E,exports.ChartFitEntrySchema=de,exports.ChartFitFactorKindSchema=ce,exports.ChartFitFactorSchema=me,exports.ChartFitVerdictSchema=le,exports.DataObservationKindSchema=ue,exports.DataObservationSchema=ge,exports.EvaluateParamsSchema=pe,exports.EvaluateResponseSchema=ye,exports.ExecutionModeSchema=d,exports.ExploreFindingSchema=w,exports.ExploreStorySchema=T,exports.ExtractAccuracyEvaluationSchema=R,exports.ExtractAttachmentInputSchema=ae,exports.ExtractAttachmentKindSchema=Q,exports.ExtractConfidenceSchema=$,exports.ExtractFromProseParamsSchema=se,exports.ExtractFromProseResponseSchema=ie,exports.ExtractMetaSchema=O,exports.GenerateAnnotationsResponseSchema=C,exports.GenerateExplorationResponseSchema=A,exports.GenerateGraphResponseSchema=ne,exports.GenerateGraphSuggestionsResponseSchema=oe,exports.GenerateMutationResponseSchema=j,exports.GenerateNarrativeParamsSchema=z,exports.GenerateNarrativeResponseSchema=_,exports.GenerateSuggestionsParamsSchema=b,exports.GenerateSuggestionsResponseSchema=S,exports.GraphGenerationRequestSchema=y,exports.GraphyAiSdk=class{constructor(e){this.client=new n(e)}generateGraph(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const{storytellingOptions:s}=t,i=e.__rest(t,["storytellingOptions"]),n=yield this.client.fetch(`${be}/generate`,i,r,a),o=ne.parse(n);return this.stripStorytelling(o,s)})}generateGraphStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){const{storytellingOptions:a}=t,s=e.__rest(t,["storytellingOptions"]),i=yield this.client.stream(`${be}/generate`,s,r);return this.wrapStreamWithStorytellingStripping(i,a)})}generateNarrative(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${be}/narrate`,t,r,a);return _.parse(e)})}generateNarrativeStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${be}/narrate`,t,r)})}generateSuggestions(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${be}/suggestions`,t,r,a);return S.parse(e)})}generateSuggestionsStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${be}/suggestions`,t,r)})}generateExploration(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${be}/explore`,t,r,a);return A.parse(e)})}generateExplorationStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${be}/explore`,t,r)})}generateAnnotations(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${be}/annotate`,t,r,a);return C.parse(e)})}generateAnnotationsStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${be}/annotate`,t,r)})}generateMutation(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${be}/mutate`,t,r,a);return j.parse(e)})}generateMutationStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${be}/mutate`,t,r)})}evaluate(t,r){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${be}/evaluate`,t,void 0,r);return ye.parse(e)})}extractFromProse(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${be}/extract`,t,r,a);return ie.parse(e)})}extractFromProseStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${be}/extract`,t,r)})}stripStorytelling(e,t){return t&&e.config.content?Object.assign(Object.assign({},e),{config:Object.assign(Object.assign({},e.config),{content:Object.assign(Object.assign(Object.assign(Object.assign({},e.config.content),t.excludeTitle&&{title:void 0}),t.excludeSubtitle&&{subtitle:void 0}),t.excludeCaption&&{caption:void 0})})}):e}wrapStreamWithStorytellingStripping(t,r){return e.__asyncGenerator(this,arguments,function*(){var a,i,n,o;try{for(var c,m=!0,l=e.__asyncValues(t);!(a=(c=yield e.__await(l.next())).done);m=!0){o=c.value,m=!1;const t=o;if(s(t)){const a=this.stripStorytelling(t.data,r);yield yield e.__await(Object.assign(Object.assign({},t),{data:a}))}else yield yield e.__await(t)}}catch(e){i={error:e}}finally{try{m||a||!(n=l.return)||(yield e.__await(n.call(l)))}finally{if(i)throw i.error}}})}},exports.GraphyApiError=r,exports.InvocationBudgetSchema=g,exports.InvocationEffortSchema=m,exports.MAX_BUDGET_COST_USD=10,exports.MAX_BUDGET_TOTAL_TOKENS=u,exports.MAX_BUDGET_WALL_CLOCK_MS=p,exports.MAX_EXTRACT_ATTACHMENTS=12,exports.MAX_EXTRACT_ATTACHMENTS_COMBINED_DECODED_BYTES=X,exports.MAX_EXTRACT_DOCUMENTS=2,exports.MAX_EXTRACT_DOCUMENTS_TOTAL_DECODED_BYTES=G,exports.MAX_EXTRACT_DOCUMENT_DECODED_BYTES=P,exports.MAX_EXTRACT_IMAGES=8,exports.MAX_EXTRACT_IMAGES_TOTAL_DECODED_BYTES=M,exports.MAX_EXTRACT_IMAGE_DECODED_BYTES=D,exports.MAX_EXTRACT_SPREADSHEETS=2,exports.MAX_EXTRACT_SPREADSHEETS_TOTAL_DECODED_BYTES=I,exports.MAX_EXTRACT_SPREADSHEET_DECODED_BYTES=B,exports.MAX_SOURCE_TEXT_LENGTH=k,exports.MAX_USER_PROMPT_LENGTH=f,exports.MetadataSchema=h,exports.StorytellingEffortSchema=l,exports.SuggestionSchema=v,exports.buildImageAttachment=function(e){return{kind:"image",mimeType:e.mimeType.trim(),dataBase64:Y(e.dataBase64)}},exports.buildPdfAttachment=function(e){return{kind:"document",mimeType:"application/pdf",dataBase64:Y(e.dataBase64)}},exports.buildSpreadsheetAttachment=function(e){return Object.assign({kind:"spreadsheet",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",dataBase64:Y(e.dataBase64)},void 0!==e.filename?{filename:e.filename.trim()}:{})},exports.isCompleteEvent=s,exports.isErrorEvent=i,exports.isGraphyApiError=e=>e instanceof r,exports.isPreviewEvent=e=>"preview"===e.type,exports.isProgressEvent=a,exports.isReasoningEvent=e=>"reasoning"===e.type;
package/dist/index.d.ts CHANGED
@@ -292,10 +292,15 @@ declare const ExecutionModeSchema: z.ZodEnum<{
292
292
  fast: "fast";
293
293
  }>;
294
294
  type ExecutionMode = z.infer<typeof ExecutionModeSchema>;
295
+ /** Absolute budget caps. Mirror `MAX_BUDGET_*` in `apps/agents-api/src/modules/api/api.types.ts`. */
296
+ declare const MAX_BUDGET_WALL_CLOCK_MS = 300000;
297
+ declare const MAX_BUDGET_TOTAL_TOKENS = 500000;
298
+ declare const MAX_BUDGET_COST_USD = 10;
295
299
  /**
296
300
  * Optional per-request invocation budget. Mirrors `InvocationBudgetSchema` in
297
- * `apps/agents-api/src/modules/api/api.types.ts`. All fields are optional — the
298
- * server merges whatever is provided with its own defaults.
301
+ * `apps/agents-api/src/modules/api/api.types.ts`. All fields are optional — the server merges
302
+ * whatever is provided with its own defaults, then clamps it to the agent's ceiling (a client can
303
+ * only lower its budget, never raise it above the per-agent limit).
299
304
  */
300
305
  declare const InvocationBudgetSchema: z.ZodObject<{
301
306
  maxWallClockMs: z.ZodOptional<z.ZodNumber>;
@@ -1555,5 +1560,5 @@ declare class GraphyAiSdk {
1555
1560
  private wrapStreamWithStorytellingStripping;
1556
1561
  }
1557
1562
 
1558
- export { AggregationFunctionSchema, AggregationSuggestionSchema, AiChartTypeEnum, ChartFamilySchema, ChartFitEntrySchema, ChartFitFactorKindSchema, ChartFitFactorSchema, ChartFitVerdictSchema, DataObservationKindSchema, DataObservationSchema, EvaluateParamsSchema, EvaluateResponseSchema, ExecutionModeSchema, ExploreFindingSchema, ExploreStorySchema, ExtractAccuracyEvaluationSchema, ExtractAttachmentInputSchema, ExtractAttachmentKindSchema, ExtractConfidenceSchema, ExtractFromProseParamsSchema, ExtractFromProseResponseSchema, ExtractMetaSchema, GenerateAnnotationsResponseSchema, GenerateExplorationResponseSchema, GenerateGraphResponseSchema, GenerateGraphSuggestionsResponseSchema, GenerateMutationResponseSchema, GenerateNarrativeParamsSchema, GenerateNarrativeResponseSchema, GenerateSuggestionsParamsSchema, GenerateSuggestionsResponseSchema, GraphGenerationRequestSchema, GraphyAiSdk, GraphyApiError, InvocationBudgetSchema, InvocationEffortSchema, MAX_EXTRACT_ATTACHMENTS, MAX_EXTRACT_ATTACHMENTS_COMBINED_DECODED_BYTES, MAX_EXTRACT_DOCUMENTS, MAX_EXTRACT_DOCUMENTS_TOTAL_DECODED_BYTES, MAX_EXTRACT_DOCUMENT_DECODED_BYTES, MAX_EXTRACT_IMAGES, MAX_EXTRACT_IMAGES_TOTAL_DECODED_BYTES, MAX_EXTRACT_IMAGE_DECODED_BYTES, MAX_EXTRACT_SPREADSHEETS, MAX_EXTRACT_SPREADSHEETS_TOTAL_DECODED_BYTES, MAX_EXTRACT_SPREADSHEET_DECODED_BYTES, MAX_SOURCE_TEXT_LENGTH, MAX_USER_PROMPT_LENGTH, MetadataSchema, StorytellingEffortSchema, SuggestionSchema, buildImageAttachment, buildPdfAttachment, buildSpreadsheetAttachment, isCompleteEvent, isErrorEvent, isGraphyApiError, isPreviewEvent, isProgressEvent, isReasoningEvent };
1563
+ export { AggregationFunctionSchema, AggregationSuggestionSchema, AiChartTypeEnum, ChartFamilySchema, ChartFitEntrySchema, ChartFitFactorKindSchema, ChartFitFactorSchema, ChartFitVerdictSchema, DataObservationKindSchema, DataObservationSchema, EvaluateParamsSchema, EvaluateResponseSchema, ExecutionModeSchema, ExploreFindingSchema, ExploreStorySchema, ExtractAccuracyEvaluationSchema, ExtractAttachmentInputSchema, ExtractAttachmentKindSchema, ExtractConfidenceSchema, ExtractFromProseParamsSchema, ExtractFromProseResponseSchema, ExtractMetaSchema, GenerateAnnotationsResponseSchema, GenerateExplorationResponseSchema, GenerateGraphResponseSchema, GenerateGraphSuggestionsResponseSchema, GenerateMutationResponseSchema, GenerateNarrativeParamsSchema, GenerateNarrativeResponseSchema, GenerateSuggestionsParamsSchema, GenerateSuggestionsResponseSchema, GraphGenerationRequestSchema, GraphyAiSdk, GraphyApiError, InvocationBudgetSchema, InvocationEffortSchema, MAX_BUDGET_COST_USD, MAX_BUDGET_TOTAL_TOKENS, MAX_BUDGET_WALL_CLOCK_MS, MAX_EXTRACT_ATTACHMENTS, MAX_EXTRACT_ATTACHMENTS_COMBINED_DECODED_BYTES, MAX_EXTRACT_DOCUMENTS, MAX_EXTRACT_DOCUMENTS_TOTAL_DECODED_BYTES, MAX_EXTRACT_DOCUMENT_DECODED_BYTES, MAX_EXTRACT_IMAGES, MAX_EXTRACT_IMAGES_TOTAL_DECODED_BYTES, MAX_EXTRACT_IMAGE_DECODED_BYTES, MAX_EXTRACT_SPREADSHEETS, MAX_EXTRACT_SPREADSHEETS_TOTAL_DECODED_BYTES, MAX_EXTRACT_SPREADSHEET_DECODED_BYTES, MAX_SOURCE_TEXT_LENGTH, MAX_USER_PROMPT_LENGTH, MetadataSchema, StorytellingEffortSchema, SuggestionSchema, buildImageAttachment, buildPdfAttachment, buildSpreadsheetAttachment, isCompleteEvent, isErrorEvent, isGraphyApiError, isPreviewEvent, isProgressEvent, isReasoningEvent };
1559
1564
  export type { AggregationFunction, AggregationSuggestion, AiChartType, ChartFamily, ChartFitEntry, ChartFitFactor, ChartFitFactorKind, ChartFitVerdict, ClientConfig, CompleteEvent, DataObservation, DataObservationKind, ErrorEvent, EvaluateParams, EvaluateResponse, ExecutionMode, ExploreFinding, ExploreStory, ExtractAccuracyEvaluation, ExtractAttachmentInput, ExtractAttachmentKind, ExtractConfidence, ExtractFromProseParams, ExtractFromProseResponse, ExtractImageInput, ExtractMeta, GenerateAnnotationsParams, GenerateAnnotationsResponse, GenerateExplorationParams, GenerateExplorationResponse, GenerateGraphParams, GenerateGraphResponse, GenerateGraphSuggestionsParams, GenerateGraphSuggestionsResponse, GenerateMutationParams, GenerateMutationResponse, GenerateNarrativeParams, GenerateNarrativeResponse, GenerateSuggestionsParams, GenerateSuggestionsResponse, GraphGenerationRequest, GraphyApiErrorOptions, InvocationBudget, InvocationEffort, Logger, Metadata, PreviewEvent, ProgressEvent, ProgressHandler, ReasoningEvent, RetryConfig, SSEEvent, StorytellingEffort, StorytellingOptions, Suggestion };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{__awaiter as e,__asyncValues as t,__asyncGenerator as i,__await as n,__rest as r}from"tslib";import{z as s}from"zod";class a extends Error{constructor(e,t){var i;super(e),Object.setPrototypeOf(this,new.target.prototype),this.name="GraphyApiError",this.status=null==t?void 0:t.status,this.code=null==t?void 0:t.code,this.retryable=null!==(i=null==t?void 0:t.retryable)&&void 0!==i&&i}}const o=e=>e instanceof a,c=e=>"progress"===e.type,l=e=>"complete"===e.type,m=e=>"error"===e.type,d=e=>"preview"===e.type,u=e=>"reasoning"===e.type;class g{constructor(e){if(this.tag="[GRAPHY]",!e.apiKey||0===e.apiKey.trim().length)throw new Error("apiKey is required and must not be empty");const t=new URL(e.baseUrl);if(!["http:","https:"].includes(t.protocol))throw new Error(`Invalid baseUrl protocol: ${t.protocol}. Only http(s) is allowed.`);this.apiKey=e.apiKey,this.baseUrl=t.origin+t.pathname.replace(/\/$/,""),this.timeout=e.timeout||6e4,this.retryConfig=e.retryConfig||{attempts:3,delay:1e3,backoff:2},this.logger=e.logger||{log:console.log,warn:console.warn,error:console.error,debug:console.debug}}static isProgressEvent(e){return c(e)}static isCompleteEvent(e){return l(e)}static isErrorEvent(e){return m(e)}stream(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.makeRequest(t,i,n);return this.parseSSE(e)})}fetch(i,n,r,s){return e(this,void 0,void 0,function*(){var e,o,d,u,g;const h=Date.now();this.logger.debug(`${this.tag} Fetch: ${i}`);try{const y=yield this.makeRequest(i,n,s),v=y.headers.get("content-type");if(null==v?void 0:v.includes("text/event-stream")){try{for(var p,f=!0,b=t(this.parseSSE(y));!(e=(p=yield b.next()).done);f=!0){u=p.value,f=!1;const e=u;if(c(e)&&r&&r(e),l(e))return e.data;if(m(e)){const t=Date.now()-h;throw this.logger.error(`${this.tag} Server error: ${i} ${t}ms`,e.error),new a(e.error,{code:e.code,retryable:null!==(g=e.retryable)&&void 0!==g&&g})}}}catch(e){o={error:e}}finally{try{f||e||!(d=b.return)||(yield d.call(b))}finally{if(o)throw o.error}}const n=Date.now()-h;throw this.logger.error(`${this.tag} Stream incomplete: ${i} ${n}ms`),new a("Stream ended without completion")}return yield y.json()}catch(e){const t=Date.now()-h;if(this.logger.error(`${this.tag} Fetch failed: ${i} ${t}ms`,e),e instanceof a)throw e;throw e}finally{const e=Date.now()-h;this.logger.debug(`${this.tag} Fetch completed: ${i} ${e}ms`)}})}ping(){return e(this,void 0,void 0,function*(){const e=Date.now();try{return yield this.makeRequest("/health",void 0,void 0,this.retryConfig.attempts,"GET"),{ok:!0,latency:Date.now()-e}}catch(t){return{ok:!1,latency:Date.now()-e}}})}sleep(t){return e(this,void 0,void 0,function*(){return new Promise(e=>setTimeout(e,t))})}parseSSE(e){return i(this,arguments,function*(){if(!e.body)throw new a("Response body is null");const t=e.body.getReader(),i=new TextDecoder;let r="",s="",o="";try{for(;;){const{done:e,value:a}=yield n(t.read());if(e)break;r+=i.decode(a,{stream:!0});const c=r.split(/\r?\n/);r=c.pop()||"";for(const e of c)if(e.startsWith("event: "))s=e.slice(7).trim();else if(e.startsWith("data: "))o+=(o?"\n":"")+e.slice(6);else if(""===e.trim()&&o){try{const e=JSON.parse(o);let t;if("progress"===s){const i=e;t=Object.assign({type:"progress"},i)}else if("complete"===s)t={type:"complete",data:e};else if("error"===s){const i=e;t=Object.assign({type:"error"},i)}else if("preview"===s){const i=e;t=Object.assign(Object.assign({},i),{type:"preview"})}else{if("reasoning"!==s){s="",o="";continue}{const i=e;t=Object.assign(Object.assign({},i),{type:"reasoning"})}}if(yield yield n(t),"complete"===s||"error"===s)return yield n(void 0)}catch(e){this.logger.warn("Invalid SSE data format",o)}s="",o=""}}}finally{t.releaseLock()}})}makeRequest(t,i,n){return e(this,arguments,void 0,function*(e,t,i,n=1,r="POST"){if(!e.startsWith("/"))throw new a("Invalid endpoint: must start with /");const s=new URL(e,this.baseUrl);if(s.origin!==new URL(this.baseUrl).origin)throw new a("Endpoint resolved to unexpected origin");this.logger.debug(`${this.tag} Request ${n}/${this.retryConfig.attempts}: ${s}`);const o=new AbortController,c=setTimeout(()=>o.abort(),this.timeout),l=()=>o.abort();i&&i.addEventListener("abort",l);try{const c=yield fetch(s,Object.assign({method:r,headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream","Cache-Control":"no-cache",Authorization:`Bearer ${this.apiKey}`,"User-Agent":"Graphy-SDK/1.0"},signal:o.signal},"POST"===r&&{body:JSON.stringify(t)}));if(!c.ok){const s=c.status>=500||429===c.status;let o,l=`HTTP ${c.status}`;try{const e=yield c.json();if("object"==typeof e&&null!==e){const t=e;"string"==typeof t.message?l=t.message:"string"==typeof t.error&&(l=t.error),"string"==typeof t.code&&(o=t.code)}}catch(e){}const m=new a(l,{status:c.status,code:o,retryable:s});if(s&&n<this.retryConfig.attempts&&!(null==i?void 0:i.aborted)){const s=this.retryConfig.delay*Math.pow(this.retryConfig.backoff,n-1);return this.logger.warn(`${this.tag} Retrying ${e} in ${s}ms (attempt ${n+1})`),yield this.sleep(s),this.makeRequest(e,t,i,n+1,r)}throw this.logger.error(`${this.tag} Request failed: ${e} (${c.status}) - ${l}`),m}return this.logger.debug(`${this.tag} Connected: ${e}`),c}catch(s){if(s instanceof a)throw s;if(s instanceof Error&&"AbortError"===s.name)throw this.logger.debug(`${this.tag} Aborted: ${e}`),s;if(n<this.retryConfig.attempts&&!(null==i?void 0:i.aborted)){const s=this.retryConfig.delay*Math.pow(this.retryConfig.backoff,n-1);return this.logger.warn(`${this.tag} Network error, retrying ${e} in ${s}ms`),yield this.sleep(s),this.makeRequest(e,t,i,n+1,r)}throw this.logger.error(`${this.tag} Network error: ${e}`,s),new a("Network error",{retryable:!0})}finally{clearTimeout(c),i&&i.removeEventListener("abort",l)}})}}const h=s.enum(["EN_GB","EN_US"]),p=s.custom(e=>null!=e&&"object"==typeof e),f=s.enum(["low","medium","high"]),b=s.enum(["none","low","medium","high"]),y=s.enum(["agentic","fast"]),v=s.object({maxWallClockMs:s.number().positive().optional(),maxTotalTokens:s.number().int().positive().optional(),maxCostUsd:s.number().positive().optional()}),w=s.object({callId:s.string().max(256).optional(),locale:h.optional(),effort:f.optional(),storytellingEffort:b.optional().default("low"),budget:v.optional(),executionMode:y.optional()}),x=1e4,j=s.object({config:p,userPrompt:s.string().max(x).optional().default(""),metadata:w.optional()}),$=j.extend({maxSuggestionCount:s.number().int().min(1).max(4).optional()}),k=s.enum(["line","areaStacked","bar","groupedBar","stackedBar","100StackedBar","column","groupedColumn","stackedColumn","100StackedColumn","combo","pie","donut","funnel","heatmap","scatter","bubble","waterfall","table","mekko"]),S=s.object({dataPrepPrompt:s.string(),chartType:k,summary:s.string()}),C=j.extend({userPrompt:s.string().max(x)}),T=s.object({response:s.object({message:s.string()}),config:p}),O=s.object({suggestions:s.array(S)}),E=s.enum(["comparison","relationship","distribution","composition"]),I=s.object({finding:s.string().describe("Plain-English summary of the finding (no stats jargon)."),confidence:s.number().min(0).max(1).describe("Statistical strength of the finding (0..1). Independent of topicality."),relevance:s.number().min(0).max(1).describe("Topical fit with the user prompt and chart narrative (0..1). Independent of statistical strength."),topic:s.string().min(1).describe("Kebab-case label grouping this finding with related ones; consumers can render findings as threads."),chartHint:s.string().min(1).max(240).describe('Natural-language data-prep recipe for a downstream mutate agent: filter → group → aggregate → sort, naming real dataset columns. No chart type or "render as" clause — that is set via chartFamily.'),chartFamily:E.describe("Abela family (comparison | relationship | distribution | composition). Downstream chart-generator picks the concrete chart type from this family + the data shape."),evidenceSummary:s.string().max(300).describe("Rigorous statistical back-up with exact numbers.")}),P=s.object({topic:s.string().min(1).describe("Kebab-case story headline shared by all child findings."),score:s.number().min(0).max(1).describe("Max quadrant score (relevance × confidence) across child findings."),count:s.number().int().min(1).describe("Number of findings in this story."),findings:s.array(I).describe("Child findings, sorted by quadrant score desc.")}),R=s.object({response:s.object({message:s.string(),steps:s.array(s.string())}),stories:s.array(P)}),B=s.object({response:s.object({message:s.string(),steps:s.array(s.string())}),config:p}),A=s.object({response:s.object({message:s.string(),steps:s.array(s.string())}),config:p}),U=s.enum(["high","medium","low"]),N=s.object({confidence:U,needsUserInput:s.boolean(),warnings:s.array(s.string()),cellConfidence:s.array(s.object({rowIndex:s.number().int().nonnegative(),columnKey:s.string(),confidence:U,quote:s.string().optional()})).optional()}),q=s.object({score:s.number().min(0).max(1),issues:s.array(s.string()),sufficient:s.boolean(),summary:s.string()}),D=5e5,F=8,K=2097152,M=7340032,L=2,G=6291456,W=8388608,z=2,H=G,J=W,_=12582912,Y=12;function Z(e){return 4*Math.ceil(e/3)}const Q=Z(K),V=Z(M),X=Z(G),ee=Z(W),te=Z(H),ie=Z(J),ne=Z(_);function re(e){return e.replace(/\s+/g,"")}function se(e){const t=re(e);return 0!==t.length&&t.length%4==0&&/^[A-Za-z0-9+/]+={0,2}$/.test(t)}const ae=/^image\/(png|jpeg|jpg|webp|gif)$/i,oe=s.object({mimeType:s.string().min(1).refine(e=>ae.test(e.trim()),{message:"mimeType must be image/png, image/jpeg, image/jpg, image/webp, or image/gif"}),dataBase64:s.string().min(1).max(Q).refine(se,{message:"dataBase64 must be standard base64 (RFC 4648)"})}),ce=s.enum(["image","document","spreadsheet"]),le=oe.extend({kind:s.literal("image")}),me=s.object({kind:s.literal("document"),mimeType:s.string().min(1).refine(e=>/^application\/pdf$/i.test(e.trim()),{message:"document mimeType must be application/pdf"}),dataBase64:s.string().min(1).max(X).refine(se,{message:"dataBase64 must be standard base64 (RFC 4648)"})}),de=s.object({kind:s.literal("spreadsheet"),mimeType:s.string().min(1).refine(e=>/^application\/vnd\.openxmlformats-officedocument\.spreadsheetml\.sheet$/i.test(e.trim()),{message:"spreadsheet mimeType must be application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),dataBase64:s.string().min(1).max(te).refine(se,{message:"dataBase64 must be standard base64 (RFC 4648)"}),filename:s.string().max(512).optional()}).refine(e=>void 0===e.filename||e.filename.trim().length>0,{message:"spreadsheet filename must not be empty or whitespace-only",path:["filename"]}),ue=s.discriminatedUnion("kind",[le,me,de]),ge=s.object({sourceText:s.string().max(D).default(""),images:s.array(oe).max(8).optional().describe('@deprecated Use attachments[] with kind: "image" instead. Will be removed in a future major release.'),attachments:s.array(ue).max(12).optional(),metadata:w.optional()}).superRefine((e,t)=>{var i,n;const r=e.sourceText.trim(),s=null!==(i=e.images)&&void 0!==i?i:[],a=null!==(n=e.attachments)&&void 0!==n?n:[];if(s.length>0&&a.length>0)return void t.addIssue({code:"custom",message:'Use either `images` (deprecated) or `attachments`, not both. Migrate to `attachments` with `kind: "image"`.',path:["attachments"]});if(0===r.length&&0===s.length&&0===a.length)return void t.addIssue({code:"custom",message:"Provide non-empty sourceText and/or at least one attachment",path:["sourceText"]});if(s.length>0){s.reduce((e,t)=>e+re(t.dataBase64).length,0)>V&&t.addIssue({code:"custom",message:"Combined image base64 exceeds maximum length for this API (must fit server decode limits)",path:["images"]})}let o=0,c=0,l=0,m=0,d=0,u=0,g=0;for(const e of a){const t=re(e.dataBase64).length;switch(g+=t,e.kind){case"image":o+=1,m+=t;break;case"document":c+=1,d+=t;break;case"spreadsheet":l+=1,u+=t}}o>8&&t.addIssue({code:"custom",message:"Too many images (max 8)",path:["attachments"]}),c>2&&t.addIssue({code:"custom",message:"Too many documents (max 2)",path:["attachments"]}),l>2&&t.addIssue({code:"custom",message:"Too many spreadsheets (max 2)",path:["attachments"]});const h=o<=8&&c<=2&&l<=2;a.length>0&&h&&(m>V&&t.addIssue({code:"custom",message:"Combined image base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),d>ee&&t.addIssue({code:"custom",message:"Combined document base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),u>ie&&t.addIssue({code:"custom",message:"Combined spreadsheet base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),g>ne&&t.addIssue({code:"custom",message:"Combined attachment base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}))});function he(e){return{kind:"image",mimeType:e.mimeType.trim(),dataBase64:re(e.dataBase64)}}function pe(e){return{kind:"document",mimeType:"application/pdf",dataBase64:re(e.dataBase64)}}function fe(e){return Object.assign({kind:"spreadsheet",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",dataBase64:re(e.dataBase64)},void 0!==e.filename?{filename:e.filename.trim()}:{})}const be=s.object({response:s.object({message:s.string()}),config:p,extractMeta:N.nullable(),lastAccuracyEvaluation:q.optional()}),ye=s.object({config:p,response:s.object({message:s.string(),steps:s.array(s.string())})}),ve=O,we=s.enum(["deal-breaker","pro","con","family","continuity"]),xe=s.object({kind:we,label:s.string(),weight:s.number(),reason:s.string()}),je=s.enum(["ok","disqualified"]),$e=s.object({rank:s.number().int().positive(),type:k,score:s.number(),verdict:je,factors:s.array(xe)}),ke=s.object({config:p,chartFamily:E.optional(),metadata:w.optional()}),Se=s.enum(["drop-noisy-dimensions","reshape-for-heatmap","unpivot-wide-format","needs-row-reduction","high-null-columns","constant-columns","outlier-heavy-measures","mixed-scale-measures","needs-metric-filter"]),Ce=s.object({kind:Se,message:s.string()}),Te=s.enum(["sum","avg","count","min","max"]),Oe=s.object({dimensionName:s.string(),dimensionLabel:s.string(),measureName:s.string().nullable(),measureLabel:s.string().nullable(),fn:Te,chartType:k,score:s.number(),message:s.string()}),Ee=s.object({ranking:s.array($e),observations:s.array(Ce).optional().default([]),suggestions:s.array(Oe).optional().default([])}),Ie="/api/v0";class Pe{constructor(e){this.client=new g(e)}generateGraph(t,i,n){return e(this,void 0,void 0,function*(){const{storytellingOptions:e}=t,s=r(t,["storytellingOptions"]),a=yield this.client.fetch(`${Ie}/generate`,s,i,n),o=ye.parse(a);return this.stripStorytelling(o,e)})}generateGraphStream(t,i){return e(this,void 0,void 0,function*(){const{storytellingOptions:e}=t,n=r(t,["storytellingOptions"]),s=yield this.client.stream(`${Ie}/generate`,n,i);return this.wrapStreamWithStorytellingStripping(s,e)})}generateNarrative(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Ie}/narrate`,t,i,n);return T.parse(e)})}generateNarrativeStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${Ie}/narrate`,t,i)})}generateSuggestions(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Ie}/suggestions`,t,i,n);return O.parse(e)})}generateSuggestionsStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${Ie}/suggestions`,t,i)})}generateExploration(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Ie}/explore`,t,i,n);return R.parse(e)})}generateExplorationStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${Ie}/explore`,t,i)})}generateAnnotations(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Ie}/annotate`,t,i,n);return B.parse(e)})}generateAnnotationsStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${Ie}/annotate`,t,i)})}generateMutation(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Ie}/mutate`,t,i,n);return A.parse(e)})}generateMutationStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${Ie}/mutate`,t,i)})}evaluate(t,i){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Ie}/evaluate`,t,void 0,i);return Ee.parse(e)})}extractFromProse(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Ie}/extract`,t,i,n);return be.parse(e)})}extractFromProseStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${Ie}/extract`,t,i)})}stripStorytelling(e,t){return t&&e.config.content?Object.assign(Object.assign({},e),{config:Object.assign(Object.assign({},e.config),{content:Object.assign(Object.assign(Object.assign(Object.assign({},e.config.content),t.excludeTitle&&{title:void 0}),t.excludeSubtitle&&{subtitle:void 0}),t.excludeCaption&&{caption:void 0})})}):e}wrapStreamWithStorytellingStripping(e,r){return i(this,arguments,function*(){var i,s,a,o;try{for(var c,m=!0,d=t(e);!(i=(c=yield n(d.next())).done);m=!0){o=c.value,m=!1;const e=o;if(l(e)){const t=this.stripStorytelling(e.data,r);yield yield n(Object.assign(Object.assign({},e),{data:t}))}else yield yield n(e)}}catch(e){s={error:e}}finally{try{m||i||!(a=d.return)||(yield n(a.call(d)))}finally{if(s)throw s.error}}})}}export{Te as AggregationFunctionSchema,Oe as AggregationSuggestionSchema,k as AiChartTypeEnum,E as ChartFamilySchema,$e as ChartFitEntrySchema,we as ChartFitFactorKindSchema,xe as ChartFitFactorSchema,je as ChartFitVerdictSchema,Se as DataObservationKindSchema,Ce as DataObservationSchema,ke as EvaluateParamsSchema,Ee as EvaluateResponseSchema,y as ExecutionModeSchema,I as ExploreFindingSchema,P as ExploreStorySchema,q as ExtractAccuracyEvaluationSchema,ue as ExtractAttachmentInputSchema,ce as ExtractAttachmentKindSchema,U as ExtractConfidenceSchema,ge as ExtractFromProseParamsSchema,be as ExtractFromProseResponseSchema,N as ExtractMetaSchema,B as GenerateAnnotationsResponseSchema,R as GenerateExplorationResponseSchema,ye as GenerateGraphResponseSchema,ve as GenerateGraphSuggestionsResponseSchema,A as GenerateMutationResponseSchema,C as GenerateNarrativeParamsSchema,T as GenerateNarrativeResponseSchema,$ as GenerateSuggestionsParamsSchema,O as GenerateSuggestionsResponseSchema,j as GraphGenerationRequestSchema,Pe as GraphyAiSdk,a as GraphyApiError,v as InvocationBudgetSchema,f as InvocationEffortSchema,Y as MAX_EXTRACT_ATTACHMENTS,_ as MAX_EXTRACT_ATTACHMENTS_COMBINED_DECODED_BYTES,L as MAX_EXTRACT_DOCUMENTS,W as MAX_EXTRACT_DOCUMENTS_TOTAL_DECODED_BYTES,G as MAX_EXTRACT_DOCUMENT_DECODED_BYTES,F as MAX_EXTRACT_IMAGES,M as MAX_EXTRACT_IMAGES_TOTAL_DECODED_BYTES,K as MAX_EXTRACT_IMAGE_DECODED_BYTES,z as MAX_EXTRACT_SPREADSHEETS,J as MAX_EXTRACT_SPREADSHEETS_TOTAL_DECODED_BYTES,H as MAX_EXTRACT_SPREADSHEET_DECODED_BYTES,D as MAX_SOURCE_TEXT_LENGTH,x as MAX_USER_PROMPT_LENGTH,w as MetadataSchema,b as StorytellingEffortSchema,S as SuggestionSchema,he as buildImageAttachment,pe as buildPdfAttachment,fe as buildSpreadsheetAttachment,l as isCompleteEvent,m as isErrorEvent,o as isGraphyApiError,d as isPreviewEvent,c as isProgressEvent,u as isReasoningEvent};
1
+ import{__awaiter as e,__asyncValues as t,__asyncGenerator as i,__await as n,__rest as r}from"tslib";import{z as s}from"zod";class a extends Error{constructor(e,t){var i;super(e),Object.setPrototypeOf(this,new.target.prototype),this.name="GraphyApiError",this.status=null==t?void 0:t.status,this.code=null==t?void 0:t.code,this.retryable=null!==(i=null==t?void 0:t.retryable)&&void 0!==i&&i}}const o=e=>e instanceof a,c=e=>"progress"===e.type,l=e=>"complete"===e.type,m=e=>"error"===e.type,d=e=>"preview"===e.type,u=e=>"reasoning"===e.type;class g{constructor(e){if(this.tag="[GRAPHY]",!e.apiKey||0===e.apiKey.trim().length)throw new Error("apiKey is required and must not be empty");const t=new URL(e.baseUrl);if(!["http:","https:"].includes(t.protocol))throw new Error(`Invalid baseUrl protocol: ${t.protocol}. Only http(s) is allowed.`);this.apiKey=e.apiKey,this.baseUrl=t.origin+t.pathname.replace(/\/$/,""),this.timeout=e.timeout||6e4,this.retryConfig=e.retryConfig||{attempts:3,delay:1e3,backoff:2},this.logger=e.logger||{log:console.log,warn:console.warn,error:console.error,debug:console.debug}}static isProgressEvent(e){return c(e)}static isCompleteEvent(e){return l(e)}static isErrorEvent(e){return m(e)}stream(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.makeRequest(t,i,n);return this.parseSSE(e)})}fetch(i,n,r,s){return e(this,void 0,void 0,function*(){var e,o,d,u,g;const h=Date.now();this.logger.debug(`${this.tag} Fetch: ${i}`);try{const y=yield this.makeRequest(i,n,s),v=y.headers.get("content-type");if(null==v?void 0:v.includes("text/event-stream")){try{for(var p,f=!0,b=t(this.parseSSE(y));!(e=(p=yield b.next()).done);f=!0){u=p.value,f=!1;const e=u;if(c(e)&&r&&r(e),l(e))return e.data;if(m(e)){const t=Date.now()-h;throw this.logger.error(`${this.tag} Server error: ${i} ${t}ms`,e.error),new a(e.error,{code:e.code,retryable:null!==(g=e.retryable)&&void 0!==g&&g})}}}catch(e){o={error:e}}finally{try{f||e||!(d=b.return)||(yield d.call(b))}finally{if(o)throw o.error}}const n=Date.now()-h;throw this.logger.error(`${this.tag} Stream incomplete: ${i} ${n}ms`),new a("Stream ended without completion")}return yield y.json()}catch(e){const t=Date.now()-h;if(this.logger.error(`${this.tag} Fetch failed: ${i} ${t}ms`,e),e instanceof a)throw e;throw e}finally{const e=Date.now()-h;this.logger.debug(`${this.tag} Fetch completed: ${i} ${e}ms`)}})}ping(){return e(this,void 0,void 0,function*(){const e=Date.now();try{return yield this.makeRequest("/health",void 0,void 0,this.retryConfig.attempts,"GET"),{ok:!0,latency:Date.now()-e}}catch(t){return{ok:!1,latency:Date.now()-e}}})}sleep(t){return e(this,void 0,void 0,function*(){return new Promise(e=>setTimeout(e,t))})}parseSSE(e){return i(this,arguments,function*(){if(!e.body)throw new a("Response body is null");const t=e.body.getReader(),i=new TextDecoder;let r="",s="",o="";try{for(;;){const{done:e,value:a}=yield n(t.read());if(e)break;r+=i.decode(a,{stream:!0});const c=r.split(/\r?\n/);r=c.pop()||"";for(const e of c)if(e.startsWith("event: "))s=e.slice(7).trim();else if(e.startsWith("data: "))o+=(o?"\n":"")+e.slice(6);else if(""===e.trim()&&o){try{const e=JSON.parse(o);let t;if("progress"===s){const i=e;t=Object.assign({type:"progress"},i)}else if("complete"===s)t={type:"complete",data:e};else if("error"===s){const i=e;t=Object.assign({type:"error"},i)}else if("preview"===s){const i=e;t=Object.assign(Object.assign({},i),{type:"preview"})}else{if("reasoning"!==s){s="",o="";continue}{const i=e;t=Object.assign(Object.assign({},i),{type:"reasoning"})}}if(yield yield n(t),"complete"===s||"error"===s)return yield n(void 0)}catch(e){this.logger.warn("Invalid SSE data format",o)}s="",o=""}}}finally{t.releaseLock()}})}makeRequest(t,i,n){return e(this,arguments,void 0,function*(e,t,i,n=1,r="POST"){if(!e.startsWith("/"))throw new a("Invalid endpoint: must start with /");const s=new URL(e,this.baseUrl);if(s.origin!==new URL(this.baseUrl).origin)throw new a("Endpoint resolved to unexpected origin");this.logger.debug(`${this.tag} Request ${n}/${this.retryConfig.attempts}: ${s}`);const o=new AbortController,c=setTimeout(()=>o.abort(),this.timeout),l=()=>o.abort();i&&i.addEventListener("abort",l);try{const c=yield fetch(s,Object.assign({method:r,headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream","Cache-Control":"no-cache",Authorization:`Bearer ${this.apiKey}`,"User-Agent":"Graphy-SDK/1.0"},signal:o.signal},"POST"===r&&{body:JSON.stringify(t)}));if(!c.ok){const s=c.status>=500||429===c.status;let o,l=`HTTP ${c.status}`;try{const e=yield c.json();if("object"==typeof e&&null!==e){const t=e;"string"==typeof t.message?l=t.message:"string"==typeof t.error&&(l=t.error),"string"==typeof t.code&&(o=t.code)}}catch(e){}const m=new a(l,{status:c.status,code:o,retryable:s});if(s&&n<this.retryConfig.attempts&&!(null==i?void 0:i.aborted)){const s=this.retryConfig.delay*Math.pow(this.retryConfig.backoff,n-1);return this.logger.warn(`${this.tag} Retrying ${e} in ${s}ms (attempt ${n+1})`),yield this.sleep(s),this.makeRequest(e,t,i,n+1,r)}throw this.logger.error(`${this.tag} Request failed: ${e} (${c.status}) - ${l}`),m}return this.logger.debug(`${this.tag} Connected: ${e}`),c}catch(s){if(s instanceof a)throw s;if(s instanceof Error&&"AbortError"===s.name)throw this.logger.debug(`${this.tag} Aborted: ${e}`),s;if(n<this.retryConfig.attempts&&!(null==i?void 0:i.aborted)){const s=this.retryConfig.delay*Math.pow(this.retryConfig.backoff,n-1);return this.logger.warn(`${this.tag} Network error, retrying ${e} in ${s}ms`),yield this.sleep(s),this.makeRequest(e,t,i,n+1,r)}throw this.logger.error(`${this.tag} Network error: ${e}`,s),new a("Network error",{retryable:!0})}finally{clearTimeout(c),i&&i.removeEventListener("abort",l)}})}}const h=s.enum(["EN_GB","EN_US"]),p=s.custom(e=>null!=e&&"object"==typeof e),f=s.enum(["low","medium","high"]),b=s.enum(["none","low","medium","high"]),y=s.enum(["agentic","fast"]),v=3e5,w=5e5,x=10,j=s.object({maxWallClockMs:s.number().positive().max(v).optional(),maxTotalTokens:s.number().int().positive().max(w).optional(),maxCostUsd:s.number().positive().max(10).optional()}),$=s.object({callId:s.string().max(256).optional(),locale:h.optional(),effort:f.optional(),storytellingEffort:b.optional().default("low"),budget:j.optional(),executionMode:y.optional()}),k=1e4,S=s.object({config:p,userPrompt:s.string().max(k).optional().default(""),metadata:$.optional()}),C=S.extend({maxSuggestionCount:s.number().int().min(1).max(4).optional()}),T=s.enum(["line","areaStacked","bar","groupedBar","stackedBar","100StackedBar","column","groupedColumn","stackedColumn","100StackedColumn","combo","pie","donut","funnel","heatmap","scatter","bubble","waterfall","table","mekko"]),O=s.object({dataPrepPrompt:s.string(),chartType:T,summary:s.string()}),E=S.extend({userPrompt:s.string().max(k)}),I=s.object({response:s.object({message:s.string()}),config:p}),P=s.object({suggestions:s.array(O)}),R=s.enum(["comparison","relationship","distribution","composition"]),B=s.object({finding:s.string().describe("Plain-English summary of the finding (no stats jargon)."),confidence:s.number().min(0).max(1).describe("Statistical strength of the finding (0..1). Independent of topicality."),relevance:s.number().min(0).max(1).describe("Topical fit with the user prompt and chart narrative (0..1). Independent of statistical strength."),topic:s.string().min(1).describe("Kebab-case label grouping this finding with related ones; consumers can render findings as threads."),chartHint:s.string().min(1).max(240).describe('Natural-language data-prep recipe for a downstream mutate agent: filter → group → aggregate → sort, naming real dataset columns. No chart type or "render as" clause — that is set via chartFamily.'),chartFamily:R.describe("Abela family (comparison | relationship | distribution | composition). Downstream chart-generator picks the concrete chart type from this family + the data shape."),evidenceSummary:s.string().max(300).describe("Rigorous statistical back-up with exact numbers.")}),A=s.object({topic:s.string().min(1).describe("Kebab-case story headline shared by all child findings."),score:s.number().min(0).max(1).describe("Max quadrant score (relevance × confidence) across child findings."),count:s.number().int().min(1).describe("Number of findings in this story."),findings:s.array(B).describe("Child findings, sorted by quadrant score desc.")}),U=s.object({response:s.object({message:s.string(),steps:s.array(s.string())}),stories:s.array(A)}),N=s.object({response:s.object({message:s.string(),steps:s.array(s.string())}),config:p}),q=s.object({response:s.object({message:s.string(),steps:s.array(s.string())}),config:p}),D=s.enum(["high","medium","low"]),F=s.object({confidence:D,needsUserInput:s.boolean(),warnings:s.array(s.string()),cellConfidence:s.array(s.object({rowIndex:s.number().int().nonnegative(),columnKey:s.string(),confidence:D,quote:s.string().optional()})).optional()}),K=s.object({score:s.number().min(0).max(1),issues:s.array(s.string()),sufficient:s.boolean(),summary:s.string()}),M=5e5,L=8,G=2097152,W=7340032,z=2,H=6291456,J=8388608,_=2,Y=H,Z=J,Q=12582912,V=12;function X(e){return 4*Math.ceil(e/3)}const ee=X(G),te=X(W),ie=X(H),ne=X(J),re=X(Y),se=X(Z),ae=X(Q);function oe(e){return e.replace(/\s+/g,"")}function ce(e){const t=oe(e);return 0!==t.length&&t.length%4==0&&/^[A-Za-z0-9+/]+={0,2}$/.test(t)}const le=/^image\/(png|jpeg|jpg|webp|gif)$/i,me=s.object({mimeType:s.string().min(1).refine(e=>le.test(e.trim()),{message:"mimeType must be image/png, image/jpeg, image/jpg, image/webp, or image/gif"}),dataBase64:s.string().min(1).max(ee).refine(ce,{message:"dataBase64 must be standard base64 (RFC 4648)"})}),de=s.enum(["image","document","spreadsheet"]),ue=me.extend({kind:s.literal("image")}),ge=s.object({kind:s.literal("document"),mimeType:s.string().min(1).refine(e=>/^application\/pdf$/i.test(e.trim()),{message:"document mimeType must be application/pdf"}),dataBase64:s.string().min(1).max(ie).refine(ce,{message:"dataBase64 must be standard base64 (RFC 4648)"})}),he=s.object({kind:s.literal("spreadsheet"),mimeType:s.string().min(1).refine(e=>/^application\/vnd\.openxmlformats-officedocument\.spreadsheetml\.sheet$/i.test(e.trim()),{message:"spreadsheet mimeType must be application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),dataBase64:s.string().min(1).max(re).refine(ce,{message:"dataBase64 must be standard base64 (RFC 4648)"}),filename:s.string().max(512).optional()}).refine(e=>void 0===e.filename||e.filename.trim().length>0,{message:"spreadsheet filename must not be empty or whitespace-only",path:["filename"]}),pe=s.discriminatedUnion("kind",[ue,ge,he]),fe=s.object({sourceText:s.string().max(M).default(""),images:s.array(me).max(8).optional().describe('@deprecated Use attachments[] with kind: "image" instead. Will be removed in a future major release.'),attachments:s.array(pe).max(12).optional(),metadata:$.optional()}).superRefine((e,t)=>{var i,n;const r=e.sourceText.trim(),s=null!==(i=e.images)&&void 0!==i?i:[],a=null!==(n=e.attachments)&&void 0!==n?n:[];if(s.length>0&&a.length>0)return void t.addIssue({code:"custom",message:'Use either `images` (deprecated) or `attachments`, not both. Migrate to `attachments` with `kind: "image"`.',path:["attachments"]});if(0===r.length&&0===s.length&&0===a.length)return void t.addIssue({code:"custom",message:"Provide non-empty sourceText and/or at least one attachment",path:["sourceText"]});if(s.length>0){s.reduce((e,t)=>e+oe(t.dataBase64).length,0)>te&&t.addIssue({code:"custom",message:"Combined image base64 exceeds maximum length for this API (must fit server decode limits)",path:["images"]})}let o=0,c=0,l=0,m=0,d=0,u=0,g=0;for(const e of a){const t=oe(e.dataBase64).length;switch(g+=t,e.kind){case"image":o+=1,m+=t;break;case"document":c+=1,d+=t;break;case"spreadsheet":l+=1,u+=t}}o>8&&t.addIssue({code:"custom",message:"Too many images (max 8)",path:["attachments"]}),c>2&&t.addIssue({code:"custom",message:"Too many documents (max 2)",path:["attachments"]}),l>2&&t.addIssue({code:"custom",message:"Too many spreadsheets (max 2)",path:["attachments"]});const h=o<=8&&c<=2&&l<=2;a.length>0&&h&&(m>te&&t.addIssue({code:"custom",message:"Combined image base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),d>ne&&t.addIssue({code:"custom",message:"Combined document base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),u>se&&t.addIssue({code:"custom",message:"Combined spreadsheet base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),g>ae&&t.addIssue({code:"custom",message:"Combined attachment base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}))});function be(e){return{kind:"image",mimeType:e.mimeType.trim(),dataBase64:oe(e.dataBase64)}}function ye(e){return{kind:"document",mimeType:"application/pdf",dataBase64:oe(e.dataBase64)}}function ve(e){return Object.assign({kind:"spreadsheet",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",dataBase64:oe(e.dataBase64)},void 0!==e.filename?{filename:e.filename.trim()}:{})}const we=s.object({response:s.object({message:s.string()}),config:p,extractMeta:F.nullable(),lastAccuracyEvaluation:K.optional()}),xe=s.object({config:p,response:s.object({message:s.string(),steps:s.array(s.string())})}),je=P,$e=s.enum(["deal-breaker","pro","con","family","continuity"]),ke=s.object({kind:$e,label:s.string(),weight:s.number(),reason:s.string()}),Se=s.enum(["ok","disqualified"]),Ce=s.object({rank:s.number().int().positive(),type:T,score:s.number(),verdict:Se,factors:s.array(ke)}),Te=s.object({config:p,chartFamily:R.optional(),metadata:$.optional()}),Oe=s.enum(["drop-noisy-dimensions","reshape-for-heatmap","unpivot-wide-format","needs-row-reduction","high-null-columns","constant-columns","outlier-heavy-measures","mixed-scale-measures","needs-metric-filter"]),Ee=s.object({kind:Oe,message:s.string()}),Ie=s.enum(["sum","avg","count","min","max"]),Pe=s.object({dimensionName:s.string(),dimensionLabel:s.string(),measureName:s.string().nullable(),measureLabel:s.string().nullable(),fn:Ie,chartType:T,score:s.number(),message:s.string()}),Re=s.object({ranking:s.array(Ce),observations:s.array(Ee).optional().default([]),suggestions:s.array(Pe).optional().default([])}),Be="/api/v0";class Ae{constructor(e){this.client=new g(e)}generateGraph(t,i,n){return e(this,void 0,void 0,function*(){const{storytellingOptions:e}=t,s=r(t,["storytellingOptions"]),a=yield this.client.fetch(`${Be}/generate`,s,i,n),o=xe.parse(a);return this.stripStorytelling(o,e)})}generateGraphStream(t,i){return e(this,void 0,void 0,function*(){const{storytellingOptions:e}=t,n=r(t,["storytellingOptions"]),s=yield this.client.stream(`${Be}/generate`,n,i);return this.wrapStreamWithStorytellingStripping(s,e)})}generateNarrative(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Be}/narrate`,t,i,n);return I.parse(e)})}generateNarrativeStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${Be}/narrate`,t,i)})}generateSuggestions(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Be}/suggestions`,t,i,n);return P.parse(e)})}generateSuggestionsStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${Be}/suggestions`,t,i)})}generateExploration(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Be}/explore`,t,i,n);return U.parse(e)})}generateExplorationStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${Be}/explore`,t,i)})}generateAnnotations(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Be}/annotate`,t,i,n);return N.parse(e)})}generateAnnotationsStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${Be}/annotate`,t,i)})}generateMutation(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Be}/mutate`,t,i,n);return q.parse(e)})}generateMutationStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${Be}/mutate`,t,i)})}evaluate(t,i){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Be}/evaluate`,t,void 0,i);return Re.parse(e)})}extractFromProse(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Be}/extract`,t,i,n);return we.parse(e)})}extractFromProseStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${Be}/extract`,t,i)})}stripStorytelling(e,t){return t&&e.config.content?Object.assign(Object.assign({},e),{config:Object.assign(Object.assign({},e.config),{content:Object.assign(Object.assign(Object.assign(Object.assign({},e.config.content),t.excludeTitle&&{title:void 0}),t.excludeSubtitle&&{subtitle:void 0}),t.excludeCaption&&{caption:void 0})})}):e}wrapStreamWithStorytellingStripping(e,r){return i(this,arguments,function*(){var i,s,a,o;try{for(var c,m=!0,d=t(e);!(i=(c=yield n(d.next())).done);m=!0){o=c.value,m=!1;const e=o;if(l(e)){const t=this.stripStorytelling(e.data,r);yield yield n(Object.assign(Object.assign({},e),{data:t}))}else yield yield n(e)}}catch(e){s={error:e}}finally{try{m||i||!(a=d.return)||(yield n(a.call(d)))}finally{if(s)throw s.error}}})}}export{Ie as AggregationFunctionSchema,Pe as AggregationSuggestionSchema,T as AiChartTypeEnum,R as ChartFamilySchema,Ce as ChartFitEntrySchema,$e as ChartFitFactorKindSchema,ke as ChartFitFactorSchema,Se as ChartFitVerdictSchema,Oe as DataObservationKindSchema,Ee as DataObservationSchema,Te as EvaluateParamsSchema,Re as EvaluateResponseSchema,y as ExecutionModeSchema,B as ExploreFindingSchema,A as ExploreStorySchema,K as ExtractAccuracyEvaluationSchema,pe as ExtractAttachmentInputSchema,de as ExtractAttachmentKindSchema,D as ExtractConfidenceSchema,fe as ExtractFromProseParamsSchema,we as ExtractFromProseResponseSchema,F as ExtractMetaSchema,N as GenerateAnnotationsResponseSchema,U as GenerateExplorationResponseSchema,xe as GenerateGraphResponseSchema,je as GenerateGraphSuggestionsResponseSchema,q as GenerateMutationResponseSchema,E as GenerateNarrativeParamsSchema,I as GenerateNarrativeResponseSchema,C as GenerateSuggestionsParamsSchema,P as GenerateSuggestionsResponseSchema,S as GraphGenerationRequestSchema,Ae as GraphyAiSdk,a as GraphyApiError,j as InvocationBudgetSchema,f as InvocationEffortSchema,x as MAX_BUDGET_COST_USD,w as MAX_BUDGET_TOTAL_TOKENS,v as MAX_BUDGET_WALL_CLOCK_MS,V as MAX_EXTRACT_ATTACHMENTS,Q as MAX_EXTRACT_ATTACHMENTS_COMBINED_DECODED_BYTES,z as MAX_EXTRACT_DOCUMENTS,J as MAX_EXTRACT_DOCUMENTS_TOTAL_DECODED_BYTES,H as MAX_EXTRACT_DOCUMENT_DECODED_BYTES,L as MAX_EXTRACT_IMAGES,W as MAX_EXTRACT_IMAGES_TOTAL_DECODED_BYTES,G as MAX_EXTRACT_IMAGE_DECODED_BYTES,_ as MAX_EXTRACT_SPREADSHEETS,Z as MAX_EXTRACT_SPREADSHEETS_TOTAL_DECODED_BYTES,Y as MAX_EXTRACT_SPREADSHEET_DECODED_BYTES,M as MAX_SOURCE_TEXT_LENGTH,k as MAX_USER_PROMPT_LENGTH,$ as MetadataSchema,b as StorytellingEffortSchema,O as SuggestionSchema,be as buildImageAttachment,ye as buildPdfAttachment,ve as buildSpreadsheetAttachment,l as isCompleteEvent,m as isErrorEvent,o as isGraphyApiError,d as isPreviewEvent,c as isProgressEvent,u as isReasoningEvent};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@graphysdk/agents-sdk",
3
3
  "author": "Graphy",
4
- "version": "1.5.0",
4
+ "version": "1.5.1-beta.1780051364996",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "files": [
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "zod": "^4.3.6",
21
- "@graphysdk/core": "1.5.0"
21
+ "@graphysdk/core": "1.5.1-beta.1780051364996"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@rollup/plugin-commonjs": "^28.0.6",