@evomap/evolver-proxy 2.0.0-beta.2 → 2.0.0-beta.22
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/dist/bin/evolver-llm-proxy.js +0 -0
- package/dist/bin/evolver-proxy.d.ts +105 -7
- package/dist/bin/evolver-proxy.js +877 -121
- package/dist/daemon/atpConsent.js +5 -2
- package/dist/daemon/collaborationFacade.js +26 -16
- package/dist/daemon/proxyDaemon.d.ts +65 -0
- package/dist/daemon/proxyDaemon.js +1384 -29
- package/dist/daemon/publishRecallVerifier.d.ts +114 -0
- package/dist/daemon/publishRecallVerifier.js +495 -0
- package/dist/daemon/selectHub.js +5 -3
- package/dist/daemon/systemdNotifier.d.ts +48 -0
- package/dist/daemon/systemdNotifier.js +163 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/lifecycle/claimNudge.d.ts +20 -0
- package/dist/lifecycle/claimNudge.js +124 -0
- package/dist/lifecycle/legacyNodeId.d.ts +11 -13
- package/dist/lifecycle/legacyNodeId.js +35 -20
- package/dist/lifecycle/manager.d.ts +4 -0
- package/dist/lifecycle/manager.js +15 -2
- package/dist/llm/server.js +24 -4
- package/dist/llm/traceControl.js +1 -1
- package/dist/llm/upstream.d.ts +5 -1
- package/dist/llm/upstream.js +72 -2
- package/dist/private/accountAssetCompatibility.d.ts +29 -0
- package/dist/private/accountAssetCompatibility.js +196 -0
- package/dist/private/adapterLoader.d.ts +21 -1
- package/dist/private/adapterLoader.js +242 -7
- package/dist/private/nodeCredentialStore.d.ts +23 -0
- package/dist/private/nodeCredentialStore.js +210 -0
- package/dist/router/messagesRoute.js +9 -3
- package/dist/router/providerRoutes.js +7 -3
- package/dist/selfUpdate/bootstrap.d.ts +162 -0
- package/dist/selfUpdate/bootstrap.js +3524 -0
- package/dist/selfUpdate/bootstrapReadiness.d.ts +9 -0
- package/dist/selfUpdate/bootstrapReadiness.js +153 -0
- package/dist/selfUpdate/builtinKey.d.ts +4 -0
- package/dist/selfUpdate/builtinKey.js +16 -0
- package/dist/selfUpdate/controllerLifecycleAuthority.d.ts +45 -0
- package/dist/selfUpdate/controllerLifecycleAuthority.js +61 -0
- package/dist/selfUpdate/executor.d.ts +27 -11
- package/dist/selfUpdate/executor.js +233 -58
- package/dist/selfUpdate/failureCodes.d.ts +10 -0
- package/dist/selfUpdate/failureCodes.js +13 -0
- package/dist/selfUpdate/index.d.ts +5 -1
- package/dist/selfUpdate/index.js +5 -1
- package/dist/selfUpdate/lastUpdate.d.ts +3 -1
- package/dist/selfUpdate/lastUpdate.js +37 -6
- package/dist/selfUpdate/migration.d.ts +158 -0
- package/dist/selfUpdate/migration.js +2672 -0
- package/dist/selfUpdate/policy.d.ts +19 -2
- package/dist/selfUpdate/policy.js +76 -2
- package/dist/selfUpdate/recoveryChildStartGate.d.ts +29 -0
- package/dist/selfUpdate/recoveryChildStartGate.js +319 -0
- package/dist/selfUpdate/releaseBinary.d.ts +13 -0
- package/dist/selfUpdate/releaseBinary.js +93 -10
- package/dist/selfUpdate/transaction.d.ts +117 -0
- package/dist/selfUpdate/transaction.js +1322 -0
- package/dist/selfUpdate/unixController.d.ts +23 -0
- package/dist/selfUpdate/unixController.js +514 -0
- package/dist/selfUpdate/version.d.ts +6 -2
- package/dist/selfUpdate/version.js +5 -3
- package/dist/selfUpdate/windowsController.d.ts +35 -0
- package/dist/selfUpdate/windowsController.js +655 -0
- package/dist/selfUpdate/windowsUpdater.d.ts +104 -0
- package/dist/selfUpdate/windowsUpdater.js +882 -0
- package/dist/sync/engine.d.ts +12 -0
- package/dist/sync/engine.js +255 -64
- package/package.json +10 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
2
3
|
import { join } from 'node:path';
|
|
3
|
-
import { events } from '@evomap/evolver-core';
|
|
4
4
|
export class AtpProxySpendConsentError extends Error {
|
|
5
5
|
source;
|
|
6
6
|
constructor(source) {
|
|
@@ -10,7 +10,10 @@ export class AtpProxySpendConsentError extends Error {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
function atpProxyConsentPath(env = process.env) {
|
|
13
|
-
const home = env['EVOMAP_DIR']
|
|
13
|
+
const home = [env['EVOMAP_DIR'], env['EVOLVER_HOME'], env['EVOMAP_HOME']]
|
|
14
|
+
.map((value) => value?.trim())
|
|
15
|
+
.find((value) => Boolean(value))
|
|
16
|
+
?? join(homedir(), '.evomap');
|
|
14
17
|
return join(home, 'evolution', 'atp-autobuy-ack.json');
|
|
15
18
|
}
|
|
16
19
|
export function getAtpProxyConsent(env = process.env, ackPath = atpProxyConsentPath(env)) {
|
|
@@ -353,16 +353,19 @@ export class CollaborationFacade {
|
|
|
353
353
|
async mailboxPoll(ctx) {
|
|
354
354
|
const body = asRecord(await ctx.readJson());
|
|
355
355
|
const type = optionalString(body['type']);
|
|
356
|
-
const
|
|
356
|
+
const channel = optionalString(body['channel']);
|
|
357
|
+
const direction = optionalDirection(body['direction']) ?? 'inbound';
|
|
357
358
|
const limit = boundedMailboxPollLimit(body['limit']);
|
|
358
|
-
const
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
359
|
+
const runtimeNamespace = legacyMailboxRuntimeNamespace(channel, this.deps.runtimeNamespace ?? 'default');
|
|
360
|
+
const messages = runtimeNamespace === undefined
|
|
361
|
+
? []
|
|
362
|
+
: this.deps.store.list({
|
|
363
|
+
status: 'pending',
|
|
364
|
+
runtimeNamespace,
|
|
365
|
+
...(type ? { type } : {}),
|
|
366
|
+
direction,
|
|
367
|
+
limit,
|
|
368
|
+
}).map(v1Message);
|
|
366
369
|
ctx.json(200, { messages, count: messages.length });
|
|
367
370
|
return true;
|
|
368
371
|
}
|
|
@@ -671,18 +674,19 @@ function v1Message(message) {
|
|
|
671
674
|
return {
|
|
672
675
|
id: message.id,
|
|
673
676
|
message_id: message.id,
|
|
674
|
-
channel: 'evomap-hub',
|
|
677
|
+
channel: message.runtimeNamespace === 'default' ? 'evomap-hub' : message.runtimeNamespace,
|
|
675
678
|
direction: message.direction,
|
|
676
679
|
type: message.type === 'dm_outbound' || isDirectDialogMessage(message) ? 'dm' : message.type,
|
|
677
680
|
status: message.status === 'done' ? (message.direction === 'inbound' ? 'delivered' : 'synced') : message.status,
|
|
678
681
|
payload: message.payload,
|
|
679
|
-
priority:
|
|
680
|
-
ref_id: message.replyTo,
|
|
682
|
+
priority: message.priority,
|
|
683
|
+
ref_id: message.replyTo ?? message.correlationId,
|
|
681
684
|
created_at: message.createdAt,
|
|
682
685
|
synced_at: message.status === 'done' ? message.updatedAt : null,
|
|
683
686
|
expires_at: message.ttlAt,
|
|
684
687
|
retry_count: message.attempts,
|
|
685
|
-
|
|
688
|
+
next_retry_at: message.nextRetryAt,
|
|
689
|
+
error: message.lastError,
|
|
686
690
|
};
|
|
687
691
|
}
|
|
688
692
|
function writeOperationError(ctx, error) {
|
|
@@ -721,10 +725,10 @@ function classifyOperationError(error) {
|
|
|
721
725
|
const candidate = error;
|
|
722
726
|
const status = numberValue(candidate?.statusCode) ?? numberValue(candidate?.status);
|
|
723
727
|
const signature = `${String(candidate?.name ?? '')} ${String(candidate?.code ?? '')}`;
|
|
724
|
-
if (status === 401 || /auth/i.test(signature))
|
|
725
|
-
return { status: 401, code: 'unauthorized', message: 'Hub authentication failed', retryable: false };
|
|
726
728
|
if (status === 403 || /forbidden|permission/i.test(signature))
|
|
727
729
|
return { status: 403, code: 'forbidden', message: 'Hub permission denied', retryable: false };
|
|
730
|
+
if (status === 401 || /auth/i.test(signature))
|
|
731
|
+
return { status: 401, code: 'unauthorized', message: 'Hub authentication failed', retryable: false };
|
|
728
732
|
if (status === 404)
|
|
729
733
|
return { status: 404, code: 'not_found', message: 'Task or claim not found', retryable: false };
|
|
730
734
|
if (status === 409 || /conflict|already_claimed/i.test(signature))
|
|
@@ -741,7 +745,7 @@ function classifyOperationError(error) {
|
|
|
741
745
|
function isDurablyRecoverableAuthError(error) {
|
|
742
746
|
const candidate = error;
|
|
743
747
|
const status = numberValue(candidate?.statusCode) ?? numberValue(candidate?.status);
|
|
744
|
-
return
|
|
748
|
+
return status === 401;
|
|
745
749
|
}
|
|
746
750
|
class FacadeTimeoutError extends Error {
|
|
747
751
|
}
|
|
@@ -794,6 +798,12 @@ function optionalString(value) {
|
|
|
794
798
|
function optionalDirection(value) {
|
|
795
799
|
return value === 'inbound' || value === 'outbound' || value === 'local' ? value : undefined;
|
|
796
800
|
}
|
|
801
|
+
function legacyMailboxRuntimeNamespace(requestedChannel, runtimeNamespace) {
|
|
802
|
+
if (requestedChannel === undefined || requestedChannel === 'evomap-hub' || requestedChannel === runtimeNamespace) {
|
|
803
|
+
return runtimeNamespace;
|
|
804
|
+
}
|
|
805
|
+
return undefined;
|
|
806
|
+
}
|
|
797
807
|
function requiredValue(record, ...keys) {
|
|
798
808
|
for (const key of keys) {
|
|
799
809
|
const value = optionalString(record[key]);
|
|
@@ -3,11 +3,15 @@ import { SyncEngine, type OutboundResult, type InboundResult } from '../sync/eng
|
|
|
3
3
|
import { LifecycleManager, type HelloLifecycleMode, type HelloResult, type HeartbeatOptions, type HeartbeatResult, type HeartbeatTickResult } from '../lifecycle/manager.js';
|
|
4
4
|
import { type SelfUpdateDeps } from '../selfUpdate/executor.js';
|
|
5
5
|
import type { AtpOrderConsentGate } from './atpConsent.js';
|
|
6
|
+
import { type PublishRecallVerifierPort } from './publishRecallVerifier.js';
|
|
6
7
|
type HubCapability = hubNs.HubCapability;
|
|
7
8
|
type AssetStoreProvider = assetstore.AssetStoreProvider;
|
|
9
|
+
type ConversationDistillExecutionVerifier = (input: hubNs.ConversationDistillInput, signal: AbortSignal) => Promise<hubNs.ConversationDistillVerifiedExecution | null>;
|
|
8
10
|
export declare const DEFAULT_IPC_PORT = 19820;
|
|
9
11
|
export interface ProxyDaemonDeps {
|
|
10
12
|
hub: HubCapability;
|
|
13
|
+
/** Immutable Hub selection for IPC callers that must fail closed across public/private runtimes. */
|
|
14
|
+
hubMode?: 'public' | 'private';
|
|
11
15
|
/** 二选一: 传 storePath 让 ProxyDaemon 建 store, 或传已建 store(供 hub senderId 共享同一 node_id). */
|
|
12
16
|
storePath?: string;
|
|
13
17
|
store?: mailbox.MailboxStore;
|
|
@@ -16,6 +20,16 @@ export interface ProxyDaemonDeps {
|
|
|
16
20
|
ipcHost?: string;
|
|
17
21
|
runtimeNamespace?: string;
|
|
18
22
|
now?: () => number;
|
|
23
|
+
/** Hub lifecycle heartbeat cadence. LifecycleManager applies its 30s safety floor and backoff policy. */
|
|
24
|
+
heartbeatIntervalMs?: number;
|
|
25
|
+
/** Remote asset-search cache TTL. Local asset-store reads are never cached. */
|
|
26
|
+
assetSearchCacheTtlMs?: number;
|
|
27
|
+
/** Maximum number of remote asset-search results cached by this daemon. */
|
|
28
|
+
assetSearchCacheMax?: number;
|
|
29
|
+
/** Time after cache expiry during which a rate-limited search may serve stale remote results. */
|
|
30
|
+
assetSearchStaleGraceMs?: number;
|
|
31
|
+
/** Maximum time the compatibility HTTP request waits before returning a durable pending receipt. */
|
|
32
|
+
assetSubmitResponseTimeoutMs?: number;
|
|
19
33
|
/** Random source for heartbeat force_update staggering. Defaults to Math.random; tests inject a deterministic value. */
|
|
20
34
|
random?: () => number;
|
|
21
35
|
/** 注入 adapter 的 /a2a/hello + heartbeat wire 调用(M6-6 提供; M6-4 测试用 fake). evolverVersion 随报供 hub 观测. */
|
|
@@ -58,6 +72,16 @@ export interface ProxyDaemonDeps {
|
|
|
58
72
|
};
|
|
59
73
|
/** V1 collaboration task operations are synchronous; tests may shorten the Hub timeout. */
|
|
60
74
|
collaborationOperationTimeoutMs?: number;
|
|
75
|
+
/** Optional test/composition seam. Production defaults to the restart-safe verifier backed by this daemon's store. */
|
|
76
|
+
publishRecallVerifier?: PublishRecallVerifierPort;
|
|
77
|
+
/** Optional deterministic sanitizer environment for composition tests. Production omits this to scan process.env. */
|
|
78
|
+
publishSanitizeEnv?: Record<string, string | undefined>;
|
|
79
|
+
/**
|
|
80
|
+
* 宿主专属的真实执行验证器。缺失时,conversation distill 只能返回草稿,绝不持久化或排队发布。
|
|
81
|
+
*/
|
|
82
|
+
publishExecutionVerifier?: ConversationDistillExecutionVerifier;
|
|
83
|
+
/** 验证器响应的硬超时,防止发布请求因宿主执行器挂起而永久占用连接。 */
|
|
84
|
+
publishExecutionVerifierTimeoutMs?: number;
|
|
61
85
|
}
|
|
62
86
|
export interface ProxyTickReport {
|
|
63
87
|
outbound: OutboundResult;
|
|
@@ -75,8 +99,12 @@ export interface ProxyTickError {
|
|
|
75
99
|
export interface ProxyHealth {
|
|
76
100
|
running: boolean;
|
|
77
101
|
ipcListening: boolean;
|
|
102
|
+
lifecycleArmed: boolean;
|
|
78
103
|
nodeId?: string;
|
|
79
104
|
lastWriteAt: number;
|
|
105
|
+
lastTickAt?: number;
|
|
106
|
+
nextTickDueAt?: number;
|
|
107
|
+
consecutiveFailures: number;
|
|
80
108
|
}
|
|
81
109
|
export interface AtpProxyClient {
|
|
82
110
|
placeOrder(opts: {
|
|
@@ -121,9 +149,23 @@ export declare class ProxyDaemon {
|
|
|
121
149
|
private readonly validator;
|
|
122
150
|
private readonly atp;
|
|
123
151
|
private readonly collaborationFacade;
|
|
152
|
+
private readonly publishRecallVerifier;
|
|
153
|
+
private readonly proxyHandler;
|
|
154
|
+
private readonly hub;
|
|
155
|
+
private readonly recipeComposeStarted;
|
|
124
156
|
private ipc;
|
|
125
157
|
private readonly now;
|
|
126
158
|
private readonly random;
|
|
159
|
+
private readonly assetSearchCacheTtlMs;
|
|
160
|
+
private readonly assetSearchCacheMax;
|
|
161
|
+
private readonly assetSearchStaleGraceMs;
|
|
162
|
+
private readonly assetSubmitResponseTimeoutMs;
|
|
163
|
+
private readonly synchronousAssetSubmitScope;
|
|
164
|
+
private readonly shadowMode;
|
|
165
|
+
private readonly assetSearchCache;
|
|
166
|
+
private readonly assetSearchInflight;
|
|
167
|
+
private readonly synchronousAssetSubmitInflight;
|
|
168
|
+
private assetSearchCooldownUntil;
|
|
127
169
|
private nextHeartbeatAt;
|
|
128
170
|
private heartbeatFailures;
|
|
129
171
|
private heartbeatGeneration;
|
|
@@ -132,6 +174,10 @@ export declare class ProxyDaemon {
|
|
|
132
174
|
/** A poke that arrived between ticks (no sleep in flight) parks the wake here so it is not lost. */
|
|
133
175
|
private wakeRunnerPending;
|
|
134
176
|
private started;
|
|
177
|
+
private lifecycleArmed;
|
|
178
|
+
private lastTickAt;
|
|
179
|
+
private nextTickDueAt;
|
|
180
|
+
private consecutiveTickFailures;
|
|
135
181
|
private storeClosed;
|
|
136
182
|
private forceUpdateTriggerInFlight;
|
|
137
183
|
private forceUpdateLastTriggeredAt;
|
|
@@ -141,6 +187,8 @@ export declare class ProxyDaemon {
|
|
|
141
187
|
private scheduledForceUpdateKey;
|
|
142
188
|
private traceBackfillDraining;
|
|
143
189
|
private loopWakeHandler;
|
|
190
|
+
/** 守护进程停止时取消宿主验证。 */
|
|
191
|
+
private publishAbortController;
|
|
144
192
|
constructor(deps: ProxyDaemonDeps);
|
|
145
193
|
/**
|
|
146
194
|
* core handler(确定性, 不经 agent): 目前只接 force_update(#108). 其他 core 类型(asset_publish_result/
|
|
@@ -151,11 +199,13 @@ export declare class ProxyDaemon {
|
|
|
151
199
|
private recordTickError;
|
|
152
200
|
/** 启动: 锁 + IPC 监听 + 初次 hello. 返回 IPC 端口. */
|
|
153
201
|
start(): Promise<number>;
|
|
202
|
+
private listenIpc;
|
|
154
203
|
/** 单轮: core pump/TTL/wake + proxy 出站 + hub 入站 + 到点心跳. */
|
|
155
204
|
tick(): Promise<ProxyTickReport>;
|
|
156
205
|
/** 下一轮建议延时: inbound 背压/idle 与 outbound pending cadence 取更快者. */
|
|
157
206
|
nextDelay(last: InboundResult): number;
|
|
158
207
|
setWakeHandler(wake: (() => void) | undefined): void;
|
|
208
|
+
setExpectedNextTick(delayMs: number | undefined): void;
|
|
159
209
|
notifyNewOutbound(): void;
|
|
160
210
|
/**
|
|
161
211
|
* Expedite the next heartbeat: clear the failure backoff, mark the heartbeat due now, and wake an
|
|
@@ -188,6 +238,21 @@ export declare class ProxyDaemon {
|
|
|
188
238
|
private stateNumber;
|
|
189
239
|
private handleProxyRoute;
|
|
190
240
|
private searchAssets;
|
|
241
|
+
private searchRemoteAssets;
|
|
242
|
+
private cacheRemoteAssetSearch;
|
|
243
|
+
private publishAssetSubmitSynchronously;
|
|
244
|
+
private createSynchronousAssetSubmitEnvelope;
|
|
245
|
+
private composeRecipeAfterAcceptedSubmit;
|
|
246
|
+
private currentHubMode;
|
|
247
|
+
private handleHubModeBoundOutbound;
|
|
248
|
+
private publishSynchronousBundle;
|
|
249
|
+
private waitForSynchronousAssetSubmit;
|
|
250
|
+
private executeSynchronousAssetSubmit;
|
|
251
|
+
private handleSynchronousProxyOutbound;
|
|
252
|
+
private readSynchronousAssetSubmitOutcome;
|
|
253
|
+
private cacheSynchronousAssetSubmitSuccess;
|
|
254
|
+
private cacheSynchronousAssetSubmitTerminal;
|
|
255
|
+
private writeSynchronousAssetSubmitOutcome;
|
|
191
256
|
private handleAtpRoute;
|
|
192
257
|
private writeAtpJson;
|
|
193
258
|
}
|