gemkit-cli 0.2.3 → 0.3.1
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 +141 -7
- package/dist/commands/agent/index.d.ts +9 -0
- package/dist/commands/agent/index.js +1329 -0
- package/dist/commands/cache/index.d.ts +5 -0
- package/dist/commands/cache/index.js +43 -0
- package/dist/commands/catalog/index.d.ts +2 -0
- package/dist/commands/catalog/index.js +57 -0
- package/dist/commands/config/index.d.ts +7 -0
- package/dist/commands/config/index.js +122 -0
- package/dist/commands/convert/index.d.ts +8 -0
- package/dist/commands/convert/index.js +391 -0
- package/dist/commands/doctor/index.d.ts +2 -0
- package/dist/commands/doctor/index.js +243 -0
- package/dist/commands/extension/index.d.ts +5 -0
- package/dist/commands/extension/index.js +52 -0
- package/dist/commands/index.d.ts +5 -0
- package/dist/commands/index.js +37 -0
- package/dist/commands/init/index.d.ts +6 -0
- package/dist/commands/init/index.js +345 -0
- package/dist/commands/new/index.d.ts +5 -0
- package/dist/commands/new/index.js +49 -0
- package/dist/commands/office/index.d.ts +5 -0
- package/dist/commands/office/index.js +283 -0
- package/dist/commands/paste/index.d.ts +10 -0
- package/dist/commands/paste/index.js +533 -0
- package/dist/commands/plan/index.d.ts +8 -0
- package/dist/commands/plan/index.js +247 -0
- package/dist/commands/session/index.d.ts +8 -0
- package/dist/commands/session/index.js +289 -0
- package/dist/commands/tokens/index.d.ts +6 -0
- package/dist/commands/tokens/index.js +148 -0
- package/dist/commands/update/index.d.ts +26 -0
- package/dist/commands/update/index.js +199 -0
- package/dist/commands/versions/index.d.ts +5 -0
- package/dist/commands/versions/index.js +39 -0
- package/dist/domains/agent/index.d.ts +8 -0
- package/dist/domains/agent/index.js +8 -0
- package/dist/domains/agent/mappings.d.ts +32 -0
- package/dist/domains/agent/mappings.js +164 -0
- package/dist/domains/agent/profile.d.ts +26 -0
- package/dist/domains/agent/profile.js +225 -0
- package/dist/domains/agent/pty-context.d.ts +11 -0
- package/dist/domains/agent/pty-context.js +83 -0
- package/dist/domains/agent/pty-providers.d.ts +18 -0
- package/dist/domains/agent/pty-providers.js +66 -0
- package/dist/domains/agent/pty-session.d.ts +33 -0
- package/dist/domains/agent/pty-session.js +82 -0
- package/dist/domains/agent/pty-types.d.ts +127 -0
- package/dist/domains/agent/pty-types.js +4 -0
- package/dist/domains/agent/search.d.ts +45 -0
- package/dist/domains/agent/search.js +614 -0
- package/dist/domains/agent/types.d.ts +78 -0
- package/dist/domains/agent/types.js +5 -0
- package/dist/domains/agent-office/documents-scanner.d.ts +9 -0
- package/dist/domains/agent-office/documents-scanner.js +143 -0
- package/dist/domains/agent-office/event-emitter.d.ts +43 -0
- package/dist/domains/agent-office/event-emitter.js +86 -0
- package/dist/domains/agent-office/file-watcher.d.ts +40 -0
- package/dist/domains/agent-office/file-watcher.js +173 -0
- package/dist/domains/agent-office/icons.d.ts +11 -0
- package/dist/domains/agent-office/icons.js +36 -0
- package/dist/domains/agent-office/index.d.ts +12 -0
- package/dist/domains/agent-office/index.js +20 -0
- package/dist/domains/agent-office/renderer/web/assets.d.ts +11 -0
- package/dist/domains/agent-office/renderer/web/assets.js +3419 -0
- package/dist/domains/agent-office/renderer/web/server.d.ts +42 -0
- package/dist/domains/agent-office/renderer/web/server.js +228 -0
- package/dist/domains/agent-office/renderer/web.d.ts +30 -0
- package/dist/domains/agent-office/renderer/web.js +111 -0
- package/dist/domains/agent-office/session-bridge.d.ts +23 -0
- package/dist/domains/agent-office/session-bridge.js +171 -0
- package/dist/domains/agent-office/state-machine.d.ts +5 -0
- package/dist/domains/agent-office/state-machine.js +82 -0
- package/dist/domains/agent-office/types.d.ts +91 -0
- package/dist/domains/agent-office/types.js +4 -0
- package/dist/domains/cache/index.d.ts +1 -0
- package/dist/domains/cache/index.js +1 -0
- package/dist/domains/cache/manager.d.ts +22 -0
- package/dist/domains/cache/manager.js +84 -0
- package/dist/domains/config/index.d.ts +5 -0
- package/dist/domains/config/index.js +5 -0
- package/dist/domains/config/manager.d.ts +24 -0
- package/dist/domains/config/manager.js +85 -0
- package/dist/domains/config/schema.d.ts +17 -0
- package/dist/domains/config/schema.js +96 -0
- package/dist/domains/convert/converter.d.ts +78 -0
- package/dist/domains/convert/converter.js +471 -0
- package/dist/domains/convert/index.d.ts +5 -0
- package/dist/domains/convert/index.js +5 -0
- package/dist/domains/convert/types.d.ts +88 -0
- package/dist/domains/convert/types.js +18 -0
- package/dist/domains/github/download.d.ts +12 -0
- package/dist/domains/github/download.js +51 -0
- package/dist/domains/github/index.d.ts +2 -0
- package/dist/domains/github/index.js +2 -0
- package/dist/domains/github/releases.d.ts +16 -0
- package/dist/domains/github/releases.js +68 -0
- package/dist/domains/installation/conflict.d.ts +13 -0
- package/dist/domains/installation/conflict.js +38 -0
- package/dist/domains/installation/file-sync.d.ts +16 -0
- package/dist/domains/installation/file-sync.js +77 -0
- package/dist/domains/installation/index.d.ts +3 -0
- package/dist/domains/installation/index.js +3 -0
- package/dist/domains/installation/metadata.d.ts +20 -0
- package/dist/domains/installation/metadata.js +52 -0
- package/dist/domains/plan/index.d.ts +2 -0
- package/dist/domains/plan/index.js +2 -0
- package/dist/domains/plan/resolver.d.ts +24 -0
- package/dist/domains/plan/resolver.js +164 -0
- package/dist/domains/plan/types.d.ts +13 -0
- package/dist/domains/plan/types.js +4 -0
- package/dist/domains/session/env.d.ts +51 -0
- package/dist/domains/session/env.js +118 -0
- package/dist/domains/session/index.d.ts +8 -0
- package/dist/domains/session/index.js +8 -0
- package/dist/domains/session/manager.d.ts +56 -0
- package/dist/domains/session/manager.js +205 -0
- package/dist/domains/session/paths.d.ts +6 -0
- package/dist/domains/session/paths.js +6 -0
- package/dist/domains/session/types.d.ts +121 -0
- package/dist/domains/session/types.js +5 -0
- package/dist/domains/session/writer.d.ts +82 -0
- package/dist/domains/session/writer.js +431 -0
- package/dist/domains/tokens/index.d.ts +5 -0
- package/dist/domains/tokens/index.js +5 -0
- package/dist/domains/tokens/pricing.d.ts +38 -0
- package/dist/domains/tokens/pricing.js +129 -0
- package/dist/domains/tokens/scanner.d.ts +42 -0
- package/dist/domains/tokens/scanner.js +168 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +90 -59
- package/dist/services/aipty.d.ts +76 -0
- package/dist/services/aipty.js +276 -0
- package/dist/services/archive.d.ts +22 -0
- package/dist/services/archive.js +53 -0
- package/dist/services/auto-update.d.ts +26 -0
- package/dist/services/auto-update.js +117 -0
- package/dist/services/hash.d.ts +36 -0
- package/dist/services/hash.js +63 -0
- package/dist/services/logger.d.ts +28 -0
- package/dist/services/logger.js +102 -0
- package/dist/services/music.d.ts +67 -0
- package/dist/services/music.js +290 -0
- package/dist/services/npm.d.ts +22 -0
- package/dist/services/npm.js +65 -0
- package/dist/services/pty-client.d.ts +66 -0
- package/dist/services/pty-client.js +154 -0
- package/dist/services/pty-server.d.ts +102 -0
- package/dist/services/pty-server.js +613 -0
- package/dist/types/index.d.ts +155 -0
- package/dist/types/index.js +4 -0
- package/dist/utils/colors.d.ts +43 -0
- package/dist/utils/colors.js +98 -0
- package/dist/utils/errors.d.ts +24 -0
- package/dist/utils/errors.js +56 -0
- package/dist/utils/paths.d.ts +46 -0
- package/dist/utils/paths.js +89 -0
- package/dist/utils/platform.d.ts +11 -0
- package/dist/utils/platform.js +31 -0
- package/package.json +55 -54
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PTY Client - Sends commands to the PTY server
|
|
3
|
+
* Ported from claude-pty-wrapper/client.js
|
|
4
|
+
*/
|
|
5
|
+
import net from 'net';
|
|
6
|
+
const DEFAULT_PORT = 3377;
|
|
7
|
+
const DEFAULT_HOST = '127.0.0.1';
|
|
8
|
+
export class PtyClient {
|
|
9
|
+
port;
|
|
10
|
+
host;
|
|
11
|
+
constructor(port = DEFAULT_PORT, host = DEFAULT_HOST) {
|
|
12
|
+
this.port = port;
|
|
13
|
+
this.host = host;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Send command to server and get response
|
|
17
|
+
*/
|
|
18
|
+
sendCommand(command) {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
const client = new net.Socket();
|
|
21
|
+
let response = '';
|
|
22
|
+
client.setTimeout(10000);
|
|
23
|
+
client.connect(this.port, this.host, () => {
|
|
24
|
+
client.write(command + '\n');
|
|
25
|
+
});
|
|
26
|
+
client.on('data', (data) => {
|
|
27
|
+
response += data.toString();
|
|
28
|
+
client.destroy();
|
|
29
|
+
});
|
|
30
|
+
client.on('close', () => {
|
|
31
|
+
resolve(response.trim());
|
|
32
|
+
});
|
|
33
|
+
client.on('error', (err) => {
|
|
34
|
+
if (err.code === 'ECONNREFUSED') {
|
|
35
|
+
reject(new Error('No server running. Use "gk agent start" first.'));
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
reject(err);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
client.on('timeout', () => {
|
|
42
|
+
client.destroy();
|
|
43
|
+
reject(new Error('Connection timeout'));
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Check if server is running
|
|
49
|
+
*/
|
|
50
|
+
async isServerRunning() {
|
|
51
|
+
try {
|
|
52
|
+
await this.sendCommand('status');
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get server status
|
|
61
|
+
*/
|
|
62
|
+
async status() {
|
|
63
|
+
const response = await this.sendCommand('status');
|
|
64
|
+
return JSON.parse(response);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Send prompt to session
|
|
68
|
+
*/
|
|
69
|
+
async send(prompt) {
|
|
70
|
+
const response = await this.sendCommand('send ' + prompt);
|
|
71
|
+
return JSON.parse(response);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Wait for completion
|
|
75
|
+
*/
|
|
76
|
+
async waitForCompletion(timeout = 120) {
|
|
77
|
+
const startTime = Date.now();
|
|
78
|
+
const timeoutMs = timeout * 1000;
|
|
79
|
+
while (Date.now() - startTime < timeoutMs) {
|
|
80
|
+
try {
|
|
81
|
+
const result = await this.complete();
|
|
82
|
+
if (result.complete) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
if (result.reason === 'pending_tool') {
|
|
86
|
+
// Tool confirmation needed, return early
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
throw err;
|
|
92
|
+
}
|
|
93
|
+
await this.sleep(2000);
|
|
94
|
+
}
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Check if response is complete
|
|
99
|
+
*/
|
|
100
|
+
async complete() {
|
|
101
|
+
const response = await this.sendCommand('complete');
|
|
102
|
+
return JSON.parse(response);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Get structured exchange output
|
|
106
|
+
*/
|
|
107
|
+
async exchange() {
|
|
108
|
+
const response = await this.sendCommand('exchange');
|
|
109
|
+
return JSON.parse(response);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Check for pending tool confirmations
|
|
113
|
+
*/
|
|
114
|
+
async pending() {
|
|
115
|
+
const response = await this.sendCommand('pending');
|
|
116
|
+
return JSON.parse(response);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Read raw output
|
|
120
|
+
*/
|
|
121
|
+
async read(lines = 200) {
|
|
122
|
+
return await this.sendCommand('read ' + lines);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get exchange history
|
|
126
|
+
*/
|
|
127
|
+
async history() {
|
|
128
|
+
const response = await this.sendCommand('history');
|
|
129
|
+
return JSON.parse(response);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Clear exchange history
|
|
133
|
+
*/
|
|
134
|
+
async clearHistory() {
|
|
135
|
+
await this.sendCommand('history clear');
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Stop the server
|
|
139
|
+
*/
|
|
140
|
+
async stop() {
|
|
141
|
+
try {
|
|
142
|
+
await this.sendCommand('stop');
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
// Server may have already stopped
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Sleep helper
|
|
150
|
+
*/
|
|
151
|
+
sleep(ms) {
|
|
152
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PTY Server - Maintains AI session and accepts commands via TCP
|
|
3
|
+
* Ported from claude-pty-wrapper/server.js
|
|
4
|
+
*/
|
|
5
|
+
import type { CliProvider } from '../domains/agent/types.js';
|
|
6
|
+
import type { PtySessionState, PtyExchange, PtyToolResult, PtyCompleteResponse, PtyPendingResponse } from '../domains/agent/pty-types.js';
|
|
7
|
+
export interface PtyServerOptions {
|
|
8
|
+
provider: CliProvider;
|
|
9
|
+
model: string;
|
|
10
|
+
tools: string[];
|
|
11
|
+
sessionState: PtySessionState;
|
|
12
|
+
port?: number;
|
|
13
|
+
debug?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare class PtyServer {
|
|
16
|
+
private options;
|
|
17
|
+
private ai;
|
|
18
|
+
private server;
|
|
19
|
+
private outputHistory;
|
|
20
|
+
private lastPromptIndex;
|
|
21
|
+
private lastSentPrompt;
|
|
22
|
+
private lastDataReceivedTime;
|
|
23
|
+
private currentExchangeId;
|
|
24
|
+
private exchangeHistory;
|
|
25
|
+
private streamClients;
|
|
26
|
+
private port;
|
|
27
|
+
private debug;
|
|
28
|
+
pid: number;
|
|
29
|
+
constructor(options: PtyServerOptions);
|
|
30
|
+
/**
|
|
31
|
+
* Start the server
|
|
32
|
+
*/
|
|
33
|
+
start(): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Start TCP server for client commands
|
|
36
|
+
*/
|
|
37
|
+
private startTcpServer;
|
|
38
|
+
/**
|
|
39
|
+
* Handle client command
|
|
40
|
+
*/
|
|
41
|
+
handleCommand(cmd: string, args: string): string;
|
|
42
|
+
/**
|
|
43
|
+
* Handle send command
|
|
44
|
+
*/
|
|
45
|
+
private handleSend;
|
|
46
|
+
/**
|
|
47
|
+
* Get server status
|
|
48
|
+
*/
|
|
49
|
+
private getStatus;
|
|
50
|
+
/**
|
|
51
|
+
* Clean ANSI codes from output
|
|
52
|
+
*/
|
|
53
|
+
private cleanAnsi;
|
|
54
|
+
/**
|
|
55
|
+
* Extract answer based on provider
|
|
56
|
+
*/
|
|
57
|
+
extractAnswer(): string;
|
|
58
|
+
/**
|
|
59
|
+
* Extract answer from Claude output
|
|
60
|
+
*/
|
|
61
|
+
private extractAnswerClaude;
|
|
62
|
+
/**
|
|
63
|
+
* Extract answer from Gemini output
|
|
64
|
+
*/
|
|
65
|
+
private extractAnswerGemini;
|
|
66
|
+
/**
|
|
67
|
+
* Detect pending tool confirmations
|
|
68
|
+
*/
|
|
69
|
+
detectPendingTools(): PtyPendingResponse;
|
|
70
|
+
/**
|
|
71
|
+
* Clean tool detail string
|
|
72
|
+
*/
|
|
73
|
+
private cleanToolDetail;
|
|
74
|
+
/**
|
|
75
|
+
* Extract tool results from output
|
|
76
|
+
*/
|
|
77
|
+
extractToolResults(): PtyToolResult[];
|
|
78
|
+
/**
|
|
79
|
+
* Get structured exchange data
|
|
80
|
+
*/
|
|
81
|
+
getStructuredExchange(): PtyExchange;
|
|
82
|
+
/**
|
|
83
|
+
* Check if response is complete
|
|
84
|
+
*/
|
|
85
|
+
isComplete(): PtyCompleteResponse;
|
|
86
|
+
/**
|
|
87
|
+
* Parse output for stream events
|
|
88
|
+
*/
|
|
89
|
+
private parseOutputForEvents;
|
|
90
|
+
/**
|
|
91
|
+
* Emit event to stream clients
|
|
92
|
+
*/
|
|
93
|
+
private emitStreamEvent;
|
|
94
|
+
/**
|
|
95
|
+
* Stop the server
|
|
96
|
+
*/
|
|
97
|
+
stop(): Promise<void>;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Start server as standalone process
|
|
101
|
+
*/
|
|
102
|
+
export declare function startPtyServerProcess(options: PtyServerOptions): Promise<void>;
|