@spotpatch/vite 1.15.5 → 1.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +5 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/runtime-client.js +568 -456
- package/dist/runtime-contextual-ask-panel.js +63 -50
- package/dist/runtime-data-flow-panel.js +23 -22
- package/dist/runtime-external-handoff-panel.js +51 -47
- package/dist/runtime-motion.js +86 -186
- package/package.json +5 -5
|
@@ -1,65 +1,78 @@
|
|
|
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}),Ee=Object.freeze(["configured-key","managed-codex"]),Ke=Object.freeze(["ready","degraded","unavailable"]),ke=Object.freeze(["queued","authorizing","running","cancelling","answered","cancelled","failed"]),Me=Object.freeze(["insufficient-evidence","partial-context","source-truncated","source-stale"]),Tt=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 I="/__spotpatch/v1",Ce="X-SpotPatch-Token",fe=Object.freeze({bootstrap:`${I}/bootstrap`,sourceContext:`${I}/source-context`,openEditor:`${I}/open-editor`,dataFlowComponentReport:`${I}/data-flow/component-report`,dataFlowPageReport:`${I}/data-flow/page-report`,agentCapability:`${I}/agent/capability`,agentWorkspaceHealth:`${I}/agent/workspace-health`,agentJobs:`${I}/agent/jobs`,askCapability:`${I}/ask/capability`,askJobs:`${I}/ask/jobs`,externalHandoffCapability:`${I}/external-handoff/capability`,externalHandoffPublish:`${I}/external-handoff/publish`,externalHandoffStatus:`${I}/external-handoff/status`,externalHandoffResolveDelivery:`${I}/external-handoff/resolve-delivery`,externalAgentControlStatus:`${I}/external-agent/control/status`,externalAgentControlConnect:`${I}/external-agent/control/connect`,externalAgentControlDisconnect:`${I}/external-agent/control/disconnect`,externalAgentControlCancel:`${I}/external-agent/control/cancel`,externalAgentEvents:`${I}/external-agent/events`,externalAgentResult:`${I}/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 _t={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"},It=Object.freeze({INVALID_REQUEST:"INVALID_REQUEST",INVALID_TOKEN:"INVALID_TOKEN",ORIGIN_NOT_ALLOWED:"ORIGIN_NOT_ALLOWED",..._t,INTERNAL_ERROR:"INTERNAL_ERROR"}),vt=Object.values(It);function Se(e){return typeof e=="string"&&vt.includes(e)}function D(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function _(e,t,n=[]){let s=Object.keys(e),f=new Set([...t,...n]);return t.every(r=>r in e)&&s.every(r=>f.has(r))}function H(e,t){return typeof e=="string"&&t.includes(e)}function O(e){return typeof e=="string"&&e.trim().length>0}function q(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=>q(t))}function Te(e){return new Set(e).size===e.length}function Rt(e){return!D(e)||!_(e,["executorId","kind","label","requestedModelLabel","effectiveModelLabel","state","providerDataConsentRequired","readOnlyProven"],["errorCode","models"])||!q(e.executorId)||!H(e.kind,Ee)||!O(e.label)||!O(e.requestedModelLabel)||!O(e.effectiveModelLabel)||e.models!==void 0&&(!Array.isArray(e.models)||e.models.length===0||e.models.length>ye.maximumModels||!e.models.every(t=>O(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)||!_(e,["schemaVersion","enabled","executors","safety","checkedAt"])||e.schemaVersion!==1||typeof e.enabled!="boolean"||!Array.isArray(e.executors)||!e.executors.every(Rt)||!D(e.safety)||!_(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)&&_(e,["executorId","kind","label","modelLabel"])&&q(e.executorId)&&H(e.kind,Ee)&&O(e.label)&&O(e.modelLabel)}function he(e){if(!D(e)||!_(e,["schemaVersion","jobId","selectionId","status","executor","createdAt","updatedAt","canCancel"],["phaseMessage","errorCode"])||e.schemaVersion!==1||!q(e.jobId)||!q(e.selectionId)||!H(e.status,ke)||!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&&!O(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)||!_(e,["sourceId","label","relativePath","fileId","startLine","endLine","confidence","targetIds","contentHash"],["sourceVersion"])||!q(e.sourceId)||!O(e.label)||!O(e.relativePath)||e.relativePath.startsWith("/")||e.relativePath.includes("\\")||e.relativePath.split("/").some(t=>t===""||t==="."||t==="..")||!q(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&&!O(e.sourceVersion)||typeof e.contentHash!="string"||!/^[a-f0-9]{64}$/u.test(e.contentHash))}function ot(e){return D(e)&&_(e,["code"])&&H(e.code,Me)}function rt(e){return!D(e)||typeof e.kind!="string"?!1:e.kind==="paragraph"?_(e,["kind","text","sourceIds"])&&O(e.text)&&we(e.sourceIds):e.kind==="code"?_(e,["kind","code","sourceIds"],["language"])&&typeof e.code=="string"&&e.code.length>0&&we(e.sourceIds)&&(e.language===void 0||O(e.language)):e.kind!=="list"||!_(e,["kind","items"])?!1:Array.isArray(e.items)&&e.items.length>0&&e.items.every(t=>D(t)&&_(t,["text","sourceIds"])&&O(t.text)&&we(t.sourceIds))}function Lt(e){if(!D(e)||!_(e,["schemaVersion","jobId","selectionId","contextHash","executor","blocks","sources","warnings","createdAt","expiresAt"])||e.schemaVersion!==1||!q(e.jobId)||!q(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),f=t.map(d=>d.sourceId);if(!Te(f))return!1;let r=new Set(f),a=n.flatMap(d=>d.kind==="list"?d.items.flatMap(m=>m.sourceIds):d.sourceIds);return a.every(d=>r.has(d))&&f.every(d=>a.includes(d))&&(a.length>0||s.some(d=>d.code==="insufficient-evidence"))}function it(e){return!D(e)||!_(e,["snapshot"],["result"])||!he(e.snapshot)||e.result!==void 0&&!Lt(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)||!_(e,["schemaVersion","sequence","jobId","status","timestamp","type"],["snapshot","message","activity","state","errorCode"])||e.schemaVersion!==1||!Je(e.sequence)||!q(e.jobId)||!H(e.status,ke)||!ae(e.timestamp)?!1:e.type==="snapshot"?_(e,["schemaVersion","sequence","jobId","status","timestamp","type","snapshot"])&&he(e.snapshot)&&e.snapshot.jobId===e.jobId&&e.snapshot.status===e.status:e.type==="phase"?_(e,["schemaVersion","sequence","jobId","status","timestamp","type","message"])&&O(e.message)&&!["answered","cancelled","failed"].includes(e.status):e.type==="answer-ready"?_(e,["schemaVersion","sequence","jobId","status","timestamp","type"])&&e.status==="answered":e.type==="error"?_(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"||!_(e,["schemaVersion","sequence","jobId","status","timestamp","type","activity","state"])||e.status!=="running"||!D(e.activity)||!H(e.state,Ue)?!1:e.activity.kind==="source"?_(e.activity,["kind","sourceId","relativePath"])&&q(e.activity.sourceId)&&O(e.activity.relativePath):e.activity.kind==="file-count"&&_(e.activity,["kind","bucket"])&&H(e.activity.bucket,Be)}var Ot=2e6,dt=1e5,Nt=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 Pt(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(),f=new TextDecoder("utf-8",{fatal:!0}),r=0,a="";try{for(;;){let d=await s.read();if(d.done)return a+f.decode();if(r+=d.value.byteLength,r>t)throw await s.cancel(),new S;a+=f.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 Pt(e,Ot));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 m=new AbortController;t.add(m);try{let R=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:m.signal});return await lt(R)}finally{t.delete(m)}}async function f(r,a,d){let m=new AbortController;t.add(m);try{let R=await e.fetch(ge(r,"events",{afterSequence:a}),{method:"GET",headers:{[Ce]:e.sessionToken},signal:m.signal});if(!R.ok){await lt(R);return}if(R.body===null)throw new S;let k=R.body.getReader(),x=new TextDecoder("utf-8",{fatal:!0}),P="",N=0,l=a,T=h=>{if(h.trim().length===0)return;if(new TextEncoder().encode(h).byteLength>dt)throw new S;let b=ut(h);if(!ct(b)||b.jobId!==r||b.sequence<=l)throw new S;l=b.sequence,d(be(b))};try{for(;;){let h=await k.read();if(h.done){T(P+x.decode());return}if(N+=h.value.byteLength,N>Nt)throw await k.cancel(),new S;P+=x.decode(h.value,{stream:!0});let b=P.split(`
|
|
2
|
-
`);if(
|
|
1
|
+
var _e=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}),Ie=Object.freeze(["configured-key","managed-codex","claude-code"]),Je=Object.freeze(["ready","degraded","unavailable"]),Le=Object.freeze(["queued","authorizing","running","cancelling","answered","cancelled","failed"]),qe=Object.freeze(["insufficient-evidence","partial-context","source-truncated","source-stale"]),Pt=Object.freeze(["insufficient-evidence","partial-context"]),$e=Object.freeze(["started","succeeded","failed"]),ze=Object.freeze(["one","few","many"]),We=Object.freeze(["exact","probable","approximate"]);var _="/__spotpatch/v1",Re="X-SpotPatch-Token",me=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 ye(e,t,n={}){let r=`${me.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 r;if(!Number.isSafeInteger(n.afterSequence)||n.afterSequence<0)throw new RangeError("afterSequence must be a non-negative safe integer.");return`${r}?afterSequence=${String(n.afterSequence)}`}var Dt={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"},Kt=Object.freeze({INVALID_REQUEST:"INVALID_REQUEST",INVALID_TOKEN:"INVALID_TOKEN",ORIGIN_NOT_ALLOWED:"ORIGIN_NOT_ALLOWED",...Dt,INTERNAL_ERROR:"INTERNAL_ERROR"}),Mt=Object.values(Kt);function Oe(e){return typeof e=="string"&&Mt.includes(e)}function M(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function C(e,t,n=[]){let r=Object.keys(e),p=new Set([...t,...n]);return t.every(s=>s in e)&&r.every(s=>p.has(s))}function Q(e,t){return typeof e=="string"&&t.includes(e)}function K(e){return typeof e=="string"&&e.trim().length>0}function z(e){return typeof e=="string"&&e.length>0&&e.length<=128&&/^[A-Za-z0-9_-]+$/u.test(e)}function le(e){return typeof e=="string"&&Number.isFinite(Date.parse(e))}function Ve(e){return Number.isSafeInteger(e)&&Number(e)>0}function He(e){return Oe(e)&&e.startsWith("ASK_")}function Ne(e){return Array.isArray(e)&&e.every(t=>z(t))}function Pe(e){return new Set(e).size===e.length}function Ut(e){return!M(e)||!C(e,["executorId","kind","label","requestedModelLabel","effectiveModelLabel","state","providerDataConsentRequired","readOnlyProven"],["errorCode","models"])||!z(e.executorId)||!Q(e.kind,Ie)||!K(e.label)||!K(e.requestedModelLabel)||!K(e.effectiveModelLabel)||e.models!==void 0&&(!Array.isArray(e.models)||e.models.length===0||e.models.length>_e.maximumModels||!e.models.every(t=>K(t)&&t.length<=_e.maximumLabelCharacters)||!Pe(e.models))||!Q(e.state,Je)||typeof e.providerDataConsentRequired!="boolean"||typeof e.readOnlyProven!="boolean"||e.errorCode!==void 0&&!He(e.errorCode)?!1:e.state==="ready"?e.readOnlyProven&&e.errorCode===void 0:e.errorCode!==void 0}function ut(e){if(!M(e)||!C(e,["schemaVersion","enabled","executors","safety","checkedAt"])||e.schemaVersion!==1||typeof e.enabled!="boolean"||!Array.isArray(e.executors)||!e.executors.every(Ut)||!M(e.safety)||!C(e.safety,["selectionRequired","singleTurn","writesAllowed","historyStored"])||e.safety.selectionRequired!==!0||e.safety.singleTurn!==!0||e.safety.writesAllowed!==!1||e.safety.historyStored!==!1||!le(e.checkedAt))return!1;let t=e.executors.map(n=>n.executorId);return(e.enabled||e.executors.length===0)&&Pe(t)}function ht(e){return M(e)&&C(e,["executorId","kind","label","modelLabel"])&&z(e.executorId)&&Q(e.kind,Ie)&&K(e.label)&&K(e.modelLabel)}function Ee(e){if(!M(e)||!C(e,["schemaVersion","jobId","selectionId","status","executor","createdAt","updatedAt","canCancel"],["phaseMessage","errorCode"])||e.schemaVersion!==1||!z(e.jobId)||!z(e.selectionId)||!Q(e.status,Le)||!ht(e.executor)||!le(e.createdAt)||!le(e.updatedAt)||Date.parse(e.updatedAt)<Date.parse(e.createdAt)||typeof e.canCancel!="boolean"||e.phaseMessage!==void 0&&!K(e.phaseMessage)||e.errorCode!==void 0&&!He(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 dt(e){return!(!M(e)||!C(e,["sourceId","label","relativePath","fileId","startLine","endLine","confidence","targetIds","contentHash"],["sourceVersion"])||!z(e.sourceId)||!K(e.label)||!K(e.relativePath)||e.relativePath.startsWith("/")||e.relativePath.includes("\\")||e.relativePath.split("/").some(t=>t===""||t==="."||t==="..")||!z(e.fileId)||!Ve(e.startLine)||!Ve(e.endLine)||e.endLine<e.startLine||!Q(e.confidence,We)||!Ne(e.targetIds)||e.targetIds.length===0||!Pe(e.targetIds)||e.sourceVersion!==void 0&&!K(e.sourceVersion)||typeof e.contentHash!="string"||!/^[a-f0-9]{64}$/u.test(e.contentHash))}function lt(e){return M(e)&&C(e,["code"])&&Q(e.code,qe)}function pt(e){return!M(e)||typeof e.kind!="string"?!1:e.kind==="paragraph"?C(e,["kind","text","sourceIds"])&&K(e.text)&&Ne(e.sourceIds):e.kind==="code"?C(e,["kind","code","sourceIds"],["language"])&&typeof e.code=="string"&&e.code.length>0&&Ne(e.sourceIds)&&(e.language===void 0||K(e.language)):e.kind!=="list"||!C(e,["kind","items"])?!1:Array.isArray(e.items)&&e.items.length>0&&e.items.every(t=>M(t)&&C(t,["text","sourceIds"])&&K(t.text)&&Ne(t.sourceIds))}function Bt(e){if(!M(e)||!C(e,["schemaVersion","jobId","selectionId","contextHash","executor","blocks","sources","warnings","createdAt","expiresAt"])||e.schemaVersion!==1||!z(e.jobId)||!z(e.selectionId)||typeof e.contextHash!="string"||!/^[a-f0-9]{64}$/u.test(e.contextHash)||!ht(e.executor)||!Array.isArray(e.blocks)||e.blocks.length===0||!e.blocks.every(pt)||!Array.isArray(e.sources)||!e.sources.every(dt)||!Array.isArray(e.warnings)||!e.warnings.every(lt)||!le(e.createdAt)||!le(e.expiresAt)||Date.parse(e.expiresAt)<=Date.parse(e.createdAt))return!1;let t=e.sources.filter(dt),n=e.blocks.filter(pt),r=e.warnings.filter(lt),p=t.map(a=>a.sourceId);if(!Pe(p))return!1;let s=new Set(p),l=n.flatMap(a=>a.kind==="list"?a.items.flatMap(f=>f.sourceIds):a.sourceIds);return l.every(a=>s.has(a))&&p.every(a=>l.includes(a))&&(l.length>0||r.some(a=>a.code==="insufficient-evidence"))}function ft(e){return!M(e)||!C(e,["snapshot"],["result"])||!Ee(e.snapshot)||e.result!==void 0&&!Bt(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 gt(e){return!M(e)||!C(e,["schemaVersion","sequence","jobId","status","timestamp","type"],["snapshot","message","activity","state","errorCode"])||e.schemaVersion!==1||!Ve(e.sequence)||!z(e.jobId)||!Q(e.status,Le)||!le(e.timestamp)?!1:e.type==="snapshot"?C(e,["schemaVersion","sequence","jobId","status","timestamp","type","snapshot"])&&Ee(e.snapshot)&&e.snapshot.jobId===e.jobId&&e.snapshot.status===e.status:e.type==="phase"?C(e,["schemaVersion","sequence","jobId","status","timestamp","type","message"])&&K(e.message)&&!["answered","cancelled","failed"].includes(e.status):e.type==="answer-ready"?C(e,["schemaVersion","sequence","jobId","status","timestamp","type"])&&e.status==="answered":e.type==="error"?C(e,["schemaVersion","sequence","jobId","status","timestamp","type","errorCode"])&&He(e.errorCode)&&(e.status==="cancelled"&&e.errorCode==="ASK_CANCELLED"||e.status==="failed"&&e.errorCode!=="ASK_CANCELLED"):e.type!=="read-activity"||!C(e,["schemaVersion","sequence","jobId","status","timestamp","type","activity","state"])||e.status!=="running"||!M(e.activity)||!Q(e.state,$e)?!1:e.activity.kind==="source"?C(e.activity,["kind","sourceId","relativePath"])&&z(e.activity.sourceId)&&K(e.activity.relativePath):e.activity.kind==="file-count"&&C(e.activity,["kind","bucket"])&&Q(e.activity.bucket,ze)}var jt=2e6,bt=1e5,Jt=4e6,k=class extends Error{constructor(n){super("SpotPatch Contextual Ask request failed.");this.code=n;this.name="ContextualAskApiError"}code};function Xe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function At(e){if(!(!Xe(e)&&!Array.isArray(e)||Object.isFrozen(e))){for(let t of Object.values(e))At(t);Object.freeze(e)}}function ke(e){return At(e),e}function mt(e){try{return JSON.parse(e)}catch{throw new k}}async function qt(e,t){let n=Number(e.headers.get("content-length"));if(Number.isFinite(n)&&n>t)throw await e.body?.cancel(),new k;if(e.body===null)throw new k;let r=e.body.getReader(),p=new TextDecoder("utf-8",{fatal:!0}),s=0,l="";try{for(;;){let a=await r.read();if(a.done)return l+p.decode();if(s+=a.value.byteLength,s>t)throw await r.cancel(),new k;l+=p.decode(a.value,{stream:!0})}}catch(a){throw a instanceof k||a instanceof DOMException&&a.name==="AbortError"?a:new k}finally{r.releaseLock()}}async function xt(e){let t=mt(await qt(e,jt));if(!Xe(t))throw new k;if(!e.ok){let n=t.ok===!1&&Xe(t.error)&&Oe(t.error.code)?t.error.code:void 0;throw new k(n)}if(t.ok!==!0||!("data"in t))throw new k;return t.data}function De(e){return e instanceof k?e.code:void 0}function yt(e){let t=new Set,n=new Set;function r(){for(let a of t)a.abort();t.clear()}function p(){r();for(let a of n)a.abort();n.clear()}async function s(a,f,P,S=t){let g=new AbortController;S.add(g);try{let w=await e.fetch(a,{method:f,headers:{...P===void 0?{}:{"Content-Type":"application/json"},[Re]:e.sessionToken},...P===void 0?{}:{body:JSON.stringify(P)},signal:g.signal});return await xt(w)}finally{S.delete(g)}}async function l(a,f,P){let S=new AbortController;t.add(S);try{let g=await e.fetch(ye(a,"events",{afterSequence:f}),{method:"GET",headers:{[Re]:e.sessionToken},signal:S.signal});if(!g.ok){await xt(g);return}if(g.body===null)throw new k;let w=g.body.getReader(),j=new TextDecoder("utf-8",{fatal:!0}),d="",v=0,T=f,x=u=>{if(u.trim().length===0)return;if(new TextEncoder().encode(u).byteLength>bt)throw new k;let I=mt(u);if(!gt(I)||I.jobId!==a||I.sequence<=T)throw new k;T=I.sequence,P(ke(I))};try{for(;;){let u=await w.read();if(u.done){x(d+j.decode());return}if(v+=u.value.byteLength,v>Jt)throw await w.cancel(),new k;d+=j.decode(u.value,{stream:!0});let I=d.split(`
|
|
2
|
+
`);if(d=I.pop()??"",new TextEncoder().encode(d).byteLength>bt)throw await w.cancel(),new k;for(let W of I)x(W)}}catch(u){throw u instanceof k||u instanceof DOMException&&u.name==="AbortError"?u:new k}finally{w.releaseLock()}}finally{t.delete(S)}}return Object.freeze({async capability(){let a=await s(me.askCapability,"GET",void 0,n);if(!ut(a))throw new k;return ke(a)},async cancelJob(a){let f=await s(ye(a,"cancel"),"POST",{});if(!Ee(f)||f.jobId!==a)throw new k;return ke(f)},cancelPending:r,async createJob(a){let f=await s(me.askJobs,"POST",a);if(!Ee(f)||f.selectionId!==a.envelope.selection.selectionId||f.executor.executorId!==a.executorId)throw new k;return ke(f)},dispose:p,events:l,async result(a){let f=await s(ye(a,"result"),"GET");if(!ft(f)||f.snapshot.jobId!==a)throw new k;return ke(f)}})}function Fe(e){return e instanceof DOMException&&e.name==="AbortError"}function Et(e){let t=!1,n=0,r=!1,p,s,l="",a=!1,f=!1,P=!1,S=new Map,g=e.api??yt({fetch:e.fetch,sessionToken:e.sessionToken});function w(i){return t&&n===i}function j(i){let A=e.getSelection();if(i.length===0||i.length>4e3||A===void 0)return;let R=new Date().toISOString();return{schemaVersion:1,taskId:e.createId(),selection:{schemaVersion:1,selectionId:e.createId(),locale:A.locale,targets:A.targets.map(E=>({targetId:E.id,page:E.page,source:E.source,react:{...E.react,componentStack:[...E.react.componentStack]},element:E.element,styles:{...E.styles,classNames:[...E.styles.classNames],matchedRules:E.styles.matchedRules.map(G=>({...G})),computed:{...E.styles.computed},warnings:[...E.styles.warnings]},...E.code===void 0?{}:{code:E.code},warnings:[]})),createdAt:R},task:{kind:"ask",question:i},createdAt:R}}function d(){a||f||(f=!0,e.panel.renderCapability(void 0),g.capability().then(i=>{if(!t)return;a=!0,e.panel.renderCapability(i);let A=e.panel.readExecutorId();e.panel.setConsent(A!==void 0&&S.get(A)===!0)}).catch(i=>{!t||Fe(i)||e.panel.renderError(De(i))}).finally(()=>{f=!1}))}function v(i,A){w(A)&&(e.panel.renderEvent(i),i.type==="snapshot"&&(p=i.snapshot))}async function T(){if(r)return;let i=e.panel.readQuestion(),A=e.panel.readExecutorId(),R=j(i);if(i.length===0||A===void 0||!e.panel.readConsent()||R===void 0)return;let E=++n,G=e.panel.readModel();l=i,r=!0,e.onBusyChange(!0),s=void 0,p=void 0,e.panel.setBusy(!0);try{let q=await g.createJob({schemaVersion:1,requestId:e.createId(),envelope:R,executorId:A,...G===void 0?{}:{model:G},providerDataConsent:!0});if(!w(E)||(p=q,e.panel.renderJob(q),await g.events(q.jobId,0,he=>{v(he,E)}),!w(E)))return;let V=await g.result(q.jobId);if(!w(E))return;if(p=V.snapshot,r=!1,e.onBusyChange(!1),V.result===void 0){e.panel.renderJob(V.snapshot),V.snapshot.status==="failed"&&e.panel.renderError(V.snapshot.errorCode);return}s=V.result,e.panel.renderAnswer(V.result,!1)}catch(q){if(!w(E)||Fe(q))return;r=!1,e.onBusyChange(!1),e.panel.renderError(De(q))}finally{w(E)&&(r=!1,e.panel.setBusy(!1))}}async function x(){if(!r||p?.canCancel!==!0)return;let i=n;try{let A=await g.cancelJob(p.jobId);if(!w(i))return;p=A,r=!1,e.onBusyChange(!1),e.panel.renderJob(A),e.panel.setBusy(!1)}catch(A){if(!w(i)||Fe(A))return;r=!1,e.onBusyChange(!1),e.panel.renderError(De(A))}}function u(){n+=1;let i=p;r=!1,e.onBusyChange(!1),p=void 0,g.cancelPending(),i?.canCancel===!0&&g.cancelJob(i.jobId).catch(()=>{}),e.panel.setBusy(!1)}function I(){r&&u(),n+=1,p=void 0,s=void 0,l="",e.panel.clear(),e.panel.focusQuestion()}function W(){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 oe(){if(s===void 0||r)return;let i=e.panel.answerPlainText().trim().slice(0,4e3);if(i.length===0)return;let A=Object.freeze({kind:"contextual-ask",askJobId:s.jobId,question:l,answerDigest:i,sourceIds:s.sources.map(R=>R.sourceId)});e.onConvert(A),e.panel.setOrigin(A),e.panel.setMode("change"),e.panel.notify("converted")}function re(i){let A=e.panel.selectedSourceId(i.target);if(A===void 0)return;let R=e.panel.sourceById(A);R!==void 0&&e.onOpenSource(R).catch(()=>{e.panel.notify("source-open-failed")})}function pe(i){i.target!==e.panel.questionInput||i.key!=="Enter"||P||i.isComposing||!i.metaKey&&!i.ctrlKey||(i.preventDefault(),T())}function L(){let i=e.panel.readExecutorId();e.panel.setConsent(i!==void 0&&S.get(i)===!0)}function H(){P=!0}function se(){P=!1}function ae(){let i=e.panel.readExecutorId();i!==void 0&&S.set(i,e.panel.readConsent())}function J(){T()}function D(){x()}function ie(){t||(t=!0,e.panel.submitButton.addEventListener("click",J),e.panel.cancelButton.addEventListener("click",D),e.panel.newQuestionButton.addEventListener("click",I),e.panel.copyButton.addEventListener("click",W),e.panel.convertButton.addEventListener("click",oe),e.panel.executorSelect.addEventListener("change",L),e.panel.consentCheckbox.addEventListener("change",ae),e.panel.questionInput.addEventListener("keydown",pe),e.panel.questionInput.addEventListener("compositionstart",H),e.panel.questionInput.addEventListener("compositionend",se),e.panel.root.addEventListener("click",re),d())}function ue(){t&&(u(),t=!1,e.panel.submitButton.removeEventListener("click",J),e.panel.cancelButton.removeEventListener("click",D),e.panel.newQuestionButton.removeEventListener("click",I),e.panel.copyButton.removeEventListener("click",W),e.panel.convertButton.removeEventListener("click",oe),e.panel.executorSelect.removeEventListener("change",L),e.panel.consentCheckbox.removeEventListener("change",ae),e.panel.questionInput.removeEventListener("keydown",pe),e.panel.questionInput.removeEventListener("compositionstart",H),e.panel.questionInput.removeEventListener("compositionend",se),e.panel.root.removeEventListener("click",re),g.dispose())}return Object.freeze({beginSelection(){n+=1,r=!1,e.onBusyChange(!1),p=void 0,s=void 0,l="",e.panel.clear(),d()},cancelPending:u,dispose:ue,isBusy:()=>r,mount:ie,selectionChanged(){s!==void 0&&e.panel.renderAnswer(s,!0)}})}var $t=Symbol.for("spotpatch.contextual-ask.v1");function kt(e){globalThis[$t]=e}var Ct="data-spotpatch-ui",ln=Object.freeze({highlight:2147483646,controls:2147483647}),pn=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(Ct,""),n}function U(e,t,n=""){let r=c(e,"button");return r.type="button",r.className=n,r.textContent=t,r}var St=`
|
|
3
3
|
.spotpatch-select-picker { position: relative; display: grid; gap: 5px; min-width: 0; }
|
|
4
|
-
.spotpatch-select-trigger { 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:
|
|
4
|
+
.spotpatch-select-trigger { 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: var(--spotpatch-radius-md); padding: 0 12px; overflow: hidden; color: var(--spotpatch-text); background: var(--spotpatch-bg-input); cursor: pointer; font: inherit; outline: none; text-align: left; transition: border-color var(--spotpatch-duration-fast) ease, box-shadow var(--spotpatch-duration-fast) ease; }
|
|
5
|
+
.spotpatch-select-trigger:hover:not(:disabled) { border-color: var(--spotpatch-border-strong); }
|
|
5
6
|
.spotpatch-select-trigger > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
6
|
-
.spotpatch-select-trigger[data-expandable="true"]::after { width: 7px; height: 7px; flex: 0 0 auto; border-right: 1.5px solid
|
|
7
|
+
.spotpatch-select-trigger[data-expandable="true"]::after { width: 7px; height: 7px; flex: 0 0 auto; border-right: 1.5px solid var(--spotpatch-text-muted); border-bottom: 1.5px solid var(--spotpatch-text-muted); content: ""; transform: translateY(-2px) rotate(45deg); transition: transform var(--spotpatch-duration-base) var(--spotpatch-ease-out); }
|
|
7
8
|
.spotpatch-select-trigger[aria-expanded="true"]::after { transform: translateY(2px) rotate(225deg); }
|
|
8
|
-
.spotpatch-select-trigger:focus-visible { border-color:
|
|
9
|
-
.spotpatch-select-trigger:disabled { color: var(--spotpatch-text); background:
|
|
9
|
+
.spotpatch-select-trigger:focus-visible { border-color: var(--spotpatch-accent-line); box-shadow: 0 0 0 3px var(--spotpatch-accent-tint); }
|
|
10
|
+
.spotpatch-select-trigger:disabled { color: var(--spotpatch-text); background: var(--spotpatch-hover); cursor: default; opacity: 1; }
|
|
10
11
|
.spotpatch-select-trigger[data-empty="true"]:disabled { color: var(--spotpatch-text-muted); }
|
|
11
|
-
.spotpatch-select-menu { position: relative; z-index: 1; display: grid; gap:
|
|
12
|
-
.spotpatch-select-
|
|
13
|
-
.spotpatch-select-option
|
|
14
|
-
.spotpatch-select-option[
|
|
15
|
-
.spotpatch-select-option[aria-selected="true"] { color: #f4f1ff; background: rgb(139 123 255 / 20%); }
|
|
12
|
+
.spotpatch-select-menu { position: relative; z-index: 1; display: grid; gap: 2px; max-height: 224px; overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--spotpatch-border); border-radius: var(--spotpatch-radius-md); padding: 4px; background: var(--spotpatch-bg-raised); box-shadow: var(--spotpatch-shadow-panel); animation: spotpatch-enter var(--spotpatch-duration-base) var(--spotpatch-ease-out) both; }
|
|
13
|
+
.spotpatch-select-option { box-sizing: border-box; min-height: 34px; border: 0; border-radius: var(--spotpatch-radius-xs); padding: 7px 10px; overflow-wrap: anywhere; color: var(--spotpatch-text-secondary); background: transparent; cursor: pointer; font: inherit; text-align: left; }
|
|
14
|
+
.spotpatch-select-option[data-active="true"], .spotpatch-select-option:hover { color: var(--spotpatch-text); background: var(--spotpatch-hover); outline: none; }
|
|
15
|
+
.spotpatch-select-option[aria-selected="true"] { color: var(--spotpatch-text); background: var(--spotpatch-accent-tint); }
|
|
16
16
|
.spotpatch-select-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; }
|
|
17
|
-
`;function
|
|
18
|
-
${
|
|
19
|
-
.spotpatch-ask-mode { display: grid; grid-template-columns: 1fr 1fr; gap:
|
|
20
|
-
.spotpatch-ask-mode
|
|
21
|
-
.spotpatch-ask-mode
|
|
17
|
+
`;function Qe(e,t){let n=c(e,"div");n.className="spotpatch-select-picker";let r=U(e,"","spotpatch-select-trigger");r.id=`spotpatch-select-picker-${Math.random().toString(36).slice(2)}`,r.setAttribute("role","combobox"),r.setAttribute("aria-haspopup","listbox"),r.setAttribute("aria-expanded","false");let p=c(e,"span");r.append(p);let s=c(e,"div");s.id=`${r.id}-menu`,s.className="spotpatch-select-menu",s.setAttribute("role","listbox"),s.hidden=!0,r.setAttribute("aria-controls",s.id);let l=c(e,"select");l.className="spotpatch-select-native",l.tabIndex=-1,l.setAttribute("aria-hidden","true"),n.append(r,s,l);function a(d=!1){s.hidden||(s.hidden=!0,r.setAttribute("aria-expanded","false"),r.removeAttribute("aria-activedescendant"),d&&r.focus({preventScroll:!0}),t())}function f(d){let v=[...s.children],T=v[d];if(T===void 0)return;for(let I of v)I.dataset.active=String(I===T);r.setAttribute("aria-activedescendant",T.id);let x=T.getBoundingClientRect(),u=s.getBoundingClientRect();x.top<u.top?s.scrollTop-=u.top-x.top:x.bottom>u.bottom&&(s.scrollTop+=x.bottom-u.bottom)}function P(){r.disabled||!s.hidden||(s.hidden=!1,r.setAttribute("aria-expanded","true"),f(Math.max(0,l.selectedIndex)),t())}function S(){p.textContent=l.selectedOptions[0]?.textContent??"",r.title=p.textContent,r.dataset.empty=String(l.value.length===0);for(let d of[...s.children])d.setAttribute("aria-selected",String(d.dataset.value===l.value))}function g(d){r.disabled||(l.value=d,S(),a(!0),l.dispatchEvent(new Event("change",{bubbles:!0})))}function w(){let d=!s.hidden,v=[...l.options];s.replaceChildren();for(let[T,x]of v.entries()){let u=c(e,"div");u.id=`${s.id}-${String(T)}`,u.className="spotpatch-select-option",u.setAttribute("role","option"),u.dataset.value=x.value,u.textContent=x.textContent,u.title=x.textContent,u.addEventListener("pointerdown",I=>{I.preventDefault()}),u.addEventListener("click",()=>{g(x.value)}),s.append(u)}S(),d&&(f(Math.max(0,l.selectedIndex)),t())}r.addEventListener("click",()=>{s.hidden?P():a()}),r.addEventListener("keydown",d=>{if(d.key==="Escape"&&!s.hidden){d.preventDefault(),d.stopPropagation(),a();return}if(d.key==="Tab"){a();return}if(["Enter"," "].includes(d.key)&&!s.hidden){d.preventDefault();let x=[...s.children].find(u=>u.id===r.getAttribute("aria-activedescendant"));x?.dataset.value!==void 0&&g(x.dataset.value);return}if(!["ArrowDown","ArrowUp","Home","End"].includes(d.key))return;if(d.preventDefault(),s.hidden){P();return}let v=[...s.children],T=v.findIndex(x=>x.id===r.getAttribute("aria-activedescendant"));f(d.key==="Home"?0:d.key==="End"?v.length-1:(T+(d.key==="ArrowDown"?1:-1)+v.length)%v.length)}),n.addEventListener("focusout",d=>{(!(d.relatedTarget instanceof Node)||!n.contains(d.relatedTarget))&&a()});let j=d=>{d.composedPath().includes(n)||a()};return e.addEventListener("pointerdown",j),l.addEventListener("change",S),{root:n,trigger:r,select:l,rebuild:w,close:a,setDisabled(d){l.disabled=d,r.disabled=d||l.options.length<2,r.dataset.expandable=String(!r.disabled),r.disabled&&a()},dispose(){e.removeEventListener("pointerdown",j)}}}var zt=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."}),Wt=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 Ge(e){return e==="zh-CN"?Wt:zt}var Vt=8;function Ht(e){let t=e.createElement("style");return t.textContent=`
|
|
18
|
+
${St}
|
|
19
|
+
.spotpatch-ask-mode { position: relative; isolation: isolate; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin-bottom: 14px; padding: 3px; border: 1px solid var(--spotpatch-border-subtle); border-radius: var(--spotpatch-radius-md); background: var(--spotpatch-bg-input); }
|
|
20
|
+
.spotpatch-ask-mode::before { position: absolute; z-index: -1; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 4.5px); border-radius: var(--spotpatch-radius-sm); background: var(--spotpatch-bg-active); box-shadow: var(--spotpatch-shadow-inset), 0 0 0 1px var(--spotpatch-border); content: ""; transition: transform var(--spotpatch-duration-slow) var(--spotpatch-ease-out); }
|
|
21
|
+
.spotpatch-ask-mode[data-mode="change"]::before { transform: translateX(calc(100% + 3px)); }
|
|
22
|
+
.spotpatch-ask-mode button { min-height: 32px; border: 0; border-radius: var(--spotpatch-radius-sm); color: var(--spotpatch-text-secondary); background: transparent; cursor: pointer; font-size: 12.5px; font-weight: 600; transition: color var(--spotpatch-duration-base) ease; }
|
|
23
|
+
.spotpatch-ask-mode button:hover, .spotpatch-ask-mode button[aria-selected="true"] { color: var(--spotpatch-text); }
|
|
22
24
|
.spotpatch-ask-panel { display: grid; gap: 14px; }
|
|
25
|
+
.spotpatch-ask-panel[data-phase="answered"] > :is(.spotpatch-ask-field, .spotpatch-ask-safety) { display: none; }
|
|
23
26
|
.spotpatch-ask-field { display: grid; gap: 7px; min-width: 0; }
|
|
24
|
-
.spotpatch-ask-field
|
|
25
|
-
.spotpatch-ask-
|
|
26
|
-
.spotpatch-ask-question {
|
|
27
|
-
.spotpatch-ask-question:focus { border-color:
|
|
27
|
+
.spotpatch-ask-field > label, .spotpatch-ask-label { color: var(--spotpatch-text-secondary); font-size: 11.5px; font-weight: 600; }
|
|
28
|
+
.spotpatch-ask-question { box-sizing: border-box; width: 100%; min-height: 92px; resize: vertical; border: 1px solid var(--spotpatch-border); border-radius: var(--spotpatch-radius-md); padding: 10px 12px; outline: none; color: var(--spotpatch-text); background: var(--spotpatch-bg-input); font-size: 13px; line-height: 1.55; transition: border-color var(--spotpatch-duration-fast) ease, box-shadow var(--spotpatch-duration-fast) ease; }
|
|
29
|
+
.spotpatch-ask-question::placeholder { color: var(--spotpatch-text-muted); }
|
|
30
|
+
.spotpatch-ask-question:focus { border-color: var(--spotpatch-accent-line); box-shadow: 0 0 0 3px var(--spotpatch-accent-tint); }
|
|
28
31
|
.spotpatch-ask-suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
29
|
-
.spotpatch-ask-suggestions button { border: 1px
|
|
30
|
-
.spotpatch-ask-suggestions button:hover {
|
|
31
|
-
.spotpatch-ask-executor-status { margin: 0; border-left: 2px solid var(--spotpatch-warning); padding-left: 8px; color:
|
|
32
|
-
.spotpatch-ask-safety { display: grid; gap: 8px; border: 1px solid
|
|
33
|
-
.spotpatch-ask-data { display: flex; justify-content: space-between; gap: 10px; color:
|
|
34
|
-
.spotpatch-ask-data strong { color:
|
|
35
|
-
.spotpatch-ask-consent { display: grid; grid-template-columns: 16px 1fr; gap: 8px; align-items: start; color: var(--spotpatch-text-secondary); cursor: pointer; font-size:
|
|
32
|
+
.spotpatch-ask-suggestions button { border: 1px dashed var(--spotpatch-accent-line); border-radius: var(--spotpatch-radius-pill); padding: 4px 10px; color: var(--spotpatch-accent-soft); background: transparent; cursor: pointer; font-size: 11.5px; transition: background var(--spotpatch-duration-fast) ease; }
|
|
33
|
+
.spotpatch-ask-suggestions button:hover { background: var(--spotpatch-accent-tint); }
|
|
34
|
+
.spotpatch-ask-executor-status { margin: 0; border-left: 2px solid var(--spotpatch-warning); padding-left: 8px; color: var(--spotpatch-warning-text); font-size: 11.5px; line-height: 1.45; }
|
|
35
|
+
.spotpatch-ask-safety { display: grid; gap: 8px; border: 1px solid var(--spotpatch-cyan-line); border-radius: var(--spotpatch-radius-md); padding: 10px 12px; background: var(--spotpatch-cyan-tint); }
|
|
36
|
+
.spotpatch-ask-data { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; color: var(--spotpatch-text-secondary); font-size: 11.5px; }
|
|
37
|
+
.spotpatch-ask-data strong { color: var(--spotpatch-success-text); font-weight: 600; white-space: nowrap; }
|
|
38
|
+
.spotpatch-ask-consent { display: grid; grid-template-columns: 16px 1fr; gap: 8px; align-items: start; color: var(--spotpatch-text-secondary); cursor: pointer; font-size: 11.5px; line-height: 1.45; }
|
|
36
39
|
.spotpatch-ask-consent input { margin: 2px 0 0; accent-color: var(--spotpatch-accent); }
|
|
37
|
-
.spotpatch-ask-actions
|
|
38
|
-
.spotpatch-ask-actions button
|
|
39
|
-
.spotpatch-ask-actions
|
|
40
|
-
.spotpatch-ask-actions
|
|
41
|
-
.spotpatch-ask-
|
|
42
|
-
.spotpatch-ask-
|
|
43
|
-
.spotpatch-ask-
|
|
44
|
-
.spotpatch-ask-
|
|
45
|
-
.spotpatch-ask-stale, .spotpatch-ask-warning {
|
|
46
|
-
.spotpatch-ask-
|
|
47
|
-
.spotpatch-ask-
|
|
48
|
-
.spotpatch-ask-
|
|
40
|
+
.spotpatch-ask-actions { position: sticky; bottom: 0; z-index: 1; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 10px 0 2px; background: var(--spotpatch-bg); box-shadow: 0 -14px 14px -6px var(--spotpatch-bg); }
|
|
41
|
+
.spotpatch-ask-actions button { min-height: 36px; border: 1px solid var(--spotpatch-border); border-radius: var(--spotpatch-radius-md); padding: 0 12px; color: var(--spotpatch-text); background: var(--spotpatch-bg-raised); cursor: pointer; font-size: 12.5px; font-weight: 600; transition: border-color var(--spotpatch-duration-fast) ease, background var(--spotpatch-duration-fast) ease; }
|
|
42
|
+
.spotpatch-ask-actions button:hover:not(:disabled) { border-color: var(--spotpatch-border-strong); background: var(--spotpatch-bg-active); }
|
|
43
|
+
.spotpatch-ask-actions .spotpatch-primary { border-color: transparent; color: var(--spotpatch-text-on-accent); background: var(--spotpatch-primary-fill); box-shadow: var(--spotpatch-shadow-accent), var(--spotpatch-shadow-inset); }
|
|
44
|
+
.spotpatch-ask-actions .spotpatch-primary:hover:not(:disabled) { border-color: transparent; background: var(--spotpatch-primary-fill); filter: brightness(1.1); }
|
|
45
|
+
.spotpatch-ask-actions button:disabled { box-shadow: none; cursor: not-allowed; opacity: .4; }
|
|
46
|
+
.spotpatch-ask-status { display: grid; gap: 7px; border-left: 2px solid var(--spotpatch-accent); padding: 2px 0 2px 10px; color: var(--spotpatch-text-secondary); font-size: 12px; animation: spotpatch-enter var(--spotpatch-duration-slow) var(--spotpatch-ease-out) both; }
|
|
47
|
+
.spotpatch-ask-activity { display: grid; gap: 4px; color: var(--spotpatch-text-muted); font: 500 11px/1.45 var(--spotpatch-font-mono); }
|
|
48
|
+
.spotpatch-ask-error, .spotpatch-ask-stale, .spotpatch-ask-warning { border-radius: var(--spotpatch-radius-sm); padding: 9px 10px; font-size: 11.5px; }
|
|
49
|
+
.spotpatch-ask-error { color: var(--spotpatch-danger-text); background: var(--spotpatch-danger-tint); }
|
|
50
|
+
.spotpatch-ask-stale, .spotpatch-ask-warning { color: var(--spotpatch-warning-text); background: var(--spotpatch-warning-tint); }
|
|
51
|
+
.spotpatch-ask-answer { display: grid; gap: 12px; border: 1px solid var(--spotpatch-border-subtle); border-radius: var(--spotpatch-radius-card); padding: 14px; background: var(--spotpatch-bg-raised); box-shadow: var(--spotpatch-shadow-inset); }
|
|
52
|
+
.spotpatch-ask-answer[data-entering="true"] { animation: spotpatch-enter var(--spotpatch-duration-slow) var(--spotpatch-ease-out) both; }
|
|
53
|
+
.spotpatch-ask-answer[data-entering="true"] [data-ask-order] { --spotpatch-ask-order: 0; animation: spotpatch-enter var(--spotpatch-duration-slow) var(--spotpatch-ease-out) both; animation-delay: calc(140ms + var(--spotpatch-ask-order) * 55ms); }
|
|
54
|
+
.spotpatch-ask-recap { display: grid; gap: 3px; border-left: 2px solid var(--spotpatch-accent-line); padding: 1px 0 1px 10px; }
|
|
55
|
+
.spotpatch-ask-recap span { color: var(--spotpatch-text-muted); font-size: 10.5px; font-weight: 600; letter-spacing: .02em; }
|
|
56
|
+
.spotpatch-ask-recap p { margin: 0; color: var(--spotpatch-text-secondary); font-size: 12.5px; line-height: 1.5; overflow-wrap: anywhere; }
|
|
57
|
+
.spotpatch-ask-answer-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; min-width: 0; }
|
|
58
|
+
.spotpatch-ask-answer-meta { overflow: hidden; color: var(--spotpatch-text-muted); font: 500 10.5px/1.3 var(--spotpatch-font-mono); text-overflow: ellipsis; white-space: nowrap; }
|
|
59
|
+
.spotpatch-ask-answer h3, .spotpatch-ask-sources h4 { margin: 0; font-size: 13px; font-weight: 620; }
|
|
60
|
+
.spotpatch-ask-blocks { display: grid; gap: 10px; font-size: 13px; line-height: 1.65; overflow-wrap: anywhere; }
|
|
49
61
|
.spotpatch-ask-blocks p, .spotpatch-ask-blocks ul { margin: 0; }
|
|
50
62
|
.spotpatch-ask-blocks ul { padding-left: 18px; }
|
|
51
|
-
.spotpatch-ask-
|
|
52
|
-
.spotpatch-ask-
|
|
53
|
-
.spotpatch-ask-
|
|
63
|
+
.spotpatch-ask-inline-code { border: 1px solid var(--spotpatch-border-subtle); border-radius: var(--spotpatch-radius-xs); padding: 1px 5px; color: var(--spotpatch-accent-soft); background: var(--spotpatch-bg-input); font: 500 .88em/1.4 var(--spotpatch-font-mono); }
|
|
64
|
+
.spotpatch-ask-blocks pre { max-width: 100%; overflow: auto; margin: 0; border: 1px solid var(--spotpatch-border-subtle); border-radius: var(--spotpatch-radius-sm); padding: 10px; background: var(--spotpatch-bg-input); font: 500 11px/1.55 var(--spotpatch-font-mono); }
|
|
65
|
+
.spotpatch-ask-citations, .spotpatch-ask-source-list { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
66
|
+
.spotpatch-ask-source { max-width: 100%; overflow: hidden; border: 1px solid var(--spotpatch-cyan-line); border-radius: var(--spotpatch-radius-pill); padding: 4px 9px; color: var(--spotpatch-cyan-text); background: var(--spotpatch-cyan-tint); cursor: pointer; font: 500 10.5px/1.3 var(--spotpatch-font-mono); text-overflow: ellipsis; white-space: nowrap; transition: border-color var(--spotpatch-duration-fast) ease; }
|
|
67
|
+
.spotpatch-ask-source:hover { border-color: var(--spotpatch-accent-cyan); }
|
|
54
68
|
.spotpatch-ask-sources { display: grid; gap: 7px; }
|
|
55
|
-
.spotpatch-ask-origin { margin-bottom: 12px; border: 1px solid
|
|
56
|
-
.spotpatch-ask-origin strong { display: block; margin-bottom: 2px; color:
|
|
57
|
-
@media (max-width: 420px) { .spotpatch-ask-
|
|
58
|
-
|
|
59
|
-
`,t}function He(e,t,n,s,f){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 m=K(e,f.sourceLabel(d.relativePath,d.startLine,d.endLine),"spotpatch-ask-source");m.dataset.askSourceId=d.sourceId,m.title=d.label,r.append(m)}t.append(r)}function At(e){let{document:t}=e,n=ze(e.locale()),s="change",f,r,a,d,m="",R="",k=Object.freeze({contextReady:!1,targetCount:0,sourceCount:0}),x=!1,P=c(t,"section"),N=c(t,"div");N.className="spotpatch-ask-mode",N.setAttribute("role","tablist");let l=K(t,""),T=K(t,"");l.setAttribute("role","tab"),T.setAttribute("role","tab"),N.append(l,T);let h=c(t,"aside");h.className="spotpatch-ask-origin",h.hidden=!0;let b=c(t,"strong"),y=c(t,"span");h.append(b,y);let M=c(t,"div");M.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 v=c(t,"textarea");v.id=ie,v.className="spotpatch-ask-question",v.maxLength=4e3;let V=c(t,"div");V.className="spotpatch-ask-suggestions",V.setAttribute("aria-label",""),te.append(ne,v,V);let oe=c(t,"div");oe.className="spotpatch-ask-field";let re=c(t,"label"),B=Ve(t,e.onViewChange),L=B.select;re.htmlFor=B.trigger.id;let se=c(t,"div");se.className="spotpatch-ask-field";let ce=c(t,"label"),i=Ve(t,e.onViewChange);ce.htmlFor=i.trigger.id,se.append(ce,i.root);let A,w=c(t,"p");w.className="spotpatch-ask-executor-status",w.setAttribute("role","status"),w.hidden=!0,oe.append(re,B.root,w);let E=c(t,"div");E.className="spotpatch-ask-safety";let F=c(t,"div");F.className="spotpatch-ask-data";let j=c(t,"span"),$=c(t,"strong");F.append(j,$);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),E.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),M.append(te,oe,se,E,J,z,ve,Z),P.append(N,h,M);function Pe(){let o=f?.executors.find(C=>C.executorId===L.value);return o?.state==="ready"&&o.readOnlyProven}function yt(){return f?.executors.some(o=>o.state==="ready"&&o.readOnlyProven)===!0}function Ge(){let o=f?.executors.find(g=>g.executorId===L.value),C=A===o?.executorId?i.select.value:void 0;A=o?.executorId;let u=o?.models;se.hidden=u===void 0,i.select.replaceChildren();for(let g of u??[]){let p=t.createElement("option");p.value=g,p.textContent=g,i.select.append(p)}i.select.value=u?.find(g=>g===C)??u?.find(g=>g===o?.requestedModelLabel)??u?.[0]??"",i.rebuild()}function U(){pe.disabled=x||v.value.trim().length===0||!Pe()||!X.checked||k.targetCount===0,k.contextReady||(pe.disabled=!0),v.disabled=x;let o=x||f===void 0||!yt();B.setDisabled(o),i.setDisabled(x||!Pe()),X.disabled=x||!Pe(),xe.hidden=x||r===void 0,le.hidden=!x}function ue(){let o=s==="ask";l.setAttribute("aria-selected",String(o)),T.setAttribute("aria-selected",String(!o)),M.hidden=!o,e.changeRoot.hidden=o,e.changeActions.hidden=o,h.hidden=o||h.dataset.active!=="true",(d!==s||m!==n.title||R!==n.subtitle)&&(d=s,m=n.title,R=n.subtitle,e.onModeChange(s,n.title,n.subtitle)),e.onViewChange()}function Et(){V.replaceChildren();for(let o of n.suggestions){let C=K(t,o);C.type="button",C.addEventListener("click",()=>{v.value=o,U(),v.focus()}),V.append(C)}}function Ye(){n=ze(e.locale()),N.setAttribute("aria-label",n.mode.label),l.textContent=n.mode.ask,T.textContent=n.mode.change,ne.textContent=n.questionLabel,v.placeholder=n.questionPlaceholder,V.setAttribute("aria-label",n.suggestionsLabel),re.textContent=n.executorLabel,ce.textContent=n.modelLabel,B.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,b.textContent=n.convertedTitle,y.textContent=n.convertedBody,j.textContent=n.dataSummary(k.targetCount,k.sourceCount),Et(),Ze(f),r!==void 0&&tt(r,!ee.hidden)}function Ze(o){f=o;let C=L.value;if(L.replaceChildren(),B.close(),w.hidden=!0,w.textContent="",o===void 0){let u=t.createElement("option");u.textContent=n.loadingExecutors,u.value="",L.append(u)}else if(!o.enabled||o.executors.length===0){let u=t.createElement("option");u.textContent=n.noExecutor,u.value="",L.append(u)}else{let u=o.executors.filter(p=>p.state==="ready"&&p.readOnlyProven),g=o.executors.filter(p=>p.state!=="ready"||!p.readOnlyProven);for(let p of u){let W=t.createElement("option");W.value=p.executorId,W.textContent=p.models===void 0?`${p.label} · ${p.effectiveModelLabel}`:p.label,L.append(W)}if(u.length===0){let p=t.createElement("option");p.textContent=n.noExecutor,p.value="",L.append(p)}L.value=u.some(p=>p.executorId===C)?C:u[0]?.executorId??"",g.length>0&&(w.textContent=g.map(p=>`${p.label}: ${n.error(p.errorCode)}`).join(" "),w.hidden=!1)}B.rebuild(),Ge(),U()}function et(o){a=o,J.hidden=!1,z.hidden=!0,Ie.textContent=n.status[o.status],["answered","cancelled","failed"].includes(o.status)?(x=!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}),U()}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 u=C.textContent;e.onExecutionChange({scene:"running",tone:"running",headline:n.status.running,expandedHeadline:n.status.running,action:u,expandedAction:u,meta:`${a.executor.label} · ${a.executor.modelLabel}`,activity:{key:`ask:${String(o.sequence)}`,kind:"read",label:u,state:"active"},recentActivities:Object.freeze([]),startedAt:a.createdAt})}}}function tt(o,C){r=o,a=void 0,e.onExecutionChange();let u=new Map(o.sources.map(g=>[g.sourceId,g]));Q.replaceChildren(),Re.replaceChildren(),me.replaceChildren(),ee.hidden=!C;for(let g of o.warnings){let p=c(t,"div");p.className="spotpatch-ask-warning",p.textContent=n.warning(g.code),Re.append(p)}for(let g of o.blocks)if(g.kind==="paragraph"){let p=c(t,"p");p.textContent=g.text,Q.append(p),He(t,Q,g.sourceIds,u,n)}else if(g.kind==="code"){let p=c(t,"pre"),W=c(t,"code");g.language!==void 0&&(W.dataset.language=g.language),W.textContent=g.code,p.append(W),Q.append(p),He(t,Q,g.sourceIds,u,n)}else{let p=c(t,"ul");for(let W of g.items){let De=c(t,"li");De.textContent=W.text,He(t,De,W.sourceIds,u,n),p.append(De)}Q.append(p)}for(let g of o.sources){let p=K(t,n.sourceLabel(g.relativePath,g.startLine,g.endLine),"spotpatch-ask-source");p.dataset.askSourceId=g.sourceId,p.title=g.label,me.append(p)}Ae.hidden=o.sources.length===0,Z.hidden=!1,J.hidden=!0,x=!1,U(),e.onViewChange()}function Ct(){if(r===void 0)return"";let o=r.blocks.flatMap(u=>u.kind==="paragraph"?[u.text]:u.kind==="code"?[u.code]:u.items.map(g=>`- ${g.text}`)).join(`
|
|
69
|
+
.spotpatch-ask-origin { margin-bottom: 12px; border: 1px solid var(--spotpatch-accent-line); border-radius: var(--spotpatch-radius-md); padding: 10px 12px; color: var(--spotpatch-text-secondary); background: var(--spotpatch-accent-tint); font-size: 11.5px; }
|
|
70
|
+
.spotpatch-ask-origin strong { display: block; margin-bottom: 2px; color: var(--spotpatch-accent-soft); font-size: 12px; }
|
|
71
|
+
@media (max-width: 420px) { .spotpatch-ask-actions { justify-content: stretch; } .spotpatch-ask-actions button { flex: 1 1 auto; } }
|
|
72
|
+
`,t}var Xt=/`([^`\n]+)`/gu;function wt(e,t,n){let r=0;for(let p of n.matchAll(Xt)){t.append(n.slice(r,p.index));let s=c(e,"code");s.className="spotpatch-ask-inline-code",s.textContent=p[1]??"",t.append(s),r=p.index+p[0].length}t.append(n.slice(r))}function Ye(e,t,n,r,p){if(n.length===0)return;let s=c(e,"div");s.className="spotpatch-ask-citations";for(let l of n){let a=r.get(l);if(a===void 0)continue;let f=U(e,p.sourceLabel(a.relativePath,a.startLine,a.endLine),"spotpatch-ask-source");f.dataset.askSourceId=a.sourceId,f.title=a.label,s.append(f)}t.append(s)}function vt(e){let{document:t}=e,n=Ge(e.locale()),r="change",p,s,l,a,f="",P="",S=Object.freeze({contextReady:!1,targetCount:0,sourceCount:0}),g=!1,w,j=c(t,"section"),d=c(t,"div");d.className="spotpatch-ask-mode",d.setAttribute("role","tablist");let v=U(t,""),T=U(t,"");v.setAttribute("role","tab"),T.setAttribute("role","tab"),d.append(v,T);let x=c(t,"aside");x.className="spotpatch-ask-origin",x.hidden=!0;let u=c(t,"strong"),I=c(t,"span");x.append(u,I);let W=c(t,"div");W.className="spotpatch-ask-panel";let oe=c(t,"div");oe.className="spotpatch-ask-field";let re=c(t,"label"),pe=`spotpatch-ask-question-${Math.random().toString(36).slice(2)}`;re.htmlFor=pe;let L=c(t,"textarea");L.id=pe,L.className="spotpatch-ask-question",L.maxLength=4e3;let H=c(t,"div");H.className="spotpatch-ask-suggestions",H.setAttribute("aria-label",""),oe.append(re,L,H);let se=c(t,"div");se.className="spotpatch-ask-field";let ae=c(t,"label"),J=Qe(t,e.onViewChange),D=J.select;ae.htmlFor=J.trigger.id;let ie=c(t,"div");ie.className="spotpatch-ask-field";let ue=c(t,"label"),i=Qe(t,e.onViewChange);ue.htmlFor=i.trigger.id,ie.append(ue,i.root);let A,R=c(t,"p");R.className="spotpatch-ask-executor-status",R.setAttribute("role","status"),R.hidden=!0,se.append(ae,J.root,R);let E=c(t,"div");E.className="spotpatch-ask-safety";let G=c(t,"div");G.className="spotpatch-ask-data";let q=c(t,"span"),V=c(t,"strong");G.append(q,V);let he=c(t,"label");he.className="spotpatch-ask-consent";let Y=c(t,"input");Y.type="checkbox";let Ze=c(t,"span");he.append(Y,Ze),E.append(G,he);let $=c(t,"div");$.className="spotpatch-ask-status",$.setAttribute("role","status"),$.setAttribute("aria-live","polite"),$.hidden=!0;let Ke=c(t,"strong"),te=c(t,"div");te.className="spotpatch-ask-activity",$.append(Ke,te);let X=c(t,"div");X.className="spotpatch-ask-error",X.setAttribute("role","alert"),X.hidden=!0;let Me=c(t,"div");Me.className="spotpatch-ask-actions";let Ce=U(t,""),fe=U(t,""),Se=U(t,""),we=U(t,"","spotpatch-primary"),ce=U(t,"","spotpatch-primary");fe.hidden=!0,Me.append(Ce,fe,Se,we,ce);let Z=c(t,"article");Z.className="spotpatch-ask-answer",Z.hidden=!0;let ne=c(t,"div");ne.className="spotpatch-ask-stale",ne.hidden=!0;let ge=c(t,"div");ge.className="spotpatch-ask-recap";let et=c(t,"span"),tt=c(t,"p");ge.append(et,tt);let ve=c(t,"div");ve.className="spotpatch-ask-answer-head";let nt=c(t,"h3"),Ue=c(t,"span");Ue.className="spotpatch-ask-answer-meta",ve.append(nt,Ue);let be=c(t,"div"),F=c(t,"div");F.className="spotpatch-ask-blocks";let xe=c(t,"section");xe.className="spotpatch-ask-sources";let ot=c(t,"h4"),Te=c(t,"div");Te.className="spotpatch-ask-source-list",xe.append(ot,Te),Z.append(ne,ge,ve,be,F,xe),W.append(X,Z,oe,se,ie,E,$,Me),j.append(d,x,W);function Be(){let o=p?.executors.find(b=>b.executorId===D.value);return o?.state==="ready"&&o.readOnlyProven}function _t(){return p?.executors.some(o=>o.state==="ready"&&o.readOnlyProven)===!0}function rt(){let o=p?.executors.find(N=>N.executorId===D.value),b=A===o?.executorId?i.select.value:void 0;A=o?.executorId;let h=o?.models;ie.hidden=h===void 0,i.select.replaceChildren();for(let N of h??[]){let m=t.createElement("option");m.value=N,m.textContent=N,i.select.append(m)}i.select.value=h?.find(N=>N===b)??h?.find(N=>N===o?.requestedModelLabel)??h?.[0]??"",i.rebuild()}function B(){ce.disabled=g||L.value.trim().length===0||!Be()||!Y.checked||S.targetCount===0,S.contextReady||(ce.disabled=!0),L.disabled=g;let o=g||p===void 0||!_t();J.setDisabled(o),i.setDisabled(g||!Be()),Y.disabled=g||!Be();let b=!g&&s!==void 0;W.dataset.phase=g?"running":b?"answered":"compose",Ce.hidden=!b,Se.hidden=!b,we.hidden=!b,ce.hidden=b,fe.hidden=!g}function Ae(){let o=r==="ask";d.dataset.mode=r,v.setAttribute("aria-selected",String(o)),T.setAttribute("aria-selected",String(!o)),W.hidden=!o,e.changeRoot.hidden=o,e.changeActions.hidden=o,x.hidden=o||x.dataset.active!=="true",(a!==r||f!==n.title||P!==n.subtitle)&&(a=r,f=n.title,P=n.subtitle,e.onModeChange(r,n.title,n.subtitle)),e.onViewChange()}function It(){H.replaceChildren();for(let o of n.suggestions){let b=U(t,o);b.type="button",b.addEventListener("click",()=>{L.value=o,B(),L.focus()}),H.append(b)}}function st(){n=Ge(e.locale()),d.setAttribute("aria-label",n.mode.label),v.textContent=n.mode.ask,T.textContent=n.mode.change,re.textContent=n.questionLabel,et.textContent=n.questionLabel,L.placeholder=n.questionPlaceholder,H.setAttribute("aria-label",n.suggestionsLabel),ae.textContent=n.executorLabel,ue.textContent=n.modelLabel,J.root.querySelector("[role=listbox]")?.setAttribute("aria-label",n.executorLabel),i.root.querySelector("[role=listbox]")?.setAttribute("aria-label",n.modelLabel),Ze.textContent=n.consent,V.textContent=n.safety,ce.textContent=n.submit,fe.textContent=n.cancel,Ce.textContent=n.newQuestion,Se.textContent=n.copy,we.textContent=n.convert,nt.textContent=n.answerTitle,ot.textContent=n.sourcesTitle,ne.textContent=n.stale,u.textContent=n.convertedTitle,I.textContent=n.convertedBody,q.textContent=n.dataSummary(S.targetCount,S.sourceCount),It(),at(p),s!==void 0&&ct(s,!ne.hidden)}function at(o){p=o;let b=D.value;if(D.replaceChildren(),J.close(),R.hidden=!0,R.textContent="",o===void 0){let h=t.createElement("option");h.textContent=n.loadingExecutors,h.value="",D.append(h)}else if(!o.enabled||o.executors.length===0){let h=t.createElement("option");h.textContent=n.noExecutor,h.value="",D.append(h)}else{let h=o.executors.filter(m=>m.state==="ready"&&m.readOnlyProven),N=o.executors.filter(m=>m.state!=="ready"||!m.readOnlyProven);for(let m of h){let y=t.createElement("option");y.value=m.executorId,y.textContent=m.models===void 0?`${m.label} · ${m.effectiveModelLabel}`:m.label,D.append(y)}if(h.length===0){let m=t.createElement("option");m.textContent=n.noExecutor,m.value="",D.append(m)}D.value=h.some(m=>m.executorId===b)?b:h[0]?.executorId??"",N.length>0&&(R.textContent=N.map(m=>`${m.label}: ${n.error(m.errorCode)}`).join(" "),R.hidden=!1)}J.rebuild(),rt(),B()}function it(o){l=o,$.hidden=!1,X.hidden=!0,Ke.textContent=n.status[o.status],["answered","cancelled","failed"].includes(o.status)?(g=!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}),B()}function Lt(o){if(o.type==="snapshot"){it(o.snapshot);return}if(o.type==="phase"&&(Ke.textContent=n.status[o.status]),o.type==="read-activity"&&o.state==="started"){let b=c(t,"span");for(b.textContent=o.activity.kind==="source"?n.readSource(o.activity.relativePath):n.readFiles(o.activity.bucket),te.append(b);te.childElementCount>5;)te.firstElementChild?.remove();if(l!==void 0){let h=b.textContent;e.onExecutionChange({scene:"running",tone:"running",headline:n.status.running,expandedHeadline:n.status.running,action:h,expandedAction:h,meta:`${l.executor.label} · ${l.executor.modelLabel}`,activity:{key:`ask:${String(o.sequence)}`,kind:"read",label:h,state:"active"},recentActivities:Object.freeze([]),startedAt:l.createdAt})}}}function ct(o,b){s=o,l=void 0,e.onExecutionChange();let h=new Map(o.sources.map(y=>[y.sourceId,y]));F.replaceChildren(),be.replaceChildren(),Te.replaceChildren(),ne.hidden=!b;for(let y of o.warnings){let O=c(t,"div");O.className="spotpatch-ask-warning",O.textContent=n.warning(y.code),be.append(O)}for(let y of o.blocks)if(y.kind==="paragraph"){let O=c(t,"p");wt(t,O,y.text),F.append(O),Ye(t,F,y.sourceIds,h,n)}else if(y.kind==="code"){let O=c(t,"pre"),de=c(t,"code");y.language!==void 0&&(de.dataset.language=y.language),de.textContent=y.code,O.append(de),F.append(O),Ye(t,F,y.sourceIds,h,n)}else{let O=c(t,"ul");for(let de of y.items){let je=c(t,"li");wt(t,je,de.text),Ye(t,je,de.sourceIds,h,n),O.append(je)}F.append(O)}for(let y of o.sources){let O=U(t,n.sourceLabel(y.relativePath,y.startLine,y.endLine),"spotpatch-ask-source");O.dataset.askSourceId=y.sourceId,O.title=y.label,Te.append(O)}xe.hidden=o.sources.length===0,be.hidden=o.warnings.length===0;let N=L.value.trim();tt.textContent=N,ge.hidden=N.length===0,Ue.textContent=`${o.executor.label} · ${o.executor.modelLabel}`,Z.dataset.entering=String(o.jobId!==w),w=o.jobId;let m=[ge,ve,...be.querySelectorAll(":scope > *"),...F.querySelectorAll(":scope > *"),xe];for(let[y,O]of m.entries())O.dataset.askOrder="",O.style.setProperty("--spotpatch-ask-order",String(Math.min(y,Vt)));Z.hidden=!1,$.hidden=!0,g=!1,B(),e.onViewChange()}function Rt(){if(s===void 0)return"";let o=s.blocks.flatMap(h=>h.kind==="paragraph"?[h.text]:h.kind==="code"?[h.code]:h.items.map(N=>`- ${N.text}`)).join(`
|
|
60
73
|
|
|
61
|
-
`),
|
|
62
|
-
`);return
|
|
74
|
+
`),b=s.sources.map(h=>n.sourceLabel(h.relativePath,h.startLine,h.endLine)).join(`
|
|
75
|
+
`);return b.length===0?o:`${o}
|
|
63
76
|
|
|
64
77
|
${n.sourcesTitle}
|
|
65
|
-
${
|
|
78
|
+
${b}`}function Ot(){s=void 0,l=void 0,e.onExecutionChange(),L.value="",Z.hidden=!0,$.hidden=!0,X.hidden=!0,te.replaceChildren(),ne.hidden=!0,g=!1,B(),e.onViewChange()}v.addEventListener("click",()=>{r="ask",Ae(),L.focus({preventScroll:!0})}),T.addEventListener("click",()=>{r="change",Ae()}),L.addEventListener("input",B),D.addEventListener("change",()=>{rt(),B(),e.onViewChange()}),Y.addEventListener("change",B);let Nt=e.subscribeLocale(st);return st(),Ae(),Object.freeze({root:j,styles:Ht(t),questionInput:L,executorSelect:D,consentCheckbox:Y,submitButton:ce,cancelButton:fe,newQuestionButton:Ce,copyButton:Se,convertButton:we,clear:Ot,dispose:()=>{Nt(),J.dispose(),i.dispose()},focusQuestion:()=>{L.focus({preventScroll:!0})},mode:()=>r,notify(o){let b=o==="copied"?n.copied:o==="copy-failed"?n.copyFailed:o==="converted"?n.converted:n.sourceOpenFailed;e.announce(b)},readConsent:()=>Y.checked,readExecutorId:()=>D.value||void 0,readModel:()=>i.select.value||void 0,readQuestion:()=>L.value.trim(),renderAnswer:ct,renderCapability:at,renderError(o){l=void 0,e.onExecutionChange(),X.textContent=n.error(o),X.hidden=!1,$.hidden=!0,g=!1,B(),e.onViewChange()},renderEvent:Lt,renderJob:it,selectedSourceId(o){return o instanceof Element?o.closest("[data-ask-source-id]")?.dataset.askSourceId:void 0},setBusy(o){g=o,o&&($.hidden=!1,X.hidden=!0,Z.hidden=!0,te.replaceChildren()),B()},setConsent(o){Y.checked=o,B()},setMode(o){r=o,Ae()},setOrigin(o){x.dataset.active=String(o!==void 0),x.hidden=r==="ask"||o===void 0,e.onViewChange()},setSelectionPreview(o){S=o,q.textContent=n.dataSummary(o.targetCount,o.sourceCount),B()},setSelectionVisible(o){j.hidden=!o,o&&Ae()},sourceById:o=>s?.sources.find(b=>b.sourceId===o),answerPlainText:Rt})}var Ft=Object.freeze({createPanel:vt,createWorkflow:Et});function Tt(){kt(Ft)}Tt();
|
|
@@ -1,26 +1,27 @@
|
|
|
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
|
|
2
|
-
`),
|
|
3
|
-
.spotpatch-view-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap:
|
|
4
|
-
.spotpatch-view-tabs button { min-width: 0; border: 0; border-radius:
|
|
5
|
-
.spotpatch-view-tabs button
|
|
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 l=u(e,"div");l.className="spotpatch-data-flow-badges",l.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,l),t.environment!==void 0&&l.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
|
+
`),E=t.response.consumedFields.length===0?n.unknown:t.response.consumedFields.join(", "),b=t.suppliedBindings.length===0?n.unknown:t.suppliedBindings.join(", "),y=u(e,"div");y.className="spotpatch-data-flow-card-body";let A=new Set(t.observationIds),S=t.evidenceIds.filter(g=>!A.has(g)).length;return y.append(O(e,n.parameters,m),O(e,n.consumed,E),O(e,n.bindings,b),O(e,n.evidence,`${String(S)} 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),l=z(e,r.pageTitle),m=F(e,r.refresh),E=e.createElement("style");E.textContent=K,m.classList.add("spotpatch-data-flow-refresh"),f.root.prepend(m);let b=u(e,"div"),y=u(e,"nav");y.className="spotpatch-view-tabs",y.setAttribute("aria-label","SpotPatch views"),y.setAttribute("role","tablist");let A=new Map([["changes",o],["component-data",f.root],["page-data",l.root],["diagnostics",a]]),S=new Map,g="changes";for(let i of A.keys()){let c=F(e,"");c.dataset.viewId=i,c.id=`spotpatch-view-${i}-tab`,c.setAttribute("role","tab"),c.setAttribute("aria-selected",String(i===g));let p=A.get(i);p?.setAttribute("aria-labelledby",c.id),p?.setAttribute("role","tabpanel"),!t&&(i==="component-data"||i==="page-data")&&(c.hidden=!0),S.set(i,c),y.append(c)}b.append(y,...A.values());function w(i){if(A.has(i)){g=i;for(let[c,p]of A){p.hidden=c!==i;let h=S.get(c);h?.setAttribute("aria-selected",String(c===i)),h!==void 0&&(h.tabIndex=c===i?0:-1)}s()}}function D(i){if(!(i.target instanceof HTMLButtonElement))return;let c=i.target.dataset.viewId;c!==void 0&&w(c)}y.addEventListener("click",D),w(g);function T(i,c,p){if(i.list.replaceChildren(),i.status.dataset.state=c.status,!t||c.status==="disabled"){i.status.textContent=r.disabled;return}if(c.status==="loading"){i.status.textContent=r.loading;return}if(c.status==="error"){i.status.textContent=c.message??r.error;return}let h=c.report,L=h===void 0?"":[...new Set(h.diagnostics.map(({code:C})=>C))].join(", "),P=L.length===0?"":` · ${r.diagnostics}: ${L}`;if(h===void 0||h.dependencies.length===0){i.status.textContent=`${p}${P}`;return}i.status.textContent=`${String(h.dependencies.length)} · ${h.completeness.complete?"complete":"partial"}${P}`,i.list.append(...h.dependencies.map(C=>W(e,C,r)))}return Object.freeze({root:b,refreshButton:m,styles:E,dispose(){y.removeEventListener("click",D)},render(i){r=j[n()];let c=[r.changes,r.componentTab,r.pageTab,r.diagnostics];[...S.values()].forEach((p,h)=>{p.textContent=c[h]??""}),m.textContent=`${r.refresh} · ${String(i.observationCount)}`,m.disabled=!t||i.component.status==="loading",T(f,i.component,r.componentEmpty),T(l,i.page,r.pageEmpty)},resetView(){w("changes")}})}var K=`
|
|
3
|
+
.spotpatch-view-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; margin-bottom: 14px; padding: 3px; border: 1px solid var(--spotpatch-border-subtle); border-radius: var(--spotpatch-radius-md); background: var(--spotpatch-bg-input); }
|
|
4
|
+
.spotpatch-view-tabs button { min-width: 0; border: 0; border-radius: var(--spotpatch-radius-sm); padding: 7px 5px; color: var(--spotpatch-text-muted); background: transparent; cursor: pointer; font-size: 11.5px; font-weight: 550; transition: color var(--spotpatch-duration-fast) ease, background var(--spotpatch-duration-base) var(--spotpatch-ease-out); }
|
|
5
|
+
.spotpatch-view-tabs button:hover { color: var(--spotpatch-text); }
|
|
6
|
+
.spotpatch-view-tabs button[aria-selected="true"] { color: var(--spotpatch-text); background: var(--spotpatch-bg-active); box-shadow: var(--spotpatch-shadow-inset), 0 0 0 1px var(--spotpatch-border); }
|
|
6
7
|
.spotpatch-data-flow-panel { position: relative; }
|
|
7
|
-
.spotpatch-data-flow-panel > h3 { margin: 0 0 3px;
|
|
8
|
-
.spotpatch-data-flow-refresh { position: absolute; top: -4px; right: 0; border: 1px solid
|
|
9
|
-
.spotpatch-data-flow-refresh:disabled { cursor: not-allowed; opacity: .
|
|
10
|
-
.spotpatch-data-flow-status { margin: 0 0 10px; color: var(--spotpatch-text-muted); font-size:
|
|
8
|
+
.spotpatch-data-flow-panel > h3 { margin: 0 0 3px; font-size: 13px; font-weight: 620; }
|
|
9
|
+
.spotpatch-data-flow-refresh { position: absolute; top: -4px; right: 0; border: 1px solid var(--spotpatch-accent-line); border-radius: var(--spotpatch-radius-sm); padding: 4px 9px; color: var(--spotpatch-accent-soft); background: var(--spotpatch-accent-tint); cursor: pointer; font-size: 11.5px; }
|
|
10
|
+
.spotpatch-data-flow-refresh:disabled { cursor: not-allowed; opacity: .4; }
|
|
11
|
+
.spotpatch-data-flow-status { margin: 0 0 10px; color: var(--spotpatch-text-muted); font-size: 11.5px; line-height: 1.5; }
|
|
11
12
|
.spotpatch-data-flow-list { display: grid; gap: 8px; }
|
|
12
|
-
.spotpatch-data-flow-card { overflow: hidden; border: 1px solid
|
|
13
|
-
.spotpatch-data-flow-card-head { display: grid; gap: 7px; padding: 10px; border-bottom: 1px solid
|
|
13
|
+
.spotpatch-data-flow-card { overflow: hidden; border: 1px solid var(--spotpatch-border-subtle); border-radius: var(--spotpatch-radius-card); background: var(--spotpatch-bg-raised); animation: spotpatch-enter var(--spotpatch-duration-slow) var(--spotpatch-ease-out) both; }
|
|
14
|
+
.spotpatch-data-flow-card-head { display: grid; gap: 7px; padding: 10px 12px; border-bottom: 1px solid var(--spotpatch-border-subtle); }
|
|
14
15
|
.spotpatch-data-flow-endpoint { display: flex; min-width: 0; align-items: center; gap: 8px; }
|
|
15
|
-
.spotpatch-data-flow-endpoint strong { color:
|
|
16
|
-
.spotpatch-data-flow-endpoint code { min-width: 0; overflow: hidden;
|
|
16
|
+
.spotpatch-data-flow-endpoint strong { color: var(--spotpatch-cyan-text); font: 700 11px/1 var(--spotpatch-font-mono); }
|
|
17
|
+
.spotpatch-data-flow-endpoint code { min-width: 0; overflow: hidden; font: 12px/1.4 var(--spotpatch-font-mono); text-overflow: ellipsis; white-space: nowrap; }
|
|
17
18
|
.spotpatch-data-flow-badges { display: flex; flex-wrap: wrap; gap: 4px; }
|
|
18
|
-
.spotpatch-data-flow-badge { border-radius:
|
|
19
|
-
.spotpatch-data-flow-badge[data-tone="success"] { color:
|
|
20
|
-
.spotpatch-data-flow-badge[data-tone="proof"] { color:
|
|
21
|
-
.spotpatch-data-flow-badge[data-tone="warning"] { color:
|
|
22
|
-
.spotpatch-data-flow-card-body { display: grid; gap: 7px; padding: 10px; }
|
|
23
|
-
.spotpatch-data-flow-detail { display: grid; grid-template-columns:
|
|
24
|
-
.spotpatch-data-flow-detail > span { color: var(--spotpatch-text-muted); font-size:
|
|
25
|
-
.spotpatch-data-flow-detail > code { overflow-wrap: anywhere; color:
|
|
26
|
-
`;var V=Symbol.for("spotpatch.data-flow.extension.v1");function
|
|
19
|
+
.spotpatch-data-flow-badge { border-radius: var(--spotpatch-radius-pill); padding: 2px 7px; color: var(--spotpatch-text-secondary); background: var(--spotpatch-hover); font-size: 10.5px; }
|
|
20
|
+
.spotpatch-data-flow-badge[data-tone="success"] { color: var(--spotpatch-success-text); background: var(--spotpatch-success-tint); }
|
|
21
|
+
.spotpatch-data-flow-badge[data-tone="proof"] { color: var(--spotpatch-accent-soft); background: var(--spotpatch-accent-tint); }
|
|
22
|
+
.spotpatch-data-flow-badge[data-tone="warning"] { color: var(--spotpatch-warning-text); background: var(--spotpatch-warning-tint); }
|
|
23
|
+
.spotpatch-data-flow-card-body { display: grid; gap: 7px; padding: 10px 12px; }
|
|
24
|
+
.spotpatch-data-flow-detail { display: grid; grid-template-columns: 86px minmax(0, 1fr); gap: 8px; align-items: start; }
|
|
25
|
+
.spotpatch-data-flow-detail > span { color: var(--spotpatch-text-muted); font-size: 11px; }
|
|
26
|
+
.spotpatch-data-flow-detail > code { overflow-wrap: anywhere; color: var(--spotpatch-text-secondary); font: 11px/1.5 var(--spotpatch-font-mono); white-space: pre-wrap; }
|
|
27
|
+
`;var V=Symbol.for("spotpatch.data-flow.extension.v1");function U(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 _(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,E)=>m.evidenceIds.length!==e.parameters[E]?.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 x(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 l=t.mode??"analysis",m=te(l),E=`${e.reportId}_collection_${l}`,b=Object.freeze([...e.capability.reasons.filter(p=>p.code!==m).slice(0,d.capabilityMaxReasons-1),Object.freeze({code:m,retryable:!1})]),y=Object.freeze([...e.diagnostics.filter(p=>p.id!==E).slice(0,d.reportMaxDiagnostics-1),Object.freeze({id:E,code:m,severity:"warning",retryable:!1,evidenceIds:Object.freeze([])})]),A=Q(a,y),S=Z(e.evidence,A,e.dependencies.length===a.length),g=new Set(S.map(({id:p})=>p)),w=Object.freeze(a.map(p=>ee(p,g))),D=Object.freeze(y.map(p=>Object.freeze({...p,evidenceIds:Object.freeze(p.evidenceIds.filter(h=>g.has(h)))}))),T=e.dependencies.length-a.length,i=e.baseline.analyzedSourceVersions.length-s.length,c=i>0&&T===0?"modules":"callsites";return Object.freeze({...e,baseline:Object.freeze({...e.baseline,analyzedSourceVersions:s}),capability:Object.freeze({...e.capability,...l==="analysis"&&e.capability.staticAnalysis==="available"?{staticAnalysis:"partial"}:{},reasons:b}),dependencies:w,evidence:S,diagnostics:D,...l==="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??c})}:{}})}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 H(e,t){let n=new Set,o=e.map(a=>{let s=t.filter(l=>ne(l,a));for(let l of s)n.add(l.id);if(s.length===0)return a;let r=[...new Set(s.flatMap(({url:l})=>l.origin===void 0?[]:[l.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:l})=>l)])]),evidenceIds:Object.freeze([...new Set([...a.evidenceIds,...s.map(({id:l})=>l)])])})});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 N(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=H(e.dependencies,o);return x(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 k(e,t){let n=t.filter(({freshness:r})=>r==="current"),o=H(e.dependencies,n),a=n.filter(({id:r})=>!o.matchedObservationIds.has(r)).map(ae),s=new Set(n.map(({id:r})=>r));return x(Object.freeze({...e,dependencies:Object.freeze([...o.dependencies,...a]),evidence:B(e.evidence,n,s)}),{mode:"observation"})}function X(){U(Object.freeze({createPanel:q,getComponentRegistration(e){return _()?.getComponentRegistration(e)},observations(e){let t=_();return t?.updateRoute(e),t?.observations()??Object.freeze([])},mergeComponentReport:N,mergePageReport:k}))}X();
|