@kody-ade/kody-engine 0.4.601 → 0.4.602

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 +76 -2
  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.601",
18
+ version: "0.4.602",
19
19
  description: "kody \u2014 autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative implementation profiles.",
20
20
  license: "MIT",
21
21
  type: "module",
@@ -16521,7 +16521,7 @@ function composeAuthBlock(authProfile, login, password) {
16521
16521
  return `Auth: a saved Playwright \`storageState.json\` is available at \`${authProfile}\`. Pass it to the browser via the \`storageState\` parameter so the session starts pre-authenticated.`;
16522
16522
  }
16523
16523
  if (login && password) {
16524
- return `Auth: log in once at the app's login page. Username: \`${login}\` \xB7 Password: \`${password}\`. Type each field key-by-key (Playwright \`locator.pressSequentially()\` / the MCP \`browser_type\` tool), NOT a one-shot \`fill()\` or value assignment: pasting a value in a single step often fails to fire the login form's framework onChange handler, so the form submits empty and you get a FALSE "invalid email or password". After typing, confirm the field shows the value before clicking submit; if the first attempt is rejected, re-type key-by-key before treating the credentials as wrong. If a login form's inputs don't respond to typing-by-label/placeholder, inspect the DOM and target them by their \`id\`/\`name\` attribute instead \u2014 e.g. a Payload CMS admin login at \`/admin\` uses \`#field-email\` and \`#field-password\`. The app may have TWO separate logins (a public/frontend one and a Payload \`/admin\` one); if a change you must verify lives behind the admin, log into that form too. Re-use the session afterwards.`;
16524
+ return `Auth: QA credentials for \`${login}\` are configured. The engine will prepare the authenticated browser session before the agent starts; the password is never included in agent context.`;
16525
16525
  }
