@zhin.js/core 1.5.12 → 1.5.13

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.
@@ -1,6 +1,6 @@
1
1
  import { Scope, generationAdmissionBinder, type GenerationAdmissionGate, type PluginId, type RuntimeSnapshot, type SnapshotLease, type SnapshotReader } from '@zhin.js/plugin-runtime';
2
2
  import { MessageBus } from './message-bus.js';
3
- import { type EndpointManagement, type EndpointManagementCapability, type AdapterEndpointPhase, type EndpointContentResolveContext } from '@zhin.js/adapter';
3
+ import { type AdapterOperation, type EndpointManagement, type EndpointManagementCapability, type AdapterEndpointPhase, type EndpointContentResolveContext } from '@zhin.js/adapter';
4
4
  import { type ConversationEventStore, type ConversationContextBlock, type ConversationReference, type ConversationResolution, type ConversationRef, type DeliveryReceipt, type MessageRef } from '@zhin.js/im-contract';
5
5
  import { Message, type ConversationAddress, type IncomingMessage, type MessageDispatchResult, type MessageGateway, type MessageSenderRef, type SendRequest } from './contracts.js';
6
6
  import { LoginAssist } from '../../built/login-assist.js';
@@ -98,6 +98,7 @@ export declare class ImRuntime implements MessageGateway {
98
98
  readonly connected: boolean;
99
99
  readonly status: 'online' | 'offline';
100
100
  readonly phase: AdapterEndpointPhase;
101
+ readonly operations: readonly AdapterOperation[];
101
102
  readonly managementCapabilities: readonly EndpointManagementCapability[];
102
103
  }[];
103
104
  /**
@@ -117,6 +118,7 @@ export declare class ImRuntime implements MessageGateway {
117
118
  readonly connected: boolean;
118
119
  readonly status: 'online' | 'offline';
119
120
  readonly phase: AdapterEndpointPhase;
121
+ readonly operations: readonly AdapterOperation[];
120
122
  readonly managementCapabilities: readonly EndpointManagementCapability[];
121
123
  } | null;
122
124
  sendEndpointMessage(input: {
@@ -1,7 +1,7 @@
1
1
  import { createToken, generationAdmissionBinder, htmlRendererToken, } from '@zhin.js/plugin-runtime';
2
2
  import { createPermissionHost, permissionHostToken } from '@zhin.js/permission';
3
3
  import { MessageBus, messageBusToken } from './message-bus.js';
4
- import { adapterFeatureId, isAdapterIndex, endpointControlOf, resolveEndpointManagement, } from '@zhin.js/adapter';
4
+ import { adapterFeatureId, isAdapterIndex, resolveEndpointManagement, } from '@zhin.js/adapter';
5
5
  import { MemoryConversationEventStore, conversationRefKey, messageRefKey, } from '@zhin.js/im-contract';
6
6
  import { segmentsToPlainText } from '../../built/segment-contract/text.js';
7
7
  import { isMiddlewareIndex, middlewareFeatureId } from '@zhin.js/middleware';
@@ -546,6 +546,7 @@ export class ImRuntime {
546
546
  connected: row.connected,
547
547
  status: row.status,
548
548
  phase: row.phase,
549
+ operations: row.operations,
549
550
  managementCapabilities: row.managementCapabilities,
550
551
  }));
551
552
  }
@@ -606,6 +607,7 @@ export class ImRuntime {
606
607
  connected: row.connected,
607
608
  status: row.status,
608
609
  phase: row.phase,
610
+ operations: row.operations,
609
611
  managementCapabilities: row.managementCapabilities,
610
612
  });
611
613
  }
@@ -643,25 +645,25 @@ export class ImRuntime {
643
645
  }
644
646
  /** Activity-feedback: add a message reaction when the live Endpoint supports it. */
