@pmate/cli 0.44.3 → 0.44.4

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.
@@ -4,6 +4,7 @@ const { homedir } = require('node:os')
4
4
  const path = require('node:path')
5
5
  const methods = ['capabilities','workspaces.list','agents.list','agents.create','agents.update','plugins.list','plugins.configure','runtime.checkEnvironment','runtime.install','runtime.status','scripts.run']
6
6
  function createAgentRuntime({ platform = process.platform, home = homedir(), execute, fetcher = fetch } = {}) {
7
+ let identityEpoch=0
7
8
  let identity, installation, progress = { phase: 'idle' }
8
9
  const root = path.join(home, '.pmate', 'merry-runtime')
9
10
  const run = execute || ((file, args, cwd) => new Promise((resolve, reject) => {
@@ -65,7 +66,15 @@ function createAgentRuntime({ platform = process.platform, home = homedir(), exe
65
66
  if(method==='agents.create'&&expectedRevision!==undefined)throw new Error('创建不能指定 revision')
66
67
  return api(base+(method==='plugins.configure'?'/runtime-plugins/':'/vega-agents/')+encodeURIComponent(id),'PUT',{...config,...(expectedRevision===undefined?{}:{expectedRevision})})
67
68
  }
68
- return { invoke, setIdentity(value) { identity=value ? {appId:value.appId,token:value.token} : undefined } }
69
+ return { invoke,
70
+ async configureIdentity(value, configure) {
71
+ const epoch=++identityEpoch;identity=undefined
72
+ const result=await configure(value)
73
+ if(epoch===identityEpoch)identity={appId:value.appId,token:value.token}
74
+ return result
75
+ },
76
+ setIdentity(value) { identityEpoch++;identity=value ? {appId:value.appId,token:value.token} : undefined }
77
+ }
69
78
  }
70
79
  function installAgentRuntime({ ipcMain, trusted, runtime }) {
71
80
  ipcMain.handle('pmate:electron:invoke',(event,method,input)=>{if(!trusted(event))throw new Error('Untrusted Electron sender');return runtime.invoke(method,input)})
@@ -95,9 +95,7 @@ else {
95
95
  })
96
96
  ipcMain.handle('pmate:reach:configure', async (event, identity) => {
97
97
  if (!desktopNotifications.trusted(event)) throw new Error('Untrusted reach sender')
98
- const result = await desktopReach.configure(identity)
99
- agentRuntime.setIdentity(identity)
100
- return result
98
+ return agentRuntime.configureIdentity(identity, value => desktopReach.configure(value))
101
99
  })
102
100
  ipcMain.handle('pmate:reach:stop', event => {
103
101
  if (!desktopNotifications.trusted(event)) throw new Error('Untrusted reach sender')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmate/cli",
3
- "version": "0.44.3",
3
+ "version": "0.44.4",
4
4
  "description": "CLI utilities for the pMate project",
5
5
  "license": "MIT",
6
6
  "bin": {