evolcore 0.0.10 → 0.0.12

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 (131) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +3 -3
  3. package/bin/codex-managed-hook.mjs +80 -0
  4. package/dist/agents/baseagent.js +4 -0
  5. package/dist/agents/claude-runner.js +158 -44
  6. package/dist/agents/codex-app-server-client.js +153 -23
  7. package/dist/agents/codex-runner.js +331 -43
  8. package/dist/agents/ecagent-runner.js +53 -6
  9. package/dist/agents/gemini-runner.js +1 -0
  10. package/dist/agents/request-identity.js +55 -0
  11. package/dist/aun/aid/client.js +11 -21
  12. package/dist/aun/aid/managed-operation.js +107 -0
  13. package/dist/aun/msg/group.js +81 -12
  14. package/dist/aun/msg/managed-operation.js +804 -0
  15. package/dist/aun/msg/mention-schema.js +20 -0
  16. package/dist/aun/msg/p2p.js +7 -0
  17. package/dist/aun/outbox.js +28 -31
  18. package/dist/channels/aun.js +418 -235
  19. package/dist/channels/daemon.js +13 -0
  20. package/dist/cli/agent-command.js +72 -17
  21. package/dist/cli/agent.js +249 -22
  22. package/dist/cli/aun-commands.js +270 -69
  23. package/dist/cli/bench.js +12 -3
  24. package/dist/cli/daemon-commands.js +52 -33
  25. package/dist/cli/fs-command.js +60 -0
  26. package/dist/cli/handoff-command.js +3 -0
  27. package/dist/cli/index.js +106 -63
  28. package/dist/cli/init-cancel.js +208 -0
  29. package/dist/cli/init-channel.js +343 -195
  30. package/dist/cli/init.js +21 -9
  31. package/dist/cli/managed-command-guard.js +41 -0
  32. package/dist/cli/model.js +11 -4
  33. package/dist/cli/queue-command.js +11 -1
  34. package/dist/cli/response.js +71 -0
  35. package/dist/cli/restart-monitor.js +4 -18
  36. package/dist/cli/trigger-command.js +4 -0
  37. package/dist/config/builtin-roles.js +5 -0
  38. package/dist/config/contact-book-store.js +11 -3
  39. package/dist/config/contact-request-service.js +161 -15
  40. package/dist/config/gateway-config.js +26 -10
  41. package/dist/config/mention-mode.js +8 -24
  42. package/dist/core/agent-reload-coordinator.js +53 -0
  43. package/dist/core/auth/agent-delegation.js +0 -1
  44. package/dist/core/auth/operation-authorizer.js +62 -154
  45. package/dist/core/auth/operation-catalog.js +264 -22
  46. package/dist/core/bootstrap-messages.js +68 -0
  47. package/dist/core/bootstrap-service.js +144 -10
  48. package/dist/core/capability/providers/claude-capability-provider.js +9 -31
  49. package/dist/core/capability/providers/codex-capability-provider.js +4 -15
  50. package/dist/core/capability/skill-discovery.js +55 -0
  51. package/dist/core/channel-loader.js +24 -7
  52. package/dist/core/command/agent-control.js +14 -11
  53. package/dist/core/command/cli-intent-parser.js +9 -0
  54. package/dist/core/command/command-handler.js +467 -6
  55. package/dist/core/command/connect-menu.js +15 -0
  56. package/dist/core/command/group-menu.js +4 -4
  57. package/dist/core/command/menu-catalog.js +366 -0
  58. package/dist/core/command/menu-handler.js +213 -110
  59. package/dist/core/command/menu-protocol.js +71 -0
  60. package/dist/core/command/slash-gate.js +5 -2
  61. package/dist/core/command/slash-handler.js +45 -25
  62. package/dist/core/daemon-file-cache.js +2 -1
  63. package/dist/core/data-migration.js +9 -2
  64. package/dist/core/evolagent-registry.js +125 -35
  65. package/dist/core/evolagent.js +12 -5
  66. package/dist/core/handoff/dispatcher.js +5 -2
  67. package/dist/core/handoff/runtime.js +145 -21
  68. package/dist/core/handoff/store.js +24 -0
  69. package/dist/core/handoff/types.js +1 -0
  70. package/dist/core/inference/text-inference.js +38 -4
  71. package/dist/core/message/logical-queue-bridge.js +1 -0
  72. package/dist/core/message/mention-schema.js +126 -0
  73. package/dist/core/message/message-bridge.js +237 -79
  74. package/dist/core/message/message-log.js +23 -0
  75. package/dist/core/message/message-queue.js +20 -4
  76. package/dist/core/message/response-engine.js +54 -36
  77. package/dist/core/model/model-catalog.js +143 -24
  78. package/dist/core/model/model-diagnostics.js +28 -10
  79. package/dist/core/permission/ec-command-parser.js +156 -10
  80. package/dist/core/permission/index.js +1 -0
  81. package/dist/core/permission/readonly-shell-query.js +532 -0
  82. package/dist/core/permission/sandbox-runtime.js +22 -1
  83. package/dist/core/permission/shell-environment.js +46 -0
  84. package/dist/core/permission/tool-policy.js +292 -111
  85. package/dist/core/protected-paths.js +17 -9
  86. package/dist/core/runner-reload-transaction.js +57 -0
  87. package/dist/core/session/session-manager.js +21 -2
  88. package/dist/eck/manifest-engine.js +39 -13
  89. package/dist/index.js +644 -180
  90. package/dist/ipc.js +246 -19
  91. package/dist/response-system/coordinator.js +6 -4
  92. package/dist/response-system/engines/v1/proactive-flow.js +26 -8
  93. package/dist/response-system/modes/single-session/index.js +14 -1
  94. package/dist/response-system/selector.js +6 -5
  95. package/dist/trigger/anomaly-store.js +4 -0
  96. package/dist/trigger/script-executor.js +1 -0
  97. package/dist/utils/aid-bind.js +3 -8
  98. package/dist/utils/codex-app-server-registry.js +90 -0
  99. package/dist/utils/codex-cli.js +5 -1
  100. package/dist/utils/cross-platform.js +15 -0
  101. package/dist/utils/log-writer.js +6 -10
  102. package/dist/utils/logger.js +5 -5
  103. package/dist/utils/npm-ops.js +5 -12
  104. package/dist/utils/tool-summary.js +11 -0
  105. package/kits/docs/channels/aun.md +1 -1
  106. package/kits/docs/context-assembly.md +2 -2
  107. package/kits/docs/evolcore/agent.md +11 -6
  108. package/kits/docs/evolcore/aid.md +14 -0
  109. package/kits/docs/evolcore/msg.md +13 -0
  110. package/kits/docs/prompt-loading-architecture.md +1 -2
  111. package/kits/docs/venues/group.md +1 -1
  112. package/kits/eck_manifest.json +0 -12
  113. package/kits/rules/01-overview.md +9 -0
  114. package/kits/rules/04-relation.md +1 -1
  115. package/kits/rules/05-venue.md +2 -2
  116. package/kits/schemas/agent-config.schema.3.json +1 -1
  117. package/kits/schemas/agent-config.schema.4.json +1 -1
  118. package/kits/schemas/relation-config.schema.2.json +1 -1
  119. package/kits/schemas/role-config.schema.1.json +1 -1
  120. package/kits/schemas/single-session.schema.1.json +3 -3
  121. package/kits/schemas/single-session.schema.2.json +3 -3
  122. package/kits/templates/roles/admin.json +27 -0
  123. package/kits/templates/roles/member.json +44 -0
  124. package/kits/templates/roles/visitor.json +40 -2
  125. package/kits/templates/system-fragments/bootstrap.md +12 -6
  126. package/kits/templates/system-fragments/channel.md +6 -0
  127. package/kits/templates/system-fragments/session.md +2 -0
  128. package/package.json +3 -2
  129. package/skills/eclink/SKILL.md +15 -3
  130. package/skills/eclink/agents/openai.yaml +3 -3
  131. package/dist/core/command/evol-menu-version-gate.js +0 -39
