@promptframe/creation 0.3.12 → 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.
- package/.agents/plugins/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +3 -1
- package/dist/cli.mjs +1070 -646
- package/docs/install-guidance.json +15 -1
- package/docs/installing.md +15 -3
- package/lib/account-bridge.mjs +3 -2
- package/lib/antigravity-host-session.mjs +159 -0
- package/lib/antigravity-installation.mjs +200 -0
- package/lib/cli.mjs +20 -6
- package/lib/connection.mjs +1 -1
- package/lib/host-context.mjs +5 -5
- package/lib/host-identity.mjs +14 -7
- package/lib/local-accounts.mjs +1 -1
- package/lib/runtime-bootstrap.mjs +2 -1
- package/lib/runtime-launch.mjs +2 -1
- package/lib/runtime-package.mjs +3 -1
- package/lib/version.mjs +1 -1
- package/package.json +1 -1
- package/skills/creation-setup/SKILL.md +8 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": "creation-install-guidance/v1",
|
|
3
3
|
"package": "@promptframe/creation",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.13",
|
|
5
5
|
"hosts": [
|
|
6
6
|
{
|
|
7
7
|
"kind": "codex",
|
|
@@ -28,6 +28,20 @@
|
|
|
28
28
|
"{{endpoint}}"
|
|
29
29
|
],
|
|
30
30
|
"nextSession": "在同一主机开始新的 Claude Code session;桌面版远程连接 WSL 时在该 WSL 安装。"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"kind": "antigravity",
|
|
34
|
+
"name": "Antigravity",
|
|
35
|
+
"minimumBridge": "0.3.13",
|
|
36
|
+
"requirements": "Node.js 20+ 与支持本地插件及 PreToolUse 的 Google Antigravity;在支持 POSIX 文件权限的宿主安装",
|
|
37
|
+
"commandArgs": [
|
|
38
|
+
"connect",
|
|
39
|
+
"--host",
|
|
40
|
+
"antigravity",
|
|
41
|
+
"--endpoint",
|
|
42
|
+
"{{endpoint}}"
|
|
43
|
+
],
|
|
44
|
+
"nextSession": "在同一主机打开新的 Antigravity 对话(或在 Customizations 确认 promptframe-creation 插件已启用)。"
|
|
31
45
|
}
|
|
32
46
|
],
|
|
33
47
|
"versionInstructions": "比较已安装版本:同版本复用,更新版本不降级;待升级或 Node 不可用时按明确指引处理,不把旧版复用当作升级成功。",
|
package/docs/installing.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
<!-- creation-install-command -->
|
|
8
8
|
```bash
|
|
9
|
-
npx --yes @promptframe/creation@0.3.
|
|
9
|
+
npx --yes @promptframe/creation@0.3.13 connect --endpoint <Studio提供的API地址>
|
|
10
10
|
```
|
|
11
11
|
<!-- /creation-install-command -->
|
|
12
12
|
|
|
@@ -26,7 +26,7 @@ npx --yes @promptframe/creation@0.3.12 connect --endpoint <Studio提供的API地
|
|
|
26
26
|
|
|
27
27
|
<!-- creation-install-command -->
|
|
28
28
|
```bash
|
|
29
|
-
npx --yes @promptframe/creation@0.3.
|
|
29
|
+
npx --yes @promptframe/creation@0.3.13 connect --host claude-code --endpoint <Studio提供的API地址>
|
|
30
30
|
```
|
|
31
31
|
<!-- /creation-install-command -->
|
|
32
32
|
|
|
@@ -38,6 +38,18 @@ CLI 优先使用 PATH 中的 Claude;桌面版远程连接 WSL 时,也识别
|
|
|
38
38
|
|
|
39
39
|
启动帮助明确不提供插件命令时,安装器使用官方 user-scope MCP 登记并准备两份用户 Skill。返回 `installationMode: mcp-and-skills`、`pluginInstalled: false` 与实际 Skill 名称;不同 profile 分开命名,原凭据保持。MCP 写后从本地配置核回,不通过 `mcp list/get` 启动健康检查。已有陌生 MCP/Skill 或未确认的插件安装不会转到备用路径;备用 MCP 的回程未知也只核原身份,不重复 add。以后宿主增加插件命令时保留现有备用登记,避免同一 profile 两份连接。
|
|
40
40
|
|
|
41
|
+
## Antigravity 接入
|
|
42
|
+
|
|
43
|
+
在支持 POSIX 文件权限并运行 Google Antigravity 的主机上打开终端,使用 Studio 提供的 API 地址。
|
|
44
|
+
|
|
45
|
+
<!-- creation-install-command -->
|
|
46
|
+
```bash
|
|
47
|
+
npx --yes @promptframe/creation@0.3.13 connect --host antigravity --endpoint <Studio提供的API地址>
|
|
48
|
+
```
|
|
49
|
+
<!-- /creation-install-command -->
|
|
50
|
+
|
|
51
|
+
安装后检查 Antigravity 的 Customizations 中是否启用 PromptFrame Creation,再打开新对话。插件通过 `PreToolUse` 将调用绑定到实际对话,两个 Skill 和 MCP 工具由宿主加载。首次授权在终端隐藏输入,已有有效授权可复用。
|
|
52
|
+
|
|
41
53
|
## 环境与账号
|
|
42
54
|
|
|
43
55
|
默认凭据沿用 `$XDG_CONFIG_HOME/promptframe-creation/credentials.json`(未配置 XDG 时位于用户 `.config`)。旧的 `PROMPTFRAME_CREATION_CONFIG` 仍可显式引用安全文件。
|
|
@@ -46,7 +58,7 @@ CLI 优先使用 PATH 中的 Claude;桌面版远程连接 WSL 时,也识别
|
|
|
46
58
|
|
|
47
59
|
<!-- creation-install-command -->
|
|
48
60
|
```bash
|
|
49
|
-
npx --yes @promptframe/creation@0.3.
|
|
61
|
+
npx --yes @promptframe/creation@0.3.13 connect --profile work-account --endpoint <另一环境API地址>
|
|
50
62
|
```
|
|
51
63
|
<!-- /creation-install-command -->
|
|
52
64
|
|
package/lib/account-bridge.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import path from 'node:path';
|
|
|
2
2
|
import { CreationClientError, readCredentials, normalizeEndpoint } from './credentials.mjs';
|
|
3
3
|
import { connectPlatform, connectionAccountIdentity } from './connection.mjs';
|
|
4
4
|
import { createHostCallBridge, resolveHostCallBinding, hostParameters } from './host-context.mjs';
|
|
5
|
+
import { isHookProofHost } from './host-identity.mjs';
|
|
5
6
|
import { CLAUDE_HOST_PROOF } from './claude-host-session.mjs';
|
|
6
7
|
import { localAccountsRoot, localAccountKey, localAgentDigest, localCredentialDigest, localReferenceId,
|
|
7
8
|
listLocalAccounts, readLocalAuthorizations, readSelectedLocalAccount, selectLocalAccount } from './local-accounts.mjs';
|
|
@@ -22,7 +23,7 @@ function localTool(name,host) {
|
|
|
22
23
|
identityKey: {type:'string',pattern:'^[a-f0-9]{64}-[a-f0-9]{64}$'},
|
|
23
24
|
referenceId: {type:'string',pattern:'^sha256:[a-f0-9]{64}$',description:'同一账号有多份创作授权时可明确选择列表中的引用。'},
|
|
24
25
|
} : {};
|
|
25
|
-
if(host.kind
|
|
26
|
+
if(isHookProofHost(host.kind))properties[CLAUDE_HOST_PROOF]={type:'string',pattern:'^[a-f0-9]{64}$',description:'由当前宿主hook填入,保留原值。'};
|
|
26
27
|
return {name,description:name===listName?'列出本机已登记账号的安全摘要和缺少的授权类型,不返回凭据或本机路径。'
|
|
27
28
|
:'只为当前宿主会话选择本机已授权账号;不切换其它Agent,不申请编辑权或重放业务。',
|
|
28
29
|
inputSchema:{type:'object',properties,additionalProperties:false,...(name===selectName?{required:['identityKey']}:{})},
|
|
@@ -43,7 +44,7 @@ export function createAccountAwareBridge(defaultClient,{credentials,configFile,h
|
|
|
43
44
|
function caller(raw,binding,required=false){
|
|
44
45
|
const params={...raw,arguments:binding.arguments};
|
|
45
46
|
hostParameters(params,binding.host,required?'authority':'independent-read');
|
|
46
|
-
const sessionId=binding.host.kind
|
|
47
|
+
const sessionId=isHookProofHost(binding.host.kind)?binding.host.threadId:params._meta?.threadId;
|
|
47
48
|
return sessionId?{kind:binding.host.kind,sessionId}:undefined;
|
|
48
49
|
}
|
|
49
50
|
async function context(identity,agent,referenceId){
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import {constants} from 'node:fs';
|
|
2
|
+
import {open,mkdir,lstat,rename,unlink,rmdir} from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import {homedir} from 'node:os';
|
|
5
|
+
import {createHash,randomBytes} from 'node:crypto';
|
|
6
|
+
import {CreationClientError} from './credentials.mjs';
|
|
7
|
+
import {CLAUDE_HOST_PROOF} from './claude-host-session.mjs';
|
|
8
|
+
import {threadFormat} from './host-identity.mjs';
|
|
9
|
+
|
|
10
|
+
const hex=/^[0-9a-f]{64}$/;
|
|
11
|
+
const TICKET_TTL_MS=120_000;
|
|
12
|
+
const MAX_TICKETS=256;
|
|
13
|
+
const error=code=>new CreationClientError('creation.'+code);
|
|
14
|
+
const canonical=value=>{
|
|
15
|
+
if(value===null||typeof value==='string'||typeof value==='boolean'||typeof value==='number'&&Number.isFinite(value))return JSON.stringify(value);
|
|
16
|
+
if(Array.isArray(value))return '['+value.map(canonical).join(',')+']';
|
|
17
|
+
if(value&&typeof value==='object'&&[Object.prototype,null].includes(Object.getPrototypeOf(value)))
|
|
18
|
+
return '{'+Object.keys(value).sort().map(key=>JSON.stringify(key)+':'+canonical(value[key])).join(',')+'}';
|
|
19
|
+
throw error('request_invalid');
|
|
20
|
+
};
|
|
21
|
+
const digest=value=>createHash('sha256').update(canonical(value)).digest('hex');
|
|
22
|
+
const withoutProof=args=>Object.fromEntries(Object.entries(args??{}).filter(([key])=>key!==CLAUDE_HOST_PROOF));
|
|
23
|
+
|
|
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);
|
|
27
|
+
}
|
|
28
|
+
function toolNameMatches(hookToolName,bridgeToolName){
|
|
29
|
+
if(typeof hookToolName!=='string'||typeof bridgeToolName!=='string'||!bridgeToolName)return false;
|
|
30
|
+
if(hookToolName===bridgeToolName)return true;
|
|
31
|
+
return hookToolName.endsWith('_'+bridgeToolName)||hookToolName.endsWith(':'+bridgeToolName);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function privateDirectory(directory){
|
|
35
|
+
try{await mkdir(directory,{recursive:true,mode:0o700});}catch(e){if(e.code!=='EEXIST')throw e;}
|
|
36
|
+
const info=await lstat(directory);
|
|
37
|
+
if(!info.isDirectory()||info.isSymbolicLink()||info.uid!==process.getuid?.()||(info.mode&0o077))throw error('host_identity_unavailable');
|
|
38
|
+
}
|
|
39
|
+
async function privateRead(file){
|
|
40
|
+
let handle;try{
|
|
41
|
+
handle=await open(file,constants.O_RDONLY|constants.O_NOFOLLOW);const info=await handle.stat();
|
|
42
|
+
if(!info.isFile()||info.uid!==process.getuid?.()||(info.mode&0o077)||info.size>262144)throw error('host_identity_unavailable');
|
|
43
|
+
return JSON.parse(await handle.readFile('utf8'));
|
|
44
|
+
}catch(e){if(e.code==='ENOENT')return null;throw e;}finally{await handle?.close();}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function antigravityConfigRoot(env=process.env){
|
|
48
|
+
return path.resolve(env.ANTIGRAVITY_CONFIG_DIR??env.GEMINI_CONFIG_DIR??path.join(homedir(),'.gemini','config'));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Local host provenance for Antigravity. Supports multiple concurrent
|
|
52
|
+
* conversations sharing one plugin MCP server process by binding each
|
|
53
|
+
* one-use PreToolUse ticket to its conversationId UUID and exact arguments. */
|
|
54
|
+
export async function createAntigravityHostSession({configFile,env=process.env,root,now=()=>Date.now()}={}){
|
|
55
|
+
const base=root??path.join(antigravityConfigRoot(env),'promptframe-host-sessions');
|
|
56
|
+
const namespace=path.join(base,digest(path.resolve(configFile)));
|
|
57
|
+
const stateFile=path.join(namespace,'state.json');
|
|
58
|
+
|
|
59
|
+
async function readState(){
|
|
60
|
+
const value=await privateRead(stateFile);
|
|
61
|
+
if(!value)return {contractVersion:'antigravity-host-session/v1',tickets:{}};
|
|
62
|
+
if(value.contractVersion!=='antigravity-host-session/v1'||!value.tickets||typeof value.tickets!=='object'
|
|
63
|
+
||Array.isArray(value.tickets)||Object.keys(value.tickets).length>MAX_TICKETS+32)throw error('host_identity_unavailable');
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function transaction(work){
|
|
68
|
+
await privateDirectory(base);await privateDirectory(namespace);
|
|
69
|
+
const lock=path.join(namespace,'write.lock');let acquired=false;
|
|
70
|
+
for(let count=0;count<100;count++)try{await mkdir(lock,{mode:0o700});acquired=true;break;}
|
|
71
|
+
catch(e){if(e.code!=='EEXIST')throw e;await new Promise(resolve=>setTimeout(resolve,10));}
|
|
72
|
+
if(!acquired)throw error('host_identity_unavailable');
|
|
73
|
+
let temporary;
|
|
74
|
+
try{
|
|
75
|
+
const current=await readState();
|
|
76
|
+
const next=await work(current);
|
|
77
|
+
if(next===undefined)return;
|
|
78
|
+
const body=JSON.stringify(next);if(Buffer.byteLength(body)>262144)throw error('host_identity_unavailable');
|
|
79
|
+
temporary=path.join(namespace,'state-'+randomBytes(16).toString('hex')+'.partial');
|
|
80
|
+
const file=await open(temporary,constants.O_WRONLY|constants.O_CREAT|constants.O_EXCL|constants.O_NOFOLLOW,0o600);
|
|
81
|
+
try{await file.writeFile(body);await file.sync();}finally{await file.close();}
|
|
82
|
+
await rename(temporary,stateFile);temporary=undefined;
|
|
83
|
+
const directory=await open(namespace,constants.O_RDONLY|constants.O_DIRECTORY|constants.O_NOFOLLOW);
|
|
84
|
+
try{await directory.sync();}finally{await directory.close();}
|
|
85
|
+
}finally{if(temporary)await unlink(temporary).catch(()=>{});await rmdir(lock).catch(()=>{});}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function pruneTickets(tickets,currentTime){
|
|
89
|
+
const kept={};
|
|
90
|
+
for(const [k,v] of Object.entries(tickets)){
|
|
91
|
+
if(v&&typeof v==='object'&&typeof v.expiresAt==='number'&&v.expiresAt>currentTime
|
|
92
|
+
&&typeof v.conversationId==='string'&&threadFormat.test(v.conversationId))kept[k]=v;
|
|
93
|
+
}
|
|
94
|
+
const keys=Object.keys(kept);
|
|
95
|
+
while(keys.length>=MAX_TICKETS)delete kept[keys.shift()];
|
|
96
|
+
return kept;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async function begin(raw){
|
|
100
|
+
const proof=raw.arguments?.[CLAUDE_HOST_PROOF],args=withoutProof(raw.arguments);
|
|
101
|
+
if(proof===undefined)return {host:{kind:'antigravity'},assertCurrent:async()=>{},arguments:args};
|
|
102
|
+
if(typeof proof!=='string'||!hex.test(proof))throw error('host_identity_invalid');
|
|
103
|
+
const argsHash=digest(args),currentTime=now();
|
|
104
|
+
let accepted;
|
|
105
|
+
try{
|
|
106
|
+
await transaction(current=>{
|
|
107
|
+
const ticket=current.tickets[proof];
|
|
108
|
+
if(!ticket||ticket.expiresAt<=currentTime||ticket.argsDigest!==argsHash
|
|
109
|
+
||!toolNameMatches(ticket.toolName,raw.name)||!threadFormat.test(ticket.conversationId??''))
|
|
110
|
+
throw error('host_identity_invalid');
|
|
111
|
+
accepted={threadId:ticket.conversationId.toLowerCase()};
|
|
112
|
+
delete current.tickets[proof];
|
|
113
|
+
current.tickets=pruneTickets(current.tickets,currentTime);
|
|
114
|
+
return current;
|
|
115
|
+
});
|
|
116
|
+
}catch(e){if(e instanceof CreationClientError)throw e;throw error('host_identity_unavailable');}
|
|
117
|
+
return {host:{kind:'antigravity',threadId:accepted.threadId},arguments:args,assertCurrent:async()=>{}};
|
|
118
|
+
}
|
|
119
|
+
|
|
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'};
|
|
133
|
+
}
|
|
134
|
+
const args=withoutProof(rawArgs),argsHash=digest(args),currentTime=now();
|
|
135
|
+
let token;
|
|
136
|
+
await transaction(current=>{
|
|
137
|
+
const tickets=pruneTickets(current.tickets,currentTime);
|
|
138
|
+
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};
|
|
141
|
+
});
|
|
142
|
+
return {decision:'allow',overwrite:{[CLAUDE_HOST_PROOF]:token}};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return {begin,hook};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export async function readAntigravityHookInput(input){
|
|
149
|
+
const chunks=[];let bytes=0;
|
|
150
|
+
for await(const value of input){const chunk=Buffer.isBuffer(value)?value:Buffer.from(value);bytes+=chunk.length;
|
|
151
|
+
if(bytes>2*1024*1024+65536)throw error('host_identity_invalid');chunks.push(chunk);}
|
|
152
|
+
return JSON.parse(new TextDecoder('utf-8',{fatal:true}).decode(Buffer.concat(chunks,bytes)));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export async function runAntigravityHostHook({configFile,input=process.stdin,output=process.stdout,env=process.env}={}){
|
|
156
|
+
const body=await readAntigravityHookInput(input);
|
|
157
|
+
const store=await createAntigravityHostSession({configFile,env});
|
|
158
|
+
output.write(JSON.stringify(await store.hook(body))+'\n');
|
|
159
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import {lstat,mkdir,open,readFile,rename,rm} from 'node:fs/promises';
|
|
2
|
+
import {createHash,randomBytes} from 'node:crypto';
|
|
3
|
+
import {homedir} from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import {CreationClientError} from './credentials.mjs';
|
|
6
|
+
import {compareBridgeVersions} from './bridge-negotiation.mjs';
|
|
7
|
+
import {inspectRuntimePackage} from './runtime-package.mjs';
|
|
8
|
+
import {antigravityConfigRoot} from './antigravity-host-session.mjs';
|
|
9
|
+
|
|
10
|
+
const hash=b=>createHash('sha256').update(b).digest('hex');
|
|
11
|
+
const fail=code=>{throw new CreationClientError('installation.'+code);};
|
|
12
|
+
const profileFormat=/^[a-z0-9][a-z0-9-]{0,39}$/;
|
|
13
|
+
|
|
14
|
+
function shellQuote(value){
|
|
15
|
+
return '"'+String(value).replace(/(["\\$`])/g,'\\$1')+'"';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function antigravityPluginManifest({version,name='promptframe-creation',displayName='PromptFrame Creation'}){
|
|
19
|
+
return {
|
|
20
|
+
name,
|
|
21
|
+
displayName,
|
|
22
|
+
description:'PromptFrame video creation Skill and MCP bridge for Antigravity: inspect projects, plan shots, search/author components, preview and render videos.',
|
|
23
|
+
version,
|
|
24
|
+
repository:'https://github.com/ty-teams/promptframe-creation',
|
|
25
|
+
suggestedPrompts:[
|
|
26
|
+
'列出我在 PromptFrame 当前项目中的作品并读取最新状态',
|
|
27
|
+
'帮我在 PromptFrame 中规划并创建一个新的科普视频分镜',
|
|
28
|
+
'在组件市场搜索适合数据对比展示的可视化组件',
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function antigravityMcpConfig({serverName,nodeCommand,runtimeRoot,configFile}){
|
|
34
|
+
return {
|
|
35
|
+
mcpServers:{
|
|
36
|
+
[serverName]:{
|
|
37
|
+
command:nodeCommand,
|
|
38
|
+
args:[path.join(runtimeRoot,'bin','promptframe-creation.mjs'),'bridge','--config',configFile,'--host','antigravity'],
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function antigravityHooksConfig({nodeCommand,runtimeRoot,configFile}){
|
|
45
|
+
const cliPath=path.join(runtimeRoot,'bin','promptframe-creation.mjs');
|
|
46
|
+
const command=[shellQuote(nodeCommand),shellQuote(cliPath),'antigravity-host-hook','--config',shellQuote(configFile)].join(' ');
|
|
47
|
+
return {
|
|
48
|
+
'promptframe-host-identity':{
|
|
49
|
+
PreToolUse:[
|
|
50
|
+
{
|
|
51
|
+
matcher:'(.*promptframe.*|^platform_.*)',
|
|
52
|
+
hooks:[{type:'command',command,timeout:5}],
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function readJsonOrNull(file){
|
|
60
|
+
try{return JSON.parse(await readFile(file,'utf8'));}catch(e){if(e.code==='ENOENT')return null;throw e;}
|
|
61
|
+
}
|
|
62
|
+
async function writeFileAtomic(file,content,mode=0o600){
|
|
63
|
+
await mkdir(path.dirname(file),{recursive:true,mode:0o700});
|
|
64
|
+
const tmp=file+'.'+randomBytes(8).toString('hex')+'.partial';
|
|
65
|
+
const fd=await open(tmp,'wx',mode);
|
|
66
|
+
try{await fd.writeFile(content);await fd.sync();}finally{await fd.close();}
|
|
67
|
+
await rename(tmp,file);
|
|
68
|
+
}
|
|
69
|
+
async function copyPackagePayload(payload,destRoot){
|
|
70
|
+
const tmp=destRoot+'.partial-'+randomBytes(8).toString('hex');
|
|
71
|
+
await mkdir(tmp,{recursive:true,mode:0o700});
|
|
72
|
+
try{
|
|
73
|
+
for(const file of payload.files){
|
|
74
|
+
const dest=path.join(tmp,...file.path.split('/'));
|
|
75
|
+
await mkdir(path.dirname(dest),{recursive:true,mode:0o700});
|
|
76
|
+
const fd=await open(dest,'wx',0o600);
|
|
77
|
+
try{await fd.writeFile(file.body);await fd.sync();}finally{await fd.close();}
|
|
78
|
+
}
|
|
79
|
+
await rename(tmp,destRoot);
|
|
80
|
+
}catch(e){
|
|
81
|
+
await rm(tmp,{recursive:true,force:true}).catch(()=>{});
|
|
82
|
+
throw e;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Install PromptFrame Creation as a native Antigravity plugin once.
|
|
87
|
+
* Subsequent bridge upgrades happen automatically on startup via
|
|
88
|
+
* runtime-bootstrap.mjs without requiring plugin reinstallation. */
|
|
89
|
+
export async function installForAntigravityUser({
|
|
90
|
+
sourceRoot,
|
|
91
|
+
profile='default',
|
|
92
|
+
configFile,
|
|
93
|
+
env=process.env,
|
|
94
|
+
nodeCommand=process.execPath,
|
|
95
|
+
signal,
|
|
96
|
+
}={}){
|
|
97
|
+
if(!profileFormat.test(profile))fail('profile_invalid');
|
|
98
|
+
if(!path.isAbsolute(configFile??''))fail('config_path_invalid');
|
|
99
|
+
signal?.throwIfAborted();
|
|
100
|
+
const payload=await inspectRuntimePackage(sourceRoot);
|
|
101
|
+
const suffix=profile==='default'?'':'-'+profile;
|
|
102
|
+
const pluginDirName='promptframe-creation'+suffix;
|
|
103
|
+
const serverName='promptframe-creation'+suffix;
|
|
104
|
+
const dataRoot=path.resolve(env.XDG_DATA_HOME??path.join(homedir(),'.local','share'),'promptframe-creation',profile,'antigravity');
|
|
105
|
+
const versionRoot=path.join(dataRoot,'versions',payload.version);
|
|
106
|
+
const pluginsRoot=path.join(antigravityConfigRoot(env),'plugins');
|
|
107
|
+
const pluginDir=path.join(pluginsRoot,pluginDirName);
|
|
108
|
+
const markerFile=path.join(pluginDir,'promptframe-installation.json');
|
|
109
|
+
|
|
110
|
+
let pluginDirectoryExists=false;
|
|
111
|
+
try{
|
|
112
|
+
const status=await lstat(pluginDir);
|
|
113
|
+
if(!status.isDirectory()||status.isSymbolicLink())fail('managed_installation_invalid');
|
|
114
|
+
pluginDirectoryExists=true;
|
|
115
|
+
}catch(error){if(error.code!=='ENOENT')throw error;}
|
|
116
|
+
const existing=await readJsonOrNull(markerFile);
|
|
117
|
+
if(pluginDirectoryExists&&!existing)fail('managed_installation_invalid');
|
|
118
|
+
if(existing){
|
|
119
|
+
if(existing.host!=='antigravity'||existing.profile!==profile||existing.configFile!==configFile
|
|
120
|
+
||typeof existing.version!=='string'||!/^\d+\.\d+\.\d+$/.test(existing.version))fail('managed_installation_invalid');
|
|
121
|
+
const cmp=compareBridgeVersions(existing.version,payload.version);
|
|
122
|
+
if(cmp>0){
|
|
123
|
+
return {registered:true,pluginInstalled:true,pluginEnabled:true,reused:true,host:'antigravity',
|
|
124
|
+
installationMode:'antigravity-plugin',profile,version:existing.version,requestedVersion:payload.version,
|
|
125
|
+
versionStatus:'newer_installed_kept',recordedRuntimeRetained:true,pluginDir,serverName,
|
|
126
|
+
skillsInstalled:true,skills:[{name:'creation-setup'},{name:'video-creation'}]};
|
|
127
|
+
}
|
|
128
|
+
if(cmp===0&&existing.payloadDigest===payload.payloadDigest&&existing.versionRoot===versionRoot){
|
|
129
|
+
return {registered:true,pluginInstalled:true,pluginEnabled:true,reused:true,host:'antigravity',
|
|
130
|
+
installationMode:'antigravity-plugin',profile,version:payload.version,requestedVersion:payload.version,
|
|
131
|
+
versionStatus:'already_current',recordedRuntimeRetained:false,pluginDir,serverName,
|
|
132
|
+
skillsInstalled:true,skills:[{name:'creation-setup'},{name:'video-creation'}]};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
let versionExists=false;
|
|
137
|
+
try{const s=await lstat(versionRoot);versionExists=s.isDirectory()&&!s.isSymbolicLink();}catch(e){if(e.code!=='ENOENT')throw e;}
|
|
138
|
+
if(!versionExists){
|
|
139
|
+
await mkdir(path.dirname(versionRoot),{recursive:true,mode:0o700});
|
|
140
|
+
await copyPackagePayload(payload,versionRoot);
|
|
141
|
+
}
|
|
142
|
+
signal?.throwIfAborted();
|
|
143
|
+
|
|
144
|
+
if(!existing){
|
|
145
|
+
await mkdir(pluginsRoot,{recursive:true,mode:0o700});
|
|
146
|
+
await mkdir(pluginDir,{mode:0o700});
|
|
147
|
+
}
|
|
148
|
+
const pluginJson=JSON.stringify(antigravityPluginManifest({
|
|
149
|
+
version:payload.version,
|
|
150
|
+
name:pluginDirName,
|
|
151
|
+
displayName:profile==='default'?'PromptFrame Creation':'PromptFrame Creation ('+profile+')',
|
|
152
|
+
}),null,2)+'\n';
|
|
153
|
+
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';
|
|
155
|
+
|
|
156
|
+
await writeFileAtomic(path.join(pluginDir,'plugin.json'),pluginJson,0o644);
|
|
157
|
+
await writeFileAtomic(path.join(pluginDir,'mcp_config.json'),mcpJson,0o600);
|
|
158
|
+
await writeFileAtomic(path.join(pluginDir,'hooks.json'),hooksJson,0o600);
|
|
159
|
+
|
|
160
|
+
const skillEntries=payload.files.filter(f=>f.path.startsWith('skills/')&&f.path.endsWith('/SKILL.md'));
|
|
161
|
+
for(const skill of skillEntries){
|
|
162
|
+
const dest=path.join(pluginDir,...skill.path.split('/'));
|
|
163
|
+
await writeFileAtomic(dest,skill.body,0o644);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const record={
|
|
167
|
+
contractVersion:'antigravity-plugin-installation/v1',
|
|
168
|
+
host:'antigravity',
|
|
169
|
+
profile,
|
|
170
|
+
configFile,
|
|
171
|
+
pluginDirName,
|
|
172
|
+
serverName,
|
|
173
|
+
version:payload.version,
|
|
174
|
+
versionRoot,
|
|
175
|
+
nodeCommand,
|
|
176
|
+
payloadDigest:payload.payloadDigest,
|
|
177
|
+
mcpDigest:hash(mcpJson),
|
|
178
|
+
hooksDigest:hash(hooksJson),
|
|
179
|
+
installedAt:new Date().toISOString(),
|
|
180
|
+
};
|
|
181
|
+
await writeFileAtomic(markerFile,JSON.stringify(record,null,2)+'\n',0o600);
|
|
182
|
+
|
|
183
|
+
return {
|
|
184
|
+
registered:true,
|
|
185
|
+
pluginInstalled:true,
|
|
186
|
+
pluginEnabled:true,
|
|
187
|
+
reused:false,
|
|
188
|
+
host:'antigravity',
|
|
189
|
+
installationMode:'antigravity-plugin',
|
|
190
|
+
profile,
|
|
191
|
+
version:payload.version,
|
|
192
|
+
requestedVersion:payload.version,
|
|
193
|
+
versionStatus:existing?'upgraded':'installed',
|
|
194
|
+
recordedRuntimeRetained:false,
|
|
195
|
+
pluginDir,
|
|
196
|
+
serverName,
|
|
197
|
+
skillsInstalled:true,
|
|
198
|
+
skills:skillEntries.map(s=>({name:s.path.split('/')[1]})),
|
|
199
|
+
};
|
|
200
|
+
}
|
package/lib/cli.mjs
CHANGED
|
@@ -25,13 +25,15 @@ import {
|
|
|
25
25
|
import { connectPlatform, connectionAccountIdentity } from "./connection.mjs";
|
|
26
26
|
import { recordLocalAuthorization, listLocalAccounts, localAccountKey, localAgentDigest } from './local-accounts.mjs';
|
|
27
27
|
import { createAccountAwareBridge } from './account-bridge.mjs';
|
|
28
|
-
import { resolveHostIdentity } from "./host-identity.mjs";
|
|
28
|
+
import { hostClientName, resolveHostIdentity } from "./host-identity.mjs";
|
|
29
29
|
import {createClaudeHostSession,runClaudeHostHook} from './claude-host-session.mjs';
|
|
30
|
+
import {createAntigravityHostSession,runAntigravityHostHook} from './antigravity-host-session.mjs';
|
|
30
31
|
import {declaredHostContentCapabilities,readPlatformBridgePolicy,bridgeErrorDetails} from './bridge-negotiation.mjs';
|
|
31
32
|
import {selectBridgeRuntime,runtimeErrorDetails} from './runtime-bootstrap.mjs';
|
|
32
33
|
import {launchSelectedBridge} from './runtime-launch.mjs';
|
|
33
34
|
import {installForUser,profileCredentialsPath,installationErrorDetails} from './user-installation.mjs';
|
|
34
35
|
import {installForClaudeUser,claudeInstallationDetails} from './claude-installation.mjs';
|
|
36
|
+
import {installForAntigravityUser} from './antigravity-installation.mjs';
|
|
35
37
|
import {claudeErrorDetails} from './claude-command.mjs';
|
|
36
38
|
import {fallbackErrorDetails} from './claude-mcp-installation.mjs';
|
|
37
39
|
import {fileURLToPath} from 'node:url';
|
|
@@ -173,7 +175,7 @@ async function setup({silent=false}={}) {
|
|
|
173
175
|
endpoint,
|
|
174
176
|
token,
|
|
175
177
|
clientId: existing?.clientId ?? randomBytes(24).toString("base64url"),
|
|
176
|
-
clientName: value("--name") ?? existing?.clientName ?? (resolveHostIdentity({host:value('--host')})
|
|
178
|
+
clientName: value("--name") ?? existing?.clientName ?? hostClientName('Codex PromptFrame', resolveHostIdentity({host:value('--host')})),
|
|
177
179
|
createdAt: existing?.createdAt ?? new Date().toISOString(),
|
|
178
180
|
};
|
|
179
181
|
// Verify before replacing the secure local file. This never calls a token
|
|
@@ -208,7 +210,11 @@ async function bridge() {
|
|
|
208
210
|
process.exitCode=result.code;return;
|
|
209
211
|
}
|
|
210
212
|
await rememberAuthorization(credentials,configFile(),connectionAccountIdentity(client));
|
|
211
|
-
const hostSession=identity.kind==='claude-code'
|
|
213
|
+
const hostSession=identity.kind==='claude-code'
|
|
214
|
+
?await createClaudeHostSession({configFile:configFile()})
|
|
215
|
+
:identity.kind==='antigravity'
|
|
216
|
+
?await createAntigravityHostSession({configFile:configFile()})
|
|
217
|
+
:undefined;
|
|
212
218
|
const server = new Server(
|
|
213
219
|
{ name: "promptframe-creation", version: CLIENT_VERSION },
|
|
214
220
|
{ capabilities: { tools: {listChanged:true},...(upstream.resources?{resources:{listChanged:true}}:{}),
|
|
@@ -308,24 +314,32 @@ try {
|
|
|
308
314
|
const signal=new AbortController();
|
|
309
315
|
const abort=()=>signal.abort();process.once('SIGINT',abort);process.once('SIGTERM',abort);
|
|
310
316
|
try{
|
|
311
|
-
const host=resolveHostIdentity({host:value('--host')})
|
|
317
|
+
const host=resolveHostIdentity({host:value('--host')});
|
|
318
|
+
const installer=host.kind==='claude-code'?installForClaudeUser:host.kind==='antigravity'?installForAntigravityUser:installForUser;
|
|
312
319
|
const installed=await installer({sourceRoot:fileURLToPath(new URL('..',import.meta.url)),
|
|
313
320
|
executable:value('--claude-bin'),profile:value('--profile')??'default',configFile:configFile(),signal:signal.signal});
|
|
314
321
|
const skillNames=installed.skills?.map(skill=>skill.name)??['creation-setup','video-creation'];
|
|
322
|
+
const nextStep=host.kind==='claude-code'
|
|
323
|
+
?'On this host, start a new Claude Code session.'
|
|
324
|
+
:host.kind==='antigravity'
|
|
325
|
+
?'On this host, start a new Antigravity conversation (or check promptframe-creation in Customizations).'
|
|
326
|
+
:'On this host, open a new Local chat (CLI: start a new session).';
|
|
315
327
|
log({...connection,pluginRegistered:(installed.pluginInstalled??true)&&installed.registered,
|
|
316
328
|
mcpRegistered:installed.registered,version:installed.version,
|
|
317
329
|
host:host.kind,pluginInstalled:installed.pluginInstalled??true,pluginEnabled:installed.pluginEnabled??true,
|
|
318
330
|
...(installed.installationMode?{installationMode:installed.installationMode,skillsInstalled:installed.skillsInstalled,skills:skillNames}:{}),
|
|
331
|
+
...(installed.pluginDir?{pluginDir:installed.pluginDir}:{}),
|
|
319
332
|
hostMcpConnected:'not_verified',sessionLoaded:'not_verified',
|
|
320
333
|
installationReused:installed.reused,profile:installed.profile,
|
|
321
334
|
requestedVersion:installed.requestedVersion,versionStatus:installed.versionStatus,
|
|
322
335
|
recordedRuntimeRetained:installed.recordedRuntimeRetained??false,
|
|
323
|
-
next:
|
|
336
|
+
next:nextStep+' Check '+skillNames.join(', ')+' and the PromptFrame MCP tools together. Keep the existing Token; no reinstall or product repository is needed.'+(installed.recordedRuntimeRetained?' Keep this version\'s recorded Node path available.':''),
|
|
324
337
|
hostThreadIdentity:'verified_by_the_platform_on_actual_host_tool_calls'});
|
|
325
338
|
}finally{process.removeListener('SIGINT',abort);process.removeListener('SIGTERM',abort);}
|
|
326
339
|
}
|
|
327
340
|
else if (command === "bridge") await bridge();
|
|
328
341
|
else if(command==='claude-host-hook')await runClaudeHostHook({configFile:configFile()});
|
|
342
|
+
else if(command==='antigravity-host-hook')await runAntigravityHostHook({configFile:configFile()});
|
|
329
343
|
else if(command==='--version')process.stdout.write(CLIENT_VERSION+'\n');
|
|
330
344
|
else if(command==='accounts'){
|
|
331
345
|
if(args[0]==='refresh'){
|
|
@@ -350,7 +364,7 @@ try {
|
|
|
350
364
|
});
|
|
351
365
|
} else if (command === "help" || command === "--help" || !command) {
|
|
352
366
|
process.stdout.write(
|
|
353
|
-
"promptframe-creation connect --endpoint <platform-api-base> [--host codex|claude-code] [--profile <environment-account>] [--claude-bin <absolute-file>] [--no-open]\npromptframe-creation setup --endpoint <platform-api-base> [--host codex|claude-code] [--no-open] [--replace] [--name <client-name>]\npromptframe-creation status [--profile <environment-account>] [--host codex|claude-code]\npromptframe-creation accounts list\npromptframe-creation accounts refresh [--profile <environment-account>] [--host codex|claude-code]\npromptframe-creation bridge [--config <private-file>] [--host codex|claude-code] [--bridge-version <X.Y.Z>]\npromptframe-creation --version\nNode.js >=20 is required. Plugin installation supports Codex >=0.160.0
|
|
367
|
+
"promptframe-creation connect --endpoint <platform-api-base> [--host codex|claude-code|antigravity] [--profile <environment-account>] [--claude-bin <absolute-file>] [--no-open]\npromptframe-creation setup --endpoint <platform-api-base> [--host codex|claude-code|antigravity] [--no-open] [--replace] [--name <client-name>]\npromptframe-creation status [--profile <environment-account>] [--host codex|claude-code|antigravity]\npromptframe-creation accounts list\npromptframe-creation accounts refresh [--profile <environment-account>] [--host codex|claude-code|antigravity]\npromptframe-creation bridge [--config <private-file>] [--host codex|claude-code|antigravity] [--bridge-version <X.Y.Z>]\npromptframe-creation --version\nNode.js >=20 is required. Plugin installation supports Codex >=0.160.0, Claude Code >=2.1.295 or Google Antigravity. Token input is masked in a terminal or accepted through --token-stdin; never use a Token command argument.\nBridge startup checks the platform minimum/recommended version. --bridge-version locks one exact compatible version for this new session; active bridges are not replaced.\n",
|
|
354
368
|
);
|
|
355
369
|
} else throw new CreationClientError("command.unknown");
|
|
356
370
|
} catch (error) {
|
package/lib/connection.mjs
CHANGED
|
@@ -64,7 +64,7 @@ export async function connectPlatform(credentials,{host=resolveHostIdentity(),co
|
|
|
64
64
|
const systemFamily=process.platform==='win32'?'Windows':process.platform==='darwin'?'macOS':
|
|
65
65
|
process.platform==='linux'?(process.env.WSL_INTEROP||process.env.WSL_DISTRO_NAME?'WSL':'Linux'):'unknown';
|
|
66
66
|
observation={contractVersion:'promptframe-client-observation/v1',instanceId,systemFamily,
|
|
67
|
-
application:host.kind==='claude-code'?'Claude Code':host.kind==='codex'?'Codex':'Creation',applicationVersion:CLIENT_VERSION};
|
|
67
|
+
application:host.kind==='claude-code'?'Claude Code':host.kind==='antigravity'?'Antigravity':host.kind==='codex'?'Codex':'Creation',applicationVersion:CLIENT_VERSION};
|
|
68
68
|
}catch{/* Missing private display metadata must not alter a valid grant. */}
|
|
69
69
|
if(enforceMinimum)assertBridgeCompatible(client.getServerCapabilities(),CLIENT_VERSION);
|
|
70
70
|
else readPlatformBridgePolicy(client.getServerCapabilities());
|
package/lib/host-context.mjs
CHANGED
|
@@ -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
|
|
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:
|
|
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
|
|
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
|
|
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'];
|
package/lib/host-identity.mjs
CHANGED
|
@@ -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
|
|
5
|
-
?host.kind
|
|
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.
|
|
11
|
-
//
|
|
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(!
|
|
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
|
|
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}};
|