lavs-client 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 +62 -0
- package/dist/client.d.ts +81 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +190 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +107 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +19 -0
- package/dist/types.js.map +1 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# lavs-client
|
|
2
|
+
|
|
3
|
+
Client SDK for the **LAVS (Local Agent View Service)** protocol.
|
|
4
|
+
|
|
5
|
+
Enables frontend applications to call LAVS endpoints via SSE (Server-Sent Events) streaming, with support for queries, mutations, and real-time subscriptions.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install lavs-client
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { LAVSClient } from 'lavs-client';
|
|
17
|
+
|
|
18
|
+
const client = new LAVSClient({
|
|
19
|
+
baseUrl: 'http://localhost:4936',
|
|
20
|
+
agentId: 'my-agent',
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Query endpoint
|
|
24
|
+
const todos = await client.query('listTodos');
|
|
25
|
+
|
|
26
|
+
// Mutation endpoint
|
|
27
|
+
const newTodo = await client.mutate('addTodo', {
|
|
28
|
+
text: 'Buy groceries',
|
|
29
|
+
priority: 3,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Subscription (real-time updates via SSE)
|
|
33
|
+
const unsubscribe = client.subscribe('watchTodos', {}, (event) => {
|
|
34
|
+
console.log('Update:', event.data);
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## API
|
|
39
|
+
|
|
40
|
+
### `new LAVSClient(options)`
|
|
41
|
+
|
|
42
|
+
| Option | Type | Description |
|
|
43
|
+
|--------|------|-------------|
|
|
44
|
+
| `baseUrl` | `string` | LAVS server base URL |
|
|
45
|
+
| `agentId` | `string` | Agent identifier |
|
|
46
|
+
|
|
47
|
+
### Methods
|
|
48
|
+
|
|
49
|
+
| Method | Description |
|
|
50
|
+
|--------|-------------|
|
|
51
|
+
| `query(endpoint, input?)` | Call a query endpoint |
|
|
52
|
+
| `mutate(endpoint, input?)` | Call a mutation endpoint |
|
|
53
|
+
| `subscribe(endpoint, input?, callback)` | Subscribe to real-time updates |
|
|
54
|
+
|
|
55
|
+
## Related Packages
|
|
56
|
+
|
|
57
|
+
- [`lavs-types`](https://www.npmjs.com/package/lavs-types) — Protocol type definitions
|
|
58
|
+
- [`lavs-runtime`](https://www.npmjs.com/package/lavs-runtime) — Server-side runtime
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
MIT
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LAVS Client SDK
|
|
3
|
+
*
|
|
4
|
+
* Client library for calling LAVS endpoints from frontend applications.
|
|
5
|
+
*/
|
|
6
|
+
import { LAVSManifest } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* LAVS Client configuration
|
|
9
|
+
*/
|
|
10
|
+
export interface LAVSClientOptions {
|
|
11
|
+
agentId: string;
|
|
12
|
+
baseURL?: string;
|
|
13
|
+
projectPath?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* LAVS Client for calling agent endpoints
|
|
17
|
+
*/
|
|
18
|
+
export declare class LAVSClient {
|
|
19
|
+
private agentId;
|
|
20
|
+
private baseURL;
|
|
21
|
+
private projectPath?;
|
|
22
|
+
private manifest;
|
|
23
|
+
constructor(options: LAVSClientOptions);
|
|
24
|
+
/**
|
|
25
|
+
* Get auth token from localStorage
|
|
26
|
+
*/
|
|
27
|
+
private getAuthToken;
|
|
28
|
+
/**
|
|
29
|
+
* Get LAVS manifest for the agent
|
|
30
|
+
*/
|
|
31
|
+
getManifest(): Promise<LAVSManifest>;
|
|
32
|
+
/**
|
|
33
|
+
* Call a LAVS endpoint
|
|
34
|
+
*
|
|
35
|
+
* @param endpointId - Endpoint ID from manifest
|
|
36
|
+
* @param input - Input data for the endpoint
|
|
37
|
+
* @returns Endpoint result
|
|
38
|
+
*/
|
|
39
|
+
call<TResult = any>(endpointId: string, input?: any): Promise<TResult>;
|
|
40
|
+
/**
|
|
41
|
+
* Subscribe to a LAVS subscription endpoint via SSE.
|
|
42
|
+
*
|
|
43
|
+
* Opens a Server-Sent Events connection to the endpoint's /subscribe URL.
|
|
44
|
+
* Returns an unsubscribe function to close the connection.
|
|
45
|
+
*
|
|
46
|
+
* @param endpointId - Subscription endpoint ID from manifest
|
|
47
|
+
* @param callback - Called with event data on each SSE message
|
|
48
|
+
* @param options - Optional: onError handler, onConnected handler
|
|
49
|
+
* @returns Unsubscribe function to close the SSE connection
|
|
50
|
+
*/
|
|
51
|
+
subscribe(endpointId: string, callback: (data: any) => void, options?: {
|
|
52
|
+
onError?: (error: Event) => void;
|
|
53
|
+
onConnected?: (subscriptionInfo: any) => void;
|
|
54
|
+
}): () => void;
|
|
55
|
+
/**
|
|
56
|
+
* Clear manifest cache (force reload on next getManifest)
|
|
57
|
+
*/
|
|
58
|
+
clearCache(): void;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Interface that view components should implement
|
|
62
|
+
*/
|
|
63
|
+
export interface LAVSViewComponent extends HTMLElement {
|
|
64
|
+
/**
|
|
65
|
+
* Called when component is mounted
|
|
66
|
+
*/
|
|
67
|
+
connectedCallback?(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Set the LAVS client (injected by container)
|
|
70
|
+
*/
|
|
71
|
+
setLAVSClient(client: LAVSClient): void;
|
|
72
|
+
/**
|
|
73
|
+
* Optional: receive notifications when agent performs actions
|
|
74
|
+
*/
|
|
75
|
+
onAgentAction?(action: any): void;
|
|
76
|
+
/**
|
|
77
|
+
* Called when component is unmounted
|
|
78
|
+
*/
|
|
79
|
+
disconnectedCallback?(): void;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAa,MAAM,SAAS,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAAC,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAA6B;gBAEjC,OAAO,EAAE,iBAAiB;IAatC;;OAEG;IACH,OAAO,CAAC,YAAY;IAKpB;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC;IA8C1C;;;;;;OAMG;IACG,IAAI,CAAC,OAAO,GAAG,GAAG,EACtB,UAAU,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,GAAG,GACV,OAAO,CAAC,OAAO,CAAC;IAkDnB;;;;;;;;;;OAUG;IACH,SAAS,CACP,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,EAC7B,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;QACjC,WAAW,CAAC,EAAE,CAAC,gBAAgB,EAAE,GAAG,KAAK,IAAI,CAAC;KAC/C,GACA,MAAM,IAAI;IAyDb;;OAEG;IACH,UAAU,IAAI,IAAI;CAGnB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,WAAW;IACpD;;OAEG;IACH,iBAAiB,CAAC,IAAI,IAAI,CAAC;IAE3B;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IAExC;;OAEG;IACH,aAAa,CAAC,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CAAC;IAElC;;OAEG;IACH,oBAAoB,CAAC,IAAI,IAAI,CAAC;CAC/B"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LAVS Client SDK
|
|
3
|
+
*
|
|
4
|
+
* Client library for calling LAVS endpoints from frontend applications.
|
|
5
|
+
*/
|
|
6
|
+
import { LAVSError } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* LAVS Client for calling agent endpoints
|
|
9
|
+
*/
|
|
10
|
+
export class LAVSClient {
|
|
11
|
+
agentId;
|
|
12
|
+
baseURL;
|
|
13
|
+
projectPath;
|
|
14
|
+
manifest = null;
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.agentId = options.agentId;
|
|
17
|
+
this.baseURL = options.baseURL || window.location.origin;
|
|
18
|
+
this.projectPath = options.projectPath;
|
|
19
|
+
// Debug logging
|
|
20
|
+
console.log('[LAVSClient] Initialized:', {
|
|
21
|
+
agentId: this.agentId,
|
|
22
|
+
projectPath: this.projectPath,
|
|
23
|
+
hasProjectPath: !!this.projectPath
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get auth token from localStorage
|
|
28
|
+
*/
|
|
29
|
+
getAuthToken() {
|
|
30
|
+
// Try both possible token keys for compatibility
|
|
31
|
+
return localStorage.getItem('auth_token') || localStorage.getItem('authToken');
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get LAVS manifest for the agent
|
|
35
|
+
*/
|
|
36
|
+
async getManifest() {
|
|
37
|
+
if (this.manifest) {
|
|
38
|
+
return this.manifest;
|
|
39
|
+
}
|
|
40
|
+
const url = `${this.baseURL}/api/agents/${this.agentId}/lavs/manifest`;
|
|
41
|
+
try {
|
|
42
|
+
const token = this.getAuthToken();
|
|
43
|
+
const headers = {
|
|
44
|
+
'Content-Type': 'application/json',
|
|
45
|
+
};
|
|
46
|
+
if (token) {
|
|
47
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
48
|
+
}
|
|
49
|
+
const response = await fetch(url, {
|
|
50
|
+
method: 'GET',
|
|
51
|
+
headers,
|
|
52
|
+
credentials: 'include', // Include cookies for auth
|
|
53
|
+
});
|
|
54
|
+
if (!response.ok) {
|
|
55
|
+
const body = await response.json();
|
|
56
|
+
// Handle JSON-RPC error format
|
|
57
|
+
const rpcError = body.error || body;
|
|
58
|
+
throw new LAVSError(rpcError.code || -1, rpcError.message || rpcError.error || `HTTP ${response.status}: ${response.statusText}`, rpcError.data);
|
|
59
|
+
}
|
|
60
|
+
const body = await response.json();
|
|
61
|
+
// Unwrap JSON-RPC 2.0 response: { jsonrpc: '2.0', result: manifest }
|
|
62
|
+
this.manifest = body.result ?? body;
|
|
63
|
+
return this.manifest;
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
if (error instanceof LAVSError) {
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
throw new LAVSError(-1, `Failed to fetch manifest: ${error.message}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Call a LAVS endpoint
|
|
74
|
+
*
|
|
75
|
+
* @param endpointId - Endpoint ID from manifest
|
|
76
|
+
* @param input - Input data for the endpoint
|
|
77
|
+
* @returns Endpoint result
|
|
78
|
+
*/
|
|
79
|
+
async call(endpointId, input) {
|
|
80
|
+
const url = `${this.baseURL}/api/agents/${this.agentId}/lavs/${endpointId}`;
|
|
81
|
+
try {
|
|
82
|
+
const token = this.getAuthToken();
|
|
83
|
+
const headers = {
|
|
84
|
+
'Content-Type': 'application/json',
|
|
85
|
+
};
|
|
86
|
+
if (token) {
|
|
87
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
88
|
+
}
|
|
89
|
+
// Add projectPath to headers if available
|
|
90
|
+
if (this.projectPath) {
|
|
91
|
+
headers['X-Project-Path'] = this.projectPath;
|
|
92
|
+
console.log('[LAVSClient] Adding X-Project-Path header:', this.projectPath);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
console.log('[LAVSClient] No projectPath available');
|
|
96
|
+
}
|
|
97
|
+
const response = await fetch(url, {
|
|
98
|
+
method: 'POST',
|
|
99
|
+
headers,
|
|
100
|
+
credentials: 'include',
|
|
101
|
+
body: JSON.stringify(input || {}),
|
|
102
|
+
});
|
|
103
|
+
if (!response.ok) {
|
|
104
|
+
const body = await response.json();
|
|
105
|
+
// Handle JSON-RPC error format
|
|
106
|
+
const rpcError = body.error || body;
|
|
107
|
+
throw new LAVSError(rpcError.code || -1, rpcError.message || rpcError.error || `HTTP ${response.status}: ${response.statusText}`, rpcError.data);
|
|
108
|
+
}
|
|
109
|
+
const body = await response.json();
|
|
110
|
+
// Unwrap JSON-RPC 2.0 response: { jsonrpc: '2.0', result: data }
|
|
111
|
+
return (body.result ?? body);
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
if (error instanceof LAVSError) {
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
throw new LAVSError(-1, `Failed to call endpoint: ${error.message}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Subscribe to a LAVS subscription endpoint via SSE.
|
|
122
|
+
*
|
|
123
|
+
* Opens a Server-Sent Events connection to the endpoint's /subscribe URL.
|
|
124
|
+
* Returns an unsubscribe function to close the connection.
|
|
125
|
+
*
|
|
126
|
+
* @param endpointId - Subscription endpoint ID from manifest
|
|
127
|
+
* @param callback - Called with event data on each SSE message
|
|
128
|
+
* @param options - Optional: onError handler, onConnected handler
|
|
129
|
+
* @returns Unsubscribe function to close the SSE connection
|
|
130
|
+
*/
|
|
131
|
+
subscribe(endpointId, callback, options) {
|
|
132
|
+
const url = `${this.baseURL}/api/agents/${this.agentId}/lavs/${endpointId}/subscribe`;
|
|
133
|
+
const eventSource = new EventSource(url, {
|
|
134
|
+
withCredentials: true,
|
|
135
|
+
});
|
|
136
|
+
// Handle connection established
|
|
137
|
+
eventSource.addEventListener('connected', (event) => {
|
|
138
|
+
try {
|
|
139
|
+
const info = JSON.parse(event.data);
|
|
140
|
+
console.log('[LAVSClient] SSE connected:', info);
|
|
141
|
+
options?.onConnected?.(info);
|
|
142
|
+
}
|
|
143
|
+
catch (e) {
|
|
144
|
+
console.warn('[LAVSClient] Failed to parse connected event:', e);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
// Handle data events
|
|
148
|
+
eventSource.addEventListener('data', (event) => {
|
|
149
|
+
try {
|
|
150
|
+
const data = JSON.parse(event.data);
|
|
151
|
+
callback(data);
|
|
152
|
+
}
|
|
153
|
+
catch (e) {
|
|
154
|
+
console.warn('[LAVSClient] Failed to parse SSE data:', e);
|
|
155
|
+
callback(event.data); // Pass raw data if not JSON
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
// Handle heartbeat (keep-alive)
|
|
159
|
+
eventSource.addEventListener('heartbeat', () => {
|
|
160
|
+
// Heartbeat received, connection is alive
|
|
161
|
+
});
|
|
162
|
+
// Handle generic messages (no event type)
|
|
163
|
+
eventSource.onmessage = (event) => {
|
|
164
|
+
try {
|
|
165
|
+
const data = JSON.parse(event.data);
|
|
166
|
+
callback(data);
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
callback(event.data);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
// Handle errors
|
|
173
|
+
eventSource.onerror = (event) => {
|
|
174
|
+
console.error('[LAVSClient] SSE error:', event);
|
|
175
|
+
options?.onError?.(event);
|
|
176
|
+
};
|
|
177
|
+
// Return unsubscribe function
|
|
178
|
+
return () => {
|
|
179
|
+
console.log('[LAVSClient] Closing SSE connection for:', endpointId);
|
|
180
|
+
eventSource.close();
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Clear manifest cache (force reload on next getManifest)
|
|
185
|
+
*/
|
|
186
|
+
clearCache() {
|
|
187
|
+
this.manifest = null;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAgB,SAAS,EAAE,MAAM,SAAS,CAAC;AAWlD;;GAEG;AACH,MAAM,OAAO,UAAU;IACb,OAAO,CAAS;IAChB,OAAO,CAAS;IAChB,WAAW,CAAU;IACrB,QAAQ,GAAwB,IAAI,CAAC;IAE7C,YAAY,OAA0B;QACpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;QACzD,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QAEvC,gBAAgB;QAChB,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE;YACvC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,cAAc,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW;SACnC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,YAAY;QAClB,iDAAiD;QACjD,OAAO,YAAY,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACjF,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW;QACf,IAAI,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,CAAC;YACpE,WAAW,CAAC,KAAK,EAAE,CAAC;QACtB,CAAC,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,UAAU;QACR,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LAVS Client Types
|
|
3
|
+
*
|
|
4
|
+
* Frontend type definitions for LAVS (Local Agent View Service)
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* LAVS Manifest - describes the agent's data interface
|
|
8
|
+
*/
|
|
9
|
+
export interface LAVSManifest {
|
|
10
|
+
lavs: string;
|
|
11
|
+
name: string;
|
|
12
|
+
version: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
endpoints: Endpoint[];
|
|
15
|
+
view?: ViewConfig;
|
|
16
|
+
types?: Record<string, any>;
|
|
17
|
+
permissions?: Permissions;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Endpoint definition
|
|
21
|
+
*/
|
|
22
|
+
export interface Endpoint {
|
|
23
|
+
id: string;
|
|
24
|
+
method: 'query' | 'mutation' | 'subscription';
|
|
25
|
+
description?: string;
|
|
26
|
+
handler: Handler;
|
|
27
|
+
schema?: Schema;
|
|
28
|
+
permissions?: Permissions;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Handler types
|
|
32
|
+
*/
|
|
33
|
+
export type Handler = ScriptHandler | FunctionHandler | HTTPHandler | MCPHandler;
|
|
34
|
+
export interface ScriptHandler {
|
|
35
|
+
type: 'script';
|
|
36
|
+
command: string;
|
|
37
|
+
args?: string[];
|
|
38
|
+
input?: 'args' | 'stdin' | 'env';
|
|
39
|
+
cwd?: string;
|
|
40
|
+
timeout?: number;
|
|
41
|
+
env?: Record<string, string>;
|
|
42
|
+
}
|
|
43
|
+
export interface FunctionHandler {
|
|
44
|
+
type: 'function';
|
|
45
|
+
module: string;
|
|
46
|
+
function: string;
|
|
47
|
+
}
|
|
48
|
+
export interface HTTPHandler {
|
|
49
|
+
type: 'http';
|
|
50
|
+
url: string;
|
|
51
|
+
method: string;
|
|
52
|
+
headers?: Record<string, string>;
|
|
53
|
+
}
|
|
54
|
+
export interface MCPHandler {
|
|
55
|
+
type: 'mcp';
|
|
56
|
+
server: string;
|
|
57
|
+
tool: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Schema definition (JSON Schema)
|
|
61
|
+
*/
|
|
62
|
+
export interface Schema {
|
|
63
|
+
input?: any;
|
|
64
|
+
output?: any;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* View configuration
|
|
68
|
+
*/
|
|
69
|
+
export interface ViewConfig {
|
|
70
|
+
component: ComponentSource;
|
|
71
|
+
fallback?: 'list' | 'table' | 'json';
|
|
72
|
+
icon?: string;
|
|
73
|
+
theme?: Record<string, string>;
|
|
74
|
+
}
|
|
75
|
+
export type ComponentSource = {
|
|
76
|
+
type: 'cdn';
|
|
77
|
+
url: string;
|
|
78
|
+
exportName?: string;
|
|
79
|
+
} | {
|
|
80
|
+
type: 'npm';
|
|
81
|
+
package: string;
|
|
82
|
+
version?: string;
|
|
83
|
+
} | {
|
|
84
|
+
type: 'local';
|
|
85
|
+
path: string;
|
|
86
|
+
} | {
|
|
87
|
+
type: 'inline';
|
|
88
|
+
code: string;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Permissions
|
|
92
|
+
*/
|
|
93
|
+
export interface Permissions {
|
|
94
|
+
fileAccess?: string[];
|
|
95
|
+
networkAccess?: boolean | string[];
|
|
96
|
+
maxExecutionTime?: number;
|
|
97
|
+
maxMemory?: number;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* LAVS Error
|
|
101
|
+
*/
|
|
102
|
+
export declare class LAVSError extends Error {
|
|
103
|
+
code: number;
|
|
104
|
+
data?: any | undefined;
|
|
105
|
+
constructor(code: number, message: string, data?: any | undefined);
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;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;IACrB,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,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;IACrB,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,MAAM,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AAI,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAErC;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAC;IACnC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAEzB,IAAI,EAAE,MAAM;IAEZ,IAAI,CAAC,EAAE,GAAG;gBAFV,IAAI,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EACR,IAAI,CAAC,EAAE,GAAG,YAAA;CAKpB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LAVS Client Types
|
|
3
|
+
*
|
|
4
|
+
* Frontend type definitions for LAVS (Local Agent View Service)
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* LAVS Error
|
|
8
|
+
*/
|
|
9
|
+
export class LAVSError extends Error {
|
|
10
|
+
code;
|
|
11
|
+
data;
|
|
12
|
+
constructor(code, message, data) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.code = code;
|
|
15
|
+
this.data = data;
|
|
16
|
+
this.name = 'LAVSError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAgGH;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IAEzB;IAEA;IAHT,YACS,IAAY,EACnB,OAAe,EACR,IAAU;QAEjB,KAAK,CAAC,OAAO,CAAC,CAAC;QAJR,SAAI,GAAJ,IAAI,CAAQ;QAEZ,SAAI,GAAJ,IAAI,CAAM;QAGjB,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "lavs-client",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "LAVS (Local Agent View Service) client SDK for frontend applications",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
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
|
+
"client",
|
|
30
|
+
"frontend",
|
|
31
|
+
"sse"
|
|
32
|
+
],
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/nicepkg/lavs.git",
|
|
37
|
+
"directory": "sdk/typescript/client"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"typescript": "^5.1.6"
|
|
42
|
+
}
|
|
43
|
+
}
|