@aiquants/enrichment-core 0.3.3 → 0.4.0
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/README.md +86 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +11272 -3012
- package/dist/index.d.ts +11272 -3012
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var g=class extends Error{statusCode;responseBody;parsedBody;constructor(t,n,i,l){super(t),this.name="EnrichmentClientError",this.statusCode=n,this.responseBody=i,this.parsedBody=l}},N=class{baseUrl;apiKey;fetchFn;timeoutMs;constructor(t){if(!t||typeof t.baseUrl!="string"||t.baseUrl.trim().length===0)throw new Error("baseUrl is required and must be a non-empty string for EnrichmentClient.");let n=t.baseUrl.trim().replace(/\/$/,"");if(t.apiKey&&n.startsWith("http://")&&!n.includes("localhost")&&!n.includes("127.0.0.1"))throw new Error("Security Violation: Transmitting Bearer tokens over unencrypted HTTP to non-localhost hosts is strictly prohibited.");this.baseUrl=n,this.apiKey=t.apiKey,this.fetchFn=t.fetchFn??fetch,this.timeoutMs=t.timeoutMs&&t.timeoutMs>0?t.timeoutMs:3e4}async request(t,n,i){let l=`${this.baseUrl}${t}`,c={Accept:"application/json","Content-Type":"application/json","X-Tenant-Id":n};this.apiKey&&(c.Authorization=`Bearer ${this.apiKey}`);let d=new AbortController,m=setTimeout(()=>d.abort(),this.timeoutMs),f;try{f=await this.fetchFn(l,{method:"POST",headers:c,body:JSON.stringify(i),signal:d.signal})}catch(y){let I=y instanceof Error?y.message:String(y);throw new g(`Network request failed for POST ${l}: ${I}`,0,"")}finally{clearTimeout(m)}if(!f.ok){let y=await f.text().catch(()=>""),I;try{I=JSON.parse(y)}catch{}throw new g(`API request failed with status ${f.status}: ${y}`,f.status,y,I)}let R=await f.text().catch(()=>"");if(R.trim().length!==0)try{return JSON.parse(R)}catch(y){let I=y instanceof Error?y.message:String(y);throw new g(`Failed to parse response JSON from ${l}: ${I}`,f.status,R)}}};import{z as o}from"zod";import{z as B}from"zod";var ge=B.enum(["google_cloud","google_vision","yomitoku_local","faster_whisper_local","google_speech","ollama_local","openai","anthropic","azure_openai","bedrock","custom_openai_compatible"]),L=B.enum(["PUBLIC","INTERNAL","DEPARTMENT","CONFIDENTIAL","RESTRICTED"]),v="RESTRICTED";var Ht={rrfK:{min:1,max:200,default:60},alpha:{min:0,max:1,default:.7},threshold:{min:0,max:1},limit:{min:1,max:50,default:10}},$=L.options.filter(e=>e!==v);if($.length===0)throw new Error("The confidentiality vocabulary left nothing filterable after removing the quarantined level; a validator built from this list would reject every request.");var Yt=$,V=["KEYWORD","SPARSE","DENSE","HYBRID","GRAPH_TRAVERSE"],C={KEYWORD:{dense:!1,sparse:!1,graph:!1,lexical:!0},SPARSE:{dense:!1,sparse:!0,graph:!1,lexical:!1},DENSE:{dense:!0,sparse:!1,graph:!1,lexical:!1},HYBRID:{dense:!0,sparse:!0,graph:!0,lexical:!0},GRAPH_TRAVERSE:{dense:!1,sparse:!1,graph:!0,lexical:!1}};function jt(e){let t=C[e];return t.dense||t.sparse||t.graph}function Bt(e){let t=C[e];return t.dense&&!t.sparse}function $t(e,t){let n=C[e],i=(n.dense||n.sparse)&&t.vector,l=n.graph&&t.graph;return i||l?i?l?{mode:e,discardGraph:!1}:n.dense&&n.sparse?{mode:e,discardGraph:!0}:{mode:n.dense?"DENSE":"SPARSE",discardGraph:!1}:{mode:"GRAPH_TRAVERSE",discardGraph:!1}:null}function Vt(e){let t=C[e];return[t.dense,t.sparse,t.graph,t.lexical].filter(Boolean).length>1}var _e=["vector","graph"],Ae=["empty_query","caller_token_unavailable","time_window_unsupported"],Ne=["vector_tier_not_configured","graph_tier_not_configured","no_active_vector_collection","vector_collections_missing"],Ce=["remote_tiers_unavailable","remote_tiers_timed_out","remote_tiers_refused_caller","remote_tiers_rejected_request","remote_tiers_failed","remote_tiers_not_executed","vector_search_disabled","graph_search_disabled"],Xt=[...Ae,...Ne,...Ce,..._e.map(e=>`circuit_breaker_open:${e}`)];var Te=o.string().trim().min(1,"tenant_id must be a non-empty string"),Wt=o.string().trim().min(1,"file_uri must be a non-empty string"),Zt=o.enum(["PENDING","EXTRACTING","ENRICHING","PROJECTING","SYNCED","FAILED_EXTRACT","FAILED_ENRICH","FAILED_VECTOR","FAILED_GRAPH"]),en=o.object({page:o.number().int().positive().optional(),x:o.number().nonnegative().optional(),y:o.number().nonnegative().optional(),width:o.number().positive().optional(),height:o.number().positive().optional(),start_sec:o.number().nonnegative().optional(),end_sec:o.number().nonnegative().optional(),frame_index:o.number().int().nonnegative().optional(),timestamp_sec:o.number().nonnegative().optional(),scene_confidence:o.number().min(0).max(1).optional()}),be=o.object({title:o.string().trim().min(1),start_sec:o.number().nonnegative(),end_sec:o.number().nonnegative(),summary:o.string()}),xe=o.object({start_sec:o.number().nonnegative(),end_sec:o.number().nonnegative(),speaker:o.string().trim().min(1),text:o.string()}),De=o.object({label:o.string(),value:o.number(),currency:o.string()}),tn=o.object({document_type:o.string().optional(),title:o.string().optional(),organization:o.string().optional(),key_entities:o.array(o.string()).optional(),dates:o.array(o.string()).optional(),amounts:o.array(De).optional(),media_type:o.enum(["video","audio"]).optional(),duration_sec:o.number().nonnegative().optional(),chapters:o.array(be).optional(),transcript_segments:o.array(xe).optional()}),nn=o.enum(["CLOSED","OPEN","HALF_OPEN"]),Oe=o.enum(V),Pe=o.object({circuit_breaker_status:o.string(),quality_tier:o.string(),latency_ms:o.number().nonnegative(),total_hits:o.number().int().nonnegative(),fallback_applied:o.boolean(),degraded_reason:o.string().nullable()}),Fe=o.enum(["CONTRACT_LEGAL","EMAIL_THREAD","DAILY_REPORT","FINANCIAL_REPORT","TECHNICAL_SPEC","MASTER_DATA","MEDIA_ASSET","GENERAL_DOCUMENT"]),rn=o.enum(["hierarchical","conversation","section","fixed_size","table_aware","semantic","none","multimodal"]),Le=o.object({metadata_id:o.number().int().positive(),chunk_index:o.number().int().nonnegative(),text:o.string(),score:o.number()}),ve=o.object({metadata_id:o.number().int().positive(),relation:o.string(),target_name:o.string()}),X=o.object({query:o.string().trim().min(1,"query must not be empty"),tenant_id:Te,domain_key:Fe.optional(),limit:o.number().int().positive().optional(),department_id:o.number().int().positive().optional(),search_mode:Oe.optional(),strategy_id:o.number().int().positive().optional()}).strict(),q=o.object({hits:o.array(Le),graph_hits:o.array(ve),tiers:o.record(o.string(),o.boolean()),metadata:Pe});var J=class extends N{async search(t){let n=X.parse(t),i=await this.request("/ai/search/hybrid",n.tenant_id,n);return q.parse(i)}};var te=["email","pdf","office","image","media","text","google_native","other"],pn={email:"\u30E1\u30FC\u30EB",pdf:"PDF",office:"Office \u6587\u66F8",image:"\u753B\u50CF",media:"\u97F3\u58F0\u30FB\u52D5\u753B",text:"\u30C6\u30AD\u30B9\u30C8",google_native:"Google \u30CD\u30A4\u30C6\u30A3\u30D6",other:"\u305D\u306E\u4ED6"},ke=[["message/rfc822","email"],["application/pdf","pdf"],["application/vnd.openxmlformats-officedocument.*","office"],["application/msword","office"],["application/vnd.ms-excel","office"],["application/vnd.ms-powerpoint","office"],["application/vnd.google-apps.*","google_native"],["image/svg+xml","text"],["image/emf","other"],["image/x-emf","other"],["image/wmf","other"],["image/x-wmf","other"],["image/*","image"],["audio/*","media"],["video/*","media"],["text/*","text"],["application/json","text"],["application/xml","text"]];function dn(e){let t=(e.split(";")[0]??"").trim().toLowerCase();for(let[n,i]of ke)if(n.endsWith("*")?t.startsWith(n.slice(0,-1)):t===n)return i;return"other"}var ne=["delete_child_assets","extract_text","analyze_media","extract_assets","ocr_children","ocr_document","resolve_body","enrich_document","project_to_indexes"],un=["EXTRACTING","ENRICHING","PROJECTING"],k=e=>({featureFlagKey:e,whenClosed:"skip",failureStatus:null}),Q=(e,t)=>({featureFlagKey:e,whenClosed:"fail",failureStatus:t}),re={delete_child_assets:{key:"delete_child_assets",label:"\u65E7\u7248\u306E\u5B50\u30A2\u30BB\u30C3\u30C8\u524A\u9664",description:"\u3053\u306E\u7248\u3088\u308A\u524D\u306E\u7248\u304C\u751F\u3093\u3060\u5B50\u30A2\u30BB\u30C3\u30C8\u3092\u4FDD\u7BA1\u5C64\u3068\u7D22\u5F15\u304B\u3089\u5916\u3059\u3002",endpoint:"/ai/assets/delete",phase:"EXTRACTING",failureStatus:"FAILED_EXTRACT",gates:[],capability:null,fanOut:null},extract_text:{key:"extract_text",label:"\u6587\u5B57\u5C64\u306E\u62BD\u51FA",description:"\u6587\u66F8\u304C\u6301\u3064\u6587\u5B57\u5C64 (PDF \u306E\u6587\u5B57\u30FBOffice \u306E\u672C\u6587\u30FB\u30E1\u30FC\u30EB\u306E\u672C\u6587\u3068\u898B\u51FA\u3057) \u3092\u8AAD\u307F\u3001\u4F4D\u7F6E\u60C5\u5831\u3068\u5171\u306B\u4FDD\u5B58\u3059\u308B\u3002",endpoint:"/ai/enrichment/extract",phase:"EXTRACTING",failureStatus:"FAILED_EXTRACT",gates:[],capability:null,fanOut:null},analyze_media:{key:"analyze_media",label:"\u30E1\u30C7\u30A3\u30A2\u89E3\u6790",description:"\u97F3\u58F0\u30FB\u52D5\u753B\u3092\u8EE2\u5199\u3057\u3001\u767A\u8A71\u533A\u9593\u4ED8\u304D\u306E\u30C1\u30E3\u30F3\u30AF\u3068\u30AD\u30FC\u30D5\u30EC\u30FC\u30E0\u6570\u3092\u8A18\u9332\u3059\u308B\u3002",endpoint:"/ai/media/analyze",phase:"EXTRACTING",failureStatus:"FAILED_EXTRACT",gates:[k("ENABLE_MEDIA_ANALYSIS")],capability:"transcription",fanOut:null},extract_assets:{key:"extract_assets",label:"\u5B50\u30A2\u30BB\u30C3\u30C8\u306E\u62BD\u51FA",description:"\u57CB\u3081\u8FBC\u307F\u753B\u50CF\u3084\u30E1\u30FC\u30EB\u306E\u6DFB\u4ED8\u3092\u5B50\u30A2\u30BB\u30C3\u30C8\u3068\u3057\u3066\u5207\u308A\u51FA\u3057\u3001\u6587\u66F8\u306E\u96A3\u306B\u4FDD\u7BA1\u3057\u3066\u767B\u9332\u3059\u308B\u3002",endpoint:"/ai/assets/extract",phase:"EXTRACTING",failureStatus:"FAILED_EXTRACT",gates:[k("ENABLE_ASSET_EXTRACTION")],capability:"asset_extraction",fanOut:null},ocr_children:{key:"ocr_children",label:"\u5B50\u30A2\u30BB\u30C3\u30C8\u306E\u8AAD\u307F\u53D6\u308A",description:"\u5207\u308A\u51FA\u3057\u305F\u5B50\u30A2\u30BB\u30C3\u30C8\u3092\u62BD\u51FA\u9806\u306B 1 \u4EF6\u305A\u3064\u8AAD\u307F\u3001\u6587\u5B57\u5C64\u3092\u8AAD\u3081\u308B\u5B50 (\u30C6\u30AD\u30B9\u30C8\u30FB\u30E1\u30FC\u30EB\u30FBOffice\u30FBPDF) \u306F\u305D\u306E\u6587\u5B57\u5C64\u3092\u3001\u8AAD\u3081\u306A\u3044\u5B50\u306F\u7248\u9762\u3092\u5149\u5B66\u8A8D\u8B58\u3067\u8AAD\u3093\u3067\u3001\u5B50\u3054\u3068\u306B\u672C\u6587\u3068\u51FA\u6240\u3092\u4FDD\u5B58\u3059\u308B\u3002",endpoint:"/ai/ocr/run",phase:"EXTRACTING",failureStatus:"FAILED_EXTRACT",gates:[],capability:"ocr",fanOut:"children"},ocr_document:{key:"ocr_document",label:"\u6587\u66F8\u306E OCR",description:"\u6587\u66F8\u81EA\u8EAB\u306E\u7248\u9762 (\u753B\u50CF\u30FBPDF \u306E\u5404\u30DA\u30FC\u30B8) \u3092\u5149\u5B66\u8A8D\u8B58\u306B\u304B\u3051\u308B\u3002",endpoint:"/ai/ocr/run",phase:"EXTRACTING",failureStatus:"FAILED_EXTRACT",gates:[k("ENABLE_OCR")],capability:"ocr",fanOut:null},resolve_body:{key:"resolve_body",label:"\u672C\u6587\u306E\u78BA\u5B9A",description:"\u6587\u5B57\u5C64\u30FBOCR\u30FB\u8EE2\u5199\u306E\u3069\u308C\u3092\u672C\u6587\u3068\u3059\u308B\u304B\u3092\u6C7A\u3081\u3001\u51FA\u6240\u3092\u8A18\u9332\u3059\u308B\u3002",endpoint:"/ai/enrichment/body",phase:"ENRICHING",failureStatus:"FAILED_ENRICH",gates:[],capability:null,fanOut:null},enrich_document:{key:"enrich_document",label:"\u8981\u7D04\u3068\u69CB\u9020\u5316\u62BD\u51FA",description:"\u672C\u6587\u3092\u30E2\u30C7\u30EB\u3078\u6E21\u3057\u3001\u8981\u7D04\u30FB\u30BF\u30B0\u30FB\u69CB\u9020\u5316\u30C7\u30FC\u30BF\u30FB\u30C9\u30E1\u30A4\u30F3\u5206\u985E\u3092\u5F97\u308B\u3002",endpoint:"/ai/enrichment/document",phase:"ENRICHING",failureStatus:"FAILED_ENRICH",gates:[],capability:"enrichment",fanOut:null},project_to_indexes:{key:"project_to_indexes",label:"\u30D9\u30AF\u30C8\u30EB\u3068\u30B0\u30E9\u30D5\u3078\u306E\u6295\u5F71",description:"\u672C\u6587\u3092\u30C1\u30E3\u30F3\u30AF\u306B\u3057\u3066\u57CB\u3081\u8FBC\u307F\u3001\u30D9\u30AF\u30C8\u30EB\u7D22\u5F15\u3068\u30CA\u30EC\u30C3\u30B8\u30B0\u30E9\u30D5\u3078\u66F8\u304F\u3002",endpoint:"/ai/enrichment/project",phase:"PROJECTING",failureStatus:"FAILED_VECTOR",gates:[Q("ENABLE_VECTOR_INDEXING","FAILED_VECTOR"),Q("ENABLE_GRAPH_INDEXING","FAILED_GRAPH")],capability:null,fanOut:null}},W={whenClosed:"fail",failureStatus:"FAILED_EXTRACT"},T=[{step:"delete_child_assets",dependsOn:[]},{step:"extract_text",dependsOn:["delete_child_assets"]},{step:"extract_assets",dependsOn:["extract_text"]},{step:"ocr_children",dependsOn:["extract_assets"]},{step:"ocr_document",dependsOn:["extract_text"]},{step:"resolve_body",dependsOn:["ocr_children","ocr_document"]},{step:"enrich_document",dependsOn:["resolve_body"]},{step:"project_to_indexes",dependsOn:["enrich_document"],chunkSource:"rebuild"}],Z=[{step:"delete_child_assets",dependsOn:[]},{step:"extract_text",dependsOn:["delete_child_assets"]},{step:"resolve_body",dependsOn:["extract_text"]},{step:"enrich_document",dependsOn:["resolve_body"]},{step:"project_to_indexes",dependsOn:["enrich_document"],chunkSource:"rebuild"}],Ue={email:{kind:"email",steps:T},pdf:{kind:"pdf",steps:T},office:{kind:"office",steps:T},google_native:{kind:"google_native",steps:T},image:{kind:"image",steps:[{step:"delete_child_assets",dependsOn:[]},{step:"ocr_document",dependsOn:["delete_child_assets"],gatePolicy:W},{step:"resolve_body",dependsOn:["ocr_document"]},{step:"enrich_document",dependsOn:["resolve_body"]},{step:"project_to_indexes",dependsOn:["enrich_document"],chunkSource:"rebuild"}]},media:{kind:"media",steps:[{step:"delete_child_assets",dependsOn:[]},{step:"analyze_media",dependsOn:["delete_child_assets"],gatePolicy:W},{step:"resolve_body",dependsOn:["analyze_media"]},{step:"enrich_document",dependsOn:["resolve_body"]},{step:"project_to_indexes",dependsOn:["enrich_document"],chunkSource:"existing"}]},text:{kind:"text",steps:Z},other:{kind:"other",steps:Z}};function mn(e){return Ue[e]}function yn(e){let{gates:t}=re[e.step],{gatePolicy:n}=e;return n===void 0?t:t.map(i=>({featureFlagKey:i.featureFlagKey,whenClosed:n.whenClosed,failureStatus:n.failureStatus}))}function fn(e){let t=new Map(e.steps.map(c=>[c.step,c]));for(let c of e.steps){if(c.gatePolicy!==void 0&&re[c.step].gates.length===0)throw new Error(`Flow ${e.kind}: step ${c.step} overrides its gate policy, but the step has no gate to close.`);for(let d of c.dependsOn)if(!t.has(d))throw new Error(`Flow ${e.kind}: step ${c.step} depends on ${d}, which the flow does not contain.`)}let n=[...e.steps],i=new Set,l=[];for(;n.length>0;){let c=n.findIndex(m=>m.dependsOn.every(f=>i.has(f)));if(c===-1)throw new Error(`Flow ${e.kind}: the steps ${n.map(m=>m.step).join(", ")} depend on each other in a cycle.`);let[d]=n.splice(c,1);i.add(d.step),l.push(d)}return l}var ee={EXTRACTING:0,ENRICHING:1,PROJECTING:2};function En(e,t){return ee[e]-ee[t]}import{z as r}from"zod";var oe=[{code:"DEPLOYMENT_DISABLED",status:503,errorCode:5035},{code:"RUN_ALREADY_ACTIVE",status:409,errorCode:4091},{code:"BASIS_INVALID",status:409,errorCode:4092},{code:"RUN_ALREADY_FINISHED",status:409,errorCode:4093},{code:"FORBIDDEN",status:403,errorCode:null}];import{z as U}from"zod";var _=U.string().uuid().transform(e=>e.toLowerCase()),u=U.string().datetime({offset:!0}),s=(e,t,n)=>{e.addIssue({code:U.ZodIssueCode.custom,path:[...t],message:n})},Me=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(?:Z|([+-])(\d{2}):?(\d{2}))$/,ie=e=>{let t=u.safeParse(e).success?Me.exec(e):null;if(t===null)return null;let[,n,i,l,c,d,m,f,R,y,I]=t,F=new Date(0);F.setUTCFullYear(Number(n),Number(i)-1,Number(l)),F.setUTCHours(Number(c),Number(d),m===void 0?0:Number(m),0);let Re=R===void 0?0:(R==="+"?1:-1)*(Number(y)*3600+Number(I)*60);return{epochSeconds:F.getTime()/1e3-Re,fraction:f===void 0?"":f}},b=(e,t)=>{let n=ie(e),i=ie(t);if(n===null||i===null)return!1;if(n.epochSeconds!==i.epochSeconds)return n.epochSeconds<i.epochSeconds;let l=Math.max(n.fraction.length,i.fraction.length);return n.fraction.padEnd(l,"0")<i.fraction.padEnd(l,"0")};var ae={INTEGRITY_TOMBSTONE_RETENTION_DAYS:{min:1,max:3650},INTEGRITY_FINDING_SAMPLE_LIMIT:{min:1,max:5e3},INTEGRITY_RUN_HEARTBEAT_TIMEOUT_SECONDS:{min:30,max:3600},INTEGRITY_RUN_RETENTION_COUNT:{min:2,max:100},POLICY_CONFLICT_MAX_TIE_GROUP_SIZE:{min:2,max:60}};var ze=e=>{for(let t of Object.values(e))Object.freeze(t);return Object.freeze(e)},x=ze(ae),se=e=>Object.hasOwn(x,e),le=(e,t)=>{let{min:n,max:i}=x[e];if(!Number.isInteger(t)||t<n||t>i)throw new RangeError(`${e} \u306F ${n}\u301C${i} \u306E\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)},An=(e,t)=>{se(e)&&le(e,t)},Nn=(e,t)=>{if(!se(e))throw new TypeError(`The range table bounds no parameter named ${JSON.stringify(e)}.`);le(e,t)};var G=r.enum(["QDRANT","NEO4J"]),Ke=r.enum(["PRODUCTION","VARIANT","LABEL"]),de=r.enum(["EXPECTED","LIVE","HISTORY","TOMBSTONE","AWAITING_SUCCESSOR","IN_FLIGHT","UNPLACED","UNRECORDED","UNREFERENCED","CHANGED_AFTER_START","PIPELINE_FAILED","PROJECTION_REFUSED","ORPHAN","TOMBSTONE_EXPIRED","UNPROPAGATED_DELETE","STALE_REVISION","MISPLACED","OUT_OF_TIER","UNMARKED_SUPERSEDED","FLAG_DRIFT","VARIANT_FLAG_DRIFT","DETACHED","UNKEYED","MISSING","COUNT_MISMATCH","UNPROJECTED","UNKEYED_ENTITY"]),ue=de.exclude(["EXPECTED","LIVE","HISTORY"]),He=r.enum(["POINT","NODE","CHUNK","DOCUMENT"]),Ye=r.enum(["EXPECTED","HEALTHY","RETAINED","INFORMATIONAL","DISCREPANCY"]),je=r.enum(["NONE","PURGE","FLAG","REPROJECT"]),p=(e,t)=>Object.freeze({disposition:e,repairAction:t}),Be=Object.freeze({EXPECTED:p("EXPECTED","NONE"),LIVE:p("HEALTHY","NONE"),HISTORY:p("RETAINED","NONE"),TOMBSTONE:p("RETAINED","NONE"),AWAITING_SUCCESSOR:p("RETAINED","NONE"),IN_FLIGHT:p("INFORMATIONAL","NONE"),UNPLACED:p("INFORMATIONAL","NONE"),UNRECORDED:p("INFORMATIONAL","NONE"),UNREFERENCED:p("INFORMATIONAL","NONE"),CHANGED_AFTER_START:p("INFORMATIONAL","NONE"),PIPELINE_FAILED:p("INFORMATIONAL","NONE"),PROJECTION_REFUSED:p("INFORMATIONAL","NONE"),ORPHAN:p("DISCREPANCY","PURGE"),TOMBSTONE_EXPIRED:p("DISCREPANCY","PURGE"),UNPROPAGATED_DELETE:p("DISCREPANCY","FLAG"),STALE_REVISION:p("DISCREPANCY","PURGE"),MISPLACED:p("DISCREPANCY","PURGE"),OUT_OF_TIER:p("DISCREPANCY","PURGE"),UNMARKED_SUPERSEDED:p("DISCREPANCY","FLAG"),FLAG_DRIFT:p("DISCREPANCY","REPROJECT"),VARIANT_FLAG_DRIFT:p("DISCREPANCY","NONE"),DETACHED:p("DISCREPANCY","PURGE"),UNKEYED:p("DISCREPANCY","PURGE"),MISSING:p("DISCREPANCY","REPROJECT"),COUNT_MISMATCH:p("DISCREPANCY","REPROJECT"),UNPROJECTED:p("DISCREPANCY","REPROJECT"),UNKEYED_ENTITY:p("DISCREPANCY","NONE")}),$e=r.enum(["SCAN","REPAIR"]),Ve=r.enum(["RUNNING","COMPLETED","FAILED","CANCELLED","ABANDONED"]),Xe=r.enum(["CONSISTENT","INCONSISTENT","UNDETERMINED"]),qe=r.enum(["QDRANT","NEO4J","DOCUMENTS"]),Je=r.enum(["APPLIED","SKIPPED","FAILED"]),Qe=r.enum(["RECLASSIFIED","IN_FLIGHT","DESTINATION_PENDING","BASIS_EXHAUSTED","PROJECTION_REFUSED","PIPELINE_FAILED","UNRECORDED","OUTSIDE"]),D=100,E=r.number().int().nonnegative(),O=r.number().int().min(300).max(599),w=["repairedCount","repairFailedCount","repairSkippedCount"],me=r.string().regex(/^[0-9a-f]{64}$/,"A store fingerprint is 64 lowercase hexadecimal digits."),ce=x.INTEGRITY_TOMBSTONE_RETENTION_DAYS,We=r.object({runUid:_,mode:$e,status:Ve,requestedBy:r.string().min(1),executor:r.string().min(1),basisRunUid:_.nullable(),storeFingerprint:me,tombstoneRetentionDays:r.number().int().min(ce.min).max(ce.max),startedAt:u,finishedAt:u.nullable(),verdict:Xe.nullable(),errorClass:r.string().min(1).nullable(),reprojectDocuments:E.nullable(),reprojectRebuildDocuments:E.nullable()}).strict(),Ze=(e,t)=>{let n=e.status==="COMPLETED";e.mode==="REPAIR"!=(e.basisRunUid!==null)&&s(t,["basisRunUid"],"A REPAIR run names its basis SCAN run, and a SCAN run names none."),n!==(e.verdict!==null)&&s(t,["verdict"],"Only a COMPLETED run has a verdict."),n!==(e.reprojectDocuments!==null)&&s(t,["reprojectDocuments"],"Only a COMPLETED run has the count of documents to re-project.");let{reprojectDocuments:i,reprojectRebuildDocuments:l}=e;i===null||l===null?i!==l&&s(t,["reprojectRebuildDocuments"],"The documents a re-projection embeds are counted together with the documents it re-projects."):l>i&&s(t,["reprojectRebuildDocuments"],"The documents a re-projection embeds are no more than the documents it re-projects."),e.status==="RUNNING"!=(e.finishedAt===null)&&s(t,["finishedAt"],"Only a RUNNING run has not finished."),e.finishedAt!==null&&b(e.finishedAt,e.startedAt)&&s(t,["finishedAt"],"A run does not finish before it starts."),(e.status==="FAILED"||e.status==="ABANDONED")!=(e.errorClass!==null)&&s(t,["errorClass"],"Only a FAILED or ABANDONED run names an error class.")},z=We.superRefine(Ze),et=r.object({store:G,scopeKey:r.string().min(1),scopeRole:Ke,itemClass:de,unit:He,disposition:Ye,repairAction:je,itemCount:E.nullable(),unmeasuredReason:r.string().min(1).nullable(),measuredAt:u.nullable(),repairedCount:E.nullable(),repairFailedCount:E.nullable(),repairSkippedCount:E.nullable()}).strict(),tt=(e,t)=>{let n=Be[e.itemClass];e.disposition!==n.disposition&&s(t,["disposition"],`A ${e.itemClass} quantity is ${n.disposition}.`),e.repairAction!==n.repairAction&&s(t,["repairAction"],`A repair's action on ${e.itemClass} items is ${n.repairAction}.`);let i=e.itemCount===null;i!==(e.unmeasuredReason!==null)&&s(t,["unmeasuredReason"],"An unmeasured quantity (itemCount null) has a reason, and a measured one has none."),i!==(e.measuredAt===null)&&s(t,["measuredAt"],"Only a measured quantity has a measurement time.");let{repairedCount:l,repairFailedCount:c,repairSkippedCount:d}=e;if(l===null||c===null||d===null){if(w.some(m=>e[m]!==null))for(let m of w)e[m]===null&&s(t,[m],"The repaired, failed and skipped counts are recorded together or not at all.");return}e.repairAction==="NONE"&&s(t,["repairAction"],"Only a class with a repair action carries repair counts."),e.itemCount!==null&&l+c+d>e.itemCount&&s(t,["itemCount"],"The repaired, failed and skipped counts together do not exceed the measured count.")},nt=et.superRefine(tt),rt=r.object({run:z,phase:qe.nullable(),phaseScope:r.string().min(1).nullable(),phaseDone:E.nullable(),phaseTotal:E.nullable(),heartbeatAt:u,isStale:r.boolean(),cancelRequestedAt:u.nullable()}).strict(),ot=(e,t)=>{if(e.run.status!=="RUNNING"&&s(t,["run","status"],"The active run is a RUNNING run."),b(e.heartbeatAt,e.run.startedAt)&&s(t,["heartbeatAt"],"A run's heartbeat is not earlier than its start."),e.phase===null)for(let n of["phaseScope","phaseDone","phaseTotal"])e[n]!==null&&s(t,[n],"A run with no phase has no phase progress.");e.phase==="DOCUMENTS"&&e.phaseScope!==null&&s(t,["phaseScope"],"The DOCUMENTS phase scans no scope.")},it=rt.superRefine(ot),at=r.object({run:z,quantities:r.array(nt),previousStoreFingerprint:me.nullable()}).strict(),st=(e,t)=>{e.run.status!=="COMPLETED"&&s(t,["run","status"],"The last completed run is a COMPLETED run.");let n=new Set;for(let[i,l]of e.quantities.entries()){let c=JSON.stringify([l.store,l.scopeKey,l.itemClass]);if(n.has(c)&&s(t,["quantities",i],"A run records each (store, scope, class) cell once."),n.add(c),e.run.mode==="SCAN")for(let d of w)l[d]!==null&&s(t,["quantities",i,d],"A SCAN run repairs nothing, so its quantities carry no repair counts.")}},lt=["FAILED","CANCELLED","ABANDONED"],ct=r.object({run:z,repairAppliedItems:E.nullable(),hasNewerRepair:r.boolean()}).strict(),pt=(e,t)=>{lt.includes(e.run.status)||s(t,["run","status"],"A newer unsuccessful run is FAILED, CANCELLED or ABANDONED."),e.run.mode==="SCAN"&&e.repairAppliedItems!==null&&s(t,["repairAppliedItems"],"A SCAN run applies nothing."),e.run.mode==="REPAIR"&&!e.hasNewerRepair&&s(t,["hasNewerRepair"],"An unsuccessful REPAIR run is itself a repair newer than the last completed run.")},On=r.object({readAt:u,lastCompleted:at.superRefine(st).nullable(),active:it.nullable(),newerUnsuccessful:ct.superRefine(pt).nullable()}).strict(),dt=r.object({sequence:r.number().int().min(1),itemKey:r.string().min(1),metadataId:r.number().int().positive().nullable(),fileUri:r.string().nullable(),revision:r.number().int().nullable(),observed:r.record(r.string(),r.unknown()),repairOutcome:Je.nullable(),repairErrorClass:r.string().min(1).nullable(),repairSkipReason:Qe.nullable()}).strict(),ut=(e,t)=>{e.repairOutcome==="FAILED"!=(e.repairErrorClass!==null)&&s(t,["repairErrorClass"],"Only a FAILED finding names an error class."),e.repairOutcome==="SKIPPED"!=(e.repairSkipReason!==null)&&s(t,["repairSkipReason"],"Only a SKIPPED finding names a skip reason.")},mt=dt.superRefine(ut),Pn=r.object({sotDomain:r.string().nullable()}).passthrough(),yt=r.object({rows:r.array(mt),nextAfter:r.number().int().min(1).nullable(),recordedCount:E,totalCount:E.nullable()}).strict(),ft=(e,t)=>{for(let[n,i]of e.rows.entries()){let l=e.rows[n-1];l!==void 0&&i.sequence<=l.sequence&&s(t,["rows",n,"sequence"],"A page lists its rows in ascending sequence.")}e.nextAfter!==null&&e.nextAfter!==e.rows.at(-1)?.sequence&&s(t,["nextAfter"],"The next page starts after the sequence of this page's last row.")},Fn=yt.superRefine(ft),Ln=r.object({runUid:_,store:G,scopeKey:r.string().min(1),itemClass:ue,after:r.number().int().min(1).optional(),limit:r.number().int().min(1).max(D)}).strict(),vn=r.object({runUid:_,store:G,scopeKey:r.string().min(1),itemClass:ue.extract(["UNRECORDED"]),after:r.number().int().min(1).optional()}).strict(),Et=r.object({requeued:E,skipped:r.array(r.object({metadataId:r.number().int().min(1),reason:r.string().min(1)}).strict()),nextAfter:r.number().int().min(1).nullable()}).strict(),St=(e,t)=>{let n=e.requeued+e.skipped.length;n>D&&s(t,["requeued"],`One chunk settles at most ${D} documents.`),e.nextAfter!==null!=(n===D)&&s(t,["nextAfter"],"A chunk continues exactly when it read the limit.");let i=new Set;for(let[l,c]of e.skipped.entries())i.has(c.metadataId)&&s(t,["skipped",l,"metadataId"],"A chunk keeps a document back once."),i.add(c.metadataId)},kn=Et.superRefine(St),K=r.enum(["DEPLOYMENT_DISABLED","RUN_ALREADY_ACTIVE","BASIS_INVALID","RUN_ALREADY_FINISHED","FORBIDDEN","UPSTREAM_FAILED"]),pe=r.enum(["start","cancel"]),ht=K.extract(["DEPLOYMENT_DISABLED","RUN_ALREADY_ACTIVE","BASIS_INVALID","FORBIDDEN","UPSTREAM_FAILED"]),It=K.extract(["DEPLOYMENT_DISABLED","RUN_ALREADY_FINISHED","FORBIDDEN","UPSTREAM_FAILED"]),M={start:ht,cancel:It},Rt=r.object({code:K.exclude(["UPSTREAM_FAILED"]),status:O,errorCode:r.number().int().nullable()}).strict(),ye=Object.freeze(r.array(Rt).parse(oe).map(e=>Object.freeze(e))),gt=(e,t)=>{e.code==="UPSTREAM_FAILED"||e.code==="FORBIDDEN"&&e.status===null||ye.some(n=>n.code===e.code&&n.status===e.status)||s(t,["status"],`A ${e.code} failure carries the status of its row in the code table.`)},Un=r.discriminatedUnion("command",[r.object({command:pe.extract(["start"]),code:M.start,status:O.nullable()}).strict(),r.object({command:pe.extract(["cancel"]),code:M.cancel,status:O.nullable()}).strict()]).superRefine(gt),wn=(e,t,n)=>{let i=M[e],l=ye.find(c=>c.status===t&&(c.errorCode===null||c.errorCode===n)&&i.safeParse(c.code).success);return l===void 0?"UPSTREAM_FAILED":l.code},Mn=r.discriminatedUnion("ok",[r.object({ok:r.literal(!0),runUid:_}).strict(),r.object({ok:r.literal(!1),status:O,errorCode:r.number().int().nullable()}).strict()]);import{z as a}from"zod";var fe=a.enum(te),P=a.enum(ne),_t=a.enum(["RUNNING","SUCCEEDED","FAILED"]),At=a.enum(["RUNNING","SUCCEEDED","SKIPPED","FAILED"]),Nt=a.enum(["ingest","retry","resync"]),Ct=a.enum(["text_layer","ocr","transcript"]),S=a.number().int().nonnegative().nullable(),Tt=a.object({provider:a.string().nullable(),model:a.string().nullable(),engine:a.string().nullable(),prompt_key:a.string().nullable(),prompt_version:a.number().int().nullable(),duration_ms:S,input_chars:S,output_chars:S,pages_read:S,pages_total:S,chunk_count:S,points_upserted:S,collection:a.string().nullable(),embedding_model:a.string().nullable(),strategy_id:a.number().int().positive().nullable(),graph_nodes:S,body_source:Ct.nullable(),detail:a.record(a.string(),a.unknown())}).strict(),bt=["no_pages","no_pages_rendered"],xt=a.enum(bt),H="gate_closed:",Y="source_skipped:",j="nothing_to_read:",Ee="no_children",Dt=/^[A-Z][A-Z0-9_]*$/;function Ot(e){if(e===Ee)return{kind:"no_children"};if(e.startsWith(H)){let t=e.slice(H.length);return Dt.test(t)?{kind:"gate_closed",featureFlagKey:t}:null}if(e.startsWith(Y)){let t=P.safeParse(e.slice(Y.length));return t.success?{kind:"source_skipped",stepKey:t.data}:null}if(e.startsWith(j)){let t=xt.safeParse(e.slice(j.length));return t.success?{kind:"nothing_to_read",token:t.data}:null}return null}function jn(e){let t=Pt(e);if(Ot(t)===null)throw new RangeError(`Skip reason ${JSON.stringify(e)} has no text form: ${JSON.stringify(t)} is outside the skip-reason grammar.`);return t}function Pt(e){switch(e.kind){case"gate_closed":return`${H}${e.featureFlagKey}`;case"no_children":return Ee;case"source_skipped":return`${Y}${e.stepKey}`;case"nothing_to_read":return`${j}${e.token}`;default:{let t=e;throw new RangeError(`Unknown skip reason kind: ${JSON.stringify(t)}`)}}}var Ft=a.object({id:a.number().int().positive(),runId:a.number().int().positive(),sequence:a.number().int().nonnegative(),stepKey:P,targetMetadataId:a.number().int().positive(),status:At,skipReason:a.string().nullable(),provenance:Tt.nullable(),strategyId:a.number().int().positive().nullable(),httpStatus:a.number().int().nullable(),errorCode:a.string().nullable(),errorMessage:a.string().nullable(),startedAt:u,finishedAt:u.nullable(),durationMs:S}).strict();function Lt(e,t){switch(e.status){case"SKIPPED":e.skipReason===null&&s(t,["skipReason"],"A SKIPPED step must record why it was skipped."),e.provenance!==null&&s(t,["provenance"],"A SKIPPED step read nothing, so it has no report.");return;case"SUCCEEDED":e.provenance===null&&s(t,["provenance"],"A SUCCEEDED step must carry its report."),e.skipReason!==null&&s(t,["skipReason"],"A SUCCEEDED step was not skipped.");return;case"RUNNING":e.finishedAt!==null&&s(t,["finishedAt"],"A RUNNING step has not finished.");return;case"FAILED":e.skipReason!==null&&s(t,["skipReason"],"A FAILED step was not skipped.");return}}var vt=Ft.superRefine(Lt),Se=a.object({id:a.number().int().positive(),tenantId:a.string().min(1),metadataId:a.number().int().positive(),revision:a.number().int().positive(),runUid:a.string().uuid(),jobId:a.string().min(1),attempt:a.number().int().positive(),trigger:Nt,documentKind:fe,flowKey:a.string().min(1),status:_t,retryScheduled:a.boolean(),failedStepKey:P.nullable(),errorMessage:a.string().nullable(),requestedBy:a.string().min(1),startedAt:u,finishedAt:u.nullable(),steps:a.array(vt)}).strict();function he(e,t){e.retryScheduled&&e.status!=="FAILED"&&s(t,["retryScheduled"],"Only a FAILED run can have a retry scheduled.")}var Bn=Se.superRefine(he),$n=Se.omit({steps:!0}).superRefine(he);function kt(e,t){e.sampleCount>0||(e.durationP50Ms!==null&&s(t,["durationP50Ms"],"A step with no sample has no median latency."),e.durationP95Ms!==null&&s(t,["durationP95Ms"],"A step with no sample has no 95th-percentile latency."))}var Vn=a.object({documentKind:fe,stepKey:P,sampleCount:a.number().int().nonnegative(),succeeded:a.number().int().nonnegative(),failed:a.number().int().nonnegative(),skipped:a.number().int().nonnegative(),durationP50Ms:S,durationP95Ms:S,lastStartedAt:u.nullable()}).strict().superRefine(kt);var Ie=[{key:"enable_summary_generation",featureFlagKey:null,label:"\u8981\u7D04\u751F\u6210"},{key:"enable_structured_extraction",featureFlagKey:null,label:"\u69CB\u9020\u5316\u62BD\u51FA"},{key:"enable_asset_extraction",featureFlagKey:"ENABLE_ASSET_EXTRACTION",label:"\u30A2\u30BB\u30C3\u30C8\u62BD\u51FA"},{key:"enable_vector_indexing",featureFlagKey:"ENABLE_VECTOR_INDEXING",label:"\u30D9\u30AF\u30C8\u30EB\u7D22\u5F15"},{key:"enable_graph_indexing",featureFlagKey:"ENABLE_GRAPH_INDEXING",label:"\u30B0\u30E9\u30D5\u6295\u5F71"}],Ut=new Set(Ie.map(e=>e.key));function qn(e){return Ut.has(e)}function Jn(e){let t=Ie.find(n=>n.key===e);if(t===void 0)throw new Error(`ENRICHMENT_STAGES does not carry ${e}; the canonical list and the key type have drifted apart.`);return t}var Qn={pageSize:{min:1,max:200,default:50},topologyLabels:{min:1,max:24,default:24}};var A=-1,h=0;function wt(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}function Zn(){let e=typeof globalThis<"u"&&globalThis.crypto?globalThis.crypto:typeof crypto<"u"?crypto:void 0;if(!e||typeof e.getRandomValues!="function")throw new Error("Cryptographically secure random number generator (crypto.getRandomValues) is required but not available.");let t=new Uint8Array(16);e.getRandomValues(t);let n=Date.now();if(n===A){if(h++,h>4095){for(;Date.now()<=A;);n=Date.now(),A=n,h=(t[6]<<4|t[7]&15)&1023}}else n>A?(A=n,h=(t[6]<<4|t[7]&15)&1023):(n=A,h++,h>4095&&(h=0));t[0]=Math.floor(n/1099511627776)&255,t[1]=Math.floor(n/4294967296)&255,t[2]=n>>>24&255,t[3]=n>>>16&255,t[4]=n>>>8&255,t[5]=n&255,t[6]=112|h>>>8&15,t[7]=h&255,t[8]=128|t[8]&63;let i=Array.from(t,c=>c.toString(16).padStart(2,"0")).join("");return`${i.slice(0,8)}-${i.slice(8,12)}-${i.slice(12,16)}-${i.slice(16,20)}-${i.slice(20)}`}function er(e){if(!wt(e))throw new Error(`Invalid RFC 9562 UUIDv7 string: "${e}"`);let t=e.slice(0,8)+e.slice(9,13),n=parseInt(t,16);if(Number.isNaN(n))throw new Error(`Invalid hex timestamp in UUIDv7: "${t}"`);return new Date(n)}export{De as AmountEntrySchema,N as BaseEnrichmentClient,Ct as BodySourceSchema,en as BoundingBoxSchema,_e as CIRCUIT_BREAKER_SERVICES,Fe as CanonicalDomainKeySchema,be as ChapterSegmentSchema,rn as ChunkingStrategySchema,nn as CircuitBreakerStatusSchema,L as ConfidentialityLevelSchema,Ce as DISPATCH_DEGRADATION_REASONS,te as DOCUMENT_KINDS,pn as DOCUMENT_KIND_LABELS,fe as DocumentKindSchema,tn as DocumentStructuredDataSchema,Ie as ENRICHMENT_STAGES,J as EnrichmentClient,g as EnrichmentClientError,Zt as EnrichmentSyncStatusSchema,Yt as FILTERABLE_CONFIDENTIALITY_LEVELS,Wt as FileUriSchema,Qn as GRAPH_INDEX_LIMITS,ve as GraphSearchHitSchema,Be as INTEGRITY_CLASS_POLICY,ye as INTEGRITY_COMMAND_CODES,D as INTEGRITY_FINDINGS_PAGE_LIMIT_MAX,it as IntegrityActiveRunSchema,On as IntegrityAuditOverviewSchema,It as IntegrityCancelFailureCodeSchema,vn as IntegrityCellResyncRequestSchema,kn as IntegrityCellResyncResultSchema,K as IntegrityCommandFailureCodeSchema,Un as IntegrityCommandFailureSchema,Mn as IntegrityCommandReplySchema,pe as IntegrityCommandSchema,Ye as IntegrityDispositionSchema,ue as IntegrityFindingItemClassSchema,Fn as IntegrityFindingPageSchema,mt as IntegrityFindingSchema,Ln as IntegrityFindingsQuerySchema,de as IntegrityItemClassSchema,qe as IntegrityPhaseSchema,Pn as IntegrityPlacementObservedSchema,nt as IntegrityQuantitySchema,je as IntegrityRepairActionSchema,Je as IntegrityRepairOutcomeSchema,Qe as IntegrityRepairSkipReasonSchema,z as IntegrityRunHeaderSchema,$e as IntegrityRunModeSchema,Ve as IntegrityRunStatusSchema,Ke as IntegrityScopeRoleSchema,ht as IntegrityStartFailureCodeSchema,G as IntegrityStoreSchema,He as IntegrityUnitSchema,Xe as IntegrityVerdictSchema,Ae as LOCAL_DEGRADATION_REASONS,ke as MIME_KIND_RULES,C as MODE_TIERS,ge as ModelProviderSchema,bt as NOTHING_TO_READ_TOKENS,xt as NothingToReadTokenSchema,Ue as PIPELINE_FLOWS,un as PIPELINE_PHASES,re as PIPELINE_STEPS,ne as PIPELINE_STEP_KEYS,Bn as PipelineRunRecordSchema,_t as PipelineRunStatusSchema,$n as PipelineRunSummarySchema,P as PipelineStepKeySchema,Vn as PipelineStepMetricSchema,vt as PipelineStepRecordSchema,At as PipelineStepStatusSchema,Nt as PipelineTriggerSchema,v as QUARANTINED_CONFIDENTIALITY_LEVEL,Ne as REMOTE_DEGRADATION_REASONS,Xt as SEARCH_DEGRADATION_REASONS,V as SEARCH_MODES,Ht as SEARCH_PARAM_LIMITS,x as SYSTEM_PARAMETER_RANGES,Le as SearchHitSchema,Pe as SearchMetadataSchema,Oe as SearchModeSchema,X as SearchRequestSchema,q as SearchResponseSchema,Tt as StageProvenanceSchema,Te as TenantIdSchema,xe as TranscriptSegmentSchema,Nn as assertBoundedSystemParameter,An as assertSystemParameterInRange,dn as classifyDocumentKind,En as comparePhases,Jn as enrichmentStage,mn as flowFor,yn as flowStepGates,jn as formatSkipReason,Zn as generateUuidV7,wn as integrityCommandFailureCodeOf,qn as isEnrichmentStageKey,b as isStrictlyEarlier,wt as isValidUuidV7,Vt as modeFusesRankings,jt as modeNeedsRemoteTiers,Bt as modeScoreIsSimilarity,$t as narrowModeToAllowedTiers,fn as orderedSteps,Ot as parseSkipReason,er as uuidv7ToDate};
|
|
1
|
+
var U=e=>{if(e===null||typeof e=="string"||typeof e=="boolean")return JSON.stringify(e);if(typeof e=="number"){if(!Number.isFinite(e))throw new RangeError(`A canonical JSON number is finite: ${e}`);return JSON.stringify(e)}if(Array.isArray(e))return`[${e.map(U).join(",")}]`;let t=e;return`{${Object.keys(t).sort().map(r=>`${JSON.stringify(r)}:${U(t[r])}`).join(",")}}`};var te=class extends Error{statusCode;responseBody;parsedBody;constructor(t,n,r,o){super(t),this.name="EnrichmentClientError",this.statusCode=n,this.responseBody=r,this.parsedBody=o}},fe=class{baseUrl;apiKey;fetchFn;timeoutMs;constructor(t){if(!t||typeof t.baseUrl!="string"||t.baseUrl.trim().length===0)throw new Error("baseUrl is required and must be a non-empty string for EnrichmentClient.");let n=t.baseUrl.trim().replace(/\/$/,"");if(t.apiKey&&n.startsWith("http://")&&!n.includes("localhost")&&!n.includes("127.0.0.1"))throw new Error("Security Violation: Transmitting Bearer tokens over unencrypted HTTP to non-localhost hosts is strictly prohibited.");this.baseUrl=n,this.apiKey=t.apiKey,this.fetchFn=t.fetchFn??fetch,this.timeoutMs=t.timeoutMs&&t.timeoutMs>0?t.timeoutMs:3e4}async request(t,n,r){let o=`${this.baseUrl}${t}`,i={Accept:"application/json","Content-Type":"application/json","X-Tenant-Id":n};this.apiKey&&(i.Authorization=`Bearer ${this.apiKey}`);let l=new AbortController,s=setTimeout(()=>l.abort(),this.timeoutMs),c;try{c=await this.fetchFn(o,{method:"POST",headers:i,body:JSON.stringify(r),signal:l.signal})}catch(u){let y=u instanceof Error?u.message:String(u);throw new te(`Network request failed for POST ${o}: ${y}`,0,"")}finally{clearTimeout(s)}if(!c.ok){let u=await c.text().catch(()=>""),y;try{y=JSON.parse(u)}catch{}throw new te(`API request failed with status ${c.status}: ${u}`,c.status,u,y)}let h=await c.text().catch(()=>"");if(h.trim().length!==0)try{return JSON.parse(h)}catch(u){let y=u instanceof Error?u.message:String(u);throw new te(`Failed to parse response JSON from ${o}: ${y}`,c.status,h)}}};import{z as m}from"zod";import{z as dt}from"zod";var Nn=dt.enum(["google_cloud","google_vision","yomitoku_local","faster_whisper_local","google_speech","ollama_local","openai","anthropic","azure_openai","bedrock","custom_openai_compatible"]),ne=dt.enum(["PUBLIC","INTERNAL","DEPARTMENT","CONFIDENTIAL","RESTRICTED"]),de="RESTRICTED";var _a={rrfK:{min:1,max:200,default:60},alpha:{min:0,max:1,default:.7},threshold:{min:0,max:1},limit:{min:1,max:50,default:10}},ut=ne.options.filter(e=>e!==de);if(ut.length===0)throw new Error("The confidentiality vocabulary left nothing filterable after removing the quarantined level; a validator built from this list would reject every request.");var Da=ut,pt=["KEYWORD","SPARSE","DENSE","HYBRID","GRAPH_TRAVERSE"],he={KEYWORD:{dense:!1,sparse:!1,graph:!1,lexical:!0},SPARSE:{dense:!1,sparse:!0,graph:!1,lexical:!1},DENSE:{dense:!0,sparse:!1,graph:!1,lexical:!1},HYBRID:{dense:!0,sparse:!0,graph:!0,lexical:!0},GRAPH_TRAVERSE:{dense:!1,sparse:!1,graph:!0,lexical:!1}};function Ta(e){let t=he[e];return t.dense||t.sparse||t.graph}function Na(e){let t=he[e];return t.dense&&!t.sparse}function ka(e,t){let n=he[e],r=(n.dense||n.sparse)&&t.vector,o=n.graph&&t.graph;return r||o?r?o?{mode:e,discardGraph:!1}:n.dense&&n.sparse?{mode:e,discardGraph:!0}:{mode:n.dense?"DENSE":"SPARSE",discardGraph:!1}:{mode:"GRAPH_TRAVERSE",discardGraph:!1}:null}function Oa(e){let t=he[e];return[t.dense,t.sparse,t.graph,t.lexical].filter(Boolean).length>1}var kn=["vector","graph"],On=["empty_query","caller_token_unavailable","time_window_unsupported"],wn=["vector_tier_not_configured","graph_tier_not_configured","no_active_vector_collection","vector_collections_missing"],Fn=["remote_tiers_unavailable","remote_tiers_timed_out","remote_tiers_refused_caller","remote_tiers_rejected_request","remote_tiers_failed","remote_tiers_not_executed","vector_search_disabled","graph_search_disabled"],wa=[...On,...wn,...Fn,...kn.map(e=>`circuit_breaker_open:${e}`)];var Pn=m.string().trim().min(1,"tenant_id must be a non-empty string"),va=m.string().trim().min(1,"file_uri must be a non-empty string"),mt=m.enum(["PENDING","EXTRACTING","ENRICHING","PROJECTING","SYNCED","FAILED_EXTRACT","FAILED_ENRICH","FAILED_VECTOR","FAILED_GRAPH"]),Ma=m.object({page:m.number().int().positive().optional(),x:m.number().nonnegative().optional(),y:m.number().nonnegative().optional(),width:m.number().positive().optional(),height:m.number().positive().optional(),start_sec:m.number().nonnegative().optional(),end_sec:m.number().nonnegative().optional(),frame_index:m.number().int().nonnegative().optional(),timestamp_sec:m.number().nonnegative().optional(),scene_confidence:m.number().min(0).max(1).optional()}),Ln=m.object({title:m.string().trim().min(1),start_sec:m.number().nonnegative(),end_sec:m.number().nonnegative(),summary:m.string()}),vn=m.object({start_sec:m.number().nonnegative(),end_sec:m.number().nonnegative(),speaker:m.string().trim().min(1),text:m.string()}),Mn=m.object({label:m.string(),value:m.number(),currency:m.string()}),Ua=m.object({document_type:m.string().optional(),title:m.string().optional(),organization:m.string().optional(),key_entities:m.array(m.string()).optional(),dates:m.array(m.string()).optional(),amounts:m.array(Mn).optional(),media_type:m.enum(["video","audio"]).optional(),duration_sec:m.number().nonnegative().optional(),chapters:m.array(Ln).optional(),transcript_segments:m.array(vn).optional()}),za=m.enum(["CLOSED","OPEN","HALF_OPEN"]),Un=m.enum(pt),zn=m.object({circuit_breaker_status:m.string(),quality_tier:m.string(),latency_ms:m.number().nonnegative(),total_hits:m.number().int().nonnegative(),fallback_applied:m.boolean(),degraded_reason:m.string().nullable()}),Hn=m.enum(["CONTRACT_LEGAL","EMAIL_THREAD","DAILY_REPORT","FINANCIAL_REPORT","TECHNICAL_SPEC","MASTER_DATA","MEDIA_ASSET","GENERAL_DOCUMENT"]),Ha=m.enum(["hierarchical","conversation","section","fixed_size","table_aware","semantic","none","multimodal"]),Kn=m.object({metadata_id:m.number().int().positive(),chunk_index:m.number().int().nonnegative(),text:m.string(),score:m.number()}),Gn=m.object({metadata_id:m.number().int().positive(),relation:m.string(),target_name:m.string()}),ft=m.object({query:m.string().trim().min(1,"query must not be empty"),tenant_id:Pn,domain_key:Hn.optional(),limit:m.number().int().positive().optional(),department_id:m.number().int().positive().optional(),search_mode:Un.optional(),strategy_id:m.number().int().positive().optional()}).strict(),ht=m.object({hits:m.array(Kn),graph_hits:m.array(Gn),tiers:m.record(m.string(),m.boolean()),metadata:zn});var yt=class extends fe{async search(t){let n=ft.parse(t),r=await this.request("/ai/search/hybrid",n.tenant_id,n);return ht.parse(r)}};import{z as a}from"zod";import{z as ke}from"zod";var re=ke.string().uuid().transform(e=>e.toLowerCase()),w=ke.string().datetime({offset:!0}),ye=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&!Object.hasOwn(e,"__proto__"),d=(e,t,n)=>{e.addIssue({code:ke.ZodIssueCode.custom,path:[...t],message:n})},jn=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(?:Z|([+-])(\d{2}):?(\d{2}))$/,gt=e=>{let t=w.safeParse(e).success?jn.exec(e):null;if(t===null)return null;let[,n,r,o,i,l,s,c,h,u,y]=t,E=new Date(0);E.setUTCFullYear(Number(n),Number(r)-1,Number(o)),E.setUTCHours(Number(i),Number(l),s===void 0?0:Number(s),0);let _=h===void 0?0:(h==="+"?1:-1)*(Number(u)*3600+Number(y)*60);return{epochSeconds:E.getTime()/1e3-_,fraction:c===void 0?"":c}},X=(e,t)=>{let n=gt(e),r=gt(t);if(n===null||r===null)return!1;if(n.epochSeconds!==r.epochSeconds)return n.epochSeconds<r.epochSeconds;let o=Math.max(n.fraction.length,r.fraction.length);return n.fraction.padEnd(o,"0")<r.fraction.padEnd(o,"0")};import{z as S}from"zod";var Rt=["email","pdf","office","image","media","text","google_native","other"],$a={email:"\u30E1\u30FC\u30EB",pdf:"PDF",office:"Office \u6587\u66F8",image:"\u753B\u50CF",media:"\u97F3\u58F0\u30FB\u52D5\u753B",text:"\u30C6\u30AD\u30B9\u30C8",google_native:"Google \u30CD\u30A4\u30C6\u30A3\u30D6",other:"\u305D\u306E\u4ED6"},Bn=[["message/rfc822","email"],["application/pdf","pdf"],["application/vnd.openxmlformats-officedocument.*","office"],["application/msword","office"],["application/vnd.ms-excel","office"],["application/vnd.ms-powerpoint","office"],["application/vnd.google-apps.*","google_native"],["image/svg+xml","text"],["image/emf","other"],["image/x-emf","other"],["image/wmf","other"],["image/x-wmf","other"],["image/*","image"],["audio/*","media"],["video/*","media"],["text/*","text"],["application/json","text"],["application/xml","text"]];function qa(e){let t=(e.split(";")[0]??"").trim().toLowerCase();for(let[n,r]of Bn)if(n.endsWith("*")?t.startsWith(n.slice(0,-1)):t===n)return r;return"other"}var we=["delete_child_assets","extract_text","analyze_media","extract_assets","ocr_children","ocr_document","resolve_body","enrich_document","project_to_indexes"],Fe="record_document_state",It=[...we,Fe],Xa=["EXTRACTING","ENRICHING","PROJECTING"],xt=["FAILED_EXTRACT","FAILED_ENRICH","FAILED_VECTOR","FAILED_GRAPH"],Oe=e=>({featureFlagKey:e,whenClosed:"skip",failureStatus:null}),St=(e,t)=>({featureFlagKey:e,whenClosed:"fail",failureStatus:t}),At={delete_child_assets:{key:"delete_child_assets",label:"\u65E7\u7248\u306E\u5B50\u30A2\u30BB\u30C3\u30C8\u524A\u9664",description:"\u3053\u306E\u7248\u3088\u308A\u524D\u306E\u7248\u304C\u751F\u3093\u3060\u5B50\u30A2\u30BB\u30C3\u30C8\u3092\u4FDD\u7BA1\u5C64\u3068\u7D22\u5F15\u304B\u3089\u5916\u3059\u3002",endpoint:"/ai/assets/delete",phase:"EXTRACTING",failureStatus:"FAILED_EXTRACT",gates:[],capability:null,fanOut:null},extract_text:{key:"extract_text",label:"\u6587\u5B57\u5C64\u306E\u62BD\u51FA",description:"\u6587\u66F8\u304C\u6301\u3064\u6587\u5B57\u5C64 (PDF \u306E\u6587\u5B57\u30FBOffice \u306E\u672C\u6587\u30FB\u30E1\u30FC\u30EB\u306E\u672C\u6587\u3068\u898B\u51FA\u3057) \u3092\u8AAD\u307F\u3001\u4F4D\u7F6E\u60C5\u5831\u3068\u5171\u306B\u4FDD\u5B58\u3059\u308B\u3002",endpoint:"/ai/enrichment/extract",phase:"EXTRACTING",failureStatus:"FAILED_EXTRACT",gates:[],capability:null,fanOut:null},analyze_media:{key:"analyze_media",label:"\u30E1\u30C7\u30A3\u30A2\u89E3\u6790",description:"\u97F3\u58F0\u30FB\u52D5\u753B\u3092\u8EE2\u5199\u3057\u3001\u767A\u8A71\u533A\u9593\u4ED8\u304D\u306E\u30C1\u30E3\u30F3\u30AF\u3068\u30AD\u30FC\u30D5\u30EC\u30FC\u30E0\u6570\u3092\u8A18\u9332\u3059\u308B\u3002",endpoint:"/ai/media/analyze",phase:"EXTRACTING",failureStatus:"FAILED_EXTRACT",gates:[Oe("ENABLE_MEDIA_ANALYSIS")],capability:"transcription",fanOut:null},extract_assets:{key:"extract_assets",label:"\u5B50\u30A2\u30BB\u30C3\u30C8\u306E\u62BD\u51FA",description:"\u57CB\u3081\u8FBC\u307F\u753B\u50CF\u3084\u30E1\u30FC\u30EB\u306E\u6DFB\u4ED8\u3092\u5B50\u30A2\u30BB\u30C3\u30C8\u3068\u3057\u3066\u5207\u308A\u51FA\u3057\u3001\u6587\u66F8\u306E\u96A3\u306B\u4FDD\u7BA1\u3057\u3066\u767B\u9332\u3059\u308B\u3002",endpoint:"/ai/assets/extract",phase:"EXTRACTING",failureStatus:"FAILED_EXTRACT",gates:[Oe("ENABLE_ASSET_EXTRACTION")],capability:"asset_extraction",fanOut:null},ocr_children:{key:"ocr_children",label:"\u5B50\u30A2\u30BB\u30C3\u30C8\u306E\u8AAD\u307F\u53D6\u308A",description:"\u5207\u308A\u51FA\u3057\u305F\u5B50\u30A2\u30BB\u30C3\u30C8\u3092\u62BD\u51FA\u9806\u306B 1 \u4EF6\u305A\u3064\u8AAD\u307F\u3001\u6587\u5B57\u5C64\u3092\u8AAD\u3081\u308B\u5B50 (\u30C6\u30AD\u30B9\u30C8\u30FB\u30E1\u30FC\u30EB\u30FBOffice\u30FBPDF) \u306F\u305D\u306E\u6587\u5B57\u5C64\u3092\u3001\u8AAD\u3081\u306A\u3044\u5B50\u306F\u7248\u9762\u3092\u5149\u5B66\u8A8D\u8B58\u3067\u8AAD\u3093\u3067\u3001\u5B50\u3054\u3068\u306B\u672C\u6587\u3068\u51FA\u6240\u3092\u4FDD\u5B58\u3059\u308B\u3002",endpoint:"/ai/ocr/run",phase:"EXTRACTING",failureStatus:"FAILED_EXTRACT",gates:[],capability:"ocr",fanOut:"children"},ocr_document:{key:"ocr_document",label:"\u6587\u66F8\u306E OCR",description:"\u6587\u66F8\u81EA\u8EAB\u306E\u7248\u9762 (\u753B\u50CF\u30FBPDF \u306E\u5404\u30DA\u30FC\u30B8) \u3092\u5149\u5B66\u8A8D\u8B58\u306B\u304B\u3051\u308B\u3002",endpoint:"/ai/ocr/run",phase:"EXTRACTING",failureStatus:"FAILED_EXTRACT",gates:[Oe("ENABLE_OCR")],capability:"ocr",fanOut:null},resolve_body:{key:"resolve_body",label:"\u672C\u6587\u306E\u78BA\u5B9A",description:"\u6587\u5B57\u5C64\u30FBOCR\u30FB\u8EE2\u5199\u306E\u3069\u308C\u3092\u672C\u6587\u3068\u3059\u308B\u304B\u3092\u6C7A\u3081\u3001\u51FA\u6240\u3092\u8A18\u9332\u3059\u308B\u3002",endpoint:"/ai/enrichment/body",phase:"ENRICHING",failureStatus:"FAILED_ENRICH",gates:[],capability:null,fanOut:null},enrich_document:{key:"enrich_document",label:"\u8981\u7D04\u3068\u69CB\u9020\u5316\u62BD\u51FA",description:"\u672C\u6587\u3092\u30E2\u30C7\u30EB\u3078\u6E21\u3057\u3001\u8981\u7D04\u30FB\u30BF\u30B0\u30FB\u69CB\u9020\u5316\u30C7\u30FC\u30BF\u30FB\u30C9\u30E1\u30A4\u30F3\u5206\u985E\u3092\u5F97\u308B\u3002",endpoint:"/ai/enrichment/document",phase:"ENRICHING",failureStatus:"FAILED_ENRICH",gates:[],capability:"enrichment",fanOut:null},project_to_indexes:{key:"project_to_indexes",label:"\u30D9\u30AF\u30C8\u30EB\u3068\u30B0\u30E9\u30D5\u3078\u306E\u6295\u5F71",description:"\u672C\u6587\u3092\u30C1\u30E3\u30F3\u30AF\u306B\u3057\u3066\u57CB\u3081\u8FBC\u307F\u3001\u30D9\u30AF\u30C8\u30EB\u7D22\u5F15\u3068\u30CA\u30EC\u30C3\u30B8\u30B0\u30E9\u30D5\u3078\u66F8\u304F\u3002",endpoint:"/ai/enrichment/project",phase:"PROJECTING",failureStatus:"FAILED_VECTOR",gates:[St("ENABLE_VECTOR_INDEXING","FAILED_VECTOR"),St("ENABLE_GRAPH_INDEXING","FAILED_GRAPH")],capability:null,fanOut:null}},Et={whenClosed:"fail",failureStatus:"FAILED_EXTRACT"},ge=[{step:"delete_child_assets",dependsOn:[]},{step:"extract_text",dependsOn:["delete_child_assets"]},{step:"extract_assets",dependsOn:["extract_text"]},{step:"ocr_children",dependsOn:["extract_assets"]},{step:"ocr_document",dependsOn:["extract_text"]},{step:"resolve_body",dependsOn:["ocr_children","ocr_document"]},{step:"enrich_document",dependsOn:["resolve_body"]},{step:"project_to_indexes",dependsOn:["enrich_document"],chunkSource:"rebuild"}],Ct=[{step:"delete_child_assets",dependsOn:[]},{step:"extract_text",dependsOn:["delete_child_assets"]},{step:"resolve_body",dependsOn:["extract_text"]},{step:"enrich_document",dependsOn:["resolve_body"]},{step:"project_to_indexes",dependsOn:["enrich_document"],chunkSource:"rebuild"}],Vn={email:{kind:"email",steps:ge},pdf:{kind:"pdf",steps:ge},office:{kind:"office",steps:ge},google_native:{kind:"google_native",steps:ge},image:{kind:"image",steps:[{step:"delete_child_assets",dependsOn:[]},{step:"ocr_document",dependsOn:["delete_child_assets"],gatePolicy:Et},{step:"resolve_body",dependsOn:["ocr_document"]},{step:"enrich_document",dependsOn:["resolve_body"]},{step:"project_to_indexes",dependsOn:["enrich_document"],chunkSource:"rebuild"}]},media:{kind:"media",steps:[{step:"delete_child_assets",dependsOn:[]},{step:"analyze_media",dependsOn:["delete_child_assets"],gatePolicy:Et},{step:"resolve_body",dependsOn:["analyze_media"]},{step:"enrich_document",dependsOn:["resolve_body"]},{step:"project_to_indexes",dependsOn:["enrich_document"],chunkSource:"existing"}]},text:{kind:"text",steps:Ct},other:{kind:"other",steps:Ct}};function Wa(e){return Vn[e]}function Qa(e){let{gates:t}=At[e.step],{gatePolicy:n}=e;return n===void 0?t:t.map(r=>({featureFlagKey:r.featureFlagKey,whenClosed:n.whenClosed,failureStatus:n.failureStatus}))}function Za(e){let t=new Map(e.steps.map(i=>[i.step,i]));for(let i of e.steps){if(i.gatePolicy!==void 0&&At[i.step].gates.length===0)throw new Error(`Flow ${e.kind}: step ${i.step} overrides its gate policy, but the step has no gate to close.`);for(let l of i.dependsOn)if(!t.has(l))throw new Error(`Flow ${e.kind}: step ${i.step} depends on ${l}, which the flow does not contain.`)}let n=[...e.steps],r=new Set,o=[];for(;n.length>0;){let i=n.findIndex(s=>s.dependsOn.every(c=>r.has(c)));if(i===-1)throw new Error(`Flow ${e.kind}: the steps ${n.map(s=>s.step).join(", ")} depend on each other in a cycle.`);let[l]=n.splice(i,1);r.add(l.step),o.push(l)}return o}var bt={EXTRACTING:0,ENRICHING:1,PROJECTING:2};function ei(e,t){return bt[e]-bt[t]}var _t=S.enum(Rt),Me=S.enum(we),Jn=S.enum(It),Dt=S.enum(xt),Yn=["RECORDED","UNCHANGED","ALREADY_RECORDED"],$n=S.enum(Yn),qn=S.object({outcome:$n}).strict(),Xn=["history_no_current_row","history_lock_timeout","history_write_failed"],Wn="stale_run",Qn=S.enum(Xn),Ue=S.enum(["RUNNING","SUCCEEDED","FAILED"]),Zn=S.enum(["RUNNING","SUCCEEDED","SKIPPED","FAILED"]),er=S.enum(["ingest","retry","resync"]),ze=S.enum(["text_layer","ocr","transcript"]),G=S.number().int().nonnegative().nullable(),tr=S.object({provider:S.string().nullable(),model:S.string().nullable(),engine:S.string().nullable(),prompt_key:S.string().nullable(),prompt_version:S.number().int().nullable(),duration_ms:G,input_chars:G,output_chars:G,pages_read:G,pages_total:G,chunk_count:G,points_upserted:G,collection:S.string().nullable(),embedding_model:S.string().nullable(),strategy_id:S.number().int().positive().nullable(),graph_nodes:G,body_source:ze.nullable(),detail:S.custom(ye,"A report's detail holds no own __proto__ member.").pipe(S.record(S.string(),S.unknown()))}).strict(),nr=["no_pages","no_pages_rendered"],rr=S.enum(nr),Pe="gate_closed:",Le="source_skipped:",ve="nothing_to_read:",or=["no_children","superseded","recording_disabled","recording_misconfigured"],ar=e=>or.includes(e),ir=/^[A-Z][A-Z0-9_]*$/;function Tt(e){if(ar(e))return{kind:e};if(e.startsWith(Pe)){let t=e.slice(Pe.length);return ir.test(t)?{kind:"gate_closed",featureFlagKey:t}:null}if(e.startsWith(Le)){let t=Me.safeParse(e.slice(Le.length));return t.success?{kind:"source_skipped",stepKey:t.data}:null}if(e.startsWith(ve)){let t=rr.safeParse(e.slice(ve.length));return t.success?{kind:"nothing_to_read",token:t.data}:null}return null}function ai(e){let t=sr(e);if(Tt(t)===null)throw new RangeError(`Skip reason ${JSON.stringify(e)} has no text form: ${JSON.stringify(t)} is outside the skip-reason grammar.`);return t}function sr(e){switch(e.kind){case"gate_closed":return`${Pe}${e.featureFlagKey}`;case"no_children":case"superseded":case"recording_disabled":case"recording_misconfigured":return e.kind;case"source_skipped":return`${Le}${e.stepKey}`;case"nothing_to_read":return`${ve}${e.token}`;default:{let t=e;throw new RangeError(`Unknown skip reason kind: ${JSON.stringify(t)}`)}}}var lr=S.object({id:S.number().int().positive(),runId:S.number().int().positive(),sequence:S.number().int().nonnegative(),stepKey:Jn,targetMetadataId:S.number().int().positive(),status:Zn,skipReason:S.string().nullable(),provenance:tr.nullable(),strategyId:S.number().int().positive().nullable(),httpStatus:S.number().int().nullable(),errorCode:S.string().nullable(),errorMessage:S.string().nullable(),startedAt:w,finishedAt:w.nullable(),durationMs:G}).strict();function cr(e,t){switch(e.stepKey===Fe&&ur(e,t),e.status){case"SKIPPED":e.skipReason===null&&d(t,["skipReason"],"A SKIPPED step must record why it was skipped."),e.provenance!==null&&d(t,["provenance"],"A SKIPPED step read nothing, so it has no report.");return;case"SUCCEEDED":e.provenance===null&&d(t,["provenance"],"A SUCCEEDED step must carry its report."),e.skipReason!==null&&d(t,["skipReason"],"A SUCCEEDED step was not skipped.");return;case"RUNNING":e.finishedAt!==null&&d(t,["finishedAt"],"A RUNNING step has not finished.");return;case"FAILED":e.skipReason!==null&&d(t,["skipReason"],"A FAILED step was not skipped.");return}}var dr=["superseded","recording_disabled","recording_misconfigured"];function ur(e,t){if(e.strategyId!==null&&d(t,["strategyId"],"The terminal step applies no strategy."),e.httpStatus!==null&&d(t,["httpStatus"],"The terminal step calls no API, so it has no HTTP status."),e.status==="SUCCEEDED"&&e.provenance!==null){qn.safeParse(e.provenance.detail).success||d(t,["provenance","detail"],"A succeeded terminal step's detail is exactly { outcome }.");for(let[n,r]of Object.entries(e.provenance))n!=="detail"&&r!==null&&d(t,["provenance",n],"A succeeded terminal step reports nothing but its outcome.")}if(e.status==="FAILED"&&(e.provenance!==null&&d(t,["provenance"],"Neither the failure close nor the recovery sweeper writes a terminal step's report."),e.errorCode!==Wn&&!Qn.safeParse(e.errorCode).success&&d(t,["errorCode"],"A failed terminal step names a history error code, or the stale-run code the sweeper writes.")),e.status==="SKIPPED"&&e.skipReason!==null){let n=Tt(e.skipReason);(n===null||!dr.includes(n.kind))&&d(t,["skipReason"],"A skipped terminal step names one of the terminal skip reasons.")}}var pr=lr.superRefine(cr),Nt=S.object({id:S.number().int().positive(),tenantId:S.string().min(1),metadataId:S.number().int().positive(),revision:S.number().int().positive(),runUid:S.string().uuid(),jobId:S.string().min(1),attempt:S.number().int().positive(),trigger:er,documentKind:_t,flowKey:S.string().min(1),status:Ue,retryScheduled:S.boolean(),failedStepKey:Me.nullable(),errorMessage:S.string().nullable(),requestedBy:S.string().min(1),startedAt:w,finishedAt:w.nullable(),steps:S.array(pr)}).strict();function kt(e,t){e.retryScheduled&&e.status!=="FAILED"&&d(t,["retryScheduled"],"Only a FAILED run can have a retry scheduled.")}var Ot=Nt.superRefine(kt),wt=Nt.omit({steps:!0}).superRefine(kt);function mr(e,t){e.sampleCount>0||(e.durationP50Ms!==null&&d(t,["durationP50Ms"],"A step with no sample has no median latency."),e.durationP95Ms!==null&&d(t,["durationP95Ms"],"A step with no sample has no 95th-percentile latency."))}var ii=S.object({documentKind:_t,stepKey:Me,sampleCount:S.number().int().nonnegative(),succeeded:S.number().int().nonnegative(),failed:S.number().int().nonnegative(),skipped:S.number().int().nonnegative(),durationP50Ms:G,durationP95Ms:G,lastStartedAt:w.nullable()}).strict().superRefine(mr);var vt=1,Ke=3,Mt=64,Ut=1e6,Ge=4096,je=.3,zt=1024,Ht=67108864,Kt=16777216,Gt=500,jt=50,fi=50,hi=1e4,fr=1,ae=["classification","metadata","labels","tags","structured_data","text","summary","chunks","assets"],Bt=a.enum(ae),hr=["RUN","PRE_WRITE","MANUAL","BACKFILL"],Vt=a.enum(hr),yr=["SUCCEEDED","FAILED"],gr=a.enum(yr),Sr=["ADDED","REMOVED","MODIFIED","MOVED"],Er=a.enum(Sr),Cr=["clause","breadcrumbs"],br=a.enum(Cr),Rr=["EXACT","WHITESPACE_NORMALIZED","UNVERIFIED"],Ir=a.enum(Rr),xr=["run","ingest","failure","state","change"],yi=a.enum(xr),Ar=["LF","CRLF","CR","MIXED","NONE"],gi=a.enum(Ar),_r=["text","summary","chunks"],Si=a.enum(_r),Dr=["RECORDED","UNCHANGED"],Tr=a.enum(Dr),Jt=a.lazy(()=>a.custom(ye,"A JSON object here holds no own __proto__ member.").pipe(a.record(a.string(),j))),j=a.lazy(()=>a.union([a.string(),a.number().finite(),a.boolean(),a.null(),a.array(j),Jt])),Yt=ne.exclude([de]),M=a.number().int().positive(),I=a.number().int().nonnegative(),Ee=a.string().regex(/^[0-9a-f]{64}$/,"A SHA-256 is 64 lowercase hexadecimal digits."),B=(e,t)=>e<t?-1:e>t?1:0,Be=(e,t)=>B(e.assetType,t.assetType)||e.assetIndex-t.assetIndex,oe=(e,t,n,r,o)=>{for(let i=1;i<e.length;i++)t(e[i-1],e[i])>=0&&d(n,[...r,i],o)},Nr=a.object({confidentialityLevel:ne,departmentId:a.number().int().nullable(),folderPath:a.string().nullable(),createdBy:a.string()}).strict(),kr=a.object({fileName:a.string(),filePath:a.string(),fileId:a.string().nullable(),revision:M,revisionId:a.string().nullable(),fileSize:I,mimeType:a.string(),fileHash:a.string().nullable(),mtime:w}).strict(),Or=a.object({labelKey:a.string().min(1),assignedBy:a.string(),confidenceScore:a.number().finite()}).strict(),wr=a.object({assetType:a.string().min(1),assetIndex:I,mimeType:a.string(),fileSize:I,textSha256:Ee.nullable()}).strict(),Fr=a.object({body:a.string().nullable(),mime:a.string().nullable(),source:ze.nullable(),isTruncated:a.boolean(),pageOffsets:j}).strict(),Pr=a.object({index:I,hash:Ee,whitespaceFreeHash:Ee,charStart:I,charEnd:I,breadcrumbs:a.string(),clause:a.string().nullable(),page:a.number().int().nullable(),sheet:a.string().nullable(),slide:a.number().int().nullable(),startSec:a.number().finite().nullable(),endSec:a.number().finite().nullable(),tokenCount:I,parentOrdinal:I}).strict(),Lr=a.object({ordinal:I,contentHash:Ee,charLength:I}).strict();function vr(e,t){oe(e.children,(r,o)=>r.index-o.index,t,["children"],"Children are listed in strictly ascending index.");let n=0;e.children.forEach((r,o)=>{r.charStart>r.charEnd&&d(t,["children",o,"charEnd"],"A span ends at or after its start."),r.parentOrdinal===n?n++:r.parentOrdinal>n&&d(t,["children",o,"parentOrdinal"],"Parents are numbered in the order they first appear.")}),(e.parents.length!==n||e.parents.some((r,o)=>r.ordinal!==o))&&d(t,["parents"],"Each parent the children reach is listed exactly once, in ordinal order.")}var Mr=a.object({version:a.literal(fr),children:a.array(Pr).min(1),parents:a.array(Lr)}).strict().superRefine(vr);function Ur(e,t){oe(e.labels,(n,r)=>B(n.labelKey,r.labelKey),t,["labels"],"Labels are ordered by labelKey with no key repeated."),oe(e.tags??[],B,t,["tags"],"Tags are ordered with no tag repeated."),oe(e.assets,Be,t,["assets"],"Assets are ordered by (assetType, assetIndex) with no key repeated.")}var Ei=a.object({classification:Nr,metadata:kr,labels:a.array(Or),tags:a.array(a.string()).nullable(),structured_data:j,text:Fr,summary:a.string().nullable(),chunks:Mr.nullable(),assets:a.array(wr)}).strict().superRefine(Ur),zr=["addedCount","removedCount","modifiedCount","movedCount","unchangedCount","charsAdded","charsRemoved"],Hr={classification:["modifiedCount"],metadata:["modifiedCount"],labels:["addedCount","removedCount","modifiedCount","unchangedCount"],tags:["addedCount","removedCount","unchangedCount"],structured_data:["addedCount","removedCount","modifiedCount"],text:["addedCount","removedCount","unchangedCount","charsAdded","charsRemoved"],summary:["addedCount","removedCount","unchangedCount","charsAdded","charsRemoved"],chunks:["addedCount","removedCount","modifiedCount","movedCount","unchangedCount"],assets:["addedCount","removedCount","modifiedCount","unchangedCount"]};function Kr(e,t){let n=Hr[e.facet];for(let r of zr)n.includes(r)&&e[r]===null&&d(t,[r],`The ${e.facet} facet always counts ${r}.`),!n.includes(r)&&e[r]!==null&&d(t,[r],`${r} does not apply to the ${e.facet} facet.`)}var Gr=a.object({facet:Bt,addedCount:I.nullable(),removedCount:I.nullable(),modifiedCount:I.nullable(),movedCount:I.nullable(),unchangedCount:I.nullable(),charsAdded:I.nullable(),charsRemoved:I.nullable()}).strict().superRefine(Kr),Ft=new Map(ae.map((e,t)=>[e,t])),Ve=(e,t)=>Ft.get(e)-Ft.get(t),$t=a.array(Gr).min(1).superRefine((e,t)=>oe(e,(n,r)=>Ve(n.facet,r.facet),t,[],"A change lists each changed facet once, in display order.")),Je=a.object({field:a.string().min(1),before:j,after:j}).strict(),Pt=a.object({key:a.string().min(1),value:Jt}).strict(),jr=a.object({key:a.string().min(1),fields:a.array(Je).min(1)}).strict(),He=a.string().refine(e=>e===""||e.startsWith("/"),"A JSON Pointer is empty or starts with '/'."),Br=a.discriminatedUnion("op",[a.object({op:a.literal("add"),path:He,value:j}).strict(),a.object({op:a.literal("remove"),path:He,previous:j}).strict(),a.object({op:a.literal("replace"),path:He,value:j,previous:j}).strict()]),Vr=a.object({linesAdded:I,linesRemoved:I,linesUnchanged:I,charsAdded:I,charsRemoved:I,similarity:a.number().min(0).max(1).nullable()}).strict();function Jr(e,t){e.linesAdded>e.newLines&&d(t,["linesAdded"],"A hunk adds no more lines than it spans on the new side."),e.linesRemoved>e.oldLines&&d(t,["linesRemoved"],"A hunk removes no more lines than it spans on the old side."),e.linesAdded+e.linesRemoved===0&&d(t,["linesAdded"],"A hunk changes at least one line.")}var Yr=a.object({hunk:I,oldStart:I,oldLines:I,newStart:I,newLines:I,firstPage:a.number().int().nullable(),linesAdded:I,linesRemoved:I}).strict().superRefine(Jr),qt=(e,t)=>{e.forEach((n,r)=>{n.hunk!==r&&d(t,["hunks",r,"hunk"],"Hunks are numbered from 0 in order.")})},Xt={attributes:a.array(Je),stats:Vr,hunks:a.array(Yr)},Ci=a.object(Xt).strict().superRefine((e,t)=>qt(e.hunks,t)),$r=a.object({kind:a.enum(["equal","removed","added"]),text:a.string().min(1)}).strict(),qr={context:["equal"],removed:["equal","removed"],added:["equal","added"]};function Xr(e,t){e.oldNumber===null!=(e.kind==="added")&&d(t,["oldNumber"],"Context and removed lines carry their old number; added lines carry none."),e.newNumber===null!=(e.kind==="removed")&&d(t,["newNumber"],"Context and added lines carry their new number; removed lines carry none."),e.segments.forEach((n,r)=>{qr[e.kind].includes(n.kind)||d(t,["segments",r,"kind"],`A ${e.kind} line has no ${n.kind} segment.`)})}var Wr=a.object({kind:a.enum(["context","removed","added"]),oldNumber:M.nullable(),newNumber:M.nullable(),page:a.number().int().nullable(),segments:a.array($r)}).strict().superRefine(Xr),bi=a.object({lines:a.array(Wr).max(Gt),next:I.nullable()}).strict().superRefine((e,t)=>{e.next!==null&&e.lines.length===0&&d(t,["next"],"An empty page has no next page.")}),Wt=a.number().int().min(1).max(Gt),Ri=a.number().int().min(1).max(jt),Lt=a.object({index:I,charStart:I,charEnd:I,page:a.number().int().nullable(),sheet:a.string().nullable(),slide:a.number().int().nullable(),startSec:a.number().finite().nullable(),endSec:a.number().finite().nullable(),breadcrumbs:a.string(),tokenCount:I,fidelity:Ir}).strict();function Qr(e,t){e.old===null!=(e.kind==="ADDED")&&d(t,["old"],"Every chunk change but ADDED has an old chunk."),e.new===null!=(e.kind==="REMOVED")&&d(t,["new"],"Every chunk change but REMOVED has a new chunk."),e.pairing===null==(e.kind==="MODIFIED")&&d(t,["pairing"],"A MODIFIED pair names the rule that paired it; no other change has one.")}var Zr=a.object({entry:I,kind:Er,pairing:br.nullable(),old:Lt.nullable(),new:Lt.nullable()}).strict().superRefine(Qr),eo=a.object({added:I,removed:I,modified:I,moved:I,unchanged:I}).strict();function to(e,t){e.entries.forEach((o,i)=>{o.entry!==i&&d(t,["entries",i,"entry"],"Chunk entries are numbered from 0 in order.")});let n={ADDED:0,REMOVED:0,MODIFIED:0,MOVED:0};for(let o of e.entries)n[o.kind]++;let r=[["added",n.ADDED],["removed",n.REMOVED],["modified",n.MODIFIED],["moved",n.MOVED]];for(let[o,i]of r)e.stats[o]!==i&&d(t,["stats",o],`The ${o} count equals the number of entries of that kind.`)}var no=a.union([a.object({facet:Bt,change:a.literal("UNCHANGED")}).strict(),a.object({facet:a.enum(["classification","metadata"]),change:a.literal("CHANGED"),fields:a.array(Je).min(1)}).strict(),a.object({facet:a.enum(["labels","assets"]),change:a.literal("CHANGED"),added:a.array(Pt),removed:a.array(Pt),modified:a.array(jr),unchangedCount:I}).strict(),a.object({facet:a.literal("tags"),change:a.literal("CHANGED"),added:a.array(a.string()),removed:a.array(a.string()),unchangedCount:I}).strict(),a.object({facet:a.literal("structured_data"),change:a.literal("CHANGED"),operations:a.array(Br).min(1)}).strict(),a.object({facet:a.enum(["text","summary"]),change:a.literal("CHANGED"),...Xt}).strict().superRefine((e,t)=>qt(e.hunks,t)),a.object({facet:a.literal("chunks"),change:a.literal("CHANGED"),stats:eo,entries:a.array(Zr),textUnchangedChunkingChanged:a.boolean()}).strict().superRefine(to)]),Ii=a.object({diffEngineVersion:M,facets:a.array(no)}).strict().superRefine((e,t)=>{(e.facets.length!==ae.length||e.facets.some((n,r)=>n.facet!==ae[r]))&&d(t,["facets"],"A comparison carries every facet once, in display order.")}),Ce=e=>a.object({kind:a.literal("readable"),item:e}).strict(),Qt=a.object({kind:a.literal("restricted"),subject:a.literal("run"),startedAt:w,finishedAt:w.nullable(),status:Ue}).strict(),xi=a.object({kind:a.literal("restricted"),subject:a.literal("ingest"),createdAt:w,updatedAt:w,syncStatus:mt.nullable()}).strict(),Ai=a.object({kind:a.literal("restricted"),subject:a.literal("failure"),failedAt:w.nullable(),syncStatus:Dt}).strict(),ro=a.object({kind:a.literal("restricted"),subject:a.literal("state"),settledAt:w}).strict(),oo=a.object({kind:a.literal("restricted"),subject:a.literal("change"),settledAt:w}).strict();function ao(e,t){let n=e.cause==="RUN";e.runId!==null!==n&&d(t,["runId"],"A RUN state names its run; no other state does."),e.runOutcome!==null!==n&&d(t,["runOutcome"],"A RUN state carries the worker's outcome; no other state does."),e.changes!==null!=(e.previousStateId!==null)&&d(t,["changes"],"A state carries its counts exactly when its predecessor is readable."),e.diffEngineVersion!==null!=(e.changes!==null)&&d(t,["diffEngineVersion"],"The engine version comes with the counts it produced."),e.modelOnlyChange&&e.changes===null&&d(t,["modelOnlyChange"],"Only a change with counts can be a model-only change."),e.previousStateId===e.stateId&&d(t,["previousStateId"],"A state does not precede itself.")}var io=a.object({stateId:M,revision:M,cause:Vt,runId:M.nullable(),runOutcome:gr.nullable(),settledAt:w,actor:a.string().min(1),classification:a.object({confidentialityLevel:Yt,departmentId:a.number().int().nullable(),folderPath:a.string().nullable()}).strict(),modelOnlyChange:a.boolean(),previousStateId:M.nullable(),changes:$t.nullable(),diffEngineVersion:M.nullable()}).strict().superRefine(ao),so=a.discriminatedUnion("kind",[Ce(io),ro]),lo=a.discriminatedUnion("kind",[Ce(Ot),Qt]),_i=a.discriminatedUnion("kind",[Ce(wt),Qt]),Zt=(e,t,n)=>{for(let r=1;r<e.length;r++)X(e[r-1],e[r])&&d(t,[...n,r],"Entries are listed newest first.")},Se=e=>e.kind==="readable"?e.item.settledAt:e.settledAt;function co(e,t){oe(e.revisions,(r,o)=>o.revision-r.revision,t,["revisions"],"Revisions are listed newest first, each once.");let n=e.revisions.filter(r=>r.isCurrent);(n.length!==1||n[0]?.metadataId!==e.document.metadataId||n[0].revision!==e.document.revision)&&d(t,["revisions"],"Exactly one revision is current: the row the history names."),Zt(e.states.map(Se),t,["states"])}var Di=a.object({document:a.object({metadataId:M,fileName:a.string().min(1),fileUri:a.string().min(1),revision:M,confidentialityLevel:Yt}).strict(),revisions:a.array(a.object({metadataId:M,revision:M,revisionId:a.string().nullable(),isCurrent:a.boolean()}).strict()),states:a.array(so),runs:a.array(lo)}).strict().superRefine(co),uo=a.object({stateId:M,previousStateId:M,metadataId:M,fileName:a.string().min(1),fileUri:a.string().min(1),revision:M,previousRevision:M,cause:Vt,actor:a.string().min(1),settledAt:w,changes:$t}).strict().superRefine((e,t)=>{e.previousStateId===e.stateId&&d(t,["previousStateId"],"A state does not precede itself.")}),po=a.discriminatedUnion("kind",[Ce(uo),oo]),en=a.object({settledAt:w,id:M.max(Number.MAX_SAFE_INTEGER)}).strict(),ue="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";function mo(e){let t="";for(let n=0;n<e.length;n+=3){let r=e.length-n,o=e[n]<<16|(r>1?e[n+1]:0)<<8|(r>2?e[n+2]:0);t+=ue[o>>18&63]+ue[o>>12&63],r>1&&(t+=ue[o>>6&63]),r>2&&(t+=ue[o&63])}return t}function fo(e){if(e.length%4===1)return null;let t=[],n=0,r=0;for(let o of e){let i=ue.indexOf(o);if(i===-1)return null;n=n<<6|i,r+=6,r>=8&&(r-=8,t.push(n>>r&255),n&=(1<<r)-1)}return Uint8Array.from(t)}function ho(e){let{settledAt:t,id:n}=en.parse(e);return mo(new TextEncoder().encode(U({id:n,settledAt:t})))}function yo(e){let t=fo(e);if(t===null)return null;let n;try{n=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(t))}catch{return null}let r=en.safeParse(n);return r.success&&ho(r.data)===e?r.data:null}var Ti=a.object({rows:a.array(po).max(jt),next:a.string().nullable()}).strict().superRefine((e,t)=>{Zt(e.rows.map(Se),t,["rows"]),e.next!==null&&e.rows.length===0&&d(t,["next"],"An empty page has no next page.");let n=e.next===null?null:yo(e.next);e.next!==null&&n===null&&d(t,["next"],"The next position is a cursor encodeChangeFeedCursor wrote.");let r=e.rows[e.rows.length-1];n!==null&&r!==void 0&&(X(n.settledAt,Se(r))||X(Se(r),n.settledAt))&&d(t,["next"],"The next position is the arriving state of the page's last row."),n!==null&&r?.kind==="readable"&&n.id!==r.item.stateId&&d(t,["next"],"The next position names the arriving state of the page's last readable row.")}),Ni=a.object({outcome:Tr}).strict();import{z as p}from"zod";var tn=[{code:"DEPLOYMENT_DISABLED",status:503,errorCode:5035},{code:"RUN_ALREADY_ACTIVE",status:409,errorCode:4091},{code:"BASIS_INVALID",status:409,errorCode:4092},{code:"RUN_ALREADY_FINISHED",status:409,errorCode:4093},{code:"FORBIDDEN",status:403,errorCode:null}];var nn={INTEGRITY_TOMBSTONE_RETENTION_DAYS:{min:1,max:3650},INTEGRITY_FINDING_SAMPLE_LIMIT:{min:1,max:5e3},INTEGRITY_RUN_HEARTBEAT_TIMEOUT_SECONDS:{min:30,max:3600},INTEGRITY_RUN_RETENTION_COUNT:{min:2,max:100},POLICY_CONFLICT_MAX_TIE_GROUP_SIZE:{min:2,max:60}};var Eo=e=>{for(let t of Object.values(e))Object.freeze(t);return Object.freeze(e)},be=Eo(nn),rn=e=>Object.hasOwn(be,e),on=(e,t)=>{let{min:n,max:r}=be[e];if(!Number.isInteger(t)||t<n||t>r)throw new RangeError(`${e} \u306F ${n}\u301C${r} \u306E\u6574\u6570\u3067\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002`)},Pi=(e,t)=>{rn(e)&&on(e,t)},Li=(e,t)=>{if(!rn(e))throw new TypeError(`The range table bounds no parameter named ${JSON.stringify(e)}.`);on(e,t)};var qe=p.enum(["QDRANT","NEO4J"]),Co=p.enum(["PRODUCTION","VARIANT","LABEL"]),ln=p.enum(["EXPECTED","LIVE","HISTORY","TOMBSTONE","AWAITING_SUCCESSOR","IN_FLIGHT","UNPLACED","UNRECORDED","UNREFERENCED","CHANGED_AFTER_START","PIPELINE_FAILED","PROJECTION_REFUSED","ORPHAN","TOMBSTONE_EXPIRED","UNPROPAGATED_DELETE","STALE_REVISION","MISPLACED","OUT_OF_TIER","UNMARKED_SUPERSEDED","FLAG_DRIFT","VARIANT_FLAG_DRIFT","DETACHED","UNKEYED","MISSING","COUNT_MISMATCH","UNPROJECTED","UNKEYED_ENTITY"]),cn=ln.exclude(["EXPECTED","LIVE","HISTORY"]),bo=p.enum(["POINT","NODE","CHUNK","DOCUMENT"]),Ro=p.enum(["EXPECTED","HEALTHY","RETAINED","INFORMATIONAL","DISCREPANCY"]),Io=p.enum(["NONE","PURGE","FLAG","REPROJECT"]),k=(e,t)=>Object.freeze({disposition:e,repairAction:t}),xo=Object.freeze({EXPECTED:k("EXPECTED","NONE"),LIVE:k("HEALTHY","NONE"),HISTORY:k("RETAINED","NONE"),TOMBSTONE:k("RETAINED","NONE"),AWAITING_SUCCESSOR:k("RETAINED","NONE"),IN_FLIGHT:k("INFORMATIONAL","NONE"),UNPLACED:k("INFORMATIONAL","NONE"),UNRECORDED:k("INFORMATIONAL","NONE"),UNREFERENCED:k("INFORMATIONAL","NONE"),CHANGED_AFTER_START:k("INFORMATIONAL","NONE"),PIPELINE_FAILED:k("INFORMATIONAL","NONE"),PROJECTION_REFUSED:k("INFORMATIONAL","NONE"),ORPHAN:k("DISCREPANCY","PURGE"),TOMBSTONE_EXPIRED:k("DISCREPANCY","PURGE"),UNPROPAGATED_DELETE:k("DISCREPANCY","FLAG"),STALE_REVISION:k("DISCREPANCY","PURGE"),MISPLACED:k("DISCREPANCY","PURGE"),OUT_OF_TIER:k("DISCREPANCY","PURGE"),UNMARKED_SUPERSEDED:k("DISCREPANCY","FLAG"),FLAG_DRIFT:k("DISCREPANCY","REPROJECT"),VARIANT_FLAG_DRIFT:k("DISCREPANCY","NONE"),DETACHED:k("DISCREPANCY","PURGE"),UNKEYED:k("DISCREPANCY","PURGE"),MISSING:k("DISCREPANCY","REPROJECT"),COUNT_MISMATCH:k("DISCREPANCY","REPROJECT"),UNPROJECTED:k("DISCREPANCY","REPROJECT"),UNKEYED_ENTITY:k("DISCREPANCY","NONE")}),Ao=p.enum(["SCAN","REPAIR"]),_o=p.enum(["RUNNING","COMPLETED","FAILED","CANCELLED","ABANDONED"]),Do=p.enum(["CONSISTENT","INCONSISTENT","UNDETERMINED"]),To=p.enum(["QDRANT","NEO4J","DOCUMENTS"]),No=p.enum(["APPLIED","SKIPPED","FAILED"]),ko=p.enum(["RECLASSIFIED","IN_FLIGHT","DESTINATION_PENDING","BASIS_EXHAUSTED","PROJECTION_REFUSED","PIPELINE_FAILED","UNRECORDED","OUTSIDE"]),Re=100,H=p.number().int().nonnegative(),Ie=p.number().int().min(300).max(599),Ye=["repairedCount","repairFailedCount","repairSkippedCount"],dn=p.string().regex(/^[0-9a-f]{64}$/,"A store fingerprint is 64 lowercase hexadecimal digits."),an=be.INTEGRITY_TOMBSTONE_RETENTION_DAYS,Oo=p.object({runUid:re,mode:Ao,status:_o,requestedBy:p.string().min(1),executor:p.string().min(1),basisRunUid:re.nullable(),storeFingerprint:dn,tombstoneRetentionDays:p.number().int().min(an.min).max(an.max),startedAt:w,finishedAt:w.nullable(),verdict:Do.nullable(),errorClass:p.string().min(1).nullable(),reprojectDocuments:H.nullable(),reprojectRebuildDocuments:H.nullable()}).strict(),wo=(e,t)=>{let n=e.status==="COMPLETED";e.mode==="REPAIR"!=(e.basisRunUid!==null)&&d(t,["basisRunUid"],"A REPAIR run names its basis SCAN run, and a SCAN run names none."),n!==(e.verdict!==null)&&d(t,["verdict"],"Only a COMPLETED run has a verdict."),n!==(e.reprojectDocuments!==null)&&d(t,["reprojectDocuments"],"Only a COMPLETED run has the count of documents to re-project.");let{reprojectDocuments:r,reprojectRebuildDocuments:o}=e;r===null||o===null?r!==o&&d(t,["reprojectRebuildDocuments"],"The documents a re-projection embeds are counted together with the documents it re-projects."):o>r&&d(t,["reprojectRebuildDocuments"],"The documents a re-projection embeds are no more than the documents it re-projects."),e.status==="RUNNING"!=(e.finishedAt===null)&&d(t,["finishedAt"],"Only a RUNNING run has not finished."),e.finishedAt!==null&&X(e.finishedAt,e.startedAt)&&d(t,["finishedAt"],"A run does not finish before it starts."),(e.status==="FAILED"||e.status==="ABANDONED")!=(e.errorClass!==null)&&d(t,["errorClass"],"Only a FAILED or ABANDONED run names an error class.")},Xe=Oo.superRefine(wo),Fo=p.object({store:qe,scopeKey:p.string().min(1),scopeRole:Co,itemClass:ln,unit:bo,disposition:Ro,repairAction:Io,itemCount:H.nullable(),unmeasuredReason:p.string().min(1).nullable(),measuredAt:w.nullable(),repairedCount:H.nullable(),repairFailedCount:H.nullable(),repairSkippedCount:H.nullable()}).strict(),Po=(e,t)=>{let n=xo[e.itemClass];e.disposition!==n.disposition&&d(t,["disposition"],`A ${e.itemClass} quantity is ${n.disposition}.`),e.repairAction!==n.repairAction&&d(t,["repairAction"],`A repair's action on ${e.itemClass} items is ${n.repairAction}.`);let r=e.itemCount===null;r!==(e.unmeasuredReason!==null)&&d(t,["unmeasuredReason"],"An unmeasured quantity (itemCount null) has a reason, and a measured one has none."),r!==(e.measuredAt===null)&&d(t,["measuredAt"],"Only a measured quantity has a measurement time.");let{repairedCount:o,repairFailedCount:i,repairSkippedCount:l}=e;if(o===null||i===null||l===null){if(Ye.some(s=>e[s]!==null))for(let s of Ye)e[s]===null&&d(t,[s],"The repaired, failed and skipped counts are recorded together or not at all.");return}e.repairAction==="NONE"&&d(t,["repairAction"],"Only a class with a repair action carries repair counts."),e.itemCount!==null&&o+i+l>e.itemCount&&d(t,["itemCount"],"The repaired, failed and skipped counts together do not exceed the measured count.")},Lo=Fo.superRefine(Po),vo=p.object({run:Xe,phase:To.nullable(),phaseScope:p.string().min(1).nullable(),phaseDone:H.nullable(),phaseTotal:H.nullable(),heartbeatAt:w,isStale:p.boolean(),cancelRequestedAt:w.nullable()}).strict(),Mo=(e,t)=>{if(e.run.status!=="RUNNING"&&d(t,["run","status"],"The active run is a RUNNING run."),X(e.heartbeatAt,e.run.startedAt)&&d(t,["heartbeatAt"],"A run's heartbeat is not earlier than its start."),e.phase===null)for(let n of["phaseScope","phaseDone","phaseTotal"])e[n]!==null&&d(t,[n],"A run with no phase has no phase progress.");e.phase==="DOCUMENTS"&&e.phaseScope!==null&&d(t,["phaseScope"],"The DOCUMENTS phase scans no scope.")},Uo=vo.superRefine(Mo),zo=p.object({run:Xe,quantities:p.array(Lo),previousStoreFingerprint:dn.nullable()}).strict(),Ho=(e,t)=>{e.run.status!=="COMPLETED"&&d(t,["run","status"],"The last completed run is a COMPLETED run.");let n=new Set;for(let[r,o]of e.quantities.entries()){let i=JSON.stringify([o.store,o.scopeKey,o.itemClass]);if(n.has(i)&&d(t,["quantities",r],"A run records each (store, scope, class) cell once."),n.add(i),e.run.mode==="SCAN")for(let l of Ye)o[l]!==null&&d(t,["quantities",r,l],"A SCAN run repairs nothing, so its quantities carry no repair counts.")}},Ko=["FAILED","CANCELLED","ABANDONED"],Go=p.object({run:Xe,repairAppliedItems:H.nullable(),hasNewerRepair:p.boolean()}).strict(),jo=(e,t)=>{Ko.includes(e.run.status)||d(t,["run","status"],"A newer unsuccessful run is FAILED, CANCELLED or ABANDONED."),e.run.mode==="SCAN"&&e.repairAppliedItems!==null&&d(t,["repairAppliedItems"],"A SCAN run applies nothing."),e.run.mode==="REPAIR"&&!e.hasNewerRepair&&d(t,["hasNewerRepair"],"An unsuccessful REPAIR run is itself a repair newer than the last completed run.")},Ki=p.object({readAt:w,lastCompleted:zo.superRefine(Ho).nullable(),active:Uo.nullable(),newerUnsuccessful:Go.superRefine(jo).nullable()}).strict(),Bo=p.object({sequence:p.number().int().min(1),itemKey:p.string().min(1),metadataId:p.number().int().positive().nullable(),fileUri:p.string().nullable(),revision:p.number().int().nullable(),observed:p.record(p.string(),p.unknown()),repairOutcome:No.nullable(),repairErrorClass:p.string().min(1).nullable(),repairSkipReason:ko.nullable()}).strict(),Vo=(e,t)=>{e.repairOutcome==="FAILED"!=(e.repairErrorClass!==null)&&d(t,["repairErrorClass"],"Only a FAILED finding names an error class."),e.repairOutcome==="SKIPPED"!=(e.repairSkipReason!==null)&&d(t,["repairSkipReason"],"Only a SKIPPED finding names a skip reason.")},Jo=Bo.superRefine(Vo),Gi=p.object({sotDomain:p.string().nullable()}).passthrough(),Yo=p.object({rows:p.array(Jo),nextAfter:p.number().int().min(1).nullable(),recordedCount:H,totalCount:H.nullable()}).strict(),$o=(e,t)=>{for(let[n,r]of e.rows.entries()){let o=e.rows[n-1];o!==void 0&&r.sequence<=o.sequence&&d(t,["rows",n,"sequence"],"A page lists its rows in ascending sequence.")}e.nextAfter!==null&&e.nextAfter!==e.rows.at(-1)?.sequence&&d(t,["nextAfter"],"The next page starts after the sequence of this page's last row.")},ji=Yo.superRefine($o),Bi=p.object({runUid:re,store:qe,scopeKey:p.string().min(1),itemClass:cn,after:p.number().int().min(1).optional(),limit:p.number().int().min(1).max(Re)}).strict(),Vi=p.object({runUid:re,store:qe,scopeKey:p.string().min(1),itemClass:cn.extract(["UNRECORDED"]),after:p.number().int().min(1).optional()}).strict(),qo=p.object({requeued:H,skipped:p.array(p.object({metadataId:p.number().int().min(1),reason:p.string().min(1)}).strict()),nextAfter:p.number().int().min(1).nullable()}).strict(),Xo=(e,t)=>{let n=e.requeued+e.skipped.length;n>Re&&d(t,["requeued"],`One chunk settles at most ${Re} documents.`),e.nextAfter!==null!=(n===Re)&&d(t,["nextAfter"],"A chunk continues exactly when it read the limit.");let r=new Set;for(let[o,i]of e.skipped.entries())r.has(i.metadataId)&&d(t,["skipped",o,"metadataId"],"A chunk keeps a document back once."),r.add(i.metadataId)},Ji=qo.superRefine(Xo),We=p.enum(["DEPLOYMENT_DISABLED","RUN_ALREADY_ACTIVE","BASIS_INVALID","RUN_ALREADY_FINISHED","FORBIDDEN","UPSTREAM_FAILED"]),sn=p.enum(["start","cancel"]),Wo=We.extract(["DEPLOYMENT_DISABLED","RUN_ALREADY_ACTIVE","BASIS_INVALID","FORBIDDEN","UPSTREAM_FAILED"]),Qo=We.extract(["DEPLOYMENT_DISABLED","RUN_ALREADY_FINISHED","FORBIDDEN","UPSTREAM_FAILED"]),$e={start:Wo,cancel:Qo},Zo=p.object({code:We.exclude(["UPSTREAM_FAILED"]),status:Ie,errorCode:p.number().int().nullable()}).strict(),un=Object.freeze(p.array(Zo).parse(tn).map(e=>Object.freeze(e))),ea=(e,t)=>{e.code==="UPSTREAM_FAILED"||e.code==="FORBIDDEN"&&e.status===null||un.some(n=>n.code===e.code&&n.status===e.status)||d(t,["status"],`A ${e.code} failure carries the status of its row in the code table.`)},Yi=p.discriminatedUnion("command",[p.object({command:sn.extract(["start"]),code:$e.start,status:Ie.nullable()}).strict(),p.object({command:sn.extract(["cancel"]),code:$e.cancel,status:Ie.nullable()}).strict()]).superRefine(ea),$i=(e,t,n)=>{let r=$e[e],o=un.find(i=>i.status===t&&(i.errorCode===null||i.errorCode===n)&&r.safeParse(i.code).success);return o===void 0?"UPSTREAM_FAILED":o.code},qi=p.discriminatedUnion("ok",[p.object({ok:p.literal(!0),runUid:re}).strict(),p.object({ok:p.literal(!1),status:Ie,errorCode:p.number().int().nullable()}).strict()]);function ta(e){let t=[];for(let r=0;r<e.length;r++){t.push(r);let o=e.charCodeAt(r);o>=55296&&o<=56319&&r+1<e.length&&(e.charCodeAt(r+1)&64512)===56320&&r++}t.push(e.length);let n=t.length-1;return{length:n,slice(r,o){if(!(Number.isInteger(r)&&Number.isInteger(o))||r<0||r>o)throw new RangeError(`A code-point span is [charStart, charEnd) with 0 <= charStart <= charEnd: [${r}, ${o})`);return o>n?null:e.slice(t[r],t[o])}}}var na=e=>e.replace(/\s/gu,"");function W(e,t){let n=new Map,r=i=>{let l=new Int32Array(i.length);return i.forEach((s,c)=>{let h=n.get(s);h===void 0&&(h=n.size,n.set(s,h)),l[c]=h}),l};return{old:r(e),new:r(t),alphabetSize:n.size}}function xe(e,t,n,r){if(r===0)return;let o=e[e.length-1];if(o!==void 0&&o.oldStart+o.length===t&&o.newStart+o.length===n){o.length+=r;return}e.push({oldStart:t,newStart:n,length:r})}function pn(e,t,n,r,o,i,l){let s=0;for(;n+s<r&&o+s<i&&e[n+s]===t[o+s];)s++;xe(l,n,o,s);let c=0;for(;r-c>n+s&&i-c>o+s&&e[r-1-c]===t[i-1-c];)c++;return{oldLow:n+s,oldHigh:r-c,newLow:o+s,newHigh:i-c,suffix:c}}function ra(e,t,n){let{oldLow:r,oldHigh:o,newLow:i,newHigh:l}=n,s=o-r,c=l-i,h=Math.ceil((s+c)/2),u=h,y=2*h+2,E=new Int32Array(y).fill(-1),_=new Int32Array(y).fill(-1);E[u+1]=0,_[u+1]=0;let C=s-c,N=C%2!==0,O=0,g=0,T=0,f=0;for(let R=0;R<h;R++){for(let D=-R+O;D<=R-g;D+=2){let x=u+D,A=D===-R||D!==R&&E[x-1]<E[x+1]?E[x+1]:E[x-1]+1,P=A-D;for(;A<s&&P<c&&e[r+A]===t[i+P];)A++,P++;if(E[x]=A,A>s)g+=2;else if(P>c)O+=2;else if(N){let v=u+C-D;if(v>=0&&v<y&&_[v]!==-1&&A>=s-_[v])return{kind:"split",oldSplit:r+A,newSplit:i+P}}}for(let D=-R+T;D<=R-f;D+=2){let x=u+D,A=D===-R||D!==R&&_[x-1]<_[x+1]?_[x+1]:_[x-1]+1,P=A-D;for(;A<s&&P<c&&e[o-1-A]===t[l-1-P];)A++,P++;if(_[x]=A,A>s)f+=2;else if(P>c)T+=2;else if(!N){let v=u+C-D;if(v>=0&&v<y&&E[v]!==-1){let b=E[v];if(b>=s-A)return{kind:"split",oldSplit:r+b,newSplit:i+u+b-v}}}}}return{kind:"disjoint"}}function Q(e,t){let n=[],r=[{kind:"region",oldLow:0,oldHigh:e.length,newLow:0,newHigh:t.length}];for(let o=r.pop();o!==void 0;o=r.pop()){if(o.kind==="run"){xe(n,o.oldStart,o.newStart,o.length);continue}let i=pn(e,t,o.oldLow,o.oldHigh,o.newLow,o.newHigh,n);if(r.push({kind:"run",oldStart:i.oldHigh,newStart:i.newHigh,length:i.suffix}),i.oldLow===i.oldHigh||i.newLow===i.newHigh)continue;let l=ra(e,t,i);l.kind==="split"&&(r.push({kind:"region",oldLow:l.oldSplit,oldHigh:i.oldHigh,newLow:l.newSplit,newHigh:i.newHigh}),r.push({kind:"region",oldLow:i.oldLow,oldHigh:l.oldSplit,newLow:i.newLow,newHigh:l.newSplit}))}return n}function mn(e,t,n){let r=Math.ceil(t.length/32),o=new Array(n);t.forEach((s,c)=>{let h=o[s];h===void 0&&(h=new Uint32Array(r),o[s]=h),h[c>>>5]=(h[c>>>5]|1<<(c&31))>>>0});let i=new Uint32Array(r).fill(4294967295);for(let s of e){let c=o[s];if(c===void 0)continue;let h=0;for(let u=0;u<r;u++){let y=i[u],E=(y&c[u])>>>0,_=y+E+h;h=_>4294967295?1:0,i[u]=(_>>>0|y&~c[u])>>>0}}let l=0;for(let s=0;s<t.length;s++)l+=i[s>>>5]>>>(s&31)&1;return t.length-l}function oa(e,t,n){if(e.occurrences!==t.occurrences)return e.occurrences<t.occurrences;if(e.length!==t.length)return e.length>t.length;let r=Math.abs(2*e.oldStart+e.length-n),o=Math.abs(2*t.oldStart+t.length-n);return r!==o?r<o:e.newStart<t.newStart||e.newStart===t.newStart&&e.oldStart<t.oldStart}function fn(e,t){let{old:n,new:r,alphabetSize:o}=e,i=new Int32Array(o),l=new Int32Array(o),s=new Int32Array(o).fill(-1),c=new Int32Array(n.length),h=[],u=[{kind:"region",oldLow:0,oldHigh:n.length,newLow:0,newHigh:r.length}];for(let y=u.pop();y!==void 0;y=u.pop()){if(y.kind==="run"){xe(h,y.oldStart,y.newStart,y.length);continue}let E=pn(n,r,y.oldLow,y.oldHigh,y.newLow,y.newHigh,h),_={kind:"run",oldStart:E.oldHigh,newStart:E.newHigh,length:E.suffix},{oldLow:C,oldHigh:N,newLow:O,newHigh:g}=E;if(C===N||O===g){u.push(_);continue}for(let x=N-1;x>=C;x--){let A=n[x];i[A]++,c[x]=s[A],s[A]=x}let T={best:null},f=x=>{(T.best===null||oa(x,T.best,C+N))&&(T.best=x)},R=new Map;for(let x=O;x<g;x++){let A=r[x],P=i[A];if(!(P===0||P>t.maxOccurrences||T.best!==null&&P>T.best.occurrences))for(let v=s[A];v!==-1;v=c[v]){let b=R.get(x-v);if(b!==void 0&&x>=b.newStart&&x<b.newEnd){P<b.occurrences&&(b.occurrences=P,f({occurrences:P,oldStart:b.oldStart,newStart:b.newStart,length:b.newEnd-b.newStart}));continue}let L=v,F=x;for(;L>C&&F>O&&n[L-1]===r[F-1];)L--,F--;let z=v-L+1;for(;L+z<N&&F+z<g&&n[L+z]===r[F+z];)z++;R.set(x-v,{oldStart:L,newStart:F,newEnd:F+z,occurrences:P}),f({occurrences:P,oldStart:L,newStart:F,length:z})}}let D=T.best;D!==null?(u.push(_),u.push({kind:"region",oldLow:D.oldStart+D.length,oldHigh:N,newLow:D.newStart+D.length,newHigh:g}),u.push({kind:"run",oldStart:D.oldStart,newStart:D.newStart,length:D.length}),u.push({kind:"region",oldLow:C,oldHigh:D.oldStart,newLow:O,newHigh:D.newStart})):(aa(n,r,E,i,l,t.cellBound,h),u.push(_));for(let x=C;x<N;x++){let A=n[x];i[A]=0,s[A]=-1}}return h}function aa(e,t,n,r,o,i,l){let{oldLow:s,oldHigh:c,newLow:h,newHigh:u}=n;if((c-s)*(u-h)>i)return;for(let C=h;C<u;C++)o[t[C]]++;let y=[];for(let C=s;C<c;C++)o[e[C]]>0&&y.push(C);let E=[];for(let C=h;C<u;C++)r[t[C]]>0&&E.push(C),o[t[C]]=0;let _=Q(Int32Array.from(y,C=>e[C]),Int32Array.from(E,C=>t[C]));for(let C of _)for(let N=0;N<C.length;N++)xe(l,y[C.oldStart+N],E[C.newStart+N],1)}function hn(e,t,n){let r=[],o=0,i=0;for(let l of[...n,{oldStart:e,newStart:t,length:0}])(l.oldStart>o||l.newStart>i)&&r.push({oldStart:o,oldEnd:l.oldStart,newStart:i,newEnd:l.newStart}),o=l.oldStart+l.length,i=l.newStart+l.length;return r}function Qe(e,t,n,r){let o=new Map;for(let l of t){let s=r(l);s!==null&&o.set(s,[...o.get(s)??[],l])}let i=[];for(let l of e){let s=n(l),c=s===null?void 0:o.get(s)?.shift();c!==void 0&&i.push([l,c])}return i}function yn(e,t){let n=new Map;for(let r of e){let o=t[r].clause;o!==null&&n.set(o,(n.get(o)??0)+1)}return n}var V=e=>e.flatMap((t,n)=>t===null?[n]:[]);function Ze(e,t){let n=e?.children??[],r=t?.children??[],o=W(n.map(f=>f.hash),r.map(f=>f.hash)),i=n.map(()=>null),l=r.map(()=>null),s=[],c=n.map(()=>0),h=r.map(()=>0);for(let f of Q(o.old,o.new))for(let R=0;R<f.length;R++)i[f.oldStart+R]=f.newStart+R,l[f.newStart+R]=f.oldStart+R;let u=0;n.forEach((f,R)=>{c[R]=u,u+=i[R]===null?0:1}),u=0,r.forEach((f,R)=>{h[R]=u,l[R]!==null&&(s.push(R),u++)});let y=[],E=(f,R,D)=>{for(let[x,A]of f)i[x]=A,l[A]=x,y.push({entry:{kind:R,pairing:D,oldPosition:x,newPosition:A},order:[A,1,A]})},_=f=>n[f],C=f=>r[f];E(Qe(V(i),V(l),f=>_(f).hash,f=>C(f).hash),"MOVED",null);let N=yn(V(i),n),O=yn(V(l),r),g=f=>f.clause!==null&&N.get(f.clause)===1&&O.get(f.clause)===1?f.clause:null;E(Qe(V(i),V(l),f=>g(_(f)),f=>g(C(f))),"MODIFIED","clause"),E(Qe(V(i),V(l),f=>JSON.stringify([c[f],_(f).breadcrumbs]),f=>JSON.stringify([h[f],C(f).breadcrumbs])),"MODIFIED","breadcrumbs");for(let f of V(i)){let R=c[f],D=R===0?0:s[R-1]+1;y.push({entry:{kind:"REMOVED",pairing:null,oldPosition:f,newPosition:null},order:[D,0,f]})}for(let f of V(l))y.push({entry:{kind:"ADDED",pairing:null,oldPosition:null,newPosition:f},order:[f,1,f]});y.sort((f,R)=>f.order[0]-R.order[0]||f.order[1]-R.order[1]||f.order[2]-R.order[2]);let T=f=>y.filter(({entry:R})=>R.kind===f).length;return{entries:y.map(({entry:f})=>f),stats:{added:T("ADDED"),removed:T("REMOVED"),modified:T("MODIFIED"),moved:T("MOVED"),unchanged:s.length}}}var Ae=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),ie=(e,t)=>`${e}/${String(t).replace(/~/g,"~0").replace(/\//g,"~1")}`;function et(e,t,n,r,o){U(t)!==U(n)&&(Ae(t)&&Ae(n)?ia(e,t,n,r,o):Array.isArray(t)&&Array.isArray(n)?sa(e,t,n,r,o):r.push({op:"replace",path:e,value:n,previous:t}))}function ia(e,t,n,r,o){let i=[...new Set([...Object.keys(t),...Object.keys(n)])].sort(B);for(let l of i){let s=ie(e,l);Object.hasOwn(n,l)?Object.hasOwn(t,l)?et(s,t[l],n[l],r,o):r.push({op:"add",path:s,value:n[l]}):r.push({op:"remove",path:s,previous:t[l]})}}function sa(e,t,n,r,o){let i=W(t.map(U),n.map(U)),l=0;for(;l<t.length&&l<n.length&&i.old[l]===i.new[l];)l++;let s=0;for(;s<t.length-l&&s<n.length-l&&i.old[t.length-1-s]===i.new[n.length-1-s];)s++;let c=(t.length-l-s)*(n.length-l-s);if(c>o.remaining){r.push({op:"replace",path:e,value:n,previous:t});return}o.remaining-=c;let h=0,u=0,y=0;for(let E of[...Q(i.old,i.new),{oldStart:t.length,newStart:n.length,length:0}]){let _=t.slice(u,E.oldStart),C=n.slice(y,E.newStart),N=Math.min(_.length,C.length);for(let O=0;O<N;O++){let g=_[O],T=C[O];Ae(g)&&Ae(T)||Array.isArray(g)&&Array.isArray(T)?et(ie(e,h),g,T,r,o):(r.push({op:"remove",path:ie(e,h),previous:g}),r.push({op:"add",path:ie(e,h),value:T})),h++}for(let O of _.slice(N))r.push({op:"remove",path:ie(e,h),previous:O});for(let O of C.slice(N))r.push({op:"add",path:ie(e,h),value:O}),h++;h+=E.length,u=E.oldStart+E.length,y=E.newStart+E.length}}function tt(e,t){let n=[];return et("",e,t,n,{remaining:Kt}),n}function gn(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!="object"||n===null||Array.isArray(n))continue;let{start:r,end:o,page_number:i}=n;Number.isInteger(r)&&Number.isInteger(o)&&Number.isInteger(i)&&t.push({start:r,end:o,pageNumber:i})}return t.sort((n,r)=>n.start-r.start)}function nt(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1;e[i].start<=t?n=i+1:r=i}let o=e[n-1];return o!==void 0&&t<o.end?o.pageNumber:null}function Sn(e){let t=[],n=[],r={LF:0,CRLF:0,CR:0},o=0,i=0,l=0;for(let u=0;u<e.length;){let y=e.charCodeAt(u);if(y===10||y===13){t.push(e.slice(o,u)),n.push(l);let E=y===13&&e.charCodeAt(u+1)===10?2:1;r[E===2?"CRLF":y===13?"CR":"LF"]++,u+=E,i+=E,o=u,l=i;continue}u+=y>=55296&&y<=56319&&(e.charCodeAt(u+1)&64512)===56320?2:1,i++}o<e.length&&(t.push(e.slice(o)),n.push(l));let s=r.LF+r.CRLF+r.CR,c=["LF","CRLF","CR"].filter(u=>r[u]>0),h=s===0?"NONE":c.length===1?c[0]:"MIXED";return{lines:t,starts:n,lineEnding:h,finalNewline:s>0&&o===e.length}}var En=null;function Cn(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>767)return!1;return!0}function at(e){return Cn(e)?e.split(""):(En??=new Intl.Segmenter("und",{granularity:"grapheme"}),Array.from(En.segment(e),t=>t.segment))}function rt(e){return Cn(e)?e.length:at(e).length}function la(e,t,n){let r=e.length+t.length;if(n.exhausted||e.length>Ge||t.length>Ge||r===0)return null;let o=W(e,t),i=mn(o.old,o.new,o.alphabetSize);if(2*i/r<je||r-2*i>zt)return null;let l=r*(r-2*i);if(l>n.remaining)return n.exhausted=!0,null;n.remaining-=l;let s=Q(o.old,o.new),c=[],h=0,u=0;for(let g of[...s,{oldStart:e.length,newStart:t.length,length:0}])(g.oldStart>h||g.newStart>u)&&c.push({equal:!1,oldStart:h,oldEnd:g.oldStart,newStart:u,newEnd:g.newStart}),g.length>0&&c.push({equal:!0,oldStart:g.oldStart,oldEnd:g.oldStart+g.length,newStart:g.newStart,newEnd:g.newStart+g.length}),h=g.oldStart+g.length,u=g.newStart+g.length;let y=[];c.forEach((g,T)=>{let f=y[y.length-1],R=f!==void 0&&!f.equal,D=g.equal&&g.oldEnd-g.oldStart<=1&&R&&T+1<c.length;if(R&&(D||!g.equal)){f.oldEnd=g.oldEnd,f.newEnd=g.newEnd;return}y.push({...g})});let E=0,_=0,C=0,N=[],O=[];for(let g of y){let T=e.slice(g.oldStart,g.oldEnd).join(""),f=t.slice(g.newStart,g.newEnd).join("");if(g.equal){E+=g.oldEnd-g.oldStart,N.push({kind:"equal",text:T}),O.push({kind:"equal",text:f});continue}_+=g.oldEnd-g.oldStart,C+=g.newEnd-g.newStart,T!==""&&N.push({kind:"removed",text:T}),f!==""&&O.push({kind:"added",text:f})}return 2*E/r<je?null:{oldSegments:N,newSegments:O,removed:_,added:C}}var bn={old:[],new:[]};function pe(e){return e.filter(([,t,n])=>U(t)!==U(n)).map(([t,n,r])=>({field:t,before:n,after:r}))}var ot=(e,t)=>t===""?[]:[{kind:e,text:t}];function ca(e,t,n){let r=[],o=(s,c)=>({kind:"context",oldNumber:s+1,newNumber:c+1,page:nt(n.pages.new,n.newText.starts[c]),segments:ot("equal",n.newText.lines[c])}),i=t.oldStart,l=t.newStart;for(let s of e){for(;i<s.oldStart;i++,l++)r.push(o(i,l));for(let c=s.oldStart;c<s.oldEnd;c++){let h=n.oldText.lines[c];r.push({kind:"removed",oldNumber:c+1,newNumber:null,page:nt(n.pages.old,n.oldText.starts[c]),segments:n.removedSegments.get(c)??ot("removed",h)})}for(let c=s.newStart;c<s.newEnd;c++){let h=n.newText.lines[c];r.push({kind:"added",oldNumber:null,newNumber:c+1,page:nt(n.pages.new,n.newText.starts[c]),segments:n.addedSegments.get(c)??ot("added",h)})}i=s.oldEnd,l=s.newEnd}for(;i<t.oldEnd;i++,l++)r.push(o(i,l));return r}function it(e,t,n,r){let o=Sn(e??""),i=Sn(t??""),l=pe([["present",e!==null,t!==null],["lineEnding",o.lineEnding,i.lineEnding],["finalNewline",o.finalNewline,i.finalNewline]]),s=fn(W(o.lines,i.lines),{maxOccurrences:Mt,cellBound:Ut}),c=hn(o.lines.length,i.lines.length,s),h=new Map,u=new Map,y={remaining:Ht,exhausted:!1},E=0,_=0,C=0,N=0,O=0,g=0;for(let b of c){C+=b.oldEnd-b.oldStart,N+=b.newEnd-b.newStart;let L=Math.min(b.oldEnd-b.oldStart,b.newEnd-b.newStart);for(let F=0;b.oldStart+F<b.oldEnd||b.newStart+F<b.newEnd;F++){let z=b.oldStart+F,K=b.newStart+F;if(F>=L){let le=z<b.oldEnd?rt(o.lines[z]):0,ee=K<b.newEnd?rt(i.lines[K]):0;O+=le,g+=ee,E+=le,_+=ee;continue}let J=at(o.lines[z]),$=at(i.lines[K]);O+=J.length,g+=$.length;let q=la(J,$,y);if(q!==null){h.set(z,q.oldSegments),u.set(K,q.newSegments),E+=q.removed,_+=q.added;continue}E+=J.length,_+=$.length}}let T=0;for(let b of s)for(let L=b.oldStart;L<b.oldStart+b.length;L++)T+=rt(o.lines[L]);let f=T+O,R=T+g,D={linesAdded:N,linesRemoved:C,linesUnchanged:o.lines.length-C,charsAdded:_,charsRemoved:E,similarity:f+R===0?null:2*(f-E)/(f+R)},x=r==="whole"?Math.max(o.lines.length,i.lines.length):r,A=[];for(let b of c){let L=A[A.length-1],F=L?.[L.length-1];L!==void 0&&F!==void 0&&b.oldStart-F.oldEnd<=2*x?L.push(b):A.push([b])}let P={oldText:o,newText:i,pages:n,removedSegments:h,addedSegments:u},v=A.map((b,L)=>{let F=b[0],z=b[b.length-1],K=Math.max(0,F.oldStart-x),J=F.newStart-(F.oldStart-K),$=Math.min(o.lines.length,z.oldEnd+x),q=z.newEnd+($-z.oldEnd),le=ca(b,{oldStart:K,oldEnd:$,newStart:J},P);return{hunk:L,oldStart:$>K?K+1:K,oldLines:$-K,newStart:q>J?J+1:J,newLines:q-J,firstPage:le[0].page,linesAdded:b.reduce((ee,ce)=>ee+ce.newEnd-ce.newStart,0),linesRemoved:b.reduce((ee,ce)=>ee+ce.oldEnd-ce.oldStart,0),lines:le}});return{attributes:l,stats:D,hunks:v}}function _e(e,t){let n=it(e.body,t.body,{old:gn(e.pageOffsets),new:gn(t.pageOffsets)},Ke),r=pe([["mime",e.mime,t.mime],["source",e.source,t.source],["isTruncated",e.isTruncated,t.isTruncated],["pageOffsets",e.pageOffsets,t.pageOffsets]]);return{...n,attributes:[...r,...n.attributes]}}function De(e,t){return it(e,t,bn,Ke)}function da(e,t){return it(e,t,bn,"whole")}function Te(e){return{attributes:[...e.attributes],stats:e.stats,hunks:e.hunks.map(({lines:t,...n})=>n)}}function ua(e,t,n,r){let o=Number.isInteger(t)&&t>=0?e.hunks[t]:void 0;if(o===void 0)throw new RangeError(`The diff has no hunk ${t}.`);if(!Number.isInteger(n)||n<0||n>=o.lines.length)throw new RangeError(`Hunk ${t} has no line at offset ${n}.`);if(!Wt.safeParse(r).success)throw new RangeError(`A line page holds 1 to the page maximum lines, not ${r}.`);let i=Math.min(n+r,o.lines.length);return{lines:o.lines.slice(n,i),next:i<o.lines.length?i:null}}function Ne(e,t,n){let r=[...e].sort(t);for(let o=1;o<r.length;o++)if(t(r[o-1],r[o])===0)throw new RangeError(`A facet set holds the key ${JSON.stringify(n(r[o]))} more than once.`);return r}function Rn(e,t,n,r){let o=0,i=0;for(;o<e.length||i<t.length;){let l=e[o],s=t[i],c=l===void 0?1:s===void 0?-1:n(l,s);r(c<=0?l:null,c>=0?s:null),o+=c<=0?1:0,i+=c>=0?1:0}}function st(e,t){let n=[],r=[],o=0;return Rn(Ne(e??[],B,String),Ne(t??[],B,String),B,(i,l)=>{i!==null&&l!==null?o++:i!==null?r.push(i):n.push(l)}),{added:n,removed:r,unchangedCount:o}}function In(e,t,n){let r=[],o=[],i=[],l=0;return Rn(Ne(e,n.compare,n.keyOf),Ne(t,n.compare,n.keyOf),n.compare,(s,c)=>{if(s===null){r.push({key:n.keyOf(c),value:{...c}});return}if(c===null){o.push({key:n.keyOf(s),value:{...s}});return}let h=new Map(n.fieldsOf(c)),u=pe(n.fieldsOf(s).map(([y,E])=>[y,E,h.get(y)]));u.length===0?l++:i.push({key:n.keyOf(s),fields:u})}),{added:r,removed:o,modified:i,unchangedCount:l}}var pa={compare:(e,t)=>B(e.labelKey,t.labelKey),keyOf:e=>e.labelKey,fieldsOf:e=>[["assignedBy",e.assignedBy],["confidenceScore",e.confidenceScore]]},ma={compare:Be,keyOf:e=>`${e.assetType}:${e.assetIndex}`,fieldsOf:e=>[["mimeType",e.mimeType],["fileSize",e.fileSize],["textSha256",e.textSha256]]},lt=(e,t)=>In(e,t,pa),ct=(e,t)=>In(e,t,ma);function me(e,t,n){return pe(n.map(r=>[r,e[r],t[r]]))}var _n=["confidentialityLevel","departmentId","folderPath","createdBy"],Dn=["fileName","filePath","fileId","revision","revisionId","fileSize","mimeType","fileHash","mtime"],Z=(e,t)=>({facet:e,addedCount:null,removedCount:null,modifiedCount:null,movedCount:null,unchangedCount:null,charsAdded:null,charsRemoved:null,...t}),xn=(e,t)=>Z(e,{addedCount:t.stats.linesAdded,removedCount:t.stats.linesRemoved,unchangedCount:t.stats.linesUnchanged,charsAdded:t.stats.charsAdded,charsRemoved:t.stats.charsRemoved});function fa(e){switch(e.facet){case"classification":return Z("classification",{modifiedCount:me(e.from,e.to,_n).length});case"metadata":return Z("metadata",{modifiedCount:me(e.from,e.to,Dn).length});case"labels":case"assets":{let t=e.facet==="labels"?lt(e.from,e.to):ct(e.from,e.to);return Z(e.facet,{addedCount:t.added.length,removedCount:t.removed.length,modifiedCount:t.modified.length,unchangedCount:t.unchangedCount})}case"tags":{let t=st(e.from,e.to);return Z("tags",{addedCount:t.added.length,removedCount:t.removed.length,unchangedCount:t.unchangedCount})}case"structured_data":{let t=tt(e.from,e.to),n=r=>t.filter(o=>o.op===r).length;return Z("structured_data",{addedCount:n("add"),removedCount:n("remove"),modifiedCount:n("replace")})}case"text":return xn("text",_e(e.from,e.to));case"summary":return xn("summary",De(e.from,e.to));case"chunks":{let{stats:t}=Ze(e.from,e.to);return Z("chunks",{addedCount:t.added,removedCount:t.removed,modifiedCount:t.modified,movedCount:t.moved,unchangedCount:t.unchanged})}}}function ha(e){if(e.length===0)throw new RangeError("A change has at least one changed facet.");let t=new Set;for(let n of e){if(t.has(n.facet))throw new RangeError(`The ${n.facet} facet is given twice.`);if(t.add(n.facet),U(n.from)===U(n.to))throw new RangeError(`The ${n.facet} facet has equal values on both sides, so it did not change.`)}return[...e].sort((n,r)=>Ve(n.facet,r.facet)).map(fa)}var ya=(e,t)=>({index:e.index,charStart:e.charStart,charEnd:e.charEnd,page:e.page,sheet:e.sheet,slide:e.slide,startSec:e.startSec,endSec:e.endSec,breadcrumbs:e.breadcrumbs,tokenCount:e.tokenCount,fidelity:t});function An(e,t){let n=e.facets.chunks?.children.length??0;if(e.chunkFidelities.length!==n)throw new RangeError(`The ${t} state has ${n} child chunks but ${e.chunkFidelities.length} fidelity checks.`)}function ga(e,t,n){let r=t.facets,o=n.facets;if(U(r[e])===U(o[e]))return{facet:e,change:"UNCHANGED"};switch(e){case"classification":return{facet:e,change:"CHANGED",fields:me(r.classification,o.classification,_n)};case"metadata":return{facet:e,change:"CHANGED",fields:me(r.metadata,o.metadata,Dn)};case"labels":case"assets":{let i=e==="labels"?lt(r.labels,o.labels):ct(r.assets,o.assets);return{facet:e,change:"CHANGED",added:[...i.added],removed:[...i.removed],modified:[...i.modified],unchangedCount:i.unchangedCount}}case"tags":{let i=st(r.tags,o.tags);return{facet:e,change:"CHANGED",added:[...i.added],removed:[...i.removed],unchangedCount:i.unchangedCount}}case"structured_data":return{facet:e,change:"CHANGED",operations:tt(r.structured_data,o.structured_data)};case"text":return{facet:e,change:"CHANGED",...Te(_e(r.text,o.text))};case"summary":return{facet:e,change:"CHANGED",...Te(De(r.summary,o.summary))};case"chunks":{let i=Ze(r.chunks,o.chunks),l=r.chunks?.children??[],s=o.chunks?.children??[],c=(h,u,y)=>y===null?null:ya(h[y],u[y]);return{facet:e,change:"CHANGED",stats:i.stats,entries:i.entries.map((h,u)=>({entry:u,kind:h.kind,pairing:h.pairing,old:c(l,t.chunkFidelities,h.oldPosition),new:c(s,n.chunkFidelities,h.newPosition)})),textUnchangedChunkingChanged:r.text.body===o.text.body}}}}function Sa(e,t){return An(e,"from"),An(t,"to"),{diffEngineVersion:vt,facets:ae.map(n=>ga(n,e,t))}}var Tn=[{key:"enable_summary_generation",featureFlagKey:null,label:"\u8981\u7D04\u751F\u6210"},{key:"enable_structured_extraction",featureFlagKey:null,label:"\u69CB\u9020\u5316\u62BD\u51FA"},{key:"enable_asset_extraction",featureFlagKey:"ENABLE_ASSET_EXTRACTION",label:"\u30A2\u30BB\u30C3\u30C8\u62BD\u51FA"},{key:"enable_vector_indexing",featureFlagKey:"ENABLE_VECTOR_INDEXING",label:"\u30D9\u30AF\u30C8\u30EB\u7D22\u5F15"},{key:"enable_graph_indexing",featureFlagKey:"ENABLE_GRAPH_INDEXING",label:"\u30B0\u30E9\u30D5\u6295\u5F71"}],Ea=new Set(Tn.map(e=>e.key));function xs(e){return Ea.has(e)}function As(e){let t=Tn.find(n=>n.key===e);if(t===void 0)throw new Error(`ENRICHMENT_STAGES does not carry ${e}; the canonical list and the key type have drifted apart.`);return t}var _s={pageSize:{min:1,max:200,default:50},topologyLabels:{min:1,max:24,default:24}};var se=-1,Y=0;function Ca(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}function Ts(){let e=typeof globalThis<"u"&&globalThis.crypto?globalThis.crypto:typeof crypto<"u"?crypto:void 0;if(!e||typeof e.getRandomValues!="function")throw new Error("Cryptographically secure random number generator (crypto.getRandomValues) is required but not available.");let t=new Uint8Array(16);e.getRandomValues(t);let n=Date.now();if(n===se){if(Y++,Y>4095){for(;Date.now()<=se;);n=Date.now(),se=n,Y=(t[6]<<4|t[7]&15)&1023}}else n>se?(se=n,Y=(t[6]<<4|t[7]&15)&1023):(n=se,Y++,Y>4095&&(Y=0));t[0]=Math.floor(n/1099511627776)&255,t[1]=Math.floor(n/4294967296)&255,t[2]=n>>>24&255,t[3]=n>>>16&255,t[4]=n>>>8&255,t[5]=n&255,t[6]=112|Y>>>8&15,t[7]=Y&255,t[8]=128|t[8]&63;let r=Array.from(t,i=>i.toString(16).padStart(2,"0")).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}function Ns(e){if(!Ca(e))throw new Error(`Invalid RFC 9562 UUIDv7 string: "${e}"`);let t=e.slice(0,8)+e.slice(9,13),n=parseInt(t,16);if(Number.isNaN(n))throw new Error(`Invalid hex timestamp in UUIDv7: "${t}"`);return new Date(n)}export{Mn as AmountEntrySchema,wr as AssetFacetItemSchema,fe as BaseEnrichmentClient,ze as BodySourceSchema,Ma as BoundingBoxSchema,Rr as CHUNK_BODY_FIDELITIES,Sr as CHUNK_CHANGE_KINDS,fr as CHUNK_MANIFEST_VERSION,Cr as CHUNK_PAIRINGS,kn as CIRCUIT_BREAKER_SERVICES,Hn as CanonicalDomainKeySchema,en as ChangeFeedCursorSchema,Ln as ChapterSegmentSchema,Ir as ChunkBodyFidelitySchema,Er as ChunkChangeKindSchema,Zr as ChunkChangeSchema,Pr as ChunkManifestChildSchema,Lr as ChunkManifestParentSchema,Mr as ChunkManifestSchema,br as ChunkPairingSchema,Lt as ChunkRefSchema,eo as ChunkStatsSchema,Ha as ChunkingStrategySchema,za as CircuitBreakerStatusSchema,Nr as ClassificationFacetSchema,ne as ConfidentialityLevelSchema,Ke as DIFF_CONTEXT_LINES,vt as DIFF_ENGINE_VERSION,_r as DIFF_LINE_FACETS,Gt as DIFF_LINE_PAGE_MAX,Ut as DIFF_REGION_CELL_BOUND,Fn as DISPATCH_DEGRADATION_REASONS,Dr as DOCUMENT_CAPTURE_OUTCOMES,jt as DOCUMENT_CHANGE_FEED_PAGE_MAX,fi as DOCUMENT_CHANGE_FEED_PAGE_SIZE,ae as DOCUMENT_FACETS,Rt as DOCUMENT_KINDS,$a as DOCUMENT_KIND_LABELS,hr as DOCUMENT_STATE_CAUSES,hi as DOCUMENT_STATE_LOCK_TIMEOUT_MS,yr as DOCUMENT_STATE_RUN_OUTCOMES,Si as DiffLineFacetSchema,Wt as DiffLinePageLimitSchema,bi as DiffLinePageSchema,Wr as DiffLineSchema,$r as DiffSegmentSchema,Ni as DocumentCaptureAnswerSchema,Tr as DocumentCaptureOutcomeSchema,uo as DocumentChangeFeedEntrySchema,Ri as DocumentChangeFeedLimitSchema,Ti as DocumentChangeFeedPageSchema,po as DocumentChangeFeedRowSchema,Ii as DocumentComparisonSchema,Bt as DocumentFacetSchema,Ei as DocumentFacetValuesSchema,Di as DocumentHistorySchema,_t as DocumentKindSchema,lo as DocumentRunEntrySchema,Vt as DocumentStateCauseSchema,so as DocumentStateEntrySchema,gr as DocumentStateRunOutcomeSchema,io as DocumentStateSummarySchema,Ua as DocumentStructuredDataSchema,Tn as ENRICHMENT_STAGES,yt as EnrichmentClient,te as EnrichmentClientError,mt as EnrichmentSyncStatusSchema,Hr as FACET_APPLICABLE_COUNTS,zr as FACET_COUNT_FIELDS,Da as FILTERABLE_CONFIDENTIALITY_LEVELS,Gr as FacetChangeCountsSchema,no as FacetDiffSchema,Je as FieldChangeSchema,va as FileUriSchema,_s as GRAPH_INDEX_LIMITS,Gn as GraphSearchHitSchema,Mt as HISTOGRAM_MAX_OCCURRENCES,Yr as HunkIndexEntrySchema,Ht as INLINE_REFINE_CELL_BUDGET,zt as INLINE_REFINE_MAX_EDIT_DISTANCE,Ge as INLINE_REFINE_MAX_GRAPHEMES,je as INLINE_REFINE_MIN_SIMILARITY,xo as INTEGRITY_CLASS_POLICY,un as INTEGRITY_COMMAND_CODES,Re as INTEGRITY_FINDINGS_PAGE_LIMIT_MAX,Uo as IntegrityActiveRunSchema,Ki as IntegrityAuditOverviewSchema,Qo as IntegrityCancelFailureCodeSchema,Vi as IntegrityCellResyncRequestSchema,Ji as IntegrityCellResyncResultSchema,We as IntegrityCommandFailureCodeSchema,Yi as IntegrityCommandFailureSchema,qi as IntegrityCommandReplySchema,sn as IntegrityCommandSchema,Ro as IntegrityDispositionSchema,cn as IntegrityFindingItemClassSchema,ji as IntegrityFindingPageSchema,Jo as IntegrityFindingSchema,Bi as IntegrityFindingsQuerySchema,ln as IntegrityItemClassSchema,To as IntegrityPhaseSchema,Gi as IntegrityPlacementObservedSchema,Lo as IntegrityQuantitySchema,Io as IntegrityRepairActionSchema,No as IntegrityRepairOutcomeSchema,ko as IntegrityRepairSkipReasonSchema,Xe as IntegrityRunHeaderSchema,Ao as IntegrityRunModeSchema,_o as IntegrityRunStatusSchema,Co as IntegrityScopeRoleSchema,Wo as IntegrityStartFailureCodeSchema,qe as IntegrityStoreSchema,bo as IntegrityUnitSchema,Do as IntegrityVerdictSchema,Br as JsonPatchOperationSchema,j as JsonValueSchema,jr as KeyedItemChangeSchema,Pt as KeyedItemSchema,It as LEDGER_STEP_KEYS,Ar as LINE_ENDINGS,On as LOCAL_DEGRADATION_REASONS,Or as LabelFacetItemSchema,Jn as LedgerStepKeySchema,gi as LineEndingSchema,Bn as MIME_KIND_RULES,he as MODE_TIERS,kr as MetadataFacetSchema,Nn as ModelProviderSchema,nr as NOTHING_TO_READ_TOKENS,rr as NothingToReadTokenSchema,xt as PIPELINE_FAILURE_STATUSES,Vn as PIPELINE_FLOWS,Xa as PIPELINE_PHASES,At as PIPELINE_STEPS,we as PIPELINE_STEP_KEYS,Dt as PipelineFailureStatusSchema,Ot as PipelineRunRecordSchema,Ue as PipelineRunStatusSchema,wt as PipelineRunSummarySchema,Me as PipelineStepKeySchema,ii as PipelineStepMetricSchema,pr as PipelineStepRecordSchema,Zn as PipelineStepStatusSchema,er as PipelineTriggerSchema,de as QUARANTINED_CONFIDENTIALITY_LEVEL,wn as REMOTE_DEGRADATION_REASONS,xr as RESTRICTED_MARK_SUBJECTS,Xn as RUN_TERMINAL_STEP_ERROR_CODES,Fe as RUN_TERMINAL_STEP_KEY,Yn as RUN_TERMINAL_STEP_OUTCOMES,Yt as ReadableConfidentialityLevelSchema,_i as RecentPipelineRunEntrySchema,oo as RestrictedChangeMarkSchema,Ai as RestrictedFailureMarkSchema,xi as RestrictedIngestMarkSchema,yi as RestrictedMarkSubjectSchema,Qt as RestrictedRunMarkSchema,ro as RestrictedStateMarkSchema,qn as RunTerminalStepDetailSchema,Qn as RunTerminalStepErrorCodeSchema,$n as RunTerminalStepOutcomeSchema,wa as SEARCH_DEGRADATION_REASONS,pt as SEARCH_MODES,_a as SEARCH_PARAM_LIMITS,Wn as STALE_RUN_ERROR_CODE,Kt as STRUCTURED_DATA_ARRAY_CELL_BOUND,be as SYSTEM_PARAMETER_RANGES,Kn as SearchHitSchema,zn as SearchMetadataSchema,Un as SearchModeSchema,ft as SearchRequestSchema,ht as SearchResponseSchema,tr as StageProvenanceSchema,Pn as TenantIdSchema,Ci as TextDiffIndexSchema,Fr as TextFacetSchema,Vr as TextStatsSchema,vn as TranscriptSegmentSchema,Li as assertBoundedSystemParameter,Pi as assertSystemParameterInRange,U as canonicalJson,qa as classifyDocumentKind,ta as codePointSlicer,Be as compareAssetKeys,B as compareCodeUnits,Ve as compareFacets,ei as comparePhases,Sa as compareStates,yo as decodeChangeFeedCursor,da as diffChunkBodies,ua as diffLinePage,ho as encodeChangeFeedCursor,As as enrichmentStage,Wa as flowFor,Qa as flowStepGates,ai as formatSkipReason,Ts as generateUuidV7,$i as integrityCommandFailureCodeOf,xs as isEnrichmentStageKey,X as isStrictlyEarlier,Ca as isValidUuidV7,Oa as modeFusesRankings,Ta as modeNeedsRemoteTiers,Na as modeScoreIsSimilarity,ka as narrowModeToAllowedTiers,Za as orderedSteps,Tt as parseSkipReason,Ce as readableEntrySchema,na as stripWhitespace,ha as summarizeTransition,De as summaryFacetDiff,Te as textDiffIndex,_e as textFacetDiff,Ns as uuidv7ToDate};
|