@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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/bin/tldr-agent +3 -2
- package/install/tldr-agent-bootstrap.sh +7 -0
- package/package.json +7 -6
- package/release/activation-manifest.json +6 -6
- package/release/payloads/arm64/TldrAgentAegis.pkg +0 -0
- package/release/payloads/arm64/tldr-agent.tar.gz +0 -0
- package/release/starport-release.json +2 -2
- package/skills/tldr/SKILL.md +37 -36
- package/src/lib/aegis_native_distribution.mjs +1 -1
- package/src/lib/aegis_protocol.mjs +1 -1
- package/src/lib/starport_onboarding.mjs +303 -6
- package/src/lib/starport_orchestrator.mjs +21 -20
- package/src/lib/starport_runtime.mjs +28 -5
- package/src/lib/tightbeam_channel.mjs +63 -119
- package/src/lib/tightbeam_channel_runtime.mjs +76 -17
- package/src/lib/tightbeam_email_adapter.mjs +10 -0
- package/src/lib/tightbeam_email_delivery_channel.mjs +107 -133
- package/src/lib/tightbeam_email_provider_map.mjs +337 -0
- package/src/lib/tightbeam_inbound_publish.mjs +84 -0
- package/src/lib/tightbeam_welcome_dispatch.mjs +129 -33
- package/src/lib/tldr_agent_diagnostic_schema.mjs +1 -0
- package/src/lib/transports/email/render/email.mjs +66 -180
- package/src/lib/transports/email/render/html.mjs +37 -80
- package/src/lib/transports/email/render/text.mjs +2 -2
- package/src/lib/transports/email/render/tldr.mjs +10 -88
- package/src/lib/transports/email/render/tokens.mjs +56 -75
- package/src/lib/transports/email/templates.mjs +38 -27
- package/src/lib/transports/email.mjs +21 -1
- package/src/lib/transports/email/render/glyphs.mjs +0 -66
|
@@ -1,25 +1,12 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* Message semantics retained independently from presentation.
|
|
2
2
|
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
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 {
|
|
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
|
-
|
|
65
|
-
|
|
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
|
-
|
|
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;"> </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
|
-
/*
|
|
1
|
+
/* Email-specific reading tokens.
|
|
2
2
|
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
/*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
/*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
/*
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
export const RADIUS = Object.freeze({ sm: "
|
|
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`
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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-
|
|
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
|
|
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
|
|
31
|
-
*
|
|
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
|
|
105
|
+
subject: "Verify your email address",
|
|
107
106
|
code: "__TLDR_CODE__",
|
|
108
|
-
body: `
|
|
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: "
|
|
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
|
-
"
|
|
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 =
|
|
208
|
+
const body = `tldr; is ready on this Mac.
|
|
198
209
|
|
|
199
|
-
|
|
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
|
-
##
|
|
212
|
+
## Try tldr;
|
|
203
213
|
|
|
204
214
|
${scenarios.map((scenario) => `- “${oneLine(scenario)}”`).join("\n")}
|
|
205
215
|
|
|
206
|
-
You
|
|
207
|
-
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:
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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:
|
|
222
|
-
|
|
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 =
|
|
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;"> </td>`
|
|
51
|
-
: `<td height="${CELL}" width="${CELL}" style="font-size:0;line-height:${CELL}px;padding:0;"> </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
|
-
});
|