@iaforged/context-code 1.0.77 → 1.0.79
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/README.md +68 -68
- package/cli.js +8515 -8515
- package/context-bootstrap.js +27 -27
- package/dist/src/bootstrap/state.js +3 -0
- package/dist/src/bridge/bridgeMain.js +40 -40
- package/dist/src/cli/print.js +12 -12
- package/dist/src/commands/agent/agent.js +8 -0
- package/dist/src/commands/commit-push-pr.js +55 -55
- package/dist/src/commands/createMovedToPluginCommand.js +9 -9
- package/dist/src/commands/init-verifiers.js +238 -238
- package/dist/src/commands/init.js +216 -216
- package/dist/src/commands/install.js +2 -2
- package/dist/src/commands/login/login.js +24 -10
- package/dist/src/commands/orchestrate/index.js +1 -1
- package/dist/src/commands/orchestrate/orchestrate.js +110 -24
- package/dist/src/commands/profile/profile.js +15 -1
- package/dist/src/commands/provider/index.js +1 -1
- package/dist/src/commands/provider/provider.js +34 -1
- package/dist/src/commands/review.js +22 -22
- package/dist/src/commands/run/index.js +2 -2
- package/dist/src/commands/run/run.js +63 -61
- package/dist/src/commands/team/index.js +1 -1
- package/dist/src/commands/team/team.js +84 -76
- package/dist/src/commands/team-auto/teamAuto.js +89 -29
- package/dist/src/commands/terminalSetup/terminalSetup.js +24 -24
- package/dist/src/commands/usage/index.js +7 -0
- package/dist/src/commands/usage/usage.js +5 -0
- package/dist/src/commands/workspace/workspace.js +39 -31
- package/dist/src/commands.js +0 -2
- package/dist/src/components/ConsoleOAuthFlow.js +92 -14
- package/dist/src/components/ModelPicker.js +2 -0
- package/dist/src/components/agents/generateAgent.js +92 -92
- package/dist/src/components/grove/Grove.js +10 -10
- package/dist/src/components/permissions/AskUserQuestionPermissionRequest/AskUserQuestionPermissionRequest.js +8 -8
- package/dist/src/constants/geminiOAuth.js +13 -0
- package/dist/src/constants/github-app.js +134 -134
- package/dist/src/constants/prompts.js +123 -123
- package/dist/src/coordinator/coordinatorMode.js +252 -252
- package/dist/src/hooks/useTypeahead.js +7 -7
- package/dist/src/ink/reconciler.js +7 -7
- package/dist/src/main.js +5 -5
- package/dist/src/memdir/findRelevantMemories.js +6 -6
- package/dist/src/services/MagicDocs/prompts.js +56 -56
- package/dist/src/services/PromptSuggestion/promptSuggestion.js +29 -29
- package/dist/src/services/SessionMemory/prompts.js +66 -66
- package/dist/src/services/api/openai.js +584 -21
- package/dist/src/services/limits/adapters/ollama.js +3 -3
- package/dist/src/services/oauth/geminiCli.js +107 -0
- package/dist/src/services/orchestration/execution/AgentTaskExecutor.js +5 -3
- package/dist/src/services/orchestration/execution/OrchestrationExecutionRuntime.js +18 -18
- package/dist/src/services/orchestration/global/reporting.js +2 -2
- package/dist/src/services/toolUseSummary/toolUseSummaryGenerator.js +9 -9
- package/dist/src/skills/bundled/batch.js +78 -78
- package/dist/src/skills/bundled/claudeApi.js +34 -34
- package/dist/src/skills/bundled/claudeInChrome.js +4 -4
- package/dist/src/skills/bundled/debug.js +36 -36
- package/dist/src/skills/bundled/scheduleRemoteAgents.js +151 -151
- package/dist/src/skills/bundled/skillify.js +132 -132
- package/dist/src/skills/bundled/stuck.js +53 -53
- package/dist/src/skills/bundled/updateConfig.js +418 -418
- package/dist/src/tasks/RemoteAgentTask/RemoteAgentTask.js +26 -26
- package/dist/src/tools/AgentTool/AgentTool.js +7 -7
- package/dist/src/tools/AgentTool/built-in/claudeCodeGuideAgent.js +67 -67
- package/dist/src/tools/AgentTool/built-in/exploreAgent.js +32 -32
- package/dist/src/tools/AgentTool/built-in/generalPurposeAgent.js +13 -13
- package/dist/src/tools/AgentTool/built-in/planAgent.js +49 -49
- package/dist/src/tools/AgentTool/built-in/statuslineSetup.js +129 -129
- package/dist/src/tools/AgentTool/built-in/verificationAgent.js +119 -119
- package/dist/src/tools/AgentTool/prompt.js +131 -131
- package/dist/src/tools/AgentTool/runAgent.js +9 -9
- package/dist/src/tools/BashTool/BashTool.js +10 -10
- package/dist/src/tools/BashTool/prompt.js +94 -94
- package/dist/src/tools/ConfigTool/prompt.js +29 -29
- package/dist/src/tools/EnterWorktreeTool/prompt.js +27 -27
- package/dist/src/tools/FileReadTool/prompt.js +12 -12
- package/dist/src/tools/PowerShellTool/prompt.js +82 -82
- package/dist/src/tools/RemoteTriggerTool/prompt.js +9 -9
- package/dist/src/tools/ScheduleCronTool/prompt.js +37 -37
- package/dist/src/tools/TeamCreateTool/prompt.js +110 -110
- package/dist/src/tools/TeamDeleteTool/prompt.js +13 -13
- package/dist/src/utils/advisor.js +15 -15
- package/dist/src/utils/api.js +2 -2
- package/dist/src/utils/auth.js +207 -2
- package/dist/src/utils/autoUpdater.js +18 -18
- package/dist/src/utils/bash/ShellSnapshot.js +86 -86
- package/dist/src/utils/bash/commands.js +61 -61
- package/dist/src/utils/claudeInChrome/prompt.js +53 -53
- package/dist/src/utils/claudeInChrome/setup.js +8 -8
- package/dist/src/utils/databaseMcp/server/queries.js +632 -632
- package/dist/src/utils/deepLink/registerProtocol.js +35 -35
- package/dist/src/utils/deepLink/terminalLauncher.js +12 -12
- package/dist/src/utils/hooks/execAgentHook.js +7 -7
- package/dist/src/utils/hooks/execPromptHook.js +4 -4
- package/dist/src/utils/hooks/skillImprovement.js +36 -36
- package/dist/src/utils/logoV2Utils.js +1 -1
- package/dist/src/utils/mcp/dateTimeParser.js +9 -9
- package/dist/src/utils/messages.js +191 -191
- package/dist/src/utils/model/model.js +18 -0
- package/dist/src/utils/model/modelOptions.js +51 -1
- package/dist/src/utils/model/modelStrings.js +5 -1
- package/dist/src/utils/model/modelSupportOverrides.js +3 -0
- package/dist/src/utils/model/providerBaseUrls.js +6 -1
- package/dist/src/utils/model/providerCatalog.js +64 -28
- package/dist/src/utils/model/providerModels.js +88 -17
- package/dist/src/utils/model/providerProfiles.js +8 -0
- package/dist/src/utils/model/providerProfilesDb.js +578 -393
- package/dist/src/utils/model/providerSwitch.js +12 -0
- package/dist/src/utils/model/providerWorkspaces.js +2 -0
- package/dist/src/utils/model/providers.js +65 -2
- package/dist/src/utils/orchestration/store/providerWorkspaceStore.js +3 -1
- package/dist/src/utils/orchestration/store/runStore.js +47 -47
- package/dist/src/utils/orchestration/store/teamStore.js +61 -61
- package/dist/src/utils/powershell/parser.js +253 -253
- package/dist/src/utils/sessionTitle.js +12 -12
- package/dist/src/utils/sideQuestion.js +17 -17
- package/dist/src/utils/status.js +1 -1
- package/dist/src/utils/swarm/backends/registry.js +9 -9
- package/dist/src/utils/telemetry/instrumentation.js +9 -9
- package/dist/src/utils/teleport.js +15 -15
- package/dist/src/utils/undercover.js +28 -28
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ import { getProviderWorkspace, listProviderWorkspaces, setProviderWorkspaceEnabl
|
|
|
6
6
|
import { createAgent, getAgent, listAgents, setAgentOrchestratorByName, setAgentRoleByName, } from '../agent/agentStore.js';
|
|
7
7
|
import { getActiveProviderProfile, getLastUsedProviderProfile, listProviderProfiles, } from '../../utils/model/providerProfiles.js';
|
|
8
8
|
import { getVisibleProvider, VISIBLE_PROVIDERS, } from '../../utils/model/providerCatalog.js';
|
|
9
|
-
import { createTeam,
|
|
9
|
+
import { createTeam, createTeamUnit, getProviderWorkspaceByProvider, getTeamByName, listTeams, listTeamUnits, updateTeam, updateTeamUnit, } from '../../utils/orchestration/store/index.js';
|
|
10
10
|
const ORCHESTRATOR_PROFILE_PREFIX = 'profile:';
|
|
11
11
|
const ORCHESTRATOR_CREATE_PROFILE_PREFIX = 'create-profile:';
|
|
12
12
|
function normalizeProviderInput(rawProvider) {
|
|
@@ -23,6 +23,14 @@ function normalizeProviderInput(rawProvider) {
|
|
|
23
23
|
case 'ollama_cloud':
|
|
24
24
|
case 'ollamacloud':
|
|
25
25
|
return 'ollama-cloud';
|
|
26
|
+
case 'gemini':
|
|
27
|
+
case 'gemini-api-key':
|
|
28
|
+
case 'google-ai':
|
|
29
|
+
return 'gemini-api';
|
|
30
|
+
case 'gemini-google':
|
|
31
|
+
case 'google':
|
|
32
|
+
case 'google-oauth':
|
|
33
|
+
return 'gemini-google';
|
|
26
34
|
default:
|
|
27
35
|
return rawProvider.trim().toLowerCase();
|
|
28
36
|
}
|
|
@@ -147,18 +155,18 @@ function buildSetupGuideMessage() {
|
|
|
147
155
|
'Si ya sabes que perfiles quieres usar, tambien puedes ejecutar el modo rapido.',
|
|
148
156
|
'',
|
|
149
157
|
'Formato rapido:',
|
|
150
|
-
'/workspace setup <team> [orchestrator=<
|
|
158
|
+
'/workspace setup <team> [orchestrator=<equipo|provider/agent>] <provider/profile:equipo> [...]',
|
|
151
159
|
'',
|
|
152
160
|
'Ejemplo:',
|
|
153
161
|
'/workspace setup core-dev orchestrator=backend claude/main:frontend openai/work:backend minimax/main:docs',
|
|
154
162
|
'',
|
|
155
163
|
'El modo rapido hara esto:',
|
|
156
164
|
'1. Habilita cada proveedor como workspace.',
|
|
157
|
-
'2. Crea un agente por
|
|
165
|
+
'2. Crea un agente por equipo interno con nombre <equipo>-lead.',
|
|
158
166
|
'3. Vincula cada agente al perfil indicado.',
|
|
159
167
|
'4. Crea el team si no existe.',
|
|
160
168
|
'5. Usa orchestrator=... como coordinador principal, o el primer agente si no lo indicas.',
|
|
161
|
-
'6. Crea o actualiza los
|
|
169
|
+
'6. Crea o actualiza los equipos internos del team.',
|
|
162
170
|
'',
|
|
163
171
|
'Despues puedes ejecutar:',
|
|
164
172
|
'/team show <team>',
|
|
@@ -175,7 +183,7 @@ function parseSetupOrchestrator(rawToken) {
|
|
|
175
183
|
}
|
|
176
184
|
const slashIndex = value.indexOf('/');
|
|
177
185
|
if (slashIndex <= 0 || slashIndex >= value.length - 1) {
|
|
178
|
-
return { type: '
|
|
186
|
+
return { type: 'team', unitName: value.toLowerCase() };
|
|
179
187
|
}
|
|
180
188
|
const provider = normalizeProviderInput(value.slice(0, slashIndex));
|
|
181
189
|
const agentName = value.slice(slashIndex + 1).trim();
|
|
@@ -189,9 +197,9 @@ function parseSetupOrchestrator(rawToken) {
|
|
|
189
197
|
};
|
|
190
198
|
}
|
|
191
199
|
function parseSetupEntry(rawEntry) {
|
|
192
|
-
const [providerProfile,
|
|
193
|
-
const
|
|
194
|
-
if (!providerProfile || !
|
|
200
|
+
const [providerProfile, rawUnit] = rawEntry.split(':');
|
|
201
|
+
const unitName = rawUnit?.trim().toLowerCase();
|
|
202
|
+
if (!providerProfile || !unitName) {
|
|
195
203
|
return null;
|
|
196
204
|
}
|
|
197
205
|
const slashIndex = providerProfile.indexOf('/');
|
|
@@ -208,8 +216,8 @@ function parseSetupEntry(rawEntry) {
|
|
|
208
216
|
return {
|
|
209
217
|
provider: provider,
|
|
210
218
|
profileName,
|
|
211
|
-
|
|
212
|
-
agentName: `${
|
|
219
|
+
unitName,
|
|
220
|
+
agentName: `${unitName}-lead`,
|
|
213
221
|
};
|
|
214
222
|
}
|
|
215
223
|
function parseSetupArgs(args) {
|
|
@@ -250,16 +258,16 @@ function parseSetupArgs(args) {
|
|
|
250
258
|
}
|
|
251
259
|
return { teamName, entries, invalidEntries, orchestrator };
|
|
252
260
|
}
|
|
253
|
-
async function
|
|
254
|
-
const
|
|
255
|
-
return
|
|
261
|
+
async function findUnitByName(teamId, unitName) {
|
|
262
|
+
const units = await listTeamUnits(teamId);
|
|
263
|
+
return units.find(unit => unit.unitName.toLowerCase() === unitName.toLowerCase()) ?? null;
|
|
256
264
|
}
|
|
257
265
|
function formatSetupOrchestrator(orchestrator) {
|
|
258
266
|
if (!orchestrator) {
|
|
259
267
|
return 'primer agente indicado';
|
|
260
268
|
}
|
|
261
|
-
if (orchestrator.type === '
|
|
262
|
-
return `
|
|
269
|
+
if (orchestrator.type === 'team') {
|
|
270
|
+
return `equipo ${orchestrator.unitName}`;
|
|
263
271
|
}
|
|
264
272
|
return `${orchestrator.provider}/${orchestrator.agentName}`;
|
|
265
273
|
}
|
|
@@ -267,9 +275,9 @@ function resolveSetupCoordinatorEntry(setup) {
|
|
|
267
275
|
if (!setup.orchestrator) {
|
|
268
276
|
return setup.entries[0] ?? null;
|
|
269
277
|
}
|
|
270
|
-
if (setup.orchestrator.type === '
|
|
271
|
-
return (setup.entries.find(entry => entry.
|
|
272
|
-
setup.orchestrator?.
|
|
278
|
+
if (setup.orchestrator.type === 'team') {
|
|
279
|
+
return (setup.entries.find(entry => entry.unitName.toLowerCase() ===
|
|
280
|
+
setup.orchestrator?.unitName.toLowerCase()) ??
|
|
273
281
|
setup.entries[0] ??
|
|
274
282
|
null);
|
|
275
283
|
}
|
|
@@ -277,7 +285,7 @@ function resolveSetupCoordinatorEntry(setup) {
|
|
|
277
285
|
entry.agentName === setup.orchestrator?.agentName) ?? {
|
|
278
286
|
provider: setup.orchestrator.provider,
|
|
279
287
|
profileName: '',
|
|
280
|
-
|
|
288
|
+
unitName: '',
|
|
281
289
|
agentName: setup.orchestrator.agentName,
|
|
282
290
|
});
|
|
283
291
|
}
|
|
@@ -301,7 +309,7 @@ async function runWorkspaceSetup(setup) {
|
|
|
301
309
|
'',
|
|
302
310
|
'Resumen de lo que se va a configurar:',
|
|
303
311
|
`- Orquestador principal: ${formatSetupOrchestrator(setup.orchestrator)}`,
|
|
304
|
-
...setup.entries.map(entry => `- ${entry.
|
|
312
|
+
...setup.entries.map(entry => `- ${entry.unitName}: ${entry.provider}/${entry.profileName} -> agente ${entry.provider}/${entry.agentName}`),
|
|
305
313
|
'',
|
|
306
314
|
'Aplicando cambios:',
|
|
307
315
|
];
|
|
@@ -328,7 +336,7 @@ async function runWorkspaceSetup(setup) {
|
|
|
328
336
|
else {
|
|
329
337
|
lines.push(`- Agente existente: ${entry.provider}/${entry.agentName}`);
|
|
330
338
|
}
|
|
331
|
-
await setAgentRoleByName(entry.provider, entry.agentName, entry.
|
|
339
|
+
await setAgentRoleByName(entry.provider, entry.agentName, entry.unitName);
|
|
332
340
|
}
|
|
333
341
|
const coordinatorEntry = resolveSetupCoordinatorEntry(setup);
|
|
334
342
|
if (coordinatorEntry) {
|
|
@@ -348,31 +356,31 @@ async function runWorkspaceSetup(setup) {
|
|
|
348
356
|
const agent = await getAgent(entry.provider, entry.agentName);
|
|
349
357
|
const workspace = await getProviderWorkspaceByProvider(entry.provider);
|
|
350
358
|
if (!agent || !workspace) {
|
|
351
|
-
lines.push(`- Saltado ${entry.
|
|
359
|
+
lines.push(`- Saltado ${entry.unitName}: falta agente o workspace.`);
|
|
352
360
|
continue;
|
|
353
361
|
}
|
|
354
|
-
const
|
|
355
|
-
if (
|
|
356
|
-
await
|
|
362
|
+
const existingUnit = await findUnitByName(team.id, entry.unitName);
|
|
363
|
+
if (existingUnit) {
|
|
364
|
+
await updateTeamUnit(existingUnit.id, {
|
|
357
365
|
workspaceId: workspace.id,
|
|
358
366
|
localOrchestratorAgentId: agent.id,
|
|
359
367
|
leadAgentId: agent.id,
|
|
360
368
|
selectionMode: 'manual',
|
|
361
369
|
required: true,
|
|
362
370
|
});
|
|
363
|
-
lines.push(`-
|
|
371
|
+
lines.push(`- Equipo actualizado: ${entry.unitName} -> ${entry.provider}/${entry.agentName}`);
|
|
364
372
|
continue;
|
|
365
373
|
}
|
|
366
|
-
await
|
|
374
|
+
await createTeamUnit({
|
|
367
375
|
teamId: team.id,
|
|
368
|
-
|
|
376
|
+
unitName: entry.unitName,
|
|
369
377
|
workspaceId: workspace.id,
|
|
370
378
|
localOrchestratorAgentId: agent.id,
|
|
371
379
|
leadAgentId: agent.id,
|
|
372
380
|
selectionMode: 'manual',
|
|
373
381
|
required: true,
|
|
374
382
|
});
|
|
375
|
-
lines.push(`-
|
|
383
|
+
lines.push(`- Equipo creado: ${entry.unitName} -> ${entry.provider}/${entry.agentName}`);
|
|
376
384
|
}
|
|
377
385
|
lines.push('', 'Listo. Siguientes comandos recomendados:', `/team show ${setup.teamName}`, `/orchestrate ${setup.teamName} <describe tu objetivo>`, '/run list', '/run resume <run-id>');
|
|
378
386
|
return lines.join('\n');
|
|
@@ -578,7 +586,7 @@ function WorkspaceSetupWizard({ onDone, }) {
|
|
|
578
586
|
onDone([
|
|
579
587
|
`Equipo seleccionado: ${cleanTeamName}.`,
|
|
580
588
|
`Orquestador seleccionado: ${selectedOrchestrator}.`,
|
|
581
|
-
'Ahora completa los
|
|
589
|
+
'Ahora completa los equipos internos con provider/profile:equipo.',
|
|
582
590
|
'Ejemplo: claude/main:frontend openai/work:backend minimax/main:docs',
|
|
583
591
|
].join('\n'), {
|
|
584
592
|
nextInput: `/workspace setup ${cleanTeamName} orchestrator=${selectedOrchestrator} `,
|
|
@@ -689,7 +697,7 @@ export async function call(onDone, _context, args) {
|
|
|
689
697
|
}
|
|
690
698
|
const action = parseProviderAction(trimmedArgs);
|
|
691
699
|
if (!action) {
|
|
692
|
-
onDone('Uso: /workspace, /workspace list, /workspace show <proveedor>, /workspace enable <proveedor>, /workspace disable <proveedor>, /workspace setup <team> <provider/profile:
|
|
700
|
+
onDone('Uso: /workspace, /workspace list, /workspace show <proveedor>, /workspace enable <proveedor>, /workspace disable <proveedor>, /workspace setup <team> <provider/profile:equipo>..., /workspace orchestrator');
|
|
693
701
|
return null;
|
|
694
702
|
}
|
|
695
703
|
if (action.action === 'show') {
|
package/dist/src/commands.js
CHANGED
|
@@ -155,7 +155,6 @@ import run from './commands/run/index.js';
|
|
|
155
155
|
import workspace from './commands/workspace/index.js';
|
|
156
156
|
import orchestrate from './commands/orchestrate/index.js';
|
|
157
157
|
import provider from './commands/provider/index.js';
|
|
158
|
-
import loginOpenAI from './commands/login-openai/index.js';
|
|
159
158
|
import tag from './commands/tag/index.js';
|
|
160
159
|
import team from './commands/team/index.js';
|
|
161
160
|
import teamAuto from './commands/team-auto/index.js';
|
|
@@ -247,7 +246,6 @@ const COMMANDS = memoize(() => [
|
|
|
247
246
|
workspace,
|
|
248
247
|
orchestrate,
|
|
249
248
|
provider,
|
|
250
|
-
loginOpenAI,
|
|
251
249
|
outputStyle,
|
|
252
250
|
remoteEnv,
|
|
253
251
|
plugin,
|
|
@@ -12,7 +12,8 @@ import { getSSLErrorHint } from '../services/api/errorUtils.js';
|
|
|
12
12
|
import { sendNotification } from '../services/notifier.js';
|
|
13
13
|
import { OAuthService } from '../services/oauth/index.js';
|
|
14
14
|
import { getOAuthRequestDetails } from '../services/oauth/client.js';
|
|
15
|
-
import { getOauthAccountInfo, saveProviderApiKey, validateForceLoginOrg } from '../utils/auth.js';
|
|
15
|
+
import { checkGeminiGoogleCredentialsValid, getOauthAccountInfo, saveGeminiGoogleOAuthTokens, saveProviderApiKey, validateForceLoginOrg } from '../utils/auth.js';
|
|
16
|
+
import { startGeminiCliOAuthFlow } from '../services/oauth/geminiCli.js';
|
|
16
17
|
import { resolveProviderProfile } from '../utils/model/providerProfiles.js';
|
|
17
18
|
import { logError } from '../utils/log.js';
|
|
18
19
|
import { getVisibleProvider } from '../utils/model/providerCatalog.js';
|
|
@@ -22,6 +23,22 @@ import { Select } from './CustomSelect/select.js';
|
|
|
22
23
|
import { KeyboardShortcutHint } from './design-system/KeyboardShortcutHint.js';
|
|
23
24
|
import { Spinner } from './Spinner.js';
|
|
24
25
|
import TextInput from './TextInput.js';
|
|
26
|
+
const LOGIN_PROVIDER_ORDER = [
|
|
27
|
+
'minimax',
|
|
28
|
+
'openrouter',
|
|
29
|
+
'zai',
|
|
30
|
+
'ollama',
|
|
31
|
+
'openai',
|
|
32
|
+
'claudeai',
|
|
33
|
+
'gemini-google',
|
|
34
|
+
'gemini-api',
|
|
35
|
+
'console',
|
|
36
|
+
];
|
|
37
|
+
function sortLoginProviderOptions(options) {
|
|
38
|
+
const order = new Map(LOGIN_PROVIDER_ORDER.map((value, index) => [value, index]));
|
|
39
|
+
return [...options].sort((a, b) => (order.get(a.value) ?? Number.MAX_SAFE_INTEGER) -
|
|
40
|
+
(order.get(b.value) ?? Number.MAX_SAFE_INTEGER));
|
|
41
|
+
}
|
|
25
42
|
const PASTE_HERE_MSG = 'Pega aqui el codigo si se solicita > ';
|
|
26
43
|
function formatOAuthDebugDetails(provider, port) {
|
|
27
44
|
if (provider !== 'openai') {
|
|
@@ -108,6 +125,12 @@ export function ConsoleOAuthFlow({ onDone, startingMessage, mode = 'login', forc
|
|
|
108
125
|
context: 'Confirmation',
|
|
109
126
|
isActive: oauthStatus.state === 'platform_setup'
|
|
110
127
|
});
|
|
128
|
+
useKeybinding('confirm:yes', () => {
|
|
129
|
+
void handleGeminiGoogleAuthSubmit();
|
|
130
|
+
}, {
|
|
131
|
+
context: 'Confirmation',
|
|
132
|
+
isActive: oauthStatus.state === 'provider_google_setup'
|
|
133
|
+
});
|
|
111
134
|
// Handle Enter to retry on error state
|
|
112
135
|
useKeybinding('confirm:yes', () => {
|
|
113
136
|
if (oauthStatus.state === 'error' && oauthStatus.toRetry) {
|
|
@@ -186,7 +209,7 @@ export function ConsoleOAuthFlow({ onDone, startingMessage, mode = 'login', forc
|
|
|
186
209
|
setOAuthStatus({
|
|
187
210
|
state: 'success'
|
|
188
211
|
});
|
|
189
|
-
const providerLabel = provider
|
|
212
|
+
const providerLabel = getVisibleProvider(provider).label;
|
|
190
213
|
void sendNotification({
|
|
191
214
|
message: `API key de ${providerLabel} guardada`,
|
|
192
215
|
notificationType: 'auth_success'
|
|
@@ -240,6 +263,44 @@ export function ConsoleOAuthFlow({ onDone, startingMessage, mode = 'login', forc
|
|
|
240
263
|
});
|
|
241
264
|
}
|
|
242
265
|
}, [onDone, terminal]);
|
|
266
|
+
const handleGeminiGoogleAuthSubmit = useCallback(async () => {
|
|
267
|
+
setOAuthStatus({
|
|
268
|
+
state: 'provider_google_auth_running'
|
|
269
|
+
});
|
|
270
|
+
try {
|
|
271
|
+
const alreadyValid = await checkGeminiGoogleCredentialsValid();
|
|
272
|
+
if (alreadyValid) {
|
|
273
|
+
onDone('gemini-google');
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
const tokens = await startGeminiCliOAuthFlow();
|
|
277
|
+
saveGeminiGoogleOAuthTokens(tokens);
|
|
278
|
+
const isValid = await checkGeminiGoogleCredentialsValid();
|
|
279
|
+
if (!isValid) {
|
|
280
|
+
void sendNotification({
|
|
281
|
+
message: 'OAuth de Gemini guardado; Code Assist no valido el proyecto de cuota',
|
|
282
|
+
notificationType: 'auth_success'
|
|
283
|
+
}, terminal);
|
|
284
|
+
onDone('gemini-google');
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
void sendNotification({
|
|
288
|
+
message: 'Credenciales de Gemini Google listas',
|
|
289
|
+
notificationType: 'auth_success'
|
|
290
|
+
}, terminal);
|
|
291
|
+
onDone('gemini-google');
|
|
292
|
+
}
|
|
293
|
+
catch (error) {
|
|
294
|
+
logError(error);
|
|
295
|
+
setOAuthStatus({
|
|
296
|
+
state: 'error',
|
|
297
|
+
message: error.message,
|
|
298
|
+
toRetry: {
|
|
299
|
+
state: 'provider_google_setup'
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
}, [onDone, terminal]);
|
|
243
304
|
const startOAuth = useCallback(async () => {
|
|
244
305
|
try {
|
|
245
306
|
logEvent('tengu_oauth_flow_start', {
|
|
@@ -362,7 +423,7 @@ export function ConsoleOAuthFlow({ onDone, startingMessage, mode = 'login', forc
|
|
|
362
423
|
return _jsxs(Box, { flexDirection: "column", gap: 1, children: [oauthStatus.state === 'waiting_for_login' && showPastePrompt && _jsxs(Box, { flexDirection: "column", gap: 1, paddingBottom: 1, children: [_jsxs(Box, { paddingX: 1, children: [_jsxs(Text, { dimColor: true, children: ["Browser didn't open? Use the url below to sign in", ' '] }), urlCopied ? _jsx(Text, { color: "success", children: "(Copied!)" }) : _jsx(Text, { dimColor: true, children: _jsx(KeyboardShortcutHint, { shortcut: "c", action: "copiar", parens: true }) })] }), _jsx(Link, { url: oauthStatus.url, children: _jsx(Text, { dimColor: true, children: oauthStatus.url }) })] }, "urlToCopy"), mode === 'setup-token' && oauthStatus.state === 'success' && oauthStatus.token && _jsxs(Box, { flexDirection: "column", gap: 1, paddingTop: 1, children: [_jsx(Text, { color: "success", children: "\u2713 Long-lived authentication token created successfully!" }), _jsxs(Box, { flexDirection: "column", gap: 1, children: [_jsx(Text, { children: "Your OAuth token (valid for 1 year):" }), _jsx(Text, { color: "warning", children: oauthStatus.token }), _jsx(Text, { dimColor: true, children: "Store this token securely. You won't be able to see it again." }), _jsx(Text, { dimColor: true, children: "Use this token by setting: export CLAUDE_CODE_OAUTH_TOKEN=<token>" })] })] }, "tokenOutput"), _jsx(Box, { paddingLeft: 1, flexDirection: "column", gap: 1, children: _jsx(OAuthStatusMessage, { oauthStatus: oauthStatus, oauthProvider: oauthProvider, mode: mode, startingMessage: startingMessage, forcedMethodMessage: forcedMethodMessage, showPastePrompt: showPastePrompt, pastedCode: pastedCode, setPastedCode: setPastedCode, cursorOffset: cursorOffset, setCursorOffset: setCursorOffset, textInputColumns: textInputColumns, handleSubmitCode: handleSubmitCode, setOAuthStatus: setOAuthStatus, setLoginWithClaudeAi: setLoginWithClaudeAi, setOAuthProvider: setOAuthProvider, providerApiKey: providerApiKey, setProviderApiKey: setProviderApiKey, providerApiKeyCursorOffset: providerApiKeyCursorOffset, setProviderApiKeyCursorOffset: setProviderApiKeyCursorOffset, handleProviderApiKeySubmit: handleProviderApiKeySubmit, providerBaseUrl: providerBaseUrl, setProviderBaseUrlInput: setProviderBaseUrlInput, providerBaseUrlCursorOffset: providerBaseUrlCursorOffset, setProviderBaseUrlCursorOffset: setProviderBaseUrlCursorOffset, handleProviderBaseUrlSubmit: handleProviderBaseUrlSubmit, onDone: onDone }) })] });
|
|
363
424
|
}
|
|
364
425
|
function OAuthStatusMessage(t0) {
|
|
365
|
-
const $ = _c(
|
|
426
|
+
const $ = _c(68);
|
|
366
427
|
const { oauthStatus, oauthProvider, mode, startingMessage, forcedMethodMessage, showPastePrompt, pastedCode, setPastedCode, cursorOffset, setCursorOffset, textInputColumns, handleSubmitCode, setOAuthStatus, setLoginWithClaudeAi, setOAuthProvider, providerApiKey, setProviderApiKey, providerApiKeyCursorOffset, setProviderApiKeyCursorOffset, handleProviderApiKeySubmit, providerBaseUrl, setProviderBaseUrlInput, providerBaseUrlCursorOffset, setProviderBaseUrlCursorOffset, handleProviderBaseUrlSubmit, onDone } = t0;
|
|
367
428
|
switch (oauthStatus.state) {
|
|
368
429
|
case "idle":
|
|
@@ -410,17 +471,20 @@ function OAuthStatusMessage(t0) {
|
|
|
410
471
|
let t6;
|
|
411
472
|
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
412
473
|
t6 = [t4, t5, {
|
|
413
|
-
label: _jsxs(Text, { children: ["Plataforma de terceros \u00B7", " ", _jsx(Text, { dimColor: true, children: "Amazon Bedrock, Microsoft Foundry o Vertex AI" }), "\n"] }),
|
|
414
|
-
value: "platform"
|
|
415
|
-
}, {
|
|
416
474
|
label: _jsxs(Text, { children: ["Cuenta de OpenAI / Codex \u00B7", " ", _jsx(Text, { dimColor: true, children: "Login OAuth" }), "\n"] }),
|
|
417
475
|
value: "openai"
|
|
418
476
|
}, {
|
|
419
477
|
label: _jsxs(Text, { children: ["OpenRouter \u00B7", " ", _jsx(Text, { dimColor: true, children: "API key / OpenAI-compatible" }), "\n"] }),
|
|
420
478
|
value: "openrouter"
|
|
421
479
|
}, {
|
|
422
|
-
label: _jsxs(Text, { children: ["Ollama
|
|
480
|
+
label: _jsxs(Text, { children: ["Ollama \u00B7", " ", _jsx(Text, { dimColor: true, children: "Servidor local compatible" }), "\n"] }),
|
|
423
481
|
value: "ollama"
|
|
482
|
+
}, {
|
|
483
|
+
label: _jsxs(Text, { children: ["Gemini API - ", _jsx(Text, { dimColor: true, children: "API key / OpenAI-compatible" }), "\n"] }),
|
|
484
|
+
value: "gemini-api"
|
|
485
|
+
}, {
|
|
486
|
+
label: _jsxs(Text, { children: ["Gemini Google - ", _jsx(Text, { dimColor: true, children: "OAuth/ADC de Google" }), "\n"] }),
|
|
487
|
+
value: "gemini-google"
|
|
424
488
|
}, {
|
|
425
489
|
label: _jsxs(Text, { children: ["Z.AI \u00B7", " ", _jsx(Text, { dimColor: true, children: "API key / OpenAI-compatible" }), "\n"] }),
|
|
426
490
|
value: "zai"
|
|
@@ -434,8 +498,8 @@ function OAuthStatusMessage(t0) {
|
|
|
434
498
|
t6 = $[5];
|
|
435
499
|
}
|
|
436
500
|
let t7;
|
|
437
|
-
if ($[6] !== setLoginWithClaudeAi || $[7] !== setOAuthStatus || $[8] !== setOAuthProvider) {
|
|
438
|
-
t7 = _jsx(Box, { children: _jsx(Select, { options: t6, onChange: value_0 => {
|
|
501
|
+
if ($[6] !== setLoginWithClaudeAi || $[7] !== setOAuthStatus || $[8] !== setOAuthProvider || $[65] !== onDone) {
|
|
502
|
+
t7 = _jsx(Box, { children: _jsx(Select, { options: sortLoginProviderOptions(t6), onChange: value_0 => {
|
|
439
503
|
if (value_0 === "platform") {
|
|
440
504
|
logEvent("tengu_oauth_platform_selected", {});
|
|
441
505
|
setOAuthStatus({
|
|
@@ -456,13 +520,18 @@ function OAuthStatusMessage(t0) {
|
|
|
456
520
|
provider: "openrouter"
|
|
457
521
|
});
|
|
458
522
|
}
|
|
459
|
-
else if (value_0 === "zai" || value_0 === "minimax") {
|
|
523
|
+
else if (value_0 === "gemini-api" || value_0 === "zai" || value_0 === "minimax") {
|
|
460
524
|
setOAuthStatus({
|
|
461
525
|
state: "provider_api_key_input",
|
|
462
526
|
provider: value_0
|
|
463
527
|
});
|
|
464
528
|
}
|
|
465
|
-
else if (value_0 === "
|
|
529
|
+
else if (value_0 === "gemini-google") {
|
|
530
|
+
setOAuthStatus({
|
|
531
|
+
state: "provider_google_setup"
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
else if (value_0 === "ollama" || value_0 === "ollama-cloud") {
|
|
466
535
|
setProviderBaseUrlInput(getConfiguredProviderBaseUrl(value_0));
|
|
467
536
|
setProviderBaseUrlCursorOffset(0);
|
|
468
537
|
setOAuthStatus({
|
|
@@ -488,10 +557,11 @@ function OAuthStatusMessage(t0) {
|
|
|
488
557
|
$[6] = setLoginWithClaudeAi;
|
|
489
558
|
$[7] = setOAuthStatus;
|
|
490
559
|
$[8] = setOAuthProvider;
|
|
491
|
-
$[
|
|
560
|
+
$[65] = onDone;
|
|
561
|
+
$[66] = t7;
|
|
492
562
|
}
|
|
493
563
|
else {
|
|
494
|
-
t7 = $[
|
|
564
|
+
t7 = $[66];
|
|
495
565
|
}
|
|
496
566
|
let t8;
|
|
497
567
|
if ($[10] !== t2 || $[11] !== t7) {
|
|
@@ -509,7 +579,7 @@ function OAuthStatusMessage(t0) {
|
|
|
509
579
|
{
|
|
510
580
|
let t1;
|
|
511
581
|
if ($[50] !== oauthStatus.provider) {
|
|
512
|
-
t1 = _jsxs(Text, { bold: true, children: ["Ingresa la API key de ", oauthStatus.provider
|
|
582
|
+
t1 = _jsxs(Text, { bold: true, children: ["Ingresa la API key de ", getVisibleProvider(oauthStatus.provider).label] });
|
|
513
583
|
$[50] = oauthStatus.provider;
|
|
514
584
|
$[51] = t1;
|
|
515
585
|
}
|
|
@@ -558,6 +628,14 @@ function OAuthStatusMessage(t0) {
|
|
|
558
628
|
const providerInfo = getVisibleProvider(oauthStatus.provider);
|
|
559
629
|
return _jsxs(Box, { flexDirection: "column", gap: 1, children: [_jsx(Text, { bold: true, children: providerInfo.label }), _jsx(Text, { dimColor: true, children: providerInfo.setup.intro }), _jsx(Text, { dimColor: true, children: providerInfo.setup.nextStep }), _jsx(Text, { children: "URL del servidor > " }), _jsx(Box, { children: _jsx(TextInput, { value: providerBaseUrl, onChange: setProviderBaseUrlInput, onSubmit: value => handleProviderBaseUrlSubmit(value, oauthStatus.provider), cursorOffset: providerBaseUrlCursorOffset, onChangeCursorOffset: setProviderBaseUrlCursorOffset, columns: textInputColumns }) }), _jsxs(Text, { color: "success", children: ["Presiona ", _jsx(Text, { bold: true, children: "Enter" }), " para guardar la URL y continuar."] })] });
|
|
560
630
|
}
|
|
631
|
+
case "provider_google_setup":
|
|
632
|
+
{
|
|
633
|
+
return _jsxs(Box, { flexDirection: "column", gap: 1, children: [_jsx(Text, { bold: true, children: "Gemini Google OAuth" }), _jsx(Text, { dimColor: true, children: "Context Code usara el flujo OAuth compatible con Gemini CLI y abrira Google en el navegador." }), _jsx(Text, { dimColor: true, children: "Se guardara el access token y refresh token en el perfil activo de Gemini Google." }), _jsxs(Text, { color: "success", children: ["Presiona ", _jsx(Text, { bold: true, children: "Enter" }), " para iniciar sesion con tu cuenta de Google."] })] });
|
|
634
|
+
}
|
|
635
|
+
case "provider_google_auth_running":
|
|
636
|
+
{
|
|
637
|
+
return _jsxs(Box, { children: [_jsx(Spinner, {}), _jsx(Text, { children: "Abriendo Google OAuth para Gemini..." })] });
|
|
638
|
+
}
|
|
561
639
|
case "platform_setup":
|
|
562
640
|
{
|
|
563
641
|
let t1;
|
|
@@ -60,6 +60,8 @@ export function ModelPicker(t0) {
|
|
|
60
60
|
provider === 'openrouter' ||
|
|
61
61
|
provider === 'ollama' ||
|
|
62
62
|
provider === 'ollama-cloud' ||
|
|
63
|
+
provider === 'gemini-api' ||
|
|
64
|
+
provider === 'gemini-google' ||
|
|
63
65
|
provider === 'zai' ||
|
|
64
66
|
provider === 'minimax') {
|
|
65
67
|
const { getCachedProviderModels, fetchProviderModels } = await import('../utils/model/providerModels.js');
|
|
@@ -8,105 +8,105 @@ import { isAutoMemoryEnabled } from '../../memdir/paths.js';
|
|
|
8
8
|
import { logEvent, } from '../../services/analytics/index.js';
|
|
9
9
|
import { jsonParse } from '../../utils/slowOperations.js';
|
|
10
10
|
import { asSystemPrompt } from '../../utils/systemPromptType.js';
|
|
11
|
-
const AGENT_CREATION_SYSTEM_PROMPT = `You are an elite AI agent architect specializing in crafting high-performance agent configurations. Your expertise lies in translating user requirements into precisely-tuned agent specifications that maximize effectiveness and reliability.
|
|
12
|
-
|
|
13
|
-
**Important Context**: You may have access to project-specific instructions from CLAUDE.md files and other context that may include coding standards, project structure, and custom requirements. Consider this context when creating agents to ensure they align with the project's established patterns and practices.
|
|
14
|
-
|
|
15
|
-
When a user describes what they want an agent to do, you will:
|
|
16
|
-
|
|
17
|
-
1. **Extract Core Intent**: Identify the fundamental purpose, key responsibilities, and success criteria for the agent. Look for both explicit requirements and implicit needs. Consider any project-specific context from CLAUDE.md files. For agents that are meant to review code, you should assume that the user is asking to review recently written code and not the whole codebase, unless the user has explicitly instructed you otherwise.
|
|
18
|
-
|
|
19
|
-
2. **Design Expert Persona**: Create a compelling expert identity that embodies deep domain knowledge relevant to the task. The persona should inspire confidence and guide the agent's decision-making approach.
|
|
20
|
-
|
|
21
|
-
3. **Architect Comprehensive Instructions**: Develop a system prompt that:
|
|
22
|
-
- Establishes clear behavioral boundaries and operational parameters
|
|
23
|
-
- Provides specific methodologies and best practices for task execution
|
|
24
|
-
- Anticipates edge cases and provides guidance for handling them
|
|
25
|
-
- Incorporates any specific requirements or preferences mentioned by the user
|
|
26
|
-
- Defines output format expectations when relevant
|
|
27
|
-
- Aligns with project-specific coding standards and patterns from CLAUDE.md
|
|
28
|
-
|
|
29
|
-
4. **Optimize for Performance**: Include:
|
|
30
|
-
- Decision-making frameworks appropriate to the domain
|
|
31
|
-
- Quality control mechanisms and self-verification steps
|
|
32
|
-
- Efficient workflow patterns
|
|
33
|
-
- Clear escalation or fallback strategies
|
|
34
|
-
|
|
35
|
-
5. **Create Identifier**: Design a concise, descriptive identifier that:
|
|
36
|
-
- Uses lowercase letters, numbers, and hyphens only
|
|
37
|
-
- Is typically 2-4 words joined by hyphens
|
|
38
|
-
- Clearly indicates the agent's primary function
|
|
39
|
-
- Is memorable and easy to type
|
|
40
|
-
- Avoids generic terms like "helper" or "assistant"
|
|
41
|
-
|
|
42
|
-
6 **Example agent descriptions**:
|
|
43
|
-
- in the 'whenToUse' field of the JSON object, you should include examples of when this agent should be used.
|
|
44
|
-
- examples should be of the form:
|
|
45
|
-
- <example>
|
|
46
|
-
Context: The user is creating a test-runner agent that should be called after a logical chunk of code is written.
|
|
47
|
-
user: "Please write a function that checks if a number is prime"
|
|
48
|
-
assistant: "Here is the relevant function: "
|
|
49
|
-
<function call omitted for brevity only for this example>
|
|
50
|
-
<commentary>
|
|
51
|
-
Since a significant piece of code was written, use the ${AGENT_TOOL_NAME} tool to launch the test-runner agent to run the tests.
|
|
52
|
-
</commentary>
|
|
53
|
-
assistant: "Now let me use the test-runner agent to run the tests"
|
|
54
|
-
</example>
|
|
55
|
-
- <example>
|
|
56
|
-
Context: User is creating an agent to respond to the word "hello" with a friendly jok.
|
|
57
|
-
user: "Hello"
|
|
58
|
-
assistant: "I'm going to use the ${AGENT_TOOL_NAME} tool to launch the greeting-responder agent to respond with a friendly joke"
|
|
59
|
-
<commentary>
|
|
60
|
-
Since the user is greeting, use the greeting-responder agent to respond with a friendly joke.
|
|
61
|
-
</commentary>
|
|
62
|
-
</example>
|
|
63
|
-
- If the user mentioned or implied that the agent should be used proactively, you should include examples of this.
|
|
64
|
-
- NOTE: Ensure that in the examples, you are making the assistant use the Agent tool and not simply respond directly to the task.
|
|
65
|
-
|
|
66
|
-
Your output must be a valid JSON object with exactly these fields:
|
|
67
|
-
{
|
|
68
|
-
"identifier": "A unique, descriptive identifier using lowercase letters, numbers, and hyphens (e.g., 'test-runner', 'api-docs-writer', 'code-formatter')",
|
|
69
|
-
"whenToUse": "A precise, actionable description starting with 'Use this agent when...' that clearly defines the triggering conditions and use cases. Ensure you include examples as described above.",
|
|
70
|
-
"systemPrompt": "The complete system prompt that will govern the agent's behavior, written in second person ('You are...', 'You will...') and structured for maximum clarity and effectiveness"
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
Key principles for your system prompts:
|
|
74
|
-
- Be specific rather than generic - avoid vague instructions
|
|
75
|
-
- Include concrete examples when they would clarify behavior
|
|
76
|
-
- Balance comprehensiveness with clarity - every instruction should add value
|
|
77
|
-
- Ensure the agent has enough context to handle variations of the core task
|
|
78
|
-
- Make the agent proactive in seeking clarification when needed
|
|
79
|
-
- Build in quality assurance and self-correction mechanisms
|
|
80
|
-
|
|
81
|
-
Remember: The agents you create should be autonomous experts capable of handling their designated tasks with minimal additional guidance. Your system prompts are their complete operational manual.
|
|
11
|
+
const AGENT_CREATION_SYSTEM_PROMPT = `You are an elite AI agent architect specializing in crafting high-performance agent configurations. Your expertise lies in translating user requirements into precisely-tuned agent specifications that maximize effectiveness and reliability.
|
|
12
|
+
|
|
13
|
+
**Important Context**: You may have access to project-specific instructions from CLAUDE.md files and other context that may include coding standards, project structure, and custom requirements. Consider this context when creating agents to ensure they align with the project's established patterns and practices.
|
|
14
|
+
|
|
15
|
+
When a user describes what they want an agent to do, you will:
|
|
16
|
+
|
|
17
|
+
1. **Extract Core Intent**: Identify the fundamental purpose, key responsibilities, and success criteria for the agent. Look for both explicit requirements and implicit needs. Consider any project-specific context from CLAUDE.md files. For agents that are meant to review code, you should assume that the user is asking to review recently written code and not the whole codebase, unless the user has explicitly instructed you otherwise.
|
|
18
|
+
|
|
19
|
+
2. **Design Expert Persona**: Create a compelling expert identity that embodies deep domain knowledge relevant to the task. The persona should inspire confidence and guide the agent's decision-making approach.
|
|
20
|
+
|
|
21
|
+
3. **Architect Comprehensive Instructions**: Develop a system prompt that:
|
|
22
|
+
- Establishes clear behavioral boundaries and operational parameters
|
|
23
|
+
- Provides specific methodologies and best practices for task execution
|
|
24
|
+
- Anticipates edge cases and provides guidance for handling them
|
|
25
|
+
- Incorporates any specific requirements or preferences mentioned by the user
|
|
26
|
+
- Defines output format expectations when relevant
|
|
27
|
+
- Aligns with project-specific coding standards and patterns from CLAUDE.md
|
|
28
|
+
|
|
29
|
+
4. **Optimize for Performance**: Include:
|
|
30
|
+
- Decision-making frameworks appropriate to the domain
|
|
31
|
+
- Quality control mechanisms and self-verification steps
|
|
32
|
+
- Efficient workflow patterns
|
|
33
|
+
- Clear escalation or fallback strategies
|
|
34
|
+
|
|
35
|
+
5. **Create Identifier**: Design a concise, descriptive identifier that:
|
|
36
|
+
- Uses lowercase letters, numbers, and hyphens only
|
|
37
|
+
- Is typically 2-4 words joined by hyphens
|
|
38
|
+
- Clearly indicates the agent's primary function
|
|
39
|
+
- Is memorable and easy to type
|
|
40
|
+
- Avoids generic terms like "helper" or "assistant"
|
|
41
|
+
|
|
42
|
+
6 **Example agent descriptions**:
|
|
43
|
+
- in the 'whenToUse' field of the JSON object, you should include examples of when this agent should be used.
|
|
44
|
+
- examples should be of the form:
|
|
45
|
+
- <example>
|
|
46
|
+
Context: The user is creating a test-runner agent that should be called after a logical chunk of code is written.
|
|
47
|
+
user: "Please write a function that checks if a number is prime"
|
|
48
|
+
assistant: "Here is the relevant function: "
|
|
49
|
+
<function call omitted for brevity only for this example>
|
|
50
|
+
<commentary>
|
|
51
|
+
Since a significant piece of code was written, use the ${AGENT_TOOL_NAME} tool to launch the test-runner agent to run the tests.
|
|
52
|
+
</commentary>
|
|
53
|
+
assistant: "Now let me use the test-runner agent to run the tests"
|
|
54
|
+
</example>
|
|
55
|
+
- <example>
|
|
56
|
+
Context: User is creating an agent to respond to the word "hello" with a friendly jok.
|
|
57
|
+
user: "Hello"
|
|
58
|
+
assistant: "I'm going to use the ${AGENT_TOOL_NAME} tool to launch the greeting-responder agent to respond with a friendly joke"
|
|
59
|
+
<commentary>
|
|
60
|
+
Since the user is greeting, use the greeting-responder agent to respond with a friendly joke.
|
|
61
|
+
</commentary>
|
|
62
|
+
</example>
|
|
63
|
+
- If the user mentioned or implied that the agent should be used proactively, you should include examples of this.
|
|
64
|
+
- NOTE: Ensure that in the examples, you are making the assistant use the Agent tool and not simply respond directly to the task.
|
|
65
|
+
|
|
66
|
+
Your output must be a valid JSON object with exactly these fields:
|
|
67
|
+
{
|
|
68
|
+
"identifier": "A unique, descriptive identifier using lowercase letters, numbers, and hyphens (e.g., 'test-runner', 'api-docs-writer', 'code-formatter')",
|
|
69
|
+
"whenToUse": "A precise, actionable description starting with 'Use this agent when...' that clearly defines the triggering conditions and use cases. Ensure you include examples as described above.",
|
|
70
|
+
"systemPrompt": "The complete system prompt that will govern the agent's behavior, written in second person ('You are...', 'You will...') and structured for maximum clarity and effectiveness"
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
Key principles for your system prompts:
|
|
74
|
+
- Be specific rather than generic - avoid vague instructions
|
|
75
|
+
- Include concrete examples when they would clarify behavior
|
|
76
|
+
- Balance comprehensiveness with clarity - every instruction should add value
|
|
77
|
+
- Ensure the agent has enough context to handle variations of the core task
|
|
78
|
+
- Make the agent proactive in seeking clarification when needed
|
|
79
|
+
- Build in quality assurance and self-correction mechanisms
|
|
80
|
+
|
|
81
|
+
Remember: The agents you create should be autonomous experts capable of handling their designated tasks with minimal additional guidance. Your system prompts are their complete operational manual.
|
|
82
82
|
`;
|
|
83
83
|
// Agent memory instructions to include in the system prompt when memory is mentioned or relevant
|
|
84
|
-
const AGENT_MEMORY_INSTRUCTIONS = `
|
|
85
|
-
|
|
86
|
-
7. **Agent Memory Instructions**: If the user mentions "memory", "remember", "learn", "persist", or similar concepts, OR if the agent would benefit from building up knowledge across conversations (e.g., code reviewers learning patterns, architects learning codebase structure, etc.), include domain-specific memory update instructions in the systemPrompt.
|
|
87
|
-
|
|
88
|
-
Add a section like this to the systemPrompt, tailored to the agent's specific domain:
|
|
89
|
-
|
|
90
|
-
"**Update your agent memory** as you discover [domain-specific items]. This builds up institutional knowledge across conversations. Write concise notes about what you found and where.
|
|
91
|
-
|
|
92
|
-
Examples of what to record:
|
|
93
|
-
- [domain-specific item 1]
|
|
94
|
-
- [domain-specific item 2]
|
|
95
|
-
- [domain-specific item 3]"
|
|
96
|
-
|
|
97
|
-
Examples of domain-specific memory instructions:
|
|
98
|
-
- For a code-reviewer: "Update your agent memory as you discover code patterns, style conventions, common issues, and architectural decisions in this codebase."
|
|
99
|
-
- For a test-runner: "Update your agent memory as you discover test patterns, common failure modes, flaky tests, and testing best practices."
|
|
100
|
-
- For an architect: "Update your agent memory as you discover codepaths, library locations, key architectural decisions, and component relationships."
|
|
101
|
-
- For a documentation writer: "Update your agent memory as you discover documentation patterns, API structures, and terminology conventions."
|
|
102
|
-
|
|
103
|
-
The memory instructions should be specific to what the agent would naturally learn while performing its core tasks.
|
|
84
|
+
const AGENT_MEMORY_INSTRUCTIONS = `
|
|
85
|
+
|
|
86
|
+
7. **Agent Memory Instructions**: If the user mentions "memory", "remember", "learn", "persist", or similar concepts, OR if the agent would benefit from building up knowledge across conversations (e.g., code reviewers learning patterns, architects learning codebase structure, etc.), include domain-specific memory update instructions in the systemPrompt.
|
|
87
|
+
|
|
88
|
+
Add a section like this to the systemPrompt, tailored to the agent's specific domain:
|
|
89
|
+
|
|
90
|
+
"**Update your agent memory** as you discover [domain-specific items]. This builds up institutional knowledge across conversations. Write concise notes about what you found and where.
|
|
91
|
+
|
|
92
|
+
Examples of what to record:
|
|
93
|
+
- [domain-specific item 1]
|
|
94
|
+
- [domain-specific item 2]
|
|
95
|
+
- [domain-specific item 3]"
|
|
96
|
+
|
|
97
|
+
Examples of domain-specific memory instructions:
|
|
98
|
+
- For a code-reviewer: "Update your agent memory as you discover code patterns, style conventions, common issues, and architectural decisions in this codebase."
|
|
99
|
+
- For a test-runner: "Update your agent memory as you discover test patterns, common failure modes, flaky tests, and testing best practices."
|
|
100
|
+
- For an architect: "Update your agent memory as you discover codepaths, library locations, key architectural decisions, and component relationships."
|
|
101
|
+
- For a documentation writer: "Update your agent memory as you discover documentation patterns, API structures, and terminology conventions."
|
|
102
|
+
|
|
103
|
+
The memory instructions should be specific to what the agent would naturally learn while performing its core tasks.
|
|
104
104
|
`;
|
|
105
105
|
export async function generateAgent(userPrompt, model, existingIdentifiers, abortSignal) {
|
|
106
106
|
const existingList = existingIdentifiers.length > 0
|
|
107
107
|
? `\n\nIMPORTANT: The following identifiers already exist and must NOT be used: ${existingIdentifiers.join(', ')}`
|
|
108
108
|
: '';
|
|
109
|
-
const prompt = `Create an agent configuration based on this request: "${userPrompt}".${existingList}
|
|
109
|
+
const prompt = `Create an agent configuration based on this request: "${userPrompt}".${existingList}
|
|
110
110
|
Return ONLY the JSON object, no other text.`;
|
|
111
111
|
const userMessage = createUserMessage({ content: prompt });
|
|
112
112
|
// Fetch user and system contexts
|