@zhin.js/core 1.1.57 → 1.1.58

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 (89) hide show
  1. package/lib/built/user-interaction.d.ts +1 -1
  2. package/lib/feature/command.d.ts +2 -4
  3. package/lib/feature/command.js +1 -2
  4. package/lib/feature/middleware.d.ts +2 -2
  5. package/lib/feature/middleware.js +1 -1
  6. package/lib/index.d.ts +1 -1
  7. package/lib/plugin-runtime/im/command-feedback.d.ts +20 -1
  8. package/lib/plugin-runtime/im/command-feedback.js +63 -0
  9. package/lib/plugin-runtime/im/contracts.d.ts +60 -5
  10. package/lib/plugin-runtime/im/contracts.js +6 -2
  11. package/lib/plugin-runtime/im/endpoint-runtime.d.ts +2 -3
  12. package/lib/plugin-runtime/im/endpoint-runtime.js +2 -2
  13. package/lib/plugin-runtime/im/host/component-host-installer.d.ts +2 -0
  14. package/lib/plugin-runtime/im/host/component-host-installer.js +14 -0
  15. package/lib/plugin-runtime/im/host/conversation-migration.d.ts +5 -0
  16. package/lib/plugin-runtime/im/host/conversation-migration.js +75 -0
  17. package/lib/plugin-runtime/im/host/database-config.d.ts +10 -0
  18. package/lib/plugin-runtime/im/host/database-config.js +114 -0
  19. package/lib/plugin-runtime/im/host/database-host-installer.d.ts +13 -0
  20. package/lib/plugin-runtime/im/host/database-host-installer.js +389 -0
  21. package/lib/plugin-runtime/im/host/database-state.d.ts +9 -0
  22. package/lib/plugin-runtime/im/host/database-state.js +91 -0
  23. package/lib/plugin-runtime/im/host/index.d.ts +8 -0
  24. package/lib/plugin-runtime/im/host/index.js +8 -0
  25. package/lib/plugin-runtime/im/host/locale-host-installer.d.ts +3 -0
  26. package/lib/plugin-runtime/im/host/locale-host-installer.js +60 -0
  27. package/lib/plugin-runtime/im/host/outbound-host-installer.d.ts +8 -0
  28. package/lib/plugin-runtime/im/host/outbound-host-installer.js +153 -0
  29. package/lib/plugin-runtime/im/host/sender-enrichment.d.ts +33 -0
  30. package/lib/plugin-runtime/im/host/sender-enrichment.js +215 -0
  31. package/lib/plugin-runtime/im/im-runtime.d.ts +7 -3
  32. package/lib/plugin-runtime/im/im-runtime.js +9 -7
  33. package/lib/plugin-runtime/im/inbound-dedup.d.ts +32 -0
  34. package/lib/plugin-runtime/im/inbound-dedup.js +138 -1
  35. package/lib/plugin-runtime/im/inbound-origin.d.ts +24 -2
  36. package/lib/plugin-runtime/im/inbound-origin.js +108 -1
  37. package/lib/plugin-runtime/im/inbound-runtime.d.ts +10 -13
  38. package/lib/plugin-runtime/im/inbound-runtime.js +74 -411
  39. package/lib/plugin-runtime/im/inbound-spine.d.ts +194 -0
  40. package/lib/plugin-runtime/im/inbound-spine.js +333 -0
  41. package/lib/plugin-runtime/im/index.d.ts +4 -7
  42. package/lib/plugin-runtime/im/index.js +4 -6
  43. package/lib/plugin-runtime/im/interaction-runtime.d.ts +4 -7
  44. package/lib/plugin-runtime/im/interaction-runtime.js +5 -8
  45. package/lib/plugin-runtime/im/interactive-router.d.ts +31 -4
  46. package/lib/plugin-runtime/im/interactive-router.js +134 -2
  47. package/lib/plugin-runtime/im/message-dispatcher.d.ts +1 -1
  48. package/lib/plugin-runtime/im/message-dispatcher.js +1 -2
  49. package/lib/plugin-runtime/im/message-events.d.ts +33 -3
  50. package/lib/plugin-runtime/im/message-events.js +34 -0
  51. package/lib/plugin-runtime/im/outbound-delivery-runtime.d.ts +1 -2
  52. package/lib/plugin-runtime/im/outbound-delivery-runtime.js +4 -8
  53. package/lib/plugin-runtime/im/outbound-renderer.d.ts +32 -2
  54. package/lib/plugin-runtime/im/outbound-renderer.js +95 -4
  55. package/package.json +13 -14
  56. package/lib/plugin-runtime/im/captured-endpoint-operation.d.ts +0 -34
  57. package/lib/plugin-runtime/im/captured-endpoint-operation.js +0 -1
  58. package/lib/plugin-runtime/im/command-menu-navigation.d.ts +0 -13
  59. package/lib/plugin-runtime/im/command-menu-navigation.js +0 -43
  60. package/lib/plugin-runtime/im/command-menu-presentation.d.ts +0 -14
  61. package/lib/plugin-runtime/im/command-menu-presentation.js +0 -25
  62. package/lib/plugin-runtime/im/group-rule-violation.d.ts +0 -52
  63. package/lib/plugin-runtime/im/group-rule-violation.js +0 -10
  64. package/lib/plugin-runtime/im/ingress-route.d.ts +0 -10
  65. package/lib/plugin-runtime/im/ingress-route.js +0 -10
  66. package/lib/plugin-runtime/im/interaction-operation.d.ts +0 -12
  67. package/lib/plugin-runtime/im/interaction-operation.js +0 -2
  68. package/lib/plugin-runtime/im/jsx-button-registry.d.ts +0 -31
  69. package/lib/plugin-runtime/im/jsx-button-registry.js +0 -135
  70. package/lib/plugin-runtime/im/locale.d.ts +0 -5
  71. package/lib/plugin-runtime/im/locale.js +0 -12
  72. package/lib/plugin-runtime/im/login-assist-host.d.ts +0 -6
  73. package/lib/plugin-runtime/im/login-assist-host.js +0 -6
  74. package/lib/plugin-runtime/im/member-welcome.d.ts +0 -8
  75. package/lib/plugin-runtime/im/member-welcome.js +0 -11
  76. package/lib/plugin-runtime/im/message-bus.d.ts +0 -38
  77. package/lib/plugin-runtime/im/message-bus.js +0 -40
  78. package/lib/plugin-runtime/im/operation-endpoint.d.ts +0 -6
  79. package/lib/plugin-runtime/im/operation-endpoint.js +0 -2
  80. package/lib/plugin-runtime/im/operation-resources.d.ts +0 -15
  81. package/lib/plugin-runtime/im/operation-resources.js +0 -2
  82. package/lib/plugin-runtime/im/outbound-ledger.d.ts +0 -24
  83. package/lib/plugin-runtime/im/outbound-ledger.js +0 -114
  84. package/lib/plugin-runtime/im/outbound-presentation.d.ts +0 -19
  85. package/lib/plugin-runtime/im/outbound-presentation.js +0 -41
  86. package/lib/plugin-runtime/im/outbound-projection.d.ts +0 -17
  87. package/lib/plugin-runtime/im/outbound-projection.js +0 -55
  88. package/lib/plugin-runtime/im/runtime-middleware.d.ts +0 -5
  89. package/lib/plugin-runtime/im/runtime-middleware.js +0 -18
