(()=>{var a={};a.id=12920,a.ids=[12920],a.modules={51455:a=>{"use strict";a.exports=require("node:fs/promises")},161730:(a,b,c)=>{"use strict";Object.defineProperty(b,"I",{enumerable:!0,get:function(){return g}});let d=c(554226),e=c(884327),f=c(728392);async function g(a,b,c,g){if((0,d.isNodeNextResponse)(b)){var h;b.statusCode=c.status,b.statusMessage=c.statusText;let d=["set-cookie","www-authenticate","proxy-authenticate","vary"];null==(h=c.headers)||h.forEach((a,c)=>{if("x-middleware-set-cookie"!==c.toLowerCase())if("set-cookie"===c.toLowerCase())for(let d of(0,f.splitCookiesString)(a))b.appendHeader(c,d);else{let e=void 0!==b.getHeader(c);(d.includes(c.toLowerCase())||!e)&&b.appendHeader(c,a)}});let{originalResponse:i}=b;c.body&&"HEAD"!==a.method?await (0,e.pipeToNodeResponse)(c.body,i,g):i.end()}}},176760:a=>{"use strict";a.exports=require("node:path")},200261:a=>{"use strict";a.exports=require("next/dist/shared/lib/router/utils/app-paths")},257975:a=>{"use strict";a.exports=require("node:util")},325306:(a,b,c)=>{"use strict";function d(a){let b=`<script>
(function() {
  if (window.dench) return;

  var _pendingRequests = {};
  var _requestId = 0;
  var _streamCallbacks = {};
  var _streamId = 0;
  var _eventListeners = {};
  var _toolHandlers = {};
  var _appMessageHandler = null;
  var _webhookHandlers = {};

  function sendRequest(method, params) {
    return new Promise(function(resolve, reject) {
      var id = ++_requestId;
      _pendingRequests[id] = { resolve: resolve, reject: reject };
      window.parent.postMessage({
        type: "dench:request",
        id: id,
        method: method,
        params: params
      }, "*");

      setTimeout(function() {
        if (_pendingRequests[id]) {
          _pendingRequests[id].reject(new Error("Request timeout: " + method));
          delete _pendingRequests[id];
        }
      }, 30000);
    });
  }

  function sendStreamRequest(method, params, onEvent) {
    return new Promise(function(resolve, reject) {
      var id = ++_requestId;
      var sid = ++_streamId;
      _streamCallbacks[sid] = onEvent;
      _pendingRequests[id] = {
        resolve: function(result) {
          delete _streamCallbacks[sid];
          resolve(result);
        },
        reject: function(err) {
          delete _streamCallbacks[sid];
          reject(err);
        }
      };
      window.parent.postMessage({
        type: "dench:request",
        id: id,
        method: method,
        params: Object.assign({}, params, { _streamId: sid })
      }, "*");

      setTimeout(function() {
        if (_pendingRequests[id]) {
          delete _streamCallbacks[sid];
          _pendingRequests[id].reject(new Error("Request timeout: " + method));
          delete _pendingRequests[id];
        }
      }, 300000);
    });
  }

  window.addEventListener("message", function(event) {
    if (!event.data) return;
    var d = event.data;

    if (d.type === "dench:response") {
      var pending = _pendingRequests[d.id];
      if (!pending) return;
      delete _pendingRequests[d.id];
      if (d.error) {
        pending.reject(new Error(d.error));
      } else {
        pending.resolve(d.result);
      }
    }

    else if (d.type === "dench:stream") {
      var cb = _streamCallbacks[d.streamId];
      if (cb) cb({ type: d.event, data: d.data, name: d.name, args: d.args, result: d.result });
    }

    else if (d.type === "dench:stream-end") {
      // Stream end is handled via the normal response path
    }

    else if (d.type === "dench:event") {
      var channel = d.channel;
      if (channel === "apps.message" && _appMessageHandler) {
        _appMessageHandler(d.data);
      }
      if (channel && channel.indexOf("webhooks.") === 0) {
        var hookName = channel.substring(9);
        var whCb = _webhookHandlers[hookName];
        if (whCb) whCb(d.data);
      }
      var listeners = _eventListeners[channel];
      if (listeners) {
        for (var i = 0; i < listeners.length; i++) {
          try { listeners[i](d.data); } catch(e) { console.error("Event handler error:", e); }
        }
      }
    }

    else if (d.type === "dench:tool-invoke") {
      var handler = _toolHandlers[d.toolName];
      if (handler) {
        Promise.resolve().then(function() {
          return handler(d.args);
        }).then(function(result) {
          window.parent.postMessage({
            type: "dench:tool-response",
            invokeId: d.invokeId,
            result: result
          }, "*");
        }).catch(function(err) {
          window.parent.postMessage({
            type: "dench:tool-response",
            invokeId: d.invokeId,
            error: err.message || "Tool handler failed"
          }, "*");
        });
      }
    }
  });

  window.dench = {
    db: {
      query: function(sql) { return sendRequest("db.query", { sql: sql }); },
      execute: function(sql) { return sendRequest("db.execute", { sql: sql }); }
    },
    objects: {
      list: function(name, opts) { return sendRequest("objects.list", Object.assign({ name: name }, opts || {})); },
      get: function(name, entryId) { return sendRequest("objects.get", { name: name, entryId: entryId }); },
      create: function(name, fields) { return sendRequest("objects.create", { name: name, fields: fields }); },
      update: function(name, entryId, fields) { return sendRequest("objects.update", { name: name, entryId: entryId, fields: fields }); },
      delete: function(name, entryId) { return sendRequest("objects.delete", { name: name, entryId: entryId }); },
      bulkDelete: function(name, entryIds) { return sendRequest("objects.bulkDelete", { name: name, entryIds: entryIds }); },
      getSchema: function(name) { return sendRequest("objects.getSchema", { name: name }); },
      getOptions: function(name, query) { return sendRequest("objects.getOptions", { name: name, query: query }); }
    },
    files: {
      read: function(path) { return sendRequest("files.read", { path: path }); },
      list: function(dir) { return sendRequest("files.list", { dir: dir }); },
      write: function(path, content) { return sendRequest("files.write", { path: path, content: content }); },
      delete: function(path) { return sendRequest("files.delete", { path: path }); },
      mkdir: function(path) { return sendRequest("files.mkdir", { path: path }); }
    },
    app: {
      getManifest: function() { return sendRequest("app.getManifest"); },
      getTheme: function() { return sendRequest("app.getTheme"); }
    },
    chat: {
      createSession: function(title) { return sendRequest("chat.createSession", { title: title }); },
      send: function(sessionId, message, opts) {
        if (opts && opts.onEvent) {
          return sendStreamRequest("chat.send", { sessionId: sessionId, message: message }, opts.onEvent);
        }
        return sendRequest("chat.send", { sessionId: sessionId, message: message });
      },
      getHistory: function(sessionId) { return sendRequest("chat.getHistory", { sessionId: sessionId }); },
      getSessions: function(opts) { return sendRequest("chat.getSessions", opts || {}); },
      abort: function(sessionId) { return sendRequest("chat.abort", { sessionId: sessionId }); },
      isActive: function(sessionId) { return sendRequest("chat.isActive", { sessionId: sessionId }); }
    },
    agent: {
      send: function(message) { return sendRequest("agent.send", { message: message }); }
    },
    tool: {
      register: function(name, handler) {
        _toolHandlers[name] = handler;
        return sendRequest("tool.register", { name: name });
      }
    },
    memory: {
      get: function() { return sendRequest("memory.get"); }
    },
    ui: {
      toast: function(message, opts) { return sendRequest("ui.toast", Object.assign({ message: message }, opts || {})); },
      navigate: function(path) { return sendRequest("ui.navigate", { path: path }); },
      openEntry: function(objectName, entryId) { return sendRequest("ui.openEntry", { objectName: objectName, entryId: entryId }); },
      setTitle: function(title) { return sendRequest("ui.setTitle", { title: title }); },
      confirm: function(message) { return sendRequest("ui.confirm", { message: message }); },
      prompt: function(message, defaultValue) { return sendRequest("ui.prompt", { message: message, defaultValue: defaultValue }); }
    },
    store: {
      get: function(key) { return sendRequest("store.get", { key: key }); },
      set: function(key, value) { return sendRequest("store.set", { key: key, value: value }); },
      delete: function(key) { return sendRequest("store.delete", { key: key }); },
      list: function() { return sendRequest("store.list"); },
      clear: function() { return sendRequest("store.clear"); }
    },
    http: {
      fetch: function(url, opts) { return sendRequest("http.fetch", Object.assign({ url: url }, opts || {})); }
    },
    events: {
      on: function(channel, callback) {
        if (!_eventListeners[channel]) _eventListeners[channel] = [];
        _eventListeners[channel].push(callback);
        sendRequest("events.subscribe", { channel: channel }).catch(function() {});
      },
      off: function(channel, callback) {
        if (!callback) {
          delete _eventListeners[channel];
        } else if (_eventListeners[channel]) {
          _eventListeners[channel] = _eventListeners[channel].filter(function(cb) { return cb !== callback; });
          if (_eventListeners[channel].length === 0) delete _eventListeners[channel];
        }
        sendRequest("events.unsubscribe", { channel: channel }).catch(function() {});
      }
    },
    context: {
      getWorkspace: function() { return sendRequest("context.getWorkspace"); },
      getAppInfo: function() { return sendRequest("context.getAppInfo"); }
    },
    apps: {
      send: function(targetApp, message) { return sendRequest("apps.send", { targetApp: targetApp, message: message }); },
      on: function(eventType, callback) {
        if (eventType === "message") _appMessageHandler = callback;
      },
      list: function() { return sendRequest("apps.list"); }
    },
    cron: {
      schedule: function(opts) { return sendRequest("cron.schedule", opts); },
      list: function() { return sendRequest("cron.list"); },
      run: function(jobId) { return sendRequest("cron.run", { jobId: jobId }); },
      cancel: function(jobId) { return sendRequest("cron.cancel", { jobId: jobId }); }
    },
    webhooks: {
      register: function(hookName) { return sendRequest("webhooks.register", { hookName: hookName }); },
      on: function(hookName, callback) {
        _webhookHandlers[hookName] = callback;
        sendRequest("webhooks.subscribe", { hookName: hookName }).catch(function() {});
      },
      poll: function(hookName, opts) { return sendRequest("webhooks.poll", Object.assign({ hookName: hookName }, opts || {})); }
    },
    clipboard: {
      read: function() { return sendRequest("clipboard.read"); },
      write: function(text) { return sendRequest("clipboard.write", { text: text }); }
    }
  };
})();
</script>`;return a.includes("</head>")?a.replace("</head>",`${b}
</head>`):a.includes("<head>")?a.replace("<head>",`<head>
${b}`):`${b}
${a}`}c.d(b,{M:()=>d})},449714:()=>{},529294:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-async-storage.external.js")},584905:(a,b,c)=>{"use strict";c.r(b),c.d(b,{handler:()=>I,patchFetch:()=>H,routeModule:()=>D,serverHooks:()=>G,workAsyncStorage:()=>E,workUnitAsyncStorage:()=>F});var d={};c.r(d),c.d(d,{GET:()=>C,dynamic:()=>y,runtime:()=>z});var e=c(940527),f=c(41752),g=c(633335),h=c(573615),i=c(301769),j=c(200261),k=c(405563),l=c(439285),m=c(443399),n=c(295860),o=c(161730),p=c(728392),q=c(976618),r=c(406527),s=c(986439),t=c(975973),u=c(51455),v=c(176760),w=c(693349),x=c(325306);let y="force-dynamic",z="nodejs",A={".html":"text/html; charset=utf-8",".htm":"text/html; charset=utf-8",".css":"text/css; charset=utf-8",".js":"application/javascript; charset=utf-8",".mjs":"application/javascript; charset=utf-8",".json":"application/json; charset=utf-8",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".webp":"image/webp",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".wasm":"application/wasm",".map":"application/json",".txt":"text/plain; charset=utf-8",".md":"text/markdown; charset=utf-8",".xml":"application/xml",".yaml":"text/yaml; charset=utf-8",".yml":"text/yaml; charset=utf-8"};async function B(a){try{return await (0,u.access)(a),!0}catch{return!1}}async function C(a,{params:b}){let{path:c}=await b,d=function(a){let b=a.join("/"),c=".dench.app",d=b.indexOf(c);if(-1===d)return null;let e=d+c.length;return{appPath:b.slice(0,e),filePath:b.slice(e+1)||"index.html"}}(c);if(!d)return Response.json({error:"Invalid app path — must contain .dench.app"},{status:400});let{appPath:e,filePath:f}=d,g=(0,w.Yn)();if(!g)return Response.json({error:"No workspace configured"},{status:404});let h=(0,v.resolve)((0,v.join)(g,e)),i=(0,v.relative)(g,h);if(i.startsWith("..")||i.startsWith("/"))return Response.json({error:"Path traversal denied"},{status:403});let j=(0,v.resolve)((0,v.join)(h,f)),k=(0,v.relative)(h,j);if(k.startsWith("..")||k.startsWith("/"))return Response.json({error:"Path traversal denied"},{status:403});if(!await B(j))return Response.json({error:"File not found"},{status:404});try{if(!(await (0,u.stat)(j)).isFile())return Response.json({error:"Not a file"},{status:400});let a=A[(0,v.extname)(f).toLowerCase()]||"application/octet-stream",b=(0,v.extname)(f).toLowerCase();if(".html"===b||".htm"===b){let b=await (0,u.readFile)(j,"utf-8"),c=(0,x.M)(b);return new Response(c,{status:200,headers:{"Content-Type":a,"Cache-Control":"no-cache","X-Content-Type-Options":"nosniff"}})}let c=await (0,u.readFile)(j);return new Response(c,{status:200,headers:{"Content-Type":a,"Content-Length":String(c.length),"Cache-Control":"no-cache","X-Content-Type-Options":"nosniff"}})}catch{return Response.json({error:"Failed to read file"},{status:500})}}let D=new e.AppRouteRouteModule({definition:{kind:f.RouteKind.APP_ROUTE,page:"/api/apps/serve/[...path]/route",pathname:"/api/apps/serve/[...path]",filename:"route",bundlePath:"app/api/apps/serve/[...path]/route"},distDir:".next",relativeProjectDir:"",resolvedPagePath:"/home/runner/work/DenchClaw/DenchClaw/apps/web/app/api/apps/serve/[...path]/route.ts",nextConfigOutput:"standalone",userland:d}),{workAsyncStorage:E,workUnitAsyncStorage:F,serverHooks:G}=D;function H(){return(0,g.patchFetch)({workAsyncStorage:E,workUnitAsyncStorage:F})}async function I(a,b,c){var d;let e="/api/apps/serve/[...path]/route";"/index"===e&&(e="/");let g=await D.prepare(a,b,{srcPage:e,multiZoneDraftMode:!1});if(!g)return b.statusCode=400,b.end("Bad Request"),null==c.waitUntil||c.waitUntil.call(c,Promise.resolve()),null;let{buildId:u,params:v,nextConfig:w,isDraftMode:x,prerenderManifest:y,routerServerContext:z,isOnDemandRevalidate:A,revalidateOnlyGenerated:B,resolvedPathname:C}=g,E=(0,j.normalizeAppPath)(e),F=!!(y.dynamicRoutes[E]||y.routes[C]);if(F&&!x){let a=!!y.routes[C],b=y.dynamicRoutes[E];if(b&&!1===b.fallback&&!a)throw new s.NoFallbackError}let G=null;!F||D.isDev||x||(G="/index"===(G=C)?"/":G);let H=!0===D.isDev||!F,I=F&&!H,J=a.method||"GET",K=(0,i.getTracer)(),L=K.getActiveScopeSpan(),M={params:v,prerenderManifest:y,renderOpts:{experimental:{cacheComponents:!!w.experimental.cacheComponents,authInterrupts:!!w.experimental.authInterrupts},supportsDynamicResponse:H,incrementalCache:(0,h.getRequestMeta)(a,"incrementalCache"),cacheLifeProfiles:null==(d=w.experimental)?void 0:d.cacheLife,isRevalidate:I,waitUntil:c.waitUntil,onClose:a=>{b.on("close",a)},onAfterTaskError:void 0,onInstrumentationRequestError:(b,c,d)=>D.onRequestError(a,b,d,z)},sharedContext:{buildId:u}},N=new k.NodeNextRequest(a),O=new k.NodeNextResponse(b),P=l.NextRequestAdapter.fromNodeNextRequest(N,(0,l.signalFromNodeResponse)(b));try{let d=async c=>D.handle(P,M).finally(()=>{if(!c)return;c.setAttributes({"http.status_code":b.statusCode,"next.rsc":!1});let d=K.getRootSpanAttributes();if(!d)return;if(d.get("next.span_type")!==m.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${d.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let e=d.get("next.route");if(e){let a=`${J} ${e}`;c.setAttributes({"next.route":e,"http.route":e,"next.span_name":a}),c.updateName(a)}else c.updateName(`${J} ${a.url}`)}),g=async g=>{var i,j;let k=async({previousCacheEntry:f})=>{try{if(!(0,h.getRequestMeta)(a,"minimalMode")&&A&&B&&!f)return b.statusCode=404,b.setHeader("x-nextjs-cache","REVALIDATED"),b.end("This page could not be found"),null;let e=await d(g);a.fetchMetrics=M.renderOpts.fetchMetrics;let i=M.renderOpts.pendingWaitUntil;i&&c.waitUntil&&(c.waitUntil(i),i=void 0);let j=M.renderOpts.collectedTags;if(!F)return await (0,o.I)(N,O,e,M.renderOpts.pendingWaitUntil),null;{let a=await e.blob(),b=(0,p.toNodeOutgoingHttpHeaders)(e.headers);j&&(b[r.NEXT_CACHE_TAGS_HEADER]=j),!b["content-type"]&&a.type&&(b["content-type"]=a.type);let c=void 0!==M.renderOpts.collectedRevalidate&&!(M.renderOpts.collectedRevalidate>=r.INFINITE_CACHE)&&M.renderOpts.collectedRevalidate,d=void 0===M.renderOpts.collectedExpire||M.renderOpts.collectedExpire>=r.INFINITE_CACHE?void 0:M.renderOpts.collectedExpire;return{value:{kind:t.CachedRouteKind.APP_ROUTE,status:e.status,body:Buffer.from(await a.arrayBuffer()),headers:b},cacheControl:{revalidate:c,expire:d}}}}catch(b){throw(null==f?void 0:f.isStale)&&await D.onRequestError(a,b,{routerKind:"App Router",routePath:e,routeType:"route",revalidateReason:(0,n.c)({isRevalidate:I,isOnDemandRevalidate:A})},z),b}},l=await D.handleResponse({req:a,nextConfig:w,cacheKey:G,routeKind:f.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:y,isRoutePPREnabled:!1,isOnDemandRevalidate:A,revalidateOnlyGenerated:B,responseGenerator:k,waitUntil:c.waitUntil});if(!F)return null;if((null==l||null==(i=l.value)?void 0:i.kind)!==t.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==l||null==(j=l.value)?void 0:j.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});(0,h.getRequestMeta)(a,"minimalMode")||b.setHeader("x-nextjs-cache",A?"REVALIDATED":l.isMiss?"MISS":l.isStale?"STALE":"HIT"),x&&b.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let m=(0,p.fromNodeOutgoingHttpHeaders)(l.value.headers);return(0,h.getRequestMeta)(a,"minimalMode")&&F||m.delete(r.NEXT_CACHE_TAGS_HEADER),!l.cacheControl||b.getHeader("Cache-Control")||m.get("Cache-Control")||m.set("Cache-Control",(0,q.getCacheControlHeader)(l.cacheControl)),await (0,o.I)(N,O,new Response(l.value.body,{headers:m,status:l.value.status||200})),null};L?await g(L):await K.withPropagatedContext(a.headers,()=>K.trace(m.BaseServerSpan.handleRequest,{spanName:`${J} ${a.url}`,kind:i.SpanKind.SERVER,attributes:{"http.method":J,"http.target":a.url}},g))}catch(b){if(b instanceof s.NoFallbackError||await D.onRequestError(a,b,{routerKind:"App Router",routePath:E,routeType:"route",revalidateReason:(0,n.c)({isRevalidate:I,isOnDemandRevalidate:A})}),F)throw b;return await (0,o.I)(N,O,new Response(null,{status:500})),null}}},663033:a=>{"use strict";a.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},709962:()=>{},710846:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},719771:a=>{"use strict";a.exports=require("process")},731421:a=>{"use strict";a.exports=require("node:child_process")},744870:a=>{"use strict";a.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},848161:a=>{"use strict";a.exports=require("node:os")},940527:(a,b,c)=>{"use strict";a.exports=c(744870)},973024:a=>{"use strict";a.exports=require("node:fs")},979428:a=>{"use strict";a.exports=require("buffer")},986439:a=>{"use strict";a.exports=require("next/dist/shared/lib/no-fallback-error.external")}};var b=require("../../../../../webpack-runtime.js");b.C(a);var c=b.X(0,[76973,22137,93349],()=>b(b.s=584905));module.exports=c})();