16526
16526
  if (login) {
16527
16527
  return `Auth: username \`${login}\` is configured but no \`LOGIN_PASSWORD\` secret was found. Note auth-gated surfaces as gaps.`;
@@ -18410,6 +18410,46 @@ function writeKodyStorageState(input) {
18410
18410
  fs48.writeFileSync(file, JSON.stringify(storageState), { mode: 384 });
18411
18411
  return { directory, file };
18412
18412
  }
18413
+ function parseSetCookie(value, hostname) {
18414
+ const parts = value.split(";").map((part) => part.trim());
18415
+ const pair = parts.shift() ?? "";
18416
+ const separator = pair.indexOf("=");
18417
+ if (separator <= 0) throw new Error("login response returned an invalid session cookie");
18418
+ const attributes = /* @__PURE__ */ new Map();
18419
+ for (const part of parts) {
18420
+ const index = part.indexOf("=");
18421
+ attributes.set(
18422
+ (index < 0 ? part : part.slice(0, index)).toLowerCase(),
18423
+ index < 0 ? "" : part.slice(index + 1)
18424
+ );
18425
+ }
18426
+ const sameSite = attributes.get("samesite")?.toLowerCase();
18427
+ return {
18428
+ name: pair.slice(0, separator),
18429
+ value: pair.slice(separator + 1),
18430
+ domain: attributes.get("domain")?.replace(/^\./, "") || hostname,
18431
+ path: attributes.get("path") || "/",
18432
+ expires: -1,
18433
+ httpOnly: attributes.has("httponly"),
18434
+ secure: attributes.has("secure"),
18435
+ sameSite: sameSite === "strict" ? "Strict" : sameSite === "none" ? "None" : "Lax"
18436
+ };
18437
+ }
18438
+ function writeCookieStorageState(targetUrl, setCookies) {
18439
+ const target = new URL(targetUrl);
18440
+ const directory = fs48.mkdtempSync(path45.join(os7.tmpdir(), "kody-browser-auth-"));
18441
+ fs48.chmodSync(directory, 448);
18442
+ const file = path45.join(directory, "storage-state.json");
18443
+ fs48.writeFileSync(
18444
+ file,
18445
+ JSON.stringify({
18446
+ cookies: setCookies.map((cookie) => parseSetCookie(cookie, target.hostname)),
18447
+ origins: []
18448
+ }),
18449
+ { mode: 384 }
18450
+ );
18451
+ return { directory, file };
18452
+ }
18413
18453
  function configurePlaywright(profile, storageStatePath) {
18414
18454
  const playwright = profile.claudeCode.mcpServers.find((server) => server.name === "playwright");
18415
18455
  if (!playwright) throw new Error("Playwright MCP server is not configured");
@@ -18512,6 +18552,34 @@ async function prepareKodyRepositoryBrowserAuth(ctx, profile, input) {
18512
18552
  return false;
18513
18553
  }
18514
18554
  }
18555
+ async function prepareEmailPasswordBrowserAuth(ctx, profile, input) {
18556
+ const password = await resolveRuntimeSecret("LOGIN_PASSWORD", ctx);
18557
+ if (!input.login || !password.value) return false;
18558
+ let state;
18559
+ try {
18560
+ const origin = browserOrigin(input.targetUrl);
18561
+ const response = await fetch(`${origin}/api/auth/sign-in/email`, {
18562
+ method: "POST",
18563
+ headers: { "content-type": "application/json", origin },
18564
+ body: JSON.stringify({ email: input.login, password: password.value })
18565
+ });
18566
+ if (!response.ok) throw new Error(`app login returned ${response.status}`);
18567
+ const headers = response.headers;
18568
+ const cookies = headers.getSetCookie?.() ?? (headers.get("set-cookie") ? [headers.get("set-cookie")] : []);
18569
+ if (cookies.length === 0) throw new Error("app login returned no session cookie");
18570
+ state = writeCookieStorageState(input.targetUrl, cookies);
18571
+ configurePlaywright(profile, state.file);
18572
+ const authDirectory = state.directory;
18573
+ registerRuntimeCleanup(ctx, () => fs48.rmSync(authDirectory, { recursive: true, force: true }));
18574
+ ctx.data.qaAuthBlock = "Auth: the app is already signed in through an engine-provided browser session. The login credentials are not available to you; never request, reveal, or report them.";
18575
+ return true;
18576
+ } catch (error) {
18577
+ if (state) fs48.rmSync(state.directory, { recursive: true, force: true });
18578
+ const reason = error instanceof Error ? error.message : String(error);
18579
+ ctx.data.qaAuthBlock = `Auth: the engine could not prepare the app login (${reason}). Note this authenticated surface as a gap.`;
18580
+ return false;
18581
+ }
18582
+ }
18515
18583
  var prepareBrowserAuth;
18516
18584
  var init_prepareBrowserAuth = __esm({
18517
18585
  "src/scripts/prepareBrowserAuth.ts"() {
@@ -18738,6 +18806,12 @@ var init_prepareSimpleCapabilityRuntime = __esm({
18738
18806
  configureBrowser(ctx, profile, requirements);
18739
18807
  if (requirements.qaCredentials) {
18740
18808
  await loadQaContext(ctx, profile);
18809
+ const capabilityInput = ctx.data.capabilityInput && typeof ctx.data.capabilityInput === "object" && !Array.isArray(ctx.data.capabilityInput) ? ctx.data.capabilityInput : {};
18810
+ const targetUrl = typeof capabilityInput.url === "string" ? capabilityInput.url : typeof capabilityInput.targetUrl === "string" ? capabilityInput.targetUrl : "";
18811
+ await prepareEmailPasswordBrowserAuth(ctx, profile, {
18812
+ login: String(ctx.data.qaLogin ?? ""),
18813
+ targetUrl
18814
+ });
18741
18815
  }
18742
18816
  if (requirements.githubTestToken) {
18743
18817
  const capabilityInput = ctx.data.capabilityInput && typeof ctx.data.capabilityInput === "object" && !Array.isArray(ctx.data.capabilityInput) ? ctx.data.capabilityInput : {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kody-ade/kody-engine",
3
- "version": "0.4.601",
3
+ "version": "0.4.602",
4
4
  "description": "kody — autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative implementation profiles.",
5
5
  "license": "MIT",
6
6
  "type": "module",