hippo-memory 3.4.0 → 3.6.0
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/README.md +29 -26
- package/dist/api/callers.d.ts +4 -1
- package/dist/api/context/context-plan.js +3 -0
- package/dist/api/context/context-pools.js +2 -0
- package/dist/api/context/context.d.ts +1 -1
- package/dist/api/context/context.js +13 -9
- package/dist/api/ledger-db.d.ts +4 -2
- package/dist/api/ledger-db.js +11 -1
- package/dist/api/objects/object-kinds.d.ts +1 -4
- package/dist/api/objects/object-kinds.js +1 -5
- package/dist/api/pilot-arm.js +4 -1
- package/dist/api/recall/finish.js +3 -2
- package/dist/api/recall/recall.js +3 -1
- package/dist/api/recall/request.d.ts +1 -1
- package/dist/api/recall/request.js +3 -1
- package/dist/api/session-end.d.ts +3 -2
- package/dist/api/session-end.js +8 -4
- package/dist/api/sharing.d.ts +4 -3
- package/dist/api/sharing.js +2 -2
- package/dist/api/sleep/auto-sleep.d.ts +3 -2
- package/dist/api/sleep/auto-sleep.js +16 -3
- package/dist/api/sleep/one-sleep.d.ts +23 -0
- package/dist/api/sleep/one-sleep.js +53 -0
- package/dist/api/sleep/sleep.d.ts +5 -0
- package/dist/api/sleep/sleep.js +2 -1
- package/dist/api/tokens.d.ts +1 -1
- package/dist/api/tokens.js +3 -0
- package/dist/api/types.d.ts +2 -0
- package/dist/api/types.js +4 -0
- package/dist/base/config/config-keys.js +1 -0
- package/dist/base/config/config.d.ts +4 -0
- package/dist/base/config/config.js +1 -0
- package/dist/base/embeddings/local.d.ts +1 -1
- package/dist/base/embeddings/local.js +2 -3
- package/dist/base/errors/read-only.d.ts +3 -0
- package/dist/base/errors/read-only.js +4 -0
- package/dist/base/ports/store/capture.d.ts +2 -0
- package/dist/base/ports/store/consolidation.d.ts +15 -0
- package/dist/base/ports/store/consolidation.js +2 -0
- package/dist/base/ports/store/context-reads.d.ts +2 -0
- package/dist/base/ports/store/objects.d.ts +15 -4
- package/dist/base/ports/store/store-effects.d.ts +2 -0
- package/dist/base/ports/store.d.ts +1 -1
- package/dist/base/scope/read-admission.d.ts +2 -0
- package/dist/base/scope/read-admission.js +8 -2
- package/dist/base/util/env.d.ts +1 -0
- package/dist/base/util/env.js +3 -0
- package/dist/base/util/version.d.ts +1 -1
- package/dist/base/util/version.js +1 -1
- package/dist/cli.js +14 -1
- package/dist/db/connect.d.ts +4 -0
- package/dist/db/connect.js +79 -1
- package/dist/db/grant.js +1 -1
- package/dist/db/migrate.d.ts +3 -0
- package/dist/db/migrate.js +1 -1
- package/dist/db/migrations/index.d.ts +1 -1
- package/dist/db/migrations/index.js +3 -1
- package/dist/db/migrations/v63.d.ts +3 -0
- package/dist/db/migrations/v63.js +9 -0
- package/dist/db/store-runtime.d.ts +7 -0
- package/dist/db/store-runtime.js +4 -0
- package/dist/domain/consolidate/merge.js +6 -6
- package/dist/domain/consolidate/tombstones.d.ts +3 -4
- package/dist/domain/consolidate/tombstones.js +3 -3
- package/dist/domain/objects/decisions.d.ts +4 -7
- package/dist/domain/objects/decisions.js +1 -9
- package/dist/domain/objects/descriptor.d.ts +2 -0
- package/dist/domain/objects/lifecycle.js +8 -2
- package/dist/domain/sharing/share.d.ts +16 -4
- package/dist/domain/sharing/share.js +33 -17
- package/dist/entry/store-kit.js +2 -1
- package/dist/infra/local-embedder.js +14 -2
- package/dist/infra/spool-claims.d.ts +2 -2
- package/dist/infra/spool-claims.js +4 -3
- package/dist/infra/spool-import.js +1 -1
- package/dist/infra/spool-record.d.ts +3 -1
- package/dist/store/sqlite/capture/compaction-hooks.js +14 -6
- package/dist/store/sqlite/capture/spool-request-id.d.ts +3 -0
- package/dist/store/sqlite/capture/spool-request-id.js +12 -0
- package/dist/store/sqlite/consolidation/consolidation.js +2 -0
- package/dist/store/sqlite/consolidation/sleep-lock.d.ts +4 -0
- package/dist/store/sqlite/consolidation/sleep-lock.js +69 -0
- package/dist/store/sqlite/entries/entry-filter.js +1 -2
- package/dist/store/sqlite/entries/entry-row.js +5 -1
- package/dist/store/sqlite/entries/entry-writes.js +3 -10
- package/dist/store/sqlite/entries/raw-archive.d.ts +2 -1
- package/dist/store/sqlite/entries/raw-archive.js +12 -3
- package/dist/store/sqlite/index.d.ts +1 -1
- package/dist/store/sqlite/learning/prediction-baserate.js +4 -2
- package/dist/store/sqlite/recall/candidates.js +2 -7
- package/dist/store/sqlite/recall/search-rows.d.ts +3 -0
- package/dist/store/sqlite/recall/search-rows.js +27 -8
- package/dist/store/sqlite/records/object-rows.d.ts +2 -0
- package/dist/store/sqlite/records/object-rows.js +5 -1
- package/dist/store/sqlite/records/object-writes.d.ts +3 -0
- package/dist/store/sqlite/records/object-writes.js +43 -1
- package/dist/store/sqlite/review/conflicts.js +3 -4
- package/dist/store/sqlite/runtime/handles.js +3 -0
- package/dist/store/sqlite/runtime/rule-sql.d.ts +1 -0
- package/dist/store/sqlite/runtime/rule-sql.js +2 -0
- package/dist/surface/capture/session-worker.d.ts +3 -2
- package/dist/surface/capture/session-worker.js +36 -10
- package/dist/surface/cli/api-context.js +3 -1
- package/dist/surface/cli/cli-runtime.js +2 -1
- package/dist/surface/cli/client.d.ts +6 -5
- package/dist/surface/cli/client.js +50 -19
- package/dist/surface/cli/decisions.js +16 -17
- package/dist/surface/cli/hooks/session-end-worker.js +3 -2
- package/dist/surface/cli/install-steps.js +99 -13
- package/dist/surface/cli/memory-writes.js +3 -2
- package/dist/surface/cli/serve.js +4 -1
- package/dist/surface/cli/sleep-render.js +7 -0
- package/dist/surface/cli/sleep.d.ts +3 -2
- package/dist/surface/cli/sleep.js +10 -4
- package/dist/surface/cli/transfer.js +6 -3
- package/dist/surface/cli/verb-row.d.ts +2 -0
- package/dist/surface/cli/verbs/health.js +3 -0
- package/dist/surface/cli/verbs/memory.js +5 -0
- package/dist/surface/cli/verbs/objects.js +2 -0
- package/dist/surface/cli/verbs/sessions.js +11 -0
- package/dist/surface/hooks-install/codex-wrapper.js +52 -11
- package/dist/surface/hooks-install/rules/hook-blocks.js +9 -2
- package/dist/surface/mcp/admin-tools.js +5 -2
- package/dist/surface/mcp/request.js +6 -2
- package/dist/surface/mcp/tools.d.ts +2 -0
- package/dist/surface/mcp/tools.js +8 -0
- package/dist/surface/open-store.d.ts +2 -2
- package/dist/surface/open-store.js +2 -2
- package/dist/surface/server/routes/decisions.js +2 -2
- package/dist/surface/server/sleep-child.js +5 -4
- package/dist/surface/server/sleep-offload.js +36 -25
- package/extensions/openclaw-plugin/openclaw.plugin.json +1 -1
- package/extensions/openclaw-plugin/package.json +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
|
@@ -63,13 +63,13 @@ function takeQueued(queued) {
|
|
|
63
63
|
catch (err) {
|
|
64
64
|
// ENOENT means nothing is queued; any other refusal leaves the request queued for the next
|
|
65
65
|
// round, but is told.
|
|
66
|
-
if (errorCode(err)
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
return
|
|
66
|
+
if (errorCode(err) === 'ENOENT')
|
|
67
|
+
return { kind: 'empty' };
|
|
68
|
+
logger.warn(`session worker: cannot take the queued request ${queued}: ${errorMessage(err)}`, errorFields(err));
|
|
69
|
+
return { kind: 'failed', err };
|
|
70
70
|
}
|
|
71
71
|
try {
|
|
72
|
-
return fs.readFileSync(taken, 'utf8') === 'full' ? 'full' : 'turn';
|
|
72
|
+
return { kind: 'took', mode: fs.readFileSync(taken, 'utf8') === 'full' ? 'full' : 'turn' };
|
|
73
73
|
}
|
|
74
74
|
finally {
|
|
75
75
|
fs.rmSync(taken, { force: true });
|
|
@@ -77,35 +77,61 @@ function takeQueued(queued) {
|
|
|
77
77
|
}
|
|
78
78
|
// Rounds in which takeQueued took nothing: such a request stays queued for the next worker instead of spinning here.
|
|
79
79
|
const MAX_ROUNDS = 5;
|
|
80
|
+
function queuedKind(queued) {
|
|
81
|
+
try {
|
|
82
|
+
return fs.readFileSync(queued, 'utf8') === 'full' ? 'full' : 'turn';
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
logger.debug(`session worker: cannot read ${queued}: ${errorMessage(err)}`, errorFields(err));
|
|
86
|
+
return 'unreadable';
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function reportGaveUp(queued, lastFailed, gaveUp) {
|
|
90
|
+
const lastTake = lastFailed === null
|
|
91
|
+
? 'none: the request was queued again each round'
|
|
92
|
+
: errorMessage(lastFailed.err);
|
|
93
|
+
const line = `session worker: gave up after ${MAX_ROUNDS} rounds with the ${queuedKind(queued)} request ` +
|
|
94
|
+
`still queued in ${queued}; ` +
|
|
95
|
+
`last take error: ${lastTake}`;
|
|
96
|
+
logger.warn(line, lastFailed === null ? undefined : errorFields(lastFailed.err));
|
|
97
|
+
gaveUp?.(line);
|
|
98
|
+
}
|
|
80
99
|
/** Runs `work` unless a live worker holds this session, which then runs the request after its
|
|
81
|
-
* own so the last reply is never dropped.
|
|
82
|
-
|
|
100
|
+
* own so the last reply is never dropped. A detached worker's stderr goes nowhere, so `gaveUp`
|
|
101
|
+
* is where it leaves the line saying it stopped with the request still queued. */
|
|
102
|
+
export async function runSessionWorker(sessionId, mode, work, gaveUp) {
|
|
83
103
|
const files = sessionStateFiles(sessionId);
|
|
84
104
|
if (files === null)
|
|
85
105
|
return work(mode);
|
|
86
106
|
if (!queueRun(files, mode))
|
|
87
107
|
return;
|
|
88
108
|
let idleRounds = 0;
|
|
109
|
+
let lastFailed = null;
|
|
89
110
|
for (let take = takeFileLock(files.lock); take.kind !== 'held'; take = takeFileLock(files.lock)) {
|
|
90
111
|
if (take.kind === 'unusable') {
|
|
91
112
|
warnUnusableLockOnce(files.lock, take.cause);
|
|
92
113
|
return work(mode);
|
|
93
114
|
}
|
|
94
115
|
let ran = false;
|
|
116
|
+
let next = { kind: 'empty' };
|
|
95
117
|
try {
|
|
96
|
-
for (
|
|
118
|
+
for (next = takeQueued(files.queued); next.kind === 'took'; next = takeQueued(files.queued)) {
|
|
97
119
|
ran = true;
|
|
98
|
-
await work(next);
|
|
120
|
+
await work(next.mode);
|
|
99
121
|
}
|
|
100
122
|
}
|
|
101
123
|
finally {
|
|
102
124
|
take.lock.release();
|
|
103
125
|
}
|
|
126
|
+
if (next.kind === 'failed')
|
|
127
|
+
lastFailed = next;
|
|
104
128
|
// A taker that found the lock held left its request queued, so look again after every release.
|
|
105
129
|
if (!fs.existsSync(files.queued))
|
|
106
130
|
return;
|
|
107
|
-
if (!ran && ++idleRounds >= MAX_ROUNDS)
|
|
131
|
+
if (!ran && ++idleRounds >= MAX_ROUNDS) {
|
|
132
|
+
reportGaveUp(files.queued, lastFailed, gaveUp);
|
|
108
133
|
return;
|
|
134
|
+
}
|
|
109
135
|
}
|
|
110
136
|
}
|
|
111
137
|
function turnKey(turn) {
|
|
@@ -4,6 +4,7 @@ import { contextReach, } from '../../api/types.js';
|
|
|
4
4
|
import { ledgerReachOf } from '../../api/ledger-db.js';
|
|
5
5
|
import { configReader } from '../../host/config-file.js';
|
|
6
6
|
import { autoSleepConsolidate } from '../../api/sleep/auto-sleep.js';
|
|
7
|
+
import { sleepWasRefused } from '../../api/sleep/one-sleep.js';
|
|
7
8
|
import { rerankerWithClef } from '../../api/recall/rows.js';
|
|
8
9
|
import { hippoHomeDir } from '../../host/agent-homes.js';
|
|
9
10
|
import { allMcpTools } from '../mcp/request.js';
|
|
@@ -156,6 +157,7 @@ export function cliSecondStore(root) {
|
|
|
156
157
|
export function cliLedgerReach(hippoRoot) {
|
|
157
158
|
return ledgerReachOf({
|
|
158
159
|
reach: cliReach(hippoRoot, cliStore(hippoRoot), cliInfra().embedderFor),
|
|
160
|
+
config: cliConfig(hippoRoot),
|
|
159
161
|
});
|
|
160
162
|
}
|
|
161
163
|
/** `root`'s auto-sleep on a session of its own: the sleep outlives the frame whose write started
|
|
@@ -166,7 +168,7 @@ function rootAutoSleep(root, hostTenantId) {
|
|
|
166
168
|
config: cliConfig(root),
|
|
167
169
|
tenantId: hostTenantId,
|
|
168
170
|
infra: cliInfra(),
|
|
169
|
-
}), 'cli', cliRuntime()).then(() => undefined);
|
|
171
|
+
}), 'cli', cliRuntime()).then((outcome) => (sleepWasRefused(outcome) ? outcome : undefined));
|
|
170
172
|
}
|
|
171
173
|
/** Stdio is the operator's own process: host admin, the folder's hippo.db, and an auto-sleep
|
|
172
174
|
* that runs in process. One host per stdio loop, so its callers live as long as the loop, which
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// The CLI command's store runtime, apart from api-context.ts so cli.ts can end a command without
|
|
2
2
|
// loading the verbs' store wiring.
|
|
3
3
|
import { withStoreRuntime } from '../open-store.js';
|
|
4
|
+
import { envReadOnly } from '../../base/util/env.js';
|
|
4
5
|
// One command per process, so its runtime is root state as its session is; between commands a store
|
|
5
6
|
// pools nothing.
|
|
6
7
|
let commandRuntime;
|
|
@@ -22,6 +23,6 @@ export async function runCliCommand(fn) {
|
|
|
22
23
|
finally {
|
|
23
24
|
commandRuntime = undefined;
|
|
24
25
|
}
|
|
25
|
-
});
|
|
26
|
+
}, { readOnly: envReadOnly() });
|
|
26
27
|
}
|
|
27
28
|
//# sourceMappingURL=cli-runtime.js.map
|
|
@@ -18,7 +18,7 @@ export declare class HttpResponseError extends Error {
|
|
|
18
18
|
* pidfile's port. */
|
|
19
19
|
export declare class MalformedReplyError extends Error {
|
|
20
20
|
readonly route: string;
|
|
21
|
-
constructor(route: string, detail: string);
|
|
21
|
+
constructor(route: string, detail: string, cause?: unknown);
|
|
22
22
|
}
|
|
23
23
|
/** The server gates every write, so a reply may be a skip; `force: true` stores it anyway. */
|
|
24
24
|
export declare function postRemember(serverUrl: string, apiKey: string | undefined, opts: RememberOptions & {
|
|
@@ -51,10 +51,11 @@ export interface NearestIdsBody {
|
|
|
51
51
|
/** The ids the server finds nearest `body.vector`, nearest first, in one try that gives up after
|
|
52
52
|
* `timeoutMs`. */
|
|
53
53
|
export declare function nearestIds(serverUrl: string, apiKey: string | undefined, body: NearestIdsBody, timeoutMs: number): Promise<string[]>;
|
|
54
|
-
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* failure. */
|
|
54
|
+
/** 'never-sent': the connection never opened, so a write replays locally. 'none': the server answered
|
|
55
|
+
* with an error, or the request could not be built. 'delivery-unknown': the default for every error
|
|
56
|
+
* not listed, as the request may have committed, so a write is never replayed. */
|
|
58
57
|
export type TransportFailure = 'none' | 'never-sent' | 'delivery-unknown';
|
|
59
58
|
export declare function classifyTransportFailure(err: Error): TransportFailure;
|
|
59
|
+
/** What the user reads when a write may have landed and is not replayed. */
|
|
60
|
+
export declare function deliveryUnknownReason(err: Error, url: string): string;
|
|
60
61
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -76,18 +76,31 @@ async function throwForStatus(res) {
|
|
|
76
76
|
* pidfile's port. */
|
|
77
77
|
export class MalformedReplyError extends Error {
|
|
78
78
|
route;
|
|
79
|
-
constructor(route, detail) {
|
|
80
|
-
super(`the hippo server's reply to ${route} was not the expected JSON object (${detail})
|
|
79
|
+
constructor(route, detail, cause) {
|
|
80
|
+
super(`the hippo server's reply to ${route} was not the expected JSON object (${detail})`, cause === undefined ? undefined : { cause });
|
|
81
81
|
this.route = route;
|
|
82
82
|
this.name = 'MalformedReplyError';
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
+
/** A 2xx body under the cap: the plain Errors `readCappedJson` throws become a MalformedReplyError,
|
|
86
|
+
* and a transport error keeps its class. */
|
|
87
|
+
async function readReplyBody(res, route) {
|
|
88
|
+
try {
|
|
89
|
+
return await readCappedJson(res, MAX_REPLY_BYTES);
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
if (err instanceof Error && err.constructor === Error) {
|
|
93
|
+
throw new MalformedReplyError(route, err.message, err);
|
|
94
|
+
}
|
|
95
|
+
throw err;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
85
98
|
/**
|
|
86
99
|
* A 2xx reply's body, read under the cap; it must be a JSON object, and `guard` narrows it further
|
|
87
100
|
* where the shape is known.
|
|
88
101
|
*/
|
|
89
102
|
async function readReply(res, route, guard) {
|
|
90
|
-
const body = await
|
|
103
|
+
const body = await readReplyBody(res, route);
|
|
91
104
|
if (!isJsonObject(body)) {
|
|
92
105
|
throw new MalformedReplyError(route, body === null ? 'null' : Array.isArray(body) ? 'array' : 'a scalar');
|
|
93
106
|
}
|
|
@@ -155,29 +168,47 @@ function transportCode(err) {
|
|
|
155
168
|
const cause = err.cause;
|
|
156
169
|
return isObjectLike(cause) && 'code' in cause ? String(cause.code) : '';
|
|
157
170
|
}
|
|
171
|
+
const SOCKET_CODES = new Set([
|
|
172
|
+
'ECONNRESET',
|
|
173
|
+
'ECONNABORTED',
|
|
174
|
+
'EPIPE',
|
|
175
|
+
'UND_ERR_SOCKET',
|
|
176
|
+
]);
|
|
177
|
+
/** A request that was on the wire when it failed: a dead socket, a fetch TypeError (no code means no
|
|
178
|
+
* known syscall) or a server gone quiet. */
|
|
179
|
+
function diedOnTheWire(err) {
|
|
180
|
+
return (SOCKET_CODES.has(transportCode(err)) || err instanceof TypeError || err.name === 'TimeoutError');
|
|
181
|
+
}
|
|
158
182
|
export function classifyTransportFailure(err) {
|
|
159
|
-
// The server answered,
|
|
160
|
-
if (err instanceof HttpResponseError)
|
|
183
|
+
// The server answered, or encodeURIComponent threw before any request existed.
|
|
184
|
+
if (err instanceof HttpResponseError || err instanceof URIError)
|
|
161
185
|
return 'none';
|
|
162
186
|
const code = transportCode(err);
|
|
163
187
|
// Connect-phase failures: no request bytes ever left the client, so a stale pidfile can be healed
|
|
164
188
|
// and the call replayed on the direct path.
|
|
165
189
|
if (code === 'ECONNREFUSED' || code === 'ENOTFOUND' || code === 'EAI_AGAIN')
|
|
166
190
|
return 'never-sent';
|
|
167
|
-
//
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
191
|
+
// Any other error may have committed: only the two classes above are known not to have.
|
|
192
|
+
return 'delivery-unknown';
|
|
193
|
+
}
|
|
194
|
+
const WRITE_MAY_HAVE_LANDED = 'so the write may already have been applied. Not retrying locally.';
|
|
195
|
+
/** The syscall code or the class name of an error hippo does not know, never its message, which a
|
|
196
|
+
* foreign library may fill with the request's headers. */
|
|
197
|
+
function unrecognisedDetail(err) {
|
|
198
|
+
const code = transportCode(err);
|
|
199
|
+
const name = err.constructor.name;
|
|
200
|
+
const detail = /^[A-Z0-9_]+$/.test(code) ? code : name === 'Error' ? '' : name;
|
|
201
|
+
return detail === '' ? '' : ` (${detail})`;
|
|
202
|
+
}
|
|
203
|
+
/** What the user reads when a write may have landed and is not replayed. */
|
|
204
|
+
export function deliveryUnknownReason(err, url) {
|
|
205
|
+
if (err instanceof MalformedReplyError) {
|
|
206
|
+
return `${url} answered, but its reply could not be read, ${WRITE_MAY_HAVE_LANDED}`;
|
|
207
|
+
}
|
|
208
|
+
if (diedOnTheWire(err)) {
|
|
209
|
+
return `the connection to ${url} dropped or timed out mid-request, ${WRITE_MAY_HAVE_LANDED}`;
|
|
173
210
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
if (err instanceof TypeError)
|
|
177
|
-
return 'delivery-unknown';
|
|
178
|
-
// The request was sent and the server went quiet, so it may have committed.
|
|
179
|
-
if (err.name === 'TimeoutError')
|
|
180
|
-
return 'delivery-unknown';
|
|
181
|
-
return 'none';
|
|
211
|
+
const unrecognised = `failed in a way hippo does not recognise${unrecognisedDetail(err)}`;
|
|
212
|
+
return `the request to ${url} ${unrecognised}, ${WRITE_MAY_HAVE_LANDED}`;
|
|
182
213
|
}
|
|
183
214
|
//# sourceMappingURL=client.js.map
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
// First-class object verbs for decisions: record one (optionally superseding an older one's
|
|
2
2
|
// memory), list, get, close.
|
|
3
3
|
import { memoryGet } from '../../api/memories/memories.js';
|
|
4
|
-
import { decisionIdByMemory
|
|
4
|
+
import { decisionIdByMemory } from '../../api/objects/object-kinds.js';
|
|
5
5
|
import { objectClose, objectCreate, objectGet, objectList, objectStates, } from '../../api/objects/objects.js';
|
|
6
6
|
import { printError } from './output.js';
|
|
7
7
|
import { flagValueless, nonEmptyStringFlag, stringFlag, } from './flag-values.js';
|
|
8
8
|
import { requireInit } from './shared.js';
|
|
9
9
|
import { cliApiContext } from './api-context.js';
|
|
10
10
|
import { closeObjectVerb, foundOrExit, idArgOrExit, listObjectsVerb, printLifecycleTail, } from './object-verbs.js';
|
|
11
|
-
import { errorMessage } from '../../base/util/log.js';
|
|
12
11
|
import { fail } from './exit.js';
|
|
13
12
|
import { shellFolder } from './versioned-verbs.js';
|
|
14
13
|
const DECISION = { cmd: 'decide', noun: 'Decision', idLabel: 'decision' };
|
|
14
|
+
const NOT_RECORDED = 'The decision was NOT recorded. Nothing changed, so it is safe to run the command again.';
|
|
15
15
|
function printDecisionRow(d) {
|
|
16
16
|
const supPart = d.supersededBy !== null ? ` superseded_by=#${d.supersededBy}` : '';
|
|
17
17
|
console.log(`#${d.id} [${d.status}]${supPart} memory=${d.memoryId ?? '-'}`);
|
|
@@ -63,22 +63,20 @@ async function decideCreate(ctx, decisionText, flags) {
|
|
|
63
63
|
fail('--supersedes requires a memory id, e.g. hippo decide "<text>" --supersedes mem_abc123.');
|
|
64
64
|
}
|
|
65
65
|
const supersedesMemId = stringFlag(flags, 'supersedes') ?? null;
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
// shows the supersession.
|
|
66
|
+
// The save weakens the old memory in the same write. A decision row backing the memory is
|
|
67
|
+
// weakened through its supersede link; a plain memory is named so the save weakens it too.
|
|
69
68
|
let supersedesDecisionId;
|
|
70
|
-
let
|
|
69
|
+
let weakensMemoryId;
|
|
71
70
|
if (supersedesMemId) {
|
|
72
|
-
|
|
73
|
-
if (!oldEntry) {
|
|
71
|
+
if (!(await memoryGet(ctx, supersedesMemId))) {
|
|
74
72
|
fail(`Memory ${supersedesMemId} not found.`);
|
|
75
73
|
}
|
|
76
74
|
supersedesDecisionId = (await decisionIdByMemory(ctx, supersedesMemId)) ?? undefined;
|
|
75
|
+
if (supersedesDecisionId === undefined)
|
|
76
|
+
weakensMemoryId = supersedesMemId;
|
|
77
77
|
}
|
|
78
|
-
const write = { decisionText, context, supersedesDecisionId };
|
|
79
|
-
const created = await
|
|
80
|
-
if (oldEntry)
|
|
81
|
-
await weakenOrWarn(ctx, oldEntry, supersedesMemId);
|
|
78
|
+
const write = { decisionText, context, supersedesDecisionId, weakensMemoryId };
|
|
79
|
+
const created = await recordDecision(ctx, write, Boolean(supersedesMemId));
|
|
82
80
|
console.log(`Decision recorded: #${created.id}`);
|
|
83
81
|
if (created.memoryId)
|
|
84
82
|
console.log(` memory: ${created.memoryId}`);
|
|
@@ -91,14 +89,15 @@ function exitWithDecideUsage() {
|
|
|
91
89
|
printError(' hippo decide get <id>');
|
|
92
90
|
fail(' hippo decide close <id>');
|
|
93
91
|
}
|
|
94
|
-
async function
|
|
95
|
-
// Best-effort and last: the decision already committed. Failing here would make a retry find no
|
|
96
|
-
// active decision for the old memory and create a duplicate active successor, so warn instead.
|
|
92
|
+
async function recordDecision(ctx, write, supersedes) {
|
|
97
93
|
try {
|
|
98
|
-
await
|
|
94
|
+
return await objectCreate(ctx, 'decision', write, shellFolder());
|
|
99
95
|
}
|
|
100
96
|
catch (e) {
|
|
101
|
-
|
|
97
|
+
// True only while the save is whole or nothing: a throw after its commit would break this claim.
|
|
98
|
+
if (supersedes)
|
|
99
|
+
printError(NOT_RECORDED);
|
|
100
|
+
throw e;
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
103
|
function printSupersedes(supersedesMemId, supersedesDecisionId) {
|
|
@@ -11,7 +11,7 @@ import { workingFolder } from '../shared.js';
|
|
|
11
11
|
import { boolFlag, stringFlag } from '../flag-values.js';
|
|
12
12
|
import { appendSessionEndCloseLog, captureTarget, flushingOnExit, logSessionEndImport, reportSessionEndFailure, } from '../hook-runtime.js';
|
|
13
13
|
export async function handleSessionEndWorker({ hippoRoot, tenantId, flags, }) {
|
|
14
|
-
await runSessionWorker(stringFlag(flags, 'session-id') ?? null, boolFlag(flags, 'turn') ? 'turn' : 'full', (mode) => sessionEndWork(hippoRoot, tenantId, flags, mode));
|
|
14
|
+
await runSessionWorker(stringFlag(flags, 'session-id') ?? null, boolFlag(flags, 'turn') ? 'turn' : 'full', (mode) => sessionEndWork(hippoRoot, tenantId, flags, mode), (line, opts) => appendSessionEndCloseLog(stringFlag(flags, 'log-file') ?? null, line, opts));
|
|
15
15
|
}
|
|
16
16
|
async function sessionEndWork(hippoRoot, tenantId, flags, mode) {
|
|
17
17
|
const logFile = stringFlag(flags, 'log-file') ?? null;
|
|
@@ -55,11 +55,12 @@ function runSessionEndWork({ hippoRoot, tenantId, flags, mode, held, }) {
|
|
|
55
55
|
* regardless. */
|
|
56
56
|
async function sleepFolderStore(hippoRoot, tenantId, flags, closeLogFile) {
|
|
57
57
|
try {
|
|
58
|
-
await (await import('../sleep.js')).sleepStore({ hippoRoot, tenantId, args: [], flags });
|
|
58
|
+
return await (await import('../sleep.js')).sleepStore({ hippoRoot, tenantId, args: [], flags });
|
|
59
59
|
}
|
|
60
60
|
catch (err) {
|
|
61
61
|
// sleepStore writes its own failure line only once its log tee is open.
|
|
62
62
|
reportSessionEndFailure(closeLogFile, 'session-end: sleep', err);
|
|
63
|
+
return false;
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
/** True when capture ran to the end, so a turn close may move its cursor past these turns. */
|
|
@@ -93,9 +93,13 @@ function scheduleOnWindows(taskName, cmd, run) {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
catch (err) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
if (schedulerTimedOut(err)) {
|
|
97
|
+
// An unanswered query may hide an existing task, so nothing is created over it.
|
|
98
|
+
console.log(` schtasks /query did not answer within ${SCHEDULER_CALL_TIMEOUT_MS / 1000} s and was stopped, so Task ` +
|
|
99
|
+
`Scheduler was not changed; run hippo init again, or check for the task ${taskName}.`);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
// Any other non-zero exit means the task does not exist yet, so it is created below.
|
|
99
103
|
}
|
|
100
104
|
try {
|
|
101
105
|
run('schtasks', buildSchtasksCreateArgs(taskName, cmd), SCHEDULER_CALL);
|
|
@@ -129,28 +133,110 @@ function readCrontab(run) {
|
|
|
129
133
|
throw err;
|
|
130
134
|
}
|
|
131
135
|
}
|
|
136
|
+
const dailyCronLine = (cmd, marker) => `15 6 * * * ${cmd} ${marker}`;
|
|
137
|
+
// The five schedule fields or an @macro, with any leading blanks.
|
|
138
|
+
const CRON_SCHEDULE = /^\s*(?:@\S+|\S+(?:\s+\S+){4})(?=\s|$)/;
|
|
139
|
+
/** Best effort shell scan: false when `text` ends inside a quote, where a marker is another job's data. */
|
|
140
|
+
function outsideQuotes(text) {
|
|
141
|
+
let open = '';
|
|
142
|
+
for (let i = 0; i < text.length; i++) {
|
|
143
|
+
const c = text[i];
|
|
144
|
+
if (open === `'`)
|
|
145
|
+
open = c === `'` ? '' : open;
|
|
146
|
+
else if (c === '\\')
|
|
147
|
+
i++;
|
|
148
|
+
else if (open === '"')
|
|
149
|
+
open = c === '"' ? '' : open;
|
|
150
|
+
else if (c === `'` || c === '"')
|
|
151
|
+
open = c;
|
|
152
|
+
}
|
|
153
|
+
return open === '';
|
|
154
|
+
}
|
|
155
|
+
/** Where `marker` stands in `line` as a whole token outside quotes, or -1; `<marker>-old` is another name. */
|
|
156
|
+
function markerAt(line, marker) {
|
|
157
|
+
const blankOrEdge = (i) => i < 0 || i >= line.length || /\s/.test(line[i]);
|
|
158
|
+
const isOurs = (at) => blankOrEdge(at - 1) && blankOrEdge(at + marker.length) && outsideQuotes(line.slice(0, at));
|
|
159
|
+
for (let at = line.indexOf(marker); at >= 0; at = line.indexOf(marker, at + 1)) {
|
|
160
|
+
if (isOurs(at))
|
|
161
|
+
return at;
|
|
162
|
+
}
|
|
163
|
+
return -1;
|
|
164
|
+
}
|
|
165
|
+
/** `line` with its command replaced by `cmd`, schedule and marker kept; null when it has no schedule. */
|
|
166
|
+
function withCommand(line, at, cmd) {
|
|
167
|
+
const schedule = CRON_SCHEDULE.exec(line)?.[0];
|
|
168
|
+
if (schedule === undefined || at < schedule.length)
|
|
169
|
+
return null;
|
|
170
|
+
return line.slice(schedule.length, at).trim() === cmd
|
|
171
|
+
? line
|
|
172
|
+
: `${schedule} ${cmd} ${line.slice(at)}`;
|
|
173
|
+
}
|
|
174
|
+
function appendEntry(existing, marker, cmd) {
|
|
175
|
+
// A user with no crontab yet gets the line alone, with no blank line above it.
|
|
176
|
+
const kept = existing.trimEnd();
|
|
177
|
+
return {
|
|
178
|
+
kind: 'write',
|
|
179
|
+
text: `${kept === '' ? '' : `${kept}\n`}${dailyCronLine(cmd, marker)}\n`,
|
|
180
|
+
said: [' Scheduled machine-level daily runner (6:15am) via crontab'],
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* What to do with the user's crontab so it holds exactly one active line for the daily runner.
|
|
185
|
+
* Every other line is kept as it was, line endings included.
|
|
186
|
+
*/
|
|
187
|
+
function reconcileCrontab(existing, marker, cmd) {
|
|
188
|
+
const lines = existing.split('\n');
|
|
189
|
+
const isEntry = (line) => !/^\s*#/.test(line) && markerAt(line, marker) >= 0;
|
|
190
|
+
const [first, ...extra] = lines.flatMap((line, i) => (isEntry(line) ? [i] : []));
|
|
191
|
+
if (first === undefined)
|
|
192
|
+
return appendEntry(existing, marker, cmd);
|
|
193
|
+
const old = lines[first];
|
|
194
|
+
const fresh = withCommand(old, markerAt(old, marker), cmd);
|
|
195
|
+
if (fresh === null)
|
|
196
|
+
return { kind: 'unreadable', line: old.trim() };
|
|
197
|
+
if (fresh === old && extra.length === 0)
|
|
198
|
+
return { kind: 'keep' };
|
|
199
|
+
const said = [
|
|
200
|
+
...(fresh === old
|
|
201
|
+
? []
|
|
202
|
+
: [
|
|
203
|
+
' Updated the daily runner entry in your crontab (the command changed).',
|
|
204
|
+
` was: ${old.trimEnd()}`,
|
|
205
|
+
` now: ${fresh.trimEnd()}`,
|
|
206
|
+
]),
|
|
207
|
+
...extra.flatMap((i) => [
|
|
208
|
+
' Removed a duplicate daily runner entry from your crontab:',
|
|
209
|
+
` ${lines[i].trimEnd()}`,
|
|
210
|
+
]),
|
|
211
|
+
];
|
|
212
|
+
const text = lines
|
|
213
|
+
.map((line, i) => (i === first ? fresh : line))
|
|
214
|
+
.filter((_, i) => !extra.includes(i))
|
|
215
|
+
.join('\n');
|
|
216
|
+
return { kind: 'write', text: text.endsWith('\n') ? text : `${text}\n`, said };
|
|
217
|
+
}
|
|
132
218
|
function scheduleOnCrontab(taskName, cmd, run) {
|
|
133
219
|
const marker = `# hippo:${taskName}`;
|
|
134
220
|
try {
|
|
135
|
-
const
|
|
136
|
-
if (
|
|
221
|
+
const plan = reconcileCrontab(readCrontab(run), marker, cmd);
|
|
222
|
+
if (plan.kind === 'keep')
|
|
137
223
|
return; // already scheduled
|
|
224
|
+
if (plan.kind === 'unreadable') {
|
|
225
|
+
log.warn(`install: the daily runner line in your crontab is not a cron schedule hippo can read, so it was left as it ` +
|
|
226
|
+
`is: ${plan.line}`);
|
|
227
|
+
return;
|
|
138
228
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const newCrontab = `${kept === '' ? '' : `${kept}\n`}${cronLine}\n`;
|
|
143
|
-
run('crontab', ['-'], { ...SCHEDULER_CALL, input: newCrontab });
|
|
144
|
-
console.log(` Scheduled machine-level daily runner (6:15am) via crontab`);
|
|
229
|
+
run('crontab', ['-'], { ...SCHEDULER_CALL, input: plan.text });
|
|
230
|
+
for (const line of plan.said)
|
|
231
|
+
console.log(line);
|
|
145
232
|
}
|
|
146
233
|
catch (err) {
|
|
147
234
|
if (schedulerTimedOut(err))
|
|
148
235
|
warnSchedulerTimedOut('crontab');
|
|
149
236
|
log.warn(`install: crontab could not be read or written, so the daily runner is not scheduled: ${errorMessage(err)}`, errorFields(err));
|
|
150
237
|
// No permission or no crontab program: print the line for the user to add by hand.
|
|
151
|
-
const cronLine = `15 6 * * * ${cmd}`;
|
|
152
238
|
console.log(` To schedule the machine-level daily runner, add to crontab (crontab -e):`);
|
|
153
|
-
console.log(` ${
|
|
239
|
+
console.log(` ${dailyCronLine(cmd, marker)}`);
|
|
154
240
|
}
|
|
155
241
|
}
|
|
156
242
|
//# sourceMappingURL=install-steps.js.map
|
|
@@ -159,8 +159,9 @@ async function sendOrFallBack(hippoRoot, server, call) {
|
|
|
159
159
|
if (failure === 'none')
|
|
160
160
|
return call.refused(err);
|
|
161
161
|
if (failure === 'delivery-unknown') {
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
log.debug('a served write may have landed, so it is not replayed on the store', errorFields(err));
|
|
163
|
+
const reason = client.deliveryUnknownReason(err, server.url);
|
|
164
|
+
fail(`hippo: ${reason} Check with \`hippo recall\` before running this again.`);
|
|
164
165
|
}
|
|
165
166
|
failIfServerRequired('the server pidfile was stale (connection refused)');
|
|
166
167
|
log.warn('stale server pidfile detected, falling back to direct mode', errorFields(err));
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { randomBytes } from 'node:crypto';
|
|
3
3
|
import { installCrashHandlers } from '../../base/util/crash-handlers.js';
|
|
4
4
|
import { printDashboardBanner, reportListenFailure } from './dashboard-banner.js';
|
|
5
|
-
import { envBodyTimeoutMs, envPort, envTlsCert, envTlsKey } from '../../base/util/env.js';
|
|
5
|
+
import { envBodyTimeoutMs, envPort, envReadOnly, envTlsCert, envTlsKey, } from '../../base/util/env.js';
|
|
6
6
|
import * as fs from 'node:fs';
|
|
7
7
|
import * as path from 'node:path';
|
|
8
8
|
import { boolFlag, numberFlag, stringFlag, stringFlagOrExit, } from './flag-values.js';
|
|
@@ -81,6 +81,9 @@ function keyRuleLine(hippoRoot) {
|
|
|
81
81
|
`${localKeyPath(hippoRoot)} (readable by this user only); mint others with \`hippo auth create\``);
|
|
82
82
|
}
|
|
83
83
|
export async function handleServe({ hippoRoot, flags }) {
|
|
84
|
+
// The server's own runtime and worker threads write, so the switch stops it rather than leak.
|
|
85
|
+
if (envReadOnly())
|
|
86
|
+
fail('hippo serve does not run under HIPPO_READ_ONLY=1; read with hippo mcp');
|
|
84
87
|
requireInit(hippoRoot);
|
|
85
88
|
const portRaw = stringFlag(flags, 'port') ?? envPort() ?? DEFAULT_SERVER_PORT;
|
|
86
89
|
const port = Number(portRaw);
|
|
@@ -3,11 +3,18 @@
|
|
|
3
3
|
import { renderAmbientSummary } from '../../base/memory/ambient.js';
|
|
4
4
|
import { plural } from '../../base/util/format.js';
|
|
5
5
|
import { sleepEventLines } from '../render/sleep-events.js';
|
|
6
|
+
import { sleepWasRefused } from '../../api/sleep/one-sleep.js';
|
|
6
7
|
/**
|
|
7
8
|
* The lines `hippo sleep` prints for an api.sleep result; pure, so the snapshot tests read them
|
|
8
9
|
* without a console spy.
|
|
9
10
|
*/
|
|
10
11
|
export function sleepResultLines(result) {
|
|
12
|
+
if (sleepWasRefused(result)) {
|
|
13
|
+
return [
|
|
14
|
+
`A sleep is already running on this store (since ${result.alreadyRunning.since}), ` +
|
|
15
|
+
'so this one skipped consolidation.',
|
|
16
|
+
];
|
|
17
|
+
}
|
|
11
18
|
return [
|
|
12
19
|
...sleepCountLines(result),
|
|
13
20
|
...(result.dryRun ? ['\n(dry run - nothing written)'] : []),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type CommandContext } from './flag-values.js';
|
|
2
2
|
/** Runs `hippo sleep`; `--global` sleeps the global store instead of the folder's. */
|
|
3
3
|
export declare function handleSleep({ hippoRoot, tenantId, args, flags, }: CommandContext): Promise<void>;
|
|
4
|
-
/** Sleeps one store; with `--log-file` it also tees its output to that file.
|
|
5
|
-
|
|
4
|
+
/** Sleeps one store; with `--log-file` it also tees its output to that file. True when another
|
|
5
|
+
* sleep held the store's claim, so this one consolidated nothing. */
|
|
6
|
+
export declare function sleepStore({ hippoRoot, tenantId, flags }: CommandContext): Promise<boolean>;
|
|
6
7
|
//# sourceMappingURL=sleep.d.ts.map
|
|
@@ -11,6 +11,7 @@ import * as api from '../../api/index.js';
|
|
|
11
11
|
import { cliConfig, cliApiContext, cliStore, cliSyncOptions } from './api-context.js';
|
|
12
12
|
import { saveVectorGraphFile } from '../open-store.js';
|
|
13
13
|
import { sleepResultLines } from './sleep-render.js';
|
|
14
|
+
import { sleepWasRefused } from '../../api/sleep/one-sleep.js';
|
|
14
15
|
import { errorFields, errorMessage, log } from '../../base/util/log.js';
|
|
15
16
|
import { teeStdStreams } from '../../host/stream-tee.js';
|
|
16
17
|
import { boolFlag, stringFlag } from './flag-values.js';
|
|
@@ -26,7 +27,8 @@ export async function handleSleep({ hippoRoot, tenantId, args, flags, }) {
|
|
|
26
27
|
const root = boolFlag(flags, 'global') ? hippoHomeDir() : hippoRoot;
|
|
27
28
|
await sleepStore({ hippoRoot: root, tenantId, args, flags });
|
|
28
29
|
}
|
|
29
|
-
/** Sleeps one store; with `--log-file` it also tees its output to that file.
|
|
30
|
+
/** Sleeps one store; with `--log-file` it also tees its output to that file. True when another
|
|
31
|
+
* sleep held the store's claim, so this one consolidated nothing. */
|
|
30
32
|
export async function sleepStore({ hippoRoot, tenantId, flags }) {
|
|
31
33
|
// Tee stdout/stderr to a log file when --log-file is set; the SessionEnd hook uses it so the
|
|
32
34
|
// SessionStart hook can re-display the output.
|
|
@@ -43,9 +45,10 @@ export async function sleepStore({ hippoRoot, tenantId, flags }) {
|
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
try {
|
|
46
|
-
await runSleepCommand(hippoRoot, tenantId, flags);
|
|
47
|
-
if (logFile)
|
|
48
|
+
const refused = await runSleepCommand(hippoRoot, tenantId, flags);
|
|
49
|
+
if (logFile && !refused)
|
|
48
50
|
console.log('[hippo] sleep complete');
|
|
51
|
+
return refused;
|
|
49
52
|
}
|
|
50
53
|
catch (err) {
|
|
51
54
|
if (logFile)
|
|
@@ -115,6 +118,7 @@ async function learnBeforeSleep(hippoRoot, tenantId, flags) {
|
|
|
115
118
|
printAgentImport(await importForStore(hippoRoot, cliSyncOptions(tenantId, currentMachine())), '');
|
|
116
119
|
}
|
|
117
120
|
}
|
|
121
|
+
/** True when another sleep held the store's claim, so this one consolidated nothing. */
|
|
118
122
|
async function runSleepCommand(hippoRoot, tenantId, flags) {
|
|
119
123
|
requireInit(hippoRoot);
|
|
120
124
|
await learnBeforeSleep(hippoRoot, tenantId, flags);
|
|
@@ -137,11 +141,13 @@ async function runSleepCommand(hippoRoot, tenantId, flags) {
|
|
|
137
141
|
noShare: boolFlag(flags, 'no-share'),
|
|
138
142
|
});
|
|
139
143
|
renderSleepResult(result);
|
|
144
|
+
const refused = sleepWasRefused(result);
|
|
140
145
|
// A store with no `hippo serve` gets its saved vector graph from its sleeps.
|
|
141
|
-
if (!result.dryRun) {
|
|
146
|
+
if (!result.dryRun && !refused) {
|
|
142
147
|
await saveVectorGraphFile(hippoRoot, {
|
|
143
148
|
maxVectors: ctx.config.vectorGraph.maxVectors,
|
|
144
149
|
});
|
|
145
150
|
}
|
|
151
|
+
return refused;
|
|
146
152
|
}
|
|
147
153
|
//# sourceMappingURL=sleep.js.map
|
|
@@ -50,9 +50,12 @@ export async function handleShare({ hippoRoot, tenantId, args, flags, }) {
|
|
|
50
50
|
const force = boolFlag(flags, 'force');
|
|
51
51
|
const ctx = cliApiContext(hippoRoot, tenantId);
|
|
52
52
|
const result = await api.shareToGlobal(ctx, shareId, { force });
|
|
53
|
-
if (result) {
|
|
54
|
-
console.log(`Shared [${result.id}] to global store.`);
|
|
55
|
-
console.log(` Source: ${result.source}`);
|
|
53
|
+
if (result.kind === 'shared') {
|
|
54
|
+
console.log(`Shared [${result.entry.id}] to global store.`);
|
|
55
|
+
console.log(` Source: ${result.entry.source}`);
|
|
56
|
+
}
|
|
57
|
+
else if (result.kind === 'already-shared') {
|
|
58
|
+
console.log(`Already shared: the global store holds this text as [${result.existingId}].`);
|
|
56
59
|
}
|
|
57
60
|
else {
|
|
58
61
|
const entry = await memoryGet(ctx, shareId);
|
|
@@ -35,6 +35,8 @@ export interface VerbRow {
|
|
|
35
35
|
readonly destructive?: true;
|
|
36
36
|
/** Unset: --dry-run is honoured exactly when the verb declares it; `false` refuses it even so. */
|
|
37
37
|
readonly dryRun?: false | DryRunForm;
|
|
38
|
+
/** Under HIPPO_READ_ONLY=1, 'refuse' exits 1 and 'skip' exits 0 before the verb opens anything. */
|
|
39
|
+
readonly readOnly?: 'refuse' | 'skip';
|
|
38
40
|
}
|
|
39
41
|
export interface VerbSpec extends VerbRow {
|
|
40
42
|
readonly run: (ctx: CommandContext) => Promise<void>;
|