@zhin.js/plugin-earthquake 0.1.11 → 0.1.12
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 +56 -0
- package/LICENSE +21 -0
- package/README.md +8 -2
- package/commands//345/234/260/351/234/207//350/256/242/351/230/205/index.js +1 -1
- package/commands//345/234/260/351/234/207//351/200/200/350/256/242/index.js +1 -1
- package/lib/i18n.js +1 -1
- package/lib/i18n.js.map +1 -1
- package/lib/permission.d.ts +4 -4
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +4 -4
- package/lib/permission.js.map +1 -1
- package/package.json +10 -14
- package/plugin.js +3 -0
- package/schema.json +93 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,61 @@
|
|
|
1
1
|
# @zhin.js/plugin-earthquake
|
|
2
2
|
|
|
3
|
+
## 0.1.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e1fda87: fix: 按审计待审清单处理(安全、功能、清理)
|
|
8
|
+
|
|
9
|
+
**行为变更(升级前请阅读)**
|
|
10
|
+
|
|
11
|
+
- kernel / core / zhin.js:出站文本中的 `${…}` 不再用 `vm` 求值,只替换 `TemplateContext` 上能解析到值的属性路径(如 `${sender.name}`);表达式、函数调用、未知名字原样保留。整套 vm 沙箱(`evaluate` / `execute` / `compiler` / `getValueWithRuntime`)已移除。
|
|
12
|
+
- kernel / core / zhin.js:移除零引用的遗留导出——`Scheduler`、错误管理器与 `ZhinError` 子类、`compose`、`segment.from/toString`、AI 触发/准入函数、`@zhin.js/core/queue-im-field-contract`、`zhin.js/contexts`。
|
|
13
|
+
- agent:readonly 执行预设不再放行重定向、后台 `&`、进程替换、`find -delete/-exec`、`sed -i`、`sort -o`、`tee`、`xargs`、awk;curl/wget 校验每个 URL 与裸主机并识别更多上传参数;自定义 `execAllowlist` 中的只读命令带写入风险时改走审批。沙箱超时/取消会杀掉进程组或具名容器,默认镜像改为 `node:22-bookworm-slim` + `bash`。移除无生产调用的 `AuditLogger`、`AnomalyDetector`、旧 vision 回合等导出。
|
|
14
|
+
- ai:移除 `storage`、`FileStateCache`、`CostTracker`、`model-name-utils`、`./agent-step-checkpoint` 子路径、`ContextManager` 及旧压缩管线;延迟工具快照改为有界 LRU。
|
|
15
|
+
- cli:`zhin send` / `watch` / `schedule` 改为与运行中的 Host 通信(新增 `POST /message/send` 与 `/assistant/jobs` 写接口),`schedule` 不再支持离线改文件;移除 `zhin uninstall service`(用 `zhin service uninstall`)、`build --analyze`、`install -S`;`zhin stop` 杀不掉进程时保留 pid 文件并以非零退出;`runtime migrate` 新增 `verify`;未设置 `TZ` 时调度默认时区改为系统时区;不带 `ZHIN_SUPERVISOR_PID` 的进程被 init 接管后不再自行退出。
|
|
16
|
+
- schedule:后台 reconcile 出错不再产生未处理 rejection(新增 `onStoreError`);启动途中 `stop()` 不再遗留定时器。
|
|
17
|
+
- schema:元组校验与 `safeParse`、JSON Schema 一致(空数组不通过,缺省的可选元组为 `undefined`)。
|
|
18
|
+
- client / contract:删除无后端路由的 agent-stream API、未使用的 `definePage` 与旧 PageManager 类型;`@zhin.js/contract` 不再依赖 `@zhin.js/ai`;客户端收到 401 会清除已保存的凭据;安装/更新/卸载 RPC 默认超时 120 秒。
|
|
19
|
+
- a2a:流式响应中途出错写入 SSE error 并结束;未配置 token 的非生产环境只接受本机请求;任务存储有上限与过期;Mailbox 凭据回退与生产环境缺密钥检查修复。
|
|
20
|
+
- speech:`provider: openai` 不再套用 Ollama 的默认 host/model;识别语言改为可配置,不再写死 `zh`。
|
|
21
|
+
- adapter-lark:支持 `encryptKey` 加密事件解密。adapter-github:Device Flow 可取消、带超时并回复失败原因。adapter-wecom / dingtalk:请求加超时并校验 HTTP 状态。adapter-weixin-ilink:输入关闭期间暂停轮询。adapter-milky:SSE 支持 CRLF、缓冲上限与空闲重连。adapter-onebot-events:好友删除通知改为 `notice.friend.decrease`。
|
|
22
|
+
- plugin-group-suite:`teachAllowRegex` 默认关闭,正则安全检查更严格。plugin-qrcode:改为本地生成,回复 data URL 图片。plugin-rss / short-url / link-poster:拒绝解析到内网的地址;rss 修复条目每周重复推送;short-url 的 Console 创建改为真实调用 is.gd。plugin-lottery:按 `historyLimit` 同步。
|
|
23
|
+
|
|
24
|
+
**其余**
|
|
25
|
+
|
|
26
|
+
- host-http:插件市场详情加缓存与包名校验,SSE 回放容忍背压。host-http-contract:新增 `readTextBody()`,九个适配器改用它。
|
|
27
|
+
- pagemanager:页面外壳 importmap 升级到 React 19.2.8 / react-router 7.12.0。console-contract:`definePage` 接受 `description` / `group` / `parent` / `fullWidth`。
|
|
28
|
+
- command:进度提示本地化,匹配不再重复拷贝消息段。runtime:源码监听降级后退避重试原生监听。
|
|
29
|
+
- html-renderer:删除未接线的 `aiTextAsImage`。create-zhin-app / scaffold-wizard:移除不起作用的"全局安装 CLI"与运行时选择提示。
|
|
30
|
+
- 依赖声明清理、发布清单不再携带解析不到的 `src` 目录、移除未使用的 Skill 挂载、README 与示例配置按当前实现更正。
|
|
31
|
+
|
|
32
|
+
- 120e225: 聊天角色(ADR 0056,2026-11-12 修订):zhin 角色 owner / admin / trusted 分四级、只来自授予;发言者的平台身份与机器人自身的平台身份是独立维度,命令、Agent 工具 / 技能、中间件与按钮按三条维度共用一个评估器过滤。升级说明见 docs/migrations/chat-roles.md。
|
|
33
|
+
|
|
34
|
+
- zhin.js:实例首次启动把适配器 `master` / `trusted`、`endpoints[i].master|trusted` 与 `ai.trigger.masters|trusted` 迁入项目数据库 `chat_roles`(先记入 `.zhin/chat-roles-migration.json`,再从配置移除并记日志);之后配置再出现这些字段时启动报错并指向升级指南。平台身份不再映射为 zhin 角色:删除 `roles.mappings`(适配器块与 `endpoints[i].roles` 出现即启动报错)、`chat_role_mappings` 表与 Console `chat-roles.mappings` / `chat-roles.set-mappings`;`features.selfService.platformAdmins|roles|allowUsers` 删除;群内「功能」「角色」命令只认 zhin 角色,平台群主不再自动具备;聊天改配置、聊天重启、Agent 主人审批按 zhin `owner` 判断。
|
|
35
|
+
- @zhin.js/core(minor,破坏性):角色模型与解析移入 core(`ChatRoleService`、`createChatRoleSenderEnricher`),入站消息带 `sender.chatRole` 与归一的 `sender.platform`;删除 `SenderRole`、`senderRolesFromMessage`、`roleSatisfies` 等,`master` 改名 `owner`;删除映射规则 API(`createMappingChatRoleSource`、`DEFAULT_CHAT_ROLE_MAPPINGS` 等)与 `ChatRoleSource`;`createSenderEnricher` / `createConfigurationChatAuthorizer` 改为基于聊天角色。IM Runtime 为 PermissionHost 提供机器人自身身份(经 Adapter 索引缓存),机器人的角色变化事件使缓存失效;命令拒绝回复说明缺少的平台 / 机器人条件;`<Button permit>` 按点击者鉴权;场景治理工具工厂同时要求 `platform:*` 与 `bot:*`;`ai.trigger.masters|trusted` 删除。
|
|
36
|
+
- @zhin.js/permission(minor,破坏性):permit 语法 `owner` / `admin` / `trusted` / `role(...)`(zhin 角色)、`platform:owner|admin`、`platform-role:<id>`、`platform-permission:<name>`(发言者平台身份),新增 `bot:owner|admin`、`bot-role:<id>`、`bot-permission:<name>`(机器人自身平台身份,`PermissionSubject.bot`);`PermissionHost` 新增 `setBotStandingResolver`、`withBotStanding`、`firstDenied`,`checkAll` 可带 `source` 解析机器人身份;新增 `describeDeniedPermit`、`permitsNeedBotStanding`。删除 `role(master)`、`scene_admin`、`scene_owner`、`platform(adapter,perm)` 及 `registerPlatform`、`createSceneRolePlatformChecker`、`platformPermission`、`definePlatformPermission`,定义时报错并给出替代写法。
|
|
37
|
+
- @zhin.js/command(minor,破坏性):命令会话的发送者改为 `chatRole` / `platform`,不再从 metadata 读角色;`CONVERSATION_MANAGER_PERMIT` 改为 `admin`(平台群主不再自动满足);分发结果 `denied` 带 `denial`(第一条不满足的规则与原因);指令菜单只列出当前发送者在本会话可用的命令。
|
|
38
|
+
- @zhin.js/agent(minor,破坏性):危险工具、文件 / exec 策略、主人审批、Agent 回合主体只读 zhin 角色(`principal.roles` 只含展开的聊天角色,平台地位在 `principal.platform`);`SenderRole` → `PrincipalRole`,`SELF_CHANGE_MASTER_ROLE` → `SELF_CHANGE_OWNER_ROLE`;回合开始时读取机器人自身身份(`contextState.bot.platform`),按三条维度过滤 tool / skill / Agent 包后才披露,执行工具时再校验一次;群规「群主和管理员豁免」改为平台群主 / 管理员与 zhin `owner`。
|
|
39
|
+
- @zhin.js/feature-kit:`OperationSession.sender` 改为 `chatRole` / `platform`。
|
|
40
|
+
- @zhin.js/im-contract:新增 `PlatformStanding`、`SelfStandingRequest`、`standingFromMemberRole`。
|
|
41
|
+
- @zhin.js/adapter:入站 sender 可带 `platform`;账号管理命令需要聊天角色 `owner`;`EndpointManagement` 新增可选 `inspectSelfStanding`,能力画像新增 `scene.selfStanding`(声明即须实现),`AdapterIndex.selfStanding` / `invalidateSelfStanding` 按会话缓存机器人自身身份。
|
|
42
|
+
- @zhin.js/middleware:入站中间件可声明 `permit`,不满足时跳过该中间件(机器人身份只读缓存)。
|
|
43
|
+
- @zhin.js/tool:定义工具时拒绝已移除的 permit 写法。
|
|
44
|
+
- @zhin.js/ai:注释更新。
|
|
45
|
+
- @zhin.js/console-protocol:`chat-roles.list|grant|revoke`(`iam.manage`);`ConsoleChatRoleSource` 只有 `grant`。
|
|
46
|
+
- @zhin.js/runtime:Host 配置 Schema 删除 `features.selfService.platformAdmins|roles|allowUsers`。
|
|
47
|
+
- @zhin.js/testing:伪造消息与 `PluginTestKit` 用 `sender.chatRole` 声明测试身份。
|
|
48
|
+
- @zhin.js/scaffold-wizard:ICQQ 向导不再写 `master`,完成后提示在 Console 账号「角色」页签或聊天 `角色 授予` 设置 owner。
|
|
49
|
+
- 适配器:配置 Schema 删除 `master` / `trusted`(以及预览版的 `roles`);群管理类工具同时声明发言者条件与机器人条件(如 `platform:admin` + `bot:admin`、`bot-permission:manage_roles`),NapCat / OneBot11 工具不再使用已移除的 `platform(adapter,…)` 写法。
|
|
50
|
+
- 插件:内容审核以 `inbound.bypass`(permit 列表,默认 `owner` 或 `platform:admin`)取代 `masters` / `inbound.bypassMasters`;群管、音乐、日历、地震、B 站、轮盘赌的权限改用 zhin 角色,订阅类命令只认 zhin `admin` / `owner`。
|
|
51
|
+
|
|
52
|
+
- eae4ea8: 官方插件接入分层功能配置(ADR 0050 / 0055):所有带配置 Schema 的官方插件都声明全部四级(全局 / 适配器 / 账号 / 会话),Console 的适配器、账号与会话页面都能开关它们;密钥、调度与全局资源类字段收窄为仅全局。answers 与 group-suite 可按会话覆盖字段并开放群内自助字段(答题超时、科目一开关;欢迎语、排行条数、教学冷却与分页),ledger 的 `reportWhenEmpty` 可按订阅者会话覆盖。主动推送在发送前按目标会话检查开关:提醒(含管理员提醒)、日历授权通知、地震速报、记账日报、彩票推送、B 站开播 / 动态推送、activity-feedback 的状态提示在已停用的账号或会话上不再发送;roulette 的超时扫描在已停用的会话里静默结束对局(不结算、不禁言、不发消息)。`@zhin.js/schema` 新增 `.fieldLevels(levels)` 用于收窄单个字段的层级;`@zhin.js/testing` 的假插件上下文提供 `isEnabledFor` / `configFor`(`feature` 选项可模拟按会话停用与字段覆盖)。
|
|
53
|
+
- 68659cd: `zod` 改为运行时依赖(原为可选对等依赖):插件运行时在启动时就会加载这些包的约定目录(Agent 工具、命令等),其中静态导入了 `zod`;生成的项目里没有安装可选对等依赖,启动会报 `Cannot find package 'zod'`。范围为 `^4.6.7`(已修复的版本)。
|
|
54
|
+
- Updated dependencies [e1fda87]
|
|
55
|
+
- Updated dependencies [120e225]
|
|
56
|
+
- @zhin.js/skill@1.1.17
|
|
57
|
+
- @zhin.js/tool@1.1.19
|
|
58
|
+
|
|
3
59
|
## 0.1.11
|
|
4
60
|
|
|
5
61
|
### Patch Changes
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 凉菜
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -30,11 +30,11 @@ earthquake: {}
|
|
|
30
30
|
|
|
31
31
|
### 权限
|
|
32
32
|
|
|
33
|
-
- **群聊 /
|
|
33
|
+
- **群聊 / 频道**:只有本会话的 zhin 聊天角色 `admin` 或 `owner`(ADR 0056)可以执行 `地震 订阅`、`地震 退订`;订阅是 zhin 功能,平台群主 / 管理员需要先被授予 zhin 角色。其他成员会收到“只有本会话的 zhin 管理员(admin)或机器人主人(owner)可以在群聊中修改地震订阅”的提示。
|
|
34
34
|
- **私聊**:用户可以直接订阅、退订自己的私聊会话,不受限制。
|
|
35
35
|
- `地震` 查询与 `地震 订阅状态` 对所有人开放。
|
|
36
36
|
|
|
37
|
-
判断使用框架内置的 permit 检查器(`private()`
|
|
37
|
+
判断使用框架内置的 permit 检查器(`private()` 或本会话 zhin 聊天角色 `admin`,ADR 0056)。平台群主 / 管理员不会自动具备,需要先被授予 `admin` / `owner`。
|
|
38
38
|
|
|
39
39
|
地区是对地点文字的关键词匹配(不区分大小写),同时匹配 CENC 的中文地名与 USGS 的英文地名;`中国` / `国内` 是预设,匹配 CENC 中以省级行政区开头的地点以及 USGS 中含 China / Taiwan 的地点。震级阈值按各数据源报告中的最大震级判断。
|
|
40
40
|
|
|
@@ -46,6 +46,12 @@ earthquake: {}
|
|
|
46
46
|
|
|
47
47
|
订阅推送需要 Outbound Host 与 Schedule Host(标准 Runtime 默认提供)。配置数据库时订阅持久保存在插件状态中;没有数据库时保存在内存里,重启后丢失。
|
|
48
48
|
|
|
49
|
+
## 分层配置(ADR 0050 / 0055)
|
|
50
|
+
|
|
51
|
+
所有字段(数据源、轮询频率、重试、推送限额等)只能在全局层修改;启停开关支持适配器、账号与会话四级。在 Console「功能」区可以按适配器、账号或会话(群 / 私聊)单独停用;开启 `features.selfService.enabled` 后,群里有 `admin` 角色(默认含群主 / 管理员)的人也可以用 `功能 关闭 earthquake` 关闭本群。上级停用后下级锁定,不能再开启。
|
|
52
|
+
|
|
53
|
+
速报推送前按订阅所在会话检查开关:已停用的会话收不到推送,订阅本身保留;重新启用后从下一条新地震开始推送,停用期间的地震不补发。推荐用会话层开关代替按群的自定义黑名单。
|
|
54
|
+
|
|
49
55
|
## 数据源
|
|
50
56
|
|
|
51
57
|
| 数据源 | 默认地址 | 说明 |
|
|
@@ -8,7 +8,7 @@ import { SubscriptionLimitError } from "../../../lib/subscriptions.js";
|
|
|
8
8
|
export default defineCommand({
|
|
9
9
|
alias: ['earthquake subscribe'],
|
|
10
10
|
preferredAliasI18n: { en: 'earthquake subscribe' },
|
|
11
|
-
description: '在当前会话订阅地震速报:地震 订阅 [最小震级] [地区...]
|
|
11
|
+
description: '在当前会话订阅地震速报:地震 订阅 [最小震级] [地区...](群聊限本会话 zhin admin 或 owner)', descriptionI18n: { en: "Subscribe this conversation to earthquake alerts (zhin admin or owner of the conversation required in groups)" },
|
|
12
12
|
params: {
|
|
13
13
|
filters: { type: 'word', rest: true, description: '可选:最小震级与地区关键词,如 5 四川 云南', descriptionI18n: { en: "Optional minimum magnitude and region keywords, such as 5 Sichuan Yunnan" } },
|
|
14
14
|
},
|
|
@@ -7,7 +7,7 @@ import { subscriptionKey } from "../../../lib/subscriptions.js";
|
|
|
7
7
|
export default defineCommand({
|
|
8
8
|
alias: ['earthquake unsubscribe'],
|
|
9
9
|
preferredAliasI18n: { en: 'earthquake unsubscribe' },
|
|
10
|
-
description: '
|
|
10
|
+
description: '取消当前会话的地震速报订阅(群聊限本会话 zhin admin 或 owner)', descriptionI18n: { en: "Unsubscribe this conversation from earthquake alerts (zhin admin or owner of the conversation required in groups)" },
|
|
11
11
|
async execute({ input, use, adapter, scene, sender, locale }) {
|
|
12
12
|
const service = use(earthquakeServiceToken);
|
|
13
13
|
const target = extractConversation(input);
|
package/lib/i18n.js
CHANGED
|
@@ -17,7 +17,7 @@ export const messages = createMessages({
|
|
|
17
17
|
maxRegions: { 'zh-CN': "最多设置 {count} 个地区关键词", en: "Use at most {count} region keywords." },
|
|
18
18
|
conversation: { 'zh-CN': "请在机器人私聊、群聊或频道中使用此命令", en: "Use this command in a private chat, group or channel with the bot." },
|
|
19
19
|
noThread: { 'zh-CN': "暂不支持在话题/子频道内订阅,请在主会话中使用", en: "Subscriptions in threads or subchannels are not supported. Use the main conversation." },
|
|
20
|
-
denied: { 'zh-CN': "
|
|
20
|
+
denied: { 'zh-CN': "只有本会话的 zhin 管理员(admin)或机器人主人(owner)可以在群聊中修改地震订阅;私聊中可以直接订阅本会话。", en: "Only a zhin admin of this conversation or the bot owner may change group earthquake subscriptions. Private chats can subscribe their own conversation." },
|
|
21
21
|
global: { 'zh-CN': "全球", en: "Worldwide" },
|
|
22
22
|
subscribed: { 'zh-CN': "已订阅:M{magnitude} 以上,地区:{regions}", en: "Subscribed: M{magnitude}+, regions: {regions}" },
|
|
23
23
|
updated: { 'zh-CN': "已更新订阅:M{magnitude} 以上,地区:{regions}", en: "Subscription updated: M{magnitude}+, regions: {regions}" },
|
package/lib/i18n.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,MAAM,CAAC,MAAM,QAAQ,GAAG,cAAc,CAAC;IACrC,WAAW,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,sCAAsC,EAAE;IAC/E,KAAK,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,kBAAkB,EAAE;IAC3D,OAAO,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE,oBAAoB,EAAE;IAC9D,OAAO,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,cAAc,EAAE;IAC/C,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE;IACvC,aAAa,EAAE,EAAE,OAAO,EAAE,uBAAuB,EAAE,EAAE,EAAE,4CAA4C,EAAE;IACrG,MAAM,EAAE,EAAE,OAAO,EAAE,mBAAmB,EAAE,EAAE,EAAE,0BAA0B,EAAE;IACxE,MAAM,EAAE,EAAE,OAAO,EAAE,wCAAwC,EAAE,EAAE,EAAE,6DAA6D,EAAE;IAChI,KAAK,EAAE,EAAE,OAAO,EAAE,yBAAyB,EAAE,EAAE,EAAE,2EAA2E,EAAE;IAC9H,KAAK,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,EAAE,EAAE,sBAAsB,EAAE;IAC/D,IAAI,EAAE,EAAE,OAAO,EAAE,wBAAwB,EAAE,EAAE,EAAE,2BAA2B,EAAE;IAC5E,WAAW,EAAE,EAAE,OAAO,EAAE,mBAAmB,EAAE,EAAE,EAAE,kDAAkD,EAAE;IACrG,KAAK,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Ae,EAAE,EAAE,EAAE,uDAAuD,EAAE;IAClG,aAAa,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,EAAE,EAAE,mDAAmD,EAAE;IAClG,YAAY,EAAE,EAAE,OAAO,EAAE,oCAAoC,EAAE,EAAE,EAAE,8DAA8D,EAAE;IACnI,OAAO,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,EAAE,iCAAiC,EAAE;IAC7E,WAAW,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,eAAe,EAAE;IACrD,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE;IACzC,YAAY,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,mBAAmB,EAAE;IAC1D,SAAS,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,2BAA2B,EAAE;IACrE,QAAQ,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,EAAE,8BAA8B,EAAE;IAC3E,KAAK,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,qBAAqB,EAAE;IACxD,MAAM,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE,EAAE,EAAE,gCAAgC,EAAE;IAC/E,WAAW,EAAE,EAAE,OAAO,EAAE,2BAA2B,EAAE,EAAE,EAAE,2EAA2E,EAAE;CACvI,CAAC,CAAC"}
|
package/lib/permission.d.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Who may change a conversation's earthquake subscriptions.
|
|
3
3
|
*
|
|
4
4
|
* - Private chat: the user manages their own conversation, no restriction.
|
|
5
|
-
* - Group or channel:
|
|
5
|
+
* - Group or channel: the zhin chat role `admin` of the conversation or higher (ADR 0056).
|
|
6
|
+
* Subscriptions are a zhin function: a platform group owner / admin needs a granted role.
|
|
6
7
|
*
|
|
7
|
-
* The rule itself lives in `canManageConversation` (`zhin.js/command`)
|
|
8
|
-
* the canonical `owner` / `admin` role names that it checks.
|
|
8
|
+
* The rule itself lives in `canManageConversation` (`zhin.js/command`).
|
|
9
9
|
*/
|
|
10
|
-
export declare const SUBSCRIPTION_PERMISSION_DENIED_MESSAGE = "\u53EA\u6709\
|
|
10
|
+
export declare const SUBSCRIPTION_PERMISSION_DENIED_MESSAGE = "\u53EA\u6709\u672C\u4F1A\u8BDD\u7684 zhin \u7BA1\u7406\u5458\uFF08admin\uFF09\u6216\u673A\u5668\u4EBA\u4E3B\u4EBA\uFF08owner\uFF09\u53EF\u4EE5\u5728\u7FA4\u804A\u4E2D\u4FEE\u6539\u5730\u9707\u8BA2\u9605\uFF1B\u79C1\u804A\u4E2D\u53EF\u4EE5\u76F4\u63A5\u8BA2\u9605\u672C\u4F1A\u8BDD\u3002";
|
|
11
11
|
//# sourceMappingURL=permission.d.ts.map
|
package/lib/permission.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission.d.ts","sourceRoot":"","sources":["../src/permission.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,sCAAsC,
|
|
1
|
+
{"version":3,"file":"permission.d.ts","sourceRoot":"","sources":["../src/permission.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,sCAAsC,mSACc,CAAC"}
|
package/lib/permission.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Who may change a conversation's earthquake subscriptions.
|
|
3
3
|
*
|
|
4
4
|
* - Private chat: the user manages their own conversation, no restriction.
|
|
5
|
-
* - Group or channel:
|
|
5
|
+
* - Group or channel: the zhin chat role `admin` of the conversation or higher (ADR 0056).
|
|
6
|
+
* Subscriptions are a zhin function: a platform group owner / admin needs a granted role.
|
|
6
7
|
*
|
|
7
|
-
* The rule itself lives in `canManageConversation` (`zhin.js/command`)
|
|
8
|
-
* the canonical `owner` / `admin` role names that it checks.
|
|
8
|
+
* The rule itself lives in `canManageConversation` (`zhin.js/command`).
|
|
9
9
|
*/
|
|
10
|
-
export const SUBSCRIPTION_PERMISSION_DENIED_MESSAGE = '
|
|
10
|
+
export const SUBSCRIPTION_PERMISSION_DENIED_MESSAGE = '只有本会话的 zhin 管理员(admin)或机器人主人(owner)可以在群聊中修改地震订阅;私聊中可以直接订阅本会话。';
|
|
11
11
|
//# sourceMappingURL=permission.js.map
|
package/lib/permission.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission.js","sourceRoot":"","sources":["../src/permission.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,sCAAsC,GACjD,
|
|
1
|
+
{"version":3,"file":"permission.js","sourceRoot":"","sources":["../src/permission.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,sCAAsC,GACjD,+DAA+D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/plugin-earthquake",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "Earthquake query and group alert plugin for Zhin.js — CENC + USGS, magnitude/region subscriptions (Plugin Runtime)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -41,28 +41,24 @@
|
|
|
41
41
|
},
|
|
42
42
|
"license": "MIT",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"
|
|
45
|
-
"@zhin.js/
|
|
44
|
+
"zod": "^4.6.7",
|
|
45
|
+
"@zhin.js/skill": "1.1.17",
|
|
46
|
+
"@zhin.js/tool": "1.1.19"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"typescript": "^6.0.3",
|
|
49
50
|
"vitest": "^4.1.10",
|
|
50
|
-
"
|
|
51
|
-
"@zhin.js/
|
|
52
|
-
"
|
|
53
|
-
"zhin.js": "1.1.24"
|
|
51
|
+
"@zhin.js/command": "1.2.0",
|
|
52
|
+
"@zhin.js/testing": "1.0.10",
|
|
53
|
+
"zhin.js": "1.1.26"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"zhin.js": "^1.1.24"
|
|
56
|
+
"@zhin.js/command": "^1.2.0",
|
|
57
|
+
"zhin.js": "^1.1.26"
|
|
59
58
|
},
|
|
60
59
|
"peerDependenciesMeta": {
|
|
61
60
|
"@zhin.js/command": {
|
|
62
61
|
"optional": true
|
|
63
|
-
},
|
|
64
|
-
"zod": {
|
|
65
|
-
"optional": true
|
|
66
62
|
}
|
|
67
63
|
},
|
|
68
64
|
"repository": {
|
|
@@ -103,6 +99,6 @@
|
|
|
103
99
|
"build": "tsc",
|
|
104
100
|
"check": "tsc -p tsconfig.check.json",
|
|
105
101
|
"clean": "rimraf lib",
|
|
106
|
-
"test": "
|
|
102
|
+
"test": "vitest run --root ../../.. plugins/utils/earthquake/tests"
|
|
107
103
|
}
|
|
108
104
|
}
|
package/plugin.js
CHANGED
|
@@ -55,6 +55,9 @@ export default definePlugin({
|
|
|
55
55
|
const target = subscription.target;
|
|
56
56
|
if (!target)
|
|
57
57
|
throw new DataMigrationError('unavailable', 'Historical earthquake subscription awaits exact-target binding');
|
|
58
|
+
// ADR 0050 / 0055: pushes are not messages; skip accounts / conversations where earthquake is switched off.
|
|
59
|
+
if (!context.isEnabledFor({ conversation: target }))
|
|
60
|
+
return;
|
|
58
61
|
const send = outbound.sendTarget;
|
|
59
62
|
if (!send)
|
|
60
63
|
throw new Error('Canonical subscription delivery requires an exact-target Outbound Host');
|
package/schema.json
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"type": "object",
|
|
4
4
|
"additionalProperties": false,
|
|
5
|
+
"x-zhin-config": {
|
|
6
|
+
"levels": [
|
|
7
|
+
"global",
|
|
8
|
+
"adapter",
|
|
9
|
+
"endpoint",
|
|
10
|
+
"conversation"
|
|
11
|
+
]
|
|
12
|
+
},
|
|
5
13
|
"properties": {
|
|
6
14
|
"sources": {
|
|
7
15
|
"type": "array",
|
|
@@ -23,6 +31,11 @@
|
|
|
23
31
|
"en": {
|
|
24
32
|
"description": "Enabled data sources in priority order. The first source supplies location text when merging the same earthquake; other sources cover a failed source."
|
|
25
33
|
}
|
|
34
|
+
},
|
|
35
|
+
"x-zhin-config": {
|
|
36
|
+
"levels": [
|
|
37
|
+
"global"
|
|
38
|
+
]
|
|
26
39
|
}
|
|
27
40
|
},
|
|
28
41
|
"cencUrls": {
|
|
@@ -43,6 +56,11 @@
|
|
|
43
56
|
"en": {
|
|
44
57
|
"description": "CENC catalog URLs, tried in order (primary followed by mirrors). HTTPS only, up to 5 URLs."
|
|
45
58
|
}
|
|
59
|
+
},
|
|
60
|
+
"x-zhin-config": {
|
|
61
|
+
"levels": [
|
|
62
|
+
"global"
|
|
63
|
+
]
|
|
46
64
|
}
|
|
47
65
|
},
|
|
48
66
|
"usgsFeed": {
|
|
@@ -63,6 +81,11 @@
|
|
|
63
81
|
"en": {
|
|
64
82
|
"description": "USGS GeoJSON summary feed name (minimum-magnitude_time-range)."
|
|
65
83
|
}
|
|
84
|
+
},
|
|
85
|
+
"x-zhin-config": {
|
|
86
|
+
"levels": [
|
|
87
|
+
"global"
|
|
88
|
+
]
|
|
66
89
|
}
|
|
67
90
|
},
|
|
68
91
|
"pollCron": {
|
|
@@ -73,6 +96,11 @@
|
|
|
73
96
|
"en": {
|
|
74
97
|
"description": "Subscription polling schedule (6-field cron: second, minute, hour, day, month, weekday)."
|
|
75
98
|
}
|
|
99
|
+
},
|
|
100
|
+
"x-zhin-config": {
|
|
101
|
+
"levels": [
|
|
102
|
+
"global"
|
|
103
|
+
]
|
|
76
104
|
}
|
|
77
105
|
},
|
|
78
106
|
"timezone": {
|
|
@@ -83,6 +111,11 @@
|
|
|
83
111
|
"en": {
|
|
84
112
|
"description": "IANA timezone used to display earthquake times."
|
|
85
113
|
}
|
|
114
|
+
},
|
|
115
|
+
"x-zhin-config": {
|
|
116
|
+
"levels": [
|
|
117
|
+
"global"
|
|
118
|
+
]
|
|
86
119
|
}
|
|
87
120
|
},
|
|
88
121
|
"requestTimeoutMs": {
|
|
@@ -95,6 +128,11 @@
|
|
|
95
128
|
"en": {
|
|
96
129
|
"description": "HTTP request timeout in milliseconds."
|
|
97
130
|
}
|
|
131
|
+
},
|
|
132
|
+
"x-zhin-config": {
|
|
133
|
+
"levels": [
|
|
134
|
+
"global"
|
|
135
|
+
]
|
|
98
136
|
}
|
|
99
137
|
},
|
|
100
138
|
"maxRetries": {
|
|
@@ -108,6 +146,11 @@
|
|
|
108
146
|
"en": {
|
|
109
147
|
"description": "Retries for network errors, timeouts, HTTP 429 and 5xx, excluding the initial request."
|
|
110
148
|
}
|
|
149
|
+
},
|
|
150
|
+
"x-zhin-config": {
|
|
151
|
+
"levels": [
|
|
152
|
+
"global"
|
|
153
|
+
]
|
|
111
154
|
}
|
|
112
155
|
},
|
|
113
156
|
"retryBaseDelayMs": {
|
|
@@ -120,6 +163,11 @@
|
|
|
120
163
|
"en": {
|
|
121
164
|
"description": "Initial exponential-backoff delay in milliseconds; doubles for each retry with random jitter."
|
|
122
165
|
}
|
|
166
|
+
},
|
|
167
|
+
"x-zhin-config": {
|
|
168
|
+
"levels": [
|
|
169
|
+
"global"
|
|
170
|
+
]
|
|
123
171
|
}
|
|
124
172
|
},
|
|
125
173
|
"retryMaxDelayMs": {
|
|
@@ -132,6 +180,11 @@
|
|
|
132
180
|
"en": {
|
|
133
181
|
"description": "Maximum backoff or Retry-After wait in milliseconds. Longer server waits abandon this round and cool down the source."
|
|
134
182
|
}
|
|
183
|
+
},
|
|
184
|
+
"x-zhin-config": {
|
|
185
|
+
"levels": [
|
|
186
|
+
"global"
|
|
187
|
+
]
|
|
135
188
|
}
|
|
136
189
|
},
|
|
137
190
|
"defaultMinMagnitude": {
|
|
@@ -144,6 +197,11 @@
|
|
|
144
197
|
"en": {
|
|
145
198
|
"description": "Minimum magnitude for subscriptions that do not specify one."
|
|
146
199
|
}
|
|
200
|
+
},
|
|
201
|
+
"x-zhin-config": {
|
|
202
|
+
"levels": [
|
|
203
|
+
"global"
|
|
204
|
+
]
|
|
147
205
|
}
|
|
148
206
|
},
|
|
149
207
|
"queryMinMagnitude": {
|
|
@@ -156,6 +214,11 @@
|
|
|
156
214
|
"en": {
|
|
157
215
|
"description": "Minimum magnitude for earthquake queries that do not specify one."
|
|
158
216
|
}
|
|
217
|
+
},
|
|
218
|
+
"x-zhin-config": {
|
|
219
|
+
"levels": [
|
|
220
|
+
"global"
|
|
221
|
+
]
|
|
159
222
|
}
|
|
160
223
|
},
|
|
161
224
|
"queryLimit": {
|
|
@@ -169,6 +232,11 @@
|
|
|
169
232
|
"en": {
|
|
170
233
|
"description": "Default number of earthquake query results."
|
|
171
234
|
}
|
|
235
|
+
},
|
|
236
|
+
"x-zhin-config": {
|
|
237
|
+
"levels": [
|
|
238
|
+
"global"
|
|
239
|
+
]
|
|
172
240
|
}
|
|
173
241
|
},
|
|
174
242
|
"maxEventAgeMinutes": {
|
|
@@ -181,6 +249,11 @@
|
|
|
181
249
|
"en": {
|
|
182
250
|
"description": "Only notify about earthquakes from the last specified number of minutes, avoiding delayed or replayed old events."
|
|
183
251
|
}
|
|
252
|
+
},
|
|
253
|
+
"x-zhin-config": {
|
|
254
|
+
"levels": [
|
|
255
|
+
"global"
|
|
256
|
+
]
|
|
184
257
|
}
|
|
185
258
|
},
|
|
186
259
|
"pushLimit": {
|
|
@@ -194,6 +267,11 @@
|
|
|
194
267
|
"en": {
|
|
195
268
|
"description": "Maximum notification messages per conversation in one rate-limit window."
|
|
196
269
|
}
|
|
270
|
+
},
|
|
271
|
+
"x-zhin-config": {
|
|
272
|
+
"levels": [
|
|
273
|
+
"global"
|
|
274
|
+
]
|
|
197
275
|
}
|
|
198
276
|
},
|
|
199
277
|
"pushWindowMinutes": {
|
|
@@ -206,6 +284,11 @@
|
|
|
206
284
|
"en": {
|
|
207
285
|
"description": "Notification rate-limit window in minutes."
|
|
208
286
|
}
|
|
287
|
+
},
|
|
288
|
+
"x-zhin-config": {
|
|
289
|
+
"levels": [
|
|
290
|
+
"global"
|
|
291
|
+
]
|
|
209
292
|
}
|
|
210
293
|
},
|
|
211
294
|
"maxEventsPerMessage": {
|
|
@@ -219,6 +302,11 @@
|
|
|
219
302
|
"en": {
|
|
220
303
|
"description": "Maximum earthquakes listed in one notification; the remainder is summarized as a count."
|
|
221
304
|
}
|
|
305
|
+
},
|
|
306
|
+
"x-zhin-config": {
|
|
307
|
+
"levels": [
|
|
308
|
+
"global"
|
|
309
|
+
]
|
|
222
310
|
}
|
|
223
311
|
},
|
|
224
312
|
"maxSubscriptions": {
|
|
@@ -232,6 +320,11 @@
|
|
|
232
320
|
"en": {
|
|
233
321
|
"description": "Maximum subscriptions across this instance, at most one per conversation."
|
|
234
322
|
}
|
|
323
|
+
},
|
|
324
|
+
"x-zhin-config": {
|
|
325
|
+
"levels": [
|
|
326
|
+
"global"
|
|
327
|
+
]
|
|
235
328
|
}
|
|
236
329
|
}
|
|
237
330
|
}
|