@promptframe/creation 0.3.11 → 0.3.13

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.
@@ -1,7 +1,7 @@
1
1
  import {LOCAL_UPLOAD_PROTOCOL} from './local-upload.mjs';
2
2
  import {createHash} from 'node:crypto';
3
3
  import {CreationClientError} from './credentials.mjs';
4
- import {hostParameters,resolveHostIdentity} from './host-identity.mjs';
4
+ import {hostParameters,isHookProofHost,resolveHostIdentity} from './host-identity.mjs';
5
5
  import {assertMcpResponseBudget} from './content-budget.mjs';
6
6
  import {CLAUDE_HOST_PROOF} from './claude-host-session.mjs';
7
7
  import {readDevelopmentPairingFile} from './development-pairing.mjs';
@@ -25,10 +25,10 @@ const boundedSet=(map,key,value)=>{if(!map.has(key)&&map.size>=1024)map.delete(m
25
25
  export async function resolveHostCallBinding(raw,{host=resolveHostIdentity(),hostSession}={}){
26
26
  for(const field of ['threadId','controller','clientDigest','token','controlVersion','developmentPairing'])if(Object.hasOwn(raw.arguments??{},field))
27
27
  throw new CreationClientError('creation.transport_authority_managed_by_bridge');
28
- if(host.kind==='claude-code'){
28
+ if(isHookProofHost(host.kind)){
29
29
  if(hostSession)return hostSession.begin(raw);
30
30
  if(raw.arguments?.[CLAUDE_HOST_PROOF]!==undefined)throw new CreationClientError('creation.host_identity_invalid');
31
- return{host:{kind:'claude-code'},arguments:raw.arguments,assertCurrent:async()=>{}};
31
+ return{host:{kind:host.kind},arguments:raw.arguments,assertCurrent:async()=>{}};
32
32
  }
33
33
  if(Object.hasOwn(raw.arguments??{},CLAUDE_HOST_PROOF))throw new CreationClientError('creation.transport_authority_managed_by_bridge');
34
34
  hostParameters(raw,host,'independent-read');
@@ -104,7 +104,7 @@ export function createHostCallBridge(client,{credentials,host=resolveHostIdentit
104
104
  if(!schema||schema.type!=='object')throw new CreationClientError('creation.upgrade_required');
105
105
  const p=schema.properties;
106
106
  const {controlVersion:_managed,developmentPairing:_privatePairing,...properties}=p??{};
107
- return {...tool,inputSchema:{...schema,properties:{...properties,...(host.kind==='claude-code'?{
107
+ return {...tool,inputSchema:{...schema,properties:{...properties,...(isHookProofHost(host.kind)?{
108
108
  [CLAUDE_HOST_PROOF]:{type:'string',pattern:'^[a-f0-9]{64}$',description:'由当前宿主hook填入的单次身份凭证;请保留,不自行填写。'}
109
109
  }:{})},...(schema.required
110
110
  ?{required:schema.required.filter(name=>name!=='controlVersion')}:{})}};
@@ -129,7 +129,7 @@ export function createHostCallBridge(client,{credentials,host=resolveHostIdentit
129
129
  }
130
130
  async function knowledgeRead(kind,method,raw={}){
131
131
  if(!upstream[kind])throw new CreationClientError('creation.knowledge_unsupported');
132
- const params=hostParameters(raw,host.kind==='claude-code'?{kind:host.kind}:host,'independent-read'),order=++sequence;
132
+ const params=hostParameters(raw,isHookProofHost(host.kind)?{kind:host.kind}:host,'independent-read'),order=++sequence;
133
133
  const result=assertMcpResponseBudget(await client[method](params,undefined,{timeout:60000}));
134
134
  const version=result._meta?.[kind==='resources'&&method==='listResources'
135
135
  ?'promptframe.guideDirectoryVersion':'promptframe.guideVersion'];
@@ -1,18 +1,25 @@
1
1
  import {CreationClientError} from './credentials.mjs';
2
2
 
3
+ export const SUPPORTED_HOSTS=Object.freeze(['codex','claude-code','antigravity']);
4
+ export const isHookProofHost=kind=>kind==='claude-code'||kind==='antigravity';
5
+ const DEFAULT_CLIENT_NAMES=Object.freeze({
6
+ codex:'Codex PromptFrame',
7
+ 'claude-code':'Claude Code PromptFrame',
8
+ antigravity:'Antigravity PromptFrame',
9
+ });
10
+
3
11
  export function hostClientName(savedName,host){
4
- return ['Codex PromptFrame','Claude Code PromptFrame'].includes(savedName)
5
- ?host.kind==='claude-code'?'Claude Code PromptFrame':'Codex PromptFrame':savedName;
12
+ return Object.values(DEFAULT_CLIENT_NAMES).includes(savedName)
13
+ ?(DEFAULT_CLIENT_NAMES[host.kind]??DEFAULT_CLIENT_NAMES.codex):savedName;
6
14
  }
7
15
 
8
16
  export const threadFormat=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
9
17
 
10
- // Select the transport kind, not a controller. Claude's startup environment
11
- // can remain stale after /clear; only a current host-hook call binds its UUID.
18
+ // Select the transport kind, not a controller. Startup environments can remain
19
+ // stale across sessions; hook-proof hosts bind each call via PreToolUse hook.
12
20
  export function resolveHostIdentity({host,env=process.env}={}){
13
21
  const kind=host??(env.CLAUDECODE==='1'?'claude-code':'codex');
14
- if(!['codex','claude-code'].includes(kind))throw new CreationClientError('creation.host_unsupported');
15
- if(kind==='codex')return Object.freeze({kind});
22
+ if(!SUPPORTED_HOSTS.includes(kind))throw new CreationClientError('creation.host_unsupported');
16
23
  return Object.freeze({kind});
17
24
  }
18
25
 
@@ -20,7 +27,7 @@ export function hostParameters(params,host,access){
20
27
  const meta=params._meta??{};
21
28
  if(Object.keys(meta).some(key=>key.startsWith('promptframe.')||['controlVersion','controller','clientDigest','token','catalogVersion','platformDigest'].includes(key)))
22
29
  throw new CreationClientError('creation.transport_authority_managed_by_bridge');
23
- if(host.kind==='claude-code'){
30
+ if(isHookProofHost(host.kind)){
24
31
  if(Object.hasOwn(meta,'threadId'))throw new CreationClientError('creation.transport_authority_managed_by_bridge');
25
32
  if(!host.threadId){if(access==='independent-read')return params;throw new CreationClientError('creation.host_identity_unavailable');}
26
33
  return {...params,_meta:{...meta,threadId:host.threadId}};
@@ -1,5 +1,5 @@
1
1
  import { constants } from 'node:fs';
2
- import { open, lstat, mkdir, rename, unlink, opendir } from 'node:fs/promises';
2
+ import { open, lstat, mkdir, rename, unlink, opendir,link } from 'node:fs/promises';
3
3
  import { homedir } from 'node:os';
4
4
  import path from 'node:path';
5
5
  import { createHash, randomUUID } from 'node:crypto';
@@ -221,7 +221,7 @@ async function listAccounts({ root = localAccountsRoot(), now = Date.now() } = {
221
221
  }
222
222
 
223
223
  export function localAgentDigest(agent) {
224
- if (!agent || !['codex', 'claude-code'].includes(agent.kind) || typeof agent.sessionId !== 'string'
224
+ if (!agent || !['codex', 'claude-code', 'antigravity'].includes(agent.kind) || typeof agent.sessionId !== 'string'
225
225
  || !threadFormat.test(agent.sessionId)) throw failure('agent_required');
226
226
  return hash(JSON.stringify([agent.kind, agent.sessionId.toLowerCase()]));
227
227
  }
@@ -261,3 +261,31 @@ export const readLocalAuthorizations = accountIO(readAuthorizations);
261
261
  export const listLocalAccounts = accountIO(listAccounts);
262
262
  export const selectLocalAccount = accountIO(selectAccount);
263
263
  export const readSelectedLocalAccount = accountIO(readSelectedAccount);
264
+
265
+ /** Optional, resettable display identity. It is scoped to the authenticated
266
+ * account and this configuration, never a machine fingerprint or credential. */
267
+ async function clientObservationInstance({root=localAccountsRoot(),identity,configFile}){
268
+ identity=parseAccountIdentity(identity);
269
+ if(typeof configFile!=='string'||!path.isAbsolute(configFile))throw failure('reference_invalid');
270
+ const parent=await ownedPath(root,['client-observations','v1',identity.platformDigest.slice(7),identity.accountDigest.slice(7)],true);
271
+ const file=path.join(parent,localReferenceId('creation',path.resolve(configFile)).slice(7)+'.json');
272
+ const parse=value=>{
273
+ if(!plain(value)||Object.keys(value).sort().join(',')!=='contractVersion,instanceId'
274
+ ||value.contractVersion!=='promptframe-client-instance/v1'||typeof value.instanceId!=='string'
275
+ ||!/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(value.instanceId))throw failure('record_invalid');
276
+ return value.instanceId;
277
+ };
278
+ const existing=await readJson(file);if(existing)return parse(existing);
279
+ const value={contractVersion:'promptframe-client-instance/v1',instanceId:randomUUID()};
280
+ const temporary=path.join(parent,'.'+randomUUID()+'.tmp');let fd;
281
+ try{fd=await open(temporary,constants.O_WRONLY|constants.O_CREAT|constants.O_EXCL|constants.O_NOFOLLOW,0o600);
282
+ await fd.writeFile(JSON.stringify(value)+'\n');await fd.sync();await fd.close();fd=undefined;
283
+ // Publish complete bytes without replacing another process's instance.
284
+ await link(temporary,file);
285
+ const directoryHandle=await open(parent,constants.O_RDONLY|constants.O_DIRECTORY|constants.O_NOFOLLOW);
286
+ try{privateOwner(await directoryHandle.stat(),true);await directoryHandle.sync();}finally{await directoryHandle.close();}
287
+ return value.instanceId;
288
+ }catch(error){if(error.code==='EEXIST')return parse(await readJson(file));throw error;}
289
+ finally{await fd?.close();await unlink(temporary).catch(error=>{if(error.code!=='ENOENT')throw error;});}
290
+ }
291
+ export const localClientObservationInstance=accountIO(clientObservationInstance);
@@ -7,6 +7,7 @@ import {promisify} from 'node:util';
7
7
  import path from 'node:path';
8
8
  import {CreationClientError} from './credentials.mjs';
9
9
  import {compareBridgeVersions,assertBridgeCompatible,readPlatformBridgePolicy} from './bridge-negotiation.mjs';
10
+ import {SUPPORTED_HOSTS} from './host-identity.mjs';
10
11
  import {inspectRuntimePackage,RUNTIME_PACKAGE_ENTRIES,OPTIONAL_HOST_ENTRIES} from './runtime-package.mjs';
11
12
 
12
13
  const PACKAGE='@promptframe/creation',REGISTRY='https://registry.npmjs.org';
@@ -132,7 +133,7 @@ async function checkedVersionIndex(cacheRoot,metadata){
132
133
  }
133
134
 
134
135
  export async function prepareVerifiedRuntime(metadata,{cacheRoot,fetchImpl=fetch,signal,checkRuntime,hostKind='codex'}={}){
135
- if(!['codex','claude-code'].includes(hostKind))throw error('runtime_host_unsupported');
136
+ if(!SUPPORTED_HOSTS.includes(hostKind))throw error('runtime_host_unsupported');
136
137
  if(!path.isAbsolute(cacheRoot??''))throw error('runtime_cache_owner_invalid');
137
138
  metadata=checkedRuntimeMetadata({name:PACKAGE,version:metadata.version,dist:metadata},metadata.version);
138
139
  await privateDirectory(cacheRoot);
@@ -1,12 +1,13 @@
1
1
  import {spawn} from 'node:child_process';
2
2
  import path from 'node:path';
3
3
  import {CreationClientError} from './credentials.mjs';
4
+ import {SUPPORTED_HOSTS} from './host-identity.mjs';
4
5
 
5
6
  /** Relay a new session once, before this process has consumed host stdio.
6
7
  * After spawning, any failure belongs to that runtime; it never respawns or
7
8
  * falls back to another bridge which could replay an accepted business call. */
8
9
  export async function launchSelectedBridge(selection,{host,configFile,spawnImpl=spawn,env=process.env}={}){
9
- if(!path.isAbsolute(selection.root??'')||!path.isAbsolute(configFile??'')||!['codex','claude-code'].includes(host?.kind))
10
+ if(!path.isAbsolute(selection.root??'')||!path.isAbsolute(configFile??'')||!SUPPORTED_HOSTS.includes(host?.kind))
10
11
  throw new CreationClientError('creation.runtime_launch_invalid');
11
12
  let child;
12
13
  try{child=spawnImpl(process.execPath,[path.join(selection.root,'bin/promptframe-creation.mjs'),'bridge',
@@ -36,6 +36,8 @@ export async function inspectRuntimePackage(root,{entries}={}){
36
36
  if(pkg.name!=='@promptframe/creation'||!/^\d+\.\d+\.\d+$/.test(pkg.version)||plugin.version!==pkg.version)invalid('package_identity_invalid');
37
37
  const claude=files.find(f=>f.path==='.claude-plugin/plugin.json');
38
38
  if(claude&&JSON.parse(claude.body).version!==pkg.version)invalid('package_identity_invalid');
39
- return{files,version:pkg.version,hosts:claude?['codex','claude-code']:['codex'],
39
+ const antigravity=files.some(f=>f.path==='lib/antigravity-host-session.mjs');
40
+ const hosts=['codex',...(claude?['claude-code']:[]),...(antigravity?['antigravity']:[])];
41
+ return{files,version:pkg.version,hosts,
40
42
  payloadDigest:hash(JSON.stringify(files.map(({path,bytes,sha256})=>({path,bytes,sha256}))))};
41
43
  }
package/lib/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const CLIENT_VERSION = "0.3.11";
1
+ export const CLIENT_VERSION = "0.3.13";
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.11",
3
+ "version": "0.3.13",
4
4
  "private": false,
5
5
  "description": "PromptFrame video creation Skill, Codex plugin and MCP client bridge.",
6
6
  "repository": {
@@ -1,20 +1,24 @@
1
1
  ---
2
2
  name: creation-setup
3
- description: 安装、连接或升级 PromptFrame Creation,复用平台创作授权并检查 Codex 或 Claude Code 的 Skill 和 MCP 加载。已有连接的普通视频创作使用 video-creation。
3
+ description: 安装、连接或升级 PromptFrame Creation,复用平台创作授权并检查 Codex、Claude Code 或 Antigravity 的 Skill 和 MCP 加载。已有连接的普通视频创作使用 video-creation。
4
4
  ---
5
5
 
6
6
  # 连接 PromptFrame
7
7
 
8
8
  使用 Studio“连接与授权”提供的完整 API 地址及公开安装入口。保留用户当前环境的 origin 和 `/api`,不替换成 localhost,不从旧聊天猜另一账号或环境。
9
9
 
10
- 先确认使用 Codex 还是 Claude Code。Claude 接入使用 `connect --host claude-code`,两种宿主可共用同一 profile 凭据,插件登记分别核实。使用 Studio 对当前环境提供的固定版本;旧版入口不会因平台更新自动改变。Claude 桌面版远程连接 WSL 时,在同一 WSL 安装;没有终端命令时可通过 `--claude-bin <实际可执行文件>` 指定桌面版提供的入口,不固定桌面构建文件名。
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.11 connect --endpoint <Studio提供的API地址>`。需要隔离另一个环境或账号时显式加 `--profile <用户选择的名称>`;正在运行的桥不会切换。此命令管理用户级版本和 Codex 插件,不向当前项目安装依赖。优先使用 Studio 当前提供的固定推荐版本;每次重新进入此入口比较已安装版本,不后台追踪 latest,也不把旧聊天里的命令当最新版本。已安装更新版不默认降级。
13
+ 在用户本机终端运行 `npx --yes @promptframe/creation@0.3.13 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.11 connect --host claude-code --endpoint <Studio提供的API地址>`。桌面版远程连接 WSL 时,在该 WSL 执行;保留相同 profile 和有效凭据。
17
+ Claude Code 使用 `npx --yes @promptframe/creation@0.3.13 connect --host claude-code --endpoint <Studio提供的API地址>`。桌面版远程连接 WSL 时,在该 WSL 执行;保留相同 profile 和有效凭据。
18
+ <!-- /creation-install-command -->
19
+
20
+ <!-- creation-install-command -->
21
+ Antigravity 使用 `npx --yes @promptframe/creation@0.3.13 connect --host antigravity --endpoint <Studio提供的API地址>`。在同一主机核对插件已启用,再打开新对话。
18
22
  <!-- /creation-install-command -->
19
23
 
20
24
  命令会复用并验证有效凭据。首次授权或明确更换已失效凭据时,由用户在 Studio 登录并在终端的不回显输入框提供 Token;不要要求用户把 Token 粘进聊天,也不要把它写进命令参数、URL或日志。网络失败不等于授权失效,不自动轮换或覆盖凭据。