okx-onchain-console 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COMPANION.md +42 -0
- package/README.md +240 -0
- package/companion.mjs +826 -0
- package/dist/assets/data-YT0JVIX1.js +1 -0
- package/dist/assets/sidepanel-Bl_Aq3uM.css +1 -0
- package/dist/background.js +1 -0
- package/dist/content.js +1 -0
- package/dist/icons/icon-128.png +0 -0
- package/dist/icons/icon-16.png +0 -0
- package/dist/icons/icon-32.png +0 -0
- package/dist/icons/icon-48.png +0 -0
- package/dist/index.html +15 -0
- package/dist/manifest.json +33 -0
- package/dist/product-icon.png +0 -0
- package/dist/screenshots/console-overview.png +0 -0
- package/dist/sidepanel.js +164 -0
- package/dist-web/assets/sidepanel-Bl_Aq3uM.css +1 -0
- package/dist-web/icons/icon-128.png +0 -0
- package/dist-web/icons/icon-16.png +0 -0
- package/dist-web/icons/icon-32.png +0 -0
- package/dist-web/icons/icon-48.png +0 -0
- package/dist-web/index.html +14 -0
- package/dist-web/manifest.json +33 -0
- package/dist-web/product-icon.png +0 -0
- package/dist-web/screenshots/console-overview.png +0 -0
- package/dist-web/sidepanel.js +164 -0
- package/package.json +49 -0
- package/public/manifest.json +33 -0
- package/web.mjs +161 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function m(o=new Date){const e=r=>new Date(o.getTime()-r*864e5).toISOString(),t="0x1111111111111111111111111111111111111111",s=[{id:"demo-radar",name:"SEO 雷达",address:t,description:"主运营账户 · 演示"},{id:"demo-lab",name:"探索实验室",address:"0x2222222222222222222222222222222222222222",description:"新账户 · 演示"}],i=[["review","SEORadar 上架申请","待审核",0,void 0,"演示:已提交资料,等待平台审核。此状态不代表真实 OKX 账户。"],["review","市场简报资料补充","已驳回",2,void 0,"演示驳回原因:服务说明缺少参数规范与可运行的调用示例。"],["task","网站 SEO 健康检查","已完成",0,"0.01","演示任务:example.com 页面基础标签检查。"],["invocation","项目名称分析","调用完成",0,"0.01","演示 A2MCP 调用,仅用于预览界面。"],["task","内容结构分析","待处理",1,"0.01"],["task","旧站迁移检查","已取消",10,"0.01"],["subscription","每周站点巡检","进行中",2,"0.30"],["subscription","月度内容报告","已到期",35,"0.20"],["income","SEO 检查服务收入","已结算",0,"0.01"],["income","SEO 检查服务收入","已结算",1,"0.01"],["income","评估奖励","待领取",3,"0.05"],["arbitration","报告交付争议","待处理",1,"0.01","演示争议:用户认为报告缺少语言标签建议;等待补充说明。无真实仲裁。"],["arbitration","重复调用退款","已关闭",9,"0.01","演示:双方达成一致,模拟记录已关闭。"],["feedback","报告清晰,建议可执行","已评价",0,void 0,"演示评价:5 / 5;来自虚构调用账户。"],["feedback","希望增加移动端建议","已评价",4,void 0,"演示评价:4 / 5;来自虚构调用账户。"],["transaction","演示充值","已确认",5,"12.00","虚构钱包事件;不是链上交易,不提供真实交易哈希。"],["transaction","服务收款","已确认",0,"0.01"]].map(([r,a,c,d,u,l],p)=>({id:`demo-event-${p}`,accountId:"demo-radar",kind:r,role:r==="transaction"?"User":a==="评估奖励"?"Evaluator":"ASP",title:a,status:c,createdAt:e(d),amount:u,detail:l??"模拟事件,仅用于演练筛选与运营流程;未从平台或链上获取。"}));return{mode:"mock",capturedAt:o.toISOString(),accounts:s,wallets:s.map((r,a)=>({accountId:r.id,address:r.address,chain:"X Layer · 演示",totalUsd:a?0:12.48,assets:a?[]:[{symbol:"USDT",balance:"12.40",usd:12.4},{symbol:"OKB",balance:"0.001",usd:.08}]})),identities:[{id:"demo-user",accountId:"demo-radar",name:"radar-user",role:"User",status:"已注册",review:"不适用",online:!0,address:t,rating:null,serviceIds:[]},{id:"demo-asp",accountId:"demo-radar",name:"SEO 雷达",role:"ASP",status:"已注册",review:"待审核",online:!0,address:t,rating:4.8,serviceIds:["demo-seo","demo-brief"]},{id:"demo-evaluator",accountId:"demo-radar",name:"Radar Evaluator",role:"Evaluator",status:"已注册",review:"不适用",online:!1,address:t,rating:4.9,serviceIds:[]}],services:[{id:"demo-seo",accountId:"demo-radar",identityId:"demo-asp",name:"SEORadar · 网站 SEO 健康检查",type:"A2MCP",price:"0.01",endpoint:"https://seo.example.com/v1/seo-audit",description:"检查页面结构与基础 SEO 信息。",volume:124,review:"待审核"},{id:"demo-brief",accountId:"demo-radar",identityId:"demo-asp",name:"市场简报 · 演示服务",type:"A2A",price:"0.02",endpoint:"https://brief.example.com/agent",description:"生成定期市场简报。",volume:0,review:"已驳回"}],events:i}}class h{constructor(e,t=m()){this.repository=e,this.snapshot=t}async getSnapshot(){return structuredClone(this.snapshot)}async getAccounts(){return(await this.getSnapshot()).accounts}async getWallet(e){return(await this.getSnapshot()).wallets.find(t=>t.accountId===e)}async getIdentities(e){return(await this.getSnapshot()).identities.filter(t=>t.accountId===e)}async getServices(e){return(await this.getSnapshot()).services.filter(t=>t.accountId===e)}async getEvents(e,t){return(await this.getSnapshot()).events.filter(s=>s.accountId===e&&(!t||s.kind===t))}async rehearse(e,t){if(!t)throw new Error("请先核对确认卡,未确认的演练不能保存。");if(!e||!this.snapshot.accounts.some(a=>a.id===e.accountId))throw new Error("账户不存在。");const s=this.snapshot.services.find(a=>a.id===e.targetId&&a.accountId===e.accountId),n=this.snapshot.events.find(a=>a.id===e.targetId&&a.accountId===e.accountId&&a.kind==="income"&&a.status==="待领取");if(!["price-update","review-submit","reward-claim","service-update"].includes(e.kind)||(e.kind==="reward-claim"?!n:!s))throw new Error("操作或目标无效。");if(typeof e.value!="string"||!e.value.trim()||e.value.length>500)throw new Error("请填写有效内容(不超过 500 字)。");if(e.kind==="price-update"&&(!/^\d+(\.\d{1,6})?$/.test(e.value)||Number(e.value)>1e6))throw new Error("价格必须是 0 至 1000000 的数值,最多 6 位小数。");if(e.kind==="service-update")try{const a=new URL(e.value);if(a.protocol!=="https:"||a.username||a.password)throw new Error}catch{throw new Error("Endpoint 必须是无账户密码的 HTTPS 地址。")}if(e.kind==="reward-claim"&&e.value!==(n==null?void 0:n.amount))throw new Error("奖励金额与演示记录不一致。");const i=(await this.repository.list(e.accountId)).find(a=>a.draft.id===e.id);if(i)return i;const r={id:crypto.randomUUID(),draft:structuredClone(e),completedAt:new Date().toISOString(),status:"simulated",externalEffect:!1,message:"演练未执行:仅保存本地记录,未提交到 OKX/链上。"};return await this.repository.append(r),r}}class w{constructor(e){this.storage=e}async list(e){return Object.entries(await this.storage.getAll()).filter(([t])=>t.startsWith("receipt:")).map(([,t])=>t).filter(t=>t.draft.accountId===e).sort((t,s)=>s.completedAt.localeCompare(t.completedAt))}async append(e){await this.storage.set(`receipt:${e.draft.id}`,e)}async getSelectedAccount(){return(await this.storage.getAll()).selectedAccount??null}async selectAccount(e){await this.storage.set("selectedAccount",e)}}function v(o,e,t,s,n=Date.now()){return o.filter(i=>(e==="all"||i.role===e)&&(t==="all"||i.status===t)&&(!s||new Date(i.createdAt).getTime()>=n-s*864e5))}export{w as L,h as M,v as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
:root{font-family:OKX Sans,Avenir Next,PingFang SC,sans-serif;color:#f2f2f2;background:#010101;color-scheme:dark;font-synthesis:none;font-size:13px;--background: oklch(6% 0 0);--surface-1: oklch(10% 0 0);--surface-2: oklch(15% 0 0);--surface-3: oklch(21% 0 0);--line: oklch(24% 0 0);--muted: oklch(65% 0 0);--text: oklch(96% 0 0);--success: oklch(78% .14 152);--warning: oklch(82% .13 85);--danger: oklch(72% .15 28)}*{box-sizing:border-box}html,body,#root{min-height:0}body{margin:0;overflow-x:hidden;background:var(--background)}button,input{font:inherit}button{cursor:pointer;color:inherit;background:var(--surface-2);border:1px solid var(--line);border-radius:6px;padding:9px 12px;transition:background .15s}button:hover{background:var(--surface-3)}button:disabled{opacity:.5;cursor:wait}button:focus-visible,input:focus-visible{outline:2px solid var(--text);outline-offset:3px}input{background:var(--surface-1);border:1px solid var(--line);padding:8px;border-radius:5px;color:inherit;max-width:100%}.select-control{position:relative;display:block;min-width:0}.select-trigger{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;min-height:34px;padding:8px 10px;background:var(--surface-1);border:1px solid var(--line);border-radius:6px;text-align:left}.select-trigger>span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select-trigger>svg{color:var(--muted);transition:transform .16s ease,color .16s ease}.select-control.open .select-trigger{border-color:#555;background:var(--surface-2)}.select-control.open .select-trigger>svg{color:var(--text);transform:rotate(180deg)}.select-menu{position:absolute;z-index:20;top:calc(100% + 6px);left:0;width:100%;min-width:max-content;max-height:240px;overflow-y:auto;padding:5px;background:#060606;border:1px solid var(--line);border-radius:7px;box-shadow:0 14px 36px #0000008c;animation:select-in .14s cubic-bezier(.22,1,.36,1)}.select-menu button{display:flex;align-items:center;justify-content:space-between;gap:16px;width:100%;min-height:34px;padding:7px 9px;color:#b7b7b7;background:transparent;border:0;border-radius:4px;text-align:left;white-space:nowrap}.select-menu button.active{color:var(--text);background:var(--surface-3)}.select-menu button[aria-selected=true]{color:var(--text);font-weight:600}.select-menu button svg{color:var(--text)}@keyframes select-in{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}h1,h2,p{margin:0}h1{font-size:clamp(26px,2.2vw,32px);letter-spacing:-1px;font-weight:600}h2{font-size:15px;font-weight:600}small{font-size:11px}svg{flex-shrink:0;vertical-align:middle}.workspace{display:grid;grid-template-columns:216px minmax(0,1fr);max-width:1400px;margin:auto}aside{border-right:1px solid var(--line);padding:24px 18px}.account-menu{padding:0 4px 18px;margin-bottom:14px;border-bottom:1px solid var(--line)}.account-row{display:flex;align-items:center;gap:6px}.account-picker{flex:1}.account-picker .select-trigger{min-height:38px;padding-left:10px;background:transparent;font-size:14px;font-weight:600}.account-meta{display:flex;align-items:center;gap:5px;min-width:0;margin-top:8px;color:var(--muted);font-size:10px}.account-meta>span:last-child{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.account-meta i{width:5px;height:5px;flex:0 0 auto;border-radius:50%;background:var(--success)}.account-meta i.warning{background:var(--warning)}nav{display:flex;flex-direction:column;gap:6px}nav button{display:flex;align-items:center;gap:12px;min-height:48px;padding:12px 14px;background:none;border:0;text-align:left;color:var(--muted);font-size:16px;font-weight:500}nav button svg{width:19px;height:19px}nav button.active{background:var(--text);color:var(--background);font-weight:600}nav button b{margin-left:auto;font-size:10px;background:#c4c4c4;color:var(--background);padding:2px 5px;border-radius:3px}main{padding:28px clamp(24px,4vw,52px) 48px;min-width:0;max-width:960px;width:100%;margin:0 auto}.eyebrow{font-size:9px;letter-spacing:1.6px;color:var(--muted);display:block;margin-bottom:7px}.icon-button{border:0;background:none;display:inline-grid;place-items:center;padding:7px}.notice{display:flex;align-items:flex-start;gap:8px;padding:11px 12px;background:var(--surface-2);color:#b1b1b1;font-size:11px;line-height:1.7;border-radius:5px;margin:14px 0 22px}.balance-section{display:flex;align-items:center;justify-content:space-between;padding:8px 0 26px;border-bottom:1px solid var(--line)}.balance-section p{font-size:12px}.balance-section h2{font-size:40px;letter-spacing:-1.8px;font-weight:500;margin:10px 0}.balance-section h2 small{font-size:12px;color:var(--muted);letter-spacing:0}.mono{font-family:SFMono-Regular,Consolas,monospace;font-size:11px}.address{overflow-wrap:anywhere;color:var(--muted)}.muted{color:var(--muted);font-size:11px}.text-button{display:inline-flex;align-items:center;gap:4px;border:0;background:none;color:var(--text);padding:5px 0;font-size:11px}.metrics{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;padding:24px 0;border-bottom:1px solid var(--line)}.metrics>div{display:flex;flex-direction:column;gap:7px}.metrics span{font-size:10px;color:#9b9b9b}.metrics strong{font-size:25px;letter-spacing:-1px;font-weight:500}.metrics em{font-size:14px;font-style:normal;color:#ababab}section{margin-bottom:26px}.section-title{display:flex;justify-content:space-between;align-items:center;gap:10px;margin:23px 0 13px}.section-title h2 svg{margin-right:5px}.role-strip{display:grid;grid-template-columns:repeat(auto-fit,minmax(0,1fr));border:1px solid var(--line);border-radius:7px;overflow:hidden}.role-strip button{display:flex;flex-direction:column;align-items:flex-start;border:0;border-radius:0;border-right:1px solid var(--line);padding:15px}.role-strip button:last-child{border-right:0}.role-strip span{font-size:11px;color:#9e9e9e}.role-strip strong{font-size:21px;margin:8px 0 6px;font-weight:500}.role-strip small{font-size:10px;color:var(--muted);width:100%;display:flex;justify-content:space-between}.event-row{display:flex;align-items:center;gap:10px;width:100%;text-align:left;background:transparent;border:0;border-bottom:1px solid var(--line);border-radius:0;padding:15px 0}.event-icon{width:30px;height:30px;border-radius:50%;background:var(--surface-3);display:grid;place-items:center;color:#aeaeae}.event-main{flex:1;min-width:0}.event-main strong{display:block;font-size:12px;font-weight:500}.event-main small{display:block;margin-top:5px;color:var(--muted);font-size:10px}.event-end{text-align:right;display:flex;flex-direction:column;gap:5px;align-items:flex-end}.event-end strong{font-size:11px;font-weight:500}.badge{display:inline-block;white-space:nowrap;border-radius:4px;background:var(--surface-3);color:#b7b7b7;padding:3px 7px;font-size:10px;line-height:1.5}.badge.good{background:#061b0d;color:var(--success)}.badge.pending{background:#1e1400;color:var(--warning)}.badge.bad{background:#250e0c;color:var(--danger)}.empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:30px 18px;color:var(--muted);font-size:11px;line-height:1.8;text-align:center;border:1px dashed var(--line);border-radius:5px}.filters{display:flex;gap:8px;flex-wrap:wrap;margin:18px 0}.filters .select-trigger,.filters .select-menu{font-size:11px;width:100%}.filters .select-control{flex:1;min-width:85px}.identity,.service{border-bottom:1px solid var(--line);padding:0 0 23px;margin-bottom:22px}.identity h2{margin-top:4px}.facts{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin:20px 0}.facts>div{display:flex;align-items:flex-start;flex-direction:column;gap:7px}.facts span:first-child{font-size:10px;color:var(--muted)}.facts strong{font-size:11px;font-weight:500}.identity>p{line-height:1.8;margin:8px 0}.price{font-size:29px;font-weight:500;margin-top:14px;letter-spacing:-1px}.price small{font-size:11px;color:var(--muted);margin-left:8px;letter-spacing:0}.endpoint{font-size:10px;color:var(--muted)}.endpoint code{display:block;padding:10px;background:var(--surface-2);color:#b1b1b1;font-size:11px;margin-top:7px;overflow-wrap:anywhere;border-radius:4px}.actions{display:flex;gap:7px;flex-wrap:wrap;margin-top:17px}.actions button{font-size:11px;flex:1}.rejection{font-size:11px;color:var(--danger);background:#1f0b09;padding:10px;margin-top:10px;line-height:1.8}.primary{background:var(--text);color:var(--background);border-color:var(--text)}.primary:hover{background:#c4c4c4}.tabs{display:flex;gap:18px;border-bottom:1px solid var(--line);margin:22px 0 5px}.tabs button{border:0;border-bottom:2px solid transparent;background:none;border-radius:0;padding:9px 1px;color:var(--muted);font-size:12px}.tabs button.selected{border-color:var(--text);color:var(--text)}.list-count{font-size:10px;color:var(--muted);margin-bottom:5px}.asset{display:grid;grid-template-columns:1fr 1fr 1fr;border-bottom:1px solid var(--line);padding:14px 0;font-size:12px}.asset span{text-align:right}.wallet-summary{padding-bottom:10px}.wallet-addresses{margin-bottom:18px;border-top:1px solid var(--line)}.wallet-addresses>div{display:grid;grid-template-columns:72px minmax(0,1fr);gap:14px;padding:11px 0;border-bottom:1px solid var(--line)}.wallet-addresses span{color:var(--muted);font-size:10px}.wallet-addresses code{overflow-wrap:anywhere;color:var(--text);font-size:10px}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.receipt-row{width:100%;display:flex;align-items:center;gap:10px;background:none;border:0;border-bottom:1px solid var(--line);border-radius:0;text-align:left;padding:16px 0;font-size:12px}.receipt-row>span:nth-child(2){flex:1;min-width:0}.receipt-row small{display:block;font-size:10px;color:var(--muted);margin-top:5px;overflow-wrap:anywhere}.description{font-size:12px;line-height:1.8;color:var(--muted);margin:13px 0 20px}.footnote{font-size:10px;line-height:1.9;color:var(--muted);margin:18px 0}.setting-row{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:18px 0;border-bottom:1px solid var(--line);font-size:12px}.setting-row small{display:block;line-height:1.7;color:var(--muted);font-size:10px;margin-top:5px}.privacy{padding-left:18px;line-height:2.1;color:#a4a4a4;font-size:11px}dialog{background:var(--surface-1);color:var(--text);border:1px solid var(--line);border-radius:10px;padding:24px;max-height:90vh;overflow:auto;width:min(450px,calc(100vw - 28px));box-shadow:0 24px 90px #000000b3}dialog::backdrop{background:#000000b8}dialog h2{font-size:21px;margin:12px 0 15px}.dialog-heading{display:flex;align-items:center;justify-content:space-between}.dialog-heading .eyebrow{margin:0}.drawer{height:100dvh;max-height:100dvh;margin:0 0 0 auto;border-radius:0;width:min(440px,100vw);border:0;border-left:1px solid var(--line);padding:0;overflow:hidden;animation:drawer-in .24s cubic-bezier(.22,1,.36,1) both}.drawer::backdrop{animation:drawer-backdrop-in .2s ease-out both}.drawer.closing{animation:drawer-out .18s cubic-bezier(.4,0,1,1) both}.drawer.closing::backdrop{animation:drawer-backdrop-out .18s ease-in both}.drawer-panel{height:100%;overflow-y:auto;padding:24px;background:var(--surface-1)}@keyframes drawer-in{0%{transform:translate(100%)}to{transform:translate(0)}}@keyframes drawer-out{0%{transform:translate(0)}to{transform:translate(100%)}}@keyframes drawer-backdrop-in{0%{opacity:0}to{opacity:1}}@keyframes drawer-backdrop-out{0%{opacity:1}to{opacity:0}}dl{font-size:12px;line-height:1.9;margin:20px 0}dt{font-size:10px;color:var(--muted);margin-top:15px}dd{margin:4px 0 0;overflow-wrap:anywhere}.form-label{display:flex;flex-direction:column;gap:9px;font-size:11px;margin-top:20px}.form-label input{padding:12px}.error{background:#1f0b09;color:var(--danger);padding:12px;font-size:12px;margin:10px 0;line-height:1.7}.success-mark{display:grid;place-items:center;width:52px;height:52px;background:#061b0d;color:var(--success);border-radius:50%;margin:20px 0}.operation-dialog>p{line-height:1.9;margin-bottom:20px}.startup{padding:60px 24px}.registration-gate{display:flex;flex-direction:column;align-items:flex-start;gap:18px;max-width:520px;min-height:560px;padding:clamp(72px,14vh,148px) clamp(24px,7vw,72px)}.registration-gate>svg{color:var(--success)}.registration-gate p{max-width:42ch;color:var(--muted);font-size:14px;line-height:1.8}.registration-gate button{display:inline-flex;align-items:center;gap:8px}.registration-gate small{color:var(--muted);font-size:12px}.startup h1{margin:20px 0}.startup p{margin-bottom:20px}.asset strong small{display:block;margin-top:5px;color:var(--muted);font-weight:400}.data-warnings{padding-left:18px;color:var(--warning);font-size:12px;line-height:1.8}main{font-size:14px;line-height:1.55}main :is(.notice,.balance-section p,.mono,.muted,.text-button,.role-strip span,.event-main strong,.event-end strong,.empty,.filters .select-trigger,.filters .select-menu,.facts strong,.price small,.endpoint code,.actions button,.rejection,.tabs button,.asset,.receipt-row,.description,.setting-row,.privacy,.data-warnings){font-size:13px}main :is(.eyebrow,.metrics span,.role-strip small,.event-main small,.badge,.facts span:first-child,.endpoint,.list-count,.wallet-addresses span,.wallet-addresses code,.receipt-row small,.footnote,.setting-row small){font-size:12px}.drawer-panel{font-size:14px;line-height:1.55}.drawer-panel :is(.eyebrow,dt,.badge){font-size:12px}.drawer-panel :is(.notice,dl){font-size:13px}@media(max-width:680px){.workspace{display:block}aside{padding:8px 14px;background:var(--background);border-right:0;border-bottom:1px solid var(--line)}.account-menu{display:flex;align-items:center;gap:10px;padding:4px 0 10px;margin-bottom:4px}.account-row{width:min(210px,62vw)}.account-meta{margin:0}.account-meta>span:last-child,.account-meta>span[aria-hidden]{display:none}nav{flex-direction:row;overflow-x:auto;gap:4px;scrollbar-width:thin}nav button{white-space:nowrap;min-height:44px;padding:10px 12px;font-size:13px;gap:8px}nav button svg{width:17px;height:17px}nav button b{display:none}main{padding:22px 20px}.account-picker .select-trigger{min-height:36px}.metrics{gap:7px}.balance-section h2{font-size:36px}.event-icon{display:none}}@media(prefers-reduced-motion:reduce){*{transition:none!important;animation-duration:.01ms!important;animation-iteration-count:1!important;scroll-behavior:auto!important}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{M as d,L as h}from"./assets/data-YT0JVIX1.js";const u="/_onchain-os-console";function f(t){try{const e=new URL(t);return e.protocol==="https:"&&["okx.ai","www.okx.ai"].includes(e.hostname)&&!e.port}catch{return!1}}function m(t){try{const e=new URL(t);return f(t)&&(e.pathname===u||e.pathname===`${u}/`)}catch{return!1}}const s=new h({getAll:()=>chrome.storage.local.get(null),set:async(t,e)=>{await chrome.storage.local.set({[t]:e})}}),w=new d(s),E="com.okx.onchain_console";let a,c;const i=new Map;function L(){if(c)return c;const t=chrome.runtime.connectNative(E);return c=t,t.onMessage.addListener(e=>{const r=i.get(e==null?void 0:e.requestId);r&&(i.delete(e.requestId),e.ok?r.resolve(e.data):r.reject(new Error(e.error??"本机数据查询失败。")))}),t.onDisconnect.addListener(()=>{var n;const e=(n=chrome.runtime.lastError)==null?void 0:n.message;c===t&&(c=void 0);const r=new Error(`无法连接本机数据服务,请运行 npm run companion:install 后重新加载扩展。${e?`(${e})`:""}`);i.forEach(({reject:o})=>o(r)),i.clear()}),t}function S(t){var e;if(t.id!==chrome.runtime.id||!m(((e=t.tab)==null?void 0:e.url)??""))return!1;try{const r=new URL(t.url??""),n=new URL(chrome.runtime.getURL("index.html"));return r.origin===n.origin&&r.pathname===n.pathname}catch{return!1}}async function l(){const t=crypto.randomUUID();return a=await new Promise((e,r)=>{i.set(t,{resolve:e,reject:r});try{L().postMessage({version:1,requestId:t,method:"snapshot"})}catch(n){i.delete(t),c=void 0,r(n)}}),a}chrome.storage.local.setAccessLevel({accessLevel:"TRUSTED_CONTEXTS"});chrome.runtime.onMessage.addListener((t,e,r)=>S(e)?((async()=>{switch(t==null?void 0:t.type){case"SNAPSHOT":return l();case"HISTORY":return s.list(t.accountId);case"SELECTED":return s.getSelectedAccount();case"SELECT":if(!(a??await l()).accounts.some(o=>o.id===t.accountId))throw new Error("账户不存在");return s.selectAccount(t.accountId);case"REHEARSE":if((a==null?void 0:a.mode)==="live")throw new Error("真实数据模式当前只读,未执行任何外部操作。");return w.rehearse(t.draft,t.confirmed===!0);default:throw new Error("不支持的请求")}})().then(o=>r({ok:!0,data:o}),o=>r({ok:!1,error:o instanceof Error?o.message:"本地操作失败"})),!0):void 0);
|
package/dist/content.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){"use strict";const c="/_onchain-os-console";function u(e){try{const t=new URL(e);return t.protocol==="https:"&&["okx.ai","www.okx.ai"].includes(t.hostname)&&!t.port}catch{return!1}}function h(e){try{const t=new URL(e);return u(e)&&(t.pathname===c||t.pathname===`${c}/`)}catch{return!1}}function g(e){const t=e.match(/(?:^|;\s*)locale=([^;]*)/i);if(!t)return"";try{return decodeURIComponent(t[1])}catch{return t[1]}}function m(e="",t="",o=""){const i=`${g(o)} ${e} ${t}`.toLowerCase();return/zh[-_]?(hant|tw|hk|mo)|zh-hant/.test(i)?"zh-Hant":/^en|\/en(?:\/|$)/.test(i)?"en":"zh-Hans"}const p={"zh-Hans":{pages:["总览","身份与审核","服务","调用与任务","钱包与流水","争议与评价","操作记录","设置"],console:"控制台",loading:"正在加载…",reload:"重新加载",registrationTitle:"需要先注册身份",registrationBody:"当前账户尚未完成 OKX.AI 身份注册。完成注册后,控制台会显示与你账户关联的 Agent、服务和活动数据。",registrationAction:"前往注册教程",registrationHint:"注册完成后,返回此页并刷新数据。",connection:"需连接",live:"实时",demo:"演示",account:"切换账户",refresh:"刷新数据",navigation:"主导航",readonly:"数据来自本机 OnchainOS 与 OKX.AI,只读展示。",mock:"所有数据均为模拟,不会提交到 OKX 或链上。",close:"关闭",roleFilter:"角色筛选",allRoles:"全部角色",statusFilter:"状态筛选",allStatus:"全部状态",timeRange:"时间范围",allTime:"全部时间",recent7:"近 7 天",recent30:"近 30 天",walletTotal:"钱包总资产",addressUnavailable:"地址未提供",viewWallet:"查看钱包",identities:"Agent 身份",attention:"待处理事项",services:"ASP 服务",identityWorkspace:"身份工作区",manageIdentities:"管理身份",items:e=>`${e} 项`,empty:"暂无匹配记录,试试调整筛选条件。"},"zh-Hant":{pages:["總覽","身份與審核","服務","調用與任務","錢包與流水","爭議與評價","操作記錄","設定"],console:"控制台",loading:"正在載入…",reload:"重新載入",registrationTitle:"需要先註冊身份",registrationBody:"目前帳戶尚未完成 OKX.AI 身份註冊。完成註冊後,控制台會顯示與帳戶相關的 Agent、服務和活動資料。",registrationAction:"前往註冊教學",registrationHint:"完成註冊後,返回此頁並重新整理資料。",connection:"需要連線",live:"即時",demo:"示範",account:"切換帳戶",refresh:"重新整理資料",navigation:"主導覽",readonly:"資料來自本機 OnchainOS 與 OKX.AI,僅供檢視。",mock:"所有資料均為模擬,不會提交到 OKX 或鏈上。",close:"關閉",roleFilter:"角色篩選",allRoles:"全部角色",statusFilter:"狀態篩選",allStatus:"全部狀態",timeRange:"時間範圍",allTime:"所有時間",recent7:"近 7 天",recent30:"近 30 天",walletTotal:"錢包總資產",addressUnavailable:"未提供地址",viewWallet:"查看錢包",identities:"Agent 身份",attention:"待處理事項",services:"ASP 服務",identityWorkspace:"身份工作區",manageIdentities:"管理身份",items:e=>`${e} 項`,empty:"暫無相符記錄,請嘗試調整篩選條件。"},en:{pages:["Overview","Identities","Services","Calls & tasks","Wallet","Disputes","Activity","Settings"],console:"Console",loading:"Loading…",reload:"Reload",registrationTitle:"Register an identity first",registrationBody:"This account has not completed OKX.AI identity registration. Once registered, the console can show the Agents, services, and activity associated with it.",registrationAction:"Open registration tutorial",registrationHint:"Return to this page and refresh after registration.",connection:"Connection needed",live:"Live",demo:"Demo",account:"Switch account",refresh:"Refresh data",navigation:"Main navigation",readonly:"Read-only data from local OnchainOS and OKX.AI.",mock:"All data is simulated and is never submitted to OKX or onchain.",close:"Close",roleFilter:"Role",allRoles:"All roles",statusFilter:"Status",allStatus:"All statuses",timeRange:"Time range",allTime:"All time",recent7:"Last 7 days",recent30:"Last 30 days",walletTotal:"Total wallet value",addressUnavailable:"Address unavailable",viewWallet:"View wallet",identities:"Agent identities",attention:"Needs attention",services:"ASP services",identityWorkspace:"Identity workspace",manageIdentities:"Manage identities",items:e=>`${e} items`,empty:"No matching records. Try adjusting the filters."}},f="https://www.okx.ai/zh-hant/tutorial";function y(e){return`${p[e].console} ↗`}function b(e){const t=document.createElement("span");t.id="onchain-console-entry";const o=t.attachShadow({mode:"closed"}),i=document.createElement("style");i.textContent=':host{display:inline-flex;flex:0 0 auto;margin-inline:12px;align-self:center;z-index:1000}button{font:500 14px "PingFang SC",sans-serif;background:transparent;color:inherit;border:1px solid currentColor;border-radius:20px;padding:8px 16px;cursor:pointer;white-space:nowrap}button:hover{opacity:.7}button:focus-visible{outline:2px solid #279767;outline-offset:3px}:host([data-current]) button{font-weight:600}:host([data-floating]){position:fixed;right:20px;top:14px;color:#202a25;background:#f8faf8;border-radius:20px;box-shadow:0 1px 5px #0002}@media(max-width:767px){:host{display:none}}';const a=document.createElement("button"),n=()=>{typeof document>"u"||(a.textContent=y(m(document.documentElement.lang,location.pathname,document.cookie)))};n(),a.title="Onchain OS Console",e&&(t.setAttribute("data-current",""),a.setAttribute("aria-current","page")),a.addEventListener("click",()=>{e||location.assign(new URL(c,location.origin))}),o.append(i,a);const l=()=>{if(typeof document>"u")return;const r=document.querySelector("header")??document.querySelector('[role="banner"]'),d=(r==null?void 0:r.querySelector("nav"))??r;d?(t.removeAttribute("data-floating"),t.parentElement!==d&&d.append(t)):t.isConnected||(t.setAttribute("data-floating",""),document.body.append(t))};l();let s=!1;new MutationObserver(()=>{s||(s=!0,requestAnimationFrame(()=>{s=!1,l()}))}).observe(document.body,{childList:!0,subtree:!0}),new MutationObserver(n).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"]})}function w(){const e=document.createElement("div");e.id="onchain-console-page",e.style.cssText="display:block!important;width:100%!important;min-height:560px!important;background:#000!important";const t=e.attachShadow({mode:"closed"}),o=document.createElement("iframe"),i=()=>{if(typeof document>"u")return;const n=new URL(chrome.runtime.getURL("index.html"));n.searchParams.set("locale",m(document.documentElement.lang,location.pathname,document.cookie)),o.src!==n.href&&(o.src=n.href)};i(),o.title="Onchain OS Console",o.scrolling="no",o.style.cssText="display:block;width:100%;height:100%;border:0;background:#000",t.append(o),window.addEventListener("message",n=>{var s,r;if(n.source!==o.contentWindow||((s=n.data)==null?void 0:s.source)!=="onchain-console"||!["RESIZE","OPEN_TUTORIAL"].includes((r=n.data)==null?void 0:r.type))return;if(n.data.type==="OPEN_TUTORIAL"){location.assign(f);return}const l=Number(n.data.height);Number.isFinite(l)&&(e.style.height=`${Math.min(Math.max(l,560),1e5)}px`)});const a=()=>{if(typeof document>"u")return;const n=document.querySelector(".okx-ai-404-container");n&&e.parentElement!==n&&n.replaceChildren(e)};a(),new MutationObserver(a).observe(document.documentElement,{childList:!0,subtree:!0}),new MutationObserver(i).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"]})}if(u(location.href)){const e=h(location.href);b(e),e&&w()}})();
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/index.html
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<link rel="icon" href="./icons/icon-32.png" />
|
|
7
|
+
<title>Onchain OS Console · 演示</title>
|
|
8
|
+
<script type="module" crossorigin src="./sidepanel.js"></script>
|
|
9
|
+
<link rel="modulepreload" crossorigin href="./assets/data-YT0JVIX1.js">
|
|
10
|
+
<link rel="stylesheet" crossorigin href="./assets/sidepanel-Bl_Aq3uM.css">
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<div id="root"></div>
|
|
14
|
+
</body>
|
|
15
|
+
</html>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"manifest_version": 3,
|
|
3
|
+
"name": "Onchain OS Console",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk0PLRnak4oaeN5zem/ZgobfvCEEvq3kvaAQtzcEMd8pS68UQ/j68wsSS0jUa3L2hmwRkBF19j4Qtr5FHr31ZmcgC268hf6Bn75ZfT+6rPGXx+MeDMo/EesdETcf3LuHKDaeqyAZivGu85O5YlP2aOAhEi4Z4HNHbBGcHd2xFK9cvxgPu/QlURBwINZbKa9wb1xp/ChKrAgL4OtHgJWlqPxVZGnjHiXkz21h1bq5kyECUGMWtLn3btXvfyXU/n7/WQmOE568HXGLL9E4okEU8JK+HfOcarAmKyIBBbCkSDpxVPCsV95hCZ+2es5SupK+D9NfnicXRgocqrsM76qH5AwIDAQAB",
|
|
6
|
+
"minimum_chrome_version": "116",
|
|
7
|
+
"description": "A local, read-only personal console for OnchainOS data inside OKX.AI.",
|
|
8
|
+
"icons": {
|
|
9
|
+
"16": "icons/icon-16.png",
|
|
10
|
+
"32": "icons/icon-32.png",
|
|
11
|
+
"48": "icons/icon-48.png",
|
|
12
|
+
"128": "icons/icon-128.png"
|
|
13
|
+
},
|
|
14
|
+
"permissions": ["nativeMessaging", "storage"],
|
|
15
|
+
"host_permissions": ["https://okx.ai/*", "https://www.okx.ai/*"],
|
|
16
|
+
"background": { "service_worker": "background.js", "type": "module" },
|
|
17
|
+
"web_accessible_resources": [
|
|
18
|
+
{
|
|
19
|
+
"resources": ["index.html"],
|
|
20
|
+
"matches": ["https://okx.ai/*", "https://www.okx.ai/*"]
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"content_scripts": [
|
|
24
|
+
{
|
|
25
|
+
"matches": ["https://okx.ai/*", "https://www.okx.ai/*"],
|
|
26
|
+
"js": ["content.js"],
|
|
27
|
+
"run_at": "document_idle"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"content_security_policy": {
|
|
31
|
+
"extension_pages": "script-src 'self'; object-src 'none'; connect-src 'none'"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
Binary file
|
|
Binary file
|