@zhin.js/adapter-satori 1.1.18 → 1.1.20

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 CHANGED
@@ -1,5 +1,48 @@
1
1
  # @zhin.js/adapter-satori
2
2
 
3
+ ## 1.1.20
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [5e878ba]
8
+ - @zhin.js/page@1.1.12
9
+
10
+ ## 1.1.19
11
+
12
+ ### Patch Changes
13
+
14
+ - 2c3610a: Move account lifecycle ownership into the generic Adapter base and let native Endpoints retain their SDK Client inheritance. Infer platform-specific operation Sessions from a single adapter registry while preserving command parameter, option, configuration and factory inference.
15
+
16
+ Bind message replies, management ports, login challenges and Agent cancellation to the captured account incarnation. Persist runtime account intent with encrypted, revision-checked Host storage; keep account management independent of Root process restarts. Require explicit operator confirmation before importing existing accounts, and give replacement accounts a new identity without inheriting previous Sessions.
17
+
18
+ Expose account save, start, stop, update and replacement through the existing adapter Console, with exact account ownership, truthful pending/unknown outcomes and no startup configuration or environment-file rewrites.
19
+
20
+ Complete the target migration across every adapter, the public authoring API, generators, examples and Console. This intentionally removes the old create factory, inheritable Endpoint/ClientEndpoint classes, Client descriptors and file-rewrite account management; plugin authors must use createAdapter, native Client inheritance and the single AdapterRegistry. Satori and OneBot12 require explicit platform/userId selection, and WeCom requires a separate agentId.
21
+
22
+ Verify opaque credential changes before the same configuration snapshot is committed. Drain admitted native callbacks across close/rollback, cancel target work on stop, and keep raw transport parsing, platform ACK timing and SDK native methods under their existing owners. Account metadata conceals credentials carried in URLs.
23
+
24
+ - a9f4e48: PATCH COMPATIBILITY CUTOVER: this batch intentionally changes plugin APIs. The maintainer explicitly chose patch releases with declared version boundaries. Upgrade the complete tested dependency set; patch numbering does not promise compatibility with the removed interfaces.
25
+
26
+ The first planned floors are zhin.js 1.1.19, Core 1.1.54, Adapter 1.1.26, FeatureKit 1.1.10, Plugin Runtime 1.1.18, Runtime/Isolate 1.1.16 and Agent 1.1.45. Keep old-interface plugins with the earlier locked stack until they are migrated. Adapter's independent Feature API changes from 1.0.0 to 2.0.0; official consumers declare ^2.0.0. Existing Feature API admission rejects explicitly incompatible ranges; omitted API metadata keeps its existing behavior and does not certify compatibility. Runtime engine and patch-only release gates remain unchanged.
27
+
28
+ Use the native-Client Adapter target contract, canonical FeatureKit AdapterRegistry augmentation and named Endpoint control/management requests. Route message controls from canonical message/conversation refs; retain exact source authority and propagate caller/account/explicit-Root-stop cancellation. Replace removed Agent activity feedback exports with source-bound feedback. HMR pause/resume belongs to concrete plugin instances; plugins choose accepted-work policy without changing Controller commit/rollback authority. Cooperative worker/process control cancellation does not kill an isolate or reopen retired business admission.
29
+
30
+ Provide authenticated historical-data preview, exact selected binding, transactional application, authoritative inspection and explicit resumption, including active games. Preserve before-images and journals; never replay an unconfirmed effect, infer an account from an alias, or reuse historical permission grants. Owner V2 approvals remain inactive legacy data, while new writes use V3. Rollback requires matching software, lockfile and verified data; installing old code alone cannot read a new V3 approval file. Conflicting after-images are never overwritten.
31
+
32
+ See docs/plans/adapter-operation-version-boundaries.md and the Chinese/English upgrade guide for the complete version inventory, custom-plugin changes, acceptance and recovery sequence. These code and metadata changes do not authorize merging, publication, deployment, login, production migration or removal of installed workspace patches.
33
+
34
+ - Updated dependencies [2c3610a]
35
+ - Updated dependencies [a9f4e48]
36
+ - Updated dependencies [f8505b0]
37
+ - Updated dependencies [2c3610a]
38
+ - @zhin.js/adapter@1.1.26
39
+ - @zhin.js/feature-kit@1.1.10
40
+ - @zhin.js/core@1.1.54
41
+ - @zhin.js/host-http@1.1.12
42
+ - @zhin.js/client@1.1.22
43
+ - @zhin.js/page@1.1.11
44
+ - @zhin.js/skill@1.1.11
45
+
3
46
  ## 1.1.18
