@standardagents/builder 0.24.0 → 0.24.2

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.
@@ -70188,6 +70188,11 @@ var callback_get_default = defineController2(async ({ req, env: env2 }) => {
70188
70188
  }
70189
70189
  });
70190
70190
  }
70191
+ const landingRaw = env2.STANDARD_AGENTS_API_ROLE_LANDING_URL;
70192
+ const landing = typeof landingRaw === "string" ? landingRaw.trim() : "";
70193
+ if (landing && /^https:\/\//.test(landing)) {
70194
+ return new Response(null, { status: 302, headers: { Location: landing } });
70195
+ }
70191
70196
  return failRedirect(req, env2, "api_only_account");
70192
70197
  }
70193
70198
  const session = await mintLocalSessionForPlatformUser(env2, {
@@ -70298,9 +70303,18 @@ function page(title, body, ok) {
70298
70303
  { headers: { "Content-Type": "text/html; charset=utf-8" } }
70299
70304
  );
70300
70305
  }
70306
+ function outcome(env2, ok, reason, fallback) {
70307
+ const baseRaw = env2.STANDARD_AGENTS_DEVICE_OUTCOME_URL_BASE;
70308
+ const base = typeof baseRaw === "string" ? baseRaw.trim().replace(/\/+$/, "") : "";
70309
+ if (base) {
70310
+ const target = ok ? `${base}/done` : `${base}/error?reason=${encodeURIComponent(reason)}`;
70311
+ return new Response(null, { status: 302, headers: { Location: target } });
70312
+ }
70313
+ return page(fallback.title, fallback.body, ok);
70314
+ }
70301
70315
  var approve_get_default = defineController2(async ({ req, env: env2, params }) => {
70302
70316
  const code = params.code;
70303
- if (!code) return page("Missing code", "This device link is malformed.", false);
70317
+ if (!code) return outcome(env2, false, "invalid_link", { title: "Missing code", body: "This device link is malformed." });
70304
70318
  const url = new URL(req.url);
70305
70319
  let approvingUserId = null;
70306
70320
  const handoff = url.searchParams.get("handoff");
@@ -70313,7 +70327,7 @@ var approve_get_default = defineController2(async ({ req, env: env2, params }) =
70313
70327
  );
70314
70328
  const projectOk = payload && (configuredProjectId || payload.project_id === hostedInstanceRedirectId(req, env2));
70315
70329
  if (!payload || !payload.platform_user_id || !payload.role || !projectOk) {
70316
- return page("Sign in failed", "This sign-in link is invalid or has expired. Start again from your terminal.", false);
70330
+ return outcome(env2, false, "signin_failed", { title: "Sign in failed", body: "This sign-in link is invalid or has expired. Start again from your terminal." });
70317
70331
  }
70318
70332
  const user = await upsertReplicaUserForPlatformProfile(env2, {
70319
70333
  platform_user_id: payload.platform_user_id,
@@ -70334,7 +70348,7 @@ var approve_get_default = defineController2(async ({ req, env: env2, params }) =
70334
70348
  return new Response(null, { status: 302, headers: { Location: `${url.origin}${target}` } });
70335
70349
  }
70336
70350
  if (authResult.authType === "api_key") {
70337
- return page("Sign in required", "Device logins must be approved from a signed-in browser session.", false);
70351
+ return outcome(env2, false, "session_required", { title: "Sign in required", body: "Device logins must be approved from a signed-in browser session." });
70338
70352
  }
70339
70353
  approvingUserId = authResult.user.id;
70340
70354
  }
@@ -70351,9 +70365,9 @@ var approve_get_default = defineController2(async ({ req, env: env2, params }) =
70351
70365
  key_name: "CLI device login"
70352
70366
  });
70353
70367
  if (!ok) {
70354
- return page("Link expired", "This device login has expired or was already used. Start again from your terminal.", false);
70368
+ return outcome(env2, false, "expired", { title: "Link expired", body: "This device login has expired or was already used. Start again from your terminal." });
70355
70369
  }
70356
- return page("You're connected", "Standard Code is now signed in. Return to your terminal \u2014 it will pick up automatically.", true);
70370
+ return outcome(env2, true, "done", { title: "You're connected", body: "Standard Code is now signed in. Return to your terminal \u2014 it will pick up automatically." });
70357
70371
  });
70358
70372
 
70359
70373
  // src/api/skills/[name]/files/[...path].get.ts