@trucore/openclaw-atf 0.2.0 → 0.2.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 CHANGED
@@ -130,7 +130,7 @@ To explicitly allowlist individual tools and customize settings:
130
130
  }
131
131
  },
132
132
  "tools": {
133
- "allowlist": [
133
+ "alsoAllow": [
134
134
  "atf_health",
135
135
  "atf_protect_intent",
136
136
  "atf_verify_receipt",
@@ -130,5 +130,5 @@ openclaw gateway restart
130
130
  # Run integration doctor
131
131
  openclaw tool call atf_integration_doctor
132
132
 
133
- # Expected: status = "ok", all 8 tools available
133
+ # Expected: status = "ok", all 13 tools available
134
134
  ```
package/index.cjs ADDED
@@ -0,0 +1,156 @@
1
+ /**
2
+ * index.cjs — CommonJS compatibility shim for @trucore/openclaw-atf
3
+ *
4
+ * OpenClaw's plugin loader may require() the package entry.
5
+ * This file is a thin CJS bridge to the real ESM plugin at ./src/index.mjs.
6
+ *
7
+ * Exports:
8
+ * - register(api) — OpenClaw lifecycle: register tools
9
+ * - activate(ctx) — OpenClaw lifecycle: activate (config validation)
10
+ * - deactivate() — OpenClaw lifecycle: deactivate (no-op)
11
+ * - default — legacy single-function entry (alias for register)
12
+ *
13
+ * All other named exports are re-exported once the ESM module is loaded.
14
+ *
15
+ * Usage by OpenClaw loader:
16
+ * const plugin = require("@trucore/openclaw-atf");
17
+ * plugin.register(api);
18
+ * plugin.activate(ctx);
19
+ */
20
+
21
+ "use strict";
22
+
23
+ // Cache for the lazily-loaded ESM module.
24
+ let _esmModule = null;
25
+
26
+ /**
27
+ * Lazily import the ESM module. Returns a cached promise after first call.
28
+ * @returns {Promise<object>}
29
+ */
30
+ function loadEsm() {
31
+ if (!_esmModule) {
32
+ _esmModule = import("./src/index.mjs");
33
+ }
34
+ return _esmModule;
35
+ }
36
+
37
+ /**
38
+ * OpenClaw lifecycle: register tools.
39
+ *
40
+ * Loads the ESM module on first call, then delegates to the real register().
41
+ * If the ESM module fails to load, logs a warning and returns gracefully —
42
+ * never crashes the gateway.
43
+ *
44
+ * @param {{ registerTool: Function, config: Record<string, unknown> }} api
45
+ * @returns {Promise<void>}
46
+ */
47
+ async function register(api) {
48
+ try {
49
+ const mod = await loadEsm();
50
+ if (typeof mod.register === "function") {
51
+ mod.register(api);
52
+ } else if (typeof mod.default === "function") {
53
+ mod.default(api);
54
+ }
55
+ } catch (err) {
56
+ if (typeof console !== "undefined") {
57
+ console.warn(
58
+ "[trucore-atf] CJS shim: failed to load ESM module: " +
59
+ (err?.message ?? String(err)) +
60
+ ". ATF CLI fallback is still available.",
61
+ );
62
+ }
63
+ }
64
+ }
65
+
66
+ /**
67
+ * OpenClaw lifecycle: activate plugin.
68
+ *
69
+ * @param {{ config?: Record<string, unknown> }} [ctx]
70
+ * @returns {Promise<void>}
71
+ */
72
+ async function activate(ctx) {
73
+ try {
74
+ const mod = await loadEsm();
75
+ if (typeof mod.activate === "function") {
76
+ mod.activate(ctx);
77
+ }
78
+ } catch (err) {
79
+ if (typeof console !== "undefined") {
80
+ console.warn(
81
+ "[trucore-atf] CJS shim: activate failed: " +
82
+ (err?.message ?? String(err)) +
83
+ ". Plugin is still operational.",
84
+ );
85
+ }
86
+ }
87
+ }
88
+
89
+ /**
90
+ * OpenClaw lifecycle: deactivate plugin.
91
+ *
92
+ * @returns {Promise<void>}
93
+ */
94
+ async function deactivate() {
95
+ try {
96
+ const mod = await loadEsm();
97
+ if (typeof mod.deactivate === "function") {
98
+ mod.deactivate();
99
+ }
100
+ } catch {
101
+ // Deactivate must never throw.
102
+ }
103
+ }
104
+
105
+ // ---- CJS exports ----
106
+
107
+ module.exports = register; // default export = register (legacy compat)
108
+ module.exports.default = register;
109
+ module.exports.register = register;
110
+ module.exports.activate = activate;
111
+ module.exports.deactivate = deactivate;
112
+
113
+ // Re-export everything from the ESM module as a lazy getter on first access.
114
+ // This allows `const { PLUGIN_ID } = require("@trucore/openclaw-atf")`
115
+ // to work once the module is loaded.
116
+ const RE_EXPORT_KEYS = [
117
+ "PLUGIN_ID",
118
+ "PLUGIN_VERSION",
119
+ "buildHumanSummary",
120
+ "REASON_CODE_CATALOG",
121
+ "ATF_BILLING_MANIFEST",
122
+ "evaluateAdoption",
123
+ "TRIGGER_MODEL",
124
+ "INSTALL_GUIDANCE",
125
+ "SAFE_CALL_SEQUENCE",
126
+ "verifyBillingClaim",
127
+ "CLAIM_STATUS",
128
+ "CLAIM_DENY_CODES",
129
+ "TREASURY_ADDRESS",
130
+ "USDC_MINT",
131
+ "KNOWN_PACKAGES",
132
+ "checkDuplicate",
133
+ "_resetClaimTracking",
134
+ "CONTRACT_FAMILIES",
135
+ "TOOL_FAMILY_MAP",
136
+ "CANONICAL_TOOLS",
137
+ "CANONICAL_TOOL_COUNT",
138
+ ];
139
+
140
+ for (const key of RE_EXPORT_KEYS) {
141
+ Object.defineProperty(module.exports, key, {
142
+ configurable: true,
143
+ enumerable: true,
144
+ get() {
145
+ // Synchronous access — returns undefined until ESM is loaded.
146
+ // Call register() or loadEsm() first in async context.
147
+ if (_esmModule && typeof _esmModule.then !== "function") {
148
+ return _esmModule[key];
149
+ }
150
+ return undefined;
151
+ },
152
+ });
153
+ }
154
+
155
+ // Expose loadEsm for tests that need to await ESM initialization.
156
+ module.exports._loadEsm = loadEsm;
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "id": "trucore-atf",
3
3
  "name": "TruCore ATF",
4
- "version": "0.2.0",
4
+ "version": "0.2.1",
5
5
  "description": "Transaction firewall tools for autonomous finance agents: protect + verify + report savings. ATF evaluates swap, lend, and perps intents against policy before they reach the chain. Never signs. Deny-by-default.",
6
6
  "homepage": "https://github.com/trucore-ai/agent-transaction-firewall",
7
- "main": "src/index.mjs",
8
- "extensions": ["src/index.mjs"],
7
+ "main": "index.cjs",
8
+ "extensions": ["index.cjs"],
9
9
  "tools": "optional",
10
10
  "configSchema": {
11
11
  "$schema": "http://json-schema.org/draft-07/schema#",
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@trucore/openclaw-atf",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "OpenClaw plugin — ATF transaction firewall tools for autonomous agents: discover, protect, verify, report savings.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "main": "src/index.mjs",
7
+ "main": "index.cjs",
8
8
  "files": [
9
9
  "src",
10
+ "index.cjs",
10
11
  "examples",
11
12
  "openclaw.plugin.json",
12
13
  "README.md",
@@ -43,7 +44,7 @@
43
44
  },
44
45
  "openclaw": {
45
46
  "extensions": [
46
- "openclaw.plugin.json"
47
+ "index.cjs"
47
48
  ]
48
49
  },
49
50
  "peerDependencies": {
@@ -29,7 +29,7 @@ import { RESPONSE_STATUS } from "./status_codes.mjs";
29
29
  const PRODUCT_ID = "trucore-atf";
30
30
 
31
31
  /** Product version — kept in sync by version consistency tests. */
32
- const PRODUCT_VERSION = "0.2.0";
32
+ const PRODUCT_VERSION = "0.2.1";
33
33
 
34
34
  // ---------------------------------------------------------------------------
35
35
  // Meta builder
package/src/doctor.mjs CHANGED
@@ -37,7 +37,7 @@ import {
37
37
  // Canonical plugin identity — duplicated from index.mjs to avoid circular
38
38
  // import at module level. Kept in sync by version consistency tests.
39
39
  const PLUGIN_ID = "trucore-atf";
40
- const PLUGIN_VERSION = "0.2.0";
40
+ const PLUGIN_VERSION = "0.2.1";
41
41
 
42
42
  // ---------------------------------------------------------------------------
43
43
  // Constants
package/src/index.mjs CHANGED
@@ -99,7 +99,7 @@ const execFileAsync = promisify(execFile);
99
99
  export const PLUGIN_ID = "trucore-atf";
100
100
 
101
101
  /** Plugin version. Must match package.json + openclaw.plugin.json `version`. */
102
- export const PLUGIN_VERSION = "0.2.0";
102
+ export const PLUGIN_VERSION = "0.2.1";
103
103
 
104
104
  // ---------------------------------------------------------------------------
105
105
  // Default config
@@ -218,7 +218,7 @@ async function toolAtfDiscover(cfg, params = {}) {
218
218
  let manifest;
219
219
  try {
220
220
  const res = await fetch(base, {
221
- headers: { "User-Agent": "openclaw-atf-plugin/0.2.0" },
221
+ headers: { "User-Agent": "openclaw-atf-plugin/0.2.1" },
222
222
  signal: AbortSignal.timeout(10_000),
223
223
  });
224
224
  if (!res.ok) {
@@ -393,7 +393,7 @@ async function toolAtfProtectIntent(cfg, params = {}) {
393
393
  method: "POST",
394
394
  headers: {
395
395
  "Content-Type": "application/json",
396
- "User-Agent": "openclaw-atf-plugin/0.2.0",
396
+ "User-Agent": "openclaw-atf-plugin/0.2.1",
397
397
  },
398
398
  body: payloadStr,
399
399
  signal: AbortSignal.timeout(15_000),
@@ -1579,6 +1579,7 @@ export default function atfPlugin(api) {
1579
1579
  required: ["receipt"],
1580
1580
  properties: {
1581
1581
  receipt: {
1582
+ type: ["object", "string"],
1582
1583
  description:
1583
1584
  "Receipt to verify: JSON object, JSON string, or file path.",
1584
1585
  },
@@ -48,7 +48,7 @@ export const RESPONSE_STATUS = _RESPONSE_STATUS;
48
48
  * Kept in sync by version consistency tests.
49
49
  */
50
50
  const PLUGIN_ID = "trucore-atf";
51
- const PLUGIN_VERSION = "0.2.0";
51
+ const PLUGIN_VERSION = "0.2.1";
52
52
 
53
53
  // ---------------------------------------------------------------------------
54
54
  // Backend meta builder