@seshat.sh/cli 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -2
- package/dist/{chunk-NUTHSM2Y.js → chunk-73X6ZBVW.js} +1 -1
- package/dist/cli.js +15 -14
- package/dist/mcp.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -91,9 +91,30 @@ seshat upload ./photos --into FOLDER_ID_OR_LINK --prefix images
|
|
|
91
91
|
- A folder holds up to 100 files and 100 MiB, 10 MiB per file.
|
|
92
92
|
- Files already stored unchanged are not sent again. If an upload is interrupted, repeat the same command with the same `--request-id`, or use `--into` with the folder ID from the output.
|
|
93
93
|
|
|
94
|
-
##
|
|
94
|
+
## Use with an AI assistant (MCP)
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
Assistants such as Claude Code, Claude Desktop, Cursor and Codex can publish to Seshat through MCP. You do not start anything yourself: the assistant runs `seshat mcp` as a local server when it needs it and signs in with a profile you approved.
|
|
97
|
+
|
|
98
|
+
```sh
|
|
99
|
+
seshat agent setup --profile my-agent
|
|
100
|
+
claude mcp add --env SESHAT_PROFILE=my-agent --transport stdio seshat -- npx -y @seshat.sh/cli mcp
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
For Claude Desktop or Cursor, add the same command to the assistant's MCP settings file:
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"mcpServers": {
|
|
108
|
+
"seshat": {
|
|
109
|
+
"command": "npx",
|
|
110
|
+
"args": ["-y", "@seshat.sh/cli", "mcp"],
|
|
111
|
+
"env": { "SESHAT_PROFILE": "my-agent" }
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Without further setup the assistant can publish what it writes. To let it upload existing files, also set `SESHAT_UPLOAD_ROOTS` to a JSON array of allowed directories; files outside them are refused. A hosted MCP endpoint is not provided yet.
|
|
97
118
|
|
|
98
119
|
This package contains only the service client. Server implementation and deployment sources are not distributed with it.
|
|
99
120
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{z as o}from"zod";import{z as ue}from"zod";var C=ue.enum(["never","hour","day","week","month","year","custom"]);var S=10*1024*1024,U=100,I=100*1024*1024,Y=["artifacts:read","artifacts:write","artifacts:delete","tokens:manage"],j=o.enum(Y),d=o.string().regex(/^[a-f0-9]{48}$/),$=o.string().min(8).max(128).regex(/^[A-Za-z0-9_-]+$/),b=o.string().regex(/^seshat_[A-Za-z0-9_-]{43}$/),J=o.iso.datetime().transform(t=>new Date(t).toISOString());function D(t){return t.expirationPreset==null||(t.expirationPreset==="never"?t.expiresAt===null:typeof t.expiresAt=="string")}var w=o.object({title:o.string().trim().min(1).max(200).optional(),description:o.string().max(2e3).default(""),expiresAt:J.nullable().optional(),expirationPreset:C.nullable().optional(),password:o.string().min(12).max(128).nullable().optional(),generateMetadata:o.boolean().optional()}).strict().refine(D,"Expiration preset must match an explicit expiration value"),L=o.object({filename:o.string().min(1).max(200).regex(/^[^/\\\x00-\x1f\x7f]+$/),contentType:o.string().max(150).regex(/^[a-z0-9!#$&^_.+-]+\/[a-z0-9!#$&^_.+-]+$/i),size:o.number().int().min(1).max(S)}).strict(),Z=o.object({title:w.shape.title.optional(),description:o.string().max(2e3).optional(),expiresAt:w.shape.expiresAt,expirationPreset:w.shape.expirationPreset,password:w.shape.password}).strict().refine(D,"Expiration preset must match an explicit expiration value").refine(t=>Object.values(t).some(e=>e!==void 0),"Provide at least one metadata field"),T=o.string().min(1).max(400).regex(/^[^\\\x00-\x1f\x7f]+$/).refine(t=>{let e=t.split("/");return e.length<=12&&e.every(r=>r.length>0&&r.length<=200&&r!=="."&&r!==".."&&!r.startsWith("~"))},"Use a relative path such as css/site.css"),G=o.object({kind:o.literal("folder"),name:L.shape.filename,title:w.shape.title,description:w.shape.description,expiresAt:w.shape.expiresAt,expirationPreset:w.shape.expirationPreset,password:w.shape.password}).strict().refine(D,"Expiration preset must match an explicit expiration value"),R=o.object({path:T,contentType:o.string(),size:o.number(),digest:o.string().regex(/^[a-f0-9]{64}$/)}),K=o.object({files:o.array(R)}),Q=o.object({slug:o.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).min(2).max(63),name:o.string().trim().min(1).max(100)}).strict(),y=o.object({name:o.string().trim().min(1).max(100),scopes:o.array(j).min(1).max(Y.length),expiresAt:J.optional()}).strict(),v=o.object({id:d,title:o.string(),description:o.string(),filename:o.string(),contentType:o.string(),size:o.number(),createdAt:o.string(),expiresAt:o.string().nullable(),expirationPreset:C.nullable().default(null),url:o.url(),downloadUrl:o.url(),passwordProtected:o.boolean().default(!1),kind:o.enum(["file","folder"]).default("file"),views:o.object({owner:o.number(),others:o.number()})}),V=o.object({artifacts:o.array(v),nextCursor:o.string().nullable()}),z=o.object({id:d,token:b,scopes:o.array(j),expiresAt:o.string().nullable()}),_=o.object({space:o.object({id:d,slug:o.string(),name:o.string()}),credential:z}),ee=o.object({spaceId:d,tokenId:d,scopes:y.shape.scopes,space:_.shape.space.optional()}),te=o.object({error:o.object({code:o.string(),message:o.string()})});import{z as u}from"zod";import{z as i}from"zod";var re="https://app.seshat.sh",A=i.url().refine(t=>{let e=new URL(t);return!e.username&&!e.password&&!e.search&&!e.hash&&e.pathname==="/"&&(e.protocol==="https:"||e.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(e.hostname))},"Use an HTTPS origin, or HTTP localhost for development").transform(t=>new URL(t).origin),O=i.string().min(1).max(64).regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]*$/),Je=i.string().max(16).transform(t=>t.toUpperCase().replaceAll("-","").trim()).pipe(i.string().regex(/^[ABCDEFGHJKLMNPQRSTUVWXYZ23456789]{8}$/)),M=i.string().trim().min(1).max(80).regex(/^[^\u0000-\u001f\u007f-\u009f\u061c\u200e\u200f\u2028-\u202e\u2066-\u2069]+$/),ge=i.strictObject({city:M.optional(),region:M.optional(),country:i.string().regex(/^[A-Z]{2}$/).optional()}).refine(t=>!!(t.city||t.region||t.country),"Location is unavailable"),q=i.strictObject({kind:i.enum(["laptop","desktop","phone","tablet","terminal"]),os:i.enum(["macos","windows","linux","android","ios","other"]),model:M.optional(),client:i.enum(["terminal","agent"])});var Ze=y.extend({tokenHash:i.string().regex(/^[a-f0-9]{64}$/),device:q.optional()}).strict().refine(t=>!t.expiresAt||Date.parse(t.expiresAt)>Date.now()&&Date.parse(t.expiresAt)<=Date.now()+366*864e5,"Choose a credential expiry within the next year"),Ge=i.strictObject({deviceCode:d}),Ke=i.strictObject({approve:i.boolean()}),F=i.object({id:d,slug:i.string(),name:i.string()}),Qe=i.object({deviceCode:d,userCode:i.string().regex(/^[ABCDEFGHJKLMNPQRSTUVWXYZ23456789]{4}-[ABCDEFGHJKLMNPQRSTUVWXYZ23456789]{4}$/),verificationUrl:i.url(),expiresAt:i.iso.datetime(),interval:i.number().int().min(1).max(60)}),Ve=i.discriminatedUnion("status",[i.object({status:i.literal("pending"),interval:i.number().int().min(1).max(60)}),i.object({status:i.literal("denied")}),i.object({status:i.literal("approved"),id:d,space:F,scopes:y.shape.scopes,expiresAt:i.iso.datetime()})]),et=i.object({device:q.nullable().default(null),userCode:i.string(),name:i.string(),scopes:y.shape.scopes,status:i.enum(["pending","approved","denied"]),expiresAt:i.iso.datetime(),tokenExpiresAt:i.iso.datetime(),space:F});var tt=i.object({devices:i.array(i.object({id:d,name:i.string(),device:q.nullable().default(null),scopes:y.shape.scopes,createdAt:i.iso.datetime(),completedAt:i.iso.datetime().nullable(),lastUsedAt:i.iso.datetime().nullable(),lastIp:i.union([i.ipv4(),i.ipv6()]).nullable().default(null),lastLocation:ge.nullable().default(null),expiresAt:i.iso.datetime().nullable()}))});var we=u.object({endpoint:A,token:b}).strict();async function ye({form:t,onProgress:e}){let r=new Response(t),n=r.headers.get("content-type");if(!n)throw new Error("Could not encode the upload");let a=new Uint8Array(await r.arrayBuffer()),s=0;return e({loadedBytes:0,totalBytes:a.byteLength}),{body:new ReadableStream({pull(p){let c=Math.min(s+65536,a.byteLength);p.enqueue(a.subarray(s,c)),s=c,e({loadedBytes:s,totalBytes:a.byteLength}),s===a.byteLength&&p.close()}},{highWaterMark:0}),headers:{"content-type":n,"content-length":String(a.byteLength)},duplex:"half"}}var k=class extends Error{constructor(r,n,a){super(n);this.code=r;this.status=a}code;status},P=class{settings;constructor(e){this.settings=we.parse(e)}async request(e,r,n={}){let a=new Headers(n.headers);a.set("authorization",`Bearer ${this.settings.token}`),typeof n.body=="string"&&a.set("content-type","application/json");let s;try{s=await fetch(new URL(e,this.settings.endpoint),{...n,headers:a,redirect:"error",signal:n.signal?AbortSignal.any([n.signal,AbortSignal.timeout(6e4)]):AbortSignal.timeout(6e4)})}catch{throw new k("connection_failed","Request failed or timed out. Check SESHAT_ENDPOINT; retry uploads with the same --request-id")}let l=await s.json();if(!s.ok){let p=te.safeParse(l);throw new k(p.success?p.data.error.code:"request_failed",p.success?p.data.error.message:`HTTP ${s.status}`,s.status)}return r.parse(l)}async upload(e){let r=L.parse({filename:e.filename,contentType:e.contentType,size:e.bytes.byteLength}),n=w.parse(e.metadata),a=$.parse(e.requestId),s=new FormData;if(s.set("metadata",JSON.stringify(n)),s.set("file",new Blob([new Uint8Array(e.bytes)],{type:r.contentType}),r.filename),e.onProgress){let l=await ye({form:s,onProgress:e.onProgress}),p={...l,method:"POST",headers:{...l.headers,"idempotency-key":a}};return this.request("/v1/artifacts",v,p)}return this.request("/v1/artifacts",v,{method:"POST",body:s,headers:{"idempotency-key":a}})}list(e={}){let r=new URLSearchParams;return e.limit!==void 0&&r.set("limit",String(e.limit)),e.cursor!==void 0&&r.set("cursor",e.cursor),this.request(`/v1/artifacts?${r}`,V)}get(e){return this.request(`/v1/artifacts/${d.parse(e)}`,v)}update(e,r){return this.request(`/v1/artifacts/${d.parse(e)}`,v,{method:"PATCH",body:JSON.stringify(Z.parse(r))})}delete(e){return this.request(`/v1/artifacts/${d.parse(e)}`,u.object({deleted:u.literal(!0),id:d}),{method:"DELETE"})}whoami(e={}){return this.request("/v1/me",ee,{signal:e.signal})}completeConnection(){return this.request("/v1/auth/complete",u.object({completed:u.literal(!0)}),{method:"POST"})}revokeSelf(){return this.request("/v1/auth/logout",u.object({revoked:u.literal(!0),id:d}),{method:"POST"})}createFolder(e){return this.request("/v1/artifacts",v,{method:"POST",body:JSON.stringify(G.parse({...e.folder,kind:"folder"})),headers:{"idempotency-key":$.parse(e.requestId)}})}putFile(e,r){return this.request(`/v1/artifacts/${d.parse(e)}/files/${T.parse(r.path).split("/").map(encodeURIComponent).join("/")}`,R,{method:"PUT",body:new Blob([new Uint8Array(r.bytes)]),headers:{"content-type":r.contentType??"application/octet-stream"}})}listFiles(e){return this.request(`/v1/artifacts/${d.parse(e)}/files`,K)}deleteFile(e,r){return this.request(`/v1/artifacts/${d.parse(e)}/files/${T.parse(r).split("/").map(encodeURIComponent).join("/")}`,u.object({deleted:u.literal(!0),path:u.string()}),{method:"DELETE"})}createSpace(e){return this.request("/v1/admin/spaces",_,{method:"POST",body:JSON.stringify(Q.parse(e))})}createToken(e){return this.request("/v1/tokens",z,{method:"POST",body:JSON.stringify(y.parse(e))})}revokeToken(e){return this.request(`/v1/tokens/${d.parse(e)}`,u.object({revoked:u.literal(!0),id:d}),{method:"DELETE"})}};import{constants as oe}from"node:fs";import{lstat as xe,mkdir as Se,open as N,rename as be,unlink as ne}from"node:fs/promises";import{homedir as ve}from"node:os";import{join as E,resolve as ke}from"node:path";import{randomUUID as ie}from"node:crypto";import{setTimeout as Te}from"node:timers/promises";import{z as h}from"zod";var wt=h.enum(["keychain","file"]),ae=h.strictObject({endpoint:A,tokenId:d,space:F,scopes:h.array(j),expiresAt:h.iso.datetime(),pendingConnection:h.literal(!0).optional(),credential:h.discriminatedUnion("kind",[h.strictObject({kind:h.literal("keychain"),account:h.string().min(1)}),h.strictObject({kind:h.literal("file"),token:b})])}),Ee=h.strictObject({version:h.literal(1),profiles:h.record(O,ae)});function se(){return ke(process.env.SESHAT_CONFIG_DIR??E(process.env.XDG_CONFIG_HOME??E(ve(),".config"),"seshat"))}function ce(t){return t instanceof Error&&"code"in t&&t.code==="ENOENT"}async function le(t,e=!1){let r=await xe(t);if(r.isSymbolicLink()||(e?!r.isDirectory():!r.isFile()))throw new Error("Seshat credential paths must be real files and directories, not symlinks");if(process.platform!=="win32"&&((r.mode&63)!==0||process.getuid&&r.uid!==process.getuid()))throw new Error(`Credential path must belong to you and have ${e?"0700":"0600"} permissions: ${t}`)}async function pe(){let t=se();try{await le(t,!0);let e=E(t,"profiles.json"),r=await N(e,oe.O_RDONLY|(oe.O_NOFOLLOW??0));try{let n=await r.stat();if(!n.isFile()||n.size>65536||process.platform!=="win32"&&((n.mode&63)!==0||process.getuid&&n.uid!==process.getuid()))throw new Error("Credential file must be a small, owner-only regular file");try{let a=Ee.safeParse(JSON.parse(await r.readFile("utf8")));if(a.success)return a.data}catch{}throw new Error("Invalid Seshat profile file. Run seshat login again")}finally{await r.close()}}catch(e){if(ce(e))return{version:1,profiles:{}};throw e}}async function H(t,e){let r=se();await Se(r,{recursive:!0,mode:448}),await le(r,!0);let n=E(r,"profiles.lock"),a;for(let l=0;l<40;l++)try{a=await N(n,"wx",384);break}catch(p){if(!(p instanceof Error&&"code"in p&&p.code==="EEXIST"))throw p;await Te(50)}if(!a)throw new Error("Another Seshat process is updating profiles. Retry shortly; if it stopped unexpectedly, remove profiles.lock from your Seshat config directory");let s=E(r,`profiles-${ie()}.tmp`);try{e?.throwIfAborted();let l=t(await pe()),p=await N(s,"wx",384);try{let c=JSON.stringify(l)+`
|
|
1
|
+
import{z as o}from"zod";import{z as ue}from"zod";var C=ue.enum(["never","hour","day","week","month","year","custom"]);var S=10*1024*1024,U=100,I=100*1024*1024,Y=["artifacts:read","artifacts:write","artifacts:delete","tokens:manage"],j=o.enum(Y),d=o.string().regex(/^[a-f0-9]{48}$/),$=o.string().min(8).max(128).regex(/^[A-Za-z0-9_-]+$/),b=o.string().regex(/^seshat_[A-Za-z0-9_-]{43}$/),J=o.iso.datetime().transform(t=>new Date(t).toISOString());function D(t){return t.expirationPreset==null||(t.expirationPreset==="never"?t.expiresAt===null:typeof t.expiresAt=="string")}var w=o.object({title:o.string().trim().min(1).max(200).optional(),description:o.string().max(2e3).default(""),expiresAt:J.nullable().optional(),expirationPreset:C.nullable().optional(),password:o.string().min(12).max(128).nullable().optional(),generateMetadata:o.boolean().optional()}).strict().refine(D,"Expiration preset must match an explicit expiration value"),L=o.object({filename:o.string().min(1).max(200).regex(/^[^/\\\x00-\x1f\x7f]+$/),contentType:o.string().max(150).regex(/^[a-z0-9!#$&^_.+-]+\/[a-z0-9!#$&^_.+-]+$/i),size:o.number().int().min(1).max(S)}).strict(),Z=o.object({title:w.shape.title.optional(),description:o.string().max(2e3).optional(),expiresAt:w.shape.expiresAt,expirationPreset:w.shape.expirationPreset,password:w.shape.password}).strict().refine(D,"Expiration preset must match an explicit expiration value").refine(t=>Object.values(t).some(e=>e!==void 0),"Provide at least one metadata field"),T=o.string().min(1).max(400).regex(/^[^\\\x00-\x1f\x7f]+$/).refine(t=>{let e=t.split("/");return e.length<=12&&e.every(r=>r.length>0&&r.length<=200&&r!=="."&&r!==".."&&!r.startsWith("~"))},"Use a relative path such as css/site.css"),G=o.object({kind:o.literal("folder"),name:L.shape.filename,title:w.shape.title,description:w.shape.description,expiresAt:w.shape.expiresAt,expirationPreset:w.shape.expirationPreset,password:w.shape.password}).strict().refine(D,"Expiration preset must match an explicit expiration value"),R=o.object({path:T,contentType:o.string(),size:o.number(),digest:o.string().regex(/^[a-f0-9]{64}$/)}),K=o.object({files:o.array(R)}),Q=o.object({slug:o.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).min(2).max(63),name:o.string().trim().min(1).max(100)}).strict(),y=o.object({name:o.string().trim().min(1).max(100),scopes:o.array(j).min(1).max(Y.length),expiresAt:J.optional()}).strict(),v=o.object({id:d,title:o.string(),description:o.string(),filename:o.string(),contentType:o.string(),size:o.number(),createdAt:o.string(),updatedAt:o.string().nullable().default(null),expiresAt:o.string().nullable(),expirationPreset:C.nullable().default(null),url:o.url(),downloadUrl:o.url(),passwordProtected:o.boolean().default(!1),kind:o.enum(["file","folder"]).default("file"),views:o.object({owner:o.number(),others:o.number()})}),V=o.object({artifacts:o.array(v),nextCursor:o.string().nullable()}),z=o.object({id:d,token:b,scopes:o.array(j),expiresAt:o.string().nullable()}),_=o.object({space:o.object({id:d,slug:o.string(),name:o.string()}),credential:z}),ee=o.object({spaceId:d,tokenId:d,scopes:y.shape.scopes,space:_.shape.space.optional()}),te=o.object({error:o.object({code:o.string(),message:o.string()})});import{z as u}from"zod";import{z as i}from"zod";var re="https://app.seshat.sh",A=i.url().refine(t=>{let e=new URL(t);return!e.username&&!e.password&&!e.search&&!e.hash&&e.pathname==="/"&&(e.protocol==="https:"||e.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(e.hostname))},"Use an HTTPS origin, or HTTP localhost for development").transform(t=>new URL(t).origin),O=i.string().min(1).max(64).regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]*$/),Je=i.string().max(16).transform(t=>t.toUpperCase().replaceAll("-","").trim()).pipe(i.string().regex(/^[ABCDEFGHJKLMNPQRSTUVWXYZ23456789]{8}$/)),M=i.string().trim().min(1).max(80).regex(/^[^\u0000-\u001f\u007f-\u009f\u061c\u200e\u200f\u2028-\u202e\u2066-\u2069]+$/),ge=i.strictObject({city:M.optional(),region:M.optional(),country:i.string().regex(/^[A-Z]{2}$/).optional()}).refine(t=>!!(t.city||t.region||t.country),"Location is unavailable"),q=i.strictObject({kind:i.enum(["laptop","desktop","phone","tablet","terminal"]),os:i.enum(["macos","windows","linux","android","ios","other"]),model:M.optional(),client:i.enum(["terminal","agent"])});var Ze=y.extend({tokenHash:i.string().regex(/^[a-f0-9]{64}$/),device:q.optional()}).strict().refine(t=>!t.expiresAt||Date.parse(t.expiresAt)>Date.now()&&Date.parse(t.expiresAt)<=Date.now()+366*864e5,"Choose a credential expiry within the next year"),Ge=i.strictObject({deviceCode:d}),Ke=i.strictObject({approve:i.boolean()}),F=i.object({id:d,slug:i.string(),name:i.string()}),Qe=i.object({deviceCode:d,userCode:i.string().regex(/^[ABCDEFGHJKLMNPQRSTUVWXYZ23456789]{4}-[ABCDEFGHJKLMNPQRSTUVWXYZ23456789]{4}$/),verificationUrl:i.url(),expiresAt:i.iso.datetime(),interval:i.number().int().min(1).max(60)}),Ve=i.discriminatedUnion("status",[i.object({status:i.literal("pending"),interval:i.number().int().min(1).max(60)}),i.object({status:i.literal("denied")}),i.object({status:i.literal("approved"),id:d,space:F,scopes:y.shape.scopes,expiresAt:i.iso.datetime()})]),et=i.object({device:q.nullable().default(null),userCode:i.string(),name:i.string(),scopes:y.shape.scopes,status:i.enum(["pending","approved","denied"]),expiresAt:i.iso.datetime(),tokenExpiresAt:i.iso.datetime(),space:F});var tt=i.object({devices:i.array(i.object({id:d,name:i.string(),device:q.nullable().default(null),scopes:y.shape.scopes,createdAt:i.iso.datetime(),completedAt:i.iso.datetime().nullable(),lastUsedAt:i.iso.datetime().nullable(),lastIp:i.union([i.ipv4(),i.ipv6()]).nullable().default(null),lastLocation:ge.nullable().default(null),expiresAt:i.iso.datetime().nullable()}))});var we=u.object({endpoint:A,token:b}).strict();async function ye({form:t,onProgress:e}){let r=new Response(t),n=r.headers.get("content-type");if(!n)throw new Error("Could not encode the upload");let a=new Uint8Array(await r.arrayBuffer()),s=0;return e({loadedBytes:0,totalBytes:a.byteLength}),{body:new ReadableStream({pull(p){let c=Math.min(s+65536,a.byteLength);p.enqueue(a.subarray(s,c)),s=c,e({loadedBytes:s,totalBytes:a.byteLength}),s===a.byteLength&&p.close()}},{highWaterMark:0}),headers:{"content-type":n,"content-length":String(a.byteLength)},duplex:"half"}}var k=class extends Error{constructor(r,n,a){super(n);this.code=r;this.status=a}code;status},P=class{settings;constructor(e){this.settings=we.parse(e)}async request(e,r,n={}){let a=new Headers(n.headers);a.set("authorization",`Bearer ${this.settings.token}`),typeof n.body=="string"&&a.set("content-type","application/json");let s;try{s=await fetch(new URL(e,this.settings.endpoint),{...n,headers:a,redirect:"error",signal:n.signal?AbortSignal.any([n.signal,AbortSignal.timeout(6e4)]):AbortSignal.timeout(6e4)})}catch{throw new k("connection_failed","Request failed or timed out. Check SESHAT_ENDPOINT; retry uploads with the same --request-id")}let l=await s.json();if(!s.ok){let p=te.safeParse(l);throw new k(p.success?p.data.error.code:"request_failed",p.success?p.data.error.message:`HTTP ${s.status}`,s.status)}return r.parse(l)}async upload(e){let r=L.parse({filename:e.filename,contentType:e.contentType,size:e.bytes.byteLength}),n=w.parse(e.metadata),a=$.parse(e.requestId),s=new FormData;if(s.set("metadata",JSON.stringify(n)),s.set("file",new Blob([new Uint8Array(e.bytes)],{type:r.contentType}),r.filename),e.onProgress){let l=await ye({form:s,onProgress:e.onProgress}),p={...l,method:"POST",headers:{...l.headers,"idempotency-key":a}};return this.request("/v1/artifacts",v,p)}return this.request("/v1/artifacts",v,{method:"POST",body:s,headers:{"idempotency-key":a}})}list(e={}){let r=new URLSearchParams;return e.limit!==void 0&&r.set("limit",String(e.limit)),e.cursor!==void 0&&r.set("cursor",e.cursor),this.request(`/v1/artifacts?${r}`,V)}get(e){return this.request(`/v1/artifacts/${d.parse(e)}`,v)}update(e,r){return this.request(`/v1/artifacts/${d.parse(e)}`,v,{method:"PATCH",body:JSON.stringify(Z.parse(r))})}delete(e){return this.request(`/v1/artifacts/${d.parse(e)}`,u.object({deleted:u.literal(!0),id:d}),{method:"DELETE"})}whoami(e={}){return this.request("/v1/me",ee,{signal:e.signal})}completeConnection(){return this.request("/v1/auth/complete",u.object({completed:u.literal(!0)}),{method:"POST"})}revokeSelf(){return this.request("/v1/auth/logout",u.object({revoked:u.literal(!0),id:d}),{method:"POST"})}createFolder(e){return this.request("/v1/artifacts",v,{method:"POST",body:JSON.stringify(G.parse({...e.folder,kind:"folder"})),headers:{"idempotency-key":$.parse(e.requestId)}})}putFile(e,r){return this.request(`/v1/artifacts/${d.parse(e)}/files/${T.parse(r.path).split("/").map(encodeURIComponent).join("/")}`,R,{method:"PUT",body:new Blob([new Uint8Array(r.bytes)]),headers:{"content-type":r.contentType??"application/octet-stream"}})}listFiles(e){return this.request(`/v1/artifacts/${d.parse(e)}/files`,K)}deleteFile(e,r){return this.request(`/v1/artifacts/${d.parse(e)}/files/${T.parse(r).split("/").map(encodeURIComponent).join("/")}`,u.object({deleted:u.literal(!0),path:u.string()}),{method:"DELETE"})}createSpace(e){return this.request("/v1/admin/spaces",_,{method:"POST",body:JSON.stringify(Q.parse(e))})}createToken(e){return this.request("/v1/tokens",z,{method:"POST",body:JSON.stringify(y.parse(e))})}revokeToken(e){return this.request(`/v1/tokens/${d.parse(e)}`,u.object({revoked:u.literal(!0),id:d}),{method:"DELETE"})}};import{constants as oe}from"node:fs";import{lstat as xe,mkdir as Se,open as N,rename as be,unlink as ne}from"node:fs/promises";import{homedir as ve}from"node:os";import{join as E,resolve as ke}from"node:path";import{randomUUID as ie}from"node:crypto";import{setTimeout as Te}from"node:timers/promises";import{z as h}from"zod";var wt=h.enum(["keychain","file"]),ae=h.strictObject({endpoint:A,tokenId:d,space:F,scopes:h.array(j),expiresAt:h.iso.datetime(),pendingConnection:h.literal(!0).optional(),credential:h.discriminatedUnion("kind",[h.strictObject({kind:h.literal("keychain"),account:h.string().min(1)}),h.strictObject({kind:h.literal("file"),token:b})])}),Ee=h.strictObject({version:h.literal(1),profiles:h.record(O,ae)});function se(){return ke(process.env.SESHAT_CONFIG_DIR??E(process.env.XDG_CONFIG_HOME??E(ve(),".config"),"seshat"))}function ce(t){return t instanceof Error&&"code"in t&&t.code==="ENOENT"}async function le(t,e=!1){let r=await xe(t);if(r.isSymbolicLink()||(e?!r.isDirectory():!r.isFile()))throw new Error("Seshat credential paths must be real files and directories, not symlinks");if(process.platform!=="win32"&&((r.mode&63)!==0||process.getuid&&r.uid!==process.getuid()))throw new Error(`Credential path must belong to you and have ${e?"0700":"0600"} permissions: ${t}`)}async function pe(){let t=se();try{await le(t,!0);let e=E(t,"profiles.json"),r=await N(e,oe.O_RDONLY|(oe.O_NOFOLLOW??0));try{let n=await r.stat();if(!n.isFile()||n.size>65536||process.platform!=="win32"&&((n.mode&63)!==0||process.getuid&&n.uid!==process.getuid()))throw new Error("Credential file must be a small, owner-only regular file");try{let a=Ee.safeParse(JSON.parse(await r.readFile("utf8")));if(a.success)return a.data}catch{}throw new Error("Invalid Seshat profile file. Run seshat login again")}finally{await r.close()}}catch(e){if(ce(e))return{version:1,profiles:{}};throw e}}async function H(t,e){let r=se();await Se(r,{recursive:!0,mode:448}),await le(r,!0);let n=E(r,"profiles.lock"),a;for(let l=0;l<40;l++)try{a=await N(n,"wx",384);break}catch(p){if(!(p instanceof Error&&"code"in p&&p.code==="EEXIST"))throw p;await Te(50)}if(!a)throw new Error("Another Seshat process is updating profiles. Retry shortly; if it stopped unexpectedly, remove profiles.lock from your Seshat config directory");let s=E(r,`profiles-${ie()}.tmp`);try{e?.throwIfAborted();let l=t(await pe()),p=await N(s,"wx",384);try{let c=JSON.stringify(l)+`
|
|
2
2
|
`;if(Buffer.byteLength(c)>65536)throw new Error("Too many stored profiles; remove unused connections before adding another");await p.writeFile(c),await p.sync()}finally{await p.close()}e?.throwIfAborted(),await be(s,E(r,"profiles.json"))}finally{try{await ne(s).catch(l=>{if(!ce(l))throw l})}finally{await a.close(),await ne(n)}}}async function W(t){let{AsyncEntry:e}=await import("@napi-rs/keyring");return new e("dev.djamil.seshat.cli",t,{linux:{store:"secret-service"}})}async function B(t){t.credential.kind==="keychain"&&await(await W(t.credential.account)).deletePassword(AbortSignal.timeout(15e3))}async function yt(t){let e=O.parse(t.name),r=b.parse(t.token);if(t.storage==="file"&&process.platform==="win32")throw new Error("Use keychain storage with Windows Credential Manager");let n=ie();if(t.storage==="keychain")try{await(await W(n)).setPassword(r,t.signal?AbortSignal.any([t.signal,AbortSignal.timeout(15e3)]):AbortSignal.timeout(15e3))}catch{throw t.signal?.aborted?new Error("Connection cancelled"):new Error("The OS credential vault is unavailable. On a headless POSIX machine, rerun login with --storage file to use an owner-only credential file")}let a=ae.parse({pendingConnection:t.pendingConnection,endpoint:t.endpoint,tokenId:t.tokenId,space:t.space,scopes:t.scopes,expiresAt:t.expiresAt,credential:t.storage==="keychain"?{kind:"keychain",account:n}:{kind:"file",token:r}}),s;try{await H(l=>{if(s=Object.hasOwn(l.profiles,e)?l.profiles[e]:void 0,(s?.tokenId??null)!==t.expectedTokenId)throw new Error("This profile changed during login. Retry; the newer connection has been preserved");return{...l,profiles:{...l.profiles,[e]:a}}},t.signal)}catch(l){throw await B(a).catch(()=>{}),l}return s&&await B(s).catch(()=>{process.stderr.write(`The previous OS credential entry could not be removed. Revoke its token in Seshat Agent access.
|
|
3
3
|
`)}),a}function Ae(t){return O.parse(t??process.env.SESHAT_PROFILE??"default")}async function de(t){let e=await pe();return Object.hasOwn(e.profiles,t)?e.profiles[t]:void 0}async function Pe(t){if(t.credential.kind==="file")return t.credential.token;try{return b.parse(await(await W(t.credential.account)).getPassword(AbortSignal.timeout(15e3)))}catch{throw new Error("Stored credential is unavailable. Run seshat login again for this profile")}}async function xt(t,e){let r=await de(t);if(r){if(r.tokenId!==e)throw new Error("This profile changed during logout. The newer connection has been preserved");await B(r),await H(n=>{let a=Object.hasOwn(n.profiles,t)?n.profiles[t]:void 0;if(a&&a.tokenId!==e)throw new Error("This profile changed during logout. The newer connection has been preserved");let s={...n.profiles};return delete s[t],{...n,profiles:s}})}}async function je(t,e,r){e.pendingConnection&&(await r.completeConnection(),await H(n=>{let a=Object.hasOwn(n.profiles,t)?n.profiles[t]:void 0;if(a?.tokenId!==e.tokenId)throw new Error("This profile changed during connection. The newer connection has been preserved");let{pendingConnection:s,...l}=a;return{...n,profiles:{...n.profiles,[t]:l}}}))}async function St(t={}){let e=t.endpoint??process.env.SESHAT_ENDPOINT;if(process.env.SESHAT_TOKEN&&!t.profile&&!process.env.SESHAT_PROFILE)return new P({endpoint:e??re,token:process.env.SESHAT_TOKEN});let r=Ae(t.profile),n=await de(r);if(!n)throw new Error(`No credential for profile "${r}". Run seshat login --profile ${r}`);if(e&&A.parse(e)!==n.endpoint)throw new Error("This profile belongs to another endpoint. Log in with a different --profile; stored credentials are never sent to a different service");let a=new P({endpoint:n.endpoint,token:await Pe(n)});return await je(r,n,a),a}function bt(t,e){return{profile:t,endpoint:e.endpoint,tokenId:e.tokenId,space:e.space,scopes:e.scopes,expiresAt:e.expiresAt,storage:e.credential.kind}}var Oe={html:"text/html",htm:"text/html",md:"text/markdown",markdown:"text/markdown",json:"application/json",pdf:"application/pdf",txt:"text/plain",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",avif:"image/avif",mp4:"video/mp4",m4v:"video/mp4",webm:"video/webm",mov:"video/quicktime",ogv:"video/ogg",mp3:"audio/mpeg",m4a:"audio/mp4",aac:"audio/aac",wav:"audio/wav",ogg:"audio/ogg",oga:"audio/ogg",opus:"audio/ogg",flac:"audio/flac"};function fe(t){return Oe[t.split(".").at(-1)?.toLowerCase()??""]}import{realpath as me,stat as Fe,readFile as Ce}from"node:fs/promises";import{basename as Ue,relative as Ie,isAbsolute as $e}from"node:path";async function X(t,e){if(!(await Promise.all(e.map(n=>me(n)))).some(n=>{let a=Ie(n,t);return a!==".."&&!a.startsWith("../")&&!$e(a)}))throw new Error("File is outside SESHAT_UPLOAD_ROOTS. Configure explicit directories for MCP file access")}async function jt(t,e){let r=await me(t);e&&await X(r,e);let n=await Fe(r);if(!n.isFile())throw new Error("Upload path must be a regular file");if(n.size<1||n.size>S)throw new Error(`File must contain 1 to ${S} bytes`);return{bytes:new Uint8Array(await Ce(r)),filename:Ue(r),contentType:fe(r)??"application/octet-stream"}}import{createHash as De}from"node:crypto";import{lstat as he,readdir as Le,readFile as Re,realpath as ze}from"node:fs/promises";import{basename as _e,join as Me}from"node:path";function Lt(t){let e=/(?:^|\/a\/)([a-f0-9]{48})(?:[/?#]|$)/.exec(t.trim())?.[1];if(!e)throw new Error("Provide a folder ID or its share link with --into");return d.parse(e)}async function Rt(t,e={}){let r=(e.prefix??"").replace(/^\/+|\/+$/g,""),n=new Map,a=(c,f,m)=>{let g=T.safeParse(r?`${r}/${c}`:c);if(!g.success)throw new Error(`${f} cannot be stored as ${c}. Use plain relative names without "..", "~" or backslashes`);let x=n.get(g.data);if(x)throw new Error(`${x.source} and ${f} would both become ${g.data}. Upload one of them with a different --prefix`);if(m<1||m>S)throw new Error(`${f} must contain 1 to ${S} bytes`);n.set(g.data,{path:g.data,source:f,size:m})},s=c=>!e.includeHidden&&(c.startsWith(".")||c==="node_modules"),l=async(c,f)=>{for(let m of(await Le(c,{withFileTypes:!0})).sort((g,x)=>g.name.localeCompare(x.name))){if(s(m.name))continue;let g=Me(c,m.name),x=f?`${f}/${m.name}`:m.name;m.isDirectory()?await l(g,x):m.isFile()&&a(x,g,(await he(g)).size)}};for(let c of t){let f=await ze(c);e.allowedRoots&&await X(f,e.allowedRoots);let m=await he(f);if(m.isDirectory())await l(f,"");else if(m.isFile())a(_e(f),f,m.size);else throw new Error(`${c} is not a file or a directory`)}let p=[...n.values()];if(!p.length)throw new Error("Nothing to upload. The paths contain no files");if(p.length>U)throw new Error(`A folder holds up to ${U} files; these paths contain ${p.length}`);if(p.reduce((c,f)=>c+f.size,0)>I)throw new Error(`A folder holds up to ${I/1024/1024} MiB`);return p}async function zt(t,e,r,n=()=>{}){let a=new Map;try{for(let c of(await t.listFiles(e)).files)a.set(c.path,c.digest)}catch(c){if(!(c instanceof k)||c.code!=="insufficient_scope")throw c}let s={uploaded:0,unchanged:0,failed:[]},l=[...r],p=0;return n({completed:p,total:r.length}),await Promise.all(Array.from({length:Math.min(4,r.length)},async()=>{for(let c=l.shift();c;c=l.shift()){try{let f=new Uint8Array(await Re(c.source));a.get(c.path)===De("sha256").update(f).digest("hex")?s.unchanged++:(await t.putFile(e,{path:c.path,bytes:f}),s.uploaded++)}catch(f){s.failed.push({path:c.path,code:f instanceof k?f.code:"read_failed",message:f instanceof Error?f.message:"Upload failed"})}n({completed:++p,total:r.length})}})),s}export{S as a,j as b,d as c,$ as d,w as e,Z as f,T as g,G as h,te as i,re as j,A as k,q as l,Qe as m,Ve as n,k as o,P as p,wt as q,yt as r,Ae as s,de as t,Pe as u,xt as v,je as w,St as x,bt as y,jt as z,Lt as A,Rt as B,zt as C};
|
package/dist/cli.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{A as pe,B as fe,C as ue,a as W,b as L,d as J,i as oe,j as G,k as Y,l as se,m as ae,n as X,o as R,p as
|
|
2
|
+
import{A as pe,B as fe,C as ue,a as W,b as L,d as J,i as oe,j as G,k as Y,l as se,m as ae,n as X,o as R,p as U,q as ie,r as ce,s as $,t as M,u as V,v as de,w as Z,x as _,y as H,z as le}from"./chunk-73X6ZBVW.js";import{parseArgs as We}from"node:util";import{pathToFileURL as Je}from"node:url";import{realpathSync as Ge}from"node:fs";import{z as B}from"zod";import{execFile as Ce}from"node:child_process";import{readFile as me}from"node:fs/promises";import{promisify as Re}from"node:util";import{z as A}from"zod";var he=Re(Ce),$e=A.coerce.number().int().min(1).max(36),Pe=A.object({SPHardwareDataType:A.array(A.object({machine_name:A.string().optional()}))}),De=A.object({model:A.string().optional(),chassis:A.array(A.number()).nullable().optional()});function Ne(e){let o=e.platform==="darwin"?"macos":e.platform==="win32"?"windows":e.platform==="android"?"android":e.platform==="linux"?"linux":"other",n="terminal";return o==="android"||e.chassis===11?n="phone":e.chassis===30?n="tablet":/^MacBook/i.test(e.model??"")||[8,9,10,14,31,32].includes(e.chassis??0)?n="laptop":(/^(?:iMac|Mac (?:mini|Pro|Studio))/i.test(e.model??"")||[3,4,5,6,7,13,15,16,24].includes(e.chassis??0))&&(n="desktop"),{kind:n,os:o,...e.model?{model:e.model}:{},client:e.client}}async function ge(e){let o,n;try{if(process.platform==="darwin"){let{stdout:i}=await he("/usr/sbin/system_profiler",["SPHardwareDataType","-detailLevel","mini","-json"],{timeout:2e3,maxBuffer:65536}),p=Pe.safeParse(JSON.parse(i));p.success&&(o=p.data.SPHardwareDataType[0]?.machine_name)}else if(process.platform==="linux"){let i=await Promise.all([me("/sys/class/dmi/id/product_name","utf8").catch(()=>""),me("/sys/class/dmi/id/chassis_type","utf8").catch(()=>"")]);o=i[0]?.trim();let p=$e.safeParse(i[1]?.trim());p.success&&(n=p.data)}else if(process.platform==="win32"){let{stdout:i}=await he("powershell.exe",["-NoProfile","-NonInteractive","-Command","[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new(); @{model=(Get-CimInstance Win32_ComputerSystem).Model;chassis=@((Get-CimInstance Win32_SystemEnclosure).ChassisTypes)} | ConvertTo-Json -Compress"],{timeout:2e3,maxBuffer:65536,windowsHide:!0}),p=De.safeParse(JSON.parse(i));p.success&&(o=p.data.model,n=p.data.chassis?.[0])}}catch{}let a=se.shape.model.safeParse(o);return Ne({platform:process.env.TERMUX_VERSION?"android":process.platform,model:a.success?a.data:void 0,chassis:n,client:e})}import{stripVTControlCharacters as Oe}from"node:util";function b(e){return Oe(e).replace(/[\u0000-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069]/g," ").trim()}function N(e){return e?new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}):"Never"}function g(e,o=[]){let n=Math.max(10,...o.map(([a])=>a.length+1));return`
|
|
3
3
|
${b(e)}
|
|
4
4
|
${o.length?`
|
|
5
5
|
`+o.map(([a,i])=>` ${a.padEnd(n)}${b(i)}`).join(`
|
|
6
6
|
`)+`
|
|
7
|
-
`:""}`}function F(e){let o={"artifacts:read":"Read artifacts","artifacts:write":"Upload and edit","artifacts:delete":"Delete artifacts","tokens:manage":"Manage tokens"};return e.map(n=>o[n]).join(" \xB7 ")}function Q(e,o,n){let a=e.profile==="default"?"":` --profile ${e.profile}`;return g(`${o?"\u2713 Already connected to":"\u2713 Connected to"} ${e.space.name}`,[["Profile",e.profile],["Service",e.endpoint],["Access",F(e.scopes)],["Expires",
|
|
7
|
+
`:""}`}function F(e){let o={"artifacts:read":"Read artifacts","artifacts:write":"Upload and edit","artifacts:delete":"Delete artifacts","tokens:manage":"Manage tokens"};return e.map(n=>o[n]).join(" \xB7 ")}function Q(e,o,n){let a=e.profile==="default"?"":` --profile ${e.profile}`;return g(`${o?"\u2713 Already connected to":"\u2713 Connected to"} ${e.space.name}`,[["Profile",e.profile],["Service",e.endpoint],["Access",F(e.scopes)],["Expires",N(e.expiresAt)],["Stored in",e.storage==="keychain"?"OS credential vault":"Private credential file (0600)"],[n?"Agent uses":"Try next",`seshat upload ./report.html${a}${n?" --json":""}`]])}function we(e){return new Date(e).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function j(e,o,n={}){return g(`${o} ${e.title}`,[["Link",e.url],["File",e.filename],["Size",`${new Intl.NumberFormat().format(e.size)} bytes`],...n.dates?[["Uploaded",we(e.createdAt)]]:[],...n.dates&&e.updatedAt&&e.updatedAt!==e.createdAt?[["Updated",we(e.updatedAt)]]:[],["Expires",N(e.expiresAt)]])}function ye(e,o){return process.env.NO_COLOR!==void 0||process.env.TERM==="dumb"?e:e.replace(/^([✓✕].*)$/m,n=>`\x1B[1;${o}m${n}\x1B[0m`)}function K(e,o,n){process.stdout.write(n?(process.stdout.isTTY?ye(o,process.exitCode?31:32):o)+`
|
|
8
8
|
`:JSON.stringify(e)+`
|
|
9
|
-
`)}function
|
|
10
|
-
`);return}let n=g(`\u2715 ${e.message}`,[["Code",e.code],...e.hint?[["Next step",e.hint]]:[],...e.requestId?[["Retry ID",e.requestId]]:[]]);process.stderr.write((process.stderr.isTTY?
|
|
11
|
-
`)}import{randomBytes as
|
|
9
|
+
`)}function ke(e,o){if(!o){process.stderr.write(JSON.stringify({error:{code:e.code,message:e.message},...e.requestId?{requestId:e.requestId}:{}})+`
|
|
10
|
+
`);return}let n=g(`\u2715 ${e.message}`,[["Code",e.code],...e.hint?[["Next step",e.hint]]:[],...e.requestId?[["Retry ID",e.requestId]]:[]]);process.stderr.write((process.stderr.isTTY?ye(n,31):n)+`
|
|
11
|
+
`)}import{randomBytes as Ue,createHash as _e}from"node:crypto";import{execFile as Fe}from"node:child_process";import{promisify as je}from"node:util";import{hostname as qe}from"node:os";import{setTimeout as Le}from"node:timers/promises";import{z as xe}from"zod";var ee=je(Fe);async function te(e,o,n,a,i){let p=await fetch(e+o,{method:"POST",redirect:"error",headers:{"content-type":"application/json"},body:JSON.stringify(n),signal:i?AbortSignal.any([i,AbortSignal.timeout(15e3)]):AbortSignal.timeout(15e3)}),t=await p.json();if(!p.ok){let h=oe.safeParse(t);throw new R(h.success?h.data.error.code:"connection_failed",h.success?h.data.error.message:"Could not connect to Seshat",p.status)}let d=a.safeParse(t);if(!d.success)throw new Error("Unexpected connection response from the service");return d.data}async function Me(e){process.platform==="darwin"?await ee("open",[e],{timeout:1e4}):process.platform==="win32"?await ee("rundll32",["url.dll,FileProtocolHandler",e],{timeout:1e4}):await ee("xdg-open",[e],{timeout:1e4})}async function ve(e){let o=$(e.profile),n=Y.parse(e.endpoint??process.env.SESHAT_ENDPOINT??G),a=ie.parse(e.storage??"keychain");if(a==="file"&&process.platform==="win32")throw new Error("Use keychain storage with Windows Credential Manager");let i=xe.array(L).min(1).parse((e.scopes??"artifacts:read,artifacts:write").split(",")),p=xe.coerce.number().int().min(5).max(600).parse(e.timeout??600),t=await M(o),d;if(t){try{d=new U({endpoint:t.endpoint,token:await V(t)})}catch{}if(!e.force&&e.expiresAt===void 0&&e.name===void 0&&(e.storage===void 0||e.storage===t.credential.kind)&&d&&t.endpoint===n&&t.expiresAt>new Date().toISOString()&&[...new Set(i)].sort().join(",")===[...t.scopes].sort().join(","))try{return await Z(o,t,d),await d.whoami(),{connected:!0,alreadyConnected:!0,...H(o,t)}}catch(k){if(!(k instanceof R&&k.status===401))throw k}}let h="seshat_"+Ue(32).toString("base64url"),y=_e("sha256").update(h).digest("hex"),f=await te(n,"/v1/auth/device",{name:e.name??`${qe().slice(0,60)} \xB7 ${o.slice(0,32)}`,scopes:i,tokenHash:y,device:await ge(e.agent?"agent":"terminal"),...e.expiresAt?{expiresAt:e.expiresAt}:{}},ae);if(!URL.canParse(f.verificationUrl))throw new Error("The service returned an invalid authorization URL");let s=new URL(f.verificationUrl);if(s.origin!==n||s.pathname!=="/connect"||s.username||s.password||s.hash||s.searchParams.get("code")!==f.userCode)throw new Error("The service returned an unexpected authorization URL");process.stderr.write(e.human?g("Connect this terminal to Seshat",[["Open",f.verificationUrl],["Code",f.userCode]])+`
|
|
12
12
|
Check the code in your browser, then approve this device.
|
|
13
13
|
Waiting for approval\u2026
|
|
14
14
|
|
|
15
15
|
`:`Approve this terminal in Seshat:
|
|
16
16
|
${f.verificationUrl}
|
|
17
17
|
Code: ${f.userCode}
|
|
18
|
-
`),e.noBrowser||await
|
|
19
|
-
`));let S=new AbortController,C=()=>S.abort();process.once("SIGINT",C);let l=Math.min(Date.parse(f.expiresAt),Date.now()+p*1e3),E=!1;try{let k=f.interval;for(;Date.now()<l&&(await
|
|
20
|
-
`)),{connected:!0,...H(o,r)}}throw new Error("Connection approval timed out. Run seshat login again")}finally{process.removeListener("SIGINT",C),E||await te(n,"/v1/auth/device/cancel",{deviceCode:f.deviceCode},X).catch(()=>{})}}async function
|
|
21
|
-
`)}d();let h=o?
|
|
18
|
+
`),e.noBrowser||await Me(f.verificationUrl).catch(()=>process.stderr.write(`Open the URL above in your browser to continue.
|
|
19
|
+
`));let S=new AbortController,C=()=>S.abort();process.once("SIGINT",C);let l=Math.min(Date.parse(f.expiresAt),Date.now()+p*1e3),E=!1;try{let k=f.interval;for(;Date.now()<l&&(await Le(Math.min(k*1e3,Math.max(0,l-Date.now())),void 0,{signal:S.signal}),!(Date.now()>=l));){let c;try{c=await te(n,"/v1/auth/device/poll",{deviceCode:f.deviceCode},X,S.signal)}catch(u){if(u instanceof R&&u.code==="slow_down"){k+=2;continue}throw u}if(c.status==="denied")throw new Error("Connection was denied. No credential was saved");if(c.status==="pending"){k=c.interval;continue}let m=await new U({endpoint:n,token:h}).whoami({signal:S.signal});if(m.spaceId!==c.space.id||m.tokenId!==c.id||[...new Set(i)].sort().join(",")!==[...m.scopes].sort().join(","))throw new Error("The approved credential does not match the requested space and permissions");S.signal.throwIfAborted();let r=await ce({name:o,endpoint:n,tokenId:c.id,token:h,space:c.space,scopes:c.scopes,expiresAt:c.expiresAt,storage:a,pendingConnection:!0,expectedTokenId:t?.tokenId??null,signal:S.signal});E=!0;try{await Z(o,r,new U({endpoint:n,token:h}))}catch{throw new Error("Credential saved, but connection completion was interrupted. Retry seshat auth status with this --profile to finish, or login --force if its five-minute approval expired")}return d&&await d.revokeSelf().catch(()=>process.stderr.write(`The previous credential could not be revoked. Revoke it in Seshat Agent access.
|
|
20
|
+
`)),{connected:!0,...H(o,r)}}throw new Error("Connection approval timed out. Run seshat login again")}finally{process.removeListener("SIGINT",C),E||await te(n,"/v1/auth/device/cancel",{deviceCode:f.deviceCode},X).catch(()=>{})}}async function be(e){let o=$(e),n=await M(o);if(!n)return{disconnected:!0,alreadyDisconnected:!0,profile:o};try{await new U({endpoint:n.endpoint,token:await V(n)}).revokeSelf()}catch(a){if(!(a instanceof R&&a.status===401))throw new Error("Could not revoke this connection. Retry logout when the service is available; the local credential has been kept")}return await de(o,n.tokenId),{disconnected:!0,profile:o}}async function Se(e={}){let o=$(e.profile);if(process.env.SESHAT_TOKEN&&!e.profile&&!process.env.SESHAT_PROFILE){let i=await(await _(e)).whoami();return{connected:!0,source:"environment",endpoint:Y.parse(e.endpoint??process.env.SESHAT_ENDPOINT??G),...i}}let n=await M(o);if(!n)return{connected:!1,profile:o};let a=await(await _(e)).whoami();return{connected:!0,...H(o,n),...a}}import He from"string-width";import{setInterval as Ke,clearInterval as Be}from"node:timers";var ze=new Intl.Segmenter(void 0,{granularity:"grapheme"}),P=e=>He(e,{ambiguousIsNarrow:!1});function Te({value:e,columns:o}){if(P(e)<=o)return e;if(o<1)return"";let n=o>=P("\u2026")?"\u2026":".",a=o-P(n),i="";for(let{segment:p}of ze.segment(e)){let t=P(p);if(t>a)break;i+=p,a-=t}return i+n}var Ee=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function Ie(e=process.stderr){let o=!!e.isTTY&&process.env.TERM!=="dumb",n={kind:"connecting"},a=0,i=!1,p="",t="artifact";function d(){if(i)return;let y=n.kind==="sending"?n.percent:n.kind==="processing"?100:n.kind==="batch"?Math.floor(100*n.completed/n.total):null,f=`${n.kind}:${y===null?"":Math.floor(y/10)}`;if(!o&&p===f)return;p=f;let s=Math.max(0,(e.columns??100)-1),S=o?Ee[a++%Ee.length]??"\u280B":"\u2026",C=s-P(S+" "),l;switch(n.kind){case"connecting":l="Connecting to Seshat\u2026";break;case"reading":l=`Reading ${n.filename}\u2026`;break;case"batch":l=`Uploading files\u2026 ${n.completed} of ${n.total}`;break;case"processing":l=s<35?"Preparing link\u2026":"Preparing your link\u2026 100% sent";break;case"sending":{let k=`Uploading\u2026 ${n.percent}%`,c=Math.floor(n.percent/10),m=` ${"\u2588".repeat(c)}${"\u2591".repeat(10-c)} ${n.percent}%`,r=C-P("Uploading "+m);C<P(k)?l=`${n.percent}%`:r<4?l=k:l=`Uploading ${Te({value:n.filename,columns:r})}${m}`;break}}let E=`${S} ${l}`;e.write(o?`\r\x1B[2K${Te({value:E,columns:s})}`:E+`
|
|
21
|
+
`)}d();let h=o?Ke(d,90):void 0;return h?.unref(),{reading(y){t=b(y),n={kind:"reading",filename:t},d()},transferred({loadedBytes:y,totalBytes:f}){let s=Math.min(100,Math.floor(100*y/f));n=s===100?{kind:"processing"}:{kind:"sending",filename:t,percent:s},d()},batch(y){n={kind:"batch",...y},d()},stop(){i||(i=!0,h&&Be(h),o&&e.write("\r\x1B[2K"))}}}var ne={root:`Seshat: publish and manage agent artifacts.
|
|
22
22
|
|
|
23
23
|
Commands default to human-readable output. Use --json for structured results and errors.
|
|
24
24
|
|
|
@@ -92,17 +92,18 @@ Examples:
|
|
|
92
92
|
seshat agent setup --profile t3 --name "T3 agent"
|
|
93
93
|
seshat agent setup --profile remote --storage file --no-browser`,"auth whoami":`Inspect the active token's space and scopes.
|
|
94
94
|
Example: seshat auth whoami`,mcp:`Start the local stdio MCP server. SESHAT_UPLOAD_ROOTS is an optional JSON array of allowed directories.
|
|
95
|
-
Example: seshat mcp`},
|
|
95
|
+
Example: seshat mcp`},Ye={help:{type:"boolean"},json:{type:"boolean"},title:{type:"string"},description:{type:"string"},"content-type":{type:"string"},filename:{type:"string"},"request-id":{type:"string"},"expires-at":{type:"string"},"no-expiry":{type:"boolean"},limit:{type:"string"},cursor:{type:"string"},yes:{type:"boolean"},"dry-run":{type:"boolean"},name:{type:"string"},scopes:{type:"string"},slug:{type:"string"},profile:{type:"string"},endpoint:{type:"string"},storage:{type:"string"},"no-browser":{type:"boolean"},timeout:{type:"string"},force:{type:"boolean"},folder:{type:"string"},into:{type:"string"},prefix:{type:"string"},"include-hidden":{type:"boolean"}},Xe={"artifacts upload":["title","description","content-type","filename","request-id","expires-at","no-expiry","folder","into","prefix","include-hidden"],"artifacts list":["limit","cursor"],"artifacts get":[],"artifacts update":["title","description","expires-at","no-expiry"],"artifacts delete":["yes","dry-run"],"tokens create":["name","scopes","expires-at"],"tokens revoke":["yes","dry-run"],"spaces create":["slug","name"],"auth whoami":[],"auth login":["name","scopes","expires-at","storage","no-browser","timeout","force"],"agent setup":["name","scopes","expires-at","storage","no-browser","timeout","force"],"auth logout":[],"auth status":[],mcp:[]};function T(e,o){let n=B.string().min(1).safeParse(e);if(!n.success)throw new Error(`Provide ${o}. Run this command with --help for an example`);return n.data}async function Ae(e){try{return await le(e)}catch(o){throw o instanceof Error&&/regular file/.test(o.message)?new Error(`${e} is a directory. Add --folder NAME to upload it as one folder`):o}}async function Ve(){let e=[],o=0;for await(let n of process.stdin){let a=Buffer.from(n);if(o+=a.length,o>W)throw new Error(`stdin exceeds ${W} bytes`);e.push(a)}return new Uint8Array(Buffer.concat(e))}async function Ze(e){let o,n,a=!e.includes("--json"),i="default",p="seshat --help";try{let{values:t,positionals:d}=We({args:e,options:Ye,allowPositionals:!0}),h={login:"auth login",logout:"auth logout",whoami:"auth whoami",upload:"artifacts upload",list:"artifacts list"},y=d[0]??"",f=Object.hasOwn(h,y)?h[y]:void 0,s=f??(y==="mcp"?"mcp":d.slice(0,2).join(" "));if(t.help||!s){process.stdout.write((ne[s]??ne.root)+(s?`
|
|
96
96
|
|
|
97
97
|
Output: human-readable by default. Use --json for structured results and errors.`:"")+`
|
|
98
|
-
`);return}if(!ne[s])throw new Error("Unknown command. Run seshat --help");p=`seshat ${s} --help`,i=$(t.profile??(s==="agent setup"?"agent":void 0));let S=["artifacts upload","artifacts get","artifacts update","artifacts delete","tokens revoke"].includes(s);if(s!=="artifacts upload"&&d.length>(s==="mcp"?1:(f?1:2)+(S?1:0)))throw new Error("Unexpected positional argument. Run this command with --help");let C=Object.keys(t).find(r=>!["help","json","profile","endpoint",...
|
|
98
|
+
`);return}if(!ne[s])throw new Error("Unknown command. Run seshat --help");p=`seshat ${s} --help`,i=$(t.profile??(s==="agent setup"?"agent":void 0));let S=["artifacts upload","artifacts get","artifacts update","artifacts delete","tokens revoke"].includes(s);if(s!=="artifacts upload"&&d.length>(s==="mcp"?1:(f?1:2)+(S?1:0)))throw new Error("Unexpected positional argument. Run this command with --help");let C=Object.keys(t).find(r=>!["help","json","profile","endpoint",...Xe[s]??[]].includes(r));if(C)throw new Error(`--${C} is not supported by ${s}. Run this command with --help`);if(s==="mcp"){let{startMcp:r}=await import("./mcp.js");await r({profile:t.profile,endpoint:t.endpoint});return}if(t["no-expiry"]&&t["expires-at"])throw new Error("Choose --no-expiry or --expires-at");if(s==="auth login"||s==="agent setup"){let r=s==="agent setup"?$(t.profile??"agent"):$(t.profile),u=await ve({profile:r,endpoint:t.endpoint,name:t.name,scopes:t.scopes??(s==="agent setup"?"artifacts:write":void 0),expiresAt:t["expires-at"],storage:t.storage,noBrowser:t["no-browser"],timeout:t.timeout,force:t.force,human:a,agent:s==="agent setup"}),z=s==="agent setup"?{...u,agent:{environment:{SESHAT_PROFILE:r},uploadCommand:`pnpx @seshat.sh/cli upload FILE --profile ${r} --json`,helpCommand:"pnpx @seshat.sh/cli upload --help"}}:u;K(z,Q(u,"alreadyConnected"in u&&!!u.alreadyConnected,s==="agent setup"),a);return}if(s==="auth logout"||s==="auth status"){let r=s==="auth logout"?await be(t.profile):await Se({profile:t.profile,endpoint:t.endpoint}),u="disconnected"in r?g(r.alreadyDisconnected?"\u2713 No saved connection":"\u2713 Device disconnected",[["Profile",r.profile]]):r.connected?"storage"in r?Q(r,!0,!1):g("\u2713 Connected with SESHAT_TOKEN",[["Service",r.endpoint],["Space",r.space?.name??r.spaceId],["Access",F(r.scopes)]]):g("No connected device",[["Profile",r.profile],["Next step",`seshat login --profile ${r.profile}`]]);K(r,u,a);return}a&&s==="artifacts upload"&&(n=Ie());let l=await _({profile:t.profile,endpoint:t.endpoint}),E=d[f?1:2],k=t["no-expiry"]?null:t["expires-at"],c,m="";switch(s){case"auth whoami":{let r=await l.whoami();c={spaceId:r.spaceId,tokenId:r.tokenId,scopes:r.scopes},m=g("\u2713 Connected to Seshat",[["Space",r.space?.name??r.spaceId],["Access",F(r.scopes)]]);break}case"spaces create":{let r=await l.createSpace({slug:T(t.slug,"--slug"),name:T(t.name,"--name")});c=r,m=g(`\u2713 Created ${r.space.name}`,[["Space ID",r.space.id],["Token",r.credential.token],["Keep safe","Copy this token now. It will not be shown again."]]);break}case"tokens create":{let r=await l.createToken({name:T(t.name,"--name"),scopes:B.array(L).parse((t.scopes??"artifacts:write").split(",")),expiresAt:t["expires-at"]});c=r,m=g("\u2713 Token created",[["Token",r.token],["Access",F(r.scopes)],["Expires",N(r.expiresAt)],["Keep safe","Copy this token now. It will not be shown again."]]);break}case"tokens revoke":{let r=T(E,"TOKEN_ID");if(t["dry-run"]){c={dryRun:!0,action:"revoke_token",id:r},m=g("Preview: revoke token",[["Token ID",r],["To apply",`seshat tokens revoke ${r} --yes`]]);break}if(!t.yes)throw new Error("Revocation requires --yes. Inspect with seshat tokens revoke TOKEN_ID --dry-run");c=await l.revokeToken(r),m=g("\u2713 Token revoked",[["Token ID",r]]);break}case"artifacts list":{let r=await l.list({limit:t.limit===void 0?void 0:B.coerce.number().int().min(1).max(100).parse(t.limit),cursor:t.cursor});c=r,m=g(r.artifacts.length?`${r.artifacts.length} artifacts`:"No artifacts yet")+r.artifacts.map(u=>`
|
|
99
99
|
${b(u.title)}
|
|
100
100
|
${b(u.url)}
|
|
101
|
+
Uploaded ${N(u.createdAt)}
|
|
101
102
|
`).join("")+(r.nextCursor?`
|
|
102
103
|
Next page: seshat list --cursor ${b(r.nextCursor)}
|
|
103
|
-
`:"");break}case"artifacts get":{let r=await l.get(T(E,"ARTIFACT_ID"));c=r,m=j(r,"Artifact:");break}case"artifacts update":{let r=await l.update(T(E,"ARTIFACT_ID"),{title:t.title,description:t.description,expiresAt:k});c=r,m=j(r,"\u2713 Updated");break}case"artifacts delete":{let r=T(E,"ARTIFACT_ID");if(t["dry-run"]){let u=await l.get(r);c={dryRun:!0,action:"delete_artifact",artifact:u},m=j(u,"Preview: delete")+`
|
|
104
|
+
`:"");break}case"artifacts get":{let r=await l.get(T(E,"ARTIFACT_ID"));c=r,m=j(r,"Artifact:",{dates:!0});break}case"artifacts update":{let r=await l.update(T(E,"ARTIFACT_ID"),{title:t.title,description:t.description,expiresAt:k});c=r,m=j(r,"\u2713 Updated");break}case"artifacts delete":{let r=T(E,"ARTIFACT_ID");if(t["dry-run"]){let u=await l.get(r);c={dryRun:!0,action:"delete_artifact",artifact:u},m=j(u,"Preview: delete")+`
|
|
104
105
|
To apply: seshat artifacts delete ${r} --yes
|
|
105
|
-
`;break}if(!t.yes)throw new Error("Deletion requires --yes. Inspect with seshat artifacts delete ARTIFACT_ID --dry-run");c=await l.delete(r),m=g("\u2713 Artifact deleted",[["ID",r]]);break}case"artifacts upload":{let r=d.slice(f?1:2),u=T(r[0],"FILE or - for stdin");if(o=J.parse(t["request-id"]??crypto.randomUUID()),t.folder!==void 0||t.into!==void 0){if(t.folder!==void 0&&t.into!==void 0)throw new Error("Choose --folder NAME for a new folder or --into FOLDER for an existing one");if(t.into!==void 0&&(t.title!==void 0||t.description!==void 0||k!==void 0))throw new Error("--title, --description and expiry belong to a new folder. Change an existing one with seshat artifacts update");if(t["content-type"]!==void 0||t.filename!==void 0||r.includes("-"))throw new Error("Folders take files and directories. --content-type, --filename and stdin apply to a single upload");n?.reading(r.length===1?u:`${r.length} paths`);let I=await fe(r,{prefix:t.prefix,includeHidden:t["include-hidden"]}),w=t.folder===void 0?void 0:await l.createFolder({folder:{name:T(t.folder,"a name after --folder"),title:t.title,description:t.description??"",expiresAt:k},requestId:o}),v=w?.id??pe(t.into??""),x=await ue(l,v,I,n?.batch);c={...w??{id:v},requestId:o,files:{total:I.length,uploaded:x.uploaded,unchanged:x.unchanged},failed:x.failed},m=g(`${x.failed.length?"\u2715":"\u2713"} ${w?`Uploaded folder ${w.title}`:"Added to folder"}`,[...w?[["Link",w.url]]:[],["Folder ID",v],["Files",`${x.uploaded} uploaded${x.unchanged?`, ${x.unchanged} unchanged`:""}${x.failed.length?`, ${x.failed.length} failed`:""}`],...x.failed.slice(0,10).map(
|
|
106
|
+
`;break}if(!t.yes)throw new Error("Deletion requires --yes. Inspect with seshat artifacts delete ARTIFACT_ID --dry-run");c=await l.delete(r),m=g("\u2713 Artifact deleted",[["ID",r]]);break}case"artifacts upload":{let r=d.slice(f?1:2),u=T(r[0],"FILE or - for stdin");if(o=J.parse(t["request-id"]??crypto.randomUUID()),t.folder!==void 0||t.into!==void 0){if(t.folder!==void 0&&t.into!==void 0)throw new Error("Choose --folder NAME for a new folder or --into FOLDER for an existing one");if(t.into!==void 0&&(t.title!==void 0||t.description!==void 0||k!==void 0))throw new Error("--title, --description and expiry belong to a new folder. Change an existing one with seshat artifacts update");if(t["content-type"]!==void 0||t.filename!==void 0||r.includes("-"))throw new Error("Folders take files and directories. --content-type, --filename and stdin apply to a single upload");n?.reading(r.length===1?u:`${r.length} paths`);let I=await fe(r,{prefix:t.prefix,includeHidden:t["include-hidden"]}),w=t.folder===void 0?void 0:await l.createFolder({folder:{name:T(t.folder,"a name after --folder"),title:t.title,description:t.description??"",expiresAt:k},requestId:o}),v=w?.id??pe(t.into??""),x=await ue(l,v,I,n?.batch);c={...w??{id:v},requestId:o,files:{total:I.length,uploaded:x.uploaded,unchanged:x.unchanged},failed:x.failed},m=g(`${x.failed.length?"\u2715":"\u2713"} ${w?`Uploaded folder ${w.title}`:"Added to folder"}`,[...w?[["Link",w.url]]:[],["Folder ID",v],["Files",`${x.uploaded} uploaded${x.unchanged?`, ${x.unchanged} unchanged`:""}${x.failed.length?`, ${x.failed.length} failed`:""}`],...x.failed.slice(0,10).map(O=>[O.path,O.message]),...x.failed.length?[["Next step",`Repeat with --into ${v}; stored files are skipped`]]:[],...w?[["Expires",N(w.expiresAt)]]:[]]),x.failed.length&&(process.exitCode=1);break}if(t.prefix!==void 0||t["include-hidden"])throw new Error("--prefix and --include-hidden need --folder NAME or --into FOLDER");if(r.length>1){if(t.title!==void 0||t.description!==void 0||t["content-type"]!==void 0||t.filename!==void 0||r.includes("-"))throw new Error("--title, --description, --content-type, --filename and stdin apply to a single upload. To keep these files together, add --folder NAME");let I=[],w=[];for(let[v,x]of r.entries()){let O=J.parse(`${o}-${v+1}`);try{n?.reading(x);let D=await Ae(x);I.push({...await l.upload({...D,metadata:{description:"",expiresAt:k},requestId:O,onProgress:n?.transferred}),requestId:O})}catch(D){w.push({path:x,code:D instanceof R?D.code:"invalid_command",message:D instanceof Error?D.message:"Upload failed"})}}c={artifacts:I,failed:w,requestId:o},m=g(`${w.length?"\u2715":"\u2713"} Uploaded ${I.length} of ${r.length} files`)+I.map(v=>`
|
|
106
107
|
${b(v.title)}
|
|
107
108
|
${b(v.url)}
|
|
108
109
|
`).join("")+w.map(v=>`
|
|
@@ -110,4 +111,4 @@ Output: human-readable by default. Use --json for structured results and errors.
|
|
|
110
111
|
${b(v.message)}
|
|
111
112
|
`).join("")+(w.length?`
|
|
112
113
|
Retry with --request-id ${o}; files already uploaded are not duplicated.
|
|
113
|
-
`:""),w.length&&(process.exitCode=1);break}let z=t.title;n?.reading(u==="-"?"stdin":u);let q;if(u==="-"){let I=T(t.filename,"--filename for stdin"),w=T(t["content-type"],"--content-type for stdin");q={bytes:await
|
|
114
|
+
`:""),w.length&&(process.exitCode=1);break}let z=t.title;n?.reading(u==="-"?"stdin":u);let q;if(u==="-"){let I=T(t.filename,"--filename for stdin"),w=T(t["content-type"],"--content-type for stdin");q={bytes:await Ve(),filename:I,contentType:w}}else q=await Ae(u);let re=await l.upload({...q,contentType:t["content-type"]??q.contentType,metadata:{title:z,description:t.description??"",expiresAt:k},requestId:o,onProgress:n?.transferred});c={...re,requestId:o},m=j(re,"\u2713 Uploaded");break}}n?.stop(),K(c,m,a)}catch(t){n?.stop();let d=t instanceof R?t.code:"invalid_command",h=t instanceof B.ZodError?`Invalid options: ${t.issues.map(f=>f.message).join("; ")}. Run ${p}`:t instanceof Error?t.message:"Command failed",y=d==="unauthorized"?`Reconnect with seshat login --profile ${i}, or check SESHAT_TOKEN if you use it.`:d==="insufficient_scope"?`Reconnect with the required --scopes using seshat login --profile ${i}.`:d==="connection_failed"?"Check your connection and service endpoint. Retry uploads with the same --request-id.":void 0;ke({code:d,message:h,requestId:o,hint:y},a),process.exitCode=1}}process.argv[1]&&import.meta.url===Je(Ge(process.argv[1])).href&&await Ze(process.argv.slice(2));export{Ze as runCli};
|
package/dist/mcp.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{B as v,C as O,c as n,d as g,e as p,f as H,g as y,h as f,x as T,z as S}from"./chunk-
|
|
2
|
+
import{B as v,C as O,c as n,d as g,e as p,f as H,g as y,h as f,x as T,z as S}from"./chunk-73X6ZBVW.js";import{pathToFileURL as b}from"node:url";import{realpathSync as A}from"node:fs";import{McpServer as R}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as I}from"@modelcontextprotocol/sdk/server/stdio.js";import{z as a}from"zod";var q=`Seshat publishes artifacts to public, unlisted links. Upload only content the user wants shared.
|
|
3
3
|
Run seshat login once to use a stored profile. SESHAT_PROFILE selects a named agent profile. For CI, set SESHAT_ENDPOINT and a tenant-scoped SESHAT_TOKEN, never in tool arguments.
|
|
4
4
|
Supported readers: interactive HTML, Markdown, images, PDF, JSON, and plain text. Other formats download.
|
|
5
5
|
Artifacts do not expire by default. Set expiresAt to an ISO date to expire one, or null for no expiration. Omit title or description to generate metadata automatically on Cloudflare; explicit values are preserved. Set metadata.password to a password of 12\u2013128 characters to protect an upload. Update password to null to remove protection; changing it invalidates previous unlocks.
|