@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.
@@ -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
+ }