evolcore 0.0.43-test.3 → 0.0.43-test.4
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 +36 -0
- package/bin/ecmsg.js +229 -0
- package/bin/install-codex-managed-hooks.mjs +130 -8
- package/dist/ability/application-service.js +37 -0
- package/dist/ability/resources.js +28 -0
- package/dist/ability/runtime.js +6 -1
- package/dist/agents/claude-runner.js +7 -5
- package/dist/agents/codex/app-server-client.js +0 -12
- package/dist/agents/codex-runner.js +0 -37
- package/dist/agents/ecagent-runner.js +130 -35
- package/dist/aun/aid/agentmd.js +31 -12
- package/dist/aun/menu/client.js +8 -7
- package/dist/aun/menu/index.js +1 -1
- package/dist/aun/menu/transport.js +8 -5
- package/dist/aun/service-proxy.js +3 -0
- package/dist/channels/aun.js +26 -5
- package/dist/channels/daemon.js +10 -2
- package/dist/cli/agent-command.js +5 -0
- package/dist/cli/agent-create.js +28 -6
- package/dist/cli/agent.js +9 -3
- package/dist/cli/aun-commands.js +2 -2
- package/dist/cli/daemon-commands.js +30 -18
- package/dist/cli/directory.js +4 -7
- package/dist/cli/getmeta-command.js +2 -1
- package/dist/cli/init.js +13 -5
- package/dist/cli/trigger-command.js +20 -14
- package/dist/config/boot-log.js +12 -2
- package/dist/config/config-field-policy.js +2 -0
- package/dist/config/config-manager.js +9 -4
- package/dist/config/peer-role-resolver.js +1 -1
- package/dist/config/role-schema.js +3 -3
- package/dist/config/schema-migration.js +121 -0
- package/dist/core/agent-application-service.js +11 -0
- package/dist/core/agent-ipc-registration.js +2 -0
- package/dist/core/agent-runtime.js +41 -9
- package/dist/core/auth/auth-gateway.js +3 -3
- package/dist/core/auth/operation-authorizer.js +2 -1
- package/dist/core/baseagent-loader.js +11 -3
- package/dist/core/bootstrap-service.js +8 -0
- package/dist/core/channel-loader.js +61 -23
- package/dist/core/command/agent-control.js +4 -1
- package/dist/core/command/chatmode-config.js +46 -0
- package/dist/core/command/command-handler.js +5 -14
- package/dist/core/command/daemon-diagnostics.js +2 -1
- package/dist/core/command/menu-catalog.js +1 -1
- package/dist/core/command/menu-handler.js +16 -16
- package/dist/core/command/slash-handler.js +4 -26
- package/dist/core/daemon-lifecycle.js +35 -17
- package/dist/core/event-catalog.js +19 -0
- package/dist/core/evolagent-registry.js +3 -0
- package/dist/core/ipc-registration.js +6 -0
- package/dist/core/message/im-renderer.js +24 -19
- package/dist/core/message/message-admission.js +11 -2
- package/dist/core/message/response-engine.js +17 -18
- package/dist/core/model/model-capabilities.js +37 -0
- package/dist/core/model/model-catalog.js +6 -2
- package/dist/core/ownership/owner-resolver.js +6 -6
- package/dist/core/permission/ec-command-parser.js +47 -12
- package/dist/core/plugin-lifecycle.js +6 -2
- package/dist/core/relation/pa-team.js +7 -2
- package/dist/directory/owner-directory-cache.js +4 -2
- package/dist/directory/owner-directory-query-operation.js +5 -7
- package/dist/ecweb/runtime/lifecycle.js +29 -5
- package/dist/ecweb/runtime/supervisor.js +83 -27
- package/dist/index.js +198 -38
- package/dist/proxy/service-supervisor.js +377 -141
- package/dist/trigger/audit.js +3 -2
- package/dist/trigger/authorization.js +2 -3
- package/dist/trigger/history.js +4 -3
- package/dist/trigger/ipc-service.js +24 -19
- package/dist/trigger/manager.js +3 -5
- package/dist/trigger/parser.js +4 -21
- package/dist/trigger/patch.js +3 -15
- package/dist/trigger/scheduler.js +45 -10
- package/dist/trigger/validation.js +0 -13
- package/dist/utils/error-utils.js +8 -0
- package/dist/utils/macos-autostart.js +31 -0
- package/dist/utils/model-prices.jsonl +15 -8
- package/dist/utils/process-introspect.js +21 -1
- package/dist/utils/startup-trace.js +7 -1
- package/dist/utils/windows-autostart.js +1 -0
- package/ecagent/dist/harness/compaction/branch-summarization.js +1 -1
- package/ecagent/dist/harness/compaction/compaction.js +4 -4
- package/kits/docs/evolcore/INDEX.md +1 -1
- package/kits/docs/evolcore/file-navigation.md +63 -49
- package/kits/docs/evolcore/menu-protocol.md +1 -0
- package/kits/docs/evolcore/model.md +5 -3
- package/kits/docs/evolcore/response.md +2 -0
- package/kits/docs/evolcore/thread-chain.md +1 -1
- package/kits/docs/evolcore/tool-authorization.md +4 -1
- package/kits/docs/evolcore/trigger.md +10 -7
- package/kits/eck_manifest.json +0 -21
- package/kits/rules/01-overview.md +42 -44
- package/kits/rules/02-navigation.md +44 -53
- package/kits/rules/03-identity.md +21 -25
- package/kits/rules/04-relation.md +23 -33
- package/kits/rules/05-venue.md +24 -25
- package/kits/schemas/_meta.json +13 -26
- package/kits/schemas/agent-config.schema.19.json +10 -6
- package/kits/schemas/relation-config.schema.12.json +2 -2
- package/kits/schemas/role-config.schema.2.json +5 -5
- package/kits/skills/ec-service-proxy/SKILL.md +10 -0
- package/kits/skills/ec-trigger/SKILL.md +1 -1
- package/kits/templates/system-fragments/commands.md +1 -1
- package/kits/templates/system-fragments/identity.md +0 -1
- package/package.json +18 -13
- package/kits/schemas/agent-config.schema.20.json +0 -925
- package/kits/schemas/relation-config.schema.13.json +0 -289
- package/kits/schemas/role-config.schema.3.json +0 -1038
|
@@ -594,9 +594,7 @@ export class CommandHandler {
|
|
|
594
594
|
validateTriggerRuntimeFields(definition, role, baseagent) {
|
|
595
595
|
if (!role)
|
|
596
596
|
return undefined;
|
|
597
|
-
const executionBaseagent =
|
|
598
|
-
? definition.execution.baseagent ?? baseagent
|
|
599
|
-
: baseagent;
|
|
597
|
+
const executionBaseagent = baseagent;
|
|
600
598
|
if (definition.execution.model) {
|
|
601
599
|
const modelDecision = validateModelSelectionForRole({
|
|
602
600
|
role,
|
|
@@ -712,20 +710,14 @@ export class CommandHandler {
|
|
|
712
710
|
if (permissionMode === 'fullaccess' && !canApprovePersistentFullAccess) {
|
|
713
711
|
return { error: '当前认证通道不能批准持久 fullaccess Trigger' };
|
|
714
712
|
}
|
|
715
|
-
if (
|
|
716
|
-
|
|
717
|
-
return { error: 'Trigger baseagent 不能为空' };
|
|
718
|
-
}
|
|
719
|
-
if (parsed.executionType !== 'trigger_session') {
|
|
720
|
-
return { error: 'Trigger baseagent 仅适用于 trigger_session' };
|
|
721
|
-
}
|
|
722
|
-
}
|
|
713
|
+
if ('baseagent' in parsed)
|
|
714
|
+
return { error: 'Trigger 不支持覆盖 baseagent;使用所属 Agent 当前基座' };
|
|
723
715
|
const daemonScheduler = schedulerAid === this.getDaemonTriggerOwnerAid(channel);
|
|
724
716
|
const triggerOwner = daemonScheduler
|
|
725
717
|
? undefined
|
|
726
718
|
: this.agentRegistry?.get?.(schedulerAid) ?? this.getOwningAgent(channel);
|
|
727
719
|
const executionBaseagent = parsed.executionType === 'trigger_session'
|
|
728
|
-
?
|
|
720
|
+
? triggerOwner?.baseagent ?? triggerRole.baseagent
|
|
729
721
|
?? (daemonScheduler ? this.parseDefaultBaseagent() : undefined)
|
|
730
722
|
: undefined;
|
|
731
723
|
if (parsed.executionType === 'trigger_session') {
|
|
@@ -761,7 +753,6 @@ export class CommandHandler {
|
|
|
761
753
|
...(script ? { script } : { prompt: parsed.prompt || '' }),
|
|
762
754
|
...(parsed.executionType === 'trigger_session' ? {
|
|
763
755
|
thread: parsed.triggerThread ?? 'by_trigger',
|
|
764
|
-
baseagent: executionBaseagent,
|
|
765
756
|
} : {}),
|
|
766
757
|
model: parsed.model,
|
|
767
758
|
timeoutMs: parsed.executionTimeoutMs,
|
|
@@ -1520,7 +1511,7 @@ export class CommandHandler {
|
|
|
1520
1511
|
/trigger list [--all] — 查看所有触发器
|
|
1521
1512
|
/trigger create <参数> — 创建触发器(set 为兼容别名)
|
|
1522
1513
|
/trigger update <名称|ID> <参数> — 修改触发器
|
|
1523
|
-
常用参数:--delay/--at/--cron/--every、--prompt、--description、--model、--effort、--permission(省略则继承;update 可用 inherit 清除覆盖)、--feedback、--target-channel/--target-channel-id、--trigger-thread、--
|
|
1514
|
+
常用参数:--delay/--at/--cron/--every、--prompt、--description、--model、--effort、--permission(省略则继承;update 可用 inherit 清除覆盖)、--feedback、--target-channel/--target-channel-id、--trigger-thread、--on-error、--retry-attempts/--retry-backoff、--script-runtime/--script-args/--script-timeout
|
|
1524
1515
|
/trigger enable <名称|ID> — 启用触发器
|
|
1525
1516
|
/trigger disable <名称|ID> — 暂停触发器
|
|
1526
1517
|
/trigger show <名称|ID> — 查看触发器详情
|
|
@@ -11,7 +11,8 @@ export function parseManagedDaemonLogArgv(argv) {
|
|
|
11
11
|
for (let index = 1; index < argv.length; index += 1) {
|
|
12
12
|
const flag = argv[index];
|
|
13
13
|
if (flag === '--raw') {
|
|
14
|
-
|
|
14
|
+
query.raw = true;
|
|
15
|
+
continue;
|
|
15
16
|
}
|
|
16
17
|
if (flag === '--no-color')
|
|
17
18
|
continue;
|
|
@@ -100,7 +100,7 @@ const ENTRIES = [
|
|
|
100
100
|
},
|
|
101
101
|
// 模型与推理强度只在 Agent 级配置(见 model.agent / effort.agent),关系菜单不再提供。
|
|
102
102
|
relation('chatmode.relation', 'chatmode', '对话模式', 30, '/chatmode', 'chatmode.current', { options: { cmd: '/chatmode', operation: 'chatmode.current', scope: 'relation', mode: 'dynamic' }, update: { cmd: '/chatmode', operation: 'chatmode.update', scope: 'relation' }, control: 'select' }),
|
|
103
|
-
relation('activity.relation', 'activity', '中间输出', 40, '/activity', 'activity.current', { options: { cmd: '/activity', operation: 'activity.current', scope: 'relation', mode: 'static', items: [{ value: 'all', label: '
|
|
103
|
+
relation('activity.relation', 'activity', '中间输出', 40, '/activity', 'activity.current', { options: { cmd: '/activity', operation: 'activity.current', scope: 'relation', mode: 'static', items: [{ value: 'all', label: '全部显示' }, { value: 'text', label: '仅文字进展' }, { value: 'none', label: '全部静默' }] }, update: { cmd: '/activity', operation: 'activity.update', scope: 'relation' }, control: 'select' }),
|
|
104
104
|
{ id: 'task.activities', type: 'list', contexts: ['private_relation', 'group_relation'], name: 'task', label: '任务活动', section: 'relation_behavior', order: 45, query: { cmd: '/task', args: { view: 'activities' }, operation: 'task.activity.read', scope: 'relation', mode: 'dynamic' }, control: 'list' },
|
|
105
105
|
relation('permissionMode.relation', 'permission', '权限模式', 50, '/perm', 'permission.current', { query: { cmd: '/perm', args: { scope: 'role' }, operation: 'permission.current', scope: 'relation' }, options: undefined, update: { cmd: '/perm', operation: 'permission.current', scope: 'relation', supported: false }, control: 'select' }),
|
|
106
106
|
relation('mentionMode.relation', 'group', '群消息响应', 60, '/group', 'group.mentionmode.current', { contexts: ['group_relation'], query: { cmd: '/group', args: { view: 'mentionMode', scope: 'relation' }, operation: 'group.mentionmode.current', scope: 'relation' }, options: { cmd: '/group', args: { option: 'mentionMode', scope: 'relation' }, operation: 'group.mentionmode.current', scope: 'relation' }, update: { cmd: '/group', args: { resource: 'mentionMode', scope: 'relation' }, operation: 'group.mentionmode.update', scope: 'relation' }, control: 'select' }),
|
|
@@ -4,6 +4,7 @@ import { getBaseagentSnapshot, loadedBaseagentIds } from '../../agents/baseagent
|
|
|
4
4
|
import { resolveBaseagentModelSelection } from '../../agents/baseagent.js';
|
|
5
5
|
import { normalizePeer, writeAgentModelConfig } from '../model/config-scope.js';
|
|
6
6
|
import { formatPeerKey } from '../relation/peer-identity.js';
|
|
7
|
+
import { writeChatmodeConfig } from './chatmode-config.js';
|
|
7
8
|
import { modelMatches, getCatalog, getBaseagentCatalog, resolveCatalogModel, assertCatalogSelectable, CONFIGURABLE_EFFORTS, configurableEfforts } from '../model/model-catalog.js';
|
|
8
9
|
import { constrainResolvedModelForRole, filterModelsForRole, validateModelSelectionForRole } from '../model/model-permission.js';
|
|
9
10
|
import { hasModelSwitcher } from '../../agents/runner-types.js';
|
|
@@ -762,16 +763,6 @@ function readMenuChatmode(target) {
|
|
|
762
763
|
catch { }
|
|
763
764
|
return { value: defaultChatmodeForField(target.field), source: 'builtin' };
|
|
764
765
|
}
|
|
765
|
-
function writeMenuChatmode(target, value) {
|
|
766
|
-
const route = routeFieldPath(target.fieldPath, target.scope);
|
|
767
|
-
const cur = cfgRead(route.target, target.sel) || {};
|
|
768
|
-
const block = cur.chatmode && typeof cur.chatmode === 'object' && !Array.isArray(cur.chatmode)
|
|
769
|
-
? { ...cur.chatmode }
|
|
770
|
-
: {};
|
|
771
|
-
block[target.field] = value;
|
|
772
|
-
cur.chatmode = block;
|
|
773
|
-
cfgWrite(route.target, cur, target.sel);
|
|
774
|
-
}
|
|
775
766
|
function menuMentionModeScope(args) {
|
|
776
767
|
const raw = menuStringArg(args, 'scope') ?? 'relation';
|
|
777
768
|
if (raw === 'agent' || raw === 'relation')
|
|
@@ -988,7 +979,10 @@ function resolveMenuActivityTarget(params) {
|
|
|
988
979
|
}
|
|
989
980
|
if (!peerKey)
|
|
990
981
|
return { error: 'relation scope 需要 peer/peerKey,或可推导的当前对端', code: 'MISSING_PEER' };
|
|
991
|
-
|
|
982
|
+
const relation = cfgRead(ConfigTarget.Relation, { ...sel, peerKey });
|
|
983
|
+
const chatType = relation?.targetKind
|
|
984
|
+
?? (!explicitPeer ? params.session?.chatType ?? params.explicitChatType : undefined);
|
|
985
|
+
return { scope, sel: { ...sel, peerKey }, fieldPath: 'show_activities', chatType };
|
|
992
986
|
}
|
|
993
987
|
function readMenuActivity(target, fallback = 'all') {
|
|
994
988
|
try {
|
|
@@ -998,7 +992,7 @@ function readMenuActivity(target, fallback = 'all') {
|
|
|
998
992
|
}
|
|
999
993
|
}
|
|
1000
994
|
catch { }
|
|
1001
|
-
return { value: fallback, source: 'builtin' };
|
|
995
|
+
return { value: target.chatType === 'group' ? 'none' : fallback, source: 'builtin' };
|
|
1002
996
|
}
|
|
1003
997
|
function writeMenuActivity(target, value) {
|
|
1004
998
|
const route = routeFieldPath(target.fieldPath, target.scope);
|
|
@@ -2156,7 +2150,7 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
2156
2150
|
const fallback = this.agentRegistry?.getShowActivities?.(channel) ?? 'all';
|
|
2157
2151
|
const currentMode = readMenuActivity(target, fallback).value;
|
|
2158
2152
|
return [
|
|
2159
|
-
{ value: 'all', label: '
|
|
2153
|
+
{ value: 'all', label: '全部显示', selected: currentMode === 'all' },
|
|
2160
2154
|
{ value: 'text', label: '仅文字进展', selected: currentMode === 'text' },
|
|
2161
2155
|
{ value: 'none', label: '全部静默', selected: currentMode === 'none' },
|
|
2162
2156
|
];
|
|
@@ -3310,7 +3304,9 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3310
3304
|
let session = loadedContext.session;
|
|
3311
3305
|
const evolagent = loadedContext.evolagent;
|
|
3312
3306
|
if (transportReplyContext?.threadId) {
|
|
3313
|
-
|
|
3307
|
+
const modelAgentScope = (cmdBase === '/model' || cmdBase === '/effort')
|
|
3308
|
+
&& (menuStringArg(args, 'scope') ?? 'agent') === 'agent';
|
|
3309
|
+
if (modelAgentScope) {
|
|
3314
3310
|
// Model settings belong to the Agent and can be changed from a locally
|
|
3315
3311
|
// created topic before its first message has registered a Core session.
|
|
3316
3312
|
try {
|
|
@@ -3728,7 +3724,7 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3728
3724
|
return { error: roleDecision.message || '当前角色不允许修改对话模式', code: roleDecision.code || 'ROLE_VALUE_NOT_ALLOWED' };
|
|
3729
3725
|
}
|
|
3730
3726
|
try {
|
|
3731
|
-
|
|
3727
|
+
writeChatmodeConfig(target, arg, subject);
|
|
3732
3728
|
}
|
|
3733
3729
|
catch (e) {
|
|
3734
3730
|
return { error: e?.message || String(e), code: e?.code || 'CONFIG_WRITE_FAILED', ...(e?.data !== undefined ? { data: e.data } : {}) };
|
|
@@ -4186,6 +4182,9 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4186
4182
|
return { error: 'Trigger details use menu.query with args.view="detail"', code: 'NOT_SUPPORTED' };
|
|
4187
4183
|
}
|
|
4188
4184
|
if (action === 'create' || action === 'set') {
|
|
4185
|
+
if (args && 'baseagent' in args) {
|
|
4186
|
+
return { error: 'Trigger 不支持覆盖 baseagent;使用所属 Agent 当前基座', code: 'INVALID_ARGS' };
|
|
4187
|
+
}
|
|
4189
4188
|
// args 结构化 → 直接组装 ParsedTriggerSet(绕过 parseTriggerSet 文本解析,无注入风险)
|
|
4190
4189
|
if (!args?.scheduleType || (args.scheduleType !== 'once' && !args?.scheduleValue) || !args?.prompt) {
|
|
4191
4190
|
return { error: '缺少必填参数:scheduleType / scheduleValue / prompt', code: 'INVALID_ARGS' };
|
|
@@ -4225,7 +4224,6 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4225
4224
|
effort: args.effort,
|
|
4226
4225
|
permissionMode: args.permissionMode,
|
|
4227
4226
|
triggerThread,
|
|
4228
|
-
baseagent: args.baseagent,
|
|
4229
4227
|
};
|
|
4230
4228
|
const r = await this.registerTriggerFromParsed(parsed, channel, channelId, userId ?? '', undefined, this.resolveMenuChatType(channel, channelId, explicitChatType), undefined, isAdmin, subject.isDaemonOwner, subject.canApprovePersistentFullAccess);
|
|
4231
4229
|
if (!r.ok) {
|
|
@@ -4671,6 +4669,8 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4671
4669
|
}
|
|
4672
4670
|
catch (err) {
|
|
4673
4671
|
logger.debug('[MenuHandler] Thread rename sync failed:', err);
|
|
4672
|
+
if (err?.code === 'RENAME_FAILED')
|
|
4673
|
+
return { error: '重命名失败', code: 'EXEC_FAILED' };
|
|
4674
4674
|
}
|
|
4675
4675
|
}
|
|
4676
4676
|
if (!renamedByThreadService) {
|
|
@@ -24,6 +24,7 @@ import { getDaemonOwners, ownerResolver, refreshOwnershipForAuthorization, OWNER
|
|
|
24
24
|
import { authorizationNextStep, formatAuthorizationDenial } from '../auth/authorization-denial.js';
|
|
25
25
|
import { resolvePermissionMode, writeAgentModelConfig } from '../model/config-scope.js';
|
|
26
26
|
import { formatPeerKey } from '../relation/peer-identity.js';
|
|
27
|
+
import { writeChatmodeConfig } from './chatmode-config.js';
|
|
27
28
|
import { preparePaTeamQualification } from '../relation/pa-team.js';
|
|
28
29
|
import { auditFullAccessEvent } from '../auth/authorization-audit.js';
|
|
29
30
|
import { isMainSession, isTopicSession, isTopicThreadId, sessionTopicThreadId } from '../thread/topic-id.js';
|
|
@@ -100,16 +101,6 @@ function readSlashChatmode(target) {
|
|
|
100
101
|
return defaultSlashChatmode(target.field);
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
|
-
function writeSlashChatmode(target, value) {
|
|
104
|
-
const route = routeFieldPath(target.fieldPath, 'relation');
|
|
105
|
-
const cur = cfgRead(route.target, target.sel) || {};
|
|
106
|
-
const block = cur.chatmode && typeof cur.chatmode === 'object' && !Array.isArray(cur.chatmode)
|
|
107
|
-
? { ...cur.chatmode }
|
|
108
|
-
: {};
|
|
109
|
-
block[target.field] = value;
|
|
110
|
-
cur.chatmode = block;
|
|
111
|
-
cfgWrite(route.target, cur, target.sel);
|
|
112
|
-
}
|
|
113
104
|
function resolveSlashMentionModeTarget(params) {
|
|
114
105
|
const self = params.selfAID
|
|
115
106
|
?? params.session?.selfAID
|
|
@@ -2120,10 +2111,6 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2120
2111
|
// 带参(写操作)需 admin+;无参查询对所有人开放(owner 门在具体切换点还有一道)
|
|
2121
2112
|
if (activityArg && !isAdmin)
|
|
2122
2113
|
return { kind: 'command.error', text: '❌ 无权限:此命令仅限管理员使用' };
|
|
2123
|
-
// proactive 模式下流式输出全部静默,activity 配置无意义
|
|
2124
|
-
if (getEffectiveChatmode(activitySession) === 'proactive') {
|
|
2125
|
-
return { kind: 'command.error', text: '❌ 当前会话为 proactive 模式,不支持 activity 配置(流式输出已全部静默)' };
|
|
2126
|
-
}
|
|
2127
2114
|
const modeMap = {
|
|
2128
2115
|
all: 'all',
|
|
2129
2116
|
text: 'text',
|
|
@@ -2133,7 +2120,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2133
2120
|
// 模式描述列表(用于 body 和文本降级)。
|
|
2134
2121
|
// all = 文本 + activity;text = 仅文字进展;none = 全部静默。
|
|
2135
2122
|
const modeDescriptions = [
|
|
2136
|
-
{ key: 'all', configVal: 'all', label: '
|
|
2123
|
+
{ key: 'all', configVal: 'all', label: '全部显示' },
|
|
2137
2124
|
{ key: 'text', configVal: 'text', label: '仅文字进展' },
|
|
2138
2125
|
{ key: 'none', configVal: 'none', label: '全部静默' },
|
|
2139
2126
|
];
|
|
@@ -2322,7 +2309,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2322
2309
|
if (chatmodeAuthDenied)
|
|
2323
2310
|
return chatmodeAuthDenied;
|
|
2324
2311
|
try {
|
|
2325
|
-
|
|
2312
|
+
writeChatmodeConfig({ ...target, scope: 'relation' }, arg, authSubject);
|
|
2326
2313
|
}
|
|
2327
2314
|
catch (e) {
|
|
2328
2315
|
return { kind: 'command.error', text: `Failed to update relation chatmode: ${e?.message || e}` };
|
|
@@ -2822,16 +2809,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2822
2809
|
const projectPath = this.getEffectiveDefaultPath(channel);
|
|
2823
2810
|
if (sendMessage && session) {
|
|
2824
2811
|
const creatingText = `⏳ 正在创建新会话${sessionName ? `: ${sessionName}` : ''}...`;
|
|
2825
|
-
|
|
2826
|
-
// 这里希望它像 /compact 等命令的占位提示一样,按普通消息发送。
|
|
2827
|
-
const creatingPayload = activeChatType === 'private'
|
|
2828
|
-
? { kind: 'command.result', text: creatingText }
|
|
2829
|
-
: {
|
|
2830
|
-
kind: 'system.notice',
|
|
2831
|
-
text: creatingText,
|
|
2832
|
-
subtype: 'session.creating',
|
|
2833
|
-
};
|
|
2834
|
-
await sendMessage(channelId, creatingText, this.getReplyContext(session), creatingPayload);
|
|
2812
|
+
await sendMessage(channelId, creatingText, this.getReplyContext(session), { kind: 'system.notice', text: creatingText, subtype: 'session.creating' });
|
|
2835
2813
|
}
|
|
2836
2814
|
const newSessionBaseagent = this.agentRegistry?.resolveByChannel(channel)?.baseagent || this.parseDefaultBaseagent();
|
|
2837
2815
|
const previousMetadata = session?.metadata || activeSession?.metadata || {};
|
|
@@ -166,13 +166,14 @@ export function resumePendingSessions({ sessionManager, messageQueue, droppedTri
|
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
export function createDaemonShutdown({ disposePluginResources, lifecycleNotices, ipcServer, readySignalPath, bindService, ecwebSupervisor, messageQueue, permissionGateway, removePermissionConfigListener, stopStatsPersistence, triggerSchedulers, agentMap, eventBus, removeGroupInviteConfigListener, groupInviteReviewService, channelLoader, channelInstances, controlChannel, sessionManager, removeAll, exit, }) {
|
|
169
|
+
export function createDaemonShutdown({ disposePluginResources, lifecycleNotices, ipcServer, readySignalPath, bindService, ecwebSupervisor, messageQueue, permissionGateway, removePermissionConfigListener, stopStatsPersistence, triggerSchedulers, agentMap, eventBus, removeGroupInviteConfigListener, groupInviteReviewService, channelLoader, channelInstances, startupRunners, cancelStartup, controlChannel, sessionManager, removeAll, exit, }) {
|
|
170
170
|
let shutdownSignal = 'unknown';
|
|
171
171
|
let shutdownInProgress = false;
|
|
172
172
|
return async (signal, traceId) => {
|
|
173
173
|
if (shutdownInProgress)
|
|
174
174
|
return;
|
|
175
175
|
shutdownInProgress = true;
|
|
176
|
+
cancelStartup?.();
|
|
176
177
|
if (signal)
|
|
177
178
|
shutdownSignal = signal;
|
|
178
179
|
// 先停掉还没发完的上线通知,避免和下面的下线通知交叉。
|
|
@@ -193,33 +194,45 @@ export function createDaemonShutdown({ disposePluginResources, lifecycleNotices,
|
|
|
193
194
|
kind: 'stop',
|
|
194
195
|
traceId: traceId || undefined,
|
|
195
196
|
processStartMs: Date.now(),
|
|
196
|
-
firstPhase: 'daemon.shutdown',
|
|
197
197
|
});
|
|
198
198
|
trace.setMeta('signal', shutdownSignal);
|
|
199
199
|
trace.setMeta('via', traceId ? 'ipc' : 'signal');
|
|
200
|
+
trace.addSpan('daemon.shutdown', trace.startedAtMs, Date.now());
|
|
201
|
+
const ipcStopStartedAt = Date.now();
|
|
200
202
|
ipcServer.stopCpuTracking();
|
|
201
|
-
trace.mark('daemon.stopIpcServer');
|
|
202
203
|
ipcServer.stop();
|
|
203
204
|
try {
|
|
204
205
|
fs.unlinkSync(readySignalPath);
|
|
205
206
|
}
|
|
206
207
|
catch { }
|
|
207
208
|
bindService?.stopCleanup();
|
|
208
|
-
|
|
209
|
+
trace.addSpan('daemon.stopIpcServer', ipcStopStartedAt, Date.now());
|
|
210
|
+
// 每个任务独立记录区间,允许阶段重叠,不能共用线性 mark/note 游标。
|
|
211
|
+
let shutdownSucceeded = true;
|
|
209
212
|
const shutdownStep = async (name, label, operation) => {
|
|
210
|
-
|
|
213
|
+
const startedAt = Date.now();
|
|
214
|
+
let detail;
|
|
211
215
|
try {
|
|
212
|
-
await operation();
|
|
216
|
+
detail = (await operation()) || undefined;
|
|
213
217
|
}
|
|
214
218
|
catch (error) {
|
|
215
|
-
|
|
219
|
+
shutdownSucceeded = false;
|
|
220
|
+
detail = `失败: ${error instanceof Error ? error.message : String(error)}`;
|
|
216
221
|
logger.error(`[Shutdown] ${label} failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
217
222
|
}
|
|
223
|
+
finally {
|
|
224
|
+
trace.addSpan(name, startedAt, Date.now(), detail);
|
|
225
|
+
}
|
|
218
226
|
};
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
227
|
+
// 先启动 ECWeb 关闭,与其余停机工作重叠;finally 必须汇合,不能遗留受管子进程。
|
|
228
|
+
const ecwebShutdown = shutdownStep('daemon.stopEcweb', 'stop ECWeb supervisor', async () => {
|
|
229
|
+
await ecwebSupervisor?.stop(timing => {
|
|
230
|
+
trace.addSpan(`daemon.stopEcweb.${timing.phase}`, timing.startMs, timing.endMs, timing.detail);
|
|
231
|
+
logger.info(`[Shutdown] ECWeb ${timing.phase}: ${timing.endMs - timing.startMs}ms`
|
|
232
|
+
+ (timing.detail ? `; ${timing.detail}` : ''));
|
|
222
233
|
});
|
|
234
|
+
});
|
|
235
|
+
try {
|
|
223
236
|
const queueShutdown = messageQueue.shutdownGracefully();
|
|
224
237
|
await shutdownStep('daemon.stopPermissions', 'cancel pending permissions', () => permissionGateway.cancelAllPending('daemon_restart'));
|
|
225
238
|
// 这两步各带超时(5s / 6.5s),退出慢的头号嫌疑就是它们空等到超时。
|
|
@@ -231,6 +244,8 @@ export function createDaemonShutdown({ disposePluginResources, lifecycleNotices,
|
|
|
231
244
|
});
|
|
232
245
|
await shutdownStep('daemon.queueDrain', 'interrupt active message queue tasks', async () => { await queueShutdown; });
|
|
233
246
|
await shutdownStep('daemon.agentRunners', 'dispose agent runners', async () => {
|
|
247
|
+
if (startupRunners)
|
|
248
|
+
await Promise.allSettled([startupRunners]);
|
|
234
249
|
const currentInstances = [...agentMap.entries()].map(([key, agent]) => {
|
|
235
250
|
const split = key.lastIndexOf('::');
|
|
236
251
|
return {
|
|
@@ -250,18 +265,22 @@ export function createDaemonShutdown({ disposePluginResources, lifecycleNotices,
|
|
|
250
265
|
const { stopGlobalSkillWatcher } = await import('./skill/global-watcher.js');
|
|
251
266
|
await stopGlobalSkillWatcher();
|
|
252
267
|
});
|
|
253
|
-
|
|
268
|
+
const channelsShutdown = shutdownStep('daemon.channels', 'disconnect channels', async () => {
|
|
254
269
|
const timings = await channelLoader.disconnectAll(channelInstances);
|
|
255
270
|
// 慢的渠道和超时的渠道写进阶段附注,甘特图上悬停就能看到,不用再翻日志。
|
|
256
271
|
const slowest = timings[0];
|
|
257
272
|
const timedOut = timings.filter(t => t.timedOut);
|
|
258
273
|
if (timedOut.length > 0) {
|
|
259
|
-
|
|
274
|
+
return `${timings.length} 个渠道;${timedOut.length} 个超时放弃(最慢 ${slowest?.name} ${slowest?.durationMs}ms)`;
|
|
260
275
|
}
|
|
261
276
|
else if (slowest && slowest.durationMs >= 1_000) {
|
|
262
|
-
|
|
277
|
+
return `${timings.length} 个渠道;最慢 ${slowest.name} ${slowest.durationMs}ms`;
|
|
263
278
|
}
|
|
264
279
|
});
|
|
280
|
+
const controlShutdown = controlChannel
|
|
281
|
+
? shutdownStep('daemon.controlAid', 'disconnect control AID', () => controlChannel.disconnect())
|
|
282
|
+
: Promise.resolve();
|
|
283
|
+
await Promise.all([channelsShutdown, controlShutdown]);
|
|
265
284
|
for (const instance of channelInstances) {
|
|
266
285
|
const type = instance.channelType || instance.adapter.channelName;
|
|
267
286
|
eventBus.publish({
|
|
@@ -271,14 +290,13 @@ export function createDaemonShutdown({ disposePluginResources, lifecycleNotices,
|
|
|
271
290
|
reason: 'shutdown',
|
|
272
291
|
});
|
|
273
292
|
}
|
|
274
|
-
if (controlChannel) {
|
|
275
|
-
await shutdownStep('daemon.controlAid', 'disconnect control AID', () => controlChannel?.disconnect());
|
|
276
|
-
}
|
|
277
293
|
}
|
|
278
294
|
catch (error) {
|
|
295
|
+
shutdownSucceeded = false;
|
|
279
296
|
logger.error(`[Shutdown] Unexpected shutdown failure: ${error instanceof Error ? error.stack || error.message : String(error)}`);
|
|
280
297
|
}
|
|
281
298
|
finally {
|
|
299
|
+
await ecwebShutdown;
|
|
282
300
|
await shutdownStep('daemon.pluginResources', 'dispose plugin resources', async () => { await disposePluginResources?.(); });
|
|
283
301
|
await shutdownStep('daemon.finalizers', 'remove permission config listener', () => removePermissionConfigListener?.());
|
|
284
302
|
await shutdownStep('daemon.statsPersistence', 'stop stats persistence', () => stopStatsPersistence?.());
|
|
@@ -287,7 +305,7 @@ export function createDaemonShutdown({ disposePluginResources, lifecycleNotices,
|
|
|
287
305
|
logger.info('✓ Shutdown complete');
|
|
288
306
|
// 必须在 exit 之前落盘:appendFileSync 是同步写,记录不会随进程消失。
|
|
289
307
|
trace.mark('daemon.exit');
|
|
290
|
-
trace.finish(
|
|
308
|
+
trace.finish(shutdownSucceeded);
|
|
291
309
|
exit(0);
|
|
292
310
|
}
|
|
293
311
|
};
|
|
@@ -781,6 +781,25 @@ const CATALOG = [
|
|
|
781
781
|
{ path: 'phase', type: 'string' },
|
|
782
782
|
],
|
|
783
783
|
},
|
|
784
|
+
{
|
|
785
|
+
type: 'trigger:interrupted',
|
|
786
|
+
namespace: 'trigger',
|
|
787
|
+
name: 'interrupted',
|
|
788
|
+
description: 'trigger run 被操作员中止',
|
|
789
|
+
internal: true,
|
|
790
|
+
fields: [
|
|
791
|
+
{ path: 'triggerId', type: 'string' },
|
|
792
|
+
{ path: 'name', type: 'string' },
|
|
793
|
+
{ path: 'runId', type: 'string' },
|
|
794
|
+
{ path: 'originTriggerId', type: 'string' },
|
|
795
|
+
{ path: 'messageId', type: 'string' },
|
|
796
|
+
{ path: 'reason', type: 'string' },
|
|
797
|
+
{ path: 'error', type: 'string' },
|
|
798
|
+
{ path: 'targetChannel', type: 'string' },
|
|
799
|
+
{ path: 'targetChannelId', type: 'string' },
|
|
800
|
+
{ path: 'fireTime', type: 'number' },
|
|
801
|
+
],
|
|
802
|
+
},
|
|
784
803
|
{
|
|
785
804
|
type: 'trigger:skipped',
|
|
786
805
|
namespace: 'trigger',
|
|
@@ -287,6 +287,7 @@ export class EvolAgentRegistry {
|
|
|
287
287
|
const oldAgent = this.agents.get(aidOrName);
|
|
288
288
|
if (!oldAgent)
|
|
289
289
|
throw new Error(`Agent "${aidOrName}" not found`);
|
|
290
|
+
await hooks.beforeAgentOperation?.(oldAgent.aid);
|
|
290
291
|
const expandedRaw = loadAgent(oldAgent.aid);
|
|
291
292
|
if (!expandedRaw)
|
|
292
293
|
throw new Error(`Agent ${oldAgent.aid}/config.json missing on reload`);
|
|
@@ -513,6 +514,7 @@ export class EvolAgentRegistry {
|
|
|
513
514
|
const agent = this.agents.get(aidOrName);
|
|
514
515
|
if (!agent)
|
|
515
516
|
throw new Error(`Agent "${aidOrName}" not found`);
|
|
517
|
+
await hooks.beforeAgentOperation?.(agent.aid);
|
|
516
518
|
if (agent.status === 'disabled')
|
|
517
519
|
throw new Error('Agent is disabled; use enable/disable instead');
|
|
518
520
|
if (agent.status === 'stopped') {
|
|
@@ -539,6 +541,7 @@ export class EvolAgentRegistry {
|
|
|
539
541
|
const agent = this.agents.get(aidOrName);
|
|
540
542
|
if (!agent)
|
|
541
543
|
throw new Error(`Agent "${aidOrName}" not found`);
|
|
544
|
+
await hooks.beforeAgentOperation?.(agent.aid);
|
|
542
545
|
if (agent.status === 'disabled')
|
|
543
546
|
throw new Error('Agent is disabled; use enable instead');
|
|
544
547
|
if (agent.status === 'error')
|
|
@@ -721,6 +721,12 @@ export function registerOperationIpcProviders({ ipcServer, sessionManager, messa
|
|
|
721
721
|
const authorization = await authorizeManagedAgentOperation(params, 'system.status');
|
|
722
722
|
if (!authorization.ok)
|
|
723
723
|
return authorization;
|
|
724
|
+
if (query.raw) {
|
|
725
|
+
if (!authorization.fullAccess) {
|
|
726
|
+
return { ok: false, code: 'NOT_ALLOWED', error: '--raw requires a trusted fullaccess task' };
|
|
727
|
+
}
|
|
728
|
+
return { ok: true, data: { rawAuthorized: true } };
|
|
729
|
+
}
|
|
724
730
|
return { ok: true, data: queryDiagnosticLogs(query, authorization.aid) };
|
|
725
731
|
}
|
|
726
732
|
catch (error) {
|
|
@@ -118,10 +118,12 @@ export class IMRenderer {
|
|
|
118
118
|
if (isFinal) {
|
|
119
119
|
const pending = this.deferredProactiveText;
|
|
120
120
|
this.deferredProactiveText = [];
|
|
121
|
-
if (!isNoopText(pending.map(item => item.text).join(''), this.opts.noopSentinel
|
|
121
|
+
if (!this.opts.noopSentinel || !isNoopText(pending.map(item => item.text).join(''), this.opts.noopSentinel)) {
|
|
122
122
|
for (const item of pending) {
|
|
123
123
|
this.recordActivity(item);
|
|
124
|
-
|
|
124
|
+
if (!this.suppressProactiveItem(item)) {
|
|
125
|
+
await this.sendPayload({ kind: 'activity.batch', items: [item] });
|
|
126
|
+
}
|
|
125
127
|
}
|
|
126
128
|
}
|
|
127
129
|
}
|
|
@@ -189,7 +191,7 @@ export class IMRenderer {
|
|
|
189
191
|
this.itemsQueue = this.itemsQueue.filter(it => it.kind !== 'text');
|
|
190
192
|
return;
|
|
191
193
|
}
|
|
192
|
-
if (mayBeNoopText(rawText, this.opts.noopSentinel
|
|
194
|
+
if (this.opts.noopSentinel && mayBeNoopText(rawText, this.opts.noopSentinel))
|
|
193
195
|
return;
|
|
194
196
|
if (this.timer) {
|
|
195
197
|
clearTimeout(this.timer);
|
|
@@ -617,21 +619,16 @@ export class IMRenderer {
|
|
|
617
619
|
this.messageTimestamps.push(Date.now());
|
|
618
620
|
this.scheduleFlush();
|
|
619
621
|
}
|
|
620
|
-
/**
|
|
621
|
-
async
|
|
622
|
-
if (!this.opts.
|
|
622
|
+
/** 通过系统通知发送运行状态,并保持与已有正文的发送顺序。 */
|
|
623
|
+
async sendOperationalNotice(text, subtype) {
|
|
624
|
+
if (!this.opts.operationalNoticesEnabled || this.opts.envelope.chatmode === 'proactive' || !text)
|
|
623
625
|
return false;
|
|
624
626
|
if (!this.hasSendableText(text, 'operational-notice'))
|
|
625
627
|
return false;
|
|
626
628
|
// 保持与流式正文的到达顺序:先发出已缓冲的正文,再投影运行状态。
|
|
627
629
|
await this.flushText();
|
|
628
|
-
const payload = {
|
|
629
|
-
kind: 'result.text',
|
|
630
|
-
text,
|
|
631
|
-
isFinal: false,
|
|
632
|
-
};
|
|
633
630
|
this.sentContent = true;
|
|
634
|
-
await this.
|
|
631
|
+
await this.sendSystemNotice(text, subtype);
|
|
635
632
|
this.lastFlush = Date.now();
|
|
636
633
|
this.flushCount++;
|
|
637
634
|
return true;
|
|
@@ -715,11 +712,11 @@ export class IMRenderer {
|
|
|
715
712
|
this.sendChain = handled.catch(() => { });
|
|
716
713
|
return handled;
|
|
717
714
|
}
|
|
718
|
-
/** Model output
|
|
719
|
-
*
|
|
715
|
+
/** Model output uses PA's automatic-text outlet.
|
|
716
|
+
* System notices, explicit sends, command receipts and interaction fallbacks bypass it.
|
|
720
717
|
*/
|
|
721
718
|
async sendAutomaticText(payload) {
|
|
722
|
-
if (isNoopText(payload.text, this.opts.noopSentinel
|
|
719
|
+
if (this.opts.noopSentinel && isNoopText(payload.text, this.opts.noopSentinel))
|
|
723
720
|
return;
|
|
724
721
|
if (this.opts.envelope.chatmode !== 'paactive')
|
|
725
722
|
return this.sendPayload(payload);
|
|
@@ -864,7 +861,7 @@ export class IMRenderer {
|
|
|
864
861
|
item.text = item.text.replace(this.opts.fileMarkerPattern, '');
|
|
865
862
|
}
|
|
866
863
|
}
|
|
867
|
-
if (isFinal && isNoopText(this.textBuffer, this.opts.noopSentinel
|
|
864
|
+
if (isFinal && this.opts.noopSentinel && isNoopText(this.textBuffer, this.opts.noopSentinel)) {
|
|
868
865
|
this.discardPendingText();
|
|
869
866
|
}
|
|
870
867
|
else if (!this.hasSendableText(this.textBuffer, isFinal ? 'final' : 'flush')) {
|
|
@@ -912,7 +909,7 @@ export class IMRenderer {
|
|
|
912
909
|
if (!isFinal && this.textBuffer.length > 0) {
|
|
913
910
|
if (this.suppressIntermediateText())
|
|
914
911
|
return;
|
|
915
|
-
if (mayBeNoopText(this.textBuffer, this.opts.noopSentinel
|
|
912
|
+
if (this.opts.noopSentinel && mayBeNoopText(this.textBuffer, this.opts.noopSentinel))
|
|
916
913
|
return;
|
|
917
914
|
// A timer cannot decide whether this is the final answer. Keep it for
|
|
918
915
|
// an explicit boundary; known commentary can still be sent immediately.
|
|
@@ -1054,13 +1051,14 @@ export class IMRenderer {
|
|
|
1054
1051
|
/** proactive:单个 ThoughtItem 包成 activity.batch[1] 发出。 */
|
|
1055
1052
|
emitProactiveItem(item) {
|
|
1056
1053
|
if (item.kind === 'text' || (item.kind === 'summary' && !item.is_error)) {
|
|
1057
|
-
if (this.opts.noopSentinel || this.deferredProactiveText.length > 0
|
|
1058
|
-
|| mayBeNoopText(item.text)) {
|
|
1054
|
+
if (this.opts.noopSentinel || this.deferredProactiveText.length > 0) {
|
|
1059
1055
|
this.deferredProactiveText.push(item);
|
|
1060
1056
|
return;
|
|
1061
1057
|
}
|
|
1062
1058
|
}
|
|
1063
1059
|
this.recordActivity(item);
|
|
1060
|
+
if (this.suppressProactiveItem(item))
|
|
1061
|
+
return;
|
|
1064
1062
|
const evolCommand = item.kind === 'tool_call' ? item.evolCommand : undefined;
|
|
1065
1063
|
const payload = evolCommand
|
|
1066
1064
|
? { kind: 'activity.batch', items: [item], ext: { evolCommand } }
|
|
@@ -1069,6 +1067,13 @@ export class IMRenderer {
|
|
|
1069
1067
|
logger.debug(`[IMRenderer] proactive send failed: ${err.message}`);
|
|
1070
1068
|
});
|
|
1071
1069
|
}
|
|
1070
|
+
suppressProactiveItem(item) {
|
|
1071
|
+
if (item.kind === 'text' || item.kind === 'summary') {
|
|
1072
|
+
// noopSentinel only defers text until its full prefix can be checked.
|
|
1073
|
+
return this.opts.suppressIntermediateText ?? this.opts.suppressActivities ?? false;
|
|
1074
|
+
}
|
|
1075
|
+
return this.suppressActivityItems();
|
|
1076
|
+
}
|
|
1072
1077
|
mapEventToItem(event) {
|
|
1073
1078
|
switch (event.type) {
|
|
1074
1079
|
case 'text':
|
|
@@ -26,8 +26,17 @@ export async function evaluateOutboundContactAdmission(input) {
|
|
|
26
26
|
catch (error) {
|
|
27
27
|
return { allow: false, code: 'CONTACT_POLICY_INVALID', status: 'absent', error: error instanceof Error ? error.message : String(error) };
|
|
28
28
|
}
|
|
29
|
-
if (decision.allow)
|
|
30
|
-
|
|
29
|
+
if (decision.allow) {
|
|
30
|
+
if (decision.reason === 'owner')
|
|
31
|
+
return { allow: true, status: 'owner' };
|
|
32
|
+
if (decision.reason === 'temporary')
|
|
33
|
+
return { allow: true, status: 'temporary' };
|
|
34
|
+
if (decision.reason === 'open') {
|
|
35
|
+
const policy = readAccessPolicy(selfAid);
|
|
36
|
+
return { allow: true, status: policy.allowedAids?.includes(targetAid) ? 'allowed_aid' : 'all_contacts' };
|
|
37
|
+
}
|
|
38
|
+
return { allow: true, status: 'contact' };
|
|
39
|
+
}
|
|
31
40
|
return { allow: false, code: decision.reason === 'unavailable' ? 'CONTACT_DIRECTORY_UNAVAILABLE'
|
|
32
41
|
: decision.reason === 'blocked' ? 'CONTACT_BLOCKED' : 'CONTACT_DENIED',
|
|
33
42
|
status: decision.reason === 'unavailable' ? 'unavailable' : decision.reason === 'blocked' ? 'blocked' : 'denied',
|