@promptframe/creation 0.3.6 → 0.3.8

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.mjs CHANGED
@@ -407,11 +407,11 @@ var require_codegen = __commonJS({
407
407
  const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
408
408
  return `${varKind} ${this.name}${rhs};` + _n2;
409
409
  }
410
- optimizeNames(names, constants6) {
410
+ optimizeNames(names, constants7) {
411
411
  if (!names[this.name.str])
412
412
  return;
413
413
  if (this.rhs)
414
- this.rhs = optimizeExpr(this.rhs, names, constants6);
414
+ this.rhs = optimizeExpr(this.rhs, names, constants7);
415
415
  return this;
416
416
  }
417
417
  get names() {
@@ -428,10 +428,10 @@ var require_codegen = __commonJS({
428
428
  render({ _n: _n2 }) {
429
429
  return `${this.lhs} = ${this.rhs};` + _n2;
430
430
  }
431
- optimizeNames(names, constants6) {
431
+ optimizeNames(names, constants7) {
432
432
  if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects)
433
433
  return;
434
- this.rhs = optimizeExpr(this.rhs, names, constants6);
434
+ this.rhs = optimizeExpr(this.rhs, names, constants7);
435
435
  return this;
436
436
  }
437
437
  get names() {
@@ -492,8 +492,8 @@ var require_codegen = __commonJS({
492
492
  optimizeNodes() {
493
493
  return `${this.code}` ? this : void 0;
494
494
  }
495
- optimizeNames(names, constants6) {
496
- this.code = optimizeExpr(this.code, names, constants6);
495
+ optimizeNames(names, constants7) {
496
+ this.code = optimizeExpr(this.code, names, constants7);
497
497
  return this;
498
498
  }
499
499
  get names() {
@@ -522,12 +522,12 @@ var require_codegen = __commonJS({
522
522
  }
523
523
  return nodes.length > 0 ? this : void 0;
524
524
  }
525
- optimizeNames(names, constants6) {
525
+ optimizeNames(names, constants7) {
526
526
  const { nodes } = this;
527
527
  let i = nodes.length;
528
528
  while (i--) {
529
529
  const n = nodes[i];
530
- if (n.optimizeNames(names, constants6))
530
+ if (n.optimizeNames(names, constants7))
531
531
  continue;
532
532
  subtractNames(names, n.names);
533
533
  nodes.splice(i, 1);
@@ -580,12 +580,12 @@ var require_codegen = __commonJS({
580
580
  return void 0;
581
581
  return this;
582
582
  }
583
- optimizeNames(names, constants6) {
583
+ optimizeNames(names, constants7) {
584
584
  var _a3;
585
- this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants6);
586
- if (!(super.optimizeNames(names, constants6) || this.else))
585
+ this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants7);
586
+ if (!(super.optimizeNames(names, constants7) || this.else))
587
587
  return;
588
- this.condition = optimizeExpr(this.condition, names, constants6);
588
+ this.condition = optimizeExpr(this.condition, names, constants7);
589
589
  return this;
590
590
  }
591
591
  get names() {
@@ -608,10 +608,10 @@ var require_codegen = __commonJS({
608
608
  render(opts) {
609
609
  return `for(${this.iteration})` + super.render(opts);
610
610
  }
611
- optimizeNames(names, constants6) {
612
- if (!super.optimizeNames(names, constants6))
611
+ optimizeNames(names, constants7) {
612
+ if (!super.optimizeNames(names, constants7))
613
613
  return;
614
- this.iteration = optimizeExpr(this.iteration, names, constants6);
614
+ this.iteration = optimizeExpr(this.iteration, names, constants7);
615
615
  return this;
616
616
  }
617
617
  get names() {
@@ -647,10 +647,10 @@ var require_codegen = __commonJS({
647
647
  render(opts) {
648
648
  return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
649
649
  }
650
- optimizeNames(names, constants6) {
651
- if (!super.optimizeNames(names, constants6))
650
+ optimizeNames(names, constants7) {
651
+ if (!super.optimizeNames(names, constants7))
652
652
  return;
653
- this.iterable = optimizeExpr(this.iterable, names, constants6);
653
+ this.iterable = optimizeExpr(this.iterable, names, constants7);
654
654
  return this;
655
655
  }
656
656
  get names() {
@@ -692,11 +692,11 @@ var require_codegen = __commonJS({
692
692
  (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
693
693
  return this;
694
694
  }
695
- optimizeNames(names, constants6) {
695
+ optimizeNames(names, constants7) {
696
696
  var _a3, _b;
697
- super.optimizeNames(names, constants6);
698
- (_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants6);
699
- (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants6);
697
+ super.optimizeNames(names, constants7);
698
+ (_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants7);
699
+ (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants7);
700
700
  return this;
701
701
  }
702
702
  get names() {
@@ -997,7 +997,7 @@ var require_codegen = __commonJS({
997
997
  function addExprNames(names, from) {
998
998
  return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
999
999
  }
1000
- function optimizeExpr(expr, names, constants6) {
1000
+ function optimizeExpr(expr, names, constants7) {
1001
1001
  if (expr instanceof code_1.Name)
1002
1002
  return replaceName(expr);
1003
1003
  if (!canOptimize(expr))
@@ -1012,14 +1012,14 @@ var require_codegen = __commonJS({
1012
1012
  return items;
1013
1013
  }, []));
1014
1014
  function replaceName(n) {
1015
- const c = constants6[n.str];
1015
+ const c = constants7[n.str];
1016
1016
  if (c === void 0 || names[n.str] !== 1)
1017
1017
  return n;
1018
1018
  delete names[n.str];
1019
1019
  return c;
1020
1020
  }
1021
1021
  function canOptimize(e) {
1022
- return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants6[c.str] !== void 0);
1022
+ return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants7[c.str] !== void 0);
1023
1023
  }
1024
1024
  }
1025
1025
  function subtractNames(names, from) {
@@ -3259,8 +3259,8 @@ var require_utils = __commonJS({
3259
3259
  }
3260
3260
  return ind;
3261
3261
  }
3262
- function removeDotSegments(path17) {
3263
- let input = path17;
3262
+ function removeDotSegments(path18) {
3263
+ let input = path18;
3264
3264
  const output = [];
3265
3265
  let nextSlash = -1;
3266
3266
  let len = 0;
@@ -3669,8 +3669,8 @@ var require_schemes = __commonJS({
3669
3669
  }
3670
3670
  if (wsComponent.resourceName) {
3671
3671
  const queryIndex = wsComponent.resourceName.indexOf("?");
3672
- const path17 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
3673
- wsComponent.path = path17 && path17 !== "/" ? path17 : void 0;
3672
+ const path18 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
3673
+ wsComponent.path = path18 && path18 !== "/" ? path18 : void 0;
3674
3674
  wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
3675
3675
  wsComponent.resourceName = void 0;
3676
3676
  }
@@ -7401,12 +7401,12 @@ import { Readable } from "node:stream";
7401
7401
  import { finished } from "node:stream/promises";
7402
7402
  var LOCAL_UPLOAD_MAX_BYTES = 2 * 1024 ** 3;
7403
7403
  var LOCAL_UPLOAD_READ_BYTES = 64 * 1024;
7404
- var fingerprint = (stat2) => ({
7405
- dev: String(stat2.dev),
7406
- ino: String(stat2.ino),
7407
- sizeBytes: Number(stat2.size),
7408
- mtimeNs: String(stat2.mtimeNs),
7409
- ctimeNs: String(stat2.ctimeNs)
7404
+ var fingerprint = (stat3) => ({
7405
+ dev: String(stat3.dev),
7406
+ ino: String(stat3.ino),
7407
+ sizeBytes: Number(stat3.size),
7408
+ mtimeNs: String(stat3.mtimeNs),
7409
+ ctimeNs: String(stat3.ctimeNs)
7410
7410
  });
7411
7411
  var equal = (left, right) => Object.keys(left).every((key) => left[key] === right[key]);
7412
7412
  var failure = (code) => new CreationClientError("creation.local_upload." + code);
@@ -7461,10 +7461,10 @@ async function openLocalUploadFile(selectedPath, { maxBytes: maxBytes2 = LOCAL_U
7461
7461
  })();
7462
7462
  try {
7463
7463
  checkSignal();
7464
- const stat2 = await handle.stat({ bigint: true });
7465
- if (!stat2.isFile()) throw failure("file_not_regular");
7466
- if (stat2.size <= 0n || stat2.size > BigInt(maxBytes2)) throw failure("file_size_limit");
7467
- original = fingerprint(stat2);
7464
+ const stat3 = await handle.stat({ bigint: true });
7465
+ if (!stat3.isFile()) throw failure("file_not_regular");
7466
+ if (stat3.size <= 0n || stat3.size > BigInt(maxBytes2)) throw failure("file_size_limit");
7467
+ original = fingerprint(stat3);
7468
7468
  await assertUnchanged();
7469
7469
  const hash6 = createHash("sha256"), buffer = Buffer.allocUnsafe(LOCAL_UPLOAD_READ_BYTES);
7470
7470
  for (let position = 0; position < original.sizeBytes; ) {
@@ -7694,8 +7694,8 @@ async function syncDirectory(root) {
7694
7694
  async function birth(pid) {
7695
7695
  if (process.platform !== "linux") return null;
7696
7696
  try {
7697
- const stat2 = await readFile2(`/proc/${pid}/stat`, "utf8"), end = stat2.lastIndexOf(")");
7698
- return { boot: (await readFile2("/proc/sys/kernel/random/boot_id", "utf8")).trim(), start: stat2.slice(end + 2).split(" ")[19] };
7697
+ const stat3 = await readFile2(`/proc/${pid}/stat`, "utf8"), end = stat3.lastIndexOf(")");
7698
+ return { boot: (await readFile2("/proc/sys/kernel/random/boot_id", "utf8")).trim(), start: stat3.slice(end + 2).split(" ")[19] };
7699
7699
  } catch (e) {
7700
7700
  if (e.code === "ENOENT") return false;
7701
7701
  fail2();
@@ -7870,6 +7870,7 @@ var fail3 = (code) => {
7870
7870
  throw new CreationClientError("creation.local_upload." + code);
7871
7871
  };
7872
7872
  var knownError = (error4) => error4 instanceof CreationClientError && /^creation\.[a-z0-9_.:-]{1,180}$/.test(error4.message) ? error4.message : "creation.local_upload.control_unconfirmed";
7873
+ var createRefusal = (code) => /^creation\.direct_object_upload\.(?:size_limit_exceeded|pending_bytes_quota_exceeded|concurrent_multipart_quota_exceeded|daily_bytes_quota_exceeded|durable_storage_quota_exceeded|capacity_unavailable|admission_facts_unavailable)$/.test(code);
7873
7874
  var typeByExtension = {
7874
7875
  ".png": ["image", "image/png"],
7875
7876
  ".jpg": ["image", "image/jpeg"],
@@ -7885,13 +7886,15 @@ var typeByExtension = {
7885
7886
  ".webm": ["video", "video/webm"],
7886
7887
  ".pdf": ["document", "application/pdf"]
7887
7888
  };
7888
- var terminal = /* @__PURE__ */ new Set(["ready", "aborted", "expired", "rejected"]);
7889
+ var terminal = /* @__PURE__ */ new Set(["ready", "aborted", "expired", "rejected", "create_rejected"]);
7889
7890
  var terminalNext = {
7890
7891
  ready: "Use this asset in the same Studio project.",
7891
7892
  derivation_failed: "This finalized upload has no remaining transfer action. Review the failure in Studio. Do not create a replacement upload automatically.",
7892
7893
  aborted: "This upload was canceled. There is no remaining transfer action. Do not create a replacement upload automatically.",
7893
7894
  expired: "This upload expired. There is no remaining transfer action. Do not create a replacement upload automatically.",
7894
- rejected: "This upload was rejected. Review the rejection in Studio. There is no remaining transfer action."
7895
+ rejected: "This upload was rejected. Review the rejection in Studio. There is no remaining transfer action.",
7896
+ create_rejected: "The platform declined this create request. Review its cause; if a new upload is still needed, explicitly use a new key. No automatic replacement or retransmission is allowed.",
7897
+ creation_unconfirmed: "Creation is unconfirmed. Observe this same original key; do not recreate, PUT, or attribute it to a local file timeout."
7895
7898
  };
7896
7899
  var safeDerivationErrorCode = (value2) => typeof value2 === "string" && value2.length <= 160 && /^[a-z][a-z0-9_]*(?:\.[a-z0-9_]+){1,8}$/u.test(value2) ? value2 : "creation.local_upload.derivation_failed";
7897
7900
  var sessionCheck = (session, state) => {
@@ -7937,6 +7940,7 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
7937
7940
  ...state.pendingPart ? { unconfirmedPart: state.pendingPart } : {},
7938
7941
  ...state.errorCode ? { errorCode: state.errorCode } : {},
7939
7942
  ...state.result ? { result: state.result } : {},
7943
+ ...state.createObservation ? { creation: { outcome: state.createDisposition ?? "unconfirmed", ...state.createObservation } } : {},
7940
7944
  automaticReplayAllowed: false,
7941
7945
  next: job ? "Read status using this same key." : terminalNext[state.phase] ?? (state.phase === "derivatives_pending" ? "Read status for the original asset validation and derivatives." : "Observe status or explicitly resume/cancel this same key. Do not create a replacement upload.")
7942
7946
  });
@@ -7962,7 +7966,28 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
7962
7966
  return body;
7963
7967
  }
7964
7968
  async function observe(state, send, persist) {
7965
- if (!state.uploadId) return { state, session: void 0 };
7969
+ if (!state.uploadId) {
7970
+ const observed = await rpc(send, { action: "inspect_create", request: state.request });
7971
+ if (observed.idempotencyKey !== state.request.idempotencyKey || typeof observed.found !== "boolean" || !Number.isFinite(Date.parse(observed.observedAt ?? ""))) fail3("session_identity_unconfirmed");
7972
+ if (!observed.found) {
7973
+ if (observed.session !== void 0) fail3("session_identity_unconfirmed");
7974
+ state.createObservation = { found: false, observedAt: observed.observedAt };
7975
+ const refused = state.createDisposition === "rejected" && createRefusal(state.createErrorCode ?? "");
7976
+ state.phase = refused ? "create_rejected" : "creation_unconfirmed";
7977
+ state.errorCode = refused ? state.createErrorCode : "creation.local_upload.create_unconfirmed_observe_original_key";
7978
+ if (persist) await persist();
7979
+ return { state, session: void 0 };
7980
+ }
7981
+ const session2 = observed.session;
7982
+ if (!session2 || typeof session2.uploadId !== "string" || typeof session2.assetId !== "string") fail3("session_identity_unconfirmed");
7983
+ sessionCheck(session2, { ...state, uploadId: session2.uploadId, assetId: session2.assetId });
7984
+ state.uploadId = session2.uploadId;
7985
+ state.assetId = session2.assetId;
7986
+ state.expiresAt = session2.expiresAt;
7987
+ state.createDisposition = "accepted";
7988
+ delete state.createErrorCode;
7989
+ delete state.createObservation;
7990
+ }
7966
7991
  const session = sessionCheck((await rpc(send, { action: "inspect", uploadId: state.uploadId })).session, state);
7967
7992
  state.expiresAt = session.expiresAt;
7968
7993
  state.lastObservedUploadState = session.state;
@@ -8127,6 +8152,10 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
8127
8152
  let file;
8128
8153
  try {
8129
8154
  state = await persistence.read(key) ?? state;
8155
+ if (state && !state.uploadId) {
8156
+ await observe(state, send, () => persistence.write(key, state));
8157
+ if (!state.uploadId || terminal.has(state.phase) || state.phase === "derivatives_pending" || state.phase === "derivation_failed") return view(state);
8158
+ }
8130
8159
  if (input.action === "cancel") {
8131
8160
  if (["ready", "derivatives_pending", "derivation_failed"].includes(state.phase))
8132
8161
  return view((await observe(state, send, () => persistence.write(key, state))).state);
@@ -8162,6 +8191,7 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
8162
8191
  return view(state);
8163
8192
  }
8164
8193
  }
8194
+ if (state) assertOriginalDeadline(state);
8165
8195
  if (typeof input.filePath !== "string" || input.filePath.length > 4096) fail3("file_selection_required");
8166
8196
  const startedAtMs = state?.startedAtMs ?? now(), deadlineAtMs = state?.deadlineAtMs ?? startedAtMs + 6e5;
8167
8197
  file = await openLocalUploadFile(input.filePath, { signal, deadlineAtMs, now });
@@ -8200,7 +8230,15 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
8200
8230
  await binding.assertCurrent();
8201
8231
  let authorization;
8202
8232
  if (!state.uploadId) {
8203
- const created = await rpc(send, { action: "create", request: state.request });
8233
+ let created;
8234
+ try {
8235
+ created = await rpc(send, { action: "create", request: state.request });
8236
+ } catch (error4) {
8237
+ const code = knownError(error4);
8238
+ state.createDisposition = createRefusal(code) ? "rejected" : "unconfirmed";
8239
+ if (createRefusal(code)) state.createErrorCode = code;
8240
+ throw error4;
8241
+ }
8204
8242
  authorization = created.authorization;
8205
8243
  const session = authorization?.session;
8206
8244
  if (!session || typeof session.uploadId !== "string" || typeof session.assetId !== "string") fail3("authorization_invalid");
@@ -8237,7 +8275,7 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
8237
8275
  return view(state, job);
8238
8276
  } catch (error4) {
8239
8277
  if (state) {
8240
- state.phase = "paused";
8278
+ state.phase = state.createDisposition === "rejected" && !state.uploadId ? "create_rejected" : "paused";
8241
8279
  state.errorCode = knownError(error4);
8242
8280
  await persistence.write(key, state);
8243
8281
  }
@@ -8276,7 +8314,7 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
8276
8314
  }
8277
8315
 
8278
8316
  // lib/version.mjs
8279
- var CLIENT_VERSION = "0.3.6";
8317
+ var CLIENT_VERSION = "0.3.8";
8280
8318
  var CLIENT_PROTOCOL = "creation-client/v1";
8281
8319
 
8282
8320
  // lib/cli.mjs
@@ -8520,10 +8558,10 @@ function mergeDefs(...defs) {
8520
8558
  function cloneDef(schema) {
8521
8559
  return mergeDefs(schema._zod.def);
8522
8560
  }
8523
- function getElementAtPath(obj, path17) {
8524
- if (!path17)
8561
+ function getElementAtPath(obj, path18) {
8562
+ if (!path18)
8525
8563
  return obj;
8526
- return path17.reduce((acc, key) => acc?.[key], obj);
8564
+ return path18.reduce((acc, key) => acc?.[key], obj);
8527
8565
  }
8528
8566
  function promiseAllObject(promisesObj) {
8529
8567
  const keys = Object.keys(promisesObj);
@@ -8863,11 +8901,11 @@ function explicitlyAborted(x, startIndex = 0) {
8863
8901
  }
8864
8902
  return false;
8865
8903
  }
8866
- function prefixIssues(path17, issues) {
8904
+ function prefixIssues(path18, issues) {
8867
8905
  return issues.map((iss) => {
8868
8906
  var _a3;
8869
8907
  (_a3 = iss).path ?? (_a3.path = []);
8870
- iss.path.unshift(path17);
8908
+ iss.path.unshift(path18);
8871
8909
  return iss;
8872
8910
  });
8873
8911
  }
@@ -9328,16 +9366,16 @@ function flattenError(error4, mapper = (issue2) => issue2.message) {
9328
9366
  }
9329
9367
  function formatError(error4, mapper = (issue2) => issue2.message) {
9330
9368
  const fieldErrors = { _errors: [] };
9331
- const processError = (error5, path17 = []) => {
9369
+ const processError = (error5, path18 = []) => {
9332
9370
  for (const issue2 of error5.issues) {
9333
9371
  if (issue2.code === "invalid_union" && issue2.errors.length) {
9334
- issue2.errors.map((issues) => processError({ issues }, [...path17, ...issue2.path]));
9372
+ issue2.errors.map((issues) => processError({ issues }, [...path18, ...issue2.path]));
9335
9373
  } else if (issue2.code === "invalid_key") {
9336
- processError({ issues: issue2.issues }, [...path17, ...issue2.path]);
9374
+ processError({ issues: issue2.issues }, [...path18, ...issue2.path]);
9337
9375
  } else if (issue2.code === "invalid_element") {
9338
- processError({ issues: issue2.issues }, [...path17, ...issue2.path]);
9376
+ processError({ issues: issue2.issues }, [...path18, ...issue2.path]);
9339
9377
  } else {
9340
- const fullpath = [...path17, ...issue2.path];
9378
+ const fullpath = [...path18, ...issue2.path];
9341
9379
  if (fullpath.length === 0) {
9342
9380
  fieldErrors._errors.push(mapper(issue2));
9343
9381
  } else {
@@ -20983,6 +21021,42 @@ async function runClaudeHostHook({ configFile: configFile2, input = process.stdi
20983
21021
  output.write(JSON.stringify(await store.hook(body)) + "\n");
20984
21022
  }
20985
21023
 
21024
+ // lib/development-pairing.mjs
21025
+ import { open as open5, stat as stat2 } from "node:fs/promises";
21026
+ import { constants as constants4 } from "node:fs";
21027
+ import path7 from "node:path";
21028
+ async function readDevelopmentPairingFile(filePath, { signal } = {}) {
21029
+ const fail8 = () => {
21030
+ throw new CreationClientError("creation.development_pairing.private_file_unavailable");
21031
+ };
21032
+ if (typeof filePath !== "string" || filePath.length > 4096 || !path7.isAbsolute(filePath)) fail8();
21033
+ let file;
21034
+ try {
21035
+ signal?.throwIfAborted();
21036
+ file = await open5(filePath, constants4.O_RDONLY | constants4.O_NOFOLLOW | constants4.O_NONBLOCK);
21037
+ const before = await file.stat();
21038
+ if (!before.isFile() || before.size < 2 || before.size > 8192 || process.platform !== "win32" && ((before.mode & 63) !== 0 || before.uid !== process.getuid())) fail8();
21039
+ const bytes2 = Buffer.alloc(before.size);
21040
+ let offset = 0;
21041
+ while (offset < bytes2.length) {
21042
+ signal?.throwIfAborted();
21043
+ const read2 = await file.read(bytes2, offset, bytes2.length - offset, offset);
21044
+ if (!read2.bytesRead) fail8();
21045
+ offset += read2.bytesRead;
21046
+ }
21047
+ const after = await file.stat(), named = await stat2(filePath);
21048
+ signal?.throwIfAborted();
21049
+ if ([after, named].some((value3) => value3.dev !== before.dev || value3.ino !== before.ino || value3.size !== before.size || value3.mtimeMs !== before.mtimeMs || value3.ctimeMs !== before.ctimeMs)) fail8();
21050
+ const value2 = JSON.parse(bytes2.toString("utf8"));
21051
+ if (!value2 || typeof value2 !== "object" || Array.isArray(value2)) fail8();
21052
+ return Object.fromEntries(["url", "connectionId", "credential", "studioOrigin", "expiresAt", "contractVersion", "lifecycle"].filter((key) => Object.hasOwn(value2, key)).map((key) => [key, value2[key]]));
21053
+ } catch {
21054
+ fail8();
21055
+ } finally {
21056
+ await file?.close();
21057
+ }
21058
+ }
21059
+
20986
21060
  // lib/host-context.mjs
20987
21061
  var digestPattern = /^sha256:[a-f0-9]{64}$/;
20988
21062
  var accesses = /* @__PURE__ */ new Set(["independent-read", "controlled", "authority"]);
@@ -21066,7 +21140,7 @@ function createHostCallBridge(client, { credentials, host = resolveHostIdentity(
21066
21140
  const schema = local?.contractVersion === LOCAL_UPLOAD_PROTOCOL ? local.inputSchema : tool.inputSchema;
21067
21141
  if (!schema || schema.type !== "object") throw new CreationClientError("creation.upgrade_required");
21068
21142
  const p2 = schema.properties;
21069
- const { controlVersion: _managed, ...properties } = p2 ?? {};
21143
+ const { controlVersion: _managed, developmentPairing: _privatePairing, ...properties } = p2 ?? {};
21070
21144
  return { ...tool, inputSchema: { ...schema, properties: { ...properties, ...host.kind === "claude-code" ? {
21071
21145
  [CLAUDE_HOST_PROOF]: { type: "string", pattern: "^[a-f0-9]{64}$", description: "\u7531\u5F53\u524D\u5BBF\u4E3Bhook\u586B\u5165\u7684\u5355\u6B21\u8EAB\u4EFD\u51ED\u8BC1\uFF1B\u8BF7\u4FDD\u7559\uFF0C\u4E0D\u81EA\u884C\u586B\u5199\u3002" }
21072
21146
  } : {} }, ...schema.required ? { required: schema.required.filter((name) => name !== "controlVersion") } : {} } };
@@ -21129,7 +21203,7 @@ function createHostCallBridge(client, { credentials, host = resolveHostIdentity(
21129
21203
  getPrompt: (params) => knowledgeRead("prompts", "getPrompt", params),
21130
21204
  close: () => localUploads?.close(),
21131
21205
  async call(raw, { signal } = {}) {
21132
- for (const field of ["threadId", "controller", "clientDigest", "token", "controlVersion"]) if (Object.hasOwn(raw.arguments ?? {}, field))
21206
+ for (const field of ["threadId", "controller", "clientDigest", "token", "controlVersion", "developmentPairing"]) if (Object.hasOwn(raw.arguments ?? {}, field))
21133
21207
  throw new CreationClientError("creation.transport_authority_managed_by_bridge");
21134
21208
  let binding = { host, arguments: raw.arguments, assertCurrent: async () => {
21135
21209
  } };
@@ -21213,6 +21287,13 @@ function createHostCallBridge(client, { credentials, host = resolveHostIdentity(
21213
21287
  }
21214
21288
  }
21215
21289
  const dispatched = key && versions.get(key);
21290
+ if (params.arguments?.tool === "studio_preview" && params.arguments.arguments?.connectionFile !== void 0) {
21291
+ if (definition._meta["promptframe.localDevelopmentPairing"] !== "creation-development-pairing/v1" || effectiveAccess !== "controlled" || params.arguments.arguments.action !== "connect_development")
21292
+ throw new CreationClientError("creation.development_pairing.unsupported");
21293
+ const pairing = await readDevelopmentPairingFile(params.arguments.arguments.connectionFile, { signal });
21294
+ await binding.assertCurrent();
21295
+ outgoing = { ...outgoing, arguments: { ...outgoing.arguments, developmentPairing: pairing } };
21296
+ }
21216
21297
  const invalidate = () => {
21217
21298
  if (host.kind === "claude-code" && binding.epoch !== hostEpoch) return;
21218
21299
  const current = key && versions.get(key);
@@ -24206,15 +24287,15 @@ var To = (s3) => {
24206
24287
  };
24207
24288
 
24208
24289
  // lib/runtime-bootstrap.mjs
24209
- import { lstat as lstat6, mkdir as mkdir4, open as open5, readFile as readFile5, readdir as readdir3, rename as rename4, rm, statfs } from "node:fs/promises";
24290
+ import { lstat as lstat6, mkdir as mkdir4, open as open6, readFile as readFile5, readdir as readdir3, rename as rename4, rm, statfs } from "node:fs/promises";
24210
24291
  import { execFile } from "node:child_process";
24211
24292
  import { promisify } from "node:util";
24212
- import path8 from "node:path";
24293
+ import path9 from "node:path";
24213
24294
 
24214
24295
  // lib/runtime-package.mjs
24215
24296
  import { lstat as lstat5, readdir as readdir2, readFile as readFile4 } from "node:fs/promises";
24216
24297
  import { createHash as createHash6 } from "node:crypto";
24217
- import path7 from "node:path";
24298
+ import path8 from "node:path";
24218
24299
  var RUNTIME_PACKAGE_ENTRIES = Object.freeze(["package.json", "README.md", "LICENSE", "bin", "dist", "lib", "skills", "docs", ".codex-plugin", ".mcp.json"]);
24219
24300
  var OPTIONAL_HOST_ENTRIES = Object.freeze([".claude-plugin", ".claude-mcp.json"]);
24220
24301
  var hash2 = (b2) => createHash6("sha256").update(b2).digest("hex");
@@ -24226,7 +24307,7 @@ async function inspectRuntimePackage(root, { entries } = {}) {
24226
24307
  entries = [...RUNTIME_PACKAGE_ENTRIES];
24227
24308
  for (const name of OPTIONAL_HOST_ENTRIES) {
24228
24309
  try {
24229
- await lstat5(path7.join(root, name));
24310
+ await lstat5(path8.join(root, name));
24230
24311
  entries.push(name);
24231
24312
  } catch (e) {
24232
24313
  if (e.code !== "ENOENT") throw e;
@@ -24238,19 +24319,19 @@ async function inspectRuntimePackage(root, { entries } = {}) {
24238
24319
  async function walk(relative) {
24239
24320
  let s3;
24240
24321
  try {
24241
- s3 = await lstat5(path7.join(root, relative));
24322
+ s3 = await lstat5(path8.join(root, relative));
24242
24323
  } catch (error4) {
24243
24324
  if (error4.code !== "ENOENT") throw error4;
24244
24325
  }
24245
24326
  if (!s3 || s3.isSymbolicLink()) invalid("package_file_invalid");
24246
24327
  if (s3.isDirectory()) {
24247
- for (const name of (await readdir2(path7.join(root, relative))).sort()) {
24328
+ for (const name of (await readdir2(path8.join(root, relative))).sort()) {
24248
24329
  if (name === "node_modules" || name === "credentials.json" || name.startsWith(".env")) invalid("package_file_invalid");
24249
- await walk(path7.join(relative, name));
24330
+ await walk(path8.join(relative, name));
24250
24331
  }
24251
24332
  } else if (s3.isFile()) {
24252
24333
  if (s3.size > 32 * 1024 * 1024) invalid("package_too_large");
24253
- const body = await readFile4(path7.join(root, relative));
24334
+ const body = await readFile4(path8.join(root, relative));
24254
24335
  bytes2 += body.length;
24255
24336
  if (files.length >= 1024 || bytes2 > 32 * 1024 * 1024) invalid("package_too_large");
24256
24337
  files.push({ path: relative, bytes: body.length, sha256: hash2(body), body });
@@ -24267,7 +24348,7 @@ async function inspectRuntimePackage(root, { entries } = {}) {
24267
24348
  files,
24268
24349
  version: pkg.version,
24269
24350
  hosts: claude ? ["codex", "claude-code"] : ["codex"],
24270
- payloadDigest: hash2(JSON.stringify(files.map(({ path: path17, bytes: bytes3, sha256 }) => ({ path: path17, bytes: bytes3, sha256 }))))
24351
+ payloadDigest: hash2(JSON.stringify(files.map(({ path: path18, bytes: bytes3, sha256 }) => ({ path: path18, bytes: bytes3, sha256 }))))
24271
24352
  };
24272
24353
  }
24273
24354
 
@@ -24302,7 +24383,7 @@ var snapshot = (payload) => ({
24302
24383
  version: payload.version,
24303
24384
  hosts: payload.hosts,
24304
24385
  payloadDigest: payload.payloadDigest,
24305
- files: payload.files.map(({ path: path17, bytes: bytes2, sha256 }) => ({ path: path17, bytes: bytes2, sha256 }))
24386
+ files: payload.files.map(({ path: path18, bytes: bytes2, sha256 }) => ({ path: path18, bytes: bytes2, sha256 }))
24306
24387
  });
24307
24388
  async function info(file) {
24308
24389
  try {
@@ -24324,7 +24405,7 @@ async function privateJSON(file) {
24324
24405
  return JSON.parse(await readFile5(file, "utf8"));
24325
24406
  }
24326
24407
  async function syncDirectory2(dir) {
24327
- const fd = await open5(dir, "r");
24408
+ const fd = await open6(dir, "r");
24328
24409
  try {
24329
24410
  await fd.sync();
24330
24411
  } finally {
@@ -24332,7 +24413,7 @@ async function syncDirectory2(dir) {
24332
24413
  }
24333
24414
  }
24334
24415
  async function exclusiveJSON(file, value2) {
24335
- const fd = await open5(file, "wx", 384);
24416
+ const fd = await open6(file, "wx", 384);
24336
24417
  try {
24337
24418
  await fd.writeFile(JSON.stringify(value2) + "\n");
24338
24419
  await fd.sync();
@@ -24422,12 +24503,12 @@ async function readRuntimeArchive(archive, metadata) {
24422
24503
  return files;
24423
24504
  }
24424
24505
  async function cacheLock(root, signal) {
24425
- const name = path8.join(root, "prepare.lock"), end = Date.now() + 5e3;
24506
+ const name = path9.join(root, "prepare.lock"), end = Date.now() + 5e3;
24426
24507
  let fd;
24427
24508
  while (!fd) {
24428
24509
  signal?.throwIfAborted();
24429
24510
  try {
24430
- fd = await open5(name, "wx", 384);
24511
+ fd = await open6(name, "wx", 384);
24431
24512
  } catch (e) {
24432
24513
  if (e.code !== "EEXIST") throw e;
24433
24514
  if (Date.now() >= end) throw error3("runtime_cache_busy");
@@ -24455,7 +24536,7 @@ async function cacheLock(root, signal) {
24455
24536
  async function verifyCached(target, metadata, hostKind) {
24456
24537
  if (!await info(target)) return null;
24457
24538
  await privateDirectory2(target);
24458
- const manifest = await privateJSON(path8.join(target, "runtime.json"));
24539
+ const manifest = await privateJSON(path9.join(target, "runtime.json"));
24459
24540
  if (!manifest || manifest.contractVersion !== "creation-verified-runtime/v1" || manifest.version !== metadata.version || manifest.integrity !== metadata.integrity)
24460
24541
  throw error3("runtime_cache_invalid");
24461
24542
  const names = (await readdir3(target)).filter((name) => name !== "runtime.json").sort();
@@ -24466,21 +24547,21 @@ async function verifyCached(target, metadata, hostKind) {
24466
24547
  return { version: payload.version, root: target, integrity: metadata.integrity, reused: true };
24467
24548
  }
24468
24549
  async function checkedVersionIndex(cacheRoot, metadata) {
24469
- const old = await privateJSON(path8.join(cacheRoot, "version-" + metadata.version + ".json"));
24550
+ const old = await privateJSON(path9.join(cacheRoot, "version-" + metadata.version + ".json"));
24470
24551
  if (old && JSON.stringify(old) !== JSON.stringify(metadata)) throw error3("runtime_registry_identity_conflict");
24471
24552
  return old;
24472
24553
  }
24473
24554
  async function prepareVerifiedRuntime(metadata, { cacheRoot, fetchImpl = fetch, signal, checkRuntime, hostKind = "codex" } = {}) {
24474
24555
  if (!["codex", "claude-code"].includes(hostKind)) throw error3("runtime_host_unsupported");
24475
- if (!path8.isAbsolute(cacheRoot ?? "")) throw error3("runtime_cache_owner_invalid");
24556
+ if (!path9.isAbsolute(cacheRoot ?? "")) throw error3("runtime_cache_owner_invalid");
24476
24557
  metadata = checkedRuntimeMetadata({ name: PACKAGE, version: metadata.version, dist: metadata }, metadata.version);
24477
24558
  await privateDirectory2(cacheRoot);
24478
24559
  await checkedVersionIndex(cacheRoot, metadata);
24479
- const target = path8.join(cacheRoot, metadata.version + "-" + hash3(metadata.integrity)), existing = await verifyCached(target, metadata, hostKind);
24560
+ const target = path9.join(cacheRoot, metadata.version + "-" + hash3(metadata.integrity)), existing = await verifyCached(target, metadata, hostKind);
24480
24561
  if (existing) return existing;
24481
24562
  const archive = await boundedGet(metadata.tarball, { fetchImpl, signal, maxBytes: MAX_ARCHIVE, timeoutMs: 15e3 });
24482
24563
  const files = await readRuntimeArchive(archive, metadata), release = await cacheLock(cacheRoot, signal);
24483
- const temporary = path8.join(cacheRoot, ".partial-" + randomBytes4(12).toString("hex"));
24564
+ const temporary = path9.join(cacheRoot, ".partial-" + randomBytes4(12).toString("hex"));
24484
24565
  try {
24485
24566
  const index = await checkedVersionIndex(cacheRoot, metadata);
24486
24567
  const found = await verifyCached(target, metadata, hostKind);
@@ -24490,9 +24571,9 @@ async function prepareVerifiedRuntime(metadata, { cacheRoot, fetchImpl = fetch,
24490
24571
  await mkdir4(temporary, { mode: 448 });
24491
24572
  for (const file of files) {
24492
24573
  signal?.throwIfAborted();
24493
- const dest = path8.join(temporary, ...file.path.split("/"));
24494
- await mkdir4(path8.dirname(dest), { recursive: true, mode: 448 });
24495
- const fd = await open5(dest, "wx", 384);
24574
+ const dest = path9.join(temporary, ...file.path.split("/"));
24575
+ await mkdir4(path9.dirname(dest), { recursive: true, mode: 448 });
24576
+ const fd = await open6(dest, "wx", 384);
24496
24577
  try {
24497
24578
  await fd.writeFile(file.body);
24498
24579
  await fd.sync();
@@ -24511,16 +24592,16 @@ async function prepareVerifiedRuntime(metadata, { cacheRoot, fetchImpl = fetch,
24511
24592
  else {
24512
24593
  const result = await execute(
24513
24594
  process.execPath,
24514
- [path8.join(temporary, "bin/promptframe-creation.mjs"), "--version"],
24595
+ [path9.join(temporary, "bin/promptframe-creation.mjs"), "--version"],
24515
24596
  { timeout: 5e3, maxBuffer: 65536, windowsHide: true, signal, env: {
24516
24597
  ...process.env,
24517
- PROMPTFRAME_CREATION_CONFIG: path8.join(temporary, "no-credentials.json")
24598
+ PROMPTFRAME_CREATION_CONFIG: path9.join(temporary, "no-credentials.json")
24518
24599
  } }
24519
24600
  );
24520
24601
  if (result.stdout.trim() !== metadata.version || result.stderr.trim()) throw error3("runtime_package_version_invalid");
24521
24602
  }
24522
24603
  signal?.throwIfAborted();
24523
- await exclusiveJSON(path8.join(temporary, "runtime.json"), {
24604
+ await exclusiveJSON(path9.join(temporary, "runtime.json"), {
24524
24605
  contractVersion: "creation-verified-runtime/v1",
24525
24606
  version: metadata.version,
24526
24607
  integrity: metadata.integrity,
@@ -24528,7 +24609,7 @@ async function prepareVerifiedRuntime(metadata, { cacheRoot, fetchImpl = fetch,
24528
24609
  });
24529
24610
  await syncDirectory2(temporary);
24530
24611
  if (!index) {
24531
- await exclusiveJSON(path8.join(cacheRoot, "version-" + metadata.version + ".json"), metadata);
24612
+ await exclusiveJSON(path9.join(cacheRoot, "version-" + metadata.version + ".json"), metadata);
24532
24613
  await syncDirectory2(cacheRoot);
24533
24614
  }
24534
24615
  await rename4(temporary, target);
@@ -24570,7 +24651,7 @@ async function selectBridgeRuntime({ policy, currentVersion, lockedVersion, reso
24570
24651
  const raw = await boundedGet(REGISTRY + "/@promptframe%2fcreation/" + target, { fetchImpl, signal, maxBytes: 256 * 1024, timeoutMs: 5e3 });
24571
24652
  metadata = checkedRuntimeMetadata(JSON.parse(raw), target);
24572
24653
  } catch (e) {
24573
- const prior = await privateJSON(path8.join(cacheRoot, "version-" + target + ".json"));
24654
+ const prior = await privateJSON(path9.join(cacheRoot, "version-" + target + ".json"));
24574
24655
  if (!prior) throw e;
24575
24656
  metadata = checkedRuntimeMetadata({ name: PACKAGE, version: target, dist: prior }, target);
24576
24657
  metadataSource = "previously-verified-cache";
@@ -24596,16 +24677,16 @@ async function selectBridgeRuntime({ policy, currentVersion, lockedVersion, reso
24596
24677
 
24597
24678
  // lib/runtime-launch.mjs
24598
24679
  import { spawn } from "node:child_process";
24599
- import path9 from "node:path";
24680
+ import path10 from "node:path";
24600
24681
  async function launchSelectedBridge(selection, { host, configFile: configFile2, spawnImpl = spawn, env = process.env } = {}) {
24601
- if (!path9.isAbsolute(selection.root ?? "") || !path9.isAbsolute(configFile2 ?? "") || !["codex", "claude-code"].includes(host?.kind))
24682
+ if (!path10.isAbsolute(selection.root ?? "") || !path10.isAbsolute(configFile2 ?? "") || !["codex", "claude-code"].includes(host?.kind))
24602
24683
  throw new CreationClientError("creation.runtime_launch_invalid");
24603
24684
  let child;
24604
24685
  try {
24605
24686
  child = spawnImpl(
24606
24687
  process.execPath,
24607
24688
  [
24608
- path9.join(selection.root, "bin/promptframe-creation.mjs"),
24689
+ path10.join(selection.root, "bin/promptframe-creation.mjs"),
24609
24690
  "bridge",
24610
24691
  "--config",
24611
24692
  configFile2,
@@ -24648,9 +24729,9 @@ async function launchSelectedBridge(selection, { host, configFile: configFile2,
24648
24729
  import { execFile as execFile2 } from "node:child_process";
24649
24730
  import { promisify as promisify2 } from "node:util";
24650
24731
  import { createHash as createHash8, randomBytes as randomBytes5 } from "node:crypto";
24651
- import { lstat as lstat7, mkdir as mkdir5, readdir as readdir4, readFile as readFile6, writeFile as writeFile2, rename as rename5, rm as rm2, open as open6 } from "node:fs/promises";
24732
+ import { lstat as lstat7, mkdir as mkdir5, readdir as readdir4, readFile as readFile6, writeFile as writeFile2, rename as rename5, rm as rm2, open as open7 } from "node:fs/promises";
24652
24733
  import { homedir as homedir4 } from "node:os";
24653
- import path10 from "node:path";
24734
+ import path11 from "node:path";
24654
24735
 
24655
24736
  // node_modules/smol-toml/dist/error.js
24656
24737
  function getLineColFromPtr(string4, ptr) {
@@ -25451,8 +25532,8 @@ function validProfile(profile) {
25451
25532
  }
25452
25533
  function profileCredentialsPath(profile = "default", env = process.env) {
25453
25534
  validProfile(profile);
25454
- return profile === "default" ? credentialsPath(env) : path10.resolve(
25455
- env.XDG_CONFIG_HOME ?? path10.join(homedir4(), ".config"),
25535
+ return profile === "default" ? credentialsPath(env) : path11.resolve(
25536
+ env.XDG_CONFIG_HOME ?? path11.join(homedir4(), ".config"),
25456
25537
  "promptframe-creation",
25457
25538
  "profiles",
25458
25539
  profile,
@@ -25484,20 +25565,20 @@ async function packageJSON(file) {
25484
25565
  return json(file);
25485
25566
  }
25486
25567
  function sameTransport(actual, expected) {
25487
- return actual?.type === "stdio" && actual.command === expected.command && typeof actual.cwd === "string" && path10.resolve(actual.cwd) === path10.resolve(expected.cwd) && JSON.stringify(actual.args) === JSON.stringify(expected.args) && JSON.stringify(actual.env_vars ?? []) === JSON.stringify(expected.env_vars ?? []) && !Object.keys(actual.env ?? {}).length;
25568
+ return actual?.type === "stdio" && actual.command === expected.command && typeof actual.cwd === "string" && path11.resolve(actual.cwd) === path11.resolve(expected.cwd) && JSON.stringify(actual.args) === JSON.stringify(expected.args) && JSON.stringify(actual.env_vars ?? []) === JSON.stringify(expected.env_vars ?? []) && !Object.keys(actual.env ?? {}).length;
25488
25569
  }
25489
25570
  async function managedTransport(installed, versions, serverName, profile, configFile2) {
25490
25571
  if (!installed) return null;
25491
25572
  const root = installed.source?.path;
25492
- if (installed.source?.source !== "local" || typeof root !== "string" || !/^\d+\.\d+\.\d+$/.test(installed.version ?? "") || root !== path10.join(versions, installed.version)) fail4("existing_registration_requires_review");
25493
- const directory2 = await info2(root), definition = await info2(path10.join(root, ".mcp.json"));
25573
+ if (installed.source?.source !== "local" || typeof root !== "string" || !/^\d+\.\d+\.\d+$/.test(installed.version ?? "") || root !== path11.join(versions, installed.version)) fail4("existing_registration_requires_review");
25574
+ const directory2 = await info2(root), definition = await info2(path11.join(root, ".mcp.json"));
25494
25575
  if (!directory2?.isDirectory() || directory2.isSymbolicLink() || !definition?.isFile() || definition.isSymbolicLink()) fail4("installed_files_invalid");
25495
- const ready = await privateRead2(path10.join(root, "installation.json"));
25576
+ const ready = await privateRead2(path11.join(root, "installation.json"));
25496
25577
  if (!ready || ready.profile !== profile || ready.configFile !== configFile2 || ready.version !== installed.version) fail4("existing_registration_requires_review");
25497
- const bytes2 = await readFile6(path10.join(root, ".mcp.json")), entry = ready.files?.find((x) => x.path === ".mcp.json");
25578
+ const bytes2 = await readFile6(path11.join(root, ".mcp.json")), entry = ready.files?.find((x) => x.path === ".mcp.json");
25498
25579
  if (!entry || entry.bytes !== bytes2.length || entry.sha256 !== hash4(bytes2)) fail4("installed_files_invalid");
25499
25580
  const mcp = JSON.parse(bytes2).mcpServers?.[serverName];
25500
- if (!mcp || typeof mcp.command !== "string" || !mcp.command || mcp.cwd !== root || JSON.stringify(mcp.args) !== JSON.stringify([path10.join(root, "bin/promptframe-creation.mjs"), "bridge", "--config", configFile2])) fail4("existing_registration_requires_review");
25581
+ if (!mcp || typeof mcp.command !== "string" || !mcp.command || mcp.cwd !== root || JSON.stringify(mcp.args) !== JSON.stringify([path11.join(root, "bin/promptframe-creation.mjs"), "bridge", "--config", configFile2])) fail4("existing_registration_requires_review");
25501
25582
  return mcp;
25502
25583
  }
25503
25584
  async function officialNpmInstallation(installed, servers, env, profile, configFile2) {
@@ -25505,12 +25586,12 @@ async function officialNpmInstallation(installed, servers, env, profile, configF
25505
25586
  const candidates = installed.filter((p3) => p3.enabled === true && p3.name === "promptframe-creation" && p3.pluginId === "promptframe-creation@" + p3.marketplaceName && /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,140}$/.test(p3.marketplaceName ?? "") && /^\d+\.\d+\.\d+$/.test(p3.version ?? "") && p3.source?.source === "npm" && p3.source.package === "@promptframe/creation" && p3.source.version === p3.version && ["https://registry.npmjs.org", "https://registry.npmjs.org/"].includes(p3.source.registry));
25506
25587
  if (candidates.length > 1) fail4("existing_registration_requires_review");
25507
25588
  if (!candidates.length) return null;
25508
- const p2 = candidates[0], root = path10.join(path10.resolve(env.CODEX_HOME ?? path10.join(homedir4(), ".codex")), "plugins/cache", p2.marketplaceName, p2.name, p2.version);
25589
+ const p2 = candidates[0], root = path11.join(path11.resolve(env.CODEX_HOME ?? path11.join(homedir4(), ".codex")), "plugins/cache", p2.marketplaceName, p2.name, p2.version);
25509
25590
  const directory2 = await info2(root);
25510
25591
  if (!directory2?.isDirectory() || directory2.isSymbolicLink()) fail4("installed_files_invalid");
25511
- const pkg = await packageJSON(path10.join(root, "package.json")), manifest = await packageJSON(path10.join(root, ".codex-plugin/plugin.json"));
25592
+ const pkg = await packageJSON(path11.join(root, "package.json")), manifest = await packageJSON(path11.join(root, ".codex-plugin/plugin.json"));
25512
25593
  if (pkg.name !== "@promptframe/creation" || pkg.version !== p2.version || manifest.name !== p2.name || manifest.version !== p2.version) fail4("installed_files_invalid");
25513
- const definition = (await packageJSON(path10.join(root, ".mcp.json"))).mcpServers?.promptframe;
25594
+ const definition = (await packageJSON(path11.join(root, ".mcp.json"))).mcpServers?.promptframe;
25514
25595
  if (!definition || definition.command !== "node" || definition.cwd !== "." || JSON.stringify(definition.args) !== JSON.stringify(["bin/promptframe-creation.mjs", "bridge"]) || JSON.stringify(definition.env_vars) !== JSON.stringify(["PROMPTFRAME_CREATION_CONFIG", "XDG_CONFIG_HOME"])) fail4("legacy_mcp_entry_requires_review");
25515
25596
  if (servers.length !== 1 || servers[0].enabled !== true || !sameTransport(servers[0].transport, { ...definition, cwd: root }) || JSON.stringify(servers[0].transport.env_vars) !== JSON.stringify(definition.env_vars)) fail4("legacy_mcp_entry_requires_review");
25516
25597
  return {
@@ -25529,7 +25610,7 @@ async function officialNpmInstallation(installed, servers, env, profile, configF
25529
25610
  async function atomicJSON(file, value2) {
25530
25611
  const temp = file + "." + randomBytes5(12).toString("hex") + ".tmp";
25531
25612
  try {
25532
- const out = await open6(temp, "wx", 384);
25613
+ const out = await open7(temp, "wx", 384);
25533
25614
  try {
25534
25615
  await out.writeFile(JSON.stringify(value2, null, 2) + "\n");
25535
25616
  await out.sync();
@@ -25537,7 +25618,7 @@ async function atomicJSON(file, value2) {
25537
25618
  await out.close();
25538
25619
  }
25539
25620
  await rename5(temp, file);
25540
- const directory2 = await open6(path10.dirname(file), "r");
25621
+ const directory2 = await open7(path11.dirname(file), "r");
25541
25622
  try {
25542
25623
  await directory2.sync();
25543
25624
  } finally {
@@ -25548,7 +25629,7 @@ async function atomicJSON(file, value2) {
25548
25629
  }
25549
25630
  }
25550
25631
  async function acquire(root, signal) {
25551
- const lock = path10.join(root, "install.lock");
25632
+ const lock = path11.join(root, "install.lock");
25552
25633
  const end = Date.now() + 3e4;
25553
25634
  let owned = false;
25554
25635
  while (!owned) {
@@ -25563,7 +25644,7 @@ async function acquire(root, signal) {
25563
25644
  }
25564
25645
  }
25565
25646
  try {
25566
- await writeFile2(path10.join(lock, "owner.json"), JSON.stringify({ pid: process.pid, startedAt: (/* @__PURE__ */ new Date()).toISOString() }), { flag: "wx", mode: 384 });
25647
+ await writeFile2(path11.join(lock, "owner.json"), JSON.stringify({ pid: process.pid, startedAt: (/* @__PURE__ */ new Date()).toISOString() }), { flag: "wx", mode: 384 });
25567
25648
  } catch (e) {
25568
25649
  await rm2(lock, { recursive: true, force: true });
25569
25650
  throw e;
@@ -25604,7 +25685,7 @@ async function codexJSON(runCodex, args2) {
25604
25685
  }
25605
25686
  }
25606
25687
  async function relatedPlugins(runCodex, pluginName, env) {
25607
- const related = /* @__PURE__ */ new Set(), registered = /* @__PURE__ */ new Set(), pinnedMarketplaces = /* @__PURE__ */ new Map(), config2 = path10.join(path10.resolve(env.CODEX_HOME ?? path10.join(homedir4(), ".codex")), "config.toml");
25688
+ const related = /* @__PURE__ */ new Set(), registered = /* @__PURE__ */ new Set(), pinnedMarketplaces = /* @__PURE__ */ new Map(), config2 = path11.join(path11.resolve(env.CODEX_HOME ?? path11.join(homedir4(), ".codex")), "config.toml");
25608
25689
  try {
25609
25690
  const s3 = await info2(config2);
25610
25691
  if (s3) {
@@ -25624,10 +25705,10 @@ async function relatedPlugins(runCodex, pluginName, env) {
25624
25705
  const state = await codexJSON(runCodex, ["plugin", "marketplace", "list", "--json"]);
25625
25706
  if (!Array.isArray(state?.marketplaces) || state.marketplaces.length > 128) fail4("local_catalog_unconfirmed");
25626
25707
  for (const market of state.marketplaces) {
25627
- if (typeof market.name !== "string" || !/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,140}$/.test(market.name) || typeof market.root !== "string" || !path10.isAbsolute(market.root)) fail4("local_catalog_unconfirmed");
25708
+ if (typeof market.name !== "string" || !/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,140}$/.test(market.name) || typeof market.root !== "string" || !path11.isAbsolute(market.root)) fail4("local_catalog_unconfirmed");
25628
25709
  let catalog;
25629
25710
  try {
25630
- catalog = await packageJSON(path10.join(market.root, ".agents/plugins/marketplace.json"));
25711
+ catalog = await packageJSON(path11.join(market.root, ".agents/plugins/marketplace.json"));
25631
25712
  } catch {
25632
25713
  fail4("local_catalog_unconfirmed", { phase: "local_check", commandKind: "marketplace_read", localRegistrationState: "unknown", action: "restore_local_marketplace_catalog" });
25633
25714
  }
@@ -25658,7 +25739,7 @@ async function relatedPlugins(runCodex, pluginName, env) {
25658
25739
  }
25659
25740
  async function runNode(root, version3) {
25660
25741
  try {
25661
- const result = await execute2(process.execPath, [path10.join(root, "bin/promptframe-creation.mjs"), "--version"], { encoding: "utf8", timeout: 1e4, maxBuffer: 8192 });
25742
+ const result = await execute2(process.execPath, [path11.join(root, "bin/promptframe-creation.mjs"), "--version"], { encoding: "utf8", timeout: 1e4, maxBuffer: 8192 });
25662
25743
  if (result.stdout.trim() !== version3) fail4("runtime_version_mismatch");
25663
25744
  } catch (e) {
25664
25745
  if (e instanceof CreationClientError) throw e;
@@ -25672,7 +25753,7 @@ async function checkInstalledRuntime(root, version3, command2, { env = process.e
25672
25753
  if (!major || Number(major[1]) < 20) throw Error("unsupported_node");
25673
25754
  const result = await execute2(
25674
25755
  command2,
25675
- [path10.join(root, "bin/promptframe-creation.mjs"), "--version"],
25756
+ [path11.join(root, "bin/promptframe-creation.mjs"), "--version"],
25676
25757
  { env, encoding: "utf8", timeout: 1e4, maxBuffer: 8192 }
25677
25758
  );
25678
25759
  if (result.stdout.trim() !== version3) throw Error("wrong_version");
@@ -25709,20 +25790,20 @@ async function installForUser({
25709
25790
  const versionOutput = await runCodex(["--version"]);
25710
25791
  const match = versionOutput.match(/codex-cli (\d+)\.(\d+)\.(\d+)/);
25711
25792
  if (!match || Number(match[1]) === 0 && Number(match[2]) < 160) fail4("codex_0160_required");
25712
- const payload = await inspectRuntimePackage(path10.resolve(sourceRoot));
25713
- const root = path10.resolve(env.XDG_DATA_HOME ?? path10.join(homedir4(), ".local/share"), "promptframe-creation", profile);
25793
+ const payload = await inspectRuntimePackage(path11.resolve(sourceRoot));
25794
+ const root = path11.resolve(env.XDG_DATA_HOME ?? path11.join(homedir4(), ".local/share"), "promptframe-creation", profile);
25714
25795
  await privateDirectory3(root);
25715
25796
  const release = await acquire(root, signal);
25716
- const versions = path10.join(root, "versions"), currentFile = path10.join(root, "current.json"), pendingFile = path10.join(root, "registration-pending.json");
25717
- const marketplaceFile = path10.join(root, ".agents/plugins/marketplace.json");
25797
+ const versions = path11.join(root, "versions"), currentFile = path11.join(root, "current.json"), pendingFile = path11.join(root, "registration-pending.json");
25798
+ const marketplaceFile = path11.join(root, ".agents/plugins/marketplace.json");
25718
25799
  const pluginName = "promptframe-creation" + (profile === "default" ? "" : "-" + profile), marketplace = "promptframe-creation-user" + (profile === "default" ? "" : "-" + profile);
25719
25800
  const pluginId = pluginName + "@" + marketplace;
25720
- const versionRoot = path10.join(versions, payload.version), temporary = path10.join(versions, ".partial-" + randomBytes5(12).toString("hex"));
25801
+ const versionRoot = path11.join(versions, payload.version), temporary = path11.join(versions, ".partial-" + randomBytes5(12).toString("hex"));
25721
25802
  let previous, registrationStarted = false, newFiles = 0;
25722
25803
  try {
25723
25804
  signal?.throwIfAborted();
25724
25805
  await privateDirectory3(versions);
25725
- await privateDirectory3(path10.dirname(marketplaceFile));
25806
+ await privateDirectory3(path11.dirname(marketplaceFile));
25726
25807
  previous = await privateRead2(currentFile);
25727
25808
  if (previous && (previous.profile !== profile || previous.pluginId !== pluginId || previous.configFile !== configFile2)) fail4("profile_binding_conflict");
25728
25809
  const state = { installed: await relatedPlugins(runCodex, pluginName, env) };
@@ -25733,12 +25814,12 @@ async function installForUser({
25733
25814
  const servers = legacy.filter((x) => x.name === serverName);
25734
25815
  const pending = await privateRead2(pendingFile);
25735
25816
  if (pending) {
25736
- if (pending.profile !== profile || pending.pluginId !== pluginId || pending.configFile !== configFile2 || pending.versionRoot !== path10.join(versions, pending.version)) fail4("profile_binding_conflict");
25817
+ if (pending.profile !== profile || pending.pluginId !== pluginId || pending.configFile !== configFile2 || pending.versionRoot !== path11.join(versions, pending.version)) fail4("profile_binding_conflict");
25737
25818
  if (installed?.version !== pending.version || installed.enabled !== true || installed.source?.path !== pending.versionRoot)
25738
25819
  fail4("registration_unconfirmed_keep_existing", { phase: "registration_observation", localRegistrationState: "unknown", action: "inspect_same_registration_no_second_add" });
25739
25820
  const transport2 = await managedTransport(installed, versions, serverName, profile, configFile2);
25740
25821
  if (servers.length !== 1 || servers[0].enabled === false || !sameTransport(servers[0].transport, transport2)) fail4("registration_unconfirmed_keep_existing");
25741
- const ready = await privateRead2(path10.join(pending.versionRoot, "installation.json"));
25822
+ const ready = await privateRead2(path11.join(pending.versionRoot, "installation.json"));
25742
25823
  if (ready?.payloadDigest !== pending.payloadDigest) fail4("installed_files_invalid");
25743
25824
  previous = pending;
25744
25825
  await atomicJSON(currentFile, pending);
@@ -25793,11 +25874,11 @@ async function installForUser({
25793
25874
  const target = await info2(versionRoot);
25794
25875
  if (target) {
25795
25876
  if (!target.isDirectory() || target.isSymbolicLink()) fail4("version_content_conflict");
25796
- const ready = await privateRead2(path10.join(versionRoot, "installation.json"));
25877
+ const ready = await privateRead2(path11.join(versionRoot, "installation.json"));
25797
25878
  if (!ready || ready.payloadDigest !== payload.payloadDigest || ready.profile !== profile || ready.configFile !== configFile2) fail4("version_content_conflict");
25798
25879
  for (const f2 of ready.files) {
25799
25880
  if (!payload.files.some((p2) => p2.path === f2.path)) fail4("installed_files_invalid");
25800
- const file = path10.join(versionRoot, f2.path), s3 = await info2(file);
25881
+ const file = path11.join(versionRoot, f2.path), s3 = await info2(file);
25801
25882
  if (!s3?.isFile() || s3.isSymbolicLink() || s3.size !== f2.bytes || hash4(await readFile6(file)) !== f2.sha256) fail4("installed_files_invalid");
25802
25883
  }
25803
25884
  if (ready.files.length !== payload.files.length) fail4("installed_files_invalid");
@@ -25805,31 +25886,31 @@ async function installForUser({
25805
25886
  await mkdir5(temporary, { mode: 448 });
25806
25887
  for (const f2 of payload.files) {
25807
25888
  signal?.throwIfAborted();
25808
- await mkdir5(path10.dirname(path10.join(temporary, f2.path)), { recursive: true, mode: 448 });
25809
- await writeFile2(path10.join(temporary, f2.path), f2.body, { flag: "wx", mode: 384 });
25889
+ await mkdir5(path11.dirname(path11.join(temporary, f2.path)), { recursive: true, mode: 448 });
25890
+ await writeFile2(path11.join(temporary, f2.path), f2.body, { flag: "wx", mode: 384 });
25810
25891
  }
25811
- const manifest = await json(path10.join(temporary, ".codex-plugin/plugin.json"));
25892
+ const manifest = await json(path11.join(temporary, ".codex-plugin/plugin.json"));
25812
25893
  manifest.name = pluginName;
25813
- await writeFile2(path10.join(temporary, ".codex-plugin/plugin.json"), JSON.stringify(manifest, null, 2) + "\n");
25894
+ await writeFile2(path11.join(temporary, ".codex-plugin/plugin.json"), JSON.stringify(manifest, null, 2) + "\n");
25814
25895
  const mcp = { mcpServers: { ["promptframe" + (profile === "default" ? "" : "-" + profile)]: {
25815
25896
  command: process.execPath,
25816
- args: [path10.join(versionRoot, "bin/promptframe-creation.mjs"), "bridge", "--config", configFile2],
25897
+ args: [path11.join(versionRoot, "bin/promptframe-creation.mjs"), "bridge", "--config", configFile2],
25817
25898
  cwd: versionRoot
25818
25899
  } } };
25819
- await writeFile2(path10.join(temporary, ".mcp.json"), JSON.stringify(mcp, null, 2) + "\n");
25900
+ await writeFile2(path11.join(temporary, ".mcp.json"), JSON.stringify(mcp, null, 2) + "\n");
25820
25901
  await checkRuntime(temporary, payload.version);
25821
25902
  const files = [];
25822
25903
  for (const f2 of payload.files) {
25823
- const body = await readFile6(path10.join(temporary, f2.path));
25904
+ const body = await readFile6(path11.join(temporary, f2.path));
25824
25905
  files.push({ path: f2.path, bytes: body.length, sha256: hash4(body) });
25825
25906
  }
25826
- await atomicJSON(path10.join(temporary, "installation.json"), { version: payload.version, profile, configFile: configFile2, payloadDigest: payload.payloadDigest, files });
25907
+ await atomicJSON(path11.join(temporary, "installation.json"), { version: payload.version, profile, configFile: configFile2, payloadDigest: payload.payloadDigest, files });
25827
25908
  signal?.throwIfAborted();
25828
25909
  await rename5(temporary, versionRoot);
25829
25910
  newFiles = payload.files.length;
25830
25911
  }
25831
25912
  if (newFiles === 0) {
25832
- const launch = (await json(path10.join(versionRoot, ".mcp.json"))).mcpServers?.[serverName];
25913
+ const launch = (await json(path11.join(versionRoot, ".mcp.json"))).mcpServers?.[serverName];
25833
25914
  await verifyInstalledRuntime(versionRoot, payload.version, launch.command, { env });
25834
25915
  }
25835
25916
  const complete = { version: payload.version, profile, configFile: configFile2, pluginId, versionRoot, payloadDigest: payload.payloadDigest };
@@ -25888,9 +25969,9 @@ async function installForUser({
25888
25969
 
25889
25970
  // lib/claude-installation.mjs
25890
25971
  import { createHash as createHash11, randomBytes as randomBytes7 } from "node:crypto";
25891
- import { mkdir as mkdir7, open as open9, readFile as readFile9, rename as rename7, rm as rm5 } from "node:fs/promises";
25972
+ import { mkdir as mkdir7, open as open10, readFile as readFile9, rename as rename7, rm as rm5 } from "node:fs/promises";
25892
25973
  import { homedir as homedir9 } from "node:os";
25893
- import path15 from "node:path";
25974
+ import path16 from "node:path";
25894
25975
 
25895
25976
  // lib/claude-hook-definition.mjs
25896
25977
  function claudeHostHooks({ pluginName = "promptframe-creation", serverName, configFile: configFile2, nodeCommand = "node", runtimeRoot = "${CLAUDE_PLUGIN_ROOT}" } = {}) {
@@ -25914,9 +25995,9 @@ function claudeHostHooks({ pluginName = "promptframe-creation", serverName, conf
25914
25995
  import { execFile as execFile3 } from "node:child_process";
25915
25996
  import { promisify as promisify3 } from "node:util";
25916
25997
  import { access, lstat as lstat8, readdir as readdir5 } from "node:fs/promises";
25917
- import { constants as constants4 } from "node:fs";
25998
+ import { constants as constants5 } from "node:fs";
25918
25999
  import { homedir as homedir5 } from "node:os";
25919
- import path11 from "node:path";
26000
+ import path12 from "node:path";
25920
26001
  var execute3 = promisify3(execFile3);
25921
26002
  var ClaudeCommandError = class extends CreationClientError {
25922
26003
  constructor(code, details) {
@@ -25928,20 +26009,20 @@ var claudeErrorDetails = (error4) => error4 instanceof ClaudeCommandError ? erro
25928
26009
  async function resolveClaudeCommand({ env = process.env, homeDirectory = homedir5(), executable } = {}) {
25929
26010
  const selected = executable ?? env.PROMPTFRAME_CLAUDE_BIN;
25930
26011
  if (selected) {
25931
- if (!path11.isAbsolute(selected)) throw new CreationClientError("installation.claude_executable_invalid");
25932
- await access(selected, constants4.X_OK);
26012
+ if (!path12.isAbsolute(selected)) throw new CreationClientError("installation.claude_executable_invalid");
26013
+ await access(selected, constants5.X_OK);
25933
26014
  return selected;
25934
26015
  }
25935
- for (const directory2 of (env.PATH ?? "").split(path11.delimiter).filter(path11.isAbsolute)) {
25936
- const file = path11.join(directory2, process.platform === "win32" ? "claude.exe" : "claude");
26016
+ for (const directory2 of (env.PATH ?? "").split(path12.delimiter).filter(path12.isAbsolute)) {
26017
+ const file = path12.join(directory2, process.platform === "win32" ? "claude.exe" : "claude");
25937
26018
  try {
25938
- await access(file, constants4.X_OK);
26019
+ await access(file, constants5.X_OK);
25939
26020
  return file;
25940
26021
  } catch (e) {
25941
26022
  if (!["ENOENT", "EACCES", "ENOTDIR"].includes(e.code)) throw e;
25942
26023
  }
25943
26024
  }
25944
- const root = path11.join(homeDirectory, ".claude/remote/ccd-cli");
26025
+ const root = path12.join(homeDirectory, ".claude/remote/ccd-cli");
25945
26026
  let entries;
25946
26027
  try {
25947
26028
  entries = await readdir5(root);
@@ -25954,9 +26035,9 @@ async function resolveClaudeCommand({ env = process.env, homeDirectory = homedir
25954
26035
  for (const name of entries) {
25955
26036
  const match = name.match(/^(\d+)\.(\d+)\.(\d+)-[a-f0-9]{6,40}$/);
25956
26037
  if (!match) continue;
25957
- const file = path11.join(root, name), s3 = await lstat8(file);
26038
+ const file = path12.join(root, name), s3 = await lstat8(file);
25958
26039
  if (s3.isFile() && !s3.isSymbolicLink() && s3.uid === process.getuid?.()) {
25959
- await access(file, constants4.X_OK);
26040
+ await access(file, constants5.X_OK);
25960
26041
  candidates.push({ file, version: match.slice(1).map(Number) });
25961
26042
  }
25962
26043
  }
@@ -25994,12 +26075,12 @@ function createClaudeRunner({ env = process.env, executable, signal, resolve = r
25994
26075
  // lib/claude-local-state.mjs
25995
26076
  import { readFile as readFile7, lstat as lstat9 } from "node:fs/promises";
25996
26077
  import { homedir as homedir6 } from "node:os";
25997
- import path12 from "node:path";
26078
+ import path13 from "node:path";
25998
26079
  function claudeConfigRoot(env = process.env) {
25999
- return path12.resolve(env.CLAUDE_CONFIG_DIR ?? path12.join(homedir6(), ".claude"));
26080
+ return path13.resolve(env.CLAUDE_CONFIG_DIR ?? path13.join(homedir6(), ".claude"));
26000
26081
  }
26001
26082
  async function readClaudeUserServer(serverName, env = process.env) {
26002
- const file = env.CLAUDE_CONFIG_DIR ? path12.join(claudeConfigRoot(env), ".claude.json") : path12.join(homedir6(), ".claude.json");
26083
+ const file = env.CLAUDE_CONFIG_DIR ? path13.join(claudeConfigRoot(env), ".claude.json") : path13.join(homedir6(), ".claude.json");
26003
26084
  let info5;
26004
26085
  try {
26005
26086
  info5 = await lstat9(file);
@@ -26023,15 +26104,15 @@ async function readClaudeUserServer(serverName, env = process.env) {
26023
26104
 
26024
26105
  // lib/claude-mcp-installation.mjs
26025
26106
  import { createHash as createHash10, randomBytes as randomBytes6 } from "node:crypto";
26026
- import { mkdir as mkdir6, open as open8, readFile as readFile8, readdir as readdir6, rename as rename6, rm as rm4, lstat as lstat10 } from "node:fs/promises";
26107
+ import { mkdir as mkdir6, open as open9, readFile as readFile8, readdir as readdir6, rename as rename6, rm as rm4, lstat as lstat10 } from "node:fs/promises";
26027
26108
  import { homedir as homedir8 } from "node:os";
26028
- import path14 from "node:path";
26109
+ import path15 from "node:path";
26029
26110
 
26030
26111
  // lib/claude-hook-registration.mjs
26031
26112
  import { createHash as createHash9 } from "node:crypto";
26032
- import { open as open7, rm as rm3 } from "node:fs/promises";
26033
- import { constants as constants5 } from "node:fs";
26034
- import path13 from "node:path";
26113
+ import { open as open8, rm as rm3 } from "node:fs/promises";
26114
+ import { constants as constants6 } from "node:fs";
26115
+ import path14 from "node:path";
26035
26116
  import { homedir as homedir7 } from "node:os";
26036
26117
  var { privateDirectory: privateDirectory4, privateRead: privateRead3, atomicJSON: atomicJSON2, acquire: acquire2 } = installationFiles;
26037
26118
  var digest4 = (value2) => createHash9("sha256").update(JSON.stringify(value2)).digest("hex");
@@ -26041,7 +26122,7 @@ var fail5 = () => {
26041
26122
  async function settings(file) {
26042
26123
  let handle;
26043
26124
  try {
26044
- handle = await open7(file, constants5.O_RDONLY | constants5.O_NOFOLLOW);
26125
+ handle = await open8(file, constants6.O_RDONLY | constants6.O_NOFOLLOW);
26045
26126
  const info5 = await handle.stat();
26046
26127
  if (!info5.isFile() || info5.uid !== process.getuid?.() || info5.size > 512 * 1024) fail5();
26047
26128
  const value2 = JSON.parse(await handle.readFile("utf8"));
@@ -26056,20 +26137,20 @@ async function settings(file) {
26056
26137
  }
26057
26138
  var contains = (value2, entries) => Object.entries(entries).every(([event, wanted]) => Array.isArray(value2.hooks?.[event]) && wanted.every((entry) => value2.hooks[event].filter((actual) => digest4(actual) === digest4(entry)).length === 1));
26058
26139
  async function verifyClaudeFallbackHooks(record2, env) {
26059
- if (!record2?.settingsFile || record2.settingsFile !== path13.join(claudeConfigRoot(env), "settings.json") || !record2.entries) fail5();
26140
+ if (!record2?.settingsFile || record2.settingsFile !== path14.join(claudeConfigRoot(env), "settings.json") || !record2.entries) fail5();
26060
26141
  if (!contains(await settings(record2.settingsFile), record2.entries)) fail5();
26061
26142
  return true;
26062
26143
  }
26063
26144
  async function registerClaudeFallbackHooks({ record: record2, root, env, nodeCommand, signal }) {
26064
- const directory2 = claudeConfigRoot(env), file = path13.join(directory2, "settings.json");
26065
- const guard = path13.resolve(
26066
- env.XDG_DATA_HOME ?? path13.join(homedir7(), ".local/share"),
26145
+ const directory2 = claudeConfigRoot(env), file = path14.join(directory2, "settings.json");
26146
+ const guard = path14.resolve(
26147
+ env.XDG_DATA_HOME ?? path14.join(homedir7(), ".local/share"),
26067
26148
  "promptframe-creation",
26068
26149
  "claude-hook-writer-" + digest4(directory2)
26069
26150
  );
26070
26151
  await privateDirectory4(guard);
26071
26152
  const release = await acquire2(guard, signal);
26072
- const markerFile = path13.join(root, "hooks-current.json"), pendingFile = path13.join(root, "hooks-pending.json");
26153
+ const markerFile = path14.join(root, "hooks-current.json"), pendingFile = path14.join(root, "hooks-pending.json");
26073
26154
  try {
26074
26155
  await privateDirectory4(directory2);
26075
26156
  const entries = claudeHostHooks({ serverName: record2.serverName, configFile: record2.configFile, nodeCommand, runtimeRoot: record2.versionRoot });
@@ -26137,7 +26218,7 @@ function same(a, b2, depth = 0) {
26137
26218
  async function atomicText(file, body) {
26138
26219
  const temporary = file + "." + randomBytes6(12).toString("hex") + ".tmp";
26139
26220
  try {
26140
- const fd = await open8(temporary, "wx", 384);
26221
+ const fd = await open9(temporary, "wx", 384);
26141
26222
  try {
26142
26223
  await fd.writeFile(body);
26143
26224
  await fd.sync();
@@ -26145,7 +26226,7 @@ async function atomicText(file, body) {
26145
26226
  await fd.close();
26146
26227
  }
26147
26228
  await rename6(temporary, file);
26148
- const dir = await open8(path14.dirname(file), "r");
26229
+ const dir = await open9(path15.dirname(file), "r");
26149
26230
  try {
26150
26231
  await dir.sync();
26151
26232
  } finally {
@@ -26158,15 +26239,15 @@ async function atomicText(file, body) {
26158
26239
  async function verifyVersion(root, record2) {
26159
26240
  const directory2 = await info3(root);
26160
26241
  if (!directory2?.isDirectory() || directory2.isSymbolicLink() || directory2.uid !== process.getuid?.() || directory2.mode & 63) fail6("claude_installed_files_invalid");
26161
- const marker = await privateRead4(path14.join(root, "installation.json")), payload = await inspectRuntimePackage(root);
26162
- if (!marker || marker.host !== "claude-code" || marker.mode !== "mcp-and-skills" || marker.profile !== record2.profile || marker.configFile !== record2.configFile || marker.version !== record2.version || marker.payloadDigest !== record2.payloadDigest || payload.payloadDigest !== marker.payloadDigest || !path14.isAbsolute(marker.nodeCommand ?? "")) fail6("claude_installed_files_invalid");
26242
+ const marker = await privateRead4(path15.join(root, "installation.json")), payload = await inspectRuntimePackage(root);
26243
+ if (!marker || marker.host !== "claude-code" || marker.mode !== "mcp-and-skills" || marker.profile !== record2.profile || marker.configFile !== record2.configFile || marker.version !== record2.version || marker.payloadDigest !== record2.payloadDigest || payload.payloadDigest !== marker.payloadDigest || !path15.isAbsolute(marker.nodeCommand ?? "")) fail6("claude_installed_files_invalid");
26163
26244
  return marker;
26164
26245
  }
26165
26246
  function mcpDefinition(record2, nodeCommand) {
26166
26247
  return {
26167
26248
  type: "stdio",
26168
26249
  command: nodeCommand,
26169
- args: [path14.join(record2.versionRoot, "bin/promptframe-creation.mjs"), "bridge", "--config", record2.configFile, "--host", "claude-code"]
26250
+ args: [path15.join(record2.versionRoot, "bin/promptframe-creation.mjs"), "bridge", "--config", record2.configFile, "--host", "claude-code"]
26170
26251
  };
26171
26252
  }
26172
26253
  function skillBody(payload, sourceName, name) {
@@ -26182,7 +26263,7 @@ async function observedSkill(plan, record2, { allowBefore = false } = {}) {
26182
26263
  if (!directory2.isDirectory() || directory2.isSymbolicLink() || directory2.uid !== process.getuid?.() || directory2.mode & 63) fail6("claude_skill_requires_review");
26183
26264
  const names = await readdir6(plan.root);
26184
26265
  if (names.some((n) => !["SKILL.md", "promptframe-installation.json"].includes(n))) fail6("claude_skill_requires_review");
26185
- const marker = await privateRead4(path14.join(plan.root, "promptframe-installation.json")), file = path14.join(plan.root, "SKILL.md"), s3 = await info3(file);
26266
+ const marker = await privateRead4(path15.join(plan.root, "promptframe-installation.json")), file = path15.join(plan.root, "SKILL.md"), s3 = await info3(file);
26186
26267
  if (!marker || marker.host !== "claude-code" || marker.profile !== record2.profile || marker.configFile !== record2.configFile || marker.name !== plan.name)
26187
26268
  fail6("claude_skill_requires_review");
26188
26269
  if (!s3 && allowBefore && plan.beforeSHA === null && marker.sha256 === null) return false;
@@ -26204,13 +26285,13 @@ async function installClaudeMcpFallback({
26204
26285
  nodeCommand,
26205
26286
  writeSkill = atomicText
26206
26287
  }) {
26207
- const payload = await inspectRuntimePackage(path14.resolve(sourceRoot)), suffix = profile === "default" ? "" : "-" + profile, serverName = "promptframe" + suffix, root = path14.resolve(env.XDG_DATA_HOME ?? path14.join(homedir8(), ".local/share"), "promptframe-creation", profile, "claude-code-mcp");
26288
+ const payload = await inspectRuntimePackage(path15.resolve(sourceRoot)), suffix = profile === "default" ? "" : "-" + profile, serverName = "promptframe" + suffix, root = path15.resolve(env.XDG_DATA_HOME ?? path15.join(homedir8(), ".local/share"), "promptframe-creation", profile, "claude-code-mcp");
26208
26289
  await privateDirectory5(root);
26209
- const release = await acquire3(root, signal), versions = path14.join(root, "versions"), currentFile = path14.join(root, "current.json"), pendingFile = path14.join(root, "registration-pending.json"), versionRoot = path14.join(versions, payload.version), temporary = path14.join(versions, ".partial-" + randomBytes6(12).toString("hex"));
26290
+ const release = await acquire3(root, signal), versions = path15.join(root, "versions"), currentFile = path15.join(root, "current.json"), pendingFile = path15.join(root, "registration-pending.json"), versionRoot = path15.join(versions, payload.version), temporary = path15.join(versions, ".partial-" + randomBytes6(12).toString("hex"));
26210
26291
  let writeStarted = false, newFiles = 0;
26211
26292
  const complete = { host: "claude-code", mode: "mcp-and-skills", profile, configFile: configFile2, serverName, version: payload.version, versionRoot, payloadDigest: payload.payloadDigest };
26212
26293
  const checkBinding = (record2) => {
26213
- if (record2 && (record2.host !== "claude-code" || record2.mode !== "mcp-and-skills" || record2.profile !== profile || record2.configFile !== configFile2 || record2.serverName !== serverName || !/^\d+\.\d+\.\d+$/.test(record2.version ?? "") || record2.versionRoot !== path14.join(versions, record2.version))) fail6("profile_binding_conflict");
26294
+ if (record2 && (record2.host !== "claude-code" || record2.mode !== "mcp-and-skills" || record2.profile !== profile || record2.configFile !== configFile2 || record2.serverName !== serverName || !/^\d+\.\d+\.\d+$/.test(record2.version ?? "") || record2.versionRoot !== path15.join(versions, record2.version))) fail6("profile_binding_conflict");
26214
26295
  };
26215
26296
  try {
26216
26297
  await privateDirectory5(versions);
@@ -26227,7 +26308,7 @@ async function installClaudeMcpFallback({
26227
26308
  if (!Array.isArray(record2.skills) || record2.skills.length !== 2) fail6("claude_skill_requires_review");
26228
26309
  for (const [i, skill] of record2.skills.entries()) {
26229
26310
  const name = ["creation-setup", "video-creation"][i] + suffix;
26230
- if (skill.name !== name || skill.root !== path14.join(claudeConfigRoot(env), "skills", name) || !/^[a-f0-9]{64}$/.test(skill.sha256 ?? ""))
26311
+ if (skill.name !== name || skill.root !== path15.join(claudeConfigRoot(env), "skills", name) || !/^[a-f0-9]{64}$/.test(skill.sha256 ?? ""))
26231
26312
  fail6("claude_skill_requires_review");
26232
26313
  if (!await observedSkill(skill, record2)) return false;
26233
26314
  }
@@ -26270,9 +26351,9 @@ async function installClaudeMcpFallback({
26270
26351
  await mkdir6(temporary, { mode: 448 });
26271
26352
  for (const file of payload.files) {
26272
26353
  signal?.throwIfAborted();
26273
- const dest = path14.join(temporary, file.path);
26274
- await mkdir6(path14.dirname(dest), { recursive: true, mode: 448 });
26275
- const fd = await open8(dest, "wx", 384);
26354
+ const dest = path15.join(temporary, file.path);
26355
+ await mkdir6(path15.dirname(dest), { recursive: true, mode: 448 });
26356
+ const fd = await open9(dest, "wx", 384);
26276
26357
  try {
26277
26358
  await fd.writeFile(file.body);
26278
26359
  await fd.sync();
@@ -26281,7 +26362,7 @@ async function installClaudeMcpFallback({
26281
26362
  }
26282
26363
  }
26283
26364
  await checkRuntime(temporary, payload.version);
26284
- await atomicJSON3(path14.join(temporary, "installation.json"), { ...complete, nodeCommand });
26365
+ await atomicJSON3(path15.join(temporary, "installation.json"), { ...complete, nodeCommand });
26285
26366
  signal?.throwIfAborted();
26286
26367
  await rename6(temporary, versionRoot);
26287
26368
  newFiles = payload.files.length;
@@ -26289,13 +26370,13 @@ async function installClaudeMcpFallback({
26289
26370
  const ready = await verifyVersion(versionRoot, complete);
26290
26371
  complete.server = mcpDefinition(complete, ready.nodeCommand);
26291
26372
  if (newFiles === 0) await verifyInstalledRuntime(versionRoot, payload.version, ready.nodeCommand, { env });
26292
- const skillRoot = path14.join(claudeConfigRoot(env), "skills");
26373
+ const skillRoot = path15.join(claudeConfigRoot(env), "skills");
26293
26374
  await mkdir6(skillRoot, { recursive: true, mode: 448 });
26294
26375
  const parent = await lstat10(skillRoot);
26295
26376
  if (!parent.isDirectory() || parent.isSymbolicLink() || parent.uid !== process.getuid?.()) fail6("claude_skill_requires_review");
26296
26377
  const plans = [];
26297
26378
  for (const sourceName of ["creation-setup", "video-creation"]) {
26298
- const name = sourceName + suffix, body = skillBody(payload, sourceName, name), skill = { name, root: path14.join(skillRoot, name), sha256: hash5(body) };
26379
+ const name = sourceName + suffix, body = skillBody(payload, sourceName, name), skill = { name, root: path15.join(skillRoot, name), sha256: hash5(body) };
26299
26380
  if (pending) {
26300
26381
  const old = pending.skills?.find((s3) => s3.name === name);
26301
26382
  if (!old || old.root !== skill.root || old.sha256 !== skill.sha256) fail6("registration_unconfirmed_keep_existing");
@@ -26304,7 +26385,7 @@ async function installClaudeMcpFallback({
26304
26385
  const existing = await info3(skill.root);
26305
26386
  let beforeSHA = null;
26306
26387
  if (existing) {
26307
- const marker = await privateRead4(path14.join(skill.root, "promptframe-installation.json"));
26388
+ const marker = await privateRead4(path15.join(skill.root, "promptframe-installation.json"));
26308
26389
  if (!marker || marker.profile !== profile || marker.configFile !== configFile2 || marker.name !== name) fail6("claude_skill_requires_review");
26309
26390
  const old = { ...skill, sha256: marker.sha256 };
26310
26391
  if (!await observedSkill(old, complete)) fail6("claude_skill_requires_review");
@@ -26325,10 +26406,10 @@ async function installClaudeMcpFallback({
26325
26406
  } else {
26326
26407
  if (plan.beforeSHA !== null) fail6("claude_skill_requires_review");
26327
26408
  await claimSkillDirectory(plan.root);
26328
- await atomicJSON3(path14.join(plan.root, "promptframe-installation.json"), { host: "claude-code", profile, configFile: configFile2, name: plan.name, sha256: null });
26409
+ await atomicJSON3(path15.join(plan.root, "promptframe-installation.json"), { host: "claude-code", profile, configFile: configFile2, name: plan.name, sha256: null });
26329
26410
  }
26330
- await writeSkill(path14.join(plan.root, "SKILL.md"), plan.body);
26331
- await atomicJSON3(path14.join(plan.root, "promptframe-installation.json"), { host: "claude-code", profile, configFile: configFile2, name: plan.name, sha256: plan.sha256 });
26411
+ await writeSkill(path15.join(plan.root, "SKILL.md"), plan.body);
26412
+ await atomicJSON3(path15.join(plan.root, "promptframe-installation.json"), { host: "claude-code", profile, configFile: configFile2, name: plan.name, sha256: plan.sha256 });
26332
26413
  }
26333
26414
  signal?.throwIfAborted();
26334
26415
  if (compareVersions2(payload.version, "0.3.1") >= 0) complete.hostHooks = await registerClaudeFallbackHooks({ record: complete, root, env, nodeCommand: ready.nodeCommand, signal });
@@ -26397,7 +26478,7 @@ async function registrations(run, pluginName, marketplace, root) {
26397
26478
  if (plugins.some((p2) => !p2 || typeof p2.id !== "string" || !p2.id || p2.id.length > 256 || typeof p2.scope !== "string" || typeof p2.version !== "string" || typeof p2.enabled !== "boolean" || typeof p2.installPath !== "string") || markets.some((p2) => !p2 || typeof p2.name !== "string" || !p2.name || typeof p2.source !== "string"))
26398
26479
  fail7("claude_local_registration_unconfirmed");
26399
26480
  const related = plugins.filter((p2) => typeof p2?.id === "string" && p2.id.startsWith(pluginName + "@"));
26400
- if (related.length > 1 || related.some((p2) => p2.id !== pluginName + "@" + marketplace || p2.scope !== "user" || typeof p2.enabled !== "boolean" || !/^\d+\.\d+\.\d+$/.test(p2.version ?? "") || !path15.isAbsolute(p2.installPath ?? "") || p2.readFromFolder !== void 0 && (!path15.isAbsolute(p2.readFromFolder) || !/^\d+\.\d+\.\d+$/.test(p2.folderVersion ?? ""))))
26481
+ if (related.length > 1 || related.some((p2) => p2.id !== pluginName + "@" + marketplace || p2.scope !== "user" || typeof p2.enabled !== "boolean" || !/^\d+\.\d+\.\d+$/.test(p2.version ?? "") || !path16.isAbsolute(p2.installPath ?? "") || p2.readFromFolder !== void 0 && (!path16.isAbsolute(p2.readFromFolder) || !/^\d+\.\d+\.\d+$/.test(p2.folderVersion ?? ""))))
26401
26482
  fail7("claude_existing_registration_requires_review");
26402
26483
  const found = markets.filter((p2) => p2?.name === marketplace);
26403
26484
  if (found.length > 1 || found.some((p2) => p2.source !== "directory" || p2.path !== root || p2.installLocation !== root))
@@ -26417,19 +26498,19 @@ async function verifyVersion2(root, { version: version3, profile, configFile: co
26417
26498
  const directory2 = await info4(root);
26418
26499
  if (!directory2?.isDirectory() || directory2.isSymbolicLink() || directory2.uid !== process.getuid?.() || directory2.mode & 63)
26419
26500
  fail7("claude_installed_files_invalid");
26420
- const ready = await privateRead5(path15.join(root, "installation.json"));
26501
+ const ready = await privateRead5(path16.join(root, "installation.json"));
26421
26502
  if (!ready || ready.host !== "claude-code" || ready.version !== version3 || ready.profile !== profile || ready.configFile !== configFile2 || ready.payloadDigest !== payloadDigest || !Array.isArray(ready.files) || ready.files.length > 1024) fail7("claude_installed_files_invalid");
26422
26503
  const actual = await inspectRuntimePackage(root);
26423
- if (actual.version !== version3 || JSON.stringify(actual.files.map(({ path: path17, bytes: bytes2, sha256 }) => ({ path: path17, bytes: bytes2, sha256 }))) !== JSON.stringify(ready.files))
26504
+ if (actual.version !== version3 || JSON.stringify(actual.files.map(({ path: path18, bytes: bytes2, sha256 }) => ({ path: path18, bytes: bytes2, sha256 }))) !== JSON.stringify(ready.files))
26424
26505
  fail7("claude_installed_files_invalid");
26425
- const manifest = JSON.parse(await readFile9(path15.join(root, ".claude-plugin/plugin.json"), "utf8"));
26506
+ const manifest = JSON.parse(await readFile9(path16.join(root, ".claude-plugin/plugin.json"), "utf8"));
26426
26507
  if (manifest.name !== pluginName || manifest.version !== version3 || manifest.skills !== "./skills/" || manifest.mcpServers !== "./.claude-mcp.json")
26427
26508
  fail7("claude_installed_files_invalid");
26428
26509
  let runtimeCommand;
26429
26510
  for (const file of [".mcp.json", ".claude-mcp.json"]) {
26430
- const mcp = JSON.parse(await readFile9(path15.join(root, file), "utf8"));
26511
+ const mcp = JSON.parse(await readFile9(path16.join(root, file), "utf8"));
26431
26512
  const command2 = mcp.mcpServers?.[serverName]?.command;
26432
- if (!path15.isAbsolute(command2 ?? "") || runtimeCommand !== void 0 && command2 !== runtimeCommand || JSON.stringify(mcp) !== JSON.stringify(transport(serverName, configFile2, command2))) fail7("claude_installed_files_invalid");
26513
+ if (!path16.isAbsolute(command2 ?? "") || runtimeCommand !== void 0 && command2 !== runtimeCommand || JSON.stringify(mcp) !== JSON.stringify(transport(serverName, configFile2, command2))) fail7("claude_installed_files_invalid");
26433
26514
  runtimeCommand = command2;
26434
26515
  }
26435
26516
  if (compareVersions3(version3, "0.3.1") >= 0 && JSON.stringify(manifest.hooks) !== JSON.stringify(claudeHostHooks({ pluginName, configFile: configFile2, nodeCommand: runtimeCommand })))
@@ -26439,7 +26520,7 @@ async function verifyVersion2(root, { version: version3, profile, configFile: co
26439
26520
  async function installForClaudeUser(options = {}) {
26440
26521
  const profile = options.profile ?? "default", env = options.env ?? process.env;
26441
26522
  validProfile2(profile);
26442
- const modeRoot = path15.resolve(env.XDG_DATA_HOME ?? path15.join(homedir9(), ".local/share"), "promptframe-creation", profile, "claude-code-mode");
26523
+ const modeRoot = path16.resolve(env.XDG_DATA_HOME ?? path16.join(homedir9(), ".local/share"), "promptframe-creation", profile, "claude-code-mode");
26443
26524
  await privateDirectory6(modeRoot);
26444
26525
  const release = await acquire4(modeRoot, options.signal);
26445
26526
  try {
@@ -26461,37 +26542,37 @@ async function installClaudeUserLocked({
26461
26542
  nodeCommand = process.execPath
26462
26543
  } = {}) {
26463
26544
  validProfile2(profile);
26464
- if (!path15.isAbsolute(nodeCommand)) fail7("runtime_command_invalid");
26545
+ if (!path16.isAbsolute(nodeCommand)) fail7("runtime_command_invalid");
26465
26546
  const hostVersion = (await runClaude(["--version"])).trim().match(/^(\d+\.\d+\.\d+) \(Claude Code\)$/);
26466
26547
  if (!hostVersion || compareVersions3(hostVersion[1], "2.1.295") < 0) fail7("claude_21295_required");
26467
26548
  const help = await runClaude(["--help"]);
26468
26549
  if (typeof help !== "string" || Buffer.byteLength(help) > 128 * 1024) fail7("claude_capabilities_unconfirmed");
26469
26550
  const hasPlugin = /^\s+plugin(?:\|plugins)?\s/m.test(help), hasMcp = /^\s+mcp\s/m.test(help);
26470
- const base = path15.resolve(env.XDG_DATA_HOME ?? path15.join(homedir9(), ".local/share"), "promptframe-creation", profile), fallbackRoot = path15.join(base, "claude-code-mcp"), pluginRoot = path15.join(base, "claude-code");
26471
- const pluginPending = await info4(path15.join(pluginRoot, "registration-pending.json")), pluginCurrent = await info4(path15.join(pluginRoot, "current.json")), fallbackState = await info4(path15.join(fallbackRoot, "current.json")) || await info4(path15.join(fallbackRoot, "registration-pending.json"));
26551
+ const base = path16.resolve(env.XDG_DATA_HOME ?? path16.join(homedir9(), ".local/share"), "promptframe-creation", profile), fallbackRoot = path16.join(base, "claude-code-mcp"), pluginRoot = path16.join(base, "claude-code");
26552
+ const pluginPending = await info4(path16.join(pluginRoot, "registration-pending.json")), pluginCurrent = await info4(path16.join(pluginRoot, "current.json")), fallbackState = await info4(path16.join(fallbackRoot, "current.json")) || await info4(path16.join(fallbackRoot, "registration-pending.json"));
26472
26553
  if ((!hasPlugin || fallbackState) && (pluginPending || pluginCurrent)) fail7("registration_unconfirmed_keep_existing");
26473
26554
  if (!hasPlugin || fallbackState) {
26474
26555
  if (!hasMcp) fail7("claude_capabilities_unconfirmed");
26475
26556
  return installClaudeMcpFallback({ sourceRoot, profile, env, configFile: configFile2, signal, runClaude, checkRuntime, verifyInstalledRuntime, nodeCommand });
26476
26557
  }
26477
- const payload = await inspectRuntimePackage(path15.resolve(sourceRoot));
26558
+ const payload = await inspectRuntimePackage(path16.resolve(sourceRoot));
26478
26559
  if (!payload.files.some((f2) => f2.path === ".claude-plugin/plugin.json") || !payload.files.some((f2) => f2.path === ".claude-mcp.json"))
26479
26560
  fail7("claude_package_incomplete");
26480
- const root = path15.resolve(env.XDG_DATA_HOME ?? path15.join(homedir9(), ".local/share"), "promptframe-creation", profile, "claude-code");
26561
+ const root = path16.resolve(env.XDG_DATA_HOME ?? path16.join(homedir9(), ".local/share"), "promptframe-creation", profile, "claude-code");
26481
26562
  await privateDirectory6(root);
26482
26563
  const release = await acquire4(root, signal);
26483
26564
  const suffix = profile === "default" ? "" : "-" + profile, pluginName = "promptframe-creation" + suffix, marketplace = "promptframe-creation-user" + suffix, pluginId = pluginName + "@" + marketplace, serverName = "promptframe" + suffix;
26484
- const versions = path15.join(root, "versions"), currentFile = path15.join(root, "current.json"), pendingFile = path15.join(root, "registration-pending.json"), catalogFile = path15.join(root, ".claude-plugin/marketplace.json"), versionRoot = path15.join(versions, payload.version), temporary = path15.join(versions, ".partial-" + randomBytes7(12).toString("hex"));
26565
+ const versions = path16.join(root, "versions"), currentFile = path16.join(root, "current.json"), pendingFile = path16.join(root, "registration-pending.json"), catalogFile = path16.join(root, ".claude-plugin/marketplace.json"), versionRoot = path16.join(versions, payload.version), temporary = path16.join(versions, ".partial-" + randomBytes7(12).toString("hex"));
26485
26566
  let registrationStarted = false, newFiles = 0;
26486
26567
  try {
26487
26568
  signal?.throwIfAborted();
26488
26569
  await privateDirectory6(versions);
26489
- await privateDirectory6(path15.dirname(catalogFile));
26570
+ await privateDirectory6(path16.dirname(catalogFile));
26490
26571
  await legacyUserMcp(env, serverName);
26491
26572
  let previous = await privateRead5(currentFile), pending = await privateRead5(pendingFile), state = await registrations(runClaude, pluginName, marketplace, root);
26492
26573
  const binding = { profile, configFile: configFile2, pluginId, pluginName, serverName, host: "claude-code" };
26493
26574
  const checkBinding = (record2) => {
26494
- if (record2 && (record2.profile !== profile || record2.configFile !== configFile2 || record2.pluginId !== pluginId || record2.host !== "claude-code" || !/^\d+\.\d+\.\d+$/.test(record2.version ?? "") || record2.versionRoot !== path15.join(versions, record2.version))) fail7("profile_binding_conflict");
26575
+ if (record2 && (record2.profile !== profile || record2.configFile !== configFile2 || record2.pluginId !== pluginId || record2.host !== "claude-code" || !/^\d+\.\d+\.\d+$/.test(record2.version ?? "") || record2.versionRoot !== path16.join(versions, record2.version))) fail7("profile_binding_conflict");
26495
26576
  };
26496
26577
  checkBinding(previous);
26497
26578
  checkBinding(pending);
@@ -26538,9 +26619,9 @@ async function installClaudeUserLocked({
26538
26619
  await mkdir7(temporary, { mode: 448 });
26539
26620
  for (const file of payload.files) {
26540
26621
  signal?.throwIfAborted();
26541
- const dest = path15.join(temporary, file.path);
26542
- await mkdir7(path15.dirname(dest), { recursive: true, mode: 448 });
26543
- const fd = await open9(dest, "wx", 384);
26622
+ const dest = path16.join(temporary, file.path);
26623
+ await mkdir7(path16.dirname(dest), { recursive: true, mode: 448 });
26624
+ const fd = await open10(dest, "wx", 384);
26544
26625
  try {
26545
26626
  await fd.writeFile(file.body);
26546
26627
  await fd.sync();
@@ -26548,18 +26629,18 @@ async function installClaudeUserLocked({
26548
26629
  await fd.close();
26549
26630
  }
26550
26631
  }
26551
- const manifest = JSON.parse(await readFile9(path15.join(temporary, ".claude-plugin/plugin.json"), "utf8"));
26632
+ const manifest = JSON.parse(await readFile9(path16.join(temporary, ".claude-plugin/plugin.json"), "utf8"));
26552
26633
  manifest.name = pluginName;
26553
26634
  if (manifest.hooks) manifest.hooks = claudeHostHooks({ pluginName, configFile: configFile2, nodeCommand });
26554
- await atomicJSON4(path15.join(temporary, ".claude-plugin/plugin.json"), manifest);
26555
- for (const file of [".mcp.json", ".claude-mcp.json"]) await atomicJSON4(path15.join(temporary, file), transport(serverName, configFile2, nodeCommand));
26635
+ await atomicJSON4(path16.join(temporary, ".claude-plugin/plugin.json"), manifest);
26636
+ for (const file of [".mcp.json", ".claude-mcp.json"]) await atomicJSON4(path16.join(temporary, file), transport(serverName, configFile2, nodeCommand));
26556
26637
  await checkRuntime(temporary, payload.version);
26557
26638
  const installed = await inspectRuntimePackage(temporary);
26558
- await atomicJSON4(path15.join(temporary, "installation.json"), {
26639
+ await atomicJSON4(path16.join(temporary, "installation.json"), {
26559
26640
  ...binding,
26560
26641
  version: payload.version,
26561
26642
  payloadDigest: payload.payloadDigest,
26562
- files: installed.files.map(({ path: path17, bytes: bytes2, sha256 }) => ({ path: path17, bytes: bytes2, sha256 }))
26643
+ files: installed.files.map(({ path: path18, bytes: bytes2, sha256 }) => ({ path: path18, bytes: bytes2, sha256 }))
26563
26644
  });
26564
26645
  signal?.throwIfAborted();
26565
26646
  await rename7(temporary, versionRoot);
@@ -26614,7 +26695,7 @@ async function installClaudeUserLocked({
26614
26695
 
26615
26696
  // lib/cli.mjs
26616
26697
  import { fileURLToPath } from "node:url";
26617
- import path16 from "node:path";
26698
+ import path17 from "node:path";
26618
26699
  var args = process.argv.slice(2);
26619
26700
  var command = args.shift();
26620
26701
  var value = (key) => {
@@ -26622,7 +26703,7 @@ var value = (key) => {
26622
26703
  return i < 0 ? void 0 : args[i + 1];
26623
26704
  };
26624
26705
  var log = (value2) => process.stdout.write(JSON.stringify(value2) + "\n");
26625
- var configFile = () => value("--config") ? path16.resolve(value("--config")) : profileCredentialsPath(value("--profile") ?? "default");
26706
+ var configFile = () => value("--config") ? path17.resolve(value("--config")) : profileCredentialsPath(value("--profile") ?? "default");
26626
26707
  async function probe(credentials) {
26627
26708
  const client = await connectPlatform(credentials, { host: resolveHostIdentity({ host: value("--host") }) });
26628
26709
  try {
@@ -26762,7 +26843,7 @@ async function bridge() {
26762
26843
  resolvedVersion: value("--resolved-runtime-version"),
26763
26844
  signal: startup.signal,
26764
26845
  hostKind: identity.kind,
26765
- cacheRoot: path16.join(path16.dirname(configFile()), "runtime-cache")
26846
+ cacheRoot: path17.join(path17.dirname(configFile()), "runtime-cache")
26766
26847
  });
26767
26848
  startup.signal.throwIfAborted();
26768
26849
  } catch (error4) {
@@ -26796,7 +26877,7 @@ async function bridge() {
26796
26877
  credentials,
26797
26878
  host: identity,
26798
26879
  hostSession,
26799
- localUploads: createLocalUploadManager({ stateRoot: path16.join(path16.dirname(configFile()), "local-upload-state") }),
26880
+ localUploads: createLocalUploadManager({ stateRoot: path17.join(path17.dirname(configFile()), "local-upload-state") }),
26800
26881
  onCatalogChange: () => server.sendToolListChanged(),
26801
26882
  onKnowledgeChange: (kind) => kind === "resources" ? server.sendResourceListChanged() : server.sendPromptListChanged()
26802
26883
  });