@zhin.js/core 1.5.16 → 1.7.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/README.md +78 -195
- package/lib/ai-completion-contract.d.ts +135 -0
- package/lib/ai-completion-contract.js +69 -0
- package/lib/built/ai-access.d.ts +2 -21
- package/lib/built/ai-access.js +1 -46
- package/lib/built/ai-outbound/index.d.ts +0 -2
- package/lib/built/ai-outbound/index.js +0 -2
- package/lib/built/ai-outbound/prompt.d.ts +2 -0
- package/lib/built/ai-outbound/prompt.js +2 -0
- package/lib/built/ai-outbound/types.d.ts +1 -10
- package/lib/built/ai-trigger.d.ts +39 -78
- package/lib/built/ai-trigger.js +3 -254
- package/lib/built/common-adapter-tools.d.ts +21 -6
- package/lib/built/common-adapter-tools.js +28 -17
- package/lib/built/generic-segment-mapper.js +4 -1
- package/lib/built/html-segment-fallback.d.ts +6 -7
- package/lib/built/html-segment-fallback.js +1 -16
- package/lib/built/html-to-text.d.ts +0 -3
- package/lib/built/html-to-text.js +131 -40
- package/lib/built/interaction-messages.d.ts +1 -0
- package/lib/built/interaction-messages.js +30 -0
- package/lib/built/interactive-segments/action.d.ts +3 -4
- package/lib/built/interactive-segments/action.js +2 -5
- package/lib/built/interactive-segments/index.d.ts +0 -2
- package/lib/built/interactive-segments/index.js +0 -2
- package/lib/built/interactive-segments/keyboard-segment.d.ts +0 -1
- package/lib/built/interactive-segments/keyboard-segment.js +0 -1
- package/lib/built/interactive-segments/onebot-keyboard.d.ts +0 -1
- package/lib/built/interactive-segments/onebot-keyboard.js +0 -2
- package/lib/built/interactive-segments/resolve.d.ts +2 -3
- package/lib/built/interactive-segments/resolve.js +21 -14
- package/lib/built/interactive-segments/types.d.ts +2 -7
- package/lib/built/interactive-segments/types.js +22 -2
- package/lib/built/login-assist.d.ts +330 -25
- package/lib/built/login-assist.js +1156 -75
- package/lib/built/login-captcha.d.ts +62 -0
- package/lib/built/login-captcha.js +107 -0
- package/lib/built/message-enrich.d.ts +24 -27
- package/lib/built/message-enrich.js +53 -49
- package/lib/built/outbound-content-arrays.d.ts +4 -0
- package/lib/built/outbound-content-arrays.js +32 -0
- package/lib/built/outbound-media-trust.d.ts +46 -0
- package/lib/built/outbound-media-trust.js +245 -0
- package/lib/built/outbound-media-utils.d.ts +5 -3
- package/lib/built/outbound-media-utils.js +5 -3
- package/lib/built/readable-link.d.ts +4 -0
- package/lib/built/readable-link.js +32 -0
- package/lib/built/rich-segments/markdown-to-text.d.ts +1 -2
- package/lib/built/rich-segments/markdown-to-text.js +141 -17
- package/lib/built/roles.d.ts +141 -12
- package/lib/built/roles.js +253 -52
- package/lib/built/segment-contract/assert.js +8 -2
- package/lib/built/segment-contract/delivery.js +1 -0
- package/lib/built/segment-contract/index.d.ts +3 -3
- package/lib/built/segment-contract/index.js +2 -2
- package/lib/built/segment-contract/json-schema.d.ts +39 -5
- package/lib/built/segment-contract/json-schema.js +207 -24
- package/lib/built/segment-contract/preview.js +8 -1
- package/lib/built/segment-contract/text.js +1 -1
- package/lib/built/segment-contract/types.d.ts +2 -2
- package/lib/built/segment-contract/validate.d.ts +1553 -224
- package/lib/built/segment-contract/validate.js +39 -3
- package/lib/built/tool-access.d.ts +5 -0
- package/lib/built/tool-access.js +17 -0
- package/lib/built/user-interaction.d.ts +5 -4
- package/lib/built/user-interaction.js +64 -52
- package/lib/errors.d.ts +1 -18
- package/lib/errors.js +1 -26
- package/lib/feature/command-public-api.d.ts +5 -0
- package/lib/feature/command-public-api.js +5 -0
- package/lib/feature/command.d.ts +2 -0
- package/lib/feature/command.js +1 -0
- package/lib/feature/component.d.ts +1 -0
- package/lib/feature/component.js +1 -0
- package/lib/feature/handler.d.ts +13 -7
- package/lib/feature/handler.js +2 -1
- package/lib/feature/middleware-public-api.d.ts +6 -0
- package/lib/feature/middleware-public-api.js +6 -0
- package/lib/feature/middleware.d.ts +22 -2
- package/lib/feature/middleware.js +7 -2
- package/lib/im-scene.d.ts +4 -3
- package/lib/im-scene.js +9 -9
- package/lib/im-session-id.d.ts +20 -12
- package/lib/im-session-id.js +8 -8
- package/lib/index.d.ts +20 -48
- package/lib/index.js +15 -41
- package/lib/jsx/intrinsic-elements.d.ts +83 -0
- package/lib/jsx/message-renderer.d.ts +13 -0
- package/lib/jsx/message-renderer.js +128 -0
- package/lib/jsx/message-tags.d.ts +133 -0
- package/lib/jsx/message-tags.js +50 -0
- package/lib/jsx-dev-runtime.d.ts +2 -2
- package/lib/jsx-dev-runtime.js +1 -2
- package/lib/jsx-runtime.d.ts +2 -12
- package/lib/jsx-runtime.js +1 -10
- package/lib/jsx.d.ts +6 -30
- package/lib/jsx.js +3 -93
- package/lib/message.d.ts +0 -40
- package/lib/message.js +1 -27
- package/lib/models/system-log.d.ts +0 -2
- package/lib/models/system-log.js +1 -8
- package/lib/models/user.d.ts +0 -2
- package/lib/models/user.js +1 -7
- package/lib/notice.d.ts +38 -33
- package/lib/notice.js +23 -7
- package/lib/plugin-runtime/im/command-feedback.d.ts +59 -0
- package/lib/plugin-runtime/im/command-feedback.js +148 -0
- package/lib/plugin-runtime/im/contracts.d.ts +217 -32
- package/lib/plugin-runtime/im/contracts.js +141 -23
- package/lib/plugin-runtime/im/conversation-runtime.d.ts +42 -0
- package/lib/plugin-runtime/im/conversation-runtime.js +451 -0
- package/lib/plugin-runtime/im/endpoint-runtime.d.ts +112 -0
- package/lib/plugin-runtime/im/endpoint-runtime.js +434 -0
- package/lib/plugin-runtime/im/feature-gate.d.ts +21 -0
- package/lib/plugin-runtime/im/feature-gate.js +88 -0
- package/lib/plugin-runtime/im/host/component-host-installer.d.ts +2 -0
- package/lib/plugin-runtime/im/host/component-host-installer.js +14 -0
- package/lib/plugin-runtime/im/host/conversation-migration.d.ts +5 -0
- package/lib/plugin-runtime/im/host/conversation-migration.js +75 -0
- package/lib/plugin-runtime/im/host/database-config.d.ts +10 -0
- package/lib/plugin-runtime/im/host/database-config.js +152 -0
- package/lib/plugin-runtime/im/host/database-console-schema.d.ts +79 -0
- package/lib/plugin-runtime/im/host/database-console-schema.js +477 -0
- package/lib/plugin-runtime/im/host/database-console-sql.d.ts +66 -0
- package/lib/plugin-runtime/im/host/database-console-sql.js +459 -0
- package/lib/plugin-runtime/im/host/database-host-installer.d.ts +60 -0
- package/lib/plugin-runtime/im/host/database-host-installer.js +1166 -0
- package/lib/plugin-runtime/im/host/database-state.d.ts +9 -0
- package/lib/plugin-runtime/im/host/database-state.js +91 -0
- package/lib/plugin-runtime/im/host/index.d.ts +8 -0
- package/lib/plugin-runtime/im/host/index.js +8 -0
- package/lib/plugin-runtime/im/host/locale-host-installer.d.ts +3 -0
- package/lib/plugin-runtime/im/host/locale-host-installer.js +60 -0
- package/lib/plugin-runtime/im/host/outbound-host-installer.d.ts +8 -0
- package/lib/plugin-runtime/im/host/outbound-host-installer.js +153 -0
- package/lib/plugin-runtime/im/host/sender-enrichment.d.ts +34 -0
- package/lib/plugin-runtime/im/host/sender-enrichment.js +82 -0
- package/lib/plugin-runtime/im/im-runtime.d.ts +40 -111
- package/lib/plugin-runtime/im/im-runtime.js +235 -1059
- package/lib/plugin-runtime/im/inbound-dedup.d.ts +84 -0
- package/lib/plugin-runtime/im/inbound-dedup.js +322 -0
- package/lib/plugin-runtime/im/inbound-origin.d.ts +150 -0
- package/lib/plugin-runtime/im/inbound-origin.js +183 -0
- package/lib/plugin-runtime/im/inbound-runtime.d.ts +59 -0
- package/lib/plugin-runtime/im/inbound-runtime.js +478 -0
- package/lib/plugin-runtime/im/inbound-spine.d.ts +196 -0
- package/lib/plugin-runtime/im/inbound-spine.js +335 -0
- package/lib/plugin-runtime/im/index.d.ts +15 -4
- package/lib/plugin-runtime/im/index.js +11 -4
- package/lib/plugin-runtime/im/interaction-runtime.d.ts +50 -0
- package/lib/plugin-runtime/im/interaction-runtime.js +390 -0
- package/lib/plugin-runtime/im/interactive-router.d.ts +81 -0
- package/lib/plugin-runtime/im/interactive-router.js +382 -0
- package/lib/plugin-runtime/im/message-diagnostics.d.ts +70 -0
- package/lib/plugin-runtime/im/message-diagnostics.js +182 -0
- package/lib/plugin-runtime/im/message-dispatcher.d.ts +18 -4
- package/lib/plugin-runtime/im/message-dispatcher.js +138 -20
- package/lib/plugin-runtime/im/message-events.d.ts +85 -0
- package/lib/plugin-runtime/im/message-events.js +113 -0
- package/lib/plugin-runtime/im/outbound-delivery-runtime.d.ts +39 -0
- package/lib/plugin-runtime/im/outbound-delivery-runtime.js +450 -0
- package/lib/plugin-runtime/im/outbound-renderer.d.ts +52 -3
- package/lib/plugin-runtime/im/outbound-renderer.js +188 -8
- package/lib/plugin-runtime/im/outbound-segments.d.ts +29 -5
- package/lib/plugin-runtime/im/outbound-segments.js +130 -36
- package/lib/plugin-runtime/im/progressive-reply.d.ts +58 -0
- package/lib/plugin-runtime/im/progressive-reply.js +501 -0
- package/lib/plugin-runtime/im/public-api.d.ts +1 -1
- package/lib/request.d.ts +27 -36
- package/lib/request.js +14 -6
- package/lib/side-event/base.d.ts +64 -44
- package/lib/side-event/base.js +72 -19
- package/lib/side-event/index.d.ts +1 -1
- package/lib/side-event/index.js +1 -1
- package/lib/side-event/normalize.d.ts +7 -38
- package/lib/side-event/normalize.js +4 -109
- package/lib/side-event/scene-events.d.ts +40 -0
- package/lib/side-event/scene-events.js +147 -0
- package/lib/side-event/types.d.ts +4 -13
- package/lib/side-event/types.js +1 -55
- package/lib/system-event.d.ts +17 -12
- package/lib/system-event.js +8 -6
- package/lib/types.d.ts +23 -167
- package/lib/utils.d.ts +50 -33
- package/lib/utils.js +12 -185
- package/lib/venue/contracts.d.ts +21 -0
- package/lib/venue/contracts.js +3 -0
- package/lib/venue/floor-controller.d.ts +11 -0
- package/lib/venue/floor-controller.js +63 -0
- package/lib/venue/index.d.ts +13 -0
- package/lib/venue/index.js +11 -0
- package/lib/venue/membership-port.d.ts +23 -0
- package/lib/venue/membership-port.js +141 -0
- package/lib/venue/projector.d.ts +38 -0
- package/lib/venue/projector.js +45 -0
- package/lib/venue/registry.d.ts +16 -0
- package/lib/venue/registry.js +63 -0
- package/lib/venue/router.d.ts +19 -0
- package/lib/venue/router.js +101 -0
- package/lib/venue/send-limiter.d.ts +17 -0
- package/lib/venue/send-limiter.js +73 -0
- package/lib/venue/validator.d.ts +6 -0
- package/lib/venue/validator.js +160 -0
- package/package.json +24 -50
- package/lib/adapter.d.ts +0 -145
- package/lib/adapter.js +0 -377
- package/lib/built/adapter-process.d.ts +0 -58
- package/lib/built/adapter-process.js +0 -128
- package/lib/built/agent-preset.d.ts +0 -64
- package/lib/built/agent-preset.js +0 -79
- package/lib/built/ai-outbound/adapter-access.d.ts +0 -3
- package/lib/built/ai-outbound/adapter-access.js +0 -9
- package/lib/built/ai-outbound/extensions/qq-message.d.ts +0 -3
- package/lib/built/ai-outbound/extensions/qq-message.js +0 -23
- package/lib/built/authorization.d.ts +0 -10
- package/lib/built/authorization.js +0 -76
- package/lib/built/command.d.ts +0 -72
- package/lib/built/command.js +0 -105
- package/lib/built/component.d.ts +0 -67
- package/lib/built/component.js +0 -97
- package/lib/built/config.d.ts +0 -98
- package/lib/built/config.js +0 -372
- package/lib/built/connect-endpoint-instance.d.ts +0 -17
- package/lib/built/connect-endpoint-instance.js +0 -42
- package/lib/built/database.d.ts +0 -68
- package/lib/built/database.js +0 -106
- package/lib/built/dispatcher.d.ts +0 -141
- package/lib/built/dispatcher.js +0 -383
- package/lib/built/endpoint-commands.d.ts +0 -3
- package/lib/built/endpoint-commands.js +0 -99
- package/lib/built/endpoint-lifecycle-service.d.ts +0 -28
- package/lib/built/endpoint-lifecycle-service.js +0 -242
- package/lib/built/endpoint-lifecycle.d.ts +0 -27
- package/lib/built/endpoint-lifecycle.js +0 -36
- package/lib/built/endpoint-manager.d.ts +0 -34
- package/lib/built/html-renderer-loader.d.ts +0 -13
- package/lib/built/html-renderer-loader.js +0 -33
- package/lib/built/inbound-pipeline.d.ts +0 -37
- package/lib/built/inbound-pipeline.js +0 -63
- package/lib/built/inbound-runner.d.ts +0 -22
- package/lib/built/inbound-runner.js +0 -34
- package/lib/built/interactive-segment-contract.d.ts +0 -6
- package/lib/built/interactive-segment-contract.js +0 -9
- package/lib/built/interactive-segments/fallback-store.d.ts +0 -29
- package/lib/built/interactive-segments/fallback-store.js +0 -63
- package/lib/built/interactive-segments/handlers.d.ts +0 -16
- package/lib/built/interactive-segments/handlers.js +0 -74
- package/lib/built/introspection-format.d.ts +0 -10
- package/lib/built/introspection-format.js +0 -28
- package/lib/built/management-command-guard.d.ts +0 -15
- package/lib/built/management-command-guard.js +0 -25
- package/lib/built/message-filter.d.ts +0 -176
- package/lib/built/message-filter.js +0 -239
- package/lib/built/optional-peer-import.d.ts +0 -3
- package/lib/built/optional-peer-import.js +0 -33
- package/lib/built/outbound-media-contract.d.ts +0 -22
- package/lib/built/outbound-media-contract.js +0 -10
- package/lib/built/permission.d.ts +0 -51
- package/lib/built/permission.js +0 -99
- package/lib/built/permit-check.d.ts +0 -7
- package/lib/built/permit-check.js +0 -35
- package/lib/built/permit-parse.d.ts +0 -16
- package/lib/built/permit-parse.js +0 -32
- package/lib/built/platform-permit.d.ts +0 -20
- package/lib/built/platform-permit.js +0 -91
- package/lib/built/queue-im-field-contract.d.ts +0 -32
- package/lib/built/queue-im-field-contract.js +0 -67
- package/lib/built/rich-segments/adapter-policies.d.ts +0 -9
- package/lib/built/rich-segments/adapter-policies.js +0 -27
- package/lib/built/rich-segments/base.d.ts +0 -11
- package/lib/built/rich-segments/base.js +0 -24
- package/lib/built/rich-segments/builtins.d.ts +0 -4
- package/lib/built/rich-segments/builtins.js +0 -40
- package/lib/built/rich-segments/capabilities.d.ts +0 -6
- package/lib/built/rich-segments/capabilities.js +0 -38
- package/lib/built/rich-segments/html-segment.d.ts +0 -15
- package/lib/built/rich-segments/html-segment.js +0 -62
- package/lib/built/rich-segments/index.d.ts +0 -13
- package/lib/built/rich-segments/index.js +0 -13
- package/lib/built/rich-segments/markdown-segment.d.ts +0 -14
- package/lib/built/rich-segments/markdown-segment.js +0 -58
- package/lib/built/rich-segments/qrcode-segment.d.ts +0 -18
- package/lib/built/rich-segments/qrcode-segment.js +0 -73
- package/lib/built/rich-segments/registry.d.ts +0 -16
- package/lib/built/rich-segments/registry.js +0 -52
- package/lib/built/rich-segments/resolve.d.ts +0 -5
- package/lib/built/rich-segments/resolve.js +0 -87
- package/lib/built/rich-segments/tts-segment.d.ts +0 -13
- package/lib/built/rich-segments/tts-segment.js +0 -51
- package/lib/built/rich-segments/types.d.ts +0 -79
- package/lib/built/rich-segments/types.js +0 -17
- package/lib/built/runtime-io.d.ts +0 -9
- package/lib/built/runtime-io.js +0 -67
- package/lib/built/schedule.d.ts +0 -54
- package/lib/built/schedule.js +0 -112
- package/lib/built/schema-endpoint-manager.d.ts +0 -17
- package/lib/built/schema-endpoint-manager.js +0 -73
- package/lib/built/schema-feature.d.ts +0 -77
- package/lib/built/schema-feature.js +0 -130
- package/lib/built/skill.d.ts +0 -120
- package/lib/built/skill.js +0 -151
- package/lib/built/speech-loader.d.ts +0 -14
- package/lib/built/speech-loader.js +0 -32
- package/lib/built/tool.d.ts +0 -151
- package/lib/built/tool.js +0 -388
- package/lib/command.d.ts +0 -50
- package/lib/command.js +0 -106
- package/lib/component.d.ts +0 -26
- package/lib/component.js +0 -583
- package/lib/endpoint-capabilities.d.ts +0 -46
- package/lib/endpoint-capabilities.js +0 -55
- package/lib/endpoint.d.ts +0 -19
- package/lib/endpoint.js +0 -3
- package/lib/host-plugin-registry.d.ts +0 -8
- package/lib/host-plugin-registry.js +0 -12
- package/lib/plugin-context.d.ts +0 -27
- package/lib/plugin-context.js +0 -64
- package/lib/plugin-runtime/im/interactive.d.ts +0 -26
- package/lib/plugin-runtime/im/interactive.js +0 -46
- package/lib/plugin-runtime/im/login-assist-host.d.ts +0 -6
- package/lib/plugin-runtime/im/login-assist-host.js +0 -6
- package/lib/plugin-runtime/im/message-bus.d.ts +0 -38
- package/lib/plugin-runtime/im/message-bus.js +0 -40
- package/lib/plugin-runtime/im/service-tokens.d.ts +0 -18
- package/lib/plugin-runtime/im/service-tokens.js +0 -13
- package/lib/plugin.d.ts +0 -268
- package/lib/plugin.js +0 -583
- package/lib/schema-interaction.d.ts +0 -117
- package/lib/schema-interaction.js +0 -247
- package/lib/side-event/dispatch.d.ts +0 -15
- package/lib/side-event/dispatch.js +0 -140
- package/lib/tool-zod.d.ts +0 -43
- package/lib/tool-zod.js +0 -184
- /package/lib/{built/endpoint-manager.js → jsx/intrinsic-elements.js} +0 -0
package/lib/built/roles.js
CHANGED
|
@@ -1,62 +1,263 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
/**
|
|
2
|
+
* ADR 0056: chat roles — zhin roles at four levels, next to (never derived from) the normalized
|
|
3
|
+
* platform standing.
|
|
4
|
+
*
|
|
5
|
+
* - zhin roles: `owner` ⊃ `admin` ⊃ `trusted`, held by a platform identity `(adapter alias, userId)`
|
|
6
|
+
* at one scope (`''`, `<alias>`, `<alias>/<endpointId>` or a conversation key) and effective at
|
|
7
|
+
* that scope and every scope under it. They come only from stored grants (the instance's
|
|
8
|
+
* `chat_roles` table, including grants migrated from the old configuration lists).
|
|
9
|
+
* - Platform standing (group owner / admin, platform roles and permissions) is *not* converted into
|
|
10
|
+
* a zhin role (ADR 0056 §4, revised 2026-11-12); it is a separate dimension read by `platform:*`
|
|
11
|
+
* permits, and the Bot account's own standing by `bot:*` permits.
|
|
12
|
+
* - Every inbound message gets `sender.chatRole` (highest role effective in its conversation) and a
|
|
13
|
+
* normalized `sender.platform` from {@link createChatRoleSenderEnricher}.
|
|
14
|
+
*/
|
|
15
|
+
import { normalizePlatformStanding, } from '@zhin.js/im-contract';
|
|
16
|
+
import { featureKeyLevel, formatFeatureResolutionKey, parseFeatureConversationKey, parseFeatureResolutionKey, resolveEndpointFeatureKey, } from '@zhin.js/plugin-runtime';
|
|
17
|
+
export { CHAT_ROLE_LEVELS, chatRoleHeldAt, hostChatRole, isChatRoleLevel, normalizeChatRoleLevels, } from '@zhin.js/im-contract';
|
|
18
|
+
export const CHAT_ROLES = Object.freeze(['owner', 'admin', 'trusted']);
|
|
19
|
+
const RANK = Object.freeze({ trusted: 1, admin: 2, owner: 3 });
|
|
20
|
+
export function isChatRole(value) {
|
|
21
|
+
return value === 'owner' || value === 'admin' || value === 'trusted';
|
|
22
|
+
}
|
|
23
|
+
/** `owner` ⊃ `admin` ⊃ `trusted`. */
|
|
24
|
+
export function chatRoleIncludes(held, required) {
|
|
25
|
+
return held !== undefined && RANK[held] >= RANK[required];
|
|
26
|
+
}
|
|
27
|
+
/** The higher of two roles. */
|
|
28
|
+
export function higherChatRole(left, right) {
|
|
29
|
+
if (!left)
|
|
30
|
+
return right;
|
|
31
|
+
if (!right)
|
|
32
|
+
return left;
|
|
33
|
+
return RANK[right] > RANK[left] ? right : left;
|
|
34
|
+
}
|
|
35
|
+
/** Whether a role list (expanded or not, other strings ignored) holds `required`. */
|
|
36
|
+
export function chatRolesInclude(roles, required) {
|
|
37
|
+
return (roles ?? []).some(role => isChatRole(role) && chatRoleIncludes(role, required));
|
|
38
|
+
}
|
|
39
|
+
/** `owner` → `[owner, admin, trusted]`, `admin` → `[admin, trusted]`, none → `[]`. */
|
|
40
|
+
export function expandChatRole(role) {
|
|
41
|
+
return role ? CHAT_ROLES.filter(candidate => chatRoleIncludes(role, candidate)) : [];
|
|
42
|
+
}
|
|
43
|
+
// ============================================================================
|
|
44
|
+
// Identities and scopes
|
|
45
|
+
// ============================================================================
|
|
46
|
+
const ADAPTER_ALIAS = /^[a-z0-9][a-z0-9-]*$/u;
|
|
47
|
+
// eslint-disable-next-line no-control-regex
|
|
48
|
+
const CONTROL = /[\u0000-\u001f\u007f]/u;
|
|
49
|
+
export function isChatIdentity(value) {
|
|
50
|
+
const identity = value;
|
|
51
|
+
return !!identity && typeof identity.adapter === 'string' && ADAPTER_ALIAS.test(identity.adapter)
|
|
52
|
+
&& typeof identity.userId === 'string' && identity.userId.length > 0 && identity.userId.length <= 256 && !CONTROL.test(identity.userId);
|
|
53
|
+
}
|
|
54
|
+
/** Validates `level` + `key` and returns the normalized scope key; throws TypeError. */
|
|
55
|
+
export function normalizeChatRoleScope(level, key) {
|
|
56
|
+
if (level === 'global') {
|
|
57
|
+
if (key !== undefined && key !== '')
|
|
58
|
+
throw new TypeError('global scope takes no key');
|
|
59
|
+
return '';
|
|
60
|
+
}
|
|
61
|
+
if (level !== 'adapter' && level !== 'endpoint' && level !== 'conversation')
|
|
62
|
+
throw new TypeError('level must be global, adapter, endpoint or conversation');
|
|
63
|
+
if (typeof key !== 'string' || !key)
|
|
64
|
+
throw new TypeError('key is required');
|
|
65
|
+
let normalized;
|
|
66
|
+
try {
|
|
67
|
+
normalized = formatFeatureResolutionKey(parseFeatureResolutionKey(key));
|
|
15
68
|
}
|
|
16
|
-
|
|
69
|
+
catch {
|
|
70
|
+
throw new TypeError(`key does not address the ${level} level`);
|
|
71
|
+
}
|
|
72
|
+
if (normalized !== key || featureKeyLevel(key) !== level)
|
|
73
|
+
throw new TypeError(`key does not address the ${level} level`);
|
|
74
|
+
if (!ADAPTER_ALIAS.test(parseFeatureResolutionKey(key).adapter ?? ''))
|
|
75
|
+
throw new TypeError('key must start with an adapter instance alias');
|
|
76
|
+
return key;
|
|
77
|
+
}
|
|
78
|
+
/** Scope keys from global down to `key` (`''`, `qq`, `qq/bot`, `qq/bot/group:1`). */
|
|
79
|
+
export function chatScopeChain(key) {
|
|
80
|
+
const parsed = parseFeatureResolutionKey(key);
|
|
81
|
+
const chain = [''];
|
|
82
|
+
if (parsed.adapter !== undefined)
|
|
83
|
+
chain.push(parsed.adapter);
|
|
84
|
+
if (parsed.endpointId !== undefined)
|
|
85
|
+
chain.push(`${parsed.adapter}/${parsed.endpointId}`);
|
|
86
|
+
if (parsed.conversation !== undefined)
|
|
87
|
+
chain.push(formatFeatureResolutionKey(parsed));
|
|
88
|
+
return Object.freeze(chain);
|
|
17
89
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const expanded = expandImpliedRoles(callerRoles);
|
|
22
|
-
return requiredAnyRole.some((req) => expanded.has(req));
|
|
90
|
+
/** Whether scope `upper` is `lower` or one of its ancestors. */
|
|
91
|
+
export function chatScopeCovers(upper, lower) {
|
|
92
|
+
return chatScopeChain(lower).includes(upper);
|
|
23
93
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
94
|
+
export function chatScopeLevel(key) {
|
|
95
|
+
return key === '' ? 'global' : featureKeyLevel(key);
|
|
96
|
+
}
|
|
97
|
+
/** Per role, the level of the topmost entry holding it (entries sorted global first). */
|
|
98
|
+
function chatRoleLevelsOf(entries) {
|
|
99
|
+
const levels = {};
|
|
100
|
+
for (const role of CHAT_ROLES) {
|
|
101
|
+
const top = entries.find(entry => chatRoleIncludes(entry.role, role));
|
|
102
|
+
if (top)
|
|
103
|
+
levels[role] = top.level;
|
|
30
104
|
}
|
|
31
|
-
|
|
32
|
-
return ['user'];
|
|
33
|
-
return [...set];
|
|
105
|
+
return Object.freeze(levels);
|
|
34
106
|
}
|
|
35
|
-
|
|
36
|
-
|
|
107
|
+
function highest(entries) {
|
|
108
|
+
let best;
|
|
109
|
+
for (const entry of entries)
|
|
110
|
+
best = higherChatRole(best, entry.role);
|
|
111
|
+
return best;
|
|
37
112
|
}
|
|
38
|
-
|
|
39
|
-
|
|
113
|
+
/**
|
|
114
|
+
* Resolution over stored grants (ADR 0056 §2): for a message the chain is
|
|
115
|
+
* conversation → endpoint → adapter → global and the highest role wins.
|
|
116
|
+
*/
|
|
117
|
+
export class ChatRoleService {
|
|
118
|
+
store;
|
|
119
|
+
constructor(options) {
|
|
120
|
+
this.store = options.store;
|
|
121
|
+
}
|
|
122
|
+
/** Entries of `identity` effective at `scopeKey` (own scope and every ancestor). */
|
|
123
|
+
entriesFor(identity, scopeKey) {
|
|
124
|
+
const chain = chatScopeChain(scopeKey);
|
|
125
|
+
const stored = this.store.list().filter(entry => entry.adapter === identity.adapter && entry.userId === identity.userId && chain.includes(entry.key));
|
|
126
|
+
return Object.freeze([...stored].sort((left, right) => chain.indexOf(left.key) - chain.indexOf(right.key)));
|
|
127
|
+
}
|
|
128
|
+
/** Highest role of `identity` effective at `scopeKey`. */
|
|
129
|
+
roleAt(identity, scopeKey) {
|
|
130
|
+
return highest(this.entriesFor(identity, scopeKey));
|
|
131
|
+
}
|
|
132
|
+
hasRole(identity, scopeKey, role) {
|
|
133
|
+
return chatRoleIncludes(this.roleAt(identity, scopeKey), role);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Per role, the topmost level at which `identity` holds that role (or a higher one) on the chain
|
|
137
|
+
* of `scopeKey` (`sender.chatRoleLevels`).
|
|
138
|
+
*/
|
|
139
|
+
levelsFor(identity, scopeKey) {
|
|
140
|
+
return chatRoleLevelsOf(this.entriesFor(identity, scopeKey));
|
|
141
|
+
}
|
|
142
|
+
/** Highest role held at a scope strictly above `scopeKey`. */
|
|
143
|
+
roleAbove(identity, scopeKey) {
|
|
144
|
+
return highest(this.entriesFor(identity, scopeKey).filter(entry => entry.key !== scopeKey));
|
|
145
|
+
}
|
|
146
|
+
/** Sender roles for a message (`undefined` outside a keyed conversation). */
|
|
147
|
+
effectiveRoles(snapshot, message) {
|
|
148
|
+
const subject = chatRoleMessageContext(snapshot, message);
|
|
149
|
+
if (!subject)
|
|
150
|
+
return undefined;
|
|
151
|
+
const entries = this.entriesFor(subject.identity, subject.context.conversationKey);
|
|
152
|
+
const role = highest(entries);
|
|
153
|
+
return Object.freeze({ identity: subject.identity, conversationKey: subject.context.conversationKey, ...(role ? { role } : {}), entries });
|
|
154
|
+
}
|
|
155
|
+
/** Stored entries covering `scopeKey` (and below it with `descendants`). */
|
|
156
|
+
list(scopeKey, descendants = false) {
|
|
157
|
+
const relevant = (key) => chatScopeCovers(key, scopeKey) || (descendants && chatScopeCovers(scopeKey, key));
|
|
158
|
+
return Object.freeze(this.store.list().filter(entry => relevant(entry.key)));
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Stored `owner`s of `scopeKey` and its ancestors whose identity is on `adapter`, closest scope
|
|
162
|
+
* first (who to ask for owner approval on an account).
|
|
163
|
+
*/
|
|
164
|
+
ownersOf(scopeKey, adapter) {
|
|
165
|
+
const chain = chatScopeChain(scopeKey);
|
|
166
|
+
const owners = this.store.list()
|
|
167
|
+
.filter(entry => entry.role === 'owner' && entry.adapter === adapter && chain.includes(entry.key))
|
|
168
|
+
.sort((left, right) => chain.indexOf(right.key) - chain.indexOf(left.key));
|
|
169
|
+
return Object.freeze([...new Set(owners.map(entry => entry.userId))]);
|
|
170
|
+
}
|
|
40
171
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
172
|
+
// ============================================================================
|
|
173
|
+
// Platform standing
|
|
174
|
+
// ============================================================================
|
|
175
|
+
const record = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
|
|
176
|
+
/** Normalized platform standing of a sender (`sender.platform`, ADR 0056 §1). */
|
|
177
|
+
export function platformStandingOf(sender) {
|
|
178
|
+
return record(sender) ? normalizePlatformStanding(sender.platform) : undefined;
|
|
179
|
+
}
|
|
180
|
+
/** `platform:admin` is met by `admin` and `owner` standings, `platform:owner` only by `owner`. */
|
|
181
|
+
export function platformStandingIncludes(held, required) {
|
|
182
|
+
return required === 'owner' ? held === 'owner' : held === 'owner' || held === 'admin';
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Identity + context of a message's sender. `context.conversationKey` is the conversation key, or —
|
|
186
|
+
* when the conversation cannot be keyed (unknown kind, an id that cannot be part of a key) — the
|
|
187
|
+
* receiving endpoint's key, so roles granted at the endpoint level and above still resolve.
|
|
188
|
+
* Threads / topics (`conversation.threadId`) share their parent conversation's key, and a platform
|
|
189
|
+
* container (`conversation.parent`, e.g. a guild) adds no level (ADR 0056 §2).
|
|
190
|
+
* Undefined when not even the endpoint can be addressed.
|
|
191
|
+
*/
|
|
192
|
+
export function chatRoleMessageContext(snapshot, message) {
|
|
193
|
+
if (!record(message) || !record(message.conversation) || !record(message.conversation.endpoint))
|
|
194
|
+
return undefined;
|
|
195
|
+
const conversation = message.conversation;
|
|
196
|
+
if (typeof conversation.endpoint.id !== 'string')
|
|
197
|
+
return undefined;
|
|
198
|
+
const key = resolveEndpointFeatureKey(snapshot, conversation.endpoint.id, typeof message.endpointId === 'string' ? message.endpointId : undefined, conversation);
|
|
199
|
+
if (!key)
|
|
200
|
+
return undefined;
|
|
201
|
+
let adapter;
|
|
202
|
+
try {
|
|
203
|
+
adapter = parseFeatureResolutionKey(key).adapter;
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
return undefined;
|
|
207
|
+
}
|
|
208
|
+
if (!adapter)
|
|
209
|
+
return undefined;
|
|
210
|
+
const parsed = parseFeatureConversationKey(key);
|
|
211
|
+
const sender = record(message.sender) ? message.sender : undefined;
|
|
212
|
+
const identity = { adapter, userId: typeof sender?.id === 'string' ? sender.id : '' };
|
|
213
|
+
if (!isChatIdentity(identity))
|
|
214
|
+
return undefined;
|
|
215
|
+
const kind = parsed?.conversation.kind ?? conversation.kind;
|
|
216
|
+
const platform = kind === 'private' ? undefined : platformStandingOf(sender);
|
|
217
|
+
return { identity, context: { conversationKey: key, ...(platform ? { platform } : {}) } };
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Inbound sender enricher: drops any adapter-supplied `chatRole` / `chatRoleLevels`, normalizes
|
|
221
|
+
* `platform` (not in private chats) and sets `chatRole` to the highest role effective in the
|
|
222
|
+
* conversation and `chatRoleLevels` to where each role comes from.
|
|
223
|
+
*/
|
|
224
|
+
export function createChatRoleSenderEnricher(options) {
|
|
225
|
+
return (sender, conversation, snapshot) => {
|
|
226
|
+
if (!sender?.id)
|
|
227
|
+
return sender;
|
|
228
|
+
const { chatRole: _spoofed, chatRoleLevels: _spoofedLevels, platform: _reported, ...rest } = sender;
|
|
229
|
+
const platform = conversation.kind === 'private' ? undefined : platformStandingOf(sender);
|
|
230
|
+
const base = { ...rest, ...(platform ? { platform } : {}) };
|
|
231
|
+
const service = options.roles();
|
|
232
|
+
if (!service || !snapshot)
|
|
233
|
+
return Object.freeze(base);
|
|
234
|
+
const subject = chatRoleMessageContext(snapshot, { conversation, sender: base });
|
|
235
|
+
if (!subject)
|
|
236
|
+
return Object.freeze(base);
|
|
237
|
+
let entries;
|
|
238
|
+
try {
|
|
239
|
+
entries = service.entriesFor(subject.identity, subject.context.conversationKey);
|
|
54
240
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
text = text.slice(m2[0].length);
|
|
58
|
-
changed = true;
|
|
241
|
+
catch {
|
|
242
|
+
entries = [];
|
|
59
243
|
}
|
|
60
|
-
|
|
61
|
-
|
|
244
|
+
const role = highest(entries);
|
|
245
|
+
return Object.freeze({ ...base, ...(role ? { chatRole: role, chatRoleLevels: chatRoleLevelsOf(entries) } : {}) });
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
// ============================================================================
|
|
249
|
+
// Prompt label hygiene
|
|
250
|
+
// ============================================================================
|
|
251
|
+
// 空白与零宽字符(不含 U+200D:会破坏 emoji ZWJ 序列)。
|
|
252
|
+
const SPOOF_GAP = '[\\s\\u200B\\u200C\\u2060\\uFEFF]';
|
|
253
|
+
const spoofWord = (word) => word.split('').join(`${SPOOF_GAP}*`);
|
|
254
|
+
const SPOOFED_LABEL_RE = new RegExp(`\\[(?=${SPOOF_GAP}*(?:${spoofWord('sender')}|${spoofWord('origin')})${SPOOF_GAP}*[::])`, 'gi');
|
|
255
|
+
/**
|
|
256
|
+
* 转义用户正文里所有自造的 `[sender:` / `[origin:` 标签(任意位置、大小写不敏感,
|
|
257
|
+
* 容忍 `[ sender :`、零宽字符、全角冒号)。命中时把开头的 ASCII `[` 换成全角 `[`,
|
|
258
|
+
* 其余原样保留:模型仍能看出这是用户文本,但它不再是权威标签。
|
|
259
|
+
* 幂等(已转义文本再次调用不变),不再剥离开头,也不 trim 原文空白。
|
|
260
|
+
*/
|
|
261
|
+
export function stripUserSpoofedSenderPrefix(rawContent) {
|
|
262
|
+
return rawContent.replace(SPOOFED_LABEL_RE, '[');
|
|
62
263
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { isStrictCanonicalSegment } from './validate.js';
|
|
2
|
+
import { isActionSegment, isKeyboardSegment } from '../interactive-segments/types.js';
|
|
2
3
|
const STRICT_CANONICAL_TYPES = new Set([
|
|
3
|
-
'text', 'mention', 'image', 'audio', 'video', 'file', 'reply', 'forward',
|
|
4
|
+
'text', 'mention', 'image', 'audio', 'video', 'file', 'reply', 'forward',
|
|
5
|
+
'face', 'dice', 'rps', 'share',
|
|
4
6
|
]);
|
|
5
7
|
// These are Core-owned wire extensions rather than canonical data types. Keep
|
|
6
8
|
// their gradual contracts isolated here; third-party extensions must be
|
|
7
9
|
// namespaced so a future canonical type cannot silently collide with them.
|
|
8
10
|
const CORE_EXTENSION_TYPES = new Set([
|
|
9
|
-
'action', 'html', 'keyboard', 'link', 'markdown', 'qrcode', 'record', 'tts', 'voice',
|
|
11
|
+
'action', 'card', 'html', 'keyboard', 'link', 'markdown', 'qrcode', 'record', 'tts', 'voice',
|
|
10
12
|
]);
|
|
11
13
|
const extensionTypePattern = /^[a-z][a-z0-9-]*(?::[a-z][a-z0-9-]*)+$/u;
|
|
12
14
|
function isPlainObject(value) {
|
|
@@ -25,6 +27,10 @@ export function isCanonicalSegment(value) {
|
|
|
25
27
|
return false;
|
|
26
28
|
if (STRICT_CANONICAL_TYPES.has(value.type))
|
|
27
29
|
return isStrictCanonicalSegment(value);
|
|
30
|
+
if (value.type === 'keyboard')
|
|
31
|
+
return isKeyboardSegment(value);
|
|
32
|
+
if (value.type === 'action')
|
|
33
|
+
return isActionSegment(value);
|
|
28
34
|
return CORE_EXTENSION_TYPES.has(value.type) || extensionTypePattern.test(value.type);
|
|
29
35
|
}
|
|
30
36
|
export function assertCanonicalSegments(segments) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export type { Segment, SegmentBase, MediaRef, TextSegment, MentionSegment, ImageSegment, AudioSegment, VideoSegment, FileSegment, ReplySegment, ForwardSegment, FaceSegment, DiceSegment, RpsSegment, } from './types.js';
|
|
2
|
-
export { mediaRefSchema, textSegmentSchema, mentionSegmentSchema, imageSegmentSchema, audioSegmentSchema, videoSegmentSchema, fileSegmentSchema, replySegmentSchema, forwardSegmentSchema, faceSegmentSchema, diceSegmentSchema, rpsSegmentSchema, canonicalSegmentSchema, segmentArraySchema, } from './validate.js';
|
|
1
|
+
export type { Segment, SegmentBase, MediaRef, TextSegment, MentionSegment, ImageSegment, AudioSegment, VideoSegment, FileSegment, ReplySegment, ForwardSegment, ShareSegment, FaceSegment, DiceSegment, RpsSegment, } from './types.js';
|
|
2
|
+
export { mediaRefSchema, textSegmentSchema, mentionSegmentSchema, imageSegmentSchema, audioSegmentSchema, videoSegmentSchema, fileSegmentSchema, replySegmentSchema, forwardSegmentSchema, faceSegmentSchema, diceSegmentSchema, rpsSegmentSchema, shareSegmentSchema, canonicalSegmentSchema, segmentArraySchema, } from './validate.js';
|
|
3
3
|
export { assertCanonicalSegments, isCanonicalSegment } from './assert.js';
|
|
4
|
-
export { mediaRefJsonSchema, outboundSegmentJsonSchema, aiOutboundJsonSchema, STRICT_OUTBOUND_SEGMENT_TYPES, } from './json-schema.js';
|
|
4
|
+
export { mediaRefJsonSchema, outboundSegmentJsonSchema, aiOutboundJsonSchema, buildAiOutboundJsonSchema, AI_OUTBOUND_SEGMENT_TYPES, DEFAULT_AI_OUTBOUND_SEGMENT_TYPES, STRICT_OUTBOUND_SEGMENT_TYPES, type AiOutboundSegmentType, type AiSegmentExtension, type AiSegmentExtensions, type AiOutboundSegmentProfile, type AiReactionProfile, } from './json-schema.js';
|
|
5
5
|
export { segmentsForImDelivery } from './delivery.js';
|
|
6
6
|
export { isMediaRef, collectSegmentMedia, type SegmentMediaRef, } from './media.js';
|
|
7
7
|
export { createImageSegment } from './image.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { mediaRefSchema, textSegmentSchema, mentionSegmentSchema, imageSegmentSchema, audioSegmentSchema, videoSegmentSchema, fileSegmentSchema, replySegmentSchema, forwardSegmentSchema, faceSegmentSchema, diceSegmentSchema, rpsSegmentSchema, canonicalSegmentSchema, segmentArraySchema, } from './validate.js';
|
|
1
|
+
export { mediaRefSchema, textSegmentSchema, mentionSegmentSchema, imageSegmentSchema, audioSegmentSchema, videoSegmentSchema, fileSegmentSchema, replySegmentSchema, forwardSegmentSchema, faceSegmentSchema, diceSegmentSchema, rpsSegmentSchema, shareSegmentSchema, canonicalSegmentSchema, segmentArraySchema, } from './validate.js';
|
|
2
2
|
export { assertCanonicalSegments, isCanonicalSegment } from './assert.js';
|
|
3
|
-
export { mediaRefJsonSchema, outboundSegmentJsonSchema, aiOutboundJsonSchema, STRICT_OUTBOUND_SEGMENT_TYPES, } from './json-schema.js';
|
|
3
|
+
export { mediaRefJsonSchema, outboundSegmentJsonSchema, aiOutboundJsonSchema, buildAiOutboundJsonSchema, AI_OUTBOUND_SEGMENT_TYPES, DEFAULT_AI_OUTBOUND_SEGMENT_TYPES, STRICT_OUTBOUND_SEGMENT_TYPES, } from './json-schema.js';
|
|
4
4
|
export { segmentsForImDelivery } from './delivery.js';
|
|
5
5
|
export { isMediaRef, collectSegmentMedia, } from './media.js';
|
|
6
6
|
export { createImageSegment } from './image.js';
|
|
@@ -13,16 +13,50 @@ type JsonSchemaObject = Record<string, unknown>;
|
|
|
13
13
|
/** MediaRef(canonical 媒体引用):types.ts 的 MediaRef 接口 */
|
|
14
14
|
export declare const mediaRefJsonSchema: JsonSchemaObject;
|
|
15
15
|
/** 严格段类型集合(SSOT:assert.ts STRICT_CANONICAL_TYPES) */
|
|
16
|
-
export declare const STRICT_OUTBOUND_SEGMENT_TYPES: readonly ["text", "mention", "image", "reply", "forward", "face", "dice", "rps"];
|
|
16
|
+
export declare const STRICT_OUTBOUND_SEGMENT_TYPES: readonly ["text", "mention", "image", "audio", "video", "file", "reply", "forward", "face", "dice", "rps", "share"];
|
|
17
17
|
/**
|
|
18
18
|
* 单条 outbound 消息段的 JSON Schema。
|
|
19
|
-
* 严格段镜像 validate.ts
|
|
19
|
+
* 严格段镜像 validate.ts,交互段镜像 interactive-segments/types.ts;其他扩展段走宽松分支。
|
|
20
20
|
*/
|
|
21
21
|
export declare const outboundSegmentJsonSchema: JsonSchemaObject;
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* Segment types a model may author in a final reply. reply / forward / face are
|
|
24
|
+
* left out: they carry platform ids (message, forward, emoji) the model has no
|
|
25
|
+
* reliable source for.
|
|
26
26
|
*/
|
|
27
|
+
export declare const AI_OUTBOUND_SEGMENT_TYPES: readonly ["text", "mention", "image", "audio", "video", "file", "markdown", "keyboard", "share", "dice", "rps"];
|
|
28
|
+
export type AiOutboundSegmentType = typeof AI_OUTBOUND_SEGMENT_TYPES[number];
|
|
29
|
+
/**
|
|
30
|
+
* Adapter-declared model extension for one segment type (`segments.model`):
|
|
31
|
+
* optional string fields of the canonical segment the model may fill, and a
|
|
32
|
+
* platform hint appended to the reply instruction.
|
|
33
|
+
*/
|
|
34
|
+
export interface AiSegmentExtension {
|
|
35
|
+
readonly fields?: readonly string[];
|
|
36
|
+
readonly hint?: string;
|
|
37
|
+
}
|
|
38
|
+
export type AiSegmentExtensions = Readonly<Partial<Record<AiOutboundSegmentType, AiSegmentExtension>>>;
|
|
39
|
+
/** Reactions the model may put on the message it answers (platform value + meaning). */
|
|
40
|
+
export interface AiReactionProfile {
|
|
41
|
+
readonly values: readonly {
|
|
42
|
+
readonly value: string;
|
|
43
|
+
readonly label: string;
|
|
44
|
+
}[];
|
|
45
|
+
}
|
|
46
|
+
/** What one reply endpoint lets the model author: offered types plus their declared extensions. */
|
|
47
|
+
export interface AiOutboundSegmentProfile {
|
|
48
|
+
readonly types: readonly AiOutboundSegmentType[];
|
|
49
|
+
readonly extensions?: AiSegmentExtensions;
|
|
50
|
+
/** Present when the endpoint can react to the current message in this conversation. */
|
|
51
|
+
readonly reaction?: AiReactionProfile;
|
|
52
|
+
}
|
|
53
|
+
/** Offered when the adapter declares no `segments.supported` list. */
|
|
54
|
+
export declare const DEFAULT_AI_OUTBOUND_SEGMENT_TYPES: readonly AiOutboundSegmentType[];
|
|
55
|
+
/**
|
|
56
|
+
* The model's final reply: one or more chat messages, sent in order. Each message
|
|
57
|
+
* is an ordered segment array; the model decides how to split, like a person
|
|
58
|
+
* sending a few short messages. No text/mentions shorthand.
|
|
59
|
+
*/
|
|
60
|
+
export declare function buildAiOutboundJsonSchema(types?: readonly AiOutboundSegmentType[], extensions?: AiSegmentExtensions, reaction?: AiReactionProfile): JsonSchemaObject;
|
|
27
61
|
export declare const aiOutboundJsonSchema: JsonSchemaObject;
|
|
28
62
|
export {};
|