cadskill 0.1.0__tar.gz → 0.1.1__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: cadskill
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: 3D CAD for Claude and Codex: build, inspect and export solid models by writing CadQuery scripts.
5
5
  Project-URL: Homepage, https://github.com/stepandel/cadskill
6
6
  Project-URL: Source, https://github.com/stepandel/cadskill
@@ -232,7 +232,7 @@ def _parser() -> argparse.ArgumentParser:
232
232
  add("models", "List the models saved on this computer.", model=False)
233
233
 
234
234
  s = add("view", "Open the live 3D viewer in the browser. It follows the model as it changes.", model=False)
235
- s.add_argument("--no-open", action="store_true", help="Only print the address.")
235
+ s.add_argument("--no-open", action="store_true", help="Print the URL for an in-app preview without launching the system browser.")
236
236
 
237
237
  s = add("install", "Install the CadSkill skill for Claude or Codex.", model=False)
238
238
  s.add_argument("--agent", choices=["claude", "codex"], default="claude", help="Agent to install for. Default: claude.")
@@ -45,6 +45,10 @@ named constants at the top. A failed run changes nothing: the previous version s
45
45
 
46
46
  If a tool answers that the CAD kernel is still starting, that is normal on first use (one to two
47
47
  minutes, once per computer). Tell the user it is warming up, wait about 20 seconds, and repeat the call.
48
+
49
+ Show the inline MCP App when available. Otherwise, open_viewer returns a URL for the host's
50
+ in-app preview or built-in browser. Reuse that view as the model changes. Open an external
51
+ system browser only when the user asks for it. Export HTML for hosts that display artifacts.
48
52
  """
49
53
 
50
54
  mcp = FastMCP("cadskill", instructions=INSTRUCTIONS)
@@ -460,9 +464,10 @@ def start_viewer_page(port: int = VIEWER_PORT, handler: type[BaseHTTPRequestHand
460
464
 
461
465
  @mcp.tool()
462
466
  def open_viewer() -> CallToolResult:
463
- """Get the address of a live 3D view of the model for the person to open in a browser.
467
+ """Get the address of a live 3D view without launching a browser.
464
468
 
465
- Use it when the conversation does not show the model inline. The page follows the model as it changes.
469
+ Use it when the conversation does not show the model inline. Open the URL in the host's
470
+ in-app preview when available. The page follows the model as it changes.
466
471
  """
467
472
  try:
468
473
  return _text(f"The live viewer is at {start_viewer_page()} (this computer only). It updates after every build.")
@@ -46,17 +46,30 @@ command again. Do not rewrite the script or give up.
46
46
 
47
47
  ## Showing the user
48
48
 
49
- Give the user a 3D view as well as any rendered pictures you share:
50
-
51
- - **Live viewer**: `cadskill view` opens a page in their browser that follows
52
- the model as you rebuild it. Do this once, after the first successful build.
53
- If you have your own browser or preview pane, you can open the address it
54
- prints there instead.
55
- - **As a page or artifact**: `cadskill export bracket html` writes
56
- `.cadskill/bracket.html`, the same viewer with the model inside it: one
57
- file, no server. If you can publish artifacts, publish that file when the
58
- user wants to keep or share the model, or cannot open a local page. Export
59
- again and republish after the model changes.
49
+ Keep the model beside the conversation when the host supports it:
50
+
51
+ - **Rendered pictures**: show the latest four-view PNG in the conversation
52
+ after a meaningful build. In Codex, use Markdown image syntax with its
53
+ absolute path: `![Model views](/absolute/path/.cadskill/bracket.png)`.
54
+ Opening it with `view_image` checks your work; include it in your reply so
55
+ the user can see it too.
56
+ - **Live in-app viewer**: after the first successful build, run
57
+ `cadskill view --no-open` to get the URL without launching the system
58
+ browser. In Codex desktop, use the available `open_in_codex` tool with
59
+ `{"target":{"type":"browser","url":"THE_RETURNED_URL"},"placement":"right"}`.
60
+ If that tool is unavailable but a built-in browser tool is available, open
61
+ the URL there. Reuse the same tab after later builds: the viewer updates
62
+ automatically. Check that the model loads before saying it is visible.
63
+ - **Page or artifact**: `cadskill export bracket html` writes
64
+ `.cadskill/bracket.html`, the viewer with the current model inside it as
65
+ one file that needs no server. If the host can display HTML artifacts,
66
+ use that surface when the user wants a snapshot, wants to keep or share the
67
+ model, or cannot reach the live viewer. Export again and update the same
68
+ artifact after model changes. A file link alone is not a rendered preview.
69
+
70
+ If there is no in-app preview or artifact surface, show the PNG and provide
71
+ the live viewer link. Run bare `cadskill view` only when the user asks to
72
+ open their system browser; it launches an external browser window.
60
73
 
