{"draft":null,"from":258,"to":259,"files":[{"path":"client/src/main.ts","added":67,"removed":4,"diff":"--- a/client/src/main.ts\n+++ b/client/src/main.ts\n@@ -8,7 +8,7 @@\n import { bool, type FlagSpec, type Parsed, parseArgs, str, UsageError } from \"./args.ts\";\n import { runAutosettle } from \"./autosettle-commands.ts\";\n import { bodyFilesHelp, readBodyFiles, withBodyFiles } from \"./body-files.ts\";\n-import { boxPublic, boxText, login, loginRequest, logout, readBox } from \"./box.ts\";\n+import { boxName, boxPublic, boxText, login, loginRequest, logout, originOf, readBox } from \"./box.ts\";\n import { runDiff, runFiles, runLog, runRestore, runShow } from \"./changes.ts\";\n import { runCheckIgnore } from \"./check-ignore.ts\";\n import { runCi } from \"./ci.ts\";\n@@ -45,7 +45,17 @@\n import { runExport } from \"./export.ts\";\n import { runGroup, runGroups } from \"./group-commands.ts\";\n import { runBlame, runWhere, runWho, runWhy } from \"./history.ts\";\n-import { runAck, runAnswer, runAsk, runIssue, runIssues, runReply, runSearch, runWaiting } from \"./issues.ts\";\n+import {\n+\topenIssues,\n+\trunAck,\n+\trunAnswer,\n+\trunAsk,\n+\trunIssue,\n+\trunIssues,\n+\trunReply,\n+\trunSearch,\n+\trunWaiting,\n+} from \"./issues.ts\";\n import { adminToken, issuedPublic, keyList, keyListText, keyNew, keyRevoke } from \"./key-admin.ts\";\n import { browserSkip, openInBrowser } from \"./open-browser.ts\";\n import { runOrg, runOrgs } from \"./orgs.ts\";\n@@ -189,13 +199,15 @@\n \t\tflags: {\n \t\t\tserver: \"string\",\n \t\t\t\"no-browser\": \"boolean\",\n+\t\t\t\"no-ask\": \"boolean\",\n \t\t\tprojects: \"string\",\n \t\t\trole: \"string\",\n \t\t\tdays: \"string\",\n \t\t},\n-\t\tusage: \"abso login [--no-browser] [--projects <name,name>] [--role <reader|writer|owner>] [--days <1-90>]\",\n+\t\tusage:\n+\t\t\t\"abso login [--no-browser] [--no-ask] [--projects <name,name>] [--role <reader|writer|owner>] [--days <1-90>]\",\n \t\tabout:\n-\t\t\t\"Sign this box in once: it opens the approve page in your browser with the code filled in, prints the link and the code too, and waits while a person approves the code on the website, choosing the projects, the highest role and how long. Then abso join in any of those projects gives each agent its own key, with no approval. The box's sign-in is kept in your user folder, never in a project folder, and is never printed. No browser opens with --no-browser or ABSO_NO_BROWSER, over SSH, under CI, or on Linux without a display.\",\n+\t\t\t\"Sign this box in once: it opens the approve page in your browser with the code filled in, prints the link and the code too, and waits while a person approves the code on the website, choosing the projects, the highest role and how long. Then abso join in any of those projects gives each agent its own key, with no approval. The box's sign-in is kept in your user folder, never in a project folder, and is never printed. No browser opens with --no-browser or ABSO_NO_BROWSER, over SSH, under CI, or on Linux without a display. In an agent's folder on the same server, it also asks a person in that project to approve it (the person who approved the agent's box, else the project's owners), as an abso ask, so nobody has to relay the code; the box can then be granted that project at no more than the agent's own role. --no-ask shows the code only.\",\n \t\trun: async (args, env) => {\n \t\t\tconst server = boxServer(args, env);\n \t\t\tconst open =\n@@ -203,6 +215,7 @@\n \t\t\t\t\t? undefined\n \t\t\t\t\t: (url: string) => openInBrowser(url);\n \t\t\tconst record = await login(server, {\n+\t\t\t\task: bool(args, \"no-ask\") ? undefined : loginAsk(server, env),\n \t\t\t\trequest: loginRequest(args),\n \t\t\t\tsay: (line) => process.stderr.write(terminalText(`${line}\\n`, colorsPass(process.stderr, env.env))),\n \t\t\t\topen,\n@@ -1063,3 +1076,53 @@\n \t\t};\n \t}\n }\n+\n+/**\n+ * abso 684: in an agent's folder on this same server, the ask `abso login` makes of a person in that project, so nobody\n+ * relays the code. The folder's agent key proves the agent; the device code proves the sign-in is this client's own.\n+ * Null outside such a folder, or when nobody could be asked: login then shows the code alone.\n+ */\n+function loginAsk(server: string, env: Env): NonNullable<Parameters<typeof login>[1][\"ask\"]> | undefined {\n+\tconst root = findRoot(env.cwd);\n+\tif (root === undefined || isVisitor(root)) return undefined;\n+\tconst config = readConfig(root, env.env);\n+\tif (config.token === undefined || originOf(config.server) !== originOf(server)) return undefined;\n+\treturn async ({ device, user }) => {\n+\t\tconst asked = await fetch(`${originOf(server)}/login/ask`, {\n+\t\t\tmethod: \"POST\",\n+\t\t\theaders: { \"content-type\": \"application/json\", authorization: `Bearer ${config.token}` },\n+\t\t\tbody: JSON.stringify({ project: config.project, agent: config.agent, device_code: device, user_code: user }),\n+\t\t});\n+\t\tconst body = (await asked.json().catch(() => ({}))) as {\n+\t\t\terror?: string;\n+\t\t\tpeople?: string[];\n+\t\t\texpires_at?: string;\n+\t\t\trequest_url?: string;\n+\t\t\trole?: string;\n+\t\t};\n+\t\tif (!asked.ok || !Array.isArray(body.people) || typeof body.request_url !== \"string\") return null;\n+\t\tconst expiresAt = Date.parse(body.expires_at ?? \"\");\n+\t\tconst { api } = openIssues(env);\n+\t\tconst when = new Intl.DateTimeFormat(\"en-US\", { timeZone: \"America/Chicago\", hour: \"numeric\", minute: \"2-digit\" });\n+\t\tconst question = `Please sign in my box \"${boxName()}\" for ${config.project}, as at most ${body.role}. It expires at ${when.format(new Date(expiresAt))} CT. Approve or deny: ${body.request_url}`;\n+\t\tconst asks: number[] = [];\n+\t\tfor (const of of body.people) asks.push((await api.ask({ of, question })).id);\n+\t\tconst first = asks[0];\n+\t\tif (first !== undefined)\n+\t\t\tawait fetch(`${originOf(server)}/login/ask/link`, {\n+\t\t\t\tmethod: \"POST\",\n+\t\t\t\theaders: { \"content-type\": \"application/json\" },\n+\t\t\t\tbody: JSON.stringify({ device_code: device, ask: first }),\n+\t\t\t});\n+\t\treturn {\n+\t\t\tproject: config.project,\n+\t\t\twho: body.people.length === 1 ? \"the person who approved this agent's box\" : `the owners of ${config.project}`,\n+\t\t\tasks,\n+\t\t\texpiresAt,\n+\t\t\trole: body.role ?? \"writer\",\n+\t\t\twithdraw: async () => {\n+\t\t\t\tfor (const id of asks) await api.withdraw(id, { note: \"The sign-in ran out; nothing was granted.\" });\n+\t\t\t},\n+\t\t};\n+\t};\n+}"}],"unmatched":[]}