@retion-miniapp/sdk 0.19.0 → 0.19.2
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/CHANGELOG.md +14 -0
- package/dist/index.cjs +39 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +39 -3
- package/dist/index.d.ts +39 -3
- package/dist/index.js +39 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -528,7 +528,41 @@ declare const AGENT_STOPPED_EVENT_TYPE = "retion.ai.stopped";
|
|
|
528
528
|
declare const AGENT_PAYLOAD_META_EVENT_TYPE = "retion.ai.payload_meta";
|
|
529
529
|
declare const AGENT_PAYLOAD_META_RESULT_EVENT_TYPE = "retion.ai.payload_meta_result";
|
|
530
530
|
/** Tin socket hội thoại Agent, app chủ đẩy nguyên vẹn */
|
|
531
|
-
|
|
531
|
+
/**
|
|
532
|
+
* Tin nhắn trong gói socket hội thoại Agent — chỉ khai báo field hay dùng, còn lại giữ nguyên như server trả.
|
|
533
|
+
* message_type: 'client' = tin agent, 'page' = tin mình (echo), 'system' = tin hệ thống.
|
|
534
|
+
*/
|
|
535
|
+
interface AgentSocketMessageItem {
|
|
536
|
+
_id?: string;
|
|
537
|
+
message_mid?: string;
|
|
538
|
+
message_text?: string;
|
|
539
|
+
message_type?: 'client' | 'page' | 'system' | (string & {});
|
|
540
|
+
fb_client_id?: string;
|
|
541
|
+
createdAt?: string;
|
|
542
|
+
updatedAt?: string;
|
|
543
|
+
/** Ngữ cảnh agent gắn vào câu hỏi (vd bộ lọc) */
|
|
544
|
+
payload_context?: unknown;
|
|
545
|
+
/** Dữ liệu mini app gửi bằng sendPayloadMeta */
|
|
546
|
+
payload_meta?: unknown;
|
|
547
|
+
message_attachments?: unknown[];
|
|
548
|
+
[key: string]: unknown;
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* 1 gói socket hội thoại Agent (đúng gói server bắn). Thường có `message` HOẶC `update_message`, kèm `conversation`
|
|
552
|
+
* và `raw` (webhook gốc). Field khác giữ nguyên.
|
|
553
|
+
*/
|
|
554
|
+
interface AgentSocketPacket {
|
|
555
|
+
/** Tin mới */
|
|
556
|
+
message?: AgentSocketMessageItem;
|
|
557
|
+
/** Tin cũ được cập nhật (vd gắn payload_context) */
|
|
558
|
+
update_message?: AgentSocketMessageItem;
|
|
559
|
+
/** Trạng thái hội thoại sau gói này */
|
|
560
|
+
conversation?: Record<string, unknown>;
|
|
561
|
+
/** Webhook gốc server nhận */
|
|
562
|
+
raw?: unknown;
|
|
563
|
+
[key: string]: unknown;
|
|
564
|
+
}
|
|
565
|
+
interface AgentMessage<TRaw = AgentSocketPacket> {
|
|
532
566
|
/** Phiên bản giao thức của app chủ */
|
|
533
567
|
v: number;
|
|
534
568
|
app_id: string;
|
|
@@ -564,6 +598,8 @@ interface SendPayloadMetaResult {
|
|
|
564
598
|
/** 'no_host' | 'unsupported' | 'invalid' | 'no_agent' | 'no_conversation' | 'send_failed' | 'timeout' … */
|
|
565
599
|
error?: string;
|
|
566
600
|
}
|
|
601
|
+
/** Bật / tắt log cầu nối Agent (mặc định bật). Log ra console cửa sổ cha nếu là app con trong iframe cùng origin. */
|
|
602
|
+
declare const setAgentBridgeDebug: (enabled: boolean) => void;
|
|
567
603
|
/**
|
|
568
604
|
* Nghe MỌI gói socket hội thoại Agent của mini app này — app chủ đẩy nguyên vẹn (step, trả lời…), mini app tự chọn.
|
|
569
605
|
* Mặc định bỏ gói chỉ chứa echo tin chính app vừa gửi bằng sendPayloadMeta (tránh vòng lặp).
|
|
@@ -572,7 +608,7 @@ interface SendPayloadMetaResult {
|
|
|
572
608
|
* @example
|
|
573
609
|
* const off = onAgentMessage(({ raw }) => handleAgentStep(raw));
|
|
574
610
|
*/
|
|
575
|
-
declare const onAgentMessage: <TRaw =
|
|
611
|
+
declare const onAgentMessage: <TRaw = AgentSocketPacket>(listener: (message: AgentMessage<TRaw>) => void, options?: OnAgentMessageOptions) => (() => void);
|
|
576
612
|
/**
|
|
577
613
|
* Nghe khi người dùng dừng lượt Agent (■ ở mini app hoặc nút dừng trong chat app chủ) → mini app ngừng thao tác.
|
|
578
614
|
*
|
|
@@ -727,4 +763,4 @@ declare const getUploadCapabilities: () => Promise<UploadCapabilities>;
|
|
|
727
763
|
*/
|
|
728
764
|
declare const uploadFiles: (options?: UploadFilesOptions) => Promise<UploadFilesResult>;
|
|
729
765
|
|
|
730
|
-
export { AGENT_BRIDGE_VERSION, AGENT_CONTEXT_EVENT_TYPE, AGENT_MESSAGE_EVENT_TYPE, AGENT_PAYLOAD_META_EVENT_TYPE, AGENT_PAYLOAD_META_RESULT_EVENT_TYPE, AGENT_STOPPED_EVENT_TYPE, type AgentContext, type AgentInfo, type AgentMessage, type AgentStopEvent, type BiometricAvailability, type BiometricRequest, type BiometricResult, type BiometryType, type ChangelogPopupOptions, CodeType, ErrorCode, HapticType, type LocationOptions, type LocationResult, MiniAppError, type OnAgentContextOptions, type OnAgentMessageOptions, type OpenScreenRequest, type PaymentRequest, type PaymentResult, type PrintImageRequest, type RouteParams, SDK_VERSION, type ScanCodeOptions, type ScanResult, type ScannerEnd, ScannerEndReason, ScannerEvent, type ScannerEvents, ScannerLayout, type SendPayloadMetaOptions, type SendPayloadMetaResult, type SetAgentOptions, type ShowToastOptions, type SpeechError, type SpeechEvents, type SpeechOptions, type SpeechResult, type StartScannerOptions, ToastType, type TokenType, type UploadCapabilities, type UploadFileType, type UploadFilesOptions, type UploadFilesResult, type UploadProcessOptions, type UploadProgress, type UploadTarget, type UploadUrlTarget, type UploadedFile, authenticateBiometric, closeApp, getAccessToken, getAgentBridgeVersion, getBiometricAvailability, getCurrentLocation, getRouteParams, getToken, getUploadCapabilities, haptic, isInHost, onAgentContext, onAgentMessage, onAgentStop, onAppPaused, onAppResumed, onContextChange, onScanner, onSpeech, openChangelogHistory, openChangelogPopup, openLink, openScreen, printImage, requestPayment, scanCode, sendPayloadMeta, setAgent, showToast, startScanner, startSpeech, stopScanner, stopSpeech, uploadFiles };
|
|
766
|
+
export { AGENT_BRIDGE_VERSION, AGENT_CONTEXT_EVENT_TYPE, AGENT_MESSAGE_EVENT_TYPE, AGENT_PAYLOAD_META_EVENT_TYPE, AGENT_PAYLOAD_META_RESULT_EVENT_TYPE, AGENT_STOPPED_EVENT_TYPE, type AgentContext, type AgentInfo, type AgentMessage, type AgentSocketMessageItem, type AgentSocketPacket, type AgentStopEvent, type BiometricAvailability, type BiometricRequest, type BiometricResult, type BiometryType, type ChangelogPopupOptions, CodeType, ErrorCode, HapticType, type LocationOptions, type LocationResult, MiniAppError, type OnAgentContextOptions, type OnAgentMessageOptions, type OpenScreenRequest, type PaymentRequest, type PaymentResult, type PrintImageRequest, type RouteParams, SDK_VERSION, type ScanCodeOptions, type ScanResult, type ScannerEnd, ScannerEndReason, ScannerEvent, type ScannerEvents, ScannerLayout, type SendPayloadMetaOptions, type SendPayloadMetaResult, type SetAgentOptions, type ShowToastOptions, type SpeechError, type SpeechEvents, type SpeechOptions, type SpeechResult, type StartScannerOptions, ToastType, type TokenType, type UploadCapabilities, type UploadFileType, type UploadFilesOptions, type UploadFilesResult, type UploadProcessOptions, type UploadProgress, type UploadTarget, type UploadUrlTarget, type UploadedFile, authenticateBiometric, closeApp, getAccessToken, getAgentBridgeVersion, getBiometricAvailability, getCurrentLocation, getRouteParams, getToken, getUploadCapabilities, haptic, isInHost, onAgentContext, onAgentMessage, onAgentStop, onAppPaused, onAppResumed, onContextChange, onScanner, onSpeech, openChangelogHistory, openChangelogPopup, openLink, openScreen, printImage, requestPayment, scanCode, sendPayloadMeta, setAgent, setAgentBridgeDebug, showToast, startScanner, startSpeech, stopScanner, stopSpeech, uploadFiles };
|
package/dist/index.d.ts
CHANGED
|
@@ -528,7 +528,41 @@ declare const AGENT_STOPPED_EVENT_TYPE = "retion.ai.stopped";
|
|
|
528
528
|
declare const AGENT_PAYLOAD_META_EVENT_TYPE = "retion.ai.payload_meta";
|
|
529
529
|
declare const AGENT_PAYLOAD_META_RESULT_EVENT_TYPE = "retion.ai.payload_meta_result";
|
|
530
530
|
/** Tin socket hội thoại Agent, app chủ đẩy nguyên vẹn */
|
|
531
|
-
|
|
531
|
+
/**
|
|
532
|
+
* Tin nhắn trong gói socket hội thoại Agent — chỉ khai báo field hay dùng, còn lại giữ nguyên như server trả.
|
|
533
|
+
* message_type: 'client' = tin agent, 'page' = tin mình (echo), 'system' = tin hệ thống.
|
|
534
|
+
*/
|
|
535
|
+
interface AgentSocketMessageItem {
|
|
536
|
+
_id?: string;
|
|
537
|
+
message_mid?: string;
|
|
538
|
+
message_text?: string;
|
|
539
|
+
message_type?: 'client' | 'page' | 'system' | (string & {});
|
|
540
|
+
fb_client_id?: string;
|
|
541
|
+
createdAt?: string;
|
|
542
|
+
updatedAt?: string;
|
|
543
|
+
/** Ngữ cảnh agent gắn vào câu hỏi (vd bộ lọc) */
|
|
544
|
+
payload_context?: unknown;
|
|
545
|
+
/** Dữ liệu mini app gửi bằng sendPayloadMeta */
|
|
546
|
+
payload_meta?: unknown;
|
|
547
|
+
message_attachments?: unknown[];
|
|
548
|
+
[key: string]: unknown;
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* 1 gói socket hội thoại Agent (đúng gói server bắn). Thường có `message` HOẶC `update_message`, kèm `conversation`
|
|
552
|
+
* và `raw` (webhook gốc). Field khác giữ nguyên.
|
|
553
|
+
*/
|
|
554
|
+
interface AgentSocketPacket {
|
|
555
|
+
/** Tin mới */
|
|
556
|
+
message?: AgentSocketMessageItem;
|
|
557
|
+
/** Tin cũ được cập nhật (vd gắn payload_context) */
|
|
558
|
+
update_message?: AgentSocketMessageItem;
|
|
559
|
+
/** Trạng thái hội thoại sau gói này */
|
|
560
|
+
conversation?: Record<string, unknown>;
|
|
561
|
+
/** Webhook gốc server nhận */
|
|
562
|
+
raw?: unknown;
|
|
563
|
+
[key: string]: unknown;
|
|
564
|
+
}
|
|
565
|
+
interface AgentMessage<TRaw = AgentSocketPacket> {
|
|
532
566
|
/** Phiên bản giao thức của app chủ */
|
|
533
567
|
v: number;
|
|
534
568
|
app_id: string;
|
|
@@ -564,6 +598,8 @@ interface SendPayloadMetaResult {
|
|
|
564
598
|
/** 'no_host' | 'unsupported' | 'invalid' | 'no_agent' | 'no_conversation' | 'send_failed' | 'timeout' … */
|
|
565
599
|
error?: string;
|
|
566
600
|
}
|
|
601
|
+
/** Bật / tắt log cầu nối Agent (mặc định bật). Log ra console cửa sổ cha nếu là app con trong iframe cùng origin. */
|
|
602
|
+
declare const setAgentBridgeDebug: (enabled: boolean) => void;
|
|
567
603
|
/**
|
|
568
604
|
* Nghe MỌI gói socket hội thoại Agent của mini app này — app chủ đẩy nguyên vẹn (step, trả lời…), mini app tự chọn.
|
|
569
605
|
* Mặc định bỏ gói chỉ chứa echo tin chính app vừa gửi bằng sendPayloadMeta (tránh vòng lặp).
|
|
@@ -572,7 +608,7 @@ interface SendPayloadMetaResult {
|
|
|
572
608
|
* @example
|
|
573
609
|
* const off = onAgentMessage(({ raw }) => handleAgentStep(raw));
|
|
574
610
|
*/
|
|
575
|
-
declare const onAgentMessage: <TRaw =
|
|
611
|
+
declare const onAgentMessage: <TRaw = AgentSocketPacket>(listener: (message: AgentMessage<TRaw>) => void, options?: OnAgentMessageOptions) => (() => void);
|
|
576
612
|
/**
|
|
577
613
|
* Nghe khi người dùng dừng lượt Agent (■ ở mini app hoặc nút dừng trong chat app chủ) → mini app ngừng thao tác.
|
|
578
614
|
*
|
|
@@ -727,4 +763,4 @@ declare const getUploadCapabilities: () => Promise<UploadCapabilities>;
|
|
|
727
763
|
*/
|
|
728
764
|
declare const uploadFiles: (options?: UploadFilesOptions) => Promise<UploadFilesResult>;
|
|
729
765
|
|
|
730
|
-
export { AGENT_BRIDGE_VERSION, AGENT_CONTEXT_EVENT_TYPE, AGENT_MESSAGE_EVENT_TYPE, AGENT_PAYLOAD_META_EVENT_TYPE, AGENT_PAYLOAD_META_RESULT_EVENT_TYPE, AGENT_STOPPED_EVENT_TYPE, type AgentContext, type AgentInfo, type AgentMessage, type AgentStopEvent, type BiometricAvailability, type BiometricRequest, type BiometricResult, type BiometryType, type ChangelogPopupOptions, CodeType, ErrorCode, HapticType, type LocationOptions, type LocationResult, MiniAppError, type OnAgentContextOptions, type OnAgentMessageOptions, type OpenScreenRequest, type PaymentRequest, type PaymentResult, type PrintImageRequest, type RouteParams, SDK_VERSION, type ScanCodeOptions, type ScanResult, type ScannerEnd, ScannerEndReason, ScannerEvent, type ScannerEvents, ScannerLayout, type SendPayloadMetaOptions, type SendPayloadMetaResult, type SetAgentOptions, type ShowToastOptions, type SpeechError, type SpeechEvents, type SpeechOptions, type SpeechResult, type StartScannerOptions, ToastType, type TokenType, type UploadCapabilities, type UploadFileType, type UploadFilesOptions, type UploadFilesResult, type UploadProcessOptions, type UploadProgress, type UploadTarget, type UploadUrlTarget, type UploadedFile, authenticateBiometric, closeApp, getAccessToken, getAgentBridgeVersion, getBiometricAvailability, getCurrentLocation, getRouteParams, getToken, getUploadCapabilities, haptic, isInHost, onAgentContext, onAgentMessage, onAgentStop, onAppPaused, onAppResumed, onContextChange, onScanner, onSpeech, openChangelogHistory, openChangelogPopup, openLink, openScreen, printImage, requestPayment, scanCode, sendPayloadMeta, setAgent, showToast, startScanner, startSpeech, stopScanner, stopSpeech, uploadFiles };
|
|
766
|
+
export { AGENT_BRIDGE_VERSION, AGENT_CONTEXT_EVENT_TYPE, AGENT_MESSAGE_EVENT_TYPE, AGENT_PAYLOAD_META_EVENT_TYPE, AGENT_PAYLOAD_META_RESULT_EVENT_TYPE, AGENT_STOPPED_EVENT_TYPE, type AgentContext, type AgentInfo, type AgentMessage, type AgentSocketMessageItem, type AgentSocketPacket, type AgentStopEvent, type BiometricAvailability, type BiometricRequest, type BiometricResult, type BiometryType, type ChangelogPopupOptions, CodeType, ErrorCode, HapticType, type LocationOptions, type LocationResult, MiniAppError, type OnAgentContextOptions, type OnAgentMessageOptions, type OpenScreenRequest, type PaymentRequest, type PaymentResult, type PrintImageRequest, type RouteParams, SDK_VERSION, type ScanCodeOptions, type ScanResult, type ScannerEnd, ScannerEndReason, ScannerEvent, type ScannerEvents, ScannerLayout, type SendPayloadMetaOptions, type SendPayloadMetaResult, type SetAgentOptions, type ShowToastOptions, type SpeechError, type SpeechEvents, type SpeechOptions, type SpeechResult, type StartScannerOptions, ToastType, type TokenType, type UploadCapabilities, type UploadFileType, type UploadFilesOptions, type UploadFilesResult, type UploadProcessOptions, type UploadProgress, type UploadTarget, type UploadUrlTarget, type UploadedFile, authenticateBiometric, closeApp, getAccessToken, getAgentBridgeVersion, getBiometricAvailability, getCurrentLocation, getRouteParams, getToken, getUploadCapabilities, haptic, isInHost, onAgentContext, onAgentMessage, onAgentStop, onAppPaused, onAppResumed, onContextChange, onScanner, onSpeech, openChangelogHistory, openChangelogPopup, openLink, openScreen, printImage, requestPayment, scanCode, sendPayloadMeta, setAgent, setAgentBridgeDebug, showToast, startScanner, startSpeech, stopScanner, stopSpeech, uploadFiles };
|
package/dist/index.js
CHANGED
|
@@ -195,7 +195,7 @@ var on = (event, listener) => {
|
|
|
195
195
|
};
|
|
196
196
|
|
|
197
197
|
// src/version.ts
|
|
198
|
-
var SDK_VERSION = "0.19.
|
|
198
|
+
var SDK_VERSION = "0.19.2" ;
|
|
199
199
|
|
|
200
200
|
// src/apis/app.ts
|
|
201
201
|
var closeApp = () => call("closeApp");
|
|
@@ -343,6 +343,7 @@ var announce = () => {
|
|
|
343
343
|
return false;
|
|
344
344
|
}
|
|
345
345
|
last_announced_at = Date.now();
|
|
346
|
+
agentLog("setAgent \u2192", `agent_id=${current.agent_id}`);
|
|
346
347
|
host.ReactNativeWebView.postMessage(JSON.stringify({
|
|
347
348
|
type: AGENT_EVENT_TYPE,
|
|
348
349
|
app_id: current.app_id,
|
|
@@ -446,6 +447,31 @@ var AGENT_MESSAGE_EVENT_TYPE = "retion.ai.message";
|
|
|
446
447
|
var AGENT_STOPPED_EVENT_TYPE = "retion.ai.stopped";
|
|
447
448
|
var AGENT_PAYLOAD_META_EVENT_TYPE = "retion.ai.payload_meta";
|
|
448
449
|
var AGENT_PAYLOAD_META_RESULT_EVENT_TYPE = "retion.ai.payload_meta_result";
|
|
450
|
+
var agent_debug = true;
|
|
451
|
+
var setAgentBridgeDebug = (enabled) => {
|
|
452
|
+
agent_debug = enabled;
|
|
453
|
+
};
|
|
454
|
+
var agentLog = (...args) => {
|
|
455
|
+
if (!agent_debug) {
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
let logger = console;
|
|
459
|
+
try {
|
|
460
|
+
if (typeof window !== "undefined" && window.parent && window.parent !== window) {
|
|
461
|
+
logger = window.parent.console;
|
|
462
|
+
}
|
|
463
|
+
} catch {
|
|
464
|
+
}
|
|
465
|
+
logger.log(`[retion-miniapp:agent${(current == null ? void 0 : current.app_id) ? `:${current.app_id}` : ""}]`, ...args);
|
|
466
|
+
};
|
|
467
|
+
var preview = (value) => {
|
|
468
|
+
try {
|
|
469
|
+
const text = JSON.stringify(value);
|
|
470
|
+
return text && text.length > 500 ? `${text.slice(0, 500)}\u2026` : text;
|
|
471
|
+
} catch {
|
|
472
|
+
return String(value);
|
|
473
|
+
}
|
|
474
|
+
};
|
|
449
475
|
var SENT_LIMIT = 50;
|
|
450
476
|
var sent_mids = [];
|
|
451
477
|
var sent_metas = [];
|
|
@@ -498,9 +524,11 @@ var listenHostEvent = (type, app_id, dedupeKey, handle) => {
|
|
|
498
524
|
}
|
|
499
525
|
const target_app = app_id != null ? app_id : current == null ? void 0 : current.app_id;
|
|
500
526
|
if (target_app && data.app_id && data.app_id !== target_app) {
|
|
527
|
+
agentLog(`${type}: b\u1ECF (c\u1EE7a app ${String(data.app_id)})`);
|
|
501
528
|
return;
|
|
502
529
|
}
|
|
503
530
|
if (!data.app_id && data.agent_id && (current == null ? void 0 : current.agent_id) && data.agent_id !== current.agent_id) {
|
|
531
|
+
agentLog(`${type}: b\u1ECF (c\u1EE7a agent ${String(data.agent_id)})`);
|
|
504
532
|
return;
|
|
505
533
|
}
|
|
506
534
|
const key = dedupeKey(data);
|
|
@@ -542,8 +570,10 @@ var onAgentMessage = (listener, options = {}) => listenHostEvent(
|
|
|
542
570
|
},
|
|
543
571
|
(data) => {
|
|
544
572
|
if (!options.includeEcho && isEchoOnly(data.raw)) {
|
|
573
|
+
agentLog("message: b\u1ECF echo tin m\xECnh v\u1EEBa g\u1EEDi", preview(data.raw));
|
|
545
574
|
return;
|
|
546
575
|
}
|
|
576
|
+
agentLog("message \u2190", `v${String(data.v)}`, `fb_client_id=${String(data.fb_client_id)}`, preview(data.raw));
|
|
547
577
|
const message = { ...data };
|
|
548
578
|
delete message.type;
|
|
549
579
|
listener(message);
|
|
@@ -557,6 +587,7 @@ var onAgentStop = (listener, options = {}) => {
|
|
|
557
587
|
return;
|
|
558
588
|
}
|
|
559
589
|
last_at = now;
|
|
590
|
+
agentLog("stopped \u2190", `source=${String(data.source)}`);
|
|
560
591
|
const event = { ...data };
|
|
561
592
|
delete event.type;
|
|
562
593
|
listener(event);
|
|
@@ -565,10 +596,12 @@ var onAgentStop = (listener, options = {}) => {
|
|
|
565
596
|
var request_seq = 0;
|
|
566
597
|
var sendPayloadMeta = (payload_meta, options = {}) => {
|
|
567
598
|
if (!payload_meta || typeof payload_meta !== "object" || Array.isArray(payload_meta)) {
|
|
599
|
+
agentLog("sendPayloadMeta: payload_meta ph\u1EA3i l\xE0 object", preview(payload_meta));
|
|
568
600
|
return Promise.resolve({ ok: false, error: "invalid" });
|
|
569
601
|
}
|
|
570
602
|
const host = getHostWindow();
|
|
571
603
|
if (!host) {
|
|
604
|
+
agentLog("sendPayloadMeta: kh\xF4ng ch\u1EA1y trong app ch\u1EE7 \u2192 b\u1ECF");
|
|
572
605
|
return Promise.resolve({ ok: false, error: "no_host" });
|
|
573
606
|
}
|
|
574
607
|
request_seq += 1;
|
|
@@ -576,7 +609,7 @@ var sendPayloadMeta = (payload_meta, options = {}) => {
|
|
|
576
609
|
const meta_key = JSON.stringify(payload_meta);
|
|
577
610
|
remember(sent_metas, meta_key);
|
|
578
611
|
return new Promise((resolve) => {
|
|
579
|
-
var _a, _b;
|
|
612
|
+
var _a, _b, _c;
|
|
580
613
|
let done = false;
|
|
581
614
|
const finish = (result) => {
|
|
582
615
|
if (done) {
|
|
@@ -588,6 +621,7 @@ var sendPayloadMeta = (payload_meta, options = {}) => {
|
|
|
588
621
|
if (result.message_mid) {
|
|
589
622
|
remember(sent_mids, result.message_mid);
|
|
590
623
|
}
|
|
624
|
+
agentLog("payload_meta_result \u2190", request_id, preview(result));
|
|
591
625
|
resolve(result);
|
|
592
626
|
};
|
|
593
627
|
const off = listenHostEvent(AGENT_PAYLOAD_META_RESULT_EVENT_TYPE, void 0, () => null, (data) => {
|
|
@@ -601,13 +635,14 @@ var sendPayloadMeta = (payload_meta, options = {}) => {
|
|
|
601
635
|
finish({ ...result, ok: !!data.ok });
|
|
602
636
|
});
|
|
603
637
|
const timer = setTimeout(() => finish({ ok: false, error: "timeout" }), (_a = options.timeout_ms) != null ? _a : 15e3);
|
|
638
|
+
agentLog("payload_meta \u2192", request_id, `text=${JSON.stringify((_b = options.text) != null ? _b : "")}`, preview(payload_meta));
|
|
604
639
|
host.ReactNativeWebView.postMessage(JSON.stringify({
|
|
605
640
|
type: AGENT_PAYLOAD_META_EVENT_TYPE,
|
|
606
641
|
v: AGENT_BRIDGE_VERSION,
|
|
607
642
|
request_id,
|
|
608
643
|
...(current == null ? void 0 : current.app_id) ? { app_id: current.app_id } : null,
|
|
609
644
|
...options.agent_id || (current == null ? void 0 : current.agent_id) ? { agent_id: options.agent_id || (current == null ? void 0 : current.agent_id) } : null,
|
|
610
|
-
text: (
|
|
645
|
+
text: (_c = options.text) != null ? _c : "",
|
|
611
646
|
payload_meta
|
|
612
647
|
}));
|
|
613
648
|
});
|
|
@@ -653,6 +688,6 @@ if (typeof window !== "undefined") {
|
|
|
653
688
|
}
|
|
654
689
|
}
|
|
655
690
|
|
|
656
|
-
export { AGENT_BRIDGE_VERSION, AGENT_CONTEXT_EVENT_TYPE, AGENT_MESSAGE_EVENT_TYPE, AGENT_PAYLOAD_META_EVENT_TYPE, AGENT_PAYLOAD_META_RESULT_EVENT_TYPE, AGENT_STOPPED_EVENT_TYPE, CodeType, ErrorCode, HapticType, MiniAppError, SDK_VERSION, ScannerEndReason, ScannerEvent, ScannerLayout, ToastType, authenticateBiometric, closeApp, getAccessToken, getAgentBridgeVersion, getBiometricAvailability, getCurrentLocation, getRouteParams, getToken, getUploadCapabilities, haptic, isInHost, onAgentContext, onAgentMessage, onAgentStop, onAppPaused, onAppResumed, onContextChange, onScanner, onSpeech, openChangelogHistory, openChangelogPopup, openLink, openScreen, printImage, requestPayment, scanCode, sendPayloadMeta, setAgent, showToast, startScanner, startSpeech, stopScanner, stopSpeech, uploadFiles };
|
|
691
|
+
export { AGENT_BRIDGE_VERSION, AGENT_CONTEXT_EVENT_TYPE, AGENT_MESSAGE_EVENT_TYPE, AGENT_PAYLOAD_META_EVENT_TYPE, AGENT_PAYLOAD_META_RESULT_EVENT_TYPE, AGENT_STOPPED_EVENT_TYPE, CodeType, ErrorCode, HapticType, MiniAppError, SDK_VERSION, ScannerEndReason, ScannerEvent, ScannerLayout, ToastType, authenticateBiometric, closeApp, getAccessToken, getAgentBridgeVersion, getBiometricAvailability, getCurrentLocation, getRouteParams, getToken, getUploadCapabilities, haptic, isInHost, onAgentContext, onAgentMessage, onAgentStop, onAppPaused, onAppResumed, onContextChange, onScanner, onSpeech, openChangelogHistory, openChangelogPopup, openLink, openScreen, printImage, requestPayment, scanCode, sendPayloadMeta, setAgent, setAgentBridgeDebug, showToast, startScanner, startSpeech, stopScanner, stopSpeech, uploadFiles };
|
|
657
692
|
//# sourceMappingURL=index.js.map
|
|
658
693
|
//# sourceMappingURL=index.js.map
|