hedera-curb 0.4.1 → 0.4.2
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/cli.js +21 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -6,9 +6,24 @@ import { createAuditTopic } from './audit.js';
|
|
|
6
6
|
import { createPolicyRegistry, publishPolicyVersion } from './policy-registry.js';
|
|
7
7
|
import { DEFAULT_CONFIG } from './config.js';
|
|
8
8
|
const flag = (name) => {
|
|
9
|
-
const
|
|
9
|
+
const eq = process.argv.find((a) => a.startsWith(`--${name}=`)); // support --name=value
|
|
10
|
+
if (eq)
|
|
11
|
+
return eq.slice(name.length + 3);
|
|
12
|
+
const i = process.argv.indexOf(`--${name}`); // and --name value
|
|
10
13
|
return i >= 0 ? process.argv[i + 1] : undefined;
|
|
11
14
|
};
|
|
15
|
+
// a numeric flag must parse to a positive, finite number — otherwise we'd publish a garbage policy (NaN caps).
|
|
16
|
+
const num = (name, def) => {
|
|
17
|
+
const raw = flag(name);
|
|
18
|
+
if (raw === undefined)
|
|
19
|
+
return def;
|
|
20
|
+
const n = Number(raw);
|
|
21
|
+
if (!Number.isFinite(n) || n <= 0) {
|
|
22
|
+
console.error(`Invalid --${name}: "${raw}" (expected a positive number).`);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
return n;
|
|
26
|
+
};
|
|
12
27
|
function parseKey(s) {
|
|
13
28
|
for (const parse of [PrivateKey.fromStringECDSA, PrivateKey.fromStringED25519, PrivateKey.fromStringDer]) {
|
|
14
29
|
try {
|
|
@@ -29,6 +44,9 @@ async function init() {
|
|
|
29
44
|
console.error('Missing credentials. Pass --account and --key, or set HEDERA_OPERATOR_ID / HEDERA_OPERATOR_KEY.');
|
|
30
45
|
process.exit(1);
|
|
31
46
|
}
|
|
47
|
+
// validate all input (flags + key) BEFORE any on-chain work, so bad input never creates topics
|
|
48
|
+
const perTask = num('per-task', DEFAULT_CONFIG.perTask);
|
|
49
|
+
const perDay = num('per-day', DEFAULT_CONFIG.perDay);
|
|
32
50
|
console.log(`Provisioning Curb on ${network}…`);
|
|
33
51
|
const client = Client.forName(network).setOperator(account, parseKey(key));
|
|
34
52
|
const auditTopicId = await createAuditTopic(client);
|
|
@@ -37,8 +55,8 @@ async function init() {
|
|
|
37
55
|
agentAccountId: agent,
|
|
38
56
|
auditTopicId,
|
|
39
57
|
...DEFAULT_CONFIG,
|
|
40
|
-
perTask
|
|
41
|
-
perDay
|
|
58
|
+
perTask,
|
|
59
|
+
perDay,
|
|
42
60
|
};
|
|
43
61
|
await publishPolicyVersion(client, config, policyTopicId, 'initial policy').catch(() => { });
|
|
44
62
|
console.log(`\n✓ Audit topic: ${auditTopicId}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hedera-curb",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Verifiable spend-control policies for Hedera AI agents — drop-in Hedera Agent Kit hooks for budgets, allowlists, human approval, and an immutable HCS audit trail.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|