@kelceyp/caw-server 0.0.95 → 0.0.98
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/main.js +1 -1
- package/dist/public_html/main.js +396 -396
- package/dist/public_html/styles.css +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -654,7 +654,7 @@ Only supports batchable (line-agnostic) operation types:
|
|
|
654
654
|
Note: Line-based operations (replace_lines, insert_at) are NOT supported in batch mode
|
|
655
655
|
because they are position-sensitive and would produce unpredictable results.
|
|
656
656
|
|
|
657
|
-
Use preview=true to see what changes would be made without saving.`,schema:CE1,execute:DE1};W6();W6();var c4=A.preprocess(($)=>$==="true"?!0:$==="false"?!1:$,A.boolean()),a86=($=A.any())=>A.preprocess((K)=>{if(typeof K==="string")try{return JSON.parse(K)}catch{return K}return K},A.record($)),r86=($)=>A.preprocess((K)=>{if(typeof K==="string")try{return JSON.parse(K)}catch{return K}return K},$);var hE1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),start_line:A.coerce.number().int().min(1).describe("Start line number (1-based)"),end_line:A.coerce.number().int().min(1).describe("End line number (1-based, inclusive)"),include_draft:c4.optional().describe("Read draft instead of published")}),EE1=async({core:$,projectId:K},{id:q,start_line:Y,end_line:J,include_draft:z})=>{try{let W=await $.readLines(K,{id:q,startLine:Y,endLine:J,includeDraft:z}),Z={content:W.content,lineNumbers:W.lineNumbers,totalLines:W.totalLines};return{content:[{type:"text",text:JSON.stringify(Z,null,2)}]}}catch(W){return{content:[{type:"text",text:`Error: ${W.message}`}],isError:!0}}},s86={name:"read_lines",title:"Read Lines",description:"Read specific lines from a document. Returns content with line numbers in format { content, lineNumbers: { start, end }, totalLines }. Line numbers are 1-based and inclusive.",schema:hE1,execute:EE1};W6();var SE1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),start_marker:A.string().describe("String marking the start"),end_marker:A.string().describe("String marking the end"),inclusive:c4.optional().default(!1).describe("Include markers in output"),include_draft:c4.optional().describe("Read draft instead of published")}),LE1=async({core:$,projectId:K},{id:q,start_marker:Y,end_marker:J,inclusive:z,include_draft:W})=>{try{let Z=await $.readBetweenMarkers(K,{id:q,startMarker:Y,endMarker:J,inclusive:z,includeDraft:W}),H={content:Z.content,lineNumbers:Z.lineNumbers};return{content:[{type:"text",text:JSON.stringify(H,null,2)}]}}catch(Z){return{content:[{type:"text",text:`Error: ${Z.message}`}],isError:!0}}},t86={name:"read_between_markers",title:"Read Between Markers",description:"Read content between markers from a document. Returns content with line numbers in format { content, lineNumbers: { start, end } }.",schema:SE1,execute:LE1};W6();var IE1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),include_draft:c4.optional().describe("Read draft instead of published")}),xE1=async({core:$,projectId:K},{id:q,include_draft:Y})=>{try{let J=await $.getDocumentStats(K,{id:q,includeDraft:Y}),z={lines:J.lines,words:J.words,chars:J.chars,headings:J.headings,checklists:J.checklists,hasFrontmatter:J.hasFrontmatter};return{content:[{type:"text",text:JSON.stringify(z,null,2)}]}}catch(J){return{content:[{type:"text",text:`Error: ${J.message}`}],isError:!0}}},e86={name:"get_document_stats",title:"Get Document Stats",description:"Get document statistics without transferring content. Returns { lines, words, chars, headings: { h1...h6 }, checklists: { checked, unchecked }, hasFrontmatter }.",schema:IE1,execute:xE1};W6();var gE1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),max_depth:A.coerce.number().int().min(1).max(6).optional().describe("Maximum heading level to include (1-6)"),include_draft:c4.optional().describe("Read draft instead of published")}),bE1=async({core:$,projectId:K},{id:q,max_depth:Y,include_draft:J})=>{try{let z=await $.readHeadings(K,{id:q,maxDepth:Y,includeDraft:J});return{content:[{type:"text",text:JSON.stringify(z,null,2)}]}}catch(z){return{content:[{type:"text",text:`Error: ${z.message}`}],isError:!0}}},$66={name:"read_headings",title:"Read Headings",description:"Extract heading structure from a document. Returns array of { level, text, lineNumber } objects. Ignores headings inside fenced code blocks.",schema:gE1,execute:bE1};W6();var yE1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),heading:A.union([A.string(),A.coerce.number()]).describe("Heading text or line number (1-based)"),include_heading:c4.optional().default(!0).describe("Include the heading line in output"),include_draft:c4.optional().describe("Read draft instead of published")}),uE1=async({core:$,projectId:K},{id:q,heading:Y,include_heading:J,include_draft:z})=>{try{let W=await $.readSection(K,{id:q,heading:Y,includeHeading:J,includeDraft:z}),Z={content:W.content,lineNumbers:W.lineNumbers};return{content:[{type:"text",text:JSON.stringify(Z,null,2)}]}}catch(W){return{content:[{type:"text",text:`Error: ${W.message}`}],isError:!0}}},K66={name:"read_section",title:"Read Section",description:"Read a section from a document. Returns section content from heading to next same-or-higher level heading (or EOF). Returns { content, lineNumbers: { start, end } }.",schema:yE1,execute:uE1};W6();var mE1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),include_draft:c4.optional().describe("Read draft instead of published")}),BE1=async({core:$,projectId:K},{id:q,include_draft:Y})=>{try{let J=await $.readFrontmatter(K,{id:q,includeDraft:Y});return{content:[{type:"text",text:JSON.stringify(J,null,2)}]}}catch(J){return{content:[{type:"text",text:`Error: ${J.message}`}],isError:!0}}},q66={name:"read_frontmatter",title:"Read Frontmatter",description:"Extract parsed YAML frontmatter from a document. Returns { data: object|null, lineNumbers: { start, end }|null, hasFrontmatter: boolean }.",schema:mE1,execute:BE1};W6();var UE1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),section:A.string().optional().describe("Exact heading text to limit scope (includes nested checklists)"),include_draft:c4.optional().describe("Read draft instead of published")}),pE1=async({core:$,projectId:K},{id:q,section:Y,include_draft:J})=>{try{let z=await $.readChecklist(K,{id:q,section:Y,includeDraft:J});return{content:[{type:"text",text:JSON.stringify(z,null,2)}]}}catch(z){return{content:[{type:"text",text:`Error: ${z.message}`}],isError:!0}}},Y66={name:"read_checklist",title:"Read Checklist",description:"Extract checklist items from a document. Returns array of { text, checked, lineNumber, itemNumber } objects. Supports optional section filtering.",schema:UE1,execute:pE1};W6();var FE1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),lines:A.coerce.number().int().min(1).describe("Number of lines to return"),include_draft:c4.optional().describe("Read draft instead of published")}),cE1=async({core:$,projectId:K},{id:q,lines:Y,include_draft:J})=>{try{let{entity:z}=await $.readDocument(K,{id:q}),W=J?z.getDraftContent?.()??z.getPublishedContent?.()??"":z.getPublishedContent?.()??"",Z=E08(W,Y);return{content:[{type:"text",text:JSON.stringify(Z,null,2)}]}}catch(z){return{content:[{type:"text",text:`Error: ${z.message}`}],isError:!0}}},J66={name:"read_head",title:"Read Head",description:"Read the first N lines from a document. Returns { content, lineNumbers: { start, end }, totalLines }. Convenience wrapper that clamps N to document length.",schema:FE1,execute:cE1};W6();var QE1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),lines:A.coerce.number().int().min(1).describe("Number of lines to return"),include_draft:c4.optional().describe("Read draft instead of published")}),lE1=async({core:$,projectId:K},{id:q,lines:Y,include_draft:J})=>{try{let{entity:z}=await $.readDocument(K,{id:q}),W=J?z.getDraftContent?.()??z.getPublishedContent?.()??"":z.getPublishedContent?.()??"",Z=S08(W,Y);return{content:[{type:"text",text:JSON.stringify(Z,null,2)}]}}catch(z){return{content:[{type:"text",text:`Error: ${z.message}`}],isError:!0}}},z66={name:"read_tail",title:"Read Tail",description:"Read the last N lines from a document. Returns { content, lineNumbers: { start, end }, totalLines }. Convenience wrapper that clamps N to document length.",schema:QE1,execute:lE1};W6();var iE1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),start_line:A.coerce.number().int().min(1).describe("Start line number (1-based)"),include_draft:c4.optional().describe("Read draft instead of published")}),dE1=async({core:$,projectId:K},{id:q,start_line:Y,include_draft:J})=>{try{let{entity:z}=await $.readDocument(K,{id:q}),W=J?z.getDraftContent?.()??z.getPublishedContent?.()??"":z.getPublishedContent?.()??"",Z=L08(W,Y);return{content:[{type:"text",text:JSON.stringify(Z,null,2)}]}}catch(z){return{content:[{type:"text",text:`Error: ${z.message}`}],isError:!0}}},W66={name:"read_from_line",title:"Read From Line",description:"Read from a starting line to the end of a document. Returns { content, lineNumbers: { start, end }, totalLines }. Line numbers are 1-based.",schema:iE1,execute:dE1};W6();var nE1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),end_line:A.coerce.number().int().min(1).describe("End line number (1-based, inclusive)"),include_draft:c4.optional().describe("Read draft instead of published")}),oE1=async({core:$,projectId:K},{id:q,end_line:Y,include_draft:J})=>{try{let{entity:z}=await $.readDocument(K,{id:q}),W=J?z.getDraftContent?.()??z.getPublishedContent?.()??"":z.getPublishedContent?.()??"",Z=I08(W,Y);return{content:[{type:"text",text:JSON.stringify(Z,null,2)}]}}catch(z){return{content:[{type:"text",text:`Error: ${z.message}`}],isError:!0}}},Z66={name:"read_to_line",title:"Read To Line",description:"Read from the beginning to an ending line in a document. Returns { content, lineNumbers: { start, end }, totalLines }. Line numbers are 1-based and inclusive.",schema:nE1,execute:oE1};W6();var aE1=A.object({id:A.string().describe("Document ID to check includes for")}),rE1=async({core:$,projectId:K},{id:q})=>{try{let Y=await $.checkIncludes(K,{id:q});return{content:[{type:"text",text:JSON.stringify({documentId:q,includes:Y,hasOutdated:Y.some((J)=>J.outdated)},null,2)}]}}catch(Y){return{content:[{type:"text",text:`Error: ${Y.message}`}],isError:!0}}},H66={name:"check_includes",title:"Check Includes",description:"Check which includes have newer versions available",schema:aE1,execute:rE1};W6();var sE1=A.object({id:A.string().describe("Document ID to update includes for")}),tE1=async({core:$,projectId:K},{id:q})=>{try{let Y=await $.updateIncludes(K,{id:q});return{content:[{type:"text",text:JSON.stringify({documentId:q,updated:Y.updated,message:Y.updated.length>0?`Updated ${Y.updated.length} include(s). Draft saved.`:"All includes already at latest versions."},null,2)}]}}catch(Y){return{content:[{type:"text",text:`Error: ${Y.message}`}],isError:!0}}},O66={name:"update_includes",title:"Update Includes",description:"Update all includes to latest available versions (creates draft)",schema:sE1,execute:tE1};W6();var eE1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),lineNumber:A.number().int().min(1).describe("Line number of the checklist item (1-based)"),checked:A.boolean().describe("New checked status (true = checked, false = unchecked)"),include_draft:A.boolean().optional().describe("Edit draft content instead of published"),session_id:A.string().optional().describe("Session UUID for edit lock tracking"),preview:A.boolean().optional().describe("If true, return diff without saving")}),$S1=async({core:$,projectId:K,sessionId:q},{id:Y,lineNumber:J,checked:z,include_draft:W,session_id:Z,preview:H})=>{try{if(!H&&!q)throw Error("Session ID required for this operation");let O=H?void 0:q,X=await $.checkChecklistItem(K,{id:Y,lineNumber:J,checked:z,includeDraft:W,sessionId:O,preview:H});return{content:[{type:"text",text:JSON.stringify(X.preview?X:X.item,null,2)}]}}catch(O){return{content:[{type:"text",text:`Error: ${O.message}`}],isError:!0}}},X66={name:"check_checklist_item",title:"Check Checklist Item",description:"Set the checked status of a checklist item by line number.",schema:eE1,execute:$S1};W6();var KS1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),lineNumber:A.number().int().min(1).describe("Line number of the checklist item (1-based)"),include_draft:A.boolean().optional().describe("Edit draft content instead of published"),session_id:A.string().optional().describe("Session UUID for edit lock tracking"),preview:A.boolean().optional().describe("If true, return diff without saving")}),qS1=async({core:$,projectId:K,sessionId:q},{id:Y,lineNumber:J,include_draft:z,session_id:W,preview:Z})=>{try{if(!Z&&!q)throw Error("Session ID required for this operation");let H=Z?void 0:q,O=await $.toggleChecklistItem(K,{id:Y,lineNumber:J,includeDraft:z,sessionId:H,preview:Z});return{content:[{type:"text",text:JSON.stringify(O.preview?O:O.item,null,2)}]}}catch(H){return{content:[{type:"text",text:`Error: ${H.message}`}],isError:!0}}},P66={name:"toggle_checklist_item",title:"Toggle Checklist Item",description:"Toggle the checked status of a checklist item by line number.",schema:KS1,execute:qS1};W6();var YS1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),items:A.array(A.object({lineNumber:A.number().int().min(1).describe("Line number (1-based)"),checked:A.boolean().describe("New checked status")})).min(1).describe("Array of items to update"),include_draft:A.boolean().optional().describe("Edit draft content instead of published"),session_id:A.string().optional().describe("Session UUID for edit lock tracking"),preview:A.boolean().optional().describe("If true, return diff without saving")}),JS1=async({core:$,projectId:K,sessionId:q},{id:Y,items:J,include_draft:z,session_id:W,preview:Z})=>{try{if(!Z&&!q)throw Error("Session ID required for this operation");let H=Z?void 0:q,O=await $.batchCheckChecklistItems(K,{id:Y,items:J,includeDraft:z,sessionId:H,preview:Z});if(O.preview)return{content:[{type:"text",text:JSON.stringify(O,null,2)}]};return{content:[{type:"text",text:JSON.stringify({items:O.items,count:O.count},null,2)}]}}catch(H){return{content:[{type:"text",text:`Error: ${H.message}`}],isError:!0}}},w66={name:"batch_check_checklist_items",title:"Batch Check Checklist Items",description:"Update multiple checklist items in a single call.",schema:YS1,execute:JS1};var T66=[g86,b86,y86,u86,m86,B86,U86,p86,F86,c86,Q86,l86,i86,d86,n86,o86,s86,t86,e86,$66,K66,q66,Y66,J66,z66,W66,Z66,H66,O66,X66,P66,w66];W6();var zS1=A.object({path:A.string().optional().describe("Path for document/file target"),store:A.string().optional().describe("Store code (for full-path mode)"),root:A.string().optional().describe('Root folder ID (e.g., "Af1")'),parentId:A.string().optional().describe("Parent folder ID"),name:A.string().optional().describe("Document name"),publish:A.boolean().optional().describe("Auto-publish document (document target only)"),jobName:A.string().optional().describe("Job name (supports Handlebars)"),jobAgent:A.string().optional().describe("Agent type (claude or codex)"),jobModel:A.string().optional().describe("Model identifier passed to agent"),jobWorktree:A.string().optional().describe("Worktree branch name to match")}),WS1=A.object({id:A.string().describe('Template ID (e.g., "At1")'),params:a86(A.any()).optional().describe("Parameter values as key-value pairs"),target:A.enum(["stdout","clipboard","document","file","job"]).optional().describe("Output target (overrides template frontmatter)"),targetOptions:r86(zS1).optional().describe("Target-specific options")}),ZS1=async({core:$,projectId:K,sessionId:q},{id:Y,params:J,target:z,targetOptions:W})=>{try{let Z=await $.renderTemplate(K,{id:Y,params:J||{},target:z,targetOptions:W,sessionId:q}),H=Z.target;if(H==="stdout")return{content:[{type:"text",text:Z.content}]};else if(H==="clipboard")return{content:[{type:"text",text:"Template rendered to clipboard"}]};else if(H==="document")return{content:[{type:"text",text:`Template rendered to document: ${Z.documentId}`}]};else if(H==="file")return{content:[{type:"text",text:`Template rendered to file: ${Z.path}`}]};else if(H==="job")return{content:[{type:"text",text:`Job created: ${Z.jobId} (${Z.jobName})`}]}}catch(Z){return{content:[{type:"text",text:`Error: ${Z.message}`}],isError:!0}}},G66={name:"render_template",title:"Render Template",description:"Render a template with parameters. Template frontmatter provides defaults for target and targetPath; MCP parameters override when explicitly provided.",schema:WS1,execute:ZS1};W6();var HS1=A.object({id:A.string().describe('Template ID (e.g., "At1")')}),OS1=async({core:$,projectId:K},{id:q})=>{try{let{entity:Y}=await $.readDocument(K,{id:q});if(!Y)return{content:[{type:"text",text:`Template not found: ${q}`}],isError:!0};let J=Y.getPublishedContent();if(!J)return{content:[{type:"text",text:`Template has no published version: ${q}`}],isError:!0};let{parameters:z,target:W,targetPath:Z}=IK.getParameters(J);return{content:[{type:"text",text:JSON.stringify({parameters:z,target:W,targetPath:Z},null,2)}]}}catch(Y){return{content:[{type:"text",text:`Error: ${Y.message}`}],isError:!0}}},j66={name:"get_template_parameters",title:"Get Template Parameters",description:"Get parameter definitions from a published template",schema:HS1,execute:OS1};W6();var XS1=A.object({typeCode:A.string().describe('Entity type code to match (e.g., "s" for stories)')}),PS1=async({core:$,projectId:K},{typeCode:q})=>{try{let Y=await $.listTemplatesByType(K,{typeCode:q});return{content:[{type:"text",text:JSON.stringify(Y,null,2)}]}}catch(Y){return{content:[{type:"text",text:`Error: ${Y.message}`}],isError:!0}}},v66={name:"list_templates_by_type",title:"List Templates by Type",description:"List templates associated with a given entity type code",schema:XS1,execute:PS1};var V66=[G66,j66,v66];W6();var wS1=A.object({path:A.string().optional().describe('Full path from tree root (e.g., "Documents/specs/api-v2") or relative path from root'),store:A.string().optional().describe("Store code (required for full path mode)"),root:A.string().optional().describe('Root folder ID (e.g., "Af1")'),parentId:A.string().optional().describe("Parent folder ID"),name:A.string().optional().describe("Folder name")}),TS1=async({core:$,projectId:K},q)=>{try{let Y;if("store"in q&&!("root"in q)&&!("parentId"in q))Y=await $.createFolder(K,{mode:"fullPath",path:q.path,store:q.store});else if("root"in q)Y=await $.createFolder(K,{mode:"rootRelative",root:q.root,path:q.path});else Y=await $.createFolder(K,{mode:"parentName",parentId:q.parentId,name:q.name});return{content:[{type:"text",text:`Created folder: ${Y.getObjectId()} (path: ${Y.getPath()})`}]}}catch(Y){return{content:[{type:"text",text:`Error: ${Y.message}`}],isError:!0}}},A66={name:"create_folder",title:"Create Folder",description:"Create a new folder. Supports three creation modes: full path (path+store), root+relative (root+path), or parent+name (parentId+name).",schema:wS1,execute:TS1};W6();var GS1=A.object({id:A.string().describe('Folder ID (e.g., "Af2") or Story ID (e.g., "As1")')}),jS1=async({core:$,projectId:K},{id:q})=>{try{let Y=await $.getFolder(K,{id:q});if(!Y)return{content:[{type:"text",text:`Folder not found: ${q}`}],isError:!0};let J;if(Y.isStory?.()){let z=Y.toJSON();J={id:z.id,parentId:z.parentId,name:z.name,path:z.path,isRoot:!1,isStory:!0,isFolder:!1,type:"s",fields:z.fields,createdAt:z.createdAt,updatedAt:z.updatedAt}}else J={id:Y.getObjectId(),parentId:Y.getParentId(),name:Y.getName(),path:Y.getPath(),isRoot:Y.isRoot(),createdAt:Y.getCreatedAt(),updatedAt:Y.getUpdatedAt()};return{content:[{type:"text",text:JSON.stringify(J,null,2)}]}}catch(Y){return{content:[{type:"text",text:`Error: ${Y.message}`}],isError:!0}}},M66={name:"get_folder",title:"Get Folder",description:"Get folder information by ID",schema:GS1,execute:jS1};W6();var vS1=A.object({path:A.string().describe('Folder path (e.g., "docs/specs") or empty for root'),store:A.string().optional().describe('Store code (default: "A")'),type:A.enum(["d","t","s"]).describe('Folder tree: "d" (documents), "t" (templates), "s" (stories) - REQUIRED')}),VS1=async({core:$,projectId:K},{path:q,store:Y,type:J})=>{try{let z=await $.getFolderByPath(K,{store:Y||"A",path:q,type:J});if(!z)return{content:[{type:"text",text:`Folder not found: ${q}`}],isError:!0};let W;if(z.isStory?.()){let Z=z.toJSON();W={id:Z.id,parentId:Z.parentId,name:Z.name,path:Z.path,isRoot:!1,isStory:!0,isFolder:!1,type:"s",fields:Z.fields,createdAt:Z.createdAt,updatedAt:Z.updatedAt}}else W={id:z.getObjectId(),parentId:z.getParentId(),name:z.getName(),path:z.getPath(),isRoot:z.isRoot(),createdAt:z.getCreatedAt(),updatedAt:z.getUpdatedAt()};return{content:[{type:"text",text:JSON.stringify(W,null,2)}]}}catch(z){return{content:[{type:"text",text:`Error: ${z.message}`}],isError:!0}}},_66={name:"get_folder_by_path",title:"Get Folder By Path",description:'Get folder information by type and path. Use type="d" for documents, type="t" for templates, type="s" for stories.',schema:vS1,execute:VS1};W6();var AS1=A.object({id:A.string().nullable().optional().describe('Folder ID (e.g., "Af2"), or omit for root folder'),store:A.string().optional().describe('Store code for root folder (default: "A")'),type:A.string().optional().describe('Document type code (e.g., "d" for document, "t" for template). Required for root folder listing. Default: "d"')}),MS1=async({core:$,projectId:K},{id:q,store:Y,type:J})=>{try{let z=await $.listFolderContents(K,{folderId:q??null,store:Y||"A",type:q?J:J||"d"}),W={folders:z.folders.map((Z)=>({id:Z.getObjectId(),parentId:Z.getParentId(),name:Z.getName(),path:Z.getPath(),isRoot:Z.isRoot?.()??!1})),documents:z.documents.map((Z)=>({id:Z.getObjectId(),path:Z.getPath(),type:Z.getTypeCode(),subtype:Z.getSubtype(),hasPublished:Z.hasPublished(),hasDraft:Z.hasDraftContent()}))};return{content:[{type:"text",text:JSON.stringify(W,null,2)}]}}catch(z){return{content:[{type:"text",text:`Error: ${z.message}`}],isError:!0}}},k66={name:"list_folder_contents",title:"List Folder Contents",description:"List contents of a folder (subfolders and documents)",schema:AS1,execute:MS1};W6();var _S1=A.object({id:A.string().describe('Folder ID (e.g., "Af2")'),name:A.string().describe("New folder name")}),kS1=async({core:$,projectId:K},{id:q,name:Y})=>{try{let J=await $.renameFolder(K,{id:q,name:Y});return{content:[{type:"text",text:`Renamed folder: ${J.getObjectId()} (new path: ${J.getPath()})`}]}}catch(J){return{content:[{type:"text",text:`Error: ${J.message}`}],isError:!0}}},f66={name:"rename_folder",title:"Rename Folder",description:"Rename a folder",schema:_S1,execute:kS1};W6();var fS1=A.object({id:A.string().describe('Folder ID to move (e.g., "Af3")'),newParentId:A.string().describe('Target parent folder ID (e.g., "Af2")')}),NS1=async({core:$,projectId:K},{id:q,newParentId:Y})=>{try{let J=await $.moveFolder(K,{id:q,parentId:Y});return{content:[{type:"text",text:`Moved folder: ${J.getObjectId()} (new path: ${J.getPath()})`}]}}catch(J){return{content:[{type:"text",text:`Error: ${J.message}`}],isError:!0}}},N66={name:"move_folder",title:"Move Folder",description:"Move a folder to a new parent folder",schema:fS1,execute:NS1};W6();var RS1=A.object({id:A.string().describe('Folder ID (e.g., "Af2")')}),CS1=async({core:$,projectId:K},{id:q})=>{try{return await $.deleteFolder(K,{id:q}),{content:[{type:"text",text:`Deleted folder: ${q}`}]}}catch(Y){return{content:[{type:"text",text:`Error: ${Y.message}`}],isError:!0}}},R66={name:"delete_folder",title:"Delete Folder",description:"Soft delete a folder and all its contents (can be restored later)",schema:RS1,execute:CS1};var C66=[A66,M66,_66,k66,f66,N66,R66];W6();var DS1=A.object({ownerEntityId:A.string().optional().describe('Owner entity ID (e.g., "Ad1" for template). Omit for global/system fields.'),ownerEntityTypeCode:A.string().optional().describe('Entity type code for type-scoped definition (e.g., "d"). Mutually exclusive with ownerEntityId.'),ownerEntityTypeSubtype:A.string().optional().describe('Entity subtype for type-scoped definition (e.g., "task"). Used with ownerEntityTypeCode.'),name:A.string().describe("Field name (alphanumeric + underscores)"),primitiveType:A.enum(["string","object_ref"]).describe("Primitive type"),label:A.string().optional().describe("UI label"),description:A.string().optional().describe("Help text"),required:A.boolean().optional().describe("Whether field is required"),multiplicity:A.enum(["single","multi"]).optional().describe("Single or multi-valued"),isSystem:A.boolean().optional().describe("System/global field"),store:A.string().optional().describe('Store code (default: "A" for project store)')}),hS1=async({core:$,projectId:K},{ownerEntityId:q,ownerEntityTypeCode:Y,ownerEntityTypeSubtype:J,name:z,primitiveType:W,label:Z,description:H,required:O,multiplicity:X,isSystem:P,store:w})=>{try{let T=await $.createFieldDefinition(K,{store:w||"A",ownerEntityId:q,ownerEntityTypeCode:Y,ownerEntityTypeSubtype:J,name:z,label:Z,description:H,primitiveType:W,required:O,multiplicity:X,isSystem:P});return{content:[{type:"text",text:`Field definition created: ${T.name} (id: ${T.id}, type: ${T.primitiveType})`}]}}catch(T){return{content:[{type:"text",text:`Error: ${T.message}`}],isError:!0}}},D66={name:"create_field_definition",title:"Create Field Definition",description:"Create a field definition on an owner entity (template/workflow)",schema:DS1,execute:hS1};W6();var ES1=A.object({ownerEntityId:A.string().optional().describe("Owner entity ID. Omit for global/system fields."),includeSystem:A.boolean().optional().describe("Include system fields"),store:A.string().optional().describe('Store code (default: "A" for project store)')}),SS1=async({core:$,projectId:K},{ownerEntityId:q,includeSystem:Y,store:J})=>{try{let z=await $.getFieldDefinitions(K,{store:J||"A",ownerEntityId:q||null,includeSystem:Y});if(z.length===0)return{content:[{type:"text",text:"No field definitions found"}]};return{content:[{type:"text",text:JSON.stringify(z,null,2)}]}}catch(z){return{content:[{type:"text",text:`Error: ${z.message}`}],isError:!0}}},h66={name:"get_field_definitions",title:"Get Field Definitions",description:"Get all field definitions for an owner entity",schema:ES1,execute:SS1};W6();var LS1=A.object({code:A.string().describe('Entity type code (e.g., "d" for document)'),subtype:A.string().describe('Entity subtype (e.g., "task")'),store:A.string().optional().describe('Store code (default: "A")')}),IS1=async({core:$,projectId:K},{code:q,subtype:Y,store:J})=>{try{let z=await $.getTypeFields(K,{store:J||"A",code:q,subtype:Y});if(z.length===0)return{content:[{type:"text",text:"No field definitions found for this entity type"}]};return{content:[{type:"text",text:JSON.stringify(z,null,2)}]}}catch(z){return{content:[{type:"text",text:`Error: ${z.message}`}],isError:!0}}},E66={name:"get_type_fields",title:"Get Type Fields",description:"Get field definitions for an entity type/subtype combination",schema:LS1,execute:IS1};W6();var xS1=A.object({id:A.string().describe('Field definition ID (e.g., "An1")')}),gS1=async({core:$,projectId:K},{id:q})=>{try{return{content:[{type:"text",text:`Field definition deleted: ${(await $.deleteFieldDefinition(K,{id:q})).name}`}]}}catch(Y){return{content:[{type:"text",text:`Error: ${Y.message}`}],isError:!0}}},S66={name:"delete_field_definition",title:"Delete Field Definition",description:"Delete a field definition (cascades to values)",schema:xS1,execute:gS1};W6();var bS1=A.object({id:A.string().describe('Entity ID (e.g., "Ad1")')}),yS1=async({core:$,projectId:K},{id:q})=>{try{let Y=await $.getFields(K,{entityId:q});if(!Y||Object.keys(Y).length===0)return{content:[{type:"text",text:"No fields set"}]};return{content:[{type:"text",text:JSON.stringify(Y,null,2)}]}}catch(Y){return{content:[{type:"text",text:`Error: ${Y.message}`}],isError:!0}}},L66={name:"get_fields",title:"Get Fields",description:"Get all field values for an entity as an object",schema:bS1,execute:yS1};W6();var uS1=A.object({id:A.string().describe('Entity ID (e.g., "Ad1")'),fieldDefinitionId:A.string().optional().describe('Field definition ID (e.g., "An1")'),fieldName:A.string().optional().describe("Field name for auto-resolution"),value:A.string().optional().describe("Single value"),values:A.array(A.string()).optional().describe("Array of values (for multi-valued)")}),mS1=async({core:$,projectId:K},{id:q,fieldDefinitionId:Y,fieldName:J,value:z,values:W})=>{try{if(z===void 0&&W===void 0)return{content:[{type:"text",text:"Error: Either value or values is required"}],isError:!0};let Z=await $.setField(K,{entityId:q,fieldDefinitionId:Y,fieldName:J,value:z,values:W}),H=J||Y,O=W!==void 0?`[${W.join(", ")}]`:z;return{content:[{type:"text",text:`Field set: ${H} = ${O}`}]}}catch(Z){return{content:[{type:"text",text:`Error: ${Z.message}`}],isError:!0}}},I66={name:"set_field",title:"Set Field",description:"Set a field value (single-valued or multi-valued)",schema:uS1,execute:mS1};W6();var BS1=A.object({id:A.string().describe('Entity ID (e.g., "Ad1")'),fieldDefinitionId:A.string().optional().describe('Field definition ID (e.g., "An1")'),fieldName:A.string().optional().describe("Field name for auto-resolution")}),US1=async({core:$,projectId:K},{id:q,fieldDefinitionId:Y,fieldName:J})=>{try{return{content:[{type:"text",text:`Field deleted: ${(await $.deleteField(K,{entityId:q,fieldDefinitionId:Y,fieldName:J})).name}`}]}}catch(z){return{content:[{type:"text",text:`Error: ${z.message}`}],isError:!0}}},x66={name:"delete_field",title:"Delete Field",description:"Remove a field from an entity",schema:BS1,execute:US1};var g66=[D66,h66,E66,S66,L66,I66,x66];W6();var pS1=A.object({}),FS1=async({core:$,projectId:K})=>{try{let q=await $.listExports(K);if(q.length===0)return{content:[{type:"text",text:"No exports found."}]};let Y=["Available exports:",""];for(let J of q)Y.push(`• ${J.filename} (${J.size} bytes)`);return{content:[{type:"text",text:Y.join(`
|
|
657
|
+
Use preview=true to see what changes would be made without saving.`,schema:CE1,execute:DE1};W6();W6();var c4=A.preprocess(($)=>$==="true"?!0:$==="false"?!1:$,A.boolean()),a86=($=A.any())=>A.preprocess((K)=>{if(typeof K==="string")try{return JSON.parse(K)}catch{return K}return K},A.record($)),r86=($)=>A.preprocess((K)=>{if(typeof K==="string")try{return JSON.parse(K)}catch{return K}return K},$);var hE1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),start_line:A.coerce.number().int().min(1).describe("Start line number (1-based)"),end_line:A.coerce.number().int().min(1).describe("End line number (1-based, inclusive)"),include_draft:c4.optional().describe("Read draft instead of published")}),EE1=async({core:$,projectId:K},{id:q,start_line:Y,end_line:J,include_draft:z})=>{try{let W=await $.readLines(K,{id:q,startLine:Y,endLine:J,includeDraft:z}),Z={content:W.content,lineNumbers:W.lineNumbers,totalLines:W.totalLines};return{content:[{type:"text",text:JSON.stringify(Z,null,2)}]}}catch(W){return{content:[{type:"text",text:`Error: ${W.message}`}],isError:!0}}},s86={name:"read_lines",title:"Read Lines",description:"Read specific lines from a document. Returns content with line numbers in format { content, lineNumbers: { start, end }, totalLines }. Line numbers are 1-based and inclusive.",schema:hE1,execute:EE1};W6();var SE1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),start_marker:A.string().describe("String marking the start"),end_marker:A.string().describe("String marking the end"),inclusive:c4.optional().default(!1).describe("Include markers in output"),include_draft:c4.optional().describe("Read draft instead of published")}),LE1=async({core:$,projectId:K},{id:q,start_marker:Y,end_marker:J,inclusive:z,include_draft:W})=>{try{let Z=await $.readBetweenMarkers(K,{id:q,startMarker:Y,endMarker:J,inclusive:z,includeDraft:W}),H={content:Z.content,lineNumbers:Z.lineNumbers};return{content:[{type:"text",text:JSON.stringify(H,null,2)}]}}catch(Z){return{content:[{type:"text",text:`Error: ${Z.message}`}],isError:!0}}},t86={name:"read_between_markers",title:"Read Between Markers",description:"Read content between markers from a document. Returns content with line numbers in format { content, lineNumbers: { start, end } }.",schema:SE1,execute:LE1};W6();var IE1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),include_draft:c4.optional().describe("Read draft instead of published")}),xE1=async({core:$,projectId:K},{id:q,include_draft:Y})=>{try{let J=await $.getDocumentStats(K,{id:q,includeDraft:Y}),z={lines:J.lines,words:J.words,chars:J.chars,headings:J.headings,checklists:J.checklists,hasFrontmatter:J.hasFrontmatter};return{content:[{type:"text",text:JSON.stringify(z,null,2)}]}}catch(J){return{content:[{type:"text",text:`Error: ${J.message}`}],isError:!0}}},e86={name:"get_document_stats",title:"Get Document Stats",description:"Get document statistics without transferring content. Returns { lines, words, chars, headings: { h1...h6 }, checklists: { checked, unchecked }, hasFrontmatter }.",schema:IE1,execute:xE1};W6();var gE1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),max_depth:A.coerce.number().int().min(1).max(6).optional().describe("Maximum heading level to include (1-6)"),include_draft:c4.optional().describe("Read draft instead of published")}),bE1=async({core:$,projectId:K},{id:q,max_depth:Y,include_draft:J})=>{try{let z=await $.readHeadings(K,{id:q,maxDepth:Y,includeDraft:J});return{content:[{type:"text",text:JSON.stringify(z,null,2)}]}}catch(z){return{content:[{type:"text",text:`Error: ${z.message}`}],isError:!0}}},$66={name:"read_headings",title:"Read Headings",description:"Extract heading structure from a document. Returns array of { level, text, lineNumber } objects. Ignores headings inside fenced code blocks.",schema:gE1,execute:bE1};W6();var yE1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),heading:A.union([A.string(),A.coerce.number()]).describe("Heading text or line number (1-based)"),include_heading:c4.optional().default(!0).describe("Include the heading line in output"),include_draft:c4.optional().describe("Read draft instead of published")}),uE1=async({core:$,projectId:K},{id:q,heading:Y,include_heading:J,include_draft:z})=>{try{let W=await $.readSection(K,{id:q,heading:Y,includeHeading:J,includeDraft:z}),Z={content:W.content,lineNumbers:W.lineNumbers};return{content:[{type:"text",text:JSON.stringify(Z,null,2)}]}}catch(W){return{content:[{type:"text",text:`Error: ${W.message}`}],isError:!0}}},K66={name:"read_section",title:"Read Section",description:"Read a section from a document. Returns section content from heading to next same-or-higher level heading (or EOF). Returns { content, lineNumbers: { start, end } }.",schema:yE1,execute:uE1};W6();var mE1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),include_draft:c4.optional().describe("Read draft instead of published")}),BE1=async({core:$,projectId:K},{id:q,include_draft:Y})=>{try{let J=await $.readFrontmatter(K,{id:q,includeDraft:Y});return{content:[{type:"text",text:JSON.stringify(J,null,2)}]}}catch(J){return{content:[{type:"text",text:`Error: ${J.message}`}],isError:!0}}},q66={name:"read_frontmatter",title:"Read Frontmatter",description:"Extract parsed YAML frontmatter from a document. Returns { data: object|null, lineNumbers: { start, end }|null, hasFrontmatter: boolean }.",schema:mE1,execute:BE1};W6();var UE1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),section:A.string().optional().describe("Exact heading text to limit scope (includes nested checklists)"),include_draft:c4.optional().describe("Read draft instead of published")}),pE1=async({core:$,projectId:K},{id:q,section:Y,include_draft:J})=>{try{let z=await $.readChecklist(K,{id:q,section:Y,includeDraft:J});return{content:[{type:"text",text:JSON.stringify(z,null,2)}]}}catch(z){return{content:[{type:"text",text:`Error: ${z.message}`}],isError:!0}}},Y66={name:"read_checklist",title:"Read Checklist",description:"Extract checklist items from a document. Returns array of { text, checked, lineNumber, itemNumber } objects. Supports optional section filtering.",schema:UE1,execute:pE1};W6();var FE1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),lines:A.coerce.number().int().min(1).describe("Number of lines to return"),include_draft:c4.optional().describe("Read draft instead of published")}),cE1=async({core:$,projectId:K},{id:q,lines:Y,include_draft:J})=>{try{let{entity:z}=await $.readDocument(K,{id:q}),W=J?z.getDraftContent?.()??z.getPublishedContent?.()??"":z.getPublishedContent?.()??"",Z=E08(W,Y);return{content:[{type:"text",text:JSON.stringify(Z,null,2)}]}}catch(z){return{content:[{type:"text",text:`Error: ${z.message}`}],isError:!0}}},J66={name:"read_head",title:"Read Head",description:"Read the first N lines from a document. Returns { content, lineNumbers: { start, end }, totalLines }. Convenience wrapper that clamps N to document length.",schema:FE1,execute:cE1};W6();var QE1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),lines:A.coerce.number().int().min(1).describe("Number of lines to return"),include_draft:c4.optional().describe("Read draft instead of published")}),lE1=async({core:$,projectId:K},{id:q,lines:Y,include_draft:J})=>{try{let{entity:z}=await $.readDocument(K,{id:q}),W=J?z.getDraftContent?.()??z.getPublishedContent?.()??"":z.getPublishedContent?.()??"",Z=S08(W,Y);return{content:[{type:"text",text:JSON.stringify(Z,null,2)}]}}catch(z){return{content:[{type:"text",text:`Error: ${z.message}`}],isError:!0}}},z66={name:"read_tail",title:"Read Tail",description:"Read the last N lines from a document. Returns { content, lineNumbers: { start, end }, totalLines }. Convenience wrapper that clamps N to document length.",schema:QE1,execute:lE1};W6();var iE1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),start_line:A.coerce.number().int().min(1).describe("Start line number (1-based)"),include_draft:c4.optional().describe("Read draft instead of published")}),dE1=async({core:$,projectId:K},{id:q,start_line:Y,include_draft:J})=>{try{let{entity:z}=await $.readDocument(K,{id:q}),W=J?z.getDraftContent?.()??z.getPublishedContent?.()??"":z.getPublishedContent?.()??"",Z=L08(W,Y);return{content:[{type:"text",text:JSON.stringify(Z,null,2)}]}}catch(z){return{content:[{type:"text",text:`Error: ${z.message}`}],isError:!0}}},W66={name:"read_from_line",title:"Read From Line",description:"Read from a starting line to the end of a document. Returns { content, lineNumbers: { start, end }, totalLines }. Line numbers are 1-based.",schema:iE1,execute:dE1};W6();var nE1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),end_line:A.coerce.number().int().min(1).describe("End line number (1-based, inclusive)"),include_draft:c4.optional().describe("Read draft instead of published")}),oE1=async({core:$,projectId:K},{id:q,end_line:Y,include_draft:J})=>{try{let{entity:z}=await $.readDocument(K,{id:q}),W=J?z.getDraftContent?.()??z.getPublishedContent?.()??"":z.getPublishedContent?.()??"",Z=I08(W,Y);return{content:[{type:"text",text:JSON.stringify(Z,null,2)}]}}catch(z){return{content:[{type:"text",text:`Error: ${z.message}`}],isError:!0}}},Z66={name:"read_to_line",title:"Read To Line",description:"Read from the beginning to an ending line in a document. Returns { content, lineNumbers: { start, end }, totalLines }. Line numbers are 1-based and inclusive.",schema:nE1,execute:oE1};W6();var aE1=A.object({id:A.string().describe("Document ID to check includes for")}),rE1=async({core:$,projectId:K},{id:q})=>{try{let Y=await $.checkIncludes(K,{id:q});return{content:[{type:"text",text:JSON.stringify({documentId:q,includes:Y,hasOutdated:Y.some((J)=>J.outdated)},null,2)}]}}catch(Y){return{content:[{type:"text",text:`Error: ${Y.message}`}],isError:!0}}},H66={name:"check_includes",title:"Check Includes",description:"Check which includes have newer versions available",schema:aE1,execute:rE1};W6();var sE1=A.object({id:A.string().describe("Document ID to update includes for")}),tE1=async({core:$,projectId:K},{id:q})=>{try{let Y=await $.updateIncludes(K,{id:q});return{content:[{type:"text",text:JSON.stringify({documentId:q,updated:Y.updated,message:Y.updated.length>0?`Updated ${Y.updated.length} include(s). Draft saved.`:"All includes already at latest versions."},null,2)}]}}catch(Y){return{content:[{type:"text",text:`Error: ${Y.message}`}],isError:!0}}},O66={name:"update_includes",title:"Update Includes",description:"Update all includes to latest available versions (creates draft)",schema:sE1,execute:tE1};W6();var eE1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),lineNumber:A.number().int().min(1).describe("Line number of the checklist item (1-based)"),checked:A.boolean().describe("New checked status (true = checked, false = unchecked)"),include_draft:A.boolean().optional().describe("Edit draft content instead of published"),session_id:A.string().optional().describe("Session UUID for edit lock tracking"),preview:A.boolean().optional().describe("If true, return diff without saving")}),$S1=async({core:$,projectId:K,sessionId:q},{id:Y,lineNumber:J,checked:z,include_draft:W,session_id:Z,preview:H})=>{try{if(!H&&!q)throw Error("Session ID required for this operation");let O=H?void 0:q,X=await $.checkChecklistItem(K,{id:Y,lineNumber:J,checked:z,includeDraft:W,sessionId:O,preview:H});return{content:[{type:"text",text:JSON.stringify(X.preview?X:X.item,null,2)}]}}catch(O){return{content:[{type:"text",text:`Error: ${O.message}`}],isError:!0}}},X66={name:"check_checklist_item",title:"Check Checklist Item",description:"Set the checked status of a checklist item by line number.",schema:eE1,execute:$S1};W6();var KS1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),lineNumber:A.number().int().min(1).describe("Line number of the checklist item (1-based)"),include_draft:A.boolean().optional().describe("Edit draft content instead of published"),session_id:A.string().optional().describe("Session UUID for edit lock tracking"),preview:A.boolean().optional().describe("If true, return diff without saving")}),qS1=async({core:$,projectId:K,sessionId:q},{id:Y,lineNumber:J,include_draft:z,session_id:W,preview:Z})=>{try{if(!Z&&!q)throw Error("Session ID required for this operation");let H=Z?void 0:q,O=await $.toggleChecklistItem(K,{id:Y,lineNumber:J,includeDraft:z,sessionId:H,preview:Z});return{content:[{type:"text",text:JSON.stringify(O.preview?O:O.item,null,2)}]}}catch(H){return{content:[{type:"text",text:`Error: ${H.message}`}],isError:!0}}},P66={name:"toggle_checklist_item",title:"Toggle Checklist Item",description:"Toggle the checked status of a checklist item by line number.",schema:KS1,execute:qS1};W6();var YS1=A.object({id:A.string().describe('Document ID (e.g., "Ad1") or Template ID (e.g., "At1")'),items:A.array(A.object({lineNumber:A.number().int().min(1).describe("Line number (1-based)"),checked:A.boolean().describe("New checked status")})).min(1).describe("Array of items to update"),include_draft:A.boolean().optional().describe("Edit draft content instead of published"),session_id:A.string().optional().describe("Session UUID for edit lock tracking"),preview:A.boolean().optional().describe("If true, return diff without saving")}),JS1=async({core:$,projectId:K,sessionId:q},{id:Y,items:J,include_draft:z,session_id:W,preview:Z})=>{try{if(!Z&&!q)throw Error("Session ID required for this operation");let H=Z?void 0:q,O=await $.batchCheckChecklistItems(K,{id:Y,items:J,includeDraft:z,sessionId:H,preview:Z});if(O.preview)return{content:[{type:"text",text:JSON.stringify(O,null,2)}]};return{content:[{type:"text",text:JSON.stringify({items:O.items,count:O.count},null,2)}]}}catch(H){return{content:[{type:"text",text:`Error: ${H.message}`}],isError:!0}}},w66={name:"batch_check_checklist_items",title:"Batch Check Checklist Items",description:"Update multiple checklist items in a single call.",schema:YS1,execute:JS1};var T66=[g86,b86,y86,u86,m86,B86,U86,p86,F86,c86,Q86,l86,i86,d86,n86,o86,s86,t86,e86,$66,K66,q66,Y66,J66,z66,W66,Z66,H66,O66,X66,P66,w66];W6();var zS1=A.object({path:A.string().optional().describe("Path for document/file target"),store:A.string().optional().describe("Store code (for full-path mode)"),root:A.string().optional().describe('Root folder ID (e.g., "Af1")'),parentId:A.string().optional().describe("Parent folder ID"),name:A.string().optional().describe("Document name"),publish:A.boolean().optional().describe("Auto-publish document (document target only)"),jobName:A.string().optional().describe("Job name (supports Handlebars)"),jobAgent:A.string().optional().describe("Agent type (claude or codex)"),jobModel:A.string().optional().describe("Model identifier passed to agent"),jobWorktree:A.string().optional().describe("Worktree branch name to match")}),WS1=A.object({id:A.string().describe('Template ID (e.g., "At1")'),params:a86(A.any()).optional().describe("Parameter values as key-value pairs"),target:A.enum(["stdout","clipboard","document","file","job"]).optional().describe("Output target (overrides template frontmatter)"),targetOptions:r86(zS1).optional().describe("Target-specific options")}),ZS1=async({core:$,projectId:K,sessionId:q},{id:Y,params:J,target:z,targetOptions:W})=>{try{let Z=await $.renderTemplate(K,{id:Y,params:J||{},target:z,targetOptions:W,sessionId:q}),H=Z.target;if(H==="stdout")return{content:[{type:"text",text:Z.content}]};else if(H==="clipboard")return{content:[{type:"text",text:"Template rendered to clipboard"}]};else if(H==="document")return{content:[{type:"text",text:`Template rendered to document: ${Z.documentId}`}]};else if(H==="file")return{content:[{type:"text",text:`Template rendered to file: ${Z.path}`}]};else if(H==="job")return{content:[{type:"text",text:`Job created: ${Z.jobId} (${Z.jobName})`}]}}catch(Z){return{content:[{type:"text",text:`Error: ${Z.message}`}],isError:!0}}},G66={name:"render_template",title:"Render Template",description:"Render a template with parameters. Template frontmatter provides defaults for target and targetPath; MCP parameters override when explicitly provided.",schema:WS1,execute:ZS1};W6();var HS1=A.object({id:A.string().describe('Template ID (e.g., "At1")')}),OS1=async({core:$,projectId:K},{id:q})=>{try{let{entity:Y}=await $.readDocument(K,{id:q});if(!Y)return{content:[{type:"text",text:`Template not found: ${q}`}],isError:!0};let J=Y.getPublishedContent();if(!J)return{content:[{type:"text",text:`Template has no published version: ${q}`}],isError:!0};let{parameters:z,target:W,targetPath:Z}=IK.getParameters(J);return{content:[{type:"text",text:JSON.stringify({parameters:z,target:W,targetPath:Z},null,2)}]}}catch(Y){return{content:[{type:"text",text:`Error: ${Y.message}`}],isError:!0}}},j66={name:"get_template_parameters",title:"Get Template Parameters",description:"Get parameter definitions from a published template",schema:HS1,execute:OS1};W6();var XS1=A.object({typeCode:A.string().describe('Entity type code to match (e.g., "s" for stories)')}),PS1=async({core:$,projectId:K},{typeCode:q})=>{try{let Y=await $.listTemplatesByType(K,{typeCode:q});return{content:[{type:"text",text:JSON.stringify(Y,null,2)}]}}catch(Y){return{content:[{type:"text",text:`Error: ${Y.message}`}],isError:!0}}},v66={name:"list_templates_by_type",title:"List Templates by Type",description:"List templates associated with a given entity type code",schema:XS1,execute:PS1};var V66=[G66,j66,v66];W6();var wS1=A.object({path:A.string().optional().describe('Full path from tree root (e.g., "Documents/specs/api-v2") or relative path from root'),store:A.string().optional().describe("Store code (required for full path mode)"),root:A.string().optional().describe('Root folder ID (e.g., "Af1")'),parentId:A.string().optional().describe("Parent folder ID"),name:A.string().optional().describe("Folder name")}),TS1=async({core:$,projectId:K},q)=>{try{let Y;if("store"in q&&!("root"in q)&&!("parentId"in q))Y=await $.createFolder(K,{mode:"fullPath",path:q.path,store:q.store});else if("root"in q)Y=await $.createFolder(K,{mode:"rootRelative",root:q.root,path:q.path});else Y=await $.createFolder(K,{mode:"parentName",parentId:q.parentId,name:q.name});return{content:[{type:"text",text:`Created folder: ${Y.getObjectId()} (path: ${Y.getPath()})`}]}}catch(Y){return{content:[{type:"text",text:`Error: ${Y.message}`}],isError:!0}}},A66={name:"create_folder",title:"Create Folder",description:"Create a new folder. Supports three creation modes: full path (path+store), root+relative (root+path), or parent+name (parentId+name).",schema:wS1,execute:TS1};W6();var GS1=A.object({id:A.string().describe('Folder ID (e.g., "Af2") or Story ID (e.g., "As1")')}),jS1=async({core:$,projectId:K},{id:q})=>{try{let Y=await $.getFolder(K,{id:q});if(!Y)return{content:[{type:"text",text:`Folder not found: ${q}`}],isError:!0};let J;if(Y.isStory?.()){let z=Y.toJSON();J={id:z.id,parentId:z.parentId,name:z.name,path:z.path,isRoot:!1,isStory:!0,isFolder:!1,type:"s",fields:z.fields,createdAt:z.createdAt,updatedAt:z.updatedAt}}else J={id:Y.getObjectId(),parentId:Y.getParentId(),name:Y.getName(),path:Y.getPath(),isRoot:Y.isRoot(),createdAt:Y.getCreatedAt(),updatedAt:Y.getUpdatedAt()};return{content:[{type:"text",text:JSON.stringify(J,null,2)}]}}catch(Y){return{content:[{type:"text",text:`Error: ${Y.message}`}],isError:!0}}},M66={name:"get_folder",title:"Get Folder",description:"Get folder information by ID",schema:GS1,execute:jS1};W6();var vS1=A.object({path:A.string().describe('Folder path (e.g., "docs/specs") or empty for root'),store:A.string().optional().describe('Store code (default: "A")'),type:A.enum(["d","t","s"]).describe('Folder tree: "d" (documents), "t" (templates), "s" (stories) - REQUIRED')}),VS1=async({core:$,projectId:K},{path:q,store:Y,type:J})=>{try{let z=await $.getFolderByPath(K,{store:Y||"A",path:q,type:J});if(!z)return{content:[{type:"text",text:`Folder not found: ${q}`}],isError:!0};let W;if(z.isStory?.()){let Z=z.toJSON();W={id:Z.id,parentId:Z.parentId,name:Z.name,path:Z.path,isRoot:!1,isStory:!0,isFolder:!1,type:"s",fields:Z.fields,createdAt:Z.createdAt,updatedAt:Z.updatedAt}}else W={id:z.getObjectId(),parentId:z.getParentId(),name:z.getName(),path:z.getPath(),isRoot:z.isRoot(),createdAt:z.getCreatedAt(),updatedAt:z.getUpdatedAt()};return{content:[{type:"text",text:JSON.stringify(W,null,2)}]}}catch(z){return{content:[{type:"text",text:`Error: ${z.message}`}],isError:!0}}},_66={name:"get_folder_by_path",title:"Get Folder By Path",description:'Get folder information by type and path. Use type="d" for documents, type="t" for templates, type="s" for stories.',schema:vS1,execute:VS1};W6();var AS1=A.object({id:A.string().nullable().optional().describe('Folder ID (e.g., "Af2"), or omit for root folder'),store:A.string().optional().describe('Store code for root folder (default: "A")'),type:A.string().optional().describe('Document type code (e.g., "d" for document, "t" for template). Required for root folder listing. Default: "d"')}),MS1=async({core:$,projectId:K},{id:q,store:Y,type:J})=>{try{let z=await $.listFolderContents(K,{folderId:q??null,store:Y||"A",type:q?J:J||"d"}),W={folders:z.folders.map((Z)=>({id:Z.getObjectId(),parentId:Z.getParentId(),name:Z.getName(),path:Z.getPath(),isRoot:Z.isRoot?.()??!1})),documents:z.documents.map((Z)=>({id:Z.getObjectId(),path:Z.getPath(),type:Z.getTypeCode(),subtype:Z.getSubtype(),hasPublished:Z.hasPublished(),hasDraft:Z.hasDraftContent()}))};return{content:[{type:"text",text:JSON.stringify(W,null,2)}]}}catch(z){return{content:[{type:"text",text:`Error: ${z.message}`}],isError:!0}}},k66={name:"list_folder_contents",title:"List Folder Contents",description:"List contents of a folder (subfolders and documents)",schema:AS1,execute:MS1};W6();var _S1=A.object({id:A.string().describe('Folder ID (e.g., "Af2")'),name:A.string().describe("New folder name")}),kS1=async({core:$,projectId:K},{id:q,name:Y})=>{try{let J=await $.renameFolder(K,{id:q,name:Y});return{content:[{type:"text",text:`Renamed folder: ${J.getObjectId()} (new path: ${J.getPath()})`}]}}catch(J){return{content:[{type:"text",text:`Error: ${J.message}`}],isError:!0}}},f66={name:"rename_folder",title:"Rename Folder",description:"Rename a folder",schema:_S1,execute:kS1};W6();var fS1=A.object({id:A.string().describe('Folder ID to move (e.g., "Af3")'),newParentId:A.string().describe('Target parent folder ID (e.g., "Af2")')}),NS1=async({core:$,projectId:K},{id:q,newParentId:Y})=>{try{let J=await $.moveFolder(K,{id:q,parentId:Y});return{content:[{type:"text",text:`Moved folder: ${J.getObjectId()} (new path: ${J.getPath()})`}]}}catch(J){return{content:[{type:"text",text:`Error: ${J.message}`}],isError:!0}}},N66={name:"move_folder",title:"Move Folder",description:"Move a folder to a new parent folder",schema:fS1,execute:NS1};W6();var RS1=A.object({id:A.string().describe('Folder ID (e.g., "Af2")')}),CS1=async({core:$,projectId:K},{id:q})=>{try{return await $.deleteFolder(K,{id:q}),{content:[{type:"text",text:`Deleted folder: ${q}`}]}}catch(Y){return{content:[{type:"text",text:`Error: ${Y.message}`}],isError:!0}}},R66={name:"delete_folder",title:"Delete Folder",description:"Soft delete a folder and all its contents (can be restored later)",schema:RS1,execute:CS1};var C66=[A66,M66,_66,k66,f66,N66,R66];W6();var DS1=A.object({ownerEntityId:A.string().optional().describe('Owner entity ID (e.g., "Ad1" for template). Omit for global/system fields.'),ownerEntityTypeCode:A.string().optional().describe('Entity type code for type-scoped definition (e.g., "d"). Mutually exclusive with ownerEntityId.'),ownerEntityTypeSubtype:A.string().optional().describe('Entity subtype for type-scoped definition (e.g., "task"). Used with ownerEntityTypeCode.'),name:A.string().describe("Field name (alphanumeric + underscores)"),primitiveType:A.enum(["string","object_ref"]).describe("Primitive type"),label:A.string().optional().describe("UI label"),description:A.string().optional().describe("Help text"),required:A.boolean().optional().describe("Whether field is required"),multiplicity:A.enum(["single","multi"]).optional().describe("Single or multi-valued"),isSystem:A.boolean().optional().describe("System/global field"),store:A.string().optional().describe('Store code (default: "A" for project store)')}),hS1=async({core:$,projectId:K},{ownerEntityId:q,ownerEntityTypeCode:Y,ownerEntityTypeSubtype:J,name:z,primitiveType:W,label:Z,description:H,required:O,multiplicity:X,isSystem:P,store:w})=>{try{let T=await $.createFieldDefinition(K,{store:w||"A",ownerEntityId:q,ownerEntityTypeCode:Y,ownerEntityTypeSubtype:J,name:z,label:Z,description:H,primitiveType:W,required:O,multiplicity:X,isSystem:P});return{content:[{type:"text",text:`Field definition created: ${T.getName()} (id: ${T.getObjectId()}, type: ${T.getPrimitiveType()})`}]}}catch(T){return{content:[{type:"text",text:`Error: ${T.message}`}],isError:!0}}},D66={name:"create_field_definition",title:"Create Field Definition",description:"Create a field definition on an owner entity (template/workflow)",schema:DS1,execute:hS1};W6();var ES1=A.object({ownerEntityId:A.string().optional().describe("Owner entity ID. Omit for global/system fields."),includeSystem:A.boolean().optional().describe("Include system fields"),store:A.string().optional().describe('Store code (default: "A" for project store)')}),SS1=async({core:$,projectId:K},{ownerEntityId:q,includeSystem:Y,store:J})=>{try{let z=await $.getFieldDefinitions(K,{store:J||"A",ownerEntityId:q||null,includeSystem:Y});if(z.length===0)return{content:[{type:"text",text:"No field definitions found"}]};return{content:[{type:"text",text:JSON.stringify(z,null,2)}]}}catch(z){return{content:[{type:"text",text:`Error: ${z.message}`}],isError:!0}}},h66={name:"get_field_definitions",title:"Get Field Definitions",description:"Get all field definitions for an owner entity",schema:ES1,execute:SS1};W6();var LS1=A.object({code:A.string().describe('Entity type code (e.g., "d" for document)'),subtype:A.string().describe('Entity subtype (e.g., "task")'),store:A.string().optional().describe('Store code (default: "A")')}),IS1=async({core:$,projectId:K},{code:q,subtype:Y,store:J})=>{try{let z=await $.getTypeFields(K,{store:J||"A",code:q,subtype:Y});if(z.length===0)return{content:[{type:"text",text:"No field definitions found for this entity type"}]};return{content:[{type:"text",text:JSON.stringify(z,null,2)}]}}catch(z){return{content:[{type:"text",text:`Error: ${z.message}`}],isError:!0}}},E66={name:"get_type_fields",title:"Get Type Fields",description:"Get field definitions for an entity type/subtype combination",schema:LS1,execute:IS1};W6();var xS1=A.object({id:A.string().describe('Field definition ID (e.g., "An1")')}),gS1=async({core:$,projectId:K},{id:q})=>{try{return{content:[{type:"text",text:`Field definition deleted: ${(await $.deleteFieldDefinition(K,{id:q})).name}`}]}}catch(Y){return{content:[{type:"text",text:`Error: ${Y.message}`}],isError:!0}}},S66={name:"delete_field_definition",title:"Delete Field Definition",description:"Delete a field definition (cascades to values)",schema:xS1,execute:gS1};W6();var bS1=A.object({id:A.string().describe('Entity ID (e.g., "Ad1")')}),yS1=async({core:$,projectId:K},{id:q})=>{try{let Y=await $.getFields(K,{entityId:q});if(!Y||Object.keys(Y).length===0)return{content:[{type:"text",text:"No fields set"}]};return{content:[{type:"text",text:JSON.stringify(Y,null,2)}]}}catch(Y){return{content:[{type:"text",text:`Error: ${Y.message}`}],isError:!0}}},L66={name:"get_fields",title:"Get Fields",description:"Get all field values for an entity as an object",schema:bS1,execute:yS1};W6();var uS1=A.object({id:A.string().describe('Entity ID (e.g., "Ad1")'),fieldDefinitionId:A.string().optional().describe('Field definition ID (e.g., "An1")'),fieldName:A.string().optional().describe("Field name for auto-resolution"),value:A.string().optional().describe("Single value"),values:A.array(A.string()).optional().describe("Array of values (for multi-valued)")}),mS1=async({core:$,projectId:K},{id:q,fieldDefinitionId:Y,fieldName:J,value:z,values:W})=>{try{if(z===void 0&&W===void 0)return{content:[{type:"text",text:"Error: Either value or values is required"}],isError:!0};let Z=await $.setField(K,{entityId:q,fieldDefinitionId:Y,fieldName:J,value:z,values:W}),H=J||Y,O=W!==void 0?`[${W.join(", ")}]`:z;return{content:[{type:"text",text:`Field set: ${H} = ${O}`}]}}catch(Z){return{content:[{type:"text",text:`Error: ${Z.message}`}],isError:!0}}},I66={name:"set_field",title:"Set Field",description:"Set a field value (single-valued or multi-valued)",schema:uS1,execute:mS1};W6();var BS1=A.object({id:A.string().describe('Entity ID (e.g., "Ad1")'),fieldDefinitionId:A.string().optional().describe('Field definition ID (e.g., "An1")'),fieldName:A.string().optional().describe("Field name for auto-resolution")}),US1=async({core:$,projectId:K},{id:q,fieldDefinitionId:Y,fieldName:J})=>{try{return{content:[{type:"text",text:`Field deleted: ${(await $.deleteField(K,{entityId:q,fieldDefinitionId:Y,fieldName:J})).name}`}]}}catch(z){return{content:[{type:"text",text:`Error: ${z.message}`}],isError:!0}}},x66={name:"delete_field",title:"Delete Field",description:"Remove a field from an entity",schema:BS1,execute:US1};var g66=[D66,h66,E66,S66,L66,I66,x66];W6();var pS1=A.object({}),FS1=async({core:$,projectId:K})=>{try{let q=await $.listExports(K);if(q.length===0)return{content:[{type:"text",text:"No exports found."}]};let Y=["Available exports:",""];for(let J of q)Y.push(`• ${J.filename} (${J.size} bytes)`);return{content:[{type:"text",text:Y.join(`
|
|
658
658
|
`)}]}}catch(q){return{content:[{type:"text",text:`Error: ${q.message}`}],isError:!0}}},b66={name:"list_exports",title:"List Exports",description:"List available export zip files in .caw-exports/",schema:pS1,execute:FS1};W6();var cS1=A.object({store:A.string().optional().describe('Store code (default: "A")')}),QS1=async({core:$,projectId:K},{store:q})=>{try{let Y=await $.exportPreview(K,{store:q}),J=Y.toExport.folders.length+Y.toExport.documents.length+Y.toExport.templates.length,z=Y.draftOnly.documents.length+Y.draftOnly.templates.length,W=`Export Preview:
|
|
659
659
|
|
|
660
660
|
`;if(W+=`Will export (${J} items):
|