@migma/mcp 1.11.9 → 1.11.10
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/README.md +14 -0
- package/build/index.d.ts +7 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +14 -7
- package/build/index.js.map +1 -1
- package/build/tools/__tests__/email-card.test.d.ts +2 -0
- package/build/tools/__tests__/email-card.test.d.ts.map +1 -0
- package/build/tools/__tests__/email-card.test.js +179 -0
- package/build/tools/__tests__/email-card.test.js.map +1 -0
- package/build/tools/__tests__/send-approval.test.js +12 -4
- package/build/tools/__tests__/send-approval.test.js.map +1 -1
- package/build/tools/email-card.d.ts +14 -0
- package/build/tools/email-card.d.ts.map +1 -0
- package/build/tools/email-card.js +717 -0
- package/build/tools/email-card.js.map +1 -0
- package/build/tools/email-images.d.ts +2 -2
- package/build/tools/email-images.d.ts.map +1 -1
- package/build/tools/email-images.js +25 -10
- package/build/tools/email-images.js.map +1 -1
- package/build/tools/generate.d.ts +2 -2
- package/build/tools/generate.d.ts.map +1 -1
- package/build/tools/generate.js +24 -9
- package/build/tools/generate.js.map +1 -1
- package/build/tools/mcp-apps.d.ts +15 -0
- package/build/tools/mcp-apps.d.ts.map +1 -0
- package/build/tools/mcp-apps.js +21 -0
- package/build/tools/mcp-apps.js.map +1 -0
- package/build/tools/send-approval-card.d.ts.map +1 -1
- package/build/tools/send-approval-card.js +8 -8
- package/build/tools/send-approval-card.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -92,6 +92,20 @@ Claude Code, get the same text result as before. `createOpenAIMcpServer` leaves
|
|
|
92
92
|
card off, so the surface ChatGPT reviewed does not change; pass `mcpApps: true`
|
|
93
93
|
to keep that tool set and add the card, as the hosted server does for Claude.
|
|
94
94
|
|
|
95
|
+
The same hosts show an email card (`ui://migma/email`) on `migma_generate_email`,
|
|
96
|
+
`migma_get_generation_status`, `migma_edit_email` and `migma_get_email`: the steps
|
|
97
|
+
while Migma designs or changes an email, then each email as its picture at real width,
|
|
98
|
+
a series as tabs, full screen where the host has it, "Edit in Migma", and two asks
|
|
99
|
+
sent to the chat ("Make it shorter", "Try another version") with their credit cost.
|
|
100
|
+
A status check shows one line, or a Ready row that opens in place. The card only reads
|
|
101
|
+
`migma_get_generation_status`, `migma_get_email_edit_status` and `migma_get_email`.
|
|
102
|
+
The same `mcpApps` option turns it on or off. When the client draws the card, email
|
|
103
|
+
results stop asking the assistant to paste previews or check progress in a loop: the
|
|
104
|
+
card already shows them. That holds when the client advertises the
|
|
105
|
+
`io.modelcontextprotocol/ui` extension, or when the host passes `mcpApps: true`, which
|
|
106
|
+
it should do only for clients that draw MCP Apps (Claude's apps, not Claude Code). Every
|
|
107
|
+
other client gets today's text, Previews list included.
|
|
108
|
+
|
|
95
109
|
`migma_send_email` sends marketing mail unless `transactional: true` is set for
|
|
96
110
|
a single recipient whose From root domain has a verified transactional identity
|
|
97
111
|
(`notify.<root>`, see `migma_provision_stream`). Tag and segment sends are always
|
package/build/index.d.ts
CHANGED
|
@@ -11,9 +11,13 @@ export type CreateMigmaMcpServerOptions = {
|
|
|
11
11
|
version?: string;
|
|
12
12
|
profile?: MigmaMcpProfile;
|
|
13
13
|
/**
|
|
14
|
-
* MCP Apps views on the tools that have one
|
|
15
|
-
* migma.ai)
|
|
16
|
-
*
|
|
14
|
+
* MCP Apps views on the tools that have one: the send approval card (approval stays on
|
|
15
|
+
* migma.ai) and the email card on generate, generation status, edit and get email. On by
|
|
16
|
+
* default for the general profile, off for the openai profile so the surface ChatGPT
|
|
17
|
+
* reviewed does not change. Pass true only for a client that draws the views (Claude's apps,
|
|
18
|
+
* not Claude Code): email results then leave the pictures to the card instead of asking for
|
|
19
|
+
* pasted previews and progress loops. Left unset, that follows the client's own
|
|
20
|
+
* `io.modelcontextprotocol/ui` capability. A host that keeps the openai tool set but shows the views (Claude) passes true.
|
|
17
21
|
*/
|
|
18
22
|
mcpApps?: boolean;
|
|
19
23
|
};
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AA4BrD,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,KAAK,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAgBF,eAAO,MAAM,yBAAyB,QAA6B,CAAC;AAqBpE,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,2BAAgC,GAAG,SAAS,CA+CzF;AAED,oFAAoF;AACpF,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,IAAI,CAAC,2BAA2B,EAAE,SAAS,CAAM,GAAG,SAAS,CAE3G;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAEzD;AAGD,wBAAgB,mBAAmB,cAOlC"}
|
package/build/index.js
CHANGED
|
@@ -27,14 +27,19 @@ import { registerCampaignTools } from "./tools/campaigns.js";
|
|
|
27
27
|
import { registerMetricsTools } from "./tools/metrics.js";
|
|
28
28
|
import { applyToolReviewMetadata, registerCapabilitiesTool, } from "./tools/capabilities.js";
|
|
29
29
|
import { registerMigmaPrompts } from "./prompts/index.js";
|
|
30
|
-
|
|
30
|
+
import { clientDrawsCards } from "./tools/mcp-apps.js";
|
|
31
|
+
const PREVIEWS_RULE = "Show every Previews image and editor link before editing or validating.";
|
|
32
|
+
// For a client that draws the email card, which already shows each picture and editor link.
|
|
33
|
+
const CARD_RULE = "The email card shows each email's picture and editor link in the chat: do not paste them or check progress in a loop.";
|
|
34
|
+
const commonInstructions = (cardsShown) => [
|
|
31
35
|
"After connecting, read the migma_get_context setup block. Reuse the known brand and reference; unknown is not missing. Setup must not block drafts.",
|
|
32
36
|
"Use one write channel; after browser edits call migma_list_emails. One migma_generate_email call makes a whole series: pass count and supplied images through the structured images argument.",
|
|
33
|
-
|
|
37
|
+
`${cardsShown ? CARD_RULE : PREVIEWS_RULE} Edit requested existing emails instead of making copies.`,
|
|
34
38
|
"Save lasting rules with migma_update_brand_guidelines and liked styles with migma_save_reference when asked. Never invent prices, offers or product claims.",
|
|
35
39
|
"The user approves every send in Migma: send and schedule tools return a summary (audience, count, sender, subject, timing) and an approval link to migma.ai. Show both with the preview, then check the outcome with migma_get_send_approval. Resolve date/timezone before scheduling. Say sent or scheduled only after it reports so.",
|
|
36
40
|
].join(" ");
|
|
37
|
-
|
|
41
|
+
const generalInstructions = (cardsShown) => `${commonInstructions(cardsShown)} Checkout links are for the user to open. Offer available billing only when asked or credits block the task; get consent and chosen plan first. Existing subscribers use billing portal. A link is not proof of payment.`;
|
|
42
|
+
export const MIGMA_SERVER_INSTRUCTIONS = generalInstructions(false);
|
|
38
43
|
function completeConfig(config) {
|
|
39
44
|
return {
|
|
40
45
|
apiKey: config?.apiKey ?? "",
|
|
@@ -56,14 +61,16 @@ export function createMigmaMcpServer(options = {}) {
|
|
|
56
61
|
const lazyClient = options.client || createLazyClient(config, options.getClient);
|
|
57
62
|
const { permissions, profile = "general" } = options;
|
|
58
63
|
const card = options.mcpApps ?? profile !== "openai";
|
|
64
|
+
// Whether this client draws the cards: the host vouches for it (mcpApps: true, as the stateless
|
|
65
|
+
// hosted server does for Claude), or the client said so when it connected.
|
|
66
|
+
const vouched = options.mcpApps === true;
|
|
67
|
+
const cardsShown = () => card && (vouched || clientDrawsCards(server));
|
|
59
68
|
const { version } = createRequire(import.meta.url)("../package.json");
|
|
60
69
|
const server = new McpServer({
|
|
61
70
|
name: "migma",
|
|
62
71
|
version: options.version || version,
|
|
63
72
|
}, {
|
|
64
|
-
instructions: profile === "openai"
|
|
65
|
-
? COMMON_SERVER_INSTRUCTIONS
|
|
66
|
-
: MIGMA_SERVER_INSTRUCTIONS,
|
|
73
|
+
instructions: profile === "openai" ? commonInstructions(vouched) : generalInstructions(vouched),
|
|
67
74
|
maxToolInputElements: MAX_TOOL_INPUT_ELEMENTS,
|
|
68
75
|
});
|
|
69
76
|
applyToolReviewMetadata(server);
|
|
@@ -71,7 +78,7 @@ export function createMigmaMcpServer(options = {}) {
|
|
|
71
78
|
registerContextTools(server, lazyClient, permissions, config.projectId, profile);
|
|
72
79
|
registerKnowledgeBaseTools(server, lazyClient, config, permissions);
|
|
73
80
|
registerBrandTools(server, lazyClient, config, permissions);
|
|
74
|
-
registerGenerateTools(server, lazyClient, config, permissions);
|
|
81
|
+
registerGenerateTools(server, lazyClient, config, permissions, card, cardsShown);
|
|
75
82
|
registerImportHtmlTools(server, lazyClient, config, permissions);
|
|
76
83
|
registerSendTools(server, lazyClient, config, permissions, card);
|
|
77
84
|
registerSendApprovalTools(server, config, permissions, card);
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":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e,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAC5B,MAAM,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IAEvC,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;AACrD,CAAC;AAED,SAAS,eAAe;IACtB,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC9B,OAAO,CAAC,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,aAAa,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;AAClE,CAAC;AAED,IAAI,eAAe,EAAE,EAAE,CAAC;IACtB,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACrB,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,KAAK,CAAC,CAAC;QAC1D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-card.test.d.ts","sourceRoot":"","sources":["../../../src/tools/__tests__/email-card.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { execFileSync } from "node:child_process";
|
|
4
|
+
import { mkdtempSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
8
|
+
import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
|
|
9
|
+
import { createMigmaMcpServer, createOpenAIMcpServer } from "../../index.js";
|
|
10
|
+
import { EMAIL_CARD_HTML, EMAIL_CARD_URI } from "../email-card.js";
|
|
11
|
+
import { IMAGE_ORIGINS } from "../mcp-apps.js";
|
|
12
|
+
const EMAIL_TOOLS = ["migma_generate_email", "migma_get_generation_status", "migma_edit_email", "migma_get_email"];
|
|
13
|
+
const CARD_READS = ["migma_get_email", "migma_get_email_edit_status", "migma_get_generation_status"];
|
|
14
|
+
async function listed(createServer, options = {}) {
|
|
15
|
+
const server = createServer({ client: {}, config: { apiKey: "sk_test" }, ...options });
|
|
16
|
+
const client = new Client({ name: "card-test", version: "1" });
|
|
17
|
+
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
|
18
|
+
await server.connect(serverTransport);
|
|
19
|
+
await client.connect(clientTransport);
|
|
20
|
+
try {
|
|
21
|
+
const { tools } = await client.listTools();
|
|
22
|
+
const { resources } = client.getServerCapabilities()?.resources ? await client.listResources() : { resources: [] };
|
|
23
|
+
const read = resources.some((r) => r.uri === EMAIL_CARD_URI) ? await client.readResource({ uri: EMAIL_CARD_URI }) : undefined;
|
|
24
|
+
return { tools, resources, read };
|
|
25
|
+
}
|
|
26
|
+
finally {
|
|
27
|
+
await client.close();
|
|
28
|
+
await server.close();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const uiOf = (tool) => tool?._meta?.ui?.resourceUri;
|
|
32
|
+
test("the four email tools open the email card; polls the card makes itself do not", async () => {
|
|
33
|
+
const { tools, read } = await listed(createMigmaMcpServer);
|
|
34
|
+
for (const name of EMAIL_TOOLS)
|
|
35
|
+
assert.equal(uiOf(tools.find((t) => t.name === name)), EMAIL_CARD_URI, name);
|
|
36
|
+
for (const name of ["migma_get_email_edit_status", "migma_list_emails", "migma_import_html"]) {
|
|
37
|
+
assert.equal(uiOf(tools.find((t) => t.name === name)), undefined, name);
|
|
38
|
+
}
|
|
39
|
+
const content = read.contents[0];
|
|
40
|
+
assert.equal(content.mimeType, "text/html;profile=mcp-app");
|
|
41
|
+
assert.deepEqual(content._meta.ui.csp.resourceDomains, IMAGE_ORIGINS);
|
|
42
|
+
assert.equal(content._meta.ui.prefersBorder, true);
|
|
43
|
+
});
|
|
44
|
+
test("the card only reads, and talks to nothing but the host", async () => {
|
|
45
|
+
const { tools } = await listed(createMigmaMcpServer);
|
|
46
|
+
const named = new Set([...EMAIL_CARD_HTML.matchAll(/"(migma_[a-z_]+)"/g)].map((m) => m[1]));
|
|
47
|
+
assert.deepEqual([...named].sort(), CARD_READS);
|
|
48
|
+
for (const name of named)
|
|
49
|
+
assert.equal(tools.find((t) => t.name === name)?.annotations?.readOnlyHint, true, `${name} is read-only`);
|
|
50
|
+
const requests = new Set([...EMAIL_CARD_HTML.matchAll(/request\("([a-z/-]+)"/g)].map((m) => m[1]));
|
|
51
|
+
assert.deepEqual([...requests].sort(), ["tools/call", "ui/initialize", "ui/message", "ui/open-link", "ui/request-display-mode"]);
|
|
52
|
+
assert.doesNotMatch(EMAIL_CARD_HTML, /fetch\(|XMLHttpRequest|sendBeacon|WebSocket|EventSource|import\(|<link /, "no network outside the host");
|
|
53
|
+
});
|
|
54
|
+
test("the card script is valid JavaScript", () => {
|
|
55
|
+
const script = EMAIL_CARD_HTML.match(/<script type="module">([\s\S]*)<\/script>/)?.[1];
|
|
56
|
+
assert.ok(script);
|
|
57
|
+
const file = join(mkdtempSync(join(tmpdir(), "email-card-")), "card.mjs");
|
|
58
|
+
writeFileSync(file, script);
|
|
59
|
+
execFileSync(process.execPath, ["--check", file]);
|
|
60
|
+
});
|
|
61
|
+
function tools(client, mcpApps) {
|
|
62
|
+
const server = createMigmaMcpServer({ client: client, config: { apiKey: "sk_test", projectId: "brand-1" }, mcpApps });
|
|
63
|
+
return server._registeredTools;
|
|
64
|
+
}
|
|
65
|
+
// No picture URLs, so no result fetches an image.
|
|
66
|
+
const email = { id: "e1", emailId: "e1", conversationId: "c1", slotIdx: 0, subject: "Out of office.", preheader: "Two days on the beach", status: "ready", html: "<p>x</p>", screenshotUrl: null, thumbnailUrl: null };
|
|
67
|
+
const client = {
|
|
68
|
+
emails: {
|
|
69
|
+
generate: async () => ({ data: { conversationId: "c1", status: "pending", message: "Started", link: "https://migma.ai/chat?c=c1" } }),
|
|
70
|
+
getGenerationStatus: async () => ({ data: { conversationId: "c1", status: "completed", createdAt: "2031-01-01T00:00:00Z", updatedAt: "2031-01-01T00:02:00Z", result: { subject: "Out of office.", emails: [email] } } }),
|
|
71
|
+
get: async () => ({ data: email }),
|
|
72
|
+
startEdit: async () => ({ data: { editId: "ed1", emailId: "e1", conversationId: "c1", status: "pending", stage: "queued", pollAfterMs: 2000 } }),
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
const CALLS = [
|
|
76
|
+
["migma_generate_email", { prompt: "A beach party", idempotency_key: "k1" }],
|
|
77
|
+
["migma_get_generation_status", { conversationId: "c1" }],
|
|
78
|
+
["migma_get_email", { emailId: "e1" }],
|
|
79
|
+
["migma_edit_email", { emailId: "e1", prompt: "Make it shorter", idempotency_key: "k2" }],
|
|
80
|
+
];
|
|
81
|
+
const textsOf = (r) => r.content.filter((c) => c.type === "text").map((c) => c.text ?? "");
|
|
82
|
+
test("results stay the same unless the client draws the card", async () => {
|
|
83
|
+
const shown = tools(client, true);
|
|
84
|
+
const unset = createMigmaMcpServer({ client: client, config: { apiKey: "sk_test", projectId: "brand-1" } });
|
|
85
|
+
const defaults = unset._registeredTools;
|
|
86
|
+
const off = tools(client, false);
|
|
87
|
+
for (const [name, args] of CALLS) {
|
|
88
|
+
// The general profile has card meta by default, but a client that never said it draws cards (Claude Code) reads today's text.
|
|
89
|
+
const before = await off[name].handler(off[name].inputSchema.parse(args), {});
|
|
90
|
+
assert.deepEqual(await defaults[name].handler(defaults[name].inputSchema.parse(args), {}), before, name);
|
|
91
|
+
const withCard = await shown[name].handler(shown[name].inputSchema.parse(args), {});
|
|
92
|
+
assert.equal(withCard.structuredContent, undefined, name);
|
|
93
|
+
const jsonOf = (r) => textsOf(r).map((t) => { try {
|
|
94
|
+
return JSON.parse(t);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return null;
|
|
98
|
+
} }).find(Boolean);
|
|
99
|
+
const { nextStep: _a, ...data } = jsonOf(withCard) ?? {};
|
|
100
|
+
const { nextStep: _b, ...was } = jsonOf(before) ?? {};
|
|
101
|
+
assert.deepEqual(data, was, `${name}: same data`);
|
|
102
|
+
}
|
|
103
|
+
const started = await off.migma_generate_email.handler({ prompt: "A beach party" }, {});
|
|
104
|
+
assert.equal(textsOf(started)[0], "Generation started. migma_get_generation_status reports progress, then returns each email's preview image and editor link.");
|
|
105
|
+
});
|
|
106
|
+
test("when the card is drawn, results leave pictures and progress to it", async () => {
|
|
107
|
+
const shown = tools(client, true);
|
|
108
|
+
const started = textsOf(await shown.migma_generate_email.handler({ prompt: "A beach party" }, {}));
|
|
109
|
+
assert.match(started[0], /email card in the chat shows the user each step/);
|
|
110
|
+
assert.match(started[0], /do not check progress in a loop or paste previews/);
|
|
111
|
+
const status = textsOf(await shown.migma_get_generation_status.handler({ conversationId: "c1" }, {}));
|
|
112
|
+
assert.ok(!status.some((t) => t.startsWith("Previews:")));
|
|
113
|
+
assert.match(JSON.parse(status.find((t) => t.startsWith("{"))).nextStep, /^The user sees the emails in the card\. Next, offer a test/);
|
|
114
|
+
const edit = JSON.parse(textsOf(await shown.migma_edit_email.handler({ emailId: "e1", prompt: "Shorter", idempotency_key: "k" }, {}))[0]);
|
|
115
|
+
assert.match(edit.nextStep, /email card shows the user the change/);
|
|
116
|
+
for (const text of [...started, ...status, edit.nextStep])
|
|
117
|
+
assert.doesNotMatch(text, /\u2014/, "no em dashes");
|
|
118
|
+
});
|
|
119
|
+
const UI = { extensions: { "io.modelcontextprotocol/ui": { mimeTypes: ["text/html;profile=mcp-app"] } } };
|
|
120
|
+
const PNG = Buffer.from("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==", "base64");
|
|
121
|
+
async function callAs(capabilities, name, args) {
|
|
122
|
+
const pictured = { ...client, emails: { ...client.emails, get: async () => ({ data: { ...email, screenshotUrl: "https://cdn.migma.ai/s/e1.png" } }) } };
|
|
123
|
+
const server = createMigmaMcpServer({ client: pictured, config: { apiKey: "sk_test", projectId: "brand-1" } });
|
|
124
|
+
const mcp = new Client({ name: "host", version: "1" }, { capabilities });
|
|
125
|
+
const [a, b] = InMemoryTransport.createLinkedPair();
|
|
126
|
+
const original = globalThis.fetch;
|
|
127
|
+
globalThis.fetch = (async () => new Response(PNG, { headers: { "content-type": "image/png" } }));
|
|
128
|
+
try {
|
|
129
|
+
await server.connect(b);
|
|
130
|
+
await mcp.connect(a);
|
|
131
|
+
return { result: await mcp.callTool({ name, arguments: args }), instructions: mcp.getInstructions() };
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
globalThis.fetch = original;
|
|
135
|
+
await mcp.close();
|
|
136
|
+
await server.close();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
test("a client that says it draws MCP Apps gets the card wording; one that does not keeps the Previews list", async () => {
|
|
140
|
+
const drawn = textsOf((await callAs(UI, "migma_get_email", { emailId: "e1" })).result);
|
|
141
|
+
assert.match(drawn[0], /attached for you to check\. The email card shows the user each email/);
|
|
142
|
+
assert.ok(!drawn.some((t) => t.startsWith("Previews:")));
|
|
143
|
+
assert.equal((await callAs(UI, "migma_get_email", { emailId: "e1" })).result.content.some((c) => c.type === "image"), true, "the picture still reaches the model");
|
|
144
|
+
const plain = textsOf((await callAs({}, "migma_get_email", { emailId: "e1" })).result);
|
|
145
|
+
assert.ok(plain.at(-1).startsWith("Previews:"));
|
|
146
|
+
});
|
|
147
|
+
test("server instructions name the card only where Migma vouches the client draws it", async () => {
|
|
148
|
+
const listedInstructions = async (create, options = {}) => {
|
|
149
|
+
const server = create({ client: {}, config: { apiKey: "sk_test" }, ...options });
|
|
150
|
+
const mcp = new Client({ name: "host", version: "1" });
|
|
151
|
+
const [a, b] = InMemoryTransport.createLinkedPair();
|
|
152
|
+
await server.connect(b);
|
|
153
|
+
await mcp.connect(a);
|
|
154
|
+
try {
|
|
155
|
+
return mcp.getInstructions() ?? "";
|
|
156
|
+
}
|
|
157
|
+
finally {
|
|
158
|
+
await mcp.close();
|
|
159
|
+
await server.close();
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
const claude = await listedInstructions(createOpenAIMcpServer, { mcpApps: true });
|
|
163
|
+
assert.match(claude, /email card shows each email's picture and editor link/);
|
|
164
|
+
assert.doesNotMatch(claude, /Show every Previews image/);
|
|
165
|
+
assert.match(await listedInstructions(createOpenAIMcpServer), /Show every Previews image/);
|
|
166
|
+
assert.match(await listedInstructions(createMigmaMcpServer), /Show every Previews image/);
|
|
167
|
+
});
|
|
168
|
+
test("no email card without email reads, nor on the reviewed ChatGPT surface", async () => {
|
|
169
|
+
const sendOnly = await listed(createMigmaMcpServer, { permissions: ["email:send"] });
|
|
170
|
+
assert.equal(sendOnly.resources.some((r) => r.uri === EMAIL_CARD_URI), false);
|
|
171
|
+
const reviewed = await listed(createOpenAIMcpServer);
|
|
172
|
+
assert.equal(reviewed.resources.length, 0);
|
|
173
|
+
for (const name of EMAIL_TOOLS)
|
|
174
|
+
assert.equal(uiOf(reviewed.tools.find((t) => t.name === name)), undefined, name);
|
|
175
|
+
const claude = await listed(createOpenAIMcpServer, { mcpApps: true });
|
|
176
|
+
for (const name of EMAIL_TOOLS)
|
|
177
|
+
assert.equal(uiOf(claude.tools.find((t) => t.name === name)), EMAIL_CARD_URI, name);
|
|
178
|
+
});
|
|
179
|
+
//# sourceMappingURL=email-card.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-card.test.js","sourceRoot":"","sources":["../../../src/tools/__tests__/email-card.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OA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client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
|
4
4
|
import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
|
|
5
5
|
import { createMigmaMcpServer, createOpenAIMcpServer } from "../../index.js";
|
|
6
6
|
import { SEND_APPROVAL_CARD_URI } from "../send-approval-card.js";
|
|
7
|
+
import { EMAIL_CARD_URI } from "../email-card.js";
|
|
7
8
|
function tools(permissions) {
|
|
8
9
|
const server = createMigmaMcpServer({
|
|
9
10
|
client: {},
|
|
@@ -89,6 +90,13 @@ async function listed(createServer, options = {}) {
|
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
92
|
const SEND_TOOLS = ["migma_send_email", "migma_send_campaign", "migma_schedule_campaign"];
|
|
93
|
+
const CARD_FOR = {
|
|
94
|
+
...Object.fromEntries(SEND_TOOLS.map((name) => [name, SEND_APPROVAL_CARD_URI])),
|
|
95
|
+
migma_generate_email: EMAIL_CARD_URI,
|
|
96
|
+
migma_get_generation_status: EMAIL_CARD_URI,
|
|
97
|
+
migma_edit_email: EMAIL_CARD_URI,
|
|
98
|
+
migma_get_email: EMAIL_CARD_URI,
|
|
99
|
+
};
|
|
92
100
|
test("send tools open the approval card; the card only reads status and opens the link", async () => {
|
|
93
101
|
const { tools, read } = await listed(createMigmaMcpServer);
|
|
94
102
|
for (const name of SEND_TOOLS) {
|
|
@@ -115,16 +123,16 @@ test("send tool text stays the same for hosts without MCP Apps", async () => {
|
|
|
115
123
|
test("the ChatGPT profile keeps its reviewed surface: no card", async () => {
|
|
116
124
|
const { tools, resources } = await listed(createOpenAIMcpServer);
|
|
117
125
|
assert.equal(resources.length, 0);
|
|
118
|
-
for (const name of
|
|
126
|
+
for (const name of Object.keys(CARD_FOR))
|
|
119
127
|
assert.equal(tools.find((t) => t.name === name)?._meta?.ui, undefined, name);
|
|
120
128
|
});
|
|
121
|
-
test("Claude keeps the reviewed tool set and adds only the
|
|
129
|
+
test("Claude keeps the reviewed tool set and adds only the cards", async () => {
|
|
122
130
|
const reviewed = await listed(createOpenAIMcpServer);
|
|
123
131
|
const claude = await listed(createOpenAIMcpServer, { mcpApps: true });
|
|
124
132
|
assert.deepEqual(claude.tools.map((t) => t.name), reviewed.tools.map((t) => t.name));
|
|
125
|
-
assert.deepEqual(claude.resources.map((r) => r.uri), [SEND_APPROVAL_CARD_URI]);
|
|
133
|
+
assert.deepEqual(claude.resources.map((r) => r.uri).sort(), [EMAIL_CARD_URI, SEND_APPROVAL_CARD_URI].sort());
|
|
126
134
|
for (const tool of claude.tools) {
|
|
127
|
-
const card =
|
|
135
|
+
const card = CARD_FOR[tool.name];
|
|
128
136
|
assert.equal(tool._meta?.ui?.resourceUri, card, tool.name);
|
|
129
137
|
const { _meta: _a, ...rest } = tool;
|
|
130
138
|
const { _meta: _b, ...before } = reviewed.tools.find((t) => t.name === tool.name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send-approval.test.js","sourceRoot":"","sources":["../../../src/tools/__tests__/send-approval.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"send-approval.test.js","sourceRoot":"","sources":["../../../src/tools/__tests__/send-approval.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,oBAAo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,CAAC,IAAI,CAAC,CAAC,CAAC;IACrF,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,EAAE,sBAAsB,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7G,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAChC,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,MAAM,CAAC,KAAK,CAAE,IAAI,CAAC,KAAuD,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9G,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;QACpC,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAE,CAAC;QACnF,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,mCAAmC,CAAC,CAAC;IAClF,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
/**
|
|
3
|
+
* MCP Apps card for the email tools (generate, generation status, edit, get): progress while
|
|
4
|
+
* Migma designs or changes an email, then each email as its picture at real width, a series
|
|
5
|
+
* as tabs, "Edit in Migma" through ui/open-link, a few asks sent to the chat through
|
|
6
|
+
* ui/message, and full screen where the host has it. It only reads: migma_get_generation_status,
|
|
7
|
+
* migma_get_email_edit_status and migma_get_email. Hosts without MCP Apps read the text result.
|
|
8
|
+
*/
|
|
9
|
+
export declare const EMAIL_CARD_URI = "ui://migma/email";
|
|
10
|
+
/** Tool `_meta` that links an email tool to the card, when the server shows it. */
|
|
11
|
+
export declare function emailCardMeta(card: boolean): Record<string, unknown> | undefined;
|
|
12
|
+
export declare function registerEmailCard(server: McpServer, card: boolean): void;
|
|
13
|
+
export declare const EMAIL_CARD_HTML = "<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"color-scheme\" content=\"light dark\">\n<title>Email</title>\n<style>\n :root {\n color-scheme: light dark;\n --surface: var(--color-background-primary, light-dark(#ffffff, #30302e));\n --muted: var(--color-background-secondary, light-dark(#f5f4ed, #262624));\n --muted-2: var(--color-background-tertiary, light-dark(#ebe9df, #3a3a37));\n --text: var(--color-text-primary, light-dark(#141413, #faf9f5));\n --text-2: var(--color-text-secondary, light-dark(#3d3d3a, #c2c0b6));\n --text-3: var(--color-text-tertiary, light-dark(#73726c, #9c9a92));\n --line: var(--color-border-tertiary, light-dark(rgb(31 30 29 / 15%), rgb(222 220 209 / 15%)));\n --line-2: var(--color-border-secondary, light-dark(rgb(31 30 29 / 30%), rgb(222 220 209 / 30%)));\n --inverse: var(--color-background-inverse, light-dark(#141413, #faf9f5));\n --on-inverse: var(--color-text-inverse, light-dark(#ffffff, #141413));\n --info: var(--color-border-info, light-dark(#4682d5, #6c9be0));\n --success: var(--color-border-success, light-dark(#437426, #7fb05b));\n --danger: var(--color-border-danger, light-dark(#a73d39, #d1615c));\n --danger-text: var(--color-text-danger, light-dark(#7f2c28, #ee8884));\n --warning-text: var(--color-text-warning, light-dark(#5a4815, #d1a041));\n --radius: var(--border-radius-lg, 10px);\n --radius-md: var(--border-radius-md, 8px);\n }\n * { box-sizing: border-box; }\n html, body { margin: 0; background: transparent; }\n body {\n font-family: var(--font-sans, system-ui, -apple-system, sans-serif);\n font-size: var(--font-text-sm-size, 14px);\n line-height: var(--font-text-sm-line-height, 1.4);\n color: var(--text);\n -webkit-font-smoothing: antialiased;\n }\n p, h1, ul { margin: 0; }\n button { font: inherit; cursor: pointer; }\n button:focus-visible, .stage:focus-visible { outline: 2px solid var(--color-ring-primary, var(--info)); outline-offset: 2px; }\n button[disabled] { cursor: default; opacity: .5; }\n main {\n container-type: inline-size;\n padding: calc(16px + var(--inset-top, 0px)) calc(16px + var(--inset-right, 0px)) calc(16px + var(--inset-bottom, 0px)) calc(16px + var(--inset-left, 0px));\n }\n .i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }\n .i.big { width: 24px; height: 24px; }\n\n .head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }\n .title { min-width: 0; }\n h1 { font-size: var(--font-heading-md-size, 16px); line-height: var(--font-heading-md-line-height, 1.4); font-weight: var(--font-weight-semibold, 600); overflow-wrap: anywhere; }\n .pre { color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n .icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text-2); }\n .icon-btn:hover { background: var(--muted); }\n\n .stage { position: relative; margin-top: 12px; height: var(--stage-h, 520px); border-radius: var(--radius); background: var(--muted); overflow: auto; overscroll-behavior: contain; display: flex; justify-content: center; align-items: flex-start; padding: 16px; scrollbar-width: thin; }\n .stage.short { height: 240px; overflow: hidden; }\n .shot { width: min(600px, 100%); flex: none; border-radius: 4px; overflow: hidden; box-shadow: 0 0 0 0.5px var(--line); background: var(--surface); }\n .shot img { display: block; width: 100%; height: auto; }\n .shot.dim { opacity: .45; }\n .skel { width: min(600px, 100%); height: 100%; min-height: 200px; flex: none; border-radius: 4px; background: var(--surface); box-shadow: 0 0 0 0.5px var(--line); padding: 28px; display: flex; flex-direction: column; gap: 14px; overflow: hidden; }\n .sk { background: var(--muted-2); border-radius: 6px; flex: none; }\n .stage-note { position: absolute; inset: 0; margin: auto; height: fit-content; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px; color: var(--text-2); text-align: center; max-width: 340px; }\n .pill { display: inline-flex; gap: 8px; align-items: center; padding: 6px 12px; border-radius: 999px; background: var(--surface); box-shadow: 0 0 0 0.5px var(--line); color: var(--text-2); }\n\n .tabs { display: flex; gap: 4px; margin-top: 12px; overflow-x: auto; scrollbar-width: none; }\n .tab { display: inline-flex; gap: 8px; align-items: center; height: 36px; max-width: 220px; flex: none; padding: 0 12px 0 8px; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--text-2); font-size: 13px; }\n .tab .n { display: grid; place-items: center; width: 20px; height: 20px; flex: none; border-radius: 50%; background: var(--muted); font-size: 12px; font-weight: 600; }\n .tab .t { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }\n .tab .d { color: var(--text-3); flex: none; }\n .tab[aria-selected=\"true\"] { background: var(--muted); color: var(--text); }\n .tab[aria-selected=\"true\"] .n { background: var(--inverse); color: var(--on-inverse); }\n\n .foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }\n .asks { display: flex; gap: 6px; flex-wrap: wrap; }\n .chip { display: inline-flex; gap: 6px; align-items: center; min-height: 32px; padding: 0 12px; border: 0.5px solid var(--line-2); border-radius: 999px; background: transparent; color: var(--text); font-size: 13px; font-weight: var(--font-weight-medium, 500); }\n .chip:hover { background: var(--muted); }\n .chip small { color: var(--text-3); font-size: 12px; font-weight: 400; }\n .primary, .ghost { display: inline-flex; gap: 6px; align-items: center; justify-content: center; min-height: 36px; padding: 0 14px; border-radius: var(--radius-md); white-space: nowrap; font-weight: var(--font-weight-semibold, 600); }\n .primary { border: 0; background: var(--inverse); color: var(--on-inverse); margin-left: auto; }\n .ghost { border: 0.5px solid var(--line-2); background: transparent; color: var(--text); font-weight: var(--font-weight-medium, 500); margin-left: auto; }\n .ghost:hover { background: var(--muted); }\n @container (max-width: 420px) { .foot .primary, .foot .ghost { width: 100%; } }\n\n .status { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; color: var(--text-2); font-weight: var(--font-weight-medium, 500); }\n .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--text-3); }\n .dot.info { background: var(--info); } .dot.ok { background: var(--success); } .dot.bad { background: var(--danger); }\n .time { margin-left: auto; color: var(--text-3); font-variant-numeric: tabular-nums; font-weight: 400; }\n .steps { list-style: none; padding: 0; margin-top: 12px; display: grid; gap: 6px; }\n .steps li { display: flex; gap: 8px; align-items: center; color: var(--text-3); min-width: 0; }\n .steps li span:nth-child(2) { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }\n .steps li.now { color: var(--text); }\n .mark { display: grid; place-items: center; width: 16px; height: 16px; flex: none; }\n .ring { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--line-2); }\n .now .ring { border-color: var(--info); background: var(--info); }\n .note { margin-top: 12px; color: var(--text-2); overflow-wrap: anywhere; }\n .note.bad { color: var(--danger-text); }\n .note.warn { margin-top: 4px; color: var(--warning-text); }\n .note.small { color: var(--text-3); font-size: 13px; }\n\n .slots { display: flex; gap: 12px; margin-top: 12px; overflow-x: auto; }\n .slot { flex: 1 0 72px; min-width: 0; max-width: 200px; display: flex; flex-direction: column; gap: 8px; }\n .slot .frame { aspect-ratio: 3 / 4; border-radius: var(--radius-md); background: var(--muted); display: grid; place-items: center; color: var(--text-3); }\n .slot.done .frame { color: var(--success); }\n .slot .lab { display: flex; flex-wrap: wrap; column-gap: 6px; color: var(--text-2); font-size: 13px; }\n .slot .lab span:last-child { color: var(--text-3); margin-left: auto; }\n\n .line { display: flex; gap: 8px; align-items: center; min-height: 28px; color: var(--text-2); min-width: 0; }\n .line .t { color: var(--text); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }\n .line .s { color: var(--text-3); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }\n .line .thumb { width: 40px; height: 40px; flex: none; border-radius: 6px; overflow: hidden; box-shadow: 0 0 0 0.5px var(--line); background: var(--muted); }\n .line .thumb img { display: block; width: 100%; }\n .line .ghost, .line .primary { min-height: 30px; padding: 0 10px; font-size: 13px; margin-left: 0; }\n .line .ghost:first-of-type { margin-left: auto; }\n @container (max-width: 420px) { .line { flex-wrap: wrap; } .line .ghost:first-of-type { margin-left: 48px; } }\n\n :root:has(.fs), :root:has(.fs) body { height: 100%; }\n main:has(.fs) { height: 100%; padding: 0; }\n .fs { height: 100%; display: flex; flex-direction: column; }\n .fs > .head { padding: calc(14px + var(--inset-top, 0px)) calc(20px + var(--inset-right, 0px)) 14px calc(20px + var(--inset-left, 0px)); border-bottom: 0.5px solid var(--line); }\n .fs-body { flex: 1; display: flex; min-height: 0; }\n .rail { width: 200px; flex: none; padding: 16px; display: flex; flex-direction: column; gap: 12px; border-right: 0.5px solid var(--line); overflow-y: auto; }\n .rail-item { display: flex; flex-direction: column; gap: 6px; padding: 6px; border-radius: var(--radius); border: 0; background: transparent; text-align: left; color: var(--text-2); font-size: 13px; }\n .rail-item .thumb { height: 140px; border-radius: 6px; overflow: hidden; box-shadow: 0 0 0 0.5px var(--line); background: var(--muted); display: grid; place-items: center; color: var(--text-3); }\n .rail-item .thumb img { display: block; width: 100%; align-self: start; }\n .rail-item[aria-current=\"true\"] { background: var(--muted); color: var(--text); }\n .fs .stage { flex: 1; height: auto; margin: 0; border-radius: 0; padding: 24px; }\n .fs .foot { margin: 0; padding: 12px calc(20px + var(--inset-right, 0px)) calc(12px + var(--inset-bottom, 0px)) calc(20px + var(--inset-left, 0px)); border-top: 0.5px solid var(--line); }\n .fs .note { margin: 0; padding: 0 20px 12px; }\n .step-btn { position: absolute; top: 50%; margin-top: -18px; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; border: 0.5px solid var(--line); background: var(--surface); color: var(--text); }\n .step-btn.prev { left: 16px; } .step-btn.next { right: 16px; }\n .fs-wrap { flex: 1; position: relative; display: flex; min-width: 0; }\n .fs .tabs { display: none; margin: 0; padding: 8px calc(20px + var(--inset-right, 0px)) 8px calc(20px + var(--inset-left, 0px)); border-bottom: 0.5px solid var(--line); }\n /* Narrow full screen (Claude's side panel): tabs replace the rail and the arrows over the email. */\n @container (max-width: 720px) { .rail, .step-btn { display: none; } .fs .tabs { display: flex; } }\n\n @media (prefers-reduced-motion: no-preference) {\n .sk, .now .ring { animation: pulse 1.4s ease-in-out infinite; }\n @keyframes pulse { 50% { opacity: .55; } }\n }\n</style>\n</head>\n<body>\n<main id=\"card\" aria-busy=\"true\">\n <div class=\"sk\" style=\"height:16px;width:40%\"></div>\n <div class=\"sk\" style=\"height:12px;width:70%;margin-top:8px\"></div>\n <div class=\"stage short\"></div>\n</main>\n<script type=\"module\">\n const ICON = {\n expand: '<path d=\"M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7\"/>',\n collapse: '<path d=\"M4 14h6v6M20 10h-6V4M14 10l7-7M3 21l7-7\"/>',\n out: '<path d=\"M7 17L17 7M8 7h9v9\"/>',\n check: '<path d=\"M5 12l5 5L20 7\"/>',\n prev: '<path d=\"M15 18l-6-6 6-6\"/>',\n next: '<path d=\"M9 18l6-6-6-6\"/>',\n image: '<rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\"/><circle cx=\"9\" cy=\"9\" r=\"2\"/><path d=\"M21 15l-5-5L5 21\"/>',\n alert: '<circle cx=\"12\" cy=\"12\" r=\"9\"/><path d=\"M12 8v4M12 16h.01\"/>',\n };\n const EDIT_STEPS = [[\"Checking the email\", [\"queued\", \"checking\"]], [\"Changing it\", [\"editing\"]], [\"Saving\", [\"saved\"]]];\n const PICTURE_TRIES = 4;\n const $ = (id) => document.getElementById(id);\n const el = (tag, text, attrs = {}) => Object.assign(document.createElement(tag), { textContent: text ?? \"\" }, attrs);\n function icon(name, big) {\n const svg = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n svg.setAttribute(\"class\", big ? \"i big\" : \"i\");\n svg.setAttribute(\"viewBox\", \"0 0 24 24\");\n svg.setAttribute(\"aria-hidden\", \"true\");\n svg.innerHTML = ICON[name];\n return svg;\n }\n function button(className, label, onclick, attrs = {}) {\n const b = el(\"button\", label, { type: \"button\", className, ...attrs });\n b.addEventListener(\"click\", onclick);\n return b;\n }\n const https = (url) => (typeof url === \"string\" && url.startsWith(\"https://\") ? url : \"\");\n\n let host = {}, caps = {}, input = {}, s = null, sel = 0, nextId = 1, timer = 0, ticker = 0, delay = 3000, tries = 0, busy = false;\n const pending = new Map();\n\n function send(msg) { window.parent.postMessage({ jsonrpc: \"2.0\", ...msg }, \"*\"); }\n function request(method, params, ms) {\n const id = nextId++;\n send({ id, method, params });\n return new Promise((resolve, reject) => {\n pending.set(id, { resolve, reject });\n // A host that never answers must not stall the card's reads.\n if (ms) setTimeout(() => pending.delete(id) && reject(new Error(\"timeout\")), ms);\n });\n }\n\n window.addEventListener(\"message\", (event) => {\n if (event.source !== window.parent) return;\n const msg = event.data;\n if (!msg || msg.jsonrpc !== \"2.0\") return;\n if (msg.id !== undefined && !msg.method) {\n const waiter = pending.get(msg.id);\n pending.delete(msg.id);\n if (waiter) msg.error ? waiter.reject(msg.error) : waiter.resolve(msg.result);\n return;\n }\n if (msg.id !== undefined) {\n // Host requests (ping, teardown) need an answer; this card holds no state to save.\n send({ id: msg.id, result: {} });\n return;\n }\n if (msg.method === \"ui/notifications/tool-input\") input = msg.params?.arguments ?? {};\n if (msg.method === \"ui/notifications/tool-result\") onResult(msg.params);\n if (msg.method === \"ui/notifications/host-context-changed\") { applyHost(msg.params); if (s) render(); }\n });\n\n function applyHost(ctx = {}) {\n host = { ...host, ...ctx };\n const root = document.documentElement;\n if (ctx.theme) { root.dataset.theme = ctx.theme; root.style.colorScheme = ctx.theme; }\n for (const [key, value] of Object.entries(ctx.styles?.variables ?? {})) if (value) root.style.setProperty(key, value);\n if (ctx.styles?.css?.fonts && !$(\"host-fonts\")) document.head.append(el(\"style\", ctx.styles.css.fonts, { id: \"host-fonts\" }));\n const inset = ctx.safeAreaInsets;\n if (inset) for (const side of [\"top\", \"right\", \"bottom\", \"left\"]) root.style.setProperty(\"--inset-\" + side, (inset[side] || 0) + \"px\");\n root.dataset.mode = host.displayMode || \"inline\";\n // Inline, the email scrolls inside the card; keep the card within the height the host allows.\n const max = host.containerDimensions?.maxHeight;\n root.style.setProperty(\"--stage-h\", (max ? Math.max(240, Math.min(520, max - 200)) : innerWidth < 480 ? 420 : 520) + \"px\");\n }\n\n // Each tool puts its JSON in one text item among others (a lead sentence, guidance, the Previews list).\n const texts = (result) => (result?.content ?? []).filter((c) => c.type === \"text\").map((c) => c.text);\n function json(result) {\n for (const text of texts(result)) {\n try { const value = JSON.parse(text); if (value && typeof value === \"object\" && !Array.isArray(value)) return value; } catch {}\n }\n return null;\n }\n function toEmail(e = {}, link = \"\") {\n return {\n emailId: e.emailId || e.id || \"\",\n subject: e.subject || \"\",\n preheader: e.preheader || e.previewText || \"\",\n picture: https(e.screenshotFullUrl) || https(e.screenshotUrl) || https(e.thumbnailUrl),\n appUrl: https(e.appUrl) || link,\n failed: e.status === \"failed\",\n day: typeof e.sendOffsetDays === \"number\" ? e.sendOffsetDays : null,\n };\n }\n\n function onResult(result) {\n clearTimeout(timer);\n sel = 0; tries = 0;\n const data = json(result);\n if (result?.isError || !data || (data.error && !data.conversationId && !data.editId)) {\n const mode = input.emailId && input.prompt ? \"edit\" : input.prompt ? \"create\" : \"email\";\n // Refused before anything started (no credits, a locked email): trying again would only repeat it.\n s = { mode, phase: \"failed\", refused: true, emailId: input.emailId, count: input.count, error: (typeof data?.error === \"string\" && data.error) || (!data && texts(result)[0]) || \"Migma could not do this.\" };\n render();\n if (mode === \"edit\") readBefore();\n return;\n }\n if (data.editId) {\n s = { mode: \"edit\", phase: \"working\", emailId: data.emailId, editId: data.editId, appUrl: https(data.appUrl), createdAt: data.createdAt, stage: data.stage };\n delay = data.pollAfterMs || 2000;\n render();\n readBefore();\n poll();\n } else if (data.emailId && \"subject\" in data) {\n s = { mode: \"email\", phase: \"ready\", emails: [toEmail(data)] };\n render();\n if (missingPicture()) retryPicture();\n } else if (data.conversationId) {\n // A status check is a snapshot: one line, or a Ready row that opens in place. The card the\n // generate call drew stays live, so these never poll unless opened.\n s = { mode: \"create\", phase: \"working\", compact: !!data.createdAt && !input.prompt, checkedAt: Date.now(), conversationId: data.conversationId, appUrl: https(data.appUrl), count: data.count || input.count };\n applyStatus(data);\n delay = 3000;\n render();\n if (!s.compact) poll();\n }\n }\n\n function applyStatus(d) {\n if (d.createdAt) s.createdAt = d.createdAt;\n if (d.status === \"failed\") { s.phase = \"failed\"; s.error = d.error || \"Migma could not create this email.\"; return; }\n if (d.status === \"completed\") {\n const r = d.result || {};\n const rows = Array.isArray(r.emails) && r.emails.length ? r.emails : [r];\n s.emails = rows.map((e) => toEmail(e, s.appUrl));\n s.phase = \"ready\";\n return;\n }\n const p = d.progress || {};\n const events = Array.isArray(p.events) ? p.events.filter((e) => e?.label) : [];\n const done = [...new Set(events.filter((e) => e.status === \"complete\").map((e) => e.label))];\n const live = p.now?.label && (p.now.status === \"start\" || p.now.status === \"progress\") ? p.now.label : \"\";\n s.now = live || events.filter((e) => e.status === \"processing\").pop()?.label || s.now || \"\";\n s.steps = done.filter((label) => label !== s.now).slice(-3);\n if (Array.isArray(p.slots) && p.slots.length) s.slots = p.slots;\n }\n\n function applyEdit(d) {\n if (d.createdAt) s.createdAt = d.createdAt;\n s.stage = d.stage || s.stage;\n if (d.status === \"completed\") {\n s.mode = \"email\"; s.phase = \"ready\";\n s.emails = [unchanged(toEmail(d.result || { emailId: s.emailId, subject: s.before?.subject }, s.before?.appUrl || s.appUrl), s.before?.picture)];\n } else if (d.status === \"failed\") {\n s.phase = \"failed\"; s.error = d.error || \"Migma could not change this email.\"; s.mayHaveSaved = !!d.changesMayHaveBeenSaved;\n }\n }\n\n // Right after a change the email can still carry its old picture until Migma captures the new\n // one: wait for a different picture, and show the old one only once the retries run out.\n function unchanged(e, old) {\n if (e.picture && e.picture === old) { e.stale = e.picture; e.picture = \"\"; }\n return e;\n }\n\n // Tried even when the host does not list serverTools or openLinks: a refusal falls back.\n async function read(name, args) {\n try {\n const result = await request(\"tools/call\", { name, arguments: args }, 30000);\n return result?.isError ? null : json(result);\n } catch { return null; }\n }\n\n async function readBefore() {\n if (!s?.emailId) return;\n const d = await read(\"migma_get_email\", { emailId: s.emailId });\n if (d?.emailId && s.mode !== \"email\") { s.before = toEmail(d); render(); }\n }\n\n async function poll() {\n clearTimeout(timer);\n if (!s || s.compact || s.phase !== \"working\" || busy || document.visibilityState !== \"visible\") return;\n busy = true;\n if (s.mode === \"create\") {\n const d = await read(\"migma_get_generation_status\", { conversationId: s.conversationId });\n if (d?.conversationId) applyStatus(d);\n } else {\n const d = await read(\"migma_get_email_edit_status\", { emailId: s.emailId, editId: s.editId });\n if (d?.status) applyEdit(d);\n }\n busy = false;\n render();\n if (s.phase === \"working\") {\n // ponytail: backoff to one read every 15 s; a push from Migma would replace polling if hosts add it.\n timer = setTimeout(poll, delay);\n delay = Math.min(delay * 1.4, 15000);\n } else if (missingPicture()) retryPicture();\n }\n\n const missingPicture = () => s?.phase === \"ready\" && s.emails.some((e) => !e.failed && !e.picture);\n // The picture is captured after the email is saved. Each read returns every picture of the\n // run, so try a few times, further apart, then say it is ready in Migma.\n function retryPicture() {\n clearTimeout(timer);\n if (tries >= PICTURE_TRIES) {\n for (const e of s.emails) if (!e.picture && e.stale) e.picture = e.stale;\n s.noPicture = true;\n return render();\n }\n timer = setTimeout(async () => {\n tries++;\n if (s.mode === \"create\") {\n const d = await read(\"migma_get_generation_status\", { conversationId: s.conversationId });\n if (d?.status === \"completed\") applyStatus(d);\n } else {\n const d = await read(\"migma_get_email\", { emailId: s.emails[0].emailId });\n if (d?.emailId) s.emails = [unchanged(toEmail(d, s.emails[0].appUrl), s.emails[0].stale)];\n }\n render();\n if (missingPicture()) retryPicture();\n }, 4000 * 2 ** tries);\n }\n\n function refreshSoon() { if (s?.phase === \"working\") { delay = 3000; poll(); } }\n document.addEventListener(\"visibilitychange\", () => document.visibilityState === \"visible\" && refreshSoon());\n window.addEventListener(\"focus\", refreshSoon);\n\n function elapsed() {\n const start = Date.parse(s.createdAt);\n if (!start) return \"\";\n const secs = Math.max(0, Math.round(((s.compact ? s.checkedAt : Date.now()) - start) / 1000));\n return Math.floor(secs / 60) + \":\" + String(secs % 60).padStart(2, \"0\");\n }\n function tick() {\n clearInterval(ticker);\n if (s.phase !== \"working\" || s.compact || !s.createdAt) return;\n ticker = setInterval(() => document.querySelectorAll(\".time\").forEach((t) => { t.textContent = elapsed(); }), 1000);\n }\n\n // ---- actions ----\n async function openLink(url) {\n if (!url) return;\n try { const r = await request(\"ui/open-link\", { url }); if (!r?.isError) return; } catch {}\n s.note = \"Could not open the link. Copy it: \" + url;\n render();\n }\n async function ask(text) {\n try {\n const r = await request(\"ui/message\", { role: \"user\", content: [{ type: \"text\", text }] });\n if (r?.isError) throw new Error();\n } catch {\n s.note = \"Could not send that to Claude. Type it in the chat instead.\";\n render();\n }\n }\n async function displayMode(mode) {\n try { const r = await request(\"ui/request-display-mode\", { mode }); applyHost({ displayMode: r?.mode || host.displayMode }); } catch {}\n render();\n }\n const canFullScreen = () => (host.availableDisplayModes || []).includes(\"fullscreen\");\n const fullScreen = () => host.displayMode === \"fullscreen\" && s.phase === \"ready\" && !s.compact;\n function select(i) {\n sel = Math.max(0, Math.min(s.emails.length - 1, i));\n render();\n document.querySelector('[aria-selected=\"true\"], [aria-current=\"true\"]')?.focus();\n }\n document.addEventListener(\"keydown\", (event) => {\n if (!s || !fullScreen() || s.emails.length < 2 || event.target.closest?.('[role=\"tab\"]')) return;\n if (event.key === \"ArrowLeft\") select(sel - 1);\n if (event.key === \"ArrowRight\") select(sel + 1);\n });\n\n // ---- pieces ----\n const series = () => s.emails.length > 1;\n const quoted = (e) => (e.subject ? \"\u201C\" + e.subject + \"\u201D\" : \"this email\");\n const named = (e, i) => (series() ? \"email \" + (i + 1) + \" of the series, \" + quoted(e) + \",\" : quoted(e));\n function chip(label, cost, text) {\n const b = button(\"chip\", label, () => ask(text));\n if (cost) b.append(el(\"small\", cost));\n return b;\n }\n function asks(list) {\n const box = el(\"div\", \"\", { className: \"asks\" });\n if (caps.message) box.append(...list.map(([label, cost, text]) => chip(label, cost, text)));\n return box;\n }\n function linkButton(url, primary) {\n if (!url) return el(\"span\", \"\");\n const b = button(primary ? \"primary\" : \"ghost\", primary ? \"Edit in Migma\" : \"Open in Migma\", () => openLink(url));\n b.append(icon(\"out\"));\n return b;\n }\n function foot(list, url, primary) {\n const f = el(\"div\", \"\", { className: \"foot\" });\n f.append(asks(list), linkButton(url, primary));\n return f;\n }\n function head(title, pre, tools = []) {\n const h = el(\"div\", \"\", { className: \"head\" });\n const t = el(\"div\", \"\", { className: \"title\" });\n t.append(el(\"h1\", title));\n if (pre) t.append(el(\"p\", pre, { className: \"pre\", title: pre }));\n h.append(t);\n if (tools.length) { const box = el(\"div\", \"\", { className: \"tools\" }); box.append(...tools); h.append(box); }\n return h;\n }\n function statusLine(label, tone) {\n const p = el(\"p\", \"\", { className: \"status\" });\n p.append(el(\"span\", \"\", { className: \"dot \" + tone }), el(\"span\", label));\n return p;\n }\n function steps(items) {\n const ul = el(\"ul\", \"\", { className: \"steps\" });\n ul.setAttribute(\"aria-live\", \"polite\");\n for (const [label, state] of items) {\n const li = el(\"li\", \"\", { className: state });\n const mark = el(\"span\", \"\", { className: \"mark\" });\n mark.append(state === \"done\" ? icon(\"check\") : el(\"span\", \"\", { className: \"ring\" }));\n li.append(mark, el(\"span\", label));\n if (state === \"now\") li.append(el(\"span\", elapsed(), { className: \"time\" }));\n ul.append(li);\n }\n return ul;\n }\n function skeleton() {\n const box = el(\"div\", \"\", { className: \"skel\" });\n for (const [h, w, m] of [[14, 30, 0], [56, 85, 16], [56, 60, 0], [200, 100, 8]]) {\n box.append(el(\"div\", \"\", { className: \"sk\", style: \"height:\" + h + \"px;width:\" + w + \"%;margin-top:\" + m + \"px\" }));\n }\n return box;\n }\n function picture(e, dim) {\n const shot = el(\"div\", \"\", { className: dim ? \"shot dim\" : \"shot\" });\n const img = el(\"img\", \"\", { alt: (e.subject || \"Email\") + (dim ? \", before the change\" : \"\") });\n img.addEventListener(\"error\", () => { e.picture = \"\"; render(); if (missingPicture()) retryPicture(); }, { once: true });\n img.src = e.picture;\n shot.append(img);\n return shot;\n }\n function stageNote(iconName, text) {\n const note = el(\"div\", \"\", { className: \"stage-note\" });\n note.append(icon(iconName, true), el(\"p\", text));\n return note;\n }\n function stage(e, opts = {}) {\n const box = el(\"div\", \"\", { className: opts.short ? \"stage short\" : \"stage\" });\n if (e?.failed) {\n const ready = s.emails.filter((x) => !x.failed).length;\n box.append(stageNote(\"alert\", \"Migma could not create this email.\" + (ready ? \" The other \" + (ready === 1 ? \"one is\" : ready + \" are\") + \" ready.\" : \"\")));\n } else if (e?.picture) {\n box.append(picture(e, opts.dim));\n box.tabIndex = 0;\n box.setAttribute(\"aria-label\", (e.subject || \"Email\") + \", scroll to read\");\n } else if (opts.short || !s.noPicture || !e) {\n box.append(skeleton());\n if (e && !opts.short) {\n const note = el(\"p\", \"\", { className: \"stage-note\", role: \"status\" });\n const pill = el(\"span\", \"\", { className: \"pill\" });\n pill.append(el(\"span\", \"\", { className: \"dot info\" }), el(\"span\", \"Preparing the picture\"));\n note.append(pill);\n box.append(note);\n }\n } else {\n box.append(stageNote(\"image\", \"No picture of this email yet. It is ready in Migma.\"));\n }\n return box;\n }\n function tabs() {\n const list = el(\"div\", \"\", { className: \"tabs\", role: \"tablist\" });\n list.setAttribute(\"aria-label\", \"Emails in this series\");\n s.emails.forEach((e, i) => {\n const tab = button(\"tab\", \"\", () => select(i), { role: \"tab\" });\n tab.setAttribute(\"aria-selected\", String(i === sel));\n tab.tabIndex = i === sel ? 0 : -1;\n tab.append(el(\"span\", String(i + 1), { className: \"n\" }), el(\"span\", e.failed ? \"Not created\" : e.subject || \"Email \" + (i + 1), { className: \"t\" }));\n if (e.failed) tab.append(el(\"span\", \"\", { className: \"dot bad\" }));\n else if (e.day !== null) tab.append(el(\"span\", \"Day \" + e.day, { className: \"d\" }));\n tab.addEventListener(\"keydown\", (event) => {\n if (event.key === \"ArrowLeft\") select(i - 1);\n if (event.key === \"ArrowRight\") select(i + 1);\n });\n list.append(tab);\n });\n return list;\n }\n function readyAsks(e, i) {\n if (e.failed) return [[\"Try this email again\", \"1 credit\", \"Try creating email \" + (i + 1) + \" of the series again.\"]];\n return [\n [\"Make it shorter\", \"0.5 credit\", \"Make \" + named(e, i) + \" shorter.\"],\n [\"Try another version\", \"1 credit\", \"Make another version of \" + named(e, i).replace(/,$/, \"\") + \".\"],\n ];\n }\n\n // ---- views ----\n function compactView() {\n const line = el(\"div\", \"\", { className: \"line\", role: \"status\" });\n const many = (s.count || s.slots?.length || s.emails?.length || 1) > 1;\n if (s.phase === \"working\") {\n line.append(el(\"span\", \"\", { className: \"dot info\" }), el(\"span\", many ? \"Designing \" + (s.count || s.slots.length) + \" emails\" : \"Designing your email\", { className: \"t\" }));\n if (s.now) line.append(el(\"span\", s.now, { className: \"s\" }));\n line.append(el(\"span\", elapsed(), { className: \"time\" }));\n } else if (s.phase === \"failed\") {\n line.append(el(\"span\", \"\", { className: \"dot bad\" }), el(\"span\", \"Not created\", { className: \"t\" }), el(\"span\", s.error, { className: \"s\" }));\n } else {\n const first = s.emails.find((e) => e.picture);\n const thumb = el(\"span\", \"\", { className: \"thumb\" });\n if (first) thumb.append(el(\"img\", \"\", { src: first.picture, alt: \"\" }));\n line.append(thumb, el(\"span\", many ? s.emails.length + \" emails\" : s.emails[0].subject || \"Your email\", { className: \"t\" }), el(\"span\", \"Ready\", { className: \"s\" }));\n const show = button(\"ghost\", \"Show\", () => { s.compact = false; render(); if (missingPicture()) retryPicture(); });\n show.setAttribute(\"aria-expanded\", \"false\");\n line.append(show, linkButton(s.emails[0].appUrl || s.appUrl, true));\n }\n return [line];\n }\n\n function workingView() {\n if (s.mode === \"edit\") {\n const at = Math.max(0, EDIT_STEPS.findIndex(([, stages]) => stages.includes(s.stage)));\n return [\n head(s.before?.subject || \"Changing your email\", input.prompt),\n steps(EDIT_STEPS.map(([label], i) => [label, i < at ? \"done\" : i === at ? \"now\" : \"todo\"])),\n s.before?.picture ? stage(s.before, { dim: true }) : stage(null, { short: true }),\n foot([], s.before?.appUrl || s.appUrl, false),\n ];\n }\n const count = s.count || s.slots?.length || 1;\n const parts = [\n head(count > 1 ? \"Designing \" + count + \" emails\" : \"Designing your email\", input.prompt),\n steps([...(s.steps || []).map((label) => [label, \"done\"]), [s.now || \"Starting\", \"now\"]]),\n ];\n if (count > 1) {\n const slots = el(\"div\", \"\", { className: \"slots\" });\n for (let i = 0; i < count; i++) {\n const done = s.slots?.[i] && !s.slots[i].pending;\n const slot = el(\"div\", \"\", { className: done ? \"slot done\" : \"slot\" });\n const frame = el(\"div\", \"\", { className: \"frame\" });\n frame.append(done ? icon(\"check\", true) : el(\"span\", \"\", { className: \"dot info\" }));\n const lab = el(\"div\", \"\", { className: \"lab\" });\n lab.append(el(\"span\", \"Email \" + (i + 1)), el(\"span\", done ? \"Done\" : \"Designing\"));\n slot.append(frame, lab);\n slots.append(slot);\n }\n parts.push(slots);\n } else {\n parts.push(stage(null, { short: true }));\n }\n parts.push(foot([], s.appUrl, false));\n return parts;\n }\n\n function failedView() {\n if (s.mode === \"edit\") {\n const e = s.before;\n const parts = [statusLine(\"Not changed\", \"bad\"), head(e?.subject || \"Your email\", input.prompt), el(\"p\", s.error, { className: \"note bad\" })];\n if (s.mayHaveSaved) parts.push(el(\"p\", \"Some changes may have been saved. Check the email in Migma before you try again.\", { className: \"note warn\" }));\n if (e?.picture) parts.push(stage(e));\n parts.push(foot(input.prompt && !s.refused ? [[\"Try again\", \"0.5 credit\", \"Try that change to \" + (e ? quoted(e) : \"the email\") + \" again.\"]] : [], e?.appUrl || s.appUrl, true));\n return parts;\n }\n if (s.mode === \"email\") return [statusLine(\"Could not show this email\", \"bad\"), el(\"p\", s.error, { className: \"note bad\" })];\n const many = (s.count || 1) > 1;\n return [\n statusLine(\"Not created\", \"bad\"),\n head(many ? \"Your emails\" : \"Your email\", input.prompt),\n el(\"p\", s.error, { className: \"note bad\" }),\n foot(input.prompt && !s.refused ? [[\"Try again\", many ? s.count + \" credits\" : \"1 credit\", many ? \"Try creating those emails again.\" : \"Try creating that email again.\"]] : [], s.appUrl, false),\n ];\n }\n\n function readyView() {\n const e = s.emails[sel];\n const full = canFullScreen() ? [button(\"icon-btn\", \"\", () => displayMode(\"fullscreen\"), { ariaLabel: \"Full screen\" })] : [];\n full[0]?.append(icon(\"expand\"));\n const title = e.failed ? \"Email \" + (sel + 1) + \" was not created\" : e.subject || \"Your email\";\n const parts = [head(title, e.failed ? \"\" : e.preheader, full)];\n if (series()) parts.push(tabs());\n parts.push(stage(e), foot(readyAsks(e, sel), e.appUrl || s.appUrl, true));\n return parts;\n }\n\n function fullScreenView() {\n const e = s.emails[sel];\n const back = button(\"icon-btn\", \"\", () => displayMode(\"inline\"), { ariaLabel: \"Back to the chat\" });\n back.append(icon(\"collapse\"));\n const box = el(\"section\", \"\", { className: \"fs\" });\n const body = el(\"div\", \"\", { className: \"fs-body\" });\n if (series()) {\n const rail = el(\"nav\", \"\", { className: \"rail\" });\n rail.setAttribute(\"aria-label\", \"Emails in this series\");\n s.emails.forEach((x, i) => {\n const item = button(\"rail-item\", \"\", () => select(i));\n if (i === sel) item.setAttribute(\"aria-current\", \"true\");\n const thumb = el(\"div\", \"\", { className: \"thumb\" });\n thumb.append(x.picture ? el(\"img\", \"\", { src: x.picture, alt: \"\" }) : icon(x.failed ? \"alert\" : \"image\", true));\n item.append(thumb, el(\"span\", (i + 1) + (x.failed ? \" \u00B7 Not created\" : x.day !== null ? \" \u00B7 Day \" + x.day : \"\")));\n rail.append(item);\n });\n body.append(rail);\n }\n const wrap = el(\"div\", \"\", { className: \"fs-wrap\" });\n wrap.append(stage(e));\n if (series()) {\n const prev = button(\"step-btn prev\", \"\", () => select(sel - 1), { ariaLabel: \"Previous email\", disabled: sel === 0 });\n const next = button(\"step-btn next\", \"\", () => select(sel + 1), { ariaLabel: \"Next email\", disabled: sel === s.emails.length - 1 });\n prev.append(icon(\"prev\")); next.append(icon(\"next\"));\n wrap.append(prev, next);\n }\n body.append(wrap);\n box.append(head(e.failed ? \"Email \" + (sel + 1) + \" was not created\" : e.subject || \"Your email\", e.failed ? \"\" : e.preheader, [back]));\n if (series()) box.append(tabs());\n box.append(body, foot(readyAsks(e, sel), e.appUrl || s.appUrl, true));\n if (s.note) box.append(el(\"p\", s.note, { className: \"note small\" }));\n return [box];\n }\n\n function render() {\n const main = $(\"card\");\n main.setAttribute(\"aria-busy\", String(s.phase === \"working\" && !s.compact));\n let parts;\n if (s.compact) parts = compactView();\n else if (fullScreen()) parts = fullScreenView();\n else parts = s.phase === \"working\" ? workingView() : s.phase === \"failed\" ? failedView() : readyView();\n if (s.note && !fullScreen()) parts.push(el(\"p\", s.note, { className: \"note small\" }));\n main.replaceChildren(...parts);\n tick();\n }\n\n new ResizeObserver(() => send({ method: \"ui/notifications/size-changed\", params: { height: Math.ceil(document.documentElement.getBoundingClientRect().height) } }))\n .observe(document.documentElement);\n\n const init = await request(\"ui/initialize\", {\n appInfo: { name: \"Migma email\", version: \"1.0.0\" },\n appCapabilities: { availableDisplayModes: [\"inline\", \"fullscreen\"] },\n protocolVersion: \"2026-01-26\",\n });\n caps = init?.hostCapabilities ?? {};\n applyHost(init?.hostContext);\n send({ method: \"ui/notifications/initialized\", params: {} });\n</script>\n</body>\n</html>\n";
|
|
14
|
+
//# sourceMappingURL=email-card.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-card.d.ts","sourceRoot":"","sources":["../../src/tools/email-card.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE;;;;;;GAMG;AAEH,eAAO,MAAM,cAAc,qBAAqB,CAAC;AAEjD,mFAAmF;AACnF,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAEhF;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,QAQjE;AAED,eAAO,MAAM,eAAe,wtsCAorB3B,CAAC"}
|