tiger-agent 0.2.5 → 0.3.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/.env.example +19 -0
- package/.env.secrets.example +3 -0
- package/README.md +373 -6
- package/package.json +1 -1
- package/scripts/onboard.js +156 -59
- package/src/agent/skills.js +1 -1
- package/src/apiProviders.js +10 -11
- package/src/apiProviders.js.bak +222 -0
- package/src/cli.js +21 -0
- package/src/config.js +19 -0
- package/src/llmClient.js +11 -1
- package/src/swarm/agentRuntime.js +836 -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 +330 -2
- package/src/telegram/supervisor.js +53 -2
package/src/config.js
CHANGED
|
@@ -101,6 +101,17 @@ 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();
|
|
110
|
+
const swarmStepMaxRetries = Math.max(0, Number(process.env.SWARM_STEP_MAX_RETRIES || 2));
|
|
111
|
+
const swarmContinueOnError =
|
|
112
|
+
['1', 'true', 'yes', 'on'].includes(cleanEnvValue(process.env.SWARM_CONTINUE_ON_ERROR || 'true').toLowerCase());
|
|
113
|
+
const swarmEnabled =
|
|
114
|
+
['1', 'true', 'yes', 'on'].includes(cleanEnvValue(process.env.SWARM_ENABLED || 'false').toLowerCase());
|
|
104
115
|
|
|
105
116
|
module.exports = {
|
|
106
117
|
kimiProvider,
|
|
@@ -127,6 +138,14 @@ module.exports = {
|
|
|
127
138
|
sqliteVecExtension,
|
|
128
139
|
memoryIngestEveryTurns,
|
|
129
140
|
memoryIngestMinChars,
|
|
141
|
+
swarmAgentTimeoutMs,
|
|
142
|
+
swarmRouteOnProviderError,
|
|
143
|
+
swarmDefaultFlow,
|
|
144
|
+
swarmFirstAgentPolicy,
|
|
145
|
+
swarmFirstAgent,
|
|
146
|
+
swarmStepMaxRetries,
|
|
147
|
+
swarmContinueOnError,
|
|
148
|
+
swarmEnabled,
|
|
130
149
|
dbPath: path.resolve(process.env.DB_PATH || './db/agent.json'),
|
|
131
150
|
maxMessages: Number(process.env.MAX_MESSAGES || 200),
|
|
132
151
|
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
|
}
|