evolcore 0.0.43-test.6 → 0.0.43-test.8
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 +95 -0
- package/bin/ecmsg.js +188 -58
- package/dist/agent-template/jobs.js +62 -0
- package/dist/agent-template/runtime.js +214 -0
- package/dist/agent-template/service.js +465 -0
- package/dist/agent-template/tool-runner.js +45 -0
- package/dist/agent-template/types.js +5 -0
- package/dist/agents/baseagent-availability.js +1 -1
- package/dist/agents/claude-runner.js +1 -1
- package/dist/agents/codex/app-server-client.js +22 -0
- package/dist/agents/codex-runner.js +69 -2
- package/dist/aun/aid/agentmd.js +56 -1
- package/dist/aun/aid/client.js +3 -1
- package/dist/aun/menu/client.js +3 -2
- package/dist/aun/msg/p2p.js +6 -1
- package/dist/channels/aun.js +277 -49
- package/dist/cli/agent-command.js +5 -0
- package/dist/cli/agent-create.js +7 -3
- package/dist/cli/agent-template.js +124 -0
- package/dist/cli/aun-commands.js +2 -2
- package/dist/cli/ctl-command.js +2 -1
- package/dist/cli/daemon-commands.js +11 -66
- package/dist/cli/daemon-lifecycle-client.js +61 -0
- package/dist/cli/ecmsg-gateway.js +35 -2
- package/dist/cli/events-command.js +109 -0
- package/dist/cli/index.js +60 -14
- package/dist/cli/invoke-command.js +182 -0
- package/dist/cli/managed-command-guard.js +6 -1
- package/dist/cli/net-check.js +1 -1
- package/dist/cli/restart-monitor.js +160 -83
- package/dist/cli/services-command.js +137 -0
- package/dist/cli/team-workspace-command.js +134 -0
- package/dist/cli/thread-command.js +103 -13
- package/dist/cli/watch-msg.js +1 -1
- package/dist/config/boot-log.js +8 -8
- package/dist/config/config-field-policy.js +2 -2
- package/dist/config/config-manager.js +0 -7
- package/dist/config/invoke-ipc-service.js +118 -0
- package/dist/config/schema-migration.js +45 -15
- package/dist/config-store.js +2 -1
- package/dist/core/agent-ipc-registration.js +25 -4
- package/dist/core/agent-reload-coordinator.js +6 -4
- package/dist/core/agent-runtime.js +106 -10
- package/dist/core/auth/delegation-authorization.js +66 -0
- package/dist/core/auth/operation-authorizer.js +2 -0
- package/dist/core/auth/operation-catalog.js +29 -0
- package/dist/core/baseagent-loader.js +60 -130
- package/dist/core/channel-loader.js +10 -1
- package/dist/core/channel-runtime.js +20 -12
- package/dist/core/command/agent-control.js +12 -2
- package/dist/core/command/agent-storage-menu.js +1 -1
- package/dist/core/command/agent-template-menu.js +147 -0
- package/dist/core/command/chatmode-config.js +2 -36
- package/dist/core/command/command-handler.js +80 -17
- package/dist/core/command/data-root-resolver.js +32 -23
- package/dist/core/command/eventcenter-menu.js +468 -0
- package/dist/core/command/menu-catalog.js +15 -0
- package/dist/core/command/menu-handler.js +216 -90
- package/dist/core/command/menu-protocol.js +71 -13
- package/dist/core/command/menu-query-batch.js +194 -0
- package/dist/core/command/slash-gate.js +1 -1
- package/dist/core/command/slash-handler.js +34 -42
- package/dist/core/command/team-workspace-bootstrap.js +350 -0
- package/dist/core/command/{pa-workspace-calendar.js → team-workspace-calendar.js} +7 -7
- package/dist/core/command/team-workspace-initializer.js +2 -0
- package/dist/core/command/{pa-workspace-items.js → team-workspace-items.js} +83 -68
- package/dist/core/command/team-workspace-job-store.js +88 -0
- package/dist/core/command/team-workspace-management-service.js +2 -0
- package/dist/core/command/team-workspace-management-store.js +96 -0
- package/dist/core/command/team-workspace-management.js +265 -0
- package/dist/core/command/team-workspace-members-menu.js +88 -0
- package/dist/core/command/team-workspace-store.js +612 -0
- package/dist/core/command/team-workspace-team.js +193 -0
- package/dist/core/daemon-control.js +22 -5
- package/dist/core/daemon-lifecycle.js +323 -191
- package/dist/core/handoff/runtime.js +45 -13
- package/dist/core/invoke/executors/index.js +13 -0
- package/dist/core/invoke/executors/media.js +283 -0
- package/dist/core/invoke/executors/text.js +198 -0
- package/dist/core/invoke/invoke-service.js +157 -0
- package/dist/core/invoke/style-router.js +48 -0
- package/dist/core/invoke/types.js +19 -0
- package/dist/core/ipc-registration.js +50 -7
- package/dist/core/legacy-rename.js +41 -0
- package/dist/core/memory/consolidation.js +7 -5
- package/dist/core/message/aun-ipc-sender.js +252 -17
- package/dist/core/message/im-renderer.js +116 -85
- package/dist/core/message/message-bridge.js +4 -0
- package/dist/core/message/message-queue.js +66 -15
- package/dist/core/message/message-utils.js +10 -2
- package/dist/core/message/peer-mode.js +7 -34
- package/dist/core/message/pending-hints.js +29 -5
- package/dist/core/message/response-engine.js +194 -61
- package/dist/core/message/send-options.js +7 -4
- package/dist/core/message/send-routing.js +50 -5
- package/dist/core/ownership/owner-resolver.js +7 -0
- package/dist/core/pack-auth.js +94 -0
- package/dist/core/pack-install.js +194 -0
- package/dist/core/permission/ec-command-parser.js +51 -17
- package/dist/core/permission/protected-paths.js +12 -2
- package/dist/core/permission/shell-environment.js +9 -0
- package/dist/core/rate-window.js +48 -0
- package/dist/core/relation/peer-identity.js +28 -0
- package/dist/core/session/session-file-health.js +243 -0
- package/dist/core/session/session-fs-store.js +67 -28
- package/dist/core/session/session-idle-monitor.js +59 -19
- package/dist/core/session/session-manager.js +13 -4
- package/dist/core/task/task-recovery-service.js +13 -2
- package/dist/core/thread/command-parser.js +9 -2
- package/dist/core/thread/thread-operation.js +21 -2
- package/dist/core/thread/thread-route.js +13 -2
- package/dist/core/thread/thread-service.js +52 -3
- package/dist/directory/owner-directory-admission.js +40 -53
- package/dist/directory/owner-directory-cache.js +89 -113
- package/dist/directory/owner-directory-query-operation.js +8 -10
- package/dist/eck/kit-renderer.js +7 -5
- package/dist/eck/message-renderer.js +2 -0
- package/dist/ecweb/basic-settings-service.js +1 -1
- package/dist/ecweb/message-context-service.js +0 -4
- package/dist/ecweb/runtime/lifecycle.js +6 -2
- package/dist/ecweb/runtime/supervisor.js +19 -4
- package/dist/event-center/admission-materializer.js +124 -0
- package/dist/event-center/bus-gate.js +154 -0
- package/dist/event-center/bus-host.js +307 -0
- package/dist/event-center/bus-resolver.js +120 -0
- package/dist/event-center/center-config.js +127 -0
- package/dist/event-center/daemon.js +44 -0
- package/dist/event-center/directory-source.js +55 -0
- package/dist/event-center/dispatcher.js +157 -0
- package/dist/event-center/event-log.js +110 -0
- package/dist/event-center/index-generator.js +73 -0
- package/dist/event-center/ipc-operation.js +423 -0
- package/dist/event-center/ledger.js +52 -0
- package/dist/event-center/pack-loader.js +207 -0
- package/dist/event-center/pack-manager.js +85 -0
- package/dist/event-center/registry.js +463 -0
- package/dist/event-center/runtime.js +837 -0
- package/dist/event-center/script-runner.js +356 -0
- package/dist/event-center/types.js +51 -0
- package/dist/event-center/validation.js +435 -0
- package/dist/index.js +424 -135
- package/dist/ipc.js +106 -12
- package/dist/paths.js +20 -0
- package/dist/product.js +14 -0
- package/dist/proxy/manager.js +5 -1
- package/dist/proxy/service-supervisor.js +13 -4
- package/dist/response-system/engines/v1/index.js +0 -1
- package/dist/response-system/engines/v1/proactive-flow.js +4 -2
- package/dist/response-system/modes/single-session/index.js +1 -1
- package/dist/services/dispatcher.js +100 -0
- package/dist/services/idempotency.js +90 -0
- package/dist/services/identity.js +52 -0
- package/dist/services/index-generator.js +70 -0
- package/dist/services/index.js +449 -0
- package/dist/services/ipc-operation.js +550 -0
- package/dist/services/ledger.js +52 -0
- package/dist/services/message-log.js +112 -0
- package/dist/services/pack-manager.js +215 -0
- package/dist/services/reply.js +55 -0
- package/dist/services/router.js +98 -0
- package/dist/services/script-runner.js +422 -0
- package/dist/services/service-payload.js +70 -0
- package/dist/services/types.js +18 -0
- package/dist/services/validation.js +297 -0
- package/dist/trigger/application-service.js +18 -0
- package/dist/trigger/event-source.js +1 -1
- package/dist/trigger/ipc-service.js +3 -1
- package/dist/trigger/scheduler.js +38 -0
- package/dist/trigger/script-sandbox.js +170 -24
- package/dist/utils/cross-platform.js +24 -10
- package/dist/utils/evolcore-version.js +69 -27
- package/dist/utils/instance-registry.js +19 -13
- package/dist/utils/npm-ops.js +2 -1
- package/dist/utils/package-version-info.js +6 -3
- package/dist/utils/process-introspect.js +45 -9
- package/dist/utils/startup-trace.js +74 -37
- package/dist/utils/windows-shell-trust.js +80 -6
- package/kits/docs/INDEX.md +2 -2
- package/kits/docs/aun/ABILITY_CALLING.md +9 -15
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +3 -1
- package/kits/docs/evolcore/ability.md +4 -0
- package/kits/docs/evolcore/agent.md +22 -1
- package/kits/docs/evolcore/aid.md +1 -1
- package/kits/docs/evolcore/event-center.md +227 -0
- package/kits/docs/evolcore/file-navigation.md +10 -264
- package/kits/docs/evolcore/fs.md +5 -3
- package/kits/docs/evolcore/group.md +1 -1
- package/kits/docs/evolcore/memory-architecture.md +2 -0
- package/kits/docs/evolcore/menu-protocol.md +28 -1
- package/kits/docs/evolcore/msg.md +21 -9
- package/kits/docs/evolcore/provider.md +3 -1
- package/kits/docs/evolcore/response.md +5 -5
- package/kits/docs/evolcore/services.md +294 -0
- package/kits/docs/evolcore/task.md +2 -0
- package/kits/docs/evolcore/team-workspace.md +41 -0
- package/kits/docs/evolcore/thread-chain.md +15 -3
- package/kits/eck_manifest.json +26 -0
- package/kits/rules/02-navigation.md +10 -1
- package/kits/rules/06-channel.md +1 -0
- package/kits/schemas/_meta.json +17 -6
- package/kits/schemas/agent-config.schema.19.json +5 -7
- package/kits/schemas/agent-config.schema.20.json +936 -0
- package/kits/schemas/relation-config.schema.12.json +2 -3
- package/kits/schemas/role-config.schema.2.json +4 -4
- package/kits/skills/.switches.json +1 -5
- package/kits/skills/ability/SKILL.md +56 -0
- package/kits/skills/ability/references/calling.md +56 -0
- package/kits/skills/{ec-ability → ability}/references/contract-checklist.md +1 -1
- package/kits/skills/{ec-ability → ability}/references/development.md +9 -33
- package/kits/skills/{ec-ability → ability}/references/management.md +2 -2
- package/kits/skills/{ec-ability → ability}/references/recovery.md +1 -1
- package/kits/skills/{ec-ability → ability}/references/runtime-protocol.md +2 -0
- package/kits/skills/ec-agent-create/SKILL.md +0 -1
- package/kits/skills/ec-group/SKILL.md +5 -8
- package/kits/skills/ec-group-collaboration/SKILL.md +7 -7
- package/kits/skills/ec-service-proxy/SKILL.md +34 -5
- package/kits/skills/ec-trigger/SKILL.md +4 -4
- package/kits/skills/personal-assistant/SKILL.md +6 -6
- package/kits/skills/personal-assistant/references/02-bootstrap.md +4 -4
- package/kits/skills/personal-assistant/scripts/clean.mjs +4 -4
- package/kits/skills/personal-assistant/scripts/init.mjs +2 -2
- package/kits/skills/personal-assistant/scripts/pa.mjs +4 -4
- package/kits/skills/thread-ops/SKILL.md +10 -10
- package/kits/templates/message-fragments/item.md +1 -1
- package/kits/templates/system-fragments/channel.md +3 -3
- package/kits/templates/system-fragments/commands.md +5 -3
- package/kits/templates/system-fragments/reply.md +1 -5
- package/kits/templates/system-fragments/thread.md +13 -10
- package/package.json +5 -6
- package/scripts/agent-template/index.mjs +40 -0
- package/scripts/agent-template/inspect.mjs +240 -0
- package/scripts/agent-template/overlay.mjs +71 -0
- package/scripts/agent-template/pack.mjs +169 -0
- package/scripts/agent-template/shared/common.mjs +235 -0
- package/scripts/agent-template/shared/evolcore.mjs +75 -0
- package/scripts/agent-template/shared/plan.mjs +129 -0
- package/scripts/agent-template/shared/team-schema.json +70 -0
- package/scripts/agent-template/shared/template-contract.mjs +154 -0
- package/scripts/agent-template/shared/template-package.mjs +265 -0
- package/scripts/agent-template/shared/template-runtime.mjs +80 -0
- package/scripts/agent-template/shared/template.mjs +142 -0
- package/dist/cli/pa-workspace-command.js +0 -225
- package/dist/core/command/pa-workspace-store.js +0 -468
- package/dist/core/relation/pa-team.js +0 -132
- package/kits/docs/evolcore/pa-workspace.md +0 -51
- package/kits/skills/aid-ability/SKILL.md +0 -244
- package/kits/skills/ec-ability/SKILL.md +0 -67
- package/kits/skills/ec-ability/references/workflows.md +0 -15
|
@@ -31,6 +31,7 @@ import { CODEX_HOOK_TOKEN_ENV, MAIN_CLI_BIN } from '../product.js';
|
|
|
31
31
|
import { ensureSessionRuntimeDir, getManagedTaskTempDir } from '../cli/task-context.js';
|
|
32
32
|
import { buildTranscriptTurns } from '../core/session/session-transcript.js';
|
|
33
33
|
import { CodexSessionFileAdapter } from '../core/session/adapters/codex-session-file-adapter.js';
|
|
34
|
+
import { repairCodexSessionProvider } from '../core/session/session-file-health.js';
|
|
34
35
|
import { execFileSync } from 'child_process';
|
|
35
36
|
import { probeCli, probeCliSync, CODEX_CLI_PROBE_TIMEOUT_MS, CODEX_CLI_PROBE_RETRY_TIMEOUT_MS } from '../utils/cross-platform.js';
|
|
36
37
|
import { createHash, randomBytes } from 'crypto';
|
|
@@ -767,6 +768,65 @@ export class CodexRunner {
|
|
|
767
768
|
}
|
|
768
769
|
return existing.client;
|
|
769
770
|
}
|
|
771
|
+
/** Called under the existing thread lock, before resume or input submission. */
|
|
772
|
+
async prepareSessionProvider(client, threadId, signal) {
|
|
773
|
+
signal?.throwIfAborted();
|
|
774
|
+
const provider = client.getModelProvider?.();
|
|
775
|
+
if (!provider || !/^evolcore_registry_[a-f0-9]{20}$/.test(provider))
|
|
776
|
+
return;
|
|
777
|
+
const sessionFile = this.findCodexSessionFile(threadId);
|
|
778
|
+
if (!sessionFile)
|
|
779
|
+
return; // Preserve the existing missing-rollout recovery behavior.
|
|
780
|
+
const repaired = await repairCodexSessionProvider({
|
|
781
|
+
codexHome: this.codexHomeDir(), threadId, sessionFile, provider,
|
|
782
|
+
releaseThread: async () => {
|
|
783
|
+
signal?.throwIfAborted();
|
|
784
|
+
if ([...this.activeSubagentTurns.values()].some(turn => turn.parentThreadId === threadId)) {
|
|
785
|
+
throw new Error('Codex Provider repair requires all descendant turns to finish');
|
|
786
|
+
}
|
|
787
|
+
const clients = new Set([
|
|
788
|
+
client, this.appServerClient, this.fullAccessAppServerClient,
|
|
789
|
+
this.threadSubscriptions.get(threadId)?.client, ...this.retiredProviderClients,
|
|
790
|
+
]);
|
|
791
|
+
for (const owner of clients) {
|
|
792
|
+
if (!owner || owner !== client && owner.isRunning?.() === false)
|
|
793
|
+
continue;
|
|
794
|
+
if (!(await owner.threadLoadedList()).data.includes(threadId))
|
|
795
|
+
continue;
|
|
796
|
+
const thread = (await owner.threadRead(threadId, false)).thread;
|
|
797
|
+
if (!['idle', 'systemError'].includes(thread?.status?.type ?? '')) {
|
|
798
|
+
throw new Error('Codex Provider repair requires an idle thread');
|
|
799
|
+
}
|
|
800
|
+
try {
|
|
801
|
+
await owner.threadUnsubscribeAndWait(threadId, CODEX_THREAD_HANDOFF_TIMEOUT_MS);
|
|
802
|
+
}
|
|
803
|
+
catch (error) {
|
|
804
|
+
if (error.code !== 'CODEX_THREAD_CLOSE_TIMEOUT')
|
|
805
|
+
throw error;
|
|
806
|
+
}
|
|
807
|
+
if ((await owner.threadLoadedList()).data.includes(threadId)) {
|
|
808
|
+
// Codex can keep an unsubscribed writer alive. Its per-thread archive
|
|
809
|
+
// tears down that runtime synchronously; unarchive preserves the UUID.
|
|
810
|
+
await this.archiveThreadForHandoff(owner, owner, threadId);
|
|
811
|
+
}
|
|
812
|
+
if ((await owner.threadLoadedList()).data.includes(threadId)) {
|
|
813
|
+
throw new Error('Codex Provider repair could not release the thread writer');
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
signal?.throwIfAborted();
|
|
817
|
+
this.threadSubscriptions.delete(threadId);
|
|
818
|
+
},
|
|
819
|
+
});
|
|
820
|
+
if (repaired)
|
|
821
|
+
this.threadProjectPaths.delete(threadId);
|
|
822
|
+
}
|
|
823
|
+
assertResumedProvider(client, response, threadId) {
|
|
824
|
+
const provider = client.getModelProvider?.();
|
|
825
|
+
if (provider && /^evolcore_registry_[a-f0-9]{20}$/.test(provider)
|
|
826
|
+
&& (response.thread?.id !== threadId || response.thread?.modelProvider !== provider)) {
|
|
827
|
+
throw new Error('Codex resume did not preserve the bound thread and current Provider');
|
|
828
|
+
}
|
|
829
|
+
}
|
|
770
830
|
async archiveThreadForHandoff(sourceClient, targetClient, threadId) {
|
|
771
831
|
const existing = this.threadSubscriptions.get(threadId);
|
|
772
832
|
if (existing && existing.client !== sourceClient) {
|
|
@@ -2294,6 +2354,7 @@ export class CodexRunner {
|
|
|
2294
2354
|
let previousAppServer;
|
|
2295
2355
|
const openThread = async () => {
|
|
2296
2356
|
if (agentSessionId) {
|
|
2357
|
+
await this.prepareSessionProvider(appServer, agentSessionId, operationController?.signal);
|
|
2297
2358
|
// A thread may have been loaded by the other permission-mode client.
|
|
2298
2359
|
// Release that one thread before asking this client to resume it.
|
|
2299
2360
|
previousAppServer = await this.prepareThreadSubscription(appServer, agentSessionId);
|
|
@@ -2398,6 +2459,8 @@ export class CodexRunner {
|
|
|
2398
2459
|
threadOptions = buildThreadOptions(true);
|
|
2399
2460
|
threadResponse = await openThread();
|
|
2400
2461
|
}
|
|
2462
|
+
if (agentSessionId)
|
|
2463
|
+
this.assertResumedProvider(appServer, threadResponse, agentSessionId);
|
|
2401
2464
|
let threadId = threadResponse.thread?.id || agentSessionId;
|
|
2402
2465
|
if (!threadId)
|
|
2403
2466
|
throw new Error('Codex app-server did not return a thread id');
|
|
@@ -3001,8 +3064,9 @@ export class CodexRunner {
|
|
|
3001
3064
|
let compactAppServer;
|
|
3002
3065
|
try {
|
|
3003
3066
|
const compactMode = normalizeExecutionPermissionMode(modelOverride?.permissionMode ?? this.chatModes.get(_sessionId) ?? this.currentMode);
|
|
3004
|
-
const appServer = this.getAppServerClient(compactMode === 'fullaccess');
|
|
3067
|
+
const appServer = this.getAppServerClient(compactMode === 'fullaccess', modelOverride?.provider);
|
|
3005
3068
|
compactAppServer = appServer;
|
|
3069
|
+
await this.prepareSessionProvider(appServer, agentSessionId);
|
|
3006
3070
|
await this.prepareThreadSubscription(appServer, agentSessionId);
|
|
3007
3071
|
this.onCompactStart?.(_sessionId);
|
|
3008
3072
|
try {
|
|
@@ -3028,7 +3092,7 @@ export class CodexRunner {
|
|
|
3028
3092
|
const compactSessionToken = this.ensureThreadCredential(agentSessionId);
|
|
3029
3093
|
if (!compactSessionToken)
|
|
3030
3094
|
throw new Error('Codex thread session credential is unavailable');
|
|
3031
|
-
await appServer.threadResume(agentSessionId, _projectPath, {
|
|
3095
|
+
const resumed = await appServer.threadResume(agentSessionId, _projectPath, {
|
|
3032
3096
|
model: compactModel,
|
|
3033
3097
|
effort: compactEffort,
|
|
3034
3098
|
approvalPolicy: compactPolicy,
|
|
@@ -3036,6 +3100,7 @@ export class CodexRunner {
|
|
|
3036
3100
|
...(executionSandbox.sandbox ? { sandbox: executionSandbox.sandbox } : {}),
|
|
3037
3101
|
config: this.sanitizeThreadEnvironmentConfig(this.mergeThreadConfig(executionSandbox.permissionProfileConfig, capabilityConfig, externalToolConfig, this.buildEvolcoreShellEnvironmentConfig(_sessionId, compactSessionToken), this.buildLifecycleLockdownConfig(compactMode)), compactMode),
|
|
3038
3102
|
});
|
|
3103
|
+
this.assertResumedProvider(appServer, resumed, agentSessionId);
|
|
3039
3104
|
this.markThreadSubscribed(appServer, agentSessionId);
|
|
3040
3105
|
this.threadProjectPaths.set(agentSessionId, path.resolve(_projectPath));
|
|
3041
3106
|
this.bindExternalToolBoundary(agentSessionId, externalToolConfig);
|
|
@@ -4961,6 +5026,7 @@ export class CodexRunner {
|
|
|
4961
5026
|
if (numTurns < 1)
|
|
4962
5027
|
return true;
|
|
4963
5028
|
const appServer = this.getAppServerClientForThread(agentSessionId);
|
|
5029
|
+
await this.prepareSessionProvider(appServer, agentSessionId);
|
|
4964
5030
|
const previousAppServer = await this.prepareThreadSubscription(appServer, agentSessionId);
|
|
4965
5031
|
let resumed = false;
|
|
4966
5032
|
try {
|
|
@@ -4977,6 +5043,7 @@ export class CodexRunner {
|
|
|
4977
5043
|
throw error;
|
|
4978
5044
|
}
|
|
4979
5045
|
}
|
|
5046
|
+
this.assertResumedProvider(appServer, resumeResponse, agentSessionId);
|
|
4980
5047
|
this.markThreadSubscribed(appServer, agentSessionId);
|
|
4981
5048
|
this.threadProjectPaths.set(agentSessionId, path.resolve(projectPath));
|
|
4982
5049
|
resumed = true;
|
package/dist/aun/aid/agentmd.js
CHANGED
|
@@ -496,6 +496,59 @@ export function stripAgentMdSignature(content) {
|
|
|
496
496
|
function escapeRegExp(value) {
|
|
497
497
|
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
498
498
|
}
|
|
499
|
+
/**
|
|
500
|
+
* 统计一个被折行的 YAML 标量值在后续行里占用的续行数。
|
|
501
|
+
*
|
|
502
|
+
* `yaml` 的 stringify 默认按 80 列折行,历史名片里会留下
|
|
503
|
+
* `avatar: "https://…-2d\` + 换行 + 缩进续行 + `"` 这种写法。
|
|
504
|
+
* 替换字段时只改第一行、把续行留下,会让整个 frontmatter 无法解析,
|
|
505
|
+
* 所以这里按引号状态把续行一并算出来。
|
|
506
|
+
*
|
|
507
|
+
* 只处理以引号开头的值:未加引号的普通标量也可能跨行,但那种写法
|
|
508
|
+
* 目前只出现在手写名片里,按单行处理至少会在校验阶段明确报错,
|
|
509
|
+
* 不会静默吞掉后面的成块映射(如 ownership.statement)。
|
|
510
|
+
*/
|
|
511
|
+
function countScalarContinuationLines(valueText, followingLines) {
|
|
512
|
+
const head = valueText.trimStart();
|
|
513
|
+
const quote = head[0];
|
|
514
|
+
if (quote !== '"' && quote !== "'")
|
|
515
|
+
return 0;
|
|
516
|
+
let open = true;
|
|
517
|
+
let escaped = false;
|
|
518
|
+
const scan = (text) => {
|
|
519
|
+
for (let index = 0; index < text.length; index++) {
|
|
520
|
+
const char = text[index];
|
|
521
|
+
if (quote === '"') {
|
|
522
|
+
if (escaped)
|
|
523
|
+
escaped = false;
|
|
524
|
+
else if (char === '\\')
|
|
525
|
+
escaped = true;
|
|
526
|
+
else if (char === '"') {
|
|
527
|
+
open = false;
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
else if (char === "'") {
|
|
532
|
+
// 单引号串里 `''` 表示一个字面量单引号
|
|
533
|
+
if (text[index + 1] === "'")
|
|
534
|
+
index++;
|
|
535
|
+
else {
|
|
536
|
+
open = false;
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
// 行尾的 `\` 转义的是换行本身,续行仍然在引号内
|
|
542
|
+
escaped = false;
|
|
543
|
+
};
|
|
544
|
+
scan(head.slice(1));
|
|
545
|
+
let continuation = 0;
|
|
546
|
+
while (open && continuation < followingLines.length) {
|
|
547
|
+
scan(followingLines[continuation] ?? '');
|
|
548
|
+
continuation++;
|
|
549
|
+
}
|
|
550
|
+
return continuation;
|
|
551
|
+
}
|
|
499
552
|
function updateAgentMdFrontmatterField(content, key, value, insertAfterKey) {
|
|
500
553
|
const original = content;
|
|
501
554
|
const payload = stripAgentMdSignature(content);
|
|
@@ -514,7 +567,9 @@ function updateAgentMdFrontmatterField(content, key, value, insertAfterKey) {
|
|
|
514
567
|
const fieldIndex = fmLines.findIndex(line => fieldPattern.test(lineValue(line)));
|
|
515
568
|
if (fieldIndex >= 0) {
|
|
516
569
|
const existingLine = fmLines[fieldIndex] ?? '';
|
|
517
|
-
|
|
570
|
+
const existingText = lineValue(existingLine);
|
|
571
|
+
const continuation = countScalarContinuationLines(existingText.slice(existingText.indexOf(':') + 1), fmLines.slice(fieldIndex + 1).map(lineValue));
|
|
572
|
+
fmLines.splice(fieldIndex, 1 + continuation, `${key}: ${yamlDoubleQuote(value)}${lineEnding(existingLine, defaultEol)}`);
|
|
518
573
|
}
|
|
519
574
|
else {
|
|
520
575
|
const anchorPattern = insertAfterKey ? new RegExp(`^${escapeRegExp(insertAfterKey)}\\s*:`) : null;
|
package/dist/aun/aid/client.js
CHANGED
|
@@ -14,6 +14,8 @@ export function suppressSdkLogs() {
|
|
|
14
14
|
const _origStderrWrite = process.stderr.write.bind(process.stderr);
|
|
15
15
|
const SDK_LOG_RE = /^\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+\]\[(?:DEBUG|INFO|WARN|ERROR)\]/;
|
|
16
16
|
const KEYSTORE_WARN_RE = /seed migration failed; continuing with legacy \.seed/;
|
|
17
|
+
// Node 自带的实验特性警告(SDK 的 SQLite store 触发),与命令结果无关。
|
|
18
|
+
const NODE_SQLITE_WARN_RE = /ExperimentalWarning: SQLite is an experimental feature|Use `node --trace-warnings \.\.\.` to show where the warning was created/;
|
|
17
19
|
console.log = (...args) => { if (typeof args[0] === 'string' && SDK_LOG_RE.test(args[0]))
|
|
18
20
|
return; _origLog(...args); };
|
|
19
21
|
console.info = (...args) => { if (typeof args[0] === 'string' && SDK_LOG_RE.test(args[0]))
|
|
@@ -26,7 +28,7 @@ export function suppressSdkLogs() {
|
|
|
26
28
|
process.stderr.write = function (chunk, encoding, callback) {
|
|
27
29
|
const str = String(chunk);
|
|
28
30
|
// Filter out keystore migration warnings and other SDK logs
|
|
29
|
-
if (SDK_LOG_RE.test(str) || KEYSTORE_WARN_RE.test(str)) {
|
|
31
|
+
if (SDK_LOG_RE.test(str) || KEYSTORE_WARN_RE.test(str) || NODE_SQLITE_WARN_RE.test(str)) {
|
|
30
32
|
if (typeof encoding === 'function') {
|
|
31
33
|
encoding(); // callback is in encoding position
|
|
32
34
|
}
|
package/dist/aun/menu/client.js
CHANGED
|
@@ -45,7 +45,7 @@ export class ManagedMenuClient {
|
|
|
45
45
|
const key = this.key(fromAid, event.requestId);
|
|
46
46
|
const entry = this.eventHandlers.get(key);
|
|
47
47
|
entry?.handler(event);
|
|
48
|
-
if (event.event === 'upgrade.result' && entry) {
|
|
48
|
+
if ((event.event === 'upgrade.result' || event.event === 'template.result') && entry) {
|
|
49
49
|
clearTimeout(entry.timer);
|
|
50
50
|
this.eventHandlers.delete(key);
|
|
51
51
|
}
|
|
@@ -106,7 +106,8 @@ export class ManagedMenuClient {
|
|
|
106
106
|
error: { code: 'NOT_ALLOWED', message: 'Remote query was denied; authorization denial cached for up to 30 minutes or until reconnect.' },
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
-
if (options.onEvent && request.type === 'menu.action' && request.action === 'upgrade' && request.args?.mode === 'update'
|
|
109
|
+
if (options.onEvent && request.type === 'menu.action' && (request.action === 'upgrade' && request.args?.mode === 'update'
|
|
110
|
+
|| (request.name === 'agent' || request.cmd === '/agent') && ['build', 'push', 'pull', 'deploy'].includes(String(request.action)))) {
|
|
110
111
|
const existing = this.eventHandlers.get(key);
|
|
111
112
|
if (existing)
|
|
112
113
|
clearTimeout(existing.timer);
|
package/dist/aun/msg/p2p.js
CHANGED
|
@@ -203,7 +203,12 @@ async function daemonMsgSendResult(args, payload, runtimeContext, daemonResult)
|
|
|
203
203
|
request_diagnostics: daemonResult.request_diagnostics,
|
|
204
204
|
transport_error: daemonResult.transport_error,
|
|
205
205
|
};
|
|
206
|
-
|
|
206
|
+
// 跨话题自派(`--to <本端AID>`)不写出站日志:chatDir 会算成「我↔我」目录,
|
|
207
|
+
// daemon 侧 `sendDaemonMsg` 同样跳过;这里是对「daemon 未写日志」的兜底,
|
|
208
|
+
// 不跳过就会在 CLI 侧把那个目录补造出来。
|
|
209
|
+
const selfAddressed = String(args.to ?? '').replace(/^@/, '').toLowerCase()
|
|
210
|
+
=== String(args.from ?? '').replace(/^@/, '').toLowerCase();
|
|
211
|
+
if (!selfAddressed && sent.message_id && !daemonResult.handoff_id && !daemonResult.log_written) {
|
|
207
212
|
await appendMsgSendOutboundLog(args, sent, {
|
|
208
213
|
payload,
|
|
209
214
|
runtimeContext,
|