4
47
 
5
48
  ### Patch Changes
package/README.md CHANGED
@@ -22,19 +22,19 @@ pnpm add @zhin.js/adapter-satori
22
22
  ## Plugin Runtime
23
23
 
24
24
  - `@zhin.js/adapter` — 约定式 `adapters/satori/index.ts`(`defineAdapter`)
25
- - `@zhin.js/core` — `Endpoint.emit(...)` 入站、`outboundMessageToken` 出站
25
+ - `@zhin.js/core` — `endpointSpec.events` 入站、统一出站管道
26
26
  - `zhin.js` — `plugin.ts`(`definePlugin`)
27
27
  - `@zhin.js/host-http` — Webhook 模式需 `httpHostToken` 注册 POST 路由
28
28
  - 配置经插件 `schema.json` 落到顶层 `<instanceKey>`(`baseUrl` / `token` / …)
29
29
 
30
- 入站:`gateway.receive({ conversation, message, content, sender, metadata })`(`conversation` 为 ConversationRef:DIRECT 频道 → kind `private`,其余 → kind `group`、所属 guild 进 `parent`)
30
+ 入站:`endpoint[endpointSpec].events.emit('message.receive', { conversation, message, content, sender, metadata })`(`conversation` 为 ConversationRef:DIRECT 频道 → kind `private`,其余 → kind `group`、所属 guild 进 `parent`)
31
+
31
32
  出站:`send({ conversation, payload })` → Satori `message.create`(`channel_id = conversation.id`;payload 已由 gateway/core 渲染;无 segment-mapper)
32
33
 
33
- 入站 `metadata.mentioned`:消息 content 中 `<at id="…"/>` 元素的 id 等于登录 selfId(READY/事件 `login.user.id`)时置 `true`。
34
+ 入站 `metadata.mentioned`:消息 content 中 `<at id="…"/>` 元素的 id 等于登录 selfId(配置的 `userId`)时置 `true`。
34
35
 
35
- 每个 Endpoint 的 `$client` 是 `@imhelper/satori-v1` 的 `SatoriV1Client`。业务代码直接调用
36
- `$client.call(resource, method, params)` 或其公开便捷方法;Client 负责协议事件变换,Endpoint
37
- 只负责 Satori IDENTIFY/心跳、Webhook 鉴权和 Zhin 投影。
36
+ 每个 Endpoint 直接继承 `@imhelper/satori-v1` 的 `SatoriV1Client`,由所属 `SatoriAdapter` 管理。业务代码直接调用
37
+ `$client.call(resource, method, params)` 或其公开便捷方法;协议事件变换、Satori IDENTIFY/心跳与 Webhook 鉴权由该实际 Client 处理,Zhin 投影经 `endpointSpec.events` 接入。
38
38
 
39
39
  ## 前置条件
40
40
 
@@ -54,17 +54,21 @@ satori:
54
54
  heartbeat_interval: 10000
55
55
  endpoints:
56
56
  - id: satori-bot
57
+ platform: qq
58
+ userId: "123456789"
57
59
  baseUrl: "http://127.0.0.1:5140"
58
60
  token: "${SATORI_TOKEN}"
