evolclaw 2.8.3 → 3.0.0

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 (105) hide show
  1. package/README.md +21 -12
  2. package/dist/agents/claude-runner.js +102 -38
  3. package/dist/agents/codex-runner.js +11 -14
  4. package/dist/agents/gemini-runner.js +10 -12
  5. package/dist/agents/resolve.js +134 -0
  6. package/dist/agents/templates.js +3 -3
  7. package/dist/aun/aid/agentmd.js +186 -0
  8. package/dist/aun/aid/client.js +134 -0
  9. package/dist/aun/aid/identity.js +131 -0
  10. package/dist/aun/aid/index.js +3 -0
  11. package/dist/aun/aid/types.js +1 -0
  12. package/dist/aun/aid/validation.js +21 -0
  13. package/dist/aun/msg/group.js +291 -0
  14. package/dist/aun/msg/index.js +4 -0
  15. package/dist/aun/msg/p2p.js +144 -0
  16. package/dist/aun/msg/payload-type.js +27 -0
  17. package/dist/aun/msg/upload.js +98 -0
  18. package/dist/aun/outbox.js +138 -0
  19. package/dist/aun/rpc/caller.js +42 -0
  20. package/dist/aun/rpc/connection.js +34 -0
  21. package/dist/aun/rpc/index.js +2 -0
  22. package/dist/aun/storage/download.js +29 -0
  23. package/dist/aun/storage/index.js +3 -0
  24. package/dist/aun/storage/manage.js +10 -0
  25. package/dist/aun/storage/upload.js +35 -0
  26. package/dist/channels/aun.js +1051 -288
  27. package/dist/channels/dingtalk.js +58 -5
  28. package/dist/channels/feishu.js +266 -30
  29. package/dist/channels/qqbot.js +67 -12
  30. package/dist/channels/wechat.js +61 -4
  31. package/dist/channels/wecom.js +58 -5
  32. package/dist/cli/agent.js +800 -0
  33. package/dist/cli/index.js +4253 -0
  34. package/dist/{utils → cli}/init-channel.js +211 -621
  35. package/dist/cli/init.js +178 -0
  36. package/dist/config-store.js +613 -0
  37. package/dist/core/{agent-loader.js → baseagent-loader.js} +6 -12
  38. package/dist/core/channel-loader.js +162 -11
  39. package/dist/core/command-handler.js +858 -847
  40. package/dist/core/evolagent-registry.js +191 -371
  41. package/dist/core/evolagent.js +203 -234
  42. package/dist/core/interaction-router.js +52 -5
  43. package/dist/core/message/im-renderer.js +480 -0
  44. package/dist/core/message/items-formatter.js +61 -0
  45. package/dist/core/message/message-bridge.js +104 -56
  46. package/dist/core/message/message-log.js +91 -0
  47. package/dist/core/message/message-processor.js +309 -142
  48. package/dist/core/message/message-queue.js +3 -3
  49. package/dist/core/permission.js +21 -8
  50. package/dist/core/session/adapters/codex-session-file-adapter.js +24 -2
  51. package/dist/core/session/session-fs-store.js +230 -0
  52. package/dist/core/session/session-manager.js +704 -775
  53. package/dist/core/session/session-mapper.js +87 -0
  54. package/dist/core/trigger/manager.js +122 -0
  55. package/dist/core/trigger/parser.js +128 -0
  56. package/dist/core/trigger/scheduler.js +224 -0
  57. package/dist/{templates → data}/prompts.md +34 -1
  58. package/dist/index.js +431 -275
  59. package/dist/ipc.js +49 -0
  60. package/dist/paths.js +82 -9
  61. package/dist/types.js +8 -2
  62. package/dist/utils/atomic-write.js +79 -0
  63. package/dist/utils/channel-helpers.js +46 -0
  64. package/dist/utils/cross-platform.js +0 -18
  65. package/dist/utils/instance-registry.js +433 -0
  66. package/dist/utils/log-writer.js +216 -0
  67. package/dist/utils/logger.js +24 -77
  68. package/dist/utils/media-cache.js +23 -0
  69. package/dist/utils/{upgrade.js → npm-ops.js} +52 -21
  70. package/dist/utils/process-introspect.js +144 -0
  71. package/dist/utils/stats.js +192 -0
  72. package/dist/watch-msg.js +529 -0
  73. package/evolclaw-install-aun.md +114 -46
  74. package/kits/aun/meta.md +25 -0
  75. package/kits/aun/role.md +25 -0
  76. package/kits/channels/aun.md +25 -0
  77. package/kits/evolclaw/commands.md +31 -0
  78. package/kits/evolclaw/identity-tools.md +26 -0
  79. package/kits/evolclaw/self-summary.md +29 -0
  80. package/kits/evolclaw/tools.md +25 -0
  81. package/kits/templates/group.md +20 -0
  82. package/kits/templates/private.md +9 -0
  83. package/kits/templates/system-fragments/personal-context.md +3 -0
  84. package/kits/templates/system-fragments/self-intro.md +5 -0
  85. package/kits/templates/system-fragments/speaker-intro.md +5 -0
  86. package/kits/templates/system-fragments/venue-intro.md +5 -0
  87. package/package.json +7 -5
  88. package/data/evolclaw.sample.json +0 -60
  89. package/dist/channels/aun-ops.js +0 -275
  90. package/dist/cli.js +0 -2178
  91. package/dist/config.js +0 -591
  92. package/dist/core/agent-registry.js +0 -450
  93. package/dist/core/evolagent-schema.js +0 -72
  94. package/dist/core/message/stream-flusher.js +0 -238
  95. package/dist/core/message/thought-emitter.js +0 -162
  96. package/dist/core/reload-hooks.js +0 -87
  97. package/dist/prompts/templates.js +0 -122
  98. package/dist/templates/skills.md +0 -66
  99. package/dist/utils/channel-fingerprint.js +0 -59
  100. package/dist/utils/error-dict.js +0 -63
  101. package/dist/utils/format.js +0 -32
  102. package/dist/utils/init.js +0 -645
  103. package/dist/utils/migrate-project.js +0 -122
  104. package/dist/utils/reload-hooks.js +0 -87
  105. package/dist/utils/stats-collector.js +0 -99
