@evomap/evolver-cli 2.0.42 → 2.0.46

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 (50) hide show
  1. package/dist/autoRecall.d.ts +24 -5
  2. package/dist/autoRecall.js +233 -12
  3. package/dist/autoexec.d.ts +69 -10
  4. package/dist/autoexec.js +847 -137
  5. package/dist/cli.d.ts +1 -1
  6. package/dist/cli.js +71 -26
  7. package/dist/cliContracts.js +29 -7
  8. package/dist/cliEntry.d.ts +3 -0
  9. package/dist/cliEntry.js +63 -0
  10. package/dist/commandCatalog.d.ts +1 -0
  11. package/dist/commandCatalog.js +1 -0
  12. package/dist/contextDelivery.d.ts +12 -0
  13. package/dist/contextDelivery.js +139 -0
  14. package/dist/cycleConsumer.js +9 -1
  15. package/dist/dispatch.js +6 -0
  16. package/dist/feedbackOutbox.d.ts +96 -0
  17. package/dist/feedbackOutbox.js +510 -0
  18. package/dist/feedbackOutboxCli.d.ts +7 -0
  19. package/dist/feedbackOutboxCli.js +208 -0
  20. package/dist/index.d.ts +3 -0
  21. package/dist/index.js +286 -69
  22. package/dist/lifecycle.d.ts +18 -0
  23. package/dist/lifecycle.js +130 -3
  24. package/dist/lifecycleBootstrapTransaction.js +1 -6
  25. package/dist/liveStatus.d.ts +27 -0
  26. package/dist/liveStatus.js +197 -0
  27. package/dist/outboxLock.d.ts +7 -0
  28. package/dist/outboxLock.js +141 -0
  29. package/dist/promptRecallHook.d.ts +7 -22
  30. package/dist/promptRecallHook.js +20 -489
  31. package/dist/promptRecallRuntime.d.ts +24 -0
  32. package/dist/promptRecallRuntime.js +678 -0
  33. package/dist/promptRecallShared.d.ts +18 -0
  34. package/dist/promptRecallShared.js +119 -0
  35. package/dist/recall.js +27 -6
  36. package/dist/runtimeTelemetry.d.ts +9 -0
  37. package/dist/runtimeTelemetry.js +16 -0
  38. package/dist/sessionIngest.d.ts +25 -2
  39. package/dist/sessionIngest.js +196 -32
  40. package/dist/setupHooks.js +63 -13
  41. package/dist/setupHooksLifecycle.js +39 -17
  42. package/dist/skill2gep.d.ts +11 -0
  43. package/dist/skill2gep.js +23 -3
  44. package/dist/solo/mode.js +4 -0
  45. package/dist/taskCommitments.d.ts +4 -2
  46. package/dist/taskCommitments.js +208 -114
  47. package/dist/taskOutcomeOutbox.d.ts +83 -0
  48. package/dist/taskOutcomeOutbox.js +553 -0
  49. package/dist/workflowRuntime.js +12 -0
  50. package/package.json +11 -7