@@ -1,4 +1,11 @@
1
1
  const HEAD_EXECUTABLES = new Set(['head', '/bin/head', '/usr/bin/head']);
2
+ // Codex app-server sends command executions through a fixed shell carrier.
3
+ // Treat the carrier as syntax only after parsing it as literal argv; never
4
+ // accept an arbitrary `sh -c` string or unwrap shell composition here.
5
+ const CODEX_SHELL_EXECUTABLES = new Set([
6
+ 'bash', '/bin/bash', '/usr/bin/bash',
7
+ 'sh', '/bin/sh', '/usr/bin/sh',
8
+ ]);
2
9
  const SHELL_UNQUOTED_META = new Set([
3
10
  ';', '&', '|', '`', '<', '>', '$', '(', ')', '*', '?', '[', ']', '{', '}', '#',
4
11
  ]);
@@ -135,6 +142,42 @@ export function parseLiteralShellArgv(command) {
135
142
  const result = parseLiteralShellCommand(command);
136
143
  return result.ok ? result.argv : null;
137
144
  }
145
+ /**
146
+ * Return the command string carried by Codex's literal `/bin/bash -lc ...`
147
+ * wrapper. The wrapper is accepted only in its exact three-argv form and the
148
+ * caller must parse the returned string with the literal shell parser again.
149
+ */
150
+ export function unwrapCodexShellCommandArgv(argv) {
151
+ if (argv.length !== 3 || argv[1] !== '-lc')
152
+ return undefined;
153
+ return CODEX_SHELL_EXECUTABLES.has(argv[0]) ? argv[2] : undefined;
154
+ }
155
+ /**
156
+ * Parse either a bare literal command or the exact shell carrier emitted by
157
+ * Codex app-server. This does not make shell composition safe: the nested
158
+ * command still has to pass `parseLiteralShellCommand`.
159
+ */
160
+ export function parseCodexShellCommandArgv(command) {
161
+ const outer = parseLiteralShellArgv(command);
162
+ if (!outer)
163
+ return null;
164
+ const wrapped = unwrapCodexShellCommandArgv(outer);
165
+ return wrapped === undefined ? outer : parseLiteralShellArgv(wrapped);
166
+ }
167
+ /**
168
+ * Resolve a Codex command input while preserving the raw `commandArgv` form
169
+ * supplied by app-server. Joining that argv with spaces loses the quoting of
170
+ * the inner `-lc` command and was the source of a false proactive denial.
171
+ */
172
+ export function parseCodexToolCommandArgv(input) {
173
+ if (Array.isArray(input.commandArgv) && input.commandArgv.every(value => typeof value === 'string')) {
174
+ const outer = input.commandArgv;
175
+ const wrapped = unwrapCodexShellCommandArgv(outer);
176
+ return wrapped === undefined ? outer : parseLiteralShellArgv(wrapped);
177
+ }
178
+ const command = typeof input.command === 'string' ? input.command : '';
179
+ return parseCodexShellCommandArgv(command);
180
+ }
138
181
  function scanBoundedOutputOperators(command) {
139
182
  const operators = [];
140
183
  let quote = null;
@@ -314,9 +357,18 @@ export function parseBoundedOutputShellCommand(command) {
314
357
  export function classifyEvolcoreShellCommand(command) {
315
358
  const literal = parseLiteralShellCommand(command);
316
359
  if (literal.ok) {
317
- return literal.argv[0] === 'ec'
318
- ? { kind: 'literal' }
319
- : { kind: 'none' };
360
+ if (literal.argv[0] === 'ec')
361
+ return { kind: 'literal' };
362
+ const wrapped = unwrapCodexShellCommandArgv(literal.argv);
363
+ if (wrapped !== undefined) {
364
+ const nested = parseLiteralShellCommand(wrapped);
365
+ if (nested.ok && nested.argv[0] === 'ec')
366
+ return { kind: 'literal' };
367
+ if (!nested.ok && EVOLCORE_COMMAND_POSITION_RE.test(wrapped)) {
368
+ return { kind: 'composite', issue: nested.issue };
369
+ }
370
+ }
371
+ return { kind: 'none' };
320
372
  }
321
373
  const boundedOutput = parseBoundedOutputShellCommand(command);
322
374
  if (boundedOutput && boundedOutput.argv[0] === 'ec') {
@@ -350,8 +402,81 @@ function findSingleFileOption(argv, startIndex) {
350
402
  ? { path: filePath, invalid: false }
351
403
  : { invalid: true };
352
404
  }
353
- export function parseEvolcoreSendCommand(command) {
354
- const argv = parseLiteralShellArgv(command);
405
+ const PROACTIVE_SEND_VALUE_FLAGS = new Set([
406
+ '--format', '--app', '--file', '--text-from-file', '--link', '--payload',
407
+ '--title', '--description', '--text', '--transcript', '--as',
408
+ '--content-type', '--mention', '--aun-path', '--thread', '--return',
409
+ ]);
410
+ const PROACTIVE_SEND_BOOLEAN_FLAGS = new Set([
411
+ '--encrypt', '--no-encrypt', '--mention-all',
412
+ ]);
413
+ function hasExecutableProactiveSendPayload(argv, scope) {
414
+ if (!argv || argv[0] !== 'ec' || argv[1] !== scope || argv[2] !== 'send')
415
+ return false;
416
+ const positionals = [];
417
+ const modes = new Map();
418
+ let endOfOptions = false;
419
+ for (let index = 5; index < argv.length; index++) {
420
+ const value = argv[index];
421
+ if (endOfOptions) {
422
+ positionals.push(value);
423
+ continue;
424
+ }
425
+ if (value === '--') {
426
+ endOfOptions = true;
427
+ continue;
428
+ }
429
+ if (PROACTIVE_SEND_BOOLEAN_FLAGS.has(value))
430
+ continue;
431
+ if (!PROACTIVE_SEND_VALUE_FLAGS.has(value)) {
432
+ positionals.push(value);
433
+ continue;
434
+ }
435
+ const operand = argv[++index];
436
+ if (operand === undefined || operand.startsWith('--'))
437
+ return false;
438
+ if (value === '--file' || value === '--text-from-file')
439
+ return false;
440
+ if (value === '--app' || value === '--aun-path')
441
+ return false;
442
+ if (value === '--return' && operand !== 'none' && operand !== 'required')
443
+ return false;
444
+ if (value === '--format' && operand !== 'json')
445
+ return false;
446
+ if (value === '--link') {
447
+ if (scope !== 'msg' || modes.has('link'))
448
+ return false;
449
+ modes.set('link', operand);
450
+ }
451
+ if (value === '--payload') {
452
+ if (modes.has('payload'))
453
+ return false;
454
+ modes.set('payload', operand);
455
+ }
456
+ }
457
+ if (modes.size > 1)
458
+ return false;
459
+ if (modes.has('link')) {
460
+ try {
461
+ const url = new URL(modes.get('link'));
462
+ return url.protocol === 'http:' || url.protocol === 'https:';
463
+ }
464
+ catch {
465
+ return false;
466
+ }
467
+ }
468
+ if (modes.has('payload')) {
469
+ try {
470
+ const payload = JSON.parse(modes.get('payload'));
471
+ return !!payload && typeof payload === 'object' && !Array.isArray(payload);
472
+ }
473
+ catch {
474
+ return false;
475
+ }
476
+ }
477
+ return positionals.join(' ').length > 0;
478
+ }
479
+ function parseEvolcoreSendArgv(argv) {
355
480
  if (!argv || argv[0] !== 'ec')
356
481
  return null;
357
482
  if (argv[1] === 'ctl') {
@@ -380,23 +505,44 @@ export function parseEvolcoreSendCommand(command) {
380
505
  if (subcommand === 'file') {
381
506
  if (argv.length !== 6 || !isDeterministicFilePath(argv[5]))
382
507
  return null;
383
- return { scope, action: 'file', targetId, filePath: argv[5] };
508
+ return { scope, action: 'file', sourceId: argv[3], targetId, filePath: argv[5] };
384
509
  }
385
510
  const fileOption = findSingleFileOption(argv, 5);
386
511
  if (fileOption.invalid)
387
512
  return null;
388
513
  return fileOption.path
389
- ? { scope, action: 'file', targetId, filePath: fileOption.path }
390
- : { scope, action: 'send', targetId };
514
+ ? { scope, action: 'file', sourceId: argv[3], targetId, filePath: fileOption.path }
515
+ : { scope, action: 'send', sourceId: argv[3], targetId };
516
+ }
517
+ export function parseEvolcoreSendCommand(command) {
518
+ const argv = parseCodexShellCommandArgv(command);
519
+ return argv ? parseEvolcoreSendArgv(argv) : null;
391
520
  }
392
521
  export function isEvolcoreSendCommandForSession(toolName, input, channelId) {
393
522
  if (toolName !== 'Bash')
394
523
  return false;
395
- const cmd = typeof input.command === 'string' ? input.command : '';
396
- const parsed = parseEvolcoreSendCommand(cmd);
524
+ const argv = parseCodexToolCommandArgv(input);
525
+ const parsed = argv ? parseEvolcoreSendArgv(argv) : null;
397
526
  if (!parsed)
398
527
  return false;
399
528
  if (parsed.scope === 'ctl')
400
529
  return true;
401
530
  return parsed.targetId === channelId;
402
531
  }
532
+ /** Proactive first-send guard: exact channel kind and current target only. */
533
+ export function isExactEvolcoreSendCommandForSession(toolName, input, channelId, chatType, selfAid) {
534
+ // Codex hooks use the canonical name `Bash`; the app-server event adapter
535
+ // exposes the same commandExecution items as `Shell` to the renderer.
536
+ if ((toolName !== 'Bash' && toolName !== 'Shell') || !selfAid)
537
+ return false;
538
+ const argv = parseCodexToolCommandArgv(input);
539
+ const parsed = argv ? parseEvolcoreSendArgv(argv) : null;
540
+ if (!parsed || parsed.action !== 'send')
541
+ return false;
542
+ const expectedScope = chatType === 'group' ? 'group' : 'msg';
543
+ return parsed.scope === expectedScope
544
+ && parsed.targetId === channelId
545
+ && parsed.sourceId === selfAid
546
+ && !!argv
547
+ && hasExecutableProactiveSendPayload(argv, expectedScope);
548
+ }
@@ -1,5 +1,6 @@
1
1
  export * from './tool-policy.js';
2
2
  export * from './ec-command-parser.js';
3
+ export * from './readonly-shell-query.js';
3
4
  export * from './approval-gateway.js';
4
5
  export * from './execution-sandbox.js';
5
6
  // Tool summaries live in utils; keep the historical permission import path compatible.