@agentsquared/cli 1.0.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/LICENSE +21 -0
- package/README.md +420 -0
- package/a2_cli.mjs +1576 -0
- package/adapters/index.mjs +79 -0
- package/adapters/openclaw/adapter.mjs +1020 -0
- package/adapters/openclaw/cli.mjs +89 -0
- package/adapters/openclaw/detect.mjs +259 -0
- package/adapters/openclaw/helpers.mjs +827 -0
- package/adapters/openclaw/ws_client.mjs +740 -0
- package/bin/a2-cli.js +8 -0
- package/lib/conversation/policy.mjs +122 -0
- package/lib/conversation/store.mjs +223 -0
- package/lib/conversation/templates.mjs +419 -0
- package/lib/gateway/api.mjs +28 -0
- package/lib/gateway/inbox.mjs +344 -0
- package/lib/gateway/lifecycle.mjs +602 -0
- package/lib/gateway/runtime_state.mjs +388 -0
- package/lib/gateway/server.mjs +883 -0
- package/lib/gateway/state.mjs +175 -0
- package/lib/routing/agent_router.mjs +511 -0
- package/lib/runtime/executor.mjs +380 -0
- package/lib/runtime/keys.mjs +85 -0
- package/lib/runtime/report.mjs +302 -0
- package/lib/runtime/safety.mjs +72 -0
- package/lib/shared/paths.mjs +155 -0
- package/lib/shared/primitives.mjs +43 -0
- package/lib/transport/http_json.mjs +96 -0
- package/lib/transport/libp2p.mjs +397 -0
- package/lib/transport/peer_session.mjs +857 -0
- package/lib/transport/relay_http.mjs +110 -0
- package/package.json +53 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { createOpenClawAdapter, parseOpenClawTaskResult } from './openclaw/adapter.mjs'
|
|
2
|
+
import { detectOpenClawHostEnvironment } from './openclaw/detect.mjs'
|
|
3
|
+
|
|
4
|
+
function clean(value) {
|
|
5
|
+
return `${value ?? ''}`.trim()
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const SUPPORTED_HOST_RUNTIMES = ['openclaw']
|
|
9
|
+
|
|
10
|
+
export async function detectHostRuntimeEnvironment({
|
|
11
|
+
preferred = 'auto',
|
|
12
|
+
openclaw = {}
|
|
13
|
+
} = {}) {
|
|
14
|
+
const normalizedPreferred = clean(preferred).toLowerCase() || 'auto'
|
|
15
|
+
if (normalizedPreferred === 'openclaw') {
|
|
16
|
+
const detection = await detectOpenClawHostEnvironment(openclaw)
|
|
17
|
+
return {
|
|
18
|
+
...detection,
|
|
19
|
+
requested: 'openclaw',
|
|
20
|
+
resolved: 'openclaw',
|
|
21
|
+
explicit: true
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (normalizedPreferred && normalizedPreferred !== 'auto' && normalizedPreferred !== 'none') {
|
|
25
|
+
return {
|
|
26
|
+
id: 'none',
|
|
27
|
+
detected: false,
|
|
28
|
+
requested: normalizedPreferred,
|
|
29
|
+
resolved: 'none',
|
|
30
|
+
confidence: 'low',
|
|
31
|
+
reason: `unsupported-host-runtime:${normalizedPreferred}`,
|
|
32
|
+
supported: SUPPORTED_HOST_RUNTIMES
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (normalizedPreferred === 'none') {
|
|
36
|
+
return {
|
|
37
|
+
id: 'none',
|
|
38
|
+
detected: false,
|
|
39
|
+
requested: 'none',
|
|
40
|
+
resolved: 'none',
|
|
41
|
+
confidence: 'high',
|
|
42
|
+
reason: 'host-runtime-disabled'
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const openclawDetection = await detectOpenClawHostEnvironment(openclaw)
|
|
47
|
+
if (openclawDetection.detected) {
|
|
48
|
+
return {
|
|
49
|
+
...openclawDetection,
|
|
50
|
+
requested: 'auto',
|
|
51
|
+
resolved: 'openclaw'
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
...openclawDetection,
|
|
56
|
+
requested: 'auto',
|
|
57
|
+
resolved: 'none'
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function createHostRuntimeAdapter({
|
|
62
|
+
hostRuntime = 'none',
|
|
63
|
+
localAgentId,
|
|
64
|
+
openclaw = {}
|
|
65
|
+
} = {}) {
|
|
66
|
+
const normalizedHostRuntime = clean(hostRuntime).toLowerCase() || 'none'
|
|
67
|
+
if (normalizedHostRuntime === 'openclaw') {
|
|
68
|
+
return createOpenClawAdapter({
|
|
69
|
+
localAgentId,
|
|
70
|
+
...openclaw
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
return null
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export {
|
|
77
|
+
createOpenClawAdapter,
|
|
78
|
+
parseOpenClawTaskResult
|
|
79
|
+
}
|