evolcore 0.0.48 → 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 +34 -0
- package/dist/agent-template/runtime.js +5 -2
- package/dist/agents/codex-runner.js +5 -1
- package/dist/aun/msg/p2p.js +2 -1
- package/dist/build-identity.json +1 -1
- package/dist/channels/aun.js +643 -273
- package/dist/cli/directory.js +6 -1
- package/dist/cli/index.js +7 -1
- package/dist/cli/managed-command-guard.js +2 -0
- package/dist/cli/model.js +20 -5
- package/dist/cli/quota.js +89 -0
- package/dist/cli/role.js +1 -0
- package/dist/cli/services-command.js +1 -0
- package/dist/cli/team-workspace-command.js +56 -2
- package/dist/config/config-field-policy.js +71 -1
- package/dist/config/config-manager.js +11 -1
- package/dist/config/providers-config.js +8 -4
- package/dist/config/providers-management.js +11 -3
- package/dist/config/resolved-config-op.js +3 -2
- package/dist/core/auth/delegation-authorization.js +33 -26
- package/dist/core/auth/operation-catalog.js +9 -0
- package/dist/core/command/cli-intent-parser.js +13 -0
- package/dist/core/command/command-handler.js +45 -2
- package/dist/core/command/menu-handler.js +6 -1
- package/dist/core/command/menu-protocol.js +24 -0
- package/dist/core/command/remote-shell.js +565 -0
- package/dist/core/daemon-control.js +57 -1
- package/dist/core/daemon-lifecycle.js +16 -2
- package/dist/core/evolagent-registry.js +6 -2
- package/dist/core/ipc-registration.js +1 -0
- package/dist/core/message/aun-ipc-sender.js +118 -56
- 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 +40 -1
- package/dist/core/message/message-admission.js +5 -39
- package/dist/core/message/message-bridge.js +92 -39
- package/dist/core/message/message-log.js +24 -0
- package/dist/core/message/message-queue.js +97 -15
- package/dist/core/message/response-engine.js +151 -18
- package/dist/core/model/config-scope.js +6 -14
- package/dist/core/model/model-diagnostics.js +19 -0
- package/dist/core/model/model-fallback.js +13 -2
- 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/services-path-acl.js +451 -0
- package/dist/core/permission/tool-policy.js +5 -1
- package/dist/core/relation/peer-identity.js +13 -0
- package/dist/core/task/task-recovery-service.js +1 -0
- package/dist/core/thread/topic-id.js +15 -0
- package/dist/directory/owner-directory-admission.js +11 -8
- package/dist/directory/owner-directory-cache.js +19 -0
- package/dist/directory/owner-directory-markdown.js +1 -1
- package/dist/directory/owner-directory-policy.js +5 -30
- package/dist/directory/owner-directory-request-operation.js +5 -2
- package/dist/eck/kit-renderer.js +1 -1
- package/dist/eck/message-renderer.js +28 -5
- package/dist/ecweb/runtime/supervisor.js +36 -8
- 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 +20 -5
- package/dist/event-center/runtime.js +10 -7
- package/dist/index.js +4 -0
- package/dist/ipc.js +25 -1
- package/dist/outputs/authorization.js +16 -0
- package/dist/outputs/cards.js +336 -0
- package/dist/outputs/events.js +3 -2
- package/dist/outputs/protocol.js +1 -0
- package/dist/outputs/service.js +2 -15
- package/dist/services/index.js +29 -5
- package/dist/services/ipc-operation.js +84 -0
- package/dist/services/pack-manager.js +1 -0
- package/dist/services/service-payload.js +13 -7
- package/dist/stats/budget.js +1 -1
- package/dist/stats/model-resolver.js +2 -2
- package/dist/stats/quota-query.js +95 -0
- package/dist/trigger/script-sandbox.js +12 -0
- package/dist/utils/atomic-write.js +22 -8
- package/dist/utils/evolcore-version.js +2 -2
- package/dist/utils/host-info.js +100 -1
- package/dist/utils/npm-ops.js +43 -8
- package/dist/workbench/service.js +1 -1
- package/kits/docs/evolcore/INDEX.md +2 -0
- package/kits/docs/evolcore/aid.md +25 -0
- package/kits/docs/evolcore/config.md +4 -1
- package/kits/docs/evolcore/directory.md +8 -9
- package/kits/docs/evolcore/msg.md +9 -0
- package/kits/docs/evolcore/provider.md +1 -1
- package/kits/docs/evolcore/quota.md +54 -0
- package/kits/docs/evolcore/role.md +3 -0
- package/kits/docs/evolcore/stats.md +2 -0
- package/kits/docs/evolcore/trigger.md +2 -0
- package/kits/schemas/agent-config.schema.20.json +24 -0
- package/kits/skills/.switches.json +4 -0
- package/kits/skills/agent-output-cards/SKILL.md +57 -0
- package/kits/skills/ec-provider/SKILL.md +57 -8
- package/kits/templates/roles/visitor.json +1 -0
- package/kits/templates/system-fragments/commands.md +1 -0
- package/kits/templates/system-fragments/directory-contacts.md +3 -4
- package/kits/templates/system-fragments/thread.md +1 -0
- package/kits/templates/system-fragments/venue.md +11 -0
- package/package.json +2 -2
- package/scripts/agent-template/inspect.mjs +46 -10
- package/scripts/agent-template/shared/common.mjs +9 -3
- package/scripts/agent-template/shared/team-schema.json +6 -4
- package/scripts/agent-template/shared/template-contract.mjs +60 -10
- package/scripts/agent-template/shared/template-package.mjs +182 -21
- package/scripts/agent-template/shared/template-runtime.mjs +35 -2
- package/scripts/agent-template/shared/template.mjs +2 -2
- package/scripts/agent-template/team-pack.mjs +46 -11
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { parseAgentWelcomeArgs, parseInitializationArgs, resolveAgentCreateMode } from '../../cli/agent-create.js';
|
|
2
2
|
import { parseOwnershipCommand } from '../../aun/aid/ownership-operation.js';
|
|
3
3
|
import { normalizeCliArgv } from '../../cli/cli-argv.js';
|
|
4
|
+
import { parseQuotaCommand } from '../../stats/quota-query.js';
|
|
4
5
|
import { resolveConfigCommand, } from '../../config/resolved-config-op.js';
|
|
5
6
|
import { getOperationMeta } from '../auth/operation-catalog.js';
|
|
6
7
|
export { normalizeCliArgv, parseLegacyCliCommand, validateCliArgv } from '../../cli/cli-argv.js';
|
|
@@ -34,6 +35,18 @@ export function parseCliIntent(inputArgv, source = 'menu.cli', options = {}) {
|
|
|
34
35
|
result = parseConfigCommand(argv, source, options.defaultRelation);
|
|
35
36
|
else if (cmd === 'stats')
|
|
36
37
|
result = parseStatsCommand(argv, source);
|
|
38
|
+
else if (cmd === 'quota') {
|
|
39
|
+
try {
|
|
40
|
+
const command = parseQuotaCommand(argv);
|
|
41
|
+
result = recognized('quota.read', 'relation', source, {
|
|
42
|
+
...(command.selfAid ? { self: command.selfAid, targetAgentAid: command.selfAid } : {}),
|
|
43
|
+
...(command.peerKey ? { peer: command.peerKey, peerKey: command.peerKey } : {}),
|
|
44
|
+
}, argv);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
return { kind: 'invalid', code: error.code ?? 'INVALID_ARGUMENT', reason: error.message };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
37
50
|
else if (cmd === 'agent')
|
|
38
51
|
result = parseAgentCommand(argv, source);
|
|
39
52
|
else if (cmd === 'aid')
|
|
@@ -37,6 +37,7 @@ import { parseTimeArg, TIME_ARG_FORMATS, splitConfigBatchGetArgv } from '../../c
|
|
|
37
37
|
import { auditCommandAuthorization, auditFullAccessEvent, hashArgv } from '../auth/authorization-audit.js';
|
|
38
38
|
import { ResponseModeRegistry } from '../../response-system/registry.js';
|
|
39
39
|
import { registerBuiltinModes } from '../../response-system/modes/index.js';
|
|
40
|
+
import { parseQuotaCommand, queryQuota } from '../../stats/quota-query.js';
|
|
40
41
|
import { DirectoryQueryError, executeDirectoryQueryCommand, resolveDirectoryQueryCommand, } from '../../directory/owner-directory-query-operation.js';
|
|
41
42
|
import { executeDirectoryRequestCommand, resolveDirectoryRequestCommand, } from '../../directory/owner-directory-request-operation.js';
|
|
42
43
|
import { executeResolvedRoleCommand, resolveRoleCommand } from '../../config/role-command-service.js';
|
|
@@ -46,6 +47,7 @@ import { executeManagedAidOperation, ManagedAidOperationError, managedAidShowVie
|
|
|
46
47
|
import { MAX_AVATAR_SOURCE_BYTES } from '../../utils/avatar-upload.js';
|
|
47
48
|
import { executeManagedGroupOperation, ManagedGroupOperationError, resolveManagedGroupOperation, executeManagedMsgOperation, ManagedMsgOperationError, resolveManagedMsgOperation, executeManagedFsOperation, ManagedFsOperationError, resolveManagedFsOperation, } from '../../aun/msg/managed-operation.js';
|
|
48
49
|
import { authorizeFreshOperation, buildAuthSubject, executeAuditedOperation } from '../auth/auth-gateway.js';
|
|
50
|
+
import { resolveDelegatedIdentity } from '../auth/delegation-authorization.js';
|
|
49
51
|
import { getExistingRelationAttachmentDirs, isHClassPath, isLClassPath, isSameOrDescendant } from '../permission/protected-paths.js';
|
|
50
52
|
import { validateModelSelectionForRole } from '../model/model-permission.js';
|
|
51
53
|
import { getModelInfo } from '../model/model-catalog.js';
|
|
@@ -2103,6 +2105,44 @@ export class CommandHandler {
|
|
|
2103
2105
|
return ownershipFailure(error);
|
|
2104
2106
|
}
|
|
2105
2107
|
}
|
|
2108
|
+
/** Read quota status using daemon-owned identity, role resolution and statistics. */
|
|
2109
|
+
async handleQuotaOperation(argv, sessionId, delegationToken, delegationCommandHash, localControl = false) {
|
|
2110
|
+
try {
|
|
2111
|
+
const command = parseQuotaCommand(argv);
|
|
2112
|
+
if (localControl) {
|
|
2113
|
+
return { ok: true, result: await queryQuota(command, { canReadAgent: true, allowOtherAgent: true }) };
|
|
2114
|
+
}
|
|
2115
|
+
const delegation = await resolveDelegatedIdentity({ sessionId, delegationToken, delegationCommandHash }, {
|
|
2116
|
+
agentDelegationRegistry: this.agentDelegationRegistry,
|
|
2117
|
+
sessionManager: this.sessionManager,
|
|
2118
|
+
getProcessOwners: () => ownerResolver.daemonOwners(),
|
|
2119
|
+
}, 'INVALID_SESSION');
|
|
2120
|
+
if (!delegation.ok)
|
|
2121
|
+
return delegation;
|
|
2122
|
+
const { grant, subject } = delegation;
|
|
2123
|
+
const decision = await authorizeFreshOperation({
|
|
2124
|
+
source: 'agent-tool', subject,
|
|
2125
|
+
intent: {
|
|
2126
|
+
operation: 'quota.read', scope: 'relation', source: 'agent-tool',
|
|
2127
|
+
args: { self: command.selfAid ?? grant.selfAid, targetAgentAid: command.selfAid ?? grant.selfAid,
|
|
2128
|
+
peerKey: command.peerKey ?? grant.peerKey },
|
|
2129
|
+
},
|
|
2130
|
+
auditMetadata: { argvHash: hashArgv(argv), taskId: grant.taskId, messageId: grant.messageId },
|
|
2131
|
+
});
|
|
2132
|
+
if (!decision.allow)
|
|
2133
|
+
return { ok: false, code: decision.code, error: decision.reason };
|
|
2134
|
+
const fullAccess = hasTrustedFullAccessDelegation(grant);
|
|
2135
|
+
return { ok: true, result: await queryQuota(command, {
|
|
2136
|
+
selfAid: grant.selfAid, peerKey: grant.peerKey, actorId: grant.actorId,
|
|
2137
|
+
chatType: grant.chatType, channelKey: grant.channel,
|
|
2138
|
+
canReadAgent: isManagementRole(decision.subject?.role) || fullAccess,
|
|
2139
|
+
allowOtherAgent: fullAccess,
|
|
2140
|
+
}) };
|
|
2141
|
+
}
|
|
2142
|
+
catch (error) {
|
|
2143
|
+
return { ok: false, code: error?.code ?? 'QUOTA_QUERY_FAILED', error: error?.message ?? String(error) };
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2106
2146
|
/**
|
|
2107
2147
|
* Agent-managed role CLI. Quota policy uses the common authorization path;
|
|
2108
2148
|
* the existing request workflow retains its Owner approval checks.
|
|
@@ -2280,7 +2320,7 @@ export class CommandHandler {
|
|
|
2280
2320
|
to: input.to, payload: input.payload, rawPayload: true, encrypt: true,
|
|
2281
2321
|
log: { content: '[friend.invite.v1]', threadId: '', msgType: 'custom', payloadType: 'friend.invite.v1', source: 'msg' },
|
|
2282
2322
|
});
|
|
2283
|
-
return { ok: sent.ok, message_id: sent.message_id, error: sent.error, code: sent.code };
|
|
2323
|
+
return { ok: sent.ok, message_id: sent.message_id, outbox_id: sent.outbox_id, status: sent.status, error: sent.error, code: sent.code };
|
|
2284
2324
|
});
|
|
2285
2325
|
return result.ok ? { ok: true, result } : { ok: false, code: result.code, error: result.error };
|
|
2286
2326
|
}
|
|
@@ -3117,7 +3157,10 @@ export class CommandHandler {
|
|
|
3117
3157
|
const fullAccess = hasTrustedFullAccessDelegation(grant);
|
|
3118
3158
|
if (hasModelSelector) {
|
|
3119
3159
|
if (!isModelRead) {
|
|
3120
|
-
|
|
3160
|
+
// 托管写操作不接受任何选择器。`--self <本端 AID>` 的幂等写法由 CLI 层在发送前
|
|
3161
|
+
// 剥掉(src/cli/model.ts),守护进程不需要为此放宽:这里收到的选择器只可能
|
|
3162
|
+
// 指向别的 Agent,或者说明调用方绕过了 CLI。
|
|
3163
|
+
return { ok: false, code: 'NOT_ALLOWED', error: 'Managed model writes cannot select --self, --peer, or --role' };
|
|
3121
3164
|
}
|
|
3122
3165
|
if ((selector.peerKey || selector.role) && !selector.self)
|
|
3123
3166
|
return invalid('--peer/--role requires --self');
|
|
@@ -16,6 +16,7 @@ import path from 'path';
|
|
|
16
16
|
import fs from 'fs';
|
|
17
17
|
import { parseFileSearchArgs, searchProjectFiles } from './file-search.js';
|
|
18
18
|
import os from 'os';
|
|
19
|
+
import { readEffectiveCpuCount } from '../../utils/host-info.js';
|
|
19
20
|
import crypto from 'crypto';
|
|
20
21
|
import { CronExpressionParser } from 'cron-parser';
|
|
21
22
|
import { parseDuration } from '../../trigger/parser.js';
|
|
@@ -2679,6 +2680,10 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2679
2680
|
protocolVersion: 1, enabled: peekServiceRouter(root.targetAid)?.enabled
|
|
2680
2681
|
?? loadRouterConfig(agentServicesDir(root.targetAid)).config.enabled,
|
|
2681
2682
|
notifications: this.eventCenter?.get(root.targetAid)?.runtime.nativeOutputAvailable === true,
|
|
2683
|
+
}, outputCards: {
|
|
2684
|
+
protocolVersion: 1, enabled: peekServiceRouter(root.targetAid)?.enabled
|
|
2685
|
+
?? loadRouterConfig(agentServicesDir(root.targetAid)).config.enabled,
|
|
2686
|
+
notifications: this.eventCenter?.get(root.targetAid)?.runtime.nativeOutputAvailable === true,
|
|
2682
2687
|
}, workbench: {
|
|
2683
2688
|
protocolVersion: 1, enabled: peekServiceRouter(root.targetAid)?.enabled
|
|
2684
2689
|
?? loadRouterConfig(agentServicesDir(root.targetAid)).config.enabled,
|
|
@@ -3232,7 +3237,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
3232
3237
|
osName: os.type(),
|
|
3233
3238
|
osRelease: os.release(),
|
|
3234
3239
|
cpuModel: cpus[0]?.model ?? null,
|
|
3235
|
-
cpuCount:
|
|
3240
|
+
cpuCount: readEffectiveCpuCount(),
|
|
3236
3241
|
memoryTotalBytes: os.totalmem(),
|
|
3237
3242
|
systemUptime: Math.floor(os.uptime()),
|
|
3238
3243
|
};
|
|
@@ -1040,6 +1040,30 @@ function writeMenuFlowRecord(record) {
|
|
|
1040
1040
|
// Observability must never affect Menu execution.
|
|
1041
1041
|
}
|
|
1042
1042
|
}
|
|
1043
|
+
/** Paired records identify an unfinished await as well as completed slow work.
|
|
1044
|
+
* Only correlation metadata is logged, never request arguments or credentials. */
|
|
1045
|
+
export async function traceMenuStage(request, context, timing, stage, operation) {
|
|
1046
|
+
if (!request)
|
|
1047
|
+
return operation();
|
|
1048
|
+
const started = performance.now();
|
|
1049
|
+
const record = (phase) => writeMenuFlowRecord({
|
|
1050
|
+
...menuFlowBaseRecord(request, context),
|
|
1051
|
+
event: 'menu.stage', stage, phase,
|
|
1052
|
+
receivedAt: timing.receivedAt,
|
|
1053
|
+
elapsedMs: menuElapsedMs(timing),
|
|
1054
|
+
...(phase === 'started' ? {} : { durationMs: Math.max(0, Math.round(performance.now() - started)) }),
|
|
1055
|
+
});
|
|
1056
|
+
record('started');
|
|
1057
|
+
try {
|
|
1058
|
+
const result = await operation();
|
|
1059
|
+
record('completed');
|
|
1060
|
+
return result;
|
|
1061
|
+
}
|
|
1062
|
+
catch (error) {
|
|
1063
|
+
record('failed');
|
|
1064
|
+
throw error;
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1043
1067
|
export function logMenuRequestReceived(request, context) {
|
|
1044
1068
|
writeMenuFlowRecord({
|
|
1045
1069
|
...menuFlowBaseRecord(request, context),
|