@ainecto/mcp 0.14.0-next.2 → 0.14.0-next.3

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.
@@ -5678,7 +5678,7 @@ function legacyRoleInput(flag, envVars = process.env) {
5678
5678
 
5679
5679
  // src/core/version.ts
5680
5680
  var UNBUNDLED_VERSION = "dev";
5681
- var CLI_VERSION = true ? "0.14.0-next.2" : UNBUNDLED_VERSION;
5681
+ var CLI_VERSION = true ? "0.14.0-next.3" : UNBUNDLED_VERSION;
5682
5682
  var PACKAGE_NAME = "@ainecto/mcp";
5683
5683
  var CLI_USER_AGENT = `${PACKAGE_NAME} ${CLI_VERSION}`;
5684
5684
  function bridgePackageSpec(version = CLI_VERSION) {
@@ -12859,23 +12859,29 @@ function claudeCodeAdapter(deps) {
12859
12859
  if (run.spawnError || run.timedOut) {
12860
12860
  return { ready: false, detail: run.spawnError ?? "timed out" };
12861
12861
  }
12862
- return claudeAuthFromJson(run.stdout, run.code, run.stderrTail);
12862
+ return claudeAuthFromJson(run.stdout, run.code, run.stderrTail, hasApiKeyVariable(deps.env));
12863
12863
  },
12864
12864
  open: ({ conversationUuid, resumeRef, textMaxCharacters }) => new ClaudeCodeSession(conversationUuid, resumeRef, deps.args({ textMaxCharacters, resumeSessionId: resumeRef }), deps)
12865
12865
  };
12866
12866
  }
12867
- function claudeAuthFromJson(stdout, code, stderrTail) {
12867
+ function hasApiKeyVariable(env) {
12868
+ return (env.ANTHROPIC_API_KEY ?? "") !== "";
12869
+ }
12870
+ function claudeAuthFromJson(stdout, code, stderrTail, apiKeyVariable) {
12868
12871
  let parsed;
12869
12872
  try {
12870
12873
  const value = JSON.parse(stdout);
12871
12874
  if (value && typeof value === "object" && !Array.isArray(value)) parsed = value;
12872
12875
  } catch {
12873
12876
  }
12877
+ if (apiKeyVariable) return { ready: true, mode: "apiKey", method: "ANTHROPIC_API_KEY" };
12874
12878
  if (!parsed) {
12875
12879
  return { ready: false, detail: `unreadable auth status (exit ${code ?? "-"})${stderrTail ? `: ${stderrTail}` : ""}` };
12876
12880
  }
12881
+ const ready = parsed.loggedIn === true;
12877
12882
  return {
12878
- ready: parsed.loggedIn === true,
12883
+ ready,
12884
+ ...ready ? { mode: "subscription" } : {},
12879
12885
  method: typeof parsed.authMethod === "string" ? parsed.authMethod : void 0,
12880
12886
  plan: typeof parsed.subscriptionType === "string" ? parsed.subscriptionType : void 0
12881
12887
  };
@@ -12953,6 +12959,8 @@ var ClaudeCodeSession = class {
12953
12959
  }
12954
12960
  if (event.type === "system" && event.subtype === "init" && typeof event.session_id === "string") {
12955
12961
  this.sessionRef = event.session_id;
12962
+ const source = typeof event.apiKeySource === "string" ? event.apiKeySource : "none";
12963
+ this.deps.log.write({ event: "agent_auth_source", pid: this.child.pid, agent: this.agent, apiKeySource: source });
12956
12964
  return;
12957
12965
  }
12958
12966
  const content = event.message?.content;
@@ -13048,9 +13056,9 @@ function codexAuthFromAccount(result) {
13048
13056
  const account = result.account && typeof result.account === "object" ? result.account : void 0;
13049
13057
  const method = typeof account?.type === "string" ? account.type : void 0;
13050
13058
  const plan = typeof account?.planType === "string" ? account.planType : void 0;
13051
- if (account) return { ready: true, method, plan };
13059
+ if (account) return { ready: true, mode: method === "apiKey" ? "apiKey" : "subscription", method, plan };
13052
13060
  if (result.requiresOpenaiAuth === false) return { ready: true, method: "none-required" };
13053
- return { ready: false, detail: "not signed in (run `codex login`)" };
13061
+ return { ready: false, detail: "not signed in with an API key or ChatGPT (run `codex login`, or `codex login --with-api-key`)" };
13054
13062
  }
13055
13063
  function codexTurnResult(turn, lastMessage) {
13056
13064
  const status = typeof turn.status === "string" ? turn.status : "unknown";
@@ -13504,13 +13512,20 @@ async function checkAgents(adapters, log) {
13504
13512
  adapter.id,
13505
13513
  "auth",
13506
13514
  () => adapter.authStatus(),
13507
- (a) => ({ ready: a.ready, method: a.method, plan: a.plan, detail: a.detail })
13515
+ (a) => ({ ready: a.ready, mode: a.mode, method: a.method, plan: a.plan, detail: a.detail })
13508
13516
  );
13509
- return { id: adapter.id, installed: true, version: detected.version, ready: auth?.ready === true, detail: auth?.detail };
13517
+ return {
13518
+ id: adapter.id,
13519
+ installed: true,
13520
+ version: detected.version,
13521
+ ready: auth?.ready === true,
13522
+ auth: auth?.ready === true ? auth.mode : void 0,
13523
+ detail: auth?.detail
13524
+ };
13510
13525
  }));
