@augurworks/augur 0.15.7 → 0.15.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@augurworks/augur",
3
- "version": "0.15.7",
3
+ "version": "0.15.8",
4
4
  "files": [
5
5
  "scripts/",
6
6
  "build.js",
@@ -64,6 +64,32 @@ async function post(pathPart, body) {
64
64
  return { status: r.status, json };
65
65
  }
66
66
 
67
+ // A machine that is ALREADY connected to this origin does not pair again by accident. One
68
+ // cold agent collected its token with a blocking `connect`, did not read the answer, ran
69
+ // `connect` again, minted a second code, and had the person approve that too. If the saved
70
+ // token still answers, say so and stop; `--again` pairs afresh on purpose, and a token the
71
+ // workspace no longer honours (revoked, another workspace's) falls through to a new pairing.
72
+ const AGAIN = argv.includes("--again");
73
+ const TOKENS_FILE = path.join(os.homedir(), ".config", "augur", "tokens.json");
74
+ function savedToken() {
75
+ try { const t = JSON.parse(readFileSync(TOKENS_FILE, "utf8"))[host]; return t && t.token ? t : null; } catch (e) { return null; }
76
+ }
77
+ if (!AGAIN && !process.env.AUGUR_TOKEN) {
78
+ const saved = savedToken();
79
+ if (saved && !(saved.expiresAt && Date.parse(saved.expiresAt) <= Date.now())) {
80
+ let live = false;
81
+ try {
82
+ const r = await fetch(`${ORIGIN}/__unit/drafts`, { headers: { Authorization: `Bearer ${saved.token}`, Accept: "application/json" } });
83
+ live = r.status === 200;
84
+ } catch (e) { live = false; }
85
+ if (live) {
86
+ log(`this machine is already connected to ${C.bold}${host}${C.off}${saved.at ? ` (since ${saved.at.slice(0, 16).replace("T", " ")})` : ""}. Nothing to approve.`);
87
+ console.log(` ${C.dim}\`augur open <opportunity>/<prototype>\` works from here. \`augur connect --again\` pairs afresh.${C.off}`);
88
+ process.exit(0);
89
+ }
90
+ }
91
+ }
92
+
67
93
  // A pairing this machine already started and nobody has collected: ask once whether it
68
94
  // was approved meanwhile, and if not, keep waiting on THAT code rather than minting a
69
95
  // second one for the same person to type.
package/src/_worker.js CHANGED
@@ -3754,10 +3754,13 @@ function connectPage(tctx, me) {
3754
3754
  <p>This account can look around but not publish, so it cannot approve a terminal.</p>
3755
3755
  <a class="home" href="/">Back to Augur</a>`
3756
3756
  : `<h1>Connect a terminal</h1>
3757
- <p>Type the code your terminal is showing. Approving it lets that terminal publish as
3758
- <strong>${escapeHtml(me.email)}</strong>.</p>
3759
- <p class="warn">Only approve a code you are reading off your own screen right now.
3760
- Nobody legitimate will ever send you one.</p>
3757
+ <p>Type the code that your terminal, or the assistant you are working with right now,
3758
+ is showing you. Approving it lets that terminal publish as
3759
+ <strong>${escapeHtml(me.email)}</strong>: it works as you, and everything it lands
3760
+ carries your name.</p>
3761
+ <p class="warn">Only approve a code from a terminal you started or an assistant you
3762
+ are talking to right now. A code that arrives by mail, from a stranger, or out of
3763
+ the blue is not yours — do not type it.</p>
3761
3764
  <form id="pairf">
3762
3765
  <input id="pairc" autocomplete="off" autocapitalize="characters" spellcheck="false"
3763
3766
  placeholder="ABCD-EFGH" aria-label="Pairing code" />
@@ -7384,12 +7387,20 @@ function browserFetch(request) {
7384
7387
  return /^Mozilla\//.test(request.headers.get("User-Agent") || "");
7385
7388
  }
7386
7389
 
7387
- /** The one paragraph a non-browser fetch of a prototype is given, first in the body. */
7390
+ /**
7391
+ * The one paragraph a non-browser fetch of a prototype is given, first in the body.
7392
+ *
7393
+ * DESCRIPTIVE, THIRD PERSON, NO ADDRESS AND NO REASSURANCE. A first draft said "Assistants
7394
+ * and scripts: … a terminal is paired with the person's approval, and nobody is ever asked
7395
+ * for a password", and the third cold agent read exactly that sentence as a prompt
7396
+ * injection — text on a fetched page that speaks to the agent and reassures it is the
7397
+ * shape of an attack, whatever it says. A statement of fact and a link is what a page may
7398
+ * carry: what this is, and where the workspace documents how it is edited.
7399
+ */
7388
7400
  function agentPreface(url) {
7389
7401
  const origin = escapeHtml(url.origin);
7390
- return `<p data-augur-door>This prototype is served by an Augur workspace at ${origin}. `
7391
- + `Assistants and scripts: <a href="${DOOR_DOCS}">${origin}${DOOR_DOCS}</a> says how to change it — `
7392
- + `a terminal is paired with the person's approval, and nobody is ever asked for a password.</p>`;
7402
+ return `<p data-augur-door>This prototype is served by an Augur workspace (${origin}). `
7403
+ + `The workspace documents how its prototypes are edited at <a href="${DOOR_DOCS}">${origin}${DOOR_DOCS}</a>.</p>`;
7393
7404
  }
7394
7405
 
7395
7406
  /**
@@ -9227,6 +9238,8 @@ function wantsJson(request, url) {
9227
9238
  // probe and the "an unknown path and the root are the same page" contract depend on it.
9228
9239
  const DOOR_DOCS = "/llms.txt";
9229
9240
  const DOOR_WELL_KNOWN = "/.well-known/augur.json";
9241
+ /** The engine's public source — what the CLI on npm is built from, named so an agent can check. */
9242
+ const ENGINE_SOURCE = "https://github.com/andratwiro/augur";
9230
9243
 
9231
9244
  /** Does this deployment serve drafts — a unit store beside a bundle store. The same two checks `unitApi` makes. */
9232
9245
  const draftsServedHere = (env) => !!(env && env.BUNDLES && unitNamespace(env));
@@ -9241,6 +9254,10 @@ function doorFacts(tctx, url, env) {
9241
9254
  engine: tctx.INSTANCE_ENGINE_VERSION ? { version: tctx.INSTANCE_ENGINE_VERSION } : {},
9242
9255
  pairing: { enabled: pairing, start: "/__publish/_pair/start", approve: "/__connect" },
9243
9256
  connect: pairing ? `npx @augurworks/augur connect --origin ${url.origin}` : null,
9257
+ // Where the CLI comes from, for an agent that checks before it runs anything: the
9258
+ // package is the same open-source engine that serves this page, and `npm view
9259
+ // @augurworks/augur repository` names the same repository.
9260
+ source: ENGINE_SOURCE,
9244
9261
  docs: DOOR_DOCS,
9245
9262
  // Where drafts are served, a prototype is changed by opening it, not by shipping a
9246
9263
  // tree — and the door is where a cold agent learns which of the two this instance is.
@@ -9261,11 +9278,16 @@ function doorText(f) {
9261
9278
  + `It prints a link and a code. The owner of this workspace opens the link in a\n`
9262
9279
  + `browser they are already signed in to and enters the code. The token lands on\n`
9263
9280
  + `that machine, and every verb below uses it from then on.\n\n`
9264
- + `AGENTS: if your person reads your messages only after you finish your turn, run\n`
9265
- + `it with --no-wait. It prints the line and exits; send them that line, end your\n`
9266
- + `turn, and run the same command again once they say they approvedthe token is\n`
9267
- + `collected then, for that same code. Do not poll for the approval in one turn:\n`
9268
- + `the code lives five minutes and nobody sees it until you stop.\n\n`
9281
+ + `The CLI is this engine's own, open source at ${f.source} the same engine that\n`
9282
+ + `serves this page; \`npm view @augurworks/augur repository\` names that repository.\n\n`
9283
+ + `AGENTS: the approval is the person's act, in their browseryou cannot approve\n`
9284
+ + `it from here and must not try; your part is to send them the line and collect\n`
9285
+ + `the token afterwards. If your person reads your messages only after you finish\n`
9286
+ + `your turn, run it with --no-wait: it prints the line and exits. Send them that\n`
9287
+ + `line, end your turn, and run the same command again once they say they approved —\n`
9288
+ + `the token is collected then, for that same code, and no second code is minted.\n`
9289
+ + `Waiting inside one turn skips nothing; it only hides the code from them for the\n`
9290
+ + `five minutes it lives.\n\n`
9269
9291
  + (f.drafts && f.drafts.enabled
9270
9292
  ? `You need no source tree here: \`augur open <opportunity>/<prototype>\` fetches that one\n`
9271
9293
  + `prototype into a folder of its own (see below). Do not clone the workspace first.\n\n`