evolcore 0.0.43-test.2 → 0.0.43-test.3
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 +8 -1
- package/dist/agents/ecagent-runner.js +13 -6
- package/dist/aun/aid/agentmd.js +21 -1
- package/dist/aun/msg/p2p.js +4 -2
- package/dist/channels/aun.js +79 -48
- package/dist/channels/daemon.js +4 -0
- package/dist/cli/agent-create.js +3 -5
- package/dist/cli/aun-commands.js +17 -19
- package/dist/cli/directory.js +101 -56
- package/dist/cli/index.js +1 -1
- package/dist/cli/peer.js +2 -1
- package/dist/cli/task-context.js +3 -1
- package/dist/config/access-policy.js +0 -1
- package/dist/config/builtin-role-templates.js +2 -2
- package/dist/config/builtin-roles.js +2 -1
- package/dist/config/config-field-policy.js +5 -0
- package/dist/config/config-manager.js +25 -10
- package/dist/config/peer-role-resolver.js +23 -1
- package/dist/config/role-schema.js +26 -2
- package/dist/config/role-service.js +9 -4
- package/dist/config/role-store.js +30 -8
- package/dist/core/auth/auth-gateway.js +14 -4
- package/dist/core/auth/operation-authorizer.js +17 -0
- package/dist/core/auth/operation-catalog.js +12 -2
- package/dist/core/channel-runtime.js +5 -0
- package/dist/core/command/agent-control.js +1 -1
- package/dist/core/command/agentmd-menu-request.js +50 -0
- package/dist/core/command/agentmd-menu.js +156 -0
- package/dist/core/command/command-handler.js +39 -3
- package/dist/core/command/menu-catalog.js +13 -0
- package/dist/core/command/menu-handler.js +59 -9
- package/dist/core/command/menu-protocol.js +8 -0
- package/dist/core/command/role-menu.js +23 -9
- package/dist/core/command/slash-handler.js +48 -21
- package/dist/core/daemon-lifecycle.js +9 -1
- package/dist/core/evolagent.js +5 -4
- package/dist/core/lifecycle-notice.js +185 -0
- package/dist/core/message/aun-ipc-sender.js +30 -24
- package/dist/core/message/contact-admission.js +1 -19
- package/dist/core/message/im-renderer.js +64 -28
- package/dist/core/message/message-admission.js +15 -65
- package/dist/core/message/message-bridge.js +18 -5
- package/dist/core/message/message-utils.js +9 -0
- package/dist/core/message/peer-mode.js +16 -8
- package/dist/core/message/response-engine.js +56 -35
- package/dist/core/ownership/owner-resolver.js +72 -34
- package/dist/core/permission/ec-command-parser.js +24 -10
- package/dist/core/relation/pa-team.js +127 -0
- package/dist/core/role/runtime-policy.js +4 -3
- package/dist/core/thread/thread-service.js +6 -4
- package/dist/directory/owner-directory-admission.js +0 -3
- package/dist/directory/owner-directory-cache.js +197 -15
- package/dist/directory/owner-directory-markdown.js +44 -21
- package/dist/directory/owner-directory-policy.js +1 -1
- package/dist/directory/owner-directory-query-operation.js +219 -97
- package/dist/directory/owner-directory-request-operation.js +76 -0
- package/dist/directory/owner-directory-scope.js +35 -4
- package/dist/directory/owner-directory-search.js +76 -23
- package/dist/directory/owner-directory-store.js +5 -38
- package/dist/directory/owner-directory-text.js +60 -0
- package/dist/eck/kit-renderer.js +6 -3
- package/dist/eck/message-renderer.js +2 -5
- package/dist/ecweb/message-context-service.js +4 -0
- package/dist/index.js +11 -0
- package/dist/paths.js +4 -2
- package/dist/product.js +1 -0
- package/dist/response-system/engines/v1/index.js +2 -4
- package/dist/response-system/modes/single-session/index.js +1 -1
- package/dist/trigger/scheduler.js +8 -3
- package/dist/utils/error-utils.js +7 -5
- package/ecagent/README.md +18 -0
- package/ecagent/dist/harness/agent-harness.d.ts +2 -0
- package/ecagent/dist/harness/agent-harness.js +24 -8
- package/ecagent/dist/harness/compaction/compaction.js +3 -0
- package/ecagent/dist/harness/types.d.ts +1 -0
- package/kits/docs/channels/aun.md +1 -1
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +4 -1
- package/kits/docs/evolcore/directory.md +125 -35
- package/kits/docs/evolcore/ecweb-lifecycle.md +26 -0
- package/kits/docs/evolcore/file-navigation.md +265 -0
- package/kits/docs/evolcore/msg.md +1 -0
- package/kits/docs/evolcore/peer.md +2 -1
- package/kits/docs/evolcore/response.md +2 -2
- package/kits/docs/evolcore/task.md +2 -0
- package/kits/docs/evolcore/tool-authorization.md +1 -1
- package/kits/docs/identity/ROLE_DETAIL.md +2 -0
- package/kits/eck_manifest.json +7 -3
- package/kits/eck_manifest.memory.json +26 -1
- package/kits/schemas/_meta.json +16 -3
- package/kits/schemas/agent-config.schema.20.json +925 -0
- package/kits/schemas/relation-config.schema.13.json +289 -0
- package/kits/schemas/role-config.schema.3.json +1038 -0
- package/kits/schemas/role-registry.schema.1.json +3 -2
- package/kits/templates/soul/00-GUIDE.md +20 -42
- package/kits/templates/system-fragments/channel.md +2 -2
- package/kits/templates/system-fragments/commands.md +1 -1
- package/kits/templates/system-fragments/directory-contacts.md +1 -1
- package/kits/templates/system-fragments/personal-assistant.md +2 -17
- package/kits/templates/system-fragments/reply.md +7 -0
- package/kits/templates/system-fragments/session.md +6 -2
- package/package.json +2 -2
- package/dist/eck/paactive-context.js +0 -45
- package/dist/response-system/engines/v1/paactive-flow.js +0 -18
- package/kits/eck_manifest.paactive.json +0 -528
- package/kits/eck_message_manifest.paactive.json +0 -233
- package/kits/templates/message-fragments/paactive/item.md +0 -3
- package/kits/templates/system-fragments/paactive/channel.md +0 -25
- package/kits/templates/system-fragments/paactive/reply.md +0 -25
- package/kits/templates/system-fragments/paactive/session.md +0 -32
|
@@ -5,6 +5,8 @@ import { createHash, randomBytes } from 'crypto';
|
|
|
5
5
|
import fs from 'fs';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import { agentStorageMenuService, isAgentStorageMenuRequest } from '../command/agent-storage-menu.js';
|
|
8
|
+
import { agentMdMenuService } from '../command/agentmd-menu.js';
|
|
9
|
+
import { containsAgentMdMenuRequest } from '../command/agentmd-menu-request.js';
|
|
8
10
|
import { logger, logPreview } from '../../utils/logger.js';
|
|
9
11
|
import { StreamDebouncer } from './stream-debouncer.js';
|
|
10
12
|
import { appendMessageLog, appendMessageLogStrict, buildInboundEntry, isTransientProtocolMessage } from './message-log.js';
|
|
@@ -17,6 +19,7 @@ import { listStaticAgentAdmins, listStaticAgentOwners, resolvePeerRoleDetail, }
|
|
|
17
19
|
import { resolvePeerView, resolvePeerDisplayLabel, resolvePrincipal } from '../../config/peer-book.js';
|
|
18
20
|
import { findPeerRequestNote, expirePendingPeerRequests, reviewPeerRequest, submitPeerRequest, peerRequestSubmissionProtocolResult, queryOwnPeerRequestStatus, } from '../../config/peer-request-service.js';
|
|
19
21
|
import { isValidAid } from '../../aun/aid/validation.js';
|
|
22
|
+
import { prepareOwnerDirectoryAdmission } from '../../directory/owner-directory-admission.js';
|
|
20
23
|
import { PeerIdentityCache, formatPeerKey } from '../relation/peer-identity.js';
|
|
21
24
|
import { ownerResolver, refreshOwnershipForAuthorization, OWNERSHIP_CACHE_MAX_AGE_MS } from '../ownership/owner-resolver.js';
|
|
22
25
|
import { isTopicSession, sessionLocalTopicId } from '../thread/topic-id.js';
|
|
@@ -39,7 +42,6 @@ import { createAgentPolicyAuthorization, createSessionFullAccessAuthorization }
|
|
|
39
42
|
import { auditFullAccessEvent } from '../auth/authorization-audit.js';
|
|
40
43
|
import { DIAGNOSTIC_AGENT_AID, DiagnosticSessionRouter, parseDiagnosticEvent, isDiagnosticSessionActive } from '../command/diag-service.js';
|
|
41
44
|
import { consumeAdmissionReplyBudget, clearAdmissionReplyBudgets, evaluateInboundAdmissionPreflight, evaluateOrdinaryInboundAdmission, evaluateOwnerDirectoryInboundAdmission, } from './message-admission.js';
|
|
42
|
-
import { prepareOwnerDirectoryAdmission } from '../../directory/owner-directory-admission.js';
|
|
43
45
|
const CONTACT_REJECTION_NOTICE = '[rejection] Not accepting messages from you.';
|
|
44
46
|
const REJECTABLE_PEER_TYPES = new Set(['ai', 'bot', 'agent', 'service']);
|
|
45
47
|
const REJECTION_MAX = 3;
|
|
@@ -481,7 +483,7 @@ export class MessageBridge {
|
|
|
481
483
|
catch { /* slash command */ }
|
|
482
484
|
if (!requestMatch && !protocolType)
|
|
483
485
|
return false;
|
|
484
|
-
if (context.channelType === 'aun'
|
|
486
|
+
if (context.channelType === 'aun') {
|
|
485
487
|
// The App owns requests; retired commands cannot create a second approval state.
|
|
486
488
|
return true;
|
|
487
489
|
}
|
|
@@ -925,7 +927,8 @@ export class MessageBridge {
|
|
|
925
927
|
actorId,
|
|
926
928
|
trustedHandoffEcho,
|
|
927
929
|
});
|
|
928
|
-
if (admissionPreflight.allow &&
|
|
930
|
+
if (admissionPreflight.allow && resolvedChannelType !== 'aun'
|
|
931
|
+
&& !trustedHandoffEcho && !admissionPreflight.context.isOwner) {
|
|
929
932
|
if (selfAid && admissionPreflight.context.primaryId) {
|
|
930
933
|
await prepareOwnerDirectoryAdmission(selfAid, admissionPreflight.context.primaryId);
|
|
931
934
|
}
|
|
@@ -1011,7 +1014,7 @@ export class MessageBridge {
|
|
|
1011
1014
|
const admissionDecision = evaluateOrdinaryInboundAdmission(admissionPreflight.context);
|
|
1012
1015
|
// 名录不可用等硬性拒绝不回自动提示,静默丢弃;其余拒绝才发控制面提示。
|
|
1013
1016
|
const directoryDenied = !admissionDecision.allow && (admissionDecision.reason === 'owner_directory_unavailable');
|
|
1014
|
-
const appControl = resolvedChannelType === 'aun' &&
|
|
1017
|
+
const appControl = resolvedChannelType === 'aun' && menuControl.isMenu;
|
|
1015
1018
|
if (!appControl && !admissionDecision.allow && (!isPrivateMenuTokenRequest || directoryDenied)) {
|
|
1016
1019
|
if (chatType === 'private' && !directoryDenied) {
|
|
1017
1020
|
if (menuControl.isMenu) {
|
|
@@ -1869,6 +1872,7 @@ export class MessageBridge {
|
|
|
1869
1872
|
...authSubject,
|
|
1870
1873
|
requestId: parsed.id,
|
|
1871
1874
|
menuEncrypted: msg.encrypted === true,
|
|
1875
|
+
menuTransportChatType: msg.chatType || 'private',
|
|
1872
1876
|
fromControlChannel: authSubject.fromControlChannel || msg.isControlChannel === true,
|
|
1873
1877
|
...(activeSession?.id ? { sessionId: activeSession.id } : {}),
|
|
1874
1878
|
};
|
|
@@ -1928,6 +1932,15 @@ export class MessageBridge {
|
|
|
1928
1932
|
}));
|
|
1929
1933
|
return;
|
|
1930
1934
|
}
|
|
1935
|
+
if (deduped.replayed && containsAgentMdMenuRequest(parsed.request)) {
|
|
1936
|
+
try {
|
|
1937
|
+
await agentMdMenuService.preflight(menuAuthSubject);
|
|
1938
|
+
}
|
|
1939
|
+
catch (error) {
|
|
1940
|
+
await this.sendMenuResponse(adapter, channel, msg, menuFailure(header, normalizeMenuError(error)));
|
|
1941
|
+
return;
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1931
1944
|
// A replay may have awaited an in-flight request; check again before release.
|
|
1932
1945
|
if (isStorageRequest) {
|
|
1933
1946
|
try {
|
|
@@ -2151,7 +2164,7 @@ export class MessageBridge {
|
|
|
2151
2164
|
metadata: {
|
|
2152
2165
|
...(msg.replyContext?.metadata ?? {}),
|
|
2153
2166
|
...evolMenuResponseTransportMetadata(msg.protectedHeaders?.sdk_version, msg.protectedHeaders?.menu_volatile_v1),
|
|
2154
|
-
...(isAgentStorageMenuRequest(request) ? { encrypted: true } : {}),
|
|
2167
|
+
...(isAgentStorageMenuRequest(request) || containsAgentMdMenuRequest(request) ? { encrypted: true } : {}),
|
|
2155
2168
|
},
|
|
2156
2169
|
};
|
|
2157
2170
|
if (msg.channelType === 'aun' && !replyContext.delivery) {
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { sessionLocalTopicId, sessionTopicThreadId } from '../thread/topic-id.js';
|
|
2
2
|
import { renderCommandCardAsText, renderActionAsText } from '../interaction-router.js';
|
|
3
|
+
export const DEFAULT_NOOP_SENTINEL = '[[NOOP]]';
|
|
4
|
+
export function isNoopText(text, sentinel = DEFAULT_NOOP_SENTINEL) {
|
|
5
|
+
return sentinel.length > 0 && text.trimStart().startsWith(sentinel);
|
|
6
|
+
}
|
|
7
|
+
export function mayBeNoopText(text, sentinel = DEFAULT_NOOP_SENTINEL) {
|
|
8
|
+
const prefix = text.trimStart();
|
|
9
|
+
return sentinel.length > 0 && prefix.length > 0
|
|
10
|
+
&& (sentinel.startsWith(prefix) || prefix.startsWith(sentinel));
|
|
11
|
+
}
|
|
3
12
|
/** A legacy adapter resolved its send call without providing a structured receipt. */
|
|
4
13
|
export const LEGACY_INTERACTION_ACCEPTED = 'legacy-accepted';
|
|
5
14
|
export function isInteractionSendAccepted(result) {
|
|
@@ -7,18 +7,20 @@ export const CHAT_MODES = ['interactive', 'proactive', 'paactive'];
|
|
|
7
7
|
export function isChatMode(value) {
|
|
8
8
|
return CHAT_MODES.includes(value);
|
|
9
9
|
}
|
|
10
|
-
/** PA output is supported only in active AUN human
|
|
10
|
+
/** PA output is supported only in active AUN human Owner conversations. */
|
|
11
11
|
export function supportsPaactive(params) {
|
|
12
12
|
const channelType = params.channelType ?? params.peerKey?.split('#')[0];
|
|
13
13
|
return channelType === 'aun'
|
|
14
14
|
&& params.chatType === 'private'
|
|
15
15
|
&& normalizePeerType(params.peerType) === 'human'
|
|
16
|
-
&&
|
|
16
|
+
&& params.role === 'owner'
|
|
17
17
|
&& (params.lifecycle === undefined || params.lifecycle === 'active')
|
|
18
18
|
&& (params.sessionType === undefined || params.sessionType === 'main');
|
|
19
19
|
}
|
|
20
20
|
/** Keep unsupported inherited PA settings from becoming output-as-reply mode. */
|
|
21
21
|
export function chatModeForScene(value, params) {
|
|
22
|
+
if (params.chatType === 'group' || normalizePeerType(params.peerType) === 'group')
|
|
23
|
+
return 'proactive';
|
|
22
24
|
if (value === 'paactive' && supportsPaactive(params))
|
|
23
25
|
return value;
|
|
24
26
|
if (value === 'interactive' || value === 'proactive')
|
|
@@ -51,14 +53,18 @@ export function resolveChatMode(params) {
|
|
|
51
53
|
configured = undefined;
|
|
52
54
|
}
|
|
53
55
|
const kind = normalizePeerType(params.peerType);
|
|
56
|
+
// Group conversations always use proactive delivery; interactive and
|
|
57
|
+
// paactive are private-chat presentation modes.
|
|
58
|
+
if (params.chatType === 'group' || kind === 'group')
|
|
59
|
+
return 'proactive';
|
|
54
60
|
// 运行时硬约束(非配置项):system/service 始终 interactive;agent 始终 proactive
|
|
55
61
|
if (kind === 'system' || kind === 'service')
|
|
56
62
|
return 'interactive';
|
|
57
63
|
if (kind === 'agent')
|
|
58
64
|
return 'proactive';
|
|
59
65
|
const field = chatmodeFieldForPeer(params.chatType, params.peerType);
|
|
60
|
-
//
|
|
61
|
-
//
|
|
66
|
+
// 人类私聊的基础角色门槛:owner/admin 才解析分层配置;
|
|
67
|
+
// paactive 另由 supportsPaactive 限定为 owner,其余角色直接 proactive。
|
|
62
68
|
if (isPrivateChatmodeRoleLocked(field, params.role))
|
|
63
69
|
return 'proactive';
|
|
64
70
|
const decision = resolveRuntimeStringField({
|
|
@@ -72,7 +78,7 @@ export function resolveChatMode(params) {
|
|
|
72
78
|
}
|
|
73
79
|
/**
|
|
74
80
|
* 人类私聊(chatmode.private)是否被角色锁定为 proactive。
|
|
75
|
-
* owner/admin
|
|
81
|
+
* interactive 需要 owner/admin;paactive 在此基础上另由 supportsPaactive 限定为 owner。
|
|
76
82
|
*/
|
|
77
83
|
export function isPrivateChatmodeRoleLocked(field, role) {
|
|
78
84
|
return field === 'private' && !isManagementRole(role);
|
|
@@ -127,7 +133,7 @@ export function isSystemOrServicePeer(peerType) {
|
|
|
127
133
|
}
|
|
128
134
|
/**
|
|
129
135
|
* 解析某会话对端的 chatMode。优先级(高→低):
|
|
130
|
-
* 1.
|
|
136
|
+
* 1. 群聊固定 proactive;私聊 system/service 对端始终 interactive(非配置项)
|
|
131
137
|
* 2. 合并后的 chatmode 场景表 `configured`(chatmode.{private|group|nothuman})——
|
|
132
138
|
* 关系级与 agent 级同名字典,已由 ConfigManager 按 x-merge:dict 逐键合并
|
|
133
139
|
* 3. schema 出厂默认表 `chatmodeFactoryDefaults()`
|
|
@@ -137,6 +143,8 @@ export function isSystemOrServicePeer(peerType) {
|
|
|
137
143
|
*/
|
|
138
144
|
export function resolveChatModeForPeer(params) {
|
|
139
145
|
const kind = normalizePeerType(params.peerType);
|
|
146
|
+
if (params.chatType === 'group' || kind === 'group')
|
|
147
|
+
return 'proactive';
|
|
140
148
|
// 运行时硬约束(非配置项):system/service 对端始终同步交互;agent 对端始终主动响应
|
|
141
149
|
if (kind === 'system' || kind === 'service')
|
|
142
150
|
return 'interactive';
|
|
@@ -163,10 +171,10 @@ export function chatmodeFactoryDefaults() {
|
|
|
163
171
|
}
|
|
164
172
|
export function chatmodeFieldForPeer(chatType, peerType) {
|
|
165
173
|
const kind = normalizePeerType(peerType);
|
|
166
|
-
if (kind === 'system' || kind === 'service')
|
|
167
|
-
return 'private';
|
|
168
174
|
if (chatType === 'group' || kind === 'group')
|
|
169
175
|
return 'group';
|
|
176
|
+
if (kind === 'system' || kind === 'service')
|
|
177
|
+
return 'private';
|
|
170
178
|
if (kind === 'agent' || kind === 'unknown')
|
|
171
179
|
return 'nothuman';
|
|
172
180
|
return 'private';
|
|
@@ -10,6 +10,8 @@ import { loadedBaseagentIds } from '../../agents/baseagent-availability.js';
|
|
|
10
10
|
import { isDiagnosticSessionActive } from '../command/diag-service.js';
|
|
11
11
|
import { evaluateInboundAdmissionPreflight, evaluateOrdinaryInboundAdmission } from './message-admission.js';
|
|
12
12
|
import { authorizeAccess, authorizeOperation, buildAuthSubject } from '../auth/auth-gateway.js';
|
|
13
|
+
import { preparePaTeamQualification, paTeamQualification, requiresPaTeamVerification } from '../relation/pa-team.js';
|
|
14
|
+
import { getRoleDefinition } from '../../config/roles.js';
|
|
13
15
|
import { buildTaskRuntimeEnv, ensureRuntimeLockDir, ensureSessionRuntimeDir } from '../../cli/task-context.js';
|
|
14
16
|
import { BUILTIN_SESSION_PATH_GRANTS, mergeRuntimeGrantsForSession, resolveGrantedReadRoots, } from '../permission/session-path-grants.js';
|
|
15
17
|
import { buildSystemSessionContext, getSystemSessionModule, isSystemSessionType, readSystemSessionMarker } from '../system-session/registry.js';
|
|
@@ -40,9 +42,8 @@ import { recordCausationLink, recordCausationSpan } from '../causation/audit.js'
|
|
|
40
42
|
import { normalizeBaseagent, resolveBaseagentModelSelection, resolveRuntimeBaseagentModelSelection } from '../../agents/baseagent.js';
|
|
41
43
|
import { renderActionAsText } from '../interaction-router.js';
|
|
42
44
|
import { formatPeerKey, parsePeerKey } from '../relation/peer-identity.js';
|
|
43
|
-
import { buildEnvelope, isInteractionSendAccepted, replyContextFromSession, sendInteractionPayload, withEnvelopeReplyContext } from './message-utils.js';
|
|
45
|
+
import { buildEnvelope, isInteractionSendAccepted, isNoopText, replyContextFromSession, sendInteractionPayload, withEnvelopeReplyContext } from './message-utils.js';
|
|
44
46
|
import { chatModeForScene, isSystemOrServicePeer, resolveChatMode } from './peer-mode.js';
|
|
45
|
-
import { buildPaactiveSystemVars, buildPaactiveMessageVars, paactiveSystemManifest } from '../../eck/paactive-context.js';
|
|
46
47
|
import { AGENT_DELEGATION_TOKEN_ENV } from '../auth/agent-delegation.js';
|
|
47
48
|
import { hasTrustedPrincipal } from '../auth/authenticated-actor.js';
|
|
48
49
|
import { isValidAid } from '../../aun/aid/identity.js';
|
|
@@ -2667,12 +2668,10 @@ export class ResponseEngine {
|
|
|
2667
2668
|
}
|
|
2668
2669
|
}
|
|
2669
2670
|
async assertCurrentExecutionAuthorization(context, agent) {
|
|
2671
|
+
await assertOwnershipAuthorization(context);
|
|
2670
2672
|
if (context.executionPermission) {
|
|
2671
2673
|
await this.assertCurrentFullAccessExecutionAuthorization(context.executionPermission, agent);
|
|
2672
2674
|
}
|
|
2673
|
-
else {
|
|
2674
|
-
await assertOwnershipAuthorization(context);
|
|
2675
|
-
}
|
|
2676
2675
|
}
|
|
2677
2676
|
/**
|
|
2678
2677
|
* The authorization envelope is immutable for one logical run, but the
|
|
@@ -3026,6 +3025,18 @@ export class ResponseEngine {
|
|
|
3026
3025
|
const accessAdapter = accessChannelInfo?.adapter;
|
|
3027
3026
|
const accessAdapterSelfAid = typeof accessAdapter?._selfAid === 'function' ? accessAdapter._selfAid() : undefined;
|
|
3028
3027
|
const selfAidForAccess = accessAdapterSelfAid || message.selfAID || session.selfAID || undefined;
|
|
3028
|
+
if (message.source === 'trigger' && message.triggerMeta?.originChannelType === 'aun'
|
|
3029
|
+
&& message.triggerMeta.originChatType !== 'group') {
|
|
3030
|
+
await preparePaTeamQualification(selfAidForAccess, message.triggerMeta.originPeerId);
|
|
3031
|
+
}
|
|
3032
|
+
if (message.source === 'handoff' && message.handoffDelivery?.direction === 'origin'
|
|
3033
|
+
&& message.handoffDelivery.originAuthorization?.channelType === 'aun'
|
|
3034
|
+
&& message.handoffDelivery.originAuthorization.chatType === 'private') {
|
|
3035
|
+
await preparePaTeamQualification(selfAidForAccess, message.handoffDelivery.originAuthorization.actorId);
|
|
3036
|
+
}
|
|
3037
|
+
if ((message.channelType || accessChannelKey.split('#')[0]) === 'aun' && message.chatType !== 'group') {
|
|
3038
|
+
await preparePaTeamQualification(selfAidForAccess, message.peerId);
|
|
3039
|
+
}
|
|
3029
3040
|
await refreshOwnershipForAuthorization(selfAidForAccess, {
|
|
3030
3041
|
maxAgeMs: OWNERSHIP_CACHE_MAX_AGE_MS,
|
|
3031
3042
|
allowTransient: true,
|
|
@@ -3651,6 +3662,15 @@ export class ResponseEngine {
|
|
|
3651
3662
|
const selfName = registrySelfName ?? adapterSelfName;
|
|
3652
3663
|
const peerName = message.peerName || session.metadata?.peerName;
|
|
3653
3664
|
const peerIdRaw = message.peerId;
|
|
3665
|
+
if (message.source === 'trigger' && message.triggerMeta?.originChannelType === 'aun'
|
|
3666
|
+
&& message.triggerMeta.originChatType !== 'group') {
|
|
3667
|
+
await preparePaTeamQualification(selfAid, message.triggerMeta.originPeerId);
|
|
3668
|
+
}
|
|
3669
|
+
if (message.handoffDelivery?.direction === 'origin'
|
|
3670
|
+
&& message.handoffDelivery.originAuthorization?.channelType === 'aun'
|
|
3671
|
+
&& message.handoffDelivery.originAuthorization.chatType === 'private') {
|
|
3672
|
+
await preparePaTeamQualification(selfAid, message.handoffDelivery.originAuthorization.actorId);
|
|
3673
|
+
}
|
|
3654
3674
|
const triggerExecutionIdentity = this.resolveTriggerExecutionIdentity(message, selfAid);
|
|
3655
3675
|
const authorizationIdentity = triggerExecutionIdentity
|
|
3656
3676
|
?? this.resolveHandoffOriginExecutionIdentity(message, selfAid);
|
|
@@ -3673,6 +3693,9 @@ export class ResponseEngine {
|
|
|
3673
3693
|
? formatPeerKey(configChannelType, peerKeyId)
|
|
3674
3694
|
: undefined);
|
|
3675
3695
|
const peerType = message.peerType ?? session.metadata?.peerType;
|
|
3696
|
+
if (configChannelType === 'aun' && configChatType === 'private') {
|
|
3697
|
+
await preparePaTeamQualification(selfAid, configActorId);
|
|
3698
|
+
}
|
|
3676
3699
|
const peerRoleDetail = authorizationIdentity ? undefined : (() => {
|
|
3677
3700
|
try {
|
|
3678
3701
|
return resolvePeerRoleDetail({
|
|
@@ -3743,11 +3766,13 @@ export class ResponseEngine {
|
|
|
3743
3766
|
});
|
|
3744
3767
|
// Resolve overrides before binding a flow so hooks, context and envelope
|
|
3745
3768
|
// all use the same scene-checked mode for this task.
|
|
3746
|
-
const effectiveChatMode =
|
|
3747
|
-
? '
|
|
3748
|
-
:
|
|
3749
|
-
?
|
|
3750
|
-
:
|
|
3769
|
+
const effectiveChatMode = chatType === 'group'
|
|
3770
|
+
? 'proactive'
|
|
3771
|
+
: systemOrServicePeer
|
|
3772
|
+
? 'interactive'
|
|
3773
|
+
: taskChatModeOverride
|
|
3774
|
+
? chatModeForScene(taskChatModeOverride, { channelType: currentChannelType, chatType, peerType, role: peerRole, lifecycle, sessionType: session.sessionType ?? session.metadata?.sessionType ?? 'main' })
|
|
3775
|
+
: chatModeFallback;
|
|
3751
3776
|
const responseModeAgentDir = selfAid ? resolveAgentDir(selfAid) : undefined;
|
|
3752
3777
|
// mentionMode:顶层通用参数(先读出备用,投递/入队策略后续接入)
|
|
3753
3778
|
const mentionMode = effectiveAgentConfig?.mentionMode ?? 'disabled';
|
|
@@ -4618,6 +4643,15 @@ export class ResponseEngine {
|
|
|
4618
4643
|
chatmode: effectiveChatMode,
|
|
4619
4644
|
// 系统会话没有角色
|
|
4620
4645
|
role: systemSessionMarker ? undefined : peerRole,
|
|
4646
|
+
paTeamAuthorization: !systemSessionMarker && configChannelType === 'aun' && configChatType === 'private'
|
|
4647
|
+
&& !!selfAid && !!configActorId && (paTeamQualification(selfAid, configActorId) === 'matched'
|
|
4648
|
+
|| requiresPaTeamVerification(selfAid, configActorId)),
|
|
4649
|
+
paTeamDefaultRole: peerRoleDetail?.source === 'pa-team-default'
|
|
4650
|
+
|| (authorizationIdentity?.role === peerRole && configChannelType === 'aun'
|
|
4651
|
+
&& configChatType === 'private' && !!selfAid && !!configActorId
|
|
4652
|
+
&& resolvePeerRoleDetail({ selfAid, channelKey: authorizationIdentity.originChannelKey, channelType: 'aun', chatType: 'private',
|
|
4653
|
+
actorId: configActorId, conversationId: configActorId }).source === 'pa-team-default'),
|
|
4654
|
+
paTeamPolicy: JSON.stringify(getRoleDefinition(peerRole, selfAid)),
|
|
4621
4655
|
chatType: authChatType,
|
|
4622
4656
|
selfAid,
|
|
4623
4657
|
managedTempDir: sessionRuntimeDir,
|
|
@@ -5382,6 +5416,8 @@ export class ResponseEngine {
|
|
|
5382
5416
|
// Stage 3: sessionKey 持久化字段
|
|
5383
5417
|
sessionKey: session.sessionKey,
|
|
5384
5418
|
chatMode: effectiveChatMode,
|
|
5419
|
+
// Message templates receive the same derived reply fact as system templates.
|
|
5420
|
+
activePush: effectiveChatMode === 'proactive' || effectiveChatMode === 'paactive',
|
|
5385
5421
|
isTriggerTask: causationPath.length > 0 || message.source === 'trigger',
|
|
5386
5422
|
readonly: effectivePermissionMode === 'readonly',
|
|
5387
5423
|
baseAgent: normalizedBaseagent.canonical,
|
|
@@ -5397,13 +5433,9 @@ export class ResponseEngine {
|
|
|
5397
5433
|
},
|
|
5398
5434
|
sessionId: session.id,
|
|
5399
5435
|
};
|
|
5400
|
-
if (effectiveChatMode === '
|
|
5401
|
-
kitCtx.vars = buildPaactiveSystemVars(kitCtx.vars);
|
|
5402
|
-
}
|
|
5403
|
-
else {
|
|
5436
|
+
if (effectiveChatMode === 'proactive') {
|
|
5404
5437
|
Object.assign(kitCtx.vars, {
|
|
5405
|
-
//
|
|
5406
|
-
// 默认值不在此硬编码,出厂默认由模式 schema 声明、经 buildState 落入 proactive.*。
|
|
5438
|
+
// Proactive policy variables are scoped to proactive tasks only.
|
|
5407
5439
|
proactivePreTool1stMsgChk: proactive?.preTool1stMsgChk ?? false,
|
|
5408
5440
|
proactiveToolUseReminder: proactive?.toolUseReminder ?? false,
|
|
5409
5441
|
// 明确续跑已表态时,提示词和运行时门禁都不再要求重复开场。
|
|
@@ -5413,8 +5445,7 @@ export class ResponseEngine {
|
|
|
5413
5445
|
proactiveSendTargetLabel: chatType === 'group' ? '群里' : '对方',
|
|
5414
5446
|
});
|
|
5415
5447
|
}
|
|
5416
|
-
const messageVars =
|
|
5417
|
-
? buildPaactiveMessageVars(kitCtx.vars) : kitCtx.vars;
|
|
5448
|
+
const messageVars = kitCtx.vars;
|
|
5418
5449
|
// 确保技能索引是最新的(懒加载机制)
|
|
5419
5450
|
if (selfAid) {
|
|
5420
5451
|
const { ensureSkillIndexUpToDate } = await import('../skill/startup.js');
|
|
@@ -5431,9 +5462,7 @@ export class ResponseEngine {
|
|
|
5431
5462
|
? DEFAULT_MANIFEST_FILE
|
|
5432
5463
|
: systemSessionMarker
|
|
5433
5464
|
? getSystemSessionModule(systemSessionMarker.type).manifest(systemSessionMarker.subtype)
|
|
5434
|
-
:
|
|
5435
|
-
? paactiveSystemManifest(kitCtx.vars)
|
|
5436
|
-
: resolveSessionManifest(sessionType, sessionManifests);
|
|
5465
|
+
: resolveSessionManifest(sessionType, sessionManifests);
|
|
5437
5466
|
const kitContext = renderKitSections(kitCtx, manifestFile);
|
|
5438
5467
|
effectiveSystemPrompt = [options?.systemPromptAppend, kitContext].filter(Boolean).join('\n') || undefined;
|
|
5439
5468
|
// ── Stats: context_breakdown 旁路采集(各段估算 token 数,字符数/4 近似) ──
|
|
@@ -5586,8 +5615,6 @@ export class ResponseEngine {
|
|
|
5586
5615
|
effectivePrompt = wrapPrompt(composeHintFallback(hintItems, fallbackContent));
|
|
5587
5616
|
}
|
|
5588
5617
|
catch (e) {
|
|
5589
|
-
if (effectiveChatMode === 'paactive')
|
|
5590
|
-
throw e;
|
|
5591
5618
|
logger.warn(`[ResponseEngine] renderMessageBody failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
5592
5619
|
if (ownerHintClaim) {
|
|
5593
5620
|
observerHintFailureCode = 'RENDER_FAILED';
|
|
@@ -6230,12 +6257,10 @@ export class ResponseEngine {
|
|
|
6230
6257
|
// 由响应模式插件统一处理(InteractiveMode.afterProcess / ProactiveMode.afterProcess)
|
|
6231
6258
|
const finalReplyText = streamResult.lastReplyText || streamResult.fullText;
|
|
6232
6259
|
const visibleFinalReplyText = stripContextLimitErrorLines(finalReplyText);
|
|
6233
|
-
const
|
|
6234
|
-
&& !this.isTrustedDaemonTrigger(message)
|
|
6235
|
-
&& !streamResult.isError
|
|
6260
|
+
const isNoopReply = !streamResult.isError
|
|
6236
6261
|
&& !isExpectedTerminalInterrupt(streamResult.terminalReason)
|
|
6237
|
-
&&
|
|
6238
|
-
if (resolvedMode?.mode.afterProcess && !
|
|
6262
|
+
&& isNoopText(visibleFinalReplyText, message.triggerMeta?.noopSentinel || undefined);
|
|
6263
|
+
if (resolvedMode?.mode.afterProcess && !isNoopReply) {
|
|
6239
6264
|
const flusherText = renderer.getFinalText();
|
|
6240
6265
|
const fullText = flusherText.length >= (streamResult.fullText?.length || 0) ? flusherText : streamResult.fullText;
|
|
6241
6266
|
await resolvedMode.mode.afterProcess({
|
|
@@ -6379,7 +6404,7 @@ export class ResponseEngine {
|
|
|
6379
6404
|
sentErrorAsSystemError = await projectTerminalReply({
|
|
6380
6405
|
isCurrent: () => !turnLease || this.turnCoordinator.canPublish(turnLease),
|
|
6381
6406
|
isInterrupted: () => terminalInterrupt || isNonErrorInterruptReason(this.interruptedSessions.get(session.id)),
|
|
6382
|
-
isNoop:
|
|
6407
|
+
isNoop: isNoopReply,
|
|
6383
6408
|
discardText: () => renderer.discardPendingText(),
|
|
6384
6409
|
isError: streamResult.isError,
|
|
6385
6410
|
text: visibleFinalReplyText,
|
|
@@ -6415,7 +6440,7 @@ export class ResponseEngine {
|
|
|
6415
6440
|
logger.info(`[ResponseEngine] task.finished: session=${session.id} task=${taskId} outcome=${terminalInterrupt ? 'interrupted' : streamResult.isError ? 'error' : 'completed'}`);
|
|
6416
6441
|
import('../../utils/msg-diag.js').then(m => m.diagLog('task_done', { aid: session.selfAID ?? '', msgId: message.messageId ?? '', taskId, text: message.content ?? '' })).catch(() => { });
|
|
6417
6442
|
// 降级模型回复末尾追加标记(代码层硬注入,不依赖模型输出)
|
|
6418
|
-
if (usedFallback && !
|
|
6443
|
+
if (usedFallback && !isNoopReply) {
|
|
6419
6444
|
const curFbState = this.modelFallbackMap.get(session.id);
|
|
6420
6445
|
const showHint = curFbState && curFbState.nextProbeAt >= 8 && !curFbState.hintShown;
|
|
6421
6446
|
const suffix = showHint
|
|
@@ -7317,12 +7342,8 @@ export class ResponseEngine {
|
|
|
7317
7342
|
}
|
|
7318
7343
|
if (totalTokens <= 0)
|
|
7319
7344
|
return undefined;
|
|
7320
|
-
// 单次请求的上下文不可能超过模型窗口。超过(留 5% 余量容纳输出侧计数)
|
|
7321
|
-
// 说明这行记的不是单次上下文,而是整轮累计用量——历史行里出现过
|
|
7322
|
-
// cache_read 被累加成 119 万的记录,它会让自动压缩在每个任务开始时
|
|
7323
|
-
// 重复触发。这类行一律不参与压缩判断。
|
|
7324
7345
|
const maxTokens = row.max_tokens ?? 0;
|
|
7325
|
-
if (maxTokens > 0 && totalTokens > maxTokens * 1.05) {
|
|
7346
|
+
if (!(recordedTotalTokens && recordedTotalTokens > 0) && maxTokens > 0 && totalTokens > maxTokens * 1.05) {
|
|
7326
7347
|
logger.warn(`[ResponseEngine] Ignoring implausible context_tokens: session=${sessionId} totalTokens=${totalTokens} maxTokens=${maxTokens}`);
|
|
7327
7348
|
return undefined;
|
|
7328
7349
|
}
|
|
@@ -913,13 +913,13 @@ export class OwnerResolver {
|
|
|
913
913
|
this.configuredOwnerFileRevision.clear();
|
|
914
914
|
}
|
|
915
915
|
async submitBinding(subjectAid, ownerAid, subject, assertCurrent) {
|
|
916
|
-
const client = subject.client;
|
|
917
916
|
const generation = subject.generation;
|
|
917
|
+
let replaced = false;
|
|
918
918
|
subject.view = { ...subject.view, requestedOwnerAid: ownerAid, requestStatus: 'requesting', task: undefined };
|
|
919
919
|
try {
|
|
920
920
|
const local = await this.tryLocalBind(subjectAid, ownerAid, assertCurrent);
|
|
921
921
|
if (local) {
|
|
922
|
-
if (
|
|
922
|
+
if (subject.client && subject.generation !== generation) {
|
|
923
923
|
throw new OwnershipError('CLIENT_REPLACED', 'Subject SDK client changed during local binding');
|
|
924
924
|
}
|
|
925
925
|
subject.view.task = local.task;
|
|
@@ -928,40 +928,63 @@ export class OwnerResolver {
|
|
|
928
928
|
subject.view.reason = undefined;
|
|
929
929
|
return this.snapshot(subjectAid);
|
|
930
930
|
}
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
931
|
+
// 尚无已加载渠道 client 的主体(典型是初始化停在 ownerpending、审批前不会
|
|
932
|
+
// hotLoad 的 Agent)也必须能在共识成立前换绑。withSubjectClient 在没有
|
|
933
|
+
// 已连接 client 时会退化为独立 slot 的临时短连接,与 submitTransfer /
|
|
934
|
+
// decide / status 的取用方式一致。
|
|
935
|
+
return await this.withSubjectClient(subjectAid, async (client, attached) => {
|
|
936
|
+
if (attached && (subject.client !== client || subject.generation !== generation)) {
|
|
937
|
+
throw new OwnershipError('CLIENT_REPLACED', 'Subject SDK client changed before binding');
|
|
938
|
+
}
|
|
939
|
+
assertCurrent();
|
|
940
|
+
const current = await client.checkOwnershipConsensus(subjectAid, true);
|
|
941
|
+
if (current.sub_aid !== subjectAid) {
|
|
942
|
+
throw new OwnershipError('TASK_MISMATCH', 'Ownership consensus returned a different subject');
|
|
943
|
+
}
|
|
944
|
+
if (current.status === 'unavailable' || current.status === 'invalid' || current.status === 'not_applicable') {
|
|
945
|
+
throw new OwnershipError(current.code ?? 'CONSENSUS_REQUIRED', current.reason ?? 'Binding requires a fresh readable ownership baseline');
|
|
946
|
+
}
|
|
947
|
+
if (current.status === 'consensus') {
|
|
948
|
+
this.applyConsensus(subjectAid, subject, current);
|
|
949
|
+
if (current.owner_aid === ownerAid)
|
|
950
|
+
return this.snapshot(subjectAid);
|
|
951
|
+
throw new OwnershipError('OWNER_ALREADY_BOUND', 'Subject already has a protocol owner; transfer is not supported');
|
|
952
|
+
}
|
|
953
|
+
if (!['unbound', 'released', 'single_sided'].includes(current.status)) {
|
|
954
|
+
throw new OwnershipError('CONSENSUS_REQUIRED', 'Binding requires a fresh readable ownership baseline');
|
|
955
|
+
}
|
|
956
|
+
this.applyConsensus(subjectAid, subject, current);
|
|
957
|
+
assertCurrent();
|
|
958
|
+
const task = this.task(await client.bindOwneraid(ownerAid));
|
|
959
|
+
if (attached && (subject.client !== client || subject.generation !== generation)) {
|
|
960
|
+
replaced = true;
|
|
961
|
+
throw new OwnershipError('CLIENT_REPLACED', 'Subject SDK client changed during binding; the request may have been submitted');
|
|
962
|
+
}
|
|
963
|
+
if (!task || task.sub_aid !== subjectAid || task.owner_aid !== ownerAid || task.operation !== 'bind') {
|
|
964
|
+
throw new OwnershipError('TASK_MISMATCH', 'SDK returned a binding result for a different subject or owner');
|
|
965
|
+
}
|
|
966
|
+
subject.view.task = task;
|
|
967
|
+
subject.view.requestStatus = task.status === 'error' ? 'error' : 'submitted';
|
|
968
|
+
subject.view.reason = task.reason;
|
|
969
|
+
if (task.status === 'rejected')
|
|
970
|
+
this.rememberRejectedOwnerBinding(task);
|
|
971
|
+
if (task.status === 'error' || task.status === 'rejected' || task.status === 'stopped') {
|
|
972
|
+
throw Object.assign(new OwnershipError(task.code ?? 'BIND_FAILED', task.reason ?? `Binding ended with ${task.status}`), {
|
|
973
|
+
retryable: task.retryable,
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
const submittedReason = 'Binding submitted; waiting for explicit owner approval and fresh consensus';
|
|
977
|
+
// 提交后旧共识必然过期(名片已写入新声明),invalidate 会清空 ownerAid 与
|
|
978
|
+
// consensusStatus;但"已提交、待审批"是调用方唯一能据以推进的事实,
|
|
979
|
+
// 必须留在视图里,否则上层只会看到 unavailable 而分不清是失败还是等待。
|
|
980
|
+
this.invalidate(subject, submittedReason, true);
|
|
981
|
+
subject.view.requestStatus = 'submitted';
|
|
982
|
+
subject.view.reason = submittedReason;
|
|
983
|
+
return this.snapshot(subjectAid);
|
|
984
|
+
});
|
|
962
985
|
}
|
|
963
986
|
catch (error) {
|
|
964
|
-
if (!
|
|
987
|
+
if (!replaced) {
|
|
965
988
|
subject.view.requestStatus = 'interrupted';
|
|
966
989
|
subject.view.reason = error instanceof Error ? error.message : String(error);
|
|
967
990
|
}
|
|
@@ -1590,6 +1613,21 @@ export async function refreshOwnershipForAuthorization(subjectAid, options = {})
|
|
|
1590
1613
|
}
|
|
1591
1614
|
}
|
|
1592
1615
|
export async function assertOwnershipAuthorization(context) {
|
|
1616
|
+
if (context?.paTeamAuthorization && context.selfAid && context.actor?.principalId) {
|
|
1617
|
+
const { preparePaTeamQualification } = await import('../relation/pa-team.js');
|
|
1618
|
+
const { resolvePeerRoleDetail } = await import('../../config/peer-role-resolver.js');
|
|
1619
|
+
const { getRoleDefinition } = await import('../../config/roles.js');
|
|
1620
|
+
await preparePaTeamQualification(context.selfAid, context.actor.principalId);
|
|
1621
|
+
const current = resolvePeerRoleDetail({
|
|
1622
|
+
selfAid: context.selfAid, channelKey: context.actor.operatorChannelKey, channelType: 'aun',
|
|
1623
|
+
chatType: 'private', actorId: context.actor.principalId, conversationId: context.actor.principalId,
|
|
1624
|
+
});
|
|
1625
|
+
if (!current.allowAccess || current.effectiveRole !== context.role
|
|
1626
|
+
|| (context.paTeamDefaultRole && current.source !== 'pa-team-default')
|
|
1627
|
+
|| (context.paTeamPolicy !== undefined && context.paTeamPolicy !== JSON.stringify(getRoleDefinition(context.role ?? '', context.selfAid)))) {
|
|
1628
|
+
throw new OwnershipError('PA_TEAM_AUTHORIZATION_CHANGED', 'PA team authorization changed; start a new task with the current role');
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1593
1631
|
const authorization = context?.executionPermission;
|
|
1594
1632
|
const ownerRole = context?.role === 'owner' && context.actor?.operatorChannelType !== 'daemon';
|
|
1595
1633
|
const ownerActor = hasTrustedPrincipal(context?.actor) ? context.actor.principalId : undefined;
|
|
@@ -1552,23 +1552,37 @@ function resolveCodexCmdCarrierString(command) {
|
|
|
1552
1552
|
*/
|
|
1553
1553
|
function resolveCodexPowerShellCarrierString(command) {
|
|
1554
1554
|
const input = trimShellSpacing(command);
|
|
1555
|
-
const match = input.match(/^(?:"([^"\r\n]+)"|(\S+))((?:[ \t]+-[A-Za-z]+)+)[ \t]+(.+)$/);
|
|
1555
|
+
const match = input.match(/^(?:"([^"\r\n]+)"|(\S+))((?:[ \t]+-[A-Za-z]+)+)[ \t]+(.+)$/s);
|
|
1556
1556
|
if (!match)
|
|
1557
1557
|
return undefined;
|
|
1558
|
-
|
|
1558
|
+
let executable = match[1] ?? match[2];
|
|
1559
|
+
if (match[1] !== undefined) {
|
|
1560
|
+
const parsedExecutable = parseLiteralShellCommand(`"${match[1]}"`, { dialect: 'posix' });
|
|
1561
|
+
if (!parsedExecutable.ok || parsedExecutable.argv.length !== 1)
|
|
1562
|
+
return undefined;
|
|
1563
|
+
executable = parsedExecutable.argv[0];
|
|
1564
|
+
}
|
|
1559
1565
|
if (!isCodexPowerShellExecutable(executable))
|
|
1560
1566
|
return undefined;
|
|
1561
|
-
// A string-form carrier has one additional command-line quoting layer. The
|
|
1562
|
-
// command argument is commonly serialized as `"ec ..."`; remove exactly
|
|
1563
|
-
// that outer pair and leave quotes belonging to EC arguments intact.
|
|
1564
1567
|
let nested = match[4].trim();
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1568
|
+
let failure;
|
|
1569
|
+
if (nested.startsWith('"') || nested.startsWith("'")) {
|
|
1570
|
+
const parsed = parseLiteralShellCommand(nested, { dialect: 'posix' });
|
|
1571
|
+
if (parsed.ok && parsed.argv.length === 1) {
|
|
1572
|
+
nested = parsed.argv[0];
|
|
1573
|
+
}
|
|
1574
|
+
else {
|
|
1575
|
+
failure = parsed.ok
|
|
1576
|
+
? parseFailure('shell-composition', nested, 0, 0, 'powershell')
|
|
1577
|
+
: { ...parsed, dialect: 'powershell' };
|
|
1578
|
+
nested = nested.length > 1 && nested.endsWith(nested[0])
|
|
1579
|
+
? nested.slice(1, -1)
|
|
1580
|
+
: nested.slice(1);
|
|
1581
|
+
}
|
|
1569
1582
|
}
|
|
1570
1583
|
const switches = match[3].trim().split(/[ \t]+/);
|
|
1571
|
-
|
|
1584
|
+
const carrier = resolveCodexPowerShellCarrierArgv([executable, ...switches, nested]);
|
|
1585
|
+
return carrier && failure ? { ...carrier, parseFailure: failure } : carrier;
|
|
1572
1586
|
}
|
|
1573
1587
|
/** Resolve a POSIX shell carrier when app-server provides only a string. */
|
|
1574
1588
|
function resolveCodexPosixShellCarrierString(command) {
|