evolcore 0.0.47 → 0.0.49
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 +90 -1
- package/bin/ec-build.mjs +86 -0
- package/dist/agent-template/jobs.js +12 -4
- package/dist/agent-template/runtime.js +143 -40
- package/dist/agent-template/service.js +66 -13
- package/dist/agents/baseagent.js +60 -20
- package/dist/agents/claude-runner.js +34 -17
- package/dist/agents/codex-runner.js +36 -17
- package/dist/agents/ecagent-runner.js +7 -4
- package/dist/agents/gemini-runner.js +5 -2
- package/dist/agents/runner-types.js +5 -21
- package/dist/aun/aid/agentmd.js +5 -1
- package/dist/aun/msg/p2p.js +2 -1
- package/dist/aun/service-proxy.js +4 -2
- package/dist/build-identity.json +1 -0
- package/dist/channels/aun.js +722 -295
- package/dist/channels/daemon.js +9 -25
- package/dist/cli/aun-commands.js +86 -51
- package/dist/cli/code-stats.js +19 -8
- package/dist/cli/command-log.js +1 -1
- package/dist/cli/daemon-commands.js +44 -43
- package/dist/cli/directory.js +13 -2
- package/dist/cli/ecmsg-gateway.js +5 -2
- package/dist/cli/index.js +9 -9
- package/dist/cli/init-channel.js +4 -6
- package/dist/cli/init.js +72 -50
- package/dist/cli/invoke-command.js +1 -1
- package/dist/cli/managed-command-guard.js +2 -0
- package/dist/cli/model.js +20 -5
- package/dist/cli/provider-command.js +74 -13
- package/dist/cli/quota.js +89 -0
- package/dist/cli/role.js +62 -17
- package/dist/cli/services-command.js +1 -0
- package/dist/cli/stats.js +3 -3
- package/dist/cli/team-workspace-command.js +56 -2
- package/dist/cli/thread-command.js +16 -51
- package/dist/config/boot-log.js +3 -9
- package/dist/config/builtin-roles.js +5 -7
- package/dist/config/config-field-policy.js +71 -1
- package/dist/config/config-manager.js +13 -7
- package/dist/config/daemon-services.js +30 -3
- package/dist/config/gateway-config.js +2 -2
- package/dist/config/invoke-ipc-service.js +6 -4
- package/dist/config/peer-bind-code.js +3 -4
- package/dist/config/peer-book-store.js +62 -229
- package/dist/config/peer-book.js +26 -27
- package/dist/config/peer-role-resolver.js +16 -1
- package/dist/config/provider-identity-migration.js +4 -1
- package/dist/config/provider-ipc-service.js +56 -11
- package/dist/config/provider-menu-request.js +24 -5
- package/dist/config/provider-templates.js +127 -0
- package/dist/config/providers-config.js +67 -12
- package/dist/config/providers-management.js +477 -51
- package/dist/config/resolved-config-op.js +3 -2
- package/dist/config/role-command-service.js +248 -1
- package/dist/config/schema-migration.js +105 -4
- package/dist/core/agent-application-service.js +6 -1
- package/dist/core/agent-runtime.js +4 -0
- package/dist/core/auth/agent-delegation.js +2 -1
- package/dist/core/auth/auth-gateway.js +2 -1
- package/dist/core/auth/delegation-authorization.js +36 -26
- package/dist/core/auth/operation-authorizer.js +25 -0
- package/dist/core/auth/operation-catalog.js +37 -64
- package/dist/core/capability/providers/codex-capability-provider.js +7 -8
- package/dist/core/channel-loader.js +18 -0
- package/dist/core/command/agent-control.js +32 -0
- package/dist/core/command/cli-intent-parser.js +13 -0
- package/dist/core/command/command-handler.js +126 -87
- package/dist/core/command/menu-catalog.js +1 -0
- package/dist/core/command/menu-handler.js +67 -150
- package/dist/core/command/menu-protocol.js +31 -1
- package/dist/core/command/provider-menu.js +13 -3
- package/dist/core/command/remote-shell.js +565 -0
- package/dist/core/command/role-menu.js +47 -23
- package/dist/core/command/slash-handler.js +26 -43
- package/dist/core/command/team-workspace-items.js +81 -12
- package/dist/core/command/team-workspace-team.js +9 -71
- package/dist/core/command/topic-slash.js +9 -30
- package/dist/core/daemon-bootstrap.js +8 -1
- package/dist/core/daemon-control.js +64 -8
- package/dist/core/daemon-lifecycle.js +16 -2
- package/dist/core/evolagent-registry.js +20 -3
- package/dist/core/file-integrity/store.js +2 -0
- package/dist/core/handoff/runtime.js +37 -1
- package/dist/core/inference/text-inference.js +3 -1
- package/dist/core/initialization/service.js +11 -6
- package/dist/core/interaction-router.js +3 -0
- package/dist/core/invoke/executors/text.js +72 -19
- package/dist/core/ipc-registration.js +3 -1
- package/dist/core/message/aun-ipc-sender.js +279 -107
- package/dist/core/message/contact-admission.js +91 -6
- package/dist/core/message/contact-pending-inbound.js +113 -0
- package/dist/core/message/contact-thread-approval.js +212 -0
- package/dist/core/message/im-renderer.js +41 -2
- package/dist/core/message/message-admission.js +5 -39
- package/dist/core/message/message-bridge.js +140 -370
- package/dist/core/message/message-log.js +29 -0
- package/dist/core/message/message-queue.js +119 -15
- package/dist/core/message/message-utils.js +8 -0
- package/dist/core/message/response-engine.js +580 -134
- package/dist/core/message/send-routing.js +5 -1
- package/dist/core/model/catalog-service.js +31 -11
- package/dist/core/model/config-scope.js +6 -14
- package/dist/core/model/model-capabilities.js +22 -4
- package/dist/core/model/model-catalog.js +1 -0
- package/dist/core/model/model-diagnostics.js +19 -0
- package/dist/core/model/model-fallback.js +13 -2
- package/dist/core/ownership/owner-resolver.js +328 -50
- package/dist/core/pack-auth.js +3 -0
- package/dist/core/pack-install.js +1 -1
- package/dist/core/permission/ec-command-parser.js +106 -19
- package/dist/core/permission/protected-paths.js +6 -6
- package/dist/core/permission/services-path-acl.js +451 -0
- package/dist/core/permission/tool-policy.js +5 -1
- package/dist/core/relation/peer-identity.js +36 -1
- package/dist/core/relation/same-owner-proof.js +81 -112
- package/dist/core/session/adapters/codex-session-file-adapter.js +96 -15
- package/dist/core/session/session-file-health.js +13 -7
- package/dist/core/session/session-fs-store.js +91 -35
- package/dist/core/session/session-manager.js +68 -24
- package/dist/core/session/session-mapper.js +14 -34
- package/dist/core/session/session-transcript.js +5 -1
- package/dist/core/task/task-activity-store.js +84 -0
- package/dist/core/task/task-recovery-service.js +13 -0
- package/dist/core/thread/command-parser.js +7 -12
- package/dist/core/thread/thread-context-storage.js +3 -2
- package/dist/core/thread/thread-operation.js +2 -13
- package/dist/core/thread/thread-service.js +15 -46
- package/dist/core/thread/topic-id.js +15 -0
- package/dist/directory/owner-directory-admission.js +12 -9
- package/dist/directory/owner-directory-cache.js +64 -28
- package/dist/directory/owner-directory-markdown.js +14 -2
- package/dist/directory/owner-directory-policy.js +5 -30
- package/dist/directory/owner-directory-query-operation.js +29 -3
- package/dist/directory/owner-directory-remarks.js +11 -3
- package/dist/directory/owner-directory-request-operation.js +5 -2
- package/dist/eck/kit-renderer.js +1 -1
- package/dist/eck/message-renderer.js +112 -29
- package/dist/ecweb/basic-settings-service.js +3 -1
- package/dist/ecweb/message-context-service.js +1 -1
- package/dist/ecweb/pairing.js +4 -3
- package/dist/ecweb/providers-service.js +26 -1
- package/dist/ecweb/runtime/lifecycle.js +18 -8
- package/dist/ecweb/runtime/proxy-access.js +74 -0
- package/dist/ecweb/runtime/supervisor.js +36 -6
- package/dist/event-center/center-config.js +9 -5
- package/dist/event-center/dispatcher.js +10 -1
- package/dist/event-center/ipc-operation.js +19 -0
- package/dist/event-center/registry.js +29 -3
- package/dist/event-center/runtime.js +106 -11
- package/dist/event-center/script-runner.js +5 -5
- package/dist/index.js +96 -59
- package/dist/ipc.js +38 -3
- package/dist/outputs/authorization.js +16 -0
- package/dist/outputs/cards.js +336 -0
- package/dist/outputs/events.js +63 -0
- package/dist/outputs/protocol.js +103 -0
- package/dist/outputs/service.js +266 -0
- package/dist/paths.js +3 -0
- package/dist/proxy/manager.js +43 -13
- package/dist/services/index.js +114 -5
- package/dist/services/ipc-operation.js +88 -15
- package/dist/services/pack-manager.js +13 -1
- package/dist/services/router.js +21 -6
- package/dist/services/script-runner.js +5 -4
- package/dist/services/service-payload.js +13 -7
- package/dist/services/validation.js +1 -1
- package/dist/stats/budget.js +2 -2
- package/dist/stats/db.js +19 -0
- package/dist/stats/index.js +1 -1
- package/dist/stats/{price-resolver.js → model-resolver.js} +304 -23
- package/dist/stats/normalizer.js +2 -0
- package/dist/stats/query.js +35 -27
- package/dist/stats/quota-query.js +95 -0
- package/dist/stats/role-budget.js +5 -2
- package/dist/stats/writer.js +10 -6
- package/dist/trigger/audit.js +7 -0
- package/dist/trigger/authorization.js +105 -11
- package/dist/trigger/feedback.js +10 -0
- package/dist/trigger/history.js +37 -11
- package/dist/trigger/ipc-service.js +12 -1
- package/dist/trigger/manager.js +1 -0
- package/dist/trigger/scheduler.js +7 -5
- package/dist/trigger/script-executor.js +2 -1
- package/dist/trigger/script-sandbox.js +21 -3
- package/dist/trigger/validation.js +22 -0
- package/dist/utils/atomic-write.js +22 -8
- package/dist/utils/cross-platform.js +73 -26
- package/dist/utils/error-dict.json +94 -4
- package/dist/utils/error-utils.js +27 -4
- package/dist/utils/evolcore-version.js +36 -65
- package/dist/utils/host-info.js +100 -1
- package/dist/utils/msg-diag.js +1 -0
- package/dist/utils/npm-ops.js +43 -8
- package/dist/utils/process-introspect.js +12 -7
- package/dist/utils/process-tree.js +50 -2
- package/dist/utils/windows-shell-trust.js +2 -0
- package/dist/workbench/protocol.js +80 -0
- package/dist/workbench/service.js +359 -0
- package/ecagent/dist/types.d.ts +6 -2
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +4 -2
- package/kits/docs/evolcore/aid.md +25 -0
- package/kits/docs/evolcore/config.md +16 -1
- package/kits/docs/evolcore/directory.md +30 -12
- package/kits/docs/evolcore/ecweb-lifecycle.md +15 -0
- package/kits/docs/evolcore/model.md +10 -0
- package/kits/docs/evolcore/msg.md +9 -0
- package/kits/docs/evolcore/peer.md +19 -65
- package/kits/docs/evolcore/provider.md +124 -4
- package/kits/docs/evolcore/quota.md +54 -0
- package/kits/docs/evolcore/role.md +83 -0
- package/kits/docs/evolcore/services.md +6 -6
- package/kits/docs/evolcore/stats.md +2 -0
- package/kits/docs/evolcore/team-workspace.md +1 -1
- package/kits/docs/evolcore/thread-chain.md +14 -15
- package/kits/docs/evolcore/tool-authorization.md +5 -0
- package/kits/docs/evolcore/trigger.md +12 -0
- package/kits/eck_message_manifest.json +12 -0
- package/kits/provider-templates.json +1213 -0
- package/kits/rules/04-relation.md +3 -3
- package/kits/schemas/_meta.json +14 -2
- package/kits/schemas/agent-config.schema.20.json +24 -0
- package/kits/schemas/contact-book.schema.4.json +52 -0
- package/kits/schemas/providers.schema.3.json +200 -0
- package/kits/skills/.switches.json +8 -0
- package/kits/skills/ability/references/calling.md +1 -1
- package/kits/skills/agent-output-cards/SKILL.md +57 -0
- package/kits/skills/ec-group/SKILL.md +2 -2
- package/kits/skills/ec-identity/SKILL.md +19 -72
- package/kits/skills/ec-provider/SKILL.md +270 -0
- package/kits/skills/ec-provider/scripts/check-model.mjs +80 -0
- package/kits/skills/ec-trigger/SKILL.md +1 -1
- package/kits/skills/thread-ops/SKILL.md +34 -21
- package/kits/templates/message-fragments/group-batch-item.md +1 -1
- package/kits/templates/message-fragments/group-batch.md +1 -1
- package/kits/templates/message-fragments/inject-default.md +1 -1
- package/kits/templates/message-fragments/interrupt-insert.md +1 -0
- package/kits/templates/message-fragments/item-group.md +1 -1
- package/kits/templates/message-fragments/item-private.md +1 -1
- package/kits/templates/message-fragments/thread-context.md +1 -1
- package/kits/templates/message-fragments/trigger-session.md +1 -1
- package/kits/templates/message-fragments/trigger-thread-check.md +1 -1
- package/kits/templates/roles/admin.json +2 -19
- package/kits/templates/roles/member.json +0 -3
- package/kits/templates/roles/visitor.json +1 -0
- package/kits/templates/system-fragments/baseagent.md +6 -0
- package/kits/templates/system-fragments/commands.md +4 -3
- package/kits/templates/system-fragments/directory-contacts.md +3 -4
- package/kits/templates/system-fragments/managed-runtime.md +1 -1
- package/kits/templates/system-fragments/relation.md +1 -1
- package/kits/templates/system-fragments/thread.md +7 -5
- package/kits/templates/system-fragments/venue.md +11 -0
- package/package.json +6 -4
- package/scripts/agent-template/inspect.mjs +50 -11
- package/scripts/agent-template/shared/common.mjs +11 -6
- package/scripts/agent-template/shared/team-schema.json +6 -4
- package/scripts/agent-template/shared/template-contract.mjs +62 -11
- package/scripts/agent-template/shared/template-package.mjs +189 -21
- package/scripts/agent-template/shared/template-runtime.mjs +54 -6
- package/scripts/agent-template/shared/template.mjs +2 -2
- package/scripts/agent-template/team-pack.mjs +52 -14
- package/dist/cli/peer.js +0 -127
- package/dist/config/peer-operation-service.js +0 -132
- package/dist/config/peer-request-service.js +0 -532
- package/dist/core/command/connect-menu.js +0 -624
|
@@ -681,8 +681,16 @@ function isCodexPosixShellExecutable(value) {
|
|
|
681
681
|
if (!value)
|
|
682
682
|
return false;
|
|
683
683
|
return CODEX_POSIX_SHELL_EXECUTABLES.has(value.toLowerCase())
|
|
684
|
+
|| isCodexZshExecutable(value)
|
|
684
685
|
|| isAbsoluteCustomShellPath(value, CODEX_CUSTOM_POSIX_SHELL_NAMES);
|
|
685
686
|
}
|
|
687
|
+
function isCodexZshExecutable(value) {
|
|
688
|
+
// Custom POSIX paths are explicit, normalized paths with an exact basename;
|
|
689
|
+
// neither relative lookalikes nor Windows zsh.exe are supported carriers.
|
|
690
|
+
return value === 'zsh' || (value.startsWith('/') && !value.startsWith('//')
|
|
691
|
+
&& path.posix.normalize(value) === value && value.endsWith('/zsh')
|
|
692
|
+
&& !/[\x00-\x1f\x7f\\"'<>|?*`$;&(){}\[\]]/u.test(value));
|
|
693
|
+
}
|
|
686
694
|
function isCodexPowerShellExecutable(value) {
|
|
687
695
|
if (!value)
|
|
688
696
|
return false;
|
|
@@ -791,6 +799,24 @@ function hasCarrierEcCommandPrefix(command, dialect) {
|
|
|
791
799
|
: input;
|
|
792
800
|
return /^\s*ec(?:\.cmd|\.exe|\.ps1)?(?:\s|$)/i.test(inner);
|
|
793
801
|
}
|
|
802
|
+
/** Identify nested EC intent only for denial; never authorize an eval/shell. */
|
|
803
|
+
function hasNestedZshEcIntent(command) {
|
|
804
|
+
let body = command;
|
|
805
|
+
while (body) {
|
|
806
|
+
if (hasEcCommandPrefix(body))
|
|
807
|
+
return true;
|
|
808
|
+
const carrier = resolveCodexShellCarrierString(body);
|
|
809
|
+
if (carrier) {
|
|
810
|
+
body = carrier.command;
|
|
811
|
+
continue;
|
|
812
|
+
}
|
|
813
|
+
const parsed = parseLiteralShellCommand(body, { posixShell: 'zsh' });
|
|
814
|
+
if (!parsed.ok || parsed.argv[0] !== 'eval')
|
|
815
|
+
return false;
|
|
816
|
+
body = parsed.argv.slice(1).join(' ');
|
|
817
|
+
}
|
|
818
|
+
return false;
|
|
819
|
+
}
|
|
794
820
|
/** Normalize the Windows npm shims to the canonical EvolCore CLI name. */
|
|
795
821
|
/**
|
|
796
822
|
* 取可执行名的 basename(小写)。与 hasEcCommandPrefix 里的算法一致:
|
|
@@ -1222,6 +1248,7 @@ export function parseCodexCarrierCommand(carrier, options = {}) {
|
|
|
1222
1248
|
const materialized = parseLiteralShellCommand(unwrapped.command, {
|
|
1223
1249
|
...options,
|
|
1224
1250
|
dialect: carrier.dialect,
|
|
1251
|
+
posixShell: carrier.posixShell ?? options.posixShell,
|
|
1225
1252
|
});
|
|
1226
1253
|
if (materialized.ok && carrier.dialect === 'powershell') {
|
|
1227
1254
|
const nestedCarrier = resolveCodexCmdCarrierString(unwrapped.command);
|
|
@@ -1267,6 +1294,9 @@ export function literalShellParseRemedy(failure) {
|
|
|
1267
1294
|
if (failure.issue === 'shell-composition') {
|
|
1268
1295
|
return '一次调用只执行一条完整命令;查询和操作请拆成独立工具调用,不要拼接管道、重定向、分号或子表达式。';
|
|
1269
1296
|
}
|
|
1297
|
+
if (failure.dialect === 'posix' && failure.issue === 'unsupported-escape') {
|
|
1298
|
+
return 'Shell 转义无法按字面量解析;请使用单引号,或受支持的 ANSI-C 转义:\\n、\\t、\\r、\\\\、\\\'。';
|
|
1299
|
+
}
|
|
1270
1300
|
if (failure.dialect !== 'powershell')
|
|
1271
1301
|
return undefined;
|
|
1272
1302
|
if (['invalid-quote', 'unsafe-expansion', 'unsupported-escape', 'structural-newline'].includes(failure.issue)) {
|
|
@@ -1733,6 +1763,7 @@ function resolveCodexPosixShellCarrierString(command) {
|
|
|
1733
1763
|
command: nested,
|
|
1734
1764
|
dialect: 'posix',
|
|
1735
1765
|
executable,
|
|
1766
|
+
...(isCodexZshExecutable(executable) ? { posixShell: 'zsh' } : {}),
|
|
1736
1767
|
parseFailure: parsed.ok
|
|
1737
1768
|
? parseFailure('shell-composition', input, 0, 0, 'posix')
|
|
1738
1769
|
: parsed,
|
|
@@ -1864,6 +1895,11 @@ export function parseLiteralShellCommand(command, options = {}) {
|
|
|
1864
1895
|
const char = input[index];
|
|
1865
1896
|
if (quote === 'single') {
|
|
1866
1897
|
if (char === "'") {
|
|
1898
|
+
// RC_QUOTES makes adjacent single quotes literal apostrophes in zsh.
|
|
1899
|
+
// Require an unambiguous boundary regardless of that startup option.
|
|
1900
|
+
if (options.posixShell === 'zsh' && input[index + 1] === "'") {
|
|
1901
|
+
return parseFailure('unsupported-escape', input, index, argv.length, 'posix');
|
|
1902
|
+
}
|
|
1867
1903
|
if (!isPosixQuotedTokenBoundary(input[index + 1]))
|
|
1868
1904
|
return parseFailure('invalid-quote', input, index, argv.length, 'posix');
|
|
1869
1905
|
quote = null;
|
|
@@ -1879,6 +1915,9 @@ export function parseLiteralShellCommand(command, options = {}) {
|
|
|
1879
1915
|
quote = null;
|
|
1880
1916
|
continue;
|
|
1881
1917
|
}
|
|
1918
|
+
if (options.posixShell === 'zsh' && char === '$' && /[=~^+\[]/u.test(input[index + 1] ?? '')) {
|
|
1919
|
+
return parseFailure('unsafe-expansion', input, index, argv.length, 'posix');
|
|
1920
|
+
}
|
|
1882
1921
|
const issue = doubleQuotedIssueAt(input, index);
|
|
1883
1922
|
if (issue)
|
|
1884
1923
|
return parseFailure(issue, input, index, argv.length, 'posix');
|
|
@@ -1964,6 +2003,9 @@ export function parseLiteralShellCommand(command, options = {}) {
|
|
|
1964
2003
|
token += "'";
|
|
1965
2004
|
break;
|
|
1966
2005
|
default:
|
|
2006
|
+
if (options.posixShell === 'zsh') {
|
|
2007
|
+
return parseFailure('unsupported-escape', input, index, argv.length, 'posix');
|
|
2008
|
+
}
|
|
1967
2009
|
token += `\\${esc}`;
|
|
1968
2010
|
break;
|
|
1969
2011
|
}
|
|
@@ -1979,6 +2021,13 @@ export function parseLiteralShellCommand(command, options = {}) {
|
|
|
1979
2021
|
return parseFailure('invalid-quote', input, index, argv.length, 'posix');
|
|
1980
2022
|
continue;
|
|
1981
2023
|
}
|
|
2024
|
+
// zsh has equals expansion and option-dependent extended glob/named-dir
|
|
2025
|
+
// expansion. Check source quoting here, before it is lost in argv.
|
|
2026
|
+
if (options.posixShell === 'zsh'
|
|
2027
|
+
&& (['~', '^', '#', '!'].includes(char)
|
|
2028
|
+
|| (char === '=' && (!tokenStarted || /[=:]$/u.test(token))))) {
|
|
2029
|
+
return parseFailure('unsafe-expansion', input, index, argv.length, 'posix');
|
|
2030
|
+
}
|
|
1982
2031
|
// `#` starts a shell comment only at the beginning of a word. Channel
|
|
1983
2032
|
// peer keys such as `aun#alice` are ordinary literal arguments.
|
|
1984
2033
|
if ((SHELL_UNQUOTED_META.has(char) && (char !== '#' || !tokenStarted))
|
|
@@ -2004,6 +2053,19 @@ export function parseLiteralShellArgv(command, options = {}) {
|
|
|
2004
2053
|
return result.ok ? result.argv : null;
|
|
2005
2054
|
}
|
|
2006
2055
|
export function resolveCodexShellCarrierArgv(argv) {
|
|
2056
|
+
if (argv[0] && isCodexZshExecutable(argv[0])) {
|
|
2057
|
+
const executeIndex = argv.findIndex((value, index) => index > 0 && /^-[A-Za-z]*c[A-Za-z]*$/u.test(value));
|
|
2058
|
+
if (executeIndex > 0 && argv[executeIndex + 1] !== undefined) {
|
|
2059
|
+
const command = argv[executeIndex + 1];
|
|
2060
|
+
const supported = argv.length === 3 && executeIndex === 1
|
|
2061
|
+
&& (argv[1] === '-c' || argv[1] === '-lc');
|
|
2062
|
+
return {
|
|
2063
|
+
command, dialect: 'posix', posixShell: 'zsh', executable: argv[0],
|
|
2064
|
+
...(!supported ? { parseFailure: parseFailure('shell-composition', command, 0, 0, 'posix') } : {}),
|
|
2065
|
+
};
|
|
2066
|
+
}
|
|
2067
|
+
return undefined;
|
|
2068
|
+
}
|
|
2007
2069
|
if (argv.length === 3
|
|
2008
2070
|
&& (argv[1] === '-lc' || argv[1] === '-c')
|
|
2009
2071
|
&& isCodexPosixShellExecutable(argv[0])) {
|
|
@@ -2818,8 +2880,8 @@ function scanBoundedOutputOperators(command) {
|
|
|
2818
2880
|
* Returns the full filter argv (executable included) so the spawn helper can
|
|
2819
2881
|
* execute exactly what policy validated.
|
|
2820
2882
|
*/
|
|
2821
|
-
export function parseStdinOnlyFilterArgv(segment) {
|
|
2822
|
-
const argv = parseLiteralShellArgv(segment);
|
|
2883
|
+
export function parseStdinOnlyFilterArgv(segment, options = {}) {
|
|
2884
|
+
const argv = parseLiteralShellArgv(segment, options);
|
|
2823
2885
|
if (!argv)
|
|
2824
2886
|
return null;
|
|
2825
2887
|
const executable = normalizeStdoutFilterExecutable(argv[0]);
|
|
@@ -2900,10 +2962,13 @@ export function parseStdinOnlyFilterArgv(segment) {
|
|
|
2900
2962
|
* optional stderr merge, one trusted stdin-only stdout filter, and one
|
|
2901
2963
|
* create-only output path.
|
|
2902
2964
|
*/
|
|
2903
|
-
export function parseBoundedOutputShellCommand(command) {
|
|
2965
|
+
export function parseBoundedOutputShellCommand(command, options = {}) {
|
|
2904
2966
|
const input = trimShellSpacing(substituteManagedTmpDirToken(command));
|
|
2905
2967
|
if (!input)
|
|
2906
2968
|
return null;
|
|
2969
|
+
// The wrapper owns TMPDIR substitution. Keep its sentinel intact until
|
|
2970
|
+
// source-argument rejection and output-path restoration have completed.
|
|
2971
|
+
const literalOptions = { ...options, allowManagedTmpDir: false };
|
|
2907
2972
|
const operators = scanBoundedOutputOperators(input);
|
|
2908
2973
|
if (!operators || operators.length === 0)
|
|
2909
2974
|
return null;
|
|
@@ -2920,7 +2985,7 @@ export function parseBoundedOutputShellCommand(command) {
|
|
|
2920
2985
|
// 所以两种情况都切在 operators[0].start,绝不能按 end 切——那会把 `2>&1` 混进 argv。
|
|
2921
2986
|
const first = operators[0];
|
|
2922
2987
|
const sourceText = trimShellSpacing(input.slice(0, first.start));
|
|
2923
|
-
const argv = parseLiteralShellArgv(sourceText);
|
|
2988
|
+
const argv = parseLiteralShellArgv(sourceText, literalOptions);
|
|
2924
2989
|
if (!argv)
|
|
2925
2990
|
return null;
|
|
2926
2991
|
// `$TMPDIR` is a transport-level path reference, never an argument
|
|
@@ -2940,7 +3005,7 @@ export function parseBoundedOutputShellCommand(command) {
|
|
|
2940
3005
|
if (operator.kind === 'redirect' || operator.kind === 'redirect-stderr') {
|
|
2941
3006
|
const next = operators[cursor + 1];
|
|
2942
3007
|
const segmentEnd = next ? next.start : input.length;
|
|
2943
|
-
const outputArgv = parseLiteralShellArgv(trimShellSpacing(input.slice(operator.end, segmentEnd)));
|
|
3008
|
+
const outputArgv = parseLiteralShellArgv(trimShellSpacing(input.slice(operator.end, segmentEnd)), literalOptions);
|
|
2944
3009
|
if (!outputArgv || outputArgv.length !== 1)
|
|
2945
3010
|
return null;
|
|
2946
3011
|
if (outputArgv[0].includes('$') && !outputArgv[0].includes(MANAGED_TMPDIR_TOKEN))
|
|
@@ -2970,7 +3035,7 @@ export function parseBoundedOutputShellCommand(command) {
|
|
|
2970
3035
|
// 该管道的下游终点:下一个操作符起点,或输入末尾。
|
|
2971
3036
|
const next = operators[cursor + 1];
|
|
2972
3037
|
const segmentEnd = next ? next.start : input.length;
|
|
2973
|
-
const parsedArgs = parseStdinOnlyFilterArgv(trimShellSpacing(input.slice(operator.end, segmentEnd)));
|
|
3038
|
+
const parsedArgs = parseStdinOnlyFilterArgv(trimShellSpacing(input.slice(operator.end, segmentEnd)), literalOptions);
|
|
2974
3039
|
if (parsedArgs === null)
|
|
2975
3040
|
return null;
|
|
2976
3041
|
filterChain.push(parsedArgs);
|
|
@@ -2993,11 +3058,11 @@ export function parseBoundedOutputShellCommand(command) {
|
|
|
2993
3058
|
* 通配、括号、重定向、管道、以及 `&&`/`;` 本身。引号包裹的普通文本(如
|
|
2994
3059
|
* `echo "extra"`)合法;`echo $?`、`echo \`id\``、`echo *` 一律不合法。
|
|
2995
3060
|
*/
|
|
2996
|
-
function parseInertSegment(segment) {
|
|
3061
|
+
function parseInertSegment(segment, options) {
|
|
2997
3062
|
const text = trimShellSpacing(segment);
|
|
2998
3063
|
if (!text)
|
|
2999
3064
|
return null;
|
|
3000
|
-
const argv = parseLiteralShellArgv(text);
|
|
3065
|
+
const argv = parseLiteralShellArgv(text, { posixShell: options.posixShell });
|
|
3001
3066
|
if (!argv || argv.length === 0)
|
|
3002
3067
|
return null;
|
|
3003
3068
|
// 字面量解析已处理引号;拒绝任何仍可能造成展开或结构变化的字符。
|
|
@@ -3026,7 +3091,7 @@ function isInertSegment(argv) {
|
|
|
3026
3091
|
* 返回 ec 段的 argv(调用方按 bounded-output 同样的方式直接 spawn,不经 shell)。
|
|
3027
3092
|
* 前后的零副作用段只用来判定结构,不参与执行。
|
|
3028
3093
|
*/
|
|
3029
|
-
export function parseCdPrefixedEcCommand(input) {
|
|
3094
|
+
export function parseCdPrefixedEcCommand(input, options = {}) {
|
|
3030
3095
|
const text = trimShellSpacing(input);
|
|
3031
3096
|
if (!text)
|
|
3032
3097
|
return null;
|
|
@@ -3048,7 +3113,7 @@ export function parseCdPrefixedEcCommand(input) {
|
|
|
3048
3113
|
let ecIndex = -1;
|
|
3049
3114
|
for (let index = 0; index < segments.length; index++) {
|
|
3050
3115
|
const segment = segments[index];
|
|
3051
|
-
const parsed = parseEcTail(segment);
|
|
3116
|
+
const parsed = parseEcTail(segment, options);
|
|
3052
3117
|
if (parsed) {
|
|
3053
3118
|
if (ecCommand)
|
|
3054
3119
|
return null; // 两条 ec,拒绝
|
|
@@ -3057,7 +3122,7 @@ export function parseCdPrefixedEcCommand(input) {
|
|
|
3057
3122
|
continue;
|
|
3058
3123
|
}
|
|
3059
3124
|
// 非 ec 段:只允许零副作用形态。
|
|
3060
|
-
const argv = parseInertSegment(segment);
|
|
3125
|
+
const argv = parseInertSegment(segment, options);
|
|
3061
3126
|
if (!argv || !isInertSegment(argv))
|
|
3062
3127
|
return null;
|
|
3063
3128
|
if (argv[0] === 'cd') {
|
|
@@ -3092,14 +3157,14 @@ export function parseCdPrefixedEcCommand(input) {
|
|
|
3092
3157
|
* 2. `ec ... 2>&1 | head` 这类已有受控过滤器(bounded-output)
|
|
3093
3158
|
* 两者都直接产出 argv 交给运行器,不再经 shell。其它一律返回 null。
|
|
3094
3159
|
*/
|
|
3095
|
-
function parseEcTail(segment) {
|
|
3096
|
-
const literal = parseLiteralShellArgv(segment);
|
|
3160
|
+
function parseEcTail(segment, options) {
|
|
3161
|
+
const literal = parseLiteralShellArgv(segment, { posixShell: options.posixShell });
|
|
3097
3162
|
// 归一化后再判首元素:`ecmsg ...` 等价于 `ec msg ...`,必须与 ec 同权进审批链。
|
|
3098
3163
|
// 返回的 argv 也必须是归一化后的形态,否则审批哈希与 daemon 侧解析会错位。
|
|
3099
3164
|
if (literal && literal.length > 0 && normalizeEvolcoreCommandArgv(literal)[0] === 'ec') {
|
|
3100
3165
|
return { argv: normalizeEvolcoreCommandArgv(literal), mergeStderr: false };
|
|
3101
3166
|
}
|
|
3102
|
-
const bounded = parseBoundedOutputShellCommand(segment);
|
|
3167
|
+
const bounded = parseBoundedOutputShellCommand(segment, options);
|
|
3103
3168
|
if (bounded && normalizeEvolcoreCommandArgv(bounded.argv)[0] === 'ec') {
|
|
3104
3169
|
return { ...bounded, argv: normalizeEvolcoreCommandArgv(bounded.argv) };
|
|
3105
3170
|
}
|
|
@@ -3137,6 +3202,13 @@ export function classifyEvolcoreShellCommand(command, options = {}) {
|
|
|
3137
3202
|
}
|
|
3138
3203
|
const stringCarrier = resolveCodexShellCarrierString(stripped);
|
|
3139
3204
|
if (stringCarrier) {
|
|
3205
|
+
if (options.posixShell === 'zsh') {
|
|
3206
|
+
// Only the app-server's outer carrier is supported. Recognize nested
|
|
3207
|
+
// EC intent for an explicit denial without granting a nested shell.
|
|
3208
|
+
return hasNestedZshEcIntent(stringCarrier.command)
|
|
3209
|
+
? { kind: 'composite', issue: 'shell-composition' }
|
|
3210
|
+
: { kind: 'none' };
|
|
3211
|
+
}
|
|
3140
3212
|
const nested = parseCodexCarrierCommand(stringCarrier, parseOptions);
|
|
3141
3213
|
if (nested.ok && nested.argv[0] === 'ec')
|
|
3142
3214
|
return { kind: 'literal' };
|
|
@@ -3150,6 +3222,11 @@ export function classifyEvolcoreShellCommand(command, options = {}) {
|
|
|
3150
3222
|
if (literal.ok) {
|
|
3151
3223
|
if (normalizeEvolcoreCommandArgv(literal.argv)[0] === 'ec')
|
|
3152
3224
|
return { kind: 'literal' };
|
|
3225
|
+
if (options.posixShell === 'zsh' && literal.argv[0] === 'eval') {
|
|
3226
|
+
return hasNestedZshEcIntent(literal.argv.slice(1).join(' '))
|
|
3227
|
+
? { kind: 'composite', issue: 'shell-composition' }
|
|
3228
|
+
: { kind: 'none' };
|
|
3229
|
+
}
|
|
3153
3230
|
const carrier = resolveCodexShellCarrierArgv(literal.argv);
|
|
3154
3231
|
if (carrier !== undefined) {
|
|
3155
3232
|
const nested = parseCodexCarrierCommand(carrier, parseOptions);
|
|
@@ -3184,7 +3261,7 @@ export function classifyEvolcoreShellCommand(command, options = {}) {
|
|
|
3184
3261
|
}
|
|
3185
3262
|
const boundedOutput = options.dialect === 'powershell' || options.dialect === 'cmd'
|
|
3186
3263
|
? null
|
|
3187
|
-
: parseBoundedOutputShellCommand(stripped);
|
|
3264
|
+
: parseBoundedOutputShellCommand(stripped, parseOptions);
|
|
3188
3265
|
if (boundedOutput && boundedOutput.argv[0] === 'ec') {
|
|
3189
3266
|
return { kind: 'bounded-output', command: boundedOutput };
|
|
3190
3267
|
}
|
|
@@ -3192,7 +3269,7 @@ export function classifyEvolcoreShellCommand(command, options = {}) {
|
|
|
3192
3269
|
// 只放宽前缀,ec 段仍走完整的字面量解析。
|
|
3193
3270
|
const cdPrefixed = options.dialect === 'powershell' || options.dialect === 'cmd'
|
|
3194
3271
|
? null
|
|
3195
|
-
: parseCdPrefixedEcCommand(stripped);
|
|
3272
|
+
: parseCdPrefixedEcCommand(stripped, parseOptions);
|
|
3196
3273
|
if (cdPrefixed)
|
|
3197
3274
|
return { kind: 'cd-prefixed', command: cdPrefixed.command, cwd: cdPrefixed.cwd };
|
|
3198
3275
|
// Only a command-boundary prefix is enough to preserve a useful syntax
|
|
@@ -3234,9 +3311,14 @@ export function resolveCanonicalEvolcoreToolInput(input, options = {}) {
|
|
|
3234
3311
|
: resolveCodexShellCarrierString(rawCommand);
|
|
3235
3312
|
const command = carrier?.command ?? rawCommand;
|
|
3236
3313
|
const dialect = carrier?.dialect ?? options.dialect;
|
|
3237
|
-
const parseOptions = {
|
|
3314
|
+
const parseOptions = {
|
|
3315
|
+
...options,
|
|
3316
|
+
...(dialect ? { dialect } : {}),
|
|
3317
|
+
...(carrier?.posixShell ? { posixShell: carrier.posixShell } : {}),
|
|
3318
|
+
};
|
|
3238
3319
|
const classification = classifyEvolcoreShellCommand(command, parseOptions);
|
|
3239
|
-
if (
|
|
3320
|
+
if (!carrier?.parseFailure
|
|
3321
|
+
&& (classification.kind === 'bounded-output' || classification.kind === 'cd-prefixed')) {
|
|
3240
3322
|
if (normalizeEvolcoreCommandArgv(classification.command.argv)[0] !== 'ec')
|
|
3241
3323
|
return { kind: 'not-ec' };
|
|
3242
3324
|
const spec = buildCanonicalEvolcoreExecutionSpec({
|
|
@@ -3263,7 +3345,12 @@ export function resolveCanonicalEvolcoreToolInput(input, options = {}) {
|
|
|
3263
3345
|
};
|
|
3264
3346
|
}
|
|
3265
3347
|
if (classification.kind === 'composite')
|
|
3266
|
-
return {
|
|
3348
|
+
return {
|
|
3349
|
+
kind: 'invalid',
|
|
3350
|
+
failure: parsed.ok
|
|
3351
|
+
? parseFailure(classification.issue, command, 0, 0, dialect ?? 'posix')
|
|
3352
|
+
: parsed,
|
|
3353
|
+
};
|
|
3267
3354
|
if (!parsed.ok && hasEcCommandPrefix(command, dialect))
|
|
3268
3355
|
return { kind: 'invalid', failure: parsed };
|
|
3269
3356
|
return { kind: 'not-ec' };
|
|
@@ -43,7 +43,7 @@ const L_CLASS_RELATIVE_PATTERNS = [
|
|
|
43
43
|
/^daemon\.json$/,
|
|
44
44
|
/^agents\/defaults\.json$/,
|
|
45
45
|
/^agents\/[^/]+\/config\.json$/,
|
|
46
|
-
/^agents\/[^/]+\/contact\.json$/,
|
|
46
|
+
/^agents\/[^/]+\/(?:contact|peers)\.json$/,
|
|
47
47
|
/^agents\/[^/]+\/contact-operations\.jsonl$/,
|
|
48
48
|
/^agents\/[^/]+\/relations\/[^/]+\/config\.json$/,
|
|
49
49
|
/^backups\/config(?:\/|$)/,
|
|
@@ -54,7 +54,7 @@ const L_CLASS_RELATIVE_PATTERNS = [
|
|
|
54
54
|
];
|
|
55
55
|
const L_CLASS_REFERENCE_PATTERNS = [
|
|
56
56
|
/(?:^|[^A-Za-z0-9_.-])daemon\.json(?=$|[^A-Za-z0-9_.-])/,
|
|
57
|
-
/(?:^|[^A-Za-z0-9_.-])agents[\\/](?:defaults\.json|[^/\\\s"']+[\\/](?:(?:config|contact)\.json|contact-operations\.jsonl|relations[\\/][^/\\\s"']+[\\/]config\.json))(?=$|[\s"';&|<>)},])/,
|
|
57
|
+
/(?:^|[^A-Za-z0-9_.-])agents[\\/](?:defaults\.json|[^/\\\s"']+[\\/](?:(?:config|contact|peers)\.json|contact-operations\.jsonl|relations[\\/][^/\\\s"']+[\\/]config\.json))(?=$|[\s"';&|<>)},])/,
|
|
58
58
|
/(?:^|[^A-Za-z0-9_.-])backups[\\/]config(?:[\\/]|$|[\s"';&|<>)},])/,
|
|
59
59
|
/(?:^|[^A-Za-z0-9_.-])agents[\\/][^/\\\s"']+[\\/]triggers(?:[\\/]|$|[\s"';&|<>)},])/,
|
|
60
60
|
/(?:^|[^A-Za-z0-9_.-])agents[\\/][^/\\\s"']+[\\/]roles(?:[\\/]|$|[\s"';&|<>)},])/,
|
|
@@ -375,7 +375,7 @@ function getLegacyHClassSandboxPatterns(root) {
|
|
|
375
375
|
'daemon.json',
|
|
376
376
|
path.join('agents', 'defaults.json'),
|
|
377
377
|
path.join('agents', '*', 'config.json'),
|
|
378
|
-
path.join('agents', '*', 'contact.json'),
|
|
378
|
+
path.join('agents', '*', 'contact.json'), path.join('agents', '*', 'peers.json'),
|
|
379
379
|
path.join('agents', '*', 'contact-operations.jsonl'),
|
|
380
380
|
path.join('agents', '*', 'relations', '*', 'config.json'),
|
|
381
381
|
path.join('backups', 'config'), path.join('backups', 'config', '**'),
|
|
@@ -560,7 +560,7 @@ export function getExistingHClassMaskTargets(root = resolveRoot(), options = {})
|
|
|
560
560
|
if (!entry.isDirectory())
|
|
561
561
|
continue;
|
|
562
562
|
const agentRoot = path.join(agentsDir, entry.name);
|
|
563
|
-
for (const fileName of ['config.json', 'config.json_', 'contact.json', 'contact.json_', 'contact-operations.jsonl']) {
|
|
563
|
+
for (const fileName of ['config.json', 'config.json_', 'contact.json', 'contact.json_', 'peers.json', 'peers.json_', 'contact-operations.jsonl']) {
|
|
564
564
|
addExistingTarget(targets, path.join(agentRoot, fileName));
|
|
565
565
|
}
|
|
566
566
|
const relationsDir = path.join(agentRoot, 'relations');
|
|
@@ -614,7 +614,7 @@ export function getExistingLClassReadOnlyTargets(root = resolveRoot(), options =
|
|
|
614
614
|
}
|
|
615
615
|
const ownRoot = path.join(agentsDir, selfAid);
|
|
616
616
|
for (const relative of [
|
|
617
|
-
'config.json', 'contact.json', 'contact-operations.jsonl', 'roles', 'triggers', 'events', 'services',
|
|
617
|
+
'config.json', 'contact.json', 'peers.json', 'contact-operations.jsonl', 'roles', 'triggers', 'events', 'services',
|
|
618
618
|
])
|
|
619
619
|
addExistingTarget(targets, path.join(ownRoot, relative));
|
|
620
620
|
try {
|
|
@@ -1027,7 +1027,7 @@ export function lClassGrantIncludesProtectedPath(value, options = {}) {
|
|
|
1027
1027
|
// relations/<peer> 本身时才覆盖它,更深的路径(如 relations/<peer>/memory/…)不会。
|
|
1028
1028
|
if (segments[2] === 'relations')
|
|
1029
1029
|
return segments.length <= 4;
|
|
1030
|
-
return ['config.json', 'contact.json', 'contact-operations.jsonl', 'roles', 'triggers', 'events', 'services']
|
|
1030
|
+
return ['config.json', 'contact.json', 'peers.json', 'contact-operations.jsonl', 'roles', 'triggers', 'events', 'services']
|
|
1031
1031
|
.includes(segments[2]);
|
|
1032
1032
|
}
|
|
1033
1033
|
return false;
|