@desplega.ai/agent-fs 0.3.0 → 0.3.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/dist/cli.js +1 -1
- package/package.json +2 -2
- package/dist/__tests__/api-client.test.d.ts +0 -2
- package/dist/__tests__/api-client.test.d.ts.map +0 -1
- package/dist/__tests__/api-client.test.js +0 -86
- package/dist/__tests__/api-client.test.js.map +0 -1
- package/dist/__tests__/param-mapping.test.d.ts +0 -2
- package/dist/__tests__/param-mapping.test.d.ts.map +0 -1
- package/dist/__tests__/param-mapping.test.js +0 -53
- package/dist/__tests__/param-mapping.test.js.map +0 -1
- package/dist/api-client.d.ts +0 -17
- package/dist/api-client.d.ts.map +0 -1
- package/dist/api-client.js +0 -63
- package/dist/api-client.js.map +0 -1
- package/dist/commands/auth.d.ts +0 -4
- package/dist/commands/auth.d.ts.map +0 -1
- package/dist/commands/auth.js +0 -81
- package/dist/commands/auth.js.map +0 -1
- package/dist/commands/comment.d.ts +0 -4
- package/dist/commands/comment.d.ts.map +0 -1
- package/dist/commands/comment.js +0 -165
- package/dist/commands/comment.js.map +0 -1
- package/dist/commands/config-cmd.d.ts +0 -3
- package/dist/commands/config-cmd.d.ts.map +0 -1
- package/dist/commands/config-cmd.js +0 -147
- package/dist/commands/config-cmd.js.map +0 -1
- package/dist/commands/daemon.d.ts +0 -3
- package/dist/commands/daemon.d.ts.map +0 -1
- package/dist/commands/daemon.js +0 -33
- package/dist/commands/daemon.js.map +0 -1
- package/dist/commands/docs.d.ts +0 -3
- package/dist/commands/docs.d.ts.map +0 -1
- package/dist/commands/docs.js +0 -13
- package/dist/commands/docs.js.map +0 -1
- package/dist/commands/drive.d.ts +0 -4
- package/dist/commands/drive.d.ts.map +0 -1
- package/dist/commands/drive.js +0 -171
- package/dist/commands/drive.js.map +0 -1
- package/dist/commands/init.d.ts +0 -3
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js +0 -20
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/onboard.d.ts +0 -3
- package/dist/commands/onboard.d.ts.map +0 -1
- package/dist/commands/onboard.js +0 -229
- package/dist/commands/onboard.js.map +0 -1
- package/dist/commands/ops.d.ts +0 -4
- package/dist/commands/ops.d.ts.map +0 -1
- package/dist/commands/ops.js +0 -100
- package/dist/commands/ops.js.map +0 -1
- package/dist/commands/org.d.ts +0 -4
- package/dist/commands/org.d.ts.map +0 -1
- package/dist/commands/org.js +0 -84
- package/dist/commands/org.js.map +0 -1
- package/dist/formatters.d.ts +0 -11
- package/dist/formatters.d.ts.map +0 -1
- package/dist/formatters.js +0 -257
- package/dist/formatters.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -83
- package/dist/index.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -150,7 +150,7 @@ CREATE VIRTUAL TABLE IF NOT EXISTS chunk_vectors USING vec0(
|
|
|
150
150
|
FROM chunk_vectors
|
|
151
151
|
WHERE embedding MATCH ?
|
|
152
152
|
ORDER BY distance
|
|
153
|
-
LIMIT ?`).all(E,i*2);if(L.length===0)return{results:[]};let y=[],R=new Set;for(let I of L){let _=t.db.select().from(u.contentChunks).where(Fn(u.contentChunks.id,I.chunk_id)).get();if(!_)continue;if(_.driveId!==t.driveId)continue;if(R.has(_.filePath))continue;R.add(_.filePath);let Z=t.db.select().from(u.files).where(Fu(Fn(u.files.path,_.filePath),Fn(u.files.driveId,t.driveId))).get();if(y.push({path:_.filePath,score:1/(1+I.distance),snippet:_.content.slice(0,200),author:Z?.author,modifiedAt:Z?.modifiedAt}),y.length>=i)break}return{results:y}}var vi=D(()=>{P()});import{eq as pt,and as Pu,or as Wu,isNull as Hu}from"drizzle-orm";async function gi(t,n){let o=[pt(u.files.driveId,t.driveId),pt(u.files.isDeleted,!1),Wu(pt(u.files.embeddingStatus,"failed"),Hu(u.files.embeddingStatus),pt(u.files.embeddingStatus,"pending"))];if(n.path){let{like:L}=await import("drizzle-orm"),y=n.path.endsWith("/")?n.path:n.path+"/";o.push(L(u.files.path,y+"%"))}let i=t.db.select({path:u.files.path}).from(u.files).where(Pu(...o)).all(),T=0,E=0,N=0;for(let L of i){let y=$(t.orgId,t.driveId,L.path);try{let R=await t.s3.getObject(y),I=new TextDecoder().decode(R.body);if(ut(t.db,{path:L.path,driveId:t.driveId,content:I}),t.embeddingProvider)await Yn(t.db,t.embeddingProvider,{path:L.path,driveId:t.driveId,content:I});else{N++;continue}T++}catch(R){console.error(`Reindex failed for ${L.path}:`,R),E++}}return{reindexed:T,failed:E,skipped:N}}var Ki=D(()=>{P();C();Ct()});import{eq as ei,and as Cu,like as vu}from"drizzle-orm";async function Vi(t,n){let o=Et(n.path??"/"),i=$(t.orgId,t.driveId,o),{objects:T}=await t.s3.listObjects(i),E=t.db.select().from(u.files).where(Cu(ei(u.files.driveId,t.driveId),vu(u.files.path,o+"%"),ei(u.files.isDeleted,!1))).all(),N=new Map(E.map((y)=>[y.path,y])),L=[];for(let y of T){let R=y.key.slice(i.length);if(!R)continue;let I=R.split("/").filter(Boolean);if(I.length===0)continue;if(n.depth!==void 0&&I.length>n.depth)continue;let _=L;for(let Z=0;Z<I.length;Z++){let H=I[Z],q=Z===I.length-1,kt=!q||R.endsWith("/");if(kt&&!q){let v=_.find((f)=>f.name===H&&f.type==="directory");if(!v)v={name:H,type:"directory",children:[]},_.push(v);if(!v.children)v.children=[];_=v.children}else if(kt&&q){let v=_.find((f)=>f.name===H&&f.type==="directory");if(!v)v={name:H,type:"directory",children:[]},_.push(v)}else{let v=o+I.slice(0,Z+1).join("/"),f=N.get(v),Un={name:H,type:"file",size:f?.size??y.size};if(f?.author)Un.author=f.author;if(f?.modifiedAt??y.lastModified)Un.modifiedAt=f?.modifiedAt??y.lastModified;_.push(Un)}}}return{tree:L}}var li=D(()=>{P();C()});import{eq as qi,and as gu,like as Ku}from"drizzle-orm";function eu(t){let n="",o=0;while(o<t.length){let i=t[o];if(i==="*")if(t[o+1]==="*"){if(n+=".*",o+=2,t[o]==="/")o++}else n+="[^/]*",o++;else if(i==="?")n+="[^/]",o++;else if(".+^${}()|[]\\".includes(i))n+="\\"+i,o++;else n+=i,o++}return new RegExp("^"+n+"$")}async function di(t,n){let o=n.path?Et(n.path):"/",i=$(t.orgId,t.driveId,o),{objects:T}=await t.s3.listObjects(i),E=t.db.select().from(u.files).where(gu(qi(u.files.driveId,t.driveId),Ku(u.files.path,o+"%"),qi(u.files.isDeleted,!1))).all(),N=new Map(E.map((R)=>[R.path,R])),L=eu(n.pattern),y=[];for(let R of T){let I=R.key.slice(i.length);if(!I||I.endsWith("/"))continue;if(L.test(I)){let _=o+I,Z=N.get(_);y.push({path:_,size:Z?.size??R.size,modifiedAt:Z?.modifiedAt??R.lastModified})}}return{matches:y}}var ki=D(()=>{P();C()});import{eq as M,and as nt,sql as Pn,desc as fi}from"drizzle-orm";function Wn(t,n){t.db.insert(u.events).values({id:crypto.randomUUID(),orgId:t.orgId,type:n.type,resourceType:n.resourceType,resourceId:n.resourceId,actor:t.userId,target:n.target??null,status:"created",metadata:n.metadata?JSON.stringify(n.metadata):null,createdAt:new Date}).run()}function ht(t){return{id:t.id,parentId:t.parentId??void 0,path:t.path,lineStart:t.lineStart??void 0,lineEnd:t.lineEnd??void 0,quotedContent:t.quotedContent??void 0,body:t.body,author:t.author,resolved:t.resolved??!1,resolvedBy:t.resolvedBy??void 0,resolvedAt:t.resolvedAt??void 0,fileVersionId:t.fileVersionId??void 0,replyCount:t.replyCount??0,createdAt:t.createdAt,updatedAt:t.updatedAt}}async function rt(t,n){let o=new Date,i=crypto.randomUUID(),T=n.path;if(n.parentId){let N=t.db.select().from(u.comments).where(nt(M(u.comments.id,n.parentId),M(u.comments.isDeleted,!1))).get();if(!N)throw new G("Parent comment not found",{suggestion:"Check that the parent comment ID is correct and not deleted"});if(N.parentId)throw new z("Cannot reply to a reply \u2014 only root comments accept replies",{suggestion:"Reply to the root comment instead"});if(!T)T=N.path}if(!T)throw new z("path is required for root comments",{field:"path"});let E=t.db.select({id:u.fileVersions.id}).from(u.fileVersions).where(nt(M(u.fileVersions.path,T),M(u.fileVersions.driveId,t.driveId))).orderBy(fi(u.fileVersions.id)).limit(1).get();return t.db.insert(u.comments).values({id:i,parentId:n.parentId??null,orgId:t.orgId,driveId:t.driveId,path:T,lineStart:n.lineStart??null,lineEnd:n.lineEnd??null,quotedContent:n.quotedContent??null,fileVersionId:E?.id??null,body:n.body,author:t.userId,resolved:!1,createdAt:o,updatedAt:o,isDeleted:!1}).run(),Wn(t,{type:"comment_created",resourceType:"comment",resourceId:i,metadata:{path:T,parentId:n.parentId}}),{id:i,path:T,body:n.body,parentId:n.parentId,lineStart:n.lineStart,lineEnd:n.lineEnd,author:t.userId,createdAt:o}}async function mt(t,n){let o=[M(u.comments.driveId,t.driveId),M(u.comments.isDeleted,!1)];if(n.path)o.push(M(u.comments.path,n.path));if(n.parentId)o.push(M(u.comments.parentId,n.parentId));else if(n.parentId===void 0&&!n.resolved)o.push(Pn`${u.comments.parentId} IS NULL`),o.push(M(u.comments.resolved,!1));else if(n.parentId===void 0&&n.resolved)o.push(Pn`${u.comments.parentId} IS NULL`);if(n.orgId)o.push(M(u.comments.orgId,n.orgId));let i=n.limit??50,T=n.offset??0;return{comments:t.db.select().from(u.comments).where(nt(...o)).orderBy(fi(u.comments.createdAt)).limit(i).offset(T).all().map((L)=>{let R=t.db.select().from(u.comments).where(nt(M(u.comments.parentId,L.id),M(u.comments.isDeleted,!1))).orderBy(u.comments.createdAt).all().map((I)=>ht({...I,replyCount:0}));return{...ht({...L,replyCount:R.length}),replies:R}})}}async function xt(t,n){let o=t.db.select().from(u.comments).where(nt(M(u.comments.id,n.id),M(u.comments.isDeleted,!1))).get();if(!o)throw new G("Comment not found",{suggestion:"Check that the comment ID is correct"});let i=t.db.select({count:Pn`count(*)`}).from(u.comments).where(nt(M(u.comments.parentId,o.id),M(u.comments.isDeleted,!1))).get(),T=ht({...o,replyCount:i?.count??0}),N=t.db.select().from(u.comments).where(nt(M(u.comments.parentId,n.id),M(u.comments.isDeleted,!1))).orderBy(u.comments.createdAt).all().map((L)=>ht({...L,replyCount:0}));return{comment:T,replies:N}}async function ct(t,n){let o=t.db.select().from(u.comments).where(nt(M(u.comments.id,n.id),M(u.comments.isDeleted,!1))).get();if(!o)throw new G("Comment not found",{suggestion:"Check that the comment ID is correct"});if(o.author!==t.userId)throw new j("You can only edit your own comments",{suggestion:"Only the comment author can update it"});let i=new Date;return t.db.update(u.comments).set({body:n.body,updatedAt:i}).where(M(u.comments.id,n.id)).run(),{id:n.id,body:n.body,updatedAt:i}}async function at(t,n){let o=t.db.select().from(u.comments).where(nt(M(u.comments.id,n.id),M(u.comments.isDeleted,!1))).get();if(!o)throw new G("Comment not found",{suggestion:"Check that the comment ID is correct"});if(o.author!==t.userId)throw new j("You can only delete your own comments",{suggestion:"Only the comment author can delete it"});let i=new Date;if(t.db.update(u.comments).set({isDeleted:!0,updatedAt:i}).where(M(u.comments.id,n.id)).run(),!o.parentId)t.db.update(u.comments).set({isDeleted:!0,updatedAt:i}).where(M(u.comments.parentId,n.id)).run();return Wn(t,{type:"comment_deleted",resourceType:"comment",resourceId:n.id}),{deleted:!0}}async function st(t,n){let o=t.db.select().from(u.comments).where(nt(M(u.comments.id,n.id),M(u.comments.isDeleted,!1))).get();if(!o)throw new G("Comment not found",{suggestion:"Check that the comment ID is correct"});if(o.parentId)throw new z("Cannot resolve a reply \u2014 only root comments can be resolved",{suggestion:"Resolve the parent comment instead"});let i=new Date,T=n.resolved?i:null,E=n.resolved?t.userId:null;return t.db.update(u.comments).set({resolved:n.resolved,resolvedBy:E,resolvedAt:T,updatedAt:i}).where(M(u.comments.id,n.id)).run(),Wn(t,{type:n.resolved?"comment_resolved":"comment_reopened",resourceType:"comment",resourceId:n.id}),{id:n.id,resolved:n.resolved,resolvedBy:E??void 0,resolvedAt:T??void 0}}var ji=D(()=>{P();d()});import{z as O}from"zod";async function yt(t,n,o,i){let T=Hn[n];if(!T)throw Error(`Unknown operation: ${n}`);if(!i?.skipAuth){let N=Wt(n);Ht(t.db,{userId:t.userId,driveId:t.driveId,requiredRole:N})}let E=T.schema.parse(o);return T.handler(t,E)}function $t(){return Object.keys(Hn)}function Lt(t){return Hn[t]}var Hn;var Cn=D(()=>{zt();xo();ao();ti();oi();Ei();yi();Ri();Di();_i();Ui();Zi();Bi();Yi();Qi();Pi();Hi();vi();Ki();li();ki();ji();Hn={write:{description:"Write or overwrite a file. Creates the file if it doesn't exist, or creates a new version. Use expectedVersion for optimistic concurrency. Returns { version, path, size }.",handler:mo,schema:O.object({path:O.string(),content:O.string(),message:O.string().optional(),expectedVersion:O.number().int().optional()})},cat:{description:"Read file content with optional pagination via offset/limit. Returns { content, totalLines, truncated }.",handler:co,schema:O.object({path:O.string(),offset:O.number().int().min(0).optional(),limit:O.number().int().min(1).optional()})},edit:{description:"Replace a specific string in a file (surgical find-and-replace). Captures the edit intent as a diff summary in version history. Returns { version, path, changes }.",handler:so,schema:O.object({path:O.string(),old_string:O.string(),new_string:O.string(),message:O.string().optional()})},append:{description:"Append content to the end of an existing file. Creates a new version. Returns { version, size }.",handler:ni,schema:O.object({path:O.string(),content:O.string(),message:O.string().optional()})},ls:{description:"List immediate children of a directory. Returns { entries } where each entry has name, type (file/directory), size, author, modifiedAt.",handler:Ti,schema:O.object({path:O.string().optional()})},stat:{description:"Get file metadata without reading content. Returns path, size, contentType, author, currentVersion, createdAt, modifiedAt, isDeleted, embeddingStatus.",handler:Ni,schema:O.object({path:O.string()})},rm:{description:"Delete a file. Removes from S3, cleans up FTS5 index and vector embeddings. Returns { path, deleted }.",handler:Li,schema:O.object({path:O.string()})},mv:{description:"Move or rename a file. Preserves version history at the new path. Returns { from, to, version }.",handler:Ii,schema:O.object({from:O.string(),to:O.string(),message:O.string().optional()})},cp:{description:"Copy a file using server-side S3 copy. Creates a new version at the destination. Returns { from, to, version }.",handler:Oi,schema:O.object({from:O.string(),to:O.string()})},tail:{description:"Read the last N lines of a file (default 20). Returns { content, totalLines, truncated }.",handler:Ai,schema:O.object({path:O.string(),lines:O.number().int().min(1).optional()})},log:{description:"Show version history for a file. Returns { versions } with version number, author, timestamp, operation type, message, and diff summary.",handler:Xi,schema:O.object({path:O.string(),limit:O.number().int().min(1).optional()})},diff:{description:"Show the diff between two versions of a file. Specify v1 and v2 version numbers. Returns { changes } as add/remove/context hunks.",handler:$i,schema:O.object({path:O.string(),v1:O.number().int(),v2:O.number().int()})},revert:{description:"Revert a file to a previous version. Creates a new version with the old content. Returns { version, revertedTo }.",handler:Mi,schema:O.object({path:O.string(),version:O.number().int()})},recent:{description:"Show recent activity across the drive. Optionally filter by path prefix and time window (since). Returns { entries } with path and version details.",handler:Gi,schema:O.object({path:O.string().optional(),since:O.coerce.date().optional(),limit:O.number().int().min(1).optional()})},grep:{description:"Search file content using regex pattern within a specific path. Returns matching lines with line numbers. Searches the FTS5 index, not S3 directly.",handler:Fi,schema:O.object({pattern:O.string(),path:O.string()})},fts:{description:"Full-text search across all file content using FTS5 tokens. Different from grep (regex) and search (semantic). Returns { matches } with path, snippet, and rank.",handler:Wi,schema:O.object({pattern:O.string(),path:O.string().optional()})},search:{description:"Semantic/vector search using natural language queries. Requires an embedding provider (OPENAI_API_KEY or GEMINI_API_KEY). Returns { results } ranked by relevance.",handler:Ci,schema:O.object({query:O.string(),limit:O.number().int().min(1).optional()})},reindex:{description:"Re-index files with failed or missing FTS5/embedding entries. Optionally scope to a path prefix. Use after bulk writes or provider changes.",handler:gi,schema:O.object({path:O.string().optional()})},tree:{description:"Recursively list all files and directories. Use depth to limit recursion. Returns a nested tree structure with name, type, size, and children.",handler:Vi,schema:O.object({path:O.string().optional(),depth:O.number().int().min(1).optional()})},glob:{description:"Find files by name pattern. Use `*.md` for root-level files only, `**/*.md` for recursive matching across all subdirectories. Supports `*` (any chars except /), `?` (single char), `**` (any path depth). Optionally scope to a path prefix. Returns { matches } with path, size, and modifiedAt.",handler:di,schema:O.object({pattern:O.string(),path:O.string().optional()})},"comment-add":{description:"Add a comment to a file. Supports line ranges and threading via parentId. Replies auto-resolve path from parent. Returns { id, path, body, author, createdAt }.",handler:rt,schema:O.object({path:O.string().optional(),body:O.string(),parentId:O.string().optional(),lineStart:O.number().int().optional(),lineEnd:O.number().int().optional(),quotedContent:O.string().optional()})},"comment-list":{description:"List comments on a file. Filter by path, resolved state, or parentId. Defaults to unresolved root comments. Returns { comments } with inline replies.",handler:mt,schema:O.object({path:O.string().optional(),parentId:O.string().optional(),resolved:O.boolean().optional(),orgId:O.string().optional(),limit:O.number().int().min(1).optional(),offset:O.number().int().min(0).optional()})},"comment-get":{description:"Get a single comment by ID with all its replies. Returns { comment, replies }.",handler:xt,schema:O.object({id:O.string()})},"comment-update":{description:"Update a comment's body. Only the original author can update. Returns { id, body, updatedAt }.",handler:ct,schema:O.object({id:O.string(),body:O.string()})},"comment-delete":{description:"Soft-delete a comment. Only the original author can delete. Deleting a root comment also soft-deletes its replies. Returns { deleted }.",handler:at,schema:O.object({id:O.string()})},"comment-resolve":{description:"Resolve or reopen a root comment. Set resolved=true to resolve, resolved=false to reopen. Only root comments can be resolved. Returns { id, resolved, resolvedBy, resolvedAt }.",handler:st,schema:O.object({id:O.string(),resolved:O.boolean()})}}});import{eq as zi}from"drizzle-orm";function Dt(t,n){let o=crypto.randomUUID(),i=new Date;return t.insert(u.drives).values({id:o,orgId:n.orgId,name:n.name,isDefault:n.isDefault??!1,createdAt:i}).run(),{id:o,name:n.name}}function Ot(t,n){return t.select().from(u.drives).where(zi(u.drives.orgId,n)).all().map((o)=>({id:o.id,name:o.name,isDefault:o.isDefault}))}function vn(t,n){let o=t.select().from(u.drives).where(zi(u.drives.id,n)).get();if(!o)return null;return{id:o.id,name:o.name,orgId:o.orgId,isDefault:o.isDefault}}function gn(t,n){t.insert(u.driveMembers).values({driveId:n.driveId,userId:n.userId,role:n.role}).onConflictDoUpdate({target:[u.driveMembers.driveId,u.driveMembers.userId],set:{role:n.role}}).run()}var Kn=D(()=>{P()});import{eq as vt}from"drizzle-orm";function _t(t,n){let o=crypto.randomUUID(),i=new Date;t.insert(u.orgs).values({id:o,name:n.name,isPersonal:n.isPersonal??!1,createdAt:i}).run(),t.insert(u.orgMembers).values({orgId:o,userId:n.userId,role:"admin"}).run();let T=Dt(t,{orgId:o,name:"default",isDefault:!0});return t.insert(u.driveMembers).values({driveId:T.id,userId:n.userId,role:"admin"}).run(),{id:o,name:n.name}}function V(t,n){return t.select({orgId:u.orgMembers.orgId,role:u.orgMembers.role,name:u.orgs.name,isPersonal:u.orgs.isPersonal}).from(u.orgMembers).innerJoin(u.orgs,vt(u.orgMembers.orgId,u.orgs.id)).where(vt(u.orgMembers.userId,n)).all().map((i)=>({id:i.orgId,name:i.name,role:i.role,isPersonal:i.isPersonal}))}function gt(t,n){let o=t.select().from(u.orgs).where(vt(u.orgs.id,n)).get();if(!o)return null;return{id:o.id,name:o.name,isPersonal:o.isPersonal}}function Kt(t,n){let o=t.select().from(u.users).where(vt(u.users.email,n.email)).get();if(!o)throw Error(`User with email ${n.email} not found`);t.insert(u.orgMembers).values({orgId:n.orgId,userId:o.id,role:n.role}).onConflictDoUpdate({target:[u.orgMembers.orgId,u.orgMembers.userId],set:{role:n.role}}).run();let i=t.select().from(u.drives).where(vt(u.drives.orgId,n.orgId)).get();if(i)t.insert(u.driveMembers).values({driveId:i.id,userId:o.id,role:n.role}).onConflictDoUpdate({target:[u.driveMembers.driveId,u.driveMembers.userId],set:{role:n.role}}).run()}var en=D(()=>{P();Kn()});import{eq as bi}from"drizzle-orm";function pi(t){let n=new Bun.CryptoHasher("sha256");return n.update(t),n.digest("hex")}function Vu(){let t=new Uint8Array(32);return crypto.getRandomValues(t),`af_${Array.from(t,(o)=>o.toString(16).padStart(2,"0")).join("")}`}function lu(){return crypto.randomUUID()}function b(t,n){let o=lu(),i=Vu(),T=pi(i),E=new Date;return t.insert(u.users).values({id:o,email:n.email,apiKeyHash:T,createdAt:E}).run(),_t(t,{name:n.email.split("@")[0],userId:o,isPersonal:!0}),{user:{id:o,email:n.email},apiKey:i}}function ot(t,n){let o=pi(n),i=t.select().from(u.users).where(bi(u.users.apiKeyHash,o)).get();if(!i)return null;return{id:i.id,email:i.email}}function Vn(t,n){let o=t.select().from(u.users).where(bi(u.users.email,n)).get();if(!o)return null;return{id:o.id,email:o.email}}var ln=D(()=>{P();en()});import{eq as Rt,and as qn}from"drizzle-orm";function p(t,n){if(n.driveId){let E=t.select().from(u.drives).where(Rt(u.drives.id,n.driveId)).get();if(!E)throw Error(`Drive not found: ${n.driveId}`);let N=tt(t,n.userId,n.driveId);if(!N)throw Error("You do not have access to this drive");return{orgId:E.orgId,driveId:n.driveId,role:N}}if(n.orgId){let E=t.select().from(u.drives).where(qn(Rt(u.drives.orgId,n.orgId),Rt(u.drives.isDefault,!0))).get();if(!E)throw Error(`No default drive for org: ${n.orgId}`);let N=tt(t,n.userId,E.id);if(!N)throw Error("You do not have access to this drive");return{orgId:n.orgId,driveId:E.id,role:N}}let o=t.select({orgId:u.orgMembers.orgId}).from(u.orgMembers).innerJoin(u.orgs,Rt(u.orgMembers.orgId,u.orgs.id)).where(qn(Rt(u.orgMembers.userId,n.userId),Rt(u.orgs.isPersonal,!0))).get();if(!o)throw Error("No personal org found for user");let i=t.select().from(u.drives).where(qn(Rt(u.drives.orgId,o.orgId),Rt(u.drives.isDefault,!0))).get();if(!i)throw Error("No default drive found");let T=tt(t,n.userId,i.id);if(!T)throw Error("You do not have access to your default drive");return{orgId:o.orgId,driveId:i.id,role:T}}var hi=D(()=>{P();zt()});function et(t){let n=B();if(n.auth.apiKey){if(ot(t,n.auth.apiKey))return{apiKey:n.auth.apiKey}}console.error("[agent-fs] No local user found, creating one...");let o=b(t,{email:"local@agent-fs.local"});return S("auth.apiKey",o.apiKey),console.error("[agent-fs] Local user created automatically."),{apiKey:o.apiKey}}var ri=D(()=>{Gt();ln()});var mi=D(()=>{ln();en();Kn();zt();hi();ri()});var ci;var xi=D(()=>{ci={name:"agent-fs",version:"0.3.0",private:!0,workspaces:["packages/*"],scripts:{typecheck:"tsc --build",test:"bun test packages/*/src/","test:coverage":"bun test --coverage packages/*/src/",build:"cd packages/cli && bun run build:npm"},devDependencies:{"bun-types":"^1.2.0",typescript:"^5.7.0",yaml:"^2.8.2","zod-to-json-schema":"^3.25.1"}}});var l;var dn=D(()=>{xi();l=ci.version});var si={};Ut(si,{LocalEmbeddingProvider:()=>ai});import{join as du}from"path";import{mkdirSync as ku,existsSync as fu}from"fs";class ai{name="local";dimensions=768;llama=null;model=null;embeddingContext=null;initPromise=null;async init(){if(this.embeddingContext)return;if(this.initPromise)return this.initPromise;return this.initPromise=this._doInit(),this.initPromise}async _doInit(){let{getLlama:t,resolveModelFile:n}=await import("node-llama-cpp");this.llama=await t();let o=du(m(),"models");if(!fu(o))ku(o,{recursive:!0});console.error("[agent-fs] Resolving local embedding model...");let i=await n(ju,o);console.error("[agent-fs] Model ready:",i),this.model=await this.llama.loadModel({modelPath:i}),this.embeddingContext=await this.model.createEmbeddingContext()}async embed(t){await this.init();let n=await this.embeddingContext.getEmbeddingFor(t);return Array.from(n.vector)}async embedBatch(t){await this.init();let n=[];for(let o of t){let i=await this.embeddingContext.getEmbeddingFor(o);n.push(Array.from(i.vector))}return n}async dispose(){if(this.embeddingContext)await this.embeddingContext.dispose(),this.embeddingContext=null;if(this.model)await this.model.dispose(),this.model=null;this.initPromise=null}}var ju="hf:nomic-ai/nomic-embed-text-v1.5-GGUF:Q8_0";var tT=D(()=>{Gt()});var kn={};Ut(kn,{OpenAIEmbeddingProvider:()=>nT});import zu from"openai";class nT{name="openai";dimensions=768;client;constructor(t){this.client=new zu({apiKey:t})}async embed(t){return(await this.client.embeddings.create({model:"text-embedding-3-small",input:t,dimensions:768})).data[0].embedding}async embedBatch(t){return(await this.client.embeddings.create({model:"text-embedding-3-small",input:t,dimensions:768})).data.sort((o,i)=>o.index-i.index).map((o)=>o.embedding)}}var fn=()=>{};var jn={};Ut(jn,{GeminiEmbeddingProvider:()=>oT});import{GoogleGenAI as bu}from"@google/genai";class oT{name="gemini";dimensions=768;client;constructor(t){this.client=new bu({apiKey:t})}async embed(t){return(await this.client.models.embedContent({model:"gemini-embedding-001",contents:t,config:{outputDimensionality:768}})).embeddings[0].values}async embedBatch(t){let n=[];for(let o of t){let i=await this.client.models.embedContent({model:"gemini-embedding-001",contents:o,config:{outputDimensionality:768}});n.push(i.embeddings[0].values)}return n}}var zn=()=>{};async function iT(t){switch(t.provider){case"local":{let{LocalEmbeddingProvider:n}=await Promise.resolve().then(() => (tT(),si));return new n}case"openai":{if(!t.apiKey)throw Error("OpenAI API key required. Set embedding.apiKey in config.");let{OpenAIEmbeddingProvider:n}=await Promise.resolve().then(() => (fn(),kn));return new n(t.apiKey)}case"gemini":{if(!t.apiKey)throw Error("Gemini API key required. Set embedding.apiKey in config.");let{GeminiEmbeddingProvider:n}=await Promise.resolve().then(() => (zn(),jn));return new n(t.apiKey)}default:throw Error(`Unknown embedding provider: ${t.provider}`)}}async function Bt(t){if(process.env.OPENAI_API_KEY)try{let{OpenAIEmbeddingProvider:n}=await Promise.resolve().then(() => (fn(),kn));return new n(process.env.OPENAI_API_KEY)}catch(n){console.error("[agent-fs] Failed to load OpenAI provider:",n)}if(process.env.GEMINI_API_KEY)try{let{GeminiEmbeddingProvider:n}=await Promise.resolve().then(() => (zn(),jn));return new n(process.env.GEMINI_API_KEY)}catch(n){console.error("[agent-fs] Failed to load Gemini provider:",n)}if(t?.provider&&t.provider!=="local"&&t.apiKey)try{return await iT(t)}catch(n){console.error("[agent-fs] Failed to create embedding provider from config:",n)}if(t?.provider==="local")try{return await iT(t)}catch(n){console.error("[agent-fs] Failed to load local embedding provider:",n)}return null}var ET,TT,uT=(t)=>typeof t==="string"?{...TT,name:t}:{...TT,...t};var tn=D(()=>{ET=Symbol("Let zodToJsonSchema decide on which parser to use"),TT={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"}});var NT=(t)=>{let n=uT(t),o=n.name!==void 0?[...n.basePath,n.definitionPath,n.name]:n.basePath;return{...n,flags:{hasReferencedOpenAiAnyType:!1},currentPath:o,propertyPath:void 0,seen:new Map(Object.entries(n.definitions).map(([i,T])=>[T._def,{def:T._def,path:[...n.basePath,n.definitionPath,i],jsonSchema:void 0}]))}};var bn=D(()=>{tn()});function pn(t,n,o,i){if(!i?.errorMessages)return;if(o)t.errorMessage={...t.errorMessage,[n]:o}}function w(t,n,o,i,T){t[n]=o,pn(t,n,i,T)}var nn=(t,n)=>{let o=0;for(;o<t.length&&o<n.length;o++)if(t[o]!==n[o])break;return[(t.length-o).toString(),...n.slice(o)].join("/")};function Q(t){if(t.target!=="openAi")return{};let n=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?nn(n,t.currentPath):n.join("/")}}var k=()=>{};import{ZodFirstPartyTypeKind as pu}from"zod/v3";function yT(t,n){let o={type:"array"};if(t.type?._def&&t.type?._def?.typeName!==pu.ZodAny)o.items=U(t.type._def,{...n,currentPath:[...n.currentPath,"items"]});if(t.minLength)w(o,"minItems",t.minLength.value,t.minLength.message,n);if(t.maxLength)w(o,"maxItems",t.maxLength.value,t.maxLength.message,n);if(t.exactLength)w(o,"minItems",t.exactLength.value,t.exactLength.message,n),w(o,"maxItems",t.exactLength.value,t.exactLength.message,n);return o}var hn=D(()=>{W()});function LT(t,n){let o={type:"integer",format:"int64"};if(!t.checks)return o;for(let i of t.checks)switch(i.kind){case"min":if(n.target==="jsonSchema7")if(i.inclusive)w(o,"minimum",i.value,i.message,n);else w(o,"exclusiveMinimum",i.value,i.message,n);else{if(!i.inclusive)o.exclusiveMinimum=!0;w(o,"minimum",i.value,i.message,n)}break;case"max":if(n.target==="jsonSchema7")if(i.inclusive)w(o,"maximum",i.value,i.message,n);else w(o,"exclusiveMaximum",i.value,i.message,n);else{if(!i.inclusive)o.exclusiveMaximum=!0;w(o,"maximum",i.value,i.message,n)}break;case"multipleOf":w(o,"multipleOf",i.value,i.message,n);break}return o}var rn=()=>{};function RT(){return{type:"boolean"}}function on(t,n){return U(t.type._def,n)}var Tn=D(()=>{W()});var IT=(t,n)=>{return U(t.innerType._def,n)};var mn=D(()=>{W()});function xn(t,n,o){let i=o??n.dateStrategy;if(Array.isArray(i))return{anyOf:i.map((T,E)=>xn(t,n,T))};switch(i){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return hu(t,n)}}var hu=(t,n)=>{let o={type:"integer",format:"unix-time"};if(n.target==="openApi3")return o;for(let i of t.checks)switch(i.kind){case"min":w(o,"minimum",i.value,i.message,n);break;case"max":w(o,"maximum",i.value,i.message,n);break}return o};var cn=()=>{};function DT(t,n){return{...U(t.innerType._def,n),default:t.defaultValue()}}var an=D(()=>{W()});function OT(t,n){return n.effectStrategy==="input"?U(t.schema._def,n):Q(n)}var sn=D(()=>{W();k()});function _T(t){return{type:"string",enum:Array.from(t.values)}}function AT(t,n){let o=[U(t.left._def,{...n,currentPath:[...n.currentPath,"allOf","0"]}),U(t.right._def,{...n,currentPath:[...n.currentPath,"allOf","1"]})].filter((E)=>!!E),i=n.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,T=[];return o.forEach((E)=>{if(ru(E)){if(T.push(...E.allOf),E.unevaluatedProperties===void 0)i=void 0}else{let N=E;if("additionalProperties"in E&&E.additionalProperties===!1){let{additionalProperties:L,...y}=E;N=y}else i=void 0;T.push(N)}}),T.length?{allOf:T,...i}:void 0}var ru=(t)=>{if("type"in t&&t.type==="string")return!1;return"allOf"in t};var to=D(()=>{W()});function UT(t,n){let o=typeof t.value;if(o!=="bigint"&&o!=="number"&&o!=="boolean"&&o!=="string")return{type:Array.isArray(t.value)?"array":"object"};if(n.target==="openApi3")return{type:o==="bigint"?"integer":o,enum:[t.value]};return{type:o==="bigint"?"integer":o,const:t.value}}function En(t,n){let o={type:"string"};if(t.checks)for(let i of t.checks)switch(i.kind){case"min":w(o,"minLength",typeof o.minLength==="number"?Math.max(o.minLength,i.value):i.value,i.message,n);break;case"max":w(o,"maxLength",typeof o.maxLength==="number"?Math.min(o.maxLength,i.value):i.value,i.message,n);break;case"email":switch(n.emailStrategy){case"format:email":r(o,"email",i.message,n);break;case"format:idn-email":r(o,"idn-email",i.message,n);break;case"pattern:zod":e(o,h.email,i.message,n);break}break;case"url":r(o,"uri",i.message,n);break;case"uuid":r(o,"uuid",i.message,n);break;case"regex":e(o,i.regex,i.message,n);break;case"cuid":e(o,h.cuid,i.message,n);break;case"cuid2":e(o,h.cuid2,i.message,n);break;case"startsWith":e(o,RegExp(`^${oo(i.value,n)}`),i.message,n);break;case"endsWith":e(o,RegExp(`${oo(i.value,n)}$`),i.message,n);break;case"datetime":r(o,"date-time",i.message,n);break;case"date":r(o,"date",i.message,n);break;case"time":r(o,"time",i.message,n);break;case"duration":r(o,"duration",i.message,n);break;case"length":w(o,"minLength",typeof o.minLength==="number"?Math.max(o.minLength,i.value):i.value,i.message,n),w(o,"maxLength",typeof o.maxLength==="number"?Math.min(o.maxLength,i.value):i.value,i.message,n);break;case"includes":{e(o,RegExp(oo(i.value,n)),i.message,n);break}case"ip":{if(i.version!=="v6")r(o,"ipv4",i.message,n);if(i.version!=="v4")r(o,"ipv6",i.message,n);break}case"base64url":e(o,h.base64url,i.message,n);break;case"jwt":e(o,h.jwt,i.message,n);break;case"cidr":{if(i.version!=="v6")e(o,h.ipv4Cidr,i.message,n);if(i.version!=="v4")e(o,h.ipv6Cidr,i.message,n);break}case"emoji":e(o,h.emoji(),i.message,n);break;case"ulid":{e(o,h.ulid,i.message,n);break}case"base64":{switch(n.base64Strategy){case"format:binary":{r(o,"binary",i.message,n);break}case"contentEncoding:base64":{w(o,"contentEncoding","base64",i.message,n);break}case"pattern:zod":{e(o,h.base64,i.message,n);break}}break}case"nanoid":e(o,h.nanoid,i.message,n);case"toLowerCase":case"toUpperCase":case"trim":break;default:((T)=>{})(i)}return o}function oo(t,n){return n.patternStrategy==="escape"?xu(t):t}function xu(t){let n="";for(let o=0;o<t.length;o++){if(!mu.has(t[o]))n+="\\";n+=t[o]}return n}function r(t,n,o,i){if(t.format||t.anyOf?.some((T)=>T.format)){if(!t.anyOf)t.anyOf=[];if(t.format){if(t.anyOf.push({format:t.format,...t.errorMessage&&i.errorMessages&&{errorMessage:{format:t.errorMessage.format}}}),delete t.format,t.errorMessage){if(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0)delete t.errorMessage}}t.anyOf.push({format:n,...o&&i.errorMessages&&{errorMessage:{format:o}}})}else w(t,"format",n,o,i)}function e(t,n,o,i){if(t.pattern||t.allOf?.some((T)=>T.pattern)){if(!t.allOf)t.allOf=[];if(t.pattern){if(t.allOf.push({pattern:t.pattern,...t.errorMessage&&i.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}}}),delete t.pattern,t.errorMessage){if(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0)delete t.errorMessage}}t.allOf.push({pattern:ST(n,i),...o&&i.errorMessages&&{errorMessage:{pattern:o}}})}else w(t,"pattern",ST(n,i),o,i)}function ST(t,n){if(!n.applyRegexFlags||!t.flags)return t.source;let o={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},i=o.i?t.source.toLowerCase():t.source,T="",E=!1,N=!1,L=!1;for(let y=0;y<i.length;y++){if(E){T+=i[y],E=!1;continue}if(o.i){if(N){if(i[y].match(/[a-z]/)){if(L)T+=i[y],T+=`${i[y-2]}-${i[y]}`.toUpperCase(),L=!1;else if(i[y+1]==="-"&&i[y+2]?.match(/[a-z]/))T+=i[y],L=!0;else T+=`${i[y]}${i[y].toUpperCase()}`;continue}}else if(i[y].match(/[a-z]/)){T+=`[${i[y]}${i[y].toUpperCase()}]`;continue}}if(o.m){if(i[y]==="^"){T+=`(^|(?<=[\r
|
|
153
|
+
LIMIT ?`).all(E,i*2);if(L.length===0)return{results:[]};let y=[],R=new Set;for(let I of L){let _=t.db.select().from(u.contentChunks).where(Fn(u.contentChunks.id,I.chunk_id)).get();if(!_)continue;if(_.driveId!==t.driveId)continue;if(R.has(_.filePath))continue;R.add(_.filePath);let Z=t.db.select().from(u.files).where(Fu(Fn(u.files.path,_.filePath),Fn(u.files.driveId,t.driveId))).get();if(y.push({path:_.filePath,score:1/(1+I.distance),snippet:_.content.slice(0,200),author:Z?.author,modifiedAt:Z?.modifiedAt}),y.length>=i)break}return{results:y}}var vi=D(()=>{P()});import{eq as pt,and as Pu,or as Wu,isNull as Hu}from"drizzle-orm";async function gi(t,n){let o=[pt(u.files.driveId,t.driveId),pt(u.files.isDeleted,!1),Wu(pt(u.files.embeddingStatus,"failed"),Hu(u.files.embeddingStatus),pt(u.files.embeddingStatus,"pending"))];if(n.path){let{like:L}=await import("drizzle-orm"),y=n.path.endsWith("/")?n.path:n.path+"/";o.push(L(u.files.path,y+"%"))}let i=t.db.select({path:u.files.path}).from(u.files).where(Pu(...o)).all(),T=0,E=0,N=0;for(let L of i){let y=$(t.orgId,t.driveId,L.path);try{let R=await t.s3.getObject(y),I=new TextDecoder().decode(R.body);if(ut(t.db,{path:L.path,driveId:t.driveId,content:I}),t.embeddingProvider)await Yn(t.db,t.embeddingProvider,{path:L.path,driveId:t.driveId,content:I});else{N++;continue}T++}catch(R){console.error(`Reindex failed for ${L.path}:`,R),E++}}return{reindexed:T,failed:E,skipped:N}}var Ki=D(()=>{P();C();Ct()});import{eq as ei,and as Cu,like as vu}from"drizzle-orm";async function Vi(t,n){let o=Et(n.path??"/"),i=$(t.orgId,t.driveId,o),{objects:T}=await t.s3.listObjects(i),E=t.db.select().from(u.files).where(Cu(ei(u.files.driveId,t.driveId),vu(u.files.path,o+"%"),ei(u.files.isDeleted,!1))).all(),N=new Map(E.map((y)=>[y.path,y])),L=[];for(let y of T){let R=y.key.slice(i.length);if(!R)continue;let I=R.split("/").filter(Boolean);if(I.length===0)continue;if(n.depth!==void 0&&I.length>n.depth)continue;let _=L;for(let Z=0;Z<I.length;Z++){let H=I[Z],q=Z===I.length-1,kt=!q||R.endsWith("/");if(kt&&!q){let v=_.find((f)=>f.name===H&&f.type==="directory");if(!v)v={name:H,type:"directory",children:[]},_.push(v);if(!v.children)v.children=[];_=v.children}else if(kt&&q){let v=_.find((f)=>f.name===H&&f.type==="directory");if(!v)v={name:H,type:"directory",children:[]},_.push(v)}else{let v=o+I.slice(0,Z+1).join("/"),f=N.get(v),Un={name:H,type:"file",size:f?.size??y.size};if(f?.author)Un.author=f.author;if(f?.modifiedAt??y.lastModified)Un.modifiedAt=f?.modifiedAt??y.lastModified;_.push(Un)}}}return{tree:L}}var li=D(()=>{P();C()});import{eq as qi,and as gu,like as Ku}from"drizzle-orm";function eu(t){let n="",o=0;while(o<t.length){let i=t[o];if(i==="*")if(t[o+1]==="*"){if(n+=".*",o+=2,t[o]==="/")o++}else n+="[^/]*",o++;else if(i==="?")n+="[^/]",o++;else if(".+^${}()|[]\\".includes(i))n+="\\"+i,o++;else n+=i,o++}return new RegExp("^"+n+"$")}async function di(t,n){let o=n.path?Et(n.path):"/",i=$(t.orgId,t.driveId,o),{objects:T}=await t.s3.listObjects(i),E=t.db.select().from(u.files).where(gu(qi(u.files.driveId,t.driveId),Ku(u.files.path,o+"%"),qi(u.files.isDeleted,!1))).all(),N=new Map(E.map((R)=>[R.path,R])),L=eu(n.pattern),y=[];for(let R of T){let I=R.key.slice(i.length);if(!I||I.endsWith("/"))continue;if(L.test(I)){let _=o+I,Z=N.get(_);y.push({path:_,size:Z?.size??R.size,modifiedAt:Z?.modifiedAt??R.lastModified})}}return{matches:y}}var ki=D(()=>{P();C()});import{eq as M,and as nt,sql as Pn,desc as fi}from"drizzle-orm";function Wn(t,n){t.db.insert(u.events).values({id:crypto.randomUUID(),orgId:t.orgId,type:n.type,resourceType:n.resourceType,resourceId:n.resourceId,actor:t.userId,target:n.target??null,status:"created",metadata:n.metadata?JSON.stringify(n.metadata):null,createdAt:new Date}).run()}function ht(t){return{id:t.id,parentId:t.parentId??void 0,path:t.path,lineStart:t.lineStart??void 0,lineEnd:t.lineEnd??void 0,quotedContent:t.quotedContent??void 0,body:t.body,author:t.author,resolved:t.resolved??!1,resolvedBy:t.resolvedBy??void 0,resolvedAt:t.resolvedAt??void 0,fileVersionId:t.fileVersionId??void 0,replyCount:t.replyCount??0,createdAt:t.createdAt,updatedAt:t.updatedAt}}async function rt(t,n){let o=new Date,i=crypto.randomUUID(),T=n.path;if(n.parentId){let N=t.db.select().from(u.comments).where(nt(M(u.comments.id,n.parentId),M(u.comments.isDeleted,!1))).get();if(!N)throw new G("Parent comment not found",{suggestion:"Check that the parent comment ID is correct and not deleted"});if(N.parentId)throw new z("Cannot reply to a reply \u2014 only root comments accept replies",{suggestion:"Reply to the root comment instead"});if(!T)T=N.path}if(!T)throw new z("path is required for root comments",{field:"path"});let E=t.db.select({id:u.fileVersions.id}).from(u.fileVersions).where(nt(M(u.fileVersions.path,T),M(u.fileVersions.driveId,t.driveId))).orderBy(fi(u.fileVersions.id)).limit(1).get();return t.db.insert(u.comments).values({id:i,parentId:n.parentId??null,orgId:t.orgId,driveId:t.driveId,path:T,lineStart:n.lineStart??null,lineEnd:n.lineEnd??null,quotedContent:n.quotedContent??null,fileVersionId:E?.id??null,body:n.body,author:t.userId,resolved:!1,createdAt:o,updatedAt:o,isDeleted:!1}).run(),Wn(t,{type:"comment_created",resourceType:"comment",resourceId:i,metadata:{path:T,parentId:n.parentId}}),{id:i,path:T,body:n.body,parentId:n.parentId,lineStart:n.lineStart,lineEnd:n.lineEnd,author:t.userId,createdAt:o}}async function mt(t,n){let o=[M(u.comments.driveId,t.driveId),M(u.comments.isDeleted,!1)];if(n.path)o.push(M(u.comments.path,n.path));if(n.parentId)o.push(M(u.comments.parentId,n.parentId));else if(n.parentId===void 0&&!n.resolved)o.push(Pn`${u.comments.parentId} IS NULL`),o.push(M(u.comments.resolved,!1));else if(n.parentId===void 0&&n.resolved)o.push(Pn`${u.comments.parentId} IS NULL`);if(n.orgId)o.push(M(u.comments.orgId,n.orgId));let i=n.limit??50,T=n.offset??0;return{comments:t.db.select().from(u.comments).where(nt(...o)).orderBy(fi(u.comments.createdAt)).limit(i).offset(T).all().map((L)=>{let R=t.db.select().from(u.comments).where(nt(M(u.comments.parentId,L.id),M(u.comments.isDeleted,!1))).orderBy(u.comments.createdAt).all().map((I)=>ht({...I,replyCount:0}));return{...ht({...L,replyCount:R.length}),replies:R}})}}async function xt(t,n){let o=t.db.select().from(u.comments).where(nt(M(u.comments.id,n.id),M(u.comments.isDeleted,!1))).get();if(!o)throw new G("Comment not found",{suggestion:"Check that the comment ID is correct"});let i=t.db.select({count:Pn`count(*)`}).from(u.comments).where(nt(M(u.comments.parentId,o.id),M(u.comments.isDeleted,!1))).get(),T=ht({...o,replyCount:i?.count??0}),N=t.db.select().from(u.comments).where(nt(M(u.comments.parentId,n.id),M(u.comments.isDeleted,!1))).orderBy(u.comments.createdAt).all().map((L)=>ht({...L,replyCount:0}));return{comment:T,replies:N}}async function ct(t,n){let o=t.db.select().from(u.comments).where(nt(M(u.comments.id,n.id),M(u.comments.isDeleted,!1))).get();if(!o)throw new G("Comment not found",{suggestion:"Check that the comment ID is correct"});if(o.author!==t.userId)throw new j("You can only edit your own comments",{suggestion:"Only the comment author can update it"});let i=new Date;return t.db.update(u.comments).set({body:n.body,updatedAt:i}).where(M(u.comments.id,n.id)).run(),{id:n.id,body:n.body,updatedAt:i}}async function at(t,n){let o=t.db.select().from(u.comments).where(nt(M(u.comments.id,n.id),M(u.comments.isDeleted,!1))).get();if(!o)throw new G("Comment not found",{suggestion:"Check that the comment ID is correct"});if(o.author!==t.userId)throw new j("You can only delete your own comments",{suggestion:"Only the comment author can delete it"});let i=new Date;if(t.db.update(u.comments).set({isDeleted:!0,updatedAt:i}).where(M(u.comments.id,n.id)).run(),!o.parentId)t.db.update(u.comments).set({isDeleted:!0,updatedAt:i}).where(M(u.comments.parentId,n.id)).run();return Wn(t,{type:"comment_deleted",resourceType:"comment",resourceId:n.id}),{deleted:!0}}async function st(t,n){let o=t.db.select().from(u.comments).where(nt(M(u.comments.id,n.id),M(u.comments.isDeleted,!1))).get();if(!o)throw new G("Comment not found",{suggestion:"Check that the comment ID is correct"});if(o.parentId)throw new z("Cannot resolve a reply \u2014 only root comments can be resolved",{suggestion:"Resolve the parent comment instead"});let i=new Date,T=n.resolved?i:null,E=n.resolved?t.userId:null;return t.db.update(u.comments).set({resolved:n.resolved,resolvedBy:E,resolvedAt:T,updatedAt:i}).where(M(u.comments.id,n.id)).run(),Wn(t,{type:n.resolved?"comment_resolved":"comment_reopened",resourceType:"comment",resourceId:n.id}),{id:n.id,resolved:n.resolved,resolvedBy:E??void 0,resolvedAt:T??void 0}}var ji=D(()=>{P();d()});import{z as O}from"zod";async function yt(t,n,o,i){let T=Hn[n];if(!T)throw Error(`Unknown operation: ${n}`);if(!i?.skipAuth){let N=Wt(n);Ht(t.db,{userId:t.userId,driveId:t.driveId,requiredRole:N})}let E=T.schema.parse(o);return T.handler(t,E)}function $t(){return Object.keys(Hn)}function Lt(t){return Hn[t]}var Hn;var Cn=D(()=>{zt();xo();ao();ti();oi();Ei();yi();Ri();Di();_i();Ui();Zi();Bi();Yi();Qi();Pi();Hi();vi();Ki();li();ki();ji();Hn={write:{description:"Write or overwrite a file. Creates the file if it doesn't exist, or creates a new version. Use expectedVersion for optimistic concurrency. Returns { version, path, size }.",handler:mo,schema:O.object({path:O.string(),content:O.string(),message:O.string().optional(),expectedVersion:O.number().int().optional()})},cat:{description:"Read file content with optional pagination via offset/limit. Returns { content, totalLines, truncated }.",handler:co,schema:O.object({path:O.string(),offset:O.number().int().min(0).optional(),limit:O.number().int().min(1).optional()})},edit:{description:"Replace a specific string in a file (surgical find-and-replace). Captures the edit intent as a diff summary in version history. Returns { version, path, changes }.",handler:so,schema:O.object({path:O.string(),old_string:O.string(),new_string:O.string(),message:O.string().optional()})},append:{description:"Append content to the end of an existing file. Creates a new version. Returns { version, size }.",handler:ni,schema:O.object({path:O.string(),content:O.string(),message:O.string().optional()})},ls:{description:"List immediate children of a directory. Returns { entries } where each entry has name, type (file/directory), size, author, modifiedAt.",handler:Ti,schema:O.object({path:O.string().optional()})},stat:{description:"Get file metadata without reading content. Returns path, size, contentType, author, currentVersion, createdAt, modifiedAt, isDeleted, embeddingStatus.",handler:Ni,schema:O.object({path:O.string()})},rm:{description:"Delete a file. Removes from S3, cleans up FTS5 index and vector embeddings. Returns { path, deleted }.",handler:Li,schema:O.object({path:O.string()})},mv:{description:"Move or rename a file. Preserves version history at the new path. Returns { from, to, version }.",handler:Ii,schema:O.object({from:O.string(),to:O.string(),message:O.string().optional()})},cp:{description:"Copy a file using server-side S3 copy. Creates a new version at the destination. Returns { from, to, version }.",handler:Oi,schema:O.object({from:O.string(),to:O.string()})},tail:{description:"Read the last N lines of a file (default 20). Returns { content, totalLines, truncated }.",handler:Ai,schema:O.object({path:O.string(),lines:O.number().int().min(1).optional()})},log:{description:"Show version history for a file. Returns { versions } with version number, author, timestamp, operation type, message, and diff summary.",handler:Xi,schema:O.object({path:O.string(),limit:O.number().int().min(1).optional()})},diff:{description:"Show the diff between two versions of a file. Specify v1 and v2 version numbers. Returns { changes } as add/remove/context hunks.",handler:$i,schema:O.object({path:O.string(),v1:O.number().int(),v2:O.number().int()})},revert:{description:"Revert a file to a previous version. Creates a new version with the old content. Returns { version, revertedTo }.",handler:Mi,schema:O.object({path:O.string(),version:O.number().int()})},recent:{description:"Show recent activity across the drive. Optionally filter by path prefix and time window (since). Returns { entries } with path and version details.",handler:Gi,schema:O.object({path:O.string().optional(),since:O.coerce.date().optional(),limit:O.number().int().min(1).optional()})},grep:{description:"Search file content using regex pattern within a specific path. Returns matching lines with line numbers. Searches the FTS5 index, not S3 directly.",handler:Fi,schema:O.object({pattern:O.string(),path:O.string()})},fts:{description:"Full-text search across all file content using FTS5 tokens. Different from grep (regex) and search (semantic). Returns { matches } with path, snippet, and rank.",handler:Wi,schema:O.object({pattern:O.string(),path:O.string().optional()})},search:{description:"Semantic/vector search using natural language queries. Requires an embedding provider (OPENAI_API_KEY or GEMINI_API_KEY). Returns { results } ranked by relevance.",handler:Ci,schema:O.object({query:O.string(),limit:O.number().int().min(1).optional()})},reindex:{description:"Re-index files with failed or missing FTS5/embedding entries. Optionally scope to a path prefix. Use after bulk writes or provider changes.",handler:gi,schema:O.object({path:O.string().optional()})},tree:{description:"Recursively list all files and directories. Use depth to limit recursion. Returns a nested tree structure with name, type, size, and children.",handler:Vi,schema:O.object({path:O.string().optional(),depth:O.number().int().min(1).optional()})},glob:{description:"Find files by name pattern. Use `*.md` for root-level files only, `**/*.md` for recursive matching across all subdirectories. Supports `*` (any chars except /), `?` (single char), `**` (any path depth). Optionally scope to a path prefix. Returns { matches } with path, size, and modifiedAt.",handler:di,schema:O.object({pattern:O.string(),path:O.string().optional()})},"comment-add":{description:"Add a comment to a file. Supports line ranges and threading via parentId. Replies auto-resolve path from parent. Returns { id, path, body, author, createdAt }.",handler:rt,schema:O.object({path:O.string().optional(),body:O.string(),parentId:O.string().optional(),lineStart:O.number().int().optional(),lineEnd:O.number().int().optional(),quotedContent:O.string().optional()})},"comment-list":{description:"List comments on a file. Filter by path, resolved state, or parentId. Defaults to unresolved root comments. Returns { comments } with inline replies.",handler:mt,schema:O.object({path:O.string().optional(),parentId:O.string().optional(),resolved:O.boolean().optional(),orgId:O.string().optional(),limit:O.number().int().min(1).optional(),offset:O.number().int().min(0).optional()})},"comment-get":{description:"Get a single comment by ID with all its replies. Returns { comment, replies }.",handler:xt,schema:O.object({id:O.string()})},"comment-update":{description:"Update a comment's body. Only the original author can update. Returns { id, body, updatedAt }.",handler:ct,schema:O.object({id:O.string(),body:O.string()})},"comment-delete":{description:"Soft-delete a comment. Only the original author can delete. Deleting a root comment also soft-deletes its replies. Returns { deleted }.",handler:at,schema:O.object({id:O.string()})},"comment-resolve":{description:"Resolve or reopen a root comment. Set resolved=true to resolve, resolved=false to reopen. Only root comments can be resolved. Returns { id, resolved, resolvedBy, resolvedAt }.",handler:st,schema:O.object({id:O.string(),resolved:O.boolean()})}}});import{eq as zi}from"drizzle-orm";function Dt(t,n){let o=crypto.randomUUID(),i=new Date;return t.insert(u.drives).values({id:o,orgId:n.orgId,name:n.name,isDefault:n.isDefault??!1,createdAt:i}).run(),{id:o,name:n.name}}function Ot(t,n){return t.select().from(u.drives).where(zi(u.drives.orgId,n)).all().map((o)=>({id:o.id,name:o.name,isDefault:o.isDefault}))}function vn(t,n){let o=t.select().from(u.drives).where(zi(u.drives.id,n)).get();if(!o)return null;return{id:o.id,name:o.name,orgId:o.orgId,isDefault:o.isDefault}}function gn(t,n){t.insert(u.driveMembers).values({driveId:n.driveId,userId:n.userId,role:n.role}).onConflictDoUpdate({target:[u.driveMembers.driveId,u.driveMembers.userId],set:{role:n.role}}).run()}var Kn=D(()=>{P()});import{eq as vt}from"drizzle-orm";function _t(t,n){let o=crypto.randomUUID(),i=new Date;t.insert(u.orgs).values({id:o,name:n.name,isPersonal:n.isPersonal??!1,createdAt:i}).run(),t.insert(u.orgMembers).values({orgId:o,userId:n.userId,role:"admin"}).run();let T=Dt(t,{orgId:o,name:"default",isDefault:!0});return t.insert(u.driveMembers).values({driveId:T.id,userId:n.userId,role:"admin"}).run(),{id:o,name:n.name}}function V(t,n){return t.select({orgId:u.orgMembers.orgId,role:u.orgMembers.role,name:u.orgs.name,isPersonal:u.orgs.isPersonal}).from(u.orgMembers).innerJoin(u.orgs,vt(u.orgMembers.orgId,u.orgs.id)).where(vt(u.orgMembers.userId,n)).all().map((i)=>({id:i.orgId,name:i.name,role:i.role,isPersonal:i.isPersonal}))}function gt(t,n){let o=t.select().from(u.orgs).where(vt(u.orgs.id,n)).get();if(!o)return null;return{id:o.id,name:o.name,isPersonal:o.isPersonal}}function Kt(t,n){let o=t.select().from(u.users).where(vt(u.users.email,n.email)).get();if(!o)throw Error(`User with email ${n.email} not found`);t.insert(u.orgMembers).values({orgId:n.orgId,userId:o.id,role:n.role}).onConflictDoUpdate({target:[u.orgMembers.orgId,u.orgMembers.userId],set:{role:n.role}}).run();let i=t.select().from(u.drives).where(vt(u.drives.orgId,n.orgId)).get();if(i)t.insert(u.driveMembers).values({driveId:i.id,userId:o.id,role:n.role}).onConflictDoUpdate({target:[u.driveMembers.driveId,u.driveMembers.userId],set:{role:n.role}}).run()}var en=D(()=>{P();Kn()});import{eq as bi}from"drizzle-orm";function pi(t){let n=new Bun.CryptoHasher("sha256");return n.update(t),n.digest("hex")}function Vu(){let t=new Uint8Array(32);return crypto.getRandomValues(t),`af_${Array.from(t,(o)=>o.toString(16).padStart(2,"0")).join("")}`}function lu(){return crypto.randomUUID()}function b(t,n){let o=lu(),i=Vu(),T=pi(i),E=new Date;return t.insert(u.users).values({id:o,email:n.email,apiKeyHash:T,createdAt:E}).run(),_t(t,{name:n.email.split("@")[0],userId:o,isPersonal:!0}),{user:{id:o,email:n.email},apiKey:i}}function ot(t,n){let o=pi(n),i=t.select().from(u.users).where(bi(u.users.apiKeyHash,o)).get();if(!i)return null;return{id:i.id,email:i.email}}function Vn(t,n){let o=t.select().from(u.users).where(bi(u.users.email,n)).get();if(!o)return null;return{id:o.id,email:o.email}}var ln=D(()=>{P();en()});import{eq as Rt,and as qn}from"drizzle-orm";function p(t,n){if(n.driveId){let E=t.select().from(u.drives).where(Rt(u.drives.id,n.driveId)).get();if(!E)throw Error(`Drive not found: ${n.driveId}`);let N=tt(t,n.userId,n.driveId);if(!N)throw Error("You do not have access to this drive");return{orgId:E.orgId,driveId:n.driveId,role:N}}if(n.orgId){let E=t.select().from(u.drives).where(qn(Rt(u.drives.orgId,n.orgId),Rt(u.drives.isDefault,!0))).get();if(!E)throw Error(`No default drive for org: ${n.orgId}`);let N=tt(t,n.userId,E.id);if(!N)throw Error("You do not have access to this drive");return{orgId:n.orgId,driveId:E.id,role:N}}let o=t.select({orgId:u.orgMembers.orgId}).from(u.orgMembers).innerJoin(u.orgs,Rt(u.orgMembers.orgId,u.orgs.id)).where(qn(Rt(u.orgMembers.userId,n.userId),Rt(u.orgs.isPersonal,!0))).get();if(!o)throw Error("No personal org found for user");let i=t.select().from(u.drives).where(qn(Rt(u.drives.orgId,o.orgId),Rt(u.drives.isDefault,!0))).get();if(!i)throw Error("No default drive found");let T=tt(t,n.userId,i.id);if(!T)throw Error("You do not have access to your default drive");return{orgId:o.orgId,driveId:i.id,role:T}}var hi=D(()=>{P();zt()});function et(t){let n=B();if(n.auth.apiKey){if(ot(t,n.auth.apiKey))return{apiKey:n.auth.apiKey}}console.error("[agent-fs] No local user found, creating one...");let o=b(t,{email:"local@agent-fs.local"});return S("auth.apiKey",o.apiKey),console.error("[agent-fs] Local user created automatically."),{apiKey:o.apiKey}}var ri=D(()=>{Gt();ln()});var mi=D(()=>{ln();en();Kn();zt();hi();ri()});var ci;var xi=D(()=>{ci={name:"agent-fs",version:"0.3.1",private:!0,workspaces:["packages/*"],scripts:{typecheck:"tsc --build",test:"bun test packages/*/src/","test:coverage":"bun test --coverage packages/*/src/",build:"cd packages/cli && bun run build:npm"},devDependencies:{"bun-types":"^1.2.0",typescript:"^5.7.0",yaml:"^2.8.2","zod-to-json-schema":"^3.25.1"}}});var l;var dn=D(()=>{xi();l=ci.version});var si={};Ut(si,{LocalEmbeddingProvider:()=>ai});import{join as du}from"path";import{mkdirSync as ku,existsSync as fu}from"fs";class ai{name="local";dimensions=768;llama=null;model=null;embeddingContext=null;initPromise=null;async init(){if(this.embeddingContext)return;if(this.initPromise)return this.initPromise;return this.initPromise=this._doInit(),this.initPromise}async _doInit(){let{getLlama:t,resolveModelFile:n}=await import("node-llama-cpp");this.llama=await t();let o=du(m(),"models");if(!fu(o))ku(o,{recursive:!0});console.error("[agent-fs] Resolving local embedding model...");let i=await n(ju,o);console.error("[agent-fs] Model ready:",i),this.model=await this.llama.loadModel({modelPath:i}),this.embeddingContext=await this.model.createEmbeddingContext()}async embed(t){await this.init();let n=await this.embeddingContext.getEmbeddingFor(t);return Array.from(n.vector)}async embedBatch(t){await this.init();let n=[];for(let o of t){let i=await this.embeddingContext.getEmbeddingFor(o);n.push(Array.from(i.vector))}return n}async dispose(){if(this.embeddingContext)await this.embeddingContext.dispose(),this.embeddingContext=null;if(this.model)await this.model.dispose(),this.model=null;this.initPromise=null}}var ju="hf:nomic-ai/nomic-embed-text-v1.5-GGUF:Q8_0";var tT=D(()=>{Gt()});var kn={};Ut(kn,{OpenAIEmbeddingProvider:()=>nT});import zu from"openai";class nT{name="openai";dimensions=768;client;constructor(t){this.client=new zu({apiKey:t})}async embed(t){return(await this.client.embeddings.create({model:"text-embedding-3-small",input:t,dimensions:768})).data[0].embedding}async embedBatch(t){return(await this.client.embeddings.create({model:"text-embedding-3-small",input:t,dimensions:768})).data.sort((o,i)=>o.index-i.index).map((o)=>o.embedding)}}var fn=()=>{};var jn={};Ut(jn,{GeminiEmbeddingProvider:()=>oT});import{GoogleGenAI as bu}from"@google/genai";class oT{name="gemini";dimensions=768;client;constructor(t){this.client=new bu({apiKey:t})}async embed(t){return(await this.client.models.embedContent({model:"gemini-embedding-001",contents:t,config:{outputDimensionality:768}})).embeddings[0].values}async embedBatch(t){let n=[];for(let o of t){let i=await this.client.models.embedContent({model:"gemini-embedding-001",contents:o,config:{outputDimensionality:768}});n.push(i.embeddings[0].values)}return n}}var zn=()=>{};async function iT(t){switch(t.provider){case"local":{let{LocalEmbeddingProvider:n}=await Promise.resolve().then(() => (tT(),si));return new n}case"openai":{if(!t.apiKey)throw Error("OpenAI API key required. Set embedding.apiKey in config.");let{OpenAIEmbeddingProvider:n}=await Promise.resolve().then(() => (fn(),kn));return new n(t.apiKey)}case"gemini":{if(!t.apiKey)throw Error("Gemini API key required. Set embedding.apiKey in config.");let{GeminiEmbeddingProvider:n}=await Promise.resolve().then(() => (zn(),jn));return new n(t.apiKey)}default:throw Error(`Unknown embedding provider: ${t.provider}`)}}async function Bt(t){if(process.env.OPENAI_API_KEY)try{let{OpenAIEmbeddingProvider:n}=await Promise.resolve().then(() => (fn(),kn));return new n(process.env.OPENAI_API_KEY)}catch(n){console.error("[agent-fs] Failed to load OpenAI provider:",n)}if(process.env.GEMINI_API_KEY)try{let{GeminiEmbeddingProvider:n}=await Promise.resolve().then(() => (zn(),jn));return new n(process.env.GEMINI_API_KEY)}catch(n){console.error("[agent-fs] Failed to load Gemini provider:",n)}if(t?.provider&&t.provider!=="local"&&t.apiKey)try{return await iT(t)}catch(n){console.error("[agent-fs] Failed to create embedding provider from config:",n)}if(t?.provider==="local")try{return await iT(t)}catch(n){console.error("[agent-fs] Failed to load local embedding provider:",n)}return null}var ET,TT,uT=(t)=>typeof t==="string"?{...TT,name:t}:{...TT,...t};var tn=D(()=>{ET=Symbol("Let zodToJsonSchema decide on which parser to use"),TT={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"}});var NT=(t)=>{let n=uT(t),o=n.name!==void 0?[...n.basePath,n.definitionPath,n.name]:n.basePath;return{...n,flags:{hasReferencedOpenAiAnyType:!1},currentPath:o,propertyPath:void 0,seen:new Map(Object.entries(n.definitions).map(([i,T])=>[T._def,{def:T._def,path:[...n.basePath,n.definitionPath,i],jsonSchema:void 0}]))}};var bn=D(()=>{tn()});function pn(t,n,o,i){if(!i?.errorMessages)return;if(o)t.errorMessage={...t.errorMessage,[n]:o}}function w(t,n,o,i,T){t[n]=o,pn(t,n,i,T)}var nn=(t,n)=>{let o=0;for(;o<t.length&&o<n.length;o++)if(t[o]!==n[o])break;return[(t.length-o).toString(),...n.slice(o)].join("/")};function Q(t){if(t.target!=="openAi")return{};let n=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?nn(n,t.currentPath):n.join("/")}}var k=()=>{};import{ZodFirstPartyTypeKind as pu}from"zod/v3";function yT(t,n){let o={type:"array"};if(t.type?._def&&t.type?._def?.typeName!==pu.ZodAny)o.items=U(t.type._def,{...n,currentPath:[...n.currentPath,"items"]});if(t.minLength)w(o,"minItems",t.minLength.value,t.minLength.message,n);if(t.maxLength)w(o,"maxItems",t.maxLength.value,t.maxLength.message,n);if(t.exactLength)w(o,"minItems",t.exactLength.value,t.exactLength.message,n),w(o,"maxItems",t.exactLength.value,t.exactLength.message,n);return o}var hn=D(()=>{W()});function LT(t,n){let o={type:"integer",format:"int64"};if(!t.checks)return o;for(let i of t.checks)switch(i.kind){case"min":if(n.target==="jsonSchema7")if(i.inclusive)w(o,"minimum",i.value,i.message,n);else w(o,"exclusiveMinimum",i.value,i.message,n);else{if(!i.inclusive)o.exclusiveMinimum=!0;w(o,"minimum",i.value,i.message,n)}break;case"max":if(n.target==="jsonSchema7")if(i.inclusive)w(o,"maximum",i.value,i.message,n);else w(o,"exclusiveMaximum",i.value,i.message,n);else{if(!i.inclusive)o.exclusiveMaximum=!0;w(o,"maximum",i.value,i.message,n)}break;case"multipleOf":w(o,"multipleOf",i.value,i.message,n);break}return o}var rn=()=>{};function RT(){return{type:"boolean"}}function on(t,n){return U(t.type._def,n)}var Tn=D(()=>{W()});var IT=(t,n)=>{return U(t.innerType._def,n)};var mn=D(()=>{W()});function xn(t,n,o){let i=o??n.dateStrategy;if(Array.isArray(i))return{anyOf:i.map((T,E)=>xn(t,n,T))};switch(i){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return hu(t,n)}}var hu=(t,n)=>{let o={type:"integer",format:"unix-time"};if(n.target==="openApi3")return o;for(let i of t.checks)switch(i.kind){case"min":w(o,"minimum",i.value,i.message,n);break;case"max":w(o,"maximum",i.value,i.message,n);break}return o};var cn=()=>{};function DT(t,n){return{...U(t.innerType._def,n),default:t.defaultValue()}}var an=D(()=>{W()});function OT(t,n){return n.effectStrategy==="input"?U(t.schema._def,n):Q(n)}var sn=D(()=>{W();k()});function _T(t){return{type:"string",enum:Array.from(t.values)}}function AT(t,n){let o=[U(t.left._def,{...n,currentPath:[...n.currentPath,"allOf","0"]}),U(t.right._def,{...n,currentPath:[...n.currentPath,"allOf","1"]})].filter((E)=>!!E),i=n.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,T=[];return o.forEach((E)=>{if(ru(E)){if(T.push(...E.allOf),E.unevaluatedProperties===void 0)i=void 0}else{let N=E;if("additionalProperties"in E&&E.additionalProperties===!1){let{additionalProperties:L,...y}=E;N=y}else i=void 0;T.push(N)}}),T.length?{allOf:T,...i}:void 0}var ru=(t)=>{if("type"in t&&t.type==="string")return!1;return"allOf"in t};var to=D(()=>{W()});function UT(t,n){let o=typeof t.value;if(o!=="bigint"&&o!=="number"&&o!=="boolean"&&o!=="string")return{type:Array.isArray(t.value)?"array":"object"};if(n.target==="openApi3")return{type:o==="bigint"?"integer":o,enum:[t.value]};return{type:o==="bigint"?"integer":o,const:t.value}}function En(t,n){let o={type:"string"};if(t.checks)for(let i of t.checks)switch(i.kind){case"min":w(o,"minLength",typeof o.minLength==="number"?Math.max(o.minLength,i.value):i.value,i.message,n);break;case"max":w(o,"maxLength",typeof o.maxLength==="number"?Math.min(o.maxLength,i.value):i.value,i.message,n);break;case"email":switch(n.emailStrategy){case"format:email":r(o,"email",i.message,n);break;case"format:idn-email":r(o,"idn-email",i.message,n);break;case"pattern:zod":e(o,h.email,i.message,n);break}break;case"url":r(o,"uri",i.message,n);break;case"uuid":r(o,"uuid",i.message,n);break;case"regex":e(o,i.regex,i.message,n);break;case"cuid":e(o,h.cuid,i.message,n);break;case"cuid2":e(o,h.cuid2,i.message,n);break;case"startsWith":e(o,RegExp(`^${oo(i.value,n)}`),i.message,n);break;case"endsWith":e(o,RegExp(`${oo(i.value,n)}$`),i.message,n);break;case"datetime":r(o,"date-time",i.message,n);break;case"date":r(o,"date",i.message,n);break;case"time":r(o,"time",i.message,n);break;case"duration":r(o,"duration",i.message,n);break;case"length":w(o,"minLength",typeof o.minLength==="number"?Math.max(o.minLength,i.value):i.value,i.message,n),w(o,"maxLength",typeof o.maxLength==="number"?Math.min(o.maxLength,i.value):i.value,i.message,n);break;case"includes":{e(o,RegExp(oo(i.value,n)),i.message,n);break}case"ip":{if(i.version!=="v6")r(o,"ipv4",i.message,n);if(i.version!=="v4")r(o,"ipv6",i.message,n);break}case"base64url":e(o,h.base64url,i.message,n);break;case"jwt":e(o,h.jwt,i.message,n);break;case"cidr":{if(i.version!=="v6")e(o,h.ipv4Cidr,i.message,n);if(i.version!=="v4")e(o,h.ipv6Cidr,i.message,n);break}case"emoji":e(o,h.emoji(),i.message,n);break;case"ulid":{e(o,h.ulid,i.message,n);break}case"base64":{switch(n.base64Strategy){case"format:binary":{r(o,"binary",i.message,n);break}case"contentEncoding:base64":{w(o,"contentEncoding","base64",i.message,n);break}case"pattern:zod":{e(o,h.base64,i.message,n);break}}break}case"nanoid":e(o,h.nanoid,i.message,n);case"toLowerCase":case"toUpperCase":case"trim":break;default:((T)=>{})(i)}return o}function oo(t,n){return n.patternStrategy==="escape"?xu(t):t}function xu(t){let n="";for(let o=0;o<t.length;o++){if(!mu.has(t[o]))n+="\\";n+=t[o]}return n}function r(t,n,o,i){if(t.format||t.anyOf?.some((T)=>T.format)){if(!t.anyOf)t.anyOf=[];if(t.format){if(t.anyOf.push({format:t.format,...t.errorMessage&&i.errorMessages&&{errorMessage:{format:t.errorMessage.format}}}),delete t.format,t.errorMessage){if(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0)delete t.errorMessage}}t.anyOf.push({format:n,...o&&i.errorMessages&&{errorMessage:{format:o}}})}else w(t,"format",n,o,i)}function e(t,n,o,i){if(t.pattern||t.allOf?.some((T)=>T.pattern)){if(!t.allOf)t.allOf=[];if(t.pattern){if(t.allOf.push({pattern:t.pattern,...t.errorMessage&&i.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}}}),delete t.pattern,t.errorMessage){if(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0)delete t.errorMessage}}t.allOf.push({pattern:ST(n,i),...o&&i.errorMessages&&{errorMessage:{pattern:o}}})}else w(t,"pattern",ST(n,i),o,i)}function ST(t,n){if(!n.applyRegexFlags||!t.flags)return t.source;let o={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},i=o.i?t.source.toLowerCase():t.source,T="",E=!1,N=!1,L=!1;for(let y=0;y<i.length;y++){if(E){T+=i[y],E=!1;continue}if(o.i){if(N){if(i[y].match(/[a-z]/)){if(L)T+=i[y],T+=`${i[y-2]}-${i[y]}`.toUpperCase(),L=!1;else if(i[y+1]==="-"&&i[y+2]?.match(/[a-z]/))T+=i[y],L=!0;else T+=`${i[y]}${i[y].toUpperCase()}`;continue}}else if(i[y].match(/[a-z]/)){T+=`[${i[y]}${i[y].toUpperCase()}]`;continue}}if(o.m){if(i[y]==="^"){T+=`(^|(?<=[\r
|
|
154
154
|
]))`;continue}else if(i[y]==="$"){T+=`($|(?=[\r
|
|
155
155
|
]))`;continue}}if(o.s&&i[y]==="."){T+=N?`${i[y]}\r
|
|
156
156
|
`:`[${i[y]}\r
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@desplega.ai/agent-fs",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Agent-first filesystem backed by S3",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"agent-fs": "dist/cli.js"
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
|
-
"dist",
|
|
25
|
+
"dist/cli.js",
|
|
26
26
|
"README.md"
|
|
27
27
|
],
|
|
28
28
|
"scripts": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/api-client.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect, beforeAll, afterAll } from "bun:test";
|
|
2
|
-
import { createTestDb, MockS3Client } from "../../../core/src/test-utils.js";
|
|
3
|
-
import { createApp } from "../../../server/src/app.js";
|
|
4
|
-
// We test ApiClient by pointing it at a real in-memory Hono server.
|
|
5
|
-
let server;
|
|
6
|
-
let port = 0;
|
|
7
|
-
let apiKey;
|
|
8
|
-
let orgId;
|
|
9
|
-
beforeAll(async () => {
|
|
10
|
-
const db = createTestDb();
|
|
11
|
-
const s3 = new MockS3Client();
|
|
12
|
-
const app = createApp(db, s3);
|
|
13
|
-
// Start on a random port
|
|
14
|
-
server = Bun.serve({
|
|
15
|
-
port: 0,
|
|
16
|
-
fetch: app.fetch,
|
|
17
|
-
});
|
|
18
|
-
port = server.port;
|
|
19
|
-
// Register a user to get an API key
|
|
20
|
-
const res = await fetch(`http://localhost:${port}/auth/register`, {
|
|
21
|
-
method: "POST",
|
|
22
|
-
headers: { "Content-Type": "application/json" },
|
|
23
|
-
body: JSON.stringify({ email: "cli-test@example.com" }),
|
|
24
|
-
});
|
|
25
|
-
const body = await res.json();
|
|
26
|
-
apiKey = body.apiKey;
|
|
27
|
-
orgId = body.orgId;
|
|
28
|
-
// Set env vars so ApiClient picks them up
|
|
29
|
-
process.env.AGENT_FS_API_URL = `http://localhost:${port}`;
|
|
30
|
-
process.env.AGENT_FS_API_KEY = apiKey;
|
|
31
|
-
});
|
|
32
|
-
afterAll(() => {
|
|
33
|
-
server?.stop();
|
|
34
|
-
delete process.env.AGENT_FS_API_URL;
|
|
35
|
-
delete process.env.AGENT_FS_API_KEY;
|
|
36
|
-
});
|
|
37
|
-
describe("ApiClient", () => {
|
|
38
|
-
// Dynamic import so env vars are set before constructor runs
|
|
39
|
-
async function makeClient() {
|
|
40
|
-
const { ApiClient } = await import("../api-client.js");
|
|
41
|
-
return new ApiClient();
|
|
42
|
-
}
|
|
43
|
-
test("get() fetches data", async () => {
|
|
44
|
-
const client = await makeClient();
|
|
45
|
-
const result = await client.get("/orgs");
|
|
46
|
-
expect(result.orgs).toBeDefined();
|
|
47
|
-
expect(result.orgs.length).toBeGreaterThan(0);
|
|
48
|
-
});
|
|
49
|
-
test("post() sends data", async () => {
|
|
50
|
-
const client = await makeClient();
|
|
51
|
-
const result = await client.post("/orgs", { name: "cli-test-org" });
|
|
52
|
-
expect(result.name).toBe("cli-test-org");
|
|
53
|
-
});
|
|
54
|
-
test("callOp() dispatches operation", async () => {
|
|
55
|
-
const client = await makeClient();
|
|
56
|
-
// Write a file
|
|
57
|
-
const writeResult = await client.callOp(orgId, "write", {
|
|
58
|
-
path: "/cli-test.txt",
|
|
59
|
-
content: "Hello from CLI",
|
|
60
|
-
});
|
|
61
|
-
expect(writeResult.version).toBe(1);
|
|
62
|
-
// Read it back
|
|
63
|
-
const catResult = await client.callOp(orgId, "cat", {
|
|
64
|
-
path: "/cli-test.txt",
|
|
65
|
-
});
|
|
66
|
-
expect(catResult.content).toBe("Hello from CLI");
|
|
67
|
-
});
|
|
68
|
-
test("setApiKey() changes auth", async () => {
|
|
69
|
-
const client = await makeClient();
|
|
70
|
-
client.setApiKey("af_invalid_key");
|
|
71
|
-
// Should fail with auth error
|
|
72
|
-
await expect(client.get("/orgs")).rejects.toThrow();
|
|
73
|
-
});
|
|
74
|
-
test("connection error gives helpful message", async () => {
|
|
75
|
-
process.env.AGENT_FS_API_URL = "http://localhost:1"; // Nothing running
|
|
76
|
-
const client = await makeClient();
|
|
77
|
-
await expect(client.get("/health")).rejects.toThrow(/Cannot connect/);
|
|
78
|
-
// Restore
|
|
79
|
-
process.env.AGENT_FS_API_URL = `http://localhost:${port}`;
|
|
80
|
-
});
|
|
81
|
-
test("server error includes message from response", async () => {
|
|
82
|
-
const client = await makeClient();
|
|
83
|
-
await expect(client.callOp(orgId, "cat", { path: "/nonexistent.txt" })).rejects.toThrow(/not found|NoSuchKey/i);
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
//# sourceMappingURL=api-client.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.test.js","sourceRoot":"","sources":["../../src/__tests__/api-client.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,oEAAoE;AACpE,IAAI,MAAoC,CAAC;AACzC,IAAI,IAAI,GAAG,CAAC,CAAC;AACb,IAAI,MAAc,CAAC;AACnB,IAAI,KAAa,CAAC;AAElB,SAAS,CAAC,KAAK,IAAI,EAAE;IACnB,MAAM,EAAE,GAAG,YAAY,EAAE,CAAC;IAC1B,MAAM,EAAE,GAAG,IAAI,YAAY,EAAE,CAAC;IAC9B,MAAM,GAAG,GAAG,SAAS,CAAC,EAAE,EAAE,EAAS,CAAC,CAAC;IAErC,yBAAyB;IACzB,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC;QACjB,IAAI,EAAE,CAAC;QACP,KAAK,EAAE,GAAG,CAAC,KAAK;KACjB,CAAC,CAAC;IACH,IAAI,GAAG,MAAM,CAAC,IAAK,CAAC;IAEpB,o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IACtD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,wCAAwC,EAAE,KAAK,IAAI,EAAE;QACxD,OAAO,CAAC,GAAG,CAAC,gBAAgB,GAAG,oBAAoB,CAAC,CAAC,kBAAkB;QACvE,MAAM,MAAM,GAAG,MAAM,UAAU,EAAE,CAAC;QAElC,MAAM,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAEtE,UAAU;QACV,OAAO,CAAC,GAAG,CAAC,gBAAgB,GAAG,oBAAoB,IAAI,EAAE,CAAC;IAC5D,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,6CAA6C,EAAE,KAAK,IAAI,EAAE;QAC7D,MAAM,MAAM,GAAG,MAAM,UAAU,EAAE,CAAC;QAElC,MAAM,MAAM,CACV,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC,CAC1D,CAAC,OAAO,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"param-mapping.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/param-mapping.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from "bun:test";
|
|
2
|
-
/**
|
|
3
|
-
* Tests for CLI flag → Zod schema param mapping.
|
|
4
|
-
* The CLI uses --old/--new flags but the edit Zod schema expects old_string/new_string.
|
|
5
|
-
* The CLI uses --expected-version but the write Zod schema expects expectedVersion.
|
|
6
|
-
*/
|
|
7
|
-
function applyParamMapping(params) {
|
|
8
|
-
const mapped = { ...params };
|
|
9
|
-
// These mappings mirror packages/cli/src/commands/ops.ts
|
|
10
|
-
if (mapped["expected-version"] !== undefined) {
|
|
11
|
-
mapped.expectedVersion = mapped["expected-version"];
|
|
12
|
-
delete mapped["expected-version"];
|
|
13
|
-
}
|
|
14
|
-
if (mapped["old"] !== undefined) {
|
|
15
|
-
mapped.old_string = mapped["old"];
|
|
16
|
-
delete mapped["old"];
|
|
17
|
-
}
|
|
18
|
-
if (mapped["new"] !== undefined) {
|
|
19
|
-
mapped.new_string = mapped["new"];
|
|
20
|
-
delete mapped["new"];
|
|
21
|
-
}
|
|
22
|
-
return mapped;
|
|
23
|
-
}
|
|
24
|
-
describe("CLI param mapping", () => {
|
|
25
|
-
test("maps --old to old_string and --new to new_string", () => {
|
|
26
|
-
const input = { path: "/test.md", old: "hello", new: "world" };
|
|
27
|
-
const result = applyParamMapping(input);
|
|
28
|
-
expect(result.old_string).toBe("hello");
|
|
29
|
-
expect(result.new_string).toBe("world");
|
|
30
|
-
expect(result.old).toBeUndefined();
|
|
31
|
-
expect(result.new).toBeUndefined();
|
|
32
|
-
expect(result.path).toBe("/test.md");
|
|
33
|
-
});
|
|
34
|
-
test("maps --expected-version to expectedVersion", () => {
|
|
35
|
-
const input = { path: "/test.md", "expected-version": "3" };
|
|
36
|
-
const result = applyParamMapping(input);
|
|
37
|
-
expect(result.expectedVersion).toBe("3");
|
|
38
|
-
expect(result["expected-version"]).toBeUndefined();
|
|
39
|
-
});
|
|
40
|
-
test("does not affect params without CLI flag names", () => {
|
|
41
|
-
const input = { path: "/test.md", content: "hello", message: "update" };
|
|
42
|
-
const result = applyParamMapping(input);
|
|
43
|
-
expect(result).toEqual(input);
|
|
44
|
-
});
|
|
45
|
-
test("handles missing optional params gracefully", () => {
|
|
46
|
-
const input = { path: "/test.md", old: "hello" };
|
|
47
|
-
const result = applyParamMapping(input);
|
|
48
|
-
expect(result.old_string).toBe("hello");
|
|
49
|
-
expect(result.new_string).toBeUndefined();
|
|
50
|
-
expect(result.old).toBeUndefined();
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
//# sourceMappingURL=param-mapping.test.js.map
|
|
@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M,CAAC,UAAU,CAAC,CAAC,aAAa,EAAE,CAAC;QAC1C,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,aAAa,EAAE,CAAC;IACrC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/api-client.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export declare class ApiClient {
|
|
2
|
-
private baseUrl;
|
|
3
|
-
private apiKey;
|
|
4
|
-
constructor();
|
|
5
|
-
private request;
|
|
6
|
-
get(path: string): Promise<any>;
|
|
7
|
-
post(path: string, body: any): Promise<any>;
|
|
8
|
-
callOp(orgId: string, op: string, params: Record<string, any>): Promise<any>;
|
|
9
|
-
getMe(): Promise<{
|
|
10
|
-
userId: string;
|
|
11
|
-
email: string;
|
|
12
|
-
defaultOrgId: string | null;
|
|
13
|
-
defaultDriveId: string | null;
|
|
14
|
-
}>;
|
|
15
|
-
setApiKey(key: string): void;
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=api-client.d.ts.map
|
package/dist/api-client.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"AAEA,qBAAa,SAAS;IACpB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAS;;YAcT,OAAO;IA+Bf,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAI/B,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAO3C,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IAI5E,KAAK,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAIrH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;CAG7B"}
|
package/dist/api-client.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { getConfig } from "@/core";
|
|
2
|
-
export class ApiClient {
|
|
3
|
-
baseUrl;
|
|
4
|
-
apiKey;
|
|
5
|
-
constructor() {
|
|
6
|
-
const config = getConfig();
|
|
7
|
-
this.baseUrl =
|
|
8
|
-
process.env.AGENT_FS_API_URL ??
|
|
9
|
-
config.apiUrl ??
|
|
10
|
-
`http://${config.server.host}:${config.server.port}`;
|
|
11
|
-
this.apiKey =
|
|
12
|
-
process.env.AGENT_FS_API_KEY ??
|
|
13
|
-
config.apiKey ??
|
|
14
|
-
config.auth.apiKey;
|
|
15
|
-
}
|
|
16
|
-
async request(path, opts) {
|
|
17
|
-
const headers = new Headers(opts?.headers);
|
|
18
|
-
if (this.apiKey) {
|
|
19
|
-
headers.set("Authorization", `Bearer ${this.apiKey}`);
|
|
20
|
-
}
|
|
21
|
-
headers.set("Content-Type", "application/json");
|
|
22
|
-
let res;
|
|
23
|
-
try {
|
|
24
|
-
res = await fetch(`${this.baseUrl}${path}`, { ...opts, headers });
|
|
25
|
-
}
|
|
26
|
-
catch (err) {
|
|
27
|
-
throw new Error(`Cannot connect to agent-fs daemon at ${this.baseUrl}. Is it running? Start with: agent-fs daemon start`);
|
|
28
|
-
}
|
|
29
|
-
let body;
|
|
30
|
-
try {
|
|
31
|
-
body = await res.json();
|
|
32
|
-
}
|
|
33
|
-
catch {
|
|
34
|
-
const text = await res.text().catch(() => "");
|
|
35
|
-
throw new Error(`Unexpected response from daemon (${res.status}): ${text || "empty"}`);
|
|
36
|
-
}
|
|
37
|
-
if (!res.ok) {
|
|
38
|
-
const msg = body.message ?? body.error ?? "Request failed";
|
|
39
|
-
const suggestion = body.suggestion ? `\n Suggestion: ${body.suggestion}` : "";
|
|
40
|
-
throw new Error(`${msg}${suggestion}`);
|
|
41
|
-
}
|
|
42
|
-
return body;
|
|
43
|
-
}
|
|
44
|
-
async get(path) {
|
|
45
|
-
return this.request(path);
|
|
46
|
-
}
|
|
47
|
-
async post(path, body) {
|
|
48
|
-
return this.request(path, {
|
|
49
|
-
method: "POST",
|
|
50
|
-
body: JSON.stringify(body),
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
async callOp(orgId, op, params) {
|
|
54
|
-
return this.post(`/orgs/${orgId}/ops`, { op, ...params });
|
|
55
|
-
}
|
|
56
|
-
async getMe() {
|
|
57
|
-
return this.get("/auth/me");
|
|
58
|
-
}
|
|
59
|
-
setApiKey(key) {
|
|
60
|
-
this.apiKey = key;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=api-client.js.map
|
package/dist/api-client.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,MAAM,OAAO,SAAS;IACZ,OAAO,CAAS;IAChB,MAAM,CAAS;IAEvB;QACE,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;QAC3B,IAAI,CAAC,OAAO;YACV,OAAO,CAAC,GAAG,CAAC,gBAAgB;gBAC5B,MAAM,CAAC,MAAM;gBACb,UAAU,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACvD,IAAI,CAAC,MAAM;YACT,OAAO,CAAC,GAAG,CAAC,gBAAgB;gBAC5B,MAAM,CAAC,MAAM;gBACb,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAEO,KAAK,CAAC,OAAO,CAAC,IAAY,EAAE,IAAkB;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EAAE,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,IAAY;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAY,EAAE,IAAS;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;YACxB,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SAC3B,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAa,EAAE,EAAU,EAAE,MAA2B;QACjE,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,KAAK,MAAM,EAAE,EAAE,EAAE,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,KAAK;QACT,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC9B,CAAC;IAED,SAAS,CAAC,GAAW;QACnB,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;IACpB,CAAC;CACF"}
|
package/dist/commands/auth.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAQlD,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,WAqE7C"}
|
package/dist/commands/auth.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { setConfigValue, createUser, createDatabase, listUserOrgs, } from "@/core";
|
|
3
|
-
export function authCommands(client) {
|
|
4
|
-
const cmd = new Command("auth").description("Authentication commands");
|
|
5
|
-
cmd
|
|
6
|
-
.command("register")
|
|
7
|
-
.argument("<email>", "Email address")
|
|
8
|
-
.description("Register a new user")
|
|
9
|
-
.action(async (email) => {
|
|
10
|
-
// Try daemon first, fall back to direct DB registration
|
|
11
|
-
try {
|
|
12
|
-
const result = await client.post("/auth/register", { email });
|
|
13
|
-
printRegistration(result, client);
|
|
14
|
-
}
|
|
15
|
-
catch {
|
|
16
|
-
// Daemon not running — register directly against DB
|
|
17
|
-
try {
|
|
18
|
-
const db = createDatabase();
|
|
19
|
-
const result = createUser(db, { email });
|
|
20
|
-
const orgs = listUserOrgs(db, result.user.id);
|
|
21
|
-
printRegistration({
|
|
22
|
-
apiKey: result.apiKey,
|
|
23
|
-
userId: result.user.id,
|
|
24
|
-
orgId: orgs[0]?.id,
|
|
25
|
-
}, client);
|
|
26
|
-
}
|
|
27
|
-
catch (err) {
|
|
28
|
-
if (err.message?.includes("UNIQUE")) {
|
|
29
|
-
console.error("Error: User with this email already exists.");
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
console.error(`Error: ${err.message}`);
|
|
33
|
-
}
|
|
34
|
-
process.exit(1);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
cmd
|
|
39
|
-
.command("whoami")
|
|
40
|
-
.description("Show current user info")
|
|
41
|
-
.action(async () => {
|
|
42
|
-
try {
|
|
43
|
-
const result = await client.get("/auth/me");
|
|
44
|
-
console.log(JSON.stringify(result, null, 2));
|
|
45
|
-
}
|
|
46
|
-
catch {
|
|
47
|
-
// Daemon not running — look up directly from DB
|
|
48
|
-
try {
|
|
49
|
-
const { getConfig, getUserByApiKey, createDatabase, listUserOrgs } = await import("@/core");
|
|
50
|
-
const config = getConfig();
|
|
51
|
-
if (!config.auth.apiKey) {
|
|
52
|
-
console.error("Not logged in. Run: agent-fs auth register <email>");
|
|
53
|
-
process.exit(1);
|
|
54
|
-
}
|
|
55
|
-
const db = createDatabase();
|
|
56
|
-
const user = getUserByApiKey(db, config.auth.apiKey);
|
|
57
|
-
if (!user) {
|
|
58
|
-
console.error("Invalid API key in config.");
|
|
59
|
-
process.exit(1);
|
|
60
|
-
}
|
|
61
|
-
const orgs = listUserOrgs(db, user.id);
|
|
62
|
-
console.log(JSON.stringify({ ...user, orgs }, null, 2));
|
|
63
|
-
}
|
|
64
|
-
catch (err) {
|
|
65
|
-
console.error(`Error: ${err.message}`);
|
|
66
|
-
process.exit(1);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
return cmd;
|
|
71
|
-
}
|
|
72
|
-
function printRegistration(result, client) {
|
|
73
|
-
console.log(`Registered successfully!`);
|
|
74
|
-
console.log(`API Key: ${result.apiKey}`);
|
|
75
|
-
console.log(`User ID: ${result.userId}`);
|
|
76
|
-
console.log(`Org ID: ${result.orgId}`);
|
|
77
|
-
setConfigValue("auth.apiKey", result.apiKey);
|
|
78
|
-
client.setApiKey(result.apiKey);
|
|
79
|
-
console.log("\nAPI key saved to config.");
|
|
80
|
-
}
|
|
81
|
-
//# sourceMappingURL=auth.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EACL,cAAc,EACd,UAAU,EACV,cAAc,EACd,YAAY,GACb,MAAM,QAAQ,CAAC;AAEhB,MAAM,UAAU,YAAY,CAAC,MAAiB;IAC5C,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,yBAAyB,CAAC,CAAC;IAEvE,GAAG;SACA,OAAO,CAAC,UAAU,CAAC;SACnB,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;SACpC,WAAW,CAAC,qBAAqB,CAAC;SAClC,MAAM,CAAC,KAAK,EAAE,KAAa,EAAE,EAAE;QAC9B,wDAAwD;QACxD,IAAI,CAAC;YACH,MAAM,MAAM,GAA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