dashclaw 2.0.3 → 2.1.1
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/README.md +56 -2120
- package/dashclaw.js +139 -2885
- package/index.cjs +48 -69
- package/legacy/dashclaw-v1.js +2887 -0
- package/legacy/index-v1.cjs +91 -0
- package/package.json +49 -46
package/index.cjs
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* DashClaw SDK
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* DashClaw SDK v2 (Stable Runtime API)
|
|
3
|
+
* CommonJS compatibility bridge.
|
|
4
|
+
*
|
|
5
|
+
* ESM: import { DashClaw } from 'dashclaw'
|
|
6
|
+
* CJS: const { DashClaw } = require('dashclaw')
|
|
5
7
|
*/
|
|
6
8
|
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
|
|
12
|
+
// Minimal CommonJS shim for the v2 SDK
|
|
13
|
+
// We use a simplified bridge that forwards calls to the async ESM import
|
|
7
14
|
let _module;
|
|
8
15
|
|
|
9
16
|
async function loadModule() {
|
|
@@ -13,79 +20,51 @@ async function loadModule() {
|
|
|
13
20
|
return _module;
|
|
14
21
|
}
|
|
15
22
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
module.exports = {
|
|
24
|
+
// Sync wrapper that returns a proxy for the DashClaw class
|
|
25
|
+
DashClaw: class DashClawProxy {
|
|
26
|
+
constructor(opts) {
|
|
27
|
+
this._opts = opts;
|
|
28
|
+
this._ready = loadModule().then(m => {
|
|
29
|
+
this._instance = new m.DashClaw(opts);
|
|
30
|
+
});
|
|
21
31
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
// Support instanceof across ESM/CJS boundary
|
|
38
|
-
loadModule().then(m => {
|
|
39
|
-
if (m.GuardBlockedError) {
|
|
40
|
-
Object.defineProperty(Placeholder, Symbol.hasInstance, {
|
|
41
|
-
value: (instance) => instance && (instance.name === 'GuardBlockedError' || instance instanceof m.GuardBlockedError)
|
|
42
|
-
});
|
|
32
|
+
return new Proxy(this, {
|
|
33
|
+
get(target, prop) {
|
|
34
|
+
if (prop in target) return target[prop];
|
|
35
|
+
if (prop === 'then') return undefined;
|
|
36
|
+
|
|
37
|
+
return async (...args) => {
|
|
38
|
+
await target._ready;
|
|
39
|
+
if (!target._instance[prop]) {
|
|
40
|
+
throw new Error(`Method ${String(prop)} does not exist on DashClaw v2`);
|
|
41
|
+
}
|
|
42
|
+
return target._instance[prop](...args);
|
|
43
|
+
};
|
|
43
44
|
}
|
|
44
45
|
});
|
|
45
|
-
|
|
46
|
-
return Placeholder;
|
|
47
46
|
}
|
|
48
|
-
if (prop === 'DashClaw' || prop === 'OpenClawAgent' || prop === 'default') {
|
|
49
|
-
return class DashClawProxy {
|
|
50
|
-
constructor(opts) {
|
|
51
|
-
this._opts = opts;
|
|
52
|
-
this._ready = loadModule().then(m => {
|
|
53
|
-
const Cls = m.DashClaw || m.default;
|
|
54
|
-
this._instance = new Cls(opts);
|
|
55
|
-
});
|
|
56
47
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
static async create(opts) {
|
|
49
|
+
const mod = await loadModule();
|
|
50
|
+
return new mod.DashClaw(opts);
|
|
51
|
+
}
|
|
52
|
+
},
|
|
62
53
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
});
|
|
72
|
-
}
|
|
54
|
+
// Errors from v2
|
|
55
|
+
ApprovalDeniedError: class ApprovalDeniedError extends Error {
|
|
56
|
+
constructor(message, decision) {
|
|
57
|
+
super(message);
|
|
58
|
+
this.name = 'ApprovalDeniedError';
|
|
59
|
+
this.decision = decision;
|
|
60
|
+
}
|
|
61
|
+
},
|
|
73
62
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
};
|
|
63
|
+
GuardBlockedError: class GuardBlockedError extends Error {
|
|
64
|
+
constructor(decision) {
|
|
65
|
+
super(decision.reason || 'Action blocked by policy');
|
|
66
|
+
this.name = 'GuardBlockedError';
|
|
67
|
+
this.decision = decision;
|
|
81
68
|
}
|
|
82
|
-
return undefined;
|
|
83
69
|
}
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
// Preferred: async factory
|
|
87
|
-
module.exports.create = async function create(opts) {
|
|
88
|
-
const mod = await loadModule();
|
|
89
|
-
const Cls = mod.DashClaw || mod.default;
|
|
90
|
-
return new Cls(opts);
|
|
91
70
|
};
|