eve 0.29.2 → 0.29.3

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.
Files changed (178) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/src/channel/types.d.ts +15 -0
  3. package/dist/src/cli/commands/integration-setup.d.ts +3 -7
  4. package/dist/src/cli/commands/integration-setup.js +1 -1
  5. package/dist/src/cli/commands/registry.d.ts +1 -0
  6. package/dist/src/cli/commands/registry.js +1 -1
  7. package/dist/src/cli/commands/trace.d.ts +7 -24
  8. package/dist/src/cli/commands/trace.js +7 -5
  9. package/dist/src/cli/dev/tui/blocks.js +1 -1
  10. package/dist/src/cli/dev/tui/clipboard.d.ts +17 -0
  11. package/dist/src/cli/dev/tui/clipboard.js +1 -0
  12. package/dist/src/cli/dev/tui/command-typeahead.js +1 -1
  13. package/dist/src/cli/dev/tui/prompt-commands.d.ts +3 -0
  14. package/dist/src/cli/dev/tui/prompt-commands.js +1 -1
  15. package/dist/src/cli/dev/tui/remote-auth.js +1 -1
  16. package/dist/src/cli/dev/tui/runner.d.ts +6 -0
  17. package/dist/src/cli/dev/tui/runner.js +1 -1
  18. package/dist/src/cli/dev/tui/stream-format.d.ts +8 -0
  19. package/dist/src/cli/dev/tui/stream-format.js +1 -1
  20. package/dist/src/cli/dev/tui/terminal-renderer.d.ts +3 -0
  21. package/dist/src/cli/dev/tui/terminal-renderer.js +12 -12
  22. package/dist/src/cli/dev/tui/test/mock-terminal.js +3 -3
  23. package/dist/src/cli/dev/tui/traces/trace-content.d.ts +28 -0
  24. package/dist/src/cli/dev/tui/traces/trace-content.js +2 -0
  25. package/dist/src/cli/dev/tui/traces/trace-conversation.d.ts +58 -0
  26. package/dist/src/cli/dev/tui/traces/trace-conversation.js +2 -0
  27. package/dist/src/cli/dev/tui/traces/trace-store.d.ts +27 -0
  28. package/dist/src/cli/dev/tui/traces/trace-store.js +1 -0
  29. package/dist/src/cli/dev/tui/traces/trace-view.d.ts +48 -0
  30. package/dist/src/cli/dev/tui/traces/trace-view.js +2 -0
  31. package/dist/src/cli/dev/tui/traces/trace-viewer-session.d.ts +41 -0
  32. package/dist/src/cli/dev/tui/traces/trace-viewer-session.js +1 -0
  33. package/dist/src/cli/dev/tui/traces/trace-viewer-state.d.ts +110 -0
  34. package/dist/src/cli/dev/tui/traces/trace-viewer-state.js +1 -0
  35. package/dist/src/cli/ui/alt-screen.d.ts +42 -0
  36. package/dist/src/cli/ui/alt-screen.js +1 -0
  37. package/dist/src/cli/ui/terminal-text.d.ts +4 -0
  38. package/dist/src/cli/ui/terminal-text.js +1 -1
  39. package/dist/src/compiled/.vendor-stamp.json +2 -1
  40. package/dist/src/compiled/@photon-ai/chat-adapter-imessage/LICENSE +21 -0
  41. package/dist/src/compiled/@photon-ai/chat-adapter-imessage/_spectrum-core.d.ts +3 -0
  42. package/dist/src/compiled/@photon-ai/chat-adapter-imessage/_spectrum-imessage.d.ts +2 -0
  43. package/dist/src/compiled/@photon-ai/chat-adapter-imessage/index.d.ts +496 -0
  44. package/dist/src/compiled/@photon-ai/chat-adapter-imessage/index.js +137 -0
  45. package/dist/src/compiled/@vercel/sandbox/index.js +13 -107
  46. package/dist/src/compiled/_chunks/node/auth-BS3UoyvT.js +2 -0
  47. package/dist/src/compiled/_chunks/node/compat-Dm2n85Mx.js +1 -0
  48. package/dist/src/compiled/_chunks/node/schemas-DtQwuPdM.js +65 -0
  49. package/dist/src/compiled/_chunks/node/undici-DWL_MYmT.js +95 -0
  50. package/dist/src/compiled/_chunks/node/version-Cztrk7z6.js +1 -0
  51. package/dist/src/compiled/shadcn-registry/index.js +461 -893
  52. package/dist/src/context/keys.d.ts +3 -1
  53. package/dist/src/context/keys.js +1 -1
  54. package/dist/src/execution/delegated-parent-notification.js +1 -1
  55. package/dist/src/execution/delegated-parent-result.js +1 -1
  56. package/dist/src/execution/dispatch-runtime-actions-step.js +1 -1
  57. package/dist/src/execution/runtime-context.js +1 -1
  58. package/dist/src/execution/sandbox/glob-tool.js +3 -3
  59. package/dist/src/execution/sandbox/grep-tool.js +1 -1
  60. package/dist/src/execution/sandbox/read-file-tool.js +3 -3
  61. package/dist/src/execution/sandbox/require-sandbox.d.ts +3 -3
  62. package/dist/src/execution/sandbox/require-sandbox.js +1 -1
  63. package/dist/src/execution/sandbox/write-file-tool.js +1 -1
  64. package/dist/src/execution/subagent-adapter-state.d.ts +39 -0
  65. package/dist/src/execution/subagent-adapter-state.js +1 -0
  66. package/dist/src/execution/subagent-adapter.d.ts +0 -34
  67. package/dist/src/execution/subagent-adapter.js +1 -1
  68. package/dist/src/execution/subagent-tool.d.ts +2 -1
  69. package/dist/src/execution/subagent-tool.js +1 -1
  70. package/dist/src/execution/workflow-steps.js +1 -1
  71. package/dist/src/harness/instrumentation-lifecycle.d.ts +18 -0
  72. package/dist/src/harness/instrumentation-native-events.d.ts +3 -1
  73. package/dist/src/harness/instrumentation-native-events.js +1 -1
  74. package/dist/src/harness/parent-lineage.d.ts +11 -0
  75. package/dist/src/harness/parent-lineage.js +1 -0
  76. package/dist/src/harness/tool-loop.js +2 -2
  77. package/dist/src/internal/application/package.js +1 -1
  78. package/dist/src/internal/nitro/host/local-tracing-runtime-plugin.js +1 -1
  79. package/dist/src/packages/eve-catalog/src/index.js +1 -1
  80. package/dist/src/public/channels/chat-sdk/chatSdkChannel.d.ts +7 -0
  81. package/dist/src/public/channels/chat-sdk/chatSdkChannel.js +2 -2
  82. package/dist/src/public/channels/photon/inboundContent.d.ts +4 -0
  83. package/dist/src/public/channels/photon/inboundContent.js +1 -0
  84. package/dist/src/public/channels/photon/index.d.ts +1 -0
  85. package/dist/src/public/channels/photon/index.js +1 -0
  86. package/dist/src/public/channels/photon/photonIMessageChannel.d.ts +54 -0
  87. package/dist/src/public/channels/photon/photonIMessageChannel.js +1 -0
  88. package/dist/src/runtime/channels/registry.js +1 -1
  89. package/dist/src/runtime/framework-tools/glob.js +1 -1
  90. package/dist/src/runtime/framework-tools/grep.js +1 -1
  91. package/dist/src/runtime/framework-tools/read-file.js +1 -1
  92. package/dist/src/runtime/framework-tools/write-file.js +1 -1
  93. package/dist/src/setup/boxes/resolve-provisioning.js +1 -1
  94. package/dist/src/setup/connect-provisioning.d.ts +32 -0
  95. package/dist/src/setup/connect-provisioning.js +1 -0
  96. package/dist/src/setup/flows/login.js +1 -1
  97. package/dist/src/setup/flows/registry.js +1 -1
  98. package/dist/src/setup/integrations/photon/connect.d.ts +40 -0
  99. package/dist/src/setup/integrations/photon/connect.js +1 -0
  100. package/dist/src/setup/integrations/photon/management.d.ts +34 -0
  101. package/dist/src/setup/integrations/photon/management.js +1 -0
  102. package/dist/src/setup/integrations/photon/setup-flow.d.ts +39 -0
  103. package/dist/src/setup/integrations/photon/setup-flow.js +20 -0
  104. package/dist/src/setup/integrations/photon/setup.d.ts +3 -0
  105. package/dist/src/setup/integrations/photon/setup.js +1 -0
  106. package/dist/src/setup/integrations/registry.d.ts +6 -0
  107. package/dist/src/setup/integrations/registry.js +1 -0
  108. package/dist/src/setup/integrations/runner.d.ts +25 -0
  109. package/dist/src/setup/integrations/runner.js +1 -0
  110. package/dist/src/setup/integrations/{channels → shared}/environment.d.ts +3 -3
  111. package/dist/src/setup/integrations/shared/environment.js +1 -0
  112. package/dist/src/setup/integrations/shared/scaffold.d.ts +19 -0
  113. package/dist/src/setup/integrations/shared/scaffold.js +1 -0
  114. package/dist/src/setup/integrations/{channels → shared}/ui.d.ts +3 -3
  115. package/dist/src/setup/integrations/shared/ui.js +2 -0
  116. package/dist/src/setup/integrations/slack/setup.d.ts +16 -0
  117. package/dist/src/setup/integrations/slack/setup.js +1 -0
  118. package/dist/src/setup/integrations/types.d.ts +26 -0
  119. package/dist/src/setup/integrations/web/setup.d.ts +3 -0
  120. package/dist/src/setup/integrations/web/setup.js +1 -0
  121. package/dist/src/setup/primitives/run-vercel.d.ts +2 -7
  122. package/dist/src/setup/primitives/run-vercel.js +1 -1
  123. package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
  124. package/dist/src/setup/scaffold/create/project.js +2 -2
  125. package/dist/src/setup/scaffold/update/channels.js +1 -1
  126. package/dist/src/setup/scaffold/update/connections.js +1 -1
  127. package/dist/src/setup/slack-connect-lifecycle.d.ts +2 -8
  128. package/dist/src/setup/slack-connect-lifecycle.js +1 -1
  129. package/dist/src/setup/state.d.ts +0 -12
  130. package/dist/src/setup/state.js +1 -1
  131. package/dist/src/shared/skill-paths.d.ts +10 -0
  132. package/dist/src/shared/skill-paths.js +2 -2
  133. package/dist/src/tracing/agent-otel-content.d.ts +32 -0
  134. package/dist/src/tracing/agent-otel-content.js +4 -0
  135. package/dist/src/{harness → tracing}/agent-otel-provider.d.ts +10 -1
  136. package/dist/src/tracing/agent-otel-provider.js +2 -0
  137. package/dist/src/{harness → tracing}/agent-trace-context-store.d.ts +8 -1
  138. package/dist/src/tracing/agent-trace-context-store.js +1 -0
  139. package/dist/src/{harness → tracing}/agent-trace-span-processor.d.ts +5 -1
  140. package/dist/src/tracing/agent-trace-span-processor.js +1 -0
  141. package/dist/src/tracing/local-instrumentation-runtime.js +1 -0
  142. package/dist/src/tracing/local-trace-reader.d.ts +57 -0
  143. package/dist/src/tracing/local-trace-reader.js +1 -0
  144. package/dist/src/{harness → tracing}/local-trace-retention.js +1 -1
  145. package/dist/src/{harness → tracing}/local-trace-span-processor.js +1 -1
  146. package/docs/channels/chat-sdk.mdx +18 -1
  147. package/docs/channels/meta.json +1 -0
  148. package/docs/channels/overview.mdx +1 -1
  149. package/docs/channels/photon.mdx +78 -0
  150. package/docs/concepts/default-harness.md +2 -0
  151. package/docs/guides/dev-tui.md +20 -1
  152. package/docs/guides/instrumentation.md +8 -7
  153. package/docs/reference/cli.md +9 -1
  154. package/docs/sandbox.mdx +1 -1
  155. package/package.json +7 -1
  156. package/dist/src/compiled/_chunks/node/auth-DMsLOrh7.js +0 -2
  157. package/dist/src/compiled/_chunks/node/version-BQBAL95V.js +0 -64
  158. package/dist/src/harness/agent-otel-provider.js +0 -1
  159. package/dist/src/harness/agent-trace-context-store.js +0 -1
  160. package/dist/src/harness/agent-trace-span-processor.js +0 -1
  161. package/dist/src/harness/local-instrumentation-runtime.js +0 -1
  162. package/dist/src/setup/integrations/channels/environment.js +0 -1
  163. package/dist/src/setup/integrations/channels/index.d.ts +0 -7
  164. package/dist/src/setup/integrations/channels/index.js +0 -1
  165. package/dist/src/setup/integrations/channels/runner.d.ts +0 -7
  166. package/dist/src/setup/integrations/channels/runner.js +0 -1
  167. package/dist/src/setup/integrations/channels/setup.d.ts +0 -130
  168. package/dist/src/setup/integrations/channels/setup.js +0 -2
  169. package/dist/src/setup/integrations/channels/slack.d.ts +0 -3
  170. package/dist/src/setup/integrations/channels/slack.js +0 -1
  171. package/dist/src/setup/integrations/channels/types.d.ts +0 -49
  172. package/dist/src/setup/integrations/channels/ui.js +0 -2
  173. package/dist/src/setup/integrations/channels/web.d.ts +0 -3
  174. package/dist/src/setup/integrations/channels/web.js +0 -1
  175. /package/dist/src/setup/integrations/{channels/types.js → types.js} +0 -0
  176. /package/dist/src/{harness → tracing}/local-instrumentation-runtime.d.ts +0 -0
  177. /package/dist/src/{harness → tracing}/local-trace-retention.d.ts +0 -0
  178. /package/dist/src/{harness → tracing}/local-trace-span-processor.d.ts +0 -0
