@spotpatch/vite 1.13.0 → 1.15.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.
@@ -0,0 +1,63 @@
1
+ var ye=Object.freeze({maximumTargets:20,maximumQuestionCharacters:4e3,maximumAnswerCharacters:4e4,maximumAnswerBlocks:40,maximumSources:64,maximumReadFiles:32,maximumReadBytesPerFile:65536,maximumReadBytesTotal:524288,maximumToolCalls:48,maximumModelTurns:12,jobTimeoutMs:3e5,resultTtlMs:9e5,maximumActiveJobsPerSession:1,maximumRetainedResultsPerSession:1,maximumRetainedEvents:256,maximumEventSubscribers:4,eventHeartbeatMs:15e3,maximumRequestBodyBytes:262144,maximumSearchQueryCharacters:256,maximumSearchResults:64,maximumSearchPreviewCharacters:500,capabilityTimeoutMs:3e4,maximumIdCharacters:128,maximumProfileIdCharacters:64,maximumLabelCharacters:256,maximumRelativePathCharacters:1024,maximumLanguageCharacters:64,maximumPhaseMessageCharacters:1024,maximumExecutors:32,maximumModels:800,contentHashHexCharacters:64}),ke=Object.freeze(["configured-key","managed-codex"]),Ke=Object.freeze(["ready","degraded","unavailable"]),Ee=Object.freeze(["queued","authorizing","running","cancelling","answered","cancelled","failed"]),Me=Object.freeze(["insufficient-evidence","partial-context","source-truncated","source-stale"]),wt=Object.freeze(["insufficient-evidence","partial-context"]),Ue=Object.freeze(["started","succeeded","failed"]),Be=Object.freeze(["one","few","many"]),je=Object.freeze(["exact","probable","approximate"]);var _="/__spotpatch/v1",Ce="X-SpotPatch-Token",fe=Object.freeze({bootstrap:`${_}/bootstrap`,sourceContext:`${_}/source-context`,openEditor:`${_}/open-editor`,dataFlowComponentReport:`${_}/data-flow/component-report`,dataFlowPageReport:`${_}/data-flow/page-report`,agentCapability:`${_}/agent/capability`,agentWorkspaceHealth:`${_}/agent/workspace-health`,agentJobs:`${_}/agent/jobs`,askCapability:`${_}/ask/capability`,askJobs:`${_}/ask/jobs`,externalHandoffCapability:`${_}/external-handoff/capability`,externalHandoffPublish:`${_}/external-handoff/publish`,externalHandoffStatus:`${_}/external-handoff/status`,externalHandoffResolveDelivery:`${_}/external-handoff/resolve-delivery`,externalAgentControlStatus:`${_}/external-agent/control/status`,externalAgentControlConnect:`${_}/external-agent/control/connect`,externalAgentControlDisconnect:`${_}/external-agent/control/disconnect`,externalAgentControlCancel:`${_}/external-agent/control/cancel`,externalAgentEvents:`${_}/external-agent/events`,externalAgentResult:`${_}/external-agent/result`});function ge(e,t,n={}){let s=`${fe.askJobs}/${encodeURIComponent(e)}/${t}`;if(t!=="events"&&n.afterSequence!==void 0)throw new RangeError("afterSequence is only valid for the events endpoint.");if(n.afterSequence===void 0)return s;if(!Number.isSafeInteger(n.afterSequence)||n.afterSequence<0)throw new RangeError("afterSequence must be a non-negative safe integer.");return`${s}?afterSequence=${String(n.afterSequence)}`}var Tt={ASK_DISABLED:"ASK_DISABLED",ASK_SELECTION_REQUIRED:"ASK_SELECTION_REQUIRED",ASK_SELECTION_STALE:"ASK_SELECTION_STALE",ASK_QUESTION_INVALID:"ASK_QUESTION_INVALID",ASK_EXECUTOR_UNAVAILABLE:"ASK_EXECUTOR_UNAVAILABLE",ASK_TIMEOUT:"ASK_TIMEOUT",ASK_CONSENT_REQUIRED:"ASK_CONSENT_REQUIRED",ASK_BUSY:"ASK_BUSY",ASK_IDEMPOTENCY_CONFLICT:"ASK_IDEMPOTENCY_CONFLICT",ASK_SOURCE_SCOPE_DENIED:"ASK_SOURCE_SCOPE_DENIED",ASK_LIMIT_EXCEEDED:"ASK_LIMIT_EXCEEDED",ASK_ANSWER_INVALID:"ASK_ANSWER_INVALID",ASK_WRITE_ATTEMPTED:"ASK_WRITE_ATTEMPTED",ASK_CANCELLED:"ASK_CANCELLED",ASK_RESULT_EXPIRED:"ASK_RESULT_EXPIRED",ASK_PROTOCOL_INCOMPATIBLE:"ASK_PROTOCOL_INCOMPATIBLE"},_t=Object.freeze({INVALID_REQUEST:"INVALID_REQUEST",INVALID_TOKEN:"INVALID_TOKEN",ORIGIN_NOT_ALLOWED:"ORIGIN_NOT_ALLOWED",...Tt,INTERNAL_ERROR:"INTERNAL_ERROR"}),It=Object.values(_t);function Se(e){return typeof e=="string"&&It.includes(e)}function D(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function T(e,t,n=[]){let s=Object.keys(e),g=new Set([...t,...n]);return t.every(r=>r in e)&&s.every(r=>g.has(r))}function H(e,t){return typeof e=="string"&&t.includes(e)}function L(e){return typeof e=="string"&&e.trim().length>0}function J(e){return typeof e=="string"&&e.length>0&&e.length<=128&&/^[A-Za-z0-9_-]+$/u.test(e)}function ae(e){return typeof e=="string"&&Number.isFinite(Date.parse(e))}function Je(e){return Number.isSafeInteger(e)&&Number(e)>0}function qe(e){return Se(e)&&e.startsWith("ASK_")}function we(e){return Array.isArray(e)&&e.every(t=>J(t))}function Te(e){return new Set(e).size===e.length}function vt(e){return!D(e)||!T(e,["executorId","kind","label","requestedModelLabel","effectiveModelLabel","state","providerDataConsentRequired","readOnlyProven"],["errorCode","models"])||!J(e.executorId)||!H(e.kind,ke)||!L(e.label)||!L(e.requestedModelLabel)||!L(e.effectiveModelLabel)||e.models!==void 0&&(!Array.isArray(e.models)||e.models.length===0||e.models.length>ye.maximumModels||!e.models.every(t=>L(t)&&t.length<=ye.maximumLabelCharacters)||!Te(e.models))||!H(e.state,Ke)||typeof e.providerDataConsentRequired!="boolean"||typeof e.readOnlyProven!="boolean"||e.errorCode!==void 0&&!qe(e.errorCode)?!1:e.state==="ready"?e.readOnlyProven&&e.errorCode===void 0:e.errorCode!==void 0}function st(e){if(!D(e)||!T(e,["schemaVersion","enabled","executors","safety","checkedAt"])||e.schemaVersion!==1||typeof e.enabled!="boolean"||!Array.isArray(e.executors)||!e.executors.every(vt)||!D(e.safety)||!T(e.safety,["selectionRequired","singleTurn","writesAllowed","historyStored"])||e.safety.selectionRequired!==!0||e.safety.singleTurn!==!0||e.safety.writesAllowed!==!1||e.safety.historyStored!==!1||!ae(e.checkedAt))return!1;let t=e.executors.map(n=>n.executorId);return(e.enabled||e.executors.length===0)&&Te(t)}function at(e){return D(e)&&T(e,["executorId","kind","label","modelLabel"])&&J(e.executorId)&&H(e.kind,ke)&&L(e.label)&&L(e.modelLabel)}function he(e){if(!D(e)||!T(e,["schemaVersion","jobId","selectionId","status","executor","createdAt","updatedAt","canCancel"],["phaseMessage","errorCode"])||e.schemaVersion!==1||!J(e.jobId)||!J(e.selectionId)||!H(e.status,Ee)||!at(e.executor)||!ae(e.createdAt)||!ae(e.updatedAt)||Date.parse(e.updatedAt)<Date.parse(e.createdAt)||typeof e.canCancel!="boolean"||e.phaseMessage!==void 0&&!L(e.phaseMessage)||e.errorCode!==void 0&&!qe(e.errorCode))return!1;let t=["queued","authorizing","running"].includes(e.status);return e.canCancel!==t?!1:e.status==="cancelled"?e.errorCode==="ASK_CANCELLED":e.status==="failed"?e.errorCode!==void 0&&e.errorCode!=="ASK_CANCELLED":e.errorCode===void 0}function nt(e){return!(!D(e)||!T(e,["sourceId","label","relativePath","fileId","startLine","endLine","confidence","targetIds","contentHash"],["sourceVersion"])||!J(e.sourceId)||!L(e.label)||!L(e.relativePath)||e.relativePath.startsWith("/")||e.relativePath.includes("\\")||e.relativePath.split("/").some(t=>t===""||t==="."||t==="..")||!J(e.fileId)||!Je(e.startLine)||!Je(e.endLine)||e.endLine<e.startLine||!H(e.confidence,je)||!we(e.targetIds)||e.targetIds.length===0||!Te(e.targetIds)||e.sourceVersion!==void 0&&!L(e.sourceVersion)||typeof e.contentHash!="string"||!/^[a-f0-9]{64}$/u.test(e.contentHash))}function ot(e){return D(e)&&T(e,["code"])&&H(e.code,Me)}function rt(e){return!D(e)||typeof e.kind!="string"?!1:e.kind==="paragraph"?T(e,["kind","text","sourceIds"])&&L(e.text)&&we(e.sourceIds):e.kind==="code"?T(e,["kind","code","sourceIds"],["language"])&&typeof e.code=="string"&&e.code.length>0&&we(e.sourceIds)&&(e.language===void 0||L(e.language)):e.kind!=="list"||!T(e,["kind","items"])?!1:Array.isArray(e.items)&&e.items.length>0&&e.items.every(t=>D(t)&&T(t,["text","sourceIds"])&&L(t.text)&&we(t.sourceIds))}function Rt(e){if(!D(e)||!T(e,["schemaVersion","jobId","selectionId","contextHash","executor","blocks","sources","warnings","createdAt","expiresAt"])||e.schemaVersion!==1||!J(e.jobId)||!J(e.selectionId)||typeof e.contextHash!="string"||!/^[a-f0-9]{64}$/u.test(e.contextHash)||!at(e.executor)||!Array.isArray(e.blocks)||e.blocks.length===0||!e.blocks.every(rt)||!Array.isArray(e.sources)||!e.sources.every(nt)||!Array.isArray(e.warnings)||!e.warnings.every(ot)||!ae(e.createdAt)||!ae(e.expiresAt)||Date.parse(e.expiresAt)<=Date.parse(e.createdAt))return!1;let t=e.sources.filter(nt),n=e.blocks.filter(rt),s=e.warnings.filter(ot),g=t.map(d=>d.sourceId);if(!Te(g))return!1;let r=new Set(g),a=n.flatMap(d=>d.kind==="list"?d.items.flatMap(k=>k.sourceIds):d.sourceIds);return a.every(d=>r.has(d))&&g.every(d=>a.includes(d))&&(a.length>0||s.some(d=>d.code==="insufficient-evidence"))}function it(e){return!D(e)||!T(e,["snapshot"],["result"])||!he(e.snapshot)||e.result!==void 0&&!Rt(e.result)?!1:e.snapshot.status==="answered"===(e.result!==void 0)&&(e.result===void 0||e.result.jobId===e.snapshot.jobId&&e.result.selectionId===e.snapshot.selectionId&&e.result.executor.executorId===e.snapshot.executor.executorId)}function ct(e){return!D(e)||!T(e,["schemaVersion","sequence","jobId","status","timestamp","type"],["snapshot","message","activity","state","errorCode"])||e.schemaVersion!==1||!Je(e.sequence)||!J(e.jobId)||!H(e.status,Ee)||!ae(e.timestamp)?!1:e.type==="snapshot"?T(e,["schemaVersion","sequence","jobId","status","timestamp","type","snapshot"])&&he(e.snapshot)&&e.snapshot.jobId===e.jobId&&e.snapshot.status===e.status:e.type==="phase"?T(e,["schemaVersion","sequence","jobId","status","timestamp","type","message"])&&L(e.message)&&!["answered","cancelled","failed"].includes(e.status):e.type==="answer-ready"?T(e,["schemaVersion","sequence","jobId","status","timestamp","type"])&&e.status==="answered":e.type==="error"?T(e,["schemaVersion","sequence","jobId","status","timestamp","type","errorCode"])&&qe(e.errorCode)&&(e.status==="cancelled"&&e.errorCode==="ASK_CANCELLED"||e.status==="failed"&&e.errorCode!=="ASK_CANCELLED"):e.type!=="read-activity"||!T(e,["schemaVersion","sequence","jobId","status","timestamp","type","activity","state"])||e.status!=="running"||!D(e.activity)||!H(e.state,Ue)?!1:e.activity.kind==="source"?T(e.activity,["kind","sourceId","relativePath"])&&J(e.activity.sourceId)&&L(e.activity.relativePath):e.activity.kind==="file-count"&&T(e.activity,["kind","bucket"])&&H(e.activity.bucket,Be)}var Lt=2e6,dt=1e5,Ot=4e6,S=class extends Error{constructor(n){super("SpotPatch Contextual Ask request failed.");this.code=n;this.name="ContextualAskApiError"}code};function $e(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function pt(e){if(!(!$e(e)&&!Array.isArray(e)||Object.isFrozen(e))){for(let t of Object.values(e))pt(t);Object.freeze(e)}}function be(e){return pt(e),e}function ut(e){try{return JSON.parse(e)}catch{throw new S}}async function Nt(e,t){let n=Number(e.headers.get("content-length"));if(Number.isFinite(n)&&n>t)throw await e.body?.cancel(),new S;if(e.body===null)throw new S;let s=e.body.getReader(),g=new TextDecoder("utf-8",{fatal:!0}),r=0,a="";try{for(;;){let d=await s.read();if(d.done)return a+g.decode();if(r+=d.value.byteLength,r>t)throw await s.cancel(),new S;a+=g.decode(d.value,{stream:!0})}}catch(d){throw d instanceof S||d instanceof DOMException&&d.name==="AbortError"?d:new S}finally{s.releaseLock()}}async function lt(e){let t=ut(await Nt(e,Lt));if(!$e(t))throw new S;if(!e.ok){let n=t.ok===!1&&$e(t.error)&&Se(t.error.code)?t.error.code:void 0;throw new S(n)}if(t.ok!==!0||!("data"in t))throw new S;return t.data}function _e(e){return e instanceof S?e.code:void 0}function ft(e){let t=new Set;function n(){for(let r of t)r.abort();t.clear()}async function s(r,a,d){let k=new AbortController;t.add(k);try{let v=await e.fetch(r,{method:a,headers:{...d===void 0?{}:{"Content-Type":"application/json"},[Ce]:e.sessionToken},...d===void 0?{}:{body:JSON.stringify(d)},signal:k.signal});return await lt(v)}finally{t.delete(k)}}async function g(r,a,d){let k=new AbortController;t.add(k);try{let v=await e.fetch(ge(r,"events",{afterSequence:a}),{method:"GET",headers:{[Ce]:e.sessionToken},signal:k.signal});if(!v.ok){await lt(v);return}if(v.body===null)throw new S;let E=v.body.getReader(),b=new TextDecoder("utf-8",{fatal:!0}),P="",O=0,l=a,m=u=>{if(u.trim().length===0)return;if(new TextEncoder().encode(u).byteLength>dt)throw new S;let A=ut(u);if(!ct(A)||A.jobId!==r||A.sequence<=l)throw new S;l=A.sequence,d(be(A))};try{for(;;){let u=await E.read();if(u.done){m(P+b.decode());return}if(O+=u.value.byteLength,O>Ot)throw await E.cancel(),new S;P+=b.decode(u.value,{stream:!0});let A=P.split(`
2
+ `);if(P=A.pop()??"",new TextEncoder().encode(P).byteLength>dt)throw await E.cancel(),new S;for(let N of A)m(N)}}catch(u){throw u instanceof S||u instanceof DOMException&&u.name==="AbortError"?u:new S}finally{E.releaseLock()}}finally{t.delete(k)}}return Object.freeze({async capability(){let r=await s(fe.askCapability,"GET");if(!st(r))throw new S;return be(r)},async cancelJob(r){let a=await s(ge(r,"cancel"),"POST",{});if(!he(a)||a.jobId!==r)throw new S;return be(a)},cancelPending:n,async createJob(r){let a=await s(fe.askJobs,"POST",r);if(!he(a)||a.selectionId!==r.envelope.selection.selectionId||a.executor.executorId!==r.executorId)throw new S;return be(a)},dispose:n,events:g,async result(r){let a=await s(ge(r,"result"),"GET");if(!it(a)||a.snapshot.jobId!==r)throw new S;return be(a)}})}function Ve(e){return e instanceof DOMException&&e.name==="AbortError"}function gt(e){let t=!1,n=0,s=!1,g,r,a="",d=!1,k=!1,v=new Map,E=e.api??ft({fetch:e.fetch,sessionToken:e.sessionToken});function b(i){return t&&n===i}function P(i){let x=e.getSelection();if(i.length===0||i.length>4e3||x===void 0)return;let w=new Date().toISOString();return{schemaVersion:1,taskId:e.createId(),selection:{schemaVersion:1,selectionId:e.createId(),locale:x.locale,targets:x.targets.map(y=>({targetId:y.id,page:y.page,source:y.source,react:{...y.react,componentStack:[...y.react.componentStack]},element:y.element,styles:{...y.styles,classNames:[...y.styles.classNames],matchedRules:y.styles.matchedRules.map(F=>({...F})),computed:{...y.styles.computed},warnings:[...y.styles.warnings]},...y.code===void 0?{}:{code:y.code},warnings:[]})),createdAt:w},task:{kind:"ask",question:i},createdAt:w}}async function O(){if(d)return;let i=n;e.panel.renderCapability(void 0);try{let x=await E.capability();if(!b(i))return;d=!0,e.panel.renderCapability(x);let w=e.panel.readExecutorId();e.panel.setConsent(w!==void 0&&v.get(w)===!0)}catch(x){if(!b(i)||Ve(x))return;e.panel.renderError(_e(x))}}function l(i,x){b(x)&&(e.panel.renderEvent(i),i.type==="snapshot"&&(g=i.snapshot))}async function m(){if(s)return;let i=e.panel.readQuestion(),x=e.panel.readExecutorId(),w=P(i);if(i.length===0||x===void 0||!e.panel.readConsent()||w===void 0)return;let y=++n,F=e.panel.readModel();a=i,s=!0,e.onBusyChange(!0),r=void 0,g=void 0,e.panel.setBusy(!0);try{let B=await E.createJob({schemaVersion:1,requestId:e.createId(),envelope:w,executorId:x,...F===void 0?{}:{model:F},providerDataConsent:!0});if(!b(y)||(g=B,e.panel.renderJob(B),await E.events(B.jobId,0,de=>{l(de,y)}),!b(y)))return;let $=await E.result(B.jobId);if(!b(y))return;if(g=$.snapshot,s=!1,e.onBusyChange(!1),$.result===void 0){e.panel.renderJob($.snapshot),$.snapshot.status==="failed"&&e.panel.renderError($.snapshot.errorCode);return}r=$.result,e.panel.renderAnswer($.result,!1)}catch(B){if(!b(y)||Ve(B))return;s=!1,e.onBusyChange(!1),e.panel.renderError(_e(B))}finally{b(y)&&(s=!1,e.panel.setBusy(!1))}}async function u(){if(!s||g?.canCancel!==!0)return;let i=n;try{let x=await E.cancelJob(g.jobId);if(!b(i))return;g=x,s=!1,e.onBusyChange(!1),e.panel.renderJob(x),e.panel.setBusy(!1)}catch(x){if(!b(i)||Ve(x))return;s=!1,e.onBusyChange(!1),e.panel.renderError(_e(x))}}function A(){n+=1;let i=g;s=!1,e.onBusyChange(!1),g=void 0,E.cancelPending(),i?.canCancel===!0&&E.cancelJob(i.jobId).catch(()=>{}),e.panel.setBusy(!1)}function N(){s&&A(),n+=1,g=void 0,r=void 0,a="",e.panel.clear(),e.panel.focusQuestion()}function q(){let i=e.panel.answerPlainText();i.length===0||e.clipboard===void 0||e.clipboard.writeText(i).then(()=>{e.panel.notify("copied")}).catch(()=>{e.panel.notify("copy-failed")})}function te(){if(r===void 0||s)return;let i=e.panel.answerPlainText().trim().slice(0,4e3);if(i.length===0)return;let x=Object.freeze({kind:"contextual-ask",askJobId:r.jobId,question:a,answerDigest:i,sourceIds:r.sources.map(w=>w.sourceId)});e.onConvert(x),e.panel.setOrigin(x),e.panel.setMode("change"),e.panel.notify("converted")}function ne(i){let x=e.panel.selectedSourceId(i.target);if(x===void 0)return;let w=e.panel.sourceById(x);w!==void 0&&e.onOpenSource(w).catch(()=>{e.panel.notify("source-open-failed")})}function ie(i){i.target!==e.panel.questionInput||i.key!=="Enter"||k||i.isComposing||!i.metaKey&&!i.ctrlKey||(i.preventDefault(),m())}function I(){let i=e.panel.readExecutorId();e.panel.setConsent(i!==void 0&&v.get(i)===!0)}function W(){k=!0}function oe(){k=!1}function re(){let i=e.panel.readExecutorId();i!==void 0&&v.set(i,e.panel.readConsent())}function U(){m()}function R(){u()}function se(){t||(t=!0,e.panel.submitButton.addEventListener("click",U),e.panel.cancelButton.addEventListener("click",R),e.panel.newQuestionButton.addEventListener("click",N),e.panel.copyButton.addEventListener("click",q),e.panel.convertButton.addEventListener("click",te),e.panel.executorSelect.addEventListener("change",I),e.panel.consentCheckbox.addEventListener("change",re),e.panel.questionInput.addEventListener("keydown",ie),e.panel.questionInput.addEventListener("compositionstart",W),e.panel.questionInput.addEventListener("compositionend",oe),e.panel.root.addEventListener("click",ne),O())}function ce(){t&&(A(),t=!1,e.panel.submitButton.removeEventListener("click",U),e.panel.cancelButton.removeEventListener("click",R),e.panel.newQuestionButton.removeEventListener("click",N),e.panel.copyButton.removeEventListener("click",q),e.panel.convertButton.removeEventListener("click",te),e.panel.executorSelect.removeEventListener("change",I),e.panel.consentCheckbox.removeEventListener("change",re),e.panel.questionInput.removeEventListener("keydown",ie),e.panel.questionInput.removeEventListener("compositionstart",W),e.panel.questionInput.removeEventListener("compositionend",oe),e.panel.root.removeEventListener("click",ne),E.dispose())}return Object.freeze({beginSelection(){n+=1,s=!1,e.onBusyChange(!1),g=void 0,r=void 0,a="",e.panel.clear(),O()},cancelPending:A,dispose:ce,isBusy:()=>s,mount:se,selectionChanged(){r!==void 0&&e.panel.renderAnswer(r,!0)}})}var Pt=Symbol.for("spotpatch.contextual-ask.v1");function ht(e){globalThis[Pt]=e}var bt="data-spotpatch-ui",Yt=Object.freeze({highlight:2147483646,controls:2147483647}),Zt=Object.freeze({compactInset:8,compactViewportWidth:520,desktopInset:24,dragActivationDistance:6,edgeSnapDistance:20,workbenchMaxHeight:620,workbenchMaxWidth:460});function c(e,t){let n=e.createElement(t);return n.setAttribute(bt,""),n}function K(e,t,n=""){let s=c(e,"button");return s.type="button",s.className=n,s.textContent=t,s}function We(e,t){let n=c(e,"div");n.className="spotpatch-ask-executor-picker";let s=K(e,"","spotpatch-ask-executor");s.id=`spotpatch-ask-picker-${Math.random().toString(36).slice(2)}`,s.setAttribute("role","combobox"),s.setAttribute("aria-haspopup","listbox"),s.setAttribute("aria-expanded","false");let g=c(e,"span");s.append(g);let r=c(e,"div");r.id=`${s.id}-menu`,r.className="spotpatch-ask-executor-menu",r.setAttribute("role","listbox"),r.hidden=!0,s.setAttribute("aria-controls",r.id);let a=c(e,"select");a.className="spotpatch-ask-executor-native",a.tabIndex=-1,a.setAttribute("aria-hidden","true"),n.append(s,r,a);function d(l=!1){r.hidden||(r.hidden=!0,s.setAttribute("aria-expanded","false"),s.removeAttribute("aria-activedescendant"),l&&s.focus({preventScroll:!0}),t())}function k(l){let m=[...r.children],u=m[l];if(u===void 0)return;for(let q of m)q.dataset.active=String(q===u);s.setAttribute("aria-activedescendant",u.id);let A=u.getBoundingClientRect(),N=r.getBoundingClientRect();A.top<N.top?r.scrollTop-=N.top-A.top:A.bottom>N.bottom&&(r.scrollTop+=A.bottom-N.bottom)}function v(){s.disabled||!r.hidden||(r.hidden=!1,s.setAttribute("aria-expanded","true"),k(Math.max(0,a.selectedIndex)),t())}function E(){g.textContent=a.selectedOptions[0]?.textContent??"",s.title=g.textContent,s.dataset.empty=String(a.value.length===0);for(let l of[...r.children])l.setAttribute("aria-selected",String(l.dataset.value===a.value))}function b(l){s.disabled||(a.value=l,E(),d(!0),a.dispatchEvent(new Event("change",{bubbles:!0})))}function P(){d(),r.replaceChildren();for(let[l,m]of[...a.options].entries()){let u=c(e,"div");u.id=`${r.id}-${String(l)}`,u.className="spotpatch-ask-executor-option",u.setAttribute("role","option"),u.dataset.value=m.value,u.textContent=m.textContent,u.title=m.textContent,u.addEventListener("pointerdown",A=>{A.preventDefault()}),u.addEventListener("click",()=>{b(m.value)}),r.append(u)}E()}s.addEventListener("click",()=>{r.hidden?v():d()}),s.addEventListener("keydown",l=>{if(l.key==="Escape"&&!r.hidden){l.preventDefault(),l.stopPropagation(),d();return}if(l.key==="Tab"){d();return}if(["Enter"," "].includes(l.key)&&!r.hidden){l.preventDefault();let A=[...r.children].find(N=>N.id===s.getAttribute("aria-activedescendant"));A?.dataset.value!==void 0&&b(A.dataset.value);return}if(!["ArrowDown","ArrowUp","Home","End"].includes(l.key))return;if(l.preventDefault(),r.hidden){v();return}let m=[...r.children],u=m.findIndex(A=>A.id===s.getAttribute("aria-activedescendant"));k(l.key==="Home"?0:l.key==="End"?m.length-1:(u+(l.key==="ArrowDown"?1:-1)+m.length)%m.length)}),n.addEventListener("focusout",l=>{(!(l.relatedTarget instanceof Node)||!n.contains(l.relatedTarget))&&d()});let O=l=>{l.composedPath().includes(n)||d()};return e.addEventListener("pointerdown",O),a.addEventListener("change",E),{root:n,trigger:s,select:a,rebuild:P,close:d,setDisabled(l){a.disabled=l,s.disabled=l||a.options.length<2,s.dataset.expandable=String(!s.disabled),s.disabled&&d()},dispose(){e.removeEventListener("pointerdown",O)}}}var Dt=Object.freeze({mode:Object.freeze({ask:"Ask",change:"Change",label:"Task mode"}),title:"Ask about this selection",subtitle:"One question, one sourced answer. SpotPatch will not write code.",questionLabel:"Question",questionPlaceholder:"What does this component do?",suggestionsLabel:"Suggested questions",suggestions:Object.freeze(["What does this component do?","Where does its data come from?","Why is it implemented this way?"]),executorLabel:"Read-only executor",modelLabel:"Model",loadingExecutors:"Checking available executors…",noExecutor:"No verified read-only executor is available.",unavailable:"unavailable",consent:"Allow the selected source snapshot to be sent to this provider for this answer.",dataSummary:(e,t)=>`${String(e)} selected element${e===1?"":"s"} · ${String(t)} source-backed`,safety:"Single turn · read-only · no history",submit:"Ask",cancel:"Cancel",newQuestion:"Start over",copy:"Copy answer",convert:"Turn into change request",answerTitle:"Answer",sourcesTitle:"Sources",stale:"The selection changed after this answer. Ask again before relying on it.",convertedTitle:"From contextual answer",convertedBody:"The answer and source references remain local and have not started a change.",status:Object.freeze({queued:"Queued",authorizing:"Verifying read-only access",running:"Analyzing selected source",cancelling:"Cancelling",answered:"Answer ready",cancelled:"Cancelled",failed:"Could not answer"}),sourceLabel:(e,t,n)=>`${e}:${String(t)}${n===t?"":`–${String(n)}`}`,readSource:e=>`Reading ${e}`,readFiles:e=>`Reading ${e} files`,copied:"Answer copied.",copyFailed:"The answer could not be copied.",sourceOpenFailed:"The source could not be opened.",converted:"Switched to Change with the answer attached as local context.",error:e=>e===void 0?"SpotPatch could not complete this question.":{INVALID_TOKEN:"The local SpotPatch session expired. Refresh the page.",ORIGIN_NOT_ALLOWED:"The local request failed its same-origin security check. Refresh or restart the dev server.",ASK_DISABLED:"Contextual Ask is disabled.",ASK_SELECTION_REQUIRED:"Select at least one element first.",ASK_SELECTION_STALE:"The selected source changed. Refresh the selection and ask again.",ASK_QUESTION_INVALID:"Enter one valid question.",ASK_EXECUTOR_UNAVAILABLE:"The selected read-only executor is unavailable.",ASK_TIMEOUT:"The read-only executor took too long to answer. Try the question again.",ASK_CONSENT_REQUIRED:"Confirm provider data access for this answer.",ASK_BUSY:"Another workspace task is active. Try again when it finishes.",ASK_CANCELLED:"The question was cancelled.",ASK_RESULT_EXPIRED:"This answer has expired. Ask again.",ASK_WRITE_ATTEMPTED:"The executor attempted a write and was stopped.",ASK_ANSWER_INVALID:"The executor returned an invalid sourced answer.",ASK_PROTOCOL_INCOMPATIBLE:"The executor protocol is incompatible.",ASK_LIMIT_EXCEEDED:"The selected context is too large.",ASK_SOURCE_SCOPE_DENIED:"A requested source was outside the granted snapshot."}[e]??"SpotPatch could not complete this question.",warning:e=>e==="insufficient-evidence"?"The selected source did not contain enough evidence for a complete answer.":"Some source references were omitted because they could not be verified."}),Kt=Object.freeze({mode:Object.freeze({ask:"问答",change:"修改",label:"任务模式"}),title:"询问所选元素",subtitle:"一次提问,一次带源码引用的回答;SpotPatch 不会写入代码。",questionLabel:"问题",questionPlaceholder:"这个组件是做什么的?",suggestionsLabel:"推荐问题",suggestions:Object.freeze(["这个组件是做什么的?","它的数据从哪里来?","为什么要这样实现?"]),executorLabel:"只读执行器",modelLabel:"模型",loadingExecutors:"正在检查可用执行器…",noExecutor:"目前没有通过只读验证的执行器。",unavailable:"不可用",consent:"允许本次回答将所选源码快照发送给该提供商。",dataSummary:(e,t)=>`${String(e)} 个已选元素 · ${String(t)} 个具备源码上下文`,safety:"单轮 · 只读 · 不保存历史",submit:"提问",cancel:"取消",newQuestion:"重新开始",copy:"复制回答",convert:"转成修改请求",answerTitle:"回答",sourcesTitle:"源码引用",stale:"回答后选择已发生变化。请重新提问后再采信此回答。",convertedTitle:"来自上下文问答",convertedBody:"回答与源码引用仅作为本地上下文保留,尚未发起任何修改。",status:Object.freeze({queued:"已排队",authorizing:"正在验证只读权限",running:"正在分析所选源码",cancelling:"正在取消",answered:"回答已就绪",cancelled:"已取消",failed:"无法回答"}),sourceLabel:(e,t,n)=>`${e}:${String(t)}${n===t?"":`–${String(n)}`}`,readSource:e=>`正在读取 ${e}`,readFiles:e=>`正在读取 ${e} 个文件`,copied:"回答已复制。",copyFailed:"无法复制回答。",sourceOpenFailed:"无法打开源码。",converted:"已切换到修改模式,并把回答作为本地上下文附带。",error:e=>e===void 0?"SpotPatch 未能完成本次提问。":{INVALID_TOKEN:"本地 SpotPatch 会话已失效,请刷新页面。",ORIGIN_NOT_ALLOWED:"本地请求未通过同源安全校验,请刷新页面或重启开发服务。",ASK_DISABLED:"上下文问答未启用。",ASK_SELECTION_REQUIRED:"请先选择至少一个元素。",ASK_SELECTION_STALE:"所选源码已经变化,请刷新选择后重新提问。",ASK_QUESTION_INVALID:"请输入一个有效的问题。",ASK_EXECUTOR_UNAVAILABLE:"所选只读执行器当前不可用。",ASK_TIMEOUT:"只读执行器未能在限定时间内返回回答,请重新提问。",ASK_CONSENT_REQUIRED:"请确认本次回答的提供商数据访问。",ASK_BUSY:"工作区正在执行其他任务,请稍后重试。",ASK_CANCELLED:"本次提问已取消。",ASK_RESULT_EXPIRED:"回答已过期,请重新提问。",ASK_WRITE_ATTEMPTED:"执行器尝试写入,已被阻止。",ASK_ANSWER_INVALID:"执行器返回的带引用回答无效。",ASK_PROTOCOL_INCOMPATIBLE:"执行器协议不兼容。",ASK_LIMIT_EXCEEDED:"所选上下文过大。",ASK_SOURCE_SCOPE_DENIED:"请求的源码超出了授权快照范围。"}[e]??"SpotPatch 未能完成本次提问。",warning:e=>e==="insufficient-evidence"?"所选源码不足以支持完整回答。":"部分源码引用因无法验证而被省略。"});function ze(e){return e==="zh-CN"?Kt:Dt}function Mt(e){let t=e.createElement("style");return t.textContent=`
3
+ .spotpatch-ask-mode { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 14px; padding: 4px; border: 1px solid var(--spotpatch-border-subtle); border-radius: 10px; background: #0a0a0e; }
4
+ .spotpatch-ask-mode button { min-height: 34px; border: 0; border-radius: 7px; color: var(--spotpatch-text-secondary); background: transparent; cursor: pointer; font-size: 12px; font-weight: 700; }
5
+ .spotpatch-ask-mode button[aria-selected="true"] { color: #f7f7ff; background: linear-gradient(135deg, rgb(139 123 255 / 25%), rgb(82 168 255 / 14%)); box-shadow: inset 0 0 0 1px rgb(139 123 255 / 24%); }
6
+ .spotpatch-ask-panel { display: grid; gap: 14px; }
7
+ .spotpatch-ask-field { display: grid; gap: 7px; min-width: 0; }
8
+ .spotpatch-ask-field[hidden] { display: none; }
9
+ .spotpatch-ask-field > label, .spotpatch-ask-label { color: #c9cad2; font-size: 11px; font-weight: 680; }
10
+ .spotpatch-ask-question { box-sizing: border-box; width: 100%; min-height: 92px; resize: vertical; border: 1px solid var(--spotpatch-border); border-radius: 10px; padding: 11px 12px; outline: none; color: var(--spotpatch-text); background: var(--spotpatch-bg-input); line-height: 1.55; }
11
+ .spotpatch-ask-question:focus { border-color: rgb(139 123 255 / 68%); box-shadow: 0 0 0 3px rgb(139 123 255 / 12%); }
12
+ .spotpatch-ask-suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
13
+ .spotpatch-ask-suggestions button { border: 1px solid var(--spotpatch-border-subtle); border-radius: 999px; padding: 5px 9px; color: var(--spotpatch-text-secondary); background: rgb(255 255 255 / 2%); cursor: pointer; font-size: 10.5px; }
14
+ .spotpatch-ask-suggestions button:hover { border-color: rgb(139 123 255 / 42%); color: #fff; }
15
+ .spotpatch-ask-executor-picker { display: grid; gap: 5px; min-width: 0; }
16
+ .spotpatch-ask-executor { box-sizing: border-box; display: flex; width: 100%; min-height: 38px; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--spotpatch-border); border-radius: 9px; padding: 0 11px; overflow: hidden; color: var(--spotpatch-text); background: var(--spotpatch-bg-input); cursor: pointer; font: inherit; outline: none; text-align: left; }
17
+ .spotpatch-ask-executor > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
18
+ .spotpatch-ask-executor[data-expandable="true"]::after { width: 7px; height: 7px; flex: 0 0 auto; border-right: 1.5px solid #8f96a3; border-bottom: 1.5px solid #8f96a3; content: ""; transform: translateY(-2px) rotate(45deg); }
19
+ .spotpatch-ask-executor[aria-expanded="true"]::after { transform: translateY(2px) rotate(225deg); }
20
+ .spotpatch-ask-executor:focus-visible { border-color: rgb(139 123 255 / 68%); box-shadow: 0 0 0 3px rgb(139 123 255 / 12%); }
21
+ .spotpatch-ask-executor:disabled { color: var(--spotpatch-text); background: rgb(255 255 255 / 3%); cursor: default; opacity: 1; }
22
+ .spotpatch-ask-executor[data-empty="true"]:disabled { color: var(--spotpatch-text-muted); }
23
+ .spotpatch-ask-executor-menu { display: grid; gap: 3px; border: 1px solid var(--spotpatch-border); border-radius: 9px; padding: 4px; background: var(--spotpatch-bg-input); max-height: 224px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; box-shadow: 0 10px 28px rgb(0 0 0 / 28%); }
24
+ .spotpatch-ask-executor-menu[hidden] { display: none; }
25
+ .spotpatch-ask-executor-option { box-sizing: border-box; min-height: 34px; border: 0; border-radius: 6px; padding: 7px 9px; color: var(--spotpatch-text-secondary); background: transparent; cursor: pointer; font: inherit; text-align: left; overflow-wrap: anywhere; }
26
+ .spotpatch-ask-executor-option[data-active="true"], .spotpatch-ask-executor-option:hover { color: #fff; background: rgb(139 123 255 / 13%); outline: none; }
27
+ .spotpatch-ask-executor-option[aria-selected="true"] { color: #f4f1ff; background: rgb(139 123 255 / 20%); }
28
+ .spotpatch-ask-executor-native { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; border: 0; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
29
+ .spotpatch-ask-executor-status { margin: 0; border-left: 2px solid var(--spotpatch-warning); padding-left: 8px; color: #d8b66c; font-size: 10.5px; line-height: 1.45; }
30
+ .spotpatch-ask-safety { display: grid; gap: 8px; border: 1px solid rgb(82 168 255 / 16%); border-radius: 10px; padding: 10px 11px; background: rgb(82 168 255 / 4%); }
31
+ .spotpatch-ask-data { display: flex; justify-content: space-between; gap: 10px; color: #aab3c2; font-size: 10.5px; }
32
+ .spotpatch-ask-data strong { color: #9fe3c4; font-weight: 650; white-space: nowrap; }
33
+ .spotpatch-ask-consent { display: grid; grid-template-columns: 16px 1fr; gap: 8px; align-items: start; color: var(--spotpatch-text-secondary); cursor: pointer; font-size: 10.5px; line-height: 1.45; }
34
+ .spotpatch-ask-consent input { margin: 2px 0 0; accent-color: var(--spotpatch-accent); }
35
+ .spotpatch-ask-actions, .spotpatch-ask-answer-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
36
+ .spotpatch-ask-actions button, .spotpatch-ask-answer-actions button { min-height: 34px; border: 1px solid var(--spotpatch-border); border-radius: 8px; padding: 0 12px; color: #d6d6de; background: var(--spotpatch-bg-raised); cursor: pointer; font-size: 11px; font-weight: 680; }
37
+ .spotpatch-ask-actions .spotpatch-primary, .spotpatch-ask-answer-actions .spotpatch-primary { border-color: transparent; color: var(--spotpatch-text-on-accent); background: linear-gradient(135deg, #a99cff, #65b7ff); }
38
+ .spotpatch-ask-actions button:disabled, .spotpatch-ask-answer-actions button:disabled { opacity: .45; cursor: not-allowed; }
39
+ .spotpatch-ask-status { display: grid; gap: 7px; border-left: 2px solid var(--spotpatch-accent); padding: 2px 0 2px 10px; color: #c8c9d2; font-size: 11px; }
40
+ .spotpatch-ask-activity { display: grid; gap: 4px; color: var(--spotpatch-text-muted); font: 500 10px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }
41
+ .spotpatch-ask-error, .spotpatch-ask-stale, .spotpatch-ask-warning { border-radius: 8px; padding: 9px 10px; font-size: 10.5px; }
42
+ .spotpatch-ask-error { color: #fecaca; background: rgb(251 113 133 / 9%); }
43
+ .spotpatch-ask-stale, .spotpatch-ask-warning { color: #f9d68a; background: rgb(245 158 11 / 8%); }
44
+ .spotpatch-ask-answer { display: grid; gap: 12px; border: 1px solid var(--spotpatch-border-subtle); border-radius: 11px; padding: 12px; background: var(--spotpatch-bg); box-shadow: 0 12px 30px rgb(0 0 0 / 18%); }
45
+ .spotpatch-ask-answer h3, .spotpatch-ask-sources h4 { margin: 0; color: var(--spotpatch-text); font-size: 13px; }
46
+ .spotpatch-ask-blocks { display: grid; gap: 10px; color: #d9dae2; font-size: 12px; line-height: 1.65; overflow-wrap: anywhere; }
47
+ .spotpatch-ask-blocks p, .spotpatch-ask-blocks ul { margin: 0; }
48
+ .spotpatch-ask-blocks ul { padding-left: 18px; }
49
+ .spotpatch-ask-blocks pre { max-width: 100%; overflow: auto; margin: 0; border: 1px solid var(--spotpatch-border-subtle); border-radius: 9px; padding: 10px; color: #dbeafe; background: #08090d; font: 500 10.5px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
50
+ .spotpatch-ask-citations, .spotpatch-ask-source-list { display: flex; flex-wrap: wrap; gap: 5px; }
51
+ .spotpatch-ask-source { max-width: 100%; overflow: hidden; border: 1px solid rgb(82 168 255 / 22%); border-radius: 999px; padding: 4px 8px; color: #b8dcff; background: rgb(82 168 255 / 7%); cursor: pointer; font: 550 9.5px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
52
+ .spotpatch-ask-sources { display: grid; gap: 7px; }
53
+ .spotpatch-ask-origin { margin-bottom: 12px; border: 1px solid rgb(139 123 255 / 22%); border-radius: 10px; padding: 10px 11px; color: var(--spotpatch-text-secondary); background: rgb(139 123 255 / 6%); font-size: 10.5px; }
54
+ .spotpatch-ask-origin strong { display: block; margin-bottom: 2px; color: #d9d4ff; font-size: 11px; }
55
+ @media (max-width: 420px) { .spotpatch-ask-data { display: grid; } .spotpatch-ask-actions, .spotpatch-ask-answer-actions { justify-content: stretch; } .spotpatch-ask-actions button, .spotpatch-ask-answer-actions button { flex: 1 1 auto; } }
56
+ @media (prefers-reduced-motion: reduce) { .spotpatch-ask-panel *, .spotpatch-ask-mode * { scroll-behavior: auto !important; transition: none !important; } }
57
+ `,t}function He(e,t,n,s,g){if(n.length===0)return;let r=c(e,"div");r.className="spotpatch-ask-citations";for(let a of n){let d=s.get(a);if(d===void 0)continue;let k=K(e,g.sourceLabel(d.relativePath,d.startLine,d.endLine),"spotpatch-ask-source");k.dataset.askSourceId=d.sourceId,k.title=d.label,r.append(k)}t.append(r)}function xt(e){let{document:t}=e,n=ze(e.locale()),s="change",g,r,a,d,k="",v="",E=Object.freeze({contextReady:!1,targetCount:0,sourceCount:0}),b=!1,P=c(t,"section"),O=c(t,"div");O.className="spotpatch-ask-mode",O.setAttribute("role","tablist");let l=K(t,""),m=K(t,"");l.setAttribute("role","tab"),m.setAttribute("role","tab"),O.append(l,m);let u=c(t,"aside");u.className="spotpatch-ask-origin",u.hidden=!0;let A=c(t,"strong"),N=c(t,"span");u.append(A,N);let q=c(t,"div");q.className="spotpatch-ask-panel";let te=c(t,"div");te.className="spotpatch-ask-field";let ne=c(t,"label"),ie=`spotpatch-ask-question-${Math.random().toString(36).slice(2)}`;ne.htmlFor=ie;let I=c(t,"textarea");I.id=ie,I.className="spotpatch-ask-question",I.maxLength=4e3;let W=c(t,"div");W.className="spotpatch-ask-suggestions",W.setAttribute("aria-label",""),te.append(ne,I,W);let oe=c(t,"div");oe.className="spotpatch-ask-field";let re=c(t,"label"),U=We(t,e.onViewChange),R=U.select;re.htmlFor=U.trigger.id;let se=c(t,"div");se.className="spotpatch-ask-field";let ce=c(t,"label"),i=We(t,e.onViewChange);ce.htmlFor=i.trigger.id,se.append(ce,i.root);let x,w=c(t,"p");w.className="spotpatch-ask-executor-status",w.setAttribute("role","status"),w.hidden=!0,oe.append(re,U.root,w);let y=c(t,"div");y.className="spotpatch-ask-safety";let F=c(t,"div");F.className="spotpatch-ask-data";let B=c(t,"span"),$=c(t,"strong");F.append(B,$);let de=c(t,"label");de.className="spotpatch-ask-consent";let X=c(t,"input");X.type="checkbox";let Fe=c(t,"span");de.append(X,Fe),y.append(F,de);let j=c(t,"div");j.className="spotpatch-ask-status",j.setAttribute("role","status"),j.setAttribute("aria-live","polite"),j.hidden=!0;let Ie=c(t,"strong"),Y=c(t,"div");Y.className="spotpatch-ask-activity",j.append(Ie,Y);let z=c(t,"div");z.className="spotpatch-ask-error",z.setAttribute("role","alert"),z.hidden=!0;let ve=c(t,"div");ve.className="spotpatch-ask-actions";let xe=K(t,""),le=K(t,""),pe=K(t,"","spotpatch-primary");le.hidden=!0,ve.append(xe,le,pe);let Z=c(t,"article");Z.className="spotpatch-ask-answer",Z.hidden=!0;let ee=c(t,"div");ee.className="spotpatch-ask-stale",ee.hidden=!0;let Xe=c(t,"h3"),Re=c(t,"div"),Q=c(t,"div");Q.className="spotpatch-ask-blocks";let Ae=c(t,"section");Ae.className="spotpatch-ask-sources";let Qe=c(t,"h4"),me=c(t,"div");me.className="spotpatch-ask-source-list",Ae.append(Qe,me);let Le=c(t,"div");Le.className="spotpatch-ask-answer-actions";let Oe=K(t,""),Ne=K(t,"","spotpatch-primary");Le.append(Oe,Ne),Z.append(ee,Xe,Re,Q,Ae,Le),q.append(te,oe,se,y,j,z,ve,Z),P.append(O,u,q);function Pe(){let o=g?.executors.find(C=>C.executorId===R.value);return o?.state==="ready"&&o.readOnlyProven}function mt(){return g?.executors.some(o=>o.state==="ready"&&o.readOnlyProven)===!0}function Ge(){let o=g?.executors.find(h=>h.executorId===R.value),C=x===o?.executorId?i.select.value:void 0;x=o?.executorId;let f=o?.models;se.hidden=f===void 0,i.select.replaceChildren();for(let h of f??[]){let p=t.createElement("option");p.value=h,p.textContent=h,i.select.append(p)}i.select.value=f?.find(h=>h===C)??f?.find(h=>h===o?.requestedModelLabel)??f?.[0]??"",i.rebuild()}function M(){pe.disabled=b||I.value.trim().length===0||!Pe()||!X.checked||E.targetCount===0,E.contextReady||(pe.disabled=!0),I.disabled=b;let o=b||g===void 0||!mt();U.setDisabled(o),i.setDisabled(b||!Pe()),X.disabled=b||!Pe(),xe.hidden=b||r===void 0,le.hidden=!b}function ue(){let o=s==="ask";l.setAttribute("aria-selected",String(o)),m.setAttribute("aria-selected",String(!o)),q.hidden=!o,e.changeRoot.hidden=o,e.changeActions.hidden=o,u.hidden=o||u.dataset.active!=="true",(d!==s||k!==n.title||v!==n.subtitle)&&(d=s,k=n.title,v=n.subtitle,e.onModeChange(s,n.title,n.subtitle)),e.onViewChange()}function yt(){W.replaceChildren();for(let o of n.suggestions){let C=K(t,o);C.type="button",C.addEventListener("click",()=>{I.value=o,M(),I.focus()}),W.append(C)}}function Ye(){n=ze(e.locale()),O.setAttribute("aria-label",n.mode.label),l.textContent=n.mode.ask,m.textContent=n.mode.change,ne.textContent=n.questionLabel,I.placeholder=n.questionPlaceholder,W.setAttribute("aria-label",n.suggestionsLabel),re.textContent=n.executorLabel,ce.textContent=n.modelLabel,U.root.querySelector("[role=listbox]")?.setAttribute("aria-label",n.executorLabel),i.root.querySelector("[role=listbox]")?.setAttribute("aria-label",n.modelLabel),Fe.textContent=n.consent,$.textContent=n.safety,pe.textContent=n.submit,le.textContent=n.cancel,xe.textContent=n.newQuestion,Oe.textContent=n.copy,Ne.textContent=n.convert,Xe.textContent=n.answerTitle,Qe.textContent=n.sourcesTitle,ee.textContent=n.stale,A.textContent=n.convertedTitle,N.textContent=n.convertedBody,B.textContent=n.dataSummary(E.targetCount,E.sourceCount),yt(),Ze(g),r!==void 0&&tt(r,!ee.hidden)}function Ze(o){g=o;let C=R.value;if(R.replaceChildren(),U.close(),w.hidden=!0,w.textContent="",o===void 0){let f=t.createElement("option");f.textContent=n.loadingExecutors,f.value="",R.append(f)}else if(!o.enabled||o.executors.length===0){let f=t.createElement("option");f.textContent=n.noExecutor,f.value="",R.append(f)}else{let f=o.executors.filter(p=>p.state==="ready"&&p.readOnlyProven),h=o.executors.filter(p=>p.state!=="ready"||!p.readOnlyProven);for(let p of f){let V=t.createElement("option");V.value=p.executorId,V.textContent=p.models===void 0?`${p.label} · ${p.effectiveModelLabel}`:p.label,R.append(V)}if(f.length===0){let p=t.createElement("option");p.textContent=n.noExecutor,p.value="",R.append(p)}R.value=f.some(p=>p.executorId===C)?C:f[0]?.executorId??"",h.length>0&&(w.textContent=h.map(p=>`${p.label}: ${n.error(p.errorCode)}`).join(" "),w.hidden=!1)}U.rebuild(),Ge(),M()}function et(o){a=o,j.hidden=!1,z.hidden=!0,Ie.textContent=n.status[o.status],["answered","cancelled","failed"].includes(o.status)?(b=!1,e.onExecutionChange()):e.onExecutionChange({scene:"running",tone:"running",headline:n.status[o.status],expandedHeadline:n.status[o.status],action:n.safety,expandedAction:n.safety,meta:`${o.executor.label} · ${o.executor.modelLabel}`,recentActivities:Object.freeze([]),startedAt:o.createdAt}),M()}function kt(o){if(o.type==="snapshot"){et(o.snapshot);return}if(o.type==="phase"&&(Ie.textContent=n.status[o.status]),o.type==="read-activity"&&o.state==="started"){let C=c(t,"span");for(C.textContent=o.activity.kind==="source"?n.readSource(o.activity.relativePath):n.readFiles(o.activity.bucket),Y.append(C);Y.childElementCount>5;)Y.firstElementChild?.remove();if(a!==void 0){let f=C.textContent;e.onExecutionChange({scene:"running",tone:"running",headline:n.status.running,expandedHeadline:n.status.running,action:f,expandedAction:f,meta:`${a.executor.label} · ${a.executor.modelLabel}`,activity:{key:`ask:${String(o.sequence)}`,kind:"read",label:f,state:"active"},recentActivities:Object.freeze([]),startedAt:a.createdAt})}}}function tt(o,C){r=o,a=void 0,e.onExecutionChange();let f=new Map(o.sources.map(h=>[h.sourceId,h]));Q.replaceChildren(),Re.replaceChildren(),me.replaceChildren(),ee.hidden=!C;for(let h of o.warnings){let p=c(t,"div");p.className="spotpatch-ask-warning",p.textContent=n.warning(h.code),Re.append(p)}for(let h of o.blocks)if(h.kind==="paragraph"){let p=c(t,"p");p.textContent=h.text,Q.append(p),He(t,Q,h.sourceIds,f,n)}else if(h.kind==="code"){let p=c(t,"pre"),V=c(t,"code");h.language!==void 0&&(V.dataset.language=h.language),V.textContent=h.code,p.append(V),Q.append(p),He(t,Q,h.sourceIds,f,n)}else{let p=c(t,"ul");for(let V of h.items){let De=c(t,"li");De.textContent=V.text,He(t,De,V.sourceIds,f,n),p.append(De)}Q.append(p)}for(let h of o.sources){let p=K(t,n.sourceLabel(h.relativePath,h.startLine,h.endLine),"spotpatch-ask-source");p.dataset.askSourceId=h.sourceId,p.title=h.label,me.append(p)}Ae.hidden=o.sources.length===0,Z.hidden=!1,j.hidden=!0,b=!1,M(),e.onViewChange()}function Et(){if(r===void 0)return"";let o=r.blocks.flatMap(f=>f.kind==="paragraph"?[f.text]:f.kind==="code"?[f.code]:f.items.map(h=>`- ${h.text}`)).join(`
58
+
59
+ `),C=r.sources.map(f=>n.sourceLabel(f.relativePath,f.startLine,f.endLine)).join(`
60
+ `);return C.length===0?o:`${o}
61
+
62
+ ${n.sourcesTitle}
63
+ ${C}`}function Ct(){r=void 0,a=void 0,e.onExecutionChange(),I.value="",Z.hidden=!0,j.hidden=!0,z.hidden=!0,Y.replaceChildren(),ee.hidden=!0,b=!1,M(),e.onViewChange()}l.addEventListener("click",()=>{s="ask",ue(),I.focus({preventScroll:!0})}),m.addEventListener("click",()=>{s="change",ue()}),I.addEventListener("input",M),R.addEventListener("change",()=>{Ge(),M(),e.onViewChange()}),X.addEventListener("change",M);let St=e.subscribeLocale(Ye);return Ye(),ue(),Object.freeze({root:P,styles:Mt(t),questionInput:I,executorSelect:R,consentCheckbox:X,submitButton:pe,cancelButton:le,newQuestionButton:xe,copyButton:Oe,convertButton:Ne,clear:Ct,dispose:()=>{St(),U.dispose(),i.dispose()},focusQuestion:()=>{I.focus({preventScroll:!0})},mode:()=>s,notify(o){let C=o==="copied"?n.copied:o==="copy-failed"?n.copyFailed:o==="converted"?n.converted:n.sourceOpenFailed;e.announce(C)},readConsent:()=>X.checked,readExecutorId:()=>R.value||void 0,readModel:()=>i.select.value||void 0,readQuestion:()=>I.value.trim(),renderAnswer:tt,renderCapability:Ze,renderError(o){a=void 0,e.onExecutionChange(),z.textContent=n.error(o),z.hidden=!1,j.hidden=!0,b=!1,M(),e.onViewChange()},renderEvent:kt,renderJob:et,selectedSourceId(o){return o instanceof Element?o.closest("[data-ask-source-id]")?.dataset.askSourceId:void 0},setBusy(o){b=o,o&&(j.hidden=!1,z.hidden=!0,Z.hidden=!0,Y.replaceChildren()),M()},setConsent(o){X.checked=o,M()},setMode(o){s=o,ue()},setOrigin(o){u.dataset.active=String(o!==void 0),u.hidden=s==="ask"||o===void 0,e.onViewChange()},setSelectionPreview(o){E=o,B.textContent=n.dataSummary(o.targetCount,o.sourceCount),M()},setSelectionVisible(o){P.hidden=!o,o&&ue()},sourceById:o=>r?.sources.find(C=>C.sourceId===o),answerPlainText:Et})}var Ut=Object.freeze({createPanel:xt,createWorkflow:gt});function At(){ht(Ut)}At();
@@ -1,5 +1,5 @@
1
- var k="data-spotpatch-ui",re=Object.freeze({highlight:2147483646,controls:2147483647}),ie=Object.freeze({compactInset:8,compactViewportWidth:520,desktopInset:24,dragActivationDistance:6,edgeSnapDistance:20,workbenchMaxHeight:620,workbenchMaxWidth:460});function u(e,t){let n=e.createElement(t);return n.setAttribute(k,""),n}function _(e,t,n=""){let o=u(e,"button");return o.type="button",o.className=n,o.textContent=t,o}var j=Object.freeze({"zh-CN":Object.freeze({bindings:"数据去向",changes:"修改说明",componentEmpty:"当前组件没有找到可证明的接口。未找到不等于没有请求。",componentTab:"数据链路",componentTitle:"组件数据链路",consumed:"读取字段",declared:"代码声明,尚未在本次页面会话中观测",diagnostics:"诊断",disabled:"数据链路能力未启用,请在插件配置中设置 dataFlow: {}。",error:"数据链路报告加载失败",evidence:"证据",loading:"正在分析源码并合并运行时证据…",logicalObserved:"本次会话已进入 tRPC 调用链",noParameters:"未提取到可证明的参数键",observed:"本次会话已实际请求",pageEmpty:"当前已选页面范围内没有静态接口或运行时网络记录。",pageTab:"页面接口",pageTitle:"页面接口",parameters:"请求参数",refresh:"刷新证据",unknown:"未知"}),"en-US":Object.freeze({bindings:"Data destinations",changes:"Changes",componentEmpty:"No proven interface was found for this component. This does not prove that no request exists.",componentTab:"Data flow",componentTitle:"Component data flow",consumed:"Consumed fields",declared:"Declared in code, not observed in this page session",diagnostics:"Diagnostics",disabled:"Data flow is disabled. Set dataFlow: {} in the plugin options.",error:"Failed to load the data-flow report",evidence:"Evidence",loading:"Analyzing source and merging runtime evidence…",logicalObserved:"Dispatched through the tRPC link in this session",noParameters:"No proven parameter keys were extracted",observed:"Actually requested in this session",pageEmpty:"No static interface or runtime traffic is available for the selected page scope.",pageTab:"Page APIs",pageTitle:"Page interfaces",parameters:"Request parameters",refresh:"Refresh evidence",unknown:"Unknown"})});function C(e,t,n){let o=u(e,"span");return o.className="spotpatch-data-flow-badge",o.dataset.tone=n,o.textContent=t,o}function v(e,t,n){let o=u(e,"div");o.className="spotpatch-data-flow-detail";let a=u(e,"span");a.textContent=t;let s=u(e,"code");return s.textContent=n,o.append(a,s),o}function X(e,t,n){let o=u(e,"article");o.className="spotpatch-data-flow-card";let a=u(e,"div");a.className="spotpatch-data-flow-card-head";let s=u(e,"div");s.className="spotpatch-data-flow-endpoint";let r=u(e,"strong");r.textContent=t.method??n.unknown;let f=u(e,"code");f.textContent=t.url===void 0?t.operation??n.unknown:`${t.url.origin??""}${t.url.pathname}`,s.append(r,f);let c=u(e,"div");c.className="spotpatch-data-flow-badges",c.append(C(e,t.execution==="observed"?t.kind==="rpc"?n.logicalObserved:n.observed:n.declared,t.execution==="observed"?"success":"neutral"),C(e,t.proof,t.proof==="proven"?"proof":"warning"),C(e,t.association,"neutral")),a.append(s,c);let m=t.parameters.length===0?n.noParameters:t.parameters.map(g=>`${g.position}.${g.path}${g.type===void 0?"":`: ${g.type}`}${g.sensitive?" [sensitive]":""}${g.condition===void 0?"":` [when ${g.condition}]`}`).join(`
2
- `),b=t.response.consumedFields.length===0?n.unknown:t.response.consumedFields.join(", "),T=t.suppliedBindings.length===0?n.unknown:t.suppliedBindings.join(", "),y=u(e,"div");y.className="spotpatch-data-flow-card-body";let E=new Set(t.observationIds),w=t.evidenceIds.filter(g=>!E.has(g)).length;return y.append(v(e,n.parameters,m),v(e,n.consumed,b),v(e,n.bindings,T),v(e,n.evidence,`${String(w)} static · ${String(t.observationIds.length)} runtime`)),o.append(a,y),o}function z(e,t){let n=u(e,"section");n.className="spotpatch-data-flow-panel";let o=u(e,"h3");o.textContent=t;let a=u(e,"p");a.className="spotpatch-data-flow-status";let s=u(e,"div");return s.className="spotpatch-data-flow-list",n.append(o,a,s),Object.freeze({root:n,status:a,list:s})}function q(e,t,n,o,a,s){let r=j[n()],f=z(e,r.componentTitle),c=z(e,r.pageTitle),m=_(e,r.refresh),b=e.createElement("style");b.textContent=W,m.classList.add("spotpatch-data-flow-refresh"),f.root.prepend(m);let T=u(e,"div"),y=u(e,"nav");y.className="spotpatch-view-tabs",y.setAttribute("aria-label","SpotPatch views"),y.setAttribute("role","tablist");let E=new Map([["changes",o],["component-data",f.root],["page-data",c.root],["diagnostics",a]]),w=new Map,g="changes";for(let i of E.keys()){let l=_(e,"");l.dataset.viewId=i,l.id=`spotpatch-view-${i}-tab`,l.setAttribute("role","tab"),l.setAttribute("aria-selected",String(i===g));let d=E.get(i);d?.setAttribute("aria-labelledby",l.id),d?.setAttribute("role","tabpanel"),!t&&(i==="component-data"||i==="page-data")&&(l.hidden=!0),w.set(i,l),y.append(l)}T.append(y,...E.values());function D(i){if(E.has(i)){g=i;for(let[l,d]of E){d.hidden=l!==i;let h=w.get(l);h?.setAttribute("aria-selected",String(l===i)),h!==void 0&&(h.tabIndex=l===i?0:-1)}s()}}function S(i){if(!(i.target instanceof HTMLButtonElement))return;let l=i.target.dataset.viewId;l!==void 0&&D(l)}y.addEventListener("click",S),D(g);function A(i,l,d){if(i.list.replaceChildren(),i.status.dataset.state=l.status,!t||l.status==="disabled"){i.status.textContent=r.disabled;return}if(l.status==="loading"){i.status.textContent=r.loading;return}if(l.status==="error"){i.status.textContent=l.message??r.error;return}let h=l.report,P=h===void 0?"":[...new Set(h.diagnostics.map(({code:x})=>x))].join(", "),M=P.length===0?"":` · ${r.diagnostics}: ${P}`;if(h===void 0||h.dependencies.length===0){i.status.textContent=`${d}${M}`;return}i.status.textContent=`${String(h.dependencies.length)} · ${h.completeness.complete?"complete":"partial"}${M}`,i.list.append(...h.dependencies.map(x=>X(e,x,r)))}return Object.freeze({root:T,refreshButton:m,styles:b,dispose(){y.removeEventListener("click",S)},render(i){r=j[n()];let l=[r.changes,r.componentTab,r.pageTab,r.diagnostics];[...w.values()].forEach((d,h)=>{d.textContent=l[h]??""}),m.textContent=`${r.refresh} · ${String(i.observationCount)}`,m.disabled=!t||i.component.status==="loading",A(f,i.component,r.componentEmpty),A(c,i.page,r.pageEmpty)},resetView(){D("changes")}})}var W=`
1
+ var M="data-spotpatch-ui",re=Object.freeze({highlight:2147483646,controls:2147483647}),se=Object.freeze({compactInset:8,compactViewportWidth:520,desktopInset:24,dragActivationDistance:6,edgeSnapDistance:20,workbenchMaxHeight:620,workbenchMaxWidth:460});function u(e,t){let n=e.createElement(t);return n.setAttribute(M,""),n}function F(e,t,n=""){let o=u(e,"button");return o.type="button",o.className=n,o.textContent=t,o}var j=Object.freeze({"zh-CN":Object.freeze({server:"服务端(静态证据)",client:"浏览器",bindings:"数据去向",changes:"修改说明",componentEmpty:"当前组件没有找到可证明的接口。未找到不等于没有请求。",componentTab:"数据链路",componentTitle:"组件数据链路",consumed:"读取字段",declared:"代码声明,尚未在本次页面会话中观测",diagnostics:"诊断",disabled:"数据链路能力未启用,请在插件配置中设置 dataFlow: {}。",error:"数据链路报告加载失败",evidence:"证据",loading:"正在分析源码并合并运行时证据…",logicalObserved:"本次会话已进入 tRPC 调用链",noParameters:"未提取到可证明的参数键",observed:"本次会话已实际请求",pageEmpty:"当前已选页面范围内没有静态接口或运行时网络记录。",pageTab:"页面接口",pageTitle:"页面接口",parameters:"请求参数",refresh:"刷新证据",unknown:"未知"}),"en-US":Object.freeze({server:"Server (static evidence)",client:"Browser",bindings:"Data destinations",changes:"Changes",componentEmpty:"No proven interface was found for this component. This does not prove that no request exists.",componentTab:"Data flow",componentTitle:"Component data flow",consumed:"Consumed fields",declared:"Declared in code, not observed in this page session",diagnostics:"Diagnostics",disabled:"Data flow is disabled. Set dataFlow: {} in the plugin options.",error:"Failed to load the data-flow report",evidence:"Evidence",loading:"Analyzing source and merging runtime evidence…",logicalObserved:"Dispatched through the tRPC link in this session",noParameters:"No proven parameter keys were extracted",observed:"Actually requested in this session",pageEmpty:"No static interface or runtime traffic is available for the selected page scope.",pageTab:"Page APIs",pageTitle:"Page interfaces",parameters:"Request parameters",refresh:"Refresh evidence",unknown:"Unknown"})});function v(e,t,n){let o=u(e,"span");return o.className="spotpatch-data-flow-badge",o.dataset.tone=n,o.textContent=t,o}function O(e,t,n){let o=u(e,"div");o.className="spotpatch-data-flow-detail";let a=u(e,"span");a.textContent=t;let s=u(e,"code");return s.textContent=n,o.append(a,s),o}function W(e,t,n){let o=u(e,"article");o.className="spotpatch-data-flow-card";let a=u(e,"div");a.className="spotpatch-data-flow-card-head";let s=u(e,"div");s.className="spotpatch-data-flow-endpoint";let r=u(e,"strong");r.textContent=t.method??n.unknown;let f=u(e,"code");f.textContent=t.url===void 0?t.operation??n.unknown:`${t.url.origin??""}${t.url.pathname}`,s.append(r,f);let c=u(e,"div");c.className="spotpatch-data-flow-badges",c.append(v(e,t.execution==="observed"?t.kind==="rpc"?n.logicalObserved:n.observed:n.declared,t.execution==="observed"?"success":"neutral"),v(e,t.proof,t.proof==="proven"?"proof":"warning"),v(e,t.association,"neutral")),a.append(s,c),t.environment!==void 0&&c.append(v(e,n[t.environment],"neutral"));let m=t.parameters.length===0?n.noParameters:t.parameters.map(g=>`${g.position}.${g.path}${g.type===void 0?"":`: ${g.type}`}${g.sensitive?" [sensitive]":""}${g.condition===void 0?"":` [when ${g.condition}]`}`).join(`
2
+ `),A=t.response.consumedFields.length===0?n.unknown:t.response.consumedFields.join(", "),S=t.suppliedBindings.length===0?n.unknown:t.suppliedBindings.join(", "),h=u(e,"div");h.className="spotpatch-data-flow-card-body";let b=new Set(t.observationIds),E=t.evidenceIds.filter(g=>!b.has(g)).length;return h.append(O(e,n.parameters,m),O(e,n.consumed,A),O(e,n.bindings,S),O(e,n.evidence,`${String(E)} static · ${String(t.observationIds.length)} runtime`)),o.append(a,h),o}function z(e,t){let n=u(e,"section");n.className="spotpatch-data-flow-panel";let o=u(e,"h3");o.textContent=t;let a=u(e,"p");a.className="spotpatch-data-flow-status";let s=u(e,"div");return s.className="spotpatch-data-flow-list",n.append(o,a,s),Object.freeze({root:n,status:a,list:s})}function q(e,t,n,o,a,s){let r=j[n()],f=z(e,r.componentTitle),c=z(e,r.pageTitle),m=F(e,r.refresh),A=e.createElement("style");A.textContent=K,m.classList.add("spotpatch-data-flow-refresh"),f.root.prepend(m);let S=u(e,"div"),h=u(e,"nav");h.className="spotpatch-view-tabs",h.setAttribute("aria-label","SpotPatch views"),h.setAttribute("role","tablist");let b=new Map([["changes",o],["component-data",f.root],["page-data",c.root],["diagnostics",a]]),E=new Map,g="changes";for(let i of b.keys()){let l=F(e,"");l.dataset.viewId=i,l.id=`spotpatch-view-${i}-tab`,l.setAttribute("role","tab"),l.setAttribute("aria-selected",String(i===g));let p=b.get(i);p?.setAttribute("aria-labelledby",l.id),p?.setAttribute("role","tabpanel"),!t&&(i==="component-data"||i==="page-data")&&(l.hidden=!0),E.set(i,l),h.append(l)}S.append(h,...b.values());function w(i){if(b.has(i)){g=i;for(let[l,p]of b){p.hidden=l!==i;let y=E.get(l);y?.setAttribute("aria-selected",String(l===i)),y!==void 0&&(y.tabIndex=l===i?0:-1)}s()}}function D(i){if(!(i.target instanceof HTMLButtonElement))return;let l=i.target.dataset.viewId;l!==void 0&&w(l)}h.addEventListener("click",D),w(g);function T(i,l,p){if(i.list.replaceChildren(),i.status.dataset.state=l.status,!t||l.status==="disabled"){i.status.textContent=r.disabled;return}if(l.status==="loading"){i.status.textContent=r.loading;return}if(l.status==="error"){i.status.textContent=l.message??r.error;return}let y=l.report,L=y===void 0?"":[...new Set(y.diagnostics.map(({code:C})=>C))].join(", "),P=L.length===0?"":` · ${r.diagnostics}: ${L}`;if(y===void 0||y.dependencies.length===0){i.status.textContent=`${p}${P}`;return}i.status.textContent=`${String(y.dependencies.length)} · ${y.completeness.complete?"complete":"partial"}${P}`,i.list.append(...y.dependencies.map(C=>W(e,C,r)))}return Object.freeze({root:S,refreshButton:m,styles:A,dispose(){h.removeEventListener("click",D)},render(i){r=j[n()];let l=[r.changes,r.componentTab,r.pageTab,r.diagnostics];[...E.values()].forEach((p,y)=>{p.textContent=l[y]??""}),m.textContent=`${r.refresh} · ${String(i.observationCount)}`,m.disabled=!t||i.component.status==="loading",T(f,i.component,r.componentEmpty),T(c,i.page,r.pageEmpty)},resetView(){w("changes")}})}var K=`
3
3
  .spotpatch-view-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin-bottom: 12px; padding: 3px; border: 1px solid rgb(255 255 255 / 7%); border-radius: 9px; background: rgb(3 7 18 / 42%); }
4
4
  .spotpatch-view-tabs button { min-width: 0; border: 0; border-radius: 7px; padding: 7px 5px; color: var(--spotpatch-text-muted); background: transparent; cursor: pointer; font-size: 10.5px; }
5
5
  .spotpatch-view-tabs button[aria-selected="true"] { color: #f8fafc; background: rgb(139 124 247 / 18%); }
@@ -23,4 +23,4 @@ var k="data-spotpatch-ui",re=Object.freeze({highlight:2147483646,controls:214748
23
23
  .spotpatch-data-flow-detail { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 8px; align-items: start; }
24
24
  .spotpatch-data-flow-detail > span { color: var(--spotpatch-text-muted); font-size: 10px; }
25
25
  .spotpatch-data-flow-detail > code { overflow-wrap: anywhere; color: #cbd5e1; font: 10px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
26
- `;var G=Symbol.for("spotpatch.data-flow.extension.v1");function H(e,t=globalThis){t[G]=e}var p=Object.freeze({observationMaxEntries:100,observationMaxBytes:262144,observationTtlMs:3e5,protocolRequestMaxBytes:32768,reportMaxBytes:131072,reportMaxEvidence:200,reportMaxDiagnostics:256,capabilityMaxReasons:64,graphMaxDepth:5,graphMaxModules:50,graphMaxCallsites:100,analysisTimeoutMs:2e3,reportMaxFields:100,sourceMaxComponents:256}),fe=p.reportMaxFields,me=Object.freeze({observationMaxEntries:p.observationMaxEntries,observationMaxBytes:p.observationMaxBytes,observationTtlMs:p.observationTtlMs,reportMaxBytes:p.reportMaxBytes});var K=Symbol.for("spotpatch.data-flow.runtime.v1");function O(e=globalThis){return e[K]}var $=new Set(["authorization","cookie","defaultvalue","password","setcookie","value"]);function Y(e){return e.toLowerCase().replaceAll(/[-_:]/gu,"")}function I(e){let t=Y(e);return $.has(t)||t.includes("apikey")||t.includes("authorization")||t.includes("secret")||t.includes("token")}function R(e,t){return Object.freeze(e.slice(0,Math.max(0,t)))}function J(e){let t=e.url===void 0?void 0:R(e.url.queryKeys,p.reportMaxFields),n=R(e.parameters,p.reportMaxFields).map(m=>Object.freeze({...m,evidenceIds:R(m.evidenceIds,p.reportMaxEvidence)})),o=R(e.response.consumedFields,p.reportMaxFields),a=R(e.suppliedBindings,p.graphMaxCallsites),s=R(e.locationIds,p.graphMaxCallsites),r=R(e.evidenceIds,p.reportMaxEvidence),f=R(e.observationIds,p.observationMaxEntries);return t?.length!==e.url?.queryKeys.length||n.length!==e.parameters.length||n.some((m,b)=>m.evidenceIds.length!==e.parameters[b]?.evidenceIds.length)||o.length!==e.response.consumedFields.length||a.length!==e.suppliedBindings.length||s.length!==e.locationIds.length||r.length!==e.evidenceIds.length||f.length!==e.observationIds.length?Object.freeze({dependency:Object.freeze({...e,...e.url===void 0?{}:{url:Object.freeze({...e.url,queryKeys:t??Object.freeze([])})},parameters:Object.freeze(n),response:Object.freeze({consumedFields:o}),suppliedBindings:a,locationIds:s,evidenceIds:r,observationIds:f}),trimmed:!0}):Object.freeze({dependency:e,trimmed:!1})}function Q(e,t){return Object.freeze([...new Set([...e.flatMap(n=>[...n.evidenceIds,...n.parameters.flatMap(o=>o.evidenceIds)]),...t.flatMap(n=>n.evidenceIds)])])}function Z(e,t,n){let o=new Map(e.map(r=>[r.id,r])),a=[],s=new Set;for(let r of t){let f=o.get(r);f!==void 0&&!s.has(r)&&(a.push(f),s.add(r))}if(n)for(let r of e)s.has(r.id)||a.push(r);return R(a,p.reportMaxEvidence)}function ee(e,t){return Object.freeze({...e,parameters:Object.freeze(e.parameters.map(n=>Object.freeze({...n,evidenceIds:Object.freeze(n.evidenceIds.filter(o=>t.has(o)))}))),evidenceIds:Object.freeze(e.evidenceIds.filter(n=>t.has(n)))})}function te(e){return e==="analysis"?"DATA_FLOW_ANALYSIS_TRUNCATED":"DATA_FLOW_OBSERVATION_DROPPED"}function F(e,t={}){let n=Math.min(Math.max(0,t.maximumDependencies??p.graphMaxCallsites),p.graphMaxCallsites),o=R(e.dependencies,n).map(J),a=o.map(({dependency:d})=>d),s=R(e.baseline.analyzedSourceVersions,p.graphMaxModules),r=e.dependencies.length>a.length||o.some(({trimmed:d})=>d)||e.baseline.analyzedSourceVersions.length>s.length||e.capability.reasons.length>p.capabilityMaxReasons||e.evidence.length>p.reportMaxEvidence||e.diagnostics.length>p.reportMaxDiagnostics;if(!(t.forceTruncation===!0||r))return e;let c=t.mode??"analysis",m=te(c),b=`${e.reportId}_collection_${c}`,T=Object.freeze([...e.capability.reasons.filter(d=>d.code!==m).slice(0,p.capabilityMaxReasons-1),Object.freeze({code:m,retryable:!1})]),y=Object.freeze([...e.diagnostics.filter(d=>d.id!==b).slice(0,p.reportMaxDiagnostics-1),Object.freeze({id:b,code:m,severity:"warning",retryable:!1,evidenceIds:Object.freeze([])})]),E=Q(a,y),w=Z(e.evidence,E,e.dependencies.length===a.length),g=new Set(w.map(({id:d})=>d)),D=Object.freeze(a.map(d=>ee(d,g))),S=Object.freeze(y.map(d=>Object.freeze({...d,evidenceIds:Object.freeze(d.evidenceIds.filter(h=>g.has(h)))}))),A=e.dependencies.length-a.length,i=e.baseline.analyzedSourceVersions.length-s.length,l=i>0&&A===0?"modules":"callsites";return Object.freeze({...e,baseline:Object.freeze({...e.baseline,analyzedSourceVersions:s}),capability:Object.freeze({...e.capability,...c==="analysis"&&e.capability.staticAnalysis==="available"?{staticAnalysis:"partial"}:{},reasons:T}),dependencies:D,evidence:w,diagnostics:S,...c==="analysis"?{completeness:Object.freeze({...e.completeness,complete:!1,frontierCount:e.completeness.frontierCount+A+i+(r&&A===0&&i===0?1:0),truncatedBy:t.truncatedBy??e.completeness.truncatedBy??l})}:{}})}function ne(e,t){let n=t.origin;return!(t.kind==="rpc"?e.transport==="trpc"&&t.operation!==void 0&&e.operation===t.operation:t.kind==="http"?e.transport==="fetch"||e.transport==="xhr":!1)||e.freshness!=="current"||n===void 0||e.requestCallsiteId!==n.requestCallsiteId||e.sourceVersion!==n.sourceVersion||t.method!==void 0&&e.method.toUpperCase()!==t.method.toUpperCase()||t.url!==void 0&&e.url.pathname!==t.url.pathname||t.url?.origin!==void 0&&e.url.origin!==t.url.origin||n.componentSourceId!==void 0&&e.componentSourceId!==void 0&&e.componentSourceId!==n.componentSourceId||n.triggerCallsiteId!==void 0&&e.triggerCallsiteId!==void 0&&e.triggerCallsiteId!==n.triggerCallsiteId?!1:t.association!=="transitive"||e.componentSourceId===n.componentSourceId&&e.triggerCallsiteId===n.triggerCallsiteId}function oe(e){return Object.freeze({id:e.id,kind:"runtime-observation",summaryKey:"dataFlow.evidence.runtimeDispatch"})}function U(e,t){let n=new Set,o=e.map(a=>{let s=t.filter(c=>ne(c,a));for(let c of s)n.add(c.id);if(s.length===0)return a;let r=[...new Set(s.flatMap(({url:c})=>c.origin===void 0?[]:[c.origin]))],f=r.length===1?r[0]:void 0;return Object.freeze({...a,...a.url===void 0||a.url.origin!==void 0||f===void 0?{}:{url:Object.freeze({...a.url,origin:f})},execution:"observed",observationIds:Object.freeze([...new Set([...a.observationIds,...s.map(({id:c})=>c)])]),evidenceIds:Object.freeze([...new Set([...a.evidenceIds,...s.map(({id:c})=>c)])])})});return Object.freeze({dependencies:Object.freeze(o),matchedObservationIds:n})}function B(e,t,n){let o=new Set(e.map(({id:a})=>a));return Object.freeze([...e,...t.flatMap(a=>n.has(a.id)&&!o.has(a.id)?[oe(a)]:[])])}function L(e,t){let n=t.filter(a=>a.componentSourceId===void 0||a.componentSourceId===e.component.componentSourceId),o=U(e.dependencies,n);return F(Object.freeze({...e,dependencies:o.dependencies,evidence:B(e.evidence,n,o.matchedObservationIds)}),{mode:"observation"})}function ae(e){let t=e.transport==="trpc";return Object.freeze({id:e.id,kind:t?"rpc":"http",direction:e.method==="GET"||e.method==="HEAD"||e.method==="QUERY"||e.method==="SUBSCRIPTION"?"read":"write",execution:"observed",proof:"unavailable",association:"unassigned",method:e.method,...t?e.operation===void 0?{}:{operation:e.operation}:{url:e.url},parameters:Object.freeze((t?[]:e.url.queryKeys).map(n=>Object.freeze({path:n,position:"query",sensitive:I(n),valueState:"not-collected",evidenceIds:Object.freeze([e.id])}))),response:Object.freeze({consumedFields:Object.freeze([])}),suppliedBindings:Object.freeze([]),locationIds:Object.freeze([]),evidenceIds:Object.freeze([e.id]),observationIds:Object.freeze([e.id])})}function N(e,t){let n=t.filter(({freshness:r})=>r==="current"),o=U(e.dependencies,n),a=n.filter(({id:r})=>!o.matchedObservationIds.has(r)).map(ae),s=new Set(n.map(({id:r})=>r));return F(Object.freeze({...e,dependencies:Object.freeze([...o.dependencies,...a]),evidence:B(e.evidence,n,s)}),{mode:"observation"})}function V(){H(Object.freeze({createPanel:q,getComponentRegistration(e){return O()?.getComponentRegistration(e)},observations(e){let t=O();return t?.updateRoute(e),t?.observations()??Object.freeze([])},mergeComponentReport:L,mergePageReport:N}))}V();
26
+ `;var V=Symbol.for("spotpatch.data-flow.extension.v1");function H(e,t=globalThis){t[V]=e}var d=Object.freeze({observationMaxEntries:100,observationMaxBytes:262144,observationTtlMs:3e5,protocolRequestMaxBytes:32768,reportMaxBytes:131072,reportMaxEvidence:200,reportMaxDiagnostics:256,capabilityMaxReasons:64,graphMaxDepth:5,graphMaxModules:50,graphMaxCallsites:100,analysisTimeoutMs:2e3,reportMaxFields:100,sourceMaxComponents:256}),fe=d.reportMaxFields,me=Object.freeze({observationMaxEntries:d.observationMaxEntries,observationMaxBytes:d.observationMaxBytes,observationTtlMs:d.observationTtlMs,reportMaxBytes:d.reportMaxBytes});var G=Symbol.for("spotpatch.data-flow.runtime.v1");function x(e=globalThis){return e[G]}var $=new Set(["authorization","cookie","defaultvalue","password","setcookie","value"]);function J(e){return e.toLowerCase().replaceAll(/[-_:]/gu,"")}function I(e){let t=J(e);return $.has(t)||t.includes("apikey")||t.includes("authorization")||t.includes("secret")||t.includes("token")}function R(e,t){return Object.freeze(e.slice(0,Math.max(0,t)))}function Y(e){let t=e.url===void 0?void 0:R(e.url.queryKeys,d.reportMaxFields),n=R(e.parameters,d.reportMaxFields).map(m=>Object.freeze({...m,evidenceIds:R(m.evidenceIds,d.reportMaxEvidence)})),o=R(e.response.consumedFields,d.reportMaxFields),a=R(e.suppliedBindings,d.graphMaxCallsites),s=R(e.locationIds,d.graphMaxCallsites),r=R(e.evidenceIds,d.reportMaxEvidence),f=R(e.observationIds,d.observationMaxEntries);return t?.length!==e.url?.queryKeys.length||n.length!==e.parameters.length||n.some((m,A)=>m.evidenceIds.length!==e.parameters[A]?.evidenceIds.length)||o.length!==e.response.consumedFields.length||a.length!==e.suppliedBindings.length||s.length!==e.locationIds.length||r.length!==e.evidenceIds.length||f.length!==e.observationIds.length?Object.freeze({dependency:Object.freeze({...e,...e.url===void 0?{}:{url:Object.freeze({...e.url,queryKeys:t??Object.freeze([])})},parameters:Object.freeze(n),response:Object.freeze({consumedFields:o}),suppliedBindings:a,locationIds:s,evidenceIds:r,observationIds:f}),trimmed:!0}):Object.freeze({dependency:e,trimmed:!1})}function Q(e,t){return Object.freeze([...new Set([...e.flatMap(n=>[...n.evidenceIds,...n.parameters.flatMap(o=>o.evidenceIds)]),...t.flatMap(n=>n.evidenceIds)])])}function Z(e,t,n){let o=new Map(e.map(r=>[r.id,r])),a=[],s=new Set;for(let r of t){let f=o.get(r);f!==void 0&&!s.has(r)&&(a.push(f),s.add(r))}if(n)for(let r of e)s.has(r.id)||a.push(r);return R(a,d.reportMaxEvidence)}function ee(e,t){return Object.freeze({...e,parameters:Object.freeze(e.parameters.map(n=>Object.freeze({...n,evidenceIds:Object.freeze(n.evidenceIds.filter(o=>t.has(o)))}))),evidenceIds:Object.freeze(e.evidenceIds.filter(n=>t.has(n)))})}function te(e){return e==="analysis"?"DATA_FLOW_ANALYSIS_TRUNCATED":"DATA_FLOW_OBSERVATION_DROPPED"}function _(e,t={}){let n=Math.min(Math.max(0,t.maximumDependencies??d.graphMaxCallsites),d.graphMaxCallsites),o=R(e.dependencies,n).map(Y),a=o.map(({dependency:p})=>p),s=R(e.baseline.analyzedSourceVersions,d.graphMaxModules),r=e.dependencies.length>a.length||o.some(({trimmed:p})=>p)||e.baseline.analyzedSourceVersions.length>s.length||e.capability.reasons.length>d.capabilityMaxReasons||e.evidence.length>d.reportMaxEvidence||e.diagnostics.length>d.reportMaxDiagnostics;if(!(t.forceTruncation===!0||r))return e;let c=t.mode??"analysis",m=te(c),A=`${e.reportId}_collection_${c}`,S=Object.freeze([...e.capability.reasons.filter(p=>p.code!==m).slice(0,d.capabilityMaxReasons-1),Object.freeze({code:m,retryable:!1})]),h=Object.freeze([...e.diagnostics.filter(p=>p.id!==A).slice(0,d.reportMaxDiagnostics-1),Object.freeze({id:A,code:m,severity:"warning",retryable:!1,evidenceIds:Object.freeze([])})]),b=Q(a,h),E=Z(e.evidence,b,e.dependencies.length===a.length),g=new Set(E.map(({id:p})=>p)),w=Object.freeze(a.map(p=>ee(p,g))),D=Object.freeze(h.map(p=>Object.freeze({...p,evidenceIds:Object.freeze(p.evidenceIds.filter(y=>g.has(y)))}))),T=e.dependencies.length-a.length,i=e.baseline.analyzedSourceVersions.length-s.length,l=i>0&&T===0?"modules":"callsites";return Object.freeze({...e,baseline:Object.freeze({...e.baseline,analyzedSourceVersions:s}),capability:Object.freeze({...e.capability,...c==="analysis"&&e.capability.staticAnalysis==="available"?{staticAnalysis:"partial"}:{},reasons:S}),dependencies:w,evidence:E,diagnostics:D,...c==="analysis"?{completeness:Object.freeze({...e.completeness,complete:!1,frontierCount:e.completeness.frontierCount+T+i+(r&&T===0&&i===0?1:0),truncatedBy:t.truncatedBy??e.completeness.truncatedBy??l})}:{}})}function ne(e,t){let n=t.origin,o=t.kind==="rpc"?e.transport==="trpc"&&t.operation!==void 0&&e.operation===t.operation:t.kind==="http"?e.transport==="fetch"||e.transport==="xhr":!1;return t.environment==="server"||!o||e.freshness!=="current"||n===void 0||e.requestCallsiteId!==n.requestCallsiteId||e.sourceVersion!==n.sourceVersion||t.method!==void 0&&e.method.toUpperCase()!==t.method.toUpperCase()||t.url!==void 0&&e.url.pathname!==t.url.pathname||t.url?.origin!==void 0&&e.url.origin!==t.url.origin||n.componentSourceId!==void 0&&e.componentSourceId!==void 0&&e.componentSourceId!==n.componentSourceId||n.triggerCallsiteId!==void 0&&e.triggerCallsiteId!==void 0&&e.triggerCallsiteId!==n.triggerCallsiteId?!1:t.association!=="transitive"||e.componentSourceId===n.componentSourceId&&e.triggerCallsiteId===n.triggerCallsiteId}function oe(e){return Object.freeze({id:e.id,kind:"runtime-observation",summaryKey:"dataFlow.evidence.runtimeDispatch"})}function U(e,t){let n=new Set,o=e.map(a=>{let s=t.filter(c=>ne(c,a));for(let c of s)n.add(c.id);if(s.length===0)return a;let r=[...new Set(s.flatMap(({url:c})=>c.origin===void 0?[]:[c.origin]))],f=r.length===1?r[0]:void 0;return Object.freeze({...a,...a.url===void 0||a.url.origin!==void 0||f===void 0?{}:{url:Object.freeze({...a.url,origin:f})},execution:"observed",observationIds:Object.freeze([...new Set([...a.observationIds,...s.map(({id:c})=>c)])]),evidenceIds:Object.freeze([...new Set([...a.evidenceIds,...s.map(({id:c})=>c)])])})});return Object.freeze({dependencies:Object.freeze(o),matchedObservationIds:n})}function B(e,t,n){let o=new Set(e.map(({id:a})=>a));return Object.freeze([...e,...t.flatMap(a=>n.has(a.id)&&!o.has(a.id)?[oe(a)]:[])])}function k(e,t){let n=new Set([e.component.componentSourceId,...e.dependencies.filter(s=>s.environment!=="server").map(s=>s.origin?.componentSourceId)]),o=t.filter(s=>s.componentSourceId===void 0||n.has(s.componentSourceId)),a=U(e.dependencies,o);return _(Object.freeze({...e,dependencies:a.dependencies,evidence:B(e.evidence,o,a.matchedObservationIds)}),{mode:"observation"})}function ae(e){let t=e.transport==="trpc";return Object.freeze({id:e.id,kind:t?"rpc":"http",direction:e.method==="GET"||e.method==="HEAD"||e.method==="QUERY"||e.method==="SUBSCRIPTION"?"read":"write",execution:"observed",proof:"unavailable",association:"unassigned",method:e.method,...t?e.operation===void 0?{}:{operation:e.operation}:{url:e.url},parameters:Object.freeze((t?[]:e.url.queryKeys).map(n=>Object.freeze({path:n,position:"query",sensitive:I(n),valueState:"not-collected",evidenceIds:Object.freeze([e.id])}))),response:Object.freeze({consumedFields:Object.freeze([])}),suppliedBindings:Object.freeze([]),locationIds:Object.freeze([]),evidenceIds:Object.freeze([e.id]),observationIds:Object.freeze([e.id])})}function N(e,t){let n=t.filter(({freshness:r})=>r==="current"),o=U(e.dependencies,n),a=n.filter(({id:r})=>!o.matchedObservationIds.has(r)).map(ae),s=new Set(n.map(({id:r})=>r));return _(Object.freeze({...e,dependencies:Object.freeze([...o.dependencies,...a]),evidence:B(e.evidence,n,s)}),{mode:"observation"})}function X(){H(Object.freeze({createPanel:q,getComponentRegistration(e){return x()?.getComponentRegistration(e)},observations(e){let t=x();return t?.updateRoute(e),t?.observations()??Object.freeze([])},mergeComponentReport:k,mergePageReport:N}))}X();
@@ -1 +1 @@
1
- var F=Object.freeze({observationMaxEntries:100,observationMaxBytes:262144,observationTtlMs:3e5,protocolRequestMaxBytes:32768,reportMaxBytes:131072,reportMaxEvidence:200,reportMaxDiagnostics:256,capabilityMaxReasons:64,graphMaxDepth:5,graphMaxModules:50,graphMaxCallsites:100,analysisTimeoutMs:2e3,reportMaxFields:100,sourceMaxComponents:256}),k=F.reportMaxFields,ne=Object.freeze({observationMaxEntries:F.observationMaxEntries,observationMaxBytes:F.observationMaxBytes,observationTtlMs:F.observationTtlMs,reportMaxBytes:F.reportMaxBytes});var l="/__spotpatch/v1";var re=Object.freeze({bootstrap:`${l}/bootstrap`,sourceContext:`${l}/source-context`,openEditor:`${l}/open-editor`,dataFlowComponentReport:`${l}/data-flow/component-report`,dataFlowPageReport:`${l}/data-flow/page-report`,agentCapability:`${l}/agent/capability`,agentWorkspaceHealth:`${l}/agent/workspace-health`,agentJobs:`${l}/agent/jobs`,externalHandoffCapability:`${l}/external-handoff/capability`,externalHandoffPublish:`${l}/external-handoff/publish`,externalHandoffStatus:`${l}/external-handoff/status`,externalHandoffResolveDelivery:`${l}/external-handoff/resolve-delivery`,externalAgentControlStatus:`${l}/external-agent/control/status`,externalAgentControlConnect:`${l}/external-agent/control/connect`,externalAgentControlDisconnect:`${l}/external-agent/control/disconnect`,externalAgentControlCancel:`${l}/external-agent/control/cancel`,externalAgentEvents:`${l}/external-agent/events`,externalAgentResult:`${l}/external-agent/result`});var q=Symbol.for("spotpatch.data-flow.runtime.v1"),K=Symbol.for("react.memo"),Y=Symbol.for("react.forward_ref");function j(e){return e.performance?.now()??Date.now()}function T(e){let n=0,o=(()=>{try{let a=new Uint8Array(8);return globalThis.crypto.getRandomValues(a),Array.from(a,p=>p.toString(36).padStart(2,"0")).join("")}catch{return"local"}})();return()=>(n+=1,`${e}_${o}_${n.toString(36)}`)}function U(e,n){try{let o=new URL(e,n);return Object.freeze({origin:o.origin,pathname:o.pathname,queryKeys:Object.freeze([...new Set(o.searchParams.keys())].sort().slice(0,k))})}catch{return Object.freeze({pathname:e.split(/[?#]/u,1)[0]??"{invalid}",queryKeys:Object.freeze([])})}}function J(e){return typeof e=="string"?e:e instanceof URL?e.toString():e.url}function Q(e,n){return n?.method!==void 0?n.method.toUpperCase():typeof Request<"u"&&e instanceof Request?e.method.toUpperCase():"GET"}function z(e,n){try{let o=new URL(e,n).pathname;return o===l||o.startsWith(`${l}/`)}catch{return!1}}function Z(e){return new TextEncoder().encode(JSON.stringify(e)).byteLength}function ee(e,n){let o=[],a=0;function p(d){for(;o[0]!==void 0&&d-o[0].recordedAt>e.observationTtlMs;){let f=o.shift();f!==void 0&&(a-=f.bytes)}}return Object.freeze({add(d){let f=j(n);p(f);let y=Z(d);if(!(y>e.observationMaxBytes))for(o.push(Object.freeze({bytes:y,observation:d,recordedAt:f})),a+=y;o.length>e.observationMaxEntries||a>e.observationMaxBytes;){let h=o.shift();h!==void 0&&(a-=h.bytes)}},clear(){o.length=0,a=0},values(){return p(j(n)),Object.freeze(o.map(({observation:d})=>d))}})}function w(e,n){try{return Object.getOwnPropertyDescriptor(e,n)}catch{return}}function te(e){let n=w(e,"$$typeof")?.value,o=n===K?"type":n===Y?"render":void 0;if(o===void 0)return;let a=w(e,o)?.value;return typeof a=="object"&&a!==null||typeof a=="function"?a:void 0}function M(e,n,o,a=w(e,n)){if(!(a===void 0||!("value"in a)||!a.writable)){try{Object.defineProperty(e,n,{...a,value:o})}catch{return}return()=>{try{w(e,n)?.value===o&&Object.defineProperty(e,n,a)}catch{}}}}function O(e){try{e()}catch{}}function $(e,n=globalThis,o={}){let a=new WeakMap,p=new WeakMap,d=ee(e.limits,n),f=T("invocation"),y=T("observation"),h=T("page")(),L=T("route"),m=L(),v,D,g,P=!1,x=(()=>{try{return n.fetch}catch{return}})();function H(t,r){if(x===void 0)throw new TypeError("Fetch is unavailable.");let s=Reflect.apply(x,this,[t,r]);return O(()=>{let i=g,c=i?.invocationToken,b=J(t);z(b,n.location?.href??"http://spotpatch.invalid/")||o.shouldObserveFetch?.(t,r,n.location?.href??"http://spotpatch.invalid/")===!1||d.add(Object.freeze({schemaVersion:1,id:y(),pageEpoch:h,routeEpoch:m,...i===void 0?{}:{requestCallsiteId:i.requestCallsiteId,sourceVersion:i.sourceVersion},...c===void 0?{}:{invocationId:c.invocationId,componentSourceId:c.componentSourceId,triggerCallsiteId:c.triggerCallsiteId},transport:"fetch",method:Q(t,r),url:U(b,n.location?.href??"http://spotpatch.invalid/"),outcome:"dispatched",freshness:"current",diagnosticIds:Object.freeze([])}))}),s}let W=x===void 0?void 0:M(n,"fetch",H),u=(()=>{try{return n.XMLHttpRequest?.prototype}catch{return}})(),C=u===void 0?void 0:w(u,"open"),_=u===void 0?void 0:w(u,"send");function N(t,r,...s){let i=C?.value;typeof i=="function"&&Reflect.apply(i,this,[t,r,...s]),O(()=>{p.set(this,Object.freeze({method:t,url:String(r)}))})}function B(t){let r=_?.value;typeof r=="function"&&Reflect.apply(r,this,[t]),O(()=>{let s=p.get(this);if(s===void 0||z(s.url,n.location?.href??"http://spotpatch.invalid/")||o.shouldObserveXhr?.(s.url,n.location?.href??"http://spotpatch.invalid/")===!1)return;let i=g,c=i?.invocationToken;d.add(Object.freeze({schemaVersion:1,id:y(),pageEpoch:h,routeEpoch:m,...i===void 0?{}:{requestCallsiteId:i.requestCallsiteId,sourceVersion:i.sourceVersion},...c===void 0?{}:{invocationId:c.invocationId,componentSourceId:c.componentSourceId,triggerCallsiteId:c.triggerCallsiteId},transport:"xhr",method:s.method.toUpperCase(),url:U(s.url,n.location?.href??"http://spotpatch.invalid/"),outcome:"dispatched",freshness:"current",diagnosticIds:Object.freeze([])}))})}let G=u===void 0||typeof C?.value!="function"?void 0:M(u,"open",N,C),X=u===void 0||typeof _?.value!="function"?void 0:M(u,"send",B,_),I=Object.freeze({beginInvocation(t){return Object.freeze({invocationId:f(),componentSourceId:t.componentSourceId,triggerCallsiteId:t.triggerCallsiteId,sourceVersion:t.sourceVersion})},bindInvocation(t,r){return function(...i){return I.withInvocation(t,()=>Reflect.apply(r,this,i))}},bindTrigger(t,r){if(typeof r!="function")return r;let s=r;return function(...c){let b=I.beginInvocation(t);return I.withInvocation(b,()=>Reflect.apply(s,this,c))}},captureInvocation:()=>D,clear:d.clear,createTrpcLink(){return()=>t=>(O(()=>{let r=t.op.path,s=t.op.type;if(typeof r!="string"||r.length===0||r.length>512||s!=="query"&&s!=="mutation"&&s!=="subscription")return;let i=g,c=i?.invocationToken;d.add(Object.freeze({schemaVersion:1,id:y(),pageEpoch:h,routeEpoch:m,...i===void 0?{}:{requestCallsiteId:i.requestCallsiteId,sourceVersion:i.sourceVersion},...c===void 0?{}:{invocationId:c.invocationId,componentSourceId:c.componentSourceId,triggerCallsiteId:c.triggerCallsiteId},transport:"trpc",method:s.toUpperCase(),operation:r,url:Object.freeze({pathname:r,queryKeys:Object.freeze([])}),outcome:"dispatched",freshness:"current",diagnosticIds:Object.freeze([])}))}),t.next(t.op))},dispose(){P||(P=!0,d.clear(),W?.(),G?.(),X?.())},getComponentRegistration:t=>a.get(t),getCurrentRequestFrame:()=>g,observations:()=>Object.freeze(d.values().map(t=>t.routeEpoch===m?t:Object.freeze({...t,freshness:"stale-route"}))),registerComponent(t,r,s){let i=Object.freeze({componentSourceId:r,sourceVersion:s}),c=[t],b=new Set;for(;c.length>0;){let R=c.pop();if(R===void 0||b.has(R))continue;b.add(R),a.set(R,i);let E=te(R);E!==void 0&&c.push(E)}},updateRoute(t){v===void 0?v=t:v!==t&&(v=t,m=L())},withInvocation(t,r){let s=D;D=t;try{return r()}finally{D=s}},withRequestFrame(t,r,s){let i=g;g=Object.freeze({requestCallsiteId:r.requestCallsiteId,sourceVersion:r.sourceVersion,...t===void 0?{}:{invocationToken:t}});try{return s()}finally{g=i}}});return I}function S(e,n=globalThis,o={}){if(!e.enabled)return;let a=n[q]??$(e,n,o);return n[q]=a,a}var V=S(__SPOTPATCH_DATA_FLOW_CONFIG__);if(V===void 0)throw new Error("SpotPatch data-flow prelude was loaded while disabled.");var ge=V;export{ge as dataFlowRuntime};
1
+ var v=Object.freeze({observationMaxEntries:100,observationMaxBytes:262144,observationTtlMs:3e5,protocolRequestMaxBytes:32768,reportMaxBytes:131072,reportMaxEvidence:200,reportMaxDiagnostics:256,capabilityMaxReasons:64,graphMaxDepth:5,graphMaxModules:50,graphMaxCallsites:100,analysisTimeoutMs:2e3,reportMaxFields:100,sourceMaxComponents:256}),A=v.reportMaxFields,ne=Object.freeze({observationMaxEntries:v.observationMaxEntries,observationMaxBytes:v.observationMaxBytes,observationTtlMs:v.observationTtlMs,reportMaxBytes:v.reportMaxBytes});var s="/__spotpatch/v1";var re=Object.freeze({bootstrap:`${s}/bootstrap`,sourceContext:`${s}/source-context`,openEditor:`${s}/open-editor`,dataFlowComponentReport:`${s}/data-flow/component-report`,dataFlowPageReport:`${s}/data-flow/page-report`,agentCapability:`${s}/agent/capability`,agentWorkspaceHealth:`${s}/agent/workspace-health`,agentJobs:`${s}/agent/jobs`,askCapability:`${s}/ask/capability`,askJobs:`${s}/ask/jobs`,externalHandoffCapability:`${s}/external-handoff/capability`,externalHandoffPublish:`${s}/external-handoff/publish`,externalHandoffStatus:`${s}/external-handoff/status`,externalHandoffResolveDelivery:`${s}/external-handoff/resolve-delivery`,externalAgentControlStatus:`${s}/external-agent/control/status`,externalAgentControlConnect:`${s}/external-agent/control/connect`,externalAgentControlDisconnect:`${s}/external-agent/control/disconnect`,externalAgentControlCancel:`${s}/external-agent/control/cancel`,externalAgentEvents:`${s}/external-agent/events`,externalAgentResult:`${s}/external-agent/result`});var E=Symbol.for("spotpatch.data-flow.runtime.v1"),K=Symbol.for("react.memo"),J=Symbol.for("react.forward_ref");function j(e){return e.performance?.now()??Date.now()}function T(e){let n=0,o=(()=>{try{let a=new Uint8Array(8);return globalThis.crypto.getRandomValues(a),Array.from(a,p=>p.toString(36).padStart(2,"0")).join("")}catch{return"local"}})();return()=>(n+=1,`${e}_${o}_${n.toString(36)}`)}function U(e,n){try{let o=new URL(e,n);return Object.freeze({origin:o.origin,pathname:o.pathname,queryKeys:Object.freeze([...new Set(o.searchParams.keys())].sort().slice(0,A))})}catch{return Object.freeze({pathname:e.split(/[?#]/u,1)[0]??"{invalid}",queryKeys:Object.freeze([])})}}function Y(e){return typeof e=="string"?e:e instanceof URL?e.toString():e.url}function Q(e,n){return n?.method!==void 0?n.method.toUpperCase():typeof Request<"u"&&e instanceof Request?e.method.toUpperCase():"GET"}function $(e,n){try{let o=new URL(e,n).pathname;return o===s||o.startsWith(`${s}/`)}catch{return!1}}function Z(e){return new TextEncoder().encode(JSON.stringify(e)).byteLength}function ee(e,n){let o=[],a=0;function p(d){for(;o[0]!==void 0&&d-o[0].recordedAt>e.observationTtlMs;){let f=o.shift();f!==void 0&&(a-=f.bytes)}}return Object.freeze({add(d){let f=j(n);p(f);let y=Z(d);if(!(y>e.observationMaxBytes))for(o.push(Object.freeze({bytes:y,observation:d,recordedAt:f})),a+=y;o.length>e.observationMaxEntries||a>e.observationMaxBytes;){let h=o.shift();h!==void 0&&(a-=h.bytes)}},clear(){o.length=0,a=0},values(){return p(j(n)),Object.freeze(o.map(({observation:d})=>d))}})}function w(e,n){try{return Object.getOwnPropertyDescriptor(e,n)}catch{return}}function te(e){let n=w(e,"$$typeof")?.value,o=n===K?"type":n===J?"render":void 0;if(o===void 0)return;let a=w(e,o)?.value;return typeof a=="object"&&a!==null||typeof a=="function"?a:void 0}function S(e,n,o,a=w(e,n)){if(!(a===void 0||!("value"in a)||!a.writable)){try{Object.defineProperty(e,n,{...a,value:o})}catch{return}return()=>{try{w(e,n)?.value===o&&Object.defineProperty(e,n,a)}catch{}}}}function O(e){try{e()}catch{}}function z(e,n=globalThis,o={}){let a=new WeakMap,p=new WeakMap,d=ee(e.limits,n),f=T("invocation"),y=T("observation"),h=T("page")(),q=T("route"),m=q(),F,D,g,L=!1,x=(()=>{try{return n.fetch}catch{return}})();function W(t,r){if(x===void 0)throw new TypeError("Fetch is unavailable.");let l=Reflect.apply(x,this,[t,r]);return O(()=>{let i=g,c=i?.invocationToken,b=Y(t);$(b,n.location?.href??"http://spotpatch.invalid/")||o.shouldObserveFetch?.(t,r,n.location?.href??"http://spotpatch.invalid/")===!1||d.add(Object.freeze({schemaVersion:1,id:y(),pageEpoch:h,routeEpoch:m,...i===void 0?{}:{requestCallsiteId:i.requestCallsiteId,sourceVersion:i.sourceVersion},...c===void 0?{}:{invocationId:c.invocationId,componentSourceId:c.componentSourceId,triggerCallsiteId:c.triggerCallsiteId},transport:"fetch",method:Q(t,r),url:U(b,n.location?.href??"http://spotpatch.invalid/"),outcome:"dispatched",freshness:"current",diagnosticIds:Object.freeze([])}))}),l}let H=x===void 0?void 0:S(n,"fetch",W),u=(()=>{try{return n.XMLHttpRequest?.prototype}catch{return}})(),k=u===void 0?void 0:w(u,"open"),C=u===void 0?void 0:w(u,"send");function N(t,r,...l){let i=k?.value;typeof i=="function"&&Reflect.apply(i,this,[t,r,...l]),O(()=>{p.set(this,Object.freeze({method:t,url:String(r)}))})}function B(t){let r=C?.value;typeof r=="function"&&Reflect.apply(r,this,[t]),O(()=>{let l=p.get(this);if(l===void 0||$(l.url,n.location?.href??"http://spotpatch.invalid/")||o.shouldObserveXhr?.(l.url,n.location?.href??"http://spotpatch.invalid/")===!1)return;let i=g,c=i?.invocationToken;d.add(Object.freeze({schemaVersion:1,id:y(),pageEpoch:h,routeEpoch:m,...i===void 0?{}:{requestCallsiteId:i.requestCallsiteId,sourceVersion:i.sourceVersion},...c===void 0?{}:{invocationId:c.invocationId,componentSourceId:c.componentSourceId,triggerCallsiteId:c.triggerCallsiteId},transport:"xhr",method:l.method.toUpperCase(),url:U(l.url,n.location?.href??"http://spotpatch.invalid/"),outcome:"dispatched",freshness:"current",diagnosticIds:Object.freeze([])}))})}let G=u===void 0||typeof k?.value!="function"?void 0:S(u,"open",N,k),X=u===void 0||typeof C?.value!="function"?void 0:S(u,"send",B,C),I=Object.freeze({beginInvocation(t){return Object.freeze({invocationId:f(),componentSourceId:t.componentSourceId,triggerCallsiteId:t.triggerCallsiteId,sourceVersion:t.sourceVersion})},bindInvocation(t,r){return function(...i){return I.withInvocation(t,()=>Reflect.apply(r,this,i))}},bindTrigger(t,r){if(typeof r!="function")return r;let l=r;return function(...c){let b=I.beginInvocation(t);return I.withInvocation(b,()=>Reflect.apply(l,this,c))}},captureInvocation:()=>D,clear:d.clear,createTrpcLink(){return()=>t=>(O(()=>{let r=t.op.path,l=t.op.type;if(typeof r!="string"||r.length===0||r.length>512||l!=="query"&&l!=="mutation"&&l!=="subscription")return;let i=g,c=i?.invocationToken;d.add(Object.freeze({schemaVersion:1,id:y(),pageEpoch:h,routeEpoch:m,...i===void 0?{}:{requestCallsiteId:i.requestCallsiteId,sourceVersion:i.sourceVersion},...c===void 0?{}:{invocationId:c.invocationId,componentSourceId:c.componentSourceId,triggerCallsiteId:c.triggerCallsiteId},transport:"trpc",method:l.toUpperCase(),operation:r,url:Object.freeze({pathname:r,queryKeys:Object.freeze([])}),outcome:"dispatched",freshness:"current",diagnosticIds:Object.freeze([])}))}),t.next(t.op))},dispose(){L||(L=!0,d.clear(),H?.(),G?.(),X?.())},getComponentRegistration:t=>a.get(t),getCurrentRequestFrame:()=>g,observations:()=>Object.freeze(d.values().map(t=>t.routeEpoch===m?t:Object.freeze({...t,freshness:"stale-route"}))),registerComponent(t,r,l){let i=Object.freeze({componentSourceId:r,sourceVersion:l}),c=[t],b=new Set;for(;c.length>0;){let R=c.pop();if(R===void 0||b.has(R))continue;b.add(R),a.set(R,i);let P=te(R);P!==void 0&&c.push(P)}},updateRoute(t){F===void 0?F=t:F!==t&&(F=t,m=q())},withInvocation(t,r){let l=D;D=t;try{return r()}finally{D=l}},withRequestFrame(t,r,l){let i=g;g=Object.freeze({requestCallsiteId:r.requestCallsiteId,sourceVersion:r.sourceVersion,...t===void 0?{}:{invocationToken:t}});try{return l()}finally{g=i}}});return I}function M(e,n=globalThis,o={}){if(!e.enabled)return;let a=n[E]??z(e,n,o);return n[E]=a,a}var V=M(__SPOTPATCH_DATA_FLOW_CONFIG__);if(V===void 0)throw new Error("SpotPatch data-flow prelude was loaded while disabled.");var be=V;export{be as dataFlowRuntime};