anyclaw 0.2.2 → 0.2.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.
@@ -9,9 +9,13 @@ export interface ChannelEvent {
9
9
  type: "content" | "tool_call" | "tool_result" | "error";
10
10
  data: Record<string, unknown>;
11
11
  }
12
+ export interface SendResult {
13
+ content: string;
14
+ conversationId?: string;
15
+ }
12
16
  export interface GatewayAdapter {
13
17
  name: string;
14
- send(gatewayUrl: string, message: string, onEvent: (event: ChannelEvent) => void, signal?: AbortSignal): Promise<string>;
18
+ send(gatewayUrl: string, message: string, onEvent: (event: ChannelEvent) => void, signal?: AbortSignal, conversationId?: string): Promise<SendResult>;
15
19
  }
16
20
  /**
17
21
  * Claw adapter (PaeanClaw / ZeroClaw / 0claw / OpenClaw / NanoClaw)
package/dist/adapters.js CHANGED
@@ -27,24 +27,32 @@ async function readSSEStream(body, handler) {
27
27
  */
28
28
  export const clawAdapter = {
29
29
  name: "claw",
30
- async send(gatewayUrl, message, onEvent, signal) {
30
+ async send(gatewayUrl, message, onEvent, signal, conversationId) {
31
31
  const url = `${gatewayUrl.replace(/\/$/, "")}/api/chat`;
32
+ const body = { message };
33
+ if (conversationId)
34
+ body.conversationId = conversationId;
32
35
  const res = await fetch(url, {
33
36
  method: "POST",
34
37
  headers: { "Content-Type": "application/json" },
35
- body: JSON.stringify({ message }),
38
+ body: JSON.stringify(body),
36
39
  signal,
37
40
  });
38
41
  if (!res.ok || !res.body) {
39
42
  throw new Error(`Gateway error: HTTP ${res.status}`);
40
43
  }
41
44
  let fullContent = "";
45
+ let returnedConversationId;
42
46
  await readSSEStream(res.body, (line) => {
43
47
  if (!line.startsWith("data: "))
44
48
  return;
45
49
  try {
46
50
  const event = JSON.parse(line.slice(6));
47
51
  switch (event.type) {
52
+ case "start":
53
+ if (event.conversationId)
54
+ returnedConversationId = event.conversationId;
55
+ break;
48
56
  case "content":
49
57
  fullContent += event.text || "";
50
58
  onEvent({ type: "content", data: { text: event.text, partial: true } });
@@ -67,7 +75,7 @@ export const clawAdapter = {
67
75
  // skip malformed lines
68
76
  }
69
77
  });
70
- return fullContent;
78
+ return { content: fullContent, conversationId: returnedConversationId };
71
79
  },
72
80
  };
73
81
  /**
@@ -76,7 +84,7 @@ export const clawAdapter = {
76
84
  */
77
85
  export const openaiAdapter = {
78
86
  name: "openai",
79
- async send(gatewayUrl, message, onEvent, signal) {
87
+ async send(gatewayUrl, message, onEvent, signal, _conversationId) {
80
88
  const url = `${gatewayUrl.replace(/\/$/, "")}/v1/chat/completions`;
81
89
  const res = await fetch(url, {
82
90
  method: "POST",
@@ -108,7 +116,7 @@ export const openaiAdapter = {
108
116
  // skip
109
117
  }
110
118
  });
111
- return fullContent;
119
+ return { content: fullContent };
112
120
  },
113
121
  };
114
122
  export function getAdapter(type) {
package/dist/cli.js CHANGED
File without changes
@@ -12,7 +12,7 @@ function parseArgs(args) {
12
12
  gatewayUrl: "http://localhost:3007",
13
13
  gatewayType: "claw",
14
14
  clawKey: "",
15
- serviceUrl: "http://localhost:4777",
15
+ serviceUrl: "https://api.paean.ai",
16
16
  name: "",
17
17
  };
18
18
  for (let i = 0; i < args.length; i++) {
@@ -45,7 +45,7 @@ function parseArgs(args) {
45
45
  }
46
46
  config.clawKey = config.clawKey || process.env.CLAW_KEY || "";
47
47
  config.serviceUrl =
48
- config.serviceUrl || process.env.ANYCLAW_SERVICE_URL || "http://localhost:4777";
48
+ config.serviceUrl || process.env.ANYCLAW_SERVICE_URL || "https://api.paean.ai";
49
49
  config.gatewayUrl =
50
50
  config.gatewayUrl || process.env.GATEWAY_URL || "http://localhost:3007";
51
51
  config.name = config.name || process.env.ANYCLAW_BRIDGE_NAME || "";
@@ -62,7 +62,7 @@ function printHelp() {
62
62
  -g, --gateway <url> Local agent gateway URL (default: http://localhost:3007)
63
63
  -t, --type <type> Gateway type: claw, paeanclaw, zeroclaw, openai (default: claw)
64
64
  -k, --key <key> ClawKey for relay authentication
65
- -s, --service <url> AnyClaw service URL (default: http://localhost:4777)
65
+ -s, --service <url> AnyClaw service URL (default: https://api.paean.ai)
66
66
  -n, --name <name> Display name for this gateway in the web UI
67
67
  -h, --help Show this help
68
68
 
@@ -81,6 +81,7 @@ function printHelp() {
81
81
  const MIN_POLL_MS = 500;
82
82
  const MAX_POLL_MS = 5000;
83
83
  const BACKOFF_FACTOR = 1.5;
84
+ let activeConversationId;
84
85
  async function processRequest(relay, gatewayUrl, gatewayType, requestId, message) {
85
86
  const claimed = await claimRequest(relay, requestId);
86
87
  if (!claimed) {
@@ -97,16 +98,18 @@ async function processRequest(relay, gatewayUrl, gatewayType, requestId, message
97
98
  await pushEvents(relay, requestId, batch);
98
99
  };
99
100
  try {
100
- const fullContent = await adapter.send(gatewayUrl, message, (event) => {
101
+ const result = await adapter.send(gatewayUrl, message, (event) => {
101
102
  eventBatch.push(event);
102
103
  if (eventBatch.length >= 5 ||
103
104
  event.type === "tool_call" ||
104
105
  event.type === "tool_result") {
105
106
  flush();
106
107
  }
107
- });
108
+ }, undefined, activeConversationId);
109
+ if (result.conversationId)
110
+ activeConversationId = result.conversationId;
108
111
  await flush();
109
- await completeRequest(relay, requestId, { content: fullContent });
112
+ await completeRequest(relay, requestId, { content: result.content });
110
113
  console.log(` [done] ${requestId}`);
111
114
  }
112
115
  catch (err) {
@@ -125,7 +128,7 @@ export async function runBridge(args) {
125
128
  }
126
129
  console.log(`\n ▄▀█ █▄░█ █▄█ █▀▀ █░░ ▄▀█ █░█░█`);
127
130
  console.log(` █▀█ █░▀█ ░█░ █▄▄ █▄▄ █▀█ ▀▄▀▄▀`);
128
- console.log(`\n AnyClaw Bridge v0.2.1`);
131
+ console.log(`\n AnyClaw Bridge v0.2.4`);
129
132
  if (config.name)
130
133
  console.log(` Name: ${config.name}`);
131
134
  console.log(` Gateway: ${config.gatewayUrl} (${config.gatewayType})`);
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ function parseArgs() {
18
18
  gatewayUrl: "http://localhost:3007",
19
19
  gatewayType: "claw",
20
20
  clawKey: "",
21
- serviceUrl: "http://localhost:4777",
21
+ serviceUrl: "https://api.paean.ai",
22
22
  };
23
23
  for (let i = 0; i < args.length; i++) {
24
24
  switch (args[i]) {
@@ -46,7 +46,7 @@ function parseArgs() {
46
46
  }
47
47
  config.clawKey = config.clawKey || process.env.CLAW_KEY || "";
48
48
  config.serviceUrl =
49
- config.serviceUrl || process.env.ANYCLAW_SERVICE_URL || "http://localhost:4777";
49
+ config.serviceUrl || process.env.ANYCLAW_SERVICE_URL || "https://api.paean.ai";
50
50
  config.gatewayUrl =
51
51
  config.gatewayUrl || process.env.GATEWAY_URL || "http://localhost:3007";
52
52
  return config;
@@ -62,7 +62,7 @@ function printHelp() {
62
62
  -g, --gateway <url> Local agent gateway URL (default: http://localhost:3007)
63
63
  -t, --type <type> Gateway type: claw, 0claw, paeanclaw, zeroclaw, openai (default: claw)
64
64
  -k, --key <key> ClawKey for relay authentication
65
- -s, --service <url> AnyClaw service URL (default: http://localhost:4777)
65
+ -s, --service <url> AnyClaw service URL (default: https://api.paean.ai)
66
66
  -h, --help Show this help
67
67
 
68
68
  Environment:
@@ -79,6 +79,7 @@ function printHelp() {
79
79
  const MIN_POLL_MS = 500;
80
80
  const MAX_POLL_MS = 5000;
81
81
  const BACKOFF_FACTOR = 1.5;
82
+ let activeConversationId;
82
83
  async function processRequest(relay, gatewayUrl, gatewayType, requestId, message) {
83
84
  const claimed = await claimRequest(relay, requestId);
84
85
  if (!claimed) {
@@ -95,16 +96,18 @@ async function processRequest(relay, gatewayUrl, gatewayType, requestId, message
95
96
  await pushEvents(relay, requestId, batch);
96
97
  };
97
98
  try {
98
- const fullContent = await adapter.send(gatewayUrl, message, (event) => {
99
+ const result = await adapter.send(gatewayUrl, message, (event) => {
99
100
  eventBatch.push(event);
100
101
  if (eventBatch.length >= 5 ||
101
102
  event.type === "tool_call" ||
102
103
  event.type === "tool_result") {
103
104
  flush();
104
105
  }
105
- });
106
+ }, undefined, activeConversationId);
107
+ if (result.conversationId)
108
+ activeConversationId = result.conversationId;
106
109
  await flush();
107
- await completeRequest(relay, requestId, { content: fullContent });
110
+ await completeRequest(relay, requestId, { content: result.content });
108
111
  console.log(` [done] ${requestId}`);
109
112
  }
110
113
  catch (err) {
@@ -123,7 +126,7 @@ async function main() {
123
126
  }
124
127
  console.log(`\n ▄▀█ █▄░█ █▄█ █▀▀ █░░ ▄▀█ █░█░█`);
125
128
  console.log(` █▀█ █░▀█ ░█░ █▄▄ █▄▄ █▀█ ▀▄▀▄▀`);
126
- console.log(`\n AnyClaw Bridge v0.1.0`);
129
+ console.log(`\n AnyClaw Bridge v0.2.4`);
127
130
  console.log(` Gateway: ${config.gatewayUrl} (${config.gatewayType})`);
128
131
  console.log(` Service: ${config.serviceUrl}`);
129
132
  console.log(` Key: ${config.clawKey.slice(0, 8)}...`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anyclaw",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "AnyClaw CLI — bridge, install, and manage local AI agent gateways",
5
5
  "type": "module",
6
6
  "bin": {