@joenandez/tldr 1.0.1 → 1.1.0

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 (31) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/bin/tldr-agent +3 -2
  4. package/install/tldr-agent-bootstrap.sh +7 -0
  5. package/package.json +7 -6
  6. package/release/activation-manifest.json +6 -6
  7. package/release/payloads/arm64/TldrAgentAegis.pkg +0 -0
  8. package/release/payloads/arm64/tldr-agent.tar.gz +0 -0
  9. package/release/starport-release.json +2 -2
  10. package/skills/tldr/SKILL.md +37 -36
  11. package/src/lib/aegis_native_distribution.mjs +1 -1
  12. package/src/lib/aegis_protocol.mjs +1 -1
  13. package/src/lib/starport_onboarding.mjs +303 -6
  14. package/src/lib/starport_orchestrator.mjs +21 -20
  15. package/src/lib/starport_runtime.mjs +28 -5
  16. package/src/lib/tightbeam_channel.mjs +63 -119
  17. package/src/lib/tightbeam_channel_runtime.mjs +76 -17
  18. package/src/lib/tightbeam_email_adapter.mjs +10 -0
  19. package/src/lib/tightbeam_email_delivery_channel.mjs +107 -133
  20. package/src/lib/tightbeam_email_provider_map.mjs +337 -0
  21. package/src/lib/tightbeam_inbound_publish.mjs +84 -0
  22. package/src/lib/tightbeam_welcome_dispatch.mjs +129 -33
  23. package/src/lib/tldr_agent_diagnostic_schema.mjs +1 -0
  24. package/src/lib/transports/email/render/email.mjs +66 -180
  25. package/src/lib/transports/email/render/html.mjs +37 -80
  26. package/src/lib/transports/email/render/text.mjs +2 -2
  27. package/src/lib/transports/email/render/tldr.mjs +10 -88
  28. package/src/lib/transports/email/render/tokens.mjs +56 -75
  29. package/src/lib/transports/email/templates.mjs +38 -27
  30. package/src/lib/transports/email.mjs +21 -1
  31. package/src/lib/transports/email/render/glyphs.mjs +0 -66
@@ -1,25 +1,12 @@
1
- /* tldr; — the TLDR block.
1
+ /* Message semantics retained independently from presentation.
2
2
  *
3
- * The product's name made literal, and the one place this system speaks above
4
- * the agent. It carries the result, the owner action and the next moment, and it
5
- * invents none of them.
6
- *
7
- * The subject's grammar is already "state word, colon, the decision", so the
8
- * state word becomes the action and the decision becomes the result. The block
9
- * sets a structure that was always in the string; it does not add a claim to it.
10
- * That is also why the subject is never printed twice — a card that repeats its
11
- * own subject above a summary of its own subject has spent the owner's first two
12
- * seconds saying one thing three times.
13
- *
14
- * THE LIVE EDGE lives here. Citron means the point where attention is active, so
15
- * it appears on the action chip when the message needs the owner and nowhere at
16
- * all when it does not. Seeing citron in an inbox has to mean something.
3
+ * State/action resolution still supports callers and future optional summaries,
4
+ * but the ordinary correspondence renderer does not turn it into a branded
5
+ * panel or badge. The agent's words own the visible hierarchy.
17
6
  */
18
7
 
19
- import { RADIUS, TYPE } from "./tokens.mjs";
8
+ import { inlineHtml } from "./html.mjs";
20
9
  import { parseInline, parseMarkdown } from "./markdown.mjs";
21
- import { bandOf, esc, inlineHtml, presentationTable as pt } from "./html.mjs";
22
- import { glyph } from "./glyphs.mjs";
23
10
 
