@memfork/cli 0.1.16 → 0.1.18
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/cli.js +3 -3
- package/dist/commands/ops.d.ts +1 -1
- package/dist/commands/ops.js +25 -11
- package/dist/commands/provision.js +28 -14
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -89,9 +89,9 @@ program
|
|
|
89
89
|
.action(wrap((opts) => cmdCommit(opts)));
|
|
90
90
|
program
|
|
91
91
|
.command("merge <from> <into>")
|
|
92
|
-
.description("
|
|
93
|
-
.
|
|
94
|
-
.option("--ttl <ms>", "TTL in milliseconds", parseInt, 86_400_000)
|
|
92
|
+
.description("merge memory from one branch into another")
|
|
93
|
+
.option("-r, --resolver <id>", "ResolverRef object ID (default: LastWriteWins, or MEMFORK_RESOLVER_ID env var)")
|
|
94
|
+
.option("--ttl <ms>", "proposal TTL in milliseconds", parseInt, 86_400_000)
|
|
95
95
|
.action(wrap((from, into, opts) => cmdMerge(from, into, opts)));
|
|
96
96
|
program
|
|
97
97
|
.command("proposals")
|
package/dist/commands/ops.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare function cmdCommit(opts: {
|
|
|
20
20
|
autoExtract?: boolean;
|
|
21
21
|
}): Promise<void>;
|
|
22
22
|
export declare function cmdMerge(from: string, into: string, opts: {
|
|
23
|
-
resolver
|
|
23
|
+
resolver?: string;
|
|
24
24
|
ttl?: number;
|
|
25
25
|
}): Promise<void>;
|
|
26
26
|
export declare function cmdProposals(): Promise<void>;
|
package/dist/commands/ops.js
CHANGED
|
@@ -126,20 +126,34 @@ export async function cmdCommit(opts) {
|
|
|
126
126
|
}
|
|
127
127
|
// ─── merge ────────────────────────────────────────────────────────────────────
|
|
128
128
|
export async function cmdMerge(from, into, opts) {
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
129
|
+
const cfg = resolveConfig();
|
|
130
|
+
const clientCfg = {
|
|
131
|
+
...toClientConfig(cfg),
|
|
132
|
+
// --resolver flag overrides MEMFORK_RESOLVER_ID env var for this call
|
|
133
|
+
...(opts.resolver ? { defaultResolverId: opts.resolver } : {}),
|
|
134
|
+
};
|
|
135
|
+
const client = await MemForksClient.connect(clientCfg);
|
|
136
|
+
const governed = !!(opts.resolver ?? process.env["MEMFORK_RESOLVER_ID"]);
|
|
137
|
+
process.stdout.write(chalk.dim(`Merging ${chalk.green(from)} → ${chalk.green(into)}`) +
|
|
138
|
+
chalk.dim(governed ? " (governed — awaiting resolver…)" : " (LWW — self-finalizing…)") +
|
|
139
|
+
" ");
|
|
140
|
+
const { digest, mergedCount, blobId, proposalId } = await client.merge(from, into);
|
|
137
141
|
console.log(chalk.green("done"));
|
|
138
142
|
console.log("");
|
|
139
|
-
console.log(chalk.dim(`
|
|
143
|
+
console.log(chalk.dim(` facts merged: ${mergedCount}`));
|
|
144
|
+
if (blobId)
|
|
145
|
+
console.log(chalk.dim(` blob: ${blobId}`));
|
|
146
|
+
if (digest)
|
|
147
|
+
console.log(chalk.dim(` tx: ${digest}`));
|
|
148
|
+
if (proposalId)
|
|
149
|
+
console.log(chalk.dim(` proposal: ${proposalId}`));
|
|
140
150
|
console.log("");
|
|
141
|
-
|
|
142
|
-
|
|
151
|
+
if (governed) {
|
|
152
|
+
console.log(chalk.dim("Resolver finalized. Use `memfork log --branch " + into + "` to verify."));
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
console.log(chalk.dim("Merge anchor written on-chain. Use `memfork log --branch " + into + "` to verify."));
|
|
156
|
+
}
|
|
143
157
|
console.log("");
|
|
144
158
|
}
|
|
145
159
|
// ─── proposals ────────────────────────────────────────────────────────────────
|
|
@@ -173,22 +173,36 @@ export async function autoProvision(opts) {
|
|
|
173
173
|
});
|
|
174
174
|
let treeId;
|
|
175
175
|
let digest;
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
"Wait 24 h and run `memfork init --quick` again, or fund the wallet manually:\n" +
|
|
185
|
-
` ${address}`);
|
|
176
|
+
// Retry once on a transient gas-coin version race: the sponsor refreshes its
|
|
177
|
+
// pool after the drip, but if initTree lands before that completes the
|
|
178
|
+
// fullnode may report a stale-object error. A short wait + retry clears it.
|
|
179
|
+
const maxAttempts = 2;
|
|
180
|
+
for (let attempt = 1;; attempt++) {
|
|
181
|
+
try {
|
|
182
|
+
({ treeId, digest } = await memClient.initTree(accountId, opts.defaultBranch ?? "main"));
|
|
183
|
+
break;
|
|
186
184
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
185
|
+
catch (e) {
|
|
186
|
+
const msg = String(e);
|
|
187
|
+
const isTransient = msg.includes("needs to be rebuilt") ||
|
|
188
|
+
msg.includes("unavailable for consumption") ||
|
|
189
|
+
msg.includes("object version");
|
|
190
|
+
if (isTransient && attempt < maxAttempts) {
|
|
191
|
+
await new Promise((r) => setTimeout(r, 1500));
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
console.log(chalk.red("failed"));
|
|
195
|
+
if (msg.includes("429") || msg.toLowerCase().includes("rate limit")) {
|
|
196
|
+
throw new Error("Sponsor rate limit hit for init_tree (1/IP/day).\n" +
|
|
197
|
+
"Wait 24 h and run `memfork init --quick` again, or fund the wallet manually:\n" +
|
|
198
|
+
` ${address}`);
|
|
199
|
+
}
|
|
200
|
+
if (msg.includes("Sponsor error: 404")) {
|
|
201
|
+
throw new Error(`Sponsor endpoint not reachable (${sponsorEndpoint}).\n` +
|
|
202
|
+
"Set MEMFORK_SPONSOR_URL to your sponsor base URL and retry.");
|
|
203
|
+
}
|
|
204
|
+
throw new Error(`MemoryTree creation failed: ${msg}`);
|
|
190
205
|
}
|
|
191
|
-
throw new Error(`MemoryTree creation failed: ${msg}`);
|
|
192
206
|
}
|
|
193
207
|
if (!treeId) {
|
|
194
208
|
throw new Error("MemoryTree creation returned no treeId — check sponsor logs.");
|