@evomap/evolver-cli 2.0.0-beta.14 → 2.0.0-beta.15

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/atp.d.ts CHANGED
@@ -81,6 +81,7 @@ export declare function runOrdersCommand(argv: readonly string[]): Promise<numbe
81
81
  export declare function runVerifyCommand(argv: readonly string[]): Promise<number>;
82
82
  export declare function runAtpCommand(argv: readonly string[]): Promise<number>;
83
83
  export declare function createAtpClientFromEnv(env?: NodeJS.ProcessEnv): AtpHubClient;
84
+ export { resolveIdentityHome as resolveAtpIdentityHome } from './identityHome.js';
84
85
  export declare function resolveAtpHome(env?: NodeJS.ProcessEnv): string;
85
86
  export declare function atpConsentPath(env?: NodeJS.ProcessEnv): string;
86
87
  export declare function getAtpConsent(env?: NodeJS.ProcessEnv, ackPath?: string): AtpConsent;
@@ -118,5 +119,4 @@ export declare function setAtpConsent(enabled: boolean, ackPath?: string, now?:
118
119
  version: 1;
119
120
  };
120
121
  export declare function resolveAtpSenderId(env?: NodeJS.ProcessEnv): string | undefined;
121
- export declare function printAtpUsage(): string;
122
- export {};
122
+ export declare function printAtpUsage(): string;
package/dist/atp.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
2
2
  import { homedir } from 'node:os';
3
- import { dirname, join } from 'node:path';
4
- import { events, mailbox } from '@evomap/evolver-core';
3
+ import { dirname, join, resolve } from 'node:path';
4
+ import { mailbox } from '@evomap/evolver-core';
5
5
  import { loadEnvFileFromEnv } from '@evomap/evolver-mcp';
6
+ import { resolveExplicitNodeCredentials, resolveIdentityHome } from './identityHome.js';
6
7
  import { AtpHubClient, ATP_PROOF_STATUSES, ATP_ROLES, ATP_ROUTING_MODES, ATP_VERIFY_ACTIONS, ATP_VERIFY_MODES, connectPublicHub, globalFetchLike, resolveHubUrl, } from '@evomap/evolver-adapter-public';
