@standardagents/builder 0.24.0 → 0.24.1
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.
package/dist/built-in-routes.js
CHANGED
|
@@ -70298,9 +70298,18 @@ function page(title, body, ok) {
|
|
|
70298
70298
|
{ headers: { "Content-Type": "text/html; charset=utf-8" } }
|
|
70299
70299
|
);
|
|
70300
70300
|
}
|
|
70301
|
+
function outcome(env2, ok, reason, fallback) {
|
|
70302
|
+
const baseRaw = env2.STANDARD_AGENTS_DEVICE_OUTCOME_URL_BASE;
|
|
70303
|
+
const base = typeof baseRaw === "string" ? baseRaw.trim().replace(/\/+$/, "") : "";
|
|
70304
|
+
if (base) {
|
|
70305
|
+
const target = ok ? `${base}/done` : `${base}/error?reason=${encodeURIComponent(reason)}`;
|
|
70306
|
+
return new Response(null, { status: 302, headers: { Location: target } });
|
|
70307
|
+
}
|
|
70308
|
+
return page(fallback.title, fallback.body, ok);
|
|
70309
|
+
}
|
|
70301
70310
|
var approve_get_default = defineController2(async ({ req, env: env2, params }) => {
|
|
70302
70311
|
const code = params.code;
|
|
70303
|
-
if (!code) return
|
|
70312
|
+
if (!code) return outcome(env2, false, "invalid_link", { title: "Missing code", body: "This device link is malformed." });
|
|
70304
70313
|
const url = new URL(req.url);
|
|
70305
70314
|
let approvingUserId = null;
|
|
70306
70315
|
const handoff = url.searchParams.get("handoff");
|
|
@@ -70313,7 +70322,7 @@ var approve_get_default = defineController2(async ({ req, env: env2, params }) =
|
|
|
70313
70322
|
);
|
|
70314
70323
|
const projectOk = payload && (configuredProjectId || payload.project_id === hostedInstanceRedirectId(req, env2));
|
|
70315
70324
|
if (!payload || !payload.platform_user_id || !payload.role || !projectOk) {
|
|
70316
|
-
return
|
|
70325
|
+
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
70326
|
}
|
|
70318
70327
|
const user = await upsertReplicaUserForPlatformProfile(env2, {
|
|
70319
70328
|
platform_user_id: payload.platform_user_id,
|
|
@@ -70334,7 +70343,7 @@ var approve_get_default = defineController2(async ({ req, env: env2, params }) =
|
|
|
70334
70343
|
return new Response(null, { status: 302, headers: { Location: `${url.origin}${target}` } });
|
|
70335
70344
|
}
|
|
70336
70345
|
if (authResult.authType === "api_key") {
|
|
70337
|
-
return
|
|
70346
|
+
return outcome(env2, false, "session_required", { title: "Sign in required", body: "Device logins must be approved from a signed-in browser session." });
|
|
70338
70347
|
}
|
|
70339
70348
|
approvingUserId = authResult.user.id;
|
|
70340
70349
|
}
|
|
@@ -70351,9 +70360,9 @@ var approve_get_default = defineController2(async ({ req, env: env2, params }) =
|
|
|
70351
70360
|
key_name: "CLI device login"
|
|
70352
70361
|
});
|
|
70353
70362
|
if (!ok) {
|
|
70354
|
-
return
|
|
70363
|
+
return outcome(env2, false, "expired", { title: "Link expired", body: "This device login has expired or was already used. Start again from your terminal." });
|
|
70355
70364
|
}
|
|
70356
|
-
return
|
|
70365
|
+
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
70366
|
});
|
|
70358
70367
|
|
|
70359
70368
|
// src/api/skills/[name]/files/[...path].get.ts
|