@teneo-protocol/sdk 1.0.0 → 2.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/.github/workflows/publish-npm.yml +8 -6
- package/CHANGELOG.md +265 -0
- package/README.md +406 -53
- package/dist/core/websocket-client.d.ts +13 -0
- package/dist/core/websocket-client.d.ts.map +1 -1
- package/dist/core/websocket-client.js +34 -3
- package/dist/core/websocket-client.js.map +1 -1
- package/dist/handlers/message-handlers/agent-room-operation-response-handler.d.ts +76 -0
- package/dist/handlers/message-handlers/agent-room-operation-response-handler.d.ts.map +1 -0
- package/dist/handlers/message-handlers/agent-room-operation-response-handler.js +70 -0
- package/dist/handlers/message-handlers/agent-room-operation-response-handler.js.map +1 -0
- package/dist/handlers/message-handlers/agent-selected-handler.d.ts +92 -38
- package/dist/handlers/message-handlers/agent-selected-handler.d.ts.map +1 -1
- package/dist/handlers/message-handlers/agent-status-update-handler.d.ts +904 -0
- package/dist/handlers/message-handlers/agent-status-update-handler.d.ts.map +1 -0
- package/dist/handlers/message-handlers/agent-status-update-handler.js +51 -0
- package/dist/handlers/message-handlers/agent-status-update-handler.js.map +1 -0
- package/dist/handlers/message-handlers/auth-error-handler.d.ts +45 -31
- package/dist/handlers/message-handlers/auth-error-handler.d.ts.map +1 -1
- package/dist/handlers/message-handlers/auth-message-handler.d.ts +6 -0
- package/dist/handlers/message-handlers/auth-message-handler.d.ts.map +1 -1
- package/dist/handlers/message-handlers/auth-message-handler.js +65 -5
- package/dist/handlers/message-handlers/auth-message-handler.js.map +1 -1
- package/dist/handlers/message-handlers/auth-required-handler.d.ts +49 -31
- package/dist/handlers/message-handlers/auth-required-handler.d.ts.map +1 -1
- package/dist/handlers/message-handlers/auth-success-handler.d.ts +6 -0
- package/dist/handlers/message-handlers/auth-success-handler.d.ts.map +1 -1
- package/dist/handlers/message-handlers/auth-success-handler.js +46 -4
- package/dist/handlers/message-handlers/auth-success-handler.js.map +1 -1
- package/dist/handlers/message-handlers/challenge-handler.d.ts +45 -31
- package/dist/handlers/message-handlers/challenge-handler.d.ts.map +1 -1
- package/dist/handlers/message-handlers/error-message-handler.d.ts +49 -31
- package/dist/handlers/message-handlers/error-message-handler.d.ts.map +1 -1
- package/dist/handlers/message-handlers/index.d.ts +5 -0
- package/dist/handlers/message-handlers/index.d.ts.map +1 -1
- package/dist/handlers/message-handlers/index.js +23 -1
- package/dist/handlers/message-handlers/index.js.map +1 -1
- package/dist/handlers/message-handlers/list-available-agents-handler.d.ts +877 -0
- package/dist/handlers/message-handlers/list-available-agents-handler.d.ts.map +1 -0
- package/dist/handlers/message-handlers/list-available-agents-handler.js +38 -0
- package/dist/handlers/message-handlers/list-available-agents-handler.js.map +1 -0
- package/dist/handlers/message-handlers/list-room-agents-handler.d.ts +886 -0
- package/dist/handlers/message-handlers/list-room-agents-handler.d.ts.map +1 -0
- package/dist/handlers/message-handlers/list-room-agents-handler.js +51 -0
- package/dist/handlers/message-handlers/list-room-agents-handler.js.map +1 -0
- package/dist/handlers/message-handlers/list-rooms-response-handler.d.ts +178 -89
- package/dist/handlers/message-handlers/list-rooms-response-handler.d.ts.map +1 -1
- package/dist/handlers/message-handlers/ping-pong-handler.d.ts +62 -58
- package/dist/handlers/message-handlers/ping-pong-handler.d.ts.map +1 -1
- package/dist/handlers/message-handlers/regular-message-handler.d.ts +31 -29
- package/dist/handlers/message-handlers/regular-message-handler.d.ts.map +1 -1
- package/dist/handlers/message-handlers/regular-message-handler.js +1 -0
- package/dist/handlers/message-handlers/regular-message-handler.js.map +1 -1
- package/dist/handlers/message-handlers/room-operation-response-handler.d.ts +328 -0
- package/dist/handlers/message-handlers/room-operation-response-handler.d.ts.map +1 -0
- package/dist/handlers/message-handlers/room-operation-response-handler.js +92 -0
- package/dist/handlers/message-handlers/room-operation-response-handler.js.map +1 -0
- package/dist/handlers/message-handlers/subscribe-response-handler.d.ts +53 -31
- package/dist/handlers/message-handlers/subscribe-response-handler.d.ts.map +1 -1
- package/dist/handlers/message-handlers/types.d.ts +2 -0
- package/dist/handlers/message-handlers/types.d.ts.map +1 -1
- package/dist/handlers/message-handlers/unsubscribe-response-handler.d.ts +53 -31
- package/dist/handlers/message-handlers/unsubscribe-response-handler.d.ts.map +1 -1
- package/dist/managers/agent-room-manager.d.ts +222 -0
- package/dist/managers/agent-room-manager.d.ts.map +1 -0
- package/dist/managers/agent-room-manager.js +508 -0
- package/dist/managers/agent-room-manager.js.map +1 -0
- package/dist/managers/index.d.ts +2 -0
- package/dist/managers/index.d.ts.map +1 -1
- package/dist/managers/index.js +5 -1
- package/dist/managers/index.js.map +1 -1
- package/dist/managers/message-router.d.ts +1 -1
- package/dist/managers/message-router.d.ts.map +1 -1
- package/dist/managers/message-router.js +41 -4
- package/dist/managers/message-router.js.map +1 -1
- package/dist/managers/room-management-manager.d.ts +213 -0
- package/dist/managers/room-management-manager.d.ts.map +1 -0
- package/dist/managers/room-management-manager.js +440 -0
- package/dist/managers/room-management-manager.js.map +1 -0
- package/dist/managers/room-manager.d.ts +4 -4
- package/dist/managers/room-manager.d.ts.map +1 -1
- package/dist/managers/room-manager.js +1 -1
- package/dist/managers/room-manager.js.map +1 -1
- package/dist/teneo-sdk.d.ts +362 -14
- package/dist/teneo-sdk.d.ts.map +1 -1
- package/dist/teneo-sdk.js +497 -7
- package/dist/teneo-sdk.js.map +1 -1
- package/dist/types/config.d.ts +63 -54
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +9 -5
- package/dist/types/config.js.map +1 -1
- package/dist/types/error-codes.d.ts +2 -0
- package/dist/types/error-codes.d.ts.map +1 -1
- package/dist/types/error-codes.js +3 -0
- package/dist/types/error-codes.js.map +1 -1
- package/dist/types/events.d.ts +132 -68
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/events.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +27 -2
- package/dist/types/index.js.map +1 -1
- package/dist/types/messages.d.ts +11396 -2559
- package/dist/types/messages.d.ts.map +1 -1
- package/dist/types/messages.js +294 -27
- package/dist/types/messages.js.map +1 -1
- package/dist/types/validation.d.ts.map +1 -1
- package/dist/types/validation.js +1 -1
- package/dist/types/validation.js.map +1 -1
- package/dist/utils/bounded-queue.d.ts +1 -1
- package/dist/utils/bounded-queue.js +6 -6
- package/dist/utils/circuit-breaker.d.ts.map +1 -1
- package/dist/utils/circuit-breaker.js.map +1 -1
- package/dist/utils/event-waiter.d.ts.map +1 -1
- package/dist/utils/event-waiter.js +2 -1
- package/dist/utils/event-waiter.js.map +1 -1
- package/dist/utils/rate-limiter.d.ts.map +1 -1
- package/dist/utils/rate-limiter.js +4 -6
- package/dist/utils/rate-limiter.js.map +1 -1
- package/dist/utils/secure-private-key.d.ts.map +1 -1
- package/dist/utils/secure-private-key.js +9 -15
- package/dist/utils/secure-private-key.js.map +1 -1
- package/dist/utils/signature-verifier.d.ts +2 -2
- package/dist/utils/signature-verifier.d.ts.map +1 -1
- package/dist/utils/signature-verifier.js +5 -5
- package/dist/utils/signature-verifier.js.map +1 -1
- package/examples/.env.example +1 -1
- package/examples/agent-room-management-example.ts +334 -0
- package/examples/claude-agent-x-follower/.env.example +117 -0
- package/examples/claude-agent-x-follower/QUICKSTART.md +243 -0
- package/examples/claude-agent-x-follower/README.md +540 -0
- package/examples/claude-agent-x-follower/index.ts +248 -0
- package/examples/claude-agent-x-follower/package.json +37 -0
- package/examples/claude-agent-x-follower/tsconfig.json +20 -0
- package/examples/n8n-teneo/.env.example +127 -0
- package/examples/n8n-teneo/Dockerfile +42 -0
- package/examples/n8n-teneo/README.md +564 -0
- package/examples/n8n-teneo/docker-compose.yml +71 -0
- package/examples/n8n-teneo/index.ts +177 -0
- package/examples/n8n-teneo/package.json +22 -0
- package/examples/n8n-teneo/tsconfig.json +12 -0
- package/examples/n8n-teneo/workflows/x-timeline.json +66 -0
- package/examples/openai-teneo/.env.example +130 -0
- package/examples/openai-teneo/README.md +635 -0
- package/examples/openai-teneo/index.ts +280 -0
- package/examples/openai-teneo/package.json +24 -0
- package/examples/openai-teneo/tsconfig.json +16 -0
- package/examples/production-dashboard/.env.example +5 -3
- package/examples/production-dashboard/README.md +839 -0
- package/examples/production-dashboard/pnpm-lock.yaml +92 -0
- package/examples/production-dashboard/public/dashboard.html +1150 -504
- package/examples/production-dashboard/server.ts +428 -12
- package/examples/room-management-example.ts +285 -0
- package/examples/usage/.env.example +17 -0
- package/examples/usage/01-connect.ts +116 -0
- package/examples/usage/02-list-agents.ts +153 -0
- package/examples/usage/03-pick-agent.ts +201 -0
- package/examples/usage/04-find-by-capability.ts +237 -0
- package/examples/usage/05-webhook-example.ts +319 -0
- package/examples/usage/06-simple-api-server.ts +396 -0
- package/examples/usage/07-event-listener.ts +402 -0
- package/examples/usage/README.md +383 -0
- package/examples/usage/package.json +42 -0
- package/package.json +13 -3
- package/src/core/websocket-client.ts +43 -9
- package/src/formatters/response-formatter.test.ts +8 -2
- package/src/handlers/message-handlers/agent-room-operation-response-handler.ts +83 -0
- package/src/handlers/message-handlers/agent-status-update-handler.ts +58 -0
- package/src/handlers/message-handlers/auth-message-handler.ts +73 -5
- package/src/handlers/message-handlers/auth-success-handler.ts +58 -6
- package/src/handlers/message-handlers/index.ts +19 -0
- package/src/handlers/message-handlers/list-available-agents-handler.ts +41 -0
- package/src/handlers/message-handlers/list-room-agents-handler.ts +61 -0
- package/src/handlers/message-handlers/regular-message-handler.ts +1 -0
- package/src/handlers/message-handlers/room-operation-response-handler.ts +105 -0
- package/src/handlers/message-handlers/types.ts +6 -0
- package/src/handlers/webhook-handler.test.ts +13 -10
- package/src/managers/agent-room-manager.ts +609 -0
- package/src/managers/index.ts +2 -0
- package/src/managers/message-router.ts +48 -6
- package/src/managers/room-management-manager.ts +523 -0
- package/src/managers/room-manager.ts +12 -6
- package/src/teneo-sdk.ts +543 -10
- package/src/types/config.ts +13 -6
- package/src/types/error-codes.ts +4 -0
- package/src/types/events.ts +24 -0
- package/src/types/index.ts +55 -0
- package/src/types/messages.ts +374 -41
- package/src/types/validation.ts +4 -1
- package/src/utils/bounded-queue.ts +9 -9
- package/src/utils/circuit-breaker.ts +4 -1
- package/src/utils/deduplication-cache.test.ts +2 -6
- package/src/utils/event-waiter.test.ts +4 -1
- package/src/utils/event-waiter.ts +5 -7
- package/src/utils/rate-limiter.test.ts +5 -17
- package/src/utils/rate-limiter.ts +6 -9
- package/src/utils/secure-private-key.test.ts +66 -59
- package/src/utils/secure-private-key.ts +10 -16
- package/src/utils/signature-verifier.test.ts +75 -70
- package/src/utils/signature-verifier.ts +7 -8
- package/src/utils/ssrf-validator.test.ts +3 -3
- package/tests/integration/room-management.test.ts +514 -0
- package/tests/integration/websocket.test.ts +1 -1
- package/tests/unit/handlers/agent-room-operation-response-handler.test.ts +394 -0
- package/tests/unit/handlers/agent-status-update-handler.test.ts +407 -0
- package/tests/unit/handlers/auth-success-handler-rooms.test.ts +699 -0
- package/tests/unit/handlers/list-available-agents-handler.test.ts +256 -0
- package/tests/unit/handlers/list-room-agents-handler.test.ts +294 -0
- package/tests/unit/handlers/room-operation-response-handler.test.ts +527 -0
- package/tests/unit/managers/agent-room-manager.test.ts +534 -0
- package/tests/unit/managers/room-management-manager.test.ts +438 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal example: Teneo Consumer SDK + n8n Integration
|
|
3
|
+
*
|
|
4
|
+
* Simple REST API for n8n workflows to query Teneo agents.
|
|
5
|
+
*
|
|
6
|
+
* Features:
|
|
7
|
+
* - POST /query - Send messages to Teneo coordinator or specific agents
|
|
8
|
+
* - GET /agents - List all available agents
|
|
9
|
+
* - GET /health - Health check endpoint
|
|
10
|
+
*
|
|
11
|
+
* The /query endpoint supports:
|
|
12
|
+
* - Automatic agent selection via coordinator (default)
|
|
13
|
+
* - Direct agent commands (when agent parameter is provided)
|
|
14
|
+
* - Event-based response handling for reliable message delivery
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import 'dotenv/config';
|
|
18
|
+
import express from 'express';
|
|
19
|
+
import { SDKConfigBuilder, TeneoSDK } from '../../dist/index.js';
|
|
20
|
+
|
|
21
|
+
// Load environment variables
|
|
22
|
+
const WS_URL = process.env.WS_URL || '';
|
|
23
|
+
const PRIVATE_KEY = process.env.PRIVATE_KEY || '';
|
|
24
|
+
const WALLET_ADDRESS = process.env.WALLET_ADDRESS || '';
|
|
25
|
+
const DEFAULT_ROOM = process.env.DEFAULT_ROOM || 'general';
|
|
26
|
+
const LOG_LEVEL = (process.env.LOG_LEVEL || 'info') as 'debug' | 'info' | 'warn' | 'error' | 'silent';
|
|
27
|
+
const ENABLE_SIG_VERIFICATION = process.env.ENABLE_SIGNATURE_VERIFICATION === 'true';
|
|
28
|
+
const TRUSTED_ADDRESSES = process.env.TRUSTED_ADDRESSES?.split(',').filter(Boolean) || [];
|
|
29
|
+
const ENABLE_CACHE = process.env.ENABLE_CACHE !== 'false';
|
|
30
|
+
const CACHE_TIMEOUT = parseInt(process.env.CACHE_TIMEOUT || '300000');
|
|
31
|
+
const MAX_CACHE_SIZE = parseInt(process.env.MAX_CACHE_SIZE || '100');
|
|
32
|
+
const ENABLE_RECONNECTION = process.env.ENABLE_RECONNECTION !== 'false';
|
|
33
|
+
const RECONNECT_DELAY = parseInt(process.env.RECONNECT_DELAY || '5000');
|
|
34
|
+
const MAX_RECONNECT_ATTEMPTS = parseInt(process.env.MAX_RECONNECT_ATTEMPTS || '10');
|
|
35
|
+
|
|
36
|
+
// Validate required environment variables
|
|
37
|
+
if (!WS_URL || !PRIVATE_KEY) {
|
|
38
|
+
console.error('Missing required environment variables: WS_URL, PRIVATE_KEY');
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const app = express();
|
|
43
|
+
app.use(express.json());
|
|
44
|
+
|
|
45
|
+
// Initialize Teneo SDK using SDKConfigBuilder pattern
|
|
46
|
+
const config = new SDKConfigBuilder()
|
|
47
|
+
.withWebSocketUrl(WS_URL)
|
|
48
|
+
.withAuthentication(PRIVATE_KEY, WALLET_ADDRESS) // Wallet auto-derived if not provided
|
|
49
|
+
.withRoom(DEFAULT_ROOM)
|
|
50
|
+
.withReconnection({
|
|
51
|
+
enabled: ENABLE_RECONNECTION,
|
|
52
|
+
delay: RECONNECT_DELAY,
|
|
53
|
+
maxAttempts: MAX_RECONNECT_ATTEMPTS
|
|
54
|
+
})
|
|
55
|
+
.withResponseFormat({ format: 'both', includeMetadata: true })
|
|
56
|
+
.withLogging(LOG_LEVEL)
|
|
57
|
+
.withCache(ENABLE_CACHE, CACHE_TIMEOUT, MAX_CACHE_SIZE)
|
|
58
|
+
.withSignatureVerification({
|
|
59
|
+
enabled: ENABLE_SIG_VERIFICATION,
|
|
60
|
+
trustedAddresses: TRUSTED_ADDRESSES,
|
|
61
|
+
requireFor: ['task_response', 'agent_selected'],
|
|
62
|
+
strictMode: false
|
|
63
|
+
})
|
|
64
|
+
.build();
|
|
65
|
+
|
|
66
|
+
const teneoSDK = new TeneoSDK(config);
|
|
67
|
+
|
|
68
|
+
// Connect to Teneo
|
|
69
|
+
console.log('📡 Connecting to Teneo network...');
|
|
70
|
+
await teneoSDK.connect();
|
|
71
|
+
console.log('✅ Connected to Teneo\n');
|
|
72
|
+
|
|
73
|
+
// Health endpoint
|
|
74
|
+
app.get('/health', (req, res) => {
|
|
75
|
+
const health = teneoSDK.getHealth();
|
|
76
|
+
res.json({
|
|
77
|
+
status: 'ok',
|
|
78
|
+
teneo: {
|
|
79
|
+
connected: health.connection.status === 'connected',
|
|
80
|
+
authenticated: health.connection.authenticated
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Query endpoint - send message to Teneo coordinator or specific agent
|
|
86
|
+
app.post('/query', async (req, res) => {
|
|
87
|
+
try {
|
|
88
|
+
const { message, agent, timeout = 30000 } = req.body;
|
|
89
|
+
|
|
90
|
+
if (!message) {
|
|
91
|
+
return res.status(400).json({
|
|
92
|
+
success: false,
|
|
93
|
+
error: 'Message is required'
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
console.log(`\n🔍 Query: ${message}${agent ? ` (to agent: ${agent})` : ' (via coordinator)'}`);
|
|
98
|
+
|
|
99
|
+
let response: any;
|
|
100
|
+
|
|
101
|
+
// Send message either to specific agent or via coordinator
|
|
102
|
+
// Use the SDK's built-in waitForResponse feature with the improved fallback matching
|
|
103
|
+
if (agent) {
|
|
104
|
+
// Direct command to specific agent
|
|
105
|
+
console.log(`🎯 Sending direct command to agent: ${agent}`);
|
|
106
|
+
response = await teneoSDK.sendDirectCommand({
|
|
107
|
+
agent,
|
|
108
|
+
command: message,
|
|
109
|
+
room: DEFAULT_ROOM
|
|
110
|
+
}, true); // waitForResponse = true
|
|
111
|
+
} else {
|
|
112
|
+
// Send via coordinator (coordinator will select best agent)
|
|
113
|
+
console.log('📡 Sending message via coordinator');
|
|
114
|
+
response = await teneoSDK.sendMessage(message, {
|
|
115
|
+
waitForResponse: true,
|
|
116
|
+
timeout
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (!response || !response.humanized) {
|
|
121
|
+
console.log('⚠️ No response data received');
|
|
122
|
+
return res.json({
|
|
123
|
+
success: false,
|
|
124
|
+
error: 'No response from agent'
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
console.log('📨 Response received from agent');
|
|
129
|
+
console.log(`✅ Response successfully processed\n`);
|
|
130
|
+
|
|
131
|
+
res.json({
|
|
132
|
+
success: true,
|
|
133
|
+
data: {
|
|
134
|
+
humanized: response.humanized,
|
|
135
|
+
raw: response.raw,
|
|
136
|
+
metadata: response.metadata
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
} catch (error) {
|
|
140
|
+
console.error('❌ Query error:', error);
|
|
141
|
+
res.status(500).json({
|
|
142
|
+
success: false,
|
|
143
|
+
error: error instanceof Error ? error.message : 'Unknown error'
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// List agents endpoint
|
|
149
|
+
app.get('/agents', (_req, res) => {
|
|
150
|
+
const agents = teneoSDK.getAgents();
|
|
151
|
+
res.json({
|
|
152
|
+
success: true,
|
|
153
|
+
agents: agents.map(a => ({
|
|
154
|
+
id: a.id,
|
|
155
|
+
name: a.name,
|
|
156
|
+
description: a.description,
|
|
157
|
+
capabilities: a.capabilities
|
|
158
|
+
}))
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
const PORT = process.env.PORT || 3000;
|
|
163
|
+
app.listen(PORT, () => {
|
|
164
|
+
console.log(`🚀 Teneo Service running on http://localhost:${PORT}`);
|
|
165
|
+
console.log(` Health: GET http://localhost:${PORT}/health`);
|
|
166
|
+
console.log(` Query: POST http://localhost:${PORT}/query`);
|
|
167
|
+
console.log(` Body: { "message": "your query", "agent": "optional-agent-id", "timeout": 30000 }`);
|
|
168
|
+
console.log(` Agents: GET http://localhost:${PORT}/agents\n`);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// Graceful shutdown
|
|
172
|
+
process.on('SIGINT', () => {
|
|
173
|
+
console.log('\n👋 Shutting down...');
|
|
174
|
+
teneoSDK.disconnect();
|
|
175
|
+
teneoSDK.destroy();
|
|
176
|
+
process.exit(0);
|
|
177
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "n8n-teneo-example",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Minimal example: Teneo Consumer SDK + n8n Integration",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "tsx watch index.ts",
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"start": "node index.js"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@teneo-protocol/sdk": "file:../../",
|
|
13
|
+
"express": "^4.18.2",
|
|
14
|
+
"dotenv": "^16.3.1"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@types/express": "^4.17.21",
|
|
18
|
+
"@types/node": "^20.10.0",
|
|
19
|
+
"tsx": "^4.7.0",
|
|
20
|
+
"typescript": "^5.3.3"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "X Timeline Query via Teneo",
|
|
3
|
+
"nodes": [
|
|
4
|
+
{
|
|
5
|
+
"parameters": {},
|
|
6
|
+
"name": "When clicking 'Test workflow'",
|
|
7
|
+
"type": "n8n-nodes-base.manualTrigger",
|
|
8
|
+
"typeVersion": 1,
|
|
9
|
+
"position": [250, 300],
|
|
10
|
+
"id": "manual-trigger"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"parameters": {
|
|
14
|
+
"method": "POST",
|
|
15
|
+
"url": "http://teneo-service:3000/query",
|
|
16
|
+
"jsonParameters": true,
|
|
17
|
+
"options": {},
|
|
18
|
+
"bodyParametersJson": "={\n \"message\": \"timeline @elonmusk 10\"\n}"
|
|
19
|
+
},
|
|
20
|
+
"name": "Query Teneo X-Agent",
|
|
21
|
+
"type": "n8n-nodes-base.httpRequest",
|
|
22
|
+
"typeVersion": 4.1,
|
|
23
|
+
"position": [450, 300],
|
|
24
|
+
"id": "http-request"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"parameters": {
|
|
28
|
+
"values": {
|
|
29
|
+
"string": [
|
|
30
|
+
{
|
|
31
|
+
"name": "response",
|
|
32
|
+
"value": "={{ $json.data.humanized }}"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "agent",
|
|
36
|
+
"value": "={{ $json.data.metadata.agentName }}"
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
"options": {}
|
|
41
|
+
},
|
|
42
|
+
"name": "Extract Response",
|
|
43
|
+
"type": "n8n-nodes-base.set",
|
|
44
|
+
"typeVersion": 3,
|
|
45
|
+
"position": [650, 300],
|
|
46
|
+
"id": "set-node"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"connections": {
|
|
50
|
+
"When clicking 'Test workflow'": {
|
|
51
|
+
"main": [[{"node": "Query Teneo X-Agent", "type": "main", "index": 0}]]
|
|
52
|
+
},
|
|
53
|
+
"Query Teneo X-Agent": {
|
|
54
|
+
"main": [[{"node": "Extract Response", "type": "main", "index": 0}]]
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"pinData": {},
|
|
58
|
+
"settings": {
|
|
59
|
+
"executionOrder": "v1"
|
|
60
|
+
},
|
|
61
|
+
"staticData": null,
|
|
62
|
+
"tags": [],
|
|
63
|
+
"triggerCount": 0,
|
|
64
|
+
"updatedAt": "2025-10-15T00:00:00.000Z",
|
|
65
|
+
"versionId": "1"
|
|
66
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# OpenAI + Teneo Service - Environment Configuration
|
|
2
|
+
# Copy this file to .env and fill in your values
|
|
3
|
+
|
|
4
|
+
# ============================================================================
|
|
5
|
+
# REQUIRED: OpenAI Configuration
|
|
6
|
+
# ============================================================================
|
|
7
|
+
|
|
8
|
+
# OpenAI API Key (get from https://platform.openai.com/api-keys)
|
|
9
|
+
OPENAI_API_KEY=sk-...
|
|
10
|
+
|
|
11
|
+
# OpenAI Model (optional, default: gpt-4-turbo-preview)
|
|
12
|
+
# Options: gpt-4-turbo-preview, gpt-4, gpt-3.5-turbo, etc.
|
|
13
|
+
OPENAI_MODEL=gpt-4-turbo-preview
|
|
14
|
+
|
|
15
|
+
# ============================================================================
|
|
16
|
+
# REQUIRED: Teneo Network Connection
|
|
17
|
+
# ============================================================================
|
|
18
|
+
|
|
19
|
+
# WebSocket URL for Teneo AI Network
|
|
20
|
+
# Production: wss://your-production-server.com/ws
|
|
21
|
+
# Development: wss://your-teneo-server.com/ws
|
|
22
|
+
WS_URL=wss://your-teneo-server.com/ws
|
|
23
|
+
|
|
24
|
+
# Ethereum Private Key (with 0x prefix)
|
|
25
|
+
# IMPORTANT: Never commit your actual private key to version control!
|
|
26
|
+
PRIVATE_KEY=0x1234567890123456789012345678901234567890123456789012345678901234
|
|
27
|
+
|
|
28
|
+
# Ethereum Wallet Address (with 0x prefix)
|
|
29
|
+
# If not provided, will be automatically derived from the private key
|
|
30
|
+
WALLET_ADDRESS=
|
|
31
|
+
|
|
32
|
+
# ============================================================================
|
|
33
|
+
# OPTIONAL: Room Configuration
|
|
34
|
+
# ============================================================================
|
|
35
|
+
|
|
36
|
+
# Default room to join on connection
|
|
37
|
+
# general: General purpose room for testing
|
|
38
|
+
# x-agent-enterprise-v2: X-Agent room for Twitter/X features
|
|
39
|
+
DEFAULT_ROOM=general
|
|
40
|
+
|
|
41
|
+
# ============================================================================
|
|
42
|
+
# OPTIONAL: Security Features
|
|
43
|
+
# ============================================================================
|
|
44
|
+
|
|
45
|
+
# Enable message signature verification (true | false)
|
|
46
|
+
# Verifies Ethereum signatures on incoming messages from agents
|
|
47
|
+
# Recommended: true for production
|
|
48
|
+
ENABLE_SIGNATURE_VERIFICATION=false
|
|
49
|
+
|
|
50
|
+
# Comma-separated list of trusted agent Ethereum addresses
|
|
51
|
+
# Only messages signed by these addresses will be accepted (if verification enabled)
|
|
52
|
+
# Leave empty to allow all signed messages
|
|
53
|
+
# Example: 0xAgent1...,0xAgent2...,0xAgent3...
|
|
54
|
+
TRUSTED_ADDRESSES=
|
|
55
|
+
|
|
56
|
+
# ============================================================================
|
|
57
|
+
# OPTIONAL: SDK Performance Tuning
|
|
58
|
+
# ============================================================================
|
|
59
|
+
|
|
60
|
+
# Enable agent caching (true | false)
|
|
61
|
+
ENABLE_CACHE=true
|
|
62
|
+
|
|
63
|
+
# Cache timeout in milliseconds (default: 300000 = 5 minutes)
|
|
64
|
+
CACHE_TIMEOUT=300000
|
|
65
|
+
|
|
66
|
+
# Maximum cache size (default: 100)
|
|
67
|
+
MAX_CACHE_SIZE=100
|
|
68
|
+
|
|
69
|
+
# ============================================================================
|
|
70
|
+
# OPTIONAL: Connection Settings
|
|
71
|
+
# ============================================================================
|
|
72
|
+
|
|
73
|
+
# Enable automatic reconnection (true | false)
|
|
74
|
+
ENABLE_RECONNECTION=true
|
|
75
|
+
|
|
76
|
+
# Reconnection delay in milliseconds (100-60000)
|
|
77
|
+
RECONNECT_DELAY=5000
|
|
78
|
+
|
|
79
|
+
# Maximum reconnection attempts (0-100, 0 = infinite)
|
|
80
|
+
MAX_RECONNECT_ATTEMPTS=10
|
|
81
|
+
|
|
82
|
+
# ============================================================================
|
|
83
|
+
# OPTIONAL: Logging
|
|
84
|
+
# ============================================================================
|
|
85
|
+
|
|
86
|
+
# Log level (debug | info | warn | error | silent)
|
|
87
|
+
# debug: Very verbose, shows all SDK operations
|
|
88
|
+
# info: Normal operations and important events
|
|
89
|
+
# warn: Warnings and potential issues
|
|
90
|
+
# error: Errors only
|
|
91
|
+
# silent: No logging
|
|
92
|
+
LOG_LEVEL=info
|
|
93
|
+
|
|
94
|
+
# ============================================================================
|
|
95
|
+
# OPTIONAL: API Server Configuration
|
|
96
|
+
# ============================================================================
|
|
97
|
+
|
|
98
|
+
# Port for the OpenAI+Teneo Service API (default: 3000)
|
|
99
|
+
PORT=3000
|
|
100
|
+
|
|
101
|
+
# ============================================================================
|
|
102
|
+
# NOTES
|
|
103
|
+
# ============================================================================
|
|
104
|
+
|
|
105
|
+
# 1. Environment Precedence:
|
|
106
|
+
# - Environment variables override .env file values
|
|
107
|
+
# - .env file overrides default SDK values
|
|
108
|
+
#
|
|
109
|
+
# 2. Security Best Practices:
|
|
110
|
+
# - Never commit .env file to git (already in .gitignore)
|
|
111
|
+
# - Use different private keys for dev/prod
|
|
112
|
+
# - Enable signature verification in production
|
|
113
|
+
# - Wallet address is auto-derived if not provided
|
|
114
|
+
# - Keep OpenAI API key secure
|
|
115
|
+
#
|
|
116
|
+
# 3. Development Tips:
|
|
117
|
+
# - Set LOG_LEVEL=debug for troubleshooting
|
|
118
|
+
# - Disable signature verification for local testing
|
|
119
|
+
# - Use 'general' room for basic testing
|
|
120
|
+
# - Test OpenAI separately via /openai endpoint
|
|
121
|
+
#
|
|
122
|
+
# 4. Production Checklist:
|
|
123
|
+
# ✓ Use production WebSocket URL
|
|
124
|
+
# ✓ Use secure private key (from secrets manager)
|
|
125
|
+
# ✓ Use secure OpenAI API key
|
|
126
|
+
# ✓ Enable signature verification
|
|
127
|
+
# ✓ Set trusted agent addresses
|
|
128
|
+
# ✓ Set LOG_LEVEL=info or warn
|
|
129
|
+
# ✓ Enable all security features
|
|
130
|
+
# ✓ Use environment variables (not .env file)
|