@@ -0,0 +1,496 @@
1
+ import { ContentBuilder, AppUrl, SpectrumInstance } from './_spectrum-core.js';
2
+ export { AppUrl } from './_spectrum-core.js';
3
+ import { FileUpload, Logger, Adapter, ChatInstance, WebhookOptions, AdapterPostableMessage, RawMessage, Message, FetchOptions, FetchResult, ThreadInfo, EmojiValue, ModalElement, FormattedContent, BaseFormatConverter, Root } from '#compiled/chat/index.js';
4
+ import { IMessageMessageEffect, CustomizedMiniAppInput } from './_spectrum-imessage.js';
5
+ export { CustomizedMiniAppInput, IMessageMessageEffect } from './_spectrum-imessage.js';
6
+
7
+ /**
8
+ * Image bytes for a chat background. Accepts raw bytes (`Uint8Array` / `Buffer`
9
+ * / `ArrayBuffer`), a `Blob`, or a Chat SDK `FileUpload` — whatever your image
10
+ * pipeline hands back gets normalized to the bytes spectrum-ts expects.
11
+ */
12
+ type BackgroundBytes = Uint8Array | ArrayBuffer | Blob | FileUpload;
13
+ /**
14
+ * A chat-background source. Either:
15
+ *
16
+ * - the literal `"clear"` sentinel, to remove the current background;
17
+ * - in-memory {@link BackgroundBytes};
18
+ * - an `http(s)` URL (a `URL` or a string) that spectrum-ts fetches at send
19
+ * time. Local file paths aren't accepted — read the file into bytes and pass
20
+ * those instead.
21
+ */
22
+ type BackgroundInput = "clear" | BackgroundBytes | URL | string;
23
+ /** Optional chat-background metadata. */
24
+ interface BackgroundOptions {
25
+ /**
26
+ * MIME type of the image (`image/*`). Required for raw bytes when the `name`
27
+ * carries no image extension; inferred from the URL / name otherwise.
28
+ */
29
+ mimeType?: string;
30
+ /** File name used to infer the MIME type from its extension. */
31
+ name?: string;
32
+ }
33
+ /**
34
+ * Validate and normalize a chat-background source into the spectrum-ts
35
+ * `background()` content builder. The `"clear"` sentinel removes the current
36
+ * background; URL sources are fetched by spectrum-ts at send time; byte sources
37
+ * are copied to a detached `Buffer` and tagged with a resolved `image/*` MIME
38
+ * type. The builder is a fire-and-forget control signal — remote and
39
+ * iMessage-only.
40
+ */
41
+ declare function resolveBackground(input: BackgroundInput, options?: BackgroundOptions): Promise<ContentBuilder>;
42
+
43
+ /** Thread ID components for iMessage */
44
+ interface iMessageThreadId {
45
+ /** Chat GUID (e.g., "iMessage;-;+1234567890") */
46
+ chatGuid: string;
47
+ /**
48
+ * Sending line, when known — encoded in the thread ID so it survives a
49
+ * cold-cache reply invocation where the Space must be rebuilt.
50
+ */
51
+ phone?: string;
52
+ }
53
+ /**
54
+ * Explicit self-hosted iMessage client entry, passed straight through to
55
+ * spectrum-ts's `imessage.config({ clients: [...] })`.
56
+ *
57
+ * - `address`: gRPC endpoint (`host:port`) of an `@photon-ai/advanced-imessage`
58
+ * server.
59
+ * - `token`: auth token for that server.
60
+ * - `phone`: the number this client sends/receives as (routing key in
61
+ * multi-number setups; use the `"shared"` sentinel for single-number).
62
+ */
63
+ interface IMessageClientEntry {
64
+ address: string;
65
+ phone: string;
66
+ token: string;
67
+ }
68
+
69
+ interface SpectrumCloudCredentials {
70
+ projectId: string;
71
+ projectSecret: string;
72
+ }
73
+ type iMessageCredentialProvider = () => Promise<SpectrumCloudCredentials> | SpectrumCloudCredentials;
74
+ /**
75
+ * Verifies an inbound webhook that was authenticated by a trusted forwarding
76
+ * service. Throwing or returning a falsy value rejects the request. A returned
77
+ * string replaces the body used for parsing; any other truthy value accepts the
78
+ * original body.
79
+ */
80
+ type iMessageWebhookVerifier = (request: Request, rawBody: string) => unknown | Promise<unknown>;
81
+ interface iMessageAdapterConfig {
82
+ /** Legacy self-host token. Mapped to a `clients` entry's `token`. */
83
+ apiKey?: string;
84
+ /** Explicit self-host gRPC clients (advanced). */
85
+ clients?: IMessageClientEntry | IMessageClientEntry[];
86
+ /** Resolve Spectrum Cloud credentials when the adapter is first used. */
87
+ credentials?: iMessageCredentialProvider;
88
+ /**
89
+ * @deprecated Local (on-device) mode was removed. `false` is accepted as a
90
+ * no-op for back-compat; `true` throws.
91
+ */
92
+ local?: false;
93
+ logger: Logger;
94
+ /** Routing/identity phone for legacy self-host (defaults to `"shared"`). */
95
+ phone?: string;
96
+ /** Spectrum Cloud project id (recommended path). */
97
+ projectId?: string;
98
+ /** Spectrum Cloud project secret (recommended path). */
99
+ projectSecret?: string;
100
+ /** Legacy self-host endpoint. Now a gRPC `host:port` (see README). */
101
+ serverUrl?: string;
102
+ /** Per-webhook signing secret for verifying Spectrum Cloud deliveries. */
103
+ webhookSecret?: string;
104
+ /** Trusted-forwarder verifier. Takes precedence over `webhookSecret`. */
105
+ webhookVerifier?: iMessageWebhookVerifier;
106
+ }
107
+ /** @deprecated Use {@link iMessageAdapterConfig}. */
108
+ type iMessageAdapterRemoteConfig = iMessageAdapterConfig;
109
+ interface CreateiMessageAdapterOptions {
110
+ apiKey?: string;
111
+ clients?: IMessageClientEntry | IMessageClientEntry[];
112
+ /**
113
+ * Resolve Spectrum Cloud credentials lazily. The provider is called when the
114
+ * adapter first initializes or sends, rather than during construction.
115
+ */
116
+ credentials?: iMessageCredentialProvider;
117
+ /**
118
+ * @deprecated Local (on-device) mode was removed. `false` is accepted as a
119
+ * no-op for back-compat; `true` throws.
120
+ */
121
+ local?: boolean;
122
+ logger?: Logger;
123
+ phone?: string;
124
+ projectId?: string;
125
+ projectSecret?: string;
126
+ serverUrl?: string;
127
+ webhookSecret?: string;
128
+ /** Trusted-forwarder verifier. Takes precedence over `webhookSecret`. */
129
+ webhookVerifier?: iMessageWebhookVerifier;
130
+ }
131
+ /**
132
+ * Normalize a legacy `serverUrl` into a gRPC `host:port` address.
133
+ *
134
+ * `@photon-ai/advanced-imessage` (the transport spectrum-ts uses) speaks gRPC,
135
+ * not HTTP/Socket.IO, so any scheme is stripped and a default `:443` port is
136
+ * appended when none is present.
137
+ */
138
+ declare function deriveAddress(serverUrl: string): string;
139
+
140
+ /**
141
+ * iMessage expressive-send effects, keyed by friendly name. Bubble effects
142
+ * (`slam`, `loud`, `gentle`, `invisible`) animate the message bubble; the rest
143
+ * are full-screen effects (`confetti`, `fireworks`, `balloons`, `heart`,
144
+ * `lasers`, `celebration`, `sparkles`, `spotlight`, `echo`).
145
+ *
146
+ * Re-exported from spectrum-ts so callers can reference effects by name without
147
+ * reaching into the provider package — e.g. `iMessageEffect.confetti`.
148
+ */
149
+ declare const iMessageEffect: {
150
+ readonly balloons: "com.apple.messages.effect.CKBalloonEffect";
151
+ readonly celebration: "com.apple.messages.effect.CKHappyBirthdayEffect";
152
+ readonly confetti: "com.apple.messages.effect.CKConfettiEffect";
153
+ readonly echo: "com.apple.messages.effect.CKEchoEffect";
154
+ readonly fireworks: "com.apple.messages.effect.CKFireworksEffect";
155
+ readonly gentle: "com.apple.MobileSMS.expressivesend.gentle";
156
+ readonly heart: "com.apple.messages.effect.CKHeartEffect";
157
+ readonly invisible: "com.apple.MobileSMS.expressivesend.invisibleink";
158
+ readonly lasers: "com.apple.messages.effect.CKLasersEffect";
159
+ readonly loud: "com.apple.MobileSMS.expressivesend.loud";
160
+ readonly slam: "com.apple.MobileSMS.expressivesend.impact";
161
+ readonly sparkles: "com.apple.messages.effect.CKSparklesEffect";
162
+ readonly spotlight: "com.apple.messages.effect.CKSpotlightEffect";
163
+ };
164
+ /** Accepted effect names (`"confetti"`, `"fireworks"`, …). */
165
+ type iMessageEffectName = keyof typeof iMessageEffect;
166
+ /**
167
+ * Resolve an effect argument to a spectrum-ts effect id. Accepts either a
168
+ * friendly name (`"confetti"`) or the raw effect id
169
+ * (`iMessageEffect.confetti`), so both styles work. Throws a `ValidationError`
170
+ * on an unknown effect.
171
+ */
172
+ declare function resolveEffect(effect: IMessageMessageEffect | iMessageEffectName): IMessageMessageEffect;
173
+
174
+ /**
175
+ * Image bytes for a mini-app card's inline image. Accepts raw bytes
176
+ * (`Uint8Array` / `Buffer` / `ArrayBuffer`), a `Blob`, or a Chat SDK
177
+ * `FileUpload` — whatever you already have on hand gets converted to the
178
+ * `Uint8Array` spectrum-ts expects.
179
+ */
180
+ type MiniAppImage = Uint8Array | ArrayBuffer | Blob | FileUpload;
181
+ /**
182
+ * Layout of a mini-app card — everything the recipient sees in the bubble.
183
+ * Every field is optional; supply the ones that make sense for your card. The
184
+ * `image` renders as the card's artwork, with `imageTitle` / `imageSubtitle`
185
+ * overlaid; the caption fields fill the text rows, and `summary` is the
186
+ * fallback text shown where the mini-app can't render.
187
+ */
188
+ interface MiniAppCardLayout {
189
+ caption?: string;
190
+ image?: MiniAppImage;
191
+ imageSubtitle?: string;
192
+ imageTitle?: string;
193
+ subcaption?: string;
194
+ summary?: string;
195
+ trailingCaption?: string;
196
+ trailingSubcaption?: string;
197
+ }
198
+ /**
199
+ * A native iMessage mini-app card (an `MSMessageExtension` balloon). The
200
+ * `appName`, `teamId`, and `extensionBundleId` identify the iMessage extension
201
+ * that opens when the recipient taps the card, receiving `url`; `appStoreId`
202
+ * optionally points recipients without the extension installed at its App
203
+ * Store entry.
204
+ */
205
+ interface MiniAppCard {
206
+ /** Display name of the iMessage extension. */
207
+ appName: string;
208
+ /** Optional App Store id, for recipients without the extension installed. */
209
+ appStoreId?: number;
210
+ /** Bundle id of the `MSMessageExtension` that receives the tap. */
211
+ extensionBundleId: string;
212
+ /** What the recipient sees in the bubble. */
213
+ layout?: MiniAppCardLayout;
214
+ /** Apple Developer team id that signs the extension. */
215
+ teamId: string;
216
+ /** URL handed to the extension when the card is tapped. */
217
+ url: string | URL;
218
+ }
219
+ /**
220
+ * Validate and normalize a {@link MiniAppCard} into the
221
+ * {@link CustomizedMiniAppInput} spectrum-ts's `customizedMiniApp()` builder
222
+ * expects: required identifiers are checked non-empty, `url` is normalized to a
223
+ * validated string, and the layout image (if any) is decoded to bytes.
224
+ */
225
+ declare function resolveMiniApp(card: MiniAppCard): Promise<CustomizedMiniAppInput>;
226
+ /**
227
+ * Distinguish the lightweight `app(url)` form from a fully-specified
228
+ * {@link MiniAppCard}. An {@link AppUrl} is a string, a `Promise<string>`, or a
229
+ * thunk (`() => string | Promise<string>`) — the mini-app card is a plain
230
+ * object with named fields, so it never matches any of those shapes.
231
+ */
232
+ declare function isAppUrl(input: MiniAppCard | AppUrl): input is AppUrl;
233
+
234
+ /**
235
+ * Audio bytes for a voice message. Accepts raw bytes (`Uint8Array` / `Buffer` /
236
+ * `ArrayBuffer`), a `Blob`, or a Chat SDK `FileUpload` — whatever your TTS
237
+ * pipeline hands back gets normalized to the bytes spectrum-ts expects.
238
+ */
239
+ type VoiceBytes = Uint8Array | ArrayBuffer | Blob | FileUpload;
240
+ /**
241
+ * A voice message source: in-memory {@link VoiceBytes}, or an `http(s)` URL (a
242
+ * `URL` or a string) that spectrum-ts fetches at send time. Local file paths
243
+ * aren't accepted — read the file into bytes and pass those instead.
244
+ */
245
+ type VoiceInput = VoiceBytes | URL | string;
246
+ /** Optional voice-message metadata. */
247
+ interface VoiceOptions {
248
+ /**
249
+ * Playback duration in seconds, surfaced on the waveform bubble. Optional —
250
+ * iMessage derives the waveform from the audio itself when omitted.
251
+ */
252
+ duration?: number;
253
+ /**
254
+ * MIME type of the audio (`audio/*`). Required for raw bytes when the `name`
255
+ * carries no audio extension; inferred from the URL / name otherwise.
256
+ */
257
+ mimeType?: string;
258
+ /** File name handed to spectrum-ts (also used to infer the MIME type). */
259
+ name?: string;
260
+ }
261
+ /**
262
+ * Validate and normalize a voice source into the spectrum-ts `voice()` content
263
+ * builder. URL sources are fetched by spectrum-ts at send time; byte sources
264
+ * are copied to a detached `Buffer` and tagged with a resolved `audio/*` MIME
265
+ * type. The builder is sent as a native iMessage voice note (a waveform
266
+ * bubble), not an audio-file attachment.
267
+ */
268
+ declare function resolveVoice(input: VoiceInput, options?: VoiceOptions): Promise<ContentBuilder>;
269
+
270
+ declare class iMessageAdapter implements Adapter {
271
+ readonly name = "imessage";
272
+ readonly userName: string;
273
+ readonly serverUrl?: string;
274
+ readonly apiKey?: string;
275
+ readonly projectId?: string;
276
+ readonly projectSecret?: string;
277
+ readonly clients?: IMessageClientEntry[];
278
+ readonly phone?: string;
279
+ readonly webhookSecret?: string;
280
+ /** The spectrum-ts instance — null until `initialize()` or `ensureApp()` runs. */
281
+ app: SpectrumInstance | null;
282
+ /** In-flight app build, so concurrent callers share one construction. */
283
+ private appBuild;
284
+ private chat;
285
+ private readonly credentialProvider?;
286
+ private readonly logger;
287
+ private readonly webhookRequestVerifier?;
288
+ private readonly formatConverter;
289
+ private readonly cache;
290
+ private readonly modals;
291
+ private gatewayOptions?;
292
+ private pump;
293
+ constructor(config: iMessageAdapterConfig);
294
+ initialize(chat: ChatInstance): Promise<void>;
295
+ /**
296
+ * Build the spectrum-ts app on demand. eve may call the adapter in an
297
+ * invocation that never ran `initialize()` (e.g. a Vercel Workflow reply
298
+ * callback), leaving `this.app` null — every send funnels through here first.
299
+ */
300
+ private ensureApp;
301
+ private buildApp;
302
+ /**
303
+ * Handle a Spectrum Cloud webhook delivery (signed JSON `messages` event).
304
+ *
305
+ * Verifies the `X-Spectrum-Signature` HMAC, then routes the message into the
306
+ * Chat SDK. A delivered thread has no live spectrum-ts `Space`, but the
307
+ * adapter rebuilds one from the chat GUID on demand (see `resolveSpace`), so
308
+ * replying works directly from a webhook delivery.
309
+ *
310
+ * @see https://photon.codes/docs/webhooks/overview
311
+ */
312
+ handleWebhook(request: Request, options?: WebhookOptions): Promise<Response>;
313
+ /**
314
+ * Build the spectrum content for an outbound message. Markdown-typed inputs
315
+ * are sent via `markdown()` so remote iMessage renders them as native styled
316
+ * text; raw/string/card inputs stay plain `text()`. Returns the rendered
317
+ * `body` too so callers can skip an empty send.
318
+ */
319
+ private toSpectrumContent;
320
+ postMessage(threadId: string, message: AdapterPostableMessage): Promise<RawMessage>;
321
+ /**
322
+ * Send a message with an iMessage expressive-send effect — a bubble effect
323
+ * (`slam`, `loud`, `gentle`, `invisible`) or a full-screen effect
324
+ * (`confetti`, `fireworks`, `balloons`, `heart`, `lasers`, `celebration`,
325
+ * `sparkles`, `spotlight`, `echo`). Not part of the Chat SDK `Adapter`
326
+ * interface — exposed as an adapter-specific extra (e.g. celebratory confetti
327
+ * on task completion).
328
+ *
329
+ * The `effect` argument accepts a friendly name (`"confetti"`) or a value from
330
+ * the re-exported `iMessageEffect` map. Effects attach to text content only,
331
+ * so this requires non-empty text.
332
+ */
333
+ sendEffect(threadId: string, message: AdapterPostableMessage, effect: IMessageMessageEffect | iMessageEffectName): Promise<RawMessage>;
334
+ /**
335
+ * Send an iMessage mini-app card — an `MSMessageExtension` balloon, the
336
+ * closest iMessage gets to a rich card (à la Slack Block Kit) instead of a
337
+ * bare link. Not part of the Chat SDK `Adapter` interface — exposed as an
338
+ * adapter-specific extra.
339
+ *
340
+ * Two forms:
341
+ *
342
+ * - **Just a URL** — pass a string (or a `Promise`/thunk resolving to one, so
343
+ * the link can be minted at send time). This is the lightweight `app(url)`
344
+ * card: the URL is rendered as a mini-app with no extension identifiers
345
+ * required.
346
+ * - **A full {@link MiniAppCard}** — pass an object to control the bubble's
347
+ * image, captions, and the exact iMessage extension that opens on tap. Its
348
+ * `appName`, `teamId`, and `extensionBundleId` identify that extension.
349
+ */
350
+ sendMiniApp(threadId: string, url: AppUrl): Promise<RawMessage>;
351
+ sendMiniApp(threadId: string, card: MiniAppCard): Promise<RawMessage>;
352
+ /**
353
+ * Send a native iMessage voice note — a real, playable waveform bubble (the
354
+ * message renders with `isAudioMessage`), not an audio file dropped in as an
355
+ * attachment. A natural fit for TTS-capable bots that reply with speech. Not
356
+ * part of the Chat SDK `Adapter` interface — exposed as an adapter-specific
357
+ * extra.
358
+ *
359
+ * The `input` is either in-memory audio bytes (`Uint8Array` / `Buffer` /
360
+ * `ArrayBuffer`, a `Blob`, or a Chat SDK `FileUpload`) or an `http(s)` URL (a
361
+ * `URL` or a string) that is fetched at send time. Audio bytes need an
362
+ * `audio/*` MIME type — supply `options.mimeType` (e.g. `"audio/mp4"`) or an
363
+ * `options.name` with an audio extension when it can't be inferred.
364
+ */
365
+ sendVoice(threadId: string, input: VoiceInput, options?: VoiceOptions): Promise<RawMessage>;
366
+ /**
367
+ * Set or clear the chat background — the wallpaper behind a conversation, an
368
+ * iMessage-only touch with no analog on the plain-text competitors. Not part
369
+ * of the Chat SDK `Adapter` interface — exposed as an adapter-specific extra.
370
+ *
371
+ * The `input` is either the literal `"clear"` (to remove the current
372
+ * background), in-memory image bytes (`Uint8Array` / `Buffer` / `ArrayBuffer`,
373
+ * a `Blob`, or a Chat SDK `FileUpload`), or an `http(s)` URL (a `URL` or a
374
+ * string) that is fetched at send time. Image bytes need an `image/*` MIME
375
+ * type — supply `options.mimeType` (e.g. `"image/jpeg"`) or an `options.name`
376
+ * with an image extension when it can't be inferred.
377
+ *
378
+ * Fire-and-forget: iMessage acknowledges the control signal without returning
379
+ * a message, so this resolves to `void` rather than a {@link RawMessage}.
380
+ */
381
+ setBackground(threadId: string, input: BackgroundInput, options?: BackgroundOptions): Promise<void>;
382
+ editMessage(threadId: string, messageId: string, message: AdapterPostableMessage): Promise<RawMessage>;
383
+ deleteMessage(threadId: string, messageId: string): Promise<void>;
384
+ parseMessage(raw: unknown): Message;
385
+ /**
386
+ * Fetch a single message by id. spectrum-ts can resolve a message by id
387
+ * (from the inbound cache or the provider's by-id lookup) even though it has
388
+ * no paginated history API, so single-message reads work where
389
+ * `fetchMessages` cannot. Returns `null` when the message can't be resolved.
390
+ */
391
+ fetchMessage(threadId: string, messageId: string): Promise<Message | null>;
392
+ fetchMessages(_threadId: string, _options?: FetchOptions): Promise<FetchResult>;
393
+ fetchThread(_threadId: string): Promise<ThreadInfo>;
394
+ channelIdFromThreadId(threadId: string): string;
395
+ addReaction(threadId: string, messageId: string, emoji: EmojiValue | string): Promise<void>;
396
+ removeReaction(_threadId: string, messageId: string, emoji: EmojiValue | string): Promise<void>;
397
+ startTyping(threadId: string, _status?: string): Promise<void>;
398
+ /**
399
+ * Cold-start a DM with a phone number / handle. spectrum-ts resolves (or
400
+ * creates) the 1:1 conversation from the participant via `space.create`, so
401
+ * the bot can message a user it has never received from. Returns the encoded
402
+ * thread id, ready to pass to `postMessage`.
403
+ */
404
+ openDM(userId: string): Promise<string>;
405
+ /**
406
+ * Mark a received message (and the conversation up to it) as read, surfacing
407
+ * a read receipt where iMessage supports one. Not part of the
408
+ * Chat SDK `Adapter` interface — exposed as an adapter-specific extra.
409
+ */
410
+ markRead(threadId: string, messageId: string): Promise<void>;
411
+ openModal(triggerId: string, modal: ModalElement, contextId?: string): Promise<{
412
+ viewId: string;
413
+ }>;
414
+ renderFormatted(content: FormattedContent): string;
415
+ encodeThreadId(platformData: iMessageThreadId): string;
416
+ decodeThreadId(threadId: string): iMessageThreadId;
417
+ isDM(threadId: string): boolean;
418
+ startGatewayListener(options: WebhookOptions, durationMs?: number, abortSignal?: AbortSignal): Promise<Response>;
419
+ private routeWebhookMessage;
420
+ private routeInbound;
421
+ private processInboundReaction;
422
+ private handlePollOption;
423
+ /**
424
+ * Resolve a sendable spectrum-ts `Space` for a thread. Prefers a cached live
425
+ * Space; otherwise rebuilds it from the chat GUID, passing the sending line
426
+ * so `space.get` can pick it when multiple lines are configured. Returns
427
+ * `undefined` when no Space can be obtained.
428
+ */
429
+ private resolveSpace;
430
+ /**
431
+ * The iMessage provider's Space namespace (`get` / `create`). `HasProvider`
432
+ * over the default provider tuple won't narrow to `true`, so `imessage(app)`
433
+ * types as `never` — cast to the slice of the instance we use.
434
+ */
435
+ private platformSpaces;
436
+ private requireSpace;
437
+ private resolveMessage;
438
+ }
439
+
440
+ /**
441
+ * Construct an {@link iMessageAdapter}, filling unset options from environment
442
+ * variables. Requires remote credentials: cloud `projectId` + `projectSecret`,
443
+ * or self-host `clients` / `serverUrl` + `apiKey`.
444
+ */
445
+ declare function createiMessageAdapter(config?: CreateiMessageAdapterOptions): iMessageAdapter;
446
+
447
+ /**
448
+ * iMessage format conversion using AST-based parsing.
449
+ *
450
+ * Remote iMessage (via spectrum-ts) renders CommonMark natively as styled text
451
+ * (bold/italic/links etc. via UTF-16 formatting ranges), so markdown-typed
452
+ * outbound content is sent through spectrum's `markdown()` builder verbatim --
453
+ * see `renderPostableContent`. The plain-text rendering here (`fromAst`) is
454
+ * still used for inbound parsing, `renderFormatted`, and the raw/card fallback
455
+ * paths: it strips formatting markers and preserves structure (lists,
456
+ * blockquotes, code blocks) with whitespace.
457
+ */
458
+
459
+ /**
460
+ * The spectrum content a postable message should be sent as: the body string
461
+ * plus whether spectrum should render it as native markdown (styled text) or
462
+ * pass it through as plain text.
463
+ */
464
+ interface PostableContent {
465
+ body: string;
466
+ markdown: boolean;
467
+ }
468
+ declare class iMessageFormatConverter extends BaseFormatConverter {
469
+ /**
470
+ * Render an AST to iMessage plain text format.
471
+ * Strips all formatting markers since iMessage doesn't support rich text via API.
472
+ */
473
+ fromAst(ast: Root): string;
474
+ /**
475
+ * Parse iMessage text into an AST.
476
+ * iMessage sends plain text, so we just parse it as markdown.
477
+ */
478
+ toAst(text: string): Root;
479
+ /**
480
+ * Decide how a postable message should reach spectrum-ts.
481
+ *
482
+ * Markdown-typed inputs -- `{ markdown }` and `{ ast }` -- carry CommonMark
483
+ * the caller wants styled, so their source is preserved verbatim and flagged
484
+ * `markdown: true`; the adapter sends it via spectrum's `markdown()` builder,
485
+ * which renders bold/italic/links/lists as native iMessage styled text.
486
+ *
487
+ * Everything else is pass-through-as-is by contract -- a plain `string` or
488
+ * `{ raw }` must not have stray `*`/`_` reinterpreted as formatting, and
489
+ * cards fall back to plain text -- so those are rendered to plain text and
490
+ * flagged `markdown: false`.
491
+ */
492
+ renderPostableContent(message: AdapterPostableMessage): PostableContent;
493
+ private nodeToPlainText;
494
+ }
495
+
496
+ export { type BackgroundBytes, type BackgroundInput, type BackgroundOptions, type CreateiMessageAdapterOptions, type IMessageClientEntry, type MiniAppCard, type MiniAppCardLayout, type MiniAppImage, type SpectrumCloudCredentials, type VoiceBytes, type VoiceInput, type VoiceOptions, createiMessageAdapter, deriveAddress, iMessageAdapter, type iMessageAdapterConfig, type iMessageAdapterRemoteConfig, type iMessageCredentialProvider, iMessageEffect, type iMessageEffectName, iMessageFormatConverter, type iMessageThreadId, type iMessageWebhookVerifier, isAppUrl, resolveBackground, resolveEffect, resolveMiniApp, resolveVoice };