59
61
  ```
60
62
 
61
63
  主配置 `plugins` 映射需引用 `@zhin.js/adapter-satori`(`instanceKey: satori`)。
62
64
 
63
- ### 可选字段
65
+ ### Endpoint 字段
64
66
 
65
67
  | 字段 | 说明 |
66
68
  |------|------|
67
69
  | `heartbeat_interval` | WS PING 间隔(毫秒),默认 `10000` |
70
+ | `platform` | 必填,远端 login 的平台标识 |
71
+ | `userId` | 必填,远端 login 的用户标识(字符串) |
68
72
  | `token` | Bearer;可在 YAML 中引用 `${SATORI_TOKEN}` |
69
73
 
70
74
  ### Webhook
@@ -77,12 +81,14 @@ satori:
77
81
  connection: webhook
78
82
  endpoints:
79
83
  - id: satori-bot
84
+ platform: qq
85
+ userId: "123456789"
80
86
  baseUrl: "http://127.0.0.1:5140"
81
87
  path: "/satori/webhook"
82
88
  token: "${SATORI_TOKEN}"
83
89
  ```
84
90
 
85
- SDK 会向 `path` 发送 POST,请求头 `Satori-Opcode: 0` 表示事件;适配器从首个事件的 `login` 取得 platform / userId 用于后续 API 调用。
91
+ SDK 会向 `path` 发送 POST,请求头 `Satori-Opcode: 0` 表示事件;每个 Endpoint 必须配置 `platform` 与 `userId`。仅接纳这两个字段精确匹配的 login 事件;API 请求也固定使用这组身份。READY 中其他 login 不会改变当前账号。
86
92
 
87
93
  ## 鉴权
88
94
 
@@ -109,7 +115,7 @@ SDK 会向 `path` 发送 POST,请求头 `Satori-Opcode: 0` 表示事件;适
109
115
  启动后打开 Console 的「Satori」页(地址 `/satori`),可以:
110
116
 
111
117
  - 查看运行中的连接、点「测试连接」做连通性诊断;
112
- - 增删 `plugins.satori.endpoints`(凭据写入 `.env`,配置里只保留 `${ENV}` 引用);
118
+ - 经所属 Adapter 增删持久化账号、启停单个 Endpoint;凭据由 Host 加密仓储保存,不改启动 YAML 或 `.env`,不重启进程;
113
119
  - 如果适配器要求登录,页面会显示 LoginAssist 的扫码 / 滑块 / 设备确认待办;
114
120
 
115
121
  读取需要 `satori:read`,写操作需要 `satori:write`;管理员 full token 不受限。页面里的「添加 endpoint」等价于原来的 `satori endpoint add`。
@@ -3,10 +3,8 @@
3
3
  * Convention entry: discover `adapters/satori/index.ts` → defineAdapter.
4
4
  */
5
5
  import { defineAdapter } from 'zhin.js/adapter';
6
- import { httpHostToken } from '@zhin.js/host-http';
7
- import { SatoriWebhookEndpoint, SatoriWsEndpoint } from "../../lib/endpoint.js";
8
- import { resolveSatoriConfig, } from "../../lib/protocol.js";
9
- import { satoriRuntimeStateToken } from "../../lib/satori-runtime-state.js";
6
+ import { SatoriAdapter } from "../../lib/adapter.js";
7
+ import {} from "../../lib/protocol.js";
10
8
  export { SatoriWebhookEndpoint, SatoriWsEndpoint } from "../../lib/endpoint.js";