7
8
  export function parseBuyArgs(args) {
8
9
  if (args.length === 0)
@@ -229,17 +230,24 @@ export async function runAtpCommand(argv) {
229
230
  export function createAtpClientFromEnv(env = process.env) {
230
231
  loadEnvFileFromEnv(env);
231
232
  const hubUrl = resolveHubUrl(env);
232
- const evomapDir = resolveAtpHome(env);
233
- const resolvedSenderId = resolveAtpSenderId(env);
233
+ const evomapDir = resolveIdentityHome(env);
234
+ const explicitCredentials = resolveExplicitNodeCredentials(env);
235
+ const { nodeSecret } = explicitCredentials;
236
+ const resolvedSenderId = nodeSecret
237
+ ? explicitCredentials.senderId ?? resolveAtpSenderId(env)
238
+ : resolveAtpSenderId(env);
234
239
  const senderId = () => resolvedSenderId;
235
- const nodeSecret = env['EVOMAP_NODE_SECRET']?.trim();
236
240
  const connected = nodeSecret
237
241
  ? connectPublicHub({ hubUrl, authMode: 'legacy', evomapDir, nodeSecret, senderId })
238
242
  : connectPublicHub({ hubUrl, authMode: 'oauth', evomapDir, senderId });
239
243
  return new AtpHubClient({ baseUrl: hubUrl, auth: connected.auth, fetchFn: globalFetchLike, senderId });
240
244
  }
245
+ export { resolveIdentityHome as resolveAtpIdentityHome } from './identityHome.js';
241
246
  export function resolveAtpHome(env = process.env) {
242
- return env['EVOMAP_DIR'] ?? env['EVOLVER_HOME'] ?? env['EVOMAP_HOME'] ?? events.evomapHome();
247
+ const configured = [env['EVOMAP_DIR'], env['EVOLVER_HOME'], env['EVOMAP_HOME']]
248
+ .map((value) => value?.trim())
249
+ .find((value) => Boolean(value));
250
+ return configured ?? join(homedir(), '.evomap');
243
251
  }
244
252
  export function atpConsentPath(env = process.env) {
245
253
  return join(resolveAtpHome(env), 'evolution', 'atp-autobuy-ack.json');
@@ -296,9 +304,23 @@ export function setAtpConsent(enabled, ackPath = atpConsentPath(), now = () => n
296
304
  return body;
297
305
  }
298
306
  export function resolveAtpSenderId(env = process.env) {
299
- const direct = env['EVOMAP_NODE_ID']?.trim();
300
- if (direct)
301
- return direct;
307
+ const evomapNodeId = env['EVOMAP_NODE_ID']?.trim();
308
+ if (evomapNodeId)
309
+ return evomapNodeId;
310
+ try {
311
+ const nodeId = readFileSync(join(resolveIdentityHome(env), 'node_id'), 'utf8').trim();
312
+ if (/^node_[a-f0-9]{12,32}$/.test(nodeId))
313
+ return nodeId;
314
+ }
315
+ catch {
316
+ // Best effort only: missing or unreadable legacy identity files are optional.
317
+ }
318
+ const a2aNodeId = env['A2A_NODE_ID']?.trim();
319
+ if (a2aNodeId)
320
+ return a2aNodeId;
321
+ return resolveStoredAtpSenderId(env);
322
+ }
323
+ function resolveStoredAtpSenderId(env) {
302
324
  for (const p of proxyStoreCandidates(env)) {
303
325
  if (!existsSync(p))
304
326
  continue;
@@ -405,11 +427,11 @@ function envOverride(env) {
405
427
  return false; // ambiguous value on a spend gate → fail closed (never auto-enable spending on an unexpected/typo value)
406
428
  }
407
429
  function proxyStoreCandidates(env) {
408
- const home = resolveAtpHome(env);
409
- const candidates = [
410
- env['EVOLVER_PROXY_STORE'],
411
- join(home, 'proxy', 'mailbox.db'),
412
- join(env['HOME'] ?? homedir(), '.evomap', 'proxy', 'mailbox.db'),
413
- ].filter((x) => typeof x === 'string' && x.length > 0);
414
- return [...new Set(candidates)];
430
+ const explicit = env['EVOLVER_PROXY_STORE']?.trim();
431
+ if (explicit)
432
+ return [explicit];
433
+ const stateHome = resolveAtpHome(env);
434
+ return resolve(stateHome) === resolve(resolveIdentityHome(env))
435
+ ? [join(stateHome, 'proxy', 'mailbox.db')]
436
+ : [];
415
437
  }
package/dist/autoexec.js CHANGED
@@ -21,12 +21,14 @@ import { runSessionIngestTick, scanSessionDirs } from './index.js';
21
21
  import { LocalMemoryGraph, resolveLocalMemoryUserIdentity } from './localMemoryGraph.js';
22
22
  import { resolveAtpAutoDeliver } from './atpAutoDeliver.js';
23
23
  import { resolveAtpHome, resolveAtpSenderId } from './atp.js';
24
+ import { resolveExplicitNodeCredentials, resolveIdentityHome } from './identityHome.js';
24
25
  import { runAutobuyPrompt } from './atpAutobuyPrompt.js';
25
26
  import * as solomode from './solo/mode.js';
26
27
  import * as gitGuard from './solo/gitGuard.js';
27
28
  import * as breaker from './solo/breaker.js';
28
29
  import { initializeWorkflowStartupRecovery } from './workflowRuntime.js';
29
30
  import { readAutoExecConfig } from './autoexecConfig.js';
31
+ import { resolveLearningTrace } from './learningTrace.js';
30
32
  export { readAutoExecConfig } from './autoexecConfig.js';
31
33
  const ENV_FILE_UNAVAILABLE_DIAGNOSTIC = '[evolver-autoexec] env_file_unavailable\n';
32
34
  /** Create the queue layout under <home>/autoexec/{tasks,done,refused}. */
@@ -452,7 +454,9 @@ export function makeHubLink(cap, ingestor, reportEnabled = true) {
452
454
  };
453
455
  }
454
456
  function resolvePublicHub(env = process.env, connectHub = connectPublicHub) {
455
- const dir = resolveAtpHome(env) ?? join(homedir(), '.evomap');
457
+ if (hubMode(env) !== 'public')
458
+ return undefined;
459
+ const dir = resolveIdentityHome(env);
456
460
  if (!existsSync(join(dir, 'token.json')))
457
461
  return undefined;
458
462
  try {
@@ -468,7 +472,8 @@ function resolvePublicHub(env = process.env, connectHub = connectPublicHub) {
468
472
  }
469
473
  }
470
474
  function hubMode(env) {
471
- return String(env['EVOMAP_HUB_MODE'] ?? 'public').trim().toLowerCase();
475
+ const mode = String(env['EVOMAP_HUB_MODE'] ?? 'public').trim().toLowerCase();
476
+ return mode === 'public' || mode === 'private' ? mode : undefined;
472
477
  }
473
478
  /**
474
479
  * Resolve the hub link (reuse seam + outcome reporter) from the environment, or undefined when reuse is
@@ -499,6 +504,8 @@ export function resolveHubLink(env = process.env, ingestor, connectHub = connect
499
504
  export function resolveHubQuestionLink(env = process.env, connectHub = connectPublicHub) {
500
505
  if (env['EVOLVER_OUTCOME_REPORT'] === '0')
501
506
  return undefined;
507
+ if (hubMode(env) !== 'public')
508
+ return undefined;
502
509
  const hub = resolvePublicHub(env, connectHub);
503
510
  if (!hub)
504
511
  return undefined;
@@ -542,21 +549,35 @@ export function resolveSolidifyPermitGate(env = process.env, connectHub = connec
542
549
  const flag = solidifyVerifyFlag(env);
543
550
  if (flag === 'off')
544
551
  return undefined;
552
+ const mode = hubMode(env);
553
+ if (mode !== 'public') {
554
+ return flag === 'on'
555
+ ? () => ({
556
+ ok: false,
557
+ reason: mode === 'private'
558
+ ? 'hub_solidify_verify_unavailable:private_hub_not_supported'
559
+ : 'hub_solidify_verify_unavailable:invalid_hub_mode',
560
+ })
561
+ : undefined;
562
+ }
545
563
  const hubUrl = resolveConfiguredHubUrl(env) ?? (flag === 'on' ? resolveHubUrl(env) : undefined);
546
564
  if (!hubUrl) {
547
565
  if (flag === 'on')
548
566
  return () => ({ ok: false, reason: 'hub_solidify_verify_unavailable:no_hub_url' });
549
567
  return undefined;
550
568
  }
551
- const senderId = resolveAtpSenderId(env);
569
+ const explicitCredentials = resolveExplicitNodeCredentials(env);
570
+ const { nodeSecret } = explicitCredentials;
571
+ const senderId = nodeSecret
572
+ ? explicitCredentials.senderId ?? resolveAtpSenderId(env)
573
+ : resolveAtpSenderId(env);
552
574
  if (!senderId) {
553
575
  if (flag === 'on')
554
576
  return () => ({ ok: false, reason: 'hub_solidify_verify_unavailable:no_sender_id' });
555
577
  return undefined;
556
578
  }
557
- const nodeSecret = env['EVOMAP_NODE_SECRET']?.trim() || env['A2A_NODE_SECRET']?.trim();
558
579
  const authMode = nodeSecret ? 'legacy' : 'oauth';
559
- const dir = resolveAtpHome(env);
580
+ const dir = resolveIdentityHome(env);
560
581
  if (authMode === 'oauth' && !existsSync(join(dir, 'token.json'))) {
561
582
  if (flag === 'on')
562
583
  return () => ({ ok: false, reason: 'hub_solidify_verify_unavailable:no_credentials' });
@@ -597,10 +618,16 @@ export function makeProxyHubCapability(proxy) {
597
618
  };
598
619
  return {
599
620
  auth,
600
- search: async (query) => resultAssets(await proxy.search(proxySearchArgs(query))),
601
- fetch: async (query) => resultAssets(await proxy.search(proxySearchArgs(query))),
621
+ search: async (query) => resultAssets(await proxy.search({
622
+ ...proxySearchArgs(query),
623
+ expectedHubMode: 'private',
624
+ })),
625
+ fetch: async (query) => resultAssets(await proxy.search({
626
+ ...proxySearchArgs(query),
627
+ expectedHubMode: 'private',
628
+ })),
602
629
  fetchAssetById: async (assetId) => {
603
- const asset = firstAsset(await proxy.fetchAsset({ assetId }));
630
+ const asset = firstAsset(await proxy.fetchAsset({ assetId, expectedHubMode: 'private' }));
604
631
  return assetMatchesId(asset, assetId) ? asset : null;
605
632
  },
606
633
  publish: async () => ({ receiptId: 'proxy-disabled', status: 'rejected', terminal: true, reason: 'proxy_autoexec_publish_disabled' }),
@@ -612,6 +639,7 @@ export function makeProxyHubCapability(proxy) {
612
639
  ...(report.traceId ? { traceId: report.traceId } : {}),
613
640
  ...(report.timeSavedSeconds !== undefined ? { timeSavedSeconds: report.timeSavedSeconds } : {}),
614
641
  ...(report.reason ? { reason: report.reason } : {}),
642
+ expectedHubMode: 'private',
615
643
  })),
616
644
  task: {
617
645
  claim: async () => ({ claimId: 'proxy-disabled' }),
@@ -875,8 +903,13 @@ export async function runAutoExec(argv) {
875
903
  // hide home secrets — so a validation command there could phone home / read ~/.ssh. Don't let that be silent.
876
904
  let warnedNoIsolation = false;
877
905
  const probationOn = geneProbationEnabled();
906
+ // Learning trace (Learning Ops slice 2): per-task trace events + LearningPacket drafts to local files under
907
+ // evolution/learning-trace/ (traceId = cycleId). Default ON; kill switch EVOLVER_LEARNING_TRACE=0. Hub upload
908
+ // is a later slice — this wiring is file-only and best-effort, so it can never fail or slow a task.
909
+ const learningTrace = resolveLearningTrace(process.env);
878
910
  const deps = {
879
911
  engine, store, provenance, review, personality: personalityStore, memoryGraph,
912
+ ...(learningTrace.config ? { learningTrace: learningTrace.config } : {}),
880
913
  // Probation (#306, gated, default OFF via EVOLVER_GENE_PROBATION): try unproven auto-distilled genes (with their
881
914
  // strategy embedded) so the cross-AI loop self-closes — contained by the proven exec gates + worktree isolation.
882
915
  ...(probationOn ? { includeProbation: true } : {}),
@@ -931,7 +964,7 @@ export async function runAutoExec(argv) {
931
964
  const antiGeneDistill = resolveAutoDistillAntiGene(process.env, { store, review, ingestor });
932
965
  const transcriptDistill = resolveAutoDistillTranscript(process.env, { store, review, ingestor });
933
966
  const atpAutoDeliver = resolveAtpAutoDeliver(process.env);
934
- process.stdout.write(`evolver autoexec: runner=${cfg.runner} queue=${dirs.tasks} allowlist=${JSON.stringify(cfg.allowedRoots)} poll=${cfg.pollMs}ms reuse=${hubLink ? 'on' : 'off'} reuse-signal=${reuseSignalOn ? 'on' : 'off'} probation=${probationOn ? 'on' : 'off'} questions=${hubQuestionLink ? 'on' : 'off'} permit=${solidifyPermit ? 'on' : 'off'} value-digest=${digest.enabled ? 'on' : 'off'} reflection=${reflection.enabled ? 'on' : 'off'} memory-event-mirror=${memoryEventMirror.enabled ? 'on' : `off(${memoryEventMirror.reason ?? 'no_hub'})`} cursor-rewrite=${cursorRewrite.enabled ? 'on' : `off(${cursorRewrite.reason})`} auto-distill=${distill.enabled ? 'on' : 'off'} auto-distill-llm=${llmDistill.enabled ? llmDistill.mode : 'off'} auto-distill-anti-gene=${antiGeneDistill.enabled ? antiGeneDistill.mode : 'off'} auto-distill-transcript=${transcriptDistill.enabled ? transcriptDistill.mode : 'off'} atp-autodeliver=${atpAutoDeliver.enabled ? 'on' : `off(${atpAutoDeliver.reason})`}\n`);
967
+ process.stdout.write(`evolver autoexec: runner=${cfg.runner} queue=${dirs.tasks} allowlist=${JSON.stringify(cfg.allowedRoots)} poll=${cfg.pollMs}ms reuse=${hubLink ? 'on' : 'off'} reuse-signal=${reuseSignalOn ? 'on' : 'off'} probation=${probationOn ? 'on' : 'off'} questions=${hubQuestionLink ? 'on' : 'off'} permit=${solidifyPermit ? 'on' : 'off'} value-digest=${digest.enabled ? 'on' : 'off'} reflection=${reflection.enabled ? 'on' : 'off'} learning-trace=${learningTrace.enabled ? `on(upload=${learningTrace.upload})` : 'off'} memory-event-mirror=${memoryEventMirror.enabled ? 'on' : `off(${memoryEventMirror.reason ?? 'no_hub'})`} cursor-rewrite=${cursorRewrite.enabled ? 'on' : `off(${cursorRewrite.reason})`} auto-distill=${distill.enabled ? 'on' : 'off'} auto-distill-llm=${llmDistill.enabled ? llmDistill.mode : 'off'} auto-distill-anti-gene=${antiGeneDistill.enabled ? antiGeneDistill.mode : 'off'} auto-distill-transcript=${transcriptDistill.enabled ? transcriptDistill.mode : 'off'} atp-autodeliver=${atpAutoDeliver.enabled ? 'on' : `off(${atpAutoDeliver.reason})`}\n`);
935
968
  if (cfg.allowedRoots.length === 0)
936
969
  process.stdout.write(' (allowlist empty → deny-by-default: nothing runs until you add a repo to config.json)\n');
937
970
  // Single-instance lock (#106): a second daemon on the same home would double-process the queue. That is harmless
@@ -2,7 +2,7 @@ import { assetstore } from '@evomap/evolver-core';
2
2
  type WritableLike = {
3
3
  write(chunk: string): unknown;
4
4
  };
5
- type ContractReason = 'missing_id' | 'cli_unavailable' | 'auth_required' | 'not_found' | 'network_error' | 'unsupported' | 'internal_error' | 'redaction_unavailable' | 'leak_detected' | 'schema_invalid' | 'bundle_required' | 'quality_gate_failed' | 'insufficient_credits';
5
+ type ContractReason = 'missing_id' | 'cli_unavailable' | 'auth_required' | 'not_found' | 'network_error' | 'unsupported' | 'internal_error' | 'redaction_unavailable' | 'leak_detected' | 'schema_invalid' | 'bundle_required' | 'quality_gate_failed' | 'gene_unproven' | 'insufficient_credits';
6
6
  export interface ReuseParseResult {
7
7
  ok: boolean;
8
8
  assetId?: string;
@@ -48,10 +48,26 @@ interface HubCallResult {
48
48
  body?: unknown;
49
49
  }
50
50
  interface ContractHubTransport {
51
+ validationCapabilityOptional?: boolean;
51
52
  fetchAssetById(assetId: string): Promise<assetstore.AssetRecord | null>;
52
53
  validate(bundle: readonly assetstore.AssetRecord[]): Promise<HubCallResult>;
53
54
  publish(bundle: readonly assetstore.AssetRecord[]): Promise<HubCallResult>;
54
55
  }
56
+ interface PrivateContractProxy {
57
+ status(): Promise<unknown>;
58
+ fetchAsset(args: {
59
+ assetId: string;
60
+ expectedHubMode: 'private';
61
+ }): Promise<unknown>;
62
+ validateAssetBundle(bundle: {
63
+ assets: unknown[];
64
+ expected_hub_mode?: 'private';
65
+ }): Promise<unknown>;
66
+ submitAssetBundle(bundle: {
67
+ assets: unknown[];
68
+ expected_hub_mode?: 'private';
69
+ }): Promise<unknown>;
70
+ }
55
71
  export interface CliContractDeps {
56
72
  out?: WritableLike;
57
73
  assetStore?: assetstore.AssetStoreProvider;
@@ -61,6 +77,8 @@ export interface CliContractDeps {
61
77
  fetchAssetById?: (assetId: string) => Promise<assetstore.AssetRecord | null>;
62
78
  validate?: (bundle: readonly assetstore.AssetRecord[]) => Promise<HubCallResult>;
63
79
  publish?: (bundle: readonly assetstore.AssetRecord[]) => Promise<HubCallResult>;
80
+ /** Test seam for private-mode proxy discovery. Production resolves the loopback proxy from env/settings. */
81
+ resolveProxyClient?: (env: NodeJS.ProcessEnv) => PrivateContractProxy | undefined;
64
82
  }
65
83
  export declare function runReuseCommand(args: readonly string[], deps?: CliContractDeps): Promise<number>;
66
84
  export declare function runPublishCommand(args: readonly string[], deps?: CliContractDeps): Promise<number>;