@evomap/evolver-cli 2.0.44 → 2.0.47

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.
Files changed (54) hide show
  1. package/dist/autoexec.d.ts +1 -2
  2. package/dist/autoexec.js +2 -7
  3. package/dist/cliEntry.js +8 -0
  4. package/dist/commandCatalog.d.ts +4 -0
  5. package/dist/commandCatalog.js +4 -0
  6. package/dist/contextDelivery.js +2 -2
  7. package/dist/dispatch.js +8 -0
  8. package/dist/experience.d.ts +2 -0
  9. package/dist/experience.js +229 -0
  10. package/dist/feedbackDestinationIdentity.d.ts +1 -0
  11. package/dist/feedbackDestinationIdentity.js +8 -0
  12. package/dist/kernelTriggerFeedback.d.ts +13 -0
  13. package/dist/kernelTriggerFeedback.js +65 -0
  14. package/dist/lifecycle.js +4 -1
  15. package/dist/lifecycleBootstrapTransaction.js +13 -7
  16. package/dist/localMemoryGraph.d.ts +38 -0
  17. package/dist/localMemoryGraph.js +192 -7
  18. package/dist/localTriggerFeedback.d.ts +30 -0
  19. package/dist/localTriggerFeedback.js +126 -0
  20. package/dist/mcpStdio.d.ts +1 -0
  21. package/dist/mcpStdio.js +9 -0
  22. package/dist/plugin.d.ts +8 -0
  23. package/dist/plugin.js +132 -0
  24. package/dist/pluginBundle.d.ts +3 -0
  25. package/dist/pluginBundle.js +94 -0
  26. package/dist/pluginHosts.d.ts +36 -0
  27. package/dist/pluginHosts.js +120 -0
  28. package/dist/pluginInspection.d.ts +22 -0
  29. package/dist/pluginInspection.js +237 -0
  30. package/dist/pluginInstall.d.ts +19 -0
  31. package/dist/pluginInstall.js +84 -0
  32. package/dist/pluginLock.d.ts +4 -0
  33. package/dist/pluginLock.js +52 -0
  34. package/dist/pluginRuntime.d.ts +31 -0
  35. package/dist/pluginRuntime.js +191 -0
  36. package/dist/recipe.d.ts +1 -1
  37. package/dist/recipe.js +14 -5
  38. package/dist/setupHooks.js +5 -3
  39. package/dist/setupHooksLifecycle.d.ts +2 -0
  40. package/dist/setupHooksLifecycle.js +52 -52
  41. package/dist/sourceQualification.js +6 -2
  42. package/dist/triggerFeedbackCli.d.ts +15 -0
  43. package/dist/triggerFeedbackCli.js +146 -0
  44. package/dist/triggerFeedbackDelivery.d.ts +9 -0
  45. package/dist/triggerFeedbackDelivery.js +29 -0
  46. package/dist/triggerFeedbackHub.d.ts +7 -0
  47. package/dist/triggerFeedbackHub.js +62 -0
  48. package/dist/triggerFeedbackRecovery.d.ts +15 -0
  49. package/dist/triggerFeedbackRecovery.js +124 -0
  50. package/dist/triggerFeedbackSync.d.ts +23 -0
  51. package/dist/triggerFeedbackSync.js +98 -0
  52. package/dist/triggerFeedbackSyncState.d.ts +42 -0
  53. package/dist/triggerFeedbackSyncState.js +112 -0
  54. package/package.json +7 -7
@@ -10,6 +10,7 @@ import { type AutoDistillAntiGeneMode, type AutoDistillAntiGeneResult } from './
10
10
  import { type AutoDistillTranscriptMode, type TranscriptDistillTickResult } from './autoDistillTranscript.js';
11
11
  import { type SessionIngestTickResult } from './sessionIngest.js';
12
12
  import { AtpAutoBuyer, type AtpAutoBuyerClient, type AtpAutoBuyerRequest } from './atpAutoBuyer.js';
13
+ export { feedbackDestinationIdentity } from './feedbackDestinationIdentity.js';
13
14
  import { FeedbackOutbox, type FeedbackOutboxRecord, type FeedbackSender } from './feedbackOutbox.js';
14
15
  import { TaskOutcomeOutbox, type PrepareTaskOutcomeInput, type TaskOutcomeSender } from './taskOutcomeOutbox.js';
15
16
  import { type ConfiguredSelectionGuard } from './selectionPolicyConfig.js';
