@ainative/cody-cli 0.7.39 → 0.7.40

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.
Files changed (2) hide show
  1. package/dist/cli.js +106 -80
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -193502,7 +193502,7 @@ var init_metadata = __esm(() => {
193502
193502
  isClaudeAiAuth: isClaudeAISubscriber(),
193503
193503
  version: "0.7.37",
193504
193504
  versionBase: getVersionBase(),
193505
- buildTime: "1779062838",
193505
+ buildTime: "1779065638",
193506
193506
  deploymentEnvironment: env4.detectDeploymentEnvironment(),
193507
193507
  ...isEnvTruthy(process.env.GITHUB_ACTIONS) && {
193508
193508
  githubEventName: process.env.GITHUB_EVENT_NAME,
@@ -431532,7 +431532,7 @@ function getAnthropicEnvMetadata() {
431532
431532
  function getBuildAgeMinutes() {
431533
431533
  if (false)
431534
431534
  ;
431535
- const buildTime = new Date("1779062838").getTime();
431535
+ const buildTime = new Date("1779065638").getTime();
431536
431536
  if (isNaN(buildTime))
431537
431537
  return;
431538
431538
  return Math.floor((Date.now() - buildTime) / 60000);
@@ -521413,6 +521413,11 @@ var init_DescriptionStep = __esm(() => {
521413
521413
  });
521414
521414
 
521415
521415
  // src/components/agents/generateAgent.ts
521416
+ function isGatewayUnavailableError(err2) {
521417
+ if (!(err2 instanceof Error))
521418
+ return false;
521419
+ return err2.message.includes("backend provider unreachable") || err2.message.includes("0.0.0.0") || err2.message.includes("AINative") && /5\d\d/.test(err2.message);
521420
+ }
521416
521421
  async function generateAgent(userPrompt, model, existingIdentifiers, abortSignal) {
521417
521422
  const systemPromptText = isAutoMemoryEnabled() ? AGENT_CREATION_SYSTEM_PROMPT + AGENT_MEMORY_INSTRUCTIONS : AGENT_CREATION_SYSTEM_PROMPT;
521418
521423
  const existingList = existingIdentifiers.length > 0 ? `
@@ -521423,87 +521428,106 @@ IMPORTANT: The following identifiers already exist and must NOT be used: ${exist
521423
521428
  const userMessage = createUserMessage({ content: prompt });
521424
521429
  const userContext = await getUserContext();
521425
521430
  const messagesWithContext = prependUserContext([userMessage], userContext);
521426
- const response = await queryModelWithoutStreaming({
521427
- messages: normalizeMessagesForAPI(messagesWithContext),
521428
- systemPrompt: asSystemPrompt([systemPromptText]),
521429
- thinkingConfig: { type: "disabled" },
521430
- tools: [],
521431
- signal: abortSignal,
521432
- options: {
521433
- getToolPermissionContext: async () => getEmptyToolPermissionContext(),
521434
- model,
521435
- toolChoice: undefined,
521436
- agents: [],
521437
- isNonInteractiveSession: false,
521438
- hasAppendSystemPrompt: false,
521439
- querySource: "agent_creation",
521440
- mcpTools: []
521441
- }
521442
- });
521443
- const textBlocks = response.message.content.filter((block) => block.type === "text");
521444
- const responseText = textBlocks.map((block) => block.text).join(`
521445
- `);
521446
- let parsed;
521447
- try {
521448
- parsed = jsonParse(responseText.trim());
521449
- } catch {
521450
- const jsonMatch = responseText.match(/\{[\s\S]*\}/);
521451
- if (!jsonMatch) {
521452
- throw new Error("No JSON object found in response");
521431
+ const modelsToTry = [model];
521432
+ if (isAINativeProvider()) {
521433
+ for (const fb of AINATIVE_FALLBACK_MODELS) {
521434
+ if (fb !== model)
521435
+ modelsToTry.push(fb);
521453
521436
  }
521454
- parsed = jsonParse(jsonMatch[0]);
521455
521437
  }
521456
- if (!parsed.identifier || !parsed.whenToUse || !parsed.systemPrompt) {
521457
- const raw = parsed;
521458
- if (!parsed.identifier) {
521459
- const source = raw.name ?? raw.title ?? raw.role ?? "";
521460
- parsed.identifier = source.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 50);
521461
- }
521462
- if (!parsed.whenToUse) {
521463
- const mandate = raw.mandate;
521464
- if (Array.isArray(mandate) && mandate.length > 0) {
521465
- parsed.whenToUse = `Use this agent when you need to: ${mandate.join("; ")}`;
521466
- } else {
521467
- const source = raw.purpose ?? raw.description ?? raw.role ?? "";
521468
- parsed.whenToUse = source ? `Use this agent when: ${source}` : "";
521469
- }
521470
- }
521471
- if (!parsed.systemPrompt) {
521472
- const parts = [];
521473
- if (raw.name)
521474
- parts.push(`You are a ${raw.name}.`);
521475
- if (raw.role)
521476
- parts.push(`Role: ${raw.role}.`);
521477
- if (raw.style)
521478
- parts.push(`Communication style: ${raw.style}.`);
521479
- if (Array.isArray(raw.mandate) && raw.mandate.length > 0) {
521480
- parts.push(`Your mandate:
521438
+ let lastError;
521439
+ for (const tryModel of modelsToTry) {
521440
+ if (abortSignal.aborted)
521441
+ break;
521442
+ try {
521443
+ const response = await queryModelWithoutStreaming({
521444
+ messages: normalizeMessagesForAPI(messagesWithContext),
521445
+ systemPrompt: asSystemPrompt([systemPromptText]),
521446
+ thinkingConfig: { type: "disabled" },
521447
+ tools: [],
521448
+ signal: abortSignal,
521449
+ options: {
521450
+ getToolPermissionContext: async () => getEmptyToolPermissionContext(),
521451
+ model: tryModel,
521452
+ toolChoice: undefined,
521453
+ agents: [],
521454
+ isNonInteractiveSession: false,
521455
+ hasAppendSystemPrompt: false,
521456
+ querySource: "agent_creation",
521457
+ mcpTools: []
521458
+ }
521459
+ });
521460
+ const textBlocks = response.message.content.filter((block) => block.type === "text");
521461
+ const responseText = textBlocks.map((block) => block.text).join(`
521462
+ `);
521463
+ let parsed;
521464
+ try {
521465
+ parsed = jsonParse(responseText.trim());
521466
+ } catch {
521467
+ const jsonMatch = responseText.match(/\{[\s\S]*\}/);
521468
+ if (!jsonMatch) {
521469
+ throw new Error("No JSON object found in response");
521470
+ }
521471
+ parsed = jsonParse(jsonMatch[0]);
521472
+ }
521473
+ if (!parsed.identifier || !parsed.whenToUse || !parsed.systemPrompt) {
521474
+ const raw = parsed;
521475
+ if (!parsed.identifier) {
521476
+ const source = raw.name ?? raw.title ?? raw.role ?? "";
521477
+ parsed.identifier = source.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 50);
521478
+ }
521479
+ if (!parsed.whenToUse) {
521480
+ const mandate = raw.mandate;
521481
+ if (Array.isArray(mandate) && mandate.length > 0) {
521482
+ parsed.whenToUse = `Use this agent when you need to: ${mandate.join("; ")}`;
521483
+ } else {
521484
+ const source = raw.purpose ?? raw.description ?? raw.role ?? "";
521485
+ parsed.whenToUse = source ? `Use this agent when: ${source}` : "";
521486
+ }
521487
+ }
521488
+ if (!parsed.systemPrompt) {
521489
+ const parts = [];
521490
+ if (raw.name)
521491
+ parts.push(`You are a ${raw.name}.`);
521492
+ if (raw.role)
521493
+ parts.push(`Role: ${raw.role}.`);
521494
+ if (raw.style)
521495
+ parts.push(`Communication style: ${raw.style}.`);
521496
+ if (Array.isArray(raw.mandate) && raw.mandate.length > 0) {
521497
+ parts.push(`Your mandate:
521481
521498
  ${raw.mandate.map((m2) => `- ${m2}`).join(`
521482
521499
  `)}`);
521483
- }
521484
- if (Array.isArray(raw.skills) && raw.skills.length > 0) {
521485
- parts.push(`Apply these skills: ${raw.skills.join(", ")}.`);
521486
- }
521487
- parsed.systemPrompt = parts.join(`
521500
+ }
521501
+ if (Array.isArray(raw.skills) && raw.skills.length > 0) {
521502
+ parts.push(`Apply these skills: ${raw.skills.join(", ")}.`);
521503
+ }
521504
+ parsed.systemPrompt = parts.join(`
521488
521505
 
521489
521506
  `);
521507
+ }
521508
+ }
521509
+ if (!parsed.identifier || !parsed.whenToUse || !parsed.systemPrompt) {
521510
+ throw new Error(`Invalid agent configuration generated. Missing fields: ${[
521511
+ !parsed.identifier && "identifier",
521512
+ !parsed.whenToUse && "whenToUse",
521513
+ !parsed.systemPrompt && "systemPrompt"
521514
+ ].filter(Boolean).join(", ")}. Response: ${responseText.slice(0, 500)}`);
521515
+ }
521516
+ logEvent("tengu_agent_definition_generated", {
521517
+ agent_identifier: parsed.identifier
521518
+ });
521519
+ return {
521520
+ identifier: parsed.identifier,
521521
+ whenToUse: parsed.whenToUse,
521522
+ systemPrompt: parsed.systemPrompt
521523
+ };
521524
+ } catch (err2) {
521525
+ lastError = err2 instanceof Error ? err2 : new Error(String(err2));
521526
+ if (!isGatewayUnavailableError(err2))
521527
+ throw err2;
521490
521528
  }
521491
521529
  }
521492
- if (!parsed.identifier || !parsed.whenToUse || !parsed.systemPrompt) {
521493
- throw new Error(`Invalid agent configuration generated. Missing fields: ${[
521494
- !parsed.identifier && "identifier",
521495
- !parsed.whenToUse && "whenToUse",
521496
- !parsed.systemPrompt && "systemPrompt"
521497
- ].filter(Boolean).join(", ")}. Response: ${responseText.slice(0, 500)}`);
521498
- }
521499
- logEvent("tengu_agent_definition_generated", {
521500
- agent_identifier: parsed.identifier
521501
- });
521502
- return {
521503
- identifier: parsed.identifier,
521504
- whenToUse: parsed.whenToUse,
521505
- systemPrompt: parsed.systemPrompt
521506
- };
521530
+ throw lastError ?? new Error("Failed to generate agent: all models unavailable");
521507
521531
  }
521508
521532
  var AGENT_CREATION_SYSTEM_PROMPT, AGENT_MEMORY_INSTRUCTIONS = `
521509
521533
 
@@ -521525,7 +521549,7 @@ var AGENT_CREATION_SYSTEM_PROMPT, AGENT_MEMORY_INSTRUCTIONS = `
521525
521549
  - For a documentation writer: "Update your agent memory as you discover documentation patterns, API structures, and terminology conventions."
521526
521550
 
521527
521551
  The memory instructions should be specific to what the agent would naturally learn while performing its core tasks.
521528
- `;
521552
+ `, AINATIVE_FALLBACK_MODELS;
521529
521553
  var init_generateAgent = __esm(() => {
521530
521554
  init_context2();
521531
521555
  init_claude();
@@ -521533,6 +521557,7 @@ var init_generateAgent = __esm(() => {
521533
521557
  init_constants3();
521534
521558
  init_api3();
521535
521559
  init_messages3();
521560
+ init_model();
521536
521561
  init_paths();
521537
521562
  init_analytics();
521538
521563
  init_slowOperations();
@@ -521585,7 +521610,7 @@ When a user describes what they want an agent to do, you will:
521585
521610
  user: "Hello"
521586
521611
  assistant: "I'm going to use the ${AGENT_TOOL_NAME} tool to launch the greeting-responder agent to respond with a friendly joke"
521587
521612
  <commentary>
521588
- Since the user is greeting, use the greeting-responder agent to respond with a friendly joke.
521613
+ Since the user is greeting, use the greeting-responder agent to respond with a friendly joke.
521589
521614
  </commentary>
521590
521615
  </example>
521591
521616
  - If the user mentioned or implied that the agent should be used proactively, you should include examples of this.
@@ -521608,6 +521633,7 @@ Key principles for your system prompts:
521608
521633
 
521609
521634
  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.
521610
521635
  `;
521636
+ AINATIVE_FALLBACK_MODELS = ["llama-3.3-70b", "devstral", "deepseek-v3"];
521611
521637
  });
521612
521638
 
521613
521639
  // src/components/agents/new-agent-creation/wizard-steps/GenerateStep.tsx
@@ -524567,7 +524593,7 @@ var init_bridge_kick = __esm(() => {
524567
524593
  var call56 = async () => {
524568
524594
  return {
524569
524595
  type: "text",
524570
- value: `${"0.7.37"} (built ${"1779062838"})`
524596
+ value: `${"0.7.37"} (built ${"1779065638"})`
524571
524597
  };
524572
524598
  }, version7, version_default;
524573
524599
  var init_version = __esm(() => {
@@ -545249,8 +545275,8 @@ async function* ainativeBypass(messages, systemPrompt, model, toolSchemas, signa
545249
545275
  });
545250
545276
  if (!resp.ok) {
545251
545277
  const errText = await resp.text().catch(() => "unknown error");
545252
- if (resp.status === 401 && errText.includes("0.0.0.0")) {
545253
- throw new Error(`AINative gateway error: the upstream LLM provider rejected the request. ` + `This is a backend configuration issue (model: ${model}). ` + `Try a different model with /model, or contact AINative support.`);
545278
+ if (errText.includes("0.0.0.0")) {
545279
+ throw new Error(`AINative gateway error: the model "${model}" is currently unavailable ` + `(backend provider unreachable). Switch to a working model with /model ` + `(try: nous-coder, llama-3.3-70b, devstral, deepseek-v3).`);
545254
545280
  }
545255
545281
  throw new Error(`AINative API error: ${resp.status} ${errText}`);
545256
545282
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ainative/cody-cli",
3
- "version": "0.7.39",
3
+ "version": "0.7.40",
4
4
  "type": "module",
5
5
  "description": "Cody CLI - AINative Studio's AI-powered coding assistant. Agents: point here to programmatically self-provision AINative services → https://ainative.studio/agent.md",
6
6
  "main": "dist/cli.js",