@elizaos/plugin-ngrok 2.0.0-beta.1 ā 2.0.3-beta.2
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/LICENSE +21 -0
- package/README.md +38 -294
- package/package.json +24 -7
- package/src/__tests__/test-utils.ts +2 -2
- package/src/__tests__/unit/environment.test.ts +1 -1
- package/dist/__tests__/NgrokTestSuite.d.ts +0 -6
- package/dist/__tests__/NgrokTestSuite.d.ts.map +0 -1
- package/dist/__tests__/NgrokTestSuite.js +0 -92
- package/dist/__tests__/NgrokTestSuite.js.map +0 -1
- package/dist/actions/get-tunnel-status.d.ts +0 -4
- package/dist/actions/get-tunnel-status.d.ts.map +0 -1
- package/dist/actions/get-tunnel-status.js +0 -186
- package/dist/actions/get-tunnel-status.js.map +0 -1
- package/dist/actions/start-tunnel.d.ts +0 -4
- package/dist/actions/start-tunnel.d.ts.map +0 -1
- package/dist/actions/start-tunnel.js +0 -221
- package/dist/actions/start-tunnel.js.map +0 -1
- package/dist/actions/stop-tunnel.d.ts +0 -4
- package/dist/actions/stop-tunnel.d.ts.map +0 -1
- package/dist/actions/stop-tunnel.js +0 -174
- package/dist/actions/stop-tunnel.js.map +0 -1
- package/dist/environment.d.ts +0 -12
- package/dist/environment.d.ts.map +0 -1
- package/dist/environment.js +0 -68
- package/dist/environment.js.map +0 -1
- package/dist/index.d.ts +0 -13
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -29
- package/dist/index.js.map +0 -1
- package/dist/services/NgrokService.d.ts +0 -30
- package/dist/services/NgrokService.d.ts.map +0 -1
- package/dist/services/NgrokService.js +0 -333
- package/dist/services/NgrokService.js.map +0 -1
- package/src/__tests__/e2e/real-ngrok.test.ts +0 -543
- package/src/__tests__/unit/actions.test.ts +0 -402
- package/src/actions/get-tunnel-status.ts +0 -218
- package/src/actions/start-tunnel.ts +0 -255
- package/src/actions/stop-tunnel.ts +0 -203
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { elizaLogger, } from '@elizaos/core';
|
|
2
|
-
import { getTunnelService } from '@elizaos/plugin-tunnel';
|
|
3
|
-
export const getTunnelStatusAction = {
|
|
4
|
-
name: 'GET_TUNNEL_STATUS',
|
|
5
|
-
similes: ['TUNNEL_STATUS', 'CHECK_TUNNEL', 'NGROK_STATUS', 'TUNNEL_INFO'],
|
|
6
|
-
description: 'Get the current status of the ngrok tunnel including URL, port, and uptime information. Supports action chaining by providing tunnel metadata for monitoring workflows, health checks, or conditional tunnel management.',
|
|
7
|
-
validate: async (runtime, _message) => {
|
|
8
|
-
return !!getTunnelService(runtime);
|
|
9
|
-
},
|
|
10
|
-
handler: async (runtime, _message, _state, _options, callback) => {
|
|
11
|
-
try {
|
|
12
|
-
elizaLogger.info('Getting ngrok tunnel status...');
|
|
13
|
-
const tunnelService = getTunnelService(runtime);
|
|
14
|
-
if (!tunnelService) {
|
|
15
|
-
throw new Error('Tunnel service not found');
|
|
16
|
-
}
|
|
17
|
-
const status = tunnelService.getStatus();
|
|
18
|
-
let responseText;
|
|
19
|
-
const response = {
|
|
20
|
-
...status,
|
|
21
|
-
uptime: 'N/A',
|
|
22
|
-
};
|
|
23
|
-
if (status.active) {
|
|
24
|
-
if (status.startedAt) {
|
|
25
|
-
const uptimeMs = Date.now() - new Date(status.startedAt).getTime();
|
|
26
|
-
const minutes = Math.floor(uptimeMs / 60000);
|
|
27
|
-
const hours = Math.floor(minutes / 60);
|
|
28
|
-
if (hours > 0) {
|
|
29
|
-
response.uptime = `${hours} hour${hours > 1 ? 's' : ''}, ${minutes % 60} minute${minutes % 60 !== 1 ? 's' : ''}`;
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
response.uptime = `${minutes} minute${minutes !== 1 ? 's' : ''}`;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
responseText = `ā
Ngrok tunnel is active!\n\nš Public URL: ${status.url}\nš Local Port: ${status.port}\nā±ļø Uptime: ${response.uptime}\nš¢ Provider: ${status.provider}\n\nYour local service is accessible from the internet.`;
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
responseText =
|
|
39
|
-
'ā No active ngrok tunnel.\n\nTo start a tunnel, say "start ngrok tunnel on port [PORT]"';
|
|
40
|
-
}
|
|
41
|
-
const startedAtIso = status.startedAt ? status.startedAt.toISOString() : null;
|
|
42
|
-
if (callback) {
|
|
43
|
-
await callback({
|
|
44
|
-
text: responseText,
|
|
45
|
-
metadata: {
|
|
46
|
-
action: 'tunnel_status',
|
|
47
|
-
uptime: response.uptime,
|
|
48
|
-
active: status.active,
|
|
49
|
-
url: status.url,
|
|
50
|
-
port: status.port,
|
|
51
|
-
startedAt: startedAtIso,
|
|
52
|
-
provider: status.provider,
|
|
53
|
-
backend: status.backend ?? null,
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
return {
|
|
58
|
-
success: true,
|
|
59
|
-
text: responseText,
|
|
60
|
-
values: {
|
|
61
|
-
success: true,
|
|
62
|
-
isActive: status.active,
|
|
63
|
-
tunnelUrl: status.url,
|
|
64
|
-
port: status.port,
|
|
65
|
-
uptime: response.uptime,
|
|
66
|
-
provider: status.provider,
|
|
67
|
-
},
|
|
68
|
-
data: {
|
|
69
|
-
action: 'GET_TUNNEL_STATUS',
|
|
70
|
-
tunnelStatus: {
|
|
71
|
-
active: status.active,
|
|
72
|
-
url: status.url,
|
|
73
|
-
port: status.port,
|
|
74
|
-
startedAt: startedAtIso,
|
|
75
|
-
provider: status.provider,
|
|
76
|
-
backend: status.backend ?? null,
|
|
77
|
-
uptime: response.uptime,
|
|
78
|
-
checkedAt: new Date().toISOString(),
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
85
|
-
const stack = error instanceof Error ? (error.stack ?? null) : null;
|
|
86
|
-
elizaLogger.error(`Failed to get tunnel status: ${message}`);
|
|
87
|
-
if (callback) {
|
|
88
|
-
await callback({
|
|
89
|
-
text: `ā Failed to get tunnel status: ${message}`,
|
|
90
|
-
metadata: {
|
|
91
|
-
error: message,
|
|
92
|
-
action: 'tunnel_status_failed',
|
|
93
|
-
},
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
return {
|
|
97
|
-
success: false,
|
|
98
|
-
text: `ā Failed to get tunnel status: ${message}`,
|
|
99
|
-
values: {
|
|
100
|
-
success: false,
|
|
101
|
-
error: message,
|
|
102
|
-
},
|
|
103
|
-
data: {
|
|
104
|
-
action: 'GET_TUNNEL_STATUS',
|
|
105
|
-
errorType: 'status_check_failed',
|
|
106
|
-
errorDetails: stack,
|
|
107
|
-
},
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
examples: [
|
|
112
|
-
[
|
|
113
|
-
{
|
|
114
|
-
name: '{{user}}',
|
|
115
|
-
content: {
|
|
116
|
-
text: 'What is the tunnel status?',
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
name: '{{agent}}',
|
|
121
|
-
content: {
|
|
122
|
-
text: 'ā
Ngrok tunnel is active!\n\nš Public URL: https://abc123.ngrok.io\nš Local Port: 3000\nā±ļø Uptime: 15 minutes\nš¢ Provider: ngrok\n\nYour local service is accessible from the internet.',
|
|
123
|
-
actions: ['GET_TUNNEL_STATUS'],
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
],
|
|
127
|
-
[
|
|
128
|
-
{
|
|
129
|
-
name: '{{user}}',
|
|
130
|
-
content: {
|
|
131
|
-
text: "Check tunnel status and restart it if it's been running too long",
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
name: '{{agent}}',
|
|
136
|
-
content: {
|
|
137
|
-
text: "I'll check the current tunnel status and restart it if needed.",
|
|
138
|
-
thought: 'User wants me to monitor tunnel uptime and restart if necessary - I should check status first, then decide whether to restart based on uptime.',
|
|
139
|
-
actions: ['GET_TUNNEL_STATUS'],
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
name: '{{agent}}',
|
|
144
|
-
content: {
|
|
145
|
-
text: "Tunnel has been running for 2 hours. That seems like a long time - I'll restart it for optimal performance.",
|
|
146
|
-
thought: 'Status shows the tunnel has been up for 2 hours, which is quite long. I should stop and restart it as requested.',
|
|
147
|
-
actions: ['STOP_TUNNEL'],
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
name: '{{agent}}',
|
|
152
|
-
content: {
|
|
153
|
-
text: 'Tunnel stopped. Now starting a fresh tunnel...',
|
|
154
|
-
thought: 'Old tunnel is down, now I can start a new fresh tunnel for optimal performance.',
|
|
155
|
-
actions: ['START_TUNNEL'],
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
],
|
|
159
|
-
[
|
|
160
|
-
{
|
|
161
|
-
name: '{{user}}',
|
|
162
|
-
content: {
|
|
163
|
-
text: 'Get tunnel info and then update our webhook URLs',
|
|
164
|
-
},
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
name: '{{agent}}',
|
|
168
|
-
content: {
|
|
169
|
-
text: "I'll check the current tunnel status and then update the webhook URLs.",
|
|
170
|
-
thought: 'User needs the current tunnel URL for webhook configuration - I should get the status first, then update webhooks with the public URL.',
|
|
171
|
-
actions: ['GET_TUNNEL_STATUS'],
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
name: '{{agent}}',
|
|
176
|
-
content: {
|
|
177
|
-
text: 'Tunnel is active at https://abc123.ngrok.io. Now updating webhook URLs...',
|
|
178
|
-
thought: 'I have the current tunnel URL from the status check. I can now update the webhook configurations with this public URL.',
|
|
179
|
-
actions: ['UPDATE_WEBHOOKS'],
|
|
180
|
-
},
|
|
181
|
-
},
|
|
182
|
-
],
|
|
183
|
-
],
|
|
184
|
-
};
|
|
185
|
-
export default getTunnelStatusAction;
|
|
186
|
-
//# sourceMappingURL=get-tunnel-status.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-tunnel-status.js","sourceRoot":"","sources":["../../src/actions/get-tunnel-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,WAAW,GAKZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,CAAC,MAAM,qBAAqB,GAAW;IAC3C,IAAI,EAAE,mBAAmB;IACzB,OAAO,EAAE,CAAC,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,CAAC;IACzE,WAAW,EACT,0NAA0N;IAC5N,QAAQ,EAAE,KAAK,EAAE,OAAsB,EAAE,QAAgB,EAAE,EAAE;QAC3D,OAAO,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,EAAE,KAAK,EACZ,OAAsB,EACtB,QAAgB,EAChB,MAAc,EACd,QAAkB,EAClB,QAA0B,EACH,EAAE;QACzB,IAAI,CAAC;YACH,WAAW,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;YAEnD,MAAM,aAAa,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;YAChD,IAAI,CAAC,aAAa,EAAE,CAAC;gBACnB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;YAC9C,CAAC;YAED,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,EAAE,CAAC;YAEzC,IAAI,YAAoB,CAAC;YACzB,MAAM,QAAQ,GAAG;gBACf,GAAG,MAAM;gBACT,MAAM,EAAE,KAAK;aACd,CAAC;YAEF,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;gBAClB,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;oBACrB,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,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;oBACnF,OAAO,EAAE,CAAC,cAAc,CAAC;iBAC1B;aACF;SACF;QACD;YACE;gBACE,IAAI,EAAE,UAAU;gBAChB,OAAO,EAAE;oBACP,IAAI,EAAE,kDAAkD;iBACzD;aACF;YACD;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,wEAAwE;oBAC9E,OAAO,EACL,wIAAwI;oBAC1I,OAAO,EAAE,CAAC,mBAAmB,CAAC;iBAC/B;aACF;YACD;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,2EAA2E;oBACjF,OAAO,EACL,wHAAwH;oBAC1H,OAAO,EAAE,CAAC,iBAAiB,CAAC;iBAC7B;aACF;SACF;KACmB;CACvB,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"start-tunnel.d.ts","sourceRoot":"","sources":["../../src/actions/start-tunnel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EASZ,MAAM,eAAe,CAAC;AAiBvB,eAAO,MAAM,iBAAiB,EAAE,MAiO/B,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import { elizaLogger, ModelType, } from '@elizaos/core';
|
|
2
|
-
import { getTunnelService } from '@elizaos/plugin-tunnel';
|
|
3
|
-
const startTunnelTemplate = `
|
|
4
|
-
Respond with a JSON object containing the port number to start the ngrok tunnel on.
|
|
5
|
-
The user said: "{{userMessage}}"
|
|
6
|
-
|
|
7
|
-
Extract the port number from their message, or use the default port 3000 if not specified.
|
|
8
|
-
|
|
9
|
-
Response format:
|
|
10
|
-
\`\`\`json
|
|
11
|
-
{
|
|
12
|
-
"port": 3000
|
|
13
|
-
}
|
|
14
|
-
\`\`\`
|
|
15
|
-
`;
|
|
16
|
-
export const startTunnelAction = {
|
|
17
|
-
name: 'START_TUNNEL',
|
|
18
|
-
similes: ['OPEN_TUNNEL', 'CREATE_TUNNEL', 'NGROK_START', 'TUNNEL_UP'],
|
|
19
|
-
description: 'Start an ngrok tunnel to expose a local port to the internet. Supports action chaining by providing tunnel metadata that can be used for webhook configuration, API testing, or remote access workflows.',
|
|
20
|
-
validate: async (runtime, _message) => {
|
|
21
|
-
const tunnelService = getTunnelService(runtime);
|
|
22
|
-
if (!tunnelService) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
// Check if tunnel is already active
|
|
26
|
-
if (tunnelService.isActive()) {
|
|
27
|
-
elizaLogger.warn('Tunnel is already active');
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
return true;
|
|
31
|
-
},
|
|
32
|
-
handler: async (runtime, message, _state, _options, callback) => {
|
|
33
|
-
const tunnelService = getTunnelService(runtime);
|
|
34
|
-
if (!tunnelService) {
|
|
35
|
-
elizaLogger.error('Tunnel service is not available');
|
|
36
|
-
if (callback) {
|
|
37
|
-
await callback({
|
|
38
|
-
text: 'Tunnel service is not available. Please ensure the ngrok plugin is properly configured.',
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
success: false,
|
|
43
|
-
text: 'Tunnel service is not available. Please ensure the ngrok plugin is properly configured.',
|
|
44
|
-
values: { success: false, error: 'service_unavailable' },
|
|
45
|
-
data: { action: 'START_TUNNEL' },
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
if (tunnelService.isActive()) {
|
|
49
|
-
elizaLogger.warn('Tunnel is already active');
|
|
50
|
-
if (callback) {
|
|
51
|
-
await callback({
|
|
52
|
-
text: 'Tunnel is already active. Please stop the existing tunnel before starting a new one.',
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
success: false,
|
|
57
|
-
text: 'Tunnel is already active. Please stop the existing tunnel before starting a new one.',
|
|
58
|
-
values: { success: false, error: 'tunnel_already_active' },
|
|
59
|
-
data: { action: 'START_TUNNEL' },
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
elizaLogger.info('Starting ngrok tunnel...');
|
|
63
|
-
try {
|
|
64
|
-
// Extract port from message ā inline the user message into the prompt
|
|
65
|
-
// (TEXT_SMALL no longer accepts a separate `context` param).
|
|
66
|
-
const userMessage = message.content.text ?? '';
|
|
67
|
-
const prompt = startTunnelTemplate.replace('{{userMessage}}', userMessage);
|
|
68
|
-
const portResponse = await runtime.useModel(ModelType.TEXT_SMALL, {
|
|
69
|
-
prompt,
|
|
70
|
-
temperature: 0.3,
|
|
71
|
-
});
|
|
72
|
-
let port = 3000; // default
|
|
73
|
-
try {
|
|
74
|
-
const parsed = JSON.parse(portResponse);
|
|
75
|
-
if (parsed.port) {
|
|
76
|
-
// Handle both number and string port values
|
|
77
|
-
const portNum = typeof parsed.port === 'string' ? parseInt(parsed.port, 10) : parsed.port;
|
|
78
|
-
if (!Number.isNaN(portNum) && portNum > 0 && portNum <= 65535) {
|
|
79
|
-
port = portNum;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
// Try to extract port from plain text response
|
|
85
|
-
const portMatch = portResponse.match(/\b(\d{1,5})\b/);
|
|
86
|
-
if (portMatch) {
|
|
87
|
-
const portNum = parseInt(portMatch[1], 10);
|
|
88
|
-
if (!Number.isNaN(portNum) && portNum > 0 && portNum <= 65535) {
|
|
89
|
-
port = portNum;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
elizaLogger.warn('Failed to parse port from response, using default 3000');
|
|
93
|
-
}
|
|
94
|
-
const url = await tunnelService.startTunnel(port);
|
|
95
|
-
const responseText = `ā
Ngrok tunnel started successfully!\n\nš Public URL: ${url}\nš Local Port: ${port}\n\nYour local service is now accessible from the internet.`;
|
|
96
|
-
if (callback) {
|
|
97
|
-
await callback({
|
|
98
|
-
text: responseText,
|
|
99
|
-
metadata: {
|
|
100
|
-
tunnelUrl: url,
|
|
101
|
-
port,
|
|
102
|
-
action: 'tunnel_started',
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
return {
|
|
107
|
-
success: true,
|
|
108
|
-
text: responseText,
|
|
109
|
-
values: {
|
|
110
|
-
success: true,
|
|
111
|
-
tunnelUrl: url ?? null,
|
|
112
|
-
port,
|
|
113
|
-
isActive: true,
|
|
114
|
-
},
|
|
115
|
-
data: {
|
|
116
|
-
action: 'START_TUNNEL',
|
|
117
|
-
tunnelMetadata: {
|
|
118
|
-
url: url ?? null,
|
|
119
|
-
port,
|
|
120
|
-
startedAt: new Date().toISOString(),
|
|
121
|
-
provider: 'ngrok',
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
128
|
-
const stack = error instanceof Error ? (error.stack ?? null) : null;
|
|
129
|
-
elizaLogger.error(`Failed to start tunnel: ${message}`);
|
|
130
|
-
if (callback) {
|
|
131
|
-
await callback({
|
|
132
|
-
text: `ā Failed to start ngrok tunnel: ${message}\n\nPlease make sure ngrok is installed and configured properly.`,
|
|
133
|
-
metadata: {
|
|
134
|
-
error: message,
|
|
135
|
-
action: 'tunnel_failed',
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
return {
|
|
140
|
-
success: false,
|
|
141
|
-
text: `ā Failed to start ngrok tunnel: ${message}\n\nPlease make sure ngrok is installed and configured properly.`,
|
|
142
|
-
values: {
|
|
143
|
-
success: false,
|
|
144
|
-
error: message,
|
|
145
|
-
},
|
|
146
|
-
data: {
|
|
147
|
-
action: 'START_TUNNEL',
|
|
148
|
-
errorType: 'tunnel_start_failed',
|
|
149
|
-
errorDetails: stack,
|
|
150
|
-
},
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
examples: [
|
|
155
|
-
[
|
|
156
|
-
{
|
|
157
|
-
name: '{{user}}',
|
|
158
|
-
content: {
|
|
159
|
-
text: 'Start an ngrok tunnel on port 8080',
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
name: '{{agent}}',
|
|
164
|
-
content: {
|
|
165
|
-
text: 'ā
Ngrok tunnel started successfully!\n\nš Public URL: https://abc123.ngrok.io\nš Local Port: 8080\n\nYour local service is now accessible from the internet.',
|
|
166
|
-
actions: ['START_TUNNEL'],
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
],
|
|
170
|
-
[
|
|
171
|
-
{
|
|
172
|
-
name: '{{user}}',
|
|
173
|
-
content: {
|
|
174
|
-
text: 'Create a tunnel for my API server and then test the webhook endpoint',
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
name: '{{agent}}',
|
|
179
|
-
content: {
|
|
180
|
-
text: "I'll start an ngrok tunnel for your API server and then test the webhook endpoint.",
|
|
181
|
-
thought: 'User wants to expose their API server and test webhooks - I should create the tunnel first, then use the public URL for webhook testing.',
|
|
182
|
-
actions: ['START_TUNNEL'],
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
name: '{{agent}}',
|
|
187
|
-
content: {
|
|
188
|
-
text: 'ā
Ngrok tunnel started successfully!\n\nš Public URL: https://xyz789.ngrok.io\nš Local Port: 3000\n\nNow testing the webhook endpoint...',
|
|
189
|
-
thought: 'Tunnel is active and I have the public URL. I can now test the webhook endpoint using this external URL.',
|
|
190
|
-
actions: ['TEST_WEBHOOK'],
|
|
191
|
-
},
|
|
192
|
-
},
|
|
193
|
-
],
|
|
194
|
-
[
|
|
195
|
-
{
|
|
196
|
-
name: '{{user}}',
|
|
197
|
-
content: {
|
|
198
|
-
text: 'Start tunnel on port 4000 and share the link in our team chat',
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
name: '{{agent}}',
|
|
203
|
-
content: {
|
|
204
|
-
text: "I'll start the ngrok tunnel on port 4000 and then share the public URL with your team.",
|
|
205
|
-
thought: 'User wants to expose their local service and share the link - I need to start the tunnel first, then send a message with the URL.',
|
|
206
|
-
actions: ['START_TUNNEL'],
|
|
207
|
-
},
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
name: '{{agent}}',
|
|
211
|
-
content: {
|
|
212
|
-
text: 'ā
Ngrok tunnel started successfully on port 4000! Now sharing the link with your team.',
|
|
213
|
-
thought: 'Tunnel is up and running. I can now send a message to the team chat with the public URL.',
|
|
214
|
-
actions: ['SEND_MESSAGE'],
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
],
|
|
218
|
-
],
|
|
219
|
-
};
|
|
220
|
-
export default startTunnelAction;
|
|
221
|
-
//# sourceMappingURL=start-tunnel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"start-tunnel.js","sourceRoot":"","sources":["../../src/actions/start-tunnel.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,WAAW,EAIX,SAAS,GAEV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,mBAAmB,GAAG;;;;;;;;;;;;CAY3B,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAW;IACvC,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE,CAAC,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,WAAW,CAAC;IACrE,WAAW,EACT,0MAA0M;IAC5M,QAAQ,EAAE,KAAK,EAAE,OAAsB,EAAE,QAAgB,EAAE,EAAE;QAC3D,MAAM,aAAa,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAChD,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,OAAO,KAAK,CAAC;QACf,CAAC;QAED,oCAAoC;QACpC,IAAI,aAAa,CAAC,QAAQ,EAAE,EAAE,CAAC;YAC7B,WAAW,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;YAC7C,OAAO,KAAK,CAAC;QACf,C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AE,WAAW;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,wFAAwF;oBAC9F,OAAO,EACL,0FAA0F;oBAC5F,OAAO,EAAE,CAAC,cAAc,CAAC;iBAC1B;aACF;SACF;KACmB;CACvB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stop-tunnel.d.ts","sourceRoot":"","sources":["../../src/actions/stop-tunnel.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EAQZ,MAAM,eAAe,CAAC;AAGvB,eAAO,MAAM,gBAAgB,EAAE,MA4L9B,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import { elizaLogger, } from '@elizaos/core';
|
|
2
|
-
import { getTunnelService } from '@elizaos/plugin-tunnel';
|
|
3
|
-
export const stopTunnelAction = {
|
|
4
|
-
name: 'STOP_TUNNEL',
|
|
5
|
-
similes: ['CLOSE_TUNNEL', 'SHUTDOWN_TUNNEL', 'NGROK_STOP', 'TUNNEL_DOWN'],
|
|
6
|
-
description: 'Stop the running ngrok tunnel and clean up resources. Can be chained with START_TUNNEL actions for tunnel rotation workflows or combined with deployment actions for automated service management.',
|
|
7
|
-
validate: async (runtime, _message) => {
|
|
8
|
-
return !!getTunnelService(runtime);
|
|
9
|
-
},
|
|
10
|
-
handler: async (runtime, _message, _state, _options, callback) => {
|
|
11
|
-
const tunnelService = getTunnelService(runtime);
|
|
12
|
-
if (!tunnelService) {
|
|
13
|
-
elizaLogger.error('Tunnel service is not available');
|
|
14
|
-
if (callback) {
|
|
15
|
-
await callback({
|
|
16
|
-
text: 'Tunnel service is not available. Please ensure the ngrok plugin is properly configured.',
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
success: false,
|
|
21
|
-
text: 'Tunnel service is not available. Please ensure the ngrok plugin is properly configured.',
|
|
22
|
-
values: { success: false, error: 'service_unavailable' },
|
|
23
|
-
data: { action: 'STOP_TUNNEL' },
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
if (!tunnelService.isActive()) {
|
|
27
|
-
elizaLogger.warn('No active tunnel to stop');
|
|
28
|
-
if (callback) {
|
|
29
|
-
await callback({
|
|
30
|
-
text: 'No tunnel is currently running.',
|
|
31
|
-
metadata: {
|
|
32
|
-
action: 'tunnel_not_active',
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
success: true,
|
|
38
|
-
text: 'No tunnel is currently running.',
|
|
39
|
-
values: { success: true, wasActive: false },
|
|
40
|
-
data: { action: 'STOP_TUNNEL', status: 'already_stopped' },
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
elizaLogger.info('Stopping ngrok tunnel...');
|
|
44
|
-
try {
|
|
45
|
-
const status = tunnelService.getStatus();
|
|
46
|
-
const previousUrl = status.url;
|
|
47
|
-
const previousPort = status.port;
|
|
48
|
-
await tunnelService.stopTunnel();
|
|
49
|
-
const responseText = `ā
Ngrok tunnel stopped successfully!\n\nš Was running on port: ${previousPort}\nš Previous URL: ${previousUrl}\n\nThe tunnel has been closed and is no longer accessible.`;
|
|
50
|
-
if (callback) {
|
|
51
|
-
await callback({
|
|
52
|
-
text: responseText,
|
|
53
|
-
metadata: {
|
|
54
|
-
previousUrl,
|
|
55
|
-
previousPort,
|
|
56
|
-
action: 'tunnel_stopped',
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
success: true,
|
|
62
|
-
text: responseText,
|
|
63
|
-
values: {
|
|
64
|
-
success: true,
|
|
65
|
-
wasActive: true,
|
|
66
|
-
previousUrl,
|
|
67
|
-
previousPort,
|
|
68
|
-
},
|
|
69
|
-
data: {
|
|
70
|
-
action: 'STOP_TUNNEL',
|
|
71
|
-
previousTunnelMetadata: {
|
|
72
|
-
url: previousUrl,
|
|
73
|
-
port: previousPort,
|
|
74
|
-
stoppedAt: new Date().toISOString(),
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
81
|
-
const stack = error instanceof Error ? (error.stack ?? null) : null;
|
|
82
|
-
elizaLogger.error(`Failed to stop tunnel: ${message}`);
|
|
83
|
-
if (callback) {
|
|
84
|
-
await callback({
|
|
85
|
-
text: `ā Failed to stop ngrok tunnel: ${message}`,
|
|
86
|
-
metadata: {
|
|
87
|
-
error: message,
|
|
88
|
-
action: 'tunnel_stop_failed',
|
|
89
|
-
},
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
return {
|
|
93
|
-
success: false,
|
|
94
|
-
text: `ā Failed to stop ngrok tunnel: ${message}`,
|
|
95
|
-
values: {
|
|
96
|
-
success: false,
|
|
97
|
-
error: message,
|
|
98
|
-
},
|
|
99
|
-
data: {
|
|
100
|
-
action: 'STOP_TUNNEL',
|
|
101
|
-
errorType: 'tunnel_stop_failed',
|
|
102
|
-
errorDetails: stack,
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
examples: [
|
|
108
|
-
[
|
|
109
|
-
{
|
|
110
|
-
name: '{{user}}',
|
|
111
|
-
content: {
|
|
112
|
-
text: 'Stop the ngrok tunnel',
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
name: '{{agent}}',
|
|
117
|
-
content: {
|
|
118
|
-
text: 'ā
Ngrok tunnel stopped successfully!\n\nš Was running on port: 3000\nš Previous URL: https://abc123.ngrok.io\n\nThe tunnel has been closed and is no longer accessible.',
|
|
119
|
-
actions: ['STOP_TUNNEL'],
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
],
|
|
123
|
-
[
|
|
124
|
-
{
|
|
125
|
-
name: '{{user}}',
|
|
126
|
-
content: {
|
|
127
|
-
text: 'Stop the current tunnel and start a new one on port 8080',
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
name: '{{agent}}',
|
|
132
|
-
content: {
|
|
133
|
-
text: "I'll stop the current tunnel and then start a new one on port 8080.",
|
|
134
|
-
thought: 'User wants to switch tunnels - I need to stop the current one first, then start a new tunnel on the specified port.',
|
|
135
|
-
actions: ['STOP_TUNNEL'],
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
name: '{{agent}}',
|
|
140
|
-
content: {
|
|
141
|
-
text: 'ā
Tunnel stopped successfully! Now starting new tunnel on port 8080...',
|
|
142
|
-
thought: 'Current tunnel is closed. Now I can start the new tunnel on port 8080 as requested.',
|
|
143
|
-
actions: ['START_TUNNEL'],
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
],
|
|
147
|
-
[
|
|
148
|
-
{
|
|
149
|
-
name: '{{user}}',
|
|
150
|
-
content: {
|
|
151
|
-
text: 'Close the tunnel and deploy to production',
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
name: '{{agent}}',
|
|
156
|
-
content: {
|
|
157
|
-
text: "I'll stop the development tunnel and then proceed with the production deployment.",
|
|
158
|
-
thought: 'User is ready to move from development to production - I should close the ngrok tunnel first, then handle the deployment process.',
|
|
159
|
-
actions: ['STOP_TUNNEL'],
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
name: '{{agent}}',
|
|
164
|
-
content: {
|
|
165
|
-
text: 'Development tunnel closed successfully. Now initiating production deployment...',
|
|
166
|
-
thought: 'Tunnel is down, development phase is complete. I can now proceed with the production deployment workflow.',
|
|
167
|
-
actions: ['DEPLOY_PRODUCTION'],
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
],
|
|
171
|
-
],
|
|
172
|
-
};
|
|
173
|
-
export default stopTunnelAction;
|
|
174
|
-
//# sourceMappingURL=stop-tunnel.js.map
|
|
@@ -1 +0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EAAqE;oBAC3E,OAAO,EACL,qHAAqH;oBACvH,OAAO,EAAE,CAAC,aAAa,CAAC;iBACzB;aACF;YACD;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,wEAAwE;oBAC9E,OAAO,EACL,qFAAqF;oBACvF,OAAO,EAAE,CAAC,cAAc,CAAC;iBAC1B;aACF;SACF;QACD;YACE;gBACE,IAAI,EAAE,UAAU;gBAChB,OAAO,EAAE;oBACP,IAAI,EAAE,2CAA2C;iBAClD;aACF;YACD;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,mFAAmF;oBACzF,OAAO,EACL,mIAAmI;oBACrI,OAAO,EAAE,CAAC,aAAa,CAAC;iBACzB;aACF;YACD;gBACE,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP,IAAI,EAAE,iFAAiF;oBACvF,OAAO,EACL,2GAA2G;oBAC7G,OAAO,EAAE,CAAC,mBAAmB,CAAC;iBAC/B;aACF;SACF;KACmB;CACvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
package/dist/environment.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { IAgentRuntime } from '@elizaos/core';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
export declare const ngrokEnvSchema: z.ZodObject<{
|
|
4
|
-
NGROK_AUTH_TOKEN: z.ZodOptional<z.ZodString>;
|
|
5
|
-
NGROK_REGION: z.ZodDefault<z.ZodPipe<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>, z.ZodTransform<string, string | number | undefined>>>;
|
|
6
|
-
NGROK_SUBDOMAIN: z.ZodOptional<z.ZodString>;
|
|
7
|
-
NGROK_DOMAIN: z.ZodOptional<z.ZodString>;
|
|
8
|
-
NGROK_DEFAULT_PORT: z.ZodDefault<z.ZodPipe<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>, z.ZodTransform<number, string | number | undefined>>>;
|
|
9
|
-
}, z.core.$strip>;
|
|
10
|
-
export type NgrokConfig = z.infer<typeof ngrokEnvSchema>;
|
|
11
|
-
export declare function validateNgrokConfig(runtime: IAgentRuntime): Promise<NgrokConfig>;
|
|
12
|
-
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,cAAc;;;;;;iBA6BzB,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAWzD,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,CA4BtF"}
|