11
9
  export default defineAdapter({
12
10
  capabilities: ['inbound', 'outbound'],
@@ -16,23 +14,5 @@ export default defineAdapter({
16
14
  outboundMedia: ['url', 'base64'],
17
15
  interactive: 'text',
18
16
  },
19
- create(context) {
20
- const config = resolveSatoriConfig(context.config);
21
- // 注册到插件运行时状态(satori endpoint list 的"运行中"数据源)
22
- context.use(satoriRuntimeStateToken).endpoints.set(config.id, {
23
- id: config.id,
24
- mode: config.connection,
25
- });
26
- if (config.connection === 'webhook') {
27
- return new SatoriWebhookEndpoint({
28
- id: context.id,
29
- http: context.use(httpHostToken),
30
- config,
31
- });
32
- }
33
- return new SatoriWsEndpoint({
34
- id: context.id,
35
- config,
36
- });
37
- },
17
+ createAdapter: context => new SatoriAdapter(context),
38
18
  });
@@ -2,13 +2,10 @@
2
2
  * Convention entry: discover `adapters/satori/index.ts` → defineAdapter.
3
3
  */
4
4
  import { defineAdapter } from 'zhin.js/adapter';
5
- import { httpHostToken } from '@zhin.js/host-http';
6
- import { SatoriWebhookEndpoint, SatoriWsEndpoint } from '../../src/endpoint.js';
5
+ import { SatoriAdapter } from '../../src/adapter.js';
7
6
  import {
8
- resolveSatoriConfig,
9
7
  type SatoriEndpointConfig,
10
8
  } from '../../src/protocol.js';
11
- import { satoriRuntimeStateToken } from '../../src/satori-runtime-state.js';
12
9
 
13
10
  export { SatoriWebhookEndpoint, SatoriWsEndpoint } from '../../src/endpoint.js';
14
11
  export type {
@@ -27,23 +24,5 @@ export default defineAdapter<SatoriEndpointConfig>({
27
24
  outboundMedia: ['url', 'base64'],
28
25
  interactive: 'text',
29
26
  },
30
- create(context) {
31
- const config = resolveSatoriConfig(context.config);
32
- // 注册到插件运行时状态(satori endpoint list 的"运行中"数据源)
33
- context.use(satoriRuntimeStateToken).endpoints.set(config.id, {
34
- id: config.id,
35
- mode: config.connection,
36
- });
37
- if (config.connection === 'webhook') {
38
- return new SatoriWebhookEndpoint({
39
- id: context.id,
40
- http: context.use(httpHostToken),
41
- config,
42
- });
43
- }
44
- return new SatoriWsEndpoint({
45
- id: context.id,
46
- config,
47
- });
48
- },
27
+ createAdapter: context => new SatoriAdapter(context),
49
28
  });
@@ -5,15 +5,15 @@
5
5
  */
6
6
  import { createEndpointCommands } from 'zhin.js/adapter';
7
7
  import { defineCommand } from 'zhin.js/command';
8
- import { satoriRuntimeStateToken } from "../../../lib/satori-runtime-state.js";
9
8
  export const satoriEndpointCommands = createEndpointCommands({
10
9
  adapterKey: 'satori',
11
10
  adapterDisplayName: 'Satori',
12
11
  fields: [
12
+ { key: 'platform', required: true, description: 'Selected Satori login platform' },
13
+ { key: 'userId', required: true, description: 'Selected Satori login user ID' },
13
14
  { key: 'baseUrl', required: true, description: 'Satori 服务 base URL', descriptionI18n: { en: "Satori service base URL" } },
14
15
  { key: 'path', description: 'webhook 路径(connection: webhook)', descriptionI18n: { en: "Webhook path (connection: webhook)" } },
15
16
  { key: 'token', env: true, description: 'Satori access token' },
16
17
  ],
17
- running: (use) => use(satoriRuntimeStateToken).endpoints.values(),
18
18
  describeEntry: (entry) => `baseUrl: ${String(entry.baseUrl)}`,
19
19
  }, defineCommand);
@@ -4,16 +4,16 @@
4
4
  */
5
5
  import { createEndpointCommands } from 'zhin.js/adapter';
6
6
  import { defineCommand } from 'zhin.js/command';
7
- import { satoriRuntimeStateToken } from '../../../src/satori-runtime-state.js';
8
7
 
9
8
  export const satoriEndpointCommands = createEndpointCommands({
10
9
  adapterKey: 'satori',
11
10
  adapterDisplayName: 'Satori',
12
11
  fields: [
12
+ { key: 'platform', required: true, description: 'Selected Satori login platform' },
13
+ { key: 'userId', required: true, description: 'Selected Satori login user ID' },
13
14
  { key: 'baseUrl', required: true, description: 'Satori 服务 base URL', descriptionI18n: { en: "Satori service base URL" } },
14
15
  { key: 'path', description: 'webhook 路径(connection: webhook)', descriptionI18n: { en: "Webhook path (connection: webhook)" } },
15
16
  { key: 'token', env: true, description: 'Satori access token' },
16
17
  ],
17
- running: (use) => use(satoriRuntimeStateToken).endpoints.values(),
18
18
  describeEntry: (entry) => `baseUrl: ${String(entry.baseUrl)}`,
19
19
  }, defineCommand);
@@ -0,0 +1,19 @@
1
+ import { Adapter, type AdapterContext, type EndpointCreationContext } from 'zhin.js/adapter';
2
+ import { type SatoriEndpointConfig } from './protocol.js';
3
+ import { SatoriWsEndpoint, SatoriWebhookEndpoint } from './endpoint.js';
4
+ import type { SatoriClientEventMap } from './client.js';
5
+ export declare class SatoriAdapter extends Adapter<SatoriWsEndpoint | SatoriWebhookEndpoint, SatoriEndpointConfig, SatoriClientEventMap> {
6
+ #private;
7
+ constructor(context: AdapterContext<SatoriEndpointConfig>);
8
+ get configurationIdentityFields(): readonly string[];
9
+ get configurationIdentityProbeFields(): readonly string[];
10
+ get configurationUpdateFields(): readonly string[];
11
+ protected validateConfiguration(config: SatoriEndpointConfig): void;
12
+ protected identifyConfiguration(input: SatoriEndpointConfig, signal: AbortSignal): Promise<string>;
13
+ protected createEndpoint(input: SatoriEndpointConfig, execution: EndpointCreationContext): SatoriWsEndpoint | SatoriWebhookEndpoint;
14
+ }
15
+ declare module '@zhin.js/feature-kit' {
16
+ interface AdapterRegistry {
17
+ readonly satori: SatoriAdapter;
18
+ }
19
+ }
package/lib/adapter.js ADDED
@@ -0,0 +1,29 @@
1
+ import { Adapter } from 'zhin.js/adapter';
2
+ import { httpHostToken } from '@zhin.js/host-http';
3
+ import { callSatoriApi, resolveSatoriConfig } from './protocol.js';
4
+ import { SatoriWsEndpoint, SatoriWebhookEndpoint } from './endpoint.js';
5
+ export class SatoriAdapter extends Adapter {
6
+ #context;
7
+ constructor(context) { super(); this.#context = context; }
8
+ get configurationIdentityFields() { return ['id', 'platform', 'userId']; }
9
+ get configurationIdentityProbeFields() { return ['token', 'baseUrl']; }
10
+ get configurationUpdateFields() { return ['connection', 'baseUrl', 'token', 'path', 'heartbeat_interval']; }
11
+ validateConfiguration(config) { resolveSatoriConfig(config); }
12
+ async identifyConfiguration(input, signal) {
13
+ const config = resolveSatoriConfig(input);
14
+ signal.throwIfAborted();
15
+ const login = await callSatoriApi({ ...config, signal, resource: 'login', method: 'get' });
16
+ signal.throwIfAborted();
17
+ if (!login?.platform || !login.user?.id)
18
+ throw new Error('Satori login identity is unavailable');
19
+ if (login.platform !== config.platform || login.user.id !== config.userId)
20
+ throw new Error('Satori returned another login identity');
21
+ return `satori:${JSON.stringify([login.platform, login.user.id])}`;
22
+ }
23
+ createEndpoint(input, execution) {
24
+ const config = resolveSatoriConfig(input), id = execution.canonicalId, signal = execution.signal;
25
+ return config.connection === 'webhook'
26
+ ? new SatoriWebhookEndpoint({ id, config, signal, http: this.#context.use(httpHostToken) })
27
+ : new SatoriWsEndpoint({ id, config, signal });
28
+ }
29
+ }
package/lib/client.d.ts CHANGED
@@ -1,18 +1,26 @@
1
1
  import { SatoriV1Client, type SatoriV1Event } from '@imhelper/satori-v1';
2
2
  import { type EventMap, type ImHelperEventMap } from 'imhelper';
3
3
  import { type ClientEventPayloads } from 'zhin.js/adapter';
4
- import type { ResolvedSatoriConfig, SatoriApiOptions, callSatoriApi } from './protocol.js';
4
+ import type { ResolvedSatoriConfig, callSatoriApi } from './protocol.js';
5
5
  export { SatoriV1Client as SatoriClient } from '@imhelper/satori-v1';
6
6
  type SatoriClientEvents = ImHelperEventMap<string, SatoriV1Event, EventMap<string>>;
7
7
  export type SatoriClientEventMap = ClientEventPayloads<SatoriClientEvents>;
8
- export declare function createSatoriEndpointClient(config: ResolvedSatoriConfig, request: typeof callSatoriApi, apiOptions: () => SatoriApiOptions): SatoriV1Client;
9
- export declare function forwardSatoriClientEvents(client: SatoriV1Client, receive: (name: string, payload: unknown) => void): () => void;
10
- declare module '@zhin.js/feature-kit' {
11
- interface AdapterClientRegistry {
12
- readonly satori: {
13
- readonly client: SatoriV1Client;
14
- readonly events: SatoriClientEventMap;
15
- };
16
- }
8
+ /** One account-bound caller is shared by native SDK and semantic ports. */
9
+ export interface SatoriActionRequest {
10
+ readonly resource: string;
11
+ readonly method: string;
12
+ readonly params?: Record<string, unknown>;
13
+ readonly signal?: AbortSignal;
14
+ }
15
+ export interface SatoriClientBinding {
16
+ readonly config: ResolvedSatoriConfig;
17
+ readonly request: typeof callSatoriApi;
18
+ readonly signal?: AbortSignal;
17
19
  }
18
- export declare const satoriClient: import("@zhin.js/adapter").EndpointClientToken<SatoriV1Client, ClientEventPayloads<SatoriClientEvents>>;
20
+ export type SatoriActionCaller = (request: SatoriActionRequest) => Promise<unknown>;
21
+ export declare function createSatoriActionCaller({ config, request, signal }: SatoriClientBinding): SatoriActionCaller;
22
+ export declare function satoriClientOptions({ config, call }: {
23
+ readonly config: ResolvedSatoriConfig;
24
+ readonly call: SatoriActionCaller;
25
+ }): ConstructorParameters<typeof SatoriV1Client>[0];
26
+ export declare function forwardSatoriClientEvents(client: SatoriV1Client, receive: (name: string, payload: unknown) => void): () => void;
package/lib/client.js CHANGED
@@ -1,15 +1,21 @@
1
- import { SatoriV1Client, } from '@imhelper/satori-v1';
1
+ import { EndpointDeliveryError } from '@zhin.js/im-contract';
2
2
  import { EventFactory } from 'imhelper';
3
- import { defineEndpointClient, forwardEndpointClientEvents, } from 'zhin.js/adapter';
3
+ import { forwardEndpointClientEvents, } from 'zhin.js/adapter';
4
4
  export { SatoriV1Client as SatoriClient } from '@imhelper/satori-v1';
5
- export function createSatoriEndpointClient(config, request, apiOptions) {
6
- return new SatoriV1Client({
7
- baseUrl: config.baseUrl,
8
- selfId: config.id,
9
- accessToken: config.token,
10
- receiveMode: 'manual',
11
- call: (resource, method, params) => request(apiOptions(), resource, method, params ?? {}),
12
- });
5
+ export function createSatoriActionCaller({ config, request, signal }) {
6
+ return action => {
7
+ const operationSignal = signal && action.signal ? AbortSignal.any([signal, action.signal]) : signal ?? action.signal;
8
+ if (operationSignal?.aborted)
9
+ throw new EndpointDeliveryError('endpoint_inactive', 'Endpoint request ended before submission', 'not_sent', { cause: operationSignal.reason });
10
+ return request({ baseUrl: config.baseUrl, platform: config.platform, userId: config.userId,
11
+ token: config.token, ...action, signal: operationSignal });
12
+ };
13
+ }
14
+ export function satoriClientOptions({ config, call }) {
15
+ return { baseUrl: config.baseUrl, selfId: config.userId, platform: config.platform,
16
+ accessToken: config.token, receiveMode: 'manual',
17
+ call: (resource, method, params) => call({ resource, method, params: params ?? {} }),
18
+ };
13
19
  }
14
20
  const satoriClientEventNames = Object.freeze([
15
21
  ...EventFactory.getSupportedEventTypes(),
@@ -18,4 +24,3 @@ const satoriClientEventNames = Object.freeze([
18
24
  export function forwardSatoriClientEvents(client, receive) {
19
25
  return forwardEndpointClientEvents(client, satoriClientEventNames, receive);
20
26
  }
21
- export const satoriClient = defineEndpointClient('satori');
@@ -2,6 +2,8 @@ export const satoriConsoleSpec = {
2
2
  adapterKey: 'satori',
3
3
  adapterDisplayName: 'Satori',
4
4
  fields: [
5
+ { key: 'platform', required: true, description: 'Selected Satori login platform' },
6
+ { key: 'userId', required: true, description: 'Selected Satori login user ID' },
5
7
  { key: 'baseUrl', required: true, description: 'Satori 服务 base URL', descriptionI18n: { en: 'Satori service base URL' } },
6
8
  { key: 'path', description: 'webhook 路径(connection: webhook)', descriptionI18n: { en: 'Webhook path (connection: webhook)' } },
7
9
  { key: 'token', env: true, description: 'Satori access token' },
package/lib/console.d.ts CHANGED
@@ -5,4 +5,4 @@
5
5
  */
6
6
  import { type AdapterConsoleResources } from 'zhin.js/adapter';
7
7
  import type { PluginConsoleRpc } from 'zhin.js';
8
- export declare function createSatoriConsoleRpc(resources: AdapterConsoleResources, getConfig: () => unknown): PluginConsoleRpc;
8
+ export declare function createSatoriConsoleRpc(_resources: AdapterConsoleResources, getConfig: () => unknown): PluginConsoleRpc;
package/lib/console.js CHANGED
@@ -4,13 +4,10 @@
4
4
  * 页面绑定 `pages/index`,读取 / 写入分别要求 `<adapter>:read` / `<adapter>:write`。
5
5
  */
6
6
  import { createAdapterConsoleRpc } from 'zhin.js/adapter';
7
- import { satoriRuntimeStateToken } from './satori-runtime-state.js';
8
7
  import { satoriConsoleSpec } from './console-spec.js';
9
- export function createSatoriConsoleRpc(resources, getConfig) {
10
- const state = resources.use(satoriRuntimeStateToken);
8
+ export function createSatoriConsoleRpc(_resources, getConfig) {
11
9
  return createAdapterConsoleRpc({
12
10
  ...satoriConsoleSpec,
13
- running: () => state.endpoints.values(),
14
11
  getConfig,
15
- }, resources);
12
+ });
16
13
  }
package/lib/endpoint.d.ts CHANGED
@@ -1,53 +1,44 @@
1
- import type { IncomingMessage, ServerResponse } from 'node:http';
2
1
  /**
3
2
  * SatoriEndpoint — WebSocket and webhook lifecycle, outbound, admit.
4
3
  */
5
- import { ClientEndpoint, type EndpointControl, type EndpointManagement, type EndpointSendRequest } from 'zhin.js/adapter';
4
+ import { endpointSpec, type Endpoint, type EndpointSpecification, type EndpointManagement } from 'zhin.js/adapter';
6
5
  import type { HttpHost } from '@zhin.js/host-http';
7
6
  import type { CapabilityId } from 'zhin.js';
8
7
  import { callSatoriApi, type ResolvedSatoriWebhookConfig, type ResolvedSatoriWsConfig } from './protocol.js';
9
- import { type SatoriClient } from './client.js';
8
+ import { type SatoriActionCaller, SatoriClient } from './client.js';
10
9
  import { type CreateSatoriWebSocket } from './ws.js';
11
10
  export type SatoriApiCaller = typeof callSatoriApi;
12
11
  export interface SatoriWsEndpointOptions {
12
+ readonly signal?: AbortSignal;
13
13
  readonly id: CapabilityId;
14
14
  readonly config: ResolvedSatoriWsConfig;
15
15
  readonly createWebSocket?: CreateSatoriWebSocket;
16
16
  readonly callApi?: SatoriApiCaller;
17
17
  }
18
- export declare class SatoriWsEndpoint extends ClientEndpoint<SatoriClient> {
18
+ export declare class SatoriWsEndpoint extends SatoriClient implements Endpoint {
19
19
  #private;
20
- readonly client: SatoriClient;
21
- readonly management: EndpointManagement;
22
- readonly control: EndpointControl;
20
+ readonly [endpointSpec]: EndpointSpecification;
23
21
  constructor(options: SatoriWsEndpointOptions);
24
- start(): Promise<void>;
25
- stop(): Promise<void>;
26
- send({ conversation, payload }: EndpointSendRequest): Promise<string>;
27
- recall(id: string, fallbackChannelId?: string): Promise<void>;
28
22
  }
29
23
  export interface SatoriWebhookEndpointOptions {
24
+ readonly signal?: AbortSignal;
30
25
  readonly id: CapabilityId;
31
26
  readonly http: HttpHost;
32
27
  readonly config: ResolvedSatoriWebhookConfig;
33
28
  readonly callApi?: SatoriApiCaller;
34
29
  }
35
- export declare class SatoriWebhookEndpoint extends ClientEndpoint<SatoriClient> {
30
+ export declare class SatoriWebhookEndpoint extends SatoriClient implements Endpoint {
36
31
  #private;
37
- readonly client: SatoriClient;
38
- readonly management: EndpointManagement;
39
- readonly control: EndpointControl;
32
+ readonly [endpointSpec]: EndpointSpecification;
40
33
  constructor(options: SatoriWebhookEndpointOptions);
41
- /** Used by webhook handler. */
42
- get isOpen(): boolean;
43
- get config(): ResolvedSatoriWebhookConfig;
44
- acceptHttp(request: IncomingMessage, response: ServerResponse): Promise<void>;
45
- start(): Promise<void>;
46
- stop(): Promise<void>;
47
- send({ conversation, payload }: EndpointSendRequest): Promise<string>;
48
- recall(id: string, fallbackChannelId?: string): Promise<void>;
49
34
  }
50
- export type SatoriManagementApi = (resource: string, method: string, params: Record<string, unknown>) => Promise<unknown>;
35
+ /**
36
+ * Satori guild id 是平台相关字符串(多数平台为雪花号,超
37
+ * Number.MAX_SAFE_INTEGER)。Console 社交面只把 group_id 当 JSON 值透传、
38
+ * 并以字符串回传给 listGroupMembers,因此保留原始字符串(仅按契约类型
39
+ * 声明强转)是全链路最不丢信息的方案。
40
+ */
41
+ export type SatoriManagementApi = SatoriActionCaller;
51
42
  /**
52
43
  * Satori endpoint 的 EndpointManagement 语义端口(ws / webhook 共用),
53
44
  * 数据走协议 API:guild.list / channel.list / guild-member.list。