evolcore 0.0.12 → 0.0.13

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.
Files changed (104) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/bin/ec-safe-output.js +26 -7
  3. package/dist/agents/claude-runner.js +53 -7
  4. package/dist/agents/codex-app-server-client.js +53 -5
  5. package/dist/agents/codex-runner.js +104 -59
  6. package/dist/agents/ecagent-runner.js +4 -1
  7. package/dist/aun/aid/control-aid.js +36 -13
  8. package/dist/aun/aid/store.js +13 -7
  9. package/dist/aun/group-fs-download.js +56 -0
  10. package/dist/aun/group-identity.js +1 -2
  11. package/dist/aun/msg/group.js +11 -33
  12. package/dist/aun/msg/index.js +1 -2
  13. package/dist/aun/msg/managed-operation.js +116 -55
  14. package/dist/aun/msg/upload.js +16 -1
  15. package/dist/aun/outbox.js +31 -2
  16. package/dist/aun/rpc/client.js +66 -0
  17. package/dist/aun/rpc/index.js +1 -2
  18. package/dist/aun/storage/{upload.js → client.js} +11 -2
  19. package/dist/aun/storage/index.js +1 -2
  20. package/dist/channels/aun.js +371 -136
  21. package/dist/cli/agent.js +9 -96
  22. package/dist/cli/cli-argv.js +10 -0
  23. package/dist/cli/config.js +9 -17
  24. package/dist/cli/ctl-command.js +1 -1
  25. package/dist/cli/daemon-commands.js +39 -24
  26. package/dist/cli/fs-command.js +19 -10
  27. package/dist/cli/init.js +77 -8
  28. package/dist/cli/queue-command.js +42 -0
  29. package/dist/cli/restart-monitor.js +3 -14
  30. package/dist/cli/trigger-command.js +7 -0
  31. package/dist/config/access-policy.js +1 -2
  32. package/dist/config/builtin-roles.js +5 -0
  33. package/dist/config/config-manager.js +21 -1
  34. package/dist/config/peer-role-resolver.js +6 -2
  35. package/dist/config/role-migration-startup.js +53 -0
  36. package/dist/config/role-store.js +1 -1
  37. package/dist/core/auth/agent-delegation.js +1 -1
  38. package/dist/core/auth/auth-gateway.js +29 -1
  39. package/dist/core/auth/authorization-audit.js +15 -0
  40. package/dist/core/auth/operation-authorizer.js +1 -0
  41. package/dist/core/auth/operation-catalog.js +9 -0
  42. package/dist/core/bootstrap-messages.js +9 -2
  43. package/dist/core/bootstrap-service.js +1 -0
  44. package/dist/core/command/command-handler.js +198 -51
  45. package/dist/core/command/menu-catalog.js +4 -0
  46. package/dist/core/command/menu-handler.js +85 -18
  47. package/dist/core/command/menu-protocol.js +23 -2
  48. package/dist/core/command/slash-handler.js +58 -10
  49. package/dist/core/event-catalog.js +6 -0
  50. package/dist/core/handoff/runtime.js +12 -1
  51. package/dist/core/handoff/store.js +5 -1
  52. package/dist/core/interaction-router.js +10 -0
  53. package/dist/core/message/im-renderer.js +19 -0
  54. package/dist/core/message/message-bridge.js +63 -11
  55. package/dist/core/message/message-log.js +2 -0
  56. package/dist/core/message/message-queue.js +267 -39
  57. package/dist/core/message/message-utils.js +81 -4
  58. package/dist/core/message/response-engine.js +107 -41
  59. package/dist/core/message/stream-debouncer.js +10 -2
  60. package/dist/core/permission/approval-gateway.js +1 -0
  61. package/dist/core/permission/ec-command-parser.js +93 -14
  62. package/dist/core/permission/index.js +1 -1
  63. package/dist/core/permission/mode.js +15 -0
  64. package/dist/core/permission/readonly-shell-query.js +148 -8
  65. package/dist/core/permission/sandbox-runtime.js +21 -0
  66. package/dist/core/permission/tool-policy.js +249 -27
  67. package/dist/core/protected-paths.js +107 -2
  68. package/dist/core/session/session-manager.js +21 -2
  69. package/dist/core/session/session-mapper.js +20 -1
  70. package/dist/eck/detect.js +18 -1
  71. package/dist/eck/group-rules-sync.js +15 -44
  72. package/dist/index.js +161 -86
  73. package/dist/ipc.js +16 -3
  74. package/dist/paths.js +3 -0
  75. package/dist/trigger/feedback.js +64 -11
  76. package/dist/trigger/manager.js +21 -1
  77. package/dist/trigger/parser.js +14 -2
  78. package/dist/trigger/scheduler.js +1 -0
  79. package/dist/trigger/validation.js +67 -6
  80. package/dist/utils/ecweb-supervisor.js +332 -0
  81. package/dist/utils/error-utils.js +10 -0
  82. package/kits/docs/evolcore/trigger.md +17 -1
  83. package/kits/migrations/migrate-contact-book-v2.mjs +1 -2
  84. package/kits/schemas/role-config.schema.1.json +1 -0
  85. package/kits/templates/roles/admin.json +5 -0
  86. package/kits/templates/roles/member.json +7 -1
  87. package/kits/templates/roles/visitor.json +2 -0
  88. package/package.json +1 -1
  89. package/dist/aun/msg/payload-type.js +0 -27
  90. package/dist/aun/rpc/caller.js +0 -42
  91. package/dist/aun/rpc/connection.js +0 -25
  92. package/dist/aun/storage/manage.js +0 -10
  93. package/dist/config/access-policy-domain.js +0 -18
  94. package/dist/config/config-batch-get.js +0 -11
  95. package/dist/config/owner-policy.js +0 -4
  96. package/dist/config/role-config-v4-startup.js +0 -32
  97. package/dist/config/role-config-v5-startup.js +0 -27
  98. package/dist/core/auth/trigger-authorization.js +0 -15
  99. package/dist/core/interaction-registration.js +0 -10
  100. package/dist/core/permission/execution-sandbox.js +0 -16
  101. package/dist/core/relation/peer-key.js +0 -1
  102. package/dist/core/session/session-key.js +0 -24
  103. package/dist/eck/baseagent-caps.js +0 -18
  104. package/dist/eck/rules-loader.js +0 -28
