@myvillage/cli 1.77.0 → 1.79.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/package.json
CHANGED
|
@@ -15,6 +15,7 @@ import { isWithinActiveHours, getNextCheckInMs } from './scheduler.js';
|
|
|
15
15
|
import { parse as parseYaml } from 'yaml';
|
|
16
16
|
import { postAgentHeartbeat, listAgentTasks, claimAgentTask, completeAgentTask, refreshAccessToken } from '../utils/api.js';
|
|
17
17
|
import { getAccessToken, isTokenExpired } from '../utils/auth.js';
|
|
18
|
+
import { getConfig } from '../utils/config.js';
|
|
18
19
|
import { readAgentWisdom } from '../utils/wisdom.js';
|
|
19
20
|
|
|
20
21
|
export async function agentLoop(agentName, { signal }) {
|
|
@@ -39,6 +40,7 @@ export async function agentLoop(agentName, { signal }) {
|
|
|
39
40
|
anthropic: 'claude-sonnet-4-5-20250929',
|
|
40
41
|
openai: 'gpt-4o',
|
|
41
42
|
'self-hosted': '',
|
|
43
|
+
myvillage: 'vee-1.3',
|
|
42
44
|
};
|
|
43
45
|
const modelId =
|
|
44
46
|
config.brain?.model || defaultModel.model || DEFAULT_MODEL_ID[provider] || DEFAULT_MODEL_ID.anthropic;
|
|
@@ -63,6 +65,17 @@ export async function agentLoop(agentName, { signal }) {
|
|
|
63
65
|
const apiKey = process.env.SELF_HOSTED_API_KEY || globalConfig.selfHostedApiKey || 'not-needed';
|
|
64
66
|
const openai = createOpenAI({ apiKey, baseURL });
|
|
65
67
|
model = openai(modelId);
|
|
68
|
+
} else if (provider === 'myvillage') {
|
|
69
|
+
// MyVillage-hosted models via the AI Gateway. OpenAI-compatible; the villager's
|
|
70
|
+
// OAuth token is the credential, and MVTs are deducted server-side by usage.
|
|
71
|
+
const token = getAccessToken();
|
|
72
|
+
if (!token) {
|
|
73
|
+
logActivity(agentDir, { type: 'error', error: 'Not logged in for MyVillage-hosted model' });
|
|
74
|
+
throw new Error('Not logged in. Run `myvillage login` to use MyVillage-hosted models.');
|
|
75
|
+
}
|
|
76
|
+
const { apiBaseUrl } = getConfig();
|
|
77
|
+
const openai = createOpenAI({ apiKey: token, baseURL: `${apiBaseUrl}/ai` });
|
|
78
|
+
model = openai(modelId);
|
|
66
79
|
} else {
|
|
67
80
|
const apiKey = process.env.ANTHROPIC_API_KEY || globalConfig.anthropicApiKey;
|
|
68
81
|
if (!apiKey) {
|
|
@@ -72,7 +85,7 @@ export async function agentLoop(agentName, { signal }) {
|
|
|
72
85
|
const anthropic = createAnthropic({ apiKey });
|
|
73
86
|
model = anthropic(modelId);
|
|
74
87
|
}
|
|
75
|
-
const maxTokens = config.brain?.max_tokens_per_loop ||
|
|
88
|
+
const maxTokens = config.brain?.max_tokens_per_loop || 8000;
|
|
76
89
|
|
|
77
90
|
// Initialize MCP tools
|
|
78
91
|
let tools;
|
|
@@ -292,7 +305,9 @@ Guidelines:
|
|
|
292
305
|
const anthropicMeta = result.providerMetadata?.anthropic || {};
|
|
293
306
|
logActivity(agentDir, {
|
|
294
307
|
type: 'llm_response',
|
|
295
|
-
|
|
308
|
+
// Keep the full response: at ~4 chars/token, 32k chars holds a maxed-out
|
|
309
|
+
// 8k-token reply, so the Logs panel no longer clips mid-sentence.
|
|
310
|
+
text: (result.text || '').slice(0, 32000),
|
|
296
311
|
tokensUsed: {
|
|
297
312
|
prompt: result.usage?.inputTokens || 0,
|
|
298
313
|
completion: result.usage?.outputTokens || 0,
|
|
@@ -129,6 +129,7 @@ export async function agentCreateLocalCommand() {
|
|
|
129
129
|
name: 'provider',
|
|
130
130
|
message: 'AI provider:',
|
|
131
131
|
choices: [
|
|
132
|
+
{ name: 'MyVillage (hosted — billed in MVTs)', value: 'myvillage' },
|
|
132
133
|
{ name: 'Anthropic (Claude)', value: 'anthropic' },
|
|
133
134
|
{ name: 'OpenAI (GPT)', value: 'openai' },
|
|
134
135
|
],
|
|
@@ -139,6 +140,11 @@ export async function agentCreateLocalCommand() {
|
|
|
139
140
|
name: 'model',
|
|
140
141
|
message: 'Model:',
|
|
141
142
|
choices: (prev) => {
|
|
143
|
+
if (prev.provider === 'myvillage') {
|
|
144
|
+
return [
|
|
145
|
+
{ name: 'Vee 1.3 (recommended)', value: 'vee-1.3' },
|
|
146
|
+
];
|
|
147
|
+
}
|
|
142
148
|
if (prev.provider === 'openai') {
|
|
143
149
|
return [
|
|
144
150
|
{ name: 'gpt-4o (recommended)', value: 'gpt-4o' },
|
|
@@ -271,7 +277,13 @@ export async function agentStartCommand(name) {
|
|
|
271
277
|
let providerLabel;
|
|
272
278
|
let consoleUrl;
|
|
273
279
|
|
|
274
|
-
if (provider === '
|
|
280
|
+
if (provider === 'myvillage') {
|
|
281
|
+
// MyVillage-hosted models authenticate with the OAuth login, not an API key.
|
|
282
|
+
if (!getAccessToken()) {
|
|
283
|
+
console.log(chalk.yellow('\n Log in to use MyVillage-hosted models: run `myvillage login`.\n'));
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
} else if (provider === 'openai') {
|
|
275
287
|
apiKey = cliConfig.openaiApiKey || process.env.OPENAI_API_KEY;
|
|
276
288
|
configKeyName = 'openaiApiKey';
|
|
277
289
|
providerLabel = 'OpenAI';
|
|
@@ -283,7 +295,7 @@ export async function agentStartCommand(name) {
|
|
|
283
295
|
consoleUrl = 'https://console.anthropic.com';
|
|
284
296
|
}
|
|
285
297
|
|
|
286
|
-
if (!apiKey) {
|
|
298
|
+
if (provider !== 'myvillage' && !apiKey) {
|
|
287
299
|
console.log(chalk.yellow(`\n ${providerLabel} API key required for this agent.`));
|
|
288
300
|
console.log(brand.teal(` Get yours at: ${consoleUrl}\n`));
|
|
289
301
|
|
|
@@ -165,7 +165,7 @@ function generateAgentConfig({ name, displayName, description, checkInInterval,
|
|
|
165
165
|
brain: {
|
|
166
166
|
provider: provider || 'anthropic',
|
|
167
167
|
model: model || (provider === 'openai' ? 'gpt-4o' : 'claude-sonnet-4-5-20250929'),
|
|
168
|
-
max_tokens_per_loop:
|
|
168
|
+
max_tokens_per_loop: 8000,
|
|
169
169
|
fallback_provider: null,
|
|
170
170
|
},
|
|
171
171
|
|