@pmate/cli 0.44.10 → 0.44.11

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.
@@ -3,12 +3,12 @@ const { homedir } = require('node:os')
3
3
  const path = require('node:path')
4
4
  const {modelCatalog}=require('./model-catalog.cjs')
5
5
  const {checkEnvironment}=require('./environment-check.cjs')
6
- const methods = ['capabilities','workspaces.list','agents.list','agents.create','agents.update','plugins.list','plugins.configure','runtime.checkEnvironment','runtime.status','scripts.run']
6
+ const methods = ['capabilities','workspaces.list','agents.list','agents.create','agents.update','plugins.list','plugins.configure','runtime.checkEnvironment','runtime.status','runtime.inspect','scripts.run']
7
7
  function createAgentRuntime({ platform = process.platform, home = homedir(), execute, fetcher = fetch, environment = process.env } = {}) {
8
8
  let identityEpoch=0
9
9
  let identity
10
- const run = execute || ((file, args, cwd, timeout = 600000) => new Promise((resolve, reject) => {
11
- execFile(file, args, { cwd, timeout, maxBuffer: 1024 * 1024, env: { ...environment, PATH: [path.join(home,'.local/bin'),path.join(home,'.bun/bin'),environment.PNPM_HOME,path.join(home,'Library/pnpm'),path.join(home,'.local/share/pnpm'),'/opt/homebrew/bin','/usr/local/bin',environment.PATH].filter(Boolean).join(':'), GIT_TERMINAL_PROMPT: '0' } }, (error, stdout) => error ? reject(new Error(`${path.basename(file)} 执行失败,请检查本地安装和仓库访问权限`)) : resolve(stdout.trim()))
10
+ const run = execute || ((file, args, cwd, timeout = 600000, credentials = {}) => new Promise((resolve, reject) => {
11
+ execFile(file, args, { cwd, timeout, maxBuffer: 4 * 1024 * 1024, env: { ...environment, ...credentials, PATH: [path.join(home,'.local/bin'),path.join(home,'.bun/bin'),environment.PNPM_HOME,path.join(home,'Library/pnpm'),path.join(home,'.local/share/pnpm'),'/opt/homebrew/bin','/usr/local/bin',environment.PATH].filter(Boolean).join(':'), GIT_TERMINAL_PROMPT: '0' } }, (error, stdout) => error ? reject(new Error(`${path.basename(file)} 执行失败,请检查本地安装和仓库访问权限`)) : resolve(stdout.trim()))
12
12
  }))
13
13
  const check = () => checkEnvironment({platform,home,run,fetcher})
14
14
  const api = async (route, method='GET', body) => {
@@ -29,6 +29,14 @@ function createAgentRuntime({ platform = process.platform, home = homedir(), exe
29
29
  const {scope,id,config,expectedRevision}=input||{}
30
30
  if(!scope||!['namespace','topic'].every(k=>typeof scope[k]==='string'&&/^[a-z0-9][a-z0-9_-]{0,127}$/.test(scope[k])))throw new Error('无效工作区')
31
31
  const base=`/v2/topics/${encodeURIComponent(scope.namespace)}/${encodeURIComponent(scope.topic)}`
32
+ if(method==='runtime.inspect'){
33
+ if(!identity)throw new Error('请先登录梅丽号')
34
+ if(!['runs','run','run-logs'].includes(input.kind)||Object.keys(input).some(k=>!['scope','kind','agentId','runId','status'].includes(k)))throw new Error('无效的 Run 查询')
35
+ const epoch=identityEpoch
36
+ const output=await run('merry-runtime',['inspect','--request',JSON.stringify(input)],undefined,600000,{PCS_AGENT_API_TOKEN:identity.token,PCS_ISSUES_API_URL:'https://issue-api.pmate.chat',PCS_AGENT_ID:undefined,PCS_AGENT_RUN_ID:undefined,VEGA_RUN_TOKEN:undefined,VEGA_INPUT_ID:undefined})
37
+ if(epoch!==identityEpoch||!identity)throw new Error('登录身份已改变,请重新打开页面')
38
+ return JSON.parse(output)
39
+ }
32
40
  if(method==='agents.list')return api(base+'/vega-agents')
33
41
  if(method==='plugins.list')return api(base+'/runtime-plugins')
34
42
  if(typeof id!=='string'||!(method==='plugins.configure'?/^(?:[a-z][a-z0-9-]*:)?[a-z][a-z0-9-]*$/:/^0x[a-f0-9]{64}$/).test(id)||!config||typeof config!=='object'||Array.isArray(config))throw new Error('无效配置')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmate/cli",
3
- "version": "0.44.10",
3
+ "version": "0.44.11",
4
4
  "description": "CLI utilities for the pMate project",
5
5
  "license": "MIT",
6
6
  "bin": {