@theaiplatform/miniapp-sdk 0.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/LICENSE.md +528 -0
- package/README.md +39 -0
- package/THIRD_PARTY_NOTICES.md +257 -0
- package/config-schema.json +3192 -0
- package/dist/config.d.ts +35 -0
- package/dist/config.js +4 -0
- package/dist/index.d.ts +475 -0
- package/dist/index.js +2 -0
- package/dist/rspack/css-entry-loader.cjs +27 -0
- package/dist/rspack/html-loader.cjs +150 -0
- package/dist/rspack/index.d.ts +53 -0
- package/dist/rspack/index.js +2655 -0
- package/dist/sdk.d.ts +441 -0
- package/dist/sdk.js +27 -0
- package/dist/surface.d.ts +49 -0
- package/dist/surface.js +28 -0
- package/dist/web.d.ts +507 -0
- package/dist/web.js +146 -0
- package/package.json +113 -0
package/dist/sdk.d.ts
ADDED
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
export declare type CreateChannelOptions = {
|
|
2
|
+
workspaceId?: string;
|
|
3
|
+
name: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
projectId?: string | null;
|
|
6
|
+
visibility?: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export declare type CreateChannelResult = {
|
|
10
|
+
roomId: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export declare type CreateProjectOptions = {
|
|
14
|
+
workspaceId?: string;
|
|
15
|
+
id?: string;
|
|
16
|
+
name: string;
|
|
17
|
+
discoverable?: boolean;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export declare type CreateProjectResult = {
|
|
21
|
+
projectId: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export declare type GetChannelAccessOptions = {
|
|
25
|
+
workspaceId?: string;
|
|
26
|
+
channelId: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export declare type GetChannelAccessResult = {
|
|
30
|
+
archived: boolean;
|
|
31
|
+
capabilities: string[];
|
|
32
|
+
isParticipant: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Last timeline sequence retained for a former participant. When present,
|
|
35
|
+
* the channel remains readable through this sequence even though
|
|
36
|
+
* `isParticipant` is false.
|
|
37
|
+
*/
|
|
38
|
+
visibleUntilSequence?: number | null;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export declare type GetChannelTimelineOptions = {
|
|
42
|
+
workspaceId?: string;
|
|
43
|
+
channelId: string;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export declare type GetChannelTimelineResult = {
|
|
47
|
+
timeline: {
|
|
48
|
+
messages: MiniAppChannelMessage[];
|
|
49
|
+
sequence: number;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export declare type GetProjectOptions = {
|
|
54
|
+
workspaceId?: string;
|
|
55
|
+
projectId: string;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export declare type GetProjectResult = {
|
|
59
|
+
project: MiniAppProject | null;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export declare type InvokeSavedWorkflowOptions<TPayload = unknown> = {
|
|
63
|
+
workflowId: string;
|
|
64
|
+
payload?: TPayload;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export declare type InvokeWorkflowOptions<TPayload = unknown> = {
|
|
68
|
+
workflowJson: string;
|
|
69
|
+
payload?: TPayload;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export declare type InvokeWorkflowResult = {
|
|
73
|
+
success: boolean;
|
|
74
|
+
status: string;
|
|
75
|
+
message: string;
|
|
76
|
+
runId?: string | null;
|
|
77
|
+
error?: string | null;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export declare type ListChannelsOptions = {
|
|
81
|
+
workspaceId?: string;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export declare type ListChannelsResult = {
|
|
85
|
+
rooms: MiniAppChannel[];
|
|
86
|
+
readMode: string;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export declare type ListWorkflowsOptions = {
|
|
90
|
+
workspaceId?: string;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export declare type ListWorkflowsResult = {
|
|
94
|
+
workflows: MiniAppWorkflow[];
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export declare type MiniAppAuthApi = {
|
|
98
|
+
getUserProfile(): MiniAppMaybePromise<MiniAppUserProfile | null>;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @capability integrations-and-marketplace
|
|
103
|
+
*/
|
|
104
|
+
export declare type MiniAppChannel = {
|
|
105
|
+
roomId: string;
|
|
106
|
+
title?: string;
|
|
107
|
+
kind?: string;
|
|
108
|
+
description?: string;
|
|
109
|
+
visibility: string;
|
|
110
|
+
archived: boolean;
|
|
111
|
+
createdAt: number;
|
|
112
|
+
updatedAt: number;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* One bounded JSON timeline row. The row schema is host-versioned, so callers
|
|
117
|
+
* must narrow it before reading fields.
|
|
118
|
+
*/
|
|
119
|
+
export declare type MiniAppChannelMessage = MiniAppJsonValue;
|
|
120
|
+
|
|
121
|
+
export declare type MiniAppChatApi = {
|
|
122
|
+
/**
|
|
123
|
+
* Select the miniapp's active conversation, reveal the shared chat panel,
|
|
124
|
+
* and place text in its composer without unmounting the miniapp surface.
|
|
125
|
+
*/
|
|
126
|
+
sendTextToChat(text: string): MiniAppMaybePromise<void>;
|
|
127
|
+
joinChannelSpecialist?(channelId: string, specialistId: string): MiniAppMaybePromise<null>;
|
|
128
|
+
archiveConversation?(workspaceId: string, userId: string, conversationId: string, projectId: string): MiniAppMaybePromise<null>;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export declare type MiniAppCreateSpecialistOptions = {
|
|
132
|
+
name: string;
|
|
133
|
+
domain: string;
|
|
134
|
+
description: string | null;
|
|
135
|
+
configuration: MiniAppJsonValue;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export declare type MiniAppCreateSpecialistResult = {
|
|
139
|
+
id: string;
|
|
140
|
+
name: string;
|
|
141
|
+
domain: string;
|
|
142
|
+
description: string | null;
|
|
143
|
+
isActive: boolean;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/** JSON-compatible values accepted by public miniapp operations. */
|
|
147
|
+
export declare type MiniAppJsonValue = null | boolean | number | string | MiniAppJsonValue[] | {
|
|
148
|
+
[key: string]: MiniAppJsonValue;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Author-controlled manifest accepted by the host-managed specialist
|
|
153
|
+
* persistence operation. Ownership, visibility, installation, and verification
|
|
154
|
+
* metadata are derived by the host and cannot be supplied by a miniapp.
|
|
155
|
+
*/
|
|
156
|
+
export declare type MiniAppManagedSpecialist = {
|
|
157
|
+
id: string;
|
|
158
|
+
slug: string;
|
|
159
|
+
name: string;
|
|
160
|
+
publisher: string;
|
|
161
|
+
description: string;
|
|
162
|
+
icon: string;
|
|
163
|
+
category?: string;
|
|
164
|
+
categoryDisplayName?: string;
|
|
165
|
+
version?: string;
|
|
166
|
+
schemaVersion?: string;
|
|
167
|
+
displayName?: string;
|
|
168
|
+
maintainers?: Array<{
|
|
169
|
+
name: string;
|
|
170
|
+
email: string;
|
|
171
|
+
url?: string;
|
|
172
|
+
}>;
|
|
173
|
+
license?: string;
|
|
174
|
+
lastUpdated?: string;
|
|
175
|
+
fullDescription?: string;
|
|
176
|
+
knowledgeSources?: MiniAppJsonValue[];
|
|
177
|
+
ownedKnowledgePlotId?: string;
|
|
178
|
+
links?: {
|
|
179
|
+
terms?: string;
|
|
180
|
+
privacy?: string;
|
|
181
|
+
website?: string;
|
|
182
|
+
};
|
|
183
|
+
systemPrompt?: string;
|
|
184
|
+
prompts?: MiniAppJsonValue;
|
|
185
|
+
skills?: string[];
|
|
186
|
+
tooling?: MiniAppJsonValue;
|
|
187
|
+
orchestration?: MiniAppJsonValue;
|
|
188
|
+
taskModels?: Record<string, string>;
|
|
189
|
+
knowledgeTargeting?: MiniAppJsonValue;
|
|
190
|
+
tasks?: MiniAppJsonValue[];
|
|
191
|
+
identity?: MiniAppJsonValue;
|
|
192
|
+
audience?: MiniAppJsonValue;
|
|
193
|
+
constraints?: MiniAppJsonValue;
|
|
194
|
+
domainContext?: MiniAppJsonValue;
|
|
195
|
+
purpose?: string;
|
|
196
|
+
values?: MiniAppJsonValue[];
|
|
197
|
+
attributes?: string[];
|
|
198
|
+
techStack?: string[];
|
|
199
|
+
writingStyle?: MiniAppJsonValue;
|
|
200
|
+
tags?: string[];
|
|
201
|
+
preferredModel?: string;
|
|
202
|
+
supportsLocal?: boolean;
|
|
203
|
+
requiresNetwork?: boolean;
|
|
204
|
+
knowledgeGardens?: string[];
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
export declare type MiniAppManagedSpecialistResult = {
|
|
208
|
+
specialistId: string;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export declare type MiniAppMaybePromise<T> = T | Promise<T>;
|
|
212
|
+
|
|
213
|
+
export declare type MiniAppPlatformApi = {
|
|
214
|
+
channels: {
|
|
215
|
+
create(options: CreateChannelOptions): CreateChannelResult | Promise<CreateChannelResult>;
|
|
216
|
+
list(options?: ListChannelsOptions): ListChannelsResult | Promise<ListChannelsResult>;
|
|
217
|
+
sendMessage(options: SendChannelMessageOptions): SendChannelMessageResult | Promise<SendChannelMessageResult>;
|
|
218
|
+
/** Persist one deterministic completed row under a joined specialist. */
|
|
219
|
+
sendSpecialistMessage(options: SendChannelSpecialistMessageOptions): SendChannelSpecialistMessageResult | Promise<SendChannelSpecialistMessageResult>;
|
|
220
|
+
getAccess(options: GetChannelAccessOptions): GetChannelAccessResult | Promise<GetChannelAccessResult>;
|
|
221
|
+
getTimeline(options: GetChannelTimelineOptions): GetChannelTimelineResult | Promise<GetChannelTimelineResult>;
|
|
222
|
+
};
|
|
223
|
+
projects: {
|
|
224
|
+
create(options: CreateProjectOptions): CreateProjectResult | Promise<CreateProjectResult>;
|
|
225
|
+
get(options: GetProjectOptions): GetProjectResult | Promise<GetProjectResult>;
|
|
226
|
+
update(options: UpdateProjectOptions): UpdateProjectResult | Promise<UpdateProjectResult>;
|
|
227
|
+
};
|
|
228
|
+
workflows: {
|
|
229
|
+
list(options?: ListWorkflowsOptions): ListWorkflowsResult | Promise<ListWorkflowsResult>;
|
|
230
|
+
invokeSaved<TPayload = unknown>(options: InvokeSavedWorkflowOptions<TPayload>): InvokeWorkflowResult | Promise<InvokeWorkflowResult>;
|
|
231
|
+
invoke?<TPayload = unknown>(options: InvokeWorkflowOptions<TPayload>): InvokeWorkflowResult | Promise<InvokeWorkflowResult>;
|
|
232
|
+
};
|
|
233
|
+
navigation: {
|
|
234
|
+
open(options: OpenNavigationOptions): void | Promise<void>;
|
|
235
|
+
};
|
|
236
|
+
chat: MiniAppChatApi;
|
|
237
|
+
/** Browser capabilities appear only when the selected target supports them. */
|
|
238
|
+
auth?: MiniAppAuthApi;
|
|
239
|
+
vfs?: MiniAppVfsApi;
|
|
240
|
+
specialist?: MiniAppSpecialistApi;
|
|
241
|
+
hasEditorView?: boolean;
|
|
242
|
+
hasHostHttpRequest?: boolean;
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
export declare type MiniAppProject = {
|
|
246
|
+
id: string;
|
|
247
|
+
name: string;
|
|
248
|
+
workspaceId: string;
|
|
249
|
+
discoverable: boolean;
|
|
250
|
+
channelIds: string[];
|
|
251
|
+
archivedChannelIds: string[];
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
export declare type MiniAppProvisionProjectChatOptions = {
|
|
255
|
+
conversationId: string;
|
|
256
|
+
projectId: string;
|
|
257
|
+
referenceBranch?: string | null;
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
export declare type MiniAppProvisionProjectChatResult = {
|
|
261
|
+
mountedRoots: string[];
|
|
262
|
+
worktreeBranch?: string | null;
|
|
263
|
+
worktreeBaseCommit?: string | null;
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
export declare type MiniAppSpecialistApi = {
|
|
267
|
+
joinToChannel(channelId: string, specialistId: string): MiniAppMaybePromise<string>;
|
|
268
|
+
listWorkspace(workspaceId: string): MiniAppMaybePromise<MiniAppSpecialistSummary[]>;
|
|
269
|
+
create(options: MiniAppCreateSpecialistOptions): MiniAppMaybePromise<MiniAppCreateSpecialistResult>;
|
|
270
|
+
upsertManaged?(specialist: MiniAppManagedSpecialist): MiniAppMaybePromise<MiniAppManagedSpecialistResult>;
|
|
271
|
+
runTurnWithTools?(options: MiniAppSpecialistTurnOptions): MiniAppMaybePromise<MiniAppSpecialistTurnResult>;
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
export declare type MiniAppSpecialistConversationPart = {
|
|
275
|
+
type: 'text';
|
|
276
|
+
content: string;
|
|
277
|
+
} | {
|
|
278
|
+
type: 'tool';
|
|
279
|
+
toolCallId: string;
|
|
280
|
+
toolName: string;
|
|
281
|
+
arguments: MiniAppJsonValue;
|
|
282
|
+
toolIntent: string | null;
|
|
283
|
+
success: boolean;
|
|
284
|
+
content: MiniAppJsonValue;
|
|
285
|
+
mediaCost?: MiniAppJsonValue | null;
|
|
286
|
+
error?: string | null;
|
|
287
|
+
executionTimeMs: number;
|
|
288
|
+
} | {
|
|
289
|
+
type: 'stepEnd';
|
|
290
|
+
iteration: number;
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
export declare type MiniAppSpecialistInteractionMode = 'conversational' | 'agentic' | 'planning' | 'background' | 'longRunning' | 'inlineEdit' | 'focus';
|
|
294
|
+
|
|
295
|
+
export declare type MiniAppSpecialistSummary = {
|
|
296
|
+
id: string;
|
|
297
|
+
slug: string;
|
|
298
|
+
displayName: string;
|
|
299
|
+
description: string;
|
|
300
|
+
tags: string[];
|
|
301
|
+
version: string;
|
|
302
|
+
availability: 'public' | 'internal' | 'private' | 'restricted';
|
|
303
|
+
canRunLocally: boolean;
|
|
304
|
+
category: string;
|
|
305
|
+
categoryDisplayName: string;
|
|
306
|
+
requiredCapabilities: {
|
|
307
|
+
inputModalities: string[];
|
|
308
|
+
toolUse?: boolean | null;
|
|
309
|
+
reasoning?: boolean | null;
|
|
310
|
+
} | null;
|
|
311
|
+
omnipresence?: {
|
|
312
|
+
autoJoinChannels: boolean;
|
|
313
|
+
includeDms: boolean;
|
|
314
|
+
pinSidebar: boolean;
|
|
315
|
+
} | null;
|
|
316
|
+
displayIcon?: {
|
|
317
|
+
type: 'bundled';
|
|
318
|
+
path: string;
|
|
319
|
+
} | {
|
|
320
|
+
type: 'remote';
|
|
321
|
+
url: string;
|
|
322
|
+
} | null;
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
export declare type MiniAppSpecialistTurnOptions = {
|
|
326
|
+
workspaceId: string;
|
|
327
|
+
channelId: string;
|
|
328
|
+
specialistId: string;
|
|
329
|
+
content: string;
|
|
330
|
+
modelOverride: string;
|
|
331
|
+
messageId: null;
|
|
332
|
+
interactionMode: MiniAppSpecialistInteractionMode;
|
|
333
|
+
timeoutMs: number;
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
export declare type MiniAppSpecialistTurnResult = {
|
|
337
|
+
completionEvent: {
|
|
338
|
+
parts: MiniAppSpecialistConversationPart[];
|
|
339
|
+
finishReason?: string;
|
|
340
|
+
modelUsed?: string;
|
|
341
|
+
};
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
export declare type MiniAppUserProfile = {
|
|
345
|
+
sub: string;
|
|
346
|
+
name?: string | null;
|
|
347
|
+
givenName?: string | null;
|
|
348
|
+
familyName?: string | null;
|
|
349
|
+
middleName?: string | null;
|
|
350
|
+
nickname?: string | null;
|
|
351
|
+
preferredUsername?: string | null;
|
|
352
|
+
profile?: string | null;
|
|
353
|
+
picture?: string | null;
|
|
354
|
+
website?: string | null;
|
|
355
|
+
email?: string | null;
|
|
356
|
+
emailVerified?: boolean | null;
|
|
357
|
+
gender?: string | null;
|
|
358
|
+
birthdate?: string | null;
|
|
359
|
+
zoneinfo?: string | null;
|
|
360
|
+
locale?: string | null;
|
|
361
|
+
phoneNumber?: string | null;
|
|
362
|
+
phoneNumberVerified?: boolean | null;
|
|
363
|
+
address?: MiniAppJsonValue | null;
|
|
364
|
+
updatedAt?: string | null;
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
export declare type MiniAppVfsApi = {
|
|
368
|
+
provisionProjectChat(options: MiniAppProvisionProjectChatOptions): MiniAppMaybePromise<MiniAppProvisionProjectChatResult>;
|
|
369
|
+
writeFile(conversationId: string, path: string, data: Uint8Array): MiniAppMaybePromise<null>;
|
|
370
|
+
mkdir(conversationId: string, path: string): MiniAppMaybePromise<null>;
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
export declare type MiniAppWorkflow = {
|
|
374
|
+
id: string;
|
|
375
|
+
name: string;
|
|
376
|
+
type: string;
|
|
377
|
+
createdAt: number;
|
|
378
|
+
updatedAt: number;
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
export declare type OpenNavigationOptions = {
|
|
382
|
+
path: string;
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Public miniapp API installed by the host. Importing this value is safe in
|
|
387
|
+
* build tools and tests; an unsupported-environment error is raised only when a
|
|
388
|
+
* property is read before the host installs the API.
|
|
389
|
+
*/
|
|
390
|
+
export declare const sdk: MiniAppPlatformApi;
|
|
391
|
+
|
|
392
|
+
export declare type SendChannelMessageOptions = {
|
|
393
|
+
workspaceId?: string;
|
|
394
|
+
channelId: string;
|
|
395
|
+
/**
|
|
396
|
+
* Optional stable client id for product-owned messages such as seeded
|
|
397
|
+
* lifecycle notices. Omit for ordinary miniapp messages.
|
|
398
|
+
*/
|
|
399
|
+
clientMessageId?: string;
|
|
400
|
+
name?: string;
|
|
401
|
+
/** Display body to persist. When omitted, the host formats `name` and `content`. */
|
|
402
|
+
body?: string;
|
|
403
|
+
content: string;
|
|
404
|
+
/** Optional structured chat content persisted with the message. */
|
|
405
|
+
messageContent?: Record<string, MiniAppJsonValue>;
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
export declare type SendChannelMessageResult = {
|
|
409
|
+
messageId: string;
|
|
410
|
+
clientMessageId: string;
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
export declare type SendChannelSpecialistMessageOptions = {
|
|
414
|
+
workspaceId?: string;
|
|
415
|
+
channelId: string;
|
|
416
|
+
projectId: string;
|
|
417
|
+
specialistId: string;
|
|
418
|
+
clientMessageId: string;
|
|
419
|
+
body: string;
|
|
420
|
+
messageContent?: Record<string, MiniAppJsonValue>;
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
export declare type SendChannelSpecialistMessageResult = {
|
|
424
|
+
messageId: string;
|
|
425
|
+
clientMessageId: string;
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
export declare type UpdateProjectOptions = {
|
|
429
|
+
workspaceId?: string;
|
|
430
|
+
projectId: string;
|
|
431
|
+
name?: string;
|
|
432
|
+
discoverable?: boolean;
|
|
433
|
+
channelIds?: string[];
|
|
434
|
+
archivedChannelIds?: string[];
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
export declare type UpdateProjectResult = {
|
|
438
|
+
project: MiniAppProject;
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
export { }
|
package/dist/sdk.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const SDK_SLOT = Symbol.for('tap.internal.v1');
|
|
2
|
+
const UNSUPPORTED_ENVIRONMENT_MESSAGE = 'Attempted to use The AI Platform MiniApp SDK outside a supported environment';
|
|
3
|
+
function readMiniAppSdk() {
|
|
4
|
+
const value = Reflect.get(globalThis, SDK_SLOT);
|
|
5
|
+
if ('object' != typeof value || null === value) throw new Error(UNSUPPORTED_ENVIRONMENT_MESSAGE);
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
8
|
+
const lazyMiniAppSdk = new Proxy(Object.create(null), {
|
|
9
|
+
get (_target, property) {
|
|
10
|
+
return Reflect.get(readMiniAppSdk(), property);
|
|
11
|
+
},
|
|
12
|
+
has (_target, property) {
|
|
13
|
+
return Reflect.has(readMiniAppSdk(), property);
|
|
14
|
+
},
|
|
15
|
+
ownKeys () {
|
|
16
|
+
return Reflect.ownKeys(readMiniAppSdk());
|
|
17
|
+
},
|
|
18
|
+
getOwnPropertyDescriptor (_target, property) {
|
|
19
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(readMiniAppSdk(), property);
|
|
20
|
+
return descriptor ? {
|
|
21
|
+
...descriptor,
|
|
22
|
+
configurable: true
|
|
23
|
+
} : void 0;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
const sdk = lazyMiniAppSdk;
|
|
27
|
+
export { sdk };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves one raw package-relative asset path inside the descriptor-selected
|
|
3
|
+
* target directory. Absolute, encoded-alias, and traversal inputs fail closed.
|
|
4
|
+
*/
|
|
5
|
+
export declare function resolvePackageAssetUrl(context: Pick<TapFederatedSurfaceMountContext, 'packageAssetBaseUrl'>, relativePath: string): URL;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Read-only authority projected by TAP for the exact package release/frame.
|
|
9
|
+
* A candidate frame starts without authority and may only perform host-backed
|
|
10
|
+
* work after the host confirms that release. Subscribers are notified only
|
|
11
|
+
* when the boolean snapshot changes.
|
|
12
|
+
*/
|
|
13
|
+
export declare interface TapFederatedSurfaceHostAuthority {
|
|
14
|
+
getSnapshot(): boolean;
|
|
15
|
+
subscribe(listener: () => void): () => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Cleanup handle returned by a federated surface mount. */
|
|
19
|
+
export declare interface TapFederatedSurfaceMount {
|
|
20
|
+
unmount(): void | Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Context supplied by TAP's isolated webview surface runtime. */
|
|
24
|
+
export declare interface TapFederatedSurfaceMountContext {
|
|
25
|
+
readonly packageId: string;
|
|
26
|
+
readonly packageNamespace: string;
|
|
27
|
+
readonly releaseId: string;
|
|
28
|
+
readonly installationId: string;
|
|
29
|
+
readonly contributionId: string;
|
|
30
|
+
readonly instanceId: string;
|
|
31
|
+
readonly hostOrigin: string;
|
|
32
|
+
readonly packageAssetBaseUrl: string;
|
|
33
|
+
readonly workspaceId?: string;
|
|
34
|
+
readonly channelId?: string;
|
|
35
|
+
readonly conversationId?: string;
|
|
36
|
+
readonly events: TapPackageEventPublisher;
|
|
37
|
+
readonly hostAuthority: TapFederatedSurfaceHostAuthority;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @capability integrations-and-marketplace
|
|
42
|
+
*/
|
|
43
|
+
/** Declared package-event channel supplied to an isolated UI contribution. */
|
|
44
|
+
export declare interface TapPackageEventPublisher {
|
|
45
|
+
publish(name: string, payload: Readonly<Record<string, unknown>>): void | Promise<void>;
|
|
46
|
+
subscribe(name: string, listener: (payload: unknown, envelope: Readonly<Record<string, unknown>>) => void | Promise<void>): () => void;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { }
|
package/dist/surface.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const ENCODED_PATH_SEPARATOR_OR_DOT_PATTERN = /%(?:2e|2f|5c)/iu;
|
|
2
|
+
const CONTROL_CHARACTER_PATTERN = /[\u0000-\u001f\u007f]/u;
|
|
3
|
+
function packageAssetBaseUrl(context) {
|
|
4
|
+
const value = context.packageAssetBaseUrl;
|
|
5
|
+
if (value.trim() !== value || value.includes('\\') || CONTROL_CHARACTER_PATTERN.test(value) || ENCODED_PATH_SEPARATOR_OR_DOT_PATTERN.test(value)) throw new Error('The TAP package asset base URL must be a canonical target directory.');
|
|
6
|
+
let base;
|
|
7
|
+
try {
|
|
8
|
+
base = new URL(value);
|
|
9
|
+
} catch {
|
|
10
|
+
throw new Error('The TAP package asset base URL is invalid.');
|
|
11
|
+
}
|
|
12
|
+
if ('http:' !== base.protocol && 'https:' !== base.protocol || 'null' === base.origin || '' !== base.username || '' !== base.password || '' !== base.search || '' !== base.hash || !base.pathname.endsWith('/') || base.pathname.slice(1).includes('//') || base.pathname.includes('\\') || ENCODED_PATH_SEPARATOR_OR_DOT_PATTERN.test(base.pathname)) throw new Error('The TAP package asset base URL must be a canonical target directory.');
|
|
13
|
+
return base;
|
|
14
|
+
}
|
|
15
|
+
function packageAssetPathSegments(relativePath) {
|
|
16
|
+
if ('' === relativePath || relativePath.trim() !== relativePath || relativePath.startsWith('/') || relativePath.includes('\\') || relativePath.includes('?') || relativePath.includes('#') || relativePath.includes(':') || relativePath.includes('%') || CONTROL_CHARACTER_PATTERN.test(relativePath)) throw new Error('A TAP package asset path must be a canonical relative path.');
|
|
17
|
+
const segments = relativePath.split('/');
|
|
18
|
+
if (segments.some((segment)=>'' === segment || '.' === segment || '..' === segment)) throw new Error('A TAP package asset path must not escape its target directory.');
|
|
19
|
+
return segments;
|
|
20
|
+
}
|
|
21
|
+
function resolvePackageAssetUrl(context, relativePath) {
|
|
22
|
+
const base = packageAssetBaseUrl(context);
|
|
23
|
+
const encodedRelativePath = packageAssetPathSegments(relativePath).map((segment)=>encodeURIComponent(segment)).join('/');
|
|
24
|
+
const resolved = new URL(encodedRelativePath, base);
|
|
25
|
+
if (resolved.origin !== base.origin || '' !== resolved.username || '' !== resolved.password || '' !== resolved.search || '' !== resolved.hash || !resolved.pathname.startsWith(base.pathname)) throw new Error('The TAP package asset URL must remain inside its target directory.');
|
|
26
|
+
return resolved;
|
|
27
|
+
}
|
|
28
|
+
export { resolvePackageAssetUrl };
|