@@ -0,0 +1,208 @@
1
+ /** Operator inspection and evidence-based reconciliation for autoexec feedback. */
2
+ import { lstatSync, readdirSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import { events, hub } from '@evomap/evolver-core';
5
+ import { loadEnvFileFromEnv } from '@evomap/evolver-mcp';
6
+ import { FeedbackOutbox, FeedbackOutboxError } from './feedbackOutbox.js';
7
+ import { TaskOutcomeOutbox, TaskOutcomeOutboxError } from './taskOutcomeOutbox.js';
8
+ const EXACT_OPERATION_ID = /^autoexec-feedback:[a-f0-9]{64}$/;
9
+ const TASK_OPERATION_ID = /^autoexec-task-outcome:[a-f0-9]{64}$/;
10
+ const ROW_NAME = /^[a-f0-9]{64}\.json$/;
11
+ const EVIDENCE_REFERENCE = /^[A-Za-z0-9][A-Za-z0-9._:/#-]{0,255}$/;
12
+ const USAGE = [
13
+ 'Usage:',
14
+ ' evolver autoexec-feedback list [--home <autoexec-dir>] [--json]',
15
+ ' evolver autoexec-feedback reconcile --operation <id> (--ack | --terminal) --evidence <operator-ref> [--reason <operator-reason>] [--home <autoexec-dir>] [--json]',
16
+ 'References must not contain credentials. Known credential formats and configured environment values are rejected; an opaque identifier is not proof of secrecy.',
17
+ 'List includes exact-use and task-wide outcomes. An ambiguous Hub write must be checked externally before reconciliation. A pending write can only be terminally settled after local commit, with evidence and an explicit reason. This command never resends it.',
18
+ ].join('\n') + '\n';
19
+ function parseArgs(argv) {
20
+ const command = argv[0];
21
+ if (command !== 'list' && command !== 'reconcile')
22
+ throw new FeedbackOutboxError('invalid feedback command');
23
+ const args = { command, json: false };
24
+ for (let i = 1; i < argv.length; i += 1) {
25
+ const arg = argv[i];
26
+ if (arg === '--home' || arg === '--operation' || arg === '--evidence' || arg === '--reason') {
27
+ const value = argv[++i];
28
+ if (!value || value.startsWith('--'))
29
+ throw new FeedbackOutboxError(`missing ${arg} value`);
30
+ if (arg === '--home') {
31
+ if (args.home !== undefined)
32
+ throw new FeedbackOutboxError('duplicate --home');
33
+ args.home = value;
34
+ }
35
+ else if (arg === '--operation') {
36
+ if (args.operationId !== undefined)
37
+ throw new FeedbackOutboxError('duplicate --operation');
38
+ args.operationId = value;
39
+ }
40
+ else if (arg === '--evidence') {
41
+ if (args.evidence !== undefined)
42
+ throw new FeedbackOutboxError('duplicate --evidence');
43
+ args.evidence = value;
44
+ }
45
+ else {
46
+ if (args.reason !== undefined)
47
+ throw new FeedbackOutboxError('duplicate --reason');
48
+ args.reason = value;
49
+ }
50
+ }
51
+ else if (arg === '--json') {
52
+ if (args.json)
53
+ throw new FeedbackOutboxError('duplicate --json');
54
+ args.json = true;
55
+ }
56
+ else if (arg === '--ack' || arg === '--terminal') {
57
+ if (args.disposition)
58
+ throw new FeedbackOutboxError('choose one feedback disposition');
59
+ args.disposition = arg === '--ack' ? 'ack' : 'terminal';
60
+ }
61
+ else {
62
+ throw new FeedbackOutboxError('unknown feedback option');
63
+ }
64
+ }
65
+ if (command === 'list') {
66
+ if (args.operationId || args.evidence || args.reason || args.disposition)
67
+ throw new FeedbackOutboxError('list accepts only --home and --json');
68
+ }
69
+ else {
70
+ if (!args.operationId || (!EXACT_OPERATION_ID.test(args.operationId) && !TASK_OPERATION_ID.test(args.operationId))) {
71
+ throw new FeedbackOutboxError('valid --operation required');
72
+ }
73
+ if (!args.disposition)
74
+ throw new FeedbackOutboxError('choose --ack or --terminal');
75
+ if (!args.evidence || !EVIDENCE_REFERENCE.test(args.evidence)) {
76
+ throw new FeedbackOutboxError('nonsecret --evidence reference required');
77
+ }
78
+ if (args.reason && (args.disposition !== 'terminal' || !EVIDENCE_REFERENCE.test(args.reason))) {
79
+ throw new FeedbackOutboxError('nonsecret --reason valid only with --terminal');
80
+ }
81
+ }
82
+ return args;
83
+ }
84
+ function visibleExact(row) {
85
+ return {
86
+ operationId: row.operationId,
87
+ localStatus: row.localStatus,
88
+ networkStatus: row.networkStatus,
89
+ assetId: row.appliedUse.assetId,
90
+ destinationId: row.destinationId ?? null,
91
+ };
92
+ }
93
+ function visibleTask(row) {
94
+ return {
95
+ operationId: row.operationId,
96
+ localStatus: row.localStatus,
97
+ networkStatus: row.networkStatus,
98
+ assetId: row.report.usedAssetIds?.[0] ?? null,
99
+ destinationId: row.destinationId,
100
+ kind: 'task-outcome',
101
+ outcomeStatus: row.report.status,
102
+ };
103
+ }
104
+ function listExactRows(outbox) {
105
+ return readdirSync(outbox.dir)
106
+ .filter((name) => ROW_NAME.test(name))
107
+ .sort()
108
+ .map((name) => outbox.get(`autoexec-feedback:${name.slice(0, -5)}`))
109
+ .filter((row) => row !== null)
110
+ .filter((row) => row.localStatus === 'pending'
111
+ || row.networkStatus === 'pending' || row.networkStatus === 'ambiguous')
112
+ .map(visibleExact);
113
+ }
114
+ function listTaskRows(outbox) {
115
+ return readdirSync(outbox.dir)
116
+ .filter((name) => ROW_NAME.test(name))
117
+ .sort()
118
+ .map((name) => outbox.get(`autoexec-task-outcome:${name.slice(0, -5)}`))
119
+ .filter((row) => row !== null)
120
+ .filter((row) => row.localStatus === 'pending'
121
+ || row.networkStatus === 'pending' || row.networkStatus === 'ambiguous')
122
+ .map(visibleTask);
123
+ }
124
+ function outboxExists(directory) {
125
+ try {
126
+ lstatSync(directory);
127
+ return true;
128
+ }
129
+ catch (error) {
130
+ if (error.code === 'ENOENT')
131
+ return false;
132
+ throw error;
133
+ }
134
+ }
135
+ function line(row) {
136
+ return `${row.operationId} local=${row.localStatus} network=${row.networkStatus} asset=${row.assetId ?? '-'} destination=${row.destinationId ?? '-'}${row.kind === 'task-outcome' ? ` kind=task-outcome outcome=${row.outcomeStatus}` : ''}\n`;
137
+ }
138
+ /** Read-only visibility plus explicit reconciliation. No sender or replay path is reachable here. */
139
+ export async function runAutoExecFeedbackCommand(argv, deps = {}) {
140
+ const stdout = deps.stdout ?? ((value) => { process.stdout.write(value); });
141
+ const stderr = deps.stderr ?? ((value) => { process.stderr.write(value); });
142
+ if (argv.length === 0 || argv.includes('--help') || argv.includes('-h')) {
143
+ stdout(USAGE);
144
+ return 0;
145
+ }
146
+ let args;
147
+ try {
148
+ args = parseArgs(argv);
149
+ }
150
+ catch (error) {
151
+ const reason = error instanceof FeedbackOutboxError ? error.message : 'invalid feedback command';
152
+ stderr(`autoexec-feedback: ${reason}\n${USAGE}`);
153
+ return 1;
154
+ }
155
+ const env = deps.env ?? process.env;
156
+ if ((args.home === undefined || args.command === 'reconcile') && loadEnvFileFromEnv(env).error) {
157
+ stderr('autoexec-feedback: env_file_unavailable\n');
158
+ return 1;
159
+ }
160
+ const home = args.home ?? join(events.evomapHome(env), 'autoexec');
161
+ const exactDirectory = join(home, 'feedback-outbox');
162
+ const taskDirectory = join(home, 'task-outcome-outbox');
163
+ try {
164
+ for (const value of [args.evidence, args.reason]) {
165
+ if (value !== undefined && hub.fullLeakCheck(value, env).found) {
166
+ throw new FeedbackOutboxError('credential-bearing reconciliation reference rejected');
167
+ }
168
+ }
169
+ if (args.command === 'list') {
170
+ const rows = [
171
+ ...(outboxExists(exactDirectory) ? listExactRows(new FeedbackOutbox(exactDirectory)) : []),
172
+ ...(outboxExists(taskDirectory) ? listTaskRows(new TaskOutcomeOutbox(taskDirectory)) : []),
173
+ ].sort((a, b) => a.operationId.localeCompare(b.operationId));
174
+ stdout(args.json
175
+ ? `${JSON.stringify({ operations: rows })}\n`
176
+ : rows.length > 0 ? rows.map(line).join('') : 'No pending or ambiguous feedback operations.\n');
177
+ return 0;
178
+ }
179
+ const operationId = args.operationId;
180
+ const evidence = args.evidence;
181
+ const task = TASK_OPERATION_ID.test(operationId);
182
+ const directory = task ? taskDirectory : exactDirectory;
183
+ if (!outboxExists(directory)) {
184
+ throw task ? new TaskOutcomeOutboxError('task outcome operation not found')
185
+ : new FeedbackOutboxError('feedback operation not found');
186
+ }
187
+ const taskBox = task ? new TaskOutcomeOutbox(directory) : undefined;
188
+ const exactBox = task ? undefined : new FeedbackOutbox(directory);
189
+ const current = task ? taskBox.get(operationId) : exactBox.get(operationId);
190
+ if (args.disposition === 'terminal' && current?.networkStatus === 'pending' && !args.reason) {
191
+ throw new FeedbackOutboxError('--reason required for pending terminal reconciliation');
192
+ }
193
+ const resolution = args.disposition === 'ack'
194
+ ? { status: 'acknowledged', evidence }
195
+ : { status: 'terminal', evidence, reason: args.reason ?? 'operator_reconciled_terminal' };
196
+ const result = task
197
+ ? visibleTask(taskBox.reconcile(operationId, resolution))
198
+ : visibleExact(exactBox.reconcile(operationId, resolution));
199
+ stdout(args.json ? `${JSON.stringify(result)}\n` : line(result));
200
+ return 0;
201
+ }
202
+ catch (error) {
203
+ const reason = error instanceof FeedbackOutboxError || error instanceof TaskOutcomeOutboxError
204
+ ? error.message : 'unable to read feedback outbox';
205
+ stderr(`autoexec-feedback: ${reason}\n`);
206
+ return 1;
207
+ }
208
+ }
package/dist/index.d.ts CHANGED
@@ -164,6 +164,9 @@ export interface InjectDeps {
164
164
  legacyTaskSweep?: () => void;
165
165
  /** Test seam for the non-git workspace notice. Production uses cwd + ~/.evomap throttle state. */
166
166
  nonGitNotice?: NonGitWorkspaceNoticeOptions;
167
+ /** Resolving means bytes written, not host receipt or execution. */
168
+ stdout?: (text: string) => void | Promise<void>;
169
+ contextTimeoutMs?: number;
167
170
  }
168
171
  /**
169
172
  * `evolver inject session-start`: the SessionStart hook entrypoint (the command every installer registers).