@graphysdk/agents-sdk 1.5.1-beta.1780051364996 → 1.6.0-beta.1780415323009

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=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;
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,i=e=>"complete"===e.type,n=e=>"error"===e.type;class o{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 i(e)}static isErrorEvent(e){return n(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,o,s,c){return e.__awaiter(this,void 0,void 0,function*(){var m,l,p,d,u;const g=Date.now();this.logger.debug(`${this.tag} Fetch: ${t}`);try{const b=yield this.makeRequest(t,o,c),z=b.headers.get("content-type");if(null==z?void 0:z.includes("text/event-stream")){try{for(var h,f=!0,y=e.__asyncValues(this.parseSSE(b));!(m=(h=yield y.next()).done);f=!0){d=h.value,f=!1;const e=d;if(a(e)&&s&&s(e),i(e))return e.data;if(n(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||!(p=y.return)||(yield p.call(y))}finally{if(l)throw l.error}}const o=Date.now()-g;throw this.logger.error(`${this.tag} Stream incomplete: ${t} ${o}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(),i=new TextDecoder;let n="",o="",s="";try{for(;;){const{done:t,value:r}=yield e.__await(a.read());if(t)break;n+=i.decode(r,{stream:!0});const c=n.split(/\r?\n/);n=c.pop()||"";for(const t of c)if(t.startsWith("event: "))o=t.slice(7).trim();else if(t.startsWith("data: "))s+=(s?"\n":"")+t.slice(6);else if(""===t.trim()&&s){try{const t=JSON.parse(s);let r;if("progress"===o){const e=t;r=Object.assign({type:"progress"},e)}else if("complete"===o)r={type:"complete",data:t};else if("error"===o){const e=t;r=Object.assign({type:"error"},e)}else if("preview"===o){const e=t;r=Object.assign(Object.assign({},e),{type:"preview"})}else{if("reasoning"!==o){o="",s="";continue}{const e=t;r=Object.assign(Object.assign({},e),{type:"reasoning"})}}if(yield yield e.__await(r),"complete"===o||"error"===o)return yield e.__await(void 0)}catch(e){this.logger.warn("Invalid SSE data format",s)}o="",s=""}}}finally{a.releaseLock()}})}makeRequest(t,a,i){return e.__awaiter(this,arguments,void 0,function*(e,t,a,i=1,n="POST"){if(!e.startsWith("/"))throw new r("Invalid endpoint: must start with /");const o=new URL(e,this.baseUrl);if(o.origin!==new URL(this.baseUrl).origin)throw new r("Endpoint resolved to unexpected origin");this.logger.debug(`${this.tag} Request ${i}/${this.retryConfig.attempts}: ${o}`);const s=new AbortController,c=setTimeout(()=>s.abort(),this.timeout),m=()=>s.abort();a&&a.addEventListener("abort",m);try{const c=yield fetch(o,Object.assign({method:n,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:s.signal},"POST"===n&&{body:JSON.stringify(t)}));if(!c.ok){const o=c.status>=500||429===c.status;let s,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&&(s=t.code)}}catch(e){}const l=new r(m,{status:c.status,code:s,retryable:o});if(o&&i<this.retryConfig.attempts&&!(null==a?void 0:a.aborted)){const r=this.retryConfig.delay*Math.pow(this.retryConfig.backoff,i-1);return this.logger.warn(`${this.tag} Retrying ${e} in ${r}ms (attempt ${i+1})`),yield this.sleep(r),this.makeRequest(e,t,a,i+1,n)}throw this.logger.error(`${this.tag} Request failed: ${e} (${c.status}) - ${m}`),l}return this.logger.debug(`${this.tag} Connected: ${e}`),c}catch(o){if(o instanceof r)throw o;if(o instanceof Error&&"AbortError"===o.name)throw this.logger.debug(`${this.tag} Aborted: ${e}`),o;if(i<this.retryConfig.attempts&&!(null==a?void 0:a.aborted)){const r=this.retryConfig.delay*Math.pow(this.retryConfig.backoff,i-1);return this.logger.warn(`${this.tag} Network error, retrying ${e} in ${r}ms`),yield this.sleep(r),this.makeRequest(e,t,a,i+1,n)}throw this.logger.error(`${this.tag} Network error: ${e}`,o),new r("Network error",{retryable:!0})}finally{clearTimeout(c),a&&a.removeEventListener("abort",m)}})}}const s=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"]),p=t.z.enum(["agentic","fast"]),d=3e5,u=5e5,g=t.z.object({maxWallClockMs:t.z.number().positive().max(d).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:s.optional(),effort:m.optional(),storytellingEffort:l.optional().default("low"),budget:g.optional(),executionMode:p.optional(),enforceTableRowCap:t.z.boolean().optional()}),f=t.z.object({steps:t.z.array(t.z.string()),postProcess:t.z.object({measureRelevance:t.z.enum(["prompt-named","derived","magnitude"]).optional(),grain:t.z.enum(["remap-x","groupBy","reshape","compositeX"]).optional(),chartType:t.z.string().optional(),comparison:t.z.string().optional()}).optional(),droppedMeasures:t.z.array(t.z.string()).optional(),rowCount:t.z.number().int().nonnegative(),totalRowCountBeforeSlice:t.z.number().int().positive().optional(),displayedRowCount:t.z.number().int().nonnegative().optional(),columnKeys:t.z.array(t.z.string()),activeFilters:t.z.array(t.z.string()).optional(),grainSummary:t.z.string().optional()}),y=1e4,b=t.z.enum(["comparison","relationship","distribution","composition"]),z=t.z.object({config:c,userPrompt:t.z.string().max(y).optional().default(""),metadata:h.optional(),chartFamily:b.optional()}),x=z.extend({maxSuggestionCount:t.z.number().int().min(1).max(4).optional()}),v=t.z.enum(["line","areaStacked","bar","groupedBar","stackedBar","100StackedBar","column","groupedColumn","stackedColumn","100StackedColumn","combo","pie","donut","funnel","heatmap","scatter","bubble","waterfall","table","mekko"]),S=t.z.object({dataPrepPrompt:t.z.string(),chartType:v,summary:t.z.string()}),_=z.extend({userPrompt:t.z.string().max(y),mutationReceipt:f.optional(),exploreFindingSummary:t.z.string().max(500).optional()}),w=t.z.object({response:t.z.object({message:t.z.string()}),config:c}),E=t.z.object({suggestions:t.z.array(S)}),T=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:b.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.")}),C=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(T).describe("Child findings, sorted by quadrant score desc.")}),j=t.z.object({response:t.z.object({message:t.z.string(),steps:t.z.array(t.z.string())}),stories:t.z.array(C)});z.extend({mutationReceipt:f.optional()});const A=t.z.object({response:t.z.object({message:t.z.string(),steps:t.z.array(t.z.string())}),config:c}),R=t.z.object({response:t.z.object({message:t.z.string(),steps:t.z.array(t.z.string())}),config:c,mutationReceipt:f.optional(),warnings:t.z.array(t.z.string()).optional()}),$=t.z.enum(["explore","mutate","narrate","annotate"]),O=t.z.object({agent:$,summary:t.z.string(),steps:t.z.array(t.z.string()).optional()}),k=z.extend({userPrompt:t.z.string().max(y),stages:t.z.array($).min(1).refine(e=>new Set(e).size===e.length,{message:"Duplicate pipeline stages are not allowed"}),exploreFindingSummary:t.z.string().max(500).optional()}),P=R.extend({reasoning:t.z.array(O),stories:t.z.array(C).optional()}),D=t.z.enum(["high","medium","low"]),M=t.z.object({confidence:D,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:D,quote:t.z.string().optional()})).optional()}),I=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()}),G=5e5,B=2097152,X=7340032,F=6291456,N=8388608,U=F,q=N,L=12582912;function K(e){return 4*Math.ceil(e/3)}const H=K(B),W=K(X),Y=K(F),J=K(N),V=K(U),Z=K(q),Q=K(L);function ee(e){return e.replace(/\s+/g,"")}function te(e){const t=ee(e);return 0!==t.length&&t.length%4==0&&/^[A-Za-z0-9+/]+={0,2}$/.test(t)}const re=/^image\/(png|jpeg|jpg|webp|gif)$/i,ae=t.z.object({mimeType:t.z.string().min(1).refine(e=>re.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(H).refine(te,{message:"dataBase64 must be standard base64 (RFC 4648)"})}),ie=t.z.enum(["image","document","spreadsheet"]),ne=ae.extend({kind:t.z.literal("image")}),oe=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(Y).refine(te,{message:"dataBase64 must be standard base64 (RFC 4648)"})}),se=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(V).refine(te,{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"]}),ce=t.z.discriminatedUnion("kind",[ne,oe,se]),me=t.z.object({sourceText:t.z.string().max(G).default(""),images:t.z.array(ae).max(8).optional().describe('@deprecated Use attachments[] with kind: "image" instead. Will be removed in a future major release.'),attachments:t.z.array(ce).max(12).optional(),metadata:h.optional()}).superRefine((e,t)=>{var r,a;const i=e.sourceText.trim(),n=null!==(r=e.images)&&void 0!==r?r:[],o=null!==(a=e.attachments)&&void 0!==a?a:[];if(n.length>0&&o.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===i.length&&0===n.length&&0===o.length)return void t.addIssue({code:"custom",message:"Provide non-empty sourceText and/or at least one attachment",path:["sourceText"]});if(n.length>0){n.reduce((e,t)=>e+ee(t.dataBase64).length,0)>W&&t.addIssue({code:"custom",message:"Combined image base64 exceeds maximum length for this API (must fit server decode limits)",path:["images"]})}let s=0,c=0,m=0,l=0,p=0,d=0,u=0;for(const e of o){const t=ee(e.dataBase64).length;switch(u+=t,e.kind){case"image":s+=1,l+=t;break;case"document":c+=1,p+=t;break;case"spreadsheet":m+=1,d+=t}}s>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=s<=8&&c<=2&&m<=2;o.length>0&&g&&(l>W&&t.addIssue({code:"custom",message:"Combined image base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),p>J&&t.addIssue({code:"custom",message:"Combined document base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),d>Z&&t.addIssue({code:"custom",message:"Combined spreadsheet base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),u>Q&&t.addIssue({code:"custom",message:"Combined attachment base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}))});const le=t.z.object({response:t.z.object({message:t.z.string()}),config:c,extractMeta:M.nullable(),lastAccuracyEvaluation:I.optional()}),pe=t.z.object({config:c,response:t.z.object({message:t.z.string(),steps:t.z.array(t.z.string())})}),de=E,ue=t.z.enum(["deal-breaker","pro","con","family","continuity"]),ge=t.z.object({kind:ue,label:t.z.string(),weight:t.z.number(),reason:t.z.string()}),he=t.z.enum(["ok","disqualified"]),fe=t.z.object({rank:t.z.number().int().positive(),type:v,score:t.z.number(),verdict:he,factors:t.z.array(ge)}),ye=t.z.object({config:c,chartFamily:b.optional(),metadata:h.optional()}),be=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"]),ze=t.z.object({kind:be,message:t.z.string()}),xe=t.z.enum(["sum","avg","count","min","max"]),ve=t.z.object({dimensionName:t.z.string(),dimensionLabel:t.z.string(),measureName:t.z.string().nullable(),measureLabel:t.z.string().nullable(),fn:xe,chartType:v,score:t.z.number(),message:t.z.string()}),Se=t.z.object({ranking:t.z.array(fe),observations:t.z.array(ze).optional().default([]),suggestions:t.z.array(ve).optional().default([])}),_e=t.z.object({prompt:t.z.string(),datasetSummary:t.z.string().optional(),mustShow:t.z.array(t.z.string()).optional(),unacceptable:t.z.array(t.z.string()).optional(),acceptableChartFamilies:t.z.array(t.z.string()).optional()}),we=t.z.object({config:c.optional(),chartImage:t.z.string().optional(),data:t.z.unknown().optional(),rubric:_e.optional(),userPrompt:t.z.string().optional(),metadata:h.optional()}).refine(e=>void 0!==e.config||void 0!==e.chartImage,{message:"Provide a chart config or a chart image to judge."}),Ee=t.z.enum(["layout","color_contrast","typography","clutter","encoding","labels_legends","title_caption","other"]),Te=t.z.enum(["info","low","medium","high"]),Ce=t.z.object({category:Ee,severity:Te,observation:t.z.string(),rationale:t.z.string().optional(),suggestedChange:t.z.string().optional(),configPaths:t.z.array(t.z.string()).optional()}),je=t.z.object({overallSummary:t.z.string(),overallSeverity:t.z.enum(["none","low","medium","high"]).optional(),issues:t.z.array(Ce)}),Ae=t.z.object({dataFidelity:t.z.number().min(0).max(1),promptRelevance:t.z.number().min(0).max(1),chartTypeAppropriateness:t.z.number().min(0).max(1),readability:t.z.number().min(0).max(1),honesty:t.z.number().min(0).max(1),composite:t.z.number().min(0).max(1),rationale:t.z.string().optional()}),Re=t.z.object({capturedAt:t.z.string(),chartId:t.z.string()}),$e=t.z.object({response:t.z.object({message:t.z.string(),steps:t.z.array(t.z.string()),critiqueCommitted:t.z.boolean()}),critiqueReport:je.nullable(),chartVisionAudit:Re.nullable().optional().default(null),rubricScores:Ae.nullable().optional().default(null)}),Oe="/api/v0";exports.AggregationFunctionSchema=xe,exports.AggregationSuggestionSchema=ve,exports.AiChartTypeEnum=v,exports.ChartCritiqueIssueCategorySchema=Ee,exports.ChartCritiqueIssueSchema=Ce,exports.ChartCritiqueIssueSeveritySchema=Te,exports.ChartCritiqueReportSchema=je,exports.ChartFamilySchema=b,exports.ChartFitEntrySchema=fe,exports.ChartFitFactorKindSchema=ue,exports.ChartFitFactorSchema=ge,exports.ChartFitVerdictSchema=he,exports.ChartJudgeRubricSchema=_e,exports.DataObservationKindSchema=be,exports.DataObservationSchema=ze,exports.EvaluateParamsSchema=ye,exports.EvaluateResponseSchema=Se,exports.ExecutionModeSchema=p,exports.ExploreFindingSchema=T,exports.ExploreStorySchema=C,exports.ExtractAccuracyEvaluationSchema=I,exports.ExtractAttachmentInputSchema=ce,exports.ExtractAttachmentKindSchema=ie,exports.ExtractConfidenceSchema=D,exports.ExtractFromProseParamsSchema=me,exports.ExtractFromProseResponseSchema=le,exports.ExtractMetaSchema=M,exports.GenerateAnnotationsResponseSchema=A,exports.GenerateExplorationResponseSchema=j,exports.GenerateGraphResponseSchema=pe,exports.GenerateGraphSuggestionsResponseSchema=de,exports.GenerateMutationResponseSchema=R,exports.GenerateNarrativeParamsSchema=_,exports.GenerateNarrativeResponseSchema=w,exports.GeneratePipelineParamsSchema=k,exports.GeneratePipelineResponseSchema=P,exports.GenerateSuggestionsParamsSchema=x,exports.GenerateSuggestionsResponseSchema=E,exports.GraphGenerationRequestSchema=z,exports.GraphyAiSdk=class{constructor(e){this.client=new o(e)}generateGraph(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const{storytellingOptions:i}=t,n=e.__rest(t,["storytellingOptions"]),o=yield this.client.fetch(`${Oe}/generate`,n,r,a),s=pe.parse(o);return this.stripStorytelling(s,i)})}generateGraphStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){const{storytellingOptions:a}=t,i=e.__rest(t,["storytellingOptions"]),n=yield this.client.stream(`${Oe}/generate`,i,r);return this.wrapStreamWithStorytellingStripping(n,a)})}generateNarrative(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Oe}/narrate`,t,r,a);return w.parse(e)})}generateNarrativeStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${Oe}/narrate`,t,r)})}generateSuggestions(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Oe}/suggestions`,t,r,a);return E.parse(e)})}generateSuggestionsStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${Oe}/suggestions`,t,r)})}generateExploration(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Oe}/explore`,t,r,a);return j.parse(e)})}generateExplorationStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${Oe}/explore`,t,r)})}generateAnnotations(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Oe}/annotate`,t,r,a);return A.parse(e)})}generateAnnotationsStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${Oe}/annotate`,t,r)})}generateMutation(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Oe}/mutate`,t,r,a);return R.parse(e)})}generateMutationStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${Oe}/mutate`,t,r)})}generatePipeline(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Oe}/pipeline`,t,r,a);return P.parse(e)})}generatePipelineStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${Oe}/pipeline`,t,r)})}evaluate(t,r){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Oe}/evaluate`,t,void 0,r);return Se.parse(e)})}judge(t,r){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Oe}/judge`,t,void 0,r);return $e.parse(e)})}judgeStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${Oe}/judge`,t,r)})}extractFromProse(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Oe}/extract`,t,r,a);return le.parse(e)})}extractFromProseStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${Oe}/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,n,o,s;try{for(var c,m=!0,l=e.__asyncValues(t);!(a=(c=yield e.__await(l.next())).done);m=!0){s=c.value,m=!1;const t=s;if(i(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){n={error:e}}finally{try{m||a||!(o=l.return)||(yield e.__await(o.call(l)))}finally{if(n)throw n.error}}})}},exports.GraphyApiError=r,exports.InvocationBudgetSchema=g,exports.InvocationEffortSchema=m,exports.JudgeParamsSchema=we,exports.JudgeResponseSchema=$e,exports.MAX_BUDGET_COST_USD=10,exports.MAX_BUDGET_TOTAL_TOKENS=u,exports.MAX_BUDGET_WALL_CLOCK_MS=d,exports.MAX_EXTRACT_ATTACHMENTS=12,exports.MAX_EXTRACT_ATTACHMENTS_COMBINED_DECODED_BYTES=L,exports.MAX_EXTRACT_DOCUMENTS=2,exports.MAX_EXTRACT_DOCUMENTS_TOTAL_DECODED_BYTES=N,exports.MAX_EXTRACT_DOCUMENT_DECODED_BYTES=F,exports.MAX_EXTRACT_IMAGES=8,exports.MAX_EXTRACT_IMAGES_TOTAL_DECODED_BYTES=X,exports.MAX_EXTRACT_IMAGE_DECODED_BYTES=B,exports.MAX_EXTRACT_SPREADSHEETS=2,exports.MAX_EXTRACT_SPREADSHEETS_TOTAL_DECODED_BYTES=q,exports.MAX_EXTRACT_SPREADSHEET_DECODED_BYTES=U,exports.MAX_SOURCE_TEXT_LENGTH=G,exports.MAX_USER_PROMPT_LENGTH=y,exports.MetadataSchema=h,exports.MutateNarrationReceiptSchema=f,exports.PipelineAgentNameSchema=$,exports.PipelineStageReasoningSchema=O,exports.RubricScoresSchema=Ae,exports.StorytellingEffortSchema=l,exports.SuggestionSchema=S,exports.buildImageAttachment=function(e){return{kind:"image",mimeType:e.mimeType.trim(),dataBase64:ee(e.dataBase64)}},exports.buildPdfAttachment=function(e){return{kind:"document",mimeType:"application/pdf",dataBase64:ee(e.dataBase64)}},exports.buildSpreadsheetAttachment=function(e){return Object.assign({kind:"spreadsheet",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",dataBase64:ee(e.dataBase64)},void 0!==e.filename?{filename:e.filename.trim()}:{})},exports.isCompleteEvent=i,exports.isErrorEvent=n,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
@@ -338,10 +338,49 @@ declare const MetadataSchema: z.ZodObject<{
338
338
  agentic: "agentic";
339
339
  fast: "fast";
340
340
  }>>;
341
+ enforceTableRowCap: z.ZodOptional<z.ZodBoolean>;
341
342
  }, z.core.$strip>;
343
+ /** Provenance from a prior mutate invocation; forwarded to narrate/annotate. Kept in sync with agents-api. */
344
+ declare const MutateNarrationReceiptSchema: z.ZodObject<{
345
+ steps: z.ZodArray<z.ZodString>;
346
+ postProcess: z.ZodOptional<z.ZodObject<{
347
+ measureRelevance: z.ZodOptional<z.ZodEnum<{
348
+ "prompt-named": "prompt-named";
349
+ derived: "derived";
350
+ magnitude: "magnitude";
351
+ }>>;
352
+ grain: z.ZodOptional<z.ZodEnum<{
353
+ "remap-x": "remap-x";
354
+ groupBy: "groupBy";
355
+ reshape: "reshape";
356
+ compositeX: "compositeX";
357
+ }>>;
358
+ chartType: z.ZodOptional<z.ZodString>;
359
+ comparison: z.ZodOptional<z.ZodString>;
360
+ }, z.core.$strip>>;
361
+ droppedMeasures: z.ZodOptional<z.ZodArray<z.ZodString>>;
362
+ rowCount: z.ZodNumber;
363
+ totalRowCountBeforeSlice: z.ZodOptional<z.ZodNumber>;
364
+ displayedRowCount: z.ZodOptional<z.ZodNumber>;
365
+ columnKeys: z.ZodArray<z.ZodString>;
366
+ activeFilters: z.ZodOptional<z.ZodArray<z.ZodString>>;
367
+ grainSummary: z.ZodOptional<z.ZodString>;
368
+ }, z.core.$strip>;
369
+ type MutateNarrationReceipt = z.infer<typeof MutateNarrationReceiptSchema>;
342
370
  type Metadata = z.infer<typeof MetadataSchema>;
343
371
  /** Mirrors `MAX_USER_PROMPT_LENGTH` in the agents-api request schema. */
344
372
  declare const MAX_USER_PROMPT_LENGTH = 10000;
373
+ /**
374
+ * Abela chart family — classifies the question-shape a finding is answering. Downstream
375
+ * chart-generator picks the concrete chart type from this family + the data shape.
376
+ */
377
+ declare const ChartFamilySchema: z.ZodEnum<{
378
+ comparison: "comparison";
379
+ relationship: "relationship";
380
+ distribution: "distribution";
381
+ composition: "composition";
382
+ }>;
383
+ type ChartFamily = z.infer<typeof ChartFamilySchema>;
345
384
  /**
346
385
  * Shared request body for every agent endpoint (`/v0/generate`, `/v0/narrate`,
347
386
  * `/v0/explore`, `/v0/annotate`, etc.). Mirrors `GraphGenerationRequestSchema`
@@ -376,7 +415,14 @@ declare const GraphGenerationRequestSchema: z.ZodObject<{
376
415
  agentic: "agentic";
377
416
  fast: "fast";
378
417
  }>>;
418
+ enforceTableRowCap: z.ZodOptional<z.ZodBoolean>;
379
419
  }, z.core.$strip>>;
420
+ chartFamily: z.ZodOptional<z.ZodEnum<{
421
+ comparison: "comparison";
422
+ relationship: "relationship";
423
+ distribution: "distribution";
424
+ composition: "composition";
425
+ }>>;
380
426
  }, z.core.$strip>;
381
427
  type GraphGenerationRequest = z.input<typeof GraphGenerationRequestSchema>;
382
428
  /** Request body for `POST /v0/suggestions` only. `maxSuggestionCount` max must match agents-api `PROMPT_SUGGESTIONS_UPPER_BOUND`. */
@@ -409,7 +455,14 @@ declare const GenerateSuggestionsParamsSchema: z.ZodObject<{
409
455
  agentic: "agentic";
410
456
  fast: "fast";
411
457
  }>>;
458
+ enforceTableRowCap: z.ZodOptional<z.ZodBoolean>;
412
459
  }, z.core.$strip>>;
460
+ chartFamily: z.ZodOptional<z.ZodEnum<{
461
+ comparison: "comparison";
462
+ relationship: "relationship";
463
+ distribution: "distribution";
464
+ composition: "composition";
465
+ }>>;
413
466
  maxSuggestionCount: z.ZodOptional<z.ZodNumber>;
414
467
  }, z.core.$strip>;
415
468
  type GenerateSuggestionsParams = z.input<typeof GenerateSuggestionsParamsSchema>;
@@ -495,8 +548,41 @@ declare const GenerateNarrativeParamsSchema: z.ZodObject<{
495
548
  agentic: "agentic";
496
549
  fast: "fast";
497
550
  }>>;
551
+ enforceTableRowCap: z.ZodOptional<z.ZodBoolean>;
498
552
  }, z.core.$strip>>;
553
+ chartFamily: z.ZodOptional<z.ZodEnum<{
554
+ comparison: "comparison";
555
+ relationship: "relationship";
556
+ distribution: "distribution";
557
+ composition: "composition";
558
+ }>>;
499
559
  userPrompt: z.ZodString;
560
+ mutationReceipt: z.ZodOptional<z.ZodObject<{
561
+ steps: z.ZodArray<z.ZodString>;
562
+ postProcess: z.ZodOptional<z.ZodObject<{
563
+ measureRelevance: z.ZodOptional<z.ZodEnum<{
564
+ "prompt-named": "prompt-named";
565
+ derived: "derived";
566
+ magnitude: "magnitude";
567
+ }>>;
568
+ grain: z.ZodOptional<z.ZodEnum<{
569
+ "remap-x": "remap-x";
570
+ groupBy: "groupBy";
571
+ reshape: "reshape";
572
+ compositeX: "compositeX";
573
+ }>>;
574
+ chartType: z.ZodOptional<z.ZodString>;
575
+ comparison: z.ZodOptional<z.ZodString>;
576
+ }, z.core.$strip>>;
577
+ droppedMeasures: z.ZodOptional<z.ZodArray<z.ZodString>>;
578
+ rowCount: z.ZodNumber;
579
+ totalRowCountBeforeSlice: z.ZodOptional<z.ZodNumber>;
580
+ displayedRowCount: z.ZodOptional<z.ZodNumber>;
581
+ columnKeys: z.ZodArray<z.ZodString>;
582
+ activeFilters: z.ZodOptional<z.ZodArray<z.ZodString>>;
583
+ grainSummary: z.ZodOptional<z.ZodString>;
584
+ }, z.core.$strip>>;
585
+ exploreFindingSummary: z.ZodOptional<z.ZodString>;
500
586
  }, z.core.$strip>;
501
587
  type GenerateNarrativeParams = z.input<typeof GenerateNarrativeParamsSchema>;
502
588
  declare const GenerateNarrativeResponseSchema: z.ZodObject<{
@@ -536,17 +622,6 @@ declare const GenerateSuggestionsResponseSchema: z.ZodObject<{
536
622
  }, z.core.$strip>;
537
623
  type GenerateSuggestionsResponse = z.infer<typeof GenerateSuggestionsResponseSchema>;
538
624
  type GenerateExplorationParams = GraphGenerationRequest;
539
- /**
540
- * Abela chart family — classifies the question-shape a finding is answering. Downstream
541
- * chart-generator picks the concrete chart type from this family + the data shape.
542
- */
543
- declare const ChartFamilySchema: z.ZodEnum<{
544
- comparison: "comparison";
545
- relationship: "relationship";
546
- distribution: "distribution";
547
- composition: "composition";
548
- }>;
549
- type ChartFamily = z.infer<typeof ChartFamilySchema>;
550
625
  /** A single structured finding produced by the explore agent. */
551
626
  declare const ExploreFindingSchema: z.ZodObject<{
552
627
  finding: z.ZodString;
@@ -615,7 +690,70 @@ declare const GenerateExplorationResponseSchema: z.ZodObject<{
615
690
  }, z.core.$strip>>;
616
691
  }, z.core.$strip>;
617
692
  type GenerateExplorationResponse = z.infer<typeof GenerateExplorationResponseSchema>;
618
- type GenerateAnnotationsParams = GraphGenerationRequest;
693
+ declare const GenerateAnnotationsParamsSchema: z.ZodObject<{
694
+ config: z.ZodType<GraphConfig, unknown, z.core.$ZodTypeInternals<GraphConfig, unknown>>;
695
+ userPrompt: z.ZodDefault<z.ZodOptional<z.ZodString>>;
696
+ metadata: z.ZodOptional<z.ZodObject<{
697
+ callId: z.ZodOptional<z.ZodString>;
698
+ locale: z.ZodOptional<z.ZodEnum<{
699
+ EN_GB: "EN_GB";
700
+ EN_US: "EN_US";
701
+ }>>;
702
+ effort: z.ZodOptional<z.ZodEnum<{
703
+ low: "low";
704
+ medium: "medium";
705
+ high: "high";
706
+ }>>;
707
+ storytellingEffort: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
708
+ low: "low";
709
+ medium: "medium";
710
+ high: "high";
711
+ none: "none";
712
+ }>>>;
713
+ budget: z.ZodOptional<z.ZodObject<{
714
+ maxWallClockMs: z.ZodOptional<z.ZodNumber>;
715
+ maxTotalTokens: z.ZodOptional<z.ZodNumber>;
716
+ maxCostUsd: z.ZodOptional<z.ZodNumber>;
717
+ }, z.core.$strip>>;
718
+ executionMode: z.ZodOptional<z.ZodEnum<{
719
+ agentic: "agentic";
720
+ fast: "fast";
721
+ }>>;
722
+ enforceTableRowCap: z.ZodOptional<z.ZodBoolean>;
723
+ }, z.core.$strip>>;
724
+ chartFamily: z.ZodOptional<z.ZodEnum<{
725
+ comparison: "comparison";
726
+ relationship: "relationship";
727
+ distribution: "distribution";
728
+ composition: "composition";
729
+ }>>;
730
+ mutationReceipt: z.ZodOptional<z.ZodObject<{
731
+ steps: z.ZodArray<z.ZodString>;
732
+ postProcess: z.ZodOptional<z.ZodObject<{
733
+ measureRelevance: z.ZodOptional<z.ZodEnum<{
734
+ "prompt-named": "prompt-named";
735
+ derived: "derived";
736
+ magnitude: "magnitude";
737
+ }>>;
738
+ grain: z.ZodOptional<z.ZodEnum<{
739
+ "remap-x": "remap-x";
740
+ groupBy: "groupBy";
741
+ reshape: "reshape";
742
+ compositeX: "compositeX";
743
+ }>>;
744
+ chartType: z.ZodOptional<z.ZodString>;
745
+ comparison: z.ZodOptional<z.ZodString>;
746
+ }, z.core.$strip>>;
747
+ droppedMeasures: z.ZodOptional<z.ZodArray<z.ZodString>>;
748
+ rowCount: z.ZodNumber;
749
+ totalRowCountBeforeSlice: z.ZodOptional<z.ZodNumber>;
750
+ displayedRowCount: z.ZodOptional<z.ZodNumber>;
751
+ columnKeys: z.ZodArray<z.ZodString>;
752
+ activeFilters: z.ZodOptional<z.ZodArray<z.ZodString>>;
753
+ grainSummary: z.ZodOptional<z.ZodString>;
754
+ }, z.core.$strip>>;
755
+ }, z.core.$strip>;
756
+ type GenerateAnnotationsParams = z.input<typeof GenerateAnnotationsParamsSchema>;
619
757
  declare const GenerateAnnotationsResponseSchema: z.ZodObject<{
620
758
  response: z.ZodObject<{
621
759
  message: z.ZodString;
@@ -631,8 +769,164 @@ declare const GenerateMutationResponseSchema: z.ZodObject<{
631
769
  steps: z.ZodArray<z.ZodString>;
632
770
  }, z.core.$strip>;
633
771
  config: z.ZodType<GraphConfig, unknown, z.core.$ZodTypeInternals<GraphConfig, unknown>>;
772
+ mutationReceipt: z.ZodOptional<z.ZodObject<{
773
+ steps: z.ZodArray<z.ZodString>;
774
+ postProcess: z.ZodOptional<z.ZodObject<{
775
+ measureRelevance: z.ZodOptional<z.ZodEnum<{
776
+ "prompt-named": "prompt-named";
777
+ derived: "derived";
778
+ magnitude: "magnitude";
779
+ }>>;
780
+ grain: z.ZodOptional<z.ZodEnum<{
781
+ "remap-x": "remap-x";
782
+ groupBy: "groupBy";
783
+ reshape: "reshape";
784
+ compositeX: "compositeX";
785
+ }>>;
786
+ chartType: z.ZodOptional<z.ZodString>;
787
+ comparison: z.ZodOptional<z.ZodString>;
788
+ }, z.core.$strip>>;
789
+ droppedMeasures: z.ZodOptional<z.ZodArray<z.ZodString>>;
790
+ rowCount: z.ZodNumber;
791
+ totalRowCountBeforeSlice: z.ZodOptional<z.ZodNumber>;
792
+ displayedRowCount: z.ZodOptional<z.ZodNumber>;
793
+ columnKeys: z.ZodArray<z.ZodString>;
794
+ activeFilters: z.ZodOptional<z.ZodArray<z.ZodString>>;
795
+ grainSummary: z.ZodOptional<z.ZodString>;
796
+ }, z.core.$strip>>;
797
+ warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
634
798
  }, z.core.$strip>;
635
799
  type GenerateMutationResponse = z.infer<typeof GenerateMutationResponseSchema>;
800
+ declare const PipelineAgentNameSchema: z.ZodEnum<{
801
+ explore: "explore";
802
+ mutate: "mutate";
803
+ narrate: "narrate";
804
+ annotate: "annotate";
805
+ }>;
806
+ type PipelineAgentName = z.infer<typeof PipelineAgentNameSchema>;
807
+ declare const PipelineStageReasoningSchema: z.ZodObject<{
808
+ agent: z.ZodEnum<{
809
+ explore: "explore";
810
+ mutate: "mutate";
811
+ narrate: "narrate";
812
+ annotate: "annotate";
813
+ }>;
814
+ summary: z.ZodString;
815
+ steps: z.ZodOptional<z.ZodArray<z.ZodString>>;
816
+ }, z.core.$strip>;
817
+ type PipelineStageReasoning = z.infer<typeof PipelineStageReasoningSchema>;
818
+ /**
819
+ * Request body for `POST /v0/pipeline` — ordered agent stages on one shared server session.
820
+ */
821
+ declare const GeneratePipelineParamsSchema: z.ZodObject<{
822
+ config: z.ZodType<GraphConfig, unknown, z.core.$ZodTypeInternals<GraphConfig, unknown>>;
823
+ metadata: z.ZodOptional<z.ZodObject<{
824
+ callId: z.ZodOptional<z.ZodString>;
825
+ locale: z.ZodOptional<z.ZodEnum<{
826
+ EN_GB: "EN_GB";
827
+ EN_US: "EN_US";
828
+ }>>;
829
+ effort: z.ZodOptional<z.ZodEnum<{
830
+ low: "low";
831
+ medium: "medium";
832
+ high: "high";
833
+ }>>;
834
+ storytellingEffort: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
835
+ low: "low";
836
+ medium: "medium";
837
+ high: "high";
838
+ none: "none";
839
+ }>>>;
840
+ budget: z.ZodOptional<z.ZodObject<{
841
+ maxWallClockMs: z.ZodOptional<z.ZodNumber>;
842
+ maxTotalTokens: z.ZodOptional<z.ZodNumber>;
843
+ maxCostUsd: z.ZodOptional<z.ZodNumber>;
844
+ }, z.core.$strip>>;
845
+ executionMode: z.ZodOptional<z.ZodEnum<{
846
+ agentic: "agentic";
847
+ fast: "fast";
848
+ }>>;
849
+ enforceTableRowCap: z.ZodOptional<z.ZodBoolean>;
850
+ }, z.core.$strip>>;
851
+ chartFamily: z.ZodOptional<z.ZodEnum<{
852
+ comparison: "comparison";
853
+ relationship: "relationship";
854
+ distribution: "distribution";
855
+ composition: "composition";
856
+ }>>;
857
+ userPrompt: z.ZodString;
858
+ stages: z.ZodArray<z.ZodEnum<{
859
+ explore: "explore";
860
+ mutate: "mutate";
861
+ narrate: "narrate";
862
+ annotate: "annotate";
863
+ }>>;
864
+ exploreFindingSummary: z.ZodOptional<z.ZodString>;
865
+ }, z.core.$strip>;
866
+ type GeneratePipelineParams = z.input<typeof GeneratePipelineParamsSchema>;
867
+ declare const GeneratePipelineResponseSchema: z.ZodObject<{
868
+ response: z.ZodObject<{
869
+ message: z.ZodString;
870
+ steps: z.ZodArray<z.ZodString>;
871
+ }, z.core.$strip>;
872
+ config: z.ZodType<GraphConfig, unknown, z.core.$ZodTypeInternals<GraphConfig, unknown>>;
873
+ mutationReceipt: z.ZodOptional<z.ZodObject<{
874
+ steps: z.ZodArray<z.ZodString>;
875
+ postProcess: z.ZodOptional<z.ZodObject<{
876
+ measureRelevance: z.ZodOptional<z.ZodEnum<{
877
+ "prompt-named": "prompt-named";
878
+ derived: "derived";
879
+ magnitude: "magnitude";
880
+ }>>;
881
+ grain: z.ZodOptional<z.ZodEnum<{
882
+ "remap-x": "remap-x";
883
+ groupBy: "groupBy";
884
+ reshape: "reshape";
885
+ compositeX: "compositeX";
886
+ }>>;
887
+ chartType: z.ZodOptional<z.ZodString>;
888
+ comparison: z.ZodOptional<z.ZodString>;
889
+ }, z.core.$strip>>;
890
+ droppedMeasures: z.ZodOptional<z.ZodArray<z.ZodString>>;
891
+ rowCount: z.ZodNumber;
892
+ totalRowCountBeforeSlice: z.ZodOptional<z.ZodNumber>;
893
+ displayedRowCount: z.ZodOptional<z.ZodNumber>;
894
+ columnKeys: z.ZodArray<z.ZodString>;
895
+ activeFilters: z.ZodOptional<z.ZodArray<z.ZodString>>;
896
+ grainSummary: z.ZodOptional<z.ZodString>;
897
+ }, z.core.$strip>>;
898
+ warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
899
+ reasoning: z.ZodArray<z.ZodObject<{
900
+ agent: z.ZodEnum<{
901
+ explore: "explore";
902
+ mutate: "mutate";
903
+ narrate: "narrate";
904
+ annotate: "annotate";
905
+ }>;
906
+ summary: z.ZodString;
907
+ steps: z.ZodOptional<z.ZodArray<z.ZodString>>;
908
+ }, z.core.$strip>>;
909
+ stories: z.ZodOptional<z.ZodArray<z.ZodObject<{
910
+ topic: z.ZodString;
911
+ score: z.ZodNumber;
912
+ count: z.ZodNumber;
913
+ findings: z.ZodArray<z.ZodObject<{
914
+ finding: z.ZodString;
915
+ confidence: z.ZodNumber;
916
+ relevance: z.ZodNumber;
917
+ topic: z.ZodString;
918
+ chartHint: z.ZodString;
919
+ chartFamily: z.ZodEnum<{
920
+ comparison: "comparison";
921
+ relationship: "relationship";
922
+ distribution: "distribution";
923
+ composition: "composition";
924
+ }>;
925
+ evidenceSummary: z.ZodString;
926
+ }, z.core.$strip>>;
927
+ }, z.core.$strip>>>;
928
+ }, z.core.$strip>;
929
+ type GeneratePipelineResponse = z.infer<typeof GeneratePipelineResponseSchema>;
636
930
  /** Mirrors agents-api `extractConfidenceSchema`. */
637
931
  declare const ExtractConfidenceSchema: z.ZodEnum<{
638
932
  low: "low";
@@ -766,6 +1060,7 @@ declare const ExtractFromProseParamsSchema: z.ZodObject<{
766
1060
  agentic: "agentic";
767
1061
  fast: "fast";
768
1062
  }>>;
1063
+ enforceTableRowCap: z.ZodOptional<z.ZodBoolean>;
769
1064
  }, z.core.$strip>>;
770
1065
  }, z.core.$strip>;
771
1066
  type ExtractImageInput = z.infer<typeof extractImagePartSchema>;
@@ -991,6 +1286,7 @@ declare const EvaluateParamsSchema: z.ZodObject<{
991
1286
  agentic: "agentic";
992
1287
  fast: "fast";
993
1288
  }>>;
1289
+ enforceTableRowCap: z.ZodOptional<z.ZodBoolean>;
994
1290
  }, z.core.$strip>>;
995
1291
  }, z.core.$strip>;
996
1292
  type EvaluateParams = z.input<typeof EvaluateParamsSchema>;
@@ -1194,6 +1490,205 @@ declare const EvaluateResponseSchema: z.ZodObject<{
1194
1490
  }, z.core.$strip>>>>;
1195
1491
  }, z.core.$strip>;
1196
1492
  type EvaluateResponse = z.infer<typeof EvaluateResponseSchema>;
1493
+ /** Optional benchmark rubric. When present, the judge also returns {@link RubricScores}. */
1494
+ declare const ChartJudgeRubricSchema: z.ZodObject<{
1495
+ prompt: z.ZodString;
1496
+ datasetSummary: z.ZodOptional<z.ZodString>;
1497
+ mustShow: z.ZodOptional<z.ZodArray<z.ZodString>>;
1498
+ unacceptable: z.ZodOptional<z.ZodArray<z.ZodString>>;
1499
+ acceptableChartFamilies: z.ZodOptional<z.ZodArray<z.ZodString>>;
1500
+ }, z.core.$strip>;
1501
+ type ChartJudgeRubric = z.infer<typeof ChartJudgeRubricSchema>;
1502
+ /**
1503
+ * Request body for `POST /v0/judge`. The judge is config-optional: provide a `config`, a rendered
1504
+ * `chartImage` (URL or `data:` URL), or both, plus an optional `data` dataset for deterministic
1505
+ * profiling and an optional `rubric` to also receive a numeric scorecard. At least one of `config`
1506
+ * / `chartImage` must be supplied.
1507
+ */
1508
+ declare const JudgeParamsSchema: z.ZodObject<{
1509
+ config: z.ZodOptional<z.ZodType<GraphConfig, unknown, z.core.$ZodTypeInternals<GraphConfig, unknown>>>;
1510
+ chartImage: z.ZodOptional<z.ZodString>;
1511
+ data: z.ZodOptional<z.ZodUnknown>;
1512
+ rubric: z.ZodOptional<z.ZodObject<{
1513
+ prompt: z.ZodString;
1514
+ datasetSummary: z.ZodOptional<z.ZodString>;
1515
+ mustShow: z.ZodOptional<z.ZodArray<z.ZodString>>;
1516
+ unacceptable: z.ZodOptional<z.ZodArray<z.ZodString>>;
1517
+ acceptableChartFamilies: z.ZodOptional<z.ZodArray<z.ZodString>>;
1518
+ }, z.core.$strip>>;
1519
+ userPrompt: z.ZodOptional<z.ZodString>;
1520
+ metadata: z.ZodOptional<z.ZodObject<{
1521
+ callId: z.ZodOptional<z.ZodString>;
1522
+ locale: z.ZodOptional<z.ZodEnum<{
1523
+ EN_GB: "EN_GB";
1524
+ EN_US: "EN_US";
1525
+ }>>;
1526
+ effort: z.ZodOptional<z.ZodEnum<{
1527
+ low: "low";
1528
+ medium: "medium";
1529
+ high: "high";
1530
+ }>>;
1531
+ storytellingEffort: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
1532
+ low: "low";
1533
+ medium: "medium";
1534
+ high: "high";
1535
+ none: "none";
1536
+ }>>>;
1537
+ budget: z.ZodOptional<z.ZodObject<{
1538
+ maxWallClockMs: z.ZodOptional<z.ZodNumber>;
1539
+ maxTotalTokens: z.ZodOptional<z.ZodNumber>;
1540
+ maxCostUsd: z.ZodOptional<z.ZodNumber>;
1541
+ }, z.core.$strip>>;
1542
+ executionMode: z.ZodOptional<z.ZodEnum<{
1543
+ agentic: "agentic";
1544
+ fast: "fast";
1545
+ }>>;
1546
+ enforceTableRowCap: z.ZodOptional<z.ZodBoolean>;
1547
+ }, z.core.$strip>>;
1548
+ }, z.core.$strip>;
1549
+ type JudgeParams = z.input<typeof JudgeParamsSchema>;
1550
+ declare const ChartCritiqueIssueCategorySchema: z.ZodEnum<{
1551
+ layout: "layout";
1552
+ color_contrast: "color_contrast";
1553
+ typography: "typography";
1554
+ clutter: "clutter";
1555
+ encoding: "encoding";
1556
+ labels_legends: "labels_legends";
1557
+ title_caption: "title_caption";
1558
+ other: "other";
1559
+ }>;
1560
+ type ChartCritiqueIssueCategory = z.infer<typeof ChartCritiqueIssueCategorySchema>;
1561
+ declare const ChartCritiqueIssueSeveritySchema: z.ZodEnum<{
1562
+ low: "low";
1563
+ medium: "medium";
1564
+ high: "high";
1565
+ info: "info";
1566
+ }>;
1567
+ type ChartCritiqueIssueSeverity = z.infer<typeof ChartCritiqueIssueSeveritySchema>;
1568
+ declare const ChartCritiqueIssueSchema: z.ZodObject<{
1569
+ category: z.ZodEnum<{
1570
+ layout: "layout";
1571
+ color_contrast: "color_contrast";
1572
+ typography: "typography";
1573
+ clutter: "clutter";
1574
+ encoding: "encoding";
1575
+ labels_legends: "labels_legends";
1576
+ title_caption: "title_caption";
1577
+ other: "other";
1578
+ }>;
1579
+ severity: z.ZodEnum<{
1580
+ low: "low";
1581
+ medium: "medium";
1582
+ high: "high";
1583
+ info: "info";
1584
+ }>;
1585
+ observation: z.ZodString;
1586
+ rationale: z.ZodOptional<z.ZodString>;
1587
+ suggestedChange: z.ZodOptional<z.ZodString>;
1588
+ configPaths: z.ZodOptional<z.ZodArray<z.ZodString>>;
1589
+ }, z.core.$strip>;
1590
+ type ChartCritiqueIssue = z.infer<typeof ChartCritiqueIssueSchema>;
1591
+ declare const ChartCritiqueReportSchema: z.ZodObject<{
1592
+ overallSummary: z.ZodString;
1593
+ overallSeverity: z.ZodOptional<z.ZodEnum<{
1594
+ low: "low";
1595
+ medium: "medium";
1596
+ high: "high";
1597
+ none: "none";
1598
+ }>>;
1599
+ issues: z.ZodArray<z.ZodObject<{
1600
+ category: z.ZodEnum<{
1601
+ layout: "layout";
1602
+ color_contrast: "color_contrast";
1603
+ typography: "typography";
1604
+ clutter: "clutter";
1605
+ encoding: "encoding";
1606
+ labels_legends: "labels_legends";
1607
+ title_caption: "title_caption";
1608
+ other: "other";
1609
+ }>;
1610
+ severity: z.ZodEnum<{
1611
+ low: "low";
1612
+ medium: "medium";
1613
+ high: "high";
1614
+ info: "info";
1615
+ }>;
1616
+ observation: z.ZodString;
1617
+ rationale: z.ZodOptional<z.ZodString>;
1618
+ suggestedChange: z.ZodOptional<z.ZodString>;
1619
+ configPaths: z.ZodOptional<z.ZodArray<z.ZodString>>;
1620
+ }, z.core.$strip>>;
1621
+ }, z.core.$strip>;
1622
+ type ChartCritiqueReport = z.infer<typeof ChartCritiqueReportSchema>;
1623
+ /** Numeric scorecard, present only when a rubric was supplied. Each dimension is in `[0, 1]`. */
1624
+ declare const RubricScoresSchema: z.ZodObject<{
1625
+ dataFidelity: z.ZodNumber;
1626
+ promptRelevance: z.ZodNumber;
1627
+ chartTypeAppropriateness: z.ZodNumber;
1628
+ readability: z.ZodNumber;
1629
+ honesty: z.ZodNumber;
1630
+ composite: z.ZodNumber;
1631
+ rationale: z.ZodOptional<z.ZodString>;
1632
+ }, z.core.$strip>;
1633
+ type RubricScores = z.infer<typeof RubricScoresSchema>;
1634
+ /**
1635
+ * Response body for `POST /v0/judge`.
1636
+ *
1637
+ * `chartVisionAudit` and `rubricScores` are nullable-with-default so the SDK tolerates a server
1638
+ * that omits them (e.g. an older deployment) — consumers can treat them as `value | null`.
1639
+ */
1640
+ declare const JudgeResponseSchema: z.ZodObject<{
1641
+ response: z.ZodObject<{
1642
+ message: z.ZodString;
1643
+ steps: z.ZodArray<z.ZodString>;
1644
+ critiqueCommitted: z.ZodBoolean;
1645
+ }, z.core.$strip>;
1646
+ critiqueReport: z.ZodNullable<z.ZodObject<{
1647
+ overallSummary: z.ZodString;
1648
+ overallSeverity: z.ZodOptional<z.ZodEnum<{
1649
+ low: "low";
1650
+ medium: "medium";
1651
+ high: "high";
1652
+ none: "none";
1653
+ }>>;
1654
+ issues: z.ZodArray<z.ZodObject<{
1655
+ category: z.ZodEnum<{
1656
+ layout: "layout";
1657
+ color_contrast: "color_contrast";
1658
+ typography: "typography";
1659
+ clutter: "clutter";
1660
+ encoding: "encoding";
1661
+ labels_legends: "labels_legends";
1662
+ title_caption: "title_caption";
1663
+ other: "other";
1664
+ }>;
1665
+ severity: z.ZodEnum<{
1666
+ low: "low";
1667
+ medium: "medium";
1668
+ high: "high";
1669
+ info: "info";
1670
+ }>;
1671
+ observation: z.ZodString;
1672
+ rationale: z.ZodOptional<z.ZodString>;
1673
+ suggestedChange: z.ZodOptional<z.ZodString>;
1674
+ configPaths: z.ZodOptional<z.ZodArray<z.ZodString>>;
1675
+ }, z.core.$strip>>;
1676
+ }, z.core.$strip>>;
1677
+ chartVisionAudit: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodObject<{
1678
+ capturedAt: z.ZodString;
1679
+ chartId: z.ZodString;
1680
+ }, z.core.$strip>>>>;
1681
+ rubricScores: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodObject<{
1682
+ dataFidelity: z.ZodNumber;
1683
+ promptRelevance: z.ZodNumber;
1684
+ chartTypeAppropriateness: z.ZodNumber;
1685
+ readability: z.ZodNumber;
1686
+ honesty: z.ZodNumber;
1687
+ composite: z.ZodNumber;
1688
+ rationale: z.ZodOptional<z.ZodString>;
1689
+ }, z.core.$strip>>>>;
1690
+ }, z.core.$strip>;
1691
+ type JudgeResponse = z.infer<typeof JudgeResponseSchema>;
1197
1692
 
1198
1693
  /**
1199
1694
  * Client SDK for the Graphy AI Agents API.
@@ -1421,6 +1916,23 @@ declare class GraphyAiSdk {
1421
1916
  steps: string[];
1422
1917
  };
1423
1918
  config: _graphysdk_core_node.GraphConfig;
1919
+ mutationReceipt?: {
1920
+ steps: string[];
1921
+ rowCount: number;
1922
+ columnKeys: string[];
1923
+ postProcess?: {
1924
+ measureRelevance?: "prompt-named" | "derived" | "magnitude" | undefined;
1925
+ grain?: "remap-x" | "groupBy" | "reshape" | "compositeX" | undefined;
1926
+ chartType?: string | undefined;
1927
+ comparison?: string | undefined;
1928
+ } | undefined;
1929
+ droppedMeasures?: string[] | undefined;
1930
+ totalRowCountBeforeSlice?: number | undefined;
1931
+ displayedRowCount?: number | undefined;
1932
+ activeFilters?: string[] | undefined;
1933
+ grainSummary?: string | undefined;
1934
+ } | undefined;
1935
+ warnings?: string[] | undefined;
1424
1936
  }>;
1425
1937
  /**
1426
1938
  * Streams mutate agent events via SSE.
@@ -1436,6 +1948,113 @@ declare class GraphyAiSdk {
1436
1948
  steps: string[];
1437
1949
  };
1438
1950
  config: _graphysdk_core_node.GraphConfig;
1951
+ mutationReceipt?: {
1952
+ steps: string[];
1953
+ rowCount: number;
1954
+ columnKeys: string[];
1955
+ postProcess?: {
1956
+ measureRelevance?: "prompt-named" | "derived" | "magnitude" | undefined;
1957
+ grain?: "remap-x" | "groupBy" | "reshape" | "compositeX" | undefined;
1958
+ chartType?: string | undefined;
1959
+ comparison?: string | undefined;
1960
+ } | undefined;
1961
+ droppedMeasures?: string[] | undefined;
1962
+ totalRowCountBeforeSlice?: number | undefined;
1963
+ displayedRowCount?: number | undefined;
1964
+ activeFilters?: string[] | undefined;
1965
+ grainSummary?: string | undefined;
1966
+ } | undefined;
1967
+ warnings?: string[] | undefined;
1968
+ }>>>;
1969
+ /**
1970
+ * Runs an ordered agent pipeline (`POST /v0/pipeline`) on one shared server session.
1971
+ * Each stage receives accumulated reasoning from prior stages.
1972
+ */
1973
+ generatePipeline(data: GeneratePipelineParams, onProgress?: ProgressHandler, signal?: AbortSignal): Promise<{
1974
+ response: {
1975
+ message: string;
1976
+ steps: string[];
1977
+ };
1978
+ config: _graphysdk_core_node.GraphConfig;
1979
+ reasoning: {
1980
+ agent: "explore" | "mutate" | "narrate" | "annotate";
1981
+ summary: string;
1982
+ steps?: string[] | undefined;
1983
+ }[];
1984
+ mutationReceipt?: {
1985
+ steps: string[];
1986
+ rowCount: number;
1987
+ columnKeys: string[];
1988
+ postProcess?: {
1989
+ measureRelevance?: "prompt-named" | "derived" | "magnitude" | undefined;
1990
+ grain?: "remap-x" | "groupBy" | "reshape" | "compositeX" | undefined;
1991
+ chartType?: string | undefined;
1992
+ comparison?: string | undefined;
1993
+ } | undefined;
1994
+ droppedMeasures?: string[] | undefined;
1995
+ totalRowCountBeforeSlice?: number | undefined;
1996
+ displayedRowCount?: number | undefined;
1997
+ activeFilters?: string[] | undefined;
1998
+ grainSummary?: string | undefined;
1999
+ } | undefined;
2000
+ warnings?: string[] | undefined;
2001
+ stories?: {
2002
+ topic: string;
2003
+ score: number;
2004
+ count: number;
2005
+ findings: {
2006
+ finding: string;
2007
+ confidence: number;
2008
+ relevance: number;
2009
+ topic: string;
2010
+ chartHint: string;
2011
+ chartFamily: "comparison" | "relationship" | "distribution" | "composition";
2012
+ evidenceSummary: string;
2013
+ }[];
2014
+ }[] | undefined;
2015
+ }>;
2016
+ generatePipelineStream(data: GeneratePipelineParams, signal?: AbortSignal): Promise<AsyncIterableIterator<SSEEvent<{
2017
+ response: {
2018
+ message: string;
2019
+ steps: string[];
2020
+ };
2021
+ config: _graphysdk_core_node.GraphConfig;
2022
+ reasoning: {
2023
+ agent: "explore" | "mutate" | "narrate" | "annotate";
2024
+ summary: string;
2025
+ steps?: string[] | undefined;
2026
+ }[];
2027
+ mutationReceipt?: {
2028
+ steps: string[];
2029
+ rowCount: number;
2030
+ columnKeys: string[];
2031
+ postProcess?: {
2032
+ measureRelevance?: "prompt-named" | "derived" | "magnitude" | undefined;
2033
+ grain?: "remap-x" | "groupBy" | "reshape" | "compositeX" | undefined;
2034
+ chartType?: string | undefined;
2035
+ comparison?: string | undefined;
2036
+ } | undefined;
2037
+ droppedMeasures?: string[] | undefined;
2038
+ totalRowCountBeforeSlice?: number | undefined;
2039
+ displayedRowCount?: number | undefined;
2040
+ activeFilters?: string[] | undefined;
2041
+ grainSummary?: string | undefined;
2042
+ } | undefined;
2043
+ warnings?: string[] | undefined;
2044
+ stories?: {
2045
+ topic: string;
2046
+ score: number;
2047
+ count: number;
2048
+ findings: {
2049
+ finding: string;
2050
+ confidence: number;
2051
+ relevance: number;
2052
+ topic: string;
2053
+ chartHint: string;
2054
+ chartFamily: "comparison" | "relationship" | "distribution" | "composition";
2055
+ evidenceSummary: string;
2056
+ }[];
2057
+ }[] | undefined;
1439
2058
  }>>>;
1440
2059
  /**
1441
2060
  * Scores every supported chart type against the dataset in the provided `GraphConfig` and
@@ -1485,6 +2104,95 @@ declare class GraphyAiSdk {
1485
2104
  message: string;
1486
2105
  }[];
1487
2106
  }>;
2107
+ /**
2108
+ * Runs the chart judge on a chart and returns a structured critique. The judge is config-optional:
2109
+ * pass a `config`, a rendered `chartImage` (URL or `data:` URL), or both, plus an optional `data`
2110
+ * dataset for deterministic profiling. When a `rubric` is supplied, the response also carries a
2111
+ * numeric {@link RubricScores} scorecard — the single code path used by both product and benchmark.
2112
+ *
2113
+ * @remarks
2114
+ * - At least one of `config` / `chartImage` must be provided.
2115
+ * - Deterministic data-shape and (config-only) chart-type-fit issues are auto-seeded into
2116
+ * `critiqueReport.issues` in addition to the model's findings.
2117
+ * - Scoring is impartial: the model judges from the image + dataset, never from a config.
2118
+ *
2119
+ * @param data - Request body (`config?`, `chartImage?`, `data?`, `rubric?`, `userPrompt?`, metadata).
2120
+ * @param signal - Optional `AbortSignal` to cancel the request.
2121
+ * @returns The critique report, vision audit, and optional rubric scorecard.
2122
+ * @throws {GraphyApiError} When the API returns an error or the network request fails.
2123
+ */
2124
+ judge(data: JudgeParams, signal?: AbortSignal): Promise<{
2125
+ response: {
2126
+ message: string;
2127
+ steps: string[];
2128
+ critiqueCommitted: boolean;
2129
+ };
2130
+ critiqueReport: {
2131
+ overallSummary: string;
2132
+ issues: {
2133
+ category: "layout" | "color_contrast" | "typography" | "clutter" | "encoding" | "labels_legends" | "title_caption" | "other";
2134
+ severity: "low" | "medium" | "high" | "info";
2135
+ observation: string;
2136
+ rationale?: string | undefined;
2137
+ suggestedChange?: string | undefined;
2138
+ configPaths?: string[] | undefined;
2139
+ }[];
2140
+ overallSeverity?: "low" | "medium" | "high" | "none" | undefined;
2141
+ } | null;
2142
+ chartVisionAudit: {
2143
+ capturedAt: string;
2144
+ chartId: string;
2145
+ } | null;
2146
+ rubricScores: {
2147
+ dataFidelity: number;
2148
+ promptRelevance: number;
2149
+ chartTypeAppropriateness: number;
2150
+ readability: number;
2151
+ honesty: number;
2152
+ composite: number;
2153
+ rationale?: string | undefined;
2154
+ } | null;
2155
+ }>;
2156
+ /**
2157
+ * Streams chart-judge events via SSE. See {@link judge} for the request shape and semantics.
2158
+ *
2159
+ * @param data - Request body (`config?`, `chartImage?`, `data?`, `rubric?`, `userPrompt?`, metadata).
2160
+ * @param signal - Optional `AbortSignal` to cancel the request.
2161
+ * @returns An async iterator yielding {@link SSEEvent} objects.
2162
+ * @throws {GraphyApiError} When the API returns an error or the network request fails.
2163
+ */
2164
+ judgeStream(data: JudgeParams, signal?: AbortSignal): Promise<AsyncIterableIterator<SSEEvent<{
2165
+ response: {
2166
+ message: string;
2167
+ steps: string[];
2168
+ critiqueCommitted: boolean;
2169
+ };
2170
+ critiqueReport: {
2171
+ overallSummary: string;
2172
+ issues: {
2173
+ category: "layout" | "color_contrast" | "typography" | "clutter" | "encoding" | "labels_legends" | "title_caption" | "other";
2174
+ severity: "low" | "medium" | "high" | "info";
2175
+ observation: string;
2176
+ rationale?: string | undefined;
2177
+ suggestedChange?: string | undefined;
2178
+ configPaths?: string[] | undefined;
2179
+ }[];
2180
+ overallSeverity?: "low" | "medium" | "high" | "none" | undefined;
2181
+ } | null;
2182
+ chartVisionAudit: {
2183
+ capturedAt: string;
2184
+ chartId: string;
2185
+ } | null;
2186
+ rubricScores: {
2187
+ dataFidelity: number;
2188
+ promptRelevance: number;
2189
+ chartTypeAppropriateness: number;
2190
+ readability: number;
2191
+ honesty: number;
2192
+ composite: number;
2193
+ rationale?: string | undefined;
2194
+ } | null;
2195
+ }>>>;
1488
2196
  /**
1489
2197
  * Runs the extract agent to build a chart-ready dataset from unstructured prose, images, and/or PDFs.
1490
2198
  *
@@ -1560,5 +2268,5 @@ declare class GraphyAiSdk {
1560
2268
  private wrapStreamWithStorytellingStripping;
1561
2269
  }
1562
2270
 
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 };
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 };
2271
+ export { AggregationFunctionSchema, AggregationSuggestionSchema, AiChartTypeEnum, ChartCritiqueIssueCategorySchema, ChartCritiqueIssueSchema, ChartCritiqueIssueSeveritySchema, ChartCritiqueReportSchema, ChartFamilySchema, ChartFitEntrySchema, ChartFitFactorKindSchema, ChartFitFactorSchema, ChartFitVerdictSchema, ChartJudgeRubricSchema, DataObservationKindSchema, DataObservationSchema, EvaluateParamsSchema, EvaluateResponseSchema, ExecutionModeSchema, ExploreFindingSchema, ExploreStorySchema, ExtractAccuracyEvaluationSchema, ExtractAttachmentInputSchema, ExtractAttachmentKindSchema, ExtractConfidenceSchema, ExtractFromProseParamsSchema, ExtractFromProseResponseSchema, ExtractMetaSchema, GenerateAnnotationsResponseSchema, GenerateExplorationResponseSchema, GenerateGraphResponseSchema, GenerateGraphSuggestionsResponseSchema, GenerateMutationResponseSchema, GenerateNarrativeParamsSchema, GenerateNarrativeResponseSchema, GeneratePipelineParamsSchema, GeneratePipelineResponseSchema, GenerateSuggestionsParamsSchema, GenerateSuggestionsResponseSchema, GraphGenerationRequestSchema, GraphyAiSdk, GraphyApiError, InvocationBudgetSchema, InvocationEffortSchema, JudgeParamsSchema, JudgeResponseSchema, 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, MutateNarrationReceiptSchema, PipelineAgentNameSchema, PipelineStageReasoningSchema, RubricScoresSchema, StorytellingEffortSchema, SuggestionSchema, buildImageAttachment, buildPdfAttachment, buildSpreadsheetAttachment, isCompleteEvent, isErrorEvent, isGraphyApiError, isPreviewEvent, isProgressEvent, isReasoningEvent };
2272
+ export type { AggregationFunction, AggregationSuggestion, AiChartType, ChartCritiqueIssue, ChartCritiqueIssueCategory, ChartCritiqueIssueSeverity, ChartCritiqueReport, ChartFamily, ChartFitEntry, ChartFitFactor, ChartFitFactorKind, ChartFitVerdict, ChartJudgeRubric, 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, GeneratePipelineParams, GeneratePipelineResponse, GenerateSuggestionsParams, GenerateSuggestionsResponse, GraphGenerationRequest, GraphyApiErrorOptions, InvocationBudget, InvocationEffort, JudgeParams, JudgeResponse, Logger, Metadata, MutateNarrationReceipt, PipelineAgentName, PipelineStageReasoning, PreviewEvent, ProgressEvent, ProgressHandler, ReasoningEvent, RetryConfig, RubricScores, 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=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};
1
+ import{__awaiter as e,__asyncValues as t,__asyncGenerator as i,__await as n,__rest as r}from"tslib";import{z as a}from"zod";class o 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 s=e=>e instanceof o,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,a){return e(this,void 0,void 0,function*(){var e,s,d,u,g;const p=Date.now();this.logger.debug(`${this.tag} Fetch: ${i}`);try{const b=yield this.makeRequest(i,n,a),v=b.headers.get("content-type");if(null==v?void 0:v.includes("text/event-stream")){try{for(var h,f=!0,y=t(this.parseSSE(b));!(e=(h=yield y.next()).done);f=!0){u=h.value,f=!1;const e=u;if(c(e)&&r&&r(e),l(e))return e.data;if(m(e)){const t=Date.now()-p;throw this.logger.error(`${this.tag} Server error: ${i} ${t}ms`,e.error),new o(e.error,{code:e.code,retryable:null!==(g=e.retryable)&&void 0!==g&&g})}}}catch(e){s={error:e}}finally{try{f||e||!(d=y.return)||(yield d.call(y))}finally{if(s)throw s.error}}const n=Date.now()-p;throw this.logger.error(`${this.tag} Stream incomplete: ${i} ${n}ms`),new o("Stream ended without completion")}return yield b.json()}catch(e){const t=Date.now()-p;if(this.logger.error(`${this.tag} Fetch failed: ${i} ${t}ms`,e),e instanceof o)throw e;throw e}finally{const e=Date.now()-p;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 o("Response body is null");const t=e.body.getReader(),i=new TextDecoder;let r="",a="",s="";try{for(;;){const{done:e,value:o}=yield n(t.read());if(e)break;r+=i.decode(o,{stream:!0});const c=r.split(/\r?\n/);r=c.pop()||"";for(const e of c)if(e.startsWith("event: "))a=e.slice(7).trim();else if(e.startsWith("data: "))s+=(s?"\n":"")+e.slice(6);else if(""===e.trim()&&s){try{const e=JSON.parse(s);let t;if("progress"===a){const i=e;t=Object.assign({type:"progress"},i)}else if("complete"===a)t={type:"complete",data:e};else if("error"===a){const i=e;t=Object.assign({type:"error"},i)}else if("preview"===a){const i=e;t=Object.assign(Object.assign({},i),{type:"preview"})}else{if("reasoning"!==a){a="",s="";continue}{const i=e;t=Object.assign(Object.assign({},i),{type:"reasoning"})}}if(yield yield n(t),"complete"===a||"error"===a)return yield n(void 0)}catch(e){this.logger.warn("Invalid SSE data format",s)}a="",s=""}}}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 o("Invalid endpoint: must start with /");const a=new URL(e,this.baseUrl);if(a.origin!==new URL(this.baseUrl).origin)throw new o("Endpoint resolved to unexpected origin");this.logger.debug(`${this.tag} Request ${n}/${this.retryConfig.attempts}: ${a}`);const s=new AbortController,c=setTimeout(()=>s.abort(),this.timeout),l=()=>s.abort();i&&i.addEventListener("abort",l);try{const c=yield fetch(a,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:s.signal},"POST"===r&&{body:JSON.stringify(t)}));if(!c.ok){const a=c.status>=500||429===c.status;let s,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&&(s=t.code)}}catch(e){}const m=new o(l,{status:c.status,code:s,retryable:a});if(a&&n<this.retryConfig.attempts&&!(null==i?void 0:i.aborted)){const a=this.retryConfig.delay*Math.pow(this.retryConfig.backoff,n-1);return this.logger.warn(`${this.tag} Retrying ${e} in ${a}ms (attempt ${n+1})`),yield this.sleep(a),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(a){if(a instanceof o)throw a;if(a instanceof Error&&"AbortError"===a.name)throw this.logger.debug(`${this.tag} Aborted: ${e}`),a;if(n<this.retryConfig.attempts&&!(null==i?void 0:i.aborted)){const a=this.retryConfig.delay*Math.pow(this.retryConfig.backoff,n-1);return this.logger.warn(`${this.tag} Network error, retrying ${e} in ${a}ms`),yield this.sleep(a),this.makeRequest(e,t,i,n+1,r)}throw this.logger.error(`${this.tag} Network error: ${e}`,a),new o("Network error",{retryable:!0})}finally{clearTimeout(c),i&&i.removeEventListener("abort",l)}})}}const p=a.enum(["EN_GB","EN_US"]),h=a.custom(e=>null!=e&&"object"==typeof e),f=a.enum(["low","medium","high"]),y=a.enum(["none","low","medium","high"]),b=a.enum(["agentic","fast"]),v=3e5,w=5e5,x=10,j=a.object({maxWallClockMs:a.number().positive().max(v).optional(),maxTotalTokens:a.number().int().positive().max(w).optional(),maxCostUsd:a.number().positive().max(10).optional()}),$=a.object({callId:a.string().max(256).optional(),locale:p.optional(),effort:f.optional(),storytellingEffort:y.optional().default("low"),budget:j.optional(),executionMode:b.optional(),enforceTableRowCap:a.boolean().optional()}),S=a.object({steps:a.array(a.string()),postProcess:a.object({measureRelevance:a.enum(["prompt-named","derived","magnitude"]).optional(),grain:a.enum(["remap-x","groupBy","reshape","compositeX"]).optional(),chartType:a.string().optional(),comparison:a.string().optional()}).optional(),droppedMeasures:a.array(a.string()).optional(),rowCount:a.number().int().nonnegative(),totalRowCountBeforeSlice:a.number().int().positive().optional(),displayedRowCount:a.number().int().nonnegative().optional(),columnKeys:a.array(a.string()),activeFilters:a.array(a.string()).optional(),grainSummary:a.string().optional()}),k=1e4,C=a.enum(["comparison","relationship","distribution","composition"]),T=a.object({config:h,userPrompt:a.string().max(k).optional().default(""),metadata:$.optional(),chartFamily:C.optional()}),O=T.extend({maxSuggestionCount:a.number().int().min(1).max(4).optional()}),R=a.enum(["line","areaStacked","bar","groupedBar","stackedBar","100StackedBar","column","groupedColumn","stackedColumn","100StackedColumn","combo","pie","donut","funnel","heatmap","scatter","bubble","waterfall","table","mekko"]),P=a.object({dataPrepPrompt:a.string(),chartType:R,summary:a.string()}),I=T.extend({userPrompt:a.string().max(k),mutationReceipt:S.optional(),exploreFindingSummary:a.string().max(500).optional()}),E=a.object({response:a.object({message:a.string()}),config:h}),A=a.object({suggestions:a.array(P)}),B=a.object({finding:a.string().describe("Plain-English summary of the finding (no stats jargon)."),confidence:a.number().min(0).max(1).describe("Statistical strength of the finding (0..1). Independent of topicality."),relevance:a.number().min(0).max(1).describe("Topical fit with the user prompt and chart narrative (0..1). Independent of statistical strength."),topic:a.string().min(1).describe("Kebab-case label grouping this finding with related ones; consumers can render findings as threads."),chartHint:a.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:C.describe("Abela family (comparison | relationship | distribution | composition). Downstream chart-generator picks the concrete chart type from this family + the data shape."),evidenceSummary:a.string().max(300).describe("Rigorous statistical back-up with exact numbers.")}),F=a.object({topic:a.string().min(1).describe("Kebab-case story headline shared by all child findings."),score:a.number().min(0).max(1).describe("Max quadrant score (relevance × confidence) across child findings."),count:a.number().int().min(1).describe("Number of findings in this story."),findings:a.array(B).describe("Child findings, sorted by quadrant score desc.")}),q=a.object({response:a.object({message:a.string(),steps:a.array(a.string())}),stories:a.array(F)});T.extend({mutationReceipt:S.optional()});const U=a.object({response:a.object({message:a.string(),steps:a.array(a.string())}),config:h}),N=a.object({response:a.object({message:a.string(),steps:a.array(a.string())}),config:h,mutationReceipt:S.optional(),warnings:a.array(a.string()).optional()}),D=a.enum(["explore","mutate","narrate","annotate"]),K=a.object({agent:D,summary:a.string(),steps:a.array(a.string()).optional()}),M=T.extend({userPrompt:a.string().max(k),stages:a.array(D).min(1).refine(e=>new Set(e).size===e.length,{message:"Duplicate pipeline stages are not allowed"}),exploreFindingSummary:a.string().max(500).optional()}),L=N.extend({reasoning:a.array(K),stories:a.array(F).optional()}),G=a.enum(["high","medium","low"]),W=a.object({confidence:G,needsUserInput:a.boolean(),warnings:a.array(a.string()),cellConfidence:a.array(a.object({rowIndex:a.number().int().nonnegative(),columnKey:a.string(),confidence:G,quote:a.string().optional()})).optional()}),_=a.object({score:a.number().min(0).max(1),issues:a.array(a.string()),sufficient:a.boolean(),summary:a.string()}),z=5e5,H=8,J=2097152,V=7340032,X=2,Y=6291456,Z=8388608,Q=2,ee=Y,te=Z,ie=12582912,ne=12;function re(e){return 4*Math.ceil(e/3)}const ae=re(J),oe=re(V),se=re(Y),ce=re(Z),le=re(ee),me=re(te),de=re(ie);function ue(e){return e.replace(/\s+/g,"")}function ge(e){const t=ue(e);return 0!==t.length&&t.length%4==0&&/^[A-Za-z0-9+/]+={0,2}$/.test(t)}const pe=/^image\/(png|jpeg|jpg|webp|gif)$/i,he=a.object({mimeType:a.string().min(1).refine(e=>pe.test(e.trim()),{message:"mimeType must be image/png, image/jpeg, image/jpg, image/webp, or image/gif"}),dataBase64:a.string().min(1).max(ae).refine(ge,{message:"dataBase64 must be standard base64 (RFC 4648)"})}),fe=a.enum(["image","document","spreadsheet"]),ye=he.extend({kind:a.literal("image")}),be=a.object({kind:a.literal("document"),mimeType:a.string().min(1).refine(e=>/^application\/pdf$/i.test(e.trim()),{message:"document mimeType must be application/pdf"}),dataBase64:a.string().min(1).max(se).refine(ge,{message:"dataBase64 must be standard base64 (RFC 4648)"})}),ve=a.object({kind:a.literal("spreadsheet"),mimeType:a.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:a.string().min(1).max(le).refine(ge,{message:"dataBase64 must be standard base64 (RFC 4648)"}),filename:a.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"]}),we=a.discriminatedUnion("kind",[ye,be,ve]),xe=a.object({sourceText:a.string().max(z).default(""),images:a.array(he).max(8).optional().describe('@deprecated Use attachments[] with kind: "image" instead. Will be removed in a future major release.'),attachments:a.array(we).max(12).optional(),metadata:$.optional()}).superRefine((e,t)=>{var i,n;const r=e.sourceText.trim(),a=null!==(i=e.images)&&void 0!==i?i:[],o=null!==(n=e.attachments)&&void 0!==n?n:[];if(a.length>0&&o.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===a.length&&0===o.length)return void t.addIssue({code:"custom",message:"Provide non-empty sourceText and/or at least one attachment",path:["sourceText"]});if(a.length>0){a.reduce((e,t)=>e+ue(t.dataBase64).length,0)>oe&&t.addIssue({code:"custom",message:"Combined image base64 exceeds maximum length for this API (must fit server decode limits)",path:["images"]})}let s=0,c=0,l=0,m=0,d=0,u=0,g=0;for(const e of o){const t=ue(e.dataBase64).length;switch(g+=t,e.kind){case"image":s+=1,m+=t;break;case"document":c+=1,d+=t;break;case"spreadsheet":l+=1,u+=t}}s>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 p=s<=8&&c<=2&&l<=2;o.length>0&&p&&(m>oe&&t.addIssue({code:"custom",message:"Combined image base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),d>ce&&t.addIssue({code:"custom",message:"Combined document base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),u>me&&t.addIssue({code:"custom",message:"Combined spreadsheet base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),g>de&&t.addIssue({code:"custom",message:"Combined attachment base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}))});function je(e){return{kind:"image",mimeType:e.mimeType.trim(),dataBase64:ue(e.dataBase64)}}function $e(e){return{kind:"document",mimeType:"application/pdf",dataBase64:ue(e.dataBase64)}}function Se(e){return Object.assign({kind:"spreadsheet",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",dataBase64:ue(e.dataBase64)},void 0!==e.filename?{filename:e.filename.trim()}:{})}const ke=a.object({response:a.object({message:a.string()}),config:h,extractMeta:W.nullable(),lastAccuracyEvaluation:_.optional()}),Ce=a.object({config:h,response:a.object({message:a.string(),steps:a.array(a.string())})}),Te=A,Oe=a.enum(["deal-breaker","pro","con","family","continuity"]),Re=a.object({kind:Oe,label:a.string(),weight:a.number(),reason:a.string()}),Pe=a.enum(["ok","disqualified"]),Ie=a.object({rank:a.number().int().positive(),type:R,score:a.number(),verdict:Pe,factors:a.array(Re)}),Ee=a.object({config:h,chartFamily:C.optional(),metadata:$.optional()}),Ae=a.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"]),Be=a.object({kind:Ae,message:a.string()}),Fe=a.enum(["sum","avg","count","min","max"]),qe=a.object({dimensionName:a.string(),dimensionLabel:a.string(),measureName:a.string().nullable(),measureLabel:a.string().nullable(),fn:Fe,chartType:R,score:a.number(),message:a.string()}),Ue=a.object({ranking:a.array(Ie),observations:a.array(Be).optional().default([]),suggestions:a.array(qe).optional().default([])}),Ne=a.object({prompt:a.string(),datasetSummary:a.string().optional(),mustShow:a.array(a.string()).optional(),unacceptable:a.array(a.string()).optional(),acceptableChartFamilies:a.array(a.string()).optional()}),De=a.object({config:h.optional(),chartImage:a.string().optional(),data:a.unknown().optional(),rubric:Ne.optional(),userPrompt:a.string().optional(),metadata:$.optional()}).refine(e=>void 0!==e.config||void 0!==e.chartImage,{message:"Provide a chart config or a chart image to judge."}),Ke=a.enum(["layout","color_contrast","typography","clutter","encoding","labels_legends","title_caption","other"]),Me=a.enum(["info","low","medium","high"]),Le=a.object({category:Ke,severity:Me,observation:a.string(),rationale:a.string().optional(),suggestedChange:a.string().optional(),configPaths:a.array(a.string()).optional()}),Ge=a.object({overallSummary:a.string(),overallSeverity:a.enum(["none","low","medium","high"]).optional(),issues:a.array(Le)}),We=a.object({dataFidelity:a.number().min(0).max(1),promptRelevance:a.number().min(0).max(1),chartTypeAppropriateness:a.number().min(0).max(1),readability:a.number().min(0).max(1),honesty:a.number().min(0).max(1),composite:a.number().min(0).max(1),rationale:a.string().optional()}),_e=a.object({capturedAt:a.string(),chartId:a.string()}),ze=a.object({response:a.object({message:a.string(),steps:a.array(a.string()),critiqueCommitted:a.boolean()}),critiqueReport:Ge.nullable(),chartVisionAudit:_e.nullable().optional().default(null),rubricScores:We.nullable().optional().default(null)}),He="/api/v0";class Je{constructor(e){this.client=new g(e)}generateGraph(t,i,n){return e(this,void 0,void 0,function*(){const{storytellingOptions:e}=t,a=r(t,["storytellingOptions"]),o=yield this.client.fetch(`${He}/generate`,a,i,n),s=Ce.parse(o);return this.stripStorytelling(s,e)})}generateGraphStream(t,i){return e(this,void 0,void 0,function*(){const{storytellingOptions:e}=t,n=r(t,["storytellingOptions"]),a=yield this.client.stream(`${He}/generate`,n,i);return this.wrapStreamWithStorytellingStripping(a,e)})}generateNarrative(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${He}/narrate`,t,i,n);return E.parse(e)})}generateNarrativeStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${He}/narrate`,t,i)})}generateSuggestions(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${He}/suggestions`,t,i,n);return A.parse(e)})}generateSuggestionsStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${He}/suggestions`,t,i)})}generateExploration(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${He}/explore`,t,i,n);return q.parse(e)})}generateExplorationStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${He}/explore`,t,i)})}generateAnnotations(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${He}/annotate`,t,i,n);return U.parse(e)})}generateAnnotationsStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${He}/annotate`,t,i)})}generateMutation(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${He}/mutate`,t,i,n);return N.parse(e)})}generateMutationStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${He}/mutate`,t,i)})}generatePipeline(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${He}/pipeline`,t,i,n);return L.parse(e)})}generatePipelineStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${He}/pipeline`,t,i)})}evaluate(t,i){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${He}/evaluate`,t,void 0,i);return Ue.parse(e)})}judge(t,i){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${He}/judge`,t,void 0,i);return ze.parse(e)})}judgeStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${He}/judge`,t,i)})}extractFromProse(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${He}/extract`,t,i,n);return ke.parse(e)})}extractFromProseStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${He}/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,a,o,s;try{for(var c,m=!0,d=t(e);!(i=(c=yield n(d.next())).done);m=!0){s=c.value,m=!1;const e=s;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){a={error:e}}finally{try{m||i||!(o=d.return)||(yield n(o.call(d)))}finally{if(a)throw a.error}}})}}export{Fe as AggregationFunctionSchema,qe as AggregationSuggestionSchema,R as AiChartTypeEnum,Ke as ChartCritiqueIssueCategorySchema,Le as ChartCritiqueIssueSchema,Me as ChartCritiqueIssueSeveritySchema,Ge as ChartCritiqueReportSchema,C as ChartFamilySchema,Ie as ChartFitEntrySchema,Oe as ChartFitFactorKindSchema,Re as ChartFitFactorSchema,Pe as ChartFitVerdictSchema,Ne as ChartJudgeRubricSchema,Ae as DataObservationKindSchema,Be as DataObservationSchema,Ee as EvaluateParamsSchema,Ue as EvaluateResponseSchema,b as ExecutionModeSchema,B as ExploreFindingSchema,F as ExploreStorySchema,_ as ExtractAccuracyEvaluationSchema,we as ExtractAttachmentInputSchema,fe as ExtractAttachmentKindSchema,G as ExtractConfidenceSchema,xe as ExtractFromProseParamsSchema,ke as ExtractFromProseResponseSchema,W as ExtractMetaSchema,U as GenerateAnnotationsResponseSchema,q as GenerateExplorationResponseSchema,Ce as GenerateGraphResponseSchema,Te as GenerateGraphSuggestionsResponseSchema,N as GenerateMutationResponseSchema,I as GenerateNarrativeParamsSchema,E as GenerateNarrativeResponseSchema,M as GeneratePipelineParamsSchema,L as GeneratePipelineResponseSchema,O as GenerateSuggestionsParamsSchema,A as GenerateSuggestionsResponseSchema,T as GraphGenerationRequestSchema,Je as GraphyAiSdk,o as GraphyApiError,j as InvocationBudgetSchema,f as InvocationEffortSchema,De as JudgeParamsSchema,ze as JudgeResponseSchema,x as MAX_BUDGET_COST_USD,w as MAX_BUDGET_TOTAL_TOKENS,v as MAX_BUDGET_WALL_CLOCK_MS,ne as MAX_EXTRACT_ATTACHMENTS,ie as MAX_EXTRACT_ATTACHMENTS_COMBINED_DECODED_BYTES,X as MAX_EXTRACT_DOCUMENTS,Z as MAX_EXTRACT_DOCUMENTS_TOTAL_DECODED_BYTES,Y as MAX_EXTRACT_DOCUMENT_DECODED_BYTES,H as MAX_EXTRACT_IMAGES,V as MAX_EXTRACT_IMAGES_TOTAL_DECODED_BYTES,J as MAX_EXTRACT_IMAGE_DECODED_BYTES,Q as MAX_EXTRACT_SPREADSHEETS,te as MAX_EXTRACT_SPREADSHEETS_TOTAL_DECODED_BYTES,ee as MAX_EXTRACT_SPREADSHEET_DECODED_BYTES,z as MAX_SOURCE_TEXT_LENGTH,k as MAX_USER_PROMPT_LENGTH,$ as MetadataSchema,S as MutateNarrationReceiptSchema,D as PipelineAgentNameSchema,K as PipelineStageReasoningSchema,We as RubricScoresSchema,y as StorytellingEffortSchema,P as SuggestionSchema,je as buildImageAttachment,$e as buildPdfAttachment,Se as buildSpreadsheetAttachment,l as isCompleteEvent,m as isErrorEvent,s 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.1-beta.1780051364996",
4
+ "version": "1.6.0-beta.1780415323009",
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.1-beta.1780051364996"
21
+ "@graphysdk/core": "1.6.0-beta.1780415323009"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@rollup/plugin-commonjs": "^28.0.6",