tiger-agent 0.2.5 → 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/.env.example +10 -0
- package/README.md +260 -4
- package/package.json +1 -1
- package/src/agent/skills.js +1 -1
- package/src/apiProviders.js +8 -9
- package/src/apiProviders.js.bak +222 -0
- package/src/cli.js +4 -0
- package/src/config.js +11 -0
- package/src/llmClient.js +11 -1
- package/src/swarm/agentRuntime.js +699 -0
- package/src/swarm/agentRuntime.js.bak +456 -0
- package/src/swarm/configStore.js +360 -0
- package/src/swarm/index.js +25 -0
- package/src/swarm/taskBus.js +246 -0
- package/src/telegram/bot.js +329 -1
package/src/config.js
CHANGED
|
@@ -101,6 +101,12 @@ const vectorDbPath = path.resolve(process.env.VECTOR_DB_PATH || './db/memory.sql
|
|
|
101
101
|
const sqliteVecExtension = cleanEnvValue(process.env.SQLITE_VEC_EXTENSION || '');
|
|
102
102
|
const memoryIngestEveryTurns = Math.max(1, Number(process.env.MEMORY_INGEST_EVERY_TURNS || 2));
|
|
103
103
|
const memoryIngestMinChars = Math.max(20, Number(process.env.MEMORY_INGEST_MIN_CHARS || 140));
|
|
104
|
+
const swarmAgentTimeoutMs = Math.max(0, Number(process.env.SWARM_AGENT_TIMEOUT_MS || 0));
|
|
105
|
+
const swarmRouteOnProviderError =
|
|
106
|
+
['1', 'true', 'yes', 'on'].includes(cleanEnvValue(process.env.SWARM_ROUTE_ON_PROVIDER_ERROR || '').toLowerCase());
|
|
107
|
+
const swarmDefaultFlow = cleanEnvValue(process.env.SWARM_DEFAULT_FLOW || 'auto').toLowerCase() || 'auto';
|
|
108
|
+
const swarmFirstAgentPolicy = cleanEnvValue(process.env.SWARM_FIRST_AGENT_POLICY || 'auto').toLowerCase() || 'auto';
|
|
109
|
+
const swarmFirstAgent = cleanEnvValue(process.env.SWARM_FIRST_AGENT || '').toLowerCase();
|
|
104
110
|
|
|
105
111
|
module.exports = {
|
|
106
112
|
kimiProvider,
|
|
@@ -127,6 +133,11 @@ module.exports = {
|
|
|
127
133
|
sqliteVecExtension,
|
|
128
134
|
memoryIngestEveryTurns,
|
|
129
135
|
memoryIngestMinChars,
|
|
136
|
+
swarmAgentTimeoutMs,
|
|
137
|
+
swarmRouteOnProviderError,
|
|
138
|
+
swarmDefaultFlow,
|
|
139
|
+
swarmFirstAgentPolicy,
|
|
140
|
+
swarmFirstAgent,
|
|
130
141
|
dbPath: path.resolve(process.env.DB_PATH || './db/agent.json'),
|
|
131
142
|
maxMessages: Number(process.env.MAX_MESSAGES || 200),
|
|
132
143
|
recentMessages: Number(process.env.RECENT_MESSAGES || 40)
|
package/src/llmClient.js
CHANGED
|
@@ -38,7 +38,7 @@ async function fetchProvider(provider, endpoint, body, maxRetries = 3) {
|
|
|
38
38
|
await sleep(delay);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
const timeout = provider.timeout ||
|
|
41
|
+
const timeout = provider.timeout || Number(process.env.SWARM_AGENT_TIMEOUT_MS || 180000);
|
|
42
42
|
const ctrl = new AbortController();
|
|
43
43
|
const timer = setTimeout(() => ctrl.abort(), timeout);
|
|
44
44
|
|
|
@@ -79,6 +79,7 @@ async function chatCompletion(messages, options = {}) {
|
|
|
79
79
|
// Build candidate list: active provider first, then fallbacks
|
|
80
80
|
const activeId = tokenManager.getCurrentProvider();
|
|
81
81
|
const candidates = [activeId, ...tokenManager.getNextCandidates(activeId)];
|
|
82
|
+
const fallbackOnAnyProviderError = Boolean(options.fallbackOnAnyProviderError);
|
|
82
83
|
|
|
83
84
|
let firstError = null;
|
|
84
85
|
|
|
@@ -110,6 +111,15 @@ async function chatCompletion(messages, options = {}) {
|
|
|
110
111
|
continue;
|
|
111
112
|
}
|
|
112
113
|
|
|
114
|
+
// Optional broader failover (used by swarm): timeout/network/API errors can route to next provider.
|
|
115
|
+
if (fallbackOnAnyProviderError) {
|
|
116
|
+
const switched = tokenManager.autoSwitch('provider_error');
|
|
117
|
+
if (switched.switched) {
|
|
118
|
+
process.stderr.write(`[llm] provider_error on ${providerId} → switched to ${switched.to}\n`);
|
|
119
|
+
}
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
|
|
113
123
|
// Any other error (auth, network, server error) — surface immediately
|
|
114
124
|
throw err;
|
|
115
125
|
}
|