lavs-types 0.1.0

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 ADDED
@@ -0,0 +1,59 @@
1
+ # lavs-types
2
+
3
+ TypeScript type definitions for the **LAVS (Local Agent View Service)** protocol.
4
+
5
+ LAVS is a protocol that bridges AI Agents and Visual UIs, enabling local AI agents to expose structured data interfaces rendered as interactive visual components.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install lavs-types
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```typescript
16
+ import type {
17
+ LAVSManifest,
18
+ Endpoint,
19
+ Handler,
20
+ ViewConfig,
21
+ Permissions,
22
+ } from 'lavs-types';
23
+
24
+ const manifest: LAVSManifest = {
25
+ lavs: '1.0',
26
+ name: 'my-service',
27
+ version: '1.0.0',
28
+ endpoints: [
29
+ {
30
+ id: 'getData',
31
+ method: 'query',
32
+ handler: { type: 'script', command: 'node', args: ['get-data.js'] },
33
+ },
34
+ ],
35
+ };
36
+ ```
37
+
38
+ ## Exported Types
39
+
40
+ | Type | Description |
41
+ |------|-------------|
42
+ | `LAVSManifest` | Root manifest definition |
43
+ | `Endpoint` | Callable operation (query / mutation / subscription) |
44
+ | `Handler` | Union of ScriptHandler, FunctionHandler, HTTPHandler, MCPHandler |
45
+ | `Schema` | JSON Schema for input/output validation |
46
+ | `ViewConfig` | UI component configuration |
47
+ | `Permissions` | Security constraints |
48
+ | `ExecutionContext` | Runtime context for handler execution |
49
+ | `LAVSError` | Standard error class |
50
+ | `LAVSErrorCode` | JSON-RPC 2.0 compatible error codes |
51
+
52
+ ## Related Packages
53
+
54
+ - [`lavs-runtime`](https://www.npmjs.com/package/lavs-runtime) — Server-side runtime (manifest loading, validation, handler execution)
55
+ - [`lavs-client`](https://www.npmjs.com/package/lavs-client) — Client SDK for frontend applications
56
+
57
+ ## License
58
+
59
+ MIT
@@ -0,0 +1,171 @@
1
+ /**
2
+ * LAVS (Local Agent View Service) Type Definitions
3
+ *
4
+ * This file defines the TypeScript types for LAVS manifests and related interfaces.
5
+ * See docs/LAVS-SPEC.md for full specification.
6
+ */
7
+ /**
8
+ * LAVS Manifest - defines agent's data interface and view configuration
9
+ */
10
+ export interface LAVSManifest {
11
+ lavs: string;
12
+ name: string;
13
+ version: string;
14
+ description?: string;
15
+ endpoints: Endpoint[];
16
+ view?: ViewConfig;
17
+ types?: TypeDefinitions;
18
+ permissions?: Permissions;
19
+ }
20
+ /**
21
+ * Endpoint - a callable operation exposed by the service
22
+ */
23
+ export interface Endpoint {
24
+ id: string;
25
+ method: 'query' | 'mutation' | 'subscription';
26
+ description?: string;
27
+ handler: Handler;
28
+ schema?: Schema;
29
+ permissions?: Permissions;
30
+ }
31
+ /**
32
+ * Handler - defines how to execute an endpoint
33
+ */
34
+ export type Handler = ScriptHandler | FunctionHandler | HTTPHandler | MCPHandler;
35
+ /**
36
+ * Script Handler - executes a script/command
37
+ */
38
+ export interface ScriptHandler {
39
+ type: 'script';
40
+ command: string;
41
+ args?: string[];
42
+ input?: 'args' | 'stdin' | 'env';
43
+ cwd?: string;
44
+ timeout?: number;
45
+ env?: Record<string, string>;
46
+ }
47
+ /**
48
+ * Function Handler - calls a JavaScript/TypeScript function
49
+ */
50
+ export interface FunctionHandler {
51
+ type: 'function';
52
+ module: string;
53
+ function: string;
54
+ }
55
+ /**
56
+ * HTTP Handler - proxies to HTTP endpoint
57
+ */
58
+ export interface HTTPHandler {
59
+ type: 'http';
60
+ url: string;
61
+ method: string;
62
+ headers?: Record<string, string>;
63
+ }
64
+ /**
65
+ * MCP Handler - bridges to MCP server tool
66
+ */
67
+ export interface MCPHandler {
68
+ type: 'mcp';
69
+ server: string;
70
+ tool: string;
71
+ }
72
+ /**
73
+ * Schema - JSON Schema for input/output validation
74
+ */
75
+ export interface Schema {
76
+ input?: JSONSchema;
77
+ output?: JSONSchema;
78
+ }
79
+ /**
80
+ * JSON Schema type (simplified)
81
+ */
82
+ export type JSONSchema = Record<string, any>;
83
+ /**
84
+ * Type Definitions - reusable type schemas
85
+ */
86
+ export type TypeDefinitions = Record<string, JSONSchema>;
87
+ /**
88
+ * View Configuration - UI component definition
89
+ */
90
+ export interface ViewConfig {
91
+ component: ComponentSource;
92
+ fallback?: 'list' | 'table' | 'json';
93
+ icon?: string;
94
+ theme?: Record<string, string>;
95
+ }
96
+ /**
97
+ * Component Source - how to load the view component
98
+ */
99
+ export type ComponentSource = {
100
+ type: 'cdn';
101
+ url: string;
102
+ exportName?: string;
103
+ } | {
104
+ type: 'npm';
105
+ package: string;
106
+ version?: string;
107
+ } | {
108
+ type: 'local';
109
+ path: string;
110
+ } | {
111
+ type: 'inline';
112
+ code: string;
113
+ };
114
+ /**
115
+ * Permissions - security constraints
116
+ *
117
+ * Enforcement levels:
118
+ * - ENFORCED: Runtime actively prevents violations
119
+ * - ADVISORY: Declared for documentation/auditing, not enforced at OS level
120
+ *
121
+ * | Permission | Enforcement | Notes |
122
+ * |-----------------|-------------|------------------------------------------------|
123
+ * | fileAccess | ADVISORY | Glob patterns for allowed paths; checked at |
124
+ * | | | handler dispatch (path traversal) but not at |
125
+ * | | | OS/syscall level during script execution |
126
+ * | networkAccess | ADVISORY | Declared intent; not enforced (no network |
127
+ * | | | namespacing). Use OS-level isolation for strict |
128
+ * | | | enforcement (e.g., nsjail, Docker) |
129
+ * | maxExecutionTime| ENFORCED | Script killed via SIGTERM/SIGKILL on timeout |
130
+ * | maxMemory | ADVISORY | Not enforced in current runtime; future: use |
131
+ * | | | Node.js child_process resource limits |
132
+ */
133
+ export interface Permissions {
134
+ fileAccess?: string[];
135
+ networkAccess?: boolean | string[];
136
+ maxExecutionTime?: number;
137
+ maxMemory?: number;
138
+ }
139
+ /**
140
+ * Execution Context - runtime context for handler execution
141
+ */
142
+ export interface ExecutionContext {
143
+ endpointId: string;
144
+ agentId: string;
145
+ workdir: string;
146
+ permissions: Permissions;
147
+ timeout?: number;
148
+ env?: Record<string, string>;
149
+ }
150
+ /**
151
+ * LAVS Error - standard error format
152
+ */
153
+ export declare class LAVSError extends Error {
154
+ code: number;
155
+ data?: Record<string, unknown> | undefined;
156
+ constructor(code: number, message: string, data?: Record<string, unknown> | undefined);
157
+ }
158
+ /**
159
+ * LAVS Error Codes (JSON-RPC 2.0 compatible)
160
+ */
161
+ export declare enum LAVSErrorCode {
162
+ ParseError = -32700,
163
+ InvalidRequest = -32600,
164
+ MethodNotFound = -32601,
165
+ InvalidParams = -32602,
166
+ InternalError = -32603,
167
+ PermissionDenied = -32001,
168
+ Timeout = -32002,
169
+ HandlerError = -32003
170
+ }
171
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,OAAO,GAAG,UAAU,GAAG,cAAc,CAAC;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,aAAa,GAAG,eAAe,GAAG,WAAW,GAAG,UAAU,CAAC;AAEjF;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,QAAQ,CAA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ACnB,cAAc,SAAS;IACvB,cAAc,SAAS;IACvB,aAAa,SAAS;IACtB,aAAa,SAAS;IACtB,gBAAgB,SAAS;IACzB,OAAO,SAAS;IAChB,YAAY,SAAS;CACtB"}
package/dist/index.js ADDED
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ /**
3
+ * LAVS (Local Agent View Service) Type Definitions
4
+ *
5
+ * This file defines the TypeScript types for LAVS manifests and related interfaces.
6
+ * See docs/LAVS-SPEC.md for full specification.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.LAVSErrorCode = exports.LAVSError = void 0;
10
+ /**
11
+ * LAVS Error - standard error format
12
+ */
13
+ class LAVSError extends Error {
14
+ code;
15
+ data;
16
+ constructor(code, message, data) {
17
+ super(message);
18
+ this.code = code;
19
+ this.data = data;
20
+ this.name = 'LAVSError';
21
+ }
22
+ }
23
+ exports.LAVSError = LAVSError;
24
+ /**
25
+ * LAVS Error Codes (JSON-RPC 2.0 compatible)
26
+ */
27
+ var LAVSErrorCode;
28
+ (function (LAVSErrorCode) {
29
+ LAVSErrorCode[LAVSErrorCode["ParseError"] = -32700] = "ParseError";
30
+ LAVSErrorCode[LAVSErrorCode["InvalidRequest"] = -32600] = "InvalidRequest";
31
+ LAVSErrorCode[LAVSErrorCode["MethodNotFound"] = -32601] = "MethodNotFound";
32
+ LAVSErrorCode[LAVSErrorCode["InvalidParams"] = -32602] = "InvalidParams";
33
+ LAVSErrorCode[LAVSErrorCode["InternalError"] = -32603] = "InternalError";
34
+ LAVSErrorCode[LAVSErrorCode["PermissionDenied"] = -32001] = "PermissionDenied";
35
+ LAVSErrorCode[LAVSErrorCode["Timeout"] = -32002] = "Timeout";
36
+ LAVSErrorCode[LAVSErrorCode["HandlerError"] = -32003] = "HandlerError";
37
+ })(LAVSErrorCode || (exports.LAVSErrorCode = LAVSErrorCode = {}));
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAuJH;;GAEG;AACH,MAAa,SAAU,SAAQ,KAAK;IAEzB;IAEA;IAHT,YACS,IAAY,EACnB,OAAe,EACR,IAA8B;QAErC,KAAK,CAAC,OAAO,CAAC,CAAC;QAJR,SAAI,GAAJ,IAAI,CAAQ;QAEZ,SAAI,GAAJ,IAAI,CAA0B;QAGrC,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;CACF;AATD,8BASC;AAED;;GAEG;AACH,IAAY,aASX;AATD,WAAY,aAAa;IACvB,kEAAmB,CAAA;IACnB,0EAAuB,CAAA;IACvB,0EAAuB,CAAA;IACvB,wEAAsB,CAAA;IACtB,wEAAsB,CAAA;IACtB,8EAAyB,CAAA;IACzB,4DAAgB,CAAA;IAChB,sEAAqB,CAAA;AACvB,CAAC,EATW,aAAa,6BAAb,aAAa,QASxB"}
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "lavs-types",
3
+ "version": "0.1.0",
4
+ "description": "LAVS (Local Agent View Service) protocol type definitions",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "require": "./dist/index.js",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "scripts": {
16
+ "build": "tsc",
17
+ "clean": "rm -rf dist",
18
+ "prepublishOnly": "npm run clean && npm run build"
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "README.md"
23
+ ],
24
+ "keywords": [
25
+ "lavs",
26
+ "agent",
27
+ "view",
28
+ "service",
29
+ "protocol",
30
+ "types",
31
+ "typescript"
32
+ ],
33
+ "license": "MIT",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/nicepkg/lavs.git",
37
+ "directory": "sdk/typescript/types"
38
+ },
39
+ "devDependencies": {
40
+ "typescript": "^5.1.6"
41
+ }
42
+ }