@agentbean/daemon 0.1.25 → 0.1.26

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.
@@ -8,16 +8,37 @@ function runtimeArgs(args = []) {
8
8
  function hasMessageFlag(args) {
9
9
  return args.includes('--message') || args.includes('-m');
10
10
  }
11
+ function hasTargetSelector(args) {
12
+ return args.includes('--agent')
13
+ || args.includes('--session-id')
14
+ || args.includes('--session-key')
15
+ || args.includes('--to')
16
+ || args.includes('-t');
17
+ }
18
+ function ensureTargetSelector(args) {
19
+ if (hasTargetSelector(args))
20
+ return args;
21
+ const messageIdx = args.findIndex((arg) => arg === '--message' || arg === '-m');
22
+ if (messageIdx >= 0) {
23
+ return [
24
+ ...args.slice(0, messageIdx),
25
+ '--agent',
26
+ 'main',
27
+ ...args.slice(messageIdx),
28
+ ];
29
+ }
30
+ return [...args, '--agent', 'main'];
31
+ }
11
32
  function buildArgs(baseArgs, prompt) {
12
- // Current OpenClaw one-shot agent turns use: openclaw agent --message "<prompt>".
33
+ // Current OpenClaw one-shot agent turns require an explicit session selector.
13
34
  // Preserve explicit custom args when the message flag is already configured.
14
- if (hasMessageFlag(baseArgs)) {
15
- return [...baseArgs, prompt];
16
- }
17
- if (baseArgs.includes('agent')) {
18
- return [...baseArgs, '--message', prompt];
35
+ const agentArgs = baseArgs.includes('agent')
36
+ ? ensureTargetSelector(baseArgs)
37
+ : [...baseArgs, 'agent', '--agent', 'main'];
38
+ if (hasMessageFlag(agentArgs)) {
39
+ return [...agentArgs, prompt];
19
40
  }
20
- return [...baseArgs, 'agent', '--message', prompt];
41
+ return [...agentArgs, '--message', prompt];
21
42
  }
22
43
  function buildPrompt(input, systemPrompt) {
23
44
  const parts = [];
package/dist/scanner.js CHANGED
@@ -96,6 +96,35 @@ function run(bin, args) {
96
96
  child.on("error", () => resolve(""));
97
97
  });
98
98
  }
99
+ export function parseOpenClawAgentId(output) {
100
+ if (!output.trim())
101
+ return null;
102
+ try {
103
+ const parsed = JSON.parse(output);
104
+ const list = Array.isArray(parsed)
105
+ ? parsed
106
+ : Array.isArray(parsed?.agents)
107
+ ? parsed.agents
108
+ : Array.isArray(parsed?.items)
109
+ ? parsed.items
110
+ : [];
111
+ for (const item of list) {
112
+ const id = typeof item === 'string'
113
+ ? item
114
+ : typeof item?.id === 'string'
115
+ ? item.id
116
+ : typeof item?.agentId === 'string'
117
+ ? item.agentId
118
+ : null;
119
+ if (id?.trim())
120
+ return id.trim();
121
+ }
122
+ }
123
+ catch {
124
+ return null;
125
+ }
126
+ return null;
127
+ }
99
128
  // --- Machine ID (stable per-device identifier) ---
100
129
  const MACHINE_ID_FILE = join(os.homedir(), ".agentbean", "device-id");
101
130
  function getFirstMacAddress() {
@@ -254,15 +283,16 @@ async function checkOpenClawGateway() {
254
283
  const path = await which("openclaw");
255
284
  if (!path)
256
285
  return null;
257
- const status = await run("openclaw", ["gateway", "status"]);
286
+ const status = await run(path, ["gateway", "status"]);
258
287
  const running = status.includes("running") || status.includes("✓");
259
288
  if (running) {
289
+ const agentId = parseOpenClawAgentId(await run(path, ["agents", "list", "--json"])) ?? "main";
260
290
  return {
261
291
  category: "agentos-hosted",
262
292
  name: "OpenClaw-Agent",
263
293
  adapterKind: "openclaw",
264
294
  command: path,
265
- args: [],
295
+ args: ["agent", "--agent", agentId],
266
296
  source: "gateway",
267
297
  };
268
298
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agentbean/daemon",
3
3
  "private": false,
4
- "version": "0.1.25",
4
+ "version": "0.1.26",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "bin": {