thinkpool-pair 0.7.391 → 0.7.393
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/account-briefs.mjs +1 -1
- package/bridge.mjs +1 -1
- package/claude-session.mjs +1 -1
- package/codex-session.mjs +1 -1
- package/cross-terminal.mjs +1 -1
- package/hermes-session.mjs +1 -1
- package/lane-work-snapshot.mjs +1 -1
- package/package.json +1 -1
- package/publish-manifest.json +14 -14
- package/thinkpool-capabilities.json +7 -7
- package/thinkpool-room-prompt.mjs +1 -1
- package/worker-completion.mjs +1 -1
package/account-briefs.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=(e,t=12e3)=>String(e||"").slice(0,t);export const BRIEF_OWNER_ONLY_REASON="
|
|
1
|
+
const e=(e,t=12e3)=>String(e||"").slice(0,t);export const BRIEF_OWNER_ONLY_REASON="Briefs are private to their owner. This turn was not verified as owner-authored. Ask the Brief owner to make the request, or use Brief content they explicitly shared in the room.";export const BRIEF_AUTHOR_UNVERIFIED_REASON="Briefs stayed private because thinkpool could not verify who authored this turn. Ask the Brief owner to retry the request.";const t=(e,t=BRIEF_OWNER_ONLY_REASON)=>({ok:!1,code:e,reason:t}),r=e=>new Promise(t=>setTimeout(t,e));export function createBriefTurnAccess({cid:e,claimedAuthorId:t,terminalId:r,turnRev:i}={}){return{cid:String(e||""),claimedAuthorId:String(t||""),terminalId:String(r||""),turnRev:Number(i)||0}}export async function verifyBriefTurnAccess({access:e,currentTurnRev:i,ownerUserId:n,roomCode:a,supabaseUrl:o,anonKey:s,token:c,fetchImpl:u=fetch,waitImpl:d=r,retryDelays:h=[0,80,240,600]}={}){if(!e?.cid||!e?.terminalId||!e?.turnRev)return t("missing_turn");if(Number(e.turnRev)!==Number(i))return t("stale_turn");if(!n||!e.claimedAuthorId||e.claimedAuthorId!==n)return t("not_owner");if(!(a&&o&&s&&c))return t("unverified_author",BRIEF_AUTHOR_UNVERIFIED_REASON);const l=new URL("/rest/v1/code_messages",String(o));l.searchParams.set("select","author_id,payload"),l.searchParams.set("session_code",`eq.${a}`),l.searchParams.set("id",`eq.${e.cid}`),l.searchParams.set("limit","1");for(const r of h){let i;Number(r)>0&&await d(Number(r));try{i=await u(l.toString(),{headers:{apikey:s,Authorization:`Bearer ${c}`}})}catch{continue}if(!i?.ok)return t("unverified_author",BRIEF_AUTHOR_UNVERIFIED_REASON);const a=await i.json().catch(()=>[]),o=Array.isArray(a)?a[0]:null;if(!o)continue;if(o.author_id!==n)return t("author_mismatch");const h=o.payload;return!0!==h?.__struct||"you"!==h?.kind||String(h?.cid||"")!==e.cid||String(h?.term||"")!==e.terminalId?t("invalid_turn_record",BRIEF_AUTHOR_UNVERIFIED_REASON):{ok:!0,code:"owner_authored"}}return t("unverified_author",BRIEF_AUTHOR_UNVERIFIED_REASON)}export async function fetchAccountBriefs({webBase:e,token:t,fetchImpl:r=fetch}={}){if(!t)throw new Error("The account bridge is not authenticated, so Briefs cannot be read.");const i=await r(`${String(e||"").replace(/\/$/,"")}/api/briefs`,{headers:{Authorization:`Bearer ${t}`}}),n=await i.json().catch(()=>({}));if(!i.ok)throw new Error(n.error||`Briefs request failed (${i.status})`);return Array.isArray(n.briefs)?n.briefs:[]}export async function listAccountBriefs(t,r={}){return function(e,{view:t="all",pinned:r,since:i,query:n,limit:a=20}={}){const o=null==i?0:Number.isFinite(Number(i))?Number(i):Date.parse(String(i))||0,s=String(n||"").trim().toLowerCase();return(Array.isArray(e)?e:[]).filter(e=>!("inbox"===t&&e.archivedAt||"pinned"===t&&(!e.pinnedAt||e.archivedAt)||"archived"===t&&!e.archivedAt||null!=r&&!!e.pinnedAt!==r||o&&Date.parse(e.updatedAt||e.capturedAt||0)<o||s&&![e.title,e.cleanNote,e.transcript].some(e=>String(e||"").toLowerCase().includes(s)))).slice(0,Math.max(1,Math.min(100,Number(a)||20)))}(await fetchAccountBriefs(t),r).map(t=>({id:t.id,title:e(t.title,240),cleanNote:e(t.cleanNote,1500),actions:t.actions||[],openQuestions:t.openQuestions||[],status:t.status,source:t.source,pinnedAt:t.pinnedAt,archivedAt:t.archivedAt,updatedAt:t.updatedAt}))}export async function searchAccountBriefs(e,t={}){return listAccountBriefs(e,{...t,query:t.query,limit:t.limit||12})}export async function readAccountBrief(t,{id:r}={}){const i=(await fetchAccountBriefs(t)).find(e=>e.id===r);return i?{id:i.id,title:e(i.title,240),cleanNote:e(i.cleanNote),actions:i.actions||[],openQuestions:i.openQuestions||[],transcript:e(i.transcript),cleanup:i.cleanup||{},status:i.status,source:i.source,revision:i.revision,pinnedAt:i.pinnedAt,archivedAt:i.archivedAt,capturedAt:i.capturedAt,updatedAt:i.updatedAt}:null}
|