13511
13526
  }
13512
13527
  function openAgents(checks) {
13513
- return checks.filter((check) => check.installed).map((check) => ({ id: check.id, ready: check.ready }));
13528
+ return checks.filter((check) => check.installed).map((check) => ({ id: check.id, ready: check.ready, ...check.auth ? { auth: check.auth } : {} }));
13514
13529
  }
13515
13530
  async function probe(log, agent, kind, work, summary) {
13516
13531
  const callId = randomUUID3();
@@ -13902,6 +13917,7 @@ var AGENT_HELP_LINES = [
13902
13917
  function isAgentCommand(domain, action) {
13903
13918
  return domain === "agent" && action === "serve";
13904
13919
  }
13920
+ var BILLED_TO = { "claude-code": "Anthropic", codex: "OpenAI" };
13905
13921
  async function executeAgentServe(input) {
13906
13922
  const paths = agentPaths();
13907
13923
  await ensurePrivateDir(paths.dir);
@@ -13942,7 +13958,7 @@ async function executeAgentServe(input) {
13942
13958
  version: CLI_VERSION,
13943
13959
  endpoint: input.endpoint,
13944
13960
  host,
13945
- agents: checks.map(({ id, installed, ready, version }) => ({ id, installed, ready, ...version ? { version } : {} }))
13961
+ agents: checks.map(({ id, installed, ready, auth, version }) => ({ id, installed, ready, ...auth ? { auth } : {}, ...version ? { version } : {} }))
13946
13962
  });
13947
13963
  const agents = openAgents(checks);
13948
13964
  if (agents.length === 0) {
@@ -13950,7 +13966,12 @@ async function executeAgentServe(input) {
13950
13966
  }
13951
13967
  for (const check of checks) {
13952
13968
  const name = all.find((adapter) => adapter.id === check.id)?.displayName ?? check.id;
13953
- if (check.installed && !check.ready) {
13969
+ if (!check.installed) continue;
13970
+ if (check.ready) {
13971
+ input.io.stderr.write(check.auth === "apiKey" ? `${name}: runs on your own API key (billed to your ${BILLED_TO[check.id]} API account).
13972
+ ` : `${name}: runs on your subscription login (uses your plan's limits).
13973
+ `);
13974
+ } else {
13954
13975
  input.io.stderr.write(`${name} is installed but not signed in${check.detail ? ` (${check.detail})` : ""}. Requests to ${name} will be refused until you sign in and run \`ainecto agent serve\` again.
13955
13976
  `);
13956
13977
  }
@@ -14103,7 +14124,7 @@ async function runAinectoCli(argv, io) {
14103
14124
  });
14104
14125
  }
14105
14126
  if (isAgentCommand(domain, action)) {
14106
- return await executeAgentServe({ endpoint: resolved.endpoint, auth: connect2().auth, io });
14127
+ return await executeAgentServe({ endpoint: resolved.endpoint, env: resolved.env, auth: connect2().auth, io });
14107
14128
  }
14108
14129
  if (domain === "auth") {
14109
14130
  return await handleAuth(action, connect2().auth, resolved.endpoint, parsed.json, io);