@stelis/say-ur-intent 0.0.3 → 0.0.4

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.
@@ -1,6 +1,7 @@
1
1
  import { hashEventValue } from "../eventlog/sink.js";
2
2
  import { cloneLocalSession, createLocalSessionBase, isLocalSessionExpired, tokenMatchesHash } from "./localSession.js";
3
3
  import { SessionStoreError } from "./sessionErrors.js";
4
+ import { InMemoryKeyedRecordStore } from "./keyedRecordStore.js";
4
5
  import { isTerminalWalletIdentityStatus, walletIdentityResultInputSchema, walletIdentitySessionSchema } from "./walletIdentity.js";
5
6
  const ALLOWED_WALLET_IDENTITY_TRANSITIONS = {
6
7
  pending: ["opened", "expired"],
@@ -29,9 +30,10 @@ function parseWalletIdentitySession(session) {
29
30
  }
30
31
  export class WalletIdentitySessionManager {
31
32
  options;
32
- sessions = new Map();
33
+ sessions;
33
34
  constructor(options) {
34
35
  this.options = options;
36
+ this.sessions = options.recordStore ?? new InMemoryKeyedRecordStore();
35
37
  }
36
38
  async create(now) {
37
39
  const { base, token } = createLocalSessionBase(now, this.options.ttlMs);
@@ -60,7 +62,7 @@ export class WalletIdentitySessionManager {
60
62
  }
61
63
  async list(now) {
62
64
  const sessions = [];
63
- for (const id of this.sessions.keys()) {
65
+ for (const id of this.sessions.ids()) {
64
66
  const session = await this.get(id, now);
65
67
  if (session) {
66
68
  sessions.push(session);
@@ -1 +1 @@
1
- import{n as e,r as t,t as n}from"./http-DMvwuuFk.js";import{a as r,c as i,i as a,n as o,o as s,r as c}from"./walletStatus-CcojOdGy.js";var l=document.querySelector(`#analysis-app`);if(!l)throw Error(`analysis app root missing`);var u=l,d=u.dataset.walletSessionId??``,f=window.location.hash.startsWith(`#`)?window.location.hash.slice(1):``,p=r(),m=!1,h=!1,g=!1,_,v=s();v&&window.setTimeout(()=>{v=!1,y()},2e3),S(`opened`).then(()=>y()).catch(e=>{_=t(e,`The local review server did not accept this wallet session.`),y()}),p.stores.$wallets.subscribe(()=>y()),p.stores.$connection.subscribe(()=>y());function y(){let e=p.stores.$connection.get(),n=p.stores.$wallets.get();u.innerHTML=``;let r=document.createElement(`section`);r.className=`wallet-shell`;let i=document.createElement(`h1`);i.textContent=`Say Ur Intent Analysis`,r.append(i);let a=document.createElement(`p`);a.textContent=`Connect a Sui mainnet wallet to provide the account address used for account-bound checks, then view a wallet asset snapshot and your stored local review records. This page only captures an address and prepares no transaction.`,r.append(a);let o=document.createElement(`p`);if(o.className=`status`,o.setAttribute(`aria-live`,`polite`),o.setAttribute(`aria-atomic`,`true`),o.textContent=P(),r.append(o),_){let e=document.createElement(`p`);e.className=`error`,e.textContent=`Return to your AI client and request a new wallet identity URL.`,r.append(e)}if(!f){let e=document.createElement(`p`);e.className=`error`,e.textContent=`Missing wallet session token. Open the wallet URL from your AI client again.`,r.append(e)}else if(e.status===`connected`){v=!1;let t=document.createElement(`p`);t.className=`success`,t.textContent=`Connected address: ${e.account.address}`,r.append(t);let n=document.createElement(`button`);n.type=`button`,n.className=`secondary`,n.disabled=h||g,n.textContent=`Disconnect / switch wallet`,n.onclick=()=>{p.disconnectWallet().then(()=>y())},r.append(n),r.append(O()),M()}else if(v||e.status===`connecting`){let e=document.createElement(`p`);e.className=`status`,e.textContent=`Reconnecting your wallet…`,r.append(e)}else if(n.length===0){let e=document.createElement(`p`);e.className=`error`,e.textContent=`No compatible Sui wallet was detected in this browser.`,r.append(e);let n=document.createElement(`button`);n.type=`button`,n.disabled=g,n.textContent=`Report no compatible wallet`,n.onclick=()=>{x(c()).then(()=>y()).catch(e=>{_=t(e,`The local review server did not accept this wallet identity result.`),y()})},r.append(n)}else{let e=document.createElement(`div`);e.className=`wallet-list`;for(let t of n){let n=document.createElement(`button`);n.type=`button`,n.disabled=h,n.textContent=t.name,n.onclick=()=>b(t),e.append(n)}r.append(e)}u.append(r)}async function b(e){if(h||g||m)return;h=!0,_=void 0,y();try{await S(`connecting`)}catch(e){_=t(e,`The local review server did not accept this wallet session.`),h=!1,y();return}let n;try{let t=(await p.connectWallet({wallet:e})).accounts[0];n=o(t,{walletName:e.name,walletId:i(e)})}catch(t){n=a(t,{walletName:e.name,walletId:i(e)})}try{await x(n)}catch(e){_=t(e,`The local review server did not accept this wallet identity result.`)}finally{h=!1,y()}}async function x(e){if(!(m||g)){g=!0,_=void 0,y();try{await C(`/api/wallet/${encodeURIComponent(d)}/result`,e),m=!0}finally{g=!1}}}async function S(e){f&&await C(`/api/wallet/${encodeURIComponent(d)}/${e}`,{})}async function C(t,r){let i=await fetch(t,{method:`POST`,headers:{"content-type":`application/json`,"x-say-ur-intent-token":f},body:JSON.stringify(r)});if(!i.ok)throw new n(i.status,await e(i))}var w=!1,T,E,D;function O(){let e=document.createElement(`div`);e.className=`analysis-panels`,e.append(k(`Wallet asset snapshot`,A())),e.append(k(`Local review records`,j()));let t=document.createElement(`p`);return t.className=`boundary-note`,t.textContent=`These panels show a wallet asset snapshot at its fetched time and stored local review records. They are not P&L, not tax or cost-basis data, not payment readiness, and not signing readiness.`,e.append(t),e}function k(e,t){let n=document.createElement(`section`);n.className=`analysis-panel`;let r=document.createElement(`h2`);return r.textContent=e,n.append(r),n.append(t),n}function A(){let e=document.createElement(`div`);if(D)return e.textContent=D,e;if(!T)return e.textContent=`Loading wallet asset snapshot from the local server.`,e;let t=typeof T.fetchedAt==`string`?T.fetchedAt:void 0;if(t){let n=document.createElement(`p`);n.textContent=`Checked at ${t}`,e.append(n)}let n=Array.isArray(T.balances)?T.balances:[];if(n.length===0){let t=document.createElement(`p`);return t.textContent=`No coin balances were returned for this account snapshot.`,e.append(t),e}let r=document.createElement(`ul`);for(let e of n){if(typeof e!=`object`||!e)continue;let t=e,n=document.createElement(`li`),i=typeof t.symbol==`string`?t.symbol:`(unknown symbol)`,a=typeof t.display==`string`?t.display:void 0,o=typeof t.raw==`string`?t.raw:void 0;n.textContent=a===void 0?`${i}: raw ${o??`unavailable`}`:`${i}: ${a}`,r.append(n)}return e.append(r),e}function j(){let e=document.createElement(`div`);if(D)return e.textContent=D,e;if(!E)return e.textContent=`Loading stored local review records from the local server.`,e;let t=document.createElement(`ul`);for(let[e,n]of Object.entries(E)){if(typeof n!=`number`&&typeof n!=`string`)continue;let r=document.createElement(`li`);r.textContent=`${e}: ${n}`,t.append(r)}return t.childElementCount===0?(e.textContent=`No stored local review records were returned.`,e):(e.append(t),e)}async function M(){if(!w){w=!0;try{let[e,t]=await Promise.all([N(`/api/analysis/${encodeURIComponent(d)}/assets`),N(`/api/analysis/${encodeURIComponent(d)}/review-activity`)]);T=e,E=t}catch(e){D=t(e,`The local server could not return analysis data for this session.`)}y()}}async function N(t){let r=await fetch(t,{headers:{"x-say-ur-intent-token":f}});if(!r.ok)throw new n(r.status,await e(r));return await r.json()}function P(){return _||(m?`Wallet identity result was sent to the local server.`:g?`Sending wallet identity result to the local server.`:h?`Finish or cancel the request in your wallet popup.`:`Choose a wallet to continue.`)}
1
+ import{n as e,r as t,t as n}from"./http-DMvwuuFk.js";import{a as r,c as i,i as a,n as o,o as s,r as c}from"./walletStatus-YODe5Y4P.js";var l=document.querySelector(`#analysis-app`);if(!l)throw Error(`analysis app root missing`);var u=l,d=u.dataset.walletSessionId??``,f=window.location.hash.startsWith(`#`)?window.location.hash.slice(1):``,p=r(),m=!1,h=!1,g=!1,_,v=s();v&&window.setTimeout(()=>{v=!1,y()},2e3),S(`opened`).then(()=>y()).catch(e=>{_=t(e,`The local review server did not accept this wallet session.`),y()}),p.stores.$wallets.subscribe(()=>y()),p.stores.$connection.subscribe(()=>y());function y(){let e=p.stores.$connection.get(),n=p.stores.$wallets.get();u.innerHTML=``;let r=document.createElement(`section`);r.className=`wallet-shell`;let i=document.createElement(`h1`);i.textContent=`Say Ur Intent Analysis`,r.append(i);let a=document.createElement(`p`);a.textContent=`Connect a Sui mainnet wallet to provide the account address used for account-bound checks, then view a wallet asset snapshot and your stored local review records. This page only captures an address and prepares no transaction.`,r.append(a);let o=document.createElement(`p`);if(o.className=`status`,o.setAttribute(`aria-live`,`polite`),o.setAttribute(`aria-atomic`,`true`),o.textContent=P(),r.append(o),_){let e=document.createElement(`p`);e.className=`error`,e.textContent=`Return to your AI client and request a new wallet identity URL.`,r.append(e)}if(!f){let e=document.createElement(`p`);e.className=`error`,e.textContent=`Missing wallet session token. Open the wallet URL from your AI client again.`,r.append(e)}else if(e.status===`connected`){v=!1;let t=document.createElement(`p`);t.className=`success`,t.textContent=`Connected address: ${e.account.address}`,r.append(t);let n=document.createElement(`button`);n.type=`button`,n.className=`secondary`,n.disabled=h||g,n.textContent=`Disconnect / switch wallet`,n.onclick=()=>{p.disconnectWallet().then(()=>y())},r.append(n),r.append(O()),M()}else if(v||e.status===`connecting`){let e=document.createElement(`p`);e.className=`status`,e.textContent=`Reconnecting your wallet…`,r.append(e)}else if(n.length===0){let e=document.createElement(`p`);e.className=`error`,e.textContent=`No compatible Sui wallet was detected in this browser.`,r.append(e);let n=document.createElement(`button`);n.type=`button`,n.disabled=g,n.textContent=`Report no compatible wallet`,n.onclick=()=>{x(c()).then(()=>y()).catch(e=>{_=t(e,`The local review server did not accept this wallet identity result.`),y()})},r.append(n)}else{let e=document.createElement(`div`);e.className=`wallet-list`;for(let t of n){let n=document.createElement(`button`);n.type=`button`,n.disabled=h,n.textContent=t.name,n.onclick=()=>b(t),e.append(n)}r.append(e)}u.append(r)}async function b(e){if(h||g||m)return;h=!0,_=void 0,y();try{await S(`connecting`)}catch(e){_=t(e,`The local review server did not accept this wallet session.`),h=!1,y();return}let n;try{let t=(await p.connectWallet({wallet:e})).accounts[0];n=o(t,{walletName:e.name,walletId:i(e)})}catch(t){n=a(t,{walletName:e.name,walletId:i(e)})}try{await x(n)}catch(e){_=t(e,`The local review server did not accept this wallet identity result.`)}finally{h=!1,y()}}async function x(e){if(!(m||g)){g=!0,_=void 0,y();try{await C(`/api/wallet/${encodeURIComponent(d)}/result`,e),m=!0}finally{g=!1}}}async function S(e){f&&await C(`/api/wallet/${encodeURIComponent(d)}/${e}`,{})}async function C(t,r){let i=await fetch(t,{method:`POST`,headers:{"content-type":`application/json`,"x-say-ur-intent-token":f},body:JSON.stringify(r)});if(!i.ok)throw new n(i.status,await e(i))}var w=!1,T,E,D;function O(){let e=document.createElement(`div`);e.className=`analysis-panels`,e.append(k(`Wallet asset snapshot`,A())),e.append(k(`Local review records`,j()));let t=document.createElement(`p`);return t.className=`boundary-note`,t.textContent=`These panels show a wallet asset snapshot at its fetched time and stored local review records. They are not P&L, not tax or cost-basis data, not payment readiness, and not signing readiness.`,e.append(t),e}function k(e,t){let n=document.createElement(`section`);n.className=`analysis-panel`;let r=document.createElement(`h2`);return r.textContent=e,n.append(r),n.append(t),n}function A(){let e=document.createElement(`div`);if(D)return e.textContent=D,e;if(!T)return e.textContent=`Loading wallet asset snapshot from the local server.`,e;let t=typeof T.fetchedAt==`string`?T.fetchedAt:void 0;if(t){let n=document.createElement(`p`);n.textContent=`Checked at ${t}`,e.append(n)}let n=Array.isArray(T.balances)?T.balances:[];if(n.length===0){let t=document.createElement(`p`);return t.textContent=`No coin balances were returned for this account snapshot.`,e.append(t),e}let r=document.createElement(`ul`);for(let e of n){if(typeof e!=`object`||!e)continue;let t=e,n=document.createElement(`li`),i=typeof t.symbol==`string`?t.symbol:`(unknown symbol)`,a=typeof t.display==`string`?t.display:void 0,o=typeof t.raw==`string`?t.raw:void 0;n.textContent=a===void 0?`${i}: raw ${o??`unavailable`}`:`${i}: ${a}`,r.append(n)}return e.append(r),e}function j(){let e=document.createElement(`div`);if(D)return e.textContent=D,e;if(!E)return e.textContent=`Loading stored local review records from the local server.`,e;let t=document.createElement(`ul`);for(let[e,n]of Object.entries(E)){if(typeof n!=`number`&&typeof n!=`string`)continue;let r=document.createElement(`li`);r.textContent=`${e}: ${n}`,t.append(r)}return t.childElementCount===0?(e.textContent=`No stored local review records were returned.`,e):(e.append(t),e)}async function M(){if(!w){w=!0;try{let[e,t]=await Promise.all([N(`/api/analysis/${encodeURIComponent(d)}/assets`),N(`/api/analysis/${encodeURIComponent(d)}/review-activity`)]);T=e,E=t}catch(e){D=t(e,`The local server could not return analysis data for this session.`)}y()}}async function N(t){let r=await fetch(t,{headers:{"x-say-ur-intent-token":f}});if(!r.ok)throw new n(r.status,await e(r));return await r.json()}function P(){return _||(m?`Wallet identity result was sent to the local server.`:g?`Sending wallet identity result to the local server.`:h?`Finish or cancel the request in your wallet popup.`:`Choose a wallet to continue.`)}
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["info-NVLQJR56-Dlx1nZic.js","chunk-FPAJGGOC-DDHjQ09H.js","chunk-BJD4TVEz.js","review.js","chunk-ABZYJK2D-Dt4W53JI.js","src-Buml7cM5.js","chunk-JA3XYJ7Z-C5ZJdU01.js","chunk-S3R3BYOJ-BWvOhDs0.js","dist-WPc74x_f.js","math-kmyYrkHL.js","identity-DY8PXc6t.js","walletStatus-CcojOdGy.js","chunk-ATLVNIR6-fZHLXURb.js","chunk-CVBHYZKI-CViawAKX.js","chunk-HN2XXSSU-yzNpjaSZ.js","chunk-JZLCHNYA-BBST4Cnk.js","chunk-QXUST7PY-DKM2-t2c.js","line-DiIv3Jgw.js","path-AEo9W6mQ.js","array-BmXUUrU6.js","http-DMvwuuFk.js","review.css","reduce-B-HuPpdd.js","flatten-DHf9IeNI.js","chunk-LBM3YZW2-CdwAPuHr.js","packet-BFZMPI3H-DqbnU92v.js","chunk-76Q3JFCE-cK_X1P_l.js","pie-7BOR55EZ-LJzaLkgr.js","chunk-T53DSG4Q-C1qEyzyV.js","architecture-U656AL7Q-aSB9x1OK.js","chunk-O7ZBX7Z2-pxdK4Sa3.js","gitGraph-F6HP7TQM-DsAD6qK1.js","chunk-S6J4BHB3-D9Fk0YeD.js","radar-NHE76QYJ-DBpHc8_Y.js","chunk-LHMN2FUI-BtB5uDcp.js","treemap-KMMF4GRG-wnVLBDeQ.js","chunk-FWNWRKHM-CVVQUptk.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["info-NVLQJR56-Dlx1nZic.js","chunk-FPAJGGOC-DDHjQ09H.js","chunk-BJD4TVEz.js","review.js","chunk-ABZYJK2D-Dt4W53JI.js","src-Buml7cM5.js","chunk-JA3XYJ7Z-C5ZJdU01.js","chunk-S3R3BYOJ-BWvOhDs0.js","dist-WPc74x_f.js","math-kmyYrkHL.js","identity-DY8PXc6t.js","walletStatus-YODe5Y4P.js","chunk-ATLVNIR6-fZHLXURb.js","chunk-CVBHYZKI-CViawAKX.js","chunk-HN2XXSSU-yzNpjaSZ.js","chunk-JZLCHNYA-BBST4Cnk.js","chunk-QXUST7PY-DKM2-t2c.js","line-DiIv3Jgw.js","path-AEo9W6mQ.js","array-BmXUUrU6.js","http-DMvwuuFk.js","review.css","reduce-B-HuPpdd.js","flatten-DHf9IeNI.js","chunk-LBM3YZW2-CdwAPuHr.js","packet-BFZMPI3H-DqbnU92v.js","chunk-76Q3JFCE-cK_X1P_l.js","pie-7BOR55EZ-LJzaLkgr.js","chunk-T53DSG4Q-C1qEyzyV.js","architecture-U656AL7Q-aSB9x1OK.js","chunk-O7ZBX7Z2-pxdK4Sa3.js","gitGraph-F6HP7TQM-DsAD6qK1.js","chunk-S6J4BHB3-D9Fk0YeD.js","radar-NHE76QYJ-DBpHc8_Y.js","chunk-LHMN2FUI-BtB5uDcp.js","treemap-KMMF4GRG-wnVLBDeQ.js","chunk-FWNWRKHM-CVVQUptk.js"])))=>i.map(i=>d[i]);
2
2
  import{X as e}from"./chunk-ABZYJK2D-Dt4W53JI.js";import{f as t}from"./chunk-FPAJGGOC-DDHjQ09H.js";import"./chunk-O7ZBX7Z2-pxdK4Sa3.js";import"./chunk-S6J4BHB3-D9Fk0YeD.js";import"./chunk-LBM3YZW2-CdwAPuHr.js";import"./chunk-76Q3JFCE-cK_X1P_l.js";import"./chunk-T53DSG4Q-C1qEyzyV.js";import"./chunk-LHMN2FUI-BtB5uDcp.js";import"./chunk-FWNWRKHM-CVVQUptk.js";var n={},r={info:t(async()=>{let{createInfoServices:t}=await e(async()=>{let{createInfoServices:e}=await import(`./info-NVLQJR56-Dlx1nZic.js`);return{createInfoServices:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]));n.info=t().Info.parser.LangiumParser},`info`),packet:t(async()=>{let{createPacketServices:t}=await e(async()=>{let{createPacketServices:e}=await import(`./packet-BFZMPI3H-DqbnU92v.js`);return{createPacketServices:e}},__vite__mapDeps([25,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,26]));n.packet=t().Packet.parser.LangiumParser},`packet`),pie:t(async()=>{let{createPieServices:t}=await e(async()=>{let{createPieServices:e}=await import(`./pie-7BOR55EZ-LJzaLkgr.js`);return{createPieServices:e}},__vite__mapDeps([27,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,28]));n.pie=t().Pie.parser.LangiumParser},`pie`),architecture:t(async()=>{let{createArchitectureServices:t}=await e(async()=>{let{createArchitectureServices:e}=await import(`./architecture-U656AL7Q-aSB9x1OK.js`);return{createArchitectureServices:e}},__vite__mapDeps([29,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,30]));n.architecture=t().Architecture.parser.LangiumParser},`architecture`),gitGraph:t(async()=>{let{createGitGraphServices:t}=await e(async()=>{let{createGitGraphServices:e}=await import(`./gitGraph-F6HP7TQM-DsAD6qK1.js`);return{createGitGraphServices:e}},__vite__mapDeps([31,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,32]));n.gitGraph=t().GitGraph.parser.LangiumParser},`gitGraph`),radar:t(async()=>{let{createRadarServices:t}=await e(async()=>{let{createRadarServices:e}=await import(`./radar-NHE76QYJ-DBpHc8_Y.js`);return{createRadarServices:e}},__vite__mapDeps([33,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,34]));n.radar=t().Radar.parser.LangiumParser},`radar`),treemap:t(async()=>{let{createTreemapServices:t}=await e(async()=>{let{createTreemapServices:e}=await import(`./treemap-KMMF4GRG-wnVLBDeQ.js`);return{createTreemapServices:e}},__vite__mapDeps([35,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,36]));n.treemap=t().Treemap.parser.LangiumParser},`treemap`)};async function i(e,t){let i=r[e];if(!i)throw Error(`Unknown diagram type: ${e}`);n[e]||await i();let o=n[e].parse(t);if(o.lexerErrors.length>0||o.parserErrors.length>0)throw new a(o);return o.value}t(i,`parse`);var a=class extends Error{constructor(e){let t=e.lexerErrors.map(e=>e.message).join(`
3
3
  `),n=e.parserErrors.map(e=>e.message).join(`
4
4
  `);super(`Parsing failed: ${t} ${n}`),this.result=e}static{t(this,`MermaidParseError`)}};export{i as t};