@@ -250,8 +251,6 @@ export declare function scheduleAutoExecHubSideEffects(task: exec.AutoExecTask,
250
251
  * the legacy task-wide outcome path cannot send a duplicate reuse-result claim.
251
252
  */
252
253
  export declare function makeHubLink(cap: OutcomeReportingHub, ingestor?: events.Ingestor, reportEnabled?: boolean, onVerifiedSearchMiss?: VerifiedHubSearchMissHandler, assetLog?: AssetCallLogger, env?: NodeJS.ProcessEnv, appliedUseSender?: FeedbackSender, reportingCap?: OutcomeReportingHub, reportingDestinationId?: string): HubLink;
253
- /** Opaque nonsecret binding to the effective Hub principal and route, never a credential. */
254
- export declare function feedbackDestinationIdentity(mode: 'public' | 'private', endpoint: string, principal: string, namespace?: string): string;
255
254
  /** The proxy attests the final identity it also checks on the feedback POST. */
256
255
  export declare function privateFeedbackDestinationIdFromStatus(value: unknown): string | undefined;
257
256
  /** A private proxy must attest its effective Hub destination, not merely its local node. */
package/dist/autoexec.js CHANGED
@@ -37,6 +37,8 @@ import { readAutoExecConfig } from './autoexecConfig.js';
37
37
  import { makeCurriculumCapabilityGapsProvider } from './curriculumCapabilityGaps.js';
38
38
  import { resolveLearningTrace } from './learningTrace.js';
39
39
  import { semanticIdfEnabled } from './semanticIdfConfig.js';
40
+ import { feedbackDestinationIdentity } from './feedbackDestinationIdentity.js';
41
+ export { feedbackDestinationIdentity } from './feedbackDestinationIdentity.js';
40
42
  import { FeedbackNotDispatchedError, FeedbackOutbox } from './feedbackOutbox.js';
41
43
  import { TaskOutcomeOutbox, taskOutcomeIdentity } from './taskOutcomeOutbox.js';
42
44
  import { selectionFloorFromEnv, selectionGuardFromEnv, selectionPolicyFromEnv, } from './selectionPolicyConfig.js';
@@ -1553,13 +1555,6 @@ function hubMode(env) {
1553
1555
  return mode === 'public' || mode === 'private' ? mode : undefined;
1554
1556
  }
1555
1557
  /** Opaque nonsecret binding to the effective Hub principal and route, never a credential. */
1556
- export function feedbackDestinationIdentity(mode, endpoint, principal, namespace = '') {
1557
- if (!endpoint || !principal || [...endpoint, ...principal, ...namespace]
1558
- .some((character) => character.charCodeAt(0) < 32 || character.charCodeAt(0) === 127)) {
1559
- throw new Error('feedback destination identity unavailable');
1560
- }
1561
- return `sha256:${createHash('sha256').update(JSON.stringify([mode, endpoint, principal, namespace])).digest('hex')}`;
1562
- }
1563
1558
  function publicFeedbackDestinationId(env) {
1564
1559
  try {
1565
1560
  const sender = resolveAtpSenderId(env);
package/dist/cliEntry.js CHANGED
@@ -58,6 +58,14 @@ export async function runCliEntry(argv) {
58
58
  watchdog.unref();
59
59
  }
60
60
  }
61
+ if (argv[0] === 'experience') {
62
+ const { runExperienceCommand } = await import('./experience.js');
63
+ return runExperienceCommand(argv.slice(1));
64
+ }
65
+ if (argv[0] === 'mcp-stdio') {
66
+ const { runMcpStdioCommand } = await import('./mcpStdio.js');
67
+ return runMcpStdioCommand(argv.slice(1));
68
+ }
61
69
  const { dispatch } = await import('./dispatch.js');
62
70
  return await Promise.resolve(dispatch(argv));
63
71
  }
@@ -9,6 +9,7 @@ export declare const COMMAND_GROUPS: {
9
9
  readonly 'proxy-token': "Daemon";
10
10
  readonly doctor: "Daemon";
11
11
  readonly 'setup-hooks': "Daemon";
12
+ readonly plugin: "Daemon";
12
13
  readonly run: "Evolution";
13
14
  readonly cycle: "Evolution";
14
15
  readonly autoexec: "Evolution";
@@ -20,12 +21,15 @@ export declare const COMMAND_GROUPS: {
20
21
  readonly ingest: "Memory";
21
22
  readonly inject: "Memory";
22
23
  readonly recall: "Memory";
24
+ readonly experience: "Memory";
25
+ readonly 'mcp-stdio': "Tools";
23
26
  readonly reuse: "Memory";
24
27
  readonly 'reuse-report': "Memory";
25
28
  readonly 'recall-verify-report': "Memory";
26
29
  readonly narrative: "Memory";
27
30
  readonly 'gene-value': "Memory";
28
31
  readonly 'memory-graph': "Memory";
32
+ readonly 'trigger-feedback': "Memory";
29
33
  readonly 'asset-log': "Assets";
30
34
  readonly 'asset-trust': "Assets";
31
35
  readonly 'asset-health': "Assets";
@@ -22,6 +22,7 @@ export const COMMAND_GROUPS = {
22
22
  'proxy-token': 'Daemon',
23
23
  doctor: 'Daemon',
24
24
  'setup-hooks': 'Daemon',
25
+ plugin: 'Daemon',
25
26
  run: 'Evolution',
26
27
  cycle: 'Evolution',
27
28
  autoexec: 'Evolution',
@@ -33,12 +34,15 @@ export const COMMAND_GROUPS = {
33
34
  ingest: 'Memory',
34
35
  inject: 'Memory',
35
36
  recall: 'Memory',
37
+ experience: 'Memory',
38
+ 'mcp-stdio': 'Tools',
36
39
  reuse: 'Memory',
37
40
  'reuse-report': 'Memory',
38
41
  'recall-verify-report': 'Memory',
39
42
  narrative: 'Memory',
40
43
  'gene-value': 'Memory',
41
44
  'memory-graph': 'Memory',
45
+ 'trigger-feedback': 'Memory',
42
46
  'asset-log': 'Assets',
43
47
  'asset-trust': 'Assets',
44
48
  'asset-health': 'Assets',
@@ -1,9 +1,9 @@
1
- import { contextDeliveryRejectionCode, startContextReadStage } from '@evomap/evolver-core/prompt-recall';
1
+ import { DEFAULT_CONTEXT_PREPARATION_BUDGET_MS, contextDeliveryRejectionCode, startContextReadStage } from '@evomap/evolver-core/prompt-recall';
2
2
  import { waitContextDelivery, writeHookStdout } from './promptRecallShared.js';
3
3
  export { waitContextDelivery } from './promptRecallShared.js';
4
4
  /** Both production context entrypoints share the same prepare -> actual callback -> projection protocol. */
5
5
  export async function deliverContextOutput(options) {
6
- const deadlineAt = Date.now() + 200;
6
+ const deadlineAt = Date.now() + DEFAULT_CONTEXT_PREPARATION_BUDGET_MS;
7
7
  const finishPreparation = startContextReadStage('delivery_prepare');
8
8
  let failureCode = 'timeout';
9
9
  const { text, prepare, stdout, stdoutWithSettlement, onOutputWritten } = options;
package/dist/dispatch.js CHANGED
@@ -9,6 +9,7 @@ import { runAutoExecFeedbackCommand } from './feedbackOutboxCli.js';
9
9
  import { runAtpCommand, runBuyCommand, runOrdersCommand, runVerifyCommand } from './atp.js';
10
10
  import { runLogin, runLogout } from './login.js';
11
11
  import { runSetupHooks } from './setupHooks.js';
12
+ import { runPluginCommand } from './plugin.js';
12
13
  import { runSkillDistill, runSkillMdUpdate } from './skillDistill.js';
13
14
  import { runSkillCommand } from './skillFetch.js';
14
15
  import { runThesisCommand } from './thesis.js';
@@ -16,6 +17,8 @@ import { getCliVersion } from './version.js';
16
17
  import { runRecipeCommand } from './recipe.js';
17
18
  import { runReuseCommand } from './reuse.js';
18
19
  import { runPublishCommand } from './cliContracts.js';
20
+ import { runExperienceCommand } from './experience.js';
21
+ import { runMcpStdioCommand } from './mcpStdio.js';
19
22
  import { runRecallCommand } from './recall.js';
20
23
  import { runReuseReportCommand } from './reuseReport.js';
21
24
  import { runRecallVerifyReportCommand } from './recallVerifyReport.js';
@@ -40,6 +43,7 @@ import { runAssetRepairCommand } from './assetRepair.js';
40
43
  import { runV1FetchCompat, runV1RunCompat, runV1SolidifyCompat, runV1WebuiCompat, runV1ExecCompat } from './v1Compat.js';
41
44
  import { runWorkflowCommand } from './workflow.js';
42
45
  import { runMemoryGraphCommand } from './memoryGraphOps.js';
46
+ import { runTriggerFeedbackCommand } from './triggerFeedbackCli.js';
43
47
  import { runModelCompatibilityReplay } from './modelCompatibility.js';
44
48
  import { SYNC_COMMAND_NAMES } from './commandCatalog.js';
45
49
  export async function runProxyCommand(argv, importer = () => import('@evomap/evolver-proxy/bin/evolver-proxy')) {
@@ -65,6 +69,7 @@ const ASYNC_COMMAND_TABLE = {
65
69
  logout: runLogout,
66
70
  'proxy-token': runProxyToken,
67
71
  'setup-hooks': runSetupHooks,
72
+ plugin: runPluginCommand,
68
73
  buy: runBuyCommand,
69
74
  orders: runOrdersCommand,
70
75
  verify: runVerifyCommand,
@@ -75,10 +80,13 @@ const ASYNC_COMMAND_TABLE = {
75
80
  reference: runReferenceCommand,
76
81
  sync: runSyncCommand,
77
82
  recall: runRecallCommand,
83
+ experience: runExperienceCommand,
84
+ 'mcp-stdio': runMcpStdioCommand,
78
85
  'reuse-report': runReuseReportCommand,
79
86
  'recall-verify-report': runRecallVerifyReportCommand,
80
87
  doctor: runDoctorCommand,
81
88
  'memory-graph': runMemoryGraphCommand,
89
+ 'trigger-feedback': runTriggerFeedbackCommand,
82
90
  phub: runPhubCommand,
83
91
  lifecycle: runLifecycleCommand,
84
92
  cycle: runCycleCommand,
@@ -0,0 +1,2 @@
1
+ /** Versioned local experience API for the desktop and remote operators. No shell, publication or model call. */
2
+ export declare function runExperienceCommand(argv: string[]): Promise<number>;
@@ -0,0 +1,229 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { deflateRawSync, inflateRawSync, brotliCompressSync, brotliDecompressSync, constants as zlibConstants } from 'node:zlib';
3
+ import * as assetstore from '@evomap/evolver-core/experience';
4
+ const LIMIT = 64 * 1024;
5
+ async function input() {
6
+ const chunks = [];
7
+ let bytes = 0;
8
+ for await (const chunk of process.stdin) {
9
+ const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
10
+ bytes += buffer.length;
11
+ if (bytes > LIMIT)
12
+ throw new assetstore.ExperienceError('INPUT_TOO_LARGE', '内容太长,请缩短任务材料。');
13
+ chunks.push(buffer);
14
+ }
15
+ let parsed;
16
+ try {
17
+ parsed = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(Buffer.concat(chunks)) || '{}');
18
+ }
19
+ catch {
20
+ throw new assetstore.ExperienceError('INPUT_INVALID', '请求不是有效的 JSON。');
21
+ }
22
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
23
+ throw new assetstore.ExperienceError('INPUT_INVALID', '请求格式不正确。');
24
+ return parsed;
25
+ }
26
+ const CONFIRMATION_PREFIX = 'evolver-experience-plan-v1.';
27
+ const BROTLI_CONFIRMATION_PREFIX = 'evolver-experience-plan-br-v1.';
28
+ function confirmationFor(plan) {
29
+ const encoded = JSON.stringify({ plan });
30
+ if (Buffer.byteLength(encoded) <= LIMIT)
31
+ return undefined;
32
+ const bytes = Buffer.from(JSON.stringify(plan));
33
+ const deflated = `${CONFIRMATION_PREFIX}${deflateRawSync(bytes).toString('base64url')}`;
34
+ if (Buffer.byteLength(JSON.stringify({ confirmation: deflated })) <= LIMIT)
35
+ return deflated;
36
+ // UTF-8 context coding also fits high-entropy multibyte material. Deflate's
37
+ // byte histogram alone can expand a valid 64KiB request after base64 framing.
38
+ const confirmation = `${BROTLI_CONFIRMATION_PREFIX}${brotliCompressSync(bytes, { params: {
39
+ [zlibConstants.BROTLI_PARAM_MODE]: zlibConstants.BROTLI_MODE_TEXT,
40
+ [zlibConstants.BROTLI_PARAM_QUALITY]: 6,
41
+ } }).toString('base64url')}`;
42
+ if (Buffer.byteLength(JSON.stringify({ confirmation })) > LIMIT)
43
+ throw new assetstore.ExperienceError('INPUT_TOO_LARGE', '完整确认内容仍超过输入预算,请缩短材料后重新查看。');
44
+ return confirmation;
45
+ }
46
+ function confirmedPlan(request) {
47
+ if (request.confirmation === undefined)
48
+ return request.plan;
49
+ if (request.plan !== undefined)
50
+ throw new assetstore.ExperienceError('PLAN_INVALID', '请只传原确认计划或紧凑确认内容,不能同时指定。');
51
+ try {
52
+ if (typeof request.confirmation !== 'string')
53
+ throw new Error();
54
+ const brotli = request.confirmation.startsWith(BROTLI_CONFIRMATION_PREFIX);
55
+ const prefix = brotli ? BROTLI_CONFIRMATION_PREFIX : CONFIRMATION_PREFIX;
56
+ if (!request.confirmation.startsWith(prefix))
57
+ throw new Error();
58
+ const encoded = request.confirmation.slice(prefix.length);
59
+ if (!/^[A-Za-z0-9_-]+$/.test(encoded))
60
+ throw new Error();
61
+ const bytes = Buffer.from(encoded, 'base64url');
62
+ if (bytes.toString('base64url') !== encoded)
63
+ throw new Error();
64
+ // A transport envelope is not additional business capacity. Inflation is
65
+ // bounded independently; the original plan/input limits still apply below.
66
+ const decoded = (brotli ? brotliDecompressSync : inflateRawSync)(bytes, { maxOutputLength: 256 * 1024 });
67
+ return JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(decoded));
68
+ }
69
+ catch {
70
+ throw new assetstore.ExperienceError('PLAN_INVALID', '紧凑确认内容不完整,请使用原样内容重新确认。');
71
+ }
72
+ }
73
+ function flags(argv) {
74
+ const result = {};
75
+ for (let i = 0; i < argv.length; i++) {
76
+ const arg = argv[i];
77
+ if (arg === '--json')
78
+ continue;
79
+ if (arg === '--no-stdin') {
80
+ result['no-stdin'] = 'true';
81
+ continue;
82
+ }
83
+ const match = /^--(action|query|limit|offset|id|code|runtime)(?:=(.*))?$/.exec(arg);
84
+ if (!match)
85
+ throw new assetstore.ExperienceError('INPUT_INVALID', '参数不正确。');
86
+ const value = match[2] ?? argv[++i];
87
+ if (value === undefined || match[2] === undefined && value.startsWith('--')) {
88
+ throw new assetstore.ExperienceError('INPUT_INVALID', '参数没有填写;以 -- 开头的内容请使用 --参数=内容。');
89
+ }
90
+ result[match[1]] = value;
91
+ }
92
+ return result;
93
+ }
94
+ function diagnostic(error) {
95
+ if (process.env['EVOLVER_EXPERIENCE_DIAGNOSTICS'] !== '1')
96
+ return;
97
+ try {
98
+ const own = (name) => error && typeof error === 'object'
99
+ ? Object.getOwnPropertyDescriptor(error, name)?.value : undefined;
100
+ const code = own('code'), reason = own('reason');
101
+ const codes = ['EACCES', 'EPERM', 'EBUSY', 'EIO', 'ENOENT', 'ENOTDIR', 'EEXIST', 'UNSAFE_ASSET_STORE_PATH'];
102
+ const reasons = ['cancelled_or_expired', 'process_identity_unavailable', 'windows_path_blocked', 'windows_io_failed',
103
+ 'windows_io_incomplete', 'windows_io_invalid_count', 'path_changed', 'lock_changed', 'cleanup_capacity',
104
+ 'not_private_regular_file', 'not_regular_file', 'not_directory', 'symlink', 'safe_open_unavailable'];
105
+ // Fixed categories only: never emit caller data, paths, messages or stacks.
106
+ console.error(JSON.stringify({ diagnostic: 'experience-operation-failed',
107
+ code: typeof code === 'string' && codes.includes(code) ? code : 'unclassified',
108
+ reason: typeof reason === 'string' && reasons.includes(reason) ? reason : 'unclassified' }));
109
+ }
110
+ catch { /* Diagnostic failures must not replace the original response. */ }
111
+ }
112
+ /** Versioned local experience API for the desktop and remote operators. No shell, publication or model call. */
113
+ export async function runExperienceCommand(argv) {
114
+ const operation = argv[0] ?? 'list';
115
+ const emit = (payload) => { process.stdout.write(`${JSON.stringify({ schema: assetstore.EXPERIENCE_SCHEMA, operation, ...payload })}\n`); };
116
+ try {
117
+ const f = flags(argv.slice(1));
118
+ if (f['no-stdin'] && !['check-start', 'search', 'check'].includes(operation)) {
119
+ throw new assetstore.ExperienceError('INPUT_INVALID', '只用参数的模式只支持生成检查码、检查和查询。');
120
+ }
121
+ if (operation === 'capabilities') {
122
+ emit({ ok: true, capabilities: { library: true, confirmedMutations: true, fullPlanBinding: true, durableRecovery: true, compactConfirmation: true, sourceRecovery: true, localOnly: true, originalMaterialsShared: false, activity: true, mcpStdio: true } });
123
+ return 0;
124
+ }
125
+ const library = new assetstore.ExperienceLibrary(assetstore.assetsDir());
126
+ const activity = new assetstore.ExperienceActivity(assetstore.assetsDir());
127
+ if (operation === 'history') {
128
+ emit({ ok: true, result: activity.history(Number(f['limit'] ?? 50)) });
129
+ return 0;
130
+ }
131
+ if (operation === 'check-status') {
132
+ emit({ ok: true, result: activity.checkStatus(f['id'] ?? '') });
133
+ return 0;
134
+ }
135
+ if (['check-start', 'check', 'task-start', 'search', 'report'].includes(operation)) {
136
+ const flagOnly = (process.stdin.isTTY || f['no-stdin'] === 'true') && (operation === 'check-start' && f['runtime'] !== undefined
137
+ || operation === 'search' && f['query'] !== undefined);
138
+ const codeOnly = operation === 'check' && f['code'] !== undefined && (process.stdin.isTTY || f['no-stdin'] === 'true');
139
+ if (f['no-stdin'] && !flagOnly && !codeOnly) {
140
+ throw new assetstore.ExperienceError('INPUT_INVALID', '只用参数时,请填写应用、查询关键词或检查码。');
141
+ }
142
+ const request = codeOnly ? { code: f['code'], runtime: f['runtime'] }
143
+ : flagOnly ? {} : await input();
144
+ if (f['runtime'] !== undefined && request.runtime !== undefined && f['runtime'] !== request.runtime) {
145
+ throw new assetstore.ExperienceError('INPUT_INVALID', '命令行和请求中的应用不一致,请指定同一应用。');
146
+ }
147
+ if (operation === 'check' && f['code'] !== undefined) {
148
+ if (request.code !== undefined && request.code !== f['code']) {
149
+ throw new assetstore.ExperienceError('INPUT_INVALID', '命令行和请求中的检查码不一致,请指定同一检查码。');
150
+ }
151
+ request.code = f['code'];
152
+ }
153
+ const runtime = f['runtime'] ?? request.runtime;
154
+ if (operation === 'search' && f['query'] !== undefined) {
155
+ if (request.query !== undefined && request.query !== f['query']) {
156
+ throw new assetstore.ExperienceError('INPUT_INVALID', '命令行和请求中的查询不一致,请指定同一查询。');
157
+ }
158
+ request.query = f['query'];
159
+ }
160
+ const source = { connectionId: request.taskId ? `cli-${request.taskId}` : `cli-${randomUUID()}`, transport: 'cli', clientName: 'evolver CLI', ...(runtime ? { runtime } : {}) };
161
+ const result = operation === 'check-start' ? await activity.startCheck(runtime ?? '')
162
+ : operation === 'check' ? await activity.check(request.code ?? '', source)
163
+ : operation === 'task-start' ? await activity.startTask(request.title ?? '', request.query ?? '', request.validationInput)
164
+ : operation === 'search' ? await activity.search(request.query ?? '', source, request.taskId)
165
+ : await activity.report(request.deliveryId ?? '', request.assetId ?? '', request.taskId ?? '', request.outcome ?? '', source, request.output);
166
+ emit({ ok: true, result });
167
+ return 0;
168
+ }
169
+ if (operation === 'list') {
170
+ emit({ ok: true, result: await library.list(f['query'] ?? '', Number(f['limit'] ?? 50), Number(f['offset'] ?? 0)) });
171
+ return 0;
172
+ }
173
+ if (operation === 'plan') {
174
+ const request = await input();
175
+ const plan = await library.plan(f['action'], request.assetId, request.input);
176
+ const confirmation = confirmationFor(plan);
177
+ emit({ ok: true, plan, ...(confirmation ? { confirmation } : {}) });
178
+ return 0;
179
+ }
180
+ if (operation === 'legacy-audit-status') {
181
+ emit({ ok: true, result: assetstore.Ingestor.experienceLegacyAuditStatus(assetstore.rootEventsPath(), Number(f['limit'] ?? 50)) });
182
+ return 0;
183
+ }
184
+ if (operation === 'operation-status') {
185
+ emit({ ok: true, result: library.operationStatus(Number(f['limit'] ?? 50), Number(f['offset'] ?? 0)) });
186
+ return 0;
187
+ }
188
+ if (operation === 'recover') {
189
+ const result = await library.recover(f['id'], Number(f['limit'] ?? 32));
190
+ emit({ ok: result.remaining === 0, result, ...(result.remaining ? { code: 'AUDIT_COMPLETION_PENDING', error: '还有结果审计待恢复,请继续运行恢复;不要重新审批。' } : {}) });
191
+ return result.remaining ? 1 : 0;
192
+ }
193
+ if (operation === 'source-recovery-plan') {
194
+ const request = await input();
195
+ emit({ ok: true, plan: await library.planSourceRecovery(request.assetId ?? '') });
196
+ return 0;
197
+ }
198
+ if (operation === 'source-recovery-execute') {
199
+ const request = await input();
200
+ if (!request.sourceRecoveryPlan)
201
+ throw new assetstore.ExperienceError('PLAN_INVALID', '请先查看并确认材料恢复。');
202
+ emit({ ok: true, result: await library.executeSourceRecovery(request.sourceRecoveryPlan) });
203
+ return 0;
204
+ }
205
+ if (operation === 'execute') {
206
+ const request = await input(), plan = confirmedPlan(request);
207
+ if (!plan)
208
+ throw new assetstore.ExperienceError('PLAN_INVALID', '请先查看并确认要保存或修改的内容。');
209
+ emit({ ok: true, result: await library.execute(plan) });
210
+ return 0;
211
+ }
212
+ throw new assetstore.ExperienceError('INPUT_INVALID', '不支持这个经验库操作。');
213
+ }
214
+ catch (error) {
215
+ if (error instanceof assetstore.ExperienceRecoveryRequiredError) {
216
+ emit({ ok: false, code: error.code, error: '经验库的写入尚未结束;请先运行经验库恢复,再重新查看。' });
217
+ return 1;
218
+ }
219
+ if (error instanceof assetstore.ExperienceJournalError) {
220
+ emit({ ok: false, code: error.code, error: '经验操作的持久证据需要核对;请运行恢复状态检查,不要重复审批。' });
221
+ return 1;
222
+ }
223
+ if (!(error instanceof assetstore.ExperienceError))
224
+ diagnostic(error);
225
+ emit({ ok: false, code: error instanceof assetstore.ExperienceError ? error.code : 'EXPERIENCE_FAILED',
226
+ error: error instanceof assetstore.ExperienceError ? error.message : '未能确认经验库结果,请检查本地安装与目录权限;已有确认请先查看恢复状态。' });
227
+ return 1;
228
+ }
229
+ }
@@ -0,0 +1 @@
1
+ export declare function feedbackDestinationIdentity(mode: 'public' | 'private', endpoint: string, principal: string, namespace?: string): string;
@@ -0,0 +1,8 @@
1
+ import { createHash } from 'node:crypto';
2
+ export function feedbackDestinationIdentity(mode, endpoint, principal, namespace = '') {
3
+ if (!endpoint || !principal || [...endpoint, ...principal, ...namespace]
4
+ .some((character) => character.charCodeAt(0) < 32 || character.charCodeAt(0) === 127)) {
5
+ throw new Error('feedback destination identity unavailable');
6
+ }
7
+ return `sha256:${createHash('sha256').update(JSON.stringify([mode, endpoint, principal, namespace])).digest('hex')}`;
8
+ }
@@ -0,0 +1,13 @@
1
+ import { algo } from '@evomap/evolver-core';
2
+ export interface KernelTriggerFeedbackBinding {
3
+ executable: string;
4
+ agentDir: string;
5
+ env: Readonly<Record<string, string | undefined>>;
6
+ }
7
+ export interface KernelTriggerFeedbackPage {
8
+ snapshots: algo.TriggerFeedbackSnapshot[];
9
+ nextAfter: string | null;
10
+ }
11
+ export declare function kernelTriggerFeedbackBinding(env: Readonly<Record<string, string | undefined>>): KernelTriggerFeedbackBinding;
12
+ export declare function readKernelTriggerFeedback(binding: KernelTriggerFeedbackBinding, runId: string, signal?: AbortSignal): Promise<algo.TriggerFeedbackSnapshot>;
13
+ export declare function listKernelTriggerFeedback(binding: KernelTriggerFeedbackBinding, after?: string | null, signal?: AbortSignal): Promise<KernelTriggerFeedbackPage>;
@@ -0,0 +1,65 @@
1
+ import { execFile } from 'node:child_process';
2
+ import { isAbsolute, resolve } from 'node:path';
3
+ import { algo, exec } from '@evomap/evolver-core';
4
+ export function kernelTriggerFeedbackBinding(env) {
5
+ const executable = env['EVOX_KERNEL_EXECUTABLE'];
6
+ const agentDir = env['EVOX_CODING_AGENT_DIR'];
7
+ if (!executable || !isAbsolute(executable) || !agentDir || !isAbsolute(agentDir))
8
+ throw new Error('trigger_feedback_kernel_unbound');
9
+ const normalized = { ...env, EVOX_CODING_AGENT_DIR: resolve(agentDir), EVOX_KERNEL_EXECUTABLE: resolve(executable) };
10
+ const scoped = exec.triggerFeedbackScopeEnv(normalized);
11
+ if (!scoped)
12
+ throw new Error('trigger_feedback_kernel_unbound');
13
+ return { executable: resolve(executable), agentDir: resolve(agentDir), env: scoped };
14
+ }
15
+ async function callKernel(binding, args, signal) {
16
+ signal?.throwIfAborted();
17
+ const stdout = await new Promise((accept, reject) => {
18
+ execFile(binding.executable, ['evolve', 'trigger-feedback', ...args, '--json'], {
19
+ env: { ...binding.env }, cwd: binding.agentDir, encoding: 'utf8', windowsHide: true, timeout: 10_000, maxBuffer: 4 * 1024 * 1024, ...(signal ? { signal } : {}),
20
+ }, (error, output) => {
21
+ if (signal?.aborted)
22
+ reject(signal.reason);
23
+ else if (error)
24
+ reject(new Error(args[0] === 'list' && error.code === 2 ? 'trigger_feedback_recovery_unsupported' : 'trigger_feedback_kernel_read_unavailable'));
25
+ else
26
+ accept(output);
27
+ });
28
+ });
29
+ try {
30
+ return JSON.parse(stdout);
31
+ }
32
+ catch {
33
+ throw new Error('trigger_feedback_kernel_invalid_output');
34
+ }
35
+ }
36
+ export async function readKernelTriggerFeedback(binding, runId, signal) {
37
+ if (!runId.trim() || Buffer.byteLength(runId) > 256)
38
+ throw new Error('trigger_feedback_invalid_identity');
39
+ return algo.parseKernelTriggerFeedback(await callKernel(binding, ['get', '--run-id', runId], signal), runId);
40
+ }
41
+ export async function listKernelTriggerFeedback(binding, after = null, signal) {
42
+ if (after !== null && (!after.trim() || Buffer.byteLength(after) > 256))
43
+ throw new Error('trigger_feedback_invalid_identity');
44
+ const raw = await callKernel(binding, ['list', '--snapshots', '--limit', '100', ...(after === null ? [] : ['--after', after])], signal);
45
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw))
46
+ throw new Error('trigger_feedback_kernel_invalid_output');
47
+ const page = raw;
48
+ if (page['schema_version'] !== 1 || !Array.isArray(page['snapshots']) || page['snapshots'].length > 100)
49
+ throw new Error('trigger_feedback_recovery_unsupported');
50
+ const snapshots = page['snapshots'].map((value) => {
51
+ if (!value || typeof value !== 'object' || Array.isArray(value) || typeof value['run_id'] !== 'string')
52
+ throw new Error('trigger_feedback_kernel_invalid_output');
53
+ return algo.parseKernelTriggerFeedback(value, value['run_id']);
54
+ });
55
+ let previous = after;
56
+ for (const snapshot of snapshots) {
57
+ if (previous !== null && snapshot.runId <= previous)
58
+ throw new Error('trigger_feedback_kernel_invalid_output');
59
+ previous = snapshot.runId;
60
+ }
61
+ const nextAfter = page['next_after'];
62
+ if (nextAfter !== null && (typeof nextAfter !== 'string' || nextAfter !== previous || snapshots.length === 0))
63
+ throw new Error('trigger_feedback_kernel_invalid_output');
64
+ return { snapshots, nextAfter: nextAfter };
65
+ }
package/dist/lifecycle.js CHANGED
@@ -5408,7 +5408,10 @@ function forceKill(pid) {
5408
5408
  function readProxySettings(path, options = {}) {
5409
5409
  let descriptor;
5410
5410
  try {
5411
- const before = lstatSync(path, { bigint: true });
5411
+ let before = lstatSync(path, { bigint: true });
5412
+ if (process.platform === 'win32' && before.dev === 0n && before.isFile() && !before.isSymbolicLink()) {
5413
+ before = coreUtil.statRegularFileIdentity(path);
5414
+ }
5412
5415
  if (!before.isFile() || before.isSymbolicLink() || before.size > BigInt(MAX_PROXY_SETTINGS_BYTES)
5413
5416
  || before.dev <= 0n || before.ino <= 0n) {
5414
5417
  throw new Error('proxy settings are not a bounded regular file');
@@ -149,7 +149,7 @@ function hardenWindowsOwnedFile(path, expected) {
149
149
  if (process.platform !== 'win32' || bootstrapWindowsAclTrustForTest)
150
150
  return;
151
151
  const assertIdentity = () => {
152
- const current = lstatSync(path, { bigint: true });
152
+ const current = bootstrapPathMetadata(path);
153
153
  if (!current.isFile() || current.isSymbolicLink() || current.nlink !== 1n
154
154
  || current.dev !== expected.dev || current.ino !== expected.ino || current.size !== expected.size) {
155
155
  throw new Error(`bootstrap Windows owned file changed before hardening: ${path}`);
@@ -281,7 +281,7 @@ function readBoundedRegularText(path, maxBytes, label, options = {}) {
281
281
  const uid = platform === 'win32' || typeof process.getuid !== 'function'
282
282
  ? undefined
283
283
  : BigInt(process.getuid());
284
- const before = lstatSync(path, { bigint: true });
284
+ const before = bootstrapPathMetadata(path);
285
285
  if (before.isSymbolicLink() || !before.isFile() || before.size > BigInt(maxBytes)
286
286
  || (options.requireOwnerOnly === true && before.nlink !== 1n)
287
287
  || before.dev <= 0n || before.ino <= 0n) {
@@ -332,7 +332,7 @@ function readBoundedRegularText(path, maxBytes, label, options = {}) {
332
332
  if (platform === 'win32') {
333
333
  (options.assertWindowsAcl ?? assertWindowsAclTrusted)(path);
334
334
  }
335
- const settled = lstatSync(path, { bigint: true });
335
+ const settled = bootstrapPathMetadata(path);
336
336
  if (!settled.isFile() || settled.isSymbolicLink()
337
337
  || settled.dev !== opened.dev || settled.ino !== opened.ino || settled.size !== opened.size
338
338
  || settled.mtimeNs !== opened.mtimeNs || settled.ctimeNs !== opened.ctimeNs
@@ -442,7 +442,7 @@ function writeDurableExclusive(path, content, mode, publication) {
442
442
  }
443
443
  if (publication && claimPath && ownershipReceipt) {
444
444
  syncDirectory(directory);
445
- const receipt = lstatSync(ownershipReceipt, { bigint: true });
445
+ const receipt = bootstrapPathMetadata(ownershipReceipt);
446
446
  if (!opened.isFile() || opened.dev <= 0n || opened.ino <= 0n
447
447
  || receipt.dev !== opened.dev || receipt.ino !== opened.ino) {
448
448
  throw new Error('bootstrap artifact ownership receipt does not bind the staged claim');
@@ -450,7 +450,7 @@ function writeDurableExclusive(path, content, mode, publication) {
450
450
  linkSync(ownershipReceipt, claimPath);
451
451
  syncDirectory(directory);
452
452
  claimPublished = true;
453
- const claim = lstatSync(claimPath, { bigint: true });
453
+ const claim = bootstrapPathMetadata(claimPath);
454
454
  if (claim.dev !== opened.dev || claim.ino !== opened.ino) {
455
455
  throw new Error('bootstrap artifact claim does not bind the staged ownership receipt');
456
456
  }
@@ -1620,6 +1620,12 @@ function assertTrustedBootstrapArtifactLeaf(stat, platform, uid, path, role) {
1620
1620
  }
1621
1621
  }
1622
1622
  export const _assertTrustedBootstrapArtifactLeafForTest = assertTrustedBootstrapArtifactLeaf;
1623
+ function bootstrapPathMetadata(path) {
1624
+ const stat = lstatSync(path, { bigint: true });
1625
+ // Reuse the native file witness; a missing Windows volume is not an identity.
1626
+ return process.platform === 'win32' && stat.dev === 0n && stat.isFile() && !stat.isSymbolicLink()
1627
+ ? util.statRegularFileIdentity(path) : stat;
1628
+ }
1623
1629
  export function readBootstrapArtifactFile(path, maxBytes = MAX_ARTIFACT_BYTES, hooks = {}) {
1624
1630
  if (!Number.isSafeInteger(maxBytes) || maxBytes < 1 || maxBytes > MAX_ARTIFACT_BYTES) {
1625
1631
  throw new Error('bootstrap artifact read limit is invalid');
@@ -1631,7 +1637,7 @@ export function readBootstrapArtifactFile(path, maxBytes = MAX_ARTIFACT_BYTES, h
1631
1637
  const assertTrustedLeaf = (stat) => assertTrustedBootstrapArtifactLeaf(stat, process.platform, trustedUid, path, role);
1632
1638
  if (process.platform === 'win32')
1633
1639
  assertWindowsAclTrusted(path, role === 'owned');
1634
- const before = lstatSync(path, { bigint: true });
1640
+ const before = bootstrapPathMetadata(path);
1635
1641
  if (before.isSymbolicLink() || !before.isFile() || before.size > BigInt(maxBytes)
1636
1642
  || before.dev <= 0n || before.ino <= 0n) {
1637
1643
  throw new Error(`bootstrap artifact is not a regular owned file: ${path}`);
@@ -1671,7 +1677,7 @@ export function readBootstrapArtifactFile(path, maxBytes = MAX_ARTIFACT_BYTES, h
1671
1677
  hooks.afterRead?.();
1672
1678
  if (process.platform === 'win32')
1673
1679
  assertWindowsAclTrusted(path, role === 'owned');
1674
- const settled = lstatSync(path, { bigint: true });
1680
+ const settled = bootstrapPathMetadata(path);
1675
1681
  if (!settled.isFile() || settled.isSymbolicLink()
1676
1682
  || settled.dev !== opened.dev || settled.ino !== opened.ino
1677
1683
  || settled.size !== opened.size || settled.mtimeNs !== opened.mtimeNs
@@ -1,5 +1,6 @@
1
1
  import { type UserInfo } from 'node:os';
2
2
  import { algo, util } from '@evomap/evolver-core';
3
+ import { type TriggerFeedbackDeliveryState, type TriggerFeedbackDeliveryStatus } from './triggerFeedbackSyncState.js';
3
4
  export interface LocalMemoryGraphOptions {
4
5
  dir: string;
5
6
  userId: string;
@@ -83,6 +84,43 @@ export declare class LocalMemoryGraph implements algo.MemoryGraphProvider {
83
84
  private rotationCleanupFailed;
84
85
  constructor(options: LocalMemoryGraphOptions);
85
86
  query(input: algo.MemoryGraphQueryInput): algo.MemoryGraphAdvice;
87
+ /** @internal Only the bound kernel reader supplies snapshots; CLI/MCP callers provide a run id, never a score. */
88
+ applyKernelTriggerFeedback(snapshot: algo.TriggerFeedbackSnapshot, destinationId?: string): {
89
+ committed: algo.TriggerRatingCommit | null;
90
+ changed: boolean;
91
+ resetSuppressed: boolean;
92
+ };
93
+ applyKernelTriggerFeedbackBatch(snapshots: readonly algo.TriggerFeedbackSnapshot[], destinationId?: string): Array<{
94
+ committed: algo.TriggerRatingCommit | null;
95
+ changed: boolean;
96
+ resetSuppressed: boolean;
97
+ }>;
98
+ readTriggerFeedback(runId: string): algo.TriggerFeedbackState | null;
99
+ triggerFeedbackSourceAvailable(runId: string): boolean;
100
+ readTriggerFeedbackDelivery(runId: string): TriggerFeedbackDeliveryState | null;
101
+ readTriggerFeedbackDeliveries(after?: string | null, limit?: number): Array<{
102
+ snapshot: algo.TriggerFeedbackSnapshot;
103
+ delivery: TriggerFeedbackDeliveryState;
104
+ }>;
105
+ markTriggerFeedbackSourceUnavailable(runId?: string): void;
106
+ authorizeTriggerFeedbackDelivery(runId: string, destinationId: string): TriggerFeedbackDeliveryState;
107
+ claimTriggerFeedbackDelivery(runId: string, destinationId: string, id: string): {
108
+ state: TriggerFeedbackDeliveryState;
109
+ claimed: boolean;
110
+ reconcile: boolean;
111
+ };
112
+ markTriggerFeedbackDispatched(runId: string, id: string): void;
113
+ settleTriggerFeedbackDelivery(runId: string, id: string, result: {
114
+ status: TriggerFeedbackDeliveryStatus;
115
+ revision?: number;
116
+ operationId?: string | null;
117
+ reason?: string;
118
+ }): TriggerFeedbackDeliveryState;
119
+ readTriggerFeedbackRecoveryCursor(kind?: 'native' | 'delivery'): string | null;
120
+ saveTriggerFeedbackRecoveryCursor(after: string | null, kind?: 'native' | 'delivery'): void;
121
+ private changeTriggerFeedbackDelivery;
122
+ private changeTriggerFeedbackFile;
123
+ private readTriggerFeedbackUnlocked;
86
124
  recordOutcome(input: algo.MemoryGraphRecordInput): void;
87
125
  importV1Outcome(workspace: string, raw: unknown, source?: string): boolean;
88
126
  /** Builds a stable import forecast without creating or locking the target graph. */