@@ -1,4 +0,0 @@
1
- export function shouldFailFastForMissingOwners(env = process.env) {
2
- const value = (env.EVOLCORE_REQUIRE_OWNERS || '').trim().toLowerCase();
3
- return value === '1' || value === 'true' || value === 'yes';
4
- }
@@ -1,32 +0,0 @@
1
- import path from 'path';
2
- import { pathToFileURL } from 'url';
3
- import { getPackageRoot, resolvePaths } from '../paths.js';
4
- import { assertRoleConfigV4Ready, ConfigError } from './config-manager.js';
5
- /**
6
- * Automatically applies the one-off role config migration before daemon startup.
7
- * The migration script owns backup, validation, atomic writes, rollback, and locking.
8
- */
9
- export async function ensureRoleConfigV4OnStartup() {
10
- try {
11
- assertRoleConfigV4Ready();
12
- return null;
13
- }
14
- catch (error) {
15
- if (!(error instanceof ConfigError) || error.code !== 'ROLE_CONFIG_MIGRATION_REQUIRED')
16
- throw error;
17
- }
18
- const home = resolvePaths().root;
19
- const script = path.join(getPackageRoot(), 'kits', 'migrations', 'migrate-role-config-v4.mjs');
20
- try {
21
- const migration = await import(pathToFileURL(script).href);
22
- const result = migration.runMigration({ home, apply: true });
23
- assertRoleConfigV4Ready();
24
- return result;
25
- }
26
- catch (error) {
27
- const detail = error instanceof Error ? error.message : String(error);
28
- throw new ConfigError('ROLE_CONFIG_MIGRATION_FAILED', `Automatic role config v4 migration failed: ${detail}\n` +
29
- `Fix the reported config or run manually:\n` +
30
- `node kits/migrations/migrate-role-config-v4.mjs --apply --home ${JSON.stringify(home)}`, { cause: error });
31
- }
32
- }
@@ -1,27 +0,0 @@
1
- import path from 'path';
2
- import { pathToFileURL } from 'url';
3
- import { getPackageRoot, resolvePaths } from '../paths.js';
4
- import { assertRoleConfigV5Ready, ConfigError } from './config-manager.js';
5
- export async function ensureRoleConfigV5OnStartup() {
6
- try {
7
- assertRoleConfigV5Ready();
8
- return null;
9
- }
10
- catch (error) {
11
- if (!(error instanceof ConfigError) || error.code !== 'ROLE_CONFIG_V5_MIGRATION_REQUIRED')
12
- throw error;
13
- }
14
- const home = resolvePaths().root;
15
- const script = path.join(getPackageRoot(), 'kits', 'migrations', 'migrate-role-config-v5.mjs');
16
- try {
17
- const migration = await import(pathToFileURL(script).href);
18
- const result = migration.runMigration({ home, apply: true });
19
- assertRoleConfigV5Ready();
20
- return result;
21
- }
22
- catch (error) {
23
- const detail = error instanceof Error ? error.message : String(error);
24
- throw new ConfigError('ROLE_CONFIG_V5_MIGRATION_FAILED', `Automatic standalone role migration failed: ${detail}\n` +
25
- `node kits/migrations/migrate-role-config-v5.mjs --apply --home ${JSON.stringify(home)}`, { cause: error });
26
- }
27
- }
@@ -1,15 +0,0 @@
1
- const CROSS_AGENT_READ_OPERATIONS = new Set([
2
- 'trigger.list',
3
- 'trigger.show',
4
- 'trigger.history',
5
- ]);
6
- export function isCrossAgentTriggerOperationAllowed(input) {
7
- if (input.control || input.taskAgentAid === input.targetAgentAid)
8
- return true;
9
- if (!input.taskAgentAid || !input.targetManagement)
10
- return false;
11
- return CROSS_AGENT_READ_OPERATIONS.has(input.operation);
12
- }
13
- export function isCrossAgentTriggerReadOperation(operation) {
14
- return CROSS_AGENT_READ_OPERATIONS.has(operation);
15
- }
@@ -1,10 +0,0 @@
1
- /** Bind an adapter response to its runtime-owned channel identity domain. */
2
- export function registerAdapterInteractions(adapter, router) {
3
- const channelKey = adapter.channelKey;
4
- adapter.onInteraction?.(async (response) => {
5
- return router.handleAsync({ ...response, channelKey });
6
- });
7
- adapter.onInteractionInvalidated?.((interactionId, reason) => {
8
- return router.cancelFromChannel(interactionId, reason);
9
- });
10
- }
@@ -1,16 +0,0 @@
1
- import { normalizePermissionMode } from './mode.js';
2
- /**
3
- * Phase one only disables the task execution sandbox for an authenticated
4
- * owner running in bypass mode. Every other combination remains fail-closed.
5
- */
6
- export function resolvePhaseOneExecutionSandbox(permissionMode, role) {
7
- const normalizedMode = normalizePermissionMode(permissionMode).mode;
8
- const normalizedRole = role ?? undefined;
9
- const sandboxOff = normalizedMode === 'bypass' && normalizedRole === 'owner';
10
- return {
11
- permissionMode: normalizedMode,
12
- role: normalizedRole,
13
- state: sandboxOff ? 'off' : 'active',
14
- reason: sandboxOff ? 'owner-bypass' : 'phase-one-required',
15
- };
16
- }
@@ -1 +0,0 @@
1
- export * from './peer-identity.js';
@@ -1,24 +0,0 @@
1
- /**
2
- * sessionKey: agent 内部会话路由键。
3
- * 格式: channelType#urlEncode(channelId)#urlEncode(threadId)
4
- * 无话题时 threadId 固定为 'main'。
5
- */
6
- export const DEFAULT_THREAD_ID = 'main';
7
- export function formatSessionKey(channelType, channelId, threadId) {
8
- const tid = threadId || DEFAULT_THREAD_ID;
9
- return `${channelType}#${encodeURIComponent(channelId)}#${encodeURIComponent(tid)}`;
10
- }
11
- export function parseSessionKey(key) {
12
- const first = key.indexOf('#');
13
- if (first <= 0)
14
- throw new Error(`Invalid session key: ${key}`);
15
- const rest = key.slice(first + 1);
16
- const second = rest.indexOf('#');
17
- if (second <= 0)
18
- throw new Error(`Invalid session key (missing threadId): ${key}`);
19
- return {
20
- channelType: key.slice(0, first),
21
- channelId: decodeURIComponent(rest.slice(0, second)),
22
- threadId: decodeURIComponent(rest.slice(second + 1)),
23
- };
24
- }
@@ -1,18 +0,0 @@
1
- export const BASEAGENT_CAPS = {
2
- 'claude-code': {
3
- autoLoadsRules: true,
4
- supportsSystemPrompt: true,
5
- },
6
- 'claude': {
7
- autoLoadsRules: true,
8
- supportsSystemPrompt: true,
9
- },
10
- 'codex': {
11
- autoLoadsRules: false,
12
- supportsSystemPrompt: true,
13
- },
14
- 'gemini': {
15
- autoLoadsRules: false,
16
- supportsSystemPrompt: true,
17
- },
18
- };
@@ -1,28 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import { kitsRulesDir } from '../paths.js';
4
- let _cachedRules = null;
5
- export function loadRulesForInjection() {
6
- if (_cachedRules !== null)
7
- return _cachedRules;
8
- const rulesDir = kitsRulesDir();
9
- if (!fs.existsSync(rulesDir)) {
10
- _cachedRules = '';
11
- return '';
12
- }
13
- const files = fs.readdirSync(rulesDir)
14
- .filter(f => f.endsWith('.md'))
15
- .sort();
16
- const parts = [];
17
- for (const file of files) {
18
- try {
19
- parts.push(fs.readFileSync(path.join(rulesDir, file), 'utf-8'));
20
- }
21
- catch { /* skip unreadable files */ }
22
- }
23
- _cachedRules = parts.join('\n\n');
24
- return _cachedRules;
25
- }
26
- export function invalidateRulesCache() {
27
- _cachedRules = null;
28
- }