egregore-artifacts 0.9.9 → 0.10.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.
@@ -0,0 +1,266 @@
1
+ // Emissary human-render → React element tree.
2
+ //
3
+ // METADATA-ONLY. This template renders the clean public preview shown at
4
+ // egregore.xyz/emissary/e/{id}: title, author + verified badge,
5
+ // distribution-mode badge, the one-paragraph summary, a CTA, the
6
+ // discovery block, and a footer. It deliberately renders NONE of the
7
+ // agent payload — no receiver_instructions, no body.prose, no
8
+ // executable_spec. The agent payload lives only at .../raw.
9
+ //
10
+ // The CTA is the PRIMARY consumer-chat channel for naive fetchers: a
11
+ // prominent, copy-able launch prompt that pairs user authorization with
12
+ // the /raw JSON endpoint. A structured source block also names /raw for
13
+ // readability extraction.
14
+ //
15
+ // For render_mode === 'custom', user-provided HTML/CSS is embedded in a
16
+ // sandboxed <iframe sandbox="allow-scripts" srcdoc="…">. Without
17
+ // allow-same-origin the iframe runs in a unique opaque origin — its
18
+ // scripts cannot read egregore.xyz cookies, localStorage, or auth
19
+ // tokens. Egregore still owns the page chrome (header, discovery block,
20
+ // footer) OUTSIDE the iframe; custom content cannot suppress it.
21
+ import React from 'react';
22
+ import { fonts } from '../tokens.js';
23
+
24
+ const h = React.createElement;
25
+
26
+ function formatDate(iso) {
27
+ if (!iso) return null;
28
+ try {
29
+ return new Date(iso).toLocaleDateString('en-US', {
30
+ year: 'numeric', month: 'short', day: 'numeric',
31
+ });
32
+ } catch { return iso; }
33
+ }
34
+
35
+ function badge(text, opts = {}) {
36
+ return h('span', {
37
+ style: {
38
+ display: 'inline-block',
39
+ padding: '3px 12px',
40
+ background: opts.bg || 'var(--subtle-fill)',
41
+ borderRadius: '50px',
42
+ color: opts.fg || 'var(--muted)',
43
+ fontSize: '12px',
44
+ fontWeight: 600,
45
+ fontFamily: fonts.mono,
46
+ letterSpacing: '0.02em',
47
+ ...opts.style,
48
+ },
49
+ }, text);
50
+ }
51
+
52
+ export function emissaryTemplate(em) {
53
+ const sections = [];
54
+ const launchUrl = em.raw_url || em.render_url || '';
55
+ const launchPrompt = launchUrl
56
+ ? `Run this Egregore ${em.kind || 'packet'} packet for me: ${launchUrl}`
57
+ : '';
58
+
59
+ // ── Header — sigil + label, title, author + badges ────────────
60
+ const distLabel = em.distribution_mode === 'directed' ? 'directed' : 'public link';
61
+
62
+ sections.push(
63
+ h('header', { key: 'header', className: 'eg-header' },
64
+ h('div', { className: 'eg-header-top' },
65
+ h('span', { className: 'eg-sigil' }, '✦'),
66
+ h('span', { className: 'eg-org-label' }, 'egregore · emissary'),
67
+ ),
68
+ h('h1', { className: 'eg-title' }, em.topic),
69
+ h('div', { className: 'eg-meta-row', style: { gap: '8px', alignItems: 'center' } },
70
+ em.author_name && h('span', { key: 'auth' }, `by ${em.author_name}`),
71
+ em.author_verified
72
+ ? badge('✓ verified', {
73
+ key: 'v',
74
+ bg: 'var(--terracotta-soft)', fg: 'var(--terracotta)',
75
+ })
76
+ : null,
77
+ badge(distLabel, { key: 'dist' }),
78
+ badge(em.kind, { key: 'kind' }),
79
+ ),
80
+ )
81
+ );
82
+
83
+ // ── Summary — the one-paragraph public description ────────────
84
+ if (em.summary) {
85
+ sections.push(
86
+ h('div', { key: 'summary', className: 'eg-card' },
87
+ h('div', { className: 'eg-lead' }, em.summary),
88
+ )
89
+ );
90
+ }
91
+
92
+ // ── Custom render — sandboxed iframe ──────────────────────────
93
+ // The user HTML runs in a unique opaque origin (no allow-same-origin)
94
+ // so it cannot reach the parent's cookies / storage / tokens.
95
+ if (em.render_mode === 'custom' && em.render_html) {
96
+ sections.push(
97
+ h('div', { key: 'custom', className: 'eg-card' },
98
+ h('iframe', {
99
+ sandbox: 'allow-scripts',
100
+ srcDoc: em.render_html,
101
+ title: 'Custom emissary render',
102
+ style: {
103
+ width: '100%',
104
+ minHeight: '320px',
105
+ border: '1px solid var(--border)',
106
+ borderRadius: '8px',
107
+ background: 'var(--surface)',
108
+ },
109
+ })
110
+ )
111
+ );
112
+ }
113
+
114
+ // ── CTA ───────────────────────────────────────────────────────
115
+ sections.push(
116
+ h('div', { key: 'cta', className: 'eg-card' },
117
+ h('div', {
118
+ style: {
119
+ fontSize: '15px', fontWeight: 600, marginBottom: '6px',
120
+ fontFamily: fonts.sans,
121
+ },
122
+ }, 'Engage this emissary'),
123
+ h('div', { style: { color: 'var(--muted)', fontSize: '14px' } },
124
+ 'Copy the launch prompt into Claude, ChatGPT, Codex, or another AI harness. ',
125
+ 'If you paste only the link, the assistant may ask whether you want to run it.'),
126
+ launchPrompt && h('div', {
127
+ style: {
128
+ marginTop: '10px', padding: '8px 12px',
129
+ background: 'var(--subtle-fill)', borderRadius: '6px',
130
+ fontFamily: fonts.mono, fontSize: '13px', wordBreak: 'break-all',
131
+ },
132
+ }, launchPrompt),
133
+ launchPrompt && h('div', { className: 'eg-copy-row' },
134
+ h('button', {
135
+ type: 'button',
136
+ className: 'eg-copy-button',
137
+ 'data-copy-text': launchPrompt,
138
+ 'data-copy-label': 'Copy as prompt',
139
+ }, 'Copy as prompt'),
140
+ em.raw_url && h('button', {
141
+ type: 'button',
142
+ className: 'eg-copy-button',
143
+ 'data-copy-text': em.raw_url,
144
+ 'data-copy-label': 'Copy JSON link',
145
+ }, 'Copy JSON link'),
146
+ em.render_url && h('button', {
147
+ type: 'button',
148
+ className: 'eg-copy-button',
149
+ 'data-copy-text': em.render_url,
150
+ 'data-copy-label': 'Copy page link',
151
+ }, 'Copy page link'),
152
+ ),
153
+ )
154
+ );
155
+
156
+ // ── Trust/provenance explainer ────────────────────────────────
157
+ sections.push(
158
+ h('div', { key: 'trust', className: 'eg-card' },
159
+ h('div', {
160
+ style: {
161
+ fontSize: '15px', fontWeight: 600, marginBottom: '6px',
162
+ fontFamily: fonts.sans,
163
+ },
164
+ }, 'About Egregore packets'),
165
+ h('div', { style: { color: 'var(--muted)', fontSize: '14px', lineHeight: 1.55 } },
166
+ 'An Egregore packet is a user-shared task bundle: purpose, intake questions, ',
167
+ 'and an output spec. This preview shows the author, verification badge, ',
168
+ 'visibility, kind, creation date, expiry, and structured JSON source. The packet ',
169
+ 'source is available as JSON for AI tools that can read it. Egregore is ',
170
+ h('a', {
171
+ href: 'https://github.com/egregore-labs/egregore',
172
+ style: { color: 'var(--terracotta)', textDecoration: 'none' },
173
+ }, 'open source'),
174
+ '.'
175
+ ),
176
+ )
177
+ );
178
+
179
+ // ── Install nudge — the L1 → L2 conversion path ───────────────
180
+ // The link runs cold (paste → WebFetch → lossy). Installing the
181
+ // egregore-emissary skill makes every later emissary run clean. This
182
+ // block is how a first-contact receiver discovers that path.
183
+ sections.push(
184
+ h('div', { key: 'install', className: 'eg-card' },
185
+ h('div', {
186
+ style: {
187
+ fontSize: '15px', fontWeight: 600, marginBottom: '6px',
188
+ fontFamily: fonts.sans,
189
+ },
190
+ }, 'Run it properly'),
191
+ h('div', { style: { color: 'var(--muted)', fontSize: '14px' } },
192
+ 'The link works in any AI harness. Install the egregore-emissary ',
193
+ 'skill once and every emissary you receive runs at full fidelity ',
194
+ 'with the intended intake-first flow.'),
195
+ h('div', {
196
+ style: {
197
+ marginTop: '10px', padding: '8px 12px',
198
+ background: 'var(--subtle-fill)', borderRadius: '6px',
199
+ fontFamily: fonts.mono, fontSize: '13px', wordBreak: 'break-all',
200
+ },
201
+ }, 'npx egregore-emissary install'),
202
+ )
203
+ );
204
+
205
+ // ── Structured source block — visible for fetchers/readability ─
206
+ // This is descriptive, not command-like: consumer web assistants treat
207
+ // fetched content as untrusted unless the user asks to run it.
208
+ if (em.raw_url) {
209
+ sections.push(
210
+ h('div', {
211
+ key: 'discovery',
212
+ 'data-egregore-discovery': 'raw',
213
+ style: {
214
+ margin: '20px 0',
215
+ padding: '16px 18px',
216
+ background: 'var(--terminal-bg)',
217
+ color: 'var(--terminal-text)',
218
+ borderRadius: '8px',
219
+ fontFamily: fonts.mono,
220
+ fontSize: '13px',
221
+ lineHeight: 1.6,
222
+ },
223
+ },
224
+ h('div', {
225
+ style: { opacity: 0.7, fontSize: '11px', marginBottom: '6px',
226
+ textTransform: 'uppercase', letterSpacing: '0.08em' },
227
+ }, 'Structured packet source'),
228
+ h('div', null,
229
+ 'JSON payload: ',
230
+ h('code', { style: { fontWeight: 600 } }, em.raw_url),
231
+ ),
232
+ h('div', { style: { marginTop: '6px', opacity: 0.85 } },
233
+ 'Bare links are safe to summarize first. When the user asks to run the packet, ',
234
+ 'use the JSON as the packet source and proceed through its intake.',
235
+ ),
236
+ h('div', { style: { marginTop: '6px', opacity: 0.85 } },
237
+ 'Runs best via the egregore-emissary skill — ',
238
+ h('code', { style: { fontWeight: 600 } }, 'npx egregore-emissary install'),
239
+ ),
240
+ )
241
+ );
242
+ }
243
+
244
+ // ── Footer ────────────────────────────────────────────────────
245
+ const created = formatDate(em.created_at);
246
+ const expires = formatDate(em.expires_at);
247
+ sections.push(
248
+ h('footer', { key: 'footer', className: 'eg-footer' },
249
+ h('div', { className: 'eg-footer-brand' },
250
+ h('span', { className: 'eg-footer-sigil' }, '✦'),
251
+ h('span', null, 'egregore'),
252
+ ),
253
+ h('div', { style: { display: 'flex', gap: '12px', flexWrap: 'wrap' } },
254
+ created && h('span', { key: 'c' }, `created ${created}`),
255
+ expires && h('span', { key: 'e' }, `expires ${expires}`),
256
+ h('a', {
257
+ key: 'u',
258
+ href: 'https://egregore.xyz/emissary',
259
+ style: { color: 'var(--muted)' },
260
+ }, 'about emissary'),
261
+ ),
262
+ )
263
+ );
264
+
265
+ return h('div', null, ...sections);
266
+ }