@@ -0,0 +1,42 @@
1
+ import { createShortConnection } from './connection.js';
2
+ export async function rpcCall(aid, method, params, opts) {
3
+ const conn = await createShortConnection(aid, opts);
4
+ try {
5
+ const result = await conn.call(method, params);
6
+ return { ok: true, result };
7
+ }
8
+ catch (e) {
9
+ if (e.code !== undefined && e.message !== undefined) {
10
+ return { ok: false, error: { code: e.code, message: e.message, data: e.data } };
11
+ }
12
+ return { ok: false, error: { code: -1, message: String(e.message || e) } };
13
+ }
14
+ finally {
15
+ await conn.close();
16
+ }
17
+ }
18
+ export async function rpcBatch(aid, calls, opts) {
19
+ const conn = await createShortConnection(aid, opts);
20
+ const results = [];
21
+ try {
22
+ for (const { method, params } of calls) {
23
+ try {
24
+ const result = await conn.call(method, params);
25
+ results.push({ ok: true, result });
26
+ }
27
+ catch (e) {
28
+ if (e.code !== undefined && e.message !== undefined) {
29
+ results.push({ ok: false, error: { code: e.code, message: e.message, data: e.data } });
30
+ }
31
+ else {
32
+ results.push({ ok: false, error: { code: -1, message: String(e.message || e) } });
33
+ }
34
+ break; // stop on first failure
35
+ }
36
+ }
37
+ }
38
+ finally {
39
+ await conn.close();
40
+ }
41
+ return results;
42
+ }
@@ -0,0 +1,34 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import os from 'os';
4
+ export async function createShortConnection(aid, opts) {
5
+ const aunPath = opts?.aunPath ?? path.join(os.homedir(), '.aun');
6
+ const slotId = opts?.slotId ?? '';
7
+ const caCertPath = path.join(aunPath, 'CA', 'root', 'root.crt');
8
+ const { AUNClient } = await import('@agentunion/fastaun');
9
+ const clientOpts = { aun_path: aunPath, debug: false };
10
+ if (fs.existsSync(caCertPath))
11
+ clientOpts.root_ca_path = caCertPath;
12
+ const client = new AUNClient(clientOpts);
13
+ await client.auth.createAid({ aid });
14
+ const authResult = await client.auth.authenticate({ aid });
15
+ const accessToken = authResult?.access_token ?? client._access_token;
16
+ const gateway = client._gatewayUrl ?? authResult?.gateway;
17
+ await client.connect({
18
+ access_token: accessToken,
19
+ gateway,
20
+ slot_id: slotId,
21
+ connection_kind: 'short',
22
+ }, { auto_reconnect: false });
23
+ return {
24
+ async call(method, params) {
25
+ return client.call(method, params);
26
+ },
27
+ async close() {
28
+ try {
29
+ await client.close();
30
+ }
31
+ catch { /* ignore */ }
32
+ },
33
+ };
34
+ }
@@ -0,0 +1,2 @@
1
+ export { rpcCall, rpcBatch } from './caller.js';
2
+ export { createShortConnection } from './connection.js';
@@ -0,0 +1,29 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { rpcCall } from '../rpc/index.js';
4
+ export async function storageDownload(aid, url, localPath, opts) {
5
+ // Parse URL: strip https:// prefix, split into owner + path
6
+ const cleaned = url.replace(/^https?:\/\//, '');
7
+ const slashIdx = cleaned.indexOf('/');
8
+ if (slashIdx === -1) {
9
+ return { ok: false, localPath: '', size: 0, error: 'URL 格式错误,需要 <owner-aid>/<path>' };
10
+ }
11
+ const ownerAid = cleaned.slice(0, slashIdx);
12
+ const objectKey = cleaned.slice(slashIdx + 1);
13
+ const ticketResult = await rpcCall(aid, 'storage.create_download_ticket', {
14
+ owner: ownerAid,
15
+ object_key: objectKey,
16
+ }, { aunPath: opts?.aunPath });
17
+ if (!ticketResult.ok) {
18
+ return { ok: false, localPath: '', size: 0, error: JSON.stringify(ticketResult.error) };
19
+ }
20
+ const downloadUrl = ticketResult.result.download_url;
21
+ const resp = await fetch(downloadUrl);
22
+ if (!resp.ok) {
23
+ return { ok: false, localPath: '', size: 0, error: `HTTP GET failed: ${resp.status}` };
24
+ }
25
+ const buffer = Buffer.from(await resp.arrayBuffer());
26
+ const outPath = localPath ?? path.basename(objectKey);
27
+ fs.writeFileSync(outPath, buffer);
28
+ return { ok: true, localPath: outPath, size: buffer.length };
29
+ }
@@ -0,0 +1,3 @@
1
+ export { storageUpload } from './upload.js';
2
+ export { storageDownload } from './download.js';
3
+ export { storageLs, storageRm, storageQuota } from './manage.js';
@@ -0,0 +1,10 @@
1
+ import { rpcCall } from '../rpc/caller.js';
2
+ export async function storageLs(aid, prefix, opts) {
3
+ return rpcCall(aid, 'storage.list_objects', { prefix: prefix || '' }, { aunPath: opts?.aunPath });
4
+ }
5
+ export async function storageRm(aid, remotePath, opts) {
6
+ return rpcCall(aid, 'storage.delete_object', { object_key: remotePath }, { aunPath: opts?.aunPath });
7
+ }
8
+ export async function storageQuota(aid, opts) {
9
+ return rpcCall(aid, 'storage.get_quota', {}, { aunPath: opts?.aunPath });
10
+ }
@@ -0,0 +1,35 @@
1
+ import fs from 'fs';
2
+ import crypto from 'crypto';
3
+ import { rpcCall } from '../rpc/index.js';
4
+ export async function storageUpload(aid, localFile, remotePath, opts) {
5
+ const fileBuffer = fs.readFileSync(localFile);
6
+ const contentType = 'application/octet-stream';
7
+ const sha256 = crypto.createHash('sha256').update(fileBuffer).digest('hex');
8
+ const createResult = await rpcCall(aid, 'storage.create_upload_session', {
9
+ object_key: remotePath,
10
+ content_type: contentType,
11
+ content_length: fileBuffer.length,
12
+ is_private: !(opts?.isPublic),
13
+ }, { aunPath: opts?.aunPath });
14
+ if (!createResult.ok) {
15
+ return { ok: false, objectKey: remotePath, error: JSON.stringify(createResult.error) };
16
+ }
17
+ const uploadUrl = createResult.result.upload_url;
18
+ const putResp = await fetch(uploadUrl, {
19
+ method: 'PUT',
20
+ headers: { 'Content-Type': contentType },
21
+ body: new Blob([fileBuffer]),
22
+ redirect: 'follow',
23
+ });
24
+ if (!putResp.ok) {
25
+ return { ok: false, objectKey: remotePath, error: `HTTP PUT failed: ${putResp.status}` };
26
+ }
27
+ const completeResult = await rpcCall(aid, 'storage.complete_upload', {
28
+ object_key: remotePath,
29
+ sha256,
30
+ }, { aunPath: opts?.aunPath });
31
+ if (!completeResult.ok) {
32
+ return { ok: false, objectKey: remotePath, error: JSON.stringify(completeResult.error) };
33
+ }
34
+ return { ok: true, objectKey: remotePath };
35
+ }