24
11
  export const ACTION = Object.freeze({
25
12
  now: "Needs you now",
@@ -27,22 +14,10 @@ export const ACTION = Object.freeze({
27
14
  none: "Nothing needed",
28
15
  });
29
16
 
30
- /* State words an agent actually writes, mapped to what they mean for the owner.
31
- * A word on neither list resolves to "later", which is the only honest default:
32
- * the message is not shouting, and claiming nothing is needed would be this
33
- * system putting words in the agent's mouth. */
34
17
  const NOW_STATES =
35
18
  /^(needs you|needs text|blocked|can[’']?t resume|action needed|verify)/i;
36
19
  const NONE_STATES =
37
20
  /^(done|got it|complete|completed|finished|delivered|text only)/i;
38
-
39
- /* Lifting the state word off the front leaves the decision starting in lower
40
- * case, and the decision is about to be set as the loudest line in the message.
41
- * It gets a capital.
42
- *
43
- * Not when the first word is an identifier, though: `org_id`, a path, a flag or
44
- * a version string is a thing with a spelling, and capitalising it would be this
45
- * renderer editing the agent's fact rather than its sentence. */
46
21
  const IDENTIFIER = /^[^\s]*[_/.\-@][^\s]*/;
47
22
 
48
23
  const sentenceCase = (value) =>
@@ -50,7 +25,6 @@ const sentenceCase = (value) =>
50
25
  ? value
51
26
  : value[0].toUpperCase() + value.slice(1);
52
27
 
53
- /* The subject's fixed grammar, split into the two things it already contains. */
54
28
  export function splitSubject(subject) {
55
29
  const match = /^([^:]{2,24}):\s*(.+)$/s.exec(String(subject).trim());
56
30
  if (!match) return { state: null, result: String(subject).trim() };
@@ -61,8 +35,9 @@ export function resolveAction(spec) {
61
35
  if (spec.action && ACTION[spec.action]) return spec.action;
62
36
 
63
37
  const raised = parseMarkdown(spec.body ?? "").some((node) => {
64
- const band = node.type === "quote" ? bandOf(node) : null;
65
- return band?.label === "CAUTION" || band?.label === "ABORT";
38
+ if (node.type !== "quote") return false;
39
+ const text = node.children?.[0]?.text?.trim() ?? "";
40
+ return /^\*\*(CAUTION|ABORT)\*\*/.test(text);
66
41
  });
67
42
  if (raised) return "now";
68
43
 
@@ -72,59 +47,6 @@ export function resolveAction(spec) {
72
47
  return "later";
73
48
  }
74
49
 
75
- /* Exactly one element may be citron, and only when something is live. */
76
50
  export const isLive = (spec) => resolveAction(spec) === "now";
77
-
78
- function chipHtml(action, t) {
79
- const label = ACTION[action];
80
- if (action === "none") {
81
- return `<span class="tl-muted" style="${TYPE.chip}color:${t.muted};text-transform:uppercase;">${label}</span>`;
82
- }
83
- const live = action === "now";
84
- return (
85
- `<span class="${live ? "tl-chip-live" : "tl-chip-wait"}" style="display:inline-block;` +
86
- `background:${live ? t.accent : t.solid};color:${live ? t.onAccent : t.onSolid};` +
87
- `${TYPE.chip}text-transform:uppercase;border-radius:${RADIUS.sm};padding:5px 9px;">${label}</span>`
88
- );
89
- }
90
-
91
- /* The reply sentence is written by this system, and it writes Markdown in it —
92
- * the recovery state's line is "Run `tldr status` for the next repair step."
93
- * Escaping it would ship literal backticks in the one sentence that says what to
94
- * do. Parsing is not a licence to emit markup: it goes through the same inline
95
- * parser as the body, which escapes text and only ever emits our own tags. */
96
- export const inlineMarkdownHtml = (value, t) =>
97
- inlineHtml(parseInline(value), t);
98
-
99
- export function tldrHtml(spec, t, reply) {
100
- const { result } = splitSubject(spec.subject);
101
- const action = resolveAction(spec);
102
-
103
- const head = pt(
104
- `<tr>` +
105
- `<td class="tl-link" style="${TYPE.tldrLabel}color:${t.link};text-transform:uppercase;vertical-align:middle;">TLDR</td>` +
106
- `<td align="right" style="vertical-align:middle;padding-left:12px;">${chipHtml(action, t)}</td>` +
107
- `</tr>`,
108
- );
109
-
110
- /* The one instruction in the message, marked by the one glyph in the system. */
111
- const next = pt(
112
- `<tr>` +
113
- `<td width="28" valign="top" style="padding:5px 12px 0 0;">${glyph("reply", t.link, "tl-fill-link")}</td>` +
114
- `<td class="tl-ink" style="${TYPE.small}color:${t.ink};">${inlineMarkdownHtml(reply, t)}</td>` +
115
- `</tr>`,
116
- );
117
-
118
- return pt(
119
- `<tr><td class="tl-bar" style="background:${t.link};height:2px;line-height:2px;font-size:0;` +
120
- `border-radius:${RADIUS.md} ${RADIUS.md} 0 0;">&nbsp;</td></tr>` +
121
- `<tr><td class="tl-field" style="background:${t.field};padding:18px 20px 20px 20px;` +
122
- `border-radius:0 0 ${RADIUS.md} ${RADIUS.md};">` +
123
- pt(
124
- `<tr><td>${head}</td></tr>` +
125
- `<tr><td class="tl-ink" style="${TYPE.result}color:${t.ink};padding:14px 0 0 0;">${esc(result)}</td></tr>` +
126
- `<tr><td style="padding:16px 0 0 0;">${next}</td></tr>`,
127
- ) +
128
- `</td></tr>`,
129
- );
130
- }
51
+ export const inlineMarkdownHtml = (value, tokens) =>
52
+ inlineHtml(parseInline(value), tokens);
@@ -1,91 +1,72 @@
1
- /* tldr; — email tokens.
1
+ /* Email-specific reading tokens.
2
2
  *
3
- * Mirrors docs/brand/tokens.css. Duplicated here because an email cannot load a
4
- * stylesheet: every value has to be baked into a style attribute, so the
5
- * renderer needs the numbers in JavaScript. tokens.css stays the source of
6
- * truth; if a value changes there it changes here, and nowhere else.
7
- *
8
- * Tokens are named for the job rather than the colour. `solid` means "the
9
- * identity plane", and in night lighting that plane is not #0000EE — a renderer
10
- * that asked for "blue" would get the wrong answer in one of the two modes.
11
- *
12
- * Every pairing these produce is declared and measured in
13
- * docs/brand/check-contrast.mjs. Thirty pairings, thirty passing.
3
+ * The wider tldr; identity is deliberately not the visual world of an owner
4
+ * conversation. Email should feel like careful correspondence between a person
5
+ * and their agent. Brand colour is reserved for links and the final semicolon
6
+ * in the quiet footer signature.
14
7
  */
15
8
 
9
+ /* Off-white rather than #FFFFFF: clients that auto-invert dark mode (classic
10
+ * Outlook, Windows Mail) override pure white/black but leave near values to the
11
+ * author, so the day document survives inversion heuristics intact. */
16
12
  export const DAY = Object.freeze({
17
13
  mode: "day",
18
- stock: "#F8FAFC",
19
- raised: "#FFFFFF",
20
- ink: "#20242C",
21
- muted: "#465365",
22
- link: "#0000EE",
23
- field: "#AFCFF5",
24
- solid: "#0000EE",
25
- onSolid: "#F8FAFC",
26
- onSolidMuted: "#AFCFF5",
27
- line: "#6A7DA5",
28
- accent: "#D9FF00",
29
- onAccent: "#20242C",
14
+ page: "#FDFDFD",
15
+ stock: "#FDFDFD",
16
+ raised: "#F4F5F7",
17
+ ink: "#24262B",
18
+ muted: "#626770",
19
+ link: "#315ECA",
20
+ line: "#DADDE2",
21
+ strongLine: "#C5C9D0",
30
22
  });
31
23
 
32
24
  export const NIGHT = Object.freeze({
33
25
  mode: "night",
34
- stock: "#101520",
35
- raised: "#19202E",
36
- ink: "#E9EDF5",
37
- muted: "#A6B3C9",
38
- link: "#93AEFF",
39
- field: "#1C2A45",
40
- solid: "#2440E8",
41
- onSolid: "#EAEFFF",
42
- onSolidMuted: "#C8D4FB",
43
- line: "#5A6880",
44
- accent: "#D9FF00",
45
- onAccent: "#20242C",
26
+ page: "#17181B",
27
+ stock: "#17181B",
28
+ raised: "#222429",
29
+ ink: "#ECEDEF",
30
+ muted: "#A8ACB4",
31
+ link: "#9AAFF0",
32
+ line: "#373A41",
33
+ strongLine: "#50545D",
46
34
  });
47
35
 
48
- /* No webfont will ever load in a mail client, so these are the faces actually
49
- * present on the machine. That is the design, not a concession.
50
- *
51
- * The condensed face is the brand's voice and it is doing real work here: a
52
- * subject line holds about three more words per line in Arial Narrow than in the
53
- * reading face at the same size, and subjects are the one string in this system
54
- * whose length nobody controls. */
55
- export const DISPLAY =
56
- "'Arial Narrow','Aptos Narrow','Helvetica Neue Condensed',Arial,sans-serif";
57
- export const BODY = "Verdana,Geneva,Tahoma,sans-serif";
36
+ /* Native UI faces make the email feel authored in the reader's environment,
37
+ * not typeset by a product. These are installed defaults, so nothing is fetched
38
+ * and every major client has a compatible fallback. */
39
+ export const BODY =
40
+ "-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif";
41
+ export const DISPLAY = BODY;
58
42
  export const MONO =
59
- "ui-monospace,SFMono-Regular,Menlo,Consolas,'Courier New',monospace";
43
+ "ui-monospace,SFMono-Regular,Menlo,Consolas,'Liberation Mono','Courier New',monospace";
60
44
 
61
- /* The condensed face carries short phrases and meaningful numerals only. It
62
- * never sets a paragraph — that is what the reading face is for, at a 16px floor
63
- * because the primary reading device is a phone held at arm's length at 3am. */
45
+ /* 14px/1.5 body is the density of mail people actually write to each other —
46
+ * Outlook composes at ~14.7px, Gmail and Apple Mail read smaller. The 16–18px
47
+ * convention belongs to marketing mail read at a glance, not correspondence.
48
+ * Headings stay within ~1.3× body: a colleague bolds a line, they do not set
49
+ * display type. */
64
50
  export const TYPE = Object.freeze({
65
- /* The TLDR result. The largest thing in the message, and the only display
66
- * string long enough to wrap. */
67
- result: `font-family:${DISPLAY};font-size:26px;line-height:1.12;font-weight:700;letter-spacing:-.02em;`,
68
- tldrLabel: `font-family:${DISPLAY};font-size:12px;line-height:1.2;font-weight:700;letter-spacing:.14em;`,
69
- chip: `font-family:${DISPLAY};font-size:11px;line-height:1.2;font-weight:700;letter-spacing:.1em;`,
70
- body: `font-family:${BODY};font-size:16px;line-height:1.55;`,
71
- small: `font-family:${BODY};font-size:13px;line-height:1.5;`,
72
- label: `font-family:${BODY};font-size:12px;line-height:1.25;font-weight:700;letter-spacing:.02em;`,
73
- context: `font-family:${MONO};font-size:12px;line-height:1.5;`,
74
- section: `font-family:${DISPLAY};font-size:21px;line-height:1.15;font-weight:700;letter-spacing:-.01em;`,
75
- sub: `font-family:${DISPLAY};font-size:16px;line-height:1.2;font-weight:700;letter-spacing:.02em;`,
76
- /* The numeral device: oversized condensed figures indexing a real step. */
77
- numeral: `font-family:${DISPLAY};font-size:20px;line-height:1;font-weight:700;`,
78
- code: `font-family:${MONO};font-size:13px;line-height:1.5;`,
79
- tag: `font-family:${MONO};font-size:11px;line-height:1.2;letter-spacing:.08em;`,
80
- tableHead: `font-family:${DISPLAY};font-size:12px;line-height:1.2;font-weight:700;letter-spacing:.08em;`,
81
- tableCell: `font-family:${BODY};font-size:14px;line-height:1.5;`,
82
- /* The system bar. */
83
- stamp: `font-family:${DISPLAY};font-size:12px;line-height:1.2;font-weight:700;letter-spacing:.1em;`,
51
+ body: `font-family:${BODY};font-size:14px;line-height:1.5;font-weight:400;`,
52
+ small: `font-family:${BODY};font-size:12.5px;line-height:1.5;font-weight:400;`,
53
+ label: `font-family:${BODY};font-size:12px;line-height:1.45;font-weight:600;`,
54
+ context: `font-family:${BODY};font-size:11.5px;line-height:1.5;font-weight:400;`,
55
+ section: `font-family:${BODY};font-size:17px;line-height:1.4;font-weight:600;letter-spacing:-.01em;`,
56
+ sub: `font-family:${BODY};font-size:15px;line-height:1.45;font-weight:600;`,
57
+ code: `font-family:${MONO};font-size:12.5px;line-height:1.55;font-weight:400;`,
58
+ tag: `font-family:${BODY};font-size:11px;line-height:1.4;font-weight:600;`,
59
+ tableHead: `font-family:${BODY};font-size:12.5px;line-height:1.45;font-weight:600;`,
60
+ tableCell: `font-family:${BODY};font-size:13.5px;line-height:1.5;font-weight:400;`,
61
+ systemLabel: `font-family:${BODY};font-size:11.5px;line-height:1.45;font-weight:500;`,
62
+ systemTitle: `font-family:${BODY};font-size:19px;line-height:1.35;font-weight:600;letter-spacing:-.01em;`,
63
+ codePlate: `font-family:${MONO};font-size:28px;line-height:1.3;font-weight:500;letter-spacing:.12em;`,
64
+ colophon: `font-family:${BODY};font-size:11px;line-height:1.45;font-weight:400;`,
84
65
  });
85
66
 
86
- /* One reading column. */
87
- export const CARD_WIDTH = 600;
88
-
89
- /* Radius is 0, 2 or 4. Four is the maximum in the system and the TLDR block is
90
- * where it is spent; code takes two; nothing is a rounded card. */
91
- export const RADIUS = Object.freeze({ sm: "2px", md: "4px" });
67
+ /* 640 sits inside the ~650px ceiling Outlook and Yahoo render comfortably and,
68
+ * with 24px gutters, gives prose a 592px measure — the width of a note in a
69
+ * desktop reading pane rather than a mobile-first promotional column. */
70
+ export const CARD_WIDTH = 640;
71
+ export const GUTTER = 24;
72
+ export const RADIUS = Object.freeze({ sm: "4px", md: "6px" });
@@ -4,14 +4,14 @@
4
4
  * and the module namespace is on the repository's side of the rename, not the
5
5
  * owner's. Everything it renders says `tldr;`.
6
6
  *
7
- * There is no `heading` any more. The envelope flows the subject into the TLDR
8
- * block, so a heading would be the subject said twice. Callers may still pass
9
- * one; it is ignored.
7
+ * There is no `heading` configuration. Normal conversation starts with the
8
+ * agent's body; system messages derive their restrained heading from the
9
+ * subject. Callers may still pass the legacy field; it is ignored.
10
10
  */
11
11
 
12
12
  import { AGENTS, render } from "./render/email.mjs";
13
13
 
14
- const TEMPLATE_VERSION = "tldr-email-v3";
14
+ const TEMPLATE_VERSION = "tldr-email-v4";
15
15
 
16
16
  const VALID_STATES = new Set([
17
17
  "conversation",
@@ -24,12 +24,11 @@ const VALID_STATES = new Set([
24
24
  "key_replaced",
25
25
  ]);
26
26
 
27
- /* The word in the system bar, per state.
27
+ /* The small system identity label, per state.
28
28
  *
29
29
  * A system message is tldr; speaking as itself, and it must not be mistakable
30
- * for the agent: without the bar, "Can't resume: your reply arrived, the session
31
- * did not" reads like the agent writing about itself. A conversation is the
32
- * agent speaking and deliberately carries no bar.
30
+ * for the agent. The distinction is typographic rather than a branded banner.
31
+ * A conversation is the agent speaking and carries no system label.
33
32
  *
34
33
  * The vocabulary is four words wide on purpose. A fifth is a distinction the
35
34
  * owner has to learn. SECURITY is separate from ERROR because a message about
@@ -103,16 +102,16 @@ stopped.`,
103
102
  * substituted by the broker at send time. */
104
103
  verification_code: {
105
104
  action: "now",
106
- subject: "Verify: your code is __TLDR_CODE__",
105
+ subject: "Verify your email address",
107
106
  code: "__TLDR_CODE__",
108
- body: `It finishes connecting this address, and it is single-use and expires in
109
- 10 minutes.
107
+ body: `This code finishes connecting your email address. It is single-use and
108
+ expires in 10 minutes.
110
109
 
111
110
  > **CAUTION**: Enter it only in the setup app on your own Mac. An agent will
112
111
  > never ask you for it, and neither will anyone else.
113
112
 
114
113
  If you didn't ask for this code, you can ignore this email.`,
115
- reply: "Enter the code in the setup app. Replying here does nothing.",
114
+ reply: "Replying here does nothing.",
116
115
  notice: "Sent because this address was entered during setup.",
117
116
  },
118
117
  owner_changed: {
@@ -148,6 +147,13 @@ function oneLine(value) {
148
147
  return cleanText(value).replace(/\s+/g, " ");
149
148
  }
150
149
 
150
+ function debugSetupTemplateDrift(stage, data) {
151
+ if (process.env.TLDR_AGENT_DEBUG_TEMPLATE_DRIFT !== "1") return;
152
+ process.stderr.write(
153
+ `[🪳 TEMP SETUP_EMAIL_TEMPLATE_DRIFT] ${stage} ${JSON.stringify(data)}\n`,
154
+ );
155
+ }
156
+
151
157
  /* The body is the one field that passes through untouched apart from line
152
158
  * endings. It is Markdown an agent wrote, and reflowing it is what destroys a
153
159
  * fenced block or a table. */
@@ -181,45 +187,50 @@ export function renderTldrAgentEmail(input = {}) {
181
187
  agent,
182
188
  });
183
189
 
190
+ debugSetupTemplateDrift("render", {
191
+ state,
192
+ template_version: TEMPLATE_VERSION,
193
+ system: SYSTEM_KIND[state] ?? null,
194
+ });
195
+
184
196
  return { ...rendered, template_version: TEMPLATE_VERSION };
185
197
  }
186
198
 
187
199
  const WELCOME_SCENARIOS = Object.freeze([
188
200
  "Email me a summary when you finish.",
189
- "Send me the decision and anything still blocked.",
190
201
  "Email me if you need input before continuing.",
191
- "Reply to this email with a follow-up for this Claude Code session.",
202
+ "Send me the decision and anything still blocked.",
192
203
  ]);
193
204
 
194
205
  export function renderTldrAgentWelcomeEmail({
195
206
  scenarios = WELCOME_SCENARIOS,
196
207
  } = {}) {
197
- const body = `# tldr; is ready
208
+ const body = `tldr; is ready on this Mac.
198
209
 
199
- Claude Code can email you from this Mac. When you reply, tldr; returns your
200
- message to the Claude Code session that sent the email.
210
+ This message came from the agent session that completed setup. Reply with anything—“hello” is enough—and the same session will answer to confirm that replies work.
201
211
 
202
- ## A few things to try
212
+ ## Try tldr;
203
213
 
204
214
  ${scenarios.map((scenario) => `- “${oneLine(scenario)}”`).join("\n")}
205
215
 
206
- You can also ask Claude to “Check tldr;,” “Configure tldr;,” “Repair
207
- tldr;,” or “Uninstall tldr;.”`;
208
- const subject = "Ready: tldr; is connected";
216
+ You don’t need to reply; setup is complete.`;
217
+ const subject = "tldr; is ready — reply to test it";
209
218
  const rendered = renderTldrAgentEmail({
210
219
  state: "conversation",
211
220
  subject,
212
221
  body,
213
- replyInstruction: "Reply to continue this Claude Code session.",
214
- securityNotice: "tldr; sent this message only to its confirmed owner.",
215
- statePanel: [["tldr;", "Ready"]],
216
- agent: AGENTS.claude,
222
+ replyInstruction:
223
+ "Reply to continue the agent session that sent this email.",
224
+ securityNotice:
225
+ "Only replies from your verified address reach the session.",
217
226
  });
218
227
  return Object.freeze({
219
228
  subject,
220
229
  body,
221
- replyInstruction: "Reply to continue this Claude Code session.",
222
- securityNotice: "tldr; sent this message only to its confirmed owner.",
230
+ replyInstruction:
231
+ "Reply to continue the agent session that sent this email.",
232
+ securityNotice:
233
+ "Only replies from your verified address reach the session.",
223
234
  ...rendered,
224
235
  });
225
236
  }
@@ -56,6 +56,8 @@ const HINT = Object.freeze({
56
56
  "Verify ~/.helm/email/config.json exists with api_key + inbox_id + inbox_email, then retry. Run `helm-tasks onboard --reconfigure agentmail` to (re)provision the credential.",
57
57
  transport_send_failed:
58
58
  "Inspect transport_state.error for the underlying AgentMail SDK exception and retry within --max-attempts.",
59
+ reply_parent_unauthorized:
60
+ "Reconcile the accepted owner reply before retrying this email response.",
59
61
  });
60
62
  const TRUSTED_OWNER_CONTEXT = Symbol("tldr-agent-verified-owner");
61
63
  const BROKER_AUTHORIZED_CONTEXT = Symbol("aegis-broker-authorized-owner");
@@ -782,7 +784,16 @@ export const emailTransport = {
782
784
  // Pre-shaped errors (transport_send_failed thrown above) propagate
783
785
  // unchanged so the caller sees the existing log + error envelope.
784
786
  if (err && err.code === "transport_send_failed" && err.hint) throw err;
785
- const wrapped = emailNotSent();
787
+ const wrapped =
788
+ canonicalRow.kind === "reply" &&
789
+ err?.code === "REPLY_PARENT_UNAUTHORIZED"
790
+ ? makeError(
791
+ "reply_parent_unauthorized",
792
+ "Email reply parent is not authorized.",
793
+ HINT.reply_parent_unauthorized,
794
+ err,
795
+ )
796
+ : emailNotSent();
786
797
  if (err?.ambiguous === true) wrapped.ambiguous = true;
787
798
  logOutcome({
788
799
  canonicalRow,
@@ -977,6 +988,7 @@ export const emailTransport = {
977
988
  const published = await ctx.tightbeamInbound.publishInboundEmail({
978
989
  binding,
979
990
  provider_message_id: externalMessageId,
991
+ provider_thread_id: externalThreadId,
980
992
  body: text,
981
993
  });
982
994
  if (published?.ok !== true) {
@@ -2225,6 +2237,14 @@ export async function reconcileInboxThread({
2225
2237
  [TRUSTED_OWNER_CONTEXT]: verifiedOwnerEmail,
2226
2238
  ...(tightbeamInbound ? { tightbeamInbound } : {}),
2227
2239
  });
2240
+ if (inboundResult?.recovery_required) {
2241
+ errors.push({
2242
+ stage: "inboundWebhook",
2243
+ messageId: m.messageId,
2244
+ error: inboundResult.reason || "thread_recovery_required",
2245
+ });
2246
+ continue;
2247
+ }
2228
2248
  // GH#24 — an idempotent re-observation is not a fresh write.
2229
2249
  if (inboundResult?.canonicalRow && !inboundResult?.idempotent)
2230
2250
  written += 1;
@@ -1,66 +0,0 @@
1
- /* tldr; — drawn glyphs.
2
- *
3
- * An email cannot load an icon font, an SVG or a remote image, so the one mark
4
- * in this system is drawn out of table cells: a matrix of 2px squares, coloured
5
- * or nothing.
6
- *
7
- * Resolution is the whole game. At 3px cells and five rows there is not enough
8
- * room above and below the shaft for an arrowhead, and the reply mark renders as
9
- * a plus. 2px cells and nine rows is the floor at which a diagonal reads as a
10
- * diagonal.
11
- *
12
- * The glyph never carries meaning alone. It sits beside the sentence it marks,
13
- * so it adds structure to the block without asking the reader to decode it.
14
- *
15
- * There is no citron glyph. On a light card citron is 1.10:1 and decorative
16
- * only, so the live edge is a filled chip with `onAccent` text on it rather than
17
- * a drawn mark — the words carry the meaning and the colour carries the
18
- * attention. A citron arrow would be a mark nobody could see in daylight.
19
- */
20
-
21
- const MATRIX = Object.freeze({
22
- /* Reply: an arrow back to the sender. It marks the next moment — the one
23
- * instruction in the message. */
24
- reply: [
25
- "....#.......",
26
- "...##.......",
27
- "..###.......",
28
- ".####.......",
29
- "############",
30
- ".####.......",
31
- "..###.......",
32
- "...##.......",
33
- "....#.......",
34
- ],
35
- });
36
-
37
- const CELL = 2;
38
-
39
- /* `fillClass` lands on the inked cells only. The blank cells carry no class and
40
- * no background, so the night block can repaint a glyph without flooding the
41
- * whole matrix — the difference between a mark and a solid square. */
42
- export function glyph(name, colour, fillClass) {
43
- const matrix = MATRIX[name];
44
- const rows = matrix
45
- .map(
46
- (row) =>
47
- `<tr>${[...row]
48
- .map((cell) =>
49
- cell === "#"
50
- ? `<td class="${fillClass}" height="${CELL}" width="${CELL}" bgcolor="${colour}" style="font-size:0;line-height:${CELL}px;padding:0;">&nbsp;</td>`
51
- : `<td height="${CELL}" width="${CELL}" style="font-size:0;line-height:${CELL}px;padding:0;">&nbsp;</td>`,
52
- )
53
- .join("")}</tr>`,
54
- )
55
- .join("");
56
-
57
- return (
58
- `<table role="presentation" cellpadding="0" cellspacing="0" border="0" ` +
59
- `style="border-collapse:collapse;width:${CELL * matrix[0].length}px;">${rows}</table>`
60
- );
61
- }
62
-
63
- /* The plain-text twin marks the same place with the same intent. */
64
- export const TEXT_GLYPH = Object.freeze({
65
- reply: "<-",
66
- });