@superjackfruitlabs/treaty-matrix-events 0.0.12 → 0.0.14
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/dist/deliveries.d.ts +8 -0
- package/dist/gate.js +37 -3
- package/package.json +1 -1
package/dist/deliveries.d.ts
CHANGED
|
@@ -24,6 +24,14 @@ export interface GatePendingDelivery {
|
|
|
24
24
|
* and a gate without it must still render.
|
|
25
25
|
*/
|
|
26
26
|
handoffSummary?: string | null;
|
|
27
|
+
/**
|
|
28
|
+
* References linked by the run that opened the gate. Absent on older deliveries; an empty
|
|
29
|
+
* list means that run linked no artifact.
|
|
30
|
+
*/
|
|
31
|
+
references?: Array<{
|
|
32
|
+
title: string | null;
|
|
33
|
+
url: string;
|
|
34
|
+
}>;
|
|
27
35
|
/**
|
|
28
36
|
* What the board is CALLED, which this hub has no other way to learn — the board's
|
|
29
37
|
* metadata route resolves a user session, the same wall that makes `humansFor` an
|
package/dist/gate.js
CHANGED
|
@@ -87,9 +87,43 @@ export function isGatePending(v) {
|
|
|
87
87
|
export function gateProseBody(d, link) {
|
|
88
88
|
const where = `at stage \`${d.stageKey}\``;
|
|
89
89
|
const tail = link ? ` [Open the card](${link})` : "";
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
const body = isVariantGate(d)
|
|
91
|
+
? `Choice needed — "${d.cardTitle}" ${where}. ${VARIANT_CHOICE_NOTE}${tail}`
|
|
92
|
+
: `Approval needed — "${d.cardTitle}" ${where}. Approve, request changes, or reject.${tail}`;
|
|
93
|
+
// `references` is not checked by isGatePending, so a board on another version can send anything
|
|
94
|
+
// here: anything but a list is treated as absent, and an entry without a usable link is left out.
|
|
95
|
+
const refs = d.references;
|
|
96
|
+
if (!Array.isArray(refs))
|
|
97
|
+
return body;
|
|
98
|
+
if (refs.length === 0)
|
|
99
|
+
return `${body}\nThis run linked no artifact`;
|
|
100
|
+
const lines = refs.flatMap((r) => {
|
|
101
|
+
const line = referenceLine(r);
|
|
102
|
+
return line ? [line] : [];
|
|
103
|
+
});
|
|
104
|
+
return lines.length ? `${body}\n${lines.join("\n")}` : body;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* One reference as a markdown list item, or null when it has no http(s) link.
|
|
108
|
+
*
|
|
109
|
+
* Titles and URLs come from agents and people, so neither may steer the markdown: the title is
|
|
110
|
+
* one line with `\`, `[` and `]` escaped, and the URL is percent-encoded wherever markdown would
|
|
111
|
+
* read it (`(`, `)`, `[`, `]`, `<`, `>`, whitespace). Only http(s) is linked: a `javascript:` link
|
|
112
|
+
* in a gate message would be one tap away for the person deciding.
|
|
113
|
+
*/
|
|
114
|
+
function referenceLine(r) {
|
|
115
|
+
if (typeof r !== "object" || r === null)
|
|
116
|
+
return null;
|
|
117
|
+
const { title, url } = r;
|
|
118
|
+
if (typeof url !== "string" || !/^https?:\/\//i.test(url))
|
|
119
|
+
return null;
|
|
120
|
+
const href = url.replace(/[()[\]<>\s]/g, (c) => "%" + c.charCodeAt(0).toString(16).toUpperCase().padStart(2, "0"));
|
|
121
|
+
const raw = typeof title === "string" && title.trim() ? title : url;
|
|
122
|
+
const text = raw
|
|
123
|
+
.replace(/\s+/g, " ")
|
|
124
|
+
.trim()
|
|
125
|
+
.replace(/[\\[\]]/g, (c) => `\\${c}`);
|
|
126
|
+
return `- [${text}](${href})`;
|
|
93
127
|
}
|
|
94
128
|
/**
|
|
95
129
|
* What a client that cannot draw the variants is told (charter 2026-11-09 §6): where the choice is
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superjackfruitlabs/treaty-matrix-events",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "The board-room Matrix event contract: JSON Schemas, builders and parsers for the gates, questions, follow-ups and waiting cards Super Jackfruit Labs products carry into chat, and the answers back.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|