{"id":46485010,"url":"https://github.com/jeffkit/lavs","last_synced_at":"2026-03-07T10:01:09.676Z","repository":{"id":341350675,"uuid":"1169794855","full_name":"jeffkit/lavs","owner":"jeffkit","description":"LAVS - Local Agent View Service protocol SDK","archived":false,"fork":false,"pushed_at":"2026-03-06T07:47:51.000Z","size":168,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-06T11:46:05.808Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jeffkit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-01T08:14:28.000Z","updated_at":"2026-03-06T07:47:23.000Z","dependencies_parsed_at":"2026-03-07T10:01:04.028Z","dependency_job_id":null,"html_url":"https://github.com/jeffkit/lavs","commit_stats":null,"previous_names":["jeffkit/lavs"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/jeffkit/lavs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffkit%2Flavs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffkit%2Flavs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffkit%2Flavs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffkit%2Flavs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeffkit","download_url":"https://codeload.github.com/jeffkit/lavs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffkit%2Flavs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30212021,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T09:02:10.694Z","status":"ssl_error","status_checked_at":"2026-03-07T09:02:08.429Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-03-06T09:14:17.615Z","updated_at":"2026-03-07T10:01:09.667Z","avatar_url":"https://github.com/jeffkit.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LAVS — Local Agent View Service\n\n**Protocol Version**: 1.0  \n**Status**: Active Development (pre-release)\n\nLAVS is a protocol that bridges **AI Agents** and **Visual UIs**. It enables local AI agents to expose structured data interfaces that can be rendered as interactive visual components alongside conversational chat.\n\n## What Problem Does LAVS Solve?\n\nCurrent AI agent protocols handle:\n- **MCP** (Model Context Protocol): Agent ↔ External Tools\n- **A2A** (Agent-to-Agent): Agent ↔ Agent communication\n- **MCP Resources**: Read-only data context for LLMs\n\n**Gap**: No standard way for agents to expose internal data to visual frontends with bidirectional sync.\n\nLAVS fills this gap:\n\n```\n┌────────────────────────────────────────────────────┐\n│     Visual Layer (LAVS)     ← Agent's \"face\"       │\n│  View + Query + Mutation + Subscription + AI Sync   │\n├────────────────────────────────────────────────────┤\n│     Context Layer (MCP Resources)                   │\n├────────────────────────────────────────────────────┤\n│     Tool Layer (MCP Tools)                          │\n├────────────────────────────────────────────────────┤\n│     Comm Layer (A2A)                                │\n└────────────────────────────────────────────────────┘\n```\n\n## Quick Start\n\n### 1. Define Your Agent's Interface\n\nCreate a `lavs.json` manifest:\n\n```json\n{\n  \"lavs\": \"1.0\",\n  \"name\": \"todo-service\",\n  \"version\": \"1.0.0\",\n  \"description\": \"A todo management service\",\n  \"endpoints\": [\n    {\n      \"id\": \"listTodos\",\n      \"method\": \"query\",\n      \"description\": \"List all todos\",\n      \"handler\": {\n        \"type\": \"script\",\n        \"command\": \"node\",\n        \"args\": [\"scripts/list-todos.js\"]\n      },\n      \"schema\": {\n        \"output\": { \"$ref\": \"#/types/TodoList\" }\n      }\n    },\n    {\n      \"id\": \"addTodo\",\n      \"method\": \"mutation\",\n      \"description\": \"Add a new todo\",\n      \"handler\": {\n        \"type\": \"script\",\n        \"command\": \"node\",\n        \"args\": [\"scripts/add-todo.js\"],\n        \"input\": \"args\"\n      },\n      \"schema\": {\n        \"input\": {\n          \"type\": \"object\",\n          \"required\": [\"text\"],\n          \"properties\": {\n            \"text\": { \"type\": \"string\" },\n            \"priority\": { \"type\": \"integer\", \"minimum\": 1, \"maximum\": 5 }\n          }\n        },\n        \"output\": { \"$ref\": \"#/types/Todo\" }\n      }\n    }\n  ],\n  \"view\": {\n    \"component\": {\n      \"type\": \"local\",\n      \"path\": \"./view/index.html\"\n    }\n  },\n  \"types\": {\n    \"Todo\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"id\": { \"type\": \"integer\" },\n        \"text\": { \"type\": \"string\" },\n        \"done\": { \"type\": \"boolean\" },\n        \"priority\": { \"type\": \"integer\" }\n      }\n    },\n    \"TodoList\": {\n      \"type\": \"array\",\n      \"items\": { \"$ref\": \"#/types/Todo\" }\n    }\n  },\n  \"permissions\": {\n    \"fileAccess\": [\"./data/**/*.json\"],\n    \"maxExecutionTime\": 5000\n  }\n}\n```\n\n### 2. Implement Handlers\n\nEach endpoint has a handler that defines how to execute it:\n\n```javascript\n// scripts/list-todos.js\nconst fs = require('fs');\nconst path = require('path');\n\nconst projectPath = process.env.LAVS_PROJECT_PATH || '.';\nconst dataFile = path.join(projectPath, 'data', 'todos.json');\n\ntry {\n  const todos = JSON.parse(fs.readFileSync(dataFile, 'utf8'));\n  console.log(JSON.stringify(todos));\n} catch {\n  console.log(JSON.stringify([]));\n}\n```\n\n### 3. Create a View Component\n\nView components run in an iframe and communicate via `postMessage`:\n\n```html\n\u003c!-- view/index.html --\u003e\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\u003ctitle\u003eTodo View\u003c/title\u003e\u003c/head\u003e\n\u003cbody\u003e\n  \u003cdiv id=\"todos\"\u003e\u003c/div\u003e\n  \u003cscript\u003e\n    // LAVS provides these globals:\n    // window.LAVS_AGENT_ID, window.LAVS_PROJECT_PATH\n\n    // Call LAVS endpoint via postMessage\n    function callEndpoint(endpoint, input) {\n      return new Promise((resolve, reject) =\u003e {\n        const id = Math.random().toString(36).slice(2);\n        const handler = (event) =\u003e {\n          if (event.data.id !== id) return;\n          window.removeEventListener('message', handler);\n          if (event.data.type === 'lavs-result') resolve(event.data.result);\n          else reject(new Error(event.data.error));\n        };\n        window.addEventListener('message', handler);\n        window.parent.postMessage({ type: 'lavs-call', id, endpoint, input }, '*');\n      });\n    }\n\n    // Listen for AI agent actions\n    window.addEventListener('message', (event) =\u003e {\n      if (event.data.type === 'lavs-agent-action') {\n        console.log('Agent did:', event.data.action);\n        loadTodos(); // Refresh on any agent action\n      }\n    });\n\n    async function loadTodos() {\n      const todos = await callEndpoint('listTodos');\n      document.getElementById('todos').innerHTML = todos\n        .map(t =\u003e `\u003cdiv\u003e${t.done ? '✅' : '⬜'} ${t.text}\u003c/div\u003e`)\n        .join('');\n    }\n\n    loadTodos();\n  \u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n## Architecture\n\n```\n┌──────────────┐        ┌──────────────┐\n│  Chat Panel  │        │  LAVS View   │\n│  (AI对话面板)  │        │  (可视化面板)  │\n└──────┬───────┘        └──────┬───────┘\n       │                       │\n       │   AI calls tool       │  View calls endpoint\n       │   lavs_addTodo()      │  postMessage('lavs-call')\n       │                       │\n       ▼                       ▼\n┌──────────────────────────────────────┐\n│           LAVS Runtime               │\n│  ┌─────────┐  ┌─────────────────┐   │\n│  │ Manifest │  │ Script Executor │   │\n│  │ Loader   │→ │ (node/python)   │   │\n│  └─────────┘  └─────────────────┘   │\n│  ┌─────────┐  ┌─────────────────┐   │\n│  │Validator │  │  Permission     │   │\n│  │ (Schema) │  │  Checker        │   │\n│  └─────────┘  └─────────────────┘   │\n└──────────────────────────────────────┘\n```\n\n## Key Concepts\n\n| Concept | Description |\n|---------|-------------|\n| **Manifest** | `lavs.json` declares endpoints, view, permissions |\n| **Endpoint** | `query` (read), `mutation` (write), `subscription` (real-time) |\n| **Handler** | `script`, `function`, `http`, `mcp` — how to execute |\n| **View** | iframe-based UI component with postMessage bridge |\n| **AI ↔ UI Sync** | AI tool executions notify the view via store → postMessage |\n\n## Handler Types\n\n| Type | Description | Status |\n|------|-------------|--------|\n| `script` | Execute CLI command (node, python, etc.) | ✅ |\n| `function` | Call JS/TS function directly | ✅ |\n| `http` | Proxy to HTTP endpoint | Planned |\n| `mcp` | Bridge to MCP server tool | Planned |\n\n## Security Model\n\n| Permission | Enforcement | Notes |\n|-----------|-------------|-------|\n| Path traversal | **ENFORCED** | Handler paths validated |\n| Input validation | **ENFORCED** | JSON Schema on all inputs |\n| maxExecutionTime | **ENFORCED** | Script killed on timeout |\n| fileAccess | ADVISORY | Glob patterns for auditing |\n| networkAccess | ADVISORY | Declared, not enforced |\n| CSP | **ENFORCED** | Nonce-based script policy |\n\n## Project Structure\n\n```\nplatform/lavs/\n├── docs/\n│   ├── SPEC.md                    # Full protocol specification\n│   └── PROTOCOL-ANALYSIS.md       # Gap analysis \u0026 improvement plan\n├── sdk/\n│   ├── typescript/                # TypeScript/Node.js SDK\n│   │   ├── types/src/index.ts     # Core type definitions\n│   │   ├── runtime/src/           # Reference runtime (to be extracted)\n│   │   └── client/src/            # Client SDK (to be extracted)\n│   └── python/                    # Python SDK (planned)\n│       ├── lavs_types/            # Type definitions (Pydantic models)\n│       ├── lavs_runtime/          # Reference runtime\n│       └── lavs_client/           # Client SDK\n├── schema/\n│   └── lavs-manifest.schema.json  # JSON Schema for IDE autocomplete\n├── examples/\n│   └── jarvis-agent/              # Example agent (planned)\n└── README.md\n```\n\nThe `sdk/` directory is organized by language. Each language provides three packages:\n- **types**: Core protocol type definitions (generated from JSON Schema)\n- **runtime**: Server-side runtime (manifest loading, handler execution, validation)\n- **client**: Client SDK for calling LAVS endpoints from UIs\n\n## LAVS vs MCP Resources\n\nLAVS and MCP Resources are **complementary**, not competing:\n\n| | LAVS | MCP Resources |\n|-|------|---------------|\n| Direction | Bidirectional (AI ↔ UI) | One-way (Server → LLM) |\n| Operations | Query + Mutation + Subscription | Read-only |\n| UI binding | View Components | None |\n| Purpose | Agent's visual interface | Agent's data context |\n\nBest combination: LAVS `type: 'mcp'` handler uses MCP Resources as data source, rendered through LAVS View Components.\n\n## Current Integration\n\nLAVS is currently integrated into [AgentStudio](../agentstudio/) via the `feature/lavs-poc` branch.\n\n**Reference implementation**:\n- Backend: `agentstudio/.worktrees/lavs/backend/src/lavs/` (runtime modules)\n- Frontend: `agentstudio/.worktrees/lavs/frontend/src/lavs/` (client SDK)\n- Routes: `agentstudio/.worktrees/lavs/backend/src/routes/lavs.ts` (HTTP API)\n\n## Roadmap\n\n- [x] Protocol spec v1.0\n- [x] Security hardening (CSP nonce, postMessage origin, publish auth)\n- [x] Spec alignment (SSE subscriptions, unified error format)\n- [x] JSON Schema for manifest validation\n- [x] postMessage protocol documentation\n- [x] File watcher for cache invalidation\n- [x] Unit tests + integration tests\n- [ ] Extract runtime as `@lavs/runtime` npm package\n- [ ] Extract client as `@lavs/client` npm package\n- [ ] Implement `http` and `mcp` handler types\n- [ ] CLI tooling (`lavs init`, `lavs validate`)\n- [ ] Independent repository and npm publishing\n\n## License\n\nTBD\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeffkit%2Flavs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeffkit%2Flavs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeffkit%2Flavs/lists"}