@openagents-org/agent-connector 0.2.0 → 0.2.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openagents-org/agent-connector",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Agent management CLI and library for OpenAgents — install, configure, and run AI coding agents",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -17,7 +17,7 @@
17
17
 
18
18
  'use strict';
19
19
 
20
- const WorkspaceClient = require('../workspace-client');
20
+ const { WorkspaceClient } = require('../workspace-client');
21
21
  const { generateSessionTitle, SESSION_DEFAULT_RE } = require('./utils');
22
22
 
23
23
  const DEFAULT_ENDPOINT = 'https://workspace-endpoint.openagents.org';
@@ -194,9 +194,14 @@ class OpenClawAdapter extends BaseAdapter {
194
194
 
195
195
  const spawnEnv = { ...process.env };
196
196
  if (IS_WINDOWS) {
197
+ // Ensure node and npm global bin are on PATH
198
+ const nodeBinDir = path.dirname(process.execPath);
197
199
  const npmBin = path.join(process.env.APPDATA || '', 'npm');
198
- if (npmBin && !(spawnEnv.PATH || '').includes(npmBin)) {
199
- spawnEnv.PATH = npmBin + ';' + (spawnEnv.PATH || '');
200
+ const extraPaths = [nodeBinDir, npmBin].filter(Boolean);
201
+ for (const p of extraPaths) {
202
+ if (p && !(spawnEnv.PATH || '').includes(p)) {
203
+ spawnEnv.PATH = p + ';' + (spawnEnv.PATH || '');
204
+ }
200
205
  }
201
206
  }
202
207
 
@@ -105,17 +105,6 @@ class WorkspaceClient {
105
105
  } catch {}
106
106
  }
107
107
 
108
- /**
109
- * Poll for pending tasks via POST /v1/poll_pending.
110
- */
111
- async pollPending(workspaceId, agentName, token) {
112
- const data = await this._post('/v1/poll_pending', {
113
- agent_name: agentName,
114
- network: workspaceId,
115
- }, this._wsHeaders(token));
116
- return data.data || data;
117
- }
118
-
119
108
  /**
120
109
  * Post a task result via POST /v1/events.
121
110
  */
@@ -190,6 +179,54 @@ class WorkspaceClient {
190
179
  return { messages, cursor };
191
180
  }
192
181
 
182
+ /**
183
+ * Get session/channel info via GET /v1/sessions/{channelName}.
184
+ */
185
+ async getSession(workspaceId, channelName, token) {
186
+ try {
187
+ const params = new URLSearchParams({ network: workspaceId });
188
+ const data = await this._get(`/v1/sessions/${channelName}?${params}`, this._wsHeaders(token));
189
+ return (data.data || data) || {};
190
+ } catch {
191
+ return {};
192
+ }
193
+ }
194
+
195
+ /**
196
+ * Update session/channel info via PUT /v1/sessions/{channelName}.
197
+ */
198
+ async updateSession(workspaceId, channelName, token, { title, autoTitle } = {}) {
199
+ const body = { network: workspaceId };
200
+ if (title !== undefined) body.title = title;
201
+ if (autoTitle !== undefined) body.auto_title = autoTitle;
202
+ try {
203
+ await this._post(`/v1/sessions/${channelName}`, body, this._wsHeaders(token));
204
+ } catch {}
205
+ }
206
+
207
+ /**
208
+ * Poll for control events targeted at an agent via GET /v1/events.
209
+ */
210
+ async pollControl(workspaceId, agentName, token, { after } = {}) {
211
+ try {
212
+ const params = new URLSearchParams({
213
+ network: workspaceId,
214
+ type: 'workspace.control',
215
+ limit: '10',
216
+ });
217
+ if (after) params.set('after', after);
218
+ const data = await this._get(`/v1/events?${params}`, this._wsHeaders(token));
219
+ const result = data.data || data;
220
+ const events = (result && result.events) || [];
221
+ return events.filter((e) => {
222
+ const targets = (e.metadata || {}).target_agents || [];
223
+ return !targets.length || targets.includes(agentName);
224
+ });
225
+ } catch {
226
+ return [];
227
+ }
228
+ }
229
+
193
230
  /**
194
231
  * Convert an ONM event to a message-compatible object.
195
232
  */