evolcore 0.0.43-test.6 → 0.0.43-test.7
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 +48 -0
- package/bin/ecmsg.js +171 -54
- package/dist/agents/baseagent-availability.js +1 -1
- package/dist/agents/codex/app-server-client.js +22 -0
- package/dist/agents/codex-runner.js +69 -2
- package/dist/aun/msg/p2p.js +6 -1
- package/dist/channels/aun.js +234 -21
- package/dist/cli/agent-create.js +2 -2
- package/dist/cli/daemon-commands.js +6 -66
- package/dist/cli/daemon-lifecycle-client.js +61 -0
- package/dist/cli/ecmsg-gateway.js +35 -2
- package/dist/cli/events-command.js +73 -0
- package/dist/cli/index.js +31 -14
- package/dist/cli/invoke-command.js +182 -0
- package/dist/cli/managed-command-guard.js +6 -1
- package/dist/cli/restart-monitor.js +45 -47
- package/dist/cli/services-command.js +111 -0
- package/dist/cli/team-workspace-command.js +134 -0
- package/dist/cli/thread-command.js +6 -2
- package/dist/cli/watch-msg.js +1 -1
- package/dist/config/config-field-policy.js +2 -2
- package/dist/config/config-manager.js +0 -7
- package/dist/config/invoke-ipc-service.js +118 -0
- package/dist/config/schema-migration.js +6 -1
- package/dist/config-store.js +2 -1
- package/dist/core/agent-reload-coordinator.js +6 -4
- package/dist/core/agent-runtime.js +104 -10
- package/dist/core/auth/delegation-authorization.js +66 -0
- package/dist/core/auth/operation-catalog.js +20 -0
- package/dist/core/baseagent-loader.js +60 -130
- package/dist/core/channel-loader.js +10 -1
- package/dist/core/channel-runtime.js +4 -3
- package/dist/core/command/agent-control.js +1 -1
- package/dist/core/command/agent-storage-menu.js +1 -1
- package/dist/core/command/chatmode-config.js +2 -36
- package/dist/core/command/command-handler.js +53 -11
- package/dist/core/command/data-root-resolver.js +32 -23
- package/dist/core/command/eventcenter-menu.js +338 -0
- package/dist/core/command/menu-catalog.js +8 -0
- package/dist/core/command/menu-handler.js +198 -84
- package/dist/core/command/menu-protocol.js +60 -11
- package/dist/core/command/menu-query-batch.js +194 -0
- package/dist/core/command/slash-gate.js +1 -1
- package/dist/core/command/slash-handler.js +34 -42
- package/dist/core/command/team-workspace-bootstrap.js +350 -0
- package/dist/core/command/{pa-workspace-calendar.js → team-workspace-calendar.js} +7 -7
- package/dist/core/command/team-workspace-initializer.js +2 -0
- package/dist/core/command/{pa-workspace-items.js → team-workspace-items.js} +83 -68
- package/dist/core/command/team-workspace-job-store.js +88 -0
- package/dist/core/command/team-workspace-management-service.js +2 -0
- package/dist/core/command/team-workspace-management-store.js +96 -0
- package/dist/core/command/team-workspace-management.js +265 -0
- package/dist/core/command/team-workspace-members-menu.js +88 -0
- package/dist/core/command/team-workspace-store.js +612 -0
- package/dist/core/command/team-workspace-team.js +193 -0
- package/dist/core/daemon-control.js +8 -5
- package/dist/core/daemon-lifecycle.js +132 -73
- package/dist/core/handoff/runtime.js +3 -3
- package/dist/core/invoke/executors/index.js +13 -0
- package/dist/core/invoke/executors/media.js +283 -0
- package/dist/core/invoke/executors/text.js +198 -0
- package/dist/core/invoke/invoke-service.js +157 -0
- package/dist/core/invoke/style-router.js +48 -0
- package/dist/core/invoke/types.js +19 -0
- package/dist/core/ipc-registration.js +46 -7
- package/dist/core/memory/consolidation.js +7 -5
- package/dist/core/message/aun-ipc-sender.js +147 -17
- package/dist/core/message/im-renderer.js +28 -84
- package/dist/core/message/message-bridge.js +4 -0
- package/dist/core/message/message-utils.js +10 -2
- package/dist/core/message/peer-mode.js +7 -34
- package/dist/core/message/response-engine.js +157 -54
- package/dist/core/message/send-options.js +7 -4
- package/dist/core/message/send-routing.js +43 -5
- package/dist/core/ownership/owner-resolver.js +7 -0
- package/dist/core/permission/ec-command-parser.js +3 -2
- package/dist/core/permission/protected-paths.js +12 -2
- package/dist/core/permission/shell-environment.js +9 -0
- package/dist/core/session/session-file-health.js +243 -0
- package/dist/core/session/session-fs-store.js +2 -3
- package/dist/core/task/task-recovery-service.js +13 -2
- package/dist/core/thread/command-parser.js +9 -2
- package/dist/core/thread/thread-operation.js +21 -2
- package/dist/core/thread/thread-route.js +13 -2
- package/dist/directory/owner-directory-admission.js +40 -53
- package/dist/directory/owner-directory-cache.js +89 -113
- package/dist/directory/owner-directory-query-operation.js +8 -10
- package/dist/eck/kit-renderer.js +7 -5
- package/dist/ecweb/basic-settings-service.js +1 -1
- package/dist/ecweb/message-context-service.js +0 -4
- package/dist/ecweb/runtime/lifecycle.js +6 -2
- package/dist/ecweb/runtime/supervisor.js +19 -4
- package/dist/event-center/admission-materializer.js +114 -0
- package/dist/event-center/bus-gate.js +136 -0
- package/dist/event-center/bus-host.js +290 -0
- package/dist/event-center/bus-resolver.js +120 -0
- package/dist/event-center/center-config.js +100 -0
- package/dist/event-center/client-factory.js +50 -0
- package/dist/event-center/daemon.js +45 -0
- package/dist/event-center/directory-source.js +53 -0
- package/dist/event-center/dispatcher.js +157 -0
- package/dist/event-center/event-log.js +110 -0
- package/dist/event-center/index-generator.js +63 -0
- package/dist/event-center/ipc-operation.js +308 -0
- package/dist/event-center/ledger.js +52 -0
- package/dist/event-center/pack-loader.js +202 -0
- package/dist/event-center/pack-manager.js +85 -0
- package/dist/event-center/registry.js +238 -0
- package/dist/event-center/runtime.js +641 -0
- package/dist/event-center/script-runner.js +356 -0
- package/dist/event-center/types.js +35 -0
- package/dist/event-center/validation.js +413 -0
- package/dist/index.js +285 -99
- package/dist/ipc.js +66 -12
- package/dist/paths.js +20 -0
- package/dist/product.js +14 -0
- package/dist/proxy/manager.js +5 -1
- package/dist/proxy/service-supervisor.js +13 -4
- package/dist/response-system/engines/v1/index.js +0 -1
- package/dist/response-system/modes/single-session/index.js +1 -1
- package/dist/services/dispatcher.js +100 -0
- package/dist/services/idempotency.js +90 -0
- package/dist/services/identity.js +52 -0
- package/dist/services/index-generator.js +70 -0
- package/dist/services/index.js +449 -0
- package/dist/services/ipc-operation.js +458 -0
- package/dist/services/ledger.js +52 -0
- package/dist/services/message-log.js +112 -0
- package/dist/services/pack-manager.js +204 -0
- package/dist/services/reply.js +55 -0
- package/dist/services/router.js +95 -0
- package/dist/services/script-runner.js +422 -0
- package/dist/services/service-payload.js +70 -0
- package/dist/services/types.js +18 -0
- package/dist/services/validation.js +297 -0
- package/dist/trigger/application-service.js +18 -0
- package/dist/trigger/event-source.js +1 -1
- package/dist/trigger/ipc-service.js +3 -1
- package/dist/trigger/script-sandbox.js +118 -22
- package/dist/utils/cross-platform.js +24 -10
- package/dist/utils/evolcore-version.js +69 -27
- package/dist/utils/instance-registry.js +19 -13
- package/dist/utils/process-introspect.js +45 -9
- package/dist/utils/startup-trace.js +74 -37
- package/dist/utils/windows-shell-trust.js +80 -6
- package/kits/docs/INDEX.md +2 -2
- package/kits/docs/aun/ABILITY_CALLING.md +7 -14
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +2 -0
- package/kits/docs/evolcore/ability.md +4 -0
- package/kits/docs/evolcore/aid.md +1 -1
- package/kits/docs/evolcore/event-center.md +207 -0
- package/kits/docs/evolcore/file-navigation.md +10 -264
- package/kits/docs/evolcore/fs.md +3 -2
- package/kits/docs/evolcore/group.md +1 -1
- package/kits/docs/evolcore/memory-architecture.md +2 -0
- package/kits/docs/evolcore/menu-protocol.md +21 -0
- package/kits/docs/evolcore/msg.md +15 -3
- package/kits/docs/evolcore/provider.md +3 -1
- package/kits/docs/evolcore/response.md +5 -5
- package/kits/docs/evolcore/services.md +277 -0
- package/kits/docs/evolcore/task.md +2 -0
- package/kits/docs/evolcore/team-workspace.md +41 -0
- package/kits/eck_manifest.json +26 -0
- package/kits/rules/02-navigation.md +10 -1
- package/kits/schemas/_meta.json +17 -6
- package/kits/schemas/agent-config.schema.19.json +5 -7
- package/kits/schemas/agent-config.schema.20.json +936 -0
- package/kits/schemas/relation-config.schema.12.json +2 -3
- package/kits/schemas/role-config.schema.2.json +4 -4
- package/kits/skills/.switches.json +1 -5
- package/kits/skills/ability/SKILL.md +56 -0
- package/kits/skills/ability/references/calling.md +56 -0
- package/kits/skills/{ec-ability → ability}/references/contract-checklist.md +1 -1
- package/kits/skills/{ec-ability → ability}/references/development.md +9 -33
- package/kits/skills/{ec-ability → ability}/references/management.md +2 -2
- package/kits/skills/{ec-ability → ability}/references/recovery.md +1 -1
- package/kits/skills/{ec-ability → ability}/references/runtime-protocol.md +2 -0
- package/kits/skills/ec-agent-create/SKILL.md +0 -1
- package/kits/skills/ec-service-proxy/SKILL.md +34 -5
- package/kits/skills/personal-assistant/SKILL.md +6 -6
- package/kits/skills/personal-assistant/references/02-bootstrap.md +4 -4
- package/kits/skills/personal-assistant/scripts/clean.mjs +4 -4
- package/kits/skills/personal-assistant/scripts/init.mjs +2 -2
- package/kits/skills/personal-assistant/scripts/pa.mjs +4 -4
- package/kits/templates/system-fragments/channel.md +3 -3
- package/kits/templates/system-fragments/commands.md +5 -3
- package/kits/templates/system-fragments/reply.md +0 -5
- package/kits/templates/system-fragments/thread.md +10 -8
- package/package.json +3 -5
- package/dist/cli/pa-workspace-command.js +0 -225
- package/dist/core/command/pa-workspace-store.js +0 -468
- package/dist/core/relation/pa-team.js +0 -132
- package/kits/docs/evolcore/pa-workspace.md +0 -51
- package/kits/skills/aid-ability/SKILL.md +0 -244
- package/kits/skills/ec-ability/SKILL.md +0 -67
- package/kits/skills/ec-ability/references/workflows.md +0 -15
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { randomUUID } from 'node:crypto';
|
|
2
1
|
import { logger } from '../../utils/logger.js';
|
|
3
2
|
import { summarizeToolInput, summarizeToolInputForDisplay, toolInputForDisplay } from '../../utils/tool-summary.js';
|
|
4
3
|
import { getErrorMessage, getToolResultErrorText, isContextTooLongText } from '../../utils/error-utils.js';
|
|
@@ -38,8 +37,7 @@ export class IMRenderer {
|
|
|
38
37
|
/** 串行发送队列:保证消息按序到达 */
|
|
39
38
|
sendChain = Promise.resolve();
|
|
40
39
|
activityRecordChain = Promise.resolve();
|
|
41
|
-
|
|
42
|
-
/** proactive:是否已发过 text 文本(用于去重 complete.result) */
|
|
40
|
+
/** 是否已投影 text 文本(用于去重 complete.result)。 */
|
|
43
41
|
hasEmittedText = false;
|
|
44
42
|
/** 自增 callId 兜底(runner 没提供时用) */
|
|
45
43
|
syntheticCallSeq = 0;
|
|
@@ -79,6 +77,9 @@ export class IMRenderer {
|
|
|
79
77
|
return true;
|
|
80
78
|
return this.opts.suppressIntermediateText ?? this.opts.suppressActivities ?? false;
|
|
81
79
|
}
|
|
80
|
+
usesProactiveBehavior() {
|
|
81
|
+
return this.opts.envelope.chatmode === 'proactive';
|
|
82
|
+
}
|
|
82
83
|
// ── 公开接口 ──
|
|
83
84
|
/** 推入 AgentEvent,按 chatmode 投影 */
|
|
84
85
|
emit(event, suppressTextProjection = false) {
|
|
@@ -106,7 +107,7 @@ export class IMRenderer {
|
|
|
106
107
|
catch {
|
|
107
108
|
// logger.event 失败不影响业务
|
|
108
109
|
}
|
|
109
|
-
if (this.
|
|
110
|
+
if (this.usesProactiveBehavior() && !suppressTextProjection) {
|
|
110
111
|
this.emitProactive(event);
|
|
111
112
|
}
|
|
112
113
|
// interactive 模式由 MessageProcessor 显式调 addText/addToolCall/... 推入 items
|
|
@@ -114,7 +115,7 @@ export class IMRenderer {
|
|
|
114
115
|
/** 强制刷新所有 pending 事件 */
|
|
115
116
|
async flush(isFinal, attention) {
|
|
116
117
|
await this.activityRecordChain;
|
|
117
|
-
if (this.
|
|
118
|
+
if (this.usesProactiveBehavior()) {
|
|
118
119
|
if (isFinal) {
|
|
119
120
|
const pending = this.deferredProactiveText;
|
|
120
121
|
this.deferredProactiveText = [];
|
|
@@ -127,7 +128,7 @@ export class IMRenderer {
|
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
130
|
}
|
|
130
|
-
//
|
|
131
|
+
// Proactive behavior is fire-and-forget; only release any held tool results.
|
|
131
132
|
this.releaseHeldToolResults();
|
|
132
133
|
await this.activityRecordChain;
|
|
133
134
|
return;
|
|
@@ -136,17 +137,17 @@ export class IMRenderer {
|
|
|
136
137
|
}
|
|
137
138
|
/** 仅 flush activities,保留 textBuffer(用于中间 complete 事件) */
|
|
138
139
|
async flushActivitiesOnly() {
|
|
139
|
-
if (this.
|
|
140
|
+
if (this.usesProactiveBehavior())
|
|
140
141
|
return;
|
|
141
142
|
return this.flushActivitiesInternal();
|
|
142
143
|
}
|
|
143
144
|
/** 是否有 pending 内容 */
|
|
144
145
|
hasContent() {
|
|
145
|
-
return
|
|
146
|
+
return this.textBuffer.length > 0 || this.deferredProactiveText.length > 0 || this.itemsQueue.some(it => it.kind !== 'text') || this.hasHeldToolResults();
|
|
146
147
|
}
|
|
147
148
|
/** 是否有会抑制兜底错误消息的正文/过程内容;lifecycle 边界不算。 */
|
|
148
149
|
hasNonLifecycleContent() {
|
|
149
|
-
return
|
|
150
|
+
return this.textBuffer.trim().length > 0 || this.hasHeldToolResults() || this.itemsQueue.some(it => {
|
|
150
151
|
if (it.kind === 'text')
|
|
151
152
|
return it.text.trim().length > 0;
|
|
152
153
|
if (this.subtaskItems.has(it))
|
|
@@ -162,14 +163,12 @@ export class IMRenderer {
|
|
|
162
163
|
}
|
|
163
164
|
/** 是否有待发送的文本 */
|
|
164
165
|
hasTextPending() {
|
|
165
|
-
return
|
|
166
|
+
return this.textBuffer.length > 0;
|
|
166
167
|
}
|
|
167
168
|
/** flush 当前 textBuffer 作为独立的 result.text(非 final),然后清空 buffer */
|
|
168
169
|
async flushText() {
|
|
169
|
-
if (this.
|
|
170
|
+
if (this.usesProactiveBehavior())
|
|
170
171
|
return;
|
|
171
|
-
if (this.pendingAutomaticText)
|
|
172
|
-
await this.retryAutomaticText();
|
|
173
172
|
if (this.textBuffer.length === 0)
|
|
174
173
|
return;
|
|
175
174
|
// 文件标记过滤后若只剩空白,应立即消费;尤其避免 final-only
|
|
@@ -208,12 +207,10 @@ export class IMRenderer {
|
|
|
208
207
|
};
|
|
209
208
|
this.sentContent = true;
|
|
210
209
|
try {
|
|
211
|
-
await this.
|
|
210
|
+
await this.sendPayload(payload);
|
|
212
211
|
}
|
|
213
212
|
catch (error) {
|
|
214
|
-
|
|
215
|
-
if (this.opts.envelope.chatmode !== 'paactive')
|
|
216
|
-
this.textBuffer = rawText + this.textBuffer;
|
|
213
|
+
this.textBuffer = rawText + this.textBuffer;
|
|
217
214
|
throw error;
|
|
218
215
|
}
|
|
219
216
|
this.lastFlush = Date.now();
|
|
@@ -237,7 +234,6 @@ export class IMRenderer {
|
|
|
237
234
|
this.textBuffer = '';
|
|
238
235
|
this.allText = '';
|
|
239
236
|
this.deferredProactiveText = [];
|
|
240
|
-
this.pendingAutomaticText = undefined;
|
|
241
237
|
}
|
|
242
238
|
/** 仅丢弃尚未发送的正文,保留 notice/tool 等活动项。 */
|
|
243
239
|
discardPendingText() {
|
|
@@ -248,16 +244,15 @@ export class IMRenderer {
|
|
|
248
244
|
this.itemsQueue = this.itemsQueue.filter(it => it.kind !== 'text');
|
|
249
245
|
this.textBuffer = '';
|
|
250
246
|
this.deferredProactiveText = [];
|
|
251
|
-
this.pendingAutomaticText = undefined;
|
|
252
247
|
}
|
|
253
248
|
/** 当前 buffer 中尚未 flush 的文本 */
|
|
254
249
|
getRemainingText() {
|
|
255
|
-
return
|
|
250
|
+
return this.textBuffer;
|
|
256
251
|
}
|
|
257
252
|
// ── 文本/活动注入(替代 StreamFlusher.addText/addActivity)──
|
|
258
253
|
/** 添加文本片段(流式 text) */
|
|
259
254
|
async addText(text, outputTokens, turn, assistantUuid, phase) {
|
|
260
|
-
if (this.
|
|
255
|
+
if (this.usesProactiveBehavior())
|
|
261
256
|
return;
|
|
262
257
|
const sameAssistant = this.currentAssistantUuid === assistantUuid;
|
|
263
258
|
// In deferred AUN private delivery, only explicit text_start/tool_use
|
|
@@ -295,7 +290,7 @@ export class IMRenderer {
|
|
|
295
290
|
addToolCall(name, input, callId, descText, turn, outputTokens, assistantUuid) {
|
|
296
291
|
if (callId && this.preflightDenialCallIds.has(callId))
|
|
297
292
|
return;
|
|
298
|
-
if (this.
|
|
293
|
+
if (this.usesProactiveBehavior())
|
|
299
294
|
return;
|
|
300
295
|
this.emitProgress('tool_call', outputTokens, turn, { toolName: name, callId });
|
|
301
296
|
const displayInput = toolInputForDisplay(name, input);
|
|
@@ -328,7 +323,7 @@ export class IMRenderer {
|
|
|
328
323
|
addToolResult(name, ok, result, error, callId, durationMs, descText, classification, assistantUuid) {
|
|
329
324
|
if (callId && this.preflightDenialCallIds.has(callId))
|
|
330
325
|
return;
|
|
331
|
-
if (this.
|
|
326
|
+
if (this.usesProactiveBehavior())
|
|
332
327
|
return;
|
|
333
328
|
const normalizedClassification = !ok
|
|
334
329
|
? normalizeToolErrorClassification(classification ?? {})
|
|
@@ -370,7 +365,7 @@ export class IMRenderer {
|
|
|
370
365
|
if (item.kind !== 'tool_result')
|
|
371
366
|
return;
|
|
372
367
|
this.toolResultCallIds.add(item.call_id);
|
|
373
|
-
if (this.
|
|
368
|
+
if (this.usesProactiveBehavior()) {
|
|
374
369
|
this.emitProactiveItem(item);
|
|
375
370
|
return;
|
|
376
371
|
}
|
|
@@ -495,7 +490,7 @@ export class IMRenderer {
|
|
|
495
490
|
}
|
|
496
491
|
/** 添加进度提示 */
|
|
497
492
|
addProgress(text, opts = {}) {
|
|
498
|
-
if (this.
|
|
493
|
+
if (this.usesProactiveBehavior())
|
|
499
494
|
return;
|
|
500
495
|
if (this.suppressActivityItems())
|
|
501
496
|
return;
|
|
@@ -558,7 +553,7 @@ export class IMRenderer {
|
|
|
558
553
|
...(text !== undefined && { text }),
|
|
559
554
|
...(metadata !== undefined && { metadata }),
|
|
560
555
|
};
|
|
561
|
-
if (this.
|
|
556
|
+
if (this.usesProactiveBehavior()) {
|
|
562
557
|
this.emitProactiveItem(item);
|
|
563
558
|
return;
|
|
564
559
|
}
|
|
@@ -578,7 +573,7 @@ export class IMRenderer {
|
|
|
578
573
|
*/
|
|
579
574
|
addSubtaskActivity(item) {
|
|
580
575
|
this.subtaskItems.add(item);
|
|
581
|
-
if (this.
|
|
576
|
+
if (this.usesProactiveBehavior()) {
|
|
582
577
|
this.emitProactiveItem(item);
|
|
583
578
|
return;
|
|
584
579
|
}
|
|
@@ -605,7 +600,7 @@ export class IMRenderer {
|
|
|
605
600
|
/** 添加系统提示 / 通知。force=true 仅跳过入队门禁;最终 flush 仍遵守 activity 抑制。 */
|
|
606
601
|
addNotice(text, severity, subtype, force = false) {
|
|
607
602
|
// proactive 模式:只放行真·终态错误,机务噪音(压缩/重试)和 emit 已覆盖的 subtype 均不发。
|
|
608
|
-
if (this.
|
|
603
|
+
if (this.usesProactiveBehavior()) {
|
|
609
604
|
if (subtype == null || !IMRenderer.PROACTIVE_NOTICE_ALLOW.has(subtype))
|
|
610
605
|
return;
|
|
611
606
|
this.emitProactiveItem({ kind: 'notice', text, severity, subtype });
|
|
@@ -621,7 +616,7 @@ export class IMRenderer {
|
|
|
621
616
|
}
|
|
622
617
|
/** 通过系统通知发送运行状态,并保持与已有正文的发送顺序。 */
|
|
623
618
|
async sendOperationalNotice(text, subtype) {
|
|
624
|
-
if (!this.opts.operationalNoticesEnabled || this.
|
|
619
|
+
if (!this.opts.operationalNoticesEnabled || this.usesProactiveBehavior() || !text)
|
|
625
620
|
return false;
|
|
626
621
|
if (!this.hasSendableText(text, 'operational-notice'))
|
|
627
622
|
return false;
|
|
@@ -712,51 +707,6 @@ export class IMRenderer {
|
|
|
712
707
|
this.sendChain = handled.catch(() => { });
|
|
713
708
|
return handled;
|
|
714
709
|
}
|
|
715
|
-
/** Model output uses PA's automatic-text outlet.
|
|
716
|
-
* System notices, explicit sends, command receipts and interaction fallbacks bypass it.
|
|
717
|
-
*/
|
|
718
|
-
async sendAutomaticText(payload) {
|
|
719
|
-
if (this.opts.noopSentinel && isNoopText(payload.text, this.opts.noopSentinel))
|
|
720
|
-
return;
|
|
721
|
-
if (this.opts.envelope.chatmode !== 'paactive')
|
|
722
|
-
return this.sendPayload(payload);
|
|
723
|
-
try {
|
|
724
|
-
// Another flush may have started while this one awaited a tool batch.
|
|
725
|
-
// Never replace its in-flight or failed text item with this payload.
|
|
726
|
-
while (this.pendingAutomaticText)
|
|
727
|
-
await this.retryAutomaticText();
|
|
728
|
-
}
|
|
729
|
-
catch (error) {
|
|
730
|
-
// This payload has not been recorded yet; preserve it behind the older
|
|
731
|
-
// pending item so a later flush can retry both without loss or overlap.
|
|
732
|
-
this.textBuffer = payload.text + this.textBuffer;
|
|
733
|
-
throw error;
|
|
734
|
-
}
|
|
735
|
-
const item = {
|
|
736
|
-
kind: 'text',
|
|
737
|
-
text: payload.text,
|
|
738
|
-
...(payload.metadata?.forkAnchor ? { forkAnchor: payload.metadata.forkAnchor } : {}),
|
|
739
|
-
};
|
|
740
|
-
this.recordActivity(item, `activity-${randomUUID().replace(/-/g, '')}`);
|
|
741
|
-
this.pendingAutomaticText = { item };
|
|
742
|
-
await this.retryAutomaticText();
|
|
743
|
-
}
|
|
744
|
-
/** Keep a failed, already-recorded text item separate from newly buffered text. */
|
|
745
|
-
retryAutomaticText() {
|
|
746
|
-
const pending = this.pendingAutomaticText;
|
|
747
|
-
if (!pending)
|
|
748
|
-
return Promise.resolve();
|
|
749
|
-
if (!pending.delivery) {
|
|
750
|
-
pending.delivery = this.sendPayload({ kind: 'activity.batch', items: [pending.item] }).then(() => {
|
|
751
|
-
if (this.pendingAutomaticText === pending)
|
|
752
|
-
this.pendingAutomaticText = undefined;
|
|
753
|
-
}, error => {
|
|
754
|
-
pending.delivery = undefined;
|
|
755
|
-
throw error;
|
|
756
|
-
});
|
|
757
|
-
}
|
|
758
|
-
return pending.delivery;
|
|
759
|
-
}
|
|
760
710
|
scheduleFlush() {
|
|
761
711
|
if (this.timer) {
|
|
762
712
|
return;
|
|
@@ -802,8 +752,6 @@ export class IMRenderer {
|
|
|
802
752
|
const nonThinking = this.itemsQueue.filter(it => it.kind !== 'text');
|
|
803
753
|
if (nonThinking.length === 0)
|
|
804
754
|
return;
|
|
805
|
-
if (this.pendingAutomaticText)
|
|
806
|
-
await this.retryAutomaticText();
|
|
807
755
|
if (this.timer) {
|
|
808
756
|
clearTimeout(this.timer);
|
|
809
757
|
this.timer = undefined;
|
|
@@ -838,8 +786,6 @@ export class IMRenderer {
|
|
|
838
786
|
clearTimeout(this.timer);
|
|
839
787
|
this.timer = undefined;
|
|
840
788
|
}
|
|
841
|
-
if (this.pendingAutomaticText)
|
|
842
|
-
await this.retryAutomaticText();
|
|
843
789
|
// 显式 flush(轮次结束、出错收尾)时放出被扣住的后台占位结果;定时 flush 不放,
|
|
844
790
|
// 否则长时间后台任务会在终态到达前就把占位结果发出去。放出的结果随本次 flush 一起发,
|
|
845
791
|
// 不需要它重新挂上的定时器。
|
|
@@ -925,11 +871,10 @@ export class IMRenderer {
|
|
|
925
871
|
};
|
|
926
872
|
this.sentContent = true;
|
|
927
873
|
try {
|
|
928
|
-
await this.
|
|
874
|
+
await this.sendPayload(payload);
|
|
929
875
|
}
|
|
930
876
|
catch (error) {
|
|
931
|
-
|
|
932
|
-
this.textBuffer = text + this.textBuffer;
|
|
877
|
+
this.textBuffer = text + this.textBuffer;
|
|
933
878
|
throw error;
|
|
934
879
|
}
|
|
935
880
|
this.lastFlush = Date.now();
|
|
@@ -947,11 +892,10 @@ export class IMRenderer {
|
|
|
947
892
|
payload.attention = attention;
|
|
948
893
|
this.sentContent = true;
|
|
949
894
|
try {
|
|
950
|
-
await this.
|
|
895
|
+
await this.sendPayload(payload);
|
|
951
896
|
}
|
|
952
897
|
catch (error) {
|
|
953
|
-
|
|
954
|
-
this.textBuffer = finalText + this.textBuffer;
|
|
898
|
+
this.textBuffer = finalText + this.textBuffer;
|
|
955
899
|
throw error;
|
|
956
900
|
}
|
|
957
901
|
this.lastFlush = Date.now();
|
|
@@ -2059,6 +2059,10 @@ export class MessageBridge {
|
|
|
2059
2059
|
}
|
|
2060
2060
|
return menuSuccess(header, this.cmdHandler.getMenuItems(identity.role, msg.chatType || 'private', msg.isControlChannel ? 'control' : 'agent', authSubject));
|
|
2061
2061
|
case 'menu.query': {
|
|
2062
|
+
if (name === 'menu' && args?.view === 'queries') {
|
|
2063
|
+
const data = await this.cmdHandler.execMenuQueryBatch(channel, msg.channelId, authSubject, args, msg.isControlChannel ? 'control' : 'agent', transportReplyContext);
|
|
2064
|
+
return menuSuccess(header, data);
|
|
2065
|
+
}
|
|
2062
2066
|
if (name === 'menu' && args?.view === 'values') {
|
|
2063
2067
|
validateMenuValueBatchArgs(args);
|
|
2064
2068
|
const data = await this.cmdHandler.execMenuValueBatch(channel, msg.channelId, authSubject, args, args.context, msg.isControlChannel ? 'control' : 'agent', transportReplyContext);
|
|
@@ -33,6 +33,7 @@ export function buildEnvelope(opts) {
|
|
|
33
33
|
channelId: opts.channelId,
|
|
34
34
|
agentName: opts.agentName ?? '<unknown>',
|
|
35
35
|
chatmode: opts.chatmode ?? 'interactive',
|
|
36
|
+
...(opts.activityTransport ? { activityTransport: opts.activityTransport } : {}),
|
|
36
37
|
delivery,
|
|
37
38
|
replyContext,
|
|
38
39
|
causation: opts.causation,
|
|
@@ -64,8 +65,15 @@ export function isDeliveryTarget(value) {
|
|
|
64
65
|
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
65
66
|
return false;
|
|
66
67
|
const route = value;
|
|
67
|
-
if (route.chatType === 'private')
|
|
68
|
-
|
|
68
|
+
if (route.chatType === 'private') {
|
|
69
|
+
if (route.service === undefined)
|
|
70
|
+
return true;
|
|
71
|
+
const service = route.service;
|
|
72
|
+
// fail-closed:形状不对就判为非法路由,让调用方拿到 AUN_OUTBOUND_ROUTE_REQUIRED,
|
|
73
|
+
// 而不是悄悄走上服务豁免分支绕过联系人准入。
|
|
74
|
+
return !!service && typeof service === 'object' && !Array.isArray(service)
|
|
75
|
+
&& typeof service.type === 'string' && typeof service.requestId === 'string';
|
|
76
|
+
}
|
|
69
77
|
return route.chatType === 'group'
|
|
70
78
|
&& typeof route.groupId === 'string'
|
|
71
79
|
&& route.groupId.trim().length > 0;
|
|
@@ -2,59 +2,33 @@ import { loadSchema } from '../../config/schema-registry.js';
|
|
|
2
2
|
import { resolveEffective } from '../../config/config-manager.js';
|
|
3
3
|
import { resolveRuntimeStringField } from '../role/runtime-policy.js';
|
|
4
4
|
import { isManagementRole } from '../../config/builtin-roles.js';
|
|
5
|
-
|
|
6
|
-
export const CHAT_MODES = ['interactive', 'proactive', 'paactive'];
|
|
5
|
+
export const CHAT_MODES = ['interactive', 'proactive'];
|
|
7
6
|
export function isChatMode(value) {
|
|
8
7
|
return CHAT_MODES.includes(value);
|
|
9
8
|
}
|
|
10
|
-
/**
|
|
11
|
-
export function supportsPaactive(params) {
|
|
12
|
-
const channelType = params.channelType ?? params.peerKey?.split('#')[0];
|
|
13
|
-
return channelType === 'aun'
|
|
14
|
-
&& params.chatType === 'private'
|
|
15
|
-
&& normalizePeerType(params.peerType) === 'human'
|
|
16
|
-
&& params.role === 'owner'
|
|
17
|
-
&& (params.lifecycle === undefined || params.lifecycle === 'active')
|
|
18
|
-
&& (params.sessionType === undefined || params.sessionType === 'main');
|
|
19
|
-
}
|
|
20
|
-
/** Keep unsupported inherited PA settings from becoming output-as-reply mode. */
|
|
9
|
+
/** Apply scene constraints to the configured chat mode. */
|
|
21
10
|
export function chatModeForScene(value, params) {
|
|
22
11
|
if (params.chatType === 'group' || normalizePeerType(params.peerType) === 'group')
|
|
23
12
|
return 'proactive';
|
|
24
|
-
if (value === 'paactive' && supportsPaactive(params))
|
|
25
|
-
return value;
|
|
26
13
|
if (value === 'interactive' || value === 'proactive')
|
|
27
14
|
return value;
|
|
28
|
-
|
|
29
|
-
const kind = normalizePeerType(params.peerType);
|
|
30
|
-
if (kind === 'system' || kind === 'service')
|
|
31
|
-
return 'interactive';
|
|
32
|
-
if (kind === 'agent'
|
|
33
|
-
|| isPrivateChatmodeRoleLocked(chatmodeFieldForPeer(params.chatType, params.peerType), params.role))
|
|
34
|
-
return 'proactive';
|
|
35
|
-
}
|
|
36
|
-
const fallback = chatmodeFactoryDefaults()[chatmodeFieldForPeer(params.chatType, params.peerType)];
|
|
37
|
-
return fallback === 'paactive' ? 'interactive' : fallback;
|
|
15
|
+
return chatmodeFactoryDefaults()[chatmodeFieldForPeer(params.chatType, params.peerType)];
|
|
38
16
|
}
|
|
39
17
|
/** Resolve the effective chat mode from the ConfigManager layering context. */
|
|
40
18
|
export function resolveChatMode(params) {
|
|
41
19
|
let configured;
|
|
42
|
-
let lifecycle = params.lifecycle;
|
|
43
20
|
try {
|
|
44
21
|
const effective = resolveEffective({
|
|
45
22
|
self: params.self,
|
|
46
23
|
peerKey: params.peerKey,
|
|
47
24
|
}, { cache: true });
|
|
48
25
|
configured = effective.chatmode;
|
|
49
|
-
if (lifecycle === undefined)
|
|
50
|
-
lifecycle = resolveAgentLifecycle(effective);
|
|
51
26
|
}
|
|
52
27
|
catch {
|
|
53
28
|
configured = undefined;
|
|
54
29
|
}
|
|
55
30
|
const kind = normalizePeerType(params.peerType);
|
|
56
|
-
// Group conversations always use proactive delivery
|
|
57
|
-
// paactive are private-chat presentation modes.
|
|
31
|
+
// Group conversations always use proactive delivery.
|
|
58
32
|
if (params.chatType === 'group' || kind === 'group')
|
|
59
33
|
return 'proactive';
|
|
60
34
|
// 运行时硬约束(非配置项):system/service 始终 interactive;agent 始终 proactive
|
|
@@ -63,8 +37,7 @@ export function resolveChatMode(params) {
|
|
|
63
37
|
if (kind === 'agent')
|
|
64
38
|
return 'proactive';
|
|
65
39
|
const field = chatmodeFieldForPeer(params.chatType, params.peerType);
|
|
66
|
-
// 人类私聊的基础角色门槛:owner/admin
|
|
67
|
-
// paactive 另由 supportsPaactive 限定为 owner,其余角色直接 proactive。
|
|
40
|
+
// 人类私聊的基础角色门槛:owner/admin 才解析分层配置,其余角色直接 proactive。
|
|
68
41
|
if (isPrivateChatmodeRoleLocked(field, params.role))
|
|
69
42
|
return 'proactive';
|
|
70
43
|
const decision = resolveRuntimeStringField({
|
|
@@ -74,11 +47,11 @@ export function resolveChatMode(params) {
|
|
|
74
47
|
configuredValue: configured?.[field],
|
|
75
48
|
});
|
|
76
49
|
const effectiveValue = decision.effectiveValue;
|
|
77
|
-
return chatModeForScene(effectiveValue,
|
|
50
|
+
return chatModeForScene(effectiveValue, params);
|
|
78
51
|
}
|
|
79
52
|
/**
|
|
80
53
|
* 人类私聊(chatmode.private)是否被角色锁定为 proactive。
|
|
81
|
-
* interactive 需要 owner/admin
|
|
54
|
+
* interactive 需要 owner/admin。
|
|
82
55
|
*/
|
|
83
56
|
export function isPrivateChatmodeRoleLocked(field, role) {
|
|
84
57
|
return field === 'private' && !isManagementRole(role);
|