@kody-ade/kody-engine 0.4.215 → 0.4.217

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/bin/kody.js +18 -41
  2. package/package.json +1 -1
package/dist/bin/kody.js CHANGED
@@ -15,7 +15,7 @@ var init_package = __esm({
15
15
  "package.json"() {
16
16
  package_default = {
17
17
  name: "@kody-ade/kody-engine",
18
- version: "0.4.215",
18
+ version: "0.4.217",
19
19
  description: "kody \u2014 autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative executable profiles.",
20
20
  license: "MIT",
21
21
  type: "module",
@@ -4331,10 +4331,10 @@ async function startLitellmIfNeeded(model, projectDir, url = LITELLM_DEFAULT_URL
4331
4331
  let child;
4332
4332
  let logPath;
4333
4333
  const spawnProxy = () => {
4334
- const configPath = path17.join(os3.tmpdir(), `kody-litellm-${Date.now()}.yaml`);
4334
+ const configPath = path17.join(os3.tmpdir(), `kody-local-litellm-${Date.now()}.yaml`);
4335
4335
  fs19.writeFileSync(configPath, generateLitellmConfigYaml(model));
4336
4336
  const args = ["--config", configPath, "--port", port];
4337
- const nextLogPath = path17.join(os3.tmpdir(), `kody-litellm-${Date.now()}.log`);
4337
+ const nextLogPath = path17.join(os3.tmpdir(), `kody-local-litellm-${Date.now()}.log`);
4338
4338
  const outFd = fs19.openSync(nextLogPath, "w");
4339
4339
  child = spawn3(cmd, args, { stdio: ["ignore", outFd, outFd], detached: true, env: childEnv });
4340
4340
  fs19.closeSync(outFd);
@@ -17613,7 +17613,6 @@ init_executor();
17613
17613
  init_registry();
17614
17614
 
17615
17615
  // src/servers/pool-serve.ts
17616
- import { spawn as spawn8 } from "child_process";
17617
17616
  import { createServer as createServer4 } from "http";
17618
17617
 
17619
17618
  // src/github-health.ts
@@ -17752,7 +17751,6 @@ var FlyClient = class {
17752
17751
  RUNNER_API_KEY: input.runnerApiKey,
17753
17752
  PORT: String(input.port ?? 8080)
17754
17753
  };
17755
- if (input.litellmUrl?.trim()) env.KODY_LITELLM_URL = input.litellmUrl.trim();
17756
17754
  const body = {
17757
17755
  region: input.region,
17758
17756
  config: {
@@ -17982,7 +17980,6 @@ var PoolManager = class {
17982
17980
  region: cfg.region,
17983
17981
  guest: cfg.guest,
17984
17982
  runnerApiKey: cfg.runnerApiKey,
17985
- litellmUrl: cfg.litellmUrl,
17986
17983
  repoTag: cfg.repoTag,
17987
17984
  port: cfg.port
17988
17985
  });
@@ -18129,6 +18126,7 @@ var PoolRegistry = class {
18129
18126
  }
18130
18127
  cfg;
18131
18128
  pools = /* @__PURE__ */ new Map();
18129
+ poolCreates = /* @__PURE__ */ new Map();
18132
18130
  resolveFlyToken;
18133
18131
  resolvePoolMin;
18134
18132
  log;
@@ -18140,6 +18138,15 @@ var PoolRegistry = class {
18140
18138
  const repoTag = this.key(owner, repo);
18141
18139
  const existing = this.pools.get(repoTag);
18142
18140
  if (existing) return existing;
18141
+ const pending = this.poolCreates.get(repoTag);
18142
+ if (pending) return pending;
18143
+ const creating = this.createPool(owner, repo, repoTag).finally(() => {
18144
+ this.poolCreates.delete(repoTag);
18145
+ });
18146
+ this.poolCreates.set(repoTag, creating);
18147
+ return creating;
18148
+ }
18149
+ async createPool(owner, repo, repoTag) {
18143
18150
  let flyToken;
18144
18151
  try {
18145
18152
  flyToken = await this.resolveFlyToken(owner, repo);
@@ -18297,32 +18304,6 @@ function parseClaimRequest(body) {
18297
18304
  if (typeof b.dashboardUrl === "string" && b.dashboardUrl.trim()) req.dashboardUrl = b.dashboardUrl.trim();
18298
18305
  return { req };
18299
18306
  }
18300
- function superviseLitellm() {
18301
- if (process.env.POOL_DISABLE_LITELLM === "1") return null;
18302
- const port = String(envInt("LITELLM_PORT", 4e3));
18303
- const config = process.env.LITELLM_CONFIG ?? "/app/config.yaml";
18304
- const host = process.env.LITELLM_HOST ?? "::";
18305
- let restarts = 0;
18306
- const start = () => {
18307
- log(`starting litellm child (port ${port}, host ${host})`);
18308
- const child = spawn8("litellm", ["--config", config, "--port", port, "--host", host], {
18309
- stdio: "inherit"
18310
- });
18311
- child.on("exit", (code) => {
18312
- restarts++;
18313
- if (restarts > 50) {
18314
- process.stderr.write("[pool-serve] litellm restarted too many times \u2014 giving up\n");
18315
- return;
18316
- }
18317
- log(`litellm exited (${code}) \u2014 restarting in 2s`);
18318
- setTimeout(start, 2e3);
18319
- });
18320
- child.on("error", (err) => process.stderr.write(`[pool-serve] litellm spawn error: ${err.message}
18321
- `));
18322
- return child;
18323
- };
18324
- return start();
18325
- }
18326
18307
  async function poolServe() {
18327
18308
  const masterRaw = process.env.KODY_MASTER_KEY?.trim();
18328
18309
  if (!masterRaw) throw new Error("KODY_MASTER_KEY required for pool-serve");
@@ -18335,12 +18316,10 @@ async function poolServe() {
18335
18316
  const region = process.env.POOL_REGION ?? "fra";
18336
18317
  const perf = process.env.POOL_PERF ?? "medium";
18337
18318
  const guest = PERF_GUEST[perf] ?? PERF_GUEST.medium;
18338
- const litellmUrl = process.env.KODY_LITELLM_URL?.trim() || void 0;
18339
18319
  const min = envInt("POOL_MIN", 2);
18340
18320
  const runnerPort = envInt("RUNNER_PORT", 8080);
18341
18321
  const apiPort = envInt("POOL_API_PORT", 4100);
18342
18322
  const healthTimeoutMs = envInt("POOL_HEALTH_TIMEOUT_MS", 12e4);
18343
- const litellm = superviseLitellm();
18344
18323
  const registry = new PoolRegistry({
18345
18324
  githubToken,
18346
18325
  masterKey: master,
@@ -18350,7 +18329,6 @@ async function poolServe() {
18350
18329
  region,
18351
18330
  guest,
18352
18331
  runnerApiKey,
18353
- litellmUrl,
18354
18332
  port: runnerPort,
18355
18333
  healthTimeoutMs,
18356
18334
  app
@@ -18378,7 +18356,6 @@ async function poolServe() {
18378
18356
  if (req.method === "GET" && url.pathname === "/healthz") {
18379
18357
  return sendJson2(res, 200, {
18380
18358
  ok: true,
18381
- litellm: litellm ? "supervised" : "off",
18382
18359
  repos: registry.activeRepos()
18383
18360
  });
18384
18361
  }
@@ -18439,7 +18416,7 @@ async function poolServe() {
18439
18416
  }
18440
18417
 
18441
18418
  // src/servers/runner-serve.ts
18442
- import { spawn as spawn9 } from "child_process";
18419
+ import { spawn as spawn8 } from "child_process";
18443
18420
  import * as fs45 from "fs";
18444
18421
  import { createServer as createServer5 } from "http";
18445
18422
  var DEFAULT_PORT2 = 8080;
@@ -18551,7 +18528,7 @@ async function defaultRunJob(job) {
18551
18528
  ...interactive && job.hardCapMs ? { KODY_HARD_CAP_MS: String(job.hardCapMs) } : {}
18552
18529
  };
18553
18530
  const run = (cmd, args, cwd) => new Promise((resolve6) => {
18554
- const child = spawn9(cmd, args, { stdio: "inherit", env: childEnv, cwd });
18531
+ const child = spawn8(cmd, args, { stdio: "inherit", env: childEnv, cwd });
18555
18532
  child.on("exit", (code) => resolve6(code ?? 0));
18556
18533
  child.on("error", (err) => {
18557
18534
  process.stderr.write(`[runner-serve] ${cmd} failed: ${err.message}
@@ -18655,7 +18632,7 @@ async function runnerServe() {
18655
18632
  // src/servers/serve.ts
18656
18633
  init_config();
18657
18634
  init_litellm();
18658
- import { spawn as spawn10 } from "child_process";
18635
+ import { spawn as spawn9 } from "child_process";
18659
18636
  function parseTarget(positional) {
18660
18637
  if (!Array.isArray(positional) || positional.length === 0) return "none";
18661
18638
  const first = String(positional[0]).toLowerCase();
@@ -18705,7 +18682,7 @@ async function serve(opts) {
18705
18682
  if (usesProxy) process.stdout.write(` ANTHROPIC_BASE_URL=${url}
18706
18683
  `);
18707
18684
  const args = ["--dangerously-skip-permissions", "--model", model.model];
18708
- const child = spawn10("claude", args, { stdio: "inherit", env: editorEnv, cwd: opts.cwd });
18685
+ const child = spawn9("claude", args, { stdio: "inherit", env: editorEnv, cwd: opts.cwd });
18709
18686
  const exitCode = await new Promise((resolve6) => {
18710
18687
  child.on("exit", (code) => resolve6(code ?? 0));
18711
18688
  child.on("error", (err) => {
@@ -18725,7 +18702,7 @@ async function serve(opts) {
18725
18702
  if (usesProxy) process.stdout.write(` ANTHROPIC_BASE_URL=${url}
18726
18703
  `);
18727
18704
  try {
18728
- const code = spawn10("code", [opts.cwd], { stdio: "inherit", env: editorEnv, detached: true });
18705
+ const code = spawn9("code", [opts.cwd], { stdio: "inherit", env: editorEnv, detached: true });
18729
18706
  code.on("error", (err) => {
18730
18707
  process.stderr.write(`[kody serve] failed to launch VS Code: ${err.message}
18731
18708
  `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kody-ade/kody-engine",
3
- "version": "0.4.215",
3
+ "version": "0.4.217",
4
4
  "description": "kody — autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative executable profiles.",
5
5
  "license": "MIT",
6
6
  "type": "module",