evolcore 0.0.43-test.5 → 0.0.43-test.7
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 +281 -81
- package/dist/agents/baseagent-availability.js +20 -5
- package/dist/agents/baseagent.js +2 -2
- package/dist/agents/claude-runner.js +19 -4
- package/dist/agents/codex/app-server-client.js +36 -3
- package/dist/agents/codex-runner.js +75 -8
- package/dist/aun/group/invite-service.js +3 -2
- package/dist/aun/msg/p2p.js +6 -1
- package/dist/aun/service-proxy.js +18 -6
- package/dist/channels/aun.js +306 -30
- package/dist/cli/agent-create.js +18 -8
- package/dist/cli/aun-commands.js +9 -1
- package/dist/cli/daemon-commands.js +34 -65
- package/dist/cli/daemon-lifecycle-client.js +61 -0
- package/dist/cli/ecmsg-gateway.js +38 -3
- package/dist/cli/events-command.js +73 -0
- package/dist/cli/index.js +31 -14
- package/dist/cli/init.js +75 -0
- package/dist/cli/invoke-command.js +182 -0
- package/dist/cli/managed-command-guard.js +6 -1
- package/dist/cli/provider-command.js +1 -1
- package/dist/cli/restart-monitor.js +67 -50
- package/dist/cli/services-command.js +111 -0
- package/dist/cli/task-context.js +38 -1
- package/dist/cli/team-workspace-command.js +134 -0
- package/dist/cli/thread-command.js +6 -2
- package/dist/cli/watch-logs.js +6 -4
- package/dist/cli/watch-msg.js +1 -1
- package/dist/config/boot-log.js +6 -4
- package/dist/config/builtin-roles.js +2 -2
- package/dist/config/config-field-policy.js +2 -2
- package/dist/config/config-manager.js +1 -8
- package/dist/config/invoke-ipc-service.js +118 -0
- package/dist/config/peer-role-resolver.js +1 -1
- package/dist/config/provider-identity-migration.js +92 -17
- package/dist/config/provider-local-sync.js +2 -0
- package/dist/config/providers-config.js +13 -0
- package/dist/config/providers-management.js +100 -10
- package/dist/config/role-service.js +8 -8
- package/dist/config/role-store.js +22 -22
- package/dist/config/schema-migration.js +86 -88
- package/dist/config/snapshot.js +70 -41
- package/dist/config-store.js +2 -1
- package/dist/core/agent-reload-coordinator.js +6 -4
- package/dist/core/agent-runtime.js +146 -15
- package/dist/core/auth/delegation-authorization.js +66 -0
- package/dist/core/auth/operation-catalog.js +20 -0
- package/dist/core/baseagent-loader.js +75 -42
- package/dist/core/channel-loader.js +45 -13
- package/dist/core/channel-runtime.js +116 -45
- package/dist/core/command/agent-control.js +1 -1
- package/dist/core/command/agent-storage-menu.js +1 -1
- package/dist/core/command/chatmode-config.js +2 -36
- package/dist/core/command/command-handler.js +58 -16
- package/dist/core/command/data-root-resolver.js +32 -23
- package/dist/core/command/eventcenter-menu.js +338 -0
- package/dist/core/command/menu-catalog.js +8 -0
- package/dist/core/command/menu-handler.js +206 -87
- package/dist/core/command/menu-protocol.js +142 -22
- package/dist/core/command/menu-query-batch.js +194 -0
- package/dist/core/command/role-menu.js +27 -15
- 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 +45 -15
- package/dist/core/daemon-lifecycle.js +478 -75
- package/dist/core/handoff/dispatcher.js +9 -3
- package/dist/core/handoff/runtime.js +130 -42
- package/dist/core/handoff/store.js +190 -2
- package/dist/core/handoff/types.js +5 -0
- package/dist/core/initialization/service.js +4 -4
- 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 +51 -11
- package/dist/core/lifecycle-notice.js +10 -4
- package/dist/core/memory/consolidation.js +7 -5
- package/dist/core/message/aun-ipc-sender.js +149 -19
- package/dist/core/message/im-renderer.js +28 -84
- package/dist/core/message/message-bridge.js +57 -4
- package/dist/core/message/message-queue.js +46 -4
- 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 +4 -10
- package/dist/core/message/response-engine.js +163 -52
- package/dist/core/message/send-options.js +7 -4
- package/dist/core/message/send-routing.js +55 -7
- package/dist/core/ownership/owner-resolver.js +8 -0
- package/dist/core/permission/ec-command-parser.js +14 -3
- package/dist/core/permission/protected-paths.js +12 -2
- package/dist/core/permission/shell-environment.js +9 -0
- package/dist/core/session/adapters/claude-session-file-adapter.js +24 -0
- package/dist/core/session/adapters/codex-session-file-adapter.js +80 -0
- package/dist/core/session/adapters/ecagent-session-file-adapter.js +22 -0
- package/dist/core/session/adapters/gemini-session-file-adapter.js +39 -0
- package/dist/core/session/session-file-health.js +243 -0
- package/dist/core/session/session-fs-store.js +163 -3
- package/dist/core/session/session-idle-monitor.js +9 -1
- package/dist/core/session/session-manager.js +36 -2
- 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/directory/owner-directory-admission.js +42 -30
- package/dist/directory/owner-directory-cache.js +143 -126
- package/dist/directory/owner-directory-query-operation.js +9 -8
- package/dist/eck/kit-renderer.js +7 -5
- package/dist/ecweb/basic-settings-service.js +1 -1
- package/dist/ecweb/message-context-service.js +0 -4
- package/dist/ecweb/runtime/lifecycle.js +14 -8
- package/dist/ecweb/runtime/supervisor.js +62 -30
- package/dist/event-center/admission-materializer.js +114 -0
- package/dist/event-center/bus-gate.js +136 -0
- package/dist/event-center/bus-host.js +290 -0
- package/dist/event-center/bus-resolver.js +120 -0
- package/dist/event-center/center-config.js +100 -0
- package/dist/event-center/client-factory.js +50 -0
- package/dist/event-center/daemon.js +45 -0
- package/dist/event-center/directory-source.js +53 -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 +63 -0
- package/dist/event-center/ipc-operation.js +308 -0
- package/dist/event-center/ledger.js +52 -0
- package/dist/event-center/pack-loader.js +202 -0
- package/dist/event-center/pack-manager.js +85 -0
- package/dist/event-center/registry.js +238 -0
- package/dist/event-center/runtime.js +641 -0
- package/dist/event-center/script-runner.js +356 -0
- package/dist/event-center/types.js +35 -0
- package/dist/event-center/validation.js +413 -0
- package/dist/index.js +751 -268
- package/dist/ipc.js +66 -12
- package/dist/paths.js +20 -0
- package/dist/product.js +14 -0
- package/dist/proxy/manager.js +43 -18
- package/dist/proxy/service-supervisor.js +78 -35
- package/dist/response-system/engines/v1/index.js +0 -1
- 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 +458 -0
- package/dist/services/ledger.js +52 -0
- package/dist/services/message-log.js +112 -0
- package/dist/services/pack-manager.js +204 -0
- package/dist/services/reply.js +55 -0
- package/dist/services/router.js +95 -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 +21 -1
- package/dist/trigger/audit.js +19 -4
- package/dist/trigger/authorization.js +14 -5
- package/dist/trigger/event-source.js +1 -1
- package/dist/trigger/history.js +176 -7
- package/dist/trigger/ipc-service.js +3 -1
- package/dist/trigger/manager.js +1 -3
- package/dist/trigger/scheduler.js +78 -5
- package/dist/trigger/script-sandbox.js +118 -22
- package/dist/utils/cross-platform.js +175 -13
- package/dist/utils/evolcore-version.js +69 -27
- package/dist/utils/host-info.js +11 -8
- package/dist/utils/instance-registry.js +19 -13
- package/dist/utils/npm-ops.js +48 -0
- package/dist/utils/process-introspect.js +109 -10
- package/dist/utils/startup-trace.js +222 -44
- package/dist/utils/windows-shell-trust.js +80 -6
- package/kits/docs/INDEX.md +2 -2
- package/kits/docs/aun/ABILITY_CALLING.md +10 -17
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +5 -2
- package/kits/docs/evolcore/ability.md +4 -0
- package/kits/docs/evolcore/aid.md +1 -1
- package/kits/docs/evolcore/ctl.md +2 -1
- package/kits/docs/evolcore/event-center.md +207 -0
- package/kits/docs/evolcore/file-navigation.md +10 -264
- package/kits/docs/evolcore/fs.md +3 -2
- package/kits/docs/evolcore/group.md +2 -2
- package/kits/docs/evolcore/memory-architecture.md +2 -0
- package/kits/docs/evolcore/menu-exec-schema-commands.md +1 -1
- package/kits/docs/evolcore/menu-protocol.md +21 -0
- package/kits/docs/evolcore/msg.md +27 -8
- package/kits/docs/evolcore/provider.md +23 -3
- package/kits/docs/evolcore/response.md +5 -5
- package/kits/docs/evolcore/services.md +277 -0
- package/kits/docs/evolcore/task.md +2 -0
- package/kits/docs/evolcore/team-workspace.md +41 -0
- package/kits/eck_manifest.json +45 -7
- package/kits/eck_message_manifest.json +3 -3
- package/kits/rules/02-navigation.md +10 -1
- package/kits/rules/06-channel.md +5 -6
- 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/daemon.schema.1.json +5 -0
- package/kits/schemas/daemon.schema.2.json +5 -0
- package/kits/schemas/daemon.schema.3.json +2 -1
- package/kits/schemas/daemon.schema.4.json +2 -1
- package/kits/schemas/daemon.schema.5.json +2 -1
- package/kits/schemas/daemon.schema.6.json +1 -1
- package/kits/schemas/daemon.schema.7.json +1 -1
- package/kits/schemas/daemon.schema.8.json +2 -1
- package/kits/schemas/daemon.schema.9.json +2 -1
- package/kits/schemas/relation-config.schema.12.json +2 -3
- package/kits/schemas/role-config.schema.2.json +4 -4
- package/kits/schemas/role-registry.schema.1.json +2 -2
- package/kits/schemas/single-session.schema.1.json +1 -1
- package/kits/schemas/single-session.schema.2.json +1 -1
- package/kits/schemas/single-session.schema.3.json +1 -1
- 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 +8 -5
- 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/system-fragments/channel.md +3 -3
- package/kits/templates/system-fragments/commands.md +9 -7
- package/kits/templates/system-fragments/reply.md +2 -6
- package/kits/templates/system-fragments/session.md +1 -1
- package/kits/templates/system-fragments/thread.md +11 -9
- package/package.json +5 -6
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getRunnerCatalog, peekRunnerCatalog, catalogEfforts, resolveCatalogModel, assertCatalogSelectable } from '../core/model/model-catalog.js';
|
|
2
2
|
import { query, forkSession as sdkForkSession, getSessionMessages as sdkGetSessionMessages, resolveSettings as sdkResolveSettings, } from '@anthropic-ai/claude-agent-sdk';
|
|
3
|
-
import { spawn
|
|
3
|
+
import { spawn } from 'child_process';
|
|
4
4
|
import { createRequire } from 'module';
|
|
5
5
|
import { ensureDir } from '../utils/atomic-write.js';
|
|
6
6
|
import { resolveAnthropicConfig } from './baseagent.js';
|
|
@@ -22,7 +22,7 @@ import { checkBashDescription, checkDangerousCommand, checkReadonly, evaluateToo
|
|
|
22
22
|
import { sanitizeShellExecutionEnvironment } from '../core/permission/shell-environment.js';
|
|
23
23
|
import { summarizeToolInput, summarizeToolInputForAudit } from '../utils/tool-summary.js';
|
|
24
24
|
import { renderToolTime } from './tool-time-context.js';
|
|
25
|
-
import { encodePath } from '../utils/cross-platform.js';
|
|
25
|
+
import { encodePath, probeCli, probeCliSync } from '../utils/cross-platform.js';
|
|
26
26
|
import { getPackageRoot, resolvePaths } from '../paths.js';
|
|
27
27
|
import { resolveEffective } from '../config/config-manager.js';
|
|
28
28
|
import { sanitizeSessionTitle } from '../core/session/session-title.js';
|
|
@@ -165,8 +165,23 @@ export function probeBundledClaudeVersion() {
|
|
|
165
165
|
if (!executable)
|
|
166
166
|
return undefined;
|
|
167
167
|
try {
|
|
168
|
-
const raw =
|
|
169
|
-
|
|
168
|
+
const raw = probeCliSync('bundled-claude', ['--version'], {
|
|
169
|
+
executable, validateOutput: output => /^\d+\.\d+\.\d+\b/.test(output.trim()),
|
|
170
|
+
});
|
|
171
|
+
return raw.trim().split(/\s+/)[0] || undefined;
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/** Shares the installation-aware probe cache and in-flight request with other readers. */
|
|
178
|
+
export async function probeBundledClaudeVersionAsync() {
|
|
179
|
+
const executable = resolveBundledClaudeExecutable();
|
|
180
|
+
if (!executable)
|
|
181
|
+
return undefined;
|
|
182
|
+
try {
|
|
183
|
+
const raw = await probeCli('bundled-claude', ['--version'], {
|
|
184
|
+
executable, validateOutput: output => /^\d+\.\d+\.\d+\b/.test(output.trim()),
|
|
170
185
|
});
|
|
171
186
|
return raw.trim().split(/\s+/)[0] || undefined;
|
|
172
187
|
}
|
|
@@ -92,6 +92,7 @@ export class CodexAppServerClient {
|
|
|
92
92
|
return this.request('thread/start', {
|
|
93
93
|
cwd: projectPath,
|
|
94
94
|
model: options?.model ?? this.options.model ?? null,
|
|
95
|
+
...(this.runtimeModelProvider() ? { modelProvider: this.runtimeModelProvider() } : {}),
|
|
95
96
|
approvalPolicy: options?.approvalPolicy ?? null,
|
|
96
97
|
approvalsReviewer: options?.approvalsReviewer ?? this.options.approvalsReviewer ?? null,
|
|
97
98
|
...(configUsesPermissionProfile
|
|
@@ -116,6 +117,7 @@ export class CodexAppServerClient {
|
|
|
116
117
|
threadId,
|
|
117
118
|
cwd: projectPath,
|
|
118
119
|
model: options?.model ?? this.options.model ?? null,
|
|
120
|
+
...(this.runtimeModelProvider() ? { modelProvider: this.runtimeModelProvider() } : {}),
|
|
119
121
|
approvalPolicy: options?.approvalPolicy ?? null,
|
|
120
122
|
approvalsReviewer: options?.approvalsReviewer ?? this.options.approvalsReviewer ?? null,
|
|
121
123
|
...(configUsesPermissionProfile
|
|
@@ -225,6 +227,28 @@ export class CodexAppServerClient {
|
|
|
225
227
|
async threadRead(threadId, includeTurns = true, timeoutMs) {
|
|
226
228
|
return this.request('thread/read', { threadId, includeTurns }, timeoutMs);
|
|
227
229
|
}
|
|
230
|
+
getModelProvider() {
|
|
231
|
+
return this.runtimeModelProvider();
|
|
232
|
+
}
|
|
233
|
+
isRunning() {
|
|
234
|
+
return this.proc !== null;
|
|
235
|
+
}
|
|
236
|
+
async threadLoadedList() {
|
|
237
|
+
const data = new Set();
|
|
238
|
+
const cursors = new Set();
|
|
239
|
+
let cursor;
|
|
240
|
+
do {
|
|
241
|
+
const page = await this.request('thread/loaded/list', cursor ? { cursor } : {}, 5000);
|
|
242
|
+
for (const id of page.data)
|
|
243
|
+
data.add(id);
|
|
244
|
+
cursor = page.nextCursor || undefined;
|
|
245
|
+
if (cursor && cursors.has(cursor))
|
|
246
|
+
throw new Error('Codex loaded thread pagination repeated a cursor');
|
|
247
|
+
if (cursor)
|
|
248
|
+
cursors.add(cursor);
|
|
249
|
+
} while (cursor);
|
|
250
|
+
return { data: [...data] };
|
|
251
|
+
}
|
|
228
252
|
async threadRollback(threadId, numTurns) {
|
|
229
253
|
return this.request('thread/rollback', { threadId, numTurns });
|
|
230
254
|
}
|
|
@@ -239,6 +263,7 @@ export class CodexAppServerClient {
|
|
|
239
263
|
threadId,
|
|
240
264
|
cwd: projectPath,
|
|
241
265
|
model: options?.model ?? this.options.model ?? null,
|
|
266
|
+
...(this.runtimeModelProvider() ? { modelProvider: this.runtimeModelProvider() } : {}),
|
|
242
267
|
approvalPolicy: options?.approvalPolicy ?? null,
|
|
243
268
|
approvalsReviewer: options?.approvalsReviewer ?? this.options.approvalsReviewer ?? null,
|
|
244
269
|
...(options?.permissions && !configUsesPermissionProfile
|
|
@@ -260,6 +285,9 @@ export class CodexAppServerClient {
|
|
|
260
285
|
}
|
|
261
286
|
buildThreadConfig(effort, config) {
|
|
262
287
|
const merged = { ...(config ?? {}) };
|
|
288
|
+
const provider = this.runtimeModelProvider();
|
|
289
|
+
if (provider)
|
|
290
|
+
merged.model_provider = provider;
|
|
263
291
|
if (effort)
|
|
264
292
|
merged.model_reasoning_effort = effort;
|
|
265
293
|
return Object.keys(merged).length > 0 ? merged : null;
|
|
@@ -756,6 +784,13 @@ export class CodexAppServerClient {
|
|
|
756
784
|
+ 'Restart EvolCore to install missing hooks and reload the Codex policy.');
|
|
757
785
|
}
|
|
758
786
|
}
|
|
787
|
+
runtimeModelProvider() {
|
|
788
|
+
if (!this.options.baseUrl && !this.options.provider
|
|
789
|
+
&& !Object.keys(this.options.headers ?? {}).length && !Object.keys(this.options.queryParams ?? {}).length)
|
|
790
|
+
return undefined;
|
|
791
|
+
const provider = this.options.provider?.trim();
|
|
792
|
+
return provider && !BUILT_IN_CODEX_PROVIDER_IDS.has(provider.toLowerCase()) ? provider : runtimeProviderId(this.options.baseUrl);
|
|
793
|
+
}
|
|
759
794
|
buildProcessArgs() {
|
|
760
795
|
const args = ['app-server', '--listen', 'stdio://'];
|
|
761
796
|
// 记忆只走 EvolCore(ec memory):显式关闭 Codex 原生 memories,
|
|
@@ -773,9 +808,7 @@ export class CodexAppServerClient {
|
|
|
773
808
|
if (hasHeaders || hasQueryParams || this.options.baseUrl || this.options.provider) {
|
|
774
809
|
const configuredProvider = this.options.provider?.trim();
|
|
775
810
|
const useRuntimeProvider = !configuredProvider || BUILT_IN_CODEX_PROVIDER_IDS.has(configuredProvider.toLowerCase());
|
|
776
|
-
const providerName =
|
|
777
|
-
? configuredProvider
|
|
778
|
-
: runtimeProviderId(this.options.baseUrl);
|
|
811
|
+
const providerName = this.runtimeModelProvider();
|
|
779
812
|
const provider = tomlProviderKey(providerName);
|
|
780
813
|
args.push('--config', `model_provider=${JSON.stringify(providerName)}`);
|
|
781
814
|
args.push('--config', `model_providers.${provider}.name=${JSON.stringify('EvolCore runtime gateway')}`);
|
|
@@ -31,8 +31,9 @@ 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
|
-
import { probeCli, probeCliSync } from '../utils/cross-platform.js';
|
|
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';
|
|
37
38
|
import { buildModelRequestHeaders } from './request-identity.js';
|
|
38
39
|
import { extractStructuredToolErrorMarker, normalizeToolErrorClassification, normalizeToolErrorCode, normalizeToolErrorDetailCode, } from '../core/permission/tool-error-code.js';
|
|
@@ -303,9 +304,6 @@ export function parseCodexCliVersion(output) {
|
|
|
303
304
|
export function isCodexCliVersionSupported(version) {
|
|
304
305
|
return compareVersions(version, MIN_CODEX_CLI_VERSION) >= 0;
|
|
305
306
|
}
|
|
306
|
-
// Windows shim/process startup can exceed the quick probe deadline under load.
|
|
307
|
-
const CODEX_CLI_PROBE_TIMEOUT_MS = 3000;
|
|
308
|
-
const CODEX_CLI_PROBE_RETRY_TIMEOUT_MS = 15_000;
|
|
309
307
|
function compactCodexProbeText(value, maxLength = 600) {
|
|
310
308
|
if (Buffer.isBuffer(value))
|
|
311
309
|
value = value.toString('utf-8');
|
|
@@ -770,6 +768,65 @@ export class CodexRunner {
|
|
|
770
768
|
}
|
|
771
769
|
return existing.client;
|
|
772
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
|
+
}
|
|
773
830
|
async archiveThreadForHandoff(sourceClient, targetClient, threadId) {
|
|
774
831
|
const existing = this.threadSubscriptions.get(threadId);
|
|
775
832
|
if (existing && existing.client !== sourceClient) {
|
|
@@ -2297,6 +2354,7 @@ export class CodexRunner {
|
|
|
2297
2354
|
let previousAppServer;
|
|
2298
2355
|
const openThread = async () => {
|
|
2299
2356
|
if (agentSessionId) {
|
|
2357
|
+
await this.prepareSessionProvider(appServer, agentSessionId, operationController?.signal);
|
|
2300
2358
|
// A thread may have been loaded by the other permission-mode client.
|
|
2301
2359
|
// Release that one thread before asking this client to resume it.
|
|
2302
2360
|
previousAppServer = await this.prepareThreadSubscription(appServer, agentSessionId);
|
|
@@ -2401,6 +2459,8 @@ export class CodexRunner {
|
|
|
2401
2459
|
threadOptions = buildThreadOptions(true);
|
|
2402
2460
|
threadResponse = await openThread();
|
|
2403
2461
|
}
|
|
2462
|
+
if (agentSessionId)
|
|
2463
|
+
this.assertResumedProvider(appServer, threadResponse, agentSessionId);
|
|
2404
2464
|
let threadId = threadResponse.thread?.id || agentSessionId;
|
|
2405
2465
|
if (!threadId)
|
|
2406
2466
|
throw new Error('Codex app-server did not return a thread id');
|
|
@@ -3004,8 +3064,9 @@ export class CodexRunner {
|
|
|
3004
3064
|
let compactAppServer;
|
|
3005
3065
|
try {
|
|
3006
3066
|
const compactMode = normalizeExecutionPermissionMode(modelOverride?.permissionMode ?? this.chatModes.get(_sessionId) ?? this.currentMode);
|
|
3007
|
-
const appServer = this.getAppServerClient(compactMode === 'fullaccess');
|
|
3067
|
+
const appServer = this.getAppServerClient(compactMode === 'fullaccess', modelOverride?.provider);
|
|
3008
3068
|
compactAppServer = appServer;
|
|
3069
|
+
await this.prepareSessionProvider(appServer, agentSessionId);
|
|
3009
3070
|
await this.prepareThreadSubscription(appServer, agentSessionId);
|
|
3010
3071
|
this.onCompactStart?.(_sessionId);
|
|
3011
3072
|
try {
|
|
@@ -3031,7 +3092,7 @@ export class CodexRunner {
|
|
|
3031
3092
|
const compactSessionToken = this.ensureThreadCredential(agentSessionId);
|
|
3032
3093
|
if (!compactSessionToken)
|
|
3033
3094
|
throw new Error('Codex thread session credential is unavailable');
|
|
3034
|
-
await appServer.threadResume(agentSessionId, _projectPath, {
|
|
3095
|
+
const resumed = await appServer.threadResume(agentSessionId, _projectPath, {
|
|
3035
3096
|
model: compactModel,
|
|
3036
3097
|
effort: compactEffort,
|
|
3037
3098
|
approvalPolicy: compactPolicy,
|
|
@@ -3039,6 +3100,7 @@ export class CodexRunner {
|
|
|
3039
3100
|
...(executionSandbox.sandbox ? { sandbox: executionSandbox.sandbox } : {}),
|
|
3040
3101
|
config: this.sanitizeThreadEnvironmentConfig(this.mergeThreadConfig(executionSandbox.permissionProfileConfig, capabilityConfig, externalToolConfig, this.buildEvolcoreShellEnvironmentConfig(_sessionId, compactSessionToken), this.buildLifecycleLockdownConfig(compactMode)), compactMode),
|
|
3041
3102
|
});
|
|
3103
|
+
this.assertResumedProvider(appServer, resumed, agentSessionId);
|
|
3042
3104
|
this.markThreadSubscribed(appServer, agentSessionId);
|
|
3043
3105
|
this.threadProjectPaths.set(agentSessionId, path.resolve(_projectPath));
|
|
3044
3106
|
this.bindExternalToolBoundary(agentSessionId, externalToolConfig);
|
|
@@ -3346,7 +3408,10 @@ export class CodexRunner {
|
|
|
3346
3408
|
const mode = normalizePermissionMode(context?.permissionMode).mode;
|
|
3347
3409
|
const executionSandbox = this.buildExecutionSandboxOptions(sessionKey, mode, projectPath, undefined, undefined, context ?? {});
|
|
3348
3410
|
const capabilityConfig = await this.resolveCapabilityThreadConfig(projectPath);
|
|
3349
|
-
|
|
3411
|
+
// Fork against the connection that owns the source thread. Codex keeps
|
|
3412
|
+
// normal and full-access threads on separate app-server clients; using the
|
|
3413
|
+
// default client here makes full-access forks time out or lose the thread.
|
|
3414
|
+
const appServer = this.getAppServerClientForThread(agentSessionId);
|
|
3350
3415
|
const externalToolConfig = await this.resolveExternalToolApprovalConfig(appServer, projectPath, capabilityConfig, mode);
|
|
3351
3416
|
if (sessionKey)
|
|
3352
3417
|
await this.assertProactiveHookAvailability(sessionKey, appServer);
|
|
@@ -3375,7 +3440,7 @@ export class CodexRunner {
|
|
|
3375
3440
|
async forkSessionAt(agentSessionId, projectPath, assistantMessageId, title, context) {
|
|
3376
3441
|
const release = await this.acquireThreadOperation(this.threadOperationKey(agentSessionId), 'forkAt');
|
|
3377
3442
|
try {
|
|
3378
|
-
const appServer = this.
|
|
3443
|
+
const appServer = this.getAppServerClientForThread(agentSessionId);
|
|
3379
3444
|
const history = await this.readForkHistory(appServer, agentSessionId);
|
|
3380
3445
|
const messages = this.mapThreadToSessionMessages(history, agentSessionId);
|
|
3381
3446
|
const turns = buildTranscriptTurns(messages);
|
|
@@ -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;
|
|
@@ -285,9 +285,10 @@ export class GroupInviteReviewService {
|
|
|
285
285
|
this.router = router;
|
|
286
286
|
this.store = store;
|
|
287
287
|
this.timer = setInterval(() => {
|
|
288
|
-
for (const runtime of this.bindings.values())
|
|
289
|
-
if (runtime.nextSync <= Date.now())
|
|
288
|
+
for (const runtime of this.bindings.values()) {
|
|
289
|
+
if (runtime.channel.isConnected() && runtime.nextSync <= Date.now())
|
|
290
290
|
this.wake(runtime);
|
|
291
|
+
}
|
|
291
292
|
}, RECONCILE_TICK_MS);
|
|
292
293
|
this.timer.unref?.();
|
|
293
294
|
}
|
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,
|
|
@@ -21,7 +21,7 @@ import { ServiceProxyClient, EndpointPolicy } from '@agentunion/fastaun';
|
|
|
21
21
|
import { resolvePaths } from '../paths.js';
|
|
22
22
|
import { logger } from '../utils/logger.js';
|
|
23
23
|
import { parseEcwebInstanceRecord } from '../contracts/ecweb-instance.js';
|
|
24
|
-
import {
|
|
24
|
+
import { getProcessStartTimeAsync, startTimeMatches } from '../utils/process-introspect.js';
|
|
25
25
|
const LOG = '[ServiceProxy]';
|
|
26
26
|
const INSTANCE_DISCOVERY_TIMEOUT_MS = 10_000;
|
|
27
27
|
const INSTANCE_DISCOVERY_INTERVAL_MS = 250;
|
|
@@ -33,7 +33,7 @@ function sleep(ms) {
|
|
|
33
33
|
* 读 data/instance/ 下指定服务的存活实例端口。
|
|
34
34
|
* 取 startedAt 最新的一条(多实例保护下通常只有一条存活)。
|
|
35
35
|
*/
|
|
36
|
-
function discoverInstancePort(serviceName, expectedPort) {
|
|
36
|
+
async function discoverInstancePort(serviceName, expectedPort) {
|
|
37
37
|
const dir = resolvePaths().instanceDir;
|
|
38
38
|
let files;
|
|
39
39
|
try {
|
|
@@ -64,14 +64,15 @@ function discoverInstancePort(serviceName, expectedPort) {
|
|
|
64
64
|
&& Number.isFinite(rec.startedAt)
|
|
65
65
|
&& (raw.owner !== 'evolcore-service-supervisor'
|
|
66
66
|
|| ((raw.state === undefined || raw.state === 'ready')
|
|
67
|
-
&& startTimeMatches(rec.startedAt,
|
|
68
|
-
&& (serviceName !== 'ecweb' || !('schemaVersion' in rec) || startTimeMatches(rec.startedAt,
|
|
67
|
+
&& startTimeMatches(rec.startedAt, await getProcessStartTimeAsync(rec.pid))))
|
|
68
|
+
&& (serviceName !== 'ecweb' || !('schemaVersion' in rec) || startTimeMatches(rec.startedAt, await getProcessStartTimeAsync(rec.pid)))
|
|
69
69
|
&& rec.startedAt >= 0
|
|
70
70
|
&& Number.isInteger(rec.port)
|
|
71
71
|
&& rec.port >= 1
|
|
72
72
|
&& rec.port <= 65535
|
|
73
73
|
&& (expectedPort === undefined || rec.port === expectedPort)) {
|
|
74
|
-
|
|
74
|
+
if (isProcessAlive(rec.pid))
|
|
75
|
+
records.push({ pid: rec.pid, port: rec.port, startedAt: rec.startedAt });
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
catch {
|
|
@@ -97,7 +98,7 @@ async function waitForInstancePort(serviceName, expectedPort) {
|
|
|
97
98
|
const deadline = Date.now() + INSTANCE_DISCOVERY_TIMEOUT_MS;
|
|
98
99
|
let loggedWait = false;
|
|
99
100
|
while (Date.now() <= deadline) {
|
|
100
|
-
const port = discoverInstancePort(serviceName, expectedPort);
|
|
101
|
+
const port = await discoverInstancePort(serviceName, expectedPort);
|
|
101
102
|
if (port)
|
|
102
103
|
return port;
|
|
103
104
|
if (!loggedWait) {
|
|
@@ -130,6 +131,14 @@ async function resolveEndpoint(svc) {
|
|
|
130
131
|
logger.warn(`${LOG} 服务 "${svc.name}" 未配置有效 proxy.source,跳过`);
|
|
131
132
|
return null;
|
|
132
133
|
}
|
|
134
|
+
/** Current endpoint only; watching instance files must not start discovery waits. */
|
|
135
|
+
export async function readServiceProxyEndpoint(svc) {
|
|
136
|
+
if (svc.proxy?.source === 'instance') {
|
|
137
|
+
const port = await discoverInstancePort(svc.name, svc.port);
|
|
138
|
+
return port ? `http://127.0.0.1:${port}` : null;
|
|
139
|
+
}
|
|
140
|
+
return svc.proxy?.source === 'static' ? svc.proxy.endpoint?.trim() || null : null;
|
|
141
|
+
}
|
|
133
142
|
/** Probe the local service root without exposing the local endpoint to callers. */
|
|
134
143
|
export async function probeServiceRoot(service) {
|
|
135
144
|
const endpoint = await resolveEndpoint(service);
|
|
@@ -168,6 +177,7 @@ export function startServiceProxy(controlChannel, providerAid, configuredService
|
|
|
168
177
|
let stopped = false;
|
|
169
178
|
let proxyClient = null;
|
|
170
179
|
const startupAbort = new AbortController();
|
|
180
|
+
const endpoints = {};
|
|
171
181
|
const run = async () => {
|
|
172
182
|
try {
|
|
173
183
|
// 控制 AID 与本地服务并行启动;等待认证连接完成,避免把正常启动阶段当作隧道故障。
|
|
@@ -240,6 +250,7 @@ export function startServiceProxy(controlChannel, providerAid, configuredService
|
|
|
240
250
|
metadata: svc.proxy?.metadata ?? {},
|
|
241
251
|
});
|
|
242
252
|
registered += 1;
|
|
253
|
+
endpoints[svc.name] = endpoint;
|
|
243
254
|
logger.info(`${LOG} 注册服务 "${svc.name}" → ${endpoint} (type=${svc.proxy?.serviceType ?? 'http'}, visibility=${svc.proxy?.visibility ?? 'private'})`);
|
|
244
255
|
}
|
|
245
256
|
catch (e) {
|
|
@@ -286,6 +297,7 @@ export function startServiceProxy(controlChannel, providerAid, configuredService
|
|
|
286
297
|
void ready.catch(() => { });
|
|
287
298
|
return {
|
|
288
299
|
ready,
|
|
300
|
+
endpoints,
|
|
289
301
|
unregister: async (serviceNames) => {
|
|
290
302
|
if (!proxyClient || serviceNames.length === 0)
|
|
291
303
|
return;
|