61
74
  ## Script rules
62
75
 
@@ -107,7 +120,7 @@ COMMAND --help` lists every option.
107
120
  | `cadskill import MODEL FILE` | Copy a STEP or BREP file in, for the script to load with `asset("name.step")` |
108
121
  | `cadskill show MODEL`, `versions MODEL`, `models` | The saved script, its history, all models |
109
122
  | `cadskill restore MODEL N --to SCRIPT` | Go back to version N and write that script back to the file |
110
- | `cadskill view` | Open the live 3D viewer |
123
+ | `cadskill view --no-open` | Get the live 3D viewer URL for the host's preview pane |
111
124
 
112
125
  A **selection** (for `--highlight` and `measure`) is `PART`, `KIND` or
113
126
  `PART/KIND`, optionally followed by `:SELECTOR` or `@ROWS` (row numbers from
@@ -4500,7 +4500,7 @@ Boolean requesting whether a visible border and background is provided by the ho
4500
4500
  - omitted: host decides border`)}),H9=I.object({method:I.literal("ui/request-display-mode"),params:I.object({mode:vh.describe("The display mode being requested.")})}),ZB=I.object({mode:vh.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),XB=I.union([I.literal("model"),I.literal("app")]).describe("Tool visibility scope - who can access the tool."),G9=I.object({resourceUri:I.string().optional(),visibility:I.array(XB).optional().describe(`Who can access this tool. Default: ["model", "app"]
4501
4501
  - "model": Tool visible to and callable by the agent
4502
4502
  - "app": Tool callable by the app from this server only`),csp:I.never().optional(),permissions:I.never().optional()}),q9=I.object({mimeTypes:I.array(I.string()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),W9=I.object({method:I.literal("ui/download-file"),params:I.object({contents:I.array(I.union([ws,Ms])).describe("Resource contents to download \u2014 embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),Z9=I.object({method:I.literal("ui/message"),params:I.object({role:I.literal("user").describe('Message role, currently only "user" is supported.'),content:I.array(ar).describe("Message content blocks (text, image, etc.).")})}),X9=I.object({method:I.literal("ui/notifications/sandbox-resource-ready"),params:I.object({html:I.string().describe("HTML content to load into the inner iframe."),sandbox:I.string().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Vw.optional().describe("CSP configuration from resource metadata."),permissions:jw.optional().describe("Sandbox permissions from resource metadata.")})}),JB=I.object({method:I.literal("ui/notifications/tool-result"),params:No.describe("Standard MCP tool execution result.")}),$C=I.object({toolInfo:I.object({id:Fi.optional().describe("JSON-RPC id of the tools/call request."),tool:$o.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:kB.optional().describe("Current color theme preference."),styles:jB.optional().describe("Style configuration for theming the app."),displayMode:vh.optional().describe("How the UI is currently displayed."),availableDisplayModes:I.array(vh).optional().describe("Display modes the host supports."),containerDimensions:I.union([I.object({height:I.number().describe("Fixed container height in pixels.")}),I.object({maxHeight:I.union([I.number(),I.undefined()]).optional().describe("Maximum container height in pixels.")})]).and(I.union([I.object({width:I.number().describe("Fixed container width in pixels.")}),I.object({maxWidth:I.union([I.number(),I.undefined()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
4503
- container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:I.string().optional().describe("User's language and region preference in BCP 47 format."),timeZone:I.string().optional().describe("User's timezone in IANA format."),userAgent:I.string().optional().describe("Host application identifier."),platform:I.union([I.literal("web"),I.literal("desktop"),I.literal("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:I.object({touch:I.boolean().optional().describe("Whether the device supports touch input."),hover:I.boolean().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:I.object({top:I.number().describe("Top safe area inset in pixels."),right:I.number().describe("Right safe area inset in pixels."),bottom:I.number().describe("Bottom safe area inset in pixels."),left:I.number().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),YB=I.object({method:I.literal("ui/notifications/host-context-changed"),params:$C.describe("Partial context update containing only changed fields.")}),J9=I.object({method:I.literal("ui/update-model-context"),params:I.object({content:I.array(ar).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:I.record(I.string(),I.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),Y9=I.object({method:I.literal("ui/initialize"),params:I.object({appInfo:or.describe("App identification (name and version)."),appCapabilities:WB.describe("Features and capabilities this app provides."),protocolVersion:I.string().describe("Protocol version this app supports.")})}),KB=I.object({protocolVersion:I.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:or.describe("Host application identification and version."),hostCapabilities:qB.describe("Features and capabilities provided by the host."),hostContext:$C.describe("Rich context about the host environment.")}).passthrough(),QB={target:"draft-2020-12"};async function zC(t,e){let n=t["~standard"];if(n.jsonSchema)return n.jsonSchema[e](QB);throw Error(`Schema (vendor: ${n.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function kC(t,e,n=""){let r=await t["~standard"].validate(e);if(r.issues){let i=r.issues.map(o=>{let s=o.path?.map(a=>typeof a=="object"?a.key:a).join(".");return s?`${s}: ${o.message}`:o.message}).join("; ");throw Error(n+i)}return r.value}function eV(t,e){let n={...t,...e};return e.experimental!==void 0&&(n.experimental={...t.experimental,...e.experimental}),e.tools!==void 0&&(n.tools={...t.tools,...e.tools}),n}var g_=class t extends gh{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new Uw;_methods=new Fw;setRequestHandler=(...e)=>{let[n,...r]=PC("request",e)??e;this._methods.claim(n,"setRequestHandler"),super.setRequestHandler.call(this,n,...r)};setNotificationHandler=(...e)=>{let[n,...r]=PC("notification",e)??e;this._methods.claim(n,"setNotificationHandler"),super.setNotificationHandler.call(this,n,...r)};removeRequestHandler=e=>{this._methods.release(e),super.removeRequestHandler(e)};removeNotificationHandler=e=>{this._methods.release(e),super.removeNotificationHandler(e)};replaceRequestHandler=(e,...n)=>{this._methods.replace(e),super.setRequestHandler.call(this,e,...n)};_assertInitialized(e){if(this._initializedSent)return;let n=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(n);console.warn(`${n}. This will throw in a future release.`)}eventSchemas={toolinput:UB,toolinputpartial:FB,toolresult:JB,toolcancelled:BB,hostcontextchanged:YB};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(e){if(!t.ONE_SHOT_EVENTS.has(e)||this._everHadListener.has(e)||(this._everHadListener.add(e),!this._initializedSent))return;let n=`[ext-apps] "${String(e)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(n);console.warn(n)}setEventHandler(e,n){n&&this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.setHandler(e,n)}addEventListener(e,n){this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.addEventListener(e,n)}removeEventListener(e,n){this._events.removeEventListener(e,n)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let n=this.eventSchemas[e];if(!n)throw Error(`Unknown event: ${String(e)}`);this.setNotificationHandler(n.shape.method.value,{params:n.shape.params},r=>{let i=r;e==="hostcontextchanged"&&(this._hostContext={...this._hostContext,...i}),this._events.dispatch(e,i)}),this._registeredEvents.add(e)}getEventHandler(e){return this._events.getHandler(e)}warnIfRequestHandlerReplaced(e,n,r){n&&r&&console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,n={},r={autoResize:!0}){super(r),this._appInfo=e,this._appCapabilities=n,this.options=r,this._methods.replace("notifications/cancelled"),this._methods.replace("notifications/progress"),!r.allowUnsafeEval&&I.config({jitless:!0}),this.replaceRequestHandler("ping",i=>(console.log("Received ping:",i.params),{})),this.setEventHandler("hostcontextchanged",void 0)}buildContext(e){return e}registerAppCapabilities(e){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._appCapabilities=eV(this._appCapabilities,e)}registerTool(e,n,r){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let i=this,o=()=>{i._initializedSent&&i._appCapabilities.tools?.listChanged&&i.sendToolListChanged()},s=n.inputSchema!==void 0,a={title:n.title,description:n.description,inputSchema:n.inputSchema,outputSchema:n.outputSchema,annotations:n.annotations,_meta:n._meta,enabled:!0,enable(){this.enabled=!0,o()},disable(){this.enabled=!1,o()},update(c){Object.assign(this,c),o()},remove(){i._registeredTools[e]===a&&(delete i._registeredTools[e],o())},handler:async(c,l)=>{if(!a.enabled)throw Error(`Tool ${e} is disabled`);let u;if(s){let d=a.inputSchema,h=d?await kC(d,c??{},`Invalid input for tool ${e}: `):c??{};u=await r(h,l)}else u=await r(l);return a.outputSchema&&!u.isError&&(u.structuredContent=await kC(a.outputSchema,u.structuredContent,`Invalid output for tool ${e}: `)),u}};return this._registeredTools[e]=a,!this._appCapabilities.tools&&!this.transport&&this.registerAppCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),o(),a}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(e,n)=>{let r=this._registeredTools[e.name];if(!r)throw Error(`Tool ${e.name} not found`);return r.handler(e.arguments,n)},this.onlisttools=async(e,n)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([r,i])=>i.enabled).map(async([r,i])=>{let o={name:r,title:i.title,description:i.description,inputSchema:i.inputSchema?await zC(i.inputSchema,"input"):{type:"object",properties:{}}};return i.outputSchema&&(o.outputSchema=await zC(i.outputSchema,"output")),i.annotations&&(o.annotations=i.annotations),i._meta&&(o._meta=i._meta),o}))}))}async sendToolListChanged(e={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(e){this.setEventHandler("toolinput",e)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(e){this.setEventHandler("toolinputpartial",e)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(e){this.setEventHandler("toolresult",e)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(e){this.setEventHandler("toolcancelled",e)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(e){this.setEventHandler("hostcontextchanged",e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,e),this._onteardown=e,this.replaceRequestHandler("ui/resource-teardown",{params:HB.shape.params,result:GB},(n,r)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(n,r)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler("tools/call",(n,r)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(n.params,r)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler("tools/list",(n,r)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(n.params,r)})}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`);break}}assertRequestHandlerCapability(e){switch(e){case"tools/call":case"tools/list":if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;default:return}}assertNotificationCapability(e){}async callServerTool(e,n){if(this._assertInitialized("callServerTool"),typeof e=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:e},{onprogress:()=>{},resetTimeoutOnProgress:!0,...n})}async readServerResource(e,n){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:e},n)}async listServerResources(e,n){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:e},n)}async createSamplingMessage(e,n){return this._assertInitialized("createSamplingMessage"),await this.request({method:"sampling/createMessage",params:e},n)}sendMessage(e,n){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:e},LB,n)}sendLog(e){return this.notification({method:"notifications/message",params:e})}updateModelContext(e,n){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:e},zo,n)}openLink(e,n){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:e},OB,n)}sendOpenLink=this.openLink;downloadFile(e,n){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:e},DB,n)}requestTeardown(e={}){return this.notification({method:"ui/notifications/request-teardown",params:e})}requestDisplayMode(e,n){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:e},ZB,n)}sendSizeChanged(e){return this.notification({method:"ui/notifications/size-changed",params:e})}setupSizeChangedNotifications(){let e=!1,n=0,r=0,i=()=>{e||(e=!0,requestAnimationFrame(()=>{e=!1;let s=document.documentElement,a=s.style.height;s.style.height="max-content";let c=Math.ceil(s.getBoundingClientRect().height);s.style.height=a;let l=Math.ceil(window.innerWidth);(l!==n||c!==r)&&(n=l,r=c,this.sendSizeChanged({width:l,height:c}))}))};i();let o=new ResizeObserver(i);return o.observe(document.documentElement),o.observe(document.body),()=>o.disconnect()}async connect(e=new Bw(window.parent,window.parent),n){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1;try{await super.connect(e);let r=await this.request({method:"ui/initialize",params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:CB}},KB,n);if(r===void 0)throw Error(`Server sent invalid initialize result: ${r}`);this._hostCapabilities=r.hostCapabilities,this._hostInfo=r.hostInfo,this._hostContext=r.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(r){throw this.close(),r}}};var tV=1e3,nV=4e3;function Hw(t){let e=atob(t),n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n.buffer}function Gw(t){return{model:t.model,version:t.version,parts:t.parts.map(e=>({...e,path:[],positions:new Float32Array(Hw(e.positions)),normals:new Float32Array(Hw(e.normals)),indices:new Uint32Array(Hw(e.indices))}))}}async function NC(t){let e="",n=(s,a)=>{let c=s+"@"+a;!s||!a||c===e||(e=c,queueMicrotask(()=>t.latest(s,a)))};if(window.CADSKILL_MODEL){let s=Gw(window.CADSKILL_MODEL);return n(s.model,s.version),{mesh:async()=>s,history:null}}if(window.parent!==window){let s=new g_({name:"CadSkill viewer",version:"0.1.0"}),a=async(l,u)=>{let d=await s.callServerTool({name:l,arguments:u}),h=d.content&&d.content.find(f=>f.type==="text");if(d.isError||!h)throw new Error(h?h.text:"no data");return JSON.parse(h.text)},c={mesh:async(l,u)=>Gw(await a("get_mesh",{model:l,version:u})),history:l=>a("get_history",{model:l})};s.ontoolresult=l=>{let u=l.structuredContent;u&&u.model?n(u.model,u.version):l.isError&&t.status("That change failed; the model is unchanged.",!0)},s.onhostcontextchanged=l=>{l&&l.theme&&t.theme(l.theme)};try{await Promise.race([s.connect(),new Promise((u,d)=>setTimeout(()=>d(new Error("no host answered")),nV))]);let l=s.getHostContext();return l&&l.theme&&t.theme(l.theme),c}catch{}}let r=async s=>{let a=await fetch(s);if(!a.ok)throw new Error(await a.text());return a.json()},i={mesh:async(s,a)=>Gw(await r("./mesh?model="+encodeURIComponent(s)+"&version="+a)),history:s=>r("./history?model="+encodeURIComponent(s))},o=async()=>{try{let s=await r("./state");s.model?n(s.model,s.version):t.status("No model yet. Ask Claude to build one.")}catch{t.status("The CadSkill server is not running.",!0)}setTimeout(o,tV)};return o(),i}var Sh=Kt("history"),qw=Kt("versions"),Xw=Kt("toggle-history"),Ww=null,OC=()=>{},yh=[],__="",Zw={latest:0,shown:0};function DC(t){Ww=t.load,OC=t.pick}async function Jw(){if(!(Sh.hidden||!Ww)){try{yh=(await Ww()).versions||[],__=""}catch{__="Could not read the history."}Yw()}}function LC(t,e){Zw={latest:t,shown:e},Yw()}function jr(t,e,n){let r=document.createElement(t);return e&&(r.className=e),n!=null&&(r.textContent=n),r}function iV(t){let[e,n=""]=String(t||"").split(" "),r=new Date,i=[r.getFullYear(),String(r.getMonth()+1).padStart(2,"0"),String(r.getDate()).padStart(2,"0")].join("-"),o=n.slice(0,5);if(e===i)return o;let[s,a,c]=e.split("-").map(Number);return s?new Date(s,a-1,c).toLocaleDateString(void 0,{month:"short",day:"numeric"})+" "+o:t||""}function Yw(){if(Kt("count").textContent=yh.length?String(yh.length):"",__||!yh.length){qw.replaceChildren(jr("li","hint",__||"No versions yet."));return}qw.replaceChildren(...yh.slice().reverse().map(e=>{let n=jr("button","ver");n.type="button",e.version===Zw.shown&&n.setAttribute("aria-current","true");let r=jr("span","vhead");if(r.append(jr("b",null,"v"+e.version)),e.version===Zw.latest&&r.append(jr("span","tag","latest")),r.append(jr("time",null,iV(e.time))),n.append(r),e.note&&n.append(jr("span","vnote",e.note)),e.summary){let o=jr("span","vsum",e.summary);o.title=e.summary,n.append(o)}n.addEventListener("click",()=>OC(e.version));let i=jr("li");return i.append(n),i}));let t=qw.querySelector('[aria-current="true"]');t&&!Sh.hidden&&t.scrollIntoView({block:"nearest"})}function Kw(t){Sh.hidden=!t,Xw.setAttribute("aria-pressed",String(t)),t&&(Yw(),Jw())}Xw.addEventListener("click",()=>Kw(Sh.hidden));Kt("close-history").addEventListener("click",()=>{Kw(!1),Xw.focus()});document.addEventListener("keydown",t=>{t.key==="Escape"&&!Sh.hidden&&Kw(!1)});var v_=Kt("msg");function FC(t,e){v_.textContent=t,v_.classList.toggle("bad",!!e),v_.hidden=!1}Wv();var Vi={model:null,latest:0,shown:0},UC=!0,Qw=0;function rV({model:t,version:e,parts:n}){let r=mn.selected&&mn.selected.id,i=oE(n);Vi.shown=e,hE(t+" \xB7 v"+e),Hv(mn.parts.find(s=>s.id===r)||null),v_.hidden=!0,(UC||i)&&uE(),UC=!1;let o=e!==Vi.latest;Kt("back").hidden=!o,Kt("back").textContent="Back to v"+Vi.latest,LC(Vi.latest,e)}async function eM(t){let e=++Qw;try{let n=await(await tM).mesh(Vi.model,t);e===Qw&&rV(n)}catch(n){e===Qw&&FC("Could not load the model: "+(n&&n.message?n.message:n),!0)}}var tM=NC({latest(t,e){Vi.model=t,Vi.latest=e,eM(e),Jw()},status:FC,theme(t){document.documentElement.dataset.theme=t}});DC({load:async()=>Vi.model?(await tM).history(Vi.model):{versions:[]},pick:t=>{Vi.model&&eM(t)}});tM.then(t=>{t.history||(Kt("toggle-history").hidden=!0)});Kt("back").addEventListener("click",()=>eM(Vi.latest));
4503
+ container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:I.string().optional().describe("User's language and region preference in BCP 47 format."),timeZone:I.string().optional().describe("User's timezone in IANA format."),userAgent:I.string().optional().describe("Host application identifier."),platform:I.union([I.literal("web"),I.literal("desktop"),I.literal("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:I.object({touch:I.boolean().optional().describe("Whether the device supports touch input."),hover:I.boolean().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:I.object({top:I.number().describe("Top safe area inset in pixels."),right:I.number().describe("Right safe area inset in pixels."),bottom:I.number().describe("Bottom safe area inset in pixels."),left:I.number().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),YB=I.object({method:I.literal("ui/notifications/host-context-changed"),params:$C.describe("Partial context update containing only changed fields.")}),J9=I.object({method:I.literal("ui/update-model-context"),params:I.object({content:I.array(ar).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:I.record(I.string(),I.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),Y9=I.object({method:I.literal("ui/initialize"),params:I.object({appInfo:or.describe("App identification (name and version)."),appCapabilities:WB.describe("Features and capabilities this app provides."),protocolVersion:I.string().describe("Protocol version this app supports.")})}),KB=I.object({protocolVersion:I.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:or.describe("Host application identification and version."),hostCapabilities:qB.describe("Features and capabilities provided by the host."),hostContext:$C.describe("Rich context about the host environment.")}).passthrough(),QB={target:"draft-2020-12"};async function zC(t,e){let n=t["~standard"];if(n.jsonSchema)return n.jsonSchema[e](QB);throw Error(`Schema (vendor: ${n.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function kC(t,e,n=""){let r=await t["~standard"].validate(e);if(r.issues){let i=r.issues.map(o=>{let s=o.path?.map(a=>typeof a=="object"?a.key:a).join(".");return s?`${s}: ${o.message}`:o.message}).join("; ");throw Error(n+i)}return r.value}function eV(t,e){let n={...t,...e};return e.experimental!==void 0&&(n.experimental={...t.experimental,...e.experimental}),e.tools!==void 0&&(n.tools={...t.tools,...e.tools}),n}var g_=class t extends gh{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new Uw;_methods=new Fw;setRequestHandler=(...e)=>{let[n,...r]=PC("request",e)??e;this._methods.claim(n,"setRequestHandler"),super.setRequestHandler.call(this,n,...r)};setNotificationHandler=(...e)=>{let[n,...r]=PC("notification",e)??e;this._methods.claim(n,"setNotificationHandler"),super.setNotificationHandler.call(this,n,...r)};removeRequestHandler=e=>{this._methods.release(e),super.removeRequestHandler(e)};removeNotificationHandler=e=>{this._methods.release(e),super.removeNotificationHandler(e)};replaceRequestHandler=(e,...n)=>{this._methods.replace(e),super.setRequestHandler.call(this,e,...n)};_assertInitialized(e){if(this._initializedSent)return;let n=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(n);console.warn(`${n}. This will throw in a future release.`)}eventSchemas={toolinput:UB,toolinputpartial:FB,toolresult:JB,toolcancelled:BB,hostcontextchanged:YB};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(e){if(!t.ONE_SHOT_EVENTS.has(e)||this._everHadListener.has(e)||(this._everHadListener.add(e),!this._initializedSent))return;let n=`[ext-apps] "${String(e)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(n);console.warn(n)}setEventHandler(e,n){n&&this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.setHandler(e,n)}addEventListener(e,n){this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.addEventListener(e,n)}removeEventListener(e,n){this._events.removeEventListener(e,n)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let n=this.eventSchemas[e];if(!n)throw Error(`Unknown event: ${String(e)}`);this.setNotificationHandler(n.shape.method.value,{params:n.shape.params},r=>{let i=r;e==="hostcontextchanged"&&(this._hostContext={...this._hostContext,...i}),this._events.dispatch(e,i)}),this._registeredEvents.add(e)}getEventHandler(e){return this._events.getHandler(e)}warnIfRequestHandlerReplaced(e,n,r){n&&r&&console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,n={},r={autoResize:!0}){super(r),this._appInfo=e,this._appCapabilities=n,this.options=r,this._methods.replace("notifications/cancelled"),this._methods.replace("notifications/progress"),!r.allowUnsafeEval&&I.config({jitless:!0}),this.replaceRequestHandler("ping",i=>(console.log("Received ping:",i.params),{})),this.setEventHandler("hostcontextchanged",void 0)}buildContext(e){return e}registerAppCapabilities(e){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._appCapabilities=eV(this._appCapabilities,e)}registerTool(e,n,r){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let i=this,o=()=>{i._initializedSent&&i._appCapabilities.tools?.listChanged&&i.sendToolListChanged()},s=n.inputSchema!==void 0,a={title:n.title,description:n.description,inputSchema:n.inputSchema,outputSchema:n.outputSchema,annotations:n.annotations,_meta:n._meta,enabled:!0,enable(){this.enabled=!0,o()},disable(){this.enabled=!1,o()},update(c){Object.assign(this,c),o()},remove(){i._registeredTools[e]===a&&(delete i._registeredTools[e],o())},handler:async(c,l)=>{if(!a.enabled)throw Error(`Tool ${e} is disabled`);let u;if(s){let d=a.inputSchema,h=d?await kC(d,c??{},`Invalid input for tool ${e}: `):c??{};u=await r(h,l)}else u=await r(l);return a.outputSchema&&!u.isError&&(u.structuredContent=await kC(a.outputSchema,u.structuredContent,`Invalid output for tool ${e}: `)),u}};return this._registeredTools[e]=a,!this._appCapabilities.tools&&!this.transport&&this.registerAppCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),o(),a}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(e,n)=>{let r=this._registeredTools[e.name];if(!r)throw Error(`Tool ${e.name} not found`);return r.handler(e.arguments,n)},this.onlisttools=async(e,n)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([r,i])=>i.enabled).map(async([r,i])=>{let o={name:r,title:i.title,description:i.description,inputSchema:i.inputSchema?await zC(i.inputSchema,"input"):{type:"object",properties:{}}};return i.outputSchema&&(o.outputSchema=await zC(i.outputSchema,"output")),i.annotations&&(o.annotations=i.annotations),i._meta&&(o._meta=i._meta),o}))}))}async sendToolListChanged(e={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(e){this.setEventHandler("toolinput",e)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(e){this.setEventHandler("toolinputpartial",e)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(e){this.setEventHandler("toolresult",e)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(e){this.setEventHandler("toolcancelled",e)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(e){this.setEventHandler("hostcontextchanged",e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,e),this._onteardown=e,this.replaceRequestHandler("ui/resource-teardown",{params:HB.shape.params,result:GB},(n,r)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(n,r)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler("tools/call",(n,r)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(n.params,r)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler("tools/list",(n,r)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(n.params,r)})}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`);break}}assertRequestHandlerCapability(e){switch(e){case"tools/call":case"tools/list":if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;default:return}}assertNotificationCapability(e){}async callServerTool(e,n){if(this._assertInitialized("callServerTool"),typeof e=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:e},{onprogress:()=>{},resetTimeoutOnProgress:!0,...n})}async readServerResource(e,n){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:e},n)}async listServerResources(e,n){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:e},n)}async createSamplingMessage(e,n){return this._assertInitialized("createSamplingMessage"),await this.request({method:"sampling/createMessage",params:e},n)}sendMessage(e,n){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:e},LB,n)}sendLog(e){return this.notification({method:"notifications/message",params:e})}updateModelContext(e,n){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:e},zo,n)}openLink(e,n){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:e},OB,n)}sendOpenLink=this.openLink;downloadFile(e,n){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:e},DB,n)}requestTeardown(e={}){return this.notification({method:"ui/notifications/request-teardown",params:e})}requestDisplayMode(e,n){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:e},ZB,n)}sendSizeChanged(e){return this.notification({method:"ui/notifications/size-changed",params:e})}setupSizeChangedNotifications(){let e=!1,n=0,r=0,i=()=>{e||(e=!0,requestAnimationFrame(()=>{e=!1;let s=document.documentElement,a=s.style.height;s.style.height="max-content";let c=Math.ceil(s.getBoundingClientRect().height);s.style.height=a;let l=Math.ceil(window.innerWidth);(l!==n||c!==r)&&(n=l,r=c,this.sendSizeChanged({width:l,height:c}))}))};i();let o=new ResizeObserver(i);return o.observe(document.documentElement),o.observe(document.body),()=>o.disconnect()}async connect(e=new Bw(window.parent,window.parent),n){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1;try{await super.connect(e);let r=await this.request({method:"ui/initialize",params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:CB}},KB,n);if(r===void 0)throw Error(`Server sent invalid initialize result: ${r}`);this._hostCapabilities=r.hostCapabilities,this._hostInfo=r.hostInfo,this._hostContext=r.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(r){throw this.close(),r}}};var tV=1e3,nV=4e3;function Hw(t){let e=atob(t),n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n.buffer}function Gw(t){return{model:t.model,version:t.version,parts:t.parts.map(e=>({...e,path:[],positions:new Float32Array(Hw(e.positions)),normals:new Float32Array(Hw(e.normals)),indices:new Uint32Array(Hw(e.indices))}))}}async function NC(t){let e="",n=(s,a)=>{let c=s+"@"+a;!s||!a||c===e||(e=c,queueMicrotask(()=>t.latest(s,a)))};if(window.CADSKILL_MODEL){let s=Gw(window.CADSKILL_MODEL);return n(s.model,s.version),{mesh:async()=>s,history:null}}if(window.parent!==window){let s=new g_({name:"CadSkill viewer",version:"0.1.1"}),a=async(l,u)=>{let d=await s.callServerTool({name:l,arguments:u}),h=d.content&&d.content.find(f=>f.type==="text");if(d.isError||!h)throw new Error(h?h.text:"no data");return JSON.parse(h.text)},c={mesh:async(l,u)=>Gw(await a("get_mesh",{model:l,version:u})),history:l=>a("get_history",{model:l})};s.ontoolresult=l=>{let u=l.structuredContent;u&&u.model?n(u.model,u.version):l.isError&&t.status("That change failed; the model is unchanged.",!0)},s.onhostcontextchanged=l=>{l&&l.theme&&t.theme(l.theme)};try{await Promise.race([s.connect(),new Promise((u,d)=>setTimeout(()=>d(new Error("no host answered")),nV))]);let l=s.getHostContext();return l&&l.theme&&t.theme(l.theme),c}catch{}}let r=async s=>{let a=await fetch(s);if(!a.ok)throw new Error(await a.text());return a.json()},i={mesh:async(s,a)=>Gw(await r("./mesh?model="+encodeURIComponent(s)+"&version="+a)),history:s=>r("./history?model="+encodeURIComponent(s))},o=async()=>{try{let s=await r("./state");s.model?n(s.model,s.version):t.status("No model yet. Ask Claude to build one.")}catch{t.status("The CadSkill server is not running.",!0)}setTimeout(o,tV)};return o(),i}var Sh=Kt("history"),qw=Kt("versions"),Xw=Kt("toggle-history"),Ww=null,OC=()=>{},yh=[],__="",Zw={latest:0,shown:0};function DC(t){Ww=t.load,OC=t.pick}async function Jw(){if(!(Sh.hidden||!Ww)){try{yh=(await Ww()).versions||[],__=""}catch{__="Could not read the history."}Yw()}}function LC(t,e){Zw={latest:t,shown:e},Yw()}function jr(t,e,n){let r=document.createElement(t);return e&&(r.className=e),n!=null&&(r.textContent=n),r}function iV(t){let[e,n=""]=String(t||"").split(" "),r=new Date,i=[r.getFullYear(),String(r.getMonth()+1).padStart(2,"0"),String(r.getDate()).padStart(2,"0")].join("-"),o=n.slice(0,5);if(e===i)return o;let[s,a,c]=e.split("-").map(Number);return s?new Date(s,a-1,c).toLocaleDateString(void 0,{month:"short",day:"numeric"})+" "+o:t||""}function Yw(){if(Kt("count").textContent=yh.length?String(yh.length):"",__||!yh.length){qw.replaceChildren(jr("li","hint",__||"No versions yet."));return}qw.replaceChildren(...yh.slice().reverse().map(e=>{let n=jr("button","ver");n.type="button",e.version===Zw.shown&&n.setAttribute("aria-current","true");let r=jr("span","vhead");if(r.append(jr("b",null,"v"+e.version)),e.version===Zw.latest&&r.append(jr("span","tag","latest")),r.append(jr("time",null,iV(e.time))),n.append(r),e.note&&n.append(jr("span","vnote",e.note)),e.summary){let o=jr("span","vsum",e.summary);o.title=e.summary,n.append(o)}n.addEventListener("click",()=>OC(e.version));let i=jr("li");return i.append(n),i}));let t=qw.querySelector('[aria-current="true"]');t&&!Sh.hidden&&t.scrollIntoView({block:"nearest"})}function Kw(t){Sh.hidden=!t,Xw.setAttribute("aria-pressed",String(t)),t&&(Yw(),Jw())}Xw.addEventListener("click",()=>Kw(Sh.hidden));Kt("close-history").addEventListener("click",()=>{Kw(!1),Xw.focus()});document.addEventListener("keydown",t=>{t.key==="Escape"&&!Sh.hidden&&Kw(!1)});var v_=Kt("msg");function FC(t,e){v_.textContent=t,v_.classList.toggle("bad",!!e),v_.hidden=!1}Wv();var Vi={model:null,latest:0,shown:0},UC=!0,Qw=0;function rV({model:t,version:e,parts:n}){let r=mn.selected&&mn.selected.id,i=oE(n);Vi.shown=e,hE(t+" \xB7 v"+e),Hv(mn.parts.find(s=>s.id===r)||null),v_.hidden=!0,(UC||i)&&uE(),UC=!1;let o=e!==Vi.latest;Kt("back").hidden=!o,Kt("back").textContent="Back to v"+Vi.latest,LC(Vi.latest,e)}async function eM(t){let e=++Qw;try{let n=await(await tM).mesh(Vi.model,t);e===Qw&&rV(n)}catch(n){e===Qw&&FC("Could not load the model: "+(n&&n.message?n.message:n),!0)}}var tM=NC({latest(t,e){Vi.model=t,Vi.latest=e,eM(e),Jw()},status:FC,theme(t){document.documentElement.dataset.theme=t}});DC({load:async()=>Vi.model?(await tM).history(Vi.model):{versions:[]},pick:t=>{Vi.model&&eM(t)}});tM.then(t=>{t.history||(Kt("toggle-history").hidden=!0)});Kt("back").addEventListener("click",()=>eM(Vi.latest));
4504
4504
  </script>
4505
4505
  </body>
4506
4506
  </html>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "cadskill"
3
- version = "0.1.0"
3
+ version = "0.1.1"
4
4
  description = "3D CAD for Claude and Codex: build, inspect and export solid models by writing CadQuery scripts."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12,<3.13"
@@ -142,7 +142,7 @@ wheels = [
142
142
 
143
143
  [[package]]
144
144
  name = "cadskill"
145
- version = "0.1.0"
145
+ version = "0.1.1"
146
146
  source = { editable = "." }
147
147
  dependencies = [
148
148
  { name = "cadquery" },
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes