@openagents-org/agent-launcher 0.2.128 → 0.2.131

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.
@@ -156,12 +156,15 @@ class WorkspaceClient {
156
156
  */
157
157
  async sendMessage(workspaceId, channelName, token, content, {
158
158
  senderType = 'agent', senderName, messageType = 'chat', metadata, attachments, sessionId,
159
+ spec, specToolCallId,
159
160
  } = {}) {
160
161
  const sourcePrefix = senderType === 'agent' ? 'openagents' : 'human';
161
162
  const source = senderName ? `${sourcePrefix}:${senderName}` : `${sourcePrefix}:unknown`;
162
163
 
163
164
  const payload = { content, message_type: messageType };
164
165
  if (attachments && attachments.length) payload.attachments = attachments;
166
+ if (spec) payload.spec = spec;
167
+ if (specToolCallId) payload.spec_tool_call_id = specToolCallId;
165
168
 
166
169
  return this.sendEvent(workspaceId, {
167
170
  type: 'workspace.message.posted',
@@ -172,6 +175,30 @@ class WorkspaceClient {
172
175
  }, token, sessionId);
173
176
  }
174
177
 
178
+ /**
179
+ * Poll workspace.tool_result events — the client's response to an agent's
180
+ * render_ui invocation. Returns events directly (no message normalization)
181
+ * because the caller treats them differently than chat messages.
182
+ */
183
+ async pollToolResults(workspaceId, token, { after, limit = 50 } = {}) {
184
+ const params = new URLSearchParams({
185
+ network: workspaceId,
186
+ type: 'workspace.tool_result',
187
+ limit: String(limit),
188
+ });
189
+ if (after) params.set('after', after);
190
+
191
+ const data = await this._get(`/v1/events?${params}`, this._wsHeaders(token));
192
+ const result = data.data || data;
193
+ const events = (result && result.events) || [];
194
+
195
+ let cursor = null;
196
+ if (events.length > 0) {
197
+ cursor = events[events.length - 1].id || null;
198
+ }
199
+ return { events, cursor };
200
+ }
201
+
175
202
  /**
176
203
  * Poll messages in a channel via GET /v1/events.
177
204
  * @returns {Array} message-compatible objects
@@ -244,7 +271,7 @@ class WorkspaceClient {
244
271
  * Poll for pending messages targeted at an agent via GET /v1/events.
245
272
  * Returns { messages, cursor } where cursor is the last event ID.
246
273
  */
247
- async pollPending(workspaceId, agentName, token, { after, limit = 50 } = {}) {
274
+ async pollPending(workspaceId, agentName, token, { after, limit = 500 } = {}) {
248
275
  const params = new URLSearchParams({
249
276
  network: workspaceId,
250
277
  type: 'workspace.message.posted',
@@ -306,7 +333,28 @@ class WorkspaceClient {
306
333
  }
307
334
  }
308
335
 
309
- return { messages, cursor };
336
+ const composing = !!(result && result.composing);
337
+ return { messages, cursor, composing };
338
+ }
339
+
340
+ /**
341
+ * Get the workspace's top-level metadata via GET /v1/workspaces/{id}.
342
+ *
343
+ * Returns the full data block from the backend — adapters care about
344
+ * `browserEnabled` today, but more keys may be surfaced over time. On
345
+ * error, returns null so callers can fall back to defaults rather than
346
+ * crashing.
347
+ */
348
+ async getWorkspaceMetadata(workspaceId, token) {
349
+ try {
350
+ const data = await this._get(
351
+ `/v1/workspaces/${workspaceId}`,
352
+ this._wsHeaders(token),
353
+ );
354
+ return data.data || data || {};
355
+ } catch {
356
+ return null;
357
+ }
310
358
  }
311
359
 
312
360
  /**
@@ -579,17 +627,22 @@ class WorkspaceClient {
579
627
 
580
628
  // ── Routines ──
581
629
 
582
- async createRoutine(workspaceId, channelName, token, { name, message, hour, minute, days, source } = {}) {
630
+ async createRoutine(workspaceId, channelName, token, { name, message, context, hour, minute, days, interval_minutes, source } = {}) {
583
631
  const body = {
584
632
  name,
585
633
  message,
586
- hour,
587
- minute,
634
+ context: context || '',
588
635
  network: workspaceId,
589
636
  channel: channelName,
590
637
  source: source || 'openagents:unknown',
591
638
  };
592
- if (days) body.days = days;
639
+ if (interval_minutes != null) {
640
+ body.interval_minutes = interval_minutes;
641
+ } else {
642
+ body.hour = hour;
643
+ body.minute = minute;
644
+ if (days) body.days = days;
645
+ }
593
646
  const data = await this._post('/v1/routines', body, this._wsHeaders(token));
594
647
  return data.data || data;
595
648
  }