@agentconnect/host 0.2.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.
@@ -0,0 +1,252 @@
1
+ import type { ChildProcess } from 'child_process';
2
+ export type RpcId = string | number;
3
+ export interface RpcRequest {
4
+ jsonrpc: '2.0';
5
+ id: RpcId;
6
+ method: string;
7
+ params?: Record<string, unknown>;
8
+ }
9
+ export interface RpcSuccess {
10
+ jsonrpc: '2.0';
11
+ id: RpcId;
12
+ result: Record<string, unknown>;
13
+ }
14
+ export type RpcErrorCode = 'AC_ERR_UNAUTHORIZED' | 'AC_ERR_NOT_INSTALLED' | 'AC_ERR_INVALID_ARGS' | 'AC_ERR_UNSUPPORTED' | 'AC_ERR_BUSY' | 'AC_ERR_INTERNAL' | 'AC_ERR_FS_READ' | 'AC_ERR_FS_WRITE' | 'AC_ERR_FS_LIST' | 'AC_ERR_FS_STAT' | 'AC_ERR_PROCESS' | 'AC_ERR_NET' | 'AC_ERR_BACKEND';
15
+ export interface RpcError {
16
+ jsonrpc: '2.0';
17
+ id: RpcId;
18
+ error: {
19
+ code: RpcErrorCode;
20
+ message: string;
21
+ data?: Record<string, unknown>;
22
+ };
23
+ }
24
+ export type RpcResponse = RpcSuccess | RpcError;
25
+ export type ProviderId = 'claude' | 'codex' | 'cursor' | 'local';
26
+ export interface AppManifestEntry {
27
+ type: 'web';
28
+ path: string;
29
+ devUrl?: string;
30
+ }
31
+ export interface AppManifestBackendHealthcheck {
32
+ type: 'http';
33
+ path: string;
34
+ }
35
+ export interface AppManifestBackend {
36
+ runtime: 'node';
37
+ command: string;
38
+ args?: string[];
39
+ cwd?: string;
40
+ env?: Record<string, string>;
41
+ healthcheck?: AppManifestBackendHealthcheck;
42
+ }
43
+ export interface AppManifestAuthor {
44
+ name?: string;
45
+ email?: string;
46
+ url?: string;
47
+ }
48
+ export interface AppManifest {
49
+ id: string;
50
+ name: string;
51
+ version: string;
52
+ description?: string;
53
+ entry: AppManifestEntry;
54
+ backend?: AppManifestBackend;
55
+ capabilities?: string[];
56
+ providers?: ProviderId[];
57
+ models?: {
58
+ default?: string;
59
+ };
60
+ icon?: string;
61
+ repo?: string;
62
+ homepage?: string;
63
+ license?: string;
64
+ author?: AppManifestAuthor;
65
+ keywords?: string[];
66
+ }
67
+ export interface RegistryAppVersion {
68
+ path: string;
69
+ manifest: AppManifest;
70
+ signature?: {
71
+ algorithm: string;
72
+ publicKey: string;
73
+ signature: string;
74
+ };
75
+ hash?: string;
76
+ }
77
+ export interface RegistryApp {
78
+ versions: Record<string, RegistryAppVersion>;
79
+ latest: string;
80
+ }
81
+ export interface RegistryIndex {
82
+ apps: Record<string, RegistryApp>;
83
+ }
84
+ export interface ProviderStatus {
85
+ installed: boolean;
86
+ loggedIn: boolean;
87
+ version?: string;
88
+ updateAvailable?: boolean;
89
+ latestVersion?: string;
90
+ updateCheckedAt?: number;
91
+ updateSource?: 'cli' | 'npm' | 'bun' | 'brew' | 'winget' | 'script' | 'unknown';
92
+ updateCommand?: string;
93
+ updateMessage?: string;
94
+ updateInProgress?: boolean;
95
+ }
96
+ export interface ProviderInfo extends ProviderStatus {
97
+ id: ProviderId;
98
+ name: string;
99
+ }
100
+ export type ProviderDetailLevel = 'minimal' | 'raw';
101
+ export interface ProviderDetail {
102
+ eventType: string;
103
+ data?: Record<string, unknown>;
104
+ raw?: unknown;
105
+ }
106
+ export interface ReasoningEffort {
107
+ id: string;
108
+ label: string;
109
+ }
110
+ export interface ModelInfo {
111
+ id: string;
112
+ provider: ProviderId;
113
+ displayName?: string;
114
+ contextWindow?: number;
115
+ maxOutputTokens?: number;
116
+ reasoningEfforts?: ReasoningEffort[];
117
+ defaultReasoningEffort?: string;
118
+ }
119
+ export interface ProviderLoginOptions {
120
+ baseUrl?: string;
121
+ apiKey?: string;
122
+ model?: string;
123
+ models?: string[];
124
+ loginMethod?: 'claudeai' | 'console';
125
+ loginExperience?: 'embedded' | 'terminal';
126
+ }
127
+ export interface SessionEvent {
128
+ type: 'delta' | 'final' | 'usage' | 'status' | 'error' | 'raw_line' | 'message' | 'thinking' | 'tool_call' | 'detail';
129
+ text?: string;
130
+ message?: string;
131
+ line?: string;
132
+ provider?: ProviderId;
133
+ providerDetail?: ProviderDetail;
134
+ providerSessionId?: string | null;
135
+ inputTokens?: number;
136
+ outputTokens?: number;
137
+ role?: 'system' | 'user' | 'assistant';
138
+ content?: string;
139
+ contentParts?: unknown;
140
+ status?: 'thinking' | 'idle' | 'error';
141
+ phase?: 'delta' | 'start' | 'completed' | 'error';
142
+ name?: string;
143
+ callId?: string;
144
+ input?: unknown;
145
+ output?: unknown;
146
+ timestampMs?: number;
147
+ }
148
+ export interface RunPromptOptions {
149
+ prompt: string;
150
+ resumeSessionId?: string | null;
151
+ model?: string;
152
+ reasoningEffort?: string | null;
153
+ repoRoot?: string;
154
+ cwd?: string;
155
+ providerDetailLevel?: ProviderDetailLevel;
156
+ signal?: AbortSignal;
157
+ onEvent: (event: SessionEvent) => void;
158
+ }
159
+ export interface RunPromptResult {
160
+ sessionId: string | null;
161
+ }
162
+ export type PackageManagerType = 'bun' | 'pnpm' | 'npm' | 'brew' | 'script' | 'unknown';
163
+ export interface InstallResult {
164
+ installed: boolean;
165
+ version?: string;
166
+ packageManager?: PackageManagerType;
167
+ }
168
+ export interface Provider {
169
+ id: ProviderId;
170
+ name: string;
171
+ ensureInstalled(): Promise<InstallResult>;
172
+ fastStatus?(): Promise<ProviderStatus>;
173
+ status(): Promise<ProviderStatus>;
174
+ update(): Promise<ProviderStatus>;
175
+ login(options?: ProviderLoginOptions): Promise<{
176
+ loggedIn: boolean;
177
+ }>;
178
+ logout(): Promise<void>;
179
+ listModels?(): Promise<ModelInfo[]>;
180
+ runPrompt(options: RunPromptOptions): Promise<RunPromptResult>;
181
+ }
182
+ export interface SessionState {
183
+ id: string;
184
+ providerId: ProviderId;
185
+ model: string;
186
+ providerSessionId: string | null;
187
+ reasoningEffort: string | null;
188
+ cwd?: string;
189
+ repoRoot?: string;
190
+ providerDetailLevel?: ProviderDetailLevel;
191
+ }
192
+ export interface BackendState {
193
+ status: 'starting' | 'running' | 'stopped' | 'error' | 'disabled';
194
+ pid?: number;
195
+ url?: string;
196
+ }
197
+ export interface ProcessHandle {
198
+ pid: number;
199
+ process: ChildProcess;
200
+ }
201
+ export interface ValidationError {
202
+ path: string;
203
+ message: string;
204
+ }
205
+ export interface ValidationWarning {
206
+ path: string;
207
+ message: string;
208
+ }
209
+ export interface RegistryValidationResult {
210
+ valid: boolean;
211
+ errors: ValidationError[];
212
+ warnings: ValidationWarning[];
213
+ }
214
+ export interface ObservedCapabilities {
215
+ requested: string[];
216
+ observed: string[];
217
+ }
218
+ export interface ObservedTracker {
219
+ record(capability: string): void;
220
+ list(): string[];
221
+ snapshot(): ObservedCapabilities;
222
+ flush(): void;
223
+ }
224
+ export interface CommandResult {
225
+ stdout: string;
226
+ stderr: string;
227
+ code: number | null;
228
+ }
229
+ export interface LineParser {
230
+ push(chunk: Buffer | string): void;
231
+ end(): void;
232
+ }
233
+ export interface CollectFilesOptions {
234
+ ignoreNames?: string[];
235
+ ignorePaths?: string[];
236
+ }
237
+ export interface FileEntry {
238
+ name: string;
239
+ path: string;
240
+ type: 'file' | 'dir' | 'link' | 'other';
241
+ size: number;
242
+ }
243
+ export interface FileStat {
244
+ type: 'file' | 'dir' | 'link' | 'other';
245
+ size: number;
246
+ mtime: string;
247
+ }
248
+ export interface SignatureData {
249
+ algorithm: string;
250
+ publicKey: string;
251
+ signature: string;
252
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@agentconnect/host",
3
+ "version": "0.2.0",
4
+ "license": "MIT",
5
+ "type": "module",
6
+ "homepage": "https://github.com/rayzhudev/agent-connect",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/rayzhudev/agent-connect.git",
10
+ "directory": "packages/host"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/rayzhudev/agent-connect/issues"
14
+ },
15
+ "main": "./dist/index.js",
16
+ "types": "./dist/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "import": "./dist/index.js",
20
+ "types": "./dist/index.d.ts",
21
+ "default": "./dist/index.js"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "scripts": {
28
+ "build": "tsc",
29
+ "dev": "tsc --watch"
30
+ },
31
+ "dependencies": {
32
+ "node-pty": "^1.1.0",
33
+ "ws": "^8.17.0"
34
+ },
35
+ "devDependencies": {
36
+ "@types/node": "^20",
37
+ "@types/ws": "^8",
38
+ "typescript": "^5.6.2"
39
+ },
40
+ "engines": {
41
+ "node": ">=20"
42
+ }
43
+ }