@promptframe/creation 0.3.13 → 0.3.14

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.
@@ -9,7 +9,7 @@
9
9
  "source": {
10
10
  "source": "npm",
11
11
  "package": "@promptframe/creation",
12
- "version": "0.3.13",
12
+ "version": "0.3.14",
13
13
  "registry": "https://registry.npmjs.org/"
14
14
  },
15
15
  "policy": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptframe-creation",
3
- "version": "0.3.13",
3
+ "version": "0.3.14",
4
4
  "description": "通过 PromptFrame 的共用工具、作品和任务创作视频。",
5
5
  "author": {
6
6
  "name": "PromptFrame"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptframe-creation",
3
- "version": "0.3.13",
3
+ "version": "0.3.14",
4
4
  "description": "使用自己的推理,通过 PromptFrame 的共用工具、作品和任务创作视频。",
5
5
  "author": {
6
6
  "name": "PromptFrame"
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  <!-- creation-install-command -->
10
10
  ```bash
11
- npx --yes @promptframe/creation@0.3.13 connect --endpoint <Studio提供的API地址>
11
+ npx --yes @promptframe/creation@0.3.14 connect --endpoint <Studio提供的API地址>
12
12
  ```
13
13
  <!-- /creation-install-command -->
14
14
 
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, constants9) {
410
+ optimizeNames(names, constants10) {
411
411
  if (!names[this.name.str])
412
412
  return;
413
413
  if (this.rhs)
414
- this.rhs = optimizeExpr(this.rhs, names, constants9);
414
+ this.rhs = optimizeExpr(this.rhs, names, constants10);
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, constants9) {
431
+ optimizeNames(names, constants10) {
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, constants9);
434
+ this.rhs = optimizeExpr(this.rhs, names, constants10);
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, constants9) {
496
- this.code = optimizeExpr(this.code, names, constants9);
495
+ optimizeNames(names, constants10) {
496
+ this.code = optimizeExpr(this.code, names, constants10);
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, constants9) {
525
+ optimizeNames(names, constants10) {
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, constants9))
530
+ if (n.optimizeNames(names, constants10))
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, constants9) {
583
+ optimizeNames(names, constants10) {
584
584
  var _a3;
585
- this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants9);
586
- if (!(super.optimizeNames(names, constants9) || this.else))
585
+ this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants10);
586
+ if (!(super.optimizeNames(names, constants10) || this.else))
587
587
  return;
588
- this.condition = optimizeExpr(this.condition, names, constants9);
588
+ this.condition = optimizeExpr(this.condition, names, constants10);
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, constants9) {
612
- if (!super.optimizeNames(names, constants9))
611
+ optimizeNames(names, constants10) {
612
+ if (!super.optimizeNames(names, constants10))
613
613
  return;
614
- this.iteration = optimizeExpr(this.iteration, names, constants9);
614
+ this.iteration = optimizeExpr(this.iteration, names, constants10);
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, constants9) {
651
- if (!super.optimizeNames(names, constants9))
650
+ optimizeNames(names, constants10) {
651
+ if (!super.optimizeNames(names, constants10))
652
652
  return;
653
- this.iterable = optimizeExpr(this.iterable, names, constants9);
653
+ this.iterable = optimizeExpr(this.iterable, names, constants10);
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, constants9) {
695
+ optimizeNames(names, constants10) {
696
696
  var _a3, _b;
697
- super.optimizeNames(names, constants9);
698
- (_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants9);
699
- (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants9);
697
+ super.optimizeNames(names, constants10);
698
+ (_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants10);
699
+ (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants10);
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, constants9) {
1000
+ function optimizeExpr(expr, names, constants10) {
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 = constants9[n.str];
1015
+ const c = constants10[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 && constants9[c.str] !== void 0);
1022
+ return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants10[c.str] !== void 0);
1023
1023
  }
1024
1024
  }
1025
1025
  function subtractNames(names, from) {
@@ -8429,7 +8429,7 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
8429
8429
  }
8430
8430
 
8431
8431
  // lib/version.mjs
8432
- var CLIENT_VERSION = "0.3.13";
8432
+ var CLIENT_VERSION = "0.3.14";
8433
8433
  var CLIENT_PROTOCOL = "creation-client/v1";
8434
8434
 
8435
8435
  // lib/cli.mjs
@@ -8579,9 +8579,9 @@ function floatSafeRemainder(val, step) {
8579
8579
  return ratio - roundedRatio;
8580
8580
  }
8581
8581
  var EVALUATING = /* @__PURE__ */ Symbol("evaluating");
8582
- function defineLazy(object3, key, getter) {
8582
+ function defineLazy(object4, key, getter) {
8583
8583
  let value2 = void 0;
8584
- Object.defineProperty(object3, key, {
8584
+ Object.defineProperty(object4, key, {
8585
8585
  get() {
8586
8586
  if (value2 === EVALUATING) {
8587
8587
  return void 0;
@@ -8593,7 +8593,7 @@ function defineLazy(object3, key, getter) {
8593
8593
  return value2;
8594
8594
  },
8595
8595
  set(v2) {
8596
- Object.defineProperty(object3, key, {
8596
+ Object.defineProperty(object4, key, {
8597
8597
  value: v2
8598
8598
  // configurable: true,
8599
8599
  });
@@ -13073,8 +13073,8 @@ function foldObjects(members2) {
13073
13073
  }
13074
13074
  const properties = {};
13075
13075
  const required2 = /* @__PURE__ */ new Set();
13076
- for (const object3 of objects) {
13077
- for (const key in object3.properties) {
13076
+ for (const object4 of objects) {
13077
+ for (const key in object4.properties) {
13078
13078
  if (Object.prototype.hasOwnProperty.call(properties, key))
13079
13079
  continue;
13080
13080
  const parts = [];
@@ -13088,18 +13088,18 @@ function foldObjects(members2) {
13088
13088
  const merged = parts.length === 1 ? parts[0] : foldObjects(parts) ?? { allOf: parts };
13089
13089
  assignProp(properties, key, merged);
13090
13090
  }
13091
- for (const key of object3.required ?? [])
13091
+ for (const key of object4.required ?? [])
13092
13092
  required2.add(key);
13093
13093
  }
13094
13094
  const folded = { type: "object", properties };
13095
13095
  if (required2.size)
13096
13096
  folded.required = [...required2];
13097
- if (objects.every((object3) => object3.additionalProperties === false)) {
13097
+ if (objects.every((object4) => object4.additionalProperties === false)) {
13098
13098
  folded.additionalProperties = false;
13099
13099
  } else {
13100
13100
  const constraints = [];
13101
- for (const object3 of objects) {
13102
- const constraint = undeclaredConstraint(object3);
13101
+ for (const object4 of objects) {
13102
+ const constraint = undeclaredConstraint(object4);
13103
13103
  if (constraint && !constraints.some((seen) => JSON.stringify(seen) === JSON.stringify(constraint)))
13104
13104
  constraints.push(constraint);
13105
13105
  }
@@ -16913,14 +16913,14 @@ var Protocol = class {
16913
16913
  const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
16914
16914
  const capturedTransport = this._transport;
16915
16915
  const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
16916
- const sessionId = capturedTransport?.sessionId;
16916
+ const sessionId2 = capturedTransport?.sessionId;
16917
16917
  const store = this._taskStore;
16918
16918
  let relatedTaskFound = true;
16919
16919
  let relatedTaskLookup;
16920
- if (relatedTaskId && store && this._taskMessageQueue && sessionId !== void 0) {
16920
+ if (relatedTaskId && store && this._taskMessageQueue && sessionId2 !== void 0) {
16921
16921
  relatedTaskFound = false;
16922
16922
  relatedTaskLookup = (async () => {
16923
- if (!await store.getTask(relatedTaskId, sessionId)) {
16923
+ if (!await store.getTask(relatedTaskId, sessionId2)) {
16924
16924
  throw new McpError(ErrorCode.InvalidParams, `Task not found: ${relatedTaskId}`);
16925
16925
  }
16926
16926
  relatedTaskFound = true;
@@ -16937,7 +16937,7 @@ var Protocol = class {
16937
16937
  };
16938
16938
  if (relatedTaskId && relatedTaskLookup) {
16939
16939
  const queuedError = { type: "error", message: errorResponse, timestamp: Date.now() };
16940
- relatedTaskLookup.then(() => this._enqueueTaskMessage(relatedTaskId, queuedError, sessionId), () => capturedTransport?.send(errorResponse)).catch((error6) => this._onerror(new Error(`Failed to send an error response: ${error6}`)));
16940
+ relatedTaskLookup.then(() => this._enqueueTaskMessage(relatedTaskId, queuedError, sessionId2), () => capturedTransport?.send(errorResponse)).catch((error6) => this._onerror(new Error(`Failed to send an error response: ${error6}`)));
16941
16941
  } else if (relatedTaskId && this._taskMessageQueue) {
16942
16942
  this._enqueueTaskMessage(relatedTaskId, {
16943
16943
  type: "error",
@@ -17502,21 +17502,21 @@ var Protocol = class {
17502
17502
  * the error appropriately (e.g., by failing the task, logging, etc.). The Protocol layer
17503
17503
  * simply propagates the error.
17504
17504
  */
17505
- async _enqueueTaskMessage(taskId, message, sessionId) {
17505
+ async _enqueueTaskMessage(taskId, message, sessionId2) {
17506
17506
  if (!this._taskStore || !this._taskMessageQueue) {
17507
17507
  throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
17508
17508
  }
17509
17509
  const maxQueueSize = this._options?.maxTaskQueueSize;
17510
- await this._taskMessageQueue.enqueue(taskId, message, sessionId ?? this._transport?.sessionId, maxQueueSize);
17510
+ await this._taskMessageQueue.enqueue(taskId, message, sessionId2 ?? this._transport?.sessionId, maxQueueSize);
17511
17511
  }
17512
17512
  /**
17513
17513
  * Clears the message queue for a task and rejects any pending request resolvers.
17514
17514
  * @param taskId The task ID whose queue should be cleared
17515
17515
  * @param sessionId Optional session ID for binding the operation to a specific session
17516
17516
  */
17517
- async _clearTaskQueue(taskId, sessionId) {
17517
+ async _clearTaskQueue(taskId, sessionId2) {
17518
17518
  if (this._taskMessageQueue) {
17519
- const messages = await this._taskMessageQueue.dequeueAll(taskId, sessionId);
17519
+ const messages = await this._taskMessageQueue.dequeueAll(taskId, sessionId2);
17520
17520
  for (const message of messages) {
17521
17521
  if (message.type === "request" && isJSONRPCRequest(message.message)) {
17522
17522
  const requestId = message.message.id;
@@ -17539,10 +17539,10 @@ var Protocol = class {
17539
17539
  * @param sessionId Session of the request that waits, passed to the task store
17540
17540
  * @returns Promise that resolves when an update occurs or rejects if aborted
17541
17541
  */
17542
- async _waitForTaskUpdate(taskId, signal, sessionId) {
17542
+ async _waitForTaskUpdate(taskId, signal, sessionId2) {
17543
17543
  let interval = this._options?.defaultTaskPollInterval ?? 1e3;
17544
17544
  try {
17545
- const task = await this._taskStore?.getTask(taskId, sessionId);
17545
+ const task = await this._taskStore?.getTask(taskId, sessionId2);
17546
17546
  if (task?.pollInterval) {
17547
17547
  interval = task.pollInterval;
17548
17548
  }
@@ -17560,7 +17560,7 @@ var Protocol = class {
17560
17560
  }, { once: true });
17561
17561
  });
17562
17562
  }
17563
- requestTaskStore(request, sessionId) {
17563
+ requestTaskStore(request, sessionId2) {
17564
17564
  const taskStore = this._taskStore;
17565
17565
  if (!taskStore) {
17566
17566
  throw new Error("No task store configured");
@@ -17573,18 +17573,18 @@ var Protocol = class {
17573
17573
  return await taskStore.createTask(taskParams, request.id, {
17574
17574
  method: request.method,
17575
17575
  params: request.params
17576
- }, sessionId);
17576
+ }, sessionId2);
17577
17577
  },
17578
17578
  getTask: async (taskId) => {
17579
- const task = await taskStore.getTask(taskId, sessionId);
17579
+ const task = await taskStore.getTask(taskId, sessionId2);
17580
17580
  if (!task) {
17581
17581
  throw new McpError(ErrorCode.InvalidParams, "Failed to retrieve task: Task not found");
17582
17582
  }
17583
17583
  return task;
17584
17584
  },
17585
17585
  storeTaskResult: async (taskId, status, result) => {
17586
- await taskStore.storeTaskResult(taskId, status, result, sessionId);
17587
- const task = await taskStore.getTask(taskId, sessionId);
17586
+ await taskStore.storeTaskResult(taskId, status, result, sessionId2);
17587
+ const task = await taskStore.getTask(taskId, sessionId2);
17588
17588
  if (task) {
17589
17589
  const notification = TaskStatusNotificationSchema.parse({
17590
17590
  method: "notifications/tasks/status",
@@ -17597,18 +17597,18 @@ var Protocol = class {
17597
17597
  }
17598
17598
  },
17599
17599
  getTaskResult: (taskId) => {
17600
- return taskStore.getTaskResult(taskId, sessionId);
17600
+ return taskStore.getTaskResult(taskId, sessionId2);
17601
17601
  },
17602
17602
  updateTaskStatus: async (taskId, status, statusMessage) => {
17603
- const task = await taskStore.getTask(taskId, sessionId);
17603
+ const task = await taskStore.getTask(taskId, sessionId2);
17604
17604
  if (!task) {
17605
17605
  throw new McpError(ErrorCode.InvalidParams, `Task "${taskId}" not found - it may have been cleaned up`);
17606
17606
  }
17607
17607
  if (isTerminal(task.status)) {
17608
17608
  throw new McpError(ErrorCode.InvalidParams, `Cannot update task "${taskId}" from terminal status "${task.status}" to "${status}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);
17609
17609
  }
17610
- await taskStore.updateTaskStatus(taskId, status, statusMessage, sessionId);
17611
- const updatedTask = await taskStore.getTask(taskId, sessionId);
17610
+ await taskStore.updateTaskStatus(taskId, status, statusMessage, sessionId2);
17611
+ const updatedTask = await taskStore.getTask(taskId, sessionId2);
17612
17612
  if (updatedTask) {
17613
17613
  const notification = TaskStatusNotificationSchema.parse({
17614
17614
  method: "notifications/tasks/status",
@@ -17621,7 +17621,7 @@ var Protocol = class {
17621
17621
  }
17622
17622
  },
17623
17623
  listTasks: (cursor) => {
17624
- return taskStore.listTasks(cursor, sessionId);
17624
+ return taskStore.listTasks(cursor, sessionId2);
17625
17625
  }
17626
17626
  };
17627
17627
  }
@@ -17972,8 +17972,8 @@ var Server = class extends Protocol {
17972
17972
  this._serverInfo = _serverInfo;
17973
17973
  this._loggingLevels = /* @__PURE__ */ new Map();
17974
17974
  this.LOG_LEVEL_SEVERITY = new Map(LoggingLevelSchema.options.map((level, index) => [level, index]));
17975
- this.isMessageIgnored = (level, sessionId) => {
17976
- const currentLevel = this._loggingLevels.get(sessionId);
17975
+ this.isMessageIgnored = (level, sessionId2) => {
17976
+ const currentLevel = this._loggingLevels.get(sessionId2);
17977
17977
  return currentLevel ? this.LOG_LEVEL_SEVERITY.get(level) < this.LOG_LEVEL_SEVERITY.get(currentLevel) : false;
17978
17978
  };
17979
17979
  this._capabilities = options?.capabilities ?? {};
@@ -18307,9 +18307,9 @@ var Server = class extends Protocol {
18307
18307
  * @param params
18308
18308
  * @param sessionId optional for stateless and backward compatibility
18309
18309
  */
18310
- async sendLoggingMessage(params, sessionId) {
18310
+ async sendLoggingMessage(params, sessionId2) {
18311
18311
  if (this._capabilities.logging) {
18312
- if (!this.isMessageIgnored(params.level, sessionId)) {
18312
+ if (!this.isMessageIgnored(params.level, sessionId2)) {
18313
18313
  return this.notification({ method: "notifications/message", params });
18314
18314
  }
18315
18315
  }
@@ -20580,9 +20580,9 @@ var StreamableHTTPClientTransport = class {
20580
20580
  signal: this._abortController?.signal
20581
20581
  };
20582
20582
  const response = await fetchWithinOrigin(this._fetch ?? fetch)(this._url, init);
20583
- const sessionId = response.headers.get("mcp-session-id");
20584
- if (sessionId) {
20585
- this._sessionId = sessionId;
20583
+ const sessionId2 = response.headers.get("mcp-session-id");
20584
+ if (sessionId2) {
20585
+ this._sessionId = sessionId2;
20586
20586
  }
20587
20587
  if (!response.ok) {
20588
20588
  const text = await response.text().catch(() => null);
@@ -21447,7 +21447,7 @@ async function createClaudeHostSession({ configFile: configFile2, env = process.
21447
21447
  async function hook(input) {
21448
21448
  const event = input?.hook_event_name;
21449
21449
  if (!["SessionStart", "PreToolUse", "SessionEnd"].includes(event)) throw error2("host_identity_invalid");
21450
- const valid = typeof input.session_id === "string" && uuid2.test(input.session_id), sessionId = valid ? input.session_id.toLowerCase() : null;
21450
+ const valid = typeof input.session_id === "string" && uuid2.test(input.session_id), sessionId2 = valid ? input.session_id.toLowerCase() : null;
21451
21451
  const rawArgs = input.tool_input;
21452
21452
  if (event === "PreToolUse" && (!rawArgs || typeof rawArgs !== "object" || Array.isArray(rawArgs) || typeof input.tool_name !== "string" || !/^mcp__[A-Za-z0-9_.:-]+__[A-Za-z0-9_.:-]+$/.test(input.tool_name))) throw error2("host_identity_invalid");
21453
21453
  if (!owner) return event === "PreToolUse" && Object.hasOwn(rawArgs, CLAUDE_HOST_PROOF) ? { hookSpecificOutput: { hookEventName: event, updatedInput: withoutProof(rawArgs) } } : {};
@@ -21455,12 +21455,12 @@ async function createClaudeHostSession({ configFile: configFile2, env = process.
21455
21455
  await transaction((current) => {
21456
21456
  if (current && later(current.order, owner.eventOrder)) return void 0;
21457
21457
  if (event === "SessionEnd") {
21458
- if (current?.sessionId === sessionId && ["prompt_input_exit", "logout", "other", "bypass_permissions_disabled"].includes(input.reason)) return null;
21459
- if (!current || current.sessionId !== sessionId) return void 0;
21458
+ if (current?.sessionId === sessionId2 && ["prompt_input_exit", "logout", "other", "bypass_permissions_disabled"].includes(input.reason)) return null;
21459
+ if (!current || current.sessionId !== sessionId2) return void 0;
21460
21460
  }
21461
21461
  if (event === "SessionStart" && !["startup", "resume", "fork", "clear", "compact"].includes(input.source)) throw error2("host_identity_invalid");
21462
- const inconsistent = event === "PreToolUse" && current?.sessionId !== sessionId || event === "SessionStart" && input.source === "compact" && current?.sessionId !== sessionId || event === "SessionStart" && input.source === "startup" && current?.sessionId && current.sessionId !== sessionId;
21463
- const nextId = event === "SessionEnd" || inconsistent ? null : sessionId;
21462
+ const inconsistent = event === "PreToolUse" && current?.sessionId !== sessionId2 || event === "SessionStart" && input.source === "compact" && current?.sessionId !== sessionId2 || event === "SessionStart" && input.source === "startup" && current?.sessionId && current.sessionId !== sessionId2;
21463
+ const nextId = event === "SessionEnd" || inconsistent ? null : sessionId2;
21464
21464
  const same2 = current && current.sessionId === nextId;
21465
21465
  const next = {
21466
21466
  contractVersion: "claude-host-session/v1",
@@ -21596,8 +21596,8 @@ function createHostCallBridge(client, { credentials, host = resolveHostIdentity(
21596
21596
  });
21597
21597
  }
21598
21598
  function keyFor(params) {
21599
- const { projectId, sessionId } = params.arguments ?? {}, thread = params._meta?.threadId;
21600
- return typeof thread === "string" && [projectId, sessionId].every((v2) => typeof v2 === "string" && v2.length > 0 && v2.length <= 160) ? JSON.stringify([thread.toLowerCase(), projectId, sessionId]) : null;
21599
+ const { projectId, sessionId: sessionId2 } = params.arguments ?? {}, thread = params._meta?.threadId;
21600
+ return typeof thread === "string" && [projectId, sessionId2].every((v2) => typeof v2 === "string" && v2.length > 0 && v2.length <= 160) ? JSON.stringify([thread.toLowerCase(), projectId, sessionId2]) : null;
21601
21601
  }
21602
21602
  function metadata(params, result) {
21603
21603
  const v2 = result?._meta?.["promptframe.creation"];
@@ -21730,9 +21730,9 @@ function createHostCallBridge(client, { credentials, host = resolveHostIdentity(
21730
21730
  let params = hostParameters(raw, binding.host, "independent-read");
21731
21731
  let effectiveAccess = access2, resolvedControl;
21732
21732
  if (definition._meta["promptframe.resolveAccess"] === "target") {
21733
- const { projectId, sessionId, tool, arguments: input } = params.arguments ?? {};
21733
+ const { projectId, sessionId: sessionId2, tool, arguments: input } = params.arguments ?? {};
21734
21734
  if (typeof tool !== "string" || !input || typeof input !== "object" || Array.isArray(input)) throw new CreationClientError("creation.request_invalid");
21735
- const observed = await send({ name: role("describe-target"), _meta: params._meta, arguments: { projectId, sessionId, tool, arguments: input } }, binding);
21735
+ const observed = await send({ name: role("describe-target"), _meta: params._meta, arguments: { projectId, sessionId: sessionId2, tool, arguments: input } }, binding);
21736
21736
  if (observed.result.isError) return observed.result;
21737
21737
  const resolved = observed.trusted?.resolvedAccess;
21738
21738
  const defaults = resolved?.scopeDefaults ?? {};
@@ -21748,9 +21748,9 @@ function createHostCallBridge(client, { credentials, host = resolveHostIdentity(
21748
21748
  const local = definition._meta["promptframe.localFileUpload"];
21749
21749
  if (local?.contractVersion === LOCAL_UPLOAD_PROTOCOL) {
21750
21750
  if (!localUploads) throw new CreationClientError("creation.upgrade_required");
21751
- const { projectId, sessionId } = params.arguments ?? {};
21752
- if (typeof projectId !== "string" || typeof sessionId !== "string") throw new CreationClientError("creation.request_invalid");
21753
- const observed = await send({ name: role("control-read"), _meta: params._meta, arguments: { projectId, sessionId, pageSize: 1 } }, binding);
21751
+ const { projectId, sessionId: sessionId2 } = params.arguments ?? {};
21752
+ if (typeof projectId !== "string" || typeof sessionId2 !== "string") throw new CreationClientError("creation.request_invalid");
21753
+ const observed = await send({ name: role("control-read"), _meta: params._meta, arguments: { projectId, sessionId: sessionId2, pageSize: 1 } }, binding);
21754
21754
  if (observed.result.isError) return observed.result;
21755
21755
  if (!observed.trusted) throw new CreationClientError("creation.access_unverified");
21756
21756
  const value2 = await localUploads.call({
@@ -21764,9 +21764,9 @@ function createHostCallBridge(client, { credentials, host = resolveHostIdentity(
21764
21764
  host: binding.host.kind,
21765
21765
  thread: params._meta.threadId.toLowerCase(),
21766
21766
  projectId,
21767
- sessionId
21767
+ sessionId: sessionId2
21768
21768
  },
21769
- send: (transfer, options) => send({ name: params.name, _meta: params._meta, arguments: { projectId, sessionId, transfer } }, binding, { timeout: 3e4, ...options })
21769
+ send: (transfer, options) => send({ name: params.name, _meta: params._meta, arguments: { projectId, sessionId: sessionId2, transfer } }, binding, { timeout: 3e4, ...options })
21770
21770
  });
21771
21771
  return assertMcpResponseBudget({ content: [{ type: "text", text: JSON.stringify(value2) }] });
21772
21772
  }
@@ -21869,8 +21869,8 @@ function createAccountAwareBridge(defaultClient, {
21869
21869
  function caller(raw, binding, required2 = false) {
21870
21870
  const params = { ...raw, arguments: binding.arguments };
21871
21871
  hostParameters(params, binding.host, required2 ? "authority" : "independent-read");
21872
- const sessionId = isHookProofHost(binding.host.kind) ? binding.host.threadId : params._meta?.threadId;
21873
- return sessionId ? { kind: binding.host.kind, sessionId } : void 0;
21872
+ const sessionId2 = isHookProofHost(binding.host.kind) ? binding.host.threadId : params._meta?.threadId;
21873
+ return sessionId2 ? { kind: binding.host.kind, sessionId: sessionId2 } : void 0;
21874
21874
  }
21875
21875
  async function context(identity, agent, referenceId) {
21876
21876
  if (sameIdentity(identity, primaryIdentity) && (!referenceId || referenceId === localReferenceId("creation", path10.resolve(configFile2)))) return primary;
@@ -21983,7 +21983,11 @@ import { homedir as homedir5 } from "node:os";
21983
21983
  import { createHash as createHash7, randomBytes as randomBytes4 } from "node:crypto";
21984
21984
  var hex2 = /^[0-9a-f]{64}$/;
21985
21985
  var TICKET_TTL_MS = 12e4;
21986
+ var SESSION_TTL_MS = 24 * 60 * 60 * 1e3;
21986
21987
  var MAX_TICKETS = 256;
21988
+ var MAX_SESSIONS = 256;
21989
+ var DEFAULT_SERVER = "promptframe-creation_promptframe-creation";
21990
+ var mcpToolName = /^[A-Za-z0-9_.:-]{1,200}$/;
21987
21991
  var error4 = (code) => new CreationClientError("creation." + code);
21988
21992
  var canonical3 = (value2) => {
21989
21993
  if (value2 === null || typeof value2 === "string" || typeof value2 === "boolean" || typeof value2 === "number" && Number.isFinite(value2)) return JSON.stringify(value2);
@@ -21994,9 +21998,31 @@ var canonical3 = (value2) => {
21994
21998
  };
21995
21999
  var digest4 = (value2) => createHash7("sha256").update(canonical3(value2)).digest("hex");
21996
22000
  var withoutProof2 = (args2) => Object.fromEntries(Object.entries(args2 ?? {}).filter(([key]) => key !== CLAUDE_HOST_PROOF));
21997
- function isPromptFrameToolName(name) {
21998
- if (typeof name !== "string" || !name || name.length > 200) return false;
21999
- return /(?:^|[_:])promptframe/i.test(name) || /^platform_[a-z0-9_]+$/i.test(name);
22001
+ function objectArgs(value2) {
22002
+ return value2 && typeof value2 === "object" && !Array.isArray(value2) ? value2 : null;
22003
+ }
22004
+ function promptFrameCall(toolCall, serverName) {
22005
+ if (typeof toolCall?.name !== "string") return null;
22006
+ const args2 = objectArgs(toolCall.args) ?? {};
22007
+ if (toolCall.name === "call_mcp_tool") {
22008
+ if (args2.ServerName !== serverName || typeof args2.ToolName !== "string" || !mcpToolName.test(args2.ToolName)) return null;
22009
+ const inner = args2.Arguments === void 0 ? {} : objectArgs(args2.Arguments);
22010
+ return inner ? { name: args2.ToolName, args: inner, lazy: true } : null;
22011
+ }
22012
+ const namespacedPrefix = `mcp_${serverName}_`, oldPrefix = `mcp_${serverName.split("_")[0]}_`;
22013
+ if (toolCall.name.startsWith(namespacedPrefix)) {
22014
+ const name2 = toolCall.name.slice(namespacedPrefix.length);
22015
+ return mcpToolName.test(name2) ? { name: name2, args: args2, lazy: false } : null;
22016
+ }
22017
+ const name = toolCall.name.startsWith(oldPrefix) ? toolCall.name.slice(oldPrefix.length) : toolCall.name;
22018
+ return /^(?:platform_|promptframe_local_)[a-z0-9_]+$/i.test(name) && mcpToolName.test(name) ? { name, args: args2, lazy: false } : null;
22019
+ }
22020
+ function sessionId(value2) {
22021
+ return typeof value2 === "string" && threadFormat.test(value2) ? value2.toLowerCase() : null;
22022
+ }
22023
+ function transcriptDigest(input) {
22024
+ const file = input?.transcriptPath;
22025
+ return typeof file === "string" && file.length <= 4096 && path11.isAbsolute(file) ? digest4(path11.normalize(file)) : null;
22000
22026
  }
22001
22027
  function toolNameMatches(hookToolName, bridgeToolName) {
22002
22028
  if (typeof hookToolName !== "string" || typeof bridgeToolName !== "string" || !bridgeToolName) return false;
@@ -22029,7 +22055,7 @@ async function privateRead2(file) {
22029
22055
  function antigravityConfigRoot(env = process.env) {
22030
22056
  return path11.resolve(env.ANTIGRAVITY_CONFIG_DIR ?? env.GEMINI_CONFIG_DIR ?? path11.join(homedir5(), ".gemini", "config"));
22031
22057
  }
22032
- async function createAntigravityHostSession({ configFile: configFile2, env = process.env, root, now = () => Date.now() } = {}) {
22058
+ async function createAntigravityHostSession({ configFile: configFile2, env = process.env, root, serverName = DEFAULT_SERVER, now = () => Date.now() } = {}) {
22033
22059
  const base = root ?? path11.join(antigravityConfigRoot(env), "promptframe-host-sessions");
22034
22060
  const namespace = path11.join(base, digest4(path11.resolve(configFile2)));
22035
22061
  const stateFile = path11.join(namespace, "state.json");
@@ -22092,6 +22118,16 @@ async function createAntigravityHostSession({ configFile: configFile2, env = pro
22092
22118
  while (keys.length >= MAX_TICKETS) delete kept[keys.shift()];
22093
22119
  return kept;
22094
22120
  }
22121
+ function pruneSessions(sessions, currentTime) {
22122
+ const active = Object.entries(sessions ?? {}).filter(([id, value2]) => sessionId(id) && Number.isSafeInteger(value2?.expiresAt) && value2.expiresAt > currentTime);
22123
+ return Object.fromEntries(active.slice(-MAX_SESSIONS));
22124
+ }
22125
+ function bindSession(sessions, id, transcript, currentTime) {
22126
+ const previous = sessions[id];
22127
+ delete sessions[id];
22128
+ sessions[id] = { transcriptDigest: transcript ?? previous?.transcriptDigest ?? null, expiresAt: currentTime + SESSION_TTL_MS };
22129
+ return pruneSessions(sessions, currentTime);
22130
+ }
22095
22131
  async function begin(raw) {
22096
22132
  const proof = raw.arguments?.[CLAUDE_HOST_PROOF], args2 = withoutProof2(raw.arguments);
22097
22133
  if (proof === void 0) return { host: { kind: "antigravity" }, assertCurrent: async () => {
@@ -22102,7 +22138,7 @@ async function createAntigravityHostSession({ configFile: configFile2, env = pro
22102
22138
  try {
22103
22139
  await transaction((current) => {
22104
22140
  const ticket = current.tickets[proof];
22105
- if (!ticket || ticket.expiresAt <= currentTime || ticket.argsDigest !== argsHash || !toolNameMatches(ticket.toolName, raw.name) || !threadFormat.test(ticket.conversationId ?? ""))
22141
+ if (!ticket || ticket.expiresAt <= currentTime || ticket.argsDigest !== argsHash || !(ticket.exactToolName ? ticket.toolName === raw.name : toolNameMatches(ticket.toolName, raw.name)) || !threadFormat.test(ticket.conversationId ?? ""))
22106
22142
  throw error4("host_identity_invalid");
22107
22143
  accepted = { threadId: ticket.conversationId.toLowerCase() };
22108
22144
  delete current.tickets[proof];
@@ -22116,26 +22152,33 @@ async function createAntigravityHostSession({ configFile: configFile2, env = pro
22116
22152
  return { host: { kind: "antigravity", threadId: accepted.threadId }, arguments: args2, assertCurrent: async () => {
22117
22153
  } };
22118
22154
  }
22119
- async function hook(input) {
22120
- const event = input?.hookEventName;
22121
- if (event !== void 0 && event !== "PreToolUse") return {};
22122
- const toolCall = input?.toolCall;
22123
- if (!toolCall || typeof toolCall !== "object" || typeof toolCall.name !== "string") return { decision: "allow" };
22124
- if (!isPromptFrameToolName(toolCall.name)) return { decision: "allow" };
22125
- const rawArgs = toolCall.args && typeof toolCall.args === "object" && !Array.isArray(toolCall.args) ? toolCall.args : {};
22126
- const conversationId = typeof input.conversationId === "string" && threadFormat.test(input.conversationId) ? input.conversationId.toLowerCase() : null;
22127
- if (!conversationId) {
22128
- return Object.hasOwn(rawArgs, CLAUDE_HOST_PROOF) ? { decision: "deny", reason: "Missing valid Antigravity conversationId for PromptFrame proof." } : { decision: "allow" };
22129
- }
22130
- const args2 = withoutProof2(rawArgs), argsHash = digest4(args2), currentTime = now();
22155
+ async function hook(input, event = input?.hookEventName ?? "PreToolUse") {
22156
+ if (input?.hookEventName !== void 0 && input.hookEventName !== event) return {};
22157
+ const id = sessionId(input?.conversationId), transcript = transcriptDigest(input), currentTime = now();
22158
+ if (event === "SessionStart") {
22159
+ if (id) await transaction((current) => {
22160
+ current.sessions = bindSession(pruneSessions(current.sessions, currentTime), id, transcript, currentTime);
22161
+ return current;
22162
+ });
22163
+ return {};
22164
+ }
22165
+ if (event !== "PreToolUse") return {};
22166
+ const call = promptFrameCall(input?.toolCall, serverName);
22167
+ if (!call) return { decision: "allow" };
22168
+ const args2 = withoutProof2(call.args), argsHash = digest4(args2);
22131
22169
  let token;
22132
22170
  await transaction((current) => {
22171
+ const sessions = pruneSessions(current.sessions, currentTime);
22172
+ const matches = !id && input?.conversationId === void 0 && transcript ? Object.keys(sessions).filter((key) => sessions[key].transcriptDigest === transcript) : [];
22173
+ const conversationId = id ?? (matches.length === 1 ? matches[0] : null);
22174
+ if (!conversationId) return;
22133
22175
  const tickets = pruneTickets(current.tickets, currentTime);
22134
22176
  token = randomBytes4(32).toString("hex");
22135
- tickets[token] = { toolName: toolCall.name, argsDigest: argsHash, conversationId, expiresAt: currentTime + TICKET_TTL_MS };
22136
- return { contractVersion: "antigravity-host-session/v1", tickets };
22177
+ tickets[token] = { toolName: call.name, exactToolName: true, argsDigest: argsHash, conversationId, expiresAt: currentTime + TICKET_TTL_MS };
22178
+ return { contractVersion: "antigravity-host-session/v1", tickets, sessions: bindSession(sessions, conversationId, transcript, currentTime) };
22137
22179
  });
22138
- return { decision: "allow", overwrite: { [CLAUDE_HOST_PROOF]: token } };
22180
+ if (!token) return Object.hasOwn(call.args, CLAUDE_HOST_PROOF) ? { decision: "deny", reason: "Missing valid Antigravity conversationId for PromptFrame proof." } : { decision: "allow" };
22181
+ return { decision: "allow", overwrite: call.lazy ? { Arguments: { ...args2, [CLAUDE_HOST_PROOF]: token } } : { [CLAUDE_HOST_PROOF]: token } };
22139
22182
  }
22140
22183
  return { begin, hook };
22141
22184
  }
@@ -22150,10 +22193,10 @@ async function readAntigravityHookInput(input) {
22150
22193
  }
22151
22194
  return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(Buffer.concat(chunks, bytes2)));
22152
22195
  }
22153
- async function runAntigravityHostHook({ configFile: configFile2, input = process.stdin, output = process.stdout, env = process.env } = {}) {
22196
+ async function runAntigravityHostHook({ configFile: configFile2, serverName, event, input = process.stdin, output = process.stdout, env = process.env } = {}) {
22154
22197
  const body = await readAntigravityHookInput(input);
22155
- const store = await createAntigravityHostSession({ configFile: configFile2, env });
22156
- output.write(JSON.stringify(await store.hook(body)) + "\n");
22198
+ const store = await createAntigravityHostSession({ configFile: configFile2, serverName, env });
22199
+ output.write(JSON.stringify(await store.hook(body, event)) + "\n");
22157
22200
  }
22158
22201
 
22159
22202
  // lib/runtime-bootstrap.mjs
@@ -27540,14 +27583,72 @@ async function installClaudeUserLocked({
27540
27583
 
27541
27584
  // lib/antigravity-installation.mjs
27542
27585
  import { lstat as lstat13, mkdir as mkdir10, open as open13, readFile as readFile10, rename as rename10, rm as rm6 } from "node:fs/promises";
27586
+ import { constants as constants9 } from "node:fs";
27543
27587
  import { createHash as createHash14, randomBytes as randomBytes9 } from "node:crypto";
27544
27588
  import { homedir as homedir12 } from "node:os";
27545
27589
  import path21 from "node:path";
27546
27590
  var hash7 = (b2) => createHash14("sha256").update(b2).digest("hex");
27547
- var fail8 = (code) => {
27548
- throw new CreationClientError("installation." + code);
27591
+ var AntigravityInstallationError = class extends CreationClientError {
27592
+ constructor(code, details) {
27593
+ super("installation." + code);
27594
+ this.details = details;
27595
+ }
27596
+ };
27597
+ var antigravityInstallationDetails = (error6) => error6 instanceof AntigravityInstallationError ? error6.details : void 0;
27598
+ var fail8 = (code, details) => {
27599
+ throw new AntigravityInstallationError(code, details);
27549
27600
  };
27550
27601
  var profileFormat = /^[a-z0-9][a-z0-9-]{0,39}$/;
27602
+ var antigravityServerName = (profile) => "promptframe-creation" + (profile === "default" ? "" : "-" + profile);
27603
+ var object3 = (value2) => value2 !== null && typeof value2 === "object" && !Array.isArray(value2);
27604
+ function usesCreationBridge(server, { profile, configFile: configFile2 }) {
27605
+ if (!object3(server) || typeof server.command !== "string" || !Array.isArray(server.args)) return false;
27606
+ const args2 = server.args;
27607
+ const bridgeIndex = args2.indexOf("bridge");
27608
+ if (bridgeIndex < 0) return false;
27609
+ const isCreationExecutable = (value2) => typeof value2 === "string" && /^promptframe-creation(?:\.mjs|\.cmd|\.exe)?$/.test(path21.win32.basename(value2));
27610
+ const command2 = path21.win32.basename(server.command);
27611
+ const bridgeLauncher = isCreationExecutable(command2) || /^(?:node|nodejs|bun)(?:\.exe)?$/.test(command2) && isCreationExecutable(args2[bridgeIndex - 1]) || /^(?:npx|npm|pnpm|yarn|bunx)(?:\.cmd|\.exe)?$/.test(command2) && typeof args2[bridgeIndex - 1] === "string" && /^@promptframe\/creation(?:@[^\s]+)?$/.test(args2[bridgeIndex - 1]);
27612
+ if (!bridgeLauncher) return false;
27613
+ const configIndex = args2.indexOf("--config", bridgeIndex + 1);
27614
+ const profileIndex = args2.indexOf("--profile", bridgeIndex + 1);
27615
+ const configuredProfile = profileIndex < 0 ? "default" : args2[profileIndex + 1];
27616
+ const configuredFile = configIndex >= 0 ? args2[configIndex + 1] : configuredProfile === "default" ? server.env?.PROMPTFRAME_CREATION_CONFIG : void 0;
27617
+ if (typeof configuredFile === "string" && path21.isAbsolute(configuredFile)) return path21.resolve(configuredFile) === configFile2;
27618
+ return configuredProfile === profile;
27619
+ }
27620
+ async function checkAntigravityMcpConflicts({ profile = "default", configFile: configFile2, env = process.env } = {}) {
27621
+ const mcpConfigFile = path21.join(antigravityConfigRoot(env), "mcp_config.json");
27622
+ const unreadable = () => fail8("antigravity_mcp_config_unreadable", {
27623
+ mcpConfigFile,
27624
+ action: "Check that the Antigravity MCP configuration is readable and contains a valid JSON object, then retry connect."
27625
+ });
27626
+ let file;
27627
+ try {
27628
+ file = await open13(mcpConfigFile, constants9.O_RDONLY | constants9.O_NONBLOCK);
27629
+ } catch (error6) {
27630
+ if (error6.code === "ENOENT") return;
27631
+ unreadable();
27632
+ }
27633
+ let config2;
27634
+ try {
27635
+ const info5 = await file.stat();
27636
+ if (!info5.isFile() || info5.size > 4 * 1024 * 1024) unreadable();
27637
+ config2 = JSON.parse(await file.readFile("utf8"));
27638
+ } catch {
27639
+ unreadable();
27640
+ } finally {
27641
+ await file.close();
27642
+ }
27643
+ if (!object3(config2) || config2.mcpServers !== void 0 && !object3(config2.mcpServers)) unreadable();
27644
+ const serverName = antigravityServerName(profile);
27645
+ const mcpServerNames = Object.entries(config2.mcpServers ?? {}).filter(([name, server]) => name === serverName || name === `${serverName}_${serverName}` || profile === "default" && name === "promptframe" || usesCreationBridge(server, { profile, configFile: configFile2 })).map(([name]) => name);
27646
+ if (mcpServerNames.length) fail8("legacy_mcp_entry_requires_review", {
27647
+ mcpConfigFile,
27648
+ mcpServerNames,
27649
+ action: "In Antigravity MCP settings, review the listed entries and remove the conflicting manual PromptFrame entries, then rerun connect with the existing Token."
27650
+ });
27651
+ }
27551
27652
  function shellQuote(value2) {
27552
27653
  return '"' + String(value2).replace(/(["\\$`])/g, "\\$1") + '"';
27553
27654
  }
@@ -27575,15 +27676,24 @@ function antigravityMcpConfig({ serverName, nodeCommand, runtimeRoot, configFile
27575
27676
  }
27576
27677
  };
27577
27678
  }
27578
- function antigravityHooksConfig({ nodeCommand, runtimeRoot, configFile: configFile2 }) {
27679
+ function antigravityHooksConfig({ nodeCommand, runtimeRoot, configFile: configFile2, serverName }) {
27579
27680
  const cliPath = path21.join(runtimeRoot, "bin", "promptframe-creation.mjs");
27580
- const command2 = [shellQuote(nodeCommand), shellQuote(cliPath), "antigravity-host-hook", "--config", shellQuote(configFile2)].join(" ");
27681
+ const command2 = [
27682
+ shellQuote(nodeCommand),
27683
+ shellQuote(cliPath),
27684
+ "antigravity-host-hook",
27685
+ "--config",
27686
+ shellQuote(configFile2),
27687
+ "--mcp-server",
27688
+ shellQuote(`${serverName}_${serverName}`)
27689
+ ].join(" ");
27581
27690
  return {
27582
27691
  "promptframe-host-identity": {
27692
+ SessionStart: [{ type: "command", command: command2 + " --hook-event SessionStart", timeout: 5 }],
27583
27693
  PreToolUse: [
27584
27694
  {
27585
- matcher: "(.*promptframe.*|^platform_.*)",
27586
- hooks: [{ type: "command", command: command2, timeout: 5 }]
27695
+ matcher: "(.*promptframe.*|^platform_.*|^call_mcp_tool$)",
27696
+ hooks: [{ type: "command", command: command2 + " --hook-event PreToolUse", timeout: 5 }]
27587
27697
  }
27588
27698
  ]
27589
27699
  }
@@ -27642,10 +27752,10 @@ async function installForAntigravityUser({
27642
27752
  if (!profileFormat.test(profile)) fail8("profile_invalid");
27643
27753
  if (!path21.isAbsolute(configFile2 ?? "")) fail8("config_path_invalid");
27644
27754
  signal?.throwIfAborted();
27755
+ await checkAntigravityMcpConflicts({ profile, configFile: configFile2, env });
27645
27756
  const payload = await inspectRuntimePackage(sourceRoot);
27646
- const suffix = profile === "default" ? "" : "-" + profile;
27647
- const pluginDirName = "promptframe-creation" + suffix;
27648
- const serverName = "promptframe-creation" + suffix;
27757
+ const serverName = antigravityServerName(profile);
27758
+ const pluginDirName = serverName;
27649
27759
  const dataRoot = path21.resolve(env.XDG_DATA_HOME ?? path21.join(homedir12(), ".local", "share"), "promptframe-creation", profile, "antigravity");
27650
27760
  const versionRoot = path21.join(dataRoot, "versions", payload.version);
27651
27761
  const pluginsRoot = path21.join(antigravityConfigRoot(env), "plugins");
@@ -27725,7 +27835,7 @@ async function installForAntigravityUser({
27725
27835
  displayName: profile === "default" ? "PromptFrame Creation" : "PromptFrame Creation (" + profile + ")"
27726
27836
  }), null, 2) + "\n";
27727
27837
  const mcpJson = JSON.stringify(antigravityMcpConfig({ serverName, nodeCommand, runtimeRoot: versionRoot, configFile: configFile2 }), null, 2) + "\n";
27728
- const hooksJson = JSON.stringify(antigravityHooksConfig({ nodeCommand, runtimeRoot: versionRoot, configFile: configFile2 }), null, 2) + "\n";
27838
+ const hooksJson = JSON.stringify(antigravityHooksConfig({ nodeCommand, runtimeRoot: versionRoot, configFile: configFile2, serverName }), null, 2) + "\n";
27729
27839
  await writeFileAtomic(path21.join(pluginDir, "plugin.json"), pluginJson, 420);
27730
27840
  await writeFileAtomic(path21.join(pluginDir, "mcp_config.json"), mcpJson, 384);
27731
27841
  await writeFileAtomic(path21.join(pluginDir, "hooks.json"), hooksJson, 384);
@@ -28061,18 +28171,20 @@ async function bridge() {
28061
28171
  try {
28062
28172
  if (command === "setup") await setup();
28063
28173
  else if (command === "connect" || command === "install") {
28174
+ const host = resolveHostIdentity({ host: value("--host") });
28175
+ const profile = value("--profile") ?? "default";
28176
+ if (host.kind === "antigravity") await checkAntigravityMcpConflicts({ profile, configFile: configFile() });
28064
28177
  const connection = await setup({ silent: true });
28065
28178
  const signal = new AbortController();
28066
28179
  const abort = () => signal.abort();
28067
28180
  process.once("SIGINT", abort);
28068
28181
  process.once("SIGTERM", abort);
28069
28182
  try {
28070
- const host = resolveHostIdentity({ host: value("--host") });
28071
28183
  const installer = host.kind === "claude-code" ? installForClaudeUser : host.kind === "antigravity" ? installForAntigravityUser : installForUser;
28072
28184
  const installed = await installer({
28073
28185
  sourceRoot: fileURLToPath(new URL("..", import.meta.url)),
28074
28186
  executable: value("--claude-bin"),
28075
- profile: value("--profile") ?? "default",
28187
+ profile,
28076
28188
  configFile: configFile(),
28077
28189
  signal: signal.signal
28078
28190
  });
@@ -28104,7 +28216,11 @@ try {
28104
28216
  }
28105
28217
  } else if (command === "bridge") await bridge();
28106
28218
  else if (command === "claude-host-hook") await runClaudeHostHook({ configFile: configFile() });
28107
- else if (command === "antigravity-host-hook") await runAntigravityHostHook({ configFile: configFile() });
28219
+ else if (command === "antigravity-host-hook") await runAntigravityHostHook({
28220
+ configFile: configFile(),
28221
+ serverName: value("--mcp-server"),
28222
+ event: value("--hook-event")
28223
+ });
28108
28224
  else if (command === "--version") process.stdout.write(CLIENT_VERSION + "\n");
28109
28225
  else if (command === "accounts") {
28110
28226
  if (args[0] === "refresh") {
@@ -28135,6 +28251,7 @@ try {
28135
28251
  process.stderr.write(
28136
28252
  JSON.stringify({
28137
28253
  ...installationErrorDetails(error6),
28254
+ ...antigravityInstallationDetails(error6),
28138
28255
  ...claudeInstallationDetails(error6),
28139
28256
  ...claudeErrorDetails(error6),
28140
28257
  ...fallbackErrorDetails(error6),
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": "creation-install-guidance/v1",
3
3
  "package": "@promptframe/creation",
4
- "version": "0.3.13",
4
+ "version": "0.3.14",
5
5
  "hosts": [
6
6
  {
7
7
  "kind": "codex",
@@ -6,7 +6,7 @@
6
6
 
7
7
  <!-- creation-install-command -->
8
8
  ```bash
9
- npx --yes @promptframe/creation@0.3.13 connect --endpoint <Studio提供的API地址>
9
+ npx --yes @promptframe/creation@0.3.14 connect --endpoint <Studio提供的API地址>
10
10
  ```
11
11
  <!-- /creation-install-command -->
12
12
 
@@ -26,7 +26,7 @@ npx --yes @promptframe/creation@0.3.13 connect --endpoint <Studio提供的API地
26
26
 
27
27
  <!-- creation-install-command -->
28
28
  ```bash
29
- npx --yes @promptframe/creation@0.3.13 connect --host claude-code --endpoint <Studio提供的API地址>
29
+ npx --yes @promptframe/creation@0.3.14 connect --host claude-code --endpoint <Studio提供的API地址>
30
30
  ```
31
31
  <!-- /creation-install-command -->
32
32
 
@@ -44,12 +44,14 @@ CLI 优先使用 PATH 中的 Claude;桌面版远程连接 WSL 时,也识别
44
44
 
45
45
  <!-- creation-install-command -->
46
46
  ```bash
47
- npx --yes @promptframe/creation@0.3.13 connect --host antigravity --endpoint <Studio提供的API地址>
47
+ npx --yes @promptframe/creation@0.3.14 connect --host antigravity --endpoint <Studio提供的API地址>
48
48
  ```
49
49
  <!-- /creation-install-command -->
50
50
 
51
51
  安装后检查 Antigravity 的 Customizations 中是否启用 PromptFrame Creation,再打开新对话。插件通过 `PreToolUse` 将调用绑定到实际对话,两个 Skill 和 MCP 工具由宿主加载。首次授权在终端隐藏输入,已有有效授权可复用。
52
52
 
53
+ 0.3.14 支持 Antigravity 默认的懒加载 MCP 调用。已有插件需重跑本段命令以更新注册的 hook,再开独立对话。如果安装报告 `installation.legacy_mcp_entry_requires_review`,在 Antigravity 的 MCP 设置核对清单所列的旧手工 PromptFrame 条目,移除冲突条目后重试。安装器保留全局文件和其他 MCP 配置。
54
+
53
55
  ## 环境与账号
54
56
 
55
57
  默认凭据沿用 `$XDG_CONFIG_HOME/promptframe-creation/credentials.json`(未配置 XDG 时位于用户 `.config`)。旧的 `PROMPTFRAME_CREATION_CONFIG` 仍可显式引用安全文件。
@@ -58,7 +60,7 @@ npx --yes @promptframe/creation@0.3.13 connect --host antigravity --endpoint <St
58
60
 
59
61
  <!-- creation-install-command -->
60
62
  ```bash
61
- npx --yes @promptframe/creation@0.3.13 connect --profile work-account --endpoint <另一环境API地址>
63
+ npx --yes @promptframe/creation@0.3.14 connect --profile work-account --endpoint <另一环境API地址>
62
64
  ```
63
65
  <!-- /creation-install-command -->
64
66
 
@@ -9,7 +9,11 @@ import {threadFormat} from './host-identity.mjs';
9
9
 
10
10
  const hex=/^[0-9a-f]{64}$/;
11
11
  const TICKET_TTL_MS=120_000;
12
+ const SESSION_TTL_MS=24*60*60*1000;
12
13
  const MAX_TICKETS=256;
14
+ const MAX_SESSIONS=256;
15
+ const DEFAULT_SERVER='promptframe-creation_promptframe-creation';
16
+ const mcpToolName=/^[A-Za-z0-9_.:-]{1,200}$/;
13
17
  const error=code=>new CreationClientError('creation.'+code);
14
18
  const canonical=value=>{
15
19
  if(value===null||typeof value==='string'||typeof value==='boolean'||typeof value==='number'&&Number.isFinite(value))return JSON.stringify(value);
@@ -21,9 +25,33 @@ const canonical=value=>{
21
25
  const digest=value=>createHash('sha256').update(canonical(value)).digest('hex');
22
26
  const withoutProof=args=>Object.fromEntries(Object.entries(args??{}).filter(([key])=>key!==CLAUDE_HOST_PROOF));
23
27
 
24
- function isPromptFrameToolName(name){
25
- if(typeof name!=='string'||!name||name.length>200)return false;
26
- return /(?:^|[_:])promptframe/i.test(name)||/^platform_[a-z0-9_]+$/i.test(name);
28
+ function objectArgs(value){
29
+ return value&&typeof value==='object'&&!Array.isArray(value)?value:null;
30
+ }
31
+ function promptFrameCall(toolCall,serverName){
32
+ if(typeof toolCall?.name!=='string')return null;
33
+ const args=objectArgs(toolCall.args)??{};
34
+ if(toolCall.name==='call_mcp_tool'){
35
+ if(args.ServerName!==serverName||typeof args.ToolName!=='string'||!mcpToolName.test(args.ToolName))return null;
36
+ const inner=args.Arguments===undefined?{}:objectArgs(args.Arguments);
37
+ return inner?{name:args.ToolName,args:inner,lazy:true}:null;
38
+ }
39
+ // Match the namespaced server, the former eager prefix, or a native
40
+ // PromptFrame tool name already reduced by the host.
41
+ const namespacedPrefix=`mcp_${serverName}_`,oldPrefix=`mcp_${serverName.split('_')[0]}_`;
42
+ if(toolCall.name.startsWith(namespacedPrefix)){
43
+ const name=toolCall.name.slice(namespacedPrefix.length);
44
+ return mcpToolName.test(name)?{name,args,lazy:false}:null;
45
+ }
46
+ const name=toolCall.name.startsWith(oldPrefix)?toolCall.name.slice(oldPrefix.length):toolCall.name;
47
+ return /^(?:platform_|promptframe_local_)[a-z0-9_]+$/i.test(name)&&mcpToolName.test(name)?{name,args,lazy:false}:null;
48
+ }
49
+ function sessionId(value){
50
+ return typeof value==='string'&&threadFormat.test(value)?value.toLowerCase():null;
51
+ }
52
+ function transcriptDigest(input){
53
+ const file=input?.transcriptPath;
54
+ return typeof file==='string'&&file.length<=4096&&path.isAbsolute(file)?digest(path.normalize(file)):null;
27
55
  }
28
56
  function toolNameMatches(hookToolName,bridgeToolName){
29
57
  if(typeof hookToolName!=='string'||typeof bridgeToolName!=='string'||!bridgeToolName)return false;
@@ -51,7 +79,7 @@ export function antigravityConfigRoot(env=process.env){
51
79
  /** Local host provenance for Antigravity. Supports multiple concurrent
52
80
  * conversations sharing one plugin MCP server process by binding each
53
81
  * one-use PreToolUse ticket to its conversationId UUID and exact arguments. */
54
- export async function createAntigravityHostSession({configFile,env=process.env,root,now=()=>Date.now()}={}){
82
+ export async function createAntigravityHostSession({configFile,env=process.env,root,serverName=DEFAULT_SERVER,now=()=>Date.now()}={}){
55
83
  const base=root??path.join(antigravityConfigRoot(env),'promptframe-host-sessions');
56
84
  const namespace=path.join(base,digest(path.resolve(configFile)));
57
85
  const stateFile=path.join(namespace,'state.json');
@@ -96,6 +124,19 @@ export async function createAntigravityHostSession({configFile,env=process.env,r
96
124
  return kept;
97
125
  }
98
126
 
127
+ function pruneSessions(sessions,currentTime){
128
+ const active=Object.entries(sessions??{}).filter(([id,value])=>sessionId(id)
129
+ &&Number.isSafeInteger(value?.expiresAt)&&value.expiresAt>currentTime);
130
+ return Object.fromEntries(active.slice(-MAX_SESSIONS));
131
+ }
132
+
133
+ function bindSession(sessions,id,transcript,currentTime){
134
+ const previous=sessions[id];
135
+ delete sessions[id];
136
+ sessions[id]={transcriptDigest:transcript??previous?.transcriptDigest??null,expiresAt:currentTime+SESSION_TTL_MS};
137
+ return pruneSessions(sessions,currentTime);
138
+ }
139
+
99
140
  async function begin(raw){
100
141
  const proof=raw.arguments?.[CLAUDE_HOST_PROOF],args=withoutProof(raw.arguments);
101
142
  if(proof===undefined)return {host:{kind:'antigravity'},assertCurrent:async()=>{},arguments:args};
@@ -106,7 +147,8 @@ export async function createAntigravityHostSession({configFile,env=process.env,r
106
147
  await transaction(current=>{
107
148
  const ticket=current.tickets[proof];
108
149
  if(!ticket||ticket.expiresAt<=currentTime||ticket.argsDigest!==argsHash
109
- ||!toolNameMatches(ticket.toolName,raw.name)||!threadFormat.test(ticket.conversationId??''))
150
+ ||!(ticket.exactToolName?ticket.toolName===raw.name:toolNameMatches(ticket.toolName,raw.name))
151
+ ||!threadFormat.test(ticket.conversationId??''))
110
152
  throw error('host_identity_invalid');
111
153
  accepted={threadId:ticket.conversationId.toLowerCase()};
112
154
  delete current.tickets[proof];
@@ -117,29 +159,38 @@ export async function createAntigravityHostSession({configFile,env=process.env,r
117
159
  return {host:{kind:'antigravity',threadId:accepted.threadId},arguments:args,assertCurrent:async()=>{}};
118
160
  }
119
161
 
120
- async function hook(input){
121
- const event=input?.hookEventName;
122
- // The installed command is scoped to PreToolUse. The host need not repeat
123
- // the event name in its stdin payload.
124
- if(event!==undefined&&event!=='PreToolUse')return {};
125
- const toolCall=input?.toolCall;
126
- if(!toolCall||typeof toolCall!=='object'||typeof toolCall.name!=='string')return {decision:'allow'};
127
- if(!isPromptFrameToolName(toolCall.name))return {decision:'allow'};
128
- const rawArgs=toolCall.args&&typeof toolCall.args==='object'&&!Array.isArray(toolCall.args)?toolCall.args:{};
129
- const conversationId=typeof input.conversationId==='string'&&threadFormat.test(input.conversationId)
130
- ?input.conversationId.toLowerCase():null;
131
- if(!conversationId){
132
- return Object.hasOwn(rawArgs,CLAUDE_HOST_PROOF)?{decision:'deny',reason:'Missing valid Antigravity conversationId for PromptFrame proof.'}:{decision:'allow'};
162
+ async function hook(input,event=input?.hookEventName??'PreToolUse'){
163
+ if(input?.hookEventName!==undefined&&input.hookEventName!==event)return {};
164
+ const id=sessionId(input?.conversationId),transcript=transcriptDigest(input),currentTime=now();
165
+ if(event==='SessionStart'){
166
+ if(id)await transaction(current=>{
167
+ current.sessions=bindSession(pruneSessions(current.sessions,currentTime),id,transcript,currentTime);
168
+ return current;
169
+ });
170
+ return {};
133
171
  }
134
- const args=withoutProof(rawArgs),argsHash=digest(args),currentTime=now();
172
+ if(event!=='PreToolUse')return {};
173
+ const call=promptFrameCall(input?.toolCall,serverName);
174
+ if(!call)return {decision:'allow'};
175
+ const args=withoutProof(call.args),argsHash=digest(args);
135
176
  let token;
136
177
  await transaction(current=>{
178
+ const sessions=pruneSessions(current.sessions,currentTime);
179
+ // SessionStart is a fallback only for an exact, unambiguous transcript.
180
+ // A shared bridge must never choose the most recently opened conversation.
181
+ const matches=!id&&input?.conversationId===undefined&&transcript
182
+ ?Object.keys(sessions).filter(key=>sessions[key].transcriptDigest===transcript):[];
183
+ const conversationId=id??(matches.length===1?matches[0]:null);
184
+ if(!conversationId)return;
137
185
  const tickets=pruneTickets(current.tickets,currentTime);
138
186
  token=randomBytes(32).toString('hex');
139
- tickets[token]={toolName:toolCall.name,argsDigest:argsHash,conversationId,expiresAt:currentTime+TICKET_TTL_MS};
140
- return {contractVersion:'antigravity-host-session/v1',tickets};
187
+ tickets[token]={toolName:call.name,exactToolName:true,argsDigest:argsHash,conversationId,expiresAt:currentTime+TICKET_TTL_MS};
188
+ return {contractVersion:'antigravity-host-session/v1',tickets,sessions:bindSession(sessions,conversationId,transcript,currentTime)};
141
189
  });
142
- return {decision:'allow',overwrite:{[CLAUDE_HOST_PROOF]:token}};
190
+ if(!token)return Object.hasOwn(call.args,CLAUDE_HOST_PROOF)
191
+ ?{decision:'deny',reason:'Missing valid Antigravity conversationId for PromptFrame proof.'}:{decision:'allow'};
192
+ return {decision:'allow',overwrite:call.lazy
193
+ ?{Arguments:{...args,[CLAUDE_HOST_PROOF]:token}}:{[CLAUDE_HOST_PROOF]:token}};
143
194
  }
144
195
 
145
196
  return {begin,hook};
@@ -152,8 +203,8 @@ export async function readAntigravityHookInput(input){
152
203
  return JSON.parse(new TextDecoder('utf-8',{fatal:true}).decode(Buffer.concat(chunks,bytes)));
153
204
  }
154
205
 
155
- export async function runAntigravityHostHook({configFile,input=process.stdin,output=process.stdout,env=process.env}={}){
206
+ export async function runAntigravityHostHook({configFile,serverName,event,input=process.stdin,output=process.stdout,env=process.env}={}){
156
207
  const body=await readAntigravityHookInput(input);
157
- const store=await createAntigravityHostSession({configFile,env});
158
- output.write(JSON.stringify(await store.hook(body))+'\n');
208
+ const store=await createAntigravityHostSession({configFile,serverName,env});
209
+ output.write(JSON.stringify(await store.hook(body,event))+'\n');
159
210
  }
@@ -1,4 +1,5 @@
1
1
  import {lstat,mkdir,open,readFile,rename,rm} from 'node:fs/promises';
2
+ import {constants} from 'node:fs';
2
3
  import {createHash,randomBytes} from 'node:crypto';
3
4
  import {homedir} from 'node:os';
4
5
  import path from 'node:path';
@@ -8,8 +9,58 @@ import {inspectRuntimePackage} from './runtime-package.mjs';
8
9
  import {antigravityConfigRoot} from './antigravity-host-session.mjs';
9
10
 
10
11
  const hash=b=>createHash('sha256').update(b).digest('hex');
11
- const fail=code=>{throw new CreationClientError('installation.'+code);};
12
+ class AntigravityInstallationError extends CreationClientError{
13
+ constructor(code,details){super('installation.'+code);this.details=details;}
14
+ }
15
+ export const antigravityInstallationDetails=error=>error instanceof AntigravityInstallationError?error.details:undefined;
16
+ const fail=(code,details)=>{throw new AntigravityInstallationError(code,details);};
12
17
  const profileFormat=/^[a-z0-9][a-z0-9-]{0,39}$/;
18
+ const antigravityServerName=profile=>'promptframe-creation'+(profile==='default'?'':'-'+profile);
19
+ const object=value=>value!==null&&typeof value==='object'&&!Array.isArray(value);
20
+
21
+ function usesCreationBridge(server,{profile,configFile}){
22
+ if(!object(server)||typeof server.command!=='string'||!Array.isArray(server.args))return false;
23
+ const args=server.args;
24
+ const bridgeIndex=args.indexOf('bridge');
25
+ if(bridgeIndex<0)return false;
26
+ const isCreationExecutable=value=>typeof value==='string'&&/^promptframe-creation(?:\.mjs|\.cmd|\.exe)?$/.test(path.win32.basename(value));
27
+ const command=path.win32.basename(server.command);
28
+ const bridgeLauncher=isCreationExecutable(command)||
29
+ (/^(?:node|nodejs|bun)(?:\.exe)?$/.test(command)&&isCreationExecutable(args[bridgeIndex-1]))||
30
+ (/^(?:npx|npm|pnpm|yarn|bunx)(?:\.cmd|\.exe)?$/.test(command)&&
31
+ typeof args[bridgeIndex-1]==='string'&&/^@promptframe\/creation(?:@[^\s]+)?$/.test(args[bridgeIndex-1]));
32
+ if(!bridgeLauncher)return false;
33
+
34
+ const configIndex=args.indexOf('--config',bridgeIndex+1);
35
+ const profileIndex=args.indexOf('--profile',bridgeIndex+1);
36
+ const configuredProfile=profileIndex<0?'default':args[profileIndex+1];
37
+ const configuredFile=configIndex>=0?args[configIndex+1]:configuredProfile==='default'?server.env?.PROMPTFRAME_CREATION_CONFIG:undefined;
38
+ if(typeof configuredFile==='string'&&path.isAbsolute(configuredFile))return path.resolve(configuredFile)===configFile;
39
+ return configuredProfile===profile;
40
+ }
41
+
42
+ export async function checkAntigravityMcpConflicts({profile='default',configFile,env=process.env}={}){
43
+ const mcpConfigFile=path.join(antigravityConfigRoot(env),'mcp_config.json');
44
+ const unreadable=()=>fail('antigravity_mcp_config_unreadable',{mcpConfigFile,
45
+ action:'Check that the Antigravity MCP configuration is readable and contains a valid JSON object, then retry connect.'});
46
+ let file;
47
+ try{file=await open(mcpConfigFile,constants.O_RDONLY|constants.O_NONBLOCK);}
48
+ catch(error){if(error.code==='ENOENT')return;unreadable();}
49
+ let config;
50
+ try{
51
+ const info=await file.stat();
52
+ if(!info.isFile()||info.size>4*1024*1024)unreadable();
53
+ config=JSON.parse(await file.readFile('utf8'));
54
+ }catch{unreadable();}finally{await file.close();}
55
+ if(!object(config)||config.mcpServers!==undefined&&!object(config.mcpServers))unreadable();
56
+ const serverName=antigravityServerName(profile);
57
+ const mcpServerNames=Object.entries(config.mcpServers??{})
58
+ .filter(([name,server])=>name===serverName||name===`${serverName}_${serverName}`
59
+ ||profile==='default'&&name==='promptframe'||usesCreationBridge(server,{profile,configFile}))
60
+ .map(([name])=>name);
61
+ if(mcpServerNames.length)fail('legacy_mcp_entry_requires_review',{mcpConfigFile,mcpServerNames,
62
+ action:'In Antigravity MCP settings, review the listed entries and remove the conflicting manual PromptFrame entries, then rerun connect with the existing Token.'});
63
+ }
13
64
 
14
65
  function shellQuote(value){
15
66
  return '"'+String(value).replace(/(["\\$`])/g,'\\$1')+'"';
@@ -41,15 +92,17 @@ export function antigravityMcpConfig({serverName,nodeCommand,runtimeRoot,configF
41
92
  };
42
93
  }
43
94
 
44
- export function antigravityHooksConfig({nodeCommand,runtimeRoot,configFile}){
95
+ export function antigravityHooksConfig({nodeCommand,runtimeRoot,configFile,serverName}){
45
96
  const cliPath=path.join(runtimeRoot,'bin','promptframe-creation.mjs');
46
- const command=[shellQuote(nodeCommand),shellQuote(cliPath),'antigravity-host-hook','--config',shellQuote(configFile)].join(' ');
97
+ const command=[shellQuote(nodeCommand),shellQuote(cliPath),'antigravity-host-hook','--config',shellQuote(configFile),
98
+ '--mcp-server',shellQuote(`${serverName}_${serverName}`)].join(' ');
47
99
  return {
48
100
  'promptframe-host-identity':{
101
+ SessionStart:[{type:'command',command:command+' --hook-event SessionStart',timeout:5}],
49
102
  PreToolUse:[
50
103
  {
51
- matcher:'(.*promptframe.*|^platform_.*)',
52
- hooks:[{type:'command',command,timeout:5}],
104
+ matcher:'(.*promptframe.*|^platform_.*|^call_mcp_tool$)',
105
+ hooks:[{type:'command',command:command+' --hook-event PreToolUse',timeout:5}],
53
106
  },
54
107
  ],
55
108
  },
@@ -97,10 +150,10 @@ export async function installForAntigravityUser({
97
150
  if(!profileFormat.test(profile))fail('profile_invalid');
98
151
  if(!path.isAbsolute(configFile??''))fail('config_path_invalid');
99
152
  signal?.throwIfAborted();
153
+ await checkAntigravityMcpConflicts({profile,configFile,env});
100
154
  const payload=await inspectRuntimePackage(sourceRoot);
101
- const suffix=profile==='default'?'':'-'+profile;
102
- const pluginDirName='promptframe-creation'+suffix;
103
- const serverName='promptframe-creation'+suffix;
155
+ const serverName=antigravityServerName(profile);
156
+ const pluginDirName=serverName;
104
157
  const dataRoot=path.resolve(env.XDG_DATA_HOME??path.join(homedir(),'.local','share'),'promptframe-creation',profile,'antigravity');
105
158
  const versionRoot=path.join(dataRoot,'versions',payload.version);
106
159
  const pluginsRoot=path.join(antigravityConfigRoot(env),'plugins');
@@ -151,7 +204,7 @@ export async function installForAntigravityUser({
151
204
  displayName:profile==='default'?'PromptFrame Creation':'PromptFrame Creation ('+profile+')',
152
205
  }),null,2)+'\n';
153
206
  const mcpJson=JSON.stringify(antigravityMcpConfig({serverName,nodeCommand,runtimeRoot:versionRoot,configFile}),null,2)+'\n';
154
- const hooksJson=JSON.stringify(antigravityHooksConfig({nodeCommand,runtimeRoot:versionRoot,configFile}),null,2)+'\n';
207
+ const hooksJson=JSON.stringify(antigravityHooksConfig({nodeCommand,runtimeRoot:versionRoot,configFile,serverName}),null,2)+'\n';
155
208
 
156
209
  await writeFileAtomic(path.join(pluginDir,'plugin.json'),pluginJson,0o644);
157
210
  await writeFileAtomic(path.join(pluginDir,'mcp_config.json'),mcpJson,0o600);
package/lib/cli.mjs CHANGED
@@ -33,7 +33,7 @@ import {selectBridgeRuntime,runtimeErrorDetails} from './runtime-bootstrap.mjs';
33
33
  import {launchSelectedBridge} from './runtime-launch.mjs';
34
34
  import {installForUser,profileCredentialsPath,installationErrorDetails} from './user-installation.mjs';
35
35
  import {installForClaudeUser,claudeInstallationDetails} from './claude-installation.mjs';
36
- import {installForAntigravityUser} from './antigravity-installation.mjs';
36
+ import {antigravityInstallationDetails,checkAntigravityMcpConflicts,installForAntigravityUser} from './antigravity-installation.mjs';
37
37
  import {claudeErrorDetails} from './claude-command.mjs';
38
38
  import {fallbackErrorDetails} from './claude-mcp-installation.mjs';
39
39
  import {fileURLToPath} from 'node:url';
@@ -310,14 +310,16 @@ async function bridge() {
310
310
  try {
311
311
  if (command === "setup") await setup();
312
312
  else if(command==='connect'||command==='install'){
313
+ const host=resolveHostIdentity({host:value('--host')});
314
+ const profile=value('--profile')??'default';
315
+ if(host.kind==='antigravity')await checkAntigravityMcpConflicts({profile,configFile:configFile()});
313
316
  const connection=await setup({silent:true});
314
317
  const signal=new AbortController();
315
318
  const abort=()=>signal.abort();process.once('SIGINT',abort);process.once('SIGTERM',abort);
316
319
  try{
317
- const host=resolveHostIdentity({host:value('--host')});
318
320
  const installer=host.kind==='claude-code'?installForClaudeUser:host.kind==='antigravity'?installForAntigravityUser:installForUser;
319
321
  const installed=await installer({sourceRoot:fileURLToPath(new URL('..',import.meta.url)),
320
- executable:value('--claude-bin'),profile:value('--profile')??'default',configFile:configFile(),signal:signal.signal});
322
+ executable:value('--claude-bin'),profile,configFile:configFile(),signal:signal.signal});
321
323
  const skillNames=installed.skills?.map(skill=>skill.name)??['creation-setup','video-creation'];
322
324
  const nextStep=host.kind==='claude-code'
323
325
  ?'On this host, start a new Claude Code session.'
@@ -339,7 +341,8 @@ try {
339
341
  }
340
342
  else if (command === "bridge") await bridge();
341
343
  else if(command==='claude-host-hook')await runClaudeHostHook({configFile:configFile()});
342
- else if(command==='antigravity-host-hook')await runAntigravityHostHook({configFile:configFile()});
344
+ else if(command==='antigravity-host-hook')await runAntigravityHostHook({configFile:configFile(),
345
+ serverName:value('--mcp-server'),event:value('--hook-event')});
343
346
  else if(command==='--version')process.stdout.write(CLIENT_VERSION+'\n');
344
347
  else if(command==='accounts'){
345
348
  if(args[0]==='refresh'){
@@ -372,6 +375,7 @@ try {
372
375
  process.stderr.write(
373
376
  JSON.stringify({
374
377
  ...installationErrorDetails(error),
378
+ ...antigravityInstallationDetails(error),
375
379
  ...claudeInstallationDetails(error),
376
380
  ...claudeErrorDetails(error),
377
381
  ...fallbackErrorDetails(error),
package/lib/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const CLIENT_VERSION = "0.3.13";
1
+ export const CLIENT_VERSION = "0.3.14";
2
2
  export const CLIENT_PROTOCOL = "creation-client/v1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptframe/creation",
3
- "version": "0.3.13",
3
+ "version": "0.3.14",
4
4
  "private": false,
5
5
  "description": "PromptFrame video creation Skill, Codex plugin and MCP client bridge.",
6
6
  "repository": {
@@ -10,15 +10,15 @@ description: 安装、连接或升级 PromptFrame Creation,复用平台创作
10
10
  先确认使用 Codex、Claude Code 或 Antigravity。各宿主可共用同一 profile 凭据,插件登记分别核实。使用 Studio 对当前环境提供的固定版本。Claude 桌面版远程连接 WSL 时,在同一 WSL 安装;没有终端命令时可通过 `--claude-bin <实际可执行文件>` 指定桌面版提供的入口。
11
11
 
12
12
  <!-- creation-install-command -->
13
- 在用户本机终端运行 `npx --yes @promptframe/creation@0.3.13 connect --endpoint <Studio提供的API地址>`。需要隔离另一个环境或账号时显式加 `--profile <用户选择的名称>`;正在运行的桥不会切换。此命令管理用户级版本和 Codex 插件,不向当前项目安装依赖。优先使用 Studio 当前提供的固定推荐版本;每次重新进入此入口比较已安装版本,不后台追踪 latest,也不把旧聊天里的命令当最新版本。已安装更新版不默认降级。
13
+ 在用户本机终端运行 `npx --yes @promptframe/creation@0.3.14 connect --endpoint <Studio提供的API地址>`。需要隔离另一个环境或账号时显式加 `--profile <用户选择的名称>`;正在运行的桥不会切换。此命令管理用户级版本和 Codex 插件,不向当前项目安装依赖。优先使用 Studio 当前提供的固定推荐版本;每次重新进入此入口比较已安装版本,不后台追踪 latest,也不把旧聊天里的命令当最新版本。已安装更新版不默认降级。
14
14
  <!-- /creation-install-command -->
15
15
 
16
16
  <!-- creation-install-command -->
17
- Claude Code 使用 `npx --yes @promptframe/creation@0.3.13 connect --host claude-code --endpoint <Studio提供的API地址>`。桌面版远程连接 WSL 时,在该 WSL 执行;保留相同 profile 和有效凭据。
17
+ Claude Code 使用 `npx --yes @promptframe/creation@0.3.14 connect --host claude-code --endpoint <Studio提供的API地址>`。桌面版远程连接 WSL 时,在该 WSL 执行;保留相同 profile 和有效凭据。
18
18
  <!-- /creation-install-command -->
19
19
 
20
20
  <!-- creation-install-command -->
21
- Antigravity 使用 `npx --yes @promptframe/creation@0.3.13 connect --host antigravity --endpoint <Studio提供的API地址>`。在同一主机核对插件已启用,再打开新对话。
21
+ Antigravity 使用 `npx --yes @promptframe/creation@0.3.14 connect --host antigravity --endpoint <Studio提供的API地址>`。在同一主机核对插件已启用,再打开新对话。
22
22
  <!-- /creation-install-command -->
23
23
 
24
24
  命令会复用并验证有效凭据。首次授权或明确更换已失效凭据时,由用户在 Studio 登录并在终端的不回显输入框提供 Token;不要要求用户把 Token 粘进聊天,也不要把它写进命令参数、URL或日志。网络失败不等于授权失效,不自动轮换或覆盖凭据。