ohwow 0.2.0 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +239 -86
- package/dist/index.js +1064 -692
- package/dist/mcp-server/index.js +64 -10
- package/dist/migrations/057-persona-soul.sql +20 -0
- package/dist/migrations/058-turboquant-stats.sql +11 -0
- package/dist/migrations/059-claude-code-sessions.sql +18 -0
- package/dist/migrations/060-consciousness-items.sql +25 -0
- package/dist/migrations/061-affect-system.sql +28 -0
- package/dist/migrations/062-endocrine-system.sql +10 -0
- package/dist/migrations/063-homeostasis.sql +24 -0
- package/dist/migrations/064-oneiros.sql +25 -0
- package/dist/migrations/065-immune-system.sql +39 -0
- package/dist/migrations/066-narrative.sql +29 -0
- package/dist/migrations/067-ethos.sql +27 -0
- package/dist/migrations/068-hexis.sql +29 -0
- package/dist/web/assets/index-CzPQPzpE.js +100 -0
- package/dist/web/assets/index-D_dz8KjO.css +1 -0
- package/dist/web/index.html +2 -2
- package/package.json +6 -1
- package/dist/web/assets/index-1Wga6dwZ.css +0 -1
- package/dist/web/assets/index-BHeLTE3N.js +0 -100
package/dist/mcp-server/index.js
CHANGED
|
@@ -1,11 +1,65 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{McpServer as
|
|
3
|
-
`);
|
|
4
|
-
[Using tool: ${
|
|
5
|
-
`);else if(
|
|
6
|
-
[Error: ${
|
|
7
|
-
`);else if(
|
|
8
|
-
[Response timed out after 120s]`;throw s}finally{clearTimeout(a)}}};import{z as p}from"zod";function x(n,r){n.tool("ohwow_chat","Send a message to the OHWOW orchestrator. It has 100+ internal tools and can run agents, manage tasks, scrape websites, research topics, manage CRM, create workflows, and more. Use this for complex or multi-step requests.",{message:p.string().describe("The message or instruction to send to the orchestrator")},async({message:t})=>{try{return{content:[{type:"text",text:await r.postSSE("/api/chat",{message:t})||"No response from orchestrator"}]}}catch(e){return{content:[{type:"text",text:`Error: ${e instanceof Error?e.message:"Unknown error"}`}],isError:!0}}}),n.tool("ohwow_list_agents","List all agents in the OHWOW workspace with their status, role, and capabilities.",{},async()=>{try{let t=await r.get("/api/agents"),e=t.data||t;return{content:[{type:"text",text:JSON.stringify(e,null,2)}]}}catch(t){return{content:[{type:"text",text:`Error: ${t instanceof Error?t.message:"Unknown error"}`}],isError:!0}}}),n.tool("ohwow_run_agent","Execute a specific agent with a prompt. Returns a task ID you can use with ohwow_get_task to check the result.",{agentId:p.string().describe("The ID of the agent to run"),prompt:p.string().describe("The task or instruction for the agent")},async({agentId:t,prompt:e})=>{try{let o=await r.post("/api/tasks",{agentId:t,title:e});return{content:[{type:"text",text:JSON.stringify(o,null,2)}]}}catch(o){return{content:[{type:"text",text:`Error: ${o instanceof Error?o.message:"Unknown error"}`}],isError:!0}}}),n.tool("ohwow_get_task","Get the status and result of a task by its ID.",{taskId:p.string().describe("The task ID to look up")},async({taskId:t})=>{try{let e=await r.get(`/api/tasks/${t}`);return{content:[{type:"text",text:JSON.stringify(e,null,2)}]}}catch(e){return{content:[{type:"text",text:`Error: ${e instanceof Error?e.message:"Unknown error"}`}],isError:!0}}}),n.tool("ohwow_list_tasks","List recent tasks. Optionally filter by status or agent.",{status:p.string().optional().describe("Filter by status: pending, running, completed, failed"),agentId:p.string().optional().describe("Filter by agent ID"),limit:p.number().optional().describe("Max number of tasks to return (default: 20)")},async({status:t,agentId:e,limit:o})=>{try{let a=new URLSearchParams;t&&a.set("status",t),e&&a.set("agentId",e),o&&a.set("limit",String(o));let i=a.toString(),h=await r.get(`/api/tasks${i?`?${i}`:""}`);return{content:[{type:"text",text:JSON.stringify(h,null,2)}]}}catch(a){return{content:[{type:"text",text:`Error: ${a instanceof Error?a.message:"Unknown error"}`}],isError:!0}}}),n.tool("ohwow_workspace_status","Get workspace status: agent count, uptime, tier, and system stats.",{},async()=>{try{let t=await r.get("/api/dashboard/init");return{content:[{type:"text",text:JSON.stringify(t,null,2)}]}}catch(t){return{content:[{type:"text",text:`Error: ${t instanceof Error?t.message:"Unknown error"}`}],isError:!0}}})}function E(n,r){n.resource("agents","ohwow://agents",{description:"All OHWOW agents with their descriptions, roles, and available tools"},async()=>{try{let t=await r.get("/api/agents"),e=t.data||t;return{contents:[{uri:"ohwow://agents",mimeType:"application/json",text:JSON.stringify(e,null,2)}]}}catch{return{contents:[{uri:"ohwow://agents",mimeType:"text/plain",text:"Could not load agents. Is the OHWOW daemon running?"}]}}}),n.resource("workspace","ohwow://workspace",{description:"OHWOW workspace status: tier, uptime, agent count, system stats"},async()=>{try{let t=await r.get("/api/dashboard/init");return{contents:[{uri:"ohwow://workspace",mimeType:"application/json",text:JSON.stringify(t,null,2)}]}}catch{return{contents:[{uri:"ohwow://workspace",mimeType:"text/plain",text:"Could not load workspace status. Is the OHWOW daemon running?"}]}}})}var d="0.2.0";async function F(){let n;try{n=await u.create()}catch(o){process.stderr.write(`[ohwow-mcp] ${o instanceof Error?o.message:"Unknown error"}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
import{McpServer as Q}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as X}from"@modelcontextprotocol/sdk/server/stdio.js";import{readFileSync as f,existsSync as C}from"fs";import{join as x}from"path";import{homedir as H}from"os";var g=class n{constructor(o,t,e){this.baseUrl=`http://127.0.0.1:${o}`,this.token=t,this.tokenPath=e}static async create(){let o=x(H(),".ohwow"),t=x(o,"config.json"),e=x(o,"data","daemon.token"),r=7700;if(C(t))try{let c=f(t,"utf-8"),a=JSON.parse(c);a.port&&(r=a.port)}catch{}if(!C(e))throw new Error("OHWOW daemon is not running. Start it with: ohwow");let s=f(e,"utf-8").trim();if(!s)throw new Error("Couldn't authenticate with OHWOW daemon. Try: ohwow restart");let i=new n(r,s,e);try{await i.get("/health")}catch{throw new Error("OHWOW daemon is not running. Start it with: ohwow")}return i}refreshToken(){try{let o=f(this.tokenPath,"utf-8").trim();if(o&&o!==this.token)return this.token=o,!0}catch{}return!1}authHeaders(){return{Authorization:`Bearer ${this.token}`}}async fetchWithRetry(o,t){let e=await fetch(o,t);if(e.status===401&&this.refreshToken()){let r={...t.headers,...this.authHeaders()};e=await fetch(o,{...t,headers:r})}return e}async get(o){let t=await this.fetchWithRetry(`${this.baseUrl}${o}`,{headers:this.authHeaders()});if(!t.ok)throw new Error(`ohwow daemon error on GET ${o}: ${t.status}. Check daemon with: ohwow logs`);return t.json()}async post(o,t){let e=await this.fetchWithRetry(`${this.baseUrl}${o}`,{method:"POST",headers:{...this.authHeaders(),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!e.ok)throw new Error(`ohwow daemon error on POST ${o}: ${e.status}. Check daemon with: ohwow logs`);return e.json()}async postSSE(o,t,e=12e4){let r=new AbortController,s=setTimeout(()=>r.abort(),e),i=[],c=async()=>fetch(`${this.baseUrl}${o}`,{method:"POST",headers:{...this.authHeaders(),"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(t),signal:r.signal});try{let a=await c();if(a.status===401&&this.refreshToken()&&(a=await c()),!a.ok)throw new Error(`Daemon API error: ${a.status} ${a.statusText}`);if(!a.body)throw new Error("No response body from daemon");let p=a.body.getReader(),b=new TextDecoder,m="";for(;;){let{done:w,value:L}=await p.read();if(w)break;m+=b.decode(L,{stream:!0});let R=m.split(`
|
|
3
|
+
`);m=R.pop()||"";for(let T of R){if(!T.startsWith("data: "))continue;let O=T.slice(6).trim();if(O!=="[DONE]")try{let u=JSON.parse(O);if(u.type==="text"&&u.content)i.push(u.content);else if(u.type==="tool_start")i.push(`
|
|
4
|
+
[Using tool: ${u.name}]
|
|
5
|
+
`);else if(u.type==="error")i.push(`
|
|
6
|
+
[Error: ${u.error}]
|
|
7
|
+
`);else if(u.type==="done")break}catch{}}}return i.join("")}catch(a){if(a instanceof Error&&a.name==="AbortError")return i.join("")+`
|
|
8
|
+
[Timed out after ${e/1e3}s. The task may still be running. Check with ohwow_list_tasks.]`;throw a}finally{clearTimeout(s)}}};import{z as h}from"zod";function $(n,o){n.tool("ohwow_chat","[Orchestrator] Send a message to the OHWOW orchestrator (88+ internal tools). Use this for: desktop control, automation creation, agent scheduling, approval management, agent state persistence, A2A protocol, PDF forms, media generation, and any multi-step request not covered by the direct tools. Do NOT use for simple listing or CRUD operations that have dedicated tools.",{message:h.string().describe("The message or instruction to send to the orchestrator")},async({message:t})=>{try{return{content:[{type:"text",text:await o.postSSE("/api/chat",{message:t})||"No response from orchestrator"}]}}catch(e){return{content:[{type:"text",text:`Error: ${e instanceof Error?e.message:"Unknown error"}`}],isError:!0}}}),n.tool("ohwow_list_agents","[Agents] List all agents in the OHWOW workspace with their status, role, and capabilities.",{},async()=>{try{let t=await o.get("/api/agents"),e=t.data||t;return{content:[{type:"text",text:JSON.stringify(e,null,2)}]}}catch(t){return{content:[{type:"text",text:`Error: ${t instanceof Error?t.message:"Unknown error"}`}],isError:!0}}}),n.tool("ohwow_run_agent","[Agents] Execute a specific agent with a prompt. Returns a task ID immediately (execution is async). Use ohwow_get_task to poll for status and result. Use ohwow_list_agents to find agent IDs.",{agentId:h.string().describe("The ID of the agent to run"),prompt:h.string().describe("The task or instruction for the agent")},async({agentId:t,prompt:e})=>{try{let r=await o.post("/api/tasks",{agentId:t,title:e});return{content:[{type:"text",text:JSON.stringify(r,null,2)}]}}catch(r){return{content:[{type:"text",text:`Error: ${r instanceof Error?r.message:"Unknown error"}`}],isError:!0}}}),n.tool("ohwow_get_task","[Tasks] Get the status and result of a task by its ID.",{taskId:h.string().describe("The task ID to look up")},async({taskId:t})=>{try{let e=await o.get(`/api/tasks/${t}`);return{content:[{type:"text",text:JSON.stringify(e,null,2)}]}}catch(e){return{content:[{type:"text",text:`Error: ${e instanceof Error?e.message:"Unknown error"}`}],isError:!0}}}),n.tool("ohwow_list_tasks","[Tasks] List recent tasks. Optionally filter by status or agent.",{status:h.string().optional().describe("Filter by status: pending, running, completed, failed"),agentId:h.string().optional().describe("Filter by agent ID"),limit:h.number().optional().describe("Max number of tasks to return (default: 20)")},async({status:t,agentId:e,limit:r})=>{try{let s=new URLSearchParams;t&&s.set("status",t),e&&s.set("agentId",e),r&&s.set("limit",String(r));let i=s.toString(),c=await o.get(`/api/tasks${i?`?${i}`:""}`);return{content:[{type:"text",text:JSON.stringify(c,null,2)}]}}catch(s){return{content:[{type:"text",text:`Error: ${s instanceof Error?s.message:"Unknown error"}`}],isError:!0}}}),n.tool("ohwow_workspace_status","[Workspace] Get workspace status: agent count, uptime, tier, and system stats.",{},async()=>{try{let t=await o.get("/api/dashboard/init");return{content:[{type:"text",text:JSON.stringify(t,null,2)}]}}catch(t){return{content:[{type:"text",text:`Error: ${t instanceof Error?t.message:"Unknown error"}`}],isError:!0}}})}import{z as l}from"zod";function j(n,o){n.tool("ohwow_list_contacts","[CRM] List contacts in the workspace. Returns name, email, company, pipeline stage, and tags.",{search:l.string().optional().describe("Filter by name, email, or company"),limit:l.number().optional().describe("Max results (default: 50)")},async({search:t,limit:e})=>{try{let r=new URLSearchParams;t&&r.set("search",t),e&&r.set("limit",String(e));let s=r.toString(),i=await o.get(`/api/contacts${s?`?${s}`:""}`),c=i.data||i;return{content:[{type:"text",text:JSON.stringify(c,null,2)}]}}catch(r){return{content:[{type:"text",text:`Error: ${r instanceof Error?r.message:"Unknown error"}`}],isError:!0}}}),n.tool("ohwow_create_contact","[CRM] Add a new contact to the CRM.",{name:l.string().describe("Contact full name"),email:l.string().optional().describe("Email address"),phone:l.string().optional().describe("Phone number"),company:l.string().optional().describe("Company or organization"),tags:l.array(l.string()).optional().describe("Tags for categorization"),notes:l.string().optional().describe("Additional notes about the contact")},async({name:t,email:e,phone:r,company:s,tags:i,notes:c})=>{try{let a={name:t};e&&(a.email=e),r&&(a.phone=r),s&&(a.company=s),i&&(a.tags=i),c&&(a.notes=c);let p=await o.post("/api/contacts",a);return{content:[{type:"text",text:JSON.stringify(p,null,2)}]}}catch(a){return{content:[{type:"text",text:`Error: ${a instanceof Error?a.message:"Unknown error"}`}],isError:!0}}}),n.tool("ohwow_search_contacts","[CRM] Full-text search across contacts by name, email, company, or notes.",{query:l.string().describe("Search query")},async({query:t})=>{try{return{content:[{type:"text",text:await o.postSSE("/api/chat",{message:`Use the search_contacts tool with query: "${t}". Return the results as-is.`},15e3)||"No contacts found"}]}}catch(e){return{content:[{type:"text",text:`Error: ${e instanceof Error?e.message:"Unknown error"}`}],isError:!0}}})}import{z as d}from"zod";function v(n,o){n.tool("ohwow_list_workflows","[Workflows] List all workflows in the workspace with their steps and status.",{},async()=>{try{let t=await o.get("/api/workflows"),e=t.data||t;return{content:[{type:"text",text:JSON.stringify(e,null,2)}]}}catch(t){return{content:[{type:"text",text:`Error: ${t instanceof Error?t.message:"Unknown error"}`}],isError:!0}}}),n.tool("ohwow_run_workflow","[Workflows] Execute a workflow by ID. Use ohwow_list_workflows to find IDs. May take up to 60 seconds depending on complexity.",{workflowId:d.string().describe("The workflow ID to execute"),variables:d.record(d.string(),d.unknown()).optional().describe("Input variables for the workflow")},async({workflowId:t,variables:e})=>{try{let r=e?` with variables: ${JSON.stringify(e)}`:"";return{content:[{type:"text",text:await o.postSSE("/api/chat",{message:`Use the run_workflow tool with workflowId: "${t}"${r}.`},6e4)||"Workflow started"}]}}catch(r){return{content:[{type:"text",text:`Error: ${r instanceof Error?r.message:"Unknown error"}`}],isError:!0}}}),n.tool("ohwow_list_automations","[Automations] List all automations with their triggers and status.",{},async()=>{try{let t=await o.get("/api/automations"),e=t.data||t;return{content:[{type:"text",text:JSON.stringify(e,null,2)}]}}catch(t){return{content:[{type:"text",text:`Error: ${t instanceof Error?t.message:"Unknown error"}`}],isError:!0}}}),n.tool("ohwow_run_automation","[Automations] Manually trigger an automation by ID. Use ohwow_list_automations to find IDs.",{automationId:d.string().describe("The automation ID to trigger")},async({automationId:t})=>{try{let e=await o.post(`/api/automations/${t}/execute`,{});return{content:[{type:"text",text:JSON.stringify(e,null,2)}]}}catch(e){return{content:[{type:"text",text:`Error: ${e instanceof Error?e.message:"Unknown error"}`}],isError:!0}}})}import{z as A}from"zod";function U(n,o){n.tool("ohwow_list_projects","[Projects] List all projects with status and task counts.",{},async()=>{try{let t=await o.get("/api/projects"),e=t.data||t;return{content:[{type:"text",text:JSON.stringify(e,null,2)}]}}catch(t){return{content:[{type:"text",text:`Error: ${t instanceof Error?t.message:"Unknown error"}`}],isError:!0}}}),n.tool("ohwow_create_project","[Projects] Create a new project for organizing work.",{name:A.string().describe("Project name"),description:A.string().optional().describe("Project description")},async({name:t,description:e})=>{try{let r={name:t};e&&(r.description=e);let s=await o.post("/api/projects",r);return{content:[{type:"text",text:JSON.stringify(s,null,2)}]}}catch(r){return{content:[{type:"text",text:`Error: ${r instanceof Error?r.message:"Unknown error"}`}],isError:!0}}}),n.tool("ohwow_list_goals","[Goals] List workspace goals with progress tracking.",{},async()=>{try{return{content:[{type:"text",text:await o.postSSE("/api/chat",{message:"Use the list_goals tool. Return the results as-is."},15e3)||"No goals found"}]}}catch(t){return{content:[{type:"text",text:`Error: ${t instanceof Error?t.message:"Unknown error"}`}],isError:!0}}})}import{z as k}from"zod";function N(n,o){n.tool("ohwow_list_knowledge","[Knowledge] List all documents in the knowledge base.",{},async()=>{try{return{content:[{type:"text",text:await o.postSSE("/api/chat",{message:"Use the list_knowledge tool. Return the results as-is."},15e3)||"No knowledge documents found"}]}}catch(t){return{content:[{type:"text",text:`Error: ${t instanceof Error?t.message:"Unknown error"}`}],isError:!0}}}),n.tool("ohwow_search_knowledge","[Knowledge] Semantic search across the knowledge base. Returns relevant document chunks.",{query:k.string().describe("The search query")},async({query:t})=>{try{return{content:[{type:"text",text:await o.postSSE("/api/chat",{message:`Use the search_knowledge tool with query: "${t}". Return the results as-is.`},15e3)||"No results found"}]}}catch(e){return{content:[{type:"text",text:`Error: ${e instanceof Error?e.message:"Unknown error"}`}],isError:!0}}}),n.tool("ohwow_add_knowledge_url","[Knowledge] Add a web page to the knowledge base. Fetches, chunks, and embeds the content for later search.",{url:k.string().describe("The URL to ingest"),title:k.string().optional().describe("Optional title for the document")},async({url:t,title:e})=>{try{let r=e?` with title: "${e}"`:"";return{content:[{type:"text",text:await o.postSSE("/api/chat",{message:`Use the add_knowledge_from_url tool with url: "${t}"${r}.`},3e4)||"Knowledge document added"}]}}catch(r){return{content:[{type:"text",text:`Error: ${r instanceof Error?r.message:"Unknown error"}`}],isError:!0}}})}import{z as _}from"zod";function D(n,o){n.tool("ohwow_deep_research","[Research] Multi-source web research with synthesis. Timing: quick ~30s, thorough ~60s, comprehensive ~120s.",{question:_.string().describe("The research question"),depth:_.enum(["quick","thorough","comprehensive"]).optional().describe("Research depth (default: thorough)")},async({question:t,depth:e})=>{try{let r=e?` with depth: "${e}"`:"";return{content:[{type:"text",text:await o.postSSE("/api/chat",{message:`Use the deep_research tool with question: "${t}"${r}. Return the full research report.`},18e4)||"No research results"}]}}catch(r){return{content:[{type:"text",text:`Error: ${r instanceof Error?r.message:"Unknown error"}`}],isError:!0}}}),n.tool("ohwow_scrape_url","[Research] Scrape a web page and return its structured content. Automatically handles anti-bot protection.",{url:_.string().describe("The URL to scrape")},async({url:t})=>{try{return{content:[{type:"text",text:await o.postSSE("/api/chat",{message:`Use the scrape_url tool with url: "${t}". Return the scraped content.`},3e4)||"No content scraped"}]}}catch(e){return{content:[{type:"text",text:`Error: ${e instanceof Error?e.message:"Unknown error"}`}],isError:!0}}})}import{z as y}from"zod";function M(n,o){n.tool("ohwow_send_message","[Messaging] Send a message via WhatsApp or Telegram. Use ohwow_list_chats to find chat IDs. The channel must be connected in the ohwow dashboard first.",{channel:y.enum(["whatsapp","telegram"]).describe("Messaging channel"),chatId:y.string().describe("Chat or contact ID to send to"),message:y.string().describe("Message text to send")},async({channel:t,chatId:e,message:r})=>{try{let s=t==="whatsapp"?"send_whatsapp_message":"send_telegram_message";return{content:[{type:"text",text:await o.postSSE("/api/chat",{message:`Use the ${s} tool to send this message to chat "${e}": ${r}`},15e3)||"Message sent"}]}}catch(s){return{content:[{type:"text",text:`Error: ${s instanceof Error?s.message:"Unknown error"}`}],isError:!0}}}),n.tool("ohwow_list_chats","[Messaging] List connected chats for WhatsApp or Telegram.",{channel:y.enum(["whatsapp","telegram"]).describe("Messaging channel")},async({channel:t})=>{try{let e=t==="whatsapp"?"list_whatsapp_chats":"list_telegram_chats";return{content:[{type:"text",text:await o.postSSE("/api/chat",{message:`Use the ${e} tool. Return the results as-is.`},15e3)||"No chats found"}]}}catch(e){return{content:[{type:"text",text:`Error: ${e instanceof Error?e.message:"Unknown error"}`}],isError:!0}}})}function W(n,o){n.tool("ohwow_list_sites","[Cloud] List all sites on the ohwow.fun cloud dashboard with status and URLs. Requires cloud connection.",{},async()=>{try{let t=await o.get("/api/cloud/sites");if(t.cloudConnected===!1)return{content:[{type:"text",text:"Not connected to ohwow.fun. Run `ohwow connect` to link your cloud account."}]};let e=t.data||[];return{content:[{type:"text",text:JSON.stringify(e,null,2)}]}}catch(t){return{content:[{type:"text",text:`Error: ${t instanceof Error?t.message:"Unknown error"}`}],isError:!0}}}),n.tool("ohwow_list_integrations","[Cloud] List connected integrations (Gmail, GitHub, Stripe, etc.) and their status. Requires cloud connection.",{},async()=>{try{let t=await o.get("/api/cloud/integrations");if(t.cloudConnected===!1)return{content:[{type:"text",text:"Not connected to ohwow.fun. Run `ohwow connect` to link your cloud account."}]};let e=t.data||[];return{content:[{type:"text",text:JSON.stringify(e,null,2)}]}}catch(t){return{content:[{type:"text",text:`Error: ${t instanceof Error?t.message:"Unknown error"}`}],isError:!0}}})}function I(n,o){$(n,o),j(n,o),v(n,o),U(n,o),N(n,o),D(n,o),M(n,o),W(n,o)}function P(n,o){n.resource("agents","ohwow://agents",{description:"All OHWOW agents with their descriptions, roles, and available tools"},async()=>{try{let t=await o.get("/api/agents"),e=t.data||t;return{contents:[{uri:"ohwow://agents",mimeType:"application/json",text:JSON.stringify(e,null,2)}]}}catch{return{contents:[{uri:"ohwow://agents",mimeType:"text/plain",text:"Could not load agents. Is the OHWOW daemon running?"}]}}}),n.resource("workspace","ohwow://workspace",{description:"OHWOW workspace status: tier, uptime, agent count, system stats"},async()=>{try{let t=await o.get("/api/dashboard/init");return{contents:[{uri:"ohwow://workspace",mimeType:"application/json",text:JSON.stringify(t,null,2)}]}}catch{return{contents:[{uri:"ohwow://workspace",mimeType:"text/plain",text:"Could not load workspace status. Is the OHWOW daemon running?"}]}}}),n.resource("contacts","ohwow://contacts",{description:"Recent CRM contacts with pipeline stage breakdown"},async()=>{try{let t=await o.get("/api/contacts?limit=10"),e=t.data||t;return{contents:[{uri:"ohwow://contacts",mimeType:"application/json",text:JSON.stringify(e,null,2)}]}}catch{return{contents:[{uri:"ohwow://contacts",mimeType:"text/plain",text:"Could not load contacts. Is the OHWOW daemon running?"}]}}}),n.resource("projects","ohwow://projects",{description:"Active projects with task counts and status"},async()=>{try{let t=await o.get("/api/projects"),e=t.data||t;return{contents:[{uri:"ohwow://projects",mimeType:"application/json",text:JSON.stringify(e,null,2)}]}}catch{return{contents:[{uri:"ohwow://projects",mimeType:"text/plain",text:"Could not load projects. Is the OHWOW daemon running?"}]}}}),n.resource("workflows","ohwow://workflows",{description:"Workflow and automation catalog with descriptions and trigger types"},async()=>{try{let[t,e]=await Promise.all([o.get("/api/workflows"),o.get("/api/automations")]),r=t.data||t,s=e.data||e;return{contents:[{uri:"ohwow://workflows",mimeType:"application/json",text:JSON.stringify({workflows:r,automations:s},null,2)}]}}catch{return{contents:[{uri:"ohwow://workflows",mimeType:"text/plain",text:"Could not load workflows. Is the OHWOW daemon running?"}]}}}),n.resource("capabilities","ohwow://capabilities",{description:"Complete list of all OHWOW MCP tools grouped by domain"},async()=>({contents:[{uri:"ohwow://capabilities",mimeType:"text/plain",text:q}]}))}var q=`OHWOW MCP Plugin \u2014 Quick Reference
|
|
9
|
+
|
|
10
|
+
GETTING STARTED
|
|
11
|
+
1. ohwow_workspace_status Check connection and workspace overview
|
|
12
|
+
2. ohwow_list_agents See available AI agents
|
|
13
|
+
3. ohwow_run_agent Run an agent (returns task ID)
|
|
14
|
+
4. ohwow_get_task Poll for task result
|
|
15
|
+
|
|
16
|
+
CORE (instant)
|
|
17
|
+
ohwow_chat Orchestrator: desktop control, scheduling, approvals, A2A, PDF, and 80+ more
|
|
18
|
+
ohwow_list_agents List all agents
|
|
19
|
+
ohwow_run_agent Run agent (async; poll with ohwow_get_task)
|
|
20
|
+
ohwow_get_task Check task status and result
|
|
21
|
+
ohwow_list_tasks Recent tasks with filters
|
|
22
|
+
ohwow_workspace_status Agent count, uptime, tier
|
|
23
|
+
|
|
24
|
+
CRM (instant)
|
|
25
|
+
ohwow_list_contacts List/filter contacts
|
|
26
|
+
ohwow_create_contact Add contact
|
|
27
|
+
ohwow_search_contacts Full-text search (~5s)
|
|
28
|
+
|
|
29
|
+
WORKFLOWS (instant unless noted)
|
|
30
|
+
ohwow_list_workflows List workflows
|
|
31
|
+
ohwow_run_workflow Run workflow (~10-60s)
|
|
32
|
+
ohwow_list_automations List automations
|
|
33
|
+
ohwow_run_automation Trigger automation
|
|
34
|
+
|
|
35
|
+
PROJECTS (instant)
|
|
36
|
+
ohwow_list_projects List projects
|
|
37
|
+
ohwow_create_project Create project
|
|
38
|
+
ohwow_list_goals List goals (~5s)
|
|
39
|
+
|
|
40
|
+
KNOWLEDGE (~5-30s)
|
|
41
|
+
ohwow_list_knowledge List documents
|
|
42
|
+
ohwow_search_knowledge Semantic search
|
|
43
|
+
ohwow_add_knowledge_url Ingest web page
|
|
44
|
+
|
|
45
|
+
RESEARCH (slow)
|
|
46
|
+
ohwow_deep_research Web research (30-120s depending on depth)
|
|
47
|
+
ohwow_scrape_url Scrape page (~10s)
|
|
48
|
+
|
|
49
|
+
MESSAGING (~5s)
|
|
50
|
+
ohwow_send_message Send WhatsApp/Telegram (channel must be connected)
|
|
51
|
+
ohwow_list_chats List connected chats
|
|
52
|
+
|
|
53
|
+
CLOUD (instant, requires ohwow.fun)
|
|
54
|
+
ohwow_list_sites Cloud sites
|
|
55
|
+
ohwow_list_integrations Connected services
|
|
56
|
+
|
|
57
|
+
USE ohwow_chat FOR: desktop control, scheduling, agent state, approvals,
|
|
58
|
+
A2A protocol, PDF forms, media generation, automation creation, and
|
|
59
|
+
anything not listed above.
|
|
60
|
+
`;import{createServer as F}from"http";import{writeFileSync as G,unlinkSync as z,existsSync as K}from"fs";import{join as B}from"path";import{homedir as V}from"os";var S=B(V(),".ohwow","data","mcp-sampling.port");function J(n){let o=null,t=F(async(r,s)=>{if(r.method!=="POST"||r.url!=="/sampling"){s.writeHead(404),s.end("Not found");return}let i="";for await(let a of r)i+=a;let c;try{c=JSON.parse(i)}catch{s.writeHead(400),s.end(JSON.stringify({error:"Invalid JSON"}));return}if(!c.messages?.length){s.writeHead(400),s.end(JSON.stringify({error:"messages array is required"}));return}try{let a=c.messages.map(w=>({role:w.role,content:{type:"text",text:w.content}})),p=await n.server.createMessage({messages:a,systemPrompt:c.systemPrompt,maxTokens:c.maxTokens||4096,temperature:c.temperature}),m={content:Array.isArray(p.content)?p.content.filter(w=>w.type==="text").map(w=>w.text).join(""):typeof p.content=="object"&&"text"in p.content?p.content.text:String(p.content),model:p.model,stopReason:p.stopReason??void 0};s.writeHead(200,{"Content-Type":"application/json"}),s.end(JSON.stringify(m))}catch(a){let p=a instanceof Error?a.message:"Sampling failed";s.writeHead(500),s.end(JSON.stringify({error:p}))}});return o=t,t.listen(0,"127.0.0.1",()=>{let r=t.address();if(r&&typeof r=="object"){let s=r.port;try{G(S,String(s)),process.stderr.write(`[ohwow-mcp] Sampling bridge listening on port ${s}
|
|
61
|
+
`)}catch{process.stderr.write(`[ohwow-mcp] Could not write sampling port file
|
|
62
|
+
`)}}}),{cleanup:()=>{o&&(o.close(),o=null);try{K(S)&&z(S)}catch{}}}}var E="0.2.0";async function Jt(){let n;try{n=await g.create()}catch(s){process.stderr.write(`[ohwow-mcp] ${s instanceof Error?s.message:"Unknown error"}
|
|
63
|
+
`),process.exit(1)}let o=new Q({name:"ohwow",version:E});I(o,n),P(o,n);let t=new X,e=null,r=async()=>{e?.();try{await o.close()}catch{}process.exit(0)};process.on("SIGTERM",r),process.on("SIGINT",r);try{await o.connect(t),process.stderr.write(`[ohwow-mcp] Connected (v${E})
|
|
64
|
+
`),e=J(o).cleanup}catch(s){process.stderr.write(`[ohwow-mcp] Failed to connect: ${s instanceof Error?s.message:"Unknown error"}
|
|
65
|
+
`),process.exit(1)}}export{Jt as startMcpServer};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
-- Soul Layer: persona observations and cached model
|
|
2
|
+
-- Layer 5 of the philosophical architecture (Aristotle's Psyche)
|
|
3
|
+
|
|
4
|
+
CREATE TABLE IF NOT EXISTS persona_observations (
|
|
5
|
+
id TEXT PRIMARY KEY,
|
|
6
|
+
event_type TEXT NOT NULL,
|
|
7
|
+
timestamp INTEGER NOT NULL,
|
|
8
|
+
metadata TEXT NOT NULL DEFAULT '{}',
|
|
9
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
CREATE INDEX IF NOT EXISTS idx_persona_obs_type_time
|
|
13
|
+
ON persona_observations(event_type, timestamp);
|
|
14
|
+
|
|
15
|
+
CREATE TABLE IF NOT EXISTS persona_model (
|
|
16
|
+
id TEXT PRIMARY KEY DEFAULT 'default',
|
|
17
|
+
model TEXT NOT NULL DEFAULT '{}',
|
|
18
|
+
data_points INTEGER DEFAULT 0,
|
|
19
|
+
updated_at TEXT DEFAULT (datetime('now'))
|
|
20
|
+
);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
-- TurboQuant KV cache compression statistics
|
|
2
|
+
-- Tracks compression performance per model for monitoring and display
|
|
3
|
+
|
|
4
|
+
CREATE TABLE IF NOT EXISTS turboquant_stats (
|
|
5
|
+
model_name TEXT PRIMARY KEY,
|
|
6
|
+
compression_ratio REAL,
|
|
7
|
+
effective_context_tokens INTEGER,
|
|
8
|
+
baseline_context_tokens INTEGER,
|
|
9
|
+
bits_per_value INTEGER DEFAULT 4,
|
|
10
|
+
last_updated TEXT DEFAULT (datetime('now'))
|
|
11
|
+
);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
-- Claude Code CLI session persistence for --resume support
|
|
2
|
+
-- Stores session IDs per agent with working directory awareness
|
|
3
|
+
|
|
4
|
+
-- @statement
|
|
5
|
+
CREATE TABLE IF NOT EXISTS claude_code_sessions (
|
|
6
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
7
|
+
agent_id TEXT NOT NULL,
|
|
8
|
+
workspace_id TEXT NOT NULL,
|
|
9
|
+
claude_session_id TEXT NOT NULL,
|
|
10
|
+
working_directory TEXT,
|
|
11
|
+
created_at TEXT DEFAULT (datetime('now')),
|
|
12
|
+
last_used_at TEXT DEFAULT (datetime('now')),
|
|
13
|
+
status TEXT DEFAULT 'active' CHECK (status IN ('active', 'stale', 'failed'))
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
-- @statement
|
|
17
|
+
CREATE INDEX IF NOT EXISTS idx_cc_sessions_agent
|
|
18
|
+
ON claude_code_sessions(agent_id, status);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
-- Consciousness Items — Shared consciousness between local and cloud.
|
|
2
|
+
-- Schema matches the cloud's consciousness_items Supabase table.
|
|
3
|
+
-- Categories: alert, insight, prediction, milestone, anomaly
|
|
4
|
+
-- Local workspace types map to cloud categories:
|
|
5
|
+
-- failure/warning → alert
|
|
6
|
+
-- discovery/pattern → insight
|
|
7
|
+
-- skill → milestone
|
|
8
|
+
-- signal → prediction
|
|
9
|
+
|
|
10
|
+
CREATE TABLE IF NOT EXISTS consciousness_items (
|
|
11
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
12
|
+
workspace_id TEXT NOT NULL,
|
|
13
|
+
source TEXT NOT NULL,
|
|
14
|
+
content TEXT NOT NULL,
|
|
15
|
+
salience REAL NOT NULL DEFAULT 0.5,
|
|
16
|
+
category TEXT NOT NULL CHECK (category IN ('alert', 'insight', 'prediction', 'milestone', 'anomaly')),
|
|
17
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
18
|
+
synced_at TEXT,
|
|
19
|
+
origin TEXT NOT NULL DEFAULT 'local' CHECK (origin IN ('local', 'cloud'))
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
CREATE INDEX IF NOT EXISTS idx_consciousness_items_workspace
|
|
23
|
+
ON consciousness_items(workspace_id, category);
|
|
24
|
+
CREATE INDEX IF NOT EXISTS idx_consciousness_items_salience
|
|
25
|
+
ON consciousness_items(workspace_id, salience DESC);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
-- Affect System: Somatic markers and affective memories (Damasio)
|
|
2
|
+
-- Emotions as fast decision heuristics
|
|
3
|
+
|
|
4
|
+
CREATE TABLE IF NOT EXISTS somatic_markers (
|
|
5
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
6
|
+
workspace_id TEXT NOT NULL,
|
|
7
|
+
context_hash TEXT NOT NULL,
|
|
8
|
+
affect TEXT NOT NULL,
|
|
9
|
+
valence REAL NOT NULL,
|
|
10
|
+
intensity REAL NOT NULL,
|
|
11
|
+
outcome TEXT NOT NULL CHECK (outcome IN ('positive','negative','neutral')),
|
|
12
|
+
tool_name TEXT,
|
|
13
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
14
|
+
);
|
|
15
|
+
CREATE INDEX IF NOT EXISTS idx_somatic_markers_context ON somatic_markers(workspace_id, context_hash);
|
|
16
|
+
CREATE INDEX IF NOT EXISTS idx_somatic_markers_tool ON somatic_markers(workspace_id, tool_name);
|
|
17
|
+
|
|
18
|
+
CREATE TABLE IF NOT EXISTS affective_memories (
|
|
19
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
20
|
+
workspace_id TEXT NOT NULL,
|
|
21
|
+
experience_id TEXT NOT NULL,
|
|
22
|
+
affect TEXT NOT NULL,
|
|
23
|
+
valence REAL NOT NULL,
|
|
24
|
+
arousal REAL NOT NULL,
|
|
25
|
+
content TEXT NOT NULL,
|
|
26
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
27
|
+
);
|
|
28
|
+
CREATE INDEX IF NOT EXISTS idx_affective_memories_affect ON affective_memories(workspace_id, affect);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- Endocrine System: Hormone snapshots (Spinoza's conatus)
|
|
2
|
+
-- Global state modulator crossing all architectural boundaries
|
|
3
|
+
|
|
4
|
+
CREATE TABLE IF NOT EXISTS hormone_snapshots (
|
|
5
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
6
|
+
workspace_id TEXT NOT NULL,
|
|
7
|
+
profile TEXT NOT NULL,
|
|
8
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
9
|
+
);
|
|
10
|
+
CREATE INDEX IF NOT EXISTS idx_hormone_snapshots_time ON hormone_snapshots(workspace_id, created_at DESC);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
-- Homeostasis: Self-regulation with set points (Cannon + Ashby)
|
|
2
|
+
-- Negative feedback loops and allostatic adaptation
|
|
3
|
+
|
|
4
|
+
CREATE TABLE IF NOT EXISTS homeostasis_set_points (
|
|
5
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
6
|
+
workspace_id TEXT NOT NULL,
|
|
7
|
+
metric TEXT NOT NULL,
|
|
8
|
+
target REAL NOT NULL,
|
|
9
|
+
tolerance REAL NOT NULL DEFAULT 0.1,
|
|
10
|
+
adaptation_rate REAL NOT NULL DEFAULT 0.1,
|
|
11
|
+
updated_at TEXT DEFAULT (datetime('now')),
|
|
12
|
+
UNIQUE(workspace_id, metric)
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
CREATE TABLE IF NOT EXISTS allostasis_events (
|
|
16
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
17
|
+
workspace_id TEXT NOT NULL,
|
|
18
|
+
metric TEXT NOT NULL,
|
|
19
|
+
old_target REAL NOT NULL,
|
|
20
|
+
new_target REAL NOT NULL,
|
|
21
|
+
reason TEXT NOT NULL,
|
|
22
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
23
|
+
);
|
|
24
|
+
CREATE INDEX IF NOT EXISTS idx_allostasis_events_time ON allostasis_events(workspace_id, created_at DESC);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
-- Oneiros: Sleep, dreams, and default mode (Aristotle + Jung + DMN)
|
|
2
|
+
-- Consolidation, creative recombination, and idle-time processing
|
|
3
|
+
|
|
4
|
+
CREATE TABLE IF NOT EXISTS sleep_state (
|
|
5
|
+
id TEXT PRIMARY KEY DEFAULT 'default',
|
|
6
|
+
workspace_id TEXT NOT NULL,
|
|
7
|
+
phase TEXT NOT NULL DEFAULT 'wake',
|
|
8
|
+
sleep_debt REAL NOT NULL DEFAULT 0,
|
|
9
|
+
last_consolidation TEXT,
|
|
10
|
+
last_dream TEXT,
|
|
11
|
+
cycle_count INTEGER DEFAULT 0,
|
|
12
|
+
updated_at TEXT DEFAULT (datetime('now'))
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
CREATE TABLE IF NOT EXISTS dream_associations (
|
|
16
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
17
|
+
workspace_id TEXT NOT NULL,
|
|
18
|
+
memory_a_id TEXT NOT NULL,
|
|
19
|
+
memory_b_id TEXT NOT NULL,
|
|
20
|
+
connection TEXT NOT NULL,
|
|
21
|
+
novelty_score REAL NOT NULL,
|
|
22
|
+
promoted INTEGER DEFAULT 0,
|
|
23
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
24
|
+
);
|
|
25
|
+
CREATE INDEX IF NOT EXISTS idx_dream_associations_novelty ON dream_associations(workspace_id, novelty_score DESC);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
-- Immune System: Layered threat defense with innate and adaptive immunity
|
|
2
|
+
-- Maturana & Varela's autopoiesis + self/non-self distinction
|
|
3
|
+
|
|
4
|
+
CREATE TABLE IF NOT EXISTS threat_signatures (
|
|
5
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
6
|
+
workspace_id TEXT NOT NULL,
|
|
7
|
+
pathogen_type TEXT NOT NULL,
|
|
8
|
+
pattern TEXT NOT NULL,
|
|
9
|
+
severity REAL NOT NULL DEFAULT 0.5,
|
|
10
|
+
origin TEXT NOT NULL DEFAULT 'learned',
|
|
11
|
+
false_positive_rate REAL NOT NULL DEFAULT 0.1,
|
|
12
|
+
last_seen TEXT,
|
|
13
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
14
|
+
);
|
|
15
|
+
CREATE INDEX IF NOT EXISTS idx_threat_signatures_workspace ON threat_signatures(workspace_id, origin);
|
|
16
|
+
|
|
17
|
+
CREATE TABLE IF NOT EXISTS immune_memories (
|
|
18
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
19
|
+
workspace_id TEXT NOT NULL,
|
|
20
|
+
pathogen_type TEXT NOT NULL,
|
|
21
|
+
context_hash TEXT NOT NULL,
|
|
22
|
+
occurrences INTEGER NOT NULL DEFAULT 1,
|
|
23
|
+
last_occurrence TEXT NOT NULL,
|
|
24
|
+
response_effectiveness REAL NOT NULL DEFAULT 0.5,
|
|
25
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
26
|
+
);
|
|
27
|
+
CREATE INDEX IF NOT EXISTS idx_immune_memories_workspace ON immune_memories(workspace_id, context_hash);
|
|
28
|
+
|
|
29
|
+
CREATE TABLE IF NOT EXISTS immune_incidents (
|
|
30
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
31
|
+
workspace_id TEXT NOT NULL,
|
|
32
|
+
pathogen_type TEXT NOT NULL,
|
|
33
|
+
confidence REAL NOT NULL,
|
|
34
|
+
recommendation TEXT NOT NULL,
|
|
35
|
+
matched_signature TEXT,
|
|
36
|
+
reason TEXT NOT NULL,
|
|
37
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
38
|
+
);
|
|
39
|
+
CREATE INDEX IF NOT EXISTS idx_immune_incidents_time ON immune_incidents(workspace_id, created_at DESC);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
-- Narrative: Story of self (Ricoeur + MacIntyre)
|
|
2
|
+
-- Agents gain identity through narrative coherence
|
|
3
|
+
|
|
4
|
+
CREATE TABLE IF NOT EXISTS narrative_episodes (
|
|
5
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
6
|
+
workspace_id TEXT NOT NULL,
|
|
7
|
+
agent_id TEXT,
|
|
8
|
+
story_type TEXT NOT NULL,
|
|
9
|
+
title TEXT NOT NULL,
|
|
10
|
+
phase TEXT NOT NULL DEFAULT 'beginning',
|
|
11
|
+
events TEXT NOT NULL DEFAULT '[]',
|
|
12
|
+
moral TEXT,
|
|
13
|
+
emotional_arc TEXT DEFAULT '[]',
|
|
14
|
+
started_at TEXT DEFAULT (datetime('now')),
|
|
15
|
+
ended_at TEXT
|
|
16
|
+
);
|
|
17
|
+
CREATE INDEX IF NOT EXISTS idx_narrative_episodes_agent ON narrative_episodes(workspace_id, agent_id);
|
|
18
|
+
CREATE INDEX IF NOT EXISTS idx_narrative_episodes_phase ON narrative_episodes(workspace_id, phase);
|
|
19
|
+
|
|
20
|
+
CREATE TABLE IF NOT EXISTS character_profiles (
|
|
21
|
+
id TEXT PRIMARY KEY DEFAULT 'default',
|
|
22
|
+
workspace_id TEXT NOT NULL,
|
|
23
|
+
agent_id TEXT,
|
|
24
|
+
identity TEXT NOT NULL DEFAULT '',
|
|
25
|
+
core_traits TEXT DEFAULT '[]',
|
|
26
|
+
defining_moments TEXT DEFAULT '[]',
|
|
27
|
+
narrative_coherence REAL DEFAULT 0.5,
|
|
28
|
+
updated_at TEXT DEFAULT (datetime('now'))
|
|
29
|
+
);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
-- Ethos System: Ethical evaluation persistence (Aristotle + Kant + Noddings)
|
|
2
|
+
-- Multi-framework moral reasoning for autonomous agent decisions
|
|
3
|
+
|
|
4
|
+
CREATE TABLE IF NOT EXISTS ethical_evaluations (
|
|
5
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
6
|
+
workspace_id TEXT NOT NULL,
|
|
7
|
+
action TEXT NOT NULL,
|
|
8
|
+
permitted INTEGER NOT NULL,
|
|
9
|
+
recommendation TEXT NOT NULL CHECK (recommendation IN ('proceed','proceed_with_caution','escalate','block')),
|
|
10
|
+
reasoning TEXT NOT NULL,
|
|
11
|
+
framework_results TEXT NOT NULL DEFAULT '[]',
|
|
12
|
+
constraint_violations TEXT DEFAULT '[]',
|
|
13
|
+
dilemma_detected INTEGER DEFAULT 0,
|
|
14
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
15
|
+
);
|
|
16
|
+
CREATE INDEX IF NOT EXISTS idx_ethical_evaluations_time ON ethical_evaluations(workspace_id, created_at DESC);
|
|
17
|
+
CREATE INDEX IF NOT EXISTS idx_ethical_evaluations_recommendation ON ethical_evaluations(workspace_id, recommendation);
|
|
18
|
+
|
|
19
|
+
CREATE TABLE IF NOT EXISTS moral_profile (
|
|
20
|
+
id TEXT PRIMARY KEY DEFAULT 'default',
|
|
21
|
+
workspace_id TEXT NOT NULL,
|
|
22
|
+
stage TEXT NOT NULL DEFAULT 'rule_following',
|
|
23
|
+
consistency_score REAL DEFAULT 0.5,
|
|
24
|
+
dilemmas_resolved INTEGER DEFAULT 0,
|
|
25
|
+
constraint_violations INTEGER DEFAULT 0,
|
|
26
|
+
updated_at TEXT DEFAULT (datetime('now'))
|
|
27
|
+
);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
-- Hexis: Habit formation (Aristotle's hexis + William James)
|
|
2
|
+
-- Cue-routine-reward loop with automaticity gradient
|
|
3
|
+
|
|
4
|
+
CREATE TABLE IF NOT EXISTS habits (
|
|
5
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
6
|
+
workspace_id TEXT NOT NULL,
|
|
7
|
+
name TEXT NOT NULL,
|
|
8
|
+
cue TEXT NOT NULL,
|
|
9
|
+
routine TEXT NOT NULL,
|
|
10
|
+
reward TEXT NOT NULL,
|
|
11
|
+
strength REAL NOT NULL DEFAULT 0.1,
|
|
12
|
+
automaticity TEXT NOT NULL DEFAULT 'deliberate',
|
|
13
|
+
success_rate REAL DEFAULT 0.5,
|
|
14
|
+
execution_count INTEGER DEFAULT 0,
|
|
15
|
+
last_executed TEXT,
|
|
16
|
+
decay_rate REAL DEFAULT 0.03,
|
|
17
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
18
|
+
);
|
|
19
|
+
CREATE INDEX IF NOT EXISTS idx_habits_strength ON habits(workspace_id, strength DESC);
|
|
20
|
+
|
|
21
|
+
CREATE TABLE IF NOT EXISTS habit_executions (
|
|
22
|
+
id TEXT PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
23
|
+
workspace_id TEXT NOT NULL,
|
|
24
|
+
habit_id TEXT NOT NULL,
|
|
25
|
+
success INTEGER NOT NULL,
|
|
26
|
+
duration_ms INTEGER,
|
|
27
|
+
created_at TEXT DEFAULT (datetime('now'))
|
|
28
|
+
);
|
|
29
|
+
CREATE INDEX IF NOT EXISTS idx_habit_executions_habit ON habit_executions(habit_id, created_at DESC);
|