@relaymessenger/sdk 0.3.6-staging.2 → 0.3.6-staging.21
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 +180 -20
- package/dist/buttons.d.ts +69 -0
- package/dist/buttons.d.ts.map +1 -0
- package/dist/buttons.js +141 -0
- package/dist/buttons.js.map +1 -0
- package/dist/call-room.d.ts +105 -0
- package/dist/call-room.d.ts.map +1 -0
- package/dist/call-room.js +584 -0
- package/dist/call-room.js.map +1 -0
- package/dist/client.d.ts +20 -24
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +62 -41
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/invoice.d.ts +64 -0
- package/dist/invoice.d.ts.map +1 -0
- package/dist/invoice.js +184 -0
- package/dist/invoice.js.map +1 -0
- package/dist/links.d.ts +50 -0
- package/dist/links.d.ts.map +1 -0
- package/dist/links.js +127 -0
- package/dist/links.js.map +1 -0
- package/dist/operations.d.ts +20 -24
- package/dist/operations.d.ts.map +1 -1
- package/dist/operations.js +25 -30
- package/dist/operations.js.map +1 -1
- package/dist/selection.d.ts +38 -0
- package/dist/selection.d.ts.map +1 -0
- package/dist/selection.js +132 -0
- package/dist/selection.js.map +1 -0
- package/dist/types.d.ts +314 -36
- package/dist/types.d.ts.map +1 -1
- package/dist/websocket.d.ts +2 -2
- package/dist/websocket.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/invoice.js
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The fence tag a text-only agent uses to ask someone to pay. The block body
|
|
3
|
+
* is one JSON object, the `invoice` part exactly as the API takes it:
|
|
4
|
+
*
|
|
5
|
+
* ```invoice
|
|
6
|
+
* {"title": "House blend, 250 g", "amount": 2400, "currency": "usd", "goods": "physical", "url": "https://buy.stripe.com/test_123"}
|
|
7
|
+
* ```
|
|
8
|
+
*/
|
|
9
|
+
export const INVOICE_FENCE = "invoice";
|
|
10
|
+
/**
|
|
11
|
+
* When an agent should send an invoice. One text, carried verbatim by every
|
|
12
|
+
* runtime's tool description or prompt. References: Linq Agent Pay ("a card
|
|
13
|
+
* is the whole message"); Telegram `sendInvoice` (only the bot sends
|
|
14
|
+
* invoices); Apple 3.1.3(e)/3.1.1(a) (physical goods or services used outside
|
|
15
|
+
* the app may use any non-IAP method; digital goods may only be linked out).
|
|
16
|
+
*/
|
|
17
|
+
export const INVOICE_GUIDANCE = [
|
|
18
|
+
"Send an invoice only when the person asked to buy something or has already agreed to a price; never invoice out of the blue.",
|
|
19
|
+
"url must be a real Stripe checkout link you were given — a Stripe Payment Link (buy.stripe.com), a Stripe Checkout Session (checkout.stripe.com) or a Stripe hosted invoice (invoice.stripe.com). Never invent one, and never paste a checkout link in text or a button; send an invoice instead.",
|
|
20
|
+
"Only a verified agent can send an invoice; if yours is refused as unverified, say so in words instead.",
|
|
21
|
+
"Set goods honestly: physical for goods or services used outside the app, digital for anything delivered in chat or used inside an app.",
|
|
22
|
+
"The invoice card is a message of its own: no buttons or selection beside it, and any words you write arrive in a message before it.",
|
|
23
|
+
"Use recurring for a subscription: interval day, week, month or year, for up to 3 years total.",
|
|
24
|
+
"When your own system learns the payment went through, for example your Stripe webhook, mark it with the status route so the card updates for the person.",
|
|
25
|
+
].join(" ");
|
|
26
|
+
/**
|
|
27
|
+
* How a text-only agent asks someone to pay: the same words for every bridge
|
|
28
|
+
* that sends the agent's final text for it.
|
|
29
|
+
*/
|
|
30
|
+
export const INVOICE_BLOCK_INSTRUCTION = "To ask the person to pay, end your answer with a fenced code block tagged `" + INVOICE_FENCE + "` "
|
|
31
|
+
+ "holding one JSON object: {\"title\": \"...\", \"amount\": 2400, \"currency\": \"usd\", "
|
|
32
|
+
+ "\"goods\": \"physical\" or \"digital\", \"url\": \"https://buy.stripe.com/...\"}, with an optional "
|
|
33
|
+
+ "\"recurring\": {\"interval\": \"month\", \"interval_count\": 1} for a subscription. "
|
|
34
|
+
+ "The block is removed from your words and drawn as its own invoice card, sent after them.";
|
|
35
|
+
/**
|
|
36
|
+
* The Stripe-hosted pages where a person pays, and the only hosts an invoice
|
|
37
|
+
* url may use (the server's own list): a Checkout Session, a Payment Link
|
|
38
|
+
* (pay/subscribe, book, donate), or a hosted invoice. Test-mode links share
|
|
39
|
+
* these hosts.
|
|
40
|
+
*/
|
|
41
|
+
export const INVOICE_CHECKOUT_HOSTS = [
|
|
42
|
+
"checkout.stripe.com",
|
|
43
|
+
"buy.stripe.com",
|
|
44
|
+
"book.stripe.com",
|
|
45
|
+
"donate.stripe.com",
|
|
46
|
+
"invoice.stripe.com",
|
|
47
|
+
];
|
|
48
|
+
const checkoutHosts = new Set(INVOICE_CHECKOUT_HOSTS);
|
|
49
|
+
/** The server's limits (Telegram title, Stripe amount/url/recurring span). */
|
|
50
|
+
export const INVOICE_TITLE_MAX_LENGTH = 32;
|
|
51
|
+
export const INVOICE_MAX_AMOUNT = 99_999_999;
|
|
52
|
+
export const INVOICE_URL_MAX_LENGTH = 2_048;
|
|
53
|
+
/** Total recurring span capped at 3 years: 1095 days / 156 weeks / 36 months / 3 years. */
|
|
54
|
+
export const INVOICE_RECURRING_MAX_COUNT = {
|
|
55
|
+
day: 1_095,
|
|
56
|
+
week: 156,
|
|
57
|
+
month: 36,
|
|
58
|
+
year: 3,
|
|
59
|
+
};
|
|
60
|
+
const record = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
61
|
+
// Counted in code points, matching the server's own check, so a 17-32
|
|
62
|
+
// character emoji title (surrogate pairs) is not rejected as too long.
|
|
63
|
+
const invoiceTitleLength = (value) => [...value].length;
|
|
64
|
+
/**
|
|
65
|
+
* A checkout link the card may open: https on a Stripe checkout host, with no
|
|
66
|
+
* username, password or port (`https://buy.stripe.com@evil.com` is evil.com).
|
|
67
|
+
* Matches the server's own check and its normalization, so a link the SDK
|
|
68
|
+
* accepts is never rejected by the API and always reads back the same way.
|
|
69
|
+
*/
|
|
70
|
+
const checkoutUrl = (value) => {
|
|
71
|
+
try {
|
|
72
|
+
const url = new URL(value);
|
|
73
|
+
return url.protocol === "https:" && checkoutHosts.has(url.hostname) && url.port === ""
|
|
74
|
+
&& url.username === "" && url.password === ""
|
|
75
|
+
? url
|
|
76
|
+
: undefined;
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const FENCE = new RegExp("(^|\\n)[ \\t]*```[ \\t]*" + INVOICE_FENCE + "(?:[ \\t][^\\r\\n]*)?\\r?\\n([\\s\\S]*?)\\r?\\n[ \\t]*```[ \\t]*(?=\\r?\\n|$)", "gu");
|
|
83
|
+
const BUTTONS_OR_SELECTION_FENCE = /(^|\n)[ \t]*```[ \t]*(?:buttons|selection)(?:[ \t][^\r\n]*)?\r?\n/u;
|
|
84
|
+
/**
|
|
85
|
+
* Turns a decoded value, the fields object or the whole part, into an
|
|
86
|
+
* `invoice` part, or explains why it cannot. The checks are the server's own,
|
|
87
|
+
* so a bad value fails here with a readable reason instead of a 400 from the
|
|
88
|
+
* API. `currency` is normalized to lowercase.
|
|
89
|
+
*/
|
|
90
|
+
export const invoicePart = (parsed) => {
|
|
91
|
+
if (!record(parsed))
|
|
92
|
+
return "the invoice block must be a JSON object";
|
|
93
|
+
const allowed = new Set(["type", "title", "amount", "currency", "goods", "url", "recurring"]);
|
|
94
|
+
const extra = Object.keys(parsed).find((key) => !allowed.has(key));
|
|
95
|
+
if (extra)
|
|
96
|
+
return `invoice has unknown field ${extra}`;
|
|
97
|
+
if (parsed.type !== undefined && parsed.type !== "invoice")
|
|
98
|
+
return "invoice part needs type invoice";
|
|
99
|
+
const { title, amount, currency, goods, url, recurring } = parsed;
|
|
100
|
+
if (typeof title !== "string" || !title.trim() || invoiceTitleLength(title.trim()) > INVOICE_TITLE_MAX_LENGTH) {
|
|
101
|
+
return `invoice needs a trimmed title of 1 to ${INVOICE_TITLE_MAX_LENGTH} characters`;
|
|
102
|
+
}
|
|
103
|
+
if (!Number.isInteger(amount) || amount < 1 || amount > INVOICE_MAX_AMOUNT) {
|
|
104
|
+
return `invoice amount must be an integer of 1 to ${INVOICE_MAX_AMOUNT}`;
|
|
105
|
+
}
|
|
106
|
+
if (typeof currency !== "string" || !/^[A-Za-z]{3}$/u.test(currency)) {
|
|
107
|
+
return "invoice currency must be a 3-letter code";
|
|
108
|
+
}
|
|
109
|
+
if (goods !== "physical" && goods !== "digital") {
|
|
110
|
+
return 'invoice goods must be "physical" or "digital"';
|
|
111
|
+
}
|
|
112
|
+
if (typeof url !== "string" || url.length > INVOICE_URL_MAX_LENGTH) {
|
|
113
|
+
return `invoice url is not a string of at most ${INVOICE_URL_MAX_LENGTH} characters`;
|
|
114
|
+
}
|
|
115
|
+
const normalizedUrl = checkoutUrl(url);
|
|
116
|
+
if (!normalizedUrl) {
|
|
117
|
+
return `invoice url must be an https Stripe checkout link on ${INVOICE_CHECKOUT_HOSTS.join(", ")}`;
|
|
118
|
+
}
|
|
119
|
+
let normalizedRecurring;
|
|
120
|
+
if (recurring !== undefined) {
|
|
121
|
+
if (!record(recurring))
|
|
122
|
+
return "invoice recurring must be an object";
|
|
123
|
+
const recurringExtra = Object.keys(recurring)
|
|
124
|
+
.find((key) => key !== "interval" && key !== "interval_count");
|
|
125
|
+
if (recurringExtra)
|
|
126
|
+
return `invoice recurring has unknown field ${recurringExtra}`;
|
|
127
|
+
const { interval, interval_count } = recurring;
|
|
128
|
+
if (typeof interval !== "string" || !Object.hasOwn(INVOICE_RECURRING_MAX_COUNT, interval)) {
|
|
129
|
+
return "invoice recurring interval must be day, week, month or year";
|
|
130
|
+
}
|
|
131
|
+
const max = INVOICE_RECURRING_MAX_COUNT[interval];
|
|
132
|
+
const count = interval_count === undefined ? 1 : interval_count;
|
|
133
|
+
if (!Number.isInteger(count) || count < 1 || count > max) {
|
|
134
|
+
return `invoice recurring interval_count for ${interval} must be an integer of 1 to ${max}`;
|
|
135
|
+
}
|
|
136
|
+
normalizedRecurring = { interval: interval, interval_count: count };
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
type: "invoice",
|
|
140
|
+
title: title.trim(),
|
|
141
|
+
amount: amount,
|
|
142
|
+
currency: currency.toLowerCase(),
|
|
143
|
+
goods: goods,
|
|
144
|
+
url: normalizedUrl.href,
|
|
145
|
+
...(normalizedRecurring ? { recurring: normalizedRecurring } : {}),
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
/** Parses the body of an invoice block, JSON, into an `invoice` part. */
|
|
149
|
+
export const parseInvoiceBlock = (body) => {
|
|
150
|
+
let parsed;
|
|
151
|
+
try {
|
|
152
|
+
parsed = JSON.parse(body);
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
return "the invoice block is not valid JSON";
|
|
156
|
+
}
|
|
157
|
+
return invoicePart(parsed);
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Lifts the one ```invoice block out of an agent's answer. An invoice must be
|
|
161
|
+
* the only part of its message, so unlike buttons it is never attached to
|
|
162
|
+
* surrounding words; the words around it stay in `text` for `answerMessages`
|
|
163
|
+
* to send as their own Message(s) first. More than one invoice block, or an
|
|
164
|
+
* invoice alongside a buttons or selection block, is a conflict: the text is
|
|
165
|
+
* returned untouched with `error` set, the same handling selection uses for
|
|
166
|
+
* selection+buttons.
|
|
167
|
+
*/
|
|
168
|
+
export const splitInvoice = (answer) => {
|
|
169
|
+
const matches = [...answer.matchAll(FENCE)];
|
|
170
|
+
if (!matches.length)
|
|
171
|
+
return { text: answer };
|
|
172
|
+
if (matches.length !== 1 || BUTTONS_OR_SELECTION_FENCE.test(answer)) {
|
|
173
|
+
return { text: answer, error: "send one invoice and nothing else in the same message" };
|
|
174
|
+
}
|
|
175
|
+
const match = matches[0];
|
|
176
|
+
const parsed = parseInvoiceBlock(match[2] ?? "");
|
|
177
|
+
if (typeof parsed === "string")
|
|
178
|
+
return { text: answer, error: parsed };
|
|
179
|
+
const before = answer.slice(0, match.index).trimEnd();
|
|
180
|
+
const after = answer.slice(match.index + match[0].length).trimStart();
|
|
181
|
+
const text = [before, after].filter(Boolean).join("\n\n");
|
|
182
|
+
return { text, invoice: parsed };
|
|
183
|
+
};
|
|
184
|
+
//# sourceMappingURL=invoice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoice.js","sourceRoot":"","sources":["../src/invoice.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC;AAEvC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,8HAA8H;IAC9H,mSAAmS;IACnS,wGAAwG;IACxG,wIAAwI;IACxI,qIAAqI;IACrI,+FAA+F;IAC/F,0JAA0J;CAC3J,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEZ;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GACpC,6EAA6E,GAAG,aAAa,GAAG,IAAI;MAClG,yFAAyF;MACzF,qGAAqG;MACrG,sFAAsF;MACtF,0FAA0F,CAAC;AAE/F;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,qBAAqB;IACrB,gBAAgB;IAChB,iBAAiB;IACjB,mBAAmB;IACnB,oBAAoB;CACZ,CAAC;AACX,MAAM,aAAa,GAAwB,IAAI,GAAG,CAAC,sBAAsB,CAAC,CAAC;AAE3E,8EAA8E;AAC9E,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAC3C,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAC7C,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAC5C,2FAA2F;AAC3F,MAAM,CAAC,MAAM,2BAA2B,GAAiD;IACvF,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,GAAG;IACT,K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,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IACvE,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;IACtD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,CAAC;IACtE,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AACnC,CAAC,CAAC"}
|
package/dist/links.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { LinkPart, MessagePart, TextPart } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* How a text-only agent sends a link: the URL alone on its own line, the way
|
|
4
|
+
* a person pastes one into Messages and the way Linq's iMessage guide asks for
|
|
5
|
+
* it ("put a single URL on its own line"). The line leaves the words and goes
|
|
6
|
+
* out as a `link` part in its own Message, which the server requires and the
|
|
7
|
+
* app draws as a card. The same words for every bridge that sends the agent's
|
|
8
|
+
* final text for it.
|
|
9
|
+
*/
|
|
10
|
+
export declare const LINK_LINE_INSTRUCTION = "To send a link, put its URL alone on its own line. That line leaves your text and is sent as its own Message, in order with your words, and drawn as a card with the page's title and image.";
|
|
11
|
+
/** The server's limit for a link part's URL (contracts/relay-v1-openapi.yaml). */
|
|
12
|
+
export declare const LINK_URL_MAX_LENGTH = 2048;
|
|
13
|
+
/** Relay takes 1 to 255 characters for an idempotency key. */
|
|
14
|
+
export declare const IDEMPOTENCY_KEY_MAX_LENGTH = 255;
|
|
15
|
+
/**
|
|
16
|
+
* The URL a line carries when the line is nothing but one absolute HTTP or
|
|
17
|
+
* HTTPS URL; otherwise undefined. A URL inside a sentence stays words.
|
|
18
|
+
*/
|
|
19
|
+
export declare const standaloneLink: (line: string) => string | undefined;
|
|
20
|
+
export type AnswerSegment = TextPart | LinkPart;
|
|
21
|
+
/**
|
|
22
|
+
* Splits an answer into its words and the links written alone on a line, in
|
|
23
|
+
* order. Text on either side of a link keeps its own line breaks, trimmed at
|
|
24
|
+
* the edges; an answer with no such line comes back as one text segment,
|
|
25
|
+
* untouched.
|
|
26
|
+
*/
|
|
27
|
+
export declare const splitLinks: (text: string) => AnswerSegment[];
|
|
28
|
+
export interface AnswerMessages {
|
|
29
|
+
/** The Messages the answer becomes, in order; each is one parts array. */
|
|
30
|
+
messages: MessagePart[][];
|
|
31
|
+
/** Why a component block could not be used. The text then keeps it. */
|
|
32
|
+
error?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The Messages a text-only agent's answer becomes: an invoice, buttons or
|
|
36
|
+
* selection block is lifted out, then each link on its own line becomes its
|
|
37
|
+
* own Message. Buttons and selection accompany the last Message of words; an
|
|
38
|
+
* invoice never does — it must be the only part of its Message, so the words
|
|
39
|
+
* around it are sent first and the invoice follows as its own, final Message.
|
|
40
|
+
* Selection requires a nonblank question; conflicting components remain text
|
|
41
|
+
* with an error.
|
|
42
|
+
*/
|
|
43
|
+
export declare const answerMessages: (answer: string) => AnswerMessages;
|
|
44
|
+
/**
|
|
45
|
+
* The idempotency key for the `index`th Message of one answer: the answer's
|
|
46
|
+
* own key for the first, and that key with the index for the rest, kept
|
|
47
|
+
* within Relay's 255 characters.
|
|
48
|
+
*/
|
|
49
|
+
export declare const indexedIdempotencyKey: (key: string, index: number) => string;
|
|
50
|
+
//# sourceMappingURL=links.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAe,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE/E;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,iMAC8J,CAAC;AAEjM,kFAAkF;AAClF,eAAO,MAAM,mBAAmB,OAAQ,CAAC;AAEzC,8DAA8D;AAC9D,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,KAAG,MAAM,GAAG,SAUtD,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,KAAG,aAAa,EAsBtD,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,QAAQ,EAAE,WAAW,EAAE,EAAE,CAAC;IAC1B,uEAAuE;IACvE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,KAAG,cA+B/C,CAAC;AAYF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,KAAK,MAAM,EAAE,OAAO,MAAM,KAAG,MAIlE,CAAC"}
|
package/dist/links.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { splitButtons } from "./buttons.js";
|
|
2
|
+
import { splitInvoice } from "./invoice.js";
|
|
3
|
+
import { splitSelection } from "./selection.js";
|
|
4
|
+
/**
|
|
5
|
+
* How a text-only agent sends a link: the URL alone on its own line, the way
|
|
6
|
+
* a person pastes one into Messages and the way Linq's iMessage guide asks for
|
|
7
|
+
* it ("put a single URL on its own line"). The line leaves the words and goes
|
|
8
|
+
* out as a `link` part in its own Message, which the server requires and the
|
|
9
|
+
* app draws as a card. The same words for every bridge that sends the agent's
|
|
10
|
+
* final text for it.
|
|
11
|
+
*/
|
|
12
|
+
export const LINK_LINE_INSTRUCTION = "To send a link, put its URL alone on its own line. That line leaves your text and is sent as its own Message, in order with your words, and drawn as a card with the page's title and image.";
|
|
13
|
+
/** The server's limit for a link part's URL (contracts/relay-v1-openapi.yaml). */
|
|
14
|
+
export const LINK_URL_MAX_LENGTH = 2_048;
|
|
15
|
+
/** Relay takes 1 to 255 characters for an idempotency key. */
|
|
16
|
+
export const IDEMPOTENCY_KEY_MAX_LENGTH = 255;
|
|
17
|
+
/**
|
|
18
|
+
* The URL a line carries when the line is nothing but one absolute HTTP or
|
|
19
|
+
* HTTPS URL; otherwise undefined. A URL inside a sentence stays words.
|
|
20
|
+
*/
|
|
21
|
+
export const standaloneLink = (line) => {
|
|
22
|
+
const value = line.trim();
|
|
23
|
+
if (!/^https?:\/\/\S+$/iu.test(value) || value.length > LINK_URL_MAX_LENGTH)
|
|
24
|
+
return undefined;
|
|
25
|
+
try {
|
|
26
|
+
const url = new URL(value);
|
|
27
|
+
if ((url.protocol !== "http:" && url.protocol !== "https:") || !url.hostname)
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
return value;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Splits an answer into its words and the links written alone on a line, in
|
|
37
|
+
* order. Text on either side of a link keeps its own line breaks, trimmed at
|
|
38
|
+
* the edges; an answer with no such line comes back as one text segment,
|
|
39
|
+
* untouched.
|
|
40
|
+
*/
|
|
41
|
+
export const splitLinks = (text) => {
|
|
42
|
+
const segments = [];
|
|
43
|
+
let words = [];
|
|
44
|
+
const flush = () => {
|
|
45
|
+
const value = words.join("\n").trim();
|
|
46
|
+
if (value)
|
|
47
|
+
segments.push({ type: "text", value });
|
|
48
|
+
words = [];
|
|
49
|
+
};
|
|
50
|
+
for (const line of text.split(/\r?\n/u)) {
|
|
51
|
+
const link = standaloneLink(line);
|
|
52
|
+
if (link === undefined) {
|
|
53
|
+
words.push(line);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
flush();
|
|
57
|
+
segments.push({ type: "link", value: link });
|
|
58
|
+
}
|
|
59
|
+
if (!segments.some((segment) => segment.type === "link")) {
|
|
60
|
+
return text.length > 0 ? [{ type: "text", value: text }] : [];
|
|
61
|
+
}
|
|
62
|
+
flush();
|
|
63
|
+
return segments;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* The Messages a text-only agent's answer becomes: an invoice, buttons or
|
|
67
|
+
* selection block is lifted out, then each link on its own line becomes its
|
|
68
|
+
* own Message. Buttons and selection accompany the last Message of words; an
|
|
69
|
+
* invoice never does — it must be the only part of its Message, so the words
|
|
70
|
+
* around it are sent first and the invoice follows as its own, final Message.
|
|
71
|
+
* Selection requires a nonblank question; conflicting components remain text
|
|
72
|
+
* with an error.
|
|
73
|
+
*/
|
|
74
|
+
export const answerMessages = (answer) => {
|
|
75
|
+
const invoiced = splitInvoice(answer);
|
|
76
|
+
if (invoiced.error) {
|
|
77
|
+
// The block stays in the words, but a link still travels alone; a bad
|
|
78
|
+
// component must not also take the person's link cards away.
|
|
79
|
+
return { messages: splitLinks(answer).map((segment) => [segment]), error: invoiced.error };
|
|
80
|
+
}
|
|
81
|
+
if (invoiced.invoice) {
|
|
82
|
+
const messages = splitLinks(invoiced.text).map((segment) => [segment]);
|
|
83
|
+
messages.push([invoiced.invoice]);
|
|
84
|
+
return { messages };
|
|
85
|
+
}
|
|
86
|
+
const selected = splitSelection(answer);
|
|
87
|
+
if (selected.error) {
|
|
88
|
+
// The block stays in the words, but a link still travels alone; a bad
|
|
89
|
+
// component must not also take the person's link cards away.
|
|
90
|
+
return { messages: splitLinks(answer).map((segment) => [segment]), error: selected.error };
|
|
91
|
+
}
|
|
92
|
+
if (selected.selection) {
|
|
93
|
+
const messages = splitLinks(selected.text).map((segment) => [segment]);
|
|
94
|
+
const prompt = messages.findLast((parts) => parts[0]?.type === "text" && parts[0].value.trim());
|
|
95
|
+
if (!prompt) {
|
|
96
|
+
return { messages: [[{ type: "text", value: answer }]], error: "selection needs a nonblank text prompt" };
|
|
97
|
+
}
|
|
98
|
+
prompt.push(selected.selection);
|
|
99
|
+
return { messages };
|
|
100
|
+
}
|
|
101
|
+
const { text, buttons, error } = splitButtons(answer);
|
|
102
|
+
const messages = splitLinks(text).map((segment) => [segment]);
|
|
103
|
+
if (buttons)
|
|
104
|
+
attachButtons(messages, buttons);
|
|
105
|
+
return error ? { messages, error } : { messages };
|
|
106
|
+
};
|
|
107
|
+
const attachButtons = (messages, buttons) => {
|
|
108
|
+
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
109
|
+
if (messages[index]?.[0]?.type === "text") {
|
|
110
|
+
messages[index].push(buttons);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
messages.push([buttons]);
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* The idempotency key for the `index`th Message of one answer: the answer's
|
|
118
|
+
* own key for the first, and that key with the index for the rest, kept
|
|
119
|
+
* within Relay's 255 characters.
|
|
120
|
+
*/
|
|
121
|
+
export const indexedIdempotencyKey = (key, index) => {
|
|
122
|
+
if (index === 0)
|
|
123
|
+
return key;
|
|
124
|
+
const suffix = `-${index}`;
|
|
125
|
+
return `${key.slice(0, IDEMPOTENCY_KEY_MAX_LENGTH - suffix.length)}${suffix}`;
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=links.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"links.js","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAChC,8LAA8L,CAAC;AAEjM,kFAAkF;AAClF,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAEzC,8DAA8D;AAC9D,MAAM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AAC,CAAC,CAAC;IAC/E,IAAI,OAAO;QAAE,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC9C,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;AACpD,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,QAAyB,EAAE,OAAoB,EAAQ,EAAE;IAC9E,KAAK,IAAI,KAAK,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAC7D,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,KAAK,MAAM,EAAE,CAAC;YAC1C,QAAQ,CAAC,KAAK,CAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC/B,OAAO;QACT,CAAC;IACH,CAAC;IACD,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AAC3B,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,GAAW,EAAE,KAAa,EAAU,EAAE;IAC1E,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IAC5B,MAAM,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;IAC3B,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,0BAA0B,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAAC;AAChF,CAAC,CAAC"}
|
package/dist/operations.d.ts
CHANGED
|
@@ -35,6 +35,18 @@ export declare const RELAY_V1_OPERATIONS: readonly [{
|
|
|
35
35
|
readonly method: "POST";
|
|
36
36
|
readonly path: "/v1/chats/{chatId}/leave";
|
|
37
37
|
readonly operationId: "leaveChat";
|
|
38
|
+
}, {
|
|
39
|
+
readonly method: "GET";
|
|
40
|
+
readonly path: "/v1/chats/{chatId}/activity";
|
|
41
|
+
readonly operationId: "getActivity";
|
|
42
|
+
}, {
|
|
43
|
+
readonly method: "PUT";
|
|
44
|
+
readonly path: "/v1/chats/{chatId}/activity";
|
|
45
|
+
readonly operationId: "setActivity";
|
|
46
|
+
}, {
|
|
47
|
+
readonly method: "DELETE";
|
|
48
|
+
readonly path: "/v1/chats/{chatId}/activity";
|
|
49
|
+
readonly operationId: "clearActivity";
|
|
38
50
|
}, {
|
|
39
51
|
readonly method: "POST";
|
|
40
52
|
readonly path: "/v1/chats/{chatId}/typing";
|
|
@@ -79,6 +91,10 @@ export declare const RELAY_V1_OPERATIONS: readonly [{
|
|
|
79
91
|
readonly method: "POST";
|
|
80
92
|
readonly path: "/v1/messages/{messageId}/reactions";
|
|
81
93
|
readonly operationId: "sendReaction";
|
|
94
|
+
}, {
|
|
95
|
+
readonly method: "PUT";
|
|
96
|
+
readonly path: "/v1/messages/{messageId}/invoice";
|
|
97
|
+
readonly operationId: "updateInvoiceStatus";
|
|
82
98
|
}, {
|
|
83
99
|
readonly method: "POST";
|
|
84
100
|
readonly path: "/v1/attachments";
|
|
@@ -127,6 +143,10 @@ export declare const RELAY_V1_OPERATIONS: readonly [{
|
|
|
127
143
|
readonly method: "DELETE";
|
|
128
144
|
readonly path: "/v1/webhook-subscriptions/{subscriptionId}";
|
|
129
145
|
readonly operationId: "deleteWebhookSubscription";
|
|
146
|
+
}, {
|
|
147
|
+
readonly method: "POST";
|
|
148
|
+
readonly path: "/v1/contacts/lookup";
|
|
149
|
+
readonly operationId: "lookupContact";
|
|
130
150
|
}, {
|
|
131
151
|
readonly method: "GET";
|
|
132
152
|
readonly path: "/v1/contact_card";
|
|
@@ -151,34 +171,10 @@ export declare const RELAY_V1_OPERATIONS: readonly [{
|
|
|
151
171
|
readonly method: "GET";
|
|
152
172
|
readonly path: "/v1/calls/{callId}";
|
|
153
173
|
readonly operationId: "getCall";
|
|
154
|
-
}, {
|
|
155
|
-
readonly method: "POST";
|
|
156
|
-
readonly path: "/v1/calls/{callId}/accept";
|
|
157
|
-
readonly operationId: "acceptCall";
|
|
158
|
-
}, {
|
|
159
|
-
readonly method: "POST";
|
|
160
|
-
readonly path: "/v1/calls/{callId}/decline";
|
|
161
|
-
readonly operationId: "declineCall";
|
|
162
174
|
}, {
|
|
163
175
|
readonly method: "POST";
|
|
164
176
|
readonly path: "/v1/calls/{callId}/end";
|
|
165
177
|
readonly operationId: "endCall";
|
|
166
|
-
}, {
|
|
167
|
-
readonly method: "POST";
|
|
168
|
-
readonly path: "/v1/calls/{callId}/connected";
|
|
169
|
-
readonly operationId: "markCallConnected";
|
|
170
|
-
}, {
|
|
171
|
-
readonly method: "POST";
|
|
172
|
-
readonly path: "/v1/calls/{callId}/connections";
|
|
173
|
-
readonly operationId: "createCallConnection";
|
|
174
|
-
}, {
|
|
175
|
-
readonly method: "POST";
|
|
176
|
-
readonly path: "/v1/calls/{callId}/connections/{connectionId}/subscribe";
|
|
177
|
-
readonly operationId: "subscribeCallAudio";
|
|
178
|
-
}, {
|
|
179
|
-
readonly method: "POST";
|
|
180
|
-
readonly path: "/v1/calls/{callId}/connections/{connectionId}/renegotiate";
|
|
181
|
-
readonly operationId: "renegotiateCallAudio";
|
|
182
178
|
}];
|
|
183
179
|
export declare const RELAY_WEBHOOK_EVENT_TYPES: readonly ["message.sent", "message.received", "message.read", "message.delivered", "message.failed", "reaction.added", "reaction.removed", "participant.added", "participant.removed", "chat.created", "chat.group_name_updated", "chat.group_icon_updated", "chat.typing_indicator.started", "chat.typing_indicator.stopped", "contact.added", "contact.removed", "call.created", "call.updated", "call.ended"];
|
|
184
180
|
//# sourceMappingURL=operations.d.ts.map
|
package/dist/operations.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC7D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,eAAO,MAAM,mBAAmB
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC7D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwNgB,CAAC;AAEjD,eAAO,MAAM,yBAAyB,kZAoB5B,CAAC"}
|
package/dist/operations.js
CHANGED
|
@@ -39,6 +39,21 @@ export const RELAY_V1_OPERATIONS = [
|
|
|
39
39
|
"path": "/v1/chats/{chatId}/leave",
|
|
40
40
|
"operationId": "leaveChat"
|
|
41
41
|
},
|
|
42
|
+
{
|
|
43
|
+
"method": "GET",
|
|
44
|
+
"path": "/v1/chats/{chatId}/activity",
|
|
45
|
+
"operationId": "getActivity"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"method": "PUT",
|
|
49
|
+
"path": "/v1/chats/{chatId}/activity",
|
|
50
|
+
"operationId": "setActivity"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"method": "DELETE",
|
|
54
|
+
"path": "/v1/chats/{chatId}/activity",
|
|
55
|
+
"operationId": "clearActivity"
|
|
56
|
+
},
|
|
42
57
|
{
|
|
43
58
|
"method": "POST",
|
|
44
59
|
"path": "/v1/chats/{chatId}/typing",
|
|
@@ -94,6 +109,11 @@ export const RELAY_V1_OPERATIONS = [
|
|
|
94
109
|
"path": "/v1/messages/{messageId}/reactions",
|
|
95
110
|
"operationId": "sendReaction"
|
|
96
111
|
},
|
|
112
|
+
{
|
|
113
|
+
"method": "PUT",
|
|
114
|
+
"path": "/v1/messages/{messageId}/invoice",
|
|
115
|
+
"operationId": "updateInvoiceStatus"
|
|
116
|
+
},
|
|
97
117
|
{
|
|
98
118
|
"method": "POST",
|
|
99
119
|
"path": "/v1/attachments",
|
|
@@ -154,6 +174,11 @@ export const RELAY_V1_OPERATIONS = [
|
|
|
154
174
|
"path": "/v1/webhook-subscriptions/{subscriptionId}",
|
|
155
175
|
"operationId": "deleteWebhookSubscription"
|
|
156
176
|
},
|
|
177
|
+
{
|
|
178
|
+
"method": "POST",
|
|
179
|
+
"path": "/v1/contacts/lookup",
|
|
180
|
+
"operationId": "lookupContact"
|
|
181
|
+
},
|
|
157
182
|
{
|
|
158
183
|
"method": "GET",
|
|
159
184
|
"path": "/v1/contact_card",
|
|
@@ -184,40 +209,10 @@ export const RELAY_V1_OPERATIONS = [
|
|
|
184
209
|
"path": "/v1/calls/{callId}",
|
|
185
210
|
"operationId": "getCall"
|
|
186
211
|
},
|
|
187
|
-
{
|
|
188
|
-
"method": "POST",
|
|
189
|
-
"path": "/v1/calls/{callId}/accept",
|
|
190
|
-
"operationId": "acceptCall"
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
"method": "POST",
|
|
194
|
-
"path": "/v1/calls/{callId}/decline",
|
|
195
|
-
"operationId": "declineCall"
|
|
196
|
-
},
|
|
197
212
|
{
|
|
198
213
|
"method": "POST",
|
|
199
214
|
"path": "/v1/calls/{callId}/end",
|
|
200
215
|
"operationId": "endCall"
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
"method": "POST",
|
|
204
|
-
"path": "/v1/calls/{callId}/connected",
|
|
205
|
-
"operationId": "markCallConnected"
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
"method": "POST",
|
|
209
|
-
"path": "/v1/calls/{callId}/connections",
|
|
210
|
-
"operationId": "createCallConnection"
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
"method": "POST",
|
|
214
|
-
"path": "/v1/calls/{callId}/connections/{connectionId}/subscribe",
|
|
215
|
-
"operationId": "subscribeCallAudio"
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
"method": "POST",
|
|
219
|
-
"path": "/v1/calls/{callId}/connections/{connectionId}/renegotiate",
|
|
220
|
-
"operationId": "renegotiateCallAudio"
|
|
221
216
|
}
|
|
222
217
|
];
|
|
223
218
|
export const RELAY_WEBHOOK_EVENT_TYPES = [
|
package/dist/operations.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC;QACE,QAAQ,EAAE,QAAQ;QAClB,MAAM,EAAE,qBAAqB;QAC7B,aAAa,EAAE,aAAa;KAC7B;IACD;QACE,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,WAAW;QACnB,aAAa,EAAE,YAAY;KAC5B;IACD;QACE,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,WAAW;QACnB,aAAa,EAAE,WAAW;KAC3B;IACD;QACE,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,oBAAoB;QAC5B,aAAa,EAAE,SAAS;KACzB;IACD;QACE,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,oBAAoB;QAC5B,aAAa,EAAE,YAAY;KAC5B;IACD;QACE,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,iCAAiC;QACzC,aAAa,EAAE,gBAAgB;KAChC;IACD;QACE,QAAQ,EAAE,QAA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D;QACE,QAAQ,EAAE,OAAO;QACjB,MAAM,EAAE,kBAAkB;QAC1B,aAAa,EAAE,mBAAmB;KACnC;IACD;QACE,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,0BAA0B;QAClC,aAAa,EAAE,YAAY;KAC5B;IACD;QACE,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,0BAA0B;QAClC,aAAa,EAAE,WAAW;KAC3B;IACD;QACE,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,oBAAoB;QAC5B,aAAa,EAAE,SAAS;KACzB;IACD;QACE,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,wBAAwB;QAChC,aAAa,EAAE,SAAS;KACzB;CAC6C,CAAC;AAEjD,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,cAAc;IACd,kBAAkB;IAClB,cAAc;IACd,mBAAmB;IACnB,gBAAgB;IAChB,gBAAgB;IAChB,kBAAkB;IAClB,mBAAmB;IACnB,qBAAqB;IACrB,cAAc;IACd,yBAAyB;IACzB,yBAAyB;IACzB,+BAA+B;IAC/B,+BAA+B;IAC/B,eAAe;IACf,iBAAiB;IACjB,cAAc;IACd,cAAc;IACd,YAAY;CACJ,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { MessagePartResponse, ReplyTo, SelectionPart, TextPart } from "./types.js";
|
|
2
|
+
/** Selection authoring uses explicit stable values, never label-derived IDs. */
|
|
3
|
+
export declare const SELECTION_MAX_OPTIONS = 25;
|
|
4
|
+
export declare const SELECTION_LABEL_MAX_LENGTH = 80;
|
|
5
|
+
export declare const SELECTION_VALUE_MAX_LENGTH = 100;
|
|
6
|
+
export declare const SELECTION_FENCE = "selection";
|
|
7
|
+
export declare const SELECTION_GUIDANCE: string;
|
|
8
|
+
export declare const SELECTION_BLOCK_INSTRUCTION: string;
|
|
9
|
+
/** Structured response discovery, never reconstructed by splitting visible labels. */
|
|
10
|
+
export interface SelectionReply {
|
|
11
|
+
selected_values: string[];
|
|
12
|
+
reply_to: ReplyTo & {
|
|
13
|
+
part_index: number;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export declare const selectionReply: (parts: readonly MessagePartResponse[], replyTo?: ReplyTo | null) => SelectionReply | undefined;
|
|
17
|
+
/** The most agent context one Message may add beside its visible text. */
|
|
18
|
+
export declare const SELECTION_CONTEXT_MAX_LENGTH = 10000;
|
|
19
|
+
/** The parts a runtime cannot show as words: components, and any future rich part. */
|
|
20
|
+
export declare const componentParts: (parts: readonly MessagePartResponse[]) => MessagePartResponse[];
|
|
21
|
+
/** Agent-context data only, not additional user-visible Message text or instructions. */
|
|
22
|
+
export declare const selectionReplyContext: (reply: SelectionReply | undefined, message?: {
|
|
23
|
+
parts: readonly MessagePartResponse[];
|
|
24
|
+
reply_to?: ReplyTo | null;
|
|
25
|
+
}) => string;
|
|
26
|
+
/** Validate an options array or complete request part. Output fields are not accepted. */
|
|
27
|
+
export declare const selectionPart: (parsed: unknown) => SelectionPart | string;
|
|
28
|
+
export declare const parseSelectionBlock: (body: string) => SelectionPart | string;
|
|
29
|
+
export interface SplitSelection {
|
|
30
|
+
text: string;
|
|
31
|
+
selection?: SelectionPart;
|
|
32
|
+
error?: string;
|
|
33
|
+
}
|
|
34
|
+
/** Invalid or conflicting blocks remain readable text; no partially valid component is sent. */
|
|
35
|
+
export declare const splitSelection: (answer: string) => SplitSelection;
|
|
36
|
+
/** Construct a complete prompt, without truncating labels, values, or the question. */
|
|
37
|
+
export declare const partsWithSelection: (text: string, selection: SelectionPart) => [TextPart, SelectionPart];
|
|
38
|
+
//# sourceMappingURL=selection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection.d.ts","sourceRoot":"","sources":["../src/selection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,OAAO,EAAmB,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEzG,gFAAgF;AAChF,eAAO,MAAM,q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