hyperstack-core 1.1.0 → 1.2.0
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/adapters/openclaw.js +46 -0
- package/package.json +1 -1
- package/src/client.js +42 -0
package/adapters/openclaw.js
CHANGED
|
@@ -203,6 +203,52 @@ function createOpenClawAdapter(opts = {}) {
|
|
|
203
203
|
* Hook: called when agent session starts.
|
|
204
204
|
* Registers the agent and loads relevant context.
|
|
205
205
|
*/
|
|
206
|
+
/**
|
|
207
|
+
* Check for cards directed at this agent from other agents.
|
|
208
|
+
* Enables cross-agent coordination via shared memory.
|
|
209
|
+
*/
|
|
210
|
+
async hs_inbox({ since } = {}) {
|
|
211
|
+
const result = await client.inbox({ since });
|
|
212
|
+
const cards = result.cards || [];
|
|
213
|
+
if (!cards.length) {
|
|
214
|
+
return { text: `No messages for agent "${agentId}".`, cards: [] };
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
text: `${cards.length} message(s) for "${agentId}":\n` +
|
|
218
|
+
cards.map(c => ` [${c.slug}] ${c.title}${c.body ? `\n ${c.body.slice(0, 150)}` : ""}`).join("\n"),
|
|
219
|
+
cards,
|
|
220
|
+
};
|
|
221
|
+
},
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Register a webhook for real-time notifications. Requires Team plan.
|
|
225
|
+
*/
|
|
226
|
+
async hs_webhook({ url, events, secret } = {}) {
|
|
227
|
+
if (!url) return { text: "Error: url required" };
|
|
228
|
+
const result = await client.registerWebhook({
|
|
229
|
+
url,
|
|
230
|
+
events: events ? events.split(",").map(e => e.trim()) : ["*"],
|
|
231
|
+
secret,
|
|
232
|
+
});
|
|
233
|
+
if (result.error) return { text: `Webhook error: ${result.error}` };
|
|
234
|
+
return { text: `Webhook registered for agent "${agentId}".\nURL: ${url}\nID: ${result.id}` };
|
|
235
|
+
},
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* List all registered webhooks for this account.
|
|
239
|
+
*/
|
|
240
|
+
async hs_webhooks() {
|
|
241
|
+
const result = await client.listWebhooks();
|
|
242
|
+
const hooks = result.webhooks || [];
|
|
243
|
+
if (!hooks.length) return { text: "No webhooks registered." };
|
|
244
|
+
return {
|
|
245
|
+
text: `${hooks.length} webhook(s):\n` +
|
|
246
|
+
hooks.map(h => ` [${h.agentId}] ${h.url} — events: ${h.events.join(", ")}`).join("\n"),
|
|
247
|
+
hooks,
|
|
248
|
+
};
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
|
|
206
252
|
async onSessionStart({ agentName, agentRole }) {
|
|
207
253
|
// Register this agent in the graph
|
|
208
254
|
await client.registerAgent({
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -253,6 +253,48 @@ class HyperStackClient {
|
|
|
253
253
|
* @param {string} agent.role — what this agent does
|
|
254
254
|
* @param {string[]} [agent.owns] — slugs this agent owns
|
|
255
255
|
*/
|
|
256
|
+
/**
|
|
257
|
+
* Check for cards directed at this agent by other agents.
|
|
258
|
+
* Enables cross-agent coordination via shared memory.
|
|
259
|
+
* @param {object} [opts]
|
|
260
|
+
* @param {string} [opts.since] — ISO timestamp, only cards after this time
|
|
261
|
+
* @returns {Promise<{cards: Array}>}
|
|
262
|
+
*/
|
|
263
|
+
async inbox(opts = {}) {
|
|
264
|
+
const agentId = this.agentId;
|
|
265
|
+
if (!agentId) throw new Error("agentId required for inbox");
|
|
266
|
+
let url = `/api/cards?workspace=${this.workspace}&targetAgent=${agentId}`;
|
|
267
|
+
if (opts.since) url += `&since=${encodeURIComponent(opts.since)}`;
|
|
268
|
+
return this._request("GET", url);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Register a webhook to receive real-time notifications.
|
|
273
|
+
* Agent gets notified when cards are directed at it. Requires Team plan.
|
|
274
|
+
* @param {object} webhook
|
|
275
|
+
* @param {string} webhook.url — URL to receive POST events
|
|
276
|
+
* @param {string[]} [webhook.events] — events to listen for (default: all)
|
|
277
|
+
* @param {string} [webhook.secret] — HMAC secret for signature verification
|
|
278
|
+
* @returns {Promise<{id: string}>}
|
|
279
|
+
*/
|
|
280
|
+
async registerWebhook(webhook) {
|
|
281
|
+
return this._request("POST", `/api/agent-webhooks`, {
|
|
282
|
+
agentId: this.agentId,
|
|
283
|
+
url: webhook.url,
|
|
284
|
+
events: webhook.events || ["*"],
|
|
285
|
+
workspace: this.workspace,
|
|
286
|
+
secret: webhook.secret || undefined,
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* List all registered webhooks for this account.
|
|
292
|
+
* @returns {Promise<{webhooks: Array}>}
|
|
293
|
+
*/
|
|
294
|
+
async listWebhooks() {
|
|
295
|
+
return this._request("GET", `/api/agent-webhooks`);
|
|
296
|
+
}
|
|
297
|
+
|
|
256
298
|
async registerAgent(agent) {
|
|
257
299
|
const links = [];
|
|
258
300
|
if (agent.owns) {
|