645
647
  async addEndpointReaction(input) {
646
- return this.#withEndpointControl(input.adapter, input.endpointKey, (control) => control.addReaction?.(input.message, input.emoji, {
648
+ return this.#withEndpointControl(input.adapter, input.endpointKey, 'reaction', (control) => control.addReaction?.(input.message, input.emoji, {
647
649
  sceneType: input.sceneType,
648
650
  channelId: input.channelId,
649
651
  }) ?? null, null);
650
652
  }
651
653
  async removeEndpointReaction(input) {
652
- await this.#withEndpointControl(input.adapter, input.endpointKey, (control) => control.removeReaction?.(input.message, input.reactionId), undefined);
654
+ await this.#withEndpointControl(input.adapter, input.endpointKey, 'reaction', (control) => control.removeReaction?.(input.message, input.reactionId), undefined);
653
655
  }
654
656
  /** Activity-feedback autoRemove: recall a previously sent status message. */
655
657
  async recallEndpointMessage(input) {
656
- await this.#withEndpointControl(input.adapter, input.endpointKey, (control) => control.recall?.(input.message), undefined);
658
+ await this.#withEndpointControl(input.adapter, input.endpointKey, 'recall', (control) => control.recall?.(input.message), undefined);
657
659
  }
658
660
  async editEndpointMessage(input) {
659
- return this.#withEndpointControl(input.adapter, input.endpointKey, (control) => control.edit?.(input.message, input.content) ?? null, null);
661
+ return this.#withEndpointControl(input.adapter, input.endpointKey, 'edit', (control) => control.edit?.(input.message, input.content) ?? null, null);
660
662
  }
661
663
  async setEndpointTyping(input) {
662
- await this.#withEndpointControl(input.adapter, input.endpointKey, (control) => control.typing?.(input.conversation, input.active), undefined);
664
+ await this.#withEndpointControl(input.adapter, input.endpointKey, 'typing', (control) => control.typing?.(input.conversation, input.active), undefined);
663
665
  }
664
- async #withEndpointControl(adapter, endpointKey, run, fallback) {
666
+ async #withEndpointControl(adapter, endpointKey, operation, run, fallback) {
665
667
  let lease;
666
668
  try {
667
669
  lease = this.#acquire();
@@ -670,8 +672,9 @@ export class ImRuntime {
670
672
  return fallback;
671
673
  }
672
674
  try {
673
- const endpoint = requireAdapters(lease.value).instance(adapter, endpointKey);
674
- const control = endpointControlOf(endpoint);
675
+ const index = requireAdapters(lease.value);
676
+ const id = index.resolve(adapter, endpointKey);
677
+ const control = id ? index.control(id, operation) : undefined;
675
678
  return control ? await run(control) : fallback;
676
679
  }
677
680
  finally {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/core",
3
- "version": "1.5.12",
3
+ "version": "1.5.13",
4
4
  "description": "Zhin机器人核心框架",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -75,9 +75,9 @@
75
75
  "segment-matcher": "^1.0.5",
76
76
  "smol-toml": "^1.7.1",
77
77
  "yaml": "^2.9.0",
78
- "@zhin.js/adapter": "1.1.11",
79
- "@zhin.js/command": "1.0.15",
78
+ "@zhin.js/adapter": "1.2.0",
80
79
  "@zhin.js/component": "1.0.12",
80
+ "@zhin.js/command": "1.0.15",
81
81
  "@zhin.js/database": "1.0.79",
82
82
  "@zhin.js/handler": "1.0.3",
83
83
  "@zhin.js/im-contract": "1.0.4",
@@ -85,8 +85,8 @@
85
85
  "@zhin.js/kernel": "1.0.7",
86
86
  "@zhin.js/logger": "1.0.76",
87
87
  "@zhin.js/middleware": "1.0.12",
88
- "@zhin.js/permission": "1.0.3",
89
88
  "@zhin.js/plugin-runtime": "1.1.7",
89
+ "@zhin.js/permission": "1.0.3",
90
90
  "@zhin.js/schema": "1.0.73"
91
91
  },
92
92
  "peerDependencies": {