dsh-open-artifact 0.8.1 → 0.8.2
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/lib/client.js +2 -2
- package/lib/index.js +41 -4
- package/package.json +1 -1
- package/skills/open-artifact/SKILL.md +1 -1
- package/vendor/artifact-types/data/scripts/cli.mjs +1 -1
- package/vendor/artifact-types/data/scripts/editors/data/assets/{index-CZiM2XTm.js → index-B041Zu27.js} +1 -1
- package/vendor/artifact-types/data/scripts/editors/data/index.html +1 -1
- package/vendor/artifact-types/{design/scripts/editors/design/assets/index-jhwXmpbV.js → data/scripts/editors/design/assets/index-D6-vjsn9.js} +1 -1
- package/vendor/artifact-types/data/scripts/editors/design/index.html +1 -1
- package/vendor/artifact-types/{design/scripts/editors/design-system/assets/index-7LPrsXBY.js → data/scripts/editors/design-system/assets/index-BoT2v4hc.js} +1 -1
- package/vendor/artifact-types/data/scripts/editors/design-system/index.html +1 -1
- package/vendor/artifact-types/{design/scripts/editors/slides/assets/index-y09Z-wXP.js → data/scripts/editors/slides/assets/index-b9M479Ro.js} +2 -2
- package/vendor/artifact-types/data/scripts/editors/slides/assets/{src-C48N4IXt.js → src-CxNLgI5_.js} +1 -1
- package/vendor/artifact-types/data/scripts/editors/slides/index.html +1 -1
- package/vendor/artifact-types/{design/scripts/editors/whiteboard/assets/index-DbekE4ru.js → data/scripts/editors/whiteboard/assets/index-TrzGo_VR.js} +1 -1
- package/vendor/artifact-types/data/scripts/editors/whiteboard/index.html +1 -1
- package/vendor/artifact-types/design/scripts/cli.mjs +1 -1
- package/vendor/artifact-types/{slides/scripts/editors/data/assets/index-CZiM2XTm.js → design/scripts/editors/data/assets/index-B041Zu27.js} +1 -1
- package/vendor/artifact-types/design/scripts/editors/data/index.html +1 -1
- package/vendor/artifact-types/{data/scripts/editors/design/assets/index-jhwXmpbV.js → design/scripts/editors/design/assets/index-D6-vjsn9.js} +1 -1
- package/vendor/artifact-types/design/scripts/editors/design/index.html +1 -1
- package/vendor/artifact-types/{design-system/scripts/editors/design-system/assets/index-7LPrsXBY.js → design/scripts/editors/design-system/assets/index-BoT2v4hc.js} +1 -1
- package/vendor/artifact-types/design/scripts/editors/design-system/index.html +1 -1
- package/vendor/artifact-types/{slides/scripts/editors/slides/assets/index-y09Z-wXP.js → design/scripts/editors/slides/assets/index-b9M479Ro.js} +2 -2
- package/vendor/artifact-types/{slides/scripts/editors/slides/assets/src-C48N4IXt.js → design/scripts/editors/slides/assets/src-CxNLgI5_.js} +1 -1
- package/vendor/artifact-types/design/scripts/editors/slides/index.html +1 -1
- package/vendor/artifact-types/{design-system/scripts/editors/whiteboard/assets/index-DbekE4ru.js → design/scripts/editors/whiteboard/assets/index-TrzGo_VR.js} +1 -1
- package/vendor/artifact-types/design/scripts/editors/whiteboard/index.html +1 -1
- package/vendor/artifact-types/design-system/scripts/cli.mjs +1 -1
- package/vendor/artifact-types/{design/scripts/editors/data/assets/index-CZiM2XTm.js → design-system/scripts/editors/data/assets/index-B041Zu27.js} +1 -1
- package/vendor/artifact-types/design-system/scripts/editors/data/index.html +1 -1
- package/vendor/artifact-types/{slides/scripts/editors/design/assets/index-jhwXmpbV.js → design-system/scripts/editors/design/assets/index-D6-vjsn9.js} +1 -1
- package/vendor/artifact-types/design-system/scripts/editors/design/index.html +1 -1
- package/vendor/artifact-types/{data/scripts/editors/design-system/assets/index-7LPrsXBY.js → design-system/scripts/editors/design-system/assets/index-BoT2v4hc.js} +1 -1
- package/vendor/artifact-types/design-system/scripts/editors/design-system/index.html +1 -1
- package/vendor/artifact-types/design-system/scripts/editors/slides/assets/{index-y09Z-wXP.js → index-b9M479Ro.js} +2 -2
- package/vendor/artifact-types/{design/scripts/editors/slides/assets/src-C48N4IXt.js → design-system/scripts/editors/slides/assets/src-CxNLgI5_.js} +1 -1
- package/vendor/artifact-types/design-system/scripts/editors/slides/index.html +1 -1
- package/vendor/artifact-types/{data/scripts/editors/whiteboard/assets/index-DbekE4ru.js → design-system/scripts/editors/whiteboard/assets/index-TrzGo_VR.js} +1 -1
- package/vendor/artifact-types/design-system/scripts/editors/whiteboard/index.html +1 -1
- package/vendor/artifact-types/slides/scripts/cli.mjs +1 -1
- package/vendor/artifact-types/{design-system/scripts/editors/data/assets/index-CZiM2XTm.js → slides/scripts/editors/data/assets/index-B041Zu27.js} +1 -1
- package/vendor/artifact-types/slides/scripts/editors/data/index.html +1 -1
- package/vendor/artifact-types/{design-system/scripts/editors/design/assets/index-jhwXmpbV.js → slides/scripts/editors/design/assets/index-D6-vjsn9.js} +1 -1
- package/vendor/artifact-types/slides/scripts/editors/design/index.html +1 -1
- package/vendor/artifact-types/slides/scripts/editors/design-system/assets/{index-7LPrsXBY.js → index-BoT2v4hc.js} +1 -1
- package/vendor/artifact-types/slides/scripts/editors/design-system/index.html +1 -1
- package/vendor/artifact-types/{data/scripts/editors/slides/assets/index-y09Z-wXP.js → slides/scripts/editors/slides/assets/index-b9M479Ro.js} +2 -2
- package/vendor/artifact-types/{design-system/scripts/editors/slides/assets/src-C48N4IXt.js → slides/scripts/editors/slides/assets/src-CxNLgI5_.js} +1 -1
- package/vendor/artifact-types/slides/scripts/editors/slides/index.html +1 -1
- package/vendor/artifact-types/slides/scripts/editors/whiteboard/assets/{index-DbekE4ru.js → index-TrzGo_VR.js} +1 -1
- package/vendor/artifact-types/slides/scripts/editors/whiteboard/index.html +1 -1
- package/vendor/artifact-types/whiteboard/scripts/cli.mjs +1 -1
- package/vendor/artifact-types/whiteboard/scripts/editors/data/assets/index-B041Zu27.js +126 -0
- package/vendor/artifact-types/whiteboard/scripts/editors/data/index.html +1 -1
- package/vendor/artifact-types/whiteboard/scripts/editors/design/assets/index-D6-vjsn9.js +215 -0
- package/vendor/artifact-types/whiteboard/scripts/editors/design/index.html +1 -1
- package/vendor/artifact-types/whiteboard/scripts/editors/design-system/assets/index-BoT2v4hc.js +139 -0
- package/vendor/artifact-types/whiteboard/scripts/editors/design-system/index.html +1 -1
- package/vendor/artifact-types/whiteboard/scripts/editors/slides/assets/index-b9M479Ro.js +569 -0
- package/vendor/artifact-types/whiteboard/scripts/editors/slides/assets/src-CxNLgI5_.js +1 -0
- package/vendor/artifact-types/whiteboard/scripts/editors/slides/index.html +1 -1
- package/vendor/artifact-types/whiteboard/scripts/editors/whiteboard/assets/index-TrzGo_VR.js +141 -0
- package/vendor/artifact-types/whiteboard/scripts/editors/whiteboard/index.html +1 -1
- package/vendor/frame-host/client/comments.js +1 -1
- package/vendor/frame-host/frame-host.mjs +1 -1
- package/vendor/home/assets/{index-CPvXdSVh.js → index-aY1m8xEm.js} +1 -1
- package/vendor/home/index.html +1 -1
- package/vendor/open-artifact.mjs +56 -38
- package/vendor/shell/assets/{index-DE0jNtst.js → index-ElpFysv2.js} +1 -1
- package/vendor/shell/index.html +1 -1
- package/vendor/artifact-types/whiteboard/scripts/editors/data/assets/index-CZiM2XTm.js +0 -126
- package/vendor/artifact-types/whiteboard/scripts/editors/design/assets/index-jhwXmpbV.js +0 -215
- package/vendor/artifact-types/whiteboard/scripts/editors/design-system/assets/index-7LPrsXBY.js +0 -139
- package/vendor/artifact-types/whiteboard/scripts/editors/slides/assets/index-y09Z-wXP.js +0 -569
- package/vendor/artifact-types/whiteboard/scripts/editors/slides/assets/src-C48N4IXt.js +0 -1
- package/vendor/artifact-types/whiteboard/scripts/editors/whiteboard/assets/index-DbekE4ru.js +0 -141
|
@@ -53,7 +53,7 @@ ${yg}
|
|
|
53
53
|
`),u=cS(l,n.split(`
|
|
54
54
|
`)),d=cS(l,s.split(`
|
|
55
55
|
`));if(!u||!d)return null;const p=[];for(const x of u){const b=d.find(w=>$$(x,w,i));if(!b){p.push(x);continue}if(!(b.start===x.start&&b.end===x.end&&z$(b.lines,x.lines)))return null}p.push(...d),p.sort((x,b)=>x.start-b.start||x.end-b.end);const h=[];let g=0;for(const x of p)h.push(...l.slice(g,x.start),...x.lines),g=x.end;return h.push(...l.slice(g)),h.join(`
|
|
56
|
-
`)}const L$="1.3.0";class Fl extends Error{code;paths;retryable;constructor(n,s,a,i){super(s),this.name="ArtifactError",this.code=n,a&&(this.paths=a),i&&(this.retryable=!0)}}function dS(e,n){if(!e||typeof e!="object")return!1;const s=e;return s.name!=="ArtifactError"||typeof s.code!="string"?!1:n===void 0||s.code===n}function I$(e){return e==="owner"||e==="editor"}const fS={defaultMs:12e4,maxMs:6e5};function H$(e,n={}){const s=n.timeoutMs??1e4,a=new Map;return Object.freeze({version:L$,use:l=>{const u=a.get(l);if(u)return u;const d=new Promise(p=>{const h=setTimeout(()=>p(null),s);Promise.resolve().then(()=>e.get(l)).then(g=>{clearTimeout(h),p(g?Object.freeze(g):null)},()=>{clearTimeout(h),p(null)})});return a.set(l,d),d}})}function P$(e,n){const s=globalThis.window?.openartifact;if(s)return s;const a=H$(e,n);return Object.defineProperty(window,"openartifact",{value:a,configurable:!1,enumerable:!0,writable:!1}),a}const pt={session:"_api/session",files:"_api/files",file:"_api/file",publish:"_api/publish",assets:"_api/assets",events:"_api/events",agentSend:"_api/agent/send",presence:"_api/presence",peers:"_api/peers",downloads:"_api/downloads",roomEmit:"_api/room/emit",dbGet:"_api/db/get",dbList:"_api/db/list",dbWrite:"_api/db/write",comments:"_api/comments",commentsCreate:"_api/comments/create",commentsReply:"_api/comments/reply",commentsResolve:"_api/comments/resolve",commentsMove:"_api/comments/move",commentsRemove:"_api/comments/remove",commentsSend:"_api/comments/send",history:"_api/history",historyFiles:"_api/history/files",historyFile:"_api/history/file",historyDiff:"_api/history/diff",historyRestore:"_api/history/restore",historyDismiss:"_api/history/dismiss",mcpTools:"_api/mcp/tools",mcpCall:"_api/mcp/call"};function B$(e,n,s){return n===401||n===403?"removed":n<200||n>=300||!s||s.id===e.id&&s.role===e.role?null:"changed"}async function pS(e){let n={};try{n=await e.json()}catch{}const s=e.status===409?"conflict":e.status===403?"not_writer":e.status===404?"not_found":"unavailable";return new Fl(n.code??s,n.message??`HTTP ${e.status}`,n.paths,n.retryable===!0)}function U$(){const e=new Uint8Array(8);return crypto.getRandomValues(e),Array.from(e,n=>n.toString(16).padStart(2,"0")).join("")}function Nk(e={}){const n=new URL(e.base??"./",location.href),s=U$(),a=(L,V)=>{const B=new URL(L,n);for(const[$,H]of Object.entries(V??{}))B.searchParams.set($,H);return B.toString()},i=async(L,V,B)=>{let $;try{$=await fetch(a(L,B),V)}catch(H){throw new Fl("unavailable",H instanceof Error?H.message:String(H))}if(!$.ok)throw await pS($);return await $.json()},l=(L,V)=>i(L,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(V)}),u=new Map,d=(L,V)=>{for(const B of u.get(L)??[])B(V)},p=(L,V)=>{let B=u.get(L);return B||(B=new Set,u.set(L,B),x?.addEventListener(L,w)),B.add(V),j(),()=>B.delete(V)};let h=null,g=!1,x=null,b=null;const w=L=>{d(L.type,JSON.parse(L.data))},S=()=>{const L=new EventSource(a(pt.events,{client:s}));x=L;for(const V of u.keys())L.addEventListener(V,w);L.onerror=()=>{k().then(V=>{V||L.readyState!==EventSource.CLOSED||x!==L||(x=null,b=setTimeout(()=>{b=null,j()},2e3))})}};let C=!1,R=!1;const T=L=>{C||(C=!0,b&&clearTimeout(b),b=null,x?.close(),x=null,h?.close(),h=null,e.onAccessChange?e.onAccessChange(L):location.reload())},k=async()=>{if(C)return!0;if(!N||R)return!1;R=!0;try{const L=(await N.catch(()=>null))?.viewer;if(!L)return!1;let V;try{V=await fetch(a(pt.session),{cache:"no-store"})}catch{return!1}const B=V.ok?(await V.json().catch(()=>null))?.viewer:null,$=B$(L,V.status,B);return $&&T($),$!==null}finally{R=!1}};function j(){if(h||x||b||C)return;if(typeof WebSocket>"u")return S();const L=new URL(a(pt.events,{client:s}));L.protocol=L.protocol==="https:"?"wss:":"ws:";const V=new WebSocket(L);h=V,V.onopen=()=>{g=!0},V.onmessage=B=>{let $;try{$=JSON.parse(String(B.data))}catch{return}$.event&&d($.event,$.data)},V.onclose=()=>{if(h===V&&(h=null),!C){if(!g)return S();k().then(B=>{B||h||x||b||(b=setTimeout(()=>{b=null,j()},2e3))})}}}let N=null;const O=()=>N??=i(pt.session),M={async artifact(){const{artifact:L}=await O();return{id:L.id,title:async()=>(await i(pt.session)).artifact.title,list:async()=>(await i(pt.files)).files,readText:async B=>new TextDecoder().decode(await D(B)),readBytes:B=>D(B),publish:async B=>{const $={files:B,client:s};return i(pt.publish,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify($)})},onChange:B=>p("files",B)}},async assets(){const{viewer:L}=await O();return I$(L.role)?{upload:async(B,$)=>i(pt.assets,{method:"POST",headers:{"content-type":B.type||"application/octet-stream"},body:B},$?.name?{name:$.name}:void 0)}:null},async user(){const{viewer:L}=await O();return{me:async()=>L}},async agent(){return{send:async(V,B)=>{const $={request:V,deliver:B?.deliver??"send"};return i(pt.agentSend,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify($)})},status:async()=>(await i(pt.session)).agent,onStatus:V=>p("agent",V)}},async room(){return{self:async()=>s,presence:async V=>{const B={client:s,patch:V};await i(pt.presence,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(B)})},peers:async()=>(await i(pt.peers)).peers,onPeers:V=>p("peers",V),emit:async(V,B)=>{const $={client:s,topic:V,data:B};await l(pt.roomEmit,$)},onMessage:V=>p("room",V)}},async db(){const{stores:L}=await O();return L?.db?{get:async B=>(await i(pt.dbGet,{cache:"no-store"},{path:B})).data,list:async B=>(await i(pt.dbList,{cache:"no-store"},{collection:B})).documents,write:async B=>{const $={writes:B,client:s};await l(pt.dbWrite,$)},onChange:B=>p("db",B)}:null},async comments(){const{stores:L}=await O();if(!L?.comments)return null;const V=async($,H)=>(await l($,H)).thread;return{list:async()=>(await i(pt.comments,{cache:"no-store"})).threads,create:$=>V(pt.commentsCreate,{input:$}),reply:($,H)=>V(pt.commentsReply,{threadId:$,text:H}),setResolved:($,H)=>V(pt.commentsResolve,{threadId:$,resolved:H}),move:($,H,K)=>V(pt.commentsMove,{threadId:$,anchor:H,...K?{location:K}:{}}),remove:async($,H)=>{await l(pt.commentsRemove,{threadId:$,...H?{messageId:H}:{}})},sendToAgent:$=>V(pt.commentsSend,{threadId:$}),onChange:$=>p("comments",$)}},async history(){const{stores:L}=await O();if(!L?.history)return null;const V=($,H)=>({n:String($),...H===void 0?{}:{path:H}});return{list:()=>i(pt.history,{cache:"no-store"}),files:async $=>(await i(pt.historyFiles,{cache:"no-store"},V($))).files,read:async($,H)=>new TextDecoder().decode(await A(pt.historyFile,V($,H))),readBytes:($,H)=>A(pt.historyFile,V($,H)),diff:($,H)=>i(pt.historyDiff,{cache:"no-store"},V($,H)),restore:($,H)=>l(pt.historyRestore,{n:$,...H?{paths:H}:{},client:s}),dismissNotice:async $=>{await l(pt.historyDismiss,{id:$})},onChange:$=>p("history",$)}},async mcp(){const{viewer:L}=await O();return L.role!=="owner"?null:{callTool:async(B,$,H,K)=>{const Z=K?.signal;Z?.throwIfAborted();const I={server:B,tool:$,args:H,...K?.timeoutMs===void 0?{}:{timeoutMs:K.timeoutMs}};try{return await i(pt.mcpCall,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(I),...Z?{signal:Z}:{}})}catch(Y){throw Z?.aborted?Z.reason:Y}},listTools:B=>i(pt.mcpTools,{cache:"no-store"},B===void 0?void 0:{server:B})}},async downloads(){return{save:async({name:V,data:B})=>i(pt.downloads,{method:"POST",headers:{"content-type":B.type||"application/octet-stream"},body:B},{name:V})}}};function D(L){return A(pt.file,{path:L})}async function A(L,V){let B;try{B=await fetch(a(L,V),{cache:"no-store"})}catch($){throw new Fl("unavailable",$ instanceof Error?$.message:String($))}if(!B.ok)throw await pS(B);return new Uint8Array(await B.arrayBuffer())}return{get(L){const V=M[L];return V?V():null}}}const F$="[Artifact comment sent to agent]",V$="[Artifact edit request sent to agent]",q$="[Artifact task finished]",Y$=1,G$=1,K$=/^[a-z][a-z0-9]{0,23}$/,X$="may not have run: the artifact was updated before this call was answered",W$=["quickstart","list","publish","read","open","call","adopt","delete","share"],Z$=["get","list","query","set","update","delete","str_replace","batch"],Q$=["read","reply","resolve","reopen","wait"],J$=["share","export"],eL={type:"object",properties:{action:{type:"string",enum:W$,description:"What to do. Omitted: publish."},intent:{type:"string",description:"quickstart: what is being made (design, slides, whiteboard, document, data, other), or a few words about it."},scope:{type:"string",enum:["types","mine","all"],description:"list: the installed types, this session's and this workspace's artifacts (default), or every artifact."},type:{type:"string",description:"list: only artifacts of this type (an id, or open-artifact://type/<id>)."},query:{type:"string",description:"list: only artifacts whose title contains this text."},limit:{type:"integer",description:"list: how many to return (default 50, at most 200)."},cursor:{type:"string",description:"list: the next_cursor of the previous page."},type_url:{type:"string",description:"publish without url: the type to create from (open-artifact://type/<id>, from quickstart). read without url: the type to describe."},title:{type:"string",description:"publish without url: the new artifact's name."},folder:{type:"string",description:"publish without url, or adopt: where the artifact's folder goes (absolute, or relative to the workspace). Default <workspace>/artifacts/<slug>."},url:{type:"string",description:"An artifact: open-artifact://artifact/<id>, as publish returned it."},files:{type:"object",additionalProperties:!0,description:'publish with url: files to write under the artifact root, as {"rel/path": "text"} or {"rel/path": {"content": "...", "encoding": "base64"}}; null deletes.'},if_match:{type:"object",additionalProperties:!0,description:'publish with url: {"rel/path": sha256 | null | "*"}. Write only while the file still has the sha256 you read, does not exist (null), or anyway ("*"). One mismatch writes nothing and returns the current versions.'},check:{type:"boolean",description:"publish with url: run the type's check action after writing; its result comes back as check."},open:{type:"string",enum:["after_first_write","now"],description:"publish without url: after_first_write opens the page in your app once your first write lands; now opens it at once. Where your app cannot show pages by itself the result says so: open view_url in your app's built-in browser, if you have one."},related:{type:"boolean",description:"quickstart: list existing artifacts the recommended type can build on, such as design systems (default true)."},path:{type:"string",description:"read: one file or folder under the root (omitted: the record and the file list)."},paths:{type:"array",items:{type:"string"},description:"read: several files under the root at once."},name:{type:"string",description:"call: the action's name (check, upload, ...; read with url lists them)."},args:{type:"object",additionalProperties:!0,description:"call: the action's arguments. upload: {file: absolute path, name?, group?}."},panel:{type:"string",enum:J$,description:"open: also open the page's Share panel (share), for the person to share it on the network, or its Export tab (export), for them to download a file."}}},tL={type:"object",properties:{action:{type:"string",enum:Z$},url:{type:"string",description:"The artifact (open-artifact://artifact/<id>)."},collection:{type:"string"},doc_id:{type:"string"},path:{type:"string",description:"collection/doc_id, instead of the two."},data:{type:"object",additionalProperties:!0,description:"set / update: the document's fields."},file_path:{type:"string",description:"set / update: a JSON file holding the fields, instead of data."},if_match:{description:'set / update / delete / str_replace: the sha256 get returned (write only if unchanged), null (only if it does not exist) or "*" (replace whatever is there).'},field:{type:"string",description:"str_replace: the text field, as a dot path (body, notes.text)."},old:{type:"string",description:"str_replace: the passage to replace; it must occur exactly once."},new:{type:"string",description:"str_replace: the passage that replaces it."},where:{type:"array",items:{type:"object",additionalProperties:!0},description:"query: [{field, op, value}], all must hold. op: ==, !=, <, <=, >, >=, in, not-in (up to 30 values), array-contains."},order_by:{type:"object",additionalProperties:!0,description:'query: {field, dir: "asc" | "desc"}.'},limit:{type:"integer",description:"list / query: how many documents (default 100, at most 1000)."},cursor:{type:"string",description:"list / query: the next_cursor of the previous page."},out_file:{type:"string",description:"get / list / query: write the result to this JSON file (absolute, or relative to the workspace) and return only its path and counts."},writes:{type:"array",items:{type:"object",additionalProperties:!0},description:"batch: [{op: set|update|delete|str_replace, path | collection+doc_id, data | file_path, if_match?, field?, old?, new?}], at most 500."}},required:["action","url"]},nL={type:"object",properties:{action:{type:"string",enum:Q$},url:{type:"string",description:"The artifact (open-artifact://artifact/<id>). wait: optional."},thread_id:{type:"string",description:'reply / resolve / reopen: the thread (after ";thread=" in the message).'},text:{type:"string",description:"reply: the answer."},resolve:{type:"boolean",description:"reply: resolve the thread too."},all:{type:"boolean",description:"read: resolved threads too."},since:{type:"string",description:"read: only threads with a message at or after this time (ISO 8601)."},acknowledge_duplicate:{type:"boolean",description:"reply: send the same text as your last reply in this thread again, on purpose."},timeout_ms:{type:"number",description:"wait: how long (default 600000)."}},required:["action"]},hS={Artifact:eL,ArtifactData:tL,ArtifactComments:nL},sL={Artifact:["Make and change artifacts: typed folders of files that open as live pages the person can view, edit, comment on and export. Actions:","- quickstart {intent}: call first for a new artifact; recommends a type and returns the call that creates it.",'- list {scope: "mine" | "all" | "types", type?, query?}: find existing artifacts, or the installed types.',"- publish {type_url, title, folder?, open?}: create an artifact; the result carries its root folder and the type's instructions. publish {url, files, if_match?, check?}: write files when you have no file tools of your own.","- read {url, path? | paths?}: the artifact's record, files and actions, or some of its files with their sha256. read {type_url}: a type's instructions, before creating.",`- open {url, panel?}: show it to the person in the computer's browser (or the app, when it shows pages), once its content is written. When your app has a built-in browser, open view_url there instead. panel "share" or "export" opens its Share panel or Export tab for them.`,"- call {url, name, args?}: run one of the type's actions (check, upload, ...). A long one answers {task, pending: true}; its result comes later as a message.","- adopt {url | folder}: take over an artifact, or add an existing folder. Only when the person asks.","- share {url}: whether it is shared on the local network, and its links. Only the person changes that, in the page's Share panel.","- delete {url}: forget an artifact; its folder stays. Only when the person asks."].join(`
|
|
56
|
+
`)}const L$="1.3.0";class Fl extends Error{code;paths;retryable;constructor(n,s,a,i){super(s),this.name="ArtifactError",this.code=n,a&&(this.paths=a),i&&(this.retryable=!0)}}function dS(e,n){if(!e||typeof e!="object")return!1;const s=e;return s.name!=="ArtifactError"||typeof s.code!="string"?!1:n===void 0||s.code===n}function I$(e){return e==="owner"||e==="editor"}const fS={defaultMs:12e4,maxMs:6e5};function H$(e,n={}){const s=n.timeoutMs??1e4,a=new Map;return Object.freeze({version:L$,use:l=>{const u=a.get(l);if(u)return u;const d=new Promise(p=>{const h=setTimeout(()=>p(null),s);Promise.resolve().then(()=>e.get(l)).then(g=>{clearTimeout(h),p(g?Object.freeze(g):null)},()=>{clearTimeout(h),p(null)})});return a.set(l,d),d}})}function P$(e,n){const s=globalThis.window?.openartifact;if(s)return s;const a=H$(e,n);return Object.defineProperty(window,"openartifact",{value:a,configurable:!1,enumerable:!0,writable:!1}),a}const pt={session:"_api/session",files:"_api/files",file:"_api/file",publish:"_api/publish",assets:"_api/assets",events:"_api/events",agentSend:"_api/agent/send",presence:"_api/presence",peers:"_api/peers",downloads:"_api/downloads",roomEmit:"_api/room/emit",dbGet:"_api/db/get",dbList:"_api/db/list",dbWrite:"_api/db/write",comments:"_api/comments",commentsCreate:"_api/comments/create",commentsReply:"_api/comments/reply",commentsResolve:"_api/comments/resolve",commentsMove:"_api/comments/move",commentsRemove:"_api/comments/remove",commentsSend:"_api/comments/send",history:"_api/history",historyFiles:"_api/history/files",historyFile:"_api/history/file",historyDiff:"_api/history/diff",historyRestore:"_api/history/restore",historyDismiss:"_api/history/dismiss",mcpTools:"_api/mcp/tools",mcpCall:"_api/mcp/call"};function B$(e,n,s){return n===401||n===403?"removed":n<200||n>=300||!s||s.id===e.id&&s.role===e.role?null:"changed"}async function pS(e){let n={};try{n=await e.json()}catch{}const s=e.status===409?"conflict":e.status===403?"not_writer":e.status===404?"not_found":"unavailable";return new Fl(n.code??s,n.message??`HTTP ${e.status}`,n.paths,n.retryable===!0)}function U$(){const e=new Uint8Array(8);return crypto.getRandomValues(e),Array.from(e,n=>n.toString(16).padStart(2,"0")).join("")}function Nk(e={}){const n=new URL(e.base??"./",location.href),s=U$(),a=(L,V)=>{const B=new URL(L,n);for(const[$,H]of Object.entries(V??{}))B.searchParams.set($,H);return B.toString()},i=async(L,V,B)=>{let $;try{$=await fetch(a(L,B),V)}catch(H){throw new Fl("unavailable",H instanceof Error?H.message:String(H))}if(!$.ok)throw await pS($);return await $.json()},l=(L,V)=>i(L,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(V)}),u=new Map,d=(L,V)=>{for(const B of u.get(L)??[])B(V)},p=(L,V)=>{let B=u.get(L);return B||(B=new Set,u.set(L,B),x?.addEventListener(L,w)),B.add(V),j(),()=>B.delete(V)};let h=null,g=!1,x=null,b=null;const w=L=>{d(L.type,JSON.parse(L.data))},S=()=>{const L=new EventSource(a(pt.events,{client:s}));x=L;for(const V of u.keys())L.addEventListener(V,w);L.onerror=()=>{k().then(V=>{V||L.readyState!==EventSource.CLOSED||x!==L||(x=null,b=setTimeout(()=>{b=null,j()},2e3))})}};let C=!1,R=!1;const T=L=>{C||(C=!0,b&&clearTimeout(b),b=null,x?.close(),x=null,h?.close(),h=null,e.onAccessChange?e.onAccessChange(L):location.reload())},k=async()=>{if(C)return!0;if(!N||R)return!1;R=!0;try{const L=(await N.catch(()=>null))?.viewer;if(!L)return!1;let V;try{V=await fetch(a(pt.session),{cache:"no-store"})}catch{return!1}const B=V.ok?(await V.json().catch(()=>null))?.viewer:null,$=B$(L,V.status,B);return $&&T($),$!==null}finally{R=!1}};function j(){if(h||x||b||C)return;if(typeof WebSocket>"u")return S();const L=new URL(a(pt.events,{client:s}));L.protocol=L.protocol==="https:"?"wss:":"ws:";const V=new WebSocket(L);h=V,V.onopen=()=>{g=!0},V.onmessage=B=>{let $;try{$=JSON.parse(String(B.data))}catch{return}$.event&&d($.event,$.data)},V.onclose=()=>{if(h===V&&(h=null),!C){if(!g)return S();k().then(B=>{B||h||x||b||(b=setTimeout(()=>{b=null,j()},2e3))})}}}let N=null;const O=()=>N??=i(pt.session),M={async artifact(){const{artifact:L}=await O();return{id:L.id,title:async()=>(await i(pt.session)).artifact.title,list:async()=>(await i(pt.files)).files,readText:async B=>new TextDecoder().decode(await D(B)),readBytes:B=>D(B),publish:async B=>{const $={files:B,client:s};return i(pt.publish,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify($)})},onChange:B=>p("files",B)}},async assets(){const{viewer:L}=await O();return I$(L.role)?{upload:async(B,$)=>i(pt.assets,{method:"POST",headers:{"content-type":B.type||"application/octet-stream"},body:B},$?.name?{name:$.name}:void 0)}:null},async user(){const{viewer:L}=await O();return{me:async()=>L}},async agent(){return{send:async(V,B)=>{const $={request:V,deliver:B?.deliver??"send"};return i(pt.agentSend,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify($)})},status:async()=>(await i(pt.session)).agent,onStatus:V=>p("agent",V)}},async room(){return{self:async()=>s,presence:async V=>{const B={client:s,patch:V};await i(pt.presence,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(B)})},peers:async()=>(await i(pt.peers)).peers,onPeers:V=>p("peers",V),emit:async(V,B)=>{const $={client:s,topic:V,data:B};await l(pt.roomEmit,$)},onMessage:V=>p("room",V)}},async db(){const{stores:L}=await O();return L?.db?{get:async B=>(await i(pt.dbGet,{cache:"no-store"},{path:B})).data,list:async B=>(await i(pt.dbList,{cache:"no-store"},{collection:B})).documents,write:async B=>{const $={writes:B,client:s};await l(pt.dbWrite,$)},onChange:B=>p("db",B)}:null},async comments(){const{stores:L}=await O();if(!L?.comments)return null;const V=async($,H)=>(await l($,H)).thread;return{list:async()=>(await i(pt.comments,{cache:"no-store"})).threads,create:$=>V(pt.commentsCreate,{input:$}),reply:($,H)=>V(pt.commentsReply,{threadId:$,text:H}),setResolved:($,H)=>V(pt.commentsResolve,{threadId:$,resolved:H}),move:($,H,K)=>V(pt.commentsMove,{threadId:$,anchor:H,...K?{location:K}:{}}),remove:async($,H)=>{await l(pt.commentsRemove,{threadId:$,...H?{messageId:H}:{}})},sendToAgent:$=>V(pt.commentsSend,{threadId:$}),onChange:$=>p("comments",$)}},async history(){const{stores:L}=await O();if(!L?.history)return null;const V=($,H)=>({n:String($),...H===void 0?{}:{path:H}});return{list:()=>i(pt.history,{cache:"no-store"}),files:async $=>(await i(pt.historyFiles,{cache:"no-store"},V($))).files,read:async($,H)=>new TextDecoder().decode(await A(pt.historyFile,V($,H))),readBytes:($,H)=>A(pt.historyFile,V($,H)),diff:($,H)=>i(pt.historyDiff,{cache:"no-store"},V($,H)),restore:($,H)=>l(pt.historyRestore,{n:$,...H?{paths:H}:{},client:s}),dismissNotice:async $=>{await l(pt.historyDismiss,{id:$})},onChange:$=>p("history",$)}},async mcp(){const{viewer:L}=await O();return L.role!=="owner"?null:{callTool:async(B,$,H,K)=>{const Z=K?.signal;Z?.throwIfAborted();const I={server:B,tool:$,args:H,...K?.timeoutMs===void 0?{}:{timeoutMs:K.timeoutMs}};try{return await i(pt.mcpCall,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(I),...Z?{signal:Z}:{}})}catch(Y){throw Z?.aborted?Z.reason:Y}},listTools:B=>i(pt.mcpTools,{cache:"no-store"},B===void 0?void 0:{server:B})}},async downloads(){return{save:async({name:V,data:B})=>i(pt.downloads,{method:"POST",headers:{"content-type":B.type||"application/octet-stream"},body:B},{name:V})}}};function D(L){return A(pt.file,{path:L})}async function A(L,V){let B;try{B=await fetch(a(L,V),{cache:"no-store"})}catch($){throw new Fl("unavailable",$ instanceof Error?$.message:String($))}if(!B.ok)throw await pS(B);return new Uint8Array(await B.arrayBuffer())}return{get(L){const V=M[L];return V?V():null}}}const F$="[Artifact comment sent to agent]",V$="[Artifact edit request sent to agent]",q$="[Artifact task finished]",Y$=1,G$=1,K$=/^[a-z][a-z0-9]{0,23}$/,X$="may not have run: the artifact was updated before this call was answered",W$=["quickstart","list","publish","read","open","call","adopt","delete","share"],Z$=["get","list","query","set","update","delete","str_replace","batch"],Q$=["read","reply","resolve","reopen","wait"],J$=["share","export"],eL={type:"object",properties:{action:{type:"string",enum:W$,description:"What to do. Omitted: publish."},intent:{type:"string",description:"quickstart: what is being made (design, design-system, slides, whiteboard, document, data, other), or a few words about it."},scope:{type:"string",enum:["types","mine","all"],description:"list: the installed types, this session's and this workspace's artifacts (default), or every artifact."},type:{type:"string",description:"list: only artifacts of this type (an id, or open-artifact://type/<id>)."},query:{type:"string",description:"list: only artifacts whose title contains this text."},limit:{type:"integer",description:"list: how many to return (default 50, at most 200)."},cursor:{type:"string",description:"list: the next_cursor of the previous page."},type_url:{type:"string",description:"publish without url: the type to create from (open-artifact://type/<id>, from quickstart). read without url: the type to describe."},title:{type:"string",description:"publish without url: the new artifact's name."},folder:{type:"string",description:"publish without url, or adopt: where the artifact's folder goes (absolute, or relative to the workspace). Default <workspace>/artifacts/<slug>."},url:{type:"string",description:"An artifact: open-artifact://artifact/<id>, as publish returned it."},files:{type:"object",additionalProperties:!0,description:'publish with url: files to write under the artifact root, as {"rel/path": "text"} or {"rel/path": {"content": "...", "encoding": "base64"}}; null deletes.'},if_match:{type:"object",additionalProperties:!0,description:'publish with url: {"rel/path": sha256 | null | "*"}. Write only while the file still has the sha256 you read, does not exist (null), or anyway ("*"). One mismatch writes nothing and returns the current versions.'},check:{type:"boolean",description:"publish with url: run the type's check action after writing; its result comes back as check."},open:{type:"string",enum:["after_first_write","now"],description:"publish without url: after_first_write opens the page in your app once your first write lands; now opens it at once. Where your app cannot show pages by itself the result says so: open view_url in your app's built-in browser, if you have one."},related:{type:"boolean",description:"quickstart: list existing artifacts the recommended type can build on, such as design systems (default true)."},path:{type:"string",description:"read: one file or folder under the root (omitted: the record and the file list)."},paths:{type:"array",items:{type:"string"},description:"read: several files under the root at once."},name:{type:"string",description:"call: the action's name (check, upload, ...; read with url lists them)."},args:{type:"object",additionalProperties:!0,description:"call: the action's arguments. upload: {file: absolute path, name?, group?}."},panel:{type:"string",enum:J$,description:"open: also open the page's Share panel (share), for the person to share it on the network, or its Export tab (export), for them to download a file."}}},tL={type:"object",properties:{action:{type:"string",enum:Z$},url:{type:"string",description:"The artifact (open-artifact://artifact/<id>)."},collection:{type:"string"},doc_id:{type:"string"},path:{type:"string",description:"collection/doc_id, instead of the two."},data:{type:"object",additionalProperties:!0,description:"set / update: the document's fields."},file_path:{type:"string",description:"set / update: a JSON file holding the fields, instead of data."},if_match:{description:'set / update / delete / str_replace: the sha256 get returned (write only if unchanged), null (only if it does not exist) or "*" (replace whatever is there).'},field:{type:"string",description:"str_replace: the text field, as a dot path (body, notes.text)."},old:{type:"string",description:"str_replace: the passage to replace; it must occur exactly once."},new:{type:"string",description:"str_replace: the passage that replaces it."},where:{type:"array",items:{type:"object",additionalProperties:!0},description:"query: [{field, op, value}], all must hold. op: ==, !=, <, <=, >, >=, in, not-in (up to 30 values), array-contains."},order_by:{type:"object",additionalProperties:!0,description:'query: {field, dir: "asc" | "desc"}.'},limit:{type:"integer",description:"list / query: how many documents (default 100, at most 1000)."},cursor:{type:"string",description:"list / query: the next_cursor of the previous page."},out_file:{type:"string",description:"get / list / query: write the result to this JSON file (absolute, or relative to the workspace) and return only its path and counts."},writes:{type:"array",items:{type:"object",additionalProperties:!0},description:"batch: [{op: set|update|delete|str_replace, path | collection+doc_id, data | file_path, if_match?, field?, old?, new?}], at most 500."}},required:["action","url"]},nL={type:"object",properties:{action:{type:"string",enum:Q$},url:{type:"string",description:"The artifact (open-artifact://artifact/<id>). wait: optional."},thread_id:{type:"string",description:'reply / resolve / reopen: the thread (after ";thread=" in the message).'},text:{type:"string",description:"reply: the answer."},resolve:{type:"boolean",description:"reply: resolve the thread too."},all:{type:"boolean",description:"read: resolved threads too."},since:{type:"string",description:"read: only threads with a message at or after this time (ISO 8601)."},acknowledge_duplicate:{type:"boolean",description:"reply: send the same text as your last reply in this thread again, on purpose."},timeout_ms:{type:"number",description:"wait: how long (default 600000)."}},required:["action"]},hS={Artifact:eL,ArtifactData:tL,ArtifactComments:nL},sL={Artifact:["Make and change artifacts: typed folders of files that open as live pages the person can view, edit, comment on and export. Actions:","- quickstart {intent}: call first for a new artifact; recommends a type and returns the call that creates it.",'- list {scope: "mine" | "all" | "types", type?, query?}: find existing artifacts, or the installed types.',"- publish {type_url, title, folder?, open?}: create an artifact; the result carries its root folder and the type's instructions. publish {url, files, if_match?, check?}: write files when you have no file tools of your own.","- read {url, path? | paths?}: the artifact's record, files and actions, or some of its files with their sha256. read {type_url}: a type's instructions, before creating.",`- open {url, panel?}: show it to the person in the computer's browser (or the app, when it shows pages), once its content is written. When your app has a built-in browser, open view_url there instead. panel "share" or "export" opens its Share panel or Export tab for them.`,"- call {url, name, args?}: run one of the type's actions (check, upload, ...). A long one answers {task, pending: true}; its result comes later as a message.","- adopt {url | folder}: take over an artifact, or add an existing folder. Only when the person asks.","- share {url}: whether it is shared on the local network, and its links. Only the person changes that, in the page's Share panel.","- delete {url}: forget an artifact; its folder stays. Only when the person asks."].join(`
|
|
57
57
|
`),ArtifactData:'Read and write the document store of an artifact whose type keeps one (its instructions say so). get, list and query read documents with their sha256; set, update, delete, str_replace and batch write them. update merges fields, and {"__delete__": true} removes one; str_replace changes one passage of a long text field. Replacing or deleting an existing document needs if_match: the sha256 you read, or "*". Your writes show live on open pages.',ArtifactComments:`Comments the person leaves on their artifact's page, kept in the artifact's own folder on this computer (no outside service). read lists the threads; reply answers one (thread_id is after ";thread=" in the message), with resolve: true when it is done; resolve and reopen change a thread's state. A thread sent to you is the person asking for your answer in it, so replying there is what they asked for. Answer only threads sent to you, in one or two lines. wait blocks until the next message for this session: use it only when nothing else can wake you.`},oL={Artifact:{title:"Artifact",openWorldHint:!1},ArtifactData:{title:"Artifact data",openWorldHint:!1},ArtifactComments:{title:"Artifact comments",destructiveHint:!1,openWorldHint:!1}};Object.keys(hS).map(e=>({name:e,description:sL[e],inputSchema:hS[e],annotations:oL[e]}));const aL=300,rL=12,mS=["Artifact","ArtifactData","ArtifactComments"];function da(e,n=aL){const s=String(e??"").replace(/[<>]/g,"").replace(/\s+/g," ").trim();return s.length>n?`${s.slice(0,n-1).trimEnd()}…`:s}function iL(e){const n=da(e,Number.MAX_SAFE_INTEGER),s=n.search(/[.!?。!?](\s|$)/);return s>=0?n.slice(0,s+1):n}function lL(e){const n=da(e,24);return/^[a-z0-9]{1,5}$/i.test(n)?n.toUpperCase():n}const gS=e=>!e||/[.!?。!?…]$/.test(e)?e:`${e}.`;function cL(e,n=!1){const s=da(e.title,80)||e.id;if(n)return`- ${e.id}: ${s}`;const a=da(e.when)||da(iL(e.description)),i=(e.exports??[]).map(lL).filter(Boolean),l=[gS(s),gS(a),i.length?`Exports: ${i.join(", ")}.`:""].filter(Boolean);return`- ${e.id}: ${l.join(" ")}`}const uL="Open Artifact lets you make artifacts: typed folders of files (a slide deck, a design canvas, a whiteboard, a data dashboard and more) that open as live pages the person can view, edit, comment on and export. You make and change them with the Artifact, ArtifactData and ArtifactComments tools.",dL=`<where_output_goes>
|
|
58
58
|
Decide where your output will live before you make anything.
|
|
59
59
|
- Something the person will read once and move on from (an answer, an explanation, a summary, a short report) goes in your reply, however long it is. A diagram or chart that explains your answer goes in the reply too, when you can show one there.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>Design system</title>
|
|
7
|
-
<script type="module" crossorigin src="./assets/index-
|
|
7
|
+
<script type="module" crossorigin src="./assets/index-BoT2v4hc.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="./assets/index-D1V6qX31.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|