@graphysdk/agents-sdk 1.6.1 → 1.6.2-beta.1782148741262
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 +1 -1
- package/dist/index.d.ts +303 -2
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
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,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 l,m,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));!(l=(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){m={error:e}}finally{try{f||l||!(p=y.return)||(yield p.call(y))}finally{if(m)throw m.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}}})}uploadMultipart(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.makeMultipartRequest(t,r,a);return yield e.json()})}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),l=()=>s.abort();a&&a.addEventListener("abort",l);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){let o,s=`HTTP ${c.status}`;try{const e=yield c.json();if("object"==typeof e&&null!==e){const t=e;"string"==typeof t.message?s=t.message:"string"==typeof t.error&&(s=t.error),"string"==typeof t.code&&(o=t.code)}}catch(e){}const l=!("QUOTA_EXCEEDED"===o)&&(c.status>=500||429===c.status),m=new r(s,{status:c.status,code:o,retryable:l});if(l&&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}) - ${s}`),m}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",l)}})}makeMultipartRequest(t,a,i){return e.__awaiter(this,arguments,void 0,function*(e,t,a,i=1){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");const o=new AbortController,s=setTimeout(()=>o.abort(),this.timeout),c=()=>o.abort();a&&a.addEventListener("abort",c);try{const s=yield fetch(n,{method:"POST",headers:{Accept:"application/json",Authorization:`Bearer ${this.apiKey}`,"User-Agent":"Graphy-SDK/1.0"},body:t,signal:o.signal});if(!s.ok){let n,o=`HTTP ${s.status}`;try{const e=yield s.json();if("object"==typeof e&&null!==e){const t=e;"string"==typeof t.message?o=t.message:"string"==typeof t.error&&(o=t.error),"string"==typeof t.code&&(n=t.code)}}catch(e){}const c=s.status>=500||429===s.status,l=new r(o,{status:s.status,code:n,retryable:c});if(c&&i<this.retryConfig.attempts&&!(null==a?void 0:a.aborted)){const r=this.retryConfig.delay*Math.pow(this.retryConfig.backoff,i-1);return yield this.sleep(r),this.makeMultipartRequest(e,t,a,i+1)}throw l}return s}catch(n){if(n instanceof r)throw n;if(n instanceof Error&&"AbortError"===n.name)throw n;if(i<this.retryConfig.attempts&&!(null==a?void 0:a.aborted)){const r=this.retryConfig.delay*Math.pow(this.retryConfig.backoff,i-1);return yield this.sleep(r),this.makeMultipartRequest(e,t,a,i+1)}throw new r("Network error",{retryable:!0})}finally{clearTimeout(s),a&&a.removeEventListener("abort",c)}})}}const s=t.z.enum(["EN_GB","EN_US"]),c=t.z.custom(e=>null!=e&&"object"==typeof e),l=t.z.enum(["low","medium","high"]),m=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:l.optional(),storytellingEffort:m.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()}),w=z.extend({userPrompt:t.z.string().max(y),mutationReceipt:f.optional(),exploreFindingSummary:t.z.string().max(500).optional()}),_=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.")}),A=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 j=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"]),k=t.z.object({agent:$,summary:t.z.string(),steps:t.z.array(t.z.string()).optional()}),O=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()}),M=R.extend({reasoning:t.z.array(k),stories:t.z.array(C).optional()}),D=t.z.enum(["high","medium","low"]),P=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,U=7340032,F=6291456,X=8388608,N=F,q=X,L=12582912;function K(e){return 4*Math.ceil(e/3)}const H=K(B),W=K(U),Y=K(F),J=K(X),V=K(N),Q=K(q),Z=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]),le=t.z.string().regex(/^graphy:\/\/attachments\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,"attachmentRefs items must be graphy://attachments/{uuid} URIs"),me=t.z.object({id:t.z.string().uuid(),uri:t.z.string(),kind:ie,mimeType:t.z.string(),filename:t.z.string().optional(),sizeBytes:t.z.number().int().positive(),expiresAt:t.z.string().datetime()}),pe=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(),attachmentRefs:t.z.array(le).max(12).optional(),metadata:h.optional()}).superRefine((e,t)=>{var r,a,i;const n=e.sourceText.trim(),o=null!==(r=e.images)&&void 0!==r?r:[],s=null!==(a=e.attachments)&&void 0!==a?a:[],c=null!==(i=e.attachmentRefs)&&void 0!==i?i:[];if(o.length>0&&s.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(c.length>0&&s.length>0)return void t.addIssue({code:"custom",message:"Use either `attachmentRefs` or inline `attachments`, not both.",path:["attachmentRefs"]});if(c.length>0&&o.length>0)return void t.addIssue({code:"custom",message:"Use either `attachmentRefs` or deprecated `images`, not both.",path:["attachmentRefs"]});if(0===n.length&&0===o.length&&0===s.length&&0===c.length)return void t.addIssue({code:"custom",message:"Provide non-empty sourceText and/or at least one attachment",path:["sourceText"]});if(c.length>0)return;if(o.length>0){o.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 l=0,m=0,p=0,d=0,u=0,g=0,h=0;for(const e of s){const t=ee(e.dataBase64).length;switch(h+=t,e.kind){case"image":l+=1,d+=t;break;case"document":m+=1,u+=t;break;case"spreadsheet":p+=1,g+=t}}l>8&&t.addIssue({code:"custom",message:"Too many images (max 8)",path:["attachments"]}),m>2&&t.addIssue({code:"custom",message:"Too many documents (max 2)",path:["attachments"]}),p>2&&t.addIssue({code:"custom",message:"Too many spreadsheets (max 2)",path:["attachments"]});const f=l<=8&&m<=2&&p<=2;s.length>0&&f&&(d>W&&t.addIssue({code:"custom",message:"Combined image base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),u>J&&t.addIssue({code:"custom",message:"Combined document base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),g>Q&&t.addIssue({code:"custom",message:"Combined spreadsheet base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),h>Z&&t.addIssue({code:"custom",message:"Combined attachment base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}))});const de=t.z.object({response:t.z.object({message:t.z.string()}),config:c,extractMeta:P.nullable(),lastAccuracyEvaluation:I.optional()}),ue=t.z.object({config:c,response:t.z.object({message:t.z.string(),steps:t.z.array(t.z.string())})}),ge=E,he=t.z.enum(["deal-breaker","pro","con","family","continuity"]),fe=t.z.object({kind:he,label:t.z.string(),weight:t.z.number(),reason:t.z.string()}),ye=t.z.enum(["ok","disqualified"]),be=t.z.object({rank:t.z.number().int().positive(),type:v,score:t.z.number(),verdict:ye,factors:t.z.array(fe)}),ze=t.z.object({config:c,chartFamily:b.optional(),metadata:h.optional()}),xe=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"]),ve=t.z.object({kind:xe,message:t.z.string()}),Se=t.z.enum(["sum","avg","count","min","max"]),we=t.z.object({dimensionName:t.z.string(),dimensionLabel:t.z.string(),measureName:t.z.string().nullable(),measureLabel:t.z.string().nullable(),fn:Se,chartType:v,score:t.z.number(),message:t.z.string()}),_e=t.z.object({ranking:t.z.array(be),observations:t.z.array(ve).optional().default([]),suggestions:t.z.array(we).optional().default([])}),Ee=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()}),Te=t.z.object({config:c.optional(),chartImage:t.z.string().optional(),data:t.z.unknown().optional(),rubric:Ee.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."}),Ce=t.z.enum(["layout","color_contrast","typography","clutter","encoding","labels_legends","title_caption","other"]),Ae=t.z.enum(["info","low","medium","high"]),je=t.z.object({category:Ce,severity:Ae,observation:t.z.string(),rationale:t.z.string().optional(),suggestedChange:t.z.string().optional(),configPaths:t.z.array(t.z.string()).optional()}),Re=t.z.object({overallSummary:t.z.string(),overallSeverity:t.z.enum(["none","low","medium","high"]).optional(),issues:t.z.array(je)}),$e=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()}),ke=t.z.object({capturedAt:t.z.string(),chartId:t.z.string()}),Oe=t.z.object({response:t.z.object({message:t.z.string(),steps:t.z.array(t.z.string()),critiqueCommitted:t.z.boolean()}),critiqueReport:Re.nullable(),chartVisionAudit:ke.nullable().optional().default(null),rubricScores:$e.nullable().optional().default(null)}),Me="/api/v0";exports.AggregationFunctionSchema=Se,exports.AggregationSuggestionSchema=we,exports.AiChartTypeEnum=v,exports.AttachmentUploadResponseSchema=me,exports.ChartCritiqueIssueCategorySchema=Ce,exports.ChartCritiqueIssueSchema=je,exports.ChartCritiqueIssueSeveritySchema=Ae,exports.ChartCritiqueReportSchema=Re,exports.ChartFamilySchema=b,exports.ChartFitEntrySchema=be,exports.ChartFitFactorKindSchema=he,exports.ChartFitFactorSchema=fe,exports.ChartFitVerdictSchema=ye,exports.ChartJudgeRubricSchema=Ee,exports.DataObservationKindSchema=xe,exports.DataObservationSchema=ve,exports.EvaluateParamsSchema=ze,exports.EvaluateResponseSchema=_e,exports.ExecutionModeSchema=p,exports.ExploreFindingSchema=T,exports.ExploreStorySchema=C,exports.ExtractAccuracyEvaluationSchema=I,exports.ExtractAttachmentInputSchema=ce,exports.ExtractAttachmentKindSchema=ie,exports.ExtractConfidenceSchema=D,exports.ExtractFromProseParamsSchema=pe,exports.ExtractFromProseResponseSchema=de,exports.ExtractMetaSchema=P,exports.GenerateAnnotationsResponseSchema=j,exports.GenerateExplorationResponseSchema=A,exports.GenerateGraphResponseSchema=ue,exports.GenerateGraphSuggestionsResponseSchema=ge,exports.GenerateMutationResponseSchema=R,exports.GenerateNarrativeParamsSchema=w,exports.GenerateNarrativeResponseSchema=_,exports.GeneratePipelineParamsSchema=O,exports.GeneratePipelineResponseSchema=M,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(`${Me}/generate`,n,r,a),s=ue.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(`${Me}/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(`${Me}/narrate`,t,r,a);return _.parse(e)})}generateNarrativeStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${Me}/narrate`,t,r)})}generateSuggestions(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Me}/suggestions`,t,r,a);return E.parse(e)})}generateSuggestionsStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${Me}/suggestions`,t,r)})}generateExploration(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Me}/explore`,t,r,a);return A.parse(e)})}generateExplorationStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${Me}/explore`,t,r)})}generateAnnotations(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Me}/annotate`,t,r,a);return j.parse(e)})}generateAnnotationsStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${Me}/annotate`,t,r)})}generateMutation(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Me}/mutate`,t,r,a);return R.parse(e)})}generateMutationStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${Me}/mutate`,t,r)})}generatePipeline(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Me}/pipeline`,t,r,a);return M.parse(e)})}generatePipelineStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${Me}/pipeline`,t,r)})}evaluate(t,r){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Me}/evaluate`,t,void 0,r);return _e.parse(e)})}judge(t,r){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Me}/judge`,t,void 0,r);return Oe.parse(e)})}judgeStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${Me}/judge`,t,r)})}extractFromProse(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Me}/extract`,t,r,a);return de.parse(e)})}extractFromProseStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${Me}/extract`,t,r)})}uploadAttachment(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=new FormData,i=null==r?void 0:r.filename;"undefined"!=typeof File&&t instanceof File?e.append("file",t):i?e.append("file",t,i):e.append("file",t,"upload"),i&&e.append("filename",i);const n=yield this.client.uploadMultipart(`${Me}/attachments`,e,a);return me.parse(n)})}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,l=!0,m=e.__asyncValues(t);!(a=(c=yield e.__await(m.next())).done);l=!0){s=c.value,l=!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{l||a||!(o=m.return)||(yield e.__await(o.call(m)))}finally{if(n)throw n.error}}})}},exports.GraphyApiError=r,exports.InvocationBudgetSchema=g,exports.InvocationEffortSchema=l,exports.JudgeParamsSchema=Te,exports.JudgeResponseSchema=Oe,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=X,exports.MAX_EXTRACT_DOCUMENT_DECODED_BYTES=F,exports.MAX_EXTRACT_IMAGES=8,exports.MAX_EXTRACT_IMAGES_TOTAL_DECODED_BYTES=U,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=N,exports.MAX_SOURCE_TEXT_LENGTH=G,exports.MAX_USER_PROMPT_LENGTH=y,exports.MetadataSchema=h,exports.MutateNarrationReceiptSchema=f,exports.PipelineAgentNameSchema=$,exports.PipelineStageReasoningSchema=k,exports.RubricScoresSchema=$e,exports.StorytellingEffortSchema=m,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;
|
|
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 l,m,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));!(l=(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){m={error:e}}finally{try{f||l||!(p=y.return)||(yield p.call(y))}finally{if(m)throw m.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}}})}uploadMultipart(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.makeMultipartRequest(t,r,a);return yield e.json()})}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),l=()=>s.abort();a&&a.addEventListener("abort",l);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){let o,s=`HTTP ${c.status}`;try{const e=yield c.json();if("object"==typeof e&&null!==e){const t=e;"string"==typeof t.message?s=t.message:"string"==typeof t.error&&(s=t.error),"string"==typeof t.code&&(o=t.code)}}catch(e){}const l=!("QUOTA_EXCEEDED"===o)&&(c.status>=500||429===c.status),m=new r(s,{status:c.status,code:o,retryable:l});if(l&&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}) - ${s}`),m}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",l)}})}makeMultipartRequest(t,a,i){return e.__awaiter(this,arguments,void 0,function*(e,t,a,i=1){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");const o=new AbortController,s=setTimeout(()=>o.abort(),this.timeout),c=()=>o.abort();a&&a.addEventListener("abort",c);try{const s=yield fetch(n,{method:"POST",headers:{Accept:"application/json",Authorization:`Bearer ${this.apiKey}`,"User-Agent":"Graphy-SDK/1.0"},body:t,signal:o.signal});if(!s.ok){let n,o=`HTTP ${s.status}`;try{const e=yield s.json();if("object"==typeof e&&null!==e){const t=e;"string"==typeof t.message?o=t.message:"string"==typeof t.error&&(o=t.error),"string"==typeof t.code&&(n=t.code)}}catch(e){}const c=s.status>=500||429===s.status,l=new r(o,{status:s.status,code:n,retryable:c});if(c&&i<this.retryConfig.attempts&&!(null==a?void 0:a.aborted)){const r=this.retryConfig.delay*Math.pow(this.retryConfig.backoff,i-1);return yield this.sleep(r),this.makeMultipartRequest(e,t,a,i+1)}throw l}return s}catch(n){if(n instanceof r)throw n;if(n instanceof Error&&"AbortError"===n.name)throw n;if(i<this.retryConfig.attempts&&!(null==a?void 0:a.aborted)){const r=this.retryConfig.delay*Math.pow(this.retryConfig.backoff,i-1);return yield this.sleep(r),this.makeMultipartRequest(e,t,a,i+1)}throw new r("Network error",{retryable:!0})}finally{clearTimeout(s),a&&a.removeEventListener("abort",c)}})}}const s=t.z.enum(["EN_GB","EN_US"]),c=t.z.custom(e=>null!=e&&"object"==typeof e),l=t.z.enum(["low","medium","high"]),m=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(),trackUsage:t.z.boolean().optional()}),h=t.z.object({wallClockMs:t.z.number(),inputTokens:t.z.number(),inputCachedTokens:t.z.number(),inputUncachedTokens:t.z.number(),outputTokens:t.z.number(),totalTokens:t.z.number(),costUsd:t.z.number().nullable(),costEnforcementSkipped:t.z.boolean().optional()}),f=t.z.object({limits:g,consumed:h,exceeded:t.z.boolean(),exceededDimensions:t.z.array(t.z.enum(["wallClockMs","totalTokens","costUsd"])),exceededSummary:t.z.string().optional()}),y=t.z.object({callId:t.z.string().max(256).optional(),locale:s.optional(),effort:l.optional(),storytellingEffort:m.optional().default("low"),budget:g.optional(),executionMode:p.optional(),enforceTableRowCap:t.z.boolean().optional()}),b=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()}),z=t.z.object({runId:t.z.string(),trackingId:t.z.string(),callId:t.z.string().optional()}),x=1e4,v=t.z.enum(["comparison","relationship","distribution","composition"]),S=t.z.object({config:c,userPrompt:t.z.string().max(x).optional().default(""),metadata:y.optional(),chartFamily:v.optional()}),w=S.extend({maxSuggestionCount:t.z.number().int().min(1).max(4).optional()}),_=t.z.enum(["line","areaStacked","bar","groupedBar","stackedBar","100StackedBar","column","groupedColumn","stackedColumn","100StackedColumn","combo","pie","donut","funnel","heatmap","scatter","bubble","waterfall","table","mekko"]),E=t.z.object({dataPrepPrompt:t.z.string(),chartType:_,summary:t.z.string()}),T=S.extend({userPrompt:t.z.string().max(x),mutationReceipt:b.optional(),exploreFindingSummary:t.z.string().max(500).optional()}),C=t.z.object({response:t.z.object({message:t.z.string()}),config:c,run:z.optional()}),j=t.z.object({suggestions:t.z.array(E),run:z.optional()}),A=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:v.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.")}),R=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(A).describe("Child findings, sorted by quadrant score desc.")}),k=t.z.object({response:t.z.object({message:t.z.string(),steps:t.z.array(t.z.string())}),stories:t.z.array(R),run:z.optional()});S.extend({mutationReceipt:b.optional()});const $=t.z.object({response:t.z.object({message:t.z.string(),steps:t.z.array(t.z.string())}),config:c,run:z.optional()}),M=t.z.object({response:t.z.object({message:t.z.string(),steps:t.z.array(t.z.string())}),config:c,mutationReceipt:b.optional(),warnings:t.z.array(t.z.string()).optional(),budget:f.optional(),run:z.optional()}),O=t.z.enum(["explore","mutate","narrate","annotate"]),D=t.z.object({agent:O,summary:t.z.string(),steps:t.z.array(t.z.string()).optional()}),P=S.extend({userPrompt:t.z.string().max(x),stages:t.z.array(O).min(1).refine(e=>new Set(e).size===e.length,{message:"Duplicate pipeline stages are not allowed"}),exploreFindingSummary:t.z.string().max(500).optional()}),I=M.extend({reasoning:t.z.array(D),stories:t.z.array(R).optional()}),U=t.z.enum(["high","medium","low"]),G=t.z.object({confidence:U,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:U,quote:t.z.string().optional()})).optional()}),B=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()}),F=5e5,X=2097152,N=7340032,q=6291456,L=8388608,K=q,H=L,W=12582912;function Y(e){return 4*Math.ceil(e/3)}const J=Y(X),V=Y(N),Q=Y(q),Z=Y(L),ee=Y(K),te=Y(H),re=Y(W);function ae(e){return e.replace(/\s+/g,"")}function ie(e){const t=ae(e);return 0!==t.length&&t.length%4==0&&/^[A-Za-z0-9+/]+={0,2}$/.test(t)}const ne=/^image\/(png|jpeg|jpg|webp|gif)$/i,oe=t.z.object({mimeType:t.z.string().min(1).refine(e=>ne.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(J).refine(ie,{message:"dataBase64 must be standard base64 (RFC 4648)"})}),se=t.z.enum(["image","document","spreadsheet"]),ce=oe.extend({kind:t.z.literal("image")}),le=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(Q).refine(ie,{message:"dataBase64 must be standard base64 (RFC 4648)"})}),me=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(ee).refine(ie,{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"]}),pe=t.z.discriminatedUnion("kind",[ce,le,me]),de=t.z.string().regex(/^graphy:\/\/attachments\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,"attachmentRefs items must be graphy://attachments/{uuid} URIs"),ue=t.z.object({id:t.z.string().uuid(),uri:t.z.string(),kind:se,mimeType:t.z.string(),filename:t.z.string().optional(),sizeBytes:t.z.number().int().positive(),expiresAt:t.z.string().datetime()}),ge=t.z.object({sourceText:t.z.string().max(F).default(""),images:t.z.array(oe).max(8).optional().describe('@deprecated Use attachments[] with kind: "image" instead. Will be removed in a future major release.'),attachments:t.z.array(pe).max(12).optional(),attachmentRefs:t.z.array(de).max(12).optional(),metadata:y.optional()}).superRefine((e,t)=>{var r,a,i;const n=e.sourceText.trim(),o=null!==(r=e.images)&&void 0!==r?r:[],s=null!==(a=e.attachments)&&void 0!==a?a:[],c=null!==(i=e.attachmentRefs)&&void 0!==i?i:[];if(o.length>0&&s.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(c.length>0&&s.length>0)return void t.addIssue({code:"custom",message:"Use either `attachmentRefs` or inline `attachments`, not both.",path:["attachmentRefs"]});if(c.length>0&&o.length>0)return void t.addIssue({code:"custom",message:"Use either `attachmentRefs` or deprecated `images`, not both.",path:["attachmentRefs"]});if(0===n.length&&0===o.length&&0===s.length&&0===c.length)return void t.addIssue({code:"custom",message:"Provide non-empty sourceText and/or at least one attachment",path:["sourceText"]});if(c.length>0)return;if(o.length>0){o.reduce((e,t)=>e+ae(t.dataBase64).length,0)>V&&t.addIssue({code:"custom",message:"Combined image base64 exceeds maximum length for this API (must fit server decode limits)",path:["images"]})}let l=0,m=0,p=0,d=0,u=0,g=0,h=0;for(const e of s){const t=ae(e.dataBase64).length;switch(h+=t,e.kind){case"image":l+=1,d+=t;break;case"document":m+=1,u+=t;break;case"spreadsheet":p+=1,g+=t}}l>8&&t.addIssue({code:"custom",message:"Too many images (max 8)",path:["attachments"]}),m>2&&t.addIssue({code:"custom",message:"Too many documents (max 2)",path:["attachments"]}),p>2&&t.addIssue({code:"custom",message:"Too many spreadsheets (max 2)",path:["attachments"]});const f=l<=8&&m<=2&&p<=2;s.length>0&&f&&(d>V&&t.addIssue({code:"custom",message:"Combined image base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),u>Z&&t.addIssue({code:"custom",message:"Combined document base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),g>te&&t.addIssue({code:"custom",message:"Combined spreadsheet base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),h>re&&t.addIssue({code:"custom",message:"Combined attachment base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}))});const he=t.z.object({response:t.z.object({message:t.z.string()}),config:c,extractMeta:G.nullable(),lastAccuracyEvaluation:B.optional(),run:z.optional()}),fe=t.z.object({config:c,response:t.z.object({message:t.z.string(),steps:t.z.array(t.z.string())}),run:z.optional()}),ye=j,be=t.z.enum(["deal-breaker","pro","con","family","continuity"]),ze=t.z.object({kind:be,label:t.z.string(),weight:t.z.number(),reason:t.z.string()}),xe=t.z.enum(["ok","disqualified"]),ve=t.z.object({rank:t.z.number().int().positive(),type:_,score:t.z.number(),verdict:xe,factors:t.z.array(ze)}),Se=t.z.object({config:c,chartFamily:v.optional(),metadata:y.optional()}),we=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"]),_e=t.z.object({kind:we,message:t.z.string()}),Ee=t.z.enum(["sum","avg","count","min","max"]),Te=t.z.object({dimensionName:t.z.string(),dimensionLabel:t.z.string(),measureName:t.z.string().nullable(),measureLabel:t.z.string().nullable(),fn:Ee,chartType:_,score:t.z.number(),message:t.z.string()}),Ce=t.z.object({ranking:t.z.array(ve),observations:t.z.array(_e).optional().default([]),suggestions:t.z.array(Te).optional().default([]),run:z.optional()}),je=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()}),Ae=t.z.object({config:c.optional(),chartImage:t.z.string().optional(),data:t.z.unknown().optional(),rubric:je.optional(),userPrompt:t.z.string().optional(),metadata:y.optional()}).refine(e=>void 0!==e.config||void 0!==e.chartImage,{message:"Provide a chart config or a chart image to judge."}),Re=t.z.enum(["layout","color_contrast","typography","clutter","encoding","labels_legends","title_caption","other"]),ke=t.z.enum(["info","low","medium","high"]),$e=t.z.object({category:Re,severity:ke,observation:t.z.string(),rationale:t.z.string().optional(),suggestedChange:t.z.string().optional(),configPaths:t.z.array(t.z.string()).optional()}),Me=t.z.object({overallSummary:t.z.string(),overallSeverity:t.z.enum(["none","low","medium","high"]).optional(),issues:t.z.array($e)}),Oe=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()}),De=t.z.object({capturedAt:t.z.string(),chartId:t.z.string()}),Pe=t.z.object({response:t.z.object({message:t.z.string(),steps:t.z.array(t.z.string()),critiqueCommitted:t.z.boolean()}),critiqueReport:Me.nullable(),chartVisionAudit:De.nullable().optional().default(null),rubricScores:Oe.nullable().optional().default(null),run:z.optional()}),Ie="/api/v0";exports.AggregationFunctionSchema=Ee,exports.AggregationSuggestionSchema=Te,exports.AiChartTypeEnum=_,exports.AttachmentUploadResponseSchema=ue,exports.ChartCritiqueIssueCategorySchema=Re,exports.ChartCritiqueIssueSchema=$e,exports.ChartCritiqueIssueSeveritySchema=ke,exports.ChartCritiqueReportSchema=Me,exports.ChartFamilySchema=v,exports.ChartFitEntrySchema=ve,exports.ChartFitFactorKindSchema=be,exports.ChartFitFactorSchema=ze,exports.ChartFitVerdictSchema=xe,exports.ChartJudgeRubricSchema=je,exports.DataObservationKindSchema=we,exports.DataObservationSchema=_e,exports.EvaluateParamsSchema=Se,exports.EvaluateResponseSchema=Ce,exports.ExecutionModeSchema=p,exports.ExploreFindingSchema=A,exports.ExploreStorySchema=R,exports.ExtractAccuracyEvaluationSchema=B,exports.ExtractAttachmentInputSchema=pe,exports.ExtractAttachmentKindSchema=se,exports.ExtractConfidenceSchema=U,exports.ExtractFromProseParamsSchema=ge,exports.ExtractFromProseResponseSchema=he,exports.ExtractMetaSchema=G,exports.GenerateAnnotationsResponseSchema=$,exports.GenerateExplorationResponseSchema=k,exports.GenerateGraphResponseSchema=fe,exports.GenerateGraphSuggestionsResponseSchema=ye,exports.GenerateMutationResponseSchema=M,exports.GenerateNarrativeParamsSchema=T,exports.GenerateNarrativeResponseSchema=C,exports.GeneratePipelineParamsSchema=P,exports.GeneratePipelineResponseSchema=I,exports.GenerateSuggestionsParamsSchema=w,exports.GenerateSuggestionsResponseSchema=j,exports.GraphGenerationRequestSchema=S,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(`${Ie}/generate`,n,r,a),s=fe.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(`${Ie}/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(`${Ie}/narrate`,t,r,a);return C.parse(e)})}generateNarrativeStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${Ie}/narrate`,t,r)})}generateSuggestions(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Ie}/suggestions`,t,r,a);return j.parse(e)})}generateSuggestionsStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${Ie}/suggestions`,t,r)})}generateExploration(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Ie}/explore`,t,r,a);return k.parse(e)})}generateExplorationStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${Ie}/explore`,t,r)})}generateAnnotations(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Ie}/annotate`,t,r,a);return $.parse(e)})}generateAnnotationsStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${Ie}/annotate`,t,r)})}generateMutation(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Ie}/mutate`,t,r,a);return M.parse(e)})}generateMutationStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${Ie}/mutate`,t,r)})}generatePipeline(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Ie}/pipeline`,t,r,a);return I.parse(e)})}generatePipelineStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${Ie}/pipeline`,t,r)})}evaluate(t,r){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Ie}/evaluate`,t,void 0,r);return Ce.parse(e)})}judge(t,r){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Ie}/judge`,t,void 0,r);return Pe.parse(e)})}judgeStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${Ie}/judge`,t,r)})}extractFromProse(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Ie}/extract`,t,r,a);return he.parse(e)})}extractFromProseStream(t,r){return e.__awaiter(this,void 0,void 0,function*(){return this.client.stream(`${Ie}/extract`,t,r)})}uploadAttachment(t,r,a){return e.__awaiter(this,void 0,void 0,function*(){const e=new FormData,i=null==r?void 0:r.filename;"undefined"!=typeof File&&t instanceof File?e.append("file",t):i?e.append("file",t,i):e.append("file",t,"upload"),i&&e.append("filename",i);const n=yield this.client.uploadMultipart(`${Ie}/attachments`,e,a);return ue.parse(n)})}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,l=!0,m=e.__asyncValues(t);!(a=(c=yield e.__await(m.next())).done);l=!0){s=c.value,l=!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{l||a||!(o=m.return)||(yield e.__await(o.call(m)))}finally{if(n)throw n.error}}})}},exports.GraphyApiError=r,exports.InvocationBudgetSchema=g,exports.InvocationEffortSchema=l,exports.JudgeParamsSchema=Ae,exports.JudgeResponseSchema=Pe,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=W,exports.MAX_EXTRACT_DOCUMENTS=2,exports.MAX_EXTRACT_DOCUMENTS_TOTAL_DECODED_BYTES=L,exports.MAX_EXTRACT_DOCUMENT_DECODED_BYTES=q,exports.MAX_EXTRACT_IMAGES=8,exports.MAX_EXTRACT_IMAGES_TOTAL_DECODED_BYTES=N,exports.MAX_EXTRACT_IMAGE_DECODED_BYTES=X,exports.MAX_EXTRACT_SPREADSHEETS=2,exports.MAX_EXTRACT_SPREADSHEETS_TOTAL_DECODED_BYTES=H,exports.MAX_EXTRACT_SPREADSHEET_DECODED_BYTES=K,exports.MAX_SOURCE_TEXT_LENGTH=F,exports.MAX_USER_PROMPT_LENGTH=x,exports.MetadataSchema=y,exports.MutateNarrationReceiptSchema=b,exports.PipelineAgentNameSchema=O,exports.PipelineStageReasoningSchema=D,exports.RubricScoresSchema=Oe,exports.RunContextSchema=z,exports.StorytellingEffortSchema=m,exports.SuggestionSchema=E,exports.buildImageAttachment=function(e){return{kind:"image",mimeType:e.mimeType.trim(),dataBase64:ae(e.dataBase64)}},exports.buildPdfAttachment=function(e){return{kind:"document",mimeType:"application/pdf",dataBase64:ae(e.dataBase64)}},exports.buildSpreadsheetAttachment=function(e){return Object.assign({kind:"spreadsheet",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",dataBase64:ae(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
|
@@ -306,6 +306,7 @@ declare const InvocationBudgetSchema: z.ZodObject<{
|
|
|
306
306
|
maxWallClockMs: z.ZodOptional<z.ZodNumber>;
|
|
307
307
|
maxTotalTokens: z.ZodOptional<z.ZodNumber>;
|
|
308
308
|
maxCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
309
|
+
trackUsage: z.ZodOptional<z.ZodBoolean>;
|
|
309
310
|
}, z.core.$strip>;
|
|
310
311
|
type InvocationBudget = z.infer<typeof InvocationBudgetSchema>;
|
|
311
312
|
/**
|
|
@@ -333,6 +334,7 @@ declare const MetadataSchema: z.ZodObject<{
|
|
|
333
334
|
maxWallClockMs: z.ZodOptional<z.ZodNumber>;
|
|
334
335
|
maxTotalTokens: z.ZodOptional<z.ZodNumber>;
|
|
335
336
|
maxCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
337
|
+
trackUsage: z.ZodOptional<z.ZodBoolean>;
|
|
336
338
|
}, z.core.$strip>>;
|
|
337
339
|
executionMode: z.ZodOptional<z.ZodEnum<{
|
|
338
340
|
agentic: "agentic";
|
|
@@ -368,6 +370,13 @@ declare const MutateNarrationReceiptSchema: z.ZodObject<{
|
|
|
368
370
|
}, z.core.$strip>;
|
|
369
371
|
type MutateNarrationReceipt = z.infer<typeof MutateNarrationReceiptSchema>;
|
|
370
372
|
type Metadata = z.infer<typeof MetadataSchema>;
|
|
373
|
+
/** Correlates one agent HTTP request across Langfuse, Grafana Tempo, and feedback. */
|
|
374
|
+
declare const RunContextSchema: z.ZodObject<{
|
|
375
|
+
runId: z.ZodString;
|
|
376
|
+
trackingId: z.ZodString;
|
|
377
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
378
|
+
}, z.core.$strip>;
|
|
379
|
+
type RunContext = z.infer<typeof RunContextSchema>;
|
|
371
380
|
/** Mirrors `MAX_USER_PROMPT_LENGTH` in the agents-api request schema. */
|
|
372
381
|
declare const MAX_USER_PROMPT_LENGTH = 10000;
|
|
373
382
|
/**
|
|
@@ -410,6 +419,7 @@ declare const GraphGenerationRequestSchema: z.ZodObject<{
|
|
|
410
419
|
maxWallClockMs: z.ZodOptional<z.ZodNumber>;
|
|
411
420
|
maxTotalTokens: z.ZodOptional<z.ZodNumber>;
|
|
412
421
|
maxCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
422
|
+
trackUsage: z.ZodOptional<z.ZodBoolean>;
|
|
413
423
|
}, z.core.$strip>>;
|
|
414
424
|
executionMode: z.ZodOptional<z.ZodEnum<{
|
|
415
425
|
agentic: "agentic";
|
|
@@ -450,6 +460,7 @@ declare const GenerateSuggestionsParamsSchema: z.ZodObject<{
|
|
|
450
460
|
maxWallClockMs: z.ZodOptional<z.ZodNumber>;
|
|
451
461
|
maxTotalTokens: z.ZodOptional<z.ZodNumber>;
|
|
452
462
|
maxCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
463
|
+
trackUsage: z.ZodOptional<z.ZodBoolean>;
|
|
453
464
|
}, z.core.$strip>>;
|
|
454
465
|
executionMode: z.ZodOptional<z.ZodEnum<{
|
|
455
466
|
agentic: "agentic";
|
|
@@ -543,6 +554,7 @@ declare const GenerateNarrativeParamsSchema: z.ZodObject<{
|
|
|
543
554
|
maxWallClockMs: z.ZodOptional<z.ZodNumber>;
|
|
544
555
|
maxTotalTokens: z.ZodOptional<z.ZodNumber>;
|
|
545
556
|
maxCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
557
|
+
trackUsage: z.ZodOptional<z.ZodBoolean>;
|
|
546
558
|
}, z.core.$strip>>;
|
|
547
559
|
executionMode: z.ZodOptional<z.ZodEnum<{
|
|
548
560
|
agentic: "agentic";
|
|
@@ -590,6 +602,11 @@ declare const GenerateNarrativeResponseSchema: z.ZodObject<{
|
|
|
590
602
|
message: z.ZodString;
|
|
591
603
|
}, z.core.$strip>;
|
|
592
604
|
config: z.ZodType<GraphConfig, unknown, z.core.$ZodTypeInternals<GraphConfig, unknown>>;
|
|
605
|
+
run: z.ZodOptional<z.ZodObject<{
|
|
606
|
+
runId: z.ZodString;
|
|
607
|
+
trackingId: z.ZodString;
|
|
608
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
609
|
+
}, z.core.$strip>>;
|
|
593
610
|
}, z.core.$strip>;
|
|
594
611
|
type GenerateNarrativeResponse = z.infer<typeof GenerateNarrativeResponseSchema>;
|
|
595
612
|
declare const GenerateSuggestionsResponseSchema: z.ZodObject<{
|
|
@@ -619,6 +636,11 @@ declare const GenerateSuggestionsResponseSchema: z.ZodObject<{
|
|
|
619
636
|
}>;
|
|
620
637
|
summary: z.ZodString;
|
|
621
638
|
}, z.core.$strip>>;
|
|
639
|
+
run: z.ZodOptional<z.ZodObject<{
|
|
640
|
+
runId: z.ZodString;
|
|
641
|
+
trackingId: z.ZodString;
|
|
642
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
643
|
+
}, z.core.$strip>>;
|
|
622
644
|
}, z.core.$strip>;
|
|
623
645
|
type GenerateSuggestionsResponse = z.infer<typeof GenerateSuggestionsResponseSchema>;
|
|
624
646
|
type GenerateExplorationParams = GraphGenerationRequest;
|
|
@@ -688,6 +710,11 @@ declare const GenerateExplorationResponseSchema: z.ZodObject<{
|
|
|
688
710
|
evidenceSummary: z.ZodString;
|
|
689
711
|
}, z.core.$strip>>;
|
|
690
712
|
}, z.core.$strip>>;
|
|
713
|
+
run: z.ZodOptional<z.ZodObject<{
|
|
714
|
+
runId: z.ZodString;
|
|
715
|
+
trackingId: z.ZodString;
|
|
716
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
717
|
+
}, z.core.$strip>>;
|
|
691
718
|
}, z.core.$strip>;
|
|
692
719
|
type GenerateExplorationResponse = z.infer<typeof GenerateExplorationResponseSchema>;
|
|
693
720
|
declare const GenerateAnnotationsParamsSchema: z.ZodObject<{
|
|
@@ -714,6 +741,7 @@ declare const GenerateAnnotationsParamsSchema: z.ZodObject<{
|
|
|
714
741
|
maxWallClockMs: z.ZodOptional<z.ZodNumber>;
|
|
715
742
|
maxTotalTokens: z.ZodOptional<z.ZodNumber>;
|
|
716
743
|
maxCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
744
|
+
trackUsage: z.ZodOptional<z.ZodBoolean>;
|
|
717
745
|
}, z.core.$strip>>;
|
|
718
746
|
executionMode: z.ZodOptional<z.ZodEnum<{
|
|
719
747
|
agentic: "agentic";
|
|
@@ -760,6 +788,11 @@ declare const GenerateAnnotationsResponseSchema: z.ZodObject<{
|
|
|
760
788
|
steps: z.ZodArray<z.ZodString>;
|
|
761
789
|
}, z.core.$strip>;
|
|
762
790
|
config: z.ZodType<GraphConfig, unknown, z.core.$ZodTypeInternals<GraphConfig, unknown>>;
|
|
791
|
+
run: z.ZodOptional<z.ZodObject<{
|
|
792
|
+
runId: z.ZodString;
|
|
793
|
+
trackingId: z.ZodString;
|
|
794
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
795
|
+
}, z.core.$strip>>;
|
|
763
796
|
}, z.core.$strip>;
|
|
764
797
|
type GenerateAnnotationsResponse = z.infer<typeof GenerateAnnotationsResponseSchema>;
|
|
765
798
|
type GenerateMutationParams = GraphGenerationRequest;
|
|
@@ -795,6 +828,36 @@ declare const GenerateMutationResponseSchema: z.ZodObject<{
|
|
|
795
828
|
grainSummary: z.ZodOptional<z.ZodString>;
|
|
796
829
|
}, z.core.$strip>>;
|
|
797
830
|
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
831
|
+
budget: z.ZodOptional<z.ZodObject<{
|
|
832
|
+
limits: z.ZodObject<{
|
|
833
|
+
maxWallClockMs: z.ZodOptional<z.ZodNumber>;
|
|
834
|
+
maxTotalTokens: z.ZodOptional<z.ZodNumber>;
|
|
835
|
+
maxCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
836
|
+
trackUsage: z.ZodOptional<z.ZodBoolean>;
|
|
837
|
+
}, z.core.$strip>;
|
|
838
|
+
consumed: z.ZodObject<{
|
|
839
|
+
wallClockMs: z.ZodNumber;
|
|
840
|
+
inputTokens: z.ZodNumber;
|
|
841
|
+
inputCachedTokens: z.ZodNumber;
|
|
842
|
+
inputUncachedTokens: z.ZodNumber;
|
|
843
|
+
outputTokens: z.ZodNumber;
|
|
844
|
+
totalTokens: z.ZodNumber;
|
|
845
|
+
costUsd: z.ZodNullable<z.ZodNumber>;
|
|
846
|
+
costEnforcementSkipped: z.ZodOptional<z.ZodBoolean>;
|
|
847
|
+
}, z.core.$strip>;
|
|
848
|
+
exceeded: z.ZodBoolean;
|
|
849
|
+
exceededDimensions: z.ZodArray<z.ZodEnum<{
|
|
850
|
+
wallClockMs: "wallClockMs";
|
|
851
|
+
totalTokens: "totalTokens";
|
|
852
|
+
costUsd: "costUsd";
|
|
853
|
+
}>>;
|
|
854
|
+
exceededSummary: z.ZodOptional<z.ZodString>;
|
|
855
|
+
}, z.core.$strip>>;
|
|
856
|
+
run: z.ZodOptional<z.ZodObject<{
|
|
857
|
+
runId: z.ZodString;
|
|
858
|
+
trackingId: z.ZodString;
|
|
859
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
860
|
+
}, z.core.$strip>>;
|
|
798
861
|
}, z.core.$strip>;
|
|
799
862
|
type GenerateMutationResponse = z.infer<typeof GenerateMutationResponseSchema>;
|
|
800
863
|
declare const PipelineAgentNameSchema: z.ZodEnum<{
|
|
@@ -841,6 +904,7 @@ declare const GeneratePipelineParamsSchema: z.ZodObject<{
|
|
|
841
904
|
maxWallClockMs: z.ZodOptional<z.ZodNumber>;
|
|
842
905
|
maxTotalTokens: z.ZodOptional<z.ZodNumber>;
|
|
843
906
|
maxCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
907
|
+
trackUsage: z.ZodOptional<z.ZodBoolean>;
|
|
844
908
|
}, z.core.$strip>>;
|
|
845
909
|
executionMode: z.ZodOptional<z.ZodEnum<{
|
|
846
910
|
agentic: "agentic";
|
|
@@ -896,6 +960,36 @@ declare const GeneratePipelineResponseSchema: z.ZodObject<{
|
|
|
896
960
|
grainSummary: z.ZodOptional<z.ZodString>;
|
|
897
961
|
}, z.core.$strip>>;
|
|
898
962
|
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
963
|
+
budget: z.ZodOptional<z.ZodObject<{
|
|
964
|
+
limits: z.ZodObject<{
|
|
965
|
+
maxWallClockMs: z.ZodOptional<z.ZodNumber>;
|
|
966
|
+
maxTotalTokens: z.ZodOptional<z.ZodNumber>;
|
|
967
|
+
maxCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
968
|
+
trackUsage: z.ZodOptional<z.ZodBoolean>;
|
|
969
|
+
}, z.core.$strip>;
|
|
970
|
+
consumed: z.ZodObject<{
|
|
971
|
+
wallClockMs: z.ZodNumber;
|
|
972
|
+
inputTokens: z.ZodNumber;
|
|
973
|
+
inputCachedTokens: z.ZodNumber;
|
|
974
|
+
inputUncachedTokens: z.ZodNumber;
|
|
975
|
+
outputTokens: z.ZodNumber;
|
|
976
|
+
totalTokens: z.ZodNumber;
|
|
977
|
+
costUsd: z.ZodNullable<z.ZodNumber>;
|
|
978
|
+
costEnforcementSkipped: z.ZodOptional<z.ZodBoolean>;
|
|
979
|
+
}, z.core.$strip>;
|
|
980
|
+
exceeded: z.ZodBoolean;
|
|
981
|
+
exceededDimensions: z.ZodArray<z.ZodEnum<{
|
|
982
|
+
wallClockMs: "wallClockMs";
|
|
983
|
+
totalTokens: "totalTokens";
|
|
984
|
+
costUsd: "costUsd";
|
|
985
|
+
}>>;
|
|
986
|
+
exceededSummary: z.ZodOptional<z.ZodString>;
|
|
987
|
+
}, z.core.$strip>>;
|
|
988
|
+
run: z.ZodOptional<z.ZodObject<{
|
|
989
|
+
runId: z.ZodString;
|
|
990
|
+
trackingId: z.ZodString;
|
|
991
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
992
|
+
}, z.core.$strip>>;
|
|
899
993
|
reasoning: z.ZodArray<z.ZodObject<{
|
|
900
994
|
agent: z.ZodEnum<{
|
|
901
995
|
explore: "explore";
|
|
@@ -1070,6 +1164,7 @@ declare const ExtractFromProseParamsSchema: z.ZodObject<{
|
|
|
1070
1164
|
maxWallClockMs: z.ZodOptional<z.ZodNumber>;
|
|
1071
1165
|
maxTotalTokens: z.ZodOptional<z.ZodNumber>;
|
|
1072
1166
|
maxCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
1167
|
+
trackUsage: z.ZodOptional<z.ZodBoolean>;
|
|
1073
1168
|
}, z.core.$strip>>;
|
|
1074
1169
|
executionMode: z.ZodOptional<z.ZodEnum<{
|
|
1075
1170
|
agentic: "agentic";
|
|
@@ -1138,6 +1233,11 @@ declare const ExtractFromProseResponseSchema: z.ZodObject<{
|
|
|
1138
1233
|
sufficient: z.ZodBoolean;
|
|
1139
1234
|
summary: z.ZodString;
|
|
1140
1235
|
}, z.core.$strip>>;
|
|
1236
|
+
run: z.ZodOptional<z.ZodObject<{
|
|
1237
|
+
runId: z.ZodString;
|
|
1238
|
+
trackingId: z.ZodString;
|
|
1239
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
1240
|
+
}, z.core.$strip>>;
|
|
1141
1241
|
}, z.core.$strip>;
|
|
1142
1242
|
type ExtractFromProseResponse = z.infer<typeof ExtractFromProseResponseSchema>;
|
|
1143
1243
|
interface StorytellingOptions {
|
|
@@ -1154,6 +1254,11 @@ declare const GenerateGraphResponseSchema: z.ZodObject<{
|
|
|
1154
1254
|
message: z.ZodString;
|
|
1155
1255
|
steps: z.ZodArray<z.ZodString>;
|
|
1156
1256
|
}, z.core.$strip>;
|
|
1257
|
+
run: z.ZodOptional<z.ZodObject<{
|
|
1258
|
+
runId: z.ZodString;
|
|
1259
|
+
trackingId: z.ZodString;
|
|
1260
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
1261
|
+
}, z.core.$strip>>;
|
|
1157
1262
|
}, z.core.$strip>;
|
|
1158
1263
|
type GenerateGraphResponse = z.infer<typeof GenerateGraphResponseSchema>;
|
|
1159
1264
|
/** @deprecated Use {@link GenerateSuggestionsParams} instead. */
|
|
@@ -1188,6 +1293,11 @@ declare const GenerateGraphSuggestionsResponseSchema: z.ZodObject<{
|
|
|
1188
1293
|
}>;
|
|
1189
1294
|
summary: z.ZodString;
|
|
1190
1295
|
}, z.core.$strip>>;
|
|
1296
|
+
run: z.ZodOptional<z.ZodObject<{
|
|
1297
|
+
runId: z.ZodString;
|
|
1298
|
+
trackingId: z.ZodString;
|
|
1299
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
1300
|
+
}, z.core.$strip>>;
|
|
1191
1301
|
}, z.core.$strip>;
|
|
1192
1302
|
/** Kind of factor that contributed to a chart-type's score. Mirrors `Factor.kind` in agents-api. */
|
|
1193
1303
|
declare const ChartFitFactorKindSchema: z.ZodEnum<{
|
|
@@ -1296,6 +1406,7 @@ declare const EvaluateParamsSchema: z.ZodObject<{
|
|
|
1296
1406
|
maxWallClockMs: z.ZodOptional<z.ZodNumber>;
|
|
1297
1407
|
maxTotalTokens: z.ZodOptional<z.ZodNumber>;
|
|
1298
1408
|
maxCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
1409
|
+
trackUsage: z.ZodOptional<z.ZodBoolean>;
|
|
1299
1410
|
}, z.core.$strip>>;
|
|
1300
1411
|
executionMode: z.ZodOptional<z.ZodEnum<{
|
|
1301
1412
|
agentic: "agentic";
|
|
@@ -1503,6 +1614,11 @@ declare const EvaluateResponseSchema: z.ZodObject<{
|
|
|
1503
1614
|
score: z.ZodNumber;
|
|
1504
1615
|
message: z.ZodString;
|
|
1505
1616
|
}, z.core.$strip>>>>;
|
|
1617
|
+
run: z.ZodOptional<z.ZodObject<{
|
|
1618
|
+
runId: z.ZodString;
|
|
1619
|
+
trackingId: z.ZodString;
|
|
1620
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
1621
|
+
}, z.core.$strip>>;
|
|
1506
1622
|
}, z.core.$strip>;
|
|
1507
1623
|
type EvaluateResponse = z.infer<typeof EvaluateResponseSchema>;
|
|
1508
1624
|
/** Optional benchmark rubric. When present, the judge also returns {@link RubricScores}. */
|
|
@@ -1553,6 +1669,7 @@ declare const JudgeParamsSchema: z.ZodObject<{
|
|
|
1553
1669
|
maxWallClockMs: z.ZodOptional<z.ZodNumber>;
|
|
1554
1670
|
maxTotalTokens: z.ZodOptional<z.ZodNumber>;
|
|
1555
1671
|
maxCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
1672
|
+
trackUsage: z.ZodOptional<z.ZodBoolean>;
|
|
1556
1673
|
}, z.core.$strip>>;
|
|
1557
1674
|
executionMode: z.ZodOptional<z.ZodEnum<{
|
|
1558
1675
|
agentic: "agentic";
|
|
@@ -1702,6 +1819,11 @@ declare const JudgeResponseSchema: z.ZodObject<{
|
|
|
1702
1819
|
composite: z.ZodNumber;
|
|
1703
1820
|
rationale: z.ZodOptional<z.ZodString>;
|
|
1704
1821
|
}, z.core.$strip>>>>;
|
|
1822
|
+
run: z.ZodOptional<z.ZodObject<{
|
|
1823
|
+
runId: z.ZodString;
|
|
1824
|
+
trackingId: z.ZodString;
|
|
1825
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
1826
|
+
}, z.core.$strip>>;
|
|
1705
1827
|
}, z.core.$strip>;
|
|
1706
1828
|
type JudgeResponse = z.infer<typeof JudgeResponseSchema>;
|
|
1707
1829
|
|
|
@@ -1748,6 +1870,11 @@ declare class GraphyAiSdk {
|
|
|
1748
1870
|
message: string;
|
|
1749
1871
|
steps: string[];
|
|
1750
1872
|
};
|
|
1873
|
+
run?: {
|
|
1874
|
+
runId: string;
|
|
1875
|
+
trackingId: string;
|
|
1876
|
+
callId?: string | undefined;
|
|
1877
|
+
} | undefined;
|
|
1751
1878
|
}>;
|
|
1752
1879
|
/**
|
|
1753
1880
|
* Streams chart generation events via SSE.
|
|
@@ -1763,6 +1890,11 @@ declare class GraphyAiSdk {
|
|
|
1763
1890
|
message: string;
|
|
1764
1891
|
steps: string[];
|
|
1765
1892
|
};
|
|
1893
|
+
run?: {
|
|
1894
|
+
runId: string;
|
|
1895
|
+
trackingId: string;
|
|
1896
|
+
callId?: string | undefined;
|
|
1897
|
+
} | undefined;
|
|
1766
1898
|
}>>>;
|
|
1767
1899
|
/**
|
|
1768
1900
|
* Generates a narrative for a chart. The agent updates `config.content.title`,
|
|
@@ -1780,6 +1912,11 @@ declare class GraphyAiSdk {
|
|
|
1780
1912
|
message: string;
|
|
1781
1913
|
};
|
|
1782
1914
|
config: _graphysdk_core_node.GraphConfig;
|
|
1915
|
+
run?: {
|
|
1916
|
+
runId: string;
|
|
1917
|
+
trackingId: string;
|
|
1918
|
+
callId?: string | undefined;
|
|
1919
|
+
} | undefined;
|
|
1783
1920
|
}>;
|
|
1784
1921
|
/**
|
|
1785
1922
|
* Streams narrative generation events via SSE.
|
|
@@ -1794,6 +1931,11 @@ declare class GraphyAiSdk {
|
|
|
1794
1931
|
message: string;
|
|
1795
1932
|
};
|
|
1796
1933
|
config: _graphysdk_core_node.GraphConfig;
|
|
1934
|
+
run?: {
|
|
1935
|
+
runId: string;
|
|
1936
|
+
trackingId: string;
|
|
1937
|
+
callId?: string | undefined;
|
|
1938
|
+
} | undefined;
|
|
1797
1939
|
}>>>;
|
|
1798
1940
|
/**
|
|
1799
1941
|
* Generates chart type and prompt suggestions for a given chart configuration.
|
|
@@ -1810,6 +1952,11 @@ declare class GraphyAiSdk {
|
|
|
1810
1952
|
chartType: "line" | "areaStacked" | "bar" | "groupedBar" | "stackedBar" | "100StackedBar" | "column" | "groupedColumn" | "stackedColumn" | "100StackedColumn" | "combo" | "pie" | "donut" | "funnel" | "heatmap" | "scatter" | "bubble" | "waterfall" | "table" | "mekko";
|
|
1811
1953
|
summary: string;
|
|
1812
1954
|
}[];
|
|
1955
|
+
run?: {
|
|
1956
|
+
runId: string;
|
|
1957
|
+
trackingId: string;
|
|
1958
|
+
callId?: string | undefined;
|
|
1959
|
+
} | undefined;
|
|
1813
1960
|
}>;
|
|
1814
1961
|
/**
|
|
1815
1962
|
* Streams suggestion generation events via SSE.
|
|
@@ -1825,6 +1972,11 @@ declare class GraphyAiSdk {
|
|
|
1825
1972
|
chartType: "line" | "areaStacked" | "bar" | "groupedBar" | "stackedBar" | "100StackedBar" | "column" | "groupedColumn" | "stackedColumn" | "100StackedColumn" | "combo" | "pie" | "donut" | "funnel" | "heatmap" | "scatter" | "bubble" | "waterfall" | "table" | "mekko";
|
|
1826
1973
|
summary: string;
|
|
1827
1974
|
}[];
|
|
1975
|
+
run?: {
|
|
1976
|
+
runId: string;
|
|
1977
|
+
trackingId: string;
|
|
1978
|
+
callId?: string | undefined;
|
|
1979
|
+
} | undefined;
|
|
1828
1980
|
}>>>;
|
|
1829
1981
|
/**
|
|
1830
1982
|
* Runs the exploration agent against a chart's dataset.
|
|
@@ -1854,6 +2006,11 @@ declare class GraphyAiSdk {
|
|
|
1854
2006
|
evidenceSummary: string;
|
|
1855
2007
|
}[];
|
|
1856
2008
|
}[];
|
|
2009
|
+
run?: {
|
|
2010
|
+
runId: string;
|
|
2011
|
+
trackingId: string;
|
|
2012
|
+
callId?: string | undefined;
|
|
2013
|
+
} | undefined;
|
|
1857
2014
|
}>;
|
|
1858
2015
|
/**
|
|
1859
2016
|
* Streams exploration agent events via SSE.
|
|
@@ -1882,6 +2039,11 @@ declare class GraphyAiSdk {
|
|
|
1882
2039
|
evidenceSummary: string;
|
|
1883
2040
|
}[];
|
|
1884
2041
|
}[];
|
|
2042
|
+
run?: {
|
|
2043
|
+
runId: string;
|
|
2044
|
+
trackingId: string;
|
|
2045
|
+
callId?: string | undefined;
|
|
2046
|
+
} | undefined;
|
|
1885
2047
|
}>>>;
|
|
1886
2048
|
/**
|
|
1887
2049
|
* Runs the annotation-tools agent to add annotations to a chart.
|
|
@@ -1898,6 +2060,11 @@ declare class GraphyAiSdk {
|
|
|
1898
2060
|
steps: string[];
|
|
1899
2061
|
};
|
|
1900
2062
|
config: _graphysdk_core_node.GraphConfig;
|
|
2063
|
+
run?: {
|
|
2064
|
+
runId: string;
|
|
2065
|
+
trackingId: string;
|
|
2066
|
+
callId?: string | undefined;
|
|
2067
|
+
} | undefined;
|
|
1901
2068
|
}>;
|
|
1902
2069
|
/**
|
|
1903
2070
|
* Streams annotation-tools agent events via SSE.
|
|
@@ -1913,6 +2080,11 @@ declare class GraphyAiSdk {
|
|
|
1913
2080
|
steps: string[];
|
|
1914
2081
|
};
|
|
1915
2082
|
config: _graphysdk_core_node.GraphConfig;
|
|
2083
|
+
run?: {
|
|
2084
|
+
runId: string;
|
|
2085
|
+
trackingId: string;
|
|
2086
|
+
callId?: string | undefined;
|
|
2087
|
+
} | undefined;
|
|
1916
2088
|
}>>>;
|
|
1917
2089
|
/**
|
|
1918
2090
|
* Runs the mutate agent to apply dataset transformations (filter, select, derive,
|
|
@@ -1948,6 +2120,32 @@ declare class GraphyAiSdk {
|
|
|
1948
2120
|
grainSummary?: string | undefined;
|
|
1949
2121
|
} | undefined;
|
|
1950
2122
|
warnings?: string[] | undefined;
|
|
2123
|
+
budget?: {
|
|
2124
|
+
limits: {
|
|
2125
|
+
maxWallClockMs?: number | undefined;
|
|
2126
|
+
maxTotalTokens?: number | undefined;
|
|
2127
|
+
maxCostUsd?: number | undefined;
|
|
2128
|
+
trackUsage?: boolean | undefined;
|
|
2129
|
+
};
|
|
2130
|
+
consumed: {
|
|
2131
|
+
wallClockMs: number;
|
|
2132
|
+
inputTokens: number;
|
|
2133
|
+
inputCachedTokens: number;
|
|
2134
|
+
inputUncachedTokens: number;
|
|
2135
|
+
outputTokens: number;
|
|
2136
|
+
totalTokens: number;
|
|
2137
|
+
costUsd: number | null;
|
|
2138
|
+
costEnforcementSkipped?: boolean | undefined;
|
|
2139
|
+
};
|
|
2140
|
+
exceeded: boolean;
|
|
2141
|
+
exceededDimensions: ("wallClockMs" | "totalTokens" | "costUsd")[];
|
|
2142
|
+
exceededSummary?: string | undefined;
|
|
2143
|
+
} | undefined;
|
|
2144
|
+
run?: {
|
|
2145
|
+
runId: string;
|
|
2146
|
+
trackingId: string;
|
|
2147
|
+
callId?: string | undefined;
|
|
2148
|
+
} | undefined;
|
|
1951
2149
|
}>;
|
|
1952
2150
|
/**
|
|
1953
2151
|
* Streams mutate agent events via SSE.
|
|
@@ -1980,6 +2178,32 @@ declare class GraphyAiSdk {
|
|
|
1980
2178
|
grainSummary?: string | undefined;
|
|
1981
2179
|
} | undefined;
|
|
1982
2180
|
warnings?: string[] | undefined;
|
|
2181
|
+
budget?: {
|
|
2182
|
+
limits: {
|
|
2183
|
+
maxWallClockMs?: number | undefined;
|
|
2184
|
+
maxTotalTokens?: number | undefined;
|
|
2185
|
+
maxCostUsd?: number | undefined;
|
|
2186
|
+
trackUsage?: boolean | undefined;
|
|
2187
|
+
};
|
|
2188
|
+
consumed: {
|
|
2189
|
+
wallClockMs: number;
|
|
2190
|
+
inputTokens: number;
|
|
2191
|
+
inputCachedTokens: number;
|
|
2192
|
+
inputUncachedTokens: number;
|
|
2193
|
+
outputTokens: number;
|
|
2194
|
+
totalTokens: number;
|
|
2195
|
+
costUsd: number | null;
|
|
2196
|
+
costEnforcementSkipped?: boolean | undefined;
|
|
2197
|
+
};
|
|
2198
|
+
exceeded: boolean;
|
|
2199
|
+
exceededDimensions: ("wallClockMs" | "totalTokens" | "costUsd")[];
|
|
2200
|
+
exceededSummary?: string | undefined;
|
|
2201
|
+
} | undefined;
|
|
2202
|
+
run?: {
|
|
2203
|
+
runId: string;
|
|
2204
|
+
trackingId: string;
|
|
2205
|
+
callId?: string | undefined;
|
|
2206
|
+
} | undefined;
|
|
1983
2207
|
}>>>;
|
|
1984
2208
|
/**
|
|
1985
2209
|
* Runs an ordered agent pipeline (`POST /v0/pipeline`) on one shared server session.
|
|
@@ -2013,6 +2237,32 @@ declare class GraphyAiSdk {
|
|
|
2013
2237
|
grainSummary?: string | undefined;
|
|
2014
2238
|
} | undefined;
|
|
2015
2239
|
warnings?: string[] | undefined;
|
|
2240
|
+
budget?: {
|
|
2241
|
+
limits: {
|
|
2242
|
+
maxWallClockMs?: number | undefined;
|
|
2243
|
+
maxTotalTokens?: number | undefined;
|
|
2244
|
+
maxCostUsd?: number | undefined;
|
|
2245
|
+
trackUsage?: boolean | undefined;
|
|
2246
|
+
};
|
|
2247
|
+
consumed: {
|
|
2248
|
+
wallClockMs: number;
|
|
2249
|
+
inputTokens: number;
|
|
2250
|
+
inputCachedTokens: number;
|
|
2251
|
+
inputUncachedTokens: number;
|
|
2252
|
+
outputTokens: number;
|
|
2253
|
+
totalTokens: number;
|
|
2254
|
+
costUsd: number | null;
|
|
2255
|
+
costEnforcementSkipped?: boolean | undefined;
|
|
2256
|
+
};
|
|
2257
|
+
exceeded: boolean;
|
|
2258
|
+
exceededDimensions: ("wallClockMs" | "totalTokens" | "costUsd")[];
|
|
2259
|
+
exceededSummary?: string | undefined;
|
|
2260
|
+
} | undefined;
|
|
2261
|
+
run?: {
|
|
2262
|
+
runId: string;
|
|
2263
|
+
trackingId: string;
|
|
2264
|
+
callId?: string | undefined;
|
|
2265
|
+
} | undefined;
|
|
2016
2266
|
stories?: {
|
|
2017
2267
|
topic: string;
|
|
2018
2268
|
score: number;
|
|
@@ -2056,6 +2306,32 @@ declare class GraphyAiSdk {
|
|
|
2056
2306
|
grainSummary?: string | undefined;
|
|
2057
2307
|
} | undefined;
|
|
2058
2308
|
warnings?: string[] | undefined;
|
|
2309
|
+
budget?: {
|
|
2310
|
+
limits: {
|
|
2311
|
+
maxWallClockMs?: number | undefined;
|
|
2312
|
+
maxTotalTokens?: number | undefined;
|
|
2313
|
+
maxCostUsd?: number | undefined;
|
|
2314
|
+
trackUsage?: boolean | undefined;
|
|
2315
|
+
};
|
|
2316
|
+
consumed: {
|
|
2317
|
+
wallClockMs: number;
|
|
2318
|
+
inputTokens: number;
|
|
2319
|
+
inputCachedTokens: number;
|
|
2320
|
+
inputUncachedTokens: number;
|
|
2321
|
+
outputTokens: number;
|
|
2322
|
+
totalTokens: number;
|
|
2323
|
+
costUsd: number | null;
|
|
2324
|
+
costEnforcementSkipped?: boolean | undefined;
|
|
2325
|
+
};
|
|
2326
|
+
exceeded: boolean;
|
|
2327
|
+
exceededDimensions: ("wallClockMs" | "totalTokens" | "costUsd")[];
|
|
2328
|
+
exceededSummary?: string | undefined;
|
|
2329
|
+
} | undefined;
|
|
2330
|
+
run?: {
|
|
2331
|
+
runId: string;
|
|
2332
|
+
trackingId: string;
|
|
2333
|
+
callId?: string | undefined;
|
|
2334
|
+
} | undefined;
|
|
2059
2335
|
stories?: {
|
|
2060
2336
|
topic: string;
|
|
2061
2337
|
score: number;
|
|
@@ -2118,6 +2394,11 @@ declare class GraphyAiSdk {
|
|
|
2118
2394
|
score: number;
|
|
2119
2395
|
message: string;
|
|
2120
2396
|
}[];
|
|
2397
|
+
run?: {
|
|
2398
|
+
runId: string;
|
|
2399
|
+
trackingId: string;
|
|
2400
|
+
callId?: string | undefined;
|
|
2401
|
+
} | undefined;
|
|
2121
2402
|
}>;
|
|
2122
2403
|
/**
|
|
2123
2404
|
* Runs the chart judge on a chart and returns a structured critique. The judge is config-optional:
|
|
@@ -2167,6 +2448,11 @@ declare class GraphyAiSdk {
|
|
|
2167
2448
|
composite: number;
|
|
2168
2449
|
rationale?: string | undefined;
|
|
2169
2450
|
} | null;
|
|
2451
|
+
run?: {
|
|
2452
|
+
runId: string;
|
|
2453
|
+
trackingId: string;
|
|
2454
|
+
callId?: string | undefined;
|
|
2455
|
+
} | undefined;
|
|
2170
2456
|
}>;
|
|
2171
2457
|
/**
|
|
2172
2458
|
* Streams chart-judge events via SSE. See {@link judge} for the request shape and semantics.
|
|
@@ -2207,6 +2493,11 @@ declare class GraphyAiSdk {
|
|
|
2207
2493
|
composite: number;
|
|
2208
2494
|
rationale?: string | undefined;
|
|
2209
2495
|
} | null;
|
|
2496
|
+
run?: {
|
|
2497
|
+
runId: string;
|
|
2498
|
+
trackingId: string;
|
|
2499
|
+
callId?: string | undefined;
|
|
2500
|
+
} | undefined;
|
|
2210
2501
|
}>>>;
|
|
2211
2502
|
/**
|
|
2212
2503
|
* Runs the extract agent to build a chart-ready dataset from unstructured prose, images, and/or PDFs.
|
|
@@ -2243,6 +2534,11 @@ declare class GraphyAiSdk {
|
|
|
2243
2534
|
sufficient: boolean;
|
|
2244
2535
|
summary: string;
|
|
2245
2536
|
} | undefined;
|
|
2537
|
+
run?: {
|
|
2538
|
+
runId: string;
|
|
2539
|
+
trackingId: string;
|
|
2540
|
+
callId?: string | undefined;
|
|
2541
|
+
} | undefined;
|
|
2246
2542
|
}>;
|
|
2247
2543
|
/**
|
|
2248
2544
|
* Streams extract-agent events via SSE.
|
|
@@ -2278,6 +2574,11 @@ declare class GraphyAiSdk {
|
|
|
2278
2574
|
sufficient: boolean;
|
|
2279
2575
|
summary: string;
|
|
2280
2576
|
} | undefined;
|
|
2577
|
+
run?: {
|
|
2578
|
+
runId: string;
|
|
2579
|
+
trackingId: string;
|
|
2580
|
+
callId?: string | undefined;
|
|
2581
|
+
} | undefined;
|
|
2281
2582
|
}>>>;
|
|
2282
2583
|
/**
|
|
2283
2584
|
* Uploads a file to the staged attachment store (`POST /v0/attachments`).
|
|
@@ -2294,5 +2595,5 @@ declare class GraphyAiSdk {
|
|
|
2294
2595
|
private wrapStreamWithStorytellingStripping;
|
|
2295
2596
|
}
|
|
2296
2597
|
|
|
2297
|
-
export { AggregationFunctionSchema, AggregationSuggestionSchema, AiChartTypeEnum, AttachmentUploadResponseSchema, 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 };
|
|
2298
|
-
export type { AggregationFunction, AggregationSuggestion, AiChartType, AttachmentUploadResponse, 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 };
|
|
2598
|
+
export { AggregationFunctionSchema, AggregationSuggestionSchema, AiChartTypeEnum, AttachmentUploadResponseSchema, 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, RunContextSchema, StorytellingEffortSchema, SuggestionSchema, buildImageAttachment, buildPdfAttachment, buildSpreadsheetAttachment, isCompleteEvent, isErrorEvent, isGraphyApiError, isPreviewEvent, isProgressEvent, isReasoningEvent };
|
|
2599
|
+
export type { AggregationFunction, AggregationSuggestion, AiChartType, AttachmentUploadResponse, 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, RunContext, 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 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}}})}uploadMultipart(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.makeMultipartRequest(t,i,n);return yield e.json()})}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){let a,s=`HTTP ${c.status}`;try{const e=yield c.json();if("object"==typeof e&&null!==e){const t=e;"string"==typeof t.message?s=t.message:"string"==typeof t.error&&(s=t.error),"string"==typeof t.code&&(a=t.code)}}catch(e){}const l=!("QUOTA_EXCEEDED"===a)&&(c.status>=500||429===c.status),m=new o(s,{status:c.status,code:a,retryable:l});if(l&&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}) - ${s}`),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)}})}makeMultipartRequest(t,i,n){return e(this,arguments,void 0,function*(e,t,i,n=1){if(!e.startsWith("/"))throw new o("Invalid endpoint: must start with /");const r=new URL(e,this.baseUrl);if(r.origin!==new URL(this.baseUrl).origin)throw new o("Endpoint resolved to unexpected origin");const a=new AbortController,s=setTimeout(()=>a.abort(),this.timeout),c=()=>a.abort();i&&i.addEventListener("abort",c);try{const s=yield fetch(r,{method:"POST",headers:{Accept:"application/json",Authorization:`Bearer ${this.apiKey}`,"User-Agent":"Graphy-SDK/1.0"},body:t,signal:a.signal});if(!s.ok){let r,a=`HTTP ${s.status}`;try{const e=yield s.json();if("object"==typeof e&&null!==e){const t=e;"string"==typeof t.message?a=t.message:"string"==typeof t.error&&(a=t.error),"string"==typeof t.code&&(r=t.code)}}catch(e){}const c=s.status>=500||429===s.status,l=new o(a,{status:s.status,code:r,retryable:c});if(c&&n<this.retryConfig.attempts&&!(null==i?void 0:i.aborted)){const r=this.retryConfig.delay*Math.pow(this.retryConfig.backoff,n-1);return yield this.sleep(r),this.makeMultipartRequest(e,t,i,n+1)}throw l}return s}catch(r){if(r instanceof o)throw r;if(r instanceof Error&&"AbortError"===r.name)throw r;if(n<this.retryConfig.attempts&&!(null==i?void 0:i.aborted)){const r=this.retryConfig.delay*Math.pow(this.retryConfig.backoff,n-1);return yield this.sleep(r),this.makeMultipartRequest(e,t,i,n+1)}throw new o("Network error",{retryable:!0})}finally{clearTimeout(s),i&&i.removeEventListener("abort",c)}})}}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()}),k=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()}),S=1e4,C=a.enum(["comparison","relationship","distribution","composition"]),R=a.object({config:h,userPrompt:a.string().max(S).optional().default(""),metadata:$.optional(),chartFamily:C.optional()}),T=R.extend({maxSuggestionCount:a.number().int().min(1).max(4).optional()}),E=a.enum(["line","areaStacked","bar","groupedBar","stackedBar","100StackedBar","column","groupedColumn","stackedColumn","100StackedColumn","combo","pie","donut","funnel","heatmap","scatter","bubble","waterfall","table","mekko"]),O=a.object({dataPrepPrompt:a.string(),chartType:E,summary:a.string()}),I=R.extend({userPrompt:a.string().max(S),mutationReceipt:k.optional(),exploreFindingSummary:a.string().max(500).optional()}),A=a.object({response:a.object({message:a.string()}),config:h}),P=a.object({suggestions:a.array(O)}),U=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.")}),B=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(U).describe("Child findings, sorted by quadrant score desc.")}),F=a.object({response:a.object({message:a.string(),steps:a.array(a.string())}),stories:a.array(B)});R.extend({mutationReceipt:k.optional()});const q=a.object({response:a.object({message:a.string(),steps:a.array(a.string())}),config:h}),M=a.object({response:a.object({message:a.string(),steps:a.array(a.string())}),config:h,mutationReceipt:k.optional(),warnings:a.array(a.string()).optional()}),D=a.enum(["explore","mutate","narrate","annotate"]),N=a.object({agent:D,summary:a.string(),steps:a.array(a.string()).optional()}),K=R.extend({userPrompt:a.string().max(S),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=M.extend({reasoning:a.array(N),stories:a.array(B).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()}),z=a.object({score:a.number().min(0).max(1),issues:a.array(a.string()),sufficient:a.boolean(),summary:a.string()}),_=5e5,H=8,J=2097152,X=7340032,Q=2,V=6291456,Y=8388608,Z=2,ee=V,te=Y,ie=12582912,ne=12;function re(e){return 4*Math.ceil(e/3)}const ae=re(J),oe=re(X),se=re(V),ce=re(Y),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.string().regex(/^graphy:\/\/attachments\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,"attachmentRefs items must be graphy://attachments/{uuid} URIs"),je=a.object({id:a.string().uuid(),uri:a.string(),kind:fe,mimeType:a.string(),filename:a.string().optional(),sizeBytes:a.number().int().positive(),expiresAt:a.string().datetime()}),$e=a.object({sourceText:a.string().max(_).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(),attachmentRefs:a.array(xe).max(12).optional(),metadata:$.optional()}).superRefine((e,t)=>{var i,n,r;const a=e.sourceText.trim(),o=null!==(i=e.images)&&void 0!==i?i:[],s=null!==(n=e.attachments)&&void 0!==n?n:[],c=null!==(r=e.attachmentRefs)&&void 0!==r?r:[];if(o.length>0&&s.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(c.length>0&&s.length>0)return void t.addIssue({code:"custom",message:"Use either `attachmentRefs` or inline `attachments`, not both.",path:["attachmentRefs"]});if(c.length>0&&o.length>0)return void t.addIssue({code:"custom",message:"Use either `attachmentRefs` or deprecated `images`, not both.",path:["attachmentRefs"]});if(0===a.length&&0===o.length&&0===s.length&&0===c.length)return void t.addIssue({code:"custom",message:"Provide non-empty sourceText and/or at least one attachment",path:["sourceText"]});if(c.length>0)return;if(o.length>0){o.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 l=0,m=0,d=0,u=0,g=0,p=0,h=0;for(const e of s){const t=ue(e.dataBase64).length;switch(h+=t,e.kind){case"image":l+=1,u+=t;break;case"document":m+=1,g+=t;break;case"spreadsheet":d+=1,p+=t}}l>8&&t.addIssue({code:"custom",message:"Too many images (max 8)",path:["attachments"]}),m>2&&t.addIssue({code:"custom",message:"Too many documents (max 2)",path:["attachments"]}),d>2&&t.addIssue({code:"custom",message:"Too many spreadsheets (max 2)",path:["attachments"]});const f=l<=8&&m<=2&&d<=2;s.length>0&&f&&(u>oe&&t.addIssue({code:"custom",message:"Combined image base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),g>ce&&t.addIssue({code:"custom",message:"Combined document base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),p>me&&t.addIssue({code:"custom",message:"Combined spreadsheet base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),h>de&&t.addIssue({code:"custom",message:"Combined attachment base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}))});function ke(e){return{kind:"image",mimeType:e.mimeType.trim(),dataBase64:ue(e.dataBase64)}}function Se(e){return{kind:"document",mimeType:"application/pdf",dataBase64:ue(e.dataBase64)}}function Ce(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 Re=a.object({response:a.object({message:a.string()}),config:h,extractMeta:W.nullable(),lastAccuracyEvaluation:z.optional()}),Te=a.object({config:h,response:a.object({message:a.string(),steps:a.array(a.string())})}),Ee=P,Oe=a.enum(["deal-breaker","pro","con","family","continuity"]),Ie=a.object({kind:Oe,label:a.string(),weight:a.number(),reason:a.string()}),Ae=a.enum(["ok","disqualified"]),Pe=a.object({rank:a.number().int().positive(),type:E,score:a.number(),verdict:Ae,factors:a.array(Ie)}),Ue=a.object({config:h,chartFamily:C.optional(),metadata:$.optional()}),Be=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"]),Fe=a.object({kind:Be,message:a.string()}),qe=a.enum(["sum","avg","count","min","max"]),Me=a.object({dimensionName:a.string(),dimensionLabel:a.string(),measureName:a.string().nullable(),measureLabel:a.string().nullable(),fn:qe,chartType:E,score:a.number(),message:a.string()}),De=a.object({ranking:a.array(Pe),observations:a.array(Fe).optional().default([]),suggestions:a.array(Me).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()}),Ke=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."}),Le=a.enum(["layout","color_contrast","typography","clutter","encoding","labels_legends","title_caption","other"]),Ge=a.enum(["info","low","medium","high"]),We=a.object({category:Le,severity:Ge,observation:a.string(),rationale:a.string().optional(),suggestedChange:a.string().optional(),configPaths:a.array(a.string()).optional()}),ze=a.object({overallSummary:a.string(),overallSeverity:a.enum(["none","low","medium","high"]).optional(),issues:a.array(We)}),_e=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()}),He=a.object({capturedAt:a.string(),chartId:a.string()}),Je=a.object({response:a.object({message:a.string(),steps:a.array(a.string()),critiqueCommitted:a.boolean()}),critiqueReport:ze.nullable(),chartVisionAudit:He.nullable().optional().default(null),rubricScores:_e.nullable().optional().default(null)}),Xe="/api/v0";class Qe{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(`${Xe}/generate`,a,i,n),s=Te.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(`${Xe}/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(`${Xe}/narrate`,t,i,n);return A.parse(e)})}generateNarrativeStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${Xe}/narrate`,t,i)})}generateSuggestions(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Xe}/suggestions`,t,i,n);return P.parse(e)})}generateSuggestionsStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${Xe}/suggestions`,t,i)})}generateExploration(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Xe}/explore`,t,i,n);return F.parse(e)})}generateExplorationStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${Xe}/explore`,t,i)})}generateAnnotations(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Xe}/annotate`,t,i,n);return q.parse(e)})}generateAnnotationsStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${Xe}/annotate`,t,i)})}generateMutation(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Xe}/mutate`,t,i,n);return M.parse(e)})}generateMutationStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${Xe}/mutate`,t,i)})}generatePipeline(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Xe}/pipeline`,t,i,n);return L.parse(e)})}generatePipelineStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${Xe}/pipeline`,t,i)})}evaluate(t,i){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Xe}/evaluate`,t,void 0,i);return De.parse(e)})}judge(t,i){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Xe}/judge`,t,void 0,i);return Je.parse(e)})}judgeStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${Xe}/judge`,t,i)})}extractFromProse(t,i,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Xe}/extract`,t,i,n);return Re.parse(e)})}extractFromProseStream(t,i){return e(this,void 0,void 0,function*(){return this.client.stream(`${Xe}/extract`,t,i)})}uploadAttachment(t,i,n){return e(this,void 0,void 0,function*(){const e=new FormData,r=null==i?void 0:i.filename;"undefined"!=typeof File&&t instanceof File?e.append("file",t):r?e.append("file",t,r):e.append("file",t,"upload"),r&&e.append("filename",r);const a=yield this.client.uploadMultipart(`${Xe}/attachments`,e,n);return je.parse(a)})}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{qe as AggregationFunctionSchema,Me as AggregationSuggestionSchema,E as AiChartTypeEnum,je as AttachmentUploadResponseSchema,Le as ChartCritiqueIssueCategorySchema,We as ChartCritiqueIssueSchema,Ge as ChartCritiqueIssueSeveritySchema,ze as ChartCritiqueReportSchema,C as ChartFamilySchema,Pe as ChartFitEntrySchema,Oe as ChartFitFactorKindSchema,Ie as ChartFitFactorSchema,Ae as ChartFitVerdictSchema,Ne as ChartJudgeRubricSchema,Be as DataObservationKindSchema,Fe as DataObservationSchema,Ue as EvaluateParamsSchema,De as EvaluateResponseSchema,b as ExecutionModeSchema,U as ExploreFindingSchema,B as ExploreStorySchema,z as ExtractAccuracyEvaluationSchema,we as ExtractAttachmentInputSchema,fe as ExtractAttachmentKindSchema,G as ExtractConfidenceSchema,$e as ExtractFromProseParamsSchema,Re as ExtractFromProseResponseSchema,W as ExtractMetaSchema,q as GenerateAnnotationsResponseSchema,F as GenerateExplorationResponseSchema,Te as GenerateGraphResponseSchema,Ee as GenerateGraphSuggestionsResponseSchema,M as GenerateMutationResponseSchema,I as GenerateNarrativeParamsSchema,A as GenerateNarrativeResponseSchema,K as GeneratePipelineParamsSchema,L as GeneratePipelineResponseSchema,T as GenerateSuggestionsParamsSchema,P as GenerateSuggestionsResponseSchema,R as GraphGenerationRequestSchema,Qe as GraphyAiSdk,o as GraphyApiError,j as InvocationBudgetSchema,f as InvocationEffortSchema,Ke as JudgeParamsSchema,Je 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,Q as MAX_EXTRACT_DOCUMENTS,Y as MAX_EXTRACT_DOCUMENTS_TOTAL_DECODED_BYTES,V as MAX_EXTRACT_DOCUMENT_DECODED_BYTES,H as MAX_EXTRACT_IMAGES,X as MAX_EXTRACT_IMAGES_TOTAL_DECODED_BYTES,J as MAX_EXTRACT_IMAGE_DECODED_BYTES,Z as MAX_EXTRACT_SPREADSHEETS,te as MAX_EXTRACT_SPREADSHEETS_TOTAL_DECODED_BYTES,ee as MAX_EXTRACT_SPREADSHEET_DECODED_BYTES,_ as MAX_SOURCE_TEXT_LENGTH,S as MAX_USER_PROMPT_LENGTH,$ as MetadataSchema,k as MutateNarrationReceiptSchema,D as PipelineAgentNameSchema,N as PipelineStageReasoningSchema,_e as RubricScoresSchema,y as StorytellingEffortSchema,O as SuggestionSchema,ke as buildImageAttachment,Se as buildPdfAttachment,Ce as buildSpreadsheetAttachment,l as isCompleteEvent,m as isErrorEvent,s as isGraphyApiError,d as isPreviewEvent,c as isProgressEvent,u as isReasoningEvent};
|
|
1
|
+
import{__awaiter as e,__asyncValues as t,__asyncGenerator as n,__await as i,__rest as r}from"tslib";import{z as a}from"zod";class o extends Error{constructor(e,t){var n;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!==(n=null==t?void 0:t.retryable)&&void 0!==n&&n}}const s=e=>e instanceof o,l=e=>"progress"===e.type,c=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 l(e)}static isCompleteEvent(e){return c(e)}static isErrorEvent(e){return m(e)}stream(t,n,i){return e(this,void 0,void 0,function*(){const e=yield this.makeRequest(t,n,i);return this.parseSSE(e)})}fetch(n,i,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: ${n}`);try{const y=yield this.makeRequest(n,i,a),v=y.headers.get("content-type");if(null==v?void 0:v.includes("text/event-stream")){try{for(var h,f=!0,b=t(this.parseSSE(y));!(e=(h=yield b.next()).done);f=!0){u=h.value,f=!1;const e=u;if(l(e)&&r&&r(e),c(e))return e.data;if(m(e)){const t=Date.now()-p;throw this.logger.error(`${this.tag} Server error: ${n} ${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=b.return)||(yield d.call(b))}finally{if(s)throw s.error}}const i=Date.now()-p;throw this.logger.error(`${this.tag} Stream incomplete: ${n} ${i}ms`),new o("Stream ended without completion")}return yield y.json()}catch(e){const t=Date.now()-p;if(this.logger.error(`${this.tag} Fetch failed: ${n} ${t}ms`,e),e instanceof o)throw e;throw e}finally{const e=Date.now()-p;this.logger.debug(`${this.tag} Fetch completed: ${n} ${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}}})}uploadMultipart(t,n,i){return e(this,void 0,void 0,function*(){const e=yield this.makeMultipartRequest(t,n,i);return yield e.json()})}sleep(t){return e(this,void 0,void 0,function*(){return new Promise(e=>setTimeout(e,t))})}parseSSE(e){return n(this,arguments,function*(){if(!e.body)throw new o("Response body is null");const t=e.body.getReader(),n=new TextDecoder;let r="",a="",s="";try{for(;;){const{done:e,value:o}=yield i(t.read());if(e)break;r+=n.decode(o,{stream:!0});const l=r.split(/\r?\n/);r=l.pop()||"";for(const e of l)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 n=e;t=Object.assign({type:"progress"},n)}else if("complete"===a)t={type:"complete",data:e};else if("error"===a){const n=e;t=Object.assign({type:"error"},n)}else if("preview"===a){const n=e;t=Object.assign(Object.assign({},n),{type:"preview"})}else{if("reasoning"!==a){a="",s="";continue}{const n=e;t=Object.assign(Object.assign({},n),{type:"reasoning"})}}if(yield yield i(t),"complete"===a||"error"===a)return yield i(void 0)}catch(e){this.logger.warn("Invalid SSE data format",s)}a="",s=""}}}finally{t.releaseLock()}})}makeRequest(t,n,i){return e(this,arguments,void 0,function*(e,t,n,i=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 ${i}/${this.retryConfig.attempts}: ${a}`);const s=new AbortController,l=setTimeout(()=>s.abort(),this.timeout),c=()=>s.abort();n&&n.addEventListener("abort",c);try{const l=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(!l.ok){let a,s=`HTTP ${l.status}`;try{const e=yield l.json();if("object"==typeof e&&null!==e){const t=e;"string"==typeof t.message?s=t.message:"string"==typeof t.error&&(s=t.error),"string"==typeof t.code&&(a=t.code)}}catch(e){}const c=!("QUOTA_EXCEEDED"===a)&&(l.status>=500||429===l.status),m=new o(s,{status:l.status,code:a,retryable:c});if(c&&i<this.retryConfig.attempts&&!(null==n?void 0:n.aborted)){const a=this.retryConfig.delay*Math.pow(this.retryConfig.backoff,i-1);return this.logger.warn(`${this.tag} Retrying ${e} in ${a}ms (attempt ${i+1})`),yield this.sleep(a),this.makeRequest(e,t,n,i+1,r)}throw this.logger.error(`${this.tag} Request failed: ${e} (${l.status}) - ${s}`),m}return this.logger.debug(`${this.tag} Connected: ${e}`),l}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(i<this.retryConfig.attempts&&!(null==n?void 0:n.aborted)){const a=this.retryConfig.delay*Math.pow(this.retryConfig.backoff,i-1);return this.logger.warn(`${this.tag} Network error, retrying ${e} in ${a}ms`),yield this.sleep(a),this.makeRequest(e,t,n,i+1,r)}throw this.logger.error(`${this.tag} Network error: ${e}`,a),new o("Network error",{retryable:!0})}finally{clearTimeout(l),n&&n.removeEventListener("abort",c)}})}makeMultipartRequest(t,n,i){return e(this,arguments,void 0,function*(e,t,n,i=1){if(!e.startsWith("/"))throw new o("Invalid endpoint: must start with /");const r=new URL(e,this.baseUrl);if(r.origin!==new URL(this.baseUrl).origin)throw new o("Endpoint resolved to unexpected origin");const a=new AbortController,s=setTimeout(()=>a.abort(),this.timeout),l=()=>a.abort();n&&n.addEventListener("abort",l);try{const s=yield fetch(r,{method:"POST",headers:{Accept:"application/json",Authorization:`Bearer ${this.apiKey}`,"User-Agent":"Graphy-SDK/1.0"},body:t,signal:a.signal});if(!s.ok){let r,a=`HTTP ${s.status}`;try{const e=yield s.json();if("object"==typeof e&&null!==e){const t=e;"string"==typeof t.message?a=t.message:"string"==typeof t.error&&(a=t.error),"string"==typeof t.code&&(r=t.code)}}catch(e){}const l=s.status>=500||429===s.status,c=new o(a,{status:s.status,code:r,retryable:l});if(l&&i<this.retryConfig.attempts&&!(null==n?void 0:n.aborted)){const r=this.retryConfig.delay*Math.pow(this.retryConfig.backoff,i-1);return yield this.sleep(r),this.makeMultipartRequest(e,t,n,i+1)}throw c}return s}catch(r){if(r instanceof o)throw r;if(r instanceof Error&&"AbortError"===r.name)throw r;if(i<this.retryConfig.attempts&&!(null==n?void 0:n.aborted)){const r=this.retryConfig.delay*Math.pow(this.retryConfig.backoff,i-1);return yield this.sleep(r),this.makeMultipartRequest(e,t,n,i+1)}throw new o("Network error",{retryable:!0})}finally{clearTimeout(s),n&&n.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"]),b=a.enum(["none","low","medium","high"]),y=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(),trackUsage:a.boolean().optional()}),k=a.object({wallClockMs:a.number(),inputTokens:a.number(),inputCachedTokens:a.number(),inputUncachedTokens:a.number(),outputTokens:a.number(),totalTokens:a.number(),costUsd:a.number().nullable(),costEnforcementSkipped:a.boolean().optional()}),$=a.object({limits:j,consumed:k,exceeded:a.boolean(),exceededDimensions:a.array(a.enum(["wallClockMs","totalTokens","costUsd"])),exceededSummary:a.string().optional()}),S=a.object({callId:a.string().max(256).optional(),locale:p.optional(),effort:f.optional(),storytellingEffort:b.optional().default("low"),budget:j.optional(),executionMode:y.optional(),enforceTableRowCap:a.boolean().optional()}),C=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()}),T=a.object({runId:a.string(),trackingId:a.string(),callId:a.string().optional()}),R=1e4,E=a.enum(["comparison","relationship","distribution","composition"]),I=a.object({config:h,userPrompt:a.string().max(R).optional().default(""),metadata:S.optional(),chartFamily:E.optional()}),O=I.extend({maxSuggestionCount:a.number().int().min(1).max(4).optional()}),A=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:A,summary:a.string()}),U=I.extend({userPrompt:a.string().max(R),mutationReceipt:C.optional(),exploreFindingSummary:a.string().max(500).optional()}),B=a.object({response:a.object({message:a.string()}),config:h,run:T.optional()}),M=a.object({suggestions:a.array(P),run:T.optional()}),F=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:E.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.")}),q=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(F).describe("Child findings, sorted by quadrant score desc.")}),D=a.object({response:a.object({message:a.string(),steps:a.array(a.string())}),stories:a.array(q),run:T.optional()});I.extend({mutationReceipt:C.optional()});const N=a.object({response:a.object({message:a.string(),steps:a.array(a.string())}),config:h,run:T.optional()}),K=a.object({response:a.object({message:a.string(),steps:a.array(a.string())}),config:h,mutationReceipt:C.optional(),warnings:a.array(a.string()).optional(),budget:$.optional(),run:T.optional()}),L=a.enum(["explore","mutate","narrate","annotate"]),G=a.object({agent:L,summary:a.string(),steps:a.array(a.string()).optional()}),W=I.extend({userPrompt:a.string().max(R),stages:a.array(L).min(1).refine(e=>new Set(e).size===e.length,{message:"Duplicate pipeline stages are not allowed"}),exploreFindingSummary:a.string().max(500).optional()}),z=K.extend({reasoning:a.array(G),stories:a.array(q).optional()}),_=a.enum(["high","medium","low"]),H=a.object({confidence:_,needsUserInput:a.boolean(),warnings:a.array(a.string()),cellConfidence:a.array(a.object({rowIndex:a.number().int().nonnegative(),columnKey:a.string(),confidence:_,quote:a.string().optional()})).optional()}),J=a.object({score:a.number().min(0).max(1),issues:a.array(a.string()),sufficient:a.boolean(),summary:a.string()}),X=5e5,Q=8,V=2097152,Y=7340032,Z=2,ee=6291456,te=8388608,ne=2,ie=ee,re=te,ae=12582912,oe=12;function se(e){return 4*Math.ceil(e/3)}const le=se(V),ce=se(Y),me=se(ee),de=se(te),ue=se(ie),ge=se(re),pe=se(ae);function he(e){return e.replace(/\s+/g,"")}function fe(e){const t=he(e);return 0!==t.length&&t.length%4==0&&/^[A-Za-z0-9+/]+={0,2}$/.test(t)}const be=/^image\/(png|jpeg|jpg|webp|gif)$/i,ye=a.object({mimeType:a.string().min(1).refine(e=>be.test(e.trim()),{message:"mimeType must be image/png, image/jpeg, image/jpg, image/webp, or image/gif"}),dataBase64:a.string().min(1).max(le).refine(fe,{message:"dataBase64 must be standard base64 (RFC 4648)"})}),ve=a.enum(["image","document","spreadsheet"]),we=ye.extend({kind:a.literal("image")}),xe=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(me).refine(fe,{message:"dataBase64 must be standard base64 (RFC 4648)"})}),je=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(ue).refine(fe,{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"]}),ke=a.discriminatedUnion("kind",[we,xe,je]),$e=a.string().regex(/^graphy:\/\/attachments\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,"attachmentRefs items must be graphy://attachments/{uuid} URIs"),Se=a.object({id:a.string().uuid(),uri:a.string(),kind:ve,mimeType:a.string(),filename:a.string().optional(),sizeBytes:a.number().int().positive(),expiresAt:a.string().datetime()}),Ce=a.object({sourceText:a.string().max(X).default(""),images:a.array(ye).max(8).optional().describe('@deprecated Use attachments[] with kind: "image" instead. Will be removed in a future major release.'),attachments:a.array(ke).max(12).optional(),attachmentRefs:a.array($e).max(12).optional(),metadata:S.optional()}).superRefine((e,t)=>{var n,i,r;const a=e.sourceText.trim(),o=null!==(n=e.images)&&void 0!==n?n:[],s=null!==(i=e.attachments)&&void 0!==i?i:[],l=null!==(r=e.attachmentRefs)&&void 0!==r?r:[];if(o.length>0&&s.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(l.length>0&&s.length>0)return void t.addIssue({code:"custom",message:"Use either `attachmentRefs` or inline `attachments`, not both.",path:["attachmentRefs"]});if(l.length>0&&o.length>0)return void t.addIssue({code:"custom",message:"Use either `attachmentRefs` or deprecated `images`, not both.",path:["attachmentRefs"]});if(0===a.length&&0===o.length&&0===s.length&&0===l.length)return void t.addIssue({code:"custom",message:"Provide non-empty sourceText and/or at least one attachment",path:["sourceText"]});if(l.length>0)return;if(o.length>0){o.reduce((e,t)=>e+he(t.dataBase64).length,0)>ce&&t.addIssue({code:"custom",message:"Combined image base64 exceeds maximum length for this API (must fit server decode limits)",path:["images"]})}let c=0,m=0,d=0,u=0,g=0,p=0,h=0;for(const e of s){const t=he(e.dataBase64).length;switch(h+=t,e.kind){case"image":c+=1,u+=t;break;case"document":m+=1,g+=t;break;case"spreadsheet":d+=1,p+=t}}c>8&&t.addIssue({code:"custom",message:"Too many images (max 8)",path:["attachments"]}),m>2&&t.addIssue({code:"custom",message:"Too many documents (max 2)",path:["attachments"]}),d>2&&t.addIssue({code:"custom",message:"Too many spreadsheets (max 2)",path:["attachments"]});const f=c<=8&&m<=2&&d<=2;s.length>0&&f&&(u>ce&&t.addIssue({code:"custom",message:"Combined image base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),g>de&&t.addIssue({code:"custom",message:"Combined document base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),p>ge&&t.addIssue({code:"custom",message:"Combined spreadsheet base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}),h>pe&&t.addIssue({code:"custom",message:"Combined attachment base64 exceeds maximum length for this API (must fit server decode limits)",path:["attachments"]}))});function Te(e){return{kind:"image",mimeType:e.mimeType.trim(),dataBase64:he(e.dataBase64)}}function Re(e){return{kind:"document",mimeType:"application/pdf",dataBase64:he(e.dataBase64)}}function Ee(e){return Object.assign({kind:"spreadsheet",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",dataBase64:he(e.dataBase64)},void 0!==e.filename?{filename:e.filename.trim()}:{})}const Ie=a.object({response:a.object({message:a.string()}),config:h,extractMeta:H.nullable(),lastAccuracyEvaluation:J.optional(),run:T.optional()}),Oe=a.object({config:h,response:a.object({message:a.string(),steps:a.array(a.string())}),run:T.optional()}),Ae=M,Pe=a.enum(["deal-breaker","pro","con","family","continuity"]),Ue=a.object({kind:Pe,label:a.string(),weight:a.number(),reason:a.string()}),Be=a.enum(["ok","disqualified"]),Me=a.object({rank:a.number().int().positive(),type:A,score:a.number(),verdict:Be,factors:a.array(Ue)}),Fe=a.object({config:h,chartFamily:E.optional(),metadata:S.optional()}),qe=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"]),De=a.object({kind:qe,message:a.string()}),Ne=a.enum(["sum","avg","count","min","max"]),Ke=a.object({dimensionName:a.string(),dimensionLabel:a.string(),measureName:a.string().nullable(),measureLabel:a.string().nullable(),fn:Ne,chartType:A,score:a.number(),message:a.string()}),Le=a.object({ranking:a.array(Me),observations:a.array(De).optional().default([]),suggestions:a.array(Ke).optional().default([]),run:T.optional()}),Ge=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()}),We=a.object({config:h.optional(),chartImage:a.string().optional(),data:a.unknown().optional(),rubric:Ge.optional(),userPrompt:a.string().optional(),metadata:S.optional()}).refine(e=>void 0!==e.config||void 0!==e.chartImage,{message:"Provide a chart config or a chart image to judge."}),ze=a.enum(["layout","color_contrast","typography","clutter","encoding","labels_legends","title_caption","other"]),_e=a.enum(["info","low","medium","high"]),He=a.object({category:ze,severity:_e,observation:a.string(),rationale:a.string().optional(),suggestedChange:a.string().optional(),configPaths:a.array(a.string()).optional()}),Je=a.object({overallSummary:a.string(),overallSeverity:a.enum(["none","low","medium","high"]).optional(),issues:a.array(He)}),Xe=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()}),Qe=a.object({capturedAt:a.string(),chartId:a.string()}),Ve=a.object({response:a.object({message:a.string(),steps:a.array(a.string()),critiqueCommitted:a.boolean()}),critiqueReport:Je.nullable(),chartVisionAudit:Qe.nullable().optional().default(null),rubricScores:Xe.nullable().optional().default(null),run:T.optional()}),Ye="/api/v0";class Ze{constructor(e){this.client=new g(e)}generateGraph(t,n,i){return e(this,void 0,void 0,function*(){const{storytellingOptions:e}=t,a=r(t,["storytellingOptions"]),o=yield this.client.fetch(`${Ye}/generate`,a,n,i),s=Oe.parse(o);return this.stripStorytelling(s,e)})}generateGraphStream(t,n){return e(this,void 0,void 0,function*(){const{storytellingOptions:e}=t,i=r(t,["storytellingOptions"]),a=yield this.client.stream(`${Ye}/generate`,i,n);return this.wrapStreamWithStorytellingStripping(a,e)})}generateNarrative(t,n,i){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Ye}/narrate`,t,n,i);return B.parse(e)})}generateNarrativeStream(t,n){return e(this,void 0,void 0,function*(){return this.client.stream(`${Ye}/narrate`,t,n)})}generateSuggestions(t,n,i){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Ye}/suggestions`,t,n,i);return M.parse(e)})}generateSuggestionsStream(t,n){return e(this,void 0,void 0,function*(){return this.client.stream(`${Ye}/suggestions`,t,n)})}generateExploration(t,n,i){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Ye}/explore`,t,n,i);return D.parse(e)})}generateExplorationStream(t,n){return e(this,void 0,void 0,function*(){return this.client.stream(`${Ye}/explore`,t,n)})}generateAnnotations(t,n,i){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Ye}/annotate`,t,n,i);return N.parse(e)})}generateAnnotationsStream(t,n){return e(this,void 0,void 0,function*(){return this.client.stream(`${Ye}/annotate`,t,n)})}generateMutation(t,n,i){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Ye}/mutate`,t,n,i);return K.parse(e)})}generateMutationStream(t,n){return e(this,void 0,void 0,function*(){return this.client.stream(`${Ye}/mutate`,t,n)})}generatePipeline(t,n,i){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Ye}/pipeline`,t,n,i);return z.parse(e)})}generatePipelineStream(t,n){return e(this,void 0,void 0,function*(){return this.client.stream(`${Ye}/pipeline`,t,n)})}evaluate(t,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Ye}/evaluate`,t,void 0,n);return Le.parse(e)})}judge(t,n){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Ye}/judge`,t,void 0,n);return Ve.parse(e)})}judgeStream(t,n){return e(this,void 0,void 0,function*(){return this.client.stream(`${Ye}/judge`,t,n)})}extractFromProse(t,n,i){return e(this,void 0,void 0,function*(){const e=yield this.client.fetch(`${Ye}/extract`,t,n,i);return Ie.parse(e)})}extractFromProseStream(t,n){return e(this,void 0,void 0,function*(){return this.client.stream(`${Ye}/extract`,t,n)})}uploadAttachment(t,n,i){return e(this,void 0,void 0,function*(){const e=new FormData,r=null==n?void 0:n.filename;"undefined"!=typeof File&&t instanceof File?e.append("file",t):r?e.append("file",t,r):e.append("file",t,"upload"),r&&e.append("filename",r);const a=yield this.client.uploadMultipart(`${Ye}/attachments`,e,i);return Se.parse(a)})}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 n(this,arguments,function*(){var n,a,o,s;try{for(var l,m=!0,d=t(e);!(n=(l=yield i(d.next())).done);m=!0){s=l.value,m=!1;const e=s;if(c(e)){const t=this.stripStorytelling(e.data,r);yield yield i(Object.assign(Object.assign({},e),{data:t}))}else yield yield i(e)}}catch(e){a={error:e}}finally{try{m||n||!(o=d.return)||(yield i(o.call(d)))}finally{if(a)throw a.error}}})}}export{Ne as AggregationFunctionSchema,Ke as AggregationSuggestionSchema,A as AiChartTypeEnum,Se as AttachmentUploadResponseSchema,ze as ChartCritiqueIssueCategorySchema,He as ChartCritiqueIssueSchema,_e as ChartCritiqueIssueSeveritySchema,Je as ChartCritiqueReportSchema,E as ChartFamilySchema,Me as ChartFitEntrySchema,Pe as ChartFitFactorKindSchema,Ue as ChartFitFactorSchema,Be as ChartFitVerdictSchema,Ge as ChartJudgeRubricSchema,qe as DataObservationKindSchema,De as DataObservationSchema,Fe as EvaluateParamsSchema,Le as EvaluateResponseSchema,y as ExecutionModeSchema,F as ExploreFindingSchema,q as ExploreStorySchema,J as ExtractAccuracyEvaluationSchema,ke as ExtractAttachmentInputSchema,ve as ExtractAttachmentKindSchema,_ as ExtractConfidenceSchema,Ce as ExtractFromProseParamsSchema,Ie as ExtractFromProseResponseSchema,H as ExtractMetaSchema,N as GenerateAnnotationsResponseSchema,D as GenerateExplorationResponseSchema,Oe as GenerateGraphResponseSchema,Ae as GenerateGraphSuggestionsResponseSchema,K as GenerateMutationResponseSchema,U as GenerateNarrativeParamsSchema,B as GenerateNarrativeResponseSchema,W as GeneratePipelineParamsSchema,z as GeneratePipelineResponseSchema,O as GenerateSuggestionsParamsSchema,M as GenerateSuggestionsResponseSchema,I as GraphGenerationRequestSchema,Ze as GraphyAiSdk,o as GraphyApiError,j as InvocationBudgetSchema,f as InvocationEffortSchema,We as JudgeParamsSchema,Ve as JudgeResponseSchema,x as MAX_BUDGET_COST_USD,w as MAX_BUDGET_TOTAL_TOKENS,v as MAX_BUDGET_WALL_CLOCK_MS,oe as MAX_EXTRACT_ATTACHMENTS,ae as MAX_EXTRACT_ATTACHMENTS_COMBINED_DECODED_BYTES,Z as MAX_EXTRACT_DOCUMENTS,te as MAX_EXTRACT_DOCUMENTS_TOTAL_DECODED_BYTES,ee as MAX_EXTRACT_DOCUMENT_DECODED_BYTES,Q as MAX_EXTRACT_IMAGES,Y as MAX_EXTRACT_IMAGES_TOTAL_DECODED_BYTES,V as MAX_EXTRACT_IMAGE_DECODED_BYTES,ne as MAX_EXTRACT_SPREADSHEETS,re as MAX_EXTRACT_SPREADSHEETS_TOTAL_DECODED_BYTES,ie as MAX_EXTRACT_SPREADSHEET_DECODED_BYTES,X as MAX_SOURCE_TEXT_LENGTH,R as MAX_USER_PROMPT_LENGTH,S as MetadataSchema,C as MutateNarrationReceiptSchema,L as PipelineAgentNameSchema,G as PipelineStageReasoningSchema,Xe as RubricScoresSchema,T as RunContextSchema,b as StorytellingEffortSchema,P as SuggestionSchema,Te as buildImageAttachment,Re as buildPdfAttachment,Ee as buildSpreadsheetAttachment,c as isCompleteEvent,m as isErrorEvent,s as isGraphyApiError,d as isPreviewEvent,l 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.6.
|
|
4
|
+
"version": "1.6.2-beta.1782148741262",
|
|
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.6.
|
|
21
|
+
"@graphysdk/core": "1.6.2-beta.1782148741262"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@rollup/plugin-commonjs": "^28.0.6",
|