@proveanything/smartlinks 2.1.18 → 2.1.19
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/adminViews.d.ts +19 -0
- package/dist/adminViews.js +16 -0
- package/dist/api/ai.d.ts +15 -5
- package/dist/api/ai.js +15 -9
- package/dist/api/aiGuide.d.ts +108 -0
- package/dist/api/aiGuide.js +161 -0
- package/dist/api/appObjects.d.ts +21 -0
- package/dist/api/appObjects.js +33 -1
- package/dist/api/authKit.d.ts +37 -1
- package/dist/api/authKit.js +51 -0
- package/dist/docs/API_SUMMARY.md +509 -40
- package/dist/docs/admin-lists-and-pickers.md +140 -0
- package/dist/docs/admin-views.md +22 -0
- package/dist/docs/app-data-storage.md +277 -276
- package/dist/docs/auth-kit.md +872 -741
- package/dist/docs/comms.md +686 -644
- package/dist/docs/customer-guide.md +70 -0
- package/dist/docs/headless-providers.md +112 -112
- package/dist/docs/server-functions.md +69 -1
- package/dist/docs/ui-utils.md +123 -121
- package/dist/docs/user-groups.md +175 -168
- package/dist/headless.js +38 -2
- package/dist/http.js +4 -0
- package/dist/index.d.ts +2 -2
- package/dist/live.d.ts +80 -0
- package/dist/live.js +315 -0
- package/dist/openapi.yaml +888 -34
- package/dist/testing/index.d.ts +22 -0
- package/dist/testing/index.js +31 -0
- package/dist/types/appManifest.d.ts +214 -1
- package/dist/types/appOptions.d.ts +32 -0
- package/dist/types/appOptions.js +3 -0
- package/dist/types/authKit.d.ts +193 -4
- package/dist/types/comms.d.ts +41 -2
- package/dist/types/headless.d.ts +49 -1
- package/dist/types/iframeResponder.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/docs/API_SUMMARY.md +509 -40
- package/docs/admin-lists-and-pickers.md +140 -0
- package/docs/admin-views.md +22 -0
- package/docs/app-data-storage.md +277 -276
- package/docs/auth-kit.md +872 -741
- package/docs/comms.md +686 -644
- package/docs/customer-guide.md +70 -0
- package/docs/headless-providers.md +112 -112
- package/docs/server-functions.md +69 -1
- package/docs/ui-utils.md +123 -121
- package/docs/user-groups.md +175 -168
- package/openapi.yaml +888 -34
- package/package.json +1 -1
- package/scripts/doctor.mjs +454 -428
- package/scripts/lib/keyed-app-data.mjs +21 -0
package/dist/adminViews.d.ts
CHANGED
|
@@ -78,6 +78,25 @@ export declare function hostChrome(): 'none' | 'full';
|
|
|
78
78
|
* useEffect(() => SL.adminViews.onNavigate(manifest.adminViews, (to) => navigate(to.path)), [navigate])
|
|
79
79
|
*/
|
|
80
80
|
export declare function onNavigate(views: AdminView[] | undefined | null, handler: (to: NavigateTarget) => void): () => void;
|
|
81
|
+
/** Another app's screen to open: by its admin view (and params), or by a hash path. */
|
|
82
|
+
export interface OpenAppRequest {
|
|
83
|
+
/** The installed app's id in this collection (`'crm'`, `'messages'`, `'appointment-booking'`). */
|
|
84
|
+
appId: string;
|
|
85
|
+
view?: string;
|
|
86
|
+
params?: Record<string, string>;
|
|
87
|
+
path?: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Ask the host (Studio) to open ANOTHER app at one of its screens: a contact in the CRM, a booking in
|
|
91
|
+
* the booking app, a person's messages in Messages. The host reads that app's manifest `adminViews`,
|
|
92
|
+
* turns the view into its address and opens it, so it works whichever SDK the other app is on. Posts
|
|
93
|
+
* `{ type: 'smartlinks:open-app', payload: { appId, view?, params?, path? } }` to the parent. No-op
|
|
94
|
+
* outside a frame.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* SL.adminViews.openApp({ appId: 'crm', view: 'contact', params: { contactId } })
|
|
98
|
+
*/
|
|
99
|
+
export declare function openApp(req: OpenAppRequest): void;
|
|
81
100
|
/**
|
|
82
101
|
* Ask an embedded app to open a screen. Post this only once the app has said it follows navigate
|
|
83
102
|
* (`smartlinks:navigable`); otherwise reload the frame at the new path as before.
|
package/dist/adminViews.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// messages that use them:
|
|
4
4
|
// host → app { type: 'smartlinks:navigate', view?, path?, params?, highlight? } open a screen, no reload
|
|
5
5
|
// app → host 'smartlinks:navigable' (the app follows navigate) 'smartlinks:navigate-result'
|
|
6
|
+
// app → host 'smartlinks:open-app' { appId, view?, params?, path? } open ANOTHER app at a screen
|
|
6
7
|
// plus `chrome=none`: the host carries the app's menu itself, so the app hides its own.
|
|
7
8
|
// One list drives the app's own side menu, Studio's workspace menu and the assistant. See
|
|
8
9
|
// docs/admin-views.md.
|
|
@@ -240,6 +241,21 @@ export function onNavigate(views, handler) {
|
|
|
240
241
|
catch ( /* ignore */_a) { /* ignore */ }
|
|
241
242
|
};
|
|
242
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* Ask the host (Studio) to open ANOTHER app at one of its screens: a contact in the CRM, a booking in
|
|
246
|
+
* the booking app, a person's messages in Messages. The host reads that app's manifest `adminViews`,
|
|
247
|
+
* turns the view into its address and opens it, so it works whichever SDK the other app is on. Posts
|
|
248
|
+
* `{ type: 'smartlinks:open-app', payload: { appId, view?, params?, path? } }` to the parent. No-op
|
|
249
|
+
* outside a frame.
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* SL.adminViews.openApp({ appId: 'crm', view: 'contact', params: { contactId } })
|
|
253
|
+
*/
|
|
254
|
+
export function openApp(req) {
|
|
255
|
+
if (!req || typeof req.appId !== 'string' || !req.appId)
|
|
256
|
+
return;
|
|
257
|
+
postParent('smartlinks:open-app', Object.assign(Object.assign(Object.assign({ appId: req.appId }, (req.view ? { view: req.view } : {})), (req.params ? { params: req.params } : {})), (req.path ? { path: req.path } : {})));
|
|
258
|
+
}
|
|
243
259
|
// -----------------------------------------------------------------------------
|
|
244
260
|
// Host side
|
|
245
261
|
// -----------------------------------------------------------------------------
|
package/dist/api/ai.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { guide as guideApi, content as contentApi, startLive } from "./aiGuide.js";
|
|
1
2
|
import type { ContentPart, FunctionCall, ToolCall, ChatMessage, ToolDefinition, ResponseTool, ResponseInputItem, ResponsesRequest, ResponsesResult, ResponsesStreamEvent, ChatCompletionRequest, ChatCompletionChoice, ChatCompletionResponse, ChatCompletionChunk, AIModel, AIModelListParams, AIModelListResponse, AgentRunRequest, AgentRunResult, AgentToolsQuery, AgentToolsResponse, ToolRunResult, AiToolName, AiToolArgsMap, PublicAgentRunRequest, ClientTool, RunWithClientToolsOptions, SkillsListResponse, CatalogResponse, DocumentChunk, IndexDocumentRequest, IndexDocumentResponse, ConfigureAssistantRequest, ConfigureAssistantResponse, PublicChatRequest, PublicChatResponse, Session, RateLimitStatus, SessionStatistics, AiSession, AiSessionCreate, AiUsageReport, VoiceSessionRequest, VoiceSessionResponse, EphemeralTokenRequest, EphemeralTokenResponse, TranscriptionResponse, TTSRequest, GeneratePodcastRequest, PodcastScript, GeneratePodcastResponse, PodcastStatus, AIGenerateContentRequest, AIGenerateContentCandidate, AIGenerateContentResponse, AIGenerateImageRequest, AIGenerateImageResponse, AIGeneratedImage, AISearchPhotosRequest, AISearchPhotosPhoto, AISearchPhotosResponse, AIUploadedFile, AICacheRef } from "../types/ai.js";
|
|
2
3
|
export type { ContentPart, FunctionCall, ToolCall, ChatMessage, ToolDefinition, ResponseTool, ResponseInputItem, ResponsesRequest, ResponsesResult, ResponsesStreamEvent, ChatCompletionRequest, ChatCompletionChoice, ChatCompletionResponse, ChatCompletionChunk, AIModel, AIModelListParams, AIModelListResponse, DocumentChunk, IndexDocumentRequest, IndexDocumentResponse, ConfigureAssistantRequest, ConfigureAssistantResponse, PublicChatRequest, PublicChatResponse, Session, RateLimitStatus, SessionStatistics, AiSession, AiSessionCreate, AiUsageReport, VoiceSessionRequest, VoiceSessionResponse, EphemeralTokenRequest, EphemeralTokenResponse, TranscriptionResponse, TTSRequest, GeneratePodcastRequest, PodcastScript, GeneratePodcastResponse, PodcastStatus, AIGenerateContentRequest, AIGenerateContentCandidate, AIGenerateContentResponse, AIGenerateImageRequest, AIGenerateImageResponse, AIGeneratedImage, AISearchPhotosRequest, AISearchPhotosPhoto, AISearchPhotosResponse, AIUploadedFile, AICacheRef, };
|
|
3
4
|
declare namespace aiInternal {
|
|
@@ -197,10 +198,6 @@ declare namespace aiInternal {
|
|
|
197
198
|
* Check rate limit status
|
|
198
199
|
*/
|
|
199
200
|
function getRateLimit(collectionId: string, userId: string): Promise<RateLimitStatus>;
|
|
200
|
-
/**
|
|
201
|
-
* Generate ephemeral token for Gemini Live
|
|
202
|
-
*/
|
|
203
|
-
function getToken(collectionId: string, request: EphemeralTokenRequest): Promise<EphemeralTokenResponse>;
|
|
204
201
|
}
|
|
205
202
|
namespace voice {
|
|
206
203
|
/**
|
|
@@ -294,13 +291,26 @@ export declare const ai: {
|
|
|
294
291
|
getSession: typeof aiInternal.publicClient.getSession;
|
|
295
292
|
clearSession: typeof aiInternal.publicClient.clearSession;
|
|
296
293
|
getRateLimit: typeof aiInternal.publicClient.getRateLimit;
|
|
297
|
-
getToken: typeof aiInternal.publicClient.getToken;
|
|
298
294
|
};
|
|
299
295
|
voice: {
|
|
300
296
|
isSupported: typeof aiInternal.voice.isSupported;
|
|
301
297
|
listen: typeof aiInternal.voice.listen;
|
|
302
298
|
speak: typeof aiInternal.voice.speak;
|
|
303
299
|
};
|
|
300
|
+
/** The customer guide: a business's assistant for its visitors (docs/customer-guide.md). */
|
|
301
|
+
guide: {
|
|
302
|
+
get: typeof guideApi.get;
|
|
303
|
+
start: typeof guideApi.start;
|
|
304
|
+
};
|
|
305
|
+
/** What's on screen, in words, for an assistant: apps provide it, hosts request it. */
|
|
306
|
+
content: {
|
|
307
|
+
provide: typeof contentApi.provide;
|
|
308
|
+
request: typeof contentApi.request;
|
|
309
|
+
};
|
|
310
|
+
/** A live conversation by voice or text, with your own endpoints (the guide and the Studio assistant use it). */
|
|
311
|
+
live: {
|
|
312
|
+
start: typeof startLive;
|
|
313
|
+
};
|
|
304
314
|
agent: {
|
|
305
315
|
run: typeof aiInternal.agent.run;
|
|
306
316
|
listTools: typeof aiInternal.agent.listTools;
|
package/dist/api/ai.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/api/ai.ts
|
|
2
2
|
// AI endpoints: public and admin helpers
|
|
3
3
|
import { post, request, del, requestStream } from "../http.js";
|
|
4
|
+
import { guide as guideApi, content as contentApi, startLive } from "./aiGuide.js";
|
|
4
5
|
function encodeQueryParams(params) {
|
|
5
6
|
if (!params)
|
|
6
7
|
return '';
|
|
@@ -375,14 +376,6 @@ var aiInternal;
|
|
|
375
376
|
return request(path);
|
|
376
377
|
}
|
|
377
378
|
publicClient.getRateLimit = getRateLimit;
|
|
378
|
-
/**
|
|
379
|
-
* Generate ephemeral token for Gemini Live
|
|
380
|
-
*/
|
|
381
|
-
async function getToken(collectionId, request) {
|
|
382
|
-
const path = `/public/collection/${encodeURIComponent(collectionId)}/ai/token`;
|
|
383
|
-
return post(path, request);
|
|
384
|
-
}
|
|
385
|
-
publicClient.getToken = getToken;
|
|
386
379
|
})(publicClient = aiInternal.publicClient || (aiInternal.publicClient = {}));
|
|
387
380
|
// ============================================================================
|
|
388
381
|
// Voice Helpers (Browser-only)
|
|
@@ -578,13 +571,26 @@ export const ai = {
|
|
|
578
571
|
getSession: aiInternal.publicClient.getSession,
|
|
579
572
|
clearSession: aiInternal.publicClient.clearSession,
|
|
580
573
|
getRateLimit: aiInternal.publicClient.getRateLimit,
|
|
581
|
-
getToken: aiInternal.publicClient.getToken,
|
|
582
574
|
},
|
|
583
575
|
voice: {
|
|
584
576
|
isSupported: aiInternal.voice.isSupported,
|
|
585
577
|
listen: aiInternal.voice.listen,
|
|
586
578
|
speak: aiInternal.voice.speak,
|
|
587
579
|
},
|
|
580
|
+
/** The customer guide: a business's assistant for its visitors (docs/customer-guide.md). */
|
|
581
|
+
guide: {
|
|
582
|
+
get: guideApi.get,
|
|
583
|
+
start: guideApi.start,
|
|
584
|
+
},
|
|
585
|
+
/** What's on screen, in words, for an assistant: apps provide it, hosts request it. */
|
|
586
|
+
content: {
|
|
587
|
+
provide: contentApi.provide,
|
|
588
|
+
request: contentApi.request,
|
|
589
|
+
},
|
|
590
|
+
/** A live conversation by voice or text, with your own endpoints (the guide and the Studio assistant use it). */
|
|
591
|
+
live: {
|
|
592
|
+
start: startLive,
|
|
593
|
+
},
|
|
588
594
|
agent: {
|
|
589
595
|
run: aiInternal.agent.run,
|
|
590
596
|
listTools: aiInternal.agent.listTools,
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { startLive, type LiveHandle, type LiveOptions, type LiveState, type LiveToolHandler, type LiveMintReply, type LiveEvent } from '../live.js';
|
|
2
|
+
export type GuideSurface = 'portal' | 'hub';
|
|
3
|
+
/** What a page may know about a business's guide before starting one. */
|
|
4
|
+
export interface GuideInfo {
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
name?: string;
|
|
7
|
+
modes?: {
|
|
8
|
+
voice: boolean;
|
|
9
|
+
text: boolean;
|
|
10
|
+
start: 'voice' | 'text';
|
|
11
|
+
};
|
|
12
|
+
suggestions?: string[];
|
|
13
|
+
handoff?: {
|
|
14
|
+
kind: 'email' | 'phone' | 'url';
|
|
15
|
+
value: string;
|
|
16
|
+
} | null;
|
|
17
|
+
}
|
|
18
|
+
/** What is on the visitor's screen, in words. */
|
|
19
|
+
export interface ScreenContent {
|
|
20
|
+
appId?: string | null;
|
|
21
|
+
title?: string | null;
|
|
22
|
+
content?: string | null;
|
|
23
|
+
}
|
|
24
|
+
/** Where the visitor is: the app on screen and the page in it (as the host's deep link). */
|
|
25
|
+
export interface GuideWhere {
|
|
26
|
+
appId?: string | null;
|
|
27
|
+
path?: string | null;
|
|
28
|
+
params?: Record<string, string>;
|
|
29
|
+
}
|
|
30
|
+
/** A page the guide opened (the host moves the app there). */
|
|
31
|
+
export interface GuideNavigate {
|
|
32
|
+
appId: string;
|
|
33
|
+
path: string;
|
|
34
|
+
params?: Record<string, string>;
|
|
35
|
+
}
|
|
36
|
+
/** Products the guide found, for the screen: each row can take the visitor there. */
|
|
37
|
+
export interface GuideCard {
|
|
38
|
+
title: string;
|
|
39
|
+
rows: Array<{
|
|
40
|
+
title: string;
|
|
41
|
+
detail?: string | null;
|
|
42
|
+
goTo?: string;
|
|
43
|
+
}>;
|
|
44
|
+
more?: number;
|
|
45
|
+
}
|
|
46
|
+
export interface GuideStartOptions {
|
|
47
|
+
surface: GuideSurface;
|
|
48
|
+
mode?: 'voice' | 'text';
|
|
49
|
+
productId?: string | null;
|
|
50
|
+
proofId?: string | null;
|
|
51
|
+
/** The apps on the visitor's page: the guide reads their pages and may open them. A core app says so. */
|
|
52
|
+
apps?: Array<{
|
|
53
|
+
id: string;
|
|
54
|
+
title: string;
|
|
55
|
+
kind?: 'core' | 'app';
|
|
56
|
+
channel?: string;
|
|
57
|
+
}>;
|
|
58
|
+
/** Where the visitor is when the conversation starts. Later, tell it with handle.note(). */
|
|
59
|
+
where?: GuideWhere;
|
|
60
|
+
/** The visitor's language (e.g. 'fr'); default: theirs as the browser says. */
|
|
61
|
+
language?: string;
|
|
62
|
+
/** What's on screen when the conversation starts. Later, the guide asks with read_screen. */
|
|
63
|
+
screen?: ScreenContent;
|
|
64
|
+
/** Read the screen now (the guide's read_screen tool). Default: ask the app on screen (ai.content.request). */
|
|
65
|
+
readScreen?: () => Promise<ScreenContent | null> | ScreenContent | null;
|
|
66
|
+
/** Open one of the business's apps at its start (the guide's show_app tool). */
|
|
67
|
+
showApp?: (appId: string) => Promise<void> | void;
|
|
68
|
+
/** Open a page of an app (the guide's open_page tool: SmartLinks resolves the page's address). */
|
|
69
|
+
openPage?: (to: GuideNavigate) => Promise<void> | void;
|
|
70
|
+
/** Go to another product's page (the guide's go_to tool). */
|
|
71
|
+
goTo?: (productId: string) => Promise<void> | void;
|
|
72
|
+
/** Products the guide found, to show (each row can call goTo). */
|
|
73
|
+
onShow?: (card: GuideCard) => void;
|
|
74
|
+
/** Show how to reach a person (the guide's offer_person tool). */
|
|
75
|
+
offerPerson?: (handoff: GuideInfo['handoff']) => Promise<void> | void;
|
|
76
|
+
onState?: (s: LiveState) => void;
|
|
77
|
+
onCaption?: (text: string) => void;
|
|
78
|
+
onReply?: (text: string) => void;
|
|
79
|
+
onError?: (message: string) => void;
|
|
80
|
+
}
|
|
81
|
+
export declare namespace guide {
|
|
82
|
+
/** Is the guide on for this surface, and how does it present itself? */
|
|
83
|
+
function get(collectionId: string, surface?: GuideSurface): Promise<GuideInfo>;
|
|
84
|
+
/** Start a live conversation with the guide. Resolves once connected; the handle pauses, stops, sends text. */
|
|
85
|
+
function start(collectionId: string, options: GuideStartOptions): Promise<LiveHandle>;
|
|
86
|
+
}
|
|
87
|
+
type ContentHandler = (ctx: {
|
|
88
|
+
reason?: string;
|
|
89
|
+
}) => Promise<ScreenContent | null> | ScreenContent | null;
|
|
90
|
+
export declare namespace content {
|
|
91
|
+
/**
|
|
92
|
+
* An app says what its screen shows, in words (an exhibit's text, a recipe, a form's purpose). Called
|
|
93
|
+
* whenever an assistant needs it. Works in an iframe (the host asks by message) and in the same page
|
|
94
|
+
* (a direct component). Returns a function that stops providing.
|
|
95
|
+
*/
|
|
96
|
+
function provide(handler: ContentHandler): () => void;
|
|
97
|
+
/**
|
|
98
|
+
* A host asks what the app on screen shows: an app in an iframe (pass its window as `frame`), or apps in
|
|
99
|
+
* this page that called `provide`. Resolves null if nothing answers within the time.
|
|
100
|
+
*/
|
|
101
|
+
function request(options?: {
|
|
102
|
+
frame?: Window | null;
|
|
103
|
+
reason?: string;
|
|
104
|
+
timeoutMs?: number;
|
|
105
|
+
}): Promise<ScreenContent | null>;
|
|
106
|
+
}
|
|
107
|
+
export { startLive };
|
|
108
|
+
export type { LiveHandle, LiveState, LiveOptions, LiveToolHandler, LiveMintReply, LiveEvent };
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// The customer guide, and "what's on my screen" for AI (browser side of prove docs/design/customer-assistant.md).
|
|
2
|
+
//
|
|
3
|
+
// ai.guide.get(collectionId, surface) is the guide on here, its name, modes and opening questions
|
|
4
|
+
// ai.guide.start(collectionId, options) a live conversation with it, by voice or by text
|
|
5
|
+
// ai.content.provide(handler) an app says what its screen shows, in words
|
|
6
|
+
// ai.content.request(options) a host asks the app on screen what it shows
|
|
7
|
+
//
|
|
8
|
+
// The guide runs as the visitor (anonymous, or signed in with Auth Kit). Everything that shapes it — its
|
|
9
|
+
// instructions, voice and tools — is fixed by SmartLinks when the conversation starts; the page only says
|
|
10
|
+
// where the visitor is and what is on their screen.
|
|
11
|
+
import { post, request } from '../http.js';
|
|
12
|
+
import { startLive } from '../live.js';
|
|
13
|
+
const base = (collectionId) => `/public/collection/${encodeURIComponent(collectionId)}/ai/guide`;
|
|
14
|
+
export var guide;
|
|
15
|
+
(function (guide) {
|
|
16
|
+
/** Is the guide on for this surface, and how does it present itself? */
|
|
17
|
+
async function get(collectionId, surface) {
|
|
18
|
+
return request(`${base(collectionId)}${surface ? `?surface=${surface}` : ''}`);
|
|
19
|
+
}
|
|
20
|
+
guide.get = get;
|
|
21
|
+
/** Start a live conversation with the guide. Resolves once connected; the handle pauses, stops, sends text. */
|
|
22
|
+
async function start(collectionId, options) {
|
|
23
|
+
let handoff = null;
|
|
24
|
+
const language = options.language || (typeof navigator !== 'undefined' ? (navigator.language || '').split('-')[0] : '') || undefined;
|
|
25
|
+
const screenTools = {
|
|
26
|
+
read_screen: async () => {
|
|
27
|
+
var _a;
|
|
28
|
+
const s = options.readScreen ? await options.readScreen() : await content.request({ timeoutMs: 1500 });
|
|
29
|
+
return s && s.content ? { title: (_a = s.title) !== null && _a !== void 0 ? _a : null, content: String(s.content).slice(0, 12000) } : { error: 'Nothing to read on the screen right now.' };
|
|
30
|
+
},
|
|
31
|
+
show_app: async (args) => {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
if (!options.showApp)
|
|
34
|
+
return { error: "That can't be opened from here." };
|
|
35
|
+
await options.showApp(String((_a = args['appId']) !== null && _a !== void 0 ? _a : ''));
|
|
36
|
+
return { opened: String((_b = args['appId']) !== null && _b !== void 0 ? _b : '') };
|
|
37
|
+
},
|
|
38
|
+
go_to: async (args) => {
|
|
39
|
+
var _a;
|
|
40
|
+
const id = String((_a = args['productId']) !== null && _a !== void 0 ? _a : '');
|
|
41
|
+
if (!id)
|
|
42
|
+
return { error: 'Which product?' };
|
|
43
|
+
if (!options.goTo)
|
|
44
|
+
return { error: "That can't be opened from here." };
|
|
45
|
+
await options.goTo(id);
|
|
46
|
+
return { opened: id };
|
|
47
|
+
},
|
|
48
|
+
offer_person: async () => {
|
|
49
|
+
var _a;
|
|
50
|
+
if (!handoff)
|
|
51
|
+
return { error: 'There is no way to reach a person set up.' };
|
|
52
|
+
await ((_a = options.offerPerson) === null || _a === void 0 ? void 0 : _a.call(options, handoff));
|
|
53
|
+
return { shown: handoff.kind };
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
const opts = {
|
|
57
|
+
mode: options.mode,
|
|
58
|
+
build: 'sdk-guide-1',
|
|
59
|
+
screenTools,
|
|
60
|
+
endpoints: {
|
|
61
|
+
mint: async () => {
|
|
62
|
+
var _a, _b, _c;
|
|
63
|
+
const reply = await post(`${base(collectionId)}/session`, {
|
|
64
|
+
surface: options.surface,
|
|
65
|
+
mode: options.mode,
|
|
66
|
+
productId: (_a = options.productId) !== null && _a !== void 0 ? _a : undefined,
|
|
67
|
+
proofId: (_b = options.proofId) !== null && _b !== void 0 ? _b : undefined,
|
|
68
|
+
apps: options.apps,
|
|
69
|
+
where: options.where,
|
|
70
|
+
language,
|
|
71
|
+
screen: options.screen,
|
|
72
|
+
});
|
|
73
|
+
handoff = (_c = reply.handoff) !== null && _c !== void 0 ? _c : null;
|
|
74
|
+
return reply;
|
|
75
|
+
},
|
|
76
|
+
tool: (name, args, sessionId) => post(`${base(collectionId)}/tool`, { name, args, sessionId }),
|
|
77
|
+
event: (event) => { void post(`${base(collectionId)}/event`, event).catch(() => undefined); },
|
|
78
|
+
},
|
|
79
|
+
onToolReply: async (_name, reply) => {
|
|
80
|
+
var _a, _b;
|
|
81
|
+
if (reply['show'])
|
|
82
|
+
(_a = options.onShow) === null || _a === void 0 ? void 0 : _a.call(options, reply['show']);
|
|
83
|
+
if (reply['navigate'])
|
|
84
|
+
await ((_b = options.openPage) === null || _b === void 0 ? void 0 : _b.call(options, reply['navigate']));
|
|
85
|
+
},
|
|
86
|
+
onState: options.onState,
|
|
87
|
+
onCaption: options.onCaption,
|
|
88
|
+
onReply: options.onReply,
|
|
89
|
+
onError: options.onError,
|
|
90
|
+
};
|
|
91
|
+
return startLive(opts);
|
|
92
|
+
}
|
|
93
|
+
guide.start = start;
|
|
94
|
+
})(guide || (guide = {}));
|
|
95
|
+
const REQUEST = 'smartlinks:ai-content-request';
|
|
96
|
+
const REPLY = 'smartlinks:ai-content';
|
|
97
|
+
const local = new Set();
|
|
98
|
+
export var content;
|
|
99
|
+
(function (content) {
|
|
100
|
+
/**
|
|
101
|
+
* An app says what its screen shows, in words (an exhibit's text, a recipe, a form's purpose). Called
|
|
102
|
+
* whenever an assistant needs it. Works in an iframe (the host asks by message) and in the same page
|
|
103
|
+
* (a direct component). Returns a function that stops providing.
|
|
104
|
+
*/
|
|
105
|
+
function provide(handler) {
|
|
106
|
+
local.add(handler);
|
|
107
|
+
let onMessage = null;
|
|
108
|
+
if (typeof window !== 'undefined' && window.parent && window.parent !== window) {
|
|
109
|
+
onMessage = (e) => {
|
|
110
|
+
const d = e.data;
|
|
111
|
+
if (e.source !== window.parent || !d || d.type !== REQUEST || !d.id)
|
|
112
|
+
return;
|
|
113
|
+
void Promise.resolve(handler({ reason: d.reason }))
|
|
114
|
+
.catch(() => null)
|
|
115
|
+
.then((c) => window.parent.postMessage({ type: REPLY, id: d.id, content: c !== null && c !== void 0 ? c : null }, '*'));
|
|
116
|
+
};
|
|
117
|
+
window.addEventListener('message', onMessage);
|
|
118
|
+
}
|
|
119
|
+
return () => {
|
|
120
|
+
local.delete(handler);
|
|
121
|
+
if (onMessage)
|
|
122
|
+
window.removeEventListener('message', onMessage);
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
content.provide = provide;
|
|
126
|
+
/**
|
|
127
|
+
* A host asks what the app on screen shows: an app in an iframe (pass its window as `frame`), or apps in
|
|
128
|
+
* this page that called `provide`. Resolves null if nothing answers within the time.
|
|
129
|
+
*/
|
|
130
|
+
async function request(options = {}) {
|
|
131
|
+
var _a;
|
|
132
|
+
const timeoutMs = (_a = options.timeoutMs) !== null && _a !== void 0 ? _a : 1000;
|
|
133
|
+
if (options.frame) {
|
|
134
|
+
const frame = options.frame;
|
|
135
|
+
const id = Math.random().toString(36).slice(2);
|
|
136
|
+
return new Promise((resolve) => {
|
|
137
|
+
const done = (c) => { clearTimeout(timer); window.removeEventListener('message', onMessage); resolve(c); };
|
|
138
|
+
const onMessage = (e) => {
|
|
139
|
+
var _a;
|
|
140
|
+
const d = e.data;
|
|
141
|
+
if (e.source === frame && d && d.type === REPLY && d.id === id)
|
|
142
|
+
done((_a = d.content) !== null && _a !== void 0 ? _a : null);
|
|
143
|
+
};
|
|
144
|
+
const timer = setTimeout(() => done(null), timeoutMs);
|
|
145
|
+
window.addEventListener('message', onMessage);
|
|
146
|
+
frame.postMessage({ type: REQUEST, id, reason: options.reason }, '*');
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
for (const handler of [...local].reverse()) {
|
|
150
|
+
const c = await Promise.race([
|
|
151
|
+
Promise.resolve(handler({ reason: options.reason })).catch(() => null),
|
|
152
|
+
new Promise((r) => setTimeout(() => r(null), timeoutMs)),
|
|
153
|
+
]);
|
|
154
|
+
if (c && c.content)
|
|
155
|
+
return c;
|
|
156
|
+
}
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
content.request = request;
|
|
160
|
+
})(content || (content = {}));
|
|
161
|
+
export { startLive };
|
package/dist/api/appObjects.d.ts
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
import type { AppCase, CreateCaseInput, UpdateCaseInput, AppendHistoryInput, CaseSummaryRequest, CaseSummaryResponse, CaseListQueryParams, AppThread, CreateThreadInput, UpdateThreadInput, ReplyInput, ThreadListQueryParams, AppRecord, CreateRecordInput, CreateRecordResponse, UpdateRecordInput, UpsertRecordInput, UpsertRecordResponse, MatchRecordsInput, MatchResult, BulkUpsertItem, BulkUpsertResult, BulkDeleteResult, BulkDeleteInput, RecordListQueryParams, ResolveAllParams, ResolveAllResult, PreviewRuleParams, PreviewRuleResult, PaginatedResponse, AggregateRequest, AggregateResponse, RelatedResponse } from '../types/appObjects.js';
|
|
2
2
|
export declare namespace app {
|
|
3
|
+
/**
|
|
4
|
+
* Pickers: the small, cached list behind "pick a machine" or "pick a hold reason".
|
|
5
|
+
* docs/admin-lists-and-pickers.md
|
|
6
|
+
*/
|
|
7
|
+
namespace options {
|
|
8
|
+
/**
|
|
9
|
+
* `source` = `type:<record type or declared type id>` | `list:<list id>`. Admins (`admin: true`)
|
|
10
|
+
* see every entry; the public API lists public records and lists the app declares public. Hold on
|
|
11
|
+
* to `version` and pass it back to get `{ unchanged: true }` when nothing changed.
|
|
12
|
+
*/
|
|
13
|
+
function get(collectionId: string, appId: string, source: string, opts?: {
|
|
14
|
+
q?: string;
|
|
15
|
+
version?: string;
|
|
16
|
+
admin?: boolean;
|
|
17
|
+
}): Promise<import('../types/appOptions.js').AppOptionsResponse>;
|
|
18
|
+
/**
|
|
19
|
+
* Save a value list's values, in order (admins). Codes never change and are never lost: a value left
|
|
20
|
+
* out stays, switched off, at the end. → the list as saved.
|
|
21
|
+
*/
|
|
22
|
+
function saveList(collectionId: string, appId: string, listId: string, values: import('../types/appOptions.js').AppOptionValueInput[]): Promise<import('../types/appOptions.js').AppOptionsResponse>;
|
|
23
|
+
}
|
|
3
24
|
namespace cases {
|
|
4
25
|
/**
|
|
5
26
|
* Create a new case
|
package/dist/api/appObjects.js
CHANGED
|
@@ -1,8 +1,40 @@
|
|
|
1
1
|
// src/api/appObjects.ts
|
|
2
|
-
import { request, post, patch, del } from '../http.js';
|
|
2
|
+
import { request, post, patch, del, put } from '../http.js';
|
|
3
3
|
// ==================== APP NAMESPACE ====================
|
|
4
4
|
export var app;
|
|
5
5
|
(function (app) {
|
|
6
|
+
// ==================== OPTIONS (pickers) ====================
|
|
7
|
+
/**
|
|
8
|
+
* Pickers: the small, cached list behind "pick a machine" or "pick a hold reason".
|
|
9
|
+
* docs/admin-lists-and-pickers.md
|
|
10
|
+
*/
|
|
11
|
+
let options;
|
|
12
|
+
(function (options) {
|
|
13
|
+
/**
|
|
14
|
+
* `source` = `type:<record type or declared type id>` | `list:<list id>`. Admins (`admin: true`)
|
|
15
|
+
* see every entry; the public API lists public records and lists the app declares public. Hold on
|
|
16
|
+
* to `version` and pass it back to get `{ unchanged: true }` when nothing changed.
|
|
17
|
+
*/
|
|
18
|
+
async function get(collectionId, appId, source, opts = {}) {
|
|
19
|
+
const zone = opts.admin ? 'admin' : 'public';
|
|
20
|
+
const qs = new URLSearchParams();
|
|
21
|
+
if (opts.q)
|
|
22
|
+
qs.set('q', opts.q);
|
|
23
|
+
if (opts.version)
|
|
24
|
+
qs.set('version', opts.version);
|
|
25
|
+
const query = qs.toString();
|
|
26
|
+
return request(`/${zone}/collection/${encodeURIComponent(collectionId)}/app/${encodeURIComponent(appId)}/options/${encodeURIComponent(source)}${query ? `?${query}` : ''}`);
|
|
27
|
+
}
|
|
28
|
+
options.get = get;
|
|
29
|
+
/**
|
|
30
|
+
* Save a value list's values, in order (admins). Codes never change and are never lost: a value left
|
|
31
|
+
* out stays, switched off, at the end. → the list as saved.
|
|
32
|
+
*/
|
|
33
|
+
async function saveList(collectionId, appId, listId, values) {
|
|
34
|
+
return put(`/admin/collection/${encodeURIComponent(collectionId)}/app/${encodeURIComponent(appId)}/options/${encodeURIComponent(`list:${listId}`)}`, { values });
|
|
35
|
+
}
|
|
36
|
+
options.saveList = saveList;
|
|
37
|
+
})(options = app.options || (app.options = {}));
|
|
6
38
|
// ==================== CASES ====================
|
|
7
39
|
let cases;
|
|
8
40
|
(function (cases) {
|
package/dist/api/authKit.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AuthLoginResponse, AppleLoginOptions, MicrosoftLoginOptions, RefreshResponse, LogoutResponse, PhoneSendCodeResponse, PhoneVerifyResponse, PasswordResetRequestResponse, VerifyResetTokenResponse, PasswordResetCompleteResponse, EmailVerificationActionResponse, EmailVerifyTokenResponse, AuthKitConfig, AuthKitConfigInput, AuthKitSetIdentityResponse, AuthKitInviteRequest, AuthKitInviteResponse, MagicLinkSendResponse, MagicLinkVerifyResponse, UserProfile, UpdateProfileResponse, ProfileUpdateData, SuccessResponse, SendWhatsAppRequest, SendWhatsAppResponse, ExchangeWhatsAppSessionResponse, VerifyWhatsAppResponse, WhatsAppStatusResponse, SendSmsVerifyRequest, SendSmsVerifyResponse, VerifySmsResponse, UpsertContactRequest, UpsertContactResponse, MfaChallengeSendResponse, MfaFinalizeResponse, MfaEnrollSendResponse, MfaTotpEnrollResponse, MfaEnrolledResponse, MfaFactor, MfaFactorsResponse, TrustedDevice } from "../types/authKit.js";
|
|
1
|
+
import type { AuthLoginResponse, AppleLoginOptions, MicrosoftLoginOptions, RefreshResponse, LogoutResponse, PhoneSendCodeResponse, PhoneVerifyResponse, PasswordResetRequestResponse, VerifyResetTokenResponse, PasswordResetCompleteResponse, EmailVerificationActionResponse, EmailVerifyTokenResponse, AuthKitConfig, AuthKitConfigInput, AuthKitSetIdentityResponse, AuthKitInviteRequest, AuthKitInviteResponse, AuthKitSchema, AuthKitSettingsResponse, AuthKitSetupRequest, AuthKitSetupResponse, AuthKitEmailKind, AuthKitEmailPreview, AuthKitSecretLink, MagicLinkSendResponse, MagicLinkVerifyResponse, UserProfile, UpdateProfileResponse, ProfileUpdateData, SuccessResponse, SendWhatsAppRequest, SendWhatsAppResponse, ExchangeWhatsAppSessionResponse, VerifyWhatsAppResponse, WhatsAppStatusResponse, SendSmsVerifyRequest, SendSmsVerifyResponse, VerifySmsResponse, UpsertContactRequest, UpsertContactResponse, MfaChallengeSendResponse, MfaFinalizeResponse, MfaEnrollSendResponse, MfaTotpEnrollResponse, MfaEnrolledResponse, MfaFactor, MfaFactorsResponse, TrustedDevice } from "../types/authKit.js";
|
|
2
2
|
/**
|
|
3
3
|
* Namespace containing helper functions for the new AuthKit API.
|
|
4
4
|
* Legacy collection-based authKit helpers retained (marked as *Legacy*).
|
|
@@ -321,5 +321,41 @@ export declare namespace authKit {
|
|
|
321
321
|
* this site's addresses), `TOO_MANY_INVITES` (429, 5 an hour per address).
|
|
322
322
|
*/
|
|
323
323
|
function invite(collectionId: string, authKitId: string, body: AuthKitInviteRequest): Promise<AuthKitInviteResponse>;
|
|
324
|
+
/** Every sign-in setting: its path, default, what reads it (`screens` / `server` / `both`), in plain words. */
|
|
325
|
+
function schema(collectionId: string): Promise<AuthKitSchema>;
|
|
326
|
+
/**
|
|
327
|
+
* Set up the collection's sign-in in one call, safe to repeat: finds its sign-in (or makes one, with
|
|
328
|
+
* email + Google and confirm-then-signed-in, and makes it the collection's default), optionally gives it
|
|
329
|
+
* its own logins (ONE WAY — members of this site only; needed for invite-only) and saves a first
|
|
330
|
+
* settings patch. Errors: `INVALID_CONFIG` (400, `problems`), `OWN_LOGINS_REQUIRED` (409),
|
|
331
|
+
* `MEMBER_POOL_CONFLICT` (409), `SECRET_IN_SETTINGS` (400).
|
|
332
|
+
*/
|
|
333
|
+
function setup(collectionId: string, body?: AuthKitSetupRequest): Promise<AuthKitSetupResponse>;
|
|
334
|
+
/** What sign-in does now: the stored config, every default filled in, which secrets are set (masked), and checks. */
|
|
335
|
+
function settings(collectionId: string, authKitId: string): Promise<AuthKitSettingsResponse>;
|
|
336
|
+
/**
|
|
337
|
+
* A one-time SmartLinks page where the PERSON types a secret (e.g. `linkedInClientSecret`) — so it never
|
|
338
|
+
* passes through a chat or your code. Give them the `url`; it works once, for 30 minutes. Asking again
|
|
339
|
+
* replaces the link. Check it landed with {@link settings} (`secrets.<name>.set`).
|
|
340
|
+
*/
|
|
341
|
+
function secretEntryLink(collectionId: string, authKitId: string, name: string, opts?: {
|
|
342
|
+
label?: string;
|
|
343
|
+
}): Promise<AuthKitSecretLink>;
|
|
344
|
+
/** Store a secret you already hold (server-side code only — never ask a person to paste one to you). Returns the masked hint. */
|
|
345
|
+
function setSecret(collectionId: string, authKitId: string, name: string, value: string): Promise<{
|
|
346
|
+
name: string;
|
|
347
|
+
hint: string;
|
|
348
|
+
setAt: string;
|
|
349
|
+
}>;
|
|
350
|
+
/** Remove a secret (that provider then uses SmartLinks' own app). */
|
|
351
|
+
function removeSecret(collectionId: string, authKitId: string, name: string): Promise<{
|
|
352
|
+
name: string;
|
|
353
|
+
removed: true;
|
|
354
|
+
}>;
|
|
355
|
+
/**
|
|
356
|
+
* An account email as it would be sent now — or with draft settings (`emailTemplates`, `emailBranding`,
|
|
357
|
+
* `branding`; checked like a save, nothing stored). Sample values stand in for the person and the link.
|
|
358
|
+
*/
|
|
359
|
+
function previewEmail(collectionId: string, authKitId: string, kind: AuthKitEmailKind, draft?: Pick<AuthKitConfigInput, 'emailTemplates' | 'emailBranding' | 'branding'>): Promise<AuthKitEmailPreview>;
|
|
324
360
|
function remove(collectionId: string, authKitId: string): Promise<void>;
|
|
325
361
|
}
|
package/dist/api/authKit.js
CHANGED
|
@@ -583,6 +583,57 @@ export var authKit;
|
|
|
583
583
|
return post(path, body);
|
|
584
584
|
}
|
|
585
585
|
authKit.invite = invite;
|
|
586
|
+
/* ===================================
|
|
587
|
+
* Setting up sign-in (admin) — everything an assistant needs; see docs/auth-kit.md "Setting up sign-in"
|
|
588
|
+
* =================================== */
|
|
589
|
+
/** Every sign-in setting: its path, default, what reads it (`screens` / `server` / `both`), in plain words. */
|
|
590
|
+
async function schema(collectionId) {
|
|
591
|
+
return request(`/admin/collection/${encodeURIComponent(collectionId)}/authKit/schema`);
|
|
592
|
+
}
|
|
593
|
+
authKit.schema = schema;
|
|
594
|
+
/**
|
|
595
|
+
* Set up the collection's sign-in in one call, safe to repeat: finds its sign-in (or makes one, with
|
|
596
|
+
* email + Google and confirm-then-signed-in, and makes it the collection's default), optionally gives it
|
|
597
|
+
* its own logins (ONE WAY — members of this site only; needed for invite-only) and saves a first
|
|
598
|
+
* settings patch. Errors: `INVALID_CONFIG` (400, `problems`), `OWN_LOGINS_REQUIRED` (409),
|
|
599
|
+
* `MEMBER_POOL_CONFLICT` (409), `SECRET_IN_SETTINGS` (400).
|
|
600
|
+
*/
|
|
601
|
+
async function setup(collectionId, body = {}) {
|
|
602
|
+
return post(`/admin/collection/${encodeURIComponent(collectionId)}/authKit/setup`, body);
|
|
603
|
+
}
|
|
604
|
+
authKit.setup = setup;
|
|
605
|
+
/** What sign-in does now: the stored config, every default filled in, which secrets are set (masked), and checks. */
|
|
606
|
+
async function settings(collectionId, authKitId) {
|
|
607
|
+
return request(`/admin/collection/${encodeURIComponent(collectionId)}/authKit/${encodeURIComponent(authKitId)}/settings`);
|
|
608
|
+
}
|
|
609
|
+
authKit.settings = settings;
|
|
610
|
+
/**
|
|
611
|
+
* A one-time SmartLinks page where the PERSON types a secret (e.g. `linkedInClientSecret`) — so it never
|
|
612
|
+
* passes through a chat or your code. Give them the `url`; it works once, for 30 minutes. Asking again
|
|
613
|
+
* replaces the link. Check it landed with {@link settings} (`secrets.<name>.set`).
|
|
614
|
+
*/
|
|
615
|
+
async function secretEntryLink(collectionId, authKitId, name, opts = {}) {
|
|
616
|
+
return post(`/admin/collection/${encodeURIComponent(collectionId)}/authKit/${encodeURIComponent(authKitId)}/secrets/${encodeURIComponent(name)}/link`, opts);
|
|
617
|
+
}
|
|
618
|
+
authKit.secretEntryLink = secretEntryLink;
|
|
619
|
+
/** Store a secret you already hold (server-side code only — never ask a person to paste one to you). Returns the masked hint. */
|
|
620
|
+
async function setSecret(collectionId, authKitId, name, value) {
|
|
621
|
+
return put(`/admin/collection/${encodeURIComponent(collectionId)}/authKit/${encodeURIComponent(authKitId)}/secrets/${encodeURIComponent(name)}`, { value });
|
|
622
|
+
}
|
|
623
|
+
authKit.setSecret = setSecret;
|
|
624
|
+
/** Remove a secret (that provider then uses SmartLinks' own app). */
|
|
625
|
+
async function removeSecret(collectionId, authKitId, name) {
|
|
626
|
+
return del(`/admin/collection/${encodeURIComponent(collectionId)}/authKit/${encodeURIComponent(authKitId)}/secrets/${encodeURIComponent(name)}`);
|
|
627
|
+
}
|
|
628
|
+
authKit.removeSecret = removeSecret;
|
|
629
|
+
/**
|
|
630
|
+
* An account email as it would be sent now — or with draft settings (`emailTemplates`, `emailBranding`,
|
|
631
|
+
* `branding`; checked like a save, nothing stored). Sample values stand in for the person and the link.
|
|
632
|
+
*/
|
|
633
|
+
async function previewEmail(collectionId, authKitId, kind, draft = {}) {
|
|
634
|
+
return post(`/admin/collection/${encodeURIComponent(collectionId)}/authKit/${encodeURIComponent(authKitId)}/emails/${encodeURIComponent(kind)}/preview`, draft);
|
|
635
|
+
}
|
|
636
|
+
authKit.previewEmail = previewEmail;
|
|
586
637
|
async function remove(collectionId, authKitId) {
|
|
587
638
|
const path = `/admin/collection/${encodeURIComponent(collectionId)}/authKit/${encodeURIComponent(authKitId)}`;
|
|
588
639
|
return del(path);
|