@clawos-dev/clawd 0.2.101-beta.193.178da3c → 0.2.101
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.cjs +66 -23
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -5378,6 +5378,36 @@ function ownerNamespace(ownerPrincipalId) {
|
|
|
5378
5378
|
function namespacedExtId(slug, ownerPrincipalId) {
|
|
5379
5379
|
return `${slug}-${ownerNamespace(ownerPrincipalId)}`;
|
|
5380
5380
|
}
|
|
5381
|
+
function validateSimpleSemver(v2) {
|
|
5382
|
+
if (typeof v2 !== "string") {
|
|
5383
|
+
return { ok: false, reason: "version must be a string" };
|
|
5384
|
+
}
|
|
5385
|
+
const parts = v2.split(".");
|
|
5386
|
+
if (parts.length !== 3) {
|
|
5387
|
+
return { ok: false, reason: `"${v2}" \u2014 only MAJOR.MINOR.PATCH allowed` };
|
|
5388
|
+
}
|
|
5389
|
+
for (const p2 of parts) {
|
|
5390
|
+
if (!/^\d+$/.test(p2)) {
|
|
5391
|
+
return { ok: false, reason: `"${v2}" \u2014 only numeric segments allowed` };
|
|
5392
|
+
}
|
|
5393
|
+
}
|
|
5394
|
+
return { ok: true };
|
|
5395
|
+
}
|
|
5396
|
+
function compareSimpleSemver(a, b2) {
|
|
5397
|
+
const pa = parseOrThrow(a);
|
|
5398
|
+
const pb = parseOrThrow(b2);
|
|
5399
|
+
for (let i = 0; i < 3; i++) {
|
|
5400
|
+
if (pa[i] < pb[i]) return -1;
|
|
5401
|
+
if (pa[i] > pb[i]) return 1;
|
|
5402
|
+
}
|
|
5403
|
+
return 0;
|
|
5404
|
+
}
|
|
5405
|
+
function parseOrThrow(v2) {
|
|
5406
|
+
const r = validateSimpleSemver(v2);
|
|
5407
|
+
if (!r.ok) throw new Error(r.reason);
|
|
5408
|
+
const [a, b2, c] = v2.split(".").map((p2) => parseInt(p2, 10));
|
|
5409
|
+
return [a, b2, c];
|
|
5410
|
+
}
|
|
5381
5411
|
var EXT_ID_REGEX, ExtensionStateSchema, ExtensionManifestSchema, ExtensionRecordSchema, PublishedSnapshotSchema, ChannelRefSchema, SourceRefSchema, PublishedExtensionRecordSchema, PublishCheckSchema, PublishStatusResultSchema;
|
|
5382
5412
|
var init_extension = __esm({
|
|
5383
5413
|
"../protocol/src/extension.ts"() {
|
|
@@ -40525,7 +40555,7 @@ function computePublishCheck(args) {
|
|
|
40525
40555
|
}
|
|
40526
40556
|
return { kind: "error-same-hash", version: head.version };
|
|
40527
40557
|
}
|
|
40528
|
-
const cmp =
|
|
40558
|
+
const cmp = compareSimpleSemver(localVersion, head.version);
|
|
40529
40559
|
if (cmp > 0) {
|
|
40530
40560
|
return {
|
|
40531
40561
|
kind: "ready-new-version",
|
|
@@ -40546,28 +40576,6 @@ function computePublishCheck(args) {
|
|
|
40546
40576
|
publishedVersion: head.version
|
|
40547
40577
|
};
|
|
40548
40578
|
}
|
|
40549
|
-
function compareSemver(a, b2) {
|
|
40550
|
-
const pa = parseSimpleSemver(a);
|
|
40551
|
-
const pb = parseSimpleSemver(b2);
|
|
40552
|
-
for (let i = 0; i < 3; i++) {
|
|
40553
|
-
if (pa[i] < pb[i]) return -1;
|
|
40554
|
-
if (pa[i] > pb[i]) return 1;
|
|
40555
|
-
}
|
|
40556
|
-
return 0;
|
|
40557
|
-
}
|
|
40558
|
-
function parseSimpleSemver(v2) {
|
|
40559
|
-
const parts = v2.split(".");
|
|
40560
|
-
if (parts.length !== 3) {
|
|
40561
|
-
throw new Error(`unsupported version "${v2}" \u2014 only MAJOR.MINOR.PATCH allowed`);
|
|
40562
|
-
}
|
|
40563
|
-
const nums = parts.map((p2) => {
|
|
40564
|
-
if (!/^\d+$/.test(p2)) {
|
|
40565
|
-
throw new Error(`unsupported version "${v2}" \u2014 only numeric segments allowed`);
|
|
40566
|
-
}
|
|
40567
|
-
return parseInt(p2, 10);
|
|
40568
|
-
});
|
|
40569
|
-
return nums;
|
|
40570
|
-
}
|
|
40571
40579
|
|
|
40572
40580
|
// src/extension/install-flow.ts
|
|
40573
40581
|
var import_promises5 = __toESM(require("fs/promises"), 1);
|
|
@@ -40856,6 +40864,37 @@ function pickStringField(frame, name) {
|
|
|
40856
40864
|
}
|
|
40857
40865
|
return v2;
|
|
40858
40866
|
}
|
|
40867
|
+
function pickOptionalString(frame, name) {
|
|
40868
|
+
const v2 = frame[name];
|
|
40869
|
+
if (v2 === void 0 || v2 === null) return null;
|
|
40870
|
+
if (typeof v2 !== "string") {
|
|
40871
|
+
throw new ClawdError(ERROR_CODES.INVALID_PARAM, `${name} must be string`);
|
|
40872
|
+
}
|
|
40873
|
+
return v2;
|
|
40874
|
+
}
|
|
40875
|
+
async function rewriteManifestVersion(root, extId, newVersion, previousPublishedVersion) {
|
|
40876
|
+
const v2 = validateSimpleSemver(newVersion);
|
|
40877
|
+
if (!v2.ok) {
|
|
40878
|
+
throw new ClawdError(
|
|
40879
|
+
ERROR_CODES.VALIDATION_ERROR,
|
|
40880
|
+
`INVALID_VERSION: ${v2.reason}`
|
|
40881
|
+
);
|
|
40882
|
+
}
|
|
40883
|
+
if (previousPublishedVersion !== void 0) {
|
|
40884
|
+
if (compareSimpleSemver(newVersion, previousPublishedVersion) <= 0) {
|
|
40885
|
+
throw new ClawdError(
|
|
40886
|
+
ERROR_CODES.VALIDATION_ERROR,
|
|
40887
|
+
`VERSION_NOT_BUMPED: newVersion ${newVersion} must be > published ${previousPublishedVersion}`
|
|
40888
|
+
);
|
|
40889
|
+
}
|
|
40890
|
+
}
|
|
40891
|
+
const manifestPath = import_node_path38.default.join(root, extId, "manifest.json");
|
|
40892
|
+
const manifest = await readManifest(root, extId);
|
|
40893
|
+
const next = { ...manifest, version: newVersion };
|
|
40894
|
+
const tmp = `${manifestPath}.tmp`;
|
|
40895
|
+
await import_promises7.default.writeFile(tmp, JSON.stringify(next, null, 2));
|
|
40896
|
+
await import_promises7.default.rename(tmp, manifestPath);
|
|
40897
|
+
}
|
|
40859
40898
|
async function readManifest(root, extId) {
|
|
40860
40899
|
const file = import_node_path38.default.join(root, extId, "manifest.json");
|
|
40861
40900
|
let raw;
|
|
@@ -40947,6 +40986,10 @@ function buildExtensionHandlers(deps) {
|
|
|
40947
40986
|
const publish = async (frame, _client, ctx) => {
|
|
40948
40987
|
assertOwner(ctx);
|
|
40949
40988
|
const extId = pickExtId(frame);
|
|
40989
|
+
const newVersion = pickOptionalString(frame, "newVersion");
|
|
40990
|
+
if (newVersion !== null) {
|
|
40991
|
+
await rewriteManifestVersion(deps.root, extId, newVersion, deps.publishedChannelStore.get(extId)?.version);
|
|
40992
|
+
}
|
|
40950
40993
|
const { manifest, contentHash } = await buildSnapshotMeta(extId);
|
|
40951
40994
|
const head = deps.publishedChannelStore.get(extId);
|
|
40952
40995
|
const check = computePublishCheck({
|
package/package.json
CHANGED