@@ -1,17 +0,0 @@
1
- import { type RuntimeSnapshot } from '@zhin.js/plugin-runtime';
2
- import { type ConversationRef } from '@zhin.js/im-contract';
3
- import type { OutboundFallbackReason, RuntimeMessageRendering } from './message-events.js';
4
- import type { OutboundPresentationPreferences } from './outbound-presentation.js';
5
- export interface OutboundProjection {
6
- readonly payload: unknown;
7
- readonly rendering: RuntimeMessageRendering;
8
- }
9
- /** Shared by transport and target-aware previews. Does not send or register callbacks. */
10
- export declare function projectOutboundPayload(rendered: unknown, conversation: ConversationRef, snapshot: RuntimeSnapshot, options?: {
11
- readonly rememberFallback?: (map: Record<string, string>) => Record<string, string> | void;
12
- readonly inheritedFallbacks?: readonly OutboundFallbackReason[];
13
- /** Keep keyboard payloads until outbound middleware has had a chance to replace them. */
14
- readonly deferInteractive?: boolean;
15
- readonly signal?: AbortSignal;
16
- readonly presentation?: OutboundPresentationPreferences;
17
- }): Promise<OutboundProjection>;
@@ -1,55 +0,0 @@
1
- import { htmlRendererToken } from '@zhin.js/plugin-runtime';
2
- import { EndpointDeliveryError } from '@zhin.js/im-contract';
3
- import { flattenOutboundArray } from '../../built/outbound-content-arrays.js';
4
- import { assertCanonicalSegments } from '../../built/segment-contract/assert.js';
5
- import { applyOutboundInteractivePolicy, applyOutboundMarkdownPolicy, normalizeOutboundPayload, resolveOutboundHtmlPolicy, resolveOutboundInteractivePolicy, resolveOutboundMarkdownPolicy, resolveOutboundMediaPolicy, resolveOutboundSupportedSegments, } from './outbound-segments.js';
6
- /** Shared by transport and target-aware previews. Does not send or register callbacks. */
7
- export async function projectOutboundPayload(rendered, conversation, snapshot, options = {}) {
8
- options.signal?.throwIfAborted();
9
- const adapter = conversation.endpoint.id;
10
- const reasons = new Set(options.inheritedFallbacks);
11
- const values = Array.isArray(rendered) ? flattenOutboundArray(rendered) : rendered;
12
- const contains = (type) => (Array.isArray(values) ? values : [values])
13
- .some(value => value && typeof value === 'object' && value.type === type);
14
- const markdown = options.presentation?.markdown === 'text' ? 'text' : resolveOutboundMarkdownPolicy(adapter, snapshot);
15
- if (markdown === 'text' && contains('markdown'))
16
- reasons.add('markdown_text_policy');
17
- const host = snapshot.resources.get(snapshot.root)?.get(htmlRendererToken.id);
18
- let payload = await normalizeOutboundPayload(applyOutboundMarkdownPolicy(values, markdown), host, {
19
- mediaPolicy: resolveOutboundMediaPolicy(adapter, snapshot),
20
- htmlPolicy: options.presentation?.html === 'text' ? 'text' : resolveOutboundHtmlPolicy(adapter, snapshot),
21
- onFallback: reason => reasons.add(reason),
22
- signal: options.signal,
23
- });
24
- options.signal?.throwIfAborted();
25
- const interactive = options.presentation?.interactive === 'text' ? 'text' : resolveOutboundInteractivePolicy(adapter, snapshot);
26
- if (interactive === 'text' && Array.isArray(payload) && payload.some(item => item?.type === 'keyboard')) {
27
- reasons.add('interactive_text_policy');
28
- }
29
- if (!options.deferInteractive)
30
- payload = applyOutboundInteractivePolicy(payload, interactive, options.rememberFallback);
31
- if (Array.isArray(payload)) {
32
- payload = payload.filter(item => !(item?.type === 'text' && item.data?.text === ''));
33
- assertCanonicalSegments(payload);
34
- }
35
- const supported = resolveOutboundSupportedSegments(adapter, snapshot);
36
- const supportedPayload = options.deferInteractive ? applyOutboundInteractivePolicy(payload, interactive) : payload;
37
- if (supported && Array.isArray(supportedPayload)) {
38
- const unsupported = supportedPayload.find(segment => segment && typeof segment === 'object'
39
- && typeof segment.type === 'string' && !supported.includes(segment.type));
40
- if (unsupported)
41
- throw new EndpointDeliveryError('unsupported_operation', `Adapter does not support canonical segment ${unsupported.type}`, 'not_sent');
42
- }
43
- const forms = new Set();
44
- for (const item of Array.isArray(payload) ? payload : [payload]) {
45
- if (typeof item === 'string' || item?.type === 'text')
46
- forms.add('text');
47
- else if (item?.type === 'image')
48
- forms.add('image');
49
- else if (item != null)
50
- forms.add('native');
51
- }
52
- return Object.freeze({ payload, rendering: Object.freeze({
53
- forms: Object.freeze([...forms]), fallbacks: Object.freeze([...reasons]),
54
- }) });
55
- }
@@ -1,5 +0,0 @@
1
- import type { RuntimeSnapshot } from '@zhin.js/plugin-runtime';
2
- /** Runs the generation-owned middleware projection or the terminal directly. */
3
- export declare function runRuntimeMiddleware<TInput>(snapshot: RuntimeSnapshot, input: TInput, terminal: () => Promise<void>, target: 'inbound' | 'outbound'): Promise<void>;
4
- /** Legacy outbound middleware sees one complete reply unless its author explicitly supports revisions. */
5
- export declare function supportsIncrementalOutbound(snapshot: RuntimeSnapshot, adapter: string): boolean;
@@ -1,18 +0,0 @@
1
- import { isMiddlewareIndex, middlewareFeatureId } from '@zhin.js/middleware';
2
- /** Runs the generation-owned middleware projection or the terminal directly. */
3
- export async function runRuntimeMiddleware(snapshot, input, terminal, target) {
4
- const index = middleware(snapshot);
5
- if (index)
6
- await index.run(input, terminal, target, snapshot);
7
- else
8
- await terminal();
9
- }
10
- function middleware(snapshot) {
11
- const projection = snapshot.projections.get(middlewareFeatureId);
12
- return isMiddlewareIndex(projection) ? projection : undefined;
13
- }
14
- /** Legacy outbound middleware sees one complete reply unless its author explicitly supports revisions. */
15
- export function supportsIncrementalOutbound(snapshot, adapter) {
16
- return middleware(snapshot)?.list().every(record => record.target !== 'outbound'
17
- || record.adapter !== undefined && record.adapter !== adapter || record.incremental === true) ?? true;
18
- }