anyclaw 0.2.1 → 0.2.3
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/dist/adapters.d.ts +7 -3
- package/dist/adapters.js +18 -7
- package/dist/commands/bridge.js +7 -4
- package/dist/commands/install.js +8 -0
- package/dist/commands/status.js +3 -1
- package/dist/index.js +9 -6
- package/package.json +4 -2
package/dist/adapters.d.ts
CHANGED
|
@@ -9,13 +9,17 @@ 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<
|
|
18
|
+
send(gatewayUrl: string, message: string, onEvent: (event: ChannelEvent) => void, signal?: AbortSignal, conversationId?: string): Promise<SendResult>;
|
|
15
19
|
}
|
|
16
20
|
/**
|
|
17
|
-
* PaeanClaw / ZeroClaw
|
|
18
|
-
*
|
|
21
|
+
* Claw adapter (PaeanClaw / ZeroClaw / 0claw / OpenClaw / NanoClaw)
|
|
22
|
+
* All expose POST /api/chat with SSE response.
|
|
19
23
|
*/
|
|
20
24
|
export declare const clawAdapter: GatewayAdapter;
|
|
21
25
|
/**
|
package/dist/adapters.js
CHANGED
|
@@ -22,29 +22,37 @@ async function readSSEStream(body, handler) {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
-
* PaeanClaw / ZeroClaw
|
|
26
|
-
*
|
|
25
|
+
* Claw adapter (PaeanClaw / ZeroClaw / 0claw / OpenClaw / NanoClaw)
|
|
26
|
+
* All expose POST /api/chat with SSE response.
|
|
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(
|
|
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) {
|
|
@@ -116,6 +124,9 @@ export function getAdapter(type) {
|
|
|
116
124
|
case "claw":
|
|
117
125
|
case "paeanclaw":
|
|
118
126
|
case "zeroclaw":
|
|
127
|
+
case "0claw":
|
|
128
|
+
case "openclaw":
|
|
129
|
+
case "nanoclaw":
|
|
119
130
|
return clawAdapter;
|
|
120
131
|
case "openai":
|
|
121
132
|
return openaiAdapter;
|
package/dist/commands/bridge.js
CHANGED
|
@@ -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
|
|
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:
|
|
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.
|
|
131
|
+
console.log(`\n AnyClaw Bridge v0.2.3`);
|
|
129
132
|
if (config.name)
|
|
130
133
|
console.log(` Name: ${config.name}`);
|
|
131
134
|
console.log(` Gateway: ${config.gatewayUrl} (${config.gatewayType})`);
|
package/dist/commands/install.js
CHANGED
|
@@ -30,6 +30,14 @@ function run(cmd) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
const VARIANTS = {
|
|
33
|
+
"0claw": {
|
|
34
|
+
name: "0claw",
|
|
35
|
+
description: "The absolute core. Minimal Rust agent runtime (~500 lines). MCP tools, SSE, SQLite.",
|
|
36
|
+
methods: [
|
|
37
|
+
{ runtime: "curl", command: "curl -fsSL https://0.works/install.sh | bash", check: () => has("curl") },
|
|
38
|
+
{ runtime: "cargo", command: "cargo install zero-claw", check: () => has("cargo") },
|
|
39
|
+
],
|
|
40
|
+
},
|
|
33
41
|
paeanclaw: {
|
|
34
42
|
name: "PaeanClaw",
|
|
35
43
|
description: "Ultra-minimal local AI agent runtime (~365 lines). MCP tools, web PWA, Telegram.",
|
package/dist/commands/status.js
CHANGED
|
@@ -13,6 +13,7 @@ const B = "\x1b[1m";
|
|
|
13
13
|
const D = "\x1b[0m";
|
|
14
14
|
const TARGETS = [
|
|
15
15
|
{ name: "PaeanClaw", port: 3007, type: "claw", healthPath: "/" },
|
|
16
|
+
{ name: "0claw", port: 3007, type: "claw", healthPath: "/api/conversations" },
|
|
16
17
|
{ name: "ZeroClaw", port: 42617, type: "claw", healthPath: "/" },
|
|
17
18
|
{ name: "OpenAI-compat (LM Studio)", port: 1234, type: "openai", healthPath: "/v1/models" },
|
|
18
19
|
{ name: "OpenAI-compat (vLLM)", port: 8080, type: "openai", healthPath: "/v1/models" },
|
|
@@ -46,6 +47,7 @@ export async function runStatus() {
|
|
|
46
47
|
console.log(` ${B}Installed:${D}`);
|
|
47
48
|
const bins = [
|
|
48
49
|
{ cmd: "paeanclaw", label: "PaeanClaw" },
|
|
50
|
+
{ cmd: "0claw", label: "0claw" },
|
|
49
51
|
{ cmd: "zeroclaw", label: "ZeroClaw" },
|
|
50
52
|
{ cmd: "openclaw", label: "OpenClaw" },
|
|
51
53
|
{ cmd: "nanoclaw", label: "NanoClaw" },
|
|
@@ -73,7 +75,7 @@ export async function runStatus() {
|
|
|
73
75
|
}
|
|
74
76
|
if (!anyRunning) {
|
|
75
77
|
console.log(` ${R}●${D} No running gateways detected.`);
|
|
76
|
-
console.log(` Start a gateway, e.g.: ${C}
|
|
78
|
+
console.log(` Start a gateway, e.g.: ${C}0claw${D} or ${C}paeanclaw${D}`);
|
|
77
79
|
}
|
|
78
80
|
console.log("");
|
|
79
81
|
}
|
package/dist/index.js
CHANGED
|
@@ -60,7 +60,7 @@ function printHelp() {
|
|
|
60
60
|
|
|
61
61
|
Options:
|
|
62
62
|
-g, --gateway <url> Local agent gateway URL (default: http://localhost:3007)
|
|
63
|
-
-t, --type <type> Gateway type: claw, paeanclaw, zeroclaw, openai (default: claw)
|
|
63
|
+
-t, --type <type> Gateway type: claw, 0claw, paeanclaw, zeroclaw, openai (default: claw)
|
|
64
64
|
-k, --key <key> ClawKey for relay authentication
|
|
65
65
|
-s, --service <url> AnyClaw service URL (default: http://localhost:4777)
|
|
66
66
|
-h, --help Show this help
|
|
@@ -72,13 +72,14 @@ function printHelp() {
|
|
|
72
72
|
|
|
73
73
|
Examples:
|
|
74
74
|
anyclaw-bridge -g http://localhost:3007 -k ck_g_abc123
|
|
75
|
-
anyclaw-bridge -g http://localhost:
|
|
75
|
+
anyclaw-bridge -g http://localhost:3007 -t 0claw -k ck_p_xyz789
|
|
76
76
|
`);
|
|
77
77
|
}
|
|
78
78
|
// ── Bridge Loop ────────────────────────────────────────
|
|
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
|
|
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:
|
|
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.
|
|
129
|
+
console.log(`\n AnyClaw Bridge v0.2.3`);
|
|
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.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "AnyClaw CLI — bridge, install, and manage local AI agent gateways",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -24,6 +24,8 @@
|
|
|
24
24
|
"bridge",
|
|
25
25
|
"relay",
|
|
26
26
|
"mcp",
|
|
27
|
+
"0claw",
|
|
28
|
+
"zero-claw",
|
|
27
29
|
"paeanclaw",
|
|
28
30
|
"zeroclaw",
|
|
29
31
|
"openclaw",
|
|
@@ -42,4 +44,4 @@
|
|
|
42
44
|
"@types/node": "^22.0.0",
|
|
43
45
|
"typescript": "^5.7.0"
|
|
44
46
|
}
|
|
45
|
-
}
|
|
47
|
+
}
|