spectrum-ts 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{attachment-B4nSrKVd.d.ts → attachment-WePAHfcH.d.ts} +1 -1
- package/dist/{authoring-BjE5BvlO.d.ts → authoring-DDh3muGT.d.ts} +61 -26
- package/dist/authoring.d.ts +3 -3
- package/dist/authoring.js +5 -5
- package/dist/{chunk-NNY6LMSC.js → chunk-77U6SH5A.js} +1 -1
- package/dist/{chunk-ATNAE7OR.js → chunk-AYCMTRVC.js} +549 -76
- package/dist/{chunk-6BI4PFTP.js → chunk-CHY5YLLV.js} +1 -1
- package/dist/{chunk-U3LXXT3W.js → chunk-EZ5SNNFS.js} +20 -8
- package/dist/{chunk-WXY5QP3M.js → chunk-FULEQIRQ.js} +27 -21
- package/dist/{chunk-2ILTJC35.js → chunk-LQMDV75O.js} +205 -11
- package/dist/{chunk-NGC4DJIX.js → chunk-LX437ZTY.js} +416 -135
- package/dist/{chunk-3B4QH4JG.js → chunk-MHGCPC2V.js} +1 -1
- package/dist/{chunk-U7AWXDH6.js → chunk-NZ5WCMTY.js} +1 -1
- package/dist/{chunk-5LT5J3NR.js → chunk-TXRWKSNH.js} +262 -30
- package/dist/{chunk-Q537JPTG.js → chunk-UXJ5OO6P.js} +10 -10
- package/dist/index.d.ts +107 -56
- package/dist/index.js +29 -182
- package/dist/providers/imessage/index.d.ts +6 -14
- package/dist/providers/imessage/index.js +6 -6
- package/dist/providers/index.d.ts +3 -3
- package/dist/providers/index.js +11 -11
- package/dist/providers/slack/index.d.ts +1 -2
- package/dist/providers/slack/index.js +3 -3
- package/dist/providers/telegram/index.d.ts +3 -5
- package/dist/providers/telegram/index.js +5 -5
- package/dist/providers/terminal/index.d.ts +2 -4
- package/dist/providers/terminal/index.js +5 -5
- package/dist/providers/whatsapp-business/index.d.ts +1 -1
- package/dist/providers/whatsapp-business/index.js +4 -4
- package/dist/{types-BD0-kKyv.d.ts → types-BujGKBin.d.ts} +1 -1
- package/dist/{types-Bje8aq1k.d.ts → types-YqCNUDIt.d.ts} +171 -23
- package/package.json +2 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import './attachment-
|
|
1
|
+
import './attachment-WePAHfcH.js';
|
|
2
2
|
import vCard from 'vcf';
|
|
3
3
|
import z__default from 'zod';
|
|
4
|
-
import { U as User, C as ContentBuilder, M as Message, e as Space, h as ContentInput } from './types-
|
|
4
|
+
import { U as User, C as ContentBuilder, M as Message, e as Space, h as ContentInput } from './types-YqCNUDIt.js';
|
|
5
5
|
|
|
6
6
|
declare const nameSchema: z__default.ZodObject<{
|
|
7
7
|
formatted: z__default.ZodOptional<z__default.ZodString>;
|
|
@@ -140,6 +140,43 @@ declare const asGroup: (input: {
|
|
|
140
140
|
}) => Group;
|
|
141
141
|
declare function group(...items: [ContentInput, ContentInput, ...ContentInput[]]): ContentBuilder;
|
|
142
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Maps one chunk emitted by a stream to the incremental text it carries.
|
|
145
|
+
* Return a string to emit, or `null`/`undefined` to skip the chunk (e.g. for
|
|
146
|
+
* control events that carry no text).
|
|
147
|
+
*/
|
|
148
|
+
type DeltaExtractor<T> = (chunk: T) => string | null | undefined;
|
|
149
|
+
/**
|
|
150
|
+
* Anything the stream overloads of `text()` and `markdown()` accept as a
|
|
151
|
+
* source. The builder normalizes all of these to an internal
|
|
152
|
+
* `AsyncIterable<string>` of text deltas:
|
|
153
|
+
*
|
|
154
|
+
* - the Vercel AI SDK `streamText()` result (its `.textStream` is picked up
|
|
155
|
+
* automatically — pass either the whole result or `.textStream` directly),
|
|
156
|
+
* - a raw `AsyncIterable<T>` (e.g. an OpenAI / Anthropic streaming response),
|
|
157
|
+
* - a raw `ReadableStream<T>` of chunks.
|
|
158
|
+
*/
|
|
159
|
+
type StreamTextSource<T = unknown> = {
|
|
160
|
+
textStream: AsyncIterable<string> | ReadableStream<string>;
|
|
161
|
+
} | AsyncIterable<T> | ReadableStream<T>;
|
|
162
|
+
interface TextStreamOptions<T = unknown> {
|
|
163
|
+
/**
|
|
164
|
+
* Map each chunk to its incremental text. Omit to rely on built-in
|
|
165
|
+
* auto-detection of the common SDK shapes (OpenAI chat/responses, Anthropic
|
|
166
|
+
* messages, AI SDK text streams, and plain strings).
|
|
167
|
+
*/
|
|
168
|
+
extract?: DeltaExtractor<T>;
|
|
169
|
+
}
|
|
170
|
+
declare const streamTextSchema: z__default.ZodObject<{
|
|
171
|
+
type: z__default.ZodLiteral<"streamText">;
|
|
172
|
+
stream: z__default.ZodCustom<() => AsyncIterable<string>, () => AsyncIterable<string>>;
|
|
173
|
+
format: z__default.ZodOptional<z__default.ZodEnum<{
|
|
174
|
+
markdown: "markdown";
|
|
175
|
+
plain: "plain";
|
|
176
|
+
}>>;
|
|
177
|
+
}, z__default.core.$strip>;
|
|
178
|
+
type StreamText = z__default.infer<typeof streamTextSchema>;
|
|
179
|
+
|
|
143
180
|
declare const pollChoiceSchema: z__default.ZodObject<{
|
|
144
181
|
title: z__default.ZodString;
|
|
145
182
|
}, z__default.core.$strip>;
|
|
@@ -185,28 +222,6 @@ declare const option: (title: string) => PollChoice;
|
|
|
185
222
|
declare function poll(title: string, options: PollChoiceInput[]): ContentBuilder;
|
|
186
223
|
declare function poll(title: string, ...options: PollChoiceInput[]): ContentBuilder;
|
|
187
224
|
|
|
188
|
-
declare const reactionSchema: z__default.ZodObject<{
|
|
189
|
-
type: z__default.ZodLiteral<"reaction">;
|
|
190
|
-
emoji: z__default.ZodString;
|
|
191
|
-
target: z__default.ZodCustom<Message<string, User, Space<unknown>>, Message<string, User, Space<unknown>>>;
|
|
192
|
-
}, z__default.core.$strip>;
|
|
193
|
-
type Reaction = z__default.infer<typeof reactionSchema>;
|
|
194
|
-
declare const asReaction: (input: {
|
|
195
|
-
emoji: string;
|
|
196
|
-
target: Message;
|
|
197
|
-
}) => Reaction;
|
|
198
|
-
/**
|
|
199
|
-
* Construct a `reaction` content value targeting the given message.
|
|
200
|
-
*
|
|
201
|
-
* `space.send(reaction(emoji, message))` is sugar for `message.react(emoji)`.
|
|
202
|
-
* Reactions are fire-and-forget — the returned `Message` will be `undefined`
|
|
203
|
-
* because platforms do not surface a message id for reactions.
|
|
204
|
-
*
|
|
205
|
-
* To react to a message known only by id, resolve it first via
|
|
206
|
-
* `space.getMessage(id)`.
|
|
207
|
-
*/
|
|
208
|
-
declare function reaction(emoji: string, target: Message): ContentBuilder;
|
|
209
|
-
|
|
210
225
|
declare const richlinkSchema: z__default.ZodObject<{
|
|
211
226
|
type: z__default.ZodLiteral<"richlink">;
|
|
212
227
|
url: z__default.ZodURL;
|
|
@@ -239,7 +254,27 @@ declare const textSchema: z__default.ZodObject<{
|
|
|
239
254
|
text: z__default.ZodString;
|
|
240
255
|
}, z__default.core.$strip>;
|
|
241
256
|
declare const asText: (text: string) => z__default.infer<typeof textSchema>;
|
|
242
|
-
|
|
257
|
+
/**
|
|
258
|
+
* Send plain text — a static string or a streaming LLM response.
|
|
259
|
+
*
|
|
260
|
+
* `text("hi")` sends one message. `text(source)` wraps a text stream so it
|
|
261
|
+
* can be sent like any other content; delivery is platform-specific —
|
|
262
|
+
* iMessage (remote) sends the first chunk as a real message and then edits it
|
|
263
|
+
* in place as more text arrives; Telegram (private chats) animates a native
|
|
264
|
+
* draft preview and persists the final text as one message. Platforms that
|
|
265
|
+
* can't stream wait for the stream to finish and deliver the accumulated text
|
|
266
|
+
* as one plain message.
|
|
267
|
+
*
|
|
268
|
+
* A stream source accepts whatever the popular SDKs return (the AI SDK
|
|
269
|
+
* `streamText()` result, OpenAI / Anthropic streaming responses, or any
|
|
270
|
+
* `AsyncIterable` / `ReadableStream`); pass `options.extract` for any chunk
|
|
271
|
+
* shape the built-in detection doesn't recognize. A stream can only be sent
|
|
272
|
+
* once. Options apply to stream sources only — they are ignored for strings.
|
|
273
|
+
*
|
|
274
|
+
* For text written in markdown, use `markdown()` instead.
|
|
275
|
+
*/
|
|
276
|
+
declare function text(source: string): ContentBuilder;
|
|
277
|
+
declare function text<T = unknown>(source: StreamTextSource<T>, options?: TextStreamOptions<T>): ContentBuilder;
|
|
243
278
|
|
|
244
279
|
declare const voiceSchema: z__default.ZodObject<{
|
|
245
280
|
type: z__default.ZodLiteral<"voice">;
|
|
@@ -266,4 +301,4 @@ declare function voice(input: VoiceInput, options?: {
|
|
|
266
301
|
duration?: number;
|
|
267
302
|
}): ContentBuilder;
|
|
268
303
|
|
|
269
|
-
export {
|
|
304
|
+
export { asVoice as A, type ContactInput as C, type DeltaExtractor as D, type Group as G, type Poll as P, type Richlink as R, type StreamTextSource as S, type TextStreamOptions as T, type Voice as V, type Contact as a, type ContactAddress as b, type ContactDetails as c, type ContactEmail as d, type ContactName as e, type ContactOrg as f, type ContactPhone as g, type PollChoice as h, type PollChoiceInput as i, type PollOption as j, type StreamText as k, contact as l, custom as m, group as n, option as o, poll as p, asContact as q, richlink as r, asCustom as s, text as t, asGroup as u, voice as v, asPoll as w, asPollOption as x, asRichlink as y, asText as z };
|
package/dist/authoring.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { c as asAttachment } from './attachment-
|
|
2
|
-
export {
|
|
3
|
-
export { d as ProviderMessageRecord } from './types-
|
|
1
|
+
export { c as asAttachment } from './attachment-WePAHfcH.js';
|
|
2
|
+
export { q as asContact, s as asCustom, u as asGroup, w as asPoll, x as asPollOption, y as asRichlink, z as asText, A as asVoice } from './authoring-DDh3muGT.js';
|
|
3
|
+
export { d as ProviderMessageRecord, $ as asReaction } from './types-YqCNUDIt.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import 'vcf';
|
|
6
6
|
import 'hotscript';
|
package/dist/authoring.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
asRichlink
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-CHY5YLLV.js";
|
|
5
5
|
import {
|
|
6
6
|
asGroup
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-MHGCPC2V.js";
|
|
8
8
|
import {
|
|
9
9
|
asVoice
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-77U6SH5A.js";
|
|
11
11
|
import {
|
|
12
12
|
asPoll,
|
|
13
13
|
asPollOption
|
|
14
14
|
} from "./chunk-2D27WW5B.js";
|
|
15
15
|
import {
|
|
16
16
|
asContact
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-NZ5WCMTY.js";
|
|
18
18
|
import "./chunk-6UZFVXQF.js";
|
|
19
19
|
import {
|
|
20
20
|
asAttachment,
|
|
21
21
|
asCustom,
|
|
22
22
|
asReaction,
|
|
23
23
|
asText
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-LQMDV75O.js";
|
|
25
25
|
export {
|
|
26
26
|
asAttachment,
|
|
27
27
|
asContact,
|