@viccy123/tapcli 1.0.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/dist/a2ui/index.d.ts +5 -0
- package/dist/a2ui/index.d.ts.map +1 -0
- package/dist/a2ui/index.js +4 -0
- package/dist/a2ui/index.js.map +1 -0
- package/dist/a2ui/schemas.d.ts +1953 -0
- package/dist/a2ui/schemas.d.ts.map +1 -0
- package/dist/a2ui/schemas.js +107 -0
- package/dist/a2ui/schemas.js.map +1 -0
- package/dist/a2ui/surface-manager.d.ts +21 -0
- package/dist/a2ui/surface-manager.d.ts.map +1 -0
- package/dist/a2ui/surface-manager.js +71 -0
- package/dist/a2ui/surface-manager.js.map +1 -0
- package/dist/a2ui/types.d.ts +50 -0
- package/dist/a2ui/types.d.ts.map +1 -0
- package/dist/a2ui/types.js +2 -0
- package/dist/a2ui/types.js.map +1 -0
- package/dist/ai/analyzer.d.ts +19 -0
- package/dist/ai/analyzer.d.ts.map +1 -0
- package/dist/ai/analyzer.js +87 -0
- package/dist/ai/analyzer.js.map +1 -0
- package/dist/ai/index.d.ts +6 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +4 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/ai/prompts.d.ts +5 -0
- package/dist/ai/prompts.d.ts.map +1 -0
- package/dist/ai/prompts.js +81 -0
- package/dist/ai/prompts.js.map +1 -0
- package/dist/ai/ui-generator.d.ts +14 -0
- package/dist/ai/ui-generator.d.ts.map +1 -0
- package/dist/ai/ui-generator.js +172 -0
- package/dist/ai/ui-generator.js.map +1 -0
- package/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +2 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/pairing.d.ts +18 -0
- package/dist/auth/pairing.d.ts.map +1 -0
- package/dist/auth/pairing.js +59 -0
- package/dist/auth/pairing.js.map +1 -0
- package/dist/config/index.d.ts +7 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +31 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/schema.d.ts +89 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +22 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol/index.d.ts +3 -0
- package/dist/protocol/index.d.ts.map +1 -0
- package/dist/protocol/index.js +3 -0
- package/dist/protocol/index.js.map +1 -0
- package/dist/protocol/schemas.d.ts +77 -0
- package/dist/protocol/schemas.d.ts.map +1 -0
- package/dist/protocol/schemas.js +18 -0
- package/dist/protocol/schemas.js.map +1 -0
- package/dist/protocol/types.d.ts +74 -0
- package/dist/protocol/types.d.ts.map +1 -0
- package/dist/protocol/types.js +2 -0
- package/dist/protocol/types.js.map +1 -0
- package/dist/pty/index.d.ts +5 -0
- package/dist/pty/index.d.ts.map +1 -0
- package/dist/pty/index.js +3 -0
- package/dist/pty/index.js.map +1 -0
- package/dist/pty/session.d.ts +17 -0
- package/dist/pty/session.d.ts.map +1 -0
- package/dist/pty/session.js +71 -0
- package/dist/pty/session.js.map +1 -0
- package/dist/pty/terminal-query-interceptor.d.ts +27 -0
- package/dist/pty/terminal-query-interceptor.d.ts.map +1 -0
- package/dist/pty/terminal-query-interceptor.js +63 -0
- package/dist/pty/terminal-query-interceptor.js.map +1 -0
- package/dist/pty/types.d.ts +13 -0
- package/dist/pty/types.d.ts.map +1 -0
- package/dist/pty/types.js +2 -0
- package/dist/pty/types.js.map +1 -0
- package/dist/server.d.ts +60 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +524 -0
- package/dist/server.js.map +1 -0
- package/dist/transport/client.d.ts +26 -0
- package/dist/transport/client.d.ts.map +1 -0
- package/dist/transport/client.js +68 -0
- package/dist/transport/client.js.map +1 -0
- package/dist/transport/index.d.ts +5 -0
- package/dist/transport/index.d.ts.map +1 -0
- package/dist/transport/index.js +3 -0
- package/dist/transport/index.js.map +1 -0
- package/dist/transport/websocket.d.ts +25 -0
- package/dist/transport/websocket.d.ts.map +1 -0
- package/dist/transport/websocket.js +61 -0
- package/dist/transport/websocket.js.map +1 -0
- package/package.json +39 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
export class A2UIGenerator {
|
|
3
|
+
generate(analysis) {
|
|
4
|
+
if (!analysis.waiting || !analysis.inputType) {
|
|
5
|
+
return { catalogId: 'empty', components: [] };
|
|
6
|
+
}
|
|
7
|
+
switch (analysis.inputType) {
|
|
8
|
+
case 'confirm':
|
|
9
|
+
return this.generateConfirm(analysis);
|
|
10
|
+
case 'select':
|
|
11
|
+
return this.generateSelect(analysis);
|
|
12
|
+
case 'multiSelect':
|
|
13
|
+
return this.generateMultiSelect(analysis);
|
|
14
|
+
case 'text':
|
|
15
|
+
return this.generateText(analysis);
|
|
16
|
+
default:
|
|
17
|
+
return { catalogId: 'empty', components: [] };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
generateConfirm(analysis) {
|
|
21
|
+
const questionId = uuidv4();
|
|
22
|
+
const rowId = uuidv4();
|
|
23
|
+
const yesId = uuidv4();
|
|
24
|
+
const noId = uuidv4();
|
|
25
|
+
const components = [
|
|
26
|
+
{
|
|
27
|
+
id: questionId,
|
|
28
|
+
component: 'text',
|
|
29
|
+
properties: {
|
|
30
|
+
text: analysis.question ?? 'Confirm?',
|
|
31
|
+
style: 'title',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: rowId,
|
|
36
|
+
component: 'card',
|
|
37
|
+
properties: {},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: yesId,
|
|
41
|
+
component: 'button',
|
|
42
|
+
parentId: rowId,
|
|
43
|
+
properties: {
|
|
44
|
+
label: 'Yes',
|
|
45
|
+
variant: 'filled',
|
|
46
|
+
action: { type: 'submit', value: 'yes' },
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: noId,
|
|
51
|
+
component: 'button',
|
|
52
|
+
parentId: rowId,
|
|
53
|
+
properties: {
|
|
54
|
+
label: 'No',
|
|
55
|
+
variant: 'outlined',
|
|
56
|
+
action: { type: 'submit', value: 'no' },
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
];
|
|
60
|
+
return { catalogId: 'confirm', components };
|
|
61
|
+
}
|
|
62
|
+
generateSelect(analysis) {
|
|
63
|
+
const questionId = uuidv4();
|
|
64
|
+
const pickerId = uuidv4();
|
|
65
|
+
const submitId = uuidv4();
|
|
66
|
+
const options = (analysis.options ?? []).map((label, index) => ({
|
|
67
|
+
id: String(index + 1),
|
|
68
|
+
label,
|
|
69
|
+
}));
|
|
70
|
+
const components = [
|
|
71
|
+
{
|
|
72
|
+
id: questionId,
|
|
73
|
+
component: 'text',
|
|
74
|
+
properties: {
|
|
75
|
+
text: analysis.question ?? 'Select an option:',
|
|
76
|
+
style: 'title',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: pickerId,
|
|
81
|
+
component: 'choicePicker',
|
|
82
|
+
properties: {
|
|
83
|
+
options,
|
|
84
|
+
mode: 'single',
|
|
85
|
+
bindTo: 'selection',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: submitId,
|
|
90
|
+
component: 'button',
|
|
91
|
+
properties: {
|
|
92
|
+
label: 'Submit',
|
|
93
|
+
variant: 'filled',
|
|
94
|
+
action: { type: 'submit', valuePath: 'selection' },
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
return { catalogId: 'select', components };
|
|
99
|
+
}
|
|
100
|
+
generateMultiSelect(analysis) {
|
|
101
|
+
const questionId = uuidv4();
|
|
102
|
+
const pickerId = uuidv4();
|
|
103
|
+
const submitId = uuidv4();
|
|
104
|
+
const options = (analysis.options ?? []).map((label, index) => ({
|
|
105
|
+
id: String(index + 1),
|
|
106
|
+
label,
|
|
107
|
+
}));
|
|
108
|
+
const components = [
|
|
109
|
+
{
|
|
110
|
+
id: questionId,
|
|
111
|
+
component: 'text',
|
|
112
|
+
properties: {
|
|
113
|
+
text: analysis.question ?? 'Select options:',
|
|
114
|
+
style: 'title',
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
id: pickerId,
|
|
119
|
+
component: 'choicePicker',
|
|
120
|
+
properties: {
|
|
121
|
+
options,
|
|
122
|
+
mode: 'multiple',
|
|
123
|
+
bindTo: 'selections',
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
id: submitId,
|
|
128
|
+
component: 'button',
|
|
129
|
+
properties: {
|
|
130
|
+
label: 'Submit',
|
|
131
|
+
variant: 'filled',
|
|
132
|
+
action: { type: 'submit', valuePath: 'selections' },
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
];
|
|
136
|
+
return { catalogId: 'multiSelect', components };
|
|
137
|
+
}
|
|
138
|
+
generateText(analysis) {
|
|
139
|
+
const questionId = uuidv4();
|
|
140
|
+
const inputId = uuidv4();
|
|
141
|
+
const submitId = uuidv4();
|
|
142
|
+
const components = [
|
|
143
|
+
{
|
|
144
|
+
id: questionId,
|
|
145
|
+
component: 'text',
|
|
146
|
+
properties: {
|
|
147
|
+
text: analysis.question ?? 'Enter your input:',
|
|
148
|
+
style: 'title',
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
id: inputId,
|
|
153
|
+
component: 'textField',
|
|
154
|
+
properties: {
|
|
155
|
+
placeholder: 'Type here...',
|
|
156
|
+
bindTo: 'input',
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
id: submitId,
|
|
161
|
+
component: 'button',
|
|
162
|
+
properties: {
|
|
163
|
+
label: 'Submit',
|
|
164
|
+
variant: 'filled',
|
|
165
|
+
action: { type: 'submit', valuePath: 'input' },
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
];
|
|
169
|
+
return { catalogId: 'text', components };
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=ui-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-generator.js","sourceRoot":"","sources":["../../src/ai/ui-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AASpC,MAAM,OAAO,aAAa;IACxB,QAAQ,CAAC,QAAwB;QAC/B,IAAI,CAAC,QAAQ,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;YAC7C,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;QAChD,CAAC;QAED,QAAQ,QAAQ,CAAC,SAAS,EAAE,CAAC;YAC3B,KAAK,SAAS;gBACZ,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;YACxC,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;YACvC,KAAK,aAAa;gBAChB,OAAO,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;YAC5C,KAAK,MAAM;gBACT,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;YACrC;gBACE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;QAClD,CAAC;IACH,CAAC;IAEO,eAAe,CAAC,QAAwB;QAC9C,MAAM,UAAU,GAAG,MAAM,EAAE,CAAC;QAC5B,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC;QACvB,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC;QAEtB,MAAM,UA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","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface VerifyCodeResult {
|
|
2
|
+
readonly valid: boolean;
|
|
3
|
+
readonly token?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class PairingManager {
|
|
6
|
+
private readonly codeLength;
|
|
7
|
+
private readonly codeExpiryMs;
|
|
8
|
+
private currentCode;
|
|
9
|
+
private tokens;
|
|
10
|
+
constructor(codeLength?: number, codeExpiryMs?: number);
|
|
11
|
+
generateCode(): string;
|
|
12
|
+
verifyCode(code: string): VerifyCodeResult;
|
|
13
|
+
verifyToken(token: string): boolean;
|
|
14
|
+
revokeToken(token: string): void;
|
|
15
|
+
getCurrentCode(): string | null;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=pairing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pairing.d.ts","sourceRoot":"","sources":["../../src/auth/pairing.ts"],"names":[],"mappings":"AAcA,UAAU,gBAAgB;IACxB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,cAAc;IAKvB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAL/B,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,MAAM,CAAqC;gBAGhC,UAAU,GAAE,MAAU,EACtB,YAAY,GAAE,MAAsB;IAGvD,YAAY,IAAI,MAAM;IAetB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB;IA8B1C,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAInC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAMhC,cAAc,IAAI,MAAM,GAAG,IAAI;CAMhC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
export class PairingManager {
|
|
3
|
+
codeLength;
|
|
4
|
+
codeExpiryMs;
|
|
5
|
+
currentCode = null;
|
|
6
|
+
tokens = new Map();
|
|
7
|
+
constructor(codeLength = 6, codeExpiryMs = 5 * 60 * 1000) {
|
|
8
|
+
this.codeLength = codeLength;
|
|
9
|
+
this.codeExpiryMs = codeExpiryMs;
|
|
10
|
+
}
|
|
11
|
+
generateCode() {
|
|
12
|
+
const code = Array.from({ length: this.codeLength }, () => Math.floor(Math.random() * 10)).join('');
|
|
13
|
+
const now = Date.now();
|
|
14
|
+
this.currentCode = {
|
|
15
|
+
code,
|
|
16
|
+
createdAt: now,
|
|
17
|
+
expiresAt: now + this.codeExpiryMs,
|
|
18
|
+
};
|
|
19
|
+
return code;
|
|
20
|
+
}
|
|
21
|
+
verifyCode(code) {
|
|
22
|
+
if (!this.currentCode) {
|
|
23
|
+
return { valid: false };
|
|
24
|
+
}
|
|
25
|
+
if (Date.now() > this.currentCode.expiresAt) {
|
|
26
|
+
this.currentCode = null;
|
|
27
|
+
return { valid: false };
|
|
28
|
+
}
|
|
29
|
+
if (this.currentCode.code !== code) {
|
|
30
|
+
return { valid: false };
|
|
31
|
+
}
|
|
32
|
+
// Code is valid, generate token and invalidate code
|
|
33
|
+
const token = uuidv4();
|
|
34
|
+
const deviceId = uuidv4();
|
|
35
|
+
const authToken = {
|
|
36
|
+
token,
|
|
37
|
+
deviceId,
|
|
38
|
+
createdAt: Date.now(),
|
|
39
|
+
};
|
|
40
|
+
this.tokens = new Map(this.tokens).set(token, authToken);
|
|
41
|
+
this.currentCode = null;
|
|
42
|
+
return { valid: true, token };
|
|
43
|
+
}
|
|
44
|
+
verifyToken(token) {
|
|
45
|
+
return this.tokens.has(token);
|
|
46
|
+
}
|
|
47
|
+
revokeToken(token) {
|
|
48
|
+
const newTokens = new Map(this.tokens);
|
|
49
|
+
newTokens.delete(token);
|
|
50
|
+
this.tokens = newTokens;
|
|
51
|
+
}
|
|
52
|
+
getCurrentCode() {
|
|
53
|
+
if (!this.currentCode || Date.now() > this.currentCode.expiresAt) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return this.currentCode.code;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=pairing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pairing.js","sourceRoot":"","sources":["../../src/auth/pairing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAmBpC,MAAM,OAAO,cAAc;IAKN;IACA;IALX,WAAW,GAAuB,IAAI,CAAC;IACvC,MAAM,GAA2B,IAAI,GAAG,EAAE,CAAC;IAEnD,YACmB,aAAqB,CAAC,EACtB,eAAuB,CAAC,GAAG,EAAE,GAAG,IAAI;QADpC,eAAU,GAAV,UAAU,CAAY;QACtB,iBAAY,GAAZ,YAAY,CAAwB;IACpD,CAAC;IAEJ,YAAY;QACV,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,GAAG,EAAE,CACxD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAC/B,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEX,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,WAAW,GAAG;YACjB,IAAI;YACJ,SAAS,EAAE,GAAG;YACd,SAAS,EAAE,GAAG,GAAG,IAAI,CAAC,YAAY;SACnC,CAAC;QA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IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC;YACjE,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IAC/B,CAAC;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Config } from './schema.js';
|
|
2
|
+
type DeepPartial<T> = {
|
|
3
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
4
|
+
};
|
|
5
|
+
export declare function loadConfig(overrides?: DeepPartial<Config>): Config;
|
|
6
|
+
export { type Config } from './schema.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAExD,KAAK,WAAW,CAAC,CAAC,IAAI;KACnB,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAChE,CAAC;AAuBF,wBAAgB,UAAU,CAAC,SAAS,GAAE,WAAW,CAAC,MAAM,CAAM,GAAG,MAAM,CAQtE;AAED,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ConfigSchema } from './schema.js';
|
|
2
|
+
const defaultConfig = {
|
|
3
|
+
server: {
|
|
4
|
+
port: 8765,
|
|
5
|
+
host: '0.0.0.0',
|
|
6
|
+
},
|
|
7
|
+
pairing: {
|
|
8
|
+
codeLength: 6,
|
|
9
|
+
codeExpiryMs: 5 * 60 * 1000,
|
|
10
|
+
},
|
|
11
|
+
pty: {
|
|
12
|
+
defaultShell: '/bin/zsh',
|
|
13
|
+
defaultCols: 80,
|
|
14
|
+
defaultRows: 24,
|
|
15
|
+
},
|
|
16
|
+
ai: {
|
|
17
|
+
apiUrl: 'https://api.siliconflow.cn/v1/chat/completions',
|
|
18
|
+
model: 'zai-org/GLM-4.6',
|
|
19
|
+
apiKey: process.env['SILICONFLOW_API_KEY'] ?? '',
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
export function loadConfig(overrides = {}) {
|
|
23
|
+
const merged = {
|
|
24
|
+
server: { ...defaultConfig.server, ...overrides.server },
|
|
25
|
+
pairing: { ...defaultConfig.pairing, ...overrides.pairing },
|
|
26
|
+
pty: { ...defaultConfig.pty, ...overrides.pty },
|
|
27
|
+
ai: { ...defaultConfig.ai, ...overrides.ai },
|
|
28
|
+
};
|
|
29
|
+
return ConfigSchema.parse(merged);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,aAAa,CAAC;AAMxD,MAAM,aAAa,GAAW;IAC5B,MAAM,EAAE;QACN,IAAI,EAAE,IAAI;QACV,IAAI,EAAE,SAAS;KAChB;IACD,OAAO,EAAE;QACP,UAAU,EAAE,CAAC;QACb,YAAY,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI;KAC5B;IACD,GAAG,EAAE;QACH,YAAY,EAAE,UAAU;QACxB,WAAW,EAAE,EAAE;QACf,WAAW,EAAE,EAAE;KAChB;IACD,EAAE,EAAE;QACF,MAAM,EAAE,gDAAgD;QACxD,KAAK,EAAE,iBAAiB;QACxB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,IAAI,EAAE;KACjD;CACF,CAAC;AAEF,MAAM,UAAU,UAAU,CAAC,YAAiC,EAAE;IAC5D,MAAM,MAAM,GAAG;QACb,MAAM,EAAE,EAAE,GAAG,aAAa,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,MAAM,EAAE;QACxD,OAAO,EAAE,EAAE,GAAG,aAAa,CAAC,OAAO,EAAE,GAAG,SAAS,CAAC,OAAO,EAAE;QAC3D,GAAG,EAAE,EAAE,GAAG,aAAa,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,EAAE;QAC/C,EAAE,EAAE,EAAE,GAAG,aAAa,CAAC,EAAE,EAAE,GAAG,SAAS,CAAC,EAAE,EAAE;KAC7C,CAAC;IACF,OAAO,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ConfigSchema: z.ZodObject<{
|
|
3
|
+
server: z.ZodObject<{
|
|
4
|
+
port: z.ZodDefault<z.ZodNumber>;
|
|
5
|
+
host: z.ZodDefault<z.ZodString>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
port: number;
|
|
8
|
+
host: string;
|
|
9
|
+
}, {
|
|
10
|
+
port?: number | undefined;
|
|
11
|
+
host?: string | undefined;
|
|
12
|
+
}>;
|
|
13
|
+
pairing: z.ZodObject<{
|
|
14
|
+
codeLength: z.ZodDefault<z.ZodNumber>;
|
|
15
|
+
codeExpiryMs: z.ZodDefault<z.ZodNumber>;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
codeLength: number;
|
|
18
|
+
codeExpiryMs: number;
|
|
19
|
+
}, {
|
|
20
|
+
codeLength?: number | undefined;
|
|
21
|
+
codeExpiryMs?: number | undefined;
|
|
22
|
+
}>;
|
|
23
|
+
pty: z.ZodObject<{
|
|
24
|
+
defaultShell: z.ZodDefault<z.ZodString>;
|
|
25
|
+
defaultCols: z.ZodDefault<z.ZodNumber>;
|
|
26
|
+
defaultRows: z.ZodDefault<z.ZodNumber>;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
defaultShell: string;
|
|
29
|
+
defaultCols: number;
|
|
30
|
+
defaultRows: number;
|
|
31
|
+
}, {
|
|
32
|
+
defaultShell?: string | undefined;
|
|
33
|
+
defaultCols?: number | undefined;
|
|
34
|
+
defaultRows?: number | undefined;
|
|
35
|
+
}>;
|
|
36
|
+
ai: z.ZodObject<{
|
|
37
|
+
apiUrl: z.ZodDefault<z.ZodString>;
|
|
38
|
+
model: z.ZodDefault<z.ZodString>;
|
|
39
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
apiUrl: string;
|
|
42
|
+
model: string;
|
|
43
|
+
apiKey?: string | undefined;
|
|
44
|
+
}, {
|
|
45
|
+
apiUrl?: string | undefined;
|
|
46
|
+
model?: string | undefined;
|
|
47
|
+
apiKey?: string | undefined;
|
|
48
|
+
}>;
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
server: {
|
|
51
|
+
port: number;
|
|
52
|
+
host: string;
|
|
53
|
+
};
|
|
54
|
+
pairing: {
|
|
55
|
+
codeLength: number;
|
|
56
|
+
codeExpiryMs: number;
|
|
57
|
+
};
|
|
58
|
+
pty: {
|
|
59
|
+
defaultShell: string;
|
|
60
|
+
defaultCols: number;
|
|
61
|
+
defaultRows: number;
|
|
62
|
+
};
|
|
63
|
+
ai: {
|
|
64
|
+
apiUrl: string;
|
|
65
|
+
model: string;
|
|
66
|
+
apiKey?: string | undefined;
|
|
67
|
+
};
|
|
68
|
+
}, {
|
|
69
|
+
server: {
|
|
70
|
+
port?: number | undefined;
|
|
71
|
+
host?: string | undefined;
|
|
72
|
+
};
|
|
73
|
+
pairing: {
|
|
74
|
+
codeLength?: number | undefined;
|
|
75
|
+
codeExpiryMs?: number | undefined;
|
|
76
|
+
};
|
|
77
|
+
pty: {
|
|
78
|
+
defaultShell?: string | undefined;
|
|
79
|
+
defaultCols?: number | undefined;
|
|
80
|
+
defaultRows?: number | undefined;
|
|
81
|
+
};
|
|
82
|
+
ai: {
|
|
83
|
+
apiUrl?: string | undefined;
|
|
84
|
+
model?: string | undefined;
|
|
85
|
+
apiKey?: string | undefined;
|
|
86
|
+
};
|
|
87
|
+
}>;
|
|
88
|
+
export type Config = z.infer<typeof ConfigSchema>;
|
|
89
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmBvB,CAAC;AAEH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const ConfigSchema = z.object({
|
|
3
|
+
server: z.object({
|
|
4
|
+
port: z.number().min(1024).max(65535).default(8765),
|
|
5
|
+
host: z.string().default('0.0.0.0'),
|
|
6
|
+
}),
|
|
7
|
+
pairing: z.object({
|
|
8
|
+
codeLength: z.number().default(6),
|
|
9
|
+
codeExpiryMs: z.number().default(5 * 60 * 1000), // 5 minutes
|
|
10
|
+
}),
|
|
11
|
+
pty: z.object({
|
|
12
|
+
defaultShell: z.string().default('/bin/zsh'),
|
|
13
|
+
defaultCols: z.number().default(80),
|
|
14
|
+
defaultRows: z.number().default(24),
|
|
15
|
+
}),
|
|
16
|
+
ai: z.object({
|
|
17
|
+
apiUrl: z.string().default('https://api.siliconflow.cn/v1/chat/completions'),
|
|
18
|
+
model: z.string().default('glm-4-flash'),
|
|
19
|
+
apiKey: z.string().optional(),
|
|
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E,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KAC9B,CAAC;CACH,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { TapCLIServer } from './server.js';
|
|
3
|
+
import { networkInterfaces } from 'os';
|
|
4
|
+
function getLocalIP() {
|
|
5
|
+
const nets = networkInterfaces();
|
|
6
|
+
for (const name of Object.keys(nets)) {
|
|
7
|
+
for (const net of nets[name] ?? []) {
|
|
8
|
+
if (net.family === 'IPv4' && !net.internal) {
|
|
9
|
+
return net.address;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return '127.0.0.1';
|
|
14
|
+
}
|
|
15
|
+
const server = new TapCLIServer();
|
|
16
|
+
const code = server.generatePairingCode();
|
|
17
|
+
const ip = getLocalIP();
|
|
18
|
+
process.stdout.write(`
|
|
19
|
+
╔════════════════════════════════════════╗
|
|
20
|
+
║ TapCLI Server ║
|
|
21
|
+
╠════════════════════════════════════════╣
|
|
22
|
+
║ IP: ${ip.padEnd(33)}║
|
|
23
|
+
║ Port: ${server.getPort().toString().padEnd(31)}║
|
|
24
|
+
║ Pairing Code: ${code.padEnd(24)}║
|
|
25
|
+
╚════════════════════════════════════════╝
|
|
26
|
+
|
|
27
|
+
Waiting for connection...
|
|
28
|
+
`);
|
|
29
|
+
process.on('SIGINT', () => {
|
|
30
|
+
process.stdout.write('\nShutting down...\n');
|
|
31
|
+
server.close();
|
|
32
|
+
process.exit(0);
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,O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AY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ClientMessage } from './types.js';
|
|
3
|
+
export declare const ClientMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
4
|
+
type: z.ZodLiteral<"auth">;
|
|
5
|
+
token: z.ZodString;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
type: "auth";
|
|
8
|
+
token: string;
|
|
9
|
+
}, {
|
|
10
|
+
type: "auth";
|
|
11
|
+
token: string;
|
|
12
|
+
}>, z.ZodObject<{
|
|
13
|
+
type: z.ZodLiteral<"pair">;
|
|
14
|
+
code: z.ZodString;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
type: "pair";
|
|
17
|
+
code: string;
|
|
18
|
+
}, {
|
|
19
|
+
type: "pair";
|
|
20
|
+
code: string;
|
|
21
|
+
}>, z.ZodObject<{
|
|
22
|
+
type: z.ZodLiteral<"start">;
|
|
23
|
+
command: z.ZodString;
|
|
24
|
+
cols: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
rows: z.ZodOptional<z.ZodNumber>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
type: "start";
|
|
28
|
+
command: string;
|
|
29
|
+
cols?: number | undefined;
|
|
30
|
+
rows?: number | undefined;
|
|
31
|
+
}, {
|
|
32
|
+
type: "start";
|
|
33
|
+
command: string;
|
|
34
|
+
cols?: number | undefined;
|
|
35
|
+
rows?: number | undefined;
|
|
36
|
+
}>, z.ZodObject<{
|
|
37
|
+
type: z.ZodLiteral<"input">;
|
|
38
|
+
data: z.ZodString;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
type: "input";
|
|
41
|
+
data: string;
|
|
42
|
+
}, {
|
|
43
|
+
type: "input";
|
|
44
|
+
data: string;
|
|
45
|
+
}>, z.ZodObject<{
|
|
46
|
+
type: z.ZodLiteral<"resize">;
|
|
47
|
+
cols: z.ZodNumber;
|
|
48
|
+
rows: z.ZodNumber;
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
type: "resize";
|
|
51
|
+
cols: number;
|
|
52
|
+
rows: number;
|
|
53
|
+
}, {
|
|
54
|
+
type: "resize";
|
|
55
|
+
cols: number;
|
|
56
|
+
rows: number;
|
|
57
|
+
}>, z.ZodObject<{
|
|
58
|
+
type: z.ZodLiteral<"action">;
|
|
59
|
+
actionId: z.ZodString;
|
|
60
|
+
data: z.ZodUnknown;
|
|
61
|
+
}, "strip", z.ZodTypeAny, {
|
|
62
|
+
type: "action";
|
|
63
|
+
actionId: string;
|
|
64
|
+
data?: unknown;
|
|
65
|
+
}, {
|
|
66
|
+
type: "action";
|
|
67
|
+
actionId: string;
|
|
68
|
+
data?: unknown;
|
|
69
|
+
}>, z.ZodObject<{
|
|
70
|
+
type: z.ZodLiteral<"ping">;
|
|
71
|
+
}, "strip", z.ZodTypeAny, {
|
|
72
|
+
type: "ping";
|
|
73
|
+
}, {
|
|
74
|
+
type: "ping";
|
|
75
|
+
}>]>;
|
|
76
|
+
export declare function parseClientMessage(data: unknown): ClientMessage;
|
|
77
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/protocol/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAY9B,CAAC;AAEH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,aAAa,CAE/D"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const ClientMessageSchema = z.discriminatedUnion('type', [
|
|
3
|
+
z.object({ type: z.literal('auth'), token: z.string() }),
|
|
4
|
+
z.object({ type: z.literal('pair'), code: z.string() }),
|
|
5
|
+
z.object({ type: z.literal('start'), command: z.string(), cols: z.number().optional(), rows: z.number().optional() }),
|
|
6
|
+
z.object({ type: z.literal('input'), data: z.string() }),
|
|
7
|
+
z.object({ type: z.literal('resize'), cols: z.number(), rows: z.number() }),
|
|
8
|
+
z.object({
|
|
9
|
+
type: z.literal('action'),
|
|
10
|
+
actionId: z.string(),
|
|
11
|
+
data: z.unknown(),
|
|
12
|
+
}),
|
|
13
|
+
z.object({ type: z.literal('ping') }),
|
|
14
|
+
]);
|
|
15
|
+
export function parseClientMessage(data) {
|
|
16
|
+
return ClientMessageSchema.parse(data);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/protocol/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IAC9D,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